import{r as e,j as r,a as t}from"./router.chunk.YsRm4bSN.js";import{aN as u}from"./main.chunk.N-eZ2ybB.js";const n=t.createContext(null),s=({children:t})=>{const s=e.useRef(new Map),[a,l]=e.useState(!1),[o,c]=e.useState(!1),i=e.useCallback(e=>{s.current.has(e)&&s.current.delete(e)},[]),m=e.useCallback((e,r)=>s.current.has(e)?u:(s.current.set(e,r),()=>{i(e)}),[i]),p=e.useCallback(()=>{if(0===s.current.size)return null;const e=[...s.current.keys()].pop();return e?s.current.get(e)??null:null},[]),C=e.useCallback(()=>{if(0===s.current.size)return null;const e=[...s.current.keys()].pop();return e||null},[]);return r.jsx(n,{value:{registerForm:m,getCurrentForm:p,getCurrentKey:C,isCurrentFormDirty:a,setIsCurrentFormDirty:l,isLoading:o,setIsLoading:c},children:t})},a=()=>{const r=e.use(n);if(!r)throw new Error("useTemplateLayoutContext must be used within a TemplateLayoutProvider");return r};export{s as T,a as u};
