"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../utils/get-value-transition.mjs.js"),t=require("../utils/resolve-transition.mjs.js"),i=require("../../render/utils/keys-position.mjs.js"),n=require("../../render/utils/setters.mjs.js"),s=require("../../value/will-change/add-will-change.mjs.js"),a=require("../optimized-appear/get-appear-id.mjs.js"),o=require("./motion-value.mjs.js"),r=require("../../frameloop/frame.mjs.js");function l(e,t){let{protectedKeys:i,needsAnimating:n}=e;const s=i.hasOwnProperty(t)&&!0!==n[t];return n[t]=!1,s}exports.animateTarget=function(u,m){let{delay:d=0,transitionOverride:c,type:p}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{transition:f,transitionEnd:g,...j}=m;const v=u.getDefaultTransition();f=f?t.resolveTransition(f,v):v;const y=f?.reduceMotion,h=f?.skipAnimations;c&&(f=c);const A=[],q=p&&u.animationState&&u.animationState.getState()[p],w=f?.path;w&&w.animateVisualElement(u,j,f,d,A);for(const t in j){const n=u.getValue(t,u.latestValues[t]??null),m=j[t];if(void 0===m||q&&l(q,t))continue;const c={delay:d,...e.getValueTransition(f||{},t)};h&&(c.skipAnimations=!0);const p=n.get();if(void 0!==p&&!n.isAnimating()&&!Array.isArray(m)&&m===p&&!c.velocity){r.frame.update((()=>n.set(m)));continue}let g=!1;if(window.MotionHandoffAnimation){const e=a.getOptimisedAppearId(u);if(e){const i=window.MotionHandoffAnimation(e,t,r.frame);null!==i&&(c.startTime=i,g=!0)}}s.addValueToWillChange(u,t);const v=y??u.shouldReduceMotion;n.start(o.animateMotionValue(t,n,m,v&&i.positionalKeys.has(t)?{type:!1}:c,u,g));const w=n.animation;w&&A.push(w)}if(g){const e=()=>r.frame.update((()=>{g&&n.setTarget(u,g)}));A.length?Promise.all(A).then(e):e()}return A};
//# sourceMappingURL=visual-element-target.mjs.js.map
