2 lines
9.4 KiB
JavaScript
Raw Permalink Normal View History

2025-06-21 23:30:33 +03:00
const t=(t,e,n)=>Math.min(Math.max(n,t),e),e={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},n=t=>"number"==typeof t,i=t=>Array.isArray(t)&&!n(t[0]),a=(t,e,n)=>{const i=e-t;return((n-t)%i+i)%i+t};const s=(t,e,n)=>-n*t+n*e+t,r=()=>{},o=t=>t,l=(t,e,n)=>e-t==0?1:(n-t)/(e-t);function c(t,e){const n=t[t.length-1];for(let i=1;i<=e;i++){const a=l(0,e,i);t.push(s(n,1,a))}}function u(e,n=function(t){const e=[0];return c(e,t-1),e}(e.length),r=o){const u=e.length,h=u-n.length;return h>0&&c(n,h),o=>{let c=0;for(;c<u-2&&!(o<n[c+1]);c++);let h=t(0,1,l(n[c],n[c+1],o));const d=function(t,e){return i(t)?t[a(0,t.length,e)]:t}(r,c);return h=d(h),s(e[c],e[c+1],h)}}const h=t=>Array.isArray(t)&&n(t[0]),d=t=>"object"==typeof t&&Boolean(t.createAnimation),f=t=>"function"==typeof t,m=t=>"string"==typeof t,p={ms:t=>1e3*t,s:t=>t/1e3},y=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,g=1e-7,v=12;function w(t,e,n,i){if(t===e&&n===i)return o;const a=e=>function(t,e,n,i,a){let s,r,o=0;do{r=e+(n-e)/2,s=y(r,i,a)-t,s>0?n=r:e=r}while(Math.abs(s)>g&&++o<v);return r}(e,0,1,t,n);return t=>0===t||1===t?t:y(a(t),e,i)}const T={ease:w(.25,.1,.25,1),"ease-in":w(.42,0,1,1),"ease-in-out":w(.42,0,.58,1),"ease-out":w(0,0,.58,1)},S=/\((.*?)\)/;function D(e){if(f(e))return e;if(h(e))return w(...e);const n=T[e];if(n)return n;if(e.startsWith("steps")){const n=S.exec(e);if(n){const e=n[1].split(",");return((e,n="end")=>i=>{const a=(i="end"===n?Math.min(i,.999):Math.max(i,.001))*e,s="end"===n?Math.floor(a):Math.ceil(a);return t(0,1,s/e)})(parseFloat(e[0]),e[1].trim())}}return o}var b=function(){};"production"!==process.env.NODE_ENV&&(b=function(t,e){if(!t)throw new Error(e)});class A{setAnimation(t){this.animation=t,null==t||t.finished.then((()=>this.clearAnimation())).catch((()=>{}))}clearAnimation(){this.animation=this.generator=void 0}}const x=new WeakMap;function O(t){return x.has(t)||x.set(t,{transforms:[],values:new Map}),x.get(t)}const k=["","X","Y","Z"],E={x:"translateX",y:"translateY",z:"translateZ"},M={syntax:"<angle>",initialValue:"0deg",toDefaultUnit:t=>t+"deg"},R={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:M,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:o},skew:M},P=new Map,j=t=>`--motion-${t}`,V=["x","y","z"];["translate","scale","rotate","skew"].forEach((t=>{k.forEach((e=>{V.push(t+e),P.set(j(t+e),R[t])}))}));const $=(t,e)=>V.indexOf(t)-V.indexOf(e),q=new Set(V),F=t=>q.has(t),N=(t,e)=>{E[e]&&(e=E[e]);const{transforms:n}=O(t);var i,a;a=e,-1===(i=n).indexOf(a)&&i.push(a),t.style.transform=U(n)},U=t=>t.sort($).reduce(_,"").trim(),_=(t,e)=>`${t} ${e}(var(${j(e)}))`,B=t=>t.startsWith("--"),C=new Set;const I=(t,e)=>document.createElement("div").animate(t,e),z={cssRegisterProperty:()=>"undefined"!=typeof CSS&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{I({opacity:[1]})}catch(t){return!1}return!0},finished:()=>Boolean(I({opacity:[0,1]},{duration:.001}).finished),linearEasing:()=>{try{I({opacity:0},{easing:"linear(0, 1)"})}catch(t){return!1}return!0}},W={},K={};for(const t in z)K[t]=()=>(void 0===W[t]&&(W[t]=z[t]()),W[t]);const X=(t,n)=>f(t)?K.linearEasing()?`linear(${((t,e)=>{let n="";const i=Math.round(e/.015);for(let e=0;e<i;e++)n+=t(l(0,i-1,e))+", ";return n.substring(0,n.length-2)})(t,n)})`:e.easing:h(t)?Y(t):t,Y=([t,e,n,i])=>`cubic-bezier(${t}, ${e}, ${n}, ${i})`;const Z=t=>Array.isArray(t)?t:[t];function L(t){return E[t]&&(t=E[t]),F(t)?j(t):t}const G={get:(t,e)=>{e=L(e);let n=B(e)?t.style.getPropertyValue(e):getComputedStyle(t)[e];if(!n&&0!==n){const t=P.get(e);t&&(n=t.initialValue)}return n},set:(t,e,n)=>{e=L(e),B(e)?t.style.setProperty(e,n):t.style[e]=n}};function H(t,e=!0){if(t&&"finished"!==t.playState)try{t.stop?t.stop():(e&&t.commitStyles(),t.cancel())}catch(t){}}function J(t,a,s,l={},c){const u=window.__MOTION_DEV_TOOLS_RECORD,h=!1!==l.record&&u;let y,{duration:g=e.duration,delay:v=e.delay,endDelay:w=e.endDelay,repeat:T=e.repeat,easing:S=e.easing,persist:D=!1,direction:b,offset:x,allowWebkitAcce