@vueuse_motion.js 86 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067
  1. import {
  2. identity,
  3. isClient,
  4. isObject,
  5. noop,
  6. notNullish,
  7. toValue,
  8. tryOnScopeDispose,
  9. tryOnUnmounted
  10. } from "./chunk-6366KF45.js";
  11. import {
  12. computed2 as computed,
  13. defineComponent,
  14. getCurrentInstance,
  15. h,
  16. isHTMLTag,
  17. isRef,
  18. onMounted,
  19. onUpdated,
  20. reactive,
  21. ref,
  22. resolveComponent,
  23. unref,
  24. useSlots,
  25. watch,
  26. watchEffect
  27. } from "./chunk-RDKJTCL2.js";
  28. import "./chunk-HM4MQYWN.js";
  29. // node_modules/defu/dist/defu.mjs
  30. function isPlainObject(value) {
  31. if (value === null || typeof value !== "object") {
  32. return false;
  33. }
  34. const prototype = Object.getPrototypeOf(value);
  35. if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
  36. return false;
  37. }
  38. if (Symbol.iterator in value) {
  39. return false;
  40. }
  41. if (Symbol.toStringTag in value) {
  42. return Object.prototype.toString.call(value) === "[object Module]";
  43. }
  44. return true;
  45. }
  46. function _defu(baseObject, defaults, namespace = ".", merger) {
  47. if (!isPlainObject(defaults)) {
  48. return _defu(baseObject, {}, namespace, merger);
  49. }
  50. const object = Object.assign({}, defaults);
  51. for (const key in baseObject) {
  52. if (key === "__proto__" || key === "constructor") {
  53. continue;
  54. }
  55. const value = baseObject[key];
  56. if (value === null || value === void 0) {
  57. continue;
  58. }
  59. if (merger && merger(object, key, value, namespace)) {
  60. continue;
  61. }
  62. if (Array.isArray(value) && Array.isArray(object[key])) {
  63. object[key] = [...value, ...object[key]];
  64. } else if (isPlainObject(value) && isPlainObject(object[key])) {
  65. object[key] = _defu(
  66. value,
  67. object[key],
  68. (namespace ? `${namespace}.` : "") + key.toString(),
  69. merger
  70. );
  71. } else {
  72. object[key] = value;
  73. }
  74. }
  75. return object;
  76. }
  77. function createDefu(merger) {
  78. return (...arguments_) => (
  79. // eslint-disable-next-line unicorn/no-array-reduce
  80. arguments_.reduce((p, c2) => _defu(p, c2, "", merger), {})
  81. );
  82. }
  83. var defu = createDefu();
  84. var defuFn = createDefu((object, key, currentValue) => {
  85. if (object[key] !== void 0 && typeof currentValue === "function") {
  86. object[key] = currentValue(object[key]);
  87. return true;
  88. }
  89. });
  90. var defuArrayFn = createDefu((object, key, currentValue) => {
  91. if (Array.isArray(object[key]) && typeof currentValue === "function") {
  92. object[key] = currentValue(object[key]);
  93. return true;
  94. }
  95. });
  96. // node_modules/@vueuse/motion/node_modules/vue-demi/lib/index.mjs
  97. var isVue2 = false;
  98. // node_modules/@vueuse/motion/node_modules/@vueuse/core/index.mjs
  99. function unrefElement(elRef) {
  100. var _a;
  101. const plain = toValue(elRef);
  102. return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
  103. }
  104. var defaultWindow = isClient ? window : void 0;
  105. var defaultDocument = isClient ? window.document : void 0;
  106. var defaultNavigator = isClient ? window.navigator : void 0;
  107. var defaultLocation = isClient ? window.location : void 0;
  108. function useEventListener(...args) {
  109. let target;
  110. let events;
  111. let listeners;
  112. let options;
  113. if (typeof args[0] === "string" || Array.isArray(args[0])) {
  114. [events, listeners, options] = args;
  115. target = defaultWindow;
  116. } else {
  117. [target, events, listeners, options] = args;
  118. }
  119. if (!target)
  120. return noop;
  121. if (!Array.isArray(events))
  122. events = [events];
  123. if (!Array.isArray(listeners))
  124. listeners = [listeners];
  125. const cleanups = [];
  126. const cleanup = () => {
  127. cleanups.forEach((fn) => fn());
  128. cleanups.length = 0;
  129. };
  130. const register = (el, event, listener, options2) => {
  131. el.addEventListener(event, listener, options2);
  132. return () => el.removeEventListener(event, listener, options2);
  133. };
  134. const stopWatch = watch(
  135. () => [unrefElement(target), toValue(options)],
  136. ([el, options2]) => {
  137. cleanup();
  138. if (!el)
  139. return;
  140. const optionsClone = isObject(options2) ? { ...options2 } : options2;
  141. cleanups.push(
  142. ...events.flatMap((event) => {
  143. return listeners.map((listener) => register(el, event, listener, optionsClone));
  144. })
  145. );
  146. },
  147. { immediate: true, flush: "post" }
  148. );
  149. const stop = () => {
  150. stopWatch();
  151. cleanup();
  152. };
  153. tryOnScopeDispose(stop);
  154. return stop;
  155. }
  156. function useMounted() {
  157. const isMounted = ref(false);
  158. const instance = getCurrentInstance();
  159. if (instance) {
  160. onMounted(() => {
  161. isMounted.value = true;
  162. }, isVue2 ? null : instance);
  163. }
  164. return isMounted;
  165. }
  166. function useSupported(callback) {
  167. const isMounted = useMounted();
  168. return computed(() => {
  169. isMounted.value;
  170. return Boolean(callback());
  171. });
  172. }
  173. function useMediaQuery(query, options = {}) {
  174. const { window: window2 = defaultWindow } = options;
  175. const isSupported = useSupported(() => window2 && "matchMedia" in window2 && typeof window2.matchMedia === "function");
  176. let mediaQuery;
  177. const matches = ref(false);
  178. const handler = (event) => {
  179. matches.value = event.matches;
  180. };
  181. const cleanup = () => {
  182. if (!mediaQuery)
  183. return;
  184. if ("removeEventListener" in mediaQuery)
  185. mediaQuery.removeEventListener("change", handler);
  186. else
  187. mediaQuery.removeListener(handler);
  188. };
  189. const stopWatch = watchEffect(() => {
  190. if (!isSupported.value)
  191. return;
  192. cleanup();
  193. mediaQuery = window2.matchMedia(toValue(query));
  194. if ("addEventListener" in mediaQuery)
  195. mediaQuery.addEventListener("change", handler);
  196. else
  197. mediaQuery.addListener(handler);
  198. matches.value = mediaQuery.matches;
  199. });
  200. tryOnScopeDispose(() => {
  201. stopWatch();
  202. cleanup();
  203. mediaQuery = void 0;
  204. });
  205. return matches;
  206. }
  207. var _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
  208. var globalKey = "__vueuse_ssr_handlers__";
  209. var handlers = getHandlers();
  210. function getHandlers() {
  211. if (!(globalKey in _global))
  212. _global[globalKey] = _global[globalKey] || {};
  213. return _global[globalKey];
  214. }
  215. function useIntersectionObserver(target, callback, options = {}) {
  216. const {
  217. root,
  218. rootMargin = "0px",
  219. threshold = 0.1,
  220. window: window2 = defaultWindow,
  221. immediate = true
  222. } = options;
  223. const isSupported = useSupported(() => window2 && "IntersectionObserver" in window2);
  224. const targets = computed(() => {
  225. const _target = toValue(target);
  226. return (Array.isArray(_target) ? _target : [_target]).map(unrefElement).filter(notNullish);
  227. });
  228. let cleanup = noop;
  229. const isActive = ref(immediate);
  230. const stopWatch = isSupported.value ? watch(
  231. () => [targets.value, unrefElement(root), isActive.value],
  232. ([targets2, root2]) => {
  233. cleanup();
  234. if (!isActive.value)
  235. return;
  236. if (!targets2.length)
  237. return;
  238. const observer = new IntersectionObserver(
  239. callback,
  240. {
  241. root: unrefElement(root2),
  242. rootMargin,
  243. threshold
  244. }
  245. );
  246. targets2.forEach((el) => el && observer.observe(el));
  247. cleanup = () => {
  248. observer.disconnect();
  249. cleanup = noop;
  250. };
  251. },
  252. { immediate, flush: "post" }
  253. ) : noop;
  254. const stop = () => {
  255. cleanup();
  256. stopWatch();
  257. isActive.value = false;
  258. };
  259. tryOnScopeDispose(stop);
  260. return {
  261. isSupported,
  262. isActive,
  263. pause() {
  264. cleanup();
  265. isActive.value = false;
  266. },
  267. resume() {
  268. isActive.value = true;
  269. },
  270. stop
  271. };
  272. }
  273. var defaultState = {
  274. x: 0,
  275. y: 0,
  276. pointerId: 0,
  277. pressure: 0,
  278. tiltX: 0,
  279. tiltY: 0,
  280. width: 0,
  281. height: 0,
  282. twist: 0,
  283. pointerType: null
  284. };
  285. var keys = Object.keys(defaultState);
  286. var DEFAULT_UNITS = [
  287. { max: 6e4, value: 1e3, name: "second" },
  288. { max: 276e4, value: 6e4, name: "minute" },
  289. { max: 72e6, value: 36e5, name: "hour" },
  290. { max: 5184e5, value: 864e5, name: "day" },
  291. { max: 24192e5, value: 6048e5, name: "week" },
  292. { max: 28512e6, value: 2592e6, name: "month" },
  293. { max: Number.POSITIVE_INFINITY, value: 31536e6, name: "year" }
  294. ];
  295. var _TransitionPresets = {
  296. easeInSine: [0.12, 0, 0.39, 0],
  297. easeOutSine: [0.61, 1, 0.88, 1],
  298. easeInOutSine: [0.37, 0, 0.63, 1],
  299. easeInQuad: [0.11, 0, 0.5, 0],
  300. easeOutQuad: [0.5, 1, 0.89, 1],
  301. easeInOutQuad: [0.45, 0, 0.55, 1],
  302. easeInCubic: [0.32, 0, 0.67, 0],
  303. easeOutCubic: [0.33, 1, 0.68, 1],
  304. easeInOutCubic: [0.65, 0, 0.35, 1],
  305. easeInQuart: [0.5, 0, 0.75, 0],
  306. easeOutQuart: [0.25, 1, 0.5, 1],
  307. easeInOutQuart: [0.76, 0, 0.24, 1],
  308. easeInQuint: [0.64, 0, 0.78, 0],
  309. easeOutQuint: [0.22, 1, 0.36, 1],
  310. easeInOutQuint: [0.83, 0, 0.17, 1],
  311. easeInExpo: [0.7, 0, 0.84, 0],
  312. easeOutExpo: [0.16, 1, 0.3, 1],
  313. easeInOutExpo: [0.87, 0, 0.13, 1],
  314. easeInCirc: [0.55, 0, 1, 0.45],
  315. easeOutCirc: [0, 0.55, 0.45, 1],
  316. easeInOutCirc: [0.85, 0, 0.15, 1],
  317. easeInBack: [0.36, 0, 0.66, -0.56],
  318. easeOutBack: [0.34, 1.56, 0.64, 1],
  319. easeInOutBack: [0.68, -0.6, 0.32, 1.6]
  320. };
  321. var TransitionPresets = Object.assign({}, { linear: identity }, _TransitionPresets);
  322. // node_modules/framesync/dist/es/on-next-frame.mjs
  323. var defaultTimestep = 1 / 60 * 1e3;
  324. var getCurrentTime = typeof performance !== "undefined" ? () => performance.now() : () => Date.now();
  325. var onNextFrame = typeof window !== "undefined" ? (callback) => window.requestAnimationFrame(callback) : (callback) => setTimeout(() => callback(getCurrentTime()), defaultTimestep);
  326. // node_modules/framesync/dist/es/create-render-step.mjs
  327. function createRenderStep(runNextFrame2) {
  328. let toRun = [];
  329. let toRunNextFrame = [];
  330. let numToRun = 0;
  331. let isProcessing2 = false;
  332. let flushNextFrame = false;
  333. const toKeepAlive = /* @__PURE__ */ new WeakSet();
  334. const step = {
  335. schedule: (callback, keepAlive = false, immediate = false) => {
  336. const addToCurrentFrame = immediate && isProcessing2;
  337. const buffer = addToCurrentFrame ? toRun : toRunNextFrame;
  338. if (keepAlive)
  339. toKeepAlive.add(callback);
  340. if (buffer.indexOf(callback) === -1) {
  341. buffer.push(callback);
  342. if (addToCurrentFrame && isProcessing2)
  343. numToRun = toRun.length;
  344. }
  345. return callback;
  346. },
  347. cancel: (callback) => {
  348. const index = toRunNextFrame.indexOf(callback);
  349. if (index !== -1)
  350. toRunNextFrame.splice(index, 1);
  351. toKeepAlive.delete(callback);
  352. },
  353. process: (frameData) => {
  354. if (isProcessing2) {
  355. flushNextFrame = true;
  356. return;
  357. }
  358. isProcessing2 = true;
  359. [toRun, toRunNextFrame] = [toRunNextFrame, toRun];
  360. toRunNextFrame.length = 0;
  361. numToRun = toRun.length;
  362. if (numToRun) {
  363. for (let i = 0; i < numToRun; i++) {
  364. const callback = toRun[i];
  365. callback(frameData);
  366. if (toKeepAlive.has(callback)) {
  367. step.schedule(callback);
  368. runNextFrame2();
  369. }
  370. }
  371. }
  372. isProcessing2 = false;
  373. if (flushNextFrame) {
  374. flushNextFrame = false;
  375. step.process(frameData);
  376. }
  377. }
  378. };
  379. return step;
  380. }
  381. // node_modules/framesync/dist/es/index.mjs
  382. var maxElapsed = 40;
  383. var useDefaultElapsed = true;
  384. var runNextFrame = false;
  385. var isProcessing = false;
  386. var frame = {
  387. delta: 0,
  388. timestamp: 0
  389. };
  390. var stepsOrder = [
  391. "read",
  392. "update",
  393. "preRender",
  394. "render",
  395. "postRender"
  396. ];
  397. var steps = stepsOrder.reduce((acc, key) => {
  398. acc[key] = createRenderStep(() => runNextFrame = true);
  399. return acc;
  400. }, {});
  401. var sync = stepsOrder.reduce((acc, key) => {
  402. const step = steps[key];
  403. acc[key] = (process2, keepAlive = false, immediate = false) => {
  404. if (!runNextFrame)
  405. startLoop();
  406. return step.schedule(process2, keepAlive, immediate);
  407. };
  408. return acc;
  409. }, {});
  410. var cancelSync = stepsOrder.reduce((acc, key) => {
  411. acc[key] = steps[key].cancel;
  412. return acc;
  413. }, {});
  414. var flushSync = stepsOrder.reduce((acc, key) => {
  415. acc[key] = () => steps[key].process(frame);
  416. return acc;
  417. }, {});
  418. var processStep = (stepId) => steps[stepId].process(frame);
  419. var processFrame = (timestamp2) => {
  420. runNextFrame = false;
  421. frame.delta = useDefaultElapsed ? defaultTimestep : Math.max(Math.min(timestamp2 - frame.timestamp, maxElapsed), 1);
  422. frame.timestamp = timestamp2;
  423. isProcessing = true;
  424. stepsOrder.forEach(processStep);
  425. isProcessing = false;
  426. if (runNextFrame) {
  427. useDefaultElapsed = false;
  428. onNextFrame(processFrame);
  429. }
  430. };
  431. var startLoop = () => {
  432. runNextFrame = true;
  433. useDefaultElapsed = true;
  434. if (!isProcessing)
  435. onNextFrame(processFrame);
  436. };
  437. var getFrameData = () => frame;
  438. var es_default = sync;
  439. // node_modules/tslib/tslib.es6.js
  440. function __rest(s, e) {
  441. var t = {};
  442. for (var p in s)
  443. if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  444. t[p] = s[p];
  445. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  446. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  447. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  448. t[p[i]] = s[p[i]];
  449. }
  450. return t;
  451. }
  452. // node_modules/hey-listen/dist/hey-listen.es.js
  453. var warning = function() {
  454. };
  455. var invariant = function() {
  456. };
  457. if (true) {
  458. warning = function(check, message) {
  459. if (!check && typeof console !== "undefined") {
  460. console.warn(message);
  461. }
  462. };
  463. invariant = function(check, message) {
  464. if (!check) {
  465. throw new Error(message);
  466. }
  467. };
  468. }
  469. // node_modules/popmotion/dist/es/utils/clamp.mjs
  470. var clamp2 = (min, max, v) => Math.min(Math.max(v, min), max);
  471. // node_modules/popmotion/dist/es/animations/utils/find-spring.mjs
  472. var safeMin = 1e-3;
  473. var minDuration = 0.01;
  474. var maxDuration = 10;
  475. var minDamping = 0.05;
  476. var maxDamping = 1;
  477. function findSpring({ duration = 800, bounce = 0.25, velocity = 0, mass = 1 }) {
  478. let envelope;
  479. let derivative;
  480. warning(duration <= maxDuration * 1e3, "Spring duration must be 10 seconds or less");
  481. let dampingRatio = 1 - bounce;
  482. dampingRatio = clamp2(minDamping, maxDamping, dampingRatio);
  483. duration = clamp2(minDuration, maxDuration, duration / 1e3);
  484. if (dampingRatio < 1) {
  485. envelope = (undampedFreq2) => {
  486. const exponentialDecay = undampedFreq2 * dampingRatio;
  487. const delta = exponentialDecay * duration;
  488. const a2 = exponentialDecay - velocity;
  489. const b2 = calcAngularFreq(undampedFreq2, dampingRatio);
  490. const c2 = Math.exp(-delta);
  491. return safeMin - a2 / b2 * c2;
  492. };
  493. derivative = (undampedFreq2) => {
  494. const exponentialDecay = undampedFreq2 * dampingRatio;
  495. const delta = exponentialDecay * duration;
  496. const d = delta * velocity + velocity;
  497. const e = Math.pow(dampingRatio, 2) * Math.pow(undampedFreq2, 2) * duration;
  498. const f = Math.exp(-delta);
  499. const g = calcAngularFreq(Math.pow(undampedFreq2, 2), dampingRatio);
  500. const factor = -envelope(undampedFreq2) + safeMin > 0 ? -1 : 1;
  501. return factor * ((d - e) * f) / g;
  502. };
  503. } else {
  504. envelope = (undampedFreq2) => {
  505. const a2 = Math.exp(-undampedFreq2 * duration);
  506. const b2 = (undampedFreq2 - velocity) * duration + 1;
  507. return -safeMin + a2 * b2;
  508. };
  509. derivative = (undampedFreq2) => {
  510. const a2 = Math.exp(-undampedFreq2 * duration);
  511. const b2 = (velocity - undampedFreq2) * (duration * duration);
  512. return a2 * b2;
  513. };
  514. }
  515. const initialGuess = 5 / duration;
  516. const undampedFreq = approximateRoot(envelope, derivative, initialGuess);
  517. duration = duration * 1e3;
  518. if (isNaN(undampedFreq)) {
  519. return {
  520. stiffness: 100,
  521. damping: 10,
  522. duration
  523. };
  524. } else {
  525. const stiffness = Math.pow(undampedFreq, 2) * mass;
  526. return {
  527. stiffness,
  528. damping: dampingRatio * 2 * Math.sqrt(mass * stiffness),
  529. duration
  530. };
  531. }
  532. }
  533. var rootIterations = 12;
  534. function approximateRoot(envelope, derivative, initialGuess) {
  535. let result = initialGuess;
  536. for (let i = 1; i < rootIterations; i++) {
  537. result = result - envelope(result) / derivative(result);
  538. }
  539. return result;
  540. }
  541. function calcAngularFreq(undampedFreq, dampingRatio) {
  542. return undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
  543. }
  544. // node_modules/popmotion/dist/es/animations/generators/spring.mjs
  545. var durationKeys = ["duration", "bounce"];
  546. var physicsKeys = ["stiffness", "damping", "mass"];
  547. function isSpringType(options, keys2) {
  548. return keys2.some((key) => options[key] !== void 0);
  549. }
  550. function getSpringOptions(options) {
  551. let springOptions = Object.assign({ velocity: 0, stiffness: 100, damping: 10, mass: 1, isResolvedFromDuration: false }, options);
  552. if (!isSpringType(options, physicsKeys) && isSpringType(options, durationKeys)) {
  553. const derived = findSpring(options);
  554. springOptions = Object.assign(Object.assign(Object.assign({}, springOptions), derived), { velocity: 0, mass: 1 });
  555. springOptions.isResolvedFromDuration = true;
  556. }
  557. return springOptions;
  558. }
  559. function spring(_a) {
  560. var { from = 0, to = 1, restSpeed = 2, restDelta } = _a, options = __rest(_a, ["from", "to", "restSpeed", "restDelta"]);
  561. const state = { done: false, value: from };
  562. let { stiffness, damping, mass, velocity, duration, isResolvedFromDuration } = getSpringOptions(options);
  563. let resolveSpring = zero;
  564. let resolveVelocity = zero;
  565. function createSpring() {
  566. const initialVelocity = velocity ? -(velocity / 1e3) : 0;
  567. const initialDelta = to - from;
  568. const dampingRatio = damping / (2 * Math.sqrt(stiffness * mass));
  569. const undampedAngularFreq = Math.sqrt(stiffness / mass) / 1e3;
  570. if (restDelta === void 0) {
  571. restDelta = Math.min(Math.abs(to - from) / 100, 0.4);
  572. }
  573. if (dampingRatio < 1) {
  574. const angularFreq = calcAngularFreq(undampedAngularFreq, dampingRatio);
  575. resolveSpring = (t) => {
  576. const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
  577. return to - envelope * ((initialVelocity + dampingRatio * undampedAngularFreq * initialDelta) / angularFreq * Math.sin(angularFreq * t) + initialDelta * Math.cos(angularFreq * t));
  578. };
  579. resolveVelocity = (t) => {
  580. const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
  581. return dampingRatio * undampedAngularFreq * envelope * (Math.sin(angularFreq * t) * (initialVelocity + dampingRatio * undampedAngularFreq * initialDelta) / angularFreq + initialDelta * Math.cos(angularFreq * t)) - envelope * (Math.cos(angularFreq * t) * (initialVelocity + dampingRatio * undampedAngularFreq * initialDelta) - angularFreq * initialDelta * Math.sin(angularFreq * t));
  582. };
  583. } else if (dampingRatio === 1) {
  584. resolveSpring = (t) => to - Math.exp(-undampedAngularFreq * t) * (initialDelta + (initialVelocity + undampedAngularFreq * initialDelta) * t);
  585. } else {
  586. const dampedAngularFreq = undampedAngularFreq * Math.sqrt(dampingRatio * dampingRatio - 1);
  587. resolveSpring = (t) => {
  588. const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
  589. const freqForT = Math.min(dampedAngularFreq * t, 300);
  590. return to - envelope * ((initialVelocity + dampingRatio * undampedAngularFreq * initialDelta) * Math.sinh(freqForT) + dampedAngularFreq * initialDelta * Math.cosh(freqForT)) / dampedAngularFreq;
  591. };
  592. }
  593. }
  594. createSpring();
  595. return {
  596. next: (t) => {
  597. const current = resolveSpring(t);
  598. if (!isResolvedFromDuration) {
  599. const currentVelocity = resolveVelocity(t) * 1e3;
  600. const isBelowVelocityThreshold = Math.abs(currentVelocity) <= restSpeed;
  601. const isBelowDisplacementThreshold = Math.abs(to - current) <= restDelta;
  602. state.done = isBelowVelocityThreshold && isBelowDisplacementThreshold;
  603. } else {
  604. state.done = t >= duration;
  605. }
  606. state.value = state.done ? to : current;
  607. return state;
  608. },
  609. flipTarget: () => {
  610. velocity = -velocity;
  611. [from, to] = [to, from];
  612. createSpring();
  613. }
  614. };
  615. }
  616. spring.needsInterpolation = (a2, b2) => typeof a2 === "string" || typeof b2 === "string";
  617. var zero = (_t) => 0;
  618. // node_modules/popmotion/dist/es/utils/progress.mjs
  619. var progress = (from, to, value) => {
  620. const toFromDifference = to - from;
  621. return toFromDifference === 0 ? 1 : (value - from) / toFromDifference;
  622. };
  623. // node_modules/popmotion/dist/es/utils/mix.mjs
  624. var mix = (from, to, progress2) => -progress2 * from + progress2 * to + from;
  625. // node_modules/style-value-types/dist/es/utils.mjs
  626. var clamp3 = (min, max) => (v) => Math.max(Math.min(v, max), min);
  627. var sanitize = (v) => v % 1 ? Number(v.toFixed(5)) : v;
  628. var floatRegex = /(-)?([\d]*\.?[\d])+/g;
  629. var colorRegex = /(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))/gi;
  630. var singleColorRegex = /^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))$/i;
  631. function isString(v) {
  632. return typeof v === "string";
  633. }
  634. // node_modules/style-value-types/dist/es/numbers/index.mjs
  635. var number = {
  636. test: (v) => typeof v === "number",
  637. parse: parseFloat,
  638. transform: (v) => v
  639. };
  640. var alpha = Object.assign(Object.assign({}, number), { transform: clamp3(0, 1) });
  641. var scale = Object.assign(Object.assign({}, number), { default: 1 });
  642. // node_modules/style-value-types/dist/es/numbers/units.mjs
  643. var createUnitType = (unit) => ({
  644. test: (v) => isString(v) && v.endsWith(unit) && v.split(" ").length === 1,
  645. parse: parseFloat,
  646. transform: (v) => `${v}${unit}`
  647. });
  648. var degrees = createUnitType("deg");
  649. var percent = createUnitType("%");
  650. var px = createUnitType("px");
  651. var vh = createUnitType("vh");
  652. var vw = createUnitType("vw");
  653. var progressPercentage = Object.assign(Object.assign({}, percent), { parse: (v) => percent.parse(v) / 100, transform: (v) => percent.transform(v * 100) });
  654. // node_modules/style-value-types/dist/es/color/utils.mjs
  655. var isColorString = (type, testProp) => (v) => {
  656. return Boolean(isString(v) && singleColorRegex.test(v) && v.startsWith(type) || testProp && Object.prototype.hasOwnProperty.call(v, testProp));
  657. };
  658. var splitColor = (aName, bName, cName) => (v) => {
  659. if (!isString(v))
  660. return v;
  661. const [a2, b2, c2, alpha2] = v.match(floatRegex);
  662. return {
  663. [aName]: parseFloat(a2),
  664. [bName]: parseFloat(b2),
  665. [cName]: parseFloat(c2),
  666. alpha: alpha2 !== void 0 ? parseFloat(alpha2) : 1
  667. };
  668. };
  669. // node_modules/style-value-types/dist/es/color/hsla.mjs
  670. var hsla = {
  671. test: isColorString("hsl", "hue"),
  672. parse: splitColor("hue", "saturation", "lightness"),
  673. transform: ({ hue, saturation, lightness, alpha: alpha$1 = 1 }) => {
  674. return "hsla(" + Math.round(hue) + ", " + percent.transform(sanitize(saturation)) + ", " + percent.transform(sanitize(lightness)) + ", " + sanitize(alpha.transform(alpha$1)) + ")";
  675. }
  676. };
  677. // node_modules/style-value-types/dist/es/color/rgba.mjs
  678. var clampRgbUnit = clamp3(0, 255);
  679. var rgbUnit = Object.assign(Object.assign({}, number), { transform: (v) => Math.round(clampRgbUnit(v)) });
  680. var rgba = {
  681. test: isColorString("rgb", "red"),
  682. parse: splitColor("red", "green", "blue"),
  683. transform: ({ red, green, blue, alpha: alpha$1 = 1 }) => "rgba(" + rgbUnit.transform(red) + ", " + rgbUnit.transform(green) + ", " + rgbUnit.transform(blue) + ", " + sanitize(alpha.transform(alpha$1)) + ")"
  684. };
  685. // node_modules/style-value-types/dist/es/color/hex.mjs
  686. function parseHex(v) {
  687. let r = "";
  688. let g = "";
  689. let b2 = "";
  690. let a2 = "";
  691. if (v.length > 5) {
  692. r = v.substr(1, 2);
  693. g = v.substr(3, 2);
  694. b2 = v.substr(5, 2);
  695. a2 = v.substr(7, 2);
  696. } else {
  697. r = v.substr(1, 1);
  698. g = v.substr(2, 1);
  699. b2 = v.substr(3, 1);
  700. a2 = v.substr(4, 1);
  701. r += r;
  702. g += g;
  703. b2 += b2;
  704. a2 += a2;
  705. }
  706. return {
  707. red: parseInt(r, 16),
  708. green: parseInt(g, 16),
  709. blue: parseInt(b2, 16),
  710. alpha: a2 ? parseInt(a2, 16) / 255 : 1
  711. };
  712. }
  713. var hex = {
  714. test: isColorString("#"),
  715. parse: parseHex,
  716. transform: rgba.transform
  717. };
  718. // node_modules/style-value-types/dist/es/color/index.mjs
  719. var color = {
  720. test: (v) => rgba.test(v) || hex.test(v) || hsla.test(v),
  721. parse: (v) => {
  722. if (rgba.test(v)) {
  723. return rgba.parse(v);
  724. } else if (hsla.test(v)) {
  725. return hsla.parse(v);
  726. } else {
  727. return hex.parse(v);
  728. }
  729. },
  730. transform: (v) => {
  731. return isString(v) ? v : v.hasOwnProperty("red") ? rgba.transform(v) : hsla.transform(v);
  732. }
  733. };
  734. // node_modules/style-value-types/dist/es/complex/index.mjs
  735. var colorToken = "${c}";
  736. var numberToken = "${n}";
  737. function test(v) {
  738. var _a, _b, _c, _d;
  739. return isNaN(v) && isString(v) && ((_b = (_a = v.match(floatRegex)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) + ((_d = (_c = v.match(colorRegex)) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0;
  740. }
  741. function analyse(v) {
  742. if (typeof v === "number")
  743. v = `${v}`;
  744. const values = [];
  745. let numColors = 0;
  746. const colors = v.match(colorRegex);
  747. if (colors) {
  748. numColors = colors.length;
  749. v = v.replace(colorRegex, colorToken);
  750. values.push(...colors.map(color.parse));
  751. }
  752. const numbers = v.match(floatRegex);
  753. if (numbers) {
  754. v = v.replace(floatRegex, numberToken);
  755. values.push(...numbers.map(number.parse));
  756. }
  757. return { values, numColors, tokenised: v };
  758. }
  759. function parse(v) {
  760. return analyse(v).values;
  761. }
  762. function createTransformer(v) {
  763. const { values, numColors, tokenised } = analyse(v);
  764. const numValues = values.length;
  765. return (v2) => {
  766. let output = tokenised;
  767. for (let i = 0; i < numValues; i++) {
  768. output = output.replace(i < numColors ? colorToken : numberToken, i < numColors ? color.transform(v2[i]) : sanitize(v2[i]));
  769. }
  770. return output;
  771. };
  772. }
  773. var convertNumbersToZero = (v) => typeof v === "number" ? 0 : v;
  774. function getAnimatableNone(v) {
  775. const parsed = parse(v);
  776. const transformer = createTransformer(v);
  777. return transformer(parsed.map(convertNumbersToZero));
  778. }
  779. var complex = { test, parse, createTransformer, getAnimatableNone };
  780. // node_modules/style-value-types/dist/es/complex/filter.mjs
  781. var maxDefaults = /* @__PURE__ */ new Set(["brightness", "contrast", "saturate", "opacity"]);
  782. function applyDefaultFilter(v) {
  783. let [name, value] = v.slice(0, -1).split("(");
  784. if (name === "drop-shadow")
  785. return v;
  786. const [number2] = value.match(floatRegex) || [];
  787. if (!number2)
  788. return v;
  789. const unit = value.replace(number2, "");
  790. let defaultValue = maxDefaults.has(name) ? 1 : 0;
  791. if (number2 !== value)
  792. defaultValue *= 100;
  793. return name + "(" + defaultValue + unit + ")";
  794. }
  795. var functionRegex = /([a-z-]*)\(.*?\)/g;
  796. var filter = Object.assign(Object.assign({}, complex), { getAnimatableNone: (v) => {
  797. const functions = v.match(functionRegex);
  798. return functions ? functions.map(applyDefaultFilter).join(" ") : v;
  799. } });
  800. // node_modules/popmotion/dist/es/utils/hsla-to-rgba.mjs
  801. function hueToRgb(p, q, t) {
  802. if (t < 0)
  803. t += 1;
  804. if (t > 1)
  805. t -= 1;
  806. if (t < 1 / 6)
  807. return p + (q - p) * 6 * t;
  808. if (t < 1 / 2)
  809. return q;
  810. if (t < 2 / 3)
  811. return p + (q - p) * (2 / 3 - t) * 6;
  812. return p;
  813. }
  814. function hslaToRgba({ hue, saturation, lightness, alpha: alpha2 }) {
  815. hue /= 360;
  816. saturation /= 100;
  817. lightness /= 100;
  818. let red = 0;
  819. let green = 0;
  820. let blue = 0;
  821. if (!saturation) {
  822. red = green = blue = lightness;
  823. } else {
  824. const q = lightness < 0.5 ? lightness * (1 + saturation) : lightness + saturation - lightness * saturation;
  825. const p = 2 * lightness - q;
  826. red = hueToRgb(p, q, hue + 1 / 3);
  827. green = hueToRgb(p, q, hue);
  828. blue = hueToRgb(p, q, hue - 1 / 3);
  829. }
  830. return {
  831. red: Math.round(red * 255),
  832. green: Math.round(green * 255),
  833. blue: Math.round(blue * 255),
  834. alpha: alpha2
  835. };
  836. }
  837. // node_modules/popmotion/dist/es/utils/mix-color.mjs
  838. var mixLinearColor = (from, to, v) => {
  839. const fromExpo = from * from;
  840. const toExpo = to * to;
  841. return Math.sqrt(Math.max(0, v * (toExpo - fromExpo) + fromExpo));
  842. };
  843. var colorTypes = [hex, rgba, hsla];
  844. var getColorType = (v) => colorTypes.find((type) => type.test(v));
  845. var notAnimatable = (color2) => `'${color2}' is not an animatable color. Use the equivalent color code instead.`;
  846. var mixColor = (from, to) => {
  847. let fromColorType = getColorType(from);
  848. let toColorType = getColorType(to);
  849. invariant(!!fromColorType, notAnimatable(from));
  850. invariant(!!toColorType, notAnimatable(to));
  851. let fromColor = fromColorType.parse(from);
  852. let toColor = toColorType.parse(to);
  853. if (fromColorType === hsla) {
  854. fromColor = hslaToRgba(fromColor);
  855. fromColorType = rgba;
  856. }
  857. if (toColorType === hsla) {
  858. toColor = hslaToRgba(toColor);
  859. toColorType = rgba;
  860. }
  861. const blended = Object.assign({}, fromColor);
  862. return (v) => {
  863. for (const key in blended) {
  864. if (key !== "alpha") {
  865. blended[key] = mixLinearColor(fromColor[key], toColor[key], v);
  866. }
  867. }
  868. blended.alpha = mix(fromColor.alpha, toColor.alpha, v);
  869. return fromColorType.transform(blended);
  870. };
  871. };
  872. // node_modules/popmotion/dist/es/utils/inc.mjs
  873. var isNum = (v) => typeof v === "number";
  874. // node_modules/popmotion/dist/es/utils/pipe.mjs
  875. var combineFunctions = (a2, b2) => (v) => b2(a2(v));
  876. var pipe = (...transformers) => transformers.reduce(combineFunctions);
  877. // node_modules/popmotion/dist/es/utils/mix-complex.mjs
  878. function getMixer(origin, target) {
  879. if (isNum(origin)) {
  880. return (v) => mix(origin, target, v);
  881. } else if (color.test(origin)) {
  882. return mixColor(origin, target);
  883. } else {
  884. return mixComplex(origin, target);
  885. }
  886. }
  887. var mixArray = (from, to) => {
  888. const output = [...from];
  889. const numValues = output.length;
  890. const blendValue = from.map((fromThis, i) => getMixer(fromThis, to[i]));
  891. return (v) => {
  892. for (let i = 0; i < numValues; i++) {
  893. output[i] = blendValue[i](v);
  894. }
  895. return output;
  896. };
  897. };
  898. var mixObject = (origin, target) => {
  899. const output = Object.assign(Object.assign({}, origin), target);
  900. const blendValue = {};
  901. for (const key in output) {
  902. if (origin[key] !== void 0 && target[key] !== void 0) {
  903. blendValue[key] = getMixer(origin[key], target[key]);
  904. }
  905. }
  906. return (v) => {
  907. for (const key in blendValue) {
  908. output[key] = blendValue[key](v);
  909. }
  910. return output;
  911. };
  912. };
  913. function analyse2(value) {
  914. const parsed = complex.parse(value);
  915. const numValues = parsed.length;
  916. let numNumbers = 0;
  917. let numRGB = 0;
  918. let numHSL = 0;
  919. for (let i = 0; i < numValues; i++) {
  920. if (numNumbers || typeof parsed[i] === "number") {
  921. numNumbers++;
  922. } else {
  923. if (parsed[i].hue !== void 0) {
  924. numHSL++;
  925. } else {
  926. numRGB++;
  927. }
  928. }
  929. }
  930. return { parsed, numNumbers, numRGB, numHSL };
  931. }
  932. var mixComplex = (origin, target) => {
  933. const template = complex.createTransformer(target);
  934. const originStats = analyse2(origin);
  935. const targetStats = analyse2(target);
  936. const canInterpolate = originStats.numHSL === targetStats.numHSL && originStats.numRGB === targetStats.numRGB && originStats.numNumbers >= targetStats.numNumbers;
  937. if (canInterpolate) {
  938. return pipe(mixArray(originStats.parsed, targetStats.parsed), template);
  939. } else {
  940. warning(true, `Complex values '${origin}' and '${target}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`);
  941. return (p) => `${p > 0 ? target : origin}`;
  942. }
  943. };
  944. // node_modules/popmotion/dist/es/utils/interpolate.mjs
  945. var mixNumber = (from, to) => (p) => mix(from, to, p);
  946. function detectMixerFactory(v) {
  947. if (typeof v === "number") {
  948. return mixNumber;
  949. } else if (typeof v === "string") {
  950. if (color.test(v)) {
  951. return mixColor;
  952. } else {
  953. return mixComplex;
  954. }
  955. } else if (Array.isArray(v)) {
  956. return mixArray;
  957. } else if (typeof v === "object") {
  958. return mixObject;
  959. }
  960. }
  961. function createMixers(output, ease, customMixer) {
  962. const mixers = [];
  963. const mixerFactory = customMixer || detectMixerFactory(output[0]);
  964. const numMixers = output.length - 1;
  965. for (let i = 0; i < numMixers; i++) {
  966. let mixer = mixerFactory(output[i], output[i + 1]);
  967. if (ease) {
  968. const easingFunction = Array.isArray(ease) ? ease[i] : ease;
  969. mixer = pipe(easingFunction, mixer);
  970. }
  971. mixers.push(mixer);
  972. }
  973. return mixers;
  974. }
  975. function fastInterpolate([from, to], [mixer]) {
  976. return (v) => mixer(progress(from, to, v));
  977. }
  978. function slowInterpolate(input, mixers) {
  979. const inputLength = input.length;
  980. const lastInputIndex = inputLength - 1;
  981. return (v) => {
  982. let mixerIndex = 0;
  983. let foundMixerIndex = false;
  984. if (v <= input[0]) {
  985. foundMixerIndex = true;
  986. } else if (v >= input[lastInputIndex]) {
  987. mixerIndex = lastInputIndex - 1;
  988. foundMixerIndex = true;
  989. }
  990. if (!foundMixerIndex) {
  991. let i = 1;
  992. for (; i < inputLength; i++) {
  993. if (input[i] > v || i === lastInputIndex) {
  994. break;
  995. }
  996. }
  997. mixerIndex = i - 1;
  998. }
  999. const progressInRange = progress(input[mixerIndex], input[mixerIndex + 1], v);
  1000. return mixers[mixerIndex](progressInRange);
  1001. };
  1002. }
  1003. function interpolate(input, output, { clamp: isClamp = true, ease, mixer } = {}) {
  1004. const inputLength = input.length;
  1005. invariant(inputLength === output.length, "Both input and output ranges must be the same length");
  1006. invariant(!ease || !Array.isArray(ease) || ease.length === inputLength - 1, "Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values.");
  1007. if (input[0] > input[inputLength - 1]) {
  1008. input = [].concat(input);
  1009. output = [].concat(output);
  1010. input.reverse();
  1011. output.reverse();
  1012. }
  1013. const mixers = createMixers(output, ease, mixer);
  1014. const interpolator = inputLength === 2 ? fastInterpolate(input, mixers) : slowInterpolate(input, mixers);
  1015. return isClamp ? (v) => interpolator(clamp2(input[0], input[inputLength - 1], v)) : interpolator;
  1016. }
  1017. // node_modules/popmotion/dist/es/easing/utils.mjs
  1018. var reverseEasing = (easing) => (p) => 1 - easing(1 - p);
  1019. var mirrorEasing = (easing) => (p) => p <= 0.5 ? easing(2 * p) / 2 : (2 - easing(2 * (1 - p))) / 2;
  1020. var createExpoIn = (power) => (p) => Math.pow(p, power);
  1021. var createBackIn = (power) => (p) => p * p * ((power + 1) * p - power);
  1022. var createAnticipate = (power) => {
  1023. const backEasing = createBackIn(power);
  1024. return (p) => (p *= 2) < 1 ? 0.5 * backEasing(p) : 0.5 * (2 - Math.pow(2, -10 * (p - 1)));
  1025. };
  1026. // node_modules/popmotion/dist/es/easing/index.mjs
  1027. var DEFAULT_OVERSHOOT_STRENGTH = 1.525;
  1028. var BOUNCE_FIRST_THRESHOLD = 4 / 11;
  1029. var BOUNCE_SECOND_THRESHOLD = 8 / 11;
  1030. var BOUNCE_THIRD_THRESHOLD = 9 / 10;
  1031. var linear = (p) => p;
  1032. var easeIn = createExpoIn(2);
  1033. var easeOut = reverseEasing(easeIn);
  1034. var easeInOut = mirrorEasing(easeIn);
  1035. var circIn = (p) => 1 - Math.sin(Math.acos(p));
  1036. var circOut = reverseEasing(circIn);
  1037. var circInOut = mirrorEasing(circOut);
  1038. var backIn = createBackIn(DEFAULT_OVERSHOOT_STRENGTH);
  1039. var backOut = reverseEasing(backIn);
  1040. var backInOut = mirrorEasing(backIn);
  1041. var anticipate = createAnticipate(DEFAULT_OVERSHOOT_STRENGTH);
  1042. var ca = 4356 / 361;
  1043. var cb = 35442 / 1805;
  1044. var cc = 16061 / 1805;
  1045. var bounceOut = (p) => {
  1046. if (p === 1 || p === 0)
  1047. return p;
  1048. const p2 = p * p;
  1049. return p < BOUNCE_FIRST_THRESHOLD ? 7.5625 * p2 : p < BOUNCE_SECOND_THRESHOLD ? 9.075 * p2 - 9.9 * p + 3.4 : p < BOUNCE_THIRD_THRESHOLD ? ca * p2 - cb * p + cc : 10.8 * p * p - 20.52 * p + 10.72;
  1050. };
  1051. var bounceIn = reverseEasing(bounceOut);
  1052. var bounceInOut = (p) => p < 0.5 ? 0.5 * (1 - bounceOut(1 - p * 2)) : 0.5 * bounceOut(p * 2 - 1) + 0.5;
  1053. // node_modules/popmotion/dist/es/animations/generators/keyframes.mjs
  1054. function defaultEasing(values, easing) {
  1055. return values.map(() => easing || easeInOut).splice(0, values.length - 1);
  1056. }
  1057. function defaultOffset(values) {
  1058. const numValues = values.length;
  1059. return values.map((_value, i) => i !== 0 ? i / (numValues - 1) : 0);
  1060. }
  1061. function convertOffsetToTimes(offset, duration) {
  1062. return offset.map((o) => o * duration);
  1063. }
  1064. function keyframes({ from = 0, to = 1, ease, offset, duration = 300 }) {
  1065. const state = { done: false, value: from };
  1066. const values = Array.isArray(to) ? to : [from, to];
  1067. const times = convertOffsetToTimes(offset && offset.length === values.length ? offset : defaultOffset(values), duration);
  1068. function createInterpolator() {
  1069. return interpolate(times, values, {
  1070. ease: Array.isArray(ease) ? ease : defaultEasing(values, ease)
  1071. });
  1072. }
  1073. let interpolator = createInterpolator();
  1074. return {
  1075. next: (t) => {
  1076. state.value = interpolator(t);
  1077. state.done = t >= duration;
  1078. return state;
  1079. },
  1080. flipTarget: () => {
  1081. values.reverse();
  1082. interpolator = createInterpolator();
  1083. }
  1084. };
  1085. }
  1086. // node_modules/popmotion/dist/es/animations/generators/decay.mjs
  1087. function decay({ velocity = 0, from = 0, power = 0.8, timeConstant = 350, restDelta = 0.5, modifyTarget }) {
  1088. const state = { done: false, value: from };
  1089. let amplitude = power * velocity;
  1090. const ideal = from + amplitude;
  1091. const target = modifyTarget === void 0 ? ideal : modifyTarget(ideal);
  1092. if (target !== ideal)
  1093. amplitude = target - from;
  1094. return {
  1095. next: (t) => {
  1096. const delta = -amplitude * Math.exp(-t / timeConstant);
  1097. state.done = !(delta > restDelta || delta < -restDelta);
  1098. state.value = state.done ? target : target + delta;
  1099. return state;
  1100. },
  1101. flipTarget: () => {
  1102. }
  1103. };
  1104. }
  1105. // node_modules/popmotion/dist/es/animations/utils/detect-animation-from-options.mjs
  1106. var types = { keyframes, spring, decay };
  1107. function detectAnimationFromOptions(config) {
  1108. if (Array.isArray(config.to)) {
  1109. return keyframes;
  1110. } else if (types[config.type]) {
  1111. return types[config.type];
  1112. }
  1113. const keys2 = new Set(Object.keys(config));
  1114. if (keys2.has("ease") || keys2.has("duration") && !keys2.has("dampingRatio")) {
  1115. return keyframes;
  1116. } else if (keys2.has("dampingRatio") || keys2.has("stiffness") || keys2.has("mass") || keys2.has("damping") || keys2.has("restSpeed") || keys2.has("restDelta")) {
  1117. return spring;
  1118. }
  1119. return keyframes;
  1120. }
  1121. // node_modules/popmotion/dist/es/animations/utils/elapsed.mjs
  1122. function loopElapsed(elapsed, duration, delay = 0) {
  1123. return elapsed - duration - delay;
  1124. }
  1125. function reverseElapsed(elapsed, duration, delay = 0, isForwardPlayback = true) {
  1126. return isForwardPlayback ? loopElapsed(duration + -elapsed, duration, delay) : duration - (elapsed - duration) + delay;
  1127. }
  1128. function hasRepeatDelayElapsed(elapsed, duration, delay, isForwardPlayback) {
  1129. return isForwardPlayback ? elapsed >= duration + delay : elapsed <= -delay;
  1130. }
  1131. // node_modules/popmotion/dist/es/animations/index.mjs
  1132. var framesync = (update) => {
  1133. const passTimestamp = ({ delta }) => update(delta);
  1134. return {
  1135. start: () => es_default.update(passTimestamp, true),
  1136. stop: () => cancelSync.update(passTimestamp)
  1137. };
  1138. };
  1139. function animate(_a) {
  1140. var _b, _c;
  1141. var { from, autoplay = true, driver = framesync, elapsed = 0, repeat: repeatMax = 0, repeatType = "loop", repeatDelay = 0, onPlay, onStop, onComplete, onRepeat, onUpdate } = _a, options = __rest(_a, ["from", "autoplay", "driver", "elapsed", "repeat", "repeatType", "repeatDelay", "onPlay", "onStop", "onComplete", "onRepeat", "onUpdate"]);
  1142. let { to } = options;
  1143. let driverControls;
  1144. let repeatCount = 0;
  1145. let computedDuration = options.duration;
  1146. let latest;
  1147. let isComplete = false;
  1148. let isForwardPlayback = true;
  1149. let interpolateFromNumber;
  1150. const animator = detectAnimationFromOptions(options);
  1151. if ((_c = (_b = animator).needsInterpolation) === null || _c === void 0 ? void 0 : _c.call(_b, from, to)) {
  1152. interpolateFromNumber = interpolate([0, 100], [from, to], {
  1153. clamp: false
  1154. });
  1155. from = 0;
  1156. to = 100;
  1157. }
  1158. const animation = animator(Object.assign(Object.assign({}, options), { from, to }));
  1159. function repeat() {
  1160. repeatCount++;
  1161. if (repeatType === "reverse") {
  1162. isForwardPlayback = repeatCount % 2 === 0;
  1163. elapsed = reverseElapsed(elapsed, computedDuration, repeatDelay, isForwardPlayback);
  1164. } else {
  1165. elapsed = loopElapsed(elapsed, computedDuration, repeatDelay);
  1166. if (repeatType === "mirror")
  1167. animation.flipTarget();
  1168. }
  1169. isComplete = false;
  1170. onRepeat && onRepeat();
  1171. }
  1172. function complete() {
  1173. driverControls.stop();
  1174. onComplete && onComplete();
  1175. }
  1176. function update(delta) {
  1177. if (!isForwardPlayback)
  1178. delta = -delta;
  1179. elapsed += delta;
  1180. if (!isComplete) {
  1181. const state = animation.next(Math.max(0, elapsed));
  1182. latest = state.value;
  1183. if (interpolateFromNumber)
  1184. latest = interpolateFromNumber(latest);
  1185. isComplete = isForwardPlayback ? state.done : elapsed <= 0;
  1186. }
  1187. onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(latest);
  1188. if (isComplete) {
  1189. if (repeatCount === 0)
  1190. computedDuration !== null && computedDuration !== void 0 ? computedDuration : computedDuration = elapsed;
  1191. if (repeatCount < repeatMax) {
  1192. hasRepeatDelayElapsed(elapsed, computedDuration, repeatDelay, isForwardPlayback) && repeat();
  1193. } else {
  1194. complete();
  1195. }
  1196. }
  1197. }
  1198. function play() {
  1199. onPlay === null || onPlay === void 0 ? void 0 : onPlay();
  1200. driverControls = driver(update);
  1201. driverControls.start();
  1202. }
  1203. autoplay && play();
  1204. return {
  1205. stop: () => {
  1206. onStop === null || onStop === void 0 ? void 0 : onStop();
  1207. driverControls.stop();
  1208. }
  1209. };
  1210. }
  1211. // node_modules/popmotion/dist/es/utils/velocity-per-second.mjs
  1212. function velocityPerSecond(velocity, frameDuration) {
  1213. return frameDuration ? velocity * (1e3 / frameDuration) : 0;
  1214. }
  1215. // node_modules/popmotion/dist/es/animations/inertia.mjs
  1216. function inertia({ from = 0, velocity = 0, min, max, power = 0.8, timeConstant = 750, bounceStiffness = 500, bounceDamping = 10, restDelta = 1, modifyTarget, driver, onUpdate, onComplete, onStop }) {
  1217. let currentAnimation;
  1218. function isOutOfBounds(v) {
  1219. return min !== void 0 && v < min || max !== void 0 && v > max;
  1220. }
  1221. function boundaryNearest(v) {
  1222. if (min === void 0)
  1223. return max;
  1224. if (max === void 0)
  1225. return min;
  1226. return Math.abs(min - v) < Math.abs(max - v) ? min : max;
  1227. }
  1228. function startAnimation(options) {
  1229. currentAnimation === null || currentAnimation === void 0 ? void 0 : currentAnimation.stop();
  1230. currentAnimation = animate(Object.assign(Object.assign({}, options), {
  1231. driver,
  1232. onUpdate: (v) => {
  1233. var _a;
  1234. onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(v);
  1235. (_a = options.onUpdate) === null || _a === void 0 ? void 0 : _a.call(options, v);
  1236. },
  1237. onComplete,
  1238. onStop
  1239. }));
  1240. }
  1241. function startSpring(options) {
  1242. startAnimation(Object.assign({ type: "spring", stiffness: bounceStiffness, damping: bounceDamping, restDelta }, options));
  1243. }
  1244. if (isOutOfBounds(from)) {
  1245. startSpring({ from, velocity, to: boundaryNearest(from) });
  1246. } else {
  1247. let target = power * velocity + from;
  1248. if (typeof modifyTarget !== "undefined")
  1249. target = modifyTarget(target);
  1250. const boundary = boundaryNearest(target);
  1251. const heading = boundary === min ? -1 : 1;
  1252. let prev;
  1253. let current;
  1254. const checkBoundary = (v) => {
  1255. prev = current;
  1256. current = v;
  1257. velocity = velocityPerSecond(v - prev, getFrameData().delta);
  1258. if (heading === 1 && v > boundary || heading === -1 && v < boundary) {
  1259. startSpring({ from: v, to: boundary, velocity });
  1260. }
  1261. };
  1262. startAnimation({
  1263. type: "decay",
  1264. from,
  1265. velocity,
  1266. timeConstant,
  1267. power,
  1268. restDelta,
  1269. modifyTarget,
  1270. onUpdate: isOutOfBounds(target) ? checkBoundary : void 0
  1271. });
  1272. }
  1273. return {
  1274. stop: () => currentAnimation === null || currentAnimation === void 0 ? void 0 : currentAnimation.stop()
  1275. };
  1276. }
  1277. // node_modules/popmotion/dist/es/utils/attract.mjs
  1278. var identity2 = (v) => v;
  1279. var createAttractor = (alterDisplacement = identity2) => (constant, origin, v) => {
  1280. const displacement = origin - v;
  1281. const springModifiedDisplacement = -(0 - constant + 1) * (0 - alterDisplacement(Math.abs(displacement)));
  1282. return displacement <= 0 ? origin + springModifiedDisplacement : origin - springModifiedDisplacement;
  1283. };
  1284. var attract = createAttractor();
  1285. var attractExpo = createAttractor(Math.sqrt);
  1286. // node_modules/popmotion/dist/es/easing/cubic-bezier.mjs
  1287. var a = (a1, a2) => 1 - 3 * a2 + 3 * a1;
  1288. var b = (a1, a2) => 3 * a2 - 6 * a1;
  1289. var c = (a1) => 3 * a1;
  1290. var calcBezier = (t, a1, a2) => ((a(a1, a2) * t + b(a1, a2)) * t + c(a1)) * t;
  1291. var getSlope = (t, a1, a2) => 3 * a(a1, a2) * t * t + 2 * b(a1, a2) * t + c(a1);
  1292. var subdivisionPrecision = 1e-7;
  1293. var subdivisionMaxIterations = 10;
  1294. function binarySubdivide(aX, aA, aB, mX1, mX2) {
  1295. let currentX;
  1296. let currentT;
  1297. let i = 0;
  1298. do {
  1299. currentT = aA + (aB - aA) / 2;
  1300. currentX = calcBezier(currentT, mX1, mX2) - aX;
  1301. if (currentX > 0) {
  1302. aB = currentT;
  1303. } else {
  1304. aA = currentT;
  1305. }
  1306. } while (Math.abs(currentX) > subdivisionPrecision && ++i < subdivisionMaxIterations);
  1307. return currentT;
  1308. }
  1309. var newtonIterations = 8;
  1310. var newtonMinSlope = 1e-3;
  1311. function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
  1312. for (let i = 0; i < newtonIterations; ++i) {
  1313. const currentSlope = getSlope(aGuessT, mX1, mX2);
  1314. if (currentSlope === 0) {
  1315. return aGuessT;
  1316. }
  1317. const currentX = calcBezier(aGuessT, mX1, mX2) - aX;
  1318. aGuessT -= currentX / currentSlope;
  1319. }
  1320. return aGuessT;
  1321. }
  1322. var kSplineTableSize = 11;
  1323. var kSampleStepSize = 1 / (kSplineTableSize - 1);
  1324. function cubicBezier(mX1, mY1, mX2, mY2) {
  1325. if (mX1 === mY1 && mX2 === mY2)
  1326. return linear;
  1327. const sampleValues = new Float32Array(kSplineTableSize);
  1328. for (let i = 0; i < kSplineTableSize; ++i) {
  1329. sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
  1330. }
  1331. function getTForX(aX) {
  1332. let intervalStart = 0;
  1333. let currentSample = 1;
  1334. const lastSample = kSplineTableSize - 1;
  1335. for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
  1336. intervalStart += kSampleStepSize;
  1337. }
  1338. --currentSample;
  1339. const dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
  1340. const guessForT = intervalStart + dist * kSampleStepSize;
  1341. const initialSlope = getSlope(guessForT, mX1, mX2);
  1342. if (initialSlope >= newtonMinSlope) {
  1343. return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
  1344. } else if (initialSlope === 0) {
  1345. return guessForT;
  1346. } else {
  1347. return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
  1348. }
  1349. }
  1350. return (t) => t === 0 || t === 1 ? t : calcBezier(getTForX(t), mY1, mY2);
  1351. }
  1352. // node_modules/@vueuse/motion/dist/index.mjs
  1353. var motionState = {};
  1354. var __defProp$1 = Object.defineProperty;
  1355. var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  1356. var __publicField$1 = (obj, key, value) => {
  1357. __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
  1358. return value;
  1359. };
  1360. var SubscriptionManager = class {
  1361. constructor() {
  1362. __publicField$1(this, "subscriptions", /* @__PURE__ */ new Set());
  1363. }
  1364. add(handler) {
  1365. this.subscriptions.add(handler);
  1366. return () => this.subscriptions.delete(handler);
  1367. }
  1368. notify(a2, b2, c2) {
  1369. if (!this.subscriptions.size)
  1370. return;
  1371. for (const handler of this.subscriptions)
  1372. handler(a2, b2, c2);
  1373. }
  1374. clear() {
  1375. this.subscriptions.clear();
  1376. }
  1377. };
  1378. var __defProp = Object.defineProperty;
  1379. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  1380. var __publicField = (obj, key, value) => {
  1381. __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
  1382. return value;
  1383. };
  1384. function isFloat(value) {
  1385. return !isNaN(parseFloat(value));
  1386. }
  1387. var MotionValue = class {
  1388. /**
  1389. * @param init - The initiating value
  1390. * @param config - Optional configuration options
  1391. */
  1392. constructor(init) {
  1393. __publicField(this, "current");
  1394. __publicField(this, "prev");
  1395. __publicField(this, "timeDelta", 0);
  1396. __publicField(this, "lastUpdated", 0);
  1397. __publicField(this, "updateSubscribers", new SubscriptionManager());
  1398. __publicField(this, "stopAnimation");
  1399. __publicField(this, "canTrackVelocity", false);
  1400. __publicField(this, "updateAndNotify", (v) => {
  1401. this.prev = this.current;
  1402. this.current = v;
  1403. const { delta, timestamp: timestamp2 } = getFrameData();
  1404. if (this.lastUpdated !== timestamp2) {
  1405. this.timeDelta = delta;
  1406. this.lastUpdated = timestamp2;
  1407. }
  1408. es_default.postRender(this.scheduleVelocityCheck);
  1409. this.updateSubscribers.notify(this.current);
  1410. });
  1411. __publicField(this, "scheduleVelocityCheck", () => es_default.postRender(this.velocityCheck));
  1412. __publicField(this, "velocityCheck", ({ timestamp: timestamp2 }) => {
  1413. if (!this.canTrackVelocity)
  1414. this.canTrackVelocity = isFloat(this.current);
  1415. if (timestamp2 !== this.lastUpdated)
  1416. this.prev = this.current;
  1417. });
  1418. this.prev = this.current = init;
  1419. this.canTrackVelocity = isFloat(this.current);
  1420. }
  1421. /**
  1422. * Adds a function that will be notified when the `MotionValue` is updated.
  1423. *
  1424. * It returns a function that, when called, will cancel the subscription.
  1425. */
  1426. onChange(subscription) {
  1427. return this.updateSubscribers.add(subscription);
  1428. }
  1429. clearListeners() {
  1430. this.updateSubscribers.clear();
  1431. }
  1432. /**
  1433. * Sets the state of the `MotionValue`.
  1434. *
  1435. * @param v
  1436. * @param render
  1437. */
  1438. set(v) {
  1439. this.updateAndNotify(v);
  1440. }
  1441. /**
  1442. * Returns the latest state of `MotionValue`
  1443. *
  1444. * @returns - The latest state of `MotionValue`
  1445. */
  1446. get() {
  1447. return this.current;
  1448. }
  1449. /**
  1450. * Get previous value.
  1451. *
  1452. * @returns - The previous latest state of `MotionValue`
  1453. */
  1454. getPrevious() {
  1455. return this.prev;
  1456. }
  1457. /**
  1458. * Returns the latest velocity of `MotionValue`
  1459. *
  1460. * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
  1461. */
  1462. getVelocity() {
  1463. return this.canTrackVelocity ? velocityPerSecond(parseFloat(this.current) - parseFloat(this.prev), this.timeDelta) : 0;
  1464. }
  1465. /**
  1466. * Registers a new animation to control this `MotionValue`. Only one
  1467. * animation can drive a `MotionValue` at one time.
  1468. */
  1469. start(animation) {
  1470. this.stop();
  1471. return new Promise((resolve) => {
  1472. const { stop } = animation(resolve);
  1473. this.stopAnimation = stop;
  1474. }).then(() => this.clearAnimation());
  1475. }
  1476. /**
  1477. * Stop the currently active animation.
  1478. */
  1479. stop() {
  1480. if (this.stopAnimation)
  1481. this.stopAnimation();
  1482. this.clearAnimation();
  1483. }
  1484. /**
  1485. * Returns `true` if this value is currently animating.
  1486. */
  1487. isAnimating() {
  1488. return !!this.stopAnimation;
  1489. }
  1490. /**
  1491. * Clear the current animation reference.
  1492. */
  1493. clearAnimation() {
  1494. this.stopAnimation = null;
  1495. }
  1496. /**
  1497. * Destroy and clean up subscribers to this `MotionValue`.
  1498. */
  1499. destroy() {
  1500. this.updateSubscribers.clear();
  1501. this.stop();
  1502. }
  1503. };
  1504. function getMotionValue(init) {
  1505. return new MotionValue(init);
  1506. }
  1507. var { isArray } = Array;
  1508. function useMotionValues() {
  1509. const motionValues = ref({});
  1510. const stop = (keys2) => {
  1511. const destroyKey = (key) => {
  1512. if (!motionValues.value[key])
  1513. return;
  1514. motionValues.value[key].stop();
  1515. motionValues.value[key].destroy();
  1516. delete motionValues.value[key];
  1517. };
  1518. if (keys2) {
  1519. if (isArray(keys2)) {
  1520. keys2.forEach(destroyKey);
  1521. } else {
  1522. destroyKey(keys2);
  1523. }
  1524. } else {
  1525. Object.keys(motionValues.value).forEach(destroyKey);
  1526. }
  1527. };
  1528. const get = (key, from, target) => {
  1529. if (motionValues.value[key])
  1530. return motionValues.value[key];
  1531. const motionValue = getMotionValue(from);
  1532. motionValue.onChange((v) => target[key] = v);
  1533. motionValues.value[key] = motionValue;
  1534. return motionValue;
  1535. };
  1536. tryOnUnmounted(stop);
  1537. return {
  1538. motionValues,
  1539. get,
  1540. stop
  1541. };
  1542. }
  1543. function isKeyframesTarget(v) {
  1544. return Array.isArray(v);
  1545. }
  1546. function underDampedSpring() {
  1547. return {
  1548. type: "spring",
  1549. stiffness: 500,
  1550. damping: 25,
  1551. restDelta: 0.5,
  1552. restSpeed: 10
  1553. };
  1554. }
  1555. function criticallyDampedSpring(to) {
  1556. return {
  1557. type: "spring",
  1558. stiffness: 550,
  1559. damping: to === 0 ? 2 * Math.sqrt(550) : 30,
  1560. restDelta: 0.01,
  1561. restSpeed: 10
  1562. };
  1563. }
  1564. function overDampedSpring(to) {
  1565. return {
  1566. type: "spring",
  1567. stiffness: 550,
  1568. damping: to === 0 ? 100 : 30,
  1569. restDelta: 0.01,
  1570. restSpeed: 10
  1571. };
  1572. }
  1573. function linearTween() {
  1574. return {
  1575. type: "keyframes",
  1576. ease: "linear",
  1577. duration: 300
  1578. };
  1579. }
  1580. function keyframes2(values) {
  1581. return {
  1582. type: "keyframes",
  1583. duration: 800,
  1584. values
  1585. };
  1586. }
  1587. var defaultTransitions = {
  1588. default: overDampedSpring,
  1589. x: underDampedSpring,
  1590. y: underDampedSpring,
  1591. z: underDampedSpring,
  1592. rotate: underDampedSpring,
  1593. rotateX: underDampedSpring,
  1594. rotateY: underDampedSpring,
  1595. rotateZ: underDampedSpring,
  1596. scaleX: criticallyDampedSpring,
  1597. scaleY: criticallyDampedSpring,
  1598. scale: criticallyDampedSpring,
  1599. backgroundColor: linearTween,
  1600. color: linearTween,
  1601. opacity: linearTween
  1602. };
  1603. function getDefaultTransition(valueKey, to) {
  1604. let transitionFactory;
  1605. if (isKeyframesTarget(to)) {
  1606. transitionFactory = keyframes2;
  1607. } else {
  1608. transitionFactory = defaultTransitions[valueKey] || defaultTransitions.default;
  1609. }
  1610. return { to, ...transitionFactory(to) };
  1611. }
  1612. var int = {
  1613. ...number,
  1614. transform: Math.round
  1615. };
  1616. var valueTypes = {
  1617. // Color props
  1618. color,
  1619. backgroundColor: color,
  1620. outlineColor: color,
  1621. fill: color,
  1622. stroke: color,
  1623. // Border props
  1624. borderColor: color,
  1625. borderTopColor: color,
  1626. borderRightColor: color,
  1627. borderBottomColor: color,
  1628. borderLeftColor: color,
  1629. borderWidth: px,
  1630. borderTopWidth: px,
  1631. borderRightWidth: px,
  1632. borderBottomWidth: px,
  1633. borderLeftWidth: px,
  1634. borderRadius: px,
  1635. radius: px,
  1636. borderTopLeftRadius: px,
  1637. borderTopRightRadius: px,
  1638. borderBottomRightRadius: px,
  1639. borderBottomLeftRadius: px,
  1640. // Positioning props
  1641. width: px,
  1642. maxWidth: px,
  1643. height: px,
  1644. maxHeight: px,
  1645. size: px,
  1646. top: px,
  1647. right: px,
  1648. bottom: px,
  1649. left: px,
  1650. // Spacing props
  1651. padding: px,
  1652. paddingTop: px,
  1653. paddingRight: px,
  1654. paddingBottom: px,
  1655. paddingLeft: px,
  1656. margin: px,
  1657. marginTop: px,
  1658. marginRight: px,
  1659. marginBottom: px,
  1660. marginLeft: px,
  1661. // Transform props
  1662. rotate: degrees,
  1663. rotateX: degrees,
  1664. rotateY: degrees,
  1665. rotateZ: degrees,
  1666. scale,
  1667. scaleX: scale,
  1668. scaleY: scale,
  1669. scaleZ: scale,
  1670. skew: degrees,
  1671. skewX: degrees,
  1672. skewY: degrees,
  1673. distance: px,
  1674. translateX: px,
  1675. translateY: px,
  1676. translateZ: px,
  1677. x: px,
  1678. y: px,
  1679. z: px,
  1680. perspective: px,
  1681. transformPerspective: px,
  1682. opacity: alpha,
  1683. originX: progressPercentage,
  1684. originY: progressPercentage,
  1685. originZ: px,
  1686. // Misc
  1687. zIndex: int,
  1688. filter,
  1689. WebkitFilter: filter,
  1690. // SVG
  1691. fillOpacity: alpha,
  1692. strokeOpacity: alpha,
  1693. numOctaves: int
  1694. };
  1695. var getValueType = (key) => valueTypes[key];
  1696. function getValueAsType(value, type) {
  1697. return type && typeof value === "number" && type.transform ? type.transform(value) : value;
  1698. }
  1699. function getAnimatableNone2(key, value) {
  1700. let defaultValueType = getValueType(key);
  1701. if (defaultValueType !== filter)
  1702. defaultValueType = complex;
  1703. return defaultValueType.getAnimatableNone ? defaultValueType.getAnimatableNone(value) : void 0;
  1704. }
  1705. var easingLookup = {
  1706. linear,
  1707. easeIn,
  1708. easeInOut,
  1709. easeOut,
  1710. circIn,
  1711. circInOut,
  1712. circOut,
  1713. backIn,
  1714. backInOut,
  1715. backOut,
  1716. anticipate,
  1717. bounceIn,
  1718. bounceInOut,
  1719. bounceOut
  1720. };
  1721. function easingDefinitionToFunction(definition) {
  1722. if (Array.isArray(definition)) {
  1723. const [x1, y1, x2, y2] = definition;
  1724. return cubicBezier(x1, y1, x2, y2);
  1725. } else if (typeof definition === "string") {
  1726. return easingLookup[definition];
  1727. }
  1728. return definition;
  1729. }
  1730. function isEasingArray(ease) {
  1731. return Array.isArray(ease) && typeof ease[0] !== "number";
  1732. }
  1733. function isAnimatable(key, value) {
  1734. if (key === "zIndex")
  1735. return false;
  1736. if (typeof value === "number" || Array.isArray(value))
  1737. return true;
  1738. if (typeof value === "string" && // It's animatable if we have a string
  1739. complex.test(value) && // And it contains numbers and/or colors
  1740. !value.startsWith("url("))
  1741. return true;
  1742. return false;
  1743. }
  1744. function hydrateKeyframes(options) {
  1745. if (Array.isArray(options.to) && options.to[0] === null) {
  1746. options.to = [...options.to];
  1747. options.to[0] = options.from;
  1748. }
  1749. return options;
  1750. }
  1751. function convertTransitionToAnimationOptions({ ease, times, delay, ...transition }) {
  1752. const options = { ...transition };
  1753. if (times)
  1754. options.offset = times;
  1755. if (ease) {
  1756. options.ease = isEasingArray(ease) ? ease.map(easingDefinitionToFunction) : easingDefinitionToFunction(ease);
  1757. }
  1758. if (delay)
  1759. options.elapsed = -delay;
  1760. return options;
  1761. }
  1762. function getPopmotionAnimationOptions(transition, options, key) {
  1763. if (Array.isArray(options.to)) {
  1764. if (!transition.duration)
  1765. transition.duration = 800;
  1766. }
  1767. hydrateKeyframes(options);
  1768. if (!isTransitionDefined(transition)) {
  1769. transition = {
  1770. ...transition,
  1771. ...getDefaultTransition(key, options.to)
  1772. };
  1773. }
  1774. return {
  1775. ...options,
  1776. ...convertTransitionToAnimationOptions(transition)
  1777. };
  1778. }
  1779. function isTransitionDefined({ delay, repeat, repeatType, repeatDelay, from, ...transition }) {
  1780. return !!Object.keys(transition).length;
  1781. }
  1782. function getValueTransition(transition, key) {
  1783. return transition[key] || transition.default || transition;
  1784. }
  1785. function getAnimation(key, value, target, transition, onComplete) {
  1786. const valueTransition = getValueTransition(transition, key);
  1787. let origin = valueTransition.from === null || valueTransition.from === void 0 ? value.get() : valueTransition.from;
  1788. const isTargetAnimatable = isAnimatable(key, target);
  1789. if (origin === "none" && isTargetAnimatable && typeof target === "string")
  1790. origin = getAnimatableNone2(key, target);
  1791. const isOriginAnimatable = isAnimatable(key, origin);
  1792. function start(complete) {
  1793. const options = {
  1794. from: origin,
  1795. to: target,
  1796. velocity: transition.velocity ? transition.velocity : value.getVelocity(),
  1797. onUpdate: (v) => value.set(v)
  1798. };
  1799. return valueTransition.type === "inertia" || valueTransition.type === "decay" ? inertia({ ...options, ...valueTransition }) : animate({
  1800. ...getPopmotionAnimationOptions(valueTransition, options, key),
  1801. onUpdate: (v) => {
  1802. options.onUpdate(v);
  1803. if (valueTransition.onUpdate)
  1804. valueTransition.onUpdate(v);
  1805. },
  1806. onComplete: () => {
  1807. if (transition.onComplete)
  1808. transition.onComplete();
  1809. if (onComplete)
  1810. onComplete();
  1811. if (complete)
  1812. complete();
  1813. }
  1814. });
  1815. }
  1816. function set2(complete) {
  1817. value.set(target);
  1818. if (transition.onComplete)
  1819. transition.onComplete();
  1820. if (onComplete)
  1821. onComplete();
  1822. if (complete)
  1823. complete();
  1824. return { stop: () => {
  1825. } };
  1826. }
  1827. return !isOriginAnimatable || !isTargetAnimatable || valueTransition.type === false ? set2 : start;
  1828. }
  1829. function useMotionTransitions() {
  1830. const { motionValues, stop, get } = useMotionValues();
  1831. const push = (key, value, target, transition = {}, onComplete) => {
  1832. const from = target[key];
  1833. const motionValue = get(key, from, target);
  1834. if (transition && transition.immediate) {
  1835. motionValue.set(value);
  1836. return;
  1837. }
  1838. const animation = getAnimation(key, motionValue, value, transition, onComplete);
  1839. motionValue.start(animation);
  1840. };
  1841. return { motionValues, stop, push };
  1842. }
  1843. function useMotionControls(motionProperties, variants = {}, { motionValues, push, stop } = useMotionTransitions()) {
  1844. const _variants = unref(variants);
  1845. const isAnimating = ref(false);
  1846. watch(
  1847. motionValues,
  1848. (newVal) => {
  1849. isAnimating.value = Object.values(newVal).filter((value) => value.isAnimating()).length > 0;
  1850. },
  1851. {
  1852. immediate: true,
  1853. deep: true
  1854. }
  1855. );
  1856. const getVariantFromKey = (variant) => {
  1857. if (!_variants || !_variants[variant])
  1858. throw new Error(`The variant ${variant} does not exist.`);
  1859. return _variants[variant];
  1860. };
  1861. const apply = (variant) => {
  1862. if (typeof variant === "string")
  1863. variant = getVariantFromKey(variant);
  1864. return Promise.all(
  1865. Object.entries(variant).map(([key, value]) => {
  1866. if (key === "transition")
  1867. return void 0;
  1868. return new Promise(
  1869. (resolve) => (
  1870. // @ts-expect-error - Fix errors later for typescript 5
  1871. push(key, value, motionProperties, variant.transition || getDefaultTransition(key, variant[key]), resolve)
  1872. )
  1873. );
  1874. }).filter(Boolean)
  1875. );
  1876. };
  1877. const set2 = (variant) => {
  1878. const variantData = isObject(variant) ? variant : getVariantFromKey(variant);
  1879. Object.entries(variantData).forEach(([key, value]) => {
  1880. if (key === "transition")
  1881. return;
  1882. push(key, value, motionProperties, {
  1883. immediate: true
  1884. });
  1885. });
  1886. };
  1887. const leave = async (done) => {
  1888. let leaveVariant;
  1889. if (_variants) {
  1890. if (_variants.leave)
  1891. leaveVariant = _variants.leave;
  1892. if (!_variants.leave && _variants.initial)
  1893. leaveVariant = _variants.initial;
  1894. }
  1895. if (!leaveVariant) {
  1896. done();
  1897. return;
  1898. }
  1899. await apply(leaveVariant);
  1900. done();
  1901. };
  1902. return {
  1903. isAnimating,
  1904. apply,
  1905. set: set2,
  1906. leave,
  1907. stop
  1908. };
  1909. }
  1910. var isBrowser = typeof window !== "undefined";
  1911. var supportsPointerEvents = () => isBrowser && window.onpointerdown === null;
  1912. var supportsTouchEvents = () => isBrowser && window.ontouchstart === null;
  1913. var supportsMouseEvents = () => isBrowser && window.onmousedown === null;
  1914. function registerEventListeners({ target, state, variants, apply }) {
  1915. const _variants = unref(variants);
  1916. const hovered = ref(false);
  1917. const tapped = ref(false);
  1918. const focused = ref(false);
  1919. const mutableKeys = computed(() => {
  1920. let result = [];
  1921. if (!_variants)
  1922. return result;
  1923. if (_variants.hovered)
  1924. result = [...result, ...Object.keys(_variants.hovered)];
  1925. if (_variants.tapped)
  1926. result = [...result, ...Object.keys(_variants.tapped)];
  1927. if (_variants.focused)
  1928. result = [...result, ...Object.keys(_variants.focused)];
  1929. return result;
  1930. });
  1931. const computedProperties = computed(() => {
  1932. const result = {};
  1933. Object.assign(result, state.value);
  1934. if (hovered.value && _variants.hovered)
  1935. Object.assign(result, _variants.hovered);
  1936. if (tapped.value && _variants.tapped)
  1937. Object.assign(result, _variants.tapped);
  1938. if (focused.value && _variants.focused)
  1939. Object.assign(result, _variants.focused);
  1940. for (const key in result) {
  1941. if (!mutableKeys.value.includes(key))
  1942. delete result[key];
  1943. }
  1944. return result;
  1945. });
  1946. if (_variants.hovered) {
  1947. useEventListener(target, "mouseenter", () => hovered.value = true);
  1948. useEventListener(target, "mouseleave", () => {
  1949. hovered.value = false;
  1950. tapped.value = false;
  1951. });
  1952. useEventListener(target, "mouseout", () => {
  1953. hovered.value = false;
  1954. tapped.value = false;
  1955. });
  1956. }
  1957. if (_variants.tapped) {
  1958. if (supportsMouseEvents()) {
  1959. useEventListener(target, "mousedown", () => tapped.value = true);
  1960. useEventListener(target, "mouseup", () => tapped.value = false);
  1961. }
  1962. if (supportsPointerEvents()) {
  1963. useEventListener(target, "pointerdown", () => tapped.value = true);
  1964. useEventListener(target, "pointerup", () => tapped.value = false);
  1965. }
  1966. if (supportsTouchEvents()) {
  1967. useEventListener(target, "touchstart", () => tapped.value = true);
  1968. useEventListener(target, "touchend", () => tapped.value = false);
  1969. }
  1970. }
  1971. if (_variants.focused) {
  1972. useEventListener(target, "focus", () => focused.value = true);
  1973. useEventListener(target, "blur", () => focused.value = false);
  1974. }
  1975. watch(computedProperties, apply);
  1976. }
  1977. function registerLifeCycleHooks({ set: set2, target, variants, variant }) {
  1978. const _variants = unref(variants);
  1979. watch(
  1980. () => target,
  1981. () => {
  1982. if (!_variants)
  1983. return;
  1984. if (_variants.initial)
  1985. set2("initial");
  1986. if (_variants.enter)
  1987. variant.value = "enter";
  1988. },
  1989. {
  1990. immediate: true,
  1991. flush: "pre"
  1992. }
  1993. );
  1994. }
  1995. function registerVariantsSync({ state, apply }) {
  1996. watch(
  1997. state,
  1998. (newVal) => {
  1999. if (newVal)
  2000. apply(newVal);
  2001. },
  2002. {
  2003. immediate: true
  2004. }
  2005. );
  2006. }
  2007. function registerVisibilityHooks({ target, variants, variant }) {
  2008. const _variants = unref(variants);
  2009. if (_variants && (_variants.visible || _variants.visibleOnce)) {
  2010. useIntersectionObserver(target, ([{ isIntersecting }]) => {
  2011. if (_variants.visible) {
  2012. if (isIntersecting)
  2013. variant.value = "visible";
  2014. else
  2015. variant.value = "initial";
  2016. } else if (_variants.visibleOnce) {
  2017. if (isIntersecting && variant.value !== "visibleOnce")
  2018. variant.value = "visibleOnce";
  2019. else if (!variant.value)
  2020. variant.value = "initial";
  2021. }
  2022. });
  2023. }
  2024. }
  2025. function useMotionFeatures(instance, options = {
  2026. syncVariants: true,
  2027. lifeCycleHooks: true,
  2028. visibilityHooks: true,
  2029. eventListeners: true
  2030. }) {
  2031. if (options.lifeCycleHooks)
  2032. registerLifeCycleHooks(instance);
  2033. if (options.syncVariants)
  2034. registerVariantsSync(instance);
  2035. if (options.visibilityHooks)
  2036. registerVisibilityHooks(instance);
  2037. if (options.eventListeners)
  2038. registerEventListeners(instance);
  2039. }
  2040. function reactiveStyle(props = {}) {
  2041. const state = reactive({
  2042. ...props
  2043. });
  2044. const style = ref({});
  2045. watch(
  2046. state,
  2047. () => {
  2048. const result = {};
  2049. for (const [key, value] of Object.entries(state)) {
  2050. const valueType = getValueType(key);
  2051. const valueAsType = getValueAsType(value, valueType);
  2052. result[key] = valueAsType;
  2053. }
  2054. style.value = result;
  2055. },
  2056. {
  2057. immediate: true,
  2058. deep: true
  2059. }
  2060. );
  2061. return {
  2062. state,
  2063. style
  2064. };
  2065. }
  2066. function usePermissiveTarget(target, onTarget) {
  2067. watch(
  2068. () => unrefElement(target),
  2069. (el) => {
  2070. if (!el)
  2071. return;
  2072. onTarget(el);
  2073. },
  2074. {
  2075. immediate: true
  2076. }
  2077. );
  2078. }
  2079. var translateAlias = {
  2080. x: "translateX",
  2081. y: "translateY",
  2082. z: "translateZ"
  2083. };
  2084. function reactiveTransform(props = {}, enableHardwareAcceleration = true) {
  2085. const state = reactive({ ...props });
  2086. const transform = ref("");
  2087. watch(
  2088. state,
  2089. (newVal) => {
  2090. let result = "";
  2091. let hasHardwareAcceleration = false;
  2092. if (enableHardwareAcceleration && (newVal.x || newVal.y || newVal.z)) {
  2093. const str = [newVal.x || 0, newVal.y || 0, newVal.z || 0].map(px.transform).join(",");
  2094. result += `translate3d(${str}) `;
  2095. hasHardwareAcceleration = true;
  2096. }
  2097. for (const [key, value] of Object.entries(newVal)) {
  2098. if (enableHardwareAcceleration && (key === "x" || key === "y" || key === "z"))
  2099. continue;
  2100. const valueType = getValueType(key);
  2101. const valueAsType = getValueAsType(value, valueType);
  2102. result += `${translateAlias[key] || key}(${valueAsType}) `;
  2103. }
  2104. if (enableHardwareAcceleration && !hasHardwareAcceleration)
  2105. result += "translateZ(0px) ";
  2106. transform.value = result.trim();
  2107. },
  2108. {
  2109. immediate: true,
  2110. deep: true
  2111. }
  2112. );
  2113. return {
  2114. state,
  2115. transform
  2116. };
  2117. }
  2118. var transformAxes = ["", "X", "Y", "Z"];
  2119. var order = ["perspective", "translate", "scale", "rotate", "skew"];
  2120. var transformProps = ["transformPerspective", "x", "y", "z"];
  2121. order.forEach((operationKey) => {
  2122. transformAxes.forEach((axesKey) => {
  2123. const key = operationKey + axesKey;
  2124. transformProps.push(key);
  2125. });
  2126. });
  2127. var transformPropSet = new Set(transformProps);
  2128. function isTransformProp(key) {
  2129. return transformPropSet.has(key);
  2130. }
  2131. var transformOriginProps = /* @__PURE__ */ new Set(["originX", "originY", "originZ"]);
  2132. function isTransformOriginProp(key) {
  2133. return transformOriginProps.has(key);
  2134. }
  2135. function splitValues(variant) {
  2136. const transform = {};
  2137. const style = {};
  2138. Object.entries(variant).forEach(([key, value]) => {
  2139. if (isTransformProp(key) || isTransformOriginProp(key))
  2140. transform[key] = value;
  2141. else
  2142. style[key] = value;
  2143. });
  2144. return { transform, style };
  2145. }
  2146. function variantToStyle(variant) {
  2147. const { transform: _transform, style: _style } = splitValues(variant);
  2148. const { transform } = reactiveTransform(_transform);
  2149. const { style } = reactiveStyle(_style);
  2150. if (transform.value)
  2151. style.value.transform = transform.value;
  2152. return style.value;
  2153. }
  2154. function useElementStyle(target, onInit) {
  2155. let _cache;
  2156. let _target;
  2157. const { state, style } = reactiveStyle();
  2158. usePermissiveTarget(target, (el) => {
  2159. _target = el;
  2160. for (const key of Object.keys(valueTypes)) {
  2161. if (el.style[key] === null || el.style[key] === "" || isTransformProp(key) || isTransformOriginProp(key))
  2162. continue;
  2163. state[key] = el.style[key];
  2164. }
  2165. if (_cache) {
  2166. Object.entries(_cache).forEach(([key, value]) => el.style[key] = value);
  2167. }
  2168. if (onInit)
  2169. onInit(state);
  2170. });
  2171. watch(
  2172. style,
  2173. (newVal) => {
  2174. if (!_target) {
  2175. _cache = newVal;
  2176. return;
  2177. }
  2178. for (const key in newVal)
  2179. _target.style[key] = newVal[key];
  2180. },
  2181. {
  2182. immediate: true
  2183. }
  2184. );
  2185. return {
  2186. style: state
  2187. };
  2188. }
  2189. function parseTransform(transform) {
  2190. const transforms = transform.trim().split(/\) |\)/);
  2191. if (transforms.length === 1)
  2192. return {};
  2193. const parseValues = (value) => {
  2194. if (value.endsWith("px") || value.endsWith("deg"))
  2195. return parseFloat(value);
  2196. if (isNaN(Number(value)))
  2197. return Number(value);
  2198. return value;
  2199. };
  2200. return transforms.reduce((acc, transform2) => {
  2201. if (!transform2)
  2202. return acc;
  2203. const [name, transformValue] = transform2.split("(");
  2204. const valueArray = transformValue.split(",");
  2205. const values = valueArray.map((val) => {
  2206. return parseValues(val.endsWith(")") ? val.replace(")", "") : val.trim());
  2207. });
  2208. const value = values.length === 1 ? values[0] : values;
  2209. return {
  2210. ...acc,
  2211. [name]: value
  2212. };
  2213. }, {});
  2214. }
  2215. function stateFromTransform(state, transform) {
  2216. Object.entries(parseTransform(transform)).forEach(([key, value]) => {
  2217. const axes = ["x", "y", "z"];
  2218. if (key === "translate3d") {
  2219. if (value === 0) {
  2220. axes.forEach((axis) => state[axis] = 0);
  2221. return;
  2222. }
  2223. value.forEach((axisValue, index) => state[axes[index]] = axisValue);
  2224. return;
  2225. }
  2226. value = parseFloat(value);
  2227. if (key === "translateX") {
  2228. state.x = value;
  2229. return;
  2230. }
  2231. if (key === "translateY") {
  2232. state.y = value;
  2233. return;
  2234. }
  2235. if (key === "translateZ") {
  2236. state.z = value;
  2237. return;
  2238. }
  2239. state[key] = value;
  2240. });
  2241. }
  2242. function useElementTransform(target, onInit) {
  2243. let _cache;
  2244. let _target;
  2245. const { state, transform } = reactiveTransform();
  2246. usePermissiveTarget(target, (el) => {
  2247. _target = el;
  2248. if (el.style.transform)
  2249. stateFromTransform(state, el.style.transform);
  2250. if (_cache)
  2251. el.style.transform = _cache;
  2252. if (onInit)
  2253. onInit(state);
  2254. });
  2255. watch(
  2256. transform,
  2257. (newValue) => {
  2258. if (!_target) {
  2259. _cache = newValue;
  2260. return;
  2261. }
  2262. _target.style.transform = newValue;
  2263. },
  2264. {
  2265. immediate: true
  2266. }
  2267. );
  2268. return {
  2269. transform: state
  2270. };
  2271. }
  2272. function useMotionProperties(target, defaultValues) {
  2273. const motionProperties = reactive({});
  2274. const apply = (values) => Object.entries(values).forEach(([key, value]) => motionProperties[key] = value);
  2275. const { style } = useElementStyle(target, apply);
  2276. const { transform } = useElementTransform(target, apply);
  2277. watch(
  2278. motionProperties,
  2279. (newVal) => {
  2280. Object.entries(newVal).forEach(([key, value]) => {
  2281. const target2 = isTransformProp(key) ? transform : style;
  2282. if (target2[key] && target2[key] === value)
  2283. return;
  2284. target2[key] = value;
  2285. });
  2286. },
  2287. {
  2288. immediate: true,
  2289. deep: true
  2290. }
  2291. );
  2292. usePermissiveTarget(target, () => defaultValues && apply(defaultValues));
  2293. return {
  2294. motionProperties,
  2295. style,
  2296. transform
  2297. };
  2298. }
  2299. function useMotionVariants(variants = {}) {
  2300. const _variants = unref(variants);
  2301. const variant = ref();
  2302. const state = computed(() => {
  2303. if (!variant.value)
  2304. return;
  2305. return _variants[variant.value];
  2306. });
  2307. return {
  2308. state,
  2309. variant
  2310. };
  2311. }
  2312. function useMotion(target, variants = {}, options) {
  2313. const { motionProperties } = useMotionProperties(target);
  2314. const { variant, state } = useMotionVariants(variants);
  2315. const controls = useMotionControls(motionProperties, variants);
  2316. const instance = {
  2317. target,
  2318. variant,
  2319. variants,
  2320. state,
  2321. motionProperties,
  2322. ...controls
  2323. };
  2324. useMotionFeatures(instance, options);
  2325. return instance;
  2326. }
  2327. var directivePropsKeys = ["initial", "enter", "leave", "visible", "visible-once", "visibleOnce", "hovered", "tapped", "focused", "delay"];
  2328. function resolveVariants(node, variantsRef) {
  2329. const target = node.props ? node.props : node.data && node.data.attrs ? node.data.attrs : {};
  2330. if (target) {
  2331. if (target.variants && isObject(target.variants)) {
  2332. variantsRef.value = {
  2333. ...variantsRef.value,
  2334. ...target.variants
  2335. };
  2336. }
  2337. directivePropsKeys.forEach((key) => {
  2338. if (key === "delay") {
  2339. if (target && target[key] && typeof target[key] === "number") {
  2340. const delay = target[key];
  2341. if (variantsRef && variantsRef.value) {
  2342. if (variantsRef.value.enter) {
  2343. if (!variantsRef.value.enter.transition)
  2344. variantsRef.value.enter.transition = {};
  2345. variantsRef.value.enter.transition = {
  2346. delay,
  2347. ...variantsRef.value.enter.transition
  2348. };
  2349. }
  2350. if (variantsRef.value.visible) {
  2351. if (!variantsRef.value.visible.transition)
  2352. variantsRef.value.visible.transition = {};
  2353. variantsRef.value.visible.transition = {
  2354. delay,
  2355. ...variantsRef.value.visible.transition
  2356. };
  2357. }
  2358. if (variantsRef.value.visibleOnce) {
  2359. if (!variantsRef.value.visibleOnce.transition)
  2360. variantsRef.value.visibleOnce.transition = {};
  2361. variantsRef.value.visibleOnce.transition = {
  2362. delay,
  2363. ...variantsRef.value.visibleOnce.transition
  2364. };
  2365. }
  2366. }
  2367. }
  2368. return;
  2369. }
  2370. if (target && target[key] && isObject(target[key])) {
  2371. const prop = target[key];
  2372. if (key === "visible-once")
  2373. key = "visibleOnce";
  2374. variantsRef.value[key] = prop;
  2375. }
  2376. });
  2377. }
  2378. }
  2379. function directive(variants) {
  2380. const register = (el, binding, node) => {
  2381. const key = binding.value && typeof binding.value === "string" ? binding.value : node.key;
  2382. if (key && motionState[key])
  2383. motionState[key].stop();
  2384. const variantsRef = ref(variants || {});
  2385. if (typeof binding.value === "object")
  2386. variantsRef.value = binding.value;
  2387. resolveVariants(node, variantsRef);
  2388. const motionOptions = { eventListeners: true, lifeCycleHooks: true, syncVariants: true, visibilityHooks: false };
  2389. const motionInstance = useMotion(el, variantsRef, motionOptions);
  2390. el.motionInstance = motionInstance;
  2391. if (key)
  2392. motionState[key] = motionInstance;
  2393. };
  2394. const mounted = (el, binding, node) => {
  2395. el.motionInstance && registerVisibilityHooks(el.motionInstance);
  2396. };
  2397. return {
  2398. created: register,
  2399. mounted,
  2400. getSSRProps(binding, node) {
  2401. let { initial: bindingInitial } = binding.value || node && (node == null ? void 0 : node.props) || {};
  2402. bindingInitial = unref(bindingInitial);
  2403. const initial = defu((variants == null ? void 0 : variants.initial) || {}, bindingInitial || {});
  2404. if (!initial || Object.keys(initial).length === 0)
  2405. return;
  2406. const style = variantToStyle(initial);
  2407. return {
  2408. style
  2409. };
  2410. }
  2411. };
  2412. }
  2413. var fade = {
  2414. initial: {
  2415. opacity: 0
  2416. },
  2417. enter: {
  2418. opacity: 1
  2419. }
  2420. };
  2421. var fadeVisible = {
  2422. initial: {
  2423. opacity: 0
  2424. },
  2425. visible: {
  2426. opacity: 1
  2427. }
  2428. };
  2429. var fadeVisibleOnce = {
  2430. initial: {
  2431. opacity: 0
  2432. },
  2433. visibleOnce: {
  2434. opacity: 1
  2435. }
  2436. };
  2437. var pop = {
  2438. initial: {
  2439. scale: 0,
  2440. opacity: 0
  2441. },
  2442. enter: {
  2443. scale: 1,
  2444. opacity: 1
  2445. }
  2446. };
  2447. var popVisible = {
  2448. initial: {
  2449. scale: 0,
  2450. opacity: 0
  2451. },
  2452. visible: {
  2453. scale: 1,
  2454. opacity: 1
  2455. }
  2456. };
  2457. var popVisibleOnce = {
  2458. initial: {
  2459. scale: 0,
  2460. opacity: 0
  2461. },
  2462. visibleOnce: {
  2463. scale: 1,
  2464. opacity: 1
  2465. }
  2466. };
  2467. var rollLeft = {
  2468. initial: {
  2469. x: -100,
  2470. rotate: 90,
  2471. opacity: 0
  2472. },
  2473. enter: {
  2474. x: 0,
  2475. rotate: 0,
  2476. opacity: 1
  2477. }
  2478. };
  2479. var rollVisibleLeft = {
  2480. initial: {
  2481. x: -100,
  2482. rotate: 90,
  2483. opacity: 0
  2484. },
  2485. visible: {
  2486. x: 0,
  2487. rotate: 0,
  2488. opacity: 1
  2489. }
  2490. };
  2491. var rollVisibleOnceLeft = {
  2492. initial: {
  2493. x: -100,
  2494. rotate: 90,
  2495. opacity: 0
  2496. },
  2497. visibleOnce: {
  2498. x: 0,
  2499. rotate: 0,
  2500. opacity: 1
  2501. }
  2502. };
  2503. var rollRight = {
  2504. initial: {
  2505. x: 100,
  2506. rotate: -90,
  2507. opacity: 0
  2508. },
  2509. enter: {
  2510. x: 0,
  2511. rotate: 0,
  2512. opacity: 1
  2513. }
  2514. };
  2515. var rollVisibleRight = {
  2516. initial: {
  2517. x: 100,
  2518. rotate: -90,
  2519. opacity: 0
  2520. },
  2521. visible: {
  2522. x: 0,
  2523. rotate: 0,
  2524. opacity: 1
  2525. }
  2526. };
  2527. var rollVisibleOnceRight = {
  2528. initial: {
  2529. x: 100,
  2530. rotate: -90,
  2531. opacity: 0
  2532. },
  2533. visibleOnce: {
  2534. x: 0,
  2535. rotate: 0,
  2536. opacity: 1
  2537. }
  2538. };
  2539. var rollTop = {
  2540. initial: {
  2541. y: -100,
  2542. rotate: -90,
  2543. opacity: 0
  2544. },
  2545. enter: {
  2546. y: 0,
  2547. rotate: 0,
  2548. opacity: 1
  2549. }
  2550. };
  2551. var rollVisibleTop = {
  2552. initial: {
  2553. y: -100,
  2554. rotate: -90,
  2555. opacity: 0
  2556. },
  2557. visible: {
  2558. y: 0,
  2559. rotate: 0,
  2560. opacity: 1
  2561. }
  2562. };
  2563. var rollVisibleOnceTop = {
  2564. initial: {
  2565. y: -100,
  2566. rotate: -90,
  2567. opacity: 0
  2568. },
  2569. visibleOnce: {
  2570. y: 0,
  2571. rotate: 0,
  2572. opacity: 1
  2573. }
  2574. };
  2575. var rollBottom = {
  2576. initial: {
  2577. y: 100,
  2578. rotate: 90,
  2579. opacity: 0
  2580. },
  2581. enter: {
  2582. y: 0,
  2583. rotate: 0,
  2584. opacity: 1
  2585. }
  2586. };
  2587. var rollVisibleBottom = {
  2588. initial: {
  2589. y: 100,
  2590. rotate: 90,
  2591. opacity: 0
  2592. },
  2593. visible: {
  2594. y: 0,
  2595. rotate: 0,
  2596. opacity: 1
  2597. }
  2598. };
  2599. var rollVisibleOnceBottom = {
  2600. initial: {
  2601. y: 100,
  2602. rotate: 90,
  2603. opacity: 0
  2604. },
  2605. visibleOnce: {
  2606. y: 0,
  2607. rotate: 0,
  2608. opacity: 1
  2609. }
  2610. };
  2611. var slideLeft = {
  2612. initial: {
  2613. x: -100,
  2614. opacity: 0
  2615. },
  2616. enter: {
  2617. x: 0,
  2618. opacity: 1
  2619. }
  2620. };
  2621. var slideVisibleLeft = {
  2622. initial: {
  2623. x: -100,
  2624. opacity: 0
  2625. },
  2626. visible: {
  2627. x: 0,
  2628. opacity: 1
  2629. }
  2630. };
  2631. var slideVisibleOnceLeft = {
  2632. initial: {
  2633. x: -100,
  2634. opacity: 0
  2635. },
  2636. visibleOnce: {
  2637. x: 0,
  2638. opacity: 1
  2639. }
  2640. };
  2641. var slideRight = {
  2642. initial: {
  2643. x: 100,
  2644. opacity: 0
  2645. },
  2646. enter: {
  2647. x: 0,
  2648. opacity: 1
  2649. }
  2650. };
  2651. var slideVisibleRight = {
  2652. initial: {
  2653. x: 100,
  2654. opacity: 0
  2655. },
  2656. visible: {
  2657. x: 0,
  2658. opacity: 1
  2659. }
  2660. };
  2661. var slideVisibleOnceRight = {
  2662. initial: {
  2663. x: 100,
  2664. opacity: 0
  2665. },
  2666. visibleOnce: {
  2667. x: 0,
  2668. opacity: 1
  2669. }
  2670. };
  2671. var slideTop = {
  2672. initial: {
  2673. y: -100,
  2674. opacity: 0
  2675. },
  2676. enter: {
  2677. y: 0,
  2678. opacity: 1
  2679. }
  2680. };
  2681. var slideVisibleTop = {
  2682. initial: {
  2683. y: -100,
  2684. opacity: 0
  2685. },
  2686. visible: {
  2687. y: 0,
  2688. opacity: 1
  2689. }
  2690. };
  2691. var slideVisibleOnceTop = {
  2692. initial: {
  2693. y: -100,
  2694. opacity: 0
  2695. },
  2696. visibleOnce: {
  2697. y: 0,
  2698. opacity: 1
  2699. }
  2700. };
  2701. var slideBottom = {
  2702. initial: {
  2703. y: 100,
  2704. opacity: 0
  2705. },
  2706. enter: {
  2707. y: 0,
  2708. opacity: 1
  2709. }
  2710. };
  2711. var slideVisibleBottom = {
  2712. initial: {
  2713. y: 100,
  2714. opacity: 0
  2715. },
  2716. visible: {
  2717. y: 0,
  2718. opacity: 1
  2719. }
  2720. };
  2721. var slideVisibleOnceBottom = {
  2722. initial: {
  2723. y: 100,
  2724. opacity: 0
  2725. },
  2726. visibleOnce: {
  2727. y: 0,
  2728. opacity: 1
  2729. }
  2730. };
  2731. var presets = {
  2732. __proto__: null,
  2733. fade,
  2734. fadeVisible,
  2735. fadeVisibleOnce,
  2736. pop,
  2737. popVisible,
  2738. popVisibleOnce,
  2739. rollBottom,
  2740. rollLeft,
  2741. rollRight,
  2742. rollTop,
  2743. rollVisibleBottom,
  2744. rollVisibleLeft,
  2745. rollVisibleOnceBottom,
  2746. rollVisibleOnceLeft,
  2747. rollVisibleOnceRight,
  2748. rollVisibleOnceTop,
  2749. rollVisibleRight,
  2750. rollVisibleTop,
  2751. slideBottom,
  2752. slideLeft,
  2753. slideRight,
  2754. slideTop,
  2755. slideVisibleBottom,
  2756. slideVisibleLeft,
  2757. slideVisibleOnceBottom,
  2758. slideVisibleOnceLeft,
  2759. slideVisibleOnceRight,
  2760. slideVisibleOnceTop,
  2761. slideVisibleRight,
  2762. slideVisibleTop
  2763. };
  2764. var component = defineComponent({
  2765. props: {
  2766. is: {
  2767. type: [String, Object],
  2768. required: false
  2769. },
  2770. // Preset to be loaded
  2771. preset: {
  2772. type: String,
  2773. required: false
  2774. },
  2775. // Instance
  2776. instance: {
  2777. type: Object,
  2778. required: false
  2779. },
  2780. // Variants
  2781. variants: {
  2782. type: Object,
  2783. required: false
  2784. },
  2785. // Initial variant
  2786. initial: {
  2787. type: Object,
  2788. required: false
  2789. },
  2790. // Lifecycle hooks variants
  2791. enter: {
  2792. type: Object,
  2793. required: false
  2794. },
  2795. leave: {
  2796. type: Object,
  2797. required: false
  2798. },
  2799. // Intersection observer variants
  2800. visible: {
  2801. type: Object,
  2802. required: false
  2803. },
  2804. visibleOnce: {
  2805. type: Object,
  2806. required: false
  2807. },
  2808. // Event listeners variants
  2809. hovered: {
  2810. type: Object,
  2811. required: false
  2812. },
  2813. tapped: {
  2814. type: Object,
  2815. required: false
  2816. },
  2817. focused: {
  2818. type: Object,
  2819. required: false
  2820. },
  2821. // Helpers
  2822. delay: {
  2823. type: [Number, String],
  2824. required: false
  2825. }
  2826. },
  2827. setup(props) {
  2828. const slots = useSlots();
  2829. const instances = reactive({});
  2830. if (!props.is && !slots.default)
  2831. return () => h("div", {});
  2832. const _preset = computed(() => {
  2833. let preset;
  2834. if (props.preset)
  2835. preset = presets[props.preset];
  2836. return preset;
  2837. });
  2838. const propsConfig = computed(() => ({
  2839. initial: props.initial,
  2840. enter: props.enter,
  2841. leave: props.leave,
  2842. visible: props.visible,
  2843. visibleOnce: props.visibleOnce,
  2844. hovered: props.hovered,
  2845. tapped: props.tapped,
  2846. focused: props.focused
  2847. }));
  2848. const motionConfig = computed(() => {
  2849. const config = {
  2850. ...propsConfig.value,
  2851. ..._preset.value || {},
  2852. ...props.variants || {}
  2853. };
  2854. if (props.delay) {
  2855. config.enter.transition = { ...config.enter.transition };
  2856. config.enter.transition.delay = parseInt(props.delay);
  2857. }
  2858. return config;
  2859. });
  2860. const component2 = computed(() => {
  2861. if (!props.is)
  2862. return;
  2863. let comp = props.is;
  2864. if (typeof component2.value === "string" && !isHTMLTag(comp)) {
  2865. comp = resolveComponent(comp);
  2866. }
  2867. return comp;
  2868. });
  2869. if (true) {
  2870. const replayAnimation = (instance) => {
  2871. var _a;
  2872. if ((_a = instance.variants) == null ? void 0 : _a.initial)
  2873. instance.set("initial");
  2874. setTimeout(() => {
  2875. var _a2, _b, _c;
  2876. if ((_a2 = instance.variants) == null ? void 0 : _a2.enter)
  2877. instance.apply("enter");
  2878. if ((_b = instance.variants) == null ? void 0 : _b.visible)
  2879. instance.apply("visible");
  2880. if ((_c = instance.variants) == null ? void 0 : _c.visibleOnce)
  2881. instance.apply("visibleOnce");
  2882. }, 10);
  2883. };
  2884. onUpdated(() => Object.entries(instances).forEach(([_, value]) => replayAnimation(value)));
  2885. }
  2886. return {
  2887. slots,
  2888. component: component2,
  2889. motionConfig,
  2890. instances
  2891. };
  2892. },
  2893. render({ slots, motionConfig, instances, component: component2 }) {
  2894. var _a;
  2895. const style = variantToStyle(motionConfig.initial || {});
  2896. const setNode = (node, index) => {
  2897. if (!node.props)
  2898. node.props = {};
  2899. node.props.style = style;
  2900. node.props.onVnodeMounted = ({ el }) => {
  2901. const instance = useMotion(el, motionConfig);
  2902. instances[index] = instance;
  2903. };
  2904. return node;
  2905. };
  2906. if (component2) {
  2907. const node = h(component2, void 0, slots);
  2908. setNode(node, 0);
  2909. return node;
  2910. }
  2911. const nodes = ((_a = slots.default) == null ? void 0 : _a.call(slots)) || [];
  2912. return nodes.map((node, index) => setNode(node, index));
  2913. }
  2914. });
  2915. function slugify(string) {
  2916. const a2 = "àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;";
  2917. const b2 = "aaaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------";
  2918. const p = new RegExp(a2.split("").join("|"), "g");
  2919. return string.toString().replace(/[A-Z]/g, (s) => `-${s}`).toLowerCase().replace(/\s+/g, "-").replace(p, (c2) => b2.charAt(a2.indexOf(c2))).replace(/&/g, "-and-").replace(/[^\w\-]+/g, "").replace(/\-\-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
  2920. }
  2921. var MotionPlugin = {
  2922. install(app, options) {
  2923. app.directive("motion", directive());
  2924. app.component("Motion", component);
  2925. if (!options || options && !options.excludePresets) {
  2926. for (const key in presets) {
  2927. const preset = presets[key];
  2928. app.directive(`motion-${slugify(key)}`, directive(preset));
  2929. }
  2930. }
  2931. if (options && options.directives) {
  2932. for (const key in options.directives) {
  2933. const variants = options.directives[key];
  2934. if (!variants.initial && __DEV__) {
  2935. console.warn(`Your directive v-motion-${key} is missing initial variant!`);
  2936. }
  2937. app.directive(`motion-${key}`, directive(variants));
  2938. }
  2939. }
  2940. }
  2941. };
  2942. function isMotionInstance(obj) {
  2943. const _obj = obj;
  2944. return _obj.apply !== void 0 && typeof _obj.apply === "function" && _obj.set !== void 0 && typeof _obj.set === "function" && _obj.target !== void 0 && isRef(_obj.target);
  2945. }
  2946. function useMotions() {
  2947. return motionState;
  2948. }
  2949. function useSpring(values, spring2) {
  2950. const { stop, get } = useMotionValues();
  2951. return {
  2952. values,
  2953. stop,
  2954. set: (properties) => Promise.all(
  2955. Object.entries(properties).map(([key, value]) => {
  2956. const motionValue = get(key, values[key], values);
  2957. return motionValue.start((onComplete) => {
  2958. const options = {
  2959. type: "spring",
  2960. ...spring2 || getDefaultTransition(key, value)
  2961. };
  2962. return animate({
  2963. from: motionValue.get(),
  2964. to: value,
  2965. velocity: motionValue.getVelocity(),
  2966. onUpdate: (v) => motionValue.set(v),
  2967. onComplete,
  2968. ...options
  2969. });
  2970. });
  2971. })
  2972. )
  2973. };
  2974. }
  2975. function useReducedMotion(options = {}) {
  2976. return useMediaQuery("(prefers-reduced-motion: reduce)", options);
  2977. }
  2978. export {
  2979. directive as MotionDirective,
  2980. MotionPlugin,
  2981. fade,
  2982. fadeVisible,
  2983. fadeVisibleOnce,
  2984. isMotionInstance,
  2985. pop,
  2986. popVisible,
  2987. popVisibleOnce,
  2988. reactiveStyle,
  2989. reactiveTransform,
  2990. rollBottom,
  2991. rollLeft,
  2992. rollRight,
  2993. rollTop,
  2994. rollVisibleBottom,
  2995. rollVisibleLeft,
  2996. rollVisibleOnceBottom,
  2997. rollVisibleOnceLeft,
  2998. rollVisibleOnceRight,
  2999. rollVisibleOnceTop,
  3000. rollVisibleRight,
  3001. rollVisibleTop,
  3002. slideBottom,
  3003. slideLeft,
  3004. slideRight,
  3005. slideTop,
  3006. slideVisibleBottom,
  3007. slideVisibleLeft,
  3008. slideVisibleOnceBottom,
  3009. slideVisibleOnceLeft,
  3010. slideVisibleOnceRight,
  3011. slideVisibleOnceTop,
  3012. slideVisibleRight,
  3013. slideVisibleTop,
  3014. slugify,
  3015. useElementStyle,
  3016. useElementTransform,
  3017. useMotion,
  3018. useMotionControls,
  3019. useMotionProperties,
  3020. useMotionTransitions,
  3021. useMotionVariants,
  3022. useMotions,
  3023. useReducedMotion,
  3024. useSpring
  3025. };
  3026. //# sourceMappingURL=@vueuse_motion.js.map