@dxos/plugin-thread 0.6.12-main.ed7cda7 → 0.6.12-staging.0b4bb48

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 (79) hide show
  1. package/dist/lib/browser/{ThreadArticle-4VU752F4.mjs → ThreadArticle-O64ZECMF.mjs} +3 -3
  2. package/dist/lib/browser/{ThreadMain-ML3P4XSD.mjs → ThreadMain-ZDCRC6RG.mjs} +3 -3
  3. package/dist/lib/browser/{chunk-7NUYW5IW.mjs → chunk-5IBJO53M.mjs} +5 -2
  4. package/dist/lib/browser/chunk-5IBJO53M.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-GJRBBPXI.mjs → chunk-GKPZHUT3.mjs} +2 -2
  6. package/dist/lib/browser/{chunk-GJRBBPXI.mjs.map → chunk-GKPZHUT3.mjs.map} +1 -1
  7. package/dist/lib/browser/{chunk-XF5QKI75.mjs → chunk-P7ZE5N5M.mjs} +11 -13
  8. package/dist/lib/browser/chunk-P7ZE5N5M.mjs.map +7 -0
  9. package/dist/lib/browser/index.mjs +207 -237
  10. package/dist/lib/browser/index.mjs.map +4 -4
  11. package/dist/lib/browser/meta.json +1 -1
  12. package/dist/lib/browser/meta.mjs +1 -1
  13. package/dist/lib/browser/types.mjs +2 -2
  14. package/dist/lib/node/{ThreadArticle-ERUHPHVT.cjs → ThreadArticle-DO56JXBU.cjs} +7 -7
  15. package/dist/lib/node/{ThreadMain-6DN7FDNB.cjs → ThreadMain-XJX75GHG.cjs} +7 -7
  16. package/dist/lib/node/{chunk-PZVUW4W2.cjs → chunk-5PZNPPQF.cjs} +63 -65
  17. package/dist/lib/node/chunk-5PZNPPQF.cjs.map +7 -0
  18. package/dist/lib/node/{chunk-6EVXCSDS.cjs → chunk-BWBONZGU.cjs} +18 -5
  19. package/dist/lib/node/chunk-BWBONZGU.cjs.map +7 -0
  20. package/dist/lib/node/{chunk-FXD3DYMO.cjs → chunk-D5GOVXHS.cjs} +6 -6
  21. package/dist/lib/node/{chunk-FXD3DYMO.cjs.map → chunk-D5GOVXHS.cjs.map} +1 -1
  22. package/dist/lib/node/index.cjs +296 -324
  23. package/dist/lib/node/index.cjs.map +4 -4
  24. package/dist/lib/node/meta.cjs +4 -4
  25. package/dist/lib/node/meta.cjs.map +1 -1
  26. package/dist/lib/node/meta.json +1 -1
  27. package/dist/lib/node/types.cjs +3 -3
  28. package/dist/lib/node/types.cjs.map +1 -1
  29. package/dist/types/src/ThreadPlugin.d.ts.map +1 -1
  30. package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
  31. package/dist/types/src/components/CommentContainer.d.ts.map +1 -1
  32. package/dist/types/src/components/CommentsContainer.d.ts.map +1 -1
  33. package/dist/types/src/components/MessageContainer.d.ts.map +1 -1
  34. package/dist/types/src/components/testing.d.ts +0 -2
  35. package/dist/types/src/components/testing.d.ts.map +1 -1
  36. package/dist/types/src/meta.d.ts +4 -1
  37. package/dist/types/src/meta.d.ts.map +1 -1
  38. package/dist/types/src/types.d.ts +1 -1
  39. package/dist/types/src/types.d.ts.map +1 -1
  40. package/dist/types/src/types.test.d.ts +2 -0
  41. package/dist/types/src/types.test.d.ts.map +1 -0
  42. package/package.json +34 -37
  43. package/src/ThreadPlugin.tsx +178 -68
  44. package/src/components/ChatContainer.tsx +8 -7
  45. package/src/components/CommentContainer.tsx +7 -10
  46. package/src/components/Comments.stories.tsx +2 -2
  47. package/src/components/CommentsContainer.tsx +18 -22
  48. package/src/components/MessageContainer.tsx +1 -2
  49. package/src/meta.tsx +5 -1
  50. package/src/types.test.ts +13 -0
  51. package/src/types.ts +1 -1
  52. package/dist/lib/browser/chunk-7NUYW5IW.mjs.map +0 -7
  53. package/dist/lib/browser/chunk-XF5QKI75.mjs.map +0 -7
  54. package/dist/lib/node/chunk-6EVXCSDS.cjs.map +0 -7
  55. package/dist/lib/node/chunk-PZVUW4W2.cjs.map +0 -7
  56. package/dist/lib/node-esm/ThreadArticle-NKI5F4W5.mjs +0 -19
  57. package/dist/lib/node-esm/ThreadArticle-NKI5F4W5.mjs.map +0 -7
  58. package/dist/lib/node-esm/ThreadMain-2A3VQLCW.mjs +0 -27
  59. package/dist/lib/node-esm/ThreadMain-2A3VQLCW.mjs.map +0 -7
  60. package/dist/lib/node-esm/chunk-A44C4MTQ.mjs +0 -413
  61. package/dist/lib/node-esm/chunk-A44C4MTQ.mjs.map +0 -7
  62. package/dist/lib/node-esm/chunk-Y475KZTX.mjs +0 -20
  63. package/dist/lib/node-esm/chunk-Y475KZTX.mjs.map +0 -7
  64. package/dist/lib/node-esm/chunk-YO46JGAE.mjs +0 -21
  65. package/dist/lib/node-esm/chunk-YO46JGAE.mjs.map +0 -7
  66. package/dist/lib/node-esm/index.mjs +0 -1133
  67. package/dist/lib/node-esm/index.mjs.map +0 -7
  68. package/dist/lib/node-esm/meta.json +0 -1
  69. package/dist/lib/node-esm/meta.mjs +0 -12
  70. package/dist/lib/node-esm/meta.mjs.map +0 -7
  71. package/dist/lib/node-esm/types.mjs +0 -9
  72. package/dist/lib/node-esm/types.mjs.map +0 -7
  73. package/dist/types/src/components/ThreadComplementary.d.ts +0 -11
  74. package/dist/types/src/components/ThreadComplementary.d.ts.map +0 -1
  75. package/src/components/ThreadComplementary.tsx +0 -120
  76. /package/dist/lib/browser/{ThreadArticle-4VU752F4.mjs.map → ThreadArticle-O64ZECMF.mjs.map} +0 -0
  77. /package/dist/lib/browser/{ThreadMain-ML3P4XSD.mjs.map → ThreadMain-ZDCRC6RG.mjs.map} +0 -0
  78. /package/dist/lib/node/{ThreadArticle-ERUHPHVT.cjs.map → ThreadArticle-DO56JXBU.cjs.map} +0 -0
  79. /package/dist/lib/node/{ThreadMain-6DN7FDNB.cjs.map → ThreadMain-XJX75GHG.cjs.map} +0 -0
@@ -28,76 +28,73 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var node_exports = {};
30
30
  __export(node_exports, {
31
- ThreadAction: () => import_chunk_FXD3DYMO.ThreadAction,
31
+ ThreadAction: () => import_chunk_D5GOVXHS.ThreadAction,
32
32
  ThreadPlugin: () => ThreadPlugin,
33
33
  default: () => src_default,
34
- useAnalyticsCallback: () => import_chunk_PZVUW4W2.useAnalyticsCallback,
35
- useOnEditAnalytics: () => import_chunk_PZVUW4W2.useOnEditAnalytics,
36
- useStatus: () => import_chunk_PZVUW4W2.useStatus
34
+ useAnalyticsCallback: () => import_chunk_5PZNPPQF.useAnalyticsCallback,
35
+ useOnEditAnalytics: () => import_chunk_5PZNPPQF.useOnEditAnalytics,
36
+ useStatus: () => import_chunk_5PZNPPQF.useStatus
37
37
  });
38
38
  module.exports = __toCommonJS(node_exports);
39
- var import_chunk_FXD3DYMO = require("./chunk-FXD3DYMO.cjs");
40
- var import_chunk_PZVUW4W2 = require("./chunk-PZVUW4W2.cjs");
41
- var import_chunk_6EVXCSDS = require("./chunk-6EVXCSDS.cjs");
39
+ var import_chunk_D5GOVXHS = require("./chunk-D5GOVXHS.cjs");
40
+ var import_chunk_5PZNPPQF = require("./chunk-5PZNPPQF.cjs");
41
+ var import_chunk_BWBONZGU = require("./chunk-BWBONZGU.cjs");
42
+ var import_react = require("@phosphor-icons/react");
42
43
  var import_signals_core = require("@preact/signals-core");
