@univerjs/thread-comment-ui 1.4.0 → 1.5.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.
package/README.md CHANGED
@@ -8,9 +8,9 @@
8
8
 
9
9
  ## Package Overview
10
10
 
11
- | Package | UMD global | CSS | Locales | Facade entry |
12
- | --- | --- | :---: | :---: | :---: |
13
- | `@univerjs/thread-comment-ui` | `UniverThreadCommentUi` | Yes | Yes | No |
11
+ | Package | UMD global | CSS | Locales | Facade entry | Worker entry |
12
+ | --- | --- | :---: | :---: | :---: | :---: |
13
+ | `@univerjs/thread-comment-ui` | `UniverThreadCommentUi` | Yes | Yes | No | No |
14
14
 
15
15
  ## Installation
16
16
 
@@ -20,10 +20,10 @@ pnpm add @univerjs/thread-comment-ui
20
20
  npm install @univerjs/thread-comment-ui
21
21
  ```
22
22
 
23
- Keep all `@univerjs/*` packages on the same version.
24
-
25
23
  ## Usage
26
24
 
25
+ Start with the [integration setup](https://docs.univer.ai/) for your document type, including its required plugins, styles, and locale resources. The snippet below assumes that setup is complete.
26
+
27
27
  ```ts
28
28
  import '@univerjs/thread-comment-ui/lib/index.css';
29
29
  import EnUS from '@univerjs/thread-comment-ui/locale/en-US';
package/lib/cjs/index.js CHANGED
@@ -10,7 +10,7 @@ let _univerjs_icons = require("@univerjs/icons");
10
10
  let react = require("react");
11
11
  let react_jsx_runtime = require("react/jsx-runtime");
12
12
 
13
- // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
13
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
14
14
  function _typeof(o) {
15
15
  "@babel/helpers - typeof";
16
16
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -20,25 +20,25 @@ function _typeof(o) {
20
20
  }, _typeof(o);
21
21
  }
22
22
 
23
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
24
- function toPrimitive(t, r) {
23
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
24
+ function toPrimitive(t, e) {
25
25
  if ("object" != _typeof(t) || !t) return t;
26
- var e = t[Symbol.toPrimitive];
27
- if (void 0 !== e) {
28
- var i = e.call(t, r || "default");
26
+ var r;
27
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
28
+ var i = r.call(t, e || "default");
29
29
  if ("object" != _typeof(i)) return i;
30
30
  throw new TypeError("@@toPrimitive must return a primitive value.");
31
31
  }
32
- return ("string" === r ? String : Number)(t);
32
+ return ("string" === e ? String : Number)(t);
33
33
  }
34
34
 
35
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
35
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
36
36
  function toPropertyKey(t) {
37
37
  var i = toPrimitive(t, "string");
38
38
  return "symbol" == _typeof(i) ? i : i + "";
39
39
  }
40
40
 
41
- // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
41
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
42
42
  function _defineProperty(e, r, t) {
43
43
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
44
44
  value: t,
@@ -48,14 +48,14 @@ function _defineProperty(e, r, t) {
48
48
  }) : e[r] = t, e;
49
49
  }
50
50
 
51
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
51
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
52
52
  function __decorateParam(paramIndex, decorator) {
53
53
  return function(target, key) {
54
54
  decorator(target, key, paramIndex);
55
55
  };
56
56
  }
57
57
 
58
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
58
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
59
59
  function __decorate(decorators, target, key, desc) {
60
60
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
61
61
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -126,7 +126,7 @@ const SetActiveCommentOperation = {
126
126
 
127
127
  // package.json
128
128
  var name = "@univerjs/thread-comment-ui";
129
- var version = "1.4.0";
129
+ var version = "1.5.0";
130
130
 
131
131
  // src/config/config.ts
132
132
  const THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY = "thread-comment-ui.config";
@@ -1138,15 +1138,15 @@ function MobileThreadCommentTree(props) {
1138
1138
 
1139
1139
  // src/views/mobile/MobileThreadCommentPanel.tsx
1140
1140
  function MobileCommentFilter({ value, options = [], onChange }) {
1141
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1142
- className: "univer-flex univer-gap-1 univer-overflow-x-auto univer-rounded-xl univer-bg-gray-100 univer-p-1 dark:!univer-bg-gray-800",
1143
- children: options.flatMap((option) => option.options ?? [option]).map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1144
- type: "button",
1145
- "aria-pressed": option.value === value,
1146
- className: (0, _univerjs_design.clsx)(_univerjs_design.resetButtonClassName, "univer-h-10 univer-shrink-0 univer-rounded-lg univer-px-3 univer-text-sm univer-text-gray-700 active:univer-scale-95 dark:!univer-text-gray-200", option.value === value && "univer-bg-gray-0 univer-font-medium univer-text-primary-600 univer-shadow-sm dark:!univer-bg-gray-700 dark:!univer-text-primary-300"),
1147
- onClick: () => option.value != null && (onChange === null || onChange === void 0 ? void 0 : onChange(option.value)),
1148
- children: option.label
1149
- }, option.value))
1141
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Segmented, {
1142
+ className: "univer-w-full",
1143
+ value,
1144
+ items: options.flatMap((option) => option.options ?? [option]).filter((option) => option.value != null).map((option) => ({
1145
+ label: option.label,
1146
+ value: option.value,
1147
+ disabled: option.disabled
1148
+ })),
1149
+ onChange
1150
1150
  });
1151
1151
  }
1152
1152
  function MobileCommentHeader({ comment: activeComment, displayRef }) {
@@ -1154,17 +1154,10 @@ function MobileCommentHeader({ comment: activeComment, displayRef }) {
1154
1154
  const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
1155
1155
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1156
1156
  className: "univer-mt-2 univer-flex univer-min-h-12 univer-items-center univer-gap-2 univer-border-0 univer-border-b univer-border-solid univer-border-gray-200 univer-pb-2 dark:!univer-border-gray-700",
1157
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1158
- type: "button",
1157
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
1158
+ size: "icon",
1159
+ variant: "text",
1159
1160
  "aria-label": localeService.t("thread-comment-ui.mobile.back"),
1160
- className: `
1161
- ${_univerjs_design.resetButtonClassName}
1162
- univer-flex univer-size-12 univer-shrink-0 univer-items-center univer-justify-center univer-rounded-xl
1163
- univer-text-2xl univer-text-gray-700
1164
- active:univer-bg-gray-100
1165
- dark:!univer-text-gray-200
1166
- dark:active:!univer-bg-gray-700
1167
- `,
1168
1161
  onClick: () => commandService.executeCommand(SetActiveCommentOperation.id),
1169
1162
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreLeftIcon, {})
1170
1163
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -1186,6 +1179,7 @@ function MobileAddComment({ onAdd }) {
1186
1179
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
1187
1180
  className: "univer-w-full",
1188
1181
  onClick: onAdd,
1182
+ size: "middle",
1189
1183
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.IncreaseIcon, { className: "univer-mr-1.5" }), localeService.t("thread-comment-ui.panel.addComment")]
1190
1184
  })
1191
1185
  });
@@ -1362,7 +1356,7 @@ function MobileThreadCommentPanel(props) {
1362
1356
  onClose: !comment.id ? onTempCommentClose : void 0
1363
1357
  }, getThreadCommentPanelItemKey(comment, index, section));
1364
1358
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1365
- className: "univer-flex univer-min-h-full univer-flex-col univer-pb-3",
1359
+ className: "univer-box-border univer-flex univer-min-h-full univer-flex-col univer-pb-3",
1366
1360
  children: [
1367
1361
  activeComment && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileCommentHeader, {
1368
1362
  comment: activeComment,
@@ -1387,6 +1381,7 @@ function MobileThreadCommentPanel(props) {
1387
1381
  className: "univer-mt-2 univer-flex univer-flex-row",
1388
1382
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
1389
1383
  onClick: handleReset,
1384
+ size: "middle",
1390
1385
  children: localeService.t("thread-comment-ui.panel.reset")
1391
1386
  })
1392
1387
  }) : null]
@@ -1557,7 +1552,7 @@ const ThreadCommentPanel = (props) => {
1557
1552
  onClose: !comment.id ? onTempCommentClose : void 0
1558
1553
  }, getThreadCommentPanelItemKey(comment, index, section));
1559
1554
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1560
- className: "univer-flex univer-min-h-full univer-flex-col univer-pb-3",
1555
+ className: "univer-box-border univer-flex univer-min-h-full univer-flex-col univer-pb-3",
1561
1556
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1562
1557
  className: "univer-mt-3 univer-flex univer-flex-row univer-justify-between",
1563
1558
  children: [type === _univerjs_core.UniverInstanceType.UNIVER_SHEET ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
package/lib/es/index.js CHANGED
@@ -4,12 +4,12 @@ import { BehaviorSubject, debounceTime, map, of, startWith } from "rxjs";
4
4
  import { BreakLineCommand, DeleteLeftCommand, DeleteRightCommand, IEditorService, RichTextEditor, UniverDocsUIPlugin } from "@univerjs/docs-ui";
5
5
  import { AddCommentCommand, DeleteCommentCommand, DeleteCommentTreeCommand, ResolveCommentCommand, ThreadCommentModel, UniverThreadCommentPlugin, UpdateCommentCommand, getDT } from "@univerjs/thread-comment";
6
6
  import { BaseObject, DEFAULT_FONTFACE_PLANE } from "@univerjs/engine-render";
7
- import { ActionRow, Button, Dropdown, MobileActionRowGroup, MobileDropdown, Select, Tooltip, borderClassName, clsx, resetButtonClassName, scrollbarClassName } from "@univerjs/design";
7
+ import { ActionRow, Button, Dropdown, MobileActionRowGroup, MobileDropdown, Segmented, Select, Tooltip, borderClassName, clsx, scrollbarClassName } from "@univerjs/design";
8
8
  import { DeleteIcon, IncreaseIcon, MoreHorizontalIcon, MoreLeftIcon, ReplyToCommentIcon, SuccessIcon, SuccessOutlineIcon } from "@univerjs/icons";
9
9
  import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
10
10
  import { jsx, jsxs } from "react/jsx-runtime";
11
11
 
12
- // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
12
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
13
13
  function _typeof(o) {
14
14
  "@babel/helpers - typeof";
15
15
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -19,25 +19,25 @@ function _typeof(o) {
19
19
  }, _typeof(o);
20
20
  }
21
21
 
22
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
23
- function toPrimitive(t, r) {
22
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
23
+ function toPrimitive(t, e) {
24
24
  if ("object" != _typeof(t) || !t) return t;
25
- var e = t[Symbol.toPrimitive];
26
- if (void 0 !== e) {
27
- var i = e.call(t, r || "default");
25
+ var r;
26
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
27
+ var i = r.call(t, e || "default");
28
28
  if ("object" != _typeof(i)) return i;
29
29
  throw new TypeError("@@toPrimitive must return a primitive value.");
30
30
  }
31
- return ("string" === r ? String : Number)(t);
31
+ return ("string" === e ? String : Number)(t);
32
32
  }
33
33
 
34
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
34
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
35
35
  function toPropertyKey(t) {
36
36
  var i = toPrimitive(t, "string");
37
37
  return "symbol" == _typeof(i) ? i : i + "";
38
38
  }
39
39
 
40
- // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
40
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
41
41
  function _defineProperty(e, r, t) {
42
42
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
43
43
  value: t,
@@ -47,14 +47,14 @@ function _defineProperty(e, r, t) {
47
47
  }) : e[r] = t, e;
48
48
  }
49
49
 
50
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
50
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
51
51
  function __decorateParam(paramIndex, decorator) {
52
52
  return function(target, key) {
53
53
  decorator(target, key, paramIndex);
54
54
  };
55
55
  }
56
56
 
57
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
57
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
58
58
  function __decorate(decorators, target, key, desc) {
59
59
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
60
60
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -125,7 +125,7 @@ const SetActiveCommentOperation = {
125
125
 
126
126
  // package.json
127
127
  var name = "@univerjs/thread-comment-ui";
128
- var version = "1.4.0";
128
+ var version = "1.5.0";
129
129
 
130
130
  // src/config/config.ts
131
131
  const THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY = "thread-comment-ui.config";
@@ -1137,15 +1137,15 @@ function MobileThreadCommentTree(props) {
1137
1137
 
1138
1138
  // src/views/mobile/MobileThreadCommentPanel.tsx
1139
1139
  function MobileCommentFilter({ value, options = [], onChange }) {
1140
- return /* @__PURE__ */ jsx("div", {
1141
- className: "univer-flex univer-gap-1 univer-overflow-x-auto univer-rounded-xl univer-bg-gray-100 univer-p-1 dark:!univer-bg-gray-800",
1142
- children: options.flatMap((option) => option.options ?? [option]).map((option) => /* @__PURE__ */ jsx("button", {
1143
- type: "button",
1144
- "aria-pressed": option.value === value,
1145
- className: clsx(resetButtonClassName, "univer-h-10 univer-shrink-0 univer-rounded-lg univer-px-3 univer-text-sm univer-text-gray-700 active:univer-scale-95 dark:!univer-text-gray-200", option.value === value && "univer-bg-gray-0 univer-font-medium univer-text-primary-600 univer-shadow-sm dark:!univer-bg-gray-700 dark:!univer-text-primary-300"),
1146
- onClick: () => option.value != null && (onChange === null || onChange === void 0 ? void 0 : onChange(option.value)),
1147
- children: option.label
1148
- }, option.value))
1140
+ return /* @__PURE__ */ jsx(Segmented, {
1141
+ className: "univer-w-full",
1142
+ value,
1143
+ items: options.flatMap((option) => option.options ?? [option]).filter((option) => option.value != null).map((option) => ({
1144
+ label: option.label,
1145
+ value: option.value,
1146
+ disabled: option.disabled
1147
+ })),
1148
+ onChange
1149
1149
  });
1150
1150
  }
1151
1151
  function MobileCommentHeader({ comment: activeComment, displayRef }) {
@@ -1153,17 +1153,10 @@ function MobileCommentHeader({ comment: activeComment, displayRef }) {
1153
1153
  const commandService = useDependency(ICommandService);
1154
1154
  return /* @__PURE__ */ jsxs("div", {
1155
1155
  className: "univer-mt-2 univer-flex univer-min-h-12 univer-items-center univer-gap-2 univer-border-0 univer-border-b univer-border-solid univer-border-gray-200 univer-pb-2 dark:!univer-border-gray-700",
1156
- children: [/* @__PURE__ */ jsx("button", {
1157
- type: "button",
1156
+ children: [/* @__PURE__ */ jsx(Button, {
1157
+ size: "icon",
1158
+ variant: "text",
1158
1159
  "aria-label": localeService.t("thread-comment-ui.mobile.back"),
1159
- className: `
1160
- ${resetButtonClassName}
1161
- univer-flex univer-size-12 univer-shrink-0 univer-items-center univer-justify-center univer-rounded-xl
1162
- univer-text-2xl univer-text-gray-700
1163
- active:univer-bg-gray-100
1164
- dark:!univer-text-gray-200
1165
- dark:active:!univer-bg-gray-700
1166
- `,
1167
1160
  onClick: () => commandService.executeCommand(SetActiveCommentOperation.id),
1168
1161
  children: /* @__PURE__ */ jsx(MoreLeftIcon, {})
1169
1162
  }), /* @__PURE__ */ jsxs("div", {
@@ -1185,6 +1178,7 @@ function MobileAddComment({ onAdd }) {
1185
1178
  children: /* @__PURE__ */ jsxs(Button, {
1186
1179
  className: "univer-w-full",
1187
1180
  onClick: onAdd,
1181
+ size: "middle",
1188
1182
  children: [/* @__PURE__ */ jsx(IncreaseIcon, { className: "univer-mr-1.5" }), localeService.t("thread-comment-ui.panel.addComment")]
1189
1183
  })
1190
1184
  });
@@ -1361,7 +1355,7 @@ function MobileThreadCommentPanel(props) {
1361
1355
  onClose: !comment.id ? onTempCommentClose : void 0
1362
1356
  }, getThreadCommentPanelItemKey(comment, index, section));
1363
1357
  return /* @__PURE__ */ jsxs("div", {
1364
- className: "univer-flex univer-min-h-full univer-flex-col univer-pb-3",
1358
+ className: "univer-box-border univer-flex univer-min-h-full univer-flex-col univer-pb-3",
1365
1359
  children: [
1366
1360
  activeComment && /* @__PURE__ */ jsx(MobileCommentHeader, {
1367
1361
  comment: activeComment,
@@ -1386,6 +1380,7 @@ function MobileThreadCommentPanel(props) {
1386
1380
  className: "univer-mt-2 univer-flex univer-flex-row",
1387
1381
  children: /* @__PURE__ */ jsx(Button, {
1388
1382
  onClick: handleReset,
1383
+ size: "middle",
1389
1384
  children: localeService.t("thread-comment-ui.panel.reset")
1390
1385
  })
1391
1386
  }) : null]
@@ -1556,7 +1551,7 @@ const ThreadCommentPanel = (props) => {
1556
1551
  onClose: !comment.id ? onTempCommentClose : void 0
1557
1552
  }, getThreadCommentPanelItemKey(comment, index, section));
1558
1553
  return /* @__PURE__ */ jsxs("div", {
1559
- className: "univer-flex univer-min-h-full univer-flex-col univer-pb-3",
1554
+ className: "univer-box-border univer-flex univer-min-h-full univer-flex-col univer-pb-3",
1560
1555
  children: [/* @__PURE__ */ jsxs("div", {
1561
1556
  className: "univer-mt-3 univer-flex univer-flex-row univer-justify-between",
1562
1557
  children: [type === UniverInstanceType.UNIVER_SHEET ? /* @__PURE__ */ jsx(Select, {
package/lib/index.css CHANGED
@@ -79,11 +79,6 @@
79
79
  display: grid;
80
80
  }
81
81
 
82
- .univer-size-12 {
83
- width: 3rem;
84
- height: 3rem;
85
- }
86
-
87
82
  .univer-size-6 {
88
83
  width: 1.5rem;
89
84
  height: 1.5rem;
@@ -93,10 +88,6 @@
93
88
  height: .375rem;
94
89
  }
95
90
 
96
- .univer-h-10 {
97
- height: 2.5rem;
98
- }
99
-
100
91
  .univer-h-3\.5 {
101
92
  height: .875rem;
102
93
  }
@@ -137,7 +128,7 @@
137
128
  flex: 1;
138
129
  }
139
130
 
140
- .univer-flex-shrink-0, .univer-shrink-0 {
131
+ .univer-flex-shrink-0 {
141
132
  flex-shrink: 0;
142
133
  }
143
134
 
@@ -181,10 +172,6 @@
181
172
  justify-content: space-between;
182
173
  }
183
174
 
184
- .univer-gap-1 {
185
- gap: .25rem;
186
- }
187
-
188
175
  .univer-gap-2 {
189
176
  gap: .5rem;
190
177
  }
@@ -197,10 +184,6 @@
197
184
  overflow: hidden;
198
185
  }
199
186
 
200
- .univer-overflow-x-auto {
201
- overflow-x: auto;
202
- }
203
-
204
187
  .univer-overflow-y-auto {
205
188
  overflow-y: auto;
206
189
  }
@@ -239,10 +222,6 @@
239
222
  border-radius: .125rem;
240
223
  }
241
224
 
242
- .univer-rounded-xl {
243
- border-radius: .75rem;
244
- }
245
-
246
225
  .univer-rounded-t-md {
247
226
  border-top-left-radius: .375rem;
248
227
  border-top-right-radius: .375rem;
@@ -272,10 +251,6 @@
272
251
  background-color: var(--univer-gray-0);
273
252
  }
274
253
 
275
- .univer-bg-gray-100 {
276
- background-color: var(--univer-gray-100);
277
- }
278
-
279
254
  .univer-bg-gray-50 {
280
255
  background-color: var(--univer-gray-50);
281
256
  }
@@ -308,10 +283,6 @@
308
283
  padding: 0;
309
284
  }
310
285
 
311
- .univer-p-1 {
312
- padding: .25rem;
313
- }
314
-
315
286
  .univer-p-1\.5 {
316
287
  padding: .375rem;
317
288
  }
@@ -320,11 +291,6 @@
320
291
  padding: 1rem;
321
292
  }
322
293
 
323
- .univer-px-3 {
324
- padding-left: .75rem;
325
- padding-right: .75rem;
326
- }
327
-
328
294
  .univer-px-4 {
329
295
  padding-left: 1rem;
330
296
  padding-right: 1rem;
@@ -342,11 +308,6 @@
342
308
  padding-left: 30px;
343
309
  }
344
310
 
345
- .univer-text-2xl {
346
- font-size: 1.5rem;
347
- line-height: 2rem;
348
- }
349
-
350
311
  .univer-text-base {
351
312
  font-size: 1rem;
352
313
  line-height: 1.5rem;
@@ -387,10 +348,6 @@
387
348
  color: var(--univer-gray-600);
388
349
  }
389
350
 
390
- .univer-text-gray-700 {
391
- color: var(--univer-gray-700);
392
- }
393
-
394
351
  .univer-text-gray-900 {
395
352
  color: var(--univer-gray-900);
396
353
  }
@@ -418,13 +375,6 @@
418
375
  box-shadow: var(--univer-tw-ring-offset-shadow, 0 0 #0000), var(--univer-tw-ring-shadow, 0 0 #0000), var(--univer-tw-shadow);
419
376
  }
420
377
 
421
- .univer-shadow-sm {
422
- --univer-tw-shadow: 0px 1px 2px 0px #1e284d14;
423
- --univer-tw-shadow-colored: 0px 1px 2px 0px var(--univer-tw-shadow-color);
424
- box-shadow: 0 0 #0000, 0 0 #0000, 0 1px 2px #1e284d14;
425
- box-shadow: var(--univer-tw-ring-offset-shadow, 0 0 #0000), var(--univer-tw-ring-shadow, 0 0 #0000), var(--univer-tw-shadow);
426
- }
427
-
428
378
  @media (hover: hover) and (pointer: fine) {
429
379
  .hover\:univer-bg-gray-100:hover {
430
380
  background-color: var(--univer-gray-100);
@@ -435,17 +385,6 @@
435
385
  }
436
386
  }
437
387
 
438
- .active\:univer-scale-95:active {
439
- --univer-tw-scale-x: .95;
440
- --univer-tw-scale-y: .95;
441
- transform: translate(var(--univer-tw-translate-x), var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skewX(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(.95) scaleY(.95);
442
- transform: translate(var(--univer-tw-translate-x), var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skewX(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));
443
- }
444
-
445
- .active\:univer-bg-gray-100:active {
446
- background-color: var(--univer-gray-100);
447
- }
448
-
449
388
  .rtl\:univer-left-auto:where([dir="rtl"], [dir="rtl"] *) {
450
389
  left: auto;
451
390
  }
@@ -486,14 +425,6 @@
486
425
  border-color: var(--univer-gray-700) !important;
487
426
  }
488
427
 
489
- .dark\:\!univer-bg-gray-700:where(.univer-dark, .univer-dark *) {
490
- background-color: var(--univer-gray-700) !important;
491
- }
492
-
493
- .dark\:\!univer-bg-gray-800:where(.univer-dark, .univer-dark *) {
494
- background-color: var(--univer-gray-800) !important;
495
- }
496
-
497
428
  .dark\:\!univer-bg-gray-900:where(.univer-dark, .univer-dark *) {
498
429
  background-color: var(--univer-gray-900) !important;
499
430
  }
@@ -510,10 +441,6 @@
510
441
  color: var(--univer-gray-400) !important;
511
442
  }
512
443
 
513
- .dark\:\!univer-text-primary-300:where(.univer-dark, .univer-dark *) {
514
- color: var(--univer-primary-300) !important;
515
- }
516
-
517
444
  @media (hover: hover) and (pointer: fine) {
518
445
  .dark\:hover\:\!univer-bg-gray-600:hover:where(.univer-dark, .univer-dark *) {
519
446
  background-color: var(--univer-gray-600) !important;
@@ -524,10 +451,6 @@
524
451
  }
525
452
  }
526
453
 
527
- .dark\:active\:\!univer-bg-gray-700:active:where(.univer-dark, .univer-dark *) {
528
- background-color: var(--univer-gray-700) !important;
529
- }
530
-
531
454
  .\[\&_button\]\:univer-block button {
532
455
  display: block;
533
456
  }
package/lib/index.js CHANGED
@@ -4,12 +4,12 @@ import { BehaviorSubject, debounceTime, map, of, startWith } from "rxjs";
4
4
  import { BreakLineCommand, DeleteLeftCommand, DeleteRightCommand, IEditorService, RichTextEditor, UniverDocsUIPlugin } from "@univerjs/docs-ui";
5
5
  import { AddCommentCommand, DeleteCommentCommand, DeleteCommentTreeCommand, ResolveCommentCommand, ThreadCommentModel, UniverThreadCommentPlugin, UpdateCommentCommand, getDT } from "@univerjs/thread-comment";
6
6
  import { BaseObject, DEFAULT_FONTFACE_PLANE } from "@univerjs/engine-render";
7
- import { ActionRow, Button, Dropdown, MobileActionRowGroup, MobileDropdown, Select, Tooltip, borderClassName, clsx, resetButtonClassName, scrollbarClassName } from "@univerjs/design";
7
+ import { ActionRow, Button, Dropdown, MobileActionRowGroup, MobileDropdown, Segmented, Select, Tooltip, borderClassName, clsx, scrollbarClassName } from "@univerjs/design";
8
8
  import { DeleteIcon, IncreaseIcon, MoreHorizontalIcon, MoreLeftIcon, ReplyToCommentIcon, SuccessIcon, SuccessOutlineIcon } from "@univerjs/icons";
9
9
  import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
10
10
  import { jsx, jsxs } from "react/jsx-runtime";
11
11
 
12
- // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
12
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
13
13
  function _typeof(o) {
14
14
  "@babel/helpers - typeof";
15
15
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -19,25 +19,25 @@ function _typeof(o) {
19
19
  }, _typeof(o);
20
20
  }
21
21
 
22
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
23
- function toPrimitive(t, r) {
22
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
23
+ function toPrimitive(t, e) {
24
24
  if ("object" != _typeof(t) || !t) return t;
25
- var e = t[Symbol.toPrimitive];
26
- if (void 0 !== e) {
27
- var i = e.call(t, r || "default");
25
+ var r;
26
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
27
+ var i = r.call(t, e || "default");
28
28
  if ("object" != _typeof(i)) return i;
29
29
  throw new TypeError("@@toPrimitive must return a primitive value.");
30
30
  }
31
- return ("string" === r ? String : Number)(t);
31
+ return ("string" === e ? String : Number)(t);
32
32
  }
33
33
 
34
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
34
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
35
35
  function toPropertyKey(t) {
36
36
  var i = toPrimitive(t, "string");
37
37
  return "symbol" == _typeof(i) ? i : i + "";
38
38
  }
39
39
 
40
- // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
40
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
41
41
  function _defineProperty(e, r, t) {
42
42
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
43
43
  value: t,
@@ -47,14 +47,14 @@ function _defineProperty(e, r, t) {
47
47
  }) : e[r] = t, e;
48
48
  }
49
49
 
50
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
50
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
51
51
  function __decorateParam(paramIndex, decorator) {
52
52
  return function(target, key) {
53
53
  decorator(target, key, paramIndex);
54
54
  };
55
55
  }
56
56
 
57
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
57
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
58
58
  function __decorate(decorators, target, key, desc) {
59
59
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
60
60
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -125,7 +125,7 @@ const SetActiveCommentOperation = {
125
125
 
126
126
  // package.json
127
127
  var name = "@univerjs/thread-comment-ui";
128
- var version = "1.4.0";
128
+ var version = "1.5.0";
129
129
 
130
130
  // src/config/config.ts
131
131
  const THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY = "thread-comment-ui.config";
@@ -1137,15 +1137,15 @@ function MobileThreadCommentTree(props) {
1137
1137
 
1138
1138
  // src/views/mobile/MobileThreadCommentPanel.tsx
1139
1139
  function MobileCommentFilter({ value, options = [], onChange }) {
1140
- return /* @__PURE__ */ jsx("div", {
1141
- className: "univer-flex univer-gap-1 univer-overflow-x-auto univer-rounded-xl univer-bg-gray-100 univer-p-1 dark:!univer-bg-gray-800",
1142
- children: options.flatMap((option) => option.options ?? [option]).map((option) => /* @__PURE__ */ jsx("button", {
1143
- type: "button",
1144
- "aria-pressed": option.value === value,
1145
- className: clsx(resetButtonClassName, "univer-h-10 univer-shrink-0 univer-rounded-lg univer-px-3 univer-text-sm univer-text-gray-700 active:univer-scale-95 dark:!univer-text-gray-200", option.value === value && "univer-bg-gray-0 univer-font-medium univer-text-primary-600 univer-shadow-sm dark:!univer-bg-gray-700 dark:!univer-text-primary-300"),
1146
- onClick: () => option.value != null && (onChange === null || onChange === void 0 ? void 0 : onChange(option.value)),
1147
- children: option.label
1148
- }, option.value))
1140
+ return /* @__PURE__ */ jsx(Segmented, {
1141
+ className: "univer-w-full",
1142
+ value,
1143
+ items: options.flatMap((option) => option.options ?? [option]).filter((option) => option.value != null).map((option) => ({
1144
+ label: option.label,
1145
+ value: option.value,
1146
+ disabled: option.disabled
1147
+ })),
1148
+ onChange
1149
1149
  });
1150
1150
  }
1151
1151
  function MobileCommentHeader({ comment: activeComment, displayRef }) {
@@ -1153,17 +1153,10 @@ function MobileCommentHeader({ comment: activeComment, displayRef }) {
1153
1153
  const commandService = useDependency(ICommandService);
1154
1154
  return /* @__PURE__ */ jsxs("div", {
1155
1155
  className: "univer-mt-2 univer-flex univer-min-h-12 univer-items-center univer-gap-2 univer-border-0 univer-border-b univer-border-solid univer-border-gray-200 univer-pb-2 dark:!univer-border-gray-700",
1156
- children: [/* @__PURE__ */ jsx("button", {
1157
- type: "button",
1156
+ children: [/* @__PURE__ */ jsx(Button, {
1157
+ size: "icon",
1158
+ variant: "text",
1158
1159
  "aria-label": localeService.t("thread-comment-ui.mobile.back"),
1159
- className: `
1160
- ${resetButtonClassName}
1161
- univer-flex univer-size-12 univer-shrink-0 univer-items-center univer-justify-center univer-rounded-xl
1162
- univer-text-2xl univer-text-gray-700
1163
- active:univer-bg-gray-100
1164
- dark:!univer-text-gray-200
1165
- dark:active:!univer-bg-gray-700
1166
- `,
1167
1160
  onClick: () => commandService.executeCommand(SetActiveCommentOperation.id),
1168
1161
  children: /* @__PURE__ */ jsx(MoreLeftIcon, {})
1169
1162
  }), /* @__PURE__ */ jsxs("div", {
@@ -1185,6 +1178,7 @@ function MobileAddComment({ onAdd }) {
1185
1178
  children: /* @__PURE__ */ jsxs(Button, {
1186
1179
  className: "univer-w-full",
1187
1180
  onClick: onAdd,
1181
+ size: "middle",
1188
1182
  children: [/* @__PURE__ */ jsx(IncreaseIcon, { className: "univer-mr-1.5" }), localeService.t("thread-comment-ui.panel.addComment")]
1189
1183
  })
1190
1184
  });
@@ -1361,7 +1355,7 @@ function MobileThreadCommentPanel(props) {
1361
1355
  onClose: !comment.id ? onTempCommentClose : void 0
1362
1356
  }, getThreadCommentPanelItemKey(comment, index, section));
1363
1357
  return /* @__PURE__ */ jsxs("div", {
1364
- className: "univer-flex univer-min-h-full univer-flex-col univer-pb-3",
1358
+ className: "univer-box-border univer-flex univer-min-h-full univer-flex-col univer-pb-3",
1365
1359
  children: [
1366
1360
  activeComment && /* @__PURE__ */ jsx(MobileCommentHeader, {
1367
1361
  comment: activeComment,
@@ -1386,6 +1380,7 @@ function MobileThreadCommentPanel(props) {
1386
1380
  className: "univer-mt-2 univer-flex univer-flex-row",
1387
1381
  children: /* @__PURE__ */ jsx(Button, {
1388
1382
  onClick: handleReset,
1383
+ size: "middle",
1389
1384
  children: localeService.t("thread-comment-ui.panel.reset")
1390
1385
  })
1391
1386
  }) : null]
@@ -1556,7 +1551,7 @@ const ThreadCommentPanel = (props) => {
1556
1551
  onClose: !comment.id ? onTempCommentClose : void 0
1557
1552
  }, getThreadCommentPanelItemKey(comment, index, section));
1558
1553
  return /* @__PURE__ */ jsxs("div", {
1559
- className: "univer-flex univer-min-h-full univer-flex-col univer-pb-3",
1554
+ className: "univer-box-border univer-flex univer-min-h-full univer-flex-col univer-pb-3",
1560
1555
  children: [/* @__PURE__ */ jsxs("div", {
1561
1556
  className: "univer-mt-3 univer-flex univer-flex-row univer-justify-between",
1562
1557
  children: [type === UniverInstanceType.UNIVER_SHEET ? /* @__PURE__ */ jsx(Select, {
package/lib/umd/index.js CHANGED
@@ -1,11 +1,4 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/docs-ui"),require("@univerjs/thread-comment"),require("@univerjs/engine-render"),require("@univerjs/design"),require("react"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/ui`,`rxjs`,`@univerjs/docs-ui`,`@univerjs/thread-comment`,`@univerjs/engine-render`,`@univerjs/design`,`react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverThreadCommentUi={},e.UniverCore,e.UniverUi,e.rxjs,e.UniverDocsUi,e.UniverThreadComment,e.UniverEngineRender,e.UniverDesign,e.React,e.React))})(this,function(e,t,n,r,i,a,o,s,c,l){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function u(e){"@babel/helpers - typeof";return u=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},u(e)}function d(e,t){if(u(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(u(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function f(e){var t=d(e,`string`);return u(t)==`symbol`?t:t+``}function p(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e,t){return function(n,r){t(n,r,e)}}function h(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let g=class extends t.Disposable{constructor(e){super(),this._sidebarService=e,p(this,`_panelVisible`,!1),p(this,`_panelVisible$`,new r.BehaviorSubject(!1)),p(this,`_activeCommentId`,void 0),p(this,`_activeCommentId$`,new r.BehaviorSubject(void 0)),p(this,`_hoveredCommentId`,void 0),p(this,`_hoveredCommentId$`,new r.BehaviorSubject(void 0)),p(this,`panelVisible$`,this._panelVisible$.asObservable()),p(this,`activeCommentId$`,this._activeCommentId$.asObservable()),p(this,`hoveredCommentId$`,this._hoveredCommentId$.asObservable()),this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._hoveredCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(e=>{e.visible||this.setPanelVisible(!1)}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}get hoveredCommentId(){return this._hoveredCommentId}setPanelVisible(e){this._panelVisible=e,this._panelVisible$.next(e),e||this.setHoveredComment(void 0)}setActiveComment(e){this._activeCommentId=e,this._activeCommentId$.next(e)}setHoveredComment(e){this._hoveredCommentId=e,this._hoveredCommentId$.next(e)}};g=h([m(0,(0,t.Inject)(n.ISidebarService))],g);let _={id:`thread-comment-ui.operation.set-active-comment`,type:t.CommandType.OPERATION,handler(e,t){return e.get(g).setActiveComment(t),!0}};var v=`@univerjs/thread-comment-ui`,y=`1.4.0`;let b=`thread-comment-ui.config`,x={},S=class extends t.Disposable{constructor(e,n){if(super(),this._userManagerService=n,p(this,`_placementType$`,new r.BehaviorSubject(null)),p(this,`_draft$`,new r.BehaviorSubject(null)),p(this,`_placementUnitId`,void 0),p(this,`_ownerUserId`,void 0),p(this,`placementType$`,this._placementType$.asObservable()),p(this,`draft$`,this._draft$.asObservable()),this.disposeWithMe(e.unitDisposed$.subscribe(e=>{var t;(((t=this.draft)==null?void 0:t.unitId)===e.getUnitId()||this._placementUnitId===e.getUnitId())&&this.cancel()})),this.disposeWithMe(e.focused$.subscribe(e=>{e&&this._placementUnitId&&e!==this._placementUnitId&&this.cancel()})),this.disposeWithMe(this._userManagerService.currentUser$.subscribe(e=>{this._ownerUserId&&(e==null?void 0:e.userID)!==this._ownerUserId&&this.cancel()})),typeof window<`u`){let e=e=>{e.key===`Escape`&&(this.placementType||this.draft)&&this.cancel()};window.addEventListener(`keydown`,e),this.disposeWithMe((0,t.toDisposable)(()=>window.removeEventListener(`keydown`,e)))}}get placementType(){return this._placementType$.value}get draft(){return this._draft$.value}startPlacement(e,t){this.placementType===e&&this._placementUnitId===t?this.cancel():(this._ownerUserId=this._userManagerService.getCurrentUser().userID,this._placementUnitId=t,this._draft$.next(null),this._placementType$.next(e))}place(e){this._ownerUserId=this._userManagerService.getCurrentUser().userID,this._placementUnitId=void 0,this._placementType$.next(null),this._draft$.next(e)}cancel(){this._ownerUserId=void 0,this._placementUnitId=void 0,this._placementType$.next(null),this._draft$.next(null)}dispose(){this._placementType$.complete(),this._draft$.complete(),super.dispose()}};S=h([m(0,t.IUniverInstanceService),m(1,(0,t.Inject)(t.UserManagerService))],S);let C=`UNIVER_THREAD_COMMENT_UI_PLUGIN`,w=class extends t.Plugin{constructor(e=x,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},x,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(b,o)}onStarting(){var e;(0,t.mergeOverrideWithDependencies)([[S],[g]],(e=this._config)==null?void 0:e.overrides).forEach(e=>{this._injector.add(e)}),this._commandService.registerCommand(_)}};p(w,`pluginName`,C),p(w,`packageName`,v),p(w,`version`,y),p(w,`type`,t.UniverInstanceType.UNIVER_UNKNOWN),w=h([(0,t.DependentOn)(a.UniverThreadCommentPlugin,i.UniverDocsUIPlugin,n.UniverMobileUIPlugin),m(1,(0,t.Inject)(t.Injector)),m(2,t.ICommandService),m(3,t.IConfigService)],w);let T=class extends t.Plugin{constructor(e=x,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},x,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(b,o)}onStarting(){var e;(0,t.mergeOverrideWithDependencies)([[S],[g]],(e=this._config)==null?void 0:e.overrides).forEach(e=>{this._injector.add(e)}),[_].forEach(e=>{this._commandService.registerCommand(e)})}};p(T,`pluginName`,C),p(T,`packageName`,v),p(T,`version`,y),p(T,`type`,t.UniverInstanceType.UNIVER_UNKNOWN),T=h([(0,t.DependentOn)(a.UniverThreadCommentPlugin,i.UniverDocsUIPlugin),m(1,(0,t.Inject)(t.Injector)),m(2,t.ICommandService),m(3,t.IConfigService)],T);let E=.42;var D=class extends o.BaseObject{constructor(e,t){super(e),p(this,`_state`,void 0),p(this,`_hoveredCommentId`,null),p(this,`_hitCommentId`,null),this.evented=!0,this._state=t,this.show()}get hitCommentId(){return this._hitCommentId}updateState(e){this._state={...this._state,...e},this._hitCommentId&&!this._containsComment(this._hitCommentId)&&(this._hitCommentId=null),this._hoveredCommentId&&!this._containsComment(this._hoveredCommentId)&&(this._hoveredCommentId=null),`previewMarker`in e||`previewUnderline`in e?this.makeDirtyNoDebounce(!0):this.makeDirty(!0)}clearHover(){this._hoveredCommentId&&(this._hoveredCommentId=null,this.makeDirty(!0)),this._hitCommentId=null}isHit(e){let t=this._getZoomRatio(),n=24/t/2,r;for(let t=this._state.markers.length-1;t>=0;--t){let i=this._state.markers[t];if(i&&e.x>=i.x-n&&e.x<=i.x+n&&e.y>=i.y-n&&e.y<=i.y+n){r=i;break}}let i;if(!r)for(let n=this._state.underlines.length-1;n>=0;--n){let r=this._state.underlines[n];if(r&&e.x>=r.left&&e.x<=r.left+r.width&&Math.abs(e.y-r.top)<=4/t){i=r;break}}let a=(r==null?void 0:r.commentId)??(i==null?void 0:i.commentId)??null;return this._hitCommentId=a,a!==this._hoveredCommentId&&(this._hoveredCommentId=a,this.makeDirty(!0)),a!==null}render(e,t){var n;let r=this._getZoomRatio();return this._state.underlines.forEach(t=>this._renderUnderline(e,t,r,1)),(n=this._state.focusOutlines)==null||n.forEach(t=>this._renderOutline(e,t,r)),this._state.previewUnderline&&this._renderUnderline(e,this._state.previewUnderline,r,E),this._state.markers.forEach(t=>{var n;return this._renderMarker(e,t,r,this._markerContainsComment(t,this._hoveredCommentId)||(n=this._state.focusedCommentIds)!=null&&n.some(e=>this._markerContainsComment(t,e))?1:.58)}),this._state.previewMarker&&this._renderMarker(e,this._state.previewMarker,r,E),this.makeDirty(!1),this}_getZoomRatio(){return Number.isFinite(this._state.zoomRatio)&&this._state.zoomRatio>0?this._state.zoomRatio:1}_containsComment(e){return this._state.markers.some(t=>this._markerContainsComment(t,e))||this._state.underlines.some(t=>t.commentId===e)}_markerContainsComment(e,t){var n;return t!=null&&(e.commentId===t||((n=e.commentIds)==null?void 0:n.includes(t))===!0)}_renderUnderline(e,t,n,r){e.save(),e.globalAlpha=r,e.strokeStyle=this._state.accentColor,e.lineWidth=2/n,e.beginPath(),e.moveTo(t.left,t.top),e.lineTo(t.left+t.width,t.top),e.stroke(),e.restore()}_renderOutline(e,t,n){let r=2/n;e.save(),e.strokeStyle=this._state.accentColor,e.lineWidth=2/n,e.strokeRect(t.left-r,t.top-r,t.width+r*2,t.height+r*2),e.restore()}_renderMarker(e,t,n,r){let i=24/n,a=t.x-i/2,s=t.y-i/2,c=4/n,l=4/n;if(e.save(),e.globalAlpha=r,e.fillStyle=this._state.accentColor,e.strokeStyle=this._state.outlineColor,e.lineWidth=1.5/n,e.beginPath(),e.moveTo(a+c,s),e.lineTo(a+i-c,s),e.quadraticCurveTo(a+i,s,a+i,s+c),e.lineTo(a+i,s+i-l-c),e.quadraticCurveTo(a+i,s+i-l,a+i-c,s+i-l),e.lineTo(a+i/2+l,s+i-l),e.lineTo(a+i/2,s+i),e.lineTo(a+i/2-l,s+i-l),e.lineTo(a+c,s+i-l),e.quadraticCurveTo(a,s+i-l,a,s+i-l-c),e.lineTo(a,s+c),e.quadraticCurveTo(a,s,a+c,s),e.closePath(),e.fill(),e.stroke(),e.fillStyle=this._state.foregroundColor,(t.count??1)>1)e.font=`600 ${11/n}px ${o.DEFAULT_FONTFACE_PLANE}`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(String(t.count),t.x,s+i*.42);else{let t=1.2/n,r=s+i*.43;[.32,.5,.68].forEach(n=>{e.beginPath(),e.arc(a+i*n,r,t,0,Math.PI*2),e.fill()})}e.restore()}};function O({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...s}=t,l=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),u=`_${(0,c.useId)()}`,d=(0,c.useRef)(null);return(0,c.useImperativeHandle)(e,()=>d.current),(0,c.useLayoutEffect)(()=>{if(n&&d.current&&d.current.localName===r.tag)return M(d.current)},[n,r]),k(r,`${i}`,{defIds:r.defIds,idSuffix:u},{ref:d,className:l,...s},o)}function k(e,t,n,r,i){return(0,c.createElement)(e.tag,{key:t,...A(e,n,i),...r},(j(e,n).children||[]).map((r,a)=>k(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function A(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0||(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),r}function j(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function M(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:N(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(P(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function N(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function P(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}O.displayName=`UniverIcon`;let F={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M5.93 1.47H10.07M1.7 3.64H14.3M4.75 5.82H11.25A1 1 0 0 1 12.25 6.82V12.53A2 2 0 0 1 10.25 14.53H5.75A2 2 0 0 1 3.75 12.53V6.82A1 1 0 0 1 4.75 5.82ZM6.55 8.73L9.45 11.63M9.45 8.73L6.55 11.63`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},I=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`delete-icon`,ref:t,icon:F}))});I.displayName=`DeleteIcon`;let L={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M8 2V14M2 8H14`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},R=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`increase-icon`,ref:t,icon:L}))});R.displayName=`IncreaseIcon`;let z={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M3 9C3.55228 9 4 8.55228 4 8C4 7.44772 3.55228 7 3 7C2.44772 7 2 7.44772 2 8C2 8.55228 2.44772 9 3 9Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8 9C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7C7.44772 7 7 7.44772 7 8C7 8.55228 7.44772 9 8 9Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M13 9C13.5523 9 14 8.55228 14 8C14 7.44772 13.5523 7 13 7C12.4477 7 12 7.44772 12 8C12 8.55228 12.4477 9 13 9Z`}}]},B=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`more-horizontal-icon`,ref:t,icon:z}))});B.displayName=`MoreHorizontalIcon`;let V={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M9.5 5L6.5 8L9.5 11`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},H=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`more-left-icon`,ref:t,icon:V}))});H.displayName=`MoreLeftIcon`;let U={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M6.41016 6.1311H6.76813`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M8.91626 6.1311H9.27424`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M3.90454 6.1311H4.26252`,strokeLinecap:`round`,strokeWidth:1.2}}]},W=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`reply-to-comment-icon`,ref:t,icon:U}))});W.displayName=`ReplyToCommentIcon`;let G={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M8 15C11.866 15 15 11.866 15 8C15 4.13401 11.866 1 8 1C4.13401 1 1 4.13401 1 8C1 11.866 4.13401 15 8 15ZM11.7245 6.42417C11.9588 6.18985 11.9588 5.80995 11.7245 5.57564C11.4901 5.34132 11.1102 5.34132 10.8759 5.57564L7.3002 9.15137L5.72446 7.57564C5.49014 7.34132 5.11025 7.34132 4.87593 7.57564C4.64162 7.80995 4.64162 8.18985 4.87593 8.42417L6.87593 10.4242C7.11025 10.6585 7.49014 10.6585 7.72446 10.4242L11.7245 6.42417Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},K=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`success-icon`,ref:t,icon:G}))});K.displayName=`SuccessIcon`;let q={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`g`,attrs:{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2},children:[{tag:`circle`,attrs:{cx:8,cy:8,r:6.4}},{tag:`path`,attrs:{d:`M5.3 8L7.3 10L11.3 6`}}]}]},J=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`success-outline-icon`,ref:t,icon:q}))});J.displayName=`SuccessOutlineIcon`;function Y(e,t){return(e==null?void 0:e.unitId)===t.unitId&&e.subUnitId===t.subUnitId&&e.commentId===t.id}function X(e,t,n){return e?e.unitId!==t||!n:!1}function ee(e,t,n){return e.id?e.id:[`thread-comment-panel-temp`,n,e.unitId,e.subUnitId,e.threadId,e.ref,e.dT,t].join(`-`)}let Z=e=>{let{dataStream:n,customRanges:r}=e,i=n.endsWith(`\r
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/docs-ui"),require("@univerjs/thread-comment"),require("@univerjs/engine-render"),require("@univerjs/design"),require("react"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/ui`,`rxjs`,`@univerjs/docs-ui`,`@univerjs/thread-comment`,`@univerjs/engine-render`,`@univerjs/design`,`react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverThreadCommentUi={},e.UniverCore,e.UniverUi,e.rxjs,e.UniverDocsUi,e.UniverThreadComment,e.UniverEngineRender,e.UniverDesign,e.React,e.React))})(this,function(e,t,n,r,i,a,o,s,c,l){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function u(e){"@babel/helpers - typeof";return u=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},u(e)}function d(e,t){if(u(e)!=`object`||!e)return e;var n;if(typeof Symbol<`u`&&(n=e[Symbol.toPrimitive])!==void 0){var r=n.call(e,t||`default`);if(u(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function f(e){var t=d(e,`string`);return u(t)==`symbol`?t:t+``}function p(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e,t){return function(n,r){t(n,r,e)}}function h(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let g=class extends t.Disposable{constructor(e){super(),this._sidebarService=e,p(this,`_panelVisible`,!1),p(this,`_panelVisible$`,new r.BehaviorSubject(!1)),p(this,`_activeCommentId`,void 0),p(this,`_activeCommentId$`,new r.BehaviorSubject(void 0)),p(this,`_hoveredCommentId`,void 0),p(this,`_hoveredCommentId$`,new r.BehaviorSubject(void 0)),p(this,`panelVisible$`,this._panelVisible$.asObservable()),p(this,`activeCommentId$`,this._activeCommentId$.asObservable()),p(this,`hoveredCommentId$`,this._hoveredCommentId$.asObservable()),this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._hoveredCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(e=>{e.visible||this.setPanelVisible(!1)}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}get hoveredCommentId(){return this._hoveredCommentId}setPanelVisible(e){this._panelVisible=e,this._panelVisible$.next(e),e||this.setHoveredComment(void 0)}setActiveComment(e){this._activeCommentId=e,this._activeCommentId$.next(e)}setHoveredComment(e){this._hoveredCommentId=e,this._hoveredCommentId$.next(e)}};g=h([m(0,(0,t.Inject)(n.ISidebarService))],g);let _={id:`thread-comment-ui.operation.set-active-comment`,type:t.CommandType.OPERATION,handler(e,t){return e.get(g).setActiveComment(t),!0}};var v=`@univerjs/thread-comment-ui`,y=`1.5.0`;let b=`thread-comment-ui.config`,x={},S=class extends t.Disposable{constructor(e,n){if(super(),this._userManagerService=n,p(this,`_placementType$`,new r.BehaviorSubject(null)),p(this,`_draft$`,new r.BehaviorSubject(null)),p(this,`_placementUnitId`,void 0),p(this,`_ownerUserId`,void 0),p(this,`placementType$`,this._placementType$.asObservable()),p(this,`draft$`,this._draft$.asObservable()),this.disposeWithMe(e.unitDisposed$.subscribe(e=>{var t;(((t=this.draft)==null?void 0:t.unitId)===e.getUnitId()||this._placementUnitId===e.getUnitId())&&this.cancel()})),this.disposeWithMe(e.focused$.subscribe(e=>{e&&this._placementUnitId&&e!==this._placementUnitId&&this.cancel()})),this.disposeWithMe(this._userManagerService.currentUser$.subscribe(e=>{this._ownerUserId&&(e==null?void 0:e.userID)!==this._ownerUserId&&this.cancel()})),typeof window<`u`){let e=e=>{e.key===`Escape`&&(this.placementType||this.draft)&&this.cancel()};window.addEventListener(`keydown`,e),this.disposeWithMe((0,t.toDisposable)(()=>window.removeEventListener(`keydown`,e)))}}get placementType(){return this._placementType$.value}get draft(){return this._draft$.value}startPlacement(e,t){this.placementType===e&&this._placementUnitId===t?this.cancel():(this._ownerUserId=this._userManagerService.getCurrentUser().userID,this._placementUnitId=t,this._draft$.next(null),this._placementType$.next(e))}place(e){this._ownerUserId=this._userManagerService.getCurrentUser().userID,this._placementUnitId=void 0,this._placementType$.next(null),this._draft$.next(e)}cancel(){this._ownerUserId=void 0,this._placementUnitId=void 0,this._placementType$.next(null),this._draft$.next(null)}dispose(){this._placementType$.complete(),this._draft$.complete(),super.dispose()}};S=h([m(0,t.IUniverInstanceService),m(1,(0,t.Inject)(t.UserManagerService))],S);let C=`UNIVER_THREAD_COMMENT_UI_PLUGIN`,w=class extends t.Plugin{constructor(e=x,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},x,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(b,o)}onStarting(){var e;(0,t.mergeOverrideWithDependencies)([[S],[g]],(e=this._config)==null?void 0:e.overrides).forEach(e=>{this._injector.add(e)}),this._commandService.registerCommand(_)}};p(w,`pluginName`,C),p(w,`packageName`,v),p(w,`version`,y),p(w,`type`,t.UniverInstanceType.UNIVER_UNKNOWN),w=h([(0,t.DependentOn)(a.UniverThreadCommentPlugin,i.UniverDocsUIPlugin,n.UniverMobileUIPlugin),m(1,(0,t.Inject)(t.Injector)),m(2,t.ICommandService),m(3,t.IConfigService)],w);let T=class extends t.Plugin{constructor(e=x,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},x,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(b,o)}onStarting(){var e;(0,t.mergeOverrideWithDependencies)([[S],[g]],(e=this._config)==null?void 0:e.overrides).forEach(e=>{this._injector.add(e)}),[_].forEach(e=>{this._commandService.registerCommand(e)})}};p(T,`pluginName`,C),p(T,`packageName`,v),p(T,`version`,y),p(T,`type`,t.UniverInstanceType.UNIVER_UNKNOWN),T=h([(0,t.DependentOn)(a.UniverThreadCommentPlugin,i.UniverDocsUIPlugin),m(1,(0,t.Inject)(t.Injector)),m(2,t.ICommandService),m(3,t.IConfigService)],T);let E=.42;var D=class extends o.BaseObject{constructor(e,t){super(e),p(this,`_state`,void 0),p(this,`_hoveredCommentId`,null),p(this,`_hitCommentId`,null),this.evented=!0,this._state=t,this.show()}get hitCommentId(){return this._hitCommentId}updateState(e){this._state={...this._state,...e},this._hitCommentId&&!this._containsComment(this._hitCommentId)&&(this._hitCommentId=null),this._hoveredCommentId&&!this._containsComment(this._hoveredCommentId)&&(this._hoveredCommentId=null),`previewMarker`in e||`previewUnderline`in e?this.makeDirtyNoDebounce(!0):this.makeDirty(!0)}clearHover(){this._hoveredCommentId&&(this._hoveredCommentId=null,this.makeDirty(!0)),this._hitCommentId=null}isHit(e){let t=this._getZoomRatio(),n=24/t/2,r;for(let t=this._state.markers.length-1;t>=0;--t){let i=this._state.markers[t];if(i&&e.x>=i.x-n&&e.x<=i.x+n&&e.y>=i.y-n&&e.y<=i.y+n){r=i;break}}let i;if(!r)for(let n=this._state.underlines.length-1;n>=0;--n){let r=this._state.underlines[n];if(r&&e.x>=r.left&&e.x<=r.left+r.width&&Math.abs(e.y-r.top)<=4/t){i=r;break}}let a=(r==null?void 0:r.commentId)??(i==null?void 0:i.commentId)??null;return this._hitCommentId=a,a!==this._hoveredCommentId&&(this._hoveredCommentId=a,this.makeDirty(!0)),a!==null}render(e,t){var n;let r=this._getZoomRatio();return this._state.underlines.forEach(t=>this._renderUnderline(e,t,r,1)),(n=this._state.focusOutlines)==null||n.forEach(t=>this._renderOutline(e,t,r)),this._state.previewUnderline&&this._renderUnderline(e,this._state.previewUnderline,r,E),this._state.markers.forEach(t=>{var n;return this._renderMarker(e,t,r,this._markerContainsComment(t,this._hoveredCommentId)||(n=this._state.focusedCommentIds)!=null&&n.some(e=>this._markerContainsComment(t,e))?1:.58)}),this._state.previewMarker&&this._renderMarker(e,this._state.previewMarker,r,E),this.makeDirty(!1),this}_getZoomRatio(){return Number.isFinite(this._state.zoomRatio)&&this._state.zoomRatio>0?this._state.zoomRatio:1}_containsComment(e){return this._state.markers.some(t=>this._markerContainsComment(t,e))||this._state.underlines.some(t=>t.commentId===e)}_markerContainsComment(e,t){var n;return t!=null&&(e.commentId===t||((n=e.commentIds)==null?void 0:n.includes(t))===!0)}_renderUnderline(e,t,n,r){e.save(),e.globalAlpha=r,e.strokeStyle=this._state.accentColor,e.lineWidth=2/n,e.beginPath(),e.moveTo(t.left,t.top),e.lineTo(t.left+t.width,t.top),e.stroke(),e.restore()}_renderOutline(e,t,n){let r=2/n;e.save(),e.strokeStyle=this._state.accentColor,e.lineWidth=2/n,e.strokeRect(t.left-r,t.top-r,t.width+r*2,t.height+r*2),e.restore()}_renderMarker(e,t,n,r){let i=24/n,a=t.x-i/2,s=t.y-i/2,c=4/n,l=4/n;if(e.save(),e.globalAlpha=r,e.fillStyle=this._state.accentColor,e.strokeStyle=this._state.outlineColor,e.lineWidth=1.5/n,e.beginPath(),e.moveTo(a+c,s),e.lineTo(a+i-c,s),e.quadraticCurveTo(a+i,s,a+i,s+c),e.lineTo(a+i,s+i-l-c),e.quadraticCurveTo(a+i,s+i-l,a+i-c,s+i-l),e.lineTo(a+i/2+l,s+i-l),e.lineTo(a+i/2,s+i),e.lineTo(a+i/2-l,s+i-l),e.lineTo(a+c,s+i-l),e.quadraticCurveTo(a,s+i-l,a,s+i-l-c),e.lineTo(a,s+c),e.quadraticCurveTo(a,s,a+c,s),e.closePath(),e.fill(),e.stroke(),e.fillStyle=this._state.foregroundColor,(t.count??1)>1)e.font=`600 ${11/n}px ${o.DEFAULT_FONTFACE_PLANE}`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(String(t.count),t.x,s+i*.42);else{let t=1.2/n,r=s+i*.43;[.32,.5,.68].forEach(n=>{e.beginPath(),e.arc(a+i*n,r,t,0,Math.PI*2),e.fill()})}e.restore()}};function O({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...s}=t,l=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),u=`_${(0,c.useId)()}`,d=(0,c.useRef)(null);return(0,c.useImperativeHandle)(e,()=>d.current),(0,c.useLayoutEffect)(()=>{if(n&&d.current&&d.current.localName===r.tag)return M(d.current)},[n,r]),k(r,`${i}`,{defIds:r.defIds,idSuffix:u},{ref:d,className:l,...s},o)}function k(e,t,n,r,i){return(0,c.createElement)(e.tag,{key:t,...A(e,n,i),...r},(j(e,n).children||[]).map((r,a)=>k(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function A(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0||(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),r}function j(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function M(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:N(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(P(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function N(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function P(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}O.displayName=`UniverIcon`;let F={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M5.93 1.47H10.07M1.7 3.64H14.3M4.75 5.82H11.25A1 1 0 0 1 12.25 6.82V12.53A2 2 0 0 1 10.25 14.53H5.75A2 2 0 0 1 3.75 12.53V6.82A1 1 0 0 1 4.75 5.82ZM6.55 8.73L9.45 11.63M9.45 8.73L6.55 11.63`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},I=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`delete-icon`,ref:t,icon:F}))});I.displayName=`DeleteIcon`;let L={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M8 2V14M2 8H14`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},R=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`increase-icon`,ref:t,icon:L}))});R.displayName=`IncreaseIcon`;let z={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M3 9C3.55228 9 4 8.55228 4 8C4 7.44772 3.55228 7 3 7C2.44772 7 2 7.44772 2 8C2 8.55228 2.44772 9 3 9Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8 9C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7C7.44772 7 7 7.44772 7 8C7 8.55228 7.44772 9 8 9Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M13 9C13.5523 9 14 8.55228 14 8C14 7.44772 13.5523 7 13 7C12.4477 7 12 7.44772 12 8C12 8.55228 12.4477 9 13 9Z`}}]},B=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`more-horizontal-icon`,ref:t,icon:z}))});B.displayName=`MoreHorizontalIcon`;let V={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M9.5 5L6.5 8L9.5 11`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},H=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`more-left-icon`,ref:t,icon:V}))});H.displayName=`MoreLeftIcon`;let U={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M6.41016 6.1311H6.76813`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M8.91626 6.1311H9.27424`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M3.90454 6.1311H4.26252`,strokeLinecap:`round`,strokeWidth:1.2}}]},W=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`reply-to-comment-icon`,ref:t,icon:U}))});W.displayName=`ReplyToCommentIcon`;let G={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M8 15C11.866 15 15 11.866 15 8C15 4.13401 11.866 1 8 1C4.13401 1 1 4.13401 1 8C1 11.866 4.13401 15 8 15ZM11.7245 6.42417C11.9588 6.18985 11.9588 5.80995 11.7245 5.57564C11.4901 5.34132 11.1102 5.34132 10.8759 5.57564L7.3002 9.15137L5.72446 7.57564C5.49014 7.34132 5.11025 7.34132 4.87593 7.57564C4.64162 7.80995 4.64162 8.18985 4.87593 8.42417L6.87593 10.4242C7.11025 10.6585 7.49014 10.6585 7.72446 10.4242L11.7245 6.42417Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},K=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`success-icon`,ref:t,icon:G}))});K.displayName=`SuccessIcon`;let q={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`g`,attrs:{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2},children:[{tag:`circle`,attrs:{cx:8,cy:8,r:6.4}},{tag:`path`,attrs:{d:`M5.3 8L7.3 10L11.3 6`}}]}]},J=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`success-outline-icon`,ref:t,icon:q}))});J.displayName=`SuccessOutlineIcon`;function Y(e,t){return(e==null?void 0:e.unitId)===t.unitId&&e.subUnitId===t.subUnitId&&e.commentId===t.id}function X(e,t,n){return e?e.unitId!==t||!n:!1}function ee(e,t,n){return e.id?e.id:[`thread-comment-panel-temp`,n,e.unitId,e.subUnitId,e.threadId,e.ref,e.dT,t].join(`-`)}let Z=e=>{let{dataStream:n,customRanges:r}=e,i=n.endsWith(`\r
2
2
  `)?n.length-2:n.length,a=[],o=0;return r==null||r.forEach(e=>{o<e.startIndex&&a.push({type:`text`,content:n.slice(o,e.startIndex)});let r=n.slice(e.startIndex,e.endIndex+1);e.rangeType===t.CustomRangeType.MENTION?a.push({type:`mention`,content:{label:r,id:e.rangeId}}):e.rangeType===t.CustomRangeType.HYPERLINK?a.push({type:`hyperlink`,content:r,range:e}):a.push({type:`text`,content:r}),o=e.endIndex+1}),a.push({type:`text`,content:n.slice(o,i)}),a},te=e=>{if(!e)return[];let{paragraphs:n=[]}=e;return n.map((r,i)=>{let a=i===0?0:n[i-1].startIndex+1,o=(0,t.getBodySlice)(e,a,r.startIndex);return Z(o)})},ne=e=>{let n=``,r=[];return e.forEach(e=>{switch(e.type){case`text`:n+=e.content;break;case`mention`:{let i=n.length;n+=e.content.label;let a=n.length-1;r.push({rangeId:e.content.id,rangeType:t.CustomRangeType.MENTION,startIndex:i,endIndex:a,properties:{},wholeEntity:!0});break}case`hyperlink`:{let t=n.length;n+=e.content,r.push({...e.range,startIndex:t,endIndex:n.length-1});break}}}),n+=`\r
3
3
  `,{textRuns:[],paragraphs:[{startIndex:n.length-2,paragraphId:(0,t.createParagraphId)(/* @__PURE__ */ new Set),paragraphStyle:{}}],sectionBreaks:[{sectionId:(0,t.createSectionId)(/* @__PURE__ */ new Set),startIndex:n.length-1}],dataStream:n,customRanges:r}};function Q(e,t,n){e.focus(t),n==null||n.focus()}function re(e){let{location:n,unitId:r,subUnitId:i,commentId:a,fallbackId:o}=e;return`${t.DOCS_COMMENT_EDITOR_UNIT_ID_KEY}_${n}_${r}_${i}_${a||o}`}function ie(e){return{id:`d`,body:e,documentStyle:{}}}let ae=(0,c.forwardRef)((e,r)=>{let{comment:a,onSave:o,id:u,onCancel:d,autoFocus:f,unitId:p,type:m,editorId:h,ActionRowComponent:g=s.ActionRow}=e,v=(0,n.useDependency)(t.ICommandService),y=(0,n.useDependency)(t.LocaleService),[b,x]=(0,c.useState)(!1),[S,C]=(0,c.useState)(!1),w=(0,c.useRef)(!1),T=(0,c.useRef)(!0),E=(0,n.useDependency)(i.IEditorService),D=(0,c.useRef)(null),O=m===t.UniverInstanceType.UNIVER_DOC?t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:p,[k,A]=(0,c.useState)(()=>{var e;return t.BuildTextUtils.transform.getPlainText((a==null||(e=a.text)==null?void 0:e.dataStream)??``)}),j=(0,c.useMemo)(()=>({keyCodes:[{keyCode:n.KeyCode.ENTER},{keyCode:n.KeyCode.BACKSPACE},{keyCode:n.KeyCode.DELETE}],handler:e=>{let r;switch(e){case n.KeyCode.ENTER:r=i.BreakLineCommand.id;break;case n.KeyCode.BACKSPACE:r=i.DeleteLeftCommand.id;break;case n.KeyCode.DELETE:r=i.DeleteRightCommand.id;break;default:return}Q(E,h,D.current),v.executeCommand(r).then(()=>{if(e!==n.KeyCode.ENTER&&T.current){var r;let e=((r=D.current)==null||(r=r.getDocumentData().body)==null?void 0:r.dataStream)??``;A(t.BuildTextUtils.transform.getPlainText(e))}})}}),[v,h,E]);return(0,c.useImperativeHandle)(r,()=>({reply(e){var n;if(!D.current)return;Q(E,h,D.current);let r=ie(e);(n=D.current)==null||n.setDocumentData(r,[{startOffset:r.body.dataStream.length-2,endOffset:r.body.dataStream.length-2,collapsed:!0}]),A(t.BuildTextUtils.transform.getPlainText(r.body.dataStream)),x(!0)}})),(0,c.useEffect)(()=>(T.current=!0,()=>{T.current=!1}),[]),(0,c.useEffect)(()=>{if(!f)return;let e=setTimeout(()=>{Q(E,h,D.current)});return()=>clearTimeout(e)},[f,h,E]),/* @__PURE__ */ (0,l.jsxs)(`div`,{onClick:e=>e.preventDefault(),children:[/* @__PURE__ */ (0,l.jsx)(`div`,{onMouseDown:()=>{Q(E,h,D.current),x(!0)},children:/* @__PURE__ */ (0,l.jsx)(i.RichTextEditor,{className:`univer-w-full`,editorRef:D,editorId:h,preserveHostFocus:!0,autoFocus:f,keyboardEventConfig:j,placeholder:y.t(`thread-comment-ui.editor.placeholder`),initialValue:(a==null?void 0:a.text)&&ie(a.text),onChange:e=>{var n;return A(t.BuildTextUtils.transform.getPlainText(((n=e.body)==null?void 0:n.dataStream)??``))},onFocusChange:e=>e&&x(e),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{E.focus(O)},30)}})}),b?/* @__PURE__ */ (0,l.jsxs)(g,{className:`univer-mt-3 univer-flex univer-flex-row univer-justify-end univer-gap-2`,children:[/* @__PURE__ */ (0,l.jsx)(s.Button,{type:`button`,onClick:()=>{let e=D.current;e==null||e.blur(),e==null||e.replaceText(``,!1),e==null||e.setSelectionRanges([],!1),A(``),d==null||d(),x(!1),v.executeCommand(_.id)},children:y.t(`thread-comment-ui.editor.cancel`)}),/* @__PURE__ */ (0,l.jsx)(s.Button,{type:`button`,variant:`primary`,disabled:!k||S,onClick:async()=>{let e=D.current;if(!e||w.current)return;let n=t.Tools.deepClone(e.getDocumentData().body);w.current=!0,C(!0);try{if(await(o==null?void 0:o({...a,text:n}))===!1||!T.current)return;e.blur(),e.replaceText(``,!1),e.setSelectionRanges([],!1),A(``),x(!1)}catch{return}finally{w.current=!1,T.current&&C(!1)}},children:y.t(u?`thread-comment-ui.editor.save`:`thread-comment-ui.editor.reply`)})]}):null]})}),$=/* @__PURE__ */ function(e){return e.CELL=`CELL`,e.PANEL=`PANEL`,e}({}),oe=`__mock__`,se=e=>{let{item:r,unitId:i,subUnitId:o,editing:s,onEditingChange:u,onReply:d,resolved:f,isRoot:p,onClose:m,onDeleteComment:h,onAfterDeleteComment:g,type:_,threadCommentEditorId:v,DropdownComponent:y,EditorComponent:b}=e,x=(0,n.useDependency)(t.ICommandService),S=(0,n.useDependency)(t.LocaleService),C=(0,n.useDependency)(t.RegionService),w=(0,n.useDependency)(t.UserManagerService);(0,n.useObservable)(w.userChange$);let T=w.getUser(r.personId),E=(0,n.useObservable)(w.currentUser$),D=(E==null?void 0:E.userID)===r.personId,O=r.id===oe,[k,A]=(0,c.useState)(!1),j=(0,n.useConfigValue)(n.UI_PLUGIN_CONFIG_KEY),M=j==null?void 0:j.avatarFallback,N=(0,n.useObservable)(C.currentRegion$,C.getCurrentRegion()),P=(0,n.useObservable)(S.direction$,S.getDirection());function F(e,n){let r=(0,t.dateKit)(e),i=t.LOCALE_META[n].tag;return r.formatIntl(i,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1,numberingSystem:`latn`})}let I=O?null:F(r.dT,N);return/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-relative univer-mb-3 univer-pl-[30px] rtl:univer-pl-0 rtl:univer-pr-[30px]`,onMouseLeave:()=>A(!1),onMouseEnter:()=>A(!0),children:[/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-absolute univer-left-0 univer-top-0 univer-size-6 univer-rounded-full univer-bg-cover univer-bg-center univer-bg-no-repeat rtl:univer-left-auto rtl:univer-right-0`,style:{backgroundImage:`url(${(T==null?void 0:T.avatar)||M})`}}),T||r.authorName?/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-mb-1 univer-flex univer-h-6 univer-items-center univer-justify-between`,children:[/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-text-sm univer-font-medium univer-leading-5`,children:(T==null?void 0:T.name)||r.authorName||` `}),/* @__PURE__ */ (0,l.jsxs)(`div`,{children:[O||f?null:k&&T?/* @__PURE__ */ (0,l.jsx)(`button`,{type:`button`,"aria-label":S.t(`thread-comment-ui.editor.reply`),className:`univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-border-0 univer-bg-transparent univer-p-0 univer-text-base univer-text-inherit hover:univer-bg-gray-50 rtl:univer-ml-0 rtl:univer-mr-1 dark:hover:!univer-bg-gray-800`,onClick:()=>d(T),children:/* @__PURE__ */ (0,l.jsx)(W,{})}):null,D&&!O&&!f?/* @__PURE__ */ (0,l.jsx)(y,{overlay:/* @__PURE__ */ (0,l.jsx)(`div`,{dir:P,className:`univer-rounded-lg`,children:/* @__PURE__ */ (0,l.jsxs)(`ul`,{className:`univer-m-0 univer-box-border univer-grid univer-list-none univer-p-1.5 univer-text-sm rtl:univer-text-right [&_button]:univer-block [&_button]:univer-w-full [&_button]:univer-cursor-pointer [&_button]:univer-rounded [&_button]:univer-border-0 [&_button]:univer-bg-transparent [&_button]:univer-px-2 [&_button]:univer-py-1.5 [&_button]:univer-text-left [&_button]:univer-text-inherit [&_button]:univer-transition-colors rtl:[&_button]:univer-text-right`,children:[/* @__PURE__ */ (0,l.jsx)(`li`,{children:/* @__PURE__ */ (0,l.jsx)(`button`,{type:`button`,className:`hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-600`,onClick:()=>u==null?void 0:u(!0),children:S.t(`thread-comment-ui.item.edit`)})}),/* @__PURE__ */ (0,l.jsx)(`li`,{children:/* @__PURE__ */ (0,l.jsx)(`button`,{type:`button`,className:`hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-600`,onClick:async()=>{if((h==null?void 0:h(r))!==!1)try{if(await x.executeCommand(p?a.DeleteCommentTreeCommand.id:a.DeleteCommentCommand.id,{unitId:i,subUnitId:o,commentId:r.id})){try{await(g==null?void 0:g(r))}catch{}p&&(m==null||m())}}catch{}},children:S.t(`thread-comment-ui.item.delete`)})})]})}),children:/* @__PURE__ */ (0,l.jsx)(`button`,{type:`button`,"aria-label":S.t(`thread-comment-ui.item.more`),className:`univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-border-0 univer-bg-transparent univer-p-0 univer-text-base univer-text-inherit hover:univer-bg-gray-50 rtl:univer-ml-0 rtl:univer-mr-1 dark:hover:!univer-bg-gray-800`,children:/* @__PURE__ */ (0,l.jsx)(B,{})})}):null]})]}):null,I&&/* @__PURE__ */ (0,l.jsx)(`time`,{className:`univer-mb-1 univer-block univer-text-xs/normal univer-text-gray-600 rtl:univer-text-right dark:!univer-text-gray-200`,children:/* @__PURE__ */ (0,l.jsx)(`bdo`,{dir:`ltr`,children:I})}),s?/* @__PURE__ */ (0,l.jsx)(b,{type:_,id:r.id,comment:r,onCancel:()=>u==null?void 0:u(!1),autoFocus:!0,unitId:i,subUnitId:o,editorId:v,onSave:async({text:e,attachments:t})=>{let n=await x.executeCommand(a.UpdateCommentCommand.id,{unitId:i,subUnitId:o,payload:{commentId:r.id,text:e,attachments:t}});return n&&(u==null||u(!1)),n}}):/* @__PURE__ */ (0,l.jsx)(`div`,{tabIndex:-1,className:`univer-select-text univer-text-sm univer-text-gray-900 dark:!univer-text-gray-0`,children:te(r.text).map((e,n)=>{var i;let a=0;return/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-break-words`,children:e.map(e=>{let n=a;switch(a+=e.type===`mention`?e.content.label.length:e.content.length,e.type){case`mention`:return/* @__PURE__ */ (0,l.jsxs)(`span`,{className:`univer-text-primary-600`,children:[e.content.label,` `]},n);case`hyperlink`:{var r;let i=(r=e.range.properties)==null?void 0:r.url;return(0,t.isSafeUrl)(i)?/* @__PURE__ */ (0,l.jsx)(`a`,{href:i,target:`_blank`,rel:`noopener noreferrer`,className:`univer-text-primary-600 univer-underline`,onClick:e=>e.stopPropagation(),children:e.content},n):e.content}default:return e.content}})},(i=r.text.paragraphs)==null||(i=i[n])==null?void 0:i.paragraphId)})})]})},ce=e=>{let{id:i,unitId:o,subUnitId:u,refStr:d,displayRef:f,showEdit:p=!0,onClick:m,showHighlight:h,onClose:g,getSubUnitName:v,location:y,autoFocus:b,onMouseEnter:x,onMouseLeave:S,onAddComment:C,onDeleteComment:w,onAfterDeleteComment:T,onResolve:E,type:D,style:O,full:k,DropdownComponent:A=s.Dropdown,EditorComponent:j=ae}=e,M=(0,n.useDependency)(a.ThreadCommentModel),[N,P]=(0,c.useState)(!1),[F,L]=(0,c.useState)(``),R=(0,c.useMemo)(()=>M.commentUpdate$.pipe((0,r.debounceTime)(16)),[M]),z=(0,n.useObservable)(()=>i?R.pipe((0,r.map)(()=>M.getCommentWithChildren(o,u,i)),(0,r.startWith)(M.getCommentWithChildren(o,u,i))):(0,r.of)(null),null,!1,[i,u,M,o,R]),B=(0,n.useDependency)(t.ICommandService),V=(0,n.useDependency)(t.LocaleService),H=(0,n.useDependency)(t.UserManagerService),U=z==null?void 0:z.root.resolved,W=(0,n.useObservable)(H.currentUser$),G=(0,c.useRef)(null),q=(0,c.useMemo)(()=>(0,t.generateRandomId)(6),[]),Y=[...z?[z.root]:[{id:oe,text:{dataStream:`
4
- \r`},personId:(W==null?void 0:W.userID)??``,ref:d??``,dT:``,unitId:o,subUnitId:u,threadId:``}],...(z==null?void 0:z.children)??[]],X=(0,c.useRef)(null),ee=(0,n.useEvent)(S),Z=async e=>{e.stopPropagation();try{if(!await B.executeCommand(a.ResolveCommentCommand.id,{unitId:o,subUnitId:u,commentId:i,resolved:!U}))return;await B.executeCommand(_.id,U?{unitId:o,subUnitId:u,commentId:i}:void 0),E==null||E(!U)}catch{}},te=async e=>{e.stopPropagation();let t=z==null?void 0:z.root;if(t&&(w==null?void 0:w(t))!==!1)try{if(await B.executeCommand(a.DeleteCommentTreeCommand.id,{unitId:o,subUnitId:u,commentId:i})){try{await(T==null?void 0:T(t))}catch{}await B.executeCommand(_.id),g==null||g()}}catch{}};(0,c.useEffect)(()=>ee,[ee]);let Q=v((z==null?void 0:z.root.subUnitId)??u),ie=p&&!F&&!U,$=`${f??d??(z==null?void 0:z.root.ref)??``}${Q?` · `:``}${Q}`,ce=V.t(U?`thread-comment-ui.item.markUnresolved`:`thread-comment-ui.item.markResolved`),le=V.t(`thread-comment-ui.item.delete`),ue=re({location:y,unitId:o,subUnitId:u,commentId:i,fallbackId:q});return/* @__PURE__ */ (0,l.jsxs)(`div`,{id:`${y}-${o}-${u}-${i}`,className:(0,s.clsx)(`univer-relative univer-box-border univer-rounded-md univer-bg-gray-0 univer-p-4 univer-text-gray-900 dark:!univer-bg-gray-900 dark:!univer-text-gray-0`,s.borderClassName,{"univer-w-[278px]":!k,"univer-w-full":k,"univer-shadow":!U&&(h||N||y===`CELL`)}),style:O,onClick:e=>{let t=e.currentTarget.ownerDocument.getSelection();t&&!t.isCollapsed&&t.anchorNode&&t.focusNode&&e.currentTarget.contains(t.anchorNode)&&e.currentTarget.contains(t.focusNode)||m==null||m()},onMouseEnter:()=>{x==null||x(),P(!0)},onMouseLeave:()=>{S==null||S(),P(!1)},children:[!U&&h&&/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-absolute univer-left-0 univer-right-0 univer-top-0 univer-h-1.5 univer-rounded-t-md univer-bg-yellow-400`}),/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-mb-4 univer-flex univer-flex-row univer-items-center univer-justify-between univer-text-sm univer-leading-5`,children:[/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-flex univer-flex-1 univer-flex-row univer-items-center univer-overflow-hidden`,children:[/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-mr-2 univer-h-3.5 univer-w-[3px] univer-flex-shrink-0 univer-flex-grow-0 univer-rounded-sm univer-bg-yellow-500 rtl:univer-ml-2 rtl:univer-mr-0`}),/* @__PURE__ */ (0,l.jsx)(s.Tooltip,{showIfEllipsis:!0,title:$,children:/* @__PURE__ */ (0,l.jsx)(`span`,{className:`univer-flex-1 univer-truncate`,children:$})})]}),!!z&&/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row`,children:[/* @__PURE__ */ (0,l.jsx)(s.Tooltip,{title:ce,children:/* @__PURE__ */ (0,l.jsx)(`button`,{type:`button`,"aria-label":ce,className:(0,s.clsx)(`univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-border-0 univer-bg-transparent univer-p-0 univer-text-base univer-text-inherit hover:univer-bg-gray-50 rtl:univer-ml-0 rtl:univer-mr-1 dark:hover:!univer-bg-gray-800`,{"univer-text-green-500":U}),onClick:Z,children:U?/* @__PURE__ */ (0,l.jsx)(K,{}):/* @__PURE__ */ (0,l.jsx)(J,{})})}),(W==null?void 0:W.userID)===z.root.personId?/* @__PURE__ */ (0,l.jsx)(s.Tooltip,{title:le,children:/* @__PURE__ */ (0,l.jsx)(`button`,{type:`button`,"aria-label":le,className:`univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-border-0 univer-bg-transparent univer-p-0 univer-text-base univer-text-inherit hover:univer-bg-gray-50 rtl:univer-ml-0 rtl:univer-mr-1 dark:hover:!univer-bg-gray-800`,onClick:te,children:/* @__PURE__ */ (0,l.jsx)(I,{})})}):null]})]}),/* @__PURE__ */ (0,l.jsx)(`div`,{ref:X,className:(0,s.clsx)(`univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden`,s.scrollbarClassName,y===`PANEL`&&`-univer-mx-4 univer-px-4`),children:Y.map(e=>/* @__PURE__ */ (0,l.jsx)(se,{unitId:o,subUnitId:u,item:e,isRoot:e.id===(z==null?void 0:z.root.id),editing:F===e.id,resolved:z==null?void 0:z.root.resolved,type:D,threadCommentEditorId:ue,DropdownComponent:A,EditorComponent:j,onClose:g,onEditingChange:t=>{L(t?e.id:``)},onReply:e=>{e&&requestAnimationFrame(()=>{var t;(t=G.current)==null||t.reply(ne([{type:`mention`,content:{id:e.userID,label:`@${e.name}`}},{type:`text`,content:` `}]))})},onDeleteComment:w,onAfterDeleteComment:T},e.id))}),ie&&/* @__PURE__ */ (0,l.jsx)(`div`,{children:/* @__PURE__ */ (0,l.jsx)(j,{ref:G,type:D,unitId:o,subUnitId:u,editorId:ue,onSave:async({text:e,attachments:n})=>{let r={text:e,attachments:n,dT:(0,a.getDT)(),id:(0,t.generateRandomId)(),ref:d,personId:(W==null?void 0:W.userID)??``,parentId:z==null?void 0:z.root.id,unitId:o,subUnitId:u,threadId:(z==null?void 0:z.root.threadId)??``};if(await(C==null?void 0:C(r))===!1)return z||g==null||g(),!0;let i=await B.executeCommand(a.AddCommentCommand.id,{unitId:o,subUnitId:u,comment:r});return i&&X.current&&(X.current.scrollTop=X.current.scrollHeight),i&&!z&&(g==null||g()),i},autoFocus:b||!z,onCancel:()=>{z||g==null||g()}},`${b}`)})]})},le=(0,c.forwardRef)((e,t)=>/* @__PURE__ */ (0,l.jsx)(ae,{...e,ref:t,ActionRowComponent:s.MobileActionRowGroup}));function ue(e){return/* @__PURE__ */ (0,l.jsx)(ce,{...e,DropdownComponent:s.MobileDropdown,EditorComponent:le})}function de({value:e,options:t=[],onChange:n}){return/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-flex univer-gap-1 univer-overflow-x-auto univer-rounded-xl univer-bg-gray-100 univer-p-1 dark:!univer-bg-gray-800`,children:t.flatMap(e=>e.options??[e]).map(t=>/* @__PURE__ */ (0,l.jsx)(`button`,{type:`button`,"aria-pressed":t.value===e,className:(0,s.clsx)(s.resetButtonClassName,`univer-h-10 univer-shrink-0 univer-rounded-lg univer-px-3 univer-text-sm univer-text-gray-700 active:univer-scale-95 dark:!univer-text-gray-200`,t.value===e&&`univer-bg-gray-0 univer-font-medium univer-text-primary-600 univer-shadow-sm dark:!univer-bg-gray-700 dark:!univer-text-primary-300`),onClick:()=>t.value!=null&&(n==null?void 0:n(t.value)),children:t.label},t.value))})}function fe({comment:e,displayRef:r}){let i=(0,n.useDependency)(t.LocaleService),a=(0,n.useDependency)(t.ICommandService);return/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-mt-2 univer-flex univer-min-h-12 univer-items-center univer-gap-2 univer-border-0 univer-border-b univer-border-solid univer-border-gray-200 univer-pb-2 dark:!univer-border-gray-700`,children:[/* @__PURE__ */ (0,l.jsx)(`button`,{type:`button`,"aria-label":i.t(`thread-comment-ui.mobile.back`),className:`
5
- ${s.resetButtonClassName}
6
- univer-flex univer-size-12 univer-shrink-0 univer-items-center univer-justify-center univer-rounded-xl
7
- univer-text-2xl univer-text-gray-700
8
- active:univer-bg-gray-100
9
- dark:!univer-text-gray-200
10
- dark:active:!univer-bg-gray-700
11
- `,onClick:()=>a.executeCommand(_.id),children:/* @__PURE__ */ (0,l.jsx)(H,{})}),/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-min-w-0 univer-flex-1`,children:[/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-truncate univer-text-base univer-font-semibold univer-text-gray-900 dark:!univer-text-gray-0`,children:i.t(`thread-comment-ui.panel.title`)}),e.ref&&/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-truncate univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400`,children:r??e.ref})]})]})}function pe({onAdd:e}){let r=(0,n.useDependency)(t.LocaleService);return/* @__PURE__ */ (0,l.jsx)(s.MobileActionRowGroup,{className:`univer-mt-3`,children:/* @__PURE__ */ (0,l.jsxs)(s.Button,{className:`univer-w-full`,onClick:e,children:[/* @__PURE__ */ (0,l.jsx)(R,{className:`univer-mr-1.5`}),r.t(`thread-comment-ui.panel.addComment`)]})})}function me(e){let{unitId:r,subUnitId$:i,type:o,onAdd:u,getSubUnitName:d,onResolve:f,sortComments:p,onItemLeave:m,onItemEnter:h,disableAdd:v,tempComment:y,onAddComment:b,onDeleteComment:x,onAfterDeleteComment:S,showComments:C,formatRef:w,onTempCommentClose:T,autoFocusActiveComment:E=!1}=e,[D,O]=(0,c.useState)(`all`),[k,A]=(0,c.useState)(`all`),j=(0,n.useDependency)(t.LocaleService),M=(0,n.useDependency)(t.UserManagerService),N=(0,n.useDependency)(a.ThreadCommentModel),P=(0,n.useDependency)(g),F=(0,n.useDependency)(t.ICommandService),I=(0,n.useObservable)(P.activeCommentId$);(0,n.useObservable)(N.commentUpdate$);let L=(0,n.useObservable)(i),R=(0,n.useObservable)(M.currentUser$),z=(0,c.useRef)(!0),B=`PANEL`,V=N.getUnit(r),H=(y==null?void 0:y.unitId)===r?y:null,U=X(I,r,I?!!(N.getComment(I.unitId,I.subUnitId,I.commentId)||H&&Y(I,H)):!1),W=(0,c.useMemo)(()=>{let e=D===`all`&&o!==t.UniverInstanceType.UNIVER_SLIDE?V:V.filter(e=>e.subUnitId===L),n=p??(e=>e),r=e.map(e=>({...e.root,children:e.children??[],users:e.relativeUsers}));if(!C)return n(r);let i=new Map(r.map(e=>[e.id,e]));return[...C,``].map(e=>i.get(e)).filter(Boolean)},[C,p,L,o,D,V]),G=(0,c.useMemo)(()=>[...W.filter(e=>!e.resolved),...W.filter(e=>e.resolved)],[W]),K=(0,c.useMemo)(()=>k===`resolved`?G.filter(e=>e.resolved):k===`unsolved`?G.filter(e=>!e.resolved):k===`concern_me`&&R!=null&&R.userID?G.filter(e=>e.users.has(R.userID)):G,[G,R==null?void 0:R.userID,k]),q=H?[H,...K]:K,J=I?q.find(e=>Y(I,e)):void 0,Z=J?[J]:q,te=Z.filter(e=>!e.resolved),ne=Z.filter(e=>e.resolved),Q=k!==`all`||D!==`all`,re=[{value:`current`,label:j.t(`thread-comment-ui.filter.sheet.current`)},{value:`all`,label:j.t(`thread-comment-ui.filter.sheet.all`)}],ie=[{value:`all`,label:j.t(`thread-comment-ui.filter.status.all`)},{value:`resolved`,label:j.t(`thread-comment-ui.filter.status.resolved`)},{value:`unsolved`,label:j.t(`thread-comment-ui.filter.status.unsolved`)},{value:`concern_me`,label:j.t(`thread-comment-ui.filter.status.concernMe`)}],ae=()=>{A(`all`),O(`all`)};(0,c.useEffect)(()=>{U&&P.setActiveComment(void 0)},[P,U]),(0,c.useEffect)(()=>{y&&(y.unitId!==r||L&&y.subUnitId!==L)&&(T==null||T())},[T,L,y,r]),(0,c.useEffect)(()=>{if(!I)return;let e=e=>{let t=P.activeCommentId,n=e.target;if(e.button!==0||!t||!(n instanceof Element))return;let r=document.getElementById(`${B}-${t.unitId}-${t.subUnitId}-${t.commentId}`);r!=null&&r.contains(n)||n.closest(`button, input, textarea, select, a, [contenteditable="true"], [role="menu"], [role="menuitem"], [role="option"], [role="listbox"], [role="combobox"], [role="separator"]`)||(F.executeCommand(_.id),H&&Y(t,H)&&(T==null||T()))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[I,F,B,T,P,H]),(0,c.useEffect)(()=>{var e;if(!I)return;if(!z.current){z.current=!0;return}let{unitId:t,subUnitId:n,commentId:r}=I;(e=document.getElementById(`${B}-${t}-${n}-${r}`))==null||e.scrollIntoView({block:`center`})},[I,B]);let $=e=>(t,n)=>/* @__PURE__ */ (0,l.jsx)(ue,{full:!0,location:B,getSubUnitName:d,id:t.id,unitId:t.unitId,subUnitId:t.subUnitId,refStr:t.ref,displayRef:w==null?void 0:w(t),type:o,showEdit:!t.id||Y(I,t),showHighlight:Y(I,t),autoFocus:E&&Y(I,t),onClick:()=>{z.current=!1,t.resolved?F.executeCommand(_.id):F.executeCommand(_.id,{unitId:t.unitId,subUnitId:t.subUnitId,commentId:t.id,temp:!1})},onMouseEnter:()=>{P.setHoveredComment({unitId:t.unitId,subUnitId:t.subUnitId,commentId:t.id,trigger:`panel-hover`}),h==null||h(t)},onMouseLeave:()=>{Y(P.hoveredCommentId,t)&&P.setHoveredComment(void 0),m==null||m(t)},onAddComment:b,onDeleteComment:x,onAfterDeleteComment:S,onResolve:e=>f==null?void 0:f(t.id,e),onClose:t.id?void 0:T},ee(t,n,e));return/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-flex univer-min-h-full univer-flex-col univer-pb-3`,children:[J&&/* @__PURE__ */ (0,l.jsx)(fe,{comment:J,displayRef:w==null?void 0:w(J)}),!J&&/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-flex-col univer-gap-2`,children:[o===t.UniverInstanceType.UNIVER_SHEET&&/* @__PURE__ */ (0,l.jsx)(de,{value:D,options:re,onChange:O}),/* @__PURE__ */ (0,l.jsx)(de,{value:k,options:ie,onChange:A})]}),!J&&!v&&!H&&/* @__PURE__ */ (0,l.jsx)(pe,{onAdd:u}),Z.length===0?/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:[j.t(`thread-comment-ui.panel.empty`),Q?/* @__PURE__ */ (0,l.jsx)(s.MobileActionRowGroup,{className:`univer-mt-2 univer-flex univer-flex-row`,children:/* @__PURE__ */ (0,l.jsx)(s.Button,{onClick:ae,children:j.t(`thread-comment-ui.panel.reset`)})}):null]}):/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-flex-col univer-gap-3`,children:[te.map($(`unsolved`)),ne.length>0&&/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-text-xs`,children:j.t(`thread-comment-ui.panel.solved`)}),ne.map($(`solved`))]})]})}e.MobileThreadCommentPanel=me,e.MobileThreadCommentTree=ue,e.SetActiveCommentOperation=_,e.ThreadCommentCanvasOverlay=D,Object.defineProperty(e,"ThreadCommentDraftService",{enumerable:!0,get:function(){return S}}),e.ThreadCommentPanel=e=>{let{unitId:r,subUnitId$:i,type:o,onAdd:u,getSubUnitName:d,onResolve:f,sortComments:p,onItemLeave:m,onItemEnter:h,disableAdd:v,tempComment:y,onAddComment:b,onDeleteComment:x,onAfterDeleteComment:S,showComments:C,formatRef:w,onTempCommentClose:T,autoFocusActiveComment:E=!1}=e,[D,O]=(0,c.useState)(`all`),[k,A]=(0,c.useState)(`all`),j=(0,n.useDependency)(t.LocaleService),M=(0,n.useDependency)(t.UserManagerService),N=(0,n.useDependency)(a.ThreadCommentModel),P=(0,n.useDependency)(g),F=(0,n.useObservable)(P.activeCommentId$);(0,n.useObservable)(N.commentUpdate$);let I=N.getUnit(r),L=(y==null?void 0:y.unitId)===r?y:null,z=X(F,r,F?!!(N.getComment(F.unitId,F.subUnitId,F.commentId)||L&&Y(F,L)):!1),B=(0,n.useDependency)(t.ICommandService),V=(0,n.useObservable)(i),H=(0,c.useRef)(!0),U=`PANEL`,W=(0,n.useObservable)(M.currentUser$),G=(0,c.useMemo)(()=>{let e=D===`all`&&o!==t.UniverInstanceType.UNIVER_SLIDE?I:I.filter(e=>e.subUnitId===V),n=p??(e=>e),r=e.map(e=>({...e.root,children:e.children??[],users:e.relativeUsers}));if(C){let e=/* @__PURE__ */ new Map;return r.forEach(t=>{e.set(t.id,t)}),[...C,``].map(t=>e.get(t)).filter(Boolean)}return n(r)},[C,D,I,p,V,o]),K=(0,c.useMemo)(()=>[...G.filter(e=>!e.resolved),...G.filter(e=>e.resolved)],[G]),q=(0,c.useMemo)(()=>k===`resolved`?K.filter(e=>e.resolved):k===`unsolved`?K.filter(e=>!e.resolved):k===`concern_me`&&W!=null&&W.userID?K.filter(e=>e==null?void 0:e.users.has(W.userID)):K,[K,W==null?void 0:W.userID,k]),J=L?[L,...q]:q,Z=J.filter(e=>!e.resolved),te=J.filter(e=>e.resolved),ne=k!==`all`||D!==`all`,Q=()=>{A(`all`),O(`all`)};(0,c.useEffect)(()=>{z&&P.setActiveComment(void 0)},[P,z]),(0,c.useEffect)(()=>{y&&(y.unitId!==r||V&&y.subUnitId!==V)&&(T==null||T())},[T,V,y,r]),(0,c.useEffect)(()=>{if(!F)return;let e=e=>{let t=P.activeCommentId,n=e.target;e.button===0&&t&&n instanceof Element&&(Object.values($).some(e=>{let r=document.getElementById(`${e}-${t.unitId}-${t.subUnitId}-${t.commentId}`);return r==null?void 0:r.contains(n)})||n.closest(`button, input, textarea, select, a, [contenteditable="true"], [role="menu"], [role="menuitem"], [role="option"], [role="listbox"], [role="combobox"], [role="separator"]`)||(B.executeCommand(_.id),L&&Y(t,L)&&(T==null||T())))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[F,B,T,P,L]),(0,c.useEffect)(()=>{var e;if(!F)return;if(!H.current){H.current=!0;return}let{unitId:t,subUnitId:n,commentId:r}=F,i=`${U}-${t}-${n}-${r}`;(e=document.getElementById(i))==null||e.scrollIntoView({block:`center`})},[F,U]);let re=e=>(t,n)=>/* @__PURE__ */ (0,l.jsx)(ce,{full:!0,location:U,getSubUnitName:d,id:t.id,unitId:t.unitId,subUnitId:t.subUnitId,refStr:t.ref,displayRef:w==null?void 0:w(t),type:o,showEdit:!t.id||Y(F,t),showHighlight:Y(F,t),autoFocus:E&&Y(F,t),onClick:()=>{H.current=!1,t.resolved?B.executeCommand(_.id):B.executeCommand(_.id,{unitId:t.unitId,subUnitId:t.subUnitId,commentId:t.id,temp:!1})},onMouseEnter:()=>{P.setHoveredComment({unitId:t.unitId,subUnitId:t.subUnitId,commentId:t.id,trigger:`panel-hover`}),h==null||h(t)},onMouseLeave:()=>{Y(P.hoveredCommentId,t)&&P.setHoveredComment(void 0),m==null||m(t)},onAddComment:b,onDeleteComment:x,onAfterDeleteComment:S,onResolve:e=>f==null?void 0:f(t.id,e),onClose:t.id?void 0:T},ee(t,n,e));return/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-flex univer-min-h-full univer-flex-col univer-pb-3`,children:[/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-flex-row univer-justify-between`,children:[o===t.UniverInstanceType.UNIVER_SHEET?/* @__PURE__ */ (0,l.jsx)(s.Select,{borderless:!0,value:D,options:[{value:`current`,label:j.t(`thread-comment-ui.filter.sheet.current`)},{value:`all`,label:j.t(`thread-comment-ui.filter.sheet.all`)}],onChange:O}):null,/* @__PURE__ */ (0,l.jsx)(s.Select,{borderless:!0,value:k,options:[{value:`all`,label:j.t(`thread-comment-ui.filter.status.all`)},{value:`resolved`,label:j.t(`thread-comment-ui.filter.status.resolved`)},{value:`unsolved`,label:j.t(`thread-comment-ui.filter.status.unsolved`)},{value:`concern_me`,label:j.t(`thread-comment-ui.filter.status.concernMe`)}],onChange:A})]}),J.length===0?/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:[j.t(`thread-comment-ui.panel.empty`),ne?/* @__PURE__ */ (0,l.jsx)(s.ActionRow,{className:`univer-mt-2 univer-flex univer-flex-row`,children:/* @__PURE__ */ (0,l.jsx)(s.Button,{onClick:Q,children:j.t(`thread-comment-ui.panel.reset`)})}):v?null:/* @__PURE__ */ (0,l.jsx)(s.ActionRow,{className:`univer-mt-2 univer-flex univer-flex-row`,children:/* @__PURE__ */ (0,l.jsxs)(s.Button,{onClick:u,children:[/* @__PURE__ */ (0,l.jsx)(R,{className:`univer-mr-1.5`}),j.t(`thread-comment-ui.panel.addComment`)]})})]}):/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-flex-col univer-gap-3`,children:[Z.map(re(`unsolved`)),te.length>0&&/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-text-xs`,children:j.t(`thread-comment-ui.panel.solved`)}),te.map(re(`solved`))]})]})},Object.defineProperty(e,"ThreadCommentPanelService",{enumerable:!0,get:function(){return g}}),e.ThreadCommentTree=ce,e.ThreadCommentTreeLocation=$,Object.defineProperty(e,"UniverThreadCommentMobileUIPlugin",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"UniverThreadCommentUIPlugin",{enumerable:!0,get:function(){return T}})});
4
+ \r`},personId:(W==null?void 0:W.userID)??``,ref:d??``,dT:``,unitId:o,subUnitId:u,threadId:``}],...(z==null?void 0:z.children)??[]],X=(0,c.useRef)(null),ee=(0,n.useEvent)(S),Z=async e=>{e.stopPropagation();try{if(!await B.executeCommand(a.ResolveCommentCommand.id,{unitId:o,subUnitId:u,commentId:i,resolved:!U}))return;await B.executeCommand(_.id,U?{unitId:o,subUnitId:u,commentId:i}:void 0),E==null||E(!U)}catch{}},te=async e=>{e.stopPropagation();let t=z==null?void 0:z.root;if(t&&(w==null?void 0:w(t))!==!1)try{if(await B.executeCommand(a.DeleteCommentTreeCommand.id,{unitId:o,subUnitId:u,commentId:i})){try{await(T==null?void 0:T(t))}catch{}await B.executeCommand(_.id),g==null||g()}}catch{}};(0,c.useEffect)(()=>ee,[ee]);let Q=v((z==null?void 0:z.root.subUnitId)??u),ie=p&&!F&&!U,$=`${f??d??(z==null?void 0:z.root.ref)??``}${Q?` · `:``}${Q}`,ce=V.t(U?`thread-comment-ui.item.markUnresolved`:`thread-comment-ui.item.markResolved`),le=V.t(`thread-comment-ui.item.delete`),ue=re({location:y,unitId:o,subUnitId:u,commentId:i,fallbackId:q});return/* @__PURE__ */ (0,l.jsxs)(`div`,{id:`${y}-${o}-${u}-${i}`,className:(0,s.clsx)(`univer-relative univer-box-border univer-rounded-md univer-bg-gray-0 univer-p-4 univer-text-gray-900 dark:!univer-bg-gray-900 dark:!univer-text-gray-0`,s.borderClassName,{"univer-w-[278px]":!k,"univer-w-full":k,"univer-shadow":!U&&(h||N||y===`CELL`)}),style:O,onClick:e=>{let t=e.currentTarget.ownerDocument.getSelection();t&&!t.isCollapsed&&t.anchorNode&&t.focusNode&&e.currentTarget.contains(t.anchorNode)&&e.currentTarget.contains(t.focusNode)||m==null||m()},onMouseEnter:()=>{x==null||x(),P(!0)},onMouseLeave:()=>{S==null||S(),P(!1)},children:[!U&&h&&/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-absolute univer-left-0 univer-right-0 univer-top-0 univer-h-1.5 univer-rounded-t-md univer-bg-yellow-400`}),/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-mb-4 univer-flex univer-flex-row univer-items-center univer-justify-between univer-text-sm univer-leading-5`,children:[/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-flex univer-flex-1 univer-flex-row univer-items-center univer-overflow-hidden`,children:[/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-mr-2 univer-h-3.5 univer-w-[3px] univer-flex-shrink-0 univer-flex-grow-0 univer-rounded-sm univer-bg-yellow-500 rtl:univer-ml-2 rtl:univer-mr-0`}),/* @__PURE__ */ (0,l.jsx)(s.Tooltip,{showIfEllipsis:!0,title:$,children:/* @__PURE__ */ (0,l.jsx)(`span`,{className:`univer-flex-1 univer-truncate`,children:$})})]}),!!z&&/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row`,children:[/* @__PURE__ */ (0,l.jsx)(s.Tooltip,{title:ce,children:/* @__PURE__ */ (0,l.jsx)(`button`,{type:`button`,"aria-label":ce,className:(0,s.clsx)(`univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-border-0 univer-bg-transparent univer-p-0 univer-text-base univer-text-inherit hover:univer-bg-gray-50 rtl:univer-ml-0 rtl:univer-mr-1 dark:hover:!univer-bg-gray-800`,{"univer-text-green-500":U}),onClick:Z,children:U?/* @__PURE__ */ (0,l.jsx)(K,{}):/* @__PURE__ */ (0,l.jsx)(J,{})})}),(W==null?void 0:W.userID)===z.root.personId?/* @__PURE__ */ (0,l.jsx)(s.Tooltip,{title:le,children:/* @__PURE__ */ (0,l.jsx)(`button`,{type:`button`,"aria-label":le,className:`univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-border-0 univer-bg-transparent univer-p-0 univer-text-base univer-text-inherit hover:univer-bg-gray-50 rtl:univer-ml-0 rtl:univer-mr-1 dark:hover:!univer-bg-gray-800`,onClick:te,children:/* @__PURE__ */ (0,l.jsx)(I,{})})}):null]})]}),/* @__PURE__ */ (0,l.jsx)(`div`,{ref:X,className:(0,s.clsx)(`univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden`,s.scrollbarClassName,y===`PANEL`&&`-univer-mx-4 univer-px-4`),children:Y.map(e=>/* @__PURE__ */ (0,l.jsx)(se,{unitId:o,subUnitId:u,item:e,isRoot:e.id===(z==null?void 0:z.root.id),editing:F===e.id,resolved:z==null?void 0:z.root.resolved,type:D,threadCommentEditorId:ue,DropdownComponent:A,EditorComponent:j,onClose:g,onEditingChange:t=>{L(t?e.id:``)},onReply:e=>{e&&requestAnimationFrame(()=>{var t;(t=G.current)==null||t.reply(ne([{type:`mention`,content:{id:e.userID,label:`@${e.name}`}},{type:`text`,content:` `}]))})},onDeleteComment:w,onAfterDeleteComment:T},e.id))}),ie&&/* @__PURE__ */ (0,l.jsx)(`div`,{children:/* @__PURE__ */ (0,l.jsx)(j,{ref:G,type:D,unitId:o,subUnitId:u,editorId:ue,onSave:async({text:e,attachments:n})=>{let r={text:e,attachments:n,dT:(0,a.getDT)(),id:(0,t.generateRandomId)(),ref:d,personId:(W==null?void 0:W.userID)??``,parentId:z==null?void 0:z.root.id,unitId:o,subUnitId:u,threadId:(z==null?void 0:z.root.threadId)??``};if(await(C==null?void 0:C(r))===!1)return z||g==null||g(),!0;let i=await B.executeCommand(a.AddCommentCommand.id,{unitId:o,subUnitId:u,comment:r});return i&&X.current&&(X.current.scrollTop=X.current.scrollHeight),i&&!z&&(g==null||g()),i},autoFocus:b||!z,onCancel:()=>{z||g==null||g()}},`${b}`)})]})},le=(0,c.forwardRef)((e,t)=>/* @__PURE__ */ (0,l.jsx)(ae,{...e,ref:t,ActionRowComponent:s.MobileActionRowGroup}));function ue(e){return/* @__PURE__ */ (0,l.jsx)(ce,{...e,DropdownComponent:s.MobileDropdown,EditorComponent:le})}function de({value:e,options:t=[],onChange:n}){return/* @__PURE__ */ (0,l.jsx)(s.Segmented,{className:`univer-w-full`,value:e,items:t.flatMap(e=>e.options??[e]).filter(e=>e.value!=null).map(e=>({label:e.label,value:e.value,disabled:e.disabled})),onChange:n})}function fe({comment:e,displayRef:r}){let i=(0,n.useDependency)(t.LocaleService),a=(0,n.useDependency)(t.ICommandService);return/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-mt-2 univer-flex univer-min-h-12 univer-items-center univer-gap-2 univer-border-0 univer-border-b univer-border-solid univer-border-gray-200 univer-pb-2 dark:!univer-border-gray-700`,children:[/* @__PURE__ */ (0,l.jsx)(s.Button,{size:`icon`,variant:`text`,"aria-label":i.t(`thread-comment-ui.mobile.back`),onClick:()=>a.executeCommand(_.id),children:/* @__PURE__ */ (0,l.jsx)(H,{})}),/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-min-w-0 univer-flex-1`,children:[/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-truncate univer-text-base univer-font-semibold univer-text-gray-900 dark:!univer-text-gray-0`,children:i.t(`thread-comment-ui.panel.title`)}),e.ref&&/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-truncate univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400`,children:r??e.ref})]})]})}function pe({onAdd:e}){let r=(0,n.useDependency)(t.LocaleService);return/* @__PURE__ */ (0,l.jsx)(s.MobileActionRowGroup,{className:`univer-mt-3`,children:/* @__PURE__ */ (0,l.jsxs)(s.Button,{className:`univer-w-full`,onClick:e,size:`middle`,children:[/* @__PURE__ */ (0,l.jsx)(R,{className:`univer-mr-1.5`}),r.t(`thread-comment-ui.panel.addComment`)]})})}function me(e){let{unitId:r,subUnitId$:i,type:o,onAdd:u,getSubUnitName:d,onResolve:f,sortComments:p,onItemLeave:m,onItemEnter:h,disableAdd:v,tempComment:y,onAddComment:b,onDeleteComment:x,onAfterDeleteComment:S,showComments:C,formatRef:w,onTempCommentClose:T,autoFocusActiveComment:E=!1}=e,[D,O]=(0,c.useState)(`all`),[k,A]=(0,c.useState)(`all`),j=(0,n.useDependency)(t.LocaleService),M=(0,n.useDependency)(t.UserManagerService),N=(0,n.useDependency)(a.ThreadCommentModel),P=(0,n.useDependency)(g),F=(0,n.useDependency)(t.ICommandService),I=(0,n.useObservable)(P.activeCommentId$);(0,n.useObservable)(N.commentUpdate$);let L=(0,n.useObservable)(i),R=(0,n.useObservable)(M.currentUser$),z=(0,c.useRef)(!0),B=`PANEL`,V=N.getUnit(r),H=(y==null?void 0:y.unitId)===r?y:null,U=X(I,r,I?!!(N.getComment(I.unitId,I.subUnitId,I.commentId)||H&&Y(I,H)):!1),W=(0,c.useMemo)(()=>{let e=D===`all`&&o!==t.UniverInstanceType.UNIVER_SLIDE?V:V.filter(e=>e.subUnitId===L),n=p??(e=>e),r=e.map(e=>({...e.root,children:e.children??[],users:e.relativeUsers}));if(!C)return n(r);let i=new Map(r.map(e=>[e.id,e]));return[...C,``].map(e=>i.get(e)).filter(Boolean)},[C,p,L,o,D,V]),G=(0,c.useMemo)(()=>[...W.filter(e=>!e.resolved),...W.filter(e=>e.resolved)],[W]),K=(0,c.useMemo)(()=>k===`resolved`?G.filter(e=>e.resolved):k===`unsolved`?G.filter(e=>!e.resolved):k===`concern_me`&&R!=null&&R.userID?G.filter(e=>e.users.has(R.userID)):G,[G,R==null?void 0:R.userID,k]),q=H?[H,...K]:K,J=I?q.find(e=>Y(I,e)):void 0,Z=J?[J]:q,te=Z.filter(e=>!e.resolved),ne=Z.filter(e=>e.resolved),Q=k!==`all`||D!==`all`,re=[{value:`current`,label:j.t(`thread-comment-ui.filter.sheet.current`)},{value:`all`,label:j.t(`thread-comment-ui.filter.sheet.all`)}],ie=[{value:`all`,label:j.t(`thread-comment-ui.filter.status.all`)},{value:`resolved`,label:j.t(`thread-comment-ui.filter.status.resolved`)},{value:`unsolved`,label:j.t(`thread-comment-ui.filter.status.unsolved`)},{value:`concern_me`,label:j.t(`thread-comment-ui.filter.status.concernMe`)}],ae=()=>{A(`all`),O(`all`)};(0,c.useEffect)(()=>{U&&P.setActiveComment(void 0)},[P,U]),(0,c.useEffect)(()=>{y&&(y.unitId!==r||L&&y.subUnitId!==L)&&(T==null||T())},[T,L,y,r]),(0,c.useEffect)(()=>{if(!I)return;let e=e=>{let t=P.activeCommentId,n=e.target;if(e.button!==0||!t||!(n instanceof Element))return;let r=document.getElementById(`${B}-${t.unitId}-${t.subUnitId}-${t.commentId}`);r!=null&&r.contains(n)||n.closest(`button, input, textarea, select, a, [contenteditable="true"], [role="menu"], [role="menuitem"], [role="option"], [role="listbox"], [role="combobox"], [role="separator"]`)||(F.executeCommand(_.id),H&&Y(t,H)&&(T==null||T()))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[I,F,B,T,P,H]),(0,c.useEffect)(()=>{var e;if(!I)return;if(!z.current){z.current=!0;return}let{unitId:t,subUnitId:n,commentId:r}=I;(e=document.getElementById(`${B}-${t}-${n}-${r}`))==null||e.scrollIntoView({block:`center`})},[I,B]);let $=e=>(t,n)=>/* @__PURE__ */ (0,l.jsx)(ue,{full:!0,location:B,getSubUnitName:d,id:t.id,unitId:t.unitId,subUnitId:t.subUnitId,refStr:t.ref,displayRef:w==null?void 0:w(t),type:o,showEdit:!t.id||Y(I,t),showHighlight:Y(I,t),autoFocus:E&&Y(I,t),onClick:()=>{z.current=!1,t.resolved?F.executeCommand(_.id):F.executeCommand(_.id,{unitId:t.unitId,subUnitId:t.subUnitId,commentId:t.id,temp:!1})},onMouseEnter:()=>{P.setHoveredComment({unitId:t.unitId,subUnitId:t.subUnitId,commentId:t.id,trigger:`panel-hover`}),h==null||h(t)},onMouseLeave:()=>{Y(P.hoveredCommentId,t)&&P.setHoveredComment(void 0),m==null||m(t)},onAddComment:b,onDeleteComment:x,onAfterDeleteComment:S,onResolve:e=>f==null?void 0:f(t.id,e),onClose:t.id?void 0:T},ee(t,n,e));return/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-box-border univer-flex univer-min-h-full univer-flex-col univer-pb-3`,children:[J&&/* @__PURE__ */ (0,l.jsx)(fe,{comment:J,displayRef:w==null?void 0:w(J)}),!J&&/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-flex-col univer-gap-2`,children:[o===t.UniverInstanceType.UNIVER_SHEET&&/* @__PURE__ */ (0,l.jsx)(de,{value:D,options:re,onChange:O}),/* @__PURE__ */ (0,l.jsx)(de,{value:k,options:ie,onChange:A})]}),!J&&!v&&!H&&/* @__PURE__ */ (0,l.jsx)(pe,{onAdd:u}),Z.length===0?/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:[j.t(`thread-comment-ui.panel.empty`),Q?/* @__PURE__ */ (0,l.jsx)(s.MobileActionRowGroup,{className:`univer-mt-2 univer-flex univer-flex-row`,children:/* @__PURE__ */ (0,l.jsx)(s.Button,{onClick:ae,size:`middle`,children:j.t(`thread-comment-ui.panel.reset`)})}):null]}):/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-flex-col univer-gap-3`,children:[te.map($(`unsolved`)),ne.length>0&&/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-text-xs`,children:j.t(`thread-comment-ui.panel.solved`)}),ne.map($(`solved`))]})]})}e.MobileThreadCommentPanel=me,e.MobileThreadCommentTree=ue,e.SetActiveCommentOperation=_,e.ThreadCommentCanvasOverlay=D,Object.defineProperty(e,"ThreadCommentDraftService",{enumerable:!0,get:function(){return S}}),e.ThreadCommentPanel=e=>{let{unitId:r,subUnitId$:i,type:o,onAdd:u,getSubUnitName:d,onResolve:f,sortComments:p,onItemLeave:m,onItemEnter:h,disableAdd:v,tempComment:y,onAddComment:b,onDeleteComment:x,onAfterDeleteComment:S,showComments:C,formatRef:w,onTempCommentClose:T,autoFocusActiveComment:E=!1}=e,[D,O]=(0,c.useState)(`all`),[k,A]=(0,c.useState)(`all`),j=(0,n.useDependency)(t.LocaleService),M=(0,n.useDependency)(t.UserManagerService),N=(0,n.useDependency)(a.ThreadCommentModel),P=(0,n.useDependency)(g),F=(0,n.useObservable)(P.activeCommentId$);(0,n.useObservable)(N.commentUpdate$);let I=N.getUnit(r),L=(y==null?void 0:y.unitId)===r?y:null,z=X(F,r,F?!!(N.getComment(F.unitId,F.subUnitId,F.commentId)||L&&Y(F,L)):!1),B=(0,n.useDependency)(t.ICommandService),V=(0,n.useObservable)(i),H=(0,c.useRef)(!0),U=`PANEL`,W=(0,n.useObservable)(M.currentUser$),G=(0,c.useMemo)(()=>{let e=D===`all`&&o!==t.UniverInstanceType.UNIVER_SLIDE?I:I.filter(e=>e.subUnitId===V),n=p??(e=>e),r=e.map(e=>({...e.root,children:e.children??[],users:e.relativeUsers}));if(C){let e=/* @__PURE__ */ new Map;return r.forEach(t=>{e.set(t.id,t)}),[...C,``].map(t=>e.get(t)).filter(Boolean)}return n(r)},[C,D,I,p,V,o]),K=(0,c.useMemo)(()=>[...G.filter(e=>!e.resolved),...G.filter(e=>e.resolved)],[G]),q=(0,c.useMemo)(()=>k===`resolved`?K.filter(e=>e.resolved):k===`unsolved`?K.filter(e=>!e.resolved):k===`concern_me`&&W!=null&&W.userID?K.filter(e=>e==null?void 0:e.users.has(W.userID)):K,[K,W==null?void 0:W.userID,k]),J=L?[L,...q]:q,Z=J.filter(e=>!e.resolved),te=J.filter(e=>e.resolved),ne=k!==`all`||D!==`all`,Q=()=>{A(`all`),O(`all`)};(0,c.useEffect)(()=>{z&&P.setActiveComment(void 0)},[P,z]),(0,c.useEffect)(()=>{y&&(y.unitId!==r||V&&y.subUnitId!==V)&&(T==null||T())},[T,V,y,r]),(0,c.useEffect)(()=>{if(!F)return;let e=e=>{let t=P.activeCommentId,n=e.target;e.button===0&&t&&n instanceof Element&&(Object.values($).some(e=>{let r=document.getElementById(`${e}-${t.unitId}-${t.subUnitId}-${t.commentId}`);return r==null?void 0:r.contains(n)})||n.closest(`button, input, textarea, select, a, [contenteditable="true"], [role="menu"], [role="menuitem"], [role="option"], [role="listbox"], [role="combobox"], [role="separator"]`)||(B.executeCommand(_.id),L&&Y(t,L)&&(T==null||T())))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[F,B,T,P,L]),(0,c.useEffect)(()=>{var e;if(!F)return;if(!H.current){H.current=!0;return}let{unitId:t,subUnitId:n,commentId:r}=F,i=`${U}-${t}-${n}-${r}`;(e=document.getElementById(i))==null||e.scrollIntoView({block:`center`})},[F,U]);let re=e=>(t,n)=>/* @__PURE__ */ (0,l.jsx)(ce,{full:!0,location:U,getSubUnitName:d,id:t.id,unitId:t.unitId,subUnitId:t.subUnitId,refStr:t.ref,displayRef:w==null?void 0:w(t),type:o,showEdit:!t.id||Y(F,t),showHighlight:Y(F,t),autoFocus:E&&Y(F,t),onClick:()=>{H.current=!1,t.resolved?B.executeCommand(_.id):B.executeCommand(_.id,{unitId:t.unitId,subUnitId:t.subUnitId,commentId:t.id,temp:!1})},onMouseEnter:()=>{P.setHoveredComment({unitId:t.unitId,subUnitId:t.subUnitId,commentId:t.id,trigger:`panel-hover`}),h==null||h(t)},onMouseLeave:()=>{Y(P.hoveredCommentId,t)&&P.setHoveredComment(void 0),m==null||m(t)},onAddComment:b,onDeleteComment:x,onAfterDeleteComment:S,onResolve:e=>f==null?void 0:f(t.id,e),onClose:t.id?void 0:T},ee(t,n,e));return/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-box-border univer-flex univer-min-h-full univer-flex-col univer-pb-3`,children:[/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-flex-row univer-justify-between`,children:[o===t.UniverInstanceType.UNIVER_SHEET?/* @__PURE__ */ (0,l.jsx)(s.Select,{borderless:!0,value:D,options:[{value:`current`,label:j.t(`thread-comment-ui.filter.sheet.current`)},{value:`all`,label:j.t(`thread-comment-ui.filter.sheet.all`)}],onChange:O}):null,/* @__PURE__ */ (0,l.jsx)(s.Select,{borderless:!0,value:k,options:[{value:`all`,label:j.t(`thread-comment-ui.filter.status.all`)},{value:`resolved`,label:j.t(`thread-comment-ui.filter.status.resolved`)},{value:`unsolved`,label:j.t(`thread-comment-ui.filter.status.unsolved`)},{value:`concern_me`,label:j.t(`thread-comment-ui.filter.status.concernMe`)}],onChange:A})]}),J.length===0?/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:[j.t(`thread-comment-ui.panel.empty`),ne?/* @__PURE__ */ (0,l.jsx)(s.ActionRow,{className:`univer-mt-2 univer-flex univer-flex-row`,children:/* @__PURE__ */ (0,l.jsx)(s.Button,{onClick:Q,children:j.t(`thread-comment-ui.panel.reset`)})}):v?null:/* @__PURE__ */ (0,l.jsx)(s.ActionRow,{className:`univer-mt-2 univer-flex univer-flex-row`,children:/* @__PURE__ */ (0,l.jsxs)(s.Button,{onClick:u,children:[/* @__PURE__ */ (0,l.jsx)(R,{className:`univer-mr-1.5`}),j.t(`thread-comment-ui.panel.addComment`)]})})]}):/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-flex-col univer-gap-3`,children:[Z.map(re(`unsolved`)),te.length>0&&/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-text-xs`,children:j.t(`thread-comment-ui.panel.solved`)}),te.map(re(`solved`))]})]})},Object.defineProperty(e,"ThreadCommentPanelService",{enumerable:!0,get:function(){return g}}),e.ThreadCommentTree=ce,e.ThreadCommentTreeLocation=$,Object.defineProperty(e,"UniverThreadCommentMobileUIPlugin",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"UniverThreadCommentUIPlugin",{enumerable:!0,get:function(){return T}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/thread-comment-ui",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "private": false,
5
5
  "description": "Shared thread comment UI components and services for Univer.",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -58,22 +58,22 @@
58
58
  "rxjs": ">=7.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@univerjs/core": "1.4.0",
62
- "@univerjs/design": "1.4.0",
63
- "@univerjs/docs-ui": "1.4.0",
64
- "@univerjs/engine-render": "1.4.0",
61
+ "@univerjs/core": "1.5.0",
62
+ "@univerjs/design": "1.5.0",
63
+ "@univerjs/docs-ui": "1.5.0",
64
+ "@univerjs/engine-render": "1.5.0",
65
65
  "@univerjs/icons": "1.47.0",
66
- "@univerjs/thread-comment": "1.4.0",
67
- "@univerjs/ui": "1.4.0"
66
+ "@univerjs/thread-comment": "1.5.0",
67
+ "@univerjs/ui": "1.5.0"
68
68
  },
69
69
  "devDependencies": {
70
- "@univerjs-infra/shared": "1.4.0",
70
+ "@univerjs-infra/shared": "1.5.0",
71
71
  "postcss": "^8.5.32",
72
72
  "react": "18.3.1",
73
73
  "rxjs": "7.8.2",
74
74
  "tailwindcss": "3.4.18",
75
- "tsrs": "0.20.1-ts7.1.0-beta",
76
- "vitest": "^5.0.5"
75
+ "tsrs": "0.23.0-ts7.1.0-beta",
76
+ "vitest": "^5.1.0"
77
77
  },
78
78
  "scripts": {
79
79
  "test": "vitest run",