@univerjs/thread-comment 0.4.2 → 0.5.0-alpha.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/lib/es/index.js CHANGED
@@ -1,529 +1,812 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { createIdentifier, Disposable, Inject, LifecycleService, LifecycleStages, IResourceManagerService, CommandType, ICommandService, Plugin, UniverInstanceType, mergeOverrideWithDependencies, Injector, IConfigService } from "@univerjs/core";
6
- import { Subject } from "rxjs";
7
- const _ThreadCommentDataSourceService = class _ThreadCommentDataSourceService extends Disposable {
1
+ var Ce = Object.defineProperty;
2
+ var _e = (s, t, e) => t in s ? Ce(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
+ var E = (s, t, e) => _e(s, typeof t != "symbol" ? t + "" : t, e);
4
+ import { createIdentifier as ve, Disposable as ee, Inject as Z, LifecycleService as ge, LifecycleStages as ae, IResourceManagerService as ye, CommandType as I, ICommandService as H, Plugin as Se, UniverInstanceType as $e, mergeOverrideWithDependencies as Te, Injector as De, IConfigService as Oe } from "@univerjs/core";
5
+ import { Subject as we } from "rxjs";
6
+ class Ue extends ee {
8
7
  constructor() {
9
8
  super();
10
- __publicField(this, "_dataSource", null);
11
- __publicField(this, "syncUpdateMutationToColla", !0);
9
+ E(this, "_dataSource", null);
10
+ E(this, "syncUpdateMutationToColla", !0);
12
11
  }
13
- set dataSource(dataSource) {
14
- this._dataSource = dataSource;
12
+ set dataSource(e) {
13
+ this._dataSource = e;
15
14
  }
16
15
  get dataSource() {
17
16
  return this._dataSource;
18
17
  }
19
- async getThreadComment(unitId, subUnitId, threadId) {
20
- return this._dataSource ? (await this._dataSource.listComments(unitId, subUnitId, [threadId]))[0] : null;
18
+ async getThreadComment(e, n, r) {
19
+ return this._dataSource ? (await this._dataSource.listComments(e, n, [r]))[0] : null;
21
20
  }
22
- async addComment(comment) {
23
- var _a4;
24
- return this._dataSource ? this._dataSource.addComment(comment) : { ...comment, threadId: (_a4 = comment.threadId) != null ? _a4 : comment.id };
21
+ async addComment(e) {
22
+ var n;
23
+ return this._dataSource ? this._dataSource.addComment(e) : { ...e, threadId: (n = e.threadId) != null ? n : e.id };
25
24
  }
26
- async updateComment(comment) {
27
- return this._dataSource ? this._dataSource.updateComment(comment) : !0;
25
+ async updateComment(e) {
26
+ return this._dataSource ? this._dataSource.updateComment(e) : !0;
28
27
  }
29
- async resolveComment(comment) {
30
- return this._dataSource ? this._dataSource.resolveComment(comment) : !0;
28
+ async resolveComment(e) {
29
+ return this._dataSource ? this._dataSource.resolveComment(e) : !0;
31
30
  }
32
- async deleteComment(unitId, subUnitId, threadId, commentId) {
33
- return this._dataSource ? this._dataSource.deleteComment(unitId, subUnitId, threadId, commentId) : !0;
31
+ async deleteComment(e, n, r, a) {
32
+ return this._dataSource ? this._dataSource.deleteComment(e, n, r, a) : !0;
34
33
  }
35
- async listThreadComments(unitId, subUnitId, threadIds) {
36
- return this.dataSource ? this.dataSource.listComments(unitId, subUnitId, threadIds) : !1;
34
+ async listThreadComments(e, n, r) {
35
+ return this.dataSource ? this.dataSource.listComments(e, n, r) : !1;
37
36
  }
38
- saveToSnapshot(unitComments, unitId) {
37
+ saveToSnapshot(e, n) {
39
38
  if (this._dataSource) {
40
- const map = {};
41
- return Object.keys(unitComments).forEach((subUnitId) => {
42
- const comments = unitComments[subUnitId];
43
- map[subUnitId] = comments.map(this.dataSource.saveCommentToSnapshot);
44
- }), map;
39
+ const r = {};
40
+ return Object.keys(e).forEach((a) => {
41
+ const o = e[a];
42
+ r[a] = o.map(this.dataSource.saveCommentToSnapshot);
43
+ }), r;
45
44
  }
46
- return unitComments;
47
- }
48
- };
49
- __name(_ThreadCommentDataSourceService, "ThreadCommentDataSourceService");
50
- let ThreadCommentDataSourceService = _ThreadCommentDataSourceService;
51
- const IThreadCommentDataSourceService = createIdentifier("univer.thread-comment.data-source-service");
52
- var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
53
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
54
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
55
- return kind && result && __defProp$2(target, key, result), result;
56
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a;
57
- let ThreadCommentModel = (_a = class extends Disposable {
58
- constructor(_dataSourceService, _lifecycleService) {
45
+ return e;
46
+ }
47
+ }
48
+ const b = ve("univer.thread-comment.data-source-service");
49
+ var Ne = Object.defineProperty, Ee = Object.getOwnPropertyDescriptor, Ie = (s, t, e, n) => {
50
+ for (var r = n > 1 ? void 0 : n ? Ee(t, e) : t, a = s.length - 1, o; a >= 0; a--)
51
+ (o = s[a]) && (r = (n ? o(t, e, r) : o(r)) || r);
52
+ return n && r && Ne(t, e, r), r;
53
+ }, se = (s, t) => (e, n) => t(e, n, s);
54
+ let O = class extends ee {
55
+ constructor(t, e) {
59
56
  super();
60
- __publicField(this, "_commentsMap", /* @__PURE__ */ new Map());
61
- __publicField(this, "_threadMap", /* @__PURE__ */ new Map());
62
- __publicField(this, "_commentUpdate$", new Subject());
63
- __publicField(this, "commentUpdate$", this._commentUpdate$.asObservable());
64
- __publicField(this, "_tasks", []);
65
- this._dataSourceService = _dataSourceService, this._lifecycleService = _lifecycleService, this.disposeWithMe(() => {
57
+ E(this, "_commentsMap", /* @__PURE__ */ new Map());
58
+ E(this, "_threadMap", /* @__PURE__ */ new Map());
59
+ E(this, "_commentUpdate$", new we());
60
+ E(this, "commentUpdate$", this._commentUpdate$.asObservable());
61
+ E(this, "_tasks", []);
62
+ this._dataSourceService = t, this._lifecycleService = e, this.disposeWithMe(() => {
66
63
  this._commentUpdate$.complete();
67
- }), this.disposeWithMe(this._lifecycleService.lifecycle$.subscribe((stage) => {
68
- const taskMap = /* @__PURE__ */ new Map();
69
- stage === LifecycleStages.Rendered && (this._tasks.forEach(({ unitId, subUnitId, threadIds }) => {
70
- let unitMap = taskMap.get(unitId);
71
- unitMap || (unitMap = /* @__PURE__ */ new Map(), taskMap.set(unitId, unitMap));
72
- let subUnitMap = unitMap.get(subUnitId);
73
- subUnitMap || (subUnitMap = /* @__PURE__ */ new Set(), unitMap.set(subUnitId, subUnitMap));
74
- for (const threadId of threadIds)
75
- subUnitMap.add(threadId);
76
- }), this._tasks = [], taskMap.forEach((subUnitMap, unitId) => {
77
- subUnitMap.forEach((threadIds, subUnitId) => {
78
- this.syncThreadComments(unitId, subUnitId, Array.from(threadIds));
64
+ }), this.disposeWithMe(this._lifecycleService.lifecycle$.subscribe((n) => {
65
+ const r = /* @__PURE__ */ new Map();
66
+ n === ae.Rendered && (this._tasks.forEach(({ unitId: a, subUnitId: o, threadIds: M }) => {
67
+ let u = r.get(a);
68
+ u || (u = /* @__PURE__ */ new Map(), r.set(a, u));
69
+ let p = u.get(o);
70
+ p || (p = /* @__PURE__ */ new Set(), u.set(o, p));
71
+ for (const S of M)
72
+ p.add(S);
73
+ }), this._tasks = [], r.forEach((a, o) => {
74
+ a.forEach((M, u) => {
75
+ this.syncThreadComments(o, u, Array.from(M));
79
76
  });
80
77
  }));
81
78
  }));
82
79
  }
83
- _ensureCommentMap(unitId, subUnitId) {
84
- let unitMap = this._commentsMap.get(unitId);
85
- unitMap || (unitMap = /* @__PURE__ */ new Map(), this._commentsMap.set(unitId, unitMap));
86
- let subUnitMap = unitMap.get(subUnitId);
87
- return subUnitMap || (subUnitMap = /* @__PURE__ */ new Map(), unitMap.set(subUnitId, subUnitMap)), subUnitMap;
88
- }
89
- ensureMap(unitId, subUnitId) {
90
- return this._ensureCommentMap(unitId, subUnitId);
91
- }
92
- _ensureThreadMap(unitId, subUnitId) {
93
- let unitMap = this._threadMap.get(unitId);
94
- unitMap || (unitMap = /* @__PURE__ */ new Map(), this._threadMap.set(unitId, unitMap));
95
- let subUnitMap = unitMap.get(subUnitId);
96
- return subUnitMap || (subUnitMap = /* @__PURE__ */ new Map(), unitMap.set(subUnitId, subUnitMap)), subUnitMap;
97
- }
98
- _replaceComment(unitId, subUnitId, comment) {
99
- const commentMap = this._ensureCommentMap(unitId, subUnitId), currentComment = commentMap.get(comment.id);
100
- if (currentComment) {
101
- const { children, ...rest } = comment, newComment = {
102
- ...rest,
103
- ref: currentComment.ref
80
+ _ensureCommentMap(t, e) {
81
+ let n = this._commentsMap.get(t);
82
+ n || (n = /* @__PURE__ */ new Map(), this._commentsMap.set(t, n));
83
+ let r = n.get(e);
84
+ return r || (r = /* @__PURE__ */ new Map(), n.set(e, r)), r;
85
+ }
86
+ ensureMap(t, e) {
87
+ return this._ensureCommentMap(t, e);
88
+ }
89
+ _ensureThreadMap(t, e) {
90
+ let n = this._threadMap.get(t);
91
+ n || (n = /* @__PURE__ */ new Map(), this._threadMap.set(t, n));
92
+ let r = n.get(e);
93
+ return r || (r = /* @__PURE__ */ new Map(), n.set(e, r)), r;
94
+ }
95
+ _replaceComment(t, e, n) {
96
+ const r = this._ensureCommentMap(t, e), a = r.get(n.id);
97
+ if (a) {
98
+ const { children: o, ...M } = n, u = {
99
+ ...M,
100
+ ref: a.ref
104
101
  };
105
- commentMap.set(comment.id, newComment), children == null || children.forEach((child) => {
106
- commentMap.set(child.id, {
107
- ...child,
102
+ r.set(n.id, u), o == null || o.forEach((p) => {
103
+ r.set(p.id, {
104
+ ...p,
108
105
  ref: ""
109
106
  });
110
107
  }), this._commentUpdate$.next({
111
- unitId,
112
- subUnitId,
108
+ unitId: t,
109
+ subUnitId: e,
113
110
  type: "syncUpdate",
114
- payload: newComment
115
- }), !!comment.resolved != !!currentComment.resolved && this._commentUpdate$.next({
116
- unitId,
117
- subUnitId,
111
+ payload: u
112
+ }), !!n.resolved != !!a.resolved && this._commentUpdate$.next({
113
+ unitId: t,
114
+ subUnitId: e,
118
115
  type: "resolve",
119
116
  payload: {
120
- commentId: comment.id,
121
- resolved: !!comment.resolved
117
+ commentId: n.id,
118
+ resolved: !!n.resolved
122
119
  }
123
120
  });
124
121
  }
125
122
  }
126
- async syncThreadComments(unitId, subUnitId, threadIds) {
127
- if (this._lifecycleService.stage < LifecycleStages.Rendered) {
128
- this._tasks.push({ unitId, subUnitId, threadIds });
123
+ async syncThreadComments(t, e, n) {
124
+ if (this._lifecycleService.stage < ae.Rendered) {
125
+ this._tasks.push({ unitId: t, subUnitId: e, threadIds: n });
129
126
  return;
130
127
  }
131
- const threadMap = this._ensureThreadMap(unitId, subUnitId), commentMap = this._ensureCommentMap(unitId, subUnitId), comments = await this._dataSourceService.listThreadComments(unitId, subUnitId, threadIds);
132
- if (!comments)
128
+ const r = this._ensureThreadMap(t, e), a = this._ensureCommentMap(t, e), o = await this._dataSourceService.listThreadComments(t, e, n);
129
+ if (!o)
133
130
  return;
134
- const deleteThreads = new Set(threadIds);
135
- comments.forEach((comment) => {
136
- this._replaceComment(unitId, subUnitId, comment), deleteThreads.delete(comment.threadId);
137
- }), deleteThreads.forEach((id) => {
138
- threadMap.delete(id), commentMap.forEach((comment, commentId) => {
139
- comment.threadId === id && commentMap.delete(commentId);
131
+ const M = new Set(n);
132
+ o.forEach((u) => {
133
+ this._replaceComment(t, e, u), M.delete(u.threadId);
134
+ }), M.forEach((u) => {
135
+ r.delete(u), a.forEach((p, S) => {
136
+ p.threadId === u && a.delete(S);
140
137
  });
141
138
  });
142
139
  }
143
- addComment(unitId, subUnitId, origin, shouldSync) {
144
- const commentMap = this._ensureCommentMap(unitId, subUnitId), { parentId, children = [], ...rest } = origin, comment = {
145
- ...rest,
146
- parentId: parentId === origin.id ? void 0 : parentId
147
- }, addCommentItem = /* @__PURE__ */ __name((item) => {
148
- commentMap.set(item.id, item), this._commentUpdate$.next({
149
- unitId,
150
- subUnitId,
140
+ addComment(t, e, n, r) {
141
+ const a = this._ensureCommentMap(t, e), { parentId: o, children: M = [], ...u } = n, p = {
142
+ ...u,
143
+ parentId: o === n.id ? void 0 : o
144
+ }, S = (N) => {
145
+ a.set(N.id, N), this._commentUpdate$.next({
146
+ unitId: t,
147
+ subUnitId: e,
151
148
  type: "add",
152
- payload: item,
153
- isRoot: !item.parentId
149
+ payload: N,
150
+ isRoot: !N.parentId
154
151
  });
155
- }, "addCommentItem");
156
- addCommentItem(comment);
157
- const threadMap = this._ensureThreadMap(unitId, subUnitId);
158
- if (!comment.parentId) {
159
- threadMap.set(comment.threadId, comment);
160
- for (const child of children)
161
- addCommentItem(child);
152
+ };
153
+ S(p);
154
+ const $ = this._ensureThreadMap(t, e);
155
+ if (!p.parentId) {
156
+ $.set(p.threadId, p);
157
+ for (const N of M)
158
+ S(N);
162
159
  }
163
- return shouldSync && this.syncThreadComments(unitId, subUnitId, [comment.threadId]), !0;
160
+ return r && this.syncThreadComments(t, e, [p.threadId]), !0;
164
161
  }
165
- updateComment(unitId, subUnitId, payload, silent) {
166
- const oldComment = this._ensureCommentMap(unitId, subUnitId).get(payload.commentId);
167
- return oldComment && (oldComment.updated = !0, oldComment.text = payload.text, oldComment.attachments = payload.attachments, oldComment.updateT = payload.updateT, this._commentUpdate$.next({
168
- unitId,
169
- subUnitId,
162
+ updateComment(t, e, n, r) {
163
+ const o = this._ensureCommentMap(t, e).get(n.commentId);
164
+ return o && (o.updated = !0, o.text = n.text, o.attachments = n.attachments, o.updateT = n.updateT, this._commentUpdate$.next({
165
+ unitId: t,
166
+ subUnitId: e,
170
167
  type: "update",
171
- payload,
172
- silent
168
+ payload: n,
169
+ silent: r
173
170
  })), !0;
174
171
  }
175
- updateCommentRef(unitId, subUnitId, payload, silent) {
176
- const oldComment = this._ensureCommentMap(unitId, subUnitId).get(payload.commentId);
177
- return oldComment ? (oldComment.ref = payload.ref, this._commentUpdate$.next({
178
- unitId,
179
- subUnitId,
172
+ updateCommentRef(t, e, n, r) {
173
+ const o = this._ensureCommentMap(t, e).get(n.commentId);
174
+ return o ? (o.ref = n.ref, this._commentUpdate$.next({
175
+ unitId: t,
176
+ subUnitId: e,
180
177
  type: "updateRef",
181
- payload,
182
- silent,
183
- threadId: oldComment.threadId
178
+ payload: n,
179
+ silent: r,
180
+ threadId: o.threadId
184
181
  }), !0) : !1;
185
182
  }
186
- resolveComment(unitId, subUnitId, commentId, resolved) {
187
- const oldComment = this._ensureCommentMap(unitId, subUnitId).get(commentId);
188
- return oldComment ? (oldComment.resolved = resolved, this._commentUpdate$.next({
189
- unitId,
190
- subUnitId,
183
+ resolveComment(t, e, n, r) {
184
+ const o = this._ensureCommentMap(t, e).get(n);
185
+ return o ? (o.resolved = r, this._commentUpdate$.next({
186
+ unitId: t,
187
+ subUnitId: e,
191
188
  type: "resolve",
192
189
  payload: {
193
- commentId,
194
- resolved
190
+ commentId: n,
191
+ resolved: r
195
192
  }
196
193
  }), !0) : !1;
197
194
  }
198
- getComment(unitId, subUnitId, commentId) {
199
- return this._ensureCommentMap(unitId, subUnitId).get(commentId);
195
+ getComment(t, e, n) {
196
+ return this._ensureCommentMap(t, e).get(n);
200
197
  }
201
- getRootComment(unitId, subUnitId, threadId) {
202
- return this._ensureThreadMap(unitId, subUnitId).get(threadId);
198
+ getRootComment(t, e, n) {
199
+ return this._ensureThreadMap(t, e).get(n);
203
200
  }
204
- getThread(unitId, subUnitId, threadId) {
205
- const commentMap = this._ensureCommentMap(unitId, subUnitId), comments = Array.from(commentMap.values()).filter((comment) => comment.threadId === threadId);
206
- let root;
207
- const children = [], relativeUsers = /* @__PURE__ */ new Set();
208
- for (const comment of comments)
209
- comment.parentId ? children.push(comment) : root = comment, relativeUsers.add(comment.personId);
210
- if (root)
201
+ getThread(t, e, n) {
202
+ const r = this._ensureCommentMap(t, e), a = Array.from(r.values()).filter((p) => p.threadId === n);
203
+ let o;
204
+ const M = [], u = /* @__PURE__ */ new Set();
205
+ for (const p of a)
206
+ p.parentId ? M.push(p) : o = p, u.add(p.personId);
207
+ if (o)
211
208
  return {
212
- root,
213
- children,
214
- relativeUsers,
215
- unitId,
216
- subUnitId,
217
- threadId
209
+ root: o,
210
+ children: M,
211
+ relativeUsers: u,
212
+ unitId: t,
213
+ subUnitId: e,
214
+ threadId: n
218
215
  };
219
216
  }
220
- getCommentWithChildren(unitId, subUnitId, commentId) {
221
- const comment = this.getComment(unitId, subUnitId, commentId);
222
- if (comment)
223
- return this.getThread(unitId, subUnitId, comment.threadId);
217
+ getCommentWithChildren(t, e, n) {
218
+ const r = this.getComment(t, e, n);
219
+ if (r)
220
+ return this.getThread(t, e, r.threadId);
224
221
  }
225
- _deleteComment(unitId, subUnitId, commentId) {
226
- const commentMap = this._ensureCommentMap(unitId, subUnitId), current = commentMap.get(commentId);
227
- current && (commentMap.delete(commentId), this._commentUpdate$.next({
228
- unitId,
229
- subUnitId,
222
+ _deleteComment(t, e, n) {
223
+ const r = this._ensureCommentMap(t, e), a = r.get(n);
224
+ a && (r.delete(n), this._commentUpdate$.next({
225
+ unitId: t,
226
+ subUnitId: e,
230
227
  type: "delete",
231
228
  payload: {
232
- commentId,
233
- isRoot: !current.parentId,
234
- comment: current
229
+ commentId: n,
230
+ isRoot: !a.parentId,
231
+ comment: a
235
232
  }
236
233
  }));
237
234
  }
238
- deleteThread(unitId, subUnitId, threadId) {
239
- this._ensureThreadMap(unitId, subUnitId).delete(threadId), this._ensureCommentMap(unitId, subUnitId).forEach((comment) => {
240
- comment.threadId === threadId && this._deleteComment(unitId, subUnitId, comment.id);
235
+ deleteThread(t, e, n) {
236
+ this._ensureThreadMap(t, e).delete(n), this._ensureCommentMap(t, e).forEach((o) => {
237
+ o.threadId === n && this._deleteComment(t, e, o.id);
241
238
  });
242
239
  }
243
- deleteComment(unitId, subUnitId, commentId) {
244
- const current = this._ensureCommentMap(unitId, subUnitId).get(commentId);
245
- return current && (current.parentId ? this._deleteComment(unitId, subUnitId, commentId) : this.deleteThread(unitId, subUnitId, current.threadId)), !0;
240
+ deleteComment(t, e, n) {
241
+ const a = this._ensureCommentMap(t, e).get(n);
242
+ return a && (a.parentId ? this._deleteComment(t, e, n) : this.deleteThread(t, e, a.threadId)), !0;
246
243
  }
247
- deleteUnit(unitId) {
248
- const unitMap = this._commentsMap.get(unitId);
249
- unitMap && unitMap.forEach((subUnitMap, subUnitId) => {
250
- subUnitMap.forEach((comment) => {
251
- this.deleteComment(unitId, subUnitId, comment.id);
244
+ deleteUnit(t) {
245
+ const e = this._commentsMap.get(t);
246
+ e && e.forEach((n, r) => {
247
+ n.forEach((a) => {
248
+ this.deleteComment(t, r, a.id);
252
249
  });
253
250
  });
254
251
  }
255
- getUnit(unitId) {
256
- const unitMap = this._threadMap.get(unitId);
257
- if (!unitMap)
252
+ getUnit(t) {
253
+ const e = this._threadMap.get(t);
254
+ if (!e)
258
255
  return [];
259
- const threads = [];
260
- return unitMap.forEach((subUnitSet, subUnitId) => {
261
- subUnitSet.forEach((threadComment, threadId) => {
262
- const thread = this.getThread(unitId, subUnitId, threadId);
263
- thread && threads.push(thread);
256
+ const n = [];
257
+ return e.forEach((r, a) => {
258
+ r.forEach((o, M) => {
259
+ const u = this.getThread(t, a, M);
260
+ u && n.push(u);
264
261
  });
265
- }), threads;
262
+ }), n;
266
263
  }
267
264
  getAll() {
268
- const all = [];
269
- return this._commentsMap.forEach((unitMap, unitId) => {
270
- all.push({
271
- unitId,
272
- threads: this.getUnit(unitId)
265
+ const t = [];
266
+ return this._commentsMap.forEach((e, n) => {
267
+ t.push({
268
+ unitId: n,
269
+ threads: this.getUnit(n)
273
270
  });
274
- }), all;
275
- }
276
- }, __name(_a, "ThreadCommentModel"), _a);
277
- ThreadCommentModel = __decorateClass$2([
278
- __decorateParam$2(0, Inject(IThreadCommentDataSourceService)),
279
- __decorateParam$2(1, Inject(LifecycleService))
280
- ], ThreadCommentModel);
281
- var _ = /* @__PURE__ */ ((E) => (E[E.UNIVER_UNKNOWN = 0] = "UNIVER_UNKNOWN", E[E.UNIVER_DOC = 1] = "UNIVER_DOC", E[E.UNIVER_SHEET = 2] = "UNIVER_SHEET", E[E.UNIVER_SLIDE = 3] = "UNIVER_SLIDE", E[E.UNIVER_PROJECT = 4] = "UNIVER_PROJECT", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(_ || {});
282
- const TC_PLUGIN_NAME = "UNIVER_THREAD_COMMENT_PLUGIN";
283
- var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
284
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
285
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
286
- return kind && result && __defProp$1(target, key, result), result;
287
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a2;
288
- let ThreadCommentResourceController = (_a2 = class extends Disposable {
289
- constructor(_resourceManagerService, _threadCommentModel, _threadCommentDataSourceService) {
290
- super(), this._resourceManagerService = _resourceManagerService, this._threadCommentModel = _threadCommentModel, this._threadCommentDataSourceService = _threadCommentDataSourceService, this._initSnapshot();
271
+ }), t;
272
+ }
273
+ };
274
+ O = Ie([
275
+ se(0, Z(b)),
276
+ se(1, Z(ge))
277
+ ], O);
278
+ var X = /* @__PURE__ */ ((s) => (s[s.UNIVER_UNKNOWN = 0] = "UNIVER_UNKNOWN", s[s.UNIVER_DOC = 1] = "UNIVER_DOC", s[s.UNIVER_SHEET = 2] = "UNIVER_SHEET", s[s.UNIVER_SLIDE = 3] = "UNIVER_SLIDE", s[s.UNIVER_PROJECT = 4] = "UNIVER_PROJECT", s[s.UNRECOGNIZED = -1] = "UNRECOGNIZED", s))(X || {});
279
+ const ce = "UNIVER_THREAD_COMMENT_PLUGIN";
280
+ var Re = Object.defineProperty, be = Object.getOwnPropertyDescriptor, xe = (s, t, e, n) => {
281
+ for (var r = n > 1 ? void 0 : n ? be(t, e) : t, a = s.length - 1, o; a >= 0; a--)
282
+ (o = s[a]) && (r = (n ? o(t, e, r) : o(r)) || r);
283
+ return n && r && Re(t, e, r), r;
284
+ }, q = (s, t) => (e, n) => t(e, n, s);
285
+ let B = class extends ee {
286
+ constructor(s, t, e) {
287
+ super(), this._resourceManagerService = s, this._threadCommentModel = t, this._threadCommentDataSourceService = e, this._initSnapshot();
291
288
  }
292
289
  _initSnapshot() {
293
- const toJson = /* @__PURE__ */ __name((unitID) => {
294
- const map = this._threadCommentModel.getUnit(unitID), resultMap = {};
295
- return map ? (map.forEach((info) => {
296
- var _a4;
297
- const subUnitComments = (_a4 = resultMap[info.subUnitId]) != null ? _a4 : [];
298
- subUnitComments.push({
299
- ...info.root,
300
- children: info.children
301
- }), resultMap[info.unitId] = subUnitComments;
302
- }), JSON.stringify(this._threadCommentDataSourceService.saveToSnapshot(resultMap, unitID))) : "";
303
- }, "toJson"), parseJson = /* @__PURE__ */ __name((json) => {
304
- if (!json)
290
+ const s = (e) => {
291
+ const n = this._threadCommentModel.getUnit(e), r = {};
292
+ return n ? (n.forEach((a) => {
293
+ var M;
294
+ const o = (M = r[a.subUnitId]) != null ? M : [];
295
+ o.push({
296
+ ...a.root,
297
+ children: a.children
298
+ }), r[a.unitId] = o;
299
+ }), JSON.stringify(this._threadCommentDataSourceService.saveToSnapshot(r, e))) : "";
300
+ }, t = (e) => {
301
+ if (!e)
305
302
  return {};
306
303
  try {
307
- return JSON.parse(json);
304
+ return JSON.parse(e);
308
305
  } catch {
309
306
  return {};
310
307
  }
311
- }, "parseJson");
308
+ };
312
309
  this.disposeWithMe(
313
310
  this._resourceManagerService.registerPluginResource({
314
- pluginName: `SHEET_${TC_PLUGIN_NAME}`,
315
- businesses: [_.UNIVER_SHEET, _.UNIVER_DOC],
316
- toJson: /* @__PURE__ */ __name((unitID) => toJson(unitID), "toJson"),
317
- parseJson: /* @__PURE__ */ __name((json) => parseJson(json), "parseJson"),
318
- onUnLoad: /* @__PURE__ */ __name((unitID) => {
319
- this._threadCommentModel.deleteUnit(unitID);
320
- }, "onUnLoad"),
321
- onLoad: /* @__PURE__ */ __name(async (unitID, value) => {
322
- Object.keys(value).forEach((subunitId) => {
323
- const commentList = value[subunitId];
324
- commentList.forEach((comment) => {
325
- this._threadCommentModel.addComment(unitID, subunitId, comment);
326
- }), this._threadCommentModel.syncThreadComments(unitID, subunitId, commentList.map((i) => i.threadId));
311
+ pluginName: `SHEET_${ce}`,
312
+ businesses: [X.UNIVER_SHEET, X.UNIVER_DOC],
313
+ toJson: (e) => s(e),
314
+ parseJson: (e) => t(e),
315
+ onUnLoad: (e) => {
316
+ this._threadCommentModel.deleteUnit(e);
317
+ },
318
+ onLoad: async (e, n) => {
319
+ Object.keys(n).forEach((r) => {
320
+ const a = n[r];
321
+ a.forEach((o) => {
322
+ this._threadCommentModel.addComment(e, r, o);
323
+ }), this._threadCommentModel.syncThreadComments(e, r, a.map((o) => o.threadId));
327
324
  });
328
- }, "onLoad")
325
+ }
329
326
  })
330
327
  );
331
328
  }
332
- }, __name(_a2, "ThreadCommentResourceController"), _a2);
333
- ThreadCommentResourceController = __decorateClass$1([
334
- __decorateParam$1(0, IResourceManagerService),
335
- __decorateParam$1(1, Inject(ThreadCommentModel)),
336
- __decorateParam$1(2, IThreadCommentDataSourceService)
337
- ], ThreadCommentResourceController);
338
- const AddCommentMutation = {
329
+ };
330
+ B = xe([
331
+ q(0, ye),
332
+ q(1, Z(O)),
333
+ q(2, b)
334
+ ], B);
335
+ const me = {
339
336
  id: "thread-comment.mutation.add-comment",
340
- type: CommandType.MUTATION,
341
- handler(accessor, params, options) {
342
- if (!params)
337
+ type: I.MUTATION,
338
+ handler(s, t, e) {
339
+ if (!t)
343
340
  return !1;
344
- const threadCommentModel = accessor.get(ThreadCommentModel), { unitId, subUnitId, comment, sync } = params, shouldSync = sync || (options == null ? void 0 : options.fromChangeset) && !comment.parentId;
345
- return threadCommentModel.addComment(unitId, subUnitId, comment, shouldSync);
341
+ const n = s.get(O), { unitId: r, subUnitId: a, comment: o, sync: M } = t, u = M || (e == null ? void 0 : e.fromChangeset) && !o.parentId;
342
+ return n.addComment(r, a, o, u);
346
343
  }
347
- }, UpdateCommentMutation = {
344
+ }, de = {
348
345
  id: "thread-comment.mutation.update-comment",
349
- type: CommandType.MUTATION,
350
- handler(accessor, params) {
351
- if (!params)
346
+ type: I.MUTATION,
347
+ handler(s, t) {
348
+ if (!t)
352
349
  return !1;
353
- const threadCommentModel = accessor.get(ThreadCommentModel), { unitId, subUnitId, payload, silent } = params;
354
- return threadCommentModel.updateComment(unitId, subUnitId, payload, silent);
350
+ const e = s.get(O), { unitId: n, subUnitId: r, payload: a, silent: o } = t;
351
+ return e.updateComment(n, r, a, o);
355
352
  }
356
- }, UpdateCommentRefMutation = {
353
+ }, Pe = {
357
354
  id: "thread-comment.mutation.update-comment-ref",
358
- type: CommandType.MUTATION,
359
- handler(accessor, params) {
360
- if (!params)
355
+ type: I.MUTATION,
356
+ handler(s, t) {
357
+ if (!t)
361
358
  return !1;
362
- const threadCommentModel = accessor.get(ThreadCommentModel), { unitId, subUnitId, payload, silent } = params;
363
- return threadCommentModel.updateCommentRef(unitId, subUnitId, payload, silent);
359
+ const e = s.get(O), { unitId: n, subUnitId: r, payload: a, silent: o } = t;
360
+ return e.updateCommentRef(n, r, a, o);
364
361
  }
365
- }, ResolveCommentMutation = {
362
+ }, ue = {
366
363
  id: "thread-comment.mutation.resolve-comment",
367
- type: CommandType.MUTATION,
368
- handler(accessor, params) {
369
- if (!params)
364
+ type: I.MUTATION,
365
+ handler(s, t) {
366
+ if (!t)
370
367
  return !1;
371
- const threadCommentModel = accessor.get(ThreadCommentModel), { unitId, subUnitId, resolved, commentId } = params;
372
- return threadCommentModel.resolveComment(unitId, subUnitId, commentId, resolved);
368
+ const e = s.get(O), { unitId: n, subUnitId: r, resolved: a, commentId: o } = t;
369
+ return e.resolveComment(n, r, o, a);
373
370
  }
374
- }, DeleteCommentMutation = {
371
+ }, te = {
375
372
  id: "thread-comment.mutation.delete-comment",
376
- type: CommandType.MUTATION,
377
- handler(accessor, params) {
378
- if (!params)
373
+ type: I.MUTATION,
374
+ handler(s, t) {
375
+ if (!t)
379
376
  return !1;
380
- const threadCommentModel = accessor.get(ThreadCommentModel), { unitId, subUnitId, commentId } = params;
381
- return threadCommentModel.deleteComment(unitId, subUnitId, commentId);
377
+ const e = s.get(O), { unitId: n, subUnitId: r, commentId: a } = t;
378
+ return e.deleteComment(n, r, a);
382
379
  }
383
- }, AddCommentCommand = {
380
+ }, je = {
384
381
  id: "thread-comment.command.add-comment",
385
- type: CommandType.COMMAND,
386
- async handler(accessor, params) {
387
- if (!params)
382
+ type: I.COMMAND,
383
+ async handler(s, t) {
384
+ if (!t)
388
385
  return !1;
389
- const commandService = accessor.get(ICommandService), dataSourceService = accessor.get(IThreadCommentDataSourceService), { comment: originComment } = params, comment = await dataSourceService.addComment(originComment), syncUpdateMutationToColla = dataSourceService.syncUpdateMutationToColla, isRoot = !originComment.parentId, redo = {
390
- id: AddCommentMutation.id,
386
+ const e = s.get(H), n = s.get(b), { comment: r } = t, a = await n.addComment(r), o = n.syncUpdateMutationToColla, M = !r.parentId, u = {
387
+ id: me.id,
391
388
  params: {
392
- ...params,
393
- comment
389
+ ...t,
390
+ comment: a
394
391
  }
395
392
  };
396
- return isRoot ? await commandService.executeCommand(redo.id, redo.params) : commandService.executeCommand(redo.id, redo.params, {
397
- onlyLocal: !syncUpdateMutationToColla
393
+ return M ? await e.executeCommand(u.id, u.params) : e.executeCommand(u.id, u.params, {
394
+ onlyLocal: !o
398
395
  });
399
396
  }
400
- }, UpdateCommentCommand = {
397
+ }, Ae = {
401
398
  id: "thread-comment.command.update-comment",
402
- type: CommandType.COMMAND,
403
- async handler(accessor, params) {
404
- if (!params)
399
+ type: I.COMMAND,
400
+ async handler(s, t) {
401
+ if (!t)
405
402
  return !1;
406
- const { unitId, subUnitId, payload } = params, commandService = accessor.get(ICommandService), threadCommentModel = accessor.get(ThreadCommentModel), dataSourceService = accessor.get(IThreadCommentDataSourceService), syncUpdateMutationToColla = dataSourceService.syncUpdateMutationToColla, current = threadCommentModel.getComment(
407
- unitId,
408
- subUnitId,
409
- payload.commentId
403
+ const { unitId: e, subUnitId: n, payload: r } = t, a = s.get(H), o = s.get(O), M = s.get(b), u = M.syncUpdateMutationToColla, p = o.getComment(
404
+ e,
405
+ n,
406
+ r.commentId
410
407
  );
411
- if (!current)
408
+ if (!p)
412
409
  return !1;
413
- const { children, ...currentComment } = current;
414
- if (!await dataSourceService.updateComment({
415
- ...currentComment,
416
- ...payload
410
+ const { children: S, ...$ } = p;
411
+ if (!await M.updateComment({
412
+ ...$,
413
+ ...r
417
414
  }))
418
415
  return !1;
419
- const redo = {
420
- id: UpdateCommentMutation.id,
421
- params
416
+ const U = {
417
+ id: de.id,
418
+ params: t
422
419
  };
423
- return commandService.executeCommand(redo.id, redo.params, { onlyLocal: !syncUpdateMutationToColla }), !0;
420
+ return a.executeCommand(U.id, U.params, { onlyLocal: !u }), !0;
424
421
  }
425
- }, ResolveCommentCommand = {
422
+ }, Le = {
426
423
  id: "thread-comment.command.resolve-comment",
427
- type: CommandType.COMMAND,
428
- async handler(accessor, params) {
429
- if (!params)
424
+ type: I.COMMAND,
425
+ async handler(s, t) {
426
+ if (!t)
430
427
  return !1;
431
- const { unitId, subUnitId, resolved, commentId } = params, dataSourceService = accessor.get(IThreadCommentDataSourceService), currentComment = accessor.get(ThreadCommentModel).getComment(unitId, subUnitId, commentId), syncUpdateMutationToColla = dataSourceService.syncUpdateMutationToColla;
432
- return !currentComment || !await dataSourceService.resolveComment({
433
- ...currentComment,
434
- resolved
435
- }) ? !1 : accessor.get(ICommandService).executeCommand(
436
- ResolveCommentMutation.id,
437
- params,
438
- { onlyLocal: !syncUpdateMutationToColla }
428
+ const { unitId: e, subUnitId: n, resolved: r, commentId: a } = t, o = s.get(b), u = s.get(O).getComment(e, n, a), p = o.syncUpdateMutationToColla;
429
+ return !u || !await o.resolveComment({
430
+ ...u,
431
+ resolved: r
432
+ }) ? !1 : s.get(H).executeCommand(
433
+ ue.id,
434
+ t,
435
+ { onlyLocal: !p }
439
436
  );
440
437
  }
441
- }, DeleteCommentCommand = {
438
+ }, He = {
442
439
  id: "thread-comment.command.delete-comment",
443
- type: CommandType.COMMAND,
444
- async handler(accessor, params) {
445
- if (!params)
440
+ type: I.COMMAND,
441
+ async handler(s, t) {
442
+ if (!t)
446
443
  return !1;
447
- const threadCommentModel = accessor.get(ThreadCommentModel), dataSourceService = accessor.get(IThreadCommentDataSourceService), commandService = accessor.get(ICommandService), { unitId, subUnitId, commentId } = params, syncUpdateMutationToColla = dataSourceService.syncUpdateMutationToColla, comment = threadCommentModel.getComment(unitId, subUnitId, commentId);
448
- if (!comment || !await dataSourceService.deleteComment(unitId, subUnitId, comment.threadId, commentId))
444
+ const e = s.get(O), n = s.get(b), r = s.get(H), { unitId: a, subUnitId: o, commentId: M } = t, u = n.syncUpdateMutationToColla, p = e.getComment(a, o, M);
445
+ if (!p || !await n.deleteComment(a, o, p.threadId, M))
449
446
  return !1;
450
- const redo = {
451
- id: DeleteCommentMutation.id,
452
- params
447
+ const S = {
448
+ id: te.id,
449
+ params: t
453
450
  };
454
- return commandService.executeCommand(redo.id, redo.params, { onlyLocal: !syncUpdateMutationToColla });
451
+ return r.executeCommand(S.id, S.params, { onlyLocal: !u });
455
452
  }
456
- }, DeleteCommentTreeCommand = {
453
+ }, We = {
457
454
  id: "thread-comment.command.delete-comment-tree",
458
- type: CommandType.COMMAND,
459
- async handler(accessor, params) {
460
- if (!params)
455
+ type: I.COMMAND,
456
+ async handler(s, t) {
457
+ if (!t)
461
458
  return !1;
462
- const threadCommentModel = accessor.get(ThreadCommentModel), commandService = accessor.get(ICommandService), dataSourceService = accessor.get(IThreadCommentDataSourceService), { unitId, subUnitId, commentId } = params, commentWithChildren = threadCommentModel.getCommentWithChildren(unitId, subUnitId, commentId);
463
- return !commentWithChildren || !await dataSourceService.deleteComment(unitId, subUnitId, commentWithChildren.root.threadId, commentId) ? !1 : await commandService.executeCommand(DeleteCommentMutation.id, {
464
- unitId,
465
- subUnitId,
466
- commentId: commentWithChildren.root.id
459
+ const e = s.get(O), n = s.get(H), r = s.get(b), { unitId: a, subUnitId: o, commentId: M } = t, u = e.getCommentWithChildren(a, o, M);
460
+ return !u || !await r.deleteComment(a, o, u.root.threadId, M) ? !1 : await n.executeCommand(te.id, {
461
+ unitId: a,
462
+ subUnitId: o,
463
+ commentId: u.root.id
467
464
  });
468
465
  }
469
- }, PLUGIN_CONFIG_KEY = "thread-comment.config", defaultPluginConfig = {};
470
- var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
471
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
472
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
473
- return kind && result && __defProp2(target, key, result), result;
474
- }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a3;
475
- let UniverThreadCommentPlugin = (_a3 = class extends Plugin {
476
- constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
477
- super(), this._config = _config, this._injector = _injector, this._commandService = _commandService, this._configService = _configService;
478
- const { ...rest } = this._config;
479
- this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
466
+ }, Ye = "thread-comment.config", Ve = {};
467
+ var Je = Object.defineProperty, ke = Object.getOwnPropertyDescriptor, Ge = (s, t, e, n) => {
468
+ for (var r = n > 1 ? void 0 : n ? ke(t, e) : t, a = s.length - 1, o; a >= 0; a--)
469
+ (o = s[a]) && (r = (n ? o(t, e, r) : o(r)) || r);
470
+ return n && r && Je(t, e, r), r;
471
+ }, Q = (s, t) => (e, n) => t(e, n, s), F;
472
+ let ie = (F = class extends Se {
473
+ constructor(s = Ve, t, e, n) {
474
+ super(), this._config = s, this._injector = t, this._commandService = e, this._configService = n;
475
+ const { ...r } = this._config;
476
+ this._configService.setConfig(Ye, r);
480
477
  }
481
478
  onStarting() {
482
- var _a4;
483
- mergeOverrideWithDependencies([
484
- [IThreadCommentDataSourceService, { useClass: ThreadCommentDataSourceService }],
485
- [ThreadCommentModel],
486
- [ThreadCommentResourceController]
487
- ], (_a4 = this._config) == null ? void 0 : _a4.overrides).forEach(
488
- (d) => {
489
- this._injector.add(d);
479
+ var s;
480
+ Te([
481
+ [b, { useClass: Ue }],
482
+ [O],
483
+ [B]
484
+ ], (s = this._config) == null ? void 0 : s.overrides).forEach(
485
+ (t) => {
486
+ this._injector.add(t);
490
487
  }
491
488
  ), [
492
- AddCommentCommand,
493
- UpdateCommentCommand,
494
- DeleteCommentCommand,
495
- ResolveCommentCommand,
496
- DeleteCommentTreeCommand,
497
- AddCommentMutation,
498
- UpdateCommentMutation,
499
- UpdateCommentRefMutation,
500
- DeleteCommentMutation,
501
- ResolveCommentMutation
502
- ].forEach((command) => {
503
- this._commandService.registerCommand(command);
504
- }), this._injector.get(ThreadCommentResourceController);
505
- }
506
- }, __name(_a3, "UniverThreadCommentPlugin"), __publicField(_a3, "pluginName", TC_PLUGIN_NAME), __publicField(_a3, "type", UniverInstanceType.UNIVER_UNKNOWN), _a3);
507
- UniverThreadCommentPlugin = __decorateClass([
508
- __decorateParam(1, Inject(Injector)),
509
- __decorateParam(2, ICommandService),
510
- __decorateParam(3, IConfigService)
511
- ], UniverThreadCommentPlugin);
489
+ je,
490
+ Ae,
491
+ He,
492
+ Le,
493
+ We,
494
+ me,
495
+ de,
496
+ Pe,
497
+ te,
498
+ ue
499
+ ].forEach((t) => {
500
+ this._commandService.registerCommand(t);
501
+ }), this._injector.get(B);
502
+ }
503
+ }, E(F, "pluginName", ce), E(F, "type", $e.UNIVER_UNKNOWN), F);
504
+ ie = Ge([
505
+ Q(1, Z(De)),
506
+ Q(2, H),
507
+ Q(3, Oe)
508
+ ], ie);
509
+ var Fe = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
510
+ function Ze(s) {
511
+ return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
512
+ }
513
+ var he = { exports: {} };
514
+ (function(s, t) {
515
+ (function(e, n) {
516
+ s.exports = n();
517
+ })(Fe, function() {
518
+ var e = 1e3, n = 6e4, r = 36e5, a = "millisecond", o = "second", M = "minute", u = "hour", p = "day", S = "week", $ = "month", N = "quarter", U = "year", A = "date", ne = "Invalid Date", le = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, fe = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, pe = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(h) {
519
+ var m = ["th", "st", "nd", "rd"], i = h % 100;
520
+ return "[" + h + (m[(i - 20) % 10] || m[i] || m[0]) + "]";
521
+ } }, K = function(h, m, i) {
522
+ var d = String(h);
523
+ return !d || d.length >= m ? h : "" + Array(m + 1 - d.length).join(i) + h;
524
+ }, Me = { s: K, z: function(h) {
525
+ var m = -h.utcOffset(), i = Math.abs(m), d = Math.floor(i / 60), c = i % 60;
526
+ return (m <= 0 ? "+" : "-") + K(d, 2, "0") + ":" + K(c, 2, "0");
527
+ }, m: function h(m, i) {
528
+ if (m.date() < i.date()) return -h(i, m);
529
+ var d = 12 * (i.year() - m.year()) + (i.month() - m.month()), c = m.clone().add(d, $), l = i - c < 0, f = m.clone().add(d + (l ? -1 : 1), $);
530
+ return +(-(d + (i - c) / (l ? c - f : f - c)) || 0);
531
+ }, a: function(h) {
532
+ return h < 0 ? Math.ceil(h) || 0 : Math.floor(h);
533
+ }, p: function(h) {
534
+ return { M: $, y: U, w: S, d: p, D: A, h: u, m: M, s: o, ms: a, Q: N }[h] || String(h || "").toLowerCase().replace(/s$/, "");
535
+ }, u: function(h) {
536
+ return h === void 0;
537
+ } }, W = "en", x = {};
538
+ x[W] = pe;
539
+ var re = "$isDayjsObject", z = function(h) {
540
+ return h instanceof k || !(!h || !h[re]);
541
+ }, J = function h(m, i, d) {
542
+ var c;
543
+ if (!m) return W;
544
+ if (typeof m == "string") {
545
+ var l = m.toLowerCase();
546
+ x[l] && (c = l), i && (x[l] = i, c = l);
547
+ var f = m.split("-");
548
+ if (!c && f.length > 1) return h(f[0]);
549
+ } else {
550
+ var _ = m.name;
551
+ x[_] = m, c = _;
552
+ }
553
+ return !d && c && (W = c), c || !d && W;
554
+ }, g = function(h, m) {
555
+ if (z(h)) return h.clone();
556
+ var i = typeof m == "object" ? m : {};
557
+ return i.date = h, i.args = arguments, new k(i);
558
+ }, C = Me;
559
+ C.l = J, C.i = z, C.w = function(h, m) {
560
+ return g(h, { locale: m.$L, utc: m.$u, x: m.$x, $offset: m.$offset });
561
+ };
562
+ var k = function() {
563
+ function h(i) {
564
+ this.$L = J(i.locale, null, !0), this.parse(i), this.$x = this.$x || i.x || {}, this[re] = !0;
565
+ }
566
+ var m = h.prototype;
567
+ return m.parse = function(i) {
568
+ this.$d = function(d) {
569
+ var c = d.date, l = d.utc;
570
+ if (c === null) return /* @__PURE__ */ new Date(NaN);
571
+ if (C.u(c)) return /* @__PURE__ */ new Date();
572
+ if (c instanceof Date) return new Date(c);
573
+ if (typeof c == "string" && !/Z$/i.test(c)) {
574
+ var f = c.match(le);
575
+ if (f) {
576
+ var _ = f[2] - 1 || 0, v = (f[7] || "0").substring(0, 3);
577
+ return l ? new Date(Date.UTC(f[1], _, f[3] || 1, f[4] || 0, f[5] || 0, f[6] || 0, v)) : new Date(f[1], _, f[3] || 1, f[4] || 0, f[5] || 0, f[6] || 0, v);
578
+ }
579
+ }
580
+ return new Date(c);
581
+ }(i), this.init();
582
+ }, m.init = function() {
583
+ var i = this.$d;
584
+ this.$y = i.getFullYear(), this.$M = i.getMonth(), this.$D = i.getDate(), this.$W = i.getDay(), this.$H = i.getHours(), this.$m = i.getMinutes(), this.$s = i.getSeconds(), this.$ms = i.getMilliseconds();
585
+ }, m.$utils = function() {
586
+ return C;
587
+ }, m.isValid = function() {
588
+ return this.$d.toString() !== ne;
589
+ }, m.isSame = function(i, d) {
590
+ var c = g(i);
591
+ return this.startOf(d) <= c && c <= this.endOf(d);
592
+ }, m.isAfter = function(i, d) {
593
+ return g(i) < this.startOf(d);
594
+ }, m.isBefore = function(i, d) {
595
+ return this.endOf(d) < g(i);
596
+ }, m.$g = function(i, d, c) {
597
+ return C.u(i) ? this[d] : this.set(c, i);
598
+ }, m.unix = function() {
599
+ return Math.floor(this.valueOf() / 1e3);
600
+ }, m.valueOf = function() {
601
+ return this.$d.getTime();
602
+ }, m.startOf = function(i, d) {
603
+ var c = this, l = !!C.u(d) || d, f = C.p(i), _ = function(j, D) {
604
+ var R = C.w(c.$u ? Date.UTC(c.$y, D, j) : new Date(c.$y, D, j), c);
605
+ return l ? R : R.endOf(p);
606
+ }, v = function(j, D) {
607
+ return C.w(c.toDate()[j].apply(c.toDate("s"), (l ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(D)), c);
608
+ }, y = this.$W, T = this.$M, w = this.$D, L = "set" + (this.$u ? "UTC" : "");
609
+ switch (f) {
610
+ case U:
611
+ return l ? _(1, 0) : _(31, 11);
612
+ case $:
613
+ return l ? _(1, T) : _(0, T + 1);
614
+ case S:
615
+ var P = this.$locale().weekStart || 0, Y = (y < P ? y + 7 : y) - P;
616
+ return _(l ? w - Y : w + (6 - Y), T);
617
+ case p:
618
+ case A:
619
+ return v(L + "Hours", 0);
620
+ case u:
621
+ return v(L + "Minutes", 1);
622
+ case M:
623
+ return v(L + "Seconds", 2);
624
+ case o:
625
+ return v(L + "Milliseconds", 3);
626
+ default:
627
+ return this.clone();
628
+ }
629
+ }, m.endOf = function(i) {
630
+ return this.startOf(i, !1);
631
+ }, m.$set = function(i, d) {
632
+ var c, l = C.p(i), f = "set" + (this.$u ? "UTC" : ""), _ = (c = {}, c[p] = f + "Date", c[A] = f + "Date", c[$] = f + "Month", c[U] = f + "FullYear", c[u] = f + "Hours", c[M] = f + "Minutes", c[o] = f + "Seconds", c[a] = f + "Milliseconds", c)[l], v = l === p ? this.$D + (d - this.$W) : d;
633
+ if (l === $ || l === U) {
634
+ var y = this.clone().set(A, 1);
635
+ y.$d[_](v), y.init(), this.$d = y.set(A, Math.min(this.$D, y.daysInMonth())).$d;
636
+ } else _ && this.$d[_](v);
637
+ return this.init(), this;
638
+ }, m.set = function(i, d) {
639
+ return this.clone().$set(i, d);
640
+ }, m.get = function(i) {
641
+ return this[C.p(i)]();
642
+ }, m.add = function(i, d) {
643
+ var c, l = this;
644
+ i = Number(i);
645
+ var f = C.p(d), _ = function(T) {
646
+ var w = g(l);
647
+ return C.w(w.date(w.date() + Math.round(T * i)), l);
648
+ };
649
+ if (f === $) return this.set($, this.$M + i);
650
+ if (f === U) return this.set(U, this.$y + i);
651
+ if (f === p) return _(1);
652
+ if (f === S) return _(7);
653
+ var v = (c = {}, c[M] = n, c[u] = r, c[o] = e, c)[f] || 1, y = this.$d.getTime() + i * v;
654
+ return C.w(y, this);
655
+ }, m.subtract = function(i, d) {
656
+ return this.add(-1 * i, d);
657
+ }, m.format = function(i) {
658
+ var d = this, c = this.$locale();
659
+ if (!this.isValid()) return c.invalidDate || ne;
660
+ var l = i || "YYYY-MM-DDTHH:mm:ssZ", f = C.z(this), _ = this.$H, v = this.$m, y = this.$M, T = c.weekdays, w = c.months, L = c.meridiem, P = function(D, R, V, G) {
661
+ return D && (D[R] || D(d, l)) || V[R].slice(0, G);
662
+ }, Y = function(D) {
663
+ return C.s(_ % 12 || 12, D, "0");
664
+ }, j = L || function(D, R, V) {
665
+ var G = D < 12 ? "AM" : "PM";
666
+ return V ? G.toLowerCase() : G;
667
+ };
668
+ return l.replace(fe, function(D, R) {
669
+ return R || function(V) {
670
+ switch (V) {
671
+ case "YY":
672
+ return String(d.$y).slice(-2);
673
+ case "YYYY":
674
+ return C.s(d.$y, 4, "0");
675
+ case "M":
676
+ return y + 1;
677
+ case "MM":
678
+ return C.s(y + 1, 2, "0");
679
+ case "MMM":
680
+ return P(c.monthsShort, y, w, 3);
681
+ case "MMMM":
682
+ return P(w, y);
683
+ case "D":
684
+ return d.$D;
685
+ case "DD":
686
+ return C.s(d.$D, 2, "0");
687
+ case "d":
688
+ return String(d.$W);
689
+ case "dd":
690
+ return P(c.weekdaysMin, d.$W, T, 2);
691
+ case "ddd":
692
+ return P(c.weekdaysShort, d.$W, T, 3);
693
+ case "dddd":
694
+ return T[d.$W];
695
+ case "H":
696
+ return String(_);
697
+ case "HH":
698
+ return C.s(_, 2, "0");
699
+ case "h":
700
+ return Y(1);
701
+ case "hh":
702
+ return Y(2);
703
+ case "a":
704
+ return j(_, v, !0);
705
+ case "A":
706
+ return j(_, v, !1);
707
+ case "m":
708
+ return String(v);
709
+ case "mm":
710
+ return C.s(v, 2, "0");
711
+ case "s":
712
+ return String(d.$s);
713
+ case "ss":
714
+ return C.s(d.$s, 2, "0");
715
+ case "SSS":
716
+ return C.s(d.$ms, 3, "0");
717
+ case "Z":
718
+ return f;
719
+ }
720
+ return null;
721
+ }(D) || f.replace(":", "");
722
+ });
723
+ }, m.utcOffset = function() {
724
+ return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
725
+ }, m.diff = function(i, d, c) {
726
+ var l, f = this, _ = C.p(d), v = g(i), y = (v.utcOffset() - this.utcOffset()) * n, T = this - v, w = function() {
727
+ return C.m(f, v);
728
+ };
729
+ switch (_) {
730
+ case U:
731
+ l = w() / 12;
732
+ break;
733
+ case $:
734
+ l = w();
735
+ break;
736
+ case N:
737
+ l = w() / 3;
738
+ break;
739
+ case S:
740
+ l = (T - y) / 6048e5;
741
+ break;
742
+ case p:
743
+ l = (T - y) / 864e5;
744
+ break;
745
+ case u:
746
+ l = T / r;
747
+ break;
748
+ case M:
749
+ l = T / n;
750
+ break;
751
+ case o:
752
+ l = T / e;
753
+ break;
754
+ default:
755
+ l = T;
756
+ }
757
+ return c ? l : C.a(l);
758
+ }, m.daysInMonth = function() {
759
+ return this.endOf($).$D;
760
+ }, m.$locale = function() {
761
+ return x[this.$L];
762
+ }, m.locale = function(i, d) {
763
+ if (!i) return this.$L;
764
+ var c = this.clone(), l = J(i, d, !0);
765
+ return l && (c.$L = l), c;
766
+ }, m.clone = function() {
767
+ return C.w(this.$d, this);
768
+ }, m.toDate = function() {
769
+ return new Date(this.valueOf());
770
+ }, m.toJSON = function() {
771
+ return this.isValid() ? this.toISOString() : null;
772
+ }, m.toISOString = function() {
773
+ return this.$d.toISOString();
774
+ }, m.toString = function() {
775
+ return this.$d.toUTCString();
776
+ }, h;
777
+ }(), oe = k.prototype;
778
+ return g.prototype = oe, [["$ms", a], ["$s", o], ["$m", M], ["$H", u], ["$W", p], ["$M", $], ["$y", U], ["$D", A]].forEach(function(h) {
779
+ oe[h[1]] = function(m) {
780
+ return this.$g(m, h[0], h[1]);
781
+ };
782
+ }), g.extend = function(h, m) {
783
+ return h.$i || (h(m, k, g), h.$i = !0), g;
784
+ }, g.locale = J, g.isDayjs = z, g.unix = function(h) {
785
+ return g(1e3 * h);
786
+ }, g.en = x[W], g.Ls = x, g.p = {}, g;
787
+ });
788
+ })(he);
789
+ var Be = he.exports;
790
+ const Ke = /* @__PURE__ */ Ze(Be);
791
+ function Xe() {
792
+ return Ke().format("YYYY/MM/DD HH:mm");
793
+ }
512
794
  export {
513
- AddCommentCommand,
514
- AddCommentMutation,
515
- DeleteCommentCommand,
516
- DeleteCommentMutation,
517
- DeleteCommentTreeCommand,
518
- IThreadCommentDataSourceService,
519
- ResolveCommentCommand,
520
- ResolveCommentMutation,
521
- TC_PLUGIN_NAME,
522
- ThreadCommentDataSourceService,
523
- ThreadCommentModel,
524
- ThreadCommentResourceController,
525
- UniverThreadCommentPlugin,
526
- UpdateCommentCommand,
527
- UpdateCommentMutation,
528
- UpdateCommentRefMutation
795
+ je as AddCommentCommand,
796
+ me as AddCommentMutation,
797
+ He as DeleteCommentCommand,
798
+ te as DeleteCommentMutation,
799
+ We as DeleteCommentTreeCommand,
800
+ b as IThreadCommentDataSourceService,
801
+ Le as ResolveCommentCommand,
802
+ ue as ResolveCommentMutation,
803
+ ce as TC_PLUGIN_NAME,
804
+ Ue as ThreadCommentDataSourceService,
805
+ O as ThreadCommentModel,
806
+ B as ThreadCommentResourceController,
807
+ ie as UniverThreadCommentPlugin,
808
+ Ae as UpdateCommentCommand,
809
+ de as UpdateCommentMutation,
810
+ Pe as UpdateCommentRefMutation,
811
+ Xe as getDT
529
812
  };