@univerjs/sheets-thread-comment-ui 0.5.5 → 0.6.0-experimental.20250125-1d060b9

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,9 +1 @@
1
- "use strict";var Se=Object.defineProperty;var _e=(o,t,n)=>t in o?Se(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var D=(o,t,n)=>_e(o,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),C=require("@univerjs/sheets"),$=require("@univerjs/sheets-thread-comment"),P=require("@univerjs/thread-comment-ui"),w=require("@univerjs/sheets-ui"),S=require("@univerjs/ui"),H=require("rxjs"),ae=require("@univerjs/engine-render"),x=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),R=require("react"),me="univer.sheet.thread-comment-modal",te="comment-single",ne="SHEET_THREAD_COMMENT";var fe=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,ge=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ie(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&fe(t,n,r),r},oe=(o,t)=>(n,e)=>t(n,e,o);exports.SheetsThreadCommentPopupService=class extends c.Disposable{constructor(n,e){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new H.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var u;const{row:r,col:i,unitId:s,subUnitId:a}=n;if(this._activePopup&&r===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&a===((u=this.activePopup)==null?void 0:u.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const m=this._canvasPopupManagerService.attachPopupToCell(r,i,{componentKey:me,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const d=new c.DisposableCollection;d.add(m),d.add({dispose:()=>{e==null||e()}}),this._lastPopup=d}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};exports.SheetsThreadCommentPopupService=ge([oe(0,c.Inject(w.SheetCanvasPopManagerService)),oe(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const A={type:c.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var f;const t=o.get(C.SheetsSelectionsService),n=o.get(c.IUniverInstanceService),e=o.get(exports.SheetsThreadCommentPopupService),r=o.get(P.ThreadCommentPanelService),i=(f=t.getCurrentLastSelection())==null?void 0:f.primary,s=o.get($.SheetsThreadCommentModel);if(!i)return!1;const a=C.getSheetCommandTarget(n);if(!a)return!1;const{workbook:m,worksheet:d,unitId:u,subUnitId:h}=a,l={workbook:m,worksheet:d,unitId:u,subUnitId:h,row:i.startRow,col:i.startColumn};e.showPopup(l);const p=s.getByLocation(u,h,i.startRow,i.startColumn);return p&&r.setActiveComment({unitId:u,subUnitId:h,commentId:p,trigger:"context-menu"}),!0}},Pe="sheets-thread-comment.config",ie={};var Te=Object.defineProperty,be=Object.getOwnPropertyDescriptor,ye=(o,t,n,e)=>{for(var r=e>1?void 0:e?be(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Te(t,n,r),r},L=(o,t)=>(n,e)=>t(n,e,o);let F=class extends c.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(o,t,n)=>{const{row:e,col:r,unitId:i,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,r)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(H.debounceTime(16)).subscribe(()=>{o()}))}};F=ye([L(0,c.Inject(C.SheetInterceptorService)),L(1,c.Inject($.SheetsThreadCommentModel)),L(2,c.IUniverInstanceService),L(3,ae.IRenderManagerService)],F);var Me=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ue=(o,t,n,e)=>{for(var r=e>1?void 0:e?we(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Me(t,n,r),r},K=(o,t)=>(n,e)=>t(n,e,o);const Re=(o,t,n)=>{const e=x.singleReferenceToGrid(o),r=n.row-t.row,i=n.column-t.column,s={startColumn:e.column+i,startRow:e.row+r,endColumn:e.column+i,endRow:e.row+r};return x.serializeRange(s)};let q=class extends c.Disposable{constructor(t,n,e){super();D(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:ne,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:i,subUnitId:s,range:a}=n,m={row:a.rows[0],column:a.cols[0]};if(r.copyType===w.COPY_TYPE.CUT&&this._copyInfo){const{range:d,unitId:u,subUnitId:h}=this._copyInfo,l={row:d.startRow,column:d.startColumn};if(!(i===u&&s===h)){const p=[];c.Range.foreach(d,(b,v)=>{const y=this._sheetsThreadCommentModel.getAllByLocation(u,h,b,v);this._threadCommentDataSourceService.syncUpdateMutationToColla?y.forEach(I=>{p.push(I)}):y.forEach(({children:I,...O})=>{O.parentId||p.push(O)})});const f=[],T=[],N=[],V=[],J=b=>{f.unshift({id:_.DeleteCommentMutation.id,params:{unitId:u,subUnitId:h,commentId:b.id}}),N.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...b,ref:Re(b.ref,l,m),unitId:i,subUnitId:s},sync:!0}}),T.push({id:_.AddCommentMutation.id,params:{unitId:u,subUnitId:h,comment:b,sync:!0}}),V.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:b.id}})};return p.forEach(b=>{J(b)}),{redos:[...f,...N],undos:[...V,...T]}}}return{redos:[],undos:[]}}}))}};q=Ue([K(0,c.Inject(w.ISheetClipboardService)),K(1,c.Inject($.SheetsThreadCommentModel)),K(2,_.IThreadCommentDataSourceService)],q);var Oe=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,je=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Oe(t,n,r),r},B=(o,t)=>(n,e)=>t(n,e,o);let G=class extends c.Disposable{constructor(o,t,n,e){super(),this._hoverManagerService=o,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(H.debounceTime(100)).subscribe(o=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(o&&(t&&t.temp||!t)){const{location:n}=o,{unitId:e,subUnitId:r,row:i,col:s}=n,a=this._sheetsThreadCommentModel.getByLocation(e,r,i,s);if(a){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}]))return;const d=this._sheetsThreadCommentModel.getComment(e,r,a);d&&!d.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:i,col:s,commentId:a,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};G=je([B(0,c.Inject(w.HoverManagerService)),B(1,c.Inject(exports.SheetsThreadCommentPopupService)),B(2,c.Inject($.SheetsThreadCommentModel)),B(3,c.Inject(C.SheetPermissionCheckController))],G);var De=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,$e=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ne(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&De(t,n,r),r},E=(o,t)=>(n,e)=>t(n,e,o);let Z=class extends c.Disposable{constructor(t,n,e,r,i,s,a,m,d,u){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=i,this._sheetPermissionCheckController=s,this._markSelectionService=a,this._sheetSelectionService=m,this._editorBridgeService=d,this._renderManagerService=u,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var l,p,f;const r=(l=t[0])==null?void 0:l.range,i=this._renderManagerService.getRenderById(n),s=(p=i==null?void 0:i.with(w.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:p.skeleton;if(!s||!r)return;const a=s.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((f=r.rangeType)!=null?f:c.RANGE_TYPE.NORMAL)!==c.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((a.isMerged||a.isMergedMainCell)&&c.Rectangle.equals(a.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const d=a.actualRow,u=a.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,d,u)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(n,e,d,u);h&&this._commandService.executeCommand(P.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===_.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:i,commentId:s}=e;n.unitId===r&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:i,trigger:s}=t,a=this._sheetsThreadCommentModel.getComment(e,r,i);if(!a||a.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=m.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const h=x.singleReferenceToGrid(a.ref),{row:l,column:p}=h;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:l,startColumn:p,endRow:l,endColumn:p}]))return;const T=1;if(await this._commandService.executeCommand(w.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-T,0),endRow:h.row+T,startColumn:Math.max(h.column-T,0),endColumn:h.column+T}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:h.row,col:h.column,commentId:a.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(H.debounceTime(100)).subscribe(t=>{var l,p;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(n,e,r);if(!i)return;const s=x.singleReferenceToGrid(i.ref),{row:a,column:m}=s;if(Number.isNaN(a)||Number.isNaN(m))return null;const d=(l=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getSheetBySheetId(e),u=(p=d==null?void 0:d.getMergedCell(a,m))!=null?p:{startColumn:m,endColumn:m,startRow:a,endRow:a},h=this._markSelectionService.addShape({range:u,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};Z=$e([E(0,c.ICommandService),E(1,c.Inject(exports.SheetsThreadCommentPopupService)),E(2,c.Inject($.SheetsThreadCommentModel)),E(3,c.Inject(P.ThreadCommentPanelService)),E(4,c.IUniverInstanceService),E(5,c.Inject(C.SheetPermissionCheckController)),E(6,w.IMarkSelectionService),E(7,c.Inject(C.SheetsSelectionsService)),E(8,w.IEditorBridgeService),E(9,ae.IRenderManagerService)],Z);var xe=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Ve=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ae(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&xe(t,n,r),r},W=(o,t)=>(n,e)=>t(n,e,o);let z=class extends c.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var t;if(o.id===C.RemoveSheetCommand.id){const n=o.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),i=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(r,i),a=Array.from(s.values()).filter(l=>!l.parentId),m=a.map(l=>l.id),d=this._threadCommentDataSourceService.syncUpdateMutationToColla,u=m.map(l=>({id:_.DeleteCommentMutation.id,params:{unitId:r,subUnitId:i,commentId:l}})),h=a.map(({children:l,...p})=>({id:_.AddCommentMutation.id,params:{unitId:r,subUnitId:i,comment:{...p,children:d?l:void 0},sync:!d}}));return{redos:u,undos:h}}return{redos:[],undos:[]}}}))}};z=Ve([W(0,c.Inject(C.SheetInterceptorService)),W(1,c.IUniverInstanceService),W(2,c.Inject(_.ThreadCommentModel)),W(3,_.IThreadCommentDataSourceService)],z);var M=function(){return M=Object.assign||function(o){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(o[r]=t[r])}return o},M.apply(this,arguments)},ke=function(o,t){var n={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&t.indexOf(e)<0&&(n[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(o);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(o,e[r])&&(n[e[r]]=o[e[r]]);return n},ue=R.forwardRef(function(o,t){var n=o.icon,e=o.id,r=o.className,i=o.extend,s=ke(o,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),m=R.useRef("_".concat(Be()));return de(n,"".concat(e),{defIds:n.defIds,idSuffix:m.current},M({ref:t,className:a},s),i)});function de(o,t,n,e,r){return R.createElement(o.tag,M(M({key:t},He(o,n,r)),e),(Le(o,n).children||[]).map(function(i,s){return de(i,"".concat(t,"-").concat(o.tag,"-").concat(s),n,void 0,r)}))}function He(o,t,n){var e=M({},o.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],a=i[1];typeof a=="string"&&(e[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function Le(o,t){var n,e=t.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?M(M({},o),{children:o.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?M(M({},r),{attrs:M(M({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):o}function Be(){return Math.random().toString(36).substring(2,8)}ue.displayName="UniverIcon";var We={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},he=R.forwardRef(function(o,t){return R.createElement(ue,Object.assign({},o,{id:"comment-single",ref:t,icon:We}))});he.displayName="CommentSingle";var Q={exports:{}},k={};/**
2
- * @license React
3
- * react-jsx-runtime.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var se;function Fe(){if(se)return k;se=1;var o=R,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,r=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(a,m,d){var u,h={},l=null,p=null;d!==void 0&&(l=""+d),m.key!==void 0&&(l=""+m.key),m.ref!==void 0&&(p=m.ref);for(u in m)e.call(m,u)&&!i.hasOwnProperty(u)&&(h[u]=m[u]);if(a&&a.defaultProps)for(u in m=a.defaultProps,m)h[u]===void 0&&(h[u]=m[u]);return{$$typeof:t,type:a,key:l,ref:p,props:h,_owner:r.current}}return k.Fragment=n,k.jsx=s,k.jsxs=s,k}var ce;function qe(){return ce||(ce=1,Q.exports=Fe()),Q.exports}var le=qe();const Ge=()=>{const o=c.useDependency(c.IUniverInstanceService),t=c.useDependency(exports.SheetsThreadCommentPopupService),n=S.useObservable(t.activePopup$),e=c.useDependency($.SheetsThreadCommentModel);if(S.useObservable(e.commentUpdate$),!n)return null;const{row:r,col:i,unitId:s,subUnitId:a,trigger:m}=n,d=e.getByLocation(s,a,r,i),u=`${c.Tools.chatAtABC(i)}${r+1}`,h=()=>{t.hidePopup()},l=p=>{var f,T,N;return(N=(T=(f=o.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:f.getSheetBySheetId(p))==null?void 0:T.getName())!=null?N:""};return le.jsx(P.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:a,type:c.UniverInstanceType.UNIVER_SHEET,refStr:u,onClose:h,getSubUnitName:l,autoFocus:m==="context-menu"})},Ze=()=>{var b;const o=c.useDependency(w.IMarkSelectionService),t=c.useDependency(c.IUniverInstanceService),n=c.useDependency(exports.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),r=e.getUnitId(),i=c.useDependency(c.ICommandService),s=R.useMemo(()=>e.activeSheet$.pipe(H.map(v=>v==null?void 0:v.getSheetId())),[e.activeSheet$]),a=S.useObservable(s,(b=e.getActiveSheet())==null?void 0:b.getSheetId()),m=R.useRef(),d=c.useDependency(P.ThreadCommentPanelService),u=S.useObservable(d.activeCommentId$),h=S.useObservable(d.panelVisible$,d.panelVisible),l=R.useCallback(v=>{const y=e.getSheets(),I={};y.forEach((U,g)=>{I[U.getSheetId()]=g});const O=U=>U.map(g=>{var re;const j=x.singleReferenceToGrid(g.ref),Ce=[(re=I[g.subUnitId])!=null?re:0,j.row,j.column];return{...g,p:Ce}}).sort((g,j)=>g.p[0]===j.p[0]?g.p[1]===j.p[1]?g.p[2]-j.p[2]:g.p[1]-j.p[1]:g.p[0]-j.p[0]);return[...O(v.filter(U=>!U.resolved)),...O(v.filter(U=>U.resolved))]},[e]),p=R.useCallback(v=>{var y;if(v.unitId===r&&v.subUnitId===a&&!v.resolved){const{row:I,column:O}=x.singleReferenceToGrid(v.ref),U=e.getSheetBySheetId(v.subUnitId),g=(y=U==null?void 0:U.getMergedCell(I,O))!=null?y:{startColumn:O,endColumn:O,startRow:I,endRow:I};if(!Number.isNaN(I)&&!Number.isNaN(O))return o.addShape({range:g,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,a,r]),f=v=>{var y,I;return(I=(y=e.getSheetBySheetId(v))==null?void 0:y.getName())!=null?I:""},T=()=>{i.executeCommand(A.id)},N=v=>{u&&u.unitId===v.unitId&&u.subUnitId===v.subUnitId&&u.commentId===v.id||(m.current&&(o.removeShape(m.current),m.current=null),m.current=p(v))},V=()=>{m.current&&(o.removeShape(m.current),m.current=null)},J=(v,y)=>{y&&n.hidePopup()};return R.useEffect(()=>{!h&&m.current&&o.removeShape(m.current)},[o,h]),le.jsx(P.ThreadCommentPanel,{unitId:r,subUnitId$:s,type:c.UniverInstanceType.UNIVER_SHEET,onAdd:T,getSubUnitName:f,onResolve:J,sortComments:l,onItemEnter:N,onItemLeave:V,onDeleteComment:()=>(V(),!0)})},ze=o=>({id:A.id,type:S.MenuItemType.BUTTON,icon:te,title:"sheetThreadComment.menu.addComment",hidden$:S.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET),disabled$:w.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),Ye=o=>({id:P.ToggleSheetCommentPanelOperation.id,type:S.MenuItemType.BUTTON,icon:te,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:w.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:S.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET)}),Je={id:A.id,binding:S.KeyCode.M|S.MetaKeys.CTRL_COMMAND|S.MetaKeys.ALT,preconditions:w.whenSheetEditorFocused},Ke={[S.RibbonStartGroup.OTHERS]:{[P.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:Ye}},[S.ContextMenuPosition.MAIN_AREA]:{[S.ContextMenuGroup.OTHERS]:{[A.id]:{order:0,menuItemFactory:ze}}}};var Qe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,et=(o,t,n,e)=>{for(var r=e>1?void 0:e?Xe(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Qe(t,n,r),r},X=(o,t)=>(n,e)=>t(n,e,o);let Y=class extends c.Disposable{constructor(o,t,n){super(),this._menuManagerService=o,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Je)}_initMenu(){this._menuManagerService.mergeMenu(Ke)}_initComponent(){[[me,Ge],[P.THREAD_COMMENT_PANEL,Ze],[te,he]].forEach(([o,t])=>{this._componentManager.register(o,t)})}};Y=et([X(0,S.IMenuManagerService),X(1,c.Inject(S.ComponentManager)),X(2,S.IShortcutService)],Y);var pe=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,nt=(o,t,n)=>t in o?pe(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,rt=(o,t,n,e)=>{for(var r=e>1?void 0:e?tt(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&pe(t,n,r),r},ee=(o,t)=>(n,e)=>t(n,e,o),ve=(o,t,n)=>nt(o,typeof t!="symbol"?t+"":t,n);exports.UniverSheetsThreadCommentUIPlugin=class extends c.Plugin{constructor(t=ie,n,e,r){super(),this._config=t,this._injector=n,this._commandService=e,this._configService=r;const{menu:i,...s}=c.merge({},ie,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Pe,s)}onStarting(){[[Y],[F],[q],[G],[z],[Z],[exports.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[A].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(Y)}onReady(){this._injector.get(F),this._injector.get(z)}onRendered(){this._injector.get(q),this._injector.get(G),this._injector.get(Z)}};ve(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",ne);ve(exports.UniverSheetsThreadCommentUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=rt([c.DependentOn(P.UniverThreadCommentUIPlugin,$.UniverSheetsThreadCommentPlugin),ee(1,c.Inject(c.Injector)),ee(2,c.Inject(c.ICommandService)),ee(3,c.IConfigService)],exports.UniverSheetsThreadCommentUIPlugin);Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>P.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"AddCommentCommand",{enumerable:!0,get:()=>_.AddCommentCommand});Object.defineProperty(exports,"DeleteCommentCommand",{enumerable:!0,get:()=>_.DeleteCommentCommand});Object.defineProperty(exports,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>_.DeleteCommentTreeCommand});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>_.IThreadCommentDataSourceService});Object.defineProperty(exports,"ResolveCommentCommand",{enumerable:!0,get:()=>_.ResolveCommentCommand});Object.defineProperty(exports,"UpdateCommentCommand",{enumerable:!0,get:()=>_.UpdateCommentCommand});exports.SHEETS_THREAD_COMMENT=ne;exports.ShowAddSheetCommentModalOperation=A;
1
+ "use strict";var le=Object.defineProperty;var pe=(o,t,n)=>t in o?le(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var j=(o,t,n)=>pe(o,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),v=require("@univerjs/sheets"),$=require("@univerjs/sheets-thread-comment"),P=require("@univerjs/thread-comment-ui"),w=require("@univerjs/sheets-ui"),S=require("@univerjs/ui"),k=require("rxjs"),oe=require("@univerjs/engine-render"),A=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),ie=require("react/jsx-runtime"),R=require("react"),se="univer.sheet.thread-comment-modal",X="comment-single",ee="SHEET_THREAD_COMMENT";var ve=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,Se=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ce(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&ve(t,n,r),r},ne=(o,t)=>(n,e)=>t(n,e,o);exports.SheetsThreadCommentPopupService=class extends c.Disposable{constructor(n,e){super();j(this,"_lastPopup",null);j(this,"_activePopup");j(this,"_activePopup$",new k.BehaviorSubject(null));j(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var h;const{row:r,col:i,unitId:s,subUnitId:a}=n;if(this._activePopup&&r===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&a===((h=this.activePopup)==null?void 0:h.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const m=this._canvasPopupManagerService.attachPopupToCell(r,i,{componentKey:se,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const d=new c.DisposableCollection;d.add(m),d.add({dispose:()=>{e==null||e()}}),this._lastPopup=d}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};exports.SheetsThreadCommentPopupService=Se([ne(0,c.Inject(w.SheetCanvasPopManagerService)),ne(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const x={type:c.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var f;const t=o.get(v.SheetsSelectionsService),n=o.get(c.IUniverInstanceService),e=o.get(exports.SheetsThreadCommentPopupService),r=o.get(P.ThreadCommentPanelService),i=(f=t.getCurrentLastSelection())==null?void 0:f.primary,s=o.get($.SheetsThreadCommentModel);if(!i)return!1;const a=v.getSheetCommandTarget(n);if(!a)return!1;const{workbook:m,worksheet:d,unitId:h,subUnitId:u}=a,l={workbook:m,worksheet:d,unitId:h,subUnitId:u,row:i.startRow,col:i.startColumn};e.showPopup(l);const C=s.getByLocation(h,u,i.startRow,i.startColumn);return C&&r.setActiveComment({unitId:h,subUnitId:u,commentId:C,trigger:"context-menu"}),!0}},_e="sheets-thread-comment.config",re={};var fe=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,ge=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ie(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&fe(t,n,r),r},H=(o,t)=>(n,e)=>t(n,e,o);let W=class extends c.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(o,t,n)=>{const{row:e,col:r,unitId:i,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,r)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(k.debounceTime(16)).subscribe(()=>{o()}))}};W=ge([H(0,c.Inject(v.SheetInterceptorService)),H(1,c.Inject($.SheetsThreadCommentModel)),H(2,c.IUniverInstanceService),H(3,oe.IRenderManagerService)],W);var Pe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,be=(o,t,n,e)=>{for(var r=e>1?void 0:e?Te(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Pe(t,n,r),r},Y=(o,t)=>(n,e)=>t(n,e,o);const Me=(o,t,n)=>{const e=A.singleReferenceToGrid(o),r=n.row-t.row,i=n.column-t.column,s={startColumn:e.column+i,startRow:e.row+r,endColumn:e.column+i,endRow:e.row+r};return A.serializeRange(s)};let F=class extends c.Disposable{constructor(t,n,e){super();j(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:ee,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:i,subUnitId:s,range:a}=n,m={row:a.rows[0],column:a.cols[0]};if(r.copyType===w.COPY_TYPE.CUT&&this._copyInfo){const{range:d,unitId:h,subUnitId:u}=this._copyInfo,l={row:d.startRow,column:d.startColumn};if(!(i===h&&s===u)){const C=[];c.Range.foreach(d,(b,p)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(h,u,b,p);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(I=>{C.push(I)}):M.forEach(({children:I,...O})=>{O.parentId||C.push(O)})});const f=[],T=[],N=[],V=[],K=b=>{f.unshift({id:_.DeleteCommentMutation.id,params:{unitId:h,subUnitId:u,commentId:b.id}}),N.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...b,ref:Me(b.ref,l,m),unitId:i,subUnitId:s},sync:!0}}),T.push({id:_.AddCommentMutation.id,params:{unitId:h,subUnitId:u,comment:b,sync:!0}}),V.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:b.id}})};return C.forEach(b=>{K(b)}),{redos:[...f,...N],undos:[...V,...T]}}}return{redos:[],undos:[]}}}))}};F=be([Y(0,c.Inject(w.ISheetClipboardService)),Y(1,c.Inject($.SheetsThreadCommentModel)),Y(2,_.IThreadCommentDataSourceService)],F);var ye=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ue=(o,t,n,e)=>{for(var r=e>1?void 0:e?we(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&ye(t,n,r),r},B=(o,t)=>(n,e)=>t(n,e,o);let q=class extends c.Disposable{constructor(o,t,n,e){super(),this._hoverManagerService=o,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(k.debounceTime(100)).subscribe(o=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(o&&(t&&t.temp||!t)){const{location:n}=o,{unitId:e,subUnitId:r,row:i,col:s}=n,a=this._sheetsThreadCommentModel.getByLocation(e,r,i,s);if(a){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}]))return;const d=this._sheetsThreadCommentModel.getComment(e,r,a);d&&!d.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:i,col:s,commentId:a,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};q=Ue([B(0,c.Inject(w.HoverManagerService)),B(1,c.Inject(exports.SheetsThreadCommentPopupService)),B(2,c.Inject($.SheetsThreadCommentModel)),B(3,c.Inject(v.SheetPermissionCheckController))],q);var Oe=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Re=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Oe(t,n,r),r},E=(o,t)=>(n,e)=>t(n,e,o);let G=class extends c.Disposable{constructor(t,n,e,r,i,s,a,m,d,h){super();j(this,"_isSwitchToCommenting",!1);j(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=i,this._sheetPermissionCheckController=s,this._markSelectionService=a,this._sheetSelectionService=m,this._editorBridgeService=d,this._renderManagerService=h,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var l,C,f;const r=(l=t[0])==null?void 0:l.range,i=this._renderManagerService.getRenderById(n),s=(C=i==null?void 0:i.with(w.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:C.skeleton;if(!s||!r)return;const a=s.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((f=r.rangeType)!=null?f:c.RANGE_TYPE.NORMAL)!==c.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((a.isMerged||a.isMergedMainCell)&&c.Rectangle.equals(a.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const d=a.actualRow,h=a.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,d,h)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const u=this._sheetsThreadCommentModel.getByLocation(n,e,d,h);u&&this._commandService.executeCommand(P.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:u})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===_.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:i,commentId:s}=e;n.unitId===r&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:i,trigger:s}=t,a=this._sheetsThreadCommentModel.getComment(e,r,i);if(!a||a.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=m.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const u=A.singleReferenceToGrid(a.ref),{row:l,column:C}=u;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:l,startColumn:C,endRow:l,endColumn:C}]))return;const T=1;if(await this._commandService.executeCommand(w.ScrollToRangeOperation.id,{range:{startRow:Math.max(u.row-T,0),endRow:u.row+T,startColumn:Math.max(u.column-T,0),endColumn:u.column+T}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:u.row,col:u.column,commentId:a.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(k.debounceTime(100)).subscribe(t=>{var l,C;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(n,e,r);if(!i)return;const s=A.singleReferenceToGrid(i.ref),{row:a,column:m}=s;if(Number.isNaN(a)||Number.isNaN(m))return null;const d=(l=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getSheetBySheetId(e),h=(C=d==null?void 0:d.getMergedCell(a,m))!=null?C:{startColumn:m,endColumn:m,startRow:a,endRow:a},u=this._markSelectionService.addShape({range:h,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);u&&(this._selectionShapeInfo={...t,shapeId:u})}))}};G=Re([E(0,c.ICommandService),E(1,c.Inject(exports.SheetsThreadCommentPopupService)),E(2,c.Inject($.SheetsThreadCommentModel)),E(3,c.Inject(P.ThreadCommentPanelService)),E(4,c.IUniverInstanceService),E(5,c.Inject(v.SheetPermissionCheckController)),E(6,w.IMarkSelectionService),E(7,c.Inject(v.SheetsSelectionsService)),E(8,w.IEditorBridgeService),E(9,oe.IRenderManagerService)],G);var De=Object.defineProperty,je=Object.getOwnPropertyDescriptor,Ne=(o,t,n,e)=>{for(var r=e>1?void 0:e?je(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&De(t,n,r),r},L=(o,t)=>(n,e)=>t(n,e,o);let Z=class extends c.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var t;if(o.id===v.RemoveSheetCommand.id){const n=o.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),i=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(r,i),a=Array.from(s.values()).filter(l=>!l.parentId),m=a.map(l=>l.id),d=this._threadCommentDataSourceService.syncUpdateMutationToColla,h=m.map(l=>({id:_.DeleteCommentMutation.id,params:{unitId:r,subUnitId:i,commentId:l}})),u=a.map(({children:l,...C})=>({id:_.AddCommentMutation.id,params:{unitId:r,subUnitId:i,comment:{...C,children:d?l:void 0},sync:!d}}));return{redos:h,undos:u}}return{redos:[],undos:[]}}}))}};Z=Ne([L(0,c.Inject(v.SheetInterceptorService)),L(1,c.IUniverInstanceService),L(2,c.Inject(_.ThreadCommentModel)),L(3,_.IThreadCommentDataSourceService)],Z);var y=function(){return y=Object.assign||function(o){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(o[r]=t[r])}return o},y.apply(this,arguments)},$e=function(o,t){var n={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&t.indexOf(e)<0&&(n[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(o);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(o,e[r])&&(n[e[r]]=o[e[r]]);return n},ce=R.forwardRef(function(o,t){var n=o.icon,e=o.id,r=o.className,i=o.extend,s=$e(o,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),m=R.useRef("_".concat(Ve()));return ae(n,"".concat(e),{defIds:n.defIds,idSuffix:m.current},y({ref:t,className:a},s),i)});function ae(o,t,n,e,r){return R.createElement(o.tag,y(y({key:t},Ae(o,n,r)),e),(xe(o,n).children||[]).map(function(i,s){return ae(i,"".concat(t,"-").concat(o.tag,"-").concat(s),n,void 0,r)}))}function Ae(o,t,n){var e=y({},o.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],a=i[1];typeof a=="string"&&(e[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function xe(o,t){var n,e=t.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?y(y({},o),{children:o.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?y(y({},r),{attrs:y(y({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):o}function Ve(){return Math.random().toString(36).substring(2,8)}ce.displayName="UniverIcon";var ke={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},me=R.forwardRef(function(o,t){return R.createElement(ce,Object.assign({},o,{id:"comment-single",ref:t,icon:ke}))});me.displayName="CommentSingle";const He=()=>{const o=c.useDependency(c.IUniverInstanceService),t=c.useDependency(exports.SheetsThreadCommentPopupService),n=S.useObservable(t.activePopup$),e=c.useDependency($.SheetsThreadCommentModel);if(S.useObservable(e.commentUpdate$),!n)return null;const{row:r,col:i,unitId:s,subUnitId:a,trigger:m}=n,d=e.getByLocation(s,a,r,i),h=`${c.Tools.chatAtABC(i)}${r+1}`,u=()=>{t.hidePopup()},l=C=>{var f,T,N;return(N=(T=(f=o.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:f.getSheetBySheetId(C))==null?void 0:T.getName())!=null?N:""};return ie.jsx(P.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:a,type:c.UniverInstanceType.UNIVER_SHEET,refStr:h,onClose:u,getSubUnitName:l,autoFocus:m==="context-menu"})},Be=()=>{var b;const o=c.useDependency(w.IMarkSelectionService),t=c.useDependency(c.IUniverInstanceService),n=c.useDependency(exports.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),r=e.getUnitId(),i=c.useDependency(c.ICommandService),s=R.useMemo(()=>e.activeSheet$.pipe(k.map(p=>p==null?void 0:p.getSheetId())),[e.activeSheet$]),a=S.useObservable(s,(b=e.getActiveSheet())==null?void 0:b.getSheetId()),m=R.useRef(null),d=c.useDependency(P.ThreadCommentPanelService),h=S.useObservable(d.activeCommentId$),u=S.useObservable(d.panelVisible$,d.panelVisible),l=R.useCallback(p=>{const M=e.getSheets(),I={};M.forEach((U,g)=>{I[U.getSheetId()]=g});const O=U=>U.map(g=>{var te;const D=A.singleReferenceToGrid(g.ref),he=[(te=I[g.subUnitId])!=null?te:0,D.row,D.column];return{...g,p:he}}).sort((g,D)=>g.p[0]===D.p[0]?g.p[1]===D.p[1]?g.p[2]-D.p[2]:g.p[1]-D.p[1]:g.p[0]-D.p[0]);return[...O(p.filter(U=>!U.resolved)),...O(p.filter(U=>U.resolved))]},[e]),C=R.useCallback(p=>{var M;if(p.unitId===r&&p.subUnitId===a&&!p.resolved){const{row:I,column:O}=A.singleReferenceToGrid(p.ref),U=e.getSheetBySheetId(p.subUnitId),g=(M=U==null?void 0:U.getMergedCell(I,O))!=null?M:{startColumn:O,endColumn:O,startRow:I,endRow:I};if(!Number.isNaN(I)&&!Number.isNaN(O))return o.addShape({range:g,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[o,a,r]),f=p=>{var M,I;return(I=(M=e.getSheetBySheetId(p))==null?void 0:M.getName())!=null?I:""},T=()=>{i.executeCommand(x.id)},N=p=>{h&&h.unitId===p.unitId&&h.subUnitId===p.subUnitId&&h.commentId===p.id||(m.current&&(o.removeShape(m.current),m.current=null),m.current=C(p))},V=()=>{m.current&&(o.removeShape(m.current),m.current=null)},K=(p,M)=>{M&&n.hidePopup()};return R.useEffect(()=>{!u&&m.current&&o.removeShape(m.current)},[o,u]),ie.jsx(P.ThreadCommentPanel,{unitId:r,subUnitId$:s,type:c.UniverInstanceType.UNIVER_SHEET,onAdd:T,getSubUnitName:f,onResolve:K,sortComments:l,onItemEnter:N,onItemLeave:V,onDeleteComment:()=>(V(),!0)})},Le=o=>({id:x.id,type:S.MenuItemType.BUTTON,icon:X,title:"sheetThreadComment.menu.addComment",hidden$:S.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET),disabled$:w.getCurrentRangeDisable$(o,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]})}),We=o=>({id:P.ToggleSheetCommentPanelOperation.id,type:S.MenuItemType.BUTTON,icon:X,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:w.getCurrentRangeDisable$(o,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]}),hidden$:S.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET)}),Fe={id:x.id,binding:S.KeyCode.M|S.MetaKeys.CTRL_COMMAND|S.MetaKeys.ALT,preconditions:w.whenSheetEditorFocused},qe={[S.RibbonStartGroup.OTHERS]:{[P.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:We}},[S.ContextMenuPosition.MAIN_AREA]:{[S.ContextMenuGroup.OTHERS]:{[x.id]:{order:0,menuItemFactory:Le}}}};var Ge=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,ze=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ze(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Ge(t,n,r),r},J=(o,t)=>(n,e)=>t(n,e,o);let z=class extends c.Disposable{constructor(o,t,n){super(),this._menuManagerService=o,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Fe)}_initMenu(){this._menuManagerService.mergeMenu(qe)}_initComponent(){[[se,He],[P.THREAD_COMMENT_PANEL,Be],[X,me]].forEach(([o,t])=>{this._componentManager.register(o,t)})}};z=ze([J(0,S.IMenuManagerService),J(1,c.Inject(S.ComponentManager)),J(2,S.IShortcutService)],z);var de=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ye=(o,t,n)=>t in o?de(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,Je=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ke(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&de(t,n,r),r},Q=(o,t)=>(n,e)=>t(n,e,o),ue=(o,t,n)=>Ye(o,typeof t!="symbol"?t+"":t,n);exports.UniverSheetsThreadCommentUIPlugin=class extends c.Plugin{constructor(t=re,n,e,r){super(),this._config=t,this._injector=n,this._commandService=e,this._configService=r;const{menu:i,...s}=c.merge({},re,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(_e,s)}onStarting(){[[z],[W],[F],[q],[Z],[G],[exports.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[x].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(z)}onReady(){this._injector.get(W),this._injector.get(Z)}onRendered(){this._injector.get(F),this._injector.get(q),this._injector.get(G)}};ue(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",ee);ue(exports.UniverSheetsThreadCommentUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=Je([c.DependentOn(P.UniverThreadCommentUIPlugin,$.UniverSheetsThreadCommentPlugin),Q(1,c.Inject(c.Injector)),Q(2,c.Inject(c.ICommandService)),Q(3,c.IConfigService)],exports.UniverSheetsThreadCommentUIPlugin);Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>P.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"AddCommentCommand",{enumerable:!0,get:()=>_.AddCommentCommand});Object.defineProperty(exports,"DeleteCommentCommand",{enumerable:!0,get:()=>_.DeleteCommentCommand});Object.defineProperty(exports,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>_.DeleteCommentTreeCommand});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>_.IThreadCommentDataSourceService});Object.defineProperty(exports,"ResolveCommentCommand",{enumerable:!0,get:()=>_.ResolveCommentCommand});Object.defineProperty(exports,"UpdateCommentCommand",{enumerable:!0,get:()=>_.UpdateCommentCommand});exports.SHEETS_THREAD_COMMENT=ee;exports.ShowAddSheetCommentModalOperation=x;