@macrostrat/feedback-components 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/esm/{feedback-components.95dbe7d7.js → feedback-components.00434ff7.js} +10 -1
  3. package/dist/esm/feedback-components.00434ff7.js.map +1 -0
  4. package/dist/esm/{feedback-components.46a7a347.js → feedback-components.1c15f37f.js} +101 -12
  5. package/dist/esm/feedback-components.1c15f37f.js.map +1 -0
  6. package/dist/esm/{feedback-components.586103e8.js → feedback-components.204f7d2b.js} +27 -276
  7. package/dist/esm/feedback-components.204f7d2b.js.map +1 -0
  8. package/dist/esm/{feedback-components.3b3a5357.js → feedback-components.28ba71be.js} +19 -8
  9. package/dist/esm/feedback-components.28ba71be.js.map +1 -0
  10. package/dist/esm/{feedback-components.5df2a926.js → feedback-components.707e3490.js} +5 -7
  11. package/dist/esm/feedback-components.707e3490.js.map +1 -0
  12. package/dist/esm/feedback-components.7e879290.js +286 -0
  13. package/dist/esm/feedback-components.7e879290.js.map +1 -0
  14. package/dist/esm/{feedback-components.5509fab3.js → feedback-components.d55a1d18.js} +6 -6
  15. package/dist/esm/{feedback-components.5509fab3.js.map → feedback-components.d55a1d18.js.map} +1 -1
  16. package/dist/esm/{feedback-components.fb60c70d.css → feedback-components.d591ffec.css} +20 -1
  17. package/dist/esm/feedback-components.d591ffec.css.map +1 -0
  18. package/dist/esm/{feedback-components.fa1d3641.js → feedback-components.f6605b83.js} +49 -7
  19. package/dist/esm/feedback-components.f6605b83.js.map +1 -0
  20. package/dist/esm/feedback-components.fd8ac9ca.js +230 -0
  21. package/dist/esm/feedback-components.fd8ac9ca.js.map +1 -0
  22. package/dist/esm/index.d.ts +5 -2
  23. package/dist/esm/index.d.ts.map +1 -1
  24. package/dist/esm/index.js +2 -2
  25. package/dist/node/feedback-components.0eef8d0c.js +2 -0
  26. package/dist/node/feedback-components.0eef8d0c.js.map +1 -0
  27. package/dist/node/{feedback-components.a39f7653.js → feedback-components.2f740fc7.js} +2 -2
  28. package/dist/node/{feedback-components.a39f7653.js.map → feedback-components.2f740fc7.js.map} +1 -1
  29. package/dist/node/feedback-components.41db283a.js +2 -0
  30. package/dist/node/feedback-components.41db283a.js.map +1 -0
  31. package/dist/node/feedback-components.69d0ccd0.js +2 -0
  32. package/dist/node/feedback-components.69d0ccd0.js.map +1 -0
  33. package/dist/node/feedback-components.a7b43cfa.js +2 -0
  34. package/dist/node/feedback-components.a7b43cfa.js.map +1 -0
  35. package/dist/node/feedback-components.b22d37d1.js +2 -0
  36. package/dist/node/feedback-components.b22d37d1.js.map +1 -0
  37. package/dist/node/feedback-components.b9317f9c.js +2 -0
  38. package/dist/node/feedback-components.b9317f9c.js.map +1 -0
  39. package/dist/node/{feedback-components.c88cb37f.css → feedback-components.e096504e.css} +2 -2
  40. package/dist/node/feedback-components.e096504e.css.map +1 -0
  41. package/dist/node/feedback-components.e140ac86.js +2 -0
  42. package/dist/node/feedback-components.e140ac86.js.map +1 -0
  43. package/dist/node/feedback-components.f8373b58.js +2 -0
  44. package/dist/node/feedback-components.f8373b58.js.map +1 -0
  45. package/dist/node/index.js +1 -1
  46. package/dist/node/index.js.map +1 -1
  47. package/package.json +3 -2
  48. package/src/extractions/index.ts +7 -2
  49. package/src/extractions/types.ts +1 -0
  50. package/src/feedback/edit-state.ts +52 -3
  51. package/src/feedback/feedback.module.sass +17 -1
  52. package/src/feedback/graph.ts +17 -4
  53. package/src/feedback/index.ts +14 -309
  54. package/src/feedback/matches.ts +241 -0
  55. package/src/feedback/text-visualizer.ts +114 -4
  56. package/src/feedback/typelist.ts +312 -0
  57. package/dist/esm/feedback-components.3b3a5357.js.map +0 -1
  58. package/dist/esm/feedback-components.46a7a347.js.map +0 -1
  59. package/dist/esm/feedback-components.586103e8.js.map +0 -1
  60. package/dist/esm/feedback-components.5df2a926.js.map +0 -1
  61. package/dist/esm/feedback-components.95dbe7d7.js.map +0 -1
  62. package/dist/esm/feedback-components.fa1d3641.js.map +0 -1
  63. package/dist/esm/feedback-components.fb60c70d.css.map +0 -1
  64. package/dist/node/feedback-components.561466ac.js +0 -2
  65. package/dist/node/feedback-components.561466ac.js.map +0 -1
  66. package/dist/node/feedback-components.571ee23c.js +0 -2
  67. package/dist/node/feedback-components.571ee23c.js.map +0 -1
  68. package/dist/node/feedback-components.8b03e8be.js +0 -2
  69. package/dist/node/feedback-components.8b03e8be.js.map +0 -1
  70. package/dist/node/feedback-components.b7946db4.js +0 -2
  71. package/dist/node/feedback-components.b7946db4.js.map +0 -1
  72. package/dist/node/feedback-components.c459cc27.js +0 -2
  73. package/dist/node/feedback-components.c459cc27.js.map +0 -1
  74. package/dist/node/feedback-components.c88cb37f.css.map +0 -1
  75. package/dist/node/feedback-components.ec54a1e7.js +0 -2
  76. package/dist/node/feedback-components.ec54a1e7.js.map +0 -1