43
- var import_react = __toESM(require("react"));
44
+ var import_react2 = __toESM(require("react"));
44
45
  var import_app_framework = require("@dxos/app-framework");
45
46
  var import_echo_schema = require("@dxos/echo-schema");
46
47
  var import_echo_schema2 = require("@dxos/echo-schema");
47
48
  var import_local_storage = require("@dxos/local-storage");
48
- var import_log = require("@dxos/log");
49
+ var import_plugin_attention = require("@dxos/plugin-attention");
49
50
  var import_plugin_client = require("@dxos/plugin-client");
50
51
  var import_plugin_graph = require("@dxos/plugin-graph");
52
+ var import_types = require("@dxos/plugin-markdown/types");
51
53
  var import_meta = require("@dxos/plugin-observability/meta");
52
54
  var import_plugin_space = require("@dxos/plugin-space");
53
- var import_types = require("@dxos/plugin-space/types");
55
+ var import_types2 = require("@dxos/plugin-space/types");
54
56
  var import_echo = require("@dxos/react-client/echo");
57
+ var import_react_ui = require("@dxos/react-ui");
58
+ var import_react_ui_attention = require("@dxos/react-ui-attention");
55
59
  var import_react_ui_editor = require("@dxos/react-ui-editor");
56
60
  var import_react_ui_thread = require("@dxos/react-ui-thread");
57
61
  var import_util = require("@dxos/util");
58
- var import_react2 = __toESM(require("react"));
59
62
  var import_react3 = __toESM(require("react"));
63
+ var import_react4 = __toESM(require("react"));
60
64
  var import_plugin_settings = require("@dxos/plugin-settings");
61
- var import_react_ui = require("@dxos/react-ui");
62
- var import_react4 = require("@phosphor-icons/react");
63
- var import_react5 = __toESM(require("react"));
65
+ var import_react_ui2 = require("@dxos/react-ui");
66
+ var import_react5 = require("@phosphor-icons/react");
67
+ var import_react6 = __toESM(require("react"));
64
68
  var import_echo_schema3 = require("@dxos/echo-schema");
65
- var import_types2 = require("@dxos/plugin-space/types");
69
+ var import_types3 = require("@dxos/plugin-space/types");
66
70
  var import_echo2 = require("@dxos/react-client/echo");
67
71
  var import_halo = require("@dxos/react-client/halo");
68
- var import_react_ui2 = require("@dxos/react-ui");
72
+ var import_react_ui3 = require("@dxos/react-ui");
69
73
  var import_react_ui_editor2 = require("@dxos/react-ui-editor");
70
74
  var import_react_ui_theme = require("@dxos/react-ui-theme");
71
75
  var import_react_ui_thread2 = require("@dxos/react-ui-thread");
72
76
  var import_util2 = require("@dxos/util");
73
- var import_react6 = require("@phosphor-icons/react");
74
- var import_react7 = __toESM(require("react"));
75
- var import_echo3 = require("@dxos/react-client/echo");
76
- var import_react_ui3 = require("@dxos/react-ui");
77
- var import_react_ui_deck = require("@dxos/react-ui-deck");
78
- var import_react_ui_theme2 = require("@dxos/react-ui-theme");
77
+ var import_react7 = require("@phosphor-icons/react");
79
78
  var import_react8 = __toESM(require("react"));
80
- var import_app_framework2 = require("@dxos/app-framework");
81
- var import_echo4 = require("@dxos/react-client/echo");
82
79
  var import_react_ui4 = require("@dxos/react-ui");
83
- var import_react_ui_attention = require("@dxos/react-ui-attention");
84
- var import_util3 = require("@dxos/util");
80
+ var import_react_ui_deck = require("@dxos/react-ui-deck");
81
+ var import_react_ui_theme2 = require("@dxos/react-ui-theme");
85
82
  var ThreadSettings = ({ settings }) => {
86
- const { t } = (0, import_react_ui.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
87
- return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement(import_plugin_settings.SettingsValue, {
83
+ const { t } = (0, import_react_ui2.useTranslation)(import_chunk_BWBONZGU.THREAD_PLUGIN);
84
+ return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, /* @__PURE__ */ import_react4.default.createElement(import_plugin_settings.SettingsValue, {
88
85
  label: t("settings standalone label")
89
- }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui.Input.Switch, {
86
+ }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Input.Switch, {
90
87
  checked: settings.standalone,
91
88
  onCheckedChange: (checked) => settings.standalone = !!checked
92
89
  })));
93
90
  };
94
91
  var sizeClass = (0, import_react_ui_theme.getSize)(4);
95
92
  var ToggleResolvedButton = ({ isResolved, onResolve }) => {
96
- const { t } = (0, import_react_ui2.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
93
+ const { t } = (0, import_react_ui3.useTranslation)(import_chunk_BWBONZGU.THREAD_PLUGIN);
97
94
  const label = t(isResolved ? "mark as unresolved label" : "mark as resolved label");
98
- return /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Root, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Trigger, {
95
+ return /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Root, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Trigger, {
99
96
  asChild: true
100
- }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Button, {
97
+ }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Button, {
101
98
  variant: "ghost",
102
99
  "data-testid": "thread.toggle-resolved",
103
100
  onClick: onResolve,
@@ -105,23 +102,23 @@ var ToggleResolvedButton = ({ isResolved, onResolve }) => {
105
102
  "min-bs-0 p-1",
106
103
  !isResolved && import_react_ui_theme.hoverableControlItem
107
104
  ]
108
- }, /* @__PURE__ */ import_react5.default.createElement("span", {
105
+ }, /* @__PURE__ */ import_react6.default.createElement("span", {
109
106
  className: "sr-only"
110
- }, label), isResolved ? /* @__PURE__ */ import_react5.default.createElement(import_react4.CheckCircle, {
107
+ }, label), isResolved ? /* @__PURE__ */ import_react6.default.createElement(import_react5.CheckCircle, {
111
108
  className: sizeClass,
112
109
  weight: "fill"
113
- }) : /* @__PURE__ */ import_react5.default.createElement(import_react4.CheckCircle, {
110
+ }) : /* @__PURE__ */ import_react6.default.createElement(import_react5.CheckCircle, {
114
111
  className: sizeClass
115
- }))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Portal, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Content, {
112
+ }))), /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Portal, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Content, {
116
113
  classNames: "z-[21]"
117
- }, label, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Arrow, null))));
114
+ }, label, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Arrow, null))));
118
115
  };
119
116
  var DeleteThreadButton = ({ onDelete }) => {
120
- const { t } = (0, import_react_ui2.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
117
+ const { t } = (0, import_react_ui3.useTranslation)(import_chunk_BWBONZGU.THREAD_PLUGIN);
121
118
  const label = t("delete thread label");
122
- return /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Root, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Trigger, {
119
+ return /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Root, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Trigger, {
123
120
  asChild: true
124
- }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Button, {
121
+ }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Button, {
125
122
  variant: "ghost",
126
123
  "data-testid": "thread.delete",
127
124
  onClick: onDelete,
@@ -129,28 +126,28 @@ var DeleteThreadButton = ({ onDelete }) => {
129
126
  "min-bs-0 p-1",
130
127
  import_react_ui_theme.hoverableControlItem
131
128
  ]
132
- }, /* @__PURE__ */ import_react5.default.createElement("span", {
129
+ }, /* @__PURE__ */ import_react6.default.createElement("span", {
133
130
  className: "sr-only"
134
- }, label), /* @__PURE__ */ import_react5.default.createElement(import_react4.X, {
131
+ }, label), /* @__PURE__ */ import_react6.default.createElement(import_react5.X, {
135
132
  className: sizeClass
136
- }))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Portal, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Content, {
133
+ }))), /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Portal, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Content, {
137
134
  classNames: "z-[21]"
138
- }, label, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Arrow, null))));
135
+ }, label, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Arrow, null))));
139
136
  };
