@wix/motion 2.1.9 → 2.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -148,6 +148,10 @@ const sequence = getSequence(
148
148
  sequence.play();
149
149
  ```
150
150
 
151
+ Add a `sequenceId` to stagger CSS-rendered animations too: `getCSSAnimation()` accepts the same options and
152
+ emits a single rule whose delay is a `calc()` over `--motion-<sequenceId>-index`, which the `Sequence` then
153
+ sets per element. See [CSS-Driven Stagger](./docs/api/sequence.md#css-driven-stagger).
154
+
151
155
  See [`docs/api/get-sequence.md`](https://github.com/wix/interact/blob/master/packages/motion/docs/api/get-sequence.md) for the full stagger model.
152
156
 
153
157
  ## ViewTimeline and Polyfills
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class _{animations;options;ready;isCSS;longestAnimation;constructor(e,n){this.animations=e,this.options=n,this.ready=n?.measured||Promise.resolve(),this.isCSS=e[0]instanceof CSSAnimation,this.longestAnimation=this._getAnimationWithLongestEndTime()}_getAnimationWithLongestEndTime(){return this.animations.reduce((e,n)=>{const i=e.effect?.getComputedTiming().endTime??0,s=n.effect?.getComputedTiming().endTime??0;return i>s?e:n},this.animations[0])}getProgress(){return this.longestAnimation?.effect?.getComputedTiming().progress||0}async play(e){await this.ready;for(const n of this.animations)n.play();await Promise.all(this.animations.map(n=>n.ready)),e&&e()}pause(){for(const e of this.animations)e.pause()}async reverse(e){await this.ready;for(const n of this.animations)n.reverse();await Promise.all(this.animations.map(n=>n.ready)),e&&e()}progress(e){for(const n of this.animations){const{delay:i,duration:s,iterations:r}=n.effect.getTiming(),c=(Number.isFinite(s)?s:0)*(Number.isFinite(r)?r:1);n.currentTime=((i||0)+c)*e}}cancel(){for(const e of this.animations)e.cancel()}setPlaybackRate(e){for(const n of this.animations)n.playbackRate=e}async onFinish(e){try{await Promise.all(this.animations.map(i=>i.finished));const n=this.animations[0];if(n&&!this.isCSS){const i=n.effect?.target;if(i){const s=this.options?.effectId||n.id,r=new CustomEvent("animationend",{detail:{effectId:s}});i.dispatchEvent(r)}}e()}catch(n){console.warn("animation was interrupted - aborting onFinish callback - ",n)}}async onAbort(e){try{await Promise.all(this.animations.map(n=>n.finished))}catch(n){if(n.name==="AbortError"){const i=this.animations[0];if(i&&!this.isCSS){const s=i.effect?.target;if(s){const r=new Event("animationcancel");s.dispatchEvent(r)}}e()}}}get finished(){return Promise.all(this.animations.map(e=>e.finished))}get playState(){return this.animations.some(e=>e.playState==="running")?"running":this.animations[0]?.playState}hasAnimationName(e){return this.animations.some(n=>n.animationName===e)}hasAnimationId(e){return this.animations.some(n=>n.id===e)}getTimingOptions(){return this.animations.map(e=>{const n=e.effect?.getTiming(),i=n?.delay??0,s=Number(n?.duration)||0,r=n?.iterations??1;return{delay:i,duration:s,iterations:r}})}}const $=t=>t,j=t=>1-Math.cos(t*Math.PI/2),L=t=>Math.sin(t*Math.PI/2),W=t=>-(Math.cos(Math.PI*t)-1)/2,H=t=>t**2,K=t=>1-(1-t)**2,V=t=>t<.5?2*t**2:1-(-2*t+2)**2/2,B=t=>t**3,U=t=>1-(1-t)**3,X=t=>t<.5?4*t**3:1-(-2*t+2)**3/2,J=t=>t**4,Y=t=>1-(1-t)**4,Z=t=>t<.5?8*t**4:1-(-2*t+2)**4/2,Q=t=>t**5,tt=t=>1-(1-t)**5,et=t=>t<.5?16*t**5:1-(-2*t+2)**5/2,nt=t=>t===0?0:2**(10*t-10),it=t=>t===1?1:1-2**(-10*t),st=t=>t===0?0:t===1?1:t<.5?2**(20*t-10)/2:(2-2**(-20*t+10))/2,rt=t=>1-Math.sqrt(1-t**2),ot=t=>Math.sqrt(1-(t-1)**2),at=t=>t<.5?(1-Math.sqrt(1-4*t**2))/2:(Math.sqrt(-(2*t-3)*(2*t-1))+1)/2,ct=t=>2.70158*t**3-1.70158*t**2,ut=t=>1+2.70158*(t-1)**3+1.70158*(t-1)**2,ft=(t,e=1.70158*1.525)=>t<.5?(2*t)**2*((e+1)*2*t-e)/2:((2*t-2)**2*((e+1)*(t*2-2)+e)+2)/2,k={linear:$,sineIn:j,sineOut:L,sineInOut:W,quadIn:H,quadOut:K,quadInOut:V,cubicIn:B,cubicOut:U,cubicInOut:X,quartIn:J,quartOut:Y,quartInOut:Z,quintIn:Q,quintOut:tt,quintInOut:et,expoIn:nt,expoOut:it,expoInOut:st,circIn:rt,circOut:ot,circInOut:at,backIn:ct,backOut:ut,backInOut:ft},q={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",sineIn:"cubic-bezier(0.47, 0, 0.745, 0.715)",sineOut:"cubic-bezier(0.39, 0.575, 0.565, 1)",sineInOut:"cubic-bezier(0.445, 0.05, 0.55, 0.95)",quadIn:"cubic-bezier(0.55, 0.085, 0.68, 0.53)",quadOut:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",quadInOut:"cubic-bezier(0.455, 0.03, 0.515, 0.955)",cubicIn:"cubic-bezier(0.55, 0.055, 0.675, 0.19)",cubicOut:"cubic-bezier(0.215, 0.61, 0.355, 1)",cubicInOut:"cubic-bezier(0.645, 0.045, 0.355, 1)",quartIn:"cubic-bezier(0.895, 0.03, 0.685, 0.22)",quartOut:"cubic-bezier(0.165, 0.84, 0.44, 1)",quartInOut:"cubic-bezier(0.77, 0, 0.175, 1)",quintIn:"cubic-bezier(0.755, 0.05, 0.855, 0.06)",quintOut:"cubic-bezier(0.23, 1, 0.32, 1)",quintInOut:"cubic-bezier(0.86, 0, 0.07, 1)",expoIn:"cubic-bezier(0.95, 0.05, 0.795, 0.035)",expoOut:"cubic-bezier(0.19, 1, 0.22, 1)",expoInOut:"cubic-bezier(1, 0, 0, 1)",circIn:"cubic-bezier(0.6, 0.04, 0.98, 0.335)",circOut:"cubic-bezier(0.075, 0.82, 0.165, 1)",circInOut:"cubic-bezier(0.785, 0.135, 0.15, 0.86)",backIn:"cubic-bezier(0.6, -0.28, 0.735, 0.045)",backOut:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",backInOut:"cubic-bezier(0.68, -0.55, 0.265, 1.55)"};function mt(t){return t==="percentage"?"%":t||"px"}const wt=/^(webkit|moz|ms|o)(?=[A-Z])/,St=Object.assign(Object.create(null),{float:"cssFloat","animation-timing-function":"easing","animation-composition":"composite"});function Tt(t){return t.startsWith("--")?t:(wt.test(t)?`-${t}`:t).replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}function lt(t){return t.startsWith("--")||!t.includes("-")?t:t.replace(/^-/,"").replace(/-([a-z])/g,(e,n)=>n.toUpperCase())}function ht(t){return St[t]||lt(t)}function kt(t){for(const e in t)if(Object.hasOwn(t,e)&&ht(e)!==e)return!0;return!1}function dt(t){if(!Array.isArray(t))return t;let e;return t.forEach((n,i)=>{if(!n||typeof n!="object"||!kt(n))return;e??=t.slice();const s={};for(const r in n)Object.hasOwn(n,r)&&(s[ht(r)]=n[r]);e[i]=s}),e||t}function pt(t){return t?q[t]||t:q.linear}function qt(t,e,n,i){const s=3*t,r=3*(n-t)-s,c=1-s-r,o=3*e,m=3*(i-e)-o,l=1-o-m,a=h=>((c*h+r)*h+s)*h,u=h=>((l*h+m)*h+o)*h,f=h=>(3*c*h+2*r)*h+s;function p(h){let d=h;for(let b=0;b<8;b++){const y=a(d)-h;if(Math.abs(y)<1e-7)return d;const O=f(d);if(Math.abs(O)<1e-6)break;d-=y/O}let E=0,g=1;for(d=(E+g)/2;g-E>1e-7;){const b=a(d);if(Math.abs(b-h)<1e-7)return d;h>b?E=d:g=d,d=(E+g)/2}return d}return h=>h<=0?0:h>=1?1:u(p(h))}function Pt(t){const e=t.match(/^cubic-bezier\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)$/);if(!e)return;const n=parseFloat(e[1]),i=parseFloat(e[2]),s=parseFloat(e[3]),r=parseFloat(e[4]);if(![n,i,s,r].some(isNaN))return qt(n,i,s,r)}function $t(t){const e=t.match(/^linear\((.+)\)$/);if(!e)return;const n=e[1].split(",").map(c=>c.trim()).filter(Boolean);if(n.length===0)return;const i=[];for(const c of n){const o=c.split(/\s+/),m=parseFloat(o[0]);if(isNaN(m))return;const l=[];for(let a=1;a<o.length;a++)if(o[a].endsWith("%")){const u=parseFloat(o[a])/100;if(isNaN(u))return;l.push(u)}l.length===0?i.push({output:m,pos:null}):l.length===1?i.push({output:m,pos:l[0]}):(i.push({output:m,pos:l[0]}),i.push({output:m,pos:l[1]}))}if(i.length===0)return;i[0].pos===null&&(i[0].pos=0),i[i.length-1].pos===null&&(i[i.length-1].pos=1);let s=0;for(;s<i.length;)if(i[s].pos===null){const c=s-1;let o=s;for(;o<i.length&&i[o].pos===null;)o++;const m=i[c].pos,l=i[o].pos,a=o-c;for(let u=c+1;u<o;u++)i[u].pos=m+(l-m)*(u-c)/a;s=o+1}else s++;for(let c=1;c<i.length;c++)i[c].pos<i[c-1].pos&&(i[c].pos=i[c-1].pos);const r=i;return c=>{if(c<=r[0].pos)return r[0].output;const o=r[r.length-1];if(c>=o.pos)return o.output;let m=0,l=r.length-1;for(;m<l-1;){const f=m+l>>>1;r[f].pos<=c?m=f:l=f}const a=r[m],u=r[l];return u.pos===a.pos?u.output:a.output+(u.output-a.output)*(c-a.pos)/(u.pos-a.pos)}}function C(t){if(!t)return;const e=k[t];return e||(Pt(t)??$t(t)??k.linear)}class Ct extends _{animationGroups;delay;offset;offsetEasing;timingOptions;constructor(e,n={}){const i=e.flatMap(s=>[...s.animations]);super(i),this.animationGroups=e,this.delay=n.delay??0,this.offset=n.offset??0,this.offsetEasing=typeof n.offsetEasing=="function"?n.offsetEasing:C(n.offsetEasing)??$,this.timingOptions=this.animationGroups.map(s=>s.getTimingOptions().map(({delay:r,duration:c,iterations:o})=>({delay:r,duration:Number.isFinite(c)?c:0,iterations:Number.isFinite(o)?o:1}))),this.applyOffsets(),this.ready=Promise.all(e.map(s=>s.ready)).then(()=>{})}calculateOffsets(){const e=this.animationGroups.length;if(e<=1)return[0];const n=e-1;return Array.from({length:e},(i,s)=>this.offsetEasing(s/n)*n*this.offset|0)}applyOffsets(){if(this.animationGroups.length===0||this.animations.length===0)return;const e=this.calculateOffsets(),n=this.getSequenceActiveDuration(e);this.animationGroups.forEach((i,s)=>{i.animations.forEach((r,c)=>{const o=r.effect;if(!o)return;const{delay:m,duration:l,iterations:a}=this.timingOptions[s][c],u=m+e[s],f=n-(u+l*a);o.updateTiming({delay:u+this.delay,endDelay:f})})})}getSequenceActiveDuration(e){const n=[];for(let i=0;i<this.timingOptions.length;i++){const s=this.timingOptions[i].reduce((r,c)=>{if(!c)return r;const{delay:o,duration:m,iterations:l}=c;return Math.max(r,o+m*l)},0);n.push(e[i]+s)}return Math.max(...n)}addGroups(e){if(e.length===0)return;const n=[...e].sort((i,s)=>s.index-i.index);for(const{index:i,group:s}of n){const r=Math.min(i,this.animationGroups.length);this.animationGroups.splice(r,0,s),this.timingOptions.splice(r,0,s.getTimingOptions());const c=[...s.animations],o=this.animationGroups.slice(0,r).reduce((m,l)=>m+l.animations.length,0);this.animations.splice(o,0,...c)}this.applyOffsets(),this.ready=Promise.all(this.animationGroups.map(i=>i.ready)).then(()=>{})}removeGroups(e){const n=[],i=[],s=[];for(let r=0;r<this.animationGroups.length;r++)e(this.animationGroups[r])?n.push(this.animationGroups[r]):(i.push(this.animationGroups[r]),s.push(this.timingOptions[r]));if(n.length===0)return n;for(const r of n)r.cancel();return this.animationGroups=i,this.timingOptions=s,this.animations=i.flatMap(r=>[...r.animations]),this.applyOffsets(),this.ready=Promise.all(this.animationGroups.map(r=>r.ready)).then(()=>{}),n}async onFinish(e){try{await Promise.all(this.animationGroups.map(n=>n.finished)),e()}catch(n){console.warn("animation was interrupted - aborting onFinish callback - ",n)}}}class zt{_animation;customEffect;progress;_tickCbId;_finishHandler;constructor(e,n,i,s){const r=new KeyframeEffect(n,[],{...i,composite:"add"}),{timeline:c}=s;this._animation=new Animation(r,c),this._tickCbId=null,this.progress=null,this.customEffect=o=>e(r.target,o),this._finishHandler=o=>{this.effect.target?.getAnimations().find(m=>m===this._animation)||this.cancel()},this.addEventListener("finish",this._finishHandler),this.addEventListener("remove",this._finishHandler)}_tick(){try{const e=this.effect?.getComputedTiming().progress??null;e!==this.progress&&(this.customEffect?.(e),this.progress=e),this._tickCbId=requestAnimationFrame(()=>{this._tick()})}catch(e){this._tickCbId=null,console.error(`failed to run customEffect! effectId: ${this.id}, error: ${e instanceof Error?e.message:e}`)}}get currentTime(){return this._animation.currentTime}set currentTime(e){this._animation.currentTime=e}get startTime(){return this._animation.startTime}set startTime(e){this._animation.startTime=e}get playbackRate(){return this._animation.playbackRate}set playbackRate(e){this._animation.playbackRate=e}get id(){return this._animation.id}set id(e){this._animation.id=e}get effect(){return this._animation.effect}set effect(e){this._animation.effect=e}get timeline(){return this._animation.timeline}set timeline(e){this._animation.timeline=e}get finished(){return this._animation.finished}get pending(){return this._animation.pending}get playState(){return this._animation.playState}get ready(){return this._animation.ready}get replaceState(){return this._animation.replaceState}get oncancel(){return this._animation.oncancel}set oncancel(e){this._animation.oncancel=e}get onfinish(){return this._animation.onfinish}set onfinish(e){this._animation.onfinish=e}get onremove(){return this._animation.onremove}set onremove(e){this._animation.onremove=e}play(){this._animation.play(),cancelAnimationFrame(this._tickCbId),this._tickCbId=requestAnimationFrame(()=>this._tick())}pause(){this._animation.pause(),cancelAnimationFrame(this._tickCbId),this._tickCbId=null}cancel(){this.removeEventListener("finish",this._finishHandler),this.removeEventListener("remove",this._finishHandler),this._animation.cancel(),this.customEffect(null),cancelAnimationFrame(this._tickCbId),this._tickCbId=null}commitStyles(){console.warn("CustomEffect animations do not support commitStyles method as they have no style to commit")}finish(){this._animation.finish()}persist(){this._animation.persist()}reverse(){this._animation.reverse()}updatePlaybackRate(e){this._animation.updatePlaybackRate(e)}addEventListener(e,n,i){this._animation.addEventListener(e,n,i)}removeEventListener(e,n,i){this._animation.removeEventListener(e,n,i)}dispatchEvent(e){return this._animation.dispatchEvent(e)}}function Ft(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var w={exports:{}},M=w.exports,G;function Nt(){return G||(G=1,(function(t){(function(e){var n=function(){},i=e.requestAnimationFrame||e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.msRequestAnimationFrame||function(a){return setTimeout(a,16)};function s(){var a=this;a.reads=[],a.writes=[],a.raf=i.bind(e)}s.prototype={constructor:s,runTasks:function(a){for(var u;u=a.shift();)u()},measure:function(a,u){var f=u?a.bind(u):a;return this.reads.push(f),r(this),f},mutate:function(a,u){var f=u?a.bind(u):a;return this.writes.push(f),r(this),f},clear:function(a){return o(this.reads,a)||o(this.writes,a)},extend:function(a){if(typeof a!="object")throw new Error("expected object");var u=Object.create(this);return m(u,a),u.fastdom=this,u.initialize&&u.initialize(),u},catch:null};function r(a){a.scheduled||(a.scheduled=!0,a.raf(c.bind(null,a)))}function c(a){var u=a.writes,f=a.reads,p;try{n("flushing reads",f.length),a.runTasks(f),n("flushing writes",u.length),a.runTasks(u)}catch(h){p=h}if(a.scheduled=!1,(f.length||u.length)&&r(a),p)if(n("task errored",p.message),a.catch)a.catch(p);else throw p}function o(a,u){var f=a.indexOf(u);return!!~f&&!!a.splice(f,1)}function m(a,u){for(var f in u)u.hasOwnProperty(f)&&(a[f]=u[f])}var l=e.fastdom=e.fastdom||new s;t.exports=l})(typeof window<"u"?window:typeof M<"u"?M:globalThis)})(w)),w.exports}var xt=Nt();const v=Ft(xt),P={};function Mt(t){Object.assign(P,t)}function Gt(t){return t in P?P[t]:(console.warn(`${t} not found in registry. Please make sure to import and register the preset.`),null)}function I(t,e){return t?(e||document).getElementById(t):null}function Rt(t,e){return t?.matches(`[data-motion-part~="${e}"]`)?t:t?.querySelector(`[data-motion-part~="${e}"]`)}function Dt(t){const e=t.alternate?"alternate":"";return t.reversed?`${e?`${e}-`:""}reverse`:e||"normal"}function T(t){return`${t.value}${mt(t.unit)}`}function R(t,e,n){return`${t.name||"cover"} ${n&&t.offset.unit!=="percentage"?`calc(100% + ${T(t.offset)}${e?` + ${e}`:""})`:e?`calc(${T(t.offset)} + ${e})`:T(t.offset)}`}function gt(t){return{start:R(t.startOffset,t.startOffsetAdd),end:R(t.endOffset,t.endOffsetAdd,!0)}}function bt(t){return e=>v.measure(()=>e(t))}function yt(t){return e=>v.mutate(()=>e(t))}function A(t){if(t.namedEffect){const e=t.namedEffect.type;return typeof e=="string"?Gt(e):null}else if(t.keyframeEffect){const e=i=>{const{name:s,keyframes:r}=i.keyframeEffect;return[{...i,name:s,keyframes:r}]};return{web:e,style:e,getNames:i=>{const{effectId:s}=i,{name:r}=i.keyframeEffect,c=r||s;return c?[c]:[]}}}else if(t.customEffect)return e=>[{...e,keyframes:[]}];return null}function Et(t,e,n,i){return t.map((s,r)=>{const c={fill:s.fill,easing:pt(s.easing),iterations:s.iterations===0?1/0:s.iterations||1,composite:s.composite,direction:Dt(s)};z(e)?(c.duration=s.duration,c.delay=s.delay||0):e?.trigger==="view-progress"&&(i||window.ViewTimeline)?c.duration="auto":(c.duration=99.99,c.delay=.01);const o=dt(s.keyframes);return{effect:o===s.keyframes?s:{...s,keyframes:o},options:c,id:n&&`${n}-${r+1}`,part:s.part}})}function z(t){return!t||t.trigger!=="pointer-move"&&t.trigger!=="view-progress"}function D(t,e,n,i,s){if(t){if(z(i)&&(e.duration=e.duration||1,s?.reducedMotion))if(e.iterations===1||e.iterations==null)e={...e,duration:1};else return[];let r;return n instanceof HTMLElement&&(r={measure:bt(n),mutate:yt(n)}),t.web?t.web(e,r,s):t(e,r,s)}return[]}function F(t,e,n,i,s){const r=typeof t=="string"?I(t,s):t;if(n?.trigger==="pointer-move"&&!e.keyframeEffect){let f=e;e.customEffect&&(f={...e,namedEffect:{id:"",type:"CustomMouse"}});const p=A(f),h=D(p,e,r,n,i);return typeof h!="function"?null:h(r)}const c=A(e),o=D(c,e,r,n,i);if(!o||o.length===0)return null;const m=Et(o,n,e.effectId);let l;const a=n?.trigger==="view-progress";a&&window.ViewTimeline&&(l=new ViewTimeline({subject:n.element||I(n.componentId)}));const u=m.map(({effect:f,options:p,id:h,part:d})=>{const E=d?Rt(r,d):r,g=new KeyframeEffect(E||null,[],p);v.mutate(()=>{"timing"in f&&g.updateTiming(f.timing),g.setKeyframes(f.keyframes)});const b=a&&l?{timeline:l}:{},y=typeof f.customEffect=="function"?new zt(f.customEffect,E||null,p,b):new Animation(g,b.timeline);if(a)if(l)v.mutate(()=>{const{start:O,end:S}=gt(f);y.rangeStart=O,y.rangeEnd=S,y.play()});else{const{startOffset:O,endOffset:S}=e;v.mutate(()=>{const N=f.startOffset||O,x=f.endOffset||S;Object.assign(y,{start:{name:N.name,offset:N.offset?.value,add:f.startOffsetAdd},end:{name:x.name,offset:x.offset?.value,add:f.endOffsetAdd}})})}return h&&(y.id=h),y});return new _(u,{...e,trigger:{...n||{}},measured:new Promise(f=>v.mutate(f))})}function jt(t,e){return t?`#${t}${e?`[data-motion-part~="${e}"]`:""}`:""}function Lt(t,e){const{duration:n,delay:i,iterations:s=1,fill:r,easing:c="linear",direction:o}=t.options,m=t.effect.name,l=n==="auto";return`${m} ${l?"auto":`${n}ms`}${l?" ":` ${i??0}ms `}${c}${r&&r!=="none"?` ${r}`:""} ${!s||s===1/0?"infinite":s}${o==="normal"?"":` ${o}`} ${e?"":"paused"}`}function Wt(t,e,n){return t?.style?(z(n)&&(e.duration=e.duration||1),t.style(e)):[]}function Ht(t,e,n){const i=A(e),s=Wt(i,e),r=Et(s,n,e.effectId,!0),c=n?.trigger==="view-progress";return r.map((o,m)=>{const{start:l,end:a}=c?gt(o.effect):{};return{target:jt(t,o.part),animation:Lt(o,c),composition:o.options.composite,custom:o.effect.custom,name:o.effect.name,keyframes:o.effect.keyframes,id:o.id&&`${o.id}-${m+1}`,animationTimeline:c?`--${n?.id}`:"",animationRange:l||a?`${l} ${a}`:""}})}function vt(t,e,n){const i=A(e),s=t instanceof HTMLElement?t:I(t);if(i&&i.prepare&&s){const r={measure:bt(s),mutate:yt(s)};i.prepare(e,r)}n&&v.mutate(n)}function Ot(t,e){const n=A(e);if(!n)return null;if(!n.style)return e.effectId&&t?It(t,e.effectId):null;const i=n.getNames(e),r=(typeof t=="string"?I(t):t)?.getAnimations(),c=r?.map(m=>m.animationName)||[],o=[];return i.forEach(m=>{c.includes(m)&&o.push(r?.find(l=>l.animationName===m))}),o?.length?new _(o):null}function It(t,e){const i=(typeof t=="string"?I(t):t)?.getAnimations().filter(s=>{const r=s.id||s.animationName;return r?r.startsWith(e):!0});return i?.length?new _(i):null}function Kt(t,e,n,i={}){const{disabled:s,allowActiveEvent:r,...c}=i,o=F(t,e,n,c);if(!o)return null;let m={};if(n.trigger==="view-progress"&&!window.ViewTimeline){const l=n.element||I(n.componentId),{ready:a}=o;return o.animations.map(u=>({get start(){return u.start},get end(){return u.end},viewSource:l,ready:a,getProgress(){return o.getProgress()},effect(f,p){const{activeDuration:h}=u.effect.getComputedTiming(),{delay:d}=u.effect.getTiming();u.currentTime=((d||0)+(h||0))*p},disabled:s,destroy(){u.cancel()}}))}else if(n.trigger==="pointer-move"){const l=e,{centeredToTarget:a,transitionDuration:u,transitionEasing:f}=l,p=n.axis;if(l.keyframeEffect){const h=o;return h.animations?.length===0?null:{target:void 0,centeredToTarget:a,ready:h.ready,_currentProgress:0,getProgress(){return this._currentProgress},effect(E,g){const b=p==="x"?g.x:g.y;this._currentProgress=b,h.progress(b)},disabled:s??!1,destroy(){h.cancel()}}}m={centeredToTarget:a,allowActiveEvent:r},e.customEffect&&u&&(m.transitionDuration=u,m.transitionEasing=C(f)),m.target=o.target}return{...m,getProgress(){return o.getProgress()},effect(l,a,u,f){o.progress(u?{...a,v:u,active:f}:a)},disabled:s,destroy(){o.cancel()}}}function At(t,e,n,i=!1){const s=Ot(t,e);return s?(s.ready=new Promise(r=>{vt(t,e,r)}),s):F(t,e,n,{reducedMotion:i})}function Vt(t){return t===null?[null]:typeof t=="string"?Array.from(document.querySelectorAll(t)):Array.isArray(t)?t:[t]}function _t(t,e){const n=[];for(const{target:i,options:s}of t){const r=Vt(i);for(const c of r){const o=At(c,s,void 0,e?.reducedMotion);o instanceof _&&n.push(o)}}return n}function Bt(t,e,n){const i=_t(e,n);return new Ct(i,t)}exports.backIn=ct;exports.backInOut=ft;exports.backOut=ut;exports.circIn=rt;exports.circInOut=at;exports.circOut=ot;exports.createAnimationGroups=_t;exports.cssEasings=q;exports.cubicIn=B;exports.cubicInOut=X;exports.cubicOut=U;exports.expoIn=nt;exports.expoInOut=st;exports.expoOut=it;exports.getAnimation=At;exports.getCSSAnimation=Ht;exports.getCssUnits=mt;exports.getEasing=pt;exports.getElementAnimation=It;exports.getElementCSSAnimation=Ot;exports.getJsEasing=C;exports.getScrubScene=Kt;exports.getSequence=Bt;exports.getWebAnimation=F;exports.jsEasings=k;exports.linear=$;exports.normalizeKeyframes=dt;exports.prepareAnimation=vt;exports.quadIn=H;exports.quadInOut=V;exports.quadOut=K;exports.quartIn=J;exports.quartInOut=Z;exports.quartOut=Y;exports.quintIn=Q;exports.quintInOut=et;exports.quintOut=tt;exports.registerEffects=Mt;exports.sineIn=j;exports.sineInOut=W;exports.sineOut=L;exports.toCSSPropertyName=Tt;exports.toWAAPIPropertyName=lt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class _{animations;options;ready;isCSS;longestAnimation;constructor(e,n){this.animations=e,this.options=n,this.ready=n?.measured||Promise.resolve(),this.isCSS=e[0]instanceof CSSAnimation,this.longestAnimation=this._getAnimationWithLongestEndTime()}_getAnimationWithLongestEndTime(){return this.animations.reduce((e,n)=>{const o=e.effect?.getComputedTiming().endTime??0,i=n.effect?.getComputedTiming().endTime??0;return o>i?e:n},this.animations[0])}getProgress(){return this.longestAnimation?.effect?.getComputedTiming().progress||0}async play(e){await this.ready;for(const n of this.animations)n.play();await Promise.all(this.animations.map(n=>n.ready)),e&&e()}pause(){for(const e of this.animations)e.pause()}async reverse(e){await this.ready;for(const n of this.animations)n.reverse();await Promise.all(this.animations.map(n=>n.ready)),e&&e()}progress(e){for(const n of this.animations){const{delay:o,duration:i,iterations:s}=n.effect.getTiming(),a=(Number.isFinite(i)?i:0)*(Number.isFinite(s)?s:1);n.currentTime=((o||0)+a)*e}}cancel(){for(const e of this.animations)e.cancel()}setPlaybackRate(e){for(const n of this.animations)n.playbackRate=e}async onFinish(e){try{await Promise.all(this.animations.map(o=>o.finished));const n=this.animations[0];if(n&&!this.isCSS){const o=n.effect?.target;if(o){const i=this.options?.effectId||n.id,s=new CustomEvent("animationend",{detail:{effectId:i}});o.dispatchEvent(s)}}e()}catch(n){console.warn("animation was interrupted - aborting onFinish callback - ",n)}}async onAbort(e){try{await Promise.all(this.animations.map(n=>n.finished))}catch(n){if(n.name==="AbortError"){const o=this.animations[0];if(o&&!this.isCSS){const i=o.effect?.target;if(i){const s=new Event("animationcancel");i.dispatchEvent(s)}}e()}}}get finished(){return Promise.all(this.animations.map(e=>e.finished))}get playState(){return this.animations.some(e=>e.playState==="running")?"running":this.animations[0]?.playState}hasAnimationName(e){return this.animations.some(n=>n.animationName===e)}hasAnimationId(e){return this.animations.some(n=>n.id===e)}getTimingOptions(){return this.animations.map(e=>{const n=e.effect?.getTiming(),o=n?.delay??0,i=Number(n?.duration)||0,s=n?.iterations??1;return{delay:o,duration:i,iterations:s}})}}const M=t=>t,B=t=>1-Math.cos(t*Math.PI/2),H=t=>Math.sin(t*Math.PI/2),K=t=>-(Math.cos(Math.PI*t)-1)/2,V=t=>t**2,J=t=>1-(1-t)**2,U=t=>t<.5?2*t**2:1-(-2*t+2)**2/2,X=t=>t**3,Y=t=>1-(1-t)**3,Z=t=>t<.5?4*t**3:1-(-2*t+2)**3/2,Q=t=>t**4,tt=t=>1-(1-t)**4,et=t=>t<.5?8*t**4:1-(-2*t+2)**4/2,nt=t=>t**5,it=t=>1-(1-t)**5,st=t=>t<.5?16*t**5:1-(-2*t+2)**5/2,ot=t=>t===0?0:2**(10*t-10),rt=t=>t===1?1:1-2**(-10*t),at=t=>t===0?0:t===1?1:t<.5?2**(20*t-10)/2:(2-2**(-20*t+10))/2,ct=t=>1-Math.sqrt(1-t**2),ut=t=>Math.sqrt(1-(t-1)**2),ft=t=>t<.5?(1-Math.sqrt(1-4*t**2))/2:(Math.sqrt(-(2*t-3)*(2*t-1))+1)/2,mt=t=>2.70158*t**3-1.70158*t**2,lt=t=>1+2.70158*(t-1)**3+1.70158*(t-1)**2,dt=(t,e=1.70158*1.525)=>t<.5?(2*t)**2*((e+1)*2*t-e)/2:((2*t-2)**2*((e+1)*(t*2-2)+e)+2)/2,C={linear:M,sineIn:B,sineOut:H,sineInOut:K,quadIn:V,quadOut:J,quadInOut:U,cubicIn:X,cubicOut:Y,cubicInOut:Z,quartIn:Q,quartOut:tt,quartInOut:et,quintIn:nt,quintOut:it,quintInOut:st,expoIn:ot,expoOut:rt,expoInOut:at,circIn:ct,circOut:ut,circInOut:ft,backIn:mt,backOut:lt,backInOut:dt},O=(t,e,n,o,i)=>{const s=3*e,a=3*(o-2*e),r=1-3*o+3*e,f=3*n,d=3*(i-2*n),c=1-3*i+3*n;let u;if(r===0)u=a===0?`(${t} / ${s})`:`((sqrt(max(0, ${s*s} + ${4*a} * ${t})) - ${s}) / ${2*a})`;else{const m=a/(3*r),p=2*Math.pow(a,3)-9*s*a*r,l=54*Math.pow(r,3),h=(3*r*s-a*a)/(9*r*r),$=`((${p} - ${27*r*r} * ${t}) / ${l})`;if(h<0){const g=2*Math.sqrt(-h);let b=0;for(const I of[0,1,2])[0,.25,.5,.75,1].every(A=>{const S=Math.min(Math.max(2*(p-27*r*r*A)/(l*h*g),-1),1),D=g*Math.cos((Math.acos(S)-I*2*Math.PI)/3)-m;return D>=-1e-6&&D<=1.000001})&&(b=I);const y=`(acos(clamp(-1, ${2/(h*g)} * ${$}, 1)) - ${360*b}deg) / 3`;u=`(${g} * cos(${y}) - ${m})`}else{const g=`sqrt(pow(${$}, 2) + ${Math.pow(h,3)})`;u=`(pow(${g} - ${$}, 1 / 3) - pow(${g} + ${$}, 1 / 3) - ${m})`}}return`(${c} * pow(${u}, 3) + ${d} * pow(${u}, 2) + ${f} * ${u})`},P={linear:t=>t,ease:t=>O(t,.25,.1,.25,1),easeIn:t=>O(t,.42,0,1,1),easeOut:t=>O(t,0,0,.58,1),easeInOut:t=>O(t,.42,0,.58,1),sineIn:t=>`(1 - cos(${t} * 90deg))`,sineOut:t=>`(sin(${t} * 90deg))`,sineInOut:t=>`((1 - cos(${t} * 180deg)) / 2)`,quadIn:t=>`(${t} * ${t})`,quadOut:t=>`(1 - (1 - ${t}) * (1 - ${t}))`,quadInOut:t=>`(round(${t}) * (1 - (-2 * ${t} + 2) * (-2 * ${t} + 2) / 2) + (1 - round(${t})) * 2 * ${t} * ${t})`,cubicIn:t=>`pow(${t}, 3)`,cubicOut:t=>`(1 - pow(1 - ${t}, 3))`,cubicInOut:t=>`(round(${t}) * (1 - pow(-2 * ${t} + 2, 3) / 2) + (1 - round(${t})) * 4 * pow(${t}, 3))`,quartIn:t=>`pow(${t}, 4)`,quartOut:t=>`(1 - pow(1 - ${t}, 4))`,quartInOut:t=>`(round(${t}) * (1 - pow(-2 * ${t} + 2, 4) / 2) + (1 - round(${t})) * 8 * pow(${t}, 4))`,quintIn:t=>`pow(${t}, 5)`,quintOut:t=>`(1 - pow(1 - ${t}, 5))`,quintInOut:t=>`(round(${t}) * (1 - pow(-2 * ${t} + 2, 5) / 2) + (1 - round(${t})) * 16 * pow(${t}, 5))`,expoIn:t=>`(pow(2, 10 * ${t} - 10) - pow(2, -10) * (1 - ${t}))`,expoOut:t=>`(1 - pow(2, -10 * ${t}) + pow(2, -10) * ${t})`,expoInOut:t=>`((round(${t}) * (2 - pow(2, -20 * ${t} + 10)) + (1 - round(${t})) * pow(2, 20 * ${t} - 10)) / 2)`,circIn:t=>`(1 - sqrt(1 - ${t} * ${t}))`,circOut:t=>`sqrt(1 - (${t} - 1) * (${t} - 1))`,circInOut:t=>`((round(${t}) * (sqrt(max(0, (3 - 2 * ${t}) * (2 * ${t} - 1))) + 1) + (1 - round(${t})) * (1 - sqrt(max(0, 1 - 4 * ${t} * ${t})))) / 2)`,backIn:t=>`(2.70158 * pow(${t}, 3) - 1.70158 * ${t} * ${t})`,backOut:t=>`(1 + 2.70158 * pow(${t} - 1, 3) + 1.70158 * (${t} - 1) * (${t} - 1))`,backInOut:t=>`((round(${t}) * (2 + (2 * ${t} - 2) * (2 * ${t} - 2) * (2.5949095 + 3.5949095 * (2 * ${t} - 2))) + (1 - round(${t})) * 4 * ${t} * ${t} * (3.5949095 * 2 * ${t} - 2.5949095)) / 2)`},z={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",sineIn:"cubic-bezier(0.47, 0, 0.745, 0.715)",sineOut:"cubic-bezier(0.39, 0.575, 0.565, 1)",sineInOut:"cubic-bezier(0.445, 0.05, 0.55, 0.95)",quadIn:"cubic-bezier(0.55, 0.085, 0.68, 0.53)",quadOut:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",quadInOut:"cubic-bezier(0.455, 0.03, 0.515, 0.955)",cubicIn:"cubic-bezier(0.55, 0.055, 0.675, 0.19)",cubicOut:"cubic-bezier(0.215, 0.61, 0.355, 1)",cubicInOut:"cubic-bezier(0.645, 0.045, 0.355, 1)",quartIn:"cubic-bezier(0.895, 0.03, 0.685, 0.22)",quartOut:"cubic-bezier(0.165, 0.84, 0.44, 1)",quartInOut:"cubic-bezier(0.77, 0, 0.175, 1)",quintIn:"cubic-bezier(0.755, 0.05, 0.855, 0.06)",quintOut:"cubic-bezier(0.23, 1, 0.32, 1)",quintInOut:"cubic-bezier(0.86, 0, 0.07, 1)",expoIn:"cubic-bezier(0.95, 0.05, 0.795, 0.035)",expoOut:"cubic-bezier(0.19, 1, 0.22, 1)",expoInOut:"cubic-bezier(1, 0, 0, 1)",circIn:"cubic-bezier(0.6, 0.04, 0.98, 0.335)",circOut:"cubic-bezier(0.075, 0.82, 0.165, 1)",circInOut:"cubic-bezier(0.785, 0.135, 0.15, 0.86)",backIn:"cubic-bezier(0.6, -0.28, 0.735, 0.045)",backOut:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",backInOut:"cubic-bezier(0.68, -0.55, 0.265, 1.55)"};function ht(t){return t==="percentage"?"%":t||"px"}const Pt=/^(webkit|moz|ms|o)(?=[A-Z])/,zt=Object.assign(Object.create(null),{float:"cssFloat","animation-timing-function":"easing","animation-composition":"composite"});function xt(t){return t.startsWith("--")?t:(Pt.test(t)?`-${t}`:t).replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}function pt(t){return t.startsWith("--")||!t.includes("-")?t:t.replace(/^-/,"").replace(/-([a-z])/g,(e,n)=>n.toUpperCase())}function gt(t){return zt[t]||pt(t)}function Mt(t){for(const e in t)if(Object.hasOwn(t,e)&&gt(e)!==e)return!0;return!1}function $t(t){if(!Array.isArray(t))return t;let e;return t.forEach((n,o)=>{if(!n||typeof n!="object"||!Mt(n))return;e??=t.slice();const i={};for(const s in n)Object.hasOwn(n,s)&&(i[gt(s)]=n[s]);e[o]=i}),e||t}function bt(t){return t?z[t]||t:z.linear}function yt(t,e,n,o){const i=3*t,s=3*(n-t)-i,a=1-i-s,r=3*e,f=3*(o-e)-r,d=1-r-f,c=l=>((a*l+s)*l+i)*l,u=l=>((d*l+f)*l+r)*l,m=l=>(3*a*l+2*s)*l+i;function p(l){let h=l;for(let b=0;b<8;b++){const y=c(h)-l;if(Math.abs(y)<1e-7)return h;const I=m(h);if(Math.abs(I)<1e-6)break;h-=y/I}let $=0,g=1;for(h=($+g)/2;g-$>1e-7;){const b=c(h);if(Math.abs(b-l)<1e-7)return h;l>b?$=h:g=h,h=($+g)/2}return h}return l=>l<=0?0:l>=1?1:u(p(l))}function It(t){const e=t.match(/^cubic-bezier\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)$/);if(!e)return;const n=parseFloat(e[1]),o=parseFloat(e[2]),i=parseFloat(e[3]),s=parseFloat(e[4]);if(![n,o,i,s].some(isNaN))return[n,o,i,s]}function Nt(t){const e=It(t);if(!(!e||e.some(isNaN)))return yt(...e)}function Ft(t){const e=It(t);if(!(!e||e.some(isNaN)))return n=>O(n,...e)}function Et(t){const e=t.match(/^linear\((.+)\)$/);if(!e)return;const n=e[1].split(",").map(s=>s.trim()).filter(Boolean);if(n.length===0)return;const o=[];for(const s of n){const a=s.split(/\s+/),r=parseFloat(a[0]);if(isNaN(r))return;const f=[];for(let d=1;d<a.length;d++)if(a[d].endsWith("%")){const c=parseFloat(a[d])/100;if(isNaN(c))return;f.push(c)}f.length===0?o.push({output:r,pos:null}):f.length===1?o.push({output:r,pos:f[0]}):(o.push({output:r,pos:f[0]}),o.push({output:r,pos:f[1]}))}if(o.length===0)return;o[0].pos===null&&(o[0].pos=0),o[o.length-1].pos===null&&(o[o.length-1].pos=1);let i=0;for(;i<o.length;)if(o[i].pos===null){const s=i-1;let a=i;for(;a<o.length&&o[a].pos===null;)a++;const r=o[s].pos,f=o[a].pos,d=a-s;for(let c=s+1;c<a;c++)o[c].pos=r+(f-r)*(c-s)/d;i=a+1}else i++;for(let s=1;s<o.length;s++)o[s].pos<o[s-1].pos&&(o[s].pos=o[s-1].pos);return o}function Gt(t){const e=Et(t);if(e)return n=>{if(n<=e[0].pos)return e[0].output;const o=e[e.length-1];if(n>=o.pos)return o.output;let i=0,s=e.length-1;for(;i<s-1;){const f=i+s>>>1;e[f].pos<=n?i=f:s=f}const a=e[i],r=e[s];return r.pos===a.pos?r.output:a.output+(r.output-a.output)*(n-a.pos)/(r.pos-a.pos)}}function Dt(t){const e=Et(t);if(e)return n=>{const o=[`${e[0].output}`];for(let i=1;i<e.length;i++){const s=e[i].pos-e[i-1].pos,a=e[i].output-e[i-1].output;if(s===0&&e[i-1].pos===0)o.push(`${a}`);else{const r=s===0?`round(${n} / ${2*e[i-1].pos})`:`(${n} - ${e[i-1].pos}) / ${s}`;o.push(`clamp(0, ${r}, 1) * ${a}`)}}return`(${o.join(" + ")})`}}function N(t){if(!t)return;const e=C[t];return e||(Nt(t)??Gt(t)??C.linear)}function Ot(t){if(!t)return;const e=P[t];return e||(Ft(t)??Dt(t)??P.linear)}class jt extends _{animationGroups;delay;offset;offsetEasing;sequenceId;timingOptions;constructor(e,n={}){const o=e.flatMap(i=>[...i.animations]);super(o),this.animationGroups=e,this.delay=n.delay??0,this.offset=n.offset??0,this.sequenceId=n.sequenceId,this.offsetEasing=typeof n.offsetEasing=="function"?n.offsetEasing:N(n.offsetEasing)??M,this.timingOptions=this.animationGroups.map(i=>i.getTimingOptions().map(({delay:s,duration:a,iterations:r})=>({delay:s,duration:Number.isFinite(a)?a:0,iterations:Number.isFinite(r)?r:1}))),this.applyOffsets(),this.ready=Promise.all(e.map(i=>i.ready)).then(()=>{})}calculateOffsets(){const e=this.animationGroups.length;if(e<=1)return[0];const n=e-1;return Array.from({length:e},(o,i)=>this.offsetEasing(i/n)*n*this.offset|0)}applyOffsets(){if(this.animationGroups.length===0||this.animations.length===0)return;const e=this.calculateOffsets(),n=this.getSequenceActiveDuration(e),o=this.animationGroups.length-1;this.animationGroups.forEach((i,s)=>{i.animations.forEach((a,r)=>{const f=a.effect;if(!f)return;const{delay:d,duration:c,iterations:u}=this.timingOptions[s][r],m=d+e[s],p=n-(m+c*u);if(i.isCSS&&this.sequenceId){const{target:l}=f;l instanceof HTMLElement&&(l.style.setProperty(`--motion-${this.sequenceId}-index`,`${s}`),l.style.setProperty(`--motion-${this.sequenceId}-last`,`${o}`)),f.updateTiming({endDelay:p})}else f.updateTiming({delay:m+this.delay,endDelay:p})})})}getSequenceActiveDuration(e){const n=[];for(let o=0;o<this.timingOptions.length;o++){const i=this.timingOptions[o].reduce((s,a)=>{if(!a)return s;const{delay:r,duration:f,iterations:d}=a;return Math.max(s,r+f*d)},0);n.push(e[o]+i)}return Math.max(...n)}addGroups(e){if(e.length===0)return;const n=[...e].sort((o,i)=>i.index-o.index);for(const{index:o,group:i}of n){const s=Math.min(o,this.animationGroups.length);this.animationGroups.splice(s,0,i),this.timingOptions.splice(s,0,i.getTimingOptions());const a=[...i.animations],r=this.animationGroups.slice(0,s).reduce((f,d)=>f+d.animations.length,0);this.animations.splice(r,0,...a)}this.applyOffsets(),this.ready=Promise.all(this.animationGroups.map(o=>o.ready)).then(()=>{})}removeGroups(e){const n=[],o=[],i=[];for(let s=0;s<this.animationGroups.length;s++)e(this.animationGroups[s])?n.push(this.animationGroups[s]):(o.push(this.animationGroups[s]),i.push(this.timingOptions[s]));if(n.length===0)return n;for(const s of n)s.cancel();return this.animationGroups=o,this.timingOptions=i,this.animations=o.flatMap(s=>[...s.animations]),this.applyOffsets(),this.ready=Promise.all(this.animationGroups.map(s=>s.ready)).then(()=>{}),n}async onFinish(e){try{await Promise.all(this.animationGroups.map(n=>n.finished)),e()}catch(n){console.warn("animation was interrupted - aborting onFinish callback - ",n)}}}class Rt{_animation;customEffect;progress;_tickCbId;_finishHandler;constructor(e,n,o,i){const s=new KeyframeEffect(n,[],{...o,composite:"add"}),{timeline:a}=i;this._animation=new Animation(s,a),this._tickCbId=null,this.progress=null,this.customEffect=r=>e(s.target,r),this._finishHandler=r=>{this.effect.target?.getAnimations().find(f=>f===this._animation)||this.cancel()},this.addEventListener("finish",this._finishHandler),this.addEventListener("remove",this._finishHandler)}_tick(){try{const e=this.effect?.getComputedTiming().progress??null;e!==this.progress&&(this.customEffect?.(e),this.progress=e),this._tickCbId=requestAnimationFrame(()=>{this._tick()})}catch(e){this._tickCbId=null,console.error(`failed to run customEffect! effectId: ${this.id}, error: ${e instanceof Error?e.message:e}`)}}get currentTime(){return this._animation.currentTime}set currentTime(e){this._animation.currentTime=e}get startTime(){return this._animation.startTime}set startTime(e){this._animation.startTime=e}get playbackRate(){return this._animation.playbackRate}set playbackRate(e){this._animation.playbackRate=e}get id(){return this._animation.id}set id(e){this._animation.id=e}get effect(){return this._animation.effect}set effect(e){this._animation.effect=e}get timeline(){return this._animation.timeline}set timeline(e){this._animation.timeline=e}get finished(){return this._animation.finished}get pending(){return this._animation.pending}get playState(){return this._animation.playState}get ready(){return this._animation.ready}get replaceState(){return this._animation.replaceState}get oncancel(){return this._animation.oncancel}set oncancel(e){this._animation.oncancel=e}get onfinish(){return this._animation.onfinish}set onfinish(e){this._animation.onfinish=e}get onremove(){return this._animation.onremove}set onremove(e){this._animation.onremove=e}play(){this._animation.play(),cancelAnimationFrame(this._tickCbId),this._tickCbId=requestAnimationFrame(()=>this._tick())}pause(){this._animation.pause(),cancelAnimationFrame(this._tickCbId),this._tickCbId=null}cancel(){this.removeEventListener("finish",this._finishHandler),this.removeEventListener("remove",this._finishHandler),this._animation.cancel(),this.customEffect(null),cancelAnimationFrame(this._tickCbId),this._tickCbId=null}commitStyles(){console.warn("CustomEffect animations do not support commitStyles method as they have no style to commit")}finish(){this._animation.finish()}persist(){this._animation.persist()}reverse(){this._animation.reverse()}updatePlaybackRate(e){this._animation.updatePlaybackRate(e)}addEventListener(e,n,o){this._animation.addEventListener(e,n,o)}removeEventListener(e,n,o){this._animation.removeEventListener(e,n,o)}dispatchEvent(e){return this._animation.dispatchEvent(e)}}function Lt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var T={exports:{}},j=T.exports,R;function Wt(){return R||(R=1,(function(t){(function(e){var n=function(){},o=e.requestAnimationFrame||e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.msRequestAnimationFrame||function(c){return setTimeout(c,16)};function i(){var c=this;c.reads=[],c.writes=[],c.raf=o.bind(e)}i.prototype={constructor:i,runTasks:function(c){for(var u;u=c.shift();)u()},measure:function(c,u){var m=u?c.bind(u):c;return this.reads.push(m),s(this),m},mutate:function(c,u){var m=u?c.bind(u):c;return this.writes.push(m),s(this),m},clear:function(c){return r(this.reads,c)||r(this.writes,c)},extend:function(c){if(typeof c!="object")throw new Error("expected object");var u=Object.create(this);return f(u,c),u.fastdom=this,u.initialize&&u.initialize(),u},catch:null};function s(c){c.scheduled||(c.scheduled=!0,c.raf(a.bind(null,c)))}function a(c){var u=c.writes,m=c.reads,p;try{n("flushing reads",m.length),c.runTasks(m),n("flushing writes",u.length),c.runTasks(u)}catch(l){p=l}if(c.scheduled=!1,(m.length||u.length)&&s(c),p)if(n("task errored",p.message),c.catch)c.catch(p);else throw p}function r(c,u){var m=c.indexOf(u);return!!~m&&!!c.splice(m,1)}function f(c,u){for(var m in u)u.hasOwnProperty(m)&&(c[m]=u[m])}var d=e.fastdom=e.fastdom||new i;t.exports=d})(typeof window<"u"?window:typeof j<"u"?j:globalThis)})(T)),T.exports}var Bt=Wt();const E=Lt(Bt),x={};function Ht(t){Object.assign(x,t)}function Kt(t){return t in x?x[t]:(console.warn(`${t} not found in registry. Please make sure to import and register the preset.`),null)}function v(t,e){return t?(e||document).getElementById(t):null}function Vt(t,e){return t?.matches(`[data-motion-part~="${e}"]`)?t:t?.querySelector(`[data-motion-part~="${e}"]`)}function Jt(t){const e=t.alternate?"alternate":"";return t.reversed?`${e?`${e}-`:""}reverse`:e||"normal"}function k(t){return`${t.value}${ht(t.unit)}`}function L(t,e,n){return`${t.name||"cover"} ${n&&t.offset.unit!=="percentage"?`calc(100% + ${k(t.offset)}${e?` + ${e}`:""})`:e?`calc(${k(t.offset)} + ${e})`:k(t.offset)}`}function vt(t){return{start:L(t.startOffset,t.startOffsetAdd),end:L(t.endOffset,t.endOffsetAdd,!0)}}function wt(t){return e=>E.measure(()=>e(t))}function _t(t){return e=>E.mutate(()=>e(t))}function w(t){if(t.namedEffect){const e=t.namedEffect.type;return typeof e=="string"?Kt(e):null}else if(t.keyframeEffect){const e=o=>{const{name:i,keyframes:s}=o.keyframeEffect;return[{...o,name:i,keyframes:s}]};return{web:e,style:e,getNames:o=>{const{effectId:i}=o,{name:s}=o.keyframeEffect,a=s||i;return a?[a]:[]}}}else if(t.customEffect)return e=>[{...e,keyframes:[]}];return null}function qt(t,e,n,o){return t.map((i,s)=>{const a={fill:i.fill,easing:bt(i.easing),iterations:i.iterations===0?1/0:i.iterations||1,composite:i.composite,direction:Jt(i)};F(e)?(a.duration=i.duration,a.delay=i.delay||0):e?.trigger==="view-progress"&&(o||window.ViewTimeline)?a.duration="auto":(a.duration=99.99,a.delay=.01);const r=$t(i.keyframes);return{effect:r===i.keyframes?i:{...i,keyframes:r},options:a,id:n&&`${n}-${s+1}`,part:i.part}})}function F(t){return!t||t.trigger!=="pointer-move"&&t.trigger!=="view-progress"}function W(t,e,n,o,i){if(t){if(F(o)&&(e.duration=e.duration||1,i?.reducedMotion))if(e.iterations===1||e.iterations==null)e={...e,duration:1};else return[];let s;return n instanceof HTMLElement&&(s={measure:wt(n),mutate:_t(n)}),t.web?t.web(e,s,i):t(e,s,i)}return[]}function G(t,e,n,o,i){const s=typeof t=="string"?v(t,i):t;if(n?.trigger==="pointer-move"&&!e.keyframeEffect){let m=e;e.customEffect&&(m={...e,namedEffect:{id:"",type:"CustomMouse"}});const p=w(m),l=W(p,e,s,n,o);return typeof l!="function"?null:l(s)}const a=w(e),r=W(a,e,s,n,o);if(!r||r.length===0)return null;const f=qt(r,n,e.effectId);let d;const c=n?.trigger==="view-progress";c&&window.ViewTimeline&&(d=new ViewTimeline({subject:n.element||v(n.componentId)}));const u=f.map(({effect:m,options:p,id:l,part:h})=>{const $=h?Vt(s,h):s,g=new KeyframeEffect($||null,[],p);E.mutate(()=>{"timing"in m&&g.updateTiming(m.timing),g.setKeyframes(m.keyframes)});const b=c&&d?{timeline:d}:{},y=typeof m.customEffect=="function"?new Rt(m.customEffect,$||null,p,b):new Animation(g,b.timeline);if(c)if(d)E.mutate(()=>{const{start:I,end:q}=vt(m);y.rangeStart=I,y.rangeEnd=q,y.play()});else{const{startOffset:I,endOffset:q}=e;E.mutate(()=>{const A=m.startOffset||I,S=m.endOffset||q;Object.assign(y,{start:{name:A.name,offset:A.offset?.value,add:m.startOffsetAdd},end:{name:S.name,offset:S.offset?.value,add:m.endOffsetAdd}})})}return l&&(y.id=l),y});return new _(u,{...e,trigger:{...n||{}},measured:new Promise(m=>E.mutate(m))})}function Ut(t,e){return t?`#${t}${e?`[data-motion-part~="${e}"]`:""}`:""}function Xt(t,e,n){const{duration:o,delay:i,iterations:s=1,fill:a,easing:r="linear",direction:f}=t.options,d=t.effect.name,c=o==="auto",{sequenceId:u,delay:m,offset:p,offsetEasing:l="linear"}=n||{};let h=`${i??0}ms`;if(u&&typeof l=="string"){const $=Ot(l);if($){const g=(i??0)+(m??0);if(p){const b=$(`(var(--motion-${u}-index, 0) / var(--motion-${u}-last, 1))`);h=`calc(${`(${g} + ${b} * ${p} * var(--motion-${u}-last, 1))`} * 1ms)`}else h=`${g}ms`}}return`${d} ${c?"auto":`${o}ms`}${c?" ":` ${h} `}${r}${a&&a!=="none"?` ${a}`:""} ${!s||s===1/0?"infinite":s}${f==="normal"?"":` ${f}`} ${e?"":"paused"}`}function Yt(t,e,n){return t?.style?(F(n)&&(e.duration=e.duration||1),t.style(e)):[]}function Zt(t,e,n,o){const i=w(e),s=Yt(i,e),a=qt(s,n,e.effectId,!0),r=n?.trigger==="view-progress";return a.map((f,d)=>{const{start:c,end:u}=r?vt(f.effect):{};return{target:Ut(t,f.part),animation:Xt(f,r,o),composition:f.options.composite,custom:f.effect.custom,name:f.effect.name,keyframes:f.effect.keyframes,id:f.id&&`${f.id}-${d+1}`,animationTimeline:r?`--${n?.id}`:"",animationRange:c||u?`${c} ${u}`:""}})}function At(t,e,n){const o=w(e),i=t instanceof HTMLElement?t:v(t);if(o&&o.prepare&&i){const s={measure:wt(i),mutate:_t(i)};o.prepare(e,s)}n&&E.mutate(n)}function St(t,e){const n=w(e);if(!n)return null;if(!n.style)return e.effectId&&t?Tt(t,e.effectId):null;const o=n.getNames(e),s=(typeof t=="string"?v(t):t)?.getAnimations(),a=s?.map(f=>f.animationName)||[],r=[];return o.forEach(f=>{a.includes(f)&&r.push(s?.find(d=>d.animationName===f))}),r?.length?new _(r):null}function Tt(t,e){const o=(typeof t=="string"?v(t):t)?.getAnimations().filter(i=>{const s=i.id||i.animationName;return s?s.startsWith(e):!0});return o?.length?new _(o):null}function Qt(t,e,n,o={}){const{disabled:i,allowActiveEvent:s,...a}=o,r=G(t,e,n,a);if(!r)return null;let f={};if(n.trigger==="view-progress"&&!window.ViewTimeline){const d=n.element||v(n.componentId),{ready:c}=r;return r.animations.map(u=>({get start(){return u.start},get end(){return u.end},viewSource:d,ready:c,getProgress(){return r.getProgress()},effect(m,p){const{activeDuration:l}=u.effect.getComputedTiming(),{delay:h}=u.effect.getTiming();u.currentTime=((h||0)+(l||0))*p},disabled:i,destroy(){u.cancel()}}))}else if(n.trigger==="pointer-move"){const d=e,{centeredToTarget:c,transitionDuration:u,transitionEasing:m}=d,p=n.axis;if(d.keyframeEffect){const l=r;return l.animations?.length===0?null:{target:void 0,centeredToTarget:c,ready:l.ready,_currentProgress:0,getProgress(){return this._currentProgress},effect($,g){const b=p==="x"?g.x:g.y;this._currentProgress=b,l.progress(b)},disabled:i??!1,destroy(){l.cancel()}}}f={centeredToTarget:c,allowActiveEvent:s},e.customEffect&&u&&(f.transitionDuration=u,f.transitionEasing=N(m)),f.target=r.target}return{...f,getProgress(){return r.getProgress()},effect(d,c,u,m){r.progress(u?{...c,v:u,active:m}:c)},disabled:i,destroy(){r.cancel()}}}function kt(t,e,n,o=!1){const i=St(t,e);return i?(i.ready=new Promise(s=>{At(t,e,s)}),i):G(t,e,n,{reducedMotion:o})}function te(t){return t===null?[null]:typeof t=="string"?Array.from(document.querySelectorAll(t)):Array.isArray(t)?t:[t]}function Ct(t,e){const n=[];for(const{target:o,options:i}of t){const s=te(o);for(const a of s){const r=kt(a,i,void 0,e?.reducedMotion);r instanceof _&&n.push(r)}}return n}function ee(t,e,n){const o=Ct(e,n);return new jt(o,t)}exports.backIn=mt;exports.backInOut=dt;exports.backOut=lt;exports.circIn=ct;exports.circInOut=ft;exports.circOut=ut;exports.createAnimationGroups=Ct;exports.cssEasings=z;exports.cubicBezierCalc=O;exports.cubicBezierEasing=yt;exports.cubicIn=X;exports.cubicInOut=Z;exports.cubicOut=Y;exports.expoIn=ot;exports.expoInOut=at;exports.expoOut=rt;exports.getAnimation=kt;exports.getCSSAnimation=Zt;exports.getCssUnits=ht;exports.getEasing=bt;exports.getElementAnimation=Tt;exports.getElementCSSAnimation=St;exports.getJsEasing=N;exports.getJsEasingInCSS=Ot;exports.getScrubScene=Qt;exports.getSequence=ee;exports.getWebAnimation=G;exports.jsEasings=C;exports.jsEasingsInCSS=P;exports.linear=M;exports.normalizeKeyframes=$t;exports.prepareAnimation=At;exports.quadIn=V;exports.quadInOut=U;exports.quadOut=J;exports.quartIn=Q;exports.quartInOut=et;exports.quartOut=tt;exports.quintIn=nt;exports.quintInOut=st;exports.quintOut=it;exports.registerEffects=Ht;exports.sineIn=B;exports.sineInOut=K;exports.sineOut=H;exports.toCSSPropertyName=xt;exports.toWAAPIPropertyName=pt;
2
2
  //# sourceMappingURL=motion.js.map