var q=[],A=new Set,y=!1;function B(j){let h={callback:j,cleanup:null,mounted:!1};if(y)G(h);else q.push(h);return A.add(h),()=>{let F=q.indexOf(h);if(F!==-1)q.splice(F,1);if(h.mounted&&h.cleanup)h.cleanup(),h.cleanup=null;A.delete(h)}}function G(j){if(j.mounted)return;j.mounted=!0;try{let h=j.callback();if(typeof h==="function")j.cleanup=h}catch(h){console.error("[Zenith] Error in onMount callback:",h)}}function J(){y=!0;let j=[...q];q.length=0;for(let h of j)G(h)}function K(){y=!1;for(let j of A){if(j.cleanup){try{j.cleanup()}catch(h){console.error("[Zenith] Error in onMount cleanup:",h)}j.cleanup=null}j.mounted=!1}}function L(){return y}function N(){y=!1,q.length=0,A.clear()}var w=new Set;function E(j){return w.add(j),()=>{w.delete(j)}}function Q(){for(let j of w)try{j()}catch(h){console.error("[Zenith] Error in onUnmount callback:",h)}w.clear()}function T(){return w.size}function V(){w.clear()}var D=B,P=E;var X=B,f=E;export{P as zenOnUnmount,D as zenOnMount,K as triggerUnmount,J as triggerMount,V as resetUnmountState,N as resetMountState,f as onUnmount,X as onMount,T as getUnmountCallbackCount,L as getIsMounted,Q as executeUnmountCallbacks};
