sykpcomposer 0.0.262 → 0.0.263
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-e36a4d21.js → ImageComponent-00bb3a02.js} +3 -3
- package/dist/{ImageComponent-e36a4d21.js.map → ImageComponent-00bb3a02.js.map} +1 -1
- package/dist/{InlineImageComponent-503c44a0.js → InlineImageComponent-2a8ae2a8.js} +3 -3
- package/dist/{InlineImageComponent-503c44a0.js.map → InlineImageComponent-2a8ae2a8.js.map} +1 -1
- package/dist/{LexicalNestedComposer.prod-86c2df5a.js → LexicalNestedComposer.prod-44f9b0cb.js} +2 -2
- package/dist/{LexicalNestedComposer.prod-86c2df5a.js.map → LexicalNestedComposer.prod-44f9b0cb.js.map} +1 -1
- package/dist/{index-61a46ad5.js → index-89c37e6e.js} +159 -159
- package/dist/{index-61a46ad5.js.map → index-89c37e6e.js.map} +1 -1
- package/dist/index.es.js +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1510,7 +1510,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1510
1510
|
`,D.append(k),b=k}!I&&x.width<1&&r.length>1&&(D.style.width="3px")}v.forEach(E=>{this.hoverList.push([E,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(t){let i=!1,e=t.target,s=!1,r=3;for(;r&&e;){if(e.__codox_track){i=!0;break}if(e.__lexicalEditor){i=!0,s=!0;break}e=e.parentNode,r--}if(!i)return;let n=null;for(let a in this.activeEditorsKeys){if(e[`__lexicalKey_${a}`]){n=a;break}e.__lexicalEditor&&(n=e.__lexicalEditor._key)}if(!n)return;let o=s?"root":e[`__lexicalKey_${n}`];if(!o||!this.trackedNodesKeys.has(`${o}__${n}`))return;let l=new Set;for(let a=0;a<this.hoverList.length;a++){let u=this.hoverList[a],[c,f,d]=u;if(l.has(d))continue;let h=oo.isMousePositionWithinElementCords(t,c);t.type===jo.mouseover&&h&&(f.style.animation=this.isEditingInProgress?oo.tooltipAnimations.hideAtOnce:oo.tooltipAnimations.showAtOnce,l.add(d)),t.type===jo.mouseout&&(f.style.animation=oo.tooltipAnimations.hideWithDelay,l.add(d)),t.type===jo.mousemove&&h&&(f.style.animation=this.isEditingInProgress?oo.tooltipAnimations.hideAtOnce:oo.tooltipAnimations.showAtOnce,l.add(d))}}_keyboardEventsListener(t){t.type===jo.keypress&&(this.isEditingInProgress||(this.isEditingInProgress=!0)),t.type===jo.keyup&&this.isEditingInProgress&&(this.isEditingInProgress=!1)}_resizeEventListener(t){Vt.mainEditorExists()&&this.paintRemoteSelections(this.remoteSelections)}mount(){window.addEventListener(jo.keypress,this.keyboardBindedListener),window.addEventListener(jo.keyup,this.keyboardBindedListener),window.addEventListener(jo.resize,this.resizeBindedListener),window.addEventListener(jo.scroll,this.resizeBindedListener);for(const t of u_)window.addEventListener(t,this.mouseBindedListener)}unmount(){window.removeEventListener(jo.keypress,this.keyboardBindedListener),window.removeEventListener(jo.keyup,this.keyboardBindedListener),window.removeEventListener(jo.resize,this.resizeBindedListener),window.removeEventListener(jo.scroll,this.resizeBindedListener);for(const t of u_)window.removeEventListener(t,this.mouseBindedListener);this.gcPrevPaintedRemoteSelections()}shouldUpdateRemoteSelections(){return!0}gcPrevPaintedRemoteSelections(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];for(let i in this.remoteSelectionDOMsMap)this.remoteSelectionDOMsMap[i].remove();this.hoverList=[],this.trackedNodesKeys=new Set,this.remoteSelections=t||[],this.remoteSelectionDOMsMap={},this.activeEditorsKeys={}}paintRemoteSelections(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];this.gcPrevPaintedRemoteSelections(t);let i=Vt.getMainEditorState();i.read&&i.read(()=>{for(let e of this.remoteSelections)if(Rm.validateJSONSelection(e,Pm.remote))if(cn.isNestedSelectionJSON(e)){let{nestedSelectionJSON:s,nestedEditor:r}=cn.getNestedSelectionJSONFromMainSelectionJSON(e);if(!r)continue;r.getEditorState().read(()=>{let n=cn.JSONToLexical(s);if(n)try{this.paintSingleRemoteSelection({editor:r,selectionJSON:e,lexicalSelection:n,selectedNodes:n.getNodes(),isBackward:n.isBackward()})}catch(o){jt.warn("[PAINT REMOTE SELECTION] failed for nested editor - ",{error:o,nestedSelectionJSON:s,fullSelection:e,lexicalSelection:n})}else jt.error("DEBUGGER: [paintRemoteSelections] nested selection from json to lexical is null: ",{selection:e,nestedSelectionJSON:s,lexicalSelection:n})})}else{let s=cn.JSONToLexical(e);if(!s){jt.error("DEBUGGER: [paintRemoteSelections] selection from json to lexical is null: ",{selection:e,lexicalSelection:s});continue}try{this.paintSingleRemoteSelection({editor:Vt.getMainEditor(),selectionJSON:e,lexicalSelection:s,selectedNodes:s.getNodes(),isBackward:s.isBackward()})}catch(r){jt.warn("[PAINT REMOTE SELECTION] failed - ",{error:r,fullSelection:e,lexicalSelection:s})}}})}updateRemoteSelections(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";this.shouldUpdateRemoteSelections(t)&&(jt.log("[updateRemoteSelections] "+i,{newRemoteSelections:t}),Promise.resolve().then(()=>{this.paintRemoteSelections(t),this.hideInUI&&this.hideRemoteSelectionsFromUI()}))}clear(){this.gcPrevPaintedRemoteSelections()}getCurrentRemoteSelections(){return this.remoteSelections}hideRemoteSelectionsFromUI(){this.hideInUI||(this.hideInUI=!0);const t=document.querySelectorAll(".codox_remote_selection");for(let i of t)i.classList.add("hidden_codox_remote_selection")}showHiddenRemoteSelectionsInUI(){this.hideInUI=!1;const t=document.querySelectorAll(".hidden_codox_remote_selection");for(let i of t)i.classList.remove("hidden_codox_remote_selection")}}const Yi=new NA;function PA(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).findIndex(p=>p===ml.editorState)}function xp(p){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,i=Vt.getMainEditorNodesClassesMap();const{klass:e}=i.get(p.type)||{};if(!e)return;const s=e.importJSON(p);if(p.children&&p.children.length)for(const r of p.children)xp(r,s);return t&&t.getChildrenSize&&t.splice(t.getChildrenSize(),0,[s]),s}function wp(p){if(p.getChildren)for(let t of p.getChildren())wp(t);p.remove()}function O_(p){p.__parent=null,p.__next=null,p.__prev=null}function A_(p,t){return!!Vt.isLexicalEditorInstance(p)&&!(typeof t!="object"||!t.editorState||(p.update(()=>{try{let i=(0,Bt.$getSelection)();const e=p.parseEditorState(t.editorState);if(e.isEmpty())return(0,Bt.$getRoot)().clear(),!0;(0,Bt.$setSelection)(i),p.setEditorState(e)}catch(i){jt.error("[stateUpdates][updateNestedEditorState] update nested state and selection error: ",i)}}),0))}function IA(p,t){let i=t;for(const e of p)i=i[e];return i}function bl(p){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,i=arguments.length>2&&arguments[2]!==void 0&&arguments[2],e=null,s=IA(p,i?t:Vt.getMainEditorState().toJSON());return s&&(e=_l(s)?(0,Bt.$getRoot)():kr.get(s.codoxId)),e||jt.debug("[WARNING][getLexicalNodeByPathOutOfJSONState] lexical node not found: ",{jsonNode:s,lexicalNode:e,pathArray:p,currentStateJSON:Vt.getMainEditorState().toJSON(),newStateJSON:t,codoxNodes:kr.nodesToArray(),searchInNewState:i}),e||(i?e:bl(p,t,!0))}function j_(p){jt.log("[applyFullLexicalStateReplace] clear current state and apply new");const t=(0,Bt.$getRoot)();t.clear();let i=Vt.getMainEditorNodesClassesMap();function e(s){const r=i.get(s.type).klass.importJSON(s);if(s.children)for(const n of s.children)r.append(e(n));return r}for(const s of p.root.children)t.append(e(s))}function MA(p){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];if(t.length){jt.log("[applyDeltasToLexicalState] Original Deltas: ",{newStateJSON:p,deltas:JSON.parse(JSON.stringify(t))});for(const i of t){let{p:e}=i;const s=e[e.length-1],r=s==="children",n=typeof s=="number",o=!n&&!r,l=PA(e),a=l!==-1,u=i.hasOwnProperty("lm")&&typeof i.lm=="number";if(e.length)if(a){let c=l-1,f=bl(e.slice(0,c),p);if(f){let d=e.slice(0,l),h=p;for(const g of d)h=h[g];let m=sd(e[c]);A_(f.getWritable()[m],h)}}else{if(r){let c=i.oi;if(!c){jt.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi attr expected for path",{delta:i});continue}if(c.some(d=>!(!d.hasOwnProperty("text")||typeof d.text=="string"))){jt.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi children contain invalid text value",{delta:i});continue}e.length=e.length-1;let f=bl(e,p);if(!f)continue;if(c.some(d=>!!d.codoxDId)){try{f=f.getWritable()}catch(g){jt.debug("[applyDeltasToLexicalState][shouldUpdateLeaves] getWritable error: ",{err:g,delta:i,fullStateJSON:p});continue}let d={};for(let g of f.getChildren())g.codoxDId?d[g.codoxDId]=g:wp(g);let h=[],m=["codoxDId","codoxId","__key","__parent","__prev","__next"];for(let g=0;g<c.length;g++){let _=c[g],v=g===0,b=g===c.length-1,S=null,E=g>=0?h[g-1]:null;if(_.codoxDId){let x=d[_.codoxDId];if(x){x=x.getWritable();let y=xp(_);if(jt.debug("[DELTA_DECORATOR_UPDATE]: ",{exisingDecorator:x,tmpDecorator:y}),!y){jt.debug("[DELTA_DECORATOR_UPDATE] UPADATE SKIPPED: ",{exisingDecorator:x,tmpDecorator:y});continue}for(let w in y)if(y.hasOwnProperty(w)&&!m.includes(w))if(Vt.isLexicalEditorInstance(y[w])){let C={editorState:y[w].getEditorState().toJSON()};A_(x[w],C)}else{let C=Nm(w),j=_[C];if(j===x[w]||!_.hasOwnProperty(C))continue;let P=j!==void 0&&y[w]!==j?j:y[w];C!=="height"&&C!=="width"||y[w]==="inherit"&&j===0&&(P=y[w]),x[w]=P}y.remove(),O_(x),S=x,delete d[_.codoxDId]}}S||(S=xp(_),S.codoxDId&&S.__type==="excalidraw"&&S.__data==="[]"&&(S.__data="{}")),S=S.getWritable(),h.push(S),S.__parent=f.__key,v?(f.__first=S.__key,S.__prev=null,b&&(f.__last=S.__key)):b?(f.__last=S.__key,S.__next=null,S.__prev=E.__key,E.__next=S.__key):(S.__prev=E.__key,E.__next=S.__key),f.__size=h.length}for(let g in d){let _=d[g];_=_.getWritable(),O_(_),wp(_),delete d[g]}}else{let d=c.map(h=>xp(h));f.splice(0,f.getChildrenSize(),d)}}if(n){if(i.ld){const c=i.ld,f=kr.get(c.codoxId);f.getChildrenSize&&f.getChildrenSize()?wp(f):f.remove()}if(i.li){let c=Vt.getMainEditorNodesClassesMap();const f=i.li,d=c.get(f.type).klass.importJSON(f);if(e.length===1&&e[0]==="root")(0,Bt.$getRoot)().splice(0,0,[d]);else{const h=e[e.length-1];e.length=e.length-2;let m=bl(e,p);m&&m.splice(h,0,[d])}if(f.children&&f.children.length){let h=function(m,g){const _=c.get(m.type).klass.importJSON(m);if(g.splice(g.getChildrenSize(),0,[_]),m.children&&m.children.length)for(const v of m.children)h(v,_)};for(const m of f.children)h(m,d)}}if(i.oi||i.od){let{p:c,oi:f,od:d}=i,h=bl(c,p);if(h)try{let m=h.getWritable();if(f){let g=Object.keys(f);for(let _ of g)m[sd(_)]=f[_]}if(d){let g=Object.keys(d);for(let _ of g)delete m[sd(_)]}}catch(m){jt.debug("[applyDeltasToLexicalState][delta oi/od] getWritable error: ",{err:m,delta:i})}}if(u){let{p:c,lm:f}=i,d=c[c.length-1],h=f,m=h<d,g=bl(c,p);if(g){let _=g.getParent().getChildren(),v=_[d],b=_[h];m?b.insertBefore(v):b.insertAfter(v)}}}if(o){const c=e[e.length-1];let f=sd(c);e.length=e.length-1;let d,h=bl(e,p);if(!h){jt.error("Missing node when update node attr from delta: ",{path:e,delta:i,fullStateJSON:p,currentEditorState:Vt.getMainEditorState().toJSON()});continue}try{d=h.getWritable()}catch(g){jt.debug("[applyDeltasToLexicalState][shouldUpdateBlockAttr] getWritable error: ",{err:g,delta:i})}if(!d)continue;let m=i.oi;if(c==="format"&&(m=IO(m)),c==="direction"&&(h.hasOwnProperty(f)||(f="__dir")),!d.hasOwnProperty(f)){let g=Object.keys(d);for(let _ of g){let v=Nm(_);if(c.startsWith(v)){f=_;break}}}d[f]=m}}else if(i.oi&&i.oi.root)return j_(i.oi)}}else jt.log("[applyDeltasToLexicalState] stop, no deltas: ",t)}function RA(p){let t=null,i=!1;try{t=p.clipboardData.getData(RO.paste),t=JSON.parse(t),typeof t=="object"&&t.nodes&&Array.isArray(t.nodes)&&(i=!0)}catch{return!1}if(!i)return!1;if(i){kr.clearPastedIds();const e=s=>{if(s.codoxId&&kr.addPastedId(s.codoxId),s.children&&s.children.length)for(const r of s.children)e(r)};for(const s of t.nodes)e(s)}return!1}var DA=p=>{var t={};return On.d(t,p),t};const N_=DA({useCollaborationContext:()=>pp});var LA=p=>{var t={};return On.d(t,p),t};const Os=LA({LexicalComposerContext:()=>wu,useLexicalComposerContext:()=>Yn});class P_{constructor(){this.blacklist=Object.keys(d_).reduce((t,i)=>{let e=d_[i];return t[i]=e.reduce((s,r)=>(s[r]=r,s),{}),t},{}),this._isBlacklistedFound=!1,this._clientCallback=null}_shouldSkipNode(t){return t instanceof Bt.TextNode||t instanceof Bt.ParagraphNode||t instanceof Bt.RootNode}setClientCallback(t){this._clientCallback=t}removeClientCallback(){this._clientCallback=null}invokeClientCallback(){this._clientCallback&&this._clientCallback()}trackBlacklisted(t){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",e=arguments.length>2?arguments[2]:void 0;if(Dm||i!==mi.created||this._isBlacklistedFound||!t||!t.__type||this._shouldSkipNode(t))return;let s=e||Vt.getMainEditorState(),r=t.__type,n=this.blacklist[r];n&&s.read(()=>{let o=t.getParent();for(;o!==null;){let l=o?o.__type:null;if(!l)return;if(n[l])return jt.warn("[ContentNestingsWatcher][trackBlacklisted] FOUND: ",{targetNode:t,targetType:r,parent:o,parentType:l,mutationType:i}),void(this._isBlacklistedFound=!0);o=o.getParent()}})}trackBlacklistedInNestedEditor(t){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",e=arguments.length>3?arguments[3]:void 0;if(i!==mi.created||this._isBlacklistedFound||this._shouldSkipNode(t))return;let s=e.__type,r=t.__type;if(!s||!r)return;let n=this.blacklist[r];n&&n[s]&&(this._isBlacklistedFound=!0,jt.warn("[ContentNestingsWatcher][trackBlacklistedInNestedEditor] FOUND: ",{targetNode:t,targetType:r,rootNode:e,rootType:s,mutationType:i}))}isBlacklistedFound(){let t=this._isBlacklistedFound;return t&&(this._isBlacklistedFound=!1),t}}const FA=new P_,As=FA,BA=["editorState","prevEditorState","dirtyElements","dirtyLeaves"];function zA(p,t){if(p==null)return{};var i,e,s=UA(p,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(p);for(e=0;e<r.length;e++)i=r[e],t.includes(i)||{}.propertyIsEnumerable.call(p,i)&&(s[i]=p[i])}return s}function UA(p,t){if(p==null)return{};var i={};for(var e in p)if({}.hasOwnProperty.call(p,e)){if(t.includes(e))continue;i[e]=p[e]}return i}class HA{constructor(){this.nestedEditorsListenersMap={}}_createNestedEditorUpdatesListener(t,i){let e=!1;return function(s){let{editorState:r,prevEditorState:n,dirtyElements:o,dirtyLeaves:l}=s,a=(zA(s,BA),Vt.getMainEditor()),u=Vt.getMainEditorState(),c=r.toJSON(),f=n.toJSON(),d=Mm(c,f),h=r._selection,m=n._selection,g=!1,_=null,v=Vt.isOnlySelectionChanged(o,l),b=t[i];if(jt.debug("[NESTED EDITOR LISTENER] invoked: ",{lexicalNode:t,key:t.__key,onlySelectionChanged:v,newEditorStateJSON:c,prevEditorStateJSON:f,isSameState:d,lexicalSelection:h,prevLexicalSelection:m,mainDirtyLeaves:a._dirtyLeaves.size,mainDirtyElements:a._dirtyElements.size,nestedDirtyLeaves:b._dirtyLeaves.size,nestedDirtyElements:b._dirtyElements.size,nestedEditorKey:b._key}),As.isBlacklistedFound())return e=!0,jt.debug("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - revert to prev state"),Vt.scanLexicalNodeForNestedEditorAttribute(t)?(b.update(()=>{try{const S=b.parseEditorState(f);if(S.isEmpty())return(0,Bt.$getRoot)().clear(),!0;b.setEditorState(S)}catch(S){jt.error("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - ROLLBACK ERROR: ",S)}}),void As.invokeClientCallback()):void 0;if(e)e=!1;else{if(t.codoxId||t.codoxDId){let S=null;u.read(()=>{S=cn.getNodeAncestorsCodoxIds(t),!t.codoxId&&t.codoxDId&&S.push(t.codoxDId)}),r.read(()=>{let E=Nm(i),x=cn.lexicalToJSONNested(h,E,S);_=Vt.getCurrentNestedSelectionJSON(),g=cn.equalSelectionsJSON(_,x),g||Vt.setNestedSelectionJSON(x)})}d&&g||a.update(()=>{try{jt.debug("[NESTED EDITOR LISTENER] MARKING DIRTY TO TRIGGER UPDATE",{mainTags:a._updateTags,nestedTags:b&&b._updateTags,isSameState:d,isSameSelection:g,onlyNestedSelectionChanged:v,mainDirtyLeaves:a._dirtyLeaves.size,mainDirtyElements:a._dirtyElements.size,nestedDirtyLeaves:b._dirtyLeaves.size,nestedDirtyElements:b._dirtyElements.size,lexicalNode:t,lexicalSelection:h,prevLexicalSelection:m,mainEditorTags:a._updateTags,mainEditorTagsSize:a._updateTags.size}),Vt.addUpdateTag({fromNestedEditor:!0}),t.markDirty()}catch(S){jt.error("[NESTED EDITOR LISTENER] MARKING DIRTY TO TRIGGER UPDATE - ERROR: ",S)}})}}}_isNestedEditorManaged(t){return!!this.nestedEditorsListenersMap[t]}gc(){for(let t in this.nestedEditorsListenersMap)if(!Vt.getLexicalNodeByKey(t)){let i=this.nestedEditorsListenersMap[t];i&&i(),delete this.nestedEditorsListenersMap[t]}}manageNestedEditorInLexicalNode(t){if(this._isNestedEditorManaged(t.getKey()))return;let i=Vt.scanLexicalNodeForNestedEditorAttribute(t);if(i){let e=t[i],s=this._createNestedEditorUpdatesListener(t,i),r=[];e._nodes.forEach((l,a,u)=>{let{klass:c}=l,f=e.registerMutationListener(c,d=>{for(let[h,m]of d)if(m===mi.created){let g=e.getEditorState()._nodeMap.get(h);g&&As.trackBlacklistedInNestedEditor(g,m,e.getEditorState(),t)}});r.push(f)});let n=(0,bc.mergeRegister)(e.registerUpdateListener(s),...r),o=t.getKey();this.nestedEditorsListenersMap[o]=n}}gcNestedEditorListenerInLexicalNode(t){let i=t.getKey(),e=this.nestedEditorsListenersMap[i];e&&(e(),delete this.nestedEditorsListenersMap[i])}manageNestedEditorInClonedLexicalNode(t,i){let e=t.getKey();e!==i.getKey()&&this._isNestedEditorManaged(e)&&(this.gcNestedEditorListenerInLexicalNode(t),this.manageNestedEditorInLexicalNode(i))}setNestedEditorSelection(t){let{nestedSelectionJSON:i,nestedEditor:e}=cn.getNestedSelectionJSONFromMainSelectionJSON(t);if(!e)return!1;let s=!0;return e.update(()=>{try{let r=cn.JSONToLexical(i);(0,Bt.$setSelection)(r),jt.debug("[setNestedEditorSelection]: lexical nested selection: ",r)}catch(r){jt.error("[setNestedEditorSelection] set nested selection error: ",r),s=!1}}),s}clearListeners(){for(let t in this.nestedEditorsListenersMap){let i=this.nestedEditorsListenersMap[t];i&&i(),delete this.nestedEditorsListenersMap[t]}}}const $A=new HA,Ja=$A,qA=function(p){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];try{let i=(0,Bt.createEditor)({namespace:"validation",nodes:[...t],onError:o=>{throw o},parentEditor:null});const e=new P_,s=i.parseEditorState(p);if(s.isEmpty())return;i.setEditorState(s);let r=i.getEditorState();const n=r._nodeMap[Symbol.iterator]();for(const o of n){let[l,a]=o;if(a&&(e.trackBlacklisted(a,mi.created,r),e.isBlacklistedFound()))throw new Error(DO)}}catch(i){throw i}};class WA{constructor(){this.removeCandidateTableKeys=new Set,this.validateTableCandidateKeys=new Set,this.tableFixActions=[]}_scanForCellHeaderState(t,i,e,s){if(i.length<s)return null;let r,n=i.some(l=>l.__headerState===ks.BOTH||l.__headerState===ks.ROW),o=t.some((l,a)=>{if(l.__size<s)return!1;let u=l.getChildAtIndex(e);return!(!u||u.__headerState!==ks.BOTH&&u.__headerState!==ks.COLUMN)});return n&&o?r=ks.BOTH:n&&!o?r=ks.ROW:o&&!n&&(r=ks.COLUMN),r}_isValidCellChildren(t){for(let i of t)if(Ec(i)||!Sc(i)&&vr(i))return!1;return!0}_createEmptyCell(){let t=(0,Er.$createTableCellNode)();return t.append((0,Bt.$createParagraphNode)()),t}_wrapInvalidCellChildrenIntoParagraph(t){let i=(0,Bt.$createParagraphNode)().getWritable(),e=t.getChildren();(t=t.getWritable()).__first=i.__key,t.__last=i.__key,t.__size=1,i.__parent=t.__key,e.forEach((s,r)=>{(s=s.getWritable()).__parent=null,i.append(s)})}_createFixAction_APPEND_CELLS_TO_ROW(t,i){return()=>{jt.debug("[TablesValidator][FIX TABLE ACTION - APPEND_CELLS_TO_ROW] invoked: ",{rowKey:t,numOfCellsToAppend:i});let e=(0,Bt.$getNodeByKey)(t);for(;i;){let s=(0,Er.$createTableCellNode)().append((0,Bt.$createParagraphNode)());s.setRowSpan(1).setColSpan(1),e.append(s),i--}}}_createFixAction_ADD_PARAGRAPH_TO_EMPTY_CELL(t){return()=>{jt.debug("[TablesValidator][FIX TABLE ACTION - ADD_PARAGRAPH_TO_EMPTY_CELL] invoked: ",{cellKey:t}),(0,Bt.$getNodeByKey)(t).append((0,Bt.$createParagraphNode)())}}_createFixAction_WRAP_CELL_CHILDREN_IN_PARAGRAPH(t){return()=>{jt.debug("[TablesValidator][FIX TABLE ACTION - WRAP_CELL_CHILDREN_IN_PARAGRAPH] invoked: ",{cellKey:t});let i=(0,Bt.$getNodeByKey)(t);this._wrapInvalidCellChildrenIntoParagraph(i)}}_createFixAction_ADD_ROW_CELL_TO_TABLE_NODE(t){return()=>{jt.debug("[TablesValidator][FIX TABLE ACTION - ADD_ROW_CELL_TO_EMPTY_TABLE_NODE] invoked: ",{tableKey:t});let i=(0,Bt.$getNodeByKey)(t),e=(0,Er.$createTableRowNode)();e.append(this._createEmptyCell()),i.append(e)}}_createFixAction_ADD_CELL_TO_EMPTY_ROW_NODE(t,i){return()=>{for(i||(i=1);i;)(0,Bt.$getNodeByKey)(t).append(this._createEmptyCell()),i--}}_createFixAction_WRAP_INVALID_ROW_NODE(t,i){return()=>{jt.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_ROW_NODE] invoked: ",{tableKey:t,rowKey:i});let e=(0,Bt.$getNodeByKey)(t);if(!e)return;let s=(0,Bt.$getNodeByKey)(i);if(!s)return;e=e.getWritable(),s=s.getWritable();let r=s.getPreviousSibling(),n=s.getNextSibling();s.__parent=null,s.__prev=null,s.__next=null;let o=(0,Er.$createTableRowNode)();if((0,Er.$isTableCellNode)(s))s.getChildren().length?this._isValidCellChildren()||this._wrapInvalidCellChildrenIntoParagraph(s):s.append((0,Bt.$createParagraphNode)()),o.append(s);else{let l=this._isValidCellChildren([s]),a=(0,Er.$createTableCellNode)();if(o.append(a),l)a.append(s);else{let u=(0,Bt.$createParagraphNode)();u.append(s),a.append(u)}}o.__parent=e.__key,e.__first===s.__key&&(e.__first=o.__key),e.__last===s.__key&&(e.__last=o.__key),r&&(r=r.getWritable(),r.__next=o.__key,o.__prev=r.__key),n&&(n=n.getWritable(),n.__prev=o.__key,o.__next=n.__key)}}_createFixAction_WRAP_INVALID_CELL_NODE(t,i){return()=>{jt.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_CELL_NODE] invoked: ",{rowKey:t,cellKey:i});let e=(0,Bt.$getNodeByKey)(t);if(!e)return;let s=(0,Bt.$getNodeByKey)(i);if(s.remove(),s=(0,Bt.$createParagraphNode)(),!s)return;e=e.getWritable(),s=s.getWritable();let r=s.getPreviousSibling(),n=s.getNextSibling(),o=(0,Er.$createTableCellNode)();if(o.__parent=e.__key,e.__first===s.__key&&(e.__first=o.__key),e.__last===s.__key&&(e.__last=o.__key),r&&(r=r.getWritable(),r.__next=o.__key,o.__prev=r.__key),n&&(n=n.getWritable(),n.__prev=o.__key,o.__next=n.__key),s.__parent=null,s.__prev=null,s.__next=null,this._isValidCellChildren([s]))o.append(s);else{let l=(0,Bt.$createParagraphNode)();l.append(s),o.append(l)}}}_createFixAction_APPLY_HEADER_STATE_TO_CELL(t,i){return()=>{jt.debug("[TablesValidator][FIX TABLE ACTION - APPLY_HEADER_STATE_TO_CELL] invoked: ",{cellKey:t,headerStateToApply:i});let e=(0,Bt.$getNodeByKey)(t);e&&(e=e.getWritable(),e.__headerState=i)}}clear(){this.removeCandidateTableKeys=new Set,this.validateTableCandidateKeys=new Set,this.tableFixActions=[]}tableRemoveEventListener(t){let i=Vt.getMainEditorState()._selection;if(jt.debug(`[${t}]`,{selection:i}),!(0,Bt.$isRangeSelection)(i))return;let e=[];try{let s=Vt.getLexicalNodeByKey(i.anchor.key),r=Vt.getLexicalNodeByKey(i.focus.key);s&&r&&(e=i.isBackward()?r.getNodesBetween(s):s.getNodesBetween(r))}catch(s){jt.warn("[TablesValidator][tableRemoveEventListener] get range selection nodes internal lexical error: ",s)}e.forEach(s=>{(0,Er.$isTableNode)(s)&&this.removeCandidateTableKeys.add(s.__key)})}tableNodeRemoveListener(t){this.removeCandidateTableKeys.has(t)&&this.removeCandidateTableKeys.delete(t)}shouldGCRemovedTables(){return!!this.removeCandidateTableKeys.size}gcRemovedTables(){jt.debug("[TablesValidator][gcRemovedTable] candidate table keys ",{tableKeys:this.removeCandidateTableKeys}),Vt.getMainEditor().update(()=>{Array.from(this.removeCandidateTableKeys).forEach(t=>{let i=(0,Bt.$getNodeByKey)(t);i&&i.remove()}),this.removeCandidateTableKeys.clear(),(0,Bt.$addUpdateTag)(Ni.historic)})}tableUpdateListener(t){this.validateTableCandidateKeys.add(t)}tableRowNodeChangesListener(t){let i=arguments.length>1&&arguments[1]!==void 0&&arguments[1],e=Vt.getLexicalNodeByKey(t);if(!e)return void(i&&jt.debug("[TablesValidator][tableRowNodeChangesListener] no row node found in lexical: ",{tableRowNodeKey:t}));let s=e.__parent;s?this.validateTableCandidateKeys.add(s):jt.debug("[tableRowNodeChangesListener] no parent table for row node found in lexical: ",{rowNode:e})}tableCellNodeChangesListener(t){let i=Vt.getLexicalNodeByKey(t);if(!i||!i.__parent)return;let e=Vt.getLexicalNodeByKey(i.__parent);e&&e.__parent&&this.validateTableCandidateKeys.add(e.__parent)}shouldValidateUpdatedTables(){return!!this.validateTableCandidateKeys.size}validateUpdatedTables(){let t=Array.from(this.validateTableCandidateKeys);return Vt.getMainEditorState().read(()=>{for(let i of t){let e=Vt.getLexicalNodeByKey(i);if(!e)continue;let s=e.getChildren();if(!s.length){this.tableFixActions.push(this._createFixAction_ADD_ROW_CELL_TO_TABLE_NODE(i));continue}let r=0;s.forEach(a=>{a.__size>r&&(r=a.__size)});let n=[],o=s.map((a,u)=>{if(!(0,Er.$isTableRowNode)(a))return this.tableFixActions.push(this._createFixAction_WRAP_INVALID_ROW_NODE(i,a.__key)),"invalid_row_node";let c=a.getChildren();if(!c.length&&!n.length)return this.tableFixActions.push(this._createFixAction_ADD_CELL_TO_EMPTY_ROW_NODE(a.__key,r)),"empty_row_should_add_cell";if(!c.length&&n.length)return n=[],"empty_row_should_be_empty";let f=0;if(n.length){let h=[];n.forEach(m=>{let[g,_]=m;f+=_,g--,g&&h.push([g,_])}),n=[...h]}let d=c.map((h,m)=>{if(!(0,Er.$isTableCellNode)(h))return this.tableFixActions.push(this._createFixAction_WRAP_INVALID_CELL_NODE(a.__key,h.__key)),f++,"invalid_cell_node_should_wrap_in_cell";let g,_=h.getChildren(),v=!_.length;if(v?this.tableFixActions.push(this._createFixAction_ADD_PARAGRAPH_TO_EMPTY_CELL(h.__key)):(g=this._isValidCellChildren(_),g||this.tableFixActions.push(this._createFixAction_WRAP_CELL_CHILDREN_IN_PARAGRAPH(h.__key))),h.__rowSpan>1){let b=h.__rowSpan,S=h.__colSpan;n.push([b-1,S])}if(f+=h.__colSpan,h.__headerState===ks.NO_STATUS){let b=this._scanForCellHeaderState(s,c,m,r);b&&this.tableFixActions.push(this._createFixAction_APPLY_HEADER_STATE_TO_CELL(h.__key,b))}return{cellKey:h.__key,rowKey:a.__key,tableKey:i,colSpan:h.__colSpan,rowSpan:h.__rowSpan,headerState:h.__headerState,childrenAreValid:g,isEmptyCell:v}});if(f<r){let h=r-f;this.tableFixActions.push(this._createFixAction_APPEND_CELLS_TO_ROW(a.__key,h))}return{realRowLength:f,rowKey:a.__key,tableKey:i,cells:d}}),l=!this.tableFixActions.length;jt[l?"debug":"warn"](`[TablesValidator][validateUpdatedTables] IS TABLE VALID: ${l}`,{tableNodeKey:i,tableValidationMatrix:o,requiredRowLength:r}),this.validateTableCandidateKeys.delete(i)}}),!this.tableFixActions.length}shouldFixTablesStructure(){return!!this.tableFixActions.length}fixTablesStructure(){if(!this.tableFixActions.length)return;let t=Vt.getMainEditor();jt.log("[TablesValidator][fixTablesStructure]: fix actions to apply - count: ",this.tableFixActions.length),t.update(()=>{for(let i of this.tableFixActions)i();this.tableFixActions=[],(0,Bt.$addUpdateTag)(Ni.historic)})}ensureDocTablesAreValid(t){return this.shouldGCRemovedTables()?(jt.warn("[TablesValidator][GARBAGE COLLECT TABLE NODES AFTER TABLE REMOVAL ATTEMPT]"),this.gcRemovedTables(),!1):!(this.shouldValidateUpdatedTables()&&(jt.debug("[TablesValidator][shouldValidateUpdatedTables] invoked"),!this.validateUpdatedTables()))||(jt.warn("[TablesValidator][shouldValidateUpdatedTables] INVALID LEXICAL TABLE(S) STRUCTURE FOUND - FIXING",{state:JSON.parse(JSON.stringify(t.toJSON()))}),this.fixTablesStructure(),!1)}}const ma=new WA,VA=["contentChanged"],JA=["state","remoteSelection"];function I_(p,t){var i=Object.keys(p);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(p);t&&(e=e.filter(function(s){return Object.getOwnPropertyDescriptor(p,s).enumerable})),i.push.apply(i,e)}return i}function xc(p){for(var t=1;t<arguments.length;t++){var i=arguments[t]!=null?arguments[t]:{};t%2?I_(Object(i),!0).forEach(function(e){GA(p,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(i)):I_(Object(i)).forEach(function(e){Object.defineProperty(p,e,Object.getOwnPropertyDescriptor(i,e))})}return p}function GA(p,t,i){return(t=KA(t))in p?Object.defineProperty(p,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):p[t]=i,p}function KA(p){var t=YA(p,"string");return typeof t=="symbol"?t:t+""}function YA(p,t){if(typeof p!="object"||!p)return p;var i=p[Symbol.toPrimitive];if(i!==void 0){var e=i.call(p,t||"default");if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(p)}function M_(p,t){if(p==null)return{};var i,e,s=ZA(p,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(p);for(e=0;e<r.length;e++)i=r[e],t.includes(i)||{}.propertyIsEnumerable.call(p,i)&&(s[i]=p[i])}return s}function ZA(p,t){if(p==null)return{};var i={};for(var e in p)if({}.hasOwnProperty.call(p,e)){if(t.includes(e))continue;i[e]=p[e]}return i}const Dm={DEBUG:!1,VERSION:"1.0.5",NAME:"@codoxhq/lexical-provider",SDKUI_SOURCE_PATH:"../../../sdkui/dist-production2/codox.bundle.js"}.LOCAL==="true";jt.info("MODE: ","production");const QA=p=>async()=>{const{state:t,timestamp:i}=await p();if(!Vt.isValidJSONState(t))throw new Error("Invalid state received from fetchDocOnNetworkReconnect hook");const{commentThreads:e,root:s}=t,r={content:{comments:e,root:s},timestamp:i};return jt.info("[decorateFetchOnReconnctHook] hook invoked: ",{returnObj:r}),r};let Sp=0,vl=null,Lm=!1,Pi={},Fm={};const XA=(0,ft.forwardRef)((p,t)=>{let{onBlacklistedInsert:i}=p;const e=(0,ft.useContext)(Os.LexicalComposerContext);if(!e)throw new Error("[CodoxCollabPlugin] CodoxCollabPlugin must be inited inside <LexicalComposer> component - LexicalComposerContext is missing");const[s]=(0,Os.useLexicalComposerContext)(),r=(0,N_.useCollaborationContext)();(0,ft.useEffect)(()=>{if(jt.debug("[INIT] lexical context check: ",{lexicalContext:e,editor:s}),!s)return;jt.log("[useEffect][editor] Editor instance changed: ",{editor:s,key:s._key}),Vt.setMainEditor(s),kr.gcAbandonedNodes(),Ja.gc(),ma.clear(),jt.log("[useEffect][editor] subscribe to editor changes");const v=(0,bc.mergeRegister)(s.registerUpdateListener(m),s.registerCommand(Bt.PASTE_COMMAND,RA,Bt.COMMAND_PRIORITY_CRITICAL),s.registerCommand(Bt.UNDO_COMMAND,()=>{Vt.setUndoInvoked(!0)},Bt.COMMAND_PRIORITY_CRITICAL),s.registerCommand(Bt.REDO_COMMAND,()=>{Vt.setRedoInvoked(!0)},Bt.COMMAND_PRIORITY_CRITICAL),s.registerCommand(Bt.KEY_DELETE_COMMAND,(S,E)=>{ma.tableRemoveEventListener("KEY_DELETE_COMMAND")},Bt.COMMAND_PRIORITY_CRITICAL),s.registerCommand(Bt.KEY_BACKSPACE_COMMAND,(S,E)=>{ma.tableRemoveEventListener("KEY_BACKSPACE_COMMAND")},Bt.COMMAND_PRIORITY_CRITICAL),s.registerCommand(Bt.CUT_COMMAND,(S,E)=>{ma.tableRemoveEventListener("CUT_COMMAND")},Bt.COMMAND_PRIORITY_CRITICAL),...g());Yi.mount(),Vt.alignStateSelectionJSONsFromLatestEditor(),jt.debug("New editor mounted: ",{isCodoxStarted:Vt.isCodoxStarted,codoxLexicalEditorManager:Vt,nestedEditorsProcessor:Ja});let b=s._onError;return s._onError=S=>{jt.error("[ERROR HANDLER WRAPPER] error from editor: ",S),b&&b(S),h()},i&&As.setClientCallback(i),()=>{Vt.getMainEditorKey()&&(jt.debug("Unmount prev editor"),v(),Vt.removeMainEditor(),Yi.unmount(),Vt.clearJSONs(),br.clear(),ma.clear(),Vt.isCodoxStarted&&(jt.debug("EDITOR USE_EFFECT stopping codox"),n(),Vt.setIsCodoxStarted(!1)),As.removeClientCallback())}},[s]);const n=()=>{Vt.isCodoxStarted&&(jt.log("[stopCodoxInstance] stopping codox"),Vt.setIsCodoxStarted(!1),Dm||ga().stop(),Vt.clearJSONs(),kr.clearAll(),Yi.clear(),br.resetComments(),Ja.clearListeners())},o=async v=>{jt.debug("[startCodoxInstance] invoked",{codoxConfigFromClient:v}),Vt.isCodoxStarted&&n(),ga().createNewInstance(),jt.debug("[startCodoxInstance] instance created");for(let F in Fm)ga().instance.on(F,Fm[F]);if(jt.debug("[startCodoxInstance] events subscribed"),Pi=v,vl=Pi.docId,!vl)return jt.error("[startCodoxInstance] - start codox skipped - docId is missing",{docId:vl});let b=br.initialCommentsExist();jt.debug("[startCodoxInstance] initCommentsExist: ",b),b&&(br.activateInitialComments(s,kr),jt.log("[activateInitialComments] "));let S=Vt.getMainEditorContentStateJSON();if(!Vt.isValidJSONState(S))throw jt.error("[startCodoxInstance] - start codox skipped - invalid init state",{docId:vl,initJSONState:S}),new Error("start codox skipped - invalid init state");jt.log("[startCodoxInstance] starting codox with: ",{docId:vl,initJSONState:S,config:Pi,codoxComments:br});let{username:E,apiKey:x,getServerState:y,domain:w="",demo:C=!1,hooks:j}=Pi;j&&j.fetchDocOnNetworkReconnect&&(j.fetchDocOnNetworkReconnect=QA(j.fetchDocOnNetworkReconnect));const P=M_(j,VA);await ga().start(ga().createConfig(xc(xc({},Pi),{},{docId:vl,username:E,apiKey:x,domain:w,hooks:xc({syncState:u,getState:a,getServerState:async()=>await y(vl)},P),editorInstanceHooks:{getSelection:()=>Vt.getCurrentActiveSelectionJSON(),setSelection:F=>c(F),getState:a,setState:F=>{const{root:I,comments:D}=F;jt.info("DEBUG: EDITOR INSTANCE setState:",{fullState:F}),f({state:{root:I},selection:Vt.getCurrentActiveSelectionJSON()},Yi.getCurrentRemoteSelections()),br.setAllComments(D)},enableEditor:()=>{Vt.disableEditorReadOnlyMode()},disableEditor:()=>{console.log("[CodoxCollabPlugin] disabling editor"),Vt.enableEditorReadOnlyMode(),Yi.updateRemoteSelections([])},getContent:()=>{let F=Vt.composeFullStateWithRootAndComments();return jt.info("[getContent]: ",F),{state:F}}},appServer:Pi.appServer,demo:C}))),jt.log("[startCodoxInstance] codox started - first sync invoking"),Vt.setIsCodoxStarted(!0),r.clientID=Pi.username,r.name=Pi.username,d({shouldValidateLexicalState:!1})},l=()=>{o(Pi)},a=()=>({state:xc(xc({},Vt.getMainEditorContentStateJSON()),{},{comments:br.getAllComments()})}),u=v=>{if(!Vt.isCodoxStarted)return;jt.log("[SYNC_STATE]: Before sync payload = ",v);const b=ga().sync({meta:v}),{state:S,remoteSelection:E=[]}=b,x=M_(b,JA);if(jt.log("[SYNC_STATE]: After sync",{state:S,remoteSelection:E,rest:x}),!S)return jt.error("[SYNC_STATE] abort apply - synced state is not valid - restarting codox"),l();const y=S.state;jt.log("[SYNC_STATE] synced state: ",{synced:JSON.parse(JSON.stringify(y))});let{stateFromSync:w,commentsFromSync:C}=Vt.extractStateAndCommentsFromSynced(y);if(!Vt.isValidJSONState(w.state))return jt.error("[SYNC_STATE] - invalid state from sync - local update skipped - restarting codox",{contentState:w.state}),l();f(w,E),br.setAllComments(C)},c=v=>{if(!Vt.isCodoxStarted||(jt.log("[setLocalSelectionFromSync] synced selection: ",{syncedSelectionJSON:v}),!Rm.validateJSONSelection(v,Pm.local)))return;let b=Vt.getCurrentActiveSelectionJSON();if(cn.equalSelectionsJSON(b,v))return void jt.log("[setLocalSelectionFromSync] STOP - local and synced selections are equal");let S=cn.isNestedSelectionJSON(v);s.update(()=>{jt.log("[setLocalSelectionFromSync] json selection to apply: ",{syncedSelectionJSON:v});const E=cn.JSONToLexical(v);if(jt.log("[setLocalSelectionFromSync] lexical selection to apply: ",E),S){let x=Ja.setNestedEditorSelection(v);Vt.setNestedSelectionJSON(x?v:null)}else(0,Bt.$setSelection)(E),Vt.setMainSelectionJSON(v);jt.log("[setLocalSelectionFromSync] selection updated. latest selection: ",{latestSelectionJSON:Vt.getCurrentActiveSelectionJSON()})})},f=function(){let{state:v,selection:b,stateReplace:S}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"",y=Vt.getMainEditorContentStateJSON();jt.log("[updateEditor] invoked: ",{currentContentStateJSON:JSON.parse(JSON.stringify(y)),newStateJSON:JSON.parse(JSON.stringify(v)),newSelectionJSON:b,remoteSelection:E,stateReplace:S,editor:s}),b===void 0&&jt.error("SELECTION FROm SYNC IS UNDEFINED - will default prev selection",b);const w=Mm(y,v),C=cn.equalSelectionsJSON(Vt.getCurrentActiveSelectionJSON(),b);s.update(()=>{if(Vt.addUpdateTag({isSameState:w,isSameSelection:C,updateTag:x}),S)jt.log("[updateEditor] invoke full stateReplace after sync"),j_(v),(0,Bt.$addUpdateTag)("codox_sync_state_changes");else{jt.log("[updateEditor] invoke deltas diff");let P=ga().diff(y,v,{keyNames:{default:"codoxId"}});jt.log("JSON_DIFF_ANALYSIS: ",{currentContentStateJSON:JSON.parse(JSON.stringify(y)),newStateJSON:v,deltas:P&&JSON.parse(JSON.stringify(P))}),P&&P.length&&(jt.log("[updateEditor] apply deltas to lexical state"),MA(v,P),(0,Bt.$addUpdateTag)("codox_sync_state_changes"))}let j=cn.isNestedSelectionJSON(b);if(Rm.validateJSONSelection(b,Pm.local)||(b=Vt.getCurrentActiveSelectionJSON()),j){let P=Ja.setNestedEditorSelection(b);Vt.setNestedSelectionJSON(P?b:null),jt.log("[updateEditor] nested selection updated",P?b:null)}else if(b!==void 0){const P=cn.JSONToLexical(b);jt.log("[updateEditor] updated selection to apply: ",{isSameSelection:C,newSelectionJSON:b,lexicalSelection:P}),(0,Bt.$setSelection)(P),Vt.setMainSelectionJSON(b),jt.log("[updateEditor] selection updated",b)}},{onUpdate:()=>{w||Yi.updateRemoteSelections(E,"from onUpdate hook")}}),w&&Yi.updateRemoteSelections(E,"from direct updateEditor")},d=function(){let{upd_call_counter:v="",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 jt.error("[invokeSync] - invalid lexical state for sync - sync invoke skipped - restarting codox",{lexicalJSONState:{root:S.root}}),l();jt.log("[invokeSync] SYNC INVOKED ",{upd_call_counter:v});const E={state:{state:S,selection:Vt.getCurrentActiveSelectionJSON()}};jt.log("[codoxSync]: Before sync",{local:E,upd_call_counter:v}),jt.log("[codoxSync]: Before sync state",JSON.parse(JSON.stringify(E.state)));let{state:x,remoteSelection:y=[],changes:w}=ga().sync({state:E,meta:{}});if(jt.log("[codoxSync]: After sync",{afterSyncState:JSON.parse(JSON.stringify(x)),remoteSelection:y,changes:w}),!x)return jt.error("[codoxSync] abort apply - synced state is not valid - restarting codox "),l();const C=x.state;jt.log("[codoxSync]: synced state: ",JSON.parse(JSON.stringify(C)),v);let{stateFromSync:j,commentsFromSync:P}=Vt.extractStateAndCommentsFromSynced(C);if(!Vt.isValidJSONState(j.state))return jt.error("[invokeSync] - invalid state from sync - local update skipped - restarting codox",{contentState:j.state}),l();f(j,y),br.setAllComments(P)},h=()=>{jt.warn("[rollbackStateDuringUpdateError] rollback invoked");let v=Vt.getPrevContentStateJSON(),b=Vt.getPrevMainSelectionJSON();jt.log("[rollbackStateDuringUpdateError] values: ",{prevState:v,currentState:Vt.getMainEditorContentStateJSON(),prevSelection:b,currentSelection:Vt.getCurrentActiveSelectionJSON(),codoxComments:br}),f({state:v,selection:b},Yi.getCurrentRemoteSelections(),Ni.historic);let S=Vt.undoInvoked(),E=Vt.redoInvoked();br.gcAbandonedNodeKeys(Vt.getMainEditorStateNodesMap()),S&&s.dispatchCommand(Bt.CAN_REDO_COMMAND,!1),E&&s.dispatchCommand(Bt.CAN_UNDO_COMMAND,!1)},m=v=>{let{editorState:b,prevEditorState:S,tags:E,dirtyElements:x,dirtyLeaves:y}=v;if(Lm)return Lm=!1,void jt.debug("[editorUpdatesListener] invoked blacklisted queued selection change - stop");if(As.isBlacklistedFound())return Lm=!0,jt.warn("[editorUpdatesListener] BLACKLISTED CHANGES FOUND - revert back to prev state"),((z,W)=>{let G=null,B=null;W.read(()=>{G=cn.lexicalToJSON(W._selection),B=W.toJSON()});let $=null;z.read(()=>{let q=(0,Bt.$getSelection)();$=cn.lexicalToJSON(q),z.toJSON()}),Vt.setMainSelectionJSON($),f({state:B,selection:G},Yi.getCurrentRemoteSelections(),Ni.historic),s.dispatchCommand(Bt.CAN_REDO_COMMAND,!1),s.dispatchCommand(Bt.CAN_UNDO_COMMAND,!1)})(b,S),void As.invokeClientCallback();if(!ma.ensureDocTablesAreValid(b))return;Sp++,jt.log("[editorUpdatesListener] invoked by lexical. call counter: ",{upd_call_counter:Sp,isCodoxStarted:Vt.isCodoxStarted});let w=Vt.isOnlySelectionChanged(x,y),C=null,j=null,P=null,F=null,I=E.has("codox_sync_state_changes"),D=E.has(ld),N=Vt.undoInvoked(),k=Vt.redoInvoked(),A=Vt.canUndo(),R=Vt.canRedo();C=b.toJSON(),j=S.toJSON(),S.read(()=>{F=cn.lexicalToJSON(S._selection)}),b.read(()=>{let z=(0,Bt.$getSelection)();P=cn.lexicalToJSON(z);let W=cn.JSONToLexical(P),G=z===null&&W===null||z.is(W);jt.log("[editorUpdatesListener] new values: ",{newContentStateJSON:C,prevContentStateJSON:JSON.parse(JSON.stringify(j)),currentCommentsJSON:JSON.parse(JSON.stringify(br.getAllComments())),newSelectionJSON:JSON.parse(JSON.stringify(P)),currentMainSelectionJSON:JSON.parse(JSON.stringify(Vt.getCurrentMainSelectionJSON())),currentNestedSelectionJSON:JSON.parse(JSON.stringify(Vt.getCurrentNestedSelectionJSON())),currentActiveSelectionJSON:JSON.parse(JSON.stringify(Vt.getCurrentActiveSelectionJSON())),lexicalSelection:z,convertedBackMainSelection:W,isMainSelectionConvertionCorrect:G,nodes:s._editorState._nodeMap,fullEditor:s,codoxNodesMap:kr.toArray(),codoxComments:br,isUpdateFromSync:I,isUpdateFromComments:D,tags:E,onlySelectionChanged:w,undoInvoked:N,redoInvoked:k,canUndo:A,canRedo:R})});let L=Mm(C,j),J=cn.equalSelectionsJSON(Vt.getCurrentActiveSelectionJSON(),P);jt.log("[editorUpdatesListener] compares: ",{isStateSame:L,isSelectionSame:J});let O=L&&J&&!D;if(!L||D||I){jt.log("[editorUpdatesListener] should trigger content_changed for client");let z=xc({},C),W=br.getAllComments();W.length&&(z.commentThreads=W);let G={source:I?f_.remote:f_.local,content:z};Pi.hooks&&Pi.hooks.contentChanged&&Pi.hooks.contentChanged(G),ga().instance&&ga().instance.emit("content_changed",G)}if(O)jt.log("[editorUpdatesListener] STOP - state and selection and comments are same ",Sp);else if(Vt.undoInvoked()&&Vt.setUndoInvoked(!1),Vt.redoInvoked()&&Vt.setRedoInvoked(!1),Vt.setPrevContentStateJSON(j),Vt.setMainSelectionJSON(P),Vt.setPrevMainSelectionJSON(F),Vt.isCodoxStarted)if(Dm){let z=Vt.getCurrentActiveSelectionJSON();f({state:Vt.getMainEditorContentStateJSON(),selection:z},[])}else d({upd_call_counter:Sp});else jt.log("[editorUpdatesListener] STOP - Codox is not started - prevent sync invoke")},g=()=>{let v=[];return Vt.getMainEditorNodesClassesMap().forEach((b,S,E)=>{let{klass:x}=b,y=s.registerMutationListener(x,w=>{for(let[C,j]of w){if(!mi[j])continue;const P=Vt.getLexicalNodeByKey(C);if(j===mi.created&&P&&As.trackBlacklisted(P,j),x.name===Er.TableNode.name&&(j===mi.destroyed?ma.tableNodeRemoveListener(C):ma.tableUpdateListener(C)),x.name===Er.TableRowNode.name&&j!==mi.destroyed&&ma.tableRowNodeChangesListener(C,j===mi.updated),x.name===Er.TableCellNode.name&&j===mi.updated&&ma.tableCellNodeChangesListener(C),x.name===ji.MarkNode.name&&(jt.debug("[MUTATION LISTENER] MARK node: ",{nodeKey:C,node:P,mutationType:j,codoxComments:br}),j===mi.destroyed?br.removeRelatedNodeKey(C):P&&br.addRelatedNodeKey(P.__key,P.__ids,j===mi.created)),P&&P.codoxId){if(j===mi.destroyed)return void(P.codoxId&&kr.remove(P.codoxId));H_(P)||jt.warn("[MutationListener Error] duplicating codoxId detected - such codoxId already exists in codoxNodesMap - updating node ref to latest: ",{mutationType:j,node:P}),kr.add(P.codoxId,P)}}v.push(y)})}),v},_={start:o,stop:n,on:(v,b)=>{jt.info(`Subscribing client to codox ${v} event`),Fm[v]=b},cursor:{hide:()=>{Yi.hideRemoteSelectionsFromUI()},show:()=>{Yi.showHiddenRemoteSelectionsInUI()}},initComments:v=>{br.setInitialComments(v)}};return(0,ft.useImperativeHandle)(t,()=>_),null}),ej=XA,tj=["comments"];function R_(p,t){var i=Object.keys(p);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(p);t&&(e=e.filter(function(s){return Object.getOwnPropertyDescriptor(p,s).enumerable})),i.push.apply(i,e)}return i}function Bm(p){for(var t=1;t<arguments.length;t++){var i=arguments[t]!=null?arguments[t]:{};t%2?R_(Object(i),!0).forEach(function(e){nj(p,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(i)):R_(Object(i)).forEach(function(e){Object.defineProperty(p,e,Object.getOwnPropertyDescriptor(i,e))})}return p}function nj(p,t,i){return(t=rj(t))in p?Object.defineProperty(p,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):p[t]=i,p}function rj(p){var t=oj(p,"string");return typeof t=="symbol"?t:t+""}function oj(p,t){if(typeof p!="object"||!p)return p;var i=p[Symbol.toPrimitive];if(i!==void 0){var e=i.call(p,t||"default");if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(p)}function ij(p,t){if(p==null)return{};var i,e,s=aj(p,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(p);for(e=0;e<r.length;e++)i=r[e],t.includes(i)||{}.propertyIsEnumerable.call(p,i)&&(s[i]=p[i])}return s}function aj(p,t){if(p==null)return{};var i={};for(var e in p)if({}.hasOwnProperty.call(p,e)){if(t.includes(e))continue;i[e]=p[e]}return i}class sj extends c_{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(t){this._canUndo=t}setCanRedo(t){this._canRedo=t}canUndo(){return this._canUndo}canRedo(){return this._canRedo}setUndoInvoked(t){this._undoInvoked=t}setRedoInvoked(t){this._redoInvoked=t}undoInvoked(){return this._undoInvoked}redoInvoked(){return this._redoInvoked}setIsCodoxStarted(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this._isCodoxStarted=t}get isCodoxStarted(){return this._isCodoxStarted}getMainEditorKey(){return this.mainEditorKey}setMainEditor(t){this.mainEditor=t,this.mainEditorKey=t._key}clearJSONs(){jt.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,Bt.$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(t){return this.mainEditor?this.getMainEditorState()._nodeMap.get(t):null}isLexicalEditorInstance(t){return t&&typeof t=="object"&&!!t.setEditorState}getMainEditorContentStateJSON(){return this.getMainEditorState().toJSON()}setPrevContentStateJSON(t){this.prevContentStateJSON=t}getPrevContentStateJSON(){return this.prevContentStateJSON}setMainSelectionJSON(t){this.currentMainSelectionJSON=t,this.currentMainSelectionJSON&&this.currentNestedSelectionJSON&&(this.currentNestedSelectionJSON=null)}setNestedSelectionJSON(t){this.currentNestedSelectionJSON=t,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(t){this.prevMainSelectionJSON=t}getPrevMainSelectionJSON(){return this.prevMainSelectionJSON}extractStateAndCommentsFromSynced(t){let{state:{comments:i},selection:e,stateReplace:s}=t;return{stateFromSync:{state:Bm({},ij(t.state,tj)),selection:e,stateReplace:s},commentsFromSync:i}}composeFullStateWithRootAndComments(){return Bm(Bm({},this.getMainEditorState().toJSON()),{},{comments:br.getAllComments()})}isValidJSONState(t){let i=!1;try{if(!t)throw new Error("State is undefined");if(!t.root)throw new Error("State 'root' node is missing");let e=this.getMainEditorNodesClassesMap(),s=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",o=r,l=e.get(o.type);if(!l)throw new Error(`Node with type "${o.type}" is not registered in editor`);let{klass:a}=l;if(n==="root"){let u=a.prototype instanceof Bt.ElementNode,c=a.prototype instanceof Bt.DecoratorNode;if(!u&&!c)throw new Error("State root node can have only element nodes as children")}if(o.children)for(let u of o.children)s(u,o.type)};s(t.root),i=!0}catch(e){jt.error("[isValidJSONState] invalid state found: ",e.message),i=!1}return i}scanLexicalNodeForNestedEditorAttribute(t){for(let i in t){let e=t[i];if(this.isLexicalEditorInstance(e))return i}return""}isOnlySelectionChanged(t,i){return t.size===0&&i.size===0}addUpdateTag(){let{isSameState:t,isSameSelection:i,fromNestedEditor:e=!1,updateTag:s=""}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return s?(jt.log(`[addUpdateTag] explicit add of tag "${s}" `),void(0,Bt.$addUpdateTag)(s)):e?(jt.log(`[addUpdateTag] add "${Ni.historic}" tag - change invoked by nested editor`),void(0,Bt.$addUpdateTag)(Ni.historic)):void(t?(jt.log(`[addUpdateTag] add "${Ni.historic}" tag - state is same`),(0,Bt.$addUpdateTag)(Ni.historic)):(jt.log(`[addUpdateTag] add "${Ni.historyMerge}" tag - state is different`),(0,Bt.$addUpdateTag)(Ni.historyMerge)))}enableEditorReadOnlyMode(){this.mainEditor&&this.mainEditor.isEditable()&&this.mainEditor.setEditable(!1)}disableEditorReadOnlyMode(){this.mainEditor&&(this.mainEditor.isEditable()||this.mainEditor.setEditable(!0))}}const lj=new sj,Vt=lj;class cj{constructor(){this._nodesMap=new Map,this._pastedNodesCodoxIds=new Set}get size(){return this._nodesMap.size}add(t,i){this._nodesMap.set(t,i)}get(t){return this._nodesMap.get(t)||null}remove(t){this._nodesMap.delete(t)}has(t){return this._nodesMap.has(t)}nodesToArray(){return Array.from(this._nodesMap.values())}keysToArray(){return Array.from(this._nodesMap.keys())}toArray(){return Array.from(this._nodesMap.entries())}addPastedId(t){this._pastedNodesCodoxIds.add(t)}removePastedId(t){this._pastedNodesCodoxIds.delete(t)}hasPastedId(t){return this._pastedNodesCodoxIds.has(t)}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 t=Vt.getMainEditorState();if(!t._nodeMap)return;let i=this.nodesToArray();for(let e of i)t._nodeMap.has(e.__key)||this.remove(e.codoxId)}}const uj=new cj,kr=uj;function D_(p,t){var i=Object.keys(p);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(p);t&&(e=e.filter(function(s){return Object.getOwnPropertyDescriptor(p,s).enumerable})),i.push.apply(i,e)}return i}function L_(p){for(var t=1;t<arguments.length;t++){var i=arguments[t]!=null?arguments[t]:{};t%2?D_(Object(i),!0).forEach(function(e){dj(p,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(i)):D_(Object(i)).forEach(function(e){Object.defineProperty(p,e,Object.getOwnPropertyDescriptor(i,e))})}return p}function dj(p,t,i){return(t=fj(t))in p?Object.defineProperty(p,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):p[t]=i,p}function fj(p){var t=pj(p,"string");return typeof t=="symbol"?t:t+""}function pj(p,t){if(typeof p!="object"||!p)return p;var i=p[Symbol.toPrimitive];if(i!==void 0){var e=i.call(p,t||"default");if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(p)}const zm=()=>xO(),F_=p=>typeof p=="number";function wc(p){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const i=function(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return p.apply(this,s)};return Object.defineProperty(i,"name",{value:t,writable:!0}),i}const _l=p=>p.__type==="root"||p.type==="root",B_=p=>_l(p.getParent()),qr=p=>p.__type===yp.text||p.type===yp.text||p.hasOwnProperty("__text")||p.hasOwnProperty("text"),Sc=p=>(0,Bt.$isElementNode)(p),Ec=p=>(0,Er.$isTableNode)(p)||(0,Er.$isTableRowNode)(p)||(0,Er.$isTableCellNode)(p),hj=p=>!p.getChildren,z_=p=>!!p.getChildren,vr=p=>(0,Bt.$isDecoratorNode)(p),ud=p=>(0,pO.$isLinkNode)(p),dd=p=>p.__type==="mark"||p.type==="mark",Um=p=>(0,Bt.$isLineBreakNode)(p),js=p=>qr(p)||Um(p),Hm=p=>p.__type===yp.horizontalrule||p.type===yp.horizontalrule,U_=p=>{if(js(p)||ud(p)||dd(p))return!1;if(!p.__parent||p.__parent==="root"||(0,Bt.$isParagraphNode)(p))return!0;let t=p.getParent().getChildren();return t.length===1&&t[0].__key===p.__key?!((vr(p)||ud(p)||dd(p))&&!Hm(p)):!t.some(i=>{let e=Hm(i);return i.__key!==p.__key&&(js(i)||vr(i)&&!e||ud(i)||dd(i))})},H_=p=>{const t=kr.get(p.codoxId);return!t||p.__key===t.__key},Cc=function(p){const t=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:null)||zm();p.codoxId=t,kr.add(t,p)},$_=p=>{kr.remove(p.codoxId),delete p.codoxId},gj=p=>{if(!z_(p)||!p.getChildrenSize())return;const t=p.getChildren();if(t.some(s=>!!(0,Bt.$isParagraphNode)(s)))return;let i=!1,e=[];for(let s of t)(js(s)||vr(s)||ud(s)||dd(s))&&!i&&(Hm(s)||(i=!0)),(z_(s)||vr(s))&&e.push(s);for(let s of e)i||s.codoxId?i&&s.codoxId&&(s=s.getWritable(),$_(s)):(s=s.getWritable(),Cc(s))},mj=p=>{const t=L_({},p);for(const i in p)p[i]===void 0&&p.hasOwnProperty(i)&&delete t[i];return t},yj=p=>{const t=`__nativeCreateDOM_${p.name}`;p.prototype[t]=wc(p.prototype.createDOM,t),p.prototype.createDOM=function(i,e){if(U_(this))if(this.codoxId){if(!H_(this)){let r=kr.get(this.codoxId);r.__type===this.__type&&this.isAttached()&&!r.isAttached()?(jt.warn("[createDOM][Non-unique codoxId] overwrite abandoned existing node with latest: ",{latestNode:this,existingNode:r}),kr.add(this.codoxId,this)):Cc(this)}}else Cc(this);else this.codoxId&&$_(this);vr(this)&&!this.codoxDId&&(this.codoxDId=zm()),Ja.manageNestedEditorInLexicalNode(this);let s=this[t](i,e);return s.__codox_track=!0,s}},bj=p=>{const t=`__nativeUpdateDOM_${p.name}`;return p.prototype[t]=wc(p.prototype.updateDOM,t),p.prototype.updateDOM=function(){const i=this[t](...arguments);return gj(this),i},p},vj=p=>{const t=`__nativeRemove_${p.name}`;return p.prototype[t]=wc(p.prototype.remove,t),p.prototype.remove=function(){const i=this.codoxId;return i&&kr.remove(i),Ja.gcNestedEditorListenerInLexicalNode(this),this[t](...arguments)},p},_j=p=>{const t=`__nativeExportJSON_${p.name}`;p.prototype[t]=wc(p.prototype.exportJSON,t),p.prototype.exportJSON=function(){const i=this[t]();return this.codoxId&&(i.codoxId=this.codoxId),this.codoxDId&&(i.codoxDId=this.codoxDId),qr(this)&&F_(i.format)&&this.hasFormat&&(i.format=PO(this)),mj(i)}},xj=p=>{const t="__nativeImportJSON";p[t]=wc(p.importJSON,t),p.importJSON=function(i){const e=L_({},i);qr(e)&&!F_(e.format)&&(e.format=NO(e.format));const s=p[t](e);Ja.manageNestedEditorInLexicalNode(s);const r=U_(s);return r&&e.codoxId&&(kr.hasPastedId(e.codoxId)&&kr.has(e.codoxId)?(kr.removePastedId(e.codoxId),Cc(s)):Cc(s,e.codoxId)),r&&!s.codoxId&&Cc(s),e.codoxDId&&(s.codoxDId=e.codoxDId),s}},wj=p=>{const t="__nativeClone";p[t]=wc(p.clone,t),p.clone=function(i){const e=p[t](i);return i.codoxId&&(e.codoxId=i.codoxId),i.codoxDId&&(e.codoxDId=i.codoxDId),Ja.manageNestedEditorInClonedLexicalNode(i,e),e}},Sj=p=>{let t=!1,i=!1,e=!1,s=!1;p.forEach(n=>{n.name===Bt.TextNode.name?t=!0:n.name===Bt.ParagraphNode.name?i=!0:n.name===Bt.LineBreakNode.name?e=!0:n.name===ji.MarkNode.name&&(s=!0)});let r=[];return t||r.push(Bt.TextNode),i||r.push(Bt.ParagraphNode),e||r.push(Bt.LineBreakNode),s||r.push(ji.MarkNode),r.length?[...r,...p]:p},Ej=function(){return Sj(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).map(p=>(p.hasOwnProperty("__isCodoxExtended")||(yj(p),bj(p),_j(p),vj(p),xj(p),wj(p),Object.defineProperty(p,"__isCodoxExtended",{value:!0,writable:!1})),p))};var Ep=On(777),kc={};kc.styleTagTransform=Va(),kc.setAttributes=qa(),kc.insert=$a().bind(null,"head"),kc.domAPI=Ha(),kc.insertStyleElement=Wa(),Ua()(Ep.A,kc),Ep.A&&Ep.A.locals&&Ep.A.locals;var Cj=p=>{var t={};return On.d(t,p),t};const kj=Cj({AutoFocusPlugin:()=>dp});var Tj=p=>{var t={};return On.d(t,p),t};const Oj=Tj({ClearEditorPlugin:()=>e_});var Aj=p=>{var t={};return On.d(t,p),t};const jj=Aj({LexicalComposer:()=>zf});var Nj=p=>{var t={};return On.d(t,p),t};const q_=Nj({default:()=>mc});var Pj=p=>{var t={};return On.d(t,p),t};const Ij=Pj({HistoryPlugin:()=>gp});var Mj=p=>{var t={};return On.d(t,p),t};const Rj=Mj({OnChangePlugin:()=>Am});var Dj=p=>{var t={};return On.d(t,p),t};const Lj=Dj({PlainTextPlugin:()=>i_});var Fj=p=>{var t={};return On.d(t,p),t};const W_=Fj({$isRootTextContentEmpty:()=>wm,$rootTextContent:()=>xm});var Bj=p=>{var t={};return On.d(t,p),t};const Tc=Bj({createPortal:()=>Xd.createPortal}),zj=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Uj=zj?ft.useLayoutEffect:ft.useEffect,V_=Uj;var Cp=On(253),Oc={};Oc.styleTagTransform=Va(),Oc.setAttributes=qa(),Oc.insert=$a().bind(null,"head"),Oc.domAPI=Ha(),Oc.insertStyleElement=Wa(),Ua()(Cp.A,Oc),Cp.A&&Cp.A.locals&&Cp.A.locals;function Hj(p){let{onClose:t,children:i,title:e,closeOnClickOutside:s}=p;const r=(0,ft.useRef)(null);return(0,ft.useEffect)(()=>{r.current!==null&&r.current.focus()},[]),(0,ft.useEffect)(()=>{let n=null;const o=u=>{u.key==="Escape"&&t()},l=u=>{const c=u.target;r.current!==null&&!r.current.contains(c)&&s&&t()},a=r.current;return a!==null&&(n=a.parentElement,n!==null&&n.addEventListener("click",l)),window.addEventListener("keydown",o),()=>{window.removeEventListener("keydown",o),n!==null&&(n==null||n.removeEventListener("click",l))}},[s,t]),ft.createElement("div",{className:"Modal__overlay",role:"dialog"},ft.createElement("div",{className:"Modal__modal",tabIndex:-1,ref:r},ft.createElement("h2",{className:"Modal__title"},e),ft.createElement("button",{className:"Modal__closeButton","aria-label":"Close modal",type:"button",onClick:t},"X"),ft.createElement("div",{className:"Modal__content"},i)))}function $j(p){let{onClose:t,children:i,title:e,closeOnClickOutside:s=!1}=p;return(0,Tc.createPortal)(ft.createElement(Hj,{onClose:t,title:e,closeOnClickOutside:s},i),document.body)}function J_(){const[p,t]=(0,ft.useState)(null),i=(0,ft.useCallback)(()=>{t(null)},[]),e=(0,ft.useMemo)(()=>{if(p===null)return null;const{title:r,content:n,closeOnClickOutside:o}=p;return ft.createElement($j,{onClose:i,title:r,closeOnClickOutside:o},n)},[p,i]),s=(0,ft.useCallback)(function(r,n){t({closeOnClickOutside:arguments.length>2&&arguments[2]!==void 0&&arguments[2],content:n(i),title:r})},[i]);return[e,s]}var kp=On(191),Ac={};Ac.styleTagTransform=Va(),Ac.setAttributes=qa(),Ac.insert=$a().bind(null,"head"),Ac.domAPI=Ha(),Ac.insertStyleElement=Wa(),Ua()(kp.A,Ac),kp.A&&kp.A.locals&&kp.A.locals;const qj={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"}},Wj=qj;var Tp=On(72),jc={};jc.styleTagTransform=Va(),jc.setAttributes=qa(),jc.insert=$a().bind(null,"head"),jc.domAPI=Ha(),jc.insertStyleElement=Wa(),Ua()(Tp.A,jc),Tp.A&&Tp.A.locals&&Tp.A.locals;function Vj(){for(var p=arguments.length,t=new Array(p),i=0;i<p;i++)t[i]=arguments[i];return t.filter(Boolean).join(" ")}function $m(){return $m=Object.assign?Object.assign.bind():function(p){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var e in i)({}).hasOwnProperty.call(i,e)&&(p[e]=i[e])}return p},$m.apply(null,arguments)}function Ns(p){let{"data-test-id":t,children:i,className:e,onClick:s,disabled:r,small:n,title:o}=p;return ft.createElement("button",$m({disabled:r,className:Vj("Button__root",r&&"Button__disabled",n&&"Button__small",e),onClick:s,title:o,"aria-label":o},t&&{"data-test-id":t}),i)}var Op=On(129),Nc={};Nc.styleTagTransform=Va(),Nc.setAttributes=qa(),Nc.insert=$a().bind(null,"head"),Nc.domAPI=Ha(),Nc.insertStyleElement=Wa(),Ua()(Op.A,Nc),Op.A&&Op.A.locals&&Op.A.locals;var Jj=p=>{var t={};return On.d(t,p),t};const Gj=Jj({ContentEditable:()=>fp});function Kj(p){let{className:t}=p;return ft.createElement(Gj.ContentEditable,{className:t||"ContentEditable__root"})}var Ap=On(457),Pc={};Pc.styleTagTransform=Va(),Pc.setAttributes=qa(),Pc.insert=$a().bind(null,"head"),Pc.domAPI=Ha(),Pc.insertStyleElement=Wa(),Ua()(Ap.A,Pc),Ap.A&&Ap.A.locals&&Ap.A.locals;function Yj(p){let{children:t,className:i}=p;return ft.createElement("div",{className:i||"Placeholder__root"},t)}const Zj=q_.default.LexicalErrorBoundary||q_.default,Qj=()=>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"})),G_=()=>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"})),Xj=()=>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"})),eN=()=>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 K_(p,t,i){let e=arguments.length>3&&arguments[3]!==void 0?arguments[3]:performance.now(),s=arguments.length>4&&arguments[4]!==void 0&&arguments[4];return br.createNewCommentObj({content:p,author:t,codoxId:i,timeStamp:e,deleted:s})}function tN(p,t,i){return br.createNewThreadObj({quote:p,comments:t,codoxId:i})}function nN(p){let{anchorKey:t,editor:i,onAddComment:e}=p;const s=(0,ft.useRef)(null),r=(0,ft.useCallback)(()=>{const n=s.current,o=i.getRootElement(),l=i.getElementByKey(t);if(n!==null&&o!==null&&l!==null){const{right:a}=o.getBoundingClientRect(),{top:u}=l.getBoundingClientRect();n.style.left=a-20+"px",n.style.top=u-30+"px"}},[t,i]);return(0,ft.useEffect)(()=>(window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}),[i,r]),V_(()=>{r()},[t,i,r]),ft.createElement("div",{className:"CodoxCommentPlugin_AddCommentBox",ref:s},ft.createElement("button",{className:"CodoxCommentPlugin_AddCommentBox_button",onClick:e},ft.createElement(Qj,null)))}function rN(p){let{onEscape:t}=p;const[i]=(0,Os.useLexicalComposerContext)();return(0,ft.useEffect)(()=>i.registerCommand(Bt.KEY_ESCAPE_COMMAND,e=>t(e),2),[i,t]),null}function oN(p){let{editorRef:t}=p;const[i]=(0,Os.useLexicalComposerContext)();return typeof t=="function"?t(i):typeof t=="object"&&(t.current=i),null}function Y_(p){let{className:t,autoFocus:i,onEscape:e,onChange:s,editorRef:r,placeholder:n="Type a comment...",onEditorClick:o=()=>{}}=p;const l={namespace:"Commenting",nodes:[],onError:a=>{throw a},theme:Wj};return ft.createElement(jj.LexicalComposer,{initialConfig:l},ft.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_EditorContainer",onClick:o},ft.createElement(Lj.PlainTextPlugin,{contentEditable:ft.createElement(Kj,{className:t}),placeholder:ft.createElement(Yj,null,n),ErrorBoundary:Zj}),ft.createElement(Rj.OnChangePlugin,{onChange:s}),ft.createElement(Ij.HistoryPlugin,null),i!==!1&&ft.createElement(kj.AutoFocusPlugin,null),ft.createElement(rN,{onEscape:e}),ft.createElement(Oj.ClearEditorPlugin,null),r!==void 0&&ft.createElement(oN,{editorRef:r})))}function Z_(p,t){return(0,ft.useCallback)((i,e)=>{i.read(()=>{p((0,W_.$rootTextContent)()),t(!(0,W_.$isRootTextContentEmpty)(e.isComposing(),!0))})},[t,p])}function iN(p){let{editor:t,cancelAddComment:i,submitAddComment:e}=p;const[s,r]=(0,ft.useState)(""),[n,o]=(0,ft.useState)(!1),l=(0,ft.useRef)(null),a=(0,ft.useMemo)(()=>({container:document.createElement("div"),elements:[]}),[]),u=(0,ft.useRef)(null),c=ex(),f=(0,ft.useCallback)(()=>{t.getEditorState().read(()=>{const h=(0,Bt.$getSelection)();if((0,Bt.$isRangeSelection)(h)){u.current=h.clone();const m=h.anchor,g=h.focus,_=(0,yl.createDOMRange)(t,m.getNode(),m.offset,g.getNode(),g.offset),v=l.current;if(_!==null&&v!==null){const{left:b,bottom:S,width:E}=_.getBoundingClientRect(),x=(0,yl.createRectsFromDOMRange)(t,_);let y=x.length===1?b+E/2-125:b-125;y<10&&(y=10),v.style.left=`${y}px`,v.style.top=`${S+20+(window.pageYOffset||document.documentElement.scrollTop)}px`;const w=x.length,{container:C}=a,j=a.elements,P=j.length;for(let F=0;F<w;F++){const I=x[F];let D=j[F];D===void 0&&(D=document.createElement("span"),j[F]=D,C.appendChild(D));const N="255, 212, 0",k=`position:absolute;top:${I.top+(window.pageYOffset||document.documentElement.scrollTop)}px;left:${I.left}px;height:${I.height}px;width:${I.width}px;background-color:rgba(${N}, 0.3);pointer-events:none;z-index:5;`;D.style.cssText=k}for(let F=P-1;F>=w;F--){const I=j[F];C.removeChild(I),j.pop()}}}})},[t,a]);V_(()=>{f();const h=a.container,m=document.body;if(m!==null)return m.appendChild(h),()=>{m.removeChild(h)}},[a.container,f]),(0,ft.useEffect)(()=>(window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f)}),[f]);const d=Z_(r,o);return ft.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox",ref:l},ft.createElement(Y_,{className:"CodoxCommentPlugin_CommentInputBox_Editor",onEscape:h=>(h.preventDefault(),i(),!0),onChange:d}),ft.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_Buttons"},ft.createElement(Ns,{onClick:i,className:"CodoxCommentPlugin_CommentInputBox_Button"},"Cancel"),ft.createElement(Ns,{onClick:()=>{if(n){let h=t.getEditorState().read(()=>{const m=u.current;return m?m.getTextContent():""});h.length>100&&(h=h.slice(0,99)+"…"),e(tN(h,[K_(s,c)]),!0,void 0,u.current),u.current=null}},disabled:!n,className:"CodoxCommentPlugin_CommentInputBox_Button primary"},"Comment")))}function aN(p){let{submitAddComment:t,thread:i,placeholder:e}=p;const[s,r]=(0,ft.useState)(""),[n,o]=(0,ft.useState)(!1),l=(0,ft.useRef)(null),a=ex(),u=Z_(r,o);return ft.createElement(ft.Fragment,null,ft.createElement(Y_,{className:"CodoxCommentPlugin_CommentsPanel_Editor",autoFocus:!1,onEscape:()=>!0,onChange:u,editorRef:l,placeholder:e}),ft.createElement(Ns,{className:"CodoxCommentPlugin_CommentsPanel_SendButton",onClick:()=>{if(n){t(K_(s,a),!1,i);const c=l.current;c!==null&&c.dispatchCommand(Bt.CLEAR_EDITOR_COMMAND,void 0)}},disabled:!n},ft.createElement(Xj,null)))}function Q_(p){let{commentOrThread:t,deleteCommentOrThread:i,onClose:e,thread:s}=p;return ft.createElement(ft.Fragment,null,"Are you sure you want to delete this ",t.type,"?",ft.createElement("div",{className:"Modal__content"},ft.createElement(Ns,{onClick:()=>{i(t,s),e()}},"Delete")," ",ft.createElement(Ns,{onClick:()=>{e()}},"Cancel")))}function X_(p){let{comment:t,deleteComment:i,thread:e,rtf:s}=p;const r=Math.round((t.timeStamp-performance.now())/1e3),n=Math.round(r/60),[o,l]=J_();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"},t.author),ft.createElement("span",{className:"CodoxCommentPlugin_CommentsPanel_List_Comment_Time"},"· ",r>-10?"Just now":s.format(n,"minute"))),ft.createElement("p",{className:t.deleted?"CodoxCommentPlugin_CommentsPanel_DeletedComment":""},t.content),!t.deleted&&ft.createElement(ft.Fragment,null,ft.createElement(Ns,{onClick:()=>{l("Delete Comment",a=>ft.createElement(Q_,{commentOrThread:t,deleteCommentOrThread:i,thread:e,onClose:a}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},ft.createElement(G_,null)),o))}function sN(p){let{activeIDs:t,comments:i,deleteCommentOrThread:e,listRef:s,submitAddComment:r,markNodeMap:n}=p;const[o]=(0,Os.useLexicalComposerContext)(),[l,a]=(0,ft.useState)(0),[u,c]=J_(),f=(0,ft.useMemo)(()=>new Intl.RelativeTimeFormat("en",{localeMatcher:"best fit",numeric:"auto",style:"short"}),[]);return(0,ft.useEffect)(()=>{const d=setTimeout(()=>{a(l+1)},1e4);return()=>{clearTimeout(d)}},[l]),ft.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List",ref:s},i.map(d=>{const h=d.codoxId;if(!h)return null;if(d.type==="thread"){const m=()=>{if(n.get(h)!==void 0&&(t===null||t.indexOf(h)===-1)){const g=document.activeElement;o.update(()=>{(0,Bt.$setSelection)(null)},{onUpdate(){g!==null&&g.focus()}})}};return ft.createElement("li",{key:h,onClick:m,className:`CodoxCommentPlugin_CommentsPanel_List_Thread ${n.has(h)?"interactive":""} ${t.indexOf(h)===-1?"":"active"}`},ft.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_QuoteBox"},ft.createElement("blockquote",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Quote"},"> ",ft.createElement("span",null,d.quote)),ft.createElement(Ns,{onClick:()=>{c("Delete Thread",g=>ft.createElement(Q_,{commentOrThread:d,deleteCommentOrThread:e,onClose:g}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},ft.createElement(G_,null)),u),ft.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Comments"},d.comments.map(g=>ft.createElement(X_,{key:g.codoxId,comment:g,deleteComment:e,thread:d,rtf:f}))),ft.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Editor"},ft.createElement(aN,{submitAddComment:r,thread:d,placeholder:"Reply to comment..."})))}return ft.createElement(X_,{key:h,comment:d,deleteComment:e,rtf:f})}))}function lN(p){let{activeIDs:t,deleteCommentOrThread:i,comments:e,submitAddComment:s,markNodeMap:r}=p;const n=(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(sN,{activeIDs:t,comments:e,deleteCommentOrThread:i,listRef:n,submitAddComment:s,markNodeMap:r}))}function ex(){const p=(0,N_.useCollaborationContext)(),{yjsDocMap:t,name:i}=p;return i||"Playground User"}function cN(p){const[t]=(0,Os.useLexicalComposerContext)(),i=WO(),e=(0,ft.useMemo)(()=>new Map,[]),[s,r]=(0,ft.useState)(),[n,o]=(0,ft.useState)([]),[l,a]=(0,ft.useState)(!1),[u,c]=(0,ft.useState)(!1);(0,ft.useEffect)(()=>{!i.length&&u?c(!1):i.length},[i]);const f=(0,ft.useCallback)(()=>{t.update(()=>{const m=(0,Bt.$getSelection)();m!==null&&(m.dirty=!0)}),a(!1)},[t]),d=(0,ft.useCallback)((m,g)=>{if(m.type==="comment"){if(jt.log("[deleteCommentOrThread]: type comment new values",{comment:m,thread:g,markNodeMap:e}),br.removeComment(g.codoxId,m.codoxId),!g)return;const _=g.codoxId,v=e.get(_);t.update(()=>{v?v.forEach((b,S)=>{const E=(0,Bt.$getNodeByKey)(S);jt.log("[deleteCommentOrThread]: type comment new values",{lexicalNode:E}),E&&E.markDirty()}):(0,Bt.$getRoot)().markDirty(),(0,Bt.$addUpdateTag)(Ni.historic),(0,Bt.$addUpdateTag)(ld)})}else{jt.log("[deleteCommentOrThread]: type thread new values",{comment:m,markNodeMap:e});const _=g!==void 0?g.codoxId:m.codoxId,v=e.get(_);setTimeout(()=>{t.update(()=>{if(v)for(const b of v){const S=(0,Bt.$getNodeByKey)(b);jt.log("[deleteCommentOrThread]: type thread new values",{node:S}),(0,ji.$isMarkNode)(S)&&(S.deleteID(_),S.getIDs().length===0&&(0,ji.$unwrapMarkNode)(S))}else(0,Bt.$getRoot)().markDirty(),jt.debug("[deleteCommentOrThread][refreshComments]");br.refreshComments(!0),(0,Bt.$addUpdateTag)(ld)})})}},[t,e]),h=(0,ft.useCallback)((m,g,_,v)=>{if(jt.log("[submitAddComment]: new values",{commentOrThread:m,isInlineComment:g,thread:_,markNodeMap:e}),_?br.addComment(_.codoxId,m):br.addCommentThread(m),g)t.update(()=>{if((0,Bt.$isRangeSelection)(v)){const b=v.isBackward(),S=m.codoxId;(0,ji.$wrapSelectionInMarkNode)(v,b,S),(0,Bt.$addUpdateTag)(ld)}}),a(!1);else if(!g&&_){const b=_.codoxId,S=e.get(b);if(!S)return void br.removeComment(_.codoxId,m.codoxId);t.update(()=>{S.forEach((E,x)=>{let y=(0,Bt.$getNodeByKey)(x);y&&y.markDirty()}),(0,Bt.$addUpdateTag)(Ni.historic),(0,Bt.$addUpdateTag)(ld)})}},[t]);return(0,ft.useEffect)(()=>{const m=[];for(let g=0;g<n.length;g++){const _=n[g],v=e.get(_);if(v!==void 0)for(const b of v){const S=t.getElementByKey(b);S!==null&&(S.classList.add("selected"),m.push(S),c(!0))}}return()=>{for(let g=0;g<m.length;g++)m[g].classList.remove("selected")}},[n,t,e]),(0,ft.useEffect)(()=>{const m=new Map;return(0,bc.mergeRegister)((0,bc.registerNestedElementResolver)(t,ji.MarkNode,g=>(0,ji.$createMarkNode)(g.getIDs()),(g,_)=>{g.getIDs().forEach(v=>{_.addID(v)})}),t.registerMutationListener(ji.MarkNode,g=>{t.getEditorState().read(()=>{for(const[_,v]of g){const b=(0,Bt.$getNodeByKey)(_);let S=[];v==="destroyed"?S=m.get(_)||[]:(0,ji.$isMarkNode)(b)&&(S=b.getIDs());for(let E=0;E<S.length;E++){const x=S[E];let y=e.get(x);m.set(_,S),v==="destroyed"?y!==void 0&&(y.delete(_),y.size===0&&e.delete(x)):(y===void 0&&(y=new Set,e.set(x,y)),y.has(_)||y.add(_))}}})}),t.registerUpdateListener(g=>{let{editorState:_,tags:v}=g;_.read(()=>{const b=(0,Bt.$getSelection)();let S=!1,E=!1;if((0,Bt.$isRangeSelection)(b)){const x=b.anchor.getNode();if((0,Bt.$isTextNode)(x)){const y=(0,ji.$getMarkIDs)(x,b.anchor.offset);y!==null&&(o(y),S=!0),b.isCollapsed()||(r(x.getKey()),E=!0)}}S||o(x=>x.length===0?x:[]),E||r(null),(0,Bt.$isRangeSelection)(b)&&a(!1)})}),t.registerCommand(Im,()=>{const g=window.getSelection();return g!==null&&g.removeAllRanges(),a(!0),!0},Bt.COMMAND_PRIORITY_EDITOR))},[t,e]),ft.createElement(ft.Fragment,null,l&&(0,Tc.createPortal)(ft.createElement(iN,{editor:t,cancelAddComment:f,submitAddComment:h}),document.body),s!=null&&!l&&(0,Tc.createPortal)(ft.createElement(nN,{anchorKey:s,editor:t,onAddComment:()=>{t.dispatchCommand(Im,void 0)}}),document.body),(0,Tc.createPortal)(ft.createElement(Ns,{className:"CodoxCommentPlugin_ShowCommentsButton "+(u?"active":""),onClick:()=>c(!u),title:u?"Hide Comments":"Show Comments"},ft.createElement(eN,null)),document.body),u&&(0,Tc.createPortal)(ft.createElement(lN,{comments:i,submitAddComment:h,deleteCommentOrThread:d,activeIDs:n,markNodeMap:e}),document.body))}var jp=On(766),Ic={};Ic.styleTagTransform=Va(),Ic.setAttributes=qa(),Ic.insert=$a().bind(null,"head"),Ic.domAPI=Ha(),Ic.insertStyleElement=Wa(),Ua()(jp.A,Ic),jp.A&&jp.A.locals&&jp.A.locals;var Np=On(225),Mc={};Mc.styleTagTransform=Va(),Mc.setAttributes=qa(),Mc.insert=$a().bind(null,"head"),Mc.domAPI=Ha(),Mc.insertStyleElement=Wa(),Ua()(Np.A,Mc),Np.A&&Np.A.locals&&Np.A.locals;function uN(p){let{label:t,value:i,onChange:e,placeholder:s="","data-test-id":r,type:n="text"}=p;return ft.createElement("div",{className:"CodoxInput__wrapper"},ft.createElement("label",{className:"CodoxInput__label"},t),ft.createElement("input",{type:n,className:"CodoxInput__input",placeholder:s,value:i,onChange:o=>{e(o.target.value)},"data-test-id":r}))}function tx(p,t){var i=Object.keys(p);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(p);t&&(e=e.filter(function(s){return Object.getOwnPropertyDescriptor(p,s).enumerable})),i.push.apply(i,e)}return i}function Pp(p){for(var t=1;t<arguments.length;t++){var i=arguments[t]!=null?arguments[t]:{};t%2?tx(Object(i),!0).forEach(function(e){dN(p,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(i)):tx(Object(i)).forEach(function(e){Object.defineProperty(p,e,Object.getOwnPropertyDescriptor(i,e))})}return p}function dN(p,t,i){return(t=fN(t))in p?Object.defineProperty(p,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):p[t]=i,p}function fN(p){var t=pN(p,"string");return typeof t=="symbol"?t:t+""}function pN(p,t){if(typeof p!="object"||!p)return p;var i=p[Symbol.toPrimitive];if(i!==void 0){var e=i.call(p,t||"default");if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(p)}let fd=!1;const hN=["#d0021b","#f5a623","#f8e71c","#8b572a","#7ed321","#417505","#bd10e0","#9013fe","#4a90e2","#50e3c2","#b8e986","#000000","#4a4a4a","#9b9b9b","#ffffff"];function gN(p){let{color:t,onChange:i}=p;const[e,s]=(0,ft.useState)(Rc("hex",t)),[r,n]=(0,ft.useState)(t),o=(0,ft.useRef)(null),l=(0,ft.useMemo)(()=>({x:e.hsv.s/100*214,y:(100-e.hsv.v)/100*150}),[e.hsv.s,e.hsv.v]),a=(0,ft.useMemo)(()=>({x:e.hsv.h/360*214}),[e.hsv]);return(0,ft.useEffect)(()=>{o.current!==null&&i&&n(e.hex)},[e,i]),(0,ft.useEffect)(()=>{if(t===void 0)return;const u=Rc("hex",t);s(u),n(u.hex)},[t]),ft.createElement("div",{className:"codox-color-picker-wrapper",style:{width:214},ref:o},ft.createElement(uN,{label:"Hex",onChange:u=>{if(n(u),/^#[0-9A-Fa-f]{6}$/i.test(u)){const c=Rc("hex",u);s(c)}},value:r}),ft.createElement("div",{className:"codox-color-picker-basic-color"},hN.map(u=>ft.createElement("button",{className:u===e.hex?" active":"",key:u,style:{backgroundColor:u},onClick:()=>(c=>{n(c);let f=Rc("hex",c);s(f),i(f.hex,fd)})(u)}))),ft.createElement(nx,{className:"codox-color-picker-saturation",style:{backgroundColor:`hsl(${e.hsv.h}, 100%, 50%)`},onChange:u=>{let{x:c,y:f}=u;const d=Rc("hsv",Pp(Pp({},e.hsv),{},{s:c/214*100,v:100-f/150*100}));s(d),n(d.hex),i(d.hex,fd)}},ft.createElement("div",{className:"codox-color-picker-saturation_cursor",style:{backgroundColor:e.hex,left:l.x,top:l.y}})),ft.createElement(nx,{className:"codox-color-picker-hue",onChange:u=>{let{x:c}=u;const f=Rc("hsv",Pp(Pp({},e.hsv),{},{h:c/214*360}));s(f),n(f.hex),i(f.hex,fd)}},ft.createElement("div",{className:"codox-color-picker-hue_cursor",style:{backgroundColor:`hsl(${e.hsv.h}, 100%, 50%)`,left:a.x}})),ft.createElement("div",{className:"codox-color-picker-color",style:{backgroundColor:e.hex}}))}function nx(p){let{className:t,style:i,onChange:e,children:s}=p;const r=(0,ft.useRef)(null),n=(0,ft.useRef)(!1),o=l=>{if(r.current){const{current:a}=r,{width:u,height:c,left:f,top:d}=a.getBoundingClientRect(),h=rx(l.clientX-f,u,0),m=rx(l.clientY-d,c,0);e({x:h,y:m})}};return ft.createElement("div",{ref:r,className:t,style:i,onMouseDown:l=>{if(l.button!==0)return;o(l);const a=c=>{n.current=!0,fd=!0,o(c)},u=c=>{n.current&&(fd=!1),document.removeEventListener("mousemove",a,!1),document.removeEventListener("mouseup",u,!1),o(c),n.current=!1};document.addEventListener("mousemove",a,!1),document.addEventListener("mouseup",u,!1)}},s)}function rx(p,t,i){return p>t?t:p<i?i:p}function ox(p){if(!p.startsWith("#")){const t=document.createElement("canvas").getContext("2d");if(!t)throw new Error("2d context not supported or canvas already initialized");return t.fillStyle=p,t.fillStyle}return p.length===4||p.length===5?p=p.split("").map((t,i)=>i?t+t:"#").join(""):p.length===7||p.length===9?p:"#000000"}function ix(p){const t=(p.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(i,e,s,r)=>"#"+e+e+s+s+r+r).substring(1).match(/.{2}/g)||[]).map(i=>parseInt(i,16));return{b:t[2],g:t[1],r:t[0]}}function qm(p){let{r:t,g:i,b:e}=p;t/=255,i/=255,e/=255;const s=Math.max(t,i,e),r=s-Math.min(t,i,e);return{h:r?60*(s===t?(i-e)/r+(i<e?6:0):s===i?2+(e-t)/r:4+(t-i)/r):0,s:s?r/s*100:0,v:100*s}}function mN(p){let{h:t,s:i,v:e}=p;i/=100,e/=100;const s=~~(t/60),r=t/60-s,n=e*(1-i),o=e*(1-i*r),l=e*(1-i*(1-r)),a=s%6,u=Math.round(255*[e,o,n,n,l,e][a]),c=Math.round(255*[l,e,e,o,n,n][a]);return{b:Math.round(255*[n,n,l,e,e,o][a]),g:c,r:u}}function ax(p){let{b:t,g:i,r:e}=p;return"#"+[e,i,t].map(s=>s.toString(16).padStart(2,"0")).join("")}function Rc(p,t){let i=ox("#121212"),e=ix(i),s=qm(e);return p==="hex"?(i=ox(t),e=ix(i),s=qm(e)):p==="rgb"?(e=t,i=ax(e),s=qm(e)):p==="hsv"&&(s=t,e=mN(s),i=ax(e)),{hex:i,hsv:s,rgb:e}}const yN=ft.createContext(null);function bN(p){let{children:t,dropDownRef:i,onClose:e,dropdownClassName:s}=p;const[r,n]=(0,ft.useState)(),[o,l]=(0,ft.useState)(),a=(0,ft.useCallback)(c=>{n(f=>f?[...f,c]:[c])},[n]),u=(0,ft.useMemo)(()=>({registerItem:a}),[a]);return(0,ft.useEffect)(()=>{r&&!o&&l(r[0]),o&&o.current&&o.current.focus()},[r,o]),ft.createElement(yN.Provider,{value:u},ft.createElement("div",{className:s,ref:i,onKeyDown:c=>{if(!r)return;const f=c.key;["Escape","ArrowUp","ArrowDown","Tab"].includes(f)&&c.preventDefault(),f==="Escape"||f==="Tab"?e():f==="ArrowUp"?l(d=>{if(!d)return r[0];const h=r.indexOf(d)-1;return r[h===-1?r.length-1:h]}):f==="ArrowDown"&&l(d=>d?r[r.indexOf(d)+1]:r[0])}},t))}function vN(p){let{disabled:t=!1,buttonLabel:i,buttonAriaLabel:e,buttonClassName:s,buttonIconClassName:r,children:n,stopCloseOnClickSelf:o,dropdownClassName:l,buttonLabelClassName:a,dropdownChevronClassName:u}=p;const c=(0,ft.useRef)(null),f=(0,ft.useRef)(null),[d,h]=(0,ft.useState)(!1);return(0,ft.useEffect)(()=>{const m=f.current,g=c.current;if(d&&m!==null&&g!==null){const{top:_,left:v}=m.getBoundingClientRect();g.style.top=`${_+m.offsetHeight+4}px`,g.style.left=`${Math.min(v,window.innerWidth-g.offsetWidth-20)}px`}},[c,f,d]),(0,ft.useEffect)(()=>{const m=f.current;if(m!==null&&d){const g=_=>{const v=_.target;o&&c.current&&c.current.contains(v)||m.contains(v)||h(!1)};return document.addEventListener("click",g),()=>{document.removeEventListener("click",g)}}},[c,f,d,o]),(0,ft.useEffect)(()=>{const m=()=>{if(d){const g=f.current,_=c.current;if(g!==null&&_!==null){const{top:v}=g.getBoundingClientRect(),b=v+g.offsetHeight+4;b!==_.getBoundingClientRect().top&&(_.style.top=`${b}px`)}}};return document.addEventListener("scroll",m),()=>{document.removeEventListener("scroll",m)}},[f,c,d]),ft.createElement(ft.Fragment,null,ft.createElement("button",{type:"button",disabled:t,"aria-label":e||i,className:s,onClick:()=>h(!d),ref:f},r&&ft.createElement("span",{className:r}),i&&ft.createElement("span",{className:a},i),ft.createElement("i",{className:u})),d&&(0,Tc.createPortal)(ft.createElement(bN,{dropDownRef:c,onClose:()=>{h(!1),f&&f.current&&f.current.focus()},dropdownClassName:l},n),document.body))}const _N=["disabled","stopCloseOnClickSelf","color","onChange"];function Wm(){return Wm=Object.assign?Object.assign.bind():function(p){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var e in i)({}).hasOwnProperty.call(i,e)&&(p[e]=i[e])}return p},Wm.apply(null,arguments)}function xN(p,t){if(p==null)return{};var i,e,s=wN(p,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(p);for(e=0;e<r.length;e++)i=r[e],t.includes(i)||{}.propertyIsEnumerable.call(p,i)&&(s[i]=p[i])}return s}function wN(p,t){if(p==null)return{};var i={};for(var e in p)if({}.hasOwnProperty.call(p,e)){if(t.includes(e))continue;i[e]=p[e]}return i}function sx(p){let{disabled:t=!1,stopCloseOnClickSelf:i=!0,color:e,onChange:s}=p,r=xN(p,_N);return ft.createElement(vN,Wm({},r,{disabled:t,stopCloseOnClickSelf:i}),ft.createElement(gN,{color:e,onChange:s}))}const SN=p=>{let{onColorChange:t,buttonClassName:i,buttonIconClassName:e,buttonAriaLabel:s,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:o,dropdownChevronClassName:l}=p;const[a]=(0,Os.useLexicalComposerContext)(),[u,c]=(0,ft.useState)(()=>a.isEditable()),[f,d]=(0,ft.useState)("");(0,ft.useEffect)(()=>(0,bc.mergeRegister)(a.registerEditableListener(m=>{c(m)}),a.registerUpdateListener(m=>{let{editorState:g}=m;g.read(()=>{const _=(0,Bt.$getSelection)();if((0,Bt.$isRangeSelection)(_)){let v=(0,yl.$getSelectionStyleValueForProperty)(_,"color");v!==f&&(d(v||""),t(v))}})})),[a]);const h=(0,ft.useCallback)((m,g)=>{a.update(()=>{const _=(0,Bt.$getSelection)();_!==null&&(0,yl.$patchStyleText)(_,{color:m})})},[a]);return ft.createElement(sx,{disabled:!u,color:f,onChange:h,buttonClassName:i||"",buttonIconClassName:e||"",buttonAriaLabel:s||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:o||"",dropdownChevronClassName:l||""})},EN=SN,CN=p=>{let{onColorChange:t,buttonClassName:i,buttonIconClassName:e,buttonAriaLabel:s,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:o,dropdownChevronClassName:l}=p;const[a]=(0,Os.useLexicalComposerContext)(),[u,c]=(0,ft.useState)(()=>a.isEditable()),[f,d]=(0,ft.useState)("#fff");(0,ft.useEffect)(()=>(0,bc.mergeRegister)(a.registerEditableListener(m=>{c(m)}),a.registerUpdateListener(m=>{let{editorState:g}=m;g.read(()=>{const _=(0,Bt.$getSelection)();if((0,Bt.$isRangeSelection)(_)){let v=(0,yl.$getSelectionStyleValueForProperty)(_,"background-color");v!==f&&(d(v||""),t(v))}})})),[a]);const h=(0,ft.useCallback)((m,g)=>{a.update(()=>{const _=(0,Bt.$getSelection)();_!==null&&(0,yl.$patchStyleText)(_,{"background-color":m})})},[a]);return ft.createElement(sx,{disabled:!u,color:f,onChange:h,buttonClassName:i||"",buttonIconClassName:e||"",buttonAriaLabel:s||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:o||"",dropdownChevronClassName:l||""})},kN=CN;var lx=Es.yy;Es._U,Es.a8,Es.Vs,Es.Cn;var cx=Es.gK;Es.vv;const TN=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?ve.useLayoutEffect:ve.useEffect,ux=p=>{const t=document.getElementById("typeahead-menu");if(!t)return;const i=t.getBoundingClientRect();i.top+i.height>window.innerHeight&&t.scrollIntoView({block:"center"}),i.top<0&&t.scrollIntoView({block:"center"}),p.scrollIntoView({block:"nearest"})};function dx(p,t){const i=p.getBoundingClientRect(),e=t.getBoundingClientRect();return i.top>e.top&&i.top<e.bottom}function ON(p,t,i,e){const[s]=Yn();ve.useEffect(()=>{if(t!=null&&p!=null){const r=s.getRootElement(),n=r!=null?function(c,f){let d=getComputedStyle(c);const h=d.position==="absolute",m=/(auto|scroll)/;if(d.position==="fixed")return document.body;for(let g=c;g=g.parentElement;)if(d=getComputedStyle(g),(!h||d.position!=="static")&&m.test(d.overflow+d.overflowY+d.overflowX))return g;return document.body}(r):document.body;let o=!1,l=dx(t,n);const a=function(){o||(window.requestAnimationFrame(function(){i(),o=!1}),o=!0);const c=dx(t,n);c!==l&&(l=c,e!=null&&e(c))},u=new ResizeObserver(i);return window.addEventListener("resize",i),document.addEventListener("scroll",a,{capture:!0,passive:!0}),u.observe(t),()=>{u.unobserve(t),window.removeEventListener("resize",i),document.removeEventListener("scroll",a,!0)}}},[t,s,e,i,p])}const fx=Yo();function AN({close:p,editor:t,anchorElementRef:i,resolution:e,options:s,menuRenderFn:r,onSelectOption:n,shouldSplitNodeWithQuery:o=!1,commandPriority:l=Ln}){const[a,u]=ve.useState(null),c=e.match&&e.match.matchingString;ve.useEffect(()=>{u(0)},[c]);const f=ve.useCallback(h=>{t.update(()=>{const m=e.match!=null&&o?function(g){const _=Ot();if(!Et(_)||!_.isCollapsed())return null;const v=_.anchor;if(v.type!=="text")return null;const b=v.getNode();if(!b.isSimpleText())return null;const S=v.offset,E=b.getTextContent().slice(0,S),x=g.replaceableString.length,y=S-function(C,j,P){let F=P;for(let I=F;I<=j.length;I++)C.substr(-I)===j.substr(0,I)&&(F=I);return F}(E,g.matchingString,x);if(y<0)return null;let w;return y===0?[w]=b.splitText(S):[,w]=b.splitText(y,S),w}(e.match):null;n(h,m,p,e.match?e.match.matchingString:"")})},[t,o,e.match,n,p]),d=ve.useCallback(h=>{const m=t.getRootElement();m!==null&&(m.setAttribute("aria-activedescendant","typeahead-item-"+h),u(h))},[t]);return ve.useEffect(()=>()=>{const h=t.getRootElement();h!==null&&h.removeAttribute("aria-activedescendant")},[t]),TN(()=>{s===null?u(null):a===null&&d(0)},[s,a,d]),ve.useEffect(()=>Mr(t.registerCommand(fx,({option:h})=>!(!h.ref||h.ref.current==null)&&(ux(h.ref.current),!0),l)),[t,d,l]),ve.useEffect(()=>Mr(t.registerCommand(Ou,h=>{const m=h;if(s!==null&&s.length&&a!==null){const g=a!==s.length-1?a+1:0;d(g);const _=s[g];_.ref!=null&&_.ref.current&&t.dispatchCommand(fx,{index:g,option:_}),m.preventDefault(),m.stopImmediatePropagation()}return!0},l),t.registerCommand(Tu,h=>{const m=h;if(s!==null&&s.length&&a!==null){const g=a!==0?a-1:s.length-1;d(g);const _=s[g];_.ref!=null&&_.ref.current&&ux(_.ref.current),m.preventDefault(),m.stopImmediatePropagation()}return!0},l),t.registerCommand(Ia,h=>{const m=h;return m.preventDefault(),m.stopImmediatePropagation(),p(),!0},l),t.registerCommand(nf,h=>{const m=h;return s!==null&&a!==null&&s[a]!=null&&(m.preventDefault(),m.stopImmediatePropagation(),f(s[a]),!0)},l),t.registerCommand(aa,h=>s!==null&&a!==null&&s[a]!=null&&(h!==null&&(h.preventDefault(),h.stopImmediatePropagation()),f(s[a]),!0),l)),[f,p,t,s,a,d,l]),r(i,ve.useMemo(()=>({options:s,selectOptionAndCleanUp:f,selectedIndex:a,setHighlightedIndex:u}),[f,a,s]),e.match?e.match.matchingString:"")}function jN({options:p,onQueryChange:t,onSelectOption:i,onOpen:e,onClose:s,menuRenderFn:r,triggerFn:n,anchorClassName:o,commandPriority:l=Ln,parent:a}){const[u]=Yn(),[c,f]=ve.useState(null),d=function(g,_,v,b=document.body){const[S]=Yn(),E=ve.useRef(document.createElement("div")),x=ve.useCallback(()=>{E.current.style.top=E.current.style.bottom;const w=S.getRootElement(),C=E.current,j=C.firstChild;if(w!==null&&g!==null){const{left:P,top:F,width:I,height:D}=g.getRect(),N=E.current.offsetHeight;if(C.style.top=`${F+window.pageYOffset+N+3}px`,C.style.left=`${P+window.pageXOffset}px`,C.style.height=`${D}px`,C.style.width=`${I}px`,j!==null){j.style.top=`${F}`;const k=j.getBoundingClientRect(),A=k.height,R=k.width,L=w.getBoundingClientRect();P+R>L.right&&(C.style.left=`${L.right-R+window.pageXOffset}px`),(F+A>window.innerHeight||F+A>L.bottom)&&F-L.top>A+D&&(C.style.top=F-A+window.pageYOffset-D+"px")}C.isConnected||(v!=null&&(C.className=v),C.setAttribute("aria-label","Typeahead menu"),C.setAttribute("id","typeahead-menu"),C.setAttribute("role","listbox"),C.style.display="block",C.style.position="absolute",b.append(C)),E.current=C,w.setAttribute("aria-controls","typeahead-menu")}},[S,g,v,b]);ve.useEffect(()=>{const w=S.getRootElement();if(g!==null)return x(),()=>{w!==null&&w.removeAttribute("aria-controls");const C=E.current;C!==null&&C.isConnected&&C.remove()}},[S,x,g]);const y=ve.useCallback(w=>{g!==null&&(w||_(null))},[g,_]);return ON(g,E.current,x,y),E}(c,f,o,a),h=ve.useCallback(()=>{f(null),s!=null&&c!==null&&s()},[s,c]),m=ve.useCallback(g=>{f(g),e!=null&&c===null&&e(g)},[e,c]);return ve.useEffect(()=>{const g=u.registerUpdateListener(()=>{u.getEditorState().read(()=>{const _=u._window||window,v=_.document.createRange(),b=Ot(),S=function(y){let w=null;return y.getEditorState().read(()=>{const C=Ot();Et(C)&&(w=function(j){const P=j.anchor;if(P.type!=="text")return null;const F=P.getNode();if(!F.isSimpleText())return null;const I=P.offset;return F.getTextContent().slice(0,I)}(C))}),w}(u);if(!Et(b)||!b.isCollapsed()||S===null||v===null)return void h();const E=n(S,u);if(t(E?E.matchingString:null),E!==null&&!function(y,w){return w===0&&y.getEditorState().read(()=>{const C=Ot();if(Et(C)){const j=C.anchor.getNode().getPreviousSibling();return qt(j)&&j.isTextEntity()}return!1})}(u,E.leadOffset)&&function(w,C,j){const P=j.getSelection();if(P===null||!P.isCollapsed)return!1;const F=P.anchorNode,I=w,D=P.anchorOffset;if(F==null||D==null)return!1;try{C.setStart(F,I),C.setEnd(F,D)}catch{return!1}return!0}(E.leadOffset,v,_)!==null)return x=()=>m({getRect:()=>v.getBoundingClientRect(),match:E}),void(ar.startTransition?ar.startTransition(x):x());var x;h()})});return()=>{g()}},[u,n,t,c,h,m]),c===null||u===null?null:_e.jsx(AN,{close:h,resolution:c,editor:u,anchorElementRef:d,options:p,menuRenderFn:r,shouldSplitNodeWithQuery:!0,onSelectOption:i,commandPriority:l})}function px(p,t){return p.getEditorState().read(()=>{const i=Xn(t);return i!==null&&i.isSelected()})}function Ip(p){const[t]=Yn(),[i,e]=ve.useState(()=>px(t,p));return ve.useEffect(()=>{let s=!0;const r=t.registerUpdateListener(()=>{s&&e(px(t,p))});return()=>{s=!1,r()}},[t,p]),[i,ve.useCallback(s=>{t.update(()=>{let r=Ot();cr(r)||(r=Pf(),or(r)),cr(r)&&(s?r.add(p):r.delete(p))})},[t,p]),ve.useCallback(()=>{t.update(()=>{const s=Ot();cr(s)&&s.clear()})},[t])]}const Dc=typeof window<"u"&&typeof window.document.createElement<"u",NN=Dc&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,pd=Dc&&window.matchMedia("(pointer: coarse)").matches,PN=Dc?ve.useLayoutEffect:ve.useEffect,Vm=()=>{const[p]=Yn(),[t,i]=ve.useState(()=>Dc?p.getRootElement()===document.activeElement:!1);return PN(()=>Mr(p.registerCommand(sf,()=>(i(!0),!1),Ju),p.registerCommand(lf,()=>(i(!1),!1),Ju)),[p]),t};function IN(p){const{value:t,trigger:i,data:e,className:s,classNameFocused:r,classNames:n,nodeKey:o,component:l}=p,[a]=Yn(),u=Vm(),[c,f,d]=Ip(o),h=ve.useRef(null),m=i+t,g=ve.useMemo(()=>{if(s){const y=[s];return c&&u&&r&&y.push(r),y.join(" ").trim()||void 0}return""},[c,s,r,u]),_=ve.useCallback(y=>{if(c&&cr(Ot())){y.preventDefault();const w=Xn(o);wl(w)&&w.remove()}return!1},[c,o]),v=ve.useCallback(y=>{const w=Xn(o);if(!(w!=null&&w.isSelected()))return!1;let C=!1;const j=Dp(w);return Nt(j)&&(j.selectEnd(),C=!0),qt(j)&&(j.select(),C=!0),ur(j)&&(j.selectNext(),C=!0),j===null&&(w.selectPrevious(),C=!0),C&&y.preventDefault(),C},[o]),b=ve.useCallback(y=>{const w=Xn(o);if(!(w!=null&&w.isSelected()))return!1;let C=!1;const j=Rp(w);return Nt(j)&&(j.selectStart(),C=!0),qt(j)&&(j.select(0,0),C=!0),ur(j)&&(j.selectPrevious(),C=!0),j===null&&(w.selectNext(),C=!0),C&&y.preventDefault(),C},[o]),S=ve.useCallback(y=>{var w;return y.target===h.current||!((w=h.current)===null||w===void 0)&&w.contains(y.target)?(y.shiftKey||d(),f(!0),!0):!1},[d,f]),E=ve.useCallback(()=>{const y=Xn(o);if(!(y!=null&&y.isSelected()))return!1;const w=Ot();return cr(w)&&or(null),!1},[o]),x=ve.useCallback(()=>NN&&c?(f(!1),!0):!1,[c,f]);return ve.useEffect(()=>{const y=Mr(a.registerCommand(ls,S,Ln),a.registerCommand(Ma,_,Ln),a.registerCommand(zi,_,Ln),a.registerCommand(ku,v,Ln),a.registerCommand(Cu,b,Ln),a.registerCommand(lf,E,Ln),a.registerCommand(zo,x,Ln));return()=>{y()}},[a,v,b,S,_,E,x]),l?_e.jsx(l,{ref:h,trigger:i,value:t,data:e,className:g,"data-beautiful-mention":m,children:m}):n?_e.jsxs("span",{ref:h,className:c&&n.containerFocused?n.containerFocused:n.container,"data-beautiful-mention":m,children:[_e.jsx("span",{className:n.trigger,children:i}),_e.jsx("span",{className:n.value,children:t})]}):_e.jsx("span",{ref:h,className:g,"data-beautiful-mention":m,children:m})}function MN(p){const t=p.getAttribute("data-lexical-beautiful-mention-trigger"),i=p.getAttribute("data-lexical-beautiful-mention-value");let e;const s=p.getAttribute("data-lexical-beautiful-mention-data");if(s)try{e=JSON.parse(s)}catch(r){console.warn("Failed to parse data attribute of beautiful mention node",r)}return t!=null&&i!==null?{node:hd(t,i,e)}:null}class xl extends rc{static getType(){return"beautifulMention"}static clone(t){return new xl(t.__trigger,t.__value,t.__data,t.__key)}constructor(t,i,e,s){super(s),this.__trigger=t,this.__value=i,this.__data=e}createDOM(){return document.createElement("span")}updateDOM(){return!1}exportDOM(){const t=document.createElement("span");return t.setAttribute("data-lexical-beautiful-mention","true"),t.setAttribute("data-lexical-beautiful-mention-trigger",this.__trigger),t.setAttribute("data-lexical-beautiful-mention-value",this.__value),this.__data&&t.setAttribute("data-lexical-beautiful-mention-data",JSON.stringify(this.__data)),t.textContent=this.getTextContent(),{element:t}}static importDOM(){return{span:t=>t.hasAttribute("data-lexical-beautiful-mention")?{conversion:MN,priority:1}:null}}static importJSON(t){return hd(t.trigger,t.value,t.data)}exportJSON(){const t=this.__data;return Object.assign(Object.assign({trigger:this.__trigger,value:this.__value},t?{data:t}:{}),{type:"beautifulMention",version:1})}getTextContent(){const t=this.getLatest();return t.__trigger+t.__value}getTrigger(){return this.getLatest().__trigger}getValue(){return this.getLatest().__value}setValue(t){const i=this.getWritable();i.__value=t}getData(){return this.getLatest().__data}setData(t){const i=this.getWritable();i.__data=t}component(){return null}decorate(t,i){const{className:e,classNameFocused:s,classNames:r}=this.getCssClassesFromTheme(i);return _e.jsx(IN,{nodeKey:this.getKey(),trigger:this.getTrigger(),value:this.getValue(),data:this.getData(),className:e,classNameFocused:s,classNames:r,component:this.component()})}getCssClassesFromTheme(t){var i;const e=t.theme.beautifulMentions||{},s=Object.entries(e).find(([u])=>new RegExp(u).test(this.__trigger)),r=(i=s==null?void 0:s[0])!==null&&i!==void 0?i:"",n=s==null?void 0:s[1],o=typeof n=="string"?n:void 0,l=o&&typeof e[r+"Focused"]=="string"?e[r+"Focused"]:void 0;return{className:o,classNameFocused:l,classNames:s&&typeof n!="string"?n:void 0}}}function hd(p,t,i){const e=new xl(p,t,i);return So(e)}function wl(p){return p instanceof xl}const RN="";class Mp extends Wi{static getType(){return"zeroWidth"}static clone(t){return new Mp(t.__textContent,t.__key)}static importJSON(t){return DN()}constructor(t,i){super(RN,i),this.__textContent=t}exportJSON(){return Object.assign(Object.assign({},super.exportJSON()),{text:"",type:"zeroWidth"})}updateDOM(){return!1}static importDOM(){return null}exportDOM(t){return{element:null}}isTextEntity(){return!0}getTextContent(){return this.__textContent}}function DN(p=""){const t=new Mp(p);return t.setMode("segmented"),So(t)}function Jm(p){return p instanceof Mp}const LN=`\\.,\\*\\?\\$\\|#{}\\(\\)\\^\\[\\]\\\\/!%'"~=<>_:;`,FN="\\(",BN=p=>"(?:"+p.join("|")+")",hx=(p,t)=>(p.length===0?"":"(?!"+p.join("|")+")")+"[^\\s"+t+"]",zN=75;function Gm(p,t,i){return new RegExp(hx(t,i)).test(p)}function gd(p,t){const i=Ot();if(!i||!Et(i))return;const e=i.anchor,s=i.focus,[r]=i.getNodes();if(e.key!==s.key||e.offset!==s.offset||!r)return;const n=qt(r)&&r.isSimpleText(),o=e.type,l=e.offset,a=ya(r),u=l===0,c=a.length===l,f=a.charAt(l-1),d=a.charAt(l),h=Gm(f,p,t),m=Gm(d,p,t),g=/\s/.test(f),_=/\s/.test(d),v=Dp(r),b=Rp(r),S=r.getParent(),E={node:r,type:o,offset:l,isTextNode:n,textContent:a,selection:i,prevNode:v,nextNode:b,parentNode:S,cursorAtStartOfNode:u,cursorAtEndOfNode:c,wordCharBeforeCursor:h,wordCharAfterCursor:m,spaceBeforeCursor:g,spaceAfterCursor:_};return n?Object.assign(Object.assign({},E),{isTextNode:!0,node:r}):Object.assign(Object.assign({},E),{isTextNode:!1,node:r})}function Rp(p){let t=p.getNextSibling();for(;t!==null&&Jm(t);)t=t.getNextSibling();return t}function Dp(p){let t=p.getPreviousSibling();for(;t!==null&&Jm(t);)t=t.getPreviousSibling();return t}function ya(p){return Jm(p)?"":p.getTextContent()}function UN(p,t){return typeof p=="string"||typeof p=="boolean"?p:t===null?!1:typeof p=="object"?p[t]:!1}function HN(p,t){return typeof p=="number"||p===!1?p:typeof p>"u"?5:t===null?!1:typeof p=="object"?p[t]:5}function $N(p){const t=p.getLastDescendant();return Nt(t)||qt(t)?t:ur(t)?t.getParent():p}function Km(){const p=yr(),t=$N(p),i=t==null?void 0:t.getKey(),e=Nt(t)?t.getChildrenSize():qt(t)?ya(t).length:0,s=Nt(t)?"element":"text";if(i){const r=ec();r.anchor.set(i,e,s),r.focus.set(i,e,s),or(r)}}function Ym(p){return p=p??uC(),dg(xl)}class Zm{constructor(t,i,e){this.value=t,this.displayValue=i,this.data=e,this.key=e?JSON.stringify(Object.assign(Object.assign({},e),{value:t})):t,this.displayValue=i??t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}function gx(p){const t=Ot();if(!Et(t)||!t.isCollapsed())return null;const i=t.anchor;if(i.type!=="text")return null;const e=i.getNode();if(!e.isSimpleText())return null;const s=i.offset,r=ya(e).slice(0,s),n=p.replaceableString.length,o=qN(r,p.matchingString,n),l=s-o;if(l<0)return null;let a;return l===0?[a]=e.splitText(s):[,a]=e.splitText(l,s),a}function qN(p,t,i){let e=i;for(let s=e;s<=t.length;s++)p.substring(-s)===t.substring(0,s)&&(e=s);return e}class Lp extends fi{static getType(){return"placeholder"}static clone(t){return new Lp(t.__textContent,t.__key)}constructor(t,i){super(i),this.__textContent=t}createDOM(t){const i=document.createElement("img");return i.style.display="inline",i.style.border="none",i.style.margin="0",i.style.height="1px",i.style.width="1px",i}updateDOM(){return!1}static importDOM(){return null}static importJSON(t){return WN()}isInline(){return!0}exportJSON(){return Object.assign(Object.assign({},super.exportJSON()),{type:"placeholder"})}getTextContent(){return""}}function WN(p=""){const t=new Lp(p);return So(t)}function VN(p){return p instanceof Lp}const JN=Yo(),GN=Yo(),KN=Yo(),YN=Yo();function mx(p,t,i,e){return yx(p,t,i,void 0,void 0,e)}function ZN(p,t,i,e,s,r){return yx(p,t,i,e,s,r)}function yx(p,t,i,e,s,r){const n=gd(p,t);if(!n)return!1;const{node:o,selection:l,wordCharBeforeCursor:a,wordCharAfterCursor:u,cursorAtStartOfNode:c,cursorAtEndOfNode:f,prevNode:d,nextNode:h}=n,m=e?hd(i,e,s):sr(i),g=[];if(!(ca(o)&&c)&&!qt(o))return r&&g.push(sr(" ")),g.push(m),l.insertNodes(g),!0;let _=null;return r&&(a||c&&d!==null&&!qt(d))&&g.push(sr(" ")),g.push(m),r&&(u||f&&h!==null&&!qt(h))&&(_=sr(" "),g.push(_)),l.insertNodes(g),g.length>1&&(qt(m)?m.select():_&&_.selectPrevious()),!0}function QN(p,t,i=!0){let e=!1,s=null,r=null;const n=Ym();for(const o of n){const l=o.getTrigger()===p,a=o.getValue()===t;l&&(a||!t)&&(s=Dp(o),r=Rp(o),o.remove(),e=!0,qt(s)&&ya(s).endsWith(" ")&&r&&ya(r).startsWith(" ")&&s.setTextContent(ya(s).slice(0,-1)),(r===null||VN(r))&&qt(s)&&ya(s).endsWith(" ")&&s.setTextContent(ya(s).trimEnd()))}return e&&i?bx(s,r):i||or(null),e}function XN(p,t,i,e=!0){const s=Ym();let r=null;for(const n of s){const o=n.getTrigger()===p,l=n.getValue()===i;o&&(l||!i)&&(r=n,n.setValue(t))}if(r&&e){const n=Dp(r),o=Rp(r);bx(n,o),o&&qt(o)?o.select(0,0):Km()}else e||or(null);return r!==null}function bx(p,t){t&&qt(t)?t.select(0,0):p&&qt(p)?p.select():Km()}class Qm extends Zm{constructor(t,i,e,s={}){super(i,e,s),this.itemType=t,this.comboboxItem={itemType:t,value:i,displayValue:e,data:s},this.menuOption=new Zm(i,e,s)}}function Xm(p){let t=null;return p.getEditorState().read(()=>{const i=Ot();Et(i)&&(t=eP(i))}),t}function eP(p){const t=p.anchor;if(t.type!=="text")return null;const i=t.getNode();if(!i.isSimpleText())return null;const e=t.offset;return ya(i).slice(0,e)}function tP(p){return p.key.length===1&&!p.ctrlKey&&!p.altKey&&!p.metaKey&&!p.repeat}function nP(p,t,i){const[e]=Yn(),[s,r]=ve.useState(t??null),[n,o]=ve.useState(null);return ve.useEffect(()=>{if(t){r(t);return}return e.registerRootListener(l=>{l&&r(l.parentElement)})},[e,t]),ve.useEffect(()=>{if(!s)return;if(!p){n&&(n.remove(),o(null));return}const{height:l}=s.getBoundingClientRect(),a=n??document.createElement("div");a.style.position="absolute",a.style.left="0",a.style.right="0",a.style.paddingTop=`${l}px`,s.prepend(a),n||o(a);const u=new ResizeObserver(([c])=>{a.style.paddingTop=`${c.contentRect.height}px`});return u.observe(s),setTimeout(()=>{a.className=i??""}),()=>{u.disconnect(),s.removeChild(a)}},[s,p,n,i]),n}function rP(p,t){var i;const e=(i=p.split(/\s/).pop())!==null&&i!==void 0?i:p,s=p!==e?p.lastIndexOf(e):0;return t.some(n=>n.startsWith(e)&&n!==e)?{leadOffset:s,matchingString:e,replaceableString:e}:null}function oP(p){var t;const{onSelectOption:i,triggers:e,punctuation:s,autoSpace:r,loading:n,triggerFn:o,onQueryChange:l,onReset:a,comboboxAnchor:u,comboboxAnchorClassName:c,comboboxComponent:f="div",comboboxItemComponent:d="div",onComboboxOpen:h,onComboboxClose:m,onComboboxFocusChange:g,comboboxAdditionalItems:_=[],onComboboxItemSelect:v}=p,b=Vm(),[S]=Yn(),[E,x]=ve.useState(null),[y,w]=ve.useState(null),[C,j]=ve.useState(null),[P,F]=ve.useState(null),I=p.options.length===0?"trigger":"value",D=ve.useMemo(()=>{const Z=_.map(X=>new Qm("additional",X.value,X.displayValue,X.data));if(I==="trigger"){const X=e.map(ee=>new Qm("trigger",ee,ee));return!P||X.every(ee=>!ee.value.startsWith(P))?[...X,...Z]:[...X.filter(ee=>ee.value.startsWith(P)),...Z]}return[...p.options.map(X=>new Qm("value",X.value,X.displayValue,X.data)),...Z]},[_,I,p.options,e,P]),[N,k]=ve.useState((t=p.comboboxOpen)!==null&&t!==void 0?t:!1),A=nP(N,u,c),R=ve.useCallback(Z=>{pd||x(Z)},[]),L=ve.useCallback(Z=>{var X;const ne=(X=D[Z].ref)===null||X===void 0?void 0:X.current;ne&&ne.scrollIntoView({block:"nearest"})},[D]),J=ve.useCallback((Z,X)=>{if(!b)return!1;let ee;return X==="up"?E===null?ee=D.length-1:E===0?ee=null:ee=E-1:E===null?ee=0:E===D.length-1?ee=null:ee=E+1,R(ee),ee&&L(ee),Z.preventDefault(),Z.stopImmediatePropagation(),!0},[b,E,D.length,L,R]),O=ve.useCallback(Z=>{R(Z),L(Z)},[L,R]),z=ve.useCallback(()=>{R(null)},[R]),W=ve.useCallback(Z=>{const X=D[Z];v==null||v(X.comboboxItem),X.itemType!=="additional"&&(S.update(()=>{const ee=C?gx(C):null;i(X.menuOption,ee)}),j(null),l(null),F(null),R(null))},[D,S,l,R,v,C,i]),G=ve.useCallback(Z=>{const X=D[Z];v==null||v(X.comboboxItem),X.itemType!=="additional"&&(S.update(()=>{const ee=y?gx(y):null;if(ee){const ne=sr(X.value);ee.replace(ne),ne.select()}else mx(e,s,X.value,r)}),w(null),F(null),R(0))},[D,S,R,v,y,e,s,r]),B=ve.useCallback(Z=>{I==="trigger"&&G(Z),I==="value"&&W(Z)},[I,G,W]),$=ve.useCallback(Z=>{if(!b||E===null)return!1;let X=!1;return I==="trigger"&&(X=!0,G(E)),I==="value"&&(X=!0,W(E)),X&&(Z.preventDefault(),Z.stopImmediatePropagation()),X},[b,W,G,I,E]),q=ve.useCallback(()=>{const Z=Xm(S),X=Z?Z.substring(0,Z.length-1):void 0;return X!=null&&X.trim()||R(null),!1},[S,R]),H=ve.useCallback(Z=>{if(k(!0),!tP(Z))return!1;const X=Xm(S),ne=(X===null?Z.key:X+Z.key).trim();return D.some(ce=>ce.displayValue.startsWith(ne)&&ne.length<=ce.displayValue.length)?R(0):I==="trigger"&&R(null),!1},[S,D,I,R]),K=ve.useCallback(()=>(k(!0),!1),[]),Y=ve.useCallback(()=>(k(!1),P||(F(null),w(null),j(null)),!1),[P]);return ve.useEffect(()=>Mr(S.registerCommand(Ou,Z=>J(Z,"down"),Ln),S.registerCommand(Tu,Z=>J(Z,"up"),Ln),S.registerCommand(aa,$,Ju),S.registerCommand(nf,$,Ln),S.registerCommand(zi,q,Ln),S.registerCommand(Wh,H,Ln),S.registerCommand(sf,K,Ju),S.registerCommand(ls,()=>(N||k(!0),!1),Ln),S.registerCommand(Ia,()=>(k(!1),!1),Ln)),[S,N,J,$,q,H,K]),ve.useEffect(()=>{const Z=()=>{S.getEditorState().read(()=>{const X=Xm(S);if(X===null){a(),w(null),j(null),l(null),F(null);return}const ee=rP(X,e);if(w(ee),ee){F(ee.matchingString),j(null);return}const ne=o(X,S);if(j(ne),l(ne?ne.matchingString:null),ne!=null&&ne.matchingString){F(ne.matchingString);return}F(null)})};return S.registerUpdateListener(Z)},[S,o,l,a,e]),ve.useEffect(()=>{var Z;k((Z=p.comboboxOpen)!==null&&Z!==void 0?Z:!1)},[p.comboboxOpen]),ve.useEffect(()=>{N?h==null||h():(x(null),m==null||m())},[h,m,N]),ve.useEffect(()=>{E!==null&&D[E]?g==null||g(D[E].comboboxItem):g==null||g(null)},[E,D,g]),ve.useEffect(()=>{if(!Dc)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]),!N||!A?null:Xd.createPortal(_e.jsx(f,{loading:n,itemType:I,role:"menu","aria-activedescendant":E!==null&&D[E]?D[E].displayValue:"","aria-label":"Choose trigger and value","aria-hidden":!N,children:D.map((Z,X)=>_e.jsx(d,{selected:X===E,role:"menuitem","aria-selected":E===X,"aria-label":`Choose ${Z.value}`,item:Z.comboboxItem,ref:Z.setRefElement,onClick:()=>{B(X)},onMouseEnter:()=>{O(X)},onMouseLeave:z,onMouseDown:ee=>{ee.preventDefault()},children:Z.displayValue},Z.key))}),A)}function iP(p,t){const[i,e]=ve.useState(p);return ve.useEffect(()=>{const s=setTimeout(()=>{e(p)},t);return()=>{clearTimeout(s)}},[p,t]),i}function aP(p){const{queryString:t,trigger:i,searchDelay:e,items:s,onSearch:r,justSelectedAnOption:n}=p,o=iP(t,e),[l,a]=ve.useState(!1),[u,c]=ve.useState([]),[f,d]=ve.useState(null);return ve.useEffect(()=>{if(!s)return;if(i===null){c([]),d(null);return}const h=Object.entries(s).find(([g])=>new RegExp(g).test(i));if(!h)return;const m=t?h[1].filter(g=>(typeof g=="string"?g:g.value).toLowerCase().includes(t.toLowerCase())):[...h[1]];c(m),d(t)},[s,i,t]),ve.useEffect(()=>{if(r){if(i===null||o===null){c([]),d(null);return}a(!0),d(o),r(i,n!=null&&n.current?"":o).then(h=>{c(h)}).finally(()=>{a(!1)}),n!=null&&n.current&&(n.current=!1)}},[o,r,i,n]),ve.useMemo(()=>({loading:l,results:u,query:f}),[l,u,f])}var sP=globalThis&&globalThis.__rest||function(p,t){var i={};for(var e in p)Object.prototype.hasOwnProperty.call(p,e)&&t.indexOf(e)<0&&(i[e]=p[e]);if(p!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,e=Object.getOwnPropertySymbols(p);s<e.length;s++)t.indexOf(e[s])<0&&Object.prototype.propertyIsEnumerable.call(p,e[s])&&(i[e[s]]=p[e[s]]);return i};class Fp extends Zm{constructor(t,i,e,s){super(i,e,s),this.trigger=t,this.menuItem={trigger:t,value:i,displayValue:e,data:s}}}const lP=p=>"(?:\\.[ |$]|\\s|["+p+"]|)";function cP(p,t,i,e){return new RegExp((t?`(^|\\s|${t})(`:"(^|\\s)(")+BN(p)+"((?:"+hx(p,i)+(e?lP(i):"")+"){0,"+zN+"}))$")}function vx(p,t,i,e,s){const r=cP(t,i,e,s).exec(p);if(r!==null){const n=r[1],o=r[2],l=r[3];if(o.length>=1)return{leadOffset:r.index+n.length,matchingString:l,replaceableString:o}}return null}function uP(p){const{items:t,onSearch:i,autoSpace:e=!0,searchDelay:s=p.onSearch?250:0,allowSpaces:r=!0,insertOnBlur:n=!0,menuComponent:o="ul",menuItemComponent:l="li",emptyComponent:a,menuAnchorClassName:u,showMentionsOnDelete:c,showCurrentMentionsAsSuggestions:f=!0,mentionEnclosure:d,onMenuOpen:h,onMenuClose:m,onMenuItemSelect:g,punctuation:_=LN,preTriggerChars:v=FN}=p,b=ve.useRef(!1),S=Vm(),E=ve.useMemo(()=>{var Y;return(Y=p.triggers)!==null&&Y!==void 0?Y:Object.keys(t??{})},[p.triggers,t]),[x]=Yn(),[y,w]=ve.useState(null),[C,j]=ve.useState(null),{results:P,loading:F,query:I}=aP({queryString:y,searchDelay:s,trigger:C,items:t,onSearch:i,justSelectedAnOption:b}),D=ve.useRef(),N=ve.useRef(null),k=UN(p.creatable,C),A=HN(p.menuItemLimit,C),R=ve.useMemo(()=>{if(!C)return[];let Y=P.map(X=>{if(typeof X=="string")return new Fp(C,X,X);{const{value:ee}=X,ne=sP(X,["value"]);return new Fp(C,ee,ee,ne)}});if(A!==!1&&A>0&&(Y=Y.slice(0,A)),(!i||!F&&I!==null)&&f&&x.getEditorState().read(()=>{const X=Ym(x);for(const ee of X){const ne=ee.getValue(),ce=ee.getData();ee.getTrigger()===C&&(I===null||ee.getValue().startsWith(I))&&Y.every(se=>se.value!==ne)&&Y.push(new Fp(C,ne,ne,ce))}}),I&&Y.every(X=>X.displayValue!==I)){const X=typeof k=="string"?k.replace("{{name}}",I):typeof k>"u"||k?`Add "${I}"`:void 0;X&&Y.push(new Fp(C,I,X))}return Y},[P,i,F,I,x,C,k,A,f]),L=!!R.length||F,J=ve.useCallback(()=>{j(null)},[]),O=ve.useCallback((Y,Z,X)=>{x.update(()=>{if(!C)return;const ne=!!k&&Y.value!==Y.displayValue&&d&&/\s/.test(Y.value)?d+Y.value+d:Y.value,ce=hd(C,ne,Y.data);if(Z){const se=Z.getNextSibling();if(Z.replace(ce),se instanceof Wi){const ue=se.getTextContent();!/\s/.test(ue)&&ne.includes(ue)&&se.remove()}}X==null||X(),b.current=!0})},[x,C,k,d]),z=ve.useCallback((Y,Z,X)=>{C&&(g==null||g({trigger:C,value:Y.value,displayValue:Y.displayValue,data:Y.data}),O(Y,Z,X))},[O,g,C]),W=ve.useCallback(Y=>{const Z=vx(Y,E,v,_,r);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(j(ce||null),Z.replaceableString)return Z}else j(null);return null},[v,r,_,E]),G=ve.useCallback(()=>{const Y=D.current;let Z=typeof Y=="number"?R[Y]:void 0;const X=R.find(le=>le.value!==le.displayValue);if(X&&(pd||Z===null)&&(Z=X),!Z)return!1;const ee=gd(E,_);if(!C||!(ee!=null&&ee.isTextNode))return!1;const ne=ee.node,ce=ya(ne),se=vx(ce,E,v,_,r);if(se===null)return!1;const ue=ce.search(new RegExp(`${se.replaceableString}\\s?$`));if(ue===-1)return!1;const ke=hd(C,Z.value,Z.data);return x.update(()=>{ne.setTextContent(ce.substring(0,ue)),ne.insertAfter(ke),ke.selectNext()},{tag:"history-merge"}),!0},[x,R,v,_,C,E,r]),B=ve.useCallback(()=>{const Y=Ot();if((!Y||cr(Y))&&N.current){const Z=N.current.clone();or(Z)}else Y||Km();N.current&&(N.current=null)},[]),$=ve.useCallback(Y=>{if(!c)return!1;const Z=gd(E,_);if(Z){const{node:X,prevNode:ee,offset:ne}=Z,ce=wl(X)?X:wl(ee)&&ne===0?ee:null;if(ce){const se=ce.getTrigger();return ce.replace(sr(se)),Y.preventDefault(),!0}}return!1},[c,E,_]),q=ve.useCallback((Y=!1)=>{if(!e)return;const Z=gd(E,_);if(!Z)return;const{node:X,offset:ee,type:ne,parentNode:ce,isTextNode:se,textContent:ue,prevNode:ke,nextNode:le,wordCharAfterCursor:de,cursorAtStartOfNode:Me,cursorAtEndOfNode:Be}=Z;if(se&&Me&&wl(ke)){X.insertBefore(sr(" "));return}if(wl(X)&&ke===null&&ca(ce)&&ne==="element"&&ee===0){const Ee=sr(" ");X.insertBefore(Ee),Ee.selectStart();return}if(se&&Be&&wl(le)){X.insertAfter(sr(" "));return}if(se&&Y&&de){const Ee=ue.substring(0,ee)+" "+ue.substring(ee);X.setTextContent(Ee);return}wl(X)&&le===null&&X.insertAfter(sr(" "))},[_,E,e]),H=ve.useCallback(Y=>{var Z;const{key:X,metaKey:ee,ctrlKey:ne}=Y,ce=X.length===1,se=Gm(X,E,_),ue=r&&/^\s$/.test(X);if(!ce||ee||ne)return!1;let ke=X;const le=gd(E,_);if(le!=null&&le.isTextNode){const{textContent:Me,offset:Be}=le;ke=(((Z=Me.substring(0,Be).split(/\s+/).at(-1))!==null&&Z!==void 0?Z:"")+X).trim()}const de=E.some(Me=>ke===Me);return!se&&!de&&!ue?G():(q(de),!1)},[q,_,G,E,r]),K=ve.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=E.some(se=>ee===se),ce=ee&&new RegExp(`[\\s${_}]`).test(ee);return(ne||!ce)&&q(),!1},[q,E,_]);return ve.useEffect(()=>{if(!x.hasNodes([xl]))throw new Error("BeautifulMentionsPlugin: BeautifulMentionNode not registered on editor");return Mr(x.registerCommand(zo,()=>{const Y=Ot();return Y&&!cr(Y)?N.current=Y:Y||(N.current=null),!1},Ln),x.registerCommand(Wh,H,Ln),x.registerCommand(zi,$,Ln),x.registerCommand(lf,()=>n?G():!1,Ln),x.registerCommand(B0,()=>!r&&k?G():!1,Ln),x.registerCommand(JN,({trigger:Y,value:Z,data:X,focus:ee=!0})=>{B();const ne=ZN(E,_,Y,Z,X,e);return ee||or(null),ne},Ln),x.registerCommand(GN,({trigger:Y,value:Z,focus:X})=>{const ee=QN(Y,Z,X);return X||(N.current=null),ee},Ln),x.registerCommand(KN,({trigger:Y,newValue:Z,value:X,focus:ee})=>XN(Y,Z,X,ee),Ln),x.registerCommand(YN,({trigger:Y})=>(B(),mx(E,_,Y,e)),Ln),x.registerCommand(rl,K,Ln))},[x,E,_,e,r,n,k,S,G,H,$,K,B]),ve.useEffect(()=>{L&&S?h==null||h():m==null||m(),L&&!S&&J()},[h,m,L,S,J]),Dc?p.combobox?_e.jsx(oP,{options:R,loading:F,onQueryChange:w,onSelectOption:O,onReset:()=>{j(null)},triggerFn:W,triggers:E,punctuation:_,creatable:k,comboboxOpen:p.comboboxOpen,comboboxAnchor:p.comboboxAnchor,comboboxAnchorClassName:p.comboboxAnchorClassName,comboboxComponent:p.comboboxComponent,comboboxItemComponent:p.comboboxItemComponent,comboboxAdditionalItems:p.comboboxAdditionalItems,onComboboxOpen:p.onComboboxOpen,onComboboxClose:p.onComboboxClose,onComboboxFocusChange:p.onComboboxFocusChange,onComboboxItemSelect:p.onComboboxItemSelect}):_e.jsx(jN,{commandPriority:Ju,onQueryChange:w,onSelectOption:z,triggerFn:W,options:R,anchorClassName:u,onClose:J,menuRenderFn:(Y,{selectedIndex:Z,selectOptionAndCleanUp:X,setHighlightedIndex:ee})=>(D.current=Z,Y.current&&R.length===0&&I&&!F&&S&&a?Xd.createPortal(_e.jsx(a,{}),Y.current):Y.current&&L?Xd.createPortal(_e.jsx(o,{loading:F,role:"menu","aria-label":"Choose a mention","aria-hidden":!L,"aria-activedescendant":!pd&&Z!==null&&R[Z]?R[Z].displayValue:"",children:R.map((ne,ce)=>_e.jsx(l,Object.assign({tabIndex:-1,selected:!pd&&Z===ce,ref:ne.setRefElement,role:"menuitem","aria-selected":!pd&&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 dP=({loading:p,...t})=>p?_e.jsx("ul",{id:"mention-container",className:"mentionsContainer",...t,children:_e.jsx("li",{className:"mentionsContainerItem",children:"Loading..."})}):_e.jsx("ul",{id:"mention-container",className:"mentionsContainer",...t}),fP=ve.forwardRef(({selected:p,item:t,children:i,...e},s)=>{var r,n,o;return _e.jsx("li",{className:`mentionsContainerItem ${p&&"selected"}`,...e,ref:s,"data-id":(r=t==null?void 0:t.data)==null?void 0:r.id,"data-list-name":(n=t==null?void 0:t.data)==null?void 0:n.listName,"data-value":(o=t==null?void 0:t.data)==null?void 0:o.value,children:t.value})});let md=[];function pP({nodeKey:p}){const[t]=Yn(),[i,e,s]=Ip(p),[r,n]=ar.useState(md),o=ve.useCallback(l=>{const a=Ot();return cr(a)&&t.update(()=>{a.getNodes().forEach(u=>{if(gP(u)){u.remove();const c=[...r];c.pop(),n(c),md=c}})}),!1},[t,i]);return ve.useEffect(()=>Mr(t.registerCommand(ls,l=>{const a=t.getElementByKey(p);return l.target===a?(l.shiftKey&&s(),e(!i),!0):!1},Ln),t.registerCommand(Ma,o,Ln),t.registerCommand(zi,o,Ln)),[s,t,i,p,o,e]),ve.useEffect(()=>{const l=t.getElementByKey(p);l!==null&&(l.className="")},[t,i,p]),null}class yd extends rc{static getType(){return"page-break"}static clone(t){return new yd(t.__key)}static importJSON(t){return _x()}static importDOM(){return{figure:t=>t.getAttribute("type")!==this.getType()?null:{conversion:hP,priority:pi}}}exportJSON(){return{type:this.getType(),version:1}}createDOM(){const t=document.createElement("figure");return t.style.pageBreakAfter="always",t.setAttribute("type",this.getType()),md.push(md.length+1),t.textContent=String(md.length),t}getTextContent(){return`
|
|
1511
1511
|
`}isInline(){return!1}updateDOM(){return!1}decorate(){return _e.jsx(pP,{nodeKey:this.__key})}}function hP(){return{node:_x()}}function _x(){return new yd}function gP(p){return p instanceof yd}function mP({editorRef:p}){const[t]=Yn();return ar.useEffect(()=>{typeof p=="function"?p(t):typeof p=="object"&&(p.current=t)},[t]),null}const xx=Wg?ve.useLayoutEffect:ve.useEffect,ba=()=>new Map,ey=p=>{const t=ba();return p.forEach((i,e)=>{t.set(e,i)}),t},Lc=(p,t,i)=>{let e=p.get(t);return e===void 0&&p.set(t,e=i()),e},yP=(p,t)=>{const i=[];for(const[e,s]of p)i.push(t(s,e));return i},bP=(p,t)=>{for(const[i,e]of p)if(t(e,i))return!0;return!1},Fc=()=>new Set,ty=p=>p[p.length-1],Bc=Array.from,vP=Array.isArray;class _P{constructor(){this._observers=ba()}on(t,i){return Lc(this._observers,t,Fc).add(i),i}once(t,i){const e=(...s)=>{this.off(t,e),i(...s)};this.on(t,e)}off(t,i){const e=this._observers.get(t);e!==void 0&&(e.delete(i),e.size===0&&this._observers.delete(t))}emit(t,i){return Bc((this._observers.get(t)||ba()).values()).forEach(e=>e(...i))}destroy(){this._observers=ba()}}const Sl=Math.floor,Bp=Math.abs,wx=(p,t)=>p<t?p:t,zc=(p,t)=>p>t?p:t,xP=p=>p!==0?p<0:1/p<0,Sx=1,Ex=2,ny=4,ry=8,wP=32,Cx=64,zp=128,SP=31,kx=63,bd=127,EP=2147483647,CP=Number.isInteger||(p=>typeof p=="number"&&isFinite(p)&&Sl(p)===p),kP=p=>p.toLowerCase(),TP=/^\s*/g,OP=p=>p.replace(TP,""),AP=/([A-Z])/g,Tx=(p,t)=>OP(p.replace(AP,i=>`${t}${kP(i)}`)),jP=p=>{const t=unescape(encodeURIComponent(p)),i=t.length,e=new Uint8Array(i);for(let s=0;s<i;s++)e[s]=t.codePointAt(s);return e},vd=typeof TextEncoder<"u"?new TextEncoder:null,NP=vd?p=>vd.encode(p):jP;let oy=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});oy&&oy.decode(new Uint8Array).length===1&&(oy=null);class _d{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const iy=()=>new _d,PP=p=>{let t=p.cpos;for(let i=0;i<p.bufs.length;i++)t+=p.bufs[i].length;return t},Ga=p=>{const t=new Uint8Array(PP(p));let i=0;for(let e=0;e<p.bufs.length;e++){const s=p.bufs[e];t.set(s,i),i+=s.length}return t.set(new Uint8Array(p.cbuf.buffer,0,p.cpos),i),t},IP=(p,t)=>{const i=p.cbuf.length;i-p.cpos<t&&(p.bufs.push(new Uint8Array(p.cbuf.buffer,0,p.cpos)),p.cbuf=new Uint8Array(zc(i,t)*2),p.cpos=0)},go=(p,t)=>{const i=p.cbuf.length;p.cpos===i&&(p.bufs.push(p.cbuf),p.cbuf=new Uint8Array(i*2),p.cpos=0),p.cbuf[p.cpos++]=t},ay=go,Tr=(p,t)=>{for(;t>bd;)go(p,zp|bd&t),t=Sl(t/128);go(p,bd&t)},sy=(p,t)=>{const i=xP(t);for(i&&(t=-t),go(p,(t>kx?zp:0)|(i?Cx:0)|kx&t),t=Sl(t/64);t>0;)go(p,(t>bd?zp:0)|bd&t),t=Sl(t/128)},ly=new Uint8Array(3e4),MP=ly.length/3,RP=(p,t)=>{if(t.length<MP){const i=vd.encodeInto(t,ly).written||0;Tr(p,i);for(let e=0;e<i;e++)go(p,ly[e])}else yi(p,NP(t))},DP=(p,t)=>{const i=unescape(encodeURIComponent(t)),e=i.length;Tr(p,e);for(let s=0;s<e;s++)go(p,i.codePointAt(s))},Uc=vd&&vd.encodeInto?RP:DP,cy=(p,t)=>{const i=p.cbuf.length,e=p.cpos,s=wx(i-e,t.length),r=t.length-s;p.cbuf.set(t.subarray(0,s),e),p.cpos+=s,r>0&&(p.bufs.push(p.cbuf),p.cbuf=new Uint8Array(zc(i*2,r)),p.cbuf.set(t.subarray(s)),p.cpos=r)},yi=(p,t)=>{Tr(p,t.byteLength),cy(p,t)},uy=(p,t)=>{IP(p,t);const i=new DataView(p.cbuf.buffer,p.cpos,t);return p.cpos+=t,i},LP=(p,t)=>uy(p,4).setFloat32(0,t,!1),FP=(p,t)=>uy(p,8).setFloat64(0,t,!1),BP=(p,t)=>uy(p,8).setBigInt64(0,t,!1),Ox=new DataView(new ArrayBuffer(4)),zP=p=>(Ox.setFloat32(0,p),Ox.getFloat32(0)===p),xd=(p,t)=>{switch(typeof t){case"string":go(p,119),Uc(p,t);break;case"number":CP(t)&&Bp(t)<=EP?(go(p,125),sy(p,t)):zP(t)?(go(p,124),LP(p,t)):(go(p,123),FP(p,t));break;case"bigint":go(p,122),BP(p,t);break;case"object":if(t===null)go(p,126);else if(vP(t)){go(p,117),Tr(p,t.length);for(let i=0;i<t.length;i++)xd(p,t[i])}else if(t instanceof Uint8Array)go(p,116),yi(p,t);else{go(p,118);const i=Object.keys(t);Tr(p,i.length);for(let e=0;e<i.length;e++){const s=i[e];Uc(p,s),xd(p,t[s])}}break;case"boolean":go(p,t?120:121);break;default:go(p,127)}};class Ax extends _d{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&Tr(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}}const jx=p=>{p.count>0&&(sy(p.encoder,p.count===1?p.s:-p.s),p.count>1&&Tr(p.encoder,p.count-2))};class Up{constructor(){this.encoder=new _d,this.s=0,this.count=0}write(t){this.s===t?this.count++:(jx(this),this.count=1,this.s=t)}toUint8Array(){return jx(this),Ga(this.encoder)}}const Nx=p=>{if(p.count>0){const t=p.diff*2+(p.count===1?0:1);sy(p.encoder,t),p.count>1&&Tr(p.encoder,p.count-2)}};class dy{constructor(){this.encoder=new _d,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(Nx(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return Nx(this),Ga(this.encoder)}}class UP{constructor(){this.sarr=[],this.s="",this.lensE=new Up}write(t){this.s+=t,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(t.length)}toUint8Array(){const t=new _d;return this.sarr.push(this.s),this.s="",Uc(t,this.sarr.join("")),cy(t,this.lensE.toUint8Array()),Ga(t)}}const Hc=p=>new Error(p),va=()=>{throw Hc("Method unimplemented")},El=()=>{throw Hc("Unexpected case")},HP=crypto.getRandomValues.bind(crypto),Px=()=>HP(new Uint32Array(1))[0],$P=[1e7]+-1e3+-4e3+-8e3+-1e11,qP=()=>$P.replace(/[018]/g,p=>(p^Px()&15>>p/4).toString(16)),Ix=p=>new Promise(p);Promise.all.bind(Promise);const Mx=p=>p===void 0?null:p;class WP{constructor(){this.map=new Map}setItem(t,i){this.map.set(t,i)}getItem(t){return this.map.get(t)}}let Rx=new WP,VP=!0;try{typeof localStorage<"u"&&localStorage&&(Rx=localStorage,VP=!1)}catch{}const JP=Rx,GP=Object.assign,KP=Object.keys,YP=(p,t)=>{for(const i in p)t(p[i],i)},Dx=p=>KP(p).length,ZP=p=>{for(const t in p)return!1;return!0},QP=(p,t)=>{for(const i in p)if(!t(p[i],i))return!1;return!0},XP=(p,t)=>Object.prototype.hasOwnProperty.call(p,t),e5=(p,t)=>p===t||Dx(p)===Dx(t)&&QP(p,(i,e)=>(i!==void 0||XP(t,e))&&t[e]===i),t5=Object.freeze,Lx=p=>{for(const t in p){const i=p[t];(typeof i=="object"||typeof i=="function")&&Lx(p[t])}return t5(p)},fy=(p,t,i=0)=>{try{for(;i<p.length;i++)p[i](...t)}finally{i<p.length&&fy(p,t,i+1)}},n5=(p,t)=>t.includes(p),wd=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";let _a;const r5=()=>{if(_a===void 0)if(wd){_a=ba();const p=process.argv;let t=null;for(let i=0;i<p.length;i++){const e=p[i];e[0]==="-"?(t!==null&&_a.set(t,""),t=e):t!==null&&(_a.set(t,e),t=null)}t!==null&&_a.set(t,"")}else typeof location=="object"?(_a=ba(),(location.search||"?").slice(1).split("&").forEach(p=>{if(p.length!==0){const[t,i]=p.split("=");_a.set(`--${Tx(t,"-")}`,i),_a.set(`-${Tx(t,"-")}`,i)}})):_a=ba();return _a},py=p=>r5().has(p),Hp=p=>Mx(wd?process.env[p.toUpperCase().replaceAll("-","_")]:JP.getItem(p)),Fx=p=>py("--"+p)||Hp(p)!==null;Fx("production");const o5=wd&&n5(process.env.FORCE_COLOR,["true","1","2"])||!py("--no-colors")&&!Fx("no-color")&&(!wd||process.stdout.isTTY)&&(!wd||py("--color")||Hp("COLORTERM")!==null||(Hp("TERM")||"").includes("color"));class i5{constructor(t,i){this.left=t,this.right=i}}const Ka=(p,t)=>new i5(p,t);typeof DOMParser<"u"&&new DOMParser;const a5=p=>yP(p,(t,i)=>`${i}:${t};`).join(""),Ya=Symbol,Bx=Ya(),zx=Ya(),s5=Ya(),l5=Ya(),c5=Ya(),Ux=Ya(),u5=Ya(),hy=Ya(),d5=Ya(),f5=p=>{var s;p.length===1&&((s=p[0])==null?void 0:s.constructor)===Function&&(p=p[0]());const t=[],i=[];let e=0;for(;e<p.length;e++){const r=p[e];if(r===void 0)break;if(r.constructor===String||r.constructor===Number)t.push(r);else if(r.constructor===Object)break}for(e>0&&i.push(t.join(""));e<p.length;e++){const r=p[e];r instanceof Symbol||i.push(r)}return i},p5={[Bx]:Ka("font-weight","bold"),[zx]:Ka("font-weight","normal"),[s5]:Ka("color","blue"),[c5]:Ka("color","green"),[l5]:Ka("color","grey"),[Ux]:Ka("color","red"),[u5]:Ka("color","purple"),[hy]:Ka("color","orange"),[d5]:Ka("color","black")},Hx=o5?p=>{var n;p.length===1&&((n=p[0])==null?void 0:n.constructor)===Function&&(p=p[0]());const t=[],i=[],e=ba();let s=[],r=0;for(;r<p.length;r++){const o=p[r],l=p5[o];if(l!==void 0)e.set(l.left,l.right);else{if(o===void 0)break;if(o.constructor===String||o.constructor===Number){const a=a5(e);r>0||a.length>0?(t.push("%c"+o),i.push(a)):t.push(o)}else break}}for(r>0&&(s=i,s.unshift(t.join("")));r<p.length;r++){const o=p[r];o instanceof Symbol||s.push(o)}return s}:f5,h5=(...p)=>{console.log(...Hx(p)),$x.forEach(t=>t.print(p))},g5=(...p)=>{console.warn(...Hx(p)),p.unshift(hy),$x.forEach(t=>t.print(p))},$x=Fc(),qx=p=>({[Symbol.iterator](){return this},next:p}),m5=(p,t)=>qx(()=>{let i;do i=p.next();while(!i.done&&!t(i.value));return i}),gy=(p,t)=>qx(()=>{const{done:i,value:e}=p.next();return{done:i,value:i?void 0:t(e)}});class y5{constructor(t,i){this.clock=t,this.len=i}}class b5{constructor(){this.clients=new Map}}const Wx=(p,t,i)=>t.clients.forEach((e,s)=>{const r=p.doc.store.clients.get(s);for(let n=0;n<e.length;n++){const o=e[n];nw(p,r,o.clock,o.len,i)}}),v5=(p,t)=>{let i=0,e=p.length-1;for(;i<=e;){const s=Sl((i+e)/2),r=p[s],n=r.clock;if(n<=t){if(t<n+r.len)return s;i=s+1}else e=s-1}return null},Vx=(p,t)=>{const i=p.clients.get(t.client);return i!==void 0&&v5(i,t.clock)!==null},Jx=p=>{p.clients.forEach(t=>{t.sort((s,r)=>s.clock-r.clock);let i,e;for(i=1,e=1;i<t.length;i++){const s=t[e-1],r=t[i];s.clock+s.len>=r.clock?s.len=zc(s.len,r.clock+r.len-s.clock):(e<i&&(t[e]=r),e++)}t.length=e})},Gx=(p,t,i,e)=>{Lc(p.clients,t,()=>[]).push(new y5(i,e))},_5=(p,t)=>{Tr(p.restEncoder,t.clients.size),Bc(t.clients.entries()).sort((i,e)=>e[0]-i[0]).forEach(([i,e])=>{p.resetDsCurVal(),Tr(p.restEncoder,i);const s=e.length;Tr(p.restEncoder,s);for(let r=0;r<s;r++){const n=e[r];p.writeDsClock(n.clock),p.writeDsLen(n.len)}})},Kx=Px;class Sd extends _P{constructor({guid:t=qP(),collectionid:i=null,gc:e=!0,gcFilter:s=()=>!0,meta:r=null,autoLoad:n=!1,shouldLoad:o=!0}={}){super(),this.gc=e,this.gcFilter=s,this.clientID=Kx(),this.guid=t,this.collectionid=i,this.share=new Map,this.store=new j5,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=n,this.meta=r,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Ix(a=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});const l=()=>Ix(a=>{const u=c=>{(c===void 0||c===!0)&&(this.off("sync",u),a())};this.on("sync",u)});this.on("sync",a=>{a===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const t=this._item;t!==null&&!this.shouldLoad&&Dr(t.parent.doc,i=>{i.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Bc(this.subdocs).map(t=>t.guid))}transact(t,i=null){return Dr(this,t,i)}get(t,i=Co){const e=Lc(this.share,t,()=>{const r=new i;return r._integrate(this,null),r}),s=e.constructor;if(i!==Co&&s!==i)if(s===Co){const r=new i;r._map=e._map,e._map.forEach(n=>{for(;n!==null;n=n.left)n.parent=r}),r._start=e._start;for(let n=r._start;n!==null;n=n.right)n.parent=r;return r._length=e._length,this.share.set(t,r),r._integrate(this,null),r}else throw new Error(`Type with the name ${t} has already been defined with a different constructor`);return e}getArray(t=""){return this.get(t,Cl)}getText(t=""){return this.get(t,Xp)}getMap(t=""){return this.get(t,qc)}getXmlElement(t=""){return this.get(t,kd)}getXmlFragment(t=""){return this.get(t,Vc)}toJSON(){const t={};return this.share.forEach((i,e)=>{t[e]=i.toJSON()}),t}destroy(){this.isDestroyed=!0,Bc(this.subdocs).forEach(i=>i.destroy());const t=this._item;if(t!==null){this._item=null;const i=t.content;i.doc=new Sd({guid:this.guid,...i.opts,shouldLoad:!1}),i.doc._item=t,Dr(t.parent.doc,e=>{const s=i.doc;t.deleted||e.subdocsAdded.add(s),e.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class x5{constructor(){this.restEncoder=iy()}toUint8Array(){return Ga(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){Tr(this.restEncoder,t)}writeDsLen(t){Tr(this.restEncoder,t)}}class w5 extends x5{writeLeftID(t){Tr(this.restEncoder,t.client),Tr(this.restEncoder,t.clock)}writeRightID(t){Tr(this.restEncoder,t.client),Tr(this.restEncoder,t.clock)}writeClient(t){Tr(this.restEncoder,t)}writeInfo(t){ay(this.restEncoder,t)}writeString(t){Uc(this.restEncoder,t)}writeParentInfo(t){Tr(this.restEncoder,t?1:0)}writeTypeRef(t){Tr(this.restEncoder,t)}writeLen(t){Tr(this.restEncoder,t)}writeAny(t){xd(this.restEncoder,t)}writeBuf(t){yi(this.restEncoder,t)}writeJSON(t){Uc(this.restEncoder,JSON.stringify(t))}writeKey(t){Uc(this.restEncoder,t)}}class S5{constructor(){this.restEncoder=iy(),this.dsCurrVal=0}toUint8Array(){return Ga(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){const i=t-this.dsCurrVal;this.dsCurrVal=t,Tr(this.restEncoder,i)}writeDsLen(t){t===0&&El(),Tr(this.restEncoder,t-1),this.dsCurrVal+=t}}class E5 extends S5{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new dy,this.clientEncoder=new Up,this.leftClockEncoder=new dy,this.rightClockEncoder=new dy,this.infoEncoder=new Ax(ay),this.stringEncoder=new UP,this.parentInfoEncoder=new Ax(ay),this.typeRefEncoder=new Up,this.lenEncoder=new Up}toUint8Array(){const t=iy();return Tr(t,0),yi(t,this.keyClockEncoder.toUint8Array()),yi(t,this.clientEncoder.toUint8Array()),yi(t,this.leftClockEncoder.toUint8Array()),yi(t,this.rightClockEncoder.toUint8Array()),yi(t,Ga(this.infoEncoder)),yi(t,this.stringEncoder.toUint8Array()),yi(t,Ga(this.parentInfoEncoder)),yi(t,this.typeRefEncoder.toUint8Array()),yi(t,this.lenEncoder.toUint8Array()),cy(t,Ga(this.restEncoder)),Ga(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){xd(this.restEncoder,t)}writeBuf(t){yi(this.restEncoder,t)}writeJSON(t){xd(this.restEncoder,t)}writeKey(t){const i=this.keyMap.get(t);i===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(i)}}const C5=(p,t,i,e)=>{e=zc(e,t[0].id.clock);const s=Za(t,e);Tr(p.restEncoder,t.length-s),p.writeClient(i),Tr(p.restEncoder,e);const r=t[s];r.write(p,e-r.id.clock);for(let n=s+1;n<t.length;n++)t[n].write(p,0)},k5=(p,t,i)=>{const e=new Map;i.forEach((s,r)=>{ei(t,r)>s&&e.set(r,s)}),yy(t).forEach((s,r)=>{i.has(r)||e.set(r,0)}),Tr(p.restEncoder,e.size),Bc(e.entries()).sort((s,r)=>r[0]-s[0]).forEach(([s,r])=>{C5(p,t.clients.get(s),s,r)})},T5=(p,t)=>k5(p,t.doc.store,t.beforeState);class O5{constructor(){this.l=[]}}const Yx=()=>new O5,Zx=(p,t)=>p.l.push(t),Qx=(p,t)=>{const i=p.l,e=i.length;p.l=i.filter(s=>t!==s),e===p.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},Xx=(p,t,i)=>fy(p.l,[t,i]);class $p{constructor(t,i){this.client=t,this.clock=i}}const qp=(p,t)=>p===t||p!==null&&t!==null&&p.client===t.client&&p.clock===t.clock,Gr=(p,t)=>new $p(p,t),A5=p=>{for(const[t,i]of p.doc.share.entries())if(i===p)return t;throw El()},$c=(p,t)=>t===void 0?!p.deleted:t.sv.has(p.id.client)&&(t.sv.get(p.id.client)||0)>p.id.clock&&!Vx(t.ds,p.id),my=(p,t)=>{const i=Lc(p.meta,my,Fc),e=p.doc.store;i.has(t)||(t.sv.forEach((s,r)=>{s<ei(e,r)&&Ps(p,Gr(r,s))}),Wx(p,t.ds,s=>{}),i.add(t))};class j5{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const yy=p=>{const t=new Map;return p.clients.forEach((i,e)=>{const s=i[i.length-1];t.set(e,s.id.clock+s.length)}),t},ei=(p,t)=>{const i=p.clients.get(t);if(i===void 0)return 0;const e=i[i.length-1];return e.id.clock+e.length},ew=(p,t)=>{let i=p.clients.get(t.id.client);if(i===void 0)i=[],p.clients.set(t.id.client,i);else{const e=i[i.length-1];if(e.id.clock+e.length!==t.id.clock)throw El()}i.push(t)},Za=(p,t)=>{let i=0,e=p.length-1,s=p[e],r=s.id.clock;if(r===t)return e;let n=Sl(t/(r+s.length-1)*e);for(;i<=e;){if(s=p[n],r=s.id.clock,r<=t){if(t<r+s.length)return n;i=n+1}else e=n-1;n=Sl((i+e)/2)}throw El()},by=(p,t)=>{const i=p.clients.get(t.client);return i[Za(i,t.clock)]},vy=(p,t,i)=>{const e=Za(t,i),s=t[e];return s.id.clock<i&&s instanceof Po?(t.splice(e+1,0,Tw(p,s,i-s.id.clock)),e+1):e},Ps=(p,t)=>{const i=p.doc.store.clients.get(t.client);return i[vy(p,i,t.clock)]},tw=(p,t,i)=>{const e=t.clients.get(i.client),s=Za(e,i.clock),r=e[s];return i.clock!==r.id.clock+r.length-1&&r.constructor!==Ms&&e.splice(s+1,0,Tw(p,r,i.clock-r.id.clock+1)),r},N5=(p,t,i)=>{const e=p.clients.get(t.id.client);e[Za(e,t.id.clock)]=i},nw=(p,t,i,e,s)=>{if(e===0)return;const r=i+e;let n=vy(p,t,i),o;do o=t[n++],r<o.id.clock+o.length&&vy(p,t,r),s(o);while(n<t.length&&t[n].id.clock<r)};class P5{constructor(t,i,e){this.doc=t,this.deleteSet=new b5,this.beforeState=yy(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=i,this.meta=new Map,this.local=e,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const rw=(p,t)=>t.deleteSet.clients.size===0&&!bP(t.afterState,(i,e)=>t.beforeState.get(e)!==i)?!1:(Jx(t.deleteSet),T5(p,t),_5(p,t.deleteSet),!0),ow=(p,t,i)=>{const e=t._item;(e===null||e.id.clock<(p.beforeState.get(e.id.client)||0)&&!e.deleted)&&Lc(p.changed,t,Fc).add(i)},Wp=(p,t)=>{let i=p[t],e=p[t-1],s=t;for(;s>0;i=e,e=p[--s-1]){if(e.deleted===i.deleted&&e.constructor===i.constructor&&e.mergeWith(i)){i instanceof Po&&i.parentSub!==null&&i.parent._map.get(i.parentSub)===i&&i.parent._map.set(i.parentSub,e);continue}break}const r=t-s;return r&&p.splice(t+1-r,r),r},I5=(p,t,i)=>{for(const[e,s]of p.clients.entries()){const r=t.clients.get(e);for(let n=s.length-1;n>=0;n--){const o=s[n],l=o.clock+o.len;for(let a=Za(r,o.clock),u=r[a];a<r.length&&u.id.clock<l;u=r[++a]){const c=r[a];if(o.clock+o.len<=c.id.clock)break;c instanceof Po&&c.deleted&&!c.keep&&i(c)&&c.gc(t,!1)}}}},M5=(p,t)=>{p.clients.forEach((i,e)=>{const s=t.clients.get(e);for(let r=i.length-1;r>=0;r--){const n=i[r],o=wx(s.length-1,1+Za(s,n.clock+n.len-1));for(let l=o,a=s[l];l>0&&a.id.clock>=n.clock;a=s[l])l-=1+Wp(s,l)}})},iw=(p,t)=>{if(t<p.length){const i=p[t],e=i.doc,s=e.store,r=i.deleteSet,n=i._mergeStructs;try{Jx(r),i.afterState=yy(i.doc.store),e.emit("beforeObserverCalls",[i,e]);const o=[];i.changed.forEach((l,a)=>o.push(()=>{(a._item===null||!a._item.deleted)&&a._callObserver(i,l)})),o.push(()=>{i.changedParentTypes.forEach((l,a)=>{a._dEH.l.length>0&&(a._item===null||!a._item.deleted)&&(l=l.filter(u=>u.target._item===null||!u.target._item.deleted),l.forEach(u=>{u.currentTarget=a,u._path=null}),l.sort((u,c)=>u.path.length-c.path.length),Xx(a._dEH,l,i))})}),o.push(()=>e.emit("afterTransaction",[i,e])),fy(o,[]),i._needFormattingCleanup&&W5(i)}finally{e.gc&&I5(r,s,e.gcFilter),M5(r,s),i.afterState.forEach((u,c)=>{const f=i.beforeState.get(c)||0;if(f!==u){const d=s.clients.get(c),h=zc(Za(d,f),1);for(let m=d.length-1;m>=h;)m-=1+Wp(d,m)}});for(let u=n.length-1;u>=0;u--){const{client:c,clock:f}=n[u].id,d=s.clients.get(c),h=Za(d,f);h+1<d.length&&Wp(d,h+1)>1||h>0&&Wp(d,h)}if(!i.local&&i.afterState.get(e.clientID)!==i.beforeState.get(e.clientID)&&(h5(hy,Bx,"[yjs] ",zx,Ux,"Changed the client-id because another client seems to be using it."),e.clientID=Kx()),e.emit("afterTransactionCleanup",[i,e]),e._observers.has("update")){const u=new w5;rw(u,i)&&e.emit("update",[u.toUint8Array(),i.origin,e,i])}if(e._observers.has("updateV2")){const u=new E5;rw(u,i)&&e.emit("updateV2",[u.toUint8Array(),i.origin,e,i])}const{subdocsAdded:o,subdocsLoaded:l,subdocsRemoved:a}=i;(o.size>0||a.size>0||l.size>0)&&(o.forEach(u=>{u.clientID=e.clientID,u.collectionid==null&&(u.collectionid=e.collectionid),e.subdocs.add(u)}),a.forEach(u=>e.subdocs.delete(u)),e.emit("subdocs",[{loaded:l,added:o,removed:a},e,i]),a.forEach(u=>u.destroy())),p.length<=t+1?(e._transactionCleanups=[],e.emit("afterAllTransactions",[e,p])):iw(p,t+1)}}},Dr=(p,t,i=null,e=!0)=>{const s=p._transactionCleanups;let r=!1,n=null;p._transaction===null&&(r=!0,p._transaction=new P5(p,i,e),s.push(p._transaction),s.length===1&&p.emit("beforeAllTransactions",[p]),p.emit("beforeTransaction",[p._transaction,p]));try{n=t(p._transaction)}finally{if(r){const o=p._transaction===s[0];p._transaction=null,o&&iw(s,0)}}return n},aw="You must not compute changes after the event-handler fired.";class Vp{constructor(t,i){this.target=t,this.currentTarget=t,this.transaction=i,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=R5(this.currentTarget,this.target))}deletes(t){return Vx(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Hc(aw);const t=new Map,i=this.target;this.transaction.changed.get(i).forEach(s=>{if(s!==null){const r=i._map.get(s);let n,o;if(this.adds(r)){let l=r.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(r))if(l!==null&&this.deletes(l))n="delete",o=ty(l.content.getContent());else return;else l!==null&&this.deletes(l)?(n="update",o=ty(l.content.getContent())):(n="add",o=void 0)}else if(this.deletes(r))n="delete",o=ty(r.content.getContent());else return;t.set(s,{action:n,oldValue:o})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw Hc(aw);const i=this.target,e=Fc(),s=Fc(),r=[];if(t={added:e,deleted:s,delta:r,keys:this.keys},this.transaction.changed.get(i).has(null)){let o=null;const l=()=>{o&&r.push(o)};for(let a=i._start;a!==null;a=a.right)a.deleted?this.deletes(a)&&!this.adds(a)&&((o===null||o.delete===void 0)&&(l(),o={delete:0}),o.delete+=a.length,s.add(a)):this.adds(a)?((o===null||o.insert===void 0)&&(l(),o={insert:[]}),o.insert=o.insert.concat(a.content.getContent()),e.add(a)):((o===null||o.retain===void 0)&&(l(),o={retain:0}),o.retain+=a.length);o!==null&&o.retain===void 0&&l()}this._changes=t}return t}}const R5=(p,t)=>{const i=[];for(;t._item!==null&&t!==p;){if(t._item.parentSub!==null)i.unshift(t._item.parentSub);else{let e=0,s=t._item.parent._start;for(;s!==t._item&&s!==null;)!s.deleted&&s.countable&&(e+=s.length),s=s.right;i.unshift(e)}t=t._item.parent}return i},No=()=>{g5("Invalid access: Add Yjs type to a document before reading data.")},sw=80;let _y=0;class D5{constructor(t,i){t.marker=!0,this.p=t,this.index=i,this.timestamp=_y++}}const L5=p=>{p.timestamp=_y++},lw=(p,t,i)=>{p.p.marker=!1,p.p=t,t.marker=!0,p.index=i,p.timestamp=_y++},F5=(p,t,i)=>{if(p.length>=sw){const e=p.reduce((s,r)=>s.timestamp<r.timestamp?s:r);return lw(e,t,i),e}else{const e=new D5(t,i);return p.push(e),e}},Jp=(p,t)=>{if(p._start===null||t===0||p._searchMarker===null)return null;const i=p._searchMarker.length===0?null:p._searchMarker.reduce((r,n)=>Bp(t-r.index)<Bp(t-n.index)?r:n);let e=p._start,s=0;for(i!==null&&(e=i.p,s=i.index,L5(i));e.right!==null&&s<t;){if(!e.deleted&&e.countable){if(t<s+e.length)break;s+=e.length}e=e.right}for(;e.left!==null&&s>t;)e=e.left,!e.deleted&&e.countable&&(s-=e.length);for(;e.left!==null&&e.left.id.client===e.id.client&&e.left.id.clock+e.left.length===e.id.clock;)e=e.left,!e.deleted&&e.countable&&(s-=e.length);return i!==null&&Bp(i.index-s)<e.parent.length/sw?(lw(i,e,s),i):F5(p._searchMarker,e,s)},Ed=(p,t,i)=>{for(let e=p.length-1;e>=0;e--){const s=p[e];if(i>0){let r=s.p;for(r.marker=!1;r&&(r.deleted||!r.countable);)r=r.left,r&&!r.deleted&&r.countable&&(s.index-=r.length);if(r===null||r.marker===!0){p.splice(e,1);continue}s.p=r,r.marker=!0}(t<s.index||i>0&&t===s.index)&&(s.index=zc(t,s.index+i))}},Gp=(p,t,i)=>{const e=p,s=t.changedParentTypes;for(;Lc(s,p,()=>[]).push(i),p._item!==null;)p=p._item.parent;Xx(e._eH,i,t)};class Co{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Yx(),this._dEH=Yx(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,i){this.doc=t,this._item=i}_copy(){throw va()}clone(){throw va()}_write(t){}get _first(){let t=this._start;for(;t!==null&&t.deleted;)t=t.right;return t}_callObserver(t,i){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){Zx(this._eH,t)}observeDeep(t){Zx(this._dEH,t)}unobserve(t){Qx(this._eH,t)}unobserveDeep(t){Qx(this._dEH,t)}toJSON(){}}const cw=(p,t,i)=>{p.doc??No(),t<0&&(t=p._length+t),i<0&&(i=p._length+i);let e=i-t;const s=[];let r=p._start;for(;r!==null&&e>0;){if(r.countable&&!r.deleted){const n=r.content.getContent();if(n.length<=t)t-=n.length;else{for(let o=t;o<n.length&&e>0;o++)s.push(n[o]),e--;t=0}}r=r.right}return s},uw=p=>{p.doc??No();const t=[];let i=p._start;for(;i!==null;){if(i.countable&&!i.deleted){const e=i.content.getContent();for(let s=0;s<e.length;s++)t.push(e[s])}i=i.right}return t},Cd=(p,t)=>{let i=0,e=p._start;for(p.doc??No();e!==null;){if(e.countable&&!e.deleted){const s=e.content.getContent();for(let r=0;r<s.length;r++)t(s[r],i++,p)}e=e.right}},dw=(p,t)=>{const i=[];return Cd(p,(e,s)=>{i.push(t(e,s,p))}),i},B5=p=>{let t=p._start,i=null,e=0;return{[Symbol.iterator](){return this},next:()=>{if(i===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};i=t.content.getContent(),e=0,t=t.right}const s=i[e++];return i.length<=e&&(i=null),{done:!1,value:s}}}},fw=(p,t)=>{p.doc??No();const i=Jp(p,t);let e=p._start;for(i!==null&&(e=i.p,t-=i.index);e!==null;e=e.right)if(!e.deleted&&e.countable){if(t<e.length)return e.content.getContent()[t];t-=e.length}},Kp=(p,t,i,e)=>{let s=i;const r=p.doc,n=r.clientID,o=r.store,l=i===null?t._start:i.right;let a=[];const u=()=>{a.length>0&&(s=new Po(Gr(n,ei(o,n)),s,s&&s.lastId,l,l&&l.id,t,null,new Gc(a)),s.integrate(p,0),a=[])};e.forEach(c=>{if(c===null)a.push(c);else switch(c.constructor){case Number:case Object:case Boolean:case Array:case String:a.push(c);break;default:switch(u(),c.constructor){case Uint8Array:case ArrayBuffer:s=new Po(Gr(n,ei(o,n)),s,s&&s.lastId,l,l&&l.id,t,null,new eh(new Uint8Array(c))),s.integrate(p,0);break;case Sd:s=new Po(Gr(n,ei(o,n)),s,s&&s.lastId,l,l&&l.id,t,null,new nh(c)),s.integrate(p,0);break;default:if(c instanceof Co)s=new Po(Gr(n,ei(o,n)),s,s&&s.lastId,l,l&&l.id,t,null,new Rs(c)),s.integrate(p,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},pw=()=>Hc("Length exceeded!"),hw=(p,t,i,e)=>{if(i>t._length)throw pw();if(i===0)return t._searchMarker&&Ed(t._searchMarker,i,e.length),Kp(p,t,null,e);const s=i,r=Jp(t,i);let n=t._start;for(r!==null&&(n=r.p,i-=r.index,i===0&&(n=n.prev,i+=n&&n.countable&&!n.deleted?n.length:0));n!==null;n=n.right)if(!n.deleted&&n.countable){if(i<=n.length){i<n.length&&Ps(p,Gr(n.id.client,n.id.clock+i));break}i-=n.length}return t._searchMarker&&Ed(t._searchMarker,s,e.length),Kp(p,t,n,e)},z5=(p,t,i)=>{let s=(t._searchMarker||[]).reduce((r,n)=>n.index>r.index?n:r,{index:0,p:t._start}).p;if(s)for(;s.right;)s=s.right;return Kp(p,t,s,i)},gw=(p,t,i,e)=>{if(e===0)return;const s=i,r=e,n=Jp(t,i);let o=t._start;for(n!==null&&(o=n.p,i-=n.index);o!==null&&i>0;o=o.right)!o.deleted&&o.countable&&(i<o.length&&Ps(p,Gr(o.id.client,o.id.clock+i)),i-=o.length);for(;e>0&&o!==null;)o.deleted||(e<o.length&&Ps(p,Gr(o.id.client,o.id.clock+e)),o.delete(p),e-=o.length),o=o.right;if(e>0)throw pw();t._searchMarker&&Ed(t._searchMarker,s,-r+e)},Yp=(p,t,i)=>{const e=t._map.get(i);e!==void 0&&e.delete(p)},xy=(p,t,i,e)=>{const s=t._map.get(i)||null,r=p.doc,n=r.clientID;let o;if(e==null)o=new Gc([e]);else switch(e.constructor){case Number:case Object:case Boolean:case Array:case String:o=new Gc([e]);break;case Uint8Array:o=new eh(e);break;case Sd:o=new nh(e);break;default:if(e instanceof Co)o=new Rs(e);else throw new Error("Unexpected content type")}new Po(Gr(n,ei(r.store,n)),s,s&&s.lastId,null,null,t,i,o).integrate(p,0)},wy=(p,t)=>{p.doc??No();const i=p._map.get(t);return i!==void 0&&!i.deleted?i.content.getContent()[i.length-1]:void 0},mw=p=>{const t={};return p.doc??No(),p._map.forEach((i,e)=>{i.deleted||(t[e]=i.content.getContent()[i.length-1])}),t},yw=(p,t)=>{p.doc??No();const i=p._map.get(t);return i!==void 0&&!i.deleted},U5=(p,t)=>{const i={};return p._map.forEach((e,s)=>{let r=e;for(;r!==null&&(!t.sv.has(r.id.client)||r.id.clock>=(t.sv.get(r.id.client)||0));)r=r.left;r!==null&&$c(r,t)&&(i[s]=r.content.getContent()[r.length-1])}),i},Zp=p=>(p.doc??No(),m5(p._map.entries(),t=>!t[1].deleted));class bw extends Vp{}class Cl extends Co{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){const i=new Cl;return i.push(t),i}_integrate(t,i){super._integrate(t,i),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Cl}clone(){const t=new Cl;return t.insert(0,this.toArray().map(i=>i instanceof Co?i.clone():i)),t}get length(){return this.doc??No(),this._length}_callObserver(t,i){super._callObserver(t,i),Gp(this,t,new bw(this,t))}insert(t,i){this.doc!==null?Dr(this.doc,e=>{hw(e,this,t,i)}):this._prelimContent.splice(t,0,...i)}push(t){this.doc!==null?Dr(this.doc,i=>{z5(i,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,i=1){this.doc!==null?Dr(this.doc,e=>{gw(e,this,t,i)}):this._prelimContent.splice(t,i)}get(t){return fw(this,t)}toArray(){return uw(this)}slice(t=0,i=this.length){return cw(this,t,i)}toJSON(){return this.map(t=>t instanceof Co?t.toJSON():t)}map(t){return dw(this,t)}forEach(t){Cd(this,t)}[Symbol.iterator](){return B5(this)}_write(t){t.writeTypeRef(Z5)}}class H5 extends Vp{constructor(t,i,e){super(t,i),this.keysChanged=e}}class qc extends Co{constructor(t){super(),this._prelimContent=null,t===void 0?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,i){super._integrate(t,i),this._prelimContent.forEach((e,s)=>{this.set(s,e)}),this._prelimContent=null}_copy(){return new qc}clone(){const t=new qc;return this.forEach((i,e)=>{t.set(e,i instanceof Co?i.clone():i)}),t}_callObserver(t,i){Gp(this,t,new H5(this,t,i))}toJSON(){this.doc??No();const t={};return this._map.forEach((i,e)=>{if(!i.deleted){const s=i.content.getContent()[i.length-1];t[e]=s instanceof Co?s.toJSON():s}}),t}get size(){return[...Zp(this)].length}keys(){return gy(Zp(this),t=>t[0])}values(){return gy(Zp(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return gy(Zp(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??No(),this._map.forEach((i,e)=>{i.deleted||t(i.content.getContent()[i.length-1],e,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?Dr(this.doc,i=>{Yp(i,this,t)}):this._prelimContent.delete(t)}set(t,i){return this.doc!==null?Dr(this.doc,e=>{xy(e,this,t,i)}):this._prelimContent.set(t,i),i}get(t){return wy(this,t)}has(t){return yw(this,t)}clear(){this.doc!==null?Dr(this.doc,t=>{this.forEach(function(i,e,s){Yp(t,s,e)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(Q5)}}const Is=(p,t)=>p===t||typeof p=="object"&&typeof t=="object"&&p&&t&&e5(p,t);class Sy{constructor(t,i,e,s){this.left=t,this.right=i,this.index=e,this.currentAttributes=s}forward(){switch(this.right===null&&El(),this.right.content.constructor){case mo:this.right.deleted||Wc(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const vw=(p,t,i)=>{for(;t.right!==null&&i>0;){switch(t.right.content.constructor){case mo:t.right.deleted||Wc(t.currentAttributes,t.right.content);break;default:t.right.deleted||(i<t.right.length&&Ps(p,Gr(t.right.id.client,t.right.id.clock+i)),t.index+=t.right.length,i-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},Qp=(p,t,i,e)=>{const s=new Map,r=e?Jp(t,i):null;if(r){const n=new Sy(r.p.left,r.p,r.index,s);return vw(p,n,i-r.index)}else{const n=new Sy(null,t._start,0,s);return vw(p,n,i)}},_w=(p,t,i,e)=>{for(;i.right!==null&&(i.right.deleted===!0||i.right.content.constructor===mo&&Is(e.get(i.right.content.key),i.right.content.value));)i.right.deleted||e.delete(i.right.content.key),i.forward();const s=p.doc,r=s.clientID;e.forEach((n,o)=>{const l=i.left,a=i.right,u=new Po(Gr(r,ei(s.store,r)),l,l&&l.lastId,a,a&&a.id,t,null,new mo(o,n));u.integrate(p,0),i.right=u,i.forward()})},Wc=(p,t)=>{const{key:i,value:e}=t;e===null?p.delete(i):p.set(i,e)},xw=(p,t)=>{for(;p.right!==null;){if(!(p.right.deleted||p.right.content.constructor===mo&&Is(t[p.right.content.key]??null,p.right.content.value)))break;p.forward()}},ww=(p,t,i,e)=>{const s=p.doc,r=s.clientID,n=new Map;for(const o in e){const l=e[o],a=i.currentAttributes.get(o)??null;if(!Is(a,l)){n.set(o,a);const{left:u,right:c}=i;i.right=new Po(Gr(r,ei(s.store,r)),u,u&&u.lastId,c,c&&c.id,t,null,new mo(o,l)),i.right.integrate(p,0),i.forward()}}return n},Ey=(p,t,i,e,s)=>{i.currentAttributes.forEach((f,d)=>{s[d]===void 0&&(s[d]=null)});const r=p.doc,n=r.clientID;xw(i,s);const o=ww(p,t,i,s),l=e.constructor===String?new Qa(e):e instanceof Co?new Rs(e):new Jc(e);let{left:a,right:u,index:c}=i;t._searchMarker&&Ed(t._searchMarker,i.index,l.getLength()),u=new Po(Gr(n,ei(r.store,n)),a,a&&a.lastId,u,u&&u.id,t,null,l),u.integrate(p,0),i.right=u,i.index=c,i.forward(),_w(p,t,i,o)},Sw=(p,t,i,e,s)=>{const r=p.doc,n=r.clientID;xw(i,s);const o=ww(p,t,i,s);e:for(;i.right!==null&&(e>0||o.size>0&&(i.right.deleted||i.right.content.constructor===mo));){if(!i.right.deleted)switch(i.right.content.constructor){case mo:{const{key:l,value:a}=i.right.content,u=s[l];if(u!==void 0){if(Is(u,a))o.delete(l);else{if(e===0)break e;o.set(l,a)}i.right.delete(p)}else i.currentAttributes.set(l,a);break}default:e<i.right.length&&Ps(p,Gr(i.right.id.client,i.right.id.clock+e)),e-=i.right.length;break}i.forward()}if(e>0){let l="";for(;e>0;e--)l+=`
|
|
1512
1512
|
`;i.right=new Po(Gr(n,ei(r.store,n)),i.left,i.left&&i.left.lastId,i.right,i.right&&i.right.id,t,null,new Qa(l)),i.right.integrate(p,0),i.forward()}_w(p,t,i,o)},Ew=(p,t,i,e,s)=>{let r=t;const n=ba();for(;r&&(!r.countable||r.deleted);){if(!r.deleted&&r.content.constructor===mo){const a=r.content;n.set(a.key,a)}r=r.right}let o=0,l=!1;for(;t!==r;){if(i===t&&(l=!0),!t.deleted){const a=t.content;switch(a.constructor){case mo:{const{key:u,value:c}=a,f=e.get(u)??null;(n.get(u)!==a||f===c)&&(t.delete(p),o++,!l&&(s.get(u)??null)===c&&f!==c&&(f===null?s.delete(u):s.set(u,f))),!l&&!t.deleted&&Wc(s,a);break}}}t=t.right}return o},$5=(p,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;const i=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===mo){const e=t.content.key;i.has(e)?t.delete(p):i.add(e)}t=t.left}},q5=p=>{let t=0;return Dr(p.doc,i=>{let e=p._start,s=p._start,r=ba();const n=ey(r);for(;s;){if(s.deleted===!1)switch(s.content.constructor){case mo:Wc(n,s.content);break;default:t+=Ew(i,e,s,r,n),r=ey(n),e=s;break}s=s.right}}),t},W5=p=>{const t=new Set,i=p.doc;for(const[e,s]of p.afterState.entries()){const r=p.beforeState.get(e)||0;s!==r&&nw(p,i.store.clients.get(e),r,s,n=>{!n.deleted&&n.content.constructor===mo&&n.constructor!==Ms&&t.add(n.parent)})}Dr(i,e=>{Wx(p,p.deleteSet,s=>{if(s instanceof Ms||!s.parent._hasFormatting||t.has(s.parent))return;const r=s.parent;s.content.constructor===mo?t.add(r):$5(e,s)});for(const s of t)q5(s)})},Cw=(p,t,i)=>{const e=i,s=ey(t.currentAttributes),r=t.right;for(;i>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Rs:case Jc:case Qa:i<t.right.length&&Ps(p,Gr(t.right.id.client,t.right.id.clock+i)),i-=t.right.length,t.right.delete(p);break}t.forward()}r&&Ew(p,r,t.right,s,t.currentAttributes);const n=(t.left||t.right).parent;return n._searchMarker&&Ed(n._searchMarker,t.index,-e+i),t};class V5 extends Vp{constructor(t,i,e){super(t,i),this.childListChanged=!1,this.keysChanged=new Set,e.forEach(s=>{s===null?this.childListChanged=!0:this.keysChanged.add(s)})}get changes(){if(this._changes===null){const t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){const t=this.target.doc,i=[];Dr(t,e=>{const s=new Map,r=new Map;let n=this.target._start,o=null;const l={};let a="",u=0,c=0;const f=()=>{if(o!==null){let d=null;switch(o){case"delete":c>0&&(d={delete:c}),c=0;break;case"insert":(typeof a=="object"||a.length>0)&&(d={insert:a},s.size>0&&(d.attributes={},s.forEach((h,m)=>{h!==null&&(d.attributes[m]=h)}))),a="";break;case"retain":u>0&&(d={retain:u},ZP(l)||(d.attributes=GP({},l))),u=0;break}d&&i.push(d),o=null}};for(;n!==null;){switch(n.content.constructor){case Rs:case Jc:this.adds(n)?this.deletes(n)||(f(),o="insert",a=n.content.getContent()[0],f()):this.deletes(n)?(o!=="delete"&&(f(),o="delete"),c+=1):n.deleted||(o!=="retain"&&(f(),o="retain"),u+=1);break;case Qa:this.adds(n)?this.deletes(n)||(o!=="insert"&&(f(),o="insert"),a+=n.content.str):this.deletes(n)?(o!=="delete"&&(f(),o="delete"),c+=n.length):n.deleted||(o!=="retain"&&(f(),o="retain"),u+=n.length);break;case mo:{const{key:d,value:h}=n.content;if(this.adds(n)){if(!this.deletes(n)){const m=s.get(d)??null;Is(m,h)?h!==null&&n.delete(e):(o==="retain"&&f(),Is(h,r.get(d)??null)?delete l[d]:l[d]=h)}}else if(this.deletes(n)){r.set(d,h);const m=s.get(d)??null;Is(m,h)||(o==="retain"&&f(),l[d]=m)}else if(!n.deleted){r.set(d,h);const m=l[d];m!==void 0&&(Is(m,h)?m!==null&&n.delete(e):(o==="retain"&&f(),h===null?delete l[d]:l[d]=h))}n.deleted||(o==="insert"&&f(),Wc(s,n.content));break}}n=n.right}for(f();i.length>0;){const d=i[i.length-1];if(d.retain!==void 0&&d.attributes===void 0)i.pop();else break}}),this._delta=i}return this._delta}}class Xp extends Co{constructor(t){super(),this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??No(),this._length}_integrate(t,i){super._integrate(t,i);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new Xp}clone(){const t=new Xp;return t.applyDelta(this.toDelta()),t}_callObserver(t,i){super._callObserver(t,i);const e=new V5(this,t,i);Gp(this,t,e),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??No();let t="",i=this._start;for(;i!==null;)!i.deleted&&i.countable&&i.content.constructor===Qa&&(t+=i.content.str),i=i.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:i=!0}={}){this.doc!==null?Dr(this.doc,e=>{const s=new Sy(null,this._start,0,new Map);for(let r=0;r<t.length;r++){const n=t[r];if(n.insert!==void 0){const o=!i&&typeof n.insert=="string"&&r===t.length-1&&s.right===null&&n.insert.slice(-1)===`
|
|
1513
|
-
`?n.insert.slice(0,-1):n.insert;(typeof o!="string"||o.length>0)&&Ey(e,this,s,o,n.attributes||{})}else n.retain!==void 0?Sw(e,this,s,n.retain,n.attributes||{}):n.delete!==void 0&&Cw(e,s,n.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,i,e){this.doc??No();const s=[],r=new Map,n=this.doc;let o="",l=this._start;function a(){if(o.length>0){const c={};let f=!1;r.forEach((h,m)=>{f=!0,c[m]=h});const d={insert:o};f&&(d.attributes=c),s.push(d),o=""}}const u=()=>{for(;l!==null;){if($c(l,t)||i!==void 0&&$c(l,i))switch(l.content.constructor){case Qa:{const c=r.get("ychange");t!==void 0&&!$c(l,t)?(c===void 0||c.user!==l.id.client||c.type!=="removed")&&(a(),r.set("ychange",e?e("removed",l.id):{type:"removed"})):i!==void 0&&!$c(l,i)?(c===void 0||c.user!==l.id.client||c.type!=="added")&&(a(),r.set("ychange",e?e("added",l.id):{type:"added"})):c!==void 0&&(a(),r.delete("ychange")),o+=l.content.str;break}case Rs:case Jc:{a();const c={insert:l.content.getContent()[0]};if(r.size>0){const f={};c.attributes=f,r.forEach((d,h)=>{f[h]=d})}s.push(c);break}case mo:$c(l,t)&&(a(),Wc(r,l.content));break}l=l.right}a()};return t||i?Dr(n,c=>{t&&my(c,t),i&&my(c,i),u()},"cleanup"):u(),s}insert(t,i,e){if(i.length<=0)return;const s=this.doc;s!==null?Dr(s,r=>{const n=Qp(r,this,t,!e);e||(e={},n.currentAttributes.forEach((o,l)=>{e[l]=o})),Ey(r,this,n,i,e)}):this._pending.push(()=>this.insert(t,i,e))}insertEmbed(t,i,e){const s=this.doc;s!==null?Dr(s,r=>{const n=Qp(r,this,t,!e);Ey(r,this,n,i,e||{})}):this._pending.push(()=>this.insertEmbed(t,i,e||{}))}delete(t,i){if(i===0)return;const e=this.doc;e!==null?Dr(e,s=>{Cw(s,Qp(s,this,t,!0),i)}):this._pending.push(()=>this.delete(t,i))}format(t,i,e){if(i===0)return;const s=this.doc;s!==null?Dr(s,r=>{const n=Qp(r,this,t,!1);n.right!==null&&Sw(r,this,n,i,e)}):this._pending.push(()=>this.format(t,i,e))}removeAttribute(t){this.doc!==null?Dr(this.doc,i=>{Yp(i,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,i){this.doc!==null?Dr(this.doc,e=>{xy(e,this,t,i)}):this._pending.push(()=>this.setAttribute(t,i))}getAttribute(t){return wy(this,t)}getAttributes(){return mw(this)}_write(t){t.writeTypeRef(X5)}}class Cy{constructor(t,i=()=>!0){this._filter=i,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??No()}[Symbol.iterator](){return this}next(){let t=this._currentNode,i=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(i)))do if(i=t.content.type,!t.deleted&&(i.constructor===kd||i.constructor===Vc)&&i._start!==null)t=i._start;else for(;t!==null;)if(t.right!==null){t=t.right;break}else t.parent===this._root?t=null:t=t.parent._item;while(t!==null&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,t===null?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}}class Vc extends Co{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,i){super._integrate(t,i),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Vc}clone(){const t=new Vc;return t.insert(0,this.toArray().map(i=>i instanceof Co?i.clone():i)),t}get length(){return this.doc??No(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new Cy(this,t)}querySelector(t){t=t.toUpperCase();const e=new Cy(this,s=>s.nodeName&&s.nodeName.toUpperCase()===t).next();return e.done?null:e.value}querySelectorAll(t){return t=t.toUpperCase(),Bc(new Cy(this,i=>i.nodeName&&i.nodeName.toUpperCase()===t))}_callObserver(t,i){Gp(this,t,new J5(this,i,t))}toString(){return dw(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,i={},e){const s=t.createDocumentFragment();return e!==void 0&&e._createAssociation(s,this),Cd(this,r=>{s.insertBefore(r.toDOM(t,i,e),null)}),s}insert(t,i){this.doc!==null?Dr(this.doc,e=>{hw(e,this,t,i)}):this._prelimContent.splice(t,0,...i)}insertAfter(t,i){if(this.doc!==null)Dr(this.doc,e=>{const s=t&&t instanceof Co?t._item:t;Kp(e,this,s,i)});else{const e=this._prelimContent,s=t===null?0:e.findIndex(r=>r===t)+1;if(s===0&&t!==null)throw Hc("Reference item not found");e.splice(s,0,...i)}}delete(t,i=1){this.doc!==null?Dr(this.doc,e=>{gw(e,this,t,i)}):this._prelimContent.splice(t,i)}toArray(){return uw(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return fw(this,t)}slice(t=0,i=this.length){return cw(this,t,i)}forEach(t){Cd(this,t)}_write(t){t.writeTypeRef(tI)}}class kd extends Vc{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,i){super._integrate(t,i),this._prelimAttrs.forEach((e,s)=>{this.setAttribute(s,e)}),this._prelimAttrs=null}_copy(){return new kd(this.nodeName)}clone(){const t=new kd(this.nodeName),i=this.getAttributes();return YP(i,(e,s)=>{typeof e=="string"&&t.setAttribute(s,e)}),t.insert(0,this.toArray().map(e=>e instanceof Co?e.clone():e)),t}toString(){const t=this.getAttributes(),i=[],e=[];for(const o in t)e.push(o);e.sort();const s=e.length;for(let o=0;o<s;o++){const l=e[o];i.push(l+'="'+t[l]+'"')}const r=this.nodeName.toLocaleLowerCase(),n=i.length>0?" "+i.join(" "):"";return`<${r}${n}>${super.toString()}</${r}>`}removeAttribute(t){this.doc!==null?Dr(this.doc,i=>{Yp(i,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,i){this.doc!==null?Dr(this.doc,e=>{xy(e,this,t,i)}):this._prelimAttrs.set(t,i)}getAttribute(t){return wy(this,t)}hasAttribute(t){return yw(this,t)}getAttributes(t){return t?U5(this,t):mw(this)}toDOM(t=document,i={},e){const s=t.createElement(this.nodeName),r=this.getAttributes();for(const n in r){const o=r[n];typeof o=="string"&&s.setAttribute(n,o)}return Cd(this,n=>{s.appendChild(n.toDOM(t,i,e))}),e!==void 0&&e._createAssociation(s,this),s}_write(t){t.writeTypeRef(eI),t.writeKey(this.nodeName)}}class J5 extends Vp{constructor(t,i,e){super(t,e),this.childListChanged=!1,this.attributesChanged=new Set,i.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}}class kw{constructor(t,i){this.id=t,this.length=i}get deleted(){throw va()}mergeWith(t){return!1}write(t,i,e){throw va()}integrate(t,i){throw va()}}const G5=0;class Ms extends kw{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,i){i>0&&(this.id.clock+=i,this.length-=i),ew(t.doc.store,this)}write(t,i){t.writeInfo(G5),t.writeLen(this.length-i)}getMissing(t,i){return null}}class eh{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new eh(this.content)}splice(t){throw va()}mergeWith(t){return!1}integrate(t,i){}delete(t){}gc(t){}write(t,i){t.writeBuf(this.content)}getRef(){return 3}}class th{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new th(this.len)}splice(t){const i=new th(this.len-t);return this.len=t,i}mergeWith(t){return this.len+=t.len,!0}integrate(t,i){Gx(t.deleteSet,i.id.client,i.id.clock,this.len),i.markDeleted()}delete(t){}gc(t){}write(t,i){t.writeLen(this.len-i)}getRef(){return 1}}const K5=(p,t)=>new Sd({guid:p,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class nh{constructor(t){t._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;const i={};this.opts=i,t.gc||(i.gc=!1),t.autoLoad&&(i.autoLoad=!0),t.meta!==null&&(i.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new nh(K5(this.doc.guid,this.opts))}splice(t){throw va()}mergeWith(t){return!1}integrate(t,i){this.doc._item=i,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,i){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}class Jc{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Jc(this.embed)}splice(t){throw va()}mergeWith(t){return!1}integrate(t,i){}delete(t){}gc(t){}write(t,i){t.writeJSON(this.embed)}getRef(){return 5}}class mo{constructor(t,i){this.key=t,this.value=i}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new mo(this.key,this.value)}splice(t){throw va()}mergeWith(t){return!1}integrate(t,i){const e=i.parent;e._searchMarker=null,e._hasFormatting=!0}delete(t){}gc(t){}write(t,i){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}const Y5=Hp("node_env")==="development";class Gc{constructor(t){this.arr=t,Y5&&Lx(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Gc(this.arr)}splice(t){const i=new Gc(this.arr.slice(t));return this.arr=this.arr.slice(0,t),i}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,i){}delete(t){}gc(t){}write(t,i){const e=this.arr.length;t.writeLen(e-i);for(let s=i;s<e;s++){const r=this.arr[s];t.writeAny(r)}}getRef(){return 8}}class Qa{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Qa(this.str)}splice(t){const i=new Qa(this.str.slice(t));this.str=this.str.slice(0,t);const e=this.str.charCodeAt(t-1);return e>=55296&&e<=56319&&(this.str=this.str.slice(0,t-1)+"�",i.str="�"+i.str.slice(1)),i}mergeWith(t){return this.str+=t.str,!0}integrate(t,i){}delete(t){}gc(t){}write(t,i){t.writeString(i===0?this.str:this.str.slice(i))}getRef(){return 4}}const Z5=0,Q5=1,X5=2,eI=3,tI=4;class Rs{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Rs(this.type._copy())}splice(t){throw va()}mergeWith(t){return!1}integrate(t,i){this.type._integrate(t.doc,i)}delete(t){let i=this.type._start;for(;i!==null;)i.deleted?i.id.clock<(t.beforeState.get(i.id.client)||0)&&t._mergeStructs.push(i):i.delete(t),i=i.right;this.type._map.forEach(e=>{e.deleted?e.id.clock<(t.beforeState.get(e.id.client)||0)&&t._mergeStructs.push(e):e.delete(t)}),t.changed.delete(this.type)}gc(t){let i=this.type._start;for(;i!==null;)i.gc(t,!0),i=i.right;this.type._start=null,this.type._map.forEach(e=>{for(;e!==null;)e.gc(t,!0),e=e.left}),this.type._map=new Map}write(t,i){this.type._write(t)}getRef(){return 7}}const Tw=(p,t,i)=>{const{client:e,clock:s}=t.id,r=new Po(Gr(e,s+i),t,Gr(e,s+i-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(i));return t.deleted&&r.markDeleted(),t.keep&&(r.keep=!0),t.redone!==null&&(r.redone=Gr(t.redone.client,t.redone.clock+i)),t.right=r,r.right!==null&&(r.right.left=r),p._mergeStructs.push(r),r.parentSub!==null&&r.right===null&&r.parent._map.set(r.parentSub,r),t.length=i,r};class Po extends kw{constructor(t,i,e,s,r,n,o,l){super(t,l.getLength()),this.origin=e,this.left=i,this.right=s,this.rightOrigin=r,this.parent=n,this.parentSub=o,this.redone=null,this.content=l,this.info=this.content.isCountable()?Ex:0}set marker(t){(this.info&ry)>0!==t&&(this.info^=ry)}get marker(){return(this.info&ry)>0}get keep(){return(this.info&Sx)>0}set keep(t){this.keep!==t&&(this.info^=Sx)}get countable(){return(this.info&Ex)>0}get deleted(){return(this.info&ny)>0}set deleted(t){this.deleted!==t&&(this.info^=ny)}markDeleted(){this.info|=ny}getMissing(t,i){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=ei(i,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=ei(i,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===$p&&this.id.client!==this.parent.client&&this.parent.clock>=ei(i,this.parent.client))return this.parent.client;if(this.origin&&(this.left=tw(t,i,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Ps(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Ms||this.right&&this.right.constructor===Ms)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Po&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===Po&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===$p){const e=by(i,this.parent);e.constructor===Ms?this.parent=null:this.parent=e.content.type}return null}integrate(t,i){if(i>0&&(this.id.clock+=i,this.left=tw(t,t.doc.store,Gr(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(i),this.length-=i),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let e=this.left,s;if(e!==null)s=e.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;const r=new Set,n=new Set;for(;s!==null&&s!==this.right;){if(n.add(s),r.add(s),qp(this.origin,s.origin)){if(s.id.client<this.id.client)e=s,r.clear();else if(qp(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&n.has(by(t.doc.store,s.origin)))r.has(by(t.doc.store,s.origin))||(e=s,r.clear());else break;s=s.right}this.left=e}if(this.left!==null){const e=this.left.right;this.right=e,this.left.right=this}else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),ew(t.doc.store,this),this.content.integrate(t,this),ow(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new Ms(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:Gr(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&qp(t.origin,this.lastId)&&this.right===t&&qp(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const i=this.parent._searchMarker;return i&&i.forEach(e=>{e.p===t&&(e.p=this,!this.deleted&&this.countable&&(e.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){const i=this.parent;this.countable&&this.parentSub===null&&(i._length-=this.length),this.markDeleted(),Gx(t.deleteSet,this.id.client,this.id.clock,this.length),ow(t,i,this.parentSub),this.content.delete(t)}}gc(t,i){if(!this.deleted)throw El();this.content.gc(t),i?N5(t,this,new Ms(this.id,this.length)):this.content=new th(this.length)}write(t,i){const e=i>0?Gr(this.id.client,this.id.clock+i-1):this.origin,s=this.rightOrigin,r=this.parentSub,n=this.content.getRef()&SP|(e===null?0:zp)|(s===null?0:Cx)|(r===null?0:wP);if(t.writeInfo(n),e!==null&&t.writeLeftID(e),s!==null&&t.writeRightID(s),e===null&&s===null){const o=this.parent;if(o._item!==void 0){const l=o._item;if(l===null){const a=A5(o);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else o.constructor===String?(t.writeParentInfo(!0),t.writeString(o)):o.constructor===$p?(t.writeParentInfo(!1),t.writeLeftID(o)):El();r!==null&&t.writeString(r)}this.content.write(t,i)}}const Ow=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Aw="__ $YJS$ __";Ow[Aw]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Ow[Aw]=!0;function nI(p){return p&&p.__esModule&&Object.prototype.hasOwnProperty.call(p,"default")?p.default:p}nI(function(p){const t=new URLSearchParams;t.append("code",p);for(let i=1;i<arguments.length;i++)t.append("v",arguments[i]);throw Error(`Minified Lexical error #${p}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const rI=Yo();function jw(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function rh(p,t,i,e,s){return{author:t,content:p,deleted:s===void 0?!1:s,id:i===void 0?jw():i,timeStamp:e===void 0?performance.now():e,type:"comment"}}function Nw(p,t,i){return{comments:t,id:i===void 0?jw():i,quote:p,type:"thread"}}function Pw(p){return{comments:Array.from(p.comments),id:p.id,quote:p.quote,type:"thread"}}function oI(p){return{author:p.author,content:"[Deleted Comment]",deleted:!0,id:p.id,timeStamp:p.timeStamp,type:"comment"}}function Iw(p){const t=p._changeListeners;for(const i of t)i()}class iI{constructor(t){Hr(this,"_editor");Hr(this,"_comments");Hr(this,"_changeListeners");Hr(this,"_collabProvider");this._comments=[],this._editor=t,this._collabProvider=null,this._changeListeners=new Set}isCollaborative(){return this._collabProvider!==null}getComments(){return this._comments}addComment(t,i,e){const s=Array.from(this._comments),r=this._getCollabComments();if(i!==void 0&&t.type==="comment")for(let n=0;n<s.length;n++){const o=s[n];if(o.type==="thread"&&o.id===i.id){const l=Pw(o);s.splice(n,1,l);const a=e!==void 0?e:l.comments.length;if(this.isCollaborative()&&r!==null){const u=r.get(n).get("comments");this._withRemoteTransaction(()=>{const c=this._createCollabSharedMap(t);u.insert(a,[c])})}l.comments.splice(a,0,t);break}}else{const n=e!==void 0?e:s.length;this.isCollaborative()&&r!==null&&this._withRemoteTransaction(()=>{const o=this._createCollabSharedMap(t);r.insert(n,[o])}),s.splice(n,0,t)}this._comments=s,Iw(this)}deleteCommentOrThread(t,i){const e=Array.from(this._comments),s=this._getCollabComments();let r=null;if(i!==void 0)for(let n=0;n<e.length;n++){const o=e[n];if(o.type==="thread"&&o.id===i.id){const l=Pw(o);e.splice(n,1,l);const a=l.comments;if(r=a.indexOf(t),this.isCollaborative()&&s!==null){const u=s.get(n).get("comments");this._withRemoteTransaction(()=>{u.delete(r)})}a.splice(r,1);break}}else r=e.indexOf(t),this.isCollaborative()&&s!==null&&this._withRemoteTransaction(()=>{s.delete(r)}),e.splice(r,1);return this._comments=e,Iw(this),t.type==="comment"?{index:r,markedComment:oI(t)}:null}registerOnChange(t){const i=this._changeListeners;return i.add(t),()=>{i.delete(t)}}_withRemoteTransaction(t){const i=this._collabProvider;i!==null&&i.doc.transact(t,this)}_withLocalTransaction(t){const i=this._collabProvider;try{this._collabProvider=null,t()}finally{this._collabProvider=i}}_getCollabComments(){const t=this._collabProvider;return t!==null?t.doc.get("comments",Cl):null}_createCollabSharedMap(t){const i=new qc,e=t.type,s=t.id;if(i.set("type",e),i.set("id",s),e==="comment")i.set("author",t.author),i.set("content",t.content),i.set("deleted",t.deleted),i.set("timeStamp",t.timeStamp);else{i.set("quote",t.quote);const r=new Cl;t.comments.forEach((n,o)=>{const l=this._createCollabSharedMap(n);r.insert(o,[l])}),i.set("comments",r)}return i}registerCollaboration(t){this._collabProvider=t;const i=this._getCollabComments(),e=()=>{t.connect()},s=()=>{try{t.disconnect()}catch{}},r=this._editor.registerCommand(rI,o=>(e!==void 0&&s!==void 0&&(o?(console.log("Comments connected!"),e()):(console.log("Comments disconnected!"),s())),!1),Ln),n=(o,l)=>{if(l.origin!==this)for(let a=0;a<o.length;a++){const u=o[a];if(u instanceof bw){const c=u.target,f=u.delta;let d=0;for(let h=0;h<f.length;h++){const m=f[h],g=m.insert,_=m.retain,v=m.delete,b=c.parent,S=c===i?void 0:b instanceof qc&&this._comments.find(E=>E.id===b.get("id"));if(Array.isArray(g))g.slice().reverse().forEach(E=>{const x=E.get("id"),w=E.get("type")==="thread"?Nw(E.get("quote"),E.get("comments").toArray().map(C=>rh(C.get("content"),C.get("author"),C.get("id"),C.get("timeStamp"),C.get("deleted"))),x):rh(E.get("content"),E.get("author"),x,E.get("timeStamp"),E.get("deleted"));this._withLocalTransaction(()=>{this.addComment(w,S,d)})});else if(typeof _=="number")d+=_;else if(typeof v=="number")for(let E=0;E<v;E++){const x=S===void 0||S===!1?this._comments[d]:S.comments[d];this._withLocalTransaction(()=>{this.deleteCommentOrThread(x,S)}),d++}}}}};return i===null?()=>null:(i.observeDeep(n),e(),()=>{i.unobserveDeep(n),r(),this._collabProvider=null})}}function aI(p){const[t,i]=ve.useState(p.getComments());return ve.useEffect(()=>p.registerOnChange(()=>{i(p.getComments())}),[p]),t}const TM="";function ky({className:p,style:t}){return _e.jsx(fp,{className:p||"ContentEditable__root",style:t})}const OM="";function Ty({children:p,className:t}){return _e.jsx("div",{className:t||"Placeholder__root",children:p})}const Oy=Yo();function sI({anchorKey:p,editor:t,onAddComment:i}){const e=ve.useRef(null),s=ve.useCallback(()=>{const r=e.current,n=t.getRootElement(),o=t.getElementByKey(p);if(r!==null&&n!==null&&o!==null){const{right:l}=n.getBoundingClientRect(),{top:a}=o.getBoundingClientRect();r.style.left=`${l-20}px`,r.style.top=`${a-30}px`}},[p,t]);return ve.useEffect(()=>(window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s)}),[t,s]),xx(()=>{s()},[p,t,s]),_e.jsx("div",{className:"CommentPlugin_AddCommentBox",ref:e,children:_e.jsx("button",{className:"CommentPlugin_AddCommentBox_button",onClick:i,children:_e.jsx("i",{className:"icon add-comment"})})})}function lI({onEscape:p}){const[t]=Yn();return ve.useEffect(()=>t.registerCommand(Ia,i=>p(i),2),[t,p]),null}function Mw({className:p,autoFocus:t,onEscape:i,onChange:e,editorRef:s,placeholder:r="Type a comment..."}){const n={namespace:"Commenting",nodes:[],onError:o=>{throw o},theme:Ug};return _e.jsx(zf,{initialConfig:n,children:_e.jsxs("div",{className:"CommentPlugin_CommentInputBox_EditorContainer",children:[_e.jsx(i_,{contentEditable:_e.jsx(ky,{className:p}),placeholder:_e.jsx(Ty,{children:r}),ErrorBoundary:mc}),_e.jsx(Am,{onChange:e}),_e.jsx(gp,{}),t!==!1&&_e.jsx(dp,{}),_e.jsx(lI,{onEscape:i}),_e.jsx(e_,{}),s!==void 0&&_e.jsx(mP,{editorRef:s})]})})}function Rw(p,t){return ve.useCallback((i,e)=>{i.read(()=>{p(xm()),t(!wm(e.isComposing(),!0))})},[t,p])}function cI({editor:p,cancelAddComment:t,submitAddComment:i}){const[e,s]=ve.useState(""),[r,n]=ve.useState(!1),o=ve.useRef(null),l=ve.useMemo(()=>({container:document.createElement("div"),elements:[]}),[]),a=ve.useRef(null),u=Fw(),c=ve.useCallback(()=>{p.getEditorState().read(()=>{const m=Ot();if(Et(m)){a.current=m.clone();const g=m.anchor,_=m.focus,v=fv(p,g.getNode(),g.offset,_.getNode(),_.offset),b=o.current;if(v!==null&&b!==null){const{left:S,bottom:E,width:x}=v.getBoundingClientRect(),y=pv(p,v);let w=y.length===1?S+x/2-125:S-125;w<10&&(w=10),b.style.left=`${w}px`,b.style.top=`${E+20+(window.pageYOffset||document.documentElement.scrollTop)}px`;const C=y.length,{container:j}=l,P=l.elements,F=P.length;for(let I=0;I<C;I++){const D=y[I];let N=P[I];N===void 0&&(N=document.createElement("span"),P[I]=N,j.appendChild(N));const k="255, 212, 0",A=`position:absolute;top:${D.top+(window.pageYOffset||document.documentElement.scrollTop)}px;left:${D.left}px;height:${D.height}px;width:${D.width}px;background-color:rgba(${k}, 0.3);pointer-events:none;z-index:5;`;N.style.cssText=A}for(let I=F-1;I>=C;I--){const D=P[I];j.removeChild(D),P.pop()}}}})},[p,l]);xx(()=>{c();const m=l.container,g=document.body;if(g!==null)return g.appendChild(m),()=>{g.removeChild(m)}},[l.container,c]),ve.useEffect(()=>(window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}),[c]);const f=m=>(m.preventDefault(),t(),!0),d=()=>{if(r){let m=p.getEditorState().read(()=>{const g=a.current;return g?g.getTextContent():""});m.length>100&&(m=m.slice(0,99)+"…"),i(Nw(m,[rh(e,u)]),!0,void 0,a.current),a.current=null}},h=Rw(s,n);return _e.jsxs("div",{className:"CommentPlugin_CommentInputBox",ref:o,children:[_e.jsx(Mw,{className:"CommentPlugin_CommentInputBox_Editor",onEscape:f,onChange:h}),_e.jsxs("div",{className:"CommentPlugin_CommentInputBox_Buttons",children:[_e.jsx(fa,{onClick:t,className:"CommentPlugin_CommentInputBox_Button",children:"Cancel"}),_e.jsx(fa,{onClick:d,disabled:!r,className:"CommentPlugin_CommentInputBox_Button primary",children:"Comment"})]})]})}function uI({submitAddComment:p,thread:t,placeholder:i}){const[e,s]=ve.useState(""),[r,n]=ve.useState(!1),o=ve.useRef(null),l=Fw(),a=Rw(s,n),u=()=>{if(r){p(rh(e,l),!1,t);const c=o.current;c!==null&&c.dispatchCommand(af,void 0)}};return _e.jsxs(_e.Fragment,{children:[_e.jsx(Mw,{className:"CommentPlugin_CommentsPanel_Editor",autoFocus:!1,onEscape:()=>!0,onChange:a,editorRef:o,placeholder:i}),_e.jsx(fa,{className:"CommentPlugin_CommentsPanel_SendButton",onClick:u,disabled:!r,children:_e.jsx("i",{className:"send"})})]})}function Dw({commentOrThread:p,deleteCommentOrThread:t,onClose:i,thread:e=void 0}){return _e.jsxs(_e.Fragment,{children:["Are you sure you want to delete this ",p.type,"?",_e.jsxs("div",{className:"Modal__content",children:[_e.jsx(fa,{onClick:()=>{t(p,e),i()},children:"Delete"})," ",_e.jsx(fa,{onClick:()=>{i()},children:"Cancel"})]})]})}function Lw({comment:p,deleteComment:t,thread:i,rtf:e}){const s=Math.round((p.timeStamp-performance.now())/1e3),r=Math.round(s/60),[n,o]=cp();return _e.jsxs("li",{className:"CommentPlugin_CommentsPanel_List_Comment",children:[_e.jsxs("div",{className:"CommentPlugin_CommentsPanel_List_Details",children:[_e.jsx("span",{className:"CommentPlugin_CommentsPanel_List_Comment_Author",children:p.author}),_e.jsxs("span",{className:"CommentPlugin_CommentsPanel_List_Comment_Time",children:["· ",s>-10?"Just now":e.format(r,"minute")]})]}),_e.jsx("p",{className:p.deleted?"CommentPlugin_CommentsPanel_DeletedComment":"",children:p.content}),!p.deleted&&_e.jsxs(_e.Fragment,{children:[_e.jsx(fa,{onClick:()=>{o("Delete Comment",l=>_e.jsx(Dw,{commentOrThread:p,deleteCommentOrThread:t,thread:i,onClose:l}))},className:"CommentPlugin_CommentsPanel_List_DeleteButton",children:_e.jsx("i",{className:"delete"})}),n]})]})}function dI({activeIDs:p,comments:t,deleteCommentOrThread:i,listRef:e,submitAddComment:s,markNodeMap:r}){const[n]=Yn(),[o,l]=ve.useState(0),[a,u]=cp(),c=ve.useMemo(()=>new Intl.RelativeTimeFormat("en",{localeMatcher:"best fit",numeric:"auto",style:"short"}),[]);return ve.useEffect(()=>{const f=setTimeout(()=>{l(o+1)},1e4);return()=>{clearTimeout(f)}},[o]),_e.jsx("ul",{className:"CommentPlugin_CommentsPanel_List",ref:e,children:t.map(f=>{const d=f.id;if(f.type==="thread"){const h=()=>{const m=r.get(d);if(m!==void 0&&(p===null||p.indexOf(d)===-1)){const g=document.activeElement;n.update(()=>{const _=Array.from(m)[0],v=Xn(_);ha(v)&&v.selectStart()},{onUpdate(){g!==null&&g.focus()}})}};return _e.jsxs("li",{onClick:h,className:`CommentPlugin_CommentsPanel_List_Thread ${r.has(d)?"interactive":""} ${p.indexOf(d)===-1?"":"active"}`,children:[_e.jsxs("div",{className:"CommentPlugin_CommentsPanel_List_Thread_QuoteBox",children:[_e.jsxs("blockquote",{className:"CommentPlugin_CommentsPanel_List_Thread_Quote",children:["> ",_e.jsx("span",{children:f.quote})]}),_e.jsx(fa,{onClick:()=>{u("Delete Thread",m=>_e.jsx(Dw,{commentOrThread:f,deleteCommentOrThread:i,onClose:m}))},className:"CommentPlugin_CommentsPanel_List_DeleteButton",children:_e.jsx("i",{className:"delete"})}),a]}),_e.jsx("ul",{className:"CommentPlugin_CommentsPanel_List_Thread_Comments",children:f.comments.map(m=>_e.jsx(Lw,{comment:m,deleteComment:i,thread:f,rtf:c},m.id))}),_e.jsx("div",{className:"CommentPlugin_CommentsPanel_List_Thread_Editor",children:_e.jsx(uI,{submitAddComment:s,thread:f,placeholder:"Reply to comment..."})})]},d)}return _e.jsx(Lw,{comment:f,deleteComment:i,rtf:c},d)})})}function fI({activeIDs:p,deleteCommentOrThread:t,comments:i,submitAddComment:e,markNodeMap:s}){const r=ve.useRef(null),n=i.length===0;return _e.jsxs("div",{className:"CommentPlugin_CommentsPanel",children:[_e.jsx("h2",{className:"CommentPlugin_CommentsPanel_Heading",children:"Comments"}),n?_e.jsx("div",{className:"CommentPlugin_CommentsPanel_Empty",children:"No Comments"}):_e.jsx(dI,{activeIDs:p,comments:i,deleteCommentOrThread:t,listRef:r,submitAddComment:e,markNodeMap:s})]})}function Fw(){const p=pp(),{yjsDocMap:t,name:i}=p;return t.has("comments")?i:"Playground User"}function pI({providerFactory:p}){const t=pp(),[i]=Yn(),e=ve.useMemo(()=>new iI(i),[i]),s=aI(e),r=ve.useMemo(()=>new Map,[]),[n,o]=ve.useState(),[l,a]=ve.useState([]),[u,c]=ve.useState(!1),[f,d]=ve.useState(!1),{yjsDocMap:h}=t;ve.useEffect(()=>{if(p){const b=p("comments",h);return e.registerCollaboration(b)}},[e,p,h]);const m=ve.useCallback(()=>{i.update(()=>{const b=Ot();b!==null&&(b.dirty=!0)}),c(!1)},[i]),g=ve.useCallback((b,S)=>{if(b.type==="comment"){const E=e.deleteCommentOrThread(b,S);if(!E)return;const{markedComment:x,index:y}=E;e.addComment(x,S,y)}else{e.deleteCommentOrThread(b);const E=S!==void 0?S.id:b.id,x=r.get(E);x!==void 0&&setTimeout(()=>{i.update(()=>{for(const y of x){const w=Xn(y);ha(w)&&(w.deleteID(E),w.getIDs().length===0&&K1(w))}})})}},[e,i,r]),_=ve.useCallback((b,S,E,x)=>{e.addComment(b,E),S&&(i.update(()=>{if(Et(x)){const y=x.isBackward(),w=b.id;Y1(x,y,w)}}),c(!1))},[e,i]);ve.useEffect(()=>{console.log("askjdhasdhasjkdh");const b=[];for(let S=0;S<l.length;S++){const E=l[S],x=r.get(E);if(x!==void 0)for(const y of x){const w=i.getElementByKey(y);w!==null&&(w.classList.add("selected"),b.push(w),d(!0))}}return()=>{for(let S=0;S<b.length;S++)b[S].classList.remove("selected")}},[l,i,r]),ve.useEffect(()=>{const b=new Map;return Mr(xv(i,od,S=>id(S.getIDs()),(S,E)=>{S.getIDs().forEach(y=>{E.addID(y)})}),i.registerMutationListener(od,S=>{i.getEditorState().read(()=>{for(const[E,x]of S){const y=Xn(E);let w=[];x==="destroyed"?w=b.get(E)||[]:ha(y)&&(w=y.getIDs());for(let C=0;C<w.length;C++){const j=w[C];let P=r.get(j);b.set(E,w),x==="destroyed"?P!==void 0&&(P.delete(E),P.size===0&&r.delete(j)):(P===void 0&&(P=new Set,r.set(j,P)),P.has(E)||P.add(E))}}})}),i.registerUpdateListener(({editorState:S,tags:E})=>{S.read(()=>{const x=Ot();let y=!1,w=!1;if(Et(x)){const C=x.anchor.getNode();if(qt(C)){const j=Z1(C,x.anchor.offset);j!==null&&(a(j),y=!0),x.isCollapsed()||(o(C.getKey()),w=!0)}}y||a(C=>C.length===0?C:[]),w||o(null),!E.has("collaboration")&&Et(x)&&c(!1)})}),i.registerCommand(Oy,()=>{const S=window.getSelection();return S!==null&&S.removeAllRanges(),c(!0),!0},Tn))},[i,r]);const v=()=>{i.dispatchCommand(Oy,void 0)};return _e.jsxs(_e.Fragment,{children:[u&&ro.createPortal(_e.jsx(cI,{editor:i,cancelAddComment:m,submitAddComment:_}),document.body),n!=null&&!u&&ro.createPortal(_e.jsx(sI,{anchorKey:n,editor:i,onAddComment:v}),document.body),ro.createPortal(_e.jsx(fa,{className:`CommentPlugin_ShowCommentsButton ${f?"active":""}`,onClick:()=>d(!f),title:f?"Hide Comments":"Show Comments",children:_e.jsx("i",{className:"comments"})}),document.body),f&&ro.createPortal(_e.jsx(fI,{comments:s,submitAddComment:_,deleteCommentOrThread:g,activeIDs:l,markNodeMap:r}),document.body)]})}var hI={exports:{}};(function(p){var t=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};/**
|
|
1513
|
+
`?n.insert.slice(0,-1):n.insert;(typeof o!="string"||o.length>0)&&Ey(e,this,s,o,n.attributes||{})}else n.retain!==void 0?Sw(e,this,s,n.retain,n.attributes||{}):n.delete!==void 0&&Cw(e,s,n.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,i,e){this.doc??No();const s=[],r=new Map,n=this.doc;let o="",l=this._start;function a(){if(o.length>0){const c={};let f=!1;r.forEach((h,m)=>{f=!0,c[m]=h});const d={insert:o};f&&(d.attributes=c),s.push(d),o=""}}const u=()=>{for(;l!==null;){if($c(l,t)||i!==void 0&&$c(l,i))switch(l.content.constructor){case Qa:{const c=r.get("ychange");t!==void 0&&!$c(l,t)?(c===void 0||c.user!==l.id.client||c.type!=="removed")&&(a(),r.set("ychange",e?e("removed",l.id):{type:"removed"})):i!==void 0&&!$c(l,i)?(c===void 0||c.user!==l.id.client||c.type!=="added")&&(a(),r.set("ychange",e?e("added",l.id):{type:"added"})):c!==void 0&&(a(),r.delete("ychange")),o+=l.content.str;break}case Rs:case Jc:{a();const c={insert:l.content.getContent()[0]};if(r.size>0){const f={};c.attributes=f,r.forEach((d,h)=>{f[h]=d})}s.push(c);break}case mo:$c(l,t)&&(a(),Wc(r,l.content));break}l=l.right}a()};return t||i?Dr(n,c=>{t&&my(c,t),i&&my(c,i),u()},"cleanup"):u(),s}insert(t,i,e){if(i.length<=0)return;const s=this.doc;s!==null?Dr(s,r=>{const n=Qp(r,this,t,!e);e||(e={},n.currentAttributes.forEach((o,l)=>{e[l]=o})),Ey(r,this,n,i,e)}):this._pending.push(()=>this.insert(t,i,e))}insertEmbed(t,i,e){const s=this.doc;s!==null?Dr(s,r=>{const n=Qp(r,this,t,!e);Ey(r,this,n,i,e||{})}):this._pending.push(()=>this.insertEmbed(t,i,e||{}))}delete(t,i){if(i===0)return;const e=this.doc;e!==null?Dr(e,s=>{Cw(s,Qp(s,this,t,!0),i)}):this._pending.push(()=>this.delete(t,i))}format(t,i,e){if(i===0)return;const s=this.doc;s!==null?Dr(s,r=>{const n=Qp(r,this,t,!1);n.right!==null&&Sw(r,this,n,i,e)}):this._pending.push(()=>this.format(t,i,e))}removeAttribute(t){this.doc!==null?Dr(this.doc,i=>{Yp(i,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,i){this.doc!==null?Dr(this.doc,e=>{xy(e,this,t,i)}):this._pending.push(()=>this.setAttribute(t,i))}getAttribute(t){return wy(this,t)}getAttributes(){return mw(this)}_write(t){t.writeTypeRef(X5)}}class Cy{constructor(t,i=()=>!0){this._filter=i,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??No()}[Symbol.iterator](){return this}next(){let t=this._currentNode,i=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(i)))do if(i=t.content.type,!t.deleted&&(i.constructor===kd||i.constructor===Vc)&&i._start!==null)t=i._start;else for(;t!==null;)if(t.right!==null){t=t.right;break}else t.parent===this._root?t=null:t=t.parent._item;while(t!==null&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,t===null?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}}class Vc extends Co{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,i){super._integrate(t,i),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Vc}clone(){const t=new Vc;return t.insert(0,this.toArray().map(i=>i instanceof Co?i.clone():i)),t}get length(){return this.doc??No(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new Cy(this,t)}querySelector(t){t=t.toUpperCase();const e=new Cy(this,s=>s.nodeName&&s.nodeName.toUpperCase()===t).next();return e.done?null:e.value}querySelectorAll(t){return t=t.toUpperCase(),Bc(new Cy(this,i=>i.nodeName&&i.nodeName.toUpperCase()===t))}_callObserver(t,i){Gp(this,t,new J5(this,i,t))}toString(){return dw(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,i={},e){const s=t.createDocumentFragment();return e!==void 0&&e._createAssociation(s,this),Cd(this,r=>{s.insertBefore(r.toDOM(t,i,e),null)}),s}insert(t,i){this.doc!==null?Dr(this.doc,e=>{hw(e,this,t,i)}):this._prelimContent.splice(t,0,...i)}insertAfter(t,i){if(this.doc!==null)Dr(this.doc,e=>{const s=t&&t instanceof Co?t._item:t;Kp(e,this,s,i)});else{const e=this._prelimContent,s=t===null?0:e.findIndex(r=>r===t)+1;if(s===0&&t!==null)throw Hc("Reference item not found");e.splice(s,0,...i)}}delete(t,i=1){this.doc!==null?Dr(this.doc,e=>{gw(e,this,t,i)}):this._prelimContent.splice(t,i)}toArray(){return uw(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return fw(this,t)}slice(t=0,i=this.length){return cw(this,t,i)}forEach(t){Cd(this,t)}_write(t){t.writeTypeRef(tI)}}class kd extends Vc{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,i){super._integrate(t,i),this._prelimAttrs.forEach((e,s)=>{this.setAttribute(s,e)}),this._prelimAttrs=null}_copy(){return new kd(this.nodeName)}clone(){const t=new kd(this.nodeName),i=this.getAttributes();return YP(i,(e,s)=>{typeof e=="string"&&t.setAttribute(s,e)}),t.insert(0,this.toArray().map(e=>e instanceof Co?e.clone():e)),t}toString(){const t=this.getAttributes(),i=[],e=[];for(const o in t)e.push(o);e.sort();const s=e.length;for(let o=0;o<s;o++){const l=e[o];i.push(l+'="'+t[l]+'"')}const r=this.nodeName.toLocaleLowerCase(),n=i.length>0?" "+i.join(" "):"";return`<${r}${n}>${super.toString()}</${r}>`}removeAttribute(t){this.doc!==null?Dr(this.doc,i=>{Yp(i,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,i){this.doc!==null?Dr(this.doc,e=>{xy(e,this,t,i)}):this._prelimAttrs.set(t,i)}getAttribute(t){return wy(this,t)}hasAttribute(t){return yw(this,t)}getAttributes(t){return t?U5(this,t):mw(this)}toDOM(t=document,i={},e){const s=t.createElement(this.nodeName),r=this.getAttributes();for(const n in r){const o=r[n];typeof o=="string"&&s.setAttribute(n,o)}return Cd(this,n=>{s.appendChild(n.toDOM(t,i,e))}),e!==void 0&&e._createAssociation(s,this),s}_write(t){t.writeTypeRef(eI),t.writeKey(this.nodeName)}}class J5 extends Vp{constructor(t,i,e){super(t,e),this.childListChanged=!1,this.attributesChanged=new Set,i.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}}class kw{constructor(t,i){this.id=t,this.length=i}get deleted(){throw va()}mergeWith(t){return!1}write(t,i,e){throw va()}integrate(t,i){throw va()}}const G5=0;class Ms extends kw{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,i){i>0&&(this.id.clock+=i,this.length-=i),ew(t.doc.store,this)}write(t,i){t.writeInfo(G5),t.writeLen(this.length-i)}getMissing(t,i){return null}}class eh{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new eh(this.content)}splice(t){throw va()}mergeWith(t){return!1}integrate(t,i){}delete(t){}gc(t){}write(t,i){t.writeBuf(this.content)}getRef(){return 3}}class th{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new th(this.len)}splice(t){const i=new th(this.len-t);return this.len=t,i}mergeWith(t){return this.len+=t.len,!0}integrate(t,i){Gx(t.deleteSet,i.id.client,i.id.clock,this.len),i.markDeleted()}delete(t){}gc(t){}write(t,i){t.writeLen(this.len-i)}getRef(){return 1}}const K5=(p,t)=>new Sd({guid:p,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class nh{constructor(t){t._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;const i={};this.opts=i,t.gc||(i.gc=!1),t.autoLoad&&(i.autoLoad=!0),t.meta!==null&&(i.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new nh(K5(this.doc.guid,this.opts))}splice(t){throw va()}mergeWith(t){return!1}integrate(t,i){this.doc._item=i,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,i){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}class Jc{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Jc(this.embed)}splice(t){throw va()}mergeWith(t){return!1}integrate(t,i){}delete(t){}gc(t){}write(t,i){t.writeJSON(this.embed)}getRef(){return 5}}class mo{constructor(t,i){this.key=t,this.value=i}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new mo(this.key,this.value)}splice(t){throw va()}mergeWith(t){return!1}integrate(t,i){const e=i.parent;e._searchMarker=null,e._hasFormatting=!0}delete(t){}gc(t){}write(t,i){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}const Y5=Hp("node_env")==="development";class Gc{constructor(t){this.arr=t,Y5&&Lx(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Gc(this.arr)}splice(t){const i=new Gc(this.arr.slice(t));return this.arr=this.arr.slice(0,t),i}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,i){}delete(t){}gc(t){}write(t,i){const e=this.arr.length;t.writeLen(e-i);for(let s=i;s<e;s++){const r=this.arr[s];t.writeAny(r)}}getRef(){return 8}}class Qa{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Qa(this.str)}splice(t){const i=new Qa(this.str.slice(t));this.str=this.str.slice(0,t);const e=this.str.charCodeAt(t-1);return e>=55296&&e<=56319&&(this.str=this.str.slice(0,t-1)+"�",i.str="�"+i.str.slice(1)),i}mergeWith(t){return this.str+=t.str,!0}integrate(t,i){}delete(t){}gc(t){}write(t,i){t.writeString(i===0?this.str:this.str.slice(i))}getRef(){return 4}}const Z5=0,Q5=1,X5=2,eI=3,tI=4;class Rs{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Rs(this.type._copy())}splice(t){throw va()}mergeWith(t){return!1}integrate(t,i){this.type._integrate(t.doc,i)}delete(t){let i=this.type._start;for(;i!==null;)i.deleted?i.id.clock<(t.beforeState.get(i.id.client)||0)&&t._mergeStructs.push(i):i.delete(t),i=i.right;this.type._map.forEach(e=>{e.deleted?e.id.clock<(t.beforeState.get(e.id.client)||0)&&t._mergeStructs.push(e):e.delete(t)}),t.changed.delete(this.type)}gc(t){let i=this.type._start;for(;i!==null;)i.gc(t,!0),i=i.right;this.type._start=null,this.type._map.forEach(e=>{for(;e!==null;)e.gc(t,!0),e=e.left}),this.type._map=new Map}write(t,i){this.type._write(t)}getRef(){return 7}}const Tw=(p,t,i)=>{const{client:e,clock:s}=t.id,r=new Po(Gr(e,s+i),t,Gr(e,s+i-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(i));return t.deleted&&r.markDeleted(),t.keep&&(r.keep=!0),t.redone!==null&&(r.redone=Gr(t.redone.client,t.redone.clock+i)),t.right=r,r.right!==null&&(r.right.left=r),p._mergeStructs.push(r),r.parentSub!==null&&r.right===null&&r.parent._map.set(r.parentSub,r),t.length=i,r};class Po extends kw{constructor(t,i,e,s,r,n,o,l){super(t,l.getLength()),this.origin=e,this.left=i,this.right=s,this.rightOrigin=r,this.parent=n,this.parentSub=o,this.redone=null,this.content=l,this.info=this.content.isCountable()?Ex:0}set marker(t){(this.info&ry)>0!==t&&(this.info^=ry)}get marker(){return(this.info&ry)>0}get keep(){return(this.info&Sx)>0}set keep(t){this.keep!==t&&(this.info^=Sx)}get countable(){return(this.info&Ex)>0}get deleted(){return(this.info&ny)>0}set deleted(t){this.deleted!==t&&(this.info^=ny)}markDeleted(){this.info|=ny}getMissing(t,i){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=ei(i,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=ei(i,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===$p&&this.id.client!==this.parent.client&&this.parent.clock>=ei(i,this.parent.client))return this.parent.client;if(this.origin&&(this.left=tw(t,i,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Ps(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Ms||this.right&&this.right.constructor===Ms)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Po&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===Po&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===$p){const e=by(i,this.parent);e.constructor===Ms?this.parent=null:this.parent=e.content.type}return null}integrate(t,i){if(i>0&&(this.id.clock+=i,this.left=tw(t,t.doc.store,Gr(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(i),this.length-=i),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let e=this.left,s;if(e!==null)s=e.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;const r=new Set,n=new Set;for(;s!==null&&s!==this.right;){if(n.add(s),r.add(s),qp(this.origin,s.origin)){if(s.id.client<this.id.client)e=s,r.clear();else if(qp(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&n.has(by(t.doc.store,s.origin)))r.has(by(t.doc.store,s.origin))||(e=s,r.clear());else break;s=s.right}this.left=e}if(this.left!==null){const e=this.left.right;this.right=e,this.left.right=this}else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),ew(t.doc.store,this),this.content.integrate(t,this),ow(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new Ms(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:Gr(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&qp(t.origin,this.lastId)&&this.right===t&&qp(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const i=this.parent._searchMarker;return i&&i.forEach(e=>{e.p===t&&(e.p=this,!this.deleted&&this.countable&&(e.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){const i=this.parent;this.countable&&this.parentSub===null&&(i._length-=this.length),this.markDeleted(),Gx(t.deleteSet,this.id.client,this.id.clock,this.length),ow(t,i,this.parentSub),this.content.delete(t)}}gc(t,i){if(!this.deleted)throw El();this.content.gc(t),i?N5(t,this,new Ms(this.id,this.length)):this.content=new th(this.length)}write(t,i){const e=i>0?Gr(this.id.client,this.id.clock+i-1):this.origin,s=this.rightOrigin,r=this.parentSub,n=this.content.getRef()&SP|(e===null?0:zp)|(s===null?0:Cx)|(r===null?0:wP);if(t.writeInfo(n),e!==null&&t.writeLeftID(e),s!==null&&t.writeRightID(s),e===null&&s===null){const o=this.parent;if(o._item!==void 0){const l=o._item;if(l===null){const a=A5(o);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else o.constructor===String?(t.writeParentInfo(!0),t.writeString(o)):o.constructor===$p?(t.writeParentInfo(!1),t.writeLeftID(o)):El();r!==null&&t.writeString(r)}this.content.write(t,i)}}const Ow=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Aw="__ $YJS$ __";Ow[Aw]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Ow[Aw]=!0;function nI(p){return p&&p.__esModule&&Object.prototype.hasOwnProperty.call(p,"default")?p.default:p}nI(function(p){const t=new URLSearchParams;t.append("code",p);for(let i=1;i<arguments.length;i++)t.append("v",arguments[i]);throw Error(`Minified Lexical error #${p}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const rI=Yo();function jw(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function rh(p,t,i,e,s){return{author:t,content:p,deleted:s===void 0?!1:s,id:i===void 0?jw():i,timeStamp:e===void 0?performance.now():e,type:"comment"}}function Nw(p,t,i){return{comments:t,id:i===void 0?jw():i,quote:p,type:"thread"}}function Pw(p){return{comments:Array.from(p.comments),id:p.id,quote:p.quote,type:"thread"}}function oI(p){return{author:p.author,content:"[Deleted Comment]",deleted:!0,id:p.id,timeStamp:p.timeStamp,type:"comment"}}function Iw(p){const t=p._changeListeners;for(const i of t)i()}class iI{constructor(t){Hr(this,"_editor");Hr(this,"_comments");Hr(this,"_changeListeners");Hr(this,"_collabProvider");this._comments=[],this._editor=t,this._collabProvider=null,this._changeListeners=new Set}isCollaborative(){return this._collabProvider!==null}getComments(){return this._comments}addComment(t,i,e){const s=Array.from(this._comments),r=this._getCollabComments();if(i!==void 0&&t.type==="comment")for(let n=0;n<s.length;n++){const o=s[n];if(o.type==="thread"&&o.id===i.id){const l=Pw(o);s.splice(n,1,l);const a=e!==void 0?e:l.comments.length;if(this.isCollaborative()&&r!==null){const u=r.get(n).get("comments");this._withRemoteTransaction(()=>{const c=this._createCollabSharedMap(t);u.insert(a,[c])})}l.comments.splice(a,0,t);break}}else{const n=e!==void 0?e:s.length;this.isCollaborative()&&r!==null&&this._withRemoteTransaction(()=>{const o=this._createCollabSharedMap(t);r.insert(n,[o])}),s.splice(n,0,t)}this._comments=s,Iw(this)}deleteCommentOrThread(t,i){const e=Array.from(this._comments),s=this._getCollabComments();let r=null;if(i!==void 0)for(let n=0;n<e.length;n++){const o=e[n];if(o.type==="thread"&&o.id===i.id){const l=Pw(o);e.splice(n,1,l);const a=l.comments;if(r=a.indexOf(t),this.isCollaborative()&&s!==null){const u=s.get(n).get("comments");this._withRemoteTransaction(()=>{u.delete(r)})}a.splice(r,1);break}}else r=e.indexOf(t),this.isCollaborative()&&s!==null&&this._withRemoteTransaction(()=>{s.delete(r)}),e.splice(r,1);return this._comments=e,Iw(this),t.type==="comment"?{index:r,markedComment:oI(t)}:null}registerOnChange(t){const i=this._changeListeners;return i.add(t),()=>{i.delete(t)}}_withRemoteTransaction(t){const i=this._collabProvider;i!==null&&i.doc.transact(t,this)}_withLocalTransaction(t){const i=this._collabProvider;try{this._collabProvider=null,t()}finally{this._collabProvider=i}}_getCollabComments(){const t=this._collabProvider;return t!==null?t.doc.get("comments",Cl):null}_createCollabSharedMap(t){const i=new qc,e=t.type,s=t.id;if(i.set("type",e),i.set("id",s),e==="comment")i.set("author",t.author),i.set("content",t.content),i.set("deleted",t.deleted),i.set("timeStamp",t.timeStamp);else{i.set("quote",t.quote);const r=new Cl;t.comments.forEach((n,o)=>{const l=this._createCollabSharedMap(n);r.insert(o,[l])}),i.set("comments",r)}return i}registerCollaboration(t){this._collabProvider=t;const i=this._getCollabComments(),e=()=>{t.connect()},s=()=>{try{t.disconnect()}catch{}},r=this._editor.registerCommand(rI,o=>(e!==void 0&&s!==void 0&&(o?(console.log("Comments connected!"),e()):(console.log("Comments disconnected!"),s())),!1),Ln),n=(o,l)=>{if(l.origin!==this)for(let a=0;a<o.length;a++){const u=o[a];if(u instanceof bw){const c=u.target,f=u.delta;let d=0;for(let h=0;h<f.length;h++){const m=f[h],g=m.insert,_=m.retain,v=m.delete,b=c.parent,S=c===i?void 0:b instanceof qc&&this._comments.find(E=>E.id===b.get("id"));if(Array.isArray(g))g.slice().reverse().forEach(E=>{const x=E.get("id"),w=E.get("type")==="thread"?Nw(E.get("quote"),E.get("comments").toArray().map(C=>rh(C.get("content"),C.get("author"),C.get("id"),C.get("timeStamp"),C.get("deleted"))),x):rh(E.get("content"),E.get("author"),x,E.get("timeStamp"),E.get("deleted"));this._withLocalTransaction(()=>{this.addComment(w,S,d)})});else if(typeof _=="number")d+=_;else if(typeof v=="number")for(let E=0;E<v;E++){const x=S===void 0||S===!1?this._comments[d]:S.comments[d];this._withLocalTransaction(()=>{this.deleteCommentOrThread(x,S)}),d++}}}}};return i===null?()=>null:(i.observeDeep(n),e(),()=>{i.unobserveDeep(n),r(),this._collabProvider=null})}}function aI(p){const[t,i]=ve.useState(p.getComments());return ve.useEffect(()=>p.registerOnChange(()=>{i(p.getComments())}),[p]),t}const TM="";function ky({className:p,style:t}){return _e.jsx(fp,{className:p||"ContentEditable__root",style:t})}const OM="";function Ty({children:p,className:t}){return _e.jsx("div",{className:t||"Placeholder__root",children:p})}const Oy=Yo();function sI({anchorKey:p,editor:t,onAddComment:i}){const e=ve.useRef(null),s=ve.useCallback(()=>{const r=e.current,n=t.getRootElement(),o=t.getElementByKey(p);if(r!==null&&n!==null&&o!==null){const{right:l}=n.getBoundingClientRect(),{top:a}=o.getBoundingClientRect();r.style.left=`${l-20}px`,r.style.top=`${a-30}px`}},[p,t]);return ve.useEffect(()=>(window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s)}),[t,s]),xx(()=>{s()},[p,t,s]),_e.jsx("div",{className:"CommentPlugin_AddCommentBox",ref:e,children:_e.jsx("button",{className:"CommentPlugin_AddCommentBox_button",onClick:i,children:_e.jsx("i",{className:"icon add-comment"})})})}function lI({onEscape:p}){const[t]=Yn();return ve.useEffect(()=>t.registerCommand(Ia,i=>p(i),2),[t,p]),null}function Mw({className:p,autoFocus:t,onEscape:i,onChange:e,editorRef:s,placeholder:r="Type a comment..."}){const n={namespace:"Commenting",nodes:[],onError:o=>{throw o},theme:Ug};return _e.jsx(zf,{initialConfig:n,children:_e.jsxs("div",{className:"CommentPlugin_CommentInputBox_EditorContainer",children:[_e.jsx(i_,{contentEditable:_e.jsx(ky,{className:p}),placeholder:_e.jsx(Ty,{children:r}),ErrorBoundary:mc}),_e.jsx(Am,{onChange:e}),_e.jsx(gp,{}),t!==!1&&_e.jsx(dp,{}),_e.jsx(lI,{onEscape:i}),_e.jsx(e_,{}),s!==void 0&&_e.jsx(mP,{editorRef:s})]})})}function Rw(p,t){return ve.useCallback((i,e)=>{i.read(()=>{p(xm()),t(!wm(e.isComposing(),!0))})},[t,p])}function cI({editor:p,cancelAddComment:t,submitAddComment:i}){const[e,s]=ve.useState(""),[r,n]=ve.useState(!1),o=ve.useRef(null),l=ve.useMemo(()=>({container:document.createElement("div"),elements:[]}),[]),a=ve.useRef(null),u=Fw(),c=ve.useCallback(()=>{p.getEditorState().read(()=>{const m=Ot();if(Et(m)){a.current=m.clone();const g=m.anchor,_=m.focus,v=fv(p,g.getNode(),g.offset,_.getNode(),_.offset),b=o.current;if(v!==null&&b!==null){const{left:S,bottom:E,width:x}=v.getBoundingClientRect(),y=pv(p,v);let w=y.length===1?S+x/2-125:S-125;w<10&&(w=10),b.style.left=`${w}px`,b.style.top=`${E+20+(window.pageYOffset||document.documentElement.scrollTop)}px`;const C=y.length,{container:j}=l,P=l.elements,F=P.length;for(let I=0;I<C;I++){const D=y[I];let N=P[I];N===void 0&&(N=document.createElement("span"),P[I]=N,j.appendChild(N));const k="255, 212, 0",A=`position:absolute;top:${D.top+(window.pageYOffset||document.documentElement.scrollTop)}px;left:${D.left}px;height:${D.height}px;width:${D.width}px;background-color:rgba(${k}, 0.3);pointer-events:none;z-index:5;`;N.style.cssText=A}for(let I=F-1;I>=C;I--){const D=P[I];j.removeChild(D),P.pop()}}}})},[p,l]);xx(()=>{c();const m=l.container,g=document.body;if(g!==null)return g.appendChild(m),()=>{g.removeChild(m)}},[l.container,c]),ve.useEffect(()=>(window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}),[c]);const f=m=>(m.preventDefault(),t(),!0),d=()=>{if(r){let m=p.getEditorState().read(()=>{const g=a.current;return g?g.getTextContent():""});m.length>100&&(m=m.slice(0,99)+"…"),i(Nw(m,[rh(e,u)]),!0,void 0,a.current),a.current=null}},h=Rw(s,n);return _e.jsxs("div",{className:"CommentPlugin_CommentInputBox",ref:o,children:[_e.jsx(Mw,{className:"CommentPlugin_CommentInputBox_Editor",onEscape:f,onChange:h}),_e.jsxs("div",{className:"CommentPlugin_CommentInputBox_Buttons",children:[_e.jsx(fa,{onClick:t,className:"CommentPlugin_CommentInputBox_Button",children:"Cancel"}),_e.jsx(fa,{onClick:d,disabled:!r,className:"CommentPlugin_CommentInputBox_Button primary",children:"Comment"})]})]})}function uI({submitAddComment:p,thread:t,placeholder:i}){const[e,s]=ve.useState(""),[r,n]=ve.useState(!1),o=ve.useRef(null),l=Fw(),a=Rw(s,n),u=()=>{if(r){p(rh(e,l),!1,t);const c=o.current;c!==null&&c.dispatchCommand(af,void 0)}};return _e.jsxs(_e.Fragment,{children:[_e.jsx(Mw,{className:"CommentPlugin_CommentsPanel_Editor",autoFocus:!1,onEscape:()=>!0,onChange:a,editorRef:o,placeholder:i}),_e.jsx(fa,{className:"CommentPlugin_CommentsPanel_SendButton",onClick:u,disabled:!r,children:_e.jsx("i",{className:"send"})})]})}function Dw({commentOrThread:p,deleteCommentOrThread:t,onClose:i,thread:e=void 0}){return _e.jsxs(_e.Fragment,{children:["Are you sure you want to delete this ",p.type,"?",_e.jsxs("div",{className:"Modal__content",children:[_e.jsx(fa,{onClick:()=>{t(p,e),i()},children:"Delete"})," ",_e.jsx(fa,{onClick:()=>{i()},children:"Cancel"})]})]})}function Lw({comment:p,deleteComment:t,thread:i,rtf:e}){const s=Math.round((p.timeStamp-performance.now())/1e3),r=Math.round(s/60),[n,o]=cp();return _e.jsxs("li",{className:"CommentPlugin_CommentsPanel_List_Comment",children:[_e.jsxs("div",{className:"CommentPlugin_CommentsPanel_List_Details",children:[_e.jsx("span",{className:"CommentPlugin_CommentsPanel_List_Comment_Author",children:p.author}),_e.jsxs("span",{className:"CommentPlugin_CommentsPanel_List_Comment_Time",children:["· ",s>-10?"Just now":e.format(r,"minute")]})]}),_e.jsx("p",{className:p.deleted?"CommentPlugin_CommentsPanel_DeletedComment":"",children:p.content}),!p.deleted&&_e.jsxs(_e.Fragment,{children:[_e.jsx(fa,{onClick:()=>{o("Delete Comment",l=>_e.jsx(Dw,{commentOrThread:p,deleteCommentOrThread:t,thread:i,onClose:l}))},className:"CommentPlugin_CommentsPanel_List_DeleteButton",children:_e.jsx("i",{className:"delete"})}),n]})]})}function dI({activeIDs:p,comments:t,deleteCommentOrThread:i,listRef:e,submitAddComment:s,markNodeMap:r}){const[n]=Yn(),[o,l]=ve.useState(0),[a,u]=cp(),c=ve.useMemo(()=>new Intl.RelativeTimeFormat("en",{localeMatcher:"best fit",numeric:"auto",style:"short"}),[]);return ve.useEffect(()=>{const f=setTimeout(()=>{l(o+1)},1e4);return()=>{clearTimeout(f)}},[o]),_e.jsx("ul",{className:"CommentPlugin_CommentsPanel_List",ref:e,children:t.map(f=>{const d=f.id;if(f.type==="thread"){const h=()=>{const m=r.get(d);if(m!==void 0&&(p===null||p.indexOf(d)===-1)){const g=document.activeElement;n.update(()=>{const _=Array.from(m)[0],v=Xn(_);ha(v)&&v.selectStart()},{onUpdate(){g!==null&&g.focus()}})}};return _e.jsxs("li",{onClick:h,className:`CommentPlugin_CommentsPanel_List_Thread ${r.has(d)?"interactive":""} ${p.indexOf(d)===-1?"":"active"}`,children:[_e.jsxs("div",{className:"CommentPlugin_CommentsPanel_List_Thread_QuoteBox",children:[_e.jsxs("blockquote",{className:"CommentPlugin_CommentsPanel_List_Thread_Quote",children:["> ",_e.jsx("span",{children:f.quote})]}),_e.jsx(fa,{onClick:()=>{u("Delete Thread",m=>_e.jsx(Dw,{commentOrThread:f,deleteCommentOrThread:i,onClose:m}))},className:"CommentPlugin_CommentsPanel_List_DeleteButton",children:_e.jsx("i",{className:"delete"})}),a]}),_e.jsx("ul",{className:"CommentPlugin_CommentsPanel_List_Thread_Comments",children:f.comments.map(m=>_e.jsx(Lw,{comment:m,deleteComment:i,thread:f,rtf:c},m.id))}),_e.jsx("div",{className:"CommentPlugin_CommentsPanel_List_Thread_Editor",children:_e.jsx(uI,{submitAddComment:s,thread:f,placeholder:"Reply to comment..."})})]},d)}return _e.jsx(Lw,{comment:f,deleteComment:i,rtf:c},d)})})}function fI({activeIDs:p,deleteCommentOrThread:t,comments:i,submitAddComment:e,markNodeMap:s}){const r=ve.useRef(null),n=i.length===0;return _e.jsxs("div",{className:"CommentPlugin_CommentsPanel",children:[_e.jsx("h2",{className:"CommentPlugin_CommentsPanel_Heading",children:"Comments"}),n?_e.jsx("div",{className:"CommentPlugin_CommentsPanel_Empty",children:"No Comments"}):_e.jsx(dI,{activeIDs:p,comments:i,deleteCommentOrThread:t,listRef:r,submitAddComment:e,markNodeMap:s})]})}function Fw(){const p=pp(),{yjsDocMap:t,name:i}=p;return t.has("comments")?i:"Playground User"}function pI({providerFactory:p}){const t=pp(),[i]=Yn(),e=ve.useMemo(()=>new iI(i),[i]),s=aI(e),r=ve.useMemo(()=>new Map,[]),[n,o]=ve.useState(),[l,a]=ve.useState([]),[u,c]=ve.useState(!1),[f,d]=ve.useState(!1),{yjsDocMap:h}=t;ve.useEffect(()=>{if(p){const b=p("comments",h);return e.registerCollaboration(b)}},[e,p,h]);const m=ve.useCallback(()=>{i.update(()=>{const b=Ot();b!==null&&(b.dirty=!0)}),c(!1)},[i]),g=ve.useCallback((b,S)=>{if(b.type==="comment"){const E=e.deleteCommentOrThread(b,S);if(!E)return;const{markedComment:x,index:y}=E;e.addComment(x,S,y)}else{e.deleteCommentOrThread(b);const E=S!==void 0?S.id:b.id,x=r.get(E);x!==void 0&&setTimeout(()=>{i.update(()=>{for(const y of x){const w=Xn(y);ha(w)&&(w.deleteID(E),w.getIDs().length===0&&K1(w))}})})}},[e,i,r]),_=ve.useCallback((b,S,E,x)=>{e.addComment(b,E),S&&(i.update(()=>{if(Et(x)){const y=x.isBackward(),w=b.id;Y1(x,y,w)}}),c(!1))},[e,i]);ve.useEffect(()=>{console.log("askjdhasdhasjkdh");const b=[];for(let S=0;S<l.length;S++){const E=l[S],x=r.get(E);if(x!==void 0)for(const y of x){const w=i.getElementByKey(y);w!==null&&(w.classList.add("selected"),b.push(w),d(!0))}}return()=>{for(let S=0;S<b.length;S++)b[S].classList.remove("selected")}},[l,i,r]),ve.useEffect(()=>{const b=new Map;return Mr(xv(i,od,S=>id(S.getIDs()),(S,E)=>{S.getIDs().forEach(y=>{E.addID(y)})}),i.registerMutationListener(od,S=>{i.getEditorState().read(()=>{for(const[E,x]of S){const y=Xn(E);let w=[];x==="destroyed"?w=b.get(E)||[]:ha(y)&&(w=y.getIDs());for(let C=0;C<w.length;C++){const j=w[C];let P=r.get(j);b.set(E,w),x==="destroyed"?P!==void 0&&(P.delete(E),P.size===0&&r.delete(j)):(P===void 0&&(P=new Set,r.set(j,P)),P.has(E)||P.add(E))}}})}),i.registerUpdateListener(({editorState:S,tags:E})=>{S.read(()=>{const x=Ot();let y=!1,w=!1;if(Et(x)){const C=x.anchor.getNode();if(qt(C)){const j=Z1(C,x.anchor.offset);j!==null&&(a(j),y=!0),x.isCollapsed()||(o(C.getKey()),w=!0)}}y||a(C=>C.length===0?C:[]),w||o(null),!E.has("collaboration")&&Et(x)&&c(!1)})}),i.registerCommand(Oy,()=>{const S=window.getSelection();return S!==null&&S.removeAllRanges(),c(!0),!0},Tn))},[i,r]);const v=()=>{i.dispatchCommand(Oy,void 0)};return console.log("CommentPlugin"),_e.jsxs(_e.Fragment,{children:[u&&ro.createPortal(_e.jsx(cI,{editor:i,cancelAddComment:m,submitAddComment:_}),document.body),n!=null&&!u&&ro.createPortal(_e.jsx(sI,{anchorKey:n,editor:i,onAddComment:v}),document.body),ro.createPortal(_e.jsx(fa,{className:`CommentPlugin_ShowCommentsButton ${f?"active":""}`,onClick:()=>d(!f),title:f?"Hide Comments":"Show Comments",children:_e.jsx("i",{className:"comments"})}),document.body),f&&ro.createPortal(_e.jsx(fI,{comments:s,submitAddComment:_,deleteCommentOrThread:g,activeIDs:l,markNodeMap:r}),document.body)]})}var hI={exports:{}};(function(p){var t=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};/**
|
|
1514
1514
|
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
1515
1515
|
*
|
|
1516
1516
|
* @license MIT <https://opensource.org/licenses/MIT>
|
|
@@ -1520,5 +1520,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1520
1520
|
*/var i=function(e){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,r=0,n={},o={manual:e.Prism&&e.Prism.manual,disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,util:{encode:function v(b){return b instanceof l?new l(b.type,v(b.content),b.alias):Array.isArray(b)?b.map(v):b.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ")},type:function(v){return Object.prototype.toString.call(v).slice(8,-1)},objId:function(v){return v.__id||Object.defineProperty(v,"__id",{value:++r}),v.__id},clone:function v(b,S){S=S||{};var E,x;switch(o.util.type(b)){case"Object":if(x=o.util.objId(b),S[x])return S[x];E={},S[x]=E;for(var y in b)b.hasOwnProperty(y)&&(E[y]=v(b[y],S));return E;case"Array":return x=o.util.objId(b),S[x]?S[x]:(E=[],S[x]=E,b.forEach(function(w,C){E[C]=v(w,S)}),E);default:return b}},getLanguage:function(v){for(;v;){var b=s.exec(v.className);if(b)return b[1].toLowerCase();v=v.parentElement}return"none"},setLanguage:function(v,b){v.className=v.className.replace(RegExp(s,"gi"),""),v.classList.add("language-"+b)},currentScript:function(){if(typeof document>"u")return null;if("currentScript"in document&&1<2)return document.currentScript;try{throw new Error}catch(E){var v=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(E.stack)||[])[1];if(v){var b=document.getElementsByTagName("script");for(var S in b)if(b[S].src==v)return b[S]}return null}},isActive:function(v,b,S){for(var E="no-"+b;v;){var x=v.classList;if(x.contains(b))return!0;if(x.contains(E))return!1;v=v.parentElement}return!!S}},languages:{plain:n,plaintext:n,text:n,txt:n,extend:function(v,b){var S=o.util.clone(o.languages[v]);for(var E in b)S[E]=b[E];return S},insertBefore:function(v,b,S,E){E=E||o.languages;var x=E[v],y={};for(var w in x)if(x.hasOwnProperty(w)){if(w==b)for(var C in S)S.hasOwnProperty(C)&&(y[C]=S[C]);S.hasOwnProperty(w)||(y[w]=x[w])}var j=E[v];return E[v]=y,o.languages.DFS(o.languages,function(P,F){F===j&&P!=v&&(this[P]=y)}),y},DFS:function v(b,S,E,x){x=x||{};var y=o.util.objId;for(var w in b)if(b.hasOwnProperty(w)){S.call(b,w,b[w],E||w);var C=b[w],j=o.util.type(C);j==="Object"&&!x[y(C)]?(x[y(C)]=!0,v(C,S,null,x)):j==="Array"&&!x[y(C)]&&(x[y(C)]=!0,v(C,S,w,x))}}},plugins:{},highlightAll:function(v,b){o.highlightAllUnder(document,v,b)},highlightAllUnder:function(v,b,S){var E={callback:S,container:v,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};o.hooks.run("before-highlightall",E),E.elements=Array.prototype.slice.apply(E.container.querySelectorAll(E.selector)),o.hooks.run("before-all-elements-highlight",E);for(var x=0,y;y=E.elements[x++];)o.highlightElement(y,b===!0,E.callback)},highlightElement:function(v,b,S){var E=o.util.getLanguage(v),x=o.languages[E];o.util.setLanguage(v,E);var y=v.parentElement;y&&y.nodeName.toLowerCase()==="pre"&&o.util.setLanguage(y,E);var w=v.textContent,C={element:v,language:E,grammar:x,code:w};function j(F){C.highlightedCode=F,o.hooks.run("before-insert",C),C.element.innerHTML=C.highlightedCode,o.hooks.run("after-highlight",C),o.hooks.run("complete",C),S&&S.call(C.element)}if(o.hooks.run("before-sanity-check",C),y=C.element.parentElement,y&&y.nodeName.toLowerCase()==="pre"&&!y.hasAttribute("tabindex")&&y.setAttribute("tabindex","0"),!C.code){o.hooks.run("complete",C),S&&S.call(C.element);return}if(o.hooks.run("before-highlight",C),!C.grammar){j(o.util.encode(C.code));return}if(b&&e.Worker){var P=new Worker(o.filename);P.onmessage=function(F){j(F.data)},P.postMessage(JSON.stringify({language:C.language,code:C.code,immediateClose:!0}))}else j(o.highlight(C.code,C.grammar,C.language))},highlight:function(v,b,S){var E={code:v,grammar:b,language:S};if(o.hooks.run("before-tokenize",E),!E.grammar)throw new Error('The language "'+E.language+'" has no grammar.');return E.tokens=o.tokenize(E.code,E.grammar),o.hooks.run("after-tokenize",E),l.stringify(o.util.encode(E.tokens),E.language)},tokenize:function(v,b){var S=b.rest;if(S){for(var E in S)b[E]=S[E];delete b.rest}var x=new c;return f(x,x.head,v),u(v,x,b,x.head,0),h(x)},hooks:{all:{},add:function(v,b){var S=o.hooks.all;S[v]=S[v]||[],S[v].push(b)},run:function(v,b){var S=o.hooks.all[v];if(!(!S||!S.length))for(var E=0,x;x=S[E++];)x(b)}},Token:l};e.Prism=o;function l(v,b,S,E){this.type=v,this.content=b,this.alias=S,this.length=(E||"").length|0}l.stringify=function v(b,S){if(typeof b=="string")return b;if(Array.isArray(b)){var E="";return b.forEach(function(j){E+=v(j,S)}),E}var x={type:b.type,content:v(b.content,S),tag:"span",classes:["token",b.type],attributes:{},language:S},y=b.alias;y&&(Array.isArray(y)?Array.prototype.push.apply(x.classes,y):x.classes.push(y)),o.hooks.run("wrap",x);var w="";for(var C in x.attributes)w+=" "+C+'="'+(x.attributes[C]||"").replace(/"/g,""")+'"';return"<"+x.tag+' class="'+x.classes.join(" ")+'"'+w+">"+x.content+"</"+x.tag+">"};function a(v,b,S,E){v.lastIndex=b;var x=v.exec(S);if(x&&E&&x[1]){var y=x[1].length;x.index+=y,x[0]=x[0].slice(y)}return x}function u(v,b,S,E,x,y){for(var w in S)if(!(!S.hasOwnProperty(w)||!S[w])){var C=S[w];C=Array.isArray(C)?C:[C];for(var j=0;j<C.length;++j){if(y&&y.cause==w+","+j)return;var P=C[j],F=P.inside,I=!!P.lookbehind,D=!!P.greedy,N=P.alias;if(D&&!P.pattern.global){var k=P.pattern.toString().match(/[imsuy]*$/)[0];P.pattern=RegExp(P.pattern.source,k+"g")}for(var A=P.pattern||P,R=E.next,L=x;R!==b.tail&&!(y&&L>=y.reach);L+=R.value.length,R=R.next){var J=R.value;if(b.length>v.length)return;if(!(J instanceof l)){var O=1,z;if(D){if(z=a(A,L,v,I),!z||z.index>=v.length)break;var $=z.index,W=z.index+z[0].length,G=L;for(G+=R.value.length;$>=G;)R=R.next,G+=R.value.length;if(G-=R.value.length,L=G,R.value instanceof l)continue;for(var B=R;B!==b.tail&&(G<W||typeof B.value=="string");B=B.next)O++,G+=B.value.length;O--,J=v.slice(L,G),z.index-=L}else if(z=a(A,0,J,I),!z)continue;var $=z.index,q=z[0],H=J.slice(0,$),K=J.slice($+q.length),Y=L+J.length;y&&Y>y.reach&&(y.reach=Y);var Z=R.prev;H&&(Z=f(b,Z,H),L+=H.length),d(b,Z,O);var X=new l(w,F?o.tokenize(q,F):q,N,q);if(R=f(b,Z,X),K&&f(b,R,K),O>1){var ee={cause:w+","+j,reach:Y};u(v,b,S,R.prev,L,ee),y&&ee.reach>y.reach&&(y.reach=ee.reach)}}}}}}function c(){var v={value:null,prev:null,next:null},b={value:null,prev:v,next:null};v.next=b,this.head=v,this.tail=b,this.length=0}function f(v,b,S){var E=b.next,x={value:S,prev:b,next:E};return b.next=x,E.prev=x,v.length++,x}function d(v,b,S){for(var E=b.next,x=0;x<S&&E!==v.tail;x++)E=E.next;b.next=E,E.prev=b,v.length-=x}function h(v){for(var b=[],S=v.head.next;S!==v.tail;)b.push(S.value),S=S.next;return b}if(!e.document)return e.addEventListener&&(o.disableWorkerMessageHandler||e.addEventListener("message",function(v){var b=JSON.parse(v.data),S=b.language,E=b.code,x=b.immediateClose;e.postMessage(o.highlight(E,o.languages[S],S)),x&&e.close()},!1)),o;var m=o.util.currentScript();m&&(o.filename=m.src,m.hasAttribute("data-manual")&&(o.manual=!0));function g(){o.manual||o.highlightAll()}if(!o.manual){var _=document.readyState;_==="loading"||_==="interactive"&&m&&m.defer?document.addEventListener("DOMContentLoaded",g):window.requestAnimationFrame?window.requestAnimationFrame(g):window.setTimeout(g,16)}return o}(t);p.exports&&(p.exports=i),typeof Uh<"u"&&(Uh.Prism=i),i.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},i.languages.markup.tag.inside["attr-value"].inside.entity=i.languages.markup.entity,i.languages.markup.doctype.inside["internal-subset"].inside=i.languages.markup,i.hooks.add("wrap",function(e){e.type==="entity"&&(e.attributes.title=e.content.replace(/&/,"&"))}),Object.defineProperty(i.languages.markup.tag,"addInlined",{value:function(s,r){var n={};n["language-"+r]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:i.languages[r]},n.cdata=/^<!\[CDATA\[|\]\]>$/i;var o={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:n}};o["language-"+r]={pattern:/[\s\S]+/,inside:i.languages[r]};var l={};l[s]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return s}),"i"),lookbehind:!0,greedy:!0,inside:o},i.languages.insertBefore("markup","cdata",l)}}),Object.defineProperty(i.languages.markup.tag,"addAttribute",{value:function(e,s){i.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+e+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[s,"language-"+s],inside:i.languages[s]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),i.languages.html=i.languages.markup,i.languages.mathml=i.languages.markup,i.languages.svg=i.languages.markup,i.languages.xml=i.languages.extend("markup",{}),i.languages.ssml=i.languages.xml,i.languages.atom=i.languages.xml,i.languages.rss=i.languages.xml,function(e){var s=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+s.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+s.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+s.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+s.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:s,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var r=e.languages.markup;r&&(r.tag.addInlined("style","css"),r.tag.addAttribute("style","css"))}(i),i.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},i.languages.javascript=i.languages.extend("clike",{"class-name":[i.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),i.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,i.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:i.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:i.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:i.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:i.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:i.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),i.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:i.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),i.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),i.languages.markup&&(i.languages.markup.tag.addInlined("script","javascript"),i.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),i.languages.js=i.languages.javascript,function(){if(typeof i>"u"||typeof document>"u")return;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var e="Loading…",s=function(m,g){return"✖ Error "+m+" while fetching file: "+g},r="✖ Error: File does not exist or is empty",n={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"},o="data-src-status",l="loading",a="loaded",u="failed",c="pre[data-src]:not(["+o+'="'+a+'"]):not(['+o+'="'+l+'"])';function f(m,g,_){var v=new XMLHttpRequest;v.open("GET",m,!0),v.onreadystatechange=function(){v.readyState==4&&(v.status<400&&v.responseText?g(v.responseText):v.status>=400?_(s(v.status,v.statusText)):_(r))},v.send(null)}function d(m){var g=/^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(m||"");if(g){var _=Number(g[1]),v=g[2],b=g[3];return v?b?[_,Number(b)]:[_,void 0]:[_,_]}}i.hooks.add("before-highlightall",function(m){m.selector+=", "+c}),i.hooks.add("before-sanity-check",function(m){var g=m.element;if(g.matches(c)){m.code="",g.setAttribute(o,l);var _=g.appendChild(document.createElement("CODE"));_.textContent=e;var v=g.getAttribute("data-src"),b=m.language;if(b==="none"){var S=(/\.(\w+)$/.exec(v)||[,"none"])[1];b=n[S]||S}i.util.setLanguage(_,b),i.util.setLanguage(g,b);var E=i.plugins.autoloader;E&&E.loadLanguages(b),f(v,function(x){g.setAttribute(o,a);var y=d(g.getAttribute("data-range"));if(y){var w=x.split(/\r\n?|\n/g),C=y[0],j=y[1]==null?w.length:y[1];C<0&&(C+=w.length),C=Math.max(0,Math.min(C-1,w.length)),j<0&&(j+=w.length),j=Math.max(0,Math.min(j,w.length)),x=w.slice(C,j).join(`
|
|
1521
1521
|
`),g.hasAttribute("data-start")||g.setAttribute("data-start",String(C+1))}_.textContent=x,i.highlightElement(_)},function(x){g.setAttribute(o,u),_.textContent=x})}}),i.plugins.fileHighlight={highlight:function(g){for(var _=(g||document).querySelectorAll(c),v=0,b;b=_[v++];)i.highlightElement(b)}};var h=!1;i.fileHighlight=function(){h||(console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."),h=!0),i.plugins.fileHighlight.highlight.apply(this,arguments)}}()})(hI),Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,Prism.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity,Prism.languages.markup.doctype.inside["internal-subset"].inside=Prism.languages.markup,Prism.hooks.add("wrap",function(p){p.type==="entity"&&(p.attributes.title=p.content.replace(/&/,"&"))}),Object.defineProperty(Prism.languages.markup.tag,"addInlined",{value:function(t,i){var e={};e["language-"+i]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:Prism.languages[i]},e.cdata=/^<!\[CDATA\[|\]\]>$/i;var s={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:e}};s["language-"+i]={pattern:/[\s\S]+/,inside:Prism.languages[i]};var r={};r[t]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return t}),"i"),lookbehind:!0,greedy:!0,inside:s},Prism.languages.insertBefore("markup","cdata",r)}}),Object.defineProperty(Prism.languages.markup.tag,"addAttribute",{value:function(p,t){Prism.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+p+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[t,"language-"+t],inside:Prism.languages[t]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),Prism.languages.html=Prism.languages.markup,Prism.languages.mathml=Prism.languages.markup,Prism.languages.svg=Prism.languages.markup,Prism.languages.xml=Prism.languages.extend("markup",{}),Prism.languages.ssml=Prism.languages.xml,Prism.languages.atom=Prism.languages.xml,Prism.languages.rss=Prism.languages.xml,function(p){var t=/(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/.source;function i(u){return u=u.replace(/<inner>/g,function(){return t}),RegExp(/((?:^|[^\\])(?:\\{2})*)/.source+"(?:"+u+")")}var e=/(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source,s=/\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g,function(){return e}),r=/\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/.source;p.languages.markdown=p.languages.extend("markup",{}),p.languages.insertBefore("markdown","prolog",{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:["yaml","language-yaml"],inside:p.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:"punctuation"},table:{pattern:RegExp("^"+s+r+"(?:"+s+")*","m"),inside:{"table-data-rows":{pattern:RegExp("^("+s+r+")(?:"+s+")*$"),lookbehind:!0,inside:{"table-data":{pattern:RegExp(e),inside:p.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp("^("+s+")"+r+"$"),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp("^"+s+"$"),inside:{"table-header":{pattern:RegExp(e),alias:"important",inside:p.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:"keyword"},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:"important",inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:"important",inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:"punctuation"},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:"punctuation"},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:"url"},bold:{pattern:i(/\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\b|\*\*(?:(?!\*)<inner>|\*(?:(?!\*)<inner>)+\*)+\*\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:i(/\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\b|\*(?:(?!\*)<inner>|\*\*(?:(?!\*)<inner>)+\*\*)+\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:i(/(~~?)(?:(?!~)<inner>)+\2/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:["code","keyword"]},url:{pattern:i(/!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)|[ \t]?\[(?:(?!\])<inner>)+\])/.source),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),["url","bold","italic","strike"].forEach(function(u){["url","bold","italic","strike","code-snippet"].forEach(function(c){u!==c&&(p.languages.markdown[u].inside.content.inside[c]=p.languages.markdown[c])})}),p.hooks.add("after-tokenize",function(u){if(u.language!=="markdown"&&u.language!=="md")return;function c(f){if(!(!f||typeof f=="string"))for(var d=0,h=f.length;d<h;d++){var m=f[d];if(m.type!=="code"){c(m.content);continue}var g=m.content[1],_=m.content[3];if(g&&_&&g.type==="code-language"&&_.type==="code-block"&&typeof g.content=="string"){var v=g.content.replace(/\b#/g,"sharp").replace(/\b\+\+/g,"pp");v=(/[a-z][\w-]*/i.exec(v)||[""])[0].toLowerCase();var b="language-"+v;_.alias?typeof _.alias=="string"?_.alias=[_.alias,b]:_.alias.push(b):_.alias=[b]}}}c(u.tokens)}),p.hooks.add("wrap",function(u){if(u.type==="code-block"){for(var c="",f=0,d=u.classes.length;f<d;f++){var h=u.classes[f],m=/language-(.+)/.exec(h);if(m){c=m[1];break}}var g=p.languages[c];if(g)u.content=p.highlight(a(u.content),g,c);else if(c&&c!=="none"&&p.plugins.autoloader){var _="md-"+new Date().valueOf()+"-"+Math.floor(Math.random()*1e16);u.attributes.id=_,p.plugins.autoloader.loadLanguages(c,function(){var v=document.getElementById(_);v&&(v.innerHTML=p.highlight(v.textContent,p.languages[c],c))})}}});var n=RegExp(p.languages.markup.tag.pattern.source,"gi"),o={amp:"&",lt:"<",gt:">",quot:'"'},l=String.fromCodePoint||String.fromCharCode;function a(u){var c=u.replace(n,"");return c=c.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(f,d){if(d=d.toLowerCase(),d[0]==="#"){var h;return d[1]==="x"?h=parseInt(d.slice(2),16):h=Number(d.slice(1)),l(h)}else{var m=o[d];return m||f}}),c}p.languages.md=p.languages.markdown}(Prism),Prism.languages.c=Prism.languages.extend("clike",{comment:{pattern:/\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},string:{pattern:/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},"class-name":{pattern:/(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,lookbehind:!0},keyword:/\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,function:/\b[a-z_]\w*(?=\s*\()/i,number:/(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/}),Prism.languages.insertBefore("c","string",{char:{pattern:/'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,greedy:!0}}),Prism.languages.insertBefore("c","string",{macro:{pattern:/(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,lookbehind:!0,greedy:!0,alias:"property",inside:{string:[{pattern:/^(#\s*include\s*)<[^>]+>/,lookbehind:!0},Prism.languages.c.string],char:Prism.languages.c.char,comment:Prism.languages.c.comment,"macro-name":[{pattern:/(^#\s*define\s+)\w+\b(?!\()/i,lookbehind:!0},{pattern:/(^#\s*define\s+)\w+\b(?=\()/i,lookbehind:!0,alias:"function"}],directive:{pattern:/^(#\s*)[a-z]+/,lookbehind:!0,alias:"keyword"},"directive-hash":/^#/,punctuation:/##|\\(?=[\r\n])/,expression:{pattern:/\S[\s\S]*/,inside:Prism.languages.c}}}}),Prism.languages.insertBefore("c","function",{constant:/\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/}),delete Prism.languages.c.boolean,function(p){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;p.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+t.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+t.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+t.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+t.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},p.languages.css.atrule.inside.rest=p.languages.css;var i=p.languages.markup;i&&(i.tag.addInlined("style","css"),i.tag.addAttribute("style","css"))}(Prism),Prism.languages.objectivec=Prism.languages.extend("c",{string:{pattern:/@?"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},keyword:/\b(?:asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|in|inline|int|long|register|return|self|short|signed|sizeof|static|struct|super|switch|typedef|typeof|union|unsigned|void|volatile|while)\b|(?:@interface|@end|@implementation|@protocol|@class|@public|@protected|@private|@property|@try|@catch|@finally|@throw|@synthesize|@dynamic|@selector)\b/,operator:/-[->]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/@]/}),delete Prism.languages.objectivec["class-name"],Prism.languages.objc=Prism.languages.objectivec,Prism.languages.sql={comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,lookbehind:!0},variable:[{pattern:/@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,greedy:!0},/@[\w.$]+/],string:{pattern:/(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,greedy:!0,lookbehind:!0},identifier:{pattern:/(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,greedy:!0,lookbehind:!0,inside:{punctuation:/^`|`$/}},function:/\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,keyword:/\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,boolean:/\b(?:FALSE|NULL|TRUE)\b/i,number:/\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,operator:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,punctuation:/[;[\]()`,.]/},function(p){var t=p.languages.powershell={comment:[{pattern:/(^|[^`])<#[\s\S]*?#>/,lookbehind:!0},{pattern:/(^|[^`])#.*/,lookbehind:!0}],string:[{pattern:/"(?:`[\s\S]|[^`"])*"/,greedy:!0,inside:null},{pattern:/'(?:[^']|'')*'/,greedy:!0}],namespace:/\[[a-z](?:\[(?:\[[^\]]*\]|[^\[\]])*\]|[^\[\]])*\]/i,boolean:/\$(?:false|true)\b/i,variable:/\$\w+\b/,function:[/\b(?:Add|Approve|Assert|Backup|Block|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|ForEach|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Sort|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Tee|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Where|Write)-[a-z]+\b/i,/\b(?:ac|cat|chdir|clc|cli|clp|clv|compare|copy|cp|cpi|cpp|cvpa|dbp|del|diff|dir|ebp|echo|epal|epcsv|epsn|erase|fc|fl|ft|fw|gal|gbp|gc|gci|gcs|gdr|gi|gl|gm|gp|gps|group|gsv|gu|gv|gwmi|iex|ii|ipal|ipcsv|ipsn|irm|iwmi|iwr|kill|lp|ls|measure|mi|mount|move|mp|mv|nal|ndr|ni|nv|ogv|popd|ps|pushd|pwd|rbp|rd|rdr|ren|ri|rm|rmdir|rni|rnp|rp|rv|rvpa|rwmi|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls|sort|sp|spps|spsv|start|sv|swmi|tee|trcm|type|write)\b/i],keyword:/\b(?:Begin|Break|Catch|Class|Continue|Data|Define|Do|DynamicParam|Else|ElseIf|End|Exit|Filter|Finally|For|ForEach|From|Function|If|InlineScript|Parallel|Param|Process|Return|Sequence|Switch|Throw|Trap|Try|Until|Using|Var|While|Workflow)\b/i,operator:{pattern:/(^|\W)(?:!|-(?:b?(?:and|x?or)|as|(?:Not)?(?:Contains|In|Like|Match)|eq|ge|gt|is(?:Not)?|Join|le|lt|ne|not|Replace|sh[lr])\b|-[-=]?|\+[+=]?|[*\/%]=?)/i,lookbehind:!0},punctuation:/[|{}[\];(),.]/};t.string[0].inside={function:{pattern:/(^|[^`])\$\((?:\$\([^\r\n()]*\)|(?!\$\()[^\r\n)])*\)/,lookbehind:!0,inside:t},boolean:t.boolean,variable:t.variable}}(Prism),Prism.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern://,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python,function(p){for(var t=/\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source,i=0;i<2;i++)t=t.replace(/<self>/g,function(){return t});t=t.replace(/<self>/g,function(){return/[^\s\S]/.source}),p.languages.rust={comment:[{pattern:RegExp(/(^|[^\\])/.source+t),lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,greedy:!0},char:{pattern:/b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,greedy:!0},attribute:{pattern:/#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,greedy:!0,alias:"attr-name",inside:{string:null}},"closure-params":{pattern:/([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,lookbehind:!0,greedy:!0,inside:{"closure-punctuation":{pattern:/^\||\|$/,alias:"punctuation"},rest:null}},"lifetime-annotation":{pattern:/'\w+/,alias:"symbol"},"fragment-specifier":{pattern:/(\$\w+:)[a-z]+/,lookbehind:!0,alias:"punctuation"},variable:/\$\w+/,"function-definition":{pattern:/(\bfn\s+)\w+/,lookbehind:!0,alias:"function"},"type-definition":{pattern:/(\b(?:enum|struct|trait|type|union)\s+)\w+/,lookbehind:!0,alias:"class-name"},"module-declaration":[{pattern:/(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,lookbehind:!0,alias:"namespace"},{pattern:/(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,lookbehind:!0,alias:"namespace",inside:{punctuation:/::/}}],keyword:[/\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,/\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/],function:/\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,macro:{pattern:/\b\w+!/,alias:"property"},constant:/\b[A-Z_][A-Z_\d]+\b/,"class-name":/\b[A-Z]\w*\b/,namespace:{pattern:/(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,inside:{punctuation:/::/}},number:/\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,boolean:/\b(?:false|true)\b/,punctuation:/->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,operator:/[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/},p.languages.rust["closure-params"].inside.rest=p.languages.rust,p.languages.rust.attribute.inside.string=p.languages.rust.string}(Prism),Prism.languages.swift={comment:{pattern:/(^|[^\\:])(?:\/\/.*|\/\*(?:[^/*]|\/(?!\*)|\*(?!\/)|\/\*(?:[^*]|\*(?!\/))*\*\/)*\*\/)/,lookbehind:!0,greedy:!0},"string-literal":[{pattern:RegExp(/(^|[^"#])/.source+"(?:"+/"(?:\\(?:\((?:[^()]|\([^()]*\))*\)|\r\n|[^(])|[^\\\r\n"])*"/.source+"|"+/"""(?:\\(?:\((?:[^()]|\([^()]*\))*\)|[^(])|[^\\"]|"(?!""))*"""/.source+")"+/(?!["#])/.source),lookbehind:!0,greedy:!0,inside:{interpolation:{pattern:/(\\\()(?:[^()]|\([^()]*\))*(?=\))/,lookbehind:!0,inside:null},"interpolation-punctuation":{pattern:/^\)|\\\($/,alias:"punctuation"},punctuation:/\\(?=[\r\n])/,string:/[\s\S]+/}},{pattern:RegExp(/(^|[^"#])(#+)/.source+"(?:"+/"(?:\\(?:#+\((?:[^()]|\([^()]*\))*\)|\r\n|[^#])|[^\\\r\n])*?"/.source+"|"+/"""(?:\\(?:#+\((?:[^()]|\([^()]*\))*\)|[^#])|[^\\])*?"""/.source+")\\2"),lookbehind:!0,greedy:!0,inside:{interpolation:{pattern:/(\\#+\()(?:[^()]|\([^()]*\))*(?=\))/,lookbehind:!0,inside:null},"interpolation-punctuation":{pattern:/^\)|\\#+\($/,alias:"punctuation"},string:/[\s\S]+/}}],directive:{pattern:RegExp(/#/.source+"(?:"+(/(?:elseif|if)\b/.source+"(?:[ ]*"+/(?:![ \t]*)?(?:\b\w+\b(?:[ \t]*\((?:[^()]|\([^()]*\))*\))?|\((?:[^()]|\([^()]*\))*\))(?:[ \t]*(?:&&|\|\|))?/.source+")+")+"|"+/(?:else|endif)\b/.source+")"),alias:"property",inside:{"directive-name":/^#\w+/,boolean:/\b(?:false|true)\b/,number:/\b\d+(?:\.\d+)*\b/,operator:/!|&&|\|\||[<>]=?/,punctuation:/[(),]/}},literal:{pattern:/#(?:colorLiteral|column|dsohandle|file(?:ID|Literal|Path)?|function|imageLiteral|line)\b/,alias:"constant"},"other-directive":{pattern:/#\w+\b/,alias:"property"},attribute:{pattern:/@\w+/,alias:"atrule"},"function-definition":{pattern:/(\bfunc\s+)\w+/,lookbehind:!0,alias:"function"},label:{pattern:/\b(break|continue)\s+\w+|\b[a-zA-Z_]\w*(?=\s*:\s*(?:for|repeat|while)\b)/,lookbehind:!0,alias:"important"},keyword:/\b(?:Any|Protocol|Self|Type|actor|as|assignment|associatedtype|associativity|async|await|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|else|enum|extension|fallthrough|fileprivate|final|for|func|get|guard|higherThan|if|import|in|indirect|infix|init|inout|internal|is|isolated|lazy|left|let|lowerThan|mutating|none|nonisolated|nonmutating|open|operator|optional|override|postfix|precedencegroup|prefix|private|protocol|public|repeat|required|rethrows|return|right|safe|self|set|some|static|struct|subscript|super|switch|throw|throws|try|typealias|unowned|unsafe|var|weak|where|while|willSet)\b/,boolean:/\b(?:false|true)\b/,nil:{pattern:/\bnil\b/,alias:"constant"},"short-argument":/\$\d+\b/,omit:{pattern:/\b_\b/,alias:"keyword"},number:/\b(?:[\d_]+(?:\.[\de_]+)?|0x[a-f0-9_]+(?:\.[a-f0-9p_]+)?|0b[01_]+|0o[0-7_]+)\b/i,"class-name":/\b[A-Z](?:[A-Z_\d]*[a-z]\w*)?\b/,function:/\b[a-z_]\w*(?=\s*\()/i,constant:/\b(?:[A-Z_]{2,}|k[A-Z][A-Za-z_]+)\b/,operator:/[-+*/%=!<>&|^~?]+|\.[.\-+*/%=!<>&|^~?]+/,punctuation:/[{}[\]();,.:\\]/},Prism.languages.swift["string-literal"].forEach(function(p){p.inside.interpolation.inside=Prism.languages.swift}),function(p){p.languages.typescript=p.languages.extend("javascript",{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),p.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete p.languages.typescript.parameter,delete p.languages.typescript["literal-property"];var t=p.languages.extend("typescript",{});delete t["class-name"],p.languages.typescript["class-name"].inside=t,p.languages.insertBefore("typescript","function",{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:"operator"},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:t}}}}),p.languages.ts=p.languages.typescript}(Prism),function(p){var t=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,i=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,e={pattern:RegExp(/(^|[^\w.])/.source+i+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};p.languages.java=p.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[e,{pattern:RegExp(/(^|[^\w.])/.source+i+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:e.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+i+/[A-Z]\w*\b/.source),lookbehind:!0,inside:e.inside}],keyword:t,function:[p.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),p.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),p.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":e,keyword:t,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+i+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:e.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+i+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:e.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(/<keyword>/g,function(){return t.source})),lookbehind:!0,inside:{punctuation:/\./}}})}(Prism),function(p){var t=/\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,i=/\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g,function(){return t.source});p.languages.cpp=p.languages.extend("c",{"class-name":[{pattern:RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source.replace(/<keyword>/g,function(){return t.source})),lookbehind:!0},/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,/\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/],keyword:t,number:{pattern:/(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,greedy:!0},operator:/>>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,boolean:/\b(?:false|true)\b/}),p.languages.insertBefore("cpp","string",{module:{pattern:RegExp(/(\b(?:import|module)\s+)/.source+"(?:"+/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source+"|"+/<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/g,function(){return i})+")"),lookbehind:!0,greedy:!0,inside:{string:/^[<"][\s\S]+/,operator:/:/,punctuation:/\./}},"raw-string":{pattern:/R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,alias:"string",greedy:!0}}),p.languages.insertBefore("cpp","keyword",{"generic-function":{pattern:/\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,inside:{function:/^\w+/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:p.languages.cpp}}}}),p.languages.insertBefore("cpp","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}}),p.languages.insertBefore("cpp","class-name",{"base-clause":{pattern:/(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,lookbehind:!0,greedy:!0,inside:p.languages.extend("cpp",{})}}),p.languages.insertBefore("inside","double-colon",{"class-name":/\b[a-z_]\w*\b(?!\s*::)/i},p.languages.cpp["base-clause"])}(Prism);function gI(p){return p&&p.__esModule&&Object.prototype.hasOwnProperty.call(p,"default")?p.default:p}gI(function(p){const t=new URLSearchParams;t.append("code",p);for(let i=1;i<arguments.length;i++)t.append("v",arguments[i]);throw Error(`Minified Lexical error #${p}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const Bw=p=>{try{return!!p&&window.Prism.languages.hasOwnProperty(p)}catch{return!1}};function zw(p,t){for(const i of p.childNodes){if(ll(i)&&i.tagName===t)return!0;zw(i,t)}return!1}const Td="data-language",oh="data-highlight-language";let Uw=class vE extends fi{static getType(){return"code"}static clone(t){return new vE(t.__language,t.__key)}constructor(t,i){super(i),this.__language=t,this.__isSyntaxHighlightSupported=Bw(t)}createDOM(t){const i=document.createElement("code");hi(i,t.theme.code),i.setAttribute("spellcheck","false");const e=this.getLanguage();return e&&(i.setAttribute(Td,e),this.getIsSyntaxHighlightSupported()&&i.setAttribute(oh,e)),i}updateDOM(t,i,e){const s=this.__language,r=t.__language;return s?s!==r&&(i.setAttribute(Td,s),this.__isSyntaxHighlightSupported&&i.setAttribute(oh,s)):r&&(i.removeAttribute(Td),t.__isSyntaxHighlightSupported&&i.removeAttribute(oh)),!1}exportDOM(t){const i=document.createElement("pre");hi(i,t._config.theme.code),i.setAttribute("spellcheck","false");const e=this.getLanguage();return e&&(i.setAttribute(Td,e),this.getIsSyntaxHighlightSupported()&&i.setAttribute(oh,e)),{element:i}}static importDOM(){return{code:t=>t.textContent!=null&&(/\r?\n/.test(t.textContent)||zw(t,"BR"))?{conversion:Hw,priority:1}:null,div:()=>({conversion:yI,priority:1}),pre:()=>({conversion:Hw,priority:0}),table:t=>Ay(t)?{conversion:bI,priority:3}:null,td:t=>{const i=t,e=i.closest("table");return i.classList.contains("js-file-line")||e&&Ay(e)?{conversion:$w,priority:3}:null},tr:t=>{const i=t.closest("table");return i&&Ay(i)?{conversion:$w,priority:3}:null}}}static importJSON(t){const i=Od(t.language);return i.setFormat(t.format),i.setIndent(t.indent),i.setDirection(t.direction),i}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),type:"code",version:1}}insertNewAfter(t,i=!0){const e=this.getChildren(),s=e.length;if(s>=2&&e[s-1].getTextContent()===`
|
|
1522
1522
|
`&&e[s-2].getTextContent()===`
|
|
1523
|
-
`&&t.isCollapsed()&&t.anchor.key===this.__key&&t.anchor.offset===s){e[s-1].remove(),e[s-2].remove();const l=lr();return this.insertAfter(l,i),l}const{anchor:r,focus:n}=t,o=(r.isBefore(n)?r:n).getNode();if(qt(o)){let l=vI(o);const a=[];for(;;)if(Pg(l))a.push(Xl()),l=l.getNextSibling();else{if(!Ny(l))break;{let g=0;const _=l.getTextContent(),v=l.getTextContentSize();for(;g<v&&_[g]===" ";)g++;if(g!==0&&a.push(Vw(" ".repeat(g))),g!==v)break;l=l.getNextSibling()}}const u=o.splitText(r.offset)[0],c=r.offset===0?0:1,f=u.getIndexWithinParent()+c,d=o.getParentOrThrow(),h=[ms(),...a];d.splice(f,0,h);const m=a[a.length-1];m?m.select():r.offset===0?u.selectPrevious():u.getNextSibling().selectNext(0,0)}if(mI(o)){const{offset:l}=t.anchor;o.splice(l,0,[ms()]),o.select(l+1,l+1)}return null}canIndent(){return!1}collapseAtStart(){const t=lr();return this.getChildren().forEach(i=>t.append(i)),this.replace(t),!0}setLanguage(t){const i=this.getWritable();i.__language=t,i.__isSyntaxHighlightSupported=Bw(t)}getLanguage(){return this.getLatest().__language}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}};function Od(p){return So(new Uw(p))}function mI(p){return p instanceof Uw}function Hw(p){return{node:Od(p.getAttribute(Td))}}function yI(p){const t=p,i=qw(t);return i||function(e){let s=e.parentElement;for(;s!==null;){if(qw(s))return!0;s=s.parentElement}return!1}(t)?{node:i?Od():null}:{node:null}}function bI(){return{node:Od()}}function $w(){return{node:null}}function qw(p){return p.style.fontFamily.match("monospace")!==null}function Ay(p){return p.classList.contains("js-file-line-container")}let Ww=class _E extends Wi{constructor(t,i,e){super(t,e),this.__highlightType=i}static getType(){return"code-highlight"}static clone(t){return new _E(t.__text,t.__highlightType||void 0,t.__key)}getHighlightType(){return this.getLatest().__highlightType}canHaveFormat(){return!1}createDOM(t){const i=super.createDOM(t),e=jy(t.theme,this.__highlightType);return hi(i,e),i}updateDOM(t,i,e){const s=super.updateDOM(t,i,e),r=jy(e.theme,t.__highlightType),n=jy(e.theme,this.__highlightType);return r!==n&&(r&&Vg(i,r),n&&hi(i,n)),s}static importJSON(t){const i=Vw(t.text,t.highlightType);return i.setFormat(t.format),i.setDetail(t.detail),i.setMode(t.mode),i.setStyle(t.style),i}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType(),type:"code-highlight",version:1}}setFormat(t){return this}isParentRequired(){return!0}createParentElementNode(){return Od()}};function jy(p,t){return t&&p&&p.codeHighlight&&p.codeHighlight[t]}function Vw(p,t){return So(new Ww(p,t))}function Ny(p){return p instanceof Ww}function vI(p){let t=p,i=p;for(;Ny(i)||Pg(i);)t=i,i=i.getPreviousSibling();return t}function _I(p,t){const i=p.getRangeAt(0);let e;if(p.anchorNode===t){let s=t;for(;s.firstElementChild!=null;)s=s.firstElementChild;e=s.getBoundingClientRect()}else e=i.getBoundingClientRect();return e}function xI(p){const t=p.anchor,i=p.focus,e=p.anchor.getNode(),s=p.focus.getNode();return e===s?e:p.isBackward()?yv(i)?e:s:yv(t)?e:s}const wI=10,SI=5;function EI(p,t,i,e=!1,s=wI,r=SI){const n=i.parentElement;if(p===null||!n){t.style.opacity="0",t.style.transform="translate(-10000px, -10000px)";return}const o=t.getBoundingClientRect(),l=i.getBoundingClientRect(),a=n.getBoundingClientRect();let u=p.top-o.height-s,c=p.left-r;u<a.top&&(u+=o.height+p.height+s*(e?9:2)),c+o.width>a.right&&(c=a.right-o.width-r),u-=l.top,c-=l.left,t.style.opacity="1",t.style.transform=`translate(${c}px, ${u}px)`}function CI({editor:p,anchorElem:t,isLink:i,isBold:e,isItalic:s,isUnderline:r,isCode:n,isStrikethrough:o,isSubscript:l,isSuperscript:a}){const u=ve.useRef(null);p.dispatchCommand(Vr,"bold"),ve.useCallback(()=>{i?p.dispatchCommand(G1,null):p.dispatchCommand(G1,"https://")},[p,i]);const c=()=>{p.dispatchCommand(Oy,void 0)};function f(m){if(u!=null&&u.current&&(m.buttons===1||m.buttons===3)&&u.current.style.pointerEvents!=="none"){const g=m.clientX,_=m.clientY,v=document.elementFromPoint(g,_);u.current.contains(v)||(u.current.style.pointerEvents="none")}}function d(m){u!=null&&u.current&&u.current.style.pointerEvents!=="auto"&&(u.current.style.pointerEvents="auto")}ve.useEffect(()=>{if(u!=null&&u.current)return document.addEventListener("mousemove",f),document.addEventListener("mouseup",d),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",d)}},[u]);const h=ve.useCallback(()=>{const m=Ot(),g=u.current,_=window.getSelection();if(g===null)return;const v=p.getRootElement();if(m!==null&&_!==null&&!_.isCollapsed&&v!==null&&v.contains(_.anchorNode)){const b=_I(_,v);EI(b,g,t,i)}},[p,t,i]);return ve.useEffect(()=>{const m=t.parentElement,g=()=>{p.getEditorState().read(()=>{h()})};return window.addEventListener("resize",g),m&&m.addEventListener("scroll",g),()=>{window.removeEventListener("resize",g),m&&m.removeEventListener("scroll",g)}},[p,h,t]),ve.useEffect(()=>(p.getEditorState().read(()=>{h()}),Mr(p.registerUpdateListener(({editorState:m})=>{m.read(()=>{h()})}),p.registerCommand(zo,()=>(h(),!1),Ln))),[p,h]),_e.jsxs("div",{ref:u,className:"floating-text-format-popup",children:[p.isEditable()&&_e.jsxs(_e.Fragment,{children:[_e.jsx("button",{type:"button",onClick:()=>{p.dispatchCommand(Vr,"bold")},className:"popup-item spaced "+(e?"active":""),"aria-label":"Format text as bold",children:_e.jsx("i",{className:"format bold"})}),_e.jsx("button",{type:"button",onClick:()=>{p.dispatchCommand(Vr,"italic")},className:"popup-item spaced "+(s?"active":""),"aria-label":"Format text as italics",children:_e.jsx("i",{className:"format italic"})}),_e.jsx("button",{type:"button",onClick:()=>{p.dispatchCommand(Vr,"underline")},className:"popup-item spaced "+(r?"active":""),"aria-label":"Format text to underlined",children:_e.jsx("i",{className:"format underline"})}),_e.jsx("button",{type:"button",onClick:()=>{p.dispatchCommand(Vr,"strikethrough")},className:"popup-item spaced "+(o?"active":""),"aria-label":"Format text with a strikethrough",children:_e.jsx("i",{className:"format strikethrough"})}),_e.jsx("button",{type:"button",onClick:()=>{p.dispatchCommand(Vr,"subscript")},className:"popup-item spaced "+(l?"active":""),title:"Subscript","aria-label":"Format Subscript",children:_e.jsx("i",{className:"format subscript"})}),_e.jsx("button",{type:"button",onClick:()=>{p.dispatchCommand(Vr,"superscript")},className:"popup-item spaced "+(a?"active":""),title:"Superscript","aria-label":"Format Superscript",children:_e.jsx("i",{className:"format superscript"})})]}),_e.jsx("button",{type:"button",onClick:c,className:"popup-item spaced insert-comment","aria-label":"Insert comment",children:_e.jsx("i",{className:"format add-comment"})})]})}function kI(p,t){const[i,e]=ve.useState(!1),[s,r]=ve.useState(!1),[n,o]=ve.useState(!0),[l,a]=ve.useState(!1),[u,c]=ve.useState(!1),[f,d]=ve.useState(!1),[h,m]=ve.useState(!1),[g,_]=ve.useState(!1),[v,b]=ve.useState(!1),S=ve.useCallback(()=>{p.getEditorState().read(()=>{if(p.isComposing())return;const E=Ot(),x=window.getSelection(),y=p.getRootElement();if(x!==null&&(!Et(E)||y===null||!y.contains(x.anchorNode))){e(!1);return}if(!Et(E))return;const w=xI(E);o(E.hasFormat("bold")),a(E.hasFormat("italic")),c(E.hasFormat("underline")),d(E.hasFormat("strikethrough")),m(E.hasFormat("subscript")),_(E.hasFormat("superscript")),b(E.hasFormat("code"));const C=w.getParent();km(C)||km(w)?r(!0):r(!1),!Ny(E.anchor.getNode())&&E.getTextContent()!==""?e(qt(w)||ca(w)):e(!1);const j=E.getTextContent().replace(/\n/g,"");if(!E.isCollapsed()&&j===""){e(!1);return}})},[p]);return ve.useEffect(()=>(document.addEventListener("selectionchange",S),()=>{document.removeEventListener("selectionchange",S)}),[S]),ve.useEffect(()=>Mr(p.registerUpdateListener(()=>{S()}),p.registerRootListener(()=>{p.getRootElement()===null&&e(!1)})),[p,S]),i?ro.createPortal(_e.jsx(CI,{editor:p,anchorElem:t,isLink:s,isBold:n,isItalic:l,isStrikethrough:f,isSubscript:h,isSuperscript:g,isUnderline:u,isCode:v}),t):null}function TI({anchorElem:p=document.body}){const[t]=Yn();return kI(t,p)}const OI=({onChange:p})=>{const[t]=Yn(),[i,e]=ve.useState(!0),s=ve.useRef(""),r=s.current,n=ve.useCallback(()=>{t.update(()=>{const o=zv(t);i?e(!1):o!==r&&(p(o),s.current=o)})},[t,i,p,r]);return ve.useEffect(()=>{const o=t.registerUpdateListener(n);return()=>o()},[t,n]),null},AI=cx([...[Ji,Gu,Vi,Yf,Qf,ep,xl,yd]]);function jI({collabApiKey:p,userObj:t,styleConfig:i,docId:e,onlUser:s,setonlUser:r,savedSpfEditorState:n,setSavedEditorState:o,setSavedEditorState2:l,mentionItems:a,showtoolbar:u=!0,customHeight:c,customWidth:f,disabled:d,editorId:h,onPaste:m,source:g}){const _=ve.useRef(null),{pageMarginTop:v,pageMarginLeft:b,pageMarginBottom:S,pageMarginRight:E,heading:x}=i||{};ve.useState("");const[y,w]=ve.useState(!0),C=ve.useRef(null),[j,P]=ve.useState(!1),[F,I]=ve.useState([]),D=ve.useRef(),[N,k]=ve.useState({root:null}),[A,R]=ve.useState(0);let L={namespace:`editor_${h}`,nodes:[...AI],onError(K){throw K},theme:Ug,editorState:K=>{K.update(()=>{if(n&&y){const Z=new DOMParser().parseFromString(n,"text/html"),X=tm(K,Z);X.forEach(ee=>{ee instanceof Vi&&ee.setStyle("font-weight: normal")}),yr(),tc(X),w(!1)}})}};ve.useEffect(()=>{setTimeout(()=>{fc(".custom-margin").css({paddingTop:`${v||"16px"}`,paddingRight:`${E||"16px"}`,paddingLeft:`${b||"16px"}`,paddingBottom:`${S||"16px"}`}),fc(".editor-inner").css({maxHeight:c?`${c}px`:"100%",overflow:"scroll",height:c?`${c}px`:"100%",minHeight:"200px",maxWidth:f?`${f}px`:"100%"}),fc(`.${h}`).attr("contentEditable",!d)},500)},[]);const{userName:J,userId:O,userEmail:z}=t,G={docId:h,apiKey:p,user:{name:J,id:O,email:z},showCursor:!1,cursorAlwaysOn:!1,showPointer:!1,hooks:{contentChanged:({source:K,content:Y})=>{},usersUpdate:K=>{I(K),renderOnlineUsers(K)}}},B=()=>{D.current&&D.current.start(G).then(()=>{console.log("[Lexical Demo][codox.start] success"),P(!0)}).catch(K=>console.log("[Lexical Demo][codox.start] error",K))};ve.useEffect(()=>()=>{$()},[]);const $=()=>{D.current&&D.current.stop(),P(!1)};ve.useEffect(()=>{N&&e&&!j&&B()},[N,e,j]),ve.useEffect(()=>{let K=[],Y=[];F&&F.length>0&&F.map((Z,X)=>{Y.includes(Z.name)||(Y.push(Z.name),K.push(_e.jsxs("div",{title:Z.email,className:`avatarStyle avatar-color-${X+1}`,children:[" ",Z.name&&Z.name[0],Z.name&&Z.name[4]]},X)))}),r(K)},[F]),ve.useEffect(()=>{(async K=>{const Y=!!p,Z=!!t,X=!!i;A>1&&A<200&&R(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.")})()},[p,t,i]);const q=ve.useCallback(K=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{o(K)},500)},[h,o,l]),H=ve.useCallback(K=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{l(K)},500)},[h,o,l]);return _e.jsxs("div",{ref:_,children:[_e.jsx(R2,{children:_e.jsxs(zf,{initialConfig:L,children:[_e.jsx(lx,{ref:D}),_e.jsxs("div",{className:"editor-container",children:[u&&_e.jsx("div",{style:{pointerEvents:d?"none":"all"},children:_e.jsx(MT,{styleConfig:i,onlUser:s,stopCodox:$,startCodox:B,source:g,onPaste:m})}),_e.jsxs("div",{className:"editor-inner",children:[_e.jsx(up,{contentEditable:_e.jsx("div",{className:"custom-margin",children:_e.jsx(fp,{className:`editor-input ${h}`,contentEditable:!1})}),placeholder:null,ErrorBoundary:mc}),_e.jsx(dp,{})]})]}),_e.jsx(_2,{}),_e.jsx($T,{}),_e.jsx(T2,{}),_e.jsx(F2,{}),_e.jsx(gp,{}),_e.jsx(uP,{items:a,menuComponent:dP,menuItemComponent:fP}),_e.jsx(OI,{onChange:h.includes("objective")?q:H}),_e.jsx(pI,{}),_e.jsx(TI,{})]})}),_e.jsx(Fk,{styleConfig:i})]})}const NI=cx([...[]]);function PI({collabApiKey:p,userObj:t,docId:i,setonlUser:e,savedSpfEditorState:s,setSavedEditorState:r,customHeight:n,customWidth:o,editorId:l}){const a=ve.useRef(null),[u,c]=ve.useState(!0),[f,d]=ve.useState(!1),[h,m]=ve.useState([]),g=ve.useRef(),[_,v]=ve.useState({root:null});ve.useState(0);const b=ve.useRef(""),S={namespace:`editor_${l}`,nodes:[...NI],onError(F){throw F},theme:Ug,editorState:F=>{F.update(()=>{if(s&&u){const D=new DOMParser().parseFromString(s,"text/html"),N=tm(F,D);yr(),tc(N),c(!1)}})}};ve.useEffect(()=>{setTimeout(()=>{fc(".custom-margin-2").css({height:`${n}px`}),fc(".editor-inner-2").css({background:"#fff",position:"relative",top:"20px",padding:"20px",borderRadius:"0 0 10px 10px",maxHeight:`${n}px`,overflow:"scroll",height:`${n}px`,minHeight:"200px",maxWidth:o?`${o}px`:"100%"})},500)},[]);const{userName:E,userId:x,userEmail:y}=t,C={docId:l,apiKey:p,user:{name:E,id:x,email:y},showCursor:!1,cursorAlwaysOn:!1,showPointer:!1,hooks:{contentChanged:({source:F,content:I})=>{},usersUpdate:F=>{m(F),renderOnlineUsers(F)}}},j=()=>{g.current&&g.current.start(C).then(()=>{console.log("[Lexical Demo][codox.start] success"),d(!0)}).catch(F=>console.log("[Lexical Demo][codox.start] error",F))};ve.useEffect(()=>{_&&i&&!f&&j()},[_,i,f]),ve.useEffect(()=>{let F=[],I=[];h&&h.length>0&&h.map((D,N)=>{I.includes(D.name)||(I.push(D.name),F.push(_e.jsxs("div",{title:D.email,className:`avatarStyle avatar-color-${N+1}`,children:[" ",D.name&&D.name[0],D.name&&D.name[4]]},N)))}),e(F)},[h]);const P=()=>{let F=fc(".editor-input-2").html();F!==b.current&&(console.log("Editor Variant 2 HTML",F),r(F),b.current=F)};return _e.jsx("div",{ref:a,children:_e.jsxs(zf,{initialConfig:S,children:[_e.jsx(lx,{ref:g}),_e.jsx("div",{className:"editor-container",children:_e.jsxs("div",{className:"editor-inner-2",children:[_e.jsx(up,{contentEditable:_e.jsx("div",{className:"custom-margin-2",children:_e.jsx(fp,{className:"editor-input-2 inpt-2"})}),placeholder:null,ErrorBoundary:mc}),_e.jsx(Am,{onChange:P}),_e.jsx(dp,{})]})}),_e.jsx(gp,{})]})})}const NM="";function II(p){return p&&p.__esModule&&Object.prototype.hasOwnProperty.call(p,"default")?p.default:p}var MI=II(function(p){const t=new URLSearchParams;t.append("code",p);for(let i=1;i<arguments.length;i++)t.append("v",arguments[i]);throw Error(`Minified Lexical error #${p}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Jw(p){const t=p.transform();return t!==null?new Set([t]):new Set}function Gw({initialEditor:p,children:t,initialNodes:i,initialTheme:e,skipCollabChecks:s}){const r=ve.useRef(!1),n=ve.useContext(wu);n==null&&MI(9);const[o,{getTheme:l}]=n,a=ve.useMemo(()=>{const d=e||l()||void 0,h=L0(n,d);if(d!==void 0&&(p._config.theme=d),p._parentEditor=o,i)for(let m of i){let g=null,_=null;if(typeof m!="function"){const b=m;m=b.replace,g=b.with,_=b.withKlass||null}const v=p._nodes.get(m.getType());p._nodes.set(m.getType(),{exportDOM:v?v.exportDOM:void 0,klass:m,replace:g,replaceWithKlass:_,transforms:Jw(m)})}else{const m=p._nodes=new Map(o._nodes);for(const[g,_]of m)p._nodes.set(g,{exportDOM:_.exportDOM,klass:_.klass,replace:_.replace,replaceWithKlass:_.replaceWithKlass,transforms:Jw(_.klass)})}return p._config.namespace=o._config.namespace,p._editable=o._editable,[p,h]},[]),{isCollabActive:u,yjsDocMap:c}=pp(),f=s||r.current||c.has(p.getKey());return ve.useEffect(()=>{f&&(r.current=!0)},[f]),ve.useEffect(()=>o.registerEditableListener(d=>{p.setEditable(d)}),[p,o]),_e.jsx(wu.Provider,{value:a,children:!u||f?t:null})}function Py(p,t,i){return Math.min(Math.max(p,t),i)}const Or={east:1,north:8,south:2,west:4};function RI({onResizeStart:p,onResizeEnd:t,buttonRef:i,imageRef:e,maxWidth:s,editor:r,showCaption:n,setShowCaption:o,captionsEnabled:l}){const a=ve.useRef(null),u=ve.useRef({priority:"",value:"default"}),c=ve.useRef({currentHeight:0,currentWidth:0,direction:0,isResizing:!1,ratio:0,startHeight:0,startWidth:0,startX:0,startY:0}),f=r.getRootElement(),d=f!==null?f.getBoundingClientRect().width-20:100,h=f!==null?f.getBoundingClientRect().height-20:100,m=100,g=100,_=x=>{const y=x===Or.east||x===Or.west,w=x===Or.north||x===Or.south,C=x&Or.north&&x&Or.west||x&Or.south&&x&Or.east,j=y?"ew":w?"ns":C?"nwse":"nesw";f!==null&&f.style.setProperty("cursor",`${j}-resize`,"important"),document.body!==null&&(document.body.style.setProperty("cursor",`${j}-resize`,"important"),u.current.value=document.body.style.getPropertyValue("-webkit-user-select"),u.current.priority=document.body.style.getPropertyPriority("-webkit-user-select"),document.body.style.setProperty("-webkit-user-select","none","important"))},v=()=>{f!==null&&f.style.setProperty("cursor","text"),document.body!==null&&(document.body.style.setProperty("cursor","default"),document.body.style.setProperty("-webkit-user-select",u.current.value,u.current.priority))},b=(x,y)=>{if(!r.isEditable())return;const w=e.current,C=a.current;if(w!==null&&C!==null){x.preventDefault();const{width:j,height:P}=w.getBoundingClientRect(),F=c.current;F.startWidth=j,F.startHeight=P,F.ratio=j/P,F.currentWidth=j,F.currentHeight=P,F.startX=x.clientX,F.startY=x.clientY,F.isResizing=!0,F.direction=y,_(y),p(),C.classList.add("image-control-wrapper--resizing"),w.style.height=`${P}px`,w.style.width=`${j}px`,document.addEventListener("pointermove",S),document.addEventListener("pointerup",E)}},S=x=>{const y=e.current,w=c.current,C=w.direction&(Or.east|Or.west),j=w.direction&(Or.south|Or.north);if(y!==null&&w.isResizing){if(C&&j){let P=Math.floor(w.startX-x.clientX);P=w.direction&Or.east?-P:P;const F=Py(w.startWidth+P,m,d),I=F/w.ratio;y.style.width=`${F}px`,y.style.height=`${I}px`,w.currentHeight=I,w.currentWidth=F}else if(j){let P=Math.floor(w.startY-x.clientY);P=w.direction&Or.south?-P:P;const F=Py(w.startHeight+P,g,h);y.style.height=`${F}px`,y.style.maxHeight=`${F}px`,w.currentHeight=F}else{let P=Math.floor(w.startX-x.clientX);P=w.direction&Or.east?-P:P;const F=Py(w.startWidth+P,m,d);y.style.width=`${F}px`,y.style.maxWidth=`${F}px`,w.currentWidth=F}y&&(y.setAttribute("width",`${w.currentWidth}`),y.setAttribute("height",`${w.currentHeight}`))}},E=()=>{const x=e.current,y=c.current,w=a.current;if(x!==null&&w!==null&&y.isResizing){const C=y.currentWidth,j=y.currentHeight;y.startWidth=0,y.startHeight=0,y.ratio=0,y.startX=0,y.startY=0,y.currentWidth=0,y.currentHeight=0,y.isResizing=!1,w.classList.remove("image-control-wrapper--resizing"),v(),t(C,j),document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",E)}};return _e.jsxs("div",{ref:a,children:[_e.jsx("div",{className:"image-resizer image-resizer-n",onPointerDown:x=>{b(x,Or.north)}}),_e.jsx("div",{className:"image-resizer image-resizer-ne",onPointerDown:x=>{b(x,Or.north|Or.east)}}),_e.jsx("div",{className:"image-resizer image-resizer-e",onPointerDown:x=>{b(x,Or.east)}}),_e.jsx("div",{className:"image-resizer image-resizer-se",onPointerDown:x=>{b(x,Or.south|Or.east)}}),_e.jsx("div",{className:"image-resizer image-resizer-s",onPointerDown:x=>{b(x,Or.south)}}),_e.jsx("div",{className:"image-resizer image-resizer-sw",onPointerDown:x=>{b(x,Or.south|Or.west)}}),_e.jsx("div",{className:"image-resizer image-resizer-w",onPointerDown:x=>{b(x,Or.west)}}),_e.jsx("div",{className:"image-resizer image-resizer-nw",onPointerDown:x=>{b(x,Or.north|Or.west)}})]})}const ih={x:0,y:0,width:0,height:0,unit:"px"},Kc=(p,t,i)=>Math.min(Math.max(p,t),i),DI=(...p)=>p.filter(t=>t&&typeof t=="string").join(" "),Kw=(p,t)=>p===t||p.width===t.width&&p.height===t.height&&p.x===t.x&&p.y===t.y&&p.unit===t.unit;function Yc(p,t,i){return p.unit==="%"?{...ih,...p,unit:"%"}:{unit:"%",x:p.x?p.x/t*100:0,y:p.y?p.y/i*100:0,width:p.width?p.width/t*100:0,height:p.height?p.height/i*100:0}}function Ds(p,t,i){return p.unit?p.unit==="px"?{...ih,...p,unit:"px"}:{unit:"px",x:p.x?p.x*t/100:0,y:p.y?p.y*i/100:0,width:p.width?p.width*t/100:0,height:p.height?p.height*i/100:0}:{...ih,...p,unit:"px"}}function Yw(p,t,i,e,s,r=0,n=0,o=e,l=s){const a={...p};let u=Math.min(r,e),c=Math.min(n,s),f=Math.min(o,e),d=Math.min(l,s);t&&(t>1?(u=n?n*t:u,c=u/t,f=o*t):(c=r?r/t:c,u=c*t,d=l/t)),a.y<0&&(a.height=Math.max(a.height+a.y,c),a.y=0),a.x<0&&(a.width=Math.max(a.width+a.x,u),a.x=0);const h=e-(a.x+a.width);h<0&&(a.x=Math.min(a.x,e-u),a.width+=h);const m=s-(a.y+a.height);if(m<0&&(a.y=Math.min(a.y,s-c),a.height+=m),a.width<u&&((i==="sw"||i=="nw")&&(a.x-=u-a.width),a.width=u),a.height<c&&((i==="nw"||i=="ne")&&(a.y-=c-a.height),a.height=c),a.width>f&&((i==="sw"||i=="nw")&&(a.x-=f-a.width),a.width=f),a.height>d&&((i==="nw"||i=="ne")&&(a.y-=d-a.height),a.height=d),t){const g=a.width/a.height;if(g<t){const _=Math.max(a.width/t,c);(i==="nw"||i=="ne")&&(a.y-=_-a.height),a.height=_}else if(g>t){const _=Math.max(a.height*t,u);(i==="sw"||i=="nw")&&(a.x-=_-a.width),a.width=_}}return a}function LI(p,t,i,e){const s={...p};return t==="ArrowLeft"?e==="nw"?(s.x-=i,s.y-=i,s.width+=i,s.height+=i):e==="w"?(s.x-=i,s.width+=i):e==="sw"?(s.x-=i,s.width+=i,s.height+=i):e==="ne"?(s.y+=i,s.width-=i,s.height-=i):e==="e"?s.width-=i:e==="se"&&(s.width-=i,s.height-=i):t==="ArrowRight"&&(e==="nw"?(s.x+=i,s.y+=i,s.width-=i,s.height-=i):e==="w"?(s.x+=i,s.width-=i):e==="sw"?(s.x+=i,s.width-=i,s.height-=i):e==="ne"?(s.y-=i,s.width+=i,s.height+=i):e==="e"?s.width+=i:e==="se"&&(s.width+=i,s.height+=i)),t==="ArrowUp"?e==="nw"?(s.x-=i,s.y-=i,s.width+=i,s.height+=i):e==="n"?(s.y-=i,s.height+=i):e==="ne"?(s.y-=i,s.width+=i,s.height+=i):e==="sw"?(s.x+=i,s.width-=i,s.height-=i):e==="s"?s.height-=i:e==="se"&&(s.width-=i,s.height-=i):t==="ArrowDown"&&(e==="nw"?(s.x+=i,s.y+=i,s.width-=i,s.height-=i):e==="n"?(s.y+=i,s.height-=i):e==="ne"?(s.y+=i,s.width-=i,s.height-=i):e==="sw"?(s.x-=i,s.width+=i,s.height+=i):e==="s"?s.height+=i:e==="se"&&(s.width+=i,s.height+=i)),s}const Zc={capture:!0,passive:!1};let FI=0;const Ls=class ia extends ve.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=ve.createRef(),this.mediaRef=ve.createRef(),this.initChangeCalled=!1,this.instanceId=`rc-${FI++}`,this.state={cropIsActive:!1,newCropIsBeingDrawn:!1},this.onCropPointerDown=t=>{const{crop:i,disabled:e}=this.props,s=this.getBox();if(!i)return;const r=Ds(i,s.width,s.height);if(e)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const n=t.target.dataset.ord,o=!!n;let l=t.clientX,a=t.clientY,u=r.x,c=r.y;if(n){const f=t.clientX-s.x,d=t.clientY-s.y;let h=0,m=0;n==="ne"||n=="e"?(h=f-(r.x+r.width),m=d-r.y,u=r.x,c=r.y+r.height):n==="se"||n==="s"?(h=f-(r.x+r.width),m=d-(r.y+r.height),u=r.x,c=r.y):n==="sw"||n=="w"?(h=f-r.x,m=d-(r.y+r.height),u=r.x+r.width,c=r.y):(n==="nw"||n=="n")&&(h=f-r.x,m=d-r.y,u=r.x+r.width,c=r.y+r.height),l=u+s.x+h,a=c+s.y+m}this.evData={startClientX:l,startClientY:a,startCropX:u,startCropY:c,clientX:t.clientX,clientY:t.clientY,isResize:o,ord:n},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})},this.onComponentPointerDown=t=>{const{crop:i,disabled:e,locked:s,keepSelection:r,onChange:n}=this.props,o=this.getBox();if(e||s||r&&i)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const l=t.clientX-o.x,a=t.clientY-o.y,u={unit:"px",x:l,y:a,width:0,height:0};this.evData={startClientX:t.clientX,startClientY:t.clientY,startCropX:l,startCropY:a,clientX:t.clientX,clientY:t.clientY,isResize:!0},this.mouseDownOnCrop=!0,n(Ds(u,o.width,o.height),Yc(u,o.width,o.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})},this.onDocPointerMove=t=>{const{crop:i,disabled:e,onChange:s,onDragStart:r}=this.props,n=this.getBox();if(e||!i||!this.mouseDownOnCrop)return;t.cancelable&&t.preventDefault(),this.dragStarted||(this.dragStarted=!0,r&&r(t));const{evData:o}=this;o.clientX=t.clientX,o.clientY=t.clientY;let l;o.isResize?l=this.resizeCrop():l=this.dragCrop(),Kw(i,l)||s(Ds(l,n.width,n.height),Yc(l,n.width,n.height))},this.onComponentKeyDown=t=>{const{crop:i,disabled:e,onChange:s,onComplete:r}=this.props;if(e)return;const n=t.key;let o=!1;if(!i)return;const l=this.getBox(),a=this.makePixelCrop(l),u=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?ia.nudgeStepLarge:t.shiftKey?ia.nudgeStepMedium:ia.nudgeStep;if(n==="ArrowLeft"?(a.x-=u,o=!0):n==="ArrowRight"?(a.x+=u,o=!0):n==="ArrowUp"?(a.y-=u,o=!0):n==="ArrowDown"&&(a.y+=u,o=!0),o){t.cancelable&&t.preventDefault(),a.x=Kc(a.x,0,l.width-a.width),a.y=Kc(a.y,0,l.height-a.height);const c=Ds(a,l.width,l.height),f=Yc(a,l.width,l.height);s(c,f),r&&r(c,f)}},this.onHandlerKeyDown=(t,i)=>{const{aspect:e=0,crop:s,disabled:r,minWidth:n=0,minHeight:o=0,maxWidth:l,maxHeight:a,onChange:u,onComplete:c}=this.props,f=this.getBox();if(r||!s)return;if(t.key==="ArrowUp"||t.key==="ArrowDown"||t.key==="ArrowLeft"||t.key==="ArrowRight")t.stopPropagation(),t.preventDefault();else return;const d=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?ia.nudgeStepLarge:t.shiftKey?ia.nudgeStepMedium:ia.nudgeStep,h=Ds(s,f.width,f.height),m=LI(h,t.key,d,i),g=Yw(m,e,i,f.width,f.height,n,o,l,a);if(!Kw(s,g)){const _=Yc(g,f.width,f.height);u(g,_),c&&c(g,_)}},this.onDocPointerDone=t=>{const{crop:i,disabled:e,onComplete:s,onDragEnd:r}=this.props,n=this.getBox();this.unbindDocMove(),!(e||!i)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,r&&r(t),s&&s(Ds(i,n.width,n.height),Yc(i,n.width,n.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))},this.onDragFocus=()=>{var t;(t=this.componentRef.current)==null||t.scrollTo(0,0)}}get document(){return document}getBox(){const t=this.mediaRef.current;if(!t)return{x:0,y:0,width:0,height:0};const{x:i,y:e,width:s,height:r}=t.getBoundingClientRect();return{x:i,y:e,width:s,height:r}}componentDidUpdate(t){const{crop:i,onComplete:e}=this.props;if(e&&!t.crop&&i){const{width:s,height:r}=this.getBox();s&&r&&e(Ds(i,s,r),Yc(i,s,r))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,Zc),this.document.addEventListener("pointerup",this.onDocPointerDone,Zc),this.document.addEventListener("pointercancel",this.onDocPointerDone,Zc),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,Zc),this.document.removeEventListener("pointerup",this.onDocPointerDone,Zc),this.document.removeEventListener("pointercancel",this.onDocPointerDone,Zc),this.docMoveBound=!1)}getCropStyle(){const{crop:t}=this.props;if(t)return{top:`${t.y}${t.unit}`,left:`${t.x}${t.unit}`,width:`${t.width}${t.unit}`,height:`${t.height}${t.unit}`}}dragCrop(){const{evData:t}=this,i=this.getBox(),e=this.makePixelCrop(i),s=t.clientX-t.startClientX,r=t.clientY-t.startClientY;return e.x=Kc(t.startCropX+s,0,i.width-e.width),e.y=Kc(t.startCropY+r,0,i.height-e.height),e}getPointRegion(t,i,e,s){const{evData:r}=this,n=r.clientX-t.x,o=r.clientY-t.y;let l;s&&i?l=i==="nw"||i==="n"||i==="ne":l=o<r.startCropY;let a;return e&&i?a=i==="nw"||i==="w"||i==="sw":a=n<r.startCropX,a?l?"nw":"sw":l?"ne":"se"}resolveMinDimensions(t,i,e=0,s=0){const r=Math.min(e,t.width),n=Math.min(s,t.height);return!i||!r&&!n?[r,n]:i>1?r?[r,r/i]:[n*i,n]:n?[n*i,n]:[r,r/i]}resizeCrop(){const{evData:t}=this,{aspect:i=0,maxWidth:e,maxHeight:s}=this.props,r=this.getBox(),[n,o]=this.resolveMinDimensions(r,i,this.props.minWidth,this.props.minHeight);let l=this.makePixelCrop(r);const a=this.getPointRegion(r,t.ord,n,o),u=t.ord||a;let c=t.clientX-t.startClientX,f=t.clientY-t.startClientY;(n&&u==="nw"||u==="w"||u==="sw")&&(c=Math.min(c,-n)),(o&&u==="nw"||u==="n"||u==="ne")&&(f=Math.min(f,-o));const d={unit:"px",x:0,y:0,width:0,height:0};a==="ne"?(d.x=t.startCropX,d.width=c,i?(d.height=d.width/i,d.y=t.startCropY-d.height):(d.height=Math.abs(f),d.y=t.startCropY-d.height)):a==="se"?(d.x=t.startCropX,d.y=t.startCropY,d.width=c,i?d.height=d.width/i:d.height=f):a==="sw"?(d.x=t.startCropX+c,d.y=t.startCropY,d.width=Math.abs(c),i?d.height=d.width/i:d.height=f):a==="nw"&&(d.x=t.startCropX+c,d.width=Math.abs(c),i?(d.height=d.width/i,d.y=t.startCropY-d.height):(d.height=Math.abs(f),d.y=t.startCropY+f));const h=Yw(d,i,a,r.width,r.height,n,o,e,s);return i||ia.xyOrds.indexOf(u)>-1?l=h:ia.xOrds.indexOf(u)>-1?(l.x=h.x,l.width=h.width):ia.yOrds.indexOf(u)>-1&&(l.y=h.y,l.height=h.height),l.x=Kc(l.x,0,r.width-l.width),l.y=Kc(l.y,0,r.height-l.height),l}renderCropSelection(){const{ariaLabels:t=ia.defaultProps.ariaLabels,disabled:i,locked:e,renderSelectionAddon:s,ruleOfThirds:r,crop:n}=this.props,o=this.getCropStyle();if(n)return ve.createElement("div",{style:o,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":t.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!i&&!e&&ve.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},ve.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),ve.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),ve.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),ve.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),ve.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":t.nwDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"nw"),role:"button"}),ve.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":t.nDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"n"),role:"button"}),ve.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":t.neDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"ne"),role:"button"}),ve.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":t.eDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"e"),role:"button"}),ve.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":t.seDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"se"),role:"button"}),ve.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":t.sDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"s"),role:"button"}),ve.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":t.swDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"sw"),role:"button"}),ve.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":t.wDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"w"),role:"button"})),s&&ve.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:l=>l.stopPropagation()},s(this.state)),r&&ve.createElement(ve.Fragment,null,ve.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),ve.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(t){const i={...ih,...this.props.crop||{}};return Ds(i,t.width,t.height)}render(){const{aspect:t,children:i,circularCrop:e,className:s,crop:r,disabled:n,locked:o,style:l,ruleOfThirds:a}=this.props,{cropIsActive:u,newCropIsBeingDrawn:c}=this.state,f=r?this.renderCropSelection():null,d=DI("ReactCrop",s,u&&"ReactCrop--active",n&&"ReactCrop--disabled",o&&"ReactCrop--locked",c&&"ReactCrop--new-crop",r&&t&&"ReactCrop--fixed-aspect",r&&e&&"ReactCrop--circular-crop",r&&a&&"ReactCrop--rule-of-thirds",!this.dragStarted&&r&&!r.width&&!r.height&&"ReactCrop--invisible-crop",e&&"ReactCrop--no-animate");return ve.createElement("div",{ref:this.componentRef,className:d,style:l},ve.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},i),r?ve.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},ve.createElement("defs",null,ve.createElement("mask",{id:`hole-${this.instanceId}`},ve.createElement("rect",{width:"100%",height:"100%",fill:"white"}),e?ve.createElement("ellipse",{cx:`${r.x+r.width/2}${r.unit}`,cy:`${r.y+r.height/2}${r.unit}`,rx:`${r.width/2}${r.unit}`,ry:`${r.height/2}${r.unit}`,fill:"black"}):ve.createElement("rect",{x:`${r.x}${r.unit}`,y:`${r.y}${r.unit}`,width:`${r.width}${r.unit}`,height:`${r.height}${r.unit}`,fill:"black"}))),ve.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,f)}};Ls.xOrds=["e","w"],Ls.yOrds=["n","s"],Ls.xyOrds=["nw","ne","se","sw"],Ls.nudgeStep=1,Ls.nudgeStepMedium=10,Ls.nudgeStepLarge=100,Ls.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 BI=Ls;const PM="",Iy=Yo();function zI({altText:p,className:t,src:i,width:e,height:s,maxWidth:r,imageRef:n,startCrop:o,setStartCrop:l,isFocused:a,nodeKey:u}){const[c,f]=ve.useState(null),[d,h]=ve.useState(null),[m,g]=ve.useState({unit:"px",x:25,y:25,width:50,height:50}),[_]=Yn(),v=()=>{if(c){const y=n.current;if(!y||!c)return;const w=y.naturalWidth/y.width,C=y.naturalHeight/y.height,j=new OffscreenCanvas(c.width*w,c.height*C),P=j.getContext("2d");if(!P)throw new Error("No 2D context available");P.drawImage(y,c.x*w,c.y*C,c.width*w,c.height*C,0,0,c.width*w,c.height*C),j.convertToBlob({type:"image/png"}).then(F=>{const I=URL.createObjectURL(F);h(I),l(!1);const D=new FileReader;D.onload=()=>{const N=D.result;_.update(()=>{const k=Xn(u);sc(k)&&N&&k.setSrc(N)})},D.onerror=()=>{console.log("error")},D.readAsDataURL(F)})}},b=()=>{o||l(y=>{if(y===!1){const w=n.current;g({unit:"px",x:0,y:0,width:w.width,height:w.height})}return!y})},S=ve.useRef(null),E=ve.useRef(null);ve.useEffect(()=>{c&&(S.current=c)},[c]);const x=y=>{E.current&&!E.current.contains(y.target)&&l(!1)};return ve.useEffect(()=>(document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}),[]),_e.jsxs("div",{ref:E,children:[a&&_e.jsx("button",{style:{zIndex:999},className:"image-caption-button",onClick:()=>b(),children:"Crop"}),o&&_e.jsx("button",{style:{zIndex:999},className:"image-caption-button",onClick:()=>v(),children:"Apply Crop"}),o?_e.jsx(BI,{crop:m,onChange:y=>g(y),onComplete:y=>f(y),children:_e.jsx("img",{className:t||void 0,src:d||i,alt:p,ref:n,style:{height:s,maxWidth:r,width:e},draggable:"false"})}):_e.jsx("img",{className:t||void 0,src:d||i,alt:p,ref:n,style:{height:s,maxWidth:r,width:e},draggable:"false"})]})}function UI({src:p,altText:t,nodeKey:i,width:e,height:s,maxWidth:r,resizable:n,showCaption:o,caption:l}){const a=ve.useRef(null),u=ve.useRef(null),[c,f,d]=Ip(i),[h,m]=ve.useState(!1),[g]=Yn(),[_,v]=ve.useState(null),[b,S]=ve.useState(!1),E=ve.useRef(null),x=async A=>{const L=await(await fetch(A)).blob();return new Promise((J,O)=>{const z=new FileReader;z.readAsDataURL(L),z.onloadend=()=>{const W=z.result;J(W)},z.onerror=O})};ve.useEffect(()=>{/^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/i.test(p)&&x(p).then(R=>{g.update(()=>{const L=Xn(i);sc(L)&&R&&L.setSrc(R)})})},[p]);const y=ve.useCallback(A=>{if(c&&cr(Ot())){A.preventDefault();const L=Xn(i);if(sc(L))return L.remove(),!0}return!1},[c,i]),w=ve.useCallback(A=>{const R=Ot(),L=u.current;if(c&&cr(R)&&R.getNodes().length===1){if(o)return or(null),A.preventDefault(),l.focus(),!0;if(L!==null&&L!==document.activeElement)return A.preventDefault(),L.focus(),!0}return!1},[l,c,o]),C=ve.useCallback(A=>E.current===l||u.current===A.target?(or(null),g.update(()=>{f(!0);const R=g.getRootElement();R!==null&&R.focus()}),!0):!1,[l,g,f]),j=ve.useCallback(A=>{const R=A;return h?!0:R.target===a.current?(R.shiftKey?f(!c):(d(),f(!0)),!0):!1},[h,c,f,d]),P=ve.useCallback(A=>{g.getEditorState().read(()=>{const R=Ot();A.target.tagName==="IMG"&&Et(R)&&R.getNodes().length===1&&g.dispatchCommand(Iy,A)})},[g]);ve.useEffect(()=>{let A=!0;const R=g.getRootElement(),L=Mr(g.registerUpdateListener(({editorState:J})=>{A&&v(J.read(()=>Ot()))}),g.registerCommand(zo,(J,O)=>(E.current=O,!1),Ln),g.registerCommand(ls,j,Ln),g.registerCommand(Iy,j,Ln),g.registerCommand(il,J=>J.target===a.current?(J.preventDefault(),!0):!1,Ln),g.registerCommand(Ma,y,Ln),g.registerCommand(zi,y,Ln),g.registerCommand(aa,w,Ln),g.registerCommand(Ia,C,Ln));return R==null||R.addEventListener("contextmenu",P),()=>{A=!1,L(),R==null||R.removeEventListener("contextmenu",P)}},[d,g,h,c,i,y,w,C,j,P,f]);const F=()=>{g.update(()=>{const A=Xn(i);sc(A)&&A.setShowCaption(!0)})},I=(A,R)=>{setTimeout(()=>{m(!1)},200),g.update(()=>{const L=Xn(i);console.log(L,"node"),sc(L)&&L.setWidthAndHeight(A,R)})},D=()=>{b||m(!0)},N=c&&cr(_)&&!h,k=c||h;return _e.jsx(ve.Suspense,{fallback:null,children:_e.jsxs(_e.Fragment,{children:[_e.jsx("div",{draggable:N,children:_e.jsx(zI,{className:k?`focused ${cr(_)?"draggable":""}`:null,src:p,altText:t,width:e,height:s,maxWidth:r,imageRef:a,startCrop:b,setStartCrop:S,isFocused:k,nodeKey:i})}),o&&_e.jsx("div",{className:"image-caption-container",children:_e.jsx(Gw,{initialEditor:l,children:_e.jsx(up,{contentEditable:_e.jsx(ky,{className:"ImageNode__contentEditable"}),placeholder:_e.jsx(Ty,{className:"ImageNode__placeholder",children:"Enter a caption..."}),ErrorBoundary:mc})})}),!b&&n&&cr(_)&&k&&_e.jsx(RI,{showCaption:o,setShowCaption:F,editor:g,buttonRef:u,maxWidth:r,onResizeStart:b?()=>{}:D,onResizeEnd:b?()=>{}:I,captionsEnabled:!1,imageRef:a})]})})}const HI=Object.freeze(Object.defineProperty({__proto__:null,RIGHT_CLICK_IMAGE_COMMAND:Iy,default:UI},Symbol.toStringTag,{value:"Module"})),Zw=new Set;function $I(p){if(!Zw.has(p))throw new Promise(t=>{const i=new Image;i.src=p,i.onload=()=>{Zw.add(p),t(null)}})}function qI({altText:p,className:t,imageRef:i,src:e,width:s,height:r,position:n}){return $I(e),_e.jsx("img",{className:t||void 0,src:e,alt:p,ref:i,"data-position":n,style:{display:"block",height:r,width:s},draggable:"false"})}function Qw({activeEditor:p,nodeKey:t,onClose:i}){const s=p.getEditorState().read(()=>Xn(t)),[r,n]=ve.useState(s.getAltText()),[o,l]=ve.useState(s.getShowCaption()),[a,u]=ve.useState(s.getPosition()),c=h=>{l(h.target.checked)},f=h=>{u(h.target.value)},d=()=>{const h={altText:r,position:a,showCaption:o};s&&p.update(()=>{s.update(h)}),i()};return _e.jsxs(_e.Fragment,{children:[_e.jsx("div",{style:{marginBottom:"1em"},children:_e.jsx(n1,{label:"Alt Text",placeholder:"Descriptive alternative text",onChange:n,value:r,"data-test-id":"image-modal-alt-text-input"})}),_e.jsxs(D2,{style:{marginBottom:"1em",width:"208px"},value:a,label:"Position",name:"position",id:"position-select",onChange:f,children:[_e.jsx("option",{value:"left",children:"Left"}),_e.jsx("option",{value:"right",children:"Right"}),_e.jsx("option",{value:"full",children:"Full Width"})]}),_e.jsxs("div",{className:"Input__wrapper",children:[_e.jsx("input",{id:"caption",type:"checkbox",checked:o,onChange:c}),_e.jsx("label",{htmlFor:"caption",children:"Show Caption"})]}),_e.jsx(r1,{children:_e.jsx(fa,{"data-test-id":"image-modal-file-upload-btn",onClick:()=>d(),children:"Confirm"})})]})}function WI({src:p,altText:t,nodeKey:i,width:e,height:s,showCaption:r,caption:n,position:o}){const[l,a]=cp(),u=ve.useRef(null),c=ve.useRef(null),[f,d,h]=Ip(i),[m]=Yn(),[g,_]=ve.useState(null),v=ve.useRef(null),b=ve.useCallback(w=>{if(f&&cr(Ot())){w.preventDefault();const j=Xn(i);if(Bv(j))return j.remove(),!0}return!1},[f,i]),S=ve.useCallback(w=>{const C=Ot(),j=c.current;if(f&&cr(C)&&C.getNodes().length===1){if(r)return or(null),w.preventDefault(),n.focus(),!0;if(j!==null&&j!==document.activeElement)return w.preventDefault(),j.focus(),!0}return!1},[n,f,r]),E=ve.useCallback(w=>v.current===n||c.current===w.target?(or(null),m.update(()=>{d(!0);const C=m.getRootElement();C!==null&&C.focus()}),!0):!1,[n,m,d]);ve.useEffect(()=>{let w=!0;const C=Mr(m.registerUpdateListener(({editorState:j})=>{w&&_(j.read(()=>Ot()))}),m.registerCommand(zo,(j,P)=>(v.current=P,!1),Ln),m.registerCommand(ls,j=>{const P=j;return P.target===u.current?(P.shiftKey?d(!f):(h(),d(!0)),!0):!1},Ln),m.registerCommand(il,j=>j.target===u.current?(j.preventDefault(),!0):!1,Ln),m.registerCommand(Ma,b,Ln),m.registerCommand(zi,b,Ln),m.registerCommand(aa,S,Ln),m.registerCommand(Ia,E,Ln));return()=>{w=!1,C()}},[h,m,f,i,b,S,E,d]);const x=f&&cr(g),y=f;return _e.jsxs(ve.Suspense,{fallback:null,children:[_e.jsxs(_e.Fragment,{children:[_e.jsxs("div",{draggable:x,children:[_e.jsx("button",{className:"image-edit-button",ref:c,onClick:()=>{a("Update Inline Image",w=>_e.jsx(Qw,{activeEditor:m,nodeKey:i,onClose:w}))},children:"Edit"}),_e.jsx(qI,{className:y?`focused ${cr(g)?"draggable":""}`:null,src:p,altText:t,imageRef:u,width:e,height:s,position:o})]}),r&&_e.jsx("div",{className:"image-caption-container",children:_e.jsx(Gw,{initialEditor:n,children:_e.jsx(up,{contentEditable:_e.jsx(ky,{className:"InlineImageNode__contentEditable"}),placeholder:_e.jsx(Ty,{className:"InlineImageNode__placeholder",children:"Enter a caption..."}),ErrorBoundary:mc})})})]}),l]})}const VI=Object.freeze(Object.defineProperty({__proto__:null,UpdateInlineImageDialog:Qw,default:WI},Symbol.toStringTag,{value:"Module"}));Bo.Editor=jI,Bo.EditorVariant2=PI,Object.defineProperty(Bo,Symbol.toStringTag,{value:"Module"})});
|
|
1523
|
+
`&&t.isCollapsed()&&t.anchor.key===this.__key&&t.anchor.offset===s){e[s-1].remove(),e[s-2].remove();const l=lr();return this.insertAfter(l,i),l}const{anchor:r,focus:n}=t,o=(r.isBefore(n)?r:n).getNode();if(qt(o)){let l=vI(o);const a=[];for(;;)if(Pg(l))a.push(Xl()),l=l.getNextSibling();else{if(!Ny(l))break;{let g=0;const _=l.getTextContent(),v=l.getTextContentSize();for(;g<v&&_[g]===" ";)g++;if(g!==0&&a.push(Vw(" ".repeat(g))),g!==v)break;l=l.getNextSibling()}}const u=o.splitText(r.offset)[0],c=r.offset===0?0:1,f=u.getIndexWithinParent()+c,d=o.getParentOrThrow(),h=[ms(),...a];d.splice(f,0,h);const m=a[a.length-1];m?m.select():r.offset===0?u.selectPrevious():u.getNextSibling().selectNext(0,0)}if(mI(o)){const{offset:l}=t.anchor;o.splice(l,0,[ms()]),o.select(l+1,l+1)}return null}canIndent(){return!1}collapseAtStart(){const t=lr();return this.getChildren().forEach(i=>t.append(i)),this.replace(t),!0}setLanguage(t){const i=this.getWritable();i.__language=t,i.__isSyntaxHighlightSupported=Bw(t)}getLanguage(){return this.getLatest().__language}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}};function Od(p){return So(new Uw(p))}function mI(p){return p instanceof Uw}function Hw(p){return{node:Od(p.getAttribute(Td))}}function yI(p){const t=p,i=qw(t);return i||function(e){let s=e.parentElement;for(;s!==null;){if(qw(s))return!0;s=s.parentElement}return!1}(t)?{node:i?Od():null}:{node:null}}function bI(){return{node:Od()}}function $w(){return{node:null}}function qw(p){return p.style.fontFamily.match("monospace")!==null}function Ay(p){return p.classList.contains("js-file-line-container")}let Ww=class _E extends Wi{constructor(t,i,e){super(t,e),this.__highlightType=i}static getType(){return"code-highlight"}static clone(t){return new _E(t.__text,t.__highlightType||void 0,t.__key)}getHighlightType(){return this.getLatest().__highlightType}canHaveFormat(){return!1}createDOM(t){const i=super.createDOM(t),e=jy(t.theme,this.__highlightType);return hi(i,e),i}updateDOM(t,i,e){const s=super.updateDOM(t,i,e),r=jy(e.theme,t.__highlightType),n=jy(e.theme,this.__highlightType);return r!==n&&(r&&Vg(i,r),n&&hi(i,n)),s}static importJSON(t){const i=Vw(t.text,t.highlightType);return i.setFormat(t.format),i.setDetail(t.detail),i.setMode(t.mode),i.setStyle(t.style),i}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType(),type:"code-highlight",version:1}}setFormat(t){return this}isParentRequired(){return!0}createParentElementNode(){return Od()}};function jy(p,t){return t&&p&&p.codeHighlight&&p.codeHighlight[t]}function Vw(p,t){return So(new Ww(p,t))}function Ny(p){return p instanceof Ww}function vI(p){let t=p,i=p;for(;Ny(i)||Pg(i);)t=i,i=i.getPreviousSibling();return t}function _I(p,t){const i=p.getRangeAt(0);let e;if(p.anchorNode===t){let s=t;for(;s.firstElementChild!=null;)s=s.firstElementChild;e=s.getBoundingClientRect()}else e=i.getBoundingClientRect();return e}function xI(p){const t=p.anchor,i=p.focus,e=p.anchor.getNode(),s=p.focus.getNode();return e===s?e:p.isBackward()?yv(i)?e:s:yv(t)?e:s}const wI=10,SI=5;function EI(p,t,i,e=!1,s=wI,r=SI){const n=i.parentElement;if(p===null||!n){t.style.opacity="0",t.style.transform="translate(-10000px, -10000px)";return}const o=t.getBoundingClientRect(),l=i.getBoundingClientRect(),a=n.getBoundingClientRect();let u=p.top-o.height-s,c=p.left-r;u<a.top&&(u+=o.height+p.height+s*(e?9:2)),c+o.width>a.right&&(c=a.right-o.width-r),u-=l.top,c-=l.left,t.style.opacity="1",t.style.transform=`translate(${c}px, ${u}px)`}function CI({editor:p,anchorElem:t,isLink:i,isBold:e,isItalic:s,isUnderline:r,isCode:n,isStrikethrough:o,isSubscript:l,isSuperscript:a}){const u=ve.useRef(null);p.dispatchCommand(Vr,"bold"),ve.useCallback(()=>{i?p.dispatchCommand(G1,null):p.dispatchCommand(G1,"https://")},[p,i]);const c=()=>{p.dispatchCommand(Oy,void 0)};function f(m){if(u!=null&&u.current&&(m.buttons===1||m.buttons===3)&&u.current.style.pointerEvents!=="none"){const g=m.clientX,_=m.clientY,v=document.elementFromPoint(g,_);u.current.contains(v)||(u.current.style.pointerEvents="none")}}function d(m){u!=null&&u.current&&u.current.style.pointerEvents!=="auto"&&(u.current.style.pointerEvents="auto")}ve.useEffect(()=>{if(u!=null&&u.current)return document.addEventListener("mousemove",f),document.addEventListener("mouseup",d),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",d)}},[u]);const h=ve.useCallback(()=>{const m=Ot(),g=u.current,_=window.getSelection();if(g===null)return;const v=p.getRootElement();if(m!==null&&_!==null&&!_.isCollapsed&&v!==null&&v.contains(_.anchorNode)){const b=_I(_,v);EI(b,g,t,i)}},[p,t,i]);return ve.useEffect(()=>{const m=t.parentElement,g=()=>{p.getEditorState().read(()=>{h()})};return window.addEventListener("resize",g),m&&m.addEventListener("scroll",g),()=>{window.removeEventListener("resize",g),m&&m.removeEventListener("scroll",g)}},[p,h,t]),ve.useEffect(()=>(console.log("SELECTION_CHANGE_COMMAND for floating text format plugin"),p.getEditorState().read(()=>{h()}),Mr(p.registerUpdateListener(({editorState:m})=>{m.read(()=>{h()})}),p.registerCommand(zo,()=>(h(),!1),Ln))),[p,h]),console.log("Floatingtexttoolbarplugin"),_e.jsxs("div",{ref:u,className:"floating-text-format-popup",children:[p.isEditable()&&_e.jsxs(_e.Fragment,{children:[_e.jsx("button",{type:"button",onClick:()=>{p.dispatchCommand(Vr,"bold")},className:"popup-item spaced "+(e?"active":""),"aria-label":"Format text as bold",children:_e.jsx("i",{className:"format bold"})}),_e.jsx("button",{type:"button",onClick:()=>{p.dispatchCommand(Vr,"italic")},className:"popup-item spaced "+(s?"active":""),"aria-label":"Format text as italics",children:_e.jsx("i",{className:"format italic"})}),_e.jsx("button",{type:"button",onClick:()=>{p.dispatchCommand(Vr,"underline")},className:"popup-item spaced "+(r?"active":""),"aria-label":"Format text to underlined",children:_e.jsx("i",{className:"format underline"})}),_e.jsx("button",{type:"button",onClick:()=>{p.dispatchCommand(Vr,"strikethrough")},className:"popup-item spaced "+(o?"active":""),"aria-label":"Format text with a strikethrough",children:_e.jsx("i",{className:"format strikethrough"})}),_e.jsx("button",{type:"button",onClick:()=>{p.dispatchCommand(Vr,"subscript")},className:"popup-item spaced "+(l?"active":""),title:"Subscript","aria-label":"Format Subscript",children:_e.jsx("i",{className:"format subscript"})}),_e.jsx("button",{type:"button",onClick:()=>{p.dispatchCommand(Vr,"superscript")},className:"popup-item spaced "+(a?"active":""),title:"Superscript","aria-label":"Format Superscript",children:_e.jsx("i",{className:"format superscript"})})]}),_e.jsx("button",{type:"button",onClick:c,className:"popup-item spaced insert-comment","aria-label":"Insert comment",children:_e.jsx("i",{className:"format add-comment"})})]})}function kI(p,t){const[i,e]=ve.useState(!1),[s,r]=ve.useState(!1),[n,o]=ve.useState(!0),[l,a]=ve.useState(!1),[u,c]=ve.useState(!1),[f,d]=ve.useState(!1),[h,m]=ve.useState(!1),[g,_]=ve.useState(!1),[v,b]=ve.useState(!1),S=ve.useCallback(()=>{p.getEditorState().read(()=>{if(p.isComposing())return;const E=Ot(),x=window.getSelection(),y=p.getRootElement();if(x!==null&&(!Et(E)||y===null||!y.contains(x.anchorNode))){e(!1);return}if(!Et(E))return;const w=xI(E);o(E.hasFormat("bold")),a(E.hasFormat("italic")),c(E.hasFormat("underline")),d(E.hasFormat("strikethrough")),m(E.hasFormat("subscript")),_(E.hasFormat("superscript")),b(E.hasFormat("code"));const C=w.getParent();km(C)||km(w)?r(!0):r(!1),!Ny(E.anchor.getNode())&&E.getTextContent()!==""?e(qt(w)||ca(w)):e(!1);const j=E.getTextContent().replace(/\n/g,"");if(!E.isCollapsed()&&j===""){e(!1);return}})},[p]);return ve.useEffect(()=>(document.addEventListener("selectionchange",S),()=>{document.removeEventListener("selectionchange",S)}),[S]),ve.useEffect(()=>Mr(p.registerUpdateListener(()=>{S()}),p.registerRootListener(()=>{p.getRootElement()===null&&e(!1)})),[p,S]),i?ro.createPortal(_e.jsx(CI,{editor:p,anchorElem:t,isLink:s,isBold:n,isItalic:l,isStrikethrough:f,isSubscript:h,isSuperscript:g,isUnderline:u,isCode:v}),t):null}function TI({anchorElem:p=document.body}){const[t]=Yn();return kI(t,p)}const OI=({onChange:p})=>{const[t]=Yn(),[i,e]=ve.useState(!0),s=ve.useRef(""),r=s.current,n=ve.useCallback(()=>{t.update(()=>{const o=zv(t);i?e(!1):o!==r&&(p(o),s.current=o)})},[t,i,p,r]);return ve.useEffect(()=>{const o=t.registerUpdateListener(n);return()=>o()},[t,n]),null},AI=cx([...[Ji,Gu,Vi,Yf,Qf,ep,xl,yd]]);function jI({collabApiKey:p,userObj:t,styleConfig:i,docId:e,onlUser:s,setonlUser:r,savedSpfEditorState:n,setSavedEditorState:o,setSavedEditorState2:l,mentionItems:a,showtoolbar:u=!0,customHeight:c,customWidth:f,disabled:d,editorId:h,onPaste:m,source:g}){const _=ve.useRef(null),{pageMarginTop:v,pageMarginLeft:b,pageMarginBottom:S,pageMarginRight:E,heading:x}=i||{};ve.useState("");const[y,w]=ve.useState(!0),C=ve.useRef(null),[j,P]=ve.useState(!1),[F,I]=ve.useState([]),D=ve.useRef(),[N,k]=ve.useState({root:null}),[A,R]=ve.useState(0);let L={namespace:`editor_${h}`,nodes:[...AI],onError(K){throw K},theme:Ug,editorState:K=>{K.update(()=>{if(n&&y){const Z=new DOMParser().parseFromString(n,"text/html"),X=tm(K,Z);X.forEach(ee=>{ee instanceof Vi&&ee.setStyle("font-weight: normal")}),yr(),tc(X),w(!1)}})}};ve.useEffect(()=>{setTimeout(()=>{fc(".custom-margin").css({paddingTop:`${v||"16px"}`,paddingRight:`${E||"16px"}`,paddingLeft:`${b||"16px"}`,paddingBottom:`${S||"16px"}`}),fc(".editor-inner").css({maxHeight:c?`${c}px`:"100%",overflow:"scroll",height:c?`${c}px`:"100%",minHeight:"200px",maxWidth:f?`${f}px`:"100%"}),fc(`.${h}`).attr("contentEditable",!d)},500)},[]);const{userName:J,userId:O,userEmail:z}=t,G={docId:h,apiKey:p,user:{name:J,id:O,email:z},showCursor:!1,cursorAlwaysOn:!1,showPointer:!1,hooks:{contentChanged:({source:K,content:Y})=>{},usersUpdate:K=>{I(K),renderOnlineUsers(K)}}},B=()=>{D.current&&D.current.start(G).then(()=>{console.log("[Lexical Demo][codox.start] success"),P(!0)}).catch(K=>console.log("[Lexical Demo][codox.start] error",K))};ve.useEffect(()=>()=>{$()},[]);const $=()=>{D.current&&D.current.stop(),P(!1)};ve.useEffect(()=>{N&&e&&!j&&B()},[N,e,j]),ve.useEffect(()=>{let K=[],Y=[];F&&F.length>0&&F.map((Z,X)=>{Y.includes(Z.name)||(Y.push(Z.name),K.push(_e.jsxs("div",{title:Z.email,className:`avatarStyle avatar-color-${X+1}`,children:[" ",Z.name&&Z.name[0],Z.name&&Z.name[4]]},X)))}),r(K)},[F]),ve.useEffect(()=>{(async K=>{const Y=!!p,Z=!!t,X=!!i;A>1&&A<200&&R(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.")})()},[p,t,i]);const q=ve.useCallback(K=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{o(K)},500)},[h,o,l]),H=ve.useCallback(K=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{l(K)},500)},[h,o,l]);return _e.jsxs("div",{ref:_,children:[_e.jsx(R2,{children:_e.jsxs(zf,{initialConfig:L,children:[_e.jsx(lx,{ref:D}),_e.jsxs("div",{className:"editor-container",children:[u&&_e.jsx("div",{style:{pointerEvents:d?"none":"all"},children:_e.jsx(MT,{styleConfig:i,onlUser:s,stopCodox:$,startCodox:B,source:g,onPaste:m})}),_e.jsxs("div",{className:"editor-inner",children:[_e.jsx(up,{contentEditable:_e.jsx("div",{className:"custom-margin",children:_e.jsx(fp,{className:`editor-input ${h}`,contentEditable:!1})}),placeholder:null,ErrorBoundary:mc}),_e.jsx(dp,{})]})]}),_e.jsx(_2,{}),_e.jsx($T,{}),_e.jsx(T2,{}),_e.jsx(F2,{}),_e.jsx(gp,{}),_e.jsx(uP,{items:a,menuComponent:dP,menuItemComponent:fP}),_e.jsx(OI,{onChange:h.includes("objective")?q:H}),_e.jsx(pI,{}),_e.jsx(TI,{})]})}),_e.jsx(Fk,{styleConfig:i})]})}const NI=cx([...[]]);function PI({collabApiKey:p,userObj:t,docId:i,setonlUser:e,savedSpfEditorState:s,setSavedEditorState:r,customHeight:n,customWidth:o,editorId:l}){const a=ve.useRef(null),[u,c]=ve.useState(!0),[f,d]=ve.useState(!1),[h,m]=ve.useState([]),g=ve.useRef(),[_,v]=ve.useState({root:null});ve.useState(0);const b=ve.useRef(""),S={namespace:`editor_${l}`,nodes:[...NI],onError(F){throw F},theme:Ug,editorState:F=>{F.update(()=>{if(s&&u){const D=new DOMParser().parseFromString(s,"text/html"),N=tm(F,D);yr(),tc(N),c(!1)}})}};ve.useEffect(()=>{setTimeout(()=>{fc(".custom-margin-2").css({height:`${n}px`}),fc(".editor-inner-2").css({background:"#fff",position:"relative",top:"20px",padding:"20px",borderRadius:"0 0 10px 10px",maxHeight:`${n}px`,overflow:"scroll",height:`${n}px`,minHeight:"200px",maxWidth:o?`${o}px`:"100%"})},500)},[]);const{userName:E,userId:x,userEmail:y}=t,C={docId:l,apiKey:p,user:{name:E,id:x,email:y},showCursor:!1,cursorAlwaysOn:!1,showPointer:!1,hooks:{contentChanged:({source:F,content:I})=>{},usersUpdate:F=>{m(F),renderOnlineUsers(F)}}},j=()=>{g.current&&g.current.start(C).then(()=>{console.log("[Lexical Demo][codox.start] success"),d(!0)}).catch(F=>console.log("[Lexical Demo][codox.start] error",F))};ve.useEffect(()=>{_&&i&&!f&&j()},[_,i,f]),ve.useEffect(()=>{let F=[],I=[];h&&h.length>0&&h.map((D,N)=>{I.includes(D.name)||(I.push(D.name),F.push(_e.jsxs("div",{title:D.email,className:`avatarStyle avatar-color-${N+1}`,children:[" ",D.name&&D.name[0],D.name&&D.name[4]]},N)))}),e(F)},[h]);const P=()=>{let F=fc(".editor-input-2").html();F!==b.current&&(console.log("Editor Variant 2 HTML",F),r(F),b.current=F)};return _e.jsx("div",{ref:a,children:_e.jsxs(zf,{initialConfig:S,children:[_e.jsx(lx,{ref:g}),_e.jsx("div",{className:"editor-container",children:_e.jsxs("div",{className:"editor-inner-2",children:[_e.jsx(up,{contentEditable:_e.jsx("div",{className:"custom-margin-2",children:_e.jsx(fp,{className:"editor-input-2 inpt-2"})}),placeholder:null,ErrorBoundary:mc}),_e.jsx(Am,{onChange:P}),_e.jsx(dp,{})]})}),_e.jsx(gp,{})]})})}const NM="";function II(p){return p&&p.__esModule&&Object.prototype.hasOwnProperty.call(p,"default")?p.default:p}var MI=II(function(p){const t=new URLSearchParams;t.append("code",p);for(let i=1;i<arguments.length;i++)t.append("v",arguments[i]);throw Error(`Minified Lexical error #${p}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Jw(p){const t=p.transform();return t!==null?new Set([t]):new Set}function Gw({initialEditor:p,children:t,initialNodes:i,initialTheme:e,skipCollabChecks:s}){const r=ve.useRef(!1),n=ve.useContext(wu);n==null&&MI(9);const[o,{getTheme:l}]=n,a=ve.useMemo(()=>{const d=e||l()||void 0,h=L0(n,d);if(d!==void 0&&(p._config.theme=d),p._parentEditor=o,i)for(let m of i){let g=null,_=null;if(typeof m!="function"){const b=m;m=b.replace,g=b.with,_=b.withKlass||null}const v=p._nodes.get(m.getType());p._nodes.set(m.getType(),{exportDOM:v?v.exportDOM:void 0,klass:m,replace:g,replaceWithKlass:_,transforms:Jw(m)})}else{const m=p._nodes=new Map(o._nodes);for(const[g,_]of m)p._nodes.set(g,{exportDOM:_.exportDOM,klass:_.klass,replace:_.replace,replaceWithKlass:_.replaceWithKlass,transforms:Jw(_.klass)})}return p._config.namespace=o._config.namespace,p._editable=o._editable,[p,h]},[]),{isCollabActive:u,yjsDocMap:c}=pp(),f=s||r.current||c.has(p.getKey());return ve.useEffect(()=>{f&&(r.current=!0)},[f]),ve.useEffect(()=>o.registerEditableListener(d=>{p.setEditable(d)}),[p,o]),_e.jsx(wu.Provider,{value:a,children:!u||f?t:null})}function Py(p,t,i){return Math.min(Math.max(p,t),i)}const Or={east:1,north:8,south:2,west:4};function RI({onResizeStart:p,onResizeEnd:t,buttonRef:i,imageRef:e,maxWidth:s,editor:r,showCaption:n,setShowCaption:o,captionsEnabled:l}){const a=ve.useRef(null),u=ve.useRef({priority:"",value:"default"}),c=ve.useRef({currentHeight:0,currentWidth:0,direction:0,isResizing:!1,ratio:0,startHeight:0,startWidth:0,startX:0,startY:0}),f=r.getRootElement(),d=f!==null?f.getBoundingClientRect().width-20:100,h=f!==null?f.getBoundingClientRect().height-20:100,m=100,g=100,_=x=>{const y=x===Or.east||x===Or.west,w=x===Or.north||x===Or.south,C=x&Or.north&&x&Or.west||x&Or.south&&x&Or.east,j=y?"ew":w?"ns":C?"nwse":"nesw";f!==null&&f.style.setProperty("cursor",`${j}-resize`,"important"),document.body!==null&&(document.body.style.setProperty("cursor",`${j}-resize`,"important"),u.current.value=document.body.style.getPropertyValue("-webkit-user-select"),u.current.priority=document.body.style.getPropertyPriority("-webkit-user-select"),document.body.style.setProperty("-webkit-user-select","none","important"))},v=()=>{f!==null&&f.style.setProperty("cursor","text"),document.body!==null&&(document.body.style.setProperty("cursor","default"),document.body.style.setProperty("-webkit-user-select",u.current.value,u.current.priority))},b=(x,y)=>{if(!r.isEditable())return;const w=e.current,C=a.current;if(w!==null&&C!==null){x.preventDefault();const{width:j,height:P}=w.getBoundingClientRect(),F=c.current;F.startWidth=j,F.startHeight=P,F.ratio=j/P,F.currentWidth=j,F.currentHeight=P,F.startX=x.clientX,F.startY=x.clientY,F.isResizing=!0,F.direction=y,_(y),p(),C.classList.add("image-control-wrapper--resizing"),w.style.height=`${P}px`,w.style.width=`${j}px`,document.addEventListener("pointermove",S),document.addEventListener("pointerup",E)}},S=x=>{const y=e.current,w=c.current,C=w.direction&(Or.east|Or.west),j=w.direction&(Or.south|Or.north);if(y!==null&&w.isResizing){if(C&&j){let P=Math.floor(w.startX-x.clientX);P=w.direction&Or.east?-P:P;const F=Py(w.startWidth+P,m,d),I=F/w.ratio;y.style.width=`${F}px`,y.style.height=`${I}px`,w.currentHeight=I,w.currentWidth=F}else if(j){let P=Math.floor(w.startY-x.clientY);P=w.direction&Or.south?-P:P;const F=Py(w.startHeight+P,g,h);y.style.height=`${F}px`,y.style.maxHeight=`${F}px`,w.currentHeight=F}else{let P=Math.floor(w.startX-x.clientX);P=w.direction&Or.east?-P:P;const F=Py(w.startWidth+P,m,d);y.style.width=`${F}px`,y.style.maxWidth=`${F}px`,w.currentWidth=F}y&&(y.setAttribute("width",`${w.currentWidth}`),y.setAttribute("height",`${w.currentHeight}`))}},E=()=>{const x=e.current,y=c.current,w=a.current;if(x!==null&&w!==null&&y.isResizing){const C=y.currentWidth,j=y.currentHeight;y.startWidth=0,y.startHeight=0,y.ratio=0,y.startX=0,y.startY=0,y.currentWidth=0,y.currentHeight=0,y.isResizing=!1,w.classList.remove("image-control-wrapper--resizing"),v(),t(C,j),document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",E)}};return _e.jsxs("div",{ref:a,children:[_e.jsx("div",{className:"image-resizer image-resizer-n",onPointerDown:x=>{b(x,Or.north)}}),_e.jsx("div",{className:"image-resizer image-resizer-ne",onPointerDown:x=>{b(x,Or.north|Or.east)}}),_e.jsx("div",{className:"image-resizer image-resizer-e",onPointerDown:x=>{b(x,Or.east)}}),_e.jsx("div",{className:"image-resizer image-resizer-se",onPointerDown:x=>{b(x,Or.south|Or.east)}}),_e.jsx("div",{className:"image-resizer image-resizer-s",onPointerDown:x=>{b(x,Or.south)}}),_e.jsx("div",{className:"image-resizer image-resizer-sw",onPointerDown:x=>{b(x,Or.south|Or.west)}}),_e.jsx("div",{className:"image-resizer image-resizer-w",onPointerDown:x=>{b(x,Or.west)}}),_e.jsx("div",{className:"image-resizer image-resizer-nw",onPointerDown:x=>{b(x,Or.north|Or.west)}})]})}const ih={x:0,y:0,width:0,height:0,unit:"px"},Kc=(p,t,i)=>Math.min(Math.max(p,t),i),DI=(...p)=>p.filter(t=>t&&typeof t=="string").join(" "),Kw=(p,t)=>p===t||p.width===t.width&&p.height===t.height&&p.x===t.x&&p.y===t.y&&p.unit===t.unit;function Yc(p,t,i){return p.unit==="%"?{...ih,...p,unit:"%"}:{unit:"%",x:p.x?p.x/t*100:0,y:p.y?p.y/i*100:0,width:p.width?p.width/t*100:0,height:p.height?p.height/i*100:0}}function Ds(p,t,i){return p.unit?p.unit==="px"?{...ih,...p,unit:"px"}:{unit:"px",x:p.x?p.x*t/100:0,y:p.y?p.y*i/100:0,width:p.width?p.width*t/100:0,height:p.height?p.height*i/100:0}:{...ih,...p,unit:"px"}}function Yw(p,t,i,e,s,r=0,n=0,o=e,l=s){const a={...p};let u=Math.min(r,e),c=Math.min(n,s),f=Math.min(o,e),d=Math.min(l,s);t&&(t>1?(u=n?n*t:u,c=u/t,f=o*t):(c=r?r/t:c,u=c*t,d=l/t)),a.y<0&&(a.height=Math.max(a.height+a.y,c),a.y=0),a.x<0&&(a.width=Math.max(a.width+a.x,u),a.x=0);const h=e-(a.x+a.width);h<0&&(a.x=Math.min(a.x,e-u),a.width+=h);const m=s-(a.y+a.height);if(m<0&&(a.y=Math.min(a.y,s-c),a.height+=m),a.width<u&&((i==="sw"||i=="nw")&&(a.x-=u-a.width),a.width=u),a.height<c&&((i==="nw"||i=="ne")&&(a.y-=c-a.height),a.height=c),a.width>f&&((i==="sw"||i=="nw")&&(a.x-=f-a.width),a.width=f),a.height>d&&((i==="nw"||i=="ne")&&(a.y-=d-a.height),a.height=d),t){const g=a.width/a.height;if(g<t){const _=Math.max(a.width/t,c);(i==="nw"||i=="ne")&&(a.y-=_-a.height),a.height=_}else if(g>t){const _=Math.max(a.height*t,u);(i==="sw"||i=="nw")&&(a.x-=_-a.width),a.width=_}}return a}function LI(p,t,i,e){const s={...p};return t==="ArrowLeft"?e==="nw"?(s.x-=i,s.y-=i,s.width+=i,s.height+=i):e==="w"?(s.x-=i,s.width+=i):e==="sw"?(s.x-=i,s.width+=i,s.height+=i):e==="ne"?(s.y+=i,s.width-=i,s.height-=i):e==="e"?s.width-=i:e==="se"&&(s.width-=i,s.height-=i):t==="ArrowRight"&&(e==="nw"?(s.x+=i,s.y+=i,s.width-=i,s.height-=i):e==="w"?(s.x+=i,s.width-=i):e==="sw"?(s.x+=i,s.width-=i,s.height-=i):e==="ne"?(s.y-=i,s.width+=i,s.height+=i):e==="e"?s.width+=i:e==="se"&&(s.width+=i,s.height+=i)),t==="ArrowUp"?e==="nw"?(s.x-=i,s.y-=i,s.width+=i,s.height+=i):e==="n"?(s.y-=i,s.height+=i):e==="ne"?(s.y-=i,s.width+=i,s.height+=i):e==="sw"?(s.x+=i,s.width-=i,s.height-=i):e==="s"?s.height-=i:e==="se"&&(s.width-=i,s.height-=i):t==="ArrowDown"&&(e==="nw"?(s.x+=i,s.y+=i,s.width-=i,s.height-=i):e==="n"?(s.y+=i,s.height-=i):e==="ne"?(s.y+=i,s.width-=i,s.height-=i):e==="sw"?(s.x-=i,s.width+=i,s.height+=i):e==="s"?s.height+=i:e==="se"&&(s.width+=i,s.height+=i)),s}const Zc={capture:!0,passive:!1};let FI=0;const Ls=class ia extends ve.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=ve.createRef(),this.mediaRef=ve.createRef(),this.initChangeCalled=!1,this.instanceId=`rc-${FI++}`,this.state={cropIsActive:!1,newCropIsBeingDrawn:!1},this.onCropPointerDown=t=>{const{crop:i,disabled:e}=this.props,s=this.getBox();if(!i)return;const r=Ds(i,s.width,s.height);if(e)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const n=t.target.dataset.ord,o=!!n;let l=t.clientX,a=t.clientY,u=r.x,c=r.y;if(n){const f=t.clientX-s.x,d=t.clientY-s.y;let h=0,m=0;n==="ne"||n=="e"?(h=f-(r.x+r.width),m=d-r.y,u=r.x,c=r.y+r.height):n==="se"||n==="s"?(h=f-(r.x+r.width),m=d-(r.y+r.height),u=r.x,c=r.y):n==="sw"||n=="w"?(h=f-r.x,m=d-(r.y+r.height),u=r.x+r.width,c=r.y):(n==="nw"||n=="n")&&(h=f-r.x,m=d-r.y,u=r.x+r.width,c=r.y+r.height),l=u+s.x+h,a=c+s.y+m}this.evData={startClientX:l,startClientY:a,startCropX:u,startCropY:c,clientX:t.clientX,clientY:t.clientY,isResize:o,ord:n},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})},this.onComponentPointerDown=t=>{const{crop:i,disabled:e,locked:s,keepSelection:r,onChange:n}=this.props,o=this.getBox();if(e||s||r&&i)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const l=t.clientX-o.x,a=t.clientY-o.y,u={unit:"px",x:l,y:a,width:0,height:0};this.evData={startClientX:t.clientX,startClientY:t.clientY,startCropX:l,startCropY:a,clientX:t.clientX,clientY:t.clientY,isResize:!0},this.mouseDownOnCrop=!0,n(Ds(u,o.width,o.height),Yc(u,o.width,o.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})},this.onDocPointerMove=t=>{const{crop:i,disabled:e,onChange:s,onDragStart:r}=this.props,n=this.getBox();if(e||!i||!this.mouseDownOnCrop)return;t.cancelable&&t.preventDefault(),this.dragStarted||(this.dragStarted=!0,r&&r(t));const{evData:o}=this;o.clientX=t.clientX,o.clientY=t.clientY;let l;o.isResize?l=this.resizeCrop():l=this.dragCrop(),Kw(i,l)||s(Ds(l,n.width,n.height),Yc(l,n.width,n.height))},this.onComponentKeyDown=t=>{const{crop:i,disabled:e,onChange:s,onComplete:r}=this.props;if(e)return;const n=t.key;let o=!1;if(!i)return;const l=this.getBox(),a=this.makePixelCrop(l),u=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?ia.nudgeStepLarge:t.shiftKey?ia.nudgeStepMedium:ia.nudgeStep;if(n==="ArrowLeft"?(a.x-=u,o=!0):n==="ArrowRight"?(a.x+=u,o=!0):n==="ArrowUp"?(a.y-=u,o=!0):n==="ArrowDown"&&(a.y+=u,o=!0),o){t.cancelable&&t.preventDefault(),a.x=Kc(a.x,0,l.width-a.width),a.y=Kc(a.y,0,l.height-a.height);const c=Ds(a,l.width,l.height),f=Yc(a,l.width,l.height);s(c,f),r&&r(c,f)}},this.onHandlerKeyDown=(t,i)=>{const{aspect:e=0,crop:s,disabled:r,minWidth:n=0,minHeight:o=0,maxWidth:l,maxHeight:a,onChange:u,onComplete:c}=this.props,f=this.getBox();if(r||!s)return;if(t.key==="ArrowUp"||t.key==="ArrowDown"||t.key==="ArrowLeft"||t.key==="ArrowRight")t.stopPropagation(),t.preventDefault();else return;const d=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?ia.nudgeStepLarge:t.shiftKey?ia.nudgeStepMedium:ia.nudgeStep,h=Ds(s,f.width,f.height),m=LI(h,t.key,d,i),g=Yw(m,e,i,f.width,f.height,n,o,l,a);if(!Kw(s,g)){const _=Yc(g,f.width,f.height);u(g,_),c&&c(g,_)}},this.onDocPointerDone=t=>{const{crop:i,disabled:e,onComplete:s,onDragEnd:r}=this.props,n=this.getBox();this.unbindDocMove(),!(e||!i)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,r&&r(t),s&&s(Ds(i,n.width,n.height),Yc(i,n.width,n.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))},this.onDragFocus=()=>{var t;(t=this.componentRef.current)==null||t.scrollTo(0,0)}}get document(){return document}getBox(){const t=this.mediaRef.current;if(!t)return{x:0,y:0,width:0,height:0};const{x:i,y:e,width:s,height:r}=t.getBoundingClientRect();return{x:i,y:e,width:s,height:r}}componentDidUpdate(t){const{crop:i,onComplete:e}=this.props;if(e&&!t.crop&&i){const{width:s,height:r}=this.getBox();s&&r&&e(Ds(i,s,r),Yc(i,s,r))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,Zc),this.document.addEventListener("pointerup",this.onDocPointerDone,Zc),this.document.addEventListener("pointercancel",this.onDocPointerDone,Zc),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,Zc),this.document.removeEventListener("pointerup",this.onDocPointerDone,Zc),this.document.removeEventListener("pointercancel",this.onDocPointerDone,Zc),this.docMoveBound=!1)}getCropStyle(){const{crop:t}=this.props;if(t)return{top:`${t.y}${t.unit}`,left:`${t.x}${t.unit}`,width:`${t.width}${t.unit}`,height:`${t.height}${t.unit}`}}dragCrop(){const{evData:t}=this,i=this.getBox(),e=this.makePixelCrop(i),s=t.clientX-t.startClientX,r=t.clientY-t.startClientY;return e.x=Kc(t.startCropX+s,0,i.width-e.width),e.y=Kc(t.startCropY+r,0,i.height-e.height),e}getPointRegion(t,i,e,s){const{evData:r}=this,n=r.clientX-t.x,o=r.clientY-t.y;let l;s&&i?l=i==="nw"||i==="n"||i==="ne":l=o<r.startCropY;let a;return e&&i?a=i==="nw"||i==="w"||i==="sw":a=n<r.startCropX,a?l?"nw":"sw":l?"ne":"se"}resolveMinDimensions(t,i,e=0,s=0){const r=Math.min(e,t.width),n=Math.min(s,t.height);return!i||!r&&!n?[r,n]:i>1?r?[r,r/i]:[n*i,n]:n?[n*i,n]:[r,r/i]}resizeCrop(){const{evData:t}=this,{aspect:i=0,maxWidth:e,maxHeight:s}=this.props,r=this.getBox(),[n,o]=this.resolveMinDimensions(r,i,this.props.minWidth,this.props.minHeight);let l=this.makePixelCrop(r);const a=this.getPointRegion(r,t.ord,n,o),u=t.ord||a;let c=t.clientX-t.startClientX,f=t.clientY-t.startClientY;(n&&u==="nw"||u==="w"||u==="sw")&&(c=Math.min(c,-n)),(o&&u==="nw"||u==="n"||u==="ne")&&(f=Math.min(f,-o));const d={unit:"px",x:0,y:0,width:0,height:0};a==="ne"?(d.x=t.startCropX,d.width=c,i?(d.height=d.width/i,d.y=t.startCropY-d.height):(d.height=Math.abs(f),d.y=t.startCropY-d.height)):a==="se"?(d.x=t.startCropX,d.y=t.startCropY,d.width=c,i?d.height=d.width/i:d.height=f):a==="sw"?(d.x=t.startCropX+c,d.y=t.startCropY,d.width=Math.abs(c),i?d.height=d.width/i:d.height=f):a==="nw"&&(d.x=t.startCropX+c,d.width=Math.abs(c),i?(d.height=d.width/i,d.y=t.startCropY-d.height):(d.height=Math.abs(f),d.y=t.startCropY+f));const h=Yw(d,i,a,r.width,r.height,n,o,e,s);return i||ia.xyOrds.indexOf(u)>-1?l=h:ia.xOrds.indexOf(u)>-1?(l.x=h.x,l.width=h.width):ia.yOrds.indexOf(u)>-1&&(l.y=h.y,l.height=h.height),l.x=Kc(l.x,0,r.width-l.width),l.y=Kc(l.y,0,r.height-l.height),l}renderCropSelection(){const{ariaLabels:t=ia.defaultProps.ariaLabels,disabled:i,locked:e,renderSelectionAddon:s,ruleOfThirds:r,crop:n}=this.props,o=this.getCropStyle();if(n)return ve.createElement("div",{style:o,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":t.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!i&&!e&&ve.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},ve.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),ve.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),ve.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),ve.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),ve.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":t.nwDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"nw"),role:"button"}),ve.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":t.nDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"n"),role:"button"}),ve.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":t.neDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"ne"),role:"button"}),ve.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":t.eDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"e"),role:"button"}),ve.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":t.seDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"se"),role:"button"}),ve.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":t.sDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"s"),role:"button"}),ve.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":t.swDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"sw"),role:"button"}),ve.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":t.wDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"w"),role:"button"})),s&&ve.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:l=>l.stopPropagation()},s(this.state)),r&&ve.createElement(ve.Fragment,null,ve.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),ve.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(t){const i={...ih,...this.props.crop||{}};return Ds(i,t.width,t.height)}render(){const{aspect:t,children:i,circularCrop:e,className:s,crop:r,disabled:n,locked:o,style:l,ruleOfThirds:a}=this.props,{cropIsActive:u,newCropIsBeingDrawn:c}=this.state,f=r?this.renderCropSelection():null,d=DI("ReactCrop",s,u&&"ReactCrop--active",n&&"ReactCrop--disabled",o&&"ReactCrop--locked",c&&"ReactCrop--new-crop",r&&t&&"ReactCrop--fixed-aspect",r&&e&&"ReactCrop--circular-crop",r&&a&&"ReactCrop--rule-of-thirds",!this.dragStarted&&r&&!r.width&&!r.height&&"ReactCrop--invisible-crop",e&&"ReactCrop--no-animate");return ve.createElement("div",{ref:this.componentRef,className:d,style:l},ve.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},i),r?ve.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},ve.createElement("defs",null,ve.createElement("mask",{id:`hole-${this.instanceId}`},ve.createElement("rect",{width:"100%",height:"100%",fill:"white"}),e?ve.createElement("ellipse",{cx:`${r.x+r.width/2}${r.unit}`,cy:`${r.y+r.height/2}${r.unit}`,rx:`${r.width/2}${r.unit}`,ry:`${r.height/2}${r.unit}`,fill:"black"}):ve.createElement("rect",{x:`${r.x}${r.unit}`,y:`${r.y}${r.unit}`,width:`${r.width}${r.unit}`,height:`${r.height}${r.unit}`,fill:"black"}))),ve.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,f)}};Ls.xOrds=["e","w"],Ls.yOrds=["n","s"],Ls.xyOrds=["nw","ne","se","sw"],Ls.nudgeStep=1,Ls.nudgeStepMedium=10,Ls.nudgeStepLarge=100,Ls.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 BI=Ls;const PM="",Iy=Yo();function zI({altText:p,className:t,src:i,width:e,height:s,maxWidth:r,imageRef:n,startCrop:o,setStartCrop:l,isFocused:a,nodeKey:u}){const[c,f]=ve.useState(null),[d,h]=ve.useState(null),[m,g]=ve.useState({unit:"px",x:25,y:25,width:50,height:50}),[_]=Yn(),v=()=>{if(c){const y=n.current;if(!y||!c)return;const w=y.naturalWidth/y.width,C=y.naturalHeight/y.height,j=new OffscreenCanvas(c.width*w,c.height*C),P=j.getContext("2d");if(!P)throw new Error("No 2D context available");P.drawImage(y,c.x*w,c.y*C,c.width*w,c.height*C,0,0,c.width*w,c.height*C),j.convertToBlob({type:"image/png"}).then(F=>{const I=URL.createObjectURL(F);h(I),l(!1);const D=new FileReader;D.onload=()=>{const N=D.result;_.update(()=>{const k=Xn(u);sc(k)&&N&&k.setSrc(N)})},D.onerror=()=>{console.log("error")},D.readAsDataURL(F)})}},b=()=>{o||l(y=>{if(y===!1){const w=n.current;g({unit:"px",x:0,y:0,width:w.width,height:w.height})}return!y})},S=ve.useRef(null),E=ve.useRef(null);ve.useEffect(()=>{c&&(S.current=c)},[c]);const x=y=>{E.current&&!E.current.contains(y.target)&&l(!1)};return ve.useEffect(()=>(document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}),[]),_e.jsxs("div",{ref:E,children:[a&&_e.jsx("button",{style:{zIndex:999},className:"image-caption-button",onClick:()=>b(),children:"Crop"}),o&&_e.jsx("button",{style:{zIndex:999},className:"image-caption-button",onClick:()=>v(),children:"Apply Crop"}),o?_e.jsx(BI,{crop:m,onChange:y=>g(y),onComplete:y=>f(y),children:_e.jsx("img",{className:t||void 0,src:d||i,alt:p,ref:n,style:{height:s,maxWidth:r,width:e},draggable:"false"})}):_e.jsx("img",{className:t||void 0,src:d||i,alt:p,ref:n,style:{height:s,maxWidth:r,width:e},draggable:"false"})]})}function UI({src:p,altText:t,nodeKey:i,width:e,height:s,maxWidth:r,resizable:n,showCaption:o,caption:l}){const a=ve.useRef(null),u=ve.useRef(null),[c,f,d]=Ip(i),[h,m]=ve.useState(!1),[g]=Yn(),[_,v]=ve.useState(null),[b,S]=ve.useState(!1),E=ve.useRef(null),x=async A=>{const L=await(await fetch(A)).blob();return new Promise((J,O)=>{const z=new FileReader;z.readAsDataURL(L),z.onloadend=()=>{const W=z.result;J(W)},z.onerror=O})};ve.useEffect(()=>{/^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/i.test(p)&&x(p).then(R=>{g.update(()=>{const L=Xn(i);sc(L)&&R&&L.setSrc(R)})})},[p]);const y=ve.useCallback(A=>{if(c&&cr(Ot())){A.preventDefault();const L=Xn(i);if(sc(L))return L.remove(),!0}return!1},[c,i]),w=ve.useCallback(A=>{const R=Ot(),L=u.current;if(c&&cr(R)&&R.getNodes().length===1){if(o)return or(null),A.preventDefault(),l.focus(),!0;if(L!==null&&L!==document.activeElement)return A.preventDefault(),L.focus(),!0}return!1},[l,c,o]),C=ve.useCallback(A=>E.current===l||u.current===A.target?(or(null),g.update(()=>{f(!0);const R=g.getRootElement();R!==null&&R.focus()}),!0):!1,[l,g,f]),j=ve.useCallback(A=>{const R=A;return h?!0:R.target===a.current?(R.shiftKey?f(!c):(d(),f(!0)),!0):!1},[h,c,f,d]),P=ve.useCallback(A=>{g.getEditorState().read(()=>{const R=Ot();A.target.tagName==="IMG"&&Et(R)&&R.getNodes().length===1&&g.dispatchCommand(Iy,A)})},[g]);ve.useEffect(()=>{let A=!0;const R=g.getRootElement(),L=Mr(g.registerUpdateListener(({editorState:J})=>{A&&v(J.read(()=>Ot()))}),g.registerCommand(zo,(J,O)=>(E.current=O,!1),Ln),g.registerCommand(ls,j,Ln),g.registerCommand(Iy,j,Ln),g.registerCommand(il,J=>J.target===a.current?(J.preventDefault(),!0):!1,Ln),g.registerCommand(Ma,y,Ln),g.registerCommand(zi,y,Ln),g.registerCommand(aa,w,Ln),g.registerCommand(Ia,C,Ln));return R==null||R.addEventListener("contextmenu",P),()=>{A=!1,L(),R==null||R.removeEventListener("contextmenu",P)}},[d,g,h,c,i,y,w,C,j,P,f]);const F=()=>{g.update(()=>{const A=Xn(i);sc(A)&&A.setShowCaption(!0)})},I=(A,R)=>{setTimeout(()=>{m(!1)},200),g.update(()=>{const L=Xn(i);console.log(L,"node"),sc(L)&&L.setWidthAndHeight(A,R)})},D=()=>{b||m(!0)},N=c&&cr(_)&&!h,k=c||h;return _e.jsx(ve.Suspense,{fallback:null,children:_e.jsxs(_e.Fragment,{children:[_e.jsx("div",{draggable:N,children:_e.jsx(zI,{className:k?`focused ${cr(_)?"draggable":""}`:null,src:p,altText:t,width:e,height:s,maxWidth:r,imageRef:a,startCrop:b,setStartCrop:S,isFocused:k,nodeKey:i})}),o&&_e.jsx("div",{className:"image-caption-container",children:_e.jsx(Gw,{initialEditor:l,children:_e.jsx(up,{contentEditable:_e.jsx(ky,{className:"ImageNode__contentEditable"}),placeholder:_e.jsx(Ty,{className:"ImageNode__placeholder",children:"Enter a caption..."}),ErrorBoundary:mc})})}),!b&&n&&cr(_)&&k&&_e.jsx(RI,{showCaption:o,setShowCaption:F,editor:g,buttonRef:u,maxWidth:r,onResizeStart:b?()=>{}:D,onResizeEnd:b?()=>{}:I,captionsEnabled:!1,imageRef:a})]})})}const HI=Object.freeze(Object.defineProperty({__proto__:null,RIGHT_CLICK_IMAGE_COMMAND:Iy,default:UI},Symbol.toStringTag,{value:"Module"})),Zw=new Set;function $I(p){if(!Zw.has(p))throw new Promise(t=>{const i=new Image;i.src=p,i.onload=()=>{Zw.add(p),t(null)}})}function qI({altText:p,className:t,imageRef:i,src:e,width:s,height:r,position:n}){return $I(e),_e.jsx("img",{className:t||void 0,src:e,alt:p,ref:i,"data-position":n,style:{display:"block",height:r,width:s},draggable:"false"})}function Qw({activeEditor:p,nodeKey:t,onClose:i}){const s=p.getEditorState().read(()=>Xn(t)),[r,n]=ve.useState(s.getAltText()),[o,l]=ve.useState(s.getShowCaption()),[a,u]=ve.useState(s.getPosition()),c=h=>{l(h.target.checked)},f=h=>{u(h.target.value)},d=()=>{const h={altText:r,position:a,showCaption:o};s&&p.update(()=>{s.update(h)}),i()};return _e.jsxs(_e.Fragment,{children:[_e.jsx("div",{style:{marginBottom:"1em"},children:_e.jsx(n1,{label:"Alt Text",placeholder:"Descriptive alternative text",onChange:n,value:r,"data-test-id":"image-modal-alt-text-input"})}),_e.jsxs(D2,{style:{marginBottom:"1em",width:"208px"},value:a,label:"Position",name:"position",id:"position-select",onChange:f,children:[_e.jsx("option",{value:"left",children:"Left"}),_e.jsx("option",{value:"right",children:"Right"}),_e.jsx("option",{value:"full",children:"Full Width"})]}),_e.jsxs("div",{className:"Input__wrapper",children:[_e.jsx("input",{id:"caption",type:"checkbox",checked:o,onChange:c}),_e.jsx("label",{htmlFor:"caption",children:"Show Caption"})]}),_e.jsx(r1,{children:_e.jsx(fa,{"data-test-id":"image-modal-file-upload-btn",onClick:()=>d(),children:"Confirm"})})]})}function WI({src:p,altText:t,nodeKey:i,width:e,height:s,showCaption:r,caption:n,position:o}){const[l,a]=cp(),u=ve.useRef(null),c=ve.useRef(null),[f,d,h]=Ip(i),[m]=Yn(),[g,_]=ve.useState(null),v=ve.useRef(null),b=ve.useCallback(w=>{if(f&&cr(Ot())){w.preventDefault();const j=Xn(i);if(Bv(j))return j.remove(),!0}return!1},[f,i]),S=ve.useCallback(w=>{const C=Ot(),j=c.current;if(f&&cr(C)&&C.getNodes().length===1){if(r)return or(null),w.preventDefault(),n.focus(),!0;if(j!==null&&j!==document.activeElement)return w.preventDefault(),j.focus(),!0}return!1},[n,f,r]),E=ve.useCallback(w=>v.current===n||c.current===w.target?(or(null),m.update(()=>{d(!0);const C=m.getRootElement();C!==null&&C.focus()}),!0):!1,[n,m,d]);ve.useEffect(()=>{let w=!0;const C=Mr(m.registerUpdateListener(({editorState:j})=>{w&&_(j.read(()=>Ot()))}),m.registerCommand(zo,(j,P)=>(v.current=P,!1),Ln),m.registerCommand(ls,j=>{const P=j;return P.target===u.current?(P.shiftKey?d(!f):(h(),d(!0)),!0):!1},Ln),m.registerCommand(il,j=>j.target===u.current?(j.preventDefault(),!0):!1,Ln),m.registerCommand(Ma,b,Ln),m.registerCommand(zi,b,Ln),m.registerCommand(aa,S,Ln),m.registerCommand(Ia,E,Ln));return()=>{w=!1,C()}},[h,m,f,i,b,S,E,d]);const x=f&&cr(g),y=f;return _e.jsxs(ve.Suspense,{fallback:null,children:[_e.jsxs(_e.Fragment,{children:[_e.jsxs("div",{draggable:x,children:[_e.jsx("button",{className:"image-edit-button",ref:c,onClick:()=>{a("Update Inline Image",w=>_e.jsx(Qw,{activeEditor:m,nodeKey:i,onClose:w}))},children:"Edit"}),_e.jsx(qI,{className:y?`focused ${cr(g)?"draggable":""}`:null,src:p,altText:t,imageRef:u,width:e,height:s,position:o})]}),r&&_e.jsx("div",{className:"image-caption-container",children:_e.jsx(Gw,{initialEditor:n,children:_e.jsx(up,{contentEditable:_e.jsx(ky,{className:"InlineImageNode__contentEditable"}),placeholder:_e.jsx(Ty,{className:"InlineImageNode__placeholder",children:"Enter a caption..."}),ErrorBoundary:mc})})})]}),l]})}const VI=Object.freeze(Object.defineProperty({__proto__:null,UpdateInlineImageDialog:Qw,default:WI},Symbol.toStringTag,{value:"Module"}));Bo.Editor=jI,Bo.EditorVariant2=PI,Object.defineProperty(Bo,Symbol.toStringTag,{value:"Module"})});
|
|
1524
1524
|
//# sourceMappingURL=index.umd.js.map
|