@macrostrat/feedback-components 1.0.1 → 1.1.0

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 (104) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/esm/feedback-components.4359bc80.js +70 -0
  3. package/dist/esm/feedback-components.4359bc80.js.map +1 -0
  4. package/dist/esm/{extractions.65bb73cc.js → feedback-components.5df2a926.js} +46 -18
  5. package/dist/esm/feedback-components.5df2a926.js.map +1 -0
  6. package/dist/esm/feedback-components.6a6c8af5.js +552 -0
  7. package/dist/esm/feedback-components.6a6c8af5.js.map +1 -0
  8. package/dist/esm/{main.module.cd706d67.js → feedback-components.6d32ee91.js} +1 -1
  9. package/dist/esm/{main.module.cd706d67.js.map → feedback-components.6d32ee91.js.map} +1 -1
  10. package/dist/esm/{graph.f4f65d79.js → feedback-components.7cd9b6cc.js} +45 -14
  11. package/dist/esm/feedback-components.7cd9b6cc.js.map +1 -0
  12. package/dist/esm/{node.28634e40.js → feedback-components.87533431.js} +11 -6
  13. package/dist/esm/feedback-components.87533431.js.map +1 -0
  14. package/dist/esm/feedback-components.921dcd46.js +241 -0
  15. package/dist/esm/feedback-components.921dcd46.js.map +1 -0
  16. package/dist/esm/{type-selector.6e8952d6.js → feedback-components.ad9f284e.js} +6 -5
  17. package/dist/esm/feedback-components.ad9f284e.js.map +1 -0
  18. package/dist/esm/feedback-components.b7d9b015.css +156 -0
  19. package/dist/esm/feedback-components.b7d9b015.css.map +1 -0
  20. package/dist/esm/{edit-state.c39d8466.js → feedback-components.bf5f7cf7.js} +98 -7
  21. package/dist/esm/feedback-components.bf5f7cf7.js.map +1 -0
  22. package/dist/esm/{main.module.8d366b6e.css → feedback-components.bf93773c.css} +1 -1
  23. package/dist/esm/{main.module.8d366b6e.css.map → feedback-components.bf93773c.css.map} +1 -1
  24. package/dist/esm/{main.module.2f2972c8.css → feedback-components.e273ed5b.css} +1 -1
  25. package/dist/esm/{main.module.2f2972c8.css.map → feedback-components.e273ed5b.css.map} +1 -1
  26. package/dist/esm/{main.module.d2fbdf09.js → feedback-components.f9850d85.js} +1 -1
  27. package/dist/esm/{main.module.d2fbdf09.js.map → feedback-components.f9850d85.js.map} +1 -1
  28. package/dist/esm/index.d.ts +38 -13
  29. package/dist/esm/index.d.ts.map +1 -1
  30. package/dist/esm/index.js +2 -2
  31. package/dist/node/feedback-components.15e1316d.js +2 -0
  32. package/dist/node/feedback-components.15e1316d.js.map +1 -0
  33. package/dist/node/feedback-components.2f391fa4.js +2 -0
  34. package/dist/node/feedback-components.2f391fa4.js.map +1 -0
  35. package/dist/node/feedback-components.65d8488e.js +2 -0
  36. package/dist/node/feedback-components.65d8488e.js.map +1 -0
  37. package/dist/node/feedback-components.6681dbde.js +2 -0
  38. package/dist/node/feedback-components.6681dbde.js.map +1 -0
  39. package/dist/node/feedback-components.77b6fc89.css +2 -0
  40. package/dist/node/feedback-components.77b6fc89.css.map +1 -0
  41. package/dist/node/{main.module.ebdf985b.js → feedback-components.794f429b.js} +2 -2
  42. package/dist/node/feedback-components.794f429b.js.map +1 -0
  43. package/dist/node/feedback-components.7caa447a.js +2 -0
  44. package/dist/node/feedback-components.7caa447a.js.map +1 -0
  45. package/dist/node/{main.module.1fdfe813.css → feedback-components.83c21466.css} +1 -1
  46. package/dist/node/feedback-components.83c21466.css.map +1 -0
  47. package/dist/node/feedback-components.8b03e8be.js +2 -0
  48. package/dist/node/feedback-components.8b03e8be.js.map +1 -0
  49. package/dist/node/{main.module.6bc7d51b.css → feedback-components.9eb1d41a.css} +1 -1
  50. package/dist/node/feedback-components.9eb1d41a.css.map +1 -0
  51. package/dist/node/feedback-components.acac789b.js +2 -0
  52. package/dist/node/feedback-components.acac789b.js.map +1 -0
  53. package/dist/node/feedback-components.e2f3c4b7.js +2 -0
  54. package/dist/node/feedback-components.e2f3c4b7.js.map +1 -0
  55. package/dist/node/feedback-components.e8aa70b8.js +2 -0
  56. package/dist/node/feedback-components.e8aa70b8.js.map +1 -0
  57. package/dist/node/index.js +1 -1
  58. package/dist/node/index.js.map +1 -1
  59. package/package.json +7 -6
  60. package/src/extractions/index.ts +76 -21
  61. package/src/extractions/types.ts +6 -1
  62. package/src/feedback/edit-state.ts +146 -16
  63. package/src/feedback/feedback.module.sass +93 -1
  64. package/src/feedback/graph.ts +71 -30
  65. package/src/feedback/index.ts +444 -71
  66. package/src/feedback/node.ts +7 -1
  67. package/src/feedback/text-visualizer.ts +258 -47
  68. package/src/feedback/type-selector/index.ts +4 -2
  69. package/dist/esm/edit-state.c39d8466.js.map +0 -1
  70. package/dist/esm/extractions.65bb73cc.js.map +0 -1
  71. package/dist/esm/feedback.5c86878e.js +0 -252
  72. package/dist/esm/feedback.5c86878e.js.map +0 -1
  73. package/dist/esm/feedback.module.55921afe.css +0 -44
  74. package/dist/esm/feedback.module.55921afe.css.map +0 -1
  75. package/dist/esm/feedback.module.765b1e58.js +0 -28
  76. package/dist/esm/feedback.module.765b1e58.js.map +0 -1
  77. package/dist/esm/graph.f4f65d79.js.map +0 -1
  78. package/dist/esm/node.28634e40.js.map +0 -1
  79. package/dist/esm/text-visualizer.198e27ff.js +0 -101
  80. package/dist/esm/text-visualizer.198e27ff.js.map +0 -1
  81. package/dist/esm/type-selector.6e8952d6.js.map +0 -1
  82. package/dist/node/edit-state.f50ca728.js +0 -2
  83. package/dist/node/edit-state.f50ca728.js.map +0 -1
  84. package/dist/node/extractions.e6ea2eb9.js +0 -2
  85. package/dist/node/extractions.e6ea2eb9.js.map +0 -1
  86. package/dist/node/feedback.8d3d1219.js +0 -2
  87. package/dist/node/feedback.8d3d1219.js.map +0 -1
  88. package/dist/node/feedback.module.a8744203.js +0 -2
  89. package/dist/node/feedback.module.a8744203.js.map +0 -1
  90. package/dist/node/feedback.module.c4eab97d.css +0 -2
  91. package/dist/node/feedback.module.c4eab97d.css.map +0 -1
  92. package/dist/node/graph.ca5b649f.js +0 -2
  93. package/dist/node/graph.ca5b649f.js.map +0 -1
  94. package/dist/node/main.module.1857be22.js +0 -2
  95. package/dist/node/main.module.1857be22.js.map +0 -1
  96. package/dist/node/main.module.1fdfe813.css.map +0 -1
  97. package/dist/node/main.module.6bc7d51b.css.map +0 -1
  98. package/dist/node/main.module.ebdf985b.js.map +0 -1
  99. package/dist/node/node.33108ccc.js +0 -2
  100. package/dist/node/node.33108ccc.js.map +0 -1
  101. package/dist/node/text-visualizer.1e770afa.js +0 -2
  102. package/dist/node/text-visualizer.1e770afa.js.map +0 -1
  103. package/dist/node/type-selector.0035ef7d.js +0 -2
  104. package/dist/node/type-selector.0035ef7d.js.map +0 -1
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,0EAAK;AAE5B,SAAS,qCAAkB,CAAS,EAAE,CAAS;IAC7C,IAAI,EAAE,IAAI,KAAK,EAAE,IAAI,EAAE,OAAO;IAC9B,KAAK,MAAM,QAAQ,EAAG;QACpB,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,OAAO;IAC3B;IACA,OAAO;AACT;AAEO,SAAS,0CAAkB,YAChC,WAAW,EAAE,QACb,IAAI,SACJ,KAAK,eACL,WAAW,kBACX,cAAc,UACd,MAAM,EACP;IACC,0BAA0B;IAE1B,MAAM,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,yCAAe,EACvC,SAAS,GAAG,CAAC,sCACb;IAGF,MAAM,iBAAE,aAAa,QAAE,IAAI,sBAAE,kBAAkB,yBAAE,qBAAqB,EAAE,GACtE;IAEF,MAAM,CAAC,SAAE,KAAK,UAAE,MAAM,EAAE,EAAE,IAAI,GAAG,CAAA,GAAA,2BAAmB;IAEpD,OAAO,wBAAE,CAAA,GAAA,yCAAkB,EAAE,QAAQ,EAAE;QAAE,OAAO;IAAS,GAAG;QAC1D,wBAAE,CAAA,GAAA,yCAAW,GAAG;kBACd;sBACA;YACA,aAAa;YACb,OAAO;2BACP;QACF;QACA,wBAAE,CAAA,GAAA,cAAM,GAAG;YAAE,YAAY;YAAY,gBAAgB;QAAgB,GAAG;YACtE,wBAAE,CAAA,GAAA,yCAAQ,GAAG;gBAAE,MAAM;YAAM;YAC3B,wBAAE,CAAA,GAAA,uBAAe,GAAG;gBAClB,SAAS;oBACP;wBAAE,OAAO;wBAAQ,OAAO;oBAAO;oBAC/B;wBAAE,OAAO;wBAAS,OAAO;oBAAQ;iBAClC;gBACD,OAAO,MAAM,QAAQ;gBACrB,OAAO;gBACP,eAAc,KAAe;oBAC3B,QAAQ,GAAG,CAAC,qBAAqB;oBACjC,SAAS;wBAAE,MAAM;wBAAiB,SAAS;oBAAM;gBACnD;YACF;SACD;QACD,wBACE,oBACA;iBACE;QACF,GACA;YACE,wBAAE,CAAA,GAAA,WAAG,GAAG;gBAAE,WAAW;YAAgB,GAAG;gBACtC,wBACE,CAAA,GAAA,kBAAU,GACV;oBACE,UAAU;oBACV,MAAM;oBACN,SAAS;oBACT,WAAW;gBACb,GACA;oBACE,wBACE,CAAA,GAAA,mBAAW,GACX;wBACE,MAAM;wBACN,UAAU,MAAM,WAAW,IAAI,MAAM,IAAI;wBACzC;4BACE,SAAS;gCAAE,MAAM;4BAAQ;wBAC3B;oBACF,GACA;oBAEF,wBACE,CAAA,GAAA,iBAAS,GACT;wBACE;4BACE,OAAO,MAAM,IAAI;wBACnB;wBACA,UAAU,MAAM,WAAW,IAAI,MAAM,IAAI;oBAC3C,GACA;iBAEH;gBAEH,wBAAE,0CAAoB;iCACpB;oBACA,UAAU;oBACV,UAAS,OAAO;wBACd,SAAS;4BAAE,MAAM;qCAAsB;wBAAQ;oBACjD;oBACA,QAAQ;oBACR,SAAS,CAAC,SACR,SAAS;4BACP,MAAM;4BACN,SAAS;wBACX;gBACJ;aACD;YACD,wBAAE,EAAE,CAAC,MAAM,QAAQ,IAAI,QAAQ,4CAAsB;+BACnD;0BACA;sBACA;uBACA;wBACA;gCACA;YACF;YACA,wBAAE,EAAE,CAAC,MAAM,QAAQ,IAAI,SAAS,CAAA,GAAA,yCAAQ,GAAG;sBACzC;uBACA;wBACA;YACF;SACD;KAEJ;AACH;AAEA,SAAS,oCAAc,MAAc;IACnC,aAAa;IACb,OAAO;QACL,GAAG,MAAM;QACT,aAAa;QACb,WAAW,OAAO,IAAI,CAAC,IAAI;QAC3B,WAAW;YAAC,OAAO,OAAO;SAAC;QAC3B,UAAU,OAAO,QAAQ,EAAE,IAAI,wCAAkB,EAAE;IACrD;AACF;AAEA,SAAS,yCAAmB,eAC1B,WAAW,YACX,QAAQ,UACR,MAAM,WACN,OAAO,YACP,QAAQ,EACT;IACC,8CAA8C;IAC9C,MAAM,YAAY,YAAY,OAAO,WAAW;IAChD,OAAO,wBAAE,CAAA,GAAA,gBAAQ,GAAG;QAAE,OAAO;QAAe,QAAQ;IAAK,GAAG;QAC1D,wBACE,iBACA;YACE;gBACE,QAAQ,CAAC,IAAM,CAAC;YAClB;QACF,GACA,SAAS,IAAI;QAEf,wBAAE,CAAA,GAAA,yCAAc,GAAG;oBACjB;YACA,OAAO,MAAM,IAAI,CAAC,YAAY,MAAM;YACpC,cAAc;YACd,cAAa,IAAI;gBACf,QAAQ;gBACR,SAAS;YACX;YACA;gBACE,QAAQ;YACV;QACF;KACD;AACH;AAEA,SAAS,2CAAqB,KAAK;IACjC,MAAM,iBACJ,aAAa,YACb,QAAQ,QACR,IAAI,UACJ,MAAM,SACN,KAAK,kBACL,cAAc,EACd,GAAG,MACJ,GAAG;IAEJ,MAAM,MAAM,CAAA,GAAA,aAAK;IAEjB,MAAM,QAAQ,CAAA,GAAA,kBAAU,EACtB,CAAC,QAAU,wBAAE,CAAA,GAAA,wCAAG,GAAG;YAAE,GAAG,KAAK;4BAAE;QAAe,IAC9C;QAAC;KAAe;IAGlB,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,IAAI,OAAO,IAAI,MAAM;QACzB,qCAAqC;QACrC,MAAM,YAAY,IAAI,IAAI,cAAc,GAAG,CAAC,CAAC,IAAM,EAAE,QAAQ;QAC7D,MAAM,mBAAmB,IAAI,OAAO,CAAC,WAAW;QAChD,IAAI,qCAAe,WAAW,mBAAmB;QACjD,2CAA2C;QAE3C,gBAAgB;QAChB,IAAI,OAAO,CAAC,YAAY,CAAC;YACvB,KAAK,cAAc,GAAG,CAAC,CAAC,IAAM,EAAE,QAAQ;YACxC,QAAQ;YACR,YAAY;QACd;IACF,GAAG;QAAC;KAAc;IAElB,OAAO,wBAAE,CAAA,GAAA,WAAG,GAAG;QACb,WAAW;gBACX;eACA;aACA;QACA,MAAM;QACN,QAAO,WAAE,OAAO,YAAE,QAAQ,SAAE,KAAK,EAAE;YACjC,SAAS;gBACP,MAAM;gBACN,SAAS;oBACP,SAAS,QAAQ,GAAG,CAAC,CAAC,IAAM,SAAS;oBACrC,UAAU,WAAW,SAAS,YAAY;2BAC1C;gBACF;YACF;QACF;QACA,UAAS,OAAE,GAAG,EAAE;YACd,SAAS;gBACP,MAAM;gBACN,SAAS;oBAAE,KAAK,IAAI,GAAG,CAAC,CAAC,IAAM,SAAS;gBAAI;YAC9C;QACF;QACA,UAAS,KAAK;YACZ,IAAI,MAAM,MAAM,GAAG,CAAC,CAAC,IAAM,SAAS,EAAE,EAAE;YACxC,IAAI,IAAI,MAAM,IAAI,KAAK,GAAG,CAAC,EAAE,IAAI,aAAa,CAAC,EAAE,EAC/C,WAAW;YACX,MAAM,EAAE;YAEV,SAAS;gBAAE,MAAM;gBAAe,SAAS;yBAAE;gBAAI;YAAE;QACnD;QACA,UAAU;QACV,YAAW,CAAW;YACpB,OAAO,EAAE,EAAE,CAAC,QAAQ;QACtB;IACF;AACF","sources":["packages/feedback-components/src/feedback/index.ts"],"sourcesContent":["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 { ModelInfo } from \"../extractions\";\nimport {\n TreeDispatchContext,\n treeToGraph,\n useUpdatableTree,\n ViewMode,\n} from \"./edit-state\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport { ButtonGroup, Card, SegmentedControl } from \"@blueprintjs/core\";\nimport { OmniboxSelector } from \"./type-selector\";\nimport {\n CancelButton,\n DataField,\n FlexBox,\n FlexRow,\n SaveButton,\n} from \"@macrostrat/ui-components\";\nimport useElementDimensions from \"use-element-dimensions\";\nimport { GraphView } from \"./graph\";\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}) {\n // Get the input arguments\n\n const [state, dispatch] = useUpdatableTree(\n entities.map(processEntity) as any,\n entityTypes\n );\n\n const { selectedNodes, tree, selectedEntityType, isSelectingEntityType } =\n state;\n\n const [{ width, height }, ref] = useElementDimensions();\n\n return h(TreeDispatchContext.Provider, { value: dispatch }, [\n h(FeedbackText, {\n text,\n dispatch,\n // @ts-ignore\n nodes: tree,\n selectedNodes,\n }),\n h(FlexRow, { alignItems: \"baseline\", justifyContent: \"space-between\" }, [\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 h(\n \"div.entity-panel\",\n {\n ref,\n },\n [\n h(Card, { className: \"control-panel\" }, [\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(EntityTypeSelector, {\n entityTypes,\n selected: selectedEntityType,\n onChange(payload) {\n dispatch({ type: \"select-entity-type\", payload });\n },\n isOpen: isSelectingEntityType,\n setOpen: (isOpen: boolean) =>\n dispatch({\n type: \"toggle-entity-type-selector\",\n payload: isOpen,\n }),\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 }),\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}) {\n // Show all entity types when selected is null\n const _selected = selected != null ? selected : undefined;\n return h(DataField, { label: \"Entity type\", inline: true }, [\n h(\n \"code.bp5-code\",\n {\n onClick() {\n setOpen((d) => !d);\n },\n },\n selected.name\n ),\n h(OmniboxSelector, {\n isOpen,\n items: Array.from(entityTypes.values()),\n selectedItem: _selected,\n onSelectItem(item) {\n setOpen(false);\n onChange(item);\n },\n onClose() {\n setOpen(false);\n },\n }),\n ]);\n}\n\nfunction ManagedSelectionTree(props) {\n const {\n selectedNodes,\n dispatch,\n tree,\n height,\n width,\n matchComponent,\n ...rest\n } = props;\n\n const ref = useRef<TreeApi<TreeData>>();\n\n const _Node = useCallback(\n (props) => h(Node, { ...props, matchComponent }),\n [matchComponent]\n );\n\n useEffect(() => {\n if (ref.current == null) return;\n // Check if selection matches current\n const selection = new Set(selectedNodes.map((d) => d.toString()));\n const currentSelection = ref.current.selectedIds;\n if (setsAreTheSame(selection, currentSelection)) return;\n // If the selection is the same, do nothing\n\n // Set selection\n ref.current.setSelection({\n ids: selectedNodes.map((d) => d.toString()),\n anchor: null,\n mostRecent: null,\n });\n }, [selectedNodes]);\n\n return 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(nodes) {\n let ids = nodes.map((d) => parseInt(d.id));\n if (ids.length == 1 && ids[0] == selectedNodes[0]) {\n // Deselect\n ids = [];\n }\n dispatch({ type: \"select-node\", payload: { ids } });\n },\n children: _Node,\n idAccessor(d: TreeData) {\n return d.id.toString();\n },\n });\n}\n"],"names":[],"version":3,"file":"feedback.5c86878e.js.map"}
@@ -1,44 +0,0 @@
1
- .QoX8-W_feedback-component {
2
- width: 800px;
3
- position: relative;
4
- }
5
-
6
- .QoX8-W_feedback-component > svg {
7
- width: 800px;
8
- }
9
-
10
- .QoX8-W_node {
11
- cursor: pointer;
12
- }
13
-
14
- .QoX8-W_feedback-text {
15
- margin-bottom: 2em;
16
- }
17
-
18
- .QoX8-W_entity-panel {
19
- max-height: 600px;
20
- position: relative;
21
- }
22
-
23
- .QoX8-W_control-panel {
24
- max-width: 15em;
25
- padding: .2em .5em;
26
- position: absolute;
27
- top: 1em;
28
- right: 1em;
29
- }
30
-
31
- .QoX8-W_entity-panel {
32
- background: var(--panel-secondary-background-color);
33
- min-height: 100px;
34
- box-shadow: 0 0 0 1px var(--panel-border-color) inset;
35
- border-radius: 4px;
36
- flex: 1;
37
- padding: 1em;
38
- }
39
-
40
- .QoX8-W_selection-tree {
41
- margin: -1em 0;
42
- padding: 1em 0;
43
- }
44
- /*# sourceMappingURL=feedback.module.55921afe.css.map */
@@ -1 +0,0 @@
1
- {"mappings":"AAAA;;;;;AAIE;;;;AAGF;;;;AAIA;;;;AAGA;;;;;AAIA;;;;;;;;AAOA;;;;;;;;;AASA","sources":["packages/feedback-components/src/feedback/feedback.module.sass"],"sourcesContent":[".feedback-component\n position: relative\n width: 800px\n\n & > svg\n width: 800px\n\n.node\n cursor: pointer\n\n\n.feedback-text\n margin-bottom: 2em\n\n.entity-panel\n position: relative\n max-height: 600px\n\n.control-panel\n max-width: 15em\n position: absolute\n top: 1em\n right: 1em\n padding: 0.2em 0.5em\n\n.entity-panel\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"],"names":[],"version":3,"file":"feedback.module.55921afe.css.map"}
@@ -1,28 +0,0 @@
1
-
2
- function $parcel$export(e, n, v, s) {
3
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
- }
5
- var $49c87ee97f392268$exports = {};
6
-
7
- $parcel$export($49c87ee97f392268$exports, "control-panel", () => $49c87ee97f392268$export$a0a23f31d5562853, (v) => $49c87ee97f392268$export$a0a23f31d5562853 = v);
8
- $parcel$export($49c87ee97f392268$exports, "entity-panel", () => $49c87ee97f392268$export$38f2cd12e45697e, (v) => $49c87ee97f392268$export$38f2cd12e45697e = v);
9
- $parcel$export($49c87ee97f392268$exports, "feedback-component", () => $49c87ee97f392268$export$579bd45c78bf5510, (v) => $49c87ee97f392268$export$579bd45c78bf5510 = v);
10
- $parcel$export($49c87ee97f392268$exports, "feedback-text", () => $49c87ee97f392268$export$890489be1870bed5, (v) => $49c87ee97f392268$export$890489be1870bed5 = v);
11
- $parcel$export($49c87ee97f392268$exports, "node", () => $49c87ee97f392268$export$35059013cd4a06db, (v) => $49c87ee97f392268$export$35059013cd4a06db = v);
12
- $parcel$export($49c87ee97f392268$exports, "selection-tree", () => $49c87ee97f392268$export$3ae1b51693c80a9c, (v) => $49c87ee97f392268$export$3ae1b51693c80a9c = v);
13
- var $49c87ee97f392268$export$a0a23f31d5562853;
14
- var $49c87ee97f392268$export$38f2cd12e45697e;
15
- var $49c87ee97f392268$export$579bd45c78bf5510;
16
- var $49c87ee97f392268$export$890489be1870bed5;
17
- var $49c87ee97f392268$export$35059013cd4a06db;
18
- var $49c87ee97f392268$export$3ae1b51693c80a9c;
19
- $49c87ee97f392268$export$a0a23f31d5562853 = `QoX8-W_control-panel`;
20
- $49c87ee97f392268$export$38f2cd12e45697e = `QoX8-W_entity-panel`;
21
- $49c87ee97f392268$export$579bd45c78bf5510 = `QoX8-W_feedback-component`;
22
- $49c87ee97f392268$export$890489be1870bed5 = `QoX8-W_feedback-text`;
23
- $49c87ee97f392268$export$35059013cd4a06db = `QoX8-W_node`;
24
- $49c87ee97f392268$export$3ae1b51693c80a9c = `QoX8-W_selection-tree`;
25
-
26
-
27
- export {$49c87ee97f392268$exports as default};
28
- //# sourceMappingURL=feedback.module.765b1e58.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;AAAA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AALA,4CAAkC,CAAC,oBAAoB,CAAC;AACxD,2CAAiC,CAAC,mBAAmB,CAAC;AACtD,4CAAuC,CAAC,yBAAyB,CAAC;AAClE,4CAAkC,CAAC,oBAAoB,CAAC;AACxD,4CAAyB,CAAC,WAAW,CAAC;AACtC,4CAAmC,CAAC,qBAAqB,CAAC","sources":["packages/feedback-components/src/feedback/feedback.module.sass"],"sourcesContent":[".feedback-component\n position: relative\n width: 800px\n\n & > svg\n width: 800px\n\n.node\n cursor: pointer\n\n\n.feedback-text\n margin-bottom: 2em\n\n.entity-panel\n position: relative\n max-height: 600px\n\n.control-panel\n max-width: 15em\n position: absolute\n top: 1em\n right: 1em\n padding: 0.2em 0.5em\n\n.entity-panel\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"],"names":[],"version":3,"file":"feedback.module.765b1e58.js.map"}
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;AAgBO,SAAS,0CAAU,KAIzB;IACC,+BAA+B;IAC/B,gDAAgD;IAChD,MAAM,QAAE,IAAI,SAAE,KAAK,UAAE,MAAM,EAAE,GAAG;IAEhC,MAAM,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,eAAO,EAAyB;IAC1D,MAAM,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,eAAO,EAAyB;IAE1D,CAAA,GAAA,gBAAQ,EAAE;QACR,MAAM,SAAE,KAAK,SAAE,KAAK,EAAE,GAAG,CAAA,GAAA,yCAAU,EAAE;QAErC,MAAM,WAAW,IAAI,IACnB,MAAM,GAAG,CAAC,CAAC,IAAM;gBAAC,EAAE,EAAE;gBAAE;aAAE;QAG5B,MAAM,QAAQ,MAAM,GAAG,CAAC,CAAC;YACvB,OAAO;gBACL,QAAQ,SAAS,GAAG,CAAC,EAAE,MAAM;gBAC7B,QAAQ,SAAS,GAAG,CAAC,EAAE,IAAI;gBAC3B,UAAU;YACZ;QACF;QAEA,MAAM,aAAa,CAAA,GAAA,sBAAc,EAAE,OAChC,KAAK,CAAC,QAAQ,CAAA,GAAA,gBAAQ,EAAE,QACxB,KAAK,CAAC,UAAU,CAAA,GAAA,oBAAY,IAAI,QAAQ,CAAC,MACzC,KAAK,CAAC,UAAU,CAAA,GAAA,kBAAU,EAAE,QAAQ,GAAG,SAAS,IAChD,KAAK,CAAC,WAAW,CAAA,GAAA,mBAAW,IAAI,MAAM,CAAC,KACvC,EAAE,CAAC,QAAQ;YACV,oCAAoC;YACpC,mBAAmB;YACnB,QAAQ,GAAG,CAAC;QACd,GACC,EAAE,CAAC,OAAO;YACT,oCAAoC;YACpC,SAAS;YACT,SAAS;QACX;QAEF,OAAO;YACL,WAAW,IAAI;QACjB;IACF,GAAG;QAAC;QAAM;QAAO;KAAO;IAExB,IAAI,SAAS,QAAQ,SAAS,MAC5B,OAAO,CAAA,GAAA,sBAAA,EAAE,CAAA,GAAA,cAAM;IAGjB,QAAQ,GAAG,CAAC,SAAS,OAAO;IAE5B,OAAO,CAAA,GAAA,sBAAA,EAAE,kBAAkB;QAAE,OAAO;mBAAE;oBAAO;QAAO;IAAE,GAAG;QACvD,CAAA,GAAA,sBAAA,EAAE,OAAO;mBAAE;oBAAO;QAAO,GAAG;YAC1B,CAAA,GAAA,sBAAA,EACE,WACA,MAAM,GAAG,CAAC,CAAC;gBACT,OAAO,CAAA,GAAA,sBAAA,EAAE,UAAU;oBACjB,IAAI,EAAE,CAAC;oBACP,IAAI,EAAE,CAAC;oBACP,GAAG;oBACH,MAAM;gBACR;YACF;YAEF,CAAA,GAAA,sBAAA,EACE,WACA,MAAM,GAAG,CAAC,CAAC;gBACT,OAAO,CAAA,GAAA,sBAAA,EAAE,QAAQ;oBACf,IAAI,EAAE,MAAM,CAAC,CAAC;oBACd,IAAI,EAAE,MAAM,CAAC,CAAC;oBACd,IAAI,EAAE,MAAM,CAAC,CAAC;oBACd,IAAI,EAAE,MAAM,CAAC,CAAC;oBACd,QAAQ;gBACV;YACF;SAEH;KACF;AACH","sources":["packages/feedback-components/src/feedback/graph.ts"],"sourcesContent":["import { TreeData } from \"./types\";\nimport { treeToGraph } from \"./edit-state\";\nimport h from \"@macrostrat/hyper\";\n\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 } from \"@blueprintjs/core\";\n\nexport function GraphView(props: {\n tree: TreeData[];\n width: number;\n height: number;\n}) {\n // A graph view with react-flow\n // Get positions of nodes using force simulation\n const { tree, width, height } = props;\n\n const [nodes, setNodes] = useState<SimulationNodeDatum[]>(null);\n const [links, setLinks] = useState<SimulationLinkDatum[]>(null);\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);\n\n return h(\"div.graph-view\", { style: { width, height } }, [\n h(\"svg\", { width, height }, [\n h(\n \"g.nodes\",\n nodes.map((d) => {\n return h(\"circle\", {\n cx: d.x,\n cy: d.y,\n r: 5,\n fill: \"blue\",\n });\n })\n ),\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 ]),\n ]);\n}\n"],"names":[],"version":3,"file":"graph.f4f65d79.js.map"}
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;AAOA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,0EAAK;AAE5B,SAAS,iCAAW,UAAoB,EAAE,QAAkB;IAC1D,OAAO,WAAW,EAAE,IAAI,SAAS,EAAE;AACnC,wEAAwE;AAC1E;AAEA,SAAS,wCAAkB,IAAuB,EAAE,IAAuB;IACzE,gFAAgF;IAChF,IAAI,KAAK,aAAa,CAAC,MAAM,IAAI,GAC/B,OAAO;IAGT,KAAK,MAAM,gBAAgB,KAAK,aAAa,CAAE;QAC7C,IAAI,iCAAW,KAAK,IAAI,EAAE,aAAa,IAAI,GACzC,OAAO;IAEX;IAEA,0CAA0C;IAC1C,IAAI,KAAK,MAAM,IAAI,QAAQ,wCAAkB,KAAK,MAAM,EAAE,OACxD,OAAO;IAGT,OAAO;AACT;AAEA,SAAS,mCAAa,IAAuB,EAAE,IAAuB;IACpE,KAAK,MAAM,gBAAgB,KAAK,aAAa,CAAE;QAC7C,IAAI,iCAAW,KAAK,IAAI,EAAE,aAAa,IAAI,GACzC,OAAO;IAEX;IACA,OAAO;AACT;AAEA,SAAS,2BAAK,QAAE,IAAI,SAAE,KAAK,cAAE,UAAU,QAAE,IAAI,kBAAE,cAAc,EAAO;IAClE,IAAI,cAAuB,wCAAkB,MAAM;IACnD,IAAI,SAAkB,mCAAa,MAAM;IAEzC,MAAM,WAAW,CAAA,GAAA,yCAAc;IAE/B,OAAO,wBACL,YACA;eAAE;QAAO,KAAK;IAAW,GACzB,wBAAE,CAAA,GAAA,yCAAQ,GAAG;QACX,MAAM,KAAK,IAAI;gBACf;qBACA;wBACA;QACA;YACE,SAAS;gBAAE,MAAM;YAA8B;QACjD;IACF;AAEJ;IAEA,2CAAe","sources":["packages/feedback-components/src/feedback/node.ts"],"sourcesContent":["import { NodeApi, TreeApi } from \"react-arborist\";\nimport { TreeData } from \"./types\";\nimport { EntityTag } from \"../extractions\";\nimport { useTreeDispatch } from \"./edit-state\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\n\nconst h = hyper.styled(styles);\n\nfunction isSelected(searchNode: TreeData, treeNode: TreeData) {\n return searchNode.id == treeNode.id;\n // We could also select children of the search node here if we wanted to\n}\n\nfunction isNodeHighlighted(node: NodeApi<TreeData>, tree: TreeApi<TreeData>) {\n // We treat no selection as all nodes being active. We may add some nuance later\n if (tree.selectedNodes.length == 0) {\n return true;\n }\n\n for (const selectedNode of tree.selectedNodes) {\n if (isSelected(node.data, selectedNode.data)) {\n return true;\n }\n }\n\n // Check if the parent node is highlighted\n if (node.parent != null && isNodeHighlighted(node.parent, tree)) {\n return true;\n }\n\n return false;\n}\n\nfunction isNodeActive(node: NodeApi<TreeData>, tree: TreeApi<TreeData>) {\n for (const selectedNode of tree.selectedNodes) {\n if (isSelected(node.data, selectedNode.data)) {\n return true;\n }\n }\n return false;\n}\n\nfunction Node({ node, style, dragHandle, tree, matchComponent }: any) {\n let highlighted: boolean = isNodeHighlighted(node, tree);\n let active: boolean = isNodeActive(node, tree);\n\n const dispatch = useTreeDispatch();\n\n return h(\n \"div.node\",\n { style, ref: dragHandle },\n h(EntityTag, {\n data: node.data,\n active,\n highlighted,\n matchComponent,\n onClickType() {\n dispatch({ type: \"toggle-entity-type-selector\" });\n },\n })\n );\n}\n\nexport default Node;\n"],"names":[],"version":3,"file":"node.28634e40.js.map"}
@@ -1,101 +0,0 @@
1
- import "./feedback.module.55921afe.css";
2
- import $aogpP$feedbackmodule765b1e58js from "./feedback.module.765b1e58.js";
3
- import {getTagStyle as $03d8811e9c9b360d$export$35baa338324d8550, buildHighlights as $03d8811e9c9b360d$export$c4b91360064ad200} from "./extractions.65bb73cc.js";
4
- import {TextAnnotateBlend as $aogpP$TextAnnotateBlend} from "react-text-annotate-blend";
5
- import $aogpP$macrostrathyper from "@macrostrat/hyper";
6
- import {useCallback as $aogpP$useCallback} from "react";
7
-
8
-
9
- function $parcel$interopDefault(a) {
10
- return a && a.__esModule ? a.default : a;
11
- }
12
-
13
-
14
-
15
-
16
-
17
- const $156a3efbc315814c$var$h = (0, $aogpP$macrostrathyper).styled((0, ($parcel$interopDefault($aogpP$feedbackmodule765b1e58js))));
18
- function $156a3efbc315814c$var$buildTags(highlights, selectedNodes) {
19
- let tags = [];
20
- // If entity ID has already been seen, don't add it again
21
- const entities = new Set();
22
- for (const highlight of highlights){
23
- // Don't add multiply-linked entities multiple times
24
- if (entities.has(highlight.id)) continue;
25
- const highlighted = $156a3efbc315814c$var$isHighlighted(highlight, selectedNodes);
26
- const active = $156a3efbc315814c$var$isActive(highlight, selectedNodes);
27
- tags.push({
28
- markStyle: {
29
- ...(0, $03d8811e9c9b360d$export$35baa338324d8550)(highlight.backgroundColor, {
30
- highlighted: highlighted,
31
- active: active
32
- }),
33
- borderRadius: "0.2em",
34
- padding: "0.1em",
35
- borderWidth: "1.5px",
36
- cursor: "pointer"
37
- },
38
- tagStyle: {
39
- display: "none"
40
- },
41
- ...highlight
42
- });
43
- entities.add(highlight.id);
44
- }
45
- return tags;
46
- }
47
- function $156a3efbc315814c$var$isActive(tag, selectedNodes) {
48
- return selectedNodes.includes(tag.id);
49
- }
50
- function $156a3efbc315814c$var$isHighlighted(tag, selectedNodes) {
51
- if (selectedNodes.length === 0) return true;
52
- return (selectedNodes.includes(tag.id) || tag.parents?.some((d)=>selectedNodes.includes(d))) ?? false;
53
- }
54
- function $156a3efbc315814c$export$6e107db9091b8219(props) {
55
- // Convert input to tags
56
- const { text: text, selectedNodes: selectedNodes, nodes: nodes, dispatch: dispatch } = props;
57
- let allTags = $156a3efbc315814c$var$buildTags((0, $03d8811e9c9b360d$export$c4b91360064ad200)(nodes, null), selectedNodes);
58
- const onChange = (0, $aogpP$useCallback)((tags)=>{
59
- // New tags
60
- console.log(tags);
61
- const newTags = tags.filter((d)=>!("id" in d));
62
- if (newTags.length > 0) {
63
- const { start: start, end: end } = newTags[0];
64
- const payload = {
65
- start: start,
66
- end: end,
67
- text: text.slice(start, end)
68
- };
69
- dispatch({
70
- type: "create-node",
71
- payload: payload
72
- });
73
- return;
74
- }
75
- const tagIDs = new Set(tags.map((d)=>d.id));
76
- const removedIds = allTags.map((d)=>d.id).filter((d)=>!tagIDs.has(d));
77
- /* Find the id that was removed: that is the one that will be selected
78
- (we are hijacking the 'click to delete' functionality to select instead) */ if (removedIds.length > 0) dispatch({
79
- type: "toggle-node-selected",
80
- payload: {
81
- ids: removedIds
82
- }
83
- });
84
- }, [
85
- allTags,
86
- text
87
- ]);
88
- return $156a3efbc315814c$var$h((0, $aogpP$TextAnnotateBlend), {
89
- style: {
90
- fontSize: "1.2em"
91
- },
92
- className: "feedback-text",
93
- content: text,
94
- onChange: onChange,
95
- value: allTags
96
- });
97
- }
98
-
99
-
100
- export {$156a3efbc315814c$export$6e107db9091b8219 as FeedbackText};
101
- //# sourceMappingURL=text-visualizer.198e27ff.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;AASA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,0EAAK;AAU5B,SAAS,gCACP,UAAuB,EACvB,aAAuB;IAEvB,IAAI,OAA2B,EAAE;IAEjC,yDAAyD;IACzD,MAAM,WAAW,IAAI;IAErB,KAAK,MAAM,aAAa,WAAY;QAClC,oDAAoD;QACpD,IAAI,SAAS,GAAG,CAAC,UAAU,EAAE,GAAG;QAEhC,MAAM,cAAc,oCAAc,WAAW;QAC7C,MAAM,SAAS,+BAAS,WAAW;QAEnC,KAAK,IAAI,CAAC;YACR,WAAW;gBACT,GAAG,CAAA,GAAA,yCAAU,EAAE,UAAU,eAAe,EAAE;iCACxC;4BACA;gBACF,EAAE;gBACF,cAAc;gBACd,SAAS;gBACT,aAAa;gBACb,QAAQ;YACV;YACA,UAAU;gBACR,SAAS;YACX;YACA,GAAG,SAAS;QACd;QAEA,SAAS,GAAG,CAAC,UAAU,EAAE;IAC3B;IAEA,OAAO;AACT;AAEA,SAAS,+BAAS,GAAc,EAAE,aAAuB;IACvD,OAAO,cAAc,QAAQ,CAAC,IAAI,EAAE;AACtC;AAEA,SAAS,oCAAc,GAAc,EAAE,aAAuB;IAC5D,IAAI,cAAc,MAAM,KAAK,GAAG,OAAO;IACvC,OACE,AAAC,CAAA,cAAc,QAAQ,CAAC,IAAI,EAAE,KAC5B,IAAI,OAAO,EAAE,KAAK,CAAC,IAAM,cAAc,QAAQ,CAAC,GAAE,KACpD;AAEJ;AAEO,SAAS,0CAAa,KAAwB;IACnD,wBAAwB;IACxB,MAAM,QAAE,IAAI,iBAAE,aAAa,SAAE,KAAK,YAAE,QAAQ,EAAE,GAAG;IACjD,IAAI,UAA8B,gCAChC,CAAA,GAAA,yCAAc,EAAE,OAAO,OACvB;IAGF,MAAM,WAAW,CAAA,GAAA,kBAAU,EACzB,CAAC;QACC,WAAW;QACX,QAAQ,GAAG,CAAC;QACZ,MAAM,UAAU,KAAK,MAAM,CAAC,CAAC,IAAM,CAAE,CAAA,QAAQ,CAAA;QAC7C,IAAI,QAAQ,MAAM,GAAG,GAAG;YACtB,MAAM,SAAE,KAAK,OAAE,GAAG,EAAE,GAAG,OAAO,CAAC,EAAE;YACjC,MAAM,UAAU;uBAAE;qBAAO;gBAAK,MAAM,KAAK,KAAK,CAAC,OAAO;YAAK;YAC3D,SAAS;gBAAE,MAAM;yBAAe;YAAQ;YACxC;QACF;QAEA,MAAM,SAAS,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,IAAM,EAAE,EAAE;QAC3C,MAAM,aAAa,QAAQ,GAAG,CAAC,CAAC,IAAM,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,IAAM,CAAC,OAAO,GAAG,CAAC;QAEtE;gFAC0E,GAC1E,IAAI,WAAW,MAAM,GAAG,GACtB,SAAS;YACP,MAAM;YACN,SAAS;gBAAE,KAAK;YAAW;QAC7B;IAEJ,GACA;QAAC;QAAS;KAAK;IAGjB,OAAO,wBAAE,CAAA,GAAA,wBAAgB,GAAG;QAC1B,OAAO;YACL,UAAU;QACZ;QACA,WAAW;QACX,SAAS;kBACT;QACA,OAAO;IACT;AACF","sources":["packages/feedback-components/src/feedback/text-visualizer.ts"],"sourcesContent":["import { AnnotateBlendTag, TextAnnotateBlend } from \"react-text-annotate-blend\";\nimport { InternalEntity } from \"./types\";\nimport { TreeDispatch } from \"./edit-state\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\nimport { buildHighlights, getTagStyle } from \"../extractions\";\nimport { Highlight } from \"../extractions/types\";\nimport { useCallback } from \"react\";\n\nconst h = hyper.styled(styles);\n\nexport interface FeedbackTextProps {\n text: string;\n selectedNodes: number[];\n nodes: InternalEntity[];\n updateNodes: (nodes: string[]) => void;\n dispatch: TreeDispatch;\n}\n\nfunction buildTags(\n highlights: Highlight[],\n selectedNodes: number[]\n): AnnotateBlendTag[] {\n let tags: AnnotateBlendTag[] = [];\n\n // If entity ID has already been seen, don't add it again\n const entities = new Set<number>();\n\n for (const highlight of highlights) {\n // Don't add multiply-linked entities multiple times\n if (entities.has(highlight.id)) continue;\n\n const highlighted = isHighlighted(highlight, selectedNodes);\n const active = isActive(highlight, selectedNodes);\n\n tags.push({\n markStyle: {\n ...getTagStyle(highlight.backgroundColor, {\n highlighted,\n active,\n }),\n borderRadius: \"0.2em\",\n padding: \"0.1em\",\n borderWidth: \"1.5px\",\n cursor: \"pointer\",\n },\n tagStyle: {\n display: \"none\",\n },\n ...highlight,\n });\n\n entities.add(highlight.id);\n }\n\n return tags;\n}\n\nfunction isActive(tag: Highlight, selectedNodes: number[]) {\n return selectedNodes.includes(tag.id);\n}\n\nfunction isHighlighted(tag: Highlight, selectedNodes: number[]) {\n if (selectedNodes.length === 0) return true;\n return (\n (selectedNodes.includes(tag.id) ||\n tag.parents?.some((d) => selectedNodes.includes(d))) ??\n false\n );\n}\n\nexport function FeedbackText(props: FeedbackTextProps) {\n // Convert input to tags\n const { text, selectedNodes, nodes, dispatch } = props;\n let allTags: AnnotateBlendTag[] = buildTags(\n buildHighlights(nodes, null),\n selectedNodes\n );\n\n const onChange = useCallback(\n (tags) => {\n // New tags\n console.log(tags);\n const newTags = tags.filter((d) => !(\"id\" in d));\n if (newTags.length > 0) {\n const { start, end } = newTags[0];\n const payload = { start, end, text: text.slice(start, end) };\n dispatch({ type: \"create-node\", payload });\n return;\n }\n\n const tagIDs = new Set(tags.map((d) => d.id));\n const removedIds = allTags.map((d) => d.id).filter((d) => !tagIDs.has(d));\n\n /* Find the id that was removed: that is the one that will be selected\n (we are hijacking the 'click to delete' functionality to select instead) */\n if (removedIds.length > 0) {\n dispatch({\n type: \"toggle-node-selected\",\n payload: { ids: removedIds },\n });\n }\n },\n [allTags, text]\n );\n\n return h(TextAnnotateBlend, {\n style: {\n fontSize: \"1.2em\",\n },\n className: \"feedback-text\",\n content: text,\n onChange,\n value: allTags,\n });\n}\n"],"names":[],"version":3,"file":"text-visualizer.198e27ff.js.map"}
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;AAAA;;CAEC;;;;;AAUD,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,sEAAK;AAa5B,MAAM,oCAAoD,CAAC;IACzD,sCAAsC,GACtC,IAAI,UAAE,MAAM,YAAE,QAAQ,aAAE,SAAS,YAAE,QAAQ,QAAE,IAAI,YAAE,QAAQ,EAAE,GAAG;IAChE,YAAY,CAAA,GAAA,iBAAS,EAAE;gBAAE;kBAAQ;IAAS,GAAG;IAC7C,MAAM,UAAU,IAAM,SAAS;IAE/B,OAAO,wBACL,sBACA;QACE,KAAK,KAAK,EAAE;mBACZ;iBACA;IACF,GACA;QACE,wBAAE,cAAc;YAAE,OAAO;gBAAE,iBAAiB,KAAK,KAAK;YAAC;QAAE;QACzD,wBAAE,YAAY,CAAC,GAAG,KAAK,IAAI;KAC5B;AAEL;AAWO,SAAS,0CAAmB,KAAsB;IACvD,2CAA2C,GAC3C,MAAM,gBAAE,YAAY,SAAE,KAAK,UAAE,MAAM,WAAE,OAAO,EAAE,GAAG;IAEjD,OAAO,wBAAE,CAAA,GAAA,cAAM,GAAG;QAChB,cAAc;eACd;QACA,eAAe;gBACf;iBACA;QACA,cAAa,IAAO,EAAE,eAAE,WAAW,aAAE,SAAS,EAAE;YAC9C,OAAO,wBAAE,mCAAa;gBACpB,KAAK,KAAK,EAAE;sBACZ;gBACA,UAAU;gBACV,QAAQ,UAAU,MAAM;gBACxB,UAAU,UAAU,MAAM;YAC5B;QACF;IACF;AACF","sources":["packages/feedback-components/src/feedback/type-selector/index.ts"],"sourcesContent":["/**\n * Entity type selector\n */\n\nimport styles from \"./main.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\n\nimport classNames from \"classnames\";\nimport React from \"react\";\nimport { Omnibar, OmnibarProps } from \"@blueprintjs/select\";\nimport \"@blueprintjs/select/lib/css/blueprint-select.css\";\n\nconst h = hyper.styled(styles);\n\ninterface TagItemProps<T> {\n selected: boolean;\n active: boolean;\n className?: string;\n item: T;\n\n onSelect(t: T): void;\n\n children?: React.ReactElement;\n}\n\nconst TagListItem: React.ComponentType<TagItemProps<T>> = (props) => {\n /** Render a tag for the omnibox list */\n let { active, selected, className, onSelect, item, children } = props;\n className = classNames({ active, selected }, className);\n const onClick = () => onSelect(item);\n\n return h(\n \"div.item-container\",\n {\n key: item.id,\n className,\n onClick,\n },\n [\n h(\"div.swatch\", { style: { backgroundColor: item.color } }),\n h(\"div.item\", {}, item.name),\n ]\n );\n};\n\ntype BoxLifecycleProps<T> = Pick<OmnibarProps<T>, \"onClose\" | \"isOpen\">;\n\ninterface OmniboxProps<T> extends BoxLifecycleProps<T> {\n items: T[];\n selectedItem: T;\n onSelectItem: (t: T) => void;\n listItemComponent?: React.ComponentType<TagItemProps<T>>;\n}\n\nexport function OmniboxSelector<T>(props: OmniboxProps<T>) {\n /** A general omnibox for annotation types */\n const { onSelectItem, items, isOpen, onClose } = props;\n\n return h(Omnibar, {\n onItemSelect: onSelectItem,\n items,\n resetOnSelect: false,\n isOpen,\n onClose,\n itemRenderer(item: T, { handleClick, modifiers }) {\n return h(TagListItem, {\n key: item.id,\n item,\n onSelect: handleClick,\n active: modifiers.active,\n selected: modifiers.active,\n });\n },\n });\n}\n"],"names":[],"version":3,"file":"type-selector.6e8952d6.js.map"}
@@ -1,2 +0,0 @@
1
- import{createContext as t}from"react";import"immutability-helper";t(null);
2
- //# sourceMappingURL=edit-state.f50ca728.js.map
@@ -1 +0,0 @@
1
- {"mappings":"A,O,iB,C,K,O,A,O,qB,CC+DmC,AAAA,EAAmC","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 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 console.log(action);\n switch(action.type){\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 return {\n ...state,\n selectedNodes: ids\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 return {\n ...state,\n selectedNodes: [\n ...nodesToKeep,\n ...nodesToAdd\n ]\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 /** 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 } = node;\n const nodeData = {\n id: id,\n type: node.type.id,\n name: name,\n txt_range: [\n indices\n ],\n reasoning: null,\n match: node.match\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}\n\n\n//# sourceMappingURL=edit-state.f50ca728.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\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 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 console.log(action);\n switch (action.type) {\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 return { ...state, selectedNodes: ids };\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 return { ...state, selectedNodes: [...nodesToKeep, ...nodesToAdd] };\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 /** 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}\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 } = node;\n\n const nodeData: EntityOutput = {\n id,\n type: node.type.id,\n name,\n txt_range: [indices],\n reasoning: null,\n match: node.match,\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"],"names":["createContext","$eGztG$createContext"],"version":3,"file":"edit-state.f50ca728.js.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- import"classnames";import"@blueprintjs/core";import"@macrostrat/color-utils";import r from"@macrostrat/hyper";var e,t=globalThis,o={},a={},i=t.parcelRequire94c2;null==i&&((i=function(r){if(r in o)return o[r].exports;if(r in a){var e=a[r];delete a[r];var t={id:r,exports:{}};return o[r]=t,e.call(t.exports,t,t.exports),t.exports}var i=Error("Cannot find module '"+r+"'");throw i.code="MODULE_NOT_FOUND",i}).register=function(r,e){a[r]=e},t.parcelRequire94c2=i),i.register;var l={};l=i("daZiC").getBundleURL("78C1X")+"main.module.1fdfe813.css",r.styled((e=l)&&e.__esModule?e.default:e);
2
- //# sourceMappingURL=extractions.e6ea2eb9.js.map
@@ -1 +0,0 @@
1
- {"mappings":"A,M,Y,A,O,mB,A,O,yB,A,Q,M,mB,C,I,E,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,EEAA,EAAiB,AAAA,EAAA,SAAA,YAAA,CAA6C,SAAW,4CDU/D,AAAA,EAAM,MAAM,C,C,EAAC,I,E,U,C,E,O,C","sources":["<anon>","packages/feedback-components/src/extractions/index.ts","../../../../.yarn/berry/cache/@parcel-runtime-js-npm-2.13.3-f44fec8492-10c0.zip/node_modules/@parcel/runtime-js/lib/runtime-49425f4027e5bc0b.js"],"sourcesContent":["import $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\";\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[\"parcelRequire94c2\"];\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[\"parcelRequire94c2\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\nvar $6458604d63891312$exports = {};\n\n$6458604d63891312$exports = (parcelRequire(\"daZiC\")).getBundleURL('78C1X') + \"main.module.1fdfe813.css\";\n\n\n\n\n\n\nconst $8c534c0378e15a46$var$h = (0, $78C1X$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($6458604d63891312$exports))));\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 ?? \"#ddd\",\n tag: entity.type.name,\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 ?? \"#ddd\");\n const { highlighted: highlighted = true, inDarkMode: inDarkMode = false, 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 = inDarkMode ? \"white\" : \"black\";\n const color = _baseColor.mix(mixTarget, mixAmount).css();\n const borderColor = highlighted ? _baseColor.mix(mixTarget, mixAmount / 2).css() : \"transparent\";\n return {\n color: color,\n backgroundColor: _baseColor.alpha(backgroundAlpha).css(),\n boxSizing: \"border-box\",\n borderStyle: \"solid\",\n borderColor: borderColor,\n borderWidth: \"1px\",\n fontWeight: active ? \"bold\" : \"normal\"\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 ?? \"#ddd\").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\n }, \"entity\");\n const style = $8c534c0378e15a46$export$35baa338324d8550(type.color ?? \"#aaaaaa\", {\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}\n\n\n//# sourceMappingURL=extractions.e6ea2eb9.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\";\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 ?? \"#ddd\",\n tag: entity.type.name,\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 ?? \"#ddd\");\n const { highlighted = true, inDarkMode = false, active = false } = 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 = inDarkMode ? \"white\" : \"black\";\n\n const color = _baseColor.mix(mixTarget, mixAmount).css();\n const borderColor = highlighted\n ? _baseColor.mix(mixTarget, mixAmount / 2).css()\n : \"transparent\";\n\n return {\n color,\n backgroundColor: _baseColor.alpha(backgroundAlpha).css(),\n boxSizing: \"border-box\",\n borderStyle: \"solid\",\n borderColor,\n borderWidth: \"1px\",\n fontWeight: active ? \"bold\" : \"normal\",\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 ?? \"#ddd\").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 const className = classNames(\n {\n matched: match != null,\n type: data.type.name,\n },\n \"entity\"\n );\n\n const style = getTagStyle(type.color ?? \"#aaaaaa\", { 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","module.exports = require('./helpers/bundle-url').getBundleURL('78C1X') + \"main.module.1fdfe813.css\";"],"names":["$78C1X$macrostrathyper","a","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$6458604d63891312$exports","getBundleURL","styled","__esModule","default"],"version":3,"file":"extractions.e6ea2eb9.js.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- import e from"@macrostrat/hyper";import"react-arborist";import"react";import"@blueprintjs/core";import"@macrostrat/ui-components";import"use-element-dimensions";var r,t=globalThis,a={},i={},o=t.parcelRequire94c2;null==o&&((o=function(e){if(e in a)return a[e].exports;if(e in i){var r=i[e];delete i[e];var t={id:e,exports:{}};return a[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){i[e]=r},t.parcelRequire94c2=o),o.register;var d={};d=o("daZiC").getBundleURL("ajJMX")+"feedback.module.c4eab97d.css",o("daZiC").getBundleURL("ajJMX"),o("daZiC").getBundleURL("ajJMX"),o("edvRb"),o("eedTh"),o("daZiC").getBundleURL("ajJMX"),o("daZiC").getBundleURL("ajJMX"),e.styled((r=d)&&r.__esModule?r.default:r);
2
- //# sourceMappingURL=feedback.8d3d1219.js.map
@@ -1 +0,0 @@
1
- {"mappings":"A,O,M,mB,A,O,gB,A,O,O,A,O,mB,A,O,2B,A,O,wB,C,I,E,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,EEAA,EAAiB,AAAA,EAAA,SAAA,YAAA,CAA6C,SAAW,gDCAxD,AAAA,EAAA,SAAA,YAAA,CAA6C,SCA7C,AAAA,EAAA,SAAA,YAAA,CAA6C,S,E,S,E,SCA7C,AAAA,EAAA,SAAA,YAAA,CAA6C,SCA7C,AAAA,EAAA,SAAA,YAAA,CAA6C,SLgCpD,AAAA,EAAM,MAAM,C,C,EAAC,I,E,U,C,E,O,C","sources":["<anon>","packages/feedback-components/src/feedback/index.ts","../../../../.yarn/berry/cache/@parcel-runtime-js-npm-2.13.3-f44fec8492-10c0.zip/node_modules/@parcel/runtime-js/lib/runtime-48e9df14db6e0616.js","../../../../.yarn/berry/cache/@parcel-runtime-js-npm-2.13.3-f44fec8492-10c0.zip/node_modules/@parcel/runtime-js/lib/runtime-7a4060e4b11f34dc.js","../../../../.yarn/berry/cache/@parcel-runtime-js-npm-2.13.3-f44fec8492-10c0.zip/node_modules/@parcel/runtime-js/lib/runtime-e7e5dd3982ba69dc.js","../../../../.yarn/berry/cache/@parcel-runtime-js-npm-2.13.3-f44fec8492-10c0.zip/node_modules/@parcel/runtime-js/lib/runtime-058c2ef41b7519dc.js","../../../../.yarn/berry/cache/@parcel-runtime-js-npm-2.13.3-f44fec8492-10c0.zip/node_modules/@parcel/runtime-js/lib/runtime-10f2bc332c68d134.js"],"sourcesContent":["import $ajJMX$macrostrathyper from \"@macrostrat/hyper\";\nimport {Tree as $ajJMX$Tree} from \"react-arborist\";\nimport {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} from \"@blueprintjs/core\";\nimport {FlexRow as $ajJMX$FlexRow, CancelButton as $ajJMX$CancelButton, SaveButton as $ajJMX$SaveButton, DataField as $ajJMX$DataField} from \"@macrostrat/ui-components\";\nimport $ajJMX$useelementdimensions from \"use-element-dimensions\";\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[\"parcelRequire94c2\"];\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[\"parcelRequire94c2\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\nvar $8e7fa15260c024b8$exports = {};\n\n$8e7fa15260c024b8$exports = (parcelRequire(\"daZiC\")).getBundleURL('ajJMX') + \"feedback.module.c4eab97d.css\";\n\n\n\n\nvar $7d518355fc256b3f$exports = {};\n\n$7d518355fc256b3f$exports = (parcelRequire(\"daZiC\")).getBundleURL('ajJMX') + \"node.33108ccc.js\";\n\n\nvar $625b25e9ec34848f$exports = {};\n\n$625b25e9ec34848f$exports = (parcelRequire(\"daZiC\")).getBundleURL('ajJMX') + \"text-visualizer.1e770afa.js\";\n\n\n\nvar $edvRb = parcelRequire(\"edvRb\");\n\nvar $eedTh = parcelRequire(\"eedTh\");\n\n\nvar $9dde9e77df32d024$exports = {};\n\n$9dde9e77df32d024$exports = (parcelRequire(\"daZiC\")).getBundleURL('ajJMX') + \"type-selector.0035ef7d.js\";\n\n\n\n\nvar $d5ed517fac59fa65$exports = {};\n\n$d5ed517fac59fa65$exports = (parcelRequire(\"daZiC\")).getBundleURL('ajJMX') + \"graph.ca5b649f.js\";\n\n\nconst $2c86488f2f3c1edd$var$h = (0, $ajJMX$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($8e7fa15260c024b8$exports))));\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 }) {\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 } = state;\n const [{ width: width, height: height }, ref] = (0, $ajJMX$useelementdimensions)();\n return $2c86488f2f3c1edd$var$h((0, $eedTh.TreeDispatchContext).Provider, {\n value: dispatch\n }, [\n $2c86488f2f3c1edd$var$h((0, $625b25e9ec34848f$exports.FeedbackText), {\n text: text,\n dispatch: dispatch,\n // @ts-ignore\n nodes: tree,\n selectedNodes: selectedNodes\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((0, $ajJMX$Card), {\n className: \"control-panel\"\n }, [\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($2c86488f2f3c1edd$var$EntityTypeSelector, {\n entityTypes: entityTypes,\n selected: selectedEntityType,\n onChange (payload) {\n dispatch({\n type: \"select-entity-type\",\n payload: payload\n });\n },\n isOpen: isSelectingEntityType,\n setOpen: (isOpen)=>dispatch({\n type: \"toggle-entity-type-selector\",\n payload: isOpen\n })\n })\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, $d5ed517fac59fa65$exports.GraphView), {\n tree: tree,\n width: width,\n height: height\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 }) {\n // Show all entity types when selected is null\n const _selected = selected != null ? selected : undefined;\n return $2c86488f2f3c1edd$var$h((0, $ajJMX$DataField), {\n label: \"Entity type\",\n inline: true\n }, [\n $2c86488f2f3c1edd$var$h(\"code.bp5-code\", {\n onClick () {\n setOpen((d)=>!d);\n }\n }, selected.name),\n $2c86488f2f3c1edd$var$h((0, $9dde9e77df32d024$exports.OmniboxSelector), {\n isOpen: isOpen,\n items: Array.from(entityTypes.values()),\n selectedItem: _selected,\n onSelectItem (item) {\n setOpen(false);\n onChange(item);\n },\n onClose () {\n setOpen(false);\n }\n })\n ]);\n}\nfunction $2c86488f2f3c1edd$var$ManagedSelectionTree(props) {\n const { selectedNodes: selectedNodes, dispatch: dispatch, tree: tree, height: height, width: width, matchComponent: matchComponent, ...rest } = props;\n const ref = (0, $ajJMX$useRef)();\n const _Node = (0, $ajJMX$useCallback)((props)=>$2c86488f2f3c1edd$var$h((0, (/*@__PURE__*/$parcel$interopDefault($7d518355fc256b3f$exports))), {\n ...props,\n matchComponent: matchComponent\n }), [\n matchComponent\n ]);\n (0, $ajJMX$useEffect)(()=>{\n if (ref.current == null) return;\n // Check if selection matches current\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 // If the selection is the same, do nothing\n // Set selection\n ref.current.setSelection({\n ids: selectedNodes.map((d)=>d.toString()),\n anchor: null,\n mostRecent: null\n });\n }, [\n selectedNodes\n ]);\n return $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 (nodes) {\n let ids = nodes.map((d)=>parseInt(d.id));\n if (ids.length == 1 && ids[0] == selectedNodes[0]) // Deselect\n ids = [];\n dispatch({\n type: \"select-node\",\n payload: {\n ids: ids\n }\n });\n },\n children: _Node,\n idAccessor (d) {\n return d.id.toString();\n }\n });\n}\n\n\n//# sourceMappingURL=feedback.8d3d1219.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 { ModelInfo } from \"../extractions\";\nimport {\n TreeDispatchContext,\n treeToGraph,\n useUpdatableTree,\n ViewMode,\n} from \"./edit-state\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport { ButtonGroup, Card, SegmentedControl } from \"@blueprintjs/core\";\nimport { OmniboxSelector } from \"./type-selector\";\nimport {\n CancelButton,\n DataField,\n FlexBox,\n FlexRow,\n SaveButton,\n} from \"@macrostrat/ui-components\";\nimport useElementDimensions from \"use-element-dimensions\";\nimport { GraphView } from \"./graph\";\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}) {\n // Get the input arguments\n\n const [state, dispatch] = useUpdatableTree(\n entities.map(processEntity) as any,\n entityTypes\n );\n\n const { selectedNodes, tree, selectedEntityType, isSelectingEntityType } =\n state;\n\n const [{ width, height }, ref] = useElementDimensions();\n\n return h(TreeDispatchContext.Provider, { value: dispatch }, [\n h(FeedbackText, {\n text,\n dispatch,\n // @ts-ignore\n nodes: tree,\n selectedNodes,\n }),\n h(FlexRow, { alignItems: \"baseline\", justifyContent: \"space-between\" }, [\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 h(\n \"div.entity-panel\",\n {\n ref,\n },\n [\n h(Card, { className: \"control-panel\" }, [\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(EntityTypeSelector, {\n entityTypes,\n selected: selectedEntityType,\n onChange(payload) {\n dispatch({ type: \"select-entity-type\", payload });\n },\n isOpen: isSelectingEntityType,\n setOpen: (isOpen: boolean) =>\n dispatch({\n type: \"toggle-entity-type-selector\",\n payload: isOpen,\n }),\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 }),\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}) {\n // Show all entity types when selected is null\n const _selected = selected != null ? selected : undefined;\n return h(DataField, { label: \"Entity type\", inline: true }, [\n h(\n \"code.bp5-code\",\n {\n onClick() {\n setOpen((d) => !d);\n },\n },\n selected.name\n ),\n h(OmniboxSelector, {\n isOpen,\n items: Array.from(entityTypes.values()),\n selectedItem: _selected,\n onSelectItem(item) {\n setOpen(false);\n onChange(item);\n },\n onClose() {\n setOpen(false);\n },\n }),\n ]);\n}\n\nfunction ManagedSelectionTree(props) {\n const {\n selectedNodes,\n dispatch,\n tree,\n height,\n width,\n matchComponent,\n ...rest\n } = props;\n\n const ref = useRef<TreeApi<TreeData>>();\n\n const _Node = useCallback(\n (props) => h(Node, { ...props, matchComponent }),\n [matchComponent]\n );\n\n useEffect(() => {\n if (ref.current == null) return;\n // Check if selection matches current\n const selection = new Set(selectedNodes.map((d) => d.toString()));\n const currentSelection = ref.current.selectedIds;\n if (setsAreTheSame(selection, currentSelection)) return;\n // If the selection is the same, do nothing\n\n // Set selection\n ref.current.setSelection({\n ids: selectedNodes.map((d) => d.toString()),\n anchor: null,\n mostRecent: null,\n });\n }, [selectedNodes]);\n\n return 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(nodes) {\n let ids = nodes.map((d) => parseInt(d.id));\n if (ids.length == 1 && ids[0] == selectedNodes[0]) {\n // Deselect\n ids = [];\n }\n dispatch({ type: \"select-node\", payload: { ids } });\n },\n children: _Node,\n idAccessor(d: TreeData) {\n return d.id.toString();\n },\n });\n}\n","module.exports = require('./helpers/bundle-url').getBundleURL('ajJMX') + \"feedback.module.c4eab97d.css\";","module.exports = require('./helpers/bundle-url').getBundleURL('ajJMX') + \"node.33108ccc.js\";","module.exports = require('./helpers/bundle-url').getBundleURL('ajJMX') + \"text-visualizer.1e770afa.js\";","module.exports = require('./helpers/bundle-url').getBundleURL('ajJMX') + \"type-selector.0035ef7d.js\";","module.exports = require('./helpers/bundle-url').getBundleURL('ajJMX') + \"graph.ca5b649f.js\";"],"names":["$ajJMX$macrostrathyper","a","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$8e7fa15260c024b8$exports","getBundleURL","styled","__esModule","default"],"version":3,"file":"feedback.8d3d1219.js.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- function e(e,n,o,t){Object.defineProperty(e,n,{get:o,set:t,enumerable:!0,configurable:!0})}var n,o,t,c,a,l,r={};e(r,"control-panel",()=>n,e=>n=e),e(r,"entity-panel",()=>o,e=>o=e),e(r,"feedback-component",()=>t,e=>t=e),e(r,"feedback-text",()=>c,e=>c=e),e(r,"node",()=>a,e=>a=e),e(r,"selection-tree",()=>l,e=>l=e),n="QoX8-W_control-panel",o="QoX8-W_entity-panel",t="QoX8-W_feedback-component",c="QoX8-W_feedback-text",a="QoX8-W_node",l="QoX8-W_selection-tree";
2
- //# sourceMappingURL=feedback.module.a8744203.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,E,E,C,E,E,E,gB,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,gB,I,E,A,G,E,G,E,E,O,I,E,A,G,E,G,E,E,iB,I,E,A,G,E,GALA,EAAkC,uBAClC,EAAiC,sBACjC,EAAuC,4BACvC,EAAkC,uBAClC,EAAyB,cACzB,EAAmC","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, \"control-panel\", () => $01ca2f1f49a3a114$export$a0a23f31d5562853, (v) => $01ca2f1f49a3a114$export$a0a23f31d5562853 = 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-text\", () => $01ca2f1f49a3a114$export$890489be1870bed5, (v) => $01ca2f1f49a3a114$export$890489be1870bed5 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"node\", () => $01ca2f1f49a3a114$export$35059013cd4a06db, (v) => $01ca2f1f49a3a114$export$35059013cd4a06db = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"selection-tree\", () => $01ca2f1f49a3a114$export$3ae1b51693c80a9c, (v) => $01ca2f1f49a3a114$export$3ae1b51693c80a9c = v);\nvar $01ca2f1f49a3a114$export$a0a23f31d5562853;\nvar $01ca2f1f49a3a114$export$38f2cd12e45697e;\nvar $01ca2f1f49a3a114$export$579bd45c78bf5510;\nvar $01ca2f1f49a3a114$export$890489be1870bed5;\nvar $01ca2f1f49a3a114$export$35059013cd4a06db;\nvar $01ca2f1f49a3a114$export$3ae1b51693c80a9c;\n$01ca2f1f49a3a114$export$a0a23f31d5562853 = `QoX8-W_control-panel`;\n$01ca2f1f49a3a114$export$38f2cd12e45697e = `QoX8-W_entity-panel`;\n$01ca2f1f49a3a114$export$579bd45c78bf5510 = `QoX8-W_feedback-component`;\n$01ca2f1f49a3a114$export$890489be1870bed5 = `QoX8-W_feedback-text`;\n$01ca2f1f49a3a114$export$35059013cd4a06db = `QoX8-W_node`;\n$01ca2f1f49a3a114$export$3ae1b51693c80a9c = `QoX8-W_selection-tree`;\n\n\n//# sourceMappingURL=feedback.module.a8744203.js.map\n",null],"names":["$parcel$export","e","n","v","s","Object","defineProperty","get","set","enumerable","configurable","$01ca2f1f49a3a114$export$a0a23f31d5562853","$01ca2f1f49a3a114$export$38f2cd12e45697e","$01ca2f1f49a3a114$export$579bd45c78bf5510","$01ca2f1f49a3a114$export$890489be1870bed5","$01ca2f1f49a3a114$export$35059013cd4a06db","$01ca2f1f49a3a114$export$3ae1b51693c80a9c","$01ca2f1f49a3a114$exports"],"version":3,"file":"feedback.module.a8744203.js.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- .QoX8-W_feedback-component{width:800px;position:relative}.QoX8-W_feedback-component>svg{width:800px}.QoX8-W_node{cursor:pointer}.QoX8-W_feedback-text{margin-bottom:2em}.QoX8-W_entity-panel{max-height:600px;position:relative}.QoX8-W_control-panel{max-width:15em;padding:.2em .5em;position:absolute;top:1em;right:1em}.QoX8-W_entity-panel{background:var(--panel-secondary-background-color);min-height:100px;box-shadow:0 0 0 1px var(--panel-border-color)inset;border-radius:4px;flex:1;padding:1em}.QoX8-W_selection-tree{margin:-1em 0;padding:1em 0}
2
- /*# sourceMappingURL=feedback.module.c4eab97d.css.map */
@@ -1 +0,0 @@
1
- {"mappings":"ACAA,yDAIE,2CAGF,4BAIA,wCAGA,wDAIA,2FAOA,kLASA","sources":["feedback.module.c4eab97d.css","packages/feedback-components/src/feedback/feedback.module.sass"],"sourcesContent":[".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\n.QoX8-W_feedback-text {\n margin-bottom: 2em;\n}\n\n.QoX8-W_entity-panel {\n max-height: 600px;\n position: relative;\n}\n\n.QoX8-W_control-panel {\n max-width: 15em;\n padding: .2em .5em;\n position: absolute;\n top: 1em;\n right: 1em;\n}\n\n.QoX8-W_entity-panel {\n background: var(--panel-secondary-background-color);\n min-height: 100px;\n box-shadow: 0 0 0 1px var(--panel-border-color) inset;\n border-radius: 4px;\n flex: 1;\n padding: 1em;\n}\n\n.QoX8-W_selection-tree {\n margin: -1em 0;\n padding: 1em 0;\n}\n/*# sourceMappingURL=feedback.module.c4eab97d.css.map */\n",".feedback-component\n position: relative\n width: 800px\n\n & > svg\n width: 800px\n\n.node\n cursor: pointer\n\n\n.feedback-text\n margin-bottom: 2em\n\n.entity-panel\n position: relative\n max-height: 600px\n\n.control-panel\n max-width: 15em\n position: absolute\n top: 1em\n right: 1em\n padding: 0.2em 0.5em\n\n.entity-panel\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"],"names":[],"version":3,"file":"feedback.module.c4eab97d.css.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- import"@macrostrat/hyper";import"d3-force";import"react";import"@blueprintjs/core";var r=globalThis,e={},t={},o=r.parcelRequire94c2;null==o&&((o=function(r){if(r in e)return e[r].exports;if(r in t){var o=t[r];delete t[r];var i={id:r,exports:{}};return e[r]=i,o.call(i.exports,i,i.exports),i.exports}var n=Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}).register=function(r,e){t[r]=e},r.parcelRequire94c2=o),o.register,o("eedTh");
2
- //# sourceMappingURL=graph.ca5b649f.js.map
@@ -1 +0,0 @@
1
- {"mappings":"A,M,mB,A,O,U,A,O,O,A,O,mB,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,E","sources":["<anon>","packages/feedback-components/src/feedback/graph.ts"],"sourcesContent":["import $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} from \"@blueprintjs/core\";\n\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequire94c2\"];\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[\"parcelRequire94c2\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\n\nvar $eedTh = parcelRequire(\"eedTh\");\n\n\n\n\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 } = props;\n const [nodes, setNodes] = (0, $9bqpz$useState)(null);\n const [links, setLinks] = (0, $9bqpz$useState)(null);\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 (0, $9bqpz$macrostrathyper)((0, $9bqpz$Spinner));\n console.log(\"Graph\", nodes, links);\n return (0, $9bqpz$macrostrathyper)(\"div.graph-view\", {\n style: {\n width: width,\n height: height\n }\n }, [\n (0, $9bqpz$macrostrathyper)(\"svg\", {\n width: width,\n height: height\n }, [\n (0, $9bqpz$macrostrathyper)(\"g.nodes\", nodes.map((d)=>{\n return (0, $9bqpz$macrostrathyper)(\"circle\", {\n cx: d.x,\n cy: d.y,\n r: 5,\n fill: \"blue\"\n });\n })),\n (0, $9bqpz$macrostrathyper)(\"g.links\", links.map((d)=>{\n return (0, $9bqpz$macrostrathyper)(\"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 ]);\n}\n\n\n//# sourceMappingURL=graph.ca5b649f.js.map\n","import { TreeData } from \"./types\";\nimport { treeToGraph } from \"./edit-state\";\nimport h from \"@macrostrat/hyper\";\n\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 } from \"@blueprintjs/core\";\n\nexport function GraphView(props: {\n tree: TreeData[];\n width: number;\n height: number;\n}) {\n // A graph view with react-flow\n // Get positions of nodes using force simulation\n const { tree, width, height } = props;\n\n const [nodes, setNodes] = useState<SimulationNodeDatum[]>(null);\n const [links, setLinks] = useState<SimulationLinkDatum[]>(null);\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);\n\n return h(\"div.graph-view\", { style: { width, height } }, [\n h(\"svg\", { width, height }, [\n h(\n \"g.nodes\",\n nodes.map((d) => {\n return h(\"circle\", {\n cx: d.x,\n cy: d.y,\n r: 5,\n fill: \"blue\",\n });\n })\n ),\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 ]),\n ]);\n}\n"],"names":["$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register"],"version":3,"file":"graph.ca5b649f.js.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- function e(e,t,a,c){Object.defineProperty(e,t,{get:a,set:c,enumerable:!0,configurable:!0})}var t,a,c,n={};e(n,"item-container",()=>t,e=>t=e),e(n,"selected",()=>a,e=>a=e),e(n,"swatch",()=>c,e=>c=e),t="WofFTa_item-container",a="WofFTa_selected",c="WofFTa_swatch";
2
- //# sourceMappingURL=main.module.1857be22.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,E,E,C,E,E,E,iB,I,E,A,G,E,G,E,E,W,I,E,A,G,E,G,E,E,S,I,E,A,G,E,GAFA,EAAmC,wBACnC,EAA6B,kBAC7B,EAA2B","sources":["<anon>","packages/feedback-components/src/feedback/type-selector/main.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 $f57561eafb1aa284$exports = {};\n\n$parcel$export($f57561eafb1aa284$exports, \"item-container\", () => $f57561eafb1aa284$export$68a2d1df2d976de8, (v) => $f57561eafb1aa284$export$68a2d1df2d976de8 = v);\n$parcel$export($f57561eafb1aa284$exports, \"selected\", () => $f57561eafb1aa284$export$d90250155de6d7e7, (v) => $f57561eafb1aa284$export$d90250155de6d7e7 = v);\n$parcel$export($f57561eafb1aa284$exports, \"swatch\", () => $f57561eafb1aa284$export$c672d9950c40fe0a, (v) => $f57561eafb1aa284$export$c672d9950c40fe0a = v);\nvar $f57561eafb1aa284$export$68a2d1df2d976de8;\nvar $f57561eafb1aa284$export$d90250155de6d7e7;\nvar $f57561eafb1aa284$export$c672d9950c40fe0a;\n$f57561eafb1aa284$export$68a2d1df2d976de8 = `WofFTa_item-container`;\n$f57561eafb1aa284$export$d90250155de6d7e7 = `WofFTa_selected`;\n$f57561eafb1aa284$export$c672d9950c40fe0a = `WofFTa_swatch`;\n\n\n//# sourceMappingURL=main.module.1857be22.js.map\n",null],"names":["$parcel$export","e","n","v","s","Object","defineProperty","get","set","enumerable","configurable","$f57561eafb1aa284$export$68a2d1df2d976de8","$f57561eafb1aa284$export$d90250155de6d7e7","$f57561eafb1aa284$export$c672d9950c40fe0a","$f57561eafb1aa284$exports"],"version":3,"file":"main.module.1857be22.js.map","sourceRoot":"../../../../"}
@@ -1 +0,0 @@
1
- {"mappings":"ACAA,gDAIE,qDAGF","sources":["main.module.1fdfe813.css","packages/feedback-components/src/extractions/main.module.sass"],"sourcesContent":[".UZr1Jq_entities {\n padding-left: 0;\n list-style: none;\n}\n\n.UZr1Jq_entities .UZr1Jq_entities ul {\n list-style: none;\n}\n\n.UZr1Jq_entity {\n margin: .2em 0 .5em;\n padding-right: 3px;\n}\n/*# sourceMappingURL=main.module.1fdfe813.css.map */\n",".entities\n list-style: none\n padding-left: 0\n\n .entities ul\n list-style: none\n\n.entity\n margin: 0.2em 0 0.5em\n padding-right: 3px\n"],"names":[],"version":3,"file":"main.module.1fdfe813.css.map","sourceRoot":"../../../../"}
@@ -1 +0,0 @@
1
- {"mappings":"ACAA,+EAME,sFAGF","sources":["main.module.6bc7d51b.css","packages/feedback-components/src/feedback/type-selector/main.module.sass"],"sourcesContent":[".WofFTa_item-container {\n align-items: center;\n gap: 1em;\n min-height: 40px;\n display: flex;\n}\n\n.WofFTa_item-container.WofFTa_selected {\n background-color: var(--panel-background-color);\n}\n\n.WofFTa_swatch {\n border-radius: 4px;\n width: 30px;\n height: 30px;\n}\n/*# sourceMappingURL=main.module.6bc7d51b.css.map */\n",".item-container\n min-height: 40px\n display: flex\n align-items: center\n gap: 1em\n\n &.selected\n background-color: var(--panel-background-color)\n\n.swatch\n width: 30px\n height: 30px\n border-radius: 4px\n"],"names":[],"version":3,"file":"main.module.6bc7d51b.css.map","sourceRoot":"../../../../"}
@@ -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,E,E,C,E,E,E,W,I,E,A,G,E,G,E,E,S,I,E,A,G,E,GADA,EAA6B,kBAC7B,EAA2B","sources":["<anon>","packages/feedback-components/src/extractions/main.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 $1c152ab3b3d783a7$exports = {};\n\n$parcel$export($1c152ab3b3d783a7$exports, \"entities\", () => $1c152ab3b3d783a7$export$5345fd892b40e1f6, (v) => $1c152ab3b3d783a7$export$5345fd892b40e1f6 = v);\n$parcel$export($1c152ab3b3d783a7$exports, \"entity\", () => $1c152ab3b3d783a7$export$4b5127edceda427d, (v) => $1c152ab3b3d783a7$export$4b5127edceda427d = v);\nvar $1c152ab3b3d783a7$export$5345fd892b40e1f6;\nvar $1c152ab3b3d783a7$export$4b5127edceda427d;\n$1c152ab3b3d783a7$export$5345fd892b40e1f6 = `UZr1Jq_entities`;\n$1c152ab3b3d783a7$export$4b5127edceda427d = `UZr1Jq_entity`;\n\n\n//# sourceMappingURL=main.module.ebdf985b.js.map\n",null],"names":["$parcel$export","e","n","v","s","Object","defineProperty","get","set","enumerable","configurable","$1c152ab3b3d783a7$export$5345fd892b40e1f6","$1c152ab3b3d783a7$export$4b5127edceda427d","$1c152ab3b3d783a7$exports"],"version":3,"file":"main.module.ebdf985b.js.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- import r from"@macrostrat/hyper";var e=globalThis,t={},o={},i=e.parcelRequire94c2;null==i&&((i=function(r){if(r in t)return t[r].exports;if(r in o){var e=o[r];delete o[r];var i={id:r,exports:{}};return t[r]=i,e.call(i.exports,i,i.exports),i.exports}var a=Error("Cannot find module '"+r+"'");throw a.code="MODULE_NOT_FOUND",a}).register=function(r,e){o[r]=e},e.parcelRequire94c2=i),i.register,i("edvRb"),i("daZiC").getBundleURL("hPIF3");var a=i("9wFEx");r.styled(a&&a.__esModule?a.default:a);
2
- //# sourceMappingURL=node.33108ccc.js.map
@@ -1 +0,0 @@
1
- {"mappings":"A,O,M,mB,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,E,SEAiB,AAAA,EAAA,SAAA,YAAA,CAA6C,S,I,E,E,SDOpD,AAAA,EAAM,MAAM,C,AAAC,G,AAAA,E,U,C,AAAA,E,O,CAAA","sources":["<anon>","packages/feedback-components/src/feedback/node.ts","../../../../.yarn/berry/cache/@parcel-runtime-js-npm-2.13.3-f44fec8492-10c0.zip/node_modules/@parcel/runtime-js/lib/runtime-be5b24876b77195e.js"],"sourcesContent":["import $hPIF3$macrostrathyper from \"@macrostrat/hyper\";\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[\"parcelRequire94c2\"];\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[\"parcelRequire94c2\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\n\nvar $edvRb = parcelRequire(\"edvRb\");\nvar $d834190537e68c62$exports = {};\n\n$d834190537e68c62$exports = (parcelRequire(\"daZiC\")).getBundleURL('hPIF3') + \"edit-state.f50ca728.js\";\n\n\n\nvar $9wFEx = parcelRequire(\"9wFEx\");\n\nconst $2e9ede27ff2a3eea$var$h = (0, $hPIF3$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wFEx))));\nfunction $2e9ede27ff2a3eea$var$isSelected(searchNode, treeNode) {\n return searchNode.id == treeNode.id;\n// We could also select children of the search node here if we wanted to\n}\nfunction $2e9ede27ff2a3eea$var$isNodeHighlighted(node, tree) {\n // We treat no selection as all nodes being active. We may add some nuance later\n if (tree.selectedNodes.length == 0) return true;\n for (const selectedNode of tree.selectedNodes){\n if ($2e9ede27ff2a3eea$var$isSelected(node.data, selectedNode.data)) return true;\n }\n // Check if the parent node is highlighted\n if (node.parent != null && $2e9ede27ff2a3eea$var$isNodeHighlighted(node.parent, tree)) return true;\n return false;\n}\nfunction $2e9ede27ff2a3eea$var$isNodeActive(node, tree) {\n for (const selectedNode of tree.selectedNodes){\n if ($2e9ede27ff2a3eea$var$isSelected(node.data, selectedNode.data)) return true;\n }\n return false;\n}\nfunction $2e9ede27ff2a3eea$var$Node({ node: node, style: style, dragHandle: dragHandle, tree: tree, matchComponent: matchComponent }) {\n let highlighted = $2e9ede27ff2a3eea$var$isNodeHighlighted(node, tree);\n let active = $2e9ede27ff2a3eea$var$isNodeActive(node, tree);\n const dispatch = (0, $d834190537e68c62$exports.useTreeDispatch)();\n return $2e9ede27ff2a3eea$var$h(\"div.node\", {\n style: style,\n ref: dragHandle\n }, $2e9ede27ff2a3eea$var$h((0, $edvRb.EntityTag), {\n data: node.data,\n active: active,\n highlighted: highlighted,\n matchComponent: matchComponent,\n onClickType () {\n dispatch({\n type: \"toggle-entity-type-selector\"\n });\n }\n }));\n}\nvar $2e9ede27ff2a3eea$export$2e2bcd8739ae039 = $2e9ede27ff2a3eea$var$Node;\n\n\n//# sourceMappingURL=node.33108ccc.js.map\n","import { NodeApi, TreeApi } from \"react-arborist\";\nimport { TreeData } from \"./types\";\nimport { EntityTag } from \"../extractions\";\nimport { useTreeDispatch } from \"./edit-state\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\n\nconst h = hyper.styled(styles);\n\nfunction isSelected(searchNode: TreeData, treeNode: TreeData) {\n return searchNode.id == treeNode.id;\n // We could also select children of the search node here if we wanted to\n}\n\nfunction isNodeHighlighted(node: NodeApi<TreeData>, tree: TreeApi<TreeData>) {\n // We treat no selection as all nodes being active. We may add some nuance later\n if (tree.selectedNodes.length == 0) {\n return true;\n }\n\n for (const selectedNode of tree.selectedNodes) {\n if (isSelected(node.data, selectedNode.data)) {\n return true;\n }\n }\n\n // Check if the parent node is highlighted\n if (node.parent != null && isNodeHighlighted(node.parent, tree)) {\n return true;\n }\n\n return false;\n}\n\nfunction isNodeActive(node: NodeApi<TreeData>, tree: TreeApi<TreeData>) {\n for (const selectedNode of tree.selectedNodes) {\n if (isSelected(node.data, selectedNode.data)) {\n return true;\n }\n }\n return false;\n}\n\nfunction Node({ node, style, dragHandle, tree, matchComponent }: any) {\n let highlighted: boolean = isNodeHighlighted(node, tree);\n let active: boolean = isNodeActive(node, tree);\n\n const dispatch = useTreeDispatch();\n\n return h(\n \"div.node\",\n { style, ref: dragHandle },\n h(EntityTag, {\n data: node.data,\n active,\n highlighted,\n matchComponent,\n onClickType() {\n dispatch({ type: \"toggle-entity-type-selector\" });\n },\n })\n );\n}\n\nexport default Node;\n","module.exports = require('./helpers/bundle-url').getBundleURL('hPIF3') + \"edit-state.f50ca728.js\";"],"names":["$hPIF3$macrostrathyper","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","getBundleURL","$9wFEx","styled","a","__esModule","default"],"version":3,"file":"node.33108ccc.js.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- import"react-text-annotate-blend";import r from"@macrostrat/hyper";import"react";var e=globalThis,t={},o={},a=e.parcelRequire94c2;null==a&&((a=function(r){if(r in t)return t[r].exports;if(r in o){var e=o[r];delete o[r];var a={id:r,exports:{}};return t[r]=a,e.call(a.exports,a,a.exports),a.exports}var i=Error("Cannot find module '"+r+"'");throw i.code="MODULE_NOT_FOUND",i}).register=function(r,e){o[r]=e},e.parcelRequire94c2=a),a.register;var i=a("9wFEx");a("edvRb"),r.styled(i&&i.__esModule?i.default:i);
2
- //# sourceMappingURL=text-visualizer.1e770afa.js.map
@@ -1 +0,0 @@
1
- {"mappings":"A,M,2B,A,Q,M,mB,A,O,O,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,SCSU,AAAA,EAAM,MAAM,C,AAAC,G,AAAA,E,U,C,AAAA,E,O,CAAA","sources":["<anon>","packages/feedback-components/src/feedback/text-visualizer.ts"],"sourcesContent":["import {TextAnnotateBlend as $h8ona$TextAnnotateBlend} from \"react-text-annotate-blend\";\nimport $h8ona$macrostrathyper from \"@macrostrat/hyper\";\nimport {useCallback as $h8ona$useCallback} from \"react\";\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[\"parcelRequire94c2\"];\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[\"parcelRequire94c2\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\n\n\nvar $9wFEx = parcelRequire(\"9wFEx\");\n\n\nvar $edvRb = parcelRequire(\"edvRb\");\n\nconst $d6cf457c7790c03a$var$h = (0, $h8ona$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wFEx))));\nfunction $d6cf457c7790c03a$var$buildTags(highlights, selectedNodes) {\n let tags = [];\n // If entity ID has already been seen, don't add it again\n const entities = new Set();\n for (const highlight of highlights){\n // Don't add multiply-linked entities multiple times\n if (entities.has(highlight.id)) continue;\n const highlighted = $d6cf457c7790c03a$var$isHighlighted(highlight, selectedNodes);\n const active = $d6cf457c7790c03a$var$isActive(highlight, selectedNodes);\n tags.push({\n markStyle: {\n ...(0, $edvRb.getTagStyle)(highlight.backgroundColor, {\n highlighted: highlighted,\n active: active\n }),\n borderRadius: \"0.2em\",\n padding: \"0.1em\",\n borderWidth: \"1.5px\",\n cursor: \"pointer\"\n },\n tagStyle: {\n display: \"none\"\n },\n ...highlight\n });\n entities.add(highlight.id);\n }\n return tags;\n}\nfunction $d6cf457c7790c03a$var$isActive(tag, selectedNodes) {\n return selectedNodes.includes(tag.id);\n}\nfunction $d6cf457c7790c03a$var$isHighlighted(tag, selectedNodes) {\n if (selectedNodes.length === 0) return true;\n return (selectedNodes.includes(tag.id) || tag.parents?.some((d)=>selectedNodes.includes(d))) ?? false;\n}\nfunction $d6cf457c7790c03a$export$6e107db9091b8219(props) {\n // Convert input to tags\n const { text: text, selectedNodes: selectedNodes, nodes: nodes, dispatch: dispatch } = props;\n let allTags = $d6cf457c7790c03a$var$buildTags((0, $edvRb.buildHighlights)(nodes, null), selectedNodes);\n const onChange = (0, $h8ona$useCallback)((tags)=>{\n // New tags\n console.log(tags);\n const newTags = tags.filter((d)=>!(\"id\" in d));\n if (newTags.length > 0) {\n const { start: start, end: end } = newTags[0];\n const payload = {\n start: start,\n end: end,\n text: text.slice(start, end)\n };\n dispatch({\n type: \"create-node\",\n payload: payload\n });\n return;\n }\n const tagIDs = new Set(tags.map((d)=>d.id));\n const removedIds = allTags.map((d)=>d.id).filter((d)=>!tagIDs.has(d));\n /* Find the id that was removed: that is the one that will be selected\n (we are hijacking the 'click to delete' functionality to select instead) */ if (removedIds.length > 0) dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: removedIds\n }\n });\n }, [\n allTags,\n text\n ]);\n return $d6cf457c7790c03a$var$h((0, $h8ona$TextAnnotateBlend), {\n style: {\n fontSize: \"1.2em\"\n },\n className: \"feedback-text\",\n content: text,\n onChange: onChange,\n value: allTags\n });\n}\n\n\n//# sourceMappingURL=text-visualizer.1e770afa.js.map\n","import { AnnotateBlendTag, TextAnnotateBlend } from \"react-text-annotate-blend\";\nimport { InternalEntity } from \"./types\";\nimport { TreeDispatch } from \"./edit-state\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\nimport { buildHighlights, getTagStyle } from \"../extractions\";\nimport { Highlight } from \"../extractions/types\";\nimport { useCallback } from \"react\";\n\nconst h = hyper.styled(styles);\n\nexport interface FeedbackTextProps {\n text: string;\n selectedNodes: number[];\n nodes: InternalEntity[];\n updateNodes: (nodes: string[]) => void;\n dispatch: TreeDispatch;\n}\n\nfunction buildTags(\n highlights: Highlight[],\n selectedNodes: number[]\n): AnnotateBlendTag[] {\n let tags: AnnotateBlendTag[] = [];\n\n // If entity ID has already been seen, don't add it again\n const entities = new Set<number>();\n\n for (const highlight of highlights) {\n // Don't add multiply-linked entities multiple times\n if (entities.has(highlight.id)) continue;\n\n const highlighted = isHighlighted(highlight, selectedNodes);\n const active = isActive(highlight, selectedNodes);\n\n tags.push({\n markStyle: {\n ...getTagStyle(highlight.backgroundColor, {\n highlighted,\n active,\n }),\n borderRadius: \"0.2em\",\n padding: \"0.1em\",\n borderWidth: \"1.5px\",\n cursor: \"pointer\",\n },\n tagStyle: {\n display: \"none\",\n },\n ...highlight,\n });\n\n entities.add(highlight.id);\n }\n\n return tags;\n}\n\nfunction isActive(tag: Highlight, selectedNodes: number[]) {\n return selectedNodes.includes(tag.id);\n}\n\nfunction isHighlighted(tag: Highlight, selectedNodes: number[]) {\n if (selectedNodes.length === 0) return true;\n return (\n (selectedNodes.includes(tag.id) ||\n tag.parents?.some((d) => selectedNodes.includes(d))) ??\n false\n );\n}\n\nexport function FeedbackText(props: FeedbackTextProps) {\n // Convert input to tags\n const { text, selectedNodes, nodes, dispatch } = props;\n let allTags: AnnotateBlendTag[] = buildTags(\n buildHighlights(nodes, null),\n selectedNodes\n );\n\n const onChange = useCallback(\n (tags) => {\n // New tags\n console.log(tags);\n const newTags = tags.filter((d) => !(\"id\" in d));\n if (newTags.length > 0) {\n const { start, end } = newTags[0];\n const payload = { start, end, text: text.slice(start, end) };\n dispatch({ type: \"create-node\", payload });\n return;\n }\n\n const tagIDs = new Set(tags.map((d) => d.id));\n const removedIds = allTags.map((d) => d.id).filter((d) => !tagIDs.has(d));\n\n /* Find the id that was removed: that is the one that will be selected\n (we are hijacking the 'click to delete' functionality to select instead) */\n if (removedIds.length > 0) {\n dispatch({\n type: \"toggle-node-selected\",\n payload: { ids: removedIds },\n });\n }\n },\n [allTags, text]\n );\n\n return h(TextAnnotateBlend, {\n style: {\n fontSize: \"1.2em\",\n },\n className: \"feedback-text\",\n content: text,\n onChange,\n value: allTags,\n });\n}\n"],"names":["$h8ona$macrostrathyper","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$9wFEx","styled","a","__esModule","default"],"version":3,"file":"text-visualizer.1e770afa.js.map","sourceRoot":"../../../../"}
@@ -1,2 +0,0 @@
1
- import e from"@macrostrat/hyper";import"classnames";import"@blueprintjs/select";import"@blueprintjs/select/lib/css/blueprint-select.css";var r,t=globalThis,s={},i={},l=t.parcelRequire94c2;null==l&&((l=function(e){if(e in s)return s[e].exports;if(e in i){var r=i[e];delete i[e];var t={id:e,exports:{}};return s[e]=t,r.call(t.exports,t,t.exports),t.exports}var l=Error("Cannot find module '"+e+"'");throw l.code="MODULE_NOT_FOUND",l}).register=function(e,r){i[e]=r},t.parcelRequire94c2=l),l.register;var o={};o=l("daZiC").getBundleURL("16Zb4")+"main.module.6bc7d51b.css",e.styled((r=o)&&r.__esModule?r.default:r);
2
- //# sourceMappingURL=type-selector.0035ef7d.js.map
@@ -1 +0,0 @@
1
- {"mappings":"A,O,M,mB,A,O,Y,A,O,qB,A,O,kD,C,I,E,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,EEAA,EAAiB,AAAA,EAAA,SAAA,YAAA,CAA6C,SAAW,4CDY/D,AAAA,EAAM,MAAM,C,C,EAAC,I,E,U,C,E,O,C","sources":["<anon>","packages/feedback-components/src/feedback/type-selector/index.ts","../../../../.yarn/berry/cache/@parcel-runtime-js-npm-2.13.3-f44fec8492-10c0.zip/node_modules/@parcel/runtime-js/lib/runtime-d2adba764022ad20.js"],"sourcesContent":["import $16Zb4$macrostrathyper from \"@macrostrat/hyper\";\nimport $16Zb4$classnames from \"classnames\";\nimport {Omnibar as $16Zb4$Omnibar} from \"@blueprintjs/select\";\nimport \"@blueprintjs/select/lib/css/blueprint-select.css\";\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[\"parcelRequire94c2\"];\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[\"parcelRequire94c2\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\n/**\n * Entity type selector\n */ var $40e2e1c28f0230c6$exports = {};\n\n$40e2e1c28f0230c6$exports = (parcelRequire(\"daZiC\")).getBundleURL('16Zb4') + \"main.module.6bc7d51b.css\";\n\n\n\n\n\n\nconst $48d99b99dde7627d$var$h = (0, $16Zb4$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($40e2e1c28f0230c6$exports))));\nconst $48d99b99dde7627d$var$TagListItem = (props)=>{\n /** Render a tag for the omnibox list */ let { active: active, selected: selected, className: className, onSelect: onSelect, item: item, children: children } = props;\n className = (0, $16Zb4$classnames)({\n active: active,\n selected: selected\n }, className);\n const onClick = ()=>onSelect(item);\n return $48d99b99dde7627d$var$h(\"div.item-container\", {\n key: item.id,\n className: className,\n onClick: onClick\n }, [\n $48d99b99dde7627d$var$h(\"div.swatch\", {\n style: {\n backgroundColor: item.color\n }\n }),\n $48d99b99dde7627d$var$h(\"div.item\", {}, item.name)\n ]);\n};\nfunction $48d99b99dde7627d$export$d8660660a589068c(props) {\n /** A general omnibox for annotation types */ const { onSelectItem: onSelectItem, items: items, isOpen: isOpen, onClose: onClose } = props;\n return $48d99b99dde7627d$var$h((0, $16Zb4$Omnibar), {\n onItemSelect: onSelectItem,\n items: items,\n resetOnSelect: false,\n isOpen: isOpen,\n onClose: onClose,\n itemRenderer (item, { handleClick: handleClick, modifiers: modifiers }) {\n return $48d99b99dde7627d$var$h($48d99b99dde7627d$var$TagListItem, {\n key: item.id,\n item: item,\n onSelect: handleClick,\n active: modifiers.active,\n selected: modifiers.active\n });\n }\n });\n}\n\n\n//# sourceMappingURL=type-selector.0035ef7d.js.map\n","/**\n * Entity type selector\n */\n\nimport styles from \"./main.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\n\nimport classNames from \"classnames\";\nimport React from \"react\";\nimport { Omnibar, OmnibarProps } from \"@blueprintjs/select\";\nimport \"@blueprintjs/select/lib/css/blueprint-select.css\";\n\nconst h = hyper.styled(styles);\n\ninterface TagItemProps<T> {\n selected: boolean;\n active: boolean;\n className?: string;\n item: T;\n\n onSelect(t: T): void;\n\n children?: React.ReactElement;\n}\n\nconst TagListItem: React.ComponentType<TagItemProps<T>> = (props) => {\n /** Render a tag for the omnibox list */\n let { active, selected, className, onSelect, item, children } = props;\n className = classNames({ active, selected }, className);\n const onClick = () => onSelect(item);\n\n return h(\n \"div.item-container\",\n {\n key: item.id,\n className,\n onClick,\n },\n [\n h(\"div.swatch\", { style: { backgroundColor: item.color } }),\n h(\"div.item\", {}, item.name),\n ]\n );\n};\n\ntype BoxLifecycleProps<T> = Pick<OmnibarProps<T>, \"onClose\" | \"isOpen\">;\n\ninterface OmniboxProps<T> extends BoxLifecycleProps<T> {\n items: T[];\n selectedItem: T;\n onSelectItem: (t: T) => void;\n listItemComponent?: React.ComponentType<TagItemProps<T>>;\n}\n\nexport function OmniboxSelector<T>(props: OmniboxProps<T>) {\n /** A general omnibox for annotation types */\n const { onSelectItem, items, isOpen, onClose } = props;\n\n return h(Omnibar, {\n onItemSelect: onSelectItem,\n items,\n resetOnSelect: false,\n isOpen,\n onClose,\n itemRenderer(item: T, { handleClick, modifiers }) {\n return h(TagListItem, {\n key: item.id,\n item,\n onSelect: handleClick,\n active: modifiers.active,\n selected: modifiers.active,\n });\n },\n });\n}\n","module.exports = require('./helpers/bundle-url').getBundleURL('16Zb4') + \"main.module.6bc7d51b.css\";"],"names":["$16Zb4$macrostrathyper","a","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$40e2e1c28f0230c6$exports","getBundleURL","styled","__esModule","default"],"version":3,"file":"type-selector.0035ef7d.js.map","sourceRoot":"../../../../"}