"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./utils/fill-wildcards.mjs.js"),s=require("./utils/unit-conversion.mjs.js"),t=require("../../frameloop/frame.mjs.js");const r=new Set;let n=!1,a=!1,l=!1;function i(){if(a){const e=Array.from(r).filter((e=>e.needsMeasurement)),t=new Set(e.map((e=>e.element))),n=new Map;t.forEach((e=>{const t=s.removeNonTranslationalTransform(e);t.length&&(n.set(e,t),e.render())})),e.forEach((e=>e.measureInitialState())),t.forEach((e=>{e.render();const s=n.get(e);s&&s.forEach((s=>{let[t,r]=s;e.getValue(t)?.set(r)}))})),e.forEach((e=>e.measureEndState())),e.forEach((e=>{void 0!==e.suspendedScrollY&&window.scrollTo(0,e.suspendedScrollY)}))}a=!1,n=!1,r.forEach((e=>e.complete(l))),r.clear()}function o(){r.forEach((e=>{e.readKeyframes(),e.needsMeasurement&&(a=!0)}))}exports.KeyframeResolver=class{constructor(e,s,t,r,n){let a=arguments.length>5&&void 0!==arguments[5]&&arguments[5];this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=s,this.name=t,this.motionValue=r,this.element=n,this.isAsync=a}scheduleResolve(){this.state="scheduled",this.isAsync?(r.add(this),n||(n=!0,t.frame.read(o),t.frame.resolveKeyframes(i))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:s,name:t,element:r,motionValue:n}=this;if(null===s[0]){const e=n?.get(),a=s[s.length-1];if(void 0!==e)s[0]=e;else if(r&&t){const e=r.readValue(t,a);null!=e&&(s[0]=e)}void 0===s[0]&&(s[0]=a),n&&void 0===e&&n.set(s[0])}e.fillWildcards(s)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),r.delete(this)}cancel(){"scheduled"===this.state&&(r.delete(this),this.state="pending")}resume(){"pending"===this.state&&this.scheduleResolve()}},exports.flushKeyframeResolvers=function(){l=!0,o(),i(),l=!1};
//# sourceMappingURL=KeyframesResolver.mjs.js.map