140
137
  var CommentContainer = ({ thread, detached, context, current, autoFocusTextbox, onAttend, onThreadDelete, onMessageDelete, onResolve, onComment }) => {
141
138
  const identity = (0, import_halo.useIdentity)();
142
139
  const space = (0, import_echo2.getSpace)(thread);
143
140
  const members = (0, import_echo2.useMembers)(space?.key);
144
- const activity = (0, import_chunk_PZVUW4W2.useStatus)(space, (0, import_echo2.fullyQualifiedId)(thread));
145
- const { t } = (0, import_react_ui2.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
146
- const threadScrollRef = (0, import_react5.useRef)(null);
147
- const [autoFocus, setAutoFocus] = (0, import_react5.useState)(!!autoFocusTextbox);
148
- const { themeMode } = (0, import_react_ui2.useThemeContext)();
149
- const textboxMetadata = (0, import_chunk_PZVUW4W2.getMessageMetadata)((0, import_echo2.fullyQualifiedId)(thread), identity);
150
- const [_count, _setCount] = (0, import_react5.useState)(0);
141
+ const activity = (0, import_chunk_5PZNPPQF.useStatus)(space, thread.id);
142
+ const { t } = (0, import_react_ui3.useTranslation)(import_chunk_BWBONZGU.THREAD_PLUGIN);
143
+ const threadScrollRef = (0, import_react6.useRef)(null);
144
+ const [autoFocus, setAutoFocus] = (0, import_react6.useState)(!!autoFocusTextbox);
145
+ const { themeMode } = (0, import_react_ui3.useThemeContext)();
146
+ const textboxMetadata = (0, import_chunk_5PZNPPQF.getMessageMetadata)(thread.id, identity);
147
+ const [_count, _setCount] = (0, import_react6.useState)(0);
151
148
  const rerenderEditor = () => _setCount((count) => count + 1);
152
- const messageRef = (0, import_react5.useRef)("");
153
- const extensions = (0, import_react5.useMemo)(() => [
149
+ const messageRef = (0, import_react6.useRef)("");
150
+ const extensions = (0, import_react6.useMemo)(() => [
154
151
  (0, import_react_ui_editor2.createBasicExtensions)({
155
152
  placeholder: t("message placeholder")
156
153
  }),
@@ -160,11 +157,11 @@ var CommentContainer = ({ thread, detached, context, current, autoFocusTextbox,
160
157
  (0, import_react_ui_editor2.listener)({
161
158
  onChange: (text) => messageRef.current = text
162
159
  }),
163
- import_chunk_PZVUW4W2.command
160
+ import_chunk_5PZNPPQF.command
164
161
  ], [
165
162
  _count
166
163
  ]);
167
- (0, import_react5.useEffect)(() => {
164
+ (0, import_react6.useEffect)(() => {
168
165
  setAutoFocus(!!autoFocusTextbox);
169
166
  }, [
170
167
  autoFocusTextbox
@@ -173,11 +170,11 @@ var CommentContainer = ({ thread, detached, context, current, autoFocusTextbox,
173
170
  behavior,
174
171
  block: "end"
175
172
  }), 10);
176
- const handleCreate = (0, import_react5.useCallback)(() => {
173
+ const handleCreate = (0, import_react6.useCallback)(() => {
177
174
  if (!messageRef.current) {
178
175
  return false;
179
176
  }
180
- thread.messages.push((0, import_echo_schema3.create)(import_types2.MessageType, {
177
+ thread.messages.push((0, import_echo_schema3.create)(import_types3.MessageType, {
181
178
  sender: {
182
179
  identityKey: identity.identityKey.toHex()
183
180
  },
@@ -195,66 +192,64 @@ var CommentContainer = ({ thread, detached, context, current, autoFocusTextbox,
195
192
  thread,
196
193
  identity
197
194
  ]);
198
- return /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.Thread, {
195
+ const handleDeleteMessage = (id) => onMessageDelete?.(id);
196
+ return /* @__PURE__ */ import_react6.default.createElement(import_react_ui_thread2.Thread, {
199
197
  onClickCapture: onAttend,
200
198
  onFocusCapture: onAttend,
201
199
  current,
202
- id: (0, import_echo2.fullyQualifiedId)(thread)
203
- }, /* @__PURE__ */ import_react5.default.createElement("div", {
200
+ id: thread.id
201
+ }, /* @__PURE__ */ import_react6.default.createElement("div", {
204
202
  role: "none",
205
203
  className: (0, import_react_ui_theme.mx)("col-span-2 grid grid-cols-[var(--rail-size)_1fr_min-content]", import_react_ui_theme.hoverableControls, import_react_ui_theme.hoverableFocusedWithinControls)
206
- }, detached ? /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Root, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Trigger, {
204
+ }, detached ? /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Root, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Trigger, {
207
205
  asChild: true
208
- }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.ThreadHeading, {
206
+ }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_thread2.ThreadHeading, {
209
207
  detached: true
210
- }, thread.name ?? t("thread title placeholder"))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Portal, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Content, {
208
+ }, thread.name ?? t("thread title placeholder"))), /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Portal, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Content, {
211
209
  classNames: "z-[21]",
212
210
  side: "top"
213
- }, t("detached thread label"), /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Arrow, null)))) : /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.ThreadHeading, null, thread.name ?? t("thread title placeholder")), /* @__PURE__ */ import_react5.default.createElement("div", {
211
+ }, t("detached thread label"), /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Arrow, null)))) : /* @__PURE__ */ import_react6.default.createElement(import_react_ui_thread2.ThreadHeading, null, thread.name ?? t("thread title placeholder")), /* @__PURE__ */ import_react6.default.createElement("div", {
214
212
  className: "flex flex-row items-center pli-1"
215
- }, thread.status === "staged" && /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tag, {
213
+ }, thread.status === "staged" && /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tag, {
216
214
  palette: "neutral"
217
- }, t("draft button")), onResolve && !(thread?.status === "staged") && /* @__PURE__ */ import_react5.default.createElement(ToggleResolvedButton, {
215
+ }, t("draft button")), onResolve && !(thread?.status === "staged") && /* @__PURE__ */ import_react6.default.createElement(ToggleResolvedButton, {
218
216
  isResolved: thread?.status === "resolved",
219
217
  onResolve
220
- }), onThreadDelete && /* @__PURE__ */ import_react5.default.createElement(DeleteThreadButton, {
218
+ }), onThreadDelete && /* @__PURE__ */ import_react6.default.createElement(DeleteThreadButton, {
221
219
  onDelete: onThreadDelete
222
- }))), thread.messages.filter(import_util2.nonNullable).map((message) => /* @__PURE__ */ import_react5.default.createElement(import_chunk_PZVUW4W2.MessageContainer, {
220
+ }))), thread.messages.filter(import_util2.nonNullable).map((message) => /* @__PURE__ */ import_react6.default.createElement(import_chunk_5PZNPPQF.MessageContainer, {
223
221
  key: message.id,
224
222
  message,
225
223
  members,
226
- onDelete: (id) => onMessageDelete?.(id)
227
- })), /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.MessageTextbox, {
224
+ onDelete: handleDeleteMessage
225
+ })), /* @__PURE__ */ import_react6.default.createElement(import_react_ui_thread2.MessageTextbox, {
228
226
  extensions,
229
227
  autoFocus,
230
228
  onSend: handleCreate,
231
229
  ...textboxMetadata
232
- }), /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.ThreadFooter, {
230
+ }), /* @__PURE__ */ import_react6.default.createElement(import_react_ui_thread2.ThreadFooter, {
233
231
  activity
234
- }, t("activity message")), /* @__PURE__ */ import_react5.default.createElement("div", {
232
+ }, t("activity message")), /* @__PURE__ */ import_react6.default.createElement("div", {
235
233
  role: "none",
236
234
  className: "bs-px -mbs-px",
237
235
  ref: threadScrollRef
238
236
  }));
239
237
  };
240
238
  var CommentsHeading = ({ attendableId }) => {
241
- const { t } = (0, import_react_ui3.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
242
- return /* @__PURE__ */ import_react7.default.createElement("div", {
239
+ const { t } = (0, import_react_ui4.useTranslation)(import_chunk_BWBONZGU.THREAD_PLUGIN);
240
+ return /* @__PURE__ */ import_react8.default.createElement("div", {
243
241
  role: "none",
244
242
  className: "flex items-center"
245
- }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui_deck.PlankHeading.Button, {
243
+ }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui_deck.PlankHeading.Button, {
246
244
  attendableId
247
- }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui3.Icon, {
248
- icon: "ph--quotes--regular",
249
- size: 5
250
- })), /* @__PURE__ */ import_react7.default.createElement(import_react_ui_deck.PlankHeading.Label, {
245
+ }, /* @__PURE__ */ import_react8.default.createElement(import_react7.Quotes, import_react_ui_deck.plankHeadingIconProps)), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_deck.PlankHeading.Label, {
251
246
  attendableId
252
247
  }, t("comments heading")));
253
248
  };
254
249
  var CommentsContainer = ({ threads, detached = [], currentId, autoFocusCurrentTextbox, showResolvedThreads, onThreadAttend, onThreadDelete, onMessageDelete, onThreadToggleResolved, ...props }) => {
255
- const { t } = (0, import_react_ui3.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
250
+ const { t } = (0, import_react_ui4.useTranslation)(import_chunk_BWBONZGU.THREAD_PLUGIN);
256
251
  const filteredThreads = showResolvedThreads ? threads : threads.filter((thread) => !(thread?.status === "resolved"));
257
- (0, import_react7.useEffect)(() => {
252
+ (0, import_react8.useEffect)(() => {
258
253
  if (currentId) {
259
254
  document.getElementById(currentId)?.scrollIntoView({
260
255
  behavior: "smooth",
@@ -264,157 +259,46 @@ var CommentsContainer = ({ threads, detached = [], currentId, autoFocusCurrentTe
264
259
  }, [
265
260
  currentId
266
261
  ]);
267
- return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, filteredThreads.length > 0 ? filteredThreads.map((thread) => {
268
- const threadId = (0, import_echo3.fullyQualifiedId)(thread);
269
- return /* @__PURE__ */ import_react7.default.createElement(CommentContainer, {
270
- key: threadId,
271
- thread,
272
- current: currentId === threadId,
273
- detached: detached.includes(threadId),
274
- autoFocusTextbox: autoFocusCurrentTextbox && currentId === threadId,
275
- ...onThreadAttend && {
276
- onAttend: () => onThreadAttend(thread)
277
- },
278
- ...onThreadDelete && {
279
- onThreadDelete: () => onThreadDelete(thread)
280
- },
281
- ...onMessageDelete && {
282
- onMessageDelete: (messageId) => onMessageDelete(thread, messageId)
283
- },
284
- ...onThreadToggleResolved && {
285
- onResolve: () => onThreadToggleResolved(thread)
286
- },
287
- ...props
288
- });
289
- }) : /* @__PURE__ */ import_react7.default.createElement("div", {
262
+ return /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, filteredThreads.length > 0 ? filteredThreads.map((thread) => /* @__PURE__ */ import_react8.default.createElement(CommentContainer, {
263
+ key: thread.id,
264
+ thread,
265
+ current: currentId === thread.id,
266
+ detached: detached.includes(thread.id),
267
+ autoFocusTextbox: autoFocusCurrentTextbox && currentId === thread.id,
268
+ ...onThreadAttend && {
269
+ onAttend: () => onThreadAttend(thread)
270
+ },
271
+ ...onThreadDelete && {
272
+ onThreadDelete: () => onThreadDelete(thread)
273
+ },
274
+ ...onMessageDelete && {
275
+ onMessageDelete: (messageId) => onMessageDelete(thread, messageId)
276
+ },
277
+ ...onThreadToggleResolved && {
278
+ onResolve: () => onThreadToggleResolved(thread)
279
+ },
280
+ ...props
281
+ })) : /* @__PURE__ */ import_react8.default.createElement("div", {
290
282
  role: "alert",
291
283
  className: (0, import_react_ui_theme2.mx)(import_react_ui_theme2.descriptionText, "place-self-center border border-dashed border-neutral-400/50 rounded-lg text-center p-4 m-4")
292
- }, /* @__PURE__ */ import_react7.default.createElement("h2", {
284
+ }, /* @__PURE__ */ import_react8.default.createElement("h2", {
293
285
  className: "mbe-2 font-medium text-baseText"
294
- }, t("no comments title")), /* @__PURE__ */ import_react7.default.createElement("p", null, /* @__PURE__ */ import_react7.default.createElement(import_react_ui3.Trans, {
286
+ }, t("no comments title")), /* @__PURE__ */ import_react8.default.createElement("p", null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.Trans, {
295
287
  t,
296
288
  i18nKey: "no comments message",
297
289
  components: {
298
- commentIcon: /* @__PURE__ */ import_react7.default.createElement(import_react6.ChatText, {
290
+ commentIcon: /* @__PURE__ */ import_react8.default.createElement(import_react7.ChatText, {
299
291
  className: "inline-block"
300
292
  })
301
293
  }
302
294
  }))));
303
295
  };
304
- var ThreadMain = import_react2.default.lazy(() => import("./ThreadMain-6DN7FDNB.cjs"));
305
- var ThreadArticle = import_react2.default.lazy(() => import("./ThreadArticle-ERUHPHVT.cjs"));
306
- var providesThreadsConfig = (plugin) => "thread" in plugin.provides ? plugin : void 0;
307
- var ThreadComplementary = ({ role, subject, stagedThreads, current, focus, showResolvedThreads }) => {
308
- const dispatch = (0, import_app_framework2.useIntentDispatcher)();
309
- const threadsIntegrators = (0, import_app_framework2.useResolvePlugins)(providesThreadsConfig);
310
- const threadProvides = (0, import_react8.useMemo)(() => threadsIntegrators.map((p) => p.provides.thread), [
311
- threadsIntegrators
312
- ]);
313
- const createSort = (0, import_react8.useMemo)(() => threadProvides.find((p) => p.predicate(subject))?.createSort, [
314
- threadProvides,
315
- subject
316
- ]);
317
- const sort = (0, import_react8.useMemo)(() => createSort?.(subject), [
318
- createSort,
319
- subject
320
- ]);
321
- const threads = (0, import_react8.useMemo)(() => {
322
- return subject.threads.concat(stagedThreads ?? []).filter(import_util3.nonNullable);
323
- }, [
324
- JSON.stringify(subject.threads),
325
- JSON.stringify(stagedThreads)
326
- ]);
327
- const detachedIds = (0, import_react8.useMemo)(() => {
328
- return threads.filter(({ anchor }) => !anchor).map((thread) => (0, import_echo4.fullyQualifiedId)(thread));
329
- }, [
330
- threads
331
- ]);
332
- (0, import_react8.useEffect)(() => {
333
- if (!sort) {
334
- return;
335
- }
336
- threads.sort((a, b) => sort(a?.anchor, b?.anchor));
337
- }, [
338
- sort,
339
- threads
340
- ]);
341
- const { attended } = (0, import_react_ui_attention.useAttentionContext)("Thread Complementary");
342
- const qualifiedSubjectId = (0, import_echo4.fullyQualifiedId)(subject);
343
- const attendableAttrs = (0, import_react_ui_attention.createAttendableAttributes)(qualifiedSubjectId);
344
- return /* @__PURE__ */ import_react8.default.createElement("div", {
345
- role: "none",
346
- className: "contents group/attention",
347
- ...attendableAttrs
348
- }, role === "complementary" && /* @__PURE__ */ import_react8.default.createElement(CommentsHeading, {
349
- attendableId: qualifiedSubjectId
350
- }), /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Root, {
351
- classNames: "row-span-2"
352
- }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Viewport, null, /* @__PURE__ */ import_react8.default.createElement(CommentsContainer, {
353
- threads,
354
- detached: detachedIds,
355
- currentId: attended.has(qualifiedSubjectId) ? current : void 0,
356
- autoFocusCurrentTextbox: focus,
357
- showResolvedThreads,
358
- onThreadAttend: (thread) => {
359
- const threadId = (0, import_echo4.fullyQualifiedId)(thread);
360
- if (current !== threadId) {
361
- current = threadId;
362
- void dispatch?.([
363
- {
364
- action: import_app_framework2.LayoutAction.SCROLL_INTO_VIEW,
365
- data: {
366
- id: (0, import_echo4.fullyQualifiedId)(subject),
367
- thread: threadId,
368
- cursor: thread.anchor
369
- }
370
- }
371
- ]);
372
- }
373
- },
374
- onThreadDelete: (thread) => {
375
- return dispatch({
376
- plugin: import_chunk_6EVXCSDS.THREAD_PLUGIN,
377
- action: import_chunk_FXD3DYMO.ThreadAction.DELETE,
378
- data: {
379
- subject,
380
- thread
381
- }
382
- });
383
- },
384
- onMessageDelete: (thread, messageId) => dispatch({
385
- plugin: import_chunk_6EVXCSDS.THREAD_PLUGIN,
386
- action: import_chunk_FXD3DYMO.ThreadAction.DELETE_MESSAGE,
387
- data: {
388
- subject,
389
- thread,
390
- messageId
391
- }
392
- }),
393
- onThreadToggleResolved: (thread) => dispatch({
394
- plugin: import_chunk_6EVXCSDS.THREAD_PLUGIN,
395
- action: import_chunk_FXD3DYMO.ThreadAction.TOGGLE_RESOLVED,
396
- data: {
397
- thread
398
- }
399
- }),
400
- onComment: (thread) => {
401
- void dispatch({
402
- action: import_chunk_FXD3DYMO.ThreadAction.ON_MESSAGE_ADD,
403
- data: {
404
- thread,
405
- subject
406
- }
407
- });
408
- }
409
- }), /* @__PURE__ */ import_react8.default.createElement("div", {
410
- role: "none",
411
- className: "bs-10"
412
- }), /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Scrollbar, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Thumb, null)))));
413
- };
296
+ var ThreadMain = import_react3.default.lazy(() => import("./ThreadMain-XJX75GHG.cjs"));
297
+ var ThreadArticle = import_react3.default.lazy(() => import("./ThreadArticle-DO56JXBU.cjs"));
414
298
  var translations_default = [
415
299
  {
416
300
  "en-US": {
417
- [import_chunk_6EVXCSDS.THREAD_PLUGIN]: {
301
+ [import_chunk_BWBONZGU.THREAD_PLUGIN]: {
418
302
  "plugin name": "Threads",
419
303
  "channel name placeholder": "New channel",
420
304
  "channel title label": "Title",
@@ -445,12 +329,12 @@ var translations_default = [
445
329
  }
446
330
  }
447
331
  ];
448
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-thread/src/ThreadPlugin.tsx";
449
332
  var initialViewState = {
450
333
  showResolvedThreads: false
451
334
  };
335
+ var providesThreadsConfig = (plugin) => "thread" in plugin.provides ? plugin : void 0;
452
336
  var ThreadPlugin = () => {
453
- const settings = new import_local_storage.LocalStorageStore(import_chunk_6EVXCSDS.THREAD_PLUGIN);
337
+ const settings = new import_local_storage.LocalStorageStore(import_chunk_BWBONZGU.THREAD_PLUGIN);
454
338
  const state = (0, import_echo_schema2.create)({
455
339
  staging: {}
456
340
  });
@@ -463,11 +347,13 @@ var ThreadPlugin = () => {
463
347
  }
464
348
  return viewStore[subjectId];
465
349
  };
350
+ let attentionPlugin;
466
351
  let navigationPlugin;
467
352
  let intentPlugin;
353
+ let dispatch;
468
354
  const unsubscribeCallbacks = [];
469
355
  return {
470
- meta: import_chunk_6EVXCSDS.meta_default,
356
+ meta: import_chunk_BWBONZGU.meta_default,
471
357
  ready: async (plugins) => {
472
358
  settings.prop({
473
359
  key: "standalone",
@@ -475,8 +361,36 @@ var ThreadPlugin = () => {
475
361
  allowUndefined: true
476
362
  })
477
363
  });
364
+ attentionPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_plugin_attention.parseAttentionPlugin);
478
365
  navigationPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseNavigationPlugin);
479
366
  intentPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseIntentPlugin);
367
+ dispatch = intentPlugin?.provides.intent.dispatch;
368
+ const graphPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseGraphPlugin);
369
+ const client = (0, import_app_framework.resolvePlugin)(plugins, import_plugin_client.parseClientPlugin)?.provides.client;
370
+ if (!client) {
371
+ return;
372
+ }
373
+ const channelsQuery = client.spaces.query(import_echo.Filter.schema(import_types2.ChannelType));
374
+ const queryUnsubscribe = channelsQuery.subscribe();
375
+ const unsubscribe = (0, import_signals_core.effect)(() => {
376
+ const attention = attentionPlugin?.provides.attention;
377
+ if (!attention?.attended) {
378
+ return;
379
+ }
380
+ const firstAttendedNodeWithComments = Array.from(attention.attended).map((id) => graphPlugin?.provides.graph.findNode(id)).find((node) => node?.data instanceof import_types.DocumentType && (node.data.threads?.length ?? 0) > 0);
381
+ if (firstAttendedNodeWithComments) {
382
+ void intentPlugin?.provides.intent.dispatch({
383
+ action: import_app_framework.NavigationAction.OPEN,
384
+ data: {
385
+ activeParts: {
386
+ complementary: `${firstAttendedNodeWithComments.id}${import_app_framework.SLUG_PATH_SEPARATOR}comments`
387
+ }
388
+ }
389
+ });
390
+ }
391
+ });
392
+ unsubscribeCallbacks.push(queryUnsubscribe);
393
+ unsubscribeCallbacks.push(unsubscribe);
480
394
  },
481
395
  unload: async () => {
482
396
  unsubscribeCallbacks.forEach((unsubscribe) => unsubscribe());
@@ -485,26 +399,27 @@ var ThreadPlugin = () => {
485
399
  settings: settings.values,
486
400
  metadata: {
487
401
  records: {
488
- [import_types.ChannelType.typename]: {
402
+ [import_types2.ChannelType.typename]: {
489
403
  placeholder: [
490
404
  "channel title placeholder",
491
405
  {
492
- ns: import_chunk_6EVXCSDS.THREAD_PLUGIN
406
+ ns: import_chunk_BWBONZGU.THREAD_PLUGIN
493
407
  }
494
408
  ],
495
- icon: "ph--chat--regular",
409
+ icon: (props) => /* @__PURE__ */ import_react2.default.createElement(import_react.Chat, props),
410
+ iconSymbol: "ph--chat--regular",
496
411
  // TODO(wittjosiah): Move out of metadata.
497
412
  loadReferences: (channel) => (0, import_echo.loadObjectReferences)(channel, (channel2) => channel2.threads)
498
413
  },
499
- [import_types.ThreadType.typename]: {
414
+ [import_types2.ThreadType.typename]: {
500
415
  // TODO(wittjosiah): Move out of metadata.
501
416
  loadReferences: (thread) => (0, import_echo.loadObjectReferences)(thread, (thread2) => thread2.messages)
502
417
  },
503
- [import_types.MessageType.typename]: {
418
+ [import_types2.MessageType.typename]: {
504
419
  // TODO(wittjosiah): Move out of metadata.
505
420
  loadReferences: (message) => []
506
421
  },
507
- [import_chunk_6EVXCSDS.THREAD_ITEM]: {
422
+ [import_chunk_BWBONZGU.THREAD_ITEM]: {
508
423
  parse: (item, type) => {
509
424
  switch (type) {
510
425
  case "node":
@@ -531,53 +446,47 @@ var ThreadPlugin = () => {
531
446
  ],
532
447
  echo: {
533
448
  schema: [
534
- import_types.ChannelType,
535
- import_types.ThreadType,
536
- import_types.MessageType
449
+ import_types2.ChannelType,
450
+ import_types2.ThreadType,
451
+ import_types2.MessageType
537
452
  ]
538
453
  },
539
454
  graph: {
540
455
  builder: (plugins) => {
541
456
  const client = (0, import_app_framework.resolvePlugin)(plugins, import_plugin_client.parseClientPlugin)?.provides.client;
542
- const dispatch = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseIntentPlugin)?.provides.intent.dispatch;
457
+ const dispatch2 = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseIntentPlugin)?.provides.intent.dispatch;
543
458
  const metadataResolver = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseMetadataResolverPlugin)?.provides.metadata.resolver;
544
- if (!client || !dispatch || !metadataResolver) {
459
+ if (!client || !dispatch2 || !metadataResolver) {
545
460
  return [];
546
461
  }
547
462
  return [
548
463
  (0, import_plugin_graph.createExtension)({
549
- id: `${import_chunk_6EVXCSDS.THREAD_PLUGIN}/comments-for-subject`,
464
+ id: `${import_chunk_BWBONZGU.THREAD_PLUGIN}/comments-for-subject`,
550
465
  resolver: ({ id }) => {
551
466
  if (!id.endsWith("~comments")) {
552
467
  return;
553
468
  }
554
- const subjectId = id.split("~").at(0);
555
- const [spaceId, objectId] = subjectId?.split(":") ?? [];
469
+ const docId = id.split("~").at(0);
470
+ const [spaceId, objectId] = docId?.split(":") ?? [];
556
471
  const space = client.spaces.get().find((space2) => space2.id === spaceId);
557
- const object = (0, import_plugin_graph.toSignal)((onChange) => {
558
- const timeout = setTimeout(async () => {
559
- await space?.db.loadObjectById(objectId);
560
- onChange();
561
- });
562
- return () => clearTimeout(timeout);
563
- }, () => space?.db.getObjectById(objectId), subjectId);
564
- if (!object || !subjectId) {
472
+ const doc = space?.db.getObjectById(objectId);
473
+ if (!doc || !docId) {
565
474
  return;
566
475
  }
567
- const meta = metadataResolver((0, import_echo_schema.getTypename)(object) ?? "");
568
- const label = meta.label?.(object) || object.name || meta.placeholder || [
476
+ const docMeta = metadataResolver((0, import_echo_schema.getTypename)(doc) ?? "");
477
+ const label = docMeta.label?.(doc) || doc.name || docMeta.placeholder || [
569
478
  "unnamed object threads label",
570
479
  {
571
- ns: import_chunk_6EVXCSDS.THREAD_PLUGIN
480
+ ns: import_chunk_BWBONZGU.THREAD_PLUGIN
572
481
  }
573
482
  ];
574
- const viewState = getViewState(subjectId);
483
+ const viewState = getViewState(docId);
575
484
  return {
576
485
  id,
577
486
  type: "orphan-comments-for-subject",
578
- data: object,
487
+ data: doc,
579
488
  properties: {
580
- icon: meta.icon,
489
+ icon: import_chunk_BWBONZGU.meta_default.iconComponent,
581
490
  label,
582
491
  showResolvedThreads: viewState.showResolvedThreads
583
492
  }
@@ -593,7 +502,7 @@ var ThreadPlugin = () => {
593
502
  const toggle = () => {
594
503
  const newToggleState = !viewState.showResolvedThreads;
595
504
  viewState.showResolvedThreads = newToggleState;
596
- void dispatch({
505
+ void dispatch2({
597
506
  action: import_meta.ObservabilityAction.SEND_EVENT,
598
507
  data: {
599
508
  name: "threads.toggle-show-resolved",
@@ -607,26 +516,25 @@ var ThreadPlugin = () => {
607
516
  };
608
517
  return [
609
518
  {
610
- id: `${import_chunk_6EVXCSDS.THREAD_PLUGIN}/toggle-show-resolved/${node.id}`,
519
+ id: `${import_chunk_BWBONZGU.THREAD_PLUGIN}/toggle-show-resolved/${node.id}`,
611
520
  data: toggle,
612
521
  properties: {
613
522
  label: [
614
523
  "toggle show resolved",
615
524
  {
616
- ns: import_chunk_6EVXCSDS.THREAD_PLUGIN
525
+ ns: import_chunk_BWBONZGU.THREAD_PLUGIN
617
526
  }
618
527
  ],
619
528
  menuItemType: "toggle",
620
529
  isChecked: viewState.showResolvedThreads,
621
- testId: "threadPlugin.toggleShowResolved",
622
- icon: viewState.showResolvedThreads ? "ph--eye-slash--regular" : "ph--eye--regular"
530
+ testId: "threadPlugin.toggleShowResolved"
623
531
  }
624
532
  }
625
533
  ];
626
534
  }
627
535
  }),
628
536
  (0, import_plugin_graph.createExtension)({
629
- id: import_chunk_FXD3DYMO.ThreadAction.CREATE,
537
+ id: import_chunk_D5GOVXHS.ThreadAction.CREATE,
630
538
  filter: (node) => !!settings.values.standalone && (0, import_plugin_graph.isActionGroup)(node) && node.id.startsWith(import_plugin_space.SpaceAction.ADD_OBJECT),
631
539
  actions: ({ node }) => {
632
540
  const id = node.id.split("/").at(-1);
@@ -639,12 +547,12 @@ var ThreadPlugin = () => {
639
547
  }
640
548
  return [
641
549
  {
642
- id: `${import_chunk_6EVXCSDS.THREAD_PLUGIN}/create/${node.id}`,
550
+ id: `${import_chunk_BWBONZGU.THREAD_PLUGIN}/create/${node.id}`,
643
551
  data: async () => {
644
- await dispatch([
552
+ await dispatch2([
645
553
  {
646
- plugin: import_chunk_6EVXCSDS.THREAD_PLUGIN,
647
- action: import_chunk_FXD3DYMO.ThreadAction.CREATE
554
+ plugin: import_chunk_BWBONZGU.THREAD_PLUGIN,
555
+ action: import_chunk_D5GOVXHS.ThreadAction.CREATE
648
556
  },
649
557
  {
650
558
  action: import_plugin_space.SpaceAction.ADD_OBJECT,
@@ -661,10 +569,11 @@ var ThreadPlugin = () => {
661
569
  label: [
662
570
  "create channel label",
663
571
  {
664
- ns: import_chunk_6EVXCSDS.THREAD_PLUGIN
572
+ ns: import_chunk_BWBONZGU.THREAD_PLUGIN
665
573
  }
666
574
  ],
667
- icon: "ph--chat--regular",
575
+ icon: (props) => /* @__PURE__ */ import_react2.default.createElement(import_react.Chat, props),
576
+ iconSymbol: "ph--chat--regular",
668
577
  testId: "threadPlugin.createObject"
669
578
  }
670
579
  }
@@ -678,19 +587,21 @@ var ThreadPlugin = () => {
678
587
  component: ({ data, role }) => {
679
588
  switch (role) {
680
589
  case "main": {
681
- return data.active instanceof import_types.ChannelType && data.active.threads[0] ? /* @__PURE__ */ import_react.default.createElement(ThreadMain, {
590
+ return data.active instanceof import_types2.ChannelType && data.active.threads[0] ? /* @__PURE__ */ import_react2.default.createElement(ThreadMain, {
682
591
  thread: data.active.threads[0]
683
592
  }) : null;
684
593
  }
685
594
  case "settings": {
686
- return data.plugin === import_chunk_6EVXCSDS.meta_default.id ? /* @__PURE__ */ import_react.default.createElement(ThreadSettings, {
595
+ return data.plugin === import_chunk_BWBONZGU.meta_default.id ? /* @__PURE__ */ import_react2.default.createElement(ThreadSettings, {
687
596
  settings: settings.values
688
597
  }) : null;
689
598
  }
690
599
  case "article":
691
600
  case "complementary": {
692
601
  const location = navigationPlugin?.provides.location;
693
- if (data.object instanceof import_types.ChannelType && data.object.threads[0]) {
602
+ const threadsIntegrators = (0, import_app_framework.useResolvePlugins)(providesThreadsConfig);
603
+ const threadProvides = threadsIntegrators.map((p) => p.provides.thread);
604
+ if (data.object instanceof import_types2.ChannelType && data.object.threads[0]) {
694
605
  const channel = data.object;
695
606
  if ((0, import_app_framework.isLayoutParts)(location?.active) && location.active.main) {
696
607
  const layoutEntries = location.active.main;
@@ -698,33 +609,101 @@ var ThreadPlugin = () => {
698
609
  if (currentPosition > 0) {
699
610
  const objectToTheLeft = layoutEntries[currentPosition - 1];
700
611
  const context = (0, import_echo.getSpace)(data.object)?.db.getObjectById(objectToTheLeft.id);
701
- return /* @__PURE__ */ import_react.default.createElement(ThreadArticle, {
612
+ return /* @__PURE__ */ import_react2.default.createElement(ThreadArticle, {
702
613
  thread: data.object.threads[0],
703
614
  context
704
615
  });
705
616
  }
706
617
  }
707
- return /* @__PURE__ */ import_react.default.createElement(ThreadArticle, {
618
+ return /* @__PURE__ */ import_react2.default.createElement(ThreadArticle, {
708
619
  thread: data.object.threads[0]
709
620
  });
710
621
  }
711
- if (data.subject instanceof import_types.ThreadType) {
712
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_chunk_PZVUW4W2.ChatHeading, {
622
+ if (data.subject instanceof import_types2.ThreadType) {
623
+ return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(import_chunk_5PZNPPQF.ChatHeading, {
713
624
  attendableId: data.subject.id
714
- }), /* @__PURE__ */ import_react.default.createElement(import_chunk_PZVUW4W2.ChatContainer, {
625
+ }), /* @__PURE__ */ import_react2.default.createElement(import_chunk_5PZNPPQF.ChatContainer, {
715
626
  thread: data.subject
716
627
  }));
717
628
  }
718
629
  if (data.subject && typeof data.subject === "object" && "threads" in data.subject && Array.isArray(data.subject.threads)) {
719
- const { showResolvedThreads } = getViewState((0, import_echo.fullyQualifiedId)(data.subject));
720
- return /* @__PURE__ */ import_react.default.createElement(ThreadComplementary, {
721
- role,
722
- subject: data.subject,
723
- stagedThreads: state.staging[(0, import_echo.fullyQualifiedId)(data.subject)],
724
- current: state.current,
725
- focus: true,
726
- showResolvedThreads
727
- });
630
+ const threads = data.subject.threads.concat(state.staging[(0, import_echo.fullyQualifiedId)(data.subject)]).filter(import_util.nonNullable);
631
+ const createSort = threadProvides.find((p) => p.predicate(data.subject))?.createSort;
632
+ if (createSort) {
633
+ const sort = createSort(data.subject);
634
+ threads.sort((a, b) => sort(a.anchor, b.anchor));
635
+ }
636
+ const detached = data.subject.threads.filter(import_util.nonNullable).filter(({ anchor }) => !anchor).map((thread) => thread.id);
637
+ const qualifiedSubjectId = (0, import_echo.fullyQualifiedId)(data.subject);
638
+ const attention = attentionPlugin?.provides.attention?.attended ?? /* @__PURE__ */ new Set([
639
+ qualifiedSubjectId
640
+ ]);
641
+ const attendableAttrs = (0, import_react_ui_attention.createAttendableAttributes)(qualifiedSubjectId);
642
+ const { showResolvedThreads } = getViewState(qualifiedSubjectId);
643
+ return /* @__PURE__ */ import_react2.default.createElement("div", {
644
+ role: "none",
645
+ className: "contents group/attention",
646
+ ...attendableAttrs
647
+ }, role === "complementary" && /* @__PURE__ */ import_react2.default.createElement(CommentsHeading, {
648
+ attendableId: qualifiedSubjectId
649
+ }), /* @__PURE__ */ import_react2.default.createElement(import_react_ui.ScrollArea.Root, {
650
+ classNames: "row-span-2"
651
+ }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.ScrollArea.Viewport, null, /* @__PURE__ */ import_react2.default.createElement(CommentsContainer, {
652
+ threads,
653
+ detached,
654
+ currentId: attention.has(qualifiedSubjectId) ? state.current : void 0,
655
+ autoFocusCurrentTextbox: state.focus,
656
+ showResolvedThreads,
657
+ onThreadAttend: (thread) => {
658
+ if (state.current !== thread.id) {
659
+ state.current = thread.id;
660
+ void dispatch?.({
661
+ action: import_app_framework.LayoutAction.SCROLL_INTO_VIEW,
662
+ data: {
663
+ id: (0, import_echo.fullyQualifiedId)(data.subject),
664
+ thread: (0, import_echo.fullyQualifiedId)(thread),
665
+ cursor: thread.anchor
666
+ }
667
+ });
668
+ }
669
+ },
670
+ onThreadDelete: (thread) => dispatch?.({
671
+ plugin: import_chunk_BWBONZGU.THREAD_PLUGIN,
672
+ action: import_chunk_D5GOVXHS.ThreadAction.DELETE,
673
+ data: {
674
+ subject: data.subject,
675
+ thread
676
+ }
677
+ }),
678
+ onMessageDelete: (thread, messageId) => dispatch?.({
679
+ plugin: import_chunk_BWBONZGU.THREAD_PLUGIN,
680
+ action: import_chunk_D5GOVXHS.ThreadAction.DELETE_MESSAGE,
681
+ data: {
682
+ subject: data.subject,
683
+ thread,
684
+ messageId
685
+ }
686
+ }),
687
+ onThreadToggleResolved: (thread) => dispatch?.({
688
+ plugin: import_chunk_BWBONZGU.THREAD_PLUGIN,
689
+ action: import_chunk_D5GOVXHS.ThreadAction.TOGGLE_RESOLVED,
690
+ data: {
691
+ thread
692
+ }
693
+ }),
694
+ onComment: (thread) => {
695
+ void intentPlugin?.provides.intent.dispatch({
696
+ action: import_chunk_D5GOVXHS.ThreadAction.ON_MESSAGE_ADD,
697
+ data: {
698
+ thread,
699
+ subject: data.subject
700
+ }
701
+ });
702
+ }
703
+ }), /* @__PURE__ */ import_react2.default.createElement("div", {
704
+ role: "none",
705
+ className: "bs-10"
706
+ }), /* @__PURE__ */ import_react2.default.createElement(import_react_ui.ScrollArea.Scrollbar, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.ScrollArea.Thumb, null)))));
728
707
  }
729
708
  }
730
709
  }
@@ -734,24 +713,11 @@ var ThreadPlugin = () => {
734
713
  intent: {
735
714
  resolver: async (intent) => {
736
715
  switch (intent.action) {
737
- case import_chunk_FXD3DYMO.ThreadAction.CREATE: {
716
+ case import_chunk_D5GOVXHS.ThreadAction.CREATE: {
738
717
  if (intent.data && intent.data.cursor !== void 0) {
739
718
  const { cursor, name, subject } = intent.data;
740
- if (subject?.threads === void 0) {
741
- try {
742
- subject.threads = [];
743
- } catch (e) {
744
- import_log.log.error("Subject does not support threads array", subject?.typename, {
745
- F: __dxlog_file,
746
- L: 332,
747
- S: void 0,
748
- C: (f, a) => f(...a)
749
- });
750
- return;
751
- }
752
- }
753
719
  const subjectId = (0, import_echo.fullyQualifiedId)(subject);
754
- const thread = (0, import_echo_schema2.create)(import_types.ThreadType, {
720
+ const thread = (0, import_echo_schema2.create)(import_types2.ThreadType, {
755
721
  name,
756
722
  anchor: cursor,
757
723
  messages: [],
@@ -770,9 +736,17 @@ var ThreadPlugin = () => {
770
736
  intents: [
771
737
  [
772
738
  {
773
- action: import_chunk_FXD3DYMO.ThreadAction.SELECT,
739
+ action: import_app_framework.NavigationAction.OPEN,
740
+ data: {
741
+ activeParts: {
742
+ complementary: `${subjectId}${import_app_framework.SLUG_PATH_SEPARATOR}comments${import_app_framework.SLUG_COLLECTION_INDICATOR}`
743
+ }
744
+ }
745
+ },
746
+ {
747
+ action: import_chunk_D5GOVXHS.ThreadAction.SELECT,
774
748
  data: {
775
- current: (0, import_echo.fullyQualifiedId)(thread),
749
+ current: thread.id,
776
750
  focus: true
777
751
  }
778
752
  },
@@ -789,9 +763,9 @@ var ThreadPlugin = () => {
789
763
  };
790
764
  } else {
791
765
  return {
792
- data: (0, import_echo_schema2.create)(import_types.ChannelType, {
766
+ data: (0, import_echo_schema2.create)(import_types2.ChannelType, {
793
767
  threads: [
794
- (0, import_echo_schema2.create)(import_types.ThreadType, {
768
+ (0, import_echo_schema2.create)(import_types2.ThreadType, {
795
769
  messages: []
796
770
  })
797
771
  ]
@@ -799,16 +773,16 @@ var ThreadPlugin = () => {
799
773
  };
800
774
  }
801
775
  }
802
- case import_chunk_FXD3DYMO.ThreadAction.SELECT: {
776
+ case import_chunk_D5GOVXHS.ThreadAction.SELECT: {
803
777
  state.focus = intent.data?.current === state.current ? state.focus : intent.data?.focus;
804
778
  state.current = intent.data?.current;
805
779
  return {
806
780
  data: true
807
781
  };
808
782
  }
809
- case import_chunk_FXD3DYMO.ThreadAction.TOGGLE_RESOLVED: {
783
+ case import_chunk_D5GOVXHS.ThreadAction.TOGGLE_RESOLVED: {
810
784
  const { thread } = intent.data ?? {};
811
- if (!(thread instanceof import_types.ThreadType)) {
785
+ if (!(thread instanceof import_types2.ThreadType)) {
812
786
  return;
813
787
  }
814
788
  if (thread.status === "active" || thread.status === void 0) {
@@ -835,9 +809,9 @@ var ThreadPlugin = () => {
835
809
  ]
836
810
  };
837
811
  }
838
- case import_chunk_FXD3DYMO.ThreadAction.DELETE: {
812
+ case import_chunk_D5GOVXHS.ThreadAction.DELETE: {
839
813
  const { subject, thread } = intent.data ?? {};
840
- if (!(thread instanceof import_types.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject)) {
814
+ if (!(subject instanceof import_types.DocumentType) || !(thread instanceof import_types2.ThreadType)) {
841
815
  return;
842
816
  }
843
817
  const subjectId = (0, import_echo.fullyQualifiedId)(subject);
@@ -846,9 +820,7 @@ var ThreadPlugin = () => {
846
820
  const index = stagingArea.findIndex((t) => t.id === thread.id);
847
821
  if (index !== -1) {
848
822
  stagingArea.splice(index, 1);
849
- return {
850
- data: true
851
- };
823
+ return;
852
824
  }
853
825
  }
854
826
  const space = (0, import_echo.getSpace)(thread);
@@ -864,7 +836,7 @@ var ThreadPlugin = () => {
864
836
  space.db.remove(thread);
865
837
  return {
866
838
  undoable: {
867
- message: translations_default[0]["en-US"][import_chunk_6EVXCSDS.THREAD_PLUGIN]["thread deleted label"],
839
+ message: translations_default[0]["en-US"][import_chunk_BWBONZGU.THREAD_PLUGIN]["thread deleted label"],
868
840
  data: {
869
841
  cursor
870
842
  }
@@ -907,9 +879,9 @@ var ThreadPlugin = () => {
907
879
  }
908
880
  break;
909
881
  }
910
- case import_chunk_FXD3DYMO.ThreadAction.ON_MESSAGE_ADD: {
882
+ case import_chunk_D5GOVXHS.ThreadAction.ON_MESSAGE_ADD: {
911
883
  const { thread, subject } = intent.data ?? {};
912
- if (!(thread instanceof import_types.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject && Array.isArray(subject.threads))) {
884
+ if (!(thread instanceof import_types2.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject)) {
913
885
  return;
914
886
  }
915
887
  const subjectId = (0, import_echo.fullyQualifiedId)(subject);
@@ -950,10 +922,10 @@ var ThreadPlugin = () => {
950
922
  ]
951
923
  };
952
924
  }
953
- case import_chunk_FXD3DYMO.ThreadAction.DELETE_MESSAGE: {
925
+ case import_chunk_D5GOVXHS.ThreadAction.DELETE_MESSAGE: {
954
926
  const { subject, thread, messageId } = intent.data ?? {};
955
927
  const space = (0, import_echo.getSpace)(subject);
956
- if (!(thread instanceof import_types.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject)) {
928
+ if (!(subject instanceof import_types.DocumentType) || !(thread instanceof import_types2.ThreadType) || !space) {
957
929
  return;
958
930
  }
959
931
  if (!intent.undo) {
@@ -967,7 +939,7 @@ var ThreadPlugin = () => {
967
939
  intents: [
968
940
  [
969
941
  {
970
- action: import_chunk_FXD3DYMO.ThreadAction.DELETE,
942
+ action: import_chunk_D5GOVXHS.ThreadAction.DELETE,
971
943
  data: {
972
944
  subject,
973
945
  thread
@@ -981,7 +953,7 @@ var ThreadPlugin = () => {
981
953
  }
982
954
  return {
983
955
  undoable: {
984
- message: translations_default[0]["en-US"][import_chunk_6EVXCSDS.THREAD_PLUGIN]["message deleted label"],
956
+ message: translations_default[0]["en-US"][import_chunk_BWBONZGU.THREAD_PLUGIN]["message deleted label"],
985
957
  data: {
986
958
  message,
987
959
  messageIndex
@@ -995,7 +967,7 @@ var ThreadPlugin = () => {
995
967
  name: "threads.message.delete",
996
968
  properties: {
997
969
  threadId: thread.id,
998
- spaceId: space?.id
970
+ spaceId: space.id
999
971
  }
1000
972
  }
1001
973
  }
@@ -1005,7 +977,7 @@ var ThreadPlugin = () => {
1005
977
  } else if (intent.undo) {
1006
978
  const message = intent.data?.message;
1007
979
  const messageIndex = intent.data?.messageIndex;
1008
- if (!(message instanceof import_types.MessageType) || !(typeof messageIndex === "number")) {
980
+ if (!(message instanceof import_types2.MessageType) || !(typeof messageIndex === "number")) {
1009
981
  return;
1010
982
  }
1011
983
  thread.messages.splice(messageIndex, 0, message);
@@ -1019,7 +991,7 @@ var ThreadPlugin = () => {
1019
991
  name: "threads.message.undo-delete",
1020
992
  properties: {
1021
993
  threadId: thread.id,
1022
- spaceId: space?.id
994
+ spaceId: space.id
1023
995
  }
1024
996
  }
1025
997
  }
@@ -1061,7 +1033,7 @@ var ThreadPlugin = () => {
1061
1033
  }
1062
1034
  }),
1063
1035
  (0, import_react_ui_editor.createExternalCommentSync)(doc.id, (sink) => (0, import_signals_core.effect)(() => sink()), () => threads.value.filter((thread) => thread?.anchor).map((thread) => ({
1064
- id: (0, import_echo.fullyQualifiedId)(thread),
1036
+ id: thread.id,
1065
1037
  cursor: thread.anchor
1066
1038
  }))),
1067
1039
  (0, import_react_ui_editor.comments)({
@@ -1072,7 +1044,7 @@ var ThreadPlugin = () => {
1072
1044
  "content"
1073
1045
  ]), start, end);
1074
1046
  void intentPlugin?.provides.intent.dispatch({
1075
- action: import_chunk_FXD3DYMO.ThreadAction.CREATE,
1047
+ action: import_chunk_D5GOVXHS.ThreadAction.CREATE,
1076
1048
  data: {
1077
1049
  cursor,
1078
1050
  name,
@@ -1083,7 +1055,7 @@ var ThreadPlugin = () => {
1083
1055
  onDelete: ({ id }) => {
1084
1056
  const stagingArea = state.staging[(0, import_echo.fullyQualifiedId)(doc)];
1085
1057
  if (stagingArea) {
1086
- const index = stagingArea.findIndex((thread2) => (0, import_echo.fullyQualifiedId)(thread2) === id);
1058
+ const index = stagingArea.findIndex((thread2) => thread2.id === id);
1087
1059
  if (index !== -1) {
1088
1060
  stagingArea.splice(index, 1);
1089
1061
  }
@@ -1094,8 +1066,8 @@ var ThreadPlugin = () => {
1094
1066
  }
1095
1067
  },
1096
1068
  onUpdate: ({ id, cursor }) => {
1097
- const thread = state.staging[(0, import_echo.fullyQualifiedId)(doc)]?.find((thread2) => (0, import_echo.fullyQualifiedId)(thread2) === id) ?? doc.threads.find((thread2) => thread2?.id === id);
1098
- if (thread instanceof import_types.ThreadType && thread.anchor) {
1069
+ const thread = state.staging[(0, import_echo.fullyQualifiedId)(doc)]?.find((thread2) => thread2.id === id) ?? doc.threads.find((thread2) => thread2?.id === id);
1070
+ if (thread instanceof import_types2.ThreadType && thread.anchor) {
1099
1071
  const [start, end] = thread.anchor.split(":");
1100
1072
  thread.name = doc.content && (0, import_echo.getTextInRange)((0, import_echo.createDocAccessor)(doc.content, [
1101
1073
  "content"
@@ -1104,11 +1076,11 @@ var ThreadPlugin = () => {
1104
1076
  }
1105
1077
  },
1106
1078
  onSelect: ({ selection: { current, closest } }) => {
1107
- const dispatch = intentPlugin?.provides.intent.dispatch;
1108
- if (dispatch) {
1109
- void dispatch([
1079
+ const dispatch2 = intentPlugin?.provides.intent.dispatch;
1080
+ if (dispatch2) {
1081
+ void dispatch2([
1110
1082
  {
1111
- action: import_chunk_FXD3DYMO.ThreadAction.SELECT,
1083
+ action: import_chunk_D5GOVXHS.ThreadAction.SELECT,
1112
1084
  data: {
1113
1085
  current: current ?? closest
1114
1086
  }