"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../motion-utils/dist/es/array.mjs.js");exports.NodeStack=class{constructor(){this.members=[]}add(s){e.addUniqueItem(this.members,s);for(let t=this.members.length-1;t>=0;t--){const o=this.members[t];if(o===s||o===this.lead||o===this.prevLead)continue;const i=o.instance;i&&!1!==i.isConnected||o.snapshot||(e.removeItem(this.members,o),o.unmount())}s.scheduleRender()}remove(s){if(e.removeItem(this.members,s),s===this.prevLead&&(this.prevLead=void 0),s===this.lead){const e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let s=this.members.indexOf(e)-1;s>=0;s--){const e=this.members[s];if(!1!==e.isPresent&&!1!==e.instance?.isConnected)return this.promote(e),!0}return!1}promote(e,s){const t=this.lead;if(e!==t&&(this.prevLead=t,this.lead=e,e.show(),t)){t.updateSnapshot(),e.scheduleRender();const{layoutDependency:o}=t.options,{layoutDependency:i}=e.options;void 0!==o&&o===i||(e.resumeFrom=t,s&&(t.preserveOpacity=!0),t.snapshot&&(e.snapshot=t.snapshot,e.snapshot.latestValues=t.animationValues||t.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),!1===e.options.crossfade&&t.hide()}}exitAnimationComplete(){this.members.forEach((e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()}))}scheduleRender(){this.members.forEach((e=>e.instance&&e.scheduleRender(!1)))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}};
//# sourceMappingURL=stack.mjs.js.map
