@univerjs/sheets-ui 0.8.0-nightly.202506061607 → 0.8.0-nightly.202506081606
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +190 -169
- package/lib/index.js +190 -169
- package/lib/umd/index.js +1 -1
- package/package.json +12 -12
package/lib/umd/index.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
`,paragraphs:[{startIndex:i.length}],customRanges:[o]}}let r=n.replace(/(\r\n|\n)/g,"\r");r.endsWith(`\r
|
|
21
21
|
`)||(r+=`\r
|
|
22
22
|
`);const e=[];for(let t=0;t<r.length;t++)r[t]==="\r"&&e.push({startIndex:t});return{dataStream:r,paragraphs:e,sectionBreaks:[{startIndex:r.indexOf(`
|
|
23
|
-
`)}]}}var VS=Object.getOwnPropertyDescriptor,WS=(n,r,e,t)=>{for(var i=t>1?void 0:t?VS(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},qe=(n,r)=>(e,t)=>r(e,t,n);const xS=[m.InsertColMutation.id,m.InsertRowMutation.id,m.RemoveColMutation.id,m.RemoveRowMutation.id,m.MoveRangeMutation.id,m.MoveRowsMutation.id,m.MoveColsMutation.id];let Rn=class extends a.RxDisposable{constructor(r,e,t,i,o,s,l,c,d,u){super();T(this,"_refreshOptionalPaste$",new D.Subject);T(this,"refreshOptionalPaste$",this._refreshOptionalPaste$.asObservable());this._injector=r,this._instanceService=e,this._renderManagerService=t,this._commandService=i,this._contextService=o,this._configService=s,this._sheetClipboardService=l,this._messageService=c,this._localService=d,this._uiPartsService=u,this._init(),this._initCommandListener(),this._initUIComponents(),this._pasteWithDoc()}refreshOptionalPaste(){this._refreshOptionalPaste$.next(Math.random())}_pasteWithDoc(){var t;const r=i=>{i.onPaste$.pipe(D.takeUntil(this.dispose$)).subscribe(o=>{var u,h;if(!le(this._contextService))return;o.event.preventDefault();const s=o.event,l=(u=s.clipboardData)==null?void 0:u.getData("text/html"),c=(h=s.clipboardData)==null?void 0:h.getData("text/plain"),d=this._resolveClipboardFiles(s.clipboardData);this._commandService.executeCommand($i.id,{htmlContent:l,textContent:c,files:d})})};let e=(t=this._renderManagerService.getRenderById(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY))==null?void 0:t.with(q.DocSelectionRenderService);e&&r(e),this._renderManagerService.created$.subscribe(i=>{var o;i.unitId===a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&(e=(o=this._renderManagerService.getRenderById(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY))==null?void 0:o.with(q.DocSelectionRenderService),e&&r(e))})}_resolveClipboardFiles(r){if(!r)return;const e=Array.from(r.items).map(t=>t.kind==="file"?t.getAsFile():void 0).filter(Boolean);return e.length>0?e:void 0}_init(){[Be,Ji,Fe].forEach(e=>this.disposeWithMe(this._commandService.registerMultipleCommand(e))),[un,hn,Pt,mn,$i,Ga].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e))),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initCopyingHooks())),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingHook()));const r=this._initSpecialPasteHooks().map(e=>this._sheetClipboardService.addClipboardHook(e));this.disposeWithMe({dispose:()=>r.forEach(e=>e.dispose())})}_initCopyingHooks(){const r=this;let e=null;return{id:Se.DEFAULT_COPY,isDefaultHook:!0,onBeforeCopy(t,i){e=r._getWorksheet(t,i)},onCopyCellContent(t,i){var l,c,d,u;const o=e.getCell(t,i);return(c=(l=o==null?void 0:o.p)==null?void 0:l.body)!=null&&c.paragraphs||(u=(d=o==null?void 0:o.p)==null?void 0:d.body)!=null&&u.textRuns?q.convertBodyToHtml(o.p):o?a.extractPureTextFromCell(o):""},onCopyCellStyle:(t,i,o,s)=>{const l={};(o||s)&&(l.rowspan=`${o||1}`,l.colspan=`${s||1}`);const c=e.getMergedCell(t,i),d=e.getComposedCellStyle(t,i);let u="";if(d&&(u=a.handleStyleToString(d)),c){const h=c.endRow,g=c.endColumn,f=e.getRange(h,g).getTextStyle();if(f){const v=a.handleStyleToString(f);u?u+=v?`;${v}`:"":u=v}}return u&&(l.style=u),Object.keys(l).length?l:null},onCopyColumn(t){return{width:`${e.getColumnWidth(t)}`}},onCopyRow(t){return{style:`height: ${e.getRowHeight(t)}px;`}},onAfterCopy(){e=null},getFilteredOutRows(t){var c;const{startRow:i,endRow:o}=t,s=(c=r._instanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:c.getActiveSheet(),l=[];if(!s)return l;for(let d=i;d<=o;d++)s.getRowFiltered(d)&&l.push(d);return l}}}_initPastingHook(){const r=this;let e=null,t=null,i=null;return{id:Se.DEFAULT_PASTE,isDefaultHook:!0,onBeforePaste({unitId:o,subUnitId:s,range:l}){i=r._getWorksheet(o,s),e=o,t=s;const c=r._configService.getConfig(m.MAX_CELL_PER_SHEET_KEY),d=l.rows[l.rows.length-1],u=l.cols[l.cols.length-1];return c&&d*u>c?(r._messageService.show({type:X.MessageType.Error,content:r._localService.t("clipboard.paste.exceedMaxCells")}),!1):!0},onPasteRows(o,s){const{range:l}=o,c=[],d=[],u=i.getMaxRows(),h=u-1,g=l.rows[l.rows.length-1]-h,S=s.length-g,f=i.getRowManager();if(g>0){const C={};s.slice(S).forEach((E,O)=>{const{height:M}=E||{};M&&(C[O]={h:Number.parseFloat(M),hd:a.BooleanNumber.FALSE})});const b={startColumn:l.cols[0],endColumn:l.cols[l.cols.length-1],endRow:l.rows[l.rows.length-1],startRow:u},w={unitId:e,subUnitId:t,range:b,rowInfo:C};c.push({id:m.InsertRowMutation.id,params:w}),d.push({id:m.RemoveRowMutation.id,params:{unitId:e,subUnitId:t,range:b}})}const v={},p={};if(s.slice(0,S).forEach((C,b)=>{var E,O;const{height:w}=C;if(w){const M=f.getRow(l.rows[0]+b),P=Number.parseFloat(w);if(M){const{h:A=a.DEFAULT_WORKSHEET_ROW_HEIGHT,ah:k=0}=M,N=Math.max(A,k);P>N?(v[b+l.rows[0]]=P,p[b+l.rows[0]]=N):(v[b+l.rows[0]]=N,p[b+l.rows[0]]=N)}else v[b+l.rows[0]]=P,p[b+l.rows[0]]=(O=(E=f.getRow(l.rows[0]+b))==null?void 0:E.h)!=null?O:a.DEFAULT_WORKSHEET_ROW_HEIGHT}}),Object.keys(v).length){const C={unitId:e,subUnitId:t,ranges:[{startRow:l.rows[0],endRow:Math.min(l.rows[l.rows.length-1],u),startColumn:l.cols[0],endColumn:l.cols[l.cols.length-1]}],rowHeight:v};c.push({id:m.SetWorksheetRowHeightMutation.id,params:C}),d.push({id:m.SetWorksheetRowHeightMutation.id,params:{...C,rowHeight:p}})}return{redos:c,undos:d}},onPasteColumns(o,s,l){var w;const{range:c}=o,d=[],u=[],h=i.getMaxColumns(),g=h-1,S=c.cols[c.cols.length-1]-g,f=s.length-S,v=(w=r._configService.getConfig(a.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?w:a.DEFAULT_WORKSHEET_COLUMN_WIDTH,p=c.cols,C=p[0];if(S>0){const E={startRow:c.rows[0],endRow:c.rows[c.rows.length-1],endColumn:c.cols[c.cols.length-1],startColumn:h},O={unitId:e,subUnitId:t,range:E,colInfo:s.slice(f).map((M,P)=>({w:M.width?Math.max(+M.width,i.getColumnWidth(p[P])):v,hd:a.BooleanNumber.FALSE}))};d.push({id:m.InsertColMutation.id,params:O}),u.push({id:m.RemoveColMutation.id,params:{unitId:e,subUnitId:t,range:E}})}const b={unitId:e,subUnitId:t,ranges:[{startRow:c.rows[0],endRow:c.rows[c.rows.length-1],startColumn:c.cols[0],endColumn:Math.min(c.cols[c.cols.length-1],h)}]};if(s.length>0){const E={...b,colWidth:s.slice(0,f).reduce((M,P,A)=>{var k;return M[A+C]=P.width?Math.max(+P.width,(k=i.getColumnWidth(p[A]))!=null?k:v):v,M},{})},O={...b,colWidth:s.slice(0,f).reduce((M,P,A)=>{var k;return M[A+C]=(k=i.getColumnWidth(p[A]))!=null?k:v,M},{})};d.push({id:m.SetWorksheetColWidthMutation.id,params:E}),u.push({id:m.SetWorksheetColWidthMutation.id,params:O})}return{redos:d,undos:u}},onPastePlainText(o,s,l){return r._onPastePlainText(o,s,l)},onPasteCells(o,s,l,c){return r._onPasteCells(o,s,l,c)},onAfterPaste(o){i=null}}}_generateDocumentDataModelSnapshot(r){var l,c;const e=(l=R.withCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,y.SheetSkeletonManagerService,this._instanceService,this._renderManagerService))==null?void 0:l.getCurrentParam();if(e==null)return null;const{skeleton:t}=e,i=(c=t.getBlankCellDocumentModel())==null?void 0:c.documentModel,s={...i==null?void 0:i.getSnapshot(),...r};return i==null||i.reset(s),i==null?void 0:i.getSnapshot()}_onPastePlainText(r,e,t){const{range:i,unitId:o,subUnitId:s}=r;let l;if(/\r|\n/.test(e)||a.Tools.isLegalUrl(e)){const d=HS(e),u=this._generateDocumentDataModelSnapshot({body:d});l={[i.rows[0]]:{[i.cols[0]]:{p:u}}}}else a.isFormulaString(e)?l={[i.rows[0]]:{[i.cols[0]]:{f:e}}}:l={[i.rows[0]]:{[i.cols[0]]:{v:e}}};const c={unitId:o,subUnitId:s,cellValue:l};return{redos:[{id:m.SetRangeValuesMutation.id,params:c}],undos:[{id:m.SetRangeValuesMutation.id,params:m.SetRangeValuesUndoMutationFactory(this._injector,c)}]}}_onPasteCells(r,e,t,i){return this._injector.invoke(o=>DS(r,e,t,i,o))}_initSpecialPasteHooks(){const r=this,e={id:Se.SPECIAL_PASTE_VALUE,specialPasteInfo:{label:"specialPaste.value"},onPasteCells:(s,l,c)=>this._injector.invoke(d=>bc(l,s,c,d))},t={id:Se.SPECIAL_PASTE_FORMAT,specialPasteInfo:{label:"specialPaste.format"},onPasteCells:(s,l,c)=>{const d=[],u=[],{undos:h,redos:g}=this._injector.invoke(C=>Ec(l,c,C));d.push(...g),u.push(...h);const{undos:S,redos:f}=this._injector.invoke(C=>es(l,c,C));d.push(...f),u.push(...S);const{undos:v,redos:p}=this._injector.invoke(C=>wc(l,s,c,C));return d.push(...p),u.push(...v),{undos:u,redos:d}}},i={id:Se.SPECIAL_PASTE_COL_WIDTH,specialPasteInfo:{label:"specialPaste.colWidth"},onPasteCells(){return{undos:[],redos:[]}},onPasteColumns(s,l,c){var A,k;const d=r._instanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),u=d.getUnitId(),h=(A=d.getActiveSheet())==null?void 0:A.getSheetId();if(!u||!h)throw new Error("Cannot find unitId or subUnitId");const g=[],S=[],f=r._getWorksheet(u,h),{range:v}=s,p=v.cols,C=p[0],b=f.getMaxColumns(),w=v.cols[v.cols.length-1]-b,E=l.length-w,O=(k=r._configService.getConfig(a.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?k:a.DEFAULT_WORKSHEET_COLUMN_WIDTH,M={unitId:u,subUnitId:h,ranges:[{startRow:v.rows[0],endRow:Math.min(v.cols[v.cols.length-1],b),startColumn:v.cols[0],endColumn:v.cols[v.cols.length-1]}],colWidth:l.slice(0,E).reduce((N,H,x)=>{var L;return N[x+C]=H.width?Math.max(+H.width,(L=f.getColumnWidth(p[x]))!=null?L:O):O,N},{})},P={unitId:u,subUnitId:h,ranges:[{startRow:v.rows[0],endRow:Math.min(v.cols[v.cols.length-1],b),startColumn:v.cols[0],endColumn:v.cols[v.cols.length-1]}],colWidth:l.slice(0,E).reduce((N,H,x)=>{var L;return N[x+C]=(L=f.getColumnWidth(p[x]))!=null?L:O,N},{})};return g.push({id:m.SetWorksheetColWidthMutation.id,params:M}),S.push({id:m.SetWorksheetColWidthMutation.id,params:P}),{redos:g,undos:S}}},o={id:Se.SPECIAL_PASTE_BESIDES_BORDER,specialPasteInfo:{label:"specialPaste.besidesBorder"},onPasteCells:(s,l,c,d)=>{r._instanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);const u=[],h=[],{range:g,unitId:S,subUnitId:f}=l,v=new a.ObjectMatrix;c.forValue((E,O,M)=>{const P=M.s;if(typeof P=="object"){const A=a.Tools.deepClone(M);A.s&&(A.s={...P,bd:null}),v.setValue(g.rows[E],g.cols[O],A)}});const p={unitId:S,subUnitId:f,cellValue:v.getData()};u.push({id:m.SetRangeValuesMutation.id,params:p});const C=this._injector.invoke(m.SetRangeValuesUndoMutationFactory,p);h.push({id:m.SetRangeValuesMutation.id,params:C});const{undos:b,redos:w}=this._injector.invoke(E=>es(l,c,E));return h.push(...b),u.push(...w),{redos:u,undos:h}}};return[e,t,i,o]}_getWorksheet(r,e){var i;const t=(i=this._instanceService.getUniverSheetInstance(r))==null?void 0:i.getSheetBySheetId(e);if(!t)throw new Error(`[SheetClipboardController]: cannot find a worksheet with unitId ${r} and subUnitId ${e}.`);return t}_initCommandListener(){var e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{t.id===gt.id?this._sheetClipboardService.removeMarkSelection():xS.includes(t.id)&&this._sheetClipboardService.removeMarkSelection()}));const r=this._configService.getConfig(He);(e=r==null?void 0:r.clipboardConfig)!=null&&e.hidePasteOptions||(this.disposeWithMe(this._commandService.onCommandExecuted(t=>{AS.includes(t.id)&&this._sheetClipboardService.disposePasteOptionsCache()})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===Le.id){if(!this._sheetClipboardService.getPasteMenuVisible())return;const o=t.params.unitId,s=this._sheetClipboardService.getPasteOptionsCache(),l=s==null?void 0:s.target.unitId;o===l&&this._refreshOptionalPaste$.next(Math.random())}})))}_initUIComponents(){var e;const r=this._configService.getConfig(He);(e=r==null?void 0:r.clipboardConfig)!=null&&e.hidePasteOptions||this.disposeWithMe(this._uiPartsService.registerComponent(_.BuiltInUIPart.CONTENT,()=>_.connectInjector(OS,this._injector)))}};Rn=WS([qe(0,a.Inject(a.Injector)),qe(1,a.IUniverInstanceService),qe(2,R.IRenderManagerService),qe(3,a.ICommandService),qe(4,a.IContextService),qe(5,a.IConfigService),qe(6,We),qe(7,_.IMessageService),qe(8,a.Inject(a.LocaleService)),qe(9,_.IUIPartsService)],Rn);var LS=Object.getOwnPropertyDescriptor,US=(n,r,e,t)=>{for(var i=t>1?void 0:t?LS(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Tc=(n,r)=>(e,t)=>r(e,t,n);y.DragManagerService=class extends a.Disposable{constructor(e,t){super();T(this,"_currentCell$",new D.Subject);T(this,"currentCell$",this._currentCell$.asObservable().pipe(D.distinctUntilChanged((e,t)=>{var i,o,s,l,c,d,u,h;return((i=e==null?void 0:e.location)==null?void 0:i.unitId)===((o=t==null?void 0:t.location)==null?void 0:o.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((l=t==null?void 0:t.location)==null?void 0:l.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((d=t==null?void 0:t.location)==null?void 0:d.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=t==null?void 0:t.location)==null?void 0:h.col)})));T(this,"_endCell$",new D.Subject);T(this,"endCell$",this._endCell$.asObservable());this._univerInstanceService=e,this._renderManagerService=t,this._initCellDisposableListener()}dispose(){super.dispose(),this._currentCell$.complete(),this._endCell$.complete()}_initCellDisposableListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e||(this._currentCell$.next(null),this._endCell$.next(null))}))}_calcActiveCell(e,t){const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!i)return null;const o=i.getActiveSheet();if(!o)return;const s=this._renderManagerService.getRenderById(i.getUnitId());if(!s)return;const l=s.with(y.SheetSkeletonManagerService).getCurrentParam(),d=s.with(y.SheetScrollManagerService).getCurrentScrollState();if(!(!l||!d||!s))return vl(s,i,o,l,e,t)}onDragOver(e){const{offsetX:t,offsetY:i,dataTransfer:o}=e,s=this._calcActiveCell(t,i);if(!s){this._currentCell$.next(null);return}const{location:l,position:c}=s;this._currentCell$.next({location:l,position:c,dataTransfer:o})}onDrop(e){const{offsetX:t,offsetY:i,dataTransfer:o}=e,s=this._calcActiveCell(t,i);if(!s){this._endCell$.next(null);return}const{location:l,position:c}=s;this._endCell$.next({location:l,position:c,dataTransfer:o})}},y.DragManagerService=US([Tc(0,a.IUniverInstanceService),Tc(1,R.IRenderManagerService)],y.DragManagerService);var BS=Object.getOwnPropertyDescriptor,FS=(n,r,e,t)=>{for(var i=t>1?void 0:t?BS(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},ts=(n,r)=>(e,t)=>r(e,t,n);y.DragRenderController=class extends a.Disposable{constructor(r,e,t,i){super(),this._context=r,this._renderManagerService=e,this._dragManagerService=t,this._sheetSkeletonManagerService=i,this._initDragEvent()}_initDragEvent(){const r=new a.DisposableCollection,e=t=>{if(r.dispose(),!t)return;const{scene:i}=this._context,o=i.onDragOver$.subscribeEvent(l=>{this._dragManagerService.onDragOver(l)}),s=i.onDrop$.subscribeEvent(l=>{this._dragManagerService.onDrop(l)});r.add({dispose(){o.unsubscribe(),s.unsubscribe()}})};e(this._sheetSkeletonManagerService.getCurrentParam()),this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(t=>{e(t)}))}},y.DragRenderController=FS([ts(1,R.IRenderManagerService),ts(2,a.Inject(y.DragManagerService)),ts(3,a.Inject(y.SheetSkeletonManagerService))],y.DragRenderController);const ns=(n,r)=>{var h,g,S,f,v;const t=r.findNodePositionByCharIndex(n.startOffset,!0,n.segmentId,-1),i=r.getSkeletonData();let o=n.endOffset;if(n.segmentId){const p=(v=Array.from((g=(h=i==null?void 0:i.skeFooters.get(n.segmentId))==null?void 0:h.values())!=null?g:[])[0])!=null?v:Array.from((f=(S=i==null?void 0:i.skeHeaders.get(n.segmentId))==null?void 0:S.values())!=null?f:[])[0];p&&(o=Math.min(p.ed,o))}const s=r.findNodePositionByCharIndex(o,!0,n.segmentId,-1);if(!s||!t)return;const l={docsLeft:0,docsTop:0,pageMarginLeft:0,pageMarginTop:0},c=new q.NodePositionConvertToCursor(l,r),{borderBoxPointGroup:d}=c.getRangePointData(t,s);return q.getLineBounding(d).map(p=>({top:p.top,bottom:p.bottom,left:p.left,right:p.right}))},zS=(n,r,e=-1)=>{const t=r.findPositionByGlyph(n,e);if(!t)return;const i={...t,isBack:!0},o={docsLeft:0,docsTop:0,pageMarginLeft:0,pageMarginTop:0},s=new q.NodePositionConvertToCursor(o,r),{borderBoxPointGroup:l}=s.getRangePointData(i,i),d=q.getLineBounding(l)[0];return{top:d.top,bottom:d.bottom,left:d.left,right:d.right}},XS=(n,r,e=0,t=0)=>{const i=ns({startOffset:r.startIndex,endOffset:r.endIndex+1},n);if(i)return{rects:i.map(o=>({top:o.top+t,bottom:o.bottom+t,left:o.left+e,right:o.right+e})),range:r}},YS=(n,r,e=0,t=0)=>{var h,g,S;const i=n.findNodeByCharIndex(r.startIndex),o=i==null?void 0:i.parent,s=o==null?void 0:o.parent,l=s==null?void 0:s.parent,c=l==null?void 0:l.lines.find(f=>f.paragraphStart&&f.paragraphIndex===r.startIndex),d=(S=(g=(h=c==null?void 0:c.divides)==null?void 0:h[0])==null?void 0:g.glyphGroup)==null?void 0:S[0];if(!d||!d)return;const u=zS(d,n);if(u)return{rect:{top:u.top+t,bottom:u.bottom+t,left:u.left+e,right:u.right+e},segmentId:void 0,segmentPageIndex:-1,paragraph:r}},yc=(n,r=0,e=0)=>{var l,c,d,u,h,g,S;const t=n.getViewModel().getDataModel(),i=(d=(c=(l=t.getBody())==null?void 0:l.customRanges)==null?void 0:c.filter(f=>f.rangeType===a.CustomRangeType.HYPERLINK))!=null?d:[],o=(g=(h=(u=t.getBody())==null?void 0:u.paragraphs)==null?void 0:h.filter(f=>{var v;return((v=f.bullet)==null?void 0:v.listType.indexOf(a.PresetListType.CHECK_LIST))===0}))!=null?g:[],s=(S=n.getSkeletonData())==null?void 0:S.pages[0].skeDrawings;return{links:i.map(f=>XS(n,f,r,e)).filter(Boolean),checkLists:o.map(f=>YS(n,f,r,e)).filter(Boolean),drawings:s?Array.from(s.keys()).map(f=>({drawingId:f,rect:{top:s.get(f).aTop,bottom:s.get(f).aTop+s.get(f).width,left:s.get(f).aLeft,right:s.get(f).aLeft+s.get(f).height},drawing:s.get(f)})):[]}};function Rc(n,r,e){var d,u,h,g,S,f;const t=(h=(u=(d=r.documentSkeleton)==null?void 0:d.getSkeletonData())==null?void 0:u.pages[0].height)!=null?h:0,i=(f=(S=(g=r.documentSkeleton)==null?void 0:g.getSkeletonData())==null?void 0:S.pages[0].width)!=null?f:0,o=r.verticalAlign,s=r.horizontalAlign;let l=0;switch(o){case a.VerticalAlign.UNSPECIFIED:case a.VerticalAlign.BOTTOM:l=n.mergeInfo.endY-n.mergeInfo.startY-t;break;case a.VerticalAlign.MIDDLE:l=(n.mergeInfo.endY-n.mergeInfo.startY-t)/2;break}let c=0;switch(s){case a.HorizontalAlign.RIGHT:c=n.mergeInfo.endX-n.mergeInfo.startX-i;break;case a.HorizontalAlign.CENTER:c=(n.mergeInfo.endX-n.mergeInfo.startX-i)/2;break;case a.HorizontalAlign.UNSPECIFIED:{e&&(c=n.mergeInfo.endX-n.mergeInfo.startX-i);break}}return{paddingLeft:c,paddingTop:l}}const jS=(n,r,e,t,i,o)=>{var H,x,L;const s=n.get(a.IUniverInstanceService),l=n.get(R.IRenderManagerService),c=s.getUnit(r,a.UniverInstanceType.UNIVER_SHEET);if(!c)return null;const d=c.getSheetBySheetId(e);if(!d)return null;const u=l.getRenderById(c.getUnitId()),h=u==null?void 0:u.with(y.SheetSkeletonManagerService).getSkeletonParam(d.getSheetId()),g=h==null?void 0:h.skeleton;if(!g||!u)return;const S=g.getFont(t,i),f=S==null?void 0:S.documentSkeleton;if(!f)return null;const v=(x=(H=f.getViewModel().getBody())==null?void 0:H.customRanges)==null?void 0:x.find(V=>V.rangeId===o);if(!v)return null;const p=q.DOC_VERTICAL_PADDING,C=g.getCellWithCoordByIndex(t,i);let{actualColumn:b,actualRow:w}=C;g.overflowCache.forValue((V,U,B)=>{B.startRow<=w&&B.endRow>=w&&B.startColumn<=b&&B.endColumn>=b&&(b=U,w=V)});const E=g.getCellWithCoordByIndex(w,b),O=d.getCell(E.actualRow,E.actualColumn),{topOffset:M=0,leftOffset:P=0}=(L=O==null?void 0:O.fontRenderExtension)!=null?L:{},{paddingLeft:A,paddingTop:k}=Rc(E,S,!1),N=ns({startOffset:v.startIndex,endOffset:v.endIndex},f);return{rects:N==null?void 0:N.map(V=>({top:V.top+E.mergeInfo.startY+k+M+p,bottom:V.bottom+E.mergeInfo.startY+k+M+p,left:V.left+E.mergeInfo.startX+A+P,right:V.right+E.mergeInfo.startX+A+P})),customRange:v,label:f.getViewModel().getBody().dataStream.slice(v.startIndex,v.endIndex+1)}},GS=(n,r,e,t,i,o)=>{var P,A,k;const s=n.get(me),l=s.getEditCellState();if(!l||!s.isVisible().visible)return null;const{editorUnitId:d,unitId:u,sheetId:h,row:g,column:S}=l;if(r!==u||e!==h||g!==t||S!==i)return null;const f=n.get(R.IRenderManagerService),v=f.getRenderById(d),p=f.getRenderById(r);if(!v||!p)return null;const C=v.with(_e.DocSkeletonManagerService).getSkeleton(),b=(P=p.with(y.SheetSkeletonManagerService).getSkeletonParam(h))==null?void 0:P.skeleton;if(!C||!b)return null;const w=(k=(A=C.getViewModel().getBody())==null?void 0:A.customRanges)==null?void 0:k.find(N=>N.rangeId===o);if(!w)return null;const E=4,O=ns({startOffset:w.startIndex,endOffset:w.endIndex},C),M=v.engine.getCanvasElement().getBoundingClientRect();return{rects:O==null?void 0:O.map(N=>({top:N.top+M.top-E,bottom:N.bottom+M.top+E,left:N.left+M.left,right:N.right+M.left})),customRange:w,label:C.getViewModel().getBody().dataStream.slice(w.startIndex,w.endIndex+1)}};var ZS=Object.getOwnPropertyDescriptor,KS=(n,r,e,t)=>{for(var i=t>1?void 0:t?ZS(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Mc=(n,r)=>(e,t)=>r(e,t,n);function zt(n){const{workbook:r,worksheet:e,...t}=n;return t}y.HoverManagerService=class extends a.Disposable{constructor(e,t){super();T(this,"_currentCell$",new D.BehaviorSubject(null));T(this,"_currentRichText$",new D.BehaviorSubject(null));T(this,"_currentClickedCell$",new D.Subject);T(this,"_currentDbClickedCell$",new D.Subject);T(this,"_currentCellWithEvent$",new D.Subject);T(this,"_currentPointerDownCell$",new D.Subject);T(this,"_currentPointerUpCell$",new D.Subject);T(this,"_currentHoveredRowHeader$",new D.BehaviorSubject(null));T(this,"_currentHoveredColHeader$",new D.BehaviorSubject(null));T(this,"_currentRowHeaderClick$",new D.Subject);T(this,"_currentColHeaderClick$",new D.Subject);T(this,"_currentRowHeaderDbClick$",new D.Subject);T(this,"_currentColHeaderDbClick$",new D.Subject);T(this,"_currentRowHeaderPointerDown$",new D.Subject);T(this,"_currentColHeaderPointerDown$",new D.Subject);T(this,"_currentRowHeaderPointerUp$",new D.Subject);T(this,"_currentColHeaderPointerUp$",new D.Subject);T(this,"currentCell$",this._currentCell$.asObservable().pipe(D.distinctUntilChanged((e,t)=>{var i,o,s,l,c,d,u,h;return((i=e==null?void 0:e.location)==null?void 0:i.unitId)===((o=t==null?void 0:t.location)==null?void 0:o.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((l=t==null?void 0:t.location)==null?void 0:l.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((d=t==null?void 0:t.location)==null?void 0:d.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=t==null?void 0:t.location)==null?void 0:h.col)})));T(this,"currentRichTextNoDistinct$",this._currentRichText$.pipe(D.map(e=>e&&{unitId:e.location.unitId,subUnitId:e.location.subUnitId,row:e.location.row,col:e.location.col,customRange:e.customRange,bullet:e.bullet,rect:e.rect,drawing:e.drawing})));T(this,"currentRichText$",this._currentRichText$.pipe(D.distinctUntilChanged((e,t)=>{var i,o,s,l,c,d,u,h,g,S,f,v,p,C,b,w,E,O;return((i=e==null?void 0:e.location)==null?void 0:i.unitId)===((o=t==null?void 0:t.location)==null?void 0:o.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((l=t==null?void 0:t.location)==null?void 0:l.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((d=t==null?void 0:t.location)==null?void 0:d.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=t==null?void 0:t.location)==null?void 0:h.col)&&((g=e==null?void 0:e.customRange)==null?void 0:g.rangeId)===((S=t==null?void 0:t.customRange)==null?void 0:S.rangeId)&&((f=e==null?void 0:e.bullet)==null?void 0:f.startIndex)===((v=t==null?void 0:t.bullet)==null?void 0:v.startIndex)&&((p=e==null?void 0:e.customRange)==null?void 0:p.startIndex)===((C=t==null?void 0:t.customRange)==null?void 0:C.startIndex)&&((b=e==null?void 0:e.customRange)==null?void 0:b.endIndex)===((w=t==null?void 0:t.customRange)==null?void 0:w.endIndex)&&((E=e==null?void 0:e.drawing)==null?void 0:E.drawingId)===((O=t==null?void 0:t.drawing)==null?void 0:O.drawingId)}),D.map(e=>e&&{unitId:e.location.unitId,subUnitId:e.location.subUnitId,row:e.location.row,col:e.location.col,customRange:e.customRange,bullet:e.bullet,rect:e.rect,drawing:e.drawing})));T(this,"currentCellPosWithEvent$",this._currentCellWithEvent$.pipe(D.distinctUntilChanged((e,t)=>{var i,o,s,l,c,d,u,h;return((i=e==null?void 0:e.location)==null?void 0:i.unitId)===((o=t==null?void 0:t.location)==null?void 0:o.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((l=t==null?void 0:t.location)==null?void 0:l.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((d=t==null?void 0:t.location)==null?void 0:d.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=t==null?void 0:t.location)==null?void 0:h.col)}),D.map(e=>e&&{unitId:e.location.unitId,subUnitId:e.location.subUnitId,row:e.location.row,col:e.location.col,event:e.event})));T(this,"currentPosition$",this._currentCell$.asObservable());T(this,"currentClickedCell$",this._currentClickedCell$.asObservable());T(this,"currentDbClickedCell$",this._currentDbClickedCell$.asObservable());T(this,"currentPointerDownCell$",this._currentPointerDownCell$.asObservable());T(this,"currentPointerUpCell$",this._currentPointerUpCell$.asObservable());T(this,"currentHoveredRowHeader$",this._currentHoveredRowHeader$.asObservable());T(this,"currentHoveredColHeader$",this._currentHoveredColHeader$.asObservable());T(this,"currentRowHeaderClick$",this._currentRowHeaderClick$.asObservable());T(this,"currentColHeaderClick$",this._currentColHeaderClick$.asObservable());T(this,"currentRowHeaderDbClick$",this._currentRowHeaderDbClick$.asObservable());T(this,"currentColHeaderDbClick$",this._currentColHeaderDbClick$.asObservable());T(this,"currentRowHeaderPointerDown$",this._currentRowHeaderPointerDown$.asObservable());T(this,"currentColHeaderPointerDown$",this._currentColHeaderPointerDown$.asObservable());T(this,"currentRowHeaderPointerUp$",this._currentRowHeaderPointerUp$.asObservable());T(this,"currentColHeaderPointerUp$",this._currentColHeaderPointerUp$.asObservable());this._univerInstanceService=e,this._renderManagerService=t,this._initCellDisposableListener()}dispose(){super.dispose(),this._currentCell$.complete(),this._currentClickedCell$.complete(),this._currentPointerDownCell$.complete(),this._currentPointerUpCell$.complete(),this._currentCellWithEvent$.complete()}_initCellDisposableListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e||this._currentCell$.next(null)})),this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(e=>{var t,i;((t=this._currentCell$.getValue())==null?void 0:t.location.unitId)===e.getUnitId()&&this._currentCell$.next(null),((i=this._currentRichText$.getValue())==null?void 0:i.location.unitId)===e.getUnitId()&&this._currentRichText$.next(null)}))}_getCalcDeps(e){const t=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET);if(!t)return null;const i=t.getActiveSheet();if(!i)return null;const o=this._renderManagerService.getRenderById(t.getUnitId());if(!o)return null;const s=o.with(y.SheetSkeletonManagerService).getSkeletonParam(i.getSheetId());if(!s)return null;const l=o.with(y.SheetScrollManagerService);if(!(!(l!=null&&l.getCurrentScrollState())||!o))return{currentRender:o,workbook:t,worksheet:i,skeletonParam:s}}_calcActiveCell(e,t,i,o,s,l){var M,P,A;const c=vl(e,t,i,o,s,l),d=o.skeleton;if(!c)return null;const{position:u,overflowLocation:h,location:g}=c,S=d.getFont(h.row,h.col);let f=null,v=null,p=null;const C=d.getCellWithCoordByIndex(h.row,h.col),b=i.getCell(h.row,h.col),{topOffset:w=0,leftOffset:E=0}=(M=b==null?void 0:b.fontRenderExtension)!=null?M:{};if(S!=null&&S.documentSkeleton){const{paddingLeft:k,paddingTop:N}=Rc(C,S,(b==null?void 0:b.v)!==null&&(b==null?void 0:b.v)!==void 0?!Number.isNaN(+b.v):!1),H=yc(S.documentSkeleton,k,N),x=s-u.startX-E,L=l-u.startY-w;f=H.links.find(V=>V.rects.some(U=>U.left<=x&&x<=U.right&&U.top<=L&&L<=U.bottom)),v=H.checkLists.find(V=>V.rect.left<=x&&x<=V.rect.right&&V.rect.top<=L&&L<=V.rect.bottom),p=H.drawings.find(V=>V.rect.left<=x&&x<=V.rect.right&&V.rect.top<=L&&L<=V.rect.bottom)}const O=(A=(P=f==null?void 0:f.rects.pop())!=null?P:v==null?void 0:v.rect)!=null?A:p==null?void 0:p.rect;return{location:g,position:u,overflowLocation:h,customRange:f==null?void 0:f.range,bullet:v==null?void 0:v.paragraph,drawing:p,rect:O&&{top:O.top+C.mergeInfo.startY+w,bottom:O.bottom+C.mergeInfo.startY+w,left:O.left+C.mergeInfo.startX+E,right:O.right+C.mergeInfo.startX+E}}}_calcActiveRowHeader(e,t,i){const o=this._getCalcDeps(e);if(!o)return;const{currentRender:s,worksheet:l,skeletonParam:c}=o,{scaleY:d}=s.scene.getAncestorScale(),u=s.scene.getViewports().find(S=>S.isHit(new R.Vector2(t,i)));if(!u||u.viewportKey!==R.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP&&u.viewportKey!==R.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM)return;const h={x:u.viewportScrollX,y:u.viewportScrollY},g=c.skeleton.getRowIndexByOffsetY(i,d,h);return{unitId:e,index:g,subUnitId:l.getSheetId()}}_calcActiveColHeader(e,t,i){const o=this._getCalcDeps(e);if(!o)return;const{currentRender:s,worksheet:l,skeletonParam:c}=o,{scaleX:d}=s.scene.getAncestorScale(),u=s.scene.getViewports().find(S=>S.isHit(new R.Vector2(t,i)));if(!u||u.viewportKey!==R.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT&&u.viewportKey!==R.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT)return;const h={x:u.viewportScrollX,y:u.viewportScrollY},g=c.skeleton.getColumnIndexByOffsetX(t,d,h);return{unitId:e,index:g,subUnitId:l.getSheetId()}}triggerPointerDown(e,t){const i=this._getCalcDeps(e);if(!i)return;const{currentRender:o,workbook:s,worksheet:l,skeletonParam:c}=i,d=this._calcActiveCell(o,s,l,c,t.offsetX,t.offsetY);if(d&&d.location){const{unitId:u,subUnitId:h,row:g,col:S}=zt(d.location);this._currentPointerDownCell$.next({unitId:u,subUnitId:h,row:g,col:S,event:t})}}triggerPointerUp(e,t){const i=this._getCalcDeps(e);if(!i)return;const{currentRender:o,workbook:s,worksheet:l,skeletonParam:c}=i,d=this._calcActiveCell(o,s,l,c,t.offsetX,t.offsetY);if(d){const u=zt(d.location);this._currentPointerUpCell$.next({...u,event:t})}}triggerMouseMove(e,t){const i=this._getCalcDeps(e);if(!i)return;const{currentRender:o,workbook:s,worksheet:l,skeletonParam:c}=i,d=this._calcActiveCell(o,s,l,c,t.offsetX,t.offsetY);this._currentCell$.next(d&&{location:zt(d.location),position:d.position}),this._currentRichText$.next(d&&{...d,location:zt(d.overflowLocation)}),this._currentCellWithEvent$.next(d&&{...d,location:zt(d.location),event:t})}triggerClick(e,t,i){const o=this._getCalcDeps(e);if(!o)return;const{currentRender:s,workbook:l,worksheet:c,skeletonParam:d}=o,u=this._calcActiveCell(s,l,c,d,t,i);u&&this._currentClickedCell$.next({...u,location:zt(u.location)})}triggerDbClick(e,t,i){const o=this._getCalcDeps(e);if(!o)return;const{currentRender:s,workbook:l,worksheet:c,skeletonParam:d}=o,u=this._calcActiveCell(s,l,c,d,t,i);u&&this._currentDbClickedCell$.next({...u,location:zt(u.location)})}triggerScroll(){this._currentCell$.next(null)}triggerRowHeaderClick(e,t,i){const o=this._calcActiveRowHeader(e,t,i);o&&this._currentRowHeaderClick$.next(o)}triggerColHeaderClick(e,t,i){const o=this._calcActiveColHeader(e,t,i);o&&this._currentColHeaderClick$.next(o)}triggerRowHeaderDbClick(e,t,i){const o=this._calcActiveRowHeader(e,t,i);o&&this._currentRowHeaderDbClick$.next(o)}triggerColHeaderDbClick(e,t,i){const o=this._calcActiveColHeader(e,t,i);o&&this._currentColHeaderDbClick$.next(o)}triggerRowHeaderMouseMove(e,t,i){this._currentHoveredRowHeader$.next(this._calcActiveRowHeader(e,t,i))}triggerColHeaderMouseMove(e,t,i){this._currentHoveredColHeader$.next(this._calcActiveColHeader(e,t,i))}triggerRowHeaderPoniterDown(e,t,i){const o=this._calcActiveRowHeader(e,t,i);o&&this._currentRowHeaderPointerDown$.next(o)}triggerColHeaderPoniterDown(e,t,i){const o=this._calcActiveColHeader(e,t,i);o&&this._currentColHeaderPointerDown$.next(o)}triggerRowHeaderPoniterUp(e,t,i){const o=this._calcActiveRowHeader(e,t,i);o&&this._currentRowHeaderPointerUp$.next(o)}triggerColHeaderPoniterUp(e,t,i){const o=this._calcActiveColHeader(e,t,i);o&&this._currentColHeaderPointerUp$.next(o)}},y.HoverManagerService=KS([Mc(0,a.IUniverInstanceService),Mc(1,R.IRenderManagerService)],y.HoverManagerService);var qS=Object.getOwnPropertyDescriptor,QS=(n,r,e,t)=>{for(var i=t>1?void 0:t?qS(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Ii=(n,r)=>(e,t)=>r(e,t,n);const is="SHEET_FORCE_STRING_ALERT";let hr=class extends a.Disposable{constructor(n,r,e,t,i,o){super(),this._context=n,this._hoverManagerService=r,this._cellAlertManagerService=e,this._localeService=t,this._zenZoneService=i,this._configService=o,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.subscribe(n=>{var r,e;if(n){const i=this._context.unit.getActiveSheet();if(!i)return;const o=i.getCell(n.location.row,n.location.col);if((o==null?void 0:o.t)===a.CellValueType.FORCE_STRING&&o.v&&a.isRealNum(o.v)){const s=this._cellAlertManagerService.currentAlert.get(is),l=(r=s==null?void 0:s.alert)==null?void 0:r.location;if(l&&l.row===n.location.row&&l.col===n.location.col&&l.subUnitId===n.location.subUnitId&&l.unitId===n.location.unitId||(e=this._configService.getConfig(He))!=null&&e.disableForceStringAlert)return;this._cellAlertManagerService.showAlert({type:yn.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:n.location,width:200,height:74,key:is});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(is)}};hr=QS([Ii(1,a.Inject(y.HoverManagerService)),Ii(2,a.Inject(y.CellAlertManagerService)),Ii(3,a.Inject(a.LocaleService)),Ii(4,_.IZenZoneService),Ii(5,a.IConfigService)],hr);var JS=Object.getOwnPropertyDescriptor,$S=(n,r,e,t)=>{for(var i=t>1?void 0:t?JS(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},rs=(n,r)=>(e,t)=>r(e,t,n);let mr=class extends a.RxDisposable{constructor(n,r,e,t){super(),this._context=n,this._sheetSkeletonManagerService=r,this._sheetInterceptorService=e,this._configService=t,this._initViewModelIntercept()}_initViewModelIntercept(){const n={tl:{size:6,color:"#409f11"}};this.disposeWithMe(this._sheetInterceptorService.intercept(m.INTERCEPTOR_POINT.CELL_CONTENT,{priority:10,effect:a.InterceptorEffectEnum.Style,handler:(r,e,t)=>{var s,l,c;if(!((s=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:s.skeleton))return t(r);const o=e.rawData;if(!o||o.v===null||o.v===void 0)return t(r);if(((r==null?void 0:r.t)===a.CellValueType.FORCE_STRING||(r==null?void 0:r.t)===a.CellValueType.STRING)&&a.isRealNum(o.v)){const d=e.workbook.getStyles().get(o.s);return Oi.isTextFormat((l=d==null?void 0:d.n)==null?void 0:l.pattern)||(c=this._configService.getConfig(He))!=null&&c.disableForceStringMark||(r===o&&(r={...o}),r.markers={...r==null?void 0:r.markers,...n}),t(r)}return t(r)}}))}};mr=$S([rs(1,a.Inject(y.SheetSkeletonManagerService)),rs(2,a.Inject(m.SheetInterceptorService)),rs(3,a.IConfigService)],mr);var ef=Object.getOwnPropertyDescriptor,tf=(n,r,e,t)=>{for(var i=t>1?void 0:t?ef(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},os=(n,r)=>(e,t)=>r(e,t,n);y.HoverRenderController=class extends a.Disposable{constructor(e,t,i,o){super();T(this,"_active",!1);this._context=e,this._hoverManagerService=t,this._sheetSkeletonManagerService=i,this._scrollManagerService=o,this._initPointerEvent(),this._initScrollEvent()}get active(){return this._active}_initPointerEvent(){const e=new a.DisposableCollection,t=i=>{if(e.dispose(),!i)return;const{mainComponent:o,unitId:s,components:l}=this._context;if(!o)return;e.add(o.onPointerEnter$.subscribeEvent(u=>{this._active=!0})),e.add(a.fromEventSubject(o.onPointerMove$).subscribe(u=>{this._active=!0,this._hoverManagerService.triggerMouseMove(s,u)})),e.add(o.onPointerDown$.subscribeEvent(u=>{this._hoverManagerService.triggerPointerDown(s,u)})),e.add(o.onPointerUp$.subscribeEvent(u=>{this._hoverManagerService.triggerPointerUp(s,u)})),e.add(o.onClick$.subscribeEvent(u=>{this._hoverManagerService.triggerClick(s,u.offsetX,u.offsetY)})),e.add(o.onDblclick$.subscribeEvent(u=>{this._hoverManagerService.triggerDbClick(s,u.offsetX,u.offsetY)})),e.add(o.onPointerLeave$.subscribeEvent(()=>{this._active=!1}));const c=l.get(he.ROW),d=l.get(he.COLUMN);c&&(e.add(c.onPointerMove$.subscribeEvent(u=>{this._hoverManagerService.triggerRowHeaderMouseMove(s,u.offsetX,u.offsetY)})),e.add(c.onPointerDown$.subscribeEvent(u=>{this._hoverManagerService.triggerRowHeaderPoniterDown(s,u.offsetX,u.offsetY)})),e.add(c.onPointerUp$.subscribeEvent(u=>{this._hoverManagerService.triggerRowHeaderPoniterUp(s,u.offsetX,u.offsetY),this._hoverManagerService.triggerRowHeaderClick(s,u.offsetX,u.offsetY)})),e.add(c.onDblclick$.subscribeEvent(u=>{this._hoverManagerService.triggerRowHeaderDbClick(s,u.offsetX,u.offsetY)}))),d&&(e.add(d.onPointerMove$.subscribeEvent(u=>{this._hoverManagerService.triggerColHeaderMouseMove(s,u.offsetX,u.offsetY)})),e.add(d.onPointerDown$.subscribeEvent(u=>{this._hoverManagerService.triggerColHeaderPoniterDown(s,u.offsetX,u.offsetY)})),e.add(d.onPointerUp$.subscribeEvent(u=>{this._hoverManagerService.triggerColHeaderPoniterUp(s,u.offsetX,u.offsetY),this._hoverManagerService.triggerColHeaderClick(s,u.offsetX,u.offsetY)})),e.add(d.onDblclick$.subscribeEvent(u=>{this._hoverManagerService.triggerColHeaderDbClick(s,u.offsetX,u.offsetY)})))};t(this._sheetSkeletonManagerService.getCurrentParam()),this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{t(i)}))}_initScrollEvent(){this.disposeWithMe(this._scrollManagerService.validViewportScrollInfo$.subscribe(()=>this._hoverManagerService.triggerScroll()))}},y.HoverRenderController=tf([os(1,a.Inject(y.HoverManagerService)),os(2,a.Inject(y.SheetSkeletonManagerService)),os(3,a.Inject(y.SheetScrollManagerService))],y.HoverRenderController);var nf=Object.getOwnPropertyDescriptor,rf=(n,r,e,t)=>{for(var i=t>1?void 0:t?nf(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},ss=(n,r)=>(e,t)=>r(e,t,n);let gr=class extends a.Disposable{constructor(n,r,e,t){super(),this._context=n,this._markSelectionService=r,this._commandService=e,this._sheetSkeletonManagerService=t,this._initListeners()}_initListeners(){this._addRemoveListener(),this._addRefreshListener()}_addRemoveListener(){const n=[ge.id];this.disposeWithMe(this._commandService.onCommandExecuted(r=>{n.includes(r.id)?this._markSelectionService.removeAllShapes():this._markSelectionService.getShapeMap().forEach((t,i)=>{t.exits.includes(r.id)&&this._markSelectionService.removeShape(i)})}))}_addRefreshListener(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(n=>{n&&this._markSelectionService.refreshShapes()}))}};gr=rf([ss(1,a.Inject(Mt)),ss(2,a.ICommandService),ss(3,a.Inject(y.SheetSkeletonManagerService))],gr);function Pc(){const n=lt();return n?I.jsx(of,{workbook:n}):null}function of(n){const{workbook:r}=n,[e,t]=W.useState([]),[i,o]=W.useState(""),s=W.useRef(new Map),l=_.useDependency(a.ICommandService),c=W.useCallback(()=>{const u=r.getActiveSheet().getSheetId(),h=r.getSheets(),g=r.getActiveSheet(),S=h.filter(f=>!f.isSheetHidden()).map((f,v)=>{var p;return{sheetId:f.getSheetId(),label:f.getName(),index:v,selected:g===f,color:(p=f.getTabColor())!=null?p:void 0}});if(t(S),o(u),s.current.has(u)){const f=s.current.get(u);f&&f.scrollIntoView({behavior:"smooth",block:"nearest"})}s.current.clear()},[r]);W.useEffect(()=>c(),[c]);const d=W.useCallback(u=>{l.executeCommand(m.SetWorksheetActiveOperation.id,{unitId:r.getUnitId(),subUnitId:u})},[l,r]);return W.useEffect(()=>{const u=l.onCommandExecuted(h=>{switch(h.id){case m.SetWorksheetHideMutation.id:case m.RemoveSheetMutation.id:case m.SetWorksheetNameMutation.id:case m.InsertSheetMutation.id:case m.SetWorksheetOrderMutation.id:case m.SetWorksheetActiveOperation.id:c();break}});return()=>u.dispose()},[l,c]),I.jsx("div",{className:"univer-h-8 univer-w-full univer-overflow-x-scroll univer-bg-gray-100 dark:!univer-bg-gray-900",children:I.jsx("div",{className:"univer-flex univer-h-8 univer-flex-nowrap univer-items-center",children:e.map(u=>I.jsx("div",{ref:h=>{s.current.set(u.sheetId,h)},className:X.clsx(`
|
|
23
|
+
`)}]}}var VS=Object.getOwnPropertyDescriptor,WS=(n,r,e,t)=>{for(var i=t>1?void 0:t?VS(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},qe=(n,r)=>(e,t)=>r(e,t,n);const xS=[m.InsertColMutation.id,m.InsertRowMutation.id,m.RemoveColMutation.id,m.RemoveRowMutation.id,m.MoveRangeMutation.id,m.MoveRowsMutation.id,m.MoveColsMutation.id];let Rn=class extends a.RxDisposable{constructor(r,e,t,i,o,s,l,c,d,u){super();T(this,"_refreshOptionalPaste$",new D.Subject);T(this,"refreshOptionalPaste$",this._refreshOptionalPaste$.asObservable());this._injector=r,this._instanceService=e,this._renderManagerService=t,this._commandService=i,this._contextService=o,this._configService=s,this._sheetClipboardService=l,this._messageService=c,this._localService=d,this._uiPartsService=u,this._init(),this._initCommandListener(),this._initUIComponents(),this._pasteWithDoc()}refreshOptionalPaste(){this._refreshOptionalPaste$.next(Math.random())}_pasteWithDoc(){var t;const r=i=>{i.onPaste$.pipe(D.takeUntil(this.dispose$)).subscribe(o=>{var u,h;if(!le(this._contextService))return;o.event.preventDefault();const s=o.event,l=(u=s.clipboardData)==null?void 0:u.getData("text/html"),c=(h=s.clipboardData)==null?void 0:h.getData("text/plain"),d=this._resolveClipboardFiles(s.clipboardData);this._commandService.executeCommand($i.id,{htmlContent:l,textContent:c,files:d})})};let e=(t=this._renderManagerService.getRenderById(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY))==null?void 0:t.with(q.DocSelectionRenderService);e&&r(e),this._renderManagerService.created$.subscribe(i=>{var o;i.unitId===a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&(e=(o=this._renderManagerService.getRenderById(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY))==null?void 0:o.with(q.DocSelectionRenderService),e&&r(e))})}_resolveClipboardFiles(r){if(!r)return;const e=Array.from(r.items).map(t=>t.kind==="file"?t.getAsFile():void 0).filter(Boolean);return e.length>0?e:void 0}_init(){[Be,Ji,Fe].forEach(e=>this.disposeWithMe(this._commandService.registerMultipleCommand(e))),[un,hn,Pt,mn,$i,Ga].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e))),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initCopyingHooks())),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingHook()));const r=this._initSpecialPasteHooks().map(e=>this._sheetClipboardService.addClipboardHook(e));this.disposeWithMe({dispose:()=>r.forEach(e=>e.dispose())})}_initCopyingHooks(){const r=this;let e=null;return{id:Se.DEFAULT_COPY,isDefaultHook:!0,onBeforeCopy(t,i){e=r._getWorksheet(t,i)},onCopyCellContent(t,i){var l,c,d,u;const o=e.getCell(t,i);return(c=(l=o==null?void 0:o.p)==null?void 0:l.body)!=null&&c.paragraphs||(u=(d=o==null?void 0:o.p)==null?void 0:d.body)!=null&&u.textRuns?q.convertBodyToHtml(o.p):o?a.extractPureTextFromCell(o):""},onCopyCellStyle:(t,i,o,s)=>{const l={};(o||s)&&(l.rowspan=`${o||1}`,l.colspan=`${s||1}`);const c=e.getMergedCell(t,i),d=e.getComposedCellStyle(t,i);let u="";if(d&&(u=a.handleStyleToString(d)),c){const h=c.endRow,g=c.endColumn,f=e.getRange(h,g).getTextStyle();if(f){const v=a.handleStyleToString(f);u?u+=v?`;${v}`:"":u=v}}return u&&(l.style=u),Object.keys(l).length?l:null},onCopyColumn(t){return{width:`${e.getColumnWidth(t)}`}},onCopyRow(t){return{style:`height: ${e.getRowHeight(t)}px;`}},onAfterCopy(){e=null},getFilteredOutRows(t){var c;const{startRow:i,endRow:o}=t,s=(c=r._instanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:c.getActiveSheet(),l=[];if(!s)return l;for(let d=i;d<=o;d++)s.getRowFiltered(d)&&l.push(d);return l}}}_initPastingHook(){const r=this;let e=null,t=null,i=null;return{id:Se.DEFAULT_PASTE,isDefaultHook:!0,onBeforePaste({unitId:o,subUnitId:s,range:l}){i=r._getWorksheet(o,s),e=o,t=s;const c=r._configService.getConfig(m.MAX_CELL_PER_SHEET_KEY),d=l.rows[l.rows.length-1],u=l.cols[l.cols.length-1];return c&&d*u>c?(r._messageService.show({type:X.MessageType.Error,content:r._localService.t("clipboard.paste.exceedMaxCells")}),!1):!0},onPasteRows(o,s){const{range:l}=o,c=[],d=[],u=i.getMaxRows(),h=u-1,g=l.rows[l.rows.length-1]-h,S=s.length-g,f=i.getRowManager();if(g>0){const C={};s.slice(S).forEach((E,O)=>{const{height:M}=E||{};M&&(C[O]={h:Number.parseFloat(M),hd:a.BooleanNumber.FALSE})});const b={startColumn:l.cols[0],endColumn:l.cols[l.cols.length-1],endRow:l.rows[l.rows.length-1],startRow:u},w={unitId:e,subUnitId:t,range:b,rowInfo:C};c.push({id:m.InsertRowMutation.id,params:w}),d.push({id:m.RemoveRowMutation.id,params:{unitId:e,subUnitId:t,range:b}})}const v={},p={};if(s.slice(0,S).forEach((C,b)=>{var E,O;const{height:w}=C;if(w){const M=f.getRow(l.rows[0]+b),P=Number.parseFloat(w);if(M){const{h:A=a.DEFAULT_WORKSHEET_ROW_HEIGHT,ah:k=0}=M,N=Math.max(A,k);P>N?(v[b+l.rows[0]]=P,p[b+l.rows[0]]=N):(v[b+l.rows[0]]=N,p[b+l.rows[0]]=N)}else v[b+l.rows[0]]=P,p[b+l.rows[0]]=(O=(E=f.getRow(l.rows[0]+b))==null?void 0:E.h)!=null?O:a.DEFAULT_WORKSHEET_ROW_HEIGHT}}),Object.keys(v).length){const C={unitId:e,subUnitId:t,ranges:[{startRow:l.rows[0],endRow:Math.min(l.rows[l.rows.length-1],u),startColumn:l.cols[0],endColumn:l.cols[l.cols.length-1]}],rowHeight:v};c.push({id:m.SetWorksheetRowHeightMutation.id,params:C}),d.push({id:m.SetWorksheetRowHeightMutation.id,params:{...C,rowHeight:p}})}return{redos:c,undos:d}},onPasteColumns(o,s,l){var w;const{range:c}=o,d=[],u=[],h=i.getMaxColumns(),g=h-1,S=c.cols[c.cols.length-1]-g,f=s.length-S,v=(w=r._configService.getConfig(a.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?w:a.DEFAULT_WORKSHEET_COLUMN_WIDTH,p=c.cols,C=p[0];if(S>0){const E={startRow:c.rows[0],endRow:c.rows[c.rows.length-1],endColumn:c.cols[c.cols.length-1],startColumn:h},O={unitId:e,subUnitId:t,range:E,colInfo:s.slice(f).map((M,P)=>({w:M.width?Math.max(+M.width,i.getColumnWidth(p[P])):v,hd:a.BooleanNumber.FALSE}))};d.push({id:m.InsertColMutation.id,params:O}),u.push({id:m.RemoveColMutation.id,params:{unitId:e,subUnitId:t,range:E}})}const b={unitId:e,subUnitId:t,ranges:[{startRow:c.rows[0],endRow:c.rows[c.rows.length-1],startColumn:c.cols[0],endColumn:Math.min(c.cols[c.cols.length-1],h)}]};if(s.length>0){const E={...b,colWidth:s.slice(0,f).reduce((M,P,A)=>{var k;return M[A+C]=P.width?Math.max(+P.width,(k=i.getColumnWidth(p[A]))!=null?k:v):v,M},{})},O={...b,colWidth:s.slice(0,f).reduce((M,P,A)=>{var k;return M[A+C]=(k=i.getColumnWidth(p[A]))!=null?k:v,M},{})};d.push({id:m.SetWorksheetColWidthMutation.id,params:E}),u.push({id:m.SetWorksheetColWidthMutation.id,params:O})}return{redos:d,undos:u}},onPastePlainText(o,s,l){return r._onPastePlainText(o,s,l)},onPasteCells(o,s,l,c){return r._onPasteCells(o,s,l,c)},onAfterPaste(o){i=null}}}_generateDocumentDataModelSnapshot(r){var l,c;const e=(l=R.withCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,y.SheetSkeletonManagerService,this._instanceService,this._renderManagerService))==null?void 0:l.getCurrentParam();if(e==null)return null;const{skeleton:t}=e,i=(c=t.getBlankCellDocumentModel())==null?void 0:c.documentModel,s={...i==null?void 0:i.getSnapshot(),...r};return i==null||i.reset(s),i==null?void 0:i.getSnapshot()}_onPastePlainText(r,e,t){const{range:i,unitId:o,subUnitId:s}=r;let l;if(/\r|\n/.test(e)||a.Tools.isLegalUrl(e)){const d=HS(e),u=this._generateDocumentDataModelSnapshot({body:d});l={[i.rows[0]]:{[i.cols[0]]:{p:u,v:null,f:null}}}}else if(a.isFormulaString(e))l={[i.rows[0]]:{[i.cols[0]]:{f:e,v:null,p:null}}};else{const d=a.numfmt.parseNumber(e);d!=null&&d.z?l={[i.rows[0]]:{[i.cols[0]]:{v:d.v,s:{n:{pattern:d.z}},f:null}}}:l={[i.rows[0]]:{[i.cols[0]]:{v:e,f:null}}}}const c={unitId:o,subUnitId:s,cellValue:l};return{redos:[{id:m.SetRangeValuesMutation.id,params:c}],undos:[{id:m.SetRangeValuesMutation.id,params:m.SetRangeValuesUndoMutationFactory(this._injector,c)}]}}_onPasteCells(r,e,t,i){return this._injector.invoke(o=>DS(r,e,t,i,o))}_initSpecialPasteHooks(){const r=this,e={id:Se.SPECIAL_PASTE_VALUE,specialPasteInfo:{label:"specialPaste.value"},onPasteCells:(s,l,c)=>this._injector.invoke(d=>bc(l,s,c,d))},t={id:Se.SPECIAL_PASTE_FORMAT,specialPasteInfo:{label:"specialPaste.format"},onPasteCells:(s,l,c)=>{const d=[],u=[],{undos:h,redos:g}=this._injector.invoke(C=>Ec(l,c,C));d.push(...g),u.push(...h);const{undos:S,redos:f}=this._injector.invoke(C=>es(l,c,C));d.push(...f),u.push(...S);const{undos:v,redos:p}=this._injector.invoke(C=>wc(l,s,c,C));return d.push(...p),u.push(...v),{undos:u,redos:d}}},i={id:Se.SPECIAL_PASTE_COL_WIDTH,specialPasteInfo:{label:"specialPaste.colWidth"},onPasteCells(){return{undos:[],redos:[]}},onPasteColumns(s,l,c){var A,k;const d=r._instanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),u=d.getUnitId(),h=(A=d.getActiveSheet())==null?void 0:A.getSheetId();if(!u||!h)throw new Error("Cannot find unitId or subUnitId");const g=[],S=[],f=r._getWorksheet(u,h),{range:v}=s,p=v.cols,C=p[0],b=f.getMaxColumns(),w=v.cols[v.cols.length-1]-b,E=l.length-w,O=(k=r._configService.getConfig(a.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?k:a.DEFAULT_WORKSHEET_COLUMN_WIDTH,M={unitId:u,subUnitId:h,ranges:[{startRow:v.rows[0],endRow:Math.min(v.cols[v.cols.length-1],b),startColumn:v.cols[0],endColumn:v.cols[v.cols.length-1]}],colWidth:l.slice(0,E).reduce((N,H,x)=>{var L;return N[x+C]=H.width?Math.max(+H.width,(L=f.getColumnWidth(p[x]))!=null?L:O):O,N},{})},P={unitId:u,subUnitId:h,ranges:[{startRow:v.rows[0],endRow:Math.min(v.cols[v.cols.length-1],b),startColumn:v.cols[0],endColumn:v.cols[v.cols.length-1]}],colWidth:l.slice(0,E).reduce((N,H,x)=>{var L;return N[x+C]=(L=f.getColumnWidth(p[x]))!=null?L:O,N},{})};return g.push({id:m.SetWorksheetColWidthMutation.id,params:M}),S.push({id:m.SetWorksheetColWidthMutation.id,params:P}),{redos:g,undos:S}}},o={id:Se.SPECIAL_PASTE_BESIDES_BORDER,specialPasteInfo:{label:"specialPaste.besidesBorder"},onPasteCells:(s,l,c,d)=>{r._instanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);const u=[],h=[],{range:g,unitId:S,subUnitId:f}=l,v=new a.ObjectMatrix;c.forValue((E,O,M)=>{const P=M.s;if(typeof P=="object"){const A=a.Tools.deepClone(M);A.s&&(A.s={...P,bd:null}),v.setValue(g.rows[E],g.cols[O],A)}});const p={unitId:S,subUnitId:f,cellValue:v.getData()};u.push({id:m.SetRangeValuesMutation.id,params:p});const C=this._injector.invoke(m.SetRangeValuesUndoMutationFactory,p);h.push({id:m.SetRangeValuesMutation.id,params:C});const{undos:b,redos:w}=this._injector.invoke(E=>es(l,c,E));return h.push(...b),u.push(...w),{redos:u,undos:h}}};return[e,t,i,o]}_getWorksheet(r,e){var i;const t=(i=this._instanceService.getUniverSheetInstance(r))==null?void 0:i.getSheetBySheetId(e);if(!t)throw new Error(`[SheetClipboardController]: cannot find a worksheet with unitId ${r} and subUnitId ${e}.`);return t}_initCommandListener(){var e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{t.id===gt.id?this._sheetClipboardService.removeMarkSelection():xS.includes(t.id)&&this._sheetClipboardService.removeMarkSelection()}));const r=this._configService.getConfig(He);(e=r==null?void 0:r.clipboardConfig)!=null&&e.hidePasteOptions||(this.disposeWithMe(this._commandService.onCommandExecuted(t=>{AS.includes(t.id)&&this._sheetClipboardService.disposePasteOptionsCache()})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===Le.id){if(!this._sheetClipboardService.getPasteMenuVisible())return;const o=t.params.unitId,s=this._sheetClipboardService.getPasteOptionsCache(),l=s==null?void 0:s.target.unitId;o===l&&this._refreshOptionalPaste$.next(Math.random())}})))}_initUIComponents(){var e;const r=this._configService.getConfig(He);(e=r==null?void 0:r.clipboardConfig)!=null&&e.hidePasteOptions||this.disposeWithMe(this._uiPartsService.registerComponent(_.BuiltInUIPart.CONTENT,()=>_.connectInjector(OS,this._injector)))}};Rn=WS([qe(0,a.Inject(a.Injector)),qe(1,a.IUniverInstanceService),qe(2,R.IRenderManagerService),qe(3,a.ICommandService),qe(4,a.IContextService),qe(5,a.IConfigService),qe(6,We),qe(7,_.IMessageService),qe(8,a.Inject(a.LocaleService)),qe(9,_.IUIPartsService)],Rn);var LS=Object.getOwnPropertyDescriptor,US=(n,r,e,t)=>{for(var i=t>1?void 0:t?LS(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Tc=(n,r)=>(e,t)=>r(e,t,n);y.DragManagerService=class extends a.Disposable{constructor(e,t){super();T(this,"_currentCell$",new D.Subject);T(this,"currentCell$",this._currentCell$.asObservable().pipe(D.distinctUntilChanged((e,t)=>{var i,o,s,l,c,d,u,h;return((i=e==null?void 0:e.location)==null?void 0:i.unitId)===((o=t==null?void 0:t.location)==null?void 0:o.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((l=t==null?void 0:t.location)==null?void 0:l.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((d=t==null?void 0:t.location)==null?void 0:d.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=t==null?void 0:t.location)==null?void 0:h.col)})));T(this,"_endCell$",new D.Subject);T(this,"endCell$",this._endCell$.asObservable());this._univerInstanceService=e,this._renderManagerService=t,this._initCellDisposableListener()}dispose(){super.dispose(),this._currentCell$.complete(),this._endCell$.complete()}_initCellDisposableListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e||(this._currentCell$.next(null),this._endCell$.next(null))}))}_calcActiveCell(e,t){const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!i)return null;const o=i.getActiveSheet();if(!o)return;const s=this._renderManagerService.getRenderById(i.getUnitId());if(!s)return;const l=s.with(y.SheetSkeletonManagerService).getCurrentParam(),d=s.with(y.SheetScrollManagerService).getCurrentScrollState();if(!(!l||!d||!s))return vl(s,i,o,l,e,t)}onDragOver(e){const{offsetX:t,offsetY:i,dataTransfer:o}=e,s=this._calcActiveCell(t,i);if(!s){this._currentCell$.next(null);return}const{location:l,position:c}=s;this._currentCell$.next({location:l,position:c,dataTransfer:o})}onDrop(e){const{offsetX:t,offsetY:i,dataTransfer:o}=e,s=this._calcActiveCell(t,i);if(!s){this._endCell$.next(null);return}const{location:l,position:c}=s;this._endCell$.next({location:l,position:c,dataTransfer:o})}},y.DragManagerService=US([Tc(0,a.IUniverInstanceService),Tc(1,R.IRenderManagerService)],y.DragManagerService);var BS=Object.getOwnPropertyDescriptor,FS=(n,r,e,t)=>{for(var i=t>1?void 0:t?BS(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},ts=(n,r)=>(e,t)=>r(e,t,n);y.DragRenderController=class extends a.Disposable{constructor(r,e,t,i){super(),this._context=r,this._renderManagerService=e,this._dragManagerService=t,this._sheetSkeletonManagerService=i,this._initDragEvent()}_initDragEvent(){const r=new a.DisposableCollection,e=t=>{if(r.dispose(),!t)return;const{scene:i}=this._context,o=i.onDragOver$.subscribeEvent(l=>{this._dragManagerService.onDragOver(l)}),s=i.onDrop$.subscribeEvent(l=>{this._dragManagerService.onDrop(l)});r.add({dispose(){o.unsubscribe(),s.unsubscribe()}})};e(this._sheetSkeletonManagerService.getCurrentParam()),this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(t=>{e(t)}))}},y.DragRenderController=FS([ts(1,R.IRenderManagerService),ts(2,a.Inject(y.DragManagerService)),ts(3,a.Inject(y.SheetSkeletonManagerService))],y.DragRenderController);const ns=(n,r)=>{var h,g,S,f,v;const t=r.findNodePositionByCharIndex(n.startOffset,!0,n.segmentId,-1),i=r.getSkeletonData();let o=n.endOffset;if(n.segmentId){const p=(v=Array.from((g=(h=i==null?void 0:i.skeFooters.get(n.segmentId))==null?void 0:h.values())!=null?g:[])[0])!=null?v:Array.from((f=(S=i==null?void 0:i.skeHeaders.get(n.segmentId))==null?void 0:S.values())!=null?f:[])[0];p&&(o=Math.min(p.ed,o))}const s=r.findNodePositionByCharIndex(o,!0,n.segmentId,-1);if(!s||!t)return;const l={docsLeft:0,docsTop:0,pageMarginLeft:0,pageMarginTop:0},c=new q.NodePositionConvertToCursor(l,r),{borderBoxPointGroup:d}=c.getRangePointData(t,s);return q.getLineBounding(d).map(p=>({top:p.top,bottom:p.bottom,left:p.left,right:p.right}))},zS=(n,r,e=-1)=>{const t=r.findPositionByGlyph(n,e);if(!t)return;const i={...t,isBack:!0},o={docsLeft:0,docsTop:0,pageMarginLeft:0,pageMarginTop:0},s=new q.NodePositionConvertToCursor(o,r),{borderBoxPointGroup:l}=s.getRangePointData(i,i),d=q.getLineBounding(l)[0];return{top:d.top,bottom:d.bottom,left:d.left,right:d.right}},XS=(n,r,e=0,t=0)=>{const i=ns({startOffset:r.startIndex,endOffset:r.endIndex+1},n);if(i)return{rects:i.map(o=>({top:o.top+t,bottom:o.bottom+t,left:o.left+e,right:o.right+e})),range:r}},YS=(n,r,e=0,t=0)=>{var h,g,S;const i=n.findNodeByCharIndex(r.startIndex),o=i==null?void 0:i.parent,s=o==null?void 0:o.parent,l=s==null?void 0:s.parent,c=l==null?void 0:l.lines.find(f=>f.paragraphStart&&f.paragraphIndex===r.startIndex),d=(S=(g=(h=c==null?void 0:c.divides)==null?void 0:h[0])==null?void 0:g.glyphGroup)==null?void 0:S[0];if(!d||!d)return;const u=zS(d,n);if(u)return{rect:{top:u.top+t,bottom:u.bottom+t,left:u.left+e,right:u.right+e},segmentId:void 0,segmentPageIndex:-1,paragraph:r}},yc=(n,r=0,e=0)=>{var l,c,d,u,h,g,S;const t=n.getViewModel().getDataModel(),i=(d=(c=(l=t.getBody())==null?void 0:l.customRanges)==null?void 0:c.filter(f=>f.rangeType===a.CustomRangeType.HYPERLINK))!=null?d:[],o=(g=(h=(u=t.getBody())==null?void 0:u.paragraphs)==null?void 0:h.filter(f=>{var v;return((v=f.bullet)==null?void 0:v.listType.indexOf(a.PresetListType.CHECK_LIST))===0}))!=null?g:[],s=(S=n.getSkeletonData())==null?void 0:S.pages[0].skeDrawings;return{links:i.map(f=>XS(n,f,r,e)).filter(Boolean),checkLists:o.map(f=>YS(n,f,r,e)).filter(Boolean),drawings:s?Array.from(s.keys()).map(f=>({drawingId:f,rect:{top:s.get(f).aTop,bottom:s.get(f).aTop+s.get(f).width,left:s.get(f).aLeft,right:s.get(f).aLeft+s.get(f).height},drawing:s.get(f)})):[]}};function Rc(n,r,e){var d,u,h,g,S,f;const t=(h=(u=(d=r.documentSkeleton)==null?void 0:d.getSkeletonData())==null?void 0:u.pages[0].height)!=null?h:0,i=(f=(S=(g=r.documentSkeleton)==null?void 0:g.getSkeletonData())==null?void 0:S.pages[0].width)!=null?f:0,o=r.verticalAlign,s=r.horizontalAlign;let l=0;switch(o){case a.VerticalAlign.UNSPECIFIED:case a.VerticalAlign.BOTTOM:l=n.mergeInfo.endY-n.mergeInfo.startY-t;break;case a.VerticalAlign.MIDDLE:l=(n.mergeInfo.endY-n.mergeInfo.startY-t)/2;break}let c=0;switch(s){case a.HorizontalAlign.RIGHT:c=n.mergeInfo.endX-n.mergeInfo.startX-i;break;case a.HorizontalAlign.CENTER:c=(n.mergeInfo.endX-n.mergeInfo.startX-i)/2;break;case a.HorizontalAlign.UNSPECIFIED:{e&&(c=n.mergeInfo.endX-n.mergeInfo.startX-i);break}}return{paddingLeft:c,paddingTop:l}}const jS=(n,r,e,t,i,o)=>{var H,x,L;const s=n.get(a.IUniverInstanceService),l=n.get(R.IRenderManagerService),c=s.getUnit(r,a.UniverInstanceType.UNIVER_SHEET);if(!c)return null;const d=c.getSheetBySheetId(e);if(!d)return null;const u=l.getRenderById(c.getUnitId()),h=u==null?void 0:u.with(y.SheetSkeletonManagerService).getSkeletonParam(d.getSheetId()),g=h==null?void 0:h.skeleton;if(!g||!u)return;const S=g.getFont(t,i),f=S==null?void 0:S.documentSkeleton;if(!f)return null;const v=(x=(H=f.getViewModel().getBody())==null?void 0:H.customRanges)==null?void 0:x.find(V=>V.rangeId===o);if(!v)return null;const p=q.DOC_VERTICAL_PADDING,C=g.getCellWithCoordByIndex(t,i);let{actualColumn:b,actualRow:w}=C;g.overflowCache.forValue((V,U,B)=>{B.startRow<=w&&B.endRow>=w&&B.startColumn<=b&&B.endColumn>=b&&(b=U,w=V)});const E=g.getCellWithCoordByIndex(w,b),O=d.getCell(E.actualRow,E.actualColumn),{topOffset:M=0,leftOffset:P=0}=(L=O==null?void 0:O.fontRenderExtension)!=null?L:{},{paddingLeft:A,paddingTop:k}=Rc(E,S,!1),N=ns({startOffset:v.startIndex,endOffset:v.endIndex},f);return{rects:N==null?void 0:N.map(V=>({top:V.top+E.mergeInfo.startY+k+M+p,bottom:V.bottom+E.mergeInfo.startY+k+M+p,left:V.left+E.mergeInfo.startX+A+P,right:V.right+E.mergeInfo.startX+A+P})),customRange:v,label:f.getViewModel().getBody().dataStream.slice(v.startIndex,v.endIndex+1)}},GS=(n,r,e,t,i,o)=>{var P,A,k;const s=n.get(me),l=s.getEditCellState();if(!l||!s.isVisible().visible)return null;const{editorUnitId:d,unitId:u,sheetId:h,row:g,column:S}=l;if(r!==u||e!==h||g!==t||S!==i)return null;const f=n.get(R.IRenderManagerService),v=f.getRenderById(d),p=f.getRenderById(r);if(!v||!p)return null;const C=v.with(_e.DocSkeletonManagerService).getSkeleton(),b=(P=p.with(y.SheetSkeletonManagerService).getSkeletonParam(h))==null?void 0:P.skeleton;if(!C||!b)return null;const w=(k=(A=C.getViewModel().getBody())==null?void 0:A.customRanges)==null?void 0:k.find(N=>N.rangeId===o);if(!w)return null;const E=4,O=ns({startOffset:w.startIndex,endOffset:w.endIndex},C),M=v.engine.getCanvasElement().getBoundingClientRect();return{rects:O==null?void 0:O.map(N=>({top:N.top+M.top-E,bottom:N.bottom+M.top+E,left:N.left+M.left,right:N.right+M.left})),customRange:w,label:C.getViewModel().getBody().dataStream.slice(w.startIndex,w.endIndex+1)}};var ZS=Object.getOwnPropertyDescriptor,KS=(n,r,e,t)=>{for(var i=t>1?void 0:t?ZS(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Mc=(n,r)=>(e,t)=>r(e,t,n);function zt(n){const{workbook:r,worksheet:e,...t}=n;return t}y.HoverManagerService=class extends a.Disposable{constructor(e,t){super();T(this,"_currentCell$",new D.BehaviorSubject(null));T(this,"_currentRichText$",new D.BehaviorSubject(null));T(this,"_currentClickedCell$",new D.Subject);T(this,"_currentDbClickedCell$",new D.Subject);T(this,"_currentCellWithEvent$",new D.Subject);T(this,"_currentPointerDownCell$",new D.Subject);T(this,"_currentPointerUpCell$",new D.Subject);T(this,"_currentHoveredRowHeader$",new D.BehaviorSubject(null));T(this,"_currentHoveredColHeader$",new D.BehaviorSubject(null));T(this,"_currentRowHeaderClick$",new D.Subject);T(this,"_currentColHeaderClick$",new D.Subject);T(this,"_currentRowHeaderDbClick$",new D.Subject);T(this,"_currentColHeaderDbClick$",new D.Subject);T(this,"_currentRowHeaderPointerDown$",new D.Subject);T(this,"_currentColHeaderPointerDown$",new D.Subject);T(this,"_currentRowHeaderPointerUp$",new D.Subject);T(this,"_currentColHeaderPointerUp$",new D.Subject);T(this,"currentCell$",this._currentCell$.asObservable().pipe(D.distinctUntilChanged((e,t)=>{var i,o,s,l,c,d,u,h;return((i=e==null?void 0:e.location)==null?void 0:i.unitId)===((o=t==null?void 0:t.location)==null?void 0:o.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((l=t==null?void 0:t.location)==null?void 0:l.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((d=t==null?void 0:t.location)==null?void 0:d.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=t==null?void 0:t.location)==null?void 0:h.col)})));T(this,"currentRichTextNoDistinct$",this._currentRichText$.pipe(D.map(e=>e&&{unitId:e.location.unitId,subUnitId:e.location.subUnitId,row:e.location.row,col:e.location.col,customRange:e.customRange,bullet:e.bullet,rect:e.rect,drawing:e.drawing})));T(this,"currentRichText$",this._currentRichText$.pipe(D.distinctUntilChanged((e,t)=>{var i,o,s,l,c,d,u,h,g,S,f,v,p,C,b,w,E,O;return((i=e==null?void 0:e.location)==null?void 0:i.unitId)===((o=t==null?void 0:t.location)==null?void 0:o.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((l=t==null?void 0:t.location)==null?void 0:l.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((d=t==null?void 0:t.location)==null?void 0:d.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=t==null?void 0:t.location)==null?void 0:h.col)&&((g=e==null?void 0:e.customRange)==null?void 0:g.rangeId)===((S=t==null?void 0:t.customRange)==null?void 0:S.rangeId)&&((f=e==null?void 0:e.bullet)==null?void 0:f.startIndex)===((v=t==null?void 0:t.bullet)==null?void 0:v.startIndex)&&((p=e==null?void 0:e.customRange)==null?void 0:p.startIndex)===((C=t==null?void 0:t.customRange)==null?void 0:C.startIndex)&&((b=e==null?void 0:e.customRange)==null?void 0:b.endIndex)===((w=t==null?void 0:t.customRange)==null?void 0:w.endIndex)&&((E=e==null?void 0:e.drawing)==null?void 0:E.drawingId)===((O=t==null?void 0:t.drawing)==null?void 0:O.drawingId)}),D.map(e=>e&&{unitId:e.location.unitId,subUnitId:e.location.subUnitId,row:e.location.row,col:e.location.col,customRange:e.customRange,bullet:e.bullet,rect:e.rect,drawing:e.drawing})));T(this,"currentCellPosWithEvent$",this._currentCellWithEvent$.pipe(D.distinctUntilChanged((e,t)=>{var i,o,s,l,c,d,u,h;return((i=e==null?void 0:e.location)==null?void 0:i.unitId)===((o=t==null?void 0:t.location)==null?void 0:o.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((l=t==null?void 0:t.location)==null?void 0:l.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((d=t==null?void 0:t.location)==null?void 0:d.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=t==null?void 0:t.location)==null?void 0:h.col)}),D.map(e=>e&&{unitId:e.location.unitId,subUnitId:e.location.subUnitId,row:e.location.row,col:e.location.col,event:e.event})));T(this,"currentPosition$",this._currentCell$.asObservable());T(this,"currentClickedCell$",this._currentClickedCell$.asObservable());T(this,"currentDbClickedCell$",this._currentDbClickedCell$.asObservable());T(this,"currentPointerDownCell$",this._currentPointerDownCell$.asObservable());T(this,"currentPointerUpCell$",this._currentPointerUpCell$.asObservable());T(this,"currentHoveredRowHeader$",this._currentHoveredRowHeader$.asObservable());T(this,"currentHoveredColHeader$",this._currentHoveredColHeader$.asObservable());T(this,"currentRowHeaderClick$",this._currentRowHeaderClick$.asObservable());T(this,"currentColHeaderClick$",this._currentColHeaderClick$.asObservable());T(this,"currentRowHeaderDbClick$",this._currentRowHeaderDbClick$.asObservable());T(this,"currentColHeaderDbClick$",this._currentColHeaderDbClick$.asObservable());T(this,"currentRowHeaderPointerDown$",this._currentRowHeaderPointerDown$.asObservable());T(this,"currentColHeaderPointerDown$",this._currentColHeaderPointerDown$.asObservable());T(this,"currentRowHeaderPointerUp$",this._currentRowHeaderPointerUp$.asObservable());T(this,"currentColHeaderPointerUp$",this._currentColHeaderPointerUp$.asObservable());this._univerInstanceService=e,this._renderManagerService=t,this._initCellDisposableListener()}dispose(){super.dispose(),this._currentCell$.complete(),this._currentClickedCell$.complete(),this._currentPointerDownCell$.complete(),this._currentPointerUpCell$.complete(),this._currentCellWithEvent$.complete()}_initCellDisposableListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e||this._currentCell$.next(null)})),this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(e=>{var t,i;((t=this._currentCell$.getValue())==null?void 0:t.location.unitId)===e.getUnitId()&&this._currentCell$.next(null),((i=this._currentRichText$.getValue())==null?void 0:i.location.unitId)===e.getUnitId()&&this._currentRichText$.next(null)}))}_getCalcDeps(e){const t=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET);if(!t)return null;const i=t.getActiveSheet();if(!i)return null;const o=this._renderManagerService.getRenderById(t.getUnitId());if(!o)return null;const s=o.with(y.SheetSkeletonManagerService).getSkeletonParam(i.getSheetId());if(!s)return null;const l=o.with(y.SheetScrollManagerService);if(!(!(l!=null&&l.getCurrentScrollState())||!o))return{currentRender:o,workbook:t,worksheet:i,skeletonParam:s}}_calcActiveCell(e,t,i,o,s,l){var M,P,A;const c=vl(e,t,i,o,s,l),d=o.skeleton;if(!c)return null;const{position:u,overflowLocation:h,location:g}=c,S=d.getFont(h.row,h.col);let f=null,v=null,p=null;const C=d.getCellWithCoordByIndex(h.row,h.col),b=i.getCell(h.row,h.col),{topOffset:w=0,leftOffset:E=0}=(M=b==null?void 0:b.fontRenderExtension)!=null?M:{};if(S!=null&&S.documentSkeleton){const{paddingLeft:k,paddingTop:N}=Rc(C,S,(b==null?void 0:b.v)!==null&&(b==null?void 0:b.v)!==void 0?!Number.isNaN(+b.v):!1),H=yc(S.documentSkeleton,k,N),x=s-u.startX-E,L=l-u.startY-w;f=H.links.find(V=>V.rects.some(U=>U.left<=x&&x<=U.right&&U.top<=L&&L<=U.bottom)),v=H.checkLists.find(V=>V.rect.left<=x&&x<=V.rect.right&&V.rect.top<=L&&L<=V.rect.bottom),p=H.drawings.find(V=>V.rect.left<=x&&x<=V.rect.right&&V.rect.top<=L&&L<=V.rect.bottom)}const O=(A=(P=f==null?void 0:f.rects.pop())!=null?P:v==null?void 0:v.rect)!=null?A:p==null?void 0:p.rect;return{location:g,position:u,overflowLocation:h,customRange:f==null?void 0:f.range,bullet:v==null?void 0:v.paragraph,drawing:p,rect:O&&{top:O.top+C.mergeInfo.startY+w,bottom:O.bottom+C.mergeInfo.startY+w,left:O.left+C.mergeInfo.startX+E,right:O.right+C.mergeInfo.startX+E}}}_calcActiveRowHeader(e,t,i){const o=this._getCalcDeps(e);if(!o)return;const{currentRender:s,worksheet:l,skeletonParam:c}=o,{scaleY:d}=s.scene.getAncestorScale(),u=s.scene.getViewports().find(S=>S.isHit(new R.Vector2(t,i)));if(!u||u.viewportKey!==R.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP&&u.viewportKey!==R.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM)return;const h={x:u.viewportScrollX,y:u.viewportScrollY},g=c.skeleton.getRowIndexByOffsetY(i,d,h);return{unitId:e,index:g,subUnitId:l.getSheetId()}}_calcActiveColHeader(e,t,i){const o=this._getCalcDeps(e);if(!o)return;const{currentRender:s,worksheet:l,skeletonParam:c}=o,{scaleX:d}=s.scene.getAncestorScale(),u=s.scene.getViewports().find(S=>S.isHit(new R.Vector2(t,i)));if(!u||u.viewportKey!==R.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT&&u.viewportKey!==R.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT)return;const h={x:u.viewportScrollX,y:u.viewportScrollY},g=c.skeleton.getColumnIndexByOffsetX(t,d,h);return{unitId:e,index:g,subUnitId:l.getSheetId()}}triggerPointerDown(e,t){const i=this._getCalcDeps(e);if(!i)return;const{currentRender:o,workbook:s,worksheet:l,skeletonParam:c}=i,d=this._calcActiveCell(o,s,l,c,t.offsetX,t.offsetY);if(d&&d.location){const{unitId:u,subUnitId:h,row:g,col:S}=zt(d.location);this._currentPointerDownCell$.next({unitId:u,subUnitId:h,row:g,col:S,event:t})}}triggerPointerUp(e,t){const i=this._getCalcDeps(e);if(!i)return;const{currentRender:o,workbook:s,worksheet:l,skeletonParam:c}=i,d=this._calcActiveCell(o,s,l,c,t.offsetX,t.offsetY);if(d){const u=zt(d.location);this._currentPointerUpCell$.next({...u,event:t})}}triggerMouseMove(e,t){const i=this._getCalcDeps(e);if(!i)return;const{currentRender:o,workbook:s,worksheet:l,skeletonParam:c}=i,d=this._calcActiveCell(o,s,l,c,t.offsetX,t.offsetY);this._currentCell$.next(d&&{location:zt(d.location),position:d.position}),this._currentRichText$.next(d&&{...d,location:zt(d.overflowLocation)}),this._currentCellWithEvent$.next(d&&{...d,location:zt(d.location),event:t})}triggerClick(e,t,i){const o=this._getCalcDeps(e);if(!o)return;const{currentRender:s,workbook:l,worksheet:c,skeletonParam:d}=o,u=this._calcActiveCell(s,l,c,d,t,i);u&&this._currentClickedCell$.next({...u,location:zt(u.location)})}triggerDbClick(e,t,i){const o=this._getCalcDeps(e);if(!o)return;const{currentRender:s,workbook:l,worksheet:c,skeletonParam:d}=o,u=this._calcActiveCell(s,l,c,d,t,i);u&&this._currentDbClickedCell$.next({...u,location:zt(u.location)})}triggerScroll(){this._currentCell$.next(null)}triggerRowHeaderClick(e,t,i){const o=this._calcActiveRowHeader(e,t,i);o&&this._currentRowHeaderClick$.next(o)}triggerColHeaderClick(e,t,i){const o=this._calcActiveColHeader(e,t,i);o&&this._currentColHeaderClick$.next(o)}triggerRowHeaderDbClick(e,t,i){const o=this._calcActiveRowHeader(e,t,i);o&&this._currentRowHeaderDbClick$.next(o)}triggerColHeaderDbClick(e,t,i){const o=this._calcActiveColHeader(e,t,i);o&&this._currentColHeaderDbClick$.next(o)}triggerRowHeaderMouseMove(e,t,i){this._currentHoveredRowHeader$.next(this._calcActiveRowHeader(e,t,i))}triggerColHeaderMouseMove(e,t,i){this._currentHoveredColHeader$.next(this._calcActiveColHeader(e,t,i))}triggerRowHeaderPoniterDown(e,t,i){const o=this._calcActiveRowHeader(e,t,i);o&&this._currentRowHeaderPointerDown$.next(o)}triggerColHeaderPoniterDown(e,t,i){const o=this._calcActiveColHeader(e,t,i);o&&this._currentColHeaderPointerDown$.next(o)}triggerRowHeaderPoniterUp(e,t,i){const o=this._calcActiveRowHeader(e,t,i);o&&this._currentRowHeaderPointerUp$.next(o)}triggerColHeaderPoniterUp(e,t,i){const o=this._calcActiveColHeader(e,t,i);o&&this._currentColHeaderPointerUp$.next(o)}},y.HoverManagerService=KS([Mc(0,a.IUniverInstanceService),Mc(1,R.IRenderManagerService)],y.HoverManagerService);var qS=Object.getOwnPropertyDescriptor,QS=(n,r,e,t)=>{for(var i=t>1?void 0:t?qS(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Ii=(n,r)=>(e,t)=>r(e,t,n);const is="SHEET_FORCE_STRING_ALERT";let hr=class extends a.Disposable{constructor(n,r,e,t,i,o){super(),this._context=n,this._hoverManagerService=r,this._cellAlertManagerService=e,this._localeService=t,this._zenZoneService=i,this._configService=o,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.subscribe(n=>{var r,e;if(n){const i=this._context.unit.getActiveSheet();if(!i)return;const o=i.getCell(n.location.row,n.location.col);if((o==null?void 0:o.t)===a.CellValueType.FORCE_STRING&&o.v&&a.isRealNum(o.v)){const s=this._cellAlertManagerService.currentAlert.get(is),l=(r=s==null?void 0:s.alert)==null?void 0:r.location;if(l&&l.row===n.location.row&&l.col===n.location.col&&l.subUnitId===n.location.subUnitId&&l.unitId===n.location.unitId||(e=this._configService.getConfig(He))!=null&&e.disableForceStringAlert)return;this._cellAlertManagerService.showAlert({type:yn.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:n.location,width:200,height:74,key:is});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(is)}};hr=QS([Ii(1,a.Inject(y.HoverManagerService)),Ii(2,a.Inject(y.CellAlertManagerService)),Ii(3,a.Inject(a.LocaleService)),Ii(4,_.IZenZoneService),Ii(5,a.IConfigService)],hr);var JS=Object.getOwnPropertyDescriptor,$S=(n,r,e,t)=>{for(var i=t>1?void 0:t?JS(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},rs=(n,r)=>(e,t)=>r(e,t,n);let mr=class extends a.RxDisposable{constructor(n,r,e,t){super(),this._context=n,this._sheetSkeletonManagerService=r,this._sheetInterceptorService=e,this._configService=t,this._initViewModelIntercept()}_initViewModelIntercept(){const n={tl:{size:6,color:"#409f11"}};this.disposeWithMe(this._sheetInterceptorService.intercept(m.INTERCEPTOR_POINT.CELL_CONTENT,{priority:10,effect:a.InterceptorEffectEnum.Style,handler:(r,e,t)=>{var s,l,c;if(!((s=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:s.skeleton))return t(r);const o=e.rawData;if(!o||o.v===null||o.v===void 0)return t(r);if(((r==null?void 0:r.t)===a.CellValueType.FORCE_STRING||(r==null?void 0:r.t)===a.CellValueType.STRING)&&a.isRealNum(o.v)){const d=e.workbook.getStyles().get(o.s);return Oi.isTextFormat((l=d==null?void 0:d.n)==null?void 0:l.pattern)||(c=this._configService.getConfig(He))!=null&&c.disableForceStringMark||(r===o&&(r={...o}),r.markers={...r==null?void 0:r.markers,...n}),t(r)}return t(r)}}))}};mr=$S([rs(1,a.Inject(y.SheetSkeletonManagerService)),rs(2,a.Inject(m.SheetInterceptorService)),rs(3,a.IConfigService)],mr);var ef=Object.getOwnPropertyDescriptor,tf=(n,r,e,t)=>{for(var i=t>1?void 0:t?ef(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},os=(n,r)=>(e,t)=>r(e,t,n);y.HoverRenderController=class extends a.Disposable{constructor(e,t,i,o){super();T(this,"_active",!1);this._context=e,this._hoverManagerService=t,this._sheetSkeletonManagerService=i,this._scrollManagerService=o,this._initPointerEvent(),this._initScrollEvent()}get active(){return this._active}_initPointerEvent(){const e=new a.DisposableCollection,t=i=>{if(e.dispose(),!i)return;const{mainComponent:o,unitId:s,components:l}=this._context;if(!o)return;e.add(o.onPointerEnter$.subscribeEvent(u=>{this._active=!0})),e.add(a.fromEventSubject(o.onPointerMove$).subscribe(u=>{this._active=!0,this._hoverManagerService.triggerMouseMove(s,u)})),e.add(o.onPointerDown$.subscribeEvent(u=>{this._hoverManagerService.triggerPointerDown(s,u)})),e.add(o.onPointerUp$.subscribeEvent(u=>{this._hoverManagerService.triggerPointerUp(s,u)})),e.add(o.onClick$.subscribeEvent(u=>{this._hoverManagerService.triggerClick(s,u.offsetX,u.offsetY)})),e.add(o.onDblclick$.subscribeEvent(u=>{this._hoverManagerService.triggerDbClick(s,u.offsetX,u.offsetY)})),e.add(o.onPointerLeave$.subscribeEvent(()=>{this._active=!1}));const c=l.get(he.ROW),d=l.get(he.COLUMN);c&&(e.add(c.onPointerMove$.subscribeEvent(u=>{this._hoverManagerService.triggerRowHeaderMouseMove(s,u.offsetX,u.offsetY)})),e.add(c.onPointerDown$.subscribeEvent(u=>{this._hoverManagerService.triggerRowHeaderPoniterDown(s,u.offsetX,u.offsetY)})),e.add(c.onPointerUp$.subscribeEvent(u=>{this._hoverManagerService.triggerRowHeaderPoniterUp(s,u.offsetX,u.offsetY),this._hoverManagerService.triggerRowHeaderClick(s,u.offsetX,u.offsetY)})),e.add(c.onDblclick$.subscribeEvent(u=>{this._hoverManagerService.triggerRowHeaderDbClick(s,u.offsetX,u.offsetY)}))),d&&(e.add(d.onPointerMove$.subscribeEvent(u=>{this._hoverManagerService.triggerColHeaderMouseMove(s,u.offsetX,u.offsetY)})),e.add(d.onPointerDown$.subscribeEvent(u=>{this._hoverManagerService.triggerColHeaderPoniterDown(s,u.offsetX,u.offsetY)})),e.add(d.onPointerUp$.subscribeEvent(u=>{this._hoverManagerService.triggerColHeaderPoniterUp(s,u.offsetX,u.offsetY),this._hoverManagerService.triggerColHeaderClick(s,u.offsetX,u.offsetY)})),e.add(d.onDblclick$.subscribeEvent(u=>{this._hoverManagerService.triggerColHeaderDbClick(s,u.offsetX,u.offsetY)})))};t(this._sheetSkeletonManagerService.getCurrentParam()),this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{t(i)}))}_initScrollEvent(){this.disposeWithMe(this._scrollManagerService.validViewportScrollInfo$.subscribe(()=>this._hoverManagerService.triggerScroll()))}},y.HoverRenderController=tf([os(1,a.Inject(y.HoverManagerService)),os(2,a.Inject(y.SheetSkeletonManagerService)),os(3,a.Inject(y.SheetScrollManagerService))],y.HoverRenderController);var nf=Object.getOwnPropertyDescriptor,rf=(n,r,e,t)=>{for(var i=t>1?void 0:t?nf(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},ss=(n,r)=>(e,t)=>r(e,t,n);let gr=class extends a.Disposable{constructor(n,r,e,t){super(),this._context=n,this._markSelectionService=r,this._commandService=e,this._sheetSkeletonManagerService=t,this._initListeners()}_initListeners(){this._addRemoveListener(),this._addRefreshListener()}_addRemoveListener(){const n=[ge.id];this.disposeWithMe(this._commandService.onCommandExecuted(r=>{n.includes(r.id)?this._markSelectionService.removeAllShapes():this._markSelectionService.getShapeMap().forEach((t,i)=>{t.exits.includes(r.id)&&this._markSelectionService.removeShape(i)})}))}_addRefreshListener(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(n=>{n&&this._markSelectionService.refreshShapes()}))}};gr=rf([ss(1,a.Inject(Mt)),ss(2,a.ICommandService),ss(3,a.Inject(y.SheetSkeletonManagerService))],gr);function Pc(){const n=lt();return n?I.jsx(of,{workbook:n}):null}function of(n){const{workbook:r}=n,[e,t]=W.useState([]),[i,o]=W.useState(""),s=W.useRef(new Map),l=_.useDependency(a.ICommandService),c=W.useCallback(()=>{const u=r.getActiveSheet().getSheetId(),h=r.getSheets(),g=r.getActiveSheet(),S=h.filter(f=>!f.isSheetHidden()).map((f,v)=>{var p;return{sheetId:f.getSheetId(),label:f.getName(),index:v,selected:g===f,color:(p=f.getTabColor())!=null?p:void 0}});if(t(S),o(u),s.current.has(u)){const f=s.current.get(u);f&&f.scrollIntoView({behavior:"smooth",block:"nearest"})}s.current.clear()},[r]);W.useEffect(()=>c(),[c]);const d=W.useCallback(u=>{l.executeCommand(m.SetWorksheetActiveOperation.id,{unitId:r.getUnitId(),subUnitId:u})},[l,r]);return W.useEffect(()=>{const u=l.onCommandExecuted(h=>{switch(h.id){case m.SetWorksheetHideMutation.id:case m.RemoveSheetMutation.id:case m.SetWorksheetNameMutation.id:case m.InsertSheetMutation.id:case m.SetWorksheetOrderMutation.id:case m.SetWorksheetActiveOperation.id:c();break}});return()=>u.dispose()},[l,c]),I.jsx("div",{className:"univer-h-8 univer-w-full univer-overflow-x-scroll univer-bg-gray-100 dark:!univer-bg-gray-900",children:I.jsx("div",{className:"univer-flex univer-h-8 univer-flex-nowrap univer-items-center",children:e.map(u=>I.jsx("div",{ref:h=>{s.current.set(u.sheetId,h)},className:X.clsx(`
|
|
24
24
|
univer-box-border univer-h-full univer-min-w-12 univer-max-w-[120px] univer-shrink-0
|
|
25
25
|
univer-flex-nowrap univer-items-center univer-overflow-hidden univer-truncate
|
|
26
26
|
univer-whitespace-nowrap univer-px-1 univer-py-0.5 univer-text-center univer-text-xs
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-ui",
|
|
3
|
-
"version": "0.8.0-nightly.
|
|
3
|
+
"version": "0.8.0-nightly.202506081606",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "UniverSheet normal ui-plugin-sheets",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -66,16 +66,16 @@
|
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@univerjs/icons": "^0.4.4",
|
|
68
68
|
"@univerjs/protocol": "0.1.46",
|
|
69
|
-
"@univerjs/
|
|
70
|
-
"@univerjs/
|
|
71
|
-
"@univerjs/
|
|
72
|
-
"@univerjs/docs": "0.8.0-nightly.
|
|
73
|
-
"@univerjs/engine-formula": "0.8.0-nightly.
|
|
74
|
-
"@univerjs/engine-numfmt": "0.8.0-nightly.
|
|
75
|
-
"@univerjs/engine-render": "0.8.0-nightly.
|
|
76
|
-
"@univerjs/sheets": "0.8.0-nightly.
|
|
77
|
-
"@univerjs/telemetry": "0.8.0-nightly.
|
|
78
|
-
"@univerjs/ui": "0.8.0-nightly.
|
|
69
|
+
"@univerjs/design": "0.8.0-nightly.202506081606",
|
|
70
|
+
"@univerjs/core": "0.8.0-nightly.202506081606",
|
|
71
|
+
"@univerjs/docs-ui": "0.8.0-nightly.202506081606",
|
|
72
|
+
"@univerjs/docs": "0.8.0-nightly.202506081606",
|
|
73
|
+
"@univerjs/engine-formula": "0.8.0-nightly.202506081606",
|
|
74
|
+
"@univerjs/engine-numfmt": "0.8.0-nightly.202506081606",
|
|
75
|
+
"@univerjs/engine-render": "0.8.0-nightly.202506081606",
|
|
76
|
+
"@univerjs/sheets": "0.8.0-nightly.202506081606",
|
|
77
|
+
"@univerjs/telemetry": "0.8.0-nightly.202506081606",
|
|
78
|
+
"@univerjs/ui": "0.8.0-nightly.202506081606"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"postcss": "^8.5.3",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"vite": "^6.3.5",
|
|
87
87
|
"vitest": "^3.1.4",
|
|
88
88
|
"@univerjs-infra/shared": "0.8.0",
|
|
89
|
-
"@univerjs/themes": "0.8.0-nightly.
|
|
89
|
+
"@univerjs/themes": "0.8.0-nightly.202506081606"
|
|
90
90
|
},
|
|
91
91
|
"scripts": {
|
|
92
92
|
"test": "vitest run",
|