@@ -1 +0,0 @@
1
- {"mappings":";;;;;AAKO,IAAA,AAAK,mEAAA;;;WAAA;;AAiDL,SAAS,0CACd,WAAuB,EACvB,WAAoC;IAEpC,4BAA4B;IAC5B,qDAAqD;IACrD,MAAM,OAAO,YAAY,MAAM,GAAG,IAAI,GAAG,KAAK;IAE9C,OAAO,CAAA,GAAA,iBAAS,EAAE,mCAAa;qBAC7B;QACA,MAAM;QACN,eAAe,EAAE;QACjB,gBAAgB;QAChB,oBAAoB;QACpB,gBAAgB;QAChB,uBAAuB;QACvB,QAAQ;IACV;AACF;AAEO,MAAM,4CAAsB,CAAA,GAAA,oBAAY,EAAuB;AAE/D,SAAS;IACd,MAAM,WAAW,CAAA,GAAA,iBAAS,EAAE;IAC5B,IAAI,YAAY,MACd,MAAM,IAAI,MAAM;IAElB,OAAO;AACT;AAEA,SAAS,kCAAY,KAAgB,EAAE,MAAkB;IACvD,OAAQ,OAAO,IAAI;QACjB,KAAK;YAAmB;gBACtB,mCAAmC;gBACnC,MAAM,QAAE,IAAI,eAAE,WAAW,SAAE,KA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Q,GACnB,sCAAgB,KAAK,QAAQ,EAAE,SAAS,eACxC,EAAE;IACR;AACF;AAEA,SAAS,qCAAe,KAAK;IAC3B,MAAM,SAAS,EAAE;IAEjB,SAAS,SAAS,QAAQ;QACxB,KAAK,MAAM,QAAQ,SAAU;YAC3B,OAAO,IAAI,CAAC;YACZ,IAAI,MAAM,OAAO,CAAC,KAAK,QAAQ,KAAK,KAAK,QAAQ,CAAC,MAAM,GAAG,GACzD,SAAS,KAAK,QAAQ;QAE1B;IACF;IAEA,SAAS;IAET,gBAAgB;IAChB,OAAO,OAAO,IAAI,CAAC,CAAC,GAAG,IAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE;AAC1D","sources":["packages/feedback-components/src/feedback/edit-state.ts"],"sourcesContent":["import { TreeData } from \"./types\";\nimport { createContext, Dispatch, useContext, useReducer } from \"react\";\nimport update, { Spec } from \"immutability-helper\";\nimport { EntityType } from \"../extractions/types\";\n\nexport enum ViewMode {\n Tree = \"tree\",\n Graph = \"graph\",\n}\n\ninterface TreeState {\n initialTree: TreeData[];\n tree: TreeData[];\n selectedNodes: number[];\n entityTypesMap: Map<number, EntityType>;\n selectedEntityType: EntityType;\n lastInternalId: number;\n isSelectingEntityType: boolean;\n viewMode: ViewMode;\n}\n\ntype TextRange = {\n start: number;\n end: number;\n text: string;\n};\n\ntype TreeAction =\n | {\n type: \"move-node\";\n payload: { dragIds: number[]; parentId: number; index: number };\n }\n | { type: \"delete-node\"; payload: { ids: number[] } }\n | { type: \"select-node\"; payload: { ids: number[] } }\n | { type: \"toggle-node-selected\"; payload: { ids: number[] } }\n | { type: \"set-view-mode\"; payload: ViewMode }\n | { type: \"create-node\"; payload: TextRange }\n | { type: \"select-entity-type\"; payload: EntityType }\n | { type: \"toggle-entity-type-selector\"; payload?: boolean | null }\n | { type: \"deselect\" }\n | { type: \"reset\" }\n | { type: \"delete-entity-type\"; payload: { id: number } }\n | {\n type: \"add-entity-type\";\n payload: { name: string; description: string; color: string };\n }\n | {\n type: \"update-entity-type\";\n payload: { id: number; name: string; description: string; color: string };\n }\n | { type: \"select-range\"; payload: { ids: number[] } };\n\nexport type TreeDispatch = Dispatch<TreeAction>;\n\nexport function useUpdatableTree(\n initialTree: TreeData[],\n entityTypes: Map<number, EntityType>,\n): [TreeState, TreeDispatch] {\n // Get the first entity type\n // issue: grabs second entity instead of selected one\n const type = entityTypes.values().next().value;\n\n return useReducer(treeReducer, {\n initialTree,\n tree: initialTree,\n selectedNodes: [],\n entityTypesMap: entityTypes,\n selectedEntityType: type,\n lastInternalId: 0,\n isSelectingEntityType: false,\n viewMode: ViewMode.Tree,\n });\n}\n\nexport const TreeDispatchContext = createContext<TreeDispatch | null>(null);\n\nexport function useTreeDispatch() {\n const dispatch = useContext(TreeDispatchContext);\n if (dispatch == null) {\n throw new Error(\"No dispatch context available\");\n }\n return dispatch;\n}\n\nfunction treeReducer(state: TreeState, action: TreeAction) {\n switch (action.type) {\n case \"add-entity-type\": {\n // Add a new entity type to the map\n const { name, description, color } = action.payload;\n const newId = state.lastInternalId - 1;\n const newType: EntityType = {\n id: newId,\n name,\n description: description === \"\" ? null : description,\n color,\n };\n\n const newEntityTypesMap = new Map(state.entityTypesMap);\n newEntityTypesMap.set(newId, newType);\n\n return {\n ...state,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: newType,\n lastInternalId: newId,\n };\n }\n case \"update-entity-type\": {\n // Update an existing entity type in the map\n const { id, name, description, color } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n\n if (!oldType) {\n console.warn(`Entity type with id ${id} not found`);\n return state;\n }\n\n const updatedType: EntityType = {\n ...oldType,\n name,\n description: description === \"\" ? null : description,\n color,\n };\n\n newEntityTypesMap.set(id, updatedType);\n\n // Update the tree to reflect the new type\n const newTree = updateTreeTypes(state.tree, oldType, updatedType);\n\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: updatedType,\n };\n }\n case \"select-range\":\n // Select a range of nodes by their IDs\n const payloadIds = action.payload.ids;\n const node1 = payloadIds[0];\n const node2 = payloadIds[1];\n\n // make list of nodes in order\n const allNodes = flattenAndSort(state.tree);\n\n // select all nodes between node1 and node2\n const startIndex = allNodes.findIndex((node) => node.id === node1);\n const endIndex = allNodes.findIndex((node) => node.id === node2);\n\n const selectedNodes = allNodes.slice(startIndex, endIndex + 1);\n\n console.log(\"Selecting range:\", selectedNodes);\n return {\n ...state,\n selectedNodes: selectedNodes.map((node) => node.id),\n };\n\n case \"move-node\":\n // For each node in the tree, if the node is in the dragIds, remove it from the tree and collect it\n const [newTree, removedNodes] = removeNodes(\n state.tree,\n action.payload.dragIds,\n );\n\n let keyPath: (number | \"children\")[] = [];\n if (action.payload.parentId) {\n keyPath = findNode(newTree, action.payload.parentId);\n keyPath.push(\"children\");\n }\n\n // Add removed nodes to the new tree at the correct location\n let updateSpec = buildNestedSpec(keyPath, {\n $splice: [[action.payload.index, 0, ...removedNodes]],\n });\n\n return { ...state, tree: update(newTree, updateSpec) };\n case \"delete-node\":\n // For each node in the tree, if the node is in the ids, remove it from the tree\n const [newTree2, _removedNodes] = removeNodes(\n state.tree,\n action.payload.ids,\n );\n // Get children of the removed nodes\n // If children are not present elsewhere in the tree, insert them\n\n const children = _removedNodes\n .flatMap((node) => node.children ?? [])\n .filter((child) => !nodeIsInTree(newTree2, child.id));\n\n // Reset the selection\n\n return {\n ...state,\n tree: [...newTree2, ...children],\n selectedNodes: state.selectedNodes.filter(\n (id) => !action.payload.ids.includes(id),\n ),\n };\n case \"select-node\":\n const { ids } = action.payload;\n\n const type =\n action.payload.ids.length > 0\n ? findNodeById(state.tree, ids[0])?.type\n : null;\n\n return { ...state, selectedNodes: ids, selectedEntityType: type };\n // otherwise fall through to toggle-node-selected for a single ID\n case \"toggle-node-selected\":\n const nodesToAdd = action.payload.ids.filter(\n (id) => !state.selectedNodes.includes(id),\n );\n const nodesToKeep = state.selectedNodes.filter(\n (id) => !action.payload.ids.includes(id),\n );\n\n const newType =\n action.payload.ids.length > 0\n ? findNodeById(state.tree, action.payload.ids[0])?.type\n : null;\n\n return {\n ...state,\n selectedNodes: [...nodesToKeep, ...nodesToAdd],\n selectedEntityType: newType,\n };\n\n case \"create-node\":\n const newId = state.lastInternalId - 1;\n const { text, start, end } = action.payload;\n const node: TreeData = {\n id: newId,\n name: text,\n children: [],\n indices: [start, end],\n type: state.selectedEntityType,\n };\n\n return {\n ...state,\n tree: [...state.tree, node],\n selectedNodes: [newId],\n lastInternalId: newId,\n };\n\n case \"delete-entity-type\": {\n // Remove the entity type from the map\n console.log(\"Deleting entity type:\", action.payload.id);\n const { id } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n newEntityTypesMap.delete(id);\n\n const defaultType = newEntityTypesMap.values().next().value;\n const newTree = updateTreeTypes(state.tree, oldType, defaultType);\n\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedNodes: [],\n };\n }\n\n /** Entity type selection */\n case \"toggle-entity-type-selector\":\n return {\n ...state,\n isSelectingEntityType: action.payload ?? !state.isSelectingEntityType,\n };\n case \"select-entity-type\": {\n // For each selected node, update the type\n let newTree2 = state.tree;\n for (let id of state.selectedNodes) {\n const keyPath = findNode(state.tree, id);\n const nestedSpec = buildNestedSpec(keyPath, {\n type: { $set: action.payload },\n });\n newTree2 = update(newTree2, nestedSpec);\n }\n\n return {\n ...state,\n tree: newTree2,\n selectedEntityType: action.payload,\n };\n }\n case \"deselect\":\n return { ...state, selectedNodes: [] };\n case \"reset\":\n return {\n ...state,\n tree: state.initialTree,\n selectedNodes: [],\n };\n case \"set-view-mode\":\n return { ...state, viewMode: action.payload };\n }\n}\n\nfunction nodeIsInTree(tree: TreeData[], id: number): boolean {\n for (let node of tree) {\n if (node.id == id) {\n return true;\n } else if (node.children) {\n if (nodeIsInTree(node.children, id)) {\n return true;\n }\n }\n }\n return false;\n}\n\nfunction buildNestedSpec(\n keyPath: (number | \"children\")[],\n innerSpec: Spec<any>,\n): Spec<TreeData[]> {\n // Build a nested object from a key path\n\n let spec = innerSpec;\n for (let i = keyPath.length - 1; i >= 0; i--) {\n spec = { [keyPath[i]]: spec };\n }\n return spec as any;\n // Since we don't have a \"children\" key at the root, we make the top-level spec an array\n}\n\nfunction findNode(\n tree: TreeData[],\n id: number,\n): (number | \"children\")[] | null {\n // Find the index of the node with the given id in the tree, returning the key path\n for (let i = 0; i < tree.length; i++) {\n if (tree[i].id == id) {\n return [i];\n } else if (tree[i].children) {\n let path = findNode(tree[i].children, id);\n if (path != null) {\n return [i, \"children\", ...path];\n }\n }\n }\n return null;\n}\n\nfunction removeNodes(\n tree: TreeData[],\n ids: number[],\n): [TreeData[], TreeData[]] {\n /** Remove nodes with the given ids from the tree and return the new tree and the removed nodes */\n let newTree: TreeData[] = [];\n let removedNodes: TreeData[] = [];\n\n for (let node of tree) {\n if (ids.includes(node.id)) {\n removedNodes.push(node);\n } else {\n // Recurse into children\n if (node.children) {\n let [newChildren, removedChildren] = removeNodes(node.children, ids);\n node = { ...node, children: newChildren };\n removedNodes.push(...removedChildren);\n }\n newTree.push(node);\n }\n }\n\n return [newTree, removedNodes];\n}\n\nexport interface EntityOutput {\n id: number;\n type: number | null;\n txt_range: number[][];\n name: string;\n match: any | null;\n reasoning: string | null;\n color: string | null;\n children: any[] | null;\n}\n\nexport interface GraphData {\n nodes: EntityOutput[];\n edges: { source: number; dest: number }[];\n}\n\nexport function treeToGraph(tree: TreeData[]): GraphData {\n // Convert the tree to a graph\n let nodes: EntityOutput[] = [];\n let edges: { source: number; dest: number }[] = [];\n const nodeMap = new Map<number, TreeData>();\n\n for (let node of tree) {\n // If we've already found an instance of this node, we don't need to record\n // it again\n if (nodeMap.has(node.id)) {\n continue;\n }\n\n const { indices, id, name, type, children } = node;\n\n const nodeData: EntityOutput = {\n id,\n type: type.id,\n color: type.color,\n name,\n txt_range: [indices],\n reasoning: null,\n match: node.match,\n children,\n };\n\n nodeMap.set(node.id, node);\n nodes.push(nodeData);\n\n if (node.children) {\n for (let child of node.children) {\n edges.push({ source: node.id, dest: child.id });\n }\n\n // Now process the children\n const { nodes: childNodes, edges: childEdges } = treeToGraph(\n node.children,\n );\n nodes.push(...childNodes);\n edges.push(...childEdges);\n }\n }\n\n return { nodes, edges };\n}\n\nfunction findNodeById(tree, id) {\n for (const node of tree) {\n if (node.id === id) {\n return node;\n }\n if (node.children) {\n const found = findNodeById(node.children, id);\n if (found) return found;\n }\n }\n return null;\n}\n\nfunction updateTreeTypes(tree, oldType, defaultType) {\n return tree.map((node) => updateNodeType(node, oldType, defaultType));\n}\n\nfunction updateNodeType(node, oldType, defaultType) {\n const type = node.type.id === oldType.id ? defaultType : node.type;\n\n return {\n ...node,\n type,\n children: node.children\n ? updateTreeTypes(node.children, oldType, defaultType)\n : [],\n };\n}\n\nfunction flattenAndSort(nodes) {\n const result = [];\n\n function traverse(nodeList) {\n for (const node of nodeList) {\n result.push(node);\n if (Array.isArray(node.children) && node.children.length > 0) {\n traverse(node.children);\n }\n }\n }\n\n traverse(nodes);\n\n // sort by start\n return result.sort((a, b) => a.indices[0] - b.indices[0]);\n}\n"],"names":[],"version":3,"file":"feedback-components.fa1d3641.js.map"}
@@ -1 +0,0 @@
1
- {"mappings":"AAAA;;;;;AAIA;;;;;;;;AAOA;;;;AAGA;;;;;AAIA;;;;;AAIA;;;;;AAIE;;;;AAGF;;;;AAGA;;;;;AAIA;;;;AAGA;;;;AAGA;;;;;;;;;;;;AAYA;;;;;AAIA;;;;;;;AAME;;;;;AAIF;;;;;AAIA;;;;;;AAKA;;;;AAGA;;;;;;;;AAOA;;;;;;;AAMA;;;;;;;AAMA;;;;;;;;AAOE;;;;AAGF;;;;;;;;AAOE;;;;;;;;;AAQE;;;;;;AAKA;;;;AAGA;;;;;AAIE;;;;;;AAKN;;;;;AAIA","sources":["packages/feedback-components/src/feedback/feedback.module.sass"],"sourcesContent":[":root\n --text-line-height: 3em\n --main-extra-width: 200px\n\n.page-wrapper\n display: flex\n flex-direction: row\n position: relative\n gap: 2em\n align-items: flex-start // makes control-content lose stick\n\n.feedback-container\n flex: 4\n\n.control-panel\n flex: 1\n height: auto\n\n.control-content\n position: sticky\n top: 0\n\n.feedback-component\n position: relative\n width: 800px\n\n & > svg\n width: 800px\n\n.node\n cursor: pointer\n\ncircle\n cursor: pointer\n border: 1px solid black\n\n.selected\n border: 1px solid white\n \n.feedback-text\n margin-bottom: 2em\n\n.entity-panel\n position: relative\n max-height: 600px\n width: calc(100% - 2em)\n flex: 1\n min-height: 100px\n padding: 1em\n background: var(--panel-secondary-background-color)\n border-radius: 4px\n // Inset box shadow\n box-shadow: 0 0 0 1px var(--panel-border-color) inset\n\n.selection-tree\n margin: -1em 0\n padding: 1em 0\n \n.type-list\n display: grid\n grid-auto-flow: column\n grid-template-rows: repeat(10, auto)\n gap: 0.2em\n\n .type-tag\n padding: .2em .5em\n border-radius: .2em\n\n.description\n max-width: 300px\n padding: .5em\n\nmark\n border-radius: .2em\n cursor: pointer\n color: black !important\n\n[role=\"treeitem\"]\n width: auto !important\n\n.highlight\n cursor: pointer\n padding: .2em 0\n border-radius: .2em\n position: relative\n zIndex: 10\n\n.feedback-text-wrapper \n position: relative\n z-index: 0\n overflow: visible\n line-height: var(--text-line-height)\n\n.type-container\n display: flex\n justify-content: space-between\n align-items: center\n column-gap: 1em\n\n.add-type\n cursor: pointer\n display: flex\n justify-content: space-between\n padding: 0 .5em\n align-items: center\n\n p\n margin: 0\n\n.overlay-container\n height: 80vh\n width: 100vw\n display: flex\n justify-content: center\n align-items: center\n\n .add-type-overlay\n background-color: var(--secondary-color)\n padding: .5em 1em\n display: flex\n flex-direction: column\n gap: 1em\n border-radius: .2em\n\n .title\n display: flex\n justify-content: space-between\n align-items: center\n\n h2\n margin: 0\n\n .form-group\n display: flex\n gap: 3em\n\n .text-inputs\n display: flex\n flex-direction: column\n gap: 1em\n\n.icons\n display: flex\n gap: .25em\n\n.node-label\n fill: var(--text-emphasized-color)\n fontSize: 10px\n pointerEvents: none"],"names":[],"version":3,"file":"feedback-components.fb60c70d.css.map"}
@@ -1,2 +0,0 @@
1
- import"./feedback-components.c459cc27.js";import"./feedback-components.a39f7653.js";import"./feedback-components.ec54a1e7.js";import"./feedback-components.8b03e8be.js";import"./feedback-components.b7946db4.js";import"./feedback-components.acac789b.js";import"./feedback-components.571ee23c.js";import e from"@macrostrat/hyper";import{Tree as t}from"react-arborist";import{useState as o,useRef as n,useCallback as r,useEffect as a}from"react";import{SegmentedControl as i,Card as d,ButtonGroup as l,Divider as s,Icon as c,Overlay2 as p,Popover as y}from"@blueprintjs/core";import{ErrorBoundary as u,FlexRow as m,CancelButton as h,SaveButton as f,useInDarkMode as v}from"@macrostrat/ui-components";import g from"use-element-dimensions";import{ColorPicker as b}from"@macrostrat/data-sheet";function w(e,t,o,n){Object.defineProperty(e,t,{get:o,set:n,enumerable:!0,configurable:!0})}var C=globalThis,T={},k={},S=C.parcelRequirea149;null==S&&((S=function(e){if(e in T)return T[e].exports;if(e in k){var t=k[e];delete k[e];var o={id:e,exports:{}};return T[e]=o,t.call(o.exports,o,o.exports),o.exports}var n=Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}).register=function(e,t){k[e]=t},C.parcelRequirea149=S),S.register;var x={};w(x,"FeedbackComponent",()=>R),w(x,"treeToGraph",()=>S("eedTh").treeToGraph);var N=S("9wFEx"),O=S("bQY4Q"),E=S("3OP12"),_=S("edvRb"),H=S("eedTh"),A=S("iKZjQ"),I=S("bK9Of");let F=e.styled(N&&N.__esModule?N.default:N);function R({entities:e=[],text:t,model:o,entityTypes:n,matchComponent:r,onSave:a,allowOverlap:c}){let[p,y]=(0,H.useUpdatableTree)(e.map(j),n),{selectedNodes:v,tree:b,selectedEntityType:w,isSelectingEntityType:C,entityTypesMap:T}=p,[{width:k,height:S},x]=g();return F("div.page-wrapper",[F("div.feedback-container",F(H.TreeDispatchContext.Provider,{value:y},[F(u,{description:"An error occurred while rendering the feedback text component."},F(E.FeedbackText,{text:t,dispatch:y,nodes:b,selectedNodes:v,allowOverlap:c})),F(m,{alignItems:"baseline",justifyContent:"space-between"},[F(_.ModelInfo,{data:o}),F(i,{options:[{label:"Tree",value:"tree"},{label:"Graph",value:"graph"}],value:p.viewMode,small:!0,onValueChange(e){console.log("Setting view mode",e),y({type:"set-view-mode",payload:e})}})]),F("div.entity-panel",{ref:x},[F.if("tree"==p.viewMode)(D,{selectedNodes:v,dispatch:y,tree:b,width:k,height:S,matchComponent:r}),F.if("graph"==p.viewMode)(I.GraphView,{tree:b,width:k,height:S,dispatch:y,selectedNodes:v})])])),F(d,{className:"control-panel"},[F("div.control-content",[F(l,{vertical:!0,fill:!0,minimal:!0,alignText:"left"},[F(h,{icon:"trash",disabled:p.initialTree==p.tree,onClick(){y({type:"reset"})}},"Reset"),F(f,{onClick(){a(p.tree)},disabled:p.initialTree==p.tree},"Save")]),F(s),F(M,{entityTypes:T,selected:w,onChange(e){y({type:"select-entity-type",payload:e})},dispatch:y,tree:b,selectedNodes:v,isOpen:C,setOpen:e=>y({type:"toggle-entity-type-selector",payload:e})})])])])}function j(e){return{...e,term_type:e.type.name,txt_range:[e.indices],children:e.children?.map(j)??[]}}function M({entityTypes:e,selected:t,isOpen:n,setOpen:r,onChange:a,tree:i,dispatch:d,selectedNodes:l=[]}){let s=null!=t?t:void 0,[c,p]=o(""),y=Array.from(e.values()),u=""!==c?y.filter(e=>e.name.toLowerCase().includes(c.toLowerCase())):y;return F("div.entity-type-selector",[F(P,{types:e,selected:s,dispatch:d,selectedNodes:l,tree:i}),F(A.OmniboxSelector,{isOpen:n,items:u,selectedItem:s,onSelectItem(e){r(!1),a(e)},onQueryChange(e){p(e)},onClose(){r(!1)}})])}function D(e){let{selectedNodes:o,dispatch:i,tree:d,height:l,width:s,matchComponent:c}=e,p=n(),y=n(!1),u=r(e=>F(O.default,{...e,matchComponent:c}),[c]);a(()=>{if(null!=p.current)!function(e,t){if(e.size!==t.size)return!1;for(let o of e)if(!t.has(o))return!1;return!0}(new Set(o.map(e=>e.toString())),p.current.selectedIds)&&p.current.setSelection({ids:o.map(e=>e.toString()),anchor:null,mostRecent:null})},[o]);let m=n(!1);return a(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&(m.current=!0)},t=()=>m.current=!1;return window.addEventListener("keydown",e),window.addEventListener("keyup",t),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",t)}},[]),F("div.selection-tree-wrapper",{onPointerDown:function(){y.current=!0}},F(t,{className:"selection-tree",height:l,width:s,ref:p,data:d,onMove({dragIds:e,parentId:t,index:o}){i({type:"move-node",payload:{dragIds:e.map(e=>parseInt(e)),parentId:t?parseInt(t):null,index:o}})},onDelete({ids:e}){i({type:"delete-node",payload:{ids:e.map(e=>parseInt(e))}})},onSelect:r(e=>{if(!y.current)return;y.current=!1;let t=m.current,n=e.map(e=>parseInt(e.id));t?i({type:"toggle-node-selected",payload:{ids:n}}):(1===n.length&&n[0]===o[0]&&(n=[]),i({type:"select-node",payload:{ids:n}}))},[o,i]),children:u,idAccessor:e=>e.id.toString()}))}function P({types:e,selected:t,dispatch:n,selectedNodes:r,tree:a}){let[i,d]=o(null),l=r.length>0,s=v()?.9:.4;return F("div.type-list-container",[F("div.type-list-header",l&&!i?"Change selected nodes to:":"Entity Types"),F("div.type-list",Array.from(e.values()).map(e=>F(B,{type:e,luminance:s,selectedType:i,setSelectedType:d,dispatch:n,tree:a,selectedNodes:r,selected:t,isSelectedNodes:l}))),F(G,{dispatch:n})])}function L(e,t){let o=[];return e.forEach(function e(n){n.type.id===t&&o.push(n.id),Array.isArray(n.children)&&n.children.forEach(e)}),o}function G({dispatch:e}){let[t,n]=o(!1);return F("div.add-type-container",[F("div.add-type",{onClick:()=>n(!0)},[F("p.add-type-text","Add new type"),F(c,{icon:"plus"})]),F(K,{setOverlayOpen:n,overlayOpen:t,title:"Add New Type",saveHandler:t=>{e({type:"add-entity-type",payload:t}),n(!1)}})])}function $({dispatch:e,type:t}){let[n,r]=o(!1);return F("div.edit-type",[F(c,{icon:"edit",className:"edit-icon",onClick:e=>{e.stopPropagation(),r(!0)}}),F(K,{setOverlayOpen:r,overlayOpen:n,originalType:t,title:"Edit Type",saveHandler:t=>{e({type:"update-entity-type",payload:t}),r(!1)}})])}function K({setOverlayOpen:e,overlayOpen:t,originalType:n,title:r,saveHandler:a}){let{name:i,description:d,color:l,id:s}=n||{},[y,u]=o(i||""),[m,h]=o(d||""),[v,g]=o(l||"#fff");return F(p,{isOpen:t},F("div.overlay-container",F("div.add-type-overlay",[F("h2.title",[r,F(c,{icon:"cross",className:"close-icon",onClick:()=>{e(!1)},style:{cursor:"pointer",color:"red"}})]),F("div.form-group",[F("div.text-inputs",[F("div.form-field.name",[F("p.label","Name"),F("input",{type:"text",placeholder:"Enter type name",onChange:e=>u(e.target.value),value:y})]),F("div.form-field.form-description",[F("p.label","Description"),F("input",{type:"text",placeholder:"Enter type description",onChange:e=>h(e.target.value),value:m})])]),F("div.form-field.color",[F("p.label","Color"),F(b,{value:v,onChange:e=>g(e),style:{width:"100%"}})])]),F(f,{className:"save-btn",small:!0,onClick:()=>a({name:y,description:m,color:v,id:s})},"Save changes")])))}function B({type:e,luminance:t,selectedType:o,setSelectedType:n,dispatch:r,tree:a,selectedNodes:i,selected:d,isSelectedNodes:l}){let{color:s,name:p,id:u,description:m}=e;v();let h=u===d?.id&&i.length>0,f=(0,_.getTagStyle)(s,{active:h,highlighted:0===i.length}),g={id:u,name:p,color:s,description:m},b=L(a,u);return F(y,{autoFocus:!1,content:F("div.description",m||"No description available"),interactionKind:"hover"},F("div.type-tag",{onClick:()=>{l||null!==o?l&&null===o?u===d?.id&&i.length>0?r({type:"toggle-node-selected",payload:{ids:i}}):r({type:"select-entity-type",payload:g}):l&&o.id===u?(n(null),r({type:"toggle-node-selected",payload:{ids:b}})):l&&o.id!==u?b.length>0&&(n(e),r({type:"toggle-node-selected",payload:{ids:L(a,o.id)}}),r({type:"toggle-node-selected",payload:{ids:b}})):console.warn("Unexpected state in TypeTag click handler",{isSelectedNodes:l,selectedType:o,selectedNodes:i,ids:b,id:u,selected:d}):b.length>0&&(n(e),r({type:"toggle-node-selected",payload:{ids:b}}))},style:{cursor:b.length>0||l&&!o?"pointer":"",color:"black",backgroundColor:f.backgroundColor,border:h?"1px solid var(--text-emphasized-color)":"1px solid var(--background-color)"}},F("div.type-container",[F("div.type-name",p),F("div.icons",[F($,{dispatch:r,type:e}),F(c,{icon:"cross",className:"delete-type-icon",style:{color:"red",cursor:"pointer"},onClick:e=>{e.stopPropagation(),r({type:"delete-entity-type",payload:{id:u}})}})])])))}export{R as FeedbackComponent,$330ae695507d96f5$export$8d9dbb7a64bf2a5e as treeToGraph};
2
- //# sourceMappingURL=feedback-components.561466ac.js.map
@@ -1 +0,0 @@
1
- {"mappings":"A,M,oD,A,O,oD,A,O,oD,A,O,oD,A,O,oD,A,O,oD,A,O,oD,A,Q,M,mB,A,Q,Q,C,K,gB,A,Q,Y,C,C,U,C,C,e,C,C,a,C,K,O,A,Q,oB,C,C,Q,C,C,e,C,C,W,C,C,Q,C,C,Y,C,C,W,C,K,mB,A,Q,iB,C,C,W,C,C,gB,C,C,c,C,C,iB,C,K,2B,A,Q,M,wB,A,Q,e,C,K,wB,C,S,E,C,C,C,C,C,C,C,E,O,c,C,E,E,C,I,E,I,E,W,C,E,a,C,C,E,C,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,C,C,E,C,C,E,E,iB,C,G,E,Q,C,I,E,C,E,E,E,oB,I,G,E,E,c,I,A,E,S,W,E,I,E,E,S,E,E,S,E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,EACzC,QAAS,AAAC,IACR,EAAE,eAAe,GACjB,EAAS,CACP,KAAM,qBACN,QAAS,CAAE,GAAA,CAAG,CAChB,EACF,CACF,GACD,EACF,GAGP,Q,K,iB,C,6C,W","sources":["<anon>","packages/feedback-components/src/feedback/index.ts"],"sourcesContent":["import \"./feedback-components.c459cc27.js\";\nimport \"./feedback-components.a39f7653.js\";\nimport \"./feedback-components.ec54a1e7.js\";\nimport \"./feedback-components.8b03e8be.js\";\nimport \"./feedback-components.b7946db4.js\";\nimport \"./feedback-components.acac789b.js\";\nimport \"./feedback-components.571ee23c.js\";\nimport $ajJMX$macrostrathyper from \"@macrostrat/hyper\";\nimport {Tree as $ajJMX$Tree} from \"react-arborist\";\nimport {useState as $ajJMX$useState, useRef as $ajJMX$useRef, useCallback as $ajJMX$useCallback, useEffect as $ajJMX$useEffect} from \"react\";\nimport {SegmentedControl as $ajJMX$SegmentedControl, Card as $ajJMX$Card, ButtonGroup as $ajJMX$ButtonGroup, Divider as $ajJMX$Divider, Icon as $ajJMX$Icon, Overlay2 as $ajJMX$Overlay2, Popover as $ajJMX$Popover} from \"@blueprintjs/core\";\nimport {ErrorBoundary as $ajJMX$ErrorBoundary, FlexRow as $ajJMX$FlexRow, CancelButton as $ajJMX$CancelButton, SaveButton as $ajJMX$SaveButton, useInDarkMode as $ajJMX$useInDarkMode} from \"@macrostrat/ui-components\";\nimport $ajJMX$useelementdimensions from \"use-element-dimensions\";\nimport {ColorPicker as $ajJMX$ColorPicker} from \"@macrostrat/data-sheet\";\n\n\nfunction $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$export(e, n, v, s) {\n Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});\n}\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirea149\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirea149\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\nvar $2c86488f2f3c1edd$exports = {};\n\n$parcel$export($2c86488f2f3c1edd$exports, \"FeedbackComponent\", () => $2c86488f2f3c1edd$export$a90600c9da52b40c);\n$parcel$export($2c86488f2f3c1edd$exports, \"treeToGraph\", () => (parcelRequire(\"eedTh\")).treeToGraph);\n\nvar $9wFEx = parcelRequire(\"9wFEx\");\n\n\n\nvar $bQY4Q = parcelRequire(\"bQY4Q\");\n\nvar $3OP12 = parcelRequire(\"3OP12\");\n\nvar $edvRb = parcelRequire(\"edvRb\");\n\nvar $eedTh = parcelRequire(\"eedTh\");\n\n\n\nvar $iKZjQ = parcelRequire(\"iKZjQ\");\n\n\n\nvar $bK9Of = parcelRequire(\"bK9Of\");\n\nconst $2c86488f2f3c1edd$var$h = (0, $ajJMX$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wFEx))));\nfunction $2c86488f2f3c1edd$var$setsAreTheSame(a, b) {\n if (a.size !== b.size) return false;\n for (const item of a){\n if (!b.has(item)) return false;\n }\n return true;\n}\nfunction $2c86488f2f3c1edd$export$a90600c9da52b40c({ entities: entities = [], text: text, model: model, entityTypes: entityTypes, matchComponent: matchComponent, onSave: onSave, allowOverlap: allowOverlap }) {\n // Get the input arguments\n const [state, dispatch] = (0, $eedTh.useUpdatableTree)(entities.map($2c86488f2f3c1edd$var$processEntity), entityTypes);\n const { selectedNodes: selectedNodes, tree: tree, selectedEntityType: selectedEntityType, isSelectingEntityType: isSelectingEntityType, entityTypesMap: entityTypesMap } = state;\n const [{ width: width, height: height }, ref] = (0, $ajJMX$useelementdimensions)();\n return $2c86488f2f3c1edd$var$h(\"div.page-wrapper\", [\n $2c86488f2f3c1edd$var$h(\"div.feedback-container\", $2c86488f2f3c1edd$var$h((0, $eedTh.TreeDispatchContext).Provider, {\n value: dispatch\n }, [\n $2c86488f2f3c1edd$var$h((0, $ajJMX$ErrorBoundary), {\n description: \"An error occurred while rendering the feedback text component.\"\n }, $2c86488f2f3c1edd$var$h((0, $3OP12.FeedbackText), {\n text: text,\n dispatch: dispatch,\n // @ts-ignore\n nodes: tree,\n selectedNodes: selectedNodes,\n allowOverlap: allowOverlap\n })),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$FlexRow), {\n alignItems: \"baseline\",\n justifyContent: \"space-between\"\n }, [\n $2c86488f2f3c1edd$var$h((0, $edvRb.ModelInfo), {\n data: model\n }),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$SegmentedControl), {\n options: [\n {\n label: \"Tree\",\n value: \"tree\"\n },\n {\n label: \"Graph\",\n value: \"graph\"\n }\n ],\n value: state.viewMode,\n small: true,\n onValueChange (value) {\n console.log(\"Setting view mode\", value);\n dispatch({\n type: \"set-view-mode\",\n payload: value\n });\n }\n })\n ]),\n $2c86488f2f3c1edd$var$h(\"div.entity-panel\", {\n ref: ref\n }, [\n $2c86488f2f3c1edd$var$h.if(state.viewMode == \"tree\")($2c86488f2f3c1edd$var$ManagedSelectionTree, {\n selectedNodes: selectedNodes,\n dispatch: dispatch,\n tree: tree,\n width: width,\n height: height,\n matchComponent: matchComponent\n }),\n $2c86488f2f3c1edd$var$h.if(state.viewMode == \"graph\")((0, $bK9Of.GraphView), {\n tree: tree,\n width: width,\n height: height,\n dispatch: dispatch,\n selectedNodes: selectedNodes\n })\n ])\n ])),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$Card), {\n className: \"control-panel\"\n }, [\n $2c86488f2f3c1edd$var$h(\"div.control-content\", [\n $2c86488f2f3c1edd$var$h((0, $ajJMX$ButtonGroup), {\n vertical: true,\n fill: true,\n minimal: true,\n alignText: \"left\"\n }, [\n $2c86488f2f3c1edd$var$h((0, $ajJMX$CancelButton), {\n icon: \"trash\",\n disabled: state.initialTree == state.tree,\n onClick () {\n dispatch({\n type: \"reset\"\n });\n }\n }, \"Reset\"),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$SaveButton), {\n onClick () {\n onSave(state.tree);\n },\n disabled: state.initialTree == state.tree\n }, \"Save\")\n ]),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$Divider)),\n $2c86488f2f3c1edd$var$h($2c86488f2f3c1edd$var$EntityTypeSelector, {\n entityTypes: entityTypesMap,\n selected: selectedEntityType,\n onChange (payload) {\n dispatch({\n type: \"select-entity-type\",\n payload: payload\n });\n },\n dispatch: dispatch,\n tree: tree,\n selectedNodes: selectedNodes,\n isOpen: isSelectingEntityType,\n setOpen: (isOpen)=>dispatch({\n type: \"toggle-entity-type-selector\",\n payload: isOpen\n })\n })\n ])\n ])\n ]);\n}\nfunction $2c86488f2f3c1edd$var$processEntity(entity) {\n // @ts-ignore\n return {\n ...entity,\n // @ts-ignore\n term_type: entity.type.name,\n txt_range: [\n entity.indices\n ],\n children: entity.children?.map($2c86488f2f3c1edd$var$processEntity) ?? []\n };\n}\nfunction $2c86488f2f3c1edd$var$EntityTypeSelector({ entityTypes: entityTypes, selected: selected, isOpen: isOpen, setOpen: setOpen, onChange: onChange, tree: tree, dispatch: dispatch, selectedNodes: selectedNodes = [] }) {\n // Show all entity types when selected is null\n const _selected = selected != null ? selected : undefined;\n const [inputValue, setInputValue] = (0, $ajJMX$useState)(\"\");\n const types = Array.from(entityTypes.values());\n const items = inputValue !== \"\" ? types.filter((d)=>d.name.toLowerCase().includes(inputValue.toLowerCase())) : types;\n return $2c86488f2f3c1edd$var$h(\"div.entity-type-selector\", [\n $2c86488f2f3c1edd$var$h($2c86488f2f3c1edd$var$TypeList, {\n types: entityTypes,\n selected: _selected,\n dispatch: dispatch,\n selectedNodes: selectedNodes,\n tree: tree\n }),\n $2c86488f2f3c1edd$var$h((0, $iKZjQ.OmniboxSelector), {\n isOpen: isOpen,\n items: items,\n selectedItem: _selected,\n onSelectItem (item) {\n setOpen(false);\n onChange(item);\n },\n onQueryChange (query) {\n setInputValue(query);\n },\n onClose () {\n setOpen(false);\n }\n })\n ]);\n}\nfunction $2c86488f2f3c1edd$var$countNodes(tree) {\n if (!tree) return 0;\n let count = 0;\n function recurse(nodes) {\n for (const node of nodes){\n count++;\n if (node.children && Array.isArray(node.children)) recurse(node.children);\n }\n }\n recurse(tree);\n return count;\n}\nfunction $2c86488f2f3c1edd$var$ManagedSelectionTree(props) {\n const { selectedNodes: selectedNodes, dispatch: dispatch, tree: tree, height: height, width: width, matchComponent: matchComponent } = props;\n const ref = (0, $ajJMX$useRef)();\n // Use a ref to track clicks (won't cause rerender)\n const clickedRef = (0, $ajJMX$useRef)(false);\n const _Node = (0, $ajJMX$useCallback)((props)=>$2c86488f2f3c1edd$var$h((0, $bQY4Q.default), {\n ...props,\n matchComponent: matchComponent\n }), [\n matchComponent\n ]);\n // Update Tree selection when selectedNodes change\n (0, $ajJMX$useEffect)(()=>{\n if (ref.current == null) return;\n const selection = new Set(selectedNodes.map((d)=>d.toString()));\n const currentSelection = ref.current.selectedIds;\n if ($2c86488f2f3c1edd$var$setsAreTheSame(selection, currentSelection)) return;\n ref.current.setSelection({\n ids: selectedNodes.map((d)=>d.toString()),\n anchor: null,\n mostRecent: null\n });\n }, [\n selectedNodes\n ]);\n // Mark clicked when user clicks inside the tree container\n function handleClick() {\n clickedRef.current = true;\n }\n const ctrlPressedRef = (0, $ajJMX$useRef)(false);\n (0, $ajJMX$useEffect)(()=>{\n const down = (e)=>{\n if (e.ctrlKey || e.metaKey) ctrlPressedRef.current = true;\n };\n const up = ()=>ctrlPressedRef.current = false;\n window.addEventListener(\"keydown\", down);\n window.addEventListener(\"keyup\", up);\n return ()=>{\n window.removeEventListener(\"keydown\", down);\n window.removeEventListener(\"keyup\", up);\n };\n }, []);\n const handleSelect = (0, $ajJMX$useCallback)((nodes)=>{\n if (!clickedRef.current) return;\n clickedRef.current = false;\n const isMultiSelect = ctrlPressedRef.current;\n let ids = nodes.map((d)=>parseInt(d.id));\n if (isMultiSelect) dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: ids\n }\n });\n else {\n if (ids.length === 1 && ids[0] === selectedNodes[0]) ids = [];\n dispatch({\n type: \"select-node\",\n payload: {\n ids: ids\n }\n });\n }\n }, [\n selectedNodes,\n dispatch\n ]);\n return $2c86488f2f3c1edd$var$h(\"div.selection-tree-wrapper\", {\n onPointerDown: handleClick\n }, $2c86488f2f3c1edd$var$h((0, $ajJMX$Tree), {\n className: \"selection-tree\",\n height: height,\n width: width,\n ref: ref,\n data: tree,\n onMove ({ dragIds: dragIds, parentId: parentId, index: index }) {\n dispatch({\n type: \"move-node\",\n payload: {\n dragIds: dragIds.map((d)=>parseInt(d)),\n parentId: parentId ? parseInt(parentId) : null,\n index: index\n }\n });\n },\n onDelete ({ ids: ids }) {\n dispatch({\n type: \"delete-node\",\n payload: {\n ids: ids.map((d)=>parseInt(d))\n }\n });\n },\n onSelect: handleSelect,\n children: _Node,\n idAccessor (d) {\n return d.id.toString();\n }\n }));\n}\nfunction $2c86488f2f3c1edd$var$TypeList({ types: types, selected: selected, dispatch: dispatch, selectedNodes: selectedNodes, tree: tree }) {\n const [selectedType, setSelectedType] = (0, $ajJMX$useState)(null);\n const isSelectedNodes = selectedNodes.length > 0;\n const darkMode = (0, $ajJMX$useInDarkMode)();\n const luminance = darkMode ? 0.9 : 0.4;\n return $2c86488f2f3c1edd$var$h(\"div.type-list-container\", [\n $2c86488f2f3c1edd$var$h(\"div.type-list-header\", isSelectedNodes && !selectedType ? \"Change selected nodes to:\" : \"Entity Types\"),\n $2c86488f2f3c1edd$var$h(\"div.type-list\", Array.from(types.values()).map((type)=>$2c86488f2f3c1edd$var$h($2c86488f2f3c1edd$var$TypeTag, {\n type: type,\n luminance: luminance,\n selectedType: selectedType,\n setSelectedType: setSelectedType,\n dispatch: dispatch,\n tree: tree,\n selectedNodes: selectedNodes,\n selected: selected,\n isSelectedNodes: isSelectedNodes\n }))),\n $2c86488f2f3c1edd$var$h($2c86488f2f3c1edd$var$AddType, {\n dispatch: dispatch\n })\n ]);\n}\nfunction $2c86488f2f3c1edd$var$collectMatchingIds(tree, id) {\n const ids = [];\n function traverse(node) {\n if (node.type.id === id) ids.push(node.id);\n if (Array.isArray(node.children)) node.children.forEach(traverse);\n }\n tree.forEach(traverse);\n return ids;\n}\nfunction $2c86488f2f3c1edd$var$AddType({ dispatch: dispatch }) {\n const [overlayOpen, setOverlayOpen] = (0, $ajJMX$useState)(false);\n const saveHandler = (payload)=>{\n dispatch({\n type: \"add-entity-type\",\n payload: payload\n });\n setOverlayOpen(false);\n };\n return $2c86488f2f3c1edd$var$h(\"div.add-type-container\", [\n $2c86488f2f3c1edd$var$h(\"div.add-type\", {\n onClick: ()=>setOverlayOpen(true)\n }, [\n $2c86488f2f3c1edd$var$h(\"p.add-type-text\", \"Add new type\"),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$Icon), {\n icon: \"plus\"\n })\n ]),\n $2c86488f2f3c1edd$var$h($2c86488f2f3c1edd$var$TypeOverlay, {\n setOverlayOpen: setOverlayOpen,\n overlayOpen: overlayOpen,\n title: \"Add New Type\",\n saveHandler: saveHandler\n })\n ]);\n}\nfunction $2c86488f2f3c1edd$var$EditType({ dispatch: dispatch, type: type }) {\n const [editorOpen, setEditorOpen] = (0, $ajJMX$useState)(false);\n const saveHandler = (payload)=>{\n dispatch({\n type: \"update-entity-type\",\n payload: payload\n });\n setEditorOpen(false);\n };\n return $2c86488f2f3c1edd$var$h(\"div.edit-type\", [\n $2c86488f2f3c1edd$var$h((0, $ajJMX$Icon), {\n icon: \"edit\",\n className: \"edit-icon\",\n onClick: (e)=>{\n e.stopPropagation();\n setEditorOpen(true);\n }\n }),\n $2c86488f2f3c1edd$var$h($2c86488f2f3c1edd$var$TypeOverlay, {\n setOverlayOpen: setEditorOpen,\n overlayOpen: editorOpen,\n originalType: type,\n title: \"Edit Type\",\n saveHandler: saveHandler\n })\n ]);\n}\nfunction $2c86488f2f3c1edd$var$TypeOverlay({ setOverlayOpen: setOverlayOpen, overlayOpen: overlayOpen, originalType: originalType, title: title, saveHandler: saveHandler }) {\n const { name: name, description: description, color: color, id: id } = originalType || {};\n const [nameInput, setNameInput] = (0, $ajJMX$useState)(name || \"\");\n const [descriptionInput, setDescriptionInput] = (0, $ajJMX$useState)(description || \"\");\n const [colorInput, setColorInput] = (0, $ajJMX$useState)(color || \"#fff\");\n return $2c86488f2f3c1edd$var$h((0, $ajJMX$Overlay2), {\n isOpen: overlayOpen\n }, $2c86488f2f3c1edd$var$h(\"div.overlay-container\", $2c86488f2f3c1edd$var$h(\"div.add-type-overlay\", [\n $2c86488f2f3c1edd$var$h(\"h2.title\", [\n title,\n $2c86488f2f3c1edd$var$h((0, $ajJMX$Icon), {\n icon: \"cross\",\n className: \"close-icon\",\n onClick: ()=>{\n setOverlayOpen(false);\n },\n style: {\n cursor: \"pointer\",\n color: \"red\"\n }\n })\n ]),\n $2c86488f2f3c1edd$var$h(\"div.form-group\", [\n $2c86488f2f3c1edd$var$h(\"div.text-inputs\", [\n $2c86488f2f3c1edd$var$h(\"div.form-field.name\", [\n $2c86488f2f3c1edd$var$h(\"p.label\", \"Name\"),\n $2c86488f2f3c1edd$var$h(\"input\", {\n type: \"text\",\n placeholder: \"Enter type name\",\n onChange: (e)=>setNameInput(e.target.value),\n value: nameInput\n })\n ]),\n $2c86488f2f3c1edd$var$h(\"div.form-field.form-description\", [\n $2c86488f2f3c1edd$var$h(\"p.label\", \"Description\"),\n $2c86488f2f3c1edd$var$h(\"input\", {\n type: \"text\",\n placeholder: \"Enter type description\",\n onChange: (e)=>setDescriptionInput(e.target.value),\n value: descriptionInput\n })\n ])\n ]),\n $2c86488f2f3c1edd$var$h(\"div.form-field.color\", [\n $2c86488f2f3c1edd$var$h(\"p.label\", \"Color\"),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$ColorPicker), {\n value: colorInput,\n onChange: (color)=>setColorInput(color),\n style: {\n width: \"100%\"\n }\n })\n ])\n ]),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$SaveButton), {\n className: \"save-btn\",\n small: true,\n onClick: ()=>saveHandler({\n name: nameInput,\n description: descriptionInput,\n color: colorInput,\n id: id\n })\n }, \"Save changes\")\n ])));\n}\nfunction $2c86488f2f3c1edd$var$TypeTag({ type: type, luminance: luminance, selectedType: selectedType, setSelectedType: setSelectedType, dispatch: dispatch, tree: tree, selectedNodes: selectedNodes, selected: selected, isSelectedNodes: isSelectedNodes }) {\n const { color: color, name: name, id: id, description: description } = type;\n const darkMode = (0, $ajJMX$useInDarkMode)();\n const isSelected = id === selected?.id && selectedNodes.length > 0;\n const style = (0, $edvRb.getTagStyle)(color, {\n active: isSelected,\n highlighted: selectedNodes.length === 0\n });\n const payload = {\n id: id,\n name: name,\n color: color,\n description: description\n };\n const ids = $2c86488f2f3c1edd$var$collectMatchingIds(tree, id);\n const handleTagClick = ()=>{\n if (!isSelectedNodes && selectedType === null) {\n if (ids.length > 0) {\n setSelectedType(type);\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: ids\n }\n });\n }\n } else if (isSelectedNodes && selectedType === null) {\n if (id === selected?.id && selectedNodes.length > 0) dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: selectedNodes\n }\n });\n else dispatch({\n type: \"select-entity-type\",\n payload: payload\n });\n } else if (isSelectedNodes && selectedType.id === id) {\n setSelectedType(null);\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: ids\n }\n });\n } else if (isSelectedNodes && selectedType.id !== id) {\n if (ids.length > 0) {\n setSelectedType(type);\n const oldIds = $2c86488f2f3c1edd$var$collectMatchingIds(tree, selectedType.id);\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: oldIds\n }\n });\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: ids\n }\n });\n }\n } else console.warn(\"Unexpected state in TypeTag click handler\", {\n isSelectedNodes: isSelectedNodes,\n selectedType: selectedType,\n selectedNodes: selectedNodes,\n ids: ids,\n id: id,\n selected: selected\n });\n };\n return $2c86488f2f3c1edd$var$h((0, $ajJMX$Popover), {\n autoFocus: false,\n content: $2c86488f2f3c1edd$var$h(\"div.description\", description || \"No description available\"),\n interactionKind: \"hover\"\n }, $2c86488f2f3c1edd$var$h(\"div.type-tag\", {\n onClick: handleTagClick,\n style: {\n cursor: ids.length > 0 || isSelectedNodes && !selectedType ? \"pointer\" : \"\",\n color: \"black\",\n backgroundColor: style.backgroundColor,\n border: isSelected ? `1px solid var(--text-emphasized-color)` : `1px solid var(--background-color)`\n }\n }, $2c86488f2f3c1edd$var$h(\"div.type-container\", [\n $2c86488f2f3c1edd$var$h(\"div.type-name\", name),\n $2c86488f2f3c1edd$var$h(\"div.icons\", [\n $2c86488f2f3c1edd$var$h($2c86488f2f3c1edd$var$EditType, {\n dispatch: dispatch,\n type: type\n }),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$Icon), {\n icon: \"cross\",\n className: \"delete-type-icon\",\n style: {\n color: \"red\",\n cursor: \"pointer\"\n },\n onClick: (e)=>{\n e.stopPropagation();\n dispatch({\n type: \"delete-entity-type\",\n payload: {\n id: id\n }\n });\n }\n })\n ])\n ])));\n}\n\n\nexport {$2c86488f2f3c1edd$export$a90600c9da52b40c as FeedbackComponent, $330ae695507d96f5$export$8d9dbb7a64bf2a5e as treeToGraph};\n//# sourceMappingURL=feedback-components.561466ac.js.map\n","import styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\n\nimport { Tree, TreeApi } from \"react-arborist\";\nimport Node from \"./node\";\nimport { FeedbackText } from \"./text-visualizer\";\nimport type { InternalEntity, TreeData } from \"./types\";\nimport type { Entity } from \"../extractions\";\nimport { getTagStyle, ModelInfo } from \"../extractions\";\nimport {\n TreeDispatchContext,\n treeToGraph,\n useUpdatableTree,\n ViewMode,\n} from \"./edit-state\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport {\n ButtonGroup,\n Card,\n SegmentedControl,\n Icon,\n Popover,\n Divider,\n Overlay2,\n} from \"@blueprintjs/core\";\nimport { OmniboxSelector } from \"./type-selector\";\nimport {\n CancelButton,\n DataField,\n ErrorBoundary,\n FlexBox,\n FlexRow,\n SaveButton,\n} from \"@macrostrat/ui-components\";\nimport useElementDimensions from \"use-element-dimensions\";\nimport { GraphView } from \"./graph\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport { asChromaColor } from \"@macrostrat/color-utils\";\nimport { ColorPicker } from \"@macrostrat/data-sheet\";\n\nexport type { GraphData } from \"./edit-state\";\nexport { treeToGraph } from \"./edit-state\";\nexport type { TreeData } from \"./types\";\n\nconst h = hyper.styled(styles);\n\nfunction setsAreTheSame<T>(a: Set<T>, b: Set<T>) {\n if (a.size !== b.size) return false;\n for (const item of a) {\n if (!b.has(item)) return false;\n }\n return true;\n}\n\nexport function FeedbackComponent({\n entities = [],\n text,\n model,\n entityTypes,\n matchComponent,\n onSave,\n allowOverlap,\n}) {\n // Get the input arguments\n const [state, dispatch] = useUpdatableTree(\n entities.map(processEntity) as any,\n entityTypes,\n );\n\n const {\n selectedNodes,\n tree,\n selectedEntityType,\n isSelectingEntityType,\n entityTypesMap,\n } = state;\n\n const [{ width, height }, ref] = useElementDimensions();\n\n return h(\"div.page-wrapper\", [\n h(\n \"div.feedback-container\",\n h(TreeDispatchContext.Provider, { value: dispatch }, [\n h(\n ErrorBoundary,\n {\n description:\n \"An error occurred while rendering the feedback text component.\",\n },\n h(FeedbackText, {\n text,\n dispatch,\n // @ts-ignore\n nodes: tree,\n selectedNodes,\n allowOverlap,\n }),\n ),\n h(\n FlexRow,\n { alignItems: \"baseline\", justifyContent: \"space-between\" },\n [\n h(ModelInfo, { data: model }),\n h(SegmentedControl, {\n options: [\n { label: \"Tree\", value: \"tree\" },\n { label: \"Graph\", value: \"graph\" },\n ],\n value: state.viewMode,\n small: true,\n onValueChange(value: ViewMode) {\n console.log(\"Setting view mode\", value);\n dispatch({ type: \"set-view-mode\", payload: value });\n },\n }),\n ],\n ),\n h(\n \"div.entity-panel\",\n {\n ref,\n },\n [\n h.if(state.viewMode == \"tree\")(ManagedSelectionTree, {\n selectedNodes,\n dispatch,\n tree,\n width,\n height,\n matchComponent,\n }),\n h.if(state.viewMode == \"graph\")(GraphView, {\n tree,\n width,\n height,\n dispatch,\n selectedNodes,\n }),\n ],\n ),\n ]),\n ),\n h(Card, { className: \"control-panel\" }, [\n h(\"div.control-content\", [\n h(\n ButtonGroup,\n {\n vertical: true,\n fill: true,\n minimal: true,\n alignText: \"left\",\n },\n [\n h(\n CancelButton,\n {\n icon: \"trash\",\n disabled: state.initialTree == state.tree,\n onClick() {\n dispatch({ type: \"reset\" });\n },\n },\n \"Reset\",\n ),\n h(\n SaveButton,\n {\n onClick() {\n onSave(state.tree);\n },\n disabled: state.initialTree == state.tree,\n },\n \"Save\",\n ),\n ],\n ),\n h(Divider),\n h(EntityTypeSelector, {\n entityTypes: entityTypesMap,\n selected: selectedEntityType,\n onChange(payload) {\n dispatch({ type: \"select-entity-type\", payload });\n },\n dispatch,\n tree,\n selectedNodes,\n isOpen: isSelectingEntityType,\n setOpen: (isOpen: boolean) =>\n dispatch({\n type: \"toggle-entity-type-selector\",\n payload: isOpen,\n }),\n }),\n ]),\n ]),\n ]);\n}\n\nfunction processEntity(entity: Entity): InternalEntity {\n // @ts-ignore\n return {\n ...entity,\n // @ts-ignore\n term_type: entity.type.name,\n txt_range: [entity.indices],\n children: entity.children?.map(processEntity) ?? [],\n };\n}\n\nfunction EntityTypeSelector({\n entityTypes,\n selected,\n isOpen,\n setOpen,\n onChange,\n tree,\n dispatch,\n selectedNodes = [],\n}) {\n // Show all entity types when selected is null\n const _selected = selected != null ? selected : undefined;\n const [inputValue, setInputValue] = useState(\"\");\n const types = Array.from(entityTypes.values());\n\n const items =\n inputValue !== \"\"\n ? types.filter((d) =>\n d.name.toLowerCase().includes(inputValue.toLowerCase()),\n )\n : types;\n\n return h(\"div.entity-type-selector\", [\n h(TypeList, {\n types: entityTypes,\n selected: _selected,\n dispatch,\n selectedNodes,\n tree,\n }),\n h(OmniboxSelector, {\n isOpen,\n items,\n selectedItem: _selected,\n onSelectItem(item) {\n setOpen(false);\n onChange(item);\n },\n onQueryChange(query) {\n setInputValue(query);\n },\n onClose() {\n setOpen(false);\n },\n }),\n ]);\n}\n\nfunction countNodes(tree) {\n if (!tree) return 0;\n let count = 0;\n\n function recurse(nodes) {\n for (const node of nodes) {\n count++;\n if (node.children && Array.isArray(node.children)) {\n recurse(node.children);\n }\n }\n }\n\n recurse(tree);\n return count;\n}\n\nfunction ManagedSelectionTree(props) {\n const { selectedNodes, dispatch, tree, height, width, matchComponent } =\n props;\n\n const ref = useRef<TreeApi<TreeData>>();\n // Use a ref to track clicks (won't cause rerender)\n const clickedRef = useRef(false);\n\n const _Node = useCallback(\n (props) => h(Node, { ...props, matchComponent }),\n [matchComponent],\n );\n\n // Update Tree selection when selectedNodes change\n useEffect(() => {\n if (ref.current == null) return;\n\n const selection = new Set(selectedNodes.map((d) => d.toString()));\n const currentSelection = ref.current.selectedIds;\n if (setsAreTheSame(selection, currentSelection)) return;\n\n ref.current.setSelection({\n ids: selectedNodes.map((d) => d.toString()),\n anchor: null,\n mostRecent: null,\n });\n }, [selectedNodes]);\n\n // Mark clicked when user clicks inside the tree container\n function handleClick() {\n clickedRef.current = true;\n }\n\n const ctrlPressedRef = useRef(false);\n\n useEffect(() => {\n const down = (e) => {\n if (e.ctrlKey || e.metaKey) ctrlPressedRef.current = true;\n };\n const up = () => (ctrlPressedRef.current = false);\n\n window.addEventListener(\"keydown\", down);\n window.addEventListener(\"keyup\", up);\n return () => {\n window.removeEventListener(\"keydown\", down);\n window.removeEventListener(\"keyup\", up);\n };\n }, []);\n\n const handleSelect = useCallback(\n (nodes) => {\n if (!clickedRef.current) return;\n clickedRef.current = false;\n const isMultiSelect = ctrlPressedRef.current;\n\n let ids = nodes.map((d) => parseInt(d.id));\n\n if (isMultiSelect) {\n dispatch({ type: \"toggle-node-selected\", payload: { ids } });\n } else {\n if (ids.length === 1 && ids[0] === selectedNodes[0]) {\n ids = [];\n }\n\n dispatch({ type: \"select-node\", payload: { ids } });\n }\n },\n [selectedNodes, dispatch],\n );\n\n return h(\n \"div.selection-tree-wrapper\",\n { onPointerDown: handleClick },\n h(Tree, {\n className: \"selection-tree\",\n height,\n width,\n ref,\n data: tree,\n onMove({ dragIds, parentId, index }) {\n dispatch({\n type: \"move-node\",\n payload: {\n dragIds: dragIds.map((d) => parseInt(d)),\n parentId: parentId ? parseInt(parentId) : null,\n index,\n },\n });\n },\n onDelete({ ids }) {\n dispatch({\n type: \"delete-node\",\n payload: { ids: ids.map((d) => parseInt(d)) },\n });\n },\n onSelect: handleSelect,\n children: _Node,\n idAccessor(d) {\n return d.id.toString();\n },\n }),\n );\n}\n\nfunction TypeList({ types, selected, dispatch, selectedNodes, tree }) {\n const [selectedType, setSelectedType] = useState(null);\n const isSelectedNodes = selectedNodes.length > 0;\n const darkMode = useInDarkMode();\n const luminance = darkMode ? 0.9 : 0.4;\n\n return h(\"div.type-list-container\", [\n h(\n \"div.type-list-header\",\n isSelectedNodes && !selectedType\n ? \"Change selected nodes to:\"\n : \"Entity Types\",\n ),\n h(\n \"div.type-list\",\n Array.from(types.values()).map((type) =>\n h(TypeTag, {\n type,\n luminance,\n selectedType,\n setSelectedType,\n dispatch,\n tree,\n selectedNodes,\n selected,\n isSelectedNodes,\n }),\n ),\n ),\n h(AddType, { dispatch }),\n ]);\n}\n\nfunction collectMatchingIds(tree, id) {\n const ids = [];\n\n function traverse(node) {\n if (node.type.id === id) {\n ids.push(node.id);\n }\n if (Array.isArray(node.children)) {\n node.children.forEach(traverse);\n }\n }\n\n tree.forEach(traverse);\n return ids;\n}\n\nfunction AddType({ dispatch }) {\n const [overlayOpen, setOverlayOpen] = useState(false);\n\n const saveHandler = (payload) => {\n dispatch({\n type: \"add-entity-type\",\n payload,\n });\n setOverlayOpen(false);\n };\n\n return h(\"div.add-type-container\", [\n h(\"div.add-type\", { onClick: () => setOverlayOpen(true) }, [\n h(\"p.add-type-text\", \"Add new type\"),\n h(Icon, { icon: \"plus\" }),\n ]),\n h(TypeOverlay, {\n setOverlayOpen,\n overlayOpen,\n title: \"Add New Type\",\n saveHandler,\n }),\n ]);\n}\n\nfunction EditType({ dispatch, type }) {\n const [editorOpen, setEditorOpen] = useState(false);\n\n const saveHandler = (payload) => {\n dispatch({\n type: \"update-entity-type\",\n payload,\n });\n setEditorOpen(false);\n };\n\n return h(\"div.edit-type\", [\n h(Icon, {\n icon: \"edit\",\n className: \"edit-icon\",\n onClick: (e) => {\n e.stopPropagation();\n setEditorOpen(true);\n },\n }),\n h(TypeOverlay, {\n setOverlayOpen: setEditorOpen,\n overlayOpen: editorOpen,\n originalType: type,\n title: \"Edit Type\",\n saveHandler,\n }),\n ]);\n}\n\nfunction TypeOverlay({\n setOverlayOpen,\n overlayOpen,\n originalType,\n title,\n saveHandler,\n}) {\n const { name, description, color, id } = originalType || {};\n\n const [nameInput, setNameInput] = useState(name || \"\");\n const [descriptionInput, setDescriptionInput] = useState(description || \"\");\n const [colorInput, setColorInput] = useState(color || \"#fff\");\n\n return h(\n Overlay2,\n {\n isOpen: overlayOpen,\n },\n h(\n \"div.overlay-container\",\n h(\"div.add-type-overlay\", [\n h(\"h2.title\", [\n title,\n h(Icon, {\n icon: \"cross\",\n className: \"close-icon\",\n onClick: () => {\n setOverlayOpen(false);\n },\n style: { cursor: \"pointer\", color: \"red\" },\n }),\n ]),\n h(\"div.form-group\", [\n h(\"div.text-inputs\", [\n h(\"div.form-field.name\", [\n h(\"p.label\", \"Name\"),\n h(\"input\", {\n type: \"text\",\n placeholder: \"Enter type name\",\n onChange: (e) => setNameInput(e.target.value),\n value: nameInput,\n }),\n ]),\n h(\"div.form-field.form-description\", [\n h(\"p.label\", \"Description\"),\n h(\"input\", {\n type: \"text\",\n placeholder: \"Enter type description\",\n onChange: (e) => setDescriptionInput(e.target.value),\n value: descriptionInput,\n }),\n ]),\n ]),\n h(\"div.form-field.color\", [\n h(\"p.label\", \"Color\"),\n h(ColorPicker, {\n value: colorInput,\n onChange: (color) => setColorInput(color),\n style: { width: \"100%\" },\n }),\n ]),\n ]),\n h(\n SaveButton,\n {\n className: \"save-btn\",\n small: true,\n onClick: () =>\n saveHandler({\n name: nameInput,\n description: descriptionInput,\n color: colorInput,\n id,\n }),\n },\n \"Save changes\",\n ),\n ]),\n ),\n );\n}\n\nfunction TypeTag({\n type,\n luminance,\n selectedType,\n setSelectedType,\n dispatch,\n tree,\n selectedNodes,\n selected,\n isSelectedNodes,\n}) {\n const { color, name, id, description } = type;\n const darkMode = useInDarkMode();\n const isSelected = id === selected?.id && selectedNodes.length > 0;\n\n const style = getTagStyle(color, {\n active: isSelected,\n highlighted: selectedNodes.length === 0,\n });\n\n const payload = {\n id,\n name,\n color,\n description,\n };\n\n const ids = collectMatchingIds(tree, id);\n\n const handleTagClick = () => {\n if (!isSelectedNodes && selectedType === null) {\n if (ids.length > 0) {\n setSelectedType(type);\n dispatch({ type: \"toggle-node-selected\", payload: { ids } });\n }\n } else if (isSelectedNodes && selectedType === null) {\n if (id === selected?.id && selectedNodes.length > 0) {\n dispatch({\n type: \"toggle-node-selected\",\n payload: { ids: selectedNodes },\n });\n } else {\n dispatch({ type: \"select-entity-type\", payload });\n }\n } else if (isSelectedNodes && selectedType.id === id) {\n setSelectedType(null);\n dispatch({ type: \"toggle-node-selected\", payload: { ids } });\n } else if (isSelectedNodes && selectedType.id !== id) {\n if (ids.length > 0) {\n setSelectedType(type);\n const oldIds = collectMatchingIds(tree, selectedType.id);\n\n dispatch({ type: \"toggle-node-selected\", payload: { ids: oldIds } });\n dispatch({ type: \"toggle-node-selected\", payload: { ids } });\n }\n } else {\n console.warn(\"Unexpected state in TypeTag click handler\", {\n isSelectedNodes,\n selectedType,\n selectedNodes,\n ids,\n id,\n selected,\n });\n }\n };\n\n return h(\n Popover,\n {\n autoFocus: false,\n content: h(\"div.description\", description || \"No description available\"),\n interactionKind: \"hover\",\n },\n h(\n \"div.type-tag\",\n {\n onClick: handleTagClick,\n style: {\n cursor:\n ids.length > 0 || (isSelectedNodes && !selectedType)\n ? \"pointer\"\n : \"\",\n color: \"black\",\n backgroundColor: style.backgroundColor,\n border: isSelected\n ? `1px solid var(--text-emphasized-color)`\n : `1px solid var(--background-color)`,\n },\n },\n h(\"div.type-container\", [\n h(\"div.type-name\", name),\n h(\"div.icons\", [\n h(EditType, {\n dispatch,\n type,\n }),\n h(Icon, {\n icon: \"cross\",\n className: \"delete-type-icon\",\n style: { color: \"red\", cursor: \"pointer\" },\n onClick: (e) => {\n e.stopPropagation();\n dispatch({\n type: \"delete-entity-type\",\n payload: { id },\n });\n },\n }),\n ]),\n ]),\n ),\n );\n}\n"],"names":["$ajJMX$macrostrathyper","Tree","$ajJMX$Tree","useState","$ajJMX$useState","useRef","$ajJMX$useRef","useCallback","$ajJMX$useCallback","useEffect","$ajJMX$useEffect","SegmentedControl","$ajJMX$SegmentedControl","Card","$ajJMX$Card","ButtonGroup","$ajJMX$ButtonGroup","Divider","$ajJMX$Divider","Icon","$ajJMX$Icon","Overlay2","$ajJMX$Overlay2","Popover","$ajJMX$Popover","ErrorBoundary","$ajJMX$ErrorBoundary","FlexRow","$ajJMX$FlexRow","CancelButton","$ajJMX$CancelButton","SaveButton","$ajJMX$SaveButton","useInDarkMode","$ajJMX$useInDarkMode","$ajJMX$useelementdimensions","ColorPicker","$ajJMX$ColorPicker","$parcel$export","e","n","v","s","Object","defineProperty","get","set","enumerable","configurable","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$2c86488f2f3c1edd$exports","$2c86488f2f3c1edd$export$a90600c9da52b40c","treeToGraph","$9wFEx","$bQY4Q","$3OP12","$edvRb","$eedTh","$iKZjQ","$bK9Of","$2c86488f2f3c1edd$var$h","styled","a","__esModule","default","entities","text","model","entityTypes","matchComponent","onSave","allowOverlap","state","dispatch","useUpdatableTree","map","$2c86488f2f3c1edd$var$processEntity","selectedNodes","tree","selectedEntityType","isSelectingEntityType","entityTypesMap","width","height","ref","TreeDispatchContext","Provider","value","description","FeedbackText","nodes","alignItems","justifyContent","ModelInfo","data","options","label","viewMode","small","onValueChange","console","log","type","payload","if","$2c86488f2f3c1edd$var$ManagedSelectionTree","GraphView","className","vertical","fill","minimal","alignText","icon","disabled","initialTree","onClick","$2c86488f2f3c1edd$var$EntityTypeSelector","selected","onChange","isOpen","setOpen","entity","term_type","name","txt_range","indices","children","_selected","undefined","inputValue","setInputValue","types","Array","from","values","items","filter","d","toLowerCase","includes","$2c86488f2f3c1edd$var$TypeList","OmniboxSelector","selectedItem","onSelectItem","item","onQueryChange","query","onClose","props","clickedRef","_Node","current","$2c86488f2f3c1edd$var$setsAreTheSame","b","size","has","Set","toString","selectedIds","setSelection","ids","anchor","mostRecent","ctrlPressedRef","down","ctrlKey","metaKey","up","window","addEventListener","removeEventListener","onPointerDown","onMove","dragIds","parentId","index","parseInt","onDelete","onSelect","isMultiSelect","length","idAccessor","selectedType","setSelectedType","isSelectedNodes","luminance","darkMode","$2c86488f2f3c1edd$var$TypeTag","$2c86488f2f3c1edd$var$AddType","$2c86488f2f3c1edd$var$collectMatchingIds","forEach","traverse","node","push","isArray","overlayOpen","setOverlayOpen","$2c86488f2f3c1edd$var$TypeOverlay","title","saveHandler","$2c86488f2f3c1edd$var$EditType","editorOpen","setEditorOpen","stopPropagation","originalType","color","nameInput","setNameInput","descriptionInput","setDescriptionInput","colorInput","setColorInput","style","cursor","placeholder","target","isSelected","getTagStyle","active","highlighted","autoFocus","content","interactionKind","warn","backgroundColor","border","FeedbackComponent","$330ae695507d96f5$export$8d9dbb7a64bf2a5e"],"version":3,"file":"feedback-components.561466ac.js.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- import"./feedback-components.b7946db4.js";import"./feedback-components.c459cc27.js";import"./feedback-components.8b03e8be.js";import e from"@macrostrat/hyper";import{forceSimulation as r,forceLink as t,forceManyBody as o,forceCenter as a,forceCollide as i}from"d3-force";import{useState as s,useEffect as c}from"react";import{Spinner as l,Switch as n}from"@blueprintjs/core";import{ErrorBoundary as d}from"@macrostrat/ui-components";var p=globalThis,h={},f={},u=p.parcelRequirea149;null==u&&((u=function(e){if(e in h)return h[e].exports;if(e in f){var r=f[e];delete f[e];var t={id:e,exports:{}};return h[e]=t,r.call(t.exports,t,t.exports),t.exports}var o=Error("Cannot find module '"+e+"'");throw o.code="MODULE_NOT_FOUND",o}).register=function(e,r){f[e]=r},p.parcelRequirea149=u),u.register;var g=u("eedTh"),m=u("9wFEx"),b=u("edvRb");let k=e.styled(m&&m.__esModule?m.default:m);function x(e){let{tree:p,width:h,height:f,dispatch:u,selectedNodes:m}=e,[x,y]=s(null),[w,v]=s(null),[S,_]=s(!1);return(c(()=>{let{nodes:e,edges:s}=(0,g.treeToGraph)(p),c=new Map(e.map(e=>[e.id,e])),l=s.map(e=>({source:c.get(e.source),target:c.get(e.dest),strength:1})),n=r(e).force("link",t(l)).force("charge",o().strength(-50)).force("center",a(h/2,f/2)).force("collide",i().radius(20)).on("tick",()=>{console.log("Simulation tick")}).on("end",()=>{y(e),v(l)});return()=>{n.stop()}},[p,h,f]),null==x||null==w)?k(l):(console.log("Graph",x,w,m),k(d,{description:"An error occurred while rendering the graph view."},k("div.graph-view",{style:{width:h,height:f}},[k(n,{className:"show-labels-switch",label:"Show Labels",checked:S,onChange:e=>_(e.target.checked)}),k("svg",{width:h,height:f},[k("g.links",w.map(e=>k("line",{x1:e.source.x,y1:e.source.y,x2:e.target.x,y2:e.target.y,stroke:"black"}))),k("g.nodes",x.map(e=>{var r,t,o;let a=m.includes(e.id),i=(r=e.id,t=m,o=x,0===t.length||t.includes(r)||o.some(e=>t.includes(e.id)&&e.children.some(e=>e.id===r))),s=(0,b.getTagStyle)(e.color,{highlighted:i,active:a});return k("g",[k("circle",{cx:e.x,cy:e.y,r:8,fill:s.backgroundColor||"blue",onClick:r=>{r.stopPropagation(),u({type:"toggle-node-selected",payload:{ids:[e.id]}})},className:a?"selected":"",stroke:a?"white":"black",strokeWidth:2}),k.if(S)("text",{x:e.x+10,y:e.y+4,className:"node-label"},e.name||`Node ${e.id}`),k.if(!S)("title",e.name||`Node ${e.id}`)])}))])])))}export{x as GraphView};
2
- //# sourceMappingURL=feedback-components.571ee23c.js.map
@@ -1 +0,0 @@
1
- {"mappings":"A,M,oD,A,O,oD,A,O,oD,A,Q,M,mB,A,Q,mB,C,C,a,C,C,iB,C,C,e,C,C,gB,C,K,U,A,Q,Y,C,C,a,C,K,O,A,Q,W,C,C,U,C,K,mB,A,Q,iB,C,K,2B,C,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,C,C,E,C,C,E,E,iB,C,G,E,Q,C,I,E,E,S,E,E,S,E,E,SCkBA,IAAM,EAAI,AAAA,EAAM,MAAM,C,AAAC,G,AAAA,E,U,C,AAAA,E,O,CAAA,GAEhB,SAAS,EAAU,CAMzB,EAGC,GAAM,CAAA,KAAE,CAAI,CAAA,MAAE,CAAK,CAAA,OAAE,CAAM,CAAA,SAAE,CAAQ,CAAA,cAAE,CAAa,CAAE,CAAG,EAEnD,CAAC,EAAO,EAAS,CAAG,AAAA,EAAgC,MACpD,CAAC,EAAO,EAAS,CAAG,AAAA,EAAgC,MACpD,CAAC,EAAY,EAAc,CAAG,AAAA,EAAS,CAAA,SAsC7C,CApCA,A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src/feedback/graph.ts"],"sourcesContent":["import \"./feedback-components.b7946db4.js\";\nimport \"./feedback-components.c459cc27.js\";\nimport \"./feedback-components.8b03e8be.js\";\nimport $9bqpz$macrostrathyper from \"@macrostrat/hyper\";\nimport {forceSimulation as $9bqpz$forceSimulation, forceLink as $9bqpz$forceLink, forceManyBody as $9bqpz$forceManyBody, forceCenter as $9bqpz$forceCenter, forceCollide as $9bqpz$forceCollide} from \"d3-force\";\nimport {useState as $9bqpz$useState, useEffect as $9bqpz$useEffect} from \"react\";\nimport {Spinner as $9bqpz$Spinner, Switch as $9bqpz$Switch} from \"@blueprintjs/core\";\nimport {ErrorBoundary as $9bqpz$ErrorBoundary} from \"@macrostrat/ui-components\";\n\n\nfunction $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirea149\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirea149\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\n\nvar $eedTh = parcelRequire(\"eedTh\");\n\nvar $9wFEx = parcelRequire(\"9wFEx\");\n\n\n\n\n\n\nvar $edvRb = parcelRequire(\"edvRb\");\nconst $8732cb0ae0ae3dfd$var$h = (0, $9bqpz$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wFEx))));\nfunction $8732cb0ae0ae3dfd$export$6a7fe3ef90e8d566(props) {\n // A graph view with react-flow\n // Get positions of nodes using force simulation\n const { tree: tree, width: width, height: height, dispatch: dispatch, selectedNodes: selectedNodes } = props;\n const [nodes, setNodes] = (0, $9bqpz$useState)(null);\n const [links, setLinks] = (0, $9bqpz$useState)(null);\n const [showLabels, setShowLabels] = (0, $9bqpz$useState)(false);\n (0, $9bqpz$useEffect)(()=>{\n const { nodes: nodes, edges: edges } = (0, $eedTh.treeToGraph)(tree);\n const nodesMap = new Map(nodes.map((d)=>[\n d.id,\n d\n ]));\n const links = edges.map((d)=>{\n return {\n source: nodesMap.get(d.source),\n target: nodesMap.get(d.dest),\n strength: 1\n };\n });\n const simulation = (0, $9bqpz$forceSimulation)(nodes).force(\"link\", (0, $9bqpz$forceLink)(links)).force(\"charge\", (0, $9bqpz$forceManyBody)().strength(-50)).force(\"center\", (0, $9bqpz$forceCenter)(width / 2, height / 2)).force(\"collide\", (0, $9bqpz$forceCollide)().radius(20)).on(\"tick\", ()=>{\n // Update the positions of the nodes\n // setNodes(nodes);\n console.log(\"Simulation tick\");\n }).on(\"end\", ()=>{\n // Update the positions of the nodes\n setNodes(nodes);\n setLinks(links);\n });\n return ()=>{\n simulation.stop();\n };\n }, [\n tree,\n width,\n height\n ]);\n if (nodes == null || links == null) return $8732cb0ae0ae3dfd$var$h((0, $9bqpz$Spinner));\n console.log(\"Graph\", nodes, links, selectedNodes);\n return $8732cb0ae0ae3dfd$var$h((0, $9bqpz$ErrorBoundary), {\n description: \"An error occurred while rendering the graph view.\"\n }, $8732cb0ae0ae3dfd$var$h(\"div.graph-view\", {\n style: {\n width: width,\n height: height\n }\n }, [\n $8732cb0ae0ae3dfd$var$h((0, $9bqpz$Switch), {\n className: \"show-labels-switch\",\n label: \"Show Labels\",\n checked: showLabels,\n onChange: (e)=>setShowLabels(e.target.checked)\n }),\n $8732cb0ae0ae3dfd$var$h(\"svg\", {\n width: width,\n height: height\n }, [\n $8732cb0ae0ae3dfd$var$h(\"g.links\", links.map((d)=>{\n return $8732cb0ae0ae3dfd$var$h(\"line\", {\n x1: d.source.x,\n y1: d.source.y,\n x2: d.target.x,\n y2: d.target.y,\n stroke: \"black\"\n });\n })),\n $8732cb0ae0ae3dfd$var$h(\"g.nodes\", nodes.map((d)=>{\n const active = selectedNodes.includes(d.id);\n const stroke = active ? \"white\" : \"black\";\n const highlighted = $8732cb0ae0ae3dfd$var$isHighlighted(d.id, selectedNodes, nodes);\n const style = (0, $edvRb.getTagStyle)(d.color, {\n highlighted: highlighted,\n active: active\n });\n return $8732cb0ae0ae3dfd$var$h(\"g\", [\n $8732cb0ae0ae3dfd$var$h(\"circle\", {\n cx: d.x,\n cy: d.y,\n r: 8,\n fill: style.backgroundColor || \"blue\",\n onClick: (e)=>{\n e.stopPropagation();\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: [\n d.id\n ]\n }\n });\n },\n className: active ? \"selected\" : \"\",\n stroke: stroke,\n strokeWidth: 2\n }),\n $8732cb0ae0ae3dfd$var$h.if(showLabels)(\"text\", {\n x: d.x + 10,\n y: d.y + 4,\n className: \"node-label\"\n }, d.name || `Node ${d.id}`),\n $8732cb0ae0ae3dfd$var$h.if(!showLabels)(\"title\", d.name || `Node ${d.id}`)\n ]);\n }))\n ])\n ]));\n}\nfunction $8732cb0ae0ae3dfd$var$isHighlighted(id, selectedNodes, nodes) {\n if (selectedNodes.length === 0) return true;\n return selectedNodes.includes(id) || nodes.some((node)=>selectedNodes.includes(node.id) && node.children.some((child)=>child.id === id));\n}\n\n\nexport {$8732cb0ae0ae3dfd$export$6a7fe3ef90e8d566 as GraphView};\n//# sourceMappingURL=feedback-components.571ee23c.js.map\n","import { TreeData } from \"./types\";\nimport { treeToGraph } from \"./edit-state\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\nimport {\n forceSimulation,\n SimulationNodeDatum,\n SimulationLinkDatum,\n forceCenter,\n forceLink,\n forceManyBody,\n forceCollide,\n} from \"d3-force\";\nimport { useEffect, useState } from \"react\";\nimport { Spinner, Switch } from \"@blueprintjs/core\";\nimport { ErrorBoundary } from \"@macrostrat/ui-components\";\nimport { getTagStyle } from \"../extractions\";\n\nconst h = hyper.styled(styles);\n\nexport function GraphView(props: {\n tree: TreeData[];\n width: number;\n height: number;\n dispatch: (action: any) => void;\n selectedNodes: number[];\n}) {\n // A graph view with react-flow\n // Get positions of nodes using force simulation\n const { tree, width, height, dispatch, selectedNodes } = props;\n\n const [nodes, setNodes] = useState<SimulationNodeDatum[]>(null);\n const [links, setLinks] = useState<SimulationLinkDatum[]>(null);\n const [showLabels, setShowLabels] = useState(false);\n\n useEffect(() => {\n const { nodes, edges } = treeToGraph(tree);\n\n const nodesMap = new Map<number, SimulationNodeDatum>(\n nodes.map((d) => [d.id, d]),\n );\n\n const links = edges.map((d) => {\n return {\n source: nodesMap.get(d.source),\n target: nodesMap.get(d.dest),\n strength: 1,\n };\n });\n\n const simulation = forceSimulation(nodes)\n .force(\"link\", forceLink(links))\n .force(\"charge\", forceManyBody().strength(-50))\n .force(\"center\", forceCenter(width / 2, height / 2))\n .force(\"collide\", forceCollide().radius(20))\n .on(\"tick\", () => {\n // Update the positions of the nodes\n // setNodes(nodes);\n console.log(\"Simulation tick\");\n })\n .on(\"end\", () => {\n // Update the positions of the nodes\n setNodes(nodes);\n setLinks(links);\n });\n\n return () => {\n simulation.stop();\n };\n }, [tree, width, height]);\n\n if (nodes == null || links == null) {\n return h(Spinner);\n }\n\n console.log(\"Graph\", nodes, links, selectedNodes);\n\n return h(\n ErrorBoundary,\n {\n description: \"An error occurred while rendering the graph view.\",\n },\n h(\"div.graph-view\", { style: { width, height } }, [\n h(Switch, {\n className: \"show-labels-switch\",\n label: \"Show Labels\",\n checked: showLabels,\n onChange: (e) => setShowLabels(e.target.checked),\n }),\n h(\"svg\", { width, height }, [\n h(\n \"g.links\",\n links.map((d) => {\n return h(\"line\", {\n x1: d.source.x,\n y1: d.source.y,\n x2: d.target.x,\n y2: d.target.y,\n stroke: \"black\",\n });\n }),\n ),\n h(\n \"g.nodes\",\n nodes.map((d) => {\n const active = selectedNodes.includes(d.id);\n const stroke = active ? \"white\" : \"black\";\n const highlighted = isHighlighted(d.id, selectedNodes, nodes);\n const style = getTagStyle(d.color, { highlighted, active });\n\n return h(\"g\", [\n h(\"circle\", {\n cx: d.x,\n cy: d.y,\n r: 8,\n fill: style.backgroundColor || \"blue\",\n onClick: (e) => {\n e.stopPropagation();\n dispatch({\n type: \"toggle-node-selected\",\n payload: { ids: [d.id] },\n });\n },\n className: active ? \"selected\" : \"\",\n stroke,\n strokeWidth: 2,\n }),\n h.if(showLabels)(\n \"text\",\n {\n x: d.x + 10,\n y: d.y + 4,\n className: \"node-label\",\n },\n d.name || `Node ${d.id}`,\n ),\n h.if(!showLabels)(\"title\", d.name || `Node ${d.id}`),\n ]);\n }),\n ),\n ]),\n ]),\n );\n}\n\nfunction isHighlighted(id: number, selectedNodes: number[], nodes: TreeData[]) {\n if (selectedNodes.length === 0) return true;\n return (\n selectedNodes.includes(id) ||\n nodes.some(\n (node) =>\n selectedNodes.includes(node.id) &&\n node.children.some((child) => child.id === id),\n )\n );\n}\n"],"names":["$9bqpz$macrostrathyper","forceSimulation","$9bqpz$forceSimulation","forceLink","$9bqpz$forceLink","forceManyBody","$9bqpz$forceManyBody","forceCenter","$9bqpz$forceCenter","forceCollide","$9bqpz$forceCollide","useState","$9bqpz$useState","useEffect","$9bqpz$useEffect","Spinner","$9bqpz$Spinner","Switch","$9bqpz$Switch","ErrorBoundary","$9bqpz$ErrorBoundary","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$eedTh","$9wFEx","$edvRb","$8732cb0ae0ae3dfd$var$h","styled","a","__esModule","default","$8732cb0ae0ae3dfd$export$6a7fe3ef90e8d566","props","tree","width","height","dispatch","selectedNodes","nodes","setNodes","links","setLinks","showLabels","setShowLabels","edges","treeToGraph","nodesMap","Map","map","d","source","get","target","dest","strength","simulation","force","radius","on","console","log","stop","description","style","className","label","checked","onChange","e","x1","x","y1","y","x2","y2","stroke","active","includes","highlighted","length","some","node","children","child","getTagStyle","color","cx","cy","r","fill","backgroundColor","onClick","stopPropagation","type","payload","ids","strokeWidth","if","name","GraphView"],"version":3,"file":"feedback-components.571ee23c.js.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- import"./feedback-components.794f429b.js";import t from"classnames";import{Tag as e}from"@blueprintjs/core";import{asChromaColor as n}from"@macrostrat/color-utils";import a from"@macrostrat/hyper";import{useDarkMode as r}from"@macrostrat/ui-components";function o(t,e,n,a){Object.defineProperty(t,e,{get:n,set:a,enumerable:!0,configurable:!0})}var i=globalThis,l={},c={},s=i.parcelRequirea149;null==s&&((s=function(t){if(t in l)return l[t].exports;if(t in c){var e=c[t];delete c[t];var n={id:t,exports:{}};return l[t]=n,e.call(n.exports,n,n.exports),n.exports}var a=Error("Cannot find module '"+t+"'");throw a.code="MODULE_NOT_FOUND",a}).register=function(t,e){c[t]=e},i.parcelRequirea149=s),s.register;var p={};o(p,"buildHighlights",()=>h),o(p,"enhanceData",()=>f),o(p,"getTagStyle",()=>m),o(p,"ExtractionContext",()=>g),o(p,"ModelInfo",()=>b),o(p,"EntityTag",()=>x);var d=s("2ptYq");let u=a.styled(d&&d.__esModule?d.default:d);function h(t,e){let n=[],a=[];for(let r of(null!=e&&(a=[e.id,...e.parents??[]]),t))n.push({start:r.indices[0],end:r.indices[1],text:r.name,backgroundColor:r.type?.color,tag:r.type?.name??"lith",id:r.id,parents:a}),n.push(...h(r.children??[],r));return n}function f(t,e,a){return{...t,model:e.get(t.model_id),entities:t.entities?.map(t=>(function t(e,a){return{...e,type:function(t,e=!1){let a=n(t.color??"#fff").brighten(e?1:2);return{...t,color:a.css()}}(a.get(e.type),null!=e.match),children:e.children?.map(e=>t(e,a))}})(t,a))}}function m(t,e){let a=n(t??"#fff"),{highlighted:o=!0,inDarkMode:i=r().isEnabled,active:l=!1}=e,c=o?.8:.5,s=o?.8:.2;l&&(c=1,s=1);let p="black",d=l?"#000":a.mix(p,c).hex(),u=o?a.mix(p,c/1.1).hex():"transparent",h=l?a.alpha(s).hex():function(t){let e=r().isEnabled?"#000000":"#ffffff",n=parseInt(t.slice(1,3),16),a=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16),i=parseInt(t.slice(7,9),16)/255,l=parseInt(e.slice(1,3),16),c=parseInt(e.slice(3,5),16),s=parseInt(e.slice(5,7),16),p=(t,e)=>Math.round((1-i)*e+i*t),d=p(n,l),u=p(a,c),h=p(o,s);return"#"+d.toString(16).padStart(2,"0")+u.toString(16).padStart(2,"0")+h.toString(16).padStart(2,"0")}(a.alpha(s).hex());return i||"#ffffff"!==h||(console.log("Adjusting background color for light mode:",h),h="#f0f0f0"),{color:d,backgroundColor:h,boxSizing:"border-box",borderStyle:"solid",borderColor:u,borderWidth:"1.5px",fontWeight:l?"bold":"normal",fontSize:"0.9em"}}function g({data:t,entityTypes:e,matchComponent:n}){let a=h(t.entities,null);return u("div",[u("p",u($,{text:t.paragraph_text,highlights:a})),u(b,{data:t.model}),u("ul.entities",t.entities.map(t=>u(y,{data:t,matchComponent:n})))])}function b({data:t}){return u("p.model-name",["Model: ",u("code.bp5-code",t.name)])}function x({data:n,highlighted:a=!0,active:r=!1,onClickType:o,matchComponent:i=null}){let{name:l,type:c,match:s}=n,p=t({matched:null!=s,type:n.type?.name??"lith"},"entity"),d=m(c?.color,{highlighted:a,active:r}),h=null;return null!=s&&null!=i&&(h=u(i,{data:s})),u(e,{style:d,className:p},[u("span.entity-name",l)," ",u("code.entity-type.bp5-code",{onClick(t){r&&null!=o&&(o(c),t.stopPropagation())}},[c?.name,h])])}function y({data:t,matchComponent:e=null}){let n=t.children??[];return u("li.entity-row",[u(x,{data:t,matchComponent:e}),u.if(n.length>0)([u("ul.children",n.map(t=>u(y,{data:t,matchComponent:e})))])])}function $(t){let{text:e,highlights:n=[]}=t,a=[],r=0,o=n.sort((t,e)=>t.start-e.start);for(let t of o.map((t,e)=>{if(0===e)return t;let n=o[e-1];return t.start<n.end&&(t.start=n.end),t})){let{start:n,end:o,...i}=t;a.push(e.slice(r,n)),a.push(u("span.highlight",{style:i},e.slice(n,o))),r=o}return a.push(e.slice(r)),u("span",a)}export{h as buildHighlights,f as enhanceData,m as getTagStyle,g as ExtractionContext,b as ModelInfo,x as EntityTag};
2
- //# sourceMappingURL=feedback-components.8b03e8be.js.map
@@ -1 +0,0 @@
1
- {"mappings":"A,M,oD,A,Q,M,Y,A,Q,O,C,K,mB,A,Q,iB,C,K,yB,A,Q,M,mB,A,Q,e,C,K,2B,C,S,E,C,C,C,C,C,C,C,E,O,c,C,E,E,C,I,E,I,E,W,C,E,a,C,C,E,C,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,C,C,E,C,C,E,E,iB,C,G,E,Q,C,I,E,C,E,E,E,kB,I,G,E,E,c,I,G,E,E,c,I,G,E,E,oB,I,G,E,E,Y,I,G,E,E,Y,I,G,I,E,E,SCWA,IAAM,EAAI,AAAA,EAAM,MAAM,C,AAAC,G,AAAA,E,U,C,AAAA,E,O,CAAA,GAEhB,SAAS,EACd,CAAqB,CACrB,CAAwB,EAExB,IAAI,EAAa,EAAE,CACf,EAAU,EAAE,CAKhB,IAAK,IAAM,KAJP,AAAU,MAAV,GACF,CAAA,EAAU,CAAC,EAAO,EAAE,IAAM,EAAO,OAAO,EAAI,EAAE,CAAE,AAAA,EAG7B,GACnB,EAAW,IAAI,CAAC,CACd,MAAO,EAAO,OAAO,CAAC,EAAE,CACxB,IAAK,EAAO,OAAO,CAAC,EAAE,CACtB,KAAM,EAAO,IAAI,CACjB,gBAAiB,EAAO,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GAAG,CACxB,EACE,cACA,EAAS,GAAG,CAAC,AAAC,GAAM,EAAE,EAAgB,CAAE,KAAM,EAAG,eAAA,CAAe,KAEnE,EACF,CACH,CAEA,SAAS,EAAgB,CAAgD,EACvE,GAAM,CAAA,KAAE,CAAI,CAAA,WAAE,EAAa,EAAE,CAAE,CAAG,EAC5B,EAAQ,EAAE,CACZ,EAAQ,EAEN,EAAmB,EAAW,IAAI,CAAC,CAAC,EAAG,IAAM,EAAE,KAAK,CAAG,EAAE,KAAK,EAUpE,IAAK,IAAM,KAToB,EAAiB,GAAG,CAAC,CAAC,EAAW,KAC9D,GAAI,AAAM,IAAN,EAAS,OAAO,EACpB,IAAM,EAAO,CAAgB,CAAC,EAAI,EAAE,CAIpC,OAHI,EAAU,KAAK,CAAG,EAAK,GAAG,EAC5B,CAAA,EAAU,KAAK,CAAG,EAAK,GAAG,AAAH,EAElB,CACT,GAEgD,CAC9C,GAAM,CAAE,MAAO,CAAC,CAAA,IAAE,CAAG,CAAE,GAAG,EAAM,CAAG,EACnC,EAAM,IAAI,CAAC,EAAK,KAAK,CAAC,EAAO,IAC7B,EAAM,IAAI,CAAC,EAAE,iBAAkB,CAAE,MAAO,CAAK,EAAG,EAAK,KAAK,CAAC,EAAG,KAC9D,EAAQ,CACV,CAEA,OADA,EAAM,IAAI,CAAC,EAAK,KAAK,CAAC,IACf,EAAE,OAAQ,EACnB,Q,K,e,C,K,W,C,K,W,C,K,iB,C,K,S,C,K,S","sources":["<anon>","packages/feedback-components/src/extractions/index.ts"],"sourcesContent":["import \"./feedback-components.794f429b.js\";\nimport $78C1X$classnames from \"classnames\";\nimport {Tag as $78C1X$Tag} from \"@blueprintjs/core\";\nimport {asChromaColor as $78C1X$asChromaColor} from \"@macrostrat/color-utils\";\nimport $78C1X$macrostrathyper from \"@macrostrat/hyper\";\nimport {useDarkMode as $78C1X$useDarkMode} from \"@macrostrat/ui-components\";\n\n\nfunction $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$export(e, n, v, s) {\n Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});\n}\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirea149\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirea149\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\nvar $8c534c0378e15a46$exports = {};\n\n$parcel$export($8c534c0378e15a46$exports, \"buildHighlights\", () => $8c534c0378e15a46$export$c4b91360064ad200);\n$parcel$export($8c534c0378e15a46$exports, \"enhanceData\", () => $8c534c0378e15a46$export$d60b563f571177d);\n$parcel$export($8c534c0378e15a46$exports, \"getTagStyle\", () => $8c534c0378e15a46$export$35baa338324d8550);\n$parcel$export($8c534c0378e15a46$exports, \"ExtractionContext\", () => $8c534c0378e15a46$export$2b07158757c249e0);\n$parcel$export($8c534c0378e15a46$exports, \"ModelInfo\", () => $8c534c0378e15a46$export$4eb2a0ce903ce967);\n$parcel$export($8c534c0378e15a46$exports, \"EntityTag\", () => $8c534c0378e15a46$export$117e56c71b172cde);\n\nvar $2ptYq = parcelRequire(\"2ptYq\");\n\n\n\n\n\nconst $8c534c0378e15a46$var$h = (0, $78C1X$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($2ptYq))));\nfunction $8c534c0378e15a46$export$c4b91360064ad200(entities, parent) {\n let highlights = [];\n let parents = [];\n if (parent != null) parents = [\n parent.id,\n ...parent.parents ?? []\n ];\n for (const entity of entities){\n highlights.push({\n start: entity.indices[0],\n end: entity.indices[1],\n text: entity.name,\n backgroundColor: entity.type?.color,\n tag: entity.type?.name ?? \"lith\",\n id: entity.id,\n parents: parents\n });\n highlights.push(...$8c534c0378e15a46$export$c4b91360064ad200(entity.children ?? [], entity));\n }\n return highlights;\n}\nfunction $8c534c0378e15a46$export$d60b563f571177d(extractionData, models, entityTypes) {\n return {\n ...extractionData,\n model: models.get(extractionData.model_id),\n entities: extractionData.entities?.map((d)=>$8c534c0378e15a46$var$enhanceEntity(d, entityTypes))\n };\n}\nfunction $8c534c0378e15a46$export$35baa338324d8550(baseColor, options) {\n const _baseColor = (0, $78C1X$asChromaColor)(baseColor ?? \"#fff\");\n const { highlighted: highlighted = true, inDarkMode: inDarkMode = (0, $78C1X$useDarkMode)().isEnabled, active: active = false } = options;\n let mixAmount = highlighted ? 0.8 : 0.5;\n let backgroundAlpha = highlighted ? 0.8 : 0.2;\n if (active) {\n mixAmount = 1;\n backgroundAlpha = 1;\n }\n const mixTarget = \"black\";\n const color = active ? \"#000\" : _baseColor.mix(mixTarget, mixAmount).hex();\n const borderColor = highlighted ? _baseColor.mix(mixTarget, mixAmount / 1.1).hex() : \"transparent\";\n let backgroundColor = active ? _baseColor.alpha(backgroundAlpha).hex() : $8c534c0378e15a46$var$normalizeColor(_baseColor.alpha(backgroundAlpha).hex());\n // handle white backgrounds in light mode\n if (!inDarkMode && backgroundColor === \"#ffffff\") {\n console.log(\"Adjusting background color for light mode:\", backgroundColor);\n backgroundColor = \"#f0f0f0\";\n }\n return {\n color: color,\n backgroundColor: backgroundColor,\n boxSizing: \"border-box\",\n borderStyle: \"solid\",\n borderColor: borderColor,\n borderWidth: \"1.5px\",\n fontWeight: active ? \"bold\" : \"normal\",\n fontSize: \"0.9em\"\n };\n}\nfunction $8c534c0378e15a46$var$enhanceEntity(entity, entityTypes) {\n return {\n ...entity,\n type: $8c534c0378e15a46$var$addColor(entityTypes.get(entity.type), entity.match != null),\n children: entity.children?.map((d)=>$8c534c0378e15a46$var$enhanceEntity(d, entityTypes))\n };\n}\nfunction $8c534c0378e15a46$var$addColor(entityType, match = false) {\n const color = (0, $78C1X$asChromaColor)(entityType.color ?? \"#fff\").brighten(match ? 1 : 2);\n return {\n ...entityType,\n color: color.css()\n };\n}\nfunction $8c534c0378e15a46$export$2b07158757c249e0({ data: data, entityTypes: entityTypes, matchComponent: matchComponent }) {\n const highlights = $8c534c0378e15a46$export$c4b91360064ad200(data.entities, null);\n return $8c534c0378e15a46$var$h(\"div\", [\n $8c534c0378e15a46$var$h(\"p\", $8c534c0378e15a46$var$h($8c534c0378e15a46$var$HighlightedText, {\n text: data.paragraph_text,\n highlights: highlights\n })),\n $8c534c0378e15a46$var$h($8c534c0378e15a46$export$4eb2a0ce903ce967, {\n data: data.model\n }),\n $8c534c0378e15a46$var$h(\"ul.entities\", data.entities.map((d)=>$8c534c0378e15a46$var$h($8c534c0378e15a46$var$ExtractionInfo, {\n data: d,\n matchComponent: matchComponent\n })))\n ]);\n}\nfunction $8c534c0378e15a46$export$4eb2a0ce903ce967({ data: data }) {\n return $8c534c0378e15a46$var$h(\"p.model-name\", [\n \"Model: \",\n $8c534c0378e15a46$var$h(\"code.bp5-code\", data.name)\n ]);\n}\nfunction $8c534c0378e15a46$export$117e56c71b172cde({ data: data, highlighted: highlighted = true, active: active = false, onClickType: onClickType, matchComponent: matchComponent = null }) {\n const { name: name, type: type, match: match } = data;\n const className = (0, $78C1X$classnames)({\n matched: match != null,\n type: data.type?.name ?? \"lith\"\n }, \"entity\");\n const style = $8c534c0378e15a46$export$35baa338324d8550(type?.color, {\n highlighted: highlighted,\n active: active\n });\n let _matchLink = null;\n if (match != null && matchComponent != null) _matchLink = $8c534c0378e15a46$var$h(matchComponent, {\n data: match\n });\n return $8c534c0378e15a46$var$h((0, $78C1X$Tag), {\n style: style,\n className: className\n }, [\n $8c534c0378e15a46$var$h(\"span.entity-name\", name),\n \" \",\n $8c534c0378e15a46$var$h(\"code.entity-type.bp5-code\", {\n onClick (evt) {\n if (active && onClickType != null) {\n onClickType(type);\n evt.stopPropagation();\n }\n }\n }, [\n type?.name,\n _matchLink\n ])\n ]);\n}\nfunction $8c534c0378e15a46$var$ExtractionInfo({ data: data, matchComponent: matchComponent = null }) {\n const children = data.children ?? [];\n return $8c534c0378e15a46$var$h(\"li.entity-row\", [\n $8c534c0378e15a46$var$h($8c534c0378e15a46$export$117e56c71b172cde, {\n data: data,\n matchComponent: matchComponent\n }),\n $8c534c0378e15a46$var$h.if(children.length > 0)([\n $8c534c0378e15a46$var$h(\"ul.children\", children.map((d)=>$8c534c0378e15a46$var$h($8c534c0378e15a46$var$ExtractionInfo, {\n data: d,\n matchComponent: matchComponent\n })))\n ])\n ]);\n}\nfunction $8c534c0378e15a46$var$HighlightedText(props) {\n const { text: text, highlights: highlights = [] } = props;\n const parts = [];\n let start = 0;\n const sortedHighlights = highlights.sort((a, b)=>a.start - b.start);\n const deconflictedHighlights = sortedHighlights.map((highlight, i)=>{\n if (i === 0) return highlight;\n const prev = sortedHighlights[i - 1];\n if (highlight.start < prev.end) highlight.start = prev.end;\n return highlight;\n });\n for (const highlight of deconflictedHighlights){\n const { start: s, end: end, ...rest } = highlight;\n parts.push(text.slice(start, s));\n parts.push($8c534c0378e15a46$var$h(\"span.highlight\", {\n style: rest\n }, text.slice(s, end)));\n start = end;\n }\n parts.push(text.slice(start));\n return $8c534c0378e15a46$var$h(\"span\", parts);\n}\nfunction $8c534c0378e15a46$var$normalizeColor(hex8) {\n const background = (0, $78C1X$useDarkMode)().isEnabled ? \"#000000\" : \"#ffffff\";\n const r = parseInt(hex8.slice(1, 3), 16);\n const g = parseInt(hex8.slice(3, 5), 16);\n const b = parseInt(hex8.slice(5, 7), 16);\n const a = parseInt(hex8.slice(7, 9), 16) / 255;\n const bgR = parseInt(background.slice(1, 3), 16);\n const bgG = parseInt(background.slice(3, 5), 16);\n const bgB = parseInt(background.slice(5, 7), 16);\n const blend = (fg, bg)=>Math.round((1 - a) * bg + a * fg);\n const blendedR = blend(r, bgR);\n const blendedG = blend(g, bgG);\n const blendedB = blend(b, bgB);\n return \"#\" + blendedR.toString(16).padStart(2, \"0\") + blendedG.toString(16).padStart(2, \"0\") + blendedB.toString(16).padStart(2, \"0\");\n}\nfunction $8c534c0378e15a46$var$isHighlighted(id, selectedNodes, nodes) {\n if (selectedNodes?.length === 0) return true;\n return selectedNodes?.includes(id) || nodes?.some((node)=>selectedNodes?.includes(node.id) && node.children.some((child)=>child.id === id));\n}\n\n\nexport {$8c534c0378e15a46$export$c4b91360064ad200 as buildHighlights, $8c534c0378e15a46$export$d60b563f571177d as enhanceData, $8c534c0378e15a46$export$35baa338324d8550 as getTagStyle, $8c534c0378e15a46$export$2b07158757c249e0 as ExtractionContext, $8c534c0378e15a46$export$4eb2a0ce903ce967 as ModelInfo, $8c534c0378e15a46$export$117e56c71b172cde as EntityTag};\n//# sourceMappingURL=feedback-components.8b03e8be.js.map\n","import styles from \"./main.module.sass\";\nimport classNames from \"classnames\";\nimport { Tag } from \"@blueprintjs/core\";\nimport type { Entity, EntityExt, Highlight, EntityType } from \"./types\";\nimport { CSSProperties } from \"react\";\nimport { asChromaColor } from \"@macrostrat/color-utils\";\nimport hyper from \"@macrostrat/hyper\";\nimport { useDarkMode } from \"@macrostrat/ui-components\";\n\nexport type { Entity, EntityExt };\n\nconst h = hyper.styled(styles);\n\nexport function buildHighlights(\n entities: EntityExt[],\n parent: EntityExt | null,\n): Highlight[] {\n let highlights = [];\n let parents = [];\n if (parent != null) {\n parents = [parent.id, ...(parent.parents ?? [])];\n }\n\n for (const entity of entities) {\n highlights.push({\n start: entity.indices[0],\n end: entity.indices[1],\n text: entity.name,\n backgroundColor: entity.type?.color,\n tag: entity.type?.name ?? \"lith\",\n id: entity.id,\n parents,\n });\n highlights.push(...buildHighlights(entity.children ?? [], entity));\n }\n return highlights;\n}\n\nexport function enhanceData(extractionData, models, entityTypes) {\n return {\n ...extractionData,\n model: models.get(extractionData.model_id),\n entities: extractionData.entities?.map((d) =>\n enhanceEntity(d, entityTypes),\n ),\n };\n}\n\nexport function getTagStyle(\n baseColor: string,\n options: { highlighted?: boolean; inDarkMode?: boolean; active?: boolean },\n): CSSProperties {\n const _baseColor = asChromaColor(baseColor ?? \"#fff\");\n const {\n highlighted = true,\n inDarkMode = useDarkMode().isEnabled,\n active = false,\n } = options;\n\n let mixAmount = highlighted ? 0.8 : 0.5;\n let backgroundAlpha = highlighted ? 0.8 : 0.2;\n\n if (active) {\n mixAmount = 1;\n backgroundAlpha = 1;\n }\n\n const mixTarget = \"black\";\n\n const color = active ? \"#000\" : _baseColor.mix(mixTarget, mixAmount).hex();\n const borderColor = highlighted\n ? _baseColor.mix(mixTarget, mixAmount / 1.1).hex()\n : \"transparent\";\n\n let backgroundColor = active\n ? _baseColor.alpha(backgroundAlpha).hex()\n : normalizeColor(_baseColor.alpha(backgroundAlpha).hex());\n\n // handle white backgrounds in light mode\n if (!inDarkMode && backgroundColor === \"#ffffff\") {\n console.log(\"Adjusting background color for light mode:\", backgroundColor);\n backgroundColor = \"#f0f0f0\";\n }\n\n return {\n color,\n backgroundColor,\n boxSizing: \"border-box\",\n borderStyle: \"solid\",\n borderColor,\n borderWidth: \"1.5px\",\n fontWeight: active ? \"bold\" : \"normal\",\n fontSize: \"0.9em\",\n };\n}\n\nfunction enhanceEntity(\n entity: Entity,\n entityTypes: Map<number, EntityType>,\n): EntityExt {\n return {\n ...entity,\n type: addColor(entityTypes.get(entity.type), entity.match != null),\n children: entity.children?.map((d) => enhanceEntity(d, entityTypes)),\n };\n}\n\nfunction addColor(entityType: EntityType, match = false) {\n const color = asChromaColor(entityType.color ?? \"#fff\").brighten(\n match ? 1 : 2,\n );\n\n return { ...entityType, color: color.css() };\n}\n\nexport function ExtractionContext({\n data,\n entityTypes,\n matchComponent,\n}: {\n data: any;\n entityTypes: Map<number, EntityType>;\n matchComponent: MatchComponent;\n}) {\n const highlights = buildHighlights(data.entities, null);\n\n return h(\"div\", [\n h(\"p\", h(HighlightedText, { text: data.paragraph_text, highlights })),\n h(ModelInfo, { data: data.model }),\n h(\n \"ul.entities\",\n data.entities.map((d) => h(ExtractionInfo, { data: d, matchComponent })),\n ),\n ]);\n}\n\nexport function ModelInfo({ data }) {\n return h(\"p.model-name\", [\"Model: \", h(\"code.bp5-code\", data.name)]);\n}\n\nexport type MatchComponent = (props: { data: any }) => any;\n\ntype EntityTagProps = {\n data: EntityExt;\n highlighted?: boolean;\n active?: boolean;\n onClickType?: (type: EntityType) => void;\n matchComponent?: MatchComponent;\n};\n\nexport function EntityTag({\n data,\n highlighted = true,\n active = false,\n onClickType,\n matchComponent = null,\n}: EntityTagProps) {\n const { name, type, match } = data;\n\n const className = classNames(\n {\n matched: match != null,\n type: data.type?.name ?? \"lith\",\n },\n \"entity\",\n );\n\n const style = getTagStyle(type?.color, { highlighted, active });\n\n let _matchLink = null;\n if (match != null && matchComponent != null) {\n _matchLink = h(matchComponent, { data: match });\n }\n\n return h(Tag, { style, className }, [\n h(\"span.entity-name\", name),\n \" \",\n h(\n \"code.entity-type.bp5-code\",\n {\n onClick(evt) {\n if (active && onClickType != null) {\n onClickType(type);\n evt.stopPropagation();\n }\n },\n },\n [type?.name, _matchLink],\n ),\n ]);\n}\n\nfunction ExtractionInfo({\n data,\n matchComponent = null,\n}: {\n data: EntityExt;\n matchComponent: MatchComponent;\n}) {\n const children = data.children ?? [];\n\n return h(\"li.entity-row\", [\n h(EntityTag, { data, matchComponent }),\n h.if(children.length > 0)([\n h(\n \"ul.children\",\n children.map((d) => h(ExtractionInfo, { data: d, matchComponent })),\n ),\n ]),\n ]);\n}\n\nfunction HighlightedText(props: { text: string; highlights: Highlight[] }) {\n const { text, highlights = [] } = props;\n const parts = [];\n let start = 0;\n\n const sortedHighlights = highlights.sort((a, b) => a.start - b.start);\n const deconflictedHighlights = sortedHighlights.map((highlight, i) => {\n if (i === 0) return highlight;\n const prev = sortedHighlights[i - 1];\n if (highlight.start < prev.end) {\n highlight.start = prev.end;\n }\n return highlight;\n });\n\n for (const highlight of deconflictedHighlights) {\n const { start: s, end, ...rest } = highlight;\n parts.push(text.slice(start, s));\n parts.push(h(\"span.highlight\", { style: rest }, text.slice(s, end)));\n start = end;\n }\n parts.push(text.slice(start));\n return h(\"span\", parts);\n}\n\nfunction normalizeColor(hex8) {\n const background = useDarkMode().isEnabled ? \"#000000\" : \"#ffffff\";\n\n const r = parseInt(hex8.slice(1, 3), 16);\n const g = parseInt(hex8.slice(3, 5), 16);\n const b = parseInt(hex8.slice(5, 7), 16);\n const a = parseInt(hex8.slice(7, 9), 16) / 255;\n\n const bgR = parseInt(background.slice(1, 3), 16);\n const bgG = parseInt(background.slice(3, 5), 16);\n const bgB = parseInt(background.slice(5, 7), 16);\n\n const blend = (fg, bg) => Math.round((1 - a) * bg + a * fg);\n\n const blendedR = blend(r, bgR);\n const blendedG = blend(g, bgG);\n const blendedB = blend(b, bgB);\n\n return (\n \"#\" +\n blendedR.toString(16).padStart(2, \"0\") +\n blendedG.toString(16).padStart(2, \"0\") +\n blendedB.toString(16).padStart(2, \"0\")\n );\n}\n\nfunction isHighlighted(id: number, selectedNodes: number[], nodes: any[]) {\n if (selectedNodes?.length === 0) return true;\n return (\n selectedNodes?.includes(id) ||\n nodes?.some(\n (node) =>\n selectedNodes?.includes(node.id) &&\n node.children.some((child) => child.id === id),\n )\n );\n}\n"],"names":["$78C1X$classnames","Tag","$78C1X$Tag","asChromaColor","$78C1X$asChromaColor","$78C1X$macrostrathyper","useDarkMode","$78C1X$useDarkMode","$parcel$export","e","n","v","s","Object","defineProperty","get","set","enumerable","configurable","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$8c534c0378e15a46$exports","$8c534c0378e15a46$export$c4b91360064ad200","$8c534c0378e15a46$export$d60b563f571177d","$8c534c0378e15a46$export$35baa338324d8550","$8c534c0378e15a46$export$2b07158757c249e0","$8c534c0378e15a46$export$4eb2a0ce903ce967","$8c534c0378e15a46$export$117e56c71b172cde","$2ptYq","$8c534c0378e15a46$var$h","styled","a","__esModule","default","entities","parent","highlights","parents","entity","push","start","indices","end","text","name","backgroundColor","type","color","tag","children","extractionData","models","entityTypes","model","model_id","map","d","$8c534c0378e15a46$var$enhanceEntity","$8c534c0378e15a46$var$addColor","entityType","match","brighten","css","baseColor","options","_baseColor","highlighted","inDarkMode","isEnabled","active","mixAmount","backgroundAlpha","mixTarget","mix","hex","borderColor","alpha","$8c534c0378e15a46$var$normalizeColor","hex8","background","r","parseInt","slice","g","b","bgR","bgG","bgB","blend","fg","bg","Math","round","blendedR","blendedG","blendedB","toString","padStart","console","log","boxSizing","borderStyle","borderWidth","fontWeight","fontSize","data","matchComponent","$8c534c0378e15a46$var$HighlightedText","paragraph_text","$8c534c0378e15a46$var$ExtractionInfo","onClickType","className","matched","style","_matchLink","onClick","evt","stopPropagation","if","length","props","parts","sortedHighlights","sort","highlight","i","prev","rest","buildHighlights","enhanceData","getTagStyle","ExtractionContext","ModelInfo","EntityTag"],"version":3,"file":"feedback-components.8b03e8be.js.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- import{useReducer as e,createContext as t,useContext as n}from"react";import l from"immutability-helper";var r,d=((r={}).Tree="tree",r.Graph="graph",r);function i(t,n){let l=n.values().next().value;return e(o,{initialTree:t,tree:t,selectedNodes:[],entityTypesMap:n,selectedEntityType:l,lastInternalId:0,isSelectingEntityType:!1,viewMode:"tree"})}let a=t(null);function s(){let e=n(a);if(null==e)throw Error("No dispatch context available");return e}function o(e,t){switch(t.type){case"add-entity-type":{let{name:n,description:l,color:r}=t.payload,d=e.lastInternalId-1,i={id:d,name:n,description:""===l?null:l,color:r},a=new Map(e.entityTypesMap);return a.set(d,i),{...e,entityTypesMap:a,selectedEntityType:i,lastInternalId:d}}case"update-entity-type":{let{id:n,name:l,description:r,color:d}=t.payload,i=new Map(e.entityTypesMap),a=i.get(n);if(!a)return console.warn(`Entity type with id ${n} not found`),e;let s={...a,name:l,description:""===r?null:r,color:d};i.set(n,s);let o=h(e.tree,a,s);return{...e,tree:o,entityTypesMap:i,selectedEntityType:s}}case"select-range":let n=t.payload.ids,r=n[0],d=n[1],i=function(e){let t=[];return!function e(n){for(let l of n)t.push(l),Array.isArray(l.children)&&l.children.length>0&&e(l.children)}(e),t.sort((e,t)=>e.indices[0]-t.indices[0])}(e.tree),a=i.findIndex(e=>e.id===r),s=i.findIndex(e=>e.id===d),o=i.slice(a,s+1);return console.log("Selecting range:",o),{...e,selectedNodes:o.map(e=>e.id)};case"move-node":let[u,g]=y(e.tree,t.payload.dragIds),T=[];t.payload.parentId&&(T=p(u,t.payload.parentId)).push("children");let m=c(T,{$splice:[[t.payload.index,0,...g]]});return{...e,tree:l(u,m)};case"delete-node":let[$,x]=y(e.tree,t.payload.ids),I=x.flatMap(e=>e.children??[]).filter(e=>!function e(t,n){for(let l of t)if(l.id==n)return!0;else if(l.children&&e(l.children,n))return!0;return!1}($,e.id));return{...e,tree:[...$,...I],selectedNodes:e.selectedNodes.filter(e=>!t.payload.ids.includes(e))};case"select-node":let{ids:M}=t.payload,N=t.payload.ids.length>0?f(e.tree,M[0])?.type:null;return{...e,selectedNodes:M,selectedEntityType:N};case"toggle-node-selected":let w=t.payload.ids.filter(t=>!e.selectedNodes.includes(t)),E=e.selectedNodes.filter(e=>!t.payload.ids.includes(e)),b=t.payload.ids.length>0?f(e.tree,t.payload.ids[0])?.type:null;return{...e,selectedNodes:[...E,...w],selectedEntityType:b};case"create-node":let v=e.lastInternalId-1,{text:S,start:C,end:D}=t.payload,A={id:v,name:S,children:[],indices:[C,D],type:e.selectedEntityType};return{...e,tree:[...e.tree,A],selectedNodes:[v],lastInternalId:v};case"delete-entity-type":{console.log("Deleting entity type:",t.payload.id);let{id:n}=t.payload,l=new Map(e.entityTypesMap),r=l.get(n);l.delete(n);let d=l.values().next().value,i=h(e.tree,r,d);return{...e,tree:i,entityTypesMap:l,selectedNodes:[]}}case"toggle-entity-type-selector":return{...e,isSelectingEntityType:t.payload??!e.isSelectingEntityType};case"select-entity-type":{let n=e.tree;for(let r of e.selectedNodes)n=l(n,c(p(e.tree,r),{type:{$set:t.payload}}));return{...e,tree:n,selectedEntityType:t.payload}}case"deselect":return{...e,selectedNodes:[]};case"reset":return{...e,tree:e.initialTree,selectedNodes:[]};case"set-view-mode":return{...e,viewMode:t.payload}}}function c(e,t){let n=t;for(let t=e.length-1;t>=0;t--)n={[e[t]]:n};return n}function p(e,t){for(let n=0;n<e.length;n++)if(e[n].id==t)return[n];else if(e[n].children){let l=p(e[n].children,t);if(null!=l)return[n,"children",...l]}return null}function y(e,t){let n=[],l=[];for(let r of e)if(t.includes(r.id))l.push(r);else{if(r.children){let[e,n]=y(r.children,t);r={...r,children:e},l.push(...n)}n.push(r)}return[n,l]}function u(e){let t=[],n=[],l=new Map;for(let r of e){if(l.has(r.id))continue;let{indices:e,id:d,name:i,type:a,children:s}=r,o={id:d,type:a.id,color:a.color,name:i,txt_range:[e],reasoning:null,match:r.match,children:s};if(l.set(r.id,r),t.push(o),r.children){for(let e of r.children)n.push({source:r.id,dest:e.id});let{nodes:e,edges:l}=u(r.children);t.push(...e),n.push(...l)}}return{nodes:t,edges:n}}function f(e,t){for(let n of e){if(n.id===t)return n;if(n.children){let e=f(n.children,t);if(e)return e}}return null}function h(e,t,n){return e.map(e=>(function(e,t,n){let l=e.type.id===t.id?n:e.type;return{...e,type:l,children:e.children?h(e.children,t,n):[]}})(e,t,n))}export{d as ViewMode,i as useUpdatableTree,a as TreeDispatchContext,s as useTreeDispatch,u as treeToGraph};
2
- //# sourceMappingURL=feedback-components.b7946db4.js.map
@@ -1 +0,0 @@
1
- {"mappings":"A,O,c,C,C,iB,C,C,c,C,K,O,A,Q,M,qB,CCKO,IAAK,EAAA,G,CAAA,E,C,G,I,C,O,E,K,C,QAAA,GAiDL,SAAS,EACd,CAAuB,CACvB,CAAoC,EAIpC,IAAM,EAA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AE,CAAO,CAAE,CAAW,EAChD,IAAM,EAAO,EAAK,IAAI,CAAC,EAAE,GAAK,EAAQ,EAAE,CAAG,EAAc,EAAK,IAAI,CAElE,MAAO,CACL,GAAG,CAAI,CACP,KAAA,EACA,SAAU,EAAK,QAAQ,CACnB,EAAgB,EAAK,QAAQ,CAAE,EAAS,GACxC,EAAE,AACR,CACF,CAAA,EAb2C,EAAM,EAAS,GAC1D,Q,K,Q,C,K,gB,C,K,mB,C,K,e,C,K,W","sources":["<anon>","packages/feedback-components/src/feedback/edit-state.ts"],"sourcesContent":["import {useReducer as $eGztG$useReducer, createContext as $eGztG$createContext, useContext as $eGztG$useContext} from \"react\";\nimport $eGztG$immutabilityhelper from \"immutability-helper\";\n\n\n\nvar $330ae695507d96f5$export$53ec42062883b2d4 = /*#__PURE__*/ function(ViewMode) {\n ViewMode[\"Tree\"] = \"tree\";\n ViewMode[\"Graph\"] = \"graph\";\n return ViewMode;\n}({});\nfunction $330ae695507d96f5$export$911bb4b9c8065d3d(initialTree, entityTypes) {\n // Get the first entity type\n // issue: grabs second entity instead of selected one\n const type = entityTypes.values().next().value;\n return (0, $eGztG$useReducer)($330ae695507d96f5$var$treeReducer, {\n initialTree: initialTree,\n tree: initialTree,\n selectedNodes: [],\n entityTypesMap: entityTypes,\n selectedEntityType: type,\n lastInternalId: 0,\n isSelectingEntityType: false,\n viewMode: \"tree\"\n });\n}\nconst $330ae695507d96f5$export$e5ce04c5b3f58533 = (0, $eGztG$createContext)(null);\nfunction $330ae695507d96f5$export$e1068f2d1c68f87e() {\n const dispatch = (0, $eGztG$useContext)($330ae695507d96f5$export$e5ce04c5b3f58533);\n if (dispatch == null) throw new Error(\"No dispatch context available\");\n return dispatch;\n}\nfunction $330ae695507d96f5$var$treeReducer(state, action) {\n switch(action.type){\n case \"add-entity-type\":\n {\n // Add a new entity type to the map\n const { name: name, description: description, color: color } = action.payload;\n const newId = state.lastInternalId - 1;\n const newType = {\n id: newId,\n name: name,\n description: description === \"\" ? null : description,\n color: color\n };\n const newEntityTypesMap = new Map(state.entityTypesMap);\n newEntityTypesMap.set(newId, newType);\n return {\n ...state,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: newType,\n lastInternalId: newId\n };\n }\n case \"update-entity-type\":\n {\n // Update an existing entity type in the map\n const { id: id, name: name, description: description, color: color } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n if (!oldType) {\n console.warn(`Entity type with id ${id} not found`);\n return state;\n }\n const updatedType = {\n ...oldType,\n name: name,\n description: description === \"\" ? null : description,\n color: color\n };\n newEntityTypesMap.set(id, updatedType);\n // Update the tree to reflect the new type\n const newTree = $330ae695507d96f5$var$updateTreeTypes(state.tree, oldType, updatedType);\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: updatedType\n };\n }\n case \"select-range\":\n // Select a range of nodes by their IDs\n const payloadIds = action.payload.ids;\n const node1 = payloadIds[0];\n const node2 = payloadIds[1];\n // make list of nodes in order\n const allNodes = $330ae695507d96f5$var$flattenAndSort(state.tree);\n // select all nodes between node1 and node2\n const startIndex = allNodes.findIndex((node)=>node.id === node1);\n const endIndex = allNodes.findIndex((node)=>node.id === node2);\n const selectedNodes = allNodes.slice(startIndex, endIndex + 1);\n console.log(\"Selecting range:\", selectedNodes);\n return {\n ...state,\n selectedNodes: selectedNodes.map((node)=>node.id)\n };\n case \"move-node\":\n // For each node in the tree, if the node is in the dragIds, remove it from the tree and collect it\n const [newTree, removedNodes] = $330ae695507d96f5$var$removeNodes(state.tree, action.payload.dragIds);\n let keyPath = [];\n if (action.payload.parentId) {\n keyPath = $330ae695507d96f5$var$findNode(newTree, action.payload.parentId);\n keyPath.push(\"children\");\n }\n // Add removed nodes to the new tree at the correct location\n let updateSpec = $330ae695507d96f5$var$buildNestedSpec(keyPath, {\n $splice: [\n [\n action.payload.index,\n 0,\n ...removedNodes\n ]\n ]\n });\n return {\n ...state,\n tree: (0, $eGztG$immutabilityhelper)(newTree, updateSpec)\n };\n case \"delete-node\":\n // For each node in the tree, if the node is in the ids, remove it from the tree\n const [newTree2, _removedNodes] = $330ae695507d96f5$var$removeNodes(state.tree, action.payload.ids);\n // Get children of the removed nodes\n // If children are not present elsewhere in the tree, insert them\n const children = _removedNodes.flatMap((node)=>node.children ?? []).filter((child)=>!$330ae695507d96f5$var$nodeIsInTree(newTree2, child.id));\n // Reset the selection\n return {\n ...state,\n tree: [\n ...newTree2,\n ...children\n ],\n selectedNodes: state.selectedNodes.filter((id)=>!action.payload.ids.includes(id))\n };\n case \"select-node\":\n const { ids: ids } = action.payload;\n const type = action.payload.ids.length > 0 ? $330ae695507d96f5$var$findNodeById(state.tree, ids[0])?.type : null;\n return {\n ...state,\n selectedNodes: ids,\n selectedEntityType: type\n };\n // otherwise fall through to toggle-node-selected for a single ID\n case \"toggle-node-selected\":\n const nodesToAdd = action.payload.ids.filter((id)=>!state.selectedNodes.includes(id));\n const nodesToKeep = state.selectedNodes.filter((id)=>!action.payload.ids.includes(id));\n const newType = action.payload.ids.length > 0 ? $330ae695507d96f5$var$findNodeById(state.tree, action.payload.ids[0])?.type : null;\n return {\n ...state,\n selectedNodes: [\n ...nodesToKeep,\n ...nodesToAdd\n ],\n selectedEntityType: newType\n };\n case \"create-node\":\n const newId = state.lastInternalId - 1;\n const { text: text, start: start, end: end } = action.payload;\n const node = {\n id: newId,\n name: text,\n children: [],\n indices: [\n start,\n end\n ],\n type: state.selectedEntityType\n };\n return {\n ...state,\n tree: [\n ...state.tree,\n node\n ],\n selectedNodes: [\n newId\n ],\n lastInternalId: newId\n };\n case \"delete-entity-type\":\n {\n // Remove the entity type from the map\n console.log(\"Deleting entity type:\", action.payload.id);\n const { id: id } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n newEntityTypesMap.delete(id);\n const defaultType = newEntityTypesMap.values().next().value;\n const newTree = $330ae695507d96f5$var$updateTreeTypes(state.tree, oldType, defaultType);\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedNodes: []\n };\n }\n /** Entity type selection */ case \"toggle-entity-type-selector\":\n return {\n ...state,\n isSelectingEntityType: action.payload ?? !state.isSelectingEntityType\n };\n case \"select-entity-type\":\n {\n // For each selected node, update the type\n let newTree2 = state.tree;\n for (let id of state.selectedNodes){\n const keyPath = $330ae695507d96f5$var$findNode(state.tree, id);\n const nestedSpec = $330ae695507d96f5$var$buildNestedSpec(keyPath, {\n type: {\n $set: action.payload\n }\n });\n newTree2 = (0, $eGztG$immutabilityhelper)(newTree2, nestedSpec);\n }\n return {\n ...state,\n tree: newTree2,\n selectedEntityType: action.payload\n };\n }\n case \"deselect\":\n return {\n ...state,\n selectedNodes: []\n };\n case \"reset\":\n return {\n ...state,\n tree: state.initialTree,\n selectedNodes: []\n };\n case \"set-view-mode\":\n return {\n ...state,\n viewMode: action.payload\n };\n }\n}\nfunction $330ae695507d96f5$var$nodeIsInTree(tree, id) {\n for (let node of tree){\n if (node.id == id) return true;\n else if (node.children) {\n if ($330ae695507d96f5$var$nodeIsInTree(node.children, id)) return true;\n }\n }\n return false;\n}\nfunction $330ae695507d96f5$var$buildNestedSpec(keyPath, innerSpec) {\n // Build a nested object from a key path\n let spec = innerSpec;\n for(let i = keyPath.length - 1; i >= 0; i--)spec = {\n [keyPath[i]]: spec\n };\n return spec;\n// Since we don't have a \"children\" key at the root, we make the top-level spec an array\n}\nfunction $330ae695507d96f5$var$findNode(tree, id) {\n // Find the index of the node with the given id in the tree, returning the key path\n for(let i = 0; i < tree.length; i++){\n if (tree[i].id == id) return [\n i\n ];\n else if (tree[i].children) {\n let path = $330ae695507d96f5$var$findNode(tree[i].children, id);\n if (path != null) return [\n i,\n \"children\",\n ...path\n ];\n }\n }\n return null;\n}\nfunction $330ae695507d96f5$var$removeNodes(tree, ids) {\n /** Remove nodes with the given ids from the tree and return the new tree and the removed nodes */ let newTree = [];\n let removedNodes = [];\n for (let node of tree)if (ids.includes(node.id)) removedNodes.push(node);\n else {\n // Recurse into children\n if (node.children) {\n let [newChildren, removedChildren] = $330ae695507d96f5$var$removeNodes(node.children, ids);\n node = {\n ...node,\n children: newChildren\n };\n removedNodes.push(...removedChildren);\n }\n newTree.push(node);\n }\n return [\n newTree,\n removedNodes\n ];\n}\nfunction $330ae695507d96f5$export$8d9dbb7a64bf2a5e(tree) {\n // Convert the tree to a graph\n let nodes = [];\n let edges = [];\n const nodeMap = new Map();\n for (let node of tree){\n // If we've already found an instance of this node, we don't need to record\n // it again\n if (nodeMap.has(node.id)) continue;\n const { indices: indices, id: id, name: name, type: type, children: children } = node;\n const nodeData = {\n id: id,\n type: type.id,\n color: type.color,\n name: name,\n txt_range: [\n indices\n ],\n reasoning: null,\n match: node.match,\n children: children\n };\n nodeMap.set(node.id, node);\n nodes.push(nodeData);\n if (node.children) {\n for (let child of node.children)edges.push({\n source: node.id,\n dest: child.id\n });\n // Now process the children\n const { nodes: childNodes, edges: childEdges } = $330ae695507d96f5$export$8d9dbb7a64bf2a5e(node.children);\n nodes.push(...childNodes);\n edges.push(...childEdges);\n }\n }\n return {\n nodes: nodes,\n edges: edges\n };\n}\nfunction $330ae695507d96f5$var$findNodeById(tree, id) {\n for (const node of tree){\n if (node.id === id) return node;\n if (node.children) {\n const found = $330ae695507d96f5$var$findNodeById(node.children, id);\n if (found) return found;\n }\n }\n return null;\n}\nfunction $330ae695507d96f5$var$updateTreeTypes(tree, oldType, defaultType) {\n return tree.map((node)=>$330ae695507d96f5$var$updateNodeType(node, oldType, defaultType));\n}\nfunction $330ae695507d96f5$var$updateNodeType(node, oldType, defaultType) {\n const type = node.type.id === oldType.id ? defaultType : node.type;\n return {\n ...node,\n type: type,\n children: node.children ? $330ae695507d96f5$var$updateTreeTypes(node.children, oldType, defaultType) : []\n };\n}\nfunction $330ae695507d96f5$var$flattenAndSort(nodes) {\n const result = [];\n function traverse(nodeList) {\n for (const node of nodeList){\n result.push(node);\n if (Array.isArray(node.children) && node.children.length > 0) traverse(node.children);\n }\n }\n traverse(nodes);\n // sort by start\n return result.sort((a, b)=>a.indices[0] - b.indices[0]);\n}\n\n\nexport {$330ae695507d96f5$export$53ec42062883b2d4 as ViewMode, $330ae695507d96f5$export$911bb4b9c8065d3d as useUpdatableTree, $330ae695507d96f5$export$e5ce04c5b3f58533 as TreeDispatchContext, $330ae695507d96f5$export$e1068f2d1c68f87e as useTreeDispatch, $330ae695507d96f5$export$8d9dbb7a64bf2a5e as treeToGraph};\n//# sourceMappingURL=feedback-components.b7946db4.js.map\n","import { TreeData } from \"./types\";\nimport { createContext, Dispatch, useContext, useReducer } from \"react\";\nimport update, { Spec } from \"immutability-helper\";\nimport { EntityType } from \"../extractions/types\";\n\nexport enum ViewMode {\n Tree = \"tree\",\n Graph = \"graph\",\n}\n\ninterface TreeState {\n initialTree: TreeData[];\n tree: TreeData[];\n selectedNodes: number[];\n entityTypesMap: Map<number, EntityType>;\n selectedEntityType: EntityType;\n lastInternalId: number;\n isSelectingEntityType: boolean;\n viewMode: ViewMode;\n}\n\ntype TextRange = {\n start: number;\n end: number;\n text: string;\n};\n\ntype TreeAction =\n | {\n type: \"move-node\";\n payload: { dragIds: number[]; parentId: number; index: number };\n }\n | { type: \"delete-node\"; payload: { ids: number[] } }\n | { type: \"select-node\"; payload: { ids: number[] } }\n | { type: \"toggle-node-selected\"; payload: { ids: number[] } }\n | { type: \"set-view-mode\"; payload: ViewMode }\n | { type: \"create-node\"; payload: TextRange }\n | { type: \"select-entity-type\"; payload: EntityType }\n | { type: \"toggle-entity-type-selector\"; payload?: boolean | null }\n | { type: \"deselect\" }\n | { type: \"reset\" }\n | { type: \"delete-entity-type\"; payload: { id: number } }\n | {\n type: \"add-entity-type\";\n payload: { name: string; description: string; color: string };\n }\n | {\n type: \"update-entity-type\";\n payload: { id: number; name: string; description: string; color: string };\n }\n | { type: \"select-range\"; payload: { ids: number[] } };\n\nexport type TreeDispatch = Dispatch<TreeAction>;\n\nexport function useUpdatableTree(\n initialTree: TreeData[],\n entityTypes: Map<number, EntityType>,\n): [TreeState, TreeDispatch] {\n // Get the first entity type\n // issue: grabs second entity instead of selected one\n const type = entityTypes.values().next().value;\n\n return useReducer(treeReducer, {\n initialTree,\n tree: initialTree,\n selectedNodes: [],\n entityTypesMap: entityTypes,\n selectedEntityType: type,\n lastInternalId: 0,\n isSelectingEntityType: false,\n viewMode: ViewMode.Tree,\n });\n}\n\nexport const TreeDispatchContext = createContext<TreeDispatch | null>(null);\n\nexport function useTreeDispatch() {\n const dispatch = useContext(TreeDispatchContext);\n if (dispatch == null) {\n throw new Error(\"No dispatch context available\");\n }\n return dispatch;\n}\n\nfunction treeReducer(state: TreeState, action: TreeAction) {\n switch (action.type) {\n case \"add-entity-type\": {\n // Add a new entity type to the map\n const { name, description, color } = action.payload;\n const newId = state.lastInternalId - 1;\n const newType: EntityType = {\n id: newId,\n name,\n description: description === \"\" ? null : description,\n color,\n };\n\n const newEntityTypesMap = new Map(state.entityTypesMap);\n newEntityTypesMap.set(newId, newType);\n\n return {\n ...state,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: newType,\n lastInternalId: newId,\n };\n }\n case \"update-entity-type\": {\n // Update an existing entity type in the map\n const { id, name, description, color } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n\n if (!oldType) {\n console.warn(`Entity type with id ${id} not found`);\n return state;\n }\n\n const updatedType: EntityType = {\n ...oldType,\n name,\n description: description === \"\" ? null : description,\n color,\n };\n\n newEntityTypesMap.set(id, updatedType);\n\n // Update the tree to reflect the new type\n const newTree = updateTreeTypes(state.tree, oldType, updatedType);\n\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: updatedType,\n };\n }\n case \"select-range\":\n // Select a range of nodes by their IDs\n const payloadIds = action.payload.ids;\n const node1 = payloadIds[0];\n const node2 = payloadIds[1];\n\n // make list of nodes in order\n const allNodes = flattenAndSort(state.tree);\n\n // select all nodes between node1 and node2\n const startIndex = allNodes.findIndex((node) => node.id === node1);\n const endIndex = allNodes.findIndex((node) => node.id === node2);\n\n const selectedNodes = allNodes.slice(startIndex, endIndex + 1);\n\n console.log(\"Selecting range:\", selectedNodes);\n return {\n ...state,\n selectedNodes: selectedNodes.map((node) => node.id),\n };\n\n case \"move-node\":\n // For each node in the tree, if the node is in the dragIds, remove it from the tree and collect it\n const [newTree, removedNodes] = removeNodes(\n state.tree,\n action.payload.dragIds,\n );\n\n let keyPath: (number | \"children\")[] = [];\n if (action.payload.parentId) {\n keyPath = findNode(newTree, action.payload.parentId);\n keyPath.push(\"children\");\n }\n\n // Add removed nodes to the new tree at the correct location\n let updateSpec = buildNestedSpec(keyPath, {\n $splice: [[action.payload.index, 0, ...removedNodes]],\n });\n\n return { ...state, tree: update(newTree, updateSpec) };\n case \"delete-node\":\n // For each node in the tree, if the node is in the ids, remove it from the tree\n const [newTree2, _removedNodes] = removeNodes(\n state.tree,\n action.payload.ids,\n );\n // Get children of the removed nodes\n // If children are not present elsewhere in the tree, insert them\n\n const children = _removedNodes\n .flatMap((node) => node.children ?? [])\n .filter((child) => !nodeIsInTree(newTree2, child.id));\n\n // Reset the selection\n\n return {\n ...state,\n tree: [...newTree2, ...children],\n selectedNodes: state.selectedNodes.filter(\n (id) => !action.payload.ids.includes(id),\n ),\n };\n case \"select-node\":\n const { ids } = action.payload;\n\n const type =\n action.payload.ids.length > 0\n ? findNodeById(state.tree, ids[0])?.type\n : null;\n\n return { ...state, selectedNodes: ids, selectedEntityType: type };\n // otherwise fall through to toggle-node-selected for a single ID\n case \"toggle-node-selected\":\n const nodesToAdd = action.payload.ids.filter(\n (id) => !state.selectedNodes.includes(id),\n );\n const nodesToKeep = state.selectedNodes.filter(\n (id) => !action.payload.ids.includes(id),\n );\n\n const newType =\n action.payload.ids.length > 0\n ? findNodeById(state.tree, action.payload.ids[0])?.type\n : null;\n\n return {\n ...state,\n selectedNodes: [...nodesToKeep, ...nodesToAdd],\n selectedEntityType: newType,\n };\n\n case \"create-node\":\n const newId = state.lastInternalId - 1;\n const { text, start, end } = action.payload;\n const node: TreeData = {\n id: newId,\n name: text,\n children: [],\n indices: [start, end],\n type: state.selectedEntityType,\n };\n\n return {\n ...state,\n tree: [...state.tree, node],\n selectedNodes: [newId],\n lastInternalId: newId,\n };\n\n case \"delete-entity-type\": {\n // Remove the entity type from the map\n console.log(\"Deleting entity type:\", action.payload.id);\n const { id } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n newEntityTypesMap.delete(id);\n\n const defaultType = newEntityTypesMap.values().next().value;\n const newTree = updateTreeTypes(state.tree, oldType, defaultType);\n\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedNodes: [],\n };\n }\n\n /** Entity type selection */\n case \"toggle-entity-type-selector\":\n return {\n ...state,\n isSelectingEntityType: action.payload ?? !state.isSelectingEntityType,\n };\n case \"select-entity-type\": {\n // For each selected node, update the type\n let newTree2 = state.tree;\n for (let id of state.selectedNodes) {\n const keyPath = findNode(state.tree, id);\n const nestedSpec = buildNestedSpec(keyPath, {\n type: { $set: action.payload },\n });\n newTree2 = update(newTree2, nestedSpec);\n }\n\n return {\n ...state,\n tree: newTree2,\n selectedEntityType: action.payload,\n };\n }\n case \"deselect\":\n return { ...state, selectedNodes: [] };\n case \"reset\":\n return {\n ...state,\n tree: state.initialTree,\n selectedNodes: [],\n };\n case \"set-view-mode\":\n return { ...state, viewMode: action.payload };\n }\n}\n\nfunction nodeIsInTree(tree: TreeData[], id: number): boolean {\n for (let node of tree) {\n if (node.id == id) {\n return true;\n } else if (node.children) {\n if (nodeIsInTree(node.children, id)) {\n return true;\n }\n }\n }\n return false;\n}\n\nfunction buildNestedSpec(\n keyPath: (number | \"children\")[],\n innerSpec: Spec<any>,\n): Spec<TreeData[]> {\n // Build a nested object from a key path\n\n let spec = innerSpec;\n for (let i = keyPath.length - 1; i >= 0; i--) {\n spec = { [keyPath[i]]: spec };\n }\n return spec as any;\n // Since we don't have a \"children\" key at the root, we make the top-level spec an array\n}\n\nfunction findNode(\n tree: TreeData[],\n id: number,\n): (number | \"children\")[] | null {\n // Find the index of the node with the given id in the tree, returning the key path\n for (let i = 0; i < tree.length; i++) {\n if (tree[i].id == id) {\n return [i];\n } else if (tree[i].children) {\n let path = findNode(tree[i].children, id);\n if (path != null) {\n return [i, \"children\", ...path];\n }\n }\n }\n return null;\n}\n\nfunction removeNodes(\n tree: TreeData[],\n ids: number[],\n): [TreeData[], TreeData[]] {\n /** Remove nodes with the given ids from the tree and return the new tree and the removed nodes */\n let newTree: TreeData[] = [];\n let removedNodes: TreeData[] = [];\n\n for (let node of tree) {\n if (ids.includes(node.id)) {\n removedNodes.push(node);\n } else {\n // Recurse into children\n if (node.children) {\n let [newChildren, removedChildren] = removeNodes(node.children, ids);\n node = { ...node, children: newChildren };\n removedNodes.push(...removedChildren);\n }\n newTree.push(node);\n }\n }\n\n return [newTree, removedNodes];\n}\n\nexport interface EntityOutput {\n id: number;\n type: number | null;\n txt_range: number[][];\n name: string;\n match: any | null;\n reasoning: string | null;\n color: string | null;\n children: any[] | null;\n}\n\nexport interface GraphData {\n nodes: EntityOutput[];\n edges: { source: number; dest: number }[];\n}\n\nexport function treeToGraph(tree: TreeData[]): GraphData {\n // Convert the tree to a graph\n let nodes: EntityOutput[] = [];\n let edges: { source: number; dest: number }[] = [];\n const nodeMap = new Map<number, TreeData>();\n\n for (let node of tree) {\n // If we've already found an instance of this node, we don't need to record\n // it again\n if (nodeMap.has(node.id)) {\n continue;\n }\n\n const { indices, id, name, type, children } = node;\n\n const nodeData: EntityOutput = {\n id,\n type: type.id,\n color: type.color,\n name,\n txt_range: [indices],\n reasoning: null,\n match: node.match,\n children,\n };\n\n nodeMap.set(node.id, node);\n nodes.push(nodeData);\n\n if (node.children) {\n for (let child of node.children) {\n edges.push({ source: node.id, dest: child.id });\n }\n\n // Now process the children\n const { nodes: childNodes, edges: childEdges } = treeToGraph(\n node.children,\n );\n nodes.push(...childNodes);\n edges.push(...childEdges);\n }\n }\n\n return { nodes, edges };\n}\n\nfunction findNodeById(tree, id) {\n for (const node of tree) {\n if (node.id === id) {\n return node;\n }\n if (node.children) {\n const found = findNodeById(node.children, id);\n if (found) return found;\n }\n }\n return null;\n}\n\nfunction updateTreeTypes(tree, oldType, defaultType) {\n return tree.map((node) => updateNodeType(node, oldType, defaultType));\n}\n\nfunction updateNodeType(node, oldType, defaultType) {\n const type = node.type.id === oldType.id ? defaultType : node.type;\n\n return {\n ...node,\n type,\n children: node.children\n ? updateTreeTypes(node.children, oldType, defaultType)\n : [],\n };\n}\n\nfunction flattenAndSort(nodes) {\n const result = [];\n\n function traverse(nodeList) {\n for (const node of nodeList) {\n result.push(node);\n if (Array.isArray(node.children) && node.children.length > 0) {\n traverse(node.children);\n }\n }\n }\n\n traverse(nodes);\n\n // sort by start\n return result.sort((a, b) => a.indices[0] - b.indices[0]);\n}\n"],"names":["useReducer","$eGztG$useReducer","createContext","$eGztG$createContext","useContext","$eGztG$useContext","$eGztG$immutabilityhelper","ViewMode","$330ae695507d96f5$export$53ec42062883b2d4","$330ae695507d96f5$export$911bb4b9c8065d3d","initialTree","entityTypes","type","values","next","value","$330ae695507d96f5$var$treeReducer","tree","selectedNodes","entityTypesMap","selectedEntityType","lastInternalId","isSelectingEntityType","viewMode","$330ae695507d96f5$export$e5ce04c5b3f58533","$330ae695507d96f5$export$e1068f2d1c68f87e","dispatch","Error","state","action","name","description","color","payload","newId","newType","id","newEntityTypesMap","Map","set","oldType","get","console","warn","updatedType","newTree","$330ae695507d96f5$var$updateTreeTypes","payloadIds","ids","node1","node2","allNodes","$330ae695507d96f5$var$flattenAndSort","nodes","result","traverse","nodeList","node","push","Array","isArray","children","length","sort","a","b","indices","startIndex","findIndex","endIndex","slice","log","map","removedNodes","$330ae695507d96f5$var$removeNodes","dragIds","keyPath","parentId","$330ae695507d96f5$var$findNode","updateSpec","$330ae695507d96f5$var$buildNestedSpec","$splice","index","newTree2","_removedNodes","flatMap","filter","child","$330ae695507d96f5$var$nodeIsInTree","includes","$330ae695507d96f5$var$findNodeById","nodesToAdd","nodesToKeep","text","start","end","delete","defaultType","$set","innerSpec","spec","i","path","newChildren","removedChildren","$330ae695507d96f5$export$8d9dbb7a64bf2a5e","edges","nodeMap","has","nodeData","txt_range","reasoning","match","source","dest","childNodes","childEdges","found","$330ae695507d96f5$var$updateNodeType","useUpdatableTree","TreeDispatchContext","useTreeDispatch","treeToGraph"],"version":3,"file":"feedback-components.b7946db4.js.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- function e(e,t,o,n){Object.defineProperty(e,t,{get:o,set:n,enumerable:!0,configurable:!0})}var t,o,n,a,r,p,c,i,l,d,Q,W,X,_,y,f,s,b,g,k,u,x,h,m,v={};e(v,"add-type",()=>t,e=>t=e),e(v,"add-type-overlay",()=>o,e=>o=e),e(v,"control-content",()=>n,e=>n=e),e(v,"control-panel",()=>a,e=>a=e),e(v,"description",()=>r,e=>r=e),e(v,"entity-panel",()=>p,e=>p=e),e(v,"feedback-component",()=>c,e=>c=e),e(v,"feedback-container",()=>i,e=>i=e),e(v,"feedback-text",()=>l,e=>l=e),e(v,"feedback-text-wrapper",()=>d,e=>d=e),e(v,"form-group",()=>Q,e=>Q=e),e(v,"highlight",()=>W,e=>W=e),e(v,"icons",()=>X,e=>X=e),e(v,"node",()=>_,e=>_=e),e(v,"node-label",()=>y,e=>y=e),e(v,"overlay-container",()=>f,e=>f=e),e(v,"page-wrapper",()=>s,e=>s=e),e(v,"selected",()=>b,e=>b=e),e(v,"selection-tree",()=>g,e=>g=e),e(v,"text-inputs",()=>k,e=>k=e),e(v,"title",()=>u,e=>u=e),e(v,"type-container",()=>x,e=>x=e),e(v,"type-list",()=>h,e=>h=e),e(v,"type-tag",()=>m,e=>m=e),t="QoX8-W_add-type",o="QoX8-W_add-type-overlay",n="QoX8-W_control-content",a="QoX8-W_control-panel",r="QoX8-W_description",p="QoX8-W_entity-panel",c="QoX8-W_feedback-component",i="QoX8-W_feedback-container",l="QoX8-W_feedback-text",d="QoX8-W_feedback-text-wrapper",Q="QoX8-W_form-group",W="QoX8-W_highlight",X="QoX8-W_icons",_="QoX8-W_node",y="QoX8-W_node-label",f="QoX8-W_overlay-container",s="QoX8-W_page-wrapper",b="QoX8-W_selected",g="QoX8-W_selection-tree",k="QoX8-W_text-inputs",u="QoX8-W_title",x="QoX8-W_type-container",h="QoX8-W_type-list",m="QoX8-W_type-tag";export{v as default};
2
- //# sourceMappingURL=feedback-components.c459cc27.js.map
@@ -1 +0,0 @@
1
- {"mappings":"A,S,E,C,C,C,C,C,C,C,E,O,c,C,E,E,C,I,E,I,E,W,C,E,a,C,C,E,C,ICAA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,E,E,C,E,E,E,W,I,E,A,G,E,G,E,E,mB,I,E,A,G,E,G,E,E,kB,I,E,A,G,E,G,E,E,gB,I,E,A,G,E,G,E,E,c,I,E,A,G,E,G,E,E,e,I,E,A,G,E,G,E,E,qB,I,E,A,G,E,G,E,E,qB,I,E,A,G,E,G,E,E,gB,I,E,A,G,E,G,E,E,wB,I,E,A,G,E,G,E,E,a,I,E,A,G,E,G,E,E,Y,I,E,A,G,E,G,E,E,Q,I,E,A,G,E,G,E,E,O,I,E,A,G,E,G,E,E,a,I,E,A,G,E,G,E,E,oB,I,E,A,G,E,G,E,E,e,I,E,A,G,E,G,E,E,W,I,E,A,G,E,G,E,E,iB,I,E,A,G,E,G,E,E,c,I,E,A,G,E,G,E,E,Q,I,E,A,G,E,G,E,E,iB,I,E,A,G,E,G,E,E,Y,I,E,A,G,E,G,E,E,W,I,E,A,G,E,GAvBA,EAA6B,kBAC7B,EAAqC,0BACrC,EAAoC,yBACpC,EAAkC,uBAClC,EAAgC,qBAChC,EAAiC,sBACjC,EAAuC,4BACvC,EAAuC,4BACvC,EAAkC,uBAClC,EAA0C,+BAC1C,EAA+B,oBAC/B,EAA8B,mBAC9B,EAA0B,eAC1B,EAAyB,cACzB,EAA+B,oBAC/B,EAAsC,2BACtC,EAAiC,sBACjC,EAA6B,kBAC7B,EAAmC,wBACnC,EAAgC,qBAChC,EAA0B,eAC1B,EAAmC,wBACnC,EAA8B,mBAC9B,EAA6B,yB,K,O","sources":["<anon>","packages/feedback-components/src/feedback/feedback.module.sass"],"sourcesContent":["\nfunction $parcel$export(e, n, v, s) {\n Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});\n}\nvar $01ca2f1f49a3a114$exports = {};\n\n$parcel$export($01ca2f1f49a3a114$exports, \"add-type\", () => $01ca2f1f49a3a114$export$cb889aaddfa2926c, (v) => $01ca2f1f49a3a114$export$cb889aaddfa2926c = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"add-type-overlay\", () => $01ca2f1f49a3a114$export$5f8f750fd71deeed, (v) => $01ca2f1f49a3a114$export$5f8f750fd71deeed = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"control-content\", () => $01ca2f1f49a3a114$export$42e8b5293e69631e, (v) => $01ca2f1f49a3a114$export$42e8b5293e69631e = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"control-panel\", () => $01ca2f1f49a3a114$export$a0a23f31d5562853, (v) => $01ca2f1f49a3a114$export$a0a23f31d5562853 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"description\", () => $01ca2f1f49a3a114$export$6d59db4903f20f7d, (v) => $01ca2f1f49a3a114$export$6d59db4903f20f7d = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"entity-panel\", () => $01ca2f1f49a3a114$export$38f2cd12e45697e, (v) => $01ca2f1f49a3a114$export$38f2cd12e45697e = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"feedback-component\", () => $01ca2f1f49a3a114$export$579bd45c78bf5510, (v) => $01ca2f1f49a3a114$export$579bd45c78bf5510 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"feedback-container\", () => $01ca2f1f49a3a114$export$23889d205b405f6e, (v) => $01ca2f1f49a3a114$export$23889d205b405f6e = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"feedback-text\", () => $01ca2f1f49a3a114$export$890489be1870bed5, (v) => $01ca2f1f49a3a114$export$890489be1870bed5 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"feedback-text-wrapper\", () => $01ca2f1f49a3a114$export$6bd0fd0a746c88f, (v) => $01ca2f1f49a3a114$export$6bd0fd0a746c88f = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"form-group\", () => $01ca2f1f49a3a114$export$55a1f87a143fb302, (v) => $01ca2f1f49a3a114$export$55a1f87a143fb302 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"highlight\", () => $01ca2f1f49a3a114$export$e4043f67d36cbb26, (v) => $01ca2f1f49a3a114$export$e4043f67d36cbb26 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"icons\", () => $01ca2f1f49a3a114$export$df03f54e09e486fa, (v) => $01ca2f1f49a3a114$export$df03f54e09e486fa = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"node\", () => $01ca2f1f49a3a114$export$35059013cd4a06db, (v) => $01ca2f1f49a3a114$export$35059013cd4a06db = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"node-label\", () => $01ca2f1f49a3a114$export$75d14899fb692bb6, (v) => $01ca2f1f49a3a114$export$75d14899fb692bb6 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"overlay-container\", () => $01ca2f1f49a3a114$export$6a1093e41947f68e, (v) => $01ca2f1f49a3a114$export$6a1093e41947f68e = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"page-wrapper\", () => $01ca2f1f49a3a114$export$7c414e944018fb15, (v) => $01ca2f1f49a3a114$export$7c414e944018fb15 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"selected\", () => $01ca2f1f49a3a114$export$d90250155de6d7e7, (v) => $01ca2f1f49a3a114$export$d90250155de6d7e7 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"selection-tree\", () => $01ca2f1f49a3a114$export$3ae1b51693c80a9c, (v) => $01ca2f1f49a3a114$export$3ae1b51693c80a9c = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"text-inputs\", () => $01ca2f1f49a3a114$export$bc7581b048bdc9d, (v) => $01ca2f1f49a3a114$export$bc7581b048bdc9d = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"title\", () => $01ca2f1f49a3a114$export$fb184b623420d9be, (v) => $01ca2f1f49a3a114$export$fb184b623420d9be = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"type-container\", () => $01ca2f1f49a3a114$export$b2d17fca990bb66c, (v) => $01ca2f1f49a3a114$export$b2d17fca990bb66c = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"type-list\", () => $01ca2f1f49a3a114$export$915fe2ca68846e4c, (v) => $01ca2f1f49a3a114$export$915fe2ca68846e4c = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"type-tag\", () => $01ca2f1f49a3a114$export$5e5acbc770fb0e4, (v) => $01ca2f1f49a3a114$export$5e5acbc770fb0e4 = v);\nvar $01ca2f1f49a3a114$export$cb889aaddfa2926c;\nvar $01ca2f1f49a3a114$export$5f8f750fd71deeed;\nvar $01ca2f1f49a3a114$export$42e8b5293e69631e;\nvar $01ca2f1f49a3a114$export$a0a23f31d5562853;\nvar $01ca2f1f49a3a114$export$6d59db4903f20f7d;\nvar $01ca2f1f49a3a114$export$38f2cd12e45697e;\nvar $01ca2f1f49a3a114$export$579bd45c78bf5510;\nvar $01ca2f1f49a3a114$export$23889d205b405f6e;\nvar $01ca2f1f49a3a114$export$890489be1870bed5;\nvar $01ca2f1f49a3a114$export$6bd0fd0a746c88f;\nvar $01ca2f1f49a3a114$export$55a1f87a143fb302;\nvar $01ca2f1f49a3a114$export$e4043f67d36cbb26;\nvar $01ca2f1f49a3a114$export$df03f54e09e486fa;\nvar $01ca2f1f49a3a114$export$35059013cd4a06db;\nvar $01ca2f1f49a3a114$export$75d14899fb692bb6;\nvar $01ca2f1f49a3a114$export$6a1093e41947f68e;\nvar $01ca2f1f49a3a114$export$7c414e944018fb15;\nvar $01ca2f1f49a3a114$export$d90250155de6d7e7;\nvar $01ca2f1f49a3a114$export$3ae1b51693c80a9c;\nvar $01ca2f1f49a3a114$export$bc7581b048bdc9d;\nvar $01ca2f1f49a3a114$export$fb184b623420d9be;\nvar $01ca2f1f49a3a114$export$b2d17fca990bb66c;\nvar $01ca2f1f49a3a114$export$915fe2ca68846e4c;\nvar $01ca2f1f49a3a114$export$5e5acbc770fb0e4;\n$01ca2f1f49a3a114$export$cb889aaddfa2926c = `QoX8-W_add-type`;\n$01ca2f1f49a3a114$export$5f8f750fd71deeed = `QoX8-W_add-type-overlay`;\n$01ca2f1f49a3a114$export$42e8b5293e69631e = `QoX8-W_control-content`;\n$01ca2f1f49a3a114$export$a0a23f31d5562853 = `QoX8-W_control-panel`;\n$01ca2f1f49a3a114$export$6d59db4903f20f7d = `QoX8-W_description`;\n$01ca2f1f49a3a114$export$38f2cd12e45697e = `QoX8-W_entity-panel`;\n$01ca2f1f49a3a114$export$579bd45c78bf5510 = `QoX8-W_feedback-component`;\n$01ca2f1f49a3a114$export$23889d205b405f6e = `QoX8-W_feedback-container`;\n$01ca2f1f49a3a114$export$890489be1870bed5 = `QoX8-W_feedback-text`;\n$01ca2f1f49a3a114$export$6bd0fd0a746c88f = `QoX8-W_feedback-text-wrapper`;\n$01ca2f1f49a3a114$export$55a1f87a143fb302 = `QoX8-W_form-group`;\n$01ca2f1f49a3a114$export$e4043f67d36cbb26 = `QoX8-W_highlight`;\n$01ca2f1f49a3a114$export$df03f54e09e486fa = `QoX8-W_icons`;\n$01ca2f1f49a3a114$export$35059013cd4a06db = `QoX8-W_node`;\n$01ca2f1f49a3a114$export$75d14899fb692bb6 = `QoX8-W_node-label`;\n$01ca2f1f49a3a114$export$6a1093e41947f68e = `QoX8-W_overlay-container`;\n$01ca2f1f49a3a114$export$7c414e944018fb15 = `QoX8-W_page-wrapper`;\n$01ca2f1f49a3a114$export$d90250155de6d7e7 = `QoX8-W_selected`;\n$01ca2f1f49a3a114$export$3ae1b51693c80a9c = `QoX8-W_selection-tree`;\n$01ca2f1f49a3a114$export$bc7581b048bdc9d = `QoX8-W_text-inputs`;\n$01ca2f1f49a3a114$export$fb184b623420d9be = `QoX8-W_title`;\n$01ca2f1f49a3a114$export$b2d17fca990bb66c = `QoX8-W_type-container`;\n$01ca2f1f49a3a114$export$915fe2ca68846e4c = `QoX8-W_type-list`;\n$01ca2f1f49a3a114$export$5e5acbc770fb0e4 = `QoX8-W_type-tag`;\n\n\nexport {$01ca2f1f49a3a114$exports as default};\n//# sourceMappingURL=feedback-components.c459cc27.js.map\n",null],"names":["$parcel$export","e","n","v","s","Object","defineProperty","get","set","enumerable","configurable","$01ca2f1f49a3a114$export$cb889aaddfa2926c","$01ca2f1f49a3a114$export$5f8f750fd71deeed","$01ca2f1f49a3a114$export$42e8b5293e69631e","$01ca2f1f49a3a114$export$a0a23f31d5562853","$01ca2f1f49a3a114$export$6d59db4903f20f7d","$01ca2f1f49a3a114$export$38f2cd12e45697e","$01ca2f1f49a3a114$export$579bd45c78bf5510","$01ca2f1f49a3a114$export$23889d205b405f6e","$01ca2f1f49a3a114$export$890489be1870bed5","$01ca2f1f49a3a114$export$6bd0fd0a746c88f","$01ca2f1f49a3a114$export$55a1f87a143fb302","$01ca2f1f49a3a114$export$e4043f67d36cbb26","$01ca2f1f49a3a114$export$df03f54e09e486fa","$01ca2f1f49a3a114$export$35059013cd4a06db","$01ca2f1f49a3a114$export$75d14899fb692bb6","$01ca2f1f49a3a114$export$6a1093e41947f68e","$01ca2f1f49a3a114$export$7c414e944018fb15","$01ca2f1f49a3a114$export$d90250155de6d7e7","$01ca2f1f49a3a114$export$3ae1b51693c80a9c","$01ca2f1f49a3a114$export$bc7581b048bdc9d","$01ca2f1f49a3a114$export$fb184b623420d9be","$01ca2f1f49a3a114$export$b2d17fca990bb66c","$01ca2f1f49a3a114$export$915fe2ca68846e4c","$01ca2f1f49a3a114$export$5e5acbc770fb0e4","$01ca2f1f49a3a114$exports","default"],"version":3,"file":"feedback-components.c459cc27.js.map","sourceRoot":"../../../../"}
@@ -1 +0,0 @@
1
- {"mappings":"ACAA,sDAIA,sGAOA,kCAGA,yCAIA,8CAIA,yDAIE,2CAGF,4BAGA,4CAIA,uCAGA,wCAGA,4OAYA,mDAIA,iGAME,wEAIF,iDAIA,4DAKA,qCAGA,+FAOA,+GAMA,oGAMA,6GAOE,4BAGF,yGAOE,0KAQE,+HAKA,+DAGA,2FAIE,qIAKN,qCAIA","sources":["feedback-components.c88cb37f.css","packages/feedback-components/src/feedback/feedback.module.sass"],"sourcesContent":[":root {\n --text-line-height: 3em;\n --main-extra-width: 200px;\n}\n\n.QoX8-W_page-wrapper {\n flex-direction: row;\n align-items: flex-start;\n gap: 2em;\n display: flex;\n position: relative;\n}\n\n.QoX8-W_feedback-container {\n flex: 4;\n}\n\n.QoX8-W_control-panel {\n flex: 1;\n height: auto;\n}\n\n.QoX8-W_control-content {\n position: sticky;\n top: 0;\n}\n\n.QoX8-W_feedback-component {\n width: 800px;\n position: relative;\n}\n\n.QoX8-W_feedback-component > svg {\n width: 800px;\n}\n\n.QoX8-W_node {\n cursor: pointer;\n}\n\ncircle {\n cursor: pointer;\n border: 1px solid #000;\n}\n\n.QoX8-W_selected {\n border: 1px solid #fff;\n}\n\n.QoX8-W_feedback-text {\n margin-bottom: 2em;\n}\n\n.QoX8-W_entity-panel {\n background: var(--panel-secondary-background-color);\n width: calc(100% - 2em);\n min-height: 100px;\n max-height: 600px;\n box-shadow: 0 0 0 1px var(--panel-border-color) inset;\n border-radius: 4px;\n flex: 1;\n padding: 1em;\n position: relative;\n}\n\n.QoX8-W_selection-tree {\n margin: -1em 0;\n padding: 1em 0;\n}\n\n.QoX8-W_type-list {\n grid-template-rows: repeat(10, auto);\n grid-auto-flow: column;\n gap: .2em;\n display: grid;\n}\n\n.QoX8-W_type-list .QoX8-W_type-tag {\n border-radius: .2em;\n padding: .2em .5em;\n}\n\n.QoX8-W_description {\n max-width: 300px;\n padding: .5em;\n}\n\nmark {\n cursor: pointer;\n border-radius: .2em;\n color: #000 !important;\n}\n\n[role=\"treeitem\"] {\n width: auto !important;\n}\n\n.QoX8-W_highlight {\n cursor: pointer;\n zIndex: 10;\n border-radius: .2em;\n padding: .2em 0;\n position: relative;\n}\n\n.QoX8-W_feedback-text-wrapper {\n z-index: 0;\n line-height: var(--text-line-height);\n position: relative;\n overflow: visible;\n}\n\n.QoX8-W_type-container {\n justify-content: space-between;\n align-items: center;\n column-gap: 1em;\n display: flex;\n}\n\n.QoX8-W_add-type {\n cursor: pointer;\n justify-content: space-between;\n align-items: center;\n padding: 0 .5em;\n display: flex;\n}\n\n.QoX8-W_add-type p {\n margin: 0;\n}\n\n.QoX8-W_overlay-container {\n justify-content: center;\n align-items: center;\n width: 100vw;\n height: 80vh;\n display: flex;\n}\n\n.QoX8-W_overlay-container .QoX8-W_add-type-overlay {\n background-color: var(--secondary-color);\n border-radius: .2em;\n flex-direction: column;\n gap: 1em;\n padding: .5em 1em;\n display: flex;\n}\n\n.QoX8-W_overlay-container .QoX8-W_add-type-overlay .QoX8-W_title {\n justify-content: space-between;\n align-items: center;\n display: flex;\n}\n\n.QoX8-W_overlay-container .QoX8-W_add-type-overlay h2 {\n margin: 0;\n}\n\n.QoX8-W_overlay-container .QoX8-W_add-type-overlay .QoX8-W_form-group {\n gap: 3em;\n display: flex;\n}\n\n.QoX8-W_overlay-container .QoX8-W_add-type-overlay .QoX8-W_form-group .QoX8-W_text-inputs {\n flex-direction: column;\n gap: 1em;\n display: flex;\n}\n\n.QoX8-W_icons {\n gap: .25em;\n display: flex;\n}\n\n.QoX8-W_node-label {\n fill: var(--text-emphasized-color);\n fontSize: 10px;\n pointerEvents: none;\n}\n/*# sourceMappingURL=feedback-components.c88cb37f.css.map */\n",":root\n --text-line-height: 3em\n --main-extra-width: 200px\n\n.page-wrapper\n display: flex\n flex-direction: row\n position: relative\n gap: 2em\n align-items: flex-start // makes control-content lose stick\n\n.feedback-container\n flex: 4\n\n.control-panel\n flex: 1\n height: auto\n\n.control-content\n position: sticky\n top: 0\n\n.feedback-component\n position: relative\n width: 800px\n\n & > svg\n width: 800px\n\n.node\n cursor: pointer\n\ncircle\n cursor: pointer\n border: 1px solid black\n\n.selected\n border: 1px solid white\n \n.feedback-text\n margin-bottom: 2em\n\n.entity-panel\n position: relative\n max-height: 600px\n width: calc(100% - 2em)\n flex: 1\n min-height: 100px\n padding: 1em\n background: var(--panel-secondary-background-color)\n border-radius: 4px\n // Inset box shadow\n box-shadow: 0 0 0 1px var(--panel-border-color) inset\n\n.selection-tree\n margin: -1em 0\n padding: 1em 0\n \n.type-list\n display: grid\n grid-auto-flow: column\n grid-template-rows: repeat(10, auto)\n gap: 0.2em\n\n .type-tag\n padding: .2em .5em\n border-radius: .2em\n\n.description\n max-width: 300px\n padding: .5em\n\nmark\n border-radius: .2em\n cursor: pointer\n color: black !important\n\n[role=\"treeitem\"]\n width: auto !important\n\n.highlight\n cursor: pointer\n padding: .2em 0\n border-radius: .2em\n position: relative\n zIndex: 10\n\n.feedback-text-wrapper \n position: relative\n z-index: 0\n overflow: visible\n line-height: var(--text-line-height)\n\n.type-container\n display: flex\n justify-content: space-between\n align-items: center\n column-gap: 1em\n\n.add-type\n cursor: pointer\n display: flex\n justify-content: space-between\n padding: 0 .5em\n align-items: center\n\n p\n margin: 0\n\n.overlay-container\n height: 80vh\n width: 100vw\n display: flex\n justify-content: center\n align-items: center\n\n .add-type-overlay\n background-color: var(--secondary-color)\n padding: .5em 1em\n display: flex\n flex-direction: column\n gap: 1em\n border-radius: .2em\n\n .title\n display: flex\n justify-content: space-between\n align-items: center\n\n h2\n margin: 0\n\n .form-group\n display: flex\n gap: 3em\n\n .text-inputs\n display: flex\n flex-direction: column\n gap: 1em\n\n.icons\n display: flex\n gap: .25em\n\n.node-label\n fill: var(--text-emphasized-color)\n fontSize: 10px\n pointerEvents: none"],"names":[],"version":3,"file":"feedback-components.c88cb37f.css.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- import"./feedback-components.c459cc27.js";import"./feedback-components.8b03e8be.js";import e from"@macrostrat/hyper";import{useRef as t,useEffect as n}from"react";var r=globalThis,o={},a={},l=r.parcelRequirea149;null==l&&((l=function(e){if(e in o)return o[e].exports;if(e in a){var t=a[e];delete a[e];var n={id:e,exports:{}};return o[e]=n,t.call(n.exports,n,n.exports),n.exports}var r=Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}).register=function(e,t){a[e]=t},r.parcelRequirea149=l),l.register;var s=l("9wFEx"),i=l("edvRb");let d=e.styled(s&&s.__esModule?s.default:s);function c(e){let{text:t,selectedNodes:n,nodes:r,dispatch:o,allowOverlap:a}=e;return d("div.feedback-text-wrapper",{tabIndex:0,onKeyDown:e=>{"Backspace"===e.key&&o({type:"delete-node",payload:{ids:n}})}},d(p,{text:t,allTags:function(e,t){let n=[],r=new Set;for(let a of e){var o;if(r.has(a.id))continue;let e=function(e,t){return 0===t.length||((t.includes(e.id)||e.parents?.some(e=>t.includes(e)))??!1)}(a,t),l=(o=a,t.includes(o.id)),s=(0,i.getTagStyle)(a.backgroundColor,{highlighted:e,active:l}),d={color:s.color,tagStyle:{display:"none"},markStyle:{backgroundColor:s.backgroundColor},...a,backgroundColor:s.backgroundColor};n.push(d),r.add(a.id)}return n}((0,i.buildHighlights)(r,null),n),allowOverlap:a,dispatch:o,selectedNodes:n}))}function p(e){let{text:r,allTags:o=[],dispatch:a,selectedNodes:l,allowOverlap:s}=e,i=function(e,t){let n=[];for(let e of t)n.push({pos:e.start,type:"start",tag:e}),n.push({pos:e.end,type:"end",tag:e});n.sort((e,t)=>e.pos!==t.pos?e.pos-t.pos:"end"===e.type&&"start"===t.type?-1:+("start"===e.type&&"end"===t.type));let r={children:[],textStart:0},o=[r],a=0;for(let{pos:t,type:r,tag:l}of n){let n=o[o.length-1];if(t>a){let r=e.slice(a,t);n.children.push(r)}if("start"===r){let e={tag:l,children:[],textStart:t};n.children.push(e),o.push(e)}else o.pop();a=t}return a<e.length&&o[o.length-1].children.push(e.slice(a)),r}(r,o),c=t(null);return n(()=>{let e=()=>{let e=function({container:e}){let t=window.getSelection();if(!t||t.isCollapsed||0===t.rangeCount||!e)return null;let n=t.getRangeAt(0);if(!e.contains(n.startContainer)||!e.contains(n.endContainer))return null;let r=document.createRange();r.setStart(e,0),r.setEnd(n.startContainer,n.startOffset);let o=r.toString().length,a=n.toString(),l=o+a.length;return{start:o,end:l,text:a}}({container:c.current});e&&function({tag:e,dispatch:t,text:n,allTags:r,allowOverlap:o}){let{start:a,end:l}=e;if(" "!=n[l-1]){for(;a>0&&/\w/.test(n[a-1]);)a--;for(;l<n.length&&/\w/.test(n[l]);)l++}let s={start:a,end:l,text:n.slice(a,l)};if(""===s.text.trim())return console.log("Blank tag found, ignoring");if(r.find(e=>e.start===s.start&&(e.end===s.end||e.end===s.end-1)))return console.log("Duplicate tag found, ignoring");s.text.endsWith(" ")&&(s.text=s.text.slice(0,-1),s.end-=1);let i=r.some(e=>e.start<=s.start&&e.end>=s.end),d=r.some(e=>e.start<s.end&&e.end>s.start);if((i||d)&&!o)return console.log("Tag is inside another tag, ignoring");t({type:"create-node",payload:s})}({tag:e,dispatch:a,text:r,allTags:o,allowOverlap:s})};return document.addEventListener("mouseup",e),()=>{document.removeEventListener("mouseup",e)}},[r,o,a,s]),d("span",{ref:c},i.children.map((e,t)=>(function e(t,n,r,o){if("string"==typeof t)return t;let{tag:a,children:l}=t,s=r?.includes(a.id),i=0===r.length||s,c={...a,zIndex:o?-1:1,border:"1px solid "+(i?a.color:"transparent"),margin:"-1px"},p=[];if(s){for(let e in l)if(Object.prototype.hasOwnProperty.call(l,e)){let t=l[e];t?.tag?p.push(t.children[0]):p.push(t)}}return d("span",{className:"highlight",style:c,onClick:e=>{e.stopPropagation(),e.ctrlKey||e.metaKey||r[0]===a.id&&1===r.length?(e.stopPropagation(),n({type:"toggle-node-selected",payload:{ids:[a.id]}})):e.shiftKey&&r.length>0?n({type:"select-range",payload:{ids:[r[r.length-1],a.id]}}):n({type:"select-node",payload:{ids:[a.id]}})}},s?p.flat():l.map((t,o)=>e(t,n,r,s)))})(e,a,l,!1)))}export{c as FeedbackText,p as HighlightedText};
2
- //# sourceMappingURL=feedback-components.ec54a1e7.js.map