@univerjs/thread-comment-ui 0.4.0 → 0.4.1-experimental.20241023-bbb123f

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,3 +1,3 @@
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 threadComment$2=require("@univerjs/thread-comment"),core=require("@univerjs/core"),ui=require("@univerjs/ui"),rxjs=require("rxjs"),design=require("@univerjs/design"),React=require("react"),docs=require("@univerjs/docs"),docsUi=require("@univerjs/docs-ui"),engineRender=require("@univerjs/engine-render");var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}__name(getDefaultExportFromCjs,"getDefaultExportFromCjs");var dayjs_min={exports:{}};(function(module2,exports2){(function(t,e){module2.exports=e()})(commonjsGlobal,function(){var t=1e3,e=6e4,n=36e5,r2="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:__name(function(t2){var e2=["th","st","nd","rd"],n2=t2%100;return"["+t2+(e2[(n2-20)%10]||e2[n2]||e2[0])+"]"},"ordinal")},m=__name(function(t2,e2,n2){var r3=String(t2);return!r3||r3.length>=e2?t2:""+Array(e2+1-r3.length).join(n2)+t2},"m"),v={s:m,z:__name(function(t2){var e2=-t2.utcOffset(),n2=Math.abs(e2),r3=Math.floor(n2/60),i2=n2%60;return(e2<=0?"+":"-")+m(r3,2,"0")+":"+m(i2,2,"0")},"z"),m:__name(function t2(e2,n2){if(e2.date()<n2.date())return-t2(n2,e2);var r3=12*(n2.year()-e2.year())+(n2.month()-e2.month()),i2=e2.clone().add(r3,c),s2=n2-i2<0,u2=e2.clone().add(r3+(s2?-1:1),c);return+(-(r3+(n2-i2)/(s2?i2-u2:u2-i2))||0)},"t"),a:__name(function(t2){return t2<0?Math.ceil(t2)||0:Math.floor(t2)},"a"),p:__name(function(t2){return{M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r2,Q:f}[t2]||String(t2||"").toLowerCase().replace(/s$/,"")},"p"),u:__name(function(t2){return t2===void 0},"u")},g="en",D={};D[g]=M;var p="$isDayjsObject",S=__name(function(t2){return t2 instanceof _||!(!t2||!t2[p])},"S"),w=__name(function t2(e2,n2,r3){var i2;if(!e2)return g;if(typeof e2=="string"){var s2=e2.toLowerCase();D[s2]&&(i2=s2),n2&&(D[s2]=n2,i2=s2);var u2=e2.split("-");if(!i2&&u2.length>1)return t2(u2[0])}else{var a2=e2.name;D[a2]=e2,i2=a2}return!r3&&i2&&(g=i2),i2||!r3&&g},"t"),O=__name(function(t2,e2){if(S(t2))return t2.clone();var n2=typeof e2=="object"?e2:{};return n2.date=t2,n2.args=arguments,new _(n2)},"O"),b=v;b.l=w,b.i=S,b.w=function(t2,e2){return O(t2,{locale:e2.$L,utc:e2.$u,x:e2.$x,$offset:e2.$offset})};var _=function(){function M2(t2){this.$L=w(t2.locale,null,!0),this.parse(t2),this.$x=this.$x||t2.x||{},this[p]=!0}__name(M2,"M");var m2=M2.prototype;return m2.parse=function(t2){this.$d=function(t3){var e2=t3.date,n2=t3.utc;if(e2===null)return new Date(NaN);if(b.u(e2))return new Date;if(e2 instanceof Date)return new Date(e2);if(typeof e2=="string"&&!/Z$/i.test(e2)){var r3=e2.match($);if(r3){var i2=r3[2]-1||0,s2=(r3[7]||"0").substring(0,3);return n2?new Date(Date.UTC(r3[1],i2,r3[3]||1,r3[4]||0,r3[5]||0,r3[6]||0,s2)):new Date(r3[1],i2,r3[3]||1,r3[4]||0,r3[5]||0,r3[6]||0,s2)}}return new Date(e2)}(t2),this.init()},m2.init=function(){var t2=this.$d;this.$y=t2.getFullYear(),this.$M=t2.getMonth(),this.$D=t2.getDate(),this.$W=t2.getDay(),this.$H=t2.getHours(),this.$m=t2.getMinutes(),this.$s=t2.getSeconds(),this.$ms=t2.getMilliseconds()},m2.$utils=function(){return b},m2.isValid=function(){return this.$d.toString()!==l},m2.isSame=function(t2,e2){var n2=O(t2);return this.startOf(e2)<=n2&&n2<=this.endOf(e2)},m2.isAfter=function(t2,e2){return O(t2)<this.startOf(e2)},m2.isBefore=function(t2,e2){return this.endOf(e2)<O(t2)},m2.$g=function(t2,e2,n2){return b.u(t2)?this[e2]:this.set(n2,t2)},m2.unix=function(){return Math.floor(this.valueOf()/1e3)},m2.valueOf=function(){return this.$d.getTime()},m2.startOf=function(t2,e2){var n2=this,r3=!!b.u(e2)||e2,f2=b.p(t2),l2=__name(function(t3,e3){var i2=b.w(n2.$u?Date.UTC(n2.$y,e3,t3):new Date(n2.$y,e3,t3),n2);return r3?i2:i2.endOf(a)},"l"),$2=__name(function(t3,e3){return b.w(n2.toDate()[t3].apply(n2.toDate("s"),(r3?[0,0,0,0]:[23,59,59,999]).slice(e3)),n2)},"$"),y2=this.$W,M3=this.$M,m3=this.$D,v2="set"+(this.$u?"UTC":"");switch(f2){case h:return r3?l2(1,0):l2(31,11);case c:return r3?l2(1,M3):l2(0,M3+1);case o:var g2=this.$locale().weekStart||0,D2=(y2<g2?y2+7:y2)-g2;return l2(r3?m3-D2:m3+(6-D2),M3);case a:case d:return $2(v2+"Hours",0);case u:return $2(v2+"Minutes",1);case s:return $2(v2+"Seconds",2);case i:return $2(v2+"Milliseconds",3);default:return this.clone()}},m2.endOf=function(t2){return this.startOf(t2,!1)},m2.$set=function(t2,e2){var n2,o2=b.p(t2),f2="set"+(this.$u?"UTC":""),l2=(n2={},n2[a]=f2+"Date",n2[d]=f2+"Date",n2[c]=f2+"Month",n2[h]=f2+"FullYear",n2[u]=f2+"Hours",n2[s]=f2+"Minutes",n2[i]=f2+"Seconds",n2[r2]=f2+"Milliseconds",n2)[o2],$2=o2===a?this.$D+(e2-this.$W):e2;if(o2===c||o2===h){var y2=this.clone().set(d,1);y2.$d[l2]($2),y2.init(),this.$d=y2.set(d,Math.min(this.$D,y2.daysInMonth())).$d}else l2&&this.$d[l2]($2);return this.init(),this},m2.set=function(t2,e2){return this.clone().$set(t2,e2)},m2.get=function(t2){return this[b.p(t2)]()},m2.add=function(r3,f2){var d2,l2=this;r3=Number(r3);var $2=b.p(f2),y2=__name(function(t2){var e2=O(l2);return b.w(e2.date(e2.date()+Math.round(t2*r3)),l2)},"y");if($2===c)return this.set(c,this.$M+r3);if($2===h)return this.set(h,this.$y+r3);if($2===a)return y2(1);if($2===o)return y2(7);var M3=(d2={},d2[s]=e,d2[u]=n,d2[i]=t,d2)[$2]||1,m3=this.$d.getTime()+r3*M3;return b.w(m3,this)},m2.subtract=function(t2,e2){return this.add(-1*t2,e2)},m2.format=function(t2){var e2=this,n2=this.$locale();if(!this.isValid())return n2.invalidDate||l;var r3=t2||"YYYY-MM-DDTHH:mm:ssZ",i2=b.z(this),s2=this.$H,u2=this.$m,a2=this.$M,o2=n2.weekdays,c2=n2.months,f2=n2.meridiem,h2=__name(function(t3,n3,i3,s3){return t3&&(t3[n3]||t3(e2,r3))||i3[n3].slice(0,s3)},"h"),d2=__name(function(t3){return b.s(s2%12||12,t3,"0")},"d"),$2=f2||function(t3,e3,n3){var r4=t3<12?"AM":"PM";return n3?r4.toLowerCase():r4};return r3.replace(y,function(t3,r4){return r4||function(t4){switch(t4){case"YY":return String(e2.$y).slice(-2);case"YYYY":return b.s(e2.$y,4,"0");case"M":return a2+1;case"MM":return b.s(a2+1,2,"0");case"MMM":return h2(n2.monthsShort,a2,c2,3);case"MMMM":return h2(c2,a2);case"D":return e2.$D;case"DD":return b.s(e2.$D,2,"0");case"d":return String(e2.$W);case"dd":return h2(n2.weekdaysMin,e2.$W,o2,2);case"ddd":return h2(n2.weekdaysShort,e2.$W,o2,3);case"dddd":return o2[e2.$W];case"H":return String(s2);case"HH":return b.s(s2,2,"0");case"h":return d2(1);case"hh":return d2(2);case"a":return $2(s2,u2,!0);case"A":return $2(s2,u2,!1);case"m":return String(u2);case"mm":return b.s(u2,2,"0");case"s":return String(e2.$s);case"ss":return b.s(e2.$s,2,"0");case"SSS":return b.s(e2.$ms,3,"0");case"Z":return i2}return null}(t3)||i2.replace(":","")})},m2.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m2.diff=function(r3,d2,l2){var $2,y2=this,M3=b.p(d2),m3=O(r3),v2=(m3.utcOffset()-this.utcOffset())*e,g2=this-m3,D2=__name(function(){return b.m(y2,m3)},"D");switch(M3){case h:$2=D2()/12;break;case c:$2=D2();break;case f:$2=D2()/3;break;case o:$2=(g2-v2)/6048e5;break;case a:$2=(g2-v2)/864e5;break;case u:$2=g2/n;break;case s:$2=g2/e;break;case i:$2=g2/t;break;default:$2=g2}return l2?$2:b.a($2)},m2.daysInMonth=function(){return this.endOf(c).$D},m2.$locale=function(){return D[this.$L]},m2.locale=function(t2,e2){if(!t2)return this.$L;var n2=this.clone(),r3=w(t2,e2,!0);return r3&&(n2.$L=r3),n2},m2.clone=function(){return b.w(this.$d,this)},m2.toDate=function(){return new Date(this.valueOf())},m2.toJSON=function(){return this.isValid()?this.toISOString():null},m2.toISOString=function(){return this.$d.toISOString()},m2.toString=function(){return this.$d.toUTCString()},M2}(),k=_.prototype;return O.prototype=k,[["$ms",r2],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach(function(t2){k[t2[1]]=function(e2){return this.$g(e2,t2[0],t2[1])}}),O.extend=function(t2,e2){return t2.$i||(t2(e2,_,O),t2.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t2){return O(1e3*t2)},O.en=D[g],O.Ls=D,O.p={},O})})(dayjs_min);var dayjs_minExports=dayjs_min.exports;const dayjs=getDefaultExportFromCjs(dayjs_minExports);function getDT(){return dayjs().format("YYYY/MM/DD HH:mm")}__name(getDT,"getDT");const THREAD_COMMENT_PANEL="thread-comment-panel",PLUGIN_NAME="UNIVER_THREAD_COMMENT_UI_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"),_a;exports.ThreadCommentPanelService=(_a=class extends core.Disposable{constructor(_sidebarService,_univerInstanceService){super();__publicField(this,"_panelVisible",!1);__publicField(this,"_panelVisible$",new rxjs.BehaviorSubject(!1));__publicField(this,"_activeCommentId");__publicField(this,"_activeCommentId$",new rxjs.BehaviorSubject(void 0));__publicField(this,"panelVisible$",this._panelVisible$.asObservable());__publicField(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=_sidebarService,this._univerInstanceService=_univerInstanceService,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(opt=>{opt.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET).pipe(rxjs.filter(sheet=>!sheet)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(visible){this._panelVisible=visible,this._panelVisible$.next(visible)}setActiveComment(commentInfo){this._activeCommentId=commentInfo,this._activeCommentId$.next(commentInfo)}},__name(_a,"ThreadCommentPanelService"),_a);exports.ThreadCommentPanelService=__decorateClass$1([__decorateParam$1(0,core.Inject(ui.ISidebarService)),__decorateParam$1(1,core.IUniverInstanceService)],exports.ThreadCommentPanelService);const ToggleSheetCommentPanelOperation={id:"thread-comment-ui.operation.toggle-panel",type:core.CommandType.OPERATION,handler(accessor){const sidebarService=accessor.get(ui.ISidebarService),panelService=accessor.get(exports.ThreadCommentPanelService);return panelService.panelVisible?(sidebarService.close(),panelService.setPanelVisible(!1)):(sidebarService.open({header:{title:"threadCommentUI.panel.title"},children:{label:THREAD_COMMENT_PANEL},width:330}),panelService.setPanelVisible(!0)),!0}},SetActiveCommentOperation={id:"thread-comment-ui.operation.set-active-comment",type:core.CommandType.OPERATION,handler(accessor,params){return accessor.get(exports.ThreadCommentPanelService).setActiveComment(params),!0}},_ThreadCommentMentionDataService=class _ThreadCommentMentionDataService{constructor(){__publicField(this,"dataSource");__publicField(this,"renderSuggestion");__publicField(this,"trigger","@")}async getMentions(search,unitId,subUnitId){return this.dataSource?this.dataSource.getMentions(search,unitId,subUnitId):[]}};__name(_ThreadCommentMentionDataService,"ThreadCommentMentionDataService");let ThreadCommentMentionDataService=_ThreadCommentMentionDataService;const IThreadCommentMentionDataService=core.createIdentifier("thread-comment.mention-data.service"),PLUGIN_CONFIG_KEY="thread-comment-ui.config",defaultPluginConfig={};var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__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"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField"),_a2;exports.UniverThreadCommentUIPlugin=(_a2=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_commandService,_configService){super(),this._config=_config,this._injector=_injector,this._commandService=_commandService,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){var _a3;core.mergeOverrideWithDependencies([[exports.ThreadCommentPanelService],[IThreadCommentMentionDataService,{useClass:ThreadCommentMentionDataService}]],(_a3=this._config)==null?void 0:_a3.overrides).forEach(dep=>{this._injector.add(dep)}),[ToggleSheetCommentPanelOperation,SetActiveCommentOperation].forEach(command=>{this._commandService.registerCommand(command)})}},__name(_a2,"UniverThreadCommentUIPlugin"),_a2);__publicField2(exports.UniverThreadCommentUIPlugin,"pluginName",PLUGIN_NAME);__publicField2(exports.UniverThreadCommentUIPlugin,"type",core.UniverInstanceType.UNIVER_UNKNOWN);exports.UniverThreadCommentUIPlugin=__decorateClass([core.DependentOn(threadComment$2.UniverThreadCommentPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.ICommandService),__decorateParam(3,core.IConfigService)],exports.UniverThreadCommentUIPlugin);var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=React.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=React.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return React.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a3){var key=_a3[0],value=_a3[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a3,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a3=node.children)===null||_a3===void 0)&&_a3.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid");IconBase.displayName="UniverIcon";var element$5={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},DeleteSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"delete-single",ref,icon:element$5}))});DeleteSingle.displayName="DeleteSingle";var element$4={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},IncreaseSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"increase-single",ref,icon:element$4}))});IncreaseSingle.displayName="IncreaseSingle";var element$3={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z"}}]},MoreHorizontalSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"more-horizontal-single",ref,icon:element$3}))});MoreHorizontalSingle.displayName="MoreHorizontalSingle";var element$2={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},ReplyToCommentSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"reply-to-comment-single",ref,icon:element$2}))});ReplyToCommentSingle.displayName="ReplyToCommentSingle";var element$1={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ResolvedSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"resolved-single",ref,icon:element$1}))});ResolvedSingle.displayName="ResolvedSingle";var element={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},SolveSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"solve-single",ref,icon:element}))});SolveSingle.displayName="SolveSingle";function r(e){var t,f,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}__name(r,"r");function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}__name(clsx,"clsx");const threadCommentEditorButtons="univer-thread-comment-editor-buttons",threadCommentEditorSuggestion="univer-thread-comment-editor-suggestion",threadCommentEditorSuggestionActive="univer-thread-comment-editor-suggestionActive",threadCommentEditorSuggestionIcon="univer-thread-comment-editor-suggestion-icon",styles$2={threadCommentEditorButtons,threadCommentEditorSuggestion,threadCommentEditorSuggestionActive,threadCommentEditorSuggestionIcon},parseMentions=__name(text=>{const regex=/@\[(.*?)\]\((.*?)\)|(\w+)/g;let match,lastIndex=0;const result=[];for(;(match=regex.exec(text))!==null;)match.index>lastIndex&&result.push({type:"text",content:text.substring(lastIndex,match.index)}),match[1]&&match[2]?result.push({type:"mention",content:{label:match[1],id:match[2]}}):match[3]&&result.push({type:"text",content:match[3]}),lastIndex=regex.lastIndex;return lastIndex<text.length&&result.push({type:"text",content:text.substring(lastIndex)}),result},"parseMentions"),transformTextNode2Text=__name(nodes=>nodes.map(item=>{switch(item.type){case"mention":return`@[${item.content.label}](${item.content.id})`;default:return item.content}}).join(""),"transformTextNode2Text"),transformDocument2TextNodes=__name(doc=>{const{dataStream,customRanges}=doc,end=dataStream.length-2,textNodes=[];let lastIndex=0;return customRanges==null||customRanges.forEach(range=>{lastIndex<range.startIndex&&textNodes.push({type:"text",content:dataStream.slice(lastIndex,range.startIndex)}),textNodes.push({type:"mention",content:{label:dataStream.slice(range.startIndex,range.endIndex).slice(1,-1),id:range.rangeId}}),lastIndex=range.endIndex}),textNodes.push({type:"text",content:dataStream.slice(lastIndex,end)}),textNodes},"transformDocument2TextNodes"),transformTextNodes2Document=__name(nodes=>{let str="";const customRanges=[];return nodes.forEach(node=>{switch(node.type){case"text":str+=node.content;break;case"mention":{const start=str.length;str+=`${node.content.label}`;const end=str.length;customRanges.push({rangeId:node.content.id,rangeType:core.CustomRangeType.MENTION,startIndex:start,endIndex:end});break}}}),str+=`
2
- \r`,{textRuns:[],paragraphs:[{startIndex:str.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:str.length-1}],dataStream:str,customRanges}},"transformTextNodes2Document"),transformMention=__name(mention=>({display:mention.label,id:`${mention.id}`,raw:mention}),"transformMention"),defaultRenderSuggestion=__name((mention,search,highlightedDisplay,index,focused)=>{var _a3,_b;const icon=(_a3=mention.raw)==null?void 0:_a3.icon;return React.createElement("div",{className:styles$2.threadCommentEditorSuggestion},icon?React.createElement("img",{className:styles$2.threadCommentEditorSuggestionIcon,src:icon}):null,React.createElement("div",null,(_b=mention.display)!=null?_b:mention.id))},"defaultRenderSuggestion"),ThreadCommentEditor=React.forwardRef((props,ref)=>{var _a3,_b;const{comment,onSave,id,onCancel,autoFocus,unitId,subUnitId}=props,mentionDataService=core.useDependency(IThreadCommentMentionDataService),commandService=core.useDependency(core.ICommandService),localeService=core.useDependency(core.LocaleService),[localComment,setLocalComment]=React.useState({...comment}),[editing,setEditing]=React.useState(!1),inputRef=React.useRef(null),docSelectionManagerService=core.useDependency(docs.DocSelectionManagerService),docSelectionRenderService=(_a3=core.useDependency(engineRender.IRenderManagerService).getCurrentTypeOfRenderer(core.UniverInstanceType.UNIVER_DOC))==null?void 0:_a3.with(docsUi.DocSelectionRenderService);React.useImperativeHandle(ref,()=>({reply(text){var _a4;setLocalComment({...comment,text,attachments:[]}),(_a4=inputRef.current)==null||_a4.inputElement.focus()}}));const handleSave=__name(()=>{var _a4;localComment.text&&(onSave==null||onSave({...localComment,text:localComment.text}),setEditing(!1),setLocalComment({text:void 0}),(_a4=inputRef.current)==null||_a4.inputElement.blur())},"handleSave");return React.createElement("div",{className:styles$2.threadCommentEditor,onClick:__name(e=>e.preventDefault(),"onClick")},React.createElement(design.Mentions,{ref:inputRef,autoFocus,style:{width:"100%"},placeholder:localeService.t("threadCommentUI.editor.placeholder"),value:localComment!=null&&localComment.text?transformTextNode2Text(transformDocument2TextNodes(localComment.text)):"",onChange:__name(e=>{e.target.value||setLocalComment({...comment,text:void 0}),setLocalComment==null||setLocalComment({...comment,text:transformTextNodes2Document(parseMentions(e.target.value))})},"onChange"),onFocus:__name(()=>{const activeRange=docSelectionManagerService.getActiveTextRange();activeRange&&activeRange.collapsed&&(docSelectionRenderService==null||docSelectionRenderService.removeAllRanges()),docSelectionRenderService==null||docSelectionRenderService.blur(),setEditing(!0)},"onFocus")},React.createElement(design.Mention,{key:mentionDataService.trigger,trigger:mentionDataService.trigger,data:__name((query,callback)=>mentionDataService.getMentions(query,unitId,subUnitId).then(res=>res.map(transformMention)).then(callback),"data"),displayTransform:__name((id2,label)=>`@${label} `,"displayTransform"),renderSuggestion:(_b=mentionDataService.renderSuggestion)!=null?_b:defaultRenderSuggestion})),editing?React.createElement("div",{className:styles$2.threadCommentEditorButtons},React.createElement(design.Button,{style:{marginRight:12},onClick:__name(()=>{onCancel==null||onCancel(),setEditing(!1),setLocalComment({text:void 0}),commandService.executeCommand(SetActiveCommentOperation.id)},"onClick")},localeService.t("threadCommentUI.editor.cancel")),React.createElement(design.Button,{type:"primary",disabled:!localComment.text,onClick:handleSave},localeService.t(id?"threadCommentUI.editor.save":"threadCommentUI.editor.reply"))):null)}),threadComment$1="univer-thread-comment",threadCommentActive="univer-thread-comment-active",threadCommentContent="univer-thread-comment-content",threadCommentHighlight="univer-thread-comment-highlight",threadCommentIconContainer="univer-thread-comment-icon-container",threadCommentIcon="univer-thread-comment-icon",threadCommentTitle="univer-thread-comment-title",threadCommentTitlePosition="univer-thread-comment-title-position",threadCommentTitleHighlight="univer-thread-comment-title-highlight",threadCommentTitlePositionText="univer-thread-comment-title-position-text",threadCommentUsername="univer-thread-comment-username",threadCommentItem="univer-thread-comment-item",threadCommentItemHead="univer-thread-comment-item-head",threadCommentItemTitle="univer-thread-comment-item-title",threadCommentItemTitlePosition="univer-thread-comment-item-title-position",threadCommentItemTitleHighlight="univer-thread-comment-item-title-highlight",threadCommentItemTime="univer-thread-comment-item-time",threadCommentItemContent="univer-thread-comment-item-content",threadCommentItemAt="univer-thread-comment-item-at",styles$1={threadComment:threadComment$1,threadCommentActive,threadCommentContent,threadCommentHighlight,threadCommentIconContainer,threadCommentIcon,threadCommentTitle,threadCommentTitlePosition,threadCommentTitleHighlight,threadCommentTitlePositionText,threadCommentUsername,threadCommentItem,threadCommentItemHead,threadCommentItemTitle,threadCommentItemTitlePosition,threadCommentItemTitleHighlight,threadCommentItemTime,threadCommentItemContent,threadCommentItemAt},MOCK_ID="__mock__",ThreadCommentItem=__name(props=>{const{item,unitId,subUnitId,editing,onEditingChange,onReply,resolved,isRoot,onClose,onDeleteComment}=props,commandService=core.useDependency(core.ICommandService),localeService=core.useDependency(core.LocaleService),userManagerService=core.useDependency(core.UserManagerService),user=userManagerService.getUser(item.personId),currentUser=ui.useObservable(userManagerService.currentUser$),isCommentBySelf=(currentUser==null?void 0:currentUser.userID)===item.personId,isMock=item.id===MOCK_ID,[showReply,setShowReply]=React.useState(!1),handleDeleteItem=__name(()=>{(onDeleteComment==null?void 0:onDeleteComment(item))!==!1&&(commandService.executeCommand(isRoot?threadComment$2.DeleteCommentTreeCommand.id:threadComment$2.DeleteCommentCommand.id,{unitId,subUnitId,commentId:item.id}),isRoot&&(onClose==null||onClose()))},"handleDeleteItem");return React.createElement("div",{className:styles$1.threadCommentItem,onMouseLeave:__name(()=>setShowReply(!1),"onMouseLeave"),onMouseEnter:__name(()=>setShowReply(!0),"onMouseEnter")},React.createElement("img",{className:styles$1.threadCommentItemHead,src:user==null?void 0:user.avatar}),React.createElement("div",{className:styles$1.threadCommentItemTitle},React.createElement("div",{className:styles$1.threadCommentUsername},(user==null?void 0:user.name)||" "),React.createElement("div",null,isMock||resolved?null:showReply?React.createElement("div",{className:styles$1.threadCommentIcon,onClick:__name(()=>onReply(user),"onClick")},React.createElement(ReplyToCommentSingle,null)):null,isCommentBySelf&&!isMock&&!resolved?React.createElement(design.Dropdown,{overlay:React.createElement(design.Menu,null,React.createElement(design.MenuItem,{key:"edit",onClick:__name(()=>onEditingChange==null?void 0:onEditingChange(!0),"onClick")},localeService.t("threadCommentUI.item.edit")),React.createElement(design.MenuItem,{key:"delete",onClick:handleDeleteItem},localeService.t("threadCommentUI.item.delete")))},React.createElement("div",{className:styles$1.threadCommentIcon},React.createElement(MoreHorizontalSingle,null))):null)),React.createElement("div",{className:styles$1.threadCommentItemTime},item.dT),editing?React.createElement(ThreadCommentEditor,{id:item.id,comment:item,onCancel:__name(()=>onEditingChange==null?void 0:onEditingChange(!1),"onCancel"),autoFocus:!0,unitId,subUnitId,onSave:__name(({text,attachments})=>{onEditingChange==null||onEditingChange(!1),commandService.executeCommand(threadComment$2.UpdateCommentCommand.id,{unitId,subUnitId,payload:{commentId:item.id,text,attachments}})},"onSave")}):React.createElement("div",{className:styles$1.threadCommentItemContent},transformDocument2TextNodes(item.text).map((item2,i)=>{switch(item2.type){case"mention":return React.createElement("a",{className:styles$1.threadCommentItemAt,key:i},"@",item2.content.label," ");default:return item2.content}})))},"ThreadCommentItem"),ThreadCommentTree=__name(props=>{var _a3,_b,_c;const{id,unitId,subUnitId,refStr,showEdit=!0,onClick,showHighlight,onClose,getSubUnitName,prefix,autoFocus,onMouseEnter,onMouseLeave,onAddComment,onDeleteComment,onResolve}=props,threadCommentModel=core.useDependency(threadComment$2.ThreadCommentModel),[isHover,setIsHover]=React.useState(!1),[editingId,setEditingId]=React.useState("");ui.useObservable(threadCommentModel.commentMap$);const comments=id?threadCommentModel.getCommentWithChildren(unitId,subUnitId,id):null,commandService=core.useDependency(core.ICommandService),userManagerService=core.useDependency(core.UserManagerService),resolved=comments==null?void 0:comments.root.resolved,currentUser=ui.useObservable(userManagerService.currentUser$),editorRef=React.useRef(null),renderComments=[...comments?[comments.root]:[{id:MOCK_ID,text:{dataStream:`
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"),threadComment$2=require("@univerjs/thread-comment"),ui=require("@univerjs/ui"),rxjs=require("rxjs"),design=require("@univerjs/design"),React=require("react"),docs=require("@univerjs/docs"),docsUi=require("@univerjs/docs-ui"),engineRender=require("@univerjs/engine-render"),threadCommentUi=require("@univerjs/thread-comment-ui");var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}__name(getDefaultExportFromCjs,"getDefaultExportFromCjs");var dayjs_min={exports:{}};(function(module2,exports2){(function(t,e){module2.exports=e()})(commonjsGlobal,function(){var t=1e3,e=6e4,n=36e5,r2="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:__name(function(t2){var e2=["th","st","nd","rd"],n2=t2%100;return"["+t2+(e2[(n2-20)%10]||e2[n2]||e2[0])+"]"},"ordinal")},m=__name(function(t2,e2,n2){var r3=String(t2);return!r3||r3.length>=e2?t2:""+Array(e2+1-r3.length).join(n2)+t2},"m"),v={s:m,z:__name(function(t2){var e2=-t2.utcOffset(),n2=Math.abs(e2),r3=Math.floor(n2/60),i2=n2%60;return(e2<=0?"+":"-")+m(r3,2,"0")+":"+m(i2,2,"0")},"z"),m:__name(function t2(e2,n2){if(e2.date()<n2.date())return-t2(n2,e2);var r3=12*(n2.year()-e2.year())+(n2.month()-e2.month()),i2=e2.clone().add(r3,c),s2=n2-i2<0,u2=e2.clone().add(r3+(s2?-1:1),c);return+(-(r3+(n2-i2)/(s2?i2-u2:u2-i2))||0)},"t"),a:__name(function(t2){return t2<0?Math.ceil(t2)||0:Math.floor(t2)},"a"),p:__name(function(t2){return{M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r2,Q:f}[t2]||String(t2||"").toLowerCase().replace(/s$/,"")},"p"),u:__name(function(t2){return t2===void 0},"u")},g="en",D={};D[g]=M;var p="$isDayjsObject",S=__name(function(t2){return t2 instanceof _||!(!t2||!t2[p])},"S"),w=__name(function t2(e2,n2,r3){var i2;if(!e2)return g;if(typeof e2=="string"){var s2=e2.toLowerCase();D[s2]&&(i2=s2),n2&&(D[s2]=n2,i2=s2);var u2=e2.split("-");if(!i2&&u2.length>1)return t2(u2[0])}else{var a2=e2.name;D[a2]=e2,i2=a2}return!r3&&i2&&(g=i2),i2||!r3&&g},"t"),O=__name(function(t2,e2){if(S(t2))return t2.clone();var n2=typeof e2=="object"?e2:{};return n2.date=t2,n2.args=arguments,new _(n2)},"O"),b=v;b.l=w,b.i=S,b.w=function(t2,e2){return O(t2,{locale:e2.$L,utc:e2.$u,x:e2.$x,$offset:e2.$offset})};var _=function(){function M2(t2){this.$L=w(t2.locale,null,!0),this.parse(t2),this.$x=this.$x||t2.x||{},this[p]=!0}__name(M2,"M");var m2=M2.prototype;return m2.parse=function(t2){this.$d=function(t3){var e2=t3.date,n2=t3.utc;if(e2===null)return new Date(NaN);if(b.u(e2))return new Date;if(e2 instanceof Date)return new Date(e2);if(typeof e2=="string"&&!/Z$/i.test(e2)){var r3=e2.match($);if(r3){var i2=r3[2]-1||0,s2=(r3[7]||"0").substring(0,3);return n2?new Date(Date.UTC(r3[1],i2,r3[3]||1,r3[4]||0,r3[5]||0,r3[6]||0,s2)):new Date(r3[1],i2,r3[3]||1,r3[4]||0,r3[5]||0,r3[6]||0,s2)}}return new Date(e2)}(t2),this.init()},m2.init=function(){var t2=this.$d;this.$y=t2.getFullYear(),this.$M=t2.getMonth(),this.$D=t2.getDate(),this.$W=t2.getDay(),this.$H=t2.getHours(),this.$m=t2.getMinutes(),this.$s=t2.getSeconds(),this.$ms=t2.getMilliseconds()},m2.$utils=function(){return b},m2.isValid=function(){return this.$d.toString()!==l},m2.isSame=function(t2,e2){var n2=O(t2);return this.startOf(e2)<=n2&&n2<=this.endOf(e2)},m2.isAfter=function(t2,e2){return O(t2)<this.startOf(e2)},m2.isBefore=function(t2,e2){return this.endOf(e2)<O(t2)},m2.$g=function(t2,e2,n2){return b.u(t2)?this[e2]:this.set(n2,t2)},m2.unix=function(){return Math.floor(this.valueOf()/1e3)},m2.valueOf=function(){return this.$d.getTime()},m2.startOf=function(t2,e2){var n2=this,r3=!!b.u(e2)||e2,f2=b.p(t2),l2=__name(function(t3,e3){var i2=b.w(n2.$u?Date.UTC(n2.$y,e3,t3):new Date(n2.$y,e3,t3),n2);return r3?i2:i2.endOf(a)},"l"),$2=__name(function(t3,e3){return b.w(n2.toDate()[t3].apply(n2.toDate("s"),(r3?[0,0,0,0]:[23,59,59,999]).slice(e3)),n2)},"$"),y2=this.$W,M3=this.$M,m3=this.$D,v2="set"+(this.$u?"UTC":"");switch(f2){case h:return r3?l2(1,0):l2(31,11);case c:return r3?l2(1,M3):l2(0,M3+1);case o:var g2=this.$locale().weekStart||0,D2=(y2<g2?y2+7:y2)-g2;return l2(r3?m3-D2:m3+(6-D2),M3);case a:case d:return $2(v2+"Hours",0);case u:return $2(v2+"Minutes",1);case s:return $2(v2+"Seconds",2);case i:return $2(v2+"Milliseconds",3);default:return this.clone()}},m2.endOf=function(t2){return this.startOf(t2,!1)},m2.$set=function(t2,e2){var n2,o2=b.p(t2),f2="set"+(this.$u?"UTC":""),l2=(n2={},n2[a]=f2+"Date",n2[d]=f2+"Date",n2[c]=f2+"Month",n2[h]=f2+"FullYear",n2[u]=f2+"Hours",n2[s]=f2+"Minutes",n2[i]=f2+"Seconds",n2[r2]=f2+"Milliseconds",n2)[o2],$2=o2===a?this.$D+(e2-this.$W):e2;if(o2===c||o2===h){var y2=this.clone().set(d,1);y2.$d[l2]($2),y2.init(),this.$d=y2.set(d,Math.min(this.$D,y2.daysInMonth())).$d}else l2&&this.$d[l2]($2);return this.init(),this},m2.set=function(t2,e2){return this.clone().$set(t2,e2)},m2.get=function(t2){return this[b.p(t2)]()},m2.add=function(r3,f2){var d2,l2=this;r3=Number(r3);var $2=b.p(f2),y2=__name(function(t2){var e2=O(l2);return b.w(e2.date(e2.date()+Math.round(t2*r3)),l2)},"y");if($2===c)return this.set(c,this.$M+r3);if($2===h)return this.set(h,this.$y+r3);if($2===a)return y2(1);if($2===o)return y2(7);var M3=(d2={},d2[s]=e,d2[u]=n,d2[i]=t,d2)[$2]||1,m3=this.$d.getTime()+r3*M3;return b.w(m3,this)},m2.subtract=function(t2,e2){return this.add(-1*t2,e2)},m2.format=function(t2){var e2=this,n2=this.$locale();if(!this.isValid())return n2.invalidDate||l;var r3=t2||"YYYY-MM-DDTHH:mm:ssZ",i2=b.z(this),s2=this.$H,u2=this.$m,a2=this.$M,o2=n2.weekdays,c2=n2.months,f2=n2.meridiem,h2=__name(function(t3,n3,i3,s3){return t3&&(t3[n3]||t3(e2,r3))||i3[n3].slice(0,s3)},"h"),d2=__name(function(t3){return b.s(s2%12||12,t3,"0")},"d"),$2=f2||function(t3,e3,n3){var r4=t3<12?"AM":"PM";return n3?r4.toLowerCase():r4};return r3.replace(y,function(t3,r4){return r4||function(t4){switch(t4){case"YY":return String(e2.$y).slice(-2);case"YYYY":return b.s(e2.$y,4,"0");case"M":return a2+1;case"MM":return b.s(a2+1,2,"0");case"MMM":return h2(n2.monthsShort,a2,c2,3);case"MMMM":return h2(c2,a2);case"D":return e2.$D;case"DD":return b.s(e2.$D,2,"0");case"d":return String(e2.$W);case"dd":return h2(n2.weekdaysMin,e2.$W,o2,2);case"ddd":return h2(n2.weekdaysShort,e2.$W,o2,3);case"dddd":return o2[e2.$W];case"H":return String(s2);case"HH":return b.s(s2,2,"0");case"h":return d2(1);case"hh":return d2(2);case"a":return $2(s2,u2,!0);case"A":return $2(s2,u2,!1);case"m":return String(u2);case"mm":return b.s(u2,2,"0");case"s":return String(e2.$s);case"ss":return b.s(e2.$s,2,"0");case"SSS":return b.s(e2.$ms,3,"0");case"Z":return i2}return null}(t3)||i2.replace(":","")})},m2.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m2.diff=function(r3,d2,l2){var $2,y2=this,M3=b.p(d2),m3=O(r3),v2=(m3.utcOffset()-this.utcOffset())*e,g2=this-m3,D2=__name(function(){return b.m(y2,m3)},"D");switch(M3){case h:$2=D2()/12;break;case c:$2=D2();break;case f:$2=D2()/3;break;case o:$2=(g2-v2)/6048e5;break;case a:$2=(g2-v2)/864e5;break;case u:$2=g2/n;break;case s:$2=g2/e;break;case i:$2=g2/t;break;default:$2=g2}return l2?$2:b.a($2)},m2.daysInMonth=function(){return this.endOf(c).$D},m2.$locale=function(){return D[this.$L]},m2.locale=function(t2,e2){if(!t2)return this.$L;var n2=this.clone(),r3=w(t2,e2,!0);return r3&&(n2.$L=r3),n2},m2.clone=function(){return b.w(this.$d,this)},m2.toDate=function(){return new Date(this.valueOf())},m2.toJSON=function(){return this.isValid()?this.toISOString():null},m2.toISOString=function(){return this.$d.toISOString()},m2.toString=function(){return this.$d.toUTCString()},M2}(),k=_.prototype;return O.prototype=k,[["$ms",r2],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach(function(t2){k[t2[1]]=function(e2){return this.$g(e2,t2[0],t2[1])}}),O.extend=function(t2,e2){return t2.$i||(t2(e2,_,O),t2.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t2){return O(1e3*t2)},O.en=D[g],O.Ls=D,O.p={},O})})(dayjs_min);var dayjs_minExports=dayjs_min.exports;const dayjs=getDefaultExportFromCjs(dayjs_minExports);function getDT(){return dayjs().format("YYYY/MM/DD HH:mm")}__name(getDT,"getDT");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"),_a;exports.ThreadCommentPanelService=(_a=class extends core.Disposable{constructor(_sidebarService,_univerInstanceService){super();__publicField(this,"_panelVisible",!1);__publicField(this,"_panelVisible$",new rxjs.BehaviorSubject(!1));__publicField(this,"_activeCommentId");__publicField(this,"_activeCommentId$",new rxjs.BehaviorSubject(void 0));__publicField(this,"panelVisible$",this._panelVisible$.asObservable());__publicField(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=_sidebarService,this._univerInstanceService=_univerInstanceService,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(opt=>{opt.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET).pipe(rxjs.filter(sheet=>!sheet)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(visible){this._panelVisible=visible,this._panelVisible$.next(visible)}setActiveComment(commentInfo){this._activeCommentId=commentInfo,this._activeCommentId$.next(commentInfo)}},__name(_a,"ThreadCommentPanelService"),_a);exports.ThreadCommentPanelService=__decorateClass$1([__decorateParam$1(0,core.Inject(ui.ISidebarService)),__decorateParam$1(1,core.IUniverInstanceService)],exports.ThreadCommentPanelService);const THREAD_COMMENT_PANEL="thread-comment-panel",PLUGIN_NAME="UNIVER_THREAD_COMMENT_UI_PLUGIN",ToggleSheetCommentPanelOperation={id:"thread-comment-ui.operation.toggle-panel",type:core.CommandType.OPERATION,handler(accessor){const sidebarService=accessor.get(ui.ISidebarService),panelService=accessor.get(exports.ThreadCommentPanelService);return panelService.panelVisible?(sidebarService.close(),panelService.setPanelVisible(!1)):(sidebarService.open({header:{title:"threadCommentUI.panel.title"},children:{label:THREAD_COMMENT_PANEL},width:330}),panelService.setPanelVisible(!0)),!0}},SetActiveCommentOperation={id:"thread-comment-ui.operation.set-active-comment",type:core.CommandType.OPERATION,handler(accessor,params){return accessor.get(exports.ThreadCommentPanelService).setActiveComment(params),!0}},PLUGIN_CONFIG_KEY="thread-comment-ui.config",defaultPluginConfig={},_ThreadCommentMentionDataService=class _ThreadCommentMentionDataService{constructor(){__publicField(this,"dataSource");__publicField(this,"renderSuggestion");__publicField(this,"trigger","@")}async getMentions(search,unitId,subUnitId){return this.dataSource?this.dataSource.getMentions(search,unitId,subUnitId):[]}};__name(_ThreadCommentMentionDataService,"ThreadCommentMentionDataService");let ThreadCommentMentionDataService=_ThreadCommentMentionDataService;const IThreadCommentMentionDataService=core.createIdentifier("thread-comment.mention-data.service");var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__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"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField"),_a2;exports.UniverThreadCommentUIPlugin=(_a2=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_commandService,_configService){super(),this._config=_config,this._injector=_injector,this._commandService=_commandService,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){var _a3;core.mergeOverrideWithDependencies([[exports.ThreadCommentPanelService],[IThreadCommentMentionDataService,{useClass:ThreadCommentMentionDataService}]],(_a3=this._config)==null?void 0:_a3.overrides).forEach(dep=>{this._injector.add(dep)}),[ToggleSheetCommentPanelOperation,SetActiveCommentOperation].forEach(command=>{this._commandService.registerCommand(command)})}},__name(_a2,"UniverThreadCommentUIPlugin"),_a2);__publicField2(exports.UniverThreadCommentUIPlugin,"pluginName",PLUGIN_NAME);__publicField2(exports.UniverThreadCommentUIPlugin,"type",core.UniverInstanceType.UNIVER_UNKNOWN);exports.UniverThreadCommentUIPlugin=__decorateClass([core.DependentOn(threadComment$2.UniverThreadCommentPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.ICommandService),__decorateParam(3,core.IConfigService)],exports.UniverThreadCommentUIPlugin);var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=React.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=React.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return React.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a3){var key=_a3[0],value=_a3[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a3,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a3=node.children)===null||_a3===void 0)&&_a3.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid");IconBase.displayName="UniverIcon";var element$5={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},DeleteSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"delete-single",ref,icon:element$5}))});DeleteSingle.displayName="DeleteSingle";var element$4={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},IncreaseSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"increase-single",ref,icon:element$4}))});IncreaseSingle.displayName="IncreaseSingle";var element$3={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z"}}]},MoreHorizontalSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"more-horizontal-single",ref,icon:element$3}))});MoreHorizontalSingle.displayName="MoreHorizontalSingle";var element$2={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},ReplyToCommentSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"reply-to-comment-single",ref,icon:element$2}))});ReplyToCommentSingle.displayName="ReplyToCommentSingle";var element$1={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ResolvedSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"resolved-single",ref,icon:element$1}))});ResolvedSingle.displayName="ResolvedSingle";var element={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},SolveSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"solve-single",ref,icon:element}))});SolveSingle.displayName="SolveSingle";function r(e){var t,f,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}__name(r,"r");function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}__name(clsx,"clsx");const threadCommentEditorButtons="univer-thread-comment-editor-buttons",threadCommentEditorSuggestion="univer-thread-comment-editor-suggestion",threadCommentEditorSuggestionActive="univer-thread-comment-editor-suggestionActive",threadCommentEditorSuggestionIcon="univer-thread-comment-editor-suggestion-icon",styles$2={threadCommentEditorButtons,threadCommentEditorSuggestion,threadCommentEditorSuggestionActive,threadCommentEditorSuggestionIcon},parseMentions=__name(text=>{const regex=/@\[(.*?)\]\((.*?)\)|(\w+)/g;let match,lastIndex=0;const result=[];for(;(match=regex.exec(text))!==null;)match.index>lastIndex&&result.push({type:"text",content:text.substring(lastIndex,match.index)}),match[1]&&match[2]?result.push({type:"mention",content:{label:match[1],id:match[2]}}):match[3]&&result.push({type:"text",content:match[3]}),lastIndex=regex.lastIndex;return lastIndex<text.length&&result.push({type:"text",content:text.substring(lastIndex)}),result},"parseMentions"),transformTextNode2Text=__name(nodes=>nodes.map(item=>{switch(item.type){case"mention":return`@[${item.content.label}](${item.content.id})`;default:return item.content}}).join(""),"transformTextNode2Text"),transformDocument2TextNodes=__name(doc=>{const{dataStream,customRanges}=doc,end=dataStream.length-2,textNodes=[];let lastIndex=0;return customRanges==null||customRanges.forEach(range=>{lastIndex<range.startIndex&&textNodes.push({type:"text",content:dataStream.slice(lastIndex,range.startIndex)}),textNodes.push({type:"mention",content:{label:dataStream.slice(range.startIndex,range.endIndex).slice(1,-1),id:range.rangeId}}),lastIndex=range.endIndex}),textNodes.push({type:"text",content:dataStream.slice(lastIndex,end)}),textNodes},"transformDocument2TextNodes"),transformTextNodes2Document=__name(nodes=>{let str="";const customRanges=[];return nodes.forEach(node=>{switch(node.type){case"text":str+=node.content;break;case"mention":{const start=str.length;str+=`${node.content.label}`;const end=str.length;customRanges.push({rangeId:node.content.id,rangeType:core.CustomRangeType.MENTION,startIndex:start,endIndex:end});break}}}),str+=`
2
+ \r`,{textRuns:[],paragraphs:[{startIndex:str.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:str.length-1}],dataStream:str,customRanges}},"transformTextNodes2Document"),transformMention=__name(mention=>({display:mention.label,id:`${mention.id}`,raw:mention}),"transformMention"),defaultRenderSuggestion=__name((mention,search,highlightedDisplay,index,focused)=>{var _a3,_b;const icon=(_a3=mention.raw)==null?void 0:_a3.icon;return React.createElement("div",{className:styles$2.threadCommentEditorSuggestion},icon?React.createElement("img",{className:styles$2.threadCommentEditorSuggestionIcon,src:icon}):null,React.createElement("div",null,(_b=mention.display)!=null?_b:mention.id))},"defaultRenderSuggestion"),ThreadCommentEditor=React.forwardRef((props,ref)=>{var _a3,_b;const{comment,onSave,id,onCancel,autoFocus,unitId,subUnitId}=props,mentionDataService=core.useDependency(threadCommentUi.IThreadCommentMentionDataService),commandService=core.useDependency(core.ICommandService),localeService=core.useDependency(core.LocaleService),[localComment,setLocalComment]=React.useState({...comment}),[editing,setEditing]=React.useState(!1),inputRef=React.useRef(null),docSelectionManagerService=core.useDependency(docs.DocSelectionManagerService),docSelectionRenderService=(_a3=core.useDependency(engineRender.IRenderManagerService).getCurrentTypeOfRenderer(core.UniverInstanceType.UNIVER_DOC))==null?void 0:_a3.with(docsUi.DocSelectionRenderService);React.useImperativeHandle(ref,()=>({reply(text){var _a4;setLocalComment({...comment,text,attachments:[]}),(_a4=inputRef.current)==null||_a4.inputElement.focus()}}));const handleSave=__name(()=>{var _a4;localComment.text&&(onSave==null||onSave({...localComment,text:localComment.text}),setEditing(!1),setLocalComment({text:void 0}),(_a4=inputRef.current)==null||_a4.inputElement.blur())},"handleSave");return React.createElement("div",{className:styles$2.threadCommentEditor,onClick:__name(e=>e.preventDefault(),"onClick")},React.createElement(design.Mentions,{ref:inputRef,autoFocus,style:{width:"100%"},placeholder:localeService.t("threadCommentUI.editor.placeholder"),value:localComment!=null&&localComment.text?transformTextNode2Text(transformDocument2TextNodes(localComment.text)):"",onChange:__name(e=>{e.target.value||setLocalComment({...comment,text:void 0}),setLocalComment==null||setLocalComment({...comment,text:transformTextNodes2Document(parseMentions(e.target.value))})},"onChange"),onFocus:__name(()=>{const activeRange=docSelectionManagerService.getActiveTextRange();activeRange&&activeRange.collapsed&&(docSelectionRenderService==null||docSelectionRenderService.removeAllRanges()),docSelectionRenderService==null||docSelectionRenderService.blur(),setEditing(!0)},"onFocus")},React.createElement(design.Mention,{key:mentionDataService.trigger,trigger:mentionDataService.trigger,data:__name((query,callback)=>mentionDataService.getMentions(query,unitId,subUnitId).then(res=>res.map(transformMention)).then(callback),"data"),displayTransform:__name((id2,label)=>`@${label} `,"displayTransform"),renderSuggestion:(_b=mentionDataService.renderSuggestion)!=null?_b:defaultRenderSuggestion})),editing?React.createElement("div",{className:styles$2.threadCommentEditorButtons},React.createElement(design.Button,{style:{marginRight:12},onClick:__name(()=>{onCancel==null||onCancel(),setEditing(!1),setLocalComment({text:void 0}),commandService.executeCommand(SetActiveCommentOperation.id)},"onClick")},localeService.t("threadCommentUI.editor.cancel")),React.createElement(design.Button,{type:"primary",disabled:!localComment.text,onClick:handleSave},localeService.t(id?"threadCommentUI.editor.save":"threadCommentUI.editor.reply"))):null)}),threadComment$1="univer-thread-comment",threadCommentActive="univer-thread-comment-active",threadCommentContent="univer-thread-comment-content",threadCommentHighlight="univer-thread-comment-highlight",threadCommentIconContainer="univer-thread-comment-icon-container",threadCommentIcon="univer-thread-comment-icon",threadCommentTitle="univer-thread-comment-title",threadCommentTitlePosition="univer-thread-comment-title-position",threadCommentTitleHighlight="univer-thread-comment-title-highlight",threadCommentTitlePositionText="univer-thread-comment-title-position-text",threadCommentUsername="univer-thread-comment-username",threadCommentItem="univer-thread-comment-item",threadCommentItemHead="univer-thread-comment-item-head",threadCommentItemTitle="univer-thread-comment-item-title",threadCommentItemTitlePosition="univer-thread-comment-item-title-position",threadCommentItemTitleHighlight="univer-thread-comment-item-title-highlight",threadCommentItemTime="univer-thread-comment-item-time",threadCommentItemContent="univer-thread-comment-item-content",threadCommentItemAt="univer-thread-comment-item-at",styles$1={threadComment:threadComment$1,threadCommentActive,threadCommentContent,threadCommentHighlight,threadCommentIconContainer,threadCommentIcon,threadCommentTitle,threadCommentTitlePosition,threadCommentTitleHighlight,threadCommentTitlePositionText,threadCommentUsername,threadCommentItem,threadCommentItemHead,threadCommentItemTitle,threadCommentItemTitlePosition,threadCommentItemTitleHighlight,threadCommentItemTime,threadCommentItemContent,threadCommentItemAt},MOCK_ID="__mock__",ThreadCommentItem=__name(props=>{const{item,unitId,subUnitId,editing,onEditingChange,onReply,resolved,isRoot,onClose,onDeleteComment}=props,commandService=core.useDependency(core.ICommandService),localeService=core.useDependency(core.LocaleService),userManagerService=core.useDependency(core.UserManagerService),user=userManagerService.getUser(item.personId),currentUser=ui.useObservable(userManagerService.currentUser$),isCommentBySelf=(currentUser==null?void 0:currentUser.userID)===item.personId,isMock=item.id===MOCK_ID,[showReply,setShowReply]=React.useState(!1),handleDeleteItem=__name(()=>{(onDeleteComment==null?void 0:onDeleteComment(item))!==!1&&(commandService.executeCommand(isRoot?threadComment$2.DeleteCommentTreeCommand.id:threadComment$2.DeleteCommentCommand.id,{unitId,subUnitId,commentId:item.id}),isRoot&&(onClose==null||onClose()))},"handleDeleteItem");return React.createElement("div",{className:styles$1.threadCommentItem,onMouseLeave:__name(()=>setShowReply(!1),"onMouseLeave"),onMouseEnter:__name(()=>setShowReply(!0),"onMouseEnter")},React.createElement("img",{className:styles$1.threadCommentItemHead,src:user==null?void 0:user.avatar}),React.createElement("div",{className:styles$1.threadCommentItemTitle},React.createElement("div",{className:styles$1.threadCommentUsername},(user==null?void 0:user.name)||" "),React.createElement("div",null,isMock||resolved?null:showReply?React.createElement("div",{className:styles$1.threadCommentIcon,onClick:__name(()=>onReply(user),"onClick")},React.createElement(ReplyToCommentSingle,null)):null,isCommentBySelf&&!isMock&&!resolved?React.createElement(design.Dropdown,{overlay:React.createElement(design.Menu,null,React.createElement(design.MenuItem,{key:"edit",onClick:__name(()=>onEditingChange==null?void 0:onEditingChange(!0),"onClick")},localeService.t("threadCommentUI.item.edit")),React.createElement(design.MenuItem,{key:"delete",onClick:handleDeleteItem},localeService.t("threadCommentUI.item.delete")))},React.createElement("div",{className:styles$1.threadCommentIcon},React.createElement(MoreHorizontalSingle,null))):null)),React.createElement("div",{className:styles$1.threadCommentItemTime},item.dT),editing?React.createElement(ThreadCommentEditor,{id:item.id,comment:item,onCancel:__name(()=>onEditingChange==null?void 0:onEditingChange(!1),"onCancel"),autoFocus:!0,unitId,subUnitId,onSave:__name(({text,attachments})=>{onEditingChange==null||onEditingChange(!1),commandService.executeCommand(threadComment$2.UpdateCommentCommand.id,{unitId,subUnitId,payload:{commentId:item.id,text,attachments}})},"onSave")}):React.createElement("div",{className:styles$1.threadCommentItemContent},transformDocument2TextNodes(item.text).map((item2,i)=>{switch(item2.type){case"mention":return React.createElement("a",{className:styles$1.threadCommentItemAt,key:i},"@",item2.content.label," ");default:return item2.content}})))},"ThreadCommentItem"),ThreadCommentTree=__name(props=>{var _a3,_b,_c;const{id,unitId,subUnitId,refStr,showEdit=!0,onClick,showHighlight,onClose,getSubUnitName,prefix,autoFocus,onMouseEnter,onMouseLeave,onAddComment,onDeleteComment,onResolve}=props,threadCommentModel=core.useDependency(threadComment$2.ThreadCommentModel),[isHover,setIsHover]=React.useState(!1),[editingId,setEditingId]=React.useState("");ui.useObservable(threadCommentModel.commentMap$);const comments=id?threadCommentModel.getCommentWithChildren(unitId,subUnitId,id):null,commandService=core.useDependency(core.ICommandService),userManagerService=core.useDependency(core.UserManagerService),resolved=comments==null?void 0:comments.root.resolved,currentUser=ui.useObservable(userManagerService.currentUser$),editorRef=React.useRef(null),renderComments=[...comments?[comments.root]:[{id:MOCK_ID,text:{dataStream:`
3
3
  \r`},personId:(_a3=currentUser==null?void 0:currentUser.userID)!=null?_a3:"",ref:refStr!=null?refStr:"",dT:"",unitId,subUnitId,threadId:""}],...(_b=comments==null?void 0:comments.children)!=null?_b:[]],scroller=React.useRef(null),handleResolve=__name(e=>{e.stopPropagation(),resolved?commandService.executeCommand(SetActiveCommentOperation.id,{unitId,subUnitId,commentId:id}):commandService.executeCommand(SetActiveCommentOperation.id),commandService.executeCommand(threadComment$2.ResolveCommentCommand.id,{unitId,subUnitId,commentId:id,resolved:!resolved}),onResolve==null||onResolve(!resolved)},"handleResolve"),handleDeleteRoot=__name(e=>{e.stopPropagation(),commandService.executeCommand(SetActiveCommentOperation.id),!(comments!=null&&comments.root&&(onDeleteComment==null?void 0:onDeleteComment(comments.root))===!1)&&(commandService.executeCommand(threadComment$2.DeleteCommentTreeCommand.id,{unitId,subUnitId,commentId:id}),onClose==null||onClose())},"handleDeleteRoot");React.useEffect(()=>onMouseLeave==null?void 0:onMouseLeave(),[]);const subUnitName=getSubUnitName((_c=comments==null?void 0:comments.root.subUnitId)!=null?_c:subUnitId),editorVisible=showEdit&&!editingId&&!resolved,title=`${refStr||(comments==null?void 0:comments.root.ref)||""}${subUnitName?" · ":""}${subUnitName}`;return React.createElement("div",{className:clsx(styles$1.threadComment,{[styles$1.threadCommentActive]:!resolved&&(showHighlight||isHover||prefix==="cell")}),onClick,id:`${prefix}-${unitId}-${subUnitId}-${id}`,onMouseEnter:__name(()=>{onMouseEnter==null||onMouseEnter(),setIsHover(!0)},"onMouseEnter"),onMouseLeave:__name(()=>{onMouseLeave==null||onMouseLeave(),setIsHover(!1)},"onMouseLeave")},!resolved&&showHighlight?React.createElement("div",{className:styles$1.threadCommentHighlight}):null,React.createElement("div",{className:styles$1.threadCommentTitle},React.createElement("div",{className:styles$1.threadCommentTitlePosition},React.createElement("div",{className:styles$1.threadCommentTitleHighlight}),React.createElement(design.Tooltip,{showIfEllipsis:!0,title},React.createElement("div",{className:styles$1.threadCommentTitlePositionText},title))),comments?React.createElement("div",{className:styles$1.threadCommentIconContainer},React.createElement("div",{onClick:handleResolve,className:styles$1.threadCommentIcon,style:{color:resolved?"rgb(var(--green-500))":""}},resolved?React.createElement(ResolvedSingle,null):React.createElement(SolveSingle,null)),(currentUser==null?void 0:currentUser.userID)===comments.root.personId?React.createElement("div",{className:styles$1.threadCommentIcon,onClick:handleDeleteRoot},React.createElement(DeleteSingle,null)):null):null),React.createElement("div",{className:styles$1.threadCommentContent,ref:scroller},renderComments.map(item=>React.createElement(ThreadCommentItem,{onClose,unitId,subUnitId,item,key:item.id,isRoot:item.id===(comments==null?void 0:comments.root.id),editing:editingId===item.id,resolved:comments==null?void 0:comments.root.resolved,onEditingChange:__name(editing=>{setEditingId(editing?item.id:"")},"onEditingChange"),onReply:__name(user=>{user&&requestAnimationFrame(()=>{var _a4;(_a4=editorRef.current)==null||_a4.reply(transformTextNodes2Document([{type:"mention",content:{id:user.userID,label:user.name}}]))})},"onReply"),onAddComment,onDeleteComment}))),editorVisible?React.createElement("div",null,React.createElement(ThreadCommentEditor,{key:`${autoFocus}`,ref:editorRef,unitId,subUnitId,onSave:__name(async({text,attachments})=>{const comment={text,attachments,dT:getDT(),id:core.generateRandomId(),ref:refStr,personId:currentUser==null?void 0:currentUser.userID,parentId:comments==null?void 0:comments.root.id,unitId,subUnitId,threadId:comments==null?void 0:comments.root.threadId};(onAddComment==null?void 0:onAddComment(comment))!==!1&&(await commandService.executeCommand(threadComment$2.AddCommentCommand.id,{unitId,subUnitId,comment}),scroller.current&&(scroller.current.scrollTop=scroller.current.scrollHeight))},"onSave"),autoFocus:autoFocus||!comments,onCancel:__name(()=>{comments||onClose==null||onClose()},"onCancel")})):null)},"ThreadCommentTree"),threadCommentPanel="univer-thread-comment-panel",threadComment="univer-thread-comment",threadCommentPanelForms="univer-thread-comment-panel-forms",select="univer-select",threadCommentPanelEmpty="univer-thread-comment-panel-empty",threadCommentPanelAdd="univer-thread-comment-panel-add",threadCommentPanelSolved="univer-thread-comment-panel-solved",styles={threadCommentPanel,threadComment,threadCommentPanelForms,select,threadCommentPanelEmpty,threadCommentPanelAdd,threadCommentPanelSolved},ThreadCommentPanel=__name(props=>{const{unitId,subUnitId$,type,onAdd,getSubUnitName,onResolve,sortComments,onItemLeave,onItemEnter,disableAdd,tempComment,onAddComment,onDeleteComment,showComments}=props,[unit,setUnit]=React.useState("all"),[status,setStatus]=React.useState("all"),localeService=core.useDependency(core.LocaleService),userService=core.useDependency(core.UserManagerService),threadCommentModel=core.useDependency(threadComment$2.ThreadCommentModel),[unitComments,setUnitComments]=React.useState(()=>threadCommentModel.getUnit(unitId)),panelService=core.useDependency(exports.ThreadCommentPanelService),activeCommentId=ui.useObservable(panelService.activeCommentId$),update=ui.useObservable(threadCommentModel.commentUpdate$),commandService=core.useDependency(core.ICommandService),subUnitId=ui.useObservable(subUnitId$),shouldScroll=React.useRef(!0),prefix="panel",currentUser=ui.useObservable(userService.currentUser$),comments=React.useMemo(()=>{var _a3,_b;const allComments=(unit==="all"?unitComments.map(i=>i[1]).flat():(_b=(_a3=unitComments.find(i=>i[0]===subUnitId))==null?void 0:_a3[1])!=null?_b:[]).filter(i=>!i.parentId),sort=sortComments!=null?sortComments:a=>a,res=allComments;if(showComments){const map=new Map;return res.forEach(comment=>{map.set(comment.id,comment)}),[...showComments,""].map(id=>map.get(id)).filter(Boolean)}else return sort(res)},[showComments,unit,unitComments,sortComments,subUnitId]),commentsSorted=React.useMemo(()=>[...comments.filter(comment=>!comment.resolved),...comments.filter(comment=>comment.resolved)],[comments]),statuedComments=React.useMemo(()=>status==="resolved"?commentsSorted.filter(comment=>comment.resolved):status==="unsolved"?commentsSorted.filter(comment=>!comment.resolved):status==="concern_me"&&currentUser!=null&&currentUser.userID?commentsSorted.map(comment=>threadCommentModel.getCommentWithChildren(comment.unitId,comment.subUnitId,comment.id)).map(comment=>comment!=null&&comment.relativeUsers.has(currentUser.userID)?comment.root:null).filter(Boolean):commentsSorted,[commentsSorted,currentUser==null?void 0:currentUser.userID,status,threadCommentModel]),renderComments=tempComment?[tempComment,...statuedComments]:statuedComments,unSolvedComments=renderComments.filter(comment=>!comment.resolved),solvedComments=renderComments.filter(comment=>comment.resolved),isFiltering=status!=="all"||unit!=="all",onReset=__name(()=>{setStatus("all"),setUnit("all")},"onReset");React.useEffect(()=>{unitId&&setUnitComments(threadCommentModel.getUnit(unitId))},[unitId,threadCommentModel,update]),React.useEffect(()=>{var _a3;if(!activeCommentId)return;if(!shouldScroll.current){shouldScroll.current=!0;return}const{unitId:unitId2,subUnitId:subUnitId2,commentId}=activeCommentId,id=`${prefix}-${unitId2}-${subUnitId2}-${commentId}`;(_a3=document.getElementById(id))==null||_a3.scrollIntoView({block:"center"})},[activeCommentId]);const renderComment=__name(comment=>React.createElement(ThreadCommentTree,{prefix,getSubUnitName,key:comment.id,id:comment.id,unitId:comment.unitId,subUnitId:comment.subUnitId,refStr:comment.ref,type,showEdit:(activeCommentId==null?void 0:activeCommentId.commentId)===comment.id,showHighlight:(activeCommentId==null?void 0:activeCommentId.commentId)===comment.id,onClick:__name(()=>{shouldScroll.current=!1,comment.resolved?commandService.executeCommand(SetActiveCommentOperation.id):commandService.executeCommand(SetActiveCommentOperation.id,{unitId:comment.unitId,subUnitId:comment.subUnitId,commentId:comment.id,temp:!1})},"onClick"),onMouseEnter:__name(()=>onItemEnter==null?void 0:onItemEnter(comment),"onMouseEnter"),onMouseLeave:__name(()=>onItemLeave==null?void 0:onItemLeave(comment),"onMouseLeave"),onAddComment,onDeleteComment,onResolve:__name(resolved=>onResolve==null?void 0:onResolve(comment.id,resolved),"onResolve")}),"renderComment");return React.createElement("div",{className:styles.threadCommentPanel},React.createElement("div",{className:styles.threadCommentPanelForms},type===core.UniverInstanceType.UNIVER_SHEET?React.createElement(design.Select,{borderless:!0,value:unit,onChange:__name(e=>setUnit(e),"onChange"),options:[{value:"current",label:localeService.t("threadCommentUI.filter.sheet.current")},{value:"all",label:localeService.t("threadCommentUI.filter.sheet.all")}]}):null,React.createElement(design.Select,{borderless:!0,value:status,onChange:__name(e=>setStatus(e),"onChange"),options:[{value:"all",label:localeService.t("threadCommentUI.filter.status.all")},{value:"resolved",label:localeService.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:localeService.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:localeService.t("threadCommentUI.filter.status.concernMe")}]})),unSolvedComments.map(renderComment),solvedComments.length?React.createElement("div",{className:styles.threadCommentPanelSolved},"已解决"):null,solvedComments.map(renderComment),renderComments.length?null:React.createElement("div",{className:styles.threadCommentPanelEmpty},isFiltering?localeService.t("threadCommentUI.panel.filterEmpty"):localeService.t("threadCommentUI.panel.empty"),isFiltering?React.createElement(design.Button,{onClick:onReset,type:"link"},localeService.t("threadCommentUI.panel.reset")):React.createElement(design.Button,{id:"thread-comment-add",className:styles.threadCommentPanelAdd,type:"primary",onClick:onAdd,disabled:disableAdd},React.createElement(IncreaseSingle,null),localeService.t("threadCommentUI.panel.addComment"))))},"ThreadCommentPanel");exports.IThreadCommentMentionDataService=IThreadCommentMentionDataService;exports.SetActiveCommentOperation=SetActiveCommentOperation;exports.THREAD_COMMENT_PANEL=THREAD_COMMENT_PANEL;exports.ThreadCommentPanel=ThreadCommentPanel;exports.ThreadCommentTree=ThreadCommentTree;exports.ToggleSheetCommentPanelOperation=ToggleSheetCommentPanelOperation;exports.getDT=getDT;
package/lib/es/index.js CHANGED
@@ -2,8 +2,8 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { UniverThreadCommentPlugin, ThreadCommentModel, AddCommentCommand, UpdateCommentCommand, ResolveCommentCommand, DeleteCommentTreeCommand, DeleteCommentCommand } from "@univerjs/thread-comment";
6
5
  import { Inject, Disposable, UniverInstanceType, IUniverInstanceService, CommandType, createIdentifier, DependentOn, Injector, Plugin, mergeOverrideWithDependencies, ICommandService, IConfigService, CustomRangeType, useDependency, LocaleService, UserManagerService, generateRandomId } from "@univerjs/core";
6
+ import { UniverThreadCommentPlugin, ThreadCommentModel, AddCommentCommand, UpdateCommentCommand, ResolveCommentCommand, DeleteCommentTreeCommand, DeleteCommentCommand } from "@univerjs/thread-comment";
7
7
  import { ISidebarService, useObservable } from "@univerjs/ui";
8
8
  import { BehaviorSubject, filter } from "rxjs";
9
9
  import { Mentions, Mention, Button, Tooltip, Dropdown, Menu, MenuItem, Select } from "@univerjs/design";
@@ -11,6 +11,7 @@ import React, { forwardRef, useRef, createElement, useState, useImperativeHandle
11
11
  import { DocSelectionManagerService } from "@univerjs/docs";
12
12
  import { DocSelectionRenderService } from "@univerjs/docs-ui";
13
13
  import { IRenderManagerService } from "@univerjs/engine-render";
14
+ import { IThreadCommentMentionDataService as IThreadCommentMentionDataService$1 } from "@univerjs/thread-comment-ui";
14
15
  var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
15
16
  function getDefaultExportFromCjs(x) {
16
17
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x.default : x;
@@ -299,7 +300,6 @@ function getDT() {
299
300
  return dayjs().format("YYYY/MM/DD HH:mm");
300
301
  }
301
302
  __name(getDT, "getDT");
302
- const THREAD_COMMENT_PANEL = "thread-comment-panel", PLUGIN_NAME = "UNIVER_THREAD_COMMENT_UI_PLUGIN";
303
303
  var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
304
304
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
305
305
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
@@ -346,7 +346,7 @@ ThreadCommentPanelService = __decorateClass$1([
346
346
  __decorateParam$1(0, Inject(ISidebarService)),
347
347
  __decorateParam$1(1, IUniverInstanceService)
348
348
  ], ThreadCommentPanelService);
349
- const ToggleSheetCommentPanelOperation = {
349
+ const THREAD_COMMENT_PANEL = "thread-comment-panel", PLUGIN_NAME = "UNIVER_THREAD_COMMENT_UI_PLUGIN", ToggleSheetCommentPanelOperation = {
350
350
  id: "thread-comment-ui.operation.toggle-panel",
351
351
  type: CommandType.OPERATION,
352
352
  handler(accessor) {
@@ -363,7 +363,7 @@ const ToggleSheetCommentPanelOperation = {
363
363
  handler(accessor, params) {
364
364
  return accessor.get(ThreadCommentPanelService).setActiveComment(params), !0;
365
365
  }
366
- }, _ThreadCommentMentionDataService = class _ThreadCommentMentionDataService {
366
+ }, PLUGIN_CONFIG_KEY = "thread-comment-ui.config", defaultPluginConfig = {}, _ThreadCommentMentionDataService = class _ThreadCommentMentionDataService {
367
367
  constructor() {
368
368
  __publicField(this, "dataSource");
369
369
  __publicField(this, "renderSuggestion");
@@ -375,7 +375,7 @@ const ToggleSheetCommentPanelOperation = {
375
375
  };
376
376
  __name(_ThreadCommentMentionDataService, "ThreadCommentMentionDataService");
377
377
  let ThreadCommentMentionDataService = _ThreadCommentMentionDataService;
378
- const IThreadCommentMentionDataService = createIdentifier("thread-comment.mention-data.service"), PLUGIN_CONFIG_KEY = "thread-comment-ui.config", defaultPluginConfig = {};
378
+ const IThreadCommentMentionDataService = createIdentifier("thread-comment.mention-data.service");
379
379
  var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
380
380
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
381
381
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
@@ -617,7 +617,7 @@ const threadCommentEditorButtons = "univer-thread-comment-editor-buttons", threa
617
617
  return /* @__PURE__ */ React.createElement("div", { className: styles$2.threadCommentEditorSuggestion }, icon ? /* @__PURE__ */ React.createElement("img", { className: styles$2.threadCommentEditorSuggestionIcon, src: icon }) : null, /* @__PURE__ */ React.createElement("div", null, (_b = mention.display) != null ? _b : mention.id));
618
618
  }, "defaultRenderSuggestion"), ThreadCommentEditor = forwardRef((props, ref) => {
619
619
  var _a3, _b;
620
- const { comment, onSave, id, onCancel, autoFocus, unitId, subUnitId } = props, mentionDataService = useDependency(IThreadCommentMentionDataService), commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), [localComment, setLocalComment] = useState({ ...comment }), [editing, setEditing] = useState(!1), inputRef = useRef(null), docSelectionManagerService = useDependency(DocSelectionManagerService), docSelectionRenderService = (_a3 = useDependency(IRenderManagerService).getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a3.with(DocSelectionRenderService);
620
+ const { comment, onSave, id, onCancel, autoFocus, unitId, subUnitId } = props, mentionDataService = useDependency(IThreadCommentMentionDataService$1), commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), [localComment, setLocalComment] = useState({ ...comment }), [editing, setEditing] = useState(!1), inputRef = useRef(null), docSelectionManagerService = useDependency(DocSelectionManagerService), docSelectionRenderService = (_a3 = useDependency(IRenderManagerService).getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a3.with(DocSelectionRenderService);
621
621
  useImperativeHandle(ref, () => ({
622
622
  reply(text) {
623
623
  var _a4;
@@ -1,5 +1,5 @@
1
- import { ICommandService, IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
2
1
  import { IUniverThreadCommentUIConfig } from './controllers/config.schema';
2
+ import { ICommandService, IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
3
3
  export declare class UniverThreadCommentUIPlugin extends Plugin {
4
4
  private readonly _config;
5
5
  protected _injector: Injector;
@@ -1,6 +1,6 @@
1
- import { default as React } from 'react';
2
1
  import { IDocumentBody } from '@univerjs/core';
3
2
  import { IThreadComment } from '@univerjs/thread-comment';
3
+ import { default as React } from 'react';
4
4
  export interface IThreadCommentEditorProps {
5
5
  id?: string;
6
6
  comment?: Pick<IThreadComment, 'attachments' | 'text' | 'mentions'>;
package/lib/umd/index.js CHANGED
@@ -1,3 +1,3 @@
1
- (function(global2,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/thread-comment"),require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("react"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("@univerjs/engine-render")):typeof define=="function"&&define.amd?define(["exports","@univerjs/thread-comment","@univerjs/core","@univerjs/ui","rxjs","@univerjs/design","react","@univerjs/docs","@univerjs/docs-ui","@univerjs/engine-render"],factory):(global2=typeof globalThis<"u"?globalThis:global2||self,factory(global2.UniverThreadCommentUi={},global2.UniverThreadComment,global2.UniverCore,global2.UniverUi,global2.rxjs,global2.UniverDesign,global2.React,global2.UniverDocs,global2.UniverDocsUi,global2.UniverEngineRender))})(this,function(exports2,threadComment$2,core,ui,rxjs,design,React,docs,docsUi,engineRender){"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;var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}__name(getDefaultExportFromCjs,"getDefaultExportFromCjs");var dayjs_min={exports:{}};(function(module2,exports3){(function(t,e){module2.exports=e()})(commonjsGlobal,function(){var t=1e3,e=6e4,n=36e5,r2="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:__name(function(t2){var e2=["th","st","nd","rd"],n2=t2%100;return"["+t2+(e2[(n2-20)%10]||e2[n2]||e2[0])+"]"},"ordinal")},m=__name(function(t2,e2,n2){var r3=String(t2);return!r3||r3.length>=e2?t2:""+Array(e2+1-r3.length).join(n2)+t2},"m"),v={s:m,z:__name(function(t2){var e2=-t2.utcOffset(),n2=Math.abs(e2),r3=Math.floor(n2/60),i2=n2%60;return(e2<=0?"+":"-")+m(r3,2,"0")+":"+m(i2,2,"0")},"z"),m:__name(function t2(e2,n2){if(e2.date()<n2.date())return-t2(n2,e2);var r3=12*(n2.year()-e2.year())+(n2.month()-e2.month()),i2=e2.clone().add(r3,c),s2=n2-i2<0,u2=e2.clone().add(r3+(s2?-1:1),c);return+(-(r3+(n2-i2)/(s2?i2-u2:u2-i2))||0)},"t"),a:__name(function(t2){return t2<0?Math.ceil(t2)||0:Math.floor(t2)},"a"),p:__name(function(t2){return{M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r2,Q:f}[t2]||String(t2||"").toLowerCase().replace(/s$/,"")},"p"),u:__name(function(t2){return t2===void 0},"u")},g="en",D={};D[g]=M;var p="$isDayjsObject",S=__name(function(t2){return t2 instanceof _||!(!t2||!t2[p])},"S"),w=__name(function t2(e2,n2,r3){var i2;if(!e2)return g;if(typeof e2=="string"){var s2=e2.toLowerCase();D[s2]&&(i2=s2),n2&&(D[s2]=n2,i2=s2);var u2=e2.split("-");if(!i2&&u2.length>1)return t2(u2[0])}else{var a2=e2.name;D[a2]=e2,i2=a2}return!r3&&i2&&(g=i2),i2||!r3&&g},"t"),O=__name(function(t2,e2){if(S(t2))return t2.clone();var n2=typeof e2=="object"?e2:{};return n2.date=t2,n2.args=arguments,new _(n2)},"O"),b=v;b.l=w,b.i=S,b.w=function(t2,e2){return O(t2,{locale:e2.$L,utc:e2.$u,x:e2.$x,$offset:e2.$offset})};var _=function(){function M2(t2){this.$L=w(t2.locale,null,!0),this.parse(t2),this.$x=this.$x||t2.x||{},this[p]=!0}__name(M2,"M");var m2=M2.prototype;return m2.parse=function(t2){this.$d=function(t3){var e2=t3.date,n2=t3.utc;if(e2===null)return new Date(NaN);if(b.u(e2))return new Date;if(e2 instanceof Date)return new Date(e2);if(typeof e2=="string"&&!/Z$/i.test(e2)){var r3=e2.match($);if(r3){var i2=r3[2]-1||0,s2=(r3[7]||"0").substring(0,3);return n2?new Date(Date.UTC(r3[1],i2,r3[3]||1,r3[4]||0,r3[5]||0,r3[6]||0,s2)):new Date(r3[1],i2,r3[3]||1,r3[4]||0,r3[5]||0,r3[6]||0,s2)}}return new Date(e2)}(t2),this.init()},m2.init=function(){var t2=this.$d;this.$y=t2.getFullYear(),this.$M=t2.getMonth(),this.$D=t2.getDate(),this.$W=t2.getDay(),this.$H=t2.getHours(),this.$m=t2.getMinutes(),this.$s=t2.getSeconds(),this.$ms=t2.getMilliseconds()},m2.$utils=function(){return b},m2.isValid=function(){return this.$d.toString()!==l},m2.isSame=function(t2,e2){var n2=O(t2);return this.startOf(e2)<=n2&&n2<=this.endOf(e2)},m2.isAfter=function(t2,e2){return O(t2)<this.startOf(e2)},m2.isBefore=function(t2,e2){return this.endOf(e2)<O(t2)},m2.$g=function(t2,e2,n2){return b.u(t2)?this[e2]:this.set(n2,t2)},m2.unix=function(){return Math.floor(this.valueOf()/1e3)},m2.valueOf=function(){return this.$d.getTime()},m2.startOf=function(t2,e2){var n2=this,r3=!!b.u(e2)||e2,f2=b.p(t2),l2=__name(function(t3,e3){var i2=b.w(n2.$u?Date.UTC(n2.$y,e3,t3):new Date(n2.$y,e3,t3),n2);return r3?i2:i2.endOf(a)},"l"),$2=__name(function(t3,e3){return b.w(n2.toDate()[t3].apply(n2.toDate("s"),(r3?[0,0,0,0]:[23,59,59,999]).slice(e3)),n2)},"$"),y2=this.$W,M3=this.$M,m3=this.$D,v2="set"+(this.$u?"UTC":"");switch(f2){case h:return r3?l2(1,0):l2(31,11);case c:return r3?l2(1,M3):l2(0,M3+1);case o:var g2=this.$locale().weekStart||0,D2=(y2<g2?y2+7:y2)-g2;return l2(r3?m3-D2:m3+(6-D2),M3);case a:case d:return $2(v2+"Hours",0);case u:return $2(v2+"Minutes",1);case s:return $2(v2+"Seconds",2);case i:return $2(v2+"Milliseconds",3);default:return this.clone()}},m2.endOf=function(t2){return this.startOf(t2,!1)},m2.$set=function(t2,e2){var n2,o2=b.p(t2),f2="set"+(this.$u?"UTC":""),l2=(n2={},n2[a]=f2+"Date",n2[d]=f2+"Date",n2[c]=f2+"Month",n2[h]=f2+"FullYear",n2[u]=f2+"Hours",n2[s]=f2+"Minutes",n2[i]=f2+"Seconds",n2[r2]=f2+"Milliseconds",n2)[o2],$2=o2===a?this.$D+(e2-this.$W):e2;if(o2===c||o2===h){var y2=this.clone().set(d,1);y2.$d[l2]($2),y2.init(),this.$d=y2.set(d,Math.min(this.$D,y2.daysInMonth())).$d}else l2&&this.$d[l2]($2);return this.init(),this},m2.set=function(t2,e2){return this.clone().$set(t2,e2)},m2.get=function(t2){return this[b.p(t2)]()},m2.add=function(r3,f2){var d2,l2=this;r3=Number(r3);var $2=b.p(f2),y2=__name(function(t2){var e2=O(l2);return b.w(e2.date(e2.date()+Math.round(t2*r3)),l2)},"y");if($2===c)return this.set(c,this.$M+r3);if($2===h)return this.set(h,this.$y+r3);if($2===a)return y2(1);if($2===o)return y2(7);var M3=(d2={},d2[s]=e,d2[u]=n,d2[i]=t,d2)[$2]||1,m3=this.$d.getTime()+r3*M3;return b.w(m3,this)},m2.subtract=function(t2,e2){return this.add(-1*t2,e2)},m2.format=function(t2){var e2=this,n2=this.$locale();if(!this.isValid())return n2.invalidDate||l;var r3=t2||"YYYY-MM-DDTHH:mm:ssZ",i2=b.z(this),s2=this.$H,u2=this.$m,a2=this.$M,o2=n2.weekdays,c2=n2.months,f2=n2.meridiem,h2=__name(function(t3,n3,i3,s3){return t3&&(t3[n3]||t3(e2,r3))||i3[n3].slice(0,s3)},"h"),d2=__name(function(t3){return b.s(s2%12||12,t3,"0")},"d"),$2=f2||function(t3,e3,n3){var r4=t3<12?"AM":"PM";return n3?r4.toLowerCase():r4};return r3.replace(y,function(t3,r4){return r4||function(t4){switch(t4){case"YY":return String(e2.$y).slice(-2);case"YYYY":return b.s(e2.$y,4,"0");case"M":return a2+1;case"MM":return b.s(a2+1,2,"0");case"MMM":return h2(n2.monthsShort,a2,c2,3);case"MMMM":return h2(c2,a2);case"D":return e2.$D;case"DD":return b.s(e2.$D,2,"0");case"d":return String(e2.$W);case"dd":return h2(n2.weekdaysMin,e2.$W,o2,2);case"ddd":return h2(n2.weekdaysShort,e2.$W,o2,3);case"dddd":return o2[e2.$W];case"H":return String(s2);case"HH":return b.s(s2,2,"0");case"h":return d2(1);case"hh":return d2(2);case"a":return $2(s2,u2,!0);case"A":return $2(s2,u2,!1);case"m":return String(u2);case"mm":return b.s(u2,2,"0");case"s":return String(e2.$s);case"ss":return b.s(e2.$s,2,"0");case"SSS":return b.s(e2.$ms,3,"0");case"Z":return i2}return null}(t3)||i2.replace(":","")})},m2.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m2.diff=function(r3,d2,l2){var $2,y2=this,M3=b.p(d2),m3=O(r3),v2=(m3.utcOffset()-this.utcOffset())*e,g2=this-m3,D2=__name(function(){return b.m(y2,m3)},"D");switch(M3){case h:$2=D2()/12;break;case c:$2=D2();break;case f:$2=D2()/3;break;case o:$2=(g2-v2)/6048e5;break;case a:$2=(g2-v2)/864e5;break;case u:$2=g2/n;break;case s:$2=g2/e;break;case i:$2=g2/t;break;default:$2=g2}return l2?$2:b.a($2)},m2.daysInMonth=function(){return this.endOf(c).$D},m2.$locale=function(){return D[this.$L]},m2.locale=function(t2,e2){if(!t2)return this.$L;var n2=this.clone(),r3=w(t2,e2,!0);return r3&&(n2.$L=r3),n2},m2.clone=function(){return b.w(this.$d,this)},m2.toDate=function(){return new Date(this.valueOf())},m2.toJSON=function(){return this.isValid()?this.toISOString():null},m2.toISOString=function(){return this.$d.toISOString()},m2.toString=function(){return this.$d.toUTCString()},M2}(),k=_.prototype;return O.prototype=k,[["$ms",r2],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach(function(t2){k[t2[1]]=function(e2){return this.$g(e2,t2[0],t2[1])}}),O.extend=function(t2,e2){return t2.$i||(t2(e2,_,O),t2.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t2){return O(1e3*t2)},O.en=D[g],O.Ls=D,O.p={},O})})(dayjs_min);var dayjs_minExports=dayjs_min.exports;const dayjs=getDefaultExportFromCjs(dayjs_minExports);function getDT(){return dayjs().format("YYYY/MM/DD HH:mm")}__name(getDT,"getDT");const THREAD_COMMENT_PANEL="thread-comment-panel",PLUGIN_NAME="UNIVER_THREAD_COMMENT_UI_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.ThreadCommentPanelService=(_a=class extends core.Disposable{constructor(_sidebarService,_univerInstanceService){super();__publicField(this,"_panelVisible",!1);__publicField(this,"_panelVisible$",new rxjs.BehaviorSubject(!1));__publicField(this,"_activeCommentId");__publicField(this,"_activeCommentId$",new rxjs.BehaviorSubject(void 0));__publicField(this,"panelVisible$",this._panelVisible$.asObservable());__publicField(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=_sidebarService,this._univerInstanceService=_univerInstanceService,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(opt=>{opt.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET).pipe(rxjs.filter(sheet=>!sheet)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(visible){this._panelVisible=visible,this._panelVisible$.next(visible)}setActiveComment(commentInfo){this._activeCommentId=commentInfo,this._activeCommentId$.next(commentInfo)}},__name(_a,"ThreadCommentPanelService"),_a),exports2.ThreadCommentPanelService=__decorateClass$1([__decorateParam$1(0,core.Inject(ui.ISidebarService)),__decorateParam$1(1,core.IUniverInstanceService)],exports2.ThreadCommentPanelService);const ToggleSheetCommentPanelOperation={id:"thread-comment-ui.operation.toggle-panel",type:core.CommandType.OPERATION,handler(accessor){const sidebarService=accessor.get(ui.ISidebarService),panelService=accessor.get(exports2.ThreadCommentPanelService);return panelService.panelVisible?(sidebarService.close(),panelService.setPanelVisible(!1)):(sidebarService.open({header:{title:"threadCommentUI.panel.title"},children:{label:THREAD_COMMENT_PANEL},width:330}),panelService.setPanelVisible(!0)),!0}},SetActiveCommentOperation={id:"thread-comment-ui.operation.set-active-comment",type:core.CommandType.OPERATION,handler(accessor,params){return accessor.get(exports2.ThreadCommentPanelService).setActiveComment(params),!0}},_ThreadCommentMentionDataService=class _ThreadCommentMentionDataService{constructor(){__publicField(this,"dataSource");__publicField(this,"renderSuggestion");__publicField(this,"trigger","@")}async getMentions(search,unitId,subUnitId){return this.dataSource?this.dataSource.getMentions(search,unitId,subUnitId):[]}};__name(_ThreadCommentMentionDataService,"ThreadCommentMentionDataService");let ThreadCommentMentionDataService=_ThreadCommentMentionDataService;const IThreadCommentMentionDataService=core.createIdentifier("thread-comment.mention-data.service"),PLUGIN_CONFIG_KEY="thread-comment-ui.config",defaultPluginConfig={};var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__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"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField");exports2.UniverThreadCommentUIPlugin=(_b=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_commandService,_configService){super(),this._config=_config,this._injector=_injector,this._commandService=_commandService,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){var _a2;core.mergeOverrideWithDependencies([[exports2.ThreadCommentPanelService],[IThreadCommentMentionDataService,{useClass:ThreadCommentMentionDataService}]],(_a2=this._config)==null?void 0:_a2.overrides).forEach(dep=>{this._injector.add(dep)}),[ToggleSheetCommentPanelOperation,SetActiveCommentOperation].forEach(command=>{this._commandService.registerCommand(command)})}},__name(_b,"UniverThreadCommentUIPlugin"),_b),__publicField2(exports2.UniverThreadCommentUIPlugin,"pluginName",PLUGIN_NAME),__publicField2(exports2.UniverThreadCommentUIPlugin,"type",core.UniverInstanceType.UNIVER_UNKNOWN),exports2.UniverThreadCommentUIPlugin=__decorateClass([core.DependentOn(threadComment$2.UniverThreadCommentPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.ICommandService),__decorateParam(3,core.IConfigService)],exports2.UniverThreadCommentUIPlugin);var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=React.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=React.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return React.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a2){var key=_a2[0],value=_a2[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a2,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a2=node.children)===null||_a2===void 0)&&_a2.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid"),IconBase.displayName="UniverIcon";var element$5={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},DeleteSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"delete-single",ref,icon:element$5}))});DeleteSingle.displayName="DeleteSingle";var element$4={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},IncreaseSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"increase-single",ref,icon:element$4}))});IncreaseSingle.displayName="IncreaseSingle";var element$3={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z"}}]},MoreHorizontalSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"more-horizontal-single",ref,icon:element$3}))});MoreHorizontalSingle.displayName="MoreHorizontalSingle";var element$2={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},ReplyToCommentSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"reply-to-comment-single",ref,icon:element$2}))});ReplyToCommentSingle.displayName="ReplyToCommentSingle";var element$1={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ResolvedSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"resolved-single",ref,icon:element$1}))});ResolvedSingle.displayName="ResolvedSingle";var element={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},SolveSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"solve-single",ref,icon:element}))});SolveSingle.displayName="SolveSingle";function r(e){var t,f,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}__name(r,"r");function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}__name(clsx,"clsx");const styles$2={threadCommentEditorButtons:"univer-thread-comment-editor-buttons",threadCommentEditorSuggestion:"univer-thread-comment-editor-suggestion",threadCommentEditorSuggestionActive:"univer-thread-comment-editor-suggestionActive",threadCommentEditorSuggestionIcon:"univer-thread-comment-editor-suggestion-icon"},parseMentions=__name(text=>{const regex=/@\[(.*?)\]\((.*?)\)|(\w+)/g;let match,lastIndex=0;const result=[];for(;(match=regex.exec(text))!==null;)match.index>lastIndex&&result.push({type:"text",content:text.substring(lastIndex,match.index)}),match[1]&&match[2]?result.push({type:"mention",content:{label:match[1],id:match[2]}}):match[3]&&result.push({type:"text",content:match[3]}),lastIndex=regex.lastIndex;return lastIndex<text.length&&result.push({type:"text",content:text.substring(lastIndex)}),result},"parseMentions"),transformTextNode2Text=__name(nodes=>nodes.map(item=>{switch(item.type){case"mention":return`@[${item.content.label}](${item.content.id})`;default:return item.content}}).join(""),"transformTextNode2Text"),transformDocument2TextNodes=__name(doc=>{const{dataStream,customRanges}=doc,end=dataStream.length-2,textNodes=[];let lastIndex=0;return customRanges==null||customRanges.forEach(range=>{lastIndex<range.startIndex&&textNodes.push({type:"text",content:dataStream.slice(lastIndex,range.startIndex)}),textNodes.push({type:"mention",content:{label:dataStream.slice(range.startIndex,range.endIndex).slice(1,-1),id:range.rangeId}}),lastIndex=range.endIndex}),textNodes.push({type:"text",content:dataStream.slice(lastIndex,end)}),textNodes},"transformDocument2TextNodes"),transformTextNodes2Document=__name(nodes=>{let str="";const customRanges=[];return nodes.forEach(node=>{switch(node.type){case"text":str+=node.content;break;case"mention":{const start=str.length;str+=`${node.content.label}`;const end=str.length;customRanges.push({rangeId:node.content.id,rangeType:core.CustomRangeType.MENTION,startIndex:start,endIndex:end});break}}}),str+=`
2
- \r`,{textRuns:[],paragraphs:[{startIndex:str.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:str.length-1}],dataStream:str,customRanges}},"transformTextNodes2Document"),transformMention=__name(mention=>({display:mention.label,id:`${mention.id}`,raw:mention}),"transformMention"),defaultRenderSuggestion=__name((mention,search,highlightedDisplay,index,focused)=>{var _a2,_b2;const icon=(_a2=mention.raw)==null?void 0:_a2.icon;return React.createElement("div",{className:styles$2.threadCommentEditorSuggestion},icon?React.createElement("img",{className:styles$2.threadCommentEditorSuggestionIcon,src:icon}):null,React.createElement("div",null,(_b2=mention.display)!=null?_b2:mention.id))},"defaultRenderSuggestion"),ThreadCommentEditor=React.forwardRef((props,ref)=>{var _a2,_b2;const{comment,onSave,id,onCancel,autoFocus,unitId,subUnitId}=props,mentionDataService=core.useDependency(IThreadCommentMentionDataService),commandService=core.useDependency(core.ICommandService),localeService=core.useDependency(core.LocaleService),[localComment,setLocalComment]=React.useState({...comment}),[editing,setEditing]=React.useState(!1),inputRef=React.useRef(null),docSelectionManagerService=core.useDependency(docs.DocSelectionManagerService),docSelectionRenderService=(_a2=core.useDependency(engineRender.IRenderManagerService).getCurrentTypeOfRenderer(core.UniverInstanceType.UNIVER_DOC))==null?void 0:_a2.with(docsUi.DocSelectionRenderService);React.useImperativeHandle(ref,()=>({reply(text){var _a3;setLocalComment({...comment,text,attachments:[]}),(_a3=inputRef.current)==null||_a3.inputElement.focus()}}));const handleSave=__name(()=>{var _a3;localComment.text&&(onSave==null||onSave({...localComment,text:localComment.text}),setEditing(!1),setLocalComment({text:void 0}),(_a3=inputRef.current)==null||_a3.inputElement.blur())},"handleSave");return React.createElement("div",{className:styles$2.threadCommentEditor,onClick:__name(e=>e.preventDefault(),"onClick")},React.createElement(design.Mentions,{ref:inputRef,autoFocus,style:{width:"100%"},placeholder:localeService.t("threadCommentUI.editor.placeholder"),value:localComment!=null&&localComment.text?transformTextNode2Text(transformDocument2TextNodes(localComment.text)):"",onChange:__name(e=>{e.target.value||setLocalComment({...comment,text:void 0}),setLocalComment==null||setLocalComment({...comment,text:transformTextNodes2Document(parseMentions(e.target.value))})},"onChange"),onFocus:__name(()=>{const activeRange=docSelectionManagerService.getActiveTextRange();activeRange&&activeRange.collapsed&&(docSelectionRenderService==null||docSelectionRenderService.removeAllRanges()),docSelectionRenderService==null||docSelectionRenderService.blur(),setEditing(!0)},"onFocus")},React.createElement(design.Mention,{key:mentionDataService.trigger,trigger:mentionDataService.trigger,data:__name((query,callback)=>mentionDataService.getMentions(query,unitId,subUnitId).then(res=>res.map(transformMention)).then(callback),"data"),displayTransform:__name((id2,label)=>`@${label} `,"displayTransform"),renderSuggestion:(_b2=mentionDataService.renderSuggestion)!=null?_b2:defaultRenderSuggestion})),editing?React.createElement("div",{className:styles$2.threadCommentEditorButtons},React.createElement(design.Button,{style:{marginRight:12},onClick:__name(()=>{onCancel==null||onCancel(),setEditing(!1),setLocalComment({text:void 0}),commandService.executeCommand(SetActiveCommentOperation.id)},"onClick")},localeService.t("threadCommentUI.editor.cancel")),React.createElement(design.Button,{type:"primary",disabled:!localComment.text,onClick:handleSave},localeService.t(id?"threadCommentUI.editor.save":"threadCommentUI.editor.reply"))):null)}),styles$1={threadComment:"univer-thread-comment",threadCommentActive:"univer-thread-comment-active",threadCommentContent:"univer-thread-comment-content",threadCommentHighlight:"univer-thread-comment-highlight",threadCommentIconContainer:"univer-thread-comment-icon-container",threadCommentIcon:"univer-thread-comment-icon",threadCommentTitle:"univer-thread-comment-title",threadCommentTitlePosition:"univer-thread-comment-title-position",threadCommentTitleHighlight:"univer-thread-comment-title-highlight",threadCommentTitlePositionText:"univer-thread-comment-title-position-text",threadCommentUsername:"univer-thread-comment-username",threadCommentItem:"univer-thread-comment-item",threadCommentItemHead:"univer-thread-comment-item-head",threadCommentItemTitle:"univer-thread-comment-item-title",threadCommentItemTitlePosition:"univer-thread-comment-item-title-position",threadCommentItemTitleHighlight:"univer-thread-comment-item-title-highlight",threadCommentItemTime:"univer-thread-comment-item-time",threadCommentItemContent:"univer-thread-comment-item-content",threadCommentItemAt:"univer-thread-comment-item-at"},MOCK_ID="__mock__",ThreadCommentItem=__name(props=>{const{item,unitId,subUnitId,editing,onEditingChange,onReply,resolved,isRoot,onClose,onDeleteComment}=props,commandService=core.useDependency(core.ICommandService),localeService=core.useDependency(core.LocaleService),userManagerService=core.useDependency(core.UserManagerService),user=userManagerService.getUser(item.personId),currentUser=ui.useObservable(userManagerService.currentUser$),isCommentBySelf=(currentUser==null?void 0:currentUser.userID)===item.personId,isMock=item.id===MOCK_ID,[showReply,setShowReply]=React.useState(!1),handleDeleteItem=__name(()=>{(onDeleteComment==null?void 0:onDeleteComment(item))!==!1&&(commandService.executeCommand(isRoot?threadComment$2.DeleteCommentTreeCommand.id:threadComment$2.DeleteCommentCommand.id,{unitId,subUnitId,commentId:item.id}),isRoot&&(onClose==null||onClose()))},"handleDeleteItem");return React.createElement("div",{className:styles$1.threadCommentItem,onMouseLeave:__name(()=>setShowReply(!1),"onMouseLeave"),onMouseEnter:__name(()=>setShowReply(!0),"onMouseEnter")},React.createElement("img",{className:styles$1.threadCommentItemHead,src:user==null?void 0:user.avatar}),React.createElement("div",{className:styles$1.threadCommentItemTitle},React.createElement("div",{className:styles$1.threadCommentUsername},(user==null?void 0:user.name)||" "),React.createElement("div",null,isMock||resolved?null:showReply?React.createElement("div",{className:styles$1.threadCommentIcon,onClick:__name(()=>onReply(user),"onClick")},React.createElement(ReplyToCommentSingle,null)):null,isCommentBySelf&&!isMock&&!resolved?React.createElement(design.Dropdown,{overlay:React.createElement(design.Menu,null,React.createElement(design.MenuItem,{key:"edit",onClick:__name(()=>onEditingChange==null?void 0:onEditingChange(!0),"onClick")},localeService.t("threadCommentUI.item.edit")),React.createElement(design.MenuItem,{key:"delete",onClick:handleDeleteItem},localeService.t("threadCommentUI.item.delete")))},React.createElement("div",{className:styles$1.threadCommentIcon},React.createElement(MoreHorizontalSingle,null))):null)),React.createElement("div",{className:styles$1.threadCommentItemTime},item.dT),editing?React.createElement(ThreadCommentEditor,{id:item.id,comment:item,onCancel:__name(()=>onEditingChange==null?void 0:onEditingChange(!1),"onCancel"),autoFocus:!0,unitId,subUnitId,onSave:__name(({text,attachments})=>{onEditingChange==null||onEditingChange(!1),commandService.executeCommand(threadComment$2.UpdateCommentCommand.id,{unitId,subUnitId,payload:{commentId:item.id,text,attachments}})},"onSave")}):React.createElement("div",{className:styles$1.threadCommentItemContent},transformDocument2TextNodes(item.text).map((item2,i)=>{switch(item2.type){case"mention":return React.createElement("a",{className:styles$1.threadCommentItemAt,key:i},"@",item2.content.label," ");default:return item2.content}})))},"ThreadCommentItem"),ThreadCommentTree=__name(props=>{var _a2,_b2,_c;const{id,unitId,subUnitId,refStr,showEdit=!0,onClick,showHighlight,onClose,getSubUnitName,prefix,autoFocus,onMouseEnter,onMouseLeave,onAddComment,onDeleteComment,onResolve}=props,threadCommentModel=core.useDependency(threadComment$2.ThreadCommentModel),[isHover,setIsHover]=React.useState(!1),[editingId,setEditingId]=React.useState("");ui.useObservable(threadCommentModel.commentMap$);const comments=id?threadCommentModel.getCommentWithChildren(unitId,subUnitId,id):null,commandService=core.useDependency(core.ICommandService),userManagerService=core.useDependency(core.UserManagerService),resolved=comments==null?void 0:comments.root.resolved,currentUser=ui.useObservable(userManagerService.currentUser$),editorRef=React.useRef(null),renderComments=[...comments?[comments.root]:[{id:MOCK_ID,text:{dataStream:`
1
+ (function(global2,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("react"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("@univerjs/thread-comment-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/thread-comment","@univerjs/ui","rxjs","@univerjs/design","react","@univerjs/docs","@univerjs/docs-ui","@univerjs/engine-render","@univerjs/thread-comment-ui"],factory):(global2=typeof globalThis<"u"?globalThis:global2||self,factory(global2.UniverThreadCommentUi={},global2.UniverCore,global2.UniverThreadComment,global2.UniverUi,global2.rxjs,global2.UniverDesign,global2.React,global2.UniverDocs,global2.UniverDocsUi,global2.UniverEngineRender,global2.UniverThreadCommentUi))})(this,function(exports2,core,threadComment$2,ui,rxjs,design,React,docs,docsUi,engineRender,threadCommentUi){"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;var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}__name(getDefaultExportFromCjs,"getDefaultExportFromCjs");var dayjs_min={exports:{}};(function(module2,exports3){(function(t,e){module2.exports=e()})(commonjsGlobal,function(){var t=1e3,e=6e4,n=36e5,r2="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:__name(function(t2){var e2=["th","st","nd","rd"],n2=t2%100;return"["+t2+(e2[(n2-20)%10]||e2[n2]||e2[0])+"]"},"ordinal")},m=__name(function(t2,e2,n2){var r3=String(t2);return!r3||r3.length>=e2?t2:""+Array(e2+1-r3.length).join(n2)+t2},"m"),v={s:m,z:__name(function(t2){var e2=-t2.utcOffset(),n2=Math.abs(e2),r3=Math.floor(n2/60),i2=n2%60;return(e2<=0?"+":"-")+m(r3,2,"0")+":"+m(i2,2,"0")},"z"),m:__name(function t2(e2,n2){if(e2.date()<n2.date())return-t2(n2,e2);var r3=12*(n2.year()-e2.year())+(n2.month()-e2.month()),i2=e2.clone().add(r3,c),s2=n2-i2<0,u2=e2.clone().add(r3+(s2?-1:1),c);return+(-(r3+(n2-i2)/(s2?i2-u2:u2-i2))||0)},"t"),a:__name(function(t2){return t2<0?Math.ceil(t2)||0:Math.floor(t2)},"a"),p:__name(function(t2){return{M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r2,Q:f}[t2]||String(t2||"").toLowerCase().replace(/s$/,"")},"p"),u:__name(function(t2){return t2===void 0},"u")},g="en",D={};D[g]=M;var p="$isDayjsObject",S=__name(function(t2){return t2 instanceof _||!(!t2||!t2[p])},"S"),w=__name(function t2(e2,n2,r3){var i2;if(!e2)return g;if(typeof e2=="string"){var s2=e2.toLowerCase();D[s2]&&(i2=s2),n2&&(D[s2]=n2,i2=s2);var u2=e2.split("-");if(!i2&&u2.length>1)return t2(u2[0])}else{var a2=e2.name;D[a2]=e2,i2=a2}return!r3&&i2&&(g=i2),i2||!r3&&g},"t"),O=__name(function(t2,e2){if(S(t2))return t2.clone();var n2=typeof e2=="object"?e2:{};return n2.date=t2,n2.args=arguments,new _(n2)},"O"),b=v;b.l=w,b.i=S,b.w=function(t2,e2){return O(t2,{locale:e2.$L,utc:e2.$u,x:e2.$x,$offset:e2.$offset})};var _=function(){function M2(t2){this.$L=w(t2.locale,null,!0),this.parse(t2),this.$x=this.$x||t2.x||{},this[p]=!0}__name(M2,"M");var m2=M2.prototype;return m2.parse=function(t2){this.$d=function(t3){var e2=t3.date,n2=t3.utc;if(e2===null)return new Date(NaN);if(b.u(e2))return new Date;if(e2 instanceof Date)return new Date(e2);if(typeof e2=="string"&&!/Z$/i.test(e2)){var r3=e2.match($);if(r3){var i2=r3[2]-1||0,s2=(r3[7]||"0").substring(0,3);return n2?new Date(Date.UTC(r3[1],i2,r3[3]||1,r3[4]||0,r3[5]||0,r3[6]||0,s2)):new Date(r3[1],i2,r3[3]||1,r3[4]||0,r3[5]||0,r3[6]||0,s2)}}return new Date(e2)}(t2),this.init()},m2.init=function(){var t2=this.$d;this.$y=t2.getFullYear(),this.$M=t2.getMonth(),this.$D=t2.getDate(),this.$W=t2.getDay(),this.$H=t2.getHours(),this.$m=t2.getMinutes(),this.$s=t2.getSeconds(),this.$ms=t2.getMilliseconds()},m2.$utils=function(){return b},m2.isValid=function(){return this.$d.toString()!==l},m2.isSame=function(t2,e2){var n2=O(t2);return this.startOf(e2)<=n2&&n2<=this.endOf(e2)},m2.isAfter=function(t2,e2){return O(t2)<this.startOf(e2)},m2.isBefore=function(t2,e2){return this.endOf(e2)<O(t2)},m2.$g=function(t2,e2,n2){return b.u(t2)?this[e2]:this.set(n2,t2)},m2.unix=function(){return Math.floor(this.valueOf()/1e3)},m2.valueOf=function(){return this.$d.getTime()},m2.startOf=function(t2,e2){var n2=this,r3=!!b.u(e2)||e2,f2=b.p(t2),l2=__name(function(t3,e3){var i2=b.w(n2.$u?Date.UTC(n2.$y,e3,t3):new Date(n2.$y,e3,t3),n2);return r3?i2:i2.endOf(a)},"l"),$2=__name(function(t3,e3){return b.w(n2.toDate()[t3].apply(n2.toDate("s"),(r3?[0,0,0,0]:[23,59,59,999]).slice(e3)),n2)},"$"),y2=this.$W,M3=this.$M,m3=this.$D,v2="set"+(this.$u?"UTC":"");switch(f2){case h:return r3?l2(1,0):l2(31,11);case c:return r3?l2(1,M3):l2(0,M3+1);case o:var g2=this.$locale().weekStart||0,D2=(y2<g2?y2+7:y2)-g2;return l2(r3?m3-D2:m3+(6-D2),M3);case a:case d:return $2(v2+"Hours",0);case u:return $2(v2+"Minutes",1);case s:return $2(v2+"Seconds",2);case i:return $2(v2+"Milliseconds",3);default:return this.clone()}},m2.endOf=function(t2){return this.startOf(t2,!1)},m2.$set=function(t2,e2){var n2,o2=b.p(t2),f2="set"+(this.$u?"UTC":""),l2=(n2={},n2[a]=f2+"Date",n2[d]=f2+"Date",n2[c]=f2+"Month",n2[h]=f2+"FullYear",n2[u]=f2+"Hours",n2[s]=f2+"Minutes",n2[i]=f2+"Seconds",n2[r2]=f2+"Milliseconds",n2)[o2],$2=o2===a?this.$D+(e2-this.$W):e2;if(o2===c||o2===h){var y2=this.clone().set(d,1);y2.$d[l2]($2),y2.init(),this.$d=y2.set(d,Math.min(this.$D,y2.daysInMonth())).$d}else l2&&this.$d[l2]($2);return this.init(),this},m2.set=function(t2,e2){return this.clone().$set(t2,e2)},m2.get=function(t2){return this[b.p(t2)]()},m2.add=function(r3,f2){var d2,l2=this;r3=Number(r3);var $2=b.p(f2),y2=__name(function(t2){var e2=O(l2);return b.w(e2.date(e2.date()+Math.round(t2*r3)),l2)},"y");if($2===c)return this.set(c,this.$M+r3);if($2===h)return this.set(h,this.$y+r3);if($2===a)return y2(1);if($2===o)return y2(7);var M3=(d2={},d2[s]=e,d2[u]=n,d2[i]=t,d2)[$2]||1,m3=this.$d.getTime()+r3*M3;return b.w(m3,this)},m2.subtract=function(t2,e2){return this.add(-1*t2,e2)},m2.format=function(t2){var e2=this,n2=this.$locale();if(!this.isValid())return n2.invalidDate||l;var r3=t2||"YYYY-MM-DDTHH:mm:ssZ",i2=b.z(this),s2=this.$H,u2=this.$m,a2=this.$M,o2=n2.weekdays,c2=n2.months,f2=n2.meridiem,h2=__name(function(t3,n3,i3,s3){return t3&&(t3[n3]||t3(e2,r3))||i3[n3].slice(0,s3)},"h"),d2=__name(function(t3){return b.s(s2%12||12,t3,"0")},"d"),$2=f2||function(t3,e3,n3){var r4=t3<12?"AM":"PM";return n3?r4.toLowerCase():r4};return r3.replace(y,function(t3,r4){return r4||function(t4){switch(t4){case"YY":return String(e2.$y).slice(-2);case"YYYY":return b.s(e2.$y,4,"0");case"M":return a2+1;case"MM":return b.s(a2+1,2,"0");case"MMM":return h2(n2.monthsShort,a2,c2,3);case"MMMM":return h2(c2,a2);case"D":return e2.$D;case"DD":return b.s(e2.$D,2,"0");case"d":return String(e2.$W);case"dd":return h2(n2.weekdaysMin,e2.$W,o2,2);case"ddd":return h2(n2.weekdaysShort,e2.$W,o2,3);case"dddd":return o2[e2.$W];case"H":return String(s2);case"HH":return b.s(s2,2,"0");case"h":return d2(1);case"hh":return d2(2);case"a":return $2(s2,u2,!0);case"A":return $2(s2,u2,!1);case"m":return String(u2);case"mm":return b.s(u2,2,"0");case"s":return String(e2.$s);case"ss":return b.s(e2.$s,2,"0");case"SSS":return b.s(e2.$ms,3,"0");case"Z":return i2}return null}(t3)||i2.replace(":","")})},m2.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m2.diff=function(r3,d2,l2){var $2,y2=this,M3=b.p(d2),m3=O(r3),v2=(m3.utcOffset()-this.utcOffset())*e,g2=this-m3,D2=__name(function(){return b.m(y2,m3)},"D");switch(M3){case h:$2=D2()/12;break;case c:$2=D2();break;case f:$2=D2()/3;break;case o:$2=(g2-v2)/6048e5;break;case a:$2=(g2-v2)/864e5;break;case u:$2=g2/n;break;case s:$2=g2/e;break;case i:$2=g2/t;break;default:$2=g2}return l2?$2:b.a($2)},m2.daysInMonth=function(){return this.endOf(c).$D},m2.$locale=function(){return D[this.$L]},m2.locale=function(t2,e2){if(!t2)return this.$L;var n2=this.clone(),r3=w(t2,e2,!0);return r3&&(n2.$L=r3),n2},m2.clone=function(){return b.w(this.$d,this)},m2.toDate=function(){return new Date(this.valueOf())},m2.toJSON=function(){return this.isValid()?this.toISOString():null},m2.toISOString=function(){return this.$d.toISOString()},m2.toString=function(){return this.$d.toUTCString()},M2}(),k=_.prototype;return O.prototype=k,[["$ms",r2],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach(function(t2){k[t2[1]]=function(e2){return this.$g(e2,t2[0],t2[1])}}),O.extend=function(t2,e2){return t2.$i||(t2(e2,_,O),t2.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t2){return O(1e3*t2)},O.en=D[g],O.Ls=D,O.p={},O})})(dayjs_min);var dayjs_minExports=dayjs_min.exports;const dayjs=getDefaultExportFromCjs(dayjs_minExports);function getDT(){return dayjs().format("YYYY/MM/DD HH:mm")}__name(getDT,"getDT");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.ThreadCommentPanelService=(_a=class extends core.Disposable{constructor(_sidebarService,_univerInstanceService){super();__publicField(this,"_panelVisible",!1);__publicField(this,"_panelVisible$",new rxjs.BehaviorSubject(!1));__publicField(this,"_activeCommentId");__publicField(this,"_activeCommentId$",new rxjs.BehaviorSubject(void 0));__publicField(this,"panelVisible$",this._panelVisible$.asObservable());__publicField(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=_sidebarService,this._univerInstanceService=_univerInstanceService,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(opt=>{opt.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET).pipe(rxjs.filter(sheet=>!sheet)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(visible){this._panelVisible=visible,this._panelVisible$.next(visible)}setActiveComment(commentInfo){this._activeCommentId=commentInfo,this._activeCommentId$.next(commentInfo)}},__name(_a,"ThreadCommentPanelService"),_a),exports2.ThreadCommentPanelService=__decorateClass$1([__decorateParam$1(0,core.Inject(ui.ISidebarService)),__decorateParam$1(1,core.IUniverInstanceService)],exports2.ThreadCommentPanelService);const THREAD_COMMENT_PANEL="thread-comment-panel",PLUGIN_NAME="UNIVER_THREAD_COMMENT_UI_PLUGIN",ToggleSheetCommentPanelOperation={id:"thread-comment-ui.operation.toggle-panel",type:core.CommandType.OPERATION,handler(accessor){const sidebarService=accessor.get(ui.ISidebarService),panelService=accessor.get(exports2.ThreadCommentPanelService);return panelService.panelVisible?(sidebarService.close(),panelService.setPanelVisible(!1)):(sidebarService.open({header:{title:"threadCommentUI.panel.title"},children:{label:THREAD_COMMENT_PANEL},width:330}),panelService.setPanelVisible(!0)),!0}},SetActiveCommentOperation={id:"thread-comment-ui.operation.set-active-comment",type:core.CommandType.OPERATION,handler(accessor,params){return accessor.get(exports2.ThreadCommentPanelService).setActiveComment(params),!0}},PLUGIN_CONFIG_KEY="thread-comment-ui.config",defaultPluginConfig={},_ThreadCommentMentionDataService=class _ThreadCommentMentionDataService{constructor(){__publicField(this,"dataSource");__publicField(this,"renderSuggestion");__publicField(this,"trigger","@")}async getMentions(search,unitId,subUnitId){return this.dataSource?this.dataSource.getMentions(search,unitId,subUnitId):[]}};__name(_ThreadCommentMentionDataService,"ThreadCommentMentionDataService");let ThreadCommentMentionDataService=_ThreadCommentMentionDataService;const IThreadCommentMentionDataService=core.createIdentifier("thread-comment.mention-data.service");var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__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"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField");exports2.UniverThreadCommentUIPlugin=(_b=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_commandService,_configService){super(),this._config=_config,this._injector=_injector,this._commandService=_commandService,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){var _a2;core.mergeOverrideWithDependencies([[exports2.ThreadCommentPanelService],[IThreadCommentMentionDataService,{useClass:ThreadCommentMentionDataService}]],(_a2=this._config)==null?void 0:_a2.overrides).forEach(dep=>{this._injector.add(dep)}),[ToggleSheetCommentPanelOperation,SetActiveCommentOperation].forEach(command=>{this._commandService.registerCommand(command)})}},__name(_b,"UniverThreadCommentUIPlugin"),_b),__publicField2(exports2.UniverThreadCommentUIPlugin,"pluginName",PLUGIN_NAME),__publicField2(exports2.UniverThreadCommentUIPlugin,"type",core.UniverInstanceType.UNIVER_UNKNOWN),exports2.UniverThreadCommentUIPlugin=__decorateClass([core.DependentOn(threadComment$2.UniverThreadCommentPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.ICommandService),__decorateParam(3,core.IConfigService)],exports2.UniverThreadCommentUIPlugin);var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=React.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=React.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return React.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a2){var key=_a2[0],value=_a2[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a2,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a2=node.children)===null||_a2===void 0)&&_a2.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid"),IconBase.displayName="UniverIcon";var element$5={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},DeleteSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"delete-single",ref,icon:element$5}))});DeleteSingle.displayName="DeleteSingle";var element$4={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},IncreaseSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"increase-single",ref,icon:element$4}))});IncreaseSingle.displayName="IncreaseSingle";var element$3={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z"}}]},MoreHorizontalSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"more-horizontal-single",ref,icon:element$3}))});MoreHorizontalSingle.displayName="MoreHorizontalSingle";var element$2={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},ReplyToCommentSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"reply-to-comment-single",ref,icon:element$2}))});ReplyToCommentSingle.displayName="ReplyToCommentSingle";var element$1={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ResolvedSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"resolved-single",ref,icon:element$1}))});ResolvedSingle.displayName="ResolvedSingle";var element={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},SolveSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"solve-single",ref,icon:element}))});SolveSingle.displayName="SolveSingle";function r(e){var t,f,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}__name(r,"r");function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}__name(clsx,"clsx");const styles$2={threadCommentEditorButtons:"univer-thread-comment-editor-buttons",threadCommentEditorSuggestion:"univer-thread-comment-editor-suggestion",threadCommentEditorSuggestionActive:"univer-thread-comment-editor-suggestionActive",threadCommentEditorSuggestionIcon:"univer-thread-comment-editor-suggestion-icon"},parseMentions=__name(text=>{const regex=/@\[(.*?)\]\((.*?)\)|(\w+)/g;let match,lastIndex=0;const result=[];for(;(match=regex.exec(text))!==null;)match.index>lastIndex&&result.push({type:"text",content:text.substring(lastIndex,match.index)}),match[1]&&match[2]?result.push({type:"mention",content:{label:match[1],id:match[2]}}):match[3]&&result.push({type:"text",content:match[3]}),lastIndex=regex.lastIndex;return lastIndex<text.length&&result.push({type:"text",content:text.substring(lastIndex)}),result},"parseMentions"),transformTextNode2Text=__name(nodes=>nodes.map(item=>{switch(item.type){case"mention":return`@[${item.content.label}](${item.content.id})`;default:return item.content}}).join(""),"transformTextNode2Text"),transformDocument2TextNodes=__name(doc=>{const{dataStream,customRanges}=doc,end=dataStream.length-2,textNodes=[];let lastIndex=0;return customRanges==null||customRanges.forEach(range=>{lastIndex<range.startIndex&&textNodes.push({type:"text",content:dataStream.slice(lastIndex,range.startIndex)}),textNodes.push({type:"mention",content:{label:dataStream.slice(range.startIndex,range.endIndex).slice(1,-1),id:range.rangeId}}),lastIndex=range.endIndex}),textNodes.push({type:"text",content:dataStream.slice(lastIndex,end)}),textNodes},"transformDocument2TextNodes"),transformTextNodes2Document=__name(nodes=>{let str="";const customRanges=[];return nodes.forEach(node=>{switch(node.type){case"text":str+=node.content;break;case"mention":{const start=str.length;str+=`${node.content.label}`;const end=str.length;customRanges.push({rangeId:node.content.id,rangeType:core.CustomRangeType.MENTION,startIndex:start,endIndex:end});break}}}),str+=`
2
+ \r`,{textRuns:[],paragraphs:[{startIndex:str.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:str.length-1}],dataStream:str,customRanges}},"transformTextNodes2Document"),transformMention=__name(mention=>({display:mention.label,id:`${mention.id}`,raw:mention}),"transformMention"),defaultRenderSuggestion=__name((mention,search,highlightedDisplay,index,focused)=>{var _a2,_b2;const icon=(_a2=mention.raw)==null?void 0:_a2.icon;return React.createElement("div",{className:styles$2.threadCommentEditorSuggestion},icon?React.createElement("img",{className:styles$2.threadCommentEditorSuggestionIcon,src:icon}):null,React.createElement("div",null,(_b2=mention.display)!=null?_b2:mention.id))},"defaultRenderSuggestion"),ThreadCommentEditor=React.forwardRef((props,ref)=>{var _a2,_b2;const{comment,onSave,id,onCancel,autoFocus,unitId,subUnitId}=props,mentionDataService=core.useDependency(threadCommentUi.IThreadCommentMentionDataService),commandService=core.useDependency(core.ICommandService),localeService=core.useDependency(core.LocaleService),[localComment,setLocalComment]=React.useState({...comment}),[editing,setEditing]=React.useState(!1),inputRef=React.useRef(null),docSelectionManagerService=core.useDependency(docs.DocSelectionManagerService),docSelectionRenderService=(_a2=core.useDependency(engineRender.IRenderManagerService).getCurrentTypeOfRenderer(core.UniverInstanceType.UNIVER_DOC))==null?void 0:_a2.with(docsUi.DocSelectionRenderService);React.useImperativeHandle(ref,()=>({reply(text){var _a3;setLocalComment({...comment,text,attachments:[]}),(_a3=inputRef.current)==null||_a3.inputElement.focus()}}));const handleSave=__name(()=>{var _a3;localComment.text&&(onSave==null||onSave({...localComment,text:localComment.text}),setEditing(!1),setLocalComment({text:void 0}),(_a3=inputRef.current)==null||_a3.inputElement.blur())},"handleSave");return React.createElement("div",{className:styles$2.threadCommentEditor,onClick:__name(e=>e.preventDefault(),"onClick")},React.createElement(design.Mentions,{ref:inputRef,autoFocus,style:{width:"100%"},placeholder:localeService.t("threadCommentUI.editor.placeholder"),value:localComment!=null&&localComment.text?transformTextNode2Text(transformDocument2TextNodes(localComment.text)):"",onChange:__name(e=>{e.target.value||setLocalComment({...comment,text:void 0}),setLocalComment==null||setLocalComment({...comment,text:transformTextNodes2Document(parseMentions(e.target.value))})},"onChange"),onFocus:__name(()=>{const activeRange=docSelectionManagerService.getActiveTextRange();activeRange&&activeRange.collapsed&&(docSelectionRenderService==null||docSelectionRenderService.removeAllRanges()),docSelectionRenderService==null||docSelectionRenderService.blur(),setEditing(!0)},"onFocus")},React.createElement(design.Mention,{key:mentionDataService.trigger,trigger:mentionDataService.trigger,data:__name((query,callback)=>mentionDataService.getMentions(query,unitId,subUnitId).then(res=>res.map(transformMention)).then(callback),"data"),displayTransform:__name((id2,label)=>`@${label} `,"displayTransform"),renderSuggestion:(_b2=mentionDataService.renderSuggestion)!=null?_b2:defaultRenderSuggestion})),editing?React.createElement("div",{className:styles$2.threadCommentEditorButtons},React.createElement(design.Button,{style:{marginRight:12},onClick:__name(()=>{onCancel==null||onCancel(),setEditing(!1),setLocalComment({text:void 0}),commandService.executeCommand(SetActiveCommentOperation.id)},"onClick")},localeService.t("threadCommentUI.editor.cancel")),React.createElement(design.Button,{type:"primary",disabled:!localComment.text,onClick:handleSave},localeService.t(id?"threadCommentUI.editor.save":"threadCommentUI.editor.reply"))):null)}),styles$1={threadComment:"univer-thread-comment",threadCommentActive:"univer-thread-comment-active",threadCommentContent:"univer-thread-comment-content",threadCommentHighlight:"univer-thread-comment-highlight",threadCommentIconContainer:"univer-thread-comment-icon-container",threadCommentIcon:"univer-thread-comment-icon",threadCommentTitle:"univer-thread-comment-title",threadCommentTitlePosition:"univer-thread-comment-title-position",threadCommentTitleHighlight:"univer-thread-comment-title-highlight",threadCommentTitlePositionText:"univer-thread-comment-title-position-text",threadCommentUsername:"univer-thread-comment-username",threadCommentItem:"univer-thread-comment-item",threadCommentItemHead:"univer-thread-comment-item-head",threadCommentItemTitle:"univer-thread-comment-item-title",threadCommentItemTitlePosition:"univer-thread-comment-item-title-position",threadCommentItemTitleHighlight:"univer-thread-comment-item-title-highlight",threadCommentItemTime:"univer-thread-comment-item-time",threadCommentItemContent:"univer-thread-comment-item-content",threadCommentItemAt:"univer-thread-comment-item-at"},MOCK_ID="__mock__",ThreadCommentItem=__name(props=>{const{item,unitId,subUnitId,editing,onEditingChange,onReply,resolved,isRoot,onClose,onDeleteComment}=props,commandService=core.useDependency(core.ICommandService),localeService=core.useDependency(core.LocaleService),userManagerService=core.useDependency(core.UserManagerService),user=userManagerService.getUser(item.personId),currentUser=ui.useObservable(userManagerService.currentUser$),isCommentBySelf=(currentUser==null?void 0:currentUser.userID)===item.personId,isMock=item.id===MOCK_ID,[showReply,setShowReply]=React.useState(!1),handleDeleteItem=__name(()=>{(onDeleteComment==null?void 0:onDeleteComment(item))!==!1&&(commandService.executeCommand(isRoot?threadComment$2.DeleteCommentTreeCommand.id:threadComment$2.DeleteCommentCommand.id,{unitId,subUnitId,commentId:item.id}),isRoot&&(onClose==null||onClose()))},"handleDeleteItem");return React.createElement("div",{className:styles$1.threadCommentItem,onMouseLeave:__name(()=>setShowReply(!1),"onMouseLeave"),onMouseEnter:__name(()=>setShowReply(!0),"onMouseEnter")},React.createElement("img",{className:styles$1.threadCommentItemHead,src:user==null?void 0:user.avatar}),React.createElement("div",{className:styles$1.threadCommentItemTitle},React.createElement("div",{className:styles$1.threadCommentUsername},(user==null?void 0:user.name)||" "),React.createElement("div",null,isMock||resolved?null:showReply?React.createElement("div",{className:styles$1.threadCommentIcon,onClick:__name(()=>onReply(user),"onClick")},React.createElement(ReplyToCommentSingle,null)):null,isCommentBySelf&&!isMock&&!resolved?React.createElement(design.Dropdown,{overlay:React.createElement(design.Menu,null,React.createElement(design.MenuItem,{key:"edit",onClick:__name(()=>onEditingChange==null?void 0:onEditingChange(!0),"onClick")},localeService.t("threadCommentUI.item.edit")),React.createElement(design.MenuItem,{key:"delete",onClick:handleDeleteItem},localeService.t("threadCommentUI.item.delete")))},React.createElement("div",{className:styles$1.threadCommentIcon},React.createElement(MoreHorizontalSingle,null))):null)),React.createElement("div",{className:styles$1.threadCommentItemTime},item.dT),editing?React.createElement(ThreadCommentEditor,{id:item.id,comment:item,onCancel:__name(()=>onEditingChange==null?void 0:onEditingChange(!1),"onCancel"),autoFocus:!0,unitId,subUnitId,onSave:__name(({text,attachments})=>{onEditingChange==null||onEditingChange(!1),commandService.executeCommand(threadComment$2.UpdateCommentCommand.id,{unitId,subUnitId,payload:{commentId:item.id,text,attachments}})},"onSave")}):React.createElement("div",{className:styles$1.threadCommentItemContent},transformDocument2TextNodes(item.text).map((item2,i)=>{switch(item2.type){case"mention":return React.createElement("a",{className:styles$1.threadCommentItemAt,key:i},"@",item2.content.label," ");default:return item2.content}})))},"ThreadCommentItem"),ThreadCommentTree=__name(props=>{var _a2,_b2,_c;const{id,unitId,subUnitId,refStr,showEdit=!0,onClick,showHighlight,onClose,getSubUnitName,prefix,autoFocus,onMouseEnter,onMouseLeave,onAddComment,onDeleteComment,onResolve}=props,threadCommentModel=core.useDependency(threadComment$2.ThreadCommentModel),[isHover,setIsHover]=React.useState(!1),[editingId,setEditingId]=React.useState("");ui.useObservable(threadCommentModel.commentMap$);const comments=id?threadCommentModel.getCommentWithChildren(unitId,subUnitId,id):null,commandService=core.useDependency(core.ICommandService),userManagerService=core.useDependency(core.UserManagerService),resolved=comments==null?void 0:comments.root.resolved,currentUser=ui.useObservable(userManagerService.currentUser$),editorRef=React.useRef(null),renderComments=[...comments?[comments.root]:[{id:MOCK_ID,text:{dataStream:`
3
3
  \r`},personId:(_a2=currentUser==null?void 0:currentUser.userID)!=null?_a2:"",ref:refStr!=null?refStr:"",dT:"",unitId,subUnitId,threadId:""}],...(_b2=comments==null?void 0:comments.children)!=null?_b2:[]],scroller=React.useRef(null),handleResolve=__name(e=>{e.stopPropagation(),resolved?commandService.executeCommand(SetActiveCommentOperation.id,{unitId,subUnitId,commentId:id}):commandService.executeCommand(SetActiveCommentOperation.id),commandService.executeCommand(threadComment$2.ResolveCommentCommand.id,{unitId,subUnitId,commentId:id,resolved:!resolved}),onResolve==null||onResolve(!resolved)},"handleResolve"),handleDeleteRoot=__name(e=>{e.stopPropagation(),commandService.executeCommand(SetActiveCommentOperation.id),!(comments!=null&&comments.root&&(onDeleteComment==null?void 0:onDeleteComment(comments.root))===!1)&&(commandService.executeCommand(threadComment$2.DeleteCommentTreeCommand.id,{unitId,subUnitId,commentId:id}),onClose==null||onClose())},"handleDeleteRoot");React.useEffect(()=>onMouseLeave==null?void 0:onMouseLeave(),[]);const subUnitName=getSubUnitName((_c=comments==null?void 0:comments.root.subUnitId)!=null?_c:subUnitId),editorVisible=showEdit&&!editingId&&!resolved,title=`${refStr||(comments==null?void 0:comments.root.ref)||""}${subUnitName?" · ":""}${subUnitName}`;return React.createElement("div",{className:clsx(styles$1.threadComment,{[styles$1.threadCommentActive]:!resolved&&(showHighlight||isHover||prefix==="cell")}),onClick,id:`${prefix}-${unitId}-${subUnitId}-${id}`,onMouseEnter:__name(()=>{onMouseEnter==null||onMouseEnter(),setIsHover(!0)},"onMouseEnter"),onMouseLeave:__name(()=>{onMouseLeave==null||onMouseLeave(),setIsHover(!1)},"onMouseLeave")},!resolved&&showHighlight?React.createElement("div",{className:styles$1.threadCommentHighlight}):null,React.createElement("div",{className:styles$1.threadCommentTitle},React.createElement("div",{className:styles$1.threadCommentTitlePosition},React.createElement("div",{className:styles$1.threadCommentTitleHighlight}),React.createElement(design.Tooltip,{showIfEllipsis:!0,title},React.createElement("div",{className:styles$1.threadCommentTitlePositionText},title))),comments?React.createElement("div",{className:styles$1.threadCommentIconContainer},React.createElement("div",{onClick:handleResolve,className:styles$1.threadCommentIcon,style:{color:resolved?"rgb(var(--green-500))":""}},resolved?React.createElement(ResolvedSingle,null):React.createElement(SolveSingle,null)),(currentUser==null?void 0:currentUser.userID)===comments.root.personId?React.createElement("div",{className:styles$1.threadCommentIcon,onClick:handleDeleteRoot},React.createElement(DeleteSingle,null)):null):null),React.createElement("div",{className:styles$1.threadCommentContent,ref:scroller},renderComments.map(item=>React.createElement(ThreadCommentItem,{onClose,unitId,subUnitId,item,key:item.id,isRoot:item.id===(comments==null?void 0:comments.root.id),editing:editingId===item.id,resolved:comments==null?void 0:comments.root.resolved,onEditingChange:__name(editing=>{setEditingId(editing?item.id:"")},"onEditingChange"),onReply:__name(user=>{user&&requestAnimationFrame(()=>{var _a3;(_a3=editorRef.current)==null||_a3.reply(transformTextNodes2Document([{type:"mention",content:{id:user.userID,label:user.name}}]))})},"onReply"),onAddComment,onDeleteComment}))),editorVisible?React.createElement("div",null,React.createElement(ThreadCommentEditor,{key:`${autoFocus}`,ref:editorRef,unitId,subUnitId,onSave:__name(async({text,attachments})=>{const comment={text,attachments,dT:getDT(),id:core.generateRandomId(),ref:refStr,personId:currentUser==null?void 0:currentUser.userID,parentId:comments==null?void 0:comments.root.id,unitId,subUnitId,threadId:comments==null?void 0:comments.root.threadId};(onAddComment==null?void 0:onAddComment(comment))!==!1&&(await commandService.executeCommand(threadComment$2.AddCommentCommand.id,{unitId,subUnitId,comment}),scroller.current&&(scroller.current.scrollTop=scroller.current.scrollHeight))},"onSave"),autoFocus:autoFocus||!comments,onCancel:__name(()=>{comments||onClose==null||onClose()},"onCancel")})):null)},"ThreadCommentTree"),styles={threadCommentPanel:"univer-thread-comment-panel",threadComment:"univer-thread-comment",threadCommentPanelForms:"univer-thread-comment-panel-forms",select:"univer-select",threadCommentPanelEmpty:"univer-thread-comment-panel-empty",threadCommentPanelAdd:"univer-thread-comment-panel-add",threadCommentPanelSolved:"univer-thread-comment-panel-solved"},ThreadCommentPanel=__name(props=>{const{unitId,subUnitId$,type,onAdd,getSubUnitName,onResolve,sortComments,onItemLeave,onItemEnter,disableAdd,tempComment,onAddComment,onDeleteComment,showComments}=props,[unit,setUnit]=React.useState("all"),[status,setStatus]=React.useState("all"),localeService=core.useDependency(core.LocaleService),userService=core.useDependency(core.UserManagerService),threadCommentModel=core.useDependency(threadComment$2.ThreadCommentModel),[unitComments,setUnitComments]=React.useState(()=>threadCommentModel.getUnit(unitId)),panelService=core.useDependency(exports2.ThreadCommentPanelService),activeCommentId=ui.useObservable(panelService.activeCommentId$),update=ui.useObservable(threadCommentModel.commentUpdate$),commandService=core.useDependency(core.ICommandService),subUnitId=ui.useObservable(subUnitId$),shouldScroll=React.useRef(!0),prefix="panel",currentUser=ui.useObservable(userService.currentUser$),comments=React.useMemo(()=>{var _a2,_b2;const allComments=(unit==="all"?unitComments.map(i=>i[1]).flat():(_b2=(_a2=unitComments.find(i=>i[0]===subUnitId))==null?void 0:_a2[1])!=null?_b2:[]).filter(i=>!i.parentId),sort=sortComments!=null?sortComments:a=>a,res=allComments;if(showComments){const map=new Map;return res.forEach(comment=>{map.set(comment.id,comment)}),[...showComments,""].map(id=>map.get(id)).filter(Boolean)}else return sort(res)},[showComments,unit,unitComments,sortComments,subUnitId]),commentsSorted=React.useMemo(()=>[...comments.filter(comment=>!comment.resolved),...comments.filter(comment=>comment.resolved)],[comments]),statuedComments=React.useMemo(()=>status==="resolved"?commentsSorted.filter(comment=>comment.resolved):status==="unsolved"?commentsSorted.filter(comment=>!comment.resolved):status==="concern_me"&&currentUser!=null&&currentUser.userID?commentsSorted.map(comment=>threadCommentModel.getCommentWithChildren(comment.unitId,comment.subUnitId,comment.id)).map(comment=>comment!=null&&comment.relativeUsers.has(currentUser.userID)?comment.root:null).filter(Boolean):commentsSorted,[commentsSorted,currentUser==null?void 0:currentUser.userID,status,threadCommentModel]),renderComments=tempComment?[tempComment,...statuedComments]:statuedComments,unSolvedComments=renderComments.filter(comment=>!comment.resolved),solvedComments=renderComments.filter(comment=>comment.resolved),isFiltering=status!=="all"||unit!=="all",onReset=__name(()=>{setStatus("all"),setUnit("all")},"onReset");React.useEffect(()=>{unitId&&setUnitComments(threadCommentModel.getUnit(unitId))},[unitId,threadCommentModel,update]),React.useEffect(()=>{var _a2;if(!activeCommentId)return;if(!shouldScroll.current){shouldScroll.current=!0;return}const{unitId:unitId2,subUnitId:subUnitId2,commentId}=activeCommentId,id=`${prefix}-${unitId2}-${subUnitId2}-${commentId}`;(_a2=document.getElementById(id))==null||_a2.scrollIntoView({block:"center"})},[activeCommentId]);const renderComment=__name(comment=>React.createElement(ThreadCommentTree,{prefix,getSubUnitName,key:comment.id,id:comment.id,unitId:comment.unitId,subUnitId:comment.subUnitId,refStr:comment.ref,type,showEdit:(activeCommentId==null?void 0:activeCommentId.commentId)===comment.id,showHighlight:(activeCommentId==null?void 0:activeCommentId.commentId)===comment.id,onClick:__name(()=>{shouldScroll.current=!1,comment.resolved?commandService.executeCommand(SetActiveCommentOperation.id):commandService.executeCommand(SetActiveCommentOperation.id,{unitId:comment.unitId,subUnitId:comment.subUnitId,commentId:comment.id,temp:!1})},"onClick"),onMouseEnter:__name(()=>onItemEnter==null?void 0:onItemEnter(comment),"onMouseEnter"),onMouseLeave:__name(()=>onItemLeave==null?void 0:onItemLeave(comment),"onMouseLeave"),onAddComment,onDeleteComment,onResolve:__name(resolved=>onResolve==null?void 0:onResolve(comment.id,resolved),"onResolve")}),"renderComment");return React.createElement("div",{className:styles.threadCommentPanel},React.createElement("div",{className:styles.threadCommentPanelForms},type===core.UniverInstanceType.UNIVER_SHEET?React.createElement(design.Select,{borderless:!0,value:unit,onChange:__name(e=>setUnit(e),"onChange"),options:[{value:"current",label:localeService.t("threadCommentUI.filter.sheet.current")},{value:"all",label:localeService.t("threadCommentUI.filter.sheet.all")}]}):null,React.createElement(design.Select,{borderless:!0,value:status,onChange:__name(e=>setStatus(e),"onChange"),options:[{value:"all",label:localeService.t("threadCommentUI.filter.status.all")},{value:"resolved",label:localeService.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:localeService.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:localeService.t("threadCommentUI.filter.status.concernMe")}]})),unSolvedComments.map(renderComment),solvedComments.length?React.createElement("div",{className:styles.threadCommentPanelSolved},"已解决"):null,solvedComments.map(renderComment),renderComments.length?null:React.createElement("div",{className:styles.threadCommentPanelEmpty},isFiltering?localeService.t("threadCommentUI.panel.filterEmpty"):localeService.t("threadCommentUI.panel.empty"),isFiltering?React.createElement(design.Button,{onClick:onReset,type:"link"},localeService.t("threadCommentUI.panel.reset")):React.createElement(design.Button,{id:"thread-comment-add",className:styles.threadCommentPanelAdd,type:"primary",onClick:onAdd,disabled:disableAdd},React.createElement(IncreaseSingle,null),localeService.t("threadCommentUI.panel.addComment"))))},"ThreadCommentPanel");exports2.IThreadCommentMentionDataService=IThreadCommentMentionDataService,exports2.SetActiveCommentOperation=SetActiveCommentOperation,exports2.THREAD_COMMENT_PANEL=THREAD_COMMENT_PANEL,exports2.ThreadCommentPanel=ThreadCommentPanel,exports2.ThreadCommentTree=ThreadCommentTree,exports2.ToggleSheetCommentPanelOperation=ToggleSheetCommentPanelOperation,exports2.getDT=getDT,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/thread-comment-ui",
