@studiometa/js-toolkit 2.0.0-alpha.4 → 2.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/Base/index.d.ts +29 -47
  2. package/Base/index.js +19 -14
  3. package/Base/managers/ChildrenManager.d.ts +6 -6
  4. package/Base/managers/ChildrenManager.js +1 -2
  5. package/Base/managers/EventsManager.d.ts +9 -9
  6. package/Base/managers/EventsManager.js +18 -33
  7. package/Base/managers/OptionsManager.d.ts +0 -8
  8. package/Base/managers/OptionsManager.js +1 -6
  9. package/Base/managers/RefsManager.js +1 -2
  10. package/Base/managers/ServicesManager.d.ts +14 -3
  11. package/Base/managers/ServicesManager.js +30 -12
  12. package/Base/utils.js +1 -2
  13. package/README.md +12 -70
  14. package/decorators/index.js +1 -2
  15. package/decorators/withBreakpointManager.d.ts +4 -4
  16. package/decorators/withBreakpointManager.js +1 -2
  17. package/decorators/withBreakpointObserver.d.ts +2 -2
  18. package/decorators/withBreakpointObserver.js +1 -2
  19. package/decorators/withDrag.d.ts +3 -3
  20. package/decorators/withDrag.js +1 -2
  21. package/decorators/withExtraConfig.d.ts +3 -3
  22. package/decorators/withExtraConfig.js +1 -2
  23. package/decorators/withIntersectionObserver.d.ts +2 -2
  24. package/decorators/withIntersectionObserver.js +1 -11
  25. package/decorators/withMountWhenInView.d.ts +3 -3
  26. package/decorators/withMountWhenInView.js +1 -2
  27. package/helpers/createApp.d.ts +3 -3
  28. package/helpers/createApp.js +9 -9
  29. package/helpers/importOnInteraction.d.ts +3 -3
  30. package/helpers/importOnInteraction.js +1 -2
  31. package/helpers/importWhenIdle.d.ts +3 -3
  32. package/helpers/importWhenIdle.js +1 -2
  33. package/helpers/importWhenVisible.d.ts +3 -3
  34. package/helpers/importWhenVisible.js +1 -2
  35. package/helpers/index.js +1 -2
  36. package/helpers/utils.js +1 -2
  37. package/index.d.ts +2 -2
  38. package/index.js +1 -2
  39. package/index.modern.js +1 -2
  40. package/index.umd.js +1 -2
  41. package/package.json +3 -4
  42. package/services/Service.js +1 -2
  43. package/services/drag.js +1 -2
  44. package/services/index.js +1 -2
  45. package/services/key.js +1 -2
  46. package/services/load.d.ts +1 -1
  47. package/services/load.js +2 -3
  48. package/services/pointer.js +1 -2
  49. package/services/raf.js +1 -2
  50. package/services/resize.js +1 -6
  51. package/services/scroll.js +1 -2
  52. package/utils/collide/boundingRectToCircle.js +1 -2
  53. package/utils/collide/collideCircleCircle.js +1 -2
  54. package/utils/collide/collideCircleRect.js +1 -2
  55. package/utils/collide/collidePointCircle.js +1 -2
  56. package/utils/collide/collidePointRect.js +1 -2
  57. package/utils/collide/collideRectRect.js +1 -2
  58. package/utils/collide/index.js +1 -2
  59. package/utils/css/classes.js +1 -2
  60. package/utils/css/index.js +1 -2
  61. package/utils/css/matrix.js +1 -2
  62. package/utils/css/styles.js +1 -2
  63. package/utils/css/transition.js +1 -2
  64. package/utils/debounce.js +1 -2
  65. package/utils/focusTrap.js +1 -2
  66. package/utils/history.js +2 -3
  67. package/utils/index.d.ts +2 -1
  68. package/utils/index.js +2 -2
  69. package/utils/keyCodes.js +1 -2
  70. package/utils/math/clamp.js +1 -2
  71. package/utils/math/clamp01.js +1 -2
  72. package/utils/math/damp.js +1 -2
  73. package/utils/math/index.js +1 -2
  74. package/utils/math/inertiaFinalValue.js +1 -2
  75. package/utils/math/lerp.js +1 -2
  76. package/utils/math/map.js +1 -2
  77. package/utils/math/round.js +1 -2
  78. package/utils/memoize.d.ts +30 -0
  79. package/utils/memoize.js +30 -0
  80. package/utils/nextFrame.js +1 -2
  81. package/utils/object/autoBind.js +1 -2
  82. package/utils/object/getAllProperties.js +1 -2
  83. package/utils/object/index.js +1 -2
  84. package/utils/object/isObject.js +1 -2
  85. package/utils/string/index.js +1 -2
  86. package/utils/string/withLeadingCharacters.js +1 -2
  87. package/utils/string/withLeadingSlash.js +1 -2
  88. package/utils/string/withTrailingCharacters.js +1 -2
  89. package/utils/string/withTrailingSlash.js +1 -2
  90. package/utils/string/withoutLeadingCharacters.js +1 -2
  91. package/utils/string/withoutLeadingCharactersRecursive.js +1 -2
  92. package/utils/string/withoutLeadingSlash.js +1 -2
  93. package/utils/string/withoutTrailingCharacters.js +1 -2
  94. package/utils/string/withoutTrailingCharactersRecursive.js +1 -2
  95. package/utils/string/withoutTrailingSlash.js +1 -2
  96. package/utils/throttle.js +1 -2
  97. package/Base/index.js.map +0 -1
  98. package/Base/managers/ChildrenManager.js.map +0 -1
  99. package/Base/managers/EventsManager.js.map +0 -1
  100. package/Base/managers/OptionsManager.js.map +0 -1
  101. package/Base/managers/RefsManager.js.map +0 -1
  102. package/Base/managers/ServicesManager.js.map +0 -1
  103. package/Base/utils.js.map +0 -1
  104. package/components/Accordion/Accordion.d.ts +0 -83
  105. package/components/Accordion/Accordion.js +0 -58
  106. package/components/Accordion/Accordion.js.map +0 -1
  107. package/components/Accordion/AccordionItem.d.ts +0 -122
  108. package/components/Accordion/AccordionItem.js +0 -244
  109. package/components/Accordion/AccordionItem.js.map +0 -1
  110. package/components/Accordion/index.d.ts +0 -27
  111. package/components/Accordion/index.js +0 -19
  112. package/components/Accordion/index.js.map +0 -1
  113. package/components/Cursor.d.ts +0 -138
  114. package/components/Cursor.js +0 -136
  115. package/components/Cursor.js.map +0 -1
  116. package/components/Draggable.d.ts +0 -49
  117. package/components/Draggable.js +0 -43
  118. package/components/Draggable.js.map +0 -1
  119. package/components/Modal.d.ts +0 -158
  120. package/components/Modal.js +0 -186
  121. package/components/Modal.js.map +0 -1
  122. package/components/Tabs.d.ts +0 -108
  123. package/components/Tabs.js +0 -120
  124. package/components/Tabs.js.map +0 -1
  125. package/components/index.d.ts +0 -6
  126. package/components/index.js +0 -7
  127. package/components/index.js.map +0 -1
  128. package/decorators/index.js.map +0 -1
  129. package/decorators/withBreakpointManager.js.map +0 -1
  130. package/decorators/withBreakpointObserver.js.map +0 -1
  131. package/decorators/withDrag.js.map +0 -1
  132. package/decorators/withExtraConfig.js.map +0 -1
  133. package/decorators/withIntersectionObserver.js.map +0 -1
  134. package/decorators/withMountWhenInView.js.map +0 -1
  135. package/helpers/createApp.js.map +0 -1
  136. package/helpers/importOnInteraction.js.map +0 -1
  137. package/helpers/importWhenIdle.js.map +0 -1
  138. package/helpers/importWhenVisible.js.map +0 -1
  139. package/helpers/index.js.map +0 -1
  140. package/helpers/utils.js.map +0 -1
  141. package/index.js.map +0 -1
  142. package/index.modern.js.map +0 -1
  143. package/index.umd.js.map +0 -1
  144. package/services/Service.js.map +0 -1
  145. package/services/drag.js.map +0 -1
  146. package/services/index.js.map +0 -1
  147. package/services/key.js.map +0 -1
  148. package/services/load.js.map +0 -1
  149. package/services/pointer.js.map +0 -1
  150. package/services/raf.js.map +0 -1
  151. package/services/resize.js.map +0 -1
  152. package/services/scroll.js.map +0 -1
  153. package/utils/collide/boundingRectToCircle.js.map +0 -1
  154. package/utils/collide/collideCircleCircle.js.map +0 -1
  155. package/utils/collide/collideCircleRect.js.map +0 -1
  156. package/utils/collide/collidePointCircle.js.map +0 -1
  157. package/utils/collide/collidePointRect.js.map +0 -1
  158. package/utils/collide/collideRectRect.js.map +0 -1
  159. package/utils/collide/index.js.map +0 -1
  160. package/utils/css/classes.js.map +0 -1
  161. package/utils/css/index.js.map +0 -1
  162. package/utils/css/matrix.js.map +0 -1
  163. package/utils/css/styles.js.map +0 -1
  164. package/utils/css/transition.js.map +0 -1
  165. package/utils/debounce.js.map +0 -1
  166. package/utils/focusTrap.js.map +0 -1
  167. package/utils/history.js.map +0 -1
  168. package/utils/index.js.map +0 -1
  169. package/utils/keyCodes.js.map +0 -1
  170. package/utils/math/clamp.js.map +0 -1
  171. package/utils/math/clamp01.js.map +0 -1
  172. package/utils/math/damp.js.map +0 -1
  173. package/utils/math/index.js.map +0 -1
  174. package/utils/math/inertiaFinalValue.js.map +0 -1
  175. package/utils/math/lerp.js.map +0 -1
  176. package/utils/math/map.js.map +0 -1
  177. package/utils/math/round.js.map +0 -1
  178. package/utils/nextFrame.js.map +0 -1
  179. package/utils/object/autoBind.js.map +0 -1
  180. package/utils/object/getAllProperties.js.map +0 -1
  181. package/utils/object/index.js.map +0 -1
  182. package/utils/object/isObject.js.map +0 -1
  183. package/utils/string/index.js.map +0 -1
  184. package/utils/string/withLeadingCharacters.js.map +0 -1
  185. package/utils/string/withLeadingSlash.js.map +0 -1
  186. package/utils/string/withTrailingCharacters.js.map +0 -1
  187. package/utils/string/withTrailingSlash.js.map +0 -1
  188. package/utils/string/withoutLeadingCharacters.js.map +0 -1
  189. package/utils/string/withoutLeadingCharactersRecursive.js.map +0 -1
  190. package/utils/string/withoutLeadingSlash.js.map +0 -1
  191. package/utils/string/withoutTrailingCharacters.js.map +0 -1
  192. package/utils/string/withoutTrailingCharactersRecursive.js.map +0 -1
  193. package/utils/string/withoutTrailingSlash.js.map +0 -1
  194. package/utils/throttle.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.modern.js","sources":["../packages/js-toolkit/utils/object/getAllProperties.js","../packages/js-toolkit/Base/utils.js","../packages/js-toolkit/Base/managers/ChildrenManager.js","../packages/js-toolkit/Base/managers/RefsManager.js","../packages/js-toolkit/services/Service.js","../packages/js-toolkit/services/pointer.js","../packages/js-toolkit/services/raf.js","../packages/js-toolkit/utils/nextFrame.js","../packages/js-toolkit/utils/debounce.js","../packages/js-toolkit/services/resize.js","../packages/js-toolkit/services/scroll.js","../packages/js-toolkit/utils/keyCodes.js","../packages/js-toolkit/services/key.js","../packages/js-toolkit/services/load.js","../packages/js-toolkit/Base/managers/ServicesManager.js","../packages/js-toolkit/Base/managers/EventsManager.js","../node_modules/deepmerge/dist/cjs.js","../packages/js-toolkit/Base/managers/OptionsManager.js","../packages/js-toolkit/utils/object/isObject.js","../packages/js-toolkit/Base/index.js","../packages/js-toolkit/utils/object/autoBind.js","../packages/js-toolkit/decorators/withBreakpointManager.js","../packages/js-toolkit/decorators/withBreakpointObserver.js","../packages/js-toolkit/utils/math/inertiaFinalValue.js","../packages/js-toolkit/services/drag.js","../packages/js-toolkit/decorators/withDrag.js","../packages/js-toolkit/decorators/withExtraConfig.js","../packages/js-toolkit/decorators/withIntersectionObserver.js","../packages/js-toolkit/decorators/withMountWhenInView.js","../packages/js-toolkit/helpers/createApp.js","../packages/js-toolkit/helpers/utils.js","../packages/js-toolkit/helpers/importOnInteraction.js","../packages/js-toolkit/helpers/importWhenIdle.js","../packages/js-toolkit/helpers/importWhenVisible.js"],"sourcesContent":["/**\n * Gets all non-builtin properties up the prototype chain.\n *\n * @param {Object} object\n * The object to get the propeties from.\n * @param {Array=} [props=[]]\n * The already existing properties.\n * @param {(name:string, proto:any) => boolean} testFn\n * @return {Array<[String, Object]>} An array of properties and the prototype they belong to.\n */\nexport default function getAllProperties(object, props = [], testFn = null) {\n const proto = Object.getPrototypeOf(object);\n\n if (proto === Object.prototype) {\n return props;\n }\n\n let foundProps = Object.getOwnPropertyNames(proto);\n\n if (typeof testFn === 'function') {\n foundProps = foundProps.filter((name) => testFn(name, proto));\n }\n\n foundProps = foundProps.map((name) => [name, proto]).reduce((acc, val) => [...acc, val], props);\n\n return getAllProperties(proto, foundProps, testFn);\n}\n","/**\n * @typedef {import('./index.js').default} Base\n */\n\n/**\n * Test if an object has a method.\n *\n * @param {Object} obj The object to test\n * @param {String} name The method's name\n * @return {Boolean}\n */\nexport function hasMethod(obj, name) {\n return typeof obj[name] === 'function';\n}\n\n/**\n * Call the given method while applying the given arguments.\n *\n * @param {Base} instance The Base instance on which to trigger the method.\n * @param {String} method The method to call.\n * @param {...any} args The arguments to pass to the method.\n */\nexport function callMethod(instance, method, ...args) {\n instance.__debug('callMethod', method, ...args);\n\n // Prevent duplicate call of `mounted` and `destroyed`\n // methods based on the component status\n if (\n (method === 'destroyed' && !instance.$isMounted) ||\n (method === 'mounted' && instance.$isMounted)\n ) {\n instance.__debug('not', method, 'because the method has already been triggered once.');\n return instance;\n }\n\n instance.$emit(method, ...args);\n\n // We always emit an event, but we do not call the method if it does not exist\n if (!hasMethod(instance, method)) {\n return instance;\n }\n\n instance[method].call(instance, ...args);\n instance.__debug(method, instance, ...args);\n\n return instance;\n}\n\n/**\n * Get a list of elements based on the name of a component.\n *\n * @param {String} nameOrSelector\n * The name or selector to used for this component.\n * @param {HTMLElement|Document} element\n * The root element on which to query the selector, defaults to `document`.\n * @return {Array<HTMLElement>}\n * A list of elements on which the component should be mounted.\n */\nexport function getComponentElements(nameOrSelector, element = document) {\n const selector = `[data-component=\"${nameOrSelector}\"]`;\n let elements = [];\n\n try {\n elements = Array.from(element.querySelectorAll(selector));\n // eslint-disable-next-line no-empty\n } catch {}\n\n // If no child component found with the default selector, try a classic DOM selector\n if (elements.length === 0) {\n elements = Array.from(element.querySelectorAll(nameOrSelector));\n }\n\n return elements;\n}\n","import { getComponentElements } from '../utils.js';\n\n/**\n * @typedef {import('../index.js').default} Base\n * @typedef {import('../index.js').BaseComponent} BaseComponent\n * @typedef {import('../index.js').BaseAsyncComponent} BaseAsyncComponent\n * @typedef {import('../index.js').BaseConfigComponents} BaseConfigComponents\n * @typedef {import('./EventsManager.js').default} EventsManager\n */\n\n/**\n * Children manager.\n */\nexport default class ChildrenManager {\n /**\n * @type {Base}\n * @private\n */\n __base;\n\n /**\n * @type {HTMLElement}\n * @private\n */\n __element;\n\n /**\n * @type {BaseConfigComponents}\n * @private\n */\n __components;\n\n /**\n * @type {EventsManager}\n * @private\n */\n __eventsManager;\n\n /**\n * @return {string[]}\n */\n get registeredNames() {\n return Object.keys(this).filter((key) => !key.startsWith('__'));\n }\n\n /**\n * Class constructor.\n * @param {Base} base\n * The component's instance.\n * @param {HTMLElement} element\n * The component's root element\n * @param {BaseConfigComponents} components\n * The children components' classes\n * @param {EventsManager} eventsManager\n */\n constructor(base, element, components, eventsManager) {\n this.__base = base;\n this.__element = element;\n this.__components = components;\n this.__eventsManager = eventsManager;\n }\n\n /**\n * Register instances of all children components.\n */\n registerAll() {\n Object.entries(this.__components).forEach(([name, component]) =>\n this.__register(name, component)\n );\n }\n\n /**\n * Register instance of a child component.\n *\n * @param {string} name\n * The name of the child component.\n * @param {BaseComponent|BaseAsyncComponent} component\n * A Base class or a Promise for async components.\n * @private\n */\n __register(name, component) {\n Object.defineProperty(this, name, {\n enumerable: true,\n configurable: true,\n get: () => {\n const elements = getComponentElements(name, this.__element);\n\n if (elements.length === 0) {\n return [];\n }\n\n return elements\n .map((element) => this.__getChild(element, component, name))\n .filter((instance) => instance !== 'terminated');\n },\n });\n }\n\n /**\n * Get a child component's instance.\n *\n * @param {HTMLElement & { __base__?: Base | 'terminated' }} el\n * The root element of the child component.\n * @param {BaseComponent|BaseAsyncComponent} ComponentClass\n * A Base class or a Promise for async components.\n * @param {string} name\n * The name of the child component.\n * @return {Base|Promise|'terminated'}\n * A Base instance or a Promise resolving to a Base instance.\n * @private\n */\n __getChild(el, ComponentClass, name) {\n // Return existing instance if it exists\n if (el.__base__) {\n return el.__base__;\n }\n\n // Return a new instance if the component class is a child of the Base class\n if ('$isBase' in ComponentClass) {\n const child = new ComponentClass(el);\n Object.defineProperty(child, '$parent', { get: () => this.__base });\n return child;\n }\n\n // Resolve async components\n return ComponentClass(this.__base).then((module) => {\n // @ts-ignore\n return this.__getChild(el, module.default ?? module, name);\n });\n }\n\n /**\n * Mount all child component instances.\n */\n mountAll() {\n this.__triggerHookForAll('$mount');\n }\n\n /**\n * Update all child component instances.\n */\n updateAll() {\n this.__triggerHookForAll('$update');\n }\n\n /**\n * Destroy all child component instances.\n */\n destroyAll() {\n this.__triggerHookForAll('$destroy');\n }\n\n /**\n * Execute the given hook for all children instances.\n *\n * @param {'$mount'|'$update'|'$destroy'} hook The hook to execute.\n * @private\n */\n __triggerHookForAll(hook) {\n this.registeredNames.forEach((name) => {\n this[name].forEach((instance) => {\n if (instance instanceof Promise) {\n instance.then((resolvedInstance) => this.__triggerHook(hook, resolvedInstance, name));\n } else {\n this.__triggerHook(hook, instance, name);\n }\n });\n });\n }\n\n /**\n * Execute the given hook for the given instance.\n *\n * @param {'$mount'|'$update'|'$destroy'} hook The hook to trigger.\n * @param {Base} instance The target instance.\n * @param {string} name The name of the component.\n * @private\n */\n __triggerHook(hook, instance, name) {\n if (hook === '$update' && !instance.$isMounted) {\n // eslint-disable-next-line no-param-reassign\n hook = '$mount';\n }\n\n if (hook === '$update' || hook === '$destroy') {\n this.__eventsManager.unbindChild(name, instance);\n }\n\n if (hook === '$update' || hook === '$mount') {\n this.__eventsManager.bindChild(name, instance);\n }\n\n instance[hook]();\n }\n}\n","/**\n * @typedef {import('../index.js').default} Base\n * @typedef {import('./EventsManager.js').default} EventsManager\n */\n\n/**\n * Refs Manager\n */\nexport default class RefsManager {\n /**\n * @type {HTMLElement}\n * @private\n */\n __element;\n\n /**\n * @type {string[]}\n * @private\n */\n __refs;\n\n /**\n * @type {Base}\n * @private\n */\n __base;\n\n /**\n * @type {EventsManager}\n * @private\n */\n __eventsManager;\n\n /**\n * Class constructor.\n *\n * @param {Base} base\n * The base instance tied to this manager.\n * @param {HTMLElement} element\n * The root element of a Base component.\n * @param {string[]} refs\n * The list of refs of this component.\n * @param {EventsManager} eventsManager\n */\n constructor(base, element, refs, eventsManager) {\n this.__element = element;\n this.__refs = refs;\n this.__base = base;\n this.__eventsManager = eventsManager;\n }\n\n /**\n * Register all refs.\n *\n * @return {void}\n */\n registerAll() {\n this.__refs.forEach((refName) => this.__register(refName));\n }\n\n /**\n * Unregister all refs.\n *\n * @return {void}\n */\n unregisterAll() {\n this.__refs.forEach((refName) => this.__unregister(refName));\n }\n\n /**\n * Register one ref.\n *\n * @param {string} refName The ref name.\n * @private\n */\n __register(refName) {\n const isMultiple = refName.endsWith('[]');\n const propName = RefsManager.normalizeRefName(refName);\n\n const refs = /** @type {HTMLElement[]} */ (\n Array.from(this.__element.querySelectorAll(`[data-ref=\"${refName}\"]`))\n ).filter(\n /**\n * @param {HTMLElement} ref\n */\n (ref) => this.__filterRefsBelongingToInstance(ref)\n );\n\n if (!isMultiple && refs.length > 1) {\n console.warn(\n `[${this.__base.$options.name}]`,\n `The \"${refName}\" ref has been found multiple times.`,\n 'Did you forgot to add the `[]` suffix to its name?'\n );\n }\n\n this.__eventsManager.bindRef(refName, refs);\n\n Object.defineProperty(this, propName, {\n // @todo remove usage of non-multiple refs as array\n value: isMultiple || refs.length > 1 ? refs : refs[0],\n enumerable: true,\n configurable: true,\n });\n }\n\n /**\n * Unregister one ref.\n *\n * @param {string} refName The ref name.\n * @private\n */\n __unregister(refName) {\n const propName = RefsManager.normalizeRefName(refName);\n const refs = Array.isArray(this[propName]) ? this[propName] : [this[propName]];\n this.__eventsManager.unbindRef(refName, refs);\n }\n\n /**\n * Normalize the name of ref.\n *\n * @param {string} name The original name.\n * @return {string} The normalized name.\n */\n static normalizeRefName(name) {\n return name.endsWith('[]') ? name.replace(/\\[\\]$/, '') : name;\n }\n\n /**\n * Filter refs belonging to the related Base instance.\n *\n * @param {HTMLElement} ref The ref to test.\n * @return {boolean}\n * @private\n */\n __filterRefsBelongingToInstance(ref) {\n let ancestor = ref.parentElement;\n\n while (ancestor && ancestor.dataset.component === undefined) {\n ancestor = ancestor.parentElement;\n }\n\n return ancestor === null || ancestor === this.__element;\n }\n}\n","/**\n * Service abstract class\n */\nexport default class Service {\n /**\n * Class constructor, used to test the abstract class implementation.\n */\n constructor() {\n this.callbacks = new Map();\n this.isInit = false;\n }\n\n /**\n * Getter to get the services properties.\n * This getter MUST be implementer by the service extending this class.\n * @return {Object}\n */\n get props() {\n throw new Error('The `props` getter must be implemented.');\n }\n\n /**\n * Method to initialize the service behaviors.\n * This method MUST be implemented by the service extending this class.\n *\n * @return {Service} The current instance\n */\n init() {\n throw new Error('The `init` method must be implemented.');\n }\n\n /**\n * Method to kill the service behaviors.\n * This method MUST be implemented by the service extending this class.\n *\n * @return {Service} The current instance\n */\n kill() {\n throw new Error('The `kill` method must be implemented.');\n }\n\n /**\n * Add a callback.\n *\n * @param {String} key The callback's identifier\n * @param {Function} callback The callback function\n * @return {this} The current instance\n */\n add(key, callback) {\n if (this.has(key)) {\n throw new Error(`A callback with the key \\`${key}\\` has already been registered.`);\n }\n\n // Initialize the service when we add the first callback\n if (this.callbacks.size === 0 && !this.isInit) {\n this.init();\n this.isInit = true;\n }\n\n this.callbacks.set(key, callback);\n return this;\n }\n\n /**\n * Test if a callback with the given key has already been added.\n *\n * @param {String} key The identifier to test\n * @return {Boolean} Whether or not the identifier already exists\n */\n has(key) {\n return this.callbacks.has(key);\n }\n\n /**\n * Get the callback tied to the given key.\n *\n * @param {String} key The identifier to get\n * @return {Function} The callback function\n */\n get(key) {\n return this.callbacks.get(key);\n }\n\n /**\n * Remove the callback tied to the given key.\n *\n * @param {String} key The identifier to remove\n * @return {Service} The current instance\n */\n remove(key) {\n this.callbacks.delete(key);\n\n // Kill the service when we remove the last callback\n if (this.callbacks.size === 0 && this.isInit) {\n this.kill();\n this.isInit = false;\n }\n\n return this;\n }\n\n /**\n * Trigger each added callback with the given arguments.\n *\n * @param {Array} args All the arguments to apply to the callback\n * @return {Service} The current instance\n */\n trigger(...args) {\n this.callbacks.forEach(function forEachCallback(callback) {\n callback(...args);\n });\n\n return this;\n }\n}\n","import Service from './Service.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {Object} PointerServiceProps\n * @property {MouseEvent | TouchEvent} event\n * @property {Boolean} isDown\n * @property {Number} x\n * @property {Number} y\n * @property {{ x: Boolean, y: Boolean }} changed\n * @property {{ x: Number, y: Number }} last\n * @property {{ x: Number, y: Number }} delta\n * @property {{ x: Number, y: Number }} progress\n * @property {{ x: Number, y: Number }} max\n */\n\n/**\n * @typedef {Object} PointerService\n * @property {(key:String, callback:(props:PointerServiceProps) => void) => void} add\n * Add a function to the resize service. The key must be uniq.\n * @property {() => PointerServiceProps} props\n * Get the current values of the resize service props.\n */\n\n/**\n * Test if an event is an instance of TouchEvent.\n *\n * @param {TouchEvent|MouseEvent} event The event instance to test.\n * @return {Boolean} Is it a TouchEvent?\n */\nfunction isTouchEvent(event) {\n return typeof TouchEvent !== 'undefined' && event instanceof TouchEvent;\n}\n\n/**\n * Pointer service\n */\nclass Pointer extends Service {\n /** @type {Boolean} State of the pointer. */\n isDown = false;\n\n /** @type {Number} The y pointer position. */\n y = window.innerHeight / 2;\n\n /** @type {Number} The y previous pointer position. */\n yLast = window.innerHeight / 2;\n\n /** @type {Number} The x pointer position. */\n x = window.innerWidth / 2;\n\n /** @type {Number} The x previous pointer position. */\n xLast = window.innerWidth / 2;\n\n /** @type {MouseEvent|TouchEvent} The latest event emitted from the pointer. */\n event;\n\n /**\n * Whether or not the raf service is running.\n * @type {Boolean}\n */\n hasRaf = false;\n\n /**\n * Bind the handler to the mousemove and touchmove events.\n * Bind the up and down handler to the mousedown, mouseup, touchstart and touchend events.\n *\n * @return {Pointer}\n */\n init() {\n document.documentElement.addEventListener('mouseenter', this, {\n once: true,\n capture: true,\n });\n\n const options = { passive: true, capture: true };\n document.addEventListener('mousemove', this, options);\n document.addEventListener('touchmove', this, options);\n document.addEventListener('mousedown', this, options);\n document.addEventListener('touchstart', this, options);\n document.addEventListener('mouseup', this, options);\n document.addEventListener('touchend', this, options);\n return this;\n }\n\n /**\n * Handle events.\n * @param {MouseEvent|TouchEvent} event The event object.\n */\n handleEvent(event) {\n // eslint-disable-next-line default-case\n switch (event.type) {\n case 'mouseenter':\n case 'mousemove':\n case 'touchmove':\n this.handler(event);\n break;\n case 'mousedown':\n case 'touchstart':\n this.downHandler();\n break;\n case 'mouseup':\n case 'touchend':\n this.upHandler();\n break;\n }\n }\n\n /**\n * Unbind all handlers from their bounded event.\n *\n * @return {Pointer}\n */\n kill() {\n document.removeEventListener('mousemove', this);\n document.removeEventListener('touchmove', this);\n document.removeEventListener('mousedown', this);\n document.removeEventListener('touchstart', this);\n document.removeEventListener('mouseup', this);\n document.removeEventListener('touchend', this);\n return this;\n }\n\n /**\n * The service handler.\n * @param {MouseEvent|TouchEvent} event The mouse event object.\n */\n handler(event) {\n this.updateValues(event);\n this.trigger(this.props);\n }\n\n /**\n * Handler for the pointer's down action.\n *\n * @return {void}\n */\n downHandler() {\n this.isDown = true;\n this.trigger(this.props);\n }\n\n /**\n * Handler for the pointer's up action.\n *\n * @return {void}\n */\n upHandler() {\n this.isDown = false;\n this.trigger(this.props);\n }\n\n /**\n * Update the pointer positions.\n *\n * @param {MouseEvent|TouchEvent} event The event object.\n * @return {void}\n */\n updateValues(event) {\n this.event = event;\n this.yLast = this.y;\n this.xLast = this.x;\n\n // Check pointer Y\n // We either get data from a touch event `event.touches[0].clientY` or from\n // a mouse event `event.clientY`.\n const y = isTouchEvent(event)\n ? /** @type {TouchEvent} */ (event).touches[0]?.clientY\n : /** @type {MouseEvent} */ (event).clientY;\n if (y !== this.y) {\n this.y = y;\n }\n\n // Check pointer X\n // We either get data from a touch event `event.touches[0].clientX` or from\n // a mouse event `event.clientX`.\n const x = isTouchEvent(event)\n ? /** @type {TouchEvent} */ (event).touches[0]?.clientX\n : /** @type {MouseEvent} */ (event).clientX;\n if (x !== this.x) {\n this.x = x;\n }\n }\n\n /**\n * Get the pointer props.\n *\n * @type {Object}\n */\n get props() {\n return {\n event: this.event,\n isDown: this.isDown,\n x: this.x,\n y: this.y,\n changed: {\n x: this.x !== this.xLast,\n y: this.y !== this.yLast,\n },\n last: {\n x: this.xLast,\n y: this.yLast,\n },\n delta: {\n x: this.x - this.xLast,\n y: this.y - this.yLast,\n },\n progress: {\n x: this.x / window.innerWidth,\n y: this.y / window.innerHeight,\n },\n max: {\n x: window.innerWidth,\n y: window.innerHeight,\n },\n };\n }\n}\n\nlet pointer = null;\n\n/**\n * Use the pointer.\n *\n * ```js\n * import usePointer from '@studiometa/js-toolkit/services';\n * const { add, remove, props } = usePointer();\n * add('id', () => {});\n * remove('id');\n * props();\n * ```\n *\n * @return {ServiceInterface & PointerService}\n */\nexport default function usePointer() {\n if (!pointer) {\n pointer = new Pointer();\n }\n\n const add = pointer.add.bind(pointer);\n const remove = pointer.remove.bind(pointer);\n const has = pointer.has.bind(pointer);\n const props = () => pointer.props;\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n","import Service from './Service.js';\nimport { getRaf, getCancelRaf } from '../utils/nextFrame.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {Object} RafServiceProps\n * @property {DOMHighResTimeStamp} time\n */\n\n/**\n * @typedef {Object} RafService\n * @property {(key:String, callback:(props:RafServiceProps) => void) => void} add\n * Add a function to the resize service. The key must be uniq.\n * @property {() => RafServiceProps} props\n * Get the current values of the resize service props.\n */\n\n/**\n * Tick service\n */\nclass Raf extends Service {\n /** @type {Boolean} Whether the loop is running or not. */\n isTicking = false;\n\n /** @type {number} */\n id = 0;\n\n raf = getRaf();\n\n cancelRaf = getCancelRaf();\n\n /**\n * Bind loop to the instance.\n */\n constructor() {\n super();\n this.loop = this.loop.bind(this);\n }\n\n /**\n * Start the requestAnimationFrame loop.\n *\n * @return {Raf}\n */\n init() {\n this.isTicking = true;\n this.loop();\n return this;\n }\n\n /**\n * Loop method.\n */\n loop() {\n this.trigger(this.props);\n\n if (!this.isTicking) {\n return;\n }\n\n this.id = this.raf(this.loop);\n }\n\n /**\n * Stop the requestAnimationFrame loop.\n *\n * @return {Raf}\n */\n kill() {\n this.cancelRaf(this.id);\n this.isTicking = false;\n return this;\n }\n\n /**\n * Get raf props.\n *\n * @todo Return elapsed time / index?\n * @type {Object}\n */\n get props() {\n return {\n time: window.performance.now(),\n };\n }\n}\n\nlet instance = null;\n\n/**\n * Use the RequestAnimationFrame (raf) service.\n *\n * ```js\n * import { useRaf } from '@studiometa/js/services';\n * const { add, remove, props } = useRag();\n * add(id, (props) => {});\n * remove(id);\n * props();\n * ```\n *\n * @return {ServiceInterface & RafService}\n */\nexport default function useRaf() {\n if (!instance) {\n instance = new Raf();\n }\n\n const add = instance.add.bind(instance);\n const remove = instance.remove.bind(instance);\n const has = instance.has.bind(instance);\n\n // eslint-disable-next-line require-jsdoc\n function props() {\n return instance.props;\n }\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n","/**\n * RequestAnimation frame polyfill.\n * @see https://github.com/vuejs/vue/blob/ec78fc8b6d03e59da669be1adf4b4b5abf670a34/dist/vue.runtime.esm.js#L7355\n * @return {(handler: Function) => number}\n */\nexport function getRaf() {\n return typeof window !== 'undefined' && window.requestAnimationFrame\n ? window.requestAnimationFrame.bind(window)\n : setTimeout;\n}\n\n/**\n * Get a function to cancel the method returned by `getRaf()`.\n *\n * @return {(id:number) => void}\n */\nexport function getCancelRaf() {\n return typeof window !== 'undefined' && window.cancelAnimationFrame\n ? window.cancelAnimationFrame.bind(window)\n : clearTimeout;\n}\n\n/**\n * Wait for the next frame to execute a function.\n *\n * @param {Function=} [fn=() => {}] The callback function to execute.\n * @return {Promise} A Promise resolving when the next frame is reached.\n *\n * @example\n * ```js\n * nextFrame(() => console.log('hello world'));\n *\n * await nextFrame();\n * console.log('hello world');\n * ```\n */\nexport default function nextFrame(fn = () => {}) {\n const raf = getRaf();\n return new Promise((resolve) => {\n raf(() => raf(() => resolve(fn())));\n });\n}\n","/**\n * Returns a function, that, as long as it continues to be invoked,\n * will not be triggered. The function will be called after it stops\n * being called for N milliseconds.\n *\n * @param {(...args:any[]) => void} fn The function to call.\n * @param {Number=} [delay=300] The delay in ms to wait before calling the function.\n * @return {(...args:any[]) => void} The debounced function.\n */\nexport default function debounce(fn, delay = 300) {\n let timeout;\n return function debounced(...args) {\n clearTimeout(timeout);\n timeout = setTimeout(() => {\n fn(...args);\n }, delay);\n };\n}\n","import Service from './Service.js';\nimport debounce from '../utils/debounce.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {Object} ResizeServiceProps\n * @property {Number} width\n * @property {Number} height\n * @property {Number} ratio\n * @property {'square'|'landscape'|'portrait'} orientation\n * @property {String} [breakpoint]\n * @property {String[]} [breakpoints]\n */\n\n/**\n * @typedef {Object} ResizeService\n * @property {(key:String, callback:(props:ResizeServiceProps) => void) => void} add\n * Add a function to the resize service. The key must be uniq.\n * @property {() => ResizeServiceProps} props\n * Get the current values of the resize service props.\n */\n\n/**\n * Resize service\n *\n * ```\n * import { useResize } from '@studiometa/js/services';\n * const { add, remove, props } = useResize();\n * add(key, (props) => {});\n * remove(key);\n * props();\n * ```\n */\nclass Resize extends Service {\n /**\n * Bind the handler to the resize event.\n *\n * @return {this}\n */\n init() {\n this.handler = debounce(() => {\n this.trigger(this.props);\n }).bind(this);\n\n window.addEventListener('resize', this.handler);\n\n return this;\n }\n\n /**\n * Unbind the handler from the resize event.\n *\n * @return {this}\n */\n kill() {\n window.removeEventListener('resize', this.handler);\n\n return this;\n }\n\n /**\n * Get resize props.\n *\n * @type {ResizeServiceProps}\n */\n get props() {\n /** @type {ResizeServiceProps} [description] */\n const props = {\n width: window.innerWidth,\n height: window.innerHeight,\n ratio: window.innerWidth / window.innerHeight,\n orientation: 'square',\n };\n\n if (props.ratio > 1) {\n props.orientation = 'landscape';\n }\n\n if (props.ratio < 1) {\n props.orientation = 'portrait';\n }\n\n if (this.breakpointElement) {\n props.breakpoint = this.breakpoint;\n props.breakpoints = this.breakpoints;\n }\n\n return props;\n }\n\n /**\n * The element holding the breakpoints data.\n * @return {HTMLElement}\n */\n get breakpointElement() {\n return document.querySelector('[data-breakpoint]') || null;\n }\n\n /**\n * Get the current breakpoint.\n * @return {String}\n */\n get breakpoint() {\n return window\n .getComputedStyle(this.breakpointElement, '::before')\n .getPropertyValue('content')\n .replace(/\"/g, '');\n }\n\n /**\n * Get all breakpoints.\n * @return {Array}\n */\n get breakpoints() {\n const breakpoints = window\n .getComputedStyle(this.breakpointElement, '::after')\n .getPropertyValue('content')\n .replace(/\"/g, '');\n\n return breakpoints.split(',');\n }\n\n /**\n * Test if we can use the `ResizeObserver` API.\n * @return {Boolean}\n */\n get canUseResizeObserver() {\n return typeof window.ResizeObserver !== 'undefined';\n }\n}\n\nlet resize = null;\n\n/**\n * Use the resize service.\n *\n * ```js\n * import useResize from '@studiometa/js-toolkit/services/resize';\n * const { add, remove, props } = useResize();\n * add(key, (props) => {});\n * remove(key);\n * props();\n * ```\n * @return {ServiceInterface & ResizeService}\n */\nexport default function useResize() {\n if (!resize) {\n resize = new Resize();\n }\n\n const add = resize.add.bind(resize);\n const remove = resize.remove.bind(resize);\n const has = resize.has.bind(resize);\n const props = () => resize.props;\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n","import Service from './Service.js';\nimport debounce from '../utils/debounce.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {Object} ScrollServiceProps\n * @property {Number} x\n * @property {Number} y\n * @property {{ x: Boolean, y: Boolean }} changed\n * @property {{ x: Number, y: Number }} last\n * @property {{ x: Number, y: Number }} delta\n * @property {{ x: Number, y: Number }} progress\n * @property {{ x: Number, y: Number }} max\n * @property {{ x: 'LEFT'|'RIGHT'|'NONE', y: 'UP'|'DOWN'|'NONE' }} direction\n */\n\n/**\n * @typedef {Object} ScrollService\n * @property {(key:String, callback:(props:ScrollServiceProps) => void) => void} add\n * Add a function to the resize service. The key must be uniq.\n * @property {() => ScrollServiceProps} props\n * Get the current values of the resize service props.\n */\n\n/**\n * Scroll service\n */\nclass Scroll extends Service {\n /** @type {Number} The y scroll position. */\n y = window.pageYOffset;\n\n /** @type {Number} The y previous scroll position. */\n yLast = window.pageYOffset;\n\n /** @type {Number} The x scroll position. */\n x = window.pageXOffset;\n\n /** @type {Number} The x previous scroll position. */\n xLast = window.pageXOffset;\n\n /**\n * Bind the handler to the scroll event.\n *\n * @return {Scroll}\n */\n init() {\n document.addEventListener('scroll', this, { passive: true, capture: true });\n return this;\n }\n\n /**\n * Debounced handler.\n *\n * @return {() => void}\n */\n get debouncedHandler() {\n const debounced = debounce(() => {\n this.trigger(this.props);\n }, 0);\n\n // Define property to avoid multiple call to the getter\n Object.defineProperty(this, 'debouncedHandler', {\n value: debounced,\n });\n\n return debounced;\n }\n\n /**\n * Scroll event handler.\n *\n * @return {void}\n */\n handleEvent() {\n this.trigger(this.props);\n\n this.debouncedHandler();\n }\n\n /**\n * Unbind the handler from the scroll event.\n *\n * @return {Scroll}\n */\n kill() {\n document.removeEventListener('scroll', this);\n return this;\n }\n\n /**\n * Get scroll props.\n *\n * @type {Object}\n */\n get props() {\n this.yLast = this.y;\n this.xLast = this.x;\n\n // Check scroll Y\n if (window.pageYOffset !== this.y) {\n this.y = window.pageYOffset;\n }\n\n // Check scroll x\n if (window.pageXOffset !== this.x) {\n this.x = window.pageXOffset;\n }\n\n return {\n x: this.x,\n y: this.y,\n changed: {\n x: this.x !== this.xLast,\n y: this.y !== this.yLast,\n },\n last: {\n x: this.xLast,\n y: this.yLast,\n },\n delta: {\n x: this.x - this.xLast,\n y: this.y - this.yLast,\n },\n progress: {\n x: this.max.x === 0 ? 1 : this.x / this.max.x,\n y: this.max.y === 0 ? 1 : this.y / this.max.y,\n },\n direction: {\n /* eslint-disable no-nested-ternary */\n x: this.x > this.xLast ? 'RIGHT' : this.x < this.xLast ? 'LEFT' : 'NONE',\n y: this.y > this.yLast ? 'DOWN' : this.y < this.yLast ? 'UP' : 'NONE',\n /* eslint-enable no-nested-ternary */\n },\n max: this.max,\n };\n }\n\n /**\n * Get scroll max values.\n *\n * @type {Object}\n */\n get max() {\n return {\n x: (document.scrollingElement || document.body).scrollWidth - window.innerWidth,\n y: (document.scrollingElement || document.body).scrollHeight - window.innerHeight,\n };\n }\n}\n\nlet scroll = null;\n\n/**\n * Use the scroll service.\n *\n * ```js\n * import { useScroll } from '@studiometa/js-toolkit/services';\n * const { add, remove, props } = useScroll();\n * add(key, (props) => {});\n * remove(key);\n * props();\n * ```\n *\n * @return {ServiceInterface & ScrollService}\n */\nexport default function useScroll() {\n if (!scroll) {\n scroll = new Scroll();\n }\n\n const add = scroll.add.bind(scroll);\n const remove = scroll.remove.bind(scroll);\n const has = scroll.has.bind(scroll);\n const props = () => scroll.props;\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n","export default {\n ENTER: 13,\n SPACE: 32,\n TAB: 9,\n ESC: 27,\n LEFT: 37,\n UP: 38,\n RIGHT: 39,\n DOWN: 40,\n};\n","import Service from './Service.js';\nimport keyCodes from '../utils/keyCodes.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {Object} KeyServiceProps\n * @property {KeyboardEvent} event\n * @property {Number} triggered\n * @property {Boolean} isUp\n * @property {Boolean} isDown\n * @property {Boolean} ENTER\n * @property {Boolean} SPACE\n * @property {Boolean} TAB\n * @property {Boolean} ESC\n * @property {Boolean} LEFT\n * @property {Boolean} UP\n * @property {Boolean} RIGHT\n * @property {Boolean} DOWN\n */\n\n/**\n * @typedef {Object} KeyService\n * @property {(key:String, callback:(props:KeyServiceProps) => void) => void} add\n * Add a function to the resize service. The key must be uniq.\n * @property {() => KeyServiceProps} props\n * Get the current values of the resize service props.\n */\n\n/**\n * Scroll service\n */\nclass Key extends Service {\n /** @type {Object} The event object. */\n event = {};\n\n /**\n * Used to accumulate the number of times the `keydown` event has been triggered.\n * @type {Number}\n */\n triggered = 0;\n\n /** @type {Object} The previous event object. */\n previousEvent = {};\n\n /**\n * Bind the handler to the keyboard event.\n *\n * @return {Key}\n */\n init() {\n this.handler = (event) => {\n this.event = event;\n this.trigger(this.props);\n };\n document.addEventListener('keydown', this.handler, { passive: false });\n document.addEventListener('keyup', this.handler, { passive: false });\n return this;\n }\n\n /**\n * Unbind the handler from the keyboard event.\n *\n * @return {Key}\n */\n kill() {\n document.removeEventListener('keydown', this.handler);\n document.removeEventListener('keyup', this.handler);\n return this;\n }\n\n /**\n * Get keyboard props.\n *\n * @type {Object}\n */\n get props() {\n const keys = Object.entries(keyCodes).reduce((acc, [name, code]) => {\n acc[name] = code === this.event.keyCode;\n return acc;\n }, {});\n\n if (!this.previousEvent.type) {\n this.triggered = 0;\n }\n\n if (this.event.type === 'keydown' && this.previousEvent.type === 'keydown') {\n this.triggered += 1;\n } else {\n this.triggered = 1;\n }\n\n this.previousEvent = this.event;\n\n return {\n event: this.event,\n triggered: this.triggered,\n direction: this.event.type === 'keydown' ? 'down' : 'up',\n isUp: this.event.type === 'keyup',\n isDown: this.event.type === 'keydown',\n ...keys,\n };\n }\n}\n\nlet key = null;\n\n/**\n * Use the keyboard service.\n *\n * ```js\n * import { useKey } from '@studiometa/js-toolkit/services';\n * const { add, remove, props } = useKey();\n * add(key, (props) => {});\n * remove(key);\n * props();\n * ```\n *\n * @return {ServiceInterface & KeyService}\n */\nexport default function useKey() {\n if (!key) {\n key = new Key();\n }\n\n const add = key.add.bind(key);\n const remove = key.remove.bind(key);\n const has = key.has.bind(key);\n const props = () => key.props;\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n","import Service from './Service.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {Object} LoadServiceProps\n * @property {DOMHighResTimeStamp} time\n */\n\n/**\n * @typedef {Object} LoadService\n * @property {(key:String, callback:(props:LoadServiceProps) => void) => void} add\n * Add a function to the resize service. The key must be uniq.\n * @property {() => LoadServiceProps} props\n * Get the current values of the resize service props.\n */\n\n/**\n * Load service\n */\nclass Load extends Service {\n /**\n * Start the requestAnimationFrame loop.\n *\n * @return {Load}\n */\n init() {\n this.handler = () => {\n this.trigger(this.props);\n };\n\n window.addEventListener('load', this.handler);\n return this;\n }\n\n /**\n * Stop the requestAnimationFrame loop.\n *\n * @return {Load}\n */\n kill() {\n window.removeEventListener('load', this.handler);\n return this;\n }\n\n /**\n * Get raf props.\n *\n * @todo Return elapsed time / index?\n * @type {Object}\n */\n get props() {\n return {};\n }\n}\n\nlet instance = null;\n\n/**\n * Use the load service.\n *\n * ```js\n * import { useLoad } from '@studiometa/js/services';\n * const { add, remove, props } = useRag();\n * add(id, (props) => {});\n * remove(id);\n * props();\n * ```\n *\n * @return {ServiceInterface & LoadService}\n */\nexport default function useRaf() {\n if (!instance) {\n instance = new Load();\n }\n\n const add = instance.add.bind(instance);\n const remove = instance.remove.bind(instance);\n const has = instance.has.bind(instance);\n\n // eslint-disable-next-line require-jsdoc\n function props() {\n return instance.props;\n }\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n","import usePointer from '../../services/pointer.js';\nimport useRaf from '../../services/raf.js';\nimport useResize from '../../services/resize.js';\nimport useScroll from '../../services/scroll.js';\nimport useKey from '../../services/key.js';\nimport useLoad from '../../services/load.js';\nimport { hasMethod, callMethod } from '../utils.js';\n\n/**\n * @typedef {import('../index').default} Base\n * @typedef {import('../../services').ServiceInterface} ServiceInterface\n */\n\n/**\n * @type {Record<string, () => ServiceInterface>}\n */\nconst SERVICES_MAP = {\n scrolled: useScroll,\n resized: useResize,\n ticked: useRaf,\n moved: usePointer,\n keyed: useKey,\n loaded: useLoad,\n};\n\n/**\n * @typedef {keyof SERVICES_MAP} ServiceName\n */\n\n/**\n * Services management for the Base class.\n */\nexport default class ServicesManager {\n /**\n * @type {Base}\n * @private\n */\n __base;\n\n /**\n * Class constructor.\n * @param {Base} instance The Base instance.\n */\n constructor(instance) {\n this.__base = instance;\n }\n\n /**\n * Test if the given service is registered.\n *\n * @param {ServiceName} service The name of the service.\n * @return {Boolean}\n */\n has(service) {\n if (!hasMethod(this.__base, service) && !SERVICES_MAP[service]) {\n return false;\n }\n\n const { has } = SERVICES_MAP[service]();\n return has(this.__base.$id);\n }\n\n /**\n * Init the given service and bind it to the given instance.\n *\n * @param {ServiceName} service The name of the service.\n * @return {() => void} A function to unbind the service.\n */\n enable(service) {\n if (this.has(service)) {\n return this.disable.bind(this, service);\n }\n\n if (!hasMethod(this.__base, service) || !SERVICES_MAP[service]) {\n return function noop() {};\n }\n\n const { add } = SERVICES_MAP[service]();\n const self = this;\n\n /**\n * @param {any[]} args\n */\n function serviceHandler(...args) {\n callMethod(self.__base, service, ...args);\n }\n\n add(this.__base.$id, serviceHandler);\n\n return this.disable.bind(this, service);\n }\n\n /**\n * Enable all services and return methods to disable them.\n *\n * @return {Function[]}\n */\n enableAll() {\n return Object.keys(SERVICES_MAP).map(\n /** @param {ServiceName} serviceName */\n (serviceName) => this.enable(serviceName)\n );\n }\n\n /**\n * Disable all services.\n *\n * @return {void}\n */\n disableAll() {\n Object.keys(SERVICES_MAP).forEach(\n /** @param {ServiceName} serviceName */\n (serviceName) => {\n this.disable(serviceName);\n }\n );\n }\n\n /**\n * Disable a service.\n *\n * @param {String} service The name of the service.\n * @return {void}\n */\n disable(service) {\n if (!SERVICES_MAP[service]) {\n return;\n }\n\n const { remove } = SERVICES_MAP[service]();\n remove(this.__base.$id);\n }\n\n /**\n * Register a new service to be enabled/disabled.\n *\n * @param {string} name The name of the service hook.\n * @param {() => ServiceInterface} useFunction The `use...` function for the service.\n */\n register(name, useFunction) {\n SERVICES_MAP[name] = useFunction;\n }\n\n /**\n * Unregister a new service to be enabled disabled.\n *\n * @param {string} name The name of the service hooK\n */\n unregister(name) {\n delete SERVICES_MAP[name];\n }\n}\n","import getAllProperties from '../../utils/object/getAllProperties.js';\nimport RefsManager from './RefsManager.js';\n\n/**\n * @typedef {import('../index.js').default} Base\n * @typedef {import('./ChildrenManager.js').default} ChildrenManager\n */\n\n/**\n * Event management class.\n */\nexport default class EventsManager {\n /**\n * @type {HTMLElement}\n * @private\n */\n __rootElement;\n\n /**\n * @type {Base}\n * @private\n */\n __base;\n\n /**\n * @type {WeakMap}\n * @private\n */\n __methodsCache = new WeakMap();\n\n /**\n * Event listener object for the root element.\n *\n * @type {EventListenerObject}\n */\n __rootElementHandler = {\n handleEvent: (event) => {\n const normalizedEventName = EventsManager.normalizeName(event.type);\n const method = `on${normalizedEventName}`;\n\n if (typeof this.__base[method] === 'function') {\n this.__base[method](event);\n }\n },\n };\n\n /**\n * Event listener object for the refs.\n *\n * @type {EventListenerObject}\n */\n __refsHandler = {\n handleEvent: (event) => {\n const ref = /** @type {HTMLElement} */ (event.currentTarget);\n const refName = RefsManager.normalizeRefName(ref.dataset.ref);\n\n const normalizedRefName = EventsManager.normalizeName(refName);\n const normalizedEventName = EventsManager.normalizeName(event.type);\n const method = `on${normalizedRefName}${normalizedEventName}`;\n\n if (typeof this.__base[method] === 'function') {\n let index = 0;\n if (Array.isArray(this.__base.$refs[refName])) {\n index = this.__base.$refs[refName].indexOf(ref);\n }\n\n this.__base[method](event, index);\n }\n },\n };\n\n /**\n * Event listener object for the children.\n *\n * @type {EventListenerObject}\n */\n __childrenHandler = {\n /**\n * @param {CustomEvent} event\n * @return {void}\n */\n handleEvent: (event) => {\n const child = /** @type {HTMLElement & { __base__: Base }} */ (event.currentTarget).__base__;\n let childName;\n let index = 0;\n\n const childrenManager = this.__base.$children;\n\n childrenManager.registeredNames.find((name) => {\n if (childrenManager[name].includes(child)) {\n childName = name;\n index = childrenManager[name].indexOf(child);\n return true;\n }\n\n return false;\n });\n\n const normalizedRefName = EventsManager.normalizeName(childName);\n const normalizedEventName = EventsManager.normalizeName(event.type);\n const method = `on${normalizedRefName}${normalizedEventName}`;\n\n if (typeof this.__base[method] === 'function') {\n const args = event.detail ?? [];\n this.__base[method](...args, index, event);\n }\n },\n };\n\n /**\n * Class constructor.\n *\n * @param {HTMLElement} rootElement\n * @param {Base} base\n */\n constructor(rootElement, base) {\n this.__rootElement = rootElement;\n this.__base = base;\n }\n\n /**\n * Manage a ref event methods.\n *\n * @param {string} name\n * The name of the ref.\n * @param {HTMLElement[]} elements\n * The elements of the ref.\n * @param {'add'|'remove'} [mode]\n * The action to perform: add or remove the event listeners.\n *\n * @return {void}\n * @private\n */\n __manageRef(name, elements, mode = 'add') {\n const action = `${mode}EventListener`;\n const methods = this.__getEventMethodsByName(name);\n methods.forEach((method) => {\n const event = this.__getEventNameByMethod(method, name);\n elements.forEach((element) => element[action](event, this.__refsHandler));\n });\n }\n\n /**\n * Bind event methods to the given ref elements.\n *\n * @param {string} name\n * The name of the ref.\n * @param {HTMLElement[]} elements\n * The elements of the ref.\n *\n * @return {void}\n */\n bindRef(name, elements) {\n this.__manageRef(name, elements);\n }\n\n /**\n * Bind event methods to the given ref elements.\n *\n * @param {string} name\n * The name of the ref.\n * @param {HTMLElement[]} elements\n * The elements of the ref.\n *\n * @return {void}\n */\n unbindRef(name, elements) {\n this.__manageRef(name, elements, 'remove');\n }\n\n /**\n * Manage event methods to the given child instance.\n *\n * @param {string} name\n * The name of the ref.\n * @param {Base} instance\n * A base instance.\n * @param {'add'|'remove'} [mode]\n * The action to perform: add or remove the event listeners.\n *\n * @return {void}\n * @private\n */\n __manageChild(name, instance, mode = 'add') {\n const action = mode === 'add' ? '$on' : '$off';\n const methods = this.__getEventMethodsByName(name);\n methods.forEach((method) => {\n const event = this.__getEventNameByMethod(method, name);\n instance[action](event, this.__childrenHandler);\n });\n }\n\n /**\n * Bind event methods to the given child instance.\n *\n * @param {string} name\n * The name of the ref.\n * @param {Base} instance\n * A base instance.\n *\n * @return {void}\n */\n bindChild(name, instance) {\n this.__manageChild(name, instance);\n }\n\n /**\n * Unbind event methods to the given child instance.\n *\n * @param {string} name\n * The name of the ref.\n * @param {Base} instance\n * A base instance.\n *\n * @return {void}\n */\n unbindChild(name, instance) {\n this.__manageChild(name, instance, 'remove');\n }\n\n /**\n * Manage event methods on the root element.\n *\n * @param {'add'|'remove'} [mode]\n * The action to perform: add or remove the event listeners.\n *\n * @return {void}\n * @private\n */\n __manageRootElement(mode = 'add') {\n const modeMethod = `${mode}EventListener`;\n const methods = this.__getEventMethodsByName();\n methods.forEach((method) => {\n const event = this.__getEventNameByMethod(method);\n this.__rootElement[modeMethod](event, this.__rootElementHandler);\n });\n }\n\n /**\n * Bind event methods on the root element.\n *\n * @return {void}\n */\n bindRootElement() {\n this.__manageRootElement();\n }\n\n /**\n * Unbind event method from the root element.\n *\n * @return {void}\n */\n unbindRootElement() {\n this.__manageRootElement('remove');\n }\n\n /**\n * Get the event name from the given method and its tied ref or children name.\n *\n * @param {string} method\n * @param {string} name\n * @return {string}\n * @private\n */\n __getEventNameByMethod(method, name = '') {\n const normalizedName = EventsManager.normalizeName(name);\n const regex = new RegExp(`^on${normalizedName}([A-Z].*)$`);\n const [, event] = method.match(regex);\n return EventsManager.normalizeEventName(event);\n }\n\n /**\n * Get the base instance methods matching the `onSomething` pattern.\n *\n * @param {string} [name]\n * @return {string[]}\n * @private\n */\n __getEventMethodsByName(name = '') {\n const normalizedName = EventsManager.normalizeName(name);\n const regex = new RegExp(`^on${normalizedName}[A-Z].*$`);\n\n let methods = this.__methodsCache.get(regex);\n\n if (!methods) {\n methods = getAllProperties(this.__base, [], (method) => regex.test(method));\n this.__methodsCache.set(regex, methods);\n }\n\n return methods.reduce((acc, [method]) => {\n if (!acc.includes(method)) {\n acc.push(method);\n }\n return acc;\n }, []);\n }\n\n /**\n * Normalize the given name to PascalCase, such as:\n *\n * ```\n * sentence case => SentenceCase\n * lowercase => Lowercase\n * UPPERCASE => Uppercase\n * kebab-case => KebabCase\n * snake_case => SnakeCase\n * camelCase => CamelCase\n * PascalCase => PascalCase\n * .class-selector => ClassSelector\n * .bem__selector => BemSelector\n * __id-selector => IdSelector\n * .complex[class^ =\"__\"] => ComplexClass\n * ```\n *\n * @param {string} name\n * @return {string}\n */\n static normalizeName(name) {\n return name\n .replace(/[A-Z]([A-Z].*)/g, (c) => c.toLowerCase())\n .replace(/[^a-zA-Z\\d\\s:]/g, ' ')\n .replace(/(^\\w|\\s+\\w)/g, (c) => c.trim().toUpperCase())\n .trim();\n }\n\n /**\n * Normalize the event names from PascalCase to kebab-case.\n *\n * @param {string} name\n * @return {string}\n */\n static normalizeEventName(name) {\n return name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`).replace(/^-/, '');\n }\n}\n","'use strict';\n\nvar isMergeableObject = function isMergeableObject(value) {\n\treturn isNonNullObject(value)\n\t\t&& !isSpecial(value)\n};\n\nfunction isNonNullObject(value) {\n\treturn !!value && typeof value === 'object'\n}\n\nfunction isSpecial(value) {\n\tvar stringValue = Object.prototype.toString.call(value);\n\n\treturn stringValue === '[object RegExp]'\n\t\t|| stringValue === '[object Date]'\n\t\t|| isReactElement(value)\n}\n\n// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25\nvar canUseSymbol = typeof Symbol === 'function' && Symbol.for;\nvar REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;\n\nfunction isReactElement(value) {\n\treturn value.$$typeof === REACT_ELEMENT_TYPE\n}\n\nfunction emptyTarget(val) {\n\treturn Array.isArray(val) ? [] : {}\n}\n\nfunction cloneUnlessOtherwiseSpecified(value, options) {\n\treturn (options.clone !== false && options.isMergeableObject(value))\n\t\t? deepmerge(emptyTarget(value), value, options)\n\t\t: value\n}\n\nfunction defaultArrayMerge(target, source, options) {\n\treturn target.concat(source).map(function(element) {\n\t\treturn cloneUnlessOtherwiseSpecified(element, options)\n\t})\n}\n\nfunction getMergeFunction(key, options) {\n\tif (!options.customMerge) {\n\t\treturn deepmerge\n\t}\n\tvar customMerge = options.customMerge(key);\n\treturn typeof customMerge === 'function' ? customMerge : deepmerge\n}\n\nfunction getEnumerableOwnPropertySymbols(target) {\n\treturn Object.getOwnPropertySymbols\n\t\t? Object.getOwnPropertySymbols(target).filter(function(symbol) {\n\t\t\treturn target.propertyIsEnumerable(symbol)\n\t\t})\n\t\t: []\n}\n\nfunction getKeys(target) {\n\treturn Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))\n}\n\nfunction propertyIsOnObject(object, property) {\n\ttry {\n\t\treturn property in object\n\t} catch(_) {\n\t\treturn false\n\t}\n}\n\n// Protects from prototype poisoning and unexpected merging up the prototype chain.\nfunction propertyIsUnsafe(target, key) {\n\treturn propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,\n\t\t&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,\n\t\t\t&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.\n}\n\nfunction mergeObject(target, source, options) {\n\tvar destination = {};\n\tif (options.isMergeableObject(target)) {\n\t\tgetKeys(target).forEach(function(key) {\n\t\t\tdestination[key] = cloneUnlessOtherwiseSpecified(target[key], options);\n\t\t});\n\t}\n\tgetKeys(source).forEach(function(key) {\n\t\tif (propertyIsUnsafe(target, key)) {\n\t\t\treturn\n\t\t}\n\n\t\tif (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {\n\t\t\tdestination[key] = getMergeFunction(key, options)(target[key], source[key], options);\n\t\t} else {\n\t\t\tdestination[key] = cloneUnlessOtherwiseSpecified(source[key], options);\n\t\t}\n\t});\n\treturn destination\n}\n\nfunction deepmerge(target, source, options) {\n\toptions = options || {};\n\toptions.arrayMerge = options.arrayMerge || defaultArrayMerge;\n\toptions.isMergeableObject = options.isMergeableObject || isMergeableObject;\n\t// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()\n\t// implementations can use it. The caller may not replace it.\n\toptions.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;\n\n\tvar sourceIsArray = Array.isArray(source);\n\tvar targetIsArray = Array.isArray(target);\n\tvar sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;\n\n\tif (!sourceAndTargetTypesMatch) {\n\t\treturn cloneUnlessOtherwiseSpecified(source, options)\n\t} else if (sourceIsArray) {\n\t\treturn options.arrayMerge(target, source, options)\n\t} else {\n\t\treturn mergeObject(target, source, options)\n\t}\n}\n\ndeepmerge.all = function deepmergeAll(array, options) {\n\tif (!Array.isArray(array)) {\n\t\tthrow new Error('first argument should be an array')\n\t}\n\n\treturn array.reduce(function(prev, next) {\n\t\treturn deepmerge(prev, next, options)\n\t}, {})\n};\n\nvar deepmerge_1 = deepmerge;\n\nmodule.exports = deepmerge_1;\n","import deepmerge from 'deepmerge';\nimport isObject from '../../utils/object/isObject.js';\n\n/**\n * @typedef {import('../index.js').BaseConfig} BaseConfig\n * @typedef {StringConstructor|NumberConstructor|BooleanConstructor|ArrayConstructor|ObjectConstructor} OptionType\n * @typedef {{ type: OptionType, default: String|Number|Boolean|(() => Array|Object)}} OptionWithDefault\n * @typedef {OptionType | OptionWithDefault} OptionValue\n * @typedef {{ [name:string]: OptionValue }} OptionsSchema\n * @typedef {{ [optionName:string]: any }} OptionsInterface\n */\n\n/**\n * Class options to manage options as data attributes on an HTML element.\n * @augments {OptionsInterface}\n */\nexport default class OptionsManager {\n /**\n * The HTML element holding the options attributes.\n * @type {HTMLElement}\n * @private\n */\n __element;\n\n /**\n * An object to store Array and Object values for reference.\n * @type {Object}\n * @private\n */\n __values = {};\n\n /**\n * List of allowed types.\n * @type {Array}\n * @private\n */\n static types = [String, Number, Boolean, Array, Object];\n\n /**\n * The default values to return for each available type.\n * @type {Object}\n * @private\n */\n __defaultValues = {\n String: '',\n Number: 0,\n Boolean: false,\n Array: () => [],\n Object: () => ({}),\n };\n\n /**\n * Default value for the name property.\n * @type {string}\n */\n name = 'Base';\n\n /**\n * Default value for the debug property.\n * @type {boolean}\n */\n debug = false;\n\n /**\n * Default value for the log property.\n * @type {Boolean}\n */\n log = false;\n\n /**\n * Class constructor.\n *\n * @param {HTMLElement} element The HTML element storing the options.\n * @param {OptionsSchema} schema A Base class config options.\n * @param {BaseConfig} baseConfig A Base class config.\n */\n constructor(element, schema, baseConfig) {\n this.__element = element;\n this.name = baseConfig.name;\n\n schema.debug = {\n type: Boolean,\n default: baseConfig.debug ?? false,\n };\n\n schema.log = {\n type: Boolean,\n default: baseConfig.log ?? false,\n };\n\n Object.entries(schema).forEach(([name, config]) => {\n this.__register(name, config);\n });\n\n return this;\n }\n\n /**\n * Register an option.\n *\n * @param {string} name\n * @param {OptionValue} config\n * @return {void}\n * @private\n */\n __register(name, config) {\n const hasDefaultValue = !OptionsManager.types.includes(config);\n const type = hasDefaultValue\n ? /** @type {OptionWithDefault} */ (config).type\n : /** @type {OptionType} */ (config);\n\n if (!OptionsManager.types.includes(type)) {\n throw new Error(\n `The \"${name}\" option has an invalid type. The allowed types are: String, Number, Boolean, Array and Object.`\n );\n }\n\n // @ts-ignore\n const defaultValue = hasDefaultValue ? config.default : this.__defaultValues[type.name];\n\n if ((type === Array || type === Object) && typeof defaultValue !== 'function') {\n throw new Error(\n `The default value for options of type \"${type.name}\" must be returned by a function.`\n );\n }\n\n Object.defineProperty(this, name, {\n get: () => {\n return this.get(name, type, defaultValue);\n },\n set: (value) => {\n this.set(name, type, value, defaultValue);\n },\n enumerable: true,\n });\n }\n\n /**\n * Get an option value.\n *\n * @param {String} name The option name.\n * @param {OptionType} type The option data's type.\n * @param {any} defaultValue The default value for this option.\n */\n get(name, type, defaultValue) {\n const propertyName = OptionsManager.__getPropertyName(name);\n const hasProperty = this.__hasProperty(propertyName);\n\n if (type === Boolean) {\n if (defaultValue) {\n const negatedPropertyName = OptionsManager.__getPropertyName(name, 'No');\n const hasNegatedProperty = this.__hasProperty(negatedPropertyName);\n\n return !hasNegatedProperty;\n }\n\n return hasProperty || defaultValue;\n }\n\n const value = this.__element.dataset[propertyName];\n\n if (type === Number) {\n return hasProperty ? Number(value) : defaultValue;\n }\n\n if (type === Array || type === Object) {\n const val = deepmerge(\n defaultValue(),\n hasProperty ? JSON.parse(value) : this.__defaultValues[type.name]()\n );\n\n if (!this.__values[name]) {\n this.__values[name] = val;\n }\n\n return this.__values[name];\n }\n\n return hasProperty ? value : defaultValue;\n }\n\n /**\n * Set an option value.\n *\n * @param {String} name The option name.\n * @param {OptionType} type The option data's type.\n * @param {any} value The new value for this option.\n */\n set(name, type, value, defaultValue) {\n const propertyName = OptionsManager.__getPropertyName(name);\n\n if (value.constructor.name !== type.name) {\n const val = Array.isArray(value) || isObject(value) ? JSON.stringify(value) : value;\n throw new TypeError(\n `The \"${val}\" value for the \"${name}\" option must be of type \"${type.name}\"`\n );\n }\n\n switch (type) {\n case Boolean:\n if (defaultValue) {\n const negatedPropertyName = OptionsManager.__getPropertyName(name, 'No');\n\n if (value) {\n delete this.__element.dataset[negatedPropertyName];\n } else {\n this.__element.dataset[negatedPropertyName] = '';\n }\n } else if (value) {\n this.__element.dataset[propertyName] = '';\n } else {\n delete this.__element.dataset[propertyName];\n }\n break;\n case Array:\n case Object:\n this.__values[name] = value;\n break;\n default:\n this.__element.dataset[propertyName] = value;\n }\n }\n\n /**\n * Test if the element has a given property.\n *\n * @param {string} prop\n * @return {boolean}\n */\n __hasProperty(prop) {\n return typeof this.__element.dataset[prop] !== 'undefined';\n }\n\n /**\n * Property name cache.\n * @type {Map}\n * @private\n */\n static __propertyNameCache = new Map();\n\n /**\n * Get a property name.\n *\n * @param {string} name\n * @return {string}\n * @private\n */\n static __getPropertyName(name, prefix = '') {\n const key = name + prefix;\n\n if (OptionsManager.__propertyNameCache.has(key)) {\n return OptionsManager.__propertyNameCache.get(key);\n }\n\n const propertyName = `option${prefix}${name.replace(/^\\w/, (c) => c.toUpperCase())}`;\n OptionsManager.__propertyNameCache.set(key, propertyName);\n return propertyName;\n }\n\n /**\n * Test if a value is primitive\n *\n * @param {any} value\n * @return {boolean}\n * @private\n */\n static __isPrimitive(value) {\n return (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'symbol' ||\n typeof value === 'boolean'\n );\n }\n}\n","/**\n * Test if the given value is an object.\n *\n * @param {*} value The value to test.\n * @return {Boolean} Whether or not the value is an object.\n */\nexport default function isObject(value) {\n return typeof value === 'object' && !!value && value.toString() === '[object Object]';\n}\n","import autoBind from '../utils/object/autoBind.js';\nimport { callMethod, getComponentElements } from './utils.js';\nimport ChildrenManager from './managers/ChildrenManager.js';\nimport RefsManager from './managers/RefsManager.js';\nimport ServicesManager from './managers/ServicesManager.js';\nimport EventsManager from './managers/EventsManager.js';\nimport OptionsManager from './managers/OptionsManager.js';\n\nlet id = 0;\n\nconst noop = function noop() {};\n\n/**\n * @typedef {typeof Base} BaseComponent\n * @typedef {(Base) => Promise<BaseComponent | { default: BaseComponent }>} BaseAsyncComponent\n * @typedef {OptionsManager & { [name:string]: any }} BaseOptions\n * @typedef {{ [name:string]: HTMLElement | HTMLElement[] }} BaseRefs\n * @typedef {{ [nameOrSelector:string]: Base[] | Promise<Base>[] }} BaseChildren\n * @typedef {{ [nameOrSelector:string]: BaseComponent | BaseAsyncComponent }} BaseConfigComponents\n * @typedef {import('./managers/OptionsManager').OptionsSchema} BaseConfigOptions\n * @typedef {import('./managers/ServicesManager.js').ServiceName} ServiceName\n */\n\n/**\n * @typedef {Object} BaseConfig\n * @property {String} name\n * @property {Boolean} [debug]\n * @property {Boolean} [log]\n * @property {String[]} [refs]\n * @property {BaseConfigComponents} [components]\n * @property {BaseConfigOptions} [options]\n */\n\n/**\n * Base class to easily create components.\n *\n * @example\n * ```js\n * class Component extends Base {\n * static config = {\n * name: 'Component',\n * log: true,\n * };\n *\n * mounted() {\n * this.$log('Component is mounted!');\n * }\n * }\n *\n * class App extends Base {\n * static config = {\n * name: 'App',\n * components: {\n * Component,\n * },\n * };\n * }\n *\n * new App(document.body).$mount();\n * ```\n */\nexport default class Base {\n /**\n * The instance parent.\n * @type {Base}\n */\n $parent = null;\n\n /**\n * The instance id.\n * @type {string}\n */\n $id;\n\n /**\n * The root element.\n * @type {HTMLElement}\n */\n $el;\n\n /**\n * The state of the component.\n * @type {Boolean}\n */\n $isMounted = false;\n\n /**\n * This is a Base instance.\n * @type {Boolean}\n */\n static $isBase = true;\n\n /**\n * Get properties to exclude from the autobind call.\n * @return {Array<String|RegExp>}\n */\n get __excludeFromAutoBind() {\n return [\n '$mount',\n '$update',\n '$destroy',\n '$terminate',\n '$log',\n '$on',\n '$once',\n '$off',\n '$emit',\n 'mounted',\n 'loaded',\n 'ticked',\n 'resized',\n 'moved',\n 'keyed',\n 'scrolled',\n 'destroyed',\n 'terminated',\n ];\n }\n\n /**\n * Merge configuration with the parents' configurations.\n *\n * @return {BaseConfig}\n * @private\n */\n get __config() {\n let proto = Object.getPrototypeOf(this);\n let { config } = proto.constructor;\n\n while (proto.constructor.config && proto.constructor.$isBase) {\n config = {\n ...proto.constructor.config,\n ...config,\n };\n\n if (proto.constructor.config.options) {\n config.options = {\n ...proto.constructor.config.options,\n ...config.options,\n };\n }\n\n proto = Object.getPrototypeOf(proto);\n }\n\n return config;\n }\n\n /**\n * @type {BaseConfig}\n */\n static config;\n\n /**\n * @type {ServicesManager}\n */\n __services;\n\n /**\n * The instance services.\n * @type {ServicesManager}\n */\n get $services() {\n const services = this.__services;\n this.$emit('get:services', services);\n return services;\n }\n\n /**\n * @type {RefsManager}\n */\n __refs;\n\n /**\n * @return {RefsManager}\n */\n get $refs() {\n const refs = this.__refs;\n this.$emit('get:refs', refs);\n return refs;\n }\n\n /**\n * @type {BaseOptions}\n */\n __options;\n\n /**\n * @return {BaseOptions}\n */\n get $options() {\n const options = this.__options;\n this.$emit('get:options', options);\n return options;\n }\n\n /**\n * @type {ChildrenManager}\n */\n __children;\n\n /**\n * @return {ChildrenManager}\n */\n get $children() {\n this.__debug('before:getChildren', this.$el, this.__config.components);\n\n const children = this.__children;\n this.$emit('get:children', children);\n\n this.__debug(this, 'after:getChildren', children);\n\n return children;\n }\n\n /**\n * @type {EventsManager}\n */\n __events;\n\n /**\n * Small helper to log stuff.\n *\n * @return {(...args: any) => void}\n */\n get $log() {\n return this.__options.log ? window.console.log.bind(window, `[${this.__config.name}]`) : noop;\n }\n\n /**\n * Small helper to debug information.\n *\n * @return {(...args:any) => void}\n */\n get __debug() {\n return this.__options.debug && typeof window.__DEV__ !== 'undefined' && window.__DEV__\n ? window.console.log.bind(window, `[debug] [${this.$id}]`)\n : noop;\n }\n\n /**\n * Class constructor where all the magic takes place.\n *\n * @param {HTMLElement} element The component's root element dd.\n */\n constructor(element) {\n if (!element) {\n throw new Error('The root element must be defined.');\n }\n\n const { __config } = this;\n\n if (!__config) {\n throw new Error('The `config` static property must be defined.');\n }\n\n if (!__config.name) {\n throw new Error('The `config.name` property is required.');\n }\n\n this.$id = `${__config.name}-${id}`;\n id += 1;\n\n this.$el = element;\n\n if (!('__base__' in this.$el)) {\n Object.defineProperty(this.$el, '__base__', {\n get: () => this,\n configurable: true,\n });\n }\n\n this.__options = new OptionsManager(element, __config.options || {}, __config);\n this.__services = new ServicesManager(this);\n this.__events = new EventsManager(element, this);\n this.__children = new ChildrenManager(this, element, __config.components || {}, this.__events);\n this.__refs = new RefsManager(this, element, __config.refs || [], this.__events);\n\n // Autobind all methods to the instance\n // @todo Maybe remove for performance reason? This pattern can use a lot of memory when creating\n // a large number of instances.\n autoBind(this, {\n exclude: [...this.__excludeFromAutoBind],\n });\n\n this.__debug('constructor', this);\n\n return this;\n }\n\n /**\n * Trigger the `mounted` callback.\n */\n $mount() {\n this.__debug('$mount');\n\n this.$children.registerAll();\n this.$refs.registerAll();\n this.__events.bindRootElement();\n this.$services.enableAll();\n this.$children.mountAll();\n\n callMethod(this, 'mounted');\n this.$isMounted = true;\n return this;\n }\n\n /**\n * Update the instance children.\n */\n $update() {\n this.__debug('$update');\n\n // Undo\n this.$refs.unregisterAll();\n this.$services.disableAll();\n\n // Redo\n this.$children.registerAll();\n this.$refs.registerAll();\n this.$services.enableAll();\n\n // Update\n this.$children.updateAll();\n\n callMethod(this, 'updated');\n return this;\n }\n\n /**\n * Trigger the `destroyed` callback.\n */\n $destroy() {\n this.__debug('$destroy');\n\n this.__events.unbindRootElement();\n this.$refs.unregisterAll();\n this.$services.disableAll();\n this.$children.destroyAll();\n callMethod(this, 'destroyed');\n this.$isMounted = false;\n return this;\n }\n\n /**\n * Terminate a child instance when it is not needed anymore.\n * @return {void}\n */\n $terminate() {\n this.__debug('$terminate');\n\n // First, destroy the component.\n this.$destroy();\n\n // Execute the `terminated` hook if it exists\n callMethod(this, 'terminated');\n\n // Delete the reference to the instance\n // delete this.$el.__base__;\n\n // And update its status to prevent re-instantiation when accessing the\n // parent's `$children` property\n Object.defineProperty(this.$el, '__base__', {\n value: 'terminated',\n configurable: false,\n writable: false,\n });\n }\n\n /**\n * Factory method to generate multiple instance of the class.\n *\n * @param {String} nameOrSelector The selector on which to mount each instance.\n * @return {Array<Base>} A list of the created instance.\n */\n static $factory(nameOrSelector) {\n if (!nameOrSelector) {\n throw new Error(\n 'The $factory method requires a component’s name or selector to be specified.'\n );\n }\n\n return getComponentElements(nameOrSelector).map((el) => new this(el).$mount());\n }\n\n /**\n * Bind a listener function to an event.\n *\n * @param {string} event\n * Name of the event.\n * @param {EventListenerOrEventListenerObject} listener\n * Function to be called.\n * @param {boolean|AddEventListenerOptions} [options]\n * Options for the `removeEventListener` method.\n * @return {() => void}\n * A function to unbind the listener.\n */\n $on(event, listener, options) {\n this.__debug('$on', event, listener, options);\n\n this.$el.addEventListener(event, listener, options);\n\n return () => {\n this.$off(event, listener, options);\n };\n }\n\n /**\n * Unbind a listener function from an event.\n *\n * @param {string} event\n * Name of the event.\n * @param {EventListenerOrEventListenerObject} listener\n * Function to be removed.\n * @param {boolean|EventListenerOptions} [options]\n * Options for the `removeEventListener` method.\n *\n * @return {void}\n */\n $off(event, listener, options) {\n this.__debug('$off', event, listener);\n\n this.$el.removeEventListener(event, listener, options);\n }\n\n /**\n * Emits an event.\n *\n * @param {string} event\n * Name of the event.\n * @param {any[]} args The arguments to apply to the functions bound to this event.\n * @return {void}\n */\n $emit(event, ...args) {\n this.__debug('$emit', event, args);\n\n this.$el.dispatchEvent(\n new CustomEvent(event, {\n detail: args,\n })\n );\n }\n}\n","import getAllProperties from './getAllProperties.js';\n\n/**\n * Auto-bind methods to an instance.\n *\n * @param {Object} instance The instance.\n * @param {Object} options Define specific methods to include or exlude.\n * @param {Array<String|RegExp>} [options.include] Methods to include.\n * @param {Array<String|RegExp>} [options.exclude] Methods to exclude.\n * @return {Object} The instance.\n */\nexport default function autoBind(instance, options) {\n const { exclude, include } = options || {};\n const filter = (key) => {\n const match = (pattern) => (typeof pattern === 'string' ? key === pattern : pattern.test(key));\n\n if (include) {\n return include.some(match);\n }\n\n if (exclude) {\n return !exclude.some(match);\n }\n\n return true;\n };\n\n getAllProperties(instance)\n .filter(([key]) => key !== 'constructor' && filter(key))\n .forEach(([key, object]) => {\n const descriptor = Object.getOwnPropertyDescriptor(object, key);\n if (descriptor && typeof descriptor.value === 'function') {\n instance[key] = instance[key].bind(instance);\n }\n });\n\n return instance;\n}\n","import useResize from '../services/resize.js';\n\n/**\n * @typedef {import('../Base').default} Base\n * @typedef {import('../Base').BaseComponent} BaseComponent\n */\n\n/**\n * Test the breakpoins of the given Base instance and return the hook to call.\n *\n * @param {Array<[String[], Base]>} breakpoints The breakpoints's data.\n */\nfunction testBreakpoints(breakpoints) {\n const { breakpoint } = useResize().props();\n breakpoints.forEach(([breakpointKeys, instance]) => {\n if (breakpointKeys.includes(breakpoint) && !instance.$isMounted) {\n setTimeout(() => instance.$mount(), 0);\n } else if (!breakpointKeys.includes(breakpoint) && instance.$isMounted) {\n instance.$destroy();\n }\n });\n}\n\n/**\n * Prepare the components.\n * @param {Base} instance\n * @param {Array<[String, BaseComponent]>} breakpoints\n * @return {Array<[String, Base]>}\n */\nfunction mountComponents(instance, breakpoints) {\n return breakpoints.map(([bk, ComponentClass]) => {\n const child = new ComponentClass(instance.$el);\n Object.defineProperty(child, '$parent', { get: () => instance.$parent });\n return [bk, child];\n });\n}\n\n/**\n * A cache object to hold each Base sub-instances.\n * @type {Object}\n */\nconst instances = new WeakMap();\n\n/**\n * BreakpointManager class.\n * @template {BaseComponent} T\n * @param {T} BaseClass\n * @param {Array<[String, BaseComponent]>} breakpoints\n * @return {T}\n */\nexport default function withBreakpointManager(BaseClass, breakpoints) {\n if (!Array.isArray(breakpoints)) {\n throw new Error('[withBreakpointManager] The `breakpoints` parameter must be an array.');\n }\n\n if (breakpoints.length < 2) {\n throw new Error('[withBreakpointManager] You must define at least 2 breakpoints.');\n }\n\n const { add, props } = useResize();\n\n // Do nothing if no breakpoint has been defined.\n // @see https://js-toolkit.meta.fr/services/resize.html#breakpoint\n if (!props().breakpoint) {\n throw new Error(`The \\`BreakpointManager\\` class requires breakpoints to be defined.`);\n }\n\n // @ts-ignore\n return class extends BaseClass {\n /**\n * Watch for the document resize to test the breakpoints.\n * @param {HTMLElement} element The component's root element.\n */\n constructor(element) {\n super(element);\n\n if (!instances.has(this)) {\n instances.set(this, mountComponents(this, breakpoints));\n }\n\n add(`BreakpointManager-${this.$id}`, () => {\n testBreakpoints(instances.get(this));\n });\n\n this.instances = instances.get(this);\n\n return this;\n }\n\n /**\n * Override the default $mount method to prevent component's from being\n * mounted when they should not.\n *\n * @return {this}\n */\n $mount() {\n super.$mount();\n\n testBreakpoints(instances.get(this));\n\n return this;\n }\n\n /**\n * Destroy all instances when the main one is destroyed.\n *\n * @return {this}\n */\n $destroy() {\n if (Array.isArray(instances.get(this))) {\n instances.get(this).forEach(([, instance]) => {\n instance.$destroy();\n });\n }\n\n return super.$destroy();\n }\n };\n}\n","import useResize from '../services/resize.js';\n\n/**\n * @typedef {import('../Base').default} Base\n * @typedef {import('../Base').BaseComponent} BaseComponent\n */\n\n/**\n * @typedef {Object} WithBreakpointObserverOptions\n * @property {String} [activeBreakpoints]\n * @property {String} [inactiveBreakpoints]\n */\n\n/**\n * @typedef {Object} WithBreakpointObserverInterface\n * @property {WithBreakpointObserverOptions} $options\n */\n\n/**\n * Test the breakpoins of the given Base instance and return the hook to call.\n *\n * @param {Base & WithBreakpointObserverInterface} instance The component's instance.\n * @return {String} The action to trigger.\n */\nfunction testBreakpoints(instance, breakpoint = useResize().props().breakpoint) {\n const { activeBreakpoints, inactiveBreakpoints } = instance.$options;\n const isInActiveBreakpoint =\n activeBreakpoints && activeBreakpoints.split(' ').includes(breakpoint);\n const isInInactiveBreakpoint =\n inactiveBreakpoints && inactiveBreakpoints.split(' ').includes(breakpoint);\n\n if (\n (activeBreakpoints && isInActiveBreakpoint) ||\n (inactiveBreakpoints && !isInInactiveBreakpoint)\n ) {\n return '$mount';\n }\n\n return '$destroy';\n}\n\n/**\n * Test if the given instance is configured for breakpoints.\n * @param {Base & WithBreakpointObserverInterface} instance A Base class instance.\n * @return {Boolean} True if configured correctly, false otherwise.\n */\nfunction hasBreakpointConfiguration(instance) {\n const { activeBreakpoints, inactiveBreakpoints } = instance.$options;\n return Boolean(activeBreakpoints || inactiveBreakpoints);\n}\n\n/**\n * Test if the given instance has a conflicting configuration for breakpoints.\n * @param {Base & WithBreakpointObserverInterface} instance A Base class instance.\n * @return {void}\n */\nfunction testConflictingBreakpointConfiguration(instance) {\n const { activeBreakpoints, inactiveBreakpoints, name } = instance.$options;\n if (activeBreakpoints && inactiveBreakpoints) {\n throw new Error(\n `[${name}] Incorrect configuration: the \\`activeBreakpoints\\` and \\`inactiveBreakpoints\\` are not compatible.`\n );\n }\n}\n\n/**\n * Add the current instance to the resize service.\n * @param {String} key The key for the resize service callback.\n * @param {Base} instance The instance to observe.\n */\nfunction addToResize(key, instance) {\n testConflictingBreakpointConfiguration(instance);\n const { add, has } = useResize();\n\n if (!has(key)) {\n add(key, function onResize({ breakpoint }) {\n const action = testBreakpoints(instance, breakpoint);\n\n // Always destroy before mounting\n if (action === '$destroy' && instance.$isMounted) {\n instance[action]();\n } else if (action === '$mount' && !instance.$isMounted) {\n setTimeout(() => instance[action](), 0);\n }\n });\n }\n}\n\n/**\n * BreakpointObserver class.\n *\n * @template {BaseComponent} T\n * @param {T} BaseClass The Base class to extend from.\n * @return {T}\n */\nexport default function withBreakpointObserver(BaseClass) {\n // @ts-ignore\n return class extends BaseClass {\n static config = {\n ...(BaseClass.config || {}),\n name: `${BaseClass?.config?.name ?? ''}WithBreakpointObserver`,\n options: {\n ...(BaseClass?.config?.options || {}),\n activeBreakpoints: String,\n inactiveBreakpoints: String,\n },\n };\n\n /**\n * Watch for the document resize to test the breakpoints.\n * @this {Base & WithBreakpointObserverInterface}\n * @param {HTMLElement} element The component's root element.\n */\n constructor(element) {\n super(element);\n\n const { remove, props } = useResize();\n const { name } = this.$options;\n\n // Do nothing if no breakpoint has been defined.\n // @see https://js-toolkit.meta.fr/services/resize.html#breakpoint\n if (!props().breakpoint) {\n throw new Error(\n `[${name}] The \\`BreakpointObserver\\` class requires breakpoints to be defined.`\n );\n }\n\n const key = `BreakpointObserver-${this.$id}`;\n\n // Watch change on the `data-options` attribute to emit the `set:options` event.\n const mutationObserver = new MutationObserver(([mutation]) => {\n if (\n mutation.type === 'attributes' &&\n (mutation.attributeName === 'data-options' ||\n mutation.attributeName.startsWith('data-option-'))\n ) {\n // Stop here silently when no breakpoint configuration given.\n if (!hasBreakpointConfiguration(this)) {\n this.$mount();\n remove(key);\n return;\n }\n\n addToResize(key, this);\n }\n });\n mutationObserver.observe(this.$el, { attributes: true });\n\n // Stop here silently when no breakpoint configuration given.\n if (!hasBreakpointConfiguration(this)) {\n return this;\n }\n\n addToResize(key, this);\n return this;\n }\n\n /**\n * Override the default $mount method to prevent component's from being\n * mounted when they should not.\n * @return {this}\n */\n $mount() {\n // Execute normal behavior when no breakpoint configuration given.\n if (!hasBreakpointConfiguration(this)) {\n return super.$mount();\n }\n\n const action = testBreakpoints(this);\n if (action === '$mount') {\n return super.$mount();\n }\n\n return this;\n }\n };\n}\n","/**\n * Get the final damped value for a given factor.\n *\n * @param {Number} initialValue The final value.\n * @param {Number} initialDelta The current value.\n * @param {Number=} [factor=0.85] The speed to reach the target value.\n * @return {Number} The next value.\n */\nexport default function inertiaFinalValue(initialValue, initialDelta, factor = 0.85) {\n if (factor >= 1 || factor <= 0) {\n throw new Error(\n `The \\`factor\\` parameter must be a number greater than 0 and smaller than 1, \\`${factor}\\` given.`\n );\n }\n\n let delta = initialDelta;\n let finalValue = initialValue;\n\n while (Math.abs(delta) > 0.1) {\n finalValue += delta;\n delta *= factor;\n }\n\n return finalValue;\n}\n","import Service from './Service.js';\nimport usePointer from './pointer.js';\nimport useRaf from './raf.js';\nimport inertiaFinalValue from '../utils/math/inertiaFinalValue.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {import('./pointer.js').PointerServiceProps} PointerServiceProps\n */\n\n/**\n * @type {Record<Uppercase<DragLifecycle>, DragLifecycle>}\n */\nconst MODES = {\n START: 'start',\n DRAG: 'drag',\n DROP: 'drop',\n INERTIA: 'inertia',\n STOP: 'stop',\n};\n\n/**\n * @typedef {'start'|'drag'|'drop'|'inertia'|'stop'} DragLifecycle\n */\n\n/**\n * @typedef {Object} DragServiceProps\n * @property {DragLifecycle} mode\n * The current mode of the dragging logic.\n * @property {HTMLElement} target\n * The target element of the drag.\n * @property {boolean} isGrabbing\n * Whether the user is currently grabbing the targeted element or not.\n * @property {boolean} hasInertia\n * Whether the drag currently has inertia or not.\n * @property {number} x\n * The current horizontal position in the viewport.\n * @property {number} y\n * The current vertical position in the viewport.\n * @property {{ x: number, y: number }} delta\n * The delta between the current position and the last.\n * @property {{ x: number, y: number }} origin\n * The initial position where the dragging started.\n * @property {{ x: number, y: number }} distance\n * The distance from the current position to the origin.\n * @property {{ x: number, y: number }} final\n * The final position that will be reached at the end of the inertia.\n */\n\n/**\n * @typedef {Object} DragServiceOptions\n * @property {number=} [factor]\n */\n\n/**\n * @typedef {Object} DragService\n * @property {(target:HTMLElement, callback:(props:DragServiceProps) => void, options?:DragServiceOptions) => void} add\n * Add a callback function to the service. The key must be the HTML element targeted by the drag.\n * @property {(target:HTMLElement) => void} remove\n * Remove a callback function to the service.\n * @property {() => DragServiceProps} props\n * Get the current values of the resize service props.\n */\n\nlet instanceIds = 0;\n\n/**\n * Drag service\n */\nclass Drag extends Service {\n /**\n * The instance ID.\n * @type {string}\n */\n id;\n\n /**\n * The target element\n * @type {HTMLElement}\n */\n target;\n\n /**\n * The drag mode, use it to follow the different parts of the drag.\n * @type {DragLifecycle}\n */\n mode;\n\n /**\n * Whether we are currently dragging or not.\n * @type {Boolean}\n */\n isGrabbing = false;\n\n /**\n * Whether we are currently runnnig with inertia.\n * @type {Boolean}\n */\n hasInertia = false;\n\n /**\n * The horizontal position of the drag.\n * @type {Number}\n */\n x = 0;\n\n /**\n * The vertical position of the drag.\n * @type {Number}\n */\n y = 0;\n\n /**\n * The velocity of the drag.\n * @type {{ x: number, y: number }}\n */\n delta = {\n x: 0,\n y: 0,\n };\n\n /**\n * The origin of the drag.\n * @type {{ x: number, y: number }}\n */\n origin = {\n x: 0,\n y: 0,\n };\n\n /**\n * The origin of the drag.\n * @type {{ x: number, y: number }}\n */\n distance = {\n x: 0,\n y: 0,\n };\n\n /**\n * The final position of the inertia.\n * @type {{ x: number, y: number }}\n */\n final = {\n x: 0,\n y: 0,\n };\n\n /**\n * Options.\n * @type {DragServiceOptions}\n */\n options = {\n factor: 0.85,\n };\n\n /**\n * Class constructor.\n * @param {HTMLElement} target The drag target.\n * @param {DragServiceOptions} options The drag options.\n */\n constructor(target, options = {}) {\n super();\n instanceIds += 1;\n this.id = `drag-${instanceIds}`;\n this.target = target;\n this.options = { ...this.options, ...options };\n this.pointerHandler = this.pointerHandler.bind(this);\n this.rafHandler = this.rafHandler.bind(this);\n return this;\n }\n\n /**\n * Bind the handler to the mousemove and touchmove events.\n * Bind the up and down handler to the mousedown, mouseup, touchstart and touchend events.\n *\n * @return {this}\n */\n init() {\n const options = { passive: true };\n this.target.addEventListener('mousedown', this, options);\n this.target.addEventListener('touchstart', this, options);\n\n const pointer = usePointer();\n pointer.add(this.id, this.pointerHandler);\n\n return this;\n }\n\n /**\n * Unbind all handlers from their bounded event.\n *\n * @return {this}\n */\n kill() {\n this.target.removeEventListener('mousemove', this);\n this.target.removeEventListener('touchmove', this);\n\n const pointer = usePointer();\n pointer.remove(this.id);\n return this;\n }\n\n /**\n * Handle any event.\n * @param {MouseEvent|TouchEvent} event [description]\n */\n handleEvent(event) {\n const x = event instanceof MouseEvent ? event.clientX : event.touches[0].clientX;\n const y = event instanceof MouseEvent ? event.clientY : event.touches[0].clientY;\n this.start(x, y);\n }\n\n /**\n * Start the drag.\n * @param {number} x The initial horizontal position.\n * @param {number} y The initial vertical position.\n * @return {void}\n */\n start(x, y) {\n // Reset state\n this.x = x;\n this.y = y;\n this.origin.x = x;\n this.origin.y = y;\n this.delta.x = 0;\n this.delta.y = 0;\n this.distance.x = 0;\n this.distance.y = 0;\n this.final.x = x;\n this.final.y = y;\n\n this.mode = MODES.START;\n\n // Enable grabbing\n this.isGrabbing = true;\n\n this.trigger(this.props);\n }\n\n /**\n * Stop the drag, or drop.\n * @return {void}\n */\n drop() {\n this.isGrabbing = false;\n this.mode = MODES.DROP;\n\n this.hasInertia = true;\n this.final.x = inertiaFinalValue(this.x, this.delta.x, this.options.factor);\n this.final.y = inertiaFinalValue(this.y, this.delta.y, this.options.factor);\n\n this.trigger(this.props);\n\n setTimeout(() => {\n const raf = useRaf();\n raf.remove(this.id);\n raf.add(this.id, this.rafHandler);\n }, 0);\n }\n\n /**\n * Stop the drag.\n */\n stop() {\n useRaf().remove(this.id);\n this.hasInertia = false;\n this.mode = MODES.STOP;\n this.trigger(this.props);\n }\n\n /**\n * Raf service handler.\n * @return {void}\n */\n rafHandler() {\n if (!this.isGrabbing) {\n this.x += this.delta.x;\n this.y += this.delta.y;\n this.distance.x = this.x - this.origin.x;\n this.distance.y = this.y - this.origin.y;\n\n this.delta.x *= this.options.factor;\n this.delta.y *= this.options.factor;\n\n if (this.mode !== MODES.INERTIA) {\n this.mode = MODES.INERTIA;\n }\n\n this.trigger(this.props);\n\n if (Math.abs(this.delta.x) < 0.1 && Math.abs(this.delta.y) < 0.1) {\n this.stop();\n }\n }\n }\n\n /**\n * Pointer service handler.\n * @param {PointerServiceProps} props\n * @return {void}\n */\n pointerHandler(props) {\n if (this.isGrabbing) {\n this.x = props.x;\n this.y = props.y;\n this.delta.x = props.delta.x;\n this.delta.y = props.delta.y;\n this.final.x = props.x;\n this.final.y = props.y;\n this.distance.x = this.x - this.origin.x;\n this.distance.y = this.y - this.origin.y;\n\n if (this.mode !== MODES.DRAG) {\n this.mode = MODES.DRAG;\n }\n\n this.trigger(this.props);\n\n if (!props.isDown) {\n this.drop();\n }\n }\n }\n\n /**\n * Get the pointer props.\n *\n * @type {Object}\n */\n get props() {\n return {\n target: this.target,\n mode: this.mode,\n isGrabbing: this.isGrabbing,\n hasInertia: this.hasInertia,\n x: this.x,\n y: this.y,\n delta: this.delta,\n origin: this.origin,\n distance: this.distance,\n final: this.final,\n };\n }\n}\n\nconst instances = new WeakMap();\n\n/**\n * Use the pointer.\n *\n * ```js\n * import { useDrag } from '@studiometa/js-toolkit/services';\n * const { add, remove, props } = useDrag();\n * const draggableElement = document.querySelector('.draggable');\n * add(draggableElement, (props) => {}, { factor: 0.8 });\n * remove(draggableElement);\n * props(draggableElement);\n * ```\n *\n * @param {HTMLElement} target\n * @param {DragServiceOptions} options\n * @return {ServiceInterface & DragService}\n */\nexport default function useDrag(target, options) {\n let drag = instances.get(target);\n\n if (!drag) {\n drag = new Drag(target, options);\n instances.set(target, drag);\n }\n\n const add = drag.add.bind(drag);\n const remove = drag.remove.bind(drag);\n const has = drag.has.bind(drag);\n const props = () => drag.props;\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n","import useDrag from '../services/drag.js';\n\n/**\n * @typedef {import('../Base').default} Base\n * @typedef {import('../Base').BaseComponent} BaseComponent\n * @typedef {import('../services/drag').DragServiceOptions} DragServiceOptions\n */\n\n/**\n * @typedef {DragServiceOptions & { target: (this:Base) => HTMLElement }} DragDecoratorOptions\n */\n\n/**\n * Add dragging capabilities to a component.\n *\n * @template {BaseComponent} T\n * @param {T} BaseClass\n * @param {DragDecoratorOptions} options\n * @return {T}\n */\nexport default function withDrag(\n BaseClass,\n options = {\n target() {\n return this.$el;\n },\n }\n) {\n // @ts-ignore\n return class extends BaseClass {\n /**\n * Class constructor.\n * @param {HTMLElement} el\n */\n constructor(el) {\n super(el);\n\n this.$on('mounted', () => {\n const { target, ...otherOptions } = options;\n const boundUseDrag = useDrag.bind(undefined, target.call(this), otherOptions);\n this.$services.register('dragged', boundUseDrag);\n this.$services.enable('dragged');\n });\n\n this.$on('destroyed', () => {\n this.$services.disable('dragged');\n this.$services.unregister('dragged');\n });\n }\n };\n}\n","import merge from 'deepmerge';\n\n/**\n * @typedef {import('deepmerge').Options} DeepmergeOptions\n * @typedef {import('../Base').BaseConfig} BaseConfig\n * @typedef {import('../Base').BaseComponent} BaseComponent\n */\n\n/**\n * Extends the configuration of an existing class.\n *\n * @template {BaseComponent} T\n * @param {T} BaseClass The Base class to extend.\n * @param {Partial<BaseConfig>} config Extra configuration to merge.\n * @param {DeepmergeOptions} options Options for the `deepmerge` function. {@link https://github.com/TehShrike/deepmerge#options}\n * @return {T}\n */\nexport default function withExtraConfig(BaseClass, config, options = {}) {\n const newConfig = merge(BaseClass.config, config, options);\n\n if (newConfig.name === BaseClass.config.name) {\n newConfig.name = `${BaseClass.config.name}WithExtraConfig`;\n }\n\n // @ts-ignore\n return class extends BaseClass {\n /**\n * Class config.\n * @type {BaseConfig}\n */\n static config = newConfig;\n };\n}\n","/**\n * @typedef {import('../Base').default} Base\n * @typedef {import('../Base').BaseComponent} BaseComponent\n */\n\n/**\n * @typedef {Object} WithIntersectionObserverOptions\n * @property {Object} intersectionObserver\n */\n\n/**\n * @typedef {Object} WithIntersectionObserverInterface\n * @property {WithIntersectionObserverOptions} $options\n * @property {IntersectionObserver} $observer\n * @property {(entries: IntersectionObserverEntry[]) => void} intersected\n */\n\n/**\n * Create an array of number between 0 and 1 from the given length.\n * @param {Number} length The length of the array.\n * @return {Array} An array of number.\n */\nfunction createArrayOfNumber(length) {\n return [...new Array(length + 1)].map((val, index) => index / length);\n}\n\n/**\n * IntersectionObserver decoration.\n *\n * @template {BaseComponent} T\n * @param {T} BaseClass The Base class to extend.\n * @param {Object} [defaultOptions] The options for the IntersectionObserver instance.\n * @return {T & { new: (element:HTMLElement) => { $observer: IntersectionObserver }}}\n */\nexport default function withIntersectionObserver(\n BaseClass,\n defaultOptions = { threshold: createArrayOfNumber(100) }\n) {\n // @ts-ignore\n return class extends BaseClass {\n /**\n * Add the `intersected` method to the list of method to exclude from the `autoBind` call.\n */\n get __excludeFromAutoBind() {\n return [...(super.__excludeFromAutoBind || []), 'intersected'];\n }\n\n static config = {\n ...(BaseClass.config || {}),\n name: `${BaseClass?.config?.name ?? ''}WithIntersectionObserver`,\n options: {\n ...(BaseClass?.config?.options || {}),\n intersectionObserver: Object,\n },\n };\n\n /**\n * Create an observer when the class in instantiated.\n *\n * @this {Base & WithIntersectionObserverInterface}\n * @param {HTMLElement} element The component's root element.\n */\n constructor(element) {\n super(element);\n\n if (!this.intersected || typeof this.intersected !== 'function') {\n throw new Error('[withIntersectionObserver] The `intersected` method must be defined.');\n }\n\n this.$observer = new IntersectionObserver(\n (entries) => {\n this.__debug('intersected', entries);\n this.$emit('intersected', entries);\n this.intersected(entries);\n },\n { ...defaultOptions, ...(this.$options.intersectionObserver || {}) }\n );\n\n if (this.$isMounted) {\n this.$observer.observe(this.$el);\n }\n\n this.$on('mounted', () => {\n this.$observer.observe(this.$el);\n });\n\n this.$on('destroyed', () => {\n this.$observer.unobserve(this.$el);\n });\n\n return this;\n }\n };\n}\n","/**\n * @typedef {import('../Base').default} Base\n * @typedef {import('../Base').BaseOptions} BaseOptions\n * @typedef {import('../Base').BaseComponent} BaseComponent\n */\n\n/**\n * @typedef {Object} WithMountWhenInViewOptions\n * @property {Object} intersectionObserver\n */\n\n/**\n * @typedef {Object} WithMountWhenInViewInterface\n * @property {() => void} terminated\n * @property {WithMountWhenInViewOptions & BaseOptions} $options\n */\n\n/**\n * IntersectionObserver decoration.\n *\n * @template {BaseComponent} T\n * @param {T} BaseClass The Base class to extend.\n * @param {Object} [defaultOptions] The options for the IntersectionObserver instance.\n * @return {T}\n */\nexport default function withMountWhenInView(BaseClass, defaultOptions = { threshold: [0, 1] }) {\n // @ts-ignore\n return class extends BaseClass {\n /**\n * Class config.\n * @type {Object}\n */\n static config = {\n ...(BaseClass.config || {}),\n name: `${BaseClass?.config?.name ?? ''}WithMountWhenInView`,\n options: {\n ...(BaseClass?.config?.options || {}),\n intersectionObserver: Object,\n },\n };\n\n /**\n * Is the component visible?\n * @type {Boolean}\n */\n #isVisible = false;\n\n /**\n * The component's observer.\n * @type {IntersectionObserver}\n */\n #observer;\n\n /**\n * Create an observer when the class in instantiated.\n *\n * @param {HTMLElement} element The component's root element.\n */\n constructor(element) {\n super(element);\n\n this.#observer = new IntersectionObserver(\n (entries) => {\n const isVisible = entries.reduce((acc, entry) => acc || entry.isIntersecting, false);\n if (this.#isVisible !== isVisible) {\n this.#isVisible = isVisible;\n\n const method = isVisible ? '$mount' : '$destroy';\n this[method]();\n }\n },\n { ...defaultOptions, ...this.$options.intersectionObserver }\n );\n\n this.#observer.observe(this.$el);\n\n this.$on('terminated', () => {\n this.#observer.disconnect();\n });\n\n return this;\n }\n\n /**\n * Override the mounting of the component.\n *\n * @return {this}\n */\n $mount() {\n if (this.#isVisible) {\n super.$mount();\n }\n\n return this;\n }\n };\n}\n","/**\n * @typedef {import('../Base/index.js').BaseComponent} BaseComponent\n */\n\n/**\n * Instantiate and mount the given component on the given root element when the page has been loaded\n * and return a function to use the app instance when it is ready.\n *\n * @usage\n * ```js\n * // app.js\n * import Base, { createApp } from '@studiometa/js-toolkit';\n *\n * class App extends Base {\n * static config = {\n * name: 'App',\n * }\n * }\n *\n * export default createApp(App, document.body);\n * ```\n * ```js\n * // other.js\n * import useApp from './app.js';\n *\n * const app = await useApp();\n * console.log(app.$options.name); // 'App'\n * ```\n *\n * @template {BaseComponent} T\n * @param {T} App\n * @param {HTMLElement} rootElement\n *\n * @return {() => Promise<InstanceType<T>>}\n *\n */\nexport default function createApp(App, rootElement) {\n let isLoaded = document.readyState === 'complete';\n let app;\n\n if (!isLoaded) {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n app = new App(rootElement).$mount();\n isLoaded = true;\n }\n });\n } else {\n app = new App(rootElement).$mount();\n }\n\n return function useApp() {\n if (isLoaded) {\n return Promise.resolve(app);\n }\n\n return new Promise((resolve) => {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n setTimeout(() => resolve(app), 0);\n }\n });\n });\n };\n}\n","/* eslint-disable import/prefer-default-export */\nimport { getComponentElements } from '../Base/utils.js';\n\n/**\n * Get the target elements for the lazy import helper functions.\n *\n * @param {string|HTMLElement|HTMLElement[]} nameOrSelectorOrElement\n * The original selector or element, or list of elements.\n * @param {HTMLElement=} [context]\n * The optional context to use to query for elements.\n *\n * @return {HTMLElement[]} A normalized list of elements.\n */\nexport function getTargetElements(nameOrSelectorOrElement, context) {\n if (typeof nameOrSelectorOrElement === 'string') {\n return getComponentElements(nameOrSelectorOrElement, context);\n }\n\n if (!Array.isArray(nameOrSelectorOrElement)) {\n return [nameOrSelectorOrElement];\n }\n\n return nameOrSelectorOrElement;\n}\n","import { getTargetElements } from './utils.js';\n\n/**\n * @typedef {import('../Base/index.js').BaseComponent} BaseComponent\n * @typedef {import('../Base/index.js').default} Base\n */\n\n/**\n * Import a component on an interaction.\n *\n * @template {BaseComponent} T\n *\n * @param {() => Promise<T|{default:T}>} fn\n * The import function.\n * @param {string|HTMLElement|HTMLElement[]} nameOrSelectorOrElement\n * The name or selector for the component.\n * @param {string|string[]} events\n * The events to listen to to trigger the import.\n * @param {Base=} [parent]\n * The parent component.\n *\n * @return {Promise<T>}\n */\nexport default function importOnInteraction(fn, nameOrSelectorOrElement, events, parent) {\n const normalizedEvents = typeof events === 'string' ? [events] : events;\n\n let ResolvedClass;\n\n const resolver = (resolve) => {\n fn().then((module) => {\n ResolvedClass = 'default' in module ? module.default : module;\n resolve(ResolvedClass);\n });\n };\n\n return new Promise((resolve) => {\n const elements = getTargetElements(nameOrSelectorOrElement, parent?.$el);\n const eventListenerOptions = {\n capture: true,\n passive: true,\n once: true,\n };\n const handler = () => {\n resolver(resolve);\n };\n\n elements.forEach((element) => {\n normalizedEvents.forEach((event) => {\n element.addEventListener(event, handler, eventListenerOptions);\n });\n });\n });\n}\n","/**\n * @typedef {import('../Base/index.js').BaseComponent} BaseComponent\n * @typedef {{ timeout?: number }} ImportWhenIdleOptions\n */\n\n/**\n * Import a component when user is idle.\n *\n * @template {BaseComponent} T\n *\n * @param {() => Promise<T|{default:T}>} fn\n * The import function.\n * @param {ImportWhenIdleOptions=} [options]\n * The time to wait before triggering the callback if never idle.\n *\n * @return {Promise<T>}\n */\nexport default function importWhenIdle(fn, options) {\n let ResolvedClass;\n\n const resolver = (resolve) => {\n fn().then((module) => {\n ResolvedClass = 'default' in module ? module.default : module;\n resolve(ResolvedClass);\n });\n };\n\n return new Promise((resolve) => {\n const timeout = options?.timeout ?? 1;\n\n if (!('requestIdleCallback' in window)) {\n setTimeout(() => {\n resolver(resolve);\n }, timeout);\n } else {\n window.requestIdleCallback(\n () => {\n setTimeout(() => {\n resolver(resolve);\n }, 0);\n },\n { timeout: options?.timeout }\n );\n }\n });\n}\n","import { getTargetElements } from './utils.js';\n\n/**\n * @typedef {import('../Base/index.js').default} Base\n * @typedef {import('../Base/index.js').BaseComponent} BaseComponent\n */\n\n/**\n * Import a component when it is visible.\n *\n * @template {BaseComponent} T\n *\n * @param {() => Promise<T|{default:T}>} fn\n * The import function.\n * @param {string|HTMLElement|HTMLElement[]} nameOrSelectorOrElement\n * The name or selector for the component.\n * @param {Base=} [parent]\n * The parent component.\n * @param {IntersectionObserverInit=} [observerOptions]\n * Options for the `IntersectionObserver` instance.\n *\n * @return {Promise<T>}\n */\nexport default function importWhenVisible(\n fn,\n nameOrSelectorOrElement,\n parent,\n observerOptions = {}\n) {\n let ResolvedClass;\n\n const resolver = (resolve, cb) => {\n fn().then((module) => {\n ResolvedClass = 'default' in module ? module.default : module;\n resolve(ResolvedClass);\n\n if (typeof cb === 'function') {\n cb();\n }\n });\n };\n\n return new Promise((resolve) => {\n const observer = new IntersectionObserver((entries) => {\n const someEntriesAreVisible = entries.some((entry) => entry.isIntersecting);\n if (someEntriesAreVisible) {\n setTimeout(() => {\n resolver(resolve, () => observer.disconnect());\n }, 0);\n }\n }, observerOptions);\n\n const elements = getTargetElements(nameOrSelectorOrElement, parent?.$el);\n elements.forEach((element) => observer.observe(element));\n });\n}\n"],"names":["getAllProperties","object","props","testFn","proto","Object","getPrototypeOf","prototype","foundProps","getOwnPropertyNames","filter","name","map","reduce","acc","val","hasMethod","obj","callMethod","instance","method","args","__debug","$isMounted","$emit","call","getComponentElements","nameOrSelector","element","document","selector","elements","Array","from","querySelectorAll","length","ChildrenManager","registeredNames","keys","this","key","startsWith","constructor","base","components","eventsManager","__base","__element","__components","__eventsManager","registerAll","entries","forEach","component","__register","defineProperty","enumerable","configurable","get","__getChild","el","ComponentClass","__base__","child","then","module","default","mountAll","__triggerHookForAll","updateAll","destroyAll","hook","Promise","resolvedInstance","__triggerHook","unbindChild","bindChild","RefsManager","refs","__refs","refName","unregisterAll","__unregister","isMultiple","endsWith","propName","normalizeRefName","ref","__filterRefsBelongingToInstance","console","warn","$options","bindRef","value","isArray","unbindRef","[object Object]","replace","ancestor","parentElement","undefined","dataset","Service","callbacks","Map","isInit","Error","init","kill","add","callback","has","size","set","remove","delete","trigger","isTouchEvent","event","TouchEvent","Pointer","isDown","y","window","innerHeight","yLast","x","innerWidth","xLast","hasRaf","documentElement","addEventListener","once","capture","options","passive","handleEvent","type","handler","downHandler","upHandler","removeEventListener","updateValues","touches","_event$touches$","clientY","_event$touches$2","clientX","changed","last","delta","progress","max","pointer","usePointer","bind","Raf","super","isTicking","id","raf","requestAnimationFrame","setTimeout","cancelRaf","cancelAnimationFrame","clearTimeout","loop","time","performance","now","useRaf","debounce","fn","delay","timeout","Resize","width","height","ratio","orientation","breakpointElement","breakpoint","breakpoints","querySelector","getComputedStyle","getPropertyValue","split","canUseResizeObserver","ResizeObserver","resize","useResize","Scroll","pageYOffset","pageXOffset","debouncedHandler","debounced","direction","scrollingElement","body","scrollWidth","scrollHeight","scroll","useScroll","ENTER","SPACE","TAB","ESC","LEFT","UP","RIGHT","DOWN","Key","triggered","previousEvent","keyCodes","code","keyCode","isUp","useKey","Load","SERVICES_MAP","scrolled","resized","ticked","moved","keyed","loaded","useLoad","ServicesManager","service","$id","enable","disable","self","enableAll","serviceName","disableAll","register","useFunction","unregister","EventsManager","rootElement","__methodsCache","WeakMap","__rootElementHandler","normalizeName","__refsHandler","currentTarget","index","$refs","indexOf","__childrenHandler","childName","childrenManager","$children","find","includes","detail","__rootElement","__manageRef","mode","action","__getEventMethodsByName","__getEventNameByMethod","__manageChild","__manageRootElement","modeMethod","bindRootElement","unbindRootElement","normalizedName","regex","RegExp","match","normalizeEventName","methods","test","push","c","toLowerCase","trim","toUpperCase","isMergeableObject","isNonNullObject","stringValue","toString","$$typeof","REACT_ELEMENT_TYPE","isReactElement","isSpecial","Symbol","for","cloneUnlessOtherwiseSpecified","clone","deepmerge","defaultArrayMerge","target","source","concat","getKeys","getOwnPropertySymbols","symbol","propertyIsEnumerable","getEnumerableOwnPropertySymbols","propertyIsOnObject","property","_","arrayMerge","sourceIsArray","destination","hasOwnProperty","propertyIsUnsafe","customMerge","getMergeFunction","mergeObject","all","array","prev","next","OptionsManager","schema","baseConfig","__values","__defaultValues","String","Number","Boolean","debug","log","config","hasDefaultValue","types","defaultValue","propertyName","__getPropertyName","hasProperty","__hasProperty","negatedPropertyName","JSON","parse","isObject","stringify","TypeError","prop","prefix","__propertyNameCache","noop","Base","__excludeFromAutoBind","__config","$isBase","$services","services","__services","__options","$el","children","__children","$log","__DEV__","$parent","__events","exclude","include","pattern","some","descriptor","getOwnPropertyDescriptor","autoBind","$mount","$update","$destroy","$terminate","writable","$on","listener","$off","dispatchEvent","CustomEvent","testBreakpoints","breakpointKeys","instances","withBreakpointManager","BaseClass","bk","mountComponents","activeBreakpoints","inactiveBreakpoints","isInActiveBreakpoint","isInInactiveBreakpoint","hasBreakpointConfiguration","addToResize","testConflictingBreakpointConfiguration","withBreakpointObserver","MutationObserver","mutation","attributeName","observe","attributes","_BaseClass$config","inertiaFinalValue","initialValue","initialDelta","factor","finalValue","Math","abs","instanceIds","Drag","isGrabbing","hasInertia","origin","distance","final","pointerHandler","rafHandler","MouseEvent","start","drop","stop","useDrag","drag","withDrag","otherOptions","boundUseDrag","withExtraConfig","newConfig","merge","createArrayOfNumber","withIntersectionObserver","defaultOptions","threshold","intersected","$observer","IntersectionObserver","intersectionObserver","unobserve","withMountWhenInView","_classPrivateFieldLooseBase","isVisible","entry","isIntersecting","disconnect","createApp","App","app","isLoaded","readyState","resolve","getTargetElements","nameOrSelectorOrElement","context","importOnInteraction","events","parent","normalizedEvents","ResolvedClass","eventListenerOptions","resolver","importWhenIdle","requestIdleCallback","importWhenVisible","observerOptions","observer","cb"],"mappings":"wZAUwBA,EAAiBC,EAAQC,EAAQ,GAAIC,EAAS,MACpE,MAAMC,EAAQC,OAAOC,eAAeL,GAEpC,GAAIG,IAAUC,OAAOE,UACnB,OAAOL,EAGT,IAAIM,EAAaH,OAAOI,oBAAoBL,GAQ5C,MANsB,mBAAXD,IACTK,EAAaA,EAAWE,OAAQC,GAASR,EAAOQ,EAAMP,KAGxDI,EAAaA,EAAWI,IAAKD,GAAS,CAACA,EAAMP,IAAQS,OAAO,CAACC,EAAKC,IAAQ,IAAID,EAAKC,GAAMb,GAElFF,EAAiBI,EAAOI,EAAYL,YCd7Ba,EAAUC,EAAKN,GAC7B,MAA4B,mBAAdM,EAAIN,YAUJO,EAAWC,EAAUC,KAAWC,GAK9C,OAJAF,EAASG,QAAQ,aAAcF,KAAWC,GAK5B,cAAXD,IAA2BD,EAASI,YACzB,YAAXH,GAAwBD,EAASI,YAElCJ,EAASG,QAAQ,MAAOF,EAAQ,uDACzBD,IAGTA,EAASK,MAAMJ,KAAWC,GAGrBL,EAAUG,EAAUC,IAIzBD,EAASC,GAAQK,KAAKN,KAAaE,GACnCF,EAASG,QAAQF,EAAQD,KAAaE,GAE/BF,GANEA,YAmBKO,EAAqBC,EAAgBC,EAAUC,UAC7D,MAAMC,EAAY,oBAAmBH,MACrC,IAAII,EAAW,GAEf,IACEA,EAAWC,MAAMC,KAAKL,EAAQM,iBAAiBJ,IAE/C,UAOF,OAJwB,IAApBC,EAASI,SACXJ,EAAWC,MAAMC,KAAKL,EAAQM,iBAAiBP,KAG1CI,QC3DYK,EA4BAC,sBACjB,OAAOhC,OAAOiC,KAAKC,MAAM7B,OAAQ8B,IAASA,EAAIC,WAAW,OA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