import{jsx as M}from"react/jsx-runtime";import{useLexicalComposerContext as b}from"@lexical/react/LexicalComposerContext.js";import{useEditDepth as v}from"@payloadcms/ui";import"react";import{createContext as S,useContext as k,useMemo as P,useRef as g,useState as s}from"react";function j(){return Math.random().toString(36).substring(2,12)+Math.random().toString(36).substring(2,12)}var w=S({editorConfig:null,fieldProps:null,uuid:null}),H=({children:o,editorConfig:c,editorContainerRef:d,fieldProps:a,parentContext:n})=>{let[f]=b(),[l]=s(()=>j()),r=g(new Map),[m,C]=s(null),i=g(new Set),[E,p]=s(),h=v(),x=P(()=>({blurEditor:t=>{i.current.clear()},childrenEditors:r,createdInlineBlock:E,editDepth:h,editor:f,editorConfig:c,editorContainerRef:d,fieldProps:a,focusedEditor:m,focusEditor:t=>{let e=t.uuid;i.current.has(e)||(i.current.add(e),C(t),n?.uuid&&n.focusEditor(t),r.current.forEach(u=>{u.focusEditor(t)}),i.current.clear())},parentEditor:n,registerChild:(t,e)=>{if(!r.current.has(t)){let u=new Map(r.current);u.set(t,e),r.current=u}},setCreatedInlineBlock:p,unregisterChild:t=>{if(r.current.has(t)){let e=new Map(r.current);e.delete(t),r.current=e}},uuid:l}),[E,p,f,r,c,d,h,a,m,n,l]);return M(w.Provider,{value:x,children:o})},I=()=>{let o=k(w);if(o===void 0)throw new Error("useEditorConfigContext must be used within an EditorConfigProvider");return o};export{H as a,I as b};
//# sourceMappingURL=chunk-3LGFOM34.js.map
