@univerjs/thread-comment 0.3.0-alpha.1 → 0.3.0-nightly.202410101606

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/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@univerjs/core"),rxjs=require("rxjs"),_ThreadCommentDataSourceService=class _ThreadCommentDataSourceService extends core.Disposable{constructor(){super();__publicField(this,"_dataSource",null);__publicField(this,"syncUpdateMutationToColla",!0)}set dataSource(dataSource){this._dataSource=dataSource}get dataSource(){return this._dataSource}async getThreadComment(unitId,subUnitId,threadId){return this._dataSource?(await this._dataSource.listComments(unitId,subUnitId,[threadId]))[0]:null}async addComment(comment){return this._dataSource?this._dataSource.addComment(comment):comment}async updateComment(comment){return this._dataSource?this._dataSource.updateComment(comment):!0}async resolveComment(comment){return this._dataSource?this._dataSource.resolveComment(comment):!0}async deleteComment(unitId,subUnitId,threadId,commentId){return this._dataSource?this._dataSource.deleteComment(unitId,subUnitId,threadId,commentId):!0}async listThreadComments(unitId,subUnitId,threadIds){return this.dataSource?this.dataSource.listComments(unitId,subUnitId,threadIds):[]}saveToSnapshot(unitComments,unitId){if(this._dataSource){const map={};return Object.keys(unitComments).forEach(subUnitId=>{const comments=unitComments[subUnitId];map[subUnitId]=comments.map(this.dataSource.saveCommentToSnapshot)}),map}return unitComments}};__name(_ThreadCommentDataSourceService,"ThreadCommentDataSourceService");let ThreadCommentDataSourceService=_ThreadCommentDataSourceService;const IThreadCommentDataSourceService=core.createIdentifier("univer.thread-comment.data-source-service");var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2"),_a;exports.ThreadCommentModel=(_a=class extends core.Disposable{constructor(_dataSourceService,_commandService){super();__publicField(this,"_commentsMap",{});__publicField(this,"_commentsTreeMap",new Map);__publicField(this,"_threadMap",new Map);__publicField(this,"_commentUpdate$",new rxjs.Subject);__publicField(this,"_commentsMap$",new rxjs.BehaviorSubject({}));__publicField(this,"commentUpdate$",this._commentUpdate$.asObservable());__publicField(this,"commentMap$",this._commentsMap$.asObservable());this._dataSourceService=_dataSourceService,this._commandService=_commandService,this.disposeWithMe(()=>{this._commentUpdate$.complete(),this._commentsMap$.complete()})}_ensureCommentMap(unitId,subUnitId){let unitMap=this._commentsMap[unitId];unitMap||(unitMap={},this._commentsMap[unitId]=unitMap);let subUnitMap=unitMap[subUnitId];return subUnitMap||(subUnitMap={},unitMap[subUnitId]=subUnitMap),subUnitMap}_ensureCommentChildrenMap(unitId,subUnitId){let unitMap=this._commentsTreeMap.get(unitId);unitMap||(unitMap=new Map,this._commentsTreeMap.set(unitId,unitMap));let subUnitMap=unitMap.get(subUnitId);return subUnitMap||(subUnitMap=new Map,unitMap.set(subUnitId,subUnitMap)),subUnitMap}_ensureThreadMap(unitId){let unitMap=this._threadMap.get(unitId);return unitMap||(unitMap=new Map,this._threadMap.set(unitId,unitMap)),unitMap}_refreshCommentsMap$(){this._commentsMap$.next({...this._commentsMap})}ensureMap(unitId,subUnitId){const commentMap=this._ensureCommentMap(unitId,subUnitId),commentChildrenMap=this._ensureCommentChildrenMap(unitId,subUnitId);return{commentMap,commentChildrenMap}}_replaceComment(unitId,subUnitId,comment){var _a4;const{commentMap,commentChildrenMap}=this.ensureMap(unitId,subUnitId),currentComment=commentMap[comment.id];if(currentComment){const newComment={...comment,ref:currentComment.ref};commentMap[comment.id]=newComment,(_a4=comment.children)==null||_a4.forEach(child=>{commentMap[child.id]={...child,ref:""}}),commentChildrenMap.set(comment.id,newComment),this._commentUpdate$.next({unitId,subUnitId,type:"syncUpdate",payload:newComment}),!!comment.resolved!=!!currentComment.resolved&&this._commentUpdate$.next({unitId,subUnitId,type:"resolve",payload:{commentId:comment.id,resolved:!!comment.resolved}})}}async syncThreadComments(unitId,subUnitId,threadIds){const comments=await this._dataSourceService.listThreadComments(unitId,subUnitId,threadIds);if(!comments.length)return;const deleteThreads=new Set(threadIds);comments.forEach(comment=>{this._replaceComment(unitId,subUnitId,comment),deleteThreads.delete(comment.threadId)}),deleteThreads.forEach(id=>{const thread=this.getThread(unitId,id);thread&&this.deleteComment(thread.unitId,thread.subUnitId,thread.id)}),this._refreshCommentsMap$()}addComment(unitId,subUnitId,origin,shouldSync){var _a4,_b;const{commentMap,commentChildrenMap}=this.ensureMap(unitId,subUnitId),comment=origin,addCommentItem=__name(item=>{commentMap[item.id]=item,this._commentUpdate$.next({unitId,subUnitId,type:"add",payload:item,isRoot:!item.parentId})},"addCommentItem"),parentId=comment.parentId;if(parentId){const parent=commentMap[parentId];parent.children=[...(_a4=parent.children)!=null?_a4:[],comment],addCommentItem(comment)}else commentChildrenMap.set(comment.id,comment),this._ensureThreadMap(unitId).set(comment.threadId,comment),addCommentItem(comment),(_b=comment.children)==null||_b.forEach(child=>addCommentItem({...child,ref:""}));return this._refreshCommentsMap$(),shouldSync&&this.syncThreadComments(unitId,subUnitId,[comment.threadId]),!0}updateComment(unitId,subUnitId,payload,silent){const{commentMap}=this.ensureMap(unitId,subUnitId),oldComment=commentMap[payload.commentId];return oldComment?(oldComment.updated=!0,oldComment.text=payload.text,oldComment.attachments=payload.attachments,oldComment.updateT=payload.updateT,this._commentUpdate$.next({unitId,subUnitId,type:"update",payload,silent}),this._refreshCommentsMap$(),!0):!1}updateCommentRef(unitId,subUnitId,payload,silent){const{commentMap}=this.ensureMap(unitId,subUnitId),oldComment=commentMap[payload.commentId];return oldComment?(oldComment.ref=payload.ref,this._commentUpdate$.next({unitId,subUnitId,type:"updateRef",payload,silent}),this._refreshCommentsMap$(),!0):!1}resolveComment(unitId,subUnitId,commentId,resolved){const{commentMap}=this.ensureMap(unitId,subUnitId),oldComment=commentMap[commentId];return oldComment?(oldComment.resolved=resolved,this._commentUpdate$.next({unitId,subUnitId,type:"resolve",payload:{commentId,resolved}}),this._refreshCommentsMap$(),!0):!1}getComment(unitId,subUnitId,commentId){const{commentMap}=this.ensureMap(unitId,subUnitId);return commentMap[commentId]}getComment$(unitId,subUnitId,commentId){return this._commentsMap$.pipe(rxjs.map(records=>records[unitId][subUnitId][commentId]))}getCommentWithChildren(unitId,subUnitId,commentId){var _a4,_b;const{commentMap,commentChildrenMap}=this.ensureMap(unitId,subUnitId),current=commentMap[commentId];if(!current)return;const relativeUsers=new Set,root=commentChildrenMap.get(commentId);if(root)return[root,...(_a4=root.children)!=null?_a4:[]].forEach(comment=>{var _a5;relativeUsers.add(comment.personId),(_a5=comment.text.customRanges)==null||_a5.forEach(range=>{range.rangeType===core.CustomRangeType.MENTION&&relativeUsers.add(range.rangeId)})}),{root:current,children:(_b=root.children)!=null?_b:[],relativeUsers}}deleteComment(unitId,subUnitId,commentId){var _a4;const{commentMap,commentChildrenMap}=this.ensureMap(unitId,subUnitId),current=commentMap[commentId];if(!current)return!0;if(current.parentId){const root=commentChildrenMap.get(current.parentId);if(root&&root.children){const index=root.children.findIndex(comment=>comment.id===commentId);root.children.splice(index,1)}delete commentMap[commentId]}else{delete commentMap[commentId];const comment=commentChildrenMap.get(commentId);commentChildrenMap.delete(commentId),this._ensureThreadMap(unitId).delete(current.threadId),(_a4=comment==null?void 0:comment.children)==null||_a4.forEach(child=>{delete commentMap[child.id],this._commentUpdate$.next({unitId,subUnitId,type:"delete",payload:{commentId:child.id,isRoot:!1,comment:child}})})}return this._commentUpdate$.next({unitId,subUnitId,type:"delete",payload:{commentId,isRoot:!current.parentId,comment:current}}),this._refreshCommentsMap$(),!0}getUnit(unitId){const unitMap=this._commentsMap[unitId];return unitMap?Array.from(Object.entries(unitMap)).map(([subUnitId,subUnitMap])=>[subUnitId,Array.from(Object.values(subUnitMap))]):[]}deleteUnit(unitId){const unitMap=this._commentsMap[unitId];unitMap&&Object.entries(unitMap).forEach(([subUnitId,subUnitMap])=>{Object.values(subUnitMap).forEach(comment=>{this.deleteComment(unitId,subUnitId,comment.id)})})}getRootCommentIds(unitId,subUnitId){const commentChildrenMap=this._ensureCommentChildrenMap(unitId,subUnitId);return Array.from(commentChildrenMap.keys())}getAll(){return this._commentsMap}getThread(unitId,threadId){return this._ensureThreadMap(unitId).get(threadId)}},__name(_a,"ThreadCommentModel"),_a);exports.ThreadCommentModel=__decorateClass$2([__decorateParam$2(0,core.Inject(IThreadCommentDataSourceService)),__decorateParam$2(1,core.ICommandService)],exports.ThreadCommentModel);var I=(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))(I||{});const TC_PLUGIN_NAME="UNIVER_THREAD_COMMENT_PLUGIN";var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1"),_a2;exports.ThreadCommentResourceController=(_a2=class extends core.Disposable{constructor(_resourceManagerService,_threadCommentModel,_threadCommentDataSourceService){super(),this._resourceManagerService=_resourceManagerService,this._threadCommentModel=_threadCommentModel,this._threadCommentDataSourceService=_threadCommentDataSourceService,this._initSnapshot()}_initSnapshot(){const toJson=__name(unitID=>{const map=this._threadCommentModel.getUnit(unitID),resultMap={};return map?(map.forEach(([key,v])=>{resultMap[key]=v}),JSON.stringify(this._threadCommentDataSourceService.saveToSnapshot(resultMap,unitID))):""},"toJson"),parseJson=__name(json=>{if(!json)return{};try{return JSON.parse(json)}catch{return{}}},"parseJson");this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:`SHEET_${TC_PLUGIN_NAME}`,businesses:[I.UNIVER_SHEET,I.UNIVER_DOC],toJson:__name(unitID=>toJson(unitID),"toJson"),parseJson:__name(json=>parseJson(json),"parseJson"),onUnLoad:__name(unitID=>{this._threadCommentModel.deleteUnit(unitID)},"onUnLoad"),onLoad:__name(async(unitID,value)=>{Object.keys(value).forEach(subunitId=>{const commentList=value[subunitId];commentList.forEach(comment=>{this._threadCommentModel.addComment(unitID,subunitId,comment)}),this._threadCommentModel.syncThreadComments(unitID,subunitId,commentList.map(i=>i.threadId))})},"onLoad")}))}},__name(_a2,"ThreadCommentResourceController"),_a2);exports.ThreadCommentResourceController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,exports.ThreadCommentResourceController),__decorateParam$1(0,core.IResourceManagerService),__decorateParam$1(1,core.Inject(exports.ThreadCommentModel)),__decorateParam$1(2,IThreadCommentDataSourceService)],exports.ThreadCommentResourceController);const AddCommentMutation={id:"thread-comment.mutation.add-comment",type:core.CommandType.MUTATION,handler(accessor,params,options){if(!params)return!1;const threadCommentModel=accessor.get(exports.ThreadCommentModel),{unitId,subUnitId,comment,sync}=params,shouldSync=sync||(options==null?void 0:options.fromChangeset)&&!comment.parentId;return threadCommentModel.addComment(unitId,subUnitId,comment,shouldSync)}},UpdateCommentMutation={id:"thread-comment.mutation.update-comment",type:core.CommandType.MUTATION,handler(accessor,params){if(!params)return!1;const threadCommentModel=accessor.get(exports.ThreadCommentModel),{unitId,subUnitId,payload,silent}=params;return threadCommentModel.updateComment(unitId,subUnitId,payload,silent)}},UpdateCommentRefMutation={id:"thread-comment.mutation.update-comment-ref",type:core.CommandType.MUTATION,handler(accessor,params){if(!params)return!1;const threadCommentModel=accessor.get(exports.ThreadCommentModel),{unitId,subUnitId,payload,silent}=params;return threadCommentModel.updateCommentRef(unitId,subUnitId,payload,silent)}},ResolveCommentMutation={id:"thread-comment.mutation.resolve-comment",type:core.CommandType.MUTATION,handler(accessor,params){if(!params)return!1;const threadCommentModel=accessor.get(exports.ThreadCommentModel),{unitId,subUnitId,resolved,commentId}=params;return threadCommentModel.resolveComment(unitId,subUnitId,commentId,resolved)}},DeleteCommentMutation={id:"thread-comment.mutation.delete-comment",type:core.CommandType.MUTATION,handler(accessor,params){if(!params)return!1;const threadCommentModel=accessor.get(exports.ThreadCommentModel),{unitId,subUnitId,commentId}=params;return threadCommentModel.deleteComment(unitId,subUnitId,commentId)}},AddCommentCommand={id:"thread-comment.command.add-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const commandService=accessor.get(core.ICommandService),dataSourceService=accessor.get(IThreadCommentDataSourceService),{comment:originComment}=params,comment=await dataSourceService.addComment(originComment),syncUpdateMutationToColla=dataSourceService.syncUpdateMutationToColla,isRoot=!originComment.parentId,redo={id:AddCommentMutation.id,params:{...params,comment}};return isRoot?await commandService.executeCommand(redo.id,redo.params):commandService.executeCommand(redo.id,redo.params,{onlyLocal:!syncUpdateMutationToColla})}},UpdateCommentCommand={id:"thread-comment.command.update-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const{unitId,subUnitId,payload}=params,commandService=accessor.get(core.ICommandService),threadCommentModel=accessor.get(exports.ThreadCommentModel),dataSourceService=accessor.get(IThreadCommentDataSourceService),syncUpdateMutationToColla=dataSourceService.syncUpdateMutationToColla,current=threadCommentModel.getComment(unitId,subUnitId,payload.commentId);if(!current)return!1;const{children,...currentComment}=current;if(!await dataSourceService.updateComment({...currentComment,...payload}))return!1;const redo={id:UpdateCommentMutation.id,params};return commandService.executeCommand(redo.id,redo.params,{onlyLocal:!syncUpdateMutationToColla}),!0}},ResolveCommentCommand={id:"thread-comment.command.resolve-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const{unitId,subUnitId,resolved,commentId}=params,dataSourceService=accessor.get(IThreadCommentDataSourceService),currentComment=accessor.get(exports.ThreadCommentModel).getComment(unitId,subUnitId,commentId),syncUpdateMutationToColla=dataSourceService.syncUpdateMutationToColla;return!currentComment||!await dataSourceService.resolveComment({...currentComment,resolved})?!1:accessor.get(core.ICommandService).executeCommand(ResolveCommentMutation.id,params,{onlyLocal:!syncUpdateMutationToColla})}},DeleteCommentCommand={id:"thread-comment.command.delete-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const threadCommentModel=accessor.get(exports.ThreadCommentModel),dataSourceService=accessor.get(IThreadCommentDataSourceService),commandService=accessor.get(core.ICommandService),{unitId,subUnitId,commentId}=params,syncUpdateMutationToColla=dataSourceService.syncUpdateMutationToColla,comment=threadCommentModel.getComment(unitId,subUnitId,commentId);if(!comment||!await dataSourceService.deleteComment(unitId,subUnitId,comment.threadId,commentId))return!1;const redo={id:DeleteCommentMutation.id,params};return commandService.executeCommand(redo.id,redo.params,{onlyLocal:!syncUpdateMutationToColla})}},DeleteCommentTreeCommand={id:"thread-comment.command.delete-comment-tree",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const threadCommentModel=accessor.get(exports.ThreadCommentModel),commandService=accessor.get(core.ICommandService),dataSourceService=accessor.get(IThreadCommentDataSourceService),{unitId,subUnitId,commentId}=params,commentWithChildren=threadCommentModel.getCommentWithChildren(unitId,subUnitId,commentId);return!commentWithChildren||!await dataSourceService.deleteComment(unitId,subUnitId,commentWithChildren.root.threadId,commentId)?!1:await commandService.executeCommand(DeleteCommentMutation.id,{unitId,subUnitId,commentId:commentWithChildren.root.id})}},PLUGIN_CONFIG_KEY="thread-comment.config",defaultPluginConfig={};var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),_a3;exports.UniverThreadCommentPlugin=(_a3=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_commandService,_configService){super(),this._config=_config,this._injector=_injector,this._commandService=_commandService,this._configService=_configService;const{...rest}=this._config;this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){var _a4;core.mergeOverrideWithDependencies([[IThreadCommentDataSourceService,{useClass:ThreadCommentDataSourceService}],[exports.ThreadCommentModel],[exports.ThreadCommentResourceController]],(_a4=this._config)==null?void 0:_a4.overrides).forEach(d=>{this._injector.add(d)}),[AddCommentCommand,UpdateCommentCommand,DeleteCommentCommand,ResolveCommentCommand,DeleteCommentTreeCommand,AddCommentMutation,UpdateCommentMutation,UpdateCommentRefMutation,DeleteCommentMutation,ResolveCommentMutation].forEach(command=>{this._commandService.registerCommand(command)})}},__name(_a3,"UniverThreadCommentPlugin"),__publicField(_a3,"pluginName",TC_PLUGIN_NAME),__publicField(_a3,"type",core.UniverInstanceType.UNIVER_UNKNOWN),_a3);exports.UniverThreadCommentPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.ICommandService),__decorateParam(3,core.IConfigService)],exports.UniverThreadCommentPlugin);exports.AddCommentCommand=AddCommentCommand;exports.AddCommentMutation=AddCommentMutation;exports.DeleteCommentCommand=DeleteCommentCommand;exports.DeleteCommentMutation=DeleteCommentMutation;exports.DeleteCommentTreeCommand=DeleteCommentTreeCommand;exports.IThreadCommentDataSourceService=IThreadCommentDataSourceService;exports.ResolveCommentCommand=ResolveCommentCommand;exports.ResolveCommentMutation=ResolveCommentMutation;exports.TC_PLUGIN_NAME=TC_PLUGIN_NAME;exports.ThreadCommentDataSourceService=ThreadCommentDataSourceService;exports.UpdateCommentCommand=UpdateCommentCommand;exports.UpdateCommentMutation=UpdateCommentMutation;exports.UpdateCommentRefMutation=UpdateCommentRefMutation;
1
+ 'use strict';const _0x313bc5=_0x3aa0;(function(_0x11a1a1,_0x3965c8){const _0x32081b=_0x3aa0,_0x4379ad=_0x11a1a1();while(!![]){try{const _0x30f7d9=-parseInt(_0x32081b(0x1c0))/0x1*(parseInt(_0x32081b(0x1dd))/0x2)+-parseInt(_0x32081b(0x1a7))/0x3*(parseInt(_0x32081b(0x191))/0x4)+-parseInt(_0x32081b(0x1f3))/0x5*(-parseInt(_0x32081b(0x21e))/0x6)+parseInt(_0x32081b(0x1ed))/0x7+-parseInt(_0x32081b(0x213))/0x8+-parseInt(_0x32081b(0x1c2))/0x9+parseInt(_0x32081b(0x214))/0xa*(parseInt(_0x32081b(0x1f9))/0xb);if(_0x30f7d9===_0x3965c8)break;else _0x4379ad['push'](_0x4379ad['shift']());}catch(_0x1f1df7){_0x4379ad['push'](_0x4379ad['shift']());}}}(_0x3bba,0x56efc));var __defProp=Object['defineProperty'],__defNormalProp=(_0x344a73,_0x130398,_0x32be89)=>_0x130398 in _0x344a73?__defProp(_0x344a73,_0x130398,{'enumerable':!0x0,'configurable':!0x0,'writable':!0x0,'value':_0x32be89}):_0x344a73[_0x130398]=_0x32be89,__name=(_0x4a4bd4,_0x177a5d)=>__defProp(_0x4a4bd4,_0x313bc5(0x1e8),{'value':_0x177a5d,'configurable':!0x0}),__publicField=(_0x390820,_0x1f22c8,_0x16a9ea)=>__defNormalProp(_0x390820,typeof _0x1f22c8!=_0x313bc5(0x1de)?_0x1f22c8+'':_0x1f22c8,_0x16a9ea);Object[_0x313bc5(0x1f0)](exports,Symbol['toStringTag'],{'value':_0x313bc5(0x21b)});const core=require(_0x313bc5(0x1b2)),rxjs=require(_0x313bc5(0x1c9)),_ThreadCommentDataSourceService=class _ThreadCommentDataSourceService extends core['Disposable']{constructor(){const _0x16bc50=_0x313bc5;super(),__publicField(this,'_dataSource',null),__publicField(this,_0x16bc50(0x216),!0x0);}set[_0x313bc5(0x192)](_0x6a7092){const _0x270f9b=_0x313bc5;this[_0x270f9b(0x1c4)]=_0x6a7092;}get['dataSource'](){return this['_dataSource'];}async[_0x313bc5(0x220)](_0x147e42,_0xd4aa76,_0x2e0778){const _0x4d5896=_0x313bc5;return this['_dataSource']?(await this['_dataSource'][_0x4d5896(0x1e6)](_0x147e42,_0xd4aa76,[_0x2e0778]))[0x0]:null;}async[_0x313bc5(0x186)](_0x51fb82){const _0x9e8719=_0x313bc5;return this[_0x9e8719(0x1c4)]?this[_0x9e8719(0x1c4)]['addComment'](_0x51fb82):_0x51fb82;}async[_0x313bc5(0x1fe)](_0x1d0e37){const _0xdfcde=_0x313bc5;return this[_0xdfcde(0x1c4)]?this[_0xdfcde(0x1c4)][_0xdfcde(0x1fe)](_0x1d0e37):!0x0;}async[_0x313bc5(0x1d8)](_0xceee6){const _0x48d5ea=_0x313bc5;return this[_0x48d5ea(0x1c4)]?this[_0x48d5ea(0x1c4)]['resolveComment'](_0xceee6):!0x0;}async[_0x313bc5(0x204)](_0x293137,_0x3c674d,_0x44d3c1,_0x3be23d){const _0x1600cd=_0x313bc5;return this[_0x1600cd(0x1c4)]?this[_0x1600cd(0x1c4)][_0x1600cd(0x204)](_0x293137,_0x3c674d,_0x44d3c1,_0x3be23d):!0x0;}async[_0x313bc5(0x1a6)](_0x53f290,_0x4bcd31,_0x20d698){const _0x9a14e=_0x313bc5;return this['dataSource']?this[_0x9a14e(0x192)][_0x9a14e(0x1e6)](_0x53f290,_0x4bcd31,_0x20d698):[];}['saveToSnapshot'](_0x463cb7,_0x1da985){const _0x529390=_0x313bc5;if(this[_0x529390(0x1c4)]){const _0x1c7cdb={};return Object[_0x529390(0x1a1)](_0x463cb7)[_0x529390(0x211)](_0x184c08=>{const _0x26972c=_0x529390,_0x4e09d1=_0x463cb7[_0x184c08];_0x1c7cdb[_0x184c08]=_0x4e09d1[_0x26972c(0x188)](this[_0x26972c(0x192)][_0x26972c(0x219)]);}),_0x1c7cdb;}return _0x463cb7;}};function _0x3aa0(_0x45df55,_0x16c158){const _0x3bba78=_0x3bba();return _0x3aa0=function(_0x3aa0d5,_0x101c32){_0x3aa0d5=_0x3aa0d5-0x185;let _0x33c953=_0x3bba78[_0x3aa0d5];return _0x33c953;},_0x3aa0(_0x45df55,_0x16c158);}__name(_ThreadCommentDataSourceService,_0x313bc5(0x20f));let ThreadCommentDataSourceService=_ThreadCommentDataSourceService;const IThreadCommentDataSourceService=core[_0x313bc5(0x1d9)](_0x313bc5(0x203));var __defProp$2=Object[_0x313bc5(0x1f0)],__getOwnPropDesc$2=Object['getOwnPropertyDescriptor'],__decorateClass$2=__name((_0x5e7539,_0x52572c,_0x2e848b,_0x31f0b5)=>{for(var _0x4c7d88=_0x31f0b5>0x1?void 0x0:_0x31f0b5?__getOwnPropDesc$2(_0x52572c,_0x2e848b):_0x52572c,_0x146793=_0x5e7539['length']-0x1,_0xf27084;_0x146793>=0x0;_0x146793--)(_0xf27084=_0x5e7539[_0x146793])&&(_0x4c7d88=(_0x31f0b5?_0xf27084(_0x52572c,_0x2e848b,_0x4c7d88):_0xf27084(_0x4c7d88))||_0x4c7d88);return _0x31f0b5&&_0x4c7d88&&__defProp$2(_0x52572c,_0x2e848b,_0x4c7d88),_0x4c7d88;},_0x313bc5(0x1e1)),__decorateParam$2=__name((_0x34a76f,_0x155472)=>(_0x1eec87,_0x2f2741)=>_0x155472(_0x1eec87,_0x2f2741,_0x34a76f),_0x313bc5(0x18f)),_a;exports[_0x313bc5(0x196)]=(_a=class extends core[_0x313bc5(0x1fa)]{constructor(_0x505e45,_0x2cc8bc){const _0x2157e3=_0x313bc5;super(),__publicField(this,'_commentsMap',{}),__publicField(this,_0x2157e3(0x189),new Map()),__publicField(this,_0x2157e3(0x1e0),new Map()),__publicField(this,'_commentUpdate$',new rxjs[(_0x2157e3(0x210))]()),__publicField(this,_0x2157e3(0x1eb),new rxjs['BehaviorSubject']({})),__publicField(this,_0x2157e3(0x1cf),this[_0x2157e3(0x1be)][_0x2157e3(0x20a)]()),__publicField(this,_0x2157e3(0x1c1),this['_commentsMap$']['asObservable']()),(this[_0x2157e3(0x1a2)]=_0x505e45,this['_commandService']=_0x2cc8bc,this[_0x2157e3(0x1b5)](()=>{const _0x4f1211=_0x2157e3;this['_commentUpdate$']['complete'](),this[_0x4f1211(0x1eb)][_0x4f1211(0x19c)]();}));}[_0x313bc5(0x1bd)](_0x287d15,_0x33887c){const _0x4b17ae=_0x313bc5;let _0x294e4c=this[_0x4b17ae(0x1ba)][_0x287d15];_0x294e4c||(_0x294e4c={},this[_0x4b17ae(0x1ba)][_0x287d15]=_0x294e4c);let _0x35585e=_0x294e4c[_0x33887c];return _0x35585e||(_0x35585e={},_0x294e4c[_0x33887c]=_0x35585e),_0x35585e;}[_0x313bc5(0x1c5)](_0x5334f8,_0x54e3a4){const _0x53e437=_0x313bc5;let _0x1df1b8=this['_commentsTreeMap']['get'](_0x5334f8);_0x1df1b8||(_0x1df1b8=new Map(),this[_0x53e437(0x189)][_0x53e437(0x212)](_0x5334f8,_0x1df1b8));let _0x43f84b=_0x1df1b8['get'](_0x54e3a4);return _0x43f84b||(_0x43f84b=new Map(),_0x1df1b8[_0x53e437(0x212)](_0x54e3a4,_0x43f84b)),_0x43f84b;}[_0x313bc5(0x1db)](_0x94758b){const _0x17413b=_0x313bc5;let _0x2a3e28=this[_0x17413b(0x1e0)][_0x17413b(0x1b9)](_0x94758b);return _0x2a3e28||(_0x2a3e28=new Map(),this[_0x17413b(0x1e0)][_0x17413b(0x212)](_0x94758b,_0x2a3e28)),_0x2a3e28;}[_0x313bc5(0x1cd)](){const _0x3294e1=_0x313bc5;this[_0x3294e1(0x1eb)][_0x3294e1(0x19f)]({...this['_commentsMap']});}[_0x313bc5(0x1ef)](_0x153841,_0x4d5a99){const _0x983592=_0x313bc5,_0x7efaf5=this[_0x983592(0x1bd)](_0x153841,_0x4d5a99),_0x4808b9=this['_ensureCommentChildrenMap'](_0x153841,_0x4d5a99);return{'commentMap':_0x7efaf5,'commentChildrenMap':_0x4808b9};}[_0x313bc5(0x1e4)](_0x531af6,_0x541fb9,_0xfbae22){const _0x1fa873=_0x313bc5;var _0x1a4219;const {commentMap:_0x262416,commentChildrenMap:_0x13a3d0}=this[_0x1fa873(0x1ef)](_0x531af6,_0x541fb9),_0x45f47b=_0x262416[_0xfbae22['id']];if(_0x45f47b){const _0x324417={..._0xfbae22,'ref':_0x45f47b[_0x1fa873(0x1b0)]};_0x262416[_0xfbae22['id']]=_0x324417,(_0x1a4219=_0xfbae22[_0x1fa873(0x18a)])==null||_0x1a4219[_0x1fa873(0x211)](_0xf602cc=>{_0x262416[_0xf602cc['id']]={..._0xf602cc,'ref':''};}),_0x13a3d0[_0x1fa873(0x212)](_0xfbae22['id'],_0x324417),this[_0x1fa873(0x1be)][_0x1fa873(0x19f)]({'unitId':_0x531af6,'subUnitId':_0x541fb9,'type':_0x1fa873(0x1da),'payload':_0x324417}),!!_0xfbae22[_0x1fa873(0x18e)]!=!!_0x45f47b['resolved']&&this['_commentUpdate$']['next']({'unitId':_0x531af6,'subUnitId':_0x541fb9,'type':_0x1fa873(0x1d5),'payload':{'commentId':_0xfbae22['id'],'resolved':!!_0xfbae22[_0x1fa873(0x18e)]}});}}async['syncThreadComments'](_0x409d16,_0x47c8bd,_0x11eebf){const _0x37d105=_0x313bc5,_0x13a97c=await this[_0x37d105(0x1a2)][_0x37d105(0x1a6)](_0x409d16,_0x47c8bd,_0x11eebf);if(!_0x13a97c[_0x37d105(0x1ee)])return;const _0xf9e86e=new Set(_0x11eebf);_0x13a97c['forEach'](_0x1df107=>{const _0xafaeea=_0x37d105;this['_replaceComment'](_0x409d16,_0x47c8bd,_0x1df107),_0xf9e86e[_0xafaeea(0x1d1)](_0x1df107[_0xafaeea(0x1dc)]);}),_0xf9e86e['forEach'](_0x59fe1e=>{const _0x4b8fd6=_0x37d105,_0x1a1c69=this[_0x4b8fd6(0x1cc)](_0x409d16,_0x59fe1e);_0x1a1c69&&this[_0x4b8fd6(0x204)](_0x1a1c69[_0x4b8fd6(0x21f)],_0x1a1c69[_0x4b8fd6(0x1ac)],_0x1a1c69['id']);}),this[_0x37d105(0x1cd)]();}[_0x313bc5(0x186)](_0x3ebc29,_0x59df78,_0x5d5112,_0x16d24a){const _0x2dc636=_0x313bc5;var _0x5d5f62,_0x15e94a;const {commentMap:_0x45eaec,commentChildrenMap:_0x32bc8a}=this[_0x2dc636(0x1ef)](_0x3ebc29,_0x59df78),_0x56fd85=_0x5d5112,_0x505c63=__name(_0x217d41=>{const _0x39226a=_0x2dc636;_0x45eaec[_0x217d41['id']]=_0x217d41,this[_0x39226a(0x1be)][_0x39226a(0x19f)]({'unitId':_0x3ebc29,'subUnitId':_0x59df78,'type':_0x39226a(0x218),'payload':_0x217d41,'isRoot':!_0x217d41[_0x39226a(0x1ad)]});},'addCommentItem'),_0x48d8f2=_0x56fd85[_0x2dc636(0x1ad)];if(_0x48d8f2){const _0x26507f=_0x45eaec[_0x48d8f2];_0x26507f[_0x2dc636(0x18a)]=[...(_0x5d5f62=_0x26507f['children'])!=null?_0x5d5f62:[],_0x56fd85],_0x505c63(_0x56fd85);}else _0x32bc8a[_0x2dc636(0x212)](_0x56fd85['id'],_0x56fd85),this[_0x2dc636(0x1db)](_0x3ebc29)['set'](_0x56fd85[_0x2dc636(0x1dc)],_0x56fd85),_0x505c63(_0x56fd85),(_0x15e94a=_0x56fd85[_0x2dc636(0x18a)])==null||_0x15e94a[_0x2dc636(0x211)](_0xb1a96d=>_0x505c63({..._0xb1a96d,'ref':''}));return this['_refreshCommentsMap$'](),_0x16d24a&&this[_0x2dc636(0x201)](_0x3ebc29,_0x59df78,[_0x56fd85[_0x2dc636(0x1dc)]]),!0x0;}[_0x313bc5(0x1fe)](_0x36eb51,_0x4d46f4,_0x4bf90d,_0x19e40d){const _0x41d2af=_0x313bc5,{commentMap:_0x2c11ee}=this[_0x41d2af(0x1ef)](_0x36eb51,_0x4d46f4),_0x491382=_0x2c11ee[_0x4bf90d[_0x41d2af(0x1b3)]];return _0x491382?(_0x491382[_0x41d2af(0x1bb)]=!0x0,_0x491382[_0x41d2af(0x1fc)]=_0x4bf90d[_0x41d2af(0x1fc)],_0x491382['attachments']=_0x4bf90d[_0x41d2af(0x19d)],_0x491382[_0x41d2af(0x18d)]=_0x4bf90d[_0x41d2af(0x18d)],this[_0x41d2af(0x1be)][_0x41d2af(0x19f)]({'unitId':_0x36eb51,'subUnitId':_0x4d46f4,'type':_0x41d2af(0x1b1),'payload':_0x4bf90d,'silent':_0x19e40d}),this[_0x41d2af(0x1cd)](),!0x0):!0x1;}['updateCommentRef'](_0x181208,_0x5432cb,_0x595cc8,_0x57e413){const _0x1030d8=_0x313bc5,{commentMap:_0x162852}=this['ensureMap'](_0x181208,_0x5432cb),_0x9d19d9=_0x162852[_0x595cc8[_0x1030d8(0x1b3)]];return _0x9d19d9?(_0x9d19d9[_0x1030d8(0x1b0)]=_0x595cc8['ref'],this[_0x1030d8(0x1be)]['next']({'unitId':_0x181208,'subUnitId':_0x5432cb,'type':'updateRef','payload':_0x595cc8,'silent':_0x57e413}),this[_0x1030d8(0x1cd)](),!0x0):!0x1;}[_0x313bc5(0x1d8)](_0x5b9344,_0x58e03e,_0x1d55c6,_0x1842ca){const _0x338254=_0x313bc5,{commentMap:_0x3214ab}=this[_0x338254(0x1ef)](_0x5b9344,_0x58e03e),_0x3e66ab=_0x3214ab[_0x1d55c6];return _0x3e66ab?(_0x3e66ab['resolved']=_0x1842ca,this[_0x338254(0x1be)][_0x338254(0x19f)]({'unitId':_0x5b9344,'subUnitId':_0x58e03e,'type':_0x338254(0x1d5),'payload':{'commentId':_0x1d55c6,'resolved':_0x1842ca}}),this[_0x338254(0x1cd)](),!0x0):!0x1;}[_0x313bc5(0x1f8)](_0x2208a4,_0x2620fe,_0x39ed08){const {commentMap:_0x2b7f38}=this['ensureMap'](_0x2208a4,_0x2620fe);return _0x2b7f38[_0x39ed08];}['getComment$'](_0xd94991,_0x562dbd,_0x3e4872){const _0x2629a9=_0x313bc5;return this[_0x2629a9(0x1eb)][_0x2629a9(0x1bf)](rxjs[_0x2629a9(0x188)](_0x2a387e=>_0x2a387e[_0xd94991][_0x562dbd][_0x3e4872]));}[_0x313bc5(0x1fd)](_0x2f91d8,_0x429aa8,_0x569b7d){const _0x4a69f7=_0x313bc5;var _0x1c533a,_0x292e27;const {commentMap:_0x39f0a9,commentChildrenMap:_0x41169b}=this[_0x4a69f7(0x1ef)](_0x2f91d8,_0x429aa8),_0x14e328=_0x39f0a9[_0x569b7d];if(!_0x14e328)return;const _0x495965=new Set(),_0x5f1d31=_0x41169b[_0x4a69f7(0x1b9)](_0x569b7d);if(_0x5f1d31)return[_0x5f1d31,...(_0x1c533a=_0x5f1d31['children'])!=null?_0x1c533a:[]][_0x4a69f7(0x211)](_0x25a31c=>{const _0x4ea5ca=_0x4a69f7;var _0x49b569;_0x495965['add'](_0x25a31c[_0x4ea5ca(0x1ff)]),(_0x49b569=_0x25a31c[_0x4ea5ca(0x1fc)][_0x4ea5ca(0x1ab)])==null||_0x49b569[_0x4ea5ca(0x211)](_0x10e199=>{const _0x4c1f30=_0x4ea5ca;_0x10e199['rangeType']===core['CustomRangeType'][_0x4c1f30(0x209)]&&_0x495965['add'](_0x10e199[_0x4c1f30(0x1af)]);});}),{'root':_0x14e328,'children':(_0x292e27=_0x5f1d31[_0x4a69f7(0x18a)])!=null?_0x292e27:[],'relativeUsers':_0x495965};}['deleteComment'](_0x421f58,_0x188fd2,_0x5962cb){const _0x4df5c1=_0x313bc5;var _0x211931;const {commentMap:_0x3b36bf,commentChildrenMap:_0x49f5ec}=this[_0x4df5c1(0x1ef)](_0x421f58,_0x188fd2),_0x460079=_0x3b36bf[_0x5962cb];if(!_0x460079)return!0x0;if(_0x460079[_0x4df5c1(0x1ad)]){const _0x4d36ec=_0x49f5ec[_0x4df5c1(0x1b9)](_0x460079[_0x4df5c1(0x1ad)]);if(_0x4d36ec&&_0x4d36ec[_0x4df5c1(0x18a)]){const _0x58a50c=_0x4d36ec[_0x4df5c1(0x18a)][_0x4df5c1(0x1f4)](_0x391877=>_0x391877['id']===_0x5962cb);_0x4d36ec['children'][_0x4df5c1(0x1f7)](_0x58a50c,0x1);}delete _0x3b36bf[_0x5962cb];}else{delete _0x3b36bf[_0x5962cb];const _0x22bae2=_0x49f5ec['get'](_0x5962cb);_0x49f5ec['delete'](_0x5962cb),this[_0x4df5c1(0x1db)](_0x421f58)['delete'](_0x460079[_0x4df5c1(0x1dc)]),(_0x211931=_0x22bae2==null?void 0x0:_0x22bae2[_0x4df5c1(0x18a)])==null||_0x211931[_0x4df5c1(0x211)](_0x1f285b=>{const _0xee6884=_0x4df5c1;delete _0x3b36bf[_0x1f285b['id']],this[_0xee6884(0x1be)]['next']({'unitId':_0x421f58,'subUnitId':_0x188fd2,'type':'delete','payload':{'commentId':_0x1f285b['id'],'isRoot':!0x1,'comment':_0x1f285b}});});}return this[_0x4df5c1(0x1be)][_0x4df5c1(0x19f)]({'unitId':_0x421f58,'subUnitId':_0x188fd2,'type':_0x4df5c1(0x1d1),'payload':{'commentId':_0x5962cb,'isRoot':!_0x460079['parentId'],'comment':_0x460079}}),this[_0x4df5c1(0x1cd)](),!0x0;}[_0x313bc5(0x1e9)](_0x5aeffe){const _0x42bf51=_0x313bc5,_0x5daf9a=this[_0x42bf51(0x1ba)][_0x5aeffe];return _0x5daf9a?Array[_0x42bf51(0x1e7)](Object[_0x42bf51(0x1a0)](_0x5daf9a))[_0x42bf51(0x188)](([_0x3d1aae,_0x37b90f])=>[_0x3d1aae,Array['from'](Object['values'](_0x37b90f))]):[];}[_0x313bc5(0x1b8)](_0xa473bc){const _0x4d0c47=_0x313bc5,_0x136918=this['_commentsMap'][_0xa473bc];_0x136918&&Object[_0x4d0c47(0x1a0)](_0x136918)[_0x4d0c47(0x211)](([_0x3dba11,_0x48e7c2])=>{const _0x3860a5=_0x4d0c47;Object[_0x3860a5(0x207)](_0x48e7c2)[_0x3860a5(0x211)](_0x2de6f7=>{this['deleteComment'](_0xa473bc,_0x3dba11,_0x2de6f7['id']);});});}[_0x313bc5(0x21a)](_0x267c39,_0x35ca4e){const _0x21d8e8=_0x313bc5,_0x2b8161=this[_0x21d8e8(0x1c5)](_0x267c39,_0x35ca4e);return Array['from'](_0x2b8161[_0x21d8e8(0x1a1)]());}[_0x313bc5(0x206)](){return this['_commentsMap'];}[_0x313bc5(0x1cc)](_0x4b4366,_0x2017d9){const _0x17f5a3=_0x313bc5;return this[_0x17f5a3(0x1db)](_0x4b4366)[_0x17f5a3(0x1b9)](_0x2017d9);}},__name(_a,_0x313bc5(0x196)),_a),exports['ThreadCommentModel']=__decorateClass$2([__decorateParam$2(0x0,core['Inject'](IThreadCommentDataSourceService)),__decorateParam$2(0x1,core[_0x313bc5(0x221)])],exports[_0x313bc5(0x196)]);var I=(_0x15ee2f=>(_0x15ee2f[_0x15ee2f[_0x313bc5(0x205)]=0x0]=_0x313bc5(0x205),_0x15ee2f[_0x15ee2f[_0x313bc5(0x1c8)]=0x1]=_0x313bc5(0x1c8),_0x15ee2f[_0x15ee2f['UNIVER_SHEET']=0x2]=_0x313bc5(0x195),_0x15ee2f[_0x15ee2f[_0x313bc5(0x199)]=0x3]=_0x313bc5(0x199),_0x15ee2f[_0x15ee2f['UNIVER_PROJECT']=0x4]='UNIVER_PROJECT',_0x15ee2f[_0x15ee2f[_0x313bc5(0x21d)]=-0x1]=_0x313bc5(0x21d),_0x15ee2f))(I||{});const TC_PLUGIN_NAME=_0x313bc5(0x1fb);function _0x3bba(){const _0x23648a=['syncUpdate','_ensureThreadMap','threadId','110cuNvYZ','symbol','SHEET_','_threadMap','__decorateClass$2','pluginName','stringify','_replaceComment','root','listComments','from','name','getUnit','MUTATION','_commentsMap$','__decorateParam$1','659106tuGYof','length','ensureMap','defineProperty','__decorateClass','thread-comment.config','32905dwIpyu','findIndex','updateCommentRef','Plugin','splice','getComment','11DmQGjA','Disposable','UNIVER_THREAD_COMMENT_PLUGIN','text','getCommentWithChildren','updateComment','personId','_config','syncThreadComments','UpdateCommentCommand','univer.thread-comment.data-source-service','deleteComment','UNIVER_UNKNOWN','getAll','values','params','MENTION','asObservable','thread-comment.command.resolve-comment','saveToSnapshot','type','COMMAND','ThreadCommentDataSourceService','Subject','forEach','set','1267272UAVhiQ','15235160MXgixo','_commandService','syncUpdateMutationToColla','ResolveCommentCommand','add','saveCommentToSnapshot','getRootCommentIds','Module','executeCommand','UNRECOGNIZED','12DdiehK','unitId','getThreadComment','ICommandService','_initSnapshot','thread-comment.command.update-comment','addComment','_resourceManagerService','map','_commentsTreeMap','children','_threadCommentDataSourceService','CommandType','updateT','resolved','__decorateParam$2','toJson','19692irapZT','dataSource','onLoad','Injector','UNIVER_SHEET','ThreadCommentModel','UpdateCommentMutation','ResolveCommentMutation','UNIVER_SLIDE','getOwnPropertyDescriptor','thread-comment.mutation.update-comment-ref','complete','attachments','thread-comment.command.delete-comment','next','entries','keys','_dataSourceService','thread-comment.command.add-comment','DeleteCommentCommand','thread-comment.mutation.update-comment','listThreadComments','369Ediaet','overrides','parse','Inject','customRanges','subUnitId','parentId','thread-comment.mutation.delete-comment','rangeId','ref','update','@univerjs/core','commentId','TC_PLUGIN_NAME','disposeWithMe','ThreadCommentResourceController','fromChangeset','deleteUnit','get','_commentsMap','updated','IConfigService','_ensureCommentMap','_commentUpdate$','pipe','4891ykUtuK','commentMap$','2176209DXqgAk','onUnLoad','_dataSource','_ensureCommentChildrenMap','AddCommentCommand','UpdateCommentRefMutation','UNIVER_DOC','rxjs','IResourceManagerService','_injector','getThread','_refreshCommentsMap$','UniverInstanceType','commentUpdate$','UniverThreadCommentPlugin','delete','_threadCommentModel','thread-comment.mutation.resolve-comment','parseJson','resolve','registerCommand','_configService','resolveComment','createIdentifier'];_0x3bba=function(){return _0x23648a;};return _0x3bba();}var __defProp$1=Object['defineProperty'],__getOwnPropDesc$1=Object[_0x313bc5(0x19a)],__decorateClass$1=__name((_0x5c46eb,_0x2a4937,_0x32ffd0,_0x212f24)=>{for(var _0x439386=_0x212f24>0x1?void 0x0:_0x212f24?__getOwnPropDesc$1(_0x2a4937,_0x32ffd0):_0x2a4937,_0x2d3156=_0x5c46eb['length']-0x1,_0x574f28;_0x2d3156>=0x0;_0x2d3156--)(_0x574f28=_0x5c46eb[_0x2d3156])&&(_0x439386=(_0x212f24?_0x574f28(_0x2a4937,_0x32ffd0,_0x439386):_0x574f28(_0x439386))||_0x439386);return _0x212f24&&_0x439386&&__defProp$1(_0x2a4937,_0x32ffd0,_0x439386),_0x439386;},'__decorateClass$1'),__decorateParam$1=__name((_0x3f395c,_0x527752)=>(_0x14d8d9,_0x9f7480)=>_0x527752(_0x14d8d9,_0x9f7480,_0x3f395c),_0x313bc5(0x1ec)),_a2;exports[_0x313bc5(0x1b6)]=(_a2=class extends core['Disposable']{constructor(_0x6d5b73,_0x41a126,_0x469781){const _0x882d64=_0x313bc5;super(),this[_0x882d64(0x187)]=_0x6d5b73,this[_0x882d64(0x1d2)]=_0x41a126,this[_0x882d64(0x18b)]=_0x469781,this[_0x882d64(0x222)]();}[_0x313bc5(0x222)](){const _0xb74aa=_0x313bc5,_0x1f93e4=__name(_0x3abe49=>{const _0x21fd7e=_0x3aa0,_0x78e4ae=this[_0x21fd7e(0x1d2)]['getUnit'](_0x3abe49),_0x57fff0={};return _0x78e4ae?(_0x78e4ae[_0x21fd7e(0x211)](([_0x27ac6c,_0x261067])=>{_0x57fff0[_0x27ac6c]=_0x261067;}),JSON[_0x21fd7e(0x1e3)](this[_0x21fd7e(0x18b)][_0x21fd7e(0x20c)](_0x57fff0,_0x3abe49))):'';},_0xb74aa(0x190)),_0x2bc89f=__name(_0x1f1319=>{const _0x546d4b=_0xb74aa;if(!_0x1f1319)return{};try{return JSON[_0x546d4b(0x1a9)](_0x1f1319);}catch{return{};}},_0xb74aa(0x1d4));this[_0xb74aa(0x1b5)](this[_0xb74aa(0x187)]['registerPluginResource']({'pluginName':_0xb74aa(0x1df)+TC_PLUGIN_NAME,'businesses':[I[_0xb74aa(0x195)],I[_0xb74aa(0x1c8)]],'toJson':__name(_0x75ad66=>_0x1f93e4(_0x75ad66),_0xb74aa(0x190)),'parseJson':__name(_0x4b7e92=>_0x2bc89f(_0x4b7e92),_0xb74aa(0x1d4)),'onUnLoad':__name(_0x3dd5c4=>{this['_threadCommentModel']['deleteUnit'](_0x3dd5c4);},_0xb74aa(0x1c3)),'onLoad':__name(async(_0x5d2d2d,_0x2eb09b)=>{const _0x45fd0d=_0xb74aa;Object[_0x45fd0d(0x1a1)](_0x2eb09b)[_0x45fd0d(0x211)](_0x109584=>{const _0x5a3216=_0x45fd0d,_0x46ac5e=_0x2eb09b[_0x109584];_0x46ac5e[_0x5a3216(0x211)](_0x465f2b=>{const _0x2bd669=_0x5a3216;this[_0x2bd669(0x1d2)][_0x2bd669(0x186)](_0x5d2d2d,_0x109584,_0x465f2b);}),this[_0x5a3216(0x1d2)][_0x5a3216(0x201)](_0x5d2d2d,_0x109584,_0x46ac5e['map'](_0x1df135=>_0x1df135[_0x5a3216(0x1dc)]));});},_0xb74aa(0x193))}));}},__name(_a2,_0x313bc5(0x1b6)),_a2),exports['ThreadCommentResourceController']=__decorateClass$1([__decorateParam$1(0x0,core[_0x313bc5(0x1ca)]),__decorateParam$1(0x1,core[_0x313bc5(0x1aa)](exports['ThreadCommentModel'])),__decorateParam$1(0x2,IThreadCommentDataSourceService)],exports[_0x313bc5(0x1b6)]);const AddCommentMutation={'id':'thread-comment.mutation.add-comment','type':core['CommandType'][_0x313bc5(0x1ea)],'handler'(_0x3b83ee,_0x317ee2,_0x108450){const _0x15b3ea=_0x313bc5;if(!_0x317ee2)return!0x1;const _0x2ea242=_0x3b83ee[_0x15b3ea(0x1b9)](exports[_0x15b3ea(0x196)]),{unitId:_0x28969f,subUnitId:_0x582e1b,comment:_0x575ad6,sync:_0x10916e}=_0x317ee2,_0x463daf=_0x10916e||(_0x108450==null?void 0x0:_0x108450[_0x15b3ea(0x1b7)])&&!_0x575ad6['parentId'];return _0x2ea242[_0x15b3ea(0x186)](_0x28969f,_0x582e1b,_0x575ad6,_0x463daf);}},UpdateCommentMutation={'id':_0x313bc5(0x1a5),'type':core[_0x313bc5(0x18c)][_0x313bc5(0x1ea)],'handler'(_0x217f72,_0x36a5e8){const _0x1ddcf3=_0x313bc5;if(!_0x36a5e8)return!0x1;const _0xb23bff=_0x217f72[_0x1ddcf3(0x1b9)](exports['ThreadCommentModel']),{unitId:_0x288272,subUnitId:_0x49daa0,payload:_0x3c8aa8,silent:_0x338ae5}=_0x36a5e8;return _0xb23bff[_0x1ddcf3(0x1fe)](_0x288272,_0x49daa0,_0x3c8aa8,_0x338ae5);}},UpdateCommentRefMutation={'id':_0x313bc5(0x19b),'type':core[_0x313bc5(0x18c)][_0x313bc5(0x1ea)],'handler'(_0x3ba0c9,_0x44d986){const _0x361b74=_0x313bc5;if(!_0x44d986)return!0x1;const _0x2dfcbf=_0x3ba0c9[_0x361b74(0x1b9)](exports['ThreadCommentModel']),{unitId:_0x5b4589,subUnitId:_0x8e6c73,payload:_0x9c24b,silent:_0x333f35}=_0x44d986;return _0x2dfcbf[_0x361b74(0x1f5)](_0x5b4589,_0x8e6c73,_0x9c24b,_0x333f35);}},ResolveCommentMutation={'id':_0x313bc5(0x1d3),'type':core['CommandType'][_0x313bc5(0x1ea)],'handler'(_0x3549fa,_0x1fdc0){const _0x18cd04=_0x313bc5;if(!_0x1fdc0)return!0x1;const _0x40bd7c=_0x3549fa[_0x18cd04(0x1b9)](exports[_0x18cd04(0x196)]),{unitId:_0x4f32f5,subUnitId:_0x20cc9a,resolved:_0x358a44,commentId:_0x1671fe}=_0x1fdc0;return _0x40bd7c['resolveComment'](_0x4f32f5,_0x20cc9a,_0x1671fe,_0x358a44);}},DeleteCommentMutation={'id':_0x313bc5(0x1ae),'type':core[_0x313bc5(0x18c)]['MUTATION'],'handler'(_0x593751,_0x1f2348){const _0x172344=_0x313bc5;if(!_0x1f2348)return!0x1;const _0x3f7dc3=_0x593751['get'](exports[_0x172344(0x196)]),{unitId:_0x25a0dd,subUnitId:_0x306818,commentId:_0x17dac9}=_0x1f2348;return _0x3f7dc3[_0x172344(0x204)](_0x25a0dd,_0x306818,_0x17dac9);}},AddCommentCommand={'id':_0x313bc5(0x1a3),'type':core[_0x313bc5(0x18c)]['COMMAND'],async 'handler'(_0xd78584,_0x430c6f){const _0x8c1f2c=_0x313bc5;if(!_0x430c6f)return!0x1;const _0x3e26a3=_0xd78584[_0x8c1f2c(0x1b9)](core[_0x8c1f2c(0x221)]),_0x69bb3c=_0xd78584['get'](IThreadCommentDataSourceService),{comment:_0x4070ec}=_0x430c6f,_0x7b6ba1=await _0x69bb3c[_0x8c1f2c(0x186)](_0x4070ec),_0x2bca28=_0x69bb3c[_0x8c1f2c(0x216)],_0x1cecc9=!_0x4070ec[_0x8c1f2c(0x1ad)],_0x2b7f86={'id':AddCommentMutation['id'],'params':{..._0x430c6f,'comment':_0x7b6ba1}};return _0x1cecc9?await _0x3e26a3[_0x8c1f2c(0x21c)](_0x2b7f86['id'],_0x2b7f86[_0x8c1f2c(0x208)]):_0x3e26a3[_0x8c1f2c(0x21c)](_0x2b7f86['id'],_0x2b7f86[_0x8c1f2c(0x208)],{'onlyLocal':!_0x2bca28});}},UpdateCommentCommand={'id':_0x313bc5(0x185),'type':core[_0x313bc5(0x18c)]['COMMAND'],async 'handler'(_0x445625,_0x6b0988){const _0x239289=_0x313bc5;if(!_0x6b0988)return!0x1;const {unitId:_0x137864,subUnitId:_0x56011,payload:_0x394d6d}=_0x6b0988,_0x7afbcf=_0x445625[_0x239289(0x1b9)](core[_0x239289(0x221)]),_0x12fb48=_0x445625['get'](exports['ThreadCommentModel']),_0x31e3a0=_0x445625[_0x239289(0x1b9)](IThreadCommentDataSourceService),_0x394fdd=_0x31e3a0[_0x239289(0x216)],_0x18e93e=_0x12fb48[_0x239289(0x1f8)](_0x137864,_0x56011,_0x394d6d[_0x239289(0x1b3)]);if(!_0x18e93e)return!0x1;const {children:_0xf6cb06,..._0x571a8f}=_0x18e93e;if(!await _0x31e3a0[_0x239289(0x1fe)]({..._0x571a8f,..._0x394d6d}))return!0x1;const _0x1fc0f4={'id':UpdateCommentMutation['id'],'params':_0x6b0988};return _0x7afbcf[_0x239289(0x21c)](_0x1fc0f4['id'],_0x1fc0f4['params'],{'onlyLocal':!_0x394fdd}),!0x0;}},ResolveCommentCommand={'id':_0x313bc5(0x20b),'type':core['CommandType'][_0x313bc5(0x20e)],async 'handler'(_0x225d29,_0x5efb6d){const _0x50788c=_0x313bc5;if(!_0x5efb6d)return!0x1;const {unitId:_0x607d1a,subUnitId:_0x130890,resolved:_0x3e5bb4,commentId:_0x3e0d15}=_0x5efb6d,_0x386184=_0x225d29[_0x50788c(0x1b9)](IThreadCommentDataSourceService),_0x128fae=_0x225d29[_0x50788c(0x1b9)](exports['ThreadCommentModel'])[_0x50788c(0x1f8)](_0x607d1a,_0x130890,_0x3e0d15),_0x1c77d0=_0x386184['syncUpdateMutationToColla'];return!_0x128fae||!await _0x386184['resolveComment']({..._0x128fae,'resolved':_0x3e5bb4})?!0x1:_0x225d29[_0x50788c(0x1b9)](core[_0x50788c(0x221)])[_0x50788c(0x21c)](ResolveCommentMutation['id'],_0x5efb6d,{'onlyLocal':!_0x1c77d0});}},DeleteCommentCommand={'id':_0x313bc5(0x19e),'type':core['CommandType'][_0x313bc5(0x20e)],async 'handler'(_0x5db263,_0x21560c){const _0x58091e=_0x313bc5;if(!_0x21560c)return!0x1;const _0x1f88b0=_0x5db263['get'](exports[_0x58091e(0x196)]),_0x30575f=_0x5db263[_0x58091e(0x1b9)](IThreadCommentDataSourceService),_0x568a9d=_0x5db263[_0x58091e(0x1b9)](core[_0x58091e(0x221)]),{unitId:_0xf47f7b,subUnitId:_0x126c75,commentId:_0x43982e}=_0x21560c,_0x14429d=_0x30575f[_0x58091e(0x216)],_0x3b2bcb=_0x1f88b0['getComment'](_0xf47f7b,_0x126c75,_0x43982e);if(!_0x3b2bcb||!await _0x30575f[_0x58091e(0x204)](_0xf47f7b,_0x126c75,_0x3b2bcb['threadId'],_0x43982e))return!0x1;const _0xdbe2c3={'id':DeleteCommentMutation['id'],'params':_0x21560c};return _0x568a9d[_0x58091e(0x21c)](_0xdbe2c3['id'],_0xdbe2c3['params'],{'onlyLocal':!_0x14429d});}},DeleteCommentTreeCommand={'id':'thread-comment.command.delete-comment-tree','type':core['CommandType']['COMMAND'],async 'handler'(_0x3c6625,_0xf3475a){const _0xef60bf=_0x313bc5;if(!_0xf3475a)return!0x1;const _0x508bbb=_0x3c6625[_0xef60bf(0x1b9)](exports[_0xef60bf(0x196)]),_0x13a05b=_0x3c6625['get'](core[_0xef60bf(0x221)]),_0x26f1a4=_0x3c6625[_0xef60bf(0x1b9)](IThreadCommentDataSourceService),{unitId:_0x24e7e7,subUnitId:_0x14057a,commentId:_0x3e1501}=_0xf3475a,_0x2d260a=_0x508bbb[_0xef60bf(0x1fd)](_0x24e7e7,_0x14057a,_0x3e1501);return!_0x2d260a||!await _0x26f1a4[_0xef60bf(0x204)](_0x24e7e7,_0x14057a,_0x2d260a[_0xef60bf(0x1e5)]['threadId'],_0x3e1501)?!0x1:await _0x13a05b[_0xef60bf(0x21c)](DeleteCommentMutation['id'],{'unitId':_0x24e7e7,'subUnitId':_0x14057a,'commentId':_0x2d260a[_0xef60bf(0x1e5)]['id']});}},PLUGIN_CONFIG_KEY=_0x313bc5(0x1f2),defaultPluginConfig={};var __defProp2=Object[_0x313bc5(0x1f0)],__getOwnPropDesc=Object['getOwnPropertyDescriptor'],__decorateClass=__name((_0x1c66ad,_0x287bf5,_0x5a1424,_0x23ee0a)=>{const _0x194dce=_0x313bc5;for(var _0x485319=_0x23ee0a>0x1?void 0x0:_0x23ee0a?__getOwnPropDesc(_0x287bf5,_0x5a1424):_0x287bf5,_0x459b26=_0x1c66ad[_0x194dce(0x1ee)]-0x1,_0x134e07;_0x459b26>=0x0;_0x459b26--)(_0x134e07=_0x1c66ad[_0x459b26])&&(_0x485319=(_0x23ee0a?_0x134e07(_0x287bf5,_0x5a1424,_0x485319):_0x134e07(_0x485319))||_0x485319);return _0x23ee0a&&_0x485319&&__defProp2(_0x287bf5,_0x5a1424,_0x485319),_0x485319;},_0x313bc5(0x1f1)),__decorateParam=__name((_0x308400,_0x3b5f5c)=>(_0xf97ba8,_0x2aa8a3)=>_0x3b5f5c(_0xf97ba8,_0x2aa8a3,_0x308400),'__decorateParam'),_a3;exports['UniverThreadCommentPlugin']=(_a3=class extends core[_0x313bc5(0x1f6)]{constructor(_0x1db7a7=defaultPluginConfig,_0x20b3b8,_0x1e68b6,_0x317f26){const _0x6a915c=_0x313bc5;super(),this[_0x6a915c(0x200)]=_0x1db7a7,this[_0x6a915c(0x1cb)]=_0x20b3b8,this[_0x6a915c(0x215)]=_0x1e68b6,this[_0x6a915c(0x1d7)]=_0x317f26;const {..._0x47fdbf}=this[_0x6a915c(0x200)];this[_0x6a915c(0x1d7)]['setConfig'](PLUGIN_CONFIG_KEY,_0x47fdbf);}['onStarting'](){const _0x5c186e=_0x313bc5;var _0xd9d9bf;core['mergeOverrideWithDependencies']([[IThreadCommentDataSourceService,{'useClass':ThreadCommentDataSourceService}],[exports[_0x5c186e(0x196)]],[exports['ThreadCommentResourceController']]],(_0xd9d9bf=this['_config'])==null?void 0x0:_0xd9d9bf[_0x5c186e(0x1a8)])[_0x5c186e(0x211)](_0x507649=>{const _0x5cc6e2=_0x5c186e;this['_injector'][_0x5cc6e2(0x218)](_0x507649);}),[AddCommentCommand,UpdateCommentCommand,DeleteCommentCommand,ResolveCommentCommand,DeleteCommentTreeCommand,AddCommentMutation,UpdateCommentMutation,UpdateCommentRefMutation,DeleteCommentMutation,ResolveCommentMutation][_0x5c186e(0x211)](_0x1fc9ae=>{const _0x2418d1=_0x5c186e;this[_0x2418d1(0x215)][_0x2418d1(0x1d6)](_0x1fc9ae);}),this['_injector'][_0x5c186e(0x1b9)](exports[_0x5c186e(0x1b6)]);}},__name(_a3,_0x313bc5(0x1d0)),__publicField(_a3,_0x313bc5(0x1e2),TC_PLUGIN_NAME),__publicField(_a3,_0x313bc5(0x20d),core[_0x313bc5(0x1ce)][_0x313bc5(0x205)]),_a3),exports['UniverThreadCommentPlugin']=__decorateClass([__decorateParam(0x1,core['Inject'](core[_0x313bc5(0x194)])),__decorateParam(0x2,core['ICommandService']),__decorateParam(0x3,core[_0x313bc5(0x1bc)])],exports[_0x313bc5(0x1d0)]),exports[_0x313bc5(0x1c6)]=AddCommentCommand,exports['AddCommentMutation']=AddCommentMutation,exports[_0x313bc5(0x1a4)]=DeleteCommentCommand,exports['DeleteCommentMutation']=DeleteCommentMutation,exports['DeleteCommentTreeCommand']=DeleteCommentTreeCommand,exports['IThreadCommentDataSourceService']=IThreadCommentDataSourceService,exports[_0x313bc5(0x217)]=ResolveCommentCommand,exports[_0x313bc5(0x198)]=ResolveCommentMutation,exports[_0x313bc5(0x1b4)]=TC_PLUGIN_NAME,exports[_0x313bc5(0x20f)]=ThreadCommentDataSourceService,exports[_0x313bc5(0x202)]=UpdateCommentCommand,exports[_0x313bc5(0x197)]=UpdateCommentMutation,exports[_0x313bc5(0x1c7)]=UpdateCommentRefMutation;
package/lib/es/index.js CHANGED
@@ -1,530 +1 @@
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, CustomRangeType, ICommandService, OnLifecycle, LifecycleStages, IResourceManagerService, CommandType, Plugin, UniverInstanceType, mergeOverrideWithDependencies, Injector, IConfigService } from "@univerjs/core";
6
- import { Subject, BehaviorSubject, map } from "rxjs";
7
- const _ThreadCommentDataSourceService = class _ThreadCommentDataSourceService extends Disposable {
8
- constructor() {
9
- super();
10
- __publicField(this, "_dataSource", null);
11
- __publicField(this, "syncUpdateMutationToColla", !0);
12
- }
13
- set dataSource(dataSource) {
14
- this._dataSource = dataSource;
15
- }
16
- get dataSource() {
17
- return this._dataSource;
18
- }
19
- async getThreadComment(unitId, subUnitId, threadId) {
20
- return this._dataSource ? (await this._dataSource.listComments(unitId, subUnitId, [threadId]))[0] : null;
21
- }
22
- async addComment(comment) {
23
- return this._dataSource ? this._dataSource.addComment(comment) : comment;
24
- }
25
- async updateComment(comment) {
26
- return this._dataSource ? this._dataSource.updateComment(comment) : !0;
27
- }
28
- async resolveComment(comment) {
29
- return this._dataSource ? this._dataSource.resolveComment(comment) : !0;
30
- }
31
- async deleteComment(unitId, subUnitId, threadId, commentId) {
32
- return this._dataSource ? this._dataSource.deleteComment(unitId, subUnitId, threadId, commentId) : !0;
33
- }
34
- async listThreadComments(unitId, subUnitId, threadIds) {
35
- return this.dataSource ? this.dataSource.listComments(unitId, subUnitId, threadIds) : [];
36
- }
37
- saveToSnapshot(unitComments, unitId) {
38
- if (this._dataSource) {
39
- const map2 = {};
40
- return Object.keys(unitComments).forEach((subUnitId) => {
41
- const comments = unitComments[subUnitId];
42
- map2[subUnitId] = comments.map(this.dataSource.saveCommentToSnapshot);
43
- }), map2;
44
- }
45
- return unitComments;
46
- }
47
- };
48
- __name(_ThreadCommentDataSourceService, "ThreadCommentDataSourceService");
49
- let ThreadCommentDataSourceService = _ThreadCommentDataSourceService;
50
- const IThreadCommentDataSourceService = createIdentifier("univer.thread-comment.data-source-service");
51
- var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
52
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
53
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
54
- return kind && result && __defProp$2(target, key, result), result;
55
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a;
56
- let ThreadCommentModel = (_a = class extends Disposable {
57
- constructor(_dataSourceService, _commandService) {
58
- super();
59
- __publicField(this, "_commentsMap", {});
60
- __publicField(this, "_commentsTreeMap", /* @__PURE__ */ new Map());
61
- __publicField(this, "_threadMap", /* @__PURE__ */ new Map());
62
- __publicField(this, "_commentUpdate$", new Subject());
63
- __publicField(this, "_commentsMap$", new BehaviorSubject({}));
64
- __publicField(this, "commentUpdate$", this._commentUpdate$.asObservable());
65
- __publicField(this, "commentMap$", this._commentsMap$.asObservable());
66
- this._dataSourceService = _dataSourceService, this._commandService = _commandService, this.disposeWithMe(() => {
67
- this._commentUpdate$.complete(), this._commentsMap$.complete();
68
- });
69
- }
70
- _ensureCommentMap(unitId, subUnitId) {
71
- let unitMap = this._commentsMap[unitId];
72
- unitMap || (unitMap = {}, this._commentsMap[unitId] = unitMap);
73
- let subUnitMap = unitMap[subUnitId];
74
- return subUnitMap || (subUnitMap = {}, unitMap[subUnitId] = subUnitMap), subUnitMap;
75
- }
76
- _ensureCommentChildrenMap(unitId, subUnitId) {
77
- let unitMap = this._commentsTreeMap.get(unitId);
78
- unitMap || (unitMap = /* @__PURE__ */ new Map(), this._commentsTreeMap.set(unitId, unitMap));
79
- let subUnitMap = unitMap.get(subUnitId);
80
- return subUnitMap || (subUnitMap = /* @__PURE__ */ new Map(), unitMap.set(subUnitId, subUnitMap)), subUnitMap;
81
- }
82
- _ensureThreadMap(unitId) {
83
- let unitMap = this._threadMap.get(unitId);
84
- return unitMap || (unitMap = /* @__PURE__ */ new Map(), this._threadMap.set(unitId, unitMap)), unitMap;
85
- }
86
- _refreshCommentsMap$() {
87
- this._commentsMap$.next({
88
- ...this._commentsMap
89
- });
90
- }
91
- ensureMap(unitId, subUnitId) {
92
- const commentMap = this._ensureCommentMap(unitId, subUnitId), commentChildrenMap = this._ensureCommentChildrenMap(unitId, subUnitId);
93
- return {
94
- commentMap,
95
- commentChildrenMap
96
- };
97
- }
98
- _replaceComment(unitId, subUnitId, comment) {
99
- var _a4;
100
- const { commentMap, commentChildrenMap } = this.ensureMap(unitId, subUnitId), currentComment = commentMap[comment.id];
101
- if (currentComment) {
102
- const newComment = {
103
- ...comment,
104
- ref: currentComment.ref
105
- };
106
- commentMap[comment.id] = newComment, (_a4 = comment.children) == null || _a4.forEach((child) => {
107
- commentMap[child.id] = {
108
- ...child,
109
- ref: ""
110
- };
111
- }), commentChildrenMap.set(comment.id, newComment), this._commentUpdate$.next({
112
- unitId,
113
- subUnitId,
114
- type: "syncUpdate",
115
- payload: newComment
116
- }), !!comment.resolved != !!currentComment.resolved && this._commentUpdate$.next({
117
- unitId,
118
- subUnitId,
119
- type: "resolve",
120
- payload: {
121
- commentId: comment.id,
122
- resolved: !!comment.resolved
123
- }
124
- });
125
- }
126
- }
127
- async syncThreadComments(unitId, subUnitId, threadIds) {
128
- const comments = await this._dataSourceService.listThreadComments(unitId, subUnitId, threadIds);
129
- if (!comments.length)
130
- return;
131
- const deleteThreads = new Set(threadIds);
132
- comments.forEach((comment) => {
133
- this._replaceComment(unitId, subUnitId, comment), deleteThreads.delete(comment.threadId);
134
- }), deleteThreads.forEach((id) => {
135
- const thread = this.getThread(unitId, id);
136
- thread && this.deleteComment(thread.unitId, thread.subUnitId, thread.id);
137
- }), this._refreshCommentsMap$();
138
- }
139
- addComment(unitId, subUnitId, origin, shouldSync) {
140
- var _a4, _b;
141
- const { commentMap, commentChildrenMap } = this.ensureMap(unitId, subUnitId), comment = origin, addCommentItem = /* @__PURE__ */ __name((item) => {
142
- commentMap[item.id] = item, this._commentUpdate$.next({
143
- unitId,
144
- subUnitId,
145
- type: "add",
146
- payload: item,
147
- isRoot: !item.parentId
148
- });
149
- }, "addCommentItem"), parentId = comment.parentId;
150
- if (parentId) {
151
- const parent = commentMap[parentId];
152
- parent.children = [
153
- ...(_a4 = parent.children) != null ? _a4 : [],
154
- comment
155
- ], addCommentItem(comment);
156
- } else
157
- commentChildrenMap.set(comment.id, comment), this._ensureThreadMap(unitId).set(comment.threadId, comment), addCommentItem(comment), (_b = comment.children) == null || _b.forEach((child) => addCommentItem({
158
- ...child,
159
- ref: ""
160
- }));
161
- return this._refreshCommentsMap$(), shouldSync && this.syncThreadComments(unitId, subUnitId, [comment.threadId]), !0;
162
- }
163
- updateComment(unitId, subUnitId, payload, silent) {
164
- const { commentMap } = this.ensureMap(unitId, subUnitId), oldComment = commentMap[payload.commentId];
165
- return oldComment ? (oldComment.updated = !0, oldComment.text = payload.text, oldComment.attachments = payload.attachments, oldComment.updateT = payload.updateT, this._commentUpdate$.next({
166
- unitId,
167
- subUnitId,
168
- type: "update",
169
- payload,
170
- silent
171
- }), this._refreshCommentsMap$(), !0) : !1;
172
- }
173
- updateCommentRef(unitId, subUnitId, payload, silent) {
174
- const { commentMap } = this.ensureMap(unitId, subUnitId), oldComment = commentMap[payload.commentId];
175
- return oldComment ? (oldComment.ref = payload.ref, this._commentUpdate$.next({
176
- unitId,
177
- subUnitId,
178
- type: "updateRef",
179
- payload,
180
- silent
181
- }), this._refreshCommentsMap$(), !0) : !1;
182
- }
183
- resolveComment(unitId, subUnitId, commentId, resolved) {
184
- const { commentMap } = this.ensureMap(unitId, subUnitId), oldComment = commentMap[commentId];
185
- return oldComment ? (oldComment.resolved = resolved, this._commentUpdate$.next({
186
- unitId,
187
- subUnitId,
188
- type: "resolve",
189
- payload: {
190
- commentId,
191
- resolved
192
- }
193
- }), this._refreshCommentsMap$(), !0) : !1;
194
- }
195
- getComment(unitId, subUnitId, commentId) {
196
- const { commentMap } = this.ensureMap(unitId, subUnitId);
197
- return commentMap[commentId];
198
- }
199
- getComment$(unitId, subUnitId, commentId) {
200
- return this._commentsMap$.pipe(map((records) => records[unitId][subUnitId][commentId]));
201
- }
202
- getCommentWithChildren(unitId, subUnitId, commentId) {
203
- var _a4, _b;
204
- const { commentMap, commentChildrenMap } = this.ensureMap(unitId, subUnitId), current = commentMap[commentId];
205
- if (!current)
206
- return;
207
- const relativeUsers = /* @__PURE__ */ new Set(), root = commentChildrenMap.get(commentId);
208
- if (root)
209
- return [root, ...(_a4 = root.children) != null ? _a4 : []].forEach((comment) => {
210
- var _a5;
211
- relativeUsers.add(comment.personId), (_a5 = comment.text.customRanges) == null || _a5.forEach((range) => {
212
- range.rangeType === CustomRangeType.MENTION && relativeUsers.add(range.rangeId);
213
- });
214
- }), {
215
- root: current,
216
- children: (_b = root.children) != null ? _b : [],
217
- relativeUsers
218
- };
219
- }
220
- deleteComment(unitId, subUnitId, commentId) {
221
- var _a4;
222
- const { commentMap, commentChildrenMap } = this.ensureMap(unitId, subUnitId), current = commentMap[commentId];
223
- if (!current)
224
- return !0;
225
- if (current.parentId) {
226
- const root = commentChildrenMap.get(current.parentId);
227
- if (root && root.children) {
228
- const index = root.children.findIndex((comment) => comment.id === commentId);
229
- root.children.splice(index, 1);
230
- }
231
- delete commentMap[commentId];
232
- } else {
233
- delete commentMap[commentId];
234
- const comment = commentChildrenMap.get(commentId);
235
- commentChildrenMap.delete(commentId), this._ensureThreadMap(unitId).delete(current.threadId), (_a4 = comment == null ? void 0 : comment.children) == null || _a4.forEach((child) => {
236
- delete commentMap[child.id], this._commentUpdate$.next({
237
- unitId,
238
- subUnitId,
239
- type: "delete",
240
- payload: {
241
- commentId: child.id,
242
- isRoot: !1,
243
- comment: child
244
- }
245
- });
246
- });
247
- }
248
- return this._commentUpdate$.next({
249
- unitId,
250
- subUnitId,
251
- type: "delete",
252
- payload: {
253
- commentId,
254
- isRoot: !current.parentId,
255
- comment: current
256
- }
257
- }), this._refreshCommentsMap$(), !0;
258
- }
259
- getUnit(unitId) {
260
- const unitMap = this._commentsMap[unitId];
261
- return unitMap ? Array.from(Object.entries(unitMap)).map(([subUnitId, subUnitMap]) => [subUnitId, Array.from(Object.values(subUnitMap))]) : [];
262
- }
263
- deleteUnit(unitId) {
264
- const unitMap = this._commentsMap[unitId];
265
- unitMap && Object.entries(unitMap).forEach(([subUnitId, subUnitMap]) => {
266
- Object.values(subUnitMap).forEach((comment) => {
267
- this.deleteComment(unitId, subUnitId, comment.id);
268
- });
269
- });
270
- }
271
- getRootCommentIds(unitId, subUnitId) {
272
- const commentChildrenMap = this._ensureCommentChildrenMap(unitId, subUnitId);
273
- return Array.from(commentChildrenMap.keys());
274
- }
275
- getAll() {
276
- return this._commentsMap;
277
- }
278
- getThread(unitId, threadId) {
279
- return this._ensureThreadMap(unitId).get(threadId);
280
- }
281
- }, __name(_a, "ThreadCommentModel"), _a);
282
- ThreadCommentModel = __decorateClass$2([
283
- __decorateParam$2(0, Inject(IThreadCommentDataSourceService)),
284
- __decorateParam$2(1, ICommandService)
285
- ], ThreadCommentModel);
286
- var I = /* @__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))(I || {});
287
- const TC_PLUGIN_NAME = "UNIVER_THREAD_COMMENT_PLUGIN";
288
- var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
289
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
290
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
291
- return kind && result && __defProp$1(target, key, result), result;
292
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a2;
293
- let ThreadCommentResourceController = (_a2 = class extends Disposable {
294
- constructor(_resourceManagerService, _threadCommentModel, _threadCommentDataSourceService) {
295
- super(), this._resourceManagerService = _resourceManagerService, this._threadCommentModel = _threadCommentModel, this._threadCommentDataSourceService = _threadCommentDataSourceService, this._initSnapshot();
296
- }
297
- _initSnapshot() {
298
- const toJson = /* @__PURE__ */ __name((unitID) => {
299
- const map2 = this._threadCommentModel.getUnit(unitID), resultMap = {};
300
- return map2 ? (map2.forEach(([key, v]) => {
301
- resultMap[key] = v;
302
- }), JSON.stringify(this._threadCommentDataSourceService.saveToSnapshot(resultMap, unitID))) : "";
303
- }, "toJson"), parseJson = /* @__PURE__ */ __name((json) => {
304
- if (!json)
305
- return {};
306
- try {
307
- return JSON.parse(json);
308
- } catch {
309
- return {};
310
- }
311
- }, "parseJson");
312
- this.disposeWithMe(
313
- this._resourceManagerService.registerPluginResource({
314
- pluginName: `SHEET_${TC_PLUGIN_NAME}`,
315
- businesses: [I.UNIVER_SHEET, I.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));
327
- });
328
- }, "onLoad")
329
- })
330
- );
331
- }
332
- }, __name(_a2, "ThreadCommentResourceController"), _a2);
333
- ThreadCommentResourceController = __decorateClass$1([
334
- OnLifecycle(LifecycleStages.Starting, ThreadCommentResourceController),
335
- __decorateParam$1(0, IResourceManagerService),
336
- __decorateParam$1(1, Inject(ThreadCommentModel)),
337
- __decorateParam$1(2, IThreadCommentDataSourceService)
338
- ], ThreadCommentResourceController);
339
- const AddCommentMutation = {
340
- id: "thread-comment.mutation.add-comment",
341
- type: CommandType.MUTATION,
342
- handler(accessor, params, options) {
343
- if (!params)
344
- return !1;
345
- const threadCommentModel = accessor.get(ThreadCommentModel), { unitId, subUnitId, comment, sync } = params, shouldSync = sync || (options == null ? void 0 : options.fromChangeset) && !comment.parentId;
346
- return threadCommentModel.addComment(unitId, subUnitId, comment, shouldSync);
347
- }
348
- }, UpdateCommentMutation = {
349
- id: "thread-comment.mutation.update-comment",
350
- type: CommandType.MUTATION,
351
- handler(accessor, params) {
352
- if (!params)
353
- return !1;
354
- const threadCommentModel = accessor.get(ThreadCommentModel), { unitId, subUnitId, payload, silent } = params;
355
- return threadCommentModel.updateComment(unitId, subUnitId, payload, silent);
356
- }
357
- }, UpdateCommentRefMutation = {
358
- id: "thread-comment.mutation.update-comment-ref",
359
- type: CommandType.MUTATION,
360
- handler(accessor, params) {
361
- if (!params)
362
- return !1;
363
- const threadCommentModel = accessor.get(ThreadCommentModel), { unitId, subUnitId, payload, silent } = params;
364
- return threadCommentModel.updateCommentRef(unitId, subUnitId, payload, silent);
365
- }
366
- }, ResolveCommentMutation = {
367
- id: "thread-comment.mutation.resolve-comment",
368
- type: CommandType.MUTATION,
369
- handler(accessor, params) {
370
- if (!params)
371
- return !1;
372
- const threadCommentModel = accessor.get(ThreadCommentModel), { unitId, subUnitId, resolved, commentId } = params;
373
- return threadCommentModel.resolveComment(unitId, subUnitId, commentId, resolved);
374
- }
375
- }, DeleteCommentMutation = {
376
- id: "thread-comment.mutation.delete-comment",
377
- type: CommandType.MUTATION,
378
- handler(accessor, params) {
379
- if (!params)
380
- return !1;
381
- const threadCommentModel = accessor.get(ThreadCommentModel), { unitId, subUnitId, commentId } = params;
382
- return threadCommentModel.deleteComment(unitId, subUnitId, commentId);
383
- }
384
- }, AddCommentCommand = {
385
- id: "thread-comment.command.add-comment",
386
- type: CommandType.COMMAND,
387
- async handler(accessor, params) {
388
- if (!params)
389
- return !1;
390
- const commandService = accessor.get(ICommandService), dataSourceService = accessor.get(IThreadCommentDataSourceService), { comment: originComment } = params, comment = await dataSourceService.addComment(originComment), syncUpdateMutationToColla = dataSourceService.syncUpdateMutationToColla, isRoot = !originComment.parentId, redo = {
391
- id: AddCommentMutation.id,
392
- params: {
393
- ...params,
394
- comment
395
- }
396
- };
397
- return isRoot ? await commandService.executeCommand(redo.id, redo.params) : commandService.executeCommand(redo.id, redo.params, {
398
- onlyLocal: !syncUpdateMutationToColla
399
- });
400
- }
401
- }, UpdateCommentCommand = {
402
- id: "thread-comment.command.update-comment",
403
- type: CommandType.COMMAND,
404
- async handler(accessor, params) {
405
- if (!params)
406
- return !1;
407
- const { unitId, subUnitId, payload } = params, commandService = accessor.get(ICommandService), threadCommentModel = accessor.get(ThreadCommentModel), dataSourceService = accessor.get(IThreadCommentDataSourceService), syncUpdateMutationToColla = dataSourceService.syncUpdateMutationToColla, current = threadCommentModel.getComment(
408
- unitId,
409
- subUnitId,
410
- payload.commentId
411
- );
412
- if (!current)
413
- return !1;
414
- const { children, ...currentComment } = current;
415
- if (!await dataSourceService.updateComment({
416
- ...currentComment,
417
- ...payload
418
- }))
419
- return !1;
420
- const redo = {
421
- id: UpdateCommentMutation.id,
422
- params
423
- };
424
- return commandService.executeCommand(redo.id, redo.params, { onlyLocal: !syncUpdateMutationToColla }), !0;
425
- }
426
- }, ResolveCommentCommand = {
427
- id: "thread-comment.command.resolve-comment",
428
- type: CommandType.COMMAND,
429
- async handler(accessor, params) {
430
- if (!params)
431
- return !1;
432
- const { unitId, subUnitId, resolved, commentId } = params, dataSourceService = accessor.get(IThreadCommentDataSourceService), currentComment = accessor.get(ThreadCommentModel).getComment(unitId, subUnitId, commentId), syncUpdateMutationToColla = dataSourceService.syncUpdateMutationToColla;
433
- return !currentComment || !await dataSourceService.resolveComment({
434
- ...currentComment,
435
- resolved
436
- }) ? !1 : accessor.get(ICommandService).executeCommand(
437
- ResolveCommentMutation.id,
438
- params,
439
- { onlyLocal: !syncUpdateMutationToColla }
440
- );
441
- }
442
- }, DeleteCommentCommand = {
443
- id: "thread-comment.command.delete-comment",
444
- type: CommandType.COMMAND,
445
- async handler(accessor, params) {
446
- if (!params)
447
- return !1;
448
- 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);
449
- if (!comment || !await dataSourceService.deleteComment(unitId, subUnitId, comment.threadId, commentId))
450
- return !1;
451
- const redo = {
452
- id: DeleteCommentMutation.id,
453
- params
454
- };
455
- return commandService.executeCommand(redo.id, redo.params, { onlyLocal: !syncUpdateMutationToColla });
456
- }
457
- }, DeleteCommentTreeCommand = {
458
- id: "thread-comment.command.delete-comment-tree",
459
- type: CommandType.COMMAND,
460
- async handler(accessor, params) {
461
- if (!params)
462
- return !1;
463
- const threadCommentModel = accessor.get(ThreadCommentModel), commandService = accessor.get(ICommandService), dataSourceService = accessor.get(IThreadCommentDataSourceService), { unitId, subUnitId, commentId } = params, commentWithChildren = threadCommentModel.getCommentWithChildren(unitId, subUnitId, commentId);
464
- return !commentWithChildren || !await dataSourceService.deleteComment(unitId, subUnitId, commentWithChildren.root.threadId, commentId) ? !1 : await commandService.executeCommand(DeleteCommentMutation.id, {
465
- unitId,
466
- subUnitId,
467
- commentId: commentWithChildren.root.id
468
- });
469
- }
470
- }, PLUGIN_CONFIG_KEY = "thread-comment.config", defaultPluginConfig = {};
471
- var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
472
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
473
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
474
- return kind && result && __defProp2(target, key, result), result;
475
- }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a3;
476
- let UniverThreadCommentPlugin = (_a3 = class extends Plugin {
477
- constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
478
- super(), this._config = _config, this._injector = _injector, this._commandService = _commandService, this._configService = _configService;
479
- const { ...rest } = this._config;
480
- this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
481
- }
482
- onStarting() {
483
- var _a4;
484
- mergeOverrideWithDependencies([
485
- [IThreadCommentDataSourceService, { useClass: ThreadCommentDataSourceService }],
486
- [ThreadCommentModel],
487
- [ThreadCommentResourceController]
488
- ], (_a4 = this._config) == null ? void 0 : _a4.overrides).forEach(
489
- (d) => {
490
- this._injector.add(d);
491
- }
492
- ), [
493
- AddCommentCommand,
494
- UpdateCommentCommand,
495
- DeleteCommentCommand,
496
- ResolveCommentCommand,
497
- DeleteCommentTreeCommand,
498
- AddCommentMutation,
499
- UpdateCommentMutation,
500
- UpdateCommentRefMutation,
501
- DeleteCommentMutation,
502
- ResolveCommentMutation
503
- ].forEach((command) => {
504
- this._commandService.registerCommand(command);
505
- });
506
- }
507
- }, __name(_a3, "UniverThreadCommentPlugin"), __publicField(_a3, "pluginName", TC_PLUGIN_NAME), __publicField(_a3, "type", UniverInstanceType.UNIVER_UNKNOWN), _a3);
508
- UniverThreadCommentPlugin = __decorateClass([
509
- __decorateParam(1, Inject(Injector)),
510
- __decorateParam(2, ICommandService),
511
- __decorateParam(3, IConfigService)
512
- ], UniverThreadCommentPlugin);
513
- export {
514
- AddCommentCommand,
515
- AddCommentMutation,
516
- DeleteCommentCommand,
517
- DeleteCommentMutation,
518
- DeleteCommentTreeCommand,
519
- IThreadCommentDataSourceService,
520
- ResolveCommentCommand,
521
- ResolveCommentMutation,
522
- TC_PLUGIN_NAME,
523
- ThreadCommentDataSourceService,
524
- ThreadCommentModel,
525
- ThreadCommentResourceController,
526
- UniverThreadCommentPlugin,
527
- UpdateCommentCommand,
528
- UpdateCommentMutation,
529
- UpdateCommentRefMutation
530
- };
1
+ const _0x52d455=_0x4ad1;(function(_0x3e2052,_0x40007a){const _0x30abaa=_0x4ad1,_0x574ca5=_0x3e2052();while(!![]){try{const _0x49e683=parseInt(_0x30abaa(0x190))/0x1*(-parseInt(_0x30abaa(0x1d4))/0x2)+-parseInt(_0x30abaa(0x196))/0x3+parseInt(_0x30abaa(0x18c))/0x4*(parseInt(_0x30abaa(0x1c4))/0x5)+-parseInt(_0x30abaa(0x1af))/0x6*(parseInt(_0x30abaa(0x177))/0x7)+-parseInt(_0x30abaa(0x1c1))/0x8*(-parseInt(_0x30abaa(0x17e))/0x9)+-parseInt(_0x30abaa(0x175))/0xa+parseInt(_0x30abaa(0x1aa))/0xb;if(_0x49e683===_0x40007a)break;else _0x574ca5['push'](_0x574ca5['shift']());}catch(_0x45df8c){_0x574ca5['push'](_0x574ca5['shift']());}}}(_0x79f9,0xc7710));function _0x4ad1(_0x4a5d7e,_0x32e21c){const _0x79f96f=_0x79f9();return _0x4ad1=function(_0x4ad19f,_0x3c44f0){_0x4ad19f=_0x4ad19f-0x175;let _0x265b9e=_0x79f96f[_0x4ad19f];return _0x265b9e;},_0x4ad1(_0x4a5d7e,_0x32e21c);}var __defProp=Object['defineProperty'],__defNormalProp=(_0x2001c3,_0x2a63f4,_0x50d62f)=>_0x2a63f4 in _0x2001c3?__defProp(_0x2001c3,_0x2a63f4,{'enumerable':!0x0,'configurable':!0x0,'writable':!0x0,'value':_0x50d62f}):_0x2001c3[_0x2a63f4]=_0x50d62f,__name=(_0x41ccf1,_0x169c17)=>__defProp(_0x41ccf1,_0x52d455(0x1d3),{'value':_0x169c17,'configurable':!0x0}),__publicField=(_0x3a1c99,_0x452427,_0x397996)=>__defNormalProp(_0x3a1c99,typeof _0x452427!=_0x52d455(0x1a6)?_0x452427+'':_0x452427,_0x397996);import{createIdentifier,Disposable,Inject,CustomRangeType,ICommandService,IResourceManagerService,CommandType,Plugin,UniverInstanceType,mergeOverrideWithDependencies,Injector,IConfigService}from'@univerjs/core';import{Subject,BehaviorSubject,map}from'rxjs';const _ThreadCommentDataSourceService=class _ThreadCommentDataSourceService extends Disposable{constructor(){const _0x3af711=_0x52d455;super(),__publicField(this,_0x3af711(0x1b8),null),__publicField(this,'syncUpdateMutationToColla',!0x0);}set[_0x52d455(0x1d6)](_0x28584a){const _0x5e03f7=_0x52d455;this[_0x5e03f7(0x1b8)]=_0x28584a;}get['dataSource'](){const _0x6283d=_0x52d455;return this[_0x6283d(0x1b8)];}async['getThreadComment'](_0x15b99a,_0x2cd116,_0x299a3e){const _0x552285=_0x52d455;return this[_0x552285(0x1b8)]?(await this[_0x552285(0x1b8)][_0x552285(0x1a5)](_0x15b99a,_0x2cd116,[_0x299a3e]))[0x0]:null;}async['addComment'](_0x3c28c8){const _0x586d12=_0x52d455;return this['_dataSource']?this[_0x586d12(0x1b8)][_0x586d12(0x183)](_0x3c28c8):_0x3c28c8;}async['updateComment'](_0x20bc7a){const _0x597e54=_0x52d455;return this[_0x597e54(0x1b8)]?this['_dataSource'][_0x597e54(0x1f2)](_0x20bc7a):!0x0;}async[_0x52d455(0x1cd)](_0x3d2a96){const _0x3a649c=_0x52d455;return this[_0x3a649c(0x1b8)]?this[_0x3a649c(0x1b8)][_0x3a649c(0x1cd)](_0x3d2a96):!0x0;}async[_0x52d455(0x17d)](_0x247907,_0x6588c9,_0x2242ab,_0x353394){const _0x399108=_0x52d455;return this[_0x399108(0x1b8)]?this[_0x399108(0x1b8)][_0x399108(0x17d)](_0x247907,_0x6588c9,_0x2242ab,_0x353394):!0x0;}async[_0x52d455(0x1e8)](_0x4357e7,_0x5bc896,_0x5d534f){const _0x3e7f2d=_0x52d455;return this[_0x3e7f2d(0x1d6)]?this['dataSource'][_0x3e7f2d(0x1a5)](_0x4357e7,_0x5bc896,_0x5d534f):[];}[_0x52d455(0x1bc)](_0x47db81,_0xad5ba1){const _0x38036f=_0x52d455;if(this[_0x38036f(0x1b8)]){const _0x2ea6a2={};return Object['keys'](_0x47db81)[_0x38036f(0x1e2)](_0x5608e4=>{const _0x2ce269=_0x38036f,_0x59b868=_0x47db81[_0x5608e4];_0x2ea6a2[_0x5608e4]=_0x59b868[_0x2ce269(0x1c5)](this[_0x2ce269(0x1d6)][_0x2ce269(0x1c6)]);}),_0x2ea6a2;}return _0x47db81;}};__name(_ThreadCommentDataSourceService,'ThreadCommentDataSourceService');let ThreadCommentDataSourceService=_ThreadCommentDataSourceService;const IThreadCommentDataSourceService=createIdentifier(_0x52d455(0x1a1));var __defProp$2=Object[_0x52d455(0x198)],__getOwnPropDesc$2=Object[_0x52d455(0x1b1)],__decorateClass$2=__name((_0x21d31b,_0x23079e,_0x5d86ae,_0x5788e0)=>{const _0x34ba9d=_0x52d455;for(var _0x1aaef2=_0x5788e0>0x1?void 0x0:_0x5788e0?__getOwnPropDesc$2(_0x23079e,_0x5d86ae):_0x23079e,_0x191908=_0x21d31b[_0x34ba9d(0x1d0)]-0x1,_0x1cbdeb;_0x191908>=0x0;_0x191908--)(_0x1cbdeb=_0x21d31b[_0x191908])&&(_0x1aaef2=(_0x5788e0?_0x1cbdeb(_0x23079e,_0x5d86ae,_0x1aaef2):_0x1cbdeb(_0x1aaef2))||_0x1aaef2);return _0x5788e0&&_0x1aaef2&&__defProp$2(_0x23079e,_0x5d86ae,_0x1aaef2),_0x1aaef2;},_0x52d455(0x184)),__decorateParam$2=__name((_0x1b500d,_0x95e9f0)=>(_0x233bba,_0xa17920)=>_0x95e9f0(_0x233bba,_0xa17920,_0x1b500d),_0x52d455(0x1ab)),_a;let ThreadCommentModel=(_a=class extends Disposable{constructor(_0x5397c4,_0x19d891){const _0x54c322=_0x52d455;super(),__publicField(this,_0x54c322(0x1ef),{}),__publicField(this,_0x54c322(0x17a),new Map()),__publicField(this,_0x54c322(0x1e7),new Map()),__publicField(this,_0x54c322(0x1bf),new Subject()),__publicField(this,_0x54c322(0x18f),new BehaviorSubject({})),__publicField(this,'commentUpdate$',this[_0x54c322(0x1bf)]['asObservable']()),__publicField(this,_0x54c322(0x19e),this[_0x54c322(0x18f)][_0x54c322(0x1a8)]()),(this[_0x54c322(0x1a0)]=_0x5397c4,this[_0x54c322(0x1e3)]=_0x19d891,this['disposeWithMe'](()=>{const _0x3fbb14=_0x54c322;this[_0x3fbb14(0x1bf)][_0x3fbb14(0x1a9)](),this['_commentsMap$']['complete']();}));}[_0x52d455(0x1f4)](_0x250ec3,_0x3d16ab){const _0x296ae7=_0x52d455;let _0x176cf0=this[_0x296ae7(0x1ef)][_0x250ec3];_0x176cf0||(_0x176cf0={},this['_commentsMap'][_0x250ec3]=_0x176cf0);let _0x35123a=_0x176cf0[_0x3d16ab];return _0x35123a||(_0x35123a={},_0x176cf0[_0x3d16ab]=_0x35123a),_0x35123a;}[_0x52d455(0x1ca)](_0x3e051e,_0x4dfe84){const _0x2918ed=_0x52d455;let _0x5e2256=this['_commentsTreeMap']['get'](_0x3e051e);_0x5e2256||(_0x5e2256=new Map(),this['_commentsTreeMap']['set'](_0x3e051e,_0x5e2256));let _0x20d786=_0x5e2256[_0x2918ed(0x1e9)](_0x4dfe84);return _0x20d786||(_0x20d786=new Map(),_0x5e2256[_0x2918ed(0x17c)](_0x4dfe84,_0x20d786)),_0x20d786;}[_0x52d455(0x1b5)](_0x8fbe50){const _0x4b37d9=_0x52d455;let _0x179d13=this['_threadMap'][_0x4b37d9(0x1e9)](_0x8fbe50);return _0x179d13||(_0x179d13=new Map(),this['_threadMap'][_0x4b37d9(0x17c)](_0x8fbe50,_0x179d13)),_0x179d13;}['_refreshCommentsMap$'](){const _0x93242c=_0x52d455;this[_0x93242c(0x18f)][_0x93242c(0x197)]({...this[_0x93242c(0x1ef)]});}['ensureMap'](_0x49d628,_0x1c1608){const _0x42553d=_0x52d455,_0x4cb770=this[_0x42553d(0x1f4)](_0x49d628,_0x1c1608),_0x115fec=this[_0x42553d(0x1ca)](_0x49d628,_0x1c1608);return{'commentMap':_0x4cb770,'commentChildrenMap':_0x115fec};}[_0x52d455(0x1e1)](_0x2c1b1b,_0x4de179,_0x2cbe7f){const _0x5c05b3=_0x52d455;var _0x4f111f;const {commentMap:_0x45afed,commentChildrenMap:_0x53ae7f}=this['ensureMap'](_0x2c1b1b,_0x4de179),_0xc96c55=_0x45afed[_0x2cbe7f['id']];if(_0xc96c55){const _0x4b06c4={..._0x2cbe7f,'ref':_0xc96c55[_0x5c05b3(0x1b3)]};_0x45afed[_0x2cbe7f['id']]=_0x4b06c4,(_0x4f111f=_0x2cbe7f[_0x5c05b3(0x1a7)])==null||_0x4f111f[_0x5c05b3(0x1e2)](_0xa2da27=>{_0x45afed[_0xa2da27['id']]={..._0xa2da27,'ref':''};}),_0x53ae7f[_0x5c05b3(0x17c)](_0x2cbe7f['id'],_0x4b06c4),this[_0x5c05b3(0x1bf)][_0x5c05b3(0x197)]({'unitId':_0x2c1b1b,'subUnitId':_0x4de179,'type':_0x5c05b3(0x1c0),'payload':_0x4b06c4}),!!_0x2cbe7f[_0x5c05b3(0x1d7)]!=!!_0xc96c55[_0x5c05b3(0x1d7)]&&this[_0x5c05b3(0x1bf)][_0x5c05b3(0x197)]({'unitId':_0x2c1b1b,'subUnitId':_0x4de179,'type':_0x5c05b3(0x179),'payload':{'commentId':_0x2cbe7f['id'],'resolved':!!_0x2cbe7f[_0x5c05b3(0x1d7)]}});}}async[_0x52d455(0x191)](_0x32a44a,_0x163dfa,_0x56e9e5){const _0x4b3636=_0x52d455,_0x3dbcef=await this[_0x4b3636(0x1a0)][_0x4b3636(0x1e8)](_0x32a44a,_0x163dfa,_0x56e9e5);if(!_0x3dbcef[_0x4b3636(0x1d0)])return;const _0xd3571e=new Set(_0x56e9e5);_0x3dbcef[_0x4b3636(0x1e2)](_0x1fbc56=>{const _0x55827f=_0x4b3636;this[_0x55827f(0x1e1)](_0x32a44a,_0x163dfa,_0x1fbc56),_0xd3571e[_0x55827f(0x1a4)](_0x1fbc56[_0x55827f(0x1ed)]);}),_0xd3571e[_0x4b3636(0x1e2)](_0xd3cbf0=>{const _0x47bc49=_0x4b3636,_0x2e4530=this['getThread'](_0x32a44a,_0xd3cbf0);_0x2e4530&&this[_0x47bc49(0x17d)](_0x2e4530[_0x47bc49(0x1eb)],_0x2e4530[_0x47bc49(0x1de)],_0x2e4530['id']);}),this[_0x4b3636(0x18a)]();}[_0x52d455(0x183)](_0x1bd63d,_0xb33fb,_0x5dd3ea,_0x64fa04){const _0x47f1ec=_0x52d455;var _0xe82b6,_0x4a7923;const {commentMap:_0x1b3d73,commentChildrenMap:_0x4ea6cf}=this[_0x47f1ec(0x1c9)](_0x1bd63d,_0xb33fb),_0x5ac762=_0x5dd3ea,_0x569d22=__name(_0x35bbf7=>{const _0x586526=_0x47f1ec;_0x1b3d73[_0x35bbf7['id']]=_0x35bbf7,this[_0x586526(0x1bf)][_0x586526(0x197)]({'unitId':_0x1bd63d,'subUnitId':_0xb33fb,'type':'add','payload':_0x35bbf7,'isRoot':!_0x35bbf7['parentId']});},'addCommentItem'),_0x37053c=_0x5ac762[_0x47f1ec(0x1c8)];if(_0x37053c){const _0x2133cb=_0x1b3d73[_0x37053c];_0x2133cb[_0x47f1ec(0x1a7)]=[...(_0xe82b6=_0x2133cb['children'])!=null?_0xe82b6:[],_0x5ac762],_0x569d22(_0x5ac762);}else _0x4ea6cf[_0x47f1ec(0x17c)](_0x5ac762['id'],_0x5ac762),this[_0x47f1ec(0x1b5)](_0x1bd63d)[_0x47f1ec(0x17c)](_0x5ac762[_0x47f1ec(0x1ed)],_0x5ac762),_0x569d22(_0x5ac762),(_0x4a7923=_0x5ac762['children'])==null||_0x4a7923[_0x47f1ec(0x1e2)](_0x330311=>_0x569d22({..._0x330311,'ref':''}));return this[_0x47f1ec(0x18a)](),_0x64fa04&&this[_0x47f1ec(0x191)](_0x1bd63d,_0xb33fb,[_0x5ac762[_0x47f1ec(0x1ed)]]),!0x0;}[_0x52d455(0x1f2)](_0x43597e,_0x1d3726,_0x2cc607,_0x5816bc){const _0x5dda7f=_0x52d455,{commentMap:_0x4c9676}=this[_0x5dda7f(0x1c9)](_0x43597e,_0x1d3726),_0x6f181b=_0x4c9676[_0x2cc607[_0x5dda7f(0x1e6)]];return _0x6f181b?(_0x6f181b[_0x5dda7f(0x193)]=!0x0,_0x6f181b[_0x5dda7f(0x1db)]=_0x2cc607[_0x5dda7f(0x1db)],_0x6f181b[_0x5dda7f(0x1ee)]=_0x2cc607['attachments'],_0x6f181b[_0x5dda7f(0x176)]=_0x2cc607[_0x5dda7f(0x176)],this[_0x5dda7f(0x1bf)]['next']({'unitId':_0x43597e,'subUnitId':_0x1d3726,'type':_0x5dda7f(0x1e4),'payload':_0x2cc607,'silent':_0x5816bc}),this[_0x5dda7f(0x18a)](),!0x0):!0x1;}[_0x52d455(0x1e5)](_0x4b52c2,_0x3a793f,_0x4b34f0,_0x18e0b5){const _0x656552=_0x52d455,{commentMap:_0x3c10b7}=this[_0x656552(0x1c9)](_0x4b52c2,_0x3a793f),_0x1c981b=_0x3c10b7[_0x4b34f0['commentId']];return _0x1c981b?(_0x1c981b[_0x656552(0x1b3)]=_0x4b34f0['ref'],this[_0x656552(0x1bf)][_0x656552(0x197)]({'unitId':_0x4b52c2,'subUnitId':_0x3a793f,'type':'updateRef','payload':_0x4b34f0,'silent':_0x18e0b5}),this[_0x656552(0x18a)](),!0x0):!0x1;}[_0x52d455(0x1cd)](_0x2a44e0,_0x34fe9f,_0x1b43d2,_0x2d081d){const _0x257fa7=_0x52d455,{commentMap:_0x29d04b}=this[_0x257fa7(0x1c9)](_0x2a44e0,_0x34fe9f),_0x81ba81=_0x29d04b[_0x1b43d2];return _0x81ba81?(_0x81ba81[_0x257fa7(0x1d7)]=_0x2d081d,this['_commentUpdate$'][_0x257fa7(0x197)]({'unitId':_0x2a44e0,'subUnitId':_0x34fe9f,'type':'resolve','payload':{'commentId':_0x1b43d2,'resolved':_0x2d081d}}),this[_0x257fa7(0x18a)](),!0x0):!0x1;}[_0x52d455(0x188)](_0xc1aa5b,_0x421941,_0x17d7f9){const _0xf94cc5=_0x52d455,{commentMap:_0x133c3f}=this[_0xf94cc5(0x1c9)](_0xc1aa5b,_0x421941);return _0x133c3f[_0x17d7f9];}['getComment$'](_0x31eac2,_0x5df60a,_0x4b20e8){const _0x1566de=_0x52d455;return this['_commentsMap$'][_0x1566de(0x1cc)](map(_0x476046=>_0x476046[_0x31eac2][_0x5df60a][_0x4b20e8]));}[_0x52d455(0x1ad)](_0x105ddb,_0x46b351,_0x4e99c0){const _0x29f15f=_0x52d455;var _0x294dbd,_0x1fc4f8;const {commentMap:_0x318182,commentChildrenMap:_0x4e736e}=this[_0x29f15f(0x1c9)](_0x105ddb,_0x46b351),_0x3b6228=_0x318182[_0x4e99c0];if(!_0x3b6228)return;const _0x75703f=new Set(),_0x59b673=_0x4e736e[_0x29f15f(0x1e9)](_0x4e99c0);if(_0x59b673)return[_0x59b673,...(_0x294dbd=_0x59b673[_0x29f15f(0x1a7)])!=null?_0x294dbd:[]][_0x29f15f(0x1e2)](_0x224483=>{const _0x966c1=_0x29f15f;var _0x20361a;_0x75703f[_0x966c1(0x1ec)](_0x224483[_0x966c1(0x189)]),(_0x20361a=_0x224483['text'][_0x966c1(0x1f5)])==null||_0x20361a[_0x966c1(0x1e2)](_0x5332a8=>{const _0x39ffb4=_0x966c1;_0x5332a8[_0x39ffb4(0x19d)]===CustomRangeType[_0x39ffb4(0x1a3)]&&_0x75703f['add'](_0x5332a8[_0x39ffb4(0x180)]);});}),{'root':_0x3b6228,'children':(_0x1fc4f8=_0x59b673[_0x29f15f(0x1a7)])!=null?_0x1fc4f8:[],'relativeUsers':_0x75703f};}[_0x52d455(0x17d)](_0x35d3bb,_0x597416,_0x317b65){const _0x49d45c=_0x52d455;var _0x289a34;const {commentMap:_0x2770bf,commentChildrenMap:_0x19780b}=this[_0x49d45c(0x1c9)](_0x35d3bb,_0x597416),_0x374a3b=_0x2770bf[_0x317b65];if(!_0x374a3b)return!0x0;if(_0x374a3b['parentId']){const _0x13c572=_0x19780b[_0x49d45c(0x1e9)](_0x374a3b[_0x49d45c(0x1c8)]);if(_0x13c572&&_0x13c572[_0x49d45c(0x1a7)]){const _0x1981ba=_0x13c572[_0x49d45c(0x1a7)]['findIndex'](_0x1ab772=>_0x1ab772['id']===_0x317b65);_0x13c572[_0x49d45c(0x1a7)][_0x49d45c(0x1ac)](_0x1981ba,0x1);}delete _0x2770bf[_0x317b65];}else{delete _0x2770bf[_0x317b65];const _0x162f3b=_0x19780b['get'](_0x317b65);_0x19780b[_0x49d45c(0x1a4)](_0x317b65),this[_0x49d45c(0x1b5)](_0x35d3bb)[_0x49d45c(0x1a4)](_0x374a3b[_0x49d45c(0x1ed)]),(_0x289a34=_0x162f3b==null?void 0x0:_0x162f3b[_0x49d45c(0x1a7)])==null||_0x289a34[_0x49d45c(0x1e2)](_0x406d82=>{const _0x40ec4d=_0x49d45c;delete _0x2770bf[_0x406d82['id']],this[_0x40ec4d(0x1bf)][_0x40ec4d(0x197)]({'unitId':_0x35d3bb,'subUnitId':_0x597416,'type':'delete','payload':{'commentId':_0x406d82['id'],'isRoot':!0x1,'comment':_0x406d82}});});}return this[_0x49d45c(0x1bf)][_0x49d45c(0x197)]({'unitId':_0x35d3bb,'subUnitId':_0x597416,'type':_0x49d45c(0x1a4),'payload':{'commentId':_0x317b65,'isRoot':!_0x374a3b[_0x49d45c(0x1c8)],'comment':_0x374a3b}}),this[_0x49d45c(0x18a)](),!0x0;}[_0x52d455(0x1cf)](_0x3ef2c4){const _0x3578df=_0x52d455,_0x279746=this[_0x3578df(0x1ef)][_0x3ef2c4];return _0x279746?Array[_0x3578df(0x1f6)](Object[_0x3578df(0x18d)](_0x279746))['map'](([_0x5f2016,_0x44b188])=>[_0x5f2016,Array[_0x3578df(0x1f6)](Object['values'](_0x44b188))]):[];}[_0x52d455(0x1d5)](_0x5e72d){const _0xe3ac35=_0x52d455,_0x4257d=this[_0xe3ac35(0x1ef)][_0x5e72d];_0x4257d&&Object[_0xe3ac35(0x18d)](_0x4257d)[_0xe3ac35(0x1e2)](([_0x681352,_0x25defd])=>{const _0x27b6f1=_0xe3ac35;Object[_0x27b6f1(0x1d9)](_0x25defd)[_0x27b6f1(0x1e2)](_0x51e560=>{const _0x450ccb=_0x27b6f1;this[_0x450ccb(0x17d)](_0x5e72d,_0x681352,_0x51e560['id']);});});}[_0x52d455(0x1f3)](_0x2ac8a6,_0x3c3d43){const _0x323b93=_0x52d455,_0x57c55b=this[_0x323b93(0x1ca)](_0x2ac8a6,_0x3c3d43);return Array[_0x323b93(0x1f6)](_0x57c55b[_0x323b93(0x192)]());}[_0x52d455(0x185)](){return this['_commentsMap'];}[_0x52d455(0x1d8)](_0x19cfc8,_0x2efd18){const _0x27a440=_0x52d455;return this[_0x27a440(0x1b5)](_0x19cfc8)[_0x27a440(0x1e9)](_0x2efd18);}},__name(_a,_0x52d455(0x1bd)),_a);ThreadCommentModel=__decorateClass$2([__decorateParam$2(0x0,Inject(IThreadCommentDataSourceService)),__decorateParam$2(0x1,ICommandService)],ThreadCommentModel);function _0x79f9(){const _0x10bbfd=['_commentsMap','thread-comment.command.delete-comment-tree','_injector','updateComment','getRootCommentIds','_ensureCommentMap','customRanges','from','3160070FAFxvn','updateT','7WazgPA','overrides','resolve','_commentsTreeMap','thread-comment.command.delete-comment','set','deleteComment','18SWhkDZ','_initSnapshot','rangeId','UNIVER_SHEET','UNIVER_THREAD_COMMENT_PLUGIN','addComment','__decorateClass$2','getAll','toJson','fromChangeset','getComment','personId','_refreshCommentsMap$','SHEET_','72HWWpYx','entries','onLoad','_commentsMap$','1vFwweL','syncThreadComments','keys','updated','thread-comment.command.add-comment','thread-comment.mutation.add-comment','774036biuhRM','next','defineProperty','params','_config','__decorateParam$1','thread-comment.command.update-comment','rangeType','commentMap$','UNIVER_PROJECT','_dataSourceService','univer.thread-comment.data-source-service','executeCommand','MENTION','delete','listComments','symbol','children','asObservable','complete','1247928UVolHD','__decorateParam$2','splice','getCommentWithChildren','COMMAND','1210998mezBIy','setConfig','getOwnPropertyDescriptor','_threadCommentDataSourceService','ref','syncUpdateMutationToColla','_ensureThreadMap','UNRECOGNIZED','thread-comment.mutation.update-comment','_dataSource','root','UNIVER_UNKNOWN','registerPluginResource','saveToSnapshot','ThreadCommentModel','parse','_commentUpdate$','syncUpdate','1302528zYpXsq','thread-comment.config','_resourceManagerService','451575TXzTbJ','map','saveCommentToSnapshot','registerCommand','parentId','ensureMap','_ensureCommentChildrenMap','disposeWithMe','pipe','resolveComment','_threadCommentModel','getUnit','length','UNIVER_DOC','onStarting','name','943972ArlKFX','deleteUnit','dataSource','resolved','getThread','values','MUTATION','text','thread-comment.mutation.delete-comment','_configService','subUnitId','onUnLoad','parseJson','_replaceComment','forEach','_commandService','update','updateCommentRef','commentId','_threadMap','listThreadComments','get','UNIVER_SLIDE','unitId','add','threadId','attachments'];_0x79f9=function(){return _0x10bbfd;};return _0x79f9();}var I=(_0x3be0bc=>(_0x3be0bc[_0x3be0bc['UNIVER_UNKNOWN']=0x0]='UNIVER_UNKNOWN',_0x3be0bc[_0x3be0bc['UNIVER_DOC']=0x1]=_0x52d455(0x1d1),_0x3be0bc[_0x3be0bc['UNIVER_SHEET']=0x2]=_0x52d455(0x181),_0x3be0bc[_0x3be0bc[_0x52d455(0x1ea)]=0x3]='UNIVER_SLIDE',_0x3be0bc[_0x3be0bc[_0x52d455(0x19f)]=0x4]=_0x52d455(0x19f),_0x3be0bc[_0x3be0bc[_0x52d455(0x1b6)]=-0x1]=_0x52d455(0x1b6),_0x3be0bc))(I||{});const TC_PLUGIN_NAME=_0x52d455(0x182);var __defProp$1=Object[_0x52d455(0x198)],__getOwnPropDesc$1=Object[_0x52d455(0x1b1)],__decorateClass$1=__name((_0x73f0c6,_0x48a7cf,_0x11b2e,_0x3f7429)=>{const _0x4c9f16=_0x52d455;for(var _0x1fe5c5=_0x3f7429>0x1?void 0x0:_0x3f7429?__getOwnPropDesc$1(_0x48a7cf,_0x11b2e):_0x48a7cf,_0x2a08bf=_0x73f0c6[_0x4c9f16(0x1d0)]-0x1,_0x532612;_0x2a08bf>=0x0;_0x2a08bf--)(_0x532612=_0x73f0c6[_0x2a08bf])&&(_0x1fe5c5=(_0x3f7429?_0x532612(_0x48a7cf,_0x11b2e,_0x1fe5c5):_0x532612(_0x1fe5c5))||_0x1fe5c5);return _0x3f7429&&_0x1fe5c5&&__defProp$1(_0x48a7cf,_0x11b2e,_0x1fe5c5),_0x1fe5c5;},'__decorateClass$1'),__decorateParam$1=__name((_0x197a88,_0xef82b5)=>(_0x218c2b,_0x19fe8b)=>_0xef82b5(_0x218c2b,_0x19fe8b,_0x197a88),_0x52d455(0x19b)),_a2;let ThreadCommentResourceController=(_a2=class extends Disposable{constructor(_0xfd8733,_0x305dbc,_0x308009){const _0x29bcc4=_0x52d455;super(),this[_0x29bcc4(0x1c3)]=_0xfd8733,this[_0x29bcc4(0x1ce)]=_0x305dbc,this[_0x29bcc4(0x1b2)]=_0x308009,this[_0x29bcc4(0x17f)]();}[_0x52d455(0x17f)](){const _0x4ad904=_0x52d455,_0x4ec245=__name(_0x21e65e=>{const _0x2375d0=_0x4ad1,_0x25c50d=this['_threadCommentModel'][_0x2375d0(0x1cf)](_0x21e65e),_0xd9585c={};return _0x25c50d?(_0x25c50d['forEach'](([_0x144523,_0x4d3533])=>{_0xd9585c[_0x144523]=_0x4d3533;}),JSON['stringify'](this['_threadCommentDataSourceService']['saveToSnapshot'](_0xd9585c,_0x21e65e))):'';},_0x4ad904(0x186)),_0x38dd49=__name(_0x30bb95=>{const _0x485413=_0x4ad904;if(!_0x30bb95)return{};try{return JSON[_0x485413(0x1be)](_0x30bb95);}catch{return{};}},_0x4ad904(0x1e0));this[_0x4ad904(0x1cb)](this[_0x4ad904(0x1c3)][_0x4ad904(0x1bb)]({'pluginName':_0x4ad904(0x18b)+TC_PLUGIN_NAME,'businesses':[I[_0x4ad904(0x181)],I[_0x4ad904(0x1d1)]],'toJson':__name(_0x194e42=>_0x4ec245(_0x194e42),_0x4ad904(0x186)),'parseJson':__name(_0x3406c9=>_0x38dd49(_0x3406c9),'parseJson'),'onUnLoad':__name(_0x40511b=>{const _0xa477b2=_0x4ad904;this[_0xa477b2(0x1ce)]['deleteUnit'](_0x40511b);},_0x4ad904(0x1df)),'onLoad':__name(async(_0x253167,_0x377190)=>{const _0x3b3e42=_0x4ad904;Object['keys'](_0x377190)[_0x3b3e42(0x1e2)](_0x542c0a=>{const _0x59b2ef=_0x3b3e42,_0xc006d=_0x377190[_0x542c0a];_0xc006d[_0x59b2ef(0x1e2)](_0x2e25eb=>{const _0x1ee8b4=_0x59b2ef;this[_0x1ee8b4(0x1ce)][_0x1ee8b4(0x183)](_0x253167,_0x542c0a,_0x2e25eb);}),this['_threadCommentModel'][_0x59b2ef(0x191)](_0x253167,_0x542c0a,_0xc006d[_0x59b2ef(0x1c5)](_0x1651ea=>_0x1651ea['threadId']));});},_0x4ad904(0x18e))}));}},__name(_a2,'ThreadCommentResourceController'),_a2);ThreadCommentResourceController=__decorateClass$1([__decorateParam$1(0x0,IResourceManagerService),__decorateParam$1(0x1,Inject(ThreadCommentModel)),__decorateParam$1(0x2,IThreadCommentDataSourceService)],ThreadCommentResourceController);const AddCommentMutation={'id':_0x52d455(0x195),'type':CommandType['MUTATION'],'handler'(_0x29d2f4,_0x2f81a4,_0x45d6bf){const _0xc351f9=_0x52d455;if(!_0x2f81a4)return!0x1;const _0x444866=_0x29d2f4['get'](ThreadCommentModel),{unitId:_0x215dce,subUnitId:_0x5555b7,comment:_0x4d7478,sync:_0x2fbd13}=_0x2f81a4,_0x47c92b=_0x2fbd13||(_0x45d6bf==null?void 0x0:_0x45d6bf[_0xc351f9(0x187)])&&!_0x4d7478[_0xc351f9(0x1c8)];return _0x444866[_0xc351f9(0x183)](_0x215dce,_0x5555b7,_0x4d7478,_0x47c92b);}},UpdateCommentMutation={'id':_0x52d455(0x1b7),'type':CommandType[_0x52d455(0x1da)],'handler'(_0x528682,_0x3c50af){const _0x37a9c7=_0x52d455;if(!_0x3c50af)return!0x1;const _0x27d0ee=_0x528682[_0x37a9c7(0x1e9)](ThreadCommentModel),{unitId:_0x22cbc6,subUnitId:_0x51a191,payload:_0x3ef60f,silent:_0x225269}=_0x3c50af;return _0x27d0ee['updateComment'](_0x22cbc6,_0x51a191,_0x3ef60f,_0x225269);}},UpdateCommentRefMutation={'id':'thread-comment.mutation.update-comment-ref','type':CommandType['MUTATION'],'handler'(_0x2ef586,_0x4f10cd){const _0x444508=_0x52d455;if(!_0x4f10cd)return!0x1;const _0x5d03d3=_0x2ef586[_0x444508(0x1e9)](ThreadCommentModel),{unitId:_0x46b01c,subUnitId:_0x29805f,payload:_0x492e99,silent:_0x6df7b1}=_0x4f10cd;return _0x5d03d3[_0x444508(0x1e5)](_0x46b01c,_0x29805f,_0x492e99,_0x6df7b1);}},ResolveCommentMutation={'id':'thread-comment.mutation.resolve-comment','type':CommandType['MUTATION'],'handler'(_0x4a686d,_0x3eb42d){const _0x12c08e=_0x52d455;if(!_0x3eb42d)return!0x1;const _0xa2d304=_0x4a686d[_0x12c08e(0x1e9)](ThreadCommentModel),{unitId:_0x1b4c35,subUnitId:_0x372a16,resolved:_0x1b4212,commentId:_0xf09e1d}=_0x3eb42d;return _0xa2d304['resolveComment'](_0x1b4c35,_0x372a16,_0xf09e1d,_0x1b4212);}},DeleteCommentMutation={'id':_0x52d455(0x1dc),'type':CommandType[_0x52d455(0x1da)],'handler'(_0x9d1fd5,_0x163edb){const _0x9de78e=_0x52d455;if(!_0x163edb)return!0x1;const _0x4f493d=_0x9d1fd5[_0x9de78e(0x1e9)](ThreadCommentModel),{unitId:_0x3fe974,subUnitId:_0x22e71a,commentId:_0x279177}=_0x163edb;return _0x4f493d[_0x9de78e(0x17d)](_0x3fe974,_0x22e71a,_0x279177);}},AddCommentCommand={'id':_0x52d455(0x194),'type':CommandType[_0x52d455(0x1ae)],async 'handler'(_0x3ba147,_0x298aaa){const _0x813e93=_0x52d455;if(!_0x298aaa)return!0x1;const _0x2cfcc0=_0x3ba147[_0x813e93(0x1e9)](ICommandService),_0xb791e7=_0x3ba147[_0x813e93(0x1e9)](IThreadCommentDataSourceService),{comment:_0x57e340}=_0x298aaa,_0x1939fd=await _0xb791e7[_0x813e93(0x183)](_0x57e340),_0x2778cc=_0xb791e7[_0x813e93(0x1b4)],_0x4e346d=!_0x57e340[_0x813e93(0x1c8)],_0x35202c={'id':AddCommentMutation['id'],'params':{..._0x298aaa,'comment':_0x1939fd}};return _0x4e346d?await _0x2cfcc0[_0x813e93(0x1a2)](_0x35202c['id'],_0x35202c['params']):_0x2cfcc0[_0x813e93(0x1a2)](_0x35202c['id'],_0x35202c[_0x813e93(0x199)],{'onlyLocal':!_0x2778cc});}},UpdateCommentCommand={'id':_0x52d455(0x19c),'type':CommandType[_0x52d455(0x1ae)],async 'handler'(_0x16b413,_0x1ed1ae){const _0x38f9e3=_0x52d455;if(!_0x1ed1ae)return!0x1;const {unitId:_0x41be3e,subUnitId:_0x187d40,payload:_0x9856b4}=_0x1ed1ae,_0xe0797f=_0x16b413[_0x38f9e3(0x1e9)](ICommandService),_0x148966=_0x16b413[_0x38f9e3(0x1e9)](ThreadCommentModel),_0x5a65e9=_0x16b413[_0x38f9e3(0x1e9)](IThreadCommentDataSourceService),_0x3655e5=_0x5a65e9[_0x38f9e3(0x1b4)],_0x57aaa0=_0x148966[_0x38f9e3(0x188)](_0x41be3e,_0x187d40,_0x9856b4[_0x38f9e3(0x1e6)]);if(!_0x57aaa0)return!0x1;const {children:_0x3dcc52,..._0x11e3a4}=_0x57aaa0;if(!await _0x5a65e9[_0x38f9e3(0x1f2)]({..._0x11e3a4,..._0x9856b4}))return!0x1;const _0x1043df={'id':UpdateCommentMutation['id'],'params':_0x1ed1ae};return _0xe0797f[_0x38f9e3(0x1a2)](_0x1043df['id'],_0x1043df[_0x38f9e3(0x199)],{'onlyLocal':!_0x3655e5}),!0x0;}},ResolveCommentCommand={'id':'thread-comment.command.resolve-comment','type':CommandType['COMMAND'],async 'handler'(_0x182d94,_0xa189d){const _0x20132c=_0x52d455;if(!_0xa189d)return!0x1;const {unitId:_0x4a4992,subUnitId:_0x373ecc,resolved:_0x34b1d9,commentId:_0x543485}=_0xa189d,_0x1f77eb=_0x182d94[_0x20132c(0x1e9)](IThreadCommentDataSourceService),_0x298984=_0x182d94[_0x20132c(0x1e9)](ThreadCommentModel)['getComment'](_0x4a4992,_0x373ecc,_0x543485),_0x49898c=_0x1f77eb[_0x20132c(0x1b4)];return!_0x298984||!await _0x1f77eb[_0x20132c(0x1cd)]({..._0x298984,'resolved':_0x34b1d9})?!0x1:_0x182d94[_0x20132c(0x1e9)](ICommandService)[_0x20132c(0x1a2)](ResolveCommentMutation['id'],_0xa189d,{'onlyLocal':!_0x49898c});}},DeleteCommentCommand={'id':_0x52d455(0x17b),'type':CommandType['COMMAND'],async 'handler'(_0x42f60e,_0xf8ed78){const _0x3b7d49=_0x52d455;if(!_0xf8ed78)return!0x1;const _0x21ab81=_0x42f60e[_0x3b7d49(0x1e9)](ThreadCommentModel),_0x3e9e2b=_0x42f60e['get'](IThreadCommentDataSourceService),_0x55ed96=_0x42f60e['get'](ICommandService),{unitId:_0x3ddb81,subUnitId:_0x43fd70,commentId:_0x51f279}=_0xf8ed78,_0x4094fe=_0x3e9e2b[_0x3b7d49(0x1b4)],_0x215942=_0x21ab81[_0x3b7d49(0x188)](_0x3ddb81,_0x43fd70,_0x51f279);if(!_0x215942||!await _0x3e9e2b[_0x3b7d49(0x17d)](_0x3ddb81,_0x43fd70,_0x215942[_0x3b7d49(0x1ed)],_0x51f279))return!0x1;const _0x2f4f7b={'id':DeleteCommentMutation['id'],'params':_0xf8ed78};return _0x55ed96[_0x3b7d49(0x1a2)](_0x2f4f7b['id'],_0x2f4f7b[_0x3b7d49(0x199)],{'onlyLocal':!_0x4094fe});}},DeleteCommentTreeCommand={'id':_0x52d455(0x1f0),'type':CommandType[_0x52d455(0x1ae)],async 'handler'(_0x4dbb0c,_0x3d58a3){const _0x4d129c=_0x52d455;if(!_0x3d58a3)return!0x1;const _0x2f94e4=_0x4dbb0c[_0x4d129c(0x1e9)](ThreadCommentModel),_0xbb714a=_0x4dbb0c[_0x4d129c(0x1e9)](ICommandService),_0xde449c=_0x4dbb0c['get'](IThreadCommentDataSourceService),{unitId:_0x3abe7b,subUnitId:_0x647bd3,commentId:_0x3e6340}=_0x3d58a3,_0x162e5d=_0x2f94e4[_0x4d129c(0x1ad)](_0x3abe7b,_0x647bd3,_0x3e6340);return!_0x162e5d||!await _0xde449c[_0x4d129c(0x17d)](_0x3abe7b,_0x647bd3,_0x162e5d[_0x4d129c(0x1b9)][_0x4d129c(0x1ed)],_0x3e6340)?!0x1:await _0xbb714a[_0x4d129c(0x1a2)](DeleteCommentMutation['id'],{'unitId':_0x3abe7b,'subUnitId':_0x647bd3,'commentId':_0x162e5d[_0x4d129c(0x1b9)]['id']});}},PLUGIN_CONFIG_KEY=_0x52d455(0x1c2),defaultPluginConfig={};var __defProp2=Object[_0x52d455(0x198)],__getOwnPropDesc=Object[_0x52d455(0x1b1)],__decorateClass=__name((_0x1f6cd3,_0x2ff3e8,_0x4b6765,_0x2a6def)=>{const _0x35f68a=_0x52d455;for(var _0x14ef0c=_0x2a6def>0x1?void 0x0:_0x2a6def?__getOwnPropDesc(_0x2ff3e8,_0x4b6765):_0x2ff3e8,_0xdd560b=_0x1f6cd3[_0x35f68a(0x1d0)]-0x1,_0x11a0e4;_0xdd560b>=0x0;_0xdd560b--)(_0x11a0e4=_0x1f6cd3[_0xdd560b])&&(_0x14ef0c=(_0x2a6def?_0x11a0e4(_0x2ff3e8,_0x4b6765,_0x14ef0c):_0x11a0e4(_0x14ef0c))||_0x14ef0c);return _0x2a6def&&_0x14ef0c&&__defProp2(_0x2ff3e8,_0x4b6765,_0x14ef0c),_0x14ef0c;},'__decorateClass'),__decorateParam=__name((_0x784f5,_0x1cf8e2)=>(_0x55d753,_0xae7efa)=>_0x1cf8e2(_0x55d753,_0xae7efa,_0x784f5),'__decorateParam'),_a3;let UniverThreadCommentPlugin=(_a3=class extends Plugin{constructor(_0xb165c5=defaultPluginConfig,_0x253d77,_0x5762c2,_0x456305){const _0x2bcb7a=_0x52d455;super(),this['_config']=_0xb165c5,this[_0x2bcb7a(0x1f1)]=_0x253d77,this[_0x2bcb7a(0x1e3)]=_0x5762c2,this[_0x2bcb7a(0x1dd)]=_0x456305;const {..._0xbebfef}=this[_0x2bcb7a(0x19a)];this['_configService'][_0x2bcb7a(0x1b0)](PLUGIN_CONFIG_KEY,_0xbebfef);}[_0x52d455(0x1d2)](){const _0x2a791b=_0x52d455;var _0x32526c;mergeOverrideWithDependencies([[IThreadCommentDataSourceService,{'useClass':ThreadCommentDataSourceService}],[ThreadCommentModel],[ThreadCommentResourceController]],(_0x32526c=this['_config'])==null?void 0x0:_0x32526c[_0x2a791b(0x178)])[_0x2a791b(0x1e2)](_0x35a9b8=>{this['_injector']['add'](_0x35a9b8);}),[AddCommentCommand,UpdateCommentCommand,DeleteCommentCommand,ResolveCommentCommand,DeleteCommentTreeCommand,AddCommentMutation,UpdateCommentMutation,UpdateCommentRefMutation,DeleteCommentMutation,ResolveCommentMutation][_0x2a791b(0x1e2)](_0xeab68=>{const _0x653816=_0x2a791b;this[_0x653816(0x1e3)][_0x653816(0x1c7)](_0xeab68);}),this[_0x2a791b(0x1f1)][_0x2a791b(0x1e9)](ThreadCommentResourceController);}},__name(_a3,'UniverThreadCommentPlugin'),__publicField(_a3,'pluginName',TC_PLUGIN_NAME),__publicField(_a3,'type',UniverInstanceType[_0x52d455(0x1ba)]),_a3);UniverThreadCommentPlugin=__decorateClass([__decorateParam(0x1,Inject(Injector)),__decorateParam(0x2,ICommandService),__decorateParam(0x3,IConfigService)],UniverThreadCommentPlugin);export{AddCommentCommand,AddCommentMutation,DeleteCommentCommand,DeleteCommentMutation,DeleteCommentTreeCommand,IThreadCommentDataSourceService,ResolveCommentCommand,ResolveCommentMutation,TC_PLUGIN_NAME,ThreadCommentDataSourceService,ThreadCommentModel,ThreadCommentResourceController,UniverThreadCommentPlugin,UpdateCommentCommand,UpdateCommentMutation,UpdateCommentRefMutation};
@@ -1,6 +1,6 @@
1
+ import { IThreadComment } from '../types/interfaces/i-thread-comment';
1
2
  import { Disposable, IResourceManagerService } from '@univerjs/core';
