import{R as a,b as e}from"./declarationMapper-CGPHX8aB.js";import{L as r,R as p}from"./index-6jOCfdig.js";import{a as s}from"./KHR_interactivity-DRPs30Rf.js";import"./index-Ds2meNS5.js";import"./svelte/svelte_svelte.js";import"./svelte/svelte_animate.js";import"./svelte/svelte_attachments.js";import"./svelte/svelte_easing.js";import"./svelte/svelte_internal_client.js";import"./svelte/svelte_internal_flags_async.js";import"./svelte/svelte_internal_flags_legacy.js";import"./svelte/svelte_internal_flags_tracing.js";import"./svelte/svelte_internal_server.js";import"./svelte/svelte_legacy.js";import"./svelte/svelte_motion.js";import"./svelte/svelte_reactivity.js";import"./svelte/svelte_reactivity_window.js";import"./svelte/svelte_server.js";import"./svelte/svelte_store.js";import"./svelte/svelte_transition.js";import"./svelte/svelte_events.js";import"./objectModelMapping-DT0r674A.js";class m extends s{constructor(i){super(i),this.animationGroup=this.registerDataInput("animationGroup",a),this.stopAtFrame=this.registerDataInput("stopAtFrame",e,-1)}_preparePendingTasks(i){const n=this.animationGroup.getValue(i),t=this.stopAtFrame.getValue(i)??-1,o=i._getGlobalContextVariable("pendingStopAnimations",[]);o.push({uniqueId:n.uniqueId,stopAtFrame:t}),i._setGlobalContextVariable("pendingStopAnimations",o)}_cancelPendingTasks(i){const n=this.animationGroup.getValue(i),t=i._getGlobalContextVariable("pendingStopAnimations",[]);for(let o=0;o<t.length;o++)if(t[o].uniqueId===n.uniqueId){t.splice(o,1),i._setGlobalContextVariable("pendingStopAnimations",t);break}}_execute(i){const n=this.animationGroup.getValue(i),t=this.stopAtFrame.getValue(i)??-1;if(!n)return r.Warn("No animation group provided to stop."),this._reportError(i,"No animation group provided to stop.");if(isNaN(t))return this._reportError(i,"Invalid stop time.");t>0?this._startPendingTasks(i):this._stopAnimation(n,i),this.out._activateSignal(i)}_executeOnTick(i){const n=this.animationGroup.getValue(i),t=i._getGlobalContextVariable("pendingStopAnimations",[]);for(let o=0;o<t.length;o++)if(t[o].uniqueId===n.uniqueId&&n.getCurrentFrame()>=t[o].stopAtFrame){this._stopAnimation(n,i),t.splice(o,1),i._setGlobalContextVariable("pendingStopAnimations",t),this.done._activateSignal(i),i._removePendingBlock(this);break}}getClassName(){return"FlowGraphStopAnimationBlock"}_stopAnimation(i,n){const t=n._getGlobalContextVariable("currentlyRunningAnimationGroups",[]),o=t.indexOf(i.uniqueId);o!==-1&&(i.stop(),t.splice(o,1),n._setGlobalContextVariable("currentlyRunningAnimationGroups",t))}}p("FlowGraphStopAnimationBlock",m);export{m as FlowGraphStopAnimationBlock};
