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,IAAM,EAAO,EAAO,cAAc,MAC5B,EAAO,EAAO,cAAc,OAElC,EAAQ,EAAQ,EAAI,KAAK,IAAI,GAAQ,GAAQ,KAAK,IAAI,EAAO,GAC7D,EAAQ,EAAQ,EAAI,KAAK,IAAI,GAAQ,GAAQ,KAAK,IAAI,EAAO,EAC9D,CAED,OAAO,IAAI,WAAW,EAAM,CAC1B,QAAS,EAAW,QAAU,EAC9B,QAAS,EAAW,QAAU,EAC9B,QAAS,EAAW,QAAU,EAC9B,QAAS,EAAW,QAAU,EAC9B,UAAW,EACX,UAAW,EACX,OAAQ,EACR,SAAS,EACT,YAAY,EACZ,UAAU,GAEb,CAEQ,WAAc,GACrB,EAAM,gBAAgB,cAAc,EACrC,CAEQ,WAAkB,G,MAGrB,EADF,UAAY,OAAQ,OAEhB,EAAiB,EAAM,iBAGvB,EAAiC,MAAd,EAAoB,EAAS,EAK/C,OACL,aALsB,EAAmB,KAHrB,EAAiB,IAIf,EAAmB,KAHrB,EAAiB,GAQrC,mBAEH,CA1HD,IACA,EAAM,GAAG,SAAU,GA4KnB,EAAU,WACR,IACA,IACA,EAAM,IAAI,SAAU,GACpB,GACD,CACF,EAMC,QAAS,kBAAM,GAAN,EAGZ,CA/ND,EAAoB,mBAAgB,S","file":"/npm/embla-carousel-wheel-gestures@8.1.0/dist/embla-carousel-wheel-gestures.esm.js/+esm","sourceRoot":"","sourcesContent":["/**\n * Bundled by jsDelivr using Rollup v2.79.2 and Terser v5.39.0.\n * Original file: /npm/embla-carousel-wheel-gestures@8.1.0/dist/embla-carousel-wheel-gestures.esm.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { CreateOptionsType, CreatePluginType, EmblaCarouselType, OptionsHandlerType } from 'embla-carousel'\nimport WheelGestures, { WheelEventState } from 'wheel-gestures'\n\nexport type WheelGesturesPluginOptions = CreateOptionsType<{\n  wheelDraggingClass: string\n  forceWheelAxis?: 'x' | 'y'\n  target?: Element\n}>\n\ntype WheelGesturesPluginType = CreatePluginType<{}, WheelGesturesPluginOptions>\n\nconst defaultOptions: WheelGesturesPluginOptions = {\n  active: true,\n  breakpoints: {},\n  wheelDraggingClass: 'is-wheel-dragging',\n  forceWheelAxis: undefined,\n  target: undefined,\n}\n\nWheelGesturesPlugin.globalOptions = undefined as WheelGesturesPluginType['options'] | undefined\n\nconst __DEV__ = process.env.NODE_ENV !== 'production'\n\nexport function WheelGesturesPlugin(userOptions: WheelGesturesPluginType['options'] = {}): WheelGesturesPluginType {\n  let options: WheelGesturesPluginOptions\n  let cleanup = () => {}\n\n  function init(embla: EmblaCarouselType, optionsHandler: OptionsHandlerType) {\n    const { mergeOptions, optionsAtMedia } = optionsHandler\n    const optionsBase = mergeOptions(defaultOptions, WheelGesturesPlugin.globalOptions)\n    const allOptions = mergeOptions(optionsBase, userOptions)\n    options = optionsAtMedia(allOptions)\n\n    const engine = embla.internalEngine()\n    const targetNode = options.target ?? (embla.containerNode().parentNode as Element)\n    const wheelAxis = options.forceWheelAxis ?? engine.options.axis\n    const wheelGestures = WheelGestures({\n      preventWheelAction: wheelAxis,\n      reverseSign: [true, true, false],\n    })\n\n    function updateSizeRelatedVariables() {\n      scrollBoundaryThreshold = (wheelAxis === 'x' ? engine.containerRect.width : engine.containerRect.height) / 2\n    }\n\n    const unobserveTargetNode = wheelGestures.observe(targetNode)\n    const offWheel = wheelGestures.on('wheel', handleWheel)\n\n    let isStarted = false\n    let startEvent: MouseEvent\n    let overBoundaryAccumulation = 0\n    let scrollBoundaryThreshold = 0\n    let blockedWaitUntilGestureEnd = false\n\n    updateSizeRelatedVariables()\n    embla.on('resize', updateSizeRelatedVariables)\n\n    function wheelGestureStarted(state: WheelEventState) {\n      try {\n        startEvent = new MouseEvent('mousedown', state.event)\n        dispatchEvent(startEvent)\n      } catch (e) {\n        // Legacy Browsers like IE 10 & 11 will throw when attempting to create the Event\n        if (__DEV__) {\n          console.warn(\n            'Legacy browser requires events-polyfill (https://github.com/xiel/embla-carousel-wheel-gestures#legacy-browsers)'\n          )\n        }\n        return cleanup()\n      }\n\n      isStarted = true\n      overBoundaryAccumulation = 0\n      addNativeMouseEventListeners()\n\n      if (options.wheelDraggingClass) {\n        targetNode.classList.add(options.wheelDraggingClass)\n      }\n    }\n\n    function wheelGestureEnded(state: WheelEventState) {\n      isStarted = false\n      dispatchEvent(createRelativeMouseEvent('mouseup', state))\n      removeNativeMouseEventListeners()\n\n      if (options.wheelDraggingClass) {\n        targetNode.classList.remove(options.wheelDraggingClass)\n      }\n    }\n\n    function addNativeMouseEventListeners() {\n      document.documentElement.addEventListener('mousemove', preventNativeMouseHandler, true)\n      document.documentElement.addEventListener('mouseup', preventNativeMouseHandler, true)\n      document.documentElement.addEventListener('mousedown', preventNativeMouseHandler, true)\n    }\n\n    function removeNativeMouseEventListeners() {\n      document.documentElement.removeEventListener('mousemove', preventNativeMouseHandler, true)\n      document.documentElement.removeEventListener('mouseup', preventNativeMouseHandler, true)\n      document.documentElement.removeEventListener('mousedown', preventNativeMouseHandler, true)\n    }\n\n    function preventNativeMouseHandler(e: MouseEvent) {\n      if (isStarted && e.isTrusted) {\n        e.stopImmediatePropagation()\n      }\n    }\n\n    function createRelativeMouseEvent(type: 'mousedown' | 'mousemove' | 'mouseup', state: WheelEventState) {\n      let moveX, moveY\n\n      if (wheelAxis === engine.options.axis) {\n        ;[moveX, moveY] = state.axisMovement\n      } else {\n        // if emblas axis and the wheelAxis don't match, swap the axes to match the right embla events\n        ;[moveY, moveX] = state.axisMovement\n      }\n\n      const { isAtBoundary } = checkIfAtBoundary(state)\n\n      // Apply progressive rubber band damping when at boundaries\n      if (isAtBoundary) {\n        // Calculate progressive damping factor based on how far over boundary we are\n        const progressRatio = Math.min(overBoundaryAccumulation / scrollBoundaryThreshold, 1)\n        const dampingFactor = 0.25 + progressRatio * 0.5\n        const counterMoveSign = moveX > 0 ? -1 : 1\n        const counterMovement = overBoundaryAccumulation * counterMoveSign\n        const dampingMovement = counterMovement * dampingFactor\n\n        moveX += dampingMovement\n        moveY += dampingMovement\n      }\n\n      // prevent skipping slides\n      if (!engine.options.skipSnaps && !engine.options.dragFree) {\n        const maxX = engine.containerRect.width\n        const maxY = engine.containerRect.height\n\n        moveX = moveX < 0 ? Math.max(moveX, -maxX) : Math.min(moveX, maxX)\n        moveY = moveY < 0 ? Math.max(moveY, -maxY) : Math.min(moveY, maxY)\n      }\n\n      return new MouseEvent(type, {\n        clientX: startEvent.clientX + moveX,\n        clientY: startEvent.clientY + moveY,\n        screenX: startEvent.screenX + moveX,\n        screenY: startEvent.screenY + moveY,\n        movementX: moveX,\n        movementY: moveY,\n        button: 0,\n        bubbles: true,\n        cancelable: true,\n        composed: true,\n      })\n    }\n\n    function dispatchEvent(event: UIEvent) {\n      embla.containerNode().dispatchEvent(event)\n    }\n\n    function checkIfAtBoundary(state: WheelEventState) {\n      const {\n        axisDelta: [deltaX, deltaY],\n      } = state\n      const scrollProgress = embla.scrollProgress()\n      const canScrollNext = scrollProgress < 1\n      const canScrollPrev = scrollProgress > 0\n      const primaryAxisDelta = wheelAxis === 'x' ? deltaX : deltaY\n      const isScrollingNext = primaryAxisDelta < 0\n      const isScrollingPrev = primaryAxisDelta > 0\n      const isAtBoundary = (isScrollingNext && !canScrollNext) || (isScrollingPrev && !canScrollPrev)\n\n      return {\n        isAtBoundary,\n        primaryAxisDelta,\n      }\n    }\n\n    function isBoundaryThresholdReached(state: WheelEventState) {\n      const { isAtBoundary, primaryAxisDelta } = checkIfAtBoundary(state)\n\n      if (isAtBoundary && !state.isMomentum) {\n        overBoundaryAccumulation += Math.abs(primaryAxisDelta)\n\n        // End gesture if we exceed the threshold\n        if (overBoundaryAccumulation > scrollBoundaryThreshold) {\n          blockedWaitUntilGestureEnd = true\n          wheelGestureEnded(state)\n          return true\n        }\n      } else {\n        // Reset accumulation when we can scroll or when not at boundary\n        overBoundaryAccumulation = 0\n      }\n\n      return false\n    }\n\n    function handleWheel(state: WheelEventState) {\n      const {\n        axisDelta: [deltaX, deltaY],\n      } = state\n      const primaryAxisDelta = wheelAxis === 'x' ? deltaX : deltaY\n      const crossAxisDelta = wheelAxis === 'x' ? deltaY : deltaX\n      const isRelease = state.isMomentum && state.previous && !state.previous.isMomentum\n      const isEndingOrRelease = (state.isEnding && !state.isMomentum) || isRelease\n      const primaryAxisDeltaIsDominant = Math.abs(primaryAxisDelta) > Math.abs(crossAxisDelta)\n\n      if (primaryAxisDeltaIsDominant && !isStarted && !state.isMomentum && !blockedWaitUntilGestureEnd) {\n        wheelGestureStarted(state)\n      }\n\n      if (blockedWaitUntilGestureEnd && state.isEnding) {\n        blockedWaitUntilGestureEnd = false\n      }\n\n      if (!isStarted) return\n\n      if (isBoundaryThresholdReached(state)) return\n\n      if (isEndingOrRelease) {\n        wheelGestureEnded(state)\n      } else {\n        dispatchEvent(createRelativeMouseEvent('mousemove', state))\n      }\n    }\n\n    cleanup = () => {\n      unobserveTargetNode()\n      offWheel()\n      embla.off('resize', updateSizeRelatedVariables)\n      removeNativeMouseEventListeners()\n    }\n  }\n\n  const self: WheelGesturesPluginType = {\n    name: 'wheelGestures',\n    options: userOptions,\n    init,\n    destroy: () => cleanup(),\n  }\n  return self\n}\n\ndeclare module 'embla-carousel' {\n  interface EmblaPluginsType {\n    wheelGestures?: WheelGesturesPluginType\n  }\n}\n"]}