@univerjs/docs-ui 0.8.2-nightly.202506261607 → 0.8.2
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/LICENSE +176 -0
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +10 -10
- package/lib/cjs/locale/ko-KR.js +0 -1
- package/lib/es/locale/ko-KR.js +0 -125
- package/lib/locale/ko-KR.js +0 -125
- package/lib/types/locale/ko-KR.d.ts +0 -3
- package/lib/umd/locale/ko-KR.js +0 -1
package/lib/cjs/index.js
CHANGED
|
@@ -32,5 +32,5 @@ ${i.DataStreamTreeTokenType.TABLE_CELL_END}`;break}}}_processBeforeLink(t,e){ret
|
|
|
32
32
|
`," ");let s=this._umdToHtml.convert(t);if(t.length===1&&e){s=s.replace(/(<[a-z]+)/,(m,g)=>`${g} data-copy-id="${n}"`);const d=t[0],u={body:d.body};if((l=(c=d.body)==null?void 0:c.customBlocks)!=null&&l.length){u.drawings={};for(const m of d.body.customBlocks){const{blockId:g}=m,h=(A=d.drawings)==null?void 0:A[g];if(h){const p=i.Tools.generateRandomId(6);m.blockId=p,u.drawings[p]={...i.Tools.deepClone(h),drawingId:p}}}}Nn.set(n,u)}return this._clipboardInterfaceService.write(r,s)}addClipboardHook(t){return this._clipboardHooks.push(t),i.toDisposable(()=>{const e=this._clipboardHooks.indexOf(t);e>-1&&this._clipboardHooks.splice(e,1)})}_getDocumentBodyInRanges(t,e){var d;const n=this._univerInstanceService.getCurrentUniverDocInstance(),r=e!=null?e:this._docSelectionManagerService.getDocRanges(),s=[];let a=!0;if(n==null||r.length===0)return;const c=r[0].segmentId,l=(d=n==null?void 0:n.getSelfOrHeaderFooterModel(c))==null?void 0:d.getBody(),A=n.getSnapshot();if(l!=null){for(const u of r){const{startOffset:m,endOffset:g,collapsed:h,rangeType:p}=u;if(h||m==null||g==null)continue;if(p===i.DOC_RANGE_TYPE.RECT){a=!1;const{spanEntireRow:E}=u;let C;C=fr(l,m,g),s.push(C);continue}const f={startOffset:m,endOffset:g},S=n.getSelfOrHeaderFooterModel(c).sliceBody(f.startOffset,f.endOffset,t);S!=null&&s.push(S)}return{newSnapshotList:s.map(u=>({...A,body:u})),needCache:a,snapshot:A,ranges:r}}}async _genDocDataFromClipboardItems(t){try{let e="",n="";const r=[];for(const s of t)for(const a of s.types)switch(a){case I.PLAIN_TEXT_CLIPBOARD_MIME_TYPE:{n=await s.getType(a).then(c=>c&&c.text());break}case I.HTML_CLIPBOARD_MIME_TYPE:{e=await s.getType(a).then(c=>c&&c.text());break}case I.FILE__BMP_CLIPBOARD_MIME_TYPE:case I.FILE__JPEG_CLIPBOARD_MIME_TYPE:case I.FILE__WEBP_CLIPBOARD_MIME_TYPE:case I.FILE_PNG_CLIPBOARD_MIME_TYPE:{const c=await s.getType(a),l=new File([c],`pasted_image.${a.split("/")[1]}`,{type:a});r.push(l);break}}return!e&&!n&&r.length&&(e=await this._createImagePasteHtml(r)),this._genDocDataFromHtmlAndText(e,n)}catch(e){return Promise.reject(e)}}_genDocDataFromHtmlAndText(t,e,n){if(!t){if(e)return{body:i.BuildTextUtils.transform.fromPlainText(e)};throw new Error("[DocClipboardService] html and text cannot be both empty!")}const r=ja(t);if(r){const a=Nn.get(r);if(a)return a}if(!n){const a=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC);n=(a==null?void 0:a.getUnitId())||""}const s=this._htmlToUDM.convert(t,{unitId:n});return r&&Nn.set(r,s),s}async _createImagePasteHtml(t){var c,l;const e={id:"",documentStyle:{},body:{dataStream:"",customBlocks:[]},drawings:{}},n=async A=>{const d=new FileReader;return new Promise(u=>{d.onloadend=function(){u({source:d.result,imageSourceType:co.ImageSourceType.BASE64})},d.readAsDataURL(A)})},r=A=>{const d=new Image,u=500;return new Promise(m=>{d.src=typeof A=="string"?A:URL.createObjectURL(A),d.onload=()=>{const g=Math.min(u,d.naturalWidth),h=d.naturalHeight/d.naturalWidth;m({width:g,height:g*h})}})},s=(l=(c=this._clipboardHooks.find(A=>A.onBeforePasteImage))==null?void 0:c.onBeforePasteImage)!=null?l:n;return await Promise.all(t.map(async(A,d)=>{var S;const u=await s(A);if(!u)return Promise.resolve();const{width:m=100,height:g=100}=await r(A),h=`paste_image_id_${d}`,p=e.body,f=e.drawings;p.dataStream+="\b",(S=p.customBlocks)==null||S.push({startIndex:d,blockId:h}),f[h]={drawingId:h,unitId:"",subUnitId:"",imageSourceType:u.imageSourceType,title:"",source:u.source,description:"",layoutType:i.PositionedObjectLayoutType.INLINE,drawingType:i.DrawingTypeEnum.DRAWING_IMAGE,transform:{width:m,height:g,angle:0},docTransform:{angle:0,size:{width:m,height:g},positionH:{relativeFrom:i.ObjectRelativeFromH.CHARACTER,posOffset:0},positionV:{relativeFrom:i.ObjectRelativeFromV.LINE,posOffset:0}}}})),this._umdToHtml.convert([e])}};qn=qa([lt(0,i.IUniverInstanceService),lt(1,i.ILogService),lt(2,i.ICommandService),lt(3,I.IClipboardInterfaceService),lt(4,i.Inject(D.DocSelectionManagerService))],qn);function pn(o){return o.getContextValue(i.FOCUSING_DOC)||o.getContextValue(i.EDITOR_ACTIVATED)}const Mo=999,vt={id:I.CopyCommand.id,name:"doc.command.copy",type:i.CommandType.COMMAND,multi:!0,priority:Mo,preconditions:pn,handler:async o=>o.get(Be).copy()},Do={id:"doc.command.copy-current-paragraph",type:i.CommandType.COMMAND,handler:async o=>{const t=o.get(Be),e=yt(o);return e?t.copy(i.SliceBodyType.copy,[{startOffset:e.paragraphStart,endOffset:e.paragraphEnd+1,collapsed:!1}]):!1}},fn={id:I.CutCommand.id,name:"doc.command.cut",type:i.CommandType.COMMAND,multi:!0,priority:Mo,preconditions:pn,handler:async o=>o.get(Be).cut()},Bo={id:"doc.command.cut-current-paragraph",type:i.CommandType.COMMAND,handler:async o=>{const t=o.get(Be),e=yt(o);return e?t.cut([{startOffset:e.paragraphStart,endOffset:e.paragraphEnd+1,collapsed:!1,rangeType:i.DOC_RANGE_TYPE.TEXT}]):!1}},Sn={id:I.PasteCommand.id,name:"doc.command.paste",type:i.CommandType.COMMAND,multi:!0,priority:Mo,preconditions:pn,handler:async o=>{const t=o.get(Be),n=await o.get(I.IClipboardInterfaceService).read();return n.length===0?!1:t.paste(n)}};var Ja=Object.getOwnPropertyDescriptor,Za=(o,t,e,n)=>{for(var r=n>1?void 0:n?Ja(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},wn=(o,t)=>(e,n)=>t(e,n,o);const $a=11,ec=9,Ut={ff:"Arial",fs:$a};let Te=class extends i.Disposable{constructor(t,e,n){super();M(this,"_cacheStyle",null);this._textSelectionManagerService=t,this._univerInstanceService=e,this._renderManagerService=n,this._init()}_init(){this._listenDocRangeChange()}_listenDocRangeChange(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(()=>{this._clearStyleCache()}))}getStyleCache(){return this._cacheStyle}getDefaultStyle(){var a;const t=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC);if(t==null)return{...Ut};const e=t==null?void 0:t.getUnitId(),n=(a=this._renderManagerService.getRenderById(e))==null?void 0:a.with(D.DocSkeletonManagerService),r=n==null?void 0:n.getViewModel();return r==null?{...Ut}:r.getEditArea()===B.DocumentEditArea.BODY?{...Ut}:{...Ut,fs:ec}}setStyleCache(t){this._cacheStyle={...this._cacheStyle,...t}}_clearStyleCache(){this._cacheStyle=null}};Te=Za([wn(0,i.Inject(D.DocSelectionManagerService)),wn(1,i.IUniverInstanceService),wn(2,B.IRenderManagerService)],Te);function _o(o,t,e){const n=[];for(let r=0,s=o.length;r<s;r++)o[r]===i.DataStreamTreeTokenType.PARAGRAPH&&n.push({startIndex:r});if(t)for(const r of n)t.bullet&&(r.bullet=i.Tools.deepClone(t.bullet)),t.paragraphStyle&&(r.paragraphStyle=i.Tools.deepClone(t.paragraphStyle),delete r.paragraphStyle.borderBottom,t.paragraphStyle.headingId&&(r.paragraphStyle.headingId=i.generateRandomId(6)));if(e)for(const r of n)r.paragraphStyle||(r.paragraphStyle={}),r.paragraphStyle.borderBottom=e;return n}const In={id:"doc.command.break-line",type:i.CommandType.COMMAND,handler:(o,t)=>{var L,G,W,H,V;const e=o.get(D.DocSelectionManagerService),n=o.get(i.IUniverInstanceService),r=o.get(i.ICommandService),s=o.get(Te),a=(L=t==null?void 0:t.textRange)!=null?L:e.getActiveTextRange(),c=e.getRectRanges();if(a==null)return!1;if(c&&c.length){const{startOffset:j}=a;return e.replaceDocRanges([{startOffset:j,endOffset:j}]),!0}const{horizontalLine:l}=t!=null?t:{},{segmentId:A}=a,d=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC),u=d==null?void 0:d.getSelfOrHeaderFooterModel(A!=null?A:"").getBody();if(d==null||u==null)return!1;const m=d.getUnitId(),{startOffset:g,endOffset:h}=a,f=((G=u.paragraphs)!=null?G:[]).find(j=>j.startIndex>=g);if(!f)return!1;const S=g===f.startIndex,E=f.startIndex,C=s.getDefaultStyle(),T=s.getStyleCache(),R=an(u,h,C,T),v={dataStream:i.DataStreamTreeTokenType.PARAGRAPH,paragraphs:_o(i.DataStreamTreeTokenType.PARAGRAPH,f,l),textRuns:[{st:0,ed:1,ts:{...R.ts}}]};if(d==null)return!1;const b=e.getActiveTextRange();if(u==null)return!1;const{collapsed:x}=a,y=v.dataStream.length,_=[{startOffset:g+y,endOffset:g+y,style:b==null?void 0:b.style,collapsed:x}],O={id:D.RichTextEditingMutation.id,params:{unitId:m,actions:[],textRanges:_,debounce:!0}},w=new i.TextX,Q=i.JSONX.getInstance();if(x)g>0&&w.push({t:i.TextXActionType.RETAIN,len:g}),w.push({t:i.TextXActionType.INSERT,body:v,len:v.dataStream.length});else{const j=i.BuildTextUtils.selection.delete([a],u,0,v);w.push(...j)}(((W=f.bullet)==null?void 0:W.listType)===i.PresetListType.CHECK_LIST_CHECKED||(H=f.paragraphStyle)!=null&&H.headingId)&&(a.endOffset<E&&w.push({t:i.TextXActionType.RETAIN,len:E-a.endOffset}),w.push({t:i.TextXActionType.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...f,paragraphStyle:{...f.paragraphStyle,...S?{headingId:void 0,namedStyleType:void 0}:null},startIndex:0,bullet:(V=f.paragraphStyle)!=null&&V.headingId?void 0:{...f.bullet,listType:i.PresetListType.CHECK_LIST}}]},coverType:i.UpdateDocsAttributeType.REPLACE})),O.params.textRanges=[{startOffset:g+y,endOffset:g+y,collapsed:x}];const k=J(d,A);return O.params.actions=Q.editOp(w.serialize(),k),!!r.syncExecuteCommand(O.id,O.params)}},Rt={id:"doc.command.horizontal-line",type:i.CommandType.COMMAND,handler:(o,t)=>o.get(i.ICommandService).syncExecuteCommand(In.id,{horizontalLine:{padding:5,color:{rgb:"#CDD0D8"},width:1,dashStyle:i.DashStyleType.SOLID},textRange:t==null?void 0:t.insertRange})},No={id:"doc.command.insert-horizontal-line-bellow",type:i.CommandType.COMMAND,handler:o=>{const t=o.get(i.ICommandService),e=yt(o);return e?t.syncExecuteCommand(Rt.id,{insertRange:{startOffset:e.startIndex+1,endOffset:e.startIndex+1}}):!1}};function ue(o,t,e){return e.executeCommand(be.id,{preCommandId:o,...t!=null?t:{}})}const Sr="doc.command.set-inline-format-bold",_e={id:Sr,type:i.CommandType.COMMAND,handler:async(o,t)=>{const e=o.get(i.ICommandService);return ue(Sr,t,e)}},Ir="doc.command.set-inline-format-italic",Ne={id:Ir,type:i.CommandType.COMMAND,handler:async(o,t)=>{const e=o.get(i.ICommandService);return ue(Ir,t,e)}},vr="doc.command.set-inline-format-underline",Pe={id:vr,type:i.CommandType.COMMAND,handler:async(o,t)=>{const e=o.get(i.ICommandService);return ue(vr,t,e)}},Er="doc.command.set-inline-format-strikethrough",we={id:Er,type:i.CommandType.COMMAND,handler:async(o,t)=>{const e=o.get(i.ICommandService);return ue(Er,t,e)}},Cr="doc.command.set-inline-format-subscript",ye={id:Cr,type:i.CommandType.COMMAND,handler:async(o,t)=>{const e=o.get(i.ICommandService);return ue(Cr,t,e)}},Tr="doc.command.set-inline-format-superscript",Ue={id:Tr,type:i.CommandType.COMMAND,handler:async(o,t)=>{const e=o.get(i.ICommandService);return ue(Tr,t,e)}},yr="doc.command.set-inline-format-fontsize",me={id:yr,type:i.CommandType.COMMAND,handler:async(o,t)=>{const e=o.get(i.ICommandService);return ue(yr,t,e)}},br="doc.command.set-inline-format-font-family",Ge={id:br,type:i.CommandType.COMMAND,handler:async(o,t)=>{const e=o.get(i.ICommandService);return ue(br,t,e)}},Rr="doc.command.set-inline-format-text-color",Me={id:Rr,type:i.CommandType.COMMAND,handler:async(o,t)=>{const e=o.get(i.ICommandService);return ue(Rr,t,e)}},xr="doc.command.set-inline-format-text-background-color",De={id:xr,type:i.CommandType.COMMAND,handler:async(o,t)=>{const e=o.get(i.ICommandService);return ue(xr,t,e)}},Or="doc.command.reset-inline-format-text-background-color",st={id:Or,type:i.CommandType.COMMAND,handler:async(o,t)=>{const e=o.get(i.ICommandService);return ue(Or,t,e)}},Jn={[_e.id]:"bl",[Ne.id]:"it",[Pe.id]:"ul",[we.id]:"st",[me.id]:"fs",[Ge.id]:"ff",[Me.id]:"cl",[De.id]:"bg",[st.id]:"bg",[ye.id]:"va",[Ue.id]:"va"},be={id:"doc.command.set-inline-format",type:i.CommandType.COMMAND,handler:async(o,t)=>{var R;const{value:e,preCommandId:n}=t,r=o.get(i.ICommandService),s=o.get(D.DocSelectionManagerService),a=o.get(i.IUniverInstanceService),c=o.get(Te),l=s.getDocRanges(),A=(R=l.find(v=>v.isActive))!=null?R:l[0];if(l.length===0)return!1;const{segmentId:d}=l[0],u=a.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC);if(u==null)return!1;const m=u.getSelfOrHeaderFooterModel(d).getBody();if(m==null)return!1;const g=u.getUnitId();let h;switch(n){case _e.id:case Ne.id:case Pe.id:case we.id:case ye.id:case Ue.id:{const v=c.getDefaultStyle(),b=Yi(m,A,v);h=nc(b,n);break}case me.id:case Ge.id:{h=e;break}case Me.id:case De.id:{h={rgb:e};break}case st.id:{h={rgb:null};break}default:throw new Error(`Unknown command: ${n} in handleInlineFormat`)}const p={id:D.RichTextEditingMutation.id,params:{unitId:g,actions:[],textRanges:l}},f=new i.TextX,S=i.JSONX.getInstance(),E=new i.MemoryCursor;E.reset();for(const v of l){let{startOffset:b,endOffset:x,rangeType:y}=v;if(b==null||x==null)continue;if(y===i.DOC_RANGE_TYPE.RECT&&(b=b-1),b===x){const w=c.getStyleCache(),Q=Jn[n];c.setStyleCache({[Q]:(w==null?void 0:w[Q])!==void 0?zi(w,Q,n):h});continue}const _={dataStream:"",textRuns:[{st:0,ed:x-b,ts:{[Jn[n]]:h}}]},O=b-E.cursor;O!==0&&f.push({t:i.TextXActionType.RETAIN,len:O}),f.push({t:i.TextXActionType.RETAIN,body:_,len:x-b}),E.reset(),E.moveCursor(x)}const C=J(u,d);return p.params.actions=S.editOp(f.serialize(),C),!!r.syncExecuteCommand(p.id,p.params)}};function tc(o){return o!==null&&typeof o=="object"}function zi(o,t,e){if(/bl|it/.test(t))return(o==null?void 0:o[t])===i.BooleanNumber.TRUE?i.BooleanNumber.FALSE:i.BooleanNumber.TRUE;if(/ul|st/.test(t))return tc(o==null?void 0:o[t])&&(o==null?void 0:o[t]).s===i.BooleanNumber.TRUE?{s:i.BooleanNumber.FALSE}:{s:i.BooleanNumber.TRUE};if(/va/.test(t))return e===ye.id?(o==null?void 0:o[t])===i.BaselineOffset.SUBSCRIPT?i.BaselineOffset.NORMAL:i.BaselineOffset.SUBSCRIPT:(o==null?void 0:o[t])===i.BaselineOffset.SUPERSCRIPT?i.BaselineOffset.NORMAL:i.BaselineOffset.SUPERSCRIPT}function Yi(o,t,e){var d,u,m,g,h,p,f,S,E,C,T,R,v,b;const{startOffset:n,endOffset:r,collapsed:s}=t;if(s){const x=(d=o.textRuns)!=null?d:[];let y=null;for(let _=x.length-1;_>=0;_--){const O=x[_];if(O.st<n&&n<=O.ed){y=O;break}}return y!=null&&y.ts?{...e,...y.ts}:e}const{textRuns:a=[]}=i.getBodySlice(o,n,r),c=i.Tools.deepClone(e),l=a.map(x=>{var y;return(y=x==null?void 0:x.ts)==null?void 0:y.fs}).filter(Boolean);c.fs=c.fs?Math.max(c.fs,...l):l.length?Math.max(...l):void 0,c.fs=!c.fs||Number.isNaN(c.fs)?void 0:c.fs,c.ff=(g=(m=(u=a.find(x=>{var y;return((y=x.ts)==null?void 0:y.ff)!=null}))==null?void 0:u.ts)==null?void 0:m.ff)!=null?g:c.ff,c.it=a.length&&a.every(x=>{var y;return((y=x.ts)==null?void 0:y.it)===i.BooleanNumber.TRUE})?i.BooleanNumber.TRUE:i.BooleanNumber.FALSE,c.bl=a.length&&a.every(x=>{var y;return((y=x.ts)==null?void 0:y.bl)===i.BooleanNumber.TRUE})?i.BooleanNumber.TRUE:i.BooleanNumber.FALSE,c.ul=a.length&&a.every(x=>{var y,_;return((_=(y=x.ts)==null?void 0:y.ul)==null?void 0:_.s)===i.BooleanNumber.TRUE})?(h=a[0].ts)==null?void 0:h.ul:c.ul,c.st=a.length&&a.every(x=>{var y,_;return((_=(y=x.ts)==null?void 0:y.st)==null?void 0:_.s)===i.BooleanNumber.TRUE})?(p=a[0].ts)==null?void 0:p.st:c.st,c.bg=(E=(S=(f=a.find(x=>{var y;return((y=x.ts)==null?void 0:y.bg)!=null}))==null?void 0:f.ts)==null?void 0:S.bg)!=null?E:c.bg,c.cl=(R=(T=(C=a.find(x=>{var y;return((y=x.ts)==null?void 0:y.cl)!=null}))==null?void 0:C.ts)==null?void 0:T.cl)!=null?R:c.cl;const A=a.filter(x=>{var y;return((y=x==null?void 0:x.ts)==null?void 0:y.va)!=null});if(A.length>0&&A.length===a.length){const x=(v=A[0].ts)==null?void 0:v.va;let y=!0;for(let _=1;_<A.length;_++)if(((b=A[_].ts)==null?void 0:b.va)!==x){y=!1;break}y&&(c.va=x)}return c}function nc(o,t){const e=Jn[t];return zi(o,e,t)}const at={id:"doc.command.list-operation",type:i.CommandType.COMMAND,handler:(o,t)=>{var T,R,v,b,x,y;const e=o.get(D.DocSelectionManagerService),n=o.get(i.IUniverInstanceService),r=o.get(i.ICommandService),s=t.listType,a=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC),c=(R=(T=t.docRange)!=null?T:e.getDocRanges())!=null?R:[];if(a==null||c.length===0)return!1;const l=c[0].segmentId,A=a.getSelfOrHeaderFooterModel(l),d=(b=(v=A.getBody())==null?void 0:v.paragraphs)!=null?b:[],u=(y=(x=A.getBody())==null?void 0:x.dataStream)!=null?y:"";if(!d.length)return!1;const m=i.BuildTextUtils.range.getParagraphsInRanges(c,d,u),g=a.getUnitId(),h={id:D.RichTextEditingMutation.id,params:{unitId:g,actions:[],textRanges:c,isEditing:!1}};new i.MemoryCursor().reset();const f=i.BuildTextUtils.paragraph.bullet.switch({paragraphs:m,listType:s,document:a,segmentId:l}),S=i.JSONX.getInstance(),E=J(a,l);return h.params.actions=S.editOp(f.serialize(),E),!!r.syncExecuteCommand(h.id,h.params)}},xt={id:"doc.command.change-list-type",type:i.CommandType.COMMAND,handler:(o,t)=>{var C,T,R,v,b;const e=o.get(D.DocSelectionManagerService),n=o.get(i.IUniverInstanceService),r=o.get(i.ICommandService),{listType:s}=t,a=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC),c=(C=t.docRange)!=null?C:e.getDocRanges();if(a==null||c==null||!c.length)return!1;const{segmentId:l}=c[0],A=a.getSelfOrHeaderFooterModel(l),d=(R=(T=A.getBody())==null?void 0:T.paragraphs)!=null?R:[],u=(b=(v=A.getBody())==null?void 0:v.dataStream)!=null?b:"";if(!d.length)return!1;const m=i.BuildTextUtils.range.getParagraphsInRanges(c,d,u),g=a.getUnitId(),h=i.BuildTextUtils.paragraph.bullet.set({paragraphs:m,listType:s,segmentId:l,document:a});if(!h)return!1;const p=i.JSONX.getInstance(),f={id:D.RichTextEditingMutation.id,params:{unitId:g,actions:[],textRanges:c,isEditing:!1}},S=J(a,l);return f.params.actions=p.editOp(h.serialize(),S),!!r.syncExecuteCommand(f.id,f.params)}};var St=(o=>(o[o.increase=1]="increase",o[o.decrease=-1]="decrease",o))(St||{});const Yt={id:"doc.command.change-list-nesting-level",type:i.CommandType.COMMAND,handler:(o,t)=>{var T,R,v,b,x;if(!t)return!1;const{type:e}=t,n=o.get(D.DocSelectionManagerService),r=o.get(i.IUniverInstanceService),s=o.get(i.ICommandService),a=r.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC),c=n.getActiveTextRange();if(a==null||c==null)return!1;const{segmentId:l}=c,A=(T=n.getDocRanges())!=null?T:[],d=a.getSelfOrHeaderFooterModel(l),u=(v=(R=d.getBody())==null?void 0:R.paragraphs)!=null?v:[],m=(x=(b=d.getBody())==null?void 0:b.dataStream)!=null?x:"";if(!u.length)return!1;const g=i.BuildTextUtils.range.getParagraphsInRange(c,u,m),h=a.getUnitId(),p=i.JSONX.getInstance(),f=i.BuildTextUtils.paragraph.bullet.changeNestLevel({paragraphs:g,type:e,segmentId:l,document:a}),S={id:D.RichTextEditingMutation.id,params:{unitId:h,actions:[],textRanges:A,isEditing:!1}},E=J(a,l);return S.params.actions=p.editOp(f.serialize(),E),!!s.syncExecuteCommand(S.id,S.params)}},nt={id:"doc.command.bullet-list",type:i.CommandType.COMMAND,handler:(o,t)=>{const e=o.get(i.ICommandService);return t!=null&&t.value?e.syncExecuteCommand(xt.id,{listType:t.value,docRange:t.docRange}):e.syncExecuteCommand(at.id,{listType:i.PresetListType.BULLET_LIST,docRange:t==null?void 0:t.docRange})}},Et={id:"doc.command.check-list",type:i.CommandType.COMMAND,handler:(o,t)=>{const e=o.get(i.ICommandService);return t!=null&&t.value?e.syncExecuteCommand(xt.id,{listType:t.value,docRange:t.docRange}):e.syncExecuteCommand(at.id,{listType:i.PresetListType.CHECK_LIST,docRange:t==null?void 0:t.docRange})}},Po={id:"doc.command.toggle-check-list",type:i.CommandType.COMMAND,handler:(o,t)=>{var p;if(!t)return!1;const e=o.get(i.IUniverInstanceService),n=o.get(i.ICommandService),{index:r,segmentId:s,textRanges:a}=t,c=e.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC);if(c==null||((p=c.getSelfOrHeaderFooterModel(s).getBody())==null?void 0:p.paragraphs)==null)return!1;const A=c.getUnitId(),d={id:D.RichTextEditingMutation.id,params:{unitId:A,actions:[],textRanges:a!=null?a:[],segmentId:s,isEditing:!1}},u=i.BuildTextUtils.paragraph.bullet.toggleChecklist({document:c,paragraphIndex:r,segmentId:s});if(!u)return!1;const m=i.JSONX.getInstance(),g=J(c,s);return d.params.actions=m.editOp(u.serialize(),g),!!n.syncExecuteCommand(d.id,d.params)}},ot={id:"doc.command.order-list",type:i.CommandType.COMMAND,handler:(o,t)=>{const e=o.get(i.ICommandService);return t!=null&&t.value?e.syncExecuteCommand(xt.id,{listType:t.value}):e.syncExecuteCommand(at.id,{listType:i.PresetListType.ORDER_LIST})}},wo={id:"doc.command.quick-list",type:i.CommandType.COMMAND,handler(o,t){var O,w,Q;if(!t)return!1;const e=o.get(D.DocSelectionManagerService),n=o.get(i.IUniverInstanceService),r=o.get(i.ICommandService),s=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC),a=e.getActiveTextRange();if(s==null||a==null)return!1;const{segmentId:c,startOffset:l}=a,{listType:A,paragraph:d}=t,{paragraphStart:u,paragraphEnd:m}=d,g=new i.TextX,h=i.JSONX.getInstance(),{paragraphStyle:p={}}=d,S=(i.PRESET_LIST_TYPE[A].nestingLevel[0].paragraphProperties||{}).textStyle;let C=i.Tools.generateRandomId(6);const T=(w=(O=s.getBody())==null?void 0:O.paragraphs)!=null?w:[],R=T.findIndex(k=>k.startIndex===d.startIndex),v=T[R-1],b=T[R+1];v&&v.bullet&&v.bullet.listType.indexOf(A)===0?C=v.bullet.listId:b&&b.bullet&&b.bullet.listType.indexOf(A)===0&&(C=b.bullet.listId);const x={id:D.RichTextEditingMutation.id,params:{unitId:s.getUnitId(),actions:[],textRanges:[{startOffset:u,endOffset:u,collapsed:!0}],isEditing:!1}};g.push({t:i.TextXActionType.RETAIN,len:u}),g.push({t:i.TextXActionType.DELETE,len:l-u}),m>l&&g.push({t:i.TextXActionType.RETAIN,len:m-l}),g.push({t:i.TextXActionType.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{...p,textStyle:{...p.textStyle,...S},indentFirstLine:void 0},bullet:{...(Q=d.bullet)!=null?Q:{nestingLevel:0,textStyle:{fs:20}},listType:A,listId:C}}]}});const y=J(s,c);return x.params.actions=h.editOp(g.serialize(),y),!!r.syncExecuteCommand(x.id,x.params)}};function Uo(o,t){var d,u;const e=o.get(i.ICommandService),n=yt(o);if(!n)return!1;const r=o.get(i.IUniverInstanceService).getCurrentUnitOfType(i.UniverInstanceType.UNIVER_DOC);if(!r)return!1;const s=i.BuildTextUtils.selection.replace({doc:r,selection:{startOffset:n.startIndex+1,endOffset:n.startIndex+1,collapsed:!0},body:{dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:{...n.paragraphStyle},bullet:{listType:t,listId:((d=n.bullet)==null?void 0:d.listType)===t?n.bullet.listId:i.Tools.generateRandomId(6),nestingLevel:((u=n.bullet)==null?void 0:u.listType)===t?n.bullet.nestingLevel:0}}]}});if(!s)return!1;const a={id:D.RichTextEditingMutation.id,params:{unitId:r.getUnitId(),actions:[],textRanges:[{startOffset:n.startIndex+1,endOffset:n.startIndex+1,collapsed:!0}],isEditing:!1}},c=i.JSONX.getInstance(),l=J(r);return a.params.actions=c.editOp(s.serialize(),l),!!e.syncExecuteCommand(a.id,a.params)}const Lo={id:"doc.command.insert-bullet-list-bellow",type:i.CommandType.COMMAND,handler:o=>Uo(o,i.PresetListType.BULLET_LIST)},Qo={id:"doc.command.insert-order-list-bellow",type:i.CommandType.COMMAND,handler:o=>Uo(o,i.PresetListType.ORDER_LIST)},Fo={id:"doc.command.insert-check-list-bellow",type:i.CommandType.COMMAND,handler:o=>Uo(o,i.PresetListType.CHECK_LIST)},le={id:"doc.command.set-paragraph-named-style",type:i.CommandType.COMMAND,handler(o,t){var h;if(!t)return!1;const n=o.get(i.IUniverInstanceService).getCurrentUnitOfType(i.UniverInstanceType.UNIVER_DOC);if(!n)return!1;const r=n.getUnitId(),s=o.get(D.DocSelectionManagerService),a=(h=t.textRanges)!=null?h:s.getTextRanges({unitId:r,subUnitId:r});if(!(a!=null&&a.length))return!1;const c=a[0].segmentId,l=i.BuildTextUtils.paragraph.style.set({document:n.getSelfOrHeaderFooterModel(c),textRanges:a,style:{namedStyleType:t.value,headingId:!t.value||t.value===i.NamedStyleType.NORMAL_TEXT?void 0:i.generateRandomId(6),spaceAbove:void 0,spaceBelow:void 0,lineSpacing:void 0},paragraphTextRun:{}}),A={id:D.RichTextEditingMutation.id,params:{actions:[],textRanges:a,unitId:r,segmentId:c}},d=i.JSONX.getInstance(),u=J(n,c);return A.params.actions=d.editOp(l.serialize(),u),!!o.get(i.ICommandService).syncExecuteCommand(A.id,A.params)}},qi={id:"doc.command.quick-heading",type:i.CommandType.COMMAND,handler(o,t){var R,v,b,x;if(!t)return!1;const{value:e}=t,n=o.get(D.DocSelectionManagerService),r=o.get(i.IUniverInstanceService),s=o.get(i.ICommandService),a=r.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC),c=n.getActiveTextRange();if(a==null||c==null||!c.collapsed)return!1;const{segmentId:l,startOffset:A}=c,d=a.getSelfOrHeaderFooterModel(l),u=(v=(R=d.getBody())==null?void 0:R.paragraphs)!=null?v:[],m=(x=(b=d.getBody())==null?void 0:b.dataStream)!=null?x:"",g=i.BuildTextUtils.paragraph.util.getParagraphsInRange(c,u,m)[0];if(!g)return!1;const{paragraphStart:h}=g,p=new i.TextX,f=i.JSONX.getInstance(),{paragraphStyle:S={}}=g,E={id:D.RichTextEditingMutation.id,params:{unitId:a.getUnitId(),actions:[],textRanges:[{startOffset:h,endOffset:h,collapsed:!0}],isEditing:!1}};p.push({t:i.TextXActionType.RETAIN,len:h}),i.BuildTextUtils.paragraph.style.set({textRanges:[c],document:a,style:{...S,headingId:i.generateRandomId(6),namedStyleType:e},cursor:A,deleteLen:A-h,textX:p,paragraphTextRun:{}});const C=J(a,l);return E.params.actions=f.editOp(p.serialize(),C),!!s.syncExecuteCommand(E.id,E.params)}},Un={"#":i.NamedStyleType.HEADING_1,"##":i.NamedStyleType.HEADING_2,"###":i.NamedStyleType.HEADING_3,"####":i.NamedStyleType.HEADING_4,"#####":i.NamedStyleType.HEADING_5},Ho={id:"doc.command.h1-heading",type:i.CommandType.COMMAND,handler:o=>o.get(i.ICommandService).syncExecuteCommand(le.id,{value:i.NamedStyleType.HEADING_1})},ko={id:"doc.command.h2-heading",type:i.CommandType.COMMAND,handler:o=>o.get(i.ICommandService).syncExecuteCommand(le.id,{value:i.NamedStyleType.HEADING_2})},Vo={id:"doc.command.h3-heading",type:i.CommandType.COMMAND,handler:o=>o.get(i.ICommandService).syncExecuteCommand(le.id,{value:i.NamedStyleType.HEADING_3})},jo={id:"doc.command.h4-heading",type:i.CommandType.COMMAND,handler:o=>o.get(i.ICommandService).syncExecuteCommand(le.id,{value:i.NamedStyleType.HEADING_4})},Wo={id:"doc.command.h5-heading",type:i.CommandType.COMMAND,handler:o=>o.get(i.ICommandService).syncExecuteCommand(le.id,{value:i.NamedStyleType.HEADING_5})},qt={id:"doc.command.normal-text-heading",type:i.CommandType.COMMAND,handler:o=>o.get(i.ICommandService).syncExecuteCommand(le.id,{value:i.NamedStyleType.NORMAL_TEXT})},Ji={id:"doc.command.title",type:i.CommandType.COMMAND,handler:o=>o.get(i.ICommandService).syncExecuteCommand(le.id,{value:i.NamedStyleType.TITLE})},Zi={id:"doc.command.subtitle-heading",type:i.CommandType.COMMAND,handler:o=>o.get(i.ICommandService).syncExecuteCommand(le.id,{value:i.NamedStyleType.SUBTITLE})},pe={id:"doc.command.align-action",type:i.CommandType.COMMAND,handler:(o,t)=>{var R,v,b,x;const e=o.get(D.DocSelectionManagerService),n=o.get(i.IUniverInstanceService),r=o.get(i.ICommandService),{alignType:s}=t,a=n.getCurrentUniverDocInstance();if(a==null)return!1;const c=e.getDocRanges();if(c.length===0)return!1;const l=c[0].segmentId,A=a.getSelfOrHeaderFooterModel(l),d=(v=(R=A.getBody())==null?void 0:R.paragraphs)!=null?v:[],u=(x=(b=A.getBody())==null?void 0:b.dataStream)!=null?x:"";if(d==null)return!1;const m=i.BuildTextUtils.range.getParagraphsInRanges(c,d,u),g=a.getUnitId(),h=m.every(y=>{var _;return((_=y.paragraphStyle)==null?void 0:_.horizontalAlign)===s}),p={id:D.RichTextEditingMutation.id,params:{unitId:g,actions:[],textRanges:c}},f=new i.MemoryCursor;f.reset();const S=new i.TextX,E=i.JSONX.getInstance();for(const y of m){const{startIndex:_}=y;S.push({t:i.TextXActionType.RETAIN,len:_-f.cursor});const O={...y.paragraphStyle,horizontalAlign:h?i.HorizontalAlign.UNSPECIFIED:s};S.push({t:i.TextXActionType.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...y,paragraphStyle:O,startIndex:0}]},coverType:i.UpdateDocsAttributeType.REPLACE}),f.moveCursorTo(_+1)}const C=J(a,l);return p.params.actions=E.editOp(S.serialize(),C),!!r.syncExecuteCommand(p.id,p.params)}},Ot={id:"doc.command.align-left",type:i.CommandType.COMMAND,handler:o=>o.get(i.ICommandService).syncExecuteCommand(pe.id,{alignType:i.HorizontalAlign.LEFT})},Mt={id:"doc.command.align-center",type:i.CommandType.COMMAND,handler:o=>o.get(i.ICommandService).syncExecuteCommand(pe.id,{alignType:i.HorizontalAlign.CENTER})},Dt={id:"doc.command.align-right",type:i.CommandType.COMMAND,handler:o=>o.get(i.ICommandService).syncExecuteCommand(pe.id,{alignType:i.HorizontalAlign.RIGHT})},Bt={id:"doc.command.align-justify",type:i.CommandType.COMMAND,handler:o=>o.get(i.ICommandService).syncExecuteCommand(pe.id,{alignType:i.HorizontalAlign.JUSTIFIED})},_t={id:"doc.command.switch-mode",type:i.CommandType.COMMAND,handler:o=>{var E,C,T,R,v;const t=o.get(i.ICommandService),e=o.get(B.IRenderManagerService),n=o.get(D.DocSelectionManagerService),s=o.get(i.IUniverInstanceService).getCurrentUniverDocInstance();if(s==null)return!1;const a=s.getUnitId(),c=(E=e.getRenderById(a))==null?void 0:E.with(D.DocSkeletonManagerService).getSkeleton(),l=(C=e.getRenderById(a))==null?void 0:C.with(exports.DocSelectionRenderService);if(c==null||l==null)return!1;const A=l==null?void 0:l.getSegment(),d=l==null?void 0:l.getSegmentPage(),u=s.getSnapshot().documentStyle.documentFlavor,m=n.getDocRanges(),g={id:D.RichTextEditingMutation.id,params:{unitId:a,actions:[],textRanges:u===i.DocumentFlavor.TRADITIONAL&&A?[]:m}},h=i.JSONX.getInstance(),p=[];let f;if(u===void 0?f=h.insertOp(["documentStyle","documentFlavor"],i.DocumentFlavor.MODERN):u===i.DocumentFlavor.MODERN?f=h.replaceOp(["documentStyle","documentFlavor"],u,i.DocumentFlavor.TRADITIONAL):f=h.replaceOp(["documentStyle","documentFlavor"],u,i.DocumentFlavor.MODERN),f)p.push(f);else return!1;if(u!==i.DocumentFlavor.MODERN){const b=s.getSnapshot(),{drawings:x={},body:y}=b,_=(T=y==null?void 0:y.customBlocks)!=null?T:[];for(const O in x){const w=x[O],Q=_.find(Z=>Z.blockId===O);if(Q==null)continue;const k=w.docTransform.positionV,{relativeFrom:F,posOffset:L}=k;if(F===i.ObjectRelativeFromV.PARAGRAPH)continue;const{startIndex:G}=Q,W=c.findNodeByCharIndex(G,A,d),H=(R=W==null?void 0:W.parent)==null?void 0:R.parent,V=H==null?void 0:H.parent,j=V==null?void 0:V.lines.find(Z=>Z.paragraphIndex===(H==null?void 0:H.paragraphIndex)&&Z.paragraphStart),X=(v=V==null?void 0:V.parent)==null?void 0:v.parent;if(W==null||H==null||j==null||V==null||X==null)continue;let z=0;F===i.ObjectRelativeFromV.LINE?z-=H.top:F===i.ObjectRelativeFromV.PAGE&&(z+=X.marginTop),z+=j.top;const Y={...k,relativeFrom:i.ObjectRelativeFromV.PARAGRAPH,posOffset:(L!=null?L:0)-z},K=h.replaceOp(["drawings",O,"docTransform","positionV"],k,Y);K&&p.push(K)}}return g.params.actions=p.reduce((b,x)=>i.JSONX.compose(b,x),null),!!t.syncExecuteCommand(g.id,g.params)}},$i="COMPONENT_DOC_CREATE_TABLE_CONFIRM",oc="doc.command.create-table",Go={id:oc,type:i.CommandType.COMMAND,handler:async(o,t)=>{var Y,K,Z,ne,ge;const{rowCount:e,colCount:n}=t,r=o.get(D.DocSelectionManagerService),s=o.get(i.IUniverInstanceService),a=o.get(i.ICommandService),c=o.get(Te),l=r.getActiveTextRange();if(l==null)return!1;const{segmentId:A,segmentPage:d}=l,u=s.getCurrentUniverDocInstance(),m=u==null?void 0:u.getSelfOrHeaderFooterModel(A).getBody();if(u==null||m==null)return!1;const g=u.getUnitId(),h=ce(o,g),p=h==null?void 0:h.getSkeleton();if(p==null)return!1;const{startOffset:f}=l,E=((Y=m.paragraphs)!=null?Y:[]).find(xe=>xe.startIndex>=f),C=p.findNodeByCharIndex(f,A,d);if(C==null)return!1;const T=new i.TextX,R=i.JSONX.getInstance(),v=[],b=f+4,x=[{startOffset:b,endOffset:b,collapsed:!0}],y={id:D.RichTextEditingMutation.id,params:{unitId:g,actions:[],textRanges:x}};f>0&&T.push({t:i.TextXActionType.RETAIN,len:f}),T.push({t:i.TextXActionType.INSERT,body:{dataStream:i.DataStreamTreeTokenType.PARAGRAPH,paragraphs:_o(i.DataStreamTreeTokenType.PARAGRAPH,E)},len:1});const _=c.getDefaultStyle(),O=c.getStyleCache(),w=an(m,f,_,O),{dataStream:Q,paragraphs:k,sectionBreaks:F}=xa(e,n),L=(ge=(ne=(Z=(K=C.parent)==null?void 0:K.parent)==null?void 0:Z.parent)==null?void 0:ne.parent)==null?void 0:ge.parent;if(L==null)return!1;const{pageWidth:G,marginLeft:W,marginRight:H}=L,V=Co(e,n,G-W-H);T.push({t:i.TextXActionType.INSERT,body:{dataStream:Q,paragraphs:k,sectionBreaks:F,textRuns:[{...w,st:0,ed:Q.length}],tables:[{startIndex:0,endIndex:Q.length,tableId:V.tableId}]},len:Q.length});const j=J(u,A);v.push(R.editOp(T.serialize(),j));const X=R.insertOp(["tableSource",V.tableId],V);return v.push(X),y.params.actions=v.reduce((xe,he)=>i.JSONX.compose(xe,he),null),!!a.syncExecuteCommand(y.id,y.params)}},Ln="doc.component.create-table-confirm",vn={id:"doc.operation.create-table",type:i.CommandType.COMMAND,handler:async o=>{const t=o.get(i.LocaleService),e=o.get(I.IConfirmService),n=o.get(i.ICommandService),r={rowCount:3,colCount:5},s=(a,c)=>{r.rowCount=a,r.colCount=c};return await e.open({id:Ln,children:{label:{name:$i,props:{handleRowColChange:s,tableCreateParams:r}}},width:400,title:{title:t.t("toolbar.table.insert")},onConfirm:()=>{n.executeCommand(Go.id,r),e.close(Ln)},onClose:()=>{e.close(Ln)}}),!0}},rc=o=>{const e=Object.keys(i.PAGE_SIZE).find(n=>{const{width:r,height:s}=i.PAGE_SIZE[n];return o.width===r&&o.height===s});return e!=null?e:"A4"};function ic(o){const{hooks:t}=o,r=I.useDependency(i.IUniverInstanceService).getCurrentUnitOfType(i.UniverInstanceType.UNIVER_DOC).getDocumentStyle(),s=I.useDependency(i.LocaleService),[a,c]=P.useState(()=>{var d,u,m,g,h;return{paperSize:rc(r.pageSize),orientation:(d=r.pageOrient)!=null?d:i.PageOrientType.PORTRAIT,margins:{top:(u=r.marginTop)!=null?u:0,bottom:(m=r.marginBottom)!=null?m:0,left:(g=r.marginLeft)!=null?g:0,right:(h=r.marginRight)!=null?h:0}}});P.useEffect(()=>{t.beforeClose=()=>a,t.beforeConfirm=()=>a},[a]);const l=d=>{c(u=>({...u,paperSize:d}))},A=(d,u)=>{c(m=>({...m,margins:{...m.margins,[d]:u||0}}))};return N.jsxs("div",{className:"univer-flex univer-flex-col univer-gap-4",children:[N.jsxs("div",{className:"univer-flex univer-flex-col univer-gap-2",children:[N.jsx("label",{className:"univer-text-sm univer-font-medium univer-text-gray-900 dark:!univer-text-white",children:s.t("page-settings.paper-size")}),N.jsx(q.Select,{value:a.paperSize,onChange:l,options:i.PAPER_TYPES.map(d=>({label:s.t(`page-settings.page-size.${d.toLocaleLowerCase()}`),value:d}))})]}),N.jsxs("div",{className:"univer-flex univer-flex-col univer-gap-2",children:[N.jsx("label",{className:"univer-text-sm univer-font-medium univer-text-gray-900 dark:!univer-text-white",children:s.t("page-settings.custom-paper-size")}),N.jsxs("div",{className:"univer-flex univer-flex-col univer-gap-2.5",children:[N.jsxs("div",{className:"univer-flex univer-gap-2.5",children:[N.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-col univer-gap-2",children:[N.jsx("label",{className:"univer-text-sm univer-font-medium univer-text-gray-500",children:s.t("page-settings.top")}),N.jsx(q.InputNumber,{value:a.margins.top,onChange:d=>A("top",d)})]}),N.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-col univer-gap-2",children:[N.jsx("label",{className:"univer-text-sm univer-font-medium univer-text-gray-500",children:s.t("page-settings.bottom")}),N.jsx(q.InputNumber,{value:a.margins.bottom,onChange:d=>A("bottom",d)})]})]}),N.jsxs("div",{className:"univer-flex univer-gap-2.5",children:[N.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-col univer-gap-2",children:[N.jsx("label",{className:"univer-text-sm univer-font-medium univer-text-gray-500",children:s.t("page-settings.left")}),N.jsx(q.InputNumber,{value:a.margins.left,onChange:d=>A("left",d)})]}),N.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-col univer-gap-2",children:[N.jsx("label",{className:"univer-text-sm univer-font-medium univer-text-gray-500",children:s.t("page-settings.right")}),N.jsx(q.InputNumber,{value:a.margins.right,onChange:d=>A("right",d)})]})]})]})]})]})}const Zn="docs.component.page-setting",es={id:"docs.command.page-setup",type:i.CommandType.COMMAND,handler:(o,t)=>{if(!t)return!1;const e=o.get(i.IUniverInstanceService),n=o.get(i.ICommandService),r=e.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_DOC);if(!r)return!1;const{marginLeft:s,marginRight:a,marginBottom:c,marginTop:l,pageOrient:A,pageSize:d}=t,u=i.JSONX.getInstance(),m=r.getDocumentStyle(),{marginBottom:g,marginLeft:h,marginRight:p,marginTop:f,pageOrient:S,pageSize:E}=m,C=[];if(g===void 0){const v=u.insertOp(["documentStyle","marginBottom"],c);v&&C.push(v)}else{const v=u.replaceOp(["documentStyle","marginBottom"],g,c);v&&C.push(v)}if(h===void 0){const v=u.insertOp(["documentStyle","marginLeft"],s);v&&C.push(v)}else{const v=u.replaceOp(["documentStyle","marginLeft"],h,s);v&&C.push(v)}if(p===void 0){const v=u.insertOp(["documentStyle","marginRight"],a);v&&C.push(v)}else{const v=u.replaceOp(["documentStyle","marginRight"],p,a);v&&C.push(v)}if(f===void 0){const v=u.insertOp(["documentStyle","marginTop"],l);v&&C.push(v)}else{const v=u.replaceOp(["documentStyle","marginTop"],f,l);v&&C.push(v)}if(E===void 0){const v=u.insertOp(["documentStyle","pageSize"],d);v&&C.push(v)}else{const v=u.replaceOp(["documentStyle","pageSize"],E,d);v&&C.push(v)}if(S===void 0){const v=u.insertOp(["documentStyle","pageOrient"],A);v&&C.push(v)}else{const v=u.replaceOp(["documentStyle","pageOrient"],S,A);v&&C.push(v)}const T={id:D.RichTextEditingMutation.id,params:{unitId:r.getUnitId(),actions:[],textRanges:void 0}};return T.params.actions=C.reduce((v,b)=>i.JSONX.compose(v,b),null),!!n.syncExecuteCommand(T.id,T.params)}},Xo={id:"docs.operation.open-page-setting",type:i.CommandType.OPERATION,handler:o=>{const t=o.get(I.IConfirmService),e=o.get(i.ICommandService),n=o.get(i.LocaleService),r=t.open({id:Zn,title:{label:n.t("page-settings.document-setting")},children:{label:Zn},width:528,onClose:()=>{r.dispose()},onConfirm:s=>{if(r.dispose(),!s)return;const a=i.PAGE_SIZE[s.paperSize];e.executeCommand(es.id,{pageOrient:s.orientation,marginTop:s.margins.top,marginBottom:s.margins.bottom,marginLeft:s.margins.left,marginRight:s.margins.right,pageSize:a})},confirmText:n.t("page-settings.confirm"),cancelText:n.t("page-settings.cancel")});return!0}};function sc(o){const t=o.get(i.IUniverInstanceService),e=o.get(B.IRenderManagerService);return new U.Observable(n=>{const r=t.focused$.subscribe(s=>{if(s==null||t.getUnitType(s)!==i.UniverInstanceType.UNIVER_DOC)return n.next(!0);const c=e.getRenderById(s);if(c==null)return n.next(!0);c.with(D.DocSkeletonManagerService).getViewModel().editAreaChange$.subscribe(A=>{n.next(A===B.DocumentEditArea.HEADER||A===B.DocumentEditArea.FOOTER)})});return()=>r.unsubscribe()})}function ac(o){const t=o.get(i.IUniverInstanceService),e=o.get(i.ICommandService);return new U.Observable(n=>{const r=e.onCommandExecuted(l=>{if(l.id===D.RichTextEditingMutation.id){const{unitId:A}=l.params,d=t.getUnit(A);if(d==null){n.next(!0);return}const{documentStyle:u}=d.getSnapshot();n.next((u==null?void 0:u.documentFlavor)!==i.DocumentFlavor.TRADITIONAL)}}),s=t.focused$.subscribe(l=>{if(l==null)return n.next(!0);const A=t.getUniverDocInstance(l),d=A==null?void 0:A.getSnapshot().documentStyle.documentFlavor;n.next(d!==i.DocumentFlavor.TRADITIONAL)}),a=t.getCurrentUniverDocInstance();if(a==null)return n.next(!0);const c=a==null?void 0:a.getSnapshot().documentStyle.documentFlavor;return n.next(c!==i.DocumentFlavor.TRADITIONAL),()=>{r.dispose(),s.unsubscribe()}})}function cc(o){const t=o.get(D.DocSelectionManagerService),e=o.get(i.IUniverInstanceService);return new U.Observable(n=>{const r=t.textSelection$.subscribe(s=>{if(s==null){n.next(!0);return}const{textRanges:a}=s;if(a.length!==1){n.next(!0);return}const c=a[0],{collapsed:l,startNodePosition:A,startOffset:d}=c;if(!l||d==null){n.next(!0);return}const u=e.getCurrentUniverDocInstance();if(u==null){n.next(!0);return}const m=ce(o,u.getUnitId());if(m==null){n.next(!0);return}if(m.getViewModel().getCustomRangeRaw(d)){n.next(!0);return}if(A!=null){const{path:p}=A;if(p.indexOf("cells")!==-1){n.next(!0);return}}n.next(!1)});return()=>r.unsubscribe()})}function ee(o){const t=o.get(D.DocSelectionManagerService);return new U.Observable(e=>{const n=t.textSelection$.subscribe(r=>{if(r==null){e.next(!0);return}const{textRanges:s,rectRanges:a}=r;if(s.length===0&&a.length===0){e.next(!0);return}e.next(!1)});return()=>n.unsubscribe()})}function lc(o){const t=o.get(i.ICommandService);return{id:_e.id,type:I.MenuItemType.BUTTON,icon:"BoldIcon",title:"Set bold",tooltip:"toolbar.bold",activated$:new U.Observable(e=>{const n=()=>{var c;const s=Le(o);if(s==null){e.next(!1);return}const a=(c=s.ts)==null?void 0:c.bl;e.next(a===i.BooleanNumber.TRUE)},r=t.onCommandExecuted(s=>{const a=s.id;(a===D.SetTextSelectionsOperation.id||a===be.id)&&n()});return n(),r.dispose}),disabled$:ee(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function dc(o){const t=o.get(i.ICommandService);return{id:Ne.id,type:I.MenuItemType.BUTTON,icon:"ItalicIcon",title:"Set italic",tooltip:"toolbar.italic",activated$:new U.Observable(e=>{const n=()=>{var c;const s=Le(o);if(s==null){e.next(!1);return}const a=(c=s.ts)==null?void 0:c.it;e.next(a===i.BooleanNumber.TRUE)},r=t.onCommandExecuted(s=>{const a=s.id;(a===D.SetTextSelectionsOperation.id||a===be.id)&&n()});return n(),r.dispose}),disabled$:ee(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function Ac(o){const t=o.get(i.ICommandService);return{id:Pe.id,type:I.MenuItemType.BUTTON,icon:"UnderlineIcon",title:"Set underline",tooltip:"toolbar.underline",activated$:new U.Observable(e=>{const n=()=>{var c;const s=Le(o);if(s==null){e.next(!1);return}const a=(c=s.ts)==null?void 0:c.ul;e.next((a==null?void 0:a.s)===i.BooleanNumber.TRUE)},r=t.onCommandExecuted(s=>{const a=s.id;(a===D.SetTextSelectionsOperation.id||a===be.id)&&n()});return n(),r.dispose}),disabled$:ee(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function uc(o){const t=o.get(i.ICommandService);return{id:we.id,type:I.MenuItemType.BUTTON,icon:"StrikethroughIcon",title:"Set strike through",tooltip:"toolbar.strikethrough",activated$:new U.Observable(e=>{const n=()=>{var c;const s=Le(o);if(s==null){e.next(!1);return}const a=(c=s.ts)==null?void 0:c.st;e.next((a==null?void 0:a.s)===i.BooleanNumber.TRUE)},r=t.onCommandExecuted(s=>{const a=s.id;(a===D.SetTextSelectionsOperation.id||a===be.id)&&n()});return n(),r.dispose}),disabled$:ee(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function gc(o){const t=o.get(i.ICommandService);return{id:ye.id,type:I.MenuItemType.BUTTON,icon:"SubscriptIcon",tooltip:"toolbar.subscript",activated$:new U.Observable(e=>{const n=()=>{var c;const s=Le(o);if(s==null){e.next(!1);return}const a=(c=s.ts)==null?void 0:c.va;e.next(a===i.BaselineOffset.SUBSCRIPT)},r=t.onCommandExecuted(s=>{const a=s.id;(a===D.SetTextSelectionsOperation.id||a===be.id)&&n()});return n(),r.dispose}),disabled$:ee(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function hc(o){const t=o.get(i.ICommandService);return{id:Ue.id,type:I.MenuItemType.BUTTON,icon:"SuperscriptIcon",tooltip:"toolbar.superscript",activated$:new U.Observable(e=>{const n=()=>{var c;const s=Le(o);if(s==null){e.next(!1);return}const a=(c=s.ts)==null?void 0:c.va;e.next(a===i.BaselineOffset.SUPERSCRIPT)},r=t.onCommandExecuted(s=>{const a=s.id;(a===D.SetTextSelectionsOperation.id||a===be.id)&&n()});return n(),r.dispose}),disabled$:ee(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function mc(o){const t=o.get(i.ICommandService);return{id:Ge.id,tooltip:"toolbar.font",type:I.MenuItemType.SELECTOR,label:I.FONT_FAMILY_COMPONENT,selections:I.FONT_FAMILY_LIST.map(e=>({label:{name:I.FONT_FAMILY_ITEM_COMPONENT},value:e.value})),value$:new U.Observable(e=>{const n=i.DEFAULT_STYLES.ff,r=()=>{var l;const a=Le(o);if(a==null){e.next(n);return}const c=(l=a.ts)==null?void 0:l.ff;e.next(c!=null?c:n)},s=t.onCommandExecuted(a=>{const c=a.id;(c===D.SetTextSelectionsOperation.id||c===Ge.id)&&r()});return r(),s.dispose}),disabled$:ee(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function pc(o){const t=o.get(i.ICommandService);return{id:me.id,type:I.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:I.FONT_SIZE_COMPONENT,props:{min:1,max:400}},selections:I.FONT_SIZE_LIST,value$:new U.Observable(e=>{const n=i.DEFAULT_STYLES.fs,r=()=>{var l;const a=Le(o);if(a==null){e.next(n);return}const c=(l=a.ts)==null?void 0:l.fs;e.next(c!=null?c:n)},s=t.onCommandExecuted(a=>{const c=a.id;(c===D.SetTextSelectionsOperation.id||c===me.id)&&r()});return r(),s.dispose}),disabled$:ee(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function fc(o){const t=o.get(i.ICommandService);return{id:le.id,type:I.MenuItemType.SELECTOR,tooltip:"toolbar.heading.tooltip",label:{name:I.COMMON_LABEL_COMPONENT,props:{selections:I.HEADING_LIST}},selections:I.HEADING_LIST.map(e=>({label:{name:I.HEADING_ITEM_COMPONENT,props:{value:e.value,text:e.label}},value:e.value})),value$:new U.Observable(e=>{const n=i.NamedStyleType.NORMAL_TEXT,r=()=>{var l,A;const a=Ke(o);if(a==null){e.next(n);return}const c=(A=(l=a.paragraphStyle)==null?void 0:l.namedStyleType)!=null?A:n;e.next(c)},s=t.onCommandExecuted(a=>{const c=a.id;(c===D.SetTextSelectionsOperation.id||c===me.id)&&r()});return r(),s.dispose}),disabled$:ee(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function Sc(o){const t=o.get(i.ICommandService),e=o.get(i.ThemeService);return{id:Me.id,icon:"FontColorDoubleIcon",tooltip:"toolbar.textColor.main",type:I.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:I.COLOR_PICKER_COMPONENT,hoverable:!1,selectable:!1}}],value$:new U.Observable(n=>{const r=e.getColorFromTheme("gray.900"),s=t.onCommandExecuted(a=>{if(a.id===Me.id){const c=a.params.value;n.next(c!=null?c:r)}});return n.next(r),s.dispose}),disabled$:ee(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function Ic(o){return{id:Io.id,type:I.MenuItemType.BUTTON,icon:"HeaderFooterIcon",tooltip:"toolbar.headerFooter",hidden$:U.combineLatest(I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC,void 0,i.DOCS_ZEN_EDITOR_UNIT_ID_KEY),ac(o),(t,e)=>t||e)}}const vc="GridIcon",ts="doc.menu.table";function Ec(o){return{id:ts,type:I.MenuItemType.SUBITEMS,icon:vc,tooltip:"toolbar.table.main",disabled$:cc(o),hidden$:U.combineLatest(I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC,void 0,i.DOCS_ZEN_EDITOR_UNIT_ID_KEY),sc(o),(t,e)=>t||e)}}function Cc(o){return{id:vn.id,title:"toolbar.table.insert",type:I.MenuItemType.BUTTON,hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function Tc(o){const t=o.get(i.ICommandService);return{id:Ot.id,type:I.MenuItemType.BUTTON,icon:"LeftJustifyingIcon",tooltip:"toolbar.alignLeft",disabled$:ee(o),activated$:new U.Observable(e=>{const n=t.onCommandExecuted(r=>{var a;const s=r.id;if(s===D.SetTextSelectionsOperation.id||s===pe.id){const c=Ke(o);if(c==null)return;const l=(a=c.paragraphStyle)==null?void 0:a.horizontalAlign;e.next(l===i.HorizontalAlign.LEFT)}});return e.next(!1),n.dispose}),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC,void 0,i.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}}function yc(o){const t=o.get(i.ICommandService);return{id:Mt.id,type:I.MenuItemType.BUTTON,icon:"HorizontallyIcon",tooltip:"toolbar.alignCenter",activated$:new U.Observable(e=>{const n=t.onCommandExecuted(r=>{var a;const s=r.id;if(s===D.SetTextSelectionsOperation.id||s===pe.id){const c=Ke(o);if(c==null)return;const l=(a=c.paragraphStyle)==null?void 0:a.horizontalAlign;e.next(l===i.HorizontalAlign.CENTER)}});return e.next(!1),n.dispose}),disabled$:ee(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC,void 0,i.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}}function bc(o){const t=o.get(i.ICommandService);return{id:Dt.id,type:I.MenuItemType.BUTTON,icon:"RightJustifyingIcon",tooltip:"toolbar.alignRight",activated$:new U.Observable(e=>{const n=t.onCommandExecuted(r=>{var a;const s=r.id;if(s===D.SetTextSelectionsOperation.id||s===pe.id){const c=Ke(o);if(c==null)return;const l=(a=c.paragraphStyle)==null?void 0:a.horizontalAlign;e.next(l===i.HorizontalAlign.RIGHT)}});return e.next(!1),n.dispose}),disabled$:ee(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC,void 0,i.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}}function Rc(o){const t=o.get(i.ICommandService);return{id:Bt.id,type:I.MenuItemType.BUTTON,icon:"AlignTextBothIcon",tooltip:"toolbar.alignJustify",activated$:new U.Observable(e=>{const n=t.onCommandExecuted(r=>{var a;const s=r.id;if(s===D.SetTextSelectionsOperation.id||s===pe.id){const c=Ke(o);if(c==null)return;const l=(a=c.paragraphStyle)==null?void 0:a.horizontalAlign;e.next(l===i.HorizontalAlign.JUSTIFIED)}});return e.next(!1),n.dispose}),disabled$:ee(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC,void 0,i.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}}function xc(o){return{id:Rt.id,type:I.MenuItemType.BUTTON,icon:"ReduceIcon",tooltip:"toolbar.horizontalLine",disabled$:ee(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC,void 0,i.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}}const Ct=o=>new U.Observable(t=>{const e=o.get(i.IUniverInstanceService),n=o.get(D.DocSelectionManagerService);let r;const s=e.focused$.subscribe(a=>{if(r==null||r.unsubscribe(),a==null)return;const c=e.getUniverDocInstance(a);c!=null&&(r=n.textSelection$.subscribe(()=>{var d,u,m,g,h;const l=n.getDocRanges(),A=(d=l.find(p=>p.isActive))!=null?d:l[0];if(A){const p=c.getSelfOrHeaderFooterModel(A==null?void 0:A.segmentId),f=i.BuildTextUtils.range.getParagraphsInRange(A,(m=(u=p.getBody())==null?void 0:u.paragraphs)!=null?m:[],(h=(g=p.getBody())==null?void 0:g.dataStream)!=null?h:"");let S;if(f.every(E=>{var C;return S||(S=(C=E.bullet)==null?void 0:C.listType),E.bullet&&E.bullet.listType===S})){t.next(S);return}}t.next(void 0)}))});return()=>{s.unsubscribe(),r==null||r.unsubscribe()}});function Mr(o){return{id:ot.id,type:I.MenuItemType.BUTTON_SELECTOR,slot:!0,selections:[{label:{name:Pi,hoverable:!1,selectable:!1},value$:Ct(o)}],icon:"OrderIcon",tooltip:"toolbar.order",hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC),disabled$:ee(o),activated$:Ct(o).pipe(U.map(t=>!!(t&&t.indexOf("ORDER_LIST")===0)))}}function Dr(o){return{id:nt.id,type:I.MenuItemType.BUTTON_SELECTOR,slot:!0,selections:[{label:{name:wi,hoverable:!1,selectable:!1},value$:Ct(o)}],icon:"UnorderIcon",tooltip:"toolbar.unorder",disabled$:ee(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC),activated$:Ct(o).pipe(U.map(t=>!!(t&&t.indexOf("BULLET_LIST")===0)))}}function Br(o){return{id:Et.id,type:I.MenuItemType.BUTTON,icon:"TodoListDoubleIcon",tooltip:"toolbar.checklist",disabled$:ee(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC),activated$:Ct(o).pipe(U.map(t=>!!(t&&t.indexOf("CHECK_LIST")===0)))}}function Oc(o){const t=o.get(i.ICommandService),e=o.get(i.IUniverInstanceService);return{id:_t.id,type:I.MenuItemType.BUTTON,icon:"KeyboardIcon",tooltip:"toolbar.documentFlavor",hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC,void 0,i.DOCS_ZEN_EDITOR_UNIT_ID_KEY),activated$:new U.Observable(n=>{var a;const r=t.onCommandExecuted(c=>{var l;if(c.id===D.RichTextEditingMutation.id){const A=e.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC);n.next(((l=A==null?void 0:A.getSnapshot())==null?void 0:l.documentStyle.documentFlavor)===i.DocumentFlavor.MODERN)}}),s=e.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC);return n.next(((a=s==null?void 0:s.getSnapshot())==null?void 0:a.documentStyle.documentFlavor)===i.DocumentFlavor.MODERN),()=>r.dispose()})}}function Mc(o){return{id:st.id,type:I.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColorDoubleIcon"}}function Dc(o){const t=o.get(i.ICommandService),e=o.get(i.ThemeService);return{id:De.id,tooltip:"toolbar.fillColor.main",type:I.MenuItemType.BUTTON_SELECTOR,icon:"PaintBucketDoubleIcon",selections:[{label:{name:I.COLOR_PICKER_COMPONENT,hoverable:!1,selectable:!1}}],value$:new U.Observable(n=>{const r=e.getColorFromTheme("primary.600"),s=t.onCommandExecuted(a=>{if(a.id===De.id){const c=a.params.value;n.next(c!=null?c:r)}});return n.next(r),s.dispose}),disabled$:ee(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function Le(o){var h,p,f,S;const t=o.get(i.IUniverInstanceService),e=o.get(D.DocSelectionManagerService),n=o.get(Te),r=t.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC),s=e.getDocRanges(),a=(h=s.find(E=>E.isActive))!=null?h:s[0],c=n.getDefaultStyle(),l=(p=n.getStyleCache())!=null?p:{},A=Ke(o),d=(f=A==null?void 0:A.paragraphStyle)!=null&&f.namedStyleType?i.NAMED_STYLE_MAP[(S=A==null?void 0:A.paragraphStyle)==null?void 0:S.namedStyleType]:null;if(r==null||a==null)return{ts:{...c,...d,...l}};const{segmentId:u}=a,m=r.getSelfOrHeaderFooterModel(u).getBody();if(m==null)return{ts:{...c,...d,...l}};const g=Yi(m,a,{});return i.Tools.deleteNull(g),{ts:{...c,...d,...g,...l}}}function Ke(o){var d,u;const t=o.get(i.IUniverInstanceService),e=o.get(D.DocSelectionManagerService),n=t.getCurrentUniverDocInstance(),r=e.getDocRanges(),s=(d=r.find(m=>m.isActive))!=null?d:r[0];if(n==null||s==null)return;const{startOffset:a,segmentId:c}=s,l=(u=n.getSelfOrHeaderFooterModel(c).getBody())==null?void 0:u.paragraphs;if(l==null)return;let A=-1;for(const m of l){const{startIndex:g}=m;if(a>A&&a<=g)return m;A=g}return null}function Bc(o){return{id:Xo.id,type:I.MenuItemType.BUTTON,icon:"DocumentSettingIcon",tooltip:"toolbar.pageSetup",hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}const _c={[i.NamedStyleType.HEADING_1]:Ho,[i.NamedStyleType.HEADING_2]:ko,[i.NamedStyleType.HEADING_3]:Vo,[i.NamedStyleType.HEADING_4]:jo,[i.NamedStyleType.HEADING_5]:Wo,[i.NamedStyleType.NORMAL_TEXT]:qt,[i.NamedStyleType.TITLE]:Ji,[i.NamedStyleType.SUBTITLE]:Zi,[i.NamedStyleType.NAMED_STYLE_TYPE_UNSPECIFIED]:qt},ns={[i.NamedStyleType.HEADING_1]:{key:"H1Icon",component:vi},[i.NamedStyleType.HEADING_2]:{key:"H2Icon",component:Ei},[i.NamedStyleType.HEADING_3]:{key:"H3Icon",component:Ci},[i.NamedStyleType.HEADING_4]:{key:"H4Icon",component:Ti},[i.NamedStyleType.HEADING_5]:{key:"H5Icon",component:yi},[i.NamedStyleType.NORMAL_TEXT]:{key:"TextTypeIcon",component:pt},[i.NamedStyleType.TITLE]:{key:"TextTypeIcon",component:pt},[i.NamedStyleType.SUBTITLE]:{key:"TextTypeIcon",component:pt},[i.NamedStyleType.NAMED_STYLE_TYPE_UNSPECIFIED]:{key:"TextTypeIcon",component:pt}},Qe=o=>t=>{const e=t.get(i.ICommandService),n=t.get(I.ComponentManager),r=ns[o];return n.get(r.key)||n.register(r.key,r.component),{id:_c[o].id,type:I.MenuItemType.BUTTON,icon:r.key,tooltip:"toolbar.heading.tooltip",disabled$:ee(t),hidden$:I.getMenuHiddenObservable(t,i.UniverInstanceType.UNIVER_DOC),activated$:new U.Observable(s=>{const a=i.NamedStyleType.NORMAL_TEXT,c=()=>{var u,m;const A=Ke(t);if(A==null){s.next(a===o);return}const d=(m=(u=A.paragraphStyle)==null?void 0:u.namedStyleType)!=null?m:a;s.next(d===o)},l=e.onCommandExecuted(A=>{const d=A.id;(d===D.SetTextSelectionsOperation.id||d===me.id)&&c()});return c(),l.dispose})}},Nc=Qe(i.NamedStyleType.HEADING_1),Pc=Qe(i.NamedStyleType.HEADING_2),wc=Qe(i.NamedStyleType.HEADING_3),Uc=Qe(i.NamedStyleType.HEADING_4),Lc=Qe(i.NamedStyleType.HEADING_5),Qc=Qe(i.NamedStyleType.NORMAL_TEXT);Qe(i.NamedStyleType.TITLE);Qe(i.NamedStyleType.SUBTITLE);const Fc=o=>({id:Do.id,type:I.MenuItemType.BUTTON,icon:"CopyDoubleIcon",title:"rightClick.copy"}),Hc=o=>({id:Bo.id,type:I.MenuItemType.BUTTON,icon:"CutIcon",title:"rightClick.cut"}),kc=o=>({id:xo.id,type:I.MenuItemType.BUTTON,icon:"DeleteIcon",title:"rightClick.delete"}),Vc=o=>({id:Lo.id,type:I.MenuItemType.BUTTON,icon:"UnorderIcon",title:"rightClick.bulletList"}),jc=o=>({id:Qo.id,type:I.MenuItemType.BUTTON,icon:"OrderIcon",title:"rightClick.orderList"}),Wc=o=>({id:Fo.id,type:I.MenuItemType.BUTTON,icon:"TodoListDoubleIcon",title:"rightClick.checkList"}),Gc=o=>({id:No.id,type:I.MenuItemType.BUTTON,icon:"ReduceIcon",title:"toolbar.horizontalLine"}),os="doc.menu.insert-bellow";function Xc(o){return{id:os,type:I.MenuItemType.SUBITEMS,title:"rightClick.insertBellow"}}const $n=4,Kc=(o,t)=>{const e=o.get(i.IUniverInstanceService).getUniverDocInstance(t.unitId),n=(e==null?void 0:e.zoomRatio)||1;return{...i.Tools.deepClone(t),zoomRatio:n}},Ae={id:"doc.operation.set-zoom-ratio",type:i.CommandType.OPERATION,handler:(o,t)=>{const e=o.get(i.IUniverInstanceService).getUniverDocInstance(t.unitId);if(!e)return!1;const n=e.getSnapshot();return n.settings==null?n.settings={zoomRatio:t.zoomRatio}:n.settings.zoomRatio=t.zoomRatio,!0}};var zc=Object.getOwnPropertyDescriptor,Yc=(o,t,e,n)=>{for(var r=n>1?void 0:n?zc(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Lt=(o,t)=>(e,n)=>t(e,n,o);function rs(o,t){const e=_r(o.left,o.top,t),n=_r(o.right,o.bottom,t);return{left:e.x,top:e.y,right:n.x,bottom:n.y}}function _r(o,t,e){const{scaleX:n,scaleY:r}=e.getAncestorScale(),s=e.getViewport(ie.VIEW_MAIN);if(!s)return{x:o,y:t};const{viewportScrollX:a,viewportScrollY:c}=s,l=(o-a)*n,A=(t-c)*r;return{x:l,y:A}}function Nr(o,t,e){const{scaleX:n,scaleY:r}=e.getAncestorScale(),s=e.getViewport(ie.VIEW_MAIN);if(!s)return{x:o,y:t};const{viewportScrollX:a,viewportScrollY:c}=s,l=o/n+a,A=t/r+c;return{x:l,y:A}}const Xt=(o,t)=>{const{scene:e,mainComponent:n,engine:r}=t,s=t.with(D.DocSkeletonManagerService).getSkeleton(),a=s.findNodePositionByCharIndex(o.startOffset,!0,o.segmentId,o.segmentPage),c=o.collapsed?o.startOffset:o.endOffset-1,l=s.findNodePositionByCharIndex(c,!0,o.segmentId,o.segmentPage),A=n;if(!l||!a)return;const d=A.getOffsetConfig(),{docsLeft:u,docsTop:m}=d,g=r.getCanvasElement(),h=g.getBoundingClientRect(),p=B.pxToNum(g.style.width),{top:f,left:S,width:E}=h,C=E/p,{scaleX:T,scaleY:R}=e.getAncestorScale(),v=new ve(d,s),{borderBoxPointGroup:b}=v.getRangePointData(a,l);return cn(b).map(_=>rs(_,e)).map(_=>({left:(_.left+u*T)*C+S,right:(_.right+u*T)*C+S,top:(_.top+m*R)*C+f,bottom:(_.bottom+m*R)*C+f}))};exports.DocCanvasPopManagerService=class extends i.Disposable{constructor(t,e,n,r){super(),this._globalPopupManagerService=t,this._renderManagerService=e,this._univerInstanceService=n,this._commandService=r}_createRectPositionObserver(t,e){const n=()=>{const{scene:l,engine:A}=e,d=typeof t=="function"?t():t,u=A.getCanvasElement(),m=u.getBoundingClientRect(),g=B.pxToNum(u.style.width),h=rs(d,l),{top:p,left:f,width:S}=m,E=S/g;return{left:h.left*E+f,right:h.right*E+f,top:h.top*E+p,bottom:h.bottom*E+p}},r=n(),s=new U.BehaviorSubject(r),a=new i.DisposableCollection;a.add(this._commandService.onCommandExecuted(l=>{if(l.id===Ae.id||l.id===D.RichTextEditingMutation.id){const A=n();A&&s.next(A)}}));const c=e.scene.getViewport(ie.VIEW_MAIN);return c&&a.add(c.onScrollAfter$.subscribeEvent(()=>{s.next(n())})),{position:r,position$:s,disposable:a}}_createObjectPositionObserver(t,e){const n=()=>{const{left:r,top:s,width:a,height:c}=t;return{left:r,right:r+a,top:s,bottom:s+c}};return this._createRectPositionObserver(n,e)}_createRangePositionObserver(t,e){var c;const n=(c=Xt(t,e))!=null?c:[],r=new U.BehaviorSubject(n),s=new i.DisposableCollection;s.add(this._commandService.onCommandExecuted(l=>{if((l.id===Ae.id||l.id===D.RichTextEditingMutation.id)&&l.params.unitId===e.unitId){const d=Xt(t,e);d&&r.next(d)}}));const a=e.scene.getViewport(ie.VIEW_MAIN);return a&&s.add(a.onScrollAfter$.subscribeEvent(()=>{const l=Xt(t,e);l&&r.next(l)})),{positions:n,positions$:r,disposable:s}}attachPopupToRect(t,e,n){const r=this._renderManagerService.getRenderById(n);if(!r)throw new Error(`Current render not found, unitId: ${n}`);const{position:s,position$:a,disposable:c}=this._createRectPositionObserver(t,r),l=this._globalPopupManagerService.addPopup({...e,unitId:n,subUnitId:"default",anchorRect:s,anchorRect$:a,canvasElement:r.engine.getCanvasElement()});return{dispose:()=>{this._globalPopupManagerService.removePopup(l),a.complete(),c.dispose()},canDispose:()=>this._globalPopupManagerService.activePopupId!==l}}attachPopupToObject(t,e,n){const r=this._renderManagerService.getRenderById(n);if(!r)throw new Error(`Current render not found, unitId: ${n}`);const{position:s,position$:a,disposable:c}=this._createObjectPositionObserver(t,r),l=this._globalPopupManagerService.addPopup({...e,unitId:n,subUnitId:"default",anchorRect:s,anchorRect$:a,canvasElement:r.engine.getCanvasElement()});return{dispose:()=>{this._globalPopupManagerService.removePopup(l),a.complete(),c.dispose()},canDispose:()=>this._globalPopupManagerService.activePopupId!==l}}attachPopupToRange(t,e,n){if(!this._univerInstanceService.getUnit(n))throw new Error(`Document not found, unitId: ${n}`);const{direction:s="top",multipleDirection:a}=e,c=this._renderManagerService.getRenderById(n);if(!c)throw new Error(`Current render not found, unitId: ${n}`);const{positions:l,positions$:A,disposable:d}=this._createRangePositionObserver(t,c),u=A.pipe(U.map(g=>s.includes("top")?g[0]:g[g.length-1])),m=this._globalPopupManagerService.addPopup({...e,unitId:n,subUnitId:"default",anchorRect:s.includes("top")?l[0]:l[l.length-1],anchorRect$:u,excludeRects:l,excludeRects$:A,direction:["top","bottom","horizontal"].some(g=>s.includes(g))&&l.length>1&&a!=null?a:s,canvasElement:c.engine.getCanvasElement()});return{dispose:()=>{this._globalPopupManagerService.removePopup(m),A.complete(),d.dispose()},canDispose:()=>this._globalPopupManagerService.activePopupId!==m}}};exports.DocCanvasPopManagerService=Yc([Lt(0,i.Inject(I.ICanvasPopupService)),Lt(1,B.IRenderManagerService),Lt(2,i.IUniverInstanceService),Lt(3,i.ICommandService)],exports.DocCanvasPopManagerService);var qc=Object.getOwnPropertyDescriptor,Jc=(o,t,e,n)=>{for(var r=n>1?void 0:n?qc(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Zc=(o,t)=>(e,n)=>t(e,n,o);const $c=(o,t,e,n)=>{var m,g,h,p,f;const r=e.findNodePositionByCharIndex(o.startOffset,!0,o.segmentId,n),s=e.getSkeletonData();let a=o.endOffset-1;if(o.segmentId){const S=(f=Array.from((g=(m=s==null?void 0:s.skeFooters.get(o.segmentId))==null?void 0:m.values())!=null?g:[])[0])!=null?f:Array.from((p=(h=s==null?void 0:s.skeHeaders.get(o.segmentId))==null?void 0:h.values())!=null?p:[])[0];S&&(a=Math.min(S.ed,a))}const c=e.findNodePositionByCharIndex(a,!0,o.segmentId,n);if(!c||!r)return;const l=t.getOffsetConfig(),A=new ve(l,e),{borderBoxPointGroup:d}=A.getRangePointData(r,c);return cn(d).map(S=>({top:S.top+l.docsTop-$n,bottom:S.bottom+l.docsTop+$n,left:S.left+l.docsLeft,right:S.right+l.docsLeft}))},Pr=(o,t,e,n)=>{const r=[];for(const s of o){const a=s.top;for(const c of s.columns){const l=c.left,A=s.colCount===1?n:c.width;let d=null;for(const u of c.lines){const m=u.paragraphIndex;if(u.paragraphStart){d&&(r.push(d),d=null);const g={top:t+a+u.top,left:e+l,right:e+l+A,bottom:t+a+u.top+u.lineHeight};d={paragraphStart:u.st,paragraphEnd:m,startIndex:m,rect:g,fisrtLine:{top:t+a+u.top+u.marginTop+u.paddingTop,left:e+l,right:e+l+A,bottom:t+a+u.top+u.marginTop+u.paddingTop+u.contentHeight}}}else d&&d.startIndex===m&&(d.rect.bottom=t+a+u.top+u.lineHeight)}d&&r.push(d)}}return r},el=(o,t,e,n=-1)=>{const r=e.findPositionByGlyph(o,n);if(!r)return;const s=t.getOffsetConfig(),a={...r,isBack:!0},c=new ve(s,e),{borderBoxPointGroup:l}=c.getRangePointData(a,a),d=cn(l)[0];return{top:d.top+s.docsTop,bottom:d.bottom+s.docsTop,left:d.left+s.docsLeft,right:d.left+s.docsLeft+o.width}};function He(o,t,e){const{left:n,right:r,top:s,bottom:a}=e;return o>=n&&o<=r&&t>=s&&t<=a}exports.DocEventManagerService=class extends i.Disposable{constructor(e,n){super();M(this,"_hoverCustomRanges$",new U.BehaviorSubject([]));M(this,"hoverCustomRanges$",this._hoverCustomRanges$.pipe(U.distinctUntilChanged((e,n)=>e.length===n.length&&e.every((r,s)=>n[s].range.rangeId===r.range.rangeId&&n[s].segmentId===r.segmentId&&n[s].segmentPageIndex===r.segmentPageIndex&&n[s].range.startIndex===r.range.startIndex))));M(this,"_clickCustomRanges$",new U.Subject);M(this,"clickCustomRanges$",this._clickCustomRanges$.asObservable());M(this,"_hoverBullet$",new U.Subject);M(this,"hoverBullet$",this._hoverBullet$.pipe(U.distinctUntilChanged((e,n)=>(e==null?void 0:e.paragraph.startIndex)===(n==null?void 0:n.paragraph.startIndex)&&(e==null?void 0:e.segmentId)===(n==null?void 0:n.segmentId)&&(e==null?void 0:e.segmentPageIndex)===(n==null?void 0:n.segmentPageIndex))));M(this,"_clickBullet$",new U.Subject);M(this,"clickBullets$",this._clickBullet$.asObservable());M(this,"_hoverParagraph$",new U.BehaviorSubject(null));M(this,"hoverParagraph$",this._hoverParagraph$.pipe(U.distinctUntilChanged((e,n)=>(e==null?void 0:e.startIndex)===(n==null?void 0:n.startIndex)&&(e==null?void 0:e.segmentId)===(n==null?void 0:n.segmentId)&&(e==null?void 0:e.pageIndex)===(n==null?void 0:n.pageIndex))));M(this,"hoverParagraphRealTime$",this._hoverParagraph$.asObservable());M(this,"_hoverParagraphLeft$",new U.BehaviorSubject(null));M(this,"hoverParagraphLeft$",this._hoverParagraphLeft$.pipe(U.distinctUntilChanged((e,n)=>(e==null?void 0:e.startIndex)===(n==null?void 0:n.startIndex)&&(e==null?void 0:e.segmentId)===(n==null?void 0:n.segmentId)&&(e==null?void 0:e.pageIndex)===(n==null?void 0:n.pageIndex))));M(this,"hoverParagraphLeftRealTime$",this._hoverParagraphLeft$.asObservable());M(this,"_hoverTableCell$",new U.Subject);M(this,"hoverTableCell$",this._hoverTableCell$.pipe(U.distinctUntilChanged((e,n)=>(e==null?void 0:e.rowIndex)===(n==null?void 0:n.rowIndex)&&(e==null?void 0:e.colIndex)===(n==null?void 0:n.colIndex)&&(e==null?void 0:e.tableId)===(n==null?void 0:n.tableId)&&(e==null?void 0:e.pageIndex)===(n==null?void 0:n.pageIndex))));M(this,"hoverTableCellRealTime$",this._hoverTableCell$.asObservable());M(this,"_hoverTable$",new U.Subject);M(this,"hoverTable$",this._hoverTable$.pipe(U.distinctUntilChanged((e,n)=>(e==null?void 0:e.tableId)===(n==null?void 0:n.tableId)&&(e==null?void 0:e.pageIndex)===(n==null?void 0:n.pageIndex))));M(this,"hoverTableRealTime$",this._hoverTable$.asObservable());M(this,"_customRangeDirty",!0);M(this,"_bulletDirty",!0);M(this,"_paragraphDirty",!0);M(this,"_customRangeBounds",[]);M(this,"_bulletBounds",[]);M(this,"_paragraphBounds",new Map);M(this,"_paragraphLeftBounds",[]);M(this,"_tableParagraphBounds",new Map);M(this,"_segmentParagraphBounds",new Map);M(this,"_tableCellBounds",new Map);M(this,"_tableBounds",new Map);this._context=e,this._docSkeletonManagerService=n,this._initResetDirty(),this._initEvents(),this._initPointer()}get hoverParagraph(){return this._hoverParagraph$.value}get hoverParagraphLeft(){return this._hoverParagraphLeft$.value}get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}get _documents(){return this._context.mainComponent}dispose(){this._hoverCustomRanges$.complete(),this._clickCustomRanges$.complete(),super.dispose()}_initPointer(){let e=B.CURSOR_TYPE.TEXT;this.disposeWithMe(this.hoverCustomRanges$.subscribe(n=>{n.length?(e=this._context.scene.getCursor(),this._context.scene.setCursor(B.CURSOR_TYPE.POINTER)):this._context.scene.setCursor(e)}))}_initResetDirty(){this.disposeWithMe(this._skeleton.dirty$.subscribe(()=>{this._customRangeDirty=!0,this._bulletDirty=!0,this._paragraphDirty=!0})),this.disposeWithMe(i.fromEventSubject(this._context.engine.onTransformChange$).pipe(U.filter(e=>e.type===B.TRANSFORM_CHANGE_OBSERVABLE_TYPE.resize)).subscribe(()=>{this._customRangeDirty=!0,this._bulletDirty=!0,this._paragraphDirty=!0}))}_initEvents(){this.disposeWithMe(i.fromEventSubject(this._context.scene.onPointerMove$).pipe(U.throttleTime(30)).subscribe(r=>{if(r.buttons>0){this._hoverBullet$.next(null),this._hoverCustomRanges$.next([]),this._hoverParagraph$.next(null),this._hoverParagraphLeft$.next(null),this._hoverTableCell$.next(null),this._hoverTable$.next(null);return}const{x:s,y:a}=Nr(r.offsetX,r.offsetY,this._context.scene);this._hoverCustomRanges$.next(this._calcActiveRanges({x:s,y:a})),this._hoverParagraph$.next(this._calcActiveParagraph({x:s,y:a})),this._hoverParagraphLeft$.next(this._calcActiveParagraphLeft({x:s,y:a})),this._hoverBullet$.next(this._calcActiveBullet({x:s,y:a}))})),this.disposeWithMe(this._context.scene.onPointerEnter$.subscribeEvent(()=>{this._hoverBullet$.next(null),this._hoverCustomRanges$.next([])}));const e=i.fromEventSubject(this._context.mainComponent.onPointerDown$),n=i.fromEventSubject(this._context.scene.onPointerUp$);this.disposeWithMe(e.pipe(U.switchMap(r=>n.pipe(U.take(1),U.map(s=>({down:r,up:s})))),U.filter(({down:r,up:s})=>r.target===s.target&&s.timeStamp-r.timeStamp<300)).subscribe(({down:r})=>{if(r.button===2)return;const s=Nr(r.offsetX,r.offsetY,this._context.scene),a=this._calcActiveRanges(s);a.length&&this._clickCustomRanges$.next(a.pop());const c=this._calcActiveBullet(s);c&&this._clickBullet$.next(c)}))}_buildCustomRangeBoundsBySegment(e,n=-1){var a,c,l;const r=(l=(c=(a=this._context.unit.getSelfOrHeaderFooterModel(e))==null?void 0:a.getBody())==null?void 0:c.customRanges)!=null?l:[],s=[];return r.forEach(A=>{const d={startOffset:A.startIndex,endOffset:A.endIndex+1,segmentId:e},u=$c(d,this._documents,this._skeleton,n);if(!u)return null;s.push({customRange:A,rects:u,segmentId:e,segmentPageIndex:n})}),s}_buildCustomRangeBounds(){var n;if(!this._customRangeDirty)return;this._customRangeDirty=!1;const e=[];e.push(...this._buildCustomRangeBoundsBySegment()),(n=this._skeleton.getSkeletonData())==null||n.pages.forEach((r,s)=>{r.headerId&&e.push(...this._buildCustomRangeBoundsBySegment(r.headerId,s)),r.footerId&&e.push(...this._buildCustomRangeBoundsBySegment(r.footerId,s))}),this._customRangeBounds=e}_calcActiveRanges(e){this._buildCustomRangeBounds();const{x:n,y:r}=e;return this._customRangeBounds.filter(a=>a.rects.some(c=>He(n,r,c))).map(a=>({segmentId:a.segmentId,range:a.customRange,segmentPageIndex:a.segmentPageIndex,rects:a.rects}))}_buildBulletBoundsBySegment(e,n=-1){var A,d,u,m,g;const r=(A=this._context.unit.getSelfOrHeaderFooterModel(e))==null?void 0:A.getBody(),s=((d=r==null?void 0:r.paragraphs)!=null?d:[]).filter(h=>h.bullet&&h.bullet.listType.indexOf("CHECK_LIST")===0),a=[],c=this._skeleton.getSkeletonData();if(!c)return a;const l=h=>{var p,f,S;for(const E of h){const C=[...E.sections];if(E.skeTables){const T=Array.from(E.skeTables.values());C.push(...T.map(R=>R.rows.map(v=>v.cells.map(b=>b.sections))).flat(4))}for(const T of C)for(const R of T.columns)for(const v of R.lines)if(v.paragraphStart){const b=s.find(x=>x.startIndex===v.paragraphIndex);if(b){const x=v,y=(S=(f=(p=x==null?void 0:x.divides)==null?void 0:p[0])==null?void 0:f.glyphGroup)==null?void 0:S[0];if(!y)continue;const _=el(y,this._documents,this._skeleton,n);if(!_)continue;a.push({rect:_,segmentId:e,segmentPageIndex:n,paragraph:b})}}}return a};if(e){const h=(g=(u=c.skeFooters.get(e))==null?void 0:u.values())!=null?g:(m=c.skeHeaders.get(e))==null?void 0:m.values();return h?l(Array.from(h)):a}return l(c.pages)}_buildBulletBounds(){var e;this._bulletDirty&&(this._bulletDirty=!1,this._bulletBounds=[],this._bulletBounds.push(...this._buildBulletBoundsBySegment()),(e=this._skeleton.getSkeletonData())==null||e.pages.forEach((n,r)=>{n.headerId&&this._bulletBounds.push(...this._buildBulletBoundsBySegment(n.headerId,r)),n.footerId&&this._bulletBounds.push(...this._buildBulletBoundsBySegment(n.footerId,r))}))}_calcActiveBullet(e){this._buildBulletBounds();const{x:n,y:r}=e;return this._bulletBounds.find(a=>He(n,r,a.rect))}_buildParagraphBoundsBySegment(e){var c,l,A;const n=this._skeleton.getSkeletonData(),s=this._documents.getOffsetConfig();if(!n)return null;const a=d=>{const u=new Map,m=(g,h,p,f)=>{Pr(g.sections,p,f,g.pageWidth-g.marginLeft-g.marginRight).forEach(E=>{if(!u.has(E.startIndex))u.set(E.startIndex,{rect:E.rect,paragraphStart:E.paragraphStart,paragraphEnd:E.paragraphEnd,startIndex:E.startIndex,rects:[E.rect],pageIndex:h,segmentId:e,firstLine:E.fisrtLine});else{const C=u.get(E.startIndex);C&&(C.rect.bottom=E.rect.bottom,C.rects.push(E.rect))}})};for(let g=0;g<d.length;g++){const h=d[g],p=((h.pageHeight===1/0?0:h.pageHeight)+s.pageMarginTop)*g+h.marginTop+s.docsTop,f=h.marginLeft+s.docsLeft;h.skeTables&&Array.from(h.skeTables.values()).forEach(S=>{const E=S.left+f,C=S.top+p,T=E+S.width,R=C+S.height,v=S.tableId;this._tableBounds.set(v,{rect:{left:E,top:C,right:T,bottom:R},pageIndex:g,tableId:v}),S.rows.forEach((b,x)=>{b.cells.forEach((y,_)=>{const O=((h.pageHeight===1/0?0:h.pageHeight)+s.pageMarginTop)*g+S.top+s.docsTop+h.marginTop+b.top+y.marginTop,w=S.left+s.docsLeft+h.marginLeft+y.left+y.marginLeft,Q=Pr(y.sections,O,w,y.pageWidth-y.marginLeft-y.marginRight);let k=this._tableParagraphBounds.get(v);k||(k=[],this._tableParagraphBounds.set(v,k)),k.push(...Q.map(L=>({rect:L.rect,paragraphStart:L.paragraphStart,paragraphEnd:L.paragraphEnd,startIndex:L.startIndex,pageIndex:g,segmentId:e,rowIndex:x,colIndex:_,firstLine:L.fisrtLine,tableId:v})));let F=this._tableCellBounds.get(v);F||(F=[],this._tableCellBounds.set(v,F)),F.push({rect:{top:O,left:w,right:w+y.pageWidth-y.marginLeft-y.marginRight,bottom:O+y.pageHeight-y.marginBottom-y.marginTop},pageIndex:g,rowIndex:x,colIndex:_,tableId:v})})})}),m(h,g,p,f)}return u};if(e){const d=(A=(c=n.skeFooters.get(e))==null?void 0:c.values())!=null?A:(l=n.skeHeaders.get(e))==null?void 0:l.values();return d?a(Array.from(d)):null}return a(n.pages)}_buildParagraphBounds(){var n,r;if(!this._paragraphDirty)return;this._paragraphDirty=!1,this._tableParagraphBounds=new Map,this._tableCellBounds=new Map,this._tableBounds=new Map,this._paragraphBounds=(n=this._buildParagraphBoundsBySegment())!=null?n:new Map,this._paragraphLeftBounds=Array.from(this._paragraphBounds.values()).map(s=>({...s,rect:{left:s.rect.left-60,right:s.rect.left,top:s.rect.top,bottom:s.rect.bottom}}));const e=s=>{var a;this._segmentParagraphBounds.set(s,(a=this._buildParagraphBoundsBySegment(s))!=null?a:new Map)};(r=this._skeleton.getSkeletonData())==null||r.pages.forEach(s=>{s.headerId&&e(s.headerId),s.footerId&&e(s.footerId)})}_calcActiveParagraph(e){var c,l;this._buildParagraphBounds();const{x:n,y:r}=e,s=Array.from(this._tableBounds.values()).find(A=>He(n,r,A.rect));if(this._hoverTable$.next(s),s){const A=(c=this._tableCellBounds.get(s.tableId))==null?void 0:c.find(m=>He(n,r,m.rect));if(this._hoverTableCell$.next(A),!A)return null;const d=(l=this._tableParagraphBounds.get(A.tableId))==null?void 0:l.filter(m=>m.colIndex===A.colIndex&&m.rowIndex===A.rowIndex),u=d==null?void 0:d.find(m=>He(n,r,m.rect));return u&&{...u,rects:[u.rect]}}let a;for(const A of this._paragraphBounds){const d=A[1];if(d.rects.some(u=>He(n,r,u))){a=d;break}}return a}_calcActiveParagraphLeft(e){this._buildParagraphBounds();const{x:n,y:r}=e;return this._paragraphLeftBounds.find(a=>He(n,r,a.rect))}get paragraphBounds(){return this._buildParagraphBounds(),this._paragraphBounds}findParagraphBoundByIndex(e){this._buildParagraphBounds();const n=this._paragraphBounds.get(e);return n||Array.from(this._tableParagraphBounds.values()).flat().find(s=>s.startIndex===e)}};exports.DocEventManagerService=Jc([Zc(1,i.Inject(D.DocSkeletonManagerService))],exports.DocEventManagerService);const tl=[me.id,_e.id,Ne.id,Pe.id,we.id,ye.id,Ue.id,Me.id,De.id];function nl(o){const{avaliableMenus:t=tl}=o,e=I.useDependency(I.IMenuManagerService),[n,r]=P.useState([]);return P.useEffect(()=>{function s(){const c=e.getFlatMenuByPositionKey(I.MenuManagerPosition.RIBBON),l=[];for(const A of t){const d=c.find(u=>u.key===A);d&&l.push(d)}r(l)}s();const a=e.menuChanged$.subscribe(s);return()=>{a.unsubscribe()}},[e]),N.jsx("div",{className:q.clsx("univer-box-border univer-flex univer-rounded univer-bg-white univer-py-1.5 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900",q.borderClassName),children:n.map(s=>s.item&&N.jsx("div",{className:"univer-flex univer-flex-nowrap univer-gap-2 univer-px-2",children:N.jsx(I.ToolbarItem,{...s.item},s.key)},s.key))})}var ol=Object.getOwnPropertyDescriptor,rl=(o,t,e,n)=>{for(var r=n>1?void 0:n?ol(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},dt=(o,t)=>(e,n)=>t(e,n,o);const wr="univer.doc.float-menu";function il(o,t){if(o==null||t==null)return!1;const{glyph:e,...n}=o,{glyph:r,...s}=t;return i.deepCompare(n,s)}const sl=[i.DataStreamTreeTokenType.CUSTOM_BLOCK,i.DataStreamTreeTokenType.PARAGRAPH];let Jt=class extends i.Disposable{constructor(t,e,n,r,s,a){super();M(this,"_floatMenu",null);this._context=t,this._docSelectionManagerService=e,this._docCanvasPopManagerService=n,this._componentManager=r,this._univerInstanceService=s,this._docSelectionRenderService=a,!i.isInternalEditorID(this._context.unitId)&&(this._registerFloatMenu(),this._initSelectionChange(),this.disposeWithMe(()=>{this._hideFloatMenu()}))}get floatMenu(){return this._floatMenu}_registerFloatMenu(){this.disposeWithMe(this._componentManager.register(wr,nl))}_initSelectionChange(){this.disposeWithMe(this._docSelectionRenderService.onSelectionStart$.subscribe(()=>{this._hideFloatMenu()})),this.disposeWithMe(this._docSelectionManagerService.textSelection$.subscribe(t=>{var s,a;const{unitId:e,textRanges:n}=t;if(e!==this._context.unitId)return;const r=n.length>0&&n.find(c=>!c.collapsed);if(r){if(r.startOffset===((s=this._floatMenu)==null?void 0:s.start)&&r.endOffset===((a=this._floatMenu)==null?void 0:a.end))return;this._hideFloatMenu(),this._showFloatMenu(e,r);return}this._hideFloatMenu()}))}_hideFloatMenu(){var t;(t=this._floatMenu)==null||t.disposable.dispose(),this._floatMenu=null}_showFloatMenu(t,e){var a,c,l;const n=this._univerInstanceService.getUnit(t,i.UniverInstanceType.UNIVER_DOC);if(!n||n.getDisabled())return;const r=(a=n.getBody())==null?void 0:a.dataStream[e.startOffset];if(e.endOffset-e.startOffset===1&&r&&sl.includes(r))return;const s=(l=(c=n.getBody())==null?void 0:c.customRanges)==null?void 0:l.filter(A=>A.wholeEntity);if(!(s!=null&&s.some(A=>A.startIndex===e.startOffset&&A.endIndex===e.endOffset-1)))return this._floatMenu={disposable:this._docCanvasPopManagerService.attachPopupToRange(e,{componentKey:wr,direction:e.direction==="backward"||il(e.startNodePosition,e.endNodePosition)?"top-center":"bottom-center",offset:[0,4]},t),start:e.startOffset,end:e.endOffset},i.toDisposable(()=>this._hideFloatMenu())}};Jt=rl([dt(1,i.Inject(D.DocSelectionManagerService)),dt(2,i.Inject(exports.DocCanvasPopManagerService)),dt(3,i.Inject(I.ComponentManager)),dt(4,i.Inject(i.IUniverInstanceService)),dt(5,i.Inject(exports.DocSelectionRenderService))],Jt);var al=Object.getOwnPropertyDescriptor,cl=(o,t,e,n)=>{for(var r=n>1?void 0:n?al(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},At=(o,t)=>(e,n)=>t(e,n,o);let Zt=class extends i.Disposable{constructor(t,e,n,r,s,a){super();M(this,"_paragrahMenu",null);this._context=t,this._docSelectionManagerService=e,this._docEventManagerService=n,this._docPopupManagerService=r,this._docSkeletonManagerService=s,this._floatMenuService=a,!i.isInternalEditorID(this._context.unitId)&&this._init()}get activeParagraph(){var t;return(t=this._paragrahMenu)==null?void 0:t.paragraph}_isCursorInActiveParagraph(){if(!this._paragrahMenu)return!1;const t=this._docSelectionManagerService.getActiveTextRange();return!(!(t!=null&&t.collapsed)||!(t!=null&&t.collapsed)||t.startOffset<this._paragrahMenu.paragraph.paragraphStart||t.startOffset>this._paragrahMenu.paragraph.paragraphEnd)}setParagraphMenuActive(t){this._paragrahMenu&&(this._paragrahMenu.active=t,this._isCursorInActiveParagraph()||this._docSelectionManagerService.replaceDocRanges([{startOffset:this._paragrahMenu.paragraph.paragraphStart,endOffset:this._paragrahMenu.paragraph.paragraphStart}]))}_init(){const t=n=>{var s;if(this._docSkeletonManagerService.getViewModel().getEditArea()===B.DocumentEditArea.BODY&&!this._floatMenuService.floatMenu&&!this._context.unit.getDisabled()){if((s=this._paragrahMenu)!=null&&s.active)return;if(n){this.showParagraphMenu(n);return}}this.hideParagraphMenu(!0)};this.disposeWithMe(U.combineLatest([this._docEventManagerService.hoverParagraphRealTime$,this._docEventManagerService.hoverParagraphLeft$]).pipe(U.throttleTime(16)).subscribe(([n,r])=>{const s=n!=null?n:r;t(s)}));let e=0;this.disposeWithMe(this._context.scene.getViewport(ie.VIEW_MAIN).onScrollAfter$.subscribeEvent(n=>{e!==n.scrollY&&(e=n.scrollY,this.hideParagraphMenu(!0))})),this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(()=>{this.hideParagraphMenu(!0)}))}showParagraphMenu(t){var l,A,d;if(((l=this._paragrahMenu)==null?void 0:l.paragraph.startIndex)===t.startIndex)return;this.hideParagraphMenu(!0);const e=(d=(A=this._context.unit.getBody())==null?void 0:A.dataStream)!=null?d:"",n=t?e.slice(t.paragraphStart,t.paragraphEnd):"";if(n==="\b"||n==="")return;const c=this._docPopupManagerService.attachPopupToRect(t.firstLine,{componentKey:"doc.paragraph.menu",direction:"left-center",onClickOutside:()=>{this._docSelectionManagerService.textSelection$.pipe(U.first()).subscribe(()=>{this._isCursorInActiveParagraph()||this.hideParagraphMenu(!0)})},zIndex:101},this._context.unitId);this._paragrahMenu={paragraph:t,disposable:c,active:!1}}hideParagraphMenu(t=!1){this._paragrahMenu&&(this._paragrahMenu.disposable.canDispose()||t)&&(this._paragrahMenu.disposable.dispose(),this._paragrahMenu=null)}};Zt=cl([At(1,i.Inject(D.DocSelectionManagerService)),At(2,i.Inject(exports.DocEventManagerService)),At(3,i.Inject(exports.DocCanvasPopManagerService)),At(4,i.Inject(D.DocSkeletonManagerService)),At(5,i.Inject(Jt))],Zt);const ll=({popup:o})=>{var v,b;const[t,e]=P.useState(!1),n=P.useRef(null),r=I.useDependency(i.ICommandService),s=I.useDependency(I.ILayoutService),a=P.useRef(null),c=P.useRef(!1),l=I.useDependency(B.IRenderManagerService),A=I.useDependency(i.IUniverInstanceService),d=l.getRenderById(o.unitId),u=A.getUnit(o.unitId,i.UniverInstanceType.UNIVER_DOC),m=d==null?void 0:d.with(Zt),g=d==null?void 0:d.with(exports.DocEventManagerService),h=I.useObservable(g==null?void 0:g.hoverParagraph$),p=I.useObservable(g==null?void 0:g.hoverParagraphLeft$),f=(v=h!=null?h:p)==null?void 0:v.startIndex,S=P.useMemo(()=>{var x,y;return(y=(x=u==null?void 0:u.getBody())==null?void 0:x.paragraphs)==null?void 0:y.find(_=>_.startIndex===f)},[u,h]),E=(b=S==null?void 0:S.paragraphStyle)==null?void 0:b.namedStyleType,C=ns[E!=null?E:i.NamedStyleType.NORMAL_TEXT],T=P.useMemo(()=>new U.BehaviorSubject({left:0,right:0,top:0,bottom:0}),[]),R=()=>{e(!1),m==null||m.hideParagraphMenu(!0)};return N.jsxs(N.Fragment,{children:[N.jsxs("div",{"data-u-comp":"paragraph-menu",ref:a,className:q.clsx("univer-mr-1 univer-inline-flex univer-h-7 univer-cursor-pointer univer-items-center univer-gap-1 univer-rounded-full univer-px-2.5 univer-py-0 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-600",q.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-700":t,"univer-bg-white dark:!univer-bg-gray-700":!t}),onMouseEnter:x=>{var _,O,w,Q,k,F;(_=o.onPointerEnter)==null||_.call(o,x),c.current=!0;const y=(O=a.current)==null?void 0:O.getBoundingClientRect();T.next({left:((w=y==null?void 0:y.left)!=null?w:0)-4,right:(Q=y==null?void 0:y.right)!=null?Q:0,top:(k=y==null?void 0:y.top)!=null?k:0,bottom:(F=y==null?void 0:y.bottom)!=null?F:0})},onMouseLeave:()=>{c.current=!1},onClick:()=>{e(!0),m==null||m.setParagraphMenuActive(!0)},children:[N.jsx(C.component,{className:"univer-size-4 univer-text-gray-900 dark:!univer-text-white"}),N.jsx(Ii,{className:"univer-size-3 univer-text-gray-600 dark:!univer-text-gray-200"})]}),t&&N.jsx(I.RectPopup,{portal:!0,mask:!0,maskZIndex:100,anchorRect$:T,direction:"left",onMaskClick:R,children:N.jsx("section",{ref:n,onMouseEnter:x=>{var y;(y=o.onPointerEnter)==null||y.call(o,x),c.current=!0},onMouseLeave:()=>{c.current=!1},children:N.jsx(I.DesktopMenu,{style:{width:212},menuType:I.ContextMenuPosition.PARAGRAPH,onOptionSelect:x=>{const{label:y,commandId:_,value:O}=x;r&&r.executeCommand(_!=null?_:y,{value:O}),s.focus(),R()}})})})]})},dl="doc.command.tab",Xe={id:dl,type:i.CommandType.COMMAND,async handler(o,t){const n=o.get(exports.DocAutoFormatService).onAutoFormat(Xe.id,t);return(await i.sequenceExecuteAsync(n,o.get(i.ICommandService))).result}},Al="doc.command.after-space",Nt={id:Al,type:i.CommandType.COMMAND,async handler(o){const e=o.get(exports.DocAutoFormatService).onAutoFormat(Nt.id);return(await i.sequenceExecuteAsync(e,o.get(i.ICommandService))).result}},rt={id:"doc.command.enter",type:i.CommandType.COMMAND,async handler(o){const e=o.get(exports.DocAutoFormatService).onAutoFormat(rt.id);return(await i.sequenceExecuteAsync(e,o.get(i.ICommandService))).result}};function $(o){return o.getContextValue(i.FOCUSING_DOC)&&o.getContextValue(i.FOCUSING_UNIVER_EDITOR)&&!o.getContextValue(i.FOCUSING_COMMON_DRAWINGS)}function ul(o){return o.getContextValue(i.FOCUSING_DOC)&&o.getContextValue(i.FOCUSING_UNIVER_EDITOR)&&!o.getContextValue(i.FOCUSING_COMMON_DRAWINGS)}const gl={id:Xe.id,binding:I.KeyCode.TAB,preconditions:$},hl={id:Xe.id,binding:I.KeyCode.TAB|I.MetaKeys.SHIFT,preconditions:$,staticParameters:{shift:!0}},ml={id:_e.id,binding:I.KeyCode.B|I.MetaKeys.CTRL_COMMAND,preconditions:$},pl={id:Ne.id,binding:I.KeyCode.I|I.MetaKeys.CTRL_COMMAND,preconditions:$},fl={id:Pe.id,binding:I.KeyCode.U|I.MetaKeys.CTRL_COMMAND,preconditions:$},Sl={id:we.id,binding:I.KeyCode.X|I.MetaKeys.SHIFT|I.MetaKeys.CTRL_COMMAND,preconditions:$},Il={id:ye.id,binding:I.KeyCode.COMMA|I.MetaKeys.CTRL_COMMAND,preconditions:$},vl={id:Ue.id,binding:I.KeyCode.PERIOD|I.MetaKeys.CTRL_COMMAND,preconditions:$},El={id:Ot.id,binding:I.KeyCode.L|I.MetaKeys.CTRL_COMMAND|I.MetaKeys.SHIFT,preconditions:$},Cl={id:Dt.id,binding:I.KeyCode.R|I.MetaKeys.CTRL_COMMAND|I.MetaKeys.SHIFT,preconditions:$},Tl={id:Mt.id,binding:I.KeyCode.E|I.MetaKeys.CTRL_COMMAND|I.MetaKeys.SHIFT,preconditions:$},yl={id:Bt.id,binding:I.KeyCode.J|I.MetaKeys.CTRL_COMMAND|I.MetaKeys.SHIFT,preconditions:$},bl={id:ot.id,binding:I.KeyCode.Digit7|I.MetaKeys.CTRL_COMMAND|I.MetaKeys.SHIFT,preconditions:$},Rl={id:nt.id,binding:I.KeyCode.Digit8|I.MetaKeys.CTRL_COMMAND|I.MetaKeys.SHIFT,preconditions:$},En="docs-ui.config",Ur={layout:{docContainerConfig:Jr,toolbarConfig:qr}},xl=[50,80,100,130,150,170,200,400],Ol=[10,400];function Ml(){const o=I.useDependency(i.ICommandService),t=I.useDependency(i.IUniverInstanceService),e=P.useMemo(()=>t.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_DOC),[]),n=I.useObservable(e),r=P.useCallback(()=>{var A,d;if(!n)return 100;const l=((d=(A=n.getSettings())==null?void 0:A.zoomRatio)!=null?d:1)*100;return Math.round(l)},[n]),[s,a]=P.useState(()=>r());P.useEffect(()=>(a(r()),o.onCommandExecuted(A=>{if(A.id===Ae.id){const d=r();a(d)}}).dispose),[o,r]);function c(l){if(a(l),n==null)return;const A=l/100;o.executeCommand(Ae.id,{unitId:n.getUnitId(),zoomRatio:A})}return N.jsx(I.Slider,{min:Ol[0],value:s,shortcuts:xl,onChange:c})}function Dl(o){return N.jsx("section",{className:"univer-flex univer-flex-shrink-0 univer-justify-end",children:N.jsx(Ml,{})})}function Bl(){var r,s,a;const o=I.useDependency(i.IUniverInstanceService),t=I.useConfigValue(En),e=I.useObservable(()=>o.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),n=(a=(s=(r=t==null?void 0:t.layout)==null?void 0:r.docContainerConfig)==null?void 0:s.footer)!=null?a:!0;return e?null:n&&N.jsxs("div",{className:"univer-box-border univer-flex univer-items-center univer-justify-between univer-px-5 univer-py-1.5",children:[N.jsx("div",{}),N.jsx(Dl,{})]})}const _l="univer-overflow-hidden univer-font-[500] univer-truncate univer-h-[24px] univer-mb-2 univer-leading-[24px] univer-ellipsis univer-cursor-pointer",Nl="univer-text-base univer-font-semibold",Pl="univer-text-sm univer-font-semibold",wl="univer-text-sm",Ul=P.forwardRef((o,t)=>{const{menus:e,onClick:n,className:r,style:s,mode:a,maxHeight:c,activeId:l,open:A,onOpenChange:d,maxWidth:u,wrapperClass:m,wrapperStyle:g,iconClass:h,iconStyle:p}=o,f=a==="side-bar",S=P.useRef(null),E=P.useRef(e);E.current=e;const C=P.useMemo(()=>({scrollTo:T=>{var O;if(!E.current||E.current.findIndex(w=>w.id===T)===-1||!S.current)return;const v=document.getElementById(`univer-side-menu-${T}`);if(!v)return;const b=v.offsetTop,x=S.current.clientHeight,y=S.current.scrollHeight-x,_=Math.max(0,Math.min(b-x/2+v.clientHeight/2,y));(O=S.current)==null||O.scrollTo({behavior:"smooth",top:_})}}),[]);return P.useImperativeHandle(t,()=>C),P.useEffect(()=>{l&&C.scrollTo(l)},[l,C]),N.jsxs("div",{className:q.clsx("univer-relative",m),style:g,children:[N.jsx("div",{onClick:()=>d==null?void 0:d(!A),className:q.clsx("univer-absolute univer-left-5 univer-top-4 univer-z-[100] univer-flex univer-h-8 univer-w-8 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-bg-white univer-text-gray-800 univer-shadow-sm dark:!univer-bg-gray-600 dark:!univer-text-gray-200",h),style:p,children:A?N.jsx(Ri,{}):N.jsx(mi,{})}),N.jsx("div",{className:q.clsx(r,`
|
|
33
33
|
univer-absolute univer-left-0 univer-top-0 univer-box-border univer-flex univer-min-w-[180px]
|
|
34
34
|
univer-flex-col univer-px-4 univer-pb-4 univer-pt-14 univer-transition-all univer-duration-300
|
|
35
|
-
`,{"univer-rounded-r-2xl univer-bg-white univer-shadow univer-backdrop-blur-[10px] dark:!univer-bg-gray-900":f}),style:{...s,transform:A?"translateX(0)":"translateX(-100%)",maxHeight:c,opacity:A?1:0,maxWidth:u!=null?u:a==="side-bar"?320:180,paddingRight:a==="float"?void 0:0},children:N.jsx("div",{ref:S,className:q.clsx("univer-flex-1 univer-overflow-y-auto univer-overflow-x-hidden",q.scrollbarClassName),children:e==null?void 0:e.map(T=>N.jsx("div",{id:`univer-side-menu-${T.id}`,className:q.clsx(_l,{[Nl]:T.isTitle,[Pl]:T.level===1,[wl]:T.level>1,"univer-text-gray-500 dark:!univer-text-gray-400":T.id!==l,"univer-text-gray-800 dark:!univer-text-gray-200":T.id===l}),style:{paddingLeft:(T.level-1)*12},onClick:()=>{n==null||n(T)},children:T.text},T.id))})})]})}),Ll=o=>{switch(o){case i.NamedStyleType.HEADING_1:return 1;case i.NamedStyleType.HEADING_2:return 2;case i.NamedStyleType.HEADING_3:return 3;case i.NamedStyleType.HEADING_4:return 4;case i.NamedStyleType.HEADING_5:return 5;case i.NamedStyleType.TITLE:return 1;default:return 1}};function Ql(o,t,e,n){var c,l;if(!o)return;const r=Array.from(o.values()),s=r.findIndex(A=>A.paragraphStart!==A.paragraphEnd&&A.rect.top<n&&A.rect.bottom>e);if(s===-1)return;const a=r==null?void 0:r.findLastIndex(A=>A.paragraphStart!==A.paragraphEnd&&A.rect.top<n&&A.rect.bottom>e);for(let A=s;A<=a;A++){const d=r[A],u=t.get(d.startIndex);if((c=u==null?void 0:u.paragraphStyle)!=null&&c.headingId)return u.paragraphStyle.headingId}for(let A=s;A>=0;A--){const d=r[A],u=t.get(d.startIndex);if((l=u==null?void 0:u.paragraphStyle)!=null&&l.headingId)return u.paragraphStyle.headingId}}const Lr="__title";function Fl(){var t,e,n;const o=I.useConfigValue(En);return(n=(e=(t=o==null?void 0:o.layout)==null?void 0:t.docContainerConfig)==null?void 0:e.sideMenu)==null||n?N.jsx(Hl,{}):null}function Hl(){var _,O,w,Q,k,F,L,G,W;const o=I.useDependency(i.ICommandService),t=I.useDependency(i.IUniverInstanceService),e=I.useObservable(P.useMemo(()=>t.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_DOC),[])),n=I.useDependency(B.IRenderManagerService),r=(O=(_=e==null?void 0:e.getBody())==null?void 0:_.dataStream)!=null?O:"",[s,a]=P.useState(0),[c,l]=P.useState(void 0),A=(w=e==null?void 0:e.getUnitId())!=null?w:"",d=n.getRenderById(A),u=e==null?void 0:e.getTitle(),m=d==null?void 0:d.with(exports.DocEventManagerService),g=m==null?void 0:m.paragraphBounds,h=(k=(Q=d==null?void 0:d.mainComponent)==null?void 0:Q.left)!=null?k:0,p=(F=d==null?void 0:d.engine.height)!=null?F:0,f=(L=d==null?void 0:d.scene.scaleY)!=null?L:1,S=(W=(G=e==null?void 0:e.getBody())==null?void 0:G.paragraphs)!=null?W:[],E=P.useMemo(()=>{const H=new Map;return S.forEach(V=>{H.set(V.startIndex,V)}),H},[S]);I.useObservable(P.useMemo(()=>d!=null&&d.engine.onTransformChange$?i.fromEventSubject(d==null?void 0:d.engine.onTransformChange$).pipe(U.throttleTime(33)):U.of(null),[d==null?void 0:d.engine.onTransformChange$]));const C=h<180?"float":"side-bar",T=S==null?void 0:S.filter(H=>{var V;return((V=H.paragraphStyle)==null?void 0:V.namedStyleType)!==void 0&&H.paragraphStyle.namedStyleType!==i.NamedStyleType.SUBTITLE&&H.paragraphStyle.namedStyleType!==i.NamedStyleType.NORMAL_TEXT}).map(H=>{var Y;const V=Ll(H.paragraphStyle.namedStyleType),j=g==null?void 0:g.get(H.startIndex);if(!j)return null;const{paragraphStart:X,paragraphEnd:z}=j;return{id:H.paragraphStyle.headingId,text:i.getPlainText(r.slice(X,z)),level:V,isTitle:((Y=H.paragraphStyle)==null?void 0:Y.namedStyleType)===i.NamedStyleType.TITLE}}).filter(H=>H==null?void 0:H.text),R=I.useEvent(H=>{const V=H.viewportScrollY,j=V+p/f,X=Ql(g,E,V,j);X&&l(X)}),v=T!=null&&T.find(H=>H.isTitle)?T:[...u?[{id:Lr,text:u,level:1,isTitle:!0}]:[],...T!=null?T:[]].filter(Boolean),[b,x]=P.useState(!0);P.useEffect(()=>{const H=i.debounce(a,100),V=o.onCommandExecuted(j=>{j.id===D.RichTextEditingMutation.id&&j.params.unitId===(e==null?void 0:e.getUnitId())&&H(z=>z+1)});return()=>{V.dispose()}},[o,e]),P.useEffect(()=>{const H=d==null?void 0:d.scene.getViewport(ie.VIEW_MAIN);if(!H)return;const V=i.fromEventSubject(H.onScrollAfter$).pipe(U.throttleTime(33)).subscribe(R);return()=>{V.unsubscribe()}},[d]);const y=I.useEvent(H=>{const V=d==null?void 0:d.scene.getViewport(ie.VIEW_MAIN);if(!V)return;if(H.id===Lr){V.scrollToViewportPos({viewportScrollY:0});return}const j=S.find(z=>{var Y;return((Y=z.paragraphStyle)==null?void 0:Y.headingId)===H.id});if(!j)return;const X=g==null?void 0:g.get(j.startIndex);X&&(V.scrollToViewportPos({viewportScrollY:X.rect.top}),l(H.id))});return!e||i.isInternalEditorID(A)||!(v!=null&&v.length)?null:N.jsx("div",{className:"univer-absolute univer-bottom-0 univer-left-0 univer-top-0 univer-z-[100] univer-w-[0px]",children:N.jsx(Ul,{menus:v,open:b,onOpenChange:x,mode:C,maxWidth:C==="float"?void 0:Math.floor(h),wrapperClass:"univer-mt-12",activeId:c,onClick:y,maxHeight:p-48})})}const Cn={id:"doc.table.delete-rows",type:i.CommandType.COMMAND,handler:async o=>{const t=o.get(D.DocSelectionManagerService),e=o.get(i.IUniverInstanceService),n=o.get(i.ICommandService),r=t.getRectRanges(),s=t.getActiveTextRange(),a=Tt(s,r);if(a==null)return!1;const{segmentId:c}=a,l=e.getCurrentUniverDocInstance(),A=l==null?void 0:l.getSelfOrHeaderFooterModel(c).getBody();if(l==null||A==null)return!1;const d=ce(o,l.getUnitId());if(d==null)return!1;const u=d.getViewModel(),m=l==null?void 0:l.getUnitId(),g=new i.TextX,h=i.JSONX.getInstance(),p=Ui(a,u);if(p==null)return!1;const{offset:f,rowIndexes:S,len:E,tableId:C,cursor:T,selectWholeTable:R}=p;if(R)return n.executeCommand(ct.id);const v=[],b=[{startOffset:T,endOffset:T,collapsed:!0}],x={id:D.RichTextEditingMutation.id,params:{unitId:m,actions:[],textRanges:b}};f>0&&g.push({t:i.TextXActionType.RETAIN,len:f}),g.push({t:i.TextXActionType.DELETE,len:E});const y=J(l,c);v.push(h.editOp(g.serialize(),y));for(const O of S.reverse()){const w=h.removeOp(["tableSource",C,"tableRows",O]);v.push(w)}return x.params.actions=v.reduce((O,w)=>i.JSONX.compose(O,w),null),!!n.syncExecuteCommand(x.id,x.params)}},Tn={id:"doc.table.delete-columns",type:i.CommandType.COMMAND,handler:async o=>{const t=o.get(D.DocSelectionManagerService),e=o.get(i.IUniverInstanceService),n=o.get(i.ICommandService),r=t.getRectRanges(),s=t.getActiveTextRange(),a=Tt(s,r);if(a==null)return!1;const{segmentId:c}=a,l=e.getCurrentUniverDocInstance(),A=l==null?void 0:l.getSelfOrHeaderFooterModel(c).getBody();if(l==null||A==null)return!1;const d=ce(o,l.getUnitId());if(d==null)return!1;const u=d.getViewModel(),m=l==null?void 0:l.getUnitId(),g=new i.TextX,h=i.JSONX.getInstance(),p=Na(a,u);if(p==null)return!1;const{offsets:f,columnIndexes:S,tableId:E,cursor:C,rowCount:T,selectWholeTable:R}=p;if(R)return n.executeCommand(ct.id);const v=[],b=[{startOffset:C,endOffset:C,collapsed:!0}],x={id:D.RichTextEditingMutation.id,params:{unitId:m,actions:[],textRanges:b}};for(const O of f){const{retain:w,delete:Q}=O;w>0&&g.push({t:i.TextXActionType.RETAIN,len:w}),g.push({t:i.TextXActionType.DELETE,len:Q})}const y=J(l,c);v.push(h.editOp(g.serialize(),y)),S.reverse();for(let O=0;O<T;O++)for(const w of S){const Q=h.removeOp(["tableSource",E,"tableRows",O,"tableCells",w]);v.push(Q)}for(const O of S){const w=h.removeOp(["tableSource",E,"tableColumns",O]);v.push(w)}return x.params.actions=v.reduce((O,w)=>i.JSONX.compose(O,w),null),!!n.syncExecuteCommand(x.id,x.params)}},ct={id:"doc.table.delete-table",type:i.CommandType.COMMAND,handler:async o=>{const t=o.get(D.DocSelectionManagerService),e=o.get(i.IUniverInstanceService),n=o.get(i.ICommandService),r=t.getRectRanges(),s=t.getActiveTextRange(),a=Tt(s,r);if(a==null)return!1;const{segmentId:c}=a,l=e.getCurrentUniverDocInstance(),A=l==null?void 0:l.getSelfOrHeaderFooterModel(c).getBody();if(l==null||A==null)return!1;const d=ce(o,l.getUnitId());if(d==null)return!1;const u=d.getViewModel(),m=l==null?void 0:l.getUnitId(),g=new i.TextX,h=i.JSONX.getInstance(),p=Li(a,u);if(p==null)return!1;const{offset:f,len:S,tableId:E,cursor:C}=p,T=[],R=[{startOffset:C,endOffset:C,collapsed:!0}],v={id:D.RichTextEditingMutation.id,params:{unitId:m,actions:[],textRanges:R}};f>0&&g.push({t:i.TextXActionType.RETAIN,len:f}),g.push({t:i.TextXActionType.DELETE,len:S});const b=J(l,c);T.push(h.editOp(g.serialize(),b));const x=h.removeOp(["tableSource",E]);return T.push(x),v.params.actions=T.reduce((_,O)=>i.JSONX.compose(_,O),null),!!n.syncExecuteCommand(v.id,v.params)}},Ko="doc.command.table-insert-row",zo="doc.command.table-insert-column",kl="doc.command.table-insert-row-above",Vl="doc.command.table-insert-row-bellow",jl="doc.command.table-insert-column-left",Wl="doc.command.table-insert-column-right",yn={id:kl,type:i.CommandType.COMMAND,handler:async o=>o.get(i.ICommandService).executeCommand(Ko,{position:ln.ABOVE})},bn={id:Vl,type:i.CommandType.COMMAND,handler:async o=>o.get(i.ICommandService).executeCommand(Ko,{position:ln.BELLOW})},Rn={id:jl,type:i.CommandType.COMMAND,handler:async o=>o.get(i.ICommandService).executeCommand(zo,{position:Eo.LEFT})},xn={id:Wl,type:i.CommandType.COMMAND,handler:async o=>o.get(i.ICommandService).executeCommand(zo,{position:Eo.RIGHT})},Yo={id:Ko,type:i.CommandType.COMMAND,handler:async(o,t)=>{const{position:e}=t,n=o.get(D.DocSelectionManagerService),r=o.get(i.IUniverInstanceService),s=o.get(i.ICommandService),a=n.getRectRanges(),c=n.getActiveTextRange(),l=Tt(c,a);if(l==null)return!1;const{segmentId:A}=l,d=r.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC),u=d==null?void 0:d.getSelfOrHeaderFooterModel(A).getBody();if(d==null||u==null)return!1;const m=ce(o,d.getUnitId());if(m==null)return!1;const g=m.getViewModel(),h=d==null?void 0:d.getUnitId(),p=new i.TextX,f=i.JSONX.getInstance(),S=Da(l,e,g);if(S==null)return!1;const{offset:E,colCount:C,tableId:T,insertRowIndex:R}=S,v=[],b=E+2,x=[{startOffset:b,endOffset:b,collapsed:!0}],y={id:D.RichTextEditingMutation.id,params:{unitId:h,actions:[],textRanges:x}};E>0&&p.push({t:i.TextXActionType.RETAIN,len:E});const _=Oa(C);p.push({t:i.TextXActionType.INSERT,body:_,len:_.dataStream.length});const O=J(d,A);v.push(f.editOp(p.serialize(),O));const w=An(C),Q=f.insertOp(["tableSource",T,"tableRows",R],w);return v.push(Q),y.params.actions=v.reduce((F,L)=>i.JSONX.compose(F,L),null),!!s.syncExecuteCommand(y.id,y.params)}},is={id:zo,type:i.CommandType.COMMAND,handler:async(o,t)=>{var X,z,Y;const{position:e}=t,n=o.get(D.DocSelectionManagerService),r=o.get(i.IUniverInstanceService),s=o.get(i.ICommandService),a=n.getRectRanges(),c=n.getActiveTextRange(),l=Tt(c,a);if(l==null)return!1;const{segmentId:A}=l,d=r.getCurrentUniverDocInstance(),u=d==null?void 0:d.getSelfOrHeaderFooterModel(A).getBody();if(d==null||u==null)return!1;const m=ce(o,d.getUnitId());if(m==null)return!1;const g=m.getViewModel(),h=d==null?void 0:d.getUnitId(),p=new i.TextX,f=i.JSONX.getInstance(),S=Ba(l,e,g);if(S==null)return!1;const{offsets:E,columnIndex:C,tableId:T,rowCount:R}=S,v=[],b=E[0]+1,x=[{startOffset:b,endOffset:b,collapsed:!0}],y={id:D.RichTextEditingMutation.id,params:{unitId:h,actions:[],textRanges:x}};for(const K of E){p.push({t:i.TextXActionType.RETAIN,len:K});const Z=Ma();p.push({t:i.TextXActionType.INSERT,body:Z,len:Z.dataStream.length})}const _=J(d,A);v.push(f.editOp(p.serialize(),_));for(let K=0;K<R;K++){const Z=dn(),ne=f.insertOp(["tableSource",T,"tableRows",K,"tableCells",C],Z);v.push(ne)}const O=d.getSnapshot(),w=O.documentStyle,{marginLeft:Q=0,marginRight:k=0}=w,F=((z=(X=w.pageSize)==null?void 0:X.width)!=null?z:800)-Q-k,L=(Y=O==null?void 0:O.tableSource)==null?void 0:Y[T].tableColumns,{newColWidth:G,widths:W}=_a(F,L,C);for(let K=0;K<W.length;K++){const Z=f.replaceOp(["tableSource",T,"tableColumns",K,"size","width","v"],L[K].size.width.v,W[K]);v.push(Z)}const H=un(G),V=f.insertOp(["tableSource",T,"tableColumns",C],H);return v.push(V),y.params.actions=v.reduce((K,Z)=>i.JSONX.compose(K,Z),null),!!s.syncExecuteCommand(y.id,y.params)}},fe={id:"doc-paragraph-setting.command",type:i.CommandType.COMMAND,handler:async(o,t)=>{var C,T,R,v,b;const e=o.get(D.DocSelectionManagerService),n=o.get(i.IUniverInstanceService),r=o.get(i.ICommandService),s=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC),a=e.getDocRanges();if(!s||a.length===0||!t)return!1;const c=a[0].segmentId,l=s.getUnitId(),A=s.getSelfOrHeaderFooterModel(c),d=(T=(C=A.getBody())==null?void 0:C.paragraphs)!=null?T:[],u=(v=(R=A.getBody())==null?void 0:R.dataStream)!=null?v:"",m=(b=i.BuildTextUtils.range.getParagraphsInRanges(a,d,u))!=null?b:[],g={id:D.RichTextEditingMutation.id,params:{unitId:l,actions:[],textRanges:a}},h=new i.MemoryCursor;h.reset();const p=new i.TextX,f=i.JSONX.getInstance();for(const x of m){const{startIndex:y}=x;p.push({t:i.TextXActionType.RETAIN,len:y-h.cursor});const _={...x.paragraphStyle,...t.paragraph};p.push({t:i.TextXActionType.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...x,paragraphStyle:_,startIndex:0}]},coverType:i.UpdateDocsAttributeType.REPLACE}),h.moveCursorTo(y+1)}const S=J(s,c);return g.params.actions=f.editOp(p.serialize(),S),!!r.syncExecuteCommand(g.id,g.params)}},Gl=()=>{const o=I.useDependency(D.DocSelectionManagerService),t=I.useDependency(it),e=P.useMemo(()=>o.getDocRanges(),[]);return P.useEffect(()=>{e.length||t.closePanel()},[e]),e},Xl=()=>{var l,A,d,u,m;const t=I.useDependency(i.IUniverInstanceService).getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC),e=Gl();if(!t||e.length===0)return[];const n=e[0].segmentId,r=t.getSelfOrHeaderFooterModel(n),s=(A=(l=r.getBody())==null?void 0:l.paragraphs)!=null?A:[],a=(u=(d=r.getBody())==null?void 0:d.dataStream)!=null?u:"";return(m=i.BuildTextUtils.range.getParagraphsInRanges(e,s,a))!=null?m:[]},Kl=(o,t)=>{const e=I.useDependency(i.ICommandService),[n,r]=P.useState(()=>{var c,l;const a=o[0];return a?String((l=(c=a.paragraphStyle)==null?void 0:c.horizontalAlign)!=null?l:t):t});return[n,a=>(r(a),e.executeCommand(fe.id,{paragraph:{horizontalAlign:Number(a)}}))]},zl=o=>{const t=I.useDependency(i.ICommandService),[e,n]=P.useState(()=>{var a;const s=o[0];return s?B.getNumberUnitValue((a=s.paragraphStyle)==null?void 0:a.indentStart,0):0});return[e,s=>(n(s),t.executeCommand(fe.id,{paragraph:{indentStart:{v:s}}}))]},Yl=o=>{const t=I.useDependency(i.ICommandService),[e,n]=P.useState(()=>{var a;const s=o[0];return s?B.getNumberUnitValue((a=s.paragraphStyle)==null?void 0:a.indentEnd,0):0});return[e,s=>(n(s),t.executeCommand(fe.id,{paragraph:{indentEnd:{v:s}}}))]},ql=o=>{const t=I.useDependency(i.ICommandService),[e,n]=P.useState(()=>{var a;const s=o[0];return s?B.getNumberUnitValue((a=s.paragraphStyle)==null?void 0:a.indentFirstLine,0):0});return[e,s=>(n(s),t.executeCommand(fe.id,{paragraph:{indentFirstLine:{v:s}}}))]},Jl=o=>{const t=I.useDependency(i.ICommandService),[e,n]=P.useState(()=>{var a;const s=o[0];return s?B.getNumberUnitValue((a=s.paragraphStyle)==null?void 0:a.hanging,0):0});return[e,s=>(n(s),t.executeCommand(fe.id,{paragraph:{hanging:{v:s}}}))]},Zl=o=>{const t=I.useDependency(i.ICommandService),[e,n]=P.useState(()=>{var a;const s=o[0];return s?B.getNumberUnitValue((a=s.paragraphStyle)==null?void 0:a.spaceAbove,0):0});return[e,s=>(n(s),t.executeCommand(fe.id,{paragraph:{spaceAbove:{v:s}}}))]},$l=o=>{const t=I.useDependency(i.ICommandService),[e,n]=P.useState(()=>{var a;const s=o[0];return s?B.getNumberUnitValue((a=s.paragraphStyle)==null?void 0:a.spaceBelow,0):0});return[e,s=>(n(s),t.executeCommand(fe.id,{paragraph:{spaceBelow:{v:s}}}))]},ed=o=>{const t=I.useDependency(i.ICommandService),e=I.useDependency(B.IRenderManagerService),n=I.useDependency(i.IUniverInstanceService),r=P.useMemo(()=>{var h;const g=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC);if(g)return(h=e.getRenderById(g==null?void 0:g.getUnitId()))==null?void 0:h.with(D.DocSkeletonManagerService).getSkeleton()},[]),s=P.useMemo(()=>new U.BehaviorSubject({}),[]),[a,c]=P.useState(()=>{var h,p;const g=o[0];return g&&(p=(h=g.paragraphStyle)==null?void 0:h.lineSpacing)!=null?p:1}),l=P.useRef(a),[A,d]=P.useState(()=>{var h,p;const g=o[0];return g&&(p=(h=g.paragraphStyle)==null?void 0:h.spacingRule)!=null?p:i.SpacingRule.AUTO}),u=async g=>{c(g),s.next({lineSpacing:g,spacingRule:A})},m=async g=>{if(g!==A){let h=l.current;if(g===i.SpacingRule.AT_LEAST){const p=r==null?void 0:r.findNodeByCharIndex(o[0].startIndex),f=p==null?void 0:p.parent,S=f==null?void 0:f.parent;(S==null?void 0:S.contentHeight)!==void 0&&(h=Math.max(S.contentHeight,h))}else h>5&&(h=2);l.current=a,u(h),d(g),s.next({spacingRule:g})}};return P.useEffect(()=>{const g=s.pipe(mt.filter(h=>!!Object.keys(h).length),mt.bufferTime(16),mt.filter(h=>!!h.length),mt.map(h=>h.reduce((p,f)=>(Object.keys(f).forEach(S=>{p[S]=f[S]}),p),{}))).subscribe(h=>t.executeCommand(fe.id,{paragraph:{...h}}));return()=>g.unsubscribe()},[]),{lineSpacing:[a,u],spacingRule:[A,m]}},ke=o=>{const{value:t,onChange:e,className:n="",min:r=0,max:s=100,step:a=1}=o,c=P.useRef(null);return N.jsx(q.InputNumber,{step:a,ref:c,min:r,max:s,value:t,onChange:l=>{e(l!=null?l:0).finally(()=>{setTimeout(()=>{var A;(A=c.current)==null||A.focus()},30)})},className:n})};function td(){const o=I.useDependency(i.LocaleService),t=P.useMemo(()=>[{label:o.t("toolbar.alignLeft"),value:String(i.HorizontalAlign.LEFT),icon:N.jsx(xi,{})},{label:o.t("toolbar.alignCenter"),value:String(i.HorizontalAlign.CENTER),icon:N.jsx(bi,{})},{label:o.t("toolbar.alignRight"),value:String(i.HorizontalAlign.RIGHT),icon:N.jsx(Oi,{})},{label:o.t("toolbar.alignJustify"),value:String(i.HorizontalAlign.JUSTIFIED),icon:N.jsx(hi,{})}],[]),e=Xl(),[n,r]=Kl(e,t[0].value),[s,a]=zl(e),[c,l]=Yl(e),[A,d]=ql(e),[u,m]=Jl(e),[g,h]=Zl(e),[p,f]=$l(e),{lineSpacing:[S,E],spacingRule:[C,T]}=ed(e),R=P.useMemo(()=>C===i.SpacingRule.AUTO?{min:1,max:5,step:S<2?.5:1}:{min:1,max:100},[C,S]);return N.jsxs("div",{children:[N.jsx("div",{className:"univer-t-4 univer-text-sm univer-font-medium",children:o.t("doc.paragraphSetting.alignment")}),N.jsx("div",{className:q.clsx("univer-mt-4 univer-box-border univer-flex univer-w-full univer-items-center univer-justify-between univer-gap-1 univer-rounded-md univer-p-1",q.borderClassName),children:t.map(v=>N.jsx(q.Tooltip,{title:v.label,placement:"bottom",children:N.jsx("span",{className:q.clsx("univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-bg-none univer-px-3 univer-py-1 hover:univer-bg-black/60",{"univer-bg-blend-color-dodge/90":n===v.value}),onClick:()=>r(v.value),children:v.icon})},v.value))}),N.jsx("div",{className:"univer-t-4 univer-text-sm univer-font-medium",children:o.t("doc.paragraphSetting.indentation")}),N.jsxs("div",{children:[N.jsxs("div",{className:"univer-item-center univer-flex univer-justify-between",children:[N.jsxs("div",{className:"univer-mt-3 univer-text-xs",children:[o.t("doc.paragraphSetting.left"),"(px)"]}),N.jsx(ke,{className:"univer-mt-4",value:s,onChange:v=>a(v!=null?v:0)})]}),N.jsxs("div",{className:"univer-item-center univer-flex univer-justify-between",children:[N.jsxs("div",{className:"univer-mt-3 univer-text-xs",children:[o.t("doc.paragraphSetting.right"),"(px)"]}),N.jsx(ke,{className:"univer-mt-4",value:c,onChange:v=>l(v!=null?v:0)})]}),N.jsxs("div",{className:"univer-item-center univer-flex univer-justify-between",children:[N.jsxs("div",{className:"univer-mt-3 univer-text-xs",children:[o.t("doc.paragraphSetting.firstLine"),"(px)"]}),N.jsx(ke,{className:"univer-mt-4",value:A,onChange:v=>d(v!=null?v:0)})]}),N.jsxs("div",{className:"univer-item-center univer-flex univer-justify-between",children:[N.jsxs("div",{className:"univer-mt-3 univer-text-xs",children:[o.t("doc.paragraphSetting.hanging"),"(px)"]}),N.jsx(ke,{className:"univer-mt-4",value:u,onChange:v=>m(v!=null?v:0)})]})]}),N.jsx("div",{className:"univer-t-4 univer-text-sm univer-font-medium",children:o.t("doc.paragraphSetting.spacing")}),N.jsxs("div",{children:[N.jsxs("div",{className:"univer-justify-betweenuniver-item-center univer-flex",children:[N.jsxs("div",{className:"univer-mt-3 univer-text-xs",children:[o.t("doc.paragraphSetting.before"),"(px)"]}),N.jsx(ke,{className:"univer-mt-4",value:g,onChange:v=>h(v!=null?v:0)})]}),N.jsxs("div",{className:"univer-item-center univer-flex univer-justify-between",children:[N.jsxs("div",{className:"univer-mt-3 univer-text-xs",children:[o.t("doc.paragraphSetting.after"),"(px)"]}),N.jsx(ke,{className:"univer-mt-4",value:p,onChange:v=>f(v!=null?v:0)})]}),N.jsxs("div",{className:"item-center univer-flex univer-justify-between",children:[N.jsx("div",{className:"univer-mt-3 univer-text-xs",children:o.t("doc.paragraphSetting.lineSpace")}),N.jsxs("div",{className:"univer-mt-4 univer-flex univer-w-[162px] univer-flex-col univer-gap-1.5",children:[N.jsx(q.Select,{value:`${C}`,options:[{label:o.t("doc.paragraphSetting.multiSpace"),value:`${i.SpacingRule.AUTO}`},{label:o.t("doc.paragraphSetting.fixedValue"),value:`${i.SpacingRule.AT_LEAST}`}],onChange:v=>T(Number(v))}),N.jsx(ke,{...R,value:S,onChange:v=>E(v!=null?v:0)})]})]})]})]})}const nd=(o,t)=>t.length===o.length&&o.some(e=>t.some(n=>n.startOffset===e.startOffset&&n.endOffset===e.endOffset));function od(){const o=I.useDependency(i.ICommandService),t=I.useDependency(i.LocaleService),e=I.useObservable(t.currentLocale$),[n,r]=P.useState(""),s=P.useMemo(()=>i.debounce(()=>r(i.generateRandomId(4)),300),[]),a=P.useRef([]);return P.useEffect(()=>{const c=o.onCommandExecuted(l=>{if(D.SetTextSelectionsOperation.id===l.id){const A=l.params.ranges;nd(A,a.current)||r(i.generateRandomId(4)),a.current=A}D.RichTextEditingMutation.id===l.id&&l.params.trigger!==fe.id&&s()});return()=>c.dispose()},[s]),P.useEffect(()=>{r(i.generateRandomId(4))},[e]),P.useEffect(()=>()=>s.cancel(),[s]),N.jsx(td,{},n)}var rd=Object.getOwnPropertyDescriptor,id=(o,t,e,n)=>{for(var r=n>1?void 0:n?rd(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Qn=(o,t)=>(e,n)=>t(e,n,o);const Qr="doc_ui_paragraph-setting-panel";let it=class extends i.Disposable{constructor(t,e,n){super();M(this,"_id");this._commandService=t,this._componentManager=e,this._sidebarService=n,this._init()}_init(){this.disposeWithMe(this._componentManager.register(Qr,od))}openPanel(){const t={header:{title:"doc.slider.paragraphSetting"},id:this._id,children:{label:Qr},width:300};this._sidebarService.open(t)}closePanel(){this._sidebarService.close(this._id)}};it=id([Qn(0,i.ICommandService),Qn(1,i.Inject(I.ComponentManager)),Qn(2,i.Inject(I.ISidebarService))],it);const qo={id:"sidebar.operation.doc-paragraph-setting-panel",type:i.CommandType.OPERATION,handler:o=>(o.get(it).openPanel(),!0)},Jo=o=>{const t=o.get(D.DocSelectionManagerService);return new U.Observable(e=>{const n=t.textSelection$.subscribe(()=>{t.getDocRanges().some(a=>a.collapsed===!1||a.rangeType===i.DOC_RANGE_TYPE.RECT)?e.next(!1):e.next(!0)});return()=>n.unsubscribe()})};function sd(o){if(o.length<2)return!0;const t=o.map(e=>e.tableId);return t.every(e=>e===t[0])}function Fr(o,t,e){var s;const n=t.getRectRanges(),r=t.getActiveTextRange();if(n&&n.length&&sd(n)&&r==null){o.next(!1);return}if(r&&(n==null||n.length===0)){const{segmentId:a,startOffset:c,endOffset:l}=r,A=e.getCurrentUniverDocInstance(),d=(s=A==null?void 0:A.getSelfOrHeaderFooterModel(a).getBody())==null?void 0:s.tables;if(d&&d.length&&d.some(u=>{const{startIndex:m,endIndex:g}=u;return c>m&&c<g||l>m&&l<g})){o.next(!1);return}}o.next(!0)}const Re=o=>{const t=o.get(D.DocSelectionManagerService),e=o.get(i.IUniverInstanceService);return new U.Observable(n=>{const r=t.textSelection$.subscribe(()=>{Fr(n,t,e)});return Fr(n,t,e),()=>r.unsubscribe()})},ad=o=>({id:vt.name,commandId:vt.id,type:I.MenuItemType.BUTTON,icon:"CopyDoubleIcon",title:"rightClick.copy",disabled$:Jo(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}),cd=o=>({id:qo.id,type:I.MenuItemType.BUTTON,icon:"MenuIcon",title:"doc.menu.paragraphSetting",hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}),ld=o=>({id:fn.id,type:I.MenuItemType.BUTTON,icon:"CopyDoubleIcon",title:"rightClick.cut",disabled$:Jo(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}),dd=o=>({id:Sn.id,type:I.MenuItemType.BUTTON,icon:"PasteSpecialDoubleIcon",title:"rightClick.paste",hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}),Ad=o=>({id:bt.id,type:I.MenuItemType.BUTTON,icon:"PasteSpecialDoubleIcon",title:"rightClick.delete",disabled$:Jo(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}),ss="doc.menu.table-insert";function ud(o){return{id:ss,type:I.MenuItemType.SUBITEMS,title:"table.insert",icon:"InsertDoubleIcon",hidden$:U.combineLatest(I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC),Re(o),(t,e)=>t||e)}}function gd(o){return{id:yn.id,type:I.MenuItemType.BUTTON,title:"table.insertRowAbove",icon:"InsertRowAboveDoubleIcon",disabled$:Re(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function hd(o){return{id:bn.id,type:I.MenuItemType.BUTTON,title:"table.insertRowBelow",icon:"InsertRowBelowDoubleIcon",disabled$:Re(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function md(o){return{id:Rn.id,type:I.MenuItemType.BUTTON,title:"table.insertColumnLeft",icon:"LeftInsertColumnDoubleIcon",disabled$:Re(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function pd(o){return{id:xn.id,type:I.MenuItemType.BUTTON,title:"table.insertColumnRight",icon:"RightInsertColumnDoubleIcon",disabled$:Re(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}const as="doc.menu.table-delete";function fd(o){return{id:as,type:I.MenuItemType.SUBITEMS,title:"table.delete",icon:"ReduceDoubleIcon",hidden$:U.combineLatest(I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC),Re(o),(t,e)=>t||e)}}function Sd(o){return{id:Cn.id,type:I.MenuItemType.BUTTON,title:"table.deleteRows",icon:"DeleteRowDoubleIcon",disabled$:Re(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function Id(o){return{id:Tn.id,type:I.MenuItemType.BUTTON,title:"table.deleteColumns",icon:"DeleteColumnDoubleIcon",disabled$:Re(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function vd(o){return{id:ct.id,type:I.MenuItemType.BUTTON,title:"table.deleteTable",icon:"GridIcon",disabled$:Re(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}const cs={[I.RibbonStartGroup.FORMAT]:{[_e.id]:{order:0,menuItemFactory:lc},[Ne.id]:{order:1,menuItemFactory:dc},[Pe.id]:{order:2,menuItemFactory:Ac},[we.id]:{order:3,menuItemFactory:uc},[ye.id]:{order:4,menuItemFactory:gc},[Ue.id]:{order:5,menuItemFactory:hc},[le.id]:{order:5.5,menuItemFactory:fc},[me.id]:{order:6,menuItemFactory:pc},[Ge.id]:{order:7,menuItemFactory:mc},[Me.id]:{order:8,menuItemFactory:Sc},[De.id]:{order:9,menuItemFactory:Dc,[st.id]:{order:0,menuItemFactory:Mc}}},[I.RibbonStartGroup.LAYOUT]:{[Ot.id]:{order:2,menuItemFactory:Tc},[Mt.id]:{order:3,menuItemFactory:yc},[Dt.id]:{order:4,menuItemFactory:bc},[Bt.id]:{order:5,menuItemFactory:Rc},[Rt.id]:{order:6,menuItemFactory:xc},[ot.id]:{order:7,menuItemFactory:Mr},[nt.id]:{order:8,menuItemFactory:Dr},[Et.id]:{order:9,menuItemFactory:Br},[Io.id]:{order:10,menuItemFactory:Ic},[_t.id]:{order:11,menuItemFactory:Oc},[Xo.id]:{order:12,menuItemFactory:Bc}},[I.RibbonInsertGroup.MEDIA]:{[ts]:{order:2,menuItemFactory:Ec,[vn.id]:{order:0,menuItemFactory:Cc}}},[I.ContextMenuPosition.MAIN_AREA]:{[I.ContextMenuGroup.FORMAT]:{[vt.name]:{order:0,menuItemFactory:ad},[fn.id]:{order:1,menuItemFactory:ld},[Sn.id]:{order:2,menuItemFactory:dd},[bt.id]:{order:3,menuItemFactory:Ad}},[I.ContextMenuGroup.LAYOUT]:{[qo.id]:{order:0,menuItemFactory:cd},[ss]:{order:1,menuItemFactory:ud,[yn.id]:{order:1,menuItemFactory:gd},[bn.id]:{order:2,menuItemFactory:hd},[Rn.id]:{order:3,menuItemFactory:md},[xn.id]:{order:4,menuItemFactory:pd}},[as]:{order:2,menuItemFactory:fd,[Cn.id]:{order:1,menuItemFactory:Sd},[Tn.id]:{order:2,menuItemFactory:Id},[ct.id]:{order:3,menuItemFactory:vd}}}},[I.ContextMenuPosition.PARAGRAPH]:{[I.ContextMenuGroup.QUICK]:{[Ho.id]:{order:0,menuItemFactory:Nc},[ko.id]:{order:1,menuItemFactory:Pc},[Vo.id]:{order:2,menuItemFactory:wc},[jo.id]:{order:3,menuItemFactory:Uc},[Wo.id]:{order:4,menuItemFactory:Lc},[qt.id]:{order:5,menuItemFactory:Qc},[ot.id]:{order:6,menuItemFactory:Mr},[nt.id]:{order:7,menuItemFactory:Dr},[Et.id]:{order:8,menuItemFactory:Br}},[I.ContextMenuGroup.FORMAT]:{[Do.id]:{order:0,menuItemFactory:Fc},[Bo.id]:{order:1,menuItemFactory:Hc},[xo.id]:{order:2,menuItemFactory:kc}},[I.ContextMenuGroup.LAYOUT]:{[os]:{menuItemFactory:Xc,[Lo.id]:{order:0,menuItemFactory:Vc},[Qo.id]:{order:1,menuItemFactory:jc},[Fo.id]:{order:2,menuItemFactory:Wc},[No.id]:{order:3,menuItemFactory:Gc}}}}};var Ed=Object.getOwnPropertyDescriptor,Cd=(o,t,e,n)=>{for(var r=n>1?void 0:n?Ed(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Se=(o,t)=>(e,n)=>t(e,n,o);exports.DocUIController=class extends i.Disposable{constructor(t,e,n,r,s,a,c,l,A){super(),this._injector=t,this._componentManager=e,this._commandService=n,this._layoutService=r,this._menuManagerService=s,this._uiPartsService=a,this._univerInstanceService=c,this._shortcutService=l,this._configService=A,this._init()}_initCustomComponents(){[[wi,Ra],[Pi,ya],["TodoListDoubleIcon",Mi],["doc.paragraph.menu",ll],["CutIcon",pi],["DeleteIcon",fi],[Zn,ic],["DocumentSettingIcon",Si]].forEach(([t,e])=>{this.disposeWithMe(this._componentManager.register(t,e))})}_initUiParts(){this.disposeWithMe(this._uiPartsService.registerComponent(I.BuiltInUIPart.FOOTER,()=>I.connectInjector(Bl,this._injector))),this.disposeWithMe(this._uiPartsService.registerComponent(I.BuiltInUIPart.CONTENT,()=>I.connectInjector(Fl,this._injector)))}_initMenus(){this._menuManagerService.mergeMenu(cs)}_initShortCut(){[ml,pl,fl,Sl,Il,vl,Tl,yl,Cl,El,bl,Rl,gl].forEach(t=>{this.disposeWithMe(this._shortcutService.registerShortcut(t))})}_init(){this._initCustomComponents(),this._initMenus(),this._initFocusHandler(),this._initCommands(),this._initUiParts(),this._initShortCut()}_initCommands(){[Bi,Io,So].forEach(t=>this.disposeWithMe(this._commandService.registerCommand(t)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(i.UniverInstanceType.UNIVER_DOC,t=>{this._injector.get(B.IRenderManagerService).getRenderById(t).with(exports.DocSelectionRenderService).focus()}))}};exports.DocUIController=Cd([Se(0,i.Inject(i.Injector)),Se(1,i.Inject(I.ComponentManager)),Se(2,i.ICommandService),Se(3,I.ILayoutService),Se(4,I.IMenuManagerService),Se(5,I.IUIPartsService),Se(6,i.IUniverInstanceService),Se(7,I.IShortcutService),Se(8,i.IConfigService)],exports.DocUIController);var Td=Object.getOwnPropertyDescriptor,yd=(o,t,e,n)=>{for(var r=n>1?void 0:n?Td(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Fn=(o,t)=>(e,n)=>t(e,n,o);const Hr=1.5;exports.DocBackScrollRenderController=class extends i.RxDisposable{constructor(t,e,n,r){super(),this._context=t,this._textSelectionManagerService=e,this._editorService=n,this._docSkeletonManagerService=r,this._init()}_init(){this._textSelectionManagerService.textSelection$.pipe(U.takeUntil(this.dispose$)).subscribe(t=>{if(t==null)return;const{isEditing:e,unitId:n}=t;n!==this._context.unitId||!e||this._context.unitId!==i.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._scrollToSelection()})}scrollToRange(t){const e=this._docSkeletonManagerService.getSkeleton();if(!e)return;const{startOffset:n}=t,r=e.findNodePositionByCharIndex(n);r&&this.scrollToNode(r)}scrollToNode(t){var _;const{unitId:e,scene:n,mainComponent:r}=this._context,s=this._docSkeletonManagerService.getSkeleton();if(r==null||s==null)return;const a=r.getOffsetConfig(),{docsLeft:c,docsTop:l}=a,A=new ve(a,s),{contentBoxPointGroup:d}=A.getRangePointData(t,t),{left:u,top:m,height:g}=ft(d),h=u+c,p=m+l,f=n.getViewport(ie.VIEW_MAIN),S=this._editorService.getEditor(e);if(f==null)return;const{left:E,top:C,right:T,bottom:R}=f.getBounding().viewBound;let v=0,b=0;const x=S?(_=S.params.backScrollOffset)!=null?_:0:100;p<C?v=p-C-x:p>R-g&&(v=p-R+g+x),h<E?b=h-E:h>T-Hr&&(b=h-T+Hr);const y=f.transViewportScroll2ScrollValue(b,v);f.scrollByBarDeltaValue(y)}_scrollToSelection(){const t=this._textSelectionManagerService.getActiveTextRange();if(t==null)return;const{collapsed:e,startNodePosition:n}=t;e&&this.scrollToNode(n)}};exports.DocBackScrollRenderController=yd([Fn(1,i.Inject(D.DocSelectionManagerService)),Fn(2,ae),Fn(3,i.Inject(D.DocSkeletonManagerService))],exports.DocBackScrollRenderController);var bd=Object.getOwnPropertyDescriptor,Rd=(o,t,e,n)=>{for(var r=n>1?void 0:n?bd(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Ye=(o,t)=>(e,n)=>t(e,n,o);exports.DocRenderController=class extends i.RxDisposable{constructor(t,e,n,r,s,a,c){super(),this._context=t,this._commandService=e,this._docSelectionRenderService=n,this._docSkeletonManagerService=r,this._editorService=s,this._renderManagerService=a,this._univerInstanceService=c,this._addNewRender(),this._initRenderRefresh(),this._initCommandListener()}reRender(t){var a,c;const e=(a=this._renderManagerService.getRenderById(t))==null?void 0:a.with(D.DocSkeletonManagerService),n=e==null?void 0:e.getSkeleton();if(!n||!!n.getViewModel().getDataModel().getSnapshot().disabled)return;n.calculate();const s=this._editorService.getEditor(t);if(this._editorService.isEditor(t)&&!(s!=null&&s.params.scrollBar)){(c=this._context.mainComponent)==null||c.makeDirty();return}this._recalculateSizeBySkeleton(n)}_addNewRender(){const{scene:t,engine:e}=this._context,n=new B.Viewport(ie.VIEW_MAIN,t,{left:0,top:0,bottom:0,right:0,isWheelPreventDefaultX:!0});t.attachControl(),t.onMouseWheel$.subscribeEvent((s,a)=>{const c=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC);if((c==null?void 0:c.getUnitId())!==this._context.unitId)return;const l=s;if(l.ctrlKey){const A=Math.abs(l.deltaX);let d=A<40?.2:A<80?.4:.2;d*=l.deltaY>0?-1:1,t.scaleX<1&&(d/=2),t.scaleX+d>4?t.scale(4,4):t.scaleX+d<.1?t.scale(.1,.1):l.preventDefault()}else n.onMouseWheel(l,a)}),new B.ScrollBar(n),t.addLayer(new B.Layer(t,[],Vt),new B.Layer(t,[],ei)),this._addComponent();const r=()=>t.render();this.disposeWithMe(this._context.activated$.subscribe(s=>{s?e.runRenderLoop(r):e.stopRenderLoop(r)})),this._docSelectionRenderService.__attachScrollEvent()}_addComponent(){const{scene:t,unit:e,components:n}=this._context,a={pageMarginLeft:20,pageMarginTop:20},c=new B.Documents(de.MAIN,void 0,a);c.zIndex=kn;const l=new B.DocBackground(de.BACKGROUND,void 0,a);l.zIndex=kn,this._context.mainComponent=c,n.set(de.MAIN,c),n.set(de.BACKGROUND,l),t.addObjects([c],Vt),t.addObjects([l],$r),this._editorService.getEditor(e.getUnitId())==null&&t.enableLayerCache(Vt)}_initRenderRefresh(){this._docSkeletonManagerService.currentSkeletonBefore$.pipe(U.takeUntil(this.dispose$)).subscribe(t=>{this._create(t)})}_create(t){var l;if(!t)return;const{mainComponent:e,components:n}=this._context,r=e,s=n.get(de.BACKGROUND);r.changeSkeleton(t),s.changeSkeleton(t);const{unitId:a}=this._context,c=this._editorService.getEditor(a);if(this._editorService.isEditor(a)&&!(c!=null&&c.params.scrollBar)){(l=this._context.mainComponent)==null||l.makeDirty();return}this._recalculateSizeBySkeleton(t)}_initCommandListener(){const t=[D.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(t.includes(e.id)){const n=e.params,{unitId:r}=n;this.reRender(r)}}))}_recalculateSizeBySkeleton(t){var h;const{mainComponent:e,scene:n,unitId:r,components:s}=this._context,a=e,c=s.get(de.BACKGROUND),l=(h=t.getSkeletonData())==null?void 0:h.pages;if(l==null)return;let A=0,d=0;const m=this._context.unit.getSnapshot().documentStyle.documentFlavor;for(let p=0,f=l.length;p<f;p++){const S=l[p];let{pageWidth:E,pageHeight:C}=S;if(m===i.DocumentFlavor.MODERN){const T=xd(S);E=T.pageWidth,C=T.pageHeight}a.pageLayoutType===B.PageLayoutType.VERTICAL?(d+=C,d+=a.pageMarginTop,p===f-1&&(d+=a.pageMarginTop),A=Math.max(A,E)):a.pageLayoutType===B.PageLayoutType.HORIZONTAL&&(A+=E,p!==f-1&&(A+=a.pageMarginLeft),d=Math.max(d,C))}a.resize(A,d),c.resize(A,d);const g=this._editorService.getEditor(r);(!this._editorService.isEditor(r)||g!=null&&g.params.scrollBar)&&n.resize(A,d)}};exports.DocRenderController=Rd([Ye(1,i.ICommandService),Ye(2,i.Inject(exports.DocSelectionRenderService)),Ye(3,i.Inject(D.DocSkeletonManagerService)),Ye(4,ae),Ye(5,B.IRenderManagerService),Ye(6,i.IUniverInstanceService)],exports.DocRenderController);function xd(o){let{pageWidth:t,pageHeight:e}=o;const{marginLeft:n,marginRight:r,marginTop:s,marginBottom:a,skeDrawings:c,skeTables:l}=o;t===Number.POSITIVE_INFINITY&&(t=o.width+n+r),e===Number.POSITIVE_INFINITY&&(e=o.height+s+a);for(const A of c.values())t=Math.max(t,A.aLeft+A.width+n+r),e=Math.max(e,A.aTop+A.height+s+a);for(const A of l.values())t=Math.max(t,A.left+A.width+n+r),e=Math.max(e,A.top+A.height+s+a);return{pageWidth:t,pageHeight:e}}const Zo={id:"doc.command.select-all",type:i.CommandType.COMMAND,handler:async o=>{var g;const t=o.get(i.IUniverInstanceService),e=o.get(D.DocSelectionManagerService),n=t.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC),r=e.getDocRanges(),s=(g=r.find(h=>h.isActive))!=null?g:r[0];if(n==null||s==null)return!1;const{segmentId:a}=s,c=n.getUnitId(),l=n.getSelfOrHeaderFooterModel(a).getSnapshot().body;if(l==null)return!1;const{tables:A=[],dataStream:d}=l;if(d===`\r
|
|
35
|
+
`,{"univer-rounded-r-2xl univer-bg-white univer-shadow univer-backdrop-blur-[10px] dark:!univer-bg-gray-900":f}),style:{...s,transform:A?"translateX(0)":"translateX(-100%)",maxHeight:c,opacity:A?1:0,maxWidth:u!=null?u:a==="side-bar"?320:180,paddingRight:a==="float"?void 0:0},children:N.jsx("div",{ref:S,className:q.clsx("univer-flex-1 univer-overflow-y-auto univer-overflow-x-hidden",q.scrollbarClassName),children:e==null?void 0:e.map(T=>N.jsx("div",{id:`univer-side-menu-${T.id}`,className:q.clsx(_l,{[Nl]:T.isTitle,[Pl]:T.level===1,[wl]:T.level>1,"univer-text-gray-500 dark:!univer-text-gray-400":T.id!==l,"univer-text-gray-800 dark:!univer-text-gray-200":T.id===l}),style:{paddingLeft:(T.level-1)*12},onClick:()=>{n==null||n(T)},children:T.text},T.id))})})]})}),Ll=o=>{switch(o){case i.NamedStyleType.HEADING_1:return 1;case i.NamedStyleType.HEADING_2:return 2;case i.NamedStyleType.HEADING_3:return 3;case i.NamedStyleType.HEADING_4:return 4;case i.NamedStyleType.HEADING_5:return 5;case i.NamedStyleType.TITLE:return 1;default:return 1}};function Ql(o,t,e,n){var c,l;if(!o)return;const r=Array.from(o.values()),s=r.findIndex(A=>A.paragraphStart!==A.paragraphEnd&&A.rect.top<n&&A.rect.bottom>e);if(s===-1)return;const a=r==null?void 0:r.findLastIndex(A=>A.paragraphStart!==A.paragraphEnd&&A.rect.top<n&&A.rect.bottom>e);for(let A=s;A<=a;A++){const d=r[A],u=t.get(d.startIndex);if((c=u==null?void 0:u.paragraphStyle)!=null&&c.headingId)return u.paragraphStyle.headingId}for(let A=s;A>=0;A--){const d=r[A],u=t.get(d.startIndex);if((l=u==null?void 0:u.paragraphStyle)!=null&&l.headingId)return u.paragraphStyle.headingId}}const Lr="__title";function Fl(){var t,e,n;const o=I.useConfigValue(En);return(n=(e=(t=o==null?void 0:o.layout)==null?void 0:t.docContainerConfig)==null?void 0:e.sideMenu)==null||n?N.jsx(Hl,{}):null}function Hl(){var _,O,w,Q,k,F,L,G,W;const o=I.useDependency(i.ICommandService),t=I.useDependency(i.IUniverInstanceService),e=I.useObservable(P.useMemo(()=>t.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_DOC),[])),n=I.useDependency(B.IRenderManagerService),r=(O=(_=e==null?void 0:e.getBody())==null?void 0:_.dataStream)!=null?O:"",[s,a]=P.useState(0),[c,l]=P.useState(void 0),A=(w=e==null?void 0:e.getUnitId())!=null?w:"",d=n.getRenderById(A),u=e==null?void 0:e.getTitle(),m=d==null?void 0:d.with(exports.DocEventManagerService),g=m==null?void 0:m.paragraphBounds,h=(k=(Q=d==null?void 0:d.mainComponent)==null?void 0:Q.left)!=null?k:0,p=(F=d==null?void 0:d.engine.height)!=null?F:0,f=(L=d==null?void 0:d.scene.scaleY)!=null?L:1,S=(W=(G=e==null?void 0:e.getBody())==null?void 0:G.paragraphs)!=null?W:[],E=P.useMemo(()=>{const H=new Map;return S.forEach(V=>{H.set(V.startIndex,V)}),H},[S]);I.useObservable(P.useMemo(()=>d!=null&&d.engine.onTransformChange$?i.fromEventSubject(d==null?void 0:d.engine.onTransformChange$).pipe(U.throttleTime(33)):U.of(null),[d==null?void 0:d.engine.onTransformChange$]));const C=h<180?"float":"side-bar",T=S==null?void 0:S.filter(H=>{var V;return((V=H.paragraphStyle)==null?void 0:V.namedStyleType)!==void 0&&H.paragraphStyle.namedStyleType!==i.NamedStyleType.SUBTITLE&&H.paragraphStyle.namedStyleType!==i.NamedStyleType.NORMAL_TEXT}).map(H=>{var Y;const V=Ll(H.paragraphStyle.namedStyleType),j=g==null?void 0:g.get(H.startIndex);if(!j)return null;const{paragraphStart:X,paragraphEnd:z}=j;return{id:H.paragraphStyle.headingId,text:i.getPlainText(r.slice(X,z)),level:V,isTitle:((Y=H.paragraphStyle)==null?void 0:Y.namedStyleType)===i.NamedStyleType.TITLE}}).filter(H=>H==null?void 0:H.text),R=I.useEvent(H=>{const V=H.viewportScrollY,j=V+p/f,X=Ql(g,E,V,j);X&&l(X)}),v=T!=null&&T.find(H=>H.isTitle)?T:[...u?[{id:Lr,text:u,level:1,isTitle:!0}]:[],...T!=null?T:[]].filter(Boolean),[b,x]=P.useState(!0);P.useEffect(()=>{const H=i.debounce(a,100),V=o.onCommandExecuted(j=>{j.id===D.RichTextEditingMutation.id&&j.params.unitId===(e==null?void 0:e.getUnitId())&&H(z=>z+1)});return()=>{V.dispose()}},[o,e]),P.useEffect(()=>{const H=d==null?void 0:d.scene.getViewport(ie.VIEW_MAIN);if(!H)return;const V=i.fromEventSubject(H.onScrollAfter$).pipe(U.throttleTime(33)).subscribe(R);return()=>{V.unsubscribe()}},[d]);const y=I.useEvent(H=>{const V=d==null?void 0:d.scene.getViewport(ie.VIEW_MAIN);if(!V)return;if(H.id===Lr){V.scrollToViewportPos({viewportScrollY:0});return}const j=S.find(z=>{var Y;return((Y=z.paragraphStyle)==null?void 0:Y.headingId)===H.id});if(!j)return;const X=g==null?void 0:g.get(j.startIndex);X&&(V.scrollToViewportPos({viewportScrollY:X.rect.top}),l(H.id))});return!e||i.isInternalEditorID(A)||!(v!=null&&v.length)?null:N.jsx("div",{className:"univer-absolute univer-bottom-0 univer-left-0 univer-top-0 univer-z-[100] univer-w-[0px]",children:N.jsx(Ul,{menus:v,open:b,onOpenChange:x,mode:C,maxWidth:C==="float"?void 0:Math.floor(h),wrapperClass:"univer-mt-12",activeId:c,onClick:y,maxHeight:p-48})})}const Cn={id:"doc.table.delete-rows",type:i.CommandType.COMMAND,handler:async o=>{const t=o.get(D.DocSelectionManagerService),e=o.get(i.IUniverInstanceService),n=o.get(i.ICommandService),r=t.getRectRanges(),s=t.getActiveTextRange(),a=Tt(s,r);if(a==null)return!1;const{segmentId:c}=a,l=e.getCurrentUniverDocInstance(),A=l==null?void 0:l.getSelfOrHeaderFooterModel(c).getBody();if(l==null||A==null)return!1;const d=ce(o,l.getUnitId());if(d==null)return!1;const u=d.getViewModel(),m=l==null?void 0:l.getUnitId(),g=new i.TextX,h=i.JSONX.getInstance(),p=Ui(a,u);if(p==null)return!1;const{offset:f,rowIndexes:S,len:E,tableId:C,cursor:T,selectWholeTable:R}=p;if(R)return n.executeCommand(ct.id);const v=[],b=[{startOffset:T,endOffset:T,collapsed:!0}],x={id:D.RichTextEditingMutation.id,params:{unitId:m,actions:[],textRanges:b}};f>0&&g.push({t:i.TextXActionType.RETAIN,len:f}),g.push({t:i.TextXActionType.DELETE,len:E});const y=J(l,c);v.push(h.editOp(g.serialize(),y));for(const O of S.reverse()){const w=h.removeOp(["tableSource",C,"tableRows",O]);v.push(w)}return x.params.actions=v.reduce((O,w)=>i.JSONX.compose(O,w),null),!!n.syncExecuteCommand(x.id,x.params)}},Tn={id:"doc.table.delete-columns",type:i.CommandType.COMMAND,handler:async o=>{const t=o.get(D.DocSelectionManagerService),e=o.get(i.IUniverInstanceService),n=o.get(i.ICommandService),r=t.getRectRanges(),s=t.getActiveTextRange(),a=Tt(s,r);if(a==null)return!1;const{segmentId:c}=a,l=e.getCurrentUniverDocInstance(),A=l==null?void 0:l.getSelfOrHeaderFooterModel(c).getBody();if(l==null||A==null)return!1;const d=ce(o,l.getUnitId());if(d==null)return!1;const u=d.getViewModel(),m=l==null?void 0:l.getUnitId(),g=new i.TextX,h=i.JSONX.getInstance(),p=Na(a,u);if(p==null)return!1;const{offsets:f,columnIndexes:S,tableId:E,cursor:C,rowCount:T,selectWholeTable:R}=p;if(R)return n.executeCommand(ct.id);const v=[],b=[{startOffset:C,endOffset:C,collapsed:!0}],x={id:D.RichTextEditingMutation.id,params:{unitId:m,actions:[],textRanges:b}};for(const O of f){const{retain:w,delete:Q}=O;w>0&&g.push({t:i.TextXActionType.RETAIN,len:w}),g.push({t:i.TextXActionType.DELETE,len:Q})}const y=J(l,c);v.push(h.editOp(g.serialize(),y)),S.reverse();for(let O=0;O<T;O++)for(const w of S){const Q=h.removeOp(["tableSource",E,"tableRows",O,"tableCells",w]);v.push(Q)}for(const O of S){const w=h.removeOp(["tableSource",E,"tableColumns",O]);v.push(w)}return x.params.actions=v.reduce((O,w)=>i.JSONX.compose(O,w),null),!!n.syncExecuteCommand(x.id,x.params)}},ct={id:"doc.table.delete-table",type:i.CommandType.COMMAND,handler:async o=>{const t=o.get(D.DocSelectionManagerService),e=o.get(i.IUniverInstanceService),n=o.get(i.ICommandService),r=t.getRectRanges(),s=t.getActiveTextRange(),a=Tt(s,r);if(a==null)return!1;const{segmentId:c}=a,l=e.getCurrentUniverDocInstance(),A=l==null?void 0:l.getSelfOrHeaderFooterModel(c).getBody();if(l==null||A==null)return!1;const d=ce(o,l.getUnitId());if(d==null)return!1;const u=d.getViewModel(),m=l==null?void 0:l.getUnitId(),g=new i.TextX,h=i.JSONX.getInstance(),p=Li(a,u);if(p==null)return!1;const{offset:f,len:S,tableId:E,cursor:C}=p,T=[],R=[{startOffset:C,endOffset:C,collapsed:!0}],v={id:D.RichTextEditingMutation.id,params:{unitId:m,actions:[],textRanges:R}};f>0&&g.push({t:i.TextXActionType.RETAIN,len:f}),g.push({t:i.TextXActionType.DELETE,len:S});const b=J(l,c);T.push(h.editOp(g.serialize(),b));const x=h.removeOp(["tableSource",E]);return T.push(x),v.params.actions=T.reduce((_,O)=>i.JSONX.compose(_,O),null),!!n.syncExecuteCommand(v.id,v.params)}},Ko="doc.command.table-insert-row",zo="doc.command.table-insert-column",kl="doc.command.table-insert-row-above",Vl="doc.command.table-insert-row-bellow",jl="doc.command.table-insert-column-left",Wl="doc.command.table-insert-column-right",yn={id:kl,type:i.CommandType.COMMAND,handler:async o=>o.get(i.ICommandService).executeCommand(Ko,{position:ln.ABOVE})},bn={id:Vl,type:i.CommandType.COMMAND,handler:async o=>o.get(i.ICommandService).executeCommand(Ko,{position:ln.BELLOW})},Rn={id:jl,type:i.CommandType.COMMAND,handler:async o=>o.get(i.ICommandService).executeCommand(zo,{position:Eo.LEFT})},xn={id:Wl,type:i.CommandType.COMMAND,handler:async o=>o.get(i.ICommandService).executeCommand(zo,{position:Eo.RIGHT})},Yo={id:Ko,type:i.CommandType.COMMAND,handler:async(o,t)=>{const{position:e}=t,n=o.get(D.DocSelectionManagerService),r=o.get(i.IUniverInstanceService),s=o.get(i.ICommandService),a=n.getRectRanges(),c=n.getActiveTextRange(),l=Tt(c,a);if(l==null)return!1;const{segmentId:A}=l,d=r.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC),u=d==null?void 0:d.getSelfOrHeaderFooterModel(A).getBody();if(d==null||u==null)return!1;const m=ce(o,d.getUnitId());if(m==null)return!1;const g=m.getViewModel(),h=d==null?void 0:d.getUnitId(),p=new i.TextX,f=i.JSONX.getInstance(),S=Da(l,e,g);if(S==null)return!1;const{offset:E,colCount:C,tableId:T,insertRowIndex:R}=S,v=[],b=E+2,x=[{startOffset:b,endOffset:b,collapsed:!0}],y={id:D.RichTextEditingMutation.id,params:{unitId:h,actions:[],textRanges:x}};E>0&&p.push({t:i.TextXActionType.RETAIN,len:E});const _=Oa(C);p.push({t:i.TextXActionType.INSERT,body:_,len:_.dataStream.length});const O=J(d,A);v.push(f.editOp(p.serialize(),O));const w=An(C),Q=f.insertOp(["tableSource",T,"tableRows",R],w);return v.push(Q),y.params.actions=v.reduce((F,L)=>i.JSONX.compose(F,L),null),!!s.syncExecuteCommand(y.id,y.params)}},is={id:zo,type:i.CommandType.COMMAND,handler:async(o,t)=>{var X,z,Y;const{position:e}=t,n=o.get(D.DocSelectionManagerService),r=o.get(i.IUniverInstanceService),s=o.get(i.ICommandService),a=n.getRectRanges(),c=n.getActiveTextRange(),l=Tt(c,a);if(l==null)return!1;const{segmentId:A}=l,d=r.getCurrentUniverDocInstance(),u=d==null?void 0:d.getSelfOrHeaderFooterModel(A).getBody();if(d==null||u==null)return!1;const m=ce(o,d.getUnitId());if(m==null)return!1;const g=m.getViewModel(),h=d==null?void 0:d.getUnitId(),p=new i.TextX,f=i.JSONX.getInstance(),S=Ba(l,e,g);if(S==null)return!1;const{offsets:E,columnIndex:C,tableId:T,rowCount:R}=S,v=[],b=E[0]+1,x=[{startOffset:b,endOffset:b,collapsed:!0}],y={id:D.RichTextEditingMutation.id,params:{unitId:h,actions:[],textRanges:x}};for(const K of E){p.push({t:i.TextXActionType.RETAIN,len:K});const Z=Ma();p.push({t:i.TextXActionType.INSERT,body:Z,len:Z.dataStream.length})}const _=J(d,A);v.push(f.editOp(p.serialize(),_));for(let K=0;K<R;K++){const Z=dn(),ne=f.insertOp(["tableSource",T,"tableRows",K,"tableCells",C],Z);v.push(ne)}const O=d.getSnapshot(),w=O.documentStyle,{marginLeft:Q=0,marginRight:k=0}=w,F=((z=(X=w.pageSize)==null?void 0:X.width)!=null?z:800)-Q-k,L=(Y=O==null?void 0:O.tableSource)==null?void 0:Y[T].tableColumns,{newColWidth:G,widths:W}=_a(F,L,C);for(let K=0;K<W.length;K++){const Z=f.replaceOp(["tableSource",T,"tableColumns",K,"size","width","v"],L[K].size.width.v,W[K]);v.push(Z)}const H=un(G),V=f.insertOp(["tableSource",T,"tableColumns",C],H);return v.push(V),y.params.actions=v.reduce((K,Z)=>i.JSONX.compose(K,Z),null),!!s.syncExecuteCommand(y.id,y.params)}},fe={id:"doc-paragraph-setting.command",type:i.CommandType.COMMAND,handler:async(o,t)=>{var C,T,R,v,b;const e=o.get(D.DocSelectionManagerService),n=o.get(i.IUniverInstanceService),r=o.get(i.ICommandService),s=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC),a=e.getDocRanges();if(!s||a.length===0||!t)return!1;const c=a[0].segmentId,l=s.getUnitId(),A=s.getSelfOrHeaderFooterModel(c),d=(T=(C=A.getBody())==null?void 0:C.paragraphs)!=null?T:[],u=(v=(R=A.getBody())==null?void 0:R.dataStream)!=null?v:"",m=(b=i.BuildTextUtils.range.getParagraphsInRanges(a,d,u))!=null?b:[],g={id:D.RichTextEditingMutation.id,params:{unitId:l,actions:[],textRanges:a}},h=new i.MemoryCursor;h.reset();const p=new i.TextX,f=i.JSONX.getInstance();for(const x of m){const{startIndex:y}=x;p.push({t:i.TextXActionType.RETAIN,len:y-h.cursor});const _={...x.paragraphStyle,...t.paragraph};p.push({t:i.TextXActionType.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...x,paragraphStyle:_,startIndex:0}]},coverType:i.UpdateDocsAttributeType.REPLACE}),h.moveCursorTo(y+1)}const S=J(s,c);return g.params.actions=f.editOp(p.serialize(),S),!!r.syncExecuteCommand(g.id,g.params)}},Gl=()=>{const o=I.useDependency(D.DocSelectionManagerService),t=I.useDependency(it),e=P.useMemo(()=>o.getDocRanges(),[]);return P.useEffect(()=>{e.length||t.closePanel()},[e]),e},Xl=()=>{var l,A,d,u,m;const t=I.useDependency(i.IUniverInstanceService).getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC),e=Gl();if(!t||e.length===0)return[];const n=e[0].segmentId,r=t.getSelfOrHeaderFooterModel(n),s=(A=(l=r.getBody())==null?void 0:l.paragraphs)!=null?A:[],a=(u=(d=r.getBody())==null?void 0:d.dataStream)!=null?u:"";return(m=i.BuildTextUtils.range.getParagraphsInRanges(e,s,a))!=null?m:[]},Kl=(o,t)=>{const e=I.useDependency(i.ICommandService),[n,r]=P.useState(()=>{var c,l;const a=o[0];return a?String((l=(c=a.paragraphStyle)==null?void 0:c.horizontalAlign)!=null?l:t):t});return[n,a=>(r(a),e.executeCommand(fe.id,{paragraph:{horizontalAlign:Number(a)}}))]},zl=o=>{const t=I.useDependency(i.ICommandService),[e,n]=P.useState(()=>{var a;const s=o[0];return s?B.getNumberUnitValue((a=s.paragraphStyle)==null?void 0:a.indentStart,0):0});return[e,s=>(n(s),t.executeCommand(fe.id,{paragraph:{indentStart:{v:s}}}))]},Yl=o=>{const t=I.useDependency(i.ICommandService),[e,n]=P.useState(()=>{var a;const s=o[0];return s?B.getNumberUnitValue((a=s.paragraphStyle)==null?void 0:a.indentEnd,0):0});return[e,s=>(n(s),t.executeCommand(fe.id,{paragraph:{indentEnd:{v:s}}}))]},ql=o=>{const t=I.useDependency(i.ICommandService),[e,n]=P.useState(()=>{var a;const s=o[0];return s?B.getNumberUnitValue((a=s.paragraphStyle)==null?void 0:a.indentFirstLine,0):0});return[e,s=>(n(s),t.executeCommand(fe.id,{paragraph:{indentFirstLine:{v:s}}}))]},Jl=o=>{const t=I.useDependency(i.ICommandService),[e,n]=P.useState(()=>{var a;const s=o[0];return s?B.getNumberUnitValue((a=s.paragraphStyle)==null?void 0:a.hanging,0):0});return[e,s=>(n(s),t.executeCommand(fe.id,{paragraph:{hanging:{v:s}}}))]},Zl=o=>{const t=I.useDependency(i.ICommandService),[e,n]=P.useState(()=>{var a;const s=o[0];return s?B.getNumberUnitValue((a=s.paragraphStyle)==null?void 0:a.spaceAbove,0):0});return[e,s=>(n(s),t.executeCommand(fe.id,{paragraph:{spaceAbove:{v:s}}}))]},$l=o=>{const t=I.useDependency(i.ICommandService),[e,n]=P.useState(()=>{var a;const s=o[0];return s?B.getNumberUnitValue((a=s.paragraphStyle)==null?void 0:a.spaceBelow,0):0});return[e,s=>(n(s),t.executeCommand(fe.id,{paragraph:{spaceBelow:{v:s}}}))]},ed=o=>{const t=I.useDependency(i.ICommandService),e=I.useDependency(B.IRenderManagerService),n=I.useDependency(i.IUniverInstanceService),r=P.useMemo(()=>{var h;const g=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC);if(g)return(h=e.getRenderById(g==null?void 0:g.getUnitId()))==null?void 0:h.with(D.DocSkeletonManagerService).getSkeleton()},[]),s=P.useMemo(()=>new U.BehaviorSubject({}),[]),[a,c]=P.useState(()=>{var h,p;const g=o[0];return g&&(p=(h=g.paragraphStyle)==null?void 0:h.lineSpacing)!=null?p:1}),l=P.useRef(a),[A,d]=P.useState(()=>{var h,p;const g=o[0];return g&&(p=(h=g.paragraphStyle)==null?void 0:h.spacingRule)!=null?p:i.SpacingRule.AUTO}),u=async g=>{c(g),s.next({lineSpacing:g,spacingRule:A})},m=async g=>{if(g!==A){let h=l.current;if(g===i.SpacingRule.AT_LEAST){const p=r==null?void 0:r.findNodeByCharIndex(o[0].startIndex),f=p==null?void 0:p.parent,S=f==null?void 0:f.parent;(S==null?void 0:S.contentHeight)!==void 0&&(h=Math.max(S.contentHeight,h))}else h>5&&(h=2);l.current=a,u(h),d(g),s.next({spacingRule:g})}};return P.useEffect(()=>{const g=s.pipe(mt.filter(h=>!!Object.keys(h).length),mt.bufferTime(16),mt.filter(h=>!!h.length),mt.map(h=>h.reduce((p,f)=>(Object.keys(f).forEach(S=>{p[S]=f[S]}),p),{}))).subscribe(h=>t.executeCommand(fe.id,{paragraph:{...h}}));return()=>g.unsubscribe()},[]),{lineSpacing:[a,u],spacingRule:[A,m]}},ke=o=>{const{value:t,onChange:e,className:n="",min:r=0,max:s=100,step:a=1}=o,c=P.useRef(null);return N.jsx(q.InputNumber,{step:a,ref:c,min:r,max:s,value:t,onChange:l=>{e(l!=null?l:0).finally(()=>{setTimeout(()=>{var A;(A=c.current)==null||A.focus()},30)})},className:n})};function td(){const o=I.useDependency(i.LocaleService),t=P.useMemo(()=>[{label:o.t("toolbar.alignLeft"),value:String(i.HorizontalAlign.LEFT),icon:N.jsx(xi,{})},{label:o.t("toolbar.alignCenter"),value:String(i.HorizontalAlign.CENTER),icon:N.jsx(bi,{})},{label:o.t("toolbar.alignRight"),value:String(i.HorizontalAlign.RIGHT),icon:N.jsx(Oi,{})},{label:o.t("toolbar.alignJustify"),value:String(i.HorizontalAlign.JUSTIFIED),icon:N.jsx(hi,{})}],[]),e=Xl(),[n,r]=Kl(e,t[0].value),[s,a]=zl(e),[c,l]=Yl(e),[A,d]=ql(e),[u,m]=Jl(e),[g,h]=Zl(e),[p,f]=$l(e),{lineSpacing:[S,E],spacingRule:[C,T]}=ed(e),R=P.useMemo(()=>C===i.SpacingRule.AUTO?{min:1,max:5,step:S<2?.5:1}:{min:1,max:100},[C,S]);return N.jsxs("div",{children:[N.jsx("div",{className:"univer-t-4 univer-text-sm univer-font-medium",children:o.t("doc.paragraphSetting.alignment")}),N.jsx("div",{className:q.clsx("univer-mt-4 univer-box-border univer-flex univer-w-full univer-items-center univer-justify-between univer-gap-1 univer-rounded-md univer-p-1",q.borderClassName),children:t.map(v=>N.jsx(q.Tooltip,{title:v.label,placement:"bottom",children:N.jsx("span",{className:q.clsx("hover:univer-bg-black/60 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-bg-none univer-px-3 univer-py-1",{"univer-bg-blend-color-dodge/90":n===v.value}),onClick:()=>r(v.value),children:v.icon})},v.value))}),N.jsx("div",{className:"univer-t-4 univer-text-sm univer-font-medium",children:o.t("doc.paragraphSetting.indentation")}),N.jsxs("div",{children:[N.jsxs("div",{className:"univer-item-center univer-flex univer-justify-between",children:[N.jsxs("div",{className:"univer-mt-3 univer-text-xs",children:[o.t("doc.paragraphSetting.left"),"(px)"]}),N.jsx(ke,{className:"univer-mt-4",value:s,onChange:v=>a(v!=null?v:0)})]}),N.jsxs("div",{className:"univer-item-center univer-flex univer-justify-between",children:[N.jsxs("div",{className:"univer-mt-3 univer-text-xs",children:[o.t("doc.paragraphSetting.right"),"(px)"]}),N.jsx(ke,{className:"univer-mt-4",value:c,onChange:v=>l(v!=null?v:0)})]}),N.jsxs("div",{className:"univer-item-center univer-flex univer-justify-between",children:[N.jsxs("div",{className:"univer-mt-3 univer-text-xs",children:[o.t("doc.paragraphSetting.firstLine"),"(px)"]}),N.jsx(ke,{className:"univer-mt-4",value:A,onChange:v=>d(v!=null?v:0)})]}),N.jsxs("div",{className:"univer-item-center univer-flex univer-justify-between",children:[N.jsxs("div",{className:"univer-mt-3 univer-text-xs",children:[o.t("doc.paragraphSetting.hanging"),"(px)"]}),N.jsx(ke,{className:"univer-mt-4",value:u,onChange:v=>m(v!=null?v:0)})]})]}),N.jsx("div",{className:"univer-t-4 univer-text-sm univer-font-medium",children:o.t("doc.paragraphSetting.spacing")}),N.jsxs("div",{children:[N.jsxs("div",{className:"univer-justify-betweenuniver-item-center univer-flex",children:[N.jsxs("div",{className:"univer-mt-3 univer-text-xs",children:[o.t("doc.paragraphSetting.before"),"(px)"]}),N.jsx(ke,{className:"univer-mt-4",value:g,onChange:v=>h(v!=null?v:0)})]}),N.jsxs("div",{className:"univer-item-center univer-flex univer-justify-between",children:[N.jsxs("div",{className:"univer-mt-3 univer-text-xs",children:[o.t("doc.paragraphSetting.after"),"(px)"]}),N.jsx(ke,{className:"univer-mt-4",value:p,onChange:v=>f(v!=null?v:0)})]}),N.jsxs("div",{className:"item-center univer-flex univer-justify-between",children:[N.jsx("div",{className:"univer-mt-3 univer-text-xs",children:o.t("doc.paragraphSetting.lineSpace")}),N.jsxs("div",{className:"univer-mt-4 univer-flex univer-w-[162px] univer-flex-col univer-gap-1.5",children:[N.jsx(q.Select,{value:`${C}`,options:[{label:o.t("doc.paragraphSetting.multiSpace"),value:`${i.SpacingRule.AUTO}`},{label:o.t("doc.paragraphSetting.fixedValue"),value:`${i.SpacingRule.AT_LEAST}`}],onChange:v=>T(Number(v))}),N.jsx(ke,{...R,value:S,onChange:v=>E(v!=null?v:0)})]})]})]})]})}const nd=(o,t)=>t.length===o.length&&o.some(e=>t.some(n=>n.startOffset===e.startOffset&&n.endOffset===e.endOffset));function od(){const o=I.useDependency(i.ICommandService),t=I.useDependency(i.LocaleService),e=I.useObservable(t.currentLocale$),[n,r]=P.useState(""),s=P.useMemo(()=>i.debounce(()=>r(i.generateRandomId(4)),300),[]),a=P.useRef([]);return P.useEffect(()=>{const c=o.onCommandExecuted(l=>{if(D.SetTextSelectionsOperation.id===l.id){const A=l.params.ranges;nd(A,a.current)||r(i.generateRandomId(4)),a.current=A}D.RichTextEditingMutation.id===l.id&&l.params.trigger!==fe.id&&s()});return()=>c.dispose()},[s]),P.useEffect(()=>{r(i.generateRandomId(4))},[e]),P.useEffect(()=>()=>s.cancel(),[s]),N.jsx(td,{},n)}var rd=Object.getOwnPropertyDescriptor,id=(o,t,e,n)=>{for(var r=n>1?void 0:n?rd(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Qn=(o,t)=>(e,n)=>t(e,n,o);const Qr="doc_ui_paragraph-setting-panel";let it=class extends i.Disposable{constructor(t,e,n){super();M(this,"_id");this._commandService=t,this._componentManager=e,this._sidebarService=n,this._init()}_init(){this.disposeWithMe(this._componentManager.register(Qr,od))}openPanel(){const t={header:{title:"doc.slider.paragraphSetting"},id:this._id,children:{label:Qr},width:300};this._sidebarService.open(t)}closePanel(){this._sidebarService.close(this._id)}};it=id([Qn(0,i.ICommandService),Qn(1,i.Inject(I.ComponentManager)),Qn(2,i.Inject(I.ISidebarService))],it);const qo={id:"sidebar.operation.doc-paragraph-setting-panel",type:i.CommandType.OPERATION,handler:o=>(o.get(it).openPanel(),!0)},Jo=o=>{const t=o.get(D.DocSelectionManagerService);return new U.Observable(e=>{const n=t.textSelection$.subscribe(()=>{t.getDocRanges().some(a=>a.collapsed===!1||a.rangeType===i.DOC_RANGE_TYPE.RECT)?e.next(!1):e.next(!0)});return()=>n.unsubscribe()})};function sd(o){if(o.length<2)return!0;const t=o.map(e=>e.tableId);return t.every(e=>e===t[0])}function Fr(o,t,e){var s;const n=t.getRectRanges(),r=t.getActiveTextRange();if(n&&n.length&&sd(n)&&r==null){o.next(!1);return}if(r&&(n==null||n.length===0)){const{segmentId:a,startOffset:c,endOffset:l}=r,A=e.getCurrentUniverDocInstance(),d=(s=A==null?void 0:A.getSelfOrHeaderFooterModel(a).getBody())==null?void 0:s.tables;if(d&&d.length&&d.some(u=>{const{startIndex:m,endIndex:g}=u;return c>m&&c<g||l>m&&l<g})){o.next(!1);return}}o.next(!0)}const Re=o=>{const t=o.get(D.DocSelectionManagerService),e=o.get(i.IUniverInstanceService);return new U.Observable(n=>{const r=t.textSelection$.subscribe(()=>{Fr(n,t,e)});return Fr(n,t,e),()=>r.unsubscribe()})},ad=o=>({id:vt.name,commandId:vt.id,type:I.MenuItemType.BUTTON,icon:"CopyDoubleIcon",title:"rightClick.copy",disabled$:Jo(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}),cd=o=>({id:qo.id,type:I.MenuItemType.BUTTON,icon:"MenuIcon",title:"doc.menu.paragraphSetting",hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}),ld=o=>({id:fn.id,type:I.MenuItemType.BUTTON,icon:"CopyDoubleIcon",title:"rightClick.cut",disabled$:Jo(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}),dd=o=>({id:Sn.id,type:I.MenuItemType.BUTTON,icon:"PasteSpecialDoubleIcon",title:"rightClick.paste",hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}),Ad=o=>({id:bt.id,type:I.MenuItemType.BUTTON,icon:"PasteSpecialDoubleIcon",title:"rightClick.delete",disabled$:Jo(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}),ss="doc.menu.table-insert";function ud(o){return{id:ss,type:I.MenuItemType.SUBITEMS,title:"table.insert",icon:"InsertDoubleIcon",hidden$:U.combineLatest(I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC),Re(o),(t,e)=>t||e)}}function gd(o){return{id:yn.id,type:I.MenuItemType.BUTTON,title:"table.insertRowAbove",icon:"InsertRowAboveDoubleIcon",disabled$:Re(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function hd(o){return{id:bn.id,type:I.MenuItemType.BUTTON,title:"table.insertRowBelow",icon:"InsertRowBelowDoubleIcon",disabled$:Re(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function md(o){return{id:Rn.id,type:I.MenuItemType.BUTTON,title:"table.insertColumnLeft",icon:"LeftInsertColumnDoubleIcon",disabled$:Re(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function pd(o){return{id:xn.id,type:I.MenuItemType.BUTTON,title:"table.insertColumnRight",icon:"RightInsertColumnDoubleIcon",disabled$:Re(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}const as="doc.menu.table-delete";function fd(o){return{id:as,type:I.MenuItemType.SUBITEMS,title:"table.delete",icon:"ReduceDoubleIcon",hidden$:U.combineLatest(I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC),Re(o),(t,e)=>t||e)}}function Sd(o){return{id:Cn.id,type:I.MenuItemType.BUTTON,title:"table.deleteRows",icon:"DeleteRowDoubleIcon",disabled$:Re(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function Id(o){return{id:Tn.id,type:I.MenuItemType.BUTTON,title:"table.deleteColumns",icon:"DeleteColumnDoubleIcon",disabled$:Re(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}function vd(o){return{id:ct.id,type:I.MenuItemType.BUTTON,title:"table.deleteTable",icon:"GridIcon",disabled$:Re(o),hidden$:I.getMenuHiddenObservable(o,i.UniverInstanceType.UNIVER_DOC)}}const cs={[I.RibbonStartGroup.FORMAT]:{[_e.id]:{order:0,menuItemFactory:lc},[Ne.id]:{order:1,menuItemFactory:dc},[Pe.id]:{order:2,menuItemFactory:Ac},[we.id]:{order:3,menuItemFactory:uc},[ye.id]:{order:4,menuItemFactory:gc},[Ue.id]:{order:5,menuItemFactory:hc},[le.id]:{order:5.5,menuItemFactory:fc},[me.id]:{order:6,menuItemFactory:pc},[Ge.id]:{order:7,menuItemFactory:mc},[Me.id]:{order:8,menuItemFactory:Sc},[De.id]:{order:9,menuItemFactory:Dc,[st.id]:{order:0,menuItemFactory:Mc}}},[I.RibbonStartGroup.LAYOUT]:{[Ot.id]:{order:2,menuItemFactory:Tc},[Mt.id]:{order:3,menuItemFactory:yc},[Dt.id]:{order:4,menuItemFactory:bc},[Bt.id]:{order:5,menuItemFactory:Rc},[Rt.id]:{order:6,menuItemFactory:xc},[ot.id]:{order:7,menuItemFactory:Mr},[nt.id]:{order:8,menuItemFactory:Dr},[Et.id]:{order:9,menuItemFactory:Br},[Io.id]:{order:10,menuItemFactory:Ic},[_t.id]:{order:11,menuItemFactory:Oc},[Xo.id]:{order:12,menuItemFactory:Bc}},[I.RibbonInsertGroup.MEDIA]:{[ts]:{order:2,menuItemFactory:Ec,[vn.id]:{order:0,menuItemFactory:Cc}}},[I.ContextMenuPosition.MAIN_AREA]:{[I.ContextMenuGroup.FORMAT]:{[vt.name]:{order:0,menuItemFactory:ad},[fn.id]:{order:1,menuItemFactory:ld},[Sn.id]:{order:2,menuItemFactory:dd},[bt.id]:{order:3,menuItemFactory:Ad}},[I.ContextMenuGroup.LAYOUT]:{[qo.id]:{order:0,menuItemFactory:cd},[ss]:{order:1,menuItemFactory:ud,[yn.id]:{order:1,menuItemFactory:gd},[bn.id]:{order:2,menuItemFactory:hd},[Rn.id]:{order:3,menuItemFactory:md},[xn.id]:{order:4,menuItemFactory:pd}},[as]:{order:2,menuItemFactory:fd,[Cn.id]:{order:1,menuItemFactory:Sd},[Tn.id]:{order:2,menuItemFactory:Id},[ct.id]:{order:3,menuItemFactory:vd}}}},[I.ContextMenuPosition.PARAGRAPH]:{[I.ContextMenuGroup.QUICK]:{[Ho.id]:{order:0,menuItemFactory:Nc},[ko.id]:{order:1,menuItemFactory:Pc},[Vo.id]:{order:2,menuItemFactory:wc},[jo.id]:{order:3,menuItemFactory:Uc},[Wo.id]:{order:4,menuItemFactory:Lc},[qt.id]:{order:5,menuItemFactory:Qc},[ot.id]:{order:6,menuItemFactory:Mr},[nt.id]:{order:7,menuItemFactory:Dr},[Et.id]:{order:8,menuItemFactory:Br}},[I.ContextMenuGroup.FORMAT]:{[Do.id]:{order:0,menuItemFactory:Fc},[Bo.id]:{order:1,menuItemFactory:Hc},[xo.id]:{order:2,menuItemFactory:kc}},[I.ContextMenuGroup.LAYOUT]:{[os]:{menuItemFactory:Xc,[Lo.id]:{order:0,menuItemFactory:Vc},[Qo.id]:{order:1,menuItemFactory:jc},[Fo.id]:{order:2,menuItemFactory:Wc},[No.id]:{order:3,menuItemFactory:Gc}}}}};var Ed=Object.getOwnPropertyDescriptor,Cd=(o,t,e,n)=>{for(var r=n>1?void 0:n?Ed(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Se=(o,t)=>(e,n)=>t(e,n,o);exports.DocUIController=class extends i.Disposable{constructor(t,e,n,r,s,a,c,l,A){super(),this._injector=t,this._componentManager=e,this._commandService=n,this._layoutService=r,this._menuManagerService=s,this._uiPartsService=a,this._univerInstanceService=c,this._shortcutService=l,this._configService=A,this._init()}_initCustomComponents(){[[wi,Ra],[Pi,ya],["TodoListDoubleIcon",Mi],["doc.paragraph.menu",ll],["CutIcon",pi],["DeleteIcon",fi],[Zn,ic],["DocumentSettingIcon",Si]].forEach(([t,e])=>{this.disposeWithMe(this._componentManager.register(t,e))})}_initUiParts(){this.disposeWithMe(this._uiPartsService.registerComponent(I.BuiltInUIPart.FOOTER,()=>I.connectInjector(Bl,this._injector))),this.disposeWithMe(this._uiPartsService.registerComponent(I.BuiltInUIPart.CONTENT,()=>I.connectInjector(Fl,this._injector)))}_initMenus(){this._menuManagerService.mergeMenu(cs)}_initShortCut(){[ml,pl,fl,Sl,Il,vl,Tl,yl,Cl,El,bl,Rl,gl].forEach(t=>{this.disposeWithMe(this._shortcutService.registerShortcut(t))})}_init(){this._initCustomComponents(),this._initMenus(),this._initFocusHandler(),this._initCommands(),this._initUiParts(),this._initShortCut()}_initCommands(){[Bi,Io,So].forEach(t=>this.disposeWithMe(this._commandService.registerCommand(t)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(i.UniverInstanceType.UNIVER_DOC,t=>{this._injector.get(B.IRenderManagerService).getRenderById(t).with(exports.DocSelectionRenderService).focus()}))}};exports.DocUIController=Cd([Se(0,i.Inject(i.Injector)),Se(1,i.Inject(I.ComponentManager)),Se(2,i.ICommandService),Se(3,I.ILayoutService),Se(4,I.IMenuManagerService),Se(5,I.IUIPartsService),Se(6,i.IUniverInstanceService),Se(7,I.IShortcutService),Se(8,i.IConfigService)],exports.DocUIController);var Td=Object.getOwnPropertyDescriptor,yd=(o,t,e,n)=>{for(var r=n>1?void 0:n?Td(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Fn=(o,t)=>(e,n)=>t(e,n,o);const Hr=1.5;exports.DocBackScrollRenderController=class extends i.RxDisposable{constructor(t,e,n,r){super(),this._context=t,this._textSelectionManagerService=e,this._editorService=n,this._docSkeletonManagerService=r,this._init()}_init(){this._textSelectionManagerService.textSelection$.pipe(U.takeUntil(this.dispose$)).subscribe(t=>{if(t==null)return;const{isEditing:e,unitId:n}=t;n!==this._context.unitId||!e||this._context.unitId!==i.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._scrollToSelection()})}scrollToRange(t){const e=this._docSkeletonManagerService.getSkeleton();if(!e)return;const{startOffset:n}=t,r=e.findNodePositionByCharIndex(n);r&&this.scrollToNode(r)}scrollToNode(t){var _;const{unitId:e,scene:n,mainComponent:r}=this._context,s=this._docSkeletonManagerService.getSkeleton();if(r==null||s==null)return;const a=r.getOffsetConfig(),{docsLeft:c,docsTop:l}=a,A=new ve(a,s),{contentBoxPointGroup:d}=A.getRangePointData(t,t),{left:u,top:m,height:g}=ft(d),h=u+c,p=m+l,f=n.getViewport(ie.VIEW_MAIN),S=this._editorService.getEditor(e);if(f==null)return;const{left:E,top:C,right:T,bottom:R}=f.getBounding().viewBound;let v=0,b=0;const x=S?(_=S.params.backScrollOffset)!=null?_:0:100;p<C?v=p-C-x:p>R-g&&(v=p-R+g+x),h<E?b=h-E:h>T-Hr&&(b=h-T+Hr);const y=f.transViewportScroll2ScrollValue(b,v);f.scrollByBarDeltaValue(y)}_scrollToSelection(){const t=this._textSelectionManagerService.getActiveTextRange();if(t==null)return;const{collapsed:e,startNodePosition:n}=t;e&&this.scrollToNode(n)}};exports.DocBackScrollRenderController=yd([Fn(1,i.Inject(D.DocSelectionManagerService)),Fn(2,ae),Fn(3,i.Inject(D.DocSkeletonManagerService))],exports.DocBackScrollRenderController);var bd=Object.getOwnPropertyDescriptor,Rd=(o,t,e,n)=>{for(var r=n>1?void 0:n?bd(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Ye=(o,t)=>(e,n)=>t(e,n,o);exports.DocRenderController=class extends i.RxDisposable{constructor(t,e,n,r,s,a,c){super(),this._context=t,this._commandService=e,this._docSelectionRenderService=n,this._docSkeletonManagerService=r,this._editorService=s,this._renderManagerService=a,this._univerInstanceService=c,this._addNewRender(),this._initRenderRefresh(),this._initCommandListener()}reRender(t){var a,c;const e=(a=this._renderManagerService.getRenderById(t))==null?void 0:a.with(D.DocSkeletonManagerService),n=e==null?void 0:e.getSkeleton();if(!n||!!n.getViewModel().getDataModel().getSnapshot().disabled)return;n.calculate();const s=this._editorService.getEditor(t);if(this._editorService.isEditor(t)&&!(s!=null&&s.params.scrollBar)){(c=this._context.mainComponent)==null||c.makeDirty();return}this._recalculateSizeBySkeleton(n)}_addNewRender(){const{scene:t,engine:e}=this._context,n=new B.Viewport(ie.VIEW_MAIN,t,{left:0,top:0,bottom:0,right:0,isWheelPreventDefaultX:!0});t.attachControl(),t.onMouseWheel$.subscribeEvent((s,a)=>{const c=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC);if((c==null?void 0:c.getUnitId())!==this._context.unitId)return;const l=s;if(l.ctrlKey){const A=Math.abs(l.deltaX);let d=A<40?.2:A<80?.4:.2;d*=l.deltaY>0?-1:1,t.scaleX<1&&(d/=2),t.scaleX+d>4?t.scale(4,4):t.scaleX+d<.1?t.scale(.1,.1):l.preventDefault()}else n.onMouseWheel(l,a)}),new B.ScrollBar(n),t.addLayer(new B.Layer(t,[],Vt),new B.Layer(t,[],ei)),this._addComponent();const r=()=>t.render();this.disposeWithMe(this._context.activated$.subscribe(s=>{s?e.runRenderLoop(r):e.stopRenderLoop(r)})),this._docSelectionRenderService.__attachScrollEvent()}_addComponent(){const{scene:t,unit:e,components:n}=this._context,a={pageMarginLeft:20,pageMarginTop:20},c=new B.Documents(de.MAIN,void 0,a);c.zIndex=kn;const l=new B.DocBackground(de.BACKGROUND,void 0,a);l.zIndex=kn,this._context.mainComponent=c,n.set(de.MAIN,c),n.set(de.BACKGROUND,l),t.addObjects([c],Vt),t.addObjects([l],$r),this._editorService.getEditor(e.getUnitId())==null&&t.enableLayerCache(Vt)}_initRenderRefresh(){this._docSkeletonManagerService.currentSkeletonBefore$.pipe(U.takeUntil(this.dispose$)).subscribe(t=>{this._create(t)})}_create(t){var l;if(!t)return;const{mainComponent:e,components:n}=this._context,r=e,s=n.get(de.BACKGROUND);r.changeSkeleton(t),s.changeSkeleton(t);const{unitId:a}=this._context,c=this._editorService.getEditor(a);if(this._editorService.isEditor(a)&&!(c!=null&&c.params.scrollBar)){(l=this._context.mainComponent)==null||l.makeDirty();return}this._recalculateSizeBySkeleton(t)}_initCommandListener(){const t=[D.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(t.includes(e.id)){const n=e.params,{unitId:r}=n;this.reRender(r)}}))}_recalculateSizeBySkeleton(t){var h;const{mainComponent:e,scene:n,unitId:r,components:s}=this._context,a=e,c=s.get(de.BACKGROUND),l=(h=t.getSkeletonData())==null?void 0:h.pages;if(l==null)return;let A=0,d=0;const m=this._context.unit.getSnapshot().documentStyle.documentFlavor;for(let p=0,f=l.length;p<f;p++){const S=l[p];let{pageWidth:E,pageHeight:C}=S;if(m===i.DocumentFlavor.MODERN){const T=xd(S);E=T.pageWidth,C=T.pageHeight}a.pageLayoutType===B.PageLayoutType.VERTICAL?(d+=C,d+=a.pageMarginTop,p===f-1&&(d+=a.pageMarginTop),A=Math.max(A,E)):a.pageLayoutType===B.PageLayoutType.HORIZONTAL&&(A+=E,p!==f-1&&(A+=a.pageMarginLeft),d=Math.max(d,C))}a.resize(A,d),c.resize(A,d);const g=this._editorService.getEditor(r);(!this._editorService.isEditor(r)||g!=null&&g.params.scrollBar)&&n.resize(A,d)}};exports.DocRenderController=Rd([Ye(1,i.ICommandService),Ye(2,i.Inject(exports.DocSelectionRenderService)),Ye(3,i.Inject(D.DocSkeletonManagerService)),Ye(4,ae),Ye(5,B.IRenderManagerService),Ye(6,i.IUniverInstanceService)],exports.DocRenderController);function xd(o){let{pageWidth:t,pageHeight:e}=o;const{marginLeft:n,marginRight:r,marginTop:s,marginBottom:a,skeDrawings:c,skeTables:l}=o;t===Number.POSITIVE_INFINITY&&(t=o.width+n+r),e===Number.POSITIVE_INFINITY&&(e=o.height+s+a);for(const A of c.values())t=Math.max(t,A.aLeft+A.width+n+r),e=Math.max(e,A.aTop+A.height+s+a);for(const A of l.values())t=Math.max(t,A.left+A.width+n+r),e=Math.max(e,A.top+A.height+s+a);return{pageWidth:t,pageHeight:e}}const Zo={id:"doc.command.select-all",type:i.CommandType.COMMAND,handler:async o=>{var g;const t=o.get(i.IUniverInstanceService),e=o.get(D.DocSelectionManagerService),n=t.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC),r=e.getDocRanges(),s=(g=r.find(h=>h.isActive))!=null?g:r[0];if(n==null||s==null)return!1;const{segmentId:a}=s,c=n.getUnitId(),l=n.getSelfOrHeaderFooterModel(a).getSnapshot().body;if(l==null)return!1;const{tables:A=[],dataStream:d}=l;if(d===`\r
|
|
36
36
|
`)return!0;const u=[];let m=0;for(const h of A){const{startIndex:p,endIndex:f}=h;m!==p&&u.push({startOffset:m,endOffset:p-1,rangeType:i.DOC_RANGE_TYPE.TEXT}),u.push({startOffset:p+3,endOffset:f-5,rangeType:i.DOC_RANGE_TYPE.RECT}),m=f}return m!==l.dataStream.length-2&&u.push({startOffset:m,endOffset:l.dataStream.length-2,rangeType:i.DOC_RANGE_TYPE.TEXT}),e.replaceDocRanges(u,{unitId:c,subUnitId:c},!1),!0}};class Pt extends i.RxDisposable{constructor(e){super();M(this,"_previousActiveRange",null);M(this,"_undoMutationParamsCache",[]);M(this,"_redoMutationParamsCache",[]);this._context=e}clearUndoRedoMutationParamsCache(){this._undoMutationParamsCache=[],this._redoMutationParamsCache=[]}getUndoRedoMutationParamsCache(){return{undoCache:this._undoMutationParamsCache,redoCache:this._redoMutationParamsCache}}setUndoRedoMutationParamsCache({undoCache:e=[],redoCache:n=[]}){this._undoMutationParamsCache=e,this._redoMutationParamsCache=n}getActiveRange(){return this._previousActiveRange}setActiveRange(e){this._previousActiveRange=e}pushUndoRedoMutationParams(e,n){this._undoMutationParamsCache.push(e),this._redoMutationParamsCache.push(n)}fetchComposedUndoRedoMutationParams(){if(this._undoMutationParamsCache.length===0||this._previousActiveRange==null||this._redoMutationParamsCache.length===0)return null;const{unitId:e}=this._undoMutationParamsCache[0],n={unitId:e,actions:this._undoMutationParamsCache.reverse().reduce((s,a)=>i.JSONX.compose(s,a.actions),null),textRanges:[]};return{redoMutationParams:{unitId:e,actions:this._redoMutationParamsCache.reduce((s,a)=>i.JSONX.compose(s,a.actions),null),textRanges:[]},undoMutationParams:n,previousActiveRange:this._previousActiveRange}}dispose(){this._undoMutationParamsCache=[],this._redoMutationParamsCache=[],this._previousActiveRange=null}}const $o={id:"doc.command.ime-input",type:i.CommandType.COMMAND,handler:async(o,t)=>{var L,G,W;const{unitId:e,newText:n,oldTextLen:r,isCompositionEnd:s,isCompositionStart:a}=t,c=o.get(i.ICommandService),l=o.get(B.IRenderManagerService),A=o.get(i.IUniverInstanceService),d=o.get(Te),u=(L=l.getRenderById(e))==null?void 0:L.with(Pt),m=A.getUnit(e,i.UniverInstanceType.UNIVER_DOC);if(m==null||u==null)return!1;const g=u.getActiveRange();if(g==null)return!1;const{style:h,segmentId:p}=g,f=m.getSelfOrHeaderFooterModel(p).getBody();if(f==null)return!1;Object.assign(g,g);const{startOffset:E,endOffset:C}=g,T=n.length,R=[{startOffset:E+T,endOffset:E+T,collapsed:!0,style:h}],v={id:D.RichTextEditingMutation.id,params:{unitId:e,actions:[],textRanges:R}},b=d.getDefaultStyle(),x=d.getStyleCache(),y=lo((G=f.customRanges)!=null?G:[],E+r,i.SHEET_EDITOR_UNITS.includes(e)),_=an(f,a?C:E+r,b,x,i.SHEET_EDITOR_UNITS.includes(e)),O=Ao((W=f.customDecorations)!=null?W:[],E+r),w=new i.TextX,Q=i.JSONX.getInstance();if(!g.collapsed&&a){const H=i.BuildTextUtils.selection.delete([g],f,0,null,!1);w.push(...H),v.params.textRanges=[{startOffset:E+T,endOffset:E+T,collapsed:!0}]}else w.push({t:i.TextXActionType.RETAIN,len:E});r>0&&w.push({t:i.TextXActionType.DELETE,len:r}),w.push({t:i.TextXActionType.INSERT,body:{dataStream:n,textRuns:_?[{..._,st:0,ed:n.length}]:[],customRanges:y?[{...y,startIndex:0,endIndex:n.length-1}]:[],customDecorations:O.map(H=>({...H,startIndex:0,endIndex:n.length-1}))},len:n.length});const k=J(m,p);v.params.actions=Q.editOp(w.serialize(),k),v.params.noHistory=!s,v.params.isCompositionEnd=s;const F=c.syncExecuteCommand(v.id,v.params);return u.pushUndoRedoMutationParams(F,v.params),!!F}},ls={id:"doc.command.insert-custom-range",type:i.CommandType.COMMAND,handler:(o,t)=>{if(!t)return!1;const e=o.get(i.ICommandService),{unitId:n,rangeId:r=i.generateRandomId(),textRanges:s,properties:a,text:c,wholeEntity:l}=t,A={unitId:n,textRanges:s,body:{dataStream:c,customRanges:[{startIndex:0,endIndex:c.length-1,rangeId:r,rangeType:i.CustomRangeType.CUSTOM,properties:a,wholeEntity:l}]}};return e.syncExecuteCommand(go.id,A)}},It={type:i.CommandType.COMMAND,id:"doc.command.set-zoom-ratio",handler:async(o,t)=>{var u,m,g;const e=o.get(i.ICommandService),n=o.get(i.IUndoRedoService),r=o.get(i.IUniverInstanceService);let s=(u=r.getCurrentUniverDocInstance())==null?void 0:u.getUnitId();if(!s)return!1;let a=1;if(t&&(s=(m=t.documentId)!=null?m:s,a=(g=t.zoomRatio)!=null?g:a),!r.getUniverDocInstance(s))return!1;const l={zoomRatio:a,unitId:s},A=Kc(o,l);return e.syncExecuteCommand(Ae.id,l)?(n.pushUndoRedo({unitID:s,undoMutations:[{id:Ae.id,params:A}],redoMutations:[{id:Ae.id,params:l}]}),!0):!1}},er={id:"doc.table.tab-in-table",type:i.CommandType.COMMAND,handler:async(o,t)=>{var h;const{shift:e}=t,n=o.get(D.DocSelectionManagerService),r=n.getDocRanges(),s=o.get(i.ICommandService),c=o.get(i.IUniverInstanceService).getCurrentUniverDocInstance();if(!c)return!1;const l=(h=r.find(p=>p.isActive))!=null?h:r[0],A=c.getUnitId(),d=ce(o,A),u=d==null?void 0:d.getSkeleton(),m=u==null?void 0:u.getViewModel().getSelfOrHeaderFooterViewModel(l==null?void 0:l.segmentId);if(m==null||l==null)return!1;let g=null;if(e?g=gr(m,l,Yn.PREV):g=gr(m,l,Yn.NEXT),g){const{startOffset:p,endOffset:f}=g,S=[{startOffset:p,endOffset:f}];return n.replaceDocRanges(S),!0}return e===!1?await s.executeCommand(Yo.id,{position:ln.BELLOW}):!0}};var Od=Object.getOwnPropertyDescriptor,Md=(o,t,e,n)=>{for(var r=n>1?void 0:n?Od(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Hn=(o,t)=>(e,n)=>t(e,n,o);let eo=class{constructor(o,t,e){M(this,"_docContainer");M(this,"getComponent",o=>{if(this._docContainer=o,!o.getContentRef().current)throw new Error("container is not ready")});M(this,"changeLocale",o=>{this._localeService.setLocale(o)});this._localeService=o,this._injector=t,this._configService=e}getUIConfig(){return{injector:this._injector,config:this._configService.getConfig(En),changeLocale:this.changeLocale,getComponent:this.getComponent}}getContentRef(){return this._docContainer.getContentRef()}UIDidMount(o){if(this._docContainer)return o(this._docContainer)}getDocContainer(){return this._docContainer}};eo=Md([Hn(0,i.Inject(i.LocaleService)),Hn(1,i.Inject(i.Injector)),Hn(2,i.IConfigService)],eo);var Dd=Object.getOwnPropertyDescriptor,Bd=(o,t,e,n)=>{for(var r=n>1?void 0:n?Dd(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},_d=(o,t)=>(e,n)=>t(e,n,o);let $t=class extends i.RxDisposable{constructor(t){super();M(this,"_docContainerController");this._injector=t,this._docContainerController=this._injector.createInstance(eo)}};$t=Bd([_d(0,i.Inject(i.Injector))],$t);var Nd=Object.getOwnPropertyDescriptor,Pd=(o,t,e,n)=>{for(var r=n>1?void 0:n?Nd(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},kr=(o,t)=>(e,n)=>t(e,n,o);let en=class extends i.Disposable{constructor(o,t){super(),this._docAutoFormatService=o,this._renderManagerService=t,this._initListTabAutoFormat(),this._initSpaceAutoFormat(),this._initDefaultEnterFormat(),this._initExitListAutoFormat()}_initListTabAutoFormat(){this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({id:Xe.id,match:o=>{var r;const{selection:t,paragraphs:e,unit:n}=o;if(e.length===1&&t.startOffset===e[0].paragraphStart&&e[0].bullet){const s=(r=n.getBody())==null?void 0:r.paragraphs,a=s==null?void 0:s.filter(c=>{var l;return((l=c.bullet)==null?void 0:l.listId)===e[0].bullet.listId});return(a==null?void 0:a.findIndex(c=>c.startIndex===e[0].startIndex))!==0}else if(e.length>1&&e.some(s=>s.bullet))return!0;return!1},getMutations(o){const t=o.commandParams;return[{id:Yt.id,params:{type:t!=null&&t.shift?St.decrease:St.increase}}]},priority:100})),this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({id:Xe.id,match:o=>{const{selection:t,unit:e}=o,{startNodePosition:n,endNodePosition:r}=t,s=this._renderManagerService.getRenderById(e.getUnitId()),a=s==null?void 0:s.with(D.DocSkeletonManagerService).getSkeleton();return a==null?!1:!!(n&&r&&di(a,n,r)||n&&!r&&n.path.indexOf("cells")>-1)},getMutations(o){const t=o.commandParams;return[{id:er.id,params:{shift:!!(t!=null&&t.shift)}}]},priority:99}))}_initSpaceAutoFormat(){this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({id:Nt.id,match:o=>{var s;const{selection:t,paragraphs:e,unit:n}=o;if(!t.collapsed||e.length!==1||!t.collapsed)return!1;const r=(s=n.getBody())==null?void 0:s.dataStream.slice(e[0].paragraphStart,t.startOffset-1);return!!(r&&(Object.keys(i.QuickListTypeMap).includes(r)||Object.keys(Un).includes(r)))},getMutations(o){var s;const{paragraphs:t,unit:e,selection:n}=o,r=(s=e.getBody())==null?void 0:s.dataStream.slice(t[0].paragraphStart,n.startOffset-1);if(r&&Object.keys(i.QuickListTypeMap).includes(r)){const a=i.QuickListTypeMap[r];return[{id:wo.id,params:{listType:a,paragraph:t[0]}}]}if(r&&Object.keys(Un).includes(r)){const a=Un[r];return[{id:qi.id,params:{value:a}}]}return[]}}))}_initExitListAutoFormat(){this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({id:rt.id,match:o=>{const{paragraphs:t}=o;return!!(t.length===1&&t[0].bullet&&t[0].paragraphStart===t[0].paragraphEnd)},getMutations:o=>{const t=o.paragraphs[0].bullet;return t?t.nestingLevel>0?[{id:Yt.id,params:{type:St.decrease}}]:[{id:at.id,params:{listType:o.paragraphs[0].bullet.listType}}]:[]}}))}_initDefaultEnterFormat(){this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({id:rt.id,match:()=>!0,getMutations(){return[{id:In.id}]},priority:-9999}))}};en=Pd([kr(0,i.Inject(exports.DocAutoFormatService)),kr(1,B.IRenderManagerService)],en);function wd(o){return o.rows[0].cells[0].sections[0].columns[0].lines[0]}function Ud(o){const t=o.rows[o.rows.length-1],e=t.cells[t.cells.length-1];return B.getLastLine(e)}function Ld(o,t){const{ed:e}=o,{skeTables:n}=t;let r=null;for(const s of n.values())if(s.st===e+1){r=s;break}return r}function Vr(o){const t=o==null?void 0:o.parent;let e=null,n=null;if(o==null||t==null)return{lineBeforeTable:e,lineAfterTable:n};const{st:r,ed:s}=o,a=t.type===B.DocumentSkeletonPageType.CELL?[t]:t.parent.pages;return B.lineIterator(a,c=>{c.st===s+1?n=c:c.ed===r-1&&(e=c)}),{lineBeforeTable:e,lineAfterTable:n}}function ds(o){return o.sections[0].columns[0].lines.length===0}function As(o){var a,c;const t=o.parent,e=t==null?void 0:t.parent,n=e==null?void 0:e.tableId;if(t==null||e==null)return;const r=t.cells.indexOf(o);let s=e.rows[e.rows.indexOf(t)+1];if(s==null&&n.indexOf("#-#")){const[l,A]=n.split("#-#"),d=(c=(a=e.parent)==null?void 0:a.parent)==null?void 0:c.pages,u=`${l}#-#${Number.parseInt(A)+1}`;if(d)for(const m of d){const{skeTables:g}=m;if(g.has(u)){const h=g.get(u);if(h!=null&&h.rows.length){s=h.rows.find(p=>!p.isRepeatRow);break}}}}if(s!=null){const l=s.cells[r];return ds(l)?As(l):l}}function us(o){var s,a;const t=o.parent,e=t==null?void 0:t.parent;if(t==null||e==null)return;let n=e.rows[e.rows.indexOf(t)-1];const r=t.cells.indexOf(o);if((n==null||n.isRepeatRow)&&e.tableId.indexOf("#-#")){const[c,l]=e.tableId.split("#-#"),A=(a=(s=e.parent)==null?void 0:s.parent)==null?void 0:a.pages,d=`${c}#-#${Number.parseInt(l)-1}`;if(A)for(const u of A){const{skeTables:m}=u;if(m.has(d)){const g=m.get(d);if(g!=null&&g.rows.length){n=g.rows[g.rows.length-1];break}}}}if(n!=null){const c=n.cells[r];return ds(c)?us(c):c}}function Qd(o,t){const{st:e}=o,{skeTables:n}=t;let r=null;for(const s of n.values())if(s.ed===e-1){r=s;break}return r}function Fd(o){return o.sections[0].columns[0].lines[0]}function Hd(o){const t=B.getLastColumn(o);return t.lines[t.lines.length-1]}var kd=Object.getOwnPropertyDescriptor,Vd=(o,t,e,n)=>{for(var r=n>1?void 0:n?kd(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Qt=(o,t)=>(e,n)=>t(e,n,o);let tn=class extends i.Disposable{constructor(t,e,n,r){super();M(this,"_onInputSubscription");this._univerInstanceService=t,this._renderManagerService=e,this._textSelectionManagerService=n,this._commandService=r,this._commandExecutedListener()}dispose(){var t;super.dispose(),(t=this._onInputSubscription)==null||t.unsubscribe()}_commandExecutedListener(){const t=[Ee.id,Ce.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(!t.includes(e.id))return;const n=e.params;switch(e.id){case Ee.id:return this._handleMoveCursor(n.direction);case Ce.id:return this._handleShiftMoveSelection(n.direction);default:throw new Error("Unknown command")}}))}_handleShiftMoveSelection(t){var C,T,R;const e=this._textSelectionManagerService.getActiveTextRange(),n=this._textSelectionManagerService.getTextRanges(),r=this._univerInstanceService.getCurrentUniverDocInstance();if(r==null)return;const s=(C=this._renderManagerService.getRenderById(r.getUnitId()))==null?void 0:C.with(D.DocSkeletonManagerService).getSkeleton(),a=this._getDocObject();if(e==null||s==null||a==null)return;const{startOffset:c,endOffset:l,style:A,collapsed:d,direction:u,segmentId:m,startNodePosition:g,endNodePosition:h,segmentPage:p}=e;if(n.length>1){let v=Number.POSITIVE_INFINITY,b=Number.NEGATIVE_INFINITY;for(const x of n)v=Math.min(v,x.startOffset),b=Math.max(b,x.endOffset);this._textSelectionManagerService.replaceTextRanges([{startOffset:t===i.Direction.LEFT||t===i.Direction.UP?b:v,endOffset:t===i.Direction.LEFT||t===i.Direction.UP?v:b,style:A}],!1);return}const f=d||u===i.RANGE_DIRECTION.FORWARD?c:l;let S=d||u===i.RANGE_DIRECTION.FORWARD?l:c;const E=(T=r.getSelfOrHeaderFooterModel(m).getBody().dataStream.length)!=null?T:Number.POSITIVE_INFINITY;if(t===i.Direction.LEFT||t===i.Direction.RIGHT){const v=s.findNodeByCharIndex(S-1,m,p),b=s.findNodeByCharIndex(S,m,p);S=t===i.Direction.RIGHT?S+b.count:S-((R=v==null?void 0:v.count)!=null?R:0),S=Math.min(E-2,Math.max(0,S)),this._textSelectionManagerService.replaceTextRanges([{startOffset:f,endOffset:S,style:A}],!1),this._scrollToFocusNodePosition(r.getUnitId(),S)}else{const v=s.findNodeByCharIndex(S,m,p),b=a.document.getOffsetConfig(),x=d?g:u===i.RANGE_DIRECTION.FORWARD?h:g,y=this._getTopOrBottomPosition(s,v,x,t===i.Direction.DOWN,!0);if(y==null){const O=t===i.Direction.UP?0:E-2;if(O===S)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:f,endOffset:O,style:A}],!1);return}const _=new ve(b,s).getRangePointData(y,y).cursorList[0];this._textSelectionManagerService.replaceTextRanges([{startOffset:f,endOffset:_.endOffset,style:A}],!1),this._scrollToFocusNodePosition(r.getUnitId(),_.endOffset)}}_handleMoveCursor(t){var E,C,T,R;const e=this._textSelectionManagerService.getActiveTextRange(),n=this._textSelectionManagerService.getTextRanges(),r=this._univerInstanceService.getCurrentUniverDocInstance();if(r==null)return!1;const s=(E=this._renderManagerService.getRenderById(r.getUnitId()))==null?void 0:E.with(D.DocSkeletonManagerService).getSkeleton(),a=this._getDocObject();if(e==null||s==null||a==null||n==null)return;const{startOffset:c,endOffset:l,style:A,collapsed:d,segmentId:u,startNodePosition:m,endNodePosition:g,segmentPage:h}=e,p=r.getSelfOrHeaderFooterModel(u).getBody();if(p==null)return;const f=(C=p.dataStream.length)!=null?C:Number.POSITIVE_INFINITY,S=(T=r.getCustomRanges())!=null?T:[];if(t===i.Direction.LEFT||t===i.Direction.RIGHT){let v;if(!e.collapsed||n.length>1){let y=Number.POSITIVE_INFINITY,_=Number.NEGATIVE_INFINITY;for(const O of n)y=Math.min(y,O.startOffset),_=Math.max(_,O.endOffset);v=t===i.Direction.LEFT?y:_}else{const y=s.findNodeByCharIndex(c-1,u,h),_=s.findNodeByCharIndex(c,u,h),O=s.findNodeByCharIndex(c+1,u,h);t===i.Direction.LEFT?v=Math.max(0,c-((R=y==null?void 0:y.count)!=null?R:1)):v=Math.min(f-2,l+_.count+((O==null?void 0:O.streamType)===i.DataStreamTreeTokenType.SECTION_BREAK?1:0))}const b=[i.DataStreamTreeTokenType.TABLE_START,i.DataStreamTreeTokenType.TABLE_END,i.DataStreamTreeTokenType.TABLE_ROW_START,i.DataStreamTreeTokenType.TABLE_ROW_END,i.DataStreamTreeTokenType.TABLE_CELL_START,i.DataStreamTreeTokenType.TABLE_CELL_END,i.DataStreamTreeTokenType.SECTION_BREAK];if(t===i.Direction.LEFT)for(;b.includes(p.dataStream[v]);)v--;else for(;b.includes(p.dataStream[v]);)v++;S.filter(y=>y.wholeEntity&&y.startIndex<v&&y.endIndex>=v).forEach(y=>{t===i.Direction.LEFT?v=Math.min(y.startIndex,v):v=Math.max(y.endIndex+1,v)}),this._textSelectionManagerService.replaceTextRanges([{startOffset:Math.max(0,v),endOffset:Math.max(0,v),style:A}],!1),this._scrollToFocusNodePosition(r.getUnitId(),v)}else{const v=s.findNodeByCharIndex(c,u,h),b=s.findNodeByCharIndex(l,u,h),x=a.document.getOffsetConfig(),y=this._getTopOrBottomPosition(s,t===i.Direction.UP||d?v:b,t===i.Direction.UP||d?m:g,t===i.Direction.DOWN);if(y==null){let O;d?O=t===i.Direction.UP?0:f-2:O=t===i.Direction.UP?c:l,this._textSelectionManagerService.replaceTextRanges([{startOffset:Math.max(0,O),endOffset:Math.max(0,O),style:A}],!1);return}const _=new ve(x,s).getRangePointData(y,y).cursorList[0];this._textSelectionManagerService.replaceTextRanges([{..._,style:A}],!1),this._scrollToFocusNodePosition(r.getUnitId(),_.endOffset)}}_getTopOrBottomPosition(t,e,n,r,s=!1){if(e==null||n==null)return;const a=this._getGlyphLeftOffsetInLine(e),c=this._getNextOrPrevLine(e,r,s);if(c==null)return;const l=this._matchPositionByLeftOffset(t,c,a,n);if(l!=null)return{...l,isBack:!0}}_getGlyphLeftOffsetInLine(t){const e=t.parent;if(e==null)return Number.NEGATIVE_INFINITY;const n=e.left,{left:r}=t;return n+r}_matchPositionByLeftOffset(t,e,n,r){const s={distance:Number.POSITIVE_INFINITY};for(const c of e.divides){const l=c.left;for(const A of c.glyphGroup){if(A.streamType===i.DataStreamTreeTokenType.SECTION_BREAK)continue;const{left:d}=A,u=l+d,m=Math.abs(n-u);m<s.distance&&(s.glyph=A,s.distance=m)}}if(s.glyph==null)return;const{segmentPage:a}=r;return t.findPositionByGlyph(s.glyph,a)}_getNextOrPrevLine(t,e,n=!1){var p,f,S,E,C,T,R,v,b,x,y,_;const r=t.parent,s=r==null?void 0:r.parent,a=s==null?void 0:s.parent,c=a==null?void 0:a.parent,l=c==null?void 0:c.parent;if(r==null||s==null||a==null||c==null||l==null)return;const A=a.lines.indexOf(s);if(A===-1)return;let d;if(l.type===B.DocumentSkeletonPageType.CELL&&n){const O=jr(l,e);if(O)return O}if(e===!0){d=a.lines[A+1];const O=Ld(s,l);if(O){const w=wd(O);w&&(d=w)}}else{d=a.lines[A-1];const O=Qd(s,l);if(O){const w=Ud(O);w&&(d=w)}}if(d!=null)return d;const u=c.columns.indexOf(a);if(u===-1)return;if(e===!0)d=(p=c.columns[u+1])==null?void 0:p.lines[0];else{const O=(S=(f=c.columns)==null?void 0:f[u-1])==null?void 0:S.lines;d=O==null?void 0:O[O.length-1]}if(d!=null)return d;const m=l.sections.indexOf(c);if(m===-1)return;if(e===!0)d=(C=(E=l.sections[m-1])==null?void 0:E.columns[0])==null?void 0:C.lines[0];else{const O=(R=(T=l.sections)==null?void 0:T[m-1])==null?void 0:R.columns,w=O==null?void 0:O[O.length-1],Q=w==null?void 0:w.lines;d=Q==null?void 0:Q[Q.length-1]}if(d!=null)return d;if(l.type===B.DocumentSkeletonPageType.CELL)return jr(l,e);const g=l.parent;if(g==null)return;const h=g.pages.indexOf(l);if(h!==-1){if(e===!0)d=(x=(b=(v=g.pages[h+1])==null?void 0:v.sections[0])==null?void 0:b.columns[0])==null?void 0:x.lines[0];else{const O=(y=g.pages[h-1])==null?void 0:y.sections;if(O==null)return;const w=(_=O[O.length-1])==null?void 0:_.columns,Q=w[w.length-1],k=Q==null?void 0:Q.lines;d=k[k.length-1]}if(d!=null)return d}}_scrollToFocusNodePosition(t,e){var r;const n=(r=this._renderManagerService.getRenderById(t))==null?void 0:r.with(exports.DocBackScrollRenderController);n!=null&&n.scrollToRange({startOffset:e,endOffset:e,collapsed:!0})}_getDocObject(){return ti(this._univerInstanceService,this._renderManagerService)}};tn=Vd([Qt(0,i.IUniverInstanceService),Qt(1,B.IRenderManagerService),Qt(2,i.Inject(D.DocSelectionManagerService)),Qt(3,i.ICommandService)],tn);function jr(o,t){var n,r;let e=null;if(t===!0){const s=As(o);if(s)e=Fd(s);else{const a=(n=o.parent)==null?void 0:n.parent,{lineAfterTable:c}=Vr(a);c&&(e=c)}}else{const s=us(o);if(s)e=Hd(s);else{const a=(r=o.parent)==null?void 0:r.parent,{lineBeforeTable:c}=Vr(a);c&&(e=c)}}return e}const jd=({handleRowColChange:o,tableCreateParams:t})=>{const e=I.useDependency(i.LocaleService),[n,r]=P.useState(3),[s,a]=P.useState(5);function c(l,A){r(l),a(A),o(l,A)}return P.useEffect(()=>{r(t.rowCount),a(t.colCount)},[t]),N.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between",children:[N.jsxs("div",{className:"univer-flex univer-items-center univer-gap-2",children:[N.jsx("span",{children:e.t("toolbar.table.rowCount")}),N.jsx(q.InputNumber,{className:"univer-w-28",min:1,max:20,precision:0,value:n,onChange:l=>{c(l,s)}})]}),N.jsxs("div",{className:"univer-flex univer-items-center univer-gap-2",children:[N.jsx("span",{children:e.t("toolbar.table.colCount")}),N.jsx(q.InputNumber,{className:"univer-w-28",min:1,max:20,precision:0,value:s,onChange:l=>{c(n,l)}})]})]})};var Wd=Object.getOwnPropertyDescriptor,Gd=(o,t,e,n)=>{for(var r=n>1?void 0:n?Wd(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Wr=(o,t)=>(e,n)=>t(e,n,o);let nn=class extends i.Disposable{constructor(o,t){super(),this._commandService=o,this._componentManager=t,this._initialize()}_initialize(){this._init(),this._registerCommands(),this._initCustomComponents()}_registerCommands(){[vn].forEach(o=>this.disposeWithMe(this._commandService.registerCommand(o)))}_initCustomComponents(){const o=this._componentManager;this.disposeWithMe(o.register($i,jd))}_init(){}};nn=Gd([Wr(0,i.ICommandService),Wr(1,i.Inject(I.ComponentManager))],nn);var Xd=Object.getOwnPropertyDescriptor,Kd=(o,t,e,n)=>{for(var r=n>1?void 0:n?Xd(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Ft=(o,t)=>(e,n)=>t(e,n,o);let to=class extends i.Disposable{constructor(o,t,e,n,r){super(),this._context=o,this._docSkeletonManagerService=t,this._commandService=e,this._docEventManagerService=n,this._textSelectionManagerService=r,this._initPointerDownObserver(),this._initHoverCursor()}_initPointerDownObserver(){this._docEventManagerService.clickBullets$.subscribe(o=>{const t=this._textSelectionManagerService.getTextRanges();this._commandService.executeCommand(Po.id,{index:o.paragraph.startIndex,segmentId:o.segmentId,textRanges:t})})}_initHoverCursor(){this.disposeWithMe(this._docEventManagerService.hoverBullet$.subscribe(o=>{o?this._context.mainComponent.setCursor(B.CURSOR_TYPE.POINTER):this._context.mainComponent.setCursor(B.CURSOR_TYPE.TEXT)}))}_getTransformCoordForDocumentOffset(o,t,e,n){const{documentTransform:r}=o.getOffsetConfig(),s=t.transformVector2SceneCoord(B.Vector2.FromArray([e,n]));if(s)return r.clone().invert().applyPoint(s)}};to=Kd([Ft(1,i.Inject(D.DocSkeletonManagerService)),Ft(2,i.ICommandService),Ft(3,i.Inject(exports.DocEventManagerService)),Ft(4,i.Inject(D.DocSelectionManagerService))],to);var zd=Object.getOwnPropertyDescriptor,Yd=(o,t,e,n)=>{for(var r=n>1?void 0:n?zd(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},ut=(o,t)=>(e,n)=>t(e,n,o);let on=class extends i.RxDisposable{constructor(o,t,e,n,r,s){super(),this._context=o,this._commandService=t,this._docClipboardService=e,this._docSelectionRenderService=n,this._contextService=r,this._editorService=s,this._init()}_init(){this._initLegacyPasteCommand()}_initLegacyPasteCommand(){var o;(o=this._docSelectionRenderService)==null||o.onPaste$.pipe(U.takeUntil(this.dispose$)).subscribe(t=>{var c,l,A;if(!pn(this._contextService))return;t.event.preventDefault();const e=t.event;let n=(c=e.clipboardData)==null?void 0:c.getData(I.HTML_CLIPBOARD_MIME_TYPE);const r=(l=e.clipboardData)==null?void 0:l.getData(I.PLAIN_TEXT_CLIPBOARD_MIME_TYPE),s=[...((A=e.clipboardData)==null?void 0:A.items)||[]].filter(d=>I.imageMimeTypeSet.has(d.type)).map(d=>d.getAsFile()).filter(d=>!!d);this._editorService.getEditor(this._context.unitId)&&(n!=null?n:"").indexOf("</table>")>-1&&(n=""),this._docClipboardService.legacyPaste({html:n,text:r,files:s})})}};on=Yd([ut(1,i.ICommandService),ut(2,Be),ut(3,i.Inject(exports.DocSelectionRenderService)),ut(4,i.IContextService),ut(5,ae)],on);var qd=Object.getOwnPropertyDescriptor,Jd=(o,t,e,n)=>{for(var r=n>1?void 0:n?qd(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Gr=(o,t)=>(e,n)=>t(e,n,o);const Zd=[i.DEFAULT_EMPTY_DOCUMENT_VALUE,i.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,i.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,i.DOCS_ZEN_EDITOR_UNIT_ID_KEY];let no=class extends i.Disposable{constructor(o,t,e){super(),this._context=o,this._contextMenuService=t,this._commandService=e,Zd.includes(this._context.unitId)||(this._initPointerDown(),this._initEditChange())}_initPointerDown(){var e,n;const t=((n=(e=this._context)==null?void 0:e.mainComponent)==null?void 0:n.onPointerDown$).subscribeEvent(r=>{r.button===2&&this._contextMenuService.triggerContextMenu(r,I.ContextMenuPosition.MAIN_AREA)});this.disposeWithMe(t)}_initEditChange(){this.disposeWithMe(this._commandService.onCommandExecuted(o=>{o.id===D.RichTextEditingMutation.id&&this._contextMenuService.visible&&this._contextMenuService.hideContextMenu()}))}};no=Jd([Gr(1,I.IContextMenuService),Gr(2,i.ICommandService)],no);var $d=Object.getOwnPropertyDescriptor,eA=(o,t,e,n)=>{for(var r=n>1?void 0:n?$d(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},qe=(o,t)=>(e,n)=>t(e,n,o);let rn=class extends i.Disposable{constructor(t,e,n,r,s,a,c){super();M(this,"_initialEditors",new Set);this._context=t,this._univerInstanceService=e,this._editorService=n,this._commandService=r,this._docSelectionRenderService=s,this._docSkeletonManagerService=a,this._renderManagerService=c,this._initialize()}_initialize(){this._editorService.getAllEditor().forEach(t=>{const e=t.getEditorId();e===this._context.unitId&&(this._initialEditors.has(e)||(this._initialEditors.add(e),this._resize(e)))}),this._commandExecutedListener(),this._initialBlur(),this._initialFocus()}_resize(t){if(t==null)return;const e=this._editorService.getEditor(t);if((e==null?void 0:e.cancelDefaultResizeListener)===!0)return;const n=this._univerInstanceService.getUniverDocInstance(t);if(!n)return;const r=this._docSkeletonManagerService.getSkeleton();if(e==null||e.render==null||r==null||n==null)return;r.calculate();const{marginTop:s=0,marginBottom:a=0,marginLeft:c=0,marginRight:l=0}=n.getSnapshot().documentStyle,{scene:A,mainComponent:d}=e.render;let{actualHeight:u,actualWidth:m}=r.getActualSize();u+=s+a,m+=c+l;const{width:g,height:h}=e.getBoundingClientRect(),p=Math.max(m,g),f=Math.max(u,h);A.transformByState({width:p,height:f}),d==null||d.resize(p,f)}_initialBlur(){this.disposeWithMe(this._editorService.blur$.subscribe(()=>{this._docSelectionRenderService.blur()})),this.disposeWithMe(this._docSelectionRenderService.onBlur$.subscribe(()=>{const{unitId:t}=this._context,e=this._editorService.getEditor(t),n=this._editorService.getFocusEditor();e==null||e.isSheetEditor()||n&&n.getEditorId()===t||t.includes("range_selector")||t.includes("embedding_formula_editor")||this._editorService.blur()}))}_initialFocus(){const t=["univer-formula-search","univer-formula-help","formula-help-decorator","univer-formula-help-param"];this.disposeWithMe(U.fromEvent(window,"mousedown").subscribe(n=>{const s=n.target.classList[0]||"";i.checkForSubstrings(s,t)&&n.stopPropagation()}));const e=new i.DisposableCollection;this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).subscribe(n=>{if(e.dispose(),!n)return;const r=n.getUnitId(),s=this._renderManagerService.getRenderById(r),a=s==null?void 0:s.engine.getCanvas().getCanvasEle();if(a==null)return;const c=U.fromEvent(a,"mousedown").subscribe(l=>{l.stopPropagation()});e.add(c)})),this.disposeWithMe(()=>e.dispose())}_commandExecutedListener(){const t=[D.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(t.includes(e.id)){const n=e.params,{unitId:r}=n;if(this._editorService.isSheetEditor(r)||r!==this._context.unitId)return;const s=this._editorService.getEditor(r);s&&!s.params.scrollBar&&this._resize(r)}}))}};rn=eA([qe(1,i.IUniverInstanceService),qe(2,ae),qe(3,i.ICommandService),qe(4,i.Inject(exports.DocSelectionRenderService)),qe(5,i.Inject(D.DocSkeletonManagerService)),qe(6,B.IRenderManagerService)],rn);var tA=Object.getOwnPropertyDescriptor,nA=(o,t,e,n)=>{for(var r=n>1?void 0:n?tA(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Ht=(o,t)=>(e,n)=>t(e,n,o);let oo=class extends i.Disposable{constructor(t,e,n,r,s){super();M(this,"_previousIMEContent","");M(this,"_isCompositionStart",!0);M(this,"_onStartSubscription");M(this,"_onUpdateSubscription");M(this,"_onEndSubscription");this._context=t,this._docSelectionRenderService=e,this._docImeInputManagerService=n,this._docSkeletonManagerService=r,this._commandService=s,this._initialize()}dispose(){var t,e,n;(t=this._onStartSubscription)==null||t.unsubscribe(),(e=this._onUpdateSubscription)==null||e.unsubscribe(),(n=this._onEndSubscription)==null||n.unsubscribe()}_initialize(){this._initialOnCompositionstart(),this._initialOnCompositionUpdate(),this._initialOnCompositionend()}_initialOnCompositionstart(){this._onStartSubscription=this._docSelectionRenderService.onCompositionstart$.subscribe(t=>{if(t==null)return;this._resetIME();const{activeRange:e}=t;e!=null&&this._docImeInputManagerService.setActiveRange(i.Tools.deepClone(e))})}_initialOnCompositionUpdate(){this._onUpdateSubscription=this._docSelectionRenderService.onCompositionupdate$.subscribe(t=>{this._updateContent(t,!0)})}_initialOnCompositionend(){this._onEndSubscription=this._docSelectionRenderService.onCompositionend$.subscribe(t=>{this._updateContent(t,!1)})}async _updateContent(t,e){if(t==null)return;const n=this._context.unitId,r=this._docSkeletonManagerService.getSkeleton(),{event:s,activeRange:a}=t;if(r==null||a==null)return;const l=s.data;l===this._previousIMEContent&&e||(await this._commandService.executeCommand($o.id,{unitId:n,newText:l,oldTextLen:this._previousIMEContent.length,isCompositionStart:this._isCompositionStart,isCompositionEnd:!e}),e?(this._isCompositionStart&&(this._isCompositionStart=!1),this._previousIMEContent=l):this._resetIME())}_resetIME(){this._previousIMEContent="",this._isCompositionStart=!0,this._docImeInputManagerService.clearUndoRedoMutationParamsCache(),this._docImeInputManagerService.setActiveRange(null)}};oo=nA([Ht(1,i.Inject(exports.DocSelectionRenderService)),Ht(2,i.Inject(Pt)),Ht(3,i.Inject(D.DocSkeletonManagerService)),Ht(4,i.ICommandService)],oo);var oA=Object.getOwnPropertyDescriptor,rA=(o,t,e,n)=>{for(var r=n>1?void 0:n?oA(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},kt=(o,t)=>(e,n)=>t(e,n,o);let ro=class extends i.Disposable{constructor(t,e,n,r,s){super();M(this,"_onInputSubscription");this._context=t,this._docSelectionRenderService=e,this._docSkeletonManagerService=n,this._commandService=r,this._docMenuStyleService=s,this._init()}dispose(){var t;super.dispose(),(t=this._onInputSubscription)==null||t.unsubscribe()}_init(){this._initialNormalInput()}_initialNormalInput(){this._onInputSubscription=this._docSelectionRenderService.onInput$.subscribe(async t=>{var f,S;if(t==null)return;const{unitId:e}=this._context,{event:n,content:r="",activeRange:s}=t,a=n,c=this._docSkeletonManagerService.getSkeleton();if(a.data==null||c==null||s==null)return;const{segmentId:l}=s,d=this._context.unit.getSelfOrHeaderFooterModel(l).getBody(),u=this._docMenuStyleService.getDefaultStyle(),m=this._docMenuStyleService.getStyleCache(),g=lo((f=d==null?void 0:d.customRanges)!=null?f:[],s.endOffset,i.SHEET_EDITOR_UNITS.includes(e)),h=an(d,s.endOffset,u,m,i.SHEET_EDITOR_UNITS.includes(e)),p=Ao((S=d==null?void 0:d.customDecorations)!=null?S:[],s.endOffset);await this._commandService.executeCommand(yo.id,{unitId:e,body:{dataStream:r,textRuns:h?[{...h,st:0,ed:r.length}]:[],customRanges:g?[{...g,startIndex:0,endIndex:r.length-1}]:[],customDecorations:p.map(E=>({...E,startIndex:0,endIndex:r.length-1}))},range:s,segmentId:l}),r===" "&&await this._commandService.executeCommand(Nt.id)})}};ro=rA([kt(1,i.Inject(exports.DocSelectionRenderService)),kt(2,i.Inject(D.DocSkeletonManagerService)),kt(3,i.ICommandService),kt(4,i.Inject(Te))],ro);class tr extends i.Disposable{constructor(t){super(),this._context=t}calculatePagePosition(){var T,R;const t=Ie(this._context),n=(R=(T=this._context.unit.getSettings())==null?void 0:T.zoomRatio)!=null?R:1,{document:r,scene:s,docBackground:a}=t,c=s==null?void 0:s.getParent(),{width:l,height:A,pageMarginLeft:d,pageMarginTop:u}=r;if(c==null||l===Number.POSITIVE_INFINITY||A===Number.POSITIVE_INFINITY)return;const{width:m,height:g}=c;let h=0,p=u,f=0,S=0,E=Number.POSITIVE_INFINITY;m>(l+d*2)*n?(h=m/2-l*n/2,h/=n,f=(m-d*2)/n,E=0):(h=d,f=l+d*2,E=(f-m/n)/2),g>A?S=(g-u*2)/n:S=A+u*2,s.resize(f,S),m<=1&&(h=-1e4,p=-1e4),r.translate(h,p),a.translate(h,p);const C=s.getViewport(ie.VIEW_MAIN);return E!==Number.POSITIVE_INFINITY&&C!=null&&C.scrollToViewportPos({viewportScrollX:E}),this}}var iA=Object.getOwnPropertyDescriptor,sA=(o,t,e,n)=>{for(var r=n>1?void 0:n?iA(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Xr=(o,t)=>(e,n)=>t(e,n,o);let io=class extends i.Disposable{constructor(o,t,e){super(),this._context=o,this._docPageLayoutService=t,this._textSelectionManagerService=e;const n=this._context.unitId;if(i.isInternalEditorID(n)&&n!==i.DOCS_ZEN_EDITOR_UNIT_ID_KEY)return this;this._initResize()}_initResize(){this.disposeWithMe(i.fromEventSubject(this._context.engine.onTransformChange$).pipe(U.filter(o=>o.type===B.TRANSFORM_CHANGE_OBSERVABLE_TYPE.resize),U.throttleTime(0,U.animationFrameScheduler)).subscribe(()=>{this._docPageLayoutService.calculatePagePosition(),this._textSelectionManagerService.refreshSelection()}))}};io=sA([Xr(1,i.Inject(tr)),Xr(2,i.Inject(D.DocSelectionManagerService))],io);var aA=Object.getOwnPropertyDescriptor,cA=(o,t,e,n)=>{for(var r=n>1?void 0:n?aA(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Je=(o,t)=>(e,n)=>t(e,n,o);let so=class extends i.Disposable{constructor(t,e,n,r,s,a,c){super();M(this,"_loadedMap",new WeakSet);this._context=t,this._commandService=e,this._editorService=n,this._instanceSrv=r,this._docSelectionRenderService=s,this._docSkeletonManagerService=a,this._docSelectionManagerService=c,this._initialize()}_initialize(){this._init(),this._skeletonListener(),this._commandExecutedListener(),this._refreshListener(),this._syncSelection()}_init(){const{unitId:t}=this._context,e=Ie(this._context);e==null||e.document==null||this._loadedMap.has(e.document)||(this._initialMain(t),this._loadedMap.add(e.document))}_refreshListener(){this.disposeWithMe(this._docSelectionManagerService.refreshSelection$.subscribe(t=>{if(t==null)return;const{unitId:e,docRanges:n,isEditing:r,options:s}=t;e===this._context.unitId&&(this._docSelectionRenderService.removeAllRanges(),this._docSelectionRenderService.addDocRanges(n,r,s))}))}_syncSelection(){this.disposeWithMe(this._docSelectionRenderService.textSelectionInner$.subscribe(t=>{t!=null&&this._docSelectionManagerService.__replaceTextRangesWithNoRefresh(t,{unitId:this._context.unitId,subUnitId:this._context.unitId})}))}_initialMain(t){const e=Ie(this._context),{document:n,scene:r}=e;this.disposeWithMe(n.onPointerEnter$.subscribeEvent(()=>{this._isEditorReadOnly(t)||(n.cursor=B.CURSOR_TYPE.TEXT)})),this.disposeWithMe(n.onPointerLeave$.subscribeEvent(()=>{n.cursor=B.CURSOR_TYPE.DEFAULT,r.resetCursor()})),this.disposeWithMe(n.onPointerDown$.subscribeEvent((s,a)=>{if(this._isEditorReadOnly(t))return;const c=this._instanceSrv.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC);(c==null?void 0:c.getUnitId())!==t&&this._instanceSrv.setCurrentUnitForType(t);const l=this._docSkeletonManagerService.getSkeleton(),{offsetX:A,offsetY:d}=s,u=this._getTransformCoordForDocumentOffset(A,d);if(u!=null){const{pageLayoutType:m=B.PageLayoutType.VERTICAL,pageMarginLeft:g,pageMarginTop:h}=n.getOffsetConfig(),{editArea:p}=l.findEditAreaByCoord(u,m,g,h),f=this._docSkeletonManagerService.getViewModel(),S=f.getEditArea();S!==B.DocumentEditArea.BODY&&p!==B.DocumentEditArea.BODY&&p!==S&&f.setEditArea(p)}if(this._docSelectionRenderService.__onPointDown(s),this._editorService.getEditor(t)){this._setEditorFocus(t);const{offsetX:m,offsetY:g}=s;setTimeout(()=>{t===this._editorService.getFocusId()||this._docSelectionRenderService.isOnPointerEvent||(this._setEditorFocus(t),this._docSelectionRenderService.setCursorManually(m,g))},0)}s.button!==2&&a.stopPropagation()})),this.disposeWithMe(n.onDblclick$.subscribeEvent(s=>{this._isEditorReadOnly(t)||this._docSelectionRenderService.__handleDblClick(s)})),this.disposeWithMe(n.onTripleClick$.subscribeEvent(s=>{this._isEditorReadOnly(t)||this._docSelectionRenderService.__handleTripleClick(s)}))}_getTransformCoordForDocumentOffset(t,e){const n=Ie(this._context),{document:r,scene:s}=n,{documentTransform:a}=r.getOffsetConfig(),c=s.getViewports()[0];if(c==null)return;const l=c.transformVector2SceneCoord(B.Vector2.FromArray([t,e]));return a.clone().invert().applyPoint(l)}_isEditorReadOnly(t){const e=this._editorService.getEditor(t);return e?e.isReadOnly():!1}_setEditorFocus(t){this._editorService.focus(t)}_commandExecutedListener(){const t=[Ae.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var n;if(t.includes(e.id)){const r=e.params,{unitId:s}=r,a=(n=this._docSelectionManagerService.__getCurrentSelection())==null?void 0:n.unitId;if(s!==a)return;this._docSelectionManagerService.refreshSelection()}}))}_skeletonListener(){this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe(t=>{if(!t)return;const{unitId:e}=this._context;if(!i.isInternalEditorID(e)){this._docSelectionRenderService.focus();const s=this._context.unit.getSnapshot(),a=Di(s);this._docSelectionManagerService.replaceDocRanges([{startOffset:a,endOffset:a}],{unitId:e,subUnitId:e},!1)}}))}};so=cA([Je(1,i.ICommandService),Je(2,ae),Je(3,i.IUniverInstanceService),Je(4,i.Inject(exports.DocSelectionRenderService)),Je(5,i.Inject(D.DocSkeletonManagerService)),Je(6,i.Inject(D.DocSelectionManagerService))],so);var lA=Object.getOwnPropertyDescriptor,dA=(o,t,e,n)=>{for(var r=n>1?void 0:n?lA(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},Ve=(o,t)=>(e,n)=>t(e,n,o);let ao=class extends i.Disposable{constructor(o,t,e,n,r,s,a,c){super(),this._context=o,this._contextService=t,this._docSkeletonManagerService=e,this._univerInstanceService=n,this._commandService=r,this._textSelectionManagerService=s,this._editorService=a,this._docPageLayoutService=c,this._initSkeletonListener(),this._initCommandExecutedListener(),this._initRenderRefresher(),setTimeout(()=>this.updateViewZoom(1,!0),20),i.isInternalEditorID(this._context.unitId)||this._initZoomEventListener()}_initRenderRefresher(){this._docSkeletonManagerService.currentSkeleton$.subscribe(o=>{if(o==null)return;const{unitId:t,scene:e}=this._context;this._editorService.isEditor(t)||this.disposeWithMe(e.onMouseWheel$.subscribeEvent(n=>{if(!n.ctrlKey||!this._contextService.getContextValue(i.FOCUSING_DOC))return;const r=this._univerInstanceService.getCurrentUniverDocInstance();if(!r)return;const{documentFlavor:s}=r.getSnapshot().documentStyle;if(s===i.DocumentFlavor.MODERN)return;const a=Math.abs(n.deltaX);let c=a<40?.2:a<80?.4:.2;c*=n.deltaY>0?-1:1,e.scaleX<1&&(c/=2);const l=r.zoomRatio;let A=+Number.parseFloat(`${l+c}`).toFixed(1);A=A>=4?4:A<=.1?.1:A,this._commandService.executeCommand(It.id,{zoomRatio:A,unitId:r.getUnitId()}),n.preventDefault()}))})}_initSkeletonListener(){this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe(o=>{if(o==null)return;const t=this._univerInstanceService.getCurrentUniverDocInstance();if(!t)return;const e=t.zoomRatio||1;this.updateViewZoom(e,!1)}))}_initCommandExecutedListener(){const o=[Ae.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(o.includes(t.id)&&t.params.unitId===this._context.unitId){const n=this._context.unit.zoomRatio||1;this.updateViewZoom(n)}})),this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===_t.id&&this._commandService.executeCommand(It.id,{zoomRatio:1,unitId:this._context.unitId})}))}updateViewZoom(o,t=!0){var n;const e=Ie(this._context);e.scene.scale(o,o),this._editorService.isEditor(this._context.unitId)||this._docPageLayoutService.calculatePagePosition(),t&&!this._editorService.isEditor(this._context.unitId)&&this._textSelectionManagerService.refreshSelection(),(n=e.scene.getTransformer())==null||n.clearSelectedObjects()}_initZoomEventListener(){const o=this._context.scene;this.disposeWithMe(o.onMouseWheel$.subscribeEvent(t=>{if(!t.ctrlKey)return;const e=Math.abs(t.deltaX);let n=e<40?.2:e<80?.4:.2;n*=t.deltaY>0?-1:1,o.scaleX<1&&(n/=2);const r=this._context.unit.zoomRatio;let s=+Number.parseFloat(`${r+n}`).toFixed(1);s=s>=4?4:s<=.1?.1:s,this._commandService.executeCommand(It.id,{zoomRatio:Math.round(s*10)/10,documentId:this._context.unitId}),t.preventDefault()}))}};ao=dA([Ve(1,i.IContextService),Ve(2,i.Inject(D.DocSkeletonManagerService)),Ve(3,i.IUniverInstanceService),Ve(4,i.ICommandService),Ve(5,i.Inject(D.DocSelectionManagerService)),Ve(6,ae),Ve(7,i.Inject(tr))],ao);const AA=i.createInterceptorKey("PRINTING_COMPONENT_COLLECT"),uA=i.createInterceptorKey("PRINTING_DOM_COLLECT");class gs extends i.Disposable{constructor(){super();M(this,"_printComponentMap",new Map);M(this,"interceptor",new i.InterceptorManager({PRINTING_COMPONENT_COLLECT:AA,PRINTING_DOM_COLLECT:uA}));this.disposeWithMe(this.interceptor.intercept(this.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{priority:-1,handler:e=>e})),this.disposeWithMe(this.interceptor.intercept(this.interceptor.getInterceptPoints().PRINTING_DOM_COLLECT,{priority:-1,handler:e=>e}))}registerPrintComponent(e,n){this._printComponentMap.set(e,n)}getPrintComponent(e){return this._printComponentMap.get(e)}}var gA=Object.getOwnPropertyDescriptor,hA=(o,t,e,n)=>{for(var r=n>1?void 0:n?gA(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},gt=(o,t)=>(e,n)=>t(e,n,o);const Kr=300;exports.DocStateChangeManagerService=class extends i.RxDisposable{constructor(e,n,r,s,a){super();M(this,"_docStateChange$",new U.BehaviorSubject(null));M(this,"docStateChange$",this._docStateChange$.asObservable());M(this,"_historyStateCache",new Map);M(this,"_changeStateCache",new Map);M(this,"_historyTimer",null);M(this,"_changeStateCacheTimer",null);this._undoRedoService=e,this._commandService=n,this._univerInstanceService=r,this._docStateEmitService=s,this._renderManagerService=a,this._initialize(),this._listenDocStateChange()}getStateCache(e){var n,r;return{history:(n=this._historyStateCache.get(e))!=null?n:[],collaboration:(r=this._changeStateCache.get(e))!=null?r:[]}}setStateCache(e,n){this._historyStateCache.set(e,n.history),this._changeStateCache.set(e,n.collaboration)}_setChangeState(e){this._cacheChangeState(e,"history"),this._cacheChangeState(e,"collaboration")}_initialize(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===i.UndoCommandId||e.id===i.RedoCommandId){const n=this._univerInstanceService.getCurrentUniverDocInstance();if(n==null)return;const r=n.getUnitId();this._pushHistory(r),this._emitChangeState(r)}}))}_listenDocStateChange(){this._docStateEmitService.docStateChangeParams$.pipe(U.takeUntil(this.dispose$)).subscribe(e=>{var l;if(e==null)return;const{isCompositionEnd:n,isSync:r,syncer:s,...a}=e,c=(l=this._renderManagerService.getRenderById(r?s:e.unitId))==null?void 0:l.with(Pt);if(c!=null){if(n){const A=c.fetchComposedUndoRedoMutationParams();if(A==null)throw new Error("historyParams is null in RichTextEditingMutation");const{undoMutationParams:d,redoMutationParams:u,previousActiveRange:m}=A;a.redoState.actions=u.actions,a.undoState.actions=d.actions,a.undoState.textRanges=[m]}this._setChangeState(a)}})}_cacheChangeState(e,n="history"){const{trigger:r,unitId:s,noHistory:a,debounce:c=!1}=e;if(a||r==null||n==="history"&&(r===i.RedoCommandId||r===i.UndoCommandId))return;const l=n==="history"?this._historyStateCache:this._changeStateCache,A=n==="history"?this._pushHistory.bind(this):this._emitChangeState.bind(this);if(l.has(s)){const d=l.get(s);d==null||d.push(e)}else l.set(s,[e]);c?n==="history"?(this._historyTimer&&clearTimeout(this._historyTimer),this._historyTimer=setTimeout(()=>{A(s)},Kr)):(this._changeStateCacheTimer&&clearTimeout(this._changeStateCacheTimer),this._changeStateCacheTimer=setTimeout(()=>{A(s)},Kr)):A(s)}_pushHistory(e){const n=this._undoRedoService,r=this._historyStateCache.get(e);if(!Array.isArray(r)||r.length===0)return;const s=r.length,a=r[0].commandId,c=r[0],l=r[s-1],A={unitId:e,actions:r.reduce((u,m)=>i.JSONX.compose(u,m.redoState.actions),null),textRanges:l.redoState.textRanges},d={unitId:e,actions:r.reverse().reduce((u,m)=>i.JSONX.compose(u,m.undoState.actions),null),textRanges:c.undoState.textRanges};n.pushUndoRedo({unitID:e,undoMutations:[{id:a,params:d}],redoMutations:[{id:a,params:A}]}),r.length=0}_emitChangeState(e){const n=this._changeStateCache.get(e);if(!Array.isArray(n)||n.length===0)return;const r=n.length,{commandId:s,trigger:a,segmentId:c,noHistory:l,debounce:A}=n[0],d=n[0],u=n[r-1],m={unitId:e,actions:n.reduce((p,f)=>i.JSONX.compose(p,f.redoState.actions),null),textRanges:u.redoState.textRanges},g={unitId:e,actions:n.reverse().reduce((p,f)=>i.JSONX.compose(p,f.undoState.actions),null),textRanges:d.undoState.textRanges},h={commandId:s,unitId:e,trigger:a,redoState:m,undoState:g,segmentId:c,noHistory:l,debounce:A};n.length=0,this._docStateChange$.next(h)}};exports.DocStateChangeManagerService=hA([gt(0,i.Inject(i.IUndoRedoService)),gt(1,i.ICommandService),gt(2,i.IUniverInstanceService),gt(3,i.Inject(D.DocStateEmitService)),gt(4,B.IRenderManagerService)],exports.DocStateChangeManagerService);var mA=Object.getOwnPropertyDescriptor,pA=(o,t,e,n)=>{for(var r=n>1?void 0:n?mA(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},zr=(o,t)=>(e,n)=>t(e,n,o);const Yr="univer-doc-main-canvas";exports.DocsRenderService=class extends i.RxDisposable{constructor(t,e){super(),this._instanceSrv=t,this._renderManagerService=e,this._init()}_init(){this._renderManagerService.createRender$.pipe(U.takeUntil(this.dispose$)).subscribe(t=>this._createRenderWithId(t)),this._instanceSrv.getAllUnitsForType(i.UniverInstanceType.UNIVER_DOC).forEach(t=>this._createRenderer(t)),this._instanceSrv.getTypeOfUnitAdded$(i.UniverInstanceType.UNIVER_DOC).pipe(U.takeUntil(this.dispose$)).subscribe(t=>this._createRenderer(t)),this._instanceSrv.getTypeOfUnitDisposed$(i.UniverInstanceType.UNIVER_DOC).pipe(U.takeUntil(this.dispose$)).subscribe(t=>this._disposeRenderer(t))}_createRenderer(t){var r;const e=t.getUnitId(),n=(r=this._instanceSrv.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC))==null?void 0:r.getUnitId();this._renderManagerService.created$.subscribe(s=>{s.unitId===n&&(s.engine.getCanvas().setId(Yr),s.engine.getCanvas().getContext().setId(Yr))}),this._renderManagerService.has(e)||this._createRenderWithId(e)}_createRenderWithId(t){this._renderManagerService.createRender(t)}_disposeRenderer(t){const e=t.getUnitId();this._renderManagerService.removeRender(e)}};exports.DocsRenderService=pA([zr(0,i.IUniverInstanceService),zr(1,B.IRenderManagerService)],exports.DocsRenderService);const fA={id:rt.id,preconditions:ul,binding:I.KeyCode.ENTER},SA={id:bt.id,preconditions:$,binding:I.KeyCode.BACKSPACE},IA={id:Ro.id,preconditions:$,binding:I.KeyCode.DELETE},vA={id:Ee.id,binding:I.KeyCode.ARROW_UP,preconditions:$,staticParameters:{direction:i.Direction.UP}},EA={id:Ee.id,binding:I.KeyCode.ARROW_DOWN,preconditions:$,staticParameters:{direction:i.Direction.DOWN}},CA={id:Ee.id,binding:I.KeyCode.ARROW_LEFT,preconditions:$,staticParameters:{direction:i.Direction.LEFT}},TA={id:Ee.id,binding:I.KeyCode.ARROW_RIGHT,preconditions:$,staticParameters:{direction:i.Direction.RIGHT}},yA={id:Ce.id,binding:I.KeyCode.ARROW_UP|I.MetaKeys.SHIFT,preconditions:$,staticParameters:{direction:i.Direction.UP}},bA={id:Ce.id,binding:I.KeyCode.ARROW_DOWN|I.MetaKeys.SHIFT,preconditions:$,staticParameters:{direction:i.Direction.DOWN}},RA={id:Ce.id,binding:I.KeyCode.ARROW_LEFT|I.MetaKeys.SHIFT,preconditions:$,staticParameters:{direction:i.Direction.LEFT}},xA={id:Ce.id,binding:I.KeyCode.ARROW_RIGHT|I.MetaKeys.SHIFT,preconditions:$,staticParameters:{direction:i.Direction.RIGHT}},OA={id:Zo.id,binding:I.KeyCode.A|I.MetaKeys.CTRL_COMMAND,preconditions:o=>o.getContextValue(i.FOCUSING_UNIVER_EDITOR)&&(o.getContextValue(i.FOCUSING_DOC)||o.getContextValue(i.EDITOR_ACTIVATED))};var MA=Object.defineProperty,DA=Object.getOwnPropertyDescriptor,BA=(o,t,e)=>t in o?MA(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,_A=(o,t,e,n)=>{for(var r=n>1?void 0:n?DA(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=a(r)||r);return r},ht=(o,t)=>(e,n)=>t(e,n,o),NA=(o,t,e)=>BA(o,t+"",e);exports.UniverDocsUIPlugin=class extends i.Plugin{constructor(t=Ur,e,n,r,s,a){super(),this._config=t,this._injector=e,this._renderManagerSrv=n,this._commandService=r,this._logService=s,this._configService=a;const{menu:c,...l}=i.merge({},Ur,this._config);c&&this._configService.setConfig("menu",c,{merge:!0}),this._configService.setConfig(En,l),this._initDependencies(e),this._initializeShortcut(),this._initCommand()}onReady(){this._initRenderBasics(),this._markDocAsFocused(),i.touchDependencies(this._injector,[[exports.DocStateChangeManagerService],[exports.DocsRenderService]])}onRendered(){this._initUI(),this._initRenderModules(),i.touchDependencies(this._injector,[[en],[tn],[it],[nn],[exports.DocUIController]])}_initCommand(){[bt,Ro,_e,Ne,Pe,we,ye,Ue,me,Ge,Me,st,De,be,In,yo,et,gn,bo,hn,ki,Ae,ot,nt,at,Ot,Mt,Dt,pe,Bt,Rt,Go,Yo,yn,bn,is,Rn,xn,Cn,Tn,ct,vo,er,Xe,Nt,rt,Yt,xt,Et,Po,wo,$o,_t,fe,To,We,ii,uo,si,It,Zo,qo,Ee,Ce,ci,go,ls,le,qi,xo,Do,Bo,Ho,ko,Vo,jo,Wo,qt,Ji,Zi,Lo,Qo,Fo,No,es,Xo].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))}),[vt,fn,Sn].forEach(t=>this.disposeWithMe(this._commandService.registerMultipleCommand(t)))}_initializeShortcut(){[vA,EA,TA,CA,yA,bA,RA,xA,OA,SA,IA,fA,hl].forEach(t=>{this._injector.get(I.IShortcutService).registerShortcut(t)})}_initDependencies(t){i.mergeOverrideWithDependencies([[gs],[on],[rn],[exports.DocUIController],[en],[nn],[tn],[$t],[it],[ae,{useClass:exports.EditorService}],[Be,{useClass:qn}],[exports.DocCanvasPopManagerService],[exports.DocsRenderService],[exports.DocStateChangeManagerService],[exports.DocAutoFormatService],[Te]],this._config.override).forEach(n=>t.add(n))}_markDocAsFocused(){const t=this._injector.get(i.IUniverInstanceService),e=this._injector.get(ae);try{const n=t.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC);if(!n)return;const r=n.getUnitId();e.isEditor(r)||t.focusUnit(n.getUnitId())}catch(n){this._logService.warn(n)}}_initUI(){this._injector.get($t)}_initRenderBasics(){[[D.DocSkeletonManagerService],[exports.DocSelectionRenderService],[D.DocInterceptorService],[tr],[Pt],[exports.DocRenderController],[ao]].forEach(t=>{this._renderManagerSrv.registerRenderModule(i.UniverInstanceType.UNIVER_DOC,t)})}_initRenderModules(){[[exports.DocEventManagerService],[Jt],[Zt],[exports.DocBackScrollRenderController],[so],[zn],[io],[no],[to],[on],[ro],[oo],[rn]].forEach(t=>{this._renderManagerSrv.registerRenderModule(i.UniverInstanceType.UNIVER_DOC,t)})}};NA(exports.UniverDocsUIPlugin,"pluginName",Zr);exports.UniverDocsUIPlugin=_A([i.DependentOn(B.UniverRenderEnginePlugin),ht(1,i.Inject(i.Injector)),ht(2,B.IRenderManagerService),ht(3,i.ICommandService),ht(4,i.ILogService),ht(5,i.IConfigService)],exports.UniverDocsUIPlugin);exports.AfterSpaceCommand=Nt;exports.AlignCenterCommand=Mt;exports.AlignJustifyCommand=Bt;exports.AlignLeftCommand=Ot;exports.AlignOperationCommand=pe;exports.AlignRightCommand=Dt;exports.BreakLineCommand=In;exports.BulletListCommand=nt;exports.ChangeListNestingLevelCommand=Yt;exports.ChangeListNestingLevelType=St;exports.ChangeListTypeCommand=xt;exports.CheckListCommand=Et;exports.CoverContentCommand=si;exports.CreateDocTableCommand=Go;exports.CutContentCommand=We;exports.DOCS_COMPONENT_BACKGROUND_LAYER_INDEX=$r;exports.DOCS_COMPONENT_DEFAULT_Z_INDEX=kn;exports.DOCS_COMPONENT_HEADER_LAYER_INDEX=ei;exports.DOCS_COMPONENT_MAIN_LAYER_INDEX=Vt;exports.DOCS_VIEW_KEY=de;exports.DOC_UI_PLUGIN_NAME=Zr;exports.DOC_VERTICAL_PADDING=$n;exports.DefaultDocContainerConfig=Jr;exports.DefaultToolbarConfig=qr;exports.DeleteCommand=et;exports.DeleteCustomBlockCommand=gn;exports.DeleteLeftCommand=bt;exports.DeleteRightCommand=Ro;exports.DocCopyCommand=vt;exports.DocCreateTableOperation=vn;exports.DocCutCommand=fn;exports.DocIMEInputManagerService=Pt;exports.DocPasteCommand=Sn;exports.DocPrintInterceptorService=gs;exports.DocSelectAllCommand=Zo;exports.DocTableDeleteColumnsCommand=Tn;exports.DocTableDeleteRowsCommand=Cn;exports.DocTableDeleteTableCommand=ct;exports.DocTableInsertColumnCommand=is;exports.DocTableInsertColumnLeftCommand=Rn;exports.DocTableInsertColumnRightCommand=xn;exports.DocTableInsertRowAboveCommand=yn;exports.DocTableInsertRowBellowCommand=bn;exports.DocTableInsertRowCommand=Yo;exports.DocTableTabCommand=er;exports.DocsUIMenuSchema=cs;exports.Editor=ui;exports.EditorInsertTextCommandId=Hi;exports.EnterCommand=rt;exports.HorizontalLineCommand=Rt;exports.IDocClipboardService=Be;exports.IEditorService=ae;exports.IMEInputCommand=$o;exports.InnerPasteCommand=To;exports.InsertCommand=yo;exports.InsertCustomRangeCommand=ls;exports.ListOperationCommand=at;exports.MergeTwoParagraphCommand=hn;exports.MoveCursorOperation=Ee;exports.MoveSelectionOperation=Ce;exports.NORMAL_TEXT_SELECTION_PLUGIN_NAME=Es;exports.NodePositionConvertToCursor=ve;exports.NodePositionConvertToRectRange=po;exports.OrderListCommand=ot;exports.PastePluginLark=ji;exports.PastePluginUniver=Gi;exports.PastePluginWord=Xi;exports.QuickListCommand=wo;exports.RectRange=fo;exports.ReplaceContentCommand=ii;exports.ReplaceSelectionCommand=go;exports.ReplaceSnapshotCommand=uo;exports.ReplaceTextRunsCommand=ci;exports.ResetInlineFormatTextBackgroundColorCommand=st;exports.RichTextEditor=Ks;exports.SetDocZoomRatioCommand=It;exports.SetDocZoomRatioOperation=Ae;exports.SetInlineFormatBoldCommand=_e;exports.SetInlineFormatCommand=be;exports.SetInlineFormatFontFamilyCommand=Ge;exports.SetInlineFormatFontSizeCommand=me;exports.SetInlineFormatItalicCommand=Ne;exports.SetInlineFormatStrikethroughCommand=we;exports.SetInlineFormatSubscriptCommand=ye;exports.SetInlineFormatSuperscriptCommand=Ue;exports.SetInlineFormatTextBackgroundColorCommand=De;exports.SetInlineFormatTextColorCommand=Me;exports.SetInlineFormatUnderlineCommand=Pe;exports.SetParagraphNamedStyleCommand=le;exports.SwitchDocModeCommand=_t;exports.TEXT_RANGE_LAYER_INDEX=Kt;exports.TabCommand=Xe;exports.TextRange=je;exports.ToggleCheckListCommand=Po;exports.UpdateCommand=bo;exports.VIEWPORT_KEY=ie;exports.addCustomDecorationBySelectionFactory=Ts;exports.addCustomDecorationFactory=ni;exports.calcDocRangePositions=Xt;exports.convertBodyToHtml=Ki;exports.convertPositionsToRectRanges=Wt;exports.deleteCustomDecorationFactory=ys;exports.docDrawingPositionToTransform=Rs;exports.genTableSource=Co;exports.generateParagraphs=_o;exports.getAnchorBounding=ft;exports.getCanvasOffsetByEngine=Ai;exports.getCommandSkeleton=ce;exports.getCursorWhenDelete=mn;exports.getCustomBlockIdsInSelections=Qi;exports.getCutActionsFromDocRanges=Fi;exports.getDocObject=ti;exports.getDocObjectById=Cs;exports.getEmptyTableCell=dn;exports.getEmptyTableRow=An;exports.getLineBounding=cn;exports.getOneTextSelectionRange=jn;exports.getRichTextEditPath=J;exports.getTableColumn=un;exports.hasParagraphInTable=bs;exports.isInSameTableCell=mo;exports.isValidRectRange=li;exports.neoGetDocObject=Ie;exports.transformToDocDrawingPosition=xs;exports.useKeyboardEvent=oi;exports.useResize=ri;exports.whenDocAndEditorFocused=$;
|
package/lib/es/index.js
CHANGED
|
@@ -9933,7 +9933,7 @@ function $h() {
|
|
|
9933
9933
|
children: e.map((E) => /* @__PURE__ */ Q(Kl, { title: E.label, placement: "bottom", children: /* @__PURE__ */ Q(
|
|
9934
9934
|
"span",
|
|
9935
9935
|
{
|
|
9936
|
-
className: Ge("univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-bg-none univer-px-3 univer-py-1
|
|
9936
|
+
className: Ge("hover:univer-bg-black/60 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-bg-none univer-px-3 univer-py-1", {
|
|
9937
9937
|
"univer-bg-blend-color-dodge/90": o === E.value
|
|
9938
9938
|
}),
|
|
9939
9939
|
onClick: () => r(E.value),
|
package/lib/index.js
CHANGED
|
@@ -9933,7 +9933,7 @@ function $h() {
|
|
|
9933
9933
|
children: e.map((E) => /* @__PURE__ */ Q(Kl, { title: E.label, placement: "bottom", children: /* @__PURE__ */ Q(
|
|
9934
9934
|
"span",
|
|
9935
9935
|
{
|
|
9936
|
-
className: Ge("univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-bg-none univer-px-3 univer-py-1
|
|
9936
|
+
className: Ge("hover:univer-bg-black/60 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-bg-none univer-px-3 univer-py-1", {
|
|
9937
9937
|
"univer-bg-blend-color-dodge/90": o === E.value
|
|
9938
9938
|
}),
|
|
9939
9939
|
onClick: () => r(E.value),
|