2
3
  import { ThreadCommentModel } from '../models/thread-comment.model';
3
- import { IThreadComment } from '../types/interfaces/i-thread-comment';
4
4
  import { IThreadCommentDataSourceService } from '../services/tc-datasource.service';
5
5
  export type UnitThreadCommentJSON = Record<string, IThreadComment[]>;
6
6
  export declare class ThreadCommentResourceController extends Disposable {
@@ -1,5 +1,5 @@
1
- import { ICommandService, IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
2
1
  import { IUniverThreadCommentConfig } from './controllers/config.schema';
2
+ import { ICommandService, IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
3
3
  export declare class UniverThreadCommentPlugin extends Plugin {
4
4
  private readonly _config;
5
5
  protected _injector: Injector;
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverThreadComment={},global.UniverCore,global.rxjs))})(this,function(exports2,core,rxjs){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c;const _ThreadCommentDataSourceService=class _ThreadCommentDataSourceService extends core.Disposable{constructor(){super();__publicField(this,"_dataSource",null);__publicField(this,"syncUpdateMutationToColla",!0)}set dataSource(dataSource){this._dataSource=dataSource}get dataSource(){return this._dataSource}async getThreadComment(unitId,subUnitId,threadId){return this._dataSource?(await this._dataSource.listComments(unitId,subUnitId,[threadId]))[0]:null}async addComment(comment){return this._dataSource?this._dataSource.addComment(comment):comment}async updateComment(comment){return this._dataSource?this._dataSource.updateComment(comment):!0}async resolveComment(comment){return this._dataSource?this._dataSource.resolveComment(comment):!0}async deleteComment(unitId,subUnitId,threadId,commentId){return this._dataSource?this._dataSource.deleteComment(unitId,subUnitId,threadId,commentId):!0}async listThreadComments(unitId,subUnitId,threadIds){return this.dataSource?this.dataSource.listComments(unitId,subUnitId,threadIds):[]}saveToSnapshot(unitComments,unitId){if(this._dataSource){const map={};return Object.keys(unitComments).forEach(subUnitId=>{const comments=unitComments[subUnitId];map[subUnitId]=comments.map(this.dataSource.saveCommentToSnapshot)}),map}return unitComments}};__name(_ThreadCommentDataSourceService,"ThreadCommentDataSourceService");let ThreadCommentDataSourceService=_ThreadCommentDataSourceService;const IThreadCommentDataSourceService=core.createIdentifier("univer.thread-comment.data-source-service");var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");exports2.ThreadCommentModel=(_a=class extends core.Disposable{constructor(_dataSourceService,_commandService){super();__publicField(this,"_commentsMap",{});__publicField(this,"_commentsTreeMap",new Map);__publicField(this,"_threadMap",new Map);__publicField(this,"_commentUpdate$",new rxjs.Subject);__publicField(this,"_commentsMap$",new rxjs.BehaviorSubject({}));__publicField(this,"commentUpdate$",this._commentUpdate$.asObservable());__publicField(this,"commentMap$",this._commentsMap$.asObservable());this._dataSourceService=_dataSourceService,this._commandService=_commandService,this.disposeWithMe(()=>{this._commentUpdate$.complete(),this._commentsMap$.complete()})}_ensureCommentMap(unitId,subUnitId){let unitMap=this._commentsMap[unitId];unitMap||(unitMap={},this._commentsMap[unitId]=unitMap);let subUnitMap=unitMap[subUnitId];return subUnitMap||(subUnitMap={},unitMap[subUnitId]=subUnitMap),subUnitMap}_ensureCommentChildrenMap(unitId,subUnitId){let unitMap=this._commentsTreeMap.get(unitId);unitMap||(unitMap=new Map,this._commentsTreeMap.set(unitId,unitMap));let subUnitMap=unitMap.get(subUnitId);return subUnitMap||(subUnitMap=new Map,unitMap.set(subUnitId,subUnitMap)),subUnitMap}_ensureThreadMap(unitId){let unitMap=this._threadMap.get(unitId);return unitMap||(unitMap=new Map,this._threadMap.set(unitId,unitMap)),unitMap}_refreshCommentsMap$(){this._commentsMap$.next({...this._commentsMap})}ensureMap(unitId,subUnitId){const commentMap=this._ensureCommentMap(unitId,subUnitId),commentChildrenMap=this._ensureCommentChildrenMap(unitId,subUnitId);return{commentMap,commentChildrenMap}}_replaceComment(unitId,subUnitId,comment){var _a2;const{commentMap,commentChildrenMap}=this.ensureMap(unitId,subUnitId),currentComment=commentMap[comment.id];if(currentComment){const newComment={...comment,ref:currentComment.ref};commentMap[comment.id]=newComment,(_a2=comment.children)==null||_a2.forEach(child=>{commentMap[child.id]={...child,ref:""}}),commentChildrenMap.set(comment.id,newComment),this._commentUpdate$.next({unitId,subUnitId,type:"syncUpdate",payload:newComment}),!!comment.resolved!=!!currentComment.resolved&&this._commentUpdate$.next({unitId,subUnitId,type:"resolve",payload:{commentId:comment.id,resolved:!!comment.resolved}})}}async syncThreadComments(unitId,subUnitId,threadIds){const comments=await this._dataSourceService.listThreadComments(unitId,subUnitId,threadIds);if(!comments.length)return;const deleteThreads=new Set(threadIds);comments.forEach(comment=>{this._replaceComment(unitId,subUnitId,comment),deleteThreads.delete(comment.threadId)}),deleteThreads.forEach(id=>{const thread=this.getThread(unitId,id);thread&&this.deleteComment(thread.unitId,thread.subUnitId,thread.id)}),this._refreshCommentsMap$()}addComment(unitId,subUnitId,origin,shouldSync){var _a2,_b2;const{commentMap,commentChildrenMap}=this.ensureMap(unitId,subUnitId),comment=origin,addCommentItem=__name(item=>{commentMap[item.id]=item,this._commentUpdate$.next({unitId,subUnitId,type:"add",payload:item,isRoot:!item.parentId})},"addCommentItem"),parentId=comment.parentId;if(parentId){const parent=commentMap[parentId];parent.children=[...(_a2=parent.children)!=null?_a2:[],comment],addCommentItem(comment)}else commentChildrenMap.set(comment.id,comment),this._ensureThreadMap(unitId).set(comment.threadId,comment),addCommentItem(comment),(_b2=comment.children)==null||_b2.forEach(child=>addCommentItem({...child,ref:""}));return this._refreshCommentsMap$(),shouldSync&&this.syncThreadComments(unitId,subUnitId,[comment.threadId]),!0}updateComment(unitId,subUnitId,payload,silent){const{commentMap}=this.ensureMap(unitId,subUnitId),oldComment=commentMap[payload.commentId];return oldComment?(oldComment.updated=!0,oldComment.text=payload.text,oldComment.attachments=payload.attachments,oldComment.updateT=payload.updateT,this._commentUpdate$.next({unitId,subUnitId,type:"update",payload,silent}),this._refreshCommentsMap$(),!0):!1}updateCommentRef(unitId,subUnitId,payload,silent){const{commentMap}=this.ensureMap(unitId,subUnitId),oldComment=commentMap[payload.commentId];return oldComment?(oldComment.ref=payload.ref,this._commentUpdate$.next({unitId,subUnitId,type:"updateRef",payload,silent}),this._refreshCommentsMap$(),!0):!1}resolveComment(unitId,subUnitId,commentId,resolved){const{commentMap}=this.ensureMap(unitId,subUnitId),oldComment=commentMap[commentId];return oldComment?(oldComment.resolved=resolved,this._commentUpdate$.next({unitId,subUnitId,type:"resolve",payload:{commentId,resolved}}),this._refreshCommentsMap$(),!0):!1}getComment(unitId,subUnitId,commentId){const{commentMap}=this.ensureMap(unitId,subUnitId);return commentMap[commentId]}getComment$(unitId,subUnitId,commentId){return this._commentsMap$.pipe(rxjs.map(records=>records[unitId][subUnitId][commentId]))}getCommentWithChildren(unitId,subUnitId,commentId){var _a2,_b2;const{commentMap,commentChildrenMap}=this.ensureMap(unitId,subUnitId),current=commentMap[commentId];if(!current)return;const relativeUsers=new Set,root=commentChildrenMap.get(commentId);if(root)return[root,...(_a2=root.children)!=null?_a2:[]].forEach(comment=>{var _a3;relativeUsers.add(comment.personId),(_a3=comment.text.customRanges)==null||_a3.forEach(range=>{range.rangeType===core.CustomRangeType.MENTION&&relativeUsers.add(range.rangeId)})}),{root:current,children:(_b2=root.children)!=null?_b2:[],relativeUsers}}deleteComment(unitId,subUnitId,commentId){var _a2;const{commentMap,commentChildrenMap}=this.ensureMap(unitId,subUnitId),current=commentMap[commentId];if(!current)return!0;if(current.parentId){const root=commentChildrenMap.get(current.parentId);if(root&&root.children){const index=root.children.findIndex(comment=>comment.id===commentId);root.children.splice(index,1)}delete commentMap[commentId]}else{delete commentMap[commentId];const comment=commentChildrenMap.get(commentId);commentChildrenMap.delete(commentId),this._ensureThreadMap(unitId).delete(current.threadId),(_a2=comment==null?void 0:comment.children)==null||_a2.forEach(child=>{delete commentMap[child.id],this._commentUpdate$.next({unitId,subUnitId,type:"delete",payload:{commentId:child.id,isRoot:!1,comment:child}})})}return this._commentUpdate$.next({unitId,subUnitId,type:"delete",payload:{commentId,isRoot:!current.parentId,comment:current}}),this._refreshCommentsMap$(),!0}getUnit(unitId){const unitMap=this._commentsMap[unitId];return unitMap?Array.from(Object.entries(unitMap)).map(([subUnitId,subUnitMap])=>[subUnitId,Array.from(Object.values(subUnitMap))]):[]}deleteUnit(unitId){const unitMap=this._commentsMap[unitId];unitMap&&Object.entries(unitMap).forEach(([subUnitId,subUnitMap])=>{Object.values(subUnitMap).forEach(comment=>{this.deleteComment(unitId,subUnitId,comment.id)})})}getRootCommentIds(unitId,subUnitId){const commentChildrenMap=this._ensureCommentChildrenMap(unitId,subUnitId);return Array.from(commentChildrenMap.keys())}getAll(){return this._commentsMap}getThread(unitId,threadId){return this._ensureThreadMap(unitId).get(threadId)}},__name(_a,"ThreadCommentModel"),_a),exports2.ThreadCommentModel=__decorateClass$2([__decorateParam$2(0,core.Inject(IThreadCommentDataSourceService)),__decorateParam$2(1,core.ICommandService)],exports2.ThreadCommentModel);var I=(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))(I||{});const TC_PLUGIN_NAME="UNIVER_THREAD_COMMENT_PLUGIN";var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");exports2.ThreadCommentResourceController=(_b=class extends core.Disposable{constructor(_resourceManagerService,_threadCommentModel,_threadCommentDataSourceService){super(),this._resourceManagerService=_resourceManagerService,this._threadCommentModel=_threadCommentModel,this._threadCommentDataSourceService=_threadCommentDataSourceService,this._initSnapshot()}_initSnapshot(){const toJson=__name(unitID=>{const map=this._threadCommentModel.getUnit(unitID),resultMap={};return map?(map.forEach(([key,v])=>{resultMap[key]=v}),JSON.stringify(this._threadCommentDataSourceService.saveToSnapshot(resultMap,unitID))):""},"toJson"),parseJson=__name(json=>{if(!json)return{};try{return JSON.parse(json)}catch{return{}}},"parseJson");this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:`SHEET_${TC_PLUGIN_NAME}`,businesses:[I.UNIVER_SHEET,I.UNIVER_DOC],toJson:__name(unitID=>toJson(unitID),"toJson"),parseJson:__name(json=>parseJson(json),"parseJson"),onUnLoad:__name(unitID=>{this._threadCommentModel.deleteUnit(unitID)},"onUnLoad"),onLoad:__name(async(unitID,value)=>{Object.keys(value).forEach(subunitId=>{const commentList=value[subunitId];commentList.forEach(comment=>{this._threadCommentModel.addComment(unitID,subunitId,comment)}),this._threadCommentModel.syncThreadComments(unitID,subunitId,commentList.map(i=>i.threadId))})},"onLoad")}))}},__name(_b,"ThreadCommentResourceController"),_b),exports2.ThreadCommentResourceController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,exports2.ThreadCommentResourceController),__decorateParam$1(0,core.IResourceManagerService),__decorateParam$1(1,core.Inject(exports2.ThreadCommentModel)),__decorateParam$1(2,IThreadCommentDataSourceService)],exports2.ThreadCommentResourceController);const AddCommentMutation={id:"thread-comment.mutation.add-comment",type:core.CommandType.MUTATION,handler(accessor,params,options){if(!params)return!1;const threadCommentModel=accessor.get(exports2.ThreadCommentModel),{unitId,subUnitId,comment,sync}=params,shouldSync=sync||(options==null?void 0:options.fromChangeset)&&!comment.parentId;return threadCommentModel.addComment(unitId,subUnitId,comment,shouldSync)}},UpdateCommentMutation={id:"thread-comment.mutation.update-comment",type:core.CommandType.MUTATION,handler(accessor,params){if(!params)return!1;const threadCommentModel=accessor.get(exports2.ThreadCommentModel),{unitId,subUnitId,payload,silent}=params;return threadCommentModel.updateComment(unitId,subUnitId,payload,silent)}},UpdateCommentRefMutation={id:"thread-comment.mutation.update-comment-ref",type:core.CommandType.MUTATION,handler(accessor,params){if(!params)return!1;const threadCommentModel=accessor.get(exports2.ThreadCommentModel),{unitId,subUnitId,payload,silent}=params;return threadCommentModel.updateCommentRef(unitId,subUnitId,payload,silent)}},ResolveCommentMutation={id:"thread-comment.mutation.resolve-comment",type:core.CommandType.MUTATION,handler(accessor,params){if(!params)return!1;const threadCommentModel=accessor.get(exports2.ThreadCommentModel),{unitId,subUnitId,resolved,commentId}=params;return threadCommentModel.resolveComment(unitId,subUnitId,commentId,resolved)}},DeleteCommentMutation={id:"thread-comment.mutation.delete-comment",type:core.CommandType.MUTATION,handler(accessor,params){if(!params)return!1;const threadCommentModel=accessor.get(exports2.ThreadCommentModel),{unitId,subUnitId,commentId}=params;return threadCommentModel.deleteComment(unitId,subUnitId,commentId)}},AddCommentCommand={id:"thread-comment.command.add-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const commandService=accessor.get(core.ICommandService),dataSourceService=accessor.get(IThreadCommentDataSourceService),{comment:originComment}=params,comment=await dataSourceService.addComment(originComment),syncUpdateMutationToColla=dataSourceService.syncUpdateMutationToColla,isRoot=!originComment.parentId,redo={id:AddCommentMutation.id,params:{...params,comment}};return isRoot?await commandService.executeCommand(redo.id,redo.params):commandService.executeCommand(redo.id,redo.params,{onlyLocal:!syncUpdateMutationToColla})}},UpdateCommentCommand={id:"thread-comment.command.update-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const{unitId,subUnitId,payload}=params,commandService=accessor.get(core.ICommandService),threadCommentModel=accessor.get(exports2.ThreadCommentModel),dataSourceService=accessor.get(IThreadCommentDataSourceService),syncUpdateMutationToColla=dataSourceService.syncUpdateMutationToColla,current=threadCommentModel.getComment(unitId,subUnitId,payload.commentId);if(!current)return!1;const{children,...currentComment}=current;if(!await dataSourceService.updateComment({...currentComment,...payload}))return!1;const redo={id:UpdateCommentMutation.id,params};return commandService.executeCommand(redo.id,redo.params,{onlyLocal:!syncUpdateMutationToColla}),!0}},ResolveCommentCommand={id:"thread-comment.command.resolve-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const{unitId,subUnitId,resolved,commentId}=params,dataSourceService=accessor.get(IThreadCommentDataSourceService),currentComment=accessor.get(exports2.ThreadCommentModel).getComment(unitId,subUnitId,commentId),syncUpdateMutationToColla=dataSourceService.syncUpdateMutationToColla;return!currentComment||!await dataSourceService.resolveComment({...currentComment,resolved})?!1:accessor.get(core.ICommandService).executeCommand(ResolveCommentMutation.id,params,{onlyLocal:!syncUpdateMutationToColla})}},DeleteCommentCommand={id:"thread-comment.command.delete-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const threadCommentModel=accessor.get(exports2.ThreadCommentModel),dataSourceService=accessor.get(IThreadCommentDataSourceService),commandService=accessor.get(core.ICommandService),{unitId,subUnitId,commentId}=params,syncUpdateMutationToColla=dataSourceService.syncUpdateMutationToColla,comment=threadCommentModel.getComment(unitId,subUnitId,commentId);if(!comment||!await dataSourceService.deleteComment(unitId,subUnitId,comment.threadId,commentId))return!1;const redo={id:DeleteCommentMutation.id,params};return commandService.executeCommand(redo.id,redo.params,{onlyLocal:!syncUpdateMutationToColla})}},DeleteCommentTreeCommand={id:"thread-comment.command.delete-comment-tree",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const threadCommentModel=accessor.get(exports2.ThreadCommentModel),commandService=accessor.get(core.ICommandService),dataSourceService=accessor.get(IThreadCommentDataSourceService),{unitId,subUnitId,commentId}=params,commentWithChildren=threadCommentModel.getCommentWithChildren(unitId,subUnitId,commentId);return!commentWithChildren||!await dataSourceService.deleteComment(unitId,subUnitId,commentWithChildren.root.threadId,commentId)?!1:await commandService.executeCommand(DeleteCommentMutation.id,{unitId,subUnitId,commentId:commentWithChildren.root.id})}},PLUGIN_CONFIG_KEY="thread-comment.config",defaultPluginConfig={};var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam");exports2.UniverThreadCommentPlugin=(_c=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_commandService,_configService){super(),this._config=_config,this._injector=_injector,this._commandService=_commandService,this._configService=_configService;const{...rest}=this._config;this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){var _a2;core.mergeOverrideWithDependencies([[IThreadCommentDataSourceService,{useClass:ThreadCommentDataSourceService}],[exports2.ThreadCommentModel],[exports2.ThreadCommentResourceController]],(_a2=this._config)==null?void 0:_a2.overrides).forEach(d=>{this._injector.add(d)}),[AddCommentCommand,UpdateCommentCommand,DeleteCommentCommand,ResolveCommentCommand,DeleteCommentTreeCommand,AddCommentMutation,UpdateCommentMutation,UpdateCommentRefMutation,DeleteCommentMutation,ResolveCommentMutation].forEach(command=>{this._commandService.registerCommand(command)})}},__name(_c,"UniverThreadCommentPlugin"),__publicField(_c,"pluginName",TC_PLUGIN_NAME),__publicField(_c,"type",core.UniverInstanceType.UNIVER_UNKNOWN),_c),exports2.UniverThreadCommentPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.ICommandService),__decorateParam(3,core.IConfigService)],exports2.UniverThreadCommentPlugin),exports2.AddCommentCommand=AddCommentCommand,exports2.AddCommentMutation=AddCommentMutation,exports2.DeleteCommentCommand=DeleteCommentCommand,exports2.DeleteCommentMutation=DeleteCommentMutation,exports2.DeleteCommentTreeCommand=DeleteCommentTreeCommand,exports2.IThreadCommentDataSourceService=IThreadCommentDataSourceService,exports2.ResolveCommentCommand=ResolveCommentCommand,exports2.ResolveCommentMutation=ResolveCommentMutation,exports2.TC_PLUGIN_NAME=TC_PLUGIN_NAME,exports2.ThreadCommentDataSourceService=ThreadCommentDataSourceService,exports2.UpdateCommentCommand=UpdateCommentCommand,exports2.UpdateCommentMutation=UpdateCommentMutation,exports2.UpdateCommentRefMutation=UpdateCommentRefMutation,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
1
+ function _0xdb5e(_0x1db8d4,_0x4fe0ba){const _0x361d1f=_0x361d();return _0xdb5e=function(_0xdb5e99,_0x4f9995){_0xdb5e99=_0xdb5e99-0x8d;let _0x5c3129=_0x361d1f[_0xdb5e99];return _0x5c3129;},_0xdb5e(_0x1db8d4,_0x4fe0ba);}function _0x361d(){const _0x3903c5=['thread-comment.command.delete-comment','ThreadCommentModel','thread-comment.command.update-comment','mergeOverrideWithDependencies','next','CommandType','AddCommentMutation','toJson','1333737WRkCcO','symbol','updated','syncThreadComments','listThreadComments','_commentUpdate$','Plugin','_initSnapshot','thread-comment.mutation.resolve-comment','Disposable','UpdateCommentMutation','overrides','UNIVER_THREAD_COMMENT_PLUGIN','rangeType','_refreshCommentsMap$','ThreadCommentResourceController','updateT','amd','1841394CgFOLR','updateRef','get','thread-comment.mutation.update-comment','params','commentMap$','ref','children','_dataSource','thread-comment.config','splice','getRootCommentIds','keys','IConfigService','UniverCore','saveToSnapshot','onUnLoad','threadId','_commentsMap','parse','delete','fromChangeset','resolved','object','getOwnPropertyDescriptor','thread-comment.mutation.update-comment-ref','Injector','_injector','_threadCommentDataSourceService','UNRECOGNIZED','unitId','defineProperty','asObservable','map','complete','listComments','resolveComment','UNIVER_SLIDE','_ensureThreadMap','disposeWithMe','parentId','912648qezghU','IResourceManagerService','commentId','_ensureCommentMap','univer.thread-comment.data-source-service','findIndex','ICommandService','TC_PLUGIN_NAME','IThreadCommentDataSourceService','UNIVER_PROJECT','forEach','rxjs','registerCommand','dataSource','updateCommentRef','__decorateClass$1','getUnit','name','rangeId','addCommentItem','executeCommand','thread-comment.command.add-comment','toStringTag','ResolveCommentMutation','UNIVER_DOC','pluginName','UniverThreadCommentPlugin','COMMAND','thread-comment.mutation.delete-comment','updateComment','MENTION','_commentsTreeMap','__decorateParam$2','values','getCommentWithChildren','1001028tQLCvP','CustomRangeType','personId','Module','718732CyRyNF','parseJson','Inject','getComment','set','from','addComment','thread-comment.mutation.add-comment','577180IvdPZs','deleteComment','pipe','_dataSourceService','@univerjs/core','_threadCommentModel','root','saveCommentToSnapshot','registerPluginResource','BehaviorSubject','MUTATION','UpdateCommentRefMutation','AddCommentCommand','_configService','getComment$','length','DeleteCommentMutation','deleteUnit','ensureMap','customRanges','resolve','20338066hXIiMU','UpdateCommentCommand','_replaceComment','add','_ensureCommentChildrenMap','_commentsMap$','subUnitId','_commandService','exports','syncUpdateMutationToColla','_threadMap','UniverInstanceType','entries','ThreadCommentDataSourceService','__decorateParam','UNIVER_SHEET','ResolveCommentCommand','__decorateClass$2','text','_config','onStarting','UNIVER_UNKNOWN'];_0x361d=function(){return _0x3903c5;};return _0x361d();}(function(_0x103f28,_0x346102){const _0x1570f6=_0xdb5e,_0x520784=_0x103f28();while(!![]){try{const _0x2e4479=-parseInt(_0x1570f6(0xd7))/0x1+-parseInt(_0x1570f6(0xae))/0x2+-parseInt(_0x1570f6(0x9c))/0x3+-parseInt(_0x1570f6(0xfe))/0x4+-parseInt(_0x1570f6(0x106))/0x5+parseInt(_0x1570f6(0xfa))/0x6+parseInt(_0x1570f6(0x11b))/0x7;if(_0x2e4479===_0x346102)break;else _0x520784['push'](_0x520784['shift']());}catch(_0x397d5e){_0x520784['push'](_0x520784['shift']());}}}(_0x361d,0x79e21),function(_0x241d5e,_0x37c580){const _0x3ba7a2=_0xdb5e;typeof exports==_0x3ba7a2(0xc5)&&typeof module<'u'?_0x37c580(exports,require('@univerjs/core'),require('rxjs')):typeof define=='function'&&define[_0x3ba7a2(0xad)]?define([_0x3ba7a2(0x123),_0x3ba7a2(0x10a),_0x3ba7a2(0xe2)],_0x37c580):(_0x241d5e=typeof globalThis<'u'?globalThis:_0x241d5e||self,_0x37c580(_0x241d5e['UniverThreadComment']={},_0x241d5e[_0x3ba7a2(0xbc)],_0x241d5e[_0x3ba7a2(0xe2)]));}(this,function(_0x3b2932,_0x50a1c2,_0x52c177){'use strict';const _0x574083=_0xdb5e;var _0x16688c=Object[_0x574083(0xcd)],_0x4e039c=(_0x47dddd,_0x593115,_0x40abac)=>_0x593115 in _0x47dddd?_0x16688c(_0x47dddd,_0x593115,{'enumerable':!0x0,'configurable':!0x0,'writable':!0x0,'value':_0x40abac}):_0x47dddd[_0x593115]=_0x40abac,_0xf301d5=(_0x39fe0f,_0x52c2ab)=>_0x16688c(_0x39fe0f,_0x574083(0xe8),{'value':_0x52c2ab,'configurable':!0x0}),_0x3ad501=(_0x35ab27,_0x367b3d,_0x141a38)=>_0x4e039c(_0x35ab27,typeof _0x367b3d!=_0x574083(0x9d)?_0x367b3d+'':_0x367b3d,_0x141a38),_0x49dbd5,_0xac56ce,_0x5732db;const _0x8c83a5=class _0x111b5f extends _0x50a1c2['Disposable']{constructor(){const _0x427688=_0x574083;super(),_0x3ad501(this,_0x427688(0xb6),null),_0x3ad501(this,_0x427688(0x124),!0x0);}set[_0x574083(0xe4)](_0x23cfba){this['_dataSource']=_0x23cfba;}get['dataSource'](){const _0x4064ce=_0x574083;return this[_0x4064ce(0xb6)];}async['getThreadComment'](_0x2dc984,_0x30ee69,_0x1dc74c){const _0xa2d9c9=_0x574083;return this[_0xa2d9c9(0xb6)]?(await this[_0xa2d9c9(0xb6)]['listComments'](_0x2dc984,_0x30ee69,[_0x1dc74c]))[0x0]:null;}async[_0x574083(0x104)](_0x5b0c62){const _0x4a537d=_0x574083;return this[_0x4a537d(0xb6)]?this[_0x4a537d(0xb6)][_0x4a537d(0x104)](_0x5b0c62):_0x5b0c62;}async[_0x574083(0xf4)](_0x7bc518){const _0x436e58=_0x574083;return this[_0x436e58(0xb6)]?this[_0x436e58(0xb6)][_0x436e58(0xf4)](_0x7bc518):!0x0;}async[_0x574083(0xd2)](_0x34afbe){const _0x50efa1=_0x574083;return this[_0x50efa1(0xb6)]?this[_0x50efa1(0xb6)][_0x50efa1(0xd2)](_0x34afbe):!0x0;}async[_0x574083(0x107)](_0x189e18,_0x25238e,_0x4bd84f,_0x1449c6){const _0x4e38cf=_0x574083;return this['_dataSource']?this['_dataSource'][_0x4e38cf(0x107)](_0x189e18,_0x25238e,_0x4bd84f,_0x1449c6):!0x0;}async[_0x574083(0xa0)](_0x3d4958,_0x98efc6,_0x31c3c2){const _0x13691c=_0x574083;return this[_0x13691c(0xe4)]?this[_0x13691c(0xe4)][_0x13691c(0xd1)](_0x3d4958,_0x98efc6,_0x31c3c2):[];}[_0x574083(0xbd)](_0x39a35b,_0x3505c5){const _0x20839d=_0x574083;if(this[_0x20839d(0xb6)]){const _0x3ac848={};return Object['keys'](_0x39a35b)['forEach'](_0x541a51=>{const _0x4d5771=_0x20839d,_0x5b8714=_0x39a35b[_0x541a51];_0x3ac848[_0x541a51]=_0x5b8714[_0x4d5771(0xcf)](this[_0x4d5771(0xe4)][_0x4d5771(0x10d)]);}),_0x3ac848;}return _0x39a35b;}};_0xf301d5(_0x8c83a5,_0x574083(0x128));let _0x3a4eb1=_0x8c83a5;const _0x31835e=_0x50a1c2['createIdentifier'](_0x574083(0xdb));var _0x512080=Object[_0x574083(0xcd)],_0x2a4c4b=Object[_0x574083(0xc6)],_0x328964=_0xf301d5((_0x1d6ff1,_0x55ffc9,_0x22bb02,_0x1daf5d)=>{const _0x222050=_0x574083;for(var _0x368125=_0x1daf5d>0x1?void 0x0:_0x1daf5d?_0x2a4c4b(_0x55ffc9,_0x22bb02):_0x55ffc9,_0x5774ad=_0x1d6ff1[_0x222050(0x115)]-0x1,_0x5bc2f5;_0x5774ad>=0x0;_0x5774ad--)(_0x5bc2f5=_0x1d6ff1[_0x5774ad])&&(_0x368125=(_0x1daf5d?_0x5bc2f5(_0x55ffc9,_0x22bb02,_0x368125):_0x5bc2f5(_0x368125))||_0x368125);return _0x1daf5d&&_0x368125&&_0x512080(_0x55ffc9,_0x22bb02,_0x368125),_0x368125;},_0x574083(0x8f)),_0x547be9=_0xf301d5((_0x5d3f64,_0x4a90ae)=>(_0x362c7a,_0x25351d)=>_0x4a90ae(_0x362c7a,_0x25351d,_0x5d3f64),_0x574083(0xf7));_0x3b2932['ThreadCommentModel']=(_0x49dbd5=class extends _0x50a1c2[_0x574083(0xa5)]{constructor(_0x37deda,_0x395f29){const _0x1235aa=_0x574083;super(),_0x3ad501(this,_0x1235aa(0xc0),{}),_0x3ad501(this,_0x1235aa(0xf6),new Map()),_0x3ad501(this,_0x1235aa(0x125),new Map()),_0x3ad501(this,'_commentUpdate$',new _0x52c177['Subject']()),_0x3ad501(this,_0x1235aa(0x120),new _0x52c177[(_0x1235aa(0x10f))]({})),_0x3ad501(this,'commentUpdate$',this[_0x1235aa(0xa1)][_0x1235aa(0xce)]()),_0x3ad501(this,_0x1235aa(0xb3),this['_commentsMap$'][_0x1235aa(0xce)]()),(this[_0x1235aa(0x109)]=_0x37deda,this['_commandService']=_0x395f29,this[_0x1235aa(0xd5)](()=>{const _0x530519=_0x1235aa;this[_0x530519(0xa1)][_0x530519(0xd0)](),this[_0x530519(0x120)]['complete']();}));}[_0x574083(0xda)](_0x185904,_0x2a5074){const _0x4a7055=_0x574083;let _0x45324e=this[_0x4a7055(0xc0)][_0x185904];_0x45324e||(_0x45324e={},this['_commentsMap'][_0x185904]=_0x45324e);let _0x55bbdf=_0x45324e[_0x2a5074];return _0x55bbdf||(_0x55bbdf={},_0x45324e[_0x2a5074]=_0x55bbdf),_0x55bbdf;}['_ensureCommentChildrenMap'](_0x587e4b,_0x30f3fe){const _0x395977=_0x574083;let _0x43598f=this[_0x395977(0xf6)][_0x395977(0xb0)](_0x587e4b);_0x43598f||(_0x43598f=new Map(),this[_0x395977(0xf6)][_0x395977(0x102)](_0x587e4b,_0x43598f));let _0x53f608=_0x43598f[_0x395977(0xb0)](_0x30f3fe);return _0x53f608||(_0x53f608=new Map(),_0x43598f[_0x395977(0x102)](_0x30f3fe,_0x53f608)),_0x53f608;}[_0x574083(0xd4)](_0x247787){const _0x4bbcbe=_0x574083;let _0x13385d=this[_0x4bbcbe(0x125)][_0x4bbcbe(0xb0)](_0x247787);return _0x13385d||(_0x13385d=new Map(),this['_threadMap'][_0x4bbcbe(0x102)](_0x247787,_0x13385d)),_0x13385d;}[_0x574083(0xaa)](){const _0x13312c=_0x574083;this[_0x13312c(0x120)][_0x13312c(0x98)]({...this[_0x13312c(0xc0)]});}[_0x574083(0x118)](_0x233d02,_0x263676){const _0x4904b1=_0x574083,_0x1b1e43=this[_0x4904b1(0xda)](_0x233d02,_0x263676),_0x4c3032=this[_0x4904b1(0x11f)](_0x233d02,_0x263676);return{'commentMap':_0x1b1e43,'commentChildrenMap':_0x4c3032};}[_0x574083(0x11d)](_0x21f132,_0x3128bd,_0x279d86){const _0xe97436=_0x574083;var _0x5278a5;const {commentMap:_0x43afa0,commentChildrenMap:_0x404129}=this['ensureMap'](_0x21f132,_0x3128bd),_0x2c27a3=_0x43afa0[_0x279d86['id']];if(_0x2c27a3){const _0x1b0c91={..._0x279d86,'ref':_0x2c27a3[_0xe97436(0xb4)]};_0x43afa0[_0x279d86['id']]=_0x1b0c91,(_0x5278a5=_0x279d86['children'])==null||_0x5278a5[_0xe97436(0xe1)](_0x1a4258=>{_0x43afa0[_0x1a4258['id']]={..._0x1a4258,'ref':''};}),_0x404129[_0xe97436(0x102)](_0x279d86['id'],_0x1b0c91),this[_0xe97436(0xa1)][_0xe97436(0x98)]({'unitId':_0x21f132,'subUnitId':_0x3128bd,'type':'syncUpdate','payload':_0x1b0c91}),!!_0x279d86['resolved']!=!!_0x2c27a3[_0xe97436(0xc4)]&&this[_0xe97436(0xa1)][_0xe97436(0x98)]({'unitId':_0x21f132,'subUnitId':_0x3128bd,'type':_0xe97436(0x11a),'payload':{'commentId':_0x279d86['id'],'resolved':!!_0x279d86[_0xe97436(0xc4)]}});}}async[_0x574083(0x9f)](_0x1c87c0,_0x4b245c,_0xc81cbb){const _0xcc77de=_0x574083,_0x19fb8e=await this[_0xcc77de(0x109)][_0xcc77de(0xa0)](_0x1c87c0,_0x4b245c,_0xc81cbb);if(!_0x19fb8e[_0xcc77de(0x115)])return;const _0x1bd2e0=new Set(_0xc81cbb);_0x19fb8e[_0xcc77de(0xe1)](_0x1a338d=>{const _0x274983=_0xcc77de;this[_0x274983(0x11d)](_0x1c87c0,_0x4b245c,_0x1a338d),_0x1bd2e0['delete'](_0x1a338d[_0x274983(0xbf)]);}),_0x1bd2e0[_0xcc77de(0xe1)](_0x1fdcd2=>{const _0x37b4c4=_0xcc77de,_0x51c984=this['getThread'](_0x1c87c0,_0x1fdcd2);_0x51c984&&this[_0x37b4c4(0x107)](_0x51c984[_0x37b4c4(0xcc)],_0x51c984[_0x37b4c4(0x121)],_0x51c984['id']);}),this['_refreshCommentsMap$']();}['addComment'](_0x1d8b5e,_0x148f6f,_0x41c6ed,_0x1d5d94){const _0x5f2c1c=_0x574083;var _0x10cf2a,_0x49e225;const {commentMap:_0x268314,commentChildrenMap:_0x15937d}=this[_0x5f2c1c(0x118)](_0x1d8b5e,_0x148f6f),_0x5e6edb=_0x41c6ed,_0x36b8f9=_0xf301d5(_0x1a088d=>{const _0x4ec112=_0x5f2c1c;_0x268314[_0x1a088d['id']]=_0x1a088d,this['_commentUpdate$'][_0x4ec112(0x98)]({'unitId':_0x1d8b5e,'subUnitId':_0x148f6f,'type':'add','payload':_0x1a088d,'isRoot':!_0x1a088d[_0x4ec112(0xd6)]});},_0x5f2c1c(0xea)),_0x725d14=_0x5e6edb['parentId'];if(_0x725d14){const _0x147b3e=_0x268314[_0x725d14];_0x147b3e[_0x5f2c1c(0xb5)]=[...(_0x10cf2a=_0x147b3e[_0x5f2c1c(0xb5)])!=null?_0x10cf2a:[],_0x5e6edb],_0x36b8f9(_0x5e6edb);}else _0x15937d[_0x5f2c1c(0x102)](_0x5e6edb['id'],_0x5e6edb),this[_0x5f2c1c(0xd4)](_0x1d8b5e)[_0x5f2c1c(0x102)](_0x5e6edb[_0x5f2c1c(0xbf)],_0x5e6edb),_0x36b8f9(_0x5e6edb),(_0x49e225=_0x5e6edb['children'])==null||_0x49e225['forEach'](_0x208a9e=>_0x36b8f9({..._0x208a9e,'ref':''}));return this['_refreshCommentsMap$'](),_0x1d5d94&&this[_0x5f2c1c(0x9f)](_0x1d8b5e,_0x148f6f,[_0x5e6edb[_0x5f2c1c(0xbf)]]),!0x0;}[_0x574083(0xf4)](_0x28fb45,_0x1029ec,_0x1a0eb4,_0x997491){const _0x34e357=_0x574083,{commentMap:_0x180e17}=this[_0x34e357(0x118)](_0x28fb45,_0x1029ec),_0x2b528a=_0x180e17[_0x1a0eb4['commentId']];return _0x2b528a?(_0x2b528a[_0x34e357(0x9e)]=!0x0,_0x2b528a['text']=_0x1a0eb4['text'],_0x2b528a['attachments']=_0x1a0eb4['attachments'],_0x2b528a[_0x34e357(0xac)]=_0x1a0eb4[_0x34e357(0xac)],this[_0x34e357(0xa1)][_0x34e357(0x98)]({'unitId':_0x28fb45,'subUnitId':_0x1029ec,'type':'update','payload':_0x1a0eb4,'silent':_0x997491}),this[_0x34e357(0xaa)](),!0x0):!0x1;}[_0x574083(0xe5)](_0x8f46a1,_0x35b083,_0x463a8b,_0xb3e358){const _0x1a5b58=_0x574083,{commentMap:_0x448e9c}=this[_0x1a5b58(0x118)](_0x8f46a1,_0x35b083),_0x56de0c=_0x448e9c[_0x463a8b[_0x1a5b58(0xd9)]];return _0x56de0c?(_0x56de0c[_0x1a5b58(0xb4)]=_0x463a8b[_0x1a5b58(0xb4)],this['_commentUpdate$'][_0x1a5b58(0x98)]({'unitId':_0x8f46a1,'subUnitId':_0x35b083,'type':_0x1a5b58(0xaf),'payload':_0x463a8b,'silent':_0xb3e358}),this[_0x1a5b58(0xaa)](),!0x0):!0x1;}['resolveComment'](_0x5804b5,_0xce94ff,_0x3baf36,_0x11ea5b){const _0x3bf197=_0x574083,{commentMap:_0x5900fb}=this[_0x3bf197(0x118)](_0x5804b5,_0xce94ff),_0x379175=_0x5900fb[_0x3baf36];return _0x379175?(_0x379175['resolved']=_0x11ea5b,this[_0x3bf197(0xa1)]['next']({'unitId':_0x5804b5,'subUnitId':_0xce94ff,'type':_0x3bf197(0x11a),'payload':{'commentId':_0x3baf36,'resolved':_0x11ea5b}}),this[_0x3bf197(0xaa)](),!0x0):!0x1;}[_0x574083(0x101)](_0x5b3f78,_0x4ac84e,_0x2bfdc1){const {commentMap:_0x460660}=this['ensureMap'](_0x5b3f78,_0x4ac84e);return _0x460660[_0x2bfdc1];}[_0x574083(0x114)](_0x2b97b5,_0x3ea474,_0x297c22){const _0x36524e=_0x574083;return this[_0x36524e(0x120)][_0x36524e(0x108)](_0x52c177[_0x36524e(0xcf)](_0xccbbc5=>_0xccbbc5[_0x2b97b5][_0x3ea474][_0x297c22]));}['getCommentWithChildren'](_0x6919b7,_0x3afa51,_0x36c978){const _0x52de44=_0x574083;var _0x36119c,_0x2e926;const {commentMap:_0x11d146,commentChildrenMap:_0x3a1e56}=this[_0x52de44(0x118)](_0x6919b7,_0x3afa51),_0x2318d4=_0x11d146[_0x36c978];if(!_0x2318d4)return;const _0x281d9f=new Set(),_0x2d7867=_0x3a1e56[_0x52de44(0xb0)](_0x36c978);if(_0x2d7867)return[_0x2d7867,...(_0x36119c=_0x2d7867['children'])!=null?_0x36119c:[]]['forEach'](_0x294cb4=>{const _0x280310=_0x52de44;var _0x2fdd5a;_0x281d9f[_0x280310(0x11e)](_0x294cb4[_0x280310(0xfc)]),(_0x2fdd5a=_0x294cb4[_0x280310(0x90)][_0x280310(0x119)])==null||_0x2fdd5a['forEach'](_0x4b20b6=>{const _0x473e40=_0x280310;_0x4b20b6[_0x473e40(0xa9)]===_0x50a1c2[_0x473e40(0xfb)][_0x473e40(0xf5)]&&_0x281d9f[_0x473e40(0x11e)](_0x4b20b6[_0x473e40(0xe9)]);});}),{'root':_0x2318d4,'children':(_0x2e926=_0x2d7867['children'])!=null?_0x2e926:[],'relativeUsers':_0x281d9f};}[_0x574083(0x107)](_0x56abf4,_0x3bb667,_0x3ae103){const _0x46e59e=_0x574083;var _0x2b17d2;const {commentMap:_0x41875b,commentChildrenMap:_0x57104e}=this[_0x46e59e(0x118)](_0x56abf4,_0x3bb667),_0x82a708=_0x41875b[_0x3ae103];if(!_0x82a708)return!0x0;if(_0x82a708[_0x46e59e(0xd6)]){const _0x37c7fa=_0x57104e['get'](_0x82a708[_0x46e59e(0xd6)]);if(_0x37c7fa&&_0x37c7fa[_0x46e59e(0xb5)]){const _0x16d72b=_0x37c7fa[_0x46e59e(0xb5)][_0x46e59e(0xdc)](_0x49f466=>_0x49f466['id']===_0x3ae103);_0x37c7fa[_0x46e59e(0xb5)][_0x46e59e(0xb8)](_0x16d72b,0x1);}delete _0x41875b[_0x3ae103];}else{delete _0x41875b[_0x3ae103];const _0x57b362=_0x57104e[_0x46e59e(0xb0)](_0x3ae103);_0x57104e[_0x46e59e(0xc2)](_0x3ae103),this[_0x46e59e(0xd4)](_0x56abf4)[_0x46e59e(0xc2)](_0x82a708[_0x46e59e(0xbf)]),(_0x2b17d2=_0x57b362==null?void 0x0:_0x57b362[_0x46e59e(0xb5)])==null||_0x2b17d2[_0x46e59e(0xe1)](_0x27ff42=>{const _0x4d2f1=_0x46e59e;delete _0x41875b[_0x27ff42['id']],this['_commentUpdate$'][_0x4d2f1(0x98)]({'unitId':_0x56abf4,'subUnitId':_0x3bb667,'type':'delete','payload':{'commentId':_0x27ff42['id'],'isRoot':!0x1,'comment':_0x27ff42}});});}return this[_0x46e59e(0xa1)][_0x46e59e(0x98)]({'unitId':_0x56abf4,'subUnitId':_0x3bb667,'type':_0x46e59e(0xc2),'payload':{'commentId':_0x3ae103,'isRoot':!_0x82a708[_0x46e59e(0xd6)],'comment':_0x82a708}}),this[_0x46e59e(0xaa)](),!0x0;}[_0x574083(0xe7)](_0x479900){const _0x4b3949=_0x574083,_0x2d3cb4=this[_0x4b3949(0xc0)][_0x479900];return _0x2d3cb4?Array['from'](Object[_0x4b3949(0x127)](_0x2d3cb4))['map'](([_0x58ec38,_0x5a8d5c])=>[_0x58ec38,Array[_0x4b3949(0x103)](Object[_0x4b3949(0xf8)](_0x5a8d5c))]):[];}[_0x574083(0x117)](_0x21ad7d){const _0x5e5ebe=_0x574083,_0x1c4781=this[_0x5e5ebe(0xc0)][_0x21ad7d];_0x1c4781&&Object[_0x5e5ebe(0x127)](_0x1c4781)['forEach'](([_0x2f19f4,_0x467857])=>{const _0x22853c=_0x5e5ebe;Object['values'](_0x467857)[_0x22853c(0xe1)](_0x242a09=>{const _0x4cb16d=_0x22853c;this[_0x4cb16d(0x107)](_0x21ad7d,_0x2f19f4,_0x242a09['id']);});});}[_0x574083(0xb9)](_0xe3c5fc,_0x1010df){const _0x4a8595=_0x574083,_0x4d5b8d=this['_ensureCommentChildrenMap'](_0xe3c5fc,_0x1010df);return Array['from'](_0x4d5b8d[_0x4a8595(0xba)]());}['getAll'](){const _0x34a539=_0x574083;return this[_0x34a539(0xc0)];}['getThread'](_0x1d6927,_0x23c4c2){const _0x3ef115=_0x574083;return this[_0x3ef115(0xd4)](_0x1d6927)[_0x3ef115(0xb0)](_0x23c4c2);}},_0xf301d5(_0x49dbd5,_0x574083(0x95)),_0x49dbd5),_0x3b2932[_0x574083(0x95)]=_0x328964([_0x547be9(0x0,_0x50a1c2[_0x574083(0x100)](_0x31835e)),_0x547be9(0x1,_0x50a1c2[_0x574083(0xdd)])],_0x3b2932['ThreadCommentModel']);var _0x43027a=(_0x25dac0=>(_0x25dac0[_0x25dac0[_0x574083(0x93)]=0x0]=_0x574083(0x93),_0x25dac0[_0x25dac0[_0x574083(0xef)]=0x1]=_0x574083(0xef),_0x25dac0[_0x25dac0[_0x574083(0x8d)]=0x2]=_0x574083(0x8d),_0x25dac0[_0x25dac0[_0x574083(0xd3)]=0x3]=_0x574083(0xd3),_0x25dac0[_0x25dac0[_0x574083(0xe0)]=0x4]=_0x574083(0xe0),_0x25dac0[_0x25dac0[_0x574083(0xcb)]=-0x1]=_0x574083(0xcb),_0x25dac0))(_0x43027a||{});const _0x43ea83=_0x574083(0xa8);var _0x544d37=Object[_0x574083(0xcd)],_0xe8ca10=Object[_0x574083(0xc6)],_0x1b2109=_0xf301d5((_0x1e0e00,_0x5bd151,_0x567fbb,_0x3da9b4)=>{for(var _0x5792f5=_0x3da9b4>0x1?void 0x0:_0x3da9b4?_0xe8ca10(_0x5bd151,_0x567fbb):_0x5bd151,_0x274acf=_0x1e0e00['length']-0x1,_0x3fff91;_0x274acf>=0x0;_0x274acf--)(_0x3fff91=_0x1e0e00[_0x274acf])&&(_0x5792f5=(_0x3da9b4?_0x3fff91(_0x5bd151,_0x567fbb,_0x5792f5):_0x3fff91(_0x5792f5))||_0x5792f5);return _0x3da9b4&&_0x5792f5&&_0x544d37(_0x5bd151,_0x567fbb,_0x5792f5),_0x5792f5;},_0x574083(0xe6)),_0x5d9b62=_0xf301d5((_0x1a89a6,_0x443ee0)=>(_0x1aea7e,_0x28d3ec)=>_0x443ee0(_0x1aea7e,_0x28d3ec,_0x1a89a6),'__decorateParam$1');_0x3b2932[_0x574083(0xab)]=(_0xac56ce=class extends _0x50a1c2['Disposable']{constructor(_0x29ed02,_0x599709,_0x7ab6c4){const _0x2368b3=_0x574083;super(),this['_resourceManagerService']=_0x29ed02,this[_0x2368b3(0x10b)]=_0x599709,this[_0x2368b3(0xca)]=_0x7ab6c4,this['_initSnapshot']();}[_0x574083(0xa3)](){const _0x13f30e=_0x574083,_0x380177=_0xf301d5(_0x74590a=>{const _0x554de3=_0xdb5e,_0x212eb8=this[_0x554de3(0x10b)][_0x554de3(0xe7)](_0x74590a),_0x3a5774={};return _0x212eb8?(_0x212eb8[_0x554de3(0xe1)](([_0x2daa7a,_0x361967])=>{_0x3a5774[_0x2daa7a]=_0x361967;}),JSON['stringify'](this[_0x554de3(0xca)]['saveToSnapshot'](_0x3a5774,_0x74590a))):'';},_0x13f30e(0x9b)),_0xb85130=_0xf301d5(_0x507b64=>{const _0x378483=_0x13f30e;if(!_0x507b64)return{};try{return JSON[_0x378483(0xc1)](_0x507b64);}catch{return{};}},'parseJson');this[_0x13f30e(0xd5)](this['_resourceManagerService'][_0x13f30e(0x10e)]({'pluginName':'SHEET_'+_0x43ea83,'businesses':[_0x43027a[_0x13f30e(0x8d)],_0x43027a['UNIVER_DOC']],'toJson':_0xf301d5(_0x20477e=>_0x380177(_0x20477e),_0x13f30e(0x9b)),'parseJson':_0xf301d5(_0x2081de=>_0xb85130(_0x2081de),_0x13f30e(0xff)),'onUnLoad':_0xf301d5(_0x538c1a=>{const _0x4f5769=_0x13f30e;this[_0x4f5769(0x10b)][_0x4f5769(0x117)](_0x538c1a);},_0x13f30e(0xbe)),'onLoad':_0xf301d5(async(_0x3f9a85,_0x253685)=>{const _0x5323c2=_0x13f30e;Object[_0x5323c2(0xba)](_0x253685)[_0x5323c2(0xe1)](_0x423d81=>{const _0x88cf7c=_0x5323c2,_0x4f4649=_0x253685[_0x423d81];_0x4f4649['forEach'](_0x2dcd3c=>{const _0x4cc13f=_0xdb5e;this[_0x4cc13f(0x10b)][_0x4cc13f(0x104)](_0x3f9a85,_0x423d81,_0x2dcd3c);}),this[_0x88cf7c(0x10b)][_0x88cf7c(0x9f)](_0x3f9a85,_0x423d81,_0x4f4649[_0x88cf7c(0xcf)](_0x3c04bf=>_0x3c04bf[_0x88cf7c(0xbf)]));});},'onLoad')}));}},_0xf301d5(_0xac56ce,_0x574083(0xab)),_0xac56ce),_0x3b2932['ThreadCommentResourceController']=_0x1b2109([_0x5d9b62(0x0,_0x50a1c2[_0x574083(0xd8)]),_0x5d9b62(0x1,_0x50a1c2[_0x574083(0x100)](_0x3b2932['ThreadCommentModel'])),_0x5d9b62(0x2,_0x31835e)],_0x3b2932['ThreadCommentResourceController']);const _0x5088c5={'id':_0x574083(0x105),'type':_0x50a1c2[_0x574083(0x99)][_0x574083(0x110)],'handler'(_0x2acc99,_0x2e6c1d,_0x289908){const _0x308bd1=_0x574083;if(!_0x2e6c1d)return!0x1;const _0x15a087=_0x2acc99[_0x308bd1(0xb0)](_0x3b2932[_0x308bd1(0x95)]),{unitId:_0x58af1c,subUnitId:_0x2e92cc,comment:_0xd69756,sync:_0x19d33c}=_0x2e6c1d,_0x3254ae=_0x19d33c||(_0x289908==null?void 0x0:_0x289908[_0x308bd1(0xc3)])&&!_0xd69756[_0x308bd1(0xd6)];return _0x15a087[_0x308bd1(0x104)](_0x58af1c,_0x2e92cc,_0xd69756,_0x3254ae);}},_0x32963c={'id':_0x574083(0xb1),'type':_0x50a1c2[_0x574083(0x99)][_0x574083(0x110)],'handler'(_0x3ec426,_0x176d1a){const _0x2e96b4=_0x574083;if(!_0x176d1a)return!0x1;const _0x337e94=_0x3ec426[_0x2e96b4(0xb0)](_0x3b2932[_0x2e96b4(0x95)]),{unitId:_0x32f28d,subUnitId:_0x956e20,payload:_0x9964cd,silent:_0x55897d}=_0x176d1a;return _0x337e94[_0x2e96b4(0xf4)](_0x32f28d,_0x956e20,_0x9964cd,_0x55897d);}},_0x4aad71={'id':_0x574083(0xc7),'type':_0x50a1c2[_0x574083(0x99)][_0x574083(0x110)],'handler'(_0x579254,_0x49359b){const _0x56327a=_0x574083;if(!_0x49359b)return!0x1;const _0x3dcdf0=_0x579254[_0x56327a(0xb0)](_0x3b2932['ThreadCommentModel']),{unitId:_0x57ebd9,subUnitId:_0x21c606,payload:_0x27639a,silent:_0x5d6f0b}=_0x49359b;return _0x3dcdf0['updateCommentRef'](_0x57ebd9,_0x21c606,_0x27639a,_0x5d6f0b);}},_0x6adb13={'id':_0x574083(0xa4),'type':_0x50a1c2[_0x574083(0x99)][_0x574083(0x110)],'handler'(_0x1a322f,_0x115c1e){const _0x4ebb0f=_0x574083;if(!_0x115c1e)return!0x1;const _0x1ef45e=_0x1a322f[_0x4ebb0f(0xb0)](_0x3b2932['ThreadCommentModel']),{unitId:_0x3da7e4,subUnitId:_0x3c2943,resolved:_0x62a802,commentId:_0x531b99}=_0x115c1e;return _0x1ef45e[_0x4ebb0f(0xd2)](_0x3da7e4,_0x3c2943,_0x531b99,_0x62a802);}},_0x85c2ab={'id':_0x574083(0xf3),'type':_0x50a1c2[_0x574083(0x99)][_0x574083(0x110)],'handler'(_0x3899bd,_0x4d8ea3){const _0x4ae88b=_0x574083;if(!_0x4d8ea3)return!0x1;const _0x1d8854=_0x3899bd[_0x4ae88b(0xb0)](_0x3b2932[_0x4ae88b(0x95)]),{unitId:_0x164b32,subUnitId:_0x5260fe,commentId:_0x46bac9}=_0x4d8ea3;return _0x1d8854['deleteComment'](_0x164b32,_0x5260fe,_0x46bac9);}},_0xa29f62={'id':_0x574083(0xec),'type':_0x50a1c2['CommandType']['COMMAND'],async 'handler'(_0x14b0f0,_0x42b524){const _0x23d030=_0x574083;if(!_0x42b524)return!0x1;const _0xfd3113=_0x14b0f0[_0x23d030(0xb0)](_0x50a1c2[_0x23d030(0xdd)]),_0x3d9cb7=_0x14b0f0[_0x23d030(0xb0)](_0x31835e),{comment:_0x34fd73}=_0x42b524,_0x8f34e=await _0x3d9cb7[_0x23d030(0x104)](_0x34fd73),_0x10ee87=_0x3d9cb7[_0x23d030(0x124)],_0x3c53d4=!_0x34fd73[_0x23d030(0xd6)],_0x405682={'id':_0x5088c5['id'],'params':{..._0x42b524,'comment':_0x8f34e}};return _0x3c53d4?await _0xfd3113[_0x23d030(0xeb)](_0x405682['id'],_0x405682[_0x23d030(0xb2)]):_0xfd3113[_0x23d030(0xeb)](_0x405682['id'],_0x405682[_0x23d030(0xb2)],{'onlyLocal':!_0x10ee87});}},_0x45dabb={'id':_0x574083(0x96),'type':_0x50a1c2['CommandType'][_0x574083(0xf2)],async 'handler'(_0x3a6885,_0x219420){const _0x4a1be2=_0x574083;if(!_0x219420)return!0x1;const {unitId:_0x4fc46a,subUnitId:_0x30cc16,payload:_0x5c171b}=_0x219420,_0x1499e8=_0x3a6885[_0x4a1be2(0xb0)](_0x50a1c2[_0x4a1be2(0xdd)]),_0x776d7c=_0x3a6885[_0x4a1be2(0xb0)](_0x3b2932[_0x4a1be2(0x95)]),_0x5d3f72=_0x3a6885['get'](_0x31835e),_0x16a6e8=_0x5d3f72['syncUpdateMutationToColla'],_0x42980e=_0x776d7c[_0x4a1be2(0x101)](_0x4fc46a,_0x30cc16,_0x5c171b[_0x4a1be2(0xd9)]);if(!_0x42980e)return!0x1;const {children:_0x338f7e,..._0x132b62}=_0x42980e;if(!await _0x5d3f72[_0x4a1be2(0xf4)]({..._0x132b62,..._0x5c171b}))return!0x1;const _0x53b3a6={'id':_0x32963c['id'],'params':_0x219420};return _0x1499e8['executeCommand'](_0x53b3a6['id'],_0x53b3a6['params'],{'onlyLocal':!_0x16a6e8}),!0x0;}},_0xffcb90={'id':'thread-comment.command.resolve-comment','type':_0x50a1c2[_0x574083(0x99)][_0x574083(0xf2)],async 'handler'(_0x474470,_0x41d6a1){const _0x44f0dd=_0x574083;if(!_0x41d6a1)return!0x1;const {unitId:_0x2620e6,subUnitId:_0xedc6cc,resolved:_0x29e08a,commentId:_0x347c90}=_0x41d6a1,_0x478ab2=_0x474470[_0x44f0dd(0xb0)](_0x31835e),_0x19bc17=_0x474470['get'](_0x3b2932[_0x44f0dd(0x95)])[_0x44f0dd(0x101)](_0x2620e6,_0xedc6cc,_0x347c90),_0x7e181f=_0x478ab2['syncUpdateMutationToColla'];return!_0x19bc17||!await _0x478ab2[_0x44f0dd(0xd2)]({..._0x19bc17,'resolved':_0x29e08a})?!0x1:_0x474470[_0x44f0dd(0xb0)](_0x50a1c2[_0x44f0dd(0xdd)])[_0x44f0dd(0xeb)](_0x6adb13['id'],_0x41d6a1,{'onlyLocal':!_0x7e181f});}},_0x157b79={'id':_0x574083(0x94),'type':_0x50a1c2[_0x574083(0x99)][_0x574083(0xf2)],async 'handler'(_0x46465b,_0x6a32f3){const _0x460c03=_0x574083;if(!_0x6a32f3)return!0x1;const _0x54764d=_0x46465b['get'](_0x3b2932[_0x460c03(0x95)]),_0x106c5b=_0x46465b[_0x460c03(0xb0)](_0x31835e),_0x425902=_0x46465b[_0x460c03(0xb0)](_0x50a1c2[_0x460c03(0xdd)]),{unitId:_0x3e73a9,subUnitId:_0x426432,commentId:_0x50bbe0}=_0x6a32f3,_0x3f3627=_0x106c5b[_0x460c03(0x124)],_0x1e956d=_0x54764d[_0x460c03(0x101)](_0x3e73a9,_0x426432,_0x50bbe0);if(!_0x1e956d||!await _0x106c5b[_0x460c03(0x107)](_0x3e73a9,_0x426432,_0x1e956d[_0x460c03(0xbf)],_0x50bbe0))return!0x1;const _0x1a53b9={'id':_0x85c2ab['id'],'params':_0x6a32f3};return _0x425902[_0x460c03(0xeb)](_0x1a53b9['id'],_0x1a53b9['params'],{'onlyLocal':!_0x3f3627});}},_0x3844c7={'id':'thread-comment.command.delete-comment-tree','type':_0x50a1c2['CommandType'][_0x574083(0xf2)],async 'handler'(_0x67c692,_0x16b4a8){const _0x5ce769=_0x574083;if(!_0x16b4a8)return!0x1;const _0x4c1e09=_0x67c692[_0x5ce769(0xb0)](_0x3b2932['ThreadCommentModel']),_0x400b8d=_0x67c692[_0x5ce769(0xb0)](_0x50a1c2[_0x5ce769(0xdd)]),_0x49e4d1=_0x67c692['get'](_0x31835e),{unitId:_0x32cb31,subUnitId:_0x17e2c5,commentId:_0x416e92}=_0x16b4a8,_0x587d59=_0x4c1e09[_0x5ce769(0xf9)](_0x32cb31,_0x17e2c5,_0x416e92);return!_0x587d59||!await _0x49e4d1[_0x5ce769(0x107)](_0x32cb31,_0x17e2c5,_0x587d59[_0x5ce769(0x10c)][_0x5ce769(0xbf)],_0x416e92)?!0x1:await _0x400b8d[_0x5ce769(0xeb)](_0x85c2ab['id'],{'unitId':_0x32cb31,'subUnitId':_0x17e2c5,'commentId':_0x587d59[_0x5ce769(0x10c)]['id']});}},_0x1cf2c0=_0x574083(0xb7),_0x2ba045={};var _0x9d4ad3=Object[_0x574083(0xcd)],_0x3dbf14=Object[_0x574083(0xc6)],_0x4e5450=_0xf301d5((_0x2e160e,_0x1330ab,_0x5d0e93,_0x302fa9)=>{for(var _0x4a0ec2=_0x302fa9>0x1?void 0x0:_0x302fa9?_0x3dbf14(_0x1330ab,_0x5d0e93):_0x1330ab,_0x388d3c=_0x2e160e['length']-0x1,_0x28ad9f;_0x388d3c>=0x0;_0x388d3c--)(_0x28ad9f=_0x2e160e[_0x388d3c])&&(_0x4a0ec2=(_0x302fa9?_0x28ad9f(_0x1330ab,_0x5d0e93,_0x4a0ec2):_0x28ad9f(_0x4a0ec2))||_0x4a0ec2);return _0x302fa9&&_0x4a0ec2&&_0x9d4ad3(_0x1330ab,_0x5d0e93,_0x4a0ec2),_0x4a0ec2;},'__decorateClass'),_0x3ab5d9=_0xf301d5((_0x2a0808,_0x71431)=>(_0x2f920c,_0x1c7f56)=>_0x71431(_0x2f920c,_0x1c7f56,_0x2a0808),_0x574083(0x129));_0x3b2932['UniverThreadCommentPlugin']=(_0x5732db=class extends _0x50a1c2[_0x574083(0xa2)]{constructor(_0x1f7ced=_0x2ba045,_0x55f07a,_0x3b4794,_0x4030fb){const _0x46eaa3=_0x574083;super(),this[_0x46eaa3(0x91)]=_0x1f7ced,this['_injector']=_0x55f07a,this[_0x46eaa3(0x122)]=_0x3b4794,this[_0x46eaa3(0x113)]=_0x4030fb;const {..._0x1cc2b3}=this[_0x46eaa3(0x91)];this['_configService']['setConfig'](_0x1cf2c0,_0x1cc2b3);}[_0x574083(0x92)](){const _0x42706c=_0x574083;var _0x2a469f;_0x50a1c2[_0x42706c(0x97)]([[_0x31835e,{'useClass':_0x3a4eb1}],[_0x3b2932[_0x42706c(0x95)]],[_0x3b2932['ThreadCommentResourceController']]],(_0x2a469f=this[_0x42706c(0x91)])==null?void 0x0:_0x2a469f[_0x42706c(0xa7)])[_0x42706c(0xe1)](_0x3ecda2=>{const _0x2ae571=_0x42706c;this[_0x2ae571(0xc9)][_0x2ae571(0x11e)](_0x3ecda2);}),[_0xa29f62,_0x45dabb,_0x157b79,_0xffcb90,_0x3844c7,_0x5088c5,_0x32963c,_0x4aad71,_0x85c2ab,_0x6adb13][_0x42706c(0xe1)](_0x470c41=>{const _0x2aa2a7=_0x42706c;this[_0x2aa2a7(0x122)][_0x2aa2a7(0xe3)](_0x470c41);}),this[_0x42706c(0xc9)]['get'](_0x3b2932['ThreadCommentResourceController']);}},_0xf301d5(_0x5732db,'UniverThreadCommentPlugin'),_0x3ad501(_0x5732db,_0x574083(0xf0),_0x43ea83),_0x3ad501(_0x5732db,'type',_0x50a1c2[_0x574083(0x126)][_0x574083(0x93)]),_0x5732db),_0x3b2932['UniverThreadCommentPlugin']=_0x4e5450([_0x3ab5d9(0x1,_0x50a1c2[_0x574083(0x100)](_0x50a1c2[_0x574083(0xc8)])),_0x3ab5d9(0x2,_0x50a1c2[_0x574083(0xdd)]),_0x3ab5d9(0x3,_0x50a1c2[_0x574083(0xbb)])],_0x3b2932[_0x574083(0xf1)]),_0x3b2932[_0x574083(0x112)]=_0xa29f62,_0x3b2932[_0x574083(0x9a)]=_0x5088c5,_0x3b2932['DeleteCommentCommand']=_0x157b79,_0x3b2932[_0x574083(0x116)]=_0x85c2ab,_0x3b2932['DeleteCommentTreeCommand']=_0x3844c7,_0x3b2932[_0x574083(0xdf)]=_0x31835e,_0x3b2932[_0x574083(0x8e)]=_0xffcb90,_0x3b2932[_0x574083(0xee)]=_0x6adb13,_0x3b2932[_0x574083(0xde)]=_0x43ea83,_0x3b2932[_0x574083(0x128)]=_0x3a4eb1,_0x3b2932[_0x574083(0x11c)]=_0x45dabb,_0x3b2932[_0x574083(0xa6)]=_0x32963c,_0x3b2932[_0x574083(0x111)]=_0x4aad71,Object[_0x574083(0xcd)](_0x3b2932,Symbol[_0x574083(0xed)],{'value':_0x574083(0xfd)});}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/thread-comment",
3
- "version": "0.3.0-alpha.1",
3
+ "version": "0.3.0-nightly.202410101606",
4
4
  "private": false,
5
5
  "description": "Univer thread comment core plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -45,18 +45,18 @@
45
45
  ],
46
46
  "peerDependencies": {
47
47
  "rxjs": ">=7.0.0",
48
- "@univerjs/core": "0.3.0-alpha.1"
48
+ "@univerjs/core": "0.3.0-nightly.202410101606"
49
49
  },
50
50
  "dependencies": {
51
51
  "@univerjs/protocol": "0.1.39-alpha.15",
52
- "@univerjs/core": "0.3.0-alpha.1"
52
+ "@univerjs/core": "0.3.0-nightly.202410101606"
53
53
  },
54
54
  "devDependencies": {
55
55
  "rxjs": "^7.8.1",
56
56
  "typescript": "^5.6.2",
57
57
  "vite": "^5.4.8",
58
58
  "vitest": "^2.1.1",
59
- "@univerjs-infra/shared": "0.3.0-alpha.1"
59
+ "@univerjs-infra/shared": "0.3.0"
60
60
  },
61
61
  "univerSpace": {
62
62
  ".": {
@@ -76,7 +76,6 @@
76
76
  "test:watch": "vitest",
77
77
  "coverage": "vitest run --coverage",
78
78
  "lint:types": "tsc --noEmit",
79
- "build": "tsc && vite build",
80
- "sync:cnpm": "cnpm sync"
79
+ "build": "tsc && vite build"
81
80
  }
82
81
  }
package/LICENSE DELETED
@@ -1,176 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS