import t,{getFrameData as e}from"../../../../framesync/dist/es/index.js";import{SubscriptionManager as i}from"../utils/subscription-manager.js";import{velocityPerSecond as r}from"../../../../popmotion/dist/es/utils/velocity-per-second.js";var s=function(){function s(r){var s,n=this;this.timeDelta=0,this.lastUpdated=0,this.updateSubscribers=new i,this.velocityUpdateSubscribers=new i,this.renderSubscribers=new i,this.canTrackVelocity=!1,this.updateAndNotify=function(i,r){void 0===r&&(r=!0),n.prev=n.current,n.current=i;var s=e(),o=s.delta,c=s.timestamp;n.lastUpdated!==c&&(n.timeDelta=o,n.lastUpdated=c,t.postRender(n.scheduleVelocityCheck)),n.prev!==n.current&&n.updateSubscribers.notify(n.current),n.velocityUpdateSubscribers.getSize()&&n.velocityUpdateSubscribers.notify(n.getVelocity()),r&&n.renderSubscribers.notify(n.current)},this.scheduleVelocityCheck=function(){return t.postRender(n.velocityCheck)},this.velocityCheck=function(t){t.timestamp!==n.lastUpdated&&(n.prev=n.current,n.velocityUpdateSubscribers.notify(n.getVelocity()))},this.hasAnimated=!1,this.prev=this.current=r,this.canTrackVelocity=(s=this.current,!isNaN(parseFloat(s)))}return s.prototype.onChange=function(t){return this.updateSubscribers.add(t)},s.prototype.clearListeners=function(){this.updateSubscribers.clear()},s.prototype.onRenderRequest=function(t){return t(this.get()),this.renderSubscribers.add(t)},s.prototype.attach=function(t){this.passiveEffect=t},s.prototype.set=function(t,e){void 0===e&&(e=!0),e&&this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t,e)},s.prototype.get=function(){return this.current},s.prototype.getPrevious=function(){return this.prev},s.prototype.getVelocity=function(){return this.canTrackVelocity?r(parseFloat(this.current)-parseFloat(this.prev),this.timeDelta):0},s.prototype.start=function(t){var e=this;return this.stop(),new Promise((function(i){e.hasAnimated=!0,e.stopAnimation=t(i)})).then((function(){return e.clearAnimation()}))},s.prototype.stop=function(){this.stopAnimation&&this.stopAnimation(),this.clearAnimation()},s.prototype.isAnimating=function(){return!!this.stopAnimation},s.prototype.clearAnimation=function(){this.stopAnimation=null},s.prototype.destroy=function(){this.updateSubscribers.clear(),this.renderSubscribers.clear(),this.stop()},s}();function n(t){return new s(t)}export{s as MotionValue,n as motionValue};
//# sourceMappingURL=index.js.map