3
- "version": "0.4.0",
3
+ "version": "0.4.1-experimental.20241023-bbb123f",
4
4
  "private": false,
5
5
  "description": "Univer common thread comment UI plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -50,16 +50,16 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@univerjs/icons": "^0.1.79",
53
- "@univerjs/protocol": "0.1.39-alpha.30",
53
+ "@univerjs/protocol": "0.1.39-alpha.36",
54
54
  "clsx": "^2.1.1",
55
55
  "dayjs": "^1.11.13",
56
- "@univerjs/core": "0.4.0",
57
- "@univerjs/docs": "0.4.0",
58
- "@univerjs/design": "0.4.0",
59
- "@univerjs/docs-ui": "0.4.0",
60
- "@univerjs/thread-comment": "0.4.0",
61
- "@univerjs/engine-render": "0.4.0",
62
- "@univerjs/ui": "0.4.0"
56
+ "@univerjs/core": "0.4.1-experimental.20241023-bbb123f",
57
+ "@univerjs/design": "0.4.1-experimental.20241023-bbb123f",
58
+ "@univerjs/docs-ui": "0.4.1-experimental.20241023-bbb123f",
59
+ "@univerjs/engine-render": "0.4.1-experimental.20241023-bbb123f",
60
+ "@univerjs/docs": "0.4.1-experimental.20241023-bbb123f",
61
+ "@univerjs/thread-comment": "0.4.1-experimental.20241023-bbb123f",
62
+ "@univerjs/ui": "0.4.1-experimental.20241023-bbb123f"
63
63
  },
64
64
  "devDependencies": {
65
65
  "less": "^4.2.0",
@@ -68,7 +68,7 @@
68
68
  "typescript": "^5.6.3",
69
69
  "vite": "^5.4.8",
70
70
  "vitest": "^2.1.2",
71
- "@univerjs-infra/shared": "0.4.0"
71
+ "@univerjs-infra/shared": "0.4.1"
72
72
  },
73
73
  "univerSpace": {
74
74
  ".": {
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