import{__rest as o,__assign as t}from"../../../node_modules/tslib/tslib.es6.js";import{detectAnimationFromOptions as e}from"./utils/detect-animation-from-options.js";import r,{cancelSync as n}from"../../../../framesync/dist/es/index.js";import{interpolate as a}from"../utils/interpolate.js";import{hasRepeatDelayElapsed as p,reverseElapsed as i,loopElapsed as l}from"./utils/elapsed.js";var s=function(o){var t=function(t){var e=t.delta;return o(e)};return{start:function(){return r.update(t,!0)},stop:function(){return n.update(t)}}};function u(r){var n,u,d,m,f,v=r.from,c=r.autoplay,y=void 0===c||c,j=r.driver,x=void 0===j?s:j,T=r.elapsed,b=void 0===T?0:T,C=r.repeat,D=void 0===C?0:C,P=r.repeatType,R=void 0===P?"loop":P,S=r.repeatDelay,U=void 0===S?0:S,g=r.onPlay,h=r.onStop,I=r.onComplete,M=r.onRepeat,_=r.onUpdate,k=o(r,["from","autoplay","driver","elapsed","repeat","repeatType","repeatDelay","onPlay","onStop","onComplete","onRepeat","onUpdate"]),q=k.to,w=0,z=k.duration,A=!1,B=!0,E=e(k);(null===(u=(n=E).needsInterpolation)||void 0===u?void 0:u.call(n,v,q))&&(f=a([0,100],[v,q],{clamp:!1}),v=0,q=100);var F=E(t(t({},k),{from:v,to:q}));function G(o){if(B||(o=-o),b+=o,!A){var t=F.next(Math.max(0,b));m=t.value,f&&(m=f(m)),A=B?t.done:b<=0}null==_||_(m),A&&(0===w&&(null!=z||(z=b)),w<D?p(b,z,U,B)&&(w++,"reverse"===R?b=i(b,z,U,B=w%2==0):(b=l(b,z,U),"mirror"===R&&F.flipTarget()),A=!1,M&&M()):(d.stop(),I&&I()))}return y&&(null==g||g(),(d=x(G)).start()),{stop:function(){null==h||h(),d.stop()}}}export{u as animate};
//# sourceMappingURL=index.js.map
