{"version":3,"file":"createTransitions.cjs","sources":["../../../src/themes/createTransitions.ts"],"sourcesContent":["// Code based on Material UI\n// The MIT License (MIT)\n// Copyright (c) 2014 Call-Em-All\n\n// Follow https://material.google.com/motion/duration-easing.html#duration-easing-natural-easing-curves\n// to learn the context in which each easing should be used.\nconst easing = {\n  // This is the most common easing curve.\n  easeInOut: 'cubic-bezier(0.4, 0, 0.2, 1)',\n  // Objects enter the screen at full velocity from off-screen and\n  // slowly decelerate to a resting point.\n  easeOut: 'cubic-bezier(0.0, 0, 0.2, 1)',\n  // Objects leave the screen at full velocity. They do not decelerate when off-screen.\n  easeIn: 'cubic-bezier(0.4, 0, 1, 1)',\n  // The sharp curve is used by objects that may return to the screen at any time.\n  sharp: 'cubic-bezier(0.4, 0, 0.6, 1)',\n};\n\n// Follow https://material.io/guidelines/motion/duration-easing.html#duration-easing-common-durations\n// to learn when use what timing\nconst duration = {\n  shortest: 150,\n  shorter: 200,\n  short: 250,\n  // most basic recommended timing\n  standard: 300,\n  // this is to be used in complex animations\n  complex: 375,\n  // recommended when something is entering screen\n  enteringScreen: 225,\n  // recommended when something is leaving screen\n  leavingScreen: 195,\n};\n\n/** @alpha */\nexport interface CreateTransitionOptions {\n  duration?: number | string;\n  easing?: string;\n  delay?: number | string;\n}\n\n/** @alpha */\nexport function create(props: string | string[] = ['all'], options: CreateTransitionOptions = {}) {\n  const { duration: durationOption = duration.standard, easing: easingOption = easing.easeInOut, delay = 0 } = options;\n\n  return (Array.isArray(props) ? props : [props])\n    .map(\n      (animatedProp) =>\n        `${animatedProp} ${\n          typeof durationOption === 'string' ? durationOption : formatMs(durationOption)\n        } ${easingOption} ${typeof delay === 'string' ? delay : formatMs(delay)}`\n    )\n    .join(',');\n}\n\ntype ReducedMotionProps = 'no-preference' | 'reduce';\n\nexport function handleMotion(...props: ReducedMotionProps[]) {\n  return `@media ${props.map((prop) => `(prefers-reduced-motion: ${prop})`).join(',')}`;\n}\n\nexport function getAutoHeightDuration(height: number) {\n  if (!height) {\n    return 0;\n  }\n\n  const constant = height / 36;\n\n  // https://www.wolframalpha.com/input/?i=(4+%2B+15+*+(x+%2F+36+)+**+0.25+%2B+(x+%2F+36)+%2F+5)+*+10\n  return Math.round((4 + 15 * constant ** 0.25 + constant / 5) * 10);\n}\n\nfunction formatMs(milliseconds: number) {\n  return `${Math.round(milliseconds)}ms`;\n}\n\n/** @alpha */\nexport interface ThemeTransitions {\n  create: typeof create;\n  duration: typeof duration;\n  easing: typeof easing;\n  getAutoHeightDuration: typeof getAutoHeightDuration;\n  handleMotion: typeof handleMotion;\n}\n\n/** @internal */\nexport function createTransitions(): ThemeTransitions {\n  return {\n    create,\n    duration,\n    easing,\n    getAutoHeightDuration,\n    handleMotion,\n  };\n}\n"],"names":[],"mappings":";;;;;AAMA,MAAM,MAAA,GAAS;AAAA;AAAA,EAEb,SAAA,EAAW,8BAAA;AAAA;AAAA;AAAA,EAGX,OAAA,EAAS,8BAAA;AAAA;AAAA,EAET,MAAA,EAAQ,4BAAA;AAAA;AAAA,EAER,KAAA,EAAO;AACT,CAAA;AAIA,MAAM,QAAA,GAAW;AAAA,EACf,QAAA,EAAU,GAAA;AAAA,EACV,OAAA,EAAS,GAAA;AAAA,EACT,KAAA,EAAO,GAAA;AAAA;AAAA,EAEP,QAAA,EAAU,GAAA;AAAA;AAAA,EAEV,OAAA,EAAS,GAAA;AAAA;AAAA,EAET,cAAA,EAAgB,GAAA;AAAA;AAAA,EAEhB,aAAA,EAAe;AACjB,CAAA;AAUO,SAAS,OAAO,KAAA,GAA2B,CAAC,KAAK,CAAA,EAAG,OAAA,GAAmC,EAAC,EAAG;AAChG,EAAA,MAAM,EAAE,QAAA,EAAU,cAAA,GAAiB,QAAA,CAAS,QAAA,EAAU,MAAA,EAAQ,YAAA,GAAe,MAAA,CAAO,SAAA,EAAW,KAAA,GAAQ,CAAA,EAAE,GAAI,OAAA;AAE7G,EAAA,OAAA,CAAQ,MAAM,OAAA,CAAQ,KAAK,IAAI,KAAA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