"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("../../../../../react/jsx-runtime.js");var e=require("react"),t=require("../../context/PresenceContext.mjs.js"),r=require("../../utils/use-constant.mjs.js"),s=require("./PopChild.mjs.js"),n=require("../../../../../../_virtual/jsx-runtime.js");function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var i=o(e);function u(){return new Map}exports.PresenceChild=o=>{let{children:c,initial:a,isPresent:l,onExitComplete:f,custom:j,presenceAffectsLayout:p,mode:d,anchorX:m,anchorY:x,root:h}=o;const P=r.useConstant(u),v=e.useId();let C=!0,b=e.useMemo((()=>(C=!1,{id:v,initial:a,isPresent:l,custom:j,onExitComplete:e=>{P.set(e,!0);for(const e of P.values())if(!e)return;f&&f()},register:e=>(P.set(e,!1),()=>P.delete(e))})),[l,P,f]);return p&&C&&(b={...b}),e.useMemo((()=>{P.forEach(((e,t)=>P.set(t,!1)))}),[l]),i.useEffect((()=>{!l&&!P.size&&f&&f()}),[l]),c=n.exports.jsx(s.PopChild,{pop:"popLayout"===d,isPresent:l,anchorX:m,anchorY:x,root:h,children:c}),n.exports.jsx(t.PresenceContext.Provider,{value:b,children:c})};
//# sourceMappingURL=PresenceChild.mjs.js.map
