@wix/motion 2.1.14 → 2.1.16

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.
@@ -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 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;
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 zt=/^(webkit|moz|ms|o)(?=[A-Z])/,xt=Object.assign(Object.create(null),{float:"cssFloat","animation-timing-function":"easing","animation-composition":"composite"});function Mt(t){return t.startsWith("--")?t:(zt.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 xt[t]||pt(t)}function Nt(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"||!Nt(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 Ft(t){const e=It(t);if(!(!e||e.some(isNaN)))return yt(...e)}function Gt(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 Dt(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 jt(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||(Ft(t)??Dt(t)??C.linear)}function Ot(t){if(!t)return;const e=P[t];return e||(Gt(t)??jt(t)??P.linear)}class Rt 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 Lt{_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 Wt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var T={exports:{}},j=T.exports,R;function Bt(){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 Ht=Bt();const E=Wt(Ht),x={};function Kt(t){Object.assign(x,t)}function vt(t,e=!0){return t in x?x[t]:(e&&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 wt(t){return{start:L(t.startOffset,t.startOffsetAdd),end:L(t.endOffset,t.endOffsetAdd,!0)}}function _t(t){return e=>E.measure(()=>e(t))}function qt(t){return e=>E.mutate(()=>e(t))}function w(t){if(t.namedEffect){const e=t.namedEffect.type;return typeof e=="string"?vt(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 At(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:_t(n),mutate:qt(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=At(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 Lt(m.customEffect,$||null,p,b):new Animation(g,b.timeline);if(c)if(d)E.mutate(()=>{const{start:I,end:q}=wt(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=At(s,n,e.effectId,!0),r=n?.trigger==="view-progress";return a.map((f,d)=>{const{start:c,end:u}=r?wt(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 St(t,e,n){const o=w(e),i=t instanceof HTMLElement?t:v(t);if(o&&o.prepare&&i){const s={measure:_t(i),mutate:qt(i)};o.prepare(e,s)}n&&E.mutate(n)}function Tt(t,e){const n=w(e);if(!n)return null;if(!n.style)return e.effectId&&t?kt(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 kt(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 Ct(t,e,n,o=!1){const i=Tt(t,e);return i?(i.ready=new Promise(s=>{St(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 Pt(t,e){const n=[];for(const{target:o,options:i}of t){const s=te(o);for(const a of s){const r=Ct(a,i,void 0,e?.reducedMotion);r instanceof _&&n.push(r)}}return n}function ee(t,e,n){const o=Pt(e,n);return new Rt(o,t)}exports.backIn=mt;exports.backInOut=dt;exports.backOut=lt;exports.circIn=ct;exports.circInOut=ft;exports.circOut=ut;exports.createAnimationGroups=Pt;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=Ct;exports.getCSSAnimation=Zt;exports.getCssUnits=ht;exports.getEasing=bt;exports.getElementAnimation=kt;exports.getElementCSSAnimation=Tt;exports.getJsEasing=N;exports.getJsEasingInCSS=Ot;exports.getRegisteredEffect=vt;exports.getScrubScene=Qt;exports.getSequence=ee;exports.getWebAnimation=G;exports.jsEasings=C;exports.jsEasingsInCSS=P;exports.linear=M;exports.normalizeKeyframes=$t;exports.prepareAnimation=St;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=Kt;exports.sineIn=B;exports.sineInOut=K;exports.sineOut=H;exports.toCSSPropertyName=Mt;exports.toWAAPIPropertyName=pt;
2
2
  //# sourceMappingURL=motion.js.map