import{F as c}from"./KHR_interactivity-BRnQ0PPJ.js";import{g as d,d as g,b as h,R as p}from"./declarationMapper-YJJdbZ_c.js";import{as as y,R as F}from"./index-T8LZyOXI.js";import"./index-BkylzejB.js";import"./objectModelMapping-D1pI71RW.js";class f extends c{constructor(t={}){super(t),this.keyFrames=[];const e=typeof t?.animationType=="string"?d(t.animationType):g(t?.animationType??0),i=t?.keyFramesCount??1,n=this.registerDataInput("duration_0",h,0),a=this.registerDataInput("value_0",e);this.keyFrames.push({duration:n,value:a});for(let s=1;s<i+1;s++){const u=this.registerDataInput(`duration_${s}`,h,s===i?t.duration:void 0),l=this.registerDataInput(`value_${s}`,e);this.keyFrames.push({duration:u,value:l})}this.initialValue=this.keyFrames[0].value,this.endValue=this.keyFrames[i].value,this.easingFunction=this.registerDataInput("easingFunction",p),this.animation=this.registerDataOutput("animation",p),this.propertyName=this.registerDataInput("propertyName",p,t?.propertyName),this.customBuildAnimation=this.registerDataInput("customBuildAnimation",p)}_updateOutputs(t){const e=t._getGlobalContextVariable("interpolationAnimations",[]),i=this.propertyName.getValue(t),n=this.easingFunction.getValue(t),a=this._createAnimation(t,i,n);if(this.animation.setValue(a,t),Array.isArray(a))for(const s of a)e.push(s.uniqueId);else e.push(a.uniqueId);t._setGlobalContextVariable("interpolationAnimations",e)}_createAnimation(t,e,i){const n=this.initialValue.richType,a=[],s=this.initialValue.getValue(t)||n.defaultValue;a.push({frame:0,value:s});const u=this.config?.numberOfKeyFrames??1;for(let r=1;r<u+1;r++){const m=this.keyFrames[r].duration?.getValue(t);let o=this.keyFrames[r].value?.getValue(t);r===u-1&&(o=o||n.defaultValue),m!==void 0&&o&&a.push({frame:m*60,value:o})}const l=this.customBuildAnimation.getValue(t);if(l)return l(null,null,t)(a,60,n.animationType,i);if(typeof e=="string"){const r=y.CreateAnimation(e,n.animationType,60,i);return r.setKeys(a),[r]}else return e.map(m=>{const o=y.CreateAnimation(m,n.animationType,60,i);return o.setKeys(a),o})}getClassName(){return"FlowGraphInterpolationBlock"}}F("FlowGraphInterpolationBlock",f);export{f as FlowGraphInterpolationBlock};
