import{isEmpty}from"../../base/helpers.mjs";import{Controller}from"../base.mjs";import{AnimationFormView}from"../../forms/enfugue/animation.mjs";class AnimationController extends Controller{getState(n=!0){return{animation:this.animationForm.values}}getDefaultState(){return{animation:{animationEnabled:!1,animationFrames:16,animationRate:8,animationSlicing:!0,animationSize:16,animationStride:8,animationLoop:null,animationRate:8,animationInterpolation:null}}}setState(n){isEmpty(n.animation)||this.animationForm.setValues(n.animation).then((()=>this.animationForm.submit()))}async initialize(){this.animationForm=new AnimationFormView(this.config),this.animationForm.onSubmit((async n=>{n.animationEnabled?(this.engine.animationFrames=n.animationFrames,this.engine.animationRate=n.animationRate,this.engine.animationInterpolation=n.animationInterpolation,this.engine.animationLoop=n.animationLoop,n.animationMotionScaleEnabled?this.engine.animationMotionScale=n.animationMotionScale:this.engine.animationMotionScale=null,n.animationPositionEncodingSliceEnabled?(this.engine.animationPositionEncodingTruncateLength=n.animationPositionEncodingTruncateLength,this.engine.animationPositionEncodingScaleLength=n.animationPositionEncodingScaleLength):(this.engine.animationPositionEncodingTruncateLength=null,this.engine.animationPositionEncodingScaleLength=null),n.animationSlicing||n.animationLoop?(this.engine.animationSize=n.animationSize,this.engine.animationStride=n.animationStride):(this.engine.animationSize=n.animationFrames,this.engine.animationStride=0),this.engine.animationInterpolation=n.animationInterpolation):this.engine.animationFrames=0})),this.application.sidebar.addChild(this.animationForm)}}export{AnimationController as SidebarController};
