{"version":3,"sources":["jsdelivr-header.js","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/context.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/utils.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/components/default-cursor.tsx","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/components/default-row.tsx","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/components/default-node.tsx","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/state/edit-slice.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/state/focus-slice.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/interfaces/node-api.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/data/create-root.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/state/open-slice.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/state/initial.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/state/selection-slice.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/state/dnd-slice.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/components/default-drag-preview.tsx","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/components/cursor.tsx","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/components/list-outer-element.tsx","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/components/list-inner-element.tsx","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/dnd/drag-hook.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/dnd/compute-drop.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/dnd/drop-hook.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/hooks/use-fresh-node.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/components/row-container.tsx","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/components/default-container.tsx","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/data/create-list.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/data/create-index.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/interfaces/tree-api.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/state/drag-slice.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/state/root-reducer.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/components/provider.tsx","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/dnd/outer-drop-hook.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/components/outer-drop.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/components/tree-container.tsx","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/components/drag-preview-container.tsx","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/data/simple-tree.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/hooks/use-simple-tree.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/hooks/use-validated-props.ts","/npm/teora-react-arborist@1.0.8/dist/packages/teora-react-arborist/src/components/tree.tsx"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,iyBCDO,MAAM,2CAAiB,EAAA,aAAA,eAAmC,MAE1D,SAAS,4CACd,MAAM,GAAQ,EAAA,aAAA,YACZ,2CAEF,GAAc,OAAV,EAAgB,MAAM,IAAI,MAAM,wBACpC,OAAO,C,CAGF,MAAM,2CAAe,EAAA,aAAA,eAAyC,MAE9D,SAAS,4CACd,MAAM,GAAQ,EAAA,aAAA,YAAW,2CACzB,GAAc,OAAV,EAAgB,MAAM,IAAI,MAAM,0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E,CCtDT,SAAS,0CAAqB,GACnC,GAAI,EAAM,aAAe,EAAM,KAC7B,MAAM,IAAI,MACR,mFAGJ,GACE,EAAM,cACL,EAAM,UAAY,EAAM,UAAY,EAAM,QAAU,EAAM,UAE3D,MAAM,IAAI,MACR,kJAIJ,GAAI,EAAM,YAAa,CAQrB,MAAO,EAAM,GAAc,0CAAiB,EAAM,aAClD,MAAO,IAAK,KAAU,E,KAAY,E,CAElC,OAAO,C,CCpBX,SAAS,oCACP,EACA,GAEA,MAAM,EAAY,0CAAkB,GACpC,OACE,EAAA,uBAAA,MAAC,0CAAY,CAAC,UAAW,EAAW,iBAAkB,E,WACpD,EAAA,uBAAA,KAAC,0CAAS,C,UACR,EAAA,uBAAA,KAAC,yCAAa,OAEhB,EAAA,uBAAA,KAAC,0CAAoB,M,CAKpB,MAAM,2CAAO,EAAA,aAAA,YAAW,qC","file":"/npm/teora-react-arborist@1.0.8/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/teora-react-arborist@1.0.8/dist/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","import React, { createContext, useContext, useMemo } from \"react\";\nimport { TreeApi } from \"./interfaces/tree-api\";\nimport { RootState } from \"./state/root-reducer\";\nimport { IdObj } from \"./types/utils\";\n\nexport const TreeApiContext = createContext<TreeApi<any> | null>(null);\n\nexport function useTreeApi<T>() {\n  const value = useContext<TreeApi<T> | null>(\n    TreeApiContext as unknown as React.Context<TreeApi<T> | null>\n  );\n  if (value === null) throw new Error(\"No Tree Api Provided\");\n  return value;\n}\n\nexport const NodesContext = createContext<RootState[\"nodes\"] | null>(null);\n\nexport function useNodesContext() {\n  const value = useContext(NodesContext);\n  if (value === null) throw new Error(\"Provide a NodesContext\");\n  return value;\n}\n\nexport const DndContext = createContext<RootState[\"dnd\"] | null>(null);\n\nexport function useDndContext() {\n  const value = useContext(DndContext);\n  if (value === null) throw new Error(\"Provide a DnDContext\");\n  return value;\n}\n\nexport const DataUpdatesContext = createContext<number>(0);\n\nexport function useDataUpdates() {\n  useContext(DataUpdatesContext);\n}\n","import { NodeApi } from \"./interfaces/node-api\";\nimport { TreeApi } from \"./interfaces/tree-api\";\nimport { IdObj } from \"./types/utils\";\n\nexport function bound(n: number, min: number, max: number) {\n  return Math.max(Math.min(n, max), min);\n}\n\nexport function isItem(node: NodeApi<any> | null) {\n  return node && node.isLeaf;\n}\n\nexport function isClosed(node: NodeApi<any> | null) {\n  return node && node.isInternal && !node.isOpen;\n}\n\n/**\n * Is first param a decendent of the second param\n */\nexport const isDecendent = (a: NodeApi<any>, b: NodeApi<any>) => {\n  let n: NodeApi<any> | null = a;\n  while (n) {\n    if (n.id === b.id) return true;\n    n = n.parent;\n  }\n  return false;\n};\n\nexport const indexOf = (node: NodeApi<any>) => {\n  if (!node.parent) throw Error(\"Node does not have a parent\");\n  return node.parent.children!.findIndex((c) => c.id === node.id);\n};\n\nexport function noop() {}\n\nexport function dfs(node: NodeApi<any>, id: string): NodeApi<any> | null {\n  if (!node) return null;\n  if (node.id === id) return node;\n  if (node.children) {\n    for (let child of node.children) {\n      const result = dfs(child, id);\n      if (result) return result;\n    }\n  }\n  return null;\n}\n\nexport function walk(\n  node: NodeApi<any>,\n  fn: (node: NodeApi<any>) => void\n): void {\n  fn(node);\n  if (node.children) {\n    for (let child of node.children) {\n      walk(child, fn);\n    }\n  }\n}\n\nexport function focusNextElement(target: HTMLElement) {\n  const elements = getFocusable(target);\n\n  let next: HTMLElement;\n  for (let i = 0; i < elements.length; ++i) {\n    const item = elements[i];\n    if (item === target) {\n      next = nextItem(elements, i);\n      break;\n    }\n  }\n\n  // @ts-ignore ??\n  next?.focus();\n}\n\nexport function focusPrevElement(target: HTMLElement) {\n  const elements = getFocusable(target);\n  let next: HTMLElement;\n  for (let i = 0; i < elements.length; ++i) {\n    const item = elements[i];\n    if (item === target) {\n      next = prevItem(elements, i);\n      break;\n    }\n  }\n  // @ts-ignore\n  next?.focus();\n}\n\nfunction nextItem(list: HTMLElement[], index: number) {\n  if (index + 1 < list.length) {\n    return list[index + 1] as HTMLElement;\n  } else {\n    return list[0] as HTMLElement;\n  }\n}\n\nfunction prevItem(list: HTMLElement[], index: number) {\n  if (index - 1 >= 0) {\n    return list[index - 1];\n  } else {\n    return list[list.length - 1];\n  }\n}\n\nfunction getFocusable(target: HTMLElement) {\n  return Array.from(\n    document.querySelectorAll(\n      'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"]):not([disabled]), details:not([disabled]), summary:not(:disabled)'\n    )\n  ).filter((e) => e === target || !target.contains(e)) as HTMLElement[];\n}\n\nexport function access<T = boolean>(\n  obj: any,\n  accessor: string | boolean | Function\n): T {\n  if (typeof accessor === \"boolean\") return accessor as unknown as T;\n  if (typeof accessor === \"string\") return obj[accessor] as T;\n  return accessor(obj) as T;\n}\n\nexport function identifyNull(obj: string | IdObj | null) {\n  if (obj === null) return null;\n  else return identify(obj);\n}\n\nexport function identify(obj: string | IdObj) {\n  return typeof obj === \"string\" ? obj : obj.id;\n}\n\nexport function mergeRefs(...refs: any) {\n  return (instance: any) => {\n    refs.forEach((ref: any) => {\n      if (typeof ref === \"function\") {\n        ref(instance);\n      } else if (ref != null) {\n        ref.current = instance;\n      }\n    });\n  };\n}\n\nexport function safeRun<T extends (...args: any[]) => any>(\n  fn: T | undefined,\n  ...args: Parameters<T>\n) {\n  if (fn) return fn(...args);\n}\n\nexport function waitFor(fn: () => boolean) {\n  return new Promise<void>((resolve, reject) => {\n    let tries = 0;\n    function check() {\n      tries += 1;\n      if (tries === 100) reject();\n      if (fn()) resolve();\n      else setTimeout(check, 10);\n    }\n    check();\n  });\n}\n\nexport function getInsertIndex(tree: TreeApi<any>) {\n  const focus = tree.focusedNode;\n  if (!focus) return tree.root.children?.length ?? 0;\n  if (focus.isOpen) return 0;\n  if (focus.parent) return focus.childIndex + 1;\n  return 0;\n}\n\nexport function getInsertParentId(tree: TreeApi<any>) {\n  const focus = tree.focusedNode;\n  if (!focus) return null;\n  if (focus.isOpen) return focus.id;\n  if (focus.parent && !focus.parent.isRoot) return focus.parent.id;\n  return null;\n}\n","import React, { CSSProperties } from \"react\";\nimport { CursorProps } from \"../types/renderers\";\n\nconst placeholderStyle = {\n  display: \"flex\",\n  alignItems: \"center\",\n  zIndex: 1,\n};\n\nconst lineStyle = {\n  flex: 1,\n  height: \"2px\",\n  background: \"#4B91E2\",\n  borderRadius: \"1px\",\n};\n\nconst circleStyle = {\n  width: \"4px\",\n  height: \"4px\",\n  boxShadow: \"0 0 0 3px #4B91E2\",\n  borderRadius: \"50%\",\n};\n\nexport const DefaultCursor = React.memo(function DefaultCursor({\n  top,\n  left,\n  indent,\n}: CursorProps) {\n  const style: CSSProperties = {\n    position: \"absolute\",\n    pointerEvents: \"none\",\n    top: top - 2 + \"px\",\n    left: left + \"px\",\n    right: indent + \"px\",\n  };\n  return (\n    <div style={{ ...placeholderStyle, ...style }}>\n      <div style={{ ...circleStyle }}></div>\n      <div style={{ ...lineStyle }}></div>\n    </div>\n  );\n});\n","import React from \"react\";\nimport { RowRendererProps } from \"../types/renderers\";\nimport { IdObj } from \"../types/utils\";\n\nexport function DefaultRow<T>({\n  node,\n  attrs,\n  innerRef,\n  children,\n}: RowRendererProps<T>) {\n  return (\n    <div\n      {...attrs}\n      ref={innerRef}\n      onFocus={(e) => e.stopPropagation()}\n      onClick={node.handleClick}\n    >\n      {children}\n    </div>\n  );\n}\n","import React, { useEffect, useRef } from \"react\";\nimport { NodeRendererProps } from \"../types/renderers\";\nimport { IdObj } from \"../types/utils\";\n\nexport function DefaultNode<T>(props: NodeRendererProps<T>) {\n  return (\n    <div ref={props.dragHandle} style={props.style}>\n      <span\n        onClick={(e) => {\n          e.stopPropagation();\n          props.node.toggle();\n        }}\n      >\n        {props.node.isLeaf ? \"🌳\" : props.node.isOpen ? \"🗁\" : \"🗀\"}\n      </span>{\" \"}\n      {props.node.isEditing ? <Edit {...props} /> : <Show {...props} />}\n    </div>\n  );\n}\n\nfunction Show<T>(props: NodeRendererProps<T>) {\n  return (\n    <>\n      {/* @ts-ignore */}\n      <span>{props.node.data.name}</span>\n    </>\n  );\n}\n\nfunction Edit<T>({ node }: NodeRendererProps<T>) {\n  const input = useRef<any>();\n\n  useEffect(() => {\n    input.current?.focus();\n    input.current?.select();\n  }, []);\n\n  return (\n    <input\n      ref={input}\n      // @ts-ignore\n      defaultValue={node.data.name}\n      onBlur={() => node.reset()}\n      onKeyDown={(e) => {\n        if (e.key === \"Escape\") node.reset();\n        if (e.key === \"Enter\") node.submit(input.current?.value || \"\");\n      }}\n    ></input>\n  );\n}\n","/* Types */\nexport type EditState = { id: string | null };\n\n/* Actions */\nexport function edit(id: string | null) {\n  return { type: \"EDIT\" as const, id };\n}\n\n/* Reducer */\nexport function reducer(\n  state: EditState = { id: null },\n  action: ReturnType<typeof edit>\n) {\n  if (action.type === \"EDIT\") {\n    return { ...state, id: action.id };\n  } else {\n    return state;\n  }\n}\n","/* Types */\n\nexport type FocusState = { id: string | null; treeFocused: boolean };\n\n/* Actions */\n\nexport function focus(id: string | null) {\n  return { type: \"FOCUS\" as const, id };\n}\n\nexport function treeBlur() {\n  return { type: \"TREE_BLUR\" } as const;\n}\n\n/* Reducer */\n\nexport function reducer(\n  state: FocusState = { id: null, treeFocused: false },\n  action: ReturnType<typeof focus> | ReturnType<typeof treeBlur>\n) {\n  if (action.type === \"FOCUS\") {\n    return { ...state, id: action.id, treeFocused: true };\n  } else if (action.type === \"TREE_BLUR\") {\n    return { ...state, treeFocused: false };\n  } else {\n    return state;\n  }\n}\n","import React from \"react\";\nimport { TreeApi } from \"./tree-api\";\nimport { IdObj } from \"../types/utils\";\nimport { ROOT_ID } from \"../data/create-root\";\n\ntype Params<T> = {\n  id: string;\n  data: T;\n  level: number;\n  children: NodeApi<T>[] | null;\n  parent: NodeApi<T> | null;\n  isDraggable: boolean;\n  rowIndex: number | null;\n  tree: TreeApi<T>;\n};\n\nexport class NodeApi<T = any> {\n  tree: TreeApi<T>;\n  id: string;\n  data: T;\n  level: number;\n  children: NodeApi<T>[] | null;\n  parent: NodeApi<T> | null;\n  isDraggable: boolean;\n  rowIndex: number | null;\n\n  constructor(params: Params<T>) {\n    this.tree = params.tree;\n    this.id = params.id;\n    this.data = params.data;\n    this.level = params.level;\n    this.children = params.children;\n    this.parent = params.parent;\n    this.isDraggable = params.isDraggable;\n    this.rowIndex = params.rowIndex;\n  }\n\n  get isRoot() {\n    return this.id === ROOT_ID;\n  }\n\n  get isLeaf() {\n    return !Array.isArray(this.children);\n  }\n\n  get isInternal() {\n    return !this.isLeaf;\n  }\n\n  get isOpen() {\n    return this.isLeaf ? false : this.tree.isOpen(this.id);\n  }\n\n  get isClosed() {\n    return this.isLeaf ? false : !this.tree.isOpen(this.id);\n  }\n\n  get isEditable() {\n    return this.tree.isEditable(this.data);\n  }\n\n  get isEditing() {\n    return this.tree.editingId === this.id;\n  }\n\n  get isSelected() {\n    return this.tree.isSelected(this.id);\n  }\n\n  get isOnlySelection() {\n    return this.isSelected && this.tree.hasOneSelection;\n  }\n\n  get isSelectedStart() {\n    return this.isSelected && !this.prev?.isSelected;\n  }\n\n  get isSelectedEnd() {\n    return this.isSelected && !this.next?.isSelected;\n  }\n\n  get isFocused() {\n    return this.tree.isFocused(this.id);\n  }\n\n  get isDragging() {\n    return this.tree.isDragging(this.id);\n  }\n\n  get willReceiveDrop() {\n    return this.tree.willReceiveDrop(this.id);\n  }\n\n  get state() {\n    return {\n      isClosed: this.isClosed,\n      isDragging: this.isDragging,\n      isEditing: this.isEditing,\n      isFocused: this.isFocused,\n      isInternal: this.isInternal,\n      isLeaf: this.isLeaf,\n      isOpen: this.isOpen,\n      isSelected: this.isSelected,\n      isSelectedEnd: this.isSelectedEnd,\n      isSelectedStart: this.isSelectedStart,\n      willReceiveDrop: this.willReceiveDrop,\n    };\n  }\n\n  get childIndex() {\n    if (this.parent && this.parent.children) {\n      return this.parent.children.findIndex((child) => child.id === this.id);\n    } else {\n      return -1;\n    }\n  }\n\n  get next(): NodeApi<T> | null {\n    if (this.rowIndex === null) return null;\n    return this.tree.at(this.rowIndex + 1);\n  }\n\n  get prev(): NodeApi<T> | null {\n    if (this.rowIndex === null) return null;\n    return this.tree.at(this.rowIndex - 1);\n  }\n\n  get nextSibling(): NodeApi<T> | null {\n    const i = this.childIndex;\n    return this.parent?.children![i + 1] ?? null;\n  }\n\n  select() {\n    this.tree.select(this);\n  }\n\n  deselect() {\n    this.tree.deselect(this);\n  }\n\n  selectMulti() {\n    this.tree.selectMulti(this);\n  }\n\n  selectContiguous() {\n    this.tree.selectContiguous(this);\n  }\n\n  activate() {\n    this.tree.activate(this);\n  }\n\n  focus() {\n    this.tree.focus(this);\n  }\n\n  toggle() {\n    this.tree.toggle(this);\n  }\n\n  open() {\n    this.tree.open(this);\n  }\n\n  openParents() {\n    this.tree.openParents(this);\n  }\n\n  close() {\n    this.tree.close(this);\n  }\n\n  submit(value: string) {\n    this.tree.submit(this, value);\n  }\n\n  reset() {\n    this.tree.reset();\n  }\n\n  clone() {\n    return new NodeApi<T>({ ...this });\n  }\n\n  edit() {\n    return this.tree.edit(this);\n  }\n\n  handleClick = (e: React.MouseEvent) => {\n    if (e.metaKey && !this.tree.props.disableMultiSelection) {\n      this.isSelected ? this.deselect() : this.selectMulti();\n    } else if (e.shiftKey && !this.tree.props.disableMultiSelection) {\n      this.selectContiguous();\n    } else {\n      this.select();\n      this.activate();\n    }\n  };\n}\n","import { IdObj } from \"../types/utils\";\nimport { NodeApi } from \"../interfaces/node-api\";\nimport { TreeApi } from \"../interfaces/tree-api\";\n\nexport const ROOT_ID = \"__REACT_ARBORIST_INTERNAL_ROOT__\";\n\nexport function createRoot<T>(tree: TreeApi<T>): NodeApi<T> {\n  function visitSelfAndChildren(\n    data: T,\n    level: number,\n    parent: NodeApi<T> | null\n  ) {\n    const id = tree.accessId(data);\n    const node = new NodeApi<T>({\n      tree,\n      data,\n      level,\n      parent,\n      id,\n      children: null,\n      isDraggable: tree.isDraggable(data),\n      rowIndex: null,\n    });\n    const children = tree.accessChildren(data);\n    if (children) {\n      node.children = children.map((child: T) =>\n        visitSelfAndChildren(child, level + 1, node)\n      );\n    }\n    return node;\n  }\n\n  const root = new NodeApi<T>({\n    tree,\n    id: ROOT_ID,\n    // @ts-ignore\n    data: { id: ROOT_ID },\n    level: -1,\n    parent: null,\n    children: null,\n    isDraggable: true,\n    rowIndex: null,\n  });\n\n  const data: readonly T[] = tree.props.data ?? [];\n\n  root.children = data.map((child) => {\n    return visitSelfAndChildren(child, 0, root);\n  });\n\n  return root;\n}\n","import { ActionTypes } from \"../types/utils\";\n\n/* Types */\nexport type OpenMap = { [id: string]: boolean };\nexport type OpenSlice = { unfiltered: OpenMap; filtered: OpenMap };\n\n/* Actions */\nexport const actions = {\n  open(id: string, filtered: boolean) {\n    return { type: \"VISIBILITY_OPEN\" as const, id, filtered };\n  },\n  close(id: string, filtered: boolean) {\n    return { type: \"VISIBILITY_CLOSE\" as const, id, filtered };\n  },\n  toggle(id: string, filtered: boolean) {\n    return { type: \"VISIBILITY_TOGGLE\" as const, id, filtered };\n  },\n  clear(filtered: boolean) {\n    return { type: \"VISIBILITY_CLEAR\" as const, filtered };\n  },\n};\n\n/* Reducer */\n\nfunction openMapReducer(\n  state: OpenMap = {},\n  action: ActionTypes<typeof actions>\n) {\n  if (action.type === \"VISIBILITY_OPEN\") {\n    return { ...state, [action.id]: true };\n  } else if (action.type === \"VISIBILITY_CLOSE\") {\n    return { ...state, [action.id]: false };\n  } else if (action.type === \"VISIBILITY_TOGGLE\") {\n    const prev = state[action.id];\n    return { ...state, [action.id]: !prev };\n  } else if (action.type === \"VISIBILITY_CLEAR\") {\n    return {};\n  } else {\n    return state;\n  }\n}\n\nexport function reducer(\n  state: OpenSlice = { filtered: {}, unfiltered: {} },\n  action: ActionTypes<typeof actions>\n): OpenSlice {\n  if (!action.type.startsWith(\"VISIBILITY\")) return state;\n  if (action.filtered) {\n    return { ...state, filtered: openMapReducer(state.filtered, action) };\n  } else {\n    return { ...state, unfiltered: openMapReducer(state.unfiltered, action) };\n  }\n}\n","import { TreeProps } from \"../types/tree-props\";\nimport { RootState } from \"./root-reducer\";\n\nexport const initialState = (props?: TreeProps<any>): RootState => ({\n  nodes: {\n    // Changes together\n    open: { filtered: {}, unfiltered: props?.initialOpenState ?? {} },\n    focus: { id: null, treeFocused: false },\n    edit: { id: null },\n    drag: { id: null, idWillReceiveDrop: null },\n    selection: { ids: new Set(), anchor: null, mostRecent: null },\n  },\n  dnd: {\n    cursor: { type: \"none\" },\n    dragId: null,\n    dragIds: [],\n    parentId: null,\n    index: -1,\n  },\n});\n","import { ActionTypes, IdObj } from \"../types/utils\";\nimport { identify } from \"../utils\";\nimport { initialState } from \"./initial\";\n\n/* Types */\nexport type SelectionState = {\n  ids: Set<string>;\n  anchor: string | null;\n  mostRecent: string | null;\n};\n\n/* Actions */\nexport const actions = {\n  clear: () => ({ type: \"SELECTION_CLEAR\" as const }),\n\n  only: (id: string | IdObj) => ({\n    type: \"SELECTION_ONLY\" as const,\n    id: identify(id),\n  }),\n\n  add: (id: string | string[] | IdObj | IdObj[]) => ({\n    type: \"SELECTION_ADD\" as const,\n    ids: (Array.isArray(id) ? id : [id]).map(identify),\n  }),\n\n  remove: (id: string | string[] | IdObj | IdObj[]) => ({\n    type: \"SELECTION_REMOVE\" as const,\n    ids: (Array.isArray(id) ? id : [id]).map(identify),\n  }),\n\n  set: (ids: Set<string>) => ({\n    type: \"SELECTION_SET\" as const,\n    ids,\n  }),\n\n  mostRecent: (id: string | null | IdObj) => ({\n    type: \"SELECTION_MOST_RECENT\" as const,\n    id: id === null ? null : identify(id),\n  }),\n\n  anchor: (id: string | null | IdObj) => ({\n    type: \"SELECTION_ANCHOR\" as const,\n    id: id === null ? null : identify(id),\n  }),\n};\n\n/* Reducer */\nexport function reducer(\n  state: SelectionState = initialState()[\"nodes\"][\"selection\"],\n  action: ActionTypes<typeof actions>\n): SelectionState {\n  const ids = state.ids;\n  switch (action.type) {\n    case \"SELECTION_CLEAR\":\n      return { ...state, ids: new Set() };\n    case \"SELECTION_ONLY\":\n      return { ...state, ids: new Set([action.id]) };\n    case \"SELECTION_ADD\":\n      if (action.ids.length === 0) return state;\n      action.ids.forEach((id) => ids.add(id));\n      return { ...state, ids: new Set(ids) };\n    case \"SELECTION_REMOVE\":\n      if (action.ids.length === 0) return state;\n      action.ids.forEach((id) => ids.delete(id));\n      return { ...state, ids: new Set(ids) };\n    case \"SELECTION_SET\":\n      return { ...state, ids: new Set(action.ids) };\n    case \"SELECTION_MOST_RECENT\":\n      return { ...state, mostRecent: action.id };\n    case \"SELECTION_ANCHOR\":\n      return { ...state, anchor: action.id };\n    default:\n      return state;\n  }\n}\n","import { Cursor } from \"../dnd/compute-drop\";\nimport { ActionTypes } from \"../types/utils\";\nimport { initialState } from \"./initial\";\n\n/* Types */\nexport type DndState = {\n  dragId: null | string;\n  cursor: Cursor;\n  dragIds: string[];\n  parentId: null | string;\n  index: number;\n};\n\n/* Actions */\nexport const actions = {\n  cursor(cursor: Cursor) {\n    return { type: \"DND_CURSOR\" as const, cursor };\n  },\n  dragStart(id: string, dragIds: string[]) {\n    return { type: \"DND_DRAG_START\" as const, id, dragIds };\n  },\n  dragEnd() {\n    return { type: \"DND_DRAG_END\" as const };\n  },\n  hovering(parentId: string | null, index: number) {\n    return { type: \"DND_HOVERING\" as const, parentId, index };\n  },\n};\n\n/* Reducer */\nexport function reducer(\n  state: DndState = initialState()[\"dnd\"],\n  action: ActionTypes<typeof actions>\n): DndState {\n  switch (action.type) {\n    case \"DND_CURSOR\":\n      return { ...state, cursor: action.cursor };\n    case \"DND_DRAG_START\":\n      return { ...state, dragId: action.id, dragIds: action.dragIds };\n    case \"DND_DRAG_END\":\n      return initialState()[\"dnd\"];\n    case \"DND_HOVERING\":\n      return { ...state, parentId: action.parentId, index: action.index };\n    default:\n      return state;\n  }\n}\n","import React, { CSSProperties, memo } from \"react\";\nimport { XYCoord } from \"react-dnd\";\nimport { useTreeApi } from \"../context\";\nimport { DragPreviewProps } from \"../types/renderers\";\nimport { IdObj } from \"../types/utils\";\n\nconst layerStyles: CSSProperties = {\n  position: \"fixed\",\n  pointerEvents: \"none\",\n  zIndex: 100,\n  left: 0,\n  top: 0,\n  width: \"100%\",\n  height: \"100%\",\n};\n\nconst getStyle = (offset: XYCoord | null) => {\n  if (!offset) return { display: \"none\" };\n  const { x, y } = offset;\n  return { transform: `translate(${x}px, ${y}px)` };\n};\n\nconst getCountStyle = (offset: XYCoord | null) => {\n  if (!offset) return { display: \"none\" };\n  const { x, y } = offset;\n  return { transform: `translate(${x + 10}px, ${y + 10}px)` };\n};\n\nexport function DefaultDragPreview({\n  offset,\n  mouse,\n  id,\n  dragIds,\n  isDragging,\n}: DragPreviewProps) {\n  return (\n    <Overlay isDragging={isDragging}>\n      <Position offset={offset}>\n        <PreviewNode id={id} dragIds={dragIds} />\n      </Position>\n      <Count mouse={mouse} count={dragIds.length} />\n    </Overlay>\n  );\n}\n\nconst Overlay = memo(function Overlay(props: {\n  children: JSX.Element[];\n  isDragging: boolean;\n}) {\n  if (!props.isDragging) return null;\n  return <div style={layerStyles}>{props.children}</div>;\n});\n\nfunction Position(props: { children: JSX.Element; offset: XYCoord | null }) {\n  return (\n    <div className=\"row preview\" style={getStyle(props.offset)}>\n      {props.children}\n    </div>\n  );\n}\n\nfunction Count(props: { count: number; mouse: XYCoord | null }) {\n  const { count, mouse } = props;\n  if (count > 1)\n    return (\n      <div className=\"selected-count\" style={getCountStyle(mouse)}>\n        {count}\n      </div>\n    );\n  else return null;\n}\n\nconst PreviewNode = memo(function PreviewNode<T>(props: {\n  id: string | null;\n  dragIds: string[];\n}) {\n  const tree = useTreeApi<T>();\n  const node = tree.get(props.id);\n  if (!node) return null;\n  return (\n    <tree.renderNode\n      preview\n      node={node}\n      style={{\n        paddingLeft: node.level * tree.indent,\n        opacity: 0.2,\n        background: \"transparent\",\n      }}\n      tree={tree}\n    />\n  );\n});\n","import { useDndContext, useTreeApi } from \"../context\";\n\nexport function Cursor() {\n  const tree = useTreeApi();\n  const state = useDndContext();\n  const cursor = state.cursor;\n  if (!cursor || cursor.type !== \"line\") return null;\n  const indent = tree.indent;\n  const top =\n    tree.rowHeight * cursor.index +\n    (tree.props.padding ?? tree.props.paddingTop ?? 0);\n  const left = indent * cursor.level;\n  const Cursor = tree.renderCursor;\n  return <Cursor {...{ top, left, indent }} />;\n}\n","import { forwardRef } from \"react\";\nimport { useTreeApi } from \"../context\";\nimport { treeBlur } from \"../state/focus-slice\";\nimport { Cursor } from \"./cursor\";\n\nexport const ListOuterElement = forwardRef(function Outer(\n  props: React.HTMLProps<HTMLDivElement>,\n  ref\n) {\n  const { children, ...rest } = props;\n  const tree = useTreeApi();\n  return (\n    <div\n      // @ts-ignore\n      ref={ref}\n      {...rest}\n      onClick={(e) => {\n        if (e.currentTarget === e.target) tree.deselectAll();\n      }}\n    >\n      <DropContainer />\n      {children}\n    </div>\n  );\n});\n\nconst DropContainer = () => {\n  const tree = useTreeApi();\n  return (\n    <div\n      style={{\n        height: tree.visibleNodes.length * tree.rowHeight,\n        width: \"100%\",\n        position: \"absolute\",\n        left: \"0\",\n        right: \"0\",\n      }}\n    >\n      <Cursor />\n    </div>\n  );\n};\n","import React from \"react\";\nimport { forwardRef } from \"react\";\nimport { useTreeApi } from \"../context\";\n\nexport const ListInnerElement = forwardRef<any, any>(function InnerElement(\n  { style, ...rest },\n  ref\n) {\n  const tree = useTreeApi();\n  const paddingTop = tree.props.padding ?? tree.props.paddingTop ?? 0;\n  const paddingBottom = tree.props.padding ?? tree.props.paddingBottom ?? 0;\n  return (\n    <div\n      ref={ref}\n      style={{\n        ...style,\n        height: `${parseFloat(style.height) + paddingTop + paddingBottom}px`,\n      }}\n      {...rest}\n    />\n  );\n});\n","import { useEffect } from \"react\";\nimport { ConnectDragSource, useDrag } from \"react-dnd\";\nimport { getEmptyImage } from \"react-dnd-html5-backend\";\nimport { useTreeApi } from \"../context\";\nimport { NodeApi } from \"../interfaces/node-api\";\nimport { DragItem } from \"../types/dnd\";\nimport { DropResult } from \"./drop-hook\";\nimport { actions as dnd } from \"../state/dnd-slice\";\nimport { safeRun } from \"../utils\";\nimport { ROOT_ID } from \"../data/create-root\";\n\nexport function useDragHook<T>(node: NodeApi<T>): ConnectDragSource {\n  const tree = useTreeApi();\n  const ids = tree.selectedIds;\n  const [_, ref, preview] = useDrag<DragItem, DropResult, void>(\n    () => ({\n      canDrag: () => node.isDraggable,\n      type: \"NODE\",\n      item: () => {\n        // This is fired once at the begging of a drag operation\n        const dragIds = tree.isSelected(node.id) ? Array.from(ids) : [node.id];\n        tree.dispatch(dnd.dragStart(node.id, dragIds));\n        return { id: node.id };\n      },\n      end: () => {\n        tree.hideCursor();\n        let { parentId, index, dragIds } = tree.state.dnd;\n        // If they held down meta, we need to create a copy\n        // if (drop.dropEffect === \"copy\")\n        if (tree.canDrop()) {\n          safeRun(tree.props.onMove, {\n            dragIds,\n            parentId: parentId === ROOT_ID ? null : parentId,\n            index,\n            dragNodes: tree.dragNodes,\n            parentNode: tree.get(parentId),\n          });\n          tree.open(parentId);\n        }\n        tree.dispatch(dnd.dragEnd());\n      },\n    }),\n    [ids, node]\n  );\n\n  useEffect(() => {\n    preview(getEmptyImage());\n  }, [preview]);\n\n  return ref;\n}\n","import { XYCoord } from \"react-dnd\";\nimport { NodeApi } from \"../interfaces/node-api\";\nimport { bound, indexOf, isClosed, isItem } from \"../utils\";\nimport { DropResult } from \"./drop-hook\";\n\nfunction measureHover(el: HTMLElement, offset: XYCoord) {\n  const rect = el.getBoundingClientRect();\n  const x = offset.x - Math.round(rect.x);\n  const y = offset.y - Math.round(rect.y);\n  const height = rect.height;\n  const inTopHalf = y < height / 2;\n  const inBottomHalf = !inTopHalf;\n  const pad = height / 4;\n  const inMiddle = y > pad && y < height - pad;\n  const atTop = !inMiddle && inTopHalf;\n  const atBottom = !inMiddle && inBottomHalf;\n  return { x, inTopHalf, inBottomHalf, inMiddle, atTop, atBottom };\n}\n\ntype HoverData = ReturnType<typeof measureHover>;\n\nfunction getNodesAroundCursor(\n  node: NodeApi | null,\n  prev: NodeApi | null,\n  next: NodeApi | null,\n  hover: HoverData\n): [NodeApi | null, NodeApi | null] {\n  if (!node) {\n    // We're hoving over the empty part of the list, not over an item,\n    // Put the cursor below the last item which is \"prev\"\n    return [prev, null];\n  }\n  if (node.isInternal) {\n    if (hover.atTop) {\n      return [prev, node];\n    } else if (hover.inMiddle) {\n      return [node, node];\n    } else {\n      return [node, next];\n    }\n  } else {\n    if (hover.inTopHalf) {\n      return [prev, node];\n    } else {\n      return [node, next];\n    }\n  }\n}\n\ntype Args = {\n  element: HTMLElement;\n  offset: XYCoord;\n  indent: number;\n  node: NodeApi | null;\n  prevNode: NodeApi | null;\n  nextNode: NodeApi | null;\n};\n\nfunction getDropLevel(\n  hovering: HoverData,\n  aboveCursor: NodeApi | null,\n  belowCursor: NodeApi | null,\n  indent: number\n) {\n  const hoverLevel = Math.round(Math.max(0, hovering.x - indent) / indent);\n  let min, max;\n  if (!aboveCursor) {\n    max = 0;\n    min = 0;\n  } else if (!belowCursor) {\n    max = aboveCursor.level;\n    min = 0;\n  } else {\n    max = aboveCursor.level;\n    min = belowCursor.level;\n  }\n\n  return bound(hoverLevel, min, max);\n}\n\nexport type ComputedDrop = {\n  drop: DropResult | null;\n  cursor: Cursor | null;\n};\n\nfunction dropAt(parentId: string | undefined, index: number): DropResult {\n  return { parentId: parentId || null, index };\n}\n\nfunction lineCursor(index: number, level: number) {\n  return {\n    type: \"line\" as \"line\",\n    index,\n    level,\n  };\n}\n\nfunction noCursor() {\n  return {\n    type: \"none\" as \"none\",\n  };\n}\n\nfunction highlightCursor(id: string) {\n  return {\n    type: \"highlight\" as \"highlight\",\n    id,\n  };\n}\n\nfunction walkUpFrom(node: NodeApi, level: number) {\n  let drop = node;\n  while (drop.parent && drop.level > level) {\n    drop = drop.parent;\n  }\n  const parentId = drop.parent?.id || null;\n  const index = indexOf(drop) + 1;\n  return { parentId, index };\n}\n\nexport type LineCursor = ReturnType<typeof lineCursor>;\nexport type NoCursor = ReturnType<typeof noCursor>;\nexport type HighlightCursor = ReturnType<typeof highlightCursor>;\nexport type Cursor = LineCursor | NoCursor | HighlightCursor;\n\n/**\n * This is the most complex, tricky function in the whole repo.\n * It could be simplified and made more understandable.\n */\nexport function computeDrop(args: Args): ComputedDrop {\n  const hover = measureHover(args.element, args.offset);\n  const { node, nextNode, prevNode } = args;\n  const [above, below] = getNodesAroundCursor(node, prevNode, nextNode, hover);\n\n  /* Hovering over the middle of a folder */\n  if (node && node.isInternal && hover.inMiddle) {\n    return {\n      drop: dropAt(node.id, 0),\n      cursor: highlightCursor(node.id),\n    };\n  }\n\n  /* At the top of the list */\n  if (!above) {\n    return {\n      drop: dropAt(below?.parent?.id, 0),\n      cursor: lineCursor(0, 0),\n    };\n  }\n\n  /* The above node is an item or a closed folder */\n  if (isItem(above) || isClosed(above)) {\n    const level = getDropLevel(hover, above, below, args.indent);\n    return {\n      drop: walkUpFrom(above, level),\n      cursor: lineCursor(above.rowIndex! + 1, level),\n    };\n  }\n\n  /* The above node is an open folder */\n  return {\n    drop: dropAt(above?.id, 0),\n    cursor: lineCursor(above.rowIndex! + 1, above.level + 1),\n  };\n}\n","import { RefObject } from \"react\";\nimport { ConnectDropTarget, useDrop } from \"react-dnd\";\nimport { useTreeApi } from \"../context\";\nimport { NodeApi } from \"../interfaces/node-api\";\nimport { DragItem } from \"../types/dnd\";\nimport { computeDrop } from \"./compute-drop\";\nimport { actions as dnd } from \"../state/dnd-slice\";\n\nexport type DropResult = {\n  parentId: string | null;\n  index: number;\n};\n\nexport function useDropHook(\n  el: RefObject<HTMLElement | null>,\n  node: NodeApi<any>\n): ConnectDropTarget {\n  const tree = useTreeApi();\n  const [_, dropRef] = useDrop<DragItem, DropResult | null, void>(\n    () => ({\n      accept: \"NODE\",\n      canDrop: () => tree.canDrop(),\n      hover: (_item, m) => {\n        const offset = m.getClientOffset();\n        if (!el.current || !offset) return;\n        const { cursor, drop } = computeDrop({\n          element: el.current,\n          offset: offset,\n          indent: tree.indent,\n          node: node,\n          prevNode: node.prev,\n          nextNode: node.next,\n        });\n        if (drop) tree.dispatch(dnd.hovering(drop.parentId, drop.index));\n\n        if (m.canDrop()) {\n          if (cursor) tree.showCursor(cursor);\n        } else {\n          tree.hideCursor();\n        }\n      },\n      drop: (_, m) => {\n        if (!m.canDrop()) return null;\n      },\n    }),\n    [node, el.current, tree.props]\n  );\n\n  return dropRef;\n}\n","import { useMemo } from \"react\";\nimport { useTreeApi } from \"../context\";\nimport { IdObj } from \"../types/utils\";\n\nexport function useFreshNode<T>(index: number) {\n  const tree = useTreeApi<T>();\n  const original = tree.at(index);\n  if (!original) throw new Error(`Could not find node for index: ${index}`);\n\n  return useMemo(() => {\n    const fresh = original.clone();\n    tree.visibleNodes[index] = fresh; // sneaky\n    return fresh;\n    // Return a fresh instance if the state values change\n  }, [...Object.values(original.state), original]);\n}\n","import React, { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { useDataUpdates, useNodesContext, useTreeApi } from \"../context\";\nimport { useDragHook } from \"../dnd/drag-hook\";\nimport { useDropHook } from \"../dnd/drop-hook\";\nimport { useFreshNode } from \"../hooks/use-fresh-node\";\n\ntype Props = {\n  style: React.CSSProperties;\n  index: number;\n};\n\nexport const RowContainer = React.memo(function RowContainer<T>({\n  index,\n  style,\n}: Props) {\n  /* When will the <Row> will re-render.\n   *\n   * The row component is memo'd so it will only render\n   * when a new instance of the NodeApi class is passed\n   * to it.\n   *\n   * The TreeApi instance is stable. It does not\n   * change when the internal state changes.\n   *\n   * The TreeApi has all the references to the nodes.\n   * We need to clone the nodes when their state\n   * changes. The node class contains no state itself,\n   * It always checks the tree for state. The tree's\n   * state will always be up to date.\n   */\n\n  useDataUpdates(); // Re-render when tree props or visability changes\n  const _ = useNodesContext(); // So that we re-render appropriately\n  const tree = useTreeApi<T>(); // Tree already has the fresh state\n  const node = useFreshNode<T>(index);\n\n  const el = useRef<HTMLDivElement | null>(null);\n  const dragRef = useDragHook<T>(node);\n  const dropRef = useDropHook(el, node);\n  const innerRef = useCallback(\n    (n: any) => {\n      el.current = n;\n      dropRef(n);\n    },\n    [dropRef]\n  );\n\n  const indent = tree.indent * node.level;\n  const nodeStyle = useMemo(() => ({ paddingLeft: indent }), [indent]);\n  const rowStyle = useMemo(\n    () => ({\n      ...style,\n      top:\n        parseFloat(style.top as string) +\n        (tree.props.padding ?? tree.props.paddingTop ?? 0),\n    }),\n    [style, tree.props.padding, tree.props.paddingTop]\n  );\n  const rowAttrs: React.HTMLAttributes<any> = {\n    role: \"treeitem\",\n    \"aria-level\": node.level,\n    \"aria-selected\": node.isSelected,\n    style: rowStyle,\n    tabIndex: -1,\n    className: tree.props.rowClassName,\n  };\n\n  useEffect(() => {\n    if (!node.isEditing && node.isFocused) {\n      el.current?.focus({ preventScroll: true });\n    }\n  }, [node.isEditing, node.isFocused, el.current]);\n\n  const Node = tree.renderNode;\n  const Row = tree.renderRow;\n\n  return (\n    <Row node={node} innerRef={innerRef} attrs={rowAttrs}>\n      <Node node={node} tree={tree} style={nodeStyle} dragHandle={dragRef} />\n    </Row>\n  );\n});\n","import { FixedSizeList } from \"react-window\";\nimport { useDataUpdates, useTreeApi } from \"../context\";\nimport { focusNextElement, focusPrevElement } from \"../utils\";\nimport { ListOuterElement } from \"./list-outer-element\";\nimport { ListInnerElement } from \"./list-inner-element\";\nimport { RowContainer } from \"./row-container\";\n\nlet focusSearchTerm = \"\";\nlet timeoutId: any = null;\n\n/**\n * All these keyboard shortcuts seem like they should be configurable.\n * Each operation should be a given a name and separated from\n * the event handler. Future clean up welcome.\n */\nexport function DefaultContainer() {\n  useDataUpdates();\n  const tree = useTreeApi();\n  return (\n    <div\n      style={{\n        height: tree.height,\n        width: tree.width,\n        minHeight: 0,\n        minWidth: 0,\n      }}\n      onContextMenu={tree.props.onContextMenu}\n      onClick={tree.props.onClick}\n      tabIndex={0}\n      onFocus={(e) => {\n        if (!e.currentTarget.contains(e.relatedTarget)) {\n          tree.onFocus();\n        }\n      }}\n      onBlur={(e) => {\n        if (!e.currentTarget.contains(e.relatedTarget)) {\n          tree.onBlur();\n        }\n      }}\n      onKeyDown={(e) => {\n        if (tree.isEditing) {\n          return;\n        }\n        if (e.key === \"Backspace\") {\n          if (!tree.props.onDelete) return;\n          const ids = Array.from(tree.selectedIds);\n          if (ids.length > 1) {\n            let nextFocus = tree.mostRecentNode;\n            while (nextFocus && nextFocus.isSelected) {\n              nextFocus = nextFocus.nextSibling;\n            }\n            if (!nextFocus) nextFocus = tree.lastNode;\n            tree.focus(nextFocus, { scroll: false });\n            tree.delete(Array.from(ids));\n          } else {\n            const node = tree.focusedNode;\n            if (node) {\n              const sib = node.nextSibling;\n              const parent = node.parent;\n              tree.focus(sib || parent, { scroll: false });\n              tree.delete(node);\n            }\n          }\n          return;\n        }\n        if (e.key === \"Tab\" && !e.shiftKey) {\n          e.preventDefault();\n          focusNextElement(e.currentTarget);\n          return;\n        }\n        if (e.key === \"Tab\" && e.shiftKey) {\n          e.preventDefault();\n          focusPrevElement(e.currentTarget);\n          return;\n        }\n        if (e.key === \"ArrowDown\") {\n          e.preventDefault();\n          const next = tree.nextNode;\n          if (e.metaKey) {\n            tree.select(tree.focusedNode);\n            tree.activate(tree.focusedNode);\n            return;\n          } else if (!e.shiftKey || tree.props.disableMultiSelection) {\n            tree.focus(next);\n            return;\n          } else {\n            if (!next) return;\n            const current = tree.focusedNode;\n            if (!current) {\n              tree.focus(tree.firstNode);\n            } else if (current.isSelected) {\n              tree.selectContiguous(next);\n            } else {\n              tree.selectMulti(next);\n            }\n            return;\n          }\n        }\n        if (e.key === \"ArrowUp\") {\n          e.preventDefault();\n          const prev = tree.prevNode;\n          if (!e.shiftKey || tree.props.disableMultiSelection) {\n            tree.focus(prev);\n            return;\n          } else {\n            if (!prev) return;\n            const current = tree.focusedNode;\n            if (!current) {\n              tree.focus(tree.lastNode); // ?\n            } else if (current.isSelected) {\n              tree.selectContiguous(prev);\n            } else {\n              tree.selectMulti(prev);\n            }\n            return;\n          }\n        }\n        if (e.key === \"ArrowRight\") {\n          const node = tree.focusedNode;\n          if (!node) return;\n          if (node.isInternal && node.isOpen) {\n            tree.focus(tree.nextNode);\n          } else if (node.isInternal) tree.open(node.id);\n          return;\n        }\n        if (e.key === \"ArrowLeft\") {\n          const node = tree.focusedNode;\n          if (!node || node.isRoot) return;\n          if (node.isInternal && node.isOpen) tree.close(node.id);\n          else if (!node.parent?.isRoot) {\n            tree.focus(node.parent);\n          }\n          return;\n        }\n        if (e.key === \"a\" && e.metaKey && !tree.props.disableMultiSelection) {\n          e.preventDefault();\n          tree.selectAll();\n          return;\n        }\n        if (e.key === \"a\" && !e.metaKey && tree.props.onCreate) {\n          tree.createLeaf();\n          return;\n        }\n        if (e.key === \"A\" && !e.metaKey) {\n          if (!tree.props.onCreate) return;\n          tree.createInternal();\n          return;\n        }\n\n        if (e.key === \"Home\") {\n          // add shift keys\n          e.preventDefault();\n          tree.focus(tree.firstNode);\n          return;\n        }\n        if (e.key === \"End\") {\n          // add shift keys\n          e.preventDefault();\n          tree.focus(tree.lastNode);\n          return;\n        }\n        if (e.key === \"Enter\") {\n          const node = tree.focusedNode;\n          if (!node) return;\n          if (!node.isEditable || !tree.props.onRename) return;\n          setTimeout(() => {\n            if (node) tree.edit(node);\n          });\n          return;\n        }\n        if (e.key === \" \") {\n          e.preventDefault();\n          const node = tree.focusedNode;\n          if (!node) return;\n          if (node.isLeaf) {\n            node.select();\n            node.activate();\n          } else {\n            node.toggle();\n          }\n          return;\n        }\n        if (e.key === \"*\") {\n          const node = tree.focusedNode;\n          if (!node) return;\n          tree.openSiblings(node);\n          return;\n        }\n        if (e.key === \"PageUp\") {\n          e.preventDefault();\n          tree.pageUp();\n          return;\n        }\n        if (e.key === \"PageDown\") {\n          e.preventDefault();\n          tree.pageDown();\n        }\n\n        // If they type a sequence of characters\n        // collect them. Reset them after a timeout.\n        // Use it to search the tree for a node, then focus it.\n        // Clean this up a bit later\n        clearTimeout(timeoutId);\n        focusSearchTerm += e.key;\n        timeoutId = setTimeout(() => {\n          focusSearchTerm = \"\";\n        }, 600);\n        const node = tree.visibleNodes.find((n) => {\n          // @ts-ignore\n          const name = n.data.name;\n          if (typeof name === \"string\") {\n            return name.toLowerCase().startsWith(focusSearchTerm);\n          } else return false;\n        });\n        if (node) tree.focus(node.id);\n      }}\n    >\n      <FixedSizeList\n        className={tree.props.className}\n        outerRef={tree.listEl}\n        itemCount={tree.visibleNodes.length}\n        height={tree.height}\n        width={tree.width}\n        itemSize={tree.rowHeight}\n        overscanCount={tree.overscanCount}\n        itemKey={(index) => tree.visibleNodes[index]?.id || index}\n        outerElementType={ListOuterElement}\n        innerElementType={ListInnerElement}\n        onScroll={tree.props.onScroll}\n        onItemsRendered={tree.onItemsRendered.bind(tree)}\n        ref={tree.list}\n      >\n        {RowContainer}\n      </FixedSizeList>\n    </div>\n  );\n}\n","import { NodeApi } from \"../interfaces/node-api\";\nimport { TreeApi } from \"../interfaces/tree-api\";\nimport { IdObj } from \"../types/utils\";\n\nexport function createList<T>(tree: TreeApi<T>) {\n  if (tree.isFiltered) {\n    return flattenAndFilterTree(tree.root, tree.isMatch.bind(tree));\n  } else {\n    return flattenTree(tree.root);\n  }\n}\n\nfunction flattenTree<T>(root: NodeApi<T>): NodeApi<T>[] {\n  const list: NodeApi<T>[] = [];\n  function collect(node: NodeApi<T>) {\n    if (node.level >= 0) {\n      list.push(node);\n    }\n    if (node.isOpen) {\n      node.children?.forEach(collect);\n    }\n  }\n  collect(root);\n  list.forEach(assignRowIndex);\n  return list;\n}\n\nfunction flattenAndFilterTree<T>(\n  root: NodeApi<T>,\n  isMatch: (n: NodeApi<T>) => boolean\n): NodeApi<T>[] {\n  const matches: Record<string, boolean> = {};\n  const list: NodeApi<T>[] = [];\n\n  function markMatch(node: NodeApi<T>) {\n    const yes = !node.isRoot && isMatch(node);\n    if (yes) {\n      matches[node.id] = true;\n      let parent = node.parent;\n      while (parent) {\n        matches[parent.id] = true;\n        parent = parent.parent;\n      }\n    }\n    if (node.children) {\n      for (let child of node.children) markMatch(child);\n    }\n  }\n\n  function collect(node: NodeApi<T>) {\n    if (node.level >= 0 && matches[node.id]) {\n      list.push(node);\n    }\n    if (node.isOpen) {\n      node.children?.forEach(collect);\n    }\n  }\n\n  markMatch(root);\n  collect(root);\n  list.forEach(assignRowIndex);\n  return list;\n}\n\nfunction assignRowIndex(node: NodeApi<any>, index: number) {\n  node.rowIndex = index;\n}\n","import { NodeApi } from \"../interfaces/node-api\";\nimport { IdObj } from \"../types/utils\";\n\nexport const createIndex = <T>(nodes: NodeApi<T>[]) => {\n  return nodes.reduce<{ [id: string]: number }>((map, node, index) => {\n    map[node.id] = index;\n    return map;\n  }, {});\n};\n","import { EditResult } from \"../types/handlers\";\nimport { Identity, IdObj } from \"../types/utils\";\nimport { TreeProps } from \"../types/tree-props\";\nimport { MutableRefObject } from \"react\";\nimport { Align, FixedSizeList, ListOnItemsRenderedProps } from \"react-window\";\nimport * as utils from \"../utils\";\nimport { DefaultCursor } from \"../components/default-cursor\";\nimport { DefaultRow } from \"../components/default-row\";\nimport { DefaultNode } from \"../components/default-node\";\nimport { NodeApi } from \"./node-api\";\nimport { edit } from \"../state/edit-slice\";\nimport { Actions, RootState } from \"../state/root-reducer\";\nimport { focus, treeBlur } from \"../state/focus-slice\";\nimport { createRoot, ROOT_ID } from \"../data/create-root\";\nimport { actions as visibility } from \"../state/open-slice\";\nimport { actions as selection } from \"../state/selection-slice\";\nimport { actions as dnd } from \"../state/dnd-slice\";\nimport { DefaultDragPreview } from \"../components/default-drag-preview\";\nimport { DefaultContainer } from \"../components/default-container\";\nimport { Cursor } from \"../dnd/compute-drop\";\nimport { Store } from \"redux\";\nimport { createList } from \"../data/create-list\";\nimport { createIndex } from \"../data/create-index\";\n\nconst { safeRun, identify, identifyNull } = utils;\nexport class TreeApi<T> {\n  static editPromise: null | ((args: EditResult) => void);\n  root: NodeApi<T>;\n  visibleNodes: NodeApi<T>[];\n  visibleStartIndex: number = 0;\n  visibleStopIndex: number = 0;\n  idToIndex: { [id: string]: number };\n\n  constructor(\n    public store: Store<RootState, Actions>,\n    public props: TreeProps<T>,\n    public list: MutableRefObject<FixedSizeList | null>,\n    public listEl: MutableRefObject<HTMLDivElement | null>\n  ) {\n    /* Changes here must also be made in update() */\n    this.root = createRoot<T>(this);\n    this.visibleNodes = createList<T>(this);\n    this.idToIndex = createIndex(this.visibleNodes);\n  }\n\n  /* Changes here must also be made in constructor() */\n  update(props: TreeProps<T>) {\n    this.props = props;\n    this.root = createRoot<T>(this);\n    this.visibleNodes = createList<T>(this);\n    this.idToIndex = createIndex(this.visibleNodes);\n  }\n\n  /* Store helpers */\n\n  dispatch(action: Actions) {\n    return this.store.dispatch(action);\n  }\n\n  get state() {\n    return this.store.getState();\n  }\n\n  get openState() {\n    return this.state.nodes.open.unfiltered;\n  }\n\n  /* Tree Props */\n\n  get width() {\n    return this.props.width ?? 300;\n  }\n\n  get height() {\n    return this.props.height ?? 500;\n  }\n\n  get indent() {\n    return this.props.indent ?? 24;\n  }\n\n  get rowHeight() {\n    return this.props.rowHeight ?? 24;\n  }\n\n  get overscanCount() {\n    return this.props.overscanCount ?? 1;\n  }\n\n  get searchTerm() {\n    return (this.props.searchTerm || \"\").trim();\n  }\n\n  get matchFn() {\n    const match =\n      this.props.searchMatch ??\n      ((node, term) => {\n        const string = JSON.stringify(\n          Object.values(node.data as { [k: string]: unknown })\n        );\n        return string.toLocaleLowerCase().includes(term.toLocaleLowerCase());\n      });\n    return (node: NodeApi<T>) => match(node, this.searchTerm);\n  }\n\n  accessChildren(data: T) {\n    const get = this.props.childrenAccessor || \"children\";\n    return utils.access<T[] | undefined>(data, get) ?? null;\n  }\n\n  accessId(data: T) {\n    const get = this.props.idAccessor || \"id\";\n    const id = utils.access<string>(data, get);\n    if (!id)\n      throw new Error(\n        \"Data must contain an 'id' property or props.idAccessor must return a string\"\n      );\n    return id;\n  }\n\n  /* Node Access */\n\n  get firstNode() {\n    return this.visibleNodes[0] ?? null;\n  }\n\n  get lastNode() {\n    return this.visibleNodes[this.visibleNodes.length - 1] ?? null;\n  }\n\n  get focusedNode() {\n    return this.get(this.state.nodes.focus.id) ?? null;\n  }\n\n  get mostRecentNode() {\n    return this.get(this.state.nodes.selection.mostRecent) ?? null;\n  }\n\n  get nextNode() {\n    const index = this.indexOf(this.focusedNode);\n    if (index === null) return null;\n    else return this.at(index + 1);\n  }\n\n  get prevNode() {\n    const index = this.indexOf(this.focusedNode);\n    if (index === null) return null;\n    else return this.at(index - 1);\n  }\n\n  get(id: string | null): NodeApi<T> | null {\n    if (!id) return null;\n    if (id in this.idToIndex)\n      return this.visibleNodes[this.idToIndex[id]] || null;\n    else return null;\n  }\n\n  at(index: number): NodeApi<T> | null {\n    return this.visibleNodes[index] || null;\n  }\n\n  nodesBetween(startId: string | null, endId: string | null) {\n    if (startId === null || endId === null) return [];\n    const index1 = this.indexOf(startId) ?? 0;\n    const index2 = this.indexOf(endId);\n    if (index2 === null) return [];\n    const start = Math.min(index1, index2);\n    const end = Math.max(index1, index2);\n    return this.visibleNodes.slice(start, end + 1);\n  }\n\n  indexOf(id: string | null | IdObj) {\n    const key = utils.identifyNull(id);\n    if (!key) return null;\n    return this.idToIndex[key];\n  }\n\n  /* Data Operations */\n\n  get editingId() {\n    return this.state.nodes.edit.id;\n  }\n\n  createInternal() {\n    return this.create({ type: \"internal\" });\n  }\n\n  createLeaf() {\n    return this.create({ type: \"leaf\" });\n  }\n\n  async create(\n    opts: {\n      type?: \"internal\" | \"leaf\";\n      parentId?: null | string;\n      index?: null | number;\n    } = {}\n  ) {\n    const parentId =\n      opts.parentId === undefined\n        ? utils.getInsertParentId(this)\n        : opts.parentId;\n    const index = opts.index ?? utils.getInsertIndex(this);\n    const type = opts.type ?? \"leaf\";\n    const data = await safeRun(this.props.onCreate, {\n      type,\n      parentId,\n      index,\n      parentNode: this.get(parentId),\n    });\n    if (data) {\n      this.focus(data);\n      setTimeout(() => {\n        this.edit(data).then(() => {\n          this.select(data);\n          this.activate(data);\n        });\n      });\n    }\n  }\n\n  async delete(node: string | IdObj | null | string[] | IdObj[]) {\n    if (!node) return;\n    const idents = Array.isArray(node) ? node : [node];\n    const ids = idents.map(identify);\n    const nodes = ids.map((id) => this.get(id)!).filter((n) => !!n);\n    await safeRun(this.props.onDelete, { nodes, ids });\n  }\n\n  edit(node: string | IdObj): Promise<EditResult> {\n    const id = identify(node);\n    this.resolveEdit({ cancelled: true });\n    this.scrollTo(id);\n    this.dispatch(edit(id));\n    return new Promise((resolve) => {\n      TreeApi.editPromise = resolve;\n    });\n  }\n\n  async submit(identity: Identity, value: string) {\n    if (!identity) return;\n    const id = identify(identity);\n    await safeRun(this.props.onRename, {\n      id,\n      name: value,\n      node: this.get(id)!,\n    });\n    this.dispatch(edit(null));\n    this.resolveEdit({ cancelled: false, value });\n    setTimeout(() => this.onFocus()); // Return focus to element;\n  }\n\n  reset() {\n    this.dispatch(edit(null));\n    this.resolveEdit({ cancelled: true });\n    setTimeout(() => this.onFocus()); // Return focus to element;\n  }\n\n  activate(id: string | IdObj | null) {\n    const node = this.get(identifyNull(id));\n    if (!node) return;\n    safeRun(this.props.onActivate, node);\n  }\n\n  private resolveEdit(value: EditResult) {\n    const resolve = TreeApi.editPromise;\n    if (resolve) resolve(value);\n    TreeApi.editPromise = null;\n  }\n\n  /* Focus and Selection */\n\n  get selectedIds() {\n    return this.state.nodes.selection.ids;\n  }\n\n  get selectedNodes() {\n    let nodes = [];\n    for (let id of Array.from(this.selectedIds)) {\n      const node = this.get(id);\n      if (node) nodes.push(node);\n    }\n    return nodes;\n  }\n\n  focus(node: Identity, opts: { scroll?: boolean } = {}) {\n    if (!node) return;\n    /* Focus is responsible for scrolling, while selection is\n     * responsible for focus. If selectionFollowsFocus, then\n     * just select it. */\n    if (this.props.selectionFollowsFocus) {\n      this.select(node);\n    } else {\n      this.dispatch(focus(identify(node)));\n      if (opts.scroll !== false) this.scrollTo(node);\n      if (this.focusedNode) safeRun(this.props.onFocus, this.focusedNode);\n    }\n  }\n\n  pageUp() {\n    const start = this.visibleStartIndex;\n    const stop = this.visibleStopIndex;\n    const page = stop - start;\n    let index = this.focusedNode?.rowIndex ?? 0;\n    if (index > start) {\n      index = start;\n    } else {\n      index = Math.max(start - page, 0);\n    }\n    this.focus(this.at(index));\n  }\n\n  pageDown() {\n    const start = this.visibleStartIndex;\n    const stop = this.visibleStopIndex;\n    const page = stop - start;\n    let index = this.focusedNode?.rowIndex ?? 0;\n    if (index < stop) {\n      index = stop;\n    } else {\n      index = Math.min(index + page, this.visibleNodes.length - 1);\n    }\n    this.focus(this.at(index));\n  }\n\n  select(node: Identity, opts: { align?: Align; focus?: boolean } = {}) {\n    if (!node) return;\n    const changeFocus = opts.focus !== false;\n    const id = identify(node);\n    if (changeFocus) this.dispatch(focus(id));\n    this.dispatch(selection.only(id));\n    this.dispatch(selection.anchor(id));\n    this.dispatch(selection.mostRecent(id));\n    this.scrollTo(id, opts.align);\n    if (this.focusedNode && changeFocus) {\n      safeRun(this.props.onFocus, this.focusedNode);\n    }\n    safeRun(this.props.onSelect, this.selectedNodes);\n  }\n\n  deselect(node: Identity) {\n    if (!node) return;\n    const id = identify(node);\n    this.dispatch(selection.remove(id));\n  }\n\n  selectMulti(node: Identity) {\n    if (!node) return;\n    const id = identify(node);\n    this.dispatch(focus(id));\n    this.dispatch(selection.add(id));\n    this.dispatch(selection.anchor(id));\n    this.dispatch(selection.mostRecent(id));\n    // this.scrollTo(node);\n    if (this.focusedNode) safeRun(this.props.onFocus, this.focusedNode);\n    safeRun(this.props.onSelect, this.selectedNodes);\n  }\n\n  selectContiguous(identity: Identity) {\n    if (!identity) return;\n    const id = identify(identity);\n    const { anchor, mostRecent } = this.state.nodes.selection;\n    this.dispatch(focus(id));\n    this.dispatch(selection.remove(this.nodesBetween(anchor, mostRecent)));\n    this.dispatch(selection.add(this.nodesBetween(anchor, identifyNull(id))));\n    this.dispatch(selection.mostRecent(id));\n    this.scrollTo(id);\n    if (this.focusedNode) safeRun(this.props.onFocus, this.focusedNode);\n    safeRun(this.props.onSelect, this.selectedNodes);\n  }\n\n  deselectAll() {\n    this.dispatch(selection.clear());\n    this.dispatch(selection.anchor(null));\n    this.dispatch(selection.mostRecent(null));\n    safeRun(this.props.onSelect, this.selectedNodes);\n  }\n\n  selectAll() {\n    this.dispatch(selection.set(new Set(Object.keys(this.idToIndex))));\n    this.dispatch(focus(this.lastNode?.id));\n    this.dispatch(selection.anchor(this.firstNode));\n    this.dispatch(selection.mostRecent(this.lastNode));\n    if (this.focusedNode) safeRun(this.props.onFocus, this.focusedNode);\n    safeRun(this.props.onSelect, this.selectedNodes);\n  }\n\n  /* Drag and Drop */\n\n  get cursorParentId() {\n    const { cursor } = this.state.dnd;\n    switch (cursor.type) {\n      case \"highlight\":\n        return cursor.id;\n      default:\n        return null;\n    }\n  }\n\n  get cursorOverFolder() {\n    return this.state.dnd.cursor.type === \"highlight\";\n  }\n\n  get dragNodes() {\n    return this.state.dnd.dragIds\n      .map((id) => this.get(id))\n      .filter((n) => !!n) as NodeApi<T>[];\n  }\n\n  canDrop() {\n    if (this.isFiltered) return false;\n    const parentNode = this.get(this.state.dnd.parentId) ?? this.root;\n    const dragNodes = this.dragNodes;\n    const isDisabled = this.props.disableDrop;\n\n    for (const drag of dragNodes) {\n      if (!drag) return false;\n      if (!parentNode) return false;\n      if (drag.isInternal && utils.isDecendent(parentNode, drag)) return false;\n    }\n\n    // Allow the user to insert their own logic\n    if (typeof isDisabled == \"function\") {\n      return !isDisabled({\n        parentNode,\n        dragNodes: this.dragNodes,\n        index: this.state.dnd.index,\n      });\n    } else if (typeof isDisabled == \"string\") {\n      // @ts-ignore\n      return !parentNode.data[isDisabled];\n    } else if (typeof isDisabled === \"boolean\") {\n      return !isDisabled;\n    } else {\n      return true;\n    }\n  }\n\n  hideCursor() {\n    this.dispatch(dnd.cursor({ type: \"none\" }));\n  }\n\n  showCursor(cursor: Cursor) {\n    this.dispatch(dnd.cursor(cursor));\n  }\n\n  /* Visibility */\n\n  open(identity: Identity) {\n    const id = identifyNull(identity);\n    if (!id) return;\n    if (this.isOpen(id)) return;\n    this.dispatch(visibility.open(id, this.isFiltered));\n    safeRun(this.props.onToggle, id);\n  }\n\n  close(identity: Identity) {\n    const id = identifyNull(identity);\n    if (!id) return;\n    if (!this.isOpen(id)) return;\n    this.dispatch(visibility.close(id, this.isFiltered));\n    safeRun(this.props.onToggle, id);\n  }\n\n  toggle(identity: Identity) {\n    const id = identifyNull(identity);\n    if (!id) return;\n    return this.isOpen(id) ? this.close(id) : this.open(id);\n  }\n\n  openParents(identity: Identity) {\n    const id = identifyNull(identity);\n    if (!id) return;\n    const node = utils.dfs(this.root, id);\n    let parent = node?.parent;\n\n    while (parent) {\n      this.open(parent.id);\n      parent = parent.parent;\n    }\n  }\n\n  openSiblings(node: NodeApi<T>) {\n    const parent = node.parent;\n    if (!parent) {\n      this.toggle(node.id);\n    } else if (parent.children) {\n      const isOpen = node.isOpen;\n      for (let sibling of parent.children) {\n        if (sibling.isInternal) {\n          isOpen ? this.close(sibling.id) : this.open(sibling.id);\n        }\n      }\n      this.scrollTo(this.focusedNode);\n    }\n  }\n\n  openAll() {\n    utils.walk(this.root, (node) => {\n      if (node.isInternal) node.open();\n    });\n  }\n\n  closeAll() {\n    utils.walk(this.root, (node) => {\n      if (node.isInternal) node.close();\n    });\n  }\n\n  /* Scrolling */\n\n  scrollTo(identity: Identity, align: Align = \"smart\") {\n    if (!identity) return;\n    const id = identify(identity);\n    this.openParents(id);\n    return utils\n      .waitFor(() => id in this.idToIndex)\n      .then(() => {\n        const index = this.idToIndex[id];\n        if (index === undefined) return;\n        this.list.current?.scrollToItem(index, align);\n      })\n      .catch(() => {\n        // Id: ${id} never appeared in the list.\n      });\n  }\n\n  /* State Checks */\n\n  get isEditing() {\n    return this.state.nodes.edit.id !== null;\n  }\n\n  get isFiltered() {\n    return !!this.props.searchTerm?.trim();\n  }\n\n  get hasFocus() {\n    return this.state.nodes.focus.treeFocused;\n  }\n\n  get hasNoSelection() {\n    return this.state.nodes.selection.ids.size === 0;\n  }\n\n  get hasOneSelection() {\n    return this.state.nodes.selection.ids.size === 1;\n  }\n\n  get hasMultipleSelections() {\n    return this.state.nodes.selection.ids.size > 1;\n  }\n\n  isSelected(id?: string) {\n    if (!id) return false;\n    return this.state.nodes.selection.ids.has(id);\n  }\n\n  isOpen(id?: string) {\n    if (!id) return false;\n    if (id === ROOT_ID) return true;\n    const def = this.props.openByDefault ?? true;\n    if (this.isFiltered) {\n      return this.state.nodes.open.filtered[id] ?? true; // Filtered folders are always opened by default\n    } else {\n      return this.state.nodes.open.unfiltered[id] ?? def;\n    }\n  }\n\n  isEditable(data: T) {\n    const check = this.props.disableEdit || (() => false);\n    return !utils.access(data, check) ?? true;\n  }\n\n  isDraggable(data: T) {\n    const check = this.props.disableDrag || (() => false);\n    return !utils.access(data, check) ?? true;\n  }\n\n  isDragging(node: string | IdObj | null) {\n    const id = identifyNull(node);\n    if (!id) return false;\n    return this.state.nodes.drag.id === id;\n  }\n\n  isFocused(id: string) {\n    return this.hasFocus && this.state.nodes.focus.id === id;\n  }\n\n  isMatch(node: NodeApi<T>) {\n    return this.matchFn(node);\n  }\n\n  willReceiveDrop(node: string | IdObj | null) {\n    const id = identifyNull(node);\n    if (!id) return false;\n    return id === this.state.nodes.drag.idWillReceiveDrop;\n  }\n\n  /* Tree Event Handlers */\n\n  onFocus() {\n    const node = this.focusedNode || this.firstNode;\n    if (node) this.dispatch(focus(node.id));\n  }\n\n  onBlur() {\n    this.dispatch(treeBlur());\n  }\n\n  onItemsRendered(args: ListOnItemsRenderedProps) {\n    this.visibleStartIndex = args.visibleStartIndex;\n    this.visibleStopIndex = args.visibleStopIndex;\n  }\n\n  /* Get Renderers */\n\n  get renderContainer() {\n    return this.props.renderContainer || DefaultContainer;\n  }\n\n  get renderRow() {\n    return this.props.renderRow || DefaultRow;\n  }\n\n  get renderNode() {\n    return this.props.children || DefaultNode;\n  }\n\n  get renderDragPreview() {\n    return this.props.renderDragPreview || DefaultDragPreview;\n  }\n\n  get renderCursor() {\n    return this.props.renderCursor || DefaultCursor;\n  }\n}\n","import { ActionTypes } from \"../types/utils\";\nimport { actions as dnd } from \"./dnd-slice\";\n\n/* Types */\n\nexport type DragSlice = { id: string | null; idWillReceiveDrop: string | null };\n\n/* Reducer */\n\nexport function reducer(\n  state: DragSlice = { id: null, idWillReceiveDrop: null },\n  action: ActionTypes<typeof dnd>\n) {\n  switch (action.type) {\n    case \"DND_DRAG_START\":\n      return { ...state, id: action.id };\n    case \"DND_DRAG_END\":\n      return { ...state, id: null };\n    case \"DND_CURSOR\":\n      const c = action.cursor;\n      if (c.type === \"highlight\" && c.id !== state.idWillReceiveDrop) {\n        return { ...state, idWillReceiveDrop: c.id };\n      } else if (c.type !== \"highlight\" && state.idWillReceiveDrop !== null) {\n        return { ...state, idWillReceiveDrop: null };\n      } else {\n        return state;\n      }\n    default:\n      return state;\n  }\n}\n","import { ActionFromReducer, combineReducers } from \"redux\";\nimport { reducer as focus } from \"./focus-slice\";\nimport { reducer as edit } from \"./edit-slice\";\nimport { reducer as dnd } from \"./dnd-slice\";\nimport { reducer as selection } from \"./selection-slice\";\nimport { reducer as open } from \"./open-slice\";\nimport { reducer as drag } from \"./drag-slice\";\n\nexport const rootReducer = combineReducers({\n  nodes: combineReducers({\n    focus,\n    edit,\n    open,\n    selection,\n    drag,\n  }),\n  dnd,\n});\n\nexport type RootState = ReturnType<typeof rootReducer>;\nexport type Actions = ActionFromReducer<typeof rootReducer>;\n","import {\n  ReactNode,\n  useEffect,\n  useImperativeHandle,\n  useMemo,\n  useRef,\n} from \"react\";\nimport { useSyncExternalStore } from \"use-sync-external-store/shim\";\nimport { FixedSizeList } from \"react-window\";\nimport {\n  DataUpdatesContext,\n  DndContext,\n  NodesContext,\n  TreeApiContext,\n} from \"../context\";\nimport { TreeApi } from \"../interfaces/tree-api\";\nimport { IdObj } from \"../types/utils\";\nimport { initialState } from \"../state/initial\";\nimport { rootReducer, RootState } from \"../state/root-reducer\";\nimport { HTML5Backend } from \"react-dnd-html5-backend\";\nimport { DndProvider } from \"react-dnd\";\nimport { TreeProps } from \"../types/tree-props\";\nimport { createStore, Store } from \"redux\";\nimport { actions as visibility } from \"../state/open-slice\";\n\ntype Props<T> = {\n  treeProps: TreeProps<T>;\n  imperativeHandle: React.Ref<TreeApi<T> | undefined>;\n  children: ReactNode;\n};\n\nconst SERVER_STATE = initialState();\n\nexport function TreeProvider<T>({\n  treeProps,\n  imperativeHandle,\n  children,\n}: Props<T>) {\n  const list = useRef<FixedSizeList | null>(null);\n  const listEl = useRef<HTMLDivElement | null>(null);\n  const store = useRef<Store>(\n    createStore(rootReducer, initialState(treeProps))\n  );\n  const state = useSyncExternalStore<RootState>(\n    store.current.subscribe,\n    store.current.getState,\n    () => SERVER_STATE\n  );\n\n  /* The tree api object is stable. */\n  const api = useMemo(() => {\n    return new TreeApi<T>(store.current, treeProps, list, listEl);\n  }, []);\n\n  /* Make sure the tree instance stays in sync */\n  const updateCount = useRef(0);\n  useMemo(() => {\n    updateCount.current += 1;\n    api.update(treeProps);\n  }, [...Object.values(treeProps), state.nodes.open]);\n\n  /* Expose the tree api */\n  useImperativeHandle(imperativeHandle, () => api);\n\n  /* Change selection based on props */\n  useEffect(() => {\n    if (api.props.selection) {\n      api.select(api.props.selection, { focus: false });\n    } else {\n      api.deselectAll();\n    }\n  }, [api.props.selection]);\n\n  /* Clear visability for filtered nodes */\n  useEffect(() => {\n    if (!api.props.searchTerm) {\n      store.current.dispatch(visibility.clear(true));\n    }\n  }, [api.props.searchTerm]);\n\n  return (\n    <TreeApiContext.Provider value={api}>\n      <DataUpdatesContext.Provider value={updateCount.current}>\n        <NodesContext.Provider value={state.nodes}>\n          <DndContext.Provider value={state.dnd}>\n            <DndProvider\n              backend={HTML5Backend}\n              options={{ rootElement: api.props.dndRootElement || undefined }}\n            >\n              {children}\n            </DndProvider>\n          </DndContext.Provider>\n        </NodesContext.Provider>\n      </DataUpdatesContext.Provider>\n    </TreeApiContext.Provider>\n  );\n}\n","import { useDrop } from \"react-dnd\";\nimport { useTreeApi } from \"../context\";\nimport { DragItem } from \"../types/dnd\";\nimport { computeDrop } from \"./compute-drop\";\nimport { DropResult } from \"./drop-hook\";\nimport { actions as dnd } from \"../state/dnd-slice\";\n\nexport function useOuterDrop() {\n  const tree = useTreeApi();\n\n  // In case we drop an item at the bottom of the list\n  const [, drop] = useDrop<DragItem, DropResult | null, { isOver: boolean }>(\n    () => ({\n      accept: \"NODE\",\n      canDrop: (_item, m) => {\n        if (!m.isOver({ shallow: true })) return false;\n        return tree.canDrop();\n      },\n      hover: (_item, m) => {\n        if (!m.isOver({ shallow: true })) return;\n        const offset = m.getClientOffset();\n        if (!tree.listEl.current || !offset) return;\n        const { cursor, drop } = computeDrop({\n          element: tree.listEl.current,\n          offset: offset,\n          indent: tree.indent,\n          node: null,\n          prevNode: tree.visibleNodes[tree.visibleNodes.length - 1],\n          nextNode: null,\n        });\n        if (drop) tree.dispatch(dnd.hovering(drop.parentId, drop.index));\n\n        if (m.canDrop()) {\n          if (cursor) tree.showCursor(cursor);\n        } else {\n          tree.hideCursor();\n        }\n      },\n    }),\n    [tree]\n  );\n\n  drop(tree.listEl);\n}\n","import { ReactElement } from \"react\";\nimport { useOuterDrop } from \"../dnd/outer-drop-hook\";\n\nexport function OuterDrop(props: { children: ReactElement }) {\n  useOuterDrop();\n  return props.children;\n}\n","import React from \"react\";\nimport { useTreeApi } from \"../context\";\nimport { DefaultContainer } from \"./default-container\";\n\nexport function TreeContainer() {\n  const tree = useTreeApi();\n  const Container = tree.props.renderContainer || DefaultContainer;\n  return (\n    <>\n      <Container />\n    </>\n  );\n}\n","import { useDragLayer } from \"react-dnd\";\nimport { useDndContext, useTreeApi } from \"../context\";\nimport { DefaultDragPreview } from \"./default-drag-preview\";\n\nexport function DragPreviewContainer() {\n  const tree = useTreeApi();\n  const { offset, mouse, item, isDragging } = useDragLayer((m) => {\n    return {\n      offset: m.getSourceClientOffset(),\n      mouse: m.getClientOffset(),\n      item: m.getItem(),\n      isDragging: m.isDragging(),\n    };\n  });\n\n  const DragPreview = tree.props.renderDragPreview || DefaultDragPreview;\n  return (\n    <DragPreview\n      offset={offset}\n      mouse={mouse}\n      id={item?.id || null}\n      dragIds={item?.dragIds || []}\n      isDragging={isDragging}\n    />\n  );\n}\n","type SimpleData = { id: string; name: string; children?: SimpleData[] };\n\nexport class SimpleTree<T extends SimpleData> {\n  root: SimpleNode<T>;\n  constructor(data: T[]) {\n    this.root = createRoot<T>(data);\n  }\n\n  get data() {\n    return this.root.children?.map((node) => node.data) ?? [];\n  }\n\n  create(args: { parentId: string | null; index: number; data: T }) {\n    const parent = args.parentId ? this.find(args.parentId) : this.root;\n    if (!parent) return null;\n    parent.addChild(args.data, args.index);\n  }\n\n  move(args: { id: string; parentId: string | null; index: number }) {\n    const src = this.find(args.id);\n    const parent = args.parentId ? this.find(args.parentId) : this.root;\n    if (!src || !parent) return;\n    parent.addChild(src.data, args.index);\n    src.drop();\n  }\n\n  update(args: { id: string; changes: Partial<T> }) {\n    const node = this.find(args.id);\n    if (node) node.update(args.changes);\n  }\n\n  drop(args: { id: string }) {\n    const node = this.find(args.id);\n    if (node) node.drop();\n  }\n\n  find(id: string, node: SimpleNode<T> = this.root): SimpleNode<T> | null {\n    if (!node) return null;\n    if (node.id === id) return node as SimpleNode<T>;\n    if (node.children) {\n      for (let child of node.children) {\n        const found = this.find(id, child);\n        if (found) return found;\n      }\n      return null;\n    }\n    return null;\n  }\n}\n\nfunction createRoot<T extends SimpleData>(data: T[]) {\n  const root = new SimpleNode<T>({ id: \"ROOT\" } as T, null);\n  root.children = data.map((d) => createNode(d as T, root));\n  return root;\n}\n\nfunction createNode<T extends SimpleData>(data: T, parent: SimpleNode<T>) {\n  const node = new SimpleNode<T>(data, parent);\n  if (data.children)\n    node.children = data.children.map((d) => createNode<T>(d as T, node));\n  return node;\n}\n\nclass SimpleNode<T extends SimpleData> {\n  id: string;\n  children?: SimpleNode<T>[];\n  constructor(public data: T, public parent: SimpleNode<T> | null) {\n    this.id = data.id;\n  }\n\n  hasParent(): this is this & { parent: SimpleNode<T> } {\n    return !!this.parent;\n  }\n\n  get childIndex(): number {\n    return this.hasParent() ? this.parent.children!.indexOf(this) : -1;\n  }\n\n  addChild(data: T, index: number) {\n    const node = createNode(data, this);\n    this.children = this.children ?? [];\n    this.children.splice(index, 0, node);\n    this.data.children = this.data.children ?? [];\n    this.data.children.splice(index, 0, data);\n  }\n\n  removeChild(index: number) {\n    this.children?.splice(index, 1);\n    this.data.children?.splice(index, 1);\n  }\n\n  update(changes: Partial<T>) {\n    if (this.hasParent()) {\n      const i = this.childIndex;\n      this.parent.addChild({ ...this.data, ...changes }, i);\n      this.drop();\n    }\n  }\n\n  drop() {\n    if (this.hasParent()) this.parent.removeChild(this.childIndex);\n  }\n}\n","import { useMemo, useState } from \"react\";\nimport { SimpleTree } from \"../data/simple-tree\";\nimport {\n  CreateHandler,\n  DeleteHandler,\n  MoveHandler,\n  RenameHandler,\n} from \"../types/handlers\";\nimport { IdObj } from \"../types/utils\";\n\nexport type SimpleTreeData = {\n  id: string;\n  name: string;\n  children?: SimpleTreeData[];\n};\n\nlet nextId = 0;\n\nexport function useSimpleTree<T>(initialData: readonly T[]) {\n  const [data, setData] = useState(initialData);\n  const tree = useMemo(\n    () =>\n      new SimpleTree<// @ts-ignore\n      T>(data),\n    [data]\n  );\n\n  const onMove: MoveHandler<T> = (args: {\n    dragIds: string[];\n    parentId: null | string;\n    index: number;\n  }) => {\n    for (const id of args.dragIds) {\n      tree.move({ id, parentId: args.parentId, index: args.index });\n    }\n    setData(tree.data);\n  };\n\n  const onRename: RenameHandler<T> = ({ name, id }) => {\n    tree.update({ id, changes: { name } as any });\n    setData(tree.data);\n  };\n\n  const onCreate: CreateHandler<T> = ({ parentId, index, type }) => {\n    const data = { id: `simple-tree-id-${nextId++}`, name: \"\" } as any;\n    if (type === \"internal\") data.children = [];\n    tree.create({ parentId, index, data });\n    setData(tree.data);\n    return data;\n  };\n\n  const onDelete: DeleteHandler<T> = (args: { ids: string[] }) => {\n    args.ids.forEach((id) => tree.drop({ id }));\n    setData(tree.data);\n  };\n\n  const controller = { onMove, onRename, onCreate, onDelete };\n\n  return [data, controller] as const;\n}\n","import { TreeProps } from \"../types/tree-props\";\nimport { IdObj } from \"../types/utils\";\nimport { SimpleTreeData, useSimpleTree } from \"./use-simple-tree\";\n\nexport function useValidatedProps<T>(props: TreeProps<T>): TreeProps<T> {\n  if (props.initialData && props.data) {\n    throw new Error(\n      `React Arborist Tree => Provide either a data or initialData prop, but not both.`\n    );\n  }\n  if (\n    props.initialData &&\n    (props.onCreate || props.onDelete || props.onMove || props.onRename)\n  ) {\n    throw new Error(\n      `React Arborist Tree => You passed the initialData prop along with a data handler.\nUse the data prop if you want to provide your own handlers.`\n    );\n  }\n  if (props.initialData) {\n    /**\n     * Let's break the rules of hooks here. If the initialData prop\n     * is provided, we will assume it will not change for the life of\n     * the component.\n     *\n     * We will provide the real data and the handlers to update it.\n     *   */\n    const [data, controller] = useSimpleTree<T>(props.initialData);\n    return { ...props, ...controller, data };\n  } else {\n    return props;\n  }\n}\n","import { forwardRef } from \"react\";\nimport { TreeProvider } from \"./provider\";\nimport { TreeApi } from \"../interfaces/tree-api\";\nimport { OuterDrop } from \"./outer-drop\";\nimport { TreeContainer } from \"./tree-container\";\nimport { DragPreviewContainer } from \"./drag-preview-container\";\nimport { TreeProps } from \"../types/tree-props\";\nimport { IdObj } from \"../types/utils\";\nimport { useValidatedProps } from \"../hooks/use-validated-props\";\n\nfunction TreeComponent<T>(\n  props: TreeProps<T>,\n  ref: React.Ref<TreeApi<T> | undefined>\n) {\n  const treeProps = useValidatedProps(props);\n  return (\n    <TreeProvider treeProps={treeProps} imperativeHandle={ref}>\n      <OuterDrop>\n        <TreeContainer />\n      </OuterDrop>\n      <DragPreviewContainer />\n    </TreeProvider>\n  );\n}\n\nexport const Tree = forwardRef(TreeComponent) as <T>(\n  props: TreeProps<T> & { ref?: React.ForwardedRef<TreeApi<T> | undefined> }\n) => ReturnType<typeof TreeComponent>;\n"]}