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mBAAZ,EAAyB,EAAU,SAAC,GAAC,OAAM,EAAU,EAAQ,CAC7E,IAAC,CAre+B,CAIxB,MAAM,YAAS,EAAA,iBAAA,SAJJ,cAAa,YAKN,CACxB,QAAS,UAAU,UAAU,CAAC,UAAU,OAAQ,UAAU,OAAO,WACjE,SAAU,UAAU,KACpB,KAAM,UAAU,MAAM,WACtB,UAAW,UAAU,KACrB,UAAW,UAAU,KACrB,aAAc,UAAU,OACxB,cAAe,UAAU,KACzB,QAAS,UAAU,OACnB,YAAa,UAAU,KACvB,mBAAoB,UAAU,OAAO,WACrC,qBAAsB,UAAU,OAAO,WACvC,YAAa,UAAU,UACxB,EAAA,iBAAA,SAlBkB,cAAa,eAmB4B,CAC1D,aAAc,CAAE,UAAW,IAAK,QAAS,IACzC,QAAS,GACT,aAAa,EACb,eAAe,EACf,mBAAoB,GACpB,qBAAsB,KACvB,OAAA,gBAAA,QAAA,OAAA,QAAA,QAAA,QAAA","file":"/npm/react-draggable-list@4.2.1/dist/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/react-draggable-list@4.2.1/dist/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/* eslint react/prop-types: \"error\" */\n\nimport * as React from 'react';\nimport * as PropTypes from 'prop-types';\nimport { Motion, spring, OpaqueConfig } from 'react-motion';\nimport update from 'immutability-helper';\nimport MultiRef from 'react-multi-ref';\nimport OnUpdate from './OnUpdate';\nimport MoveContainer, { HeightData } from './MoveContainer';\n\nconst DEFAULT_HEIGHT: HeightData = { natural: 200, drag: 30 };\n\nfunction getScrollSpeed(distance: number, speed: number, size: number): number {\n  // If distance is zero, then the result is the max speed. Otherwise,\n  // the result tapers toward zero as it gets closer to the opposite\n  // edge of the region.\n  return Math.round(speed - (speed / size) * distance);\n}\n\ninterface Drag {\n  itemKey: string;\n\n  // The y position of the dragged item when the drag started. This will be\n  // equal to the initial mouseY value. The items not being dragged will be\n  // positioned so that the dragged item's original position lines up with\n  // startY.\n  startY: number;\n\n  // The y-position that corresponds to the mouse's current location. The\n  // dragged item will be rendered with this as its y-position.\n  mouseY: number;\n\n  // This is the difference between the raw mouse y value and startY. For\n  // example, if a user clicks the drag handle at a point 5 px below the item's\n  // top, then mouseOffset will be set to 5. As the user moves their mouse, we\n  // update mouseY to be the raw mouse y value minus mouseOffset.\n  mouseOffset: number;\n}\n\nexport interface TemplateProps<I, C> {\n  item: I;\n  itemSelected: number;\n  anySelected: number;\n  dragHandleProps: object;\n  commonProps: C;\n}\n\nexport interface Props<I, C, T> {\n  itemKey: string | ((item: I) => string);\n  template: new (props: any, context?: any) => T;\n  list: ReadonlyArray<I>;\n  onMoveEnd?: (\n    newList: ReadonlyArray<I>,\n    movedItem: I,\n    oldIndex: number,\n    newIndex: number\n  ) => void;\n  container?: () => HTMLElement | null | undefined;\n  constrainDrag?: boolean;\n  springConfig?: object;\n  padding?: number;\n  unsetZIndex?: boolean;\n  autoScrollMaxSpeed?: number;\n  autoScrollRegionSize?: number;\n  commonProps?: C;\n  onDragStart?: (draggedItem: I) => void;\n  onDragEnd?: (draggedItem: I) => void;\n}\ninterface State {\n  useAbsolutePositioning: boolean;\n  dragging: boolean;\n  lastDrag: Drag | null;\n  heights: { [key: string]: HeightData } | null;\n}\nexport default class DraggableList<\n  I,\n  C,\n  T extends React.Component<Partial<TemplateProps<I, C>>>\n> extends React.Component<Props<I, C, T>, State> {\n  public static propTypes = {\n    itemKey: PropTypes.oneOfType([PropTypes.string, PropTypes.func]).isRequired,\n    template: PropTypes.func,\n    list: PropTypes.array.isRequired,\n    onMoveEnd: PropTypes.func,\n    container: PropTypes.func,\n    springConfig: PropTypes.object,\n    constrainDrag: PropTypes.bool,\n    padding: PropTypes.number,\n    unsetZIndex: PropTypes.bool,\n    autoScrollMaxSpeed: PropTypes.number.isRequired,\n    autoScrollRegionSize: PropTypes.number.isRequired,\n    commonProps: PropTypes.object,\n  };\n  public static defaultProps: Partial<Props<any, any, any>> = {\n    springConfig: { stiffness: 300, damping: 50 },\n    padding: 10,\n    unsetZIndex: false,\n    constrainDrag: false,\n    autoScrollMaxSpeed: 15,\n    autoScrollRegionSize: 30,\n  };\n  private readonly _itemRefs: MultiRef<string, MoveContainer<I, any, T>> =\n    new MultiRef();\n  private _autoScrollerTimer: any;\n\n  private _listRef = React.createRef<HTMLDivElement>();\n\n  public state: State = {\n    useAbsolutePositioning: false,\n    dragging: false,\n    lastDrag: null,\n    heights: null,\n  };\n\n  public getItemInstance(key: string): T {\n    const ref = this._itemRefs.map.get(key);\n    if (!ref) throw new Error('key not found');\n    return ref.getTemplate();\n  }\n\n  public static getDerivedStateFromProps<I, C, T>(\n    newProps: Props<I, C, T>,\n    state: State\n  ): Partial<State> | null {\n    const { list } = newProps;\n    const { lastDrag } = state;\n\n    if (lastDrag) {\n      const keyFn = DraggableList._getKeyFn<I>(newProps.itemKey);\n\n      try {\n        DraggableList._getIndexOfItemWithKey<I>(keyFn, list, lastDrag.itemKey);\n      } catch (err) {\n        // If the dragged item was removed from the list, this block will get hit.\n        // Cancel the drag.\n        return { dragging: false, lastDrag: null };\n      }\n    }\n\n    return null;\n  }\n\n  public componentWillUnmount() {\n    this._handleMouseUp();\n  }\n\n  private _handleTouchStart(\n    itemKey: string,\n    pressY: number | undefined,\n    event: TouchEvent | React.TouchEvent\n  ) {\n    event.stopPropagation();\n    this._handleStartDrag(itemKey, pressY, event.touches[0].pageY);\n  }\n\n  private _handleMouseDown(\n    itemKey: string,\n    pressY: number | undefined,\n    event: MouseEvent | React.MouseEvent\n  ) {\n    event.preventDefault();\n    this._handleStartDrag(itemKey, pressY, event.pageY);\n  }\n\n  private _handleStartDrag(\n    itemKey: string,\n    pressY: number | undefined,\n    pageY: number\n  ) {\n    if (document.documentElement)\n      document.documentElement.style.cursor = 'move';\n    window.addEventListener('mouseup', this._handleMouseUp);\n    window.addEventListener('touchend', this._handleMouseUp);\n    window.addEventListener('touchmove', this._handleTouchMove);\n    window.addEventListener('mousemove', this._handleMouseMove);\n\n    const keyFn = this._getKeyFn();\n\n    if (this.props.onDragStart) {\n      const {list} = this.props;\n      const draggedItem = list[DraggableList._getIndexOfItemWithKey(keyFn, list, itemKey)];\n      this.props.onDragStart(draggedItem);\n    }\n\n    // If an element has focus while we drag around the parent, some browsers\n    // try to scroll the parent element to keep the focused element in view.\n    // Prevent that by unfocusing the element if it is focused.\n    {\n      const listEl = this._listRef.current;\n      if (!listEl) throw new Error('Should not happen');\n      if (\n        listEl.contains &&\n        document.activeElement &&\n        listEl.contains(document.activeElement) &&\n        document.activeElement instanceof HTMLElement\n      ) {\n        document.activeElement.blur();\n      }\n    }\n\n    let newHeights = null;\n    if (this.state.heights == null) {\n      const _newHeights: { [key: string]: HeightData } = Object.create(null);\n\n      this.props.list.forEach((item) => {\n        const key = keyFn(item);\n        const containerRef = this._itemRefs.map.get(key);\n        const refEl = containerRef\n          ? containerRef.getDOMNode().firstElementChild\n          : null;\n        const ref = containerRef ? containerRef.getTemplate() : null;\n        const natural =\n          refEl instanceof HTMLElement\n            ? refEl.offsetHeight\n            : DEFAULT_HEIGHT.natural;\n        const drag =\n          (ref &&\n            typeof (ref as any).getDragHeight === 'function' &&\n            (ref as any).getDragHeight()) ||\n          natural;\n\n        _newHeights[key] = { natural, drag };\n      });\n\n      newHeights = _newHeights;\n    }\n\n    // Need to re-render once before we start dragging so that the `y` values\n    // are set using the correct state.heights and then can animate from there.\n\n    const afterHeights = () => {\n      const itemIndex = DraggableList._getIndexOfItemWithKey(keyFn, this.props.list, itemKey);\n\n      // pressY will be non-null if the list is currently animating (because the\n      // clicked item has its `y` prop set). pressY will be null if the list is\n      // not currently animating (because the clicked item will be at its\n      // natural position, which is calculatable using _getDistance).\n      const startY =\n        pressY == null ? this._getDistance(0, itemIndex, false) : pressY;\n\n      const containerEl = this._getContainer();\n      const containerScroll =\n        !containerEl || containerEl === document.body\n          ? 0\n          : containerEl.scrollTop;\n\n      this.setState({\n        useAbsolutePositioning: true,\n        dragging: true,\n        lastDrag: {\n          itemKey,\n          startY,\n          mouseY: startY,\n          mouseOffset: pageY - startY + containerScroll,\n        },\n      });\n    };\n\n    if (newHeights) {\n      this.setState({ heights: newHeights }, afterHeights);\n    } else {\n      afterHeights();\n    }\n  }\n\n  private _handleTouchMove = (e: TouchEvent) => {\n    e.preventDefault();\n    this._handleMouseMove(e.touches[0]);\n  };\n\n  private _handleMouseMove = ({\n    pageY,\n    clientY,\n  }: MouseEvent | Touch | { pageY: number; clientY: number }) => {\n    const { list } = this.props;\n    const autoScrollMaxSpeed = this.props.autoScrollMaxSpeed!;\n    const autoScrollRegionSize = this.props.autoScrollRegionSize!;\n    const { dragging, lastDrag } = this.state;\n    if (!dragging || !lastDrag) return;\n\n    const containerEl = this._getContainer();\n    const dragVisualIndex = this._getDragVisualIndex();\n    const keyFn = this._getKeyFn();\n\n    clearInterval(this._autoScrollerTimer);\n\n    // If the user has the mouse near the top or bottom of the container and\n    // not at the end of the list, then autoscroll.\n    if (dragVisualIndex !== 0 && dragVisualIndex !== list.length - 1) {\n      let scrollSpeed = 0;\n\n      const containerRect =\n        containerEl &&\n        containerEl !== document.body &&\n        containerEl.getBoundingClientRect\n          ? containerEl.getBoundingClientRect()\n          : { top: 0, bottom: Infinity };\n\n      // Get the lowest of the screen top and the container top.\n      const top = Math.max(0, containerRect.top);\n\n      const distanceFromTop = clientY - top;\n      if (distanceFromTop > 0 && distanceFromTop < autoScrollRegionSize) {\n        scrollSpeed =\n          -1 *\n          getScrollSpeed(\n            distanceFromTop,\n            autoScrollMaxSpeed,\n            autoScrollRegionSize\n          );\n      } else {\n        // Get the lowest of the screen bottom and the container bottom.\n        const bottom = Math.min(window.innerHeight, containerRect.bottom);\n        const distanceFromBottom = bottom - clientY;\n        if (\n          distanceFromBottom > 0 &&\n          distanceFromBottom < autoScrollRegionSize\n        ) {\n          scrollSpeed = getScrollSpeed(\n            distanceFromBottom,\n            autoScrollMaxSpeed,\n            autoScrollRegionSize\n          );\n        }\n      }\n\n      if (scrollSpeed !== 0) {\n        this._scrollContainer(scrollSpeed);\n        this._autoScrollerTimer = setTimeout(() => {\n          this._handleMouseMove({\n            pageY: pageY + (containerEl === document.body ? scrollSpeed : 0),\n            clientY,\n          });\n        }, 16);\n      }\n    }\n\n    const containerScroll =\n      !containerEl || containerEl === document.body ? 0 : containerEl.scrollTop;\n    let mouseY = pageY - lastDrag.mouseOffset + containerScroll;\n    if (this.props.constrainDrag) {\n      const visualList = this._getVisualListDuringDrag();\n\n      mouseY = Math.max(\n        mouseY,\n        this._getDistanceFromTopDuringDrag(\n          lastDrag,\n          keyFn(visualList[0]),\n          visualList\n        )\n      );\n      mouseY = Math.min(\n        mouseY,\n        this._getDistanceFromTopDuringDrag(\n          lastDrag,\n          keyFn(visualList[visualList.length - 1]),\n          visualList\n        )\n      );\n    }\n\n    this.setState({ lastDrag: { ...lastDrag, mouseY } });\n  };\n\n  private _handleMouseUp = () => {\n    clearInterval(this._autoScrollerTimer);\n    window.removeEventListener('mouseup', this._handleMouseUp);\n    window.removeEventListener('touchend', this._handleMouseUp);\n    window.removeEventListener('touchmove', this._handleTouchMove);\n    window.removeEventListener('mousemove', this._handleMouseMove);\n\n    if (document.documentElement) document.documentElement.style.cursor = '';\n    this._lastScrollDelta = 0;\n\n    const { list, onMoveEnd, onDragEnd } = this.props;\n    const { dragging, lastDrag } = this.state;\n\n    if (dragging && lastDrag && onMoveEnd) {\n      const dragIndex = this._getDragListIndex();\n      const newIndex = this._getDragVisualIndex();\n\n      if (onDragEnd) {\n        onDragEnd(list[dragIndex]);\n      }\n\n      if (dragIndex !== newIndex) {\n        const newList = this._getVisualListDuringDrag();\n\n        onMoveEnd(newList, list[dragIndex], dragIndex, newIndex);\n      }\n\n      this.setState({ dragging: false });\n    }\n  };\n\n  private _scrollContainer(delta: number) {\n    const containerEl = this._getContainer();\n    if (!containerEl) return;\n    if (window.scrollBy && containerEl === document.body) {\n      window.scrollBy(0, delta);\n    } else {\n      containerEl.scrollTop += delta;\n    }\n  }\n\n  private _lastScrollDelta = 0;\n  private _adjustScrollAtEnd(delta: number) {\n    const frameDelta = Math.round(delta - this._lastScrollDelta);\n    this._scrollContainer(frameDelta);\n    this._lastScrollDelta += frameDelta;\n  }\n\n  private static _getIndexOfItemWithKey<I>(\n    keyFn: (item: I) => string,\n    list: ReadonlyArray<I>,\n    itemKey: string\n  ): number {\n    for (let i = 0, len = list.length; i < len; i++) {\n      if (keyFn(list[i]) === itemKey) {\n        return i;\n      }\n    }\n    throw new Error('Failed to find drag index');\n  }\n\n  private _getDragListIndex(): number {\n    const { list } = this.props;\n    const { lastDrag } = this.state;\n    if (!lastDrag) {\n      throw new Error('No drag happened');\n    }\n    const keyFn = this._getKeyFn();\n    return DraggableList._getIndexOfItemWithKey(keyFn, list, lastDrag.itemKey);\n  }\n\n  private _getDragVisualIndex(): number {\n    const { list } = this.props;\n    const padding = this.props.padding!;\n    const { dragging, lastDrag } = this.state;\n    if (!dragging || !lastDrag) throw new Error('Should not happen');\n\n    const dragListIndex = this._getDragListIndex();\n\n    const { mouseY, startY } = lastDrag;\n\n    const movementFromNatural = mouseY - startY;\n    // 1 down, -1 up, 0 neither\n    const direction =\n      movementFromNatural > 0 ? 1 : movementFromNatural < 0 ? -1 : 0;\n    let newIndex = dragListIndex;\n    if (direction !== 0) {\n      const keyFn = this._getKeyFn();\n      let reach = Math.abs(movementFromNatural);\n      for (\n        let i = dragListIndex + direction;\n        i < list.length && i >= 0;\n        i += direction\n      ) {\n        const iDragHeight = this._getItemHeight(keyFn(list[i])).drag;\n        if (reach < iDragHeight / 2 + padding) break;\n        reach -= iDragHeight + padding;\n        newIndex = i;\n      }\n    }\n\n    return newIndex;\n  }\n\n  private _getVisualListDuringDrag(): ReadonlyArray<I> {\n    const { list } = this.props;\n    const { dragging, lastDrag } = this.state;\n    if (!dragging || !lastDrag)\n      throw new Error(\n        'Should not happen: _getVisualListDuringDrag called outside of drag'\n      );\n\n    const dragListIndex = this._getDragListIndex();\n    const dragVisualIndex = this._getDragVisualIndex();\n\n    return update(list, {\n      $splice: [\n        [dragListIndex, 1],\n        [dragVisualIndex, 0, list[dragListIndex]],\n      ],\n    });\n  }\n\n  private _getItemHeight(key: string): HeightData {\n    return this.state.heights != null && key in this.state.heights\n      ? this.state.heights[key]\n      : DEFAULT_HEIGHT;\n  }\n\n  // Get the distance between the tops of two items in the list.\n  // Does not consider how the dragged item may be rendered in a different position\n  // unless you pass in the re-ordered list as a parameter.\n  private _getDistance(\n    start: number,\n    end: number,\n    dragging: boolean,\n    list: ReadonlyArray<I> = this.props.list\n  ): number {\n    if (end < start) {\n      return -this._getDistance(end, start, dragging, list);\n    }\n\n    const padding = this.props.padding!;\n    const keyFn = this._getKeyFn();\n    let distance = 0;\n    for (let i = start; i < end; i++) {\n      const height = this._getItemHeight(keyFn(list[i]));\n      distance += (dragging ? height.drag : height.natural) + padding;\n    }\n    return distance;\n  }\n\n  private _getDistanceFromTopDuringDrag(\n    lastDrag: Drag,\n    itemKey: string,\n    visualList: ReadonlyArray<I>\n  ): number {\n    const keyFn = this._getKeyFn();\n    const index = DraggableList._getIndexOfItemWithKey(\n      keyFn,\n      visualList,\n      itemKey\n    );\n    const dragListIndex = this._getDragListIndex();\n    const dragVisualIndex = DraggableList._getIndexOfItemWithKey(\n      keyFn,\n      visualList,\n      lastDrag.itemKey\n    );\n\n    let offset = 0;\n    if (dragVisualIndex < dragListIndex) {\n      const dragItemHeight = this._getItemHeight(lastDrag.itemKey);\n      const newCenterHeight = this._getItemHeight(\n        keyFn(visualList[dragListIndex])\n      );\n      offset = dragItemHeight.drag - newCenterHeight.drag;\n    }\n\n    return (\n      lastDrag.startY +\n      offset +\n      this._getDistance(dragListIndex, index, true, visualList)\n    );\n  }\n\n  private _getContainer(): HTMLElement | null | undefined {\n    const { container } = this.props;\n    return container ? container() : null;\n  }\n\n  private static _getKeyFn<I>(\n    itemKey: string | ((item: I) => string)\n  ): (item: I) => string {\n    return typeof itemKey === 'function' ? itemKey : (x) => (x as any)[itemKey];\n  }\n\n  private _getKeyFn(): (item: I) => string {\n    return DraggableList._getKeyFn<I>(this.props.itemKey);\n  }\n\n  render() {\n    const padding = this.props.padding!;\n    const {\n      list,\n      springConfig,\n      container,\n      template,\n      unsetZIndex,\n      commonProps,\n    } = this.props;\n    const { dragging, lastDrag, useAbsolutePositioning } = this.state;\n\n    const keyFn = this._getKeyFn();\n    const anySelected = spring(dragging ? 1 : 0, springConfig);\n\n    const visualList = dragging ? this._getVisualListDuringDrag() : list;\n\n    const children = list.map((item, i) => {\n      const key = keyFn(item);\n      const selectedStyle =\n        dragging && lastDrag && lastDrag.itemKey === key\n          ? {\n              itemSelected: spring(1, springConfig),\n              y: lastDrag.mouseY,\n            }\n          : {\n              itemSelected: spring(0, springConfig),\n              y: (useAbsolutePositioning ? spring : (x: number) => x)(\n                dragging && lastDrag\n                  ? this._getDistanceFromTopDuringDrag(\n                      lastDrag,\n                      key,\n                      visualList\n                    )\n                  : this._getDistance(0, i, false),\n                springConfig\n              ),\n            };\n      const style = {\n        anySelected,\n        ...selectedStyle,\n      };\n      const makeDragHandleProps = (getY: () => number | undefined): object => ({\n        onMouseDown: (e: React.MouseEvent) =>\n          this._handleMouseDown(key, getY(), e),\n        onTouchStart: (e: React.TouchEvent) =>\n          this._handleTouchStart(key, getY(), e),\n      });\n      const height = this._getItemHeight(key);\n      return (\n        <Motion\n          style={style}\n          key={key}\n          children={({ itemSelected, anySelected, y }) => (\n            <MoveContainer\n              ref={this._itemRefs.ref(key)}\n              y={useAbsolutePositioning ? y : undefined}\n              template={template}\n              padding={padding}\n              item={item}\n              itemSelected={itemSelected}\n              anySelected={anySelected}\n              height={height}\n              zIndex={\n                unsetZIndex && !useAbsolutePositioning\n                  ? 'auto'\n                  : lastDrag && lastDrag.itemKey === key\n                  ? list.length\n                  : i\n              }\n              makeDragHandleProps={makeDragHandleProps}\n              commonProps={commonProps}\n            />\n          )}\n        />\n      );\n    });\n\n    let adjustScroll: number | OpaqueConfig = 0;\n    if (!dragging && lastDrag && useAbsolutePositioning) {\n      const dragListIndex = this._getDragListIndex();\n      adjustScroll = spring(\n        this._getDistance(0, dragListIndex, false) - lastDrag.mouseY,\n        springConfig\n      );\n    }\n\n    let heightReserverHeight = 0;\n    let heightReserverMarginBottom = 0;\n    if (list.length) {\n      heightReserverMarginBottom = padding;\n      if (useAbsolutePositioning) {\n        heightReserverHeight =\n          this._getDistance(0, list.length, false) - padding;\n      }\n    }\n    return (\n      <div style={{ position: 'relative' }} ref={this._listRef}>\n        <Motion\n          style={{ adjustScroll, anySelected }}\n          onRest={() => {\n            if (!dragging) {\n              this.setState({\n                heights: null,\n                useAbsolutePositioning: false,\n              });\n            }\n          }}\n          children={({ adjustScroll }) => (\n            <div\n              style={{\n                display: useAbsolutePositioning ? 'block' : 'none',\n                height: `${heightReserverHeight}px`,\n                marginBottom: `${heightReserverMarginBottom}px`,\n              }}\n            >\n              {container && (\n                <OnUpdate\n                  cb={() => {\n                    if (!dragging && lastDrag && useAbsolutePositioning) {\n                      this._adjustScrollAtEnd(adjustScroll);\n                    }\n                  }}\n                />\n              )}\n            </div>\n          )}\n        />\n        {children}\n      </div>\n    );\n  }\n}\n"]}