@univerjs/sheets-ui 0.6.6-nightly.202503161606 → 0.6.6-nightly.202503181607

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var dd=Object.defineProperty;var ud=(n,i,e)=>i in n?dd(n,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[i]=e;var E=(n,i,e)=>ud(n,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ee=require("@univerjs/docs-ui"),a=require("@univerjs/core"),T=require("@univerjs/engine-render"),_=require("@univerjs/ui"),V=require("react"),O=require("rxjs"),m=require("@univerjs/sheets"),Re=require("@univerjs/docs"),Z=require("@univerjs/engine-formula"),hd=require("@univerjs/engine-numfmt"),b=require("react/jsx-runtime"),Y=require("@univerjs/design"),me=require("rxjs/operators"),md=require("@univerjs/telemetry");function Mi(n,i){if(n==null)return;const e=i.getRenderById(n);if(e==null)return;const{mainComponent:t,scene:r,engine:o,components:s}=e,l=t,c=s.get(ee.DOCS_VIEW_KEY.BACKGROUND);return{document:l,docBackground:c,scene:r,engine:o}}const Ao=[10,400],ls="RANGE_SELECTOR_COMPONENT_KEY",Pi="EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY";var he=(n=>(n.MAIN="__SpreadsheetRender__",n.ROW="__SpreadsheetRowHeader__",n.COLUMN="__SpreadsheetColumnHeader__",n.LEFT_TOP="__SpreadsheetLeftTopPlaceholder__",n))(he||{});const Bs=0,ei=1,bt=10,gd=11,Fs=12,Oi={id:"sheet.command.set-row-header-width",type:a.CommandType.COMMAND,handler:async(n,i)=>{if(!i)return!1;const e=n.get(T.IRenderManagerService);if(!e)return!1;const{unitId:t,subUnitId:r,size:o}=i,s=e.getRenderById(t);if(s){e.getRenderById(t).with(exports.SheetSkeletonManagerService).setRowHeaderSize(s,r,o);const{components:c}=s,d=c.get(he.ROW);d&&d.setCustomHeader({headerStyle:{size:o}})}return!0}},xi={id:"sheet.command.set-col-header-height",type:a.CommandType.COMMAND,handler:async(n,i)=>{if(!i)return!1;const e=n.get(T.IRenderManagerService);if(!e)return!1;const{unitId:t,subUnitId:r,size:o}=i,s=e.getRenderById(t);if(s){e.getRenderById(t).with(exports.SheetSkeletonManagerService).setColumnHeaderSize(s,r,o);const{components:c}=s,d=c.get(he.COLUMN);d&&d.setCustomHeader({headerStyle:{size:o}})}return!0}},ko=a.createInterceptorKey("rangeMovePermissionCheck"),Do=a.createInterceptorKey("rangeFillPermissionCheck");var cs=(n=>(n[n.FORMULA_EDITOR_SHOW=100]="FORMULA_EDITOR_SHOW",n[n.MARK_SELECTION=1e4]="MARK_SELECTION",n))(cs||{});function Rt(n){const i=n.getCurrentTheme(),e=new a.ColorKit(i.primaryColor).setAlpha(.07).toRgbString();return{strokeWidth:1,stroke:i.primaryColor,fill:e,widgets:{},widgetSize:6,widgetStrokeWidth:1,widgetStroke:i.colorWhite,autofillSize:6,autofillStrokeWidth:1,autofillStroke:i.colorWhite,rowHeaderFill:e,rowHeaderStroke:i.primaryColor,rowHeaderStrokeWidth:1,columnHeaderFill:e,columnHeaderStroke:i.primaryColor,columnHeaderStrokeWidth:1,expandCornerSize:40}}class Sd{constructor(){E(this,"_startColumn",-1);E(this,"_startRow",-1);E(this,"_endColumn",-1);E(this,"_endRow",-1);E(this,"_startX",0);E(this,"_startY",0);E(this,"_endX",0);E(this,"_endY",0);E(this,"_primary");E(this,"_rangeType",a.RANGE_TYPE.NORMAL)}get startColumn(){return this._startColumn}get startRow(){return this._startRow}get endColumn(){return this._endColumn}get endRow(){return this._endRow}get startX(){return this._startX}get startY(){return this._startY}get endX(){return this._endX}get endY(){return this._endY}get currentCell(){return this._primary}get rangeType(){return this._rangeType}isEqual(i){const{startColumn:e,startRow:t,endColumn:r,endRow:o}=this,{startColumn:s,startRow:l,endColumn:c,endRow:d}=i;return e===s&&t===l&&r===c&&o===d}highlightToSelection(){if(this._primary)return a.convertCellToRange(this._primary)}getRange(){return{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this.rangeType}}getCell(){return this._primary}getRangeType(){return this._rangeType}setRangeType(i){this._rangeType=i}getValue(){return{rangeWithCoord:this.getRange(),primaryWithCoord:this._primary}}setValue(i,e){const{startColumn:t,startRow:r,endColumn:o,endRow:s,startX:l,startY:c,endX:d,endY:u,rangeType:h}=i;this._startColumn=t,this._startRow=r,this._endColumn=o,this._endRow=s,this._startX=l,this._startY=c,this._endX=d,this._endY=u,h!==void 0&&(this._rangeType=h),e!==void 0&&this.setCurrentCell(e)}setCurrentCell(i){this._primary=i}clearCurrentCell(){this._primary=null}}function Cn(n,i){const{startRow:e,startColumn:t,endRow:r,endColumn:o,rangeType:s}=i,l=r<e?r:e,c=r<e?e:r,d=o<t?o:t,u=o<t?t:o,h=n.getNoMergeCellWithCoordByIndex(l,d),g=n.getNoMergeCellWithCoordByIndex(c,u);return{startRow:e,startColumn:t,endRow:r,endColumn:o,rangeType:s,startY:(h==null?void 0:h.startY)||0,endY:(g==null?void 0:g.endY)||0,startX:(h==null?void 0:h.startX)||0,endX:(g==null?void 0:g.endX)||0}}function Pe(n,i){const{range:e,primary:t,style:r}=n,o=Cn(i,e),s=t&&$n(i,t);return{rangeWithCoord:o,primaryWithCoord:s,style:r}}function $n(n,i){const{actualRow:e,actualColumn:t,isMerged:r,isMergedMainCell:o,startRow:s,startColumn:l,endRow:c,endColumn:d}=i,u=n.getNoMergeCellWithCoordByIndex(e,t),h=n.getNoMergeCellWithCoordByIndex(s,l),g=n.getNoMergeCellWithCoordByIndex(c,d);return{actualRow:e,actualColumn:t,isMerged:r,isMergedMainCell:o,startX:u.startX,startY:u.startY,endX:u.endX,endY:u.endY,mergeInfo:{startRow:s,startColumn:l,endRow:c,endColumn:d,startY:(h==null?void 0:h.startY)||0,endY:(g==null?void 0:g.endY)||0,startX:(h==null?void 0:h.startX)||0,endX:(g==null?void 0:g.endX)||0}}}const js="__SpreadsheetHelperSelectionTempRect",fd=35;class za{constructor(i,e){E(this,"_startOffsetX",0);E(this,"_startOffsetY",0);E(this,"_relativeSelectionPositionRow",0);E(this,"_relativeSelectionPositionColumn",0);E(this,"_relativeSelectionRowLength",0);E(this,"_relativeSelectionColumnLength",0);E(this,"_scenePointerMoveSub");E(this,"_scenePointerUpSub");E(this,"_helperSelection");E(this,"_scrollTimer");E(this,"_activeViewport");E(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});E(this,"_isInMergeState",!1);E(this,"_fillControlColors",[]);E(this,"_skeleton");E(this,"_scene");E(this,"_themeService");E(this,"_injector");E(this,"_selectionHooks");this._control=i,this._skeleton=e.skeleton,this._scene=e.scene,this._themeService=e.themeService,this._injector=e.injector,this._selectionHooks=e.selectionHooks,this._initialControl(),this._initialWidget(),this._initialAutoFill(),this._control.dispose$.subscribe(()=>{this.dispose()})}get isHelperSelection(){return this._control.isHelperSelection}dispose(){var i,e;(i=this._scrollTimer)==null||i.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(e=this._helperSelection)==null||e.dispose()}_getFreeze(){var e,t;return(t=(e=T.withCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,exports.SheetSkeletonManagerService,this._injector.get(a.IUniverInstanceService),this._injector.get(T.IRenderManagerService)))==null?void 0:e.getCurrentParam())==null?void 0:t.skeleton.getWorksheetConfig().freeze}_isSelectionInViewport(i,e){const t=this._getFreeze()||{startRow:-1,startColumn:-1};switch(e.viewportKey){case T.SHEET_VIEWPORT_KEY.VIEW_MAIN:return i.endRow>=t.startRow&&i.endColumn>=t.startColumn;case T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP:case T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT:return i.endColumn>=t.startColumn&&i.startRow<t.startRow;case T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT:case T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM:return i.endRow>=t.startRow&&i.startColumn<t.startColumn;case T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP:case T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT:case T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP:case T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP:return i.startRow<t.startRow&&i.startColumn<t.startColumn}}_clearObserverEvent(){var i,e;(i=this._scenePointerMoveSub)==null||i.unsubscribe(),(e=this._scenePointerUpSub)==null||e.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null}_initialControl(){const{leftControl:i,rightControl:e,topControl:t,bottomControl:r}=this._control;[i,e,t,r].forEach(o=>{o.onPointerEnter$.subscribeEvent(()=>{var l;((l=this._injector.get(ve,a.Quantity.OPTIONAL))==null?void 0:l.interceptor.fetchThroughInterceptors(ko)(!1,null))!==!1&&o.setCursor(T.CURSOR_TYPE.MOVE)}),o.onPointerLeave$.subscribeEvent(()=>{o.resetCursor()}),o.onPointerDown$.subscribeEvent(this._controlPointerDownHandler.bind(this))})}_controlMoving(i,e){var A;const t=this._scene,r=t.getScrollXYInfoByViewport(T.Vector2.FromArray([i,e])),{scaleX:o,scaleY:s}=t.getAncestorScale(),l=this._skeleton.getCellIndexByOffset(i,e,o,s,r),{row:c,column:d}=l,u=this._skeleton.getRowCount()-1,h=this._skeleton.getColumnCount()-1;let g=Math.max(0,c+this._relativeSelectionPositionRow),S=g+this._relativeSelectionRowLength;S>u&&(S=u,S-g<this._relativeSelectionRowLength&&(g=S-this._relativeSelectionRowLength));let f=Math.max(0,d+this._relativeSelectionPositionColumn),p=f+this._relativeSelectionColumnLength;p>h&&(p=h,p-f<this._relativeSelectionColumnLength&&(f=p-this._relativeSelectionColumnLength));const v=this._skeleton.worksheet.getCellInfoInMergeData(g,f),I=Pe({range:{startRow:g,endRow:S,startColumn:f,endColumn:p},primary:v,style:null},this._skeleton),R=this._skeleton.getNoMergeCellWithCoordByIndex(g,f),w=this._skeleton.getNoMergeCellWithCoordByIndex(S,p),M=(R==null?void 0:R.startY)||0,y=(w==null?void 0:w.endY)||0,P=(R==null?void 0:R.startX)||0,x=(w==null?void 0:w.endX)||0;(A=this._helperSelection)==null||A.transformByState({left:P,top:M,width:x-P,height:y-M}),this._targetSelection={...I.rangeWithCoord},this._control.selectionMoving$.next(I.rangeWithCoord)}_controlPointerDownHandler(i){const{offsetX:e,offsetY:t}=i,r=this._scene,o=r.getCoordRelativeToViewport(T.Vector2.FromArray([e,t])),{x:s,y:l}=o,c=r.getScrollXYInfoByViewport(o),{scaleX:d,scaleY:u}=r.getAncestorScale(),h=this._skeleton.getCellIndexByOffset(s,l,d,u,c);this._startOffsetX=s,this._startOffsetY=l;const{row:g,column:S}=h,{startRow:f,startColumn:p,endRow:v,endColumn:C}=this._control.model;let I=0,R=0;g<f?I-=1:g>v&&(I+=1),S<p?R-=1:S>C&&(R+=1),this._relativeSelectionPositionRow=f-g+I,this._relativeSelectionPositionColumn=p-S+R,this._relativeSelectionRowLength=v-f,this._relativeSelectionColumnLength=C-p;const w=this._control.currentStyle,M=this._getScale();this.isHelperSelection&&(this._helperSelection=new T.Rect(js,{stroke:w.stroke,strokeWidth:w.strokeWidth/M}),r.addObject(this._helperSelection));const y=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),P=T.ScrollTimer.create(r);this._scrollTimer=P,P.startScroll(s,l,y),r.disableObjectsEvent(),this._scenePointerMoveSub=r.onPointerMove$.subscribeEvent(x=>{var N;const{offsetX:A,offsetY:k}=x;if(((N=this._injector.get(ve,a.Quantity.OPTIONAL))==null?void 0:N.interceptor.fetchThroughInterceptors(ko)(!1,null))===!1)return;const{x:H,y:W}=r.getCoordRelativeToViewport(T.Vector2.FromArray([A,k]));this._controlMoving(H,W),r.setCursor(T.CURSOR_TYPE.MOVE),P.scrolling(H,W,()=>{this._controlMoving(H,W)})}),this._scenePointerUpSub=r.onPointerUp$.subscribeEvent(()=>{var A,k,D,H;(A=this._helperSelection)==null||A.dispose();const x=this._scene;x.resetCursor(),this._clearObserverEvent(),x.enableObjectsEvent(),(k=this._scrollTimer)==null||k.dispose(),this._control.selectionMoveEnd$.next(this._targetSelection),(H=(D=this._selectionHooks).selectionMoveEnd)==null||H.call(D)})}_initialWidget(){const{topLeftWidget:i,topCenterWidget:e,topRightWidget:t,middleLeftWidget:r,middleRightWidget:o,bottomLeftWidget:s,bottomCenterWidget:l,bottomRightWidget:c}=this._control,d=[T.CURSOR_TYPE.NORTH_WEST_RESIZE,T.CURSOR_TYPE.NORTH_RESIZE,T.CURSOR_TYPE.NORTH_EAST_RESIZE,T.CURSOR_TYPE.WEST_RESIZE,T.CURSOR_TYPE.EAST_RESIZE,T.CURSOR_TYPE.SOUTH_WEST_RESIZE,T.CURSOR_TYPE.SOUTH_RESIZE,T.CURSOR_TYPE.SOUTH_EAST_RESIZE];[i,e,t,r,o,s,l,c].forEach((u,h)=>{u.onPointerEnter$.subscribeEvent(()=>{u.setCursor(d[h])}),u.onPointerLeave$.subscribeEvent(()=>{u.resetCursor()}),u.onPointerDown$.subscribeEvent(g=>{this._widgetPointerDownEvent(g,d[h])})})}_widgetPointerDownEvent(i,e){const t=this._scene,{offsetX:r,offsetY:o}=i,s=t.getCoordRelativeToViewport(T.Vector2.FromArray([r,o])),{x:l,y:c}=s;this._startOffsetX=r,this._startOffsetY=o;const{startRow:d,startColumn:u,endRow:h,endColumn:g}=this._control.model,S=Math.min(d,h),f=Math.min(u,g),p=Math.max(d,h),v=Math.max(u,g);this._relativeSelectionPositionRow=S,this._relativeSelectionPositionColumn=f,this._relativeSelectionRowLength=p-S,this._relativeSelectionColumnLength=v-f,e===T.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=p,this._relativeSelectionPositionColumn=v):e===T.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=p:e===T.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=p:e===T.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=v:e===T.CURSOR_TYPE.SOUTH_WEST_RESIZE?this._relativeSelectionPositionColumn=v:e===T.CURSOR_TYPE.SOUTH_RESIZE&&(this._relativeSelectionPositionRow=S);const C=T.ScrollTimer.create(t),I=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);C.startScroll(l,c,I),this._scrollTimer=C,t.disableObjectsEvent(),this._scenePointerMoveSub=t.onPointerMove$.subscribeEvent(R=>{const{offsetX:w,offsetY:M}=R,{x:y,y:P}=t.getCoordRelativeToViewport(T.Vector2.FromArray([w,M]));this._widgetMoving(y,P,e),t.setCursor(e),C.scrolling(y,P,()=>{this._widgetMoving(y,P,e)})}),this._scenePointerUpSub=t.onPointerUp$.subscribeEvent(()=>{var w,M,y;const R=this._scene;R.resetCursor(),this._clearObserverEvent(),R.enableObjectsEvent(),(w=this._scrollTimer)==null||w.dispose(),this._control.selectionScaled$.next(this._targetSelection),(y=(M=this._selectionHooks).selectionMoveEnd)==null||y.call(M)})}_widgetMoving(i,e,t){const r=this._scene,o=r.getScrollXYInfoByViewport(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:l}=r.getAncestorScale(),c=this._skeleton.getCellIndexByOffset(i,e,s,l,o),{row:d,column:u}=c;let h=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,S=d,f=u;t===T.CURSOR_TYPE.NORTH_WEST_RESIZE?(h=d,g=u,S=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn):t===T.CURSOR_TYPE.NORTH_RESIZE?(h=d,g=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):t===T.CURSOR_TYPE.NORTH_EAST_RESIZE?(h=d,g=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,f=u):t===T.CURSOR_TYPE.WEST_RESIZE?(h=this._relativeSelectionPositionRow,g=u,S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,f=this._relativeSelectionPositionColumn):t===T.CURSOR_TYPE.EAST_RESIZE?S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:t===T.CURSOR_TYPE.SOUTH_WEST_RESIZE?(h=this._relativeSelectionPositionRow,g=u,S=d,f=this._relativeSelectionPositionColumn):t===T.CURSOR_TYPE.SOUTH_RESIZE&&(h=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,S=d,f=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const p=this._swapPositions(h,g,S,f),v=this._skeleton.getCellWithMergeInfoByIndex(h,g),I=Pe({range:p,primary:v,style:null},this._skeleton);this._targetSelection={...I.rangeWithCoord},this._control.updateRangeBySelectionWithCoord(I),this._control.selectionScaling$.next(this._targetSelection)}_initialAutoFill(){const{fillControl:i}=this._control;i.onPointerEnter$.subscribeEvent(e=>{this._injector.get(ve).interceptor.fetchThroughInterceptors(Do)(!1,{x:e.offsetX,y:e.offsetY,skeleton:this._skeleton,scene:this._scene})&&i.setCursor(T.CURSOR_TYPE.CROSSHAIR)}),i.onPointerLeave$.subscribeEvent(()=>{i.resetCursor()}),i.onPointerDown$.subscribeEvent(this._autoFillForPointerdown.bind(this))}_autoFillMoving(i,e){var k,D,H;const t=this._scene,r=t.getViewportScrollXY(this._activeViewport),{scaleX:o,scaleY:s}=t.getAncestorScale(),l=this._skeleton.getCellIndexByOffset(i,e,o,s,r),{row:c,column:d}=l,u=t.getCoordRelativeToViewport(T.Vector2.FromArray([i,e])),h=this._skeleton.getRowCount()-1,g=this._skeleton.getColumnCount()-1;let S=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn,p=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,C=!1,I=!0;if((d<f||d>v)&&c>=S&&c<=p){const W=this._fillRuler(d,f,v,this._relativeSelectionColumnLength,g);f=W.startRowOrColumn,v=W.endRowOrColumn,C=W.isLighten,I=!1}else if((c<S||c>p)&&d>=f&&d<=v){const W=this._fillRuler(c,S,p,this._relativeSelectionRowLength,h);S=W.startRowOrColumn,p=W.endRowOrColumn,C=W.isLighten}else if(Math.abs(this._startOffsetX-u.x-r.x)/2>Math.abs(this._startOffsetY-u.y-r.y)){const W=this._fillRuler(d,f,v,this._relativeSelectionColumnLength,g);f=W.startRowOrColumn,v=W.endRowOrColumn,C=W.isLighten,I=!1}else{const W=this._fillRuler(c,S,p,this._relativeSelectionRowLength,h);S=W.startRowOrColumn,p=W.endRowOrColumn,C=W.isLighten}const R=this._skeleton.getNoMergeCellWithCoordByIndex(S,f),w=this._skeleton.getNoMergeCellWithCoordByIndex(p,v),M=(R==null?void 0:R.startY)||0,y=(w==null?void 0:w.endY)||0,P=(R==null?void 0:R.startX)||0,x=(w==null?void 0:w.endX)||0;C?this._controlHandler((W,N)=>{const U=new a.ColorKit(this._fillControlColors[N]).lighten(fd).toRgbString();W.setProps({fill:U})}):this._controlHandler((W,N)=>{W.setProps({fill:this._fillControlColors[N]})});const A=m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();S===p&&I===!0||f===v&&I===!1?(k=this._helperSelection)==null||k.hide():((D=this._helperSelection)==null||D.transformByState({left:P-A/2,top:M-A/2,width:x-P,height:y-M}),(H=this._helperSelection)==null||H.show()),this._targetSelection={startY:M,endY:y,startX:P,endX:x,startRow:S,endRow:p,startColumn:f,endColumn:v},this._control.selectionFilling$.next(this._targetSelection)}_autoFillForPointerdown(i){const{offsetX:e,offsetY:t}=i,r=this._scene,o=r.getCoordRelativeToViewport(T.Vector2.FromArray([e,t])),{x:s,y:l}=o;this._startOffsetX=s,this._startOffsetY=l;const{startRow:c,startColumn:d,endRow:u,endColumn:h}=this._control.model;this._isInMergeState=this._hasMergeInRange(c,d,u,h),this._relativeSelectionPositionRow=c,this._relativeSelectionPositionColumn=d,this._relativeSelectionRowLength=u-c,this._relativeSelectionColumnLength=h-d;const g=this._control.currentStyle;let S=g==null?void 0:g.stroke,f=g==null?void 0:g.strokeWidth;const p=Rt(this._themeService);S==null&&(S=p.stroke),f==null&&(f=p.strokeWidth);const v=this._getScale();f/=v;const C=m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/v,I=new a.ColorKit(S).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new T.Rect(js,{stroke:I,strokeWidth:f+C/2}),r.addObject(this._helperSelection)),this._activeViewport=r.getActiveViewportByCoord(T.Vector2.FromArray([e,t]));const R=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),w=T.ScrollTimer.create(r,this._activeViewport.viewportKey===T.SHEET_VIEWPORT_KEY.VIEW_MAIN?T.ScrollTimerType.ALL:T.ScrollTimerType.NONE);w.startScroll(s,l,R),this._scrollTimer=w,r.disableObjectsEvent(),this._controlHandler(M=>{this._fillControlColors.push(M.fill)}),this._scenePointerMoveSub=r.onPointerMove$.subscribeEvent(M=>{var W;const{offsetX:y,offsetY:P}=M,x=r.getActiveViewportByCoord(T.Vector2.FromArray([y,P]));if(!this._injector.get(ve).interceptor.fetchThroughInterceptors(Do)(!1,{x:i.offsetX,y:i.offsetY,skeleton:this._skeleton,scene:this._scene}))return;const{x:k,y:D}=r.getCoordRelativeToViewport(T.Vector2.FromArray([y,P]));this._autoFillMoving(k,D),r.setCursor(T.CURSOR_TYPE.CROSSHAIR);const H=this._targetSelection;if(R&&x&&((W=this._activeViewport)==null?void 0:W.viewportKey)!==(x==null?void 0:x.viewportKey)){let N;H.startRow!==c?(w.scrollTimerType=T.ScrollTimerType.Y,N={...H,endRow:H.startRow}):H.endRow!==u?(w.scrollTimerType=T.ScrollTimerType.Y,N={...H,startRow:H.endRow}):H.startColumn!==d?(w.scrollTimerType=T.ScrollTimerType.X,N={...H,endColumn:H.startColumn}):(w.scrollTimerType=T.ScrollTimerType.X,N={...H,startColumn:H.endColumn}),this._isSelectionInViewport(N,x)&&(R.scrollToBarPos({x:w.scrollTimerType===T.ScrollTimerType.X?0:void 0,y:w.scrollTimerType===T.ScrollTimerType.Y?0:void 0}),this._activeViewport=x)}w.scrolling(k,D,()=>{this._autoFillMoving(k,D)})}),this._scenePointerUpSub=r.onPointerUp$.subscribeEvent(()=>{var y,P;(y=this._helperSelection)==null||y.dispose();const M=this._scene;M.resetCursor(),this._clearObserverEvent(),M.enableObjectsEvent(),(P=this._scrollTimer)==null||P.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((x,A)=>{x.setProps({fill:this._fillControlColors[A]})}),this._fillControlColors=[]})}_hasMergeInRange(i,e,t,r){return this._skeleton.worksheet.getMergedCellRange(i,e,t,r).length>0}_swapPositions(i,e,t,r){const o=Math.min(i,t),s=Math.min(e,r),l=Math.max(i,t),c=Math.max(e,r);return{startRow:o,startColumn:s,endRow:l,endColumn:c}}_controlHandler(i){const{leftControl:e,rightControl:t,topControl:r,bottomControl:o,backgroundControlTop:s,backgroundControlMiddleLeft:l,backgroundControlMiddleRight:c,backgroundControlBottom:d,fillControl:u}=this._control,h=[e,t,r,o,s,l,c,d,u];for(let g=0,S=h.length;g<S;g++){const f=h[g];i(f,g)}}_fillRuler(i,e,t,r,o){let s=!1;if(i<e)if(this._isInMergeState&&i<e){const l=e-i,c=r+1,d=Math.ceil(l/c);let u=e-d*c;u<0&&(u=e-(d-1)*c),e=u}else e=i;else if(i>=e&&i<=t)s=!0,this._isInMergeState||(t=i);else if(this._isInMergeState&&i>t){const l=i-t,c=r+1,d=Math.ceil(l/c);let u=t+d*c;u>o&&(u=t+(d-1)*c),t=u}else t=i;return{rowOrColumn:i,startRowOrColumn:e,endRowOrColumn:t,isLighten:s}}_getScale(){const{scaleX:i,scaleY:e}=this._scene.getAncestorScale();return Math.max(i,e)}}var No=(n=>(n.Selection="__SpreadsheetSelectionShape__",n.top="__SpreadsheetSelectionTopControl__",n.bottom="__SpreadsheetSelectionBottomControl__",n.left="__SpreadsheetSelectionShapeLeftControl__",n.right="__SpreadsheetSelectionShapeRightControl__",n.backgroundTop="__SpreadsheetSelectionBackgroundControlTop__",n.backgroundMiddleLeft="__SpreadsheetSelectionBackgroundControlMiddleLeft__",n.backgroundMiddleRight="__SpreadsheetSelectionBackgroundControlMiddleRight__",n.backgroundBottom="__SpreadsheetSelectionBackgroundControlBottom__",n.fill="__SpreadsheetSelectionFillControl__",n.fillTopLeft="__SpreadsheetSelectionFillControlTopLeft__",n.fillBottomRight="__SpreadsheetSelectionFillControlBottomRight__",n.fillTopLeftInner="__SpreadsheetSelectionFillControlTopLeftInner__",n.fillBottomRightInner="__SpreadsheetSelectionFillControlBottomRightInner__",n.lineMain="__SpreadsheetDragLineMainControl__",n.lineContent="__SpreadsheetDragLineContentControl__",n.line="__SpreadsheetDragLineControl__",n.dash="__SpreadsheetDragDashControl__",n.rowHeaderBackground="__SpreadSheetSelectionRowHeaderBackground__",n.rowHeaderBorder="__SpreadSheetSelectionRowHeaderBorder__",n.rowHeaderGroup="__SpreadSheetSelectionRowHeaderGroup__",n.columnHeaderBackground="__SpreadSheetSelectionColumnHeaderBackground__",n.columnHeaderBorder="__SpreadSheetSelectionColumnHeaderBorder__",n.columnHeaderGroup="__SpreadSheetSelectionColumnHeaderGroup__",n.topLeftWidget="__SpreadSheetSelectionTopLeftWidget__",n.topCenterWidget="__SpreadSheetSelectionTopCenterWidget__",n.topRightWidget="__SpreadSheetSelectionTopRightWidget__",n.middleLeftWidget="__SpreadSheetSelectionMiddleLeftWidget__",n.middleRightWidget="__SpreadSheetSelectionMiddleRightWidget__",n.bottomLeftWidget="__SpreadSheetSelectionBottomLeftWidget__",n.bottomCenterWidget="__SpreadSheetSelectionBottomCenterWidget__",n.bottomRightWidget="__SpreadSheetSelectionBottomRightWidget__",n))(No||{});const zs=.3;class cr extends a.Disposable{constructor(e,t,r,o){var s,l,c,d;super();E(this,"_isHelperSelection",!0);E(this,"_enableAutoFill",!0);E(this,"_showAutoFill",!1);E(this,"_highlightHeader",!0);E(this,"_selectionRenderModel");E(this,"_leftBorder");E(this,"_rightBorder");E(this,"_topBorder");E(this,"_bottomBorder");E(this,"_backgroundControlTop");E(this,"_backgroundControlBottom");E(this,"_backgroundControlMiddleLeft");E(this,"_backgroundControlMiddleRight");E(this,"_autoFillControl");E(this,"_selectionShapeGroup");E(this,"_rowHeaderBackground");E(this,"_rowHeaderBorder");E(this,"_rowHeaderGroup");E(this,"_columnHeaderBackground");E(this,"_columnHeaderBorder");E(this,"_columnHeaderGroup");E(this,"_dashedRect");E(this,"_topLeftWidget");E(this,"_topCenterWidget");E(this,"_topRightWidget");E(this,"_middleLeftWidget");E(this,"_middleRightWidget");E(this,"_bottomLeftWidget");E(this,"_bottomCenterWidget");E(this,"_bottomRightWidget");E(this,"_defaultStyle");E(this,"_currentStyle");E(this,"_rowHeaderWidth",0);E(this,"_columnHeaderHeight",0);E(this,"_widgetRects",[]);E(this,"_controlExtension");E(this,"_dispose$",new O.BehaviorSubject(this));E(this,"dispose$",this._dispose$.asObservable());E(this,"selectionMoving$",new O.Subject);E(this,"selectionMoveEnd$",new O.Subject);E(this,"selectionScaling$",new O.Subject);E(this,"selectionScaled$",new O.Subject);E(this,"selectionFilling$",new O.Subject);E(this,"_selectionFilled$",new O.Subject);E(this,"selectionFilled$",this._selectionFilled$.asObservable());E(this,"_antLineOffset",0);E(this,"_antRequestNewFrame",-1);this._scene=e,this._zIndex=t,this._themeService=r,this._enableAutoFill=(s=o==null?void 0:o.enableAutoFill)!=null?s:!0,this._highlightHeader=(l=o==null?void 0:o.highlightHeader)!=null?l:!0,this._rowHeaderWidth=(c=o==null?void 0:o.rowHeaderWidth)!=null?c:0,this._columnHeaderHeight=(d=o==null?void 0:o.columnHeaderHeight)!=null?d:0,this._initializeSheetBody(),this._initialHeader()}_initializeSheetBody(){this._defaultStyle=Rt(this._themeService),this._currentStyle=Rt(this._themeService),this._selectionRenderModel=new Sd;const e=this._zIndex;this._leftBorder=new T.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightBorder=new T.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topBorder=new T.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomBorder=new T.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new T.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new T.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new T.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new T.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._autoFillControl=new T.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._autoFillControl.hide(),this._dashedRect=new T.DashedRect("__SpreadsheetDragDashControl__"+e,{zIndex:e+2,evented:!1,stroke:"#fff"});const t=[this._autoFillControl,this._leftBorder,this._rightBorder,this._topBorder,this._bottomBorder,this._backgroundControlTop,this._backgroundControlMiddleLeft,this._backgroundControlMiddleRight,this._backgroundControlBottom,this._dashedRect];this._widgetRects=this._initialWidget(),this._selectionShapeGroup=new T.Group("__SpreadsheetSelectionShape__"+e,...t,...this._widgetRects),this._selectionShapeGroup.hide(),this._selectionShapeGroup.evented=!1,this._selectionShapeGroup.zIndex=e;const r=this.getScene();r.addObject(this._selectionShapeGroup,ei),this.disposeWithMe(a.toDisposable(r.onTransformChange$.subscribeEvent(o=>{o.type===T.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&(this._updateLayoutOfSelectionControl(this._currentStyle),this._updateControlCoord())})))}_initialHeader(){const e=this._zIndex;this._rowHeaderBackground=new T.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new T.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new T.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new T.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new T.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new T.Group("__SpreadSheetSelectionColumnHeaderGroup__"+e,this._columnHeaderBackground,this._columnHeaderBorder),this._columnHeaderGroup.hide(),this._columnHeaderGroup.evented=!1,this._columnHeaderGroup.zIndex=e,this.getScene().addObjects([this._rowHeaderGroup,this._columnHeaderGroup],gd)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new T.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new T.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new T.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new T.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new T.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new T.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new T.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new T.Rect("__SpreadSheetSelectionBottomRightWidget__"+e,{zIndex:e+1}),[this._topLeftWidget,this._topCenterWidget,this._topRightWidget,this._middleLeftWidget,this._middleRightWidget,this._bottomLeftWidget,this._bottomCenterWidget,this._bottomRightWidget]}get zIndex(){return this._zIndex}get leftControl(){return this._leftBorder}get rightControl(){return this._rightBorder}get topControl(){return this._topBorder}get bottomControl(){return this._bottomBorder}get fillControl(){return this._autoFillControl}get backgroundControlTop(){return this._backgroundControlTop}get backgroundControlBottom(){return this._backgroundControlBottom}get backgroundControlMiddleLeft(){return this._backgroundControlMiddleLeft}get backgroundControlMiddleRight(){return this._backgroundControlMiddleRight}get selectionShape(){return this._selectionShapeGroup}get columnHeaderGroup(){return this._columnHeaderGroup}get rowHeaderGroup(){return this._rowHeaderGroup}get selectionShapeGroup(){return this._selectionShapeGroup}get model(){return this._selectionRenderModel}get topLeftWidget(){return this._topLeftWidget}get topCenterWidget(){return this._topCenterWidget}get topRightWidget(){return this._topRightWidget}get middleLeftWidget(){return this._middleLeftWidget}get middleRightWidget(){return this._middleRightWidget}get bottomLeftWidget(){return this._bottomLeftWidget}get bottomCenterWidget(){return this._bottomCenterWidget}get bottomRightWidget(){return this._bottomRightWidget}get themeService(){return this._themeService}get selectionModel(){return this._selectionRenderModel}set selectionModel(e){this._selectionRenderModel=e}get currentStyle(){return this._currentStyle}set currentStyle(e){this._currentStyle=e}get dashedRect(){return this._dashedRect}get isHelperSelection(){return this._isHelperSelection}get rowHeaderWidth(){return this._rowHeaderWidth}set rowHeaderWidth(e){this._rowHeaderWidth=e}get columnHeaderHeight(){return this._columnHeaderHeight}set columnHeaderHeight(e){this._columnHeaderHeight=e}setControlExtension(e){this._controlExtension=new za(this,e)}setEvent(e){this.leftControl.evented=e,this.rightControl.evented=e,this.topControl.evented=e,this.bottomControl.evented=e}refreshSelectionFilled(e){this._selectionFilled$.next(e)}_updateLayoutOfSelectionControl(e){e&&(this.currentStyle=Object.assign({},this._defaultStyle,e));const t=this.currentStyle,{stroke:r,widgets:o,autofillStroke:s,strokeDash:l,isAnimationDash:c}=t;let d=t.autofillSize,u=t.strokeWidth,h=t.autofillStrokeWidth;const g=this._getScale(),S=(u+m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH)/2/g;u/=g,d/=g,h/=g<1?1:g;const f=m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/g,p=T.FIX_ONE_PIXEL_BLUR_OFFSET/g,{startX:v,startY:C,endX:I,endY:R}=this._selectionRenderModel;if(this.leftControl.transformByState({height:R-C,left:-S+p,width:u,strokeWidth:f,top:-f/2+p}),this.leftControl.setProps({fill:r,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:R-C,left:I-v-S+p,width:u,strokeWidth:f,top:-f/2+p}),this.rightControl.setProps({fill:r,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:I-v+u,top:-S+p,left:-S+p,height:u,strokeWidth:f}),this.topControl.setProps({fill:r,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:I-v+u,top:R-C-S+p,height:u,left:-S+p,strokeWidth:f}),this.bottomControl.setProps({fill:r,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),l==null)this.dashedRect.hide(),this._stopAntLineAnimation();else{const w=t.strokeWidth*2/g;this.dashedRect.transformByState({height:R-C,width:I-v,strokeWidth:w,left:-w/2+p,top:-w/2+p}),this.dashedRect.setProps({strokeDashArray:[0,l/g]}),this._stopAntLineAnimation(),c!==!1&&this._startAntLineAnimation(),this.dashedRect.show()}if(this._showAutoFill=this._showAutoFill&&this._enableAutoFill,this._showAutoFill&&!this._hasWidgets(o)){const w={fill:r,stroke:s,strokeScaleEnabled:!1},M={width:d-h,height:d-h,left:I-v-d/2+h/2-p,top:R-C-d/2+h/2-p,strokeWidth:h};this._autoFillControl.setProps(w),this._autoFillControl.transformByState(M),this._autoFillControl.show()}else this._autoFillControl.hide();this._updateBackgroundControl(t),this._updateHeaderBackground(t),this._updateWidgets(t)}_updateControlCoord(){const{startX:e,startY:t}=this._selectionRenderModel;this.selectionShapeGroup.show(),this.selectionShapeGroup.translate(e,t),this.selectionShapeGroup.makeDirtyNoDebounce(!0)}updateStyle(e){this._updateLayoutOfSelectionControl(e),this._updateControlCoord()}updateRange(e,t){this._selectionRenderModel.setValue(e,t),this._showAutoFill=t!==null,this._updateLayoutOfSelectionControl(),this._updateControlCoord()}updateRangeBySelectionWithCoord(e,t){t&&(this._rowHeaderWidth=t.rowHeaderWidth,this._columnHeaderHeight=t.columnHeaderHeight),this._selectionRenderModel.setValue(e.rangeWithCoord,e.primaryWithCoord),this._showAutoFill=e.primaryWithCoord!==null,this._updateLayoutOfSelectionControl(e.style),this._updateControlCoord()}update(e,t=0,r=0,o,s){this._rowHeaderWidth=t,this._columnHeaderHeight=r,this.updateRangeBySelectionWithCoord({rangeWithCoord:e,primaryWithCoord:s,style:o}),o&&this.updateStyle(o)}updateCurrCell(e){this._showAutoFill=e!==null,this._selectionRenderModel.setCurrentCell(e)}clearHighlight(){this._showAutoFill=!1,this._selectionRenderModel.clearCurrentCell(),this._updateLayoutOfSelectionControl(this._currentStyle)}getScene(){return this._scene}dispose(){var e,t,r,o,s,l,c,d,u,h,g,S,f,p,v,C,I,R,w,M,y,P,x,A,k;(e=this._leftBorder)==null||e.dispose(),(t=this._rightBorder)==null||t.dispose(),(r=this._topBorder)==null||r.dispose(),(o=this._bottomBorder)==null||o.dispose(),(s=this._backgroundControlTop)==null||s.dispose(),(l=this._backgroundControlMiddleLeft)==null||l.dispose(),(c=this._backgroundControlMiddleRight)==null||c.dispose(),(d=this._backgroundControlBottom)==null||d.dispose(),this._autoFillControl.dispose(),(u=this._selectionShapeGroup)==null||u.dispose(),(h=this._rowHeaderBackground)==null||h.dispose(),(g=this._rowHeaderBorder)==null||g.dispose(),(S=this._rowHeaderGroup)==null||S.dispose(),(f=this._rowHeaderBackground)==null||f.dispose(),(p=this._columnHeaderBackground)==null||p.dispose(),(v=this._columnHeaderBorder)==null||v.dispose(),(C=this._columnHeaderGroup)==null||C.dispose(),(I=this._topLeftWidget)==null||I.dispose(),(R=this._topCenterWidget)==null||R.dispose(),(w=this._topRightWidget)==null||w.dispose(),(M=this._middleLeftWidget)==null||M.dispose(),(y=this._middleRightWidget)==null||y.dispose(),(P=this._bottomLeftWidget)==null||P.dispose(),(x=this._bottomCenterWidget)==null||x.dispose(),(A=this._bottomRightWidget)==null||A.dispose(),(k=this._controlExtension)==null||k.dispose(),super.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let t;if(e.isMerged){const r=e.mergeInfo;t={startRow:r.startRow,endRow:r.endRow,startColumn:r.startColumn,endColumn:r.endColumn,startX:r.startX,endX:r.endX,startY:r.startY,endY:r.endY}}else{const{actualRow:r,actualColumn:o,startX:s,endX:l,startY:c,endY:d}=e;t={startRow:r,endRow:r,startColumn:o,endColumn:o,startX:s,endX:l,startY:c,endY:d}}return t}}getValue(){return{...this._selectionRenderModel.getValue(),style:this._currentStyle}}getRange(){return this._selectionRenderModel.getValue().rangeWithCoord}enableHelperSelection(){this._isHelperSelection=!0}disableHelperSelection(){this._isHelperSelection=!1}_updateHeaderBackground(e){const{startX:t,startY:r,endX:o,endY:s,rangeType:l}=this._selectionRenderModel,c=this._currentStyle,d=this._getScale(),{stroke:u,rowHeaderFill:h=c.rowHeaderFill,rowHeaderStroke:g=c.rowHeaderStroke,columnHeaderFill:S=c.columnHeaderFill,columnHeaderStroke:f=c.columnHeaderStroke}=e;let{rowHeaderStrokeWidth:p=c.rowHeaderStrokeWidth,columnHeaderStrokeWidth:v=c.columnHeaderStrokeWidth}=e;p/=d,v/=d;const C=this._rowHeaderWidth,I=this._columnHeaderHeight;if(this._highlightHeader&&I>0){let R=S;l===a.RANGE_TYPE.COLUMN&&(R=new a.ColorKit(u).setAlpha(zs).toString()),this._columnHeaderBackground.setProps({fill:R}),this._columnHeaderBackground.resize(o-t,I),this._columnHeaderBorder.setProps({fill:f}),this._columnHeaderBorder.transformByState({width:o-t,height:v,top:I-v+1/d}),this._columnHeaderGroup.show(),this._columnHeaderGroup.translate(t,0)}else this._columnHeaderGroup.hide();if(this._columnHeaderGroup.makeDirty(!0),this._highlightHeader&&C>0){let R=h;l===a.RANGE_TYPE.ROW&&(R=new a.ColorKit(u).setAlpha(zs).toString()),this._rowHeaderBackground.setProps({fill:R}),this._rowHeaderBackground.resize(C,s-r),this._rowHeaderBorder.setProps({fill:g}),this._rowHeaderBorder.transformByState({width:p,height:s-r,left:C-p+1/d}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,r)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){const{startX:t,startY:r,endX:o,endY:s}=this._selectionRenderModel,l=this._getScale(),{fill:c=e.fill}=e;let{strokeWidth:d}=e;d/=l;const u=this._selectionRenderModel.highlightToSelection();if(!u){this._backgroundControlTop.resize(o-t,s-r),this._backgroundControlTop.setProps({fill:c}),this._backgroundControlBottom.resize(0,0),this._backgroundControlMiddleLeft.resize(0,0),this._backgroundControlMiddleRight.resize(0,0);return}const{startX:h,startY:g,endX:S,endY:f}=u,p=d/2,v={left:-p,top:-p,width:o-t+p*2,height:g-r+p};v.height<0&&(v.width=0,v.height=0),this._backgroundControlTop.transformByState(v);const C={left:-p,top:g-r,width:h-t+p,height:f-g};C.width<0&&(C.width=0,C.height=0),this._backgroundControlMiddleLeft.transformByState(C);const I={left:S-t-p,top:g-r,width:o-S+p*2,height:f-g};I.width<0&&(I.width=0,I.height=0),this._backgroundControlMiddleRight.transformByState(I);const R={left:-p,top:f-r,width:o-t+p*2,height:s-f+p};R.height<0&&(R.width=0,R.height=0),this._backgroundControlBottom.transformByState(R),this._backgroundControlTop.setProps({fill:c}),this._backgroundControlMiddleLeft.setProps({fill:c}),this._backgroundControlMiddleRight.setProps({fill:c}),this._backgroundControlBottom.setProps({fill:c})}_updateWidgets(e){const{startX:t,startY:r,endX:o,endY:s}=this._selectionRenderModel,{stroke:l=e.stroke,widgets:c=e.widgets,widgetStroke:d=e.widgetStroke}=e,u=this._getScale();let{widgetSize:h,widgetStrokeWidth:g}=e;h/=u,g/=u;const S={left:-h/2+g/2,center:(o-t)/2-h/2+g/2,right:o-t-h/2+g/2,top:-h/2,middle:(s-r)/2-h/2,bottom:s-r-h/2+g/2},f=h-g;this._widgetRects.forEach(p=>{p.setProps({fill:l,stroke:d})}),c.tl===!0?(this._topLeftWidget.transformByState({height:f,width:f,left:S.left,top:S.top,strokeWidth:g}),this._topLeftWidget.show()):this._topLeftWidget.hide(),c.tc===!0?(this._topCenterWidget.transformByState({height:f,width:f,left:S.center,top:S.top,strokeWidth:g}),this._topCenterWidget.show()):this._topCenterWidget.hide(),c.tr===!0?(this._topRightWidget.transformByState({height:f,width:f,left:S.right,top:S.top,strokeWidth:g}),this._topRightWidget.show()):this._topRightWidget.hide(),c.ml===!0?(this._middleLeftWidget.transformByState({height:f,width:f,left:S.left,top:S.middle,strokeWidth:g}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),c.mr===!0?(this._middleRightWidget.transformByState({height:f,width:f,left:S.right,top:S.middle,strokeWidth:g}),this._middleRightWidget.show()):this._middleRightWidget.hide(),c.bl===!0?(this._bottomLeftWidget.transformByState({height:f,width:f,left:S.left,top:S.bottom,strokeWidth:g}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),c.bc===!0?(this._bottomCenterWidget.transformByState({height:f,width:f,left:S.center,top:S.bottom,strokeWidth:g}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),c.br===!0?(this._bottomRightWidget.transformByState({height:f,width:f,left:S.right,top:S.bottom,strokeWidth:g}),this._bottomRightWidget.show()):this._bottomRightWidget.hide()}_hasWidgets(e){if(e==null)return!1;const t=Object.keys(e);if(t.length===0)return!1;for(const r of t)if(e[r]===!0)return!0;return!1}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}_stopAntLineAnimation(){this._antLineOffset=0,T.cancelRequestFrame(this._antRequestNewFrame)}_startAntLineAnimation(){const e=this._getScale();this._antLineOffset+=.6/e,this._antLineOffset>160/e&&(this._antLineOffset=0),this.dashedRect.setProps({strokeDashOffset:-this._antLineOffset}),this._antRequestNewFrame=T.requestNewFrame(()=>{this._startAntLineAnimation()})}}class pd extends T.Layer{render(i,e=!1){const t=a.Tools.now();return super.render(i,e),this._afterRender(t),this}_afterRender(i){this.scene.getEngine().renderFrameTimeMetric$.next(["selectionLayer",a.Tools.now()-i])}}const ve=a.createIdentifier("univer.sheet.selection-render-service");class ds extends a.Disposable{constructor(e,t,r,o,s){super();E(this,"_downObserver");E(this,"_scenePointerMoveSub");E(this,"_scenePointerUpSub");E(this,"_controlFillConfig$",new O.BehaviorSubject(null));E(this,"controlFillConfig$",this._controlFillConfig$.asObservable());E(this,"_selectionControls",[]);E(this,"_startRangeWhenPointerDown",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});E(this,"_activeControlIndex",-1);E(this,"_startViewportPosX",0);E(this,"_startViewportPosY",0);E(this,"_scrollTimer");E(this,"_cancelDownSubscription");E(this,"_cancelUpSubscription");E(this,"_skeleton");E(this,"_scene");E(this,"_highlightHeader",!0);E(this,"_rangeType",a.RANGE_TYPE.NORMAL);E(this,"_selectionStyle");E(this,"_remainLastEnabled",!1);E(this,"_skipLastEnabled",!1);E(this,"_singleSelectionEnabled",!1);E(this,"_selectionMoveEnd$",new O.BehaviorSubject([]));E(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());E(this,"_selectionMoving$",new O.Subject);E(this,"selectionMoving$",this._selectionMoving$.asObservable());E(this,"_selectionMoveStart$",new O.Subject);E(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());E(this,"_selectionMoving",!1);E(this,"_selectionTheme");E(this,"_activeViewport");E(this,"interceptor",new a.InterceptorManager({RANGE_MOVE_PERMISSION_CHECK:ko,RANGE_FILL_PERMISSION_CHECK:Do}));E(this,"_escapeShortcutDisposable",null);this._injector=e,this._themeService=t,this._shortcutService=r,this._sheetSkeletonManagerService=o,this.contextService=s,this._initSelectionThemeFromThemeService(),this._initMoving()}get selectionMoving(){return this._selectionMoving}get _shouldDetectMergedCells(){return this._rangeType===a.RANGE_TYPE.NORMAL}_initMoving(){this.disposeWithMe(this._selectionMoving$.subscribe(()=>{this._selectionMoving=!0})),this.disposeWithMe(this._selectionMoveEnd$.subscribe(()=>{this._selectionMoving=!1}))}_setSelectionStyle(e){this._selectionStyle=e}getViewPort(){return this._activeViewport}setSingleSelectionEnabled(e=!1){this._singleSelectionEnabled=e}newSelectionControl(e,t,r){const o=this.getSelectionControls().length,{rowHeaderWidth:s,columnHeaderHeight:l}=t,c=new cr(e,o,this._selectionTheme,{highlightHeader:this._highlightHeader,rowHeaderWidth:s,columnHeaderHeight:l});this._selectionControls.push(c);const d=Pe(r,t);return c.updateRangeBySelectionWithCoord(d,t),c.setControlExtension({skeleton:t,scene:e,themeService:this._selectionTheme,injector:this._injector,selectionHooks:{selectionMoveEnd:()=>{this._selectionMoveEnd$.next(this.getSelectionDataWithStyle())}}}),c}resetSelectionsByModelData(e){const t=this.getSelectionControls(),r=this._skeleton;if(!(!t||!r)){for(let o=0,s=e.length;o<s;o++){const l=e[o],c=Pe(l,this._skeleton),d=t[o];d?d.updateRangeBySelectionWithCoord(c,r):this.isSelectionEnabled()&&this.newSelectionControl(this._scene,r,l)}e.length<t.length&&t.splice(e.length).forEach(s=>s.dispose())}}refreshSelectionMoveStart(){this._selectionMoveStart$.next(this.getSelectionDataWithStyle())}refreshSelectionMoveEnd(){this._selectionMoveEnd$.next(this.getSelectionDataWithStyle())}_initSelectionThemeFromThemeService(){const e=this._themeService.getCurrentTheme();this._selectionTheme=new a.ThemeService,this._selectionTheme.setTheme(e)}setSelectionTheme(e){this._selectionTheme.setTheme(e)}_changeRuntime(e,t,r){this._skeleton=e,this._scene=t,this._activeViewport=r||(t==null?void 0:t.getViewports()[0]),t.findLayerByZIndex(ei)||t.addLayer(new pd(t,[],ei))}getSkeleton(){return this._skeleton}getSelectionDataWithStyle(){const e=this._selectionControls,[t,r]=this._skeleton.getLocation();return e.map(o=>{const s=o.getValue();return s.rangeWithCoord.sheetId=r,s.rangeWithCoord.unitId=t,s})}getSelectionControls(){return this._selectionControls}_addSelectionControlByModelData(e){var l;const t=this._skeleton,r=(l=e.style)!=null?l:Rt(this._selectionTheme),o=this._scene;return e.style=r,this.newSelectionControl(o,t,e)}_clearAllSelectionControls(){const e=this._selectionControls;for(const t of e)t.dispose();this._selectionControls.length=0}_getFreeze(){var t;return(t=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:t.skeleton.getWorksheetConfig().freeze}_getViewportByCell(e,t){if(e===void 0||t===void 0)return null;const r=this._getFreeze();if(!r||r.startRow<=0&&r.startColumn<=0)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(e>r.startRow&&t>r.startColumn)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(e<=r.startRow&&t<=r.startColumn)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP);if(e<=r.startRow&&t>r.startColumn)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(e>r.startRow&&t<=r.startColumn)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)}getActiveRange(){const e=this.getSelectionControls(),t=e&&e[e.length-1].model;return t&&{startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}}setActiveSelectionIndex(e){this._activeControlIndex=e}resetActiveSelectionIndex(){this._activeControlIndex=-1}getActiveSelectionControl(){const e=this.getSelectionControls();if(e)return this._activeControlIndex<0?e[e.length-1]:e[this._activeControlIndex]}endSelection(){var e;this._clearUpdatingListeners(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),(e=this._escapeShortcutDisposable)==null||e.dispose(),this._escapeShortcutDisposable=null}_reset(){var e;this._clearAllSelectionControls(),(e=this._downObserver)==null||e.unsubscribe(),this._downObserver=null}_setupPointerMoveListener(e,t,r,o=T.ScrollTimerType.ALL,s,l){var f,p;let c=0,d=0,u=s,h=l;this._scrollTimer=T.ScrollTimer.create(this._scene,o),this._scrollTimer.startScroll((f=e==null?void 0:e.left)!=null?f:0,(p=e==null?void 0:e.top)!=null?p:0,e);const g=this._scene,S=g.getActiveViewportByCoord(T.Vector2.FromArray([s,l]));this._scenePointerMoveSub=g.onPointerMove$.subscribeEvent(v=>{var H,W,N,U,L,F,B,j,z;const{offsetX:C,offsetY:I}=v,{x:R,y:w}=g.getCoordRelativeToViewport(T.Vector2.FromArray([C,I]));this._movingHandler(R,w,t,r);let M=R,y=w;const P=this.getActiveSelectionControl(),x=this._getFreeze(),A=P==null?void 0:P.model,k=(H=g.getActiveViewportByCoord(T.Vector2.FromArray([C,I])))!=null?H:this._getViewportByCell(A==null?void 0:A.endRow,A==null?void 0:A.endColumn);if((()=>{if(!S||!k||!e)return!1;const K=[T.SHEET_VIEWPORT_KEY.VIEW_MAIN,T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP,T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP,T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT];return K.includes(S.viewportKey)&&K.includes(k.viewportKey)})()){if(!S||!k||!e)return!1;const K=u<e.left&&R>e.left||u>e.left&&R<e.left,ne=h<e.top&&w>e.top||h>e.top&&w<e.top;K&&(c+=1),ne&&(d+=1);const Q=S.viewportKey,se=k.viewportKey;if(Q===T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP)I<e.top&&((W=A==null?void 0:A.endRow)!=null?W:0)<((N=x==null?void 0:x.startRow)!=null?N:0)?y=e.top:ne&&d%2===1&&e.scrollToViewportPos({viewportScrollY:0});else if(Q===T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT)C<e.left&&((U=A==null?void 0:A.endColumn)!=null?U:0)<((L=x==null?void 0:x.startColumn)!=null?L:0)?M=e.left:K&&c%2===1&&e.scrollToViewportPos({viewportScrollX:0});else if(Q===se){let ce=!1,X=!1;Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP?(ce=!0,X=!0):Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP?X=!0:Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT&&(ce=!0),((F=A==null?void 0:A.endRow)!=null?F:0)>((B=x==null?void 0:x.startRow)!=null?B:0)&&(X=!1),((j=A==null?void 0:A.endColumn)!=null?j:0)>((z=x==null?void 0:x.startColumn)!=null?z:0)&&(ce=!1),ce&&(M=e.left),X&&(y=e.top)}else{const ce={x:S.scrollX,y:S.scrollY},X={x:k.scrollX,y:k.scrollY},G=ce.x!==X.x&&K&&c%2===1,q=ce.y!==X.y&&ne&&d%2===1;(G||q)&&(e.scrollToBarPos({x:G?ce.x:void 0,y:q?ce.y:void 0}),G||(M=e.left),q||(y=e.top)),(Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&se===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT||se===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)&&(M=e.left),(Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&se===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP||se===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP)&&(y=e.top)}u=R,h=w}this._scrollTimer.scrolling(M,y,()=>{this._movingHandler(R,w,t,r)})})}attachSelectionWithCoord(e){return Pe(e,this._skeleton)}attachPrimaryWithCoord(e){return $n(this._skeleton,e)}getSelectionCellByPosition(e,t){return this.getCellWithCoordByOffset(e,t)}getCellWithCoordByOffset(e,t,r){const o=this._scene,s=r!=null?r:this._skeleton,l=o.getViewportScrollXY(o.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN)),{scaleX:c,scaleY:d}=o.getAncestorScale();return s.getCellWithCoordByOffset(e,t,c,d,l)}_movingHandler(e,t,r,o){var M,y,P,x,A;const s=this._skeleton,l=this._scene,[c,d]=s.getLocation(),u={startRow:(M=r==null?void 0:r.model.startRow)!=null?M:-1,endRow:(y=r==null?void 0:r.model.endRow)!=null?y:-1,startColumn:(P=r==null?void 0:r.model.startColumn)!=null?P:-1,endColumn:(x=r==null?void 0:r.model.endColumn)!=null?x:-1},h=l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),g=(A=this._getViewportByCell(u.endRow,u.endColumn))!=null?A:h,S=l.getScrollXYInfoByViewport(T.Vector2.FromArray([this._startViewportPosX,this._startViewportPosY]),g),{scaleX:f,scaleY:p}=l.getAncestorScale();o===a.RANGE_TYPE.ROW?e=Number.POSITIVE_INFINITY:o===a.RANGE_TYPE.COLUMN&&(t=Number.POSITIVE_INFINITY);const v=this._skeleton.getCellByOffset(e,t,f,p,S);if(!v)return;let C={startRow:Math.min(v.startRow,this._startRangeWhenPointerDown.startRow),startColumn:Math.min(v.startColumn,this._startRangeWhenPointerDown.startColumn),endRow:Math.max(v.endRow,this._startRangeWhenPointerDown.endRow),endColumn:Math.max(v.endColumn,this._startRangeWhenPointerDown.endColumn)};this._shouldDetectMergedCells&&(C=s.expandRangeByMerge(C));const R=Pe({range:C,primary:void 0,style:null},s);R.rangeWithCoord.unitId=c,R.rangeWithCoord.sheetId=d,R.rangeWithCoord.rangeType=o;const w=u.startRow!==C.startRow||u.startColumn!==C.startColumn||u.endRow!==C.endRow||u.endColumn!==C.endColumn;r!=null&&w&&(r.updateRangeBySelectionWithCoord(R),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_clearUpdatingListeners(){var t,r,o,s,l;this._scene.enableObjectsEvent(),(t=this._scenePointerMoveSub)==null||t.unsubscribe(),this._scenePointerMoveSub=null,(r=this._scenePointerUpSub)==null||r.unsubscribe(),this._scenePointerUpSub=null,(o=this._cancelDownSubscription)==null||o.unsubscribe(),this._cancelDownSubscription=null,(s=this._cancelUpSubscription)==null||s.unsubscribe(),this._cancelUpSubscription=null,(l=this._scrollTimer)==null||l.dispose()}_addEndingListeners(){var r,o,s;const e=this._scene,t=(r=e.getEngine())==null?void 0:r.activeScene;!t||t===e||((o=this._cancelDownSubscription)==null||o.unsubscribe(),this._cancelDownSubscription=null,(s=this._cancelUpSubscription)==null||s.unsubscribe(),this._cancelUpSubscription=null,this._cancelDownSubscription=t.onPointerDown$.subscribeEvent(()=>this._clearUpdatingListeners()),this._cancelUpSubscription=t.onPointerUp$.subscribeEvent(()=>this._clearUpdatingListeners()))}_getSelectionWithCoordByOffset(e,t,r,o,s){const l=this._skeleton;if(l==null)return null;if(this._shouldDetectMergedCells){const C=l==null?void 0:l.getCellWithCoordByOffset(e,t,r,o,s,{firstMatch:!0});if(!C)return;const I=a.convertCellToRange(C);return{primaryWithCoord:C,rangeWithCoord:I}}const{row:c,column:d}=l.getCellIndexByOffset(e,t,r,o,s),u=l.getNoMergeCellWithCoordByIndex(c,d),{startX:h,startY:g,endX:S,endY:f}=u,p={startY:g,endY:f,startX:h,endX:S,startRow:c,endRow:c,startColumn:d,endColumn:d};return{primaryWithCoord:{mergeInfo:p,actualRow:c,actualColumn:d,isMerged:!1,isMergedMainCell:!1,startY:g,endY:f,startX:h,endX:S},rangeWithCoord:p}}_checkClearPreviousControls(e){this.getSelectionControls().length!==0&&(!e.ctrlKey&&!e.shiftKey&&!this._remainLastEnabled||this._singleSelectionEnabled&&!e.shiftKey)&&this._clearAllSelectionControls()}_makeSelectionByTwoCells(e,t,r,o,s){const{actualRow:l,actualColumn:c,mergeInfo:d}=e;this._startRangeWhenPointerDown={...e.mergeInfo};const u=Math.min(l,t.startRow,d.startRow),h=Math.max(l,t.endRow,d.endRow),g=Math.min(c,t.startColumn,d.startColumn),S=Math.max(c,t.endColumn,d.endColumn),p={range:r.expandRangeByMerge({startRow:u,startColumn:g,endRow:h,endColumn:S}),primary:null,style:null},v=Pe(p,r);s.updateRangeBySelectionWithCoord(v)}isSelectionEnabled(){return this.contextService.getContextValue(m.SELECTIONS_ENABLED)}isSelectionDisabled(){return this.contextService.getContextValue(m.SELECTIONS_ENABLED)===!1}inRefSelectionMode(){return this.contextService.getContextValue(m.REF_SELECTIONS_ENABLED)}}function us(n){return{range:{startRow:0,startColumn:0,endRow:n.getRowCount()-1,endColumn:n.getColumnCount()-1,rangeType:a.RANGE_TYPE.ALL},primary:Ai(n).primary,style:null}}function Ai(n){return Xa(n,{startRow:0,startColumn:0,endRow:0,endColumn:0})}function Xa(n,i){const e=n.worksheet.getCellInfoInMergeData(i.startRow,i.startColumn),t=n.worksheet.getCellInfoInMergeData(i.endRow,i.endColumn);return{range:{startRow:e.startRow,startColumn:e.startColumn,endRow:t.endRow,endColumn:t.endColumn,rangeType:a.RANGE_TYPE.NORMAL},primary:{actualRow:e.startRow,actualColumn:e.startColumn,startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn,isMerged:e.isMerged,isMergedMainCell:e.isMergedMainCell},style:null}}var vd=Object.getOwnPropertyDescriptor,Cd=(n,i,e,t)=>{for(var r=t>1?void 0:t?vd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Xs=(n,i)=>(e,t)=>i(e,t,n);exports.SheetSkeletonManagerService=class extends a.Disposable{constructor(e,t,r){super();E(this,"_sheetId","");E(this,"_sheetSkeletonParamStore",new Map);E(this,"_currentSkeleton$",new O.BehaviorSubject(null));E(this,"currentSkeleton$",this._currentSkeleton$.asObservable());E(this,"_currentSkeletonBefore$",new O.BehaviorSubject(null));E(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._context=e,this._injector=t,this._sheetSkService=r,this.disposeWithMe(()=>{this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParamStore.forEach(o=>this.disposeSkeleton(o.sheetId)),this._sheetSkeletonParamStore.clear()}),this._initRemoveSheet()}_initRemoveSheet(){this.disposeWithMe(this._context.unit.sheetDisposed$.subscribe(e=>{this.disposeSkeleton(e.getSheetId())}))}getCurrentSkeleton(){var e;return(e=this.getCurrentParam())==null?void 0:e.skeleton}getCurrent(){return this.getCurrentParam()}getCurrentParam(){return this._getSkeletonParam(this._sheetId)}getSkeleton(e){return this._getSkeleton(e)}getSkeletonParam(e){return this._getSkeletonParam(e)}getWorksheetSkeleton(e){return this.getSkeletonParam(e)}getUnitSkeleton(e,t){const r=this._getSkeletonParam(t);return r!=null&&(r.unitId=e),r}setCurrent(e){this._setCurrent(e.sheetId)}setSkeletonParam(e,t){this._sheetSkService.setSkeleton(t.unitId,e,t.skeleton),this._sheetSkeletonParamStore.set(e,t)}_setCurrent(e){this._sheetId=e;const t=this._getSkeletonParam(e),r=this._context.unitId;if(t!=null)this.reCalculate(t);else{const l=this._context.unit.getSheetBySheetId(e);if(l==null)return;const c=this._context.scene,d=this._buildSkeleton(l,c);this.setSkeletonParam(e,{unitId:r,sheetId:e,skeleton:d,dirty:!1})}const o=this._getSkeletonParam(e);this._currentSkeletonBefore$.next(o),this._currentSkeleton$.next(o)}reCalculate(e){e||(e=this.getCurrentParam()),e!=null&&(e.dirty&&(e.skeleton.makeDirty(!0),e.dirty=!1),e.skeleton.calculate())}makeDirty(e,t=!0){const r=this._getSkeletonParam(e.sheetId);r!=null&&(r.dirty=t)}getOrCreateSkeleton(e){return this.ensureSkeleton(e.sheetId)}ensureSkeleton(e){const t=this._getSkeletonParam(e);if(t)return t.skeleton;const o=this._context.unit.getSheetBySheetId(e);if(!o)return;const s=this._buildSkeleton(o);return this.setSkeletonParam(e,{unitId:this._context.unitId,sheetId:e,skeleton:s,dirty:!1}),s}disposeSkeleton(e){const t=this.getSkeletonParam(e);t&&(t.skeleton.dispose(),this._sheetSkeletonParamStore.delete(e),this._sheetSkService.deleteSkeleton(t.unitId,e))}attachRangeWithCoord(e){const t=this.getCurrentSkeleton();return t?Cn(t,e):null}_getSkeletonParam(e){return this._sheetSkeletonParamStore.get(e)}_getSkeleton(e){const t=this._getSkeletonParam(e);return t?t.skeleton:null}_buildSkeleton(e,t){return this._injector.createInstance(T.SpreadsheetSkeleton,e,this._context.unit.getStyles())}setColumnHeaderSize(e,t,r){var u;if(!e)return;const o=(u=this.getWorksheetSkeleton(t))==null?void 0:u.skeleton;if(!o)return;o.columnHeaderHeight=r,e.scene.getViewports()[0].top=r,e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).setViewportSize({height:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT).setViewportSize({height:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM).setViewportSize({top:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP).setViewportSize({top:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).setViewportSize({height:r});const s=e==null?void 0:e.with(m.SheetsSelectionsService),l=e==null?void 0:e.with(ve),c=s.getCurrentSelections();l.resetSelectionsByModelData(c);const d=this.getUnitSkeleton(e.unitId,t);d&&(d.commandId=xi.id,this._currentSkeleton$.next(d))}setRowHeaderSize(e,t,r){var f;const o=(f=this.getWorksheetSkeleton(t))==null?void 0:f.skeleton;if(!e||!o)return;o.rowHeaderWidth=r;const s=e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).width||46,l=r-s,c=e.scene.getViewports()[0].left;e.scene.getViewports()[0].left=c+l,e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM).setViewportSize({width:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP).setViewportSize({width:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT).setViewportSize({left:r});const d=e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).left||0;e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).setViewportSize({left:d+l}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).setViewportSize({width:r});const u=e==null?void 0:e.with(m.SheetsSelectionsService),h=e==null?void 0:e.with(ve),g=u.getCurrentSelections();h.resetSelectionsByModelData(g);const S=this.getCurrent();S&&(S.commandId=Oi.id,this._currentSkeleton$.next(S))}};exports.SheetSkeletonManagerService=Cd([Xs(1,a.Inject(a.Injector)),Xs(2,a.Inject(m.SheetSkeletonService))],exports.SheetSkeletonManagerService);function gt(){const n=_.useDependency(a.IUniverInstanceService),i=_.useObservable(()=>n.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return i!=null?i:null}function _d(n){return _.useObservable(()=>{var e;return(e=n==null?void 0:n.activeSheet$)!=null?e:O.of(null)},void 0,void 0,[n])}function Id(){const n=_.useDependency(a.IUniverInstanceService);return _.useObservable(()=>O.merge([n.getTypeOfUnitAdded$(a.UniverInstanceType.UNIVER_SHEET),n.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET)]).pipe(O.map(()=>n.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET)),O.startWith(n.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET))),[],void 0,[n])}const bd="SheetUI";var hs=(n=>(n.FILTER_PANEL_EMBED_POINT="filter-panel-embed-point",n.SHEETS_FOOTER="sheets-footer",n.FORMULA_AUX="formula-aux",n))(hs||{});const mt="sheets-ui.config",Ho={formulaBar:!0,statusBarStatistic:!0,maxAutoHeightCount:1e3};var Rd=Object.getOwnPropertyDescriptor,Ed=(n,i,e,t)=>{for(var r=t>1?void 0:t?Rd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Un=(n,i)=>(e,t)=>i(e,t,n);const ms=["ff","fs","tr","tb"];exports.AutoHeightController=class extends a.Disposable{constructor(i,e,t,r,o){super(),this._renderManagerService=i,this._sheetInterceptorService=e,this._selectionManagerService=t,this._univerInstanceService=r,this._configService=o,this._initialize()}_getRangesScope(i){let e,t;for(const{startRow:r,endRow:o}of i)e=e===void 0?r:Math.min(e,r),t=t===void 0?o:Math.max(t,o);return t-e+1}getUndoRedoParamsOfAutoHeight(i,e){var I;const{_univerInstanceService:t,_configService:r}=this,o=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=o.getUnitId();let l=o.getActiveSheet(),c=l.getSheetId();if(e){const R=m.getSheetCommandTarget(t,{unitId:s,subUnitId:e});R&&(l=R.worksheet,c=l.getSheetId())}const u=this._renderManagerService.getRenderById(s).with(exports.SheetSkeletonManagerService).ensureSkeleton(c);if(!u)return{redos:[],undos:[]};const h=r.getConfig(mt);let g=i;Array.isArray(i)||(i&&i.startRow!==void 0&&i.startRow!==void 0?g=[i]:g=[]);const S=this._getRangesScope(g);if(((I=h==null?void 0:h.maxAutoHeightCount)!=null?I:1e3)<S)return{redos:[],undos:[]};const p=u.calculateAutoHeightInRange(i),v={subUnitId:c,unitId:s,rowsAutoHeightInfo:p},C=m.SetWorksheetRowAutoHeightMutationFactory(v,l);return{undos:[{id:m.SetWorksheetRowAutoHeightMutation.id,params:C}],redos:[{id:m.SetWorksheetRowAutoHeightMutation.id,params:v}]}}_initialize(){const{_sheetInterceptorService:i,_selectionManagerService:e}=this;this.disposeWithMe(i.interceptCommand({getMutations:t=>{if(t.id===m.SetRangeValuesCommand.id){const r=t.params;return this.getUndoRedoParamsOfAutoHeight(r.range,r.subUnitId)}return{redos:[],undos:[]}}})),this.disposeWithMe(i.interceptCommand({getMutations:t=>t.id!==m.SetWorksheetRowIsAutoHeightCommand.id?{redos:[],undos:[]}:this.getUndoRedoParamsOfAutoHeight(t.params.ranges,t.params.subUnitId)})),this.disposeWithMe(i.interceptCommand({getMutations:t=>{var o,s;if(t.id!==m.SetStyleCommand.id)return{redos:[],undos:[]};if(!ms.includes((o=t.params)==null?void 0:o.style.type))return{redos:[],undos:[]};const r=(s=e.getCurrentSelections())==null?void 0:s.map(l=>l.range);return r!=null&&r.length?this.getUndoRedoParamsOfAutoHeight(r,t.params.subUnitId):{redos:[],undos:[]}}})),this.disposeWithMe(i.interceptAfterCommand({getMutations:t=>{if(t.id===m.MoveRangeCommand.id){const r=t.params;return this.getUndoRedoParamsOfAutoHeight([r.fromRange,r.toRange])}if(t.id===m.ReorderRangeCommand.id){const r=t.params;return this.getUndoRedoParamsOfAutoHeight([r.range])}return{redos:[],undos:[]}}}))}};exports.AutoHeightController=Ed([Un(0,T.IRenderManagerService),Un(1,a.Inject(m.SheetInterceptorService)),Un(2,a.Inject(m.SheetsSelectionsService)),Un(3,a.Inject(a.IUniverInstanceService)),Un(4,a.IConfigService)],exports.AutoHeightController);function Et(n){const{rows:i,cols:e}=n;return{startRow:i[0],endRow:i[i.length-1],startColumn:e[0],endColumn:e[e.length-1]}}function Gt(n){let i=[],e=[];const t=[];return n.forEach(r=>{i=i.concat(r.rows),e=e.concat(r.cols)}),i=Array.from(new Set(i)).sort((r,o)=>r-o),e=Array.from(new Set(e)).sort((r,o)=>r-o),n.forEach(r=>{t.push({startRow:i.findIndex(o=>o===r.rows[0]),endRow:i.findIndex(o=>o===r.rows[r.rows.length-1]),startColumn:e.findIndex(o=>o===r.cols[0]),endColumn:e.findIndex(o=>o===r.cols[r.cols.length-1])})}),{ranges:t,mapFunc:(r,o)=>({row:i[r],col:e[o]})}}function wd(n){const i=new a.ObjectMatrix;return n.forEach(e=>{const{rows:t,cols:r}=e;t.forEach(o=>{r.forEach(s=>{i.setValue(o,s,{v:null,p:null,f:null,si:null,custom:null})})})}),i.getData()}const Vo={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},ti=["零","一","二","三","四","五","六","七","八","九"],Ys=["","万","亿","万亿","亿亿"],Td=["","十","百","千"],Ya={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function ut(n){if(!n)return 0;let i=0,e=0,t=0,r=!1;const o=n.split("");for(let s=0;s<o.length;s++){const l=Vo[o[s]];if(typeof l<"u")t=l,s===o.length-1&&(e+=t);else{const c=Ya[o[s]],d=c.value;r=c.secUnit,r?(e=(e+t)*d,i+=e,e=0):e+=t*d,t=0}}return i+e}function yd(n){let i="",e="",t=0,r=!0;for(;n>0;){const o=n%10;o===0?r||(r=!0,e=ti[o]+e):(r=!1,i=ti[o],i+=Td[t],e=i+e),t++,n=Math.floor(n/10)}return e}function Md(n){let i=0,e="",t="",r=!1;if(n===0)return ti[0];for(;n>0;){const o=n%1e4;r&&(t=ti[0]+t),e=yd(o),e+=o!==0?Ys[i]:Ys[0],t=e+t,r=o<1e3&&o>0,n=Math.floor(n/1e4),i++}return t}function Pd(n){if(!n)return!1;let i=!0;if(n)if(n.length===1)n==="日"||n in Vo?i=!0:i=!1;else{const e=n.split("");for(let t=0;t<e.length;t++)if(!(e[t]in Vo||e[t]in Ya)){i=!1;break}}return i}function Vr(n){if(!n)return{isExtendNumber:!1};const i=/0|([1-9]+[0-9]*)/g,e=i.test(n);if(e){const t=n.match(i);if(t&&t.length>0){const r=t[t.length-1],o=n.lastIndexOf(r),s=n.substr(0,o),l=n.substr(o+r.length);return{isExtendNumber:!0,matchTxt:Number(r),beforeTxt:s,afterTxt:l}}return{isExtendNumber:!1}}return{isExtendNumber:e}}function Od(n){let i;return n.length===2&&(n==="周一"||n==="周二"||n==="周三"||n==="周四"||n==="周五"||n==="周六"||n==="周日")?i=!0:i=!1,i}function xd(n){let i;return n.length===3&&(n==="星期一"||n==="星期二"||n==="星期三"||n==="星期四"||n==="星期五"||n==="星期六"||n==="星期日")?i=!0:i=!1,i}function Ad(n,i){let e=0;for(let t=0;t<n.length&&n[t]<i;t++)e++;return e}function dr(n){let i=!0;const e=n[1]-n[0];for(let t=1;t<n.length;t++)if(n[t]-n[t-1]!==e){i=!1;break}return i}function kd(n,i,e){const t=[],r=Math.floor(i/n),o=i%n;let s=0;if(r>0){for(let l=0;l<r;l++)for(let c=0;c<e.length;c++)t[e[c]+l*n]=s,s++;for(let l=0;l<e.length&&e[l]<o;l++)t[e[l]+n*r]=s,s++}else for(let l=0;l<e.length&&e[l]<o;l++)t[e[l]]=s,s++;return t}function Ft(n,i){const e=[];for(let t=1;t<=i;t++){const r=(t-1)%n.length,o=a.Tools.deepClone(n[r]);jt(o),e.push({v:null,s:null,p:null,f:null,si:null,t:null,...o})}return e}function Dd(n,i){var t;const e=[];for(let r=1;r<=i;r++){const o=(r-1)%n.length,s={s:(t=n[o])==null?void 0:t.s};e.push(s)}return e}function Nd(n){let i=!0;const e=n[1]/n[0];for(let t=1;t<n.length;t++)if(n[t]/n[t-1]!==e){i=!1;break}return i}function Hd(n){const i=[];for(let e=1;e<=n;e++)i.push(e);return i}function ni(n,i,e){var o,s,l,c;const t=[],r=[];for(let d=0;d<n.length;d++)r.push(Number((o=n[d])==null?void 0:o.v));if(n.length>2&&Nd(r))for(let d=1;d<=i;d++){const u=(d-1)%n.length,h=a.Tools.deepClone(n[u]);jt(h);const g=Number((s=n[n.length-1])==null?void 0:s.v)*(Number((l=n[1])==null?void 0:l.v)/Number((c=n[0])==null?void 0:c.v))**d;h&&(qs(h)&&(h.v=g),t.push(h))}else{const d=Hd(n.length);for(let u=1;u<=i;u++){const h=(u-1)%n.length,g=a.Tools.deepClone(n[h]);jt(g);const S=e===a.Direction.DOWN||e===a.Direction.RIGHT,f=Vd(n.length+u,r,d,S);g&&(qs(g)&&(g.v=f),t.push(g))}}return t}function Vd(n,i,e,t=!0){function r(h){let g=0;for(let S=0;S<h.length;S++)g+=h[S];return g/h.length}const o=r(e),s=r(i);let l=0,c=0;for(let h=0;h<e.length;h++)l+=(e[h]-o)*(i[h]-s),c+=(e[h]-o)*(e[h]-o);let d;c===0?d=t?1:-1:d=l/c;const u=s-d*o;return Math.round((u+d*n)*1e5)/1e5}function Gs(n,i,e){var o;const t=[],r=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=i;s++){const l=(s-1)%n.length,c=a.Tools.deepClone(n[l]);jt(c);const d=`${(o=n[n.length-1])==null?void 0:o.v}`,u=d==null?void 0:d.match(r),h=u==null?void 0:u[u.length-1],g=Math.abs(Number(h)+e*s);if(!d||!h)continue;const S=d.lastIndexOf(h),f=d.substr(0,S)+g.toString()+d.substr(S+h.length);c&&(c.v=f,t.push(c))}return t}function _n(n,i,e,t=0){var l,c;const r=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(t>=r.length)return[];const o=r[t],s=[];for(let d=1;d<=i;d++){const u=(d-1)%n.length,h=a.Tools.deepClone(n[u]);jt(h);let g=0;if(((l=n[n.length-1])==null?void 0:l.v)===o[0])g=7+e*d;else{const f=`${(c=n[n.length-1])==null?void 0:c.v}`;if(f){const p=f.substr(f.length-1,1);g=ut(p)+e*d}}g<0&&(g=Math.ceil(Math.abs(g)/7)*7+g);const S=g%7;h&&(h.v=o[S],s.push(h))}return s}function Zs(n,i,e){var r;const t=[];for(let o=1;o<=i;o++){const s=(o-1)%n.length,l=a.Tools.deepClone(n[s]);jt(l);const c=`${(r=n[n.length-1])==null?void 0:r.v}`,d=ut(c)+e*o;let u;d<=0?u="零":u=Md(d),l&&(l.v=u,t.push(l))}return t}const qn={enWeek1:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],enWeek2:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],enMonth1:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],enMonth2:["January","February","March","April","May","June","July","August","September","October","November","December"],chnMonth1:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],chnMonth2:["正月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","腊月"],chHour1:["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"],chHour2:["子时","丑时","寅时","卯时","辰时","巳时","午时","未时","申时","酉时","戌时","亥时"],chYear1:["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"],chSeason1:["春","夏","秋","冬"],chSeason2:["春季","夏季","秋季","冬季"]};function Wd(n){let i=!1;return Object.keys(qn).forEach(e=>{qn[e].includes(n)&&(i=!0)}),i}function ji(n){let i="";const e=[];return Object.keys(qn).forEach(t=>{qn[t].includes(n)&&(i=t,e.push(...qn[t]))}),{name:i,series:e}}function Ks(n,i,e,t){var s;const r=t.length,o=[];for(let l=1;l<=i;l++){const c=(l-1)%n.length,d=a.Tools.deepClone(n[c]);jt(d);const u=`${(s=n[n.length-1])==null?void 0:s.v}`;let h=t.indexOf(u)+e*l;h<0&&(h+=Math.abs(e)*r);const g=h%r;d&&(d.v=t[g],o.push(d))}return o}function Ud(n,i){const e=[];let t;if(i.startRow<n.startRow)t=a.Direction.UP;else if(i.endRow>n.endRow)t=a.Direction.DOWN;else if(i.startColumn<n.startColumn)t=a.Direction.LEFT;else if(i.endColumn>n.endColumn)t=a.Direction.RIGHT;else return[];if(t===a.Direction.DOWN||t===a.Direction.UP){const r=n.endRow-n.startRow+1,o=i.endRow-i.startRow+1,s=Math.floor(o/r),l=o%r,c={startRow:0,startColumn:0,endRow:n.endRow-n.startRow,endColumn:n.endColumn-n.startColumn};if(t===a.Direction.DOWN){for(let d=0;d<s;d++)e.push({repeatStartCell:{row:n.startRow+(d+1)*r,col:n.startColumn},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow+(s+1)*r,col:n.startColumn},relativeRange:{startRow:0,startColumn:0,endRow:l-1,endColumn:n.endColumn-n.startColumn}})}else{for(let d=0;d<s;d++)e.push({repeatStartCell:{row:n.startRow-(d+1)*r,col:n.startColumn},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow-(s+1)*r,col:n.startColumn},relativeRange:{startRow:r-l,endRow:r-1,startColumn:0,endColumn:n.endColumn-n.startColumn}})}}if(t===a.Direction.RIGHT||t===a.Direction.LEFT){const r=n.endColumn-n.startColumn+1,o=i.endColumn-i.startColumn+1,s=Math.floor(o/r),l=o%r,c={startRow:0,startColumn:0,endRow:n.endRow-n.startRow,endColumn:n.endColumn-n.startColumn};if(t===a.Direction.RIGHT){for(let d=0;d<s;d++)e.push({repeatStartCell:{row:n.startRow,col:n.startColumn+(d+1)*r},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow,col:n.startColumn+(s+1)*r},relativeRange:{startRow:0,startColumn:0,endRow:n.endRow-n.startRow,endColumn:l-1}})}else{for(let d=0;d<s;d++)e.push({repeatStartCell:{row:n.startRow,col:n.startColumn-(d+1)*r},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow,col:n.startColumn-(s+1)*r},relativeRange:{startRow:0,startColumn:r-l,endRow:n.endRow-n.startRow,endColumn:r-1}})}}return e}function qs(n){return!(a.isFormulaString(n.f)||a.isFormulaId(n.si)||n.t===a.CellValueType.BOOLEAN)}function jt(n){n&&"custom"in n&&delete n.custom}var un=(n=>(n.Append="APPEND",n.Default="DEFAULT",n.Only="ONLY",n))(un||{}),Ie=(n=>(n.NUMBER="number",n.DATE="date",n.EXTEND_NUMBER="extendNumber",n.CHN_NUMBER="chnNumber",n.CHN_WEEK2="chnWeek2",n.CHN_WEEK3="chnWeek3",n.LOOP_SERIES="loopSeries",n.FORMULA="formula",n.OTHER="other",n))(Ie||{}),le=(n=>(n.COPY="COPY",n.SERIES="SERIES",n.ONLY_FORMAT="ONLY_FORMAT",n.NO_FORMAT="NO_FORMAT",n))(le||{});const Ld={type:Ie.DATE,priority:1100,match:(n,i)=>{var e;if(n!=null&&n.f||n!=null&&n.si)return!1;if((typeof(n==null?void 0:n.v)=="number"||(n==null?void 0:n.t)===a.CellValueType.NUMBER)&&n.s){if(typeof n.s=="string"){const r=i.get(a.IUniverInstanceService).getFocusedUnit().getStyles().get(n.s),o=(e=r==null?void 0:r.n)==null?void 0:e.pattern;if(o)return a.numfmt.getInfo(o).isDate}else if(n.s.n&&a.numfmt.getInfo(n.s.n.pattern).isDate)return!0}return!1},isContinue:(n,i)=>n.type===Ie.DATE,applyFunctions:{[le.SERIES]:(n,i,e)=>{const{data:t}=n;return e===a.Direction.LEFT||e===a.Direction.UP?(t.reverse(),ni(t,i,e).reverse()):ni(t,i,e)}}},Bd={type:Ie.NUMBER,priority:1e3,match:n=>typeof(n==null?void 0:n.v)=="number"||(n==null?void 0:n.t)===a.CellValueType.NUMBER,isContinue:(n,i)=>n.type===Ie.NUMBER,applyFunctions:{[le.SERIES]:(n,i,e)=>{const{data:t}=n;return e===a.Direction.LEFT||e===a.Direction.UP?(t.reverse(),ni(t,i,e).reverse()):ni(t,i,e)}}},Ga={type:Ie.OTHER,priority:0,match:()=>!0,isContinue:(n,i)=>n.type===Ie.OTHER},Fd={type:Ie.EXTEND_NUMBER,priority:900,match:n=>Vr(`${n==null?void 0:n.v}`||"").isExtendNumber,isContinue:(n,i)=>{var e;if(n.type===Ie.EXTEND_NUMBER){const{beforeTxt:t,afterTxt:r}=Vr(`${(e=n.cellData)==null?void 0:e.v}`||""),{beforeTxt:o,afterTxt:s}=Vr(`${i==null?void 0:i.v}`||"");if(t===o&&r===s)return!0}return!1},applyFunctions:{[le.SERIES]:(n,i,e)=>{var l;const{data:t}=n,r=e===a.Direction.UP||e===a.Direction.LEFT;let o;if(t.length===1)return o=r?-1:1,Ue(Gs(t,i,o),r);const s=[];for(let c=0;c<t.length;c++){const d=`${(l=t[c])==null?void 0:l.v}`;d&&s.push(Number(Vr(d).matchTxt))}return r&&(t.reverse(),s.reverse()),dr(s)?(o=s[1]-s[0],Ue(Gs(t,i,o),r)):Ft(t,i)}}},jd={type:Ie.CHN_NUMBER,priority:830,match:n=>!!Pd(`${n==null?void 0:n.v}`||""),isContinue:(n,i)=>n.type===Ie.CHN_NUMBER,applyFunctions:{[le.SERIES]:(n,i,e)=>{var c,d,u;const{data:t}=n,r=e===a.Direction.LEFT||e===a.Direction.UP;if(t.length===1){const h=`${(c=t[0])==null?void 0:c.v}`;let g;return r?g=-1:g=1,h&&(h==="日"||ut(h)<7)?Ue(_n(t,i,g),r):Ue(Zs(t,i,g),r)}let o=!1;for(let h=0;h<t.length;h++)if(((d=t[h])==null?void 0:d.v)==="日"){o=!0;break}const s=[];let l=0;for(let h=0;h<t.length;h++){const g=`${(u=t[h])==null?void 0:u.v}`;g==="日"?h===0?s.push(0):(l++,s.push(l*7)):o&&ut(g)>0&&ut(g)<7?s.push(ut(g)+l*7):s.push(ut(g))}if(r&&(t.reverse(),s.reverse()),dr(s)){if(o||s[s.length-1]<6&&s[0]>0||s[0]<6&&s[s.length-1]>0){const g=s[1]-s[0];return Ue(_n(t,i,g),r)}const h=s[1]-s[0];return Ue(Zs(t,i,h),r)}return Ft(t,i)}}},zd={type:Ie.CHN_WEEK2,priority:820,match:n=>!!Od(`${n==null?void 0:n.v}`||""),isContinue:(n,i)=>n.type===Ie.CHN_WEEK2,applyFunctions:{[le.SERIES]:(n,i,e)=>{var l;const{data:t}=n,r=e===a.Direction.LEFT||e===a.Direction.UP;if(t.length===1){let c;return r?c=-1:c=1,Ue(_n(t,i,c,1),r)}const o=[];let s=0;for(let c=0;c<t.length;c++){const d=`${(l=t[c])==null?void 0:l.v}`,u=d==null?void 0:d.substr(d.length-1,1);d==="周日"?c===0?o.push(0):(s++,o.push(s*7)):o.push(ut(u)+s*7)}if(r&&(t.reverse(),o.reverse()),dr(o)){const c=o[1]-o[0];return Ue(_n(t,i,c,1),r)}return Ft(t,i)}}},Xd={type:Ie.CHN_WEEK3,priority:810,match:n=>xd(`${n==null?void 0:n.v}`||""),isContinue:(n,i)=>n.type===Ie.CHN_WEEK3,applyFunctions:{[le.SERIES]:(n,i,e)=>{var l;const{data:t}=n,r=e===a.Direction.LEFT||e===a.Direction.UP;if(t.length===1){let c;return r?c=-1:c=1,Ue(_n(t,i,c,2),r)}const o=[];let s=0;for(let c=0;c<t.length;c++){const d=`${(l=t[c])==null?void 0:l.v}`;if(d){const u=d.substr(d.length-1,1);d==="星期日"?c===0?o.push(0):(s++,o.push(s*7)):o.push(ut(u)+s*7)}}if(r&&(t.reverse(),o.reverse()),dr(o)){const c=o[1]-o[0];return Ue(_n(t,i,c,2),r)}return Ft(t,i)}}},Yd={type:Ie.LOOP_SERIES,priority:800,match:n=>Wd(`${n==null?void 0:n.v}`||""),isContinue:(n,i)=>{var e;return n.type===Ie.LOOP_SERIES?ji(`${(e=n.cellData)==null?void 0:e.v}`||"").name===ji(`${i==null?void 0:i.v}`||"").name:!1},applyFunctions:{[le.SERIES]:(n,i,e)=>{var c,d;const{data:t}=n,r=e===a.Direction.LEFT||e===a.Direction.UP,{series:o}=ji(`${(c=t[0])==null?void 0:c.v}`||"");if(t.length===1){let u;return r?u=-1:u=1,Ue(Ks(t,i,u,o),r)}const s=[];let l=0;for(let u=0;u<t.length;u++){const h=`${(d=t[u])==null?void 0:d.v}`;h&&(h===o[0]?u===0?s.push(0):(l++,s.push(l*o.length)):s.push(o.indexOf(h)+l*7))}if(r&&(t.reverse(),s.reverse()),dr(s)){const u=s[1]-s[0];return Ue(Ks(t,i,u,o),r)}return Ft(t,i)}}};function Ue(n,i){return i?n.reverse():n}var Gd=Object.getOwnPropertyDescriptor,Zd=(n,i,e,t)=>{for(var r=t>1?void 0:t?Gd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},rn=(n,i)=>(e,t)=>i(e,t,n);exports.AutoFillService=class extends a.Disposable{constructor(e,t,r,o,s,l){super();E(this,"_rules",[]);E(this,"_hooks",[]);E(this,"_applyType$",new O.BehaviorSubject(le.SERIES));E(this,"_isFillingStyle",!0);E(this,"_prevUndos",[]);E(this,"_autoFillLocation$",new O.BehaviorSubject(null));E(this,"autoFillLocation$",this._autoFillLocation$.asObservable());E(this,"_showMenu$",new O.BehaviorSubject(!1));E(this,"showMenu$",this._showMenu$.asObservable());E(this,"_direction",a.Direction.DOWN);E(this,"applyType$",this._applyType$.asObservable());E(this,"_menu$",new O.BehaviorSubject([{label:"autoFill.copy",value:le.COPY,disable:!1},{label:"autoFill.series",value:le.SERIES,disable:!1},{label:"autoFill.formatOnly",value:le.ONLY_FORMAT,disable:!1},{label:"autoFill.noFormat",value:le.NO_FORMAT,disable:!1}]));E(this,"menu$",this._menu$.asObservable());this._commandService=e,this._undoRedoService=t,this._renderManagerService=r,this._univerInstanceService=o,this._selectionManagerService=s,this._injector=l,this._init()}_init(){this._rules=[Ld,Bd,Fd,jd,zd,Xd,Yd,Ga].sort((e,t)=>t.priority-e.priority),this._isFillingStyle=!0}_getOneByPriority(e){return e.length<=0?[]:[e.reduce((r,o)=>(o.priority||0)>(r.priority||0)?o:r,e[0])]}_initPrevUndo(){this._prevUndos=[]}async triggerAutoFill(e,t,r,o){var S;if(r.startColumn===o.startColumn&&r.startRow===o.startRow&&r.endColumn===o.endColumn&&r.endRow===o.endRow)return!1;if(o.endColumn<r.endColumn&&o.endColumn>r.startColumn)return this._commandService.executeCommand(In.id,{clearRange:{startRow:o.startRow,endRow:o.endRow,startColumn:o.endColumn+1,endColumn:r.endColumn},selectionRange:o});if(o.endRow<r.endRow&&o.endRow>r.startRow)return this._commandService.executeCommand(In.id,{clearRange:{startRow:o.endRow+1,endRow:r.endRow,startColumn:o.startColumn,endColumn:o.endColumn},selectionRange:o});const s={startRow:o.startRow,endRow:o.endRow,startColumn:o.startColumn,endColumn:o.endColumn};let l=null;if(o.startRow<r.startRow)l=a.Direction.UP,s.endRow=r.startRow-1;else if(o.endRow>r.endRow)l=a.Direction.DOWN,s.startRow=r.endRow+1;else if(o.startColumn<r.startColumn)l=a.Direction.LEFT,s.endColumn=r.startColumn-1;else if(o.endColumn>r.endColumn)l=a.Direction.RIGHT,s.startColumn=r.endColumn+1;else return!1;this.direction=l;const c=this._injector.invoke(f=>m.rangeToDiscreteRange(r,f)),d=this._injector.invoke(f=>m.rangeToDiscreteRange(s,f));if(!c||!d)return!1;this.autoFillLocation={source:c,target:d,unitId:e,subUnitId:t};const u=[];this.getActiveHooks().forEach(f=>{var v;const p=(v=f==null?void 0:f.onBeforeFillData)==null?void 0:v.call(f,{source:c,target:d,unitId:e,subUnitId:t},l);p&&u.unshift(p)}),this._initPrevUndo();for(let f=0;f<u.length;f++){const p=this.menu.find(v=>v.value===u[f]);if(p&&!p.disable)return this.fillData(u[f])}const g=(S=this.menu.find(f=>f.disable===!1))==null?void 0:S.value;return g?this.fillData(g):!1}addHook(e){if(this._hooks.find(t=>t.id===e.id))throw new Error(`Add hook failed, hook id '${e.id}' already exist!`);return e.priority===void 0&&(e.priority=0),e.type===void 0&&(e.type=un.Append),this._hooks.push(e),a.toDisposable(()=>{const t=this._hooks.findIndex(r=>r===e);t>-1&&this._hooks.splice(t,1)})}registerRule(e){if(this._rules.find(r=>r.type===e.type))throw new Error(`Registry rule failed, type '${e.type}' already exist!`);const t=this._rules.findIndex(r=>r.priority<e.priority);this._rules.splice(t===-1?this._rules.length:t,0,e)}getRules(){return this._rules}getAllHooks(){return this._hooks}getActiveHooks(){const{source:e,target:t,unitId:r,subUnitId:o}=this.autoFillLocation||{};if(!e||!t||!r||!o)return[];const s=this._hooks.filter(u=>{var h;return!((h=u.disable)!=null&&h.call(u,{source:e,target:t,unitId:r,subUnitId:o},this._direction,this.applyType))}),l=s.filter(u=>u.type===un.Only);if(l.length>0)return this._getOneByPriority(l);const c=this._getOneByPriority(s.filter(u=>u.type===un.Default)),d=s.filter(u=>u.type===un.Append)||[];return[...c,...d]}get applyType(){return this._applyType$.getValue()}set applyType(e){this._applyType$.next(e)}get menu(){return this._menu$.getValue()}get direction(){return this._direction}set direction(e){this._direction=e}isFillingStyle(){return this._isFillingStyle}setFillingStyle(e){this._isFillingStyle=e}get autoFillLocation(){return this._autoFillLocation$.getValue()}set autoFillLocation(e){this._autoFillLocation$.next(e)}setDisableApplyType(e,t){this._menu$.next(this._menu$.getValue().map(r=>r.value===e?{...r,disable:t}:r))}setShowMenu(e){this._showMenu$.next(e)}fillData(e){var C,I,R;this.applyType=e;const{source:t,target:r,unitId:o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),subUnitId:s=(C=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:C.getSheetId()}=this.autoFillLocation||{};if(!t||!r||!o||!s)return!1;const l=this.direction;this._prevUndos.length>0&&this._prevUndos.forEach(w=>{this._commandService.syncExecuteCommand(w.id,w.params)}),this._prevUndos=[];const c=a.Rectangle.union(Et(t),Et(r)),d=this.getActiveHooks(),u=this._univerInstanceService.getUnit(o,a.UniverInstanceType.UNIVER_SHEET);this._commandService.syncExecuteCommand(m.SetSelectionsOperation.id,{selections:[{primary:{...(R=(I=this._selectionManagerService.getCurrentLastSelection())==null?void 0:I.primary)!=null?R:c},range:{...c,rangeType:a.RANGE_TYPE.NORMAL}}],unitId:o,subUnitId:s});const h=[],g=[];d.forEach(w=>{var P;const{undos:M,redos:y}=((P=w.onFillData)==null?void 0:P.call(w,{source:t,target:r,unitId:o,subUnitId:s},l,e))||{};M&&h.push(...M),y&&g.push(...y)});const S=g.every(w=>this._commandService.syncExecuteCommand(w.id,w.params)),f=[];e!==le.NO_FORMAT&&g.forEach(w=>{if(w.id===m.SetRangeValuesMutation.id){const{cellValue:M}=w.params;new a.ObjectMatrix(M).forValue((P,x,A)=>{const k=Object.keys(u.getStyles().get(A==null?void 0:A.s)||{});(A!=null&&A.p||k.length&&ms.some(D=>k.includes(D)))&&f.push({startRow:P,endRow:P,startColumn:x,endColumn:x})})}});const p=this._getAutoHeightUndoRedos(o,s,f);return p.redos.every(w=>this._commandService.syncExecuteCommand(w.id,w.params))&&(h.push(...p.undos),g.push(...p.redos)),S&&(this._prevUndos=h,this._undoRedoService.pushUndoRedo({unitID:o,undoMutations:h,redoMutations:g})),d.forEach(w=>{var M;(M=w.onAfterFillData)==null||M.call(w,{source:t,target:r,unitId:o,subUnitId:s},l,e)}),this.setShowMenu(!0),!0}_getAutoHeightUndoRedos(e,t,r){var h,g;const o=(h=this._renderManagerService.getRenderById(e))==null?void 0:h.with(exports.SheetSkeletonManagerService),s=(g=o==null?void 0:o.getCurrentParam())==null?void 0:g.skeleton;if(!s)return{redos:[],undos:[]};const l=s.calculateAutoHeightInRange(r),c={subUnitId:t,unitId:e,rowsAutoHeightInfo:l},d=s.worksheet,u=m.SetWorksheetRowAutoHeightMutationFactory(c,d);return{undos:[{id:m.SetWorksheetRowAutoHeightMutation.id,params:u}],redos:[{id:m.SetWorksheetRowAutoHeightMutation.id,params:c}]}}};exports.AutoFillService=Zd([rn(0,a.ICommandService),rn(1,a.IUndoRedoService),rn(2,T.IRenderManagerService),rn(3,a.Inject(a.IUniverInstanceService)),rn(4,a.Inject(m.SheetsSelectionsService)),rn(5,a.Inject(a.Injector))],exports.AutoFillService);const wt=a.createIdentifier("univer.auto-fill-service"),_t={type:a.CommandType.COMMAND,id:"sheet.command.auto-fill",handler:async(n,i)=>{const e=n.get(wt),t=n.get(a.IUniverInstanceService),{sourceRange:r,targetRange:o}=i,s=m.getSheetCommandTarget(t);if(!s)return!1;const{subUnitId:l,unitId:c}=s;return e.triggerAutoFill(c,l,r,o)}},In={id:"sheet.command.auto-clear-content",type:a.CommandType.COMMAND,handler:async(n,i)=>{const e=n.get(a.IUniverInstanceService),t=n.get(a.ICommandService),r=n.get(a.IUndoRedoService),o=n.get(m.SheetInterceptorService),s=m.getSheetCommandTarget(e);if(!s)return!1;const{unitId:l,subUnitId:c}=s,{clearRange:d,selectionRange:u}=i,h={subUnitId:c,unitId:l,cellValue:m.generateNullCellValue([d])},g=m.SetRangeValuesUndoMutationFactory(n,h),{startColumn:S,startRow:f}=u,p={selections:[{primary:{startColumn:S,startRow:f,endColumn:S,endRow:f,actualRow:f,actualColumn:S,isMerged:!1,isMergedMainCell:!1},range:{...u}}],unitId:l,subUnitId:c};if(t.executeCommand(m.SetSelectionsOperation.id,p),t.syncExecuteCommand(m.SetRangeValuesMutation.id,h)){const C=o.afterCommandExecute({id:m.SetRangeValuesMutation.id,params:h});return a.sequenceExecute(C.redos,t),r.pushUndoRedo({unitID:l,undoMutations:[{id:m.SetRangeValuesMutation.id,params:g},...C.undos],redoMutations:[{id:m.SetRangeValuesMutation.id,params:h},...C.redos]}),!0}return!1}},ur={id:"sheet.command.refill",type:a.CommandType.COMMAND,handler:async(n,i)=>n.get(wt).fillData(i.type)};var Kd=Object.getOwnPropertyDescriptor,qd=(n,i,e,t)=>{for(var r=t>1?void 0:t?Kd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Pt=(n,i)=>(e,t)=>i(e,t,n);exports.EditorBridgeService=class extends a.Disposable{constructor(e,t,r,o,s,l,c){super();E(this,"_editorUnitId",a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);E(this,"_editorIsDirty",!1);E(this,"_isDisabled",!1);E(this,"_visible",{visible:!1,eventType:T.DeviceInputEventType.Dblclick,unitId:""});E(this,"_currentEditCell",null);E(this,"_currentEditCellState",null);E(this,"_currentEditCellLayout",null);E(this,"_currentEditCellState$",new O.BehaviorSubject(null));E(this,"currentEditCellState$",this._currentEditCellState$.asObservable());E(this,"_currentEditCellLayout$",new O.BehaviorSubject(null));E(this,"currentEditCellLayout$",this._currentEditCellLayout$.asObservable());E(this,"currentEditCell$",this._currentEditCellState$.pipe(O.switchMap(e=>this._currentEditCellLayout$.pipe(O.map(t=>e&&t?{...e,...t}:null)))));E(this,"_visible$",new O.BehaviorSubject(this._visible));E(this,"visible$",this._visible$.asObservable());E(this,"_afterVisible$",new O.BehaviorSubject(this._visible));E(this,"afterVisible$",this._afterVisible$.asObservable());E(this,"_forceKeepVisible$",new O.BehaviorSubject(!1));E(this,"forceKeepVisible$",this._forceKeepVisible$.asObservable());this._sheetInterceptorService=e,this._renderManagerService=t,this._themeService=r,this._univerInstanceService=o,this._editorService=s,this._refSelectionsService=l,this._contextService=c,this.disposeWithMe(a.toDisposable(()=>{this._currentEditCellState$.complete(),this._currentEditCell=null})),this._univerInstanceService.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET).subscribe(d=>{var u;d.getUnitId()===((u=this._currentEditCellState)==null?void 0:u.unitId)&&this._clearCurrentEditCellState()})}refreshEditCellState(){const e=this.getLatestEditCellState();if(!e){this._currentEditCellState=null,this._currentEditCellLayout=null,this._currentEditCellState$.next(null),this._currentEditCellLayout$.next(null);return}const{position:t,scaleX:r,scaleY:o,canvasOffset:s,...l}=e;this._currentEditCellState=l,this._currentEditCellLayout={position:t,scaleX:r,scaleY:o,canvasOffset:s},this._currentEditCellState$.next(this._currentEditCellState),this._currentEditCellLayout$.next(this._currentEditCellLayout)}refreshEditCellPosition(e){var P;const t=this._currentEditCell;if(t==null)return;const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return;const o=this._renderManagerService.getRenderUnitById(r.getUnitId());if(!o)return;const s=(P=o.with(exports.SheetSkeletonManagerService).getSkeletonParam(t.sheetId))==null?void 0:P.skeleton,l=o.with(ve);if(!s||!this._currentEditCellState)return;const{primary:c,unitId:d,sheetId:u,scene:h,engine:g}=t,S=$n(s,c);if(S==null)return;const f=a.convertCellToRange(S),p=ee.getCanvasOffsetByEngine(g);let{startX:v,startY:C,endX:I,endY:R}=f;const{scaleX:w,scaleY:M}=h.getAncestorScale(),y=h.getViewportScrollXY(l.getViewPort());v=T.convertTransformToOffsetX(v,w,y),C=T.convertTransformToOffsetY(C,M,y),I=T.convertTransformToOffsetX(I,w,y),R=T.convertTransformToOffsetY(R,M,y),e&&this._currentEditCellLayout&&(I=I-v+this._currentEditCellLayout.position.startX,R=R-C+this._currentEditCellLayout.position.startY,v=this._currentEditCellLayout.position.startX,C=this._currentEditCellLayout.position.startY),this._currentEditCellLayout={position:{startX:v,startY:C,endX:I,endY:R},canvasOffset:p,scaleX:w,scaleY:M},this._currentEditCellLayout$.next(this._currentEditCellLayout)}setEditCell(e){this._currentEditCell=e,this._editorService.getFocusEditor()||(this._editorService.focus(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._contextService.setContextValue(a.EDITOR_ACTIVATED,!1),this._contextService.setContextValue(a.FOCUSING_EDITOR_STANDALONE,!1));const t=this.getLatestEditCellState();if(!t){this._currentEditCellState=t,this._currentEditCellLayout=t,this._currentEditCellState$.next(t),this._currentEditCellLayout$.next(t);return}const{position:r,canvasOffset:o,scaleX:s,scaleY:l,...c}=t;this._currentEditCellState=c,this._currentEditCellLayout={position:r,canvasOffset:o,scaleX:s,scaleY:l},this._currentEditCellState$.next(this._currentEditCellState),this._currentEditCellLayout$.next(this._currentEditCellLayout)}_clearCurrentEditCellState(){this._currentEditCellState=null,this._currentEditCellState$.next(null),this._currentEditCellLayout=null,this._currentEditCellLayout$.next(null)}getEditCellState(){return this._currentEditCellState==null||this._currentEditCellLayout==null?null:{...this._currentEditCellState,...this._currentEditCellLayout}}getEditCellLayout(){return this._currentEditCellLayout}getEditLocation(){return this._currentEditCellState}updateEditLocation(e,t){this._currentEditCellState&&(this._currentEditCellState={...this._currentEditCellState,row:e,column:t})}getLatestEditCellState(){var W,N,U;const e=this._currentEditCell;if(e==null)return;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const r=this._renderManagerService.getRenderUnitById(t.getUnitId());if(!r)return;const o=r.with(exports.SheetSkeletonManagerService).getCurrentSkeleton(),s=r.with(ve);if(!o)return;const{primary:l,unitId:c,sheetId:d,scene:u,engine:h}=e,{startRow:g,startColumn:S}=l,f=$n(o,l);if(f==null)return;const p=a.convertCellToRange(f),v=ee.getCanvasOffsetByEngine(h);let{startX:C,startY:I,endX:R,endY:w}=p;const{scaleX:M,scaleY:y}=u.getAncestorScale(),P=u.getViewportScrollXY(s.getViewPort());C=T.convertTransformToOffsetX(C,M,P),I=T.convertTransformToOffsetY(I,y,P),R=T.convertTransformToOffsetX(R,M,P),w=T.convertTransformToOffsetY(w,y,P);const x=t.getActiveSheet();if(!x)return;const A={workbook:t,worksheet:x,unitId:t.getUnitId(),subUnitId:x.getSheetId(),row:g,col:S,origin:x.getCellRaw(g,S)};let k;const D=this._sheetInterceptorService.writeCellInterceptor.fetchThroughInterceptors(m.BEFORE_CELL_EDIT)(x.getCell(g,S),A);k=D&&o.getCellDocumentModelWithFormula(D);const H=(W=k==null?void 0:k.documentModel)==null?void 0:W.documentStyle.renderConfig;if(H!=null&&(H.cellValueType=a.CellValueType.STRING),!k||k.documentModel==null){const L=o.getBlankCellDocumentModel(D);if(k!=null){const{verticalAlign:F,horizontalAlign:B,wrapStrategy:j,textRotation:z,fill:K}=k,{centerAngle:ne,vertexAngle:Q}=T.convertTextRotation(z);L.documentModel.documentStyle.renderConfig={...H,verticalAlign:F,horizontalAlign:B,wrapStrategy:j,background:{rgb:K},centerAngle:ne,vertexAngle:Q}}k=L}if(k.fill=k.fill||"#fff",(N=k.documentModel)==null||N.setZoomRatio(Math.max(M,y)),(D==null?void 0:D.isInArrayFormulaRange)===!0){const L=(U=k.documentModel)==null?void 0:U.getBody();L&&(L.textRuns=[{st:0,ed:L.dataStream.length-2,ts:{cl:{rgb:this._themeService.getCurrentTheme().textColorSecondary}}}])}return{position:{startX:C,startY:I,endX:R,endY:w},scaleX:M,scaleY:y,canvasOffset:v,row:g,column:S,unitId:c,sheetId:d,documentLayoutObject:k,editorUnitId:this._editorUnitId,isInArrayFormulaRange:D==null?void 0:D.isInArrayFormulaRange}}getCurrentEditorId(){return this._editorUnitId}changeVisible(e){this._visible=e,e.visible&&(this._editorIsDirty=!1),this._visible$.next(this._visible),this._afterVisible$.next(this._visible)}isVisible(){return this._visible}enableForceKeepVisible(){this._forceKeepVisible$.next(!0)}disableForceKeepVisible(){this._forceKeepVisible$.next(!1)}isForceKeepVisible(){return this._forceKeepVisible$.getValue()}changeEditorDirty(e){this._editorIsDirty=e}getEditorDirty(){return this._editorIsDirty}};exports.EditorBridgeService=qd([Pt(0,a.Inject(m.SheetInterceptorService)),Pt(1,T.IRenderManagerService),Pt(2,a.Inject(a.ThemeService)),Pt(3,a.IUniverInstanceService),Pt(4,ee.IEditorService),Pt(5,m.IRefSelectionsService),Pt(6,a.IContextService)],exports.EditorBridgeService);const Se=a.createIdentifier("univer.sheet-editor-bridge.service"),Ce={id:"sheet.operation.set-cell-edit-visible",type:a.CommandType.OPERATION,handler:(n,i)=>{if(!i)return!1;const{unitId:e}=i,r=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return r?(n.get(Se).changeVisible({...i,unitId:e!=null?e:r.getUnitId()}),!0):!1}},hr={id:"sheet.operation.set-cell-edit-visible-f2",type:a.CommandType.OPERATION,handler:(n,i)=>{const e=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return r?(e.syncExecuteCommand(Ce.id,{...i,unitId:r.getUnitId()}),!0):!1}},zt={id:"sheet.operation.set-cell-edit-visible-arrow",type:a.CommandType.OPERATION,handler:()=>!0},xn={id:"sheet.command.change-zoom-ratio",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const e=n.get(a.IUniverInstanceService),t=m.getSheetCommandTarget(e);if(!t)return!1;const{worksheet:r,subUnitId:o,unitId:s}=t,{delta:l,reset:c}=i;let d=c?100:Math.round((r.getConfig().zoomRatio+l)*100);d=Math.max(Ao[0],d),d=Math.min(Ao[1],d);const u=d/100,g=n.get(Se).isVisible();return(g.unitId===s||g.unitId===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)&&g.visible?!1:n.get(a.ICommandService).executeCommand(Le.id,{unitId:s,subUnitId:o,zoomRatio:u})}},An={id:"sheet.command.set-zoom-ratio",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const{unitId:e,subUnitId:t,zoomRatio:r}=i,s=n.get(Se).isVisible();return(s.unitId===e||s.unitId===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)&&s.visible?!1:n.get(a.ICommandService).executeCommand(Le.id,{unitId:e,subUnitId:t,zoomRatio:r})}};function Qd(n){return typeof n.isMainScene>"u"}function Ge(n,i){const e=n instanceof a.Workbook?n:n.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return null;const t=e.getUnitId();let r,o,s,l;if(Qd(i)){const g=i.getRenderById(t);if(g==null)return null;r=g.components,r=g.components,o=g.mainComponent,s=g.scene,l=g.engine}else r=i.components,o=i.mainComponent,s=i.scene,l=i.engine;if(!r||!o)return null;const c=o,d=r.get(he.ROW),u=r.get(he.COLUMN),h=r.get(he.LEFT_TOP);return{spreadsheet:c,spreadsheetRowHeader:d,spreadsheetColumnHeader:u,spreadsheetLeftTopPlaceholder:h,scene:s,engine:l}}function Wo(n,i,e,t){const{startX:r,startY:o,endX:s,endY:l}=t.getCellWithCoordByIndex(n,i);return{startX:r,startY:o,endX:s,endY:l}}function qe(n,i,e,t,r,o){const s=e.getCoordRelativeToViewport(T.Vector2.FromArray([n,i])),{x:l,y:c}=s,d=e.getScrollXYInfoByViewport(s,r),{scaleX:u,scaleY:h}=e.getAncestorScale(),g=t.getCellIndexByOffset(l,c,u,h,d,{closeFirst:o}),{row:S,column:f}=g,p=t.getNoMergeCellWithCoordByIndex(S,f),{startX:v,startY:C,endX:I,endY:R}=p;return{startX:v,startY:C,endX:I,endY:R,row:S,column:f}}function Qn(n,i,e,t){const r=e.getCoordRelativeToViewport(T.Vector2.FromArray([n,i])),o=e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),s=e.getScrollXYInfoByViewport(r,o),{scaleX:l,scaleY:c}=e.getAncestorScale(),{x:d,y:u}=s,h=n/l+d,g=i/c+u;return{x:h,y:g}}var Jd=Object.getOwnPropertyDescriptor,$d=(n,i,e,t)=>{for(var r=t>1?void 0:t?Jd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Wr=(n,i)=>(e,t)=>i(e,t,n);let er=class extends a.Disposable{constructor(i,e,t,r,o){super();E(this,"_zoom");this._context=i,this._sheetSkeletonManagerService=e,this._commandService=t,this._contextService=r,this._editorBridgeService=o,this._initSkeletonListener(),this._initZoomEventListener()}updateZoom(i,e){const t=this._context.unit.getSheetBySheetId(i);return t?(t.getConfig().zoomRatio=e,t===this._context.unit.getActiveSheet()&&this._updateViewZoom(e),!0):!1}_initZoomEventListener(){const i=this._getSheetObject().scene;this.disposeWithMe(i.onMouseWheel$.subscribeEvent(e=>{if(!e.ctrlKey||!this._contextService.getContextValue(a.FOCUSING_SHEET))return;if(this._editorBridgeService){const d=this._editorBridgeService.isVisible();if((d.unitId===this._context.unitId||d.unitId===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)&&d.visible)return}const t=Math.abs(e.deltaX);let r=t<40?.2:t<80?.4:.2;r*=e.deltaY>0?-1:1,i.scaleX<1&&(r/=2);const o=this._context.unit,s=o.getActiveSheet();if(!s)return;const l=s.getZoomRatio();let c=+Number.parseFloat(`${l+r}`).toFixed(1);c=c>=4?4:c<=.1?.1:c,this._commandService.executeCommand(An.id,{zoomRatio:Math.round(c*10)/10,unitId:o.getUnitId(),subUnitId:s.getSheetId()}),e.preventDefault()}))}_initSkeletonListener(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const t=this._context.unit.getActiveSheet();if(!t)return;const r=t.getZoomRatio()||1;this._zoom!==r&&this._updateViewZoom(r),this._zoom=r}))}_updateViewZoom(i){const e=this._getSheetObject();e==null||e.scene.scale(i,i),e==null||e.spreadsheet.makeForceDirty()}_getSheetObject(){return Ge(this._context.unit,this._context)}};er=$d([Wr(1,a.Inject(exports.SheetSkeletonManagerService)),Wr(2,a.ICommandService),Wr(3,a.IContextService),Wr(4,a.Optional(Se))],er);const Le={id:"sheet.operation.set-zoom-ratio",type:a.CommandType.OPERATION,handler:(n,i)=>{const t=n.get(T.IRenderManagerService).getRenderById(i.unitId);return t?t.with(er).updateZoom(i.subUnitId,i.zoomRatio):!1}};var eu=Object.getOwnPropertyDescriptor,tu=(n,i,e,t)=>{for(var r=t>1?void 0:t?eu(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},zi=(n,i)=>(e,t)=>i(e,t,n);const Qs="univer-sheet-main-canvas";exports.SheetsRenderService=class extends a.RxDisposable{constructor(e,t,r){super();E(this,"_skeletonChangeMutations",new Set);this._contextService=e,this._instanceSrv=t,this._renderManagerService=r,Promise.resolve().then(()=>this._init())}registerSkeletonChangingMutations(e){return this._skeletonChangeMutations.has(e)?a.toDisposable(()=>{}):(this._skeletonChangeMutations.add(e),a.toDisposable(()=>this._skeletonChangeMutations.delete(e)))}checkMutationShouldTriggerRerender(e){return this._skeletonChangeMutations.has(e)}_init(){this._initWorkbookListener(),this._initContextListener()}_initWorkbookListener(){this._instanceSrv.getTypeOfUnitAdded$(a.UniverInstanceType.UNIVER_SHEET).pipe(O.takeUntil(this.dispose$)).subscribe(e=>this._createRenderer(e)),this._instanceSrv.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET).forEach(e=>this._createRenderer(e)),this._instanceSrv.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET).pipe(O.takeUntil(this.dispose$)).subscribe(e=>this._disposeRenderer(e))}_createRenderer(e){const t=e.getUnitId();this._renderManagerService.created$.subscribe(r=>{r.unitId===t&&(r.engine.getCanvas().setId(`${Qs}_${t}`),r.engine.getCanvas().getContext().setId(`${Qs}_${t}`))}),this._renderManagerService.createRender(t)}_disposeRenderer(e){const t=e.getUnitId();this._renderManagerService.removeRender(t)}_initContextListener(){this.disposeWithMe(this._contextService.subscribeContextValue$(T.RENDER_RAW_FORMULA_KEY).pipe(O.distinctUntilChanged()).subscribe(()=>{this._renderManagerService.getRenderAll().forEach(e=>{e.mainComponent instanceof T.Spreadsheet&&e.mainComponent.makeForceDirty(!0)})}))}};exports.SheetsRenderService=tu([zi(0,a.IContextService),zi(1,a.IUniverInstanceService),zi(2,T.IRenderManagerService)],exports.SheetsRenderService);var nu=Object.getOwnPropertyDescriptor,ru=(n,i,e,t)=>{for(var r=t>1?void 0:t?nu(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Ot=(n,i)=>(e,t)=>i(e,t,n);exports.AutoFillController=class extends a.Disposable{constructor(e,t,r,o,s,l,c){super();E(this,"_beforeApplyData",[]);E(this,"_currentLocation",null);E(this,"_copyData",[]);E(this,"_defaultHook");this._univerInstanceService=e,this._commandService=t,this._autoFillService=r,this._editorBridgeService=o,this._renderManagerService=s,this._injector=l,this._sheetsRenderService=c,this._defaultHook={id:"default",type:un.Default,priority:0,onBeforeFillData:(d,u)=>this._presetAndCacheData(d,u),onFillData:(d,u,h)=>this._fillData(d,u,h)},this._init()}_init(){this._initDefaultHook(),this._initSelectionControlFillChanged(),this._initQuitListener(),this._initSkeletonChange()}_initSkeletonChange(){this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(_t.id))}_initDefaultHook(){this.disposeWithMe(this._autoFillService.addHook(this._defaultHook))}_initQuitListener(){const e=[Ce.id,In.id,m.SetRangeValuesCommand.id,Le.id,m.SetWorksheetActiveOperation.id,m.MoveRangeMutation.id,m.RemoveRowMutation.id,m.RemoveColMutation.id,m.InsertRowMutation.id,m.InsertColMutation.id,m.MoveRowsMutation.id,m.MoveColsMutation.id,m.SetWorksheetColWidthMutation.id,m.SetWorksheetRowHeightMutation.id,m.SetRangeValuesMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted((t,r)=>{var c,d;const o=r==null?void 0:r.fromCollab,s=r==null?void 0:r.fromSync,l=r==null?void 0:r.fromFormula;e.includes(t.id)&&!o&&!s&&!l&&t.params.trigger!==_t.id&&t.params.trigger!==ur.id&&this._quit(),t.id===m.RemoveSheetMutation.id&&t.params.unitId===((c=this._currentLocation)==null?void 0:c.unitId)&&t.params.subUnitId===((d=this._currentLocation)==null?void 0:d.subUnitId)&&this._quit()})),this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(t=>{var r;t.getUnitId()===((r=this._currentLocation)==null?void 0:r.unitId)&&this._quit()}))}_quit(){this._currentLocation=null,this._beforeApplyData=[],this._copyData=[],this._autoFillService.setShowMenu(!1)}_initSelectionControlFillChanged(){const e=new a.DisposableCollection,t=()=>{e.dispose();const r=T.getCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService);if(!r)return;r.with(ve).getSelectionControls().forEach(l=>{e.add(l.selectionFilled$.subscribe(c=>{if(c==null||c.startColumn===-1||c.startRow===-1||c.endColumn===-1||c.endRow===-1)return;const d={startColumn:l.model.startColumn,endColumn:l.model.endColumn,startRow:l.model.startRow,endRow:l.model.endRow},u={startColumn:c.startColumn,endColumn:c.endColumn,startRow:c.startRow,endRow:c.endRow};this._commandService.executeCommand(_t.id,{sourceRange:d,targetRange:u})})),e.add(l.fillControl.onDblclick$.subscribeEvent(()=>{const c={startColumn:l.model.startColumn,endColumn:l.model.endColumn,startRow:l.model.startRow,endRow:l.model.endRow};this._handleDbClickFill(c)})),e.add(l.fillControl.onPointerDown$.subscribeEvent(()=>{this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(Ce.id,{visible:!1,eventType:T.DeviceInputEventType.PointerDown,unitId:r.unitId})}))})};t(),this.disposeWithMe(this._commandService.onCommandExecuted(r=>{r.id===m.SetSelectionsOperation.id&&t()})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(()=>t()))}_handleDbClickFill(e){const t=this._detectFillRange(e);t.endRow<=e.endRow||this._commandService.executeCommand(_t.id,{sourceRange:e,targetRange:t})}_detectFillRange(e){var g,S,f,p,v,C;const{startRow:t,endRow:r,startColumn:o,endColumn:s}=e,l=(g=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:g.getActiveSheet();if(!l)return e;const c=l.getCellMatrix(),d=l.getMaxRows()-1,u=l.getMaxColumns()-1;let h=r;if(o>0&&((S=c.getValue(t,o-1))==null?void 0:S.v)!=null){let I=t;for(;((f=c.getValue(I,o-1))==null?void 0:f.v)!=null&&I<d;)I+=1;h=I-1}else if(s<u&&((p=c.getValue(r,s+1))==null?void 0:p.v)!=null){let I=t;for(;((v=c.getValue(I,s+1))==null?void 0:v.v)!=null&&I<d;)I+=1;h=I-1}for(let I=r+1;I<=h;I++)for(let R=o;R<=s;R++)if(((C=c.getValue(I,R))==null?void 0:C.v)!=null){h=I-1;break}return{startColumn:o,endColumn:s,startRow:t,endRow:h}}_getApplyData(e,t,r,o,s,l=!0){const c=[],d=Math.floor(r/t),u=r%t,h=this._autoFillService.getRules();if(!l&&s===le.ONLY_FORMAT)return console.error("ERROR: only format can not be applied when hasStyle is false"),[];const g={};h.forEach(S=>{g[S.type]=[]}),h.forEach(S=>{const{type:f,applyFunctions:p={}}=S,v=e[f];v&&v.forEach(C=>{const I=Ad(C.index,u),R=C.index.length*d+I,w=this._applyFunctions(C,R,o,s,p,e),M=kd(t,r,C.index);g[f].push({data:w,index:M})})});for(let S=0;S<r;S++)h.forEach(f=>{const{type:p}=f,v=g[p];for(let C=0;C<v.length;C++)S in v[C].index&&c.push(v[C].data[v[C].index[S]])});return c}_applyFunctions(e,t,r,o,s,l){const{data:c}=e,d=r===a.Direction.UP||r===a.Direction.LEFT;if(o===le.COPY){const u=s==null?void 0:s[le.COPY];return u?u(e,t,r,l):(d&&c.reverse(),Ft(c,t))}if(o===le.SERIES){const u=s==null?void 0:s[le.SERIES];return u?u(e,t,r,l):(d&&c.reverse(),s!=null&&s[le.COPY]?s[le.COPY](e,t,r,l):Ft(c,t))}if(o===le.ONLY_FORMAT){const u=s==null?void 0:s[le.ONLY_FORMAT];return u?u(e,t,r,l):Dd(c,t)}}_getCopyData(e,t){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!r)throw new Error("No active sheet found");const o=r.getCellMatrix(),s=this._autoFillService.getRules(),l=[],c=t===a.Direction.DOWN||t===a.Direction.UP;let d,u;return c?(d=e.cols,u=e.rows):(d=e.rows,u=e.cols),d.forEach(h=>{const g=this._getEmptyCopyDataPiece(),S={type:void 0,cellData:void 0};u.forEach(f=>{let p;c?p=o.getValue(f,h):p=o.getValue(h,f);const{type:v,isContinue:C}=s.find(I=>I.match(p,this._injector))||Ga;if(C(S,p)){const I=g[v],R=I[I.length-1];R.data.push(p),R.index.push(f-u[0])}else{const I=g[v];I?I.push({data:[p],index:[f-u[0]]}):g[v]=[{data:[p],index:[f-u[0]]}]}S.type=v,S.cellData=p}),l.push(g)}),l}_getEmptyCopyDataPiece(){const e={};return this._autoFillService.getRules().forEach(t=>{e[t.type]=[]}),e}_getMergeApplyData(e,t,r,o){const s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!s)throw new Error("No active sheet found");const l=[];for(let c=e.startRow;c<=e.endRow;c++)for(let d=e.startColumn;d<=e.endColumn;d++){const{isMergedMainCell:u,startRow:h,startColumn:g,endRow:S,endColumn:f}=s.getCellInfoInMergeData(c,d);if(u){if(r===a.Direction.DOWN){let p=h+o,v=S+o;for(;v<=t.endRow;)l.push({startRow:p,startColumn:g,endRow:v,endColumn:f}),p+=o,v+=o}else if(r===a.Direction.UP){let p=h-o,v=S-o;for(;p>=t.startRow;)l.push({startRow:p,startColumn:g,endRow:v,endColumn:f}),p-=o,v-=o}else if(r===a.Direction.RIGHT){let p=g+o,v=f+o;for(;v<=t.endColumn;)l.push({startRow:h,startColumn:p,endRow:S,endColumn:v}),p+=o,v+=o}else if(r===a.Direction.LEFT){let p=g-o,v=f-o;for(;p>=t.startColumn;)l.push({startRow:h,startColumn:p,endRow:S,endColumn:v}),p-=o,v-=o}}}return l}_presetAndCacheData(e,t){const{source:r,target:o}=e,s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!s)throw new Error("No active sheet found");const l=s.getCellMatrix(),c=[];return o.rows.forEach(d=>{const u=[];o.cols.forEach(h=>{u.push(a.Tools.deepClone(l.getValue(d,h)))}),c.push(u)}),this._beforeApplyData=c,this._copyData=this._getCopyData(r,t),this._currentLocation=e,this._shouldDisableSeries(this._copyData)?(this._autoFillService.setDisableApplyType(le.SERIES,!0),le.COPY):(this._autoFillService.setDisableApplyType(le.SERIES,!1),this._getPreferredApplyType(this._copyData))}_fillData(e,t,r){var W,N;const o=[],s=[];let l=!0;r===le.NO_FORMAT&&(l=!1,r=le.SERIES);const{source:c,target:d,unitId:u,subUnitId:h}=e;if(!c||!d||t==null)return{undos:o,redos:s};const g=Et(c),S=Et(d),{cols:f,rows:p}=d,{cols:v,rows:C}=c,I=this._copyData;let R;t===a.Direction.DOWN||t===a.Direction.UP?R=C.length:R=v.length;const w=[];if(t===a.Direction.DOWN||t===a.Direction.UP){const U=p.length,L=[];f.forEach((F,B)=>{const j=I[B],z=this._getApplyData(j,R,U,t,r,l);L.push(z)});for(let F=0;F<L[0].length;F++){const B=[];for(let j=0;j<L.length;j++)B.push({s:null,...L[j][F]});w.push(B)}}else{const U=f.length;p.forEach((L,F)=>{const B=I[F],j=this._getApplyData(B,R,U,t,r,l),z=[];for(let K=0;K<j.length;K++)z.push({s:null,...j[K]});w.push(z)})}let M=[];const y=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getStyles();if(l?(M=this._getMergeApplyData(g,S,t,R),w.forEach(U=>{U.forEach(L=>{L&&y&&y&&(L.s=y.getStyleByCell(L))})})):w.forEach((U,L)=>{U.forEach((F,B)=>{F&&y&&(F.s=y.getStyleByCell(this._beforeApplyData[L][B])||null)})}),r===le.ONLY_FORMAT&&w.forEach((U,L)=>{U.forEach((F,B)=>{if(F){const j=this._beforeApplyData[L][B]||{};F.f=j.f,F.si=j.si,F.t=j.t,F.v=j.v}})}),l){const U=[],L=(N=(W=this._univerInstanceService.getUniverSheetInstance(u))==null?void 0:W.getSheetBySheetId(h))==null?void 0:N.getMergeData();L&&L.forEach(j=>{a.Rectangle.intersects(j,S)&&U.push(j)});const F={unitId:u,subUnitId:h,ranges:U},B=this._injector.invoke(m.RemoveMergeUndoMutationFactory,F);U.length&&(s.push({id:m.RemoveWorksheetMergeMutation.id,params:F}),o.unshift({id:m.AddWorksheetMergeMutation.id,params:B}))}const P={subUnitId:h,unitId:u,cellValue:wd([d])},x=this._injector.invoke(m.SetRangeValuesUndoMutationFactory,P);s.push({id:m.SetRangeValuesMutation.id,params:P}),o.unshift({id:m.SetRangeValuesMutation.id,params:x});const A=new a.ObjectMatrix;p.forEach((U,L)=>{f.forEach((F,B)=>{w[L][B]&&A.setValue(U,F,w[L][B])})});const k=A.getMatrix(),D={subUnitId:h,unitId:u,cellValue:k},H=this._injector.invoke(m.SetRangeValuesUndoMutationFactory,D);if(this._autoFillService.getActiveHooks().forEach(U=>{var L;(L=U.onBeforeSubmit)==null||L.call(U,e,t,r,k)}),o.unshift({id:m.SetRangeValuesMutation.id,params:H}),s.push({id:m.SetRangeValuesMutation.id,params:D}),M!=null&&M.length){const U=m.getAddMergeMutationRangeByType(M),L={unitId:u,subUnitId:h,ranges:U},F=this._injector.invoke(m.AddMergeUndoMutationFactory,L);o.unshift({id:m.RemoveWorksheetMergeMutation.id,params:F}),s.push({id:m.AddWorksheetMergeMutation.id,params:L})}return{undos:o,redos:s}}_shouldDisableSeries(e){return e.every(t=>Object.keys(t).every(r=>{var o;return((o=t[r])==null?void 0:o.length)===0||[Ie.OTHER,Ie.FORMULA].includes(r)}))}_getPreferredApplyType(e){return e.every(r=>Object.keys(r).every(o=>{var s,l;return((s=r[o])==null?void 0:s.length)===0||((l=r[o])==null?void 0:l.length)===1&&r[o][0].data.length===1&&Ie.NUMBER===o}))?le.COPY:le.SERIES}};exports.AutoFillController=ru([Ot(0,a.IUniverInstanceService),Ot(1,a.ICommandService),Ot(2,wt),Ot(3,Se),Ot(4,T.IRenderManagerService),Ot(5,a.Inject(a.Injector)),Ot(6,a.Inject(exports.SheetsRenderService))],exports.AutoFillController);var iu=Object.getOwnPropertyDescriptor,ou=(n,i,e,t)=>{for(var r=t>1?void 0:t?iu(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Xi=(n,i)=>(e,t)=>i(e,t,n);exports.CellCustomRenderController=class extends a.Disposable{constructor(e,t,r,o){super();E(this,"_enterActiveRender");this._context=e,this._sheetSkeletonManagerService=t,this._renderManagerService=r,this._permissionService=o,this._initEventBinding()}_initEventBinding(){const e=new a.DisposableCollection,t=this._context.unit,r=o=>{if(e.dispose(),!o)return;const s=this._context.unitId,{skeleton:l}=o,c=this._renderManagerService.getRenderById(s);if(c&&c.mainComponent){const d=c.mainComponent,u=S=>{const{offsetX:f,offsetY:p}=S,v=c.scene,C=t.getActiveSheet();if(!C)return;const I=v.getActiveViewportByCoord(T.Vector2.FromArray([f,p]));if(!I)return;const{scaleX:R,scaleY:w}=v.getAncestorScale(),M={x:I.viewportScrollX,y:I.viewportScrollY},y=l.getCellIndexByOffset(f,p,R,w,M),P=l.worksheet.getMergedCell(y.row,y.column),x={actualRow:P?P.startRow:y.row,actualCol:P?P.startColumn:y.column,row:y.row,col:y.column};if(!x||!l)return;const A=C.getCell(x.actualRow,x.actualCol);if(!A)return;const k=A.customRender;if(!(k!=null&&k.length))return;const D=x.actualRow,H=x.actualCol,W=k.sort(a.sortRules),N=C.getSheetId(),U={data:A,style:l.getStyles().getStyleByCell(A),primaryWithCoord:l.getCellWithCoordByIndex(x.actualRow,x.actualCol),unitId:s,subUnitId:N,row:D,col:H,workbook:t,worksheet:C},L={x:M.x+f/R,y:M.y+p/w},F=W.find(B=>{var j;return(j=B.isHit)==null?void 0:j.call(B,L,U)});if(F)return[F,U]},h=d.onPointerDown$.subscribeEvent(S=>{var p,v,C,I;const f=u(S);if(f){const[R,w]=f,{row:M,col:y,worksheet:P,unitId:x,subUnitId:A}=w;if(!((p=this._permissionService.composePermission([new m.WorkbookEditablePermission(x).id,new m.WorksheetEditPermission(x,A).id]))==null?void 0:p.every(H=>H.value)))return!1;const D=(C=(v=P.getCell(M,y))==null?void 0:v.selectionProtection)==null?void 0:C[0];if((D==null?void 0:D[m.UnitAction.Edit])===!1)return!1;(I=R.onPointerDown)==null||I.call(R,w,S)}}),g=a.fromEventSubject(d.onPointerMove$).pipe(O.throttleTime(30)).subscribe(S=>{var p,v,C,I,R,w;const f=u(S);if(f){const[M,y]=f;this._enterActiveRender?this._enterActiveRender.render!==M&&((v=(p=this._enterActiveRender.render).onPointerLeave)==null||v.call(p,this._enterActiveRender.cellContext,S),this._enterActiveRender={render:M,cellContext:y},(C=M.onPointerEnter)==null||C.call(M,y,S)):(this._enterActiveRender={render:M,cellContext:y},(I=M.onPointerEnter)==null||I.call(M,y,S))}else this._enterActiveRender&&((w=(R=this._enterActiveRender.render).onPointerLeave)==null||w.call(R,this._enterActiveRender.cellContext,S),this._enterActiveRender=null)});h&&e.add(h),g&&e.add(g)}};this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(r)),r(this._sheetSkeletonManagerService.getCurrentParam()),this.disposeWithMe(e)}};exports.CellCustomRenderController=ou([Xi(1,a.Inject(exports.SheetSkeletonManagerService)),Xi(2,T.IRenderManagerService),Xi(3,a.IPermissionService)],exports.CellCustomRenderController);class gs extends a.Disposable{constructor(){super(...arguments);E(this,"rangesStack",[]);E(this,"selectedRangeWorksheet","")}}var su=Object.getOwnPropertyDescriptor,au=(n,i,e,t)=>{for(var r=t>1?void 0:t?su(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Js=(n,i)=>(e,t)=>i(e,t,n);let bn=class{constructor(n,i){E(this,"_current",null);E(this,"_shortcutParam",[]);this._univerInstanceService=n,this._localeService=i}dispose(){this._shortcutParam=[]}getCurrentBySearch(n){return this._getCurrentBySearch(n)}getCurrent(){return this._getCurrentBySearch(this._current)}addOrUpdate(n){const i=this._getCurrentBySearch({unitId:n.unitId,sheetId:n.sheetId,keycode:n.keycode});if(i!=null){const e=this._shortcutParam.indexOf(i);this._shortcutParam.splice(e,1)}return this._shortcutParam.push(n),i}remove(n){if(n==null)return;const i=this._getCurrentBySearch(n);if(i==null)return;const e=this._shortcutParam.indexOf(i);return this._shortcutParam.splice(e,1)[0]}_getCurrentBySearch(n){return n==null?void 0:this._shortcutParam.find(e=>e.unitId===n.unitId&&e.sheetId===n.sheetId&&e.keycode===n.keycode)}};bn=au([Js(0,a.IUniverInstanceService),Js(1,a.Inject(a.LocaleService))],bn);var ki=(n=>(n.MergeAll="mergeAll",n.MergeVertical="mergeVertical",n.MergeHorizontal="mergeHorizontal",n))(ki||{});function It(n,i,e,t,r=!0,o=1,s=!0){let l={...n};t==null&&(t={startRow:0,endRow:e.getRowCount()-1,startColumn:0,endColumn:e.getColumnCount()-1});let c;switch(i){case a.Direction.UP:for(c=n.startRow-o;c>-1&&!e.getRowVisible(c);)c-=1;c>=t.startRow?(l.startRow=c,l.endRow=c):s&&(l.startRow=t.endRow,l.endRow=t.endRow,r&&(l=It(l,a.Direction.LEFT,e,t,!1)));break;case a.Direction.DOWN:for(c=n.endRow+o;c<e.getRowCount()&&!e.getRowVisible(c);)c+=1;c<=t.endRow?(l.startRow=c,l.endRow=c):s&&(l.startRow=t.startRow,l.endRow=t.startRow,r&&(l=It(l,a.Direction.RIGHT,e,t,!1)));break;case a.Direction.LEFT:for(c=n.startColumn-o;c>-1&&!e.getColVisible(c);)c-=1;c>=t.startColumn?(l.startColumn=c,l.endColumn=c):s&&(l.startColumn=t.endColumn,l.endColumn=t.endColumn,r&&(l=It(l,a.Direction.UP,e,t,!1)));break;case a.Direction.RIGHT:for(c=n.endColumn+o;c<e.getColumnCount()&&!e.getColVisible(c);)c+=1;c<=t.endColumn?(l.startColumn=c,l.endColumn=c):s&&(l.startColumn=t.startColumn,l.endColumn=t.startColumn,r&&(l=It(l,a.Direction.DOWN,e,t,!1)));break}return l}function Ss(n,i,e){const t={...n},{startRow:r,startColumn:o,endRow:s,endColumn:l}=tr(n,i,e);let c=Ln(e,r,o,s,l).hasValue,d=!0,u=!0;for(;u;){if(a.Direction.UP===i){let h=t.startRow-1;for(;h>-1&&!e.getRowVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:g,matrix:S}=Ln(e,h,t.startColumn,h,t.endColumn);if(c&&!g&&!d){u=!1;break}else{if(S.getLength()!==0){let f=h;S.forValue(p=>{f=Math.min(p,f)}),t.startRow=f}else t.startRow=h;if(t.endRow=t.startRow,!c&&g){u=!1;break}c=g,d=!1}}if(a.Direction.DOWN===i){let h=t.endRow+1;for(;h<e.getRowCount()&&!e.getRowVisible(h);)h+=1;if(h===e.getRowCount()){u=!1;break}const{hasValue:g,matrix:S}=Ln(e,h,t.startColumn,h,t.endColumn);if(c&&!g&&!d){u=!1;break}else{if(S.getLength()!==0){let f=h;S.forValue((p,v,C)=>{f=Math.max(p+(C.rowSpan||1)-1,f)}),t.endRow=f}else t.endRow=h;if(t.startRow=t.endRow,!c&&g){u=!1;break}c=g,d=!1}}if(a.Direction.LEFT===i){let h=t.startColumn-1;for(;h>-1&&!e.getColVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:g,matrix:S}=Ln(e,t.startRow,h,t.endRow,h);if(c&&!g&&!d){u=!1;break}else{if(S.getLength()!==0){let f=h;S.forValue((p,v)=>{f=Math.min(v,f)}),t.startColumn=f}else t.startColumn=h;if(t.endColumn=t.startColumn,!c&&g){u=!1;break}c=g,d=!1}}if(a.Direction.RIGHT===i){let h=t.endColumn+1;for(;h<e.getColumnCount()&&!e.getColVisible(h);)h+=1;if(h===e.getColumnCount()){u=!1;break}const{hasValue:g,matrix:S}=Ln(e,t.startRow,h,t.endRow,h);if(c&&!g&&!d){u=!1;break}else{if(S.getLength()!==0){let f=h;S.forValue((p,v,C)=>{f=Math.max(v+(C.colSpan||1)-1,f)}),t.endColumn=f}else t.endColumn=h;if(t.startColumn=t.endColumn,!c&&g){u=!1;break}c=g,d=!1}}}return m.alignToMergedCellsBorders(t,e,!0)}function Za(n,i,e){return It(n,i,e,void 0,!1,1,!1)}function lu(n,i,e){const t=Ss(n,i,e);return m.alignToMergedCellsBorders(a.Rectangle.union(t,n),e,!0)}function cu(n,i,e){const t=Za(n,i,e),r={startRow:Math.min(n.startRow,t.startRow),startColumn:Math.min(n.startColumn,t.startColumn),endRow:Math.max(n.endRow,t.endRow),endColumn:Math.max(n.endColumn,t.endColumn)};return m.alignToMergedCellsBorders(a.Rectangle.union(n,r),e)}function du(n,i,e,t){const r=a.getReverseDirection(e),o=Ss(tr(n,r,t),e,t);return e===a.Direction.UP&&o.startRow<=n.startRow?m.alignToMergedCellsBorders({...i,startColumn:n.startColumn,endColumn:n.endColumn},t,!0):e===a.Direction.DOWN&&o.endRow>=n.endRow?m.alignToMergedCellsBorders({...i,startColumn:n.startColumn,endColumn:n.endColumn},t,!0):e===a.Direction.LEFT&&o.startColumn<=n.startColumn?m.alignToMergedCellsBorders({...i,startRow:n.startRow,endRow:n.endRow},t,!0):e===a.Direction.RIGHT&&o.endColumn>=n.endColumn?m.alignToMergedCellsBorders({...i,startRow:n.startRow,endRow:n.endRow},t,!0):a.Rectangle.union(a.Rectangle.clone(i),o)}function uu(n,i,e){const t=a.getReverseDirection(i),r=tr(n,t,e),o=tr(n,i,e),s=Za(r,i,e);return m.alignToMergedCellsBorders(a.Rectangle.union(o,s),e,!1)}function $s(n){return{startRow:0,startColumn:0,endRow:n.getRowCount()-1,endColumn:n.getColumnCount()-1,rangeType:a.RANGE_TYPE.ALL}}function tr(n,i,e){let t;switch(i){case a.Direction.UP:t={startRow:n.startRow,startColumn:n.startColumn,endRow:n.startRow,endColumn:n.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.DOWN:t={startRow:n.endRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.LEFT:t={startRow:n.startRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.startColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.RIGHT:t={startRow:n.startRow,startColumn:n.endColumn,endRow:n.endRow,endColumn:n.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;default:throw new Error("Invalid direction")}return m.alignToMergedCellsBorders(t,e,!1)}function Ln(n,i,e,t,r){let o=!1;const s=n.getMatrixWithMergedCells(i,e,t,r).forValue((l,c,d)=>{if(mu(d))return o=!0,!1});return{hasValue:o,matrix:s}}function Uo(n,i,e){const t=a.Rectangle.clone(n);if(i==null)return t;switch(e){case a.Direction.UP:case a.Direction.DOWN:t.startColumn=t.endColumn=i.actualColumn;break;case a.Direction.LEFT:case a.Direction.RIGHT:t.startRow=t.endRow=i.actualRow;break}return t}function hu(n,i,e){var l,c,d,u;const{primary:t,range:r}=n,o=a.Rectangle.clone(r);switch(i){case a.Direction.UP:case a.Direction.DOWN:o.startRow=(l=t==null?void 0:t.startRow)!=null?l:r.startRow,o.endRow=(c=t==null?void 0:t.endRow)!=null?c:r.startRow;break;case a.Direction.LEFT:case a.Direction.RIGHT:o.startColumn=(d=t==null?void 0:t.startColumn)!=null?d:r.startColumn,o.endColumn=(u=t==null?void 0:t.endColumn)!=null?u:r.startColumn;break}const s=tr(o,i,e);switch(i){case a.Direction.DOWN:return r.startRow<s.startRow;case a.Direction.UP:return r.endRow>s.endRow;case a.Direction.LEFT:return s.endColumn<r.endColumn;case a.Direction.RIGHT:return s.startColumn>r.startColumn}}function Ka(n,i){let e=n[0].startRow,t=n[0].endRow;n.forEach(o=>{const{startRow:s,endRow:l}=o;e=Math.min(e,s),t=Math.max(t,l)});const r=new Array(t-e+1).fill(!1);return i.forEach(o=>{const{startRow:s,endRow:l}=o;for(let c=Math.max(s,e);c<=Math.min(l,t);c++)r[c-e]=!0}),n.every(o=>{const{startRow:s,endRow:l}=o;for(let c=s;c<=l;c++)if(!r[c-e])return!1;return!0})}function qa(n,i){let e=n[0].startColumn,t=n[0].endColumn;n.forEach(o=>{const{startColumn:s,endColumn:l}=o;e=Math.min(e,s),t=Math.max(t,l)});const r=new Array(t-e+1).fill(!1);return i.forEach(o=>{const{startColumn:s,endColumn:l}=o;for(let c=Math.max(s,e);c<=Math.min(l,t);c++)r[c-e]=!0}),n.every(o=>{const{startColumn:s,endColumn:l}=o;for(let c=s;c<=l;c++)if(!r[c-e])return!1;return!0})}function fs(n,i){return i?n==="mergeAll"?i.filter(e=>!(e.startRow===e.endRow&&e.startColumn===e.endColumn)):n==="mergeVertical"?i.filter(e=>e.startRow!==e.endRow):n==="mergeHorizontal"?i.filter(e=>e.startColumn!==e.endColumn):i:null}function mu(n){return n.v!==void 0&&n.v!==null&&n.v!==""||n.p!==void 0}var Je=(n=>(n[n.moveStopeOne=0]="moveStopeOne",n[n.moveGap=1]="moveGap",n[n.moveStepPage=2]="moveStepPage",n[n.moveStepEnd=3]="moveStepEnd",n))(Je||{});const xe={id:"sheet.command.move-selection",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const{workbook:t,worksheet:r}=e,o=m.getSelectionsService(n,i.fromCurrentSelection).getCurrentLastSelection();if(!o)return!1;const{direction:s,jumpOver:l,extra:c}=i,{range:d,primary:u}=o,h=Uo(d,u,s),g=l===1?Ss(h,s,r):It(h,s,r),S=m.getCellAtRowCol(g.startRow,g.startColumn,r);if(a.Rectangle.equals(S,h))return!1;const f=t.getUnitId();n.get(bn).remove({unitId:f,sheetId:r.getSheetId(),keycode:_.KeyCode.TAB});const p=[{range:a.Rectangle.clone(S),primary:{startRow:S.startRow,startColumn:S.startColumn,endRow:S.endRow,endColumn:S.endColumn,actualRow:g.startRow,actualColumn:g.startColumn,isMerged:S.isMerged,isMergedMainCell:S.startRow===g.startRow&&S.startColumn===g.startColumn}}];return n.get(a.ICommandService).executeCommand(m.SetSelectionsOperation.id,{unitId:t.getUnitId(),subUnitId:r.getSheetId(),selections:p,type:m.SelectionMoveType.MOVE_END,extra:c,reveal:!0})}},$e={id:"sheet.command.move-selection-enter-tab",type:a.CommandType.COMMAND,handler:(n,i)=>{var U;if(!i)return!1;const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const{workbook:t,worksheet:r}=e,o=m.getSelectionsService(n),{direction:s,keycode:l}=i,c=s===a.Direction.LEFT||s===a.Direction.UP,d=o.getCurrentSelections().concat(),u=d.findIndex(L=>L.primary),h=d[u];if(!h)return!1;const g=c?-1:1,S=u+g!==d.length?d[u+g]:d[0],f=d.findIndex(L=>L===S),p=t.getUnitId(),v=r.getSheetId();if(!h)return!1;const{range:C}=h,I=h.primary;let R=Uo(C,I,s);const w=n.get(bn),M=w.getCurrentBySearch({unitId:p,sheetId:v,keycode:_.KeyCode.TAB});let y;const{startRow:P,endRow:x,startColumn:A,endColumn:k}=C,D=c?I.startRow===P&&I.startColumn===A:I.endRow===x&&I.endColumn===k;if(a.Rectangle.equals(C,I)){if(l===_.KeyCode.TAB)M==null&&w.addOrUpdate({unitId:p,sheetId:v,keycode:_.KeyCode.TAB,selection:h});else{const B=M==null?void 0:M.selection;if(B!=null){const{range:j,primary:z}=B;R=Uo(j,z,s)}w.remove({unitId:p,sheetId:v,keycode:_.KeyCode.TAB})}const L=It(R,s,r),F=m.getCellAtRowCol(L.startRow,L.startColumn,r);if(a.Rectangle.equals(F,R))return!1;y={range:a.Rectangle.clone(F),primary:{startRow:F.startRow,startColumn:F.startColumn,endRow:F.endRow,endColumn:F.endColumn,actualRow:L.startRow,actualColumn:L.startColumn,isMerged:F.isMerged,isMergedMainCell:F.startRow===L.startRow&&F.startColumn===L.startColumn}}}else{w.remove({unitId:p,sheetId:v,keycode:_.KeyCode.TAB});const L=a.Tools.deepClone(I),F=D?S.range:It({startRow:L.startRow,startColumn:L.startColumn,endRow:L.endRow,endColumn:L.endColumn},s,r,{startRow:P,endRow:x,startColumn:A,endColumn:k}),B=D&&c,j=B?m.getCellAtRowCol(F.endRow,F.endColumn,r):m.getCellAtRowCol(F.startRow,F.startColumn,r);y={range:D?S.range:a.Rectangle.clone(C),primary:{startRow:j.startRow,startColumn:j.startColumn,endRow:j.endRow,endColumn:j.endColumn,actualRow:B?j.startRow:F.startRow,actualColumn:B?j.startColumn:F.startColumn,isMerged:j.isMerged,isMergedMainCell:j.startRow===F.startRow&&j.startColumn===F.startColumn},style:D?S.style:h.style}}D?(d[u].primary=null,d[f]=y,o.setSelections(p,v,[],m.SelectionMoveType.MOVE_END)):d[u]=y;const H=n.get(a.ICommandService).executeCommand(m.SetSelectionsOperation.id,{unitId:p,subUnitId:v,type:m.SelectionMoveType.MOVE_END,selections:d,reveal:!0,extra:i.extra}),N=(U=n.get(T.IRenderManagerService).getRenderById(p))==null?void 0:U.with(ve);return N==null||N.refreshSelectionMoveEnd(),H}},Ne={id:"sheet.command.expand-selection",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const{worksheet:t,unitId:r,subUnitId:o}=e,s=m.getSelectionsService(n).getCurrentLastSelection();if(!s)return!1;const{range:l,primary:c}=s,{jumpOver:d,direction:u,extra:h}=i,S=hu(s,u,t)?d===1?du(l,{...a.Rectangle.clone(c),rangeType:a.RANGE_TYPE.NORMAL},u,t):uu(l,u,t):d===1?lu(l,u,t):cu(l,u,t);return S.rangeType=s.range.rangeType,a.Rectangle.equals(S,l)?!1:n.get(a.ICommandService).syncExecuteCommand(m.SetSelectionsOperation.id,{unitId:r,subUnitId:o,type:m.SelectionMoveType.MOVE_END,selections:[{range:S,primary:c}],extra:h,reveal:!0})}},Di={id:"sheet.command.select-all",type:a.CommandType.COMMAND,handler:async(n,i={expandToGapFirst:!0,loop:!1})=>{const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const t=m.getSelectionsService(n).getCurrentLastSelection();if(!t)return!1;const r=n.get(gs),{worksheet:o,unitId:s,subUnitId:l}=e,c=`${s}|${l}`;c!==r.selectedRangeWorksheet&&(r.rangesStack=[],r.selectedRangeWorksheet=c);const d=o.getMaxRows(),u=o.getMaxColumns(),{expandToGapFirst:h,loop:g}=i,{range:S,primary:f}=t,p=S.endColumn===u-1&&S.endRow===d-1&&S.startRow===0&&S.startColumn===0;r.rangesStack.some(C=>a.Rectangle.equals(C,S))||(r.rangesStack=[],r.rangesStack.push(S));let v;if(p)if(g){if(r.rangesStack.findIndex(I=>a.Rectangle.equals(I,S))!==r.rangesStack.length-1)return!1;v=r.rangesStack[0]}else return!1;else h?(v=m.expandToContinuousRange(S,{left:!0,right:!0,up:!0,down:!0},o),a.Rectangle.equals(v,S)&&(v=$s(o))):v=$s(o);return r.rangesStack.some(C=>a.Rectangle.equals(C,v))||r.rangesStack.push(v),n.get(a.ICommandService).executeCommand(m.SetSelectionsOperation.id,{unitId:s,subUnitId:l,reveal:!0,selections:[{range:v,primary:f}]})}};var gu=Object.getOwnPropertyDescriptor,Su=(n,i,e,t)=>{for(var r=t>1?void 0:t?gu(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},fu=(n,i)=>(e,t)=>i(e,t,n);exports.SheetScrollManagerService=class{constructor(i,e){E(this,"_scrollStateMap",new Map);E(this,"_rawScrollInfo$",new O.BehaviorSubject(null));E(this,"rawScrollInfo$",this._rawScrollInfo$.asObservable());E(this,"validViewportScrollInfo$",new O.BehaviorSubject(null));E(this,"_searchParamForScroll",null);this._context=i,this._sheetSkeletonManagerService=e}dispose(){this._rawScrollInfo$.complete()}calcViewportScrollFromRowColOffset(i){if(!i)return{viewportScrollX:0,viewportScrollY:0};let{sheetViewStartColumn:e,sheetViewStartRow:t,offsetX:r,offsetY:o}=i;t=t||0,o=o||0;const s=this._sheetSkeletonManagerService.getCurrentSkeleton(),l=(s==null?void 0:s.rowHeightAccumulation[t-1])||0,d=((s==null?void 0:s.columnWidthAccumulation[e-1])||0)+r,u=l+o;return{viewportScrollX:d,viewportScrollY:u}}setSearchParam(i){this._searchParamForScroll=i}getScrollStateByParam(i){return this._getCurrentScroll(i)}getCurrentScrollState(){return this._getCurrentScroll(this._searchParamForScroll)}setValidScrollState(i){this._setScrollState(i)}emitRawScrollParam(i){this._emitRawScroll(i)}setValidScrollStateToCurrSheet(i){if(this._searchParamForScroll==null)return;this._setScrollState({...this._searchParamForScroll,...i});const e=this._searchParamForScroll.sheetId,t=this._sheetSkeletonManagerService.getSkeleton(e);t&&t.setScroll(i.viewportScrollX,i.viewportScrollY)}clear(){this._searchParamForScroll!=null&&this._clearByParamAndNotify(this._searchParamForScroll)}_setScrollState(i){const{unitId:e,sheetId:t,sheetViewStartColumn:r,sheetViewStartRow:o,offsetX:s,offsetY:l}=i;this._scrollStateMap.has(e)||this._scrollStateMap.set(e,new Map);const c=this._scrollStateMap.get(e),d={sheetViewStartRow:o,sheetViewStartColumn:r,offsetX:s,offsetY:l};c.set(t,d)}_clearByParamAndNotify(i){this._setScrollState({...i,sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),this._emitRawScroll({sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0})}_getCurrentScroll(i){var s;const e={sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0};if(i==null)return e;const{unitId:t,sheetId:r}=i;return((s=this._scrollStateMap.get(t))==null?void 0:s.get(r))||e}_emitRawScroll(i){this._rawScrollInfo$.next(i)}};exports.SheetScrollManagerService=Su([fu(1,a.Inject(exports.SheetSkeletonManagerService))],exports.SheetScrollManagerService);const je={id:"sheet.operation.set-scroll",type:a.CommandType.OPERATION,handler:(n,i)=>{if(!i)return!1;const{unitId:e,sheetId:t,offsetX:r,offsetY:o,sheetViewStartColumn:s,sheetViewStartRow:l}=i;return n.get(T.IRenderManagerService).getRenderById(e).with(exports.SheetScrollManagerService).emitRawScrollParam({unitId:e,sheetId:t,offsetX:r,offsetY:o,sheetViewStartRow:l,sheetViewStartColumn:s}),!0}},Rn={id:"sheet.command.set-scroll-relative",type:a.CommandType.COMMAND,handler:async(n,i)=>{const e=n.get(a.ICommandService),t=n.get(a.IUniverInstanceService),r=n.get(T.IRenderManagerService),o=m.getSheetCommandTarget(t);if(!o)return!1;const{unitId:s,subUnitId:l}=o,d=r.getRenderById(s).with(exports.SheetScrollManagerService).getCurrentScrollState(),{offsetX:u=0,offsetY:h=0}=i||{},{sheetViewStartRow:g=0,sheetViewStartColumn:S=0,offsetX:f=0,offsetY:p=0}=d||{};return e.executeCommand(je.id,{unitId:s,sheetId:l,sheetViewStartRow:g,sheetViewStartColumn:S,offsetX:f+u,offsetY:p+h})}},ze={id:"sheet.command.scroll-view",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const e=n.get(a.IUniverInstanceService),t=n.get(T.IRenderManagerService),r=m.getSheetCommandTarget(e);if(!r)return!1;const{workbook:o,worksheet:s,unitId:l}=r,d=t.getRenderById(l).with(exports.SheetScrollManagerService).getCurrentScrollState();if(!s)return!1;const{sheetViewStartRow:u,sheetViewStartColumn:h,offsetX:g,offsetY:S}=i,{sheetViewStartColumn:f,sheetViewStartRow:p,offsetX:v,offsetY:C}=d||{},{xSplit:I,ySplit:R}=r.worksheet.getConfig().freeze;return n.get(a.ICommandService).syncExecuteCommand(je.id,{unitId:o.getUnitId(),sheetId:s.getSheetId(),sheetViewStartRow:u!=null?u:p!=null?p:0+R,sheetViewStartColumn:h!=null?h:f!=null?f:0+I,offsetX:g!=null?g:v,offsetY:S!=null?S:C})}},ps={id:"sheet.command.scroll-to-cell",type:a.CommandType.COMMAND,handler:(n,i)=>{const e=n.get(a.IUniverInstanceService);return n.get(T.IRenderManagerService).getRenderById(e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(exports.SheetsScrollRenderController).scrollToRange(i.range,i.forceTop,i.forceLeft)}},pu={id:"sheet.command.scroll-view-reset",type:a.CommandType.COMMAND,handler:async n=>{const i=n.get(a.IUniverInstanceService),e=m.getSheetCommandTarget(i);if(!e)return!1;const{subUnitId:t,unitId:r}=e;return n.get(a.ICommandService).executeCommand(je.id,{unitId:r,sheetId:t,sheetViewStartRow:0,sheetViewStartColumn:0})}};var vu=Object.getOwnPropertyDescriptor,Cu=(n,i,e,t)=>{for(var r=t>1?void 0:t?vu(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},on=(n,i)=>(e,t)=>i(e,t,n);xe.id,$e.id;const _u=3;exports.SheetsScrollRenderController=class extends a.Disposable{constructor(i,e,t,r,o,s,l){super(),this._context=i,this._injector=e,this._sheetSkeletonManagerService=t,this._contextService=r,this._commandService=o,this._renderManagerService=s,this._scrollManagerService=l,this._initCommandListener(),this._wheelEventListener(),this._scrollBarEventListener(),this._initSkeletonListener()}_wheelEventListener(){const{scene:i}=this._context;if(!i)return;const e=i.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);e&&this.disposeWithMe(i.onMouseWheel$.subscribeEvent((t,r)=>{if(t.ctrlKey||!this._contextService.getContextValue(a.FOCUSING_SHEET))return;let o=0,s=0;o=t.deltaX,t.shiftKey?o=(t.deltaY||t.deltaX)*_u:s=t.deltaY,this._commandService.executeCommand(Rn.id,{offsetX:o,offsetY:s}),this._context.scene.makeDirty(!0);const l=e.limitedScroll(e.scrollX+o,e.scrollY+s);l&&!l.isLimitedX&&!l.isLimitedY&&(t.preventDefault(),i.getParent().classType===T.RENDER_CLASS_TYPE.SCENE_VIEWER&&r.stopPropagation()),e.isWheelPreventDefaultX&&e.isWheelPreventDefaultY&&t.preventDefault()}))}_scrollBarEventListener(){const{scene:i}=this._context;if(i==null)return;const e=i.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);e&&(this.disposeWithMe(a.toDisposable(this._scrollManagerService.rawScrollInfo$.subscribe(t=>{var S;const r=(S=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:S.skeleton;if(!r)return;if(t==null){e.scrollToViewportPos({viewportScrollX:0,viewportScrollY:0});return}const{sheetViewStartRow:o,sheetViewStartColumn:s,offsetX:l,offsetY:c}=t,{startX:d,startY:u}=r.getCellWithCoordByIndex(o,s,!1),h=d+l,g=u+c;e.scrollToViewportPos({viewportScrollX:h,viewportScrollY:g})}))),this.disposeWithMe(e.onScrollAfter$.subscribeEvent(t=>{var p;const r=(p=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:p.skeleton;if(r==null||t.isTrigger===!1)return;const o=this._getSheetObject();if(r==null||o==null)return;const{viewportScrollX:s,viewportScrollY:l,scrollX:c,scrollY:d}=t,{row:u,column:h,rowOffset:g,columnOffset:S}=r.getOffsetRelativeToRowCol(s,l),f={sheetViewStartRow:u,sheetViewStartColumn:h,offsetX:S,offsetY:g,viewportScrollX:s,viewportScrollY:l,scrollX:c,scrollY:d};this._scrollManagerService.setValidScrollStateToCurrSheet(f),this._scrollManagerService.validViewportScrollInfo$.next({...f,viewportScrollX:s,viewportScrollY:l,scrollX:c,scrollY:d})})),this.disposeWithMe(e.onScrollByBar$.subscribeEvent(t=>{var g;const r=(g=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:g.skeleton;if(r==null||t.isTrigger===!1)return;const o=this._getSheetObject();if(r==null||o==null)return;const{viewportScrollX:s=0,viewportScrollY:l=0}=t;this._getFreeze();const{row:c,column:d,rowOffset:u,columnOffset:h}=r.getOffsetRelativeToRowCol(s,l);this._commandService.executeCommand(ze.id,{sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:h,offsetY:u})})))}_initSkeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeletonBefore$.subscribe(i=>{if(i==null)return;const e={unitId:i.unitId,sheetId:i.sheetId};if(this._scrollManagerService.setSearchParam(e),!this._getSheetObject())return;const r=this._scrollManagerService.getScrollStateByParam(e),{viewportScrollX:o,viewportScrollY:s}=this._scrollManagerService.calcViewportScrollFromRowColOffset(r);r&&this._updateViewportScroll(o,s)})))}_updateViewportScroll(i=0,e=0){const t=this._getSheetObject();if(!t)return;const r=t.scene,o=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),s=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT),l=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM),c=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT),d=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);o&&(o.viewportScrollX=i,o.viewportScrollY=e),l&&(l.viewportScrollY=e),s&&(s.viewportScrollX=i),c&&(c.viewportScrollY=e),d&&(d.viewportScrollX=i)}scrollToRange(i,e,t){let{endRow:r,endColumn:o,startColumn:s,startRow:l}=i;const c=this._getViewportBounding();if(i.rangeType===a.RANGE_TYPE.ROW?(s=0,o=0):i.rangeType===a.RANGE_TYPE.COLUMN&&(l=0,r=0),c&&!e&&!t){const d=c.startRow>r?l:r,u=c.startColumn>o?s:o;return this._scrollToCell(d,u)}else return this._scrollToCell(l,s,e,t)}scrollToCell(i,e){const t=this._context.unit.getActiveSheet(),{ySplit:r,xSplit:o}=t.getFreeze();return this._commandService.syncExecuteCommand(ze.id,{sheetViewStartRow:i-r,sheetViewStartColumn:e-o,offsetX:0,offsetY:0})}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{switch(i.id){case m.SetSelectionsOperation.id:{const e=i.params;e.unitId===this._context.unitId&&e.reveal&&this._scrollToSelection()}break;case m.ScrollToCellOperation.id:{const e=i.params;if(e.unitId===this._context.unitId){const t=e.range;this.scrollToRange(t)}}break;case Ne.id:{const e=i.params;this._scrollToSelectionForExpand(e)}break}}))}_scrollToSelectionForExpand(i){setTimeout(()=>{const e=this._getSelectionsService().getCurrentLastSelection();if(e==null)return;const{startRow:t,startColumn:r,endRow:o,endColumn:s}=e.range,l=this._getViewportBounding();if(l==null)return;const{startRow:c,startColumn:d,endRow:u,endColumn:h}=l;let g=0,S=0;t>c?g=o:o<u?g=t:g=c,r>d?S=s:s<h?S=r:S=d,i.direction===a.Direction.DOWN?g=o:i.direction===a.Direction.UP?g=t:i.direction===a.Direction.RIGHT?S=s:i.direction===a.Direction.LEFT&&(S=r),this._scrollToCell(g,S)},0)}_getFreeze(){var e;const i=(e=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:e.skeleton.getWorksheetConfig();if(i!=null)return i.freeze}_updateSceneSize(i){var h;if(i==null)return;const{unitId:e}=this._context,{skeleton:t}=i,r=(h=this._renderManagerService.getRenderById(e))==null?void 0:h.scene;if(t==null||r==null)return;const{rowTotalHeight:o,columnTotalWidth:s,rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:c}=t;this._context.unit.getActiveSheet()&&(r==null||r.transformByState({width:l+s,height:c+o}))}_getSheetObject(){return Ge(this._context.unit,this._context)}_scrollToSelectionByDirection(i){const e=this._getViewportBounding();if(e==null)return!1;const{startRow:t,startColumn:r,endRow:o,endColumn:s}=e;let l=0,c=0;const{startRow:d,startColumn:u,endRow:h,endColumn:g}=i;d>=t&&(l=h),h<=o&&(l=d),u>=r&&(c=g),g<=s&&(c=u),this._scrollToCell(l,c)}_scrollToSelection(i=!0){var d;const e=this._getSelectionsService().getCurrentLastSelection();if(!e)return;const{startRow:t,startColumn:r,actualRow:o,actualColumn:s}=(d=e.primary)!=null?d:e.range,l=i&&o!=null?o:t,c=i&&s!=null?s:r;this._scrollToCell(l,c)}_getSelectionsService(){return m.getSelectionsService(this._injector)}_getViewportBounding(){var o,s;const i=(o=this._getSheetObject())==null?void 0:o.scene;if(i==null)return;const e=i.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(e==null)return;const t=(s=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:s.skeleton;if(t==null)return;const r=e.calcViewportInfo();return t.getRangeByViewBound(r.viewBound)}_scrollToCell(i,e,t=!1,r=!1){var k,D,H;const{rowHeightAccumulation:o,columnWidthAccumulation:s}=(k=this._sheetSkeletonManagerService.getCurrentSkeleton())!=null?k:{};if(o==null||s==null)return!1;const l=(D=this._getSheetObject())==null?void 0:D.scene;if(l==null)return!1;const c=l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(c==null)return!1;const d=(H=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:H.skeleton;if(d==null)return!1;const u=this._context.unit.getActiveSheet();if(!u)return!1;i=a.Tools.clamp(i,0,o.length-1),e=a.Tools.clamp(e,0,s.length-1);const{startColumn:h,startRow:g,ySplit:S,xSplit:f}=u.getFreeze(),p=this._getViewportBounding();if(p==null)return!1;const{startRow:v,startColumn:C,endRow:I,endColumn:R}=p;let w,M;if(i>=g&&e>=h-S&&(i<=v&&(w=i,t=!0),i>=I)){const W=o[i]-c.height;for(let N=v;N<=i&&(w=N+1,!(o[N]>=W));N++);}if(e>=h&&i>=g-S&&(e<=C&&(M=e,r=!0),e>=R)){const W=s[e]-c.width;for(let N=C;N<=e&&(M=N+1,!(s[N]>=W));N++);}if(w===void 0&&M===void 0)return!1;let{offsetX:y,offsetY:P,sheetViewStartRow:x,sheetViewStartColumn:A}=this._scrollManagerService.getCurrentScrollState()||{};if(w=w?Math.min(w,i):x+S,M=M?Math.min(M,e):A+f,r){y=0,M=e;const W=d.getHiddenColumnsInRange({startColumn:M-f,endColumn:M});M=M-W.length}if(t){P=0,w=i;const W=d.getHiddenRowsInRange({startRow:w-S,endRow:w});w=w-W.length}return this._commandService.syncExecuteCommand(ze.id,{sheetViewStartRow:Math.max(0,w-S),sheetViewStartColumn:Math.max(0,M-f),offsetX:y,offsetY:P})}};exports.SheetsScrollRenderController=Cu([on(1,a.Inject(a.Injector)),on(2,a.Inject(exports.SheetSkeletonManagerService)),on(3,a.IContextService),on(4,a.ICommandService),on(5,T.IRenderManagerService),on(6,a.Inject(exports.SheetScrollManagerService))],exports.SheetsScrollRenderController);const vs={id:"sheet.operation.scroll-to-range",type:a.CommandType.OPERATION,handler:(n,i)=>{if(!i)return!1;const e=n.get(a.IUniverInstanceService);return n.get(T.IRenderManagerService).getRenderById(e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(exports.SheetsScrollRenderController).scrollToRange(i.range,i.forceTop,i.forceLeft)}};class Qa{constructor(){E(this,"_state",null);E(this,"_rect",null);E(this,"_state$",new O.BehaviorSubject(null));E(this,"state$",this._state$.asObservable());E(this,"_rect$",new O.BehaviorSubject(null));E(this,"rect$",this._rect$.asObservable());E(this,"_focus",!1);E(this,"_focus$",new O.BehaviorSubject(this._focus));E(this,"focus$",this._focus$.asObservable())}dispose(){this._state$.complete(),this._state=null,this._rect$.complete(),this._rect=null}setState(i){this._state=i,this._refresh(i)}getRect(){return this._rect}setRect(i){this._rect=i,this._rect$.next(i)}getState(){return this._state}setFocus(i=!1){this._focus=i,this._focus$.next(i)}_refresh(i){this._state$.next(i)}}const mr=a.createIdentifier("univer.sheet-cell-editor-manager.service");var Ve=function(){return Ve=Object.assign||function(n){for(var i,e=1,t=arguments.length;e<t;e++){i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(n[r]=i[r])}return n},Ve.apply(this,arguments)},Iu=function(n,i){var e={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&i.indexOf(t)<0&&(e[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(n);r<t.length;r++)i.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(n,t[r])&&(e[t[r]]=n[t[r]]);return e},Ee=V.forwardRef(function(n,i){var e=n.icon,t=n.id,r=n.className,o=n.extend,s=Iu(n,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),c=V.useRef("_".concat(Eu()));return Ja(e,"".concat(t),{defIds:e.defIds,idSuffix:c.current},Ve({ref:i,className:l},s),o)});function Ja(n,i,e,t,r){return V.createElement(n.tag,Ve(Ve({key:i},bu(n,e,r)),t),(Ru(n,e).children||[]).map(function(o,s){return Ja(o,"".concat(i,"-").concat(n.tag,"-").concat(s),e,void 0,r)}))}function bu(n,i,e){var t=Ve({},n.attrs);e!=null&&e.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=e.colorChannel1),n.tag==="mask"&&t.id&&(t.id=t.id+i.idSuffix),Object.entries(t).forEach(function(o){var s=o[0],l=o[1];s==="mask"&&typeof l=="string"&&(t[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))});var r=i.defIds;return!r||r.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+i.idSuffix),Object.entries(t).forEach(function(o){var s=o[0],l=o[1];typeof l=="string"&&(t[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),t}function Ru(n,i){var e,t=i.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((e=n.children)===null||e===void 0)&&e.length)?Ve(Ve({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?Ve(Ve({},r),{attrs:Ve(Ve({},r.attrs),{id:r.attrs.id+i.idSuffix})}):r})}):n}function Eu(){return Math.random().toString(36).substring(2,8)}Ee.displayName="UniverIcon";var wu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z",fillRule:"evenodd",clipRule:"evenodd"}}]},$a=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"autofill",ref:i,icon:wu}))});$a.displayName="Autofill";var Tu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Zt=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"check-mark-single",ref:i,icon:Tu}))});Zt.displayName="CheckMarkSingle";var yu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},el=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"close-single",ref:i,icon:yu}))});el.displayName="CloseSingle";var Mu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"g",attrs:{fill:"currentColor",clipPath:"url(#convert-single_clip0_911_593)"},children:[{tag:"path",attrs:{d:"M2.44766.848145C1.564.848145.847656 1.56449.847656 2.44814V6.44814C.847656 7.3318 1.564 8.04814 2.44766 8.04814H6.44766C7.33131 8.04814 8.04766 7.3318 8.04766 6.44814V2.44814C8.04766 1.56449 7.33131.848145 6.44766.848145H2.44766zM2.04766 6.44814V5.04824H3.84775V6.84814H2.44766C2.22674 6.84814 2.04766 6.66906 2.04766 6.44814zM2.04766 3.84824H3.84775V2.04814H2.44766C2.22674 2.04814 2.04766 2.22723 2.04766 2.44814V3.84824zM5.04775 6.84814V5.04824H6.84766V6.44814C6.84766 6.66906 6.66857 6.84814 6.44766 6.84814H5.04775zM5.04775 3.84824H6.84766V2.44814C6.84766 2.22723 6.66857 2.04814 6.44766 2.04814H5.04775V3.84824zM9.55215 7.95166C8.66849 7.95166 7.95215 8.668 7.95215 9.55166V13.5517C7.95215 14.4353 8.66849 15.1517 9.55215 15.1517L11.5522 15.1517 13.5521 15.1517C14.4358 15.1517 15.1521 14.4353 15.1521 13.5517L15.1521 11.5518 15.1521 9.55166C15.1521 8.668 14.4358 7.95166 13.5521 7.95166H9.55215zM13.9521 10.9518V9.55166C13.9521 9.33075 13.7731 9.15166 13.5521 9.15166H12.1522V10.9518H13.9521zM10.9522 10.9518V9.15166H9.55215C9.33123 9.15166 9.15215 9.33075 9.15215 9.55166V10.9518H10.9522zM9.15215 12.1518H10.9522V13.9517H9.55215C9.33123 13.9517 9.15215 13.7726 9.15215 13.5517V12.1518zM12.1522 12.1518H13.9521V13.5517C13.9521 13.7726 13.7731 13.9517 13.5521 13.9517H12.1522V12.1518z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{d:"M9.62158 2.44912C9.62158 2.11775 9.89021 1.84912 10.2216 1.84912H12.7516C13.6352 1.84912 14.3516 2.56547 14.3516 3.44912V5.9791C14.3516 6.31047 14.0829 6.5791 13.7516 6.5791 13.4202 6.5791 13.1516 6.31047 13.1516 5.9791V3.44912C13.1516 3.22821 12.9725 3.04912 12.7516 3.04912H10.2216C9.89021 3.04912 9.62158 2.78049 9.62158 2.44912zM5.77871 14.1507C6.11008 14.1507 6.37871 13.8821 6.37871 13.5507 6.37871 13.2193 6.11008 12.9507 5.77871 12.9507L3.24873 12.9507C3.02782 12.9507 2.84873 12.7716 2.84873 12.5507L2.84873 10.0207C2.84873 9.68933 2.5801 9.4207 2.24873 9.4207 1.91736 9.4207 1.64873 9.68933 1.64873 10.0207L1.64873 12.5507C1.64873 13.4343 2.36507 14.1507 3.24873 14.1507H5.77871z"}}]},{tag:"defs",attrs:{},children:[{tag:"clipPath",attrs:{id:"convert-single_clip0_911_593"},children:[{tag:"path",attrs:{fill:"#fff",d:"M0 0H16V16H0z"}}]}]}],defIds:["convert-single_clip0_911_593"]},tl=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"convert-single",ref:i,icon:Mu}))});tl.displayName="ConvertSingle";var Pu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ni=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"delete-single",ref:i,icon:Pu}))});Ni.displayName="DeleteSingle";var Ou={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.85869 12.9216C8.38445 13.4708 7.61555 13.4708 7.14131 12.9216L0.358114 5.06726C-0.406895 4.18144 0.134916 2.66683 1.2168 2.66683L14.7832 2.66683C15.8651 2.66683 16.4069 4.18144 15.6419 5.06726L8.85869 12.9216Z"}}]},Lo=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"dropdown-single",ref:i,icon:Ou}))});Lo.displayName="DropdownSingle";var xu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M15 8C15 11.866 11.866 15 8 15C4.13401 15 1 11.866 1 8C1 4.13401 4.13401 1 8 1C11.866 1 15 4.13401 15 8ZM10.3097 5.69014C10.544 5.92445 10.544 6.30435 10.3097 6.53867L8.84843 7.9999L10.3099 9.46137C10.5442 9.69569 10.5442 10.0756 10.3099 10.3099C10.0756 10.5442 9.69569 10.5442 9.46137 10.3099L7.9999 8.84843L6.53842 10.3099C6.30411 10.5442 5.92421 10.5442 5.6899 10.3099C5.45558 10.0756 5.45558 9.69569 5.6899 9.46137L7.15137 7.9999L5.69014 6.53867C5.45583 6.30435 5.45583 5.92445 5.69014 5.69014C5.92445 5.45583 6.30435 5.45583 6.53867 5.69014L7.9999 7.15137L9.46113 5.69014C9.69544 5.45583 10.0753 5.45583 10.3097 5.69014Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Cs=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"error-single",ref:i,icon:xu}))});Cs.displayName="ErrorSingle";var Au={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.28096 4.6541C1.57489 4.50109 1.93721 4.61533 2.09022 4.90926C2.27315 5.26067 2.55999 5.60455 2.94829 5.92278C4.04628 6.82266 5.87505 7.44865 7.99828 7.44865C10.1215 7.44865 11.9503 6.82267 13.0482 5.92279C13.4366 5.60455 13.7234 5.26067 13.9063 4.90927C14.0594 4.61533 14.4217 4.50109 14.7156 4.65409C15.0095 4.8071 15.1238 5.16941 14.9708 5.46334C14.6995 5.98445 14.2981 6.44997 13.8089 6.8509C13.7298 6.91575 13.6481 6.97914 13.564 7.041L15.2245 8.70153C15.4588 8.93585 15.4588 9.31575 15.2245 9.55006C14.9902 9.78438 14.6103 9.78438 14.376 9.55006L12.5041 7.67822C11.8977 7.97568 11.2181 8.21208 10.4884 8.37706L11.0996 10.6581C11.1853 10.9782 10.9954 11.3072 10.6753 11.393C10.3552 11.4787 10.0262 11.2888 9.94045 10.9687L9.29949 8.57652C8.8758 8.62404 8.44081 8.64865 7.99828 8.64865C7.55276 8.64865 7.11487 8.62371 6.68846 8.57555L6.04723 10.9687C5.96147 11.2888 5.63247 11.4788 5.31239 11.393C4.99231 11.3073 4.80236 10.9783 4.88812 10.6582L5.49983 8.37516C4.7743 8.2105 4.09843 7.9752 3.49498 7.67947L1.62436 9.55009C1.39005 9.78441 1.01015 9.78441 0.775835 9.5501C0.54152 9.31578 0.541518 8.93588 0.775832 8.70157L2.43478 7.04261C2.34987 6.98024 2.26746 6.91632 2.18764 6.8509C1.69842 6.44997 1.29706 5.98445 1.0258 5.46335C0.872791 5.16942 0.987031 4.80711 1.28096 4.6541Z"}}]},nl=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"eyelash-single",ref:i,icon:Au}))});nl.displayName="EyelashSingle";var ku={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6.06409 5.53454C5.93592 5.53454 5.84083 5.41567 5.86897 5.29063L5.95442 4.9109C6.05444 4.48178 6.23806 4.11547 6.51182 3.81952 6.81082 3.49628 7.25398 3.35405 7.79738 3.35405 7.99847 3.35405 8.21359 3.37775 8.44188 3.42245 8.46089 3.42617 8.47974 3.43006 8.49846 3.4341 8.7099 3.4798 8.93698 3.38478 9.02031 3.18514L9.24767 2.6404C9.33457 2.43219 9.23178 2.19404 9.01582 2.12874 8.98358 2.11899 8.95028 2.10912 8.91591 2.09914 8.62745 2.01631 8.28392 1.97217 7.88074 1.97217 6.82015 1.97217 6.02714 2.23936 5.4746 2.7444 4.90987 3.26069 4.50889 3.99917 4.28413 4.9762L2.83703 11.1909C2.76126 11.5286 2.666 11.8917 2.54844 12.2812 2.42975 12.6734 2.2873 13.0595 2.12221 13.4373 1.95577 13.8159 1.76813 14.1762 1.55955 14.5171 1.49345 14.6251 1.42515 14.7282 1.35467 14.8263 1.26508 14.9509 1.3347 15.133 1.48655 15.1554 2.13635 15.2509 2.8179 15.0763 3.18197 14.5296 3.32661 14.3124 3.46779 14.0646 3.60509 13.7851 3.96635 13.0497 4.30522 12.0103 4.61867 10.6574L5.469 7.01534C5.49013 6.92483 5.57082 6.86081 5.66376 6.86081H7.62478C7.8097 6.86081 7.97051 6.73405 8.01371 6.55425L8.14014 6.02798C8.20057 5.77642 8.00992 5.53454 7.75121 5.53454H6.06409zM14.3211 5.72037L12.5124 7.96963 11.4089 5.77754C11.3422 5.63012 11.1954 5.5354 11.0336 5.5354H10.3129C10.0085 5.5354 9.80921 5.85428 9.9427 6.1279L11.4089 9.05502 8.79783 12.1493C8.56587 12.4158 8.75519 12.8315 9.10855 12.8315H9.68607C9.80672 12.8315 9.9605 12.7822 10.0388 12.6904L12.1108 10.2648 13.1176 12.561C13.1786 12.7231 13.333 12.8315 13.5061 12.8315H14.3C14.5831 12.8315 14.7417 12.6175 14.6426 12.3524L13.1728 9.28628C13.1728 9.28628 15.4009 6.45542 15.6013 6.17892 15.7966 5.90929 15.6023 5.5354 15.2693 5.5354H14.6661C14.5275 5.5354 14.4333 5.58887 14.3211 5.72037z"}}]},rl=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"fx-single",ref:i,icon:ku}))});rl.displayName="FxSingle";var Du={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M6.4833 1.65005C6.4833 1.31868 6.21467 1.05005 5.8833 1.05005C5.55193 1.05005 5.2833 1.31868 5.2833 1.65005V5.28345H1.65029C1.31892 5.28345 1.05029 5.55208 1.05029 5.88345C1.05029 6.21482 1.31892 6.48345 1.65029 6.48345H5.2833V9.51684H1.65029C1.31892 9.51684 1.05029 9.78547 1.05029 10.1168C1.05029 10.4482 1.31892 10.7168 1.65029 10.7168H5.2833V14.35C5.2833 14.6814 5.55193 14.95 5.8833 14.95C6.21467 14.95 6.4833 14.6814 6.4833 14.35V10.7168H9.5167V14.35C9.5167 14.6814 9.78533 14.95 10.1167 14.95C10.4481 14.95 10.7167 14.6814 10.7167 14.35V10.7168H14.3503C14.6817 10.7168 14.9503 10.4482 14.9503 10.1168C14.9503 9.78547 14.6817 9.51685 14.3503 9.51685H10.7167V6.48345H14.3503C14.6817 6.48345 14.9503 6.21482 14.9503 5.88345C14.9503 5.55208 14.6817 5.28345 14.3503 5.28345H10.7167V1.65005C10.7167 1.31868 10.4481 1.05005 10.1167 1.05005C9.78533 1.05005 9.5167 1.31868 9.5167 1.65005V5.28345L6.4833 5.28345V1.65005ZM6.4833 6.48345V9.51684L9.5167 9.51685V6.48345L6.4833 6.48345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.0498 3.65005C1.0498 2.21411 2.21386 1.05005 3.6498 1.05005H12.3498C13.7857 1.05005 14.9498 2.21411 14.9498 3.65005V12.3501C14.9498 13.786 13.7857 14.95 12.3498 14.95H3.6498C2.21386 14.95 1.0498 13.786 1.0498 12.35V3.65005ZM3.6498 2.25005C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H3.6498Z",fillRule:"evenodd",clipRule:"evenodd"}}]},il=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"hide-gridlines",ref:i,icon:Du}))});il.displayName="HideGridlines";var Nu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},_s=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"increase-single",ref:i,icon:Nu}))});_s.displayName="IncreaseSingle";var Hu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.62402 7.72905C2.58427 7.72905 2.55205 7.76127 2.55205 7.80102V13.6782C2.55205 13.7179 2.58427 13.7502 2.62402 13.7502H13.3755C13.4152 13.7502 13.4474 13.7179 13.4474 13.6782V7.80102C13.4474 7.76127 13.4152 7.72905 13.3755 7.72905H2.62402ZM1.35205 7.80102C1.35205 7.09853 1.92153 6.52905 2.62402 6.52905H13.3755C14.0779 6.52905 14.6474 7.09853 14.6474 7.80102V13.6782C14.6474 14.3807 14.0779 14.9502 13.3755 14.9502H2.62402C1.92153 14.9502 1.35205 14.3807 1.35205 13.6782V7.80102Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M8 2.25005C6.69847 2.25003 5.64336 3.30513 5.64336 4.60666V7.12895C5.64336 7.46032 5.37473 7.72895 5.04336 7.72895 4.71199 7.72895 4.44336 7.46032 4.44336 7.12895V4.60666C4.44336 2.64239 6.04451 1.05565 8.00879 1.05566M8 2.25005L8.00879 1.05566 8 2.25005zM8.00879 1.05566L8 2.25005C9.30154 2.25003 10.3567 3.30513 10.3567 4.60666V7.12895C10.3567 7.46032 10.6253 7.72895 10.9567 7.72895 11.288 7.72895 11.5567 7.46032 11.5567 7.12895V4.60666C11.5567 2.64239 9.97306 1.05565 8.00879 1.05566zM8.00039 9.4668C8.33176 9.4668 8.60039 9.73543 8.60039 10.0668V12.0827C8.60039 12.4141 8.33176 12.6827 8.00039 12.6827 7.66902 12.6827 7.40039 12.4141 7.40039 12.0827V10.0668C7.40039 9.73543 7.66902 9.4668 8.00039 9.4668z",fillRule:"evenodd",clipRule:"evenodd"}}]},Is=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"lock-single",ref:i,icon:Hu}))});Is.displayName="LockSingle";var Vu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},En=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"more-down-single",ref:i,icon:Vu}))});En.displayName="MoreDownSingle";var Wu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.90913 3.57564C6.14345 3.34132 6.52335 3.34132 6.75766 3.57564L10.7577 7.57564C10.992 7.80995 10.992 8.18985 10.7577 8.42417L6.75766 12.4242C6.52335 12.6585 6.14345 12.6585 5.90913 12.4242C5.67482 12.1899 5.67482 11.81 5.90913 11.5756L9.48487 7.9999L5.90913 4.42417C5.67482 4.18985 5.67482 3.80995 5.90913 3.57564Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Bo=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"more-single",ref:i,icon:Wu}))});Bo.displayName="MoreSingle";var Uu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.01281 1.36643C8.79386 0.585377 10.0602 0.585378 10.8412 1.36643L12.9223 3.44752C13.7034 4.22857 13.7034 5.4949 12.9223 6.27595L9.36445 9.83383C8.5834 10.6149 7.31707 10.6149 6.53602 9.83383L4.45493 7.75273C3.67388 6.97168 3.67388 5.70535 4.45493 4.9243L8.01281 1.36643ZM9.9927 2.21495C9.68028 1.90253 9.17375 1.90253 8.86133 2.21495L5.30346 5.77283L5.29671 5.77966L10.839 6.66224L12.0738 5.42742C12.3862 5.115 12.3862 4.60847 12.0738 4.29605L9.9927 2.21495Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.5179 9.48875C14.5179 9.99175 14.1101 10.3995 13.607 10.3995C13.1041 10.3995 12.6963 9.99175 12.6963 9.48875C12.6963 9.1773 13.0455 8.59966 13.3114 8.20487C13.4549 7.99177 13.7591 7.99177 13.9027 8.20486C14.1687 8.59965 14.5179 9.1773 14.5179 9.48875Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}}]},ol=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"paint-bucket",ref:i,icon:Uu}))});ol.displayName="PaintBucket";var Lu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1138",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_1138)"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M7.74692 9.12463C7.74692 9.46018 8.01893 9.73219 8.35448 9.73219H11.4933C11.8288 9.73219 12.1009 9.46018 12.1009 9.12463 12.1009 8.78909 11.8288 8.51707 11.4933 8.51707H8.35448C8.01893 8.51707 7.74692 8.78909 7.74692 9.12463zM10.8636 10.8523C10.8636 11.1879 10.5915 11.4599 10.256 11.4599H8.35448C8.01893 11.4599 7.74692 11.1879 7.74692 10.8523 7.74692 10.5168 8.01893 10.2447 8.35448 10.2447H10.256C10.5915 10.2447 10.8636 10.5168 10.8636 10.8523z"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.4791 1.98268C5.47913 1.71529 5.87912 1.49854 6.37252 1.49854C6.86593 1.49854 7.26592 1.71529 7.26595 1.98268H7.62187C8.22277 1.98268 8.72459 2.39534 8.84412 2.9452H9.39563C10.0856 2.9452 10.6449 3.48923 10.6449 4.16032V6.00569H12.1261C13.161 6.00569 14 6.82174 14 7.82838V11.334C14 11.8174 13.8025 12.281 13.4511 12.6228L12.0693 13.9647C11.7179 14.3065 11.2412 14.4985 10.7442 14.4985H7.91116C7.05024 14.4985 6.32492 14.0431 6.10535 13.2737H3.34925C2.6593 13.2737 2.09998 12.7297 2.09998 12.0586V4.16032C2.09998 3.48923 2.6593 2.9452 3.34925 2.9452H3.90107C4.0206 2.39534 4.52241 1.98268 5.12332 1.98268H5.4791ZM3.97249 4.16032H3.24925L3.24925 12.0586H6.03725V7.82838C6.03725 6.82174 6.87623 6.00569 7.91116 6.00569H9.49563V4.16032H8.7727C8.58289 4.59611 8.13909 4.90183 7.62187 4.90183H5.12332C4.6061 4.90183 4.1623 4.59611 3.97249 4.16032ZM5.12332 2.89403H7.62187C7.79436 2.89403 7.93419 3.03003 7.93419 3.19781V3.68671C7.93419 3.85448 7.79436 3.99049 7.62187 3.99049H5.12332C4.95083 3.99049 4.811 3.85448 4.811 3.68671V3.19781C4.811 3.03003 4.95083 2.89403 5.12332 2.89403ZM7.91116 7.11157C7.56618 7.11157 7.28652 7.38359 7.28652 7.71913V12.7851C7.28652 13.1206 7.56618 13.3927 7.91116 13.3927H10.7442C10.8401 13.3927 10.9337 13.3712 11.0182 13.3311C11.1373 13.2746 11.1859 13.1423 11.1859 13.0134V12.0066C11.1859 11.8724 11.2978 11.7636 11.4358 11.7636H12.4709C12.6034 11.7636 12.7394 11.7163 12.7975 11.6004C12.8388 11.5182 12.8608 11.4272 12.8608 11.334V7.71913C12.8608 7.38359 12.5811 7.11157 12.2362 7.11157H7.91116Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},sl=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"paste-special",ref:i,icon:Lu}))});sl.displayName="PasteSpecial";var Bu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.785 6.77762C5.78908 6.7777 5.79316 6.77774 5.79725 6.77774C5.80134 6.77774 5.80543 6.7777 5.8095 6.77762H10.0184C10.0225 6.7777 10.0266 6.77774 10.0307 6.77774C10.0347 6.77774 10.0388 6.7777 10.0429 6.77762H13.6638V7.63727C13.6638 7.96864 13.9324 8.23727 14.2638 8.23727C14.5951 8.23727 14.8638 7.96864 14.8638 7.63727V3.9999C14.8638 2.56395 13.6997 1.39989 12.2637 1.3999L3.56389 1.39999C2.12797 1.40001 0.96393 2.56405 0.96392 3.99998L0.963867 11.6666C0.963857 13.1025 2.12792 14.2666 3.56387 14.2666H8.0542C8.38557 14.2666 8.6542 13.9979 8.6542 13.6666C8.6542 13.3352 8.38557 13.0666 8.0542 13.0666H3.56387C2.79067 13.0666 2.16386 12.4398 2.16387 11.6666L2.1639 6.77762H5.785ZM6.39725 2.59996L9.43065 2.59993V5.57762H6.39725V2.59996ZM5.19725 5.57762V2.59998L3.56391 2.59999C2.79072 2.6 2.16393 3.22679 2.16392 3.99998L2.16391 5.57762H5.19725ZM13.6638 5.57762V3.9999C13.6638 3.2267 13.037 2.59989 12.2638 2.5999L10.6307 2.59992V5.57762H13.6638Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.1223 10.2333V10.7496C14.7087 10.9869 15.1223 11.5618 15.1223 12.2333V12.8999C15.1223 13.7836 14.406 14.4999 13.5223 14.4999H11.5223C10.6387 14.4999 9.92235 13.7836 9.92235 12.8999V12.2333C9.92235 11.5618 10.336 10.9869 10.9223 10.7496V10.2333C10.9223 9.34961 11.6387 8.63328 12.5223 8.63328C13.406 8.63328 14.1223 9.34961 14.1223 10.2333ZM11.1223 12.2333C11.1223 12.0124 11.3014 11.8333 11.5223 11.8333H13.5223C13.7433 11.8333 13.9223 12.0124 13.9223 12.2333V12.8999C13.9223 13.1209 13.7433 13.2999 13.5223 13.2999H11.5223C11.3014 13.2999 11.1223 13.1209 11.1223 12.8999V12.2333ZM12.9223 10.2333V10.6333H12.1223V10.2333C12.1223 10.0124 12.3014 9.83328 12.5223 9.83328C12.7433 9.83328 12.9223 10.0124 12.9223 10.2333Z",fillRule:"evenodd",clipRule:"evenodd"}}]},al=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"protect-single",ref:i,icon:Bu}))});al.displayName="ProtectSingle";var Fu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M15 8C15 11.866 11.866 15 8 15C4.13401 15 1 11.866 1 8C1 4.13401 4.13401 1 8 1C11.866 1 15 4.13401 15 8ZM8.00008 12.3671C8.46031 12.3671 8.83342 11.994 8.83342 11.5338C8.83342 11.0735 8.46031 10.7004 8.00008 10.7004C7.53985 10.7004 7.16675 11.0735 7.16675 11.5338C7.16675 11.994 7.53985 12.3671 8.00008 12.3671ZM8.5999 4.4335C8.5999 4.10213 8.33127 3.8335 7.9999 3.8335C7.66853 3.8335 7.3999 4.10213 7.3999 4.4335V9.36683C7.3999 9.6982 7.66853 9.96683 7.9999 9.96683C8.33127 9.96683 8.5999 9.6982 8.5999 9.36683V4.4335Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Fo=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"warning-single",ref:i,icon:Fu}))});Fo.displayName="WarningSingle";var ju={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},bs=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"write-single",ref:i,icon:ju}))});bs.displayName="WriteSingle";const zu=()=>{const[,n]=V.useState({});return V.useCallback(()=>n(i=>!i),[])},Xu=()=>{const n=_.useDependency(a.ICommandService),i=_.useDependency(a.IUniverInstanceService),e=_.useDependency(T.IRenderManagerService),t=_.useDependency(wt),r=_.useDependency(a.LocaleService),[o,s]=V.useState([]),[l,c]=V.useState(!1),[d,u]=V.useState({row:-1,col:-1}),[h,g]=V.useState(le.SERIES),[S,f]=V.useState(!1),p=gt(),{sheetSkeletonManagerService:v,selectionRenderService:C}=V.useMemo(()=>{if(p){const z=e.getRenderById(p.getUnitId());return{sheetSkeletonManagerService:z==null?void 0:z.with(exports.SheetSkeletonManagerService),selectionRenderService:z==null?void 0:z.with(ve)}}return{sheetSkeletonManagerService:null,selectionRenderService:null}},[p,e]),I=()=>{f(!0)},R=()=>{f(!1)},w=zu();if(V.useEffect(()=>n.onCommandExecuted((K,ne)=>{K.id===je.id&&w()}).dispose,[w,n]),V.useEffect(()=>{const z=v&&a.toDisposable(v.currentSkeleton$.subscribe(K=>{K&&w()}));return z==null?void 0:z.dispose},[v,w]),V.useEffect(()=>a.toDisposable(t.menu$.subscribe(K=>{s(K.map(ne=>({...ne,index:K.indexOf(ne)})))})).dispose,[t]),V.useEffect(()=>a.toDisposable(t.showMenu$.subscribe(K=>{const{source:ne,target:Q}=t.autoFillLocation||{source:null,target:null};if(K&&ne&&Q){const se=Math.max(ne.rows[ne.rows.length-1],Q.rows[Q.rows.length-1]),ce=Math.max(ne.cols[ne.cols.length-1],Q.cols[Q.cols.length-1]);u({row:se,col:ce})}else u({row:-1,col:-1})})).dispose,[t]),V.useEffect(()=>a.toDisposable(t.applyType$.subscribe(K=>{g(K)})).dispose,[t]),V.useEffect(()=>{function z(){c(!1)}return document.addEventListener("wheel",z),()=>{document.removeEventListener("wheel",z)}},[l]),d.col<0||d.row<0)return null;const M=Ge(i,e);if(!M||!C)return null;const{scene:y}=M,P=v==null?void 0:v.getCurrentSkeleton(),x=C.getViewPort(),A=y==null?void 0:y.scaleX,k=y==null?void 0:y.scaleY,D=y==null?void 0:y.getViewportScrollXY(x);if(!A||!y||!A||!k||!D)return null;const H=(P==null?void 0:P.getNoMergeCellWithCoordByIndex(d.row,d.col).endX)||0,W=(P==null?void 0:P.getNoMergeCellWithCoordByIndex(d.row,d.col).endY)||0,N=T.convertTransformToOffsetX(H,A,D),U=T.convertTransformToOffsetY(W,k,D);if(N==null||U==null)return null;const L=z=>{c(z)},F=z=>{n.executeCommand(ur.id,{type:z.value}),c(!1)},B=l||S,j=o.filter(z=>!z.disable);return b.jsx("div",{className:"univer-absolute univer-inset-0 univer-z-10 univer-size-0",children:b.jsx("div",{style:{left:`${N+2}px`,top:`${U+2}px`,position:"absolute"},onMouseEnter:I,onMouseLeave:R,children:b.jsx(Y.DropdownMenu,{align:"start",items:j.map(z=>({type:"radio",value:h,options:[{label:r.t(z.label),value:z.value}],onSelect:()=>F(z)})),open:l,onOpenChange:L,children:b.jsxs("div",{className:Y.clsx(`
1
+ "use strict";var dd=Object.defineProperty;var ud=(n,i,e)=>i in n?dd(n,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[i]=e;var E=(n,i,e)=>ud(n,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ee=require("@univerjs/docs-ui"),a=require("@univerjs/core"),T=require("@univerjs/engine-render"),_=require("@univerjs/ui"),V=require("react"),O=require("rxjs"),m=require("@univerjs/sheets"),Re=require("@univerjs/docs"),Z=require("@univerjs/engine-formula"),hd=require("@univerjs/engine-numfmt"),b=require("react/jsx-runtime"),Y=require("@univerjs/design"),me=require("rxjs/operators"),md=require("@univerjs/telemetry");function Mi(n,i){if(n==null)return;const e=i.getRenderById(n);if(e==null)return;const{mainComponent:t,scene:r,engine:o,components:s}=e,l=t,c=s.get(ee.DOCS_VIEW_KEY.BACKGROUND);return{document:l,docBackground:c,scene:r,engine:o}}const Ao=[10,400],ls="RANGE_SELECTOR_COMPONENT_KEY",Pi="EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY";var he=(n=>(n.MAIN="__SpreadsheetRender__",n.ROW="__SpreadsheetRowHeader__",n.COLUMN="__SpreadsheetColumnHeader__",n.LEFT_TOP="__SpreadsheetLeftTopPlaceholder__",n))(he||{});const Bs=0,ei=1,bt=10,gd=11,Fs=12,Oi={id:"sheet.command.set-row-header-width",type:a.CommandType.COMMAND,handler:async(n,i)=>{if(!i)return!1;const e=n.get(T.IRenderManagerService);if(!e)return!1;const{unitId:t,subUnitId:r,size:o}=i,s=e.getRenderById(t);if(s){e.getRenderById(t).with(exports.SheetSkeletonManagerService).setRowHeaderSize(s,r,o);const{components:c}=s,d=c.get(he.ROW);d&&d.setCustomHeader({headerStyle:{size:o}})}return!0}},xi={id:"sheet.command.set-col-header-height",type:a.CommandType.COMMAND,handler:async(n,i)=>{if(!i)return!1;const e=n.get(T.IRenderManagerService);if(!e)return!1;const{unitId:t,subUnitId:r,size:o}=i,s=e.getRenderById(t);if(s){e.getRenderById(t).with(exports.SheetSkeletonManagerService).setColumnHeaderSize(s,r,o);const{components:c}=s,d=c.get(he.COLUMN);d&&d.setCustomHeader({headerStyle:{size:o}})}return!0}},ko=a.createInterceptorKey("rangeMovePermissionCheck"),Do=a.createInterceptorKey("rangeFillPermissionCheck");var cs=(n=>(n[n.FORMULA_EDITOR_SHOW=100]="FORMULA_EDITOR_SHOW",n[n.MARK_SELECTION=1e4]="MARK_SELECTION",n))(cs||{});function Rt(n){const i=n.getCurrentTheme(),e=new a.ColorKit(i.primaryColor).setAlpha(.07).toRgbString();return{strokeWidth:1,stroke:i.primaryColor,fill:e,widgets:{},widgetSize:6,widgetStrokeWidth:1,widgetStroke:i.colorWhite,autofillSize:6,autofillStrokeWidth:1,autofillStroke:i.colorWhite,rowHeaderFill:e,rowHeaderStroke:i.primaryColor,rowHeaderStrokeWidth:1,columnHeaderFill:e,columnHeaderStroke:i.primaryColor,columnHeaderStrokeWidth:1,expandCornerSize:40}}class Sd{constructor(){E(this,"_startColumn",-1);E(this,"_startRow",-1);E(this,"_endColumn",-1);E(this,"_endRow",-1);E(this,"_startX",0);E(this,"_startY",0);E(this,"_endX",0);E(this,"_endY",0);E(this,"_primary");E(this,"_rangeType",a.RANGE_TYPE.NORMAL)}get startColumn(){return this._startColumn}get startRow(){return this._startRow}get endColumn(){return this._endColumn}get endRow(){return this._endRow}get startX(){return this._startX}get startY(){return this._startY}get endX(){return this._endX}get endY(){return this._endY}get currentCell(){return this._primary}get rangeType(){return this._rangeType}isEqual(i){const{startColumn:e,startRow:t,endColumn:r,endRow:o}=this,{startColumn:s,startRow:l,endColumn:c,endRow:d}=i;return e===s&&t===l&&r===c&&o===d}highlightToSelection(){if(this._primary)return a.convertCellToRange(this._primary)}getRange(){return{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this.rangeType}}getCell(){return this._primary}getRangeType(){return this._rangeType}setRangeType(i){this._rangeType=i}getValue(){return{rangeWithCoord:this.getRange(),primaryWithCoord:this._primary}}setValue(i,e){const{startColumn:t,startRow:r,endColumn:o,endRow:s,startX:l,startY:c,endX:d,endY:u,rangeType:h}=i;this._startColumn=t,this._startRow=r,this._endColumn=o,this._endRow=s,this._startX=l,this._startY=c,this._endX=d,this._endY=u,h!==void 0&&(this._rangeType=h),e!==void 0&&this.setCurrentCell(e)}setCurrentCell(i){this._primary=i}clearCurrentCell(){this._primary=null}}function Cn(n,i){const{startRow:e,startColumn:t,endRow:r,endColumn:o,rangeType:s}=i,l=r<e?r:e,c=r<e?e:r,d=o<t?o:t,u=o<t?t:o,h=n.getNoMergeCellWithCoordByIndex(l,d),g=n.getNoMergeCellWithCoordByIndex(c,u);return{startRow:e,startColumn:t,endRow:r,endColumn:o,rangeType:s,startY:(h==null?void 0:h.startY)||0,endY:(g==null?void 0:g.endY)||0,startX:(h==null?void 0:h.startX)||0,endX:(g==null?void 0:g.endX)||0}}function Pe(n,i){const{range:e,primary:t,style:r}=n,o=Cn(i,e),s=t&&$n(i,t);return{rangeWithCoord:o,primaryWithCoord:s,style:r}}function $n(n,i){const{actualRow:e,actualColumn:t,isMerged:r,isMergedMainCell:o,startRow:s,startColumn:l,endRow:c,endColumn:d}=i,u=n.getNoMergeCellWithCoordByIndex(e,t),h=n.getNoMergeCellWithCoordByIndex(s,l),g=n.getNoMergeCellWithCoordByIndex(c,d);return{actualRow:e,actualColumn:t,isMerged:r,isMergedMainCell:o,startX:u.startX,startY:u.startY,endX:u.endX,endY:u.endY,mergeInfo:{startRow:s,startColumn:l,endRow:c,endColumn:d,startY:(h==null?void 0:h.startY)||0,endY:(g==null?void 0:g.endY)||0,startX:(h==null?void 0:h.startX)||0,endX:(g==null?void 0:g.endX)||0}}}const js="__SpreadsheetHelperSelectionTempRect",fd=35;class za{constructor(i,e){E(this,"_startOffsetX",0);E(this,"_startOffsetY",0);E(this,"_relativeSelectionPositionRow",0);E(this,"_relativeSelectionPositionColumn",0);E(this,"_relativeSelectionRowLength",0);E(this,"_relativeSelectionColumnLength",0);E(this,"_scenePointerMoveSub");E(this,"_scenePointerUpSub");E(this,"_helperSelection");E(this,"_scrollTimer");E(this,"_activeViewport");E(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});E(this,"_isInMergeState",!1);E(this,"_fillControlColors",[]);E(this,"_skeleton");E(this,"_scene");E(this,"_themeService");E(this,"_injector");E(this,"_selectionHooks");this._control=i,this._skeleton=e.skeleton,this._scene=e.scene,this._themeService=e.themeService,this._injector=e.injector,this._selectionHooks=e.selectionHooks,this._initialControl(),this._initialWidget(),this._initialAutoFill(),this._control.dispose$.subscribe(()=>{this.dispose()})}get isHelperSelection(){return this._control.isHelperSelection}dispose(){var i,e;(i=this._scrollTimer)==null||i.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(e=this._helperSelection)==null||e.dispose()}_getFreeze(){var e,t;return(t=(e=T.withCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,exports.SheetSkeletonManagerService,this._injector.get(a.IUniverInstanceService),this._injector.get(T.IRenderManagerService)))==null?void 0:e.getCurrentParam())==null?void 0:t.skeleton.getWorksheetConfig().freeze}_isSelectionInViewport(i,e){const t=this._getFreeze()||{startRow:-1,startColumn:-1};switch(e.viewportKey){case T.SHEET_VIEWPORT_KEY.VIEW_MAIN:return i.endRow>=t.startRow&&i.endColumn>=t.startColumn;case T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP:case T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT:return i.endColumn>=t.startColumn&&i.startRow<t.startRow;case T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT:case T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM:return i.endRow>=t.startRow&&i.startColumn<t.startColumn;case T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP:case T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT:case T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP:case T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP:return i.startRow<t.startRow&&i.startColumn<t.startColumn}}_clearObserverEvent(){var i,e;(i=this._scenePointerMoveSub)==null||i.unsubscribe(),(e=this._scenePointerUpSub)==null||e.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null}_initialControl(){const{leftControl:i,rightControl:e,topControl:t,bottomControl:r}=this._control;[i,e,t,r].forEach(o=>{o.onPointerEnter$.subscribeEvent(()=>{var l;((l=this._injector.get(ve,a.Quantity.OPTIONAL))==null?void 0:l.interceptor.fetchThroughInterceptors(ko)(!1,null))!==!1&&o.setCursor(T.CURSOR_TYPE.MOVE)}),o.onPointerLeave$.subscribeEvent(()=>{o.resetCursor()}),o.onPointerDown$.subscribeEvent(this._controlPointerDownHandler.bind(this))})}_controlMoving(i,e){var A;const t=this._scene,r=t.getScrollXYInfoByViewport(T.Vector2.FromArray([i,e])),{scaleX:o,scaleY:s}=t.getAncestorScale(),l=this._skeleton.getCellIndexByOffset(i,e,o,s,r),{row:c,column:d}=l,u=this._skeleton.getRowCount()-1,h=this._skeleton.getColumnCount()-1;let g=Math.max(0,c+this._relativeSelectionPositionRow),S=g+this._relativeSelectionRowLength;S>u&&(S=u,S-g<this._relativeSelectionRowLength&&(g=S-this._relativeSelectionRowLength));let f=Math.max(0,d+this._relativeSelectionPositionColumn),p=f+this._relativeSelectionColumnLength;p>h&&(p=h,p-f<this._relativeSelectionColumnLength&&(f=p-this._relativeSelectionColumnLength));const v=this._skeleton.worksheet.getCellInfoInMergeData(g,f),I=Pe({range:{startRow:g,endRow:S,startColumn:f,endColumn:p},primary:v,style:null},this._skeleton),R=this._skeleton.getNoMergeCellWithCoordByIndex(g,f),w=this._skeleton.getNoMergeCellWithCoordByIndex(S,p),M=(R==null?void 0:R.startY)||0,y=(w==null?void 0:w.endY)||0,P=(R==null?void 0:R.startX)||0,x=(w==null?void 0:w.endX)||0;(A=this._helperSelection)==null||A.transformByState({left:P,top:M,width:x-P,height:y-M}),this._targetSelection={...I.rangeWithCoord},this._control.selectionMoving$.next(I.rangeWithCoord)}_controlPointerDownHandler(i){const{offsetX:e,offsetY:t}=i,r=this._scene,o=r.getCoordRelativeToViewport(T.Vector2.FromArray([e,t])),{x:s,y:l}=o,c=r.getScrollXYInfoByViewport(o),{scaleX:d,scaleY:u}=r.getAncestorScale(),h=this._skeleton.getCellIndexByOffset(s,l,d,u,c);this._startOffsetX=s,this._startOffsetY=l;const{row:g,column:S}=h,{startRow:f,startColumn:p,endRow:v,endColumn:C}=this._control.model;let I=0,R=0;g<f?I-=1:g>v&&(I+=1),S<p?R-=1:S>C&&(R+=1),this._relativeSelectionPositionRow=f-g+I,this._relativeSelectionPositionColumn=p-S+R,this._relativeSelectionRowLength=v-f,this._relativeSelectionColumnLength=C-p;const w=this._control.currentStyle,M=this._getScale();this.isHelperSelection&&(this._helperSelection=new T.Rect(js,{stroke:w.stroke,strokeWidth:w.strokeWidth/M}),r.addObject(this._helperSelection));const y=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),P=T.ScrollTimer.create(r);this._scrollTimer=P,P.startScroll(s,l,y),r.disableObjectsEvent(),this._scenePointerMoveSub=r.onPointerMove$.subscribeEvent(x=>{var N;const{offsetX:A,offsetY:k}=x;if(((N=this._injector.get(ve,a.Quantity.OPTIONAL))==null?void 0:N.interceptor.fetchThroughInterceptors(ko)(!1,null))===!1)return;const{x:H,y:W}=r.getCoordRelativeToViewport(T.Vector2.FromArray([A,k]));this._controlMoving(H,W),r.setCursor(T.CURSOR_TYPE.MOVE),P.scrolling(H,W,()=>{this._controlMoving(H,W)})}),this._scenePointerUpSub=r.onPointerUp$.subscribeEvent(()=>{var A,k,D,H;(A=this._helperSelection)==null||A.dispose();const x=this._scene;x.resetCursor(),this._clearObserverEvent(),x.enableObjectsEvent(),(k=this._scrollTimer)==null||k.dispose(),this._control.selectionMoveEnd$.next(this._targetSelection),(H=(D=this._selectionHooks).selectionMoveEnd)==null||H.call(D)})}_initialWidget(){const{topLeftWidget:i,topCenterWidget:e,topRightWidget:t,middleLeftWidget:r,middleRightWidget:o,bottomLeftWidget:s,bottomCenterWidget:l,bottomRightWidget:c}=this._control,d=[T.CURSOR_TYPE.NORTH_WEST_RESIZE,T.CURSOR_TYPE.NORTH_RESIZE,T.CURSOR_TYPE.NORTH_EAST_RESIZE,T.CURSOR_TYPE.WEST_RESIZE,T.CURSOR_TYPE.EAST_RESIZE,T.CURSOR_TYPE.SOUTH_WEST_RESIZE,T.CURSOR_TYPE.SOUTH_RESIZE,T.CURSOR_TYPE.SOUTH_EAST_RESIZE];[i,e,t,r,o,s,l,c].forEach((u,h)=>{u.onPointerEnter$.subscribeEvent(()=>{u.setCursor(d[h])}),u.onPointerLeave$.subscribeEvent(()=>{u.resetCursor()}),u.onPointerDown$.subscribeEvent(g=>{this._widgetPointerDownEvent(g,d[h])})})}_widgetPointerDownEvent(i,e){const t=this._scene,{offsetX:r,offsetY:o}=i,s=t.getCoordRelativeToViewport(T.Vector2.FromArray([r,o])),{x:l,y:c}=s;this._startOffsetX=r,this._startOffsetY=o;const{startRow:d,startColumn:u,endRow:h,endColumn:g}=this._control.model,S=Math.min(d,h),f=Math.min(u,g),p=Math.max(d,h),v=Math.max(u,g);this._relativeSelectionPositionRow=S,this._relativeSelectionPositionColumn=f,this._relativeSelectionRowLength=p-S,this._relativeSelectionColumnLength=v-f,e===T.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=p,this._relativeSelectionPositionColumn=v):e===T.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=p:e===T.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=p:e===T.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=v:e===T.CURSOR_TYPE.SOUTH_WEST_RESIZE?this._relativeSelectionPositionColumn=v:e===T.CURSOR_TYPE.SOUTH_RESIZE&&(this._relativeSelectionPositionRow=S);const C=T.ScrollTimer.create(t),I=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);C.startScroll(l,c,I),this._scrollTimer=C,t.disableObjectsEvent(),this._scenePointerMoveSub=t.onPointerMove$.subscribeEvent(R=>{const{offsetX:w,offsetY:M}=R,{x:y,y:P}=t.getCoordRelativeToViewport(T.Vector2.FromArray([w,M]));this._widgetMoving(y,P,e),t.setCursor(e),C.scrolling(y,P,()=>{this._widgetMoving(y,P,e)})}),this._scenePointerUpSub=t.onPointerUp$.subscribeEvent(()=>{var w,M,y;const R=this._scene;R.resetCursor(),this._clearObserverEvent(),R.enableObjectsEvent(),(w=this._scrollTimer)==null||w.dispose(),this._control.selectionScaled$.next(this._targetSelection),(y=(M=this._selectionHooks).selectionMoveEnd)==null||y.call(M)})}_widgetMoving(i,e,t){const r=this._scene,o=r.getScrollXYInfoByViewport(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:l}=r.getAncestorScale(),c=this._skeleton.getCellIndexByOffset(i,e,s,l,o),{row:d,column:u}=c;let h=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,S=d,f=u;t===T.CURSOR_TYPE.NORTH_WEST_RESIZE?(h=d,g=u,S=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn):t===T.CURSOR_TYPE.NORTH_RESIZE?(h=d,g=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):t===T.CURSOR_TYPE.NORTH_EAST_RESIZE?(h=d,g=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,f=u):t===T.CURSOR_TYPE.WEST_RESIZE?(h=this._relativeSelectionPositionRow,g=u,S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,f=this._relativeSelectionPositionColumn):t===T.CURSOR_TYPE.EAST_RESIZE?S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:t===T.CURSOR_TYPE.SOUTH_WEST_RESIZE?(h=this._relativeSelectionPositionRow,g=u,S=d,f=this._relativeSelectionPositionColumn):t===T.CURSOR_TYPE.SOUTH_RESIZE&&(h=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,S=d,f=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const p=this._swapPositions(h,g,S,f),v=this._skeleton.getCellWithMergeInfoByIndex(h,g),I=Pe({range:p,primary:v,style:null},this._skeleton);this._targetSelection={...I.rangeWithCoord},this._control.updateRangeBySelectionWithCoord(I),this._control.selectionScaling$.next(this._targetSelection)}_initialAutoFill(){const{fillControl:i}=this._control;i.onPointerEnter$.subscribeEvent(e=>{this._injector.get(ve).interceptor.fetchThroughInterceptors(Do)(!1,{x:e.offsetX,y:e.offsetY,skeleton:this._skeleton,scene:this._scene})&&i.setCursor(T.CURSOR_TYPE.CROSSHAIR)}),i.onPointerLeave$.subscribeEvent(()=>{i.resetCursor()}),i.onPointerDown$.subscribeEvent(this._autoFillForPointerdown.bind(this))}_autoFillMoving(i,e){var k,D,H;const t=this._scene,r=t.getViewportScrollXY(this._activeViewport),{scaleX:o,scaleY:s}=t.getAncestorScale(),l=this._skeleton.getCellIndexByOffset(i,e,o,s,r),{row:c,column:d}=l,u=t.getCoordRelativeToViewport(T.Vector2.FromArray([i,e])),h=this._skeleton.getRowCount()-1,g=this._skeleton.getColumnCount()-1;let S=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn,p=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,C=!1,I=!0;if((d<f||d>v)&&c>=S&&c<=p){const W=this._fillRuler(d,f,v,this._relativeSelectionColumnLength,g);f=W.startRowOrColumn,v=W.endRowOrColumn,C=W.isLighten,I=!1}else if((c<S||c>p)&&d>=f&&d<=v){const W=this._fillRuler(c,S,p,this._relativeSelectionRowLength,h);S=W.startRowOrColumn,p=W.endRowOrColumn,C=W.isLighten}else if(Math.abs(this._startOffsetX-u.x-r.x)/2>Math.abs(this._startOffsetY-u.y-r.y)){const W=this._fillRuler(d,f,v,this._relativeSelectionColumnLength,g);f=W.startRowOrColumn,v=W.endRowOrColumn,C=W.isLighten,I=!1}else{const W=this._fillRuler(c,S,p,this._relativeSelectionRowLength,h);S=W.startRowOrColumn,p=W.endRowOrColumn,C=W.isLighten}const R=this._skeleton.getNoMergeCellWithCoordByIndex(S,f),w=this._skeleton.getNoMergeCellWithCoordByIndex(p,v),M=(R==null?void 0:R.startY)||0,y=(w==null?void 0:w.endY)||0,P=(R==null?void 0:R.startX)||0,x=(w==null?void 0:w.endX)||0;C?this._controlHandler((W,N)=>{const U=new a.ColorKit(this._fillControlColors[N]).lighten(fd).toRgbString();W.setProps({fill:U})}):this._controlHandler((W,N)=>{W.setProps({fill:this._fillControlColors[N]})});const A=m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();S===p&&I===!0||f===v&&I===!1?(k=this._helperSelection)==null||k.hide():((D=this._helperSelection)==null||D.transformByState({left:P-A/2,top:M-A/2,width:x-P,height:y-M}),(H=this._helperSelection)==null||H.show()),this._targetSelection={startY:M,endY:y,startX:P,endX:x,startRow:S,endRow:p,startColumn:f,endColumn:v},this._control.selectionFilling$.next(this._targetSelection)}_autoFillForPointerdown(i){const{offsetX:e,offsetY:t}=i,r=this._scene,o=r.getCoordRelativeToViewport(T.Vector2.FromArray([e,t])),{x:s,y:l}=o;this._startOffsetX=s,this._startOffsetY=l;const{startRow:c,startColumn:d,endRow:u,endColumn:h}=this._control.model;this._isInMergeState=this._hasMergeInRange(c,d,u,h),this._relativeSelectionPositionRow=c,this._relativeSelectionPositionColumn=d,this._relativeSelectionRowLength=u-c,this._relativeSelectionColumnLength=h-d;const g=this._control.currentStyle;let S=g==null?void 0:g.stroke,f=g==null?void 0:g.strokeWidth;const p=Rt(this._themeService);S==null&&(S=p.stroke),f==null&&(f=p.strokeWidth);const v=this._getScale();f/=v;const C=m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/v,I=new a.ColorKit(S).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new T.Rect(js,{stroke:I,strokeWidth:f+C/2}),r.addObject(this._helperSelection)),this._activeViewport=r.getActiveViewportByCoord(T.Vector2.FromArray([e,t]));const R=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),w=T.ScrollTimer.create(r,this._activeViewport.viewportKey===T.SHEET_VIEWPORT_KEY.VIEW_MAIN?T.ScrollTimerType.ALL:T.ScrollTimerType.NONE);w.startScroll(s,l,R),this._scrollTimer=w,r.disableObjectsEvent(),this._controlHandler(M=>{this._fillControlColors.push(M.fill)}),this._scenePointerMoveSub=r.onPointerMove$.subscribeEvent(M=>{var W;const{offsetX:y,offsetY:P}=M,x=r.getActiveViewportByCoord(T.Vector2.FromArray([y,P]));if(!this._injector.get(ve).interceptor.fetchThroughInterceptors(Do)(!1,{x:i.offsetX,y:i.offsetY,skeleton:this._skeleton,scene:this._scene}))return;const{x:k,y:D}=r.getCoordRelativeToViewport(T.Vector2.FromArray([y,P]));this._autoFillMoving(k,D),r.setCursor(T.CURSOR_TYPE.CROSSHAIR);const H=this._targetSelection;if(R&&x&&((W=this._activeViewport)==null?void 0:W.viewportKey)!==(x==null?void 0:x.viewportKey)){let N;H.startRow!==c?(w.scrollTimerType=T.ScrollTimerType.Y,N={...H,endRow:H.startRow}):H.endRow!==u?(w.scrollTimerType=T.ScrollTimerType.Y,N={...H,startRow:H.endRow}):H.startColumn!==d?(w.scrollTimerType=T.ScrollTimerType.X,N={...H,endColumn:H.startColumn}):(w.scrollTimerType=T.ScrollTimerType.X,N={...H,startColumn:H.endColumn}),this._isSelectionInViewport(N,x)&&(R.scrollToBarPos({x:w.scrollTimerType===T.ScrollTimerType.X?0:void 0,y:w.scrollTimerType===T.ScrollTimerType.Y?0:void 0}),this._activeViewport=x)}w.scrolling(k,D,()=>{this._autoFillMoving(k,D)})}),this._scenePointerUpSub=r.onPointerUp$.subscribeEvent(()=>{var y,P;(y=this._helperSelection)==null||y.dispose();const M=this._scene;M.resetCursor(),this._clearObserverEvent(),M.enableObjectsEvent(),(P=this._scrollTimer)==null||P.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((x,A)=>{x.setProps({fill:this._fillControlColors[A]})}),this._fillControlColors=[]})}_hasMergeInRange(i,e,t,r){return this._skeleton.worksheet.getMergedCellRange(i,e,t,r).length>0}_swapPositions(i,e,t,r){const o=Math.min(i,t),s=Math.min(e,r),l=Math.max(i,t),c=Math.max(e,r);return{startRow:o,startColumn:s,endRow:l,endColumn:c}}_controlHandler(i){const{leftControl:e,rightControl:t,topControl:r,bottomControl:o,backgroundControlTop:s,backgroundControlMiddleLeft:l,backgroundControlMiddleRight:c,backgroundControlBottom:d,fillControl:u}=this._control,h=[e,t,r,o,s,l,c,d,u];for(let g=0,S=h.length;g<S;g++){const f=h[g];i(f,g)}}_fillRuler(i,e,t,r,o){let s=!1;if(i<e)if(this._isInMergeState&&i<e){const l=e-i,c=r+1,d=Math.ceil(l/c);let u=e-d*c;u<0&&(u=e-(d-1)*c),e=u}else e=i;else if(i>=e&&i<=t)s=!0,this._isInMergeState||(t=i);else if(this._isInMergeState&&i>t){const l=i-t,c=r+1,d=Math.ceil(l/c);let u=t+d*c;u>o&&(u=t+(d-1)*c),t=u}else t=i;return{rowOrColumn:i,startRowOrColumn:e,endRowOrColumn:t,isLighten:s}}_getScale(){const{scaleX:i,scaleY:e}=this._scene.getAncestorScale();return Math.max(i,e)}}var No=(n=>(n.Selection="__SpreadsheetSelectionShape__",n.top="__SpreadsheetSelectionTopControl__",n.bottom="__SpreadsheetSelectionBottomControl__",n.left="__SpreadsheetSelectionShapeLeftControl__",n.right="__SpreadsheetSelectionShapeRightControl__",n.backgroundTop="__SpreadsheetSelectionBackgroundControlTop__",n.backgroundMiddleLeft="__SpreadsheetSelectionBackgroundControlMiddleLeft__",n.backgroundMiddleRight="__SpreadsheetSelectionBackgroundControlMiddleRight__",n.backgroundBottom="__SpreadsheetSelectionBackgroundControlBottom__",n.fill="__SpreadsheetSelectionFillControl__",n.fillTopLeft="__SpreadsheetSelectionFillControlTopLeft__",n.fillBottomRight="__SpreadsheetSelectionFillControlBottomRight__",n.fillTopLeftInner="__SpreadsheetSelectionFillControlTopLeftInner__",n.fillBottomRightInner="__SpreadsheetSelectionFillControlBottomRightInner__",n.lineMain="__SpreadsheetDragLineMainControl__",n.lineContent="__SpreadsheetDragLineContentControl__",n.line="__SpreadsheetDragLineControl__",n.dash="__SpreadsheetDragDashControl__",n.rowHeaderBackground="__SpreadSheetSelectionRowHeaderBackground__",n.rowHeaderBorder="__SpreadSheetSelectionRowHeaderBorder__",n.rowHeaderGroup="__SpreadSheetSelectionRowHeaderGroup__",n.columnHeaderBackground="__SpreadSheetSelectionColumnHeaderBackground__",n.columnHeaderBorder="__SpreadSheetSelectionColumnHeaderBorder__",n.columnHeaderGroup="__SpreadSheetSelectionColumnHeaderGroup__",n.topLeftWidget="__SpreadSheetSelectionTopLeftWidget__",n.topCenterWidget="__SpreadSheetSelectionTopCenterWidget__",n.topRightWidget="__SpreadSheetSelectionTopRightWidget__",n.middleLeftWidget="__SpreadSheetSelectionMiddleLeftWidget__",n.middleRightWidget="__SpreadSheetSelectionMiddleRightWidget__",n.bottomLeftWidget="__SpreadSheetSelectionBottomLeftWidget__",n.bottomCenterWidget="__SpreadSheetSelectionBottomCenterWidget__",n.bottomRightWidget="__SpreadSheetSelectionBottomRightWidget__",n))(No||{});const zs=.3;class cr extends a.Disposable{constructor(e,t,r,o){var s,l,c,d;super();E(this,"_isHelperSelection",!0);E(this,"_enableAutoFill",!0);E(this,"_showAutoFill",!1);E(this,"_highlightHeader",!0);E(this,"_selectionRenderModel");E(this,"_leftBorder");E(this,"_rightBorder");E(this,"_topBorder");E(this,"_bottomBorder");E(this,"_backgroundControlTop");E(this,"_backgroundControlBottom");E(this,"_backgroundControlMiddleLeft");E(this,"_backgroundControlMiddleRight");E(this,"_autoFillControl");E(this,"_selectionShapeGroup");E(this,"_rowHeaderBackground");E(this,"_rowHeaderBorder");E(this,"_rowHeaderGroup");E(this,"_columnHeaderBackground");E(this,"_columnHeaderBorder");E(this,"_columnHeaderGroup");E(this,"_dashedRect");E(this,"_topLeftWidget");E(this,"_topCenterWidget");E(this,"_topRightWidget");E(this,"_middleLeftWidget");E(this,"_middleRightWidget");E(this,"_bottomLeftWidget");E(this,"_bottomCenterWidget");E(this,"_bottomRightWidget");E(this,"_defaultStyle");E(this,"_currentStyle");E(this,"_rowHeaderWidth",0);E(this,"_columnHeaderHeight",0);E(this,"_widgetRects",[]);E(this,"_controlExtension");E(this,"_dispose$",new O.BehaviorSubject(this));E(this,"dispose$",this._dispose$.asObservable());E(this,"selectionMoving$",new O.Subject);E(this,"selectionMoveEnd$",new O.Subject);E(this,"selectionScaling$",new O.Subject);E(this,"selectionScaled$",new O.Subject);E(this,"selectionFilling$",new O.Subject);E(this,"_selectionFilled$",new O.Subject);E(this,"selectionFilled$",this._selectionFilled$.asObservable());E(this,"_antLineOffset",0);E(this,"_antRequestNewFrame",-1);this._scene=e,this._zIndex=t,this._themeService=r,this._enableAutoFill=(s=o==null?void 0:o.enableAutoFill)!=null?s:!0,this._highlightHeader=(l=o==null?void 0:o.highlightHeader)!=null?l:!0,this._rowHeaderWidth=(c=o==null?void 0:o.rowHeaderWidth)!=null?c:0,this._columnHeaderHeight=(d=o==null?void 0:o.columnHeaderHeight)!=null?d:0,this._initializeSheetBody(),this._initialHeader()}_initializeSheetBody(){this._defaultStyle=Rt(this._themeService),this._currentStyle=Rt(this._themeService),this._selectionRenderModel=new Sd;const e=this._zIndex;this._leftBorder=new T.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightBorder=new T.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topBorder=new T.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomBorder=new T.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new T.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new T.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new T.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new T.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._autoFillControl=new T.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._autoFillControl.hide(),this._dashedRect=new T.DashedRect("__SpreadsheetDragDashControl__"+e,{zIndex:e+2,evented:!1,stroke:"#fff"});const t=[this._autoFillControl,this._leftBorder,this._rightBorder,this._topBorder,this._bottomBorder,this._backgroundControlTop,this._backgroundControlMiddleLeft,this._backgroundControlMiddleRight,this._backgroundControlBottom,this._dashedRect];this._widgetRects=this._initialWidget(),this._selectionShapeGroup=new T.Group("__SpreadsheetSelectionShape__"+e,...t,...this._widgetRects),this._selectionShapeGroup.hide(),this._selectionShapeGroup.evented=!1,this._selectionShapeGroup.zIndex=e;const r=this.getScene();r.addObject(this._selectionShapeGroup,ei),this.disposeWithMe(a.toDisposable(r.onTransformChange$.subscribeEvent(o=>{o.type===T.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&(this._updateLayoutOfSelectionControl(this._currentStyle),this._updateControlCoord())})))}_initialHeader(){const e=this._zIndex;this._rowHeaderBackground=new T.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new T.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new T.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new T.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new T.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new T.Group("__SpreadSheetSelectionColumnHeaderGroup__"+e,this._columnHeaderBackground,this._columnHeaderBorder),this._columnHeaderGroup.hide(),this._columnHeaderGroup.evented=!1,this._columnHeaderGroup.zIndex=e,this.getScene().addObjects([this._rowHeaderGroup,this._columnHeaderGroup],gd)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new T.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new T.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new T.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new T.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new T.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new T.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new T.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new T.Rect("__SpreadSheetSelectionBottomRightWidget__"+e,{zIndex:e+1}),[this._topLeftWidget,this._topCenterWidget,this._topRightWidget,this._middleLeftWidget,this._middleRightWidget,this._bottomLeftWidget,this._bottomCenterWidget,this._bottomRightWidget]}get zIndex(){return this._zIndex}get leftControl(){return this._leftBorder}get rightControl(){return this._rightBorder}get topControl(){return this._topBorder}get bottomControl(){return this._bottomBorder}get fillControl(){return this._autoFillControl}get backgroundControlTop(){return this._backgroundControlTop}get backgroundControlBottom(){return this._backgroundControlBottom}get backgroundControlMiddleLeft(){return this._backgroundControlMiddleLeft}get backgroundControlMiddleRight(){return this._backgroundControlMiddleRight}get selectionShape(){return this._selectionShapeGroup}get columnHeaderGroup(){return this._columnHeaderGroup}get rowHeaderGroup(){return this._rowHeaderGroup}get selectionShapeGroup(){return this._selectionShapeGroup}get model(){return this._selectionRenderModel}get topLeftWidget(){return this._topLeftWidget}get topCenterWidget(){return this._topCenterWidget}get topRightWidget(){return this._topRightWidget}get middleLeftWidget(){return this._middleLeftWidget}get middleRightWidget(){return this._middleRightWidget}get bottomLeftWidget(){return this._bottomLeftWidget}get bottomCenterWidget(){return this._bottomCenterWidget}get bottomRightWidget(){return this._bottomRightWidget}get themeService(){return this._themeService}get selectionModel(){return this._selectionRenderModel}set selectionModel(e){this._selectionRenderModel=e}get currentStyle(){return this._currentStyle}set currentStyle(e){this._currentStyle=e}get dashedRect(){return this._dashedRect}get isHelperSelection(){return this._isHelperSelection}get rowHeaderWidth(){return this._rowHeaderWidth}set rowHeaderWidth(e){this._rowHeaderWidth=e}get columnHeaderHeight(){return this._columnHeaderHeight}set columnHeaderHeight(e){this._columnHeaderHeight=e}setControlExtension(e){this._controlExtension=new za(this,e)}setEvent(e){this.leftControl.evented=e,this.rightControl.evented=e,this.topControl.evented=e,this.bottomControl.evented=e}refreshSelectionFilled(e){this._selectionFilled$.next(e)}_updateLayoutOfSelectionControl(e){e&&(this.currentStyle=Object.assign({},this._defaultStyle,e));const t=this.currentStyle,{stroke:r,widgets:o,autofillStroke:s,strokeDash:l,isAnimationDash:c}=t;let d=t.autofillSize,u=t.strokeWidth,h=t.autofillStrokeWidth;const g=this._getScale(),S=(u+m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH)/2/g;u/=g,d/=g,h/=g<1?1:g;const f=m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/g,p=T.FIX_ONE_PIXEL_BLUR_OFFSET/g,{startX:v,startY:C,endX:I,endY:R}=this._selectionRenderModel;if(this.leftControl.transformByState({height:R-C,left:-S+p,width:u,strokeWidth:f,top:-f/2+p}),this.leftControl.setProps({fill:r,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:R-C,left:I-v-S+p,width:u,strokeWidth:f,top:-f/2+p}),this.rightControl.setProps({fill:r,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:I-v+u,top:-S+p,left:-S+p,height:u,strokeWidth:f}),this.topControl.setProps({fill:r,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:I-v+u,top:R-C-S+p,height:u,left:-S+p,strokeWidth:f}),this.bottomControl.setProps({fill:r,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),l==null)this.dashedRect.hide(),this._stopAntLineAnimation();else{const w=t.strokeWidth*2/g;this.dashedRect.transformByState({height:R-C,width:I-v,strokeWidth:w,left:-w/2+p,top:-w/2+p}),this.dashedRect.setProps({strokeDashArray:[0,l/g]}),this._stopAntLineAnimation(),c!==!1&&this._startAntLineAnimation(),this.dashedRect.show()}if(this._showAutoFill=this._showAutoFill&&this._enableAutoFill,this._showAutoFill&&!this._hasWidgets(o)){const w={fill:r,stroke:s,strokeScaleEnabled:!1},M={width:d-h,height:d-h,left:I-v-d/2+h/2-p,top:R-C-d/2+h/2-p,strokeWidth:h};this._autoFillControl.setProps(w),this._autoFillControl.transformByState(M),this._autoFillControl.show()}else this._autoFillControl.hide();this._updateBackgroundControl(t),this._updateHeaderBackground(t),this._updateWidgets(t)}_updateControlCoord(){const{startX:e,startY:t}=this._selectionRenderModel;this.selectionShapeGroup.show(),this.selectionShapeGroup.translate(e,t),this.selectionShapeGroup.makeDirtyNoDebounce(!0)}updateStyle(e){this._updateLayoutOfSelectionControl(e),this._updateControlCoord()}updateRange(e,t){this._selectionRenderModel.setValue(e,t),this._showAutoFill=t!==null,this._updateLayoutOfSelectionControl(),this._updateControlCoord()}updateRangeBySelectionWithCoord(e,t){t&&(this._rowHeaderWidth=t.rowHeaderWidth,this._columnHeaderHeight=t.columnHeaderHeight),this._selectionRenderModel.setValue(e.rangeWithCoord,e.primaryWithCoord),this._showAutoFill=e.primaryWithCoord!==null,this._updateLayoutOfSelectionControl(e.style),this._updateControlCoord()}update(e,t=0,r=0,o,s){this._rowHeaderWidth=t,this._columnHeaderHeight=r,this.updateRangeBySelectionWithCoord({rangeWithCoord:e,primaryWithCoord:s,style:o}),o&&this.updateStyle(o)}updateCurrCell(e){this._showAutoFill=e!==null,this._selectionRenderModel.setCurrentCell(e)}clearHighlight(){this._showAutoFill=!1,this._selectionRenderModel.clearCurrentCell(),this._updateLayoutOfSelectionControl(this._currentStyle)}getScene(){return this._scene}dispose(){var e,t,r,o,s,l,c,d,u,h,g,S,f,p,v,C,I,R,w,M,y,P,x,A,k;(e=this._leftBorder)==null||e.dispose(),(t=this._rightBorder)==null||t.dispose(),(r=this._topBorder)==null||r.dispose(),(o=this._bottomBorder)==null||o.dispose(),(s=this._backgroundControlTop)==null||s.dispose(),(l=this._backgroundControlMiddleLeft)==null||l.dispose(),(c=this._backgroundControlMiddleRight)==null||c.dispose(),(d=this._backgroundControlBottom)==null||d.dispose(),this._autoFillControl.dispose(),(u=this._selectionShapeGroup)==null||u.dispose(),(h=this._rowHeaderBackground)==null||h.dispose(),(g=this._rowHeaderBorder)==null||g.dispose(),(S=this._rowHeaderGroup)==null||S.dispose(),(f=this._rowHeaderBackground)==null||f.dispose(),(p=this._columnHeaderBackground)==null||p.dispose(),(v=this._columnHeaderBorder)==null||v.dispose(),(C=this._columnHeaderGroup)==null||C.dispose(),(I=this._topLeftWidget)==null||I.dispose(),(R=this._topCenterWidget)==null||R.dispose(),(w=this._topRightWidget)==null||w.dispose(),(M=this._middleLeftWidget)==null||M.dispose(),(y=this._middleRightWidget)==null||y.dispose(),(P=this._bottomLeftWidget)==null||P.dispose(),(x=this._bottomCenterWidget)==null||x.dispose(),(A=this._bottomRightWidget)==null||A.dispose(),(k=this._controlExtension)==null||k.dispose(),super.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let t;if(e.isMerged){const r=e.mergeInfo;t={startRow:r.startRow,endRow:r.endRow,startColumn:r.startColumn,endColumn:r.endColumn,startX:r.startX,endX:r.endX,startY:r.startY,endY:r.endY}}else{const{actualRow:r,actualColumn:o,startX:s,endX:l,startY:c,endY:d}=e;t={startRow:r,endRow:r,startColumn:o,endColumn:o,startX:s,endX:l,startY:c,endY:d}}return t}}getValue(){return{...this._selectionRenderModel.getValue(),style:this._currentStyle}}getRange(){return this._selectionRenderModel.getValue().rangeWithCoord}enableHelperSelection(){this._isHelperSelection=!0}disableHelperSelection(){this._isHelperSelection=!1}_updateHeaderBackground(e){const{startX:t,startY:r,endX:o,endY:s,rangeType:l}=this._selectionRenderModel,c=this._currentStyle,d=this._getScale(),{stroke:u,rowHeaderFill:h=c.rowHeaderFill,rowHeaderStroke:g=c.rowHeaderStroke,columnHeaderFill:S=c.columnHeaderFill,columnHeaderStroke:f=c.columnHeaderStroke}=e;let{rowHeaderStrokeWidth:p=c.rowHeaderStrokeWidth,columnHeaderStrokeWidth:v=c.columnHeaderStrokeWidth}=e;p/=d,v/=d;const C=this._rowHeaderWidth,I=this._columnHeaderHeight;if(this._highlightHeader&&I>0){let R=S;l===a.RANGE_TYPE.COLUMN&&(R=new a.ColorKit(u).setAlpha(zs).toString()),this._columnHeaderBackground.setProps({fill:R}),this._columnHeaderBackground.resize(o-t,I),this._columnHeaderBorder.setProps({fill:f}),this._columnHeaderBorder.transformByState({width:o-t,height:v,top:I-v+1/d}),this._columnHeaderGroup.show(),this._columnHeaderGroup.translate(t,0)}else this._columnHeaderGroup.hide();if(this._columnHeaderGroup.makeDirty(!0),this._highlightHeader&&C>0){let R=h;l===a.RANGE_TYPE.ROW&&(R=new a.ColorKit(u).setAlpha(zs).toString()),this._rowHeaderBackground.setProps({fill:R}),this._rowHeaderBackground.resize(C,s-r),this._rowHeaderBorder.setProps({fill:g}),this._rowHeaderBorder.transformByState({width:p,height:s-r,left:C-p+1/d}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,r)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){const{startX:t,startY:r,endX:o,endY:s}=this._selectionRenderModel,l=this._getScale(),{fill:c=e.fill}=e;let{strokeWidth:d}=e;d/=l;const u=this._selectionRenderModel.highlightToSelection();if(!u){this._backgroundControlTop.resize(o-t,s-r),this._backgroundControlTop.setProps({fill:c}),this._backgroundControlBottom.resize(0,0),this._backgroundControlMiddleLeft.resize(0,0),this._backgroundControlMiddleRight.resize(0,0);return}const{startX:h,startY:g,endX:S,endY:f}=u,p=d/2,v={left:-p,top:-p,width:o-t+p*2,height:g-r+p};v.height<0&&(v.width=0,v.height=0),this._backgroundControlTop.transformByState(v);const C={left:-p,top:g-r,width:h-t+p,height:f-g};C.width<0&&(C.width=0,C.height=0),this._backgroundControlMiddleLeft.transformByState(C);const I={left:S-t-p,top:g-r,width:o-S+p*2,height:f-g};I.width<0&&(I.width=0,I.height=0),this._backgroundControlMiddleRight.transformByState(I);const R={left:-p,top:f-r,width:o-t+p*2,height:s-f+p};R.height<0&&(R.width=0,R.height=0),this._backgroundControlBottom.transformByState(R),this._backgroundControlTop.setProps({fill:c}),this._backgroundControlMiddleLeft.setProps({fill:c}),this._backgroundControlMiddleRight.setProps({fill:c}),this._backgroundControlBottom.setProps({fill:c})}_updateWidgets(e){const{startX:t,startY:r,endX:o,endY:s}=this._selectionRenderModel,{stroke:l=e.stroke,widgets:c=e.widgets,widgetStroke:d=e.widgetStroke}=e,u=this._getScale();let{widgetSize:h,widgetStrokeWidth:g}=e;h/=u,g/=u;const S={left:-h/2+g/2,center:(o-t)/2-h/2+g/2,right:o-t-h/2+g/2,top:-h/2,middle:(s-r)/2-h/2,bottom:s-r-h/2+g/2},f=h-g;this._widgetRects.forEach(p=>{p.setProps({fill:l,stroke:d})}),c.tl===!0?(this._topLeftWidget.transformByState({height:f,width:f,left:S.left,top:S.top,strokeWidth:g}),this._topLeftWidget.show()):this._topLeftWidget.hide(),c.tc===!0?(this._topCenterWidget.transformByState({height:f,width:f,left:S.center,top:S.top,strokeWidth:g}),this._topCenterWidget.show()):this._topCenterWidget.hide(),c.tr===!0?(this._topRightWidget.transformByState({height:f,width:f,left:S.right,top:S.top,strokeWidth:g}),this._topRightWidget.show()):this._topRightWidget.hide(),c.ml===!0?(this._middleLeftWidget.transformByState({height:f,width:f,left:S.left,top:S.middle,strokeWidth:g}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),c.mr===!0?(this._middleRightWidget.transformByState({height:f,width:f,left:S.right,top:S.middle,strokeWidth:g}),this._middleRightWidget.show()):this._middleRightWidget.hide(),c.bl===!0?(this._bottomLeftWidget.transformByState({height:f,width:f,left:S.left,top:S.bottom,strokeWidth:g}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),c.bc===!0?(this._bottomCenterWidget.transformByState({height:f,width:f,left:S.center,top:S.bottom,strokeWidth:g}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),c.br===!0?(this._bottomRightWidget.transformByState({height:f,width:f,left:S.right,top:S.bottom,strokeWidth:g}),this._bottomRightWidget.show()):this._bottomRightWidget.hide()}_hasWidgets(e){if(e==null)return!1;const t=Object.keys(e);if(t.length===0)return!1;for(const r of t)if(e[r]===!0)return!0;return!1}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}_stopAntLineAnimation(){this._antLineOffset=0,T.cancelRequestFrame(this._antRequestNewFrame)}_startAntLineAnimation(){const e=this._getScale();this._antLineOffset+=.6/e,this._antLineOffset>160/e&&(this._antLineOffset=0),this.dashedRect.setProps({strokeDashOffset:-this._antLineOffset}),this._antRequestNewFrame=T.requestNewFrame(()=>{this._startAntLineAnimation()})}}class pd extends T.Layer{render(i,e=!1){const t=a.Tools.now();return super.render(i,e),this._afterRender(t),this}_afterRender(i){this.scene.getEngine().renderFrameTimeMetric$.next(["selectionLayer",a.Tools.now()-i])}}const ve=a.createIdentifier("univer.sheet.selection-render-service");class ds extends a.Disposable{constructor(e,t,r,o,s){super();E(this,"_downObserver");E(this,"_scenePointerMoveSub");E(this,"_scenePointerUpSub");E(this,"_controlFillConfig$",new O.BehaviorSubject(null));E(this,"controlFillConfig$",this._controlFillConfig$.asObservable());E(this,"_selectionControls",[]);E(this,"_startRangeWhenPointerDown",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});E(this,"_activeControlIndex",-1);E(this,"_startViewportPosX",0);E(this,"_startViewportPosY",0);E(this,"_scrollTimer");E(this,"_cancelDownSubscription");E(this,"_cancelUpSubscription");E(this,"_skeleton");E(this,"_scene");E(this,"_highlightHeader",!0);E(this,"_rangeType",a.RANGE_TYPE.NORMAL);E(this,"_selectionStyle");E(this,"_remainLastEnabled",!1);E(this,"_skipLastEnabled",!1);E(this,"_singleSelectionEnabled",!1);E(this,"_selectionMoveEnd$",new O.BehaviorSubject([]));E(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());E(this,"_selectionMoving$",new O.Subject);E(this,"selectionMoving$",this._selectionMoving$.asObservable());E(this,"_selectionMoveStart$",new O.Subject);E(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());E(this,"_selectionMoving",!1);E(this,"_selectionTheme");E(this,"_activeViewport");E(this,"interceptor",new a.InterceptorManager({RANGE_MOVE_PERMISSION_CHECK:ko,RANGE_FILL_PERMISSION_CHECK:Do}));E(this,"_escapeShortcutDisposable",null);this._injector=e,this._themeService=t,this._shortcutService=r,this._sheetSkeletonManagerService=o,this.contextService=s,this._initSelectionThemeFromThemeService(),this._initMoving()}get selectionMoving(){return this._selectionMoving}get _shouldDetectMergedCells(){return this._rangeType===a.RANGE_TYPE.NORMAL}_initMoving(){this.disposeWithMe(this._selectionMoving$.subscribe(()=>{this._selectionMoving=!0})),this.disposeWithMe(this._selectionMoveEnd$.subscribe(()=>{this._selectionMoving=!1}))}_setSelectionStyle(e){this._selectionStyle=e}getViewPort(){return this._activeViewport}setSingleSelectionEnabled(e=!1){this._singleSelectionEnabled=e}newSelectionControl(e,t,r){const o=this.getSelectionControls().length,{rowHeaderWidth:s,columnHeaderHeight:l}=t,c=new cr(e,o,this._selectionTheme,{highlightHeader:this._highlightHeader,rowHeaderWidth:s,columnHeaderHeight:l});this._selectionControls.push(c);const d=Pe(r,t);return c.updateRangeBySelectionWithCoord(d,t),c.setControlExtension({skeleton:t,scene:e,themeService:this._selectionTheme,injector:this._injector,selectionHooks:{selectionMoveEnd:()=>{this._selectionMoveEnd$.next(this.getSelectionDataWithStyle())}}}),c}resetSelectionsByModelData(e){const t=this.getSelectionControls(),r=this._skeleton;if(!(!t||!r)){for(let o=0,s=e.length;o<s;o++){const l=e[o],c=Pe(l,this._skeleton),d=t[o];d?d.updateRangeBySelectionWithCoord(c,r):this.isSelectionEnabled()&&this.newSelectionControl(this._scene,r,l)}e.length<t.length&&t.splice(e.length).forEach(s=>s.dispose())}}refreshSelectionMoveStart(){this._selectionMoveStart$.next(this.getSelectionDataWithStyle())}refreshSelectionMoveEnd(){this._selectionMoveEnd$.next(this.getSelectionDataWithStyle())}_initSelectionThemeFromThemeService(){const e=this._themeService.getCurrentTheme();this._selectionTheme=new a.ThemeService,this._selectionTheme.setTheme(e)}setSelectionTheme(e){this._selectionTheme.setTheme(e)}_changeRuntime(e,t,r){this._skeleton=e,this._scene=t,this._activeViewport=r||(t==null?void 0:t.getViewports()[0]),t.findLayerByZIndex(ei)||t.addLayer(new pd(t,[],ei))}getSkeleton(){return this._skeleton}getSelectionDataWithStyle(){const e=this._selectionControls,[t,r]=this._skeleton.getLocation();return e.map(o=>{const s=o.getValue();return s.rangeWithCoord.sheetId=r,s.rangeWithCoord.unitId=t,s})}getSelectionControls(){return this._selectionControls}_addSelectionControlByModelData(e){var l;const t=this._skeleton,r=(l=e.style)!=null?l:Rt(this._selectionTheme),o=this._scene;return e.style=r,this.newSelectionControl(o,t,e)}_clearAllSelectionControls(){const e=this._selectionControls;for(const t of e)t.dispose();this._selectionControls.length=0}_getFreeze(){var t;return(t=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:t.skeleton.getWorksheetConfig().freeze}_getViewportByCell(e,t){if(e===void 0||t===void 0)return null;const r=this._getFreeze();if(!r||r.startRow<=0&&r.startColumn<=0)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(e>r.startRow&&t>r.startColumn)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(e<=r.startRow&&t<=r.startColumn)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP);if(e<=r.startRow&&t>r.startColumn)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(e>r.startRow&&t<=r.startColumn)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)}getActiveRange(){const e=this.getSelectionControls(),t=e&&e[e.length-1].model;return t&&{startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}}setActiveSelectionIndex(e){this._activeControlIndex=e}resetActiveSelectionIndex(){this._activeControlIndex=-1}getActiveSelectionControl(){const e=this.getSelectionControls();if(e)return this._activeControlIndex<0?e[e.length-1]:e[this._activeControlIndex]}endSelection(){var e;this._clearUpdatingListeners(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),(e=this._escapeShortcutDisposable)==null||e.dispose(),this._escapeShortcutDisposable=null}_reset(){var e;this._clearAllSelectionControls(),(e=this._downObserver)==null||e.unsubscribe(),this._downObserver=null}_setupPointerMoveListener(e,t,r,o=T.ScrollTimerType.ALL,s,l){var f,p;let c=0,d=0,u=s,h=l;this._scrollTimer=T.ScrollTimer.create(this._scene,o),this._scrollTimer.startScroll((f=e==null?void 0:e.left)!=null?f:0,(p=e==null?void 0:e.top)!=null?p:0,e);const g=this._scene,S=g.getActiveViewportByCoord(T.Vector2.FromArray([s,l]));this._scenePointerMoveSub=g.onPointerMove$.subscribeEvent(v=>{var H,W,N,U,L,F,B,j,z;const{offsetX:C,offsetY:I}=v,{x:R,y:w}=g.getCoordRelativeToViewport(T.Vector2.FromArray([C,I]));this._movingHandler(R,w,t,r);let M=R,y=w;const P=this.getActiveSelectionControl(),x=this._getFreeze(),A=P==null?void 0:P.model,k=(H=g.getActiveViewportByCoord(T.Vector2.FromArray([C,I])))!=null?H:this._getViewportByCell(A==null?void 0:A.endRow,A==null?void 0:A.endColumn);if((()=>{if(!S||!k||!e)return!1;const K=[T.SHEET_VIEWPORT_KEY.VIEW_MAIN,T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP,T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP,T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT];return K.includes(S.viewportKey)&&K.includes(k.viewportKey)})()){if(!S||!k||!e)return!1;const K=u<e.left&&R>e.left||u>e.left&&R<e.left,ne=h<e.top&&w>e.top||h>e.top&&w<e.top;K&&(c+=1),ne&&(d+=1);const Q=S.viewportKey,se=k.viewportKey;if(Q===T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP)I<e.top&&((W=A==null?void 0:A.endRow)!=null?W:0)<((N=x==null?void 0:x.startRow)!=null?N:0)?y=e.top:ne&&d%2===1&&e.scrollToViewportPos({viewportScrollY:0});else if(Q===T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT)C<e.left&&((U=A==null?void 0:A.endColumn)!=null?U:0)<((L=x==null?void 0:x.startColumn)!=null?L:0)?M=e.left:K&&c%2===1&&e.scrollToViewportPos({viewportScrollX:0});else if(Q===se){let ce=!1,X=!1;Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP?(ce=!0,X=!0):Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP?X=!0:Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT&&(ce=!0),((F=A==null?void 0:A.endRow)!=null?F:0)>((B=x==null?void 0:x.startRow)!=null?B:0)&&(X=!1),((j=A==null?void 0:A.endColumn)!=null?j:0)>((z=x==null?void 0:x.startColumn)!=null?z:0)&&(ce=!1),ce&&(M=e.left),X&&(y=e.top)}else{const ce={x:S.scrollX,y:S.scrollY},X={x:k.scrollX,y:k.scrollY},G=ce.x!==X.x&&K&&c%2===1,q=ce.y!==X.y&&ne&&d%2===1;(G||q)&&(e.scrollToBarPos({x:G?ce.x:void 0,y:q?ce.y:void 0}),G||(M=e.left),q||(y=e.top)),(Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&se===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT||se===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)&&(M=e.left),(Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&se===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP||se===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP)&&(y=e.top)}u=R,h=w}this._scrollTimer.scrolling(M,y,()=>{this._movingHandler(R,w,t,r)})})}attachSelectionWithCoord(e){return Pe(e,this._skeleton)}attachPrimaryWithCoord(e){return $n(this._skeleton,e)}getSelectionCellByPosition(e,t){return this.getCellWithCoordByOffset(e,t)}getCellWithCoordByOffset(e,t,r){const o=this._scene,s=r!=null?r:this._skeleton,l=o.getViewportScrollXY(o.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN)),{scaleX:c,scaleY:d}=o.getAncestorScale();return s.getCellWithCoordByOffset(e,t,c,d,l)}_movingHandler(e,t,r,o){var M,y,P,x,A;const s=this._skeleton,l=this._scene,[c,d]=s.getLocation(),u={startRow:(M=r==null?void 0:r.model.startRow)!=null?M:-1,endRow:(y=r==null?void 0:r.model.endRow)!=null?y:-1,startColumn:(P=r==null?void 0:r.model.startColumn)!=null?P:-1,endColumn:(x=r==null?void 0:r.model.endColumn)!=null?x:-1},h=l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),g=(A=this._getViewportByCell(u.endRow,u.endColumn))!=null?A:h,S=l.getScrollXYInfoByViewport(T.Vector2.FromArray([this._startViewportPosX,this._startViewportPosY]),g),{scaleX:f,scaleY:p}=l.getAncestorScale();o===a.RANGE_TYPE.ROW?e=Number.POSITIVE_INFINITY:o===a.RANGE_TYPE.COLUMN&&(t=Number.POSITIVE_INFINITY);const v=this._skeleton.getCellByOffset(e,t,f,p,S);if(!v)return;let C={startRow:Math.min(v.startRow,this._startRangeWhenPointerDown.startRow),startColumn:Math.min(v.startColumn,this._startRangeWhenPointerDown.startColumn),endRow:Math.max(v.endRow,this._startRangeWhenPointerDown.endRow),endColumn:Math.max(v.endColumn,this._startRangeWhenPointerDown.endColumn)};this._shouldDetectMergedCells&&(C=s.expandRangeByMerge(C));const R=Pe({range:C,primary:void 0,style:null},s);R.rangeWithCoord.unitId=c,R.rangeWithCoord.sheetId=d,R.rangeWithCoord.rangeType=o;const w=u.startRow!==C.startRow||u.startColumn!==C.startColumn||u.endRow!==C.endRow||u.endColumn!==C.endColumn;r!=null&&w&&(r.updateRangeBySelectionWithCoord(R),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_clearUpdatingListeners(){var t,r,o,s,l;this._scene.enableObjectsEvent(),(t=this._scenePointerMoveSub)==null||t.unsubscribe(),this._scenePointerMoveSub=null,(r=this._scenePointerUpSub)==null||r.unsubscribe(),this._scenePointerUpSub=null,(o=this._cancelDownSubscription)==null||o.unsubscribe(),this._cancelDownSubscription=null,(s=this._cancelUpSubscription)==null||s.unsubscribe(),this._cancelUpSubscription=null,(l=this._scrollTimer)==null||l.dispose()}_addEndingListeners(){var r,o,s;const e=this._scene,t=(r=e.getEngine())==null?void 0:r.activeScene;!t||t===e||((o=this._cancelDownSubscription)==null||o.unsubscribe(),this._cancelDownSubscription=null,(s=this._cancelUpSubscription)==null||s.unsubscribe(),this._cancelUpSubscription=null,this._cancelDownSubscription=t.onPointerDown$.subscribeEvent(()=>this._clearUpdatingListeners()),this._cancelUpSubscription=t.onPointerUp$.subscribeEvent(()=>this._clearUpdatingListeners()))}_getSelectionWithCoordByOffset(e,t,r,o,s){const l=this._skeleton;if(l==null)return null;if(this._shouldDetectMergedCells){const C=l==null?void 0:l.getCellWithCoordByOffset(e,t,r,o,s,{firstMatch:!0});if(!C)return;const I=a.convertCellToRange(C);return{primaryWithCoord:C,rangeWithCoord:I}}const{row:c,column:d}=l.getCellIndexByOffset(e,t,r,o,s),u=l.getNoMergeCellWithCoordByIndex(c,d),{startX:h,startY:g,endX:S,endY:f}=u,p={startY:g,endY:f,startX:h,endX:S,startRow:c,endRow:c,startColumn:d,endColumn:d};return{primaryWithCoord:{mergeInfo:p,actualRow:c,actualColumn:d,isMerged:!1,isMergedMainCell:!1,startY:g,endY:f,startX:h,endX:S},rangeWithCoord:p}}_checkClearPreviousControls(e){this.getSelectionControls().length!==0&&(!e.ctrlKey&&!e.shiftKey&&!this._remainLastEnabled||this._singleSelectionEnabled&&!e.shiftKey)&&this._clearAllSelectionControls()}_makeSelectionByTwoCells(e,t,r,o,s){const{actualRow:l,actualColumn:c,mergeInfo:d}=e;this._startRangeWhenPointerDown={...e.mergeInfo};const u=Math.min(l,t.startRow,d.startRow),h=Math.max(l,t.endRow,d.endRow),g=Math.min(c,t.startColumn,d.startColumn),S=Math.max(c,t.endColumn,d.endColumn),p={range:r.expandRangeByMerge({startRow:u,startColumn:g,endRow:h,endColumn:S}),primary:null,style:null},v=Pe(p,r);s.updateRangeBySelectionWithCoord(v)}isSelectionEnabled(){return this.contextService.getContextValue(m.SELECTIONS_ENABLED)}isSelectionDisabled(){return this.contextService.getContextValue(m.SELECTIONS_ENABLED)===!1}inRefSelectionMode(){return this.contextService.getContextValue(m.REF_SELECTIONS_ENABLED)}}function us(n){return{range:{startRow:0,startColumn:0,endRow:n.getRowCount()-1,endColumn:n.getColumnCount()-1,rangeType:a.RANGE_TYPE.ALL},primary:Ai(n).primary,style:null}}function Ai(n){return Xa(n,{startRow:0,startColumn:0,endRow:0,endColumn:0})}function Xa(n,i){const e=n.worksheet.getCellInfoInMergeData(i.startRow,i.startColumn),t=n.worksheet.getCellInfoInMergeData(i.endRow,i.endColumn);return{range:{startRow:e.startRow,startColumn:e.startColumn,endRow:t.endRow,endColumn:t.endColumn,rangeType:a.RANGE_TYPE.NORMAL},primary:{actualRow:e.startRow,actualColumn:e.startColumn,startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn,isMerged:e.isMerged,isMergedMainCell:e.isMergedMainCell},style:null}}var vd=Object.getOwnPropertyDescriptor,Cd=(n,i,e,t)=>{for(var r=t>1?void 0:t?vd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Xs=(n,i)=>(e,t)=>i(e,t,n);exports.SheetSkeletonManagerService=class extends a.Disposable{constructor(e,t,r){super();E(this,"_sheetId","");E(this,"_sheetSkeletonParamStore",new Map);E(this,"_currentSkeleton$",new O.BehaviorSubject(null));E(this,"currentSkeleton$",this._currentSkeleton$.asObservable());E(this,"_currentSkeletonBefore$",new O.BehaviorSubject(null));E(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._context=e,this._injector=t,this._sheetSkService=r,this.disposeWithMe(()=>{this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParamStore.forEach(o=>this.disposeSkeleton(o.sheetId)),this._sheetSkeletonParamStore.clear()}),this._initRemoveSheet()}_initRemoveSheet(){this.disposeWithMe(this._context.unit.sheetDisposed$.subscribe(e=>{this.disposeSkeleton(e.getSheetId())}))}getCurrentSkeleton(){var e;return(e=this.getCurrentParam())==null?void 0:e.skeleton}getCurrent(){return this.getCurrentParam()}getCurrentParam(){return this._getSkeletonParam(this._sheetId)}getSkeleton(e){return this._getSkeleton(e)}getSkeletonParam(e){return this._getSkeletonParam(e)}getWorksheetSkeleton(e){return this.getSkeletonParam(e)}getUnitSkeleton(e,t){const r=this._getSkeletonParam(t);return r!=null&&(r.unitId=e),r}setCurrent(e){this._setCurrent(e.sheetId)}setSkeletonParam(e,t){this._sheetSkService.setSkeleton(t.unitId,e,t.skeleton),this._sheetSkeletonParamStore.set(e,t)}_setCurrent(e){this._sheetId=e;const t=this._getSkeletonParam(e),r=this._context.unitId;if(t!=null)this.reCalculate(t);else{const l=this._context.unit.getSheetBySheetId(e);if(l==null)return;const c=this._context.scene,d=this._buildSkeleton(l,c);this.setSkeletonParam(e,{unitId:r,sheetId:e,skeleton:d,dirty:!1})}const o=this._getSkeletonParam(e);this._currentSkeletonBefore$.next(o),this._currentSkeleton$.next(o)}reCalculate(e){e||(e=this.getCurrentParam()),e!=null&&(e.dirty&&(e.skeleton.makeDirty(!0),e.dirty=!1),e.skeleton.calculate())}makeDirty(e,t=!0){const r=this._getSkeletonParam(e.sheetId);r!=null&&(r.dirty=t)}getOrCreateSkeleton(e){return this.ensureSkeleton(e.sheetId)}ensureSkeleton(e){const t=this._getSkeletonParam(e);if(t)return t.skeleton;const o=this._context.unit.getSheetBySheetId(e);if(!o)return;const s=this._buildSkeleton(o);return this.setSkeletonParam(e,{unitId:this._context.unitId,sheetId:e,skeleton:s,dirty:!1}),s}disposeSkeleton(e){const t=this.getSkeletonParam(e);t&&(t.skeleton.dispose(),this._sheetSkeletonParamStore.delete(e),this._sheetSkService.deleteSkeleton(t.unitId,e))}attachRangeWithCoord(e){const t=this.getCurrentSkeleton();return t?Cn(t,e):null}_getSkeletonParam(e){return this._sheetSkeletonParamStore.get(e)}_getSkeleton(e){const t=this._getSkeletonParam(e);return t?t.skeleton:null}_buildSkeleton(e,t){return this._injector.createInstance(T.SpreadsheetSkeleton,e,this._context.unit.getStyles())}setColumnHeaderSize(e,t,r){var u;if(!e)return;const o=(u=this.getWorksheetSkeleton(t))==null?void 0:u.skeleton;if(!o)return;o.columnHeaderHeight=r,e.scene.getViewports()[0].top=r,e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).setViewportSize({height:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT).setViewportSize({height:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM).setViewportSize({top:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP).setViewportSize({top:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).setViewportSize({height:r});const s=e==null?void 0:e.with(m.SheetsSelectionsService),l=e==null?void 0:e.with(ve),c=s.getCurrentSelections();l.resetSelectionsByModelData(c);const d=this.getUnitSkeleton(e.unitId,t);d&&(d.commandId=xi.id,this._currentSkeleton$.next(d))}setRowHeaderSize(e,t,r){var f;const o=(f=this.getWorksheetSkeleton(t))==null?void 0:f.skeleton;if(!e||!o)return;o.rowHeaderWidth=r;const s=e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).width||46,l=r-s,c=e.scene.getViewports()[0].left;e.scene.getViewports()[0].left=c+l,e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM).setViewportSize({width:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP).setViewportSize({width:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT).setViewportSize({left:r});const d=e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).left||0;e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).setViewportSize({left:d+l}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).setViewportSize({width:r});const u=e==null?void 0:e.with(m.SheetsSelectionsService),h=e==null?void 0:e.with(ve),g=u.getCurrentSelections();h.resetSelectionsByModelData(g);const S=this.getCurrent();S&&(S.commandId=Oi.id,this._currentSkeleton$.next(S))}};exports.SheetSkeletonManagerService=Cd([Xs(1,a.Inject(a.Injector)),Xs(2,a.Inject(m.SheetSkeletonService))],exports.SheetSkeletonManagerService);function gt(){const n=_.useDependency(a.IUniverInstanceService),i=_.useObservable(()=>n.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return i!=null?i:null}function _d(n){return _.useObservable(()=>{var e;return(e=n==null?void 0:n.activeSheet$)!=null?e:O.of(null)},void 0,void 0,[n])}function Id(){const n=_.useDependency(a.IUniverInstanceService);return _.useObservable(()=>O.merge([n.getTypeOfUnitAdded$(a.UniverInstanceType.UNIVER_SHEET),n.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET)]).pipe(O.map(()=>n.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET)),O.startWith(n.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET))),[],void 0,[n])}const bd="SheetUI";var hs=(n=>(n.FILTER_PANEL_EMBED_POINT="filter-panel-embed-point",n.SHEETS_FOOTER="sheets-footer",n.FORMULA_AUX="formula-aux",n))(hs||{});const mt="sheets-ui.config",Ho={formulaBar:!0,statusBarStatistic:!0,maxAutoHeightCount:1e3};var Rd=Object.getOwnPropertyDescriptor,Ed=(n,i,e,t)=>{for(var r=t>1?void 0:t?Rd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Un=(n,i)=>(e,t)=>i(e,t,n);const ms=["ff","fs","tr","tb"];exports.AutoHeightController=class extends a.Disposable{constructor(i,e,t,r,o){super(),this._renderManagerService=i,this._sheetInterceptorService=e,this._selectionManagerService=t,this._univerInstanceService=r,this._configService=o,this._initialize()}_getRangesScope(i){let e,t;for(const{startRow:r,endRow:o}of i)e=e===void 0?r:Math.min(e,r),t=t===void 0?o:Math.max(t,o);return t-e+1}getUndoRedoParamsOfAutoHeight(i,e){var I;const{_univerInstanceService:t,_configService:r}=this,o=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=o.getUnitId();let l=o.getActiveSheet(),c=l.getSheetId();if(e){const R=m.getSheetCommandTarget(t,{unitId:s,subUnitId:e});R&&(l=R.worksheet,c=l.getSheetId())}const u=this._renderManagerService.getRenderById(s).with(exports.SheetSkeletonManagerService).ensureSkeleton(c);if(!u)return{redos:[],undos:[]};const h=r.getConfig(mt);let g=i;Array.isArray(i)||(i&&i.startRow!==void 0&&i.startRow!==void 0?g=[i]:g=[]);const S=this._getRangesScope(g);if(((I=h==null?void 0:h.maxAutoHeightCount)!=null?I:1e3)<S)return{redos:[],undos:[]};const p=u.calculateAutoHeightInRange(i),v={subUnitId:c,unitId:s,rowsAutoHeightInfo:p},C=m.SetWorksheetRowAutoHeightMutationFactory(v,l);return{undos:[{id:m.SetWorksheetRowAutoHeightMutation.id,params:C}],redos:[{id:m.SetWorksheetRowAutoHeightMutation.id,params:v}]}}_initialize(){const{_sheetInterceptorService:i,_selectionManagerService:e}=this;this.disposeWithMe(i.interceptCommand({getMutations:t=>{if(t.id===m.SetRangeValuesCommand.id){const r=t.params;return this.getUndoRedoParamsOfAutoHeight(r.range,r.subUnitId)}return{redos:[],undos:[]}}})),this.disposeWithMe(i.interceptCommand({getMutations:t=>t.id!==m.SetWorksheetRowIsAutoHeightCommand.id?{redos:[],undos:[]}:this.getUndoRedoParamsOfAutoHeight(t.params.ranges,t.params.subUnitId)})),this.disposeWithMe(i.interceptCommand({getMutations:t=>{var o,s;if(t.id!==m.SetStyleCommand.id)return{redos:[],undos:[]};if(!ms.includes((o=t.params)==null?void 0:o.style.type))return{redos:[],undos:[]};const r=(s=e.getCurrentSelections())==null?void 0:s.map(l=>l.range);return r!=null&&r.length?this.getUndoRedoParamsOfAutoHeight(r,t.params.subUnitId):{redos:[],undos:[]}}})),this.disposeWithMe(i.interceptAfterCommand({getMutations:t=>{if(t.id===m.MoveRangeCommand.id){const r=t.params;return this.getUndoRedoParamsOfAutoHeight([r.fromRange,r.toRange])}if(t.id===m.ReorderRangeCommand.id){const r=t.params;return this.getUndoRedoParamsOfAutoHeight([r.range])}return{redos:[],undos:[]}}}))}};exports.AutoHeightController=Ed([Un(0,T.IRenderManagerService),Un(1,a.Inject(m.SheetInterceptorService)),Un(2,a.Inject(m.SheetsSelectionsService)),Un(3,a.Inject(a.IUniverInstanceService)),Un(4,a.IConfigService)],exports.AutoHeightController);function Et(n){const{rows:i,cols:e}=n;return{startRow:i[0],endRow:i[i.length-1],startColumn:e[0],endColumn:e[e.length-1]}}function Gt(n){let i=[],e=[];const t=[];return n.forEach(r=>{i=i.concat(r.rows),e=e.concat(r.cols)}),i=Array.from(new Set(i)).sort((r,o)=>r-o),e=Array.from(new Set(e)).sort((r,o)=>r-o),n.forEach(r=>{t.push({startRow:i.findIndex(o=>o===r.rows[0]),endRow:i.findIndex(o=>o===r.rows[r.rows.length-1]),startColumn:e.findIndex(o=>o===r.cols[0]),endColumn:e.findIndex(o=>o===r.cols[r.cols.length-1])})}),{ranges:t,mapFunc:(r,o)=>({row:i[r],col:e[o]})}}function wd(n){const i=new a.ObjectMatrix;return n.forEach(e=>{const{rows:t,cols:r}=e;t.forEach(o=>{r.forEach(s=>{i.setValue(o,s,{v:null,p:null,f:null,si:null,custom:null})})})}),i.getData()}const Vo={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},ti=["零","一","二","三","四","五","六","七","八","九"],Ys=["","万","亿","万亿","亿亿"],Td=["","十","百","千"],Ya={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function ut(n){if(!n)return 0;let i=0,e=0,t=0,r=!1;const o=n.split("");for(let s=0;s<o.length;s++){const l=Vo[o[s]];if(typeof l<"u")t=l,s===o.length-1&&(e+=t);else{const c=Ya[o[s]],d=c.value;r=c.secUnit,r?(e=(e+t)*d,i+=e,e=0):e+=t*d,t=0}}return i+e}function yd(n){let i="",e="",t=0,r=!0;for(;n>0;){const o=n%10;o===0?r||(r=!0,e=ti[o]+e):(r=!1,i=ti[o],i+=Td[t],e=i+e),t++,n=Math.floor(n/10)}return e}function Md(n){let i=0,e="",t="",r=!1;if(n===0)return ti[0];for(;n>0;){const o=n%1e4;r&&(t=ti[0]+t),e=yd(o),e+=o!==0?Ys[i]:Ys[0],t=e+t,r=o<1e3&&o>0,n=Math.floor(n/1e4),i++}return t}function Pd(n){if(!n)return!1;let i=!0;if(n)if(n.length===1)n==="日"||n in Vo?i=!0:i=!1;else{const e=n.split("");for(let t=0;t<e.length;t++)if(!(e[t]in Vo||e[t]in Ya)){i=!1;break}}return i}function Vr(n){if(!n)return{isExtendNumber:!1};const i=/0|([1-9]+[0-9]*)/g,e=i.test(n);if(e){const t=n.match(i);if(t&&t.length>0){const r=t[t.length-1],o=n.lastIndexOf(r),s=n.substr(0,o),l=n.substr(o+r.length);return{isExtendNumber:!0,matchTxt:Number(r),beforeTxt:s,afterTxt:l}}return{isExtendNumber:!1}}return{isExtendNumber:e}}function Od(n){let i;return n.length===2&&(n==="周一"||n==="周二"||n==="周三"||n==="周四"||n==="周五"||n==="周六"||n==="周日")?i=!0:i=!1,i}function xd(n){let i;return n.length===3&&(n==="星期一"||n==="星期二"||n==="星期三"||n==="星期四"||n==="星期五"||n==="星期六"||n==="星期日")?i=!0:i=!1,i}function Ad(n,i){let e=0;for(let t=0;t<n.length&&n[t]<i;t++)e++;return e}function dr(n){let i=!0;const e=n[1]-n[0];for(let t=1;t<n.length;t++)if(n[t]-n[t-1]!==e){i=!1;break}return i}function kd(n,i,e){const t=[],r=Math.floor(i/n),o=i%n;let s=0;if(r>0){for(let l=0;l<r;l++)for(let c=0;c<e.length;c++)t[e[c]+l*n]=s,s++;for(let l=0;l<e.length&&e[l]<o;l++)t[e[l]+n*r]=s,s++}else for(let l=0;l<e.length&&e[l]<o;l++)t[e[l]]=s,s++;return t}function Ft(n,i){const e=[];for(let t=1;t<=i;t++){const r=(t-1)%n.length,o=a.Tools.deepClone(n[r]);jt(o),e.push({v:null,s:null,p:null,f:null,si:null,t:null,...o})}return e}function Dd(n,i){var t;const e=[];for(let r=1;r<=i;r++){const o=(r-1)%n.length,s={s:(t=n[o])==null?void 0:t.s};e.push(s)}return e}function Nd(n){let i=!0;const e=n[1]/n[0];for(let t=1;t<n.length;t++)if(n[t]/n[t-1]!==e){i=!1;break}return i}function Hd(n){const i=[];for(let e=1;e<=n;e++)i.push(e);return i}function ni(n,i,e){var o,s,l,c;const t=[],r=[];for(let d=0;d<n.length;d++)r.push(Number((o=n[d])==null?void 0:o.v));if(n.length>2&&Nd(r))for(let d=1;d<=i;d++){const u=(d-1)%n.length,h=a.Tools.deepClone(n[u]);jt(h);const g=Number((s=n[n.length-1])==null?void 0:s.v)*(Number((l=n[1])==null?void 0:l.v)/Number((c=n[0])==null?void 0:c.v))**d;h&&(qs(h)&&(h.v=g),t.push(h))}else{const d=Hd(n.length);for(let u=1;u<=i;u++){const h=(u-1)%n.length,g=a.Tools.deepClone(n[h]);jt(g);const S=e===a.Direction.DOWN||e===a.Direction.RIGHT,f=Vd(n.length+u,r,d,S);g&&(qs(g)&&(g.v=f),t.push(g))}}return t}function Vd(n,i,e,t=!0){function r(h){let g=0;for(let S=0;S<h.length;S++)g+=h[S];return g/h.length}const o=r(e),s=r(i);let l=0,c=0;for(let h=0;h<e.length;h++)l+=(e[h]-o)*(i[h]-s),c+=(e[h]-o)*(e[h]-o);let d;c===0?d=t?1:-1:d=l/c;const u=s-d*o;return Math.round((u+d*n)*1e5)/1e5}function Gs(n,i,e){var o;const t=[],r=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=i;s++){const l=(s-1)%n.length,c=a.Tools.deepClone(n[l]);jt(c);const d=`${(o=n[n.length-1])==null?void 0:o.v}`,u=d==null?void 0:d.match(r),h=u==null?void 0:u[u.length-1],g=Math.abs(Number(h)+e*s);if(!d||!h)continue;const S=d.lastIndexOf(h),f=d.substr(0,S)+g.toString()+d.substr(S+h.length);c&&(c.v=f,t.push(c))}return t}function _n(n,i,e,t=0){var l,c;const r=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(t>=r.length)return[];const o=r[t],s=[];for(let d=1;d<=i;d++){const u=(d-1)%n.length,h=a.Tools.deepClone(n[u]);jt(h);let g=0;if(((l=n[n.length-1])==null?void 0:l.v)===o[0])g=7+e*d;else{const f=`${(c=n[n.length-1])==null?void 0:c.v}`;if(f){const p=f.substr(f.length-1,1);g=ut(p)+e*d}}g<0&&(g=Math.ceil(Math.abs(g)/7)*7+g);const S=g%7;h&&(h.v=o[S],s.push(h))}return s}function Zs(n,i,e){var r;const t=[];for(let o=1;o<=i;o++){const s=(o-1)%n.length,l=a.Tools.deepClone(n[s]);jt(l);const c=`${(r=n[n.length-1])==null?void 0:r.v}`,d=ut(c)+e*o;let u;d<=0?u="零":u=Md(d),l&&(l.v=u,t.push(l))}return t}const qn={enWeek1:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],enWeek2:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],enMonth1:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],enMonth2:["January","February","March","April","May","June","July","August","September","October","November","December"],chnMonth1:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],chnMonth2:["正月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","腊月"],chHour1:["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"],chHour2:["子时","丑时","寅时","卯时","辰时","巳时","午时","未时","申时","酉时","戌时","亥时"],chYear1:["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"],chSeason1:["春","夏","秋","冬"],chSeason2:["春季","夏季","秋季","冬季"]};function Wd(n){let i=!1;return Object.keys(qn).forEach(e=>{qn[e].includes(n)&&(i=!0)}),i}function ji(n){let i="";const e=[];return Object.keys(qn).forEach(t=>{qn[t].includes(n)&&(i=t,e.push(...qn[t]))}),{name:i,series:e}}function Ks(n,i,e,t){var s;const r=t.length,o=[];for(let l=1;l<=i;l++){const c=(l-1)%n.length,d=a.Tools.deepClone(n[c]);jt(d);const u=`${(s=n[n.length-1])==null?void 0:s.v}`;let h=t.indexOf(u)+e*l;h<0&&(h+=Math.abs(e)*r);const g=h%r;d&&(d.v=t[g],o.push(d))}return o}function Ud(n,i){const e=[];let t;if(i.startRow<n.startRow)t=a.Direction.UP;else if(i.endRow>n.endRow)t=a.Direction.DOWN;else if(i.startColumn<n.startColumn)t=a.Direction.LEFT;else if(i.endColumn>n.endColumn)t=a.Direction.RIGHT;else return[];if(t===a.Direction.DOWN||t===a.Direction.UP){const r=n.endRow-n.startRow+1,o=i.endRow-i.startRow+1,s=Math.floor(o/r),l=o%r,c={startRow:0,startColumn:0,endRow:n.endRow-n.startRow,endColumn:n.endColumn-n.startColumn};if(t===a.Direction.DOWN){for(let d=0;d<s;d++)e.push({repeatStartCell:{row:n.startRow+(d+1)*r,col:n.startColumn},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow+(s+1)*r,col:n.startColumn},relativeRange:{startRow:0,startColumn:0,endRow:l-1,endColumn:n.endColumn-n.startColumn}})}else{for(let d=0;d<s;d++)e.push({repeatStartCell:{row:n.startRow-(d+1)*r,col:n.startColumn},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow-(s+1)*r,col:n.startColumn},relativeRange:{startRow:r-l,endRow:r-1,startColumn:0,endColumn:n.endColumn-n.startColumn}})}}if(t===a.Direction.RIGHT||t===a.Direction.LEFT){const r=n.endColumn-n.startColumn+1,o=i.endColumn-i.startColumn+1,s=Math.floor(o/r),l=o%r,c={startRow:0,startColumn:0,endRow:n.endRow-n.startRow,endColumn:n.endColumn-n.startColumn};if(t===a.Direction.RIGHT){for(let d=0;d<s;d++)e.push({repeatStartCell:{row:n.startRow,col:n.startColumn+(d+1)*r},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow,col:n.startColumn+(s+1)*r},relativeRange:{startRow:0,startColumn:0,endRow:n.endRow-n.startRow,endColumn:l-1}})}else{for(let d=0;d<s;d++)e.push({repeatStartCell:{row:n.startRow,col:n.startColumn-(d+1)*r},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow,col:n.startColumn-(s+1)*r},relativeRange:{startRow:0,startColumn:r-l,endRow:n.endRow-n.startRow,endColumn:r-1}})}}return e}function qs(n){return!(a.isFormulaString(n.f)||a.isFormulaId(n.si)||n.t===a.CellValueType.BOOLEAN)}function jt(n){n&&"custom"in n&&delete n.custom}var un=(n=>(n.Append="APPEND",n.Default="DEFAULT",n.Only="ONLY",n))(un||{}),Ie=(n=>(n.NUMBER="number",n.DATE="date",n.EXTEND_NUMBER="extendNumber",n.CHN_NUMBER="chnNumber",n.CHN_WEEK2="chnWeek2",n.CHN_WEEK3="chnWeek3",n.LOOP_SERIES="loopSeries",n.FORMULA="formula",n.OTHER="other",n))(Ie||{}),le=(n=>(n.COPY="COPY",n.SERIES="SERIES",n.ONLY_FORMAT="ONLY_FORMAT",n.NO_FORMAT="NO_FORMAT",n))(le||{});const Ld={type:Ie.DATE,priority:1100,match:(n,i)=>{var e;if(n!=null&&n.f||n!=null&&n.si)return!1;if((typeof(n==null?void 0:n.v)=="number"||(n==null?void 0:n.t)===a.CellValueType.NUMBER)&&n.s){if(typeof n.s=="string"){const r=i.get(a.IUniverInstanceService).getFocusedUnit().getStyles().get(n.s),o=(e=r==null?void 0:r.n)==null?void 0:e.pattern;if(o)return a.numfmt.getInfo(o).isDate}else if(n.s.n&&a.numfmt.getInfo(n.s.n.pattern).isDate)return!0}return!1},isContinue:(n,i)=>n.type===Ie.DATE,applyFunctions:{[le.SERIES]:(n,i,e)=>{const{data:t}=n;return e===a.Direction.LEFT||e===a.Direction.UP?(t.reverse(),ni(t,i,e).reverse()):ni(t,i,e)}}},Bd={type:Ie.NUMBER,priority:1e3,match:n=>typeof(n==null?void 0:n.v)=="number"||(n==null?void 0:n.t)===a.CellValueType.NUMBER,isContinue:(n,i)=>n.type===Ie.NUMBER,applyFunctions:{[le.SERIES]:(n,i,e)=>{const{data:t}=n;return e===a.Direction.LEFT||e===a.Direction.UP?(t.reverse(),ni(t,i,e).reverse()):ni(t,i,e)}}},Ga={type:Ie.OTHER,priority:0,match:()=>!0,isContinue:(n,i)=>n.type===Ie.OTHER},Fd={type:Ie.EXTEND_NUMBER,priority:900,match:n=>Vr(`${n==null?void 0:n.v}`||"").isExtendNumber,isContinue:(n,i)=>{var e;if(n.type===Ie.EXTEND_NUMBER){const{beforeTxt:t,afterTxt:r}=Vr(`${(e=n.cellData)==null?void 0:e.v}`||""),{beforeTxt:o,afterTxt:s}=Vr(`${i==null?void 0:i.v}`||"");if(t===o&&r===s)return!0}return!1},applyFunctions:{[le.SERIES]:(n,i,e)=>{var l;const{data:t}=n,r=e===a.Direction.UP||e===a.Direction.LEFT;let o;if(t.length===1)return o=r?-1:1,Ue(Gs(t,i,o),r);const s=[];for(let c=0;c<t.length;c++){const d=`${(l=t[c])==null?void 0:l.v}`;d&&s.push(Number(Vr(d).matchTxt))}return r&&(t.reverse(),s.reverse()),dr(s)?(o=s[1]-s[0],Ue(Gs(t,i,o),r)):Ft(t,i)}}},jd={type:Ie.CHN_NUMBER,priority:830,match:n=>!!Pd(`${n==null?void 0:n.v}`||""),isContinue:(n,i)=>n.type===Ie.CHN_NUMBER,applyFunctions:{[le.SERIES]:(n,i,e)=>{var c,d,u;const{data:t}=n,r=e===a.Direction.LEFT||e===a.Direction.UP;if(t.length===1){const h=`${(c=t[0])==null?void 0:c.v}`;let g;return r?g=-1:g=1,h&&(h==="日"||ut(h)<7)?Ue(_n(t,i,g),r):Ue(Zs(t,i,g),r)}let o=!1;for(let h=0;h<t.length;h++)if(((d=t[h])==null?void 0:d.v)==="日"){o=!0;break}const s=[];let l=0;for(let h=0;h<t.length;h++){const g=`${(u=t[h])==null?void 0:u.v}`;g==="日"?h===0?s.push(0):(l++,s.push(l*7)):o&&ut(g)>0&&ut(g)<7?s.push(ut(g)+l*7):s.push(ut(g))}if(r&&(t.reverse(),s.reverse()),dr(s)){if(o||s[s.length-1]<6&&s[0]>0||s[0]<6&&s[s.length-1]>0){const g=s[1]-s[0];return Ue(_n(t,i,g),r)}const h=s[1]-s[0];return Ue(Zs(t,i,h),r)}return Ft(t,i)}}},zd={type:Ie.CHN_WEEK2,priority:820,match:n=>!!Od(`${n==null?void 0:n.v}`||""),isContinue:(n,i)=>n.type===Ie.CHN_WEEK2,applyFunctions:{[le.SERIES]:(n,i,e)=>{var l;const{data:t}=n,r=e===a.Direction.LEFT||e===a.Direction.UP;if(t.length===1){let c;return r?c=-1:c=1,Ue(_n(t,i,c,1),r)}const o=[];let s=0;for(let c=0;c<t.length;c++){const d=`${(l=t[c])==null?void 0:l.v}`,u=d==null?void 0:d.substr(d.length-1,1);d==="周日"?c===0?o.push(0):(s++,o.push(s*7)):o.push(ut(u)+s*7)}if(r&&(t.reverse(),o.reverse()),dr(o)){const c=o[1]-o[0];return Ue(_n(t,i,c,1),r)}return Ft(t,i)}}},Xd={type:Ie.CHN_WEEK3,priority:810,match:n=>xd(`${n==null?void 0:n.v}`||""),isContinue:(n,i)=>n.type===Ie.CHN_WEEK3,applyFunctions:{[le.SERIES]:(n,i,e)=>{var l;const{data:t}=n,r=e===a.Direction.LEFT||e===a.Direction.UP;if(t.length===1){let c;return r?c=-1:c=1,Ue(_n(t,i,c,2),r)}const o=[];let s=0;for(let c=0;c<t.length;c++){const d=`${(l=t[c])==null?void 0:l.v}`;if(d){const u=d.substr(d.length-1,1);d==="星期日"?c===0?o.push(0):(s++,o.push(s*7)):o.push(ut(u)+s*7)}}if(r&&(t.reverse(),o.reverse()),dr(o)){const c=o[1]-o[0];return Ue(_n(t,i,c,2),r)}return Ft(t,i)}}},Yd={type:Ie.LOOP_SERIES,priority:800,match:n=>Wd(`${n==null?void 0:n.v}`||""),isContinue:(n,i)=>{var e;return n.type===Ie.LOOP_SERIES?ji(`${(e=n.cellData)==null?void 0:e.v}`||"").name===ji(`${i==null?void 0:i.v}`||"").name:!1},applyFunctions:{[le.SERIES]:(n,i,e)=>{var c,d;const{data:t}=n,r=e===a.Direction.LEFT||e===a.Direction.UP,{series:o}=ji(`${(c=t[0])==null?void 0:c.v}`||"");if(t.length===1){let u;return r?u=-1:u=1,Ue(Ks(t,i,u,o),r)}const s=[];let l=0;for(let u=0;u<t.length;u++){const h=`${(d=t[u])==null?void 0:d.v}`;h&&(h===o[0]?u===0?s.push(0):(l++,s.push(l*o.length)):s.push(o.indexOf(h)+l*7))}if(r&&(t.reverse(),s.reverse()),dr(s)){const u=s[1]-s[0];return Ue(Ks(t,i,u,o),r)}return Ft(t,i)}}};function Ue(n,i){return i?n.reverse():n}var Gd=Object.getOwnPropertyDescriptor,Zd=(n,i,e,t)=>{for(var r=t>1?void 0:t?Gd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},rn=(n,i)=>(e,t)=>i(e,t,n);exports.AutoFillService=class extends a.Disposable{constructor(e,t,r,o,s,l){super();E(this,"_rules",[]);E(this,"_hooks",[]);E(this,"_applyType$",new O.BehaviorSubject(le.SERIES));E(this,"_isFillingStyle",!0);E(this,"_prevUndos",[]);E(this,"_autoFillLocation$",new O.BehaviorSubject(null));E(this,"autoFillLocation$",this._autoFillLocation$.asObservable());E(this,"_showMenu$",new O.BehaviorSubject(!1));E(this,"showMenu$",this._showMenu$.asObservable());E(this,"_direction",a.Direction.DOWN);E(this,"applyType$",this._applyType$.asObservable());E(this,"_menu$",new O.BehaviorSubject([{label:"autoFill.copy",value:le.COPY,disable:!1},{label:"autoFill.series",value:le.SERIES,disable:!1},{label:"autoFill.formatOnly",value:le.ONLY_FORMAT,disable:!1},{label:"autoFill.noFormat",value:le.NO_FORMAT,disable:!1}]));E(this,"menu$",this._menu$.asObservable());this._commandService=e,this._undoRedoService=t,this._renderManagerService=r,this._univerInstanceService=o,this._selectionManagerService=s,this._injector=l,this._init()}_init(){this._rules=[Ld,Bd,Fd,jd,zd,Xd,Yd,Ga].sort((e,t)=>t.priority-e.priority),this._isFillingStyle=!0}_getOneByPriority(e){return e.length<=0?[]:[e.reduce((r,o)=>(o.priority||0)>(r.priority||0)?o:r,e[0])]}_initPrevUndo(){this._prevUndos=[]}async triggerAutoFill(e,t,r,o){var S;if(r.startColumn===o.startColumn&&r.startRow===o.startRow&&r.endColumn===o.endColumn&&r.endRow===o.endRow)return!1;if(o.endColumn<r.endColumn&&o.endColumn>r.startColumn)return this._commandService.executeCommand(In.id,{clearRange:{startRow:o.startRow,endRow:o.endRow,startColumn:o.endColumn+1,endColumn:r.endColumn},selectionRange:o});if(o.endRow<r.endRow&&o.endRow>r.startRow)return this._commandService.executeCommand(In.id,{clearRange:{startRow:o.endRow+1,endRow:r.endRow,startColumn:o.startColumn,endColumn:o.endColumn},selectionRange:o});const s={startRow:o.startRow,endRow:o.endRow,startColumn:o.startColumn,endColumn:o.endColumn};let l=null;if(o.startRow<r.startRow)l=a.Direction.UP,s.endRow=r.startRow-1;else if(o.endRow>r.endRow)l=a.Direction.DOWN,s.startRow=r.endRow+1;else if(o.startColumn<r.startColumn)l=a.Direction.LEFT,s.endColumn=r.startColumn-1;else if(o.endColumn>r.endColumn)l=a.Direction.RIGHT,s.startColumn=r.endColumn+1;else return!1;this.direction=l;const c=this._injector.invoke(f=>m.rangeToDiscreteRange(r,f)),d=this._injector.invoke(f=>m.rangeToDiscreteRange(s,f));if(!c||!d)return!1;this.autoFillLocation={source:c,target:d,unitId:e,subUnitId:t};const u=[];this.getActiveHooks().forEach(f=>{var v;const p=(v=f==null?void 0:f.onBeforeFillData)==null?void 0:v.call(f,{source:c,target:d,unitId:e,subUnitId:t},l);p&&u.unshift(p)}),this._initPrevUndo();for(let f=0;f<u.length;f++){const p=this.menu.find(v=>v.value===u[f]);if(p&&!p.disable)return this.fillData(u[f])}const g=(S=this.menu.find(f=>f.disable===!1))==null?void 0:S.value;return g?this.fillData(g):!1}addHook(e){if(this._hooks.find(t=>t.id===e.id))throw new Error(`Add hook failed, hook id '${e.id}' already exist!`);return e.priority===void 0&&(e.priority=0),e.type===void 0&&(e.type=un.Append),this._hooks.push(e),a.toDisposable(()=>{const t=this._hooks.findIndex(r=>r===e);t>-1&&this._hooks.splice(t,1)})}registerRule(e){if(this._rules.find(r=>r.type===e.type))throw new Error(`Registry rule failed, type '${e.type}' already exist!`);const t=this._rules.findIndex(r=>r.priority<e.priority);this._rules.splice(t===-1?this._rules.length:t,0,e)}getRules(){return this._rules}getAllHooks(){return this._hooks}getActiveHooks(){const{source:e,target:t,unitId:r,subUnitId:o}=this.autoFillLocation||{};if(!e||!t||!r||!o)return[];const s=this._hooks.filter(u=>{var h;return!((h=u.disable)!=null&&h.call(u,{source:e,target:t,unitId:r,subUnitId:o},this._direction,this.applyType))}),l=s.filter(u=>u.type===un.Only);if(l.length>0)return this._getOneByPriority(l);const c=this._getOneByPriority(s.filter(u=>u.type===un.Default)),d=s.filter(u=>u.type===un.Append)||[];return[...c,...d]}get applyType(){return this._applyType$.getValue()}set applyType(e){this._applyType$.next(e)}get menu(){return this._menu$.getValue()}get direction(){return this._direction}set direction(e){this._direction=e}isFillingStyle(){return this._isFillingStyle}setFillingStyle(e){this._isFillingStyle=e}get autoFillLocation(){return this._autoFillLocation$.getValue()}set autoFillLocation(e){this._autoFillLocation$.next(e)}setDisableApplyType(e,t){this._menu$.next(this._menu$.getValue().map(r=>r.value===e?{...r,disable:t}:r))}setShowMenu(e){this._showMenu$.next(e)}fillData(e){var C,I,R;this.applyType=e;const{source:t,target:r,unitId:o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),subUnitId:s=(C=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:C.getSheetId()}=this.autoFillLocation||{};if(!t||!r||!o||!s)return!1;const l=this.direction;this._prevUndos.length>0&&this._prevUndos.forEach(w=>{this._commandService.syncExecuteCommand(w.id,w.params)}),this._prevUndos=[];const c=a.Rectangle.union(Et(t),Et(r)),d=this.getActiveHooks(),u=this._univerInstanceService.getUnit(o,a.UniverInstanceType.UNIVER_SHEET);this._commandService.syncExecuteCommand(m.SetSelectionsOperation.id,{selections:[{primary:{...(R=(I=this._selectionManagerService.getCurrentLastSelection())==null?void 0:I.primary)!=null?R:c},range:{...c,rangeType:a.RANGE_TYPE.NORMAL}}],unitId:o,subUnitId:s});const h=[],g=[];d.forEach(w=>{var P;const{undos:M,redos:y}=((P=w.onFillData)==null?void 0:P.call(w,{source:t,target:r,unitId:o,subUnitId:s},l,e))||{};M&&h.push(...M),y&&g.push(...y)});const S=g.every(w=>this._commandService.syncExecuteCommand(w.id,w.params)),f=[];e!==le.NO_FORMAT&&g.forEach(w=>{if(w.id===m.SetRangeValuesMutation.id){const{cellValue:M}=w.params;new a.ObjectMatrix(M).forValue((P,x,A)=>{const k=Object.keys(u.getStyles().get(A==null?void 0:A.s)||{});(A!=null&&A.p||k.length&&ms.some(D=>k.includes(D)))&&f.push({startRow:P,endRow:P,startColumn:x,endColumn:x})})}});const p=this._getAutoHeightUndoRedos(o,s,f);return p.redos.every(w=>this._commandService.syncExecuteCommand(w.id,w.params))&&(h.push(...p.undos),g.push(...p.redos)),S&&(this._prevUndos=h,this._undoRedoService.pushUndoRedo({unitID:o,undoMutations:h,redoMutations:g})),d.forEach(w=>{var M;(M=w.onAfterFillData)==null||M.call(w,{source:t,target:r,unitId:o,subUnitId:s},l,e)}),this.setShowMenu(!0),!0}_getAutoHeightUndoRedos(e,t,r){var h,g;const o=(h=this._renderManagerService.getRenderById(e))==null?void 0:h.with(exports.SheetSkeletonManagerService),s=(g=o==null?void 0:o.getCurrentParam())==null?void 0:g.skeleton;if(!s)return{redos:[],undos:[]};const l=s.calculateAutoHeightInRange(r),c={subUnitId:t,unitId:e,rowsAutoHeightInfo:l},d=s.worksheet,u=m.SetWorksheetRowAutoHeightMutationFactory(c,d);return{undos:[{id:m.SetWorksheetRowAutoHeightMutation.id,params:u}],redos:[{id:m.SetWorksheetRowAutoHeightMutation.id,params:c}]}}};exports.AutoFillService=Zd([rn(0,a.ICommandService),rn(1,a.IUndoRedoService),rn(2,T.IRenderManagerService),rn(3,a.Inject(a.IUniverInstanceService)),rn(4,a.Inject(m.SheetsSelectionsService)),rn(5,a.Inject(a.Injector))],exports.AutoFillService);const wt=a.createIdentifier("univer.auto-fill-service"),_t={type:a.CommandType.COMMAND,id:"sheet.command.auto-fill",handler:async(n,i)=>{const e=n.get(wt),t=n.get(a.IUniverInstanceService),{sourceRange:r,targetRange:o}=i,s=m.getSheetCommandTarget(t);if(!s)return!1;const{subUnitId:l,unitId:c}=s;return e.triggerAutoFill(c,l,r,o)}},In={id:"sheet.command.auto-clear-content",type:a.CommandType.COMMAND,handler:async(n,i)=>{const e=n.get(a.IUniverInstanceService),t=n.get(a.ICommandService),r=n.get(a.IUndoRedoService),o=n.get(m.SheetInterceptorService),s=m.getSheetCommandTarget(e);if(!s)return!1;const{unitId:l,subUnitId:c}=s,{clearRange:d,selectionRange:u}=i,h={subUnitId:c,unitId:l,cellValue:m.generateNullCellValue([d])},g=m.SetRangeValuesUndoMutationFactory(n,h),{startColumn:S,startRow:f}=u,p={selections:[{primary:{startColumn:S,startRow:f,endColumn:S,endRow:f,actualRow:f,actualColumn:S,isMerged:!1,isMergedMainCell:!1},range:{...u}}],unitId:l,subUnitId:c};if(t.executeCommand(m.SetSelectionsOperation.id,p),t.syncExecuteCommand(m.SetRangeValuesMutation.id,h)){const C=o.afterCommandExecute({id:m.SetRangeValuesMutation.id,params:h});return a.sequenceExecute(C.redos,t),r.pushUndoRedo({unitID:l,undoMutations:[{id:m.SetRangeValuesMutation.id,params:g},...C.undos],redoMutations:[{id:m.SetRangeValuesMutation.id,params:h},...C.redos]}),!0}return!1}},ur={id:"sheet.command.refill",type:a.CommandType.COMMAND,handler:async(n,i)=>n.get(wt).fillData(i.type)};var Kd=Object.getOwnPropertyDescriptor,qd=(n,i,e,t)=>{for(var r=t>1?void 0:t?Kd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Pt=(n,i)=>(e,t)=>i(e,t,n);exports.EditorBridgeService=class extends a.Disposable{constructor(e,t,r,o,s,l,c){super();E(this,"_editorUnitId",a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);E(this,"_editorIsDirty",!1);E(this,"_isDisabled",!1);E(this,"_visible",{visible:!1,eventType:T.DeviceInputEventType.Dblclick,unitId:""});E(this,"_currentEditCell",null);E(this,"_currentEditCellState",null);E(this,"_currentEditCellLayout",null);E(this,"_currentEditCellState$",new O.BehaviorSubject(null));E(this,"currentEditCellState$",this._currentEditCellState$.asObservable());E(this,"_currentEditCellLayout$",new O.BehaviorSubject(null));E(this,"currentEditCellLayout$",this._currentEditCellLayout$.asObservable());E(this,"currentEditCell$",this._currentEditCellState$.pipe(O.switchMap(e=>this._currentEditCellLayout$.pipe(O.map(t=>e&&t?{...e,...t}:null)))));E(this,"_visible$",new O.BehaviorSubject(this._visible));E(this,"visible$",this._visible$.asObservable());E(this,"_afterVisible$",new O.BehaviorSubject(this._visible));E(this,"afterVisible$",this._afterVisible$.asObservable());E(this,"_forceKeepVisible$",new O.BehaviorSubject(!1));E(this,"forceKeepVisible$",this._forceKeepVisible$.asObservable());this._sheetInterceptorService=e,this._renderManagerService=t,this._themeService=r,this._univerInstanceService=o,this._editorService=s,this._refSelectionsService=l,this._contextService=c,this.disposeWithMe(a.toDisposable(()=>{this._currentEditCellState$.complete(),this._currentEditCell=null})),this._univerInstanceService.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET).subscribe(d=>{var u;d.getUnitId()===((u=this._currentEditCellState)==null?void 0:u.unitId)&&this._clearCurrentEditCellState()})}refreshEditCellState(){const e=this.getLatestEditCellState();if(!e){this._currentEditCellState=null,this._currentEditCellLayout=null,this._currentEditCellState$.next(null),this._currentEditCellLayout$.next(null);return}const{position:t,scaleX:r,scaleY:o,canvasOffset:s,...l}=e;this._currentEditCellState=l,this._currentEditCellLayout={position:t,scaleX:r,scaleY:o,canvasOffset:s},this._currentEditCellState$.next(this._currentEditCellState),this._currentEditCellLayout$.next(this._currentEditCellLayout)}refreshEditCellPosition(e){var P;const t=this._currentEditCell;if(t==null)return;const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return;const o=this._renderManagerService.getRenderUnitById(r.getUnitId());if(!o)return;const s=(P=o.with(exports.SheetSkeletonManagerService).getSkeletonParam(t.sheetId))==null?void 0:P.skeleton,l=o.with(ve);if(!s||!this._currentEditCellState)return;const{primary:c,unitId:d,sheetId:u,scene:h,engine:g}=t,S=$n(s,c);if(S==null)return;const f=a.convertCellToRange(S),p=ee.getCanvasOffsetByEngine(g);let{startX:v,startY:C,endX:I,endY:R}=f;const{scaleX:w,scaleY:M}=h.getAncestorScale(),y=h.getViewportScrollXY(l.getViewPort());v=T.convertTransformToOffsetX(v,w,y),C=T.convertTransformToOffsetY(C,M,y),I=T.convertTransformToOffsetX(I,w,y),R=T.convertTransformToOffsetY(R,M,y),e&&this._currentEditCellLayout&&(I=I-v+this._currentEditCellLayout.position.startX,R=R-C+this._currentEditCellLayout.position.startY,v=this._currentEditCellLayout.position.startX,C=this._currentEditCellLayout.position.startY),this._currentEditCellLayout={position:{startX:v,startY:C,endX:I,endY:R},canvasOffset:p,scaleX:w,scaleY:M},this._currentEditCellLayout$.next(this._currentEditCellLayout)}setEditCell(e){this._currentEditCell=e,this._editorService.getFocusEditor()||(this._editorService.focus(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._contextService.setContextValue(a.EDITOR_ACTIVATED,!1),this._contextService.setContextValue(a.FOCUSING_EDITOR_STANDALONE,!1));const t=this.getLatestEditCellState();if(!t){this._currentEditCellState=t,this._currentEditCellLayout=t,this._currentEditCellState$.next(t),this._currentEditCellLayout$.next(t);return}const{position:r,canvasOffset:o,scaleX:s,scaleY:l,...c}=t;this._currentEditCellState=c,this._currentEditCellLayout={position:r,canvasOffset:o,scaleX:s,scaleY:l},this._currentEditCellState$.next(this._currentEditCellState),this._currentEditCellLayout$.next(this._currentEditCellLayout)}_clearCurrentEditCellState(){this._currentEditCellState=null,this._currentEditCellState$.next(null),this._currentEditCellLayout=null,this._currentEditCellLayout$.next(null)}getEditCellState(){return this._currentEditCellState==null||this._currentEditCellLayout==null?null:{...this._currentEditCellState,...this._currentEditCellLayout}}getEditCellLayout(){return this._currentEditCellLayout}getEditLocation(){return this._currentEditCellState}updateEditLocation(e,t){this._currentEditCellState&&(this._currentEditCellState={...this._currentEditCellState,row:e,column:t})}getLatestEditCellState(){var W,N,U;const e=this._currentEditCell;if(e==null)return;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const r=this._renderManagerService.getRenderUnitById(t.getUnitId());if(!r)return;const o=r.with(exports.SheetSkeletonManagerService).getCurrentSkeleton(),s=r.with(ve);if(!o)return;const{primary:l,unitId:c,sheetId:d,scene:u,engine:h}=e,{startRow:g,startColumn:S}=l,f=$n(o,l);if(f==null)return;const p=a.convertCellToRange(f),v=ee.getCanvasOffsetByEngine(h);let{startX:C,startY:I,endX:R,endY:w}=p;const{scaleX:M,scaleY:y}=u.getAncestorScale(),P=u.getViewportScrollXY(s.getViewPort());C=T.convertTransformToOffsetX(C,M,P),I=T.convertTransformToOffsetY(I,y,P),R=T.convertTransformToOffsetX(R,M,P),w=T.convertTransformToOffsetY(w,y,P);const x=t.getActiveSheet();if(!x)return;const A={workbook:t,worksheet:x,unitId:t.getUnitId(),subUnitId:x.getSheetId(),row:g,col:S,origin:x.getCellRaw(g,S)};let k;const D=this._sheetInterceptorService.writeCellInterceptor.fetchThroughInterceptors(m.BEFORE_CELL_EDIT)(x.getCell(g,S),A);k=D&&o.getCellDocumentModelWithFormula(D);const H=(W=k==null?void 0:k.documentModel)==null?void 0:W.documentStyle.renderConfig;if(H!=null&&(H.cellValueType=a.CellValueType.STRING),!k||k.documentModel==null){const L=o.getBlankCellDocumentModel(D);if(k!=null){const{verticalAlign:F,horizontalAlign:B,wrapStrategy:j,textRotation:z,fill:K}=k,{centerAngle:ne,vertexAngle:Q}=T.convertTextRotation(z);L.documentModel.documentStyle.renderConfig={...H,verticalAlign:F,horizontalAlign:B,wrapStrategy:j,background:{rgb:K},centerAngle:ne,vertexAngle:Q}}k=L}if(k.fill=k.fill||"#fff",(N=k.documentModel)==null||N.setZoomRatio(Math.max(M,y)),(D==null?void 0:D.isInArrayFormulaRange)===!0){const L=(U=k.documentModel)==null?void 0:U.getBody();L&&(L.textRuns=[{st:0,ed:L.dataStream.length-2,ts:{cl:{rgb:this._themeService.getCurrentTheme().textColorSecondary}}}])}return{position:{startX:C,startY:I,endX:R,endY:w},scaleX:M,scaleY:y,canvasOffset:v,row:g,column:S,unitId:c,sheetId:d,documentLayoutObject:k,editorUnitId:this._editorUnitId,isInArrayFormulaRange:D==null?void 0:D.isInArrayFormulaRange}}getCurrentEditorId(){return this._editorUnitId}changeVisible(e){this._visible=e,e.visible&&(this._editorIsDirty=!1),this._visible$.next(this._visible),this._afterVisible$.next(this._visible)}isVisible(){return this._visible}enableForceKeepVisible(){this._forceKeepVisible$.next(!0)}disableForceKeepVisible(){this._forceKeepVisible$.next(!1)}isForceKeepVisible(){return this._forceKeepVisible$.getValue()}changeEditorDirty(e){this._editorIsDirty=e}getEditorDirty(){return this._editorIsDirty}};exports.EditorBridgeService=qd([Pt(0,a.Inject(m.SheetInterceptorService)),Pt(1,T.IRenderManagerService),Pt(2,a.Inject(a.ThemeService)),Pt(3,a.IUniverInstanceService),Pt(4,ee.IEditorService),Pt(5,m.IRefSelectionsService),Pt(6,a.IContextService)],exports.EditorBridgeService);const Se=a.createIdentifier("univer.sheet-editor-bridge.service"),Ce={id:"sheet.operation.set-cell-edit-visible",type:a.CommandType.OPERATION,handler:(n,i)=>{if(!i)return!1;const{unitId:e}=i,r=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return r?(n.get(Se).changeVisible({...i,unitId:e!=null?e:r.getUnitId()}),!0):!1}},hr={id:"sheet.operation.set-cell-edit-visible-f2",type:a.CommandType.OPERATION,handler:(n,i)=>{const e=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return r?(e.syncExecuteCommand(Ce.id,{...i,unitId:r.getUnitId()}),!0):!1}},zt={id:"sheet.operation.set-cell-edit-visible-arrow",type:a.CommandType.OPERATION,handler:()=>!0},xn={id:"sheet.command.change-zoom-ratio",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const e=n.get(a.IUniverInstanceService),t=m.getSheetCommandTarget(e);if(!t)return!1;const{worksheet:r,subUnitId:o,unitId:s}=t,{delta:l,reset:c}=i;let d=c?100:Math.round((r.getConfig().zoomRatio+l)*100);d=Math.max(Ao[0],d),d=Math.min(Ao[1],d);const u=d/100,g=n.get(Se).isVisible();return(g.unitId===s||g.unitId===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)&&g.visible?!1:n.get(a.ICommandService).executeCommand(Le.id,{unitId:s,subUnitId:o,zoomRatio:u})}},An={id:"sheet.command.set-zoom-ratio",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const{unitId:e,subUnitId:t,zoomRatio:r}=i,s=n.get(Se).isVisible();return(s.unitId===e||s.unitId===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)&&s.visible?!1:n.get(a.ICommandService).executeCommand(Le.id,{unitId:e,subUnitId:t,zoomRatio:r})}};function Qd(n){return typeof n.isMainScene>"u"}function Ge(n,i){const e=n instanceof a.Workbook?n:n.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return null;const t=e.getUnitId();let r,o,s,l;if(Qd(i)){const g=i.getRenderById(t);if(g==null)return null;r=g.components,r=g.components,o=g.mainComponent,s=g.scene,l=g.engine}else r=i.components,o=i.mainComponent,s=i.scene,l=i.engine;if(!r||!o)return null;const c=o,d=r.get(he.ROW),u=r.get(he.COLUMN),h=r.get(he.LEFT_TOP);return{spreadsheet:c,spreadsheetRowHeader:d,spreadsheetColumnHeader:u,spreadsheetLeftTopPlaceholder:h,scene:s,engine:l}}function Wo(n,i,e,t){const{startX:r,startY:o,endX:s,endY:l}=t.getCellWithCoordByIndex(n,i);return{startX:r,startY:o,endX:s,endY:l}}function qe(n,i,e,t,r,o){const s=e.getCoordRelativeToViewport(T.Vector2.FromArray([n,i])),{x:l,y:c}=s,d=e.getScrollXYInfoByViewport(s,r),{scaleX:u,scaleY:h}=e.getAncestorScale(),g=t.getCellIndexByOffset(l,c,u,h,d,{closeFirst:o}),{row:S,column:f}=g,p=t.getNoMergeCellWithCoordByIndex(S,f),{startX:v,startY:C,endX:I,endY:R}=p;return{startX:v,startY:C,endX:I,endY:R,row:S,column:f}}function Qn(n,i,e,t){const r=e.getCoordRelativeToViewport(T.Vector2.FromArray([n,i])),o=e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),s=e.getScrollXYInfoByViewport(r,o),{scaleX:l,scaleY:c}=e.getAncestorScale(),{x:d,y:u}=s,h=n/l+d,g=i/c+u;return{x:h,y:g}}var Jd=Object.getOwnPropertyDescriptor,$d=(n,i,e,t)=>{for(var r=t>1?void 0:t?Jd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Wr=(n,i)=>(e,t)=>i(e,t,n);let er=class extends a.Disposable{constructor(i,e,t,r,o){super();E(this,"_zoom");this._context=i,this._sheetSkeletonManagerService=e,this._commandService=t,this._contextService=r,this._editorBridgeService=o,this._initSkeletonListener(),this._initZoomEventListener()}updateZoom(i,e){const t=this._context.unit.getSheetBySheetId(i);return t?(t.getConfig().zoomRatio=e,t===this._context.unit.getActiveSheet()&&this._updateViewZoom(e),!0):!1}_initZoomEventListener(){const i=this._getSheetObject().scene;this.disposeWithMe(i.onMouseWheel$.subscribeEvent(e=>{if(!e.ctrlKey||!this._contextService.getContextValue(a.FOCUSING_SHEET))return;if(this._editorBridgeService){const d=this._editorBridgeService.isVisible();if((d.unitId===this._context.unitId||d.unitId===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)&&d.visible)return}const t=Math.abs(e.deltaX);let r=t<40?.2:t<80?.4:.2;r*=e.deltaY>0?-1:1,i.scaleX<1&&(r/=2);const o=this._context.unit,s=o.getActiveSheet();if(!s)return;const l=s.getZoomRatio();let c=+Number.parseFloat(`${l+r}`).toFixed(1);c=c>=4?4:c<=.1?.1:c,this._commandService.executeCommand(An.id,{zoomRatio:Math.round(c*10)/10,unitId:o.getUnitId(),subUnitId:s.getSheetId()}),e.preventDefault()}))}_initSkeletonListener(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const t=this._context.unit.getActiveSheet();if(!t)return;const r=t.getZoomRatio()||1;this._zoom!==r&&this._updateViewZoom(r),this._zoom=r}))}_updateViewZoom(i){const e=this._getSheetObject();e==null||e.scene.scale(i,i),e==null||e.spreadsheet.makeForceDirty()}_getSheetObject(){return Ge(this._context.unit,this._context)}};er=$d([Wr(1,a.Inject(exports.SheetSkeletonManagerService)),Wr(2,a.ICommandService),Wr(3,a.IContextService),Wr(4,a.Optional(Se))],er);const Le={id:"sheet.operation.set-zoom-ratio",type:a.CommandType.OPERATION,handler:(n,i)=>{const t=n.get(T.IRenderManagerService).getRenderById(i.unitId);return t?t.with(er).updateZoom(i.subUnitId,i.zoomRatio):!1}};var eu=Object.getOwnPropertyDescriptor,tu=(n,i,e,t)=>{for(var r=t>1?void 0:t?eu(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},zi=(n,i)=>(e,t)=>i(e,t,n);const Qs="univer-sheet-main-canvas";exports.SheetsRenderService=class extends a.RxDisposable{constructor(e,t,r){super();E(this,"_skeletonChangeMutations",new Set);this._contextService=e,this._instanceSrv=t,this._renderManagerService=r,Promise.resolve().then(()=>this._init())}registerSkeletonChangingMutations(e){return this._skeletonChangeMutations.has(e)?a.toDisposable(()=>{}):(this._skeletonChangeMutations.add(e),a.toDisposable(()=>this._skeletonChangeMutations.delete(e)))}checkMutationShouldTriggerRerender(e){return this._skeletonChangeMutations.has(e)}_init(){this._initWorkbookListener(),this._initContextListener()}_initWorkbookListener(){this._instanceSrv.getTypeOfUnitAdded$(a.UniverInstanceType.UNIVER_SHEET).pipe(O.takeUntil(this.dispose$)).subscribe(e=>this._createRenderer(e)),this._instanceSrv.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET).forEach(e=>this._createRenderer(e)),this._instanceSrv.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET).pipe(O.takeUntil(this.dispose$)).subscribe(e=>this._disposeRenderer(e))}_createRenderer(e){const t=e.getUnitId();this._renderManagerService.created$.subscribe(r=>{r.unitId===t&&(r.engine.getCanvas().setId(`${Qs}_${t}`),r.engine.getCanvas().getContext().setId(`${Qs}_${t}`))}),this._renderManagerService.createRender(t)}_disposeRenderer(e){const t=e.getUnitId();this._renderManagerService.removeRender(t)}_initContextListener(){this.disposeWithMe(this._contextService.subscribeContextValue$(T.RENDER_RAW_FORMULA_KEY).pipe(O.distinctUntilChanged()).subscribe(()=>{this._renderManagerService.getRenderAll().forEach(e=>{e.mainComponent instanceof T.Spreadsheet&&e.mainComponent.makeForceDirty(!0)})}))}};exports.SheetsRenderService=tu([zi(0,a.IContextService),zi(1,a.IUniverInstanceService),zi(2,T.IRenderManagerService)],exports.SheetsRenderService);var nu=Object.getOwnPropertyDescriptor,ru=(n,i,e,t)=>{for(var r=t>1?void 0:t?nu(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Ot=(n,i)=>(e,t)=>i(e,t,n);exports.AutoFillController=class extends a.Disposable{constructor(e,t,r,o,s,l,c){super();E(this,"_beforeApplyData",[]);E(this,"_currentLocation",null);E(this,"_copyData",[]);E(this,"_defaultHook");this._univerInstanceService=e,this._commandService=t,this._autoFillService=r,this._editorBridgeService=o,this._renderManagerService=s,this._injector=l,this._sheetsRenderService=c,this._defaultHook={id:"default",type:un.Default,priority:0,onBeforeFillData:(d,u)=>this._presetAndCacheData(d,u),onFillData:(d,u,h)=>this._fillData(d,u,h)},this._init()}_init(){this._initDefaultHook(),this._initSelectionControlFillChanged(),this._initQuitListener(),this._initSkeletonChange()}_initSkeletonChange(){this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(_t.id))}_initDefaultHook(){this.disposeWithMe(this._autoFillService.addHook(this._defaultHook))}_initQuitListener(){const e=[Ce.id,In.id,m.SetRangeValuesCommand.id,Le.id,m.SetWorksheetActiveOperation.id,m.MoveRangeMutation.id,m.RemoveRowMutation.id,m.RemoveColMutation.id,m.InsertRowMutation.id,m.InsertColMutation.id,m.MoveRowsMutation.id,m.MoveColsMutation.id,m.SetWorksheetColWidthMutation.id,m.SetWorksheetRowHeightMutation.id,m.SetRangeValuesMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted((t,r)=>{var c,d;const o=r==null?void 0:r.fromCollab,s=r==null?void 0:r.fromSync,l=r==null?void 0:r.fromFormula;e.includes(t.id)&&!o&&!s&&!l&&t.params.trigger!==_t.id&&t.params.trigger!==ur.id&&this._quit(),t.id===m.RemoveSheetMutation.id&&t.params.unitId===((c=this._currentLocation)==null?void 0:c.unitId)&&t.params.subUnitId===((d=this._currentLocation)==null?void 0:d.subUnitId)&&this._quit()})),this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(t=>{var r;t.getUnitId()===((r=this._currentLocation)==null?void 0:r.unitId)&&this._quit()}))}_quit(){this._currentLocation=null,this._beforeApplyData=[],this._copyData=[],this._autoFillService.setShowMenu(!1)}_initSelectionControlFillChanged(){const e=new a.DisposableCollection,t=()=>{e.dispose();const r=T.getCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService);if(!r)return;r.with(ve).getSelectionControls().forEach(l=>{e.add(l.selectionFilled$.subscribe(c=>{if(c==null||c.startColumn===-1||c.startRow===-1||c.endColumn===-1||c.endRow===-1)return;const d={startColumn:l.model.startColumn,endColumn:l.model.endColumn,startRow:l.model.startRow,endRow:l.model.endRow},u={startColumn:c.startColumn,endColumn:c.endColumn,startRow:c.startRow,endRow:c.endRow};this._commandService.executeCommand(_t.id,{sourceRange:d,targetRange:u})})),e.add(l.fillControl.onDblclick$.subscribeEvent(()=>{const c={startColumn:l.model.startColumn,endColumn:l.model.endColumn,startRow:l.model.startRow,endRow:l.model.endRow};this._handleDbClickFill(c)})),e.add(l.fillControl.onPointerDown$.subscribeEvent(()=>{this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(Ce.id,{visible:!1,eventType:T.DeviceInputEventType.PointerDown,unitId:r.unitId})}))})};t(),this.disposeWithMe(this._commandService.onCommandExecuted(r=>{r.id===m.SetSelectionsOperation.id&&t()})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(()=>t()))}_handleDbClickFill(e){const t=this._detectFillRange(e);t.endRow<=e.endRow||this._commandService.executeCommand(_t.id,{sourceRange:e,targetRange:t})}_detectFillRange(e){var g,S,f,p,v,C;const{startRow:t,endRow:r,startColumn:o,endColumn:s}=e,l=(g=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:g.getActiveSheet();if(!l)return e;const c=l.getCellMatrix(),d=l.getMaxRows()-1,u=l.getMaxColumns()-1;let h=r;if(o>0&&((S=c.getValue(t,o-1))==null?void 0:S.v)!=null){let I=t;for(;((f=c.getValue(I,o-1))==null?void 0:f.v)!=null&&I<d;)I+=1;h=I-1}else if(s<u&&((p=c.getValue(r,s+1))==null?void 0:p.v)!=null){let I=t;for(;((v=c.getValue(I,s+1))==null?void 0:v.v)!=null&&I<d;)I+=1;h=I-1}for(let I=r+1;I<=h;I++)for(let R=o;R<=s;R++)if(((C=c.getValue(I,R))==null?void 0:C.v)!=null){h=I-1;break}return{startColumn:o,endColumn:s,startRow:t,endRow:h}}_getApplyData(e,t,r,o,s,l=!0,c){const d=[],u=Math.floor(r/t),h=r%t,g=this._autoFillService.getRules();if(!l&&s===le.ONLY_FORMAT)return console.error("ERROR: only format can not be applied when hasStyle is false"),[];const S={};g.forEach(f=>{S[f.type]=[]}),g.forEach(f=>{const{type:p,applyFunctions:v={}}=f,C=e[p];C&&C.forEach(I=>{const R=Ad(I.index,h),w=I.index.length*u+R,M=this._applyFunctions(I,w,o,s,v,e,c),y=kd(t,r,I.index);S[p].push({data:M,index:y})})});for(let f=0;f<r;f++)g.forEach(p=>{const{type:v}=p,C=S[v];for(let I=0;I<C.length;I++)f in C[I].index&&d.push(C[I].data[C[I].index[f]])});return d}_applyFunctions(e,t,r,o,s,l,c){const{data:d}=e,u=r===a.Direction.UP||r===a.Direction.LEFT;if(o===le.COPY){const h=s==null?void 0:s[le.COPY];return h?h(e,t,r,l,c):(u&&d.reverse(),Ft(d,t))}if(o===le.SERIES){const h=s==null?void 0:s[le.SERIES];return h?h(e,t,r,l):(u&&d.reverse(),s!=null&&s[le.COPY]?s[le.COPY](e,t,r,l,c):Ft(d,t))}if(o===le.ONLY_FORMAT){const h=s==null?void 0:s[le.ONLY_FORMAT];return h?h(e,t,r,l):Dd(d,t)}}_getCopyData(e,t){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!r)throw new Error("No active sheet found");const o=r.getCellMatrix(),s=this._autoFillService.getRules(),l=[],c=t===a.Direction.DOWN||t===a.Direction.UP;let d,u;return c?(d=e.cols,u=e.rows):(d=e.rows,u=e.cols),d.forEach(h=>{const g=this._getEmptyCopyDataPiece(),S={type:void 0,cellData:void 0};u.forEach(f=>{let p;c?p=o.getValue(f,h):p=o.getValue(h,f);const{type:v,isContinue:C}=s.find(I=>I.match(p,this._injector))||Ga;if(C(S,p)){const I=g[v],R=I[I.length-1];R.data.push(p),R.index.push(f-u[0])}else{const I=g[v];I?I.push({data:[p],index:[f-u[0]]}):g[v]=[{data:[p],index:[f-u[0]]}]}S.type=v,S.cellData=p}),l.push(g)}),l}_getEmptyCopyDataPiece(){const e={};return this._autoFillService.getRules().forEach(t=>{e[t.type]=[]}),e}_getMergeApplyData(e,t,r,o){const s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!s)throw new Error("No active sheet found");const l=[];for(let c=e.startRow;c<=e.endRow;c++)for(let d=e.startColumn;d<=e.endColumn;d++){const{isMergedMainCell:u,startRow:h,startColumn:g,endRow:S,endColumn:f}=s.getCellInfoInMergeData(c,d);if(u){if(r===a.Direction.DOWN){let p=h+o,v=S+o;for(;v<=t.endRow;)l.push({startRow:p,startColumn:g,endRow:v,endColumn:f}),p+=o,v+=o}else if(r===a.Direction.UP){let p=h-o,v=S-o;for(;p>=t.startRow;)l.push({startRow:p,startColumn:g,endRow:v,endColumn:f}),p-=o,v-=o}else if(r===a.Direction.RIGHT){let p=g+o,v=f+o;for(;v<=t.endColumn;)l.push({startRow:h,startColumn:p,endRow:S,endColumn:v}),p+=o,v+=o}else if(r===a.Direction.LEFT){let p=g-o,v=f-o;for(;p>=t.startColumn;)l.push({startRow:h,startColumn:p,endRow:S,endColumn:v}),p-=o,v-=o}}}return l}_presetAndCacheData(e,t){const{source:r,target:o}=e,s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!s)throw new Error("No active sheet found");const l=s.getCellMatrix(),c=[];return o.rows.forEach(d=>{const u=[];o.cols.forEach(h=>{u.push(a.Tools.deepClone(l.getValue(d,h)))}),c.push(u)}),this._beforeApplyData=c,this._copyData=this._getCopyData(r,t),this._currentLocation=e,this._shouldDisableSeries(this._copyData)?(this._autoFillService.setDisableApplyType(le.SERIES,!0),le.COPY):(this._autoFillService.setDisableApplyType(le.SERIES,!1),this._getPreferredApplyType(this._copyData))}_fillData(e,t,r){var W,N;const o=[],s=[];let l=!0;r===le.NO_FORMAT&&(l=!1,r=le.SERIES);const{source:c,target:d,unitId:u,subUnitId:h}=e;if(!c||!d||t==null)return{undos:o,redos:s};const g=Et(c),S=Et(d),{cols:f,rows:p}=d,{cols:v,rows:C}=c,I=this._copyData;let R;t===a.Direction.DOWN||t===a.Direction.UP?R=C.length:R=v.length;const w=[];if(t===a.Direction.DOWN||t===a.Direction.UP){const U=p.length,L=[];f.forEach((F,B)=>{const j=I[B],z=this._getApplyData(j,R,U,t,r,l,e);L.push(z)});for(let F=0;F<L[0].length;F++){const B=[];for(let j=0;j<L.length;j++)B.push({s:null,...L[j][F]});w.push(B)}}else{const U=f.length;p.forEach((L,F)=>{const B=I[F],j=this._getApplyData(B,R,U,t,r,l,e),z=[];for(let K=0;K<j.length;K++)z.push({s:null,...j[K]});w.push(z)})}let M=[];const y=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getStyles();if(l?(M=this._getMergeApplyData(g,S,t,R),w.forEach(U=>{U.forEach(L=>{L&&y&&y&&(L.s=y.getStyleByCell(L))})})):w.forEach((U,L)=>{U.forEach((F,B)=>{F&&y&&(F.s=y.getStyleByCell(this._beforeApplyData[L][B])||null)})}),r===le.ONLY_FORMAT&&w.forEach((U,L)=>{U.forEach((F,B)=>{if(F){const j=this._beforeApplyData[L][B]||{};F.f=j.f,F.si=j.si,F.t=j.t,F.v=j.v}})}),l){const U=[],L=(N=(W=this._univerInstanceService.getUniverSheetInstance(u))==null?void 0:W.getSheetBySheetId(h))==null?void 0:N.getMergeData();L&&L.forEach(j=>{a.Rectangle.intersects(j,S)&&U.push(j)});const F={unitId:u,subUnitId:h,ranges:U},B=this._injector.invoke(m.RemoveMergeUndoMutationFactory,F);U.length&&(s.push({id:m.RemoveWorksheetMergeMutation.id,params:F}),o.unshift({id:m.AddWorksheetMergeMutation.id,params:B}))}const P={subUnitId:h,unitId:u,cellValue:wd([d])},x=this._injector.invoke(m.SetRangeValuesUndoMutationFactory,P);s.push({id:m.SetRangeValuesMutation.id,params:P}),o.unshift({id:m.SetRangeValuesMutation.id,params:x});const A=new a.ObjectMatrix;p.forEach((U,L)=>{f.forEach((F,B)=>{w[L][B]&&A.setValue(U,F,w[L][B])})});const k=A.getMatrix(),D={subUnitId:h,unitId:u,cellValue:k},H=this._injector.invoke(m.SetRangeValuesUndoMutationFactory,D);if(this._autoFillService.getActiveHooks().forEach(U=>{var L;(L=U.onBeforeSubmit)==null||L.call(U,e,t,r,k)}),o.unshift({id:m.SetRangeValuesMutation.id,params:H}),s.push({id:m.SetRangeValuesMutation.id,params:D}),M!=null&&M.length){const U=m.getAddMergeMutationRangeByType(M),L={unitId:u,subUnitId:h,ranges:U},F=this._injector.invoke(m.AddMergeUndoMutationFactory,L);o.unshift({id:m.RemoveWorksheetMergeMutation.id,params:F}),s.push({id:m.AddWorksheetMergeMutation.id,params:L})}return{undos:o,redos:s}}_shouldDisableSeries(e){return e.every(t=>Object.keys(t).every(r=>{var o;return((o=t[r])==null?void 0:o.length)===0||[Ie.OTHER,Ie.FORMULA].includes(r)}))}_getPreferredApplyType(e){return e.every(r=>Object.keys(r).every(o=>{var s,l;return((s=r[o])==null?void 0:s.length)===0||((l=r[o])==null?void 0:l.length)===1&&r[o][0].data.length===1&&Ie.NUMBER===o}))?le.COPY:le.SERIES}};exports.AutoFillController=ru([Ot(0,a.IUniverInstanceService),Ot(1,a.ICommandService),Ot(2,wt),Ot(3,Se),Ot(4,T.IRenderManagerService),Ot(5,a.Inject(a.Injector)),Ot(6,a.Inject(exports.SheetsRenderService))],exports.AutoFillController);var iu=Object.getOwnPropertyDescriptor,ou=(n,i,e,t)=>{for(var r=t>1?void 0:t?iu(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Xi=(n,i)=>(e,t)=>i(e,t,n);exports.CellCustomRenderController=class extends a.Disposable{constructor(e,t,r,o){super();E(this,"_enterActiveRender");this._context=e,this._sheetSkeletonManagerService=t,this._renderManagerService=r,this._permissionService=o,this._initEventBinding()}_initEventBinding(){const e=new a.DisposableCollection,t=this._context.unit,r=o=>{if(e.dispose(),!o)return;const s=this._context.unitId,{skeleton:l}=o,c=this._renderManagerService.getRenderById(s);if(c&&c.mainComponent){const d=c.mainComponent,u=S=>{const{offsetX:f,offsetY:p}=S,v=c.scene,C=t.getActiveSheet();if(!C)return;const I=v.getActiveViewportByCoord(T.Vector2.FromArray([f,p]));if(!I)return;const{scaleX:R,scaleY:w}=v.getAncestorScale(),M={x:I.viewportScrollX,y:I.viewportScrollY},y=l.getCellIndexByOffset(f,p,R,w,M),P=l.worksheet.getMergedCell(y.row,y.column),x={actualRow:P?P.startRow:y.row,actualCol:P?P.startColumn:y.column,row:y.row,col:y.column};if(!x||!l)return;const A=C.getCell(x.actualRow,x.actualCol);if(!A)return;const k=A.customRender;if(!(k!=null&&k.length))return;const D=x.actualRow,H=x.actualCol,W=k.sort(a.sortRules),N=C.getSheetId(),U={data:A,style:l.getStyles().getStyleByCell(A),primaryWithCoord:l.getCellWithCoordByIndex(x.actualRow,x.actualCol),unitId:s,subUnitId:N,row:D,col:H,workbook:t,worksheet:C},L={x:M.x+f/R,y:M.y+p/w},F=W.find(B=>{var j;return(j=B.isHit)==null?void 0:j.call(B,L,U)});if(F)return[F,U]},h=d.onPointerDown$.subscribeEvent(S=>{var p,v,C,I;const f=u(S);if(f){const[R,w]=f,{row:M,col:y,worksheet:P,unitId:x,subUnitId:A}=w;if(!((p=this._permissionService.composePermission([new m.WorkbookEditablePermission(x).id,new m.WorksheetEditPermission(x,A).id]))==null?void 0:p.every(H=>H.value)))return!1;const D=(C=(v=P.getCell(M,y))==null?void 0:v.selectionProtection)==null?void 0:C[0];if((D==null?void 0:D[m.UnitAction.Edit])===!1)return!1;(I=R.onPointerDown)==null||I.call(R,w,S)}}),g=a.fromEventSubject(d.onPointerMove$).pipe(O.throttleTime(30)).subscribe(S=>{var p,v,C,I,R,w;const f=u(S);if(f){const[M,y]=f;this._enterActiveRender?this._enterActiveRender.render!==M&&((v=(p=this._enterActiveRender.render).onPointerLeave)==null||v.call(p,this._enterActiveRender.cellContext,S),this._enterActiveRender={render:M,cellContext:y},(C=M.onPointerEnter)==null||C.call(M,y,S)):(this._enterActiveRender={render:M,cellContext:y},(I=M.onPointerEnter)==null||I.call(M,y,S))}else this._enterActiveRender&&((w=(R=this._enterActiveRender.render).onPointerLeave)==null||w.call(R,this._enterActiveRender.cellContext,S),this._enterActiveRender=null)});h&&e.add(h),g&&e.add(g)}};this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(r)),r(this._sheetSkeletonManagerService.getCurrentParam()),this.disposeWithMe(e)}};exports.CellCustomRenderController=ou([Xi(1,a.Inject(exports.SheetSkeletonManagerService)),Xi(2,T.IRenderManagerService),Xi(3,a.IPermissionService)],exports.CellCustomRenderController);class gs extends a.Disposable{constructor(){super(...arguments);E(this,"rangesStack",[]);E(this,"selectedRangeWorksheet","")}}var su=Object.getOwnPropertyDescriptor,au=(n,i,e,t)=>{for(var r=t>1?void 0:t?su(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Js=(n,i)=>(e,t)=>i(e,t,n);let bn=class{constructor(n,i){E(this,"_current",null);E(this,"_shortcutParam",[]);this._univerInstanceService=n,this._localeService=i}dispose(){this._shortcutParam=[]}getCurrentBySearch(n){return this._getCurrentBySearch(n)}getCurrent(){return this._getCurrentBySearch(this._current)}addOrUpdate(n){const i=this._getCurrentBySearch({unitId:n.unitId,sheetId:n.sheetId,keycode:n.keycode});if(i!=null){const e=this._shortcutParam.indexOf(i);this._shortcutParam.splice(e,1)}return this._shortcutParam.push(n),i}remove(n){if(n==null)return;const i=this._getCurrentBySearch(n);if(i==null)return;const e=this._shortcutParam.indexOf(i);return this._shortcutParam.splice(e,1)[0]}_getCurrentBySearch(n){return n==null?void 0:this._shortcutParam.find(e=>e.unitId===n.unitId&&e.sheetId===n.sheetId&&e.keycode===n.keycode)}};bn=au([Js(0,a.IUniverInstanceService),Js(1,a.Inject(a.LocaleService))],bn);var ki=(n=>(n.MergeAll="mergeAll",n.MergeVertical="mergeVertical",n.MergeHorizontal="mergeHorizontal",n))(ki||{});function It(n,i,e,t,r=!0,o=1,s=!0){let l={...n};t==null&&(t={startRow:0,endRow:e.getRowCount()-1,startColumn:0,endColumn:e.getColumnCount()-1});let c;switch(i){case a.Direction.UP:for(c=n.startRow-o;c>-1&&!e.getRowVisible(c);)c-=1;c>=t.startRow?(l.startRow=c,l.endRow=c):s&&(l.startRow=t.endRow,l.endRow=t.endRow,r&&(l=It(l,a.Direction.LEFT,e,t,!1)));break;case a.Direction.DOWN:for(c=n.endRow+o;c<e.getRowCount()&&!e.getRowVisible(c);)c+=1;c<=t.endRow?(l.startRow=c,l.endRow=c):s&&(l.startRow=t.startRow,l.endRow=t.startRow,r&&(l=It(l,a.Direction.RIGHT,e,t,!1)));break;case a.Direction.LEFT:for(c=n.startColumn-o;c>-1&&!e.getColVisible(c);)c-=1;c>=t.startColumn?(l.startColumn=c,l.endColumn=c):s&&(l.startColumn=t.endColumn,l.endColumn=t.endColumn,r&&(l=It(l,a.Direction.UP,e,t,!1)));break;case a.Direction.RIGHT:for(c=n.endColumn+o;c<e.getColumnCount()&&!e.getColVisible(c);)c+=1;c<=t.endColumn?(l.startColumn=c,l.endColumn=c):s&&(l.startColumn=t.startColumn,l.endColumn=t.startColumn,r&&(l=It(l,a.Direction.DOWN,e,t,!1)));break}return l}function Ss(n,i,e){const t={...n},{startRow:r,startColumn:o,endRow:s,endColumn:l}=tr(n,i,e);let c=Ln(e,r,o,s,l).hasValue,d=!0,u=!0;for(;u;){if(a.Direction.UP===i){let h=t.startRow-1;for(;h>-1&&!e.getRowVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:g,matrix:S}=Ln(e,h,t.startColumn,h,t.endColumn);if(c&&!g&&!d){u=!1;break}else{if(S.getLength()!==0){let f=h;S.forValue(p=>{f=Math.min(p,f)}),t.startRow=f}else t.startRow=h;if(t.endRow=t.startRow,!c&&g){u=!1;break}c=g,d=!1}}if(a.Direction.DOWN===i){let h=t.endRow+1;for(;h<e.getRowCount()&&!e.getRowVisible(h);)h+=1;if(h===e.getRowCount()){u=!1;break}const{hasValue:g,matrix:S}=Ln(e,h,t.startColumn,h,t.endColumn);if(c&&!g&&!d){u=!1;break}else{if(S.getLength()!==0){let f=h;S.forValue((p,v,C)=>{f=Math.max(p+(C.rowSpan||1)-1,f)}),t.endRow=f}else t.endRow=h;if(t.startRow=t.endRow,!c&&g){u=!1;break}c=g,d=!1}}if(a.Direction.LEFT===i){let h=t.startColumn-1;for(;h>-1&&!e.getColVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:g,matrix:S}=Ln(e,t.startRow,h,t.endRow,h);if(c&&!g&&!d){u=!1;break}else{if(S.getLength()!==0){let f=h;S.forValue((p,v)=>{f=Math.min(v,f)}),t.startColumn=f}else t.startColumn=h;if(t.endColumn=t.startColumn,!c&&g){u=!1;break}c=g,d=!1}}if(a.Direction.RIGHT===i){let h=t.endColumn+1;for(;h<e.getColumnCount()&&!e.getColVisible(h);)h+=1;if(h===e.getColumnCount()){u=!1;break}const{hasValue:g,matrix:S}=Ln(e,t.startRow,h,t.endRow,h);if(c&&!g&&!d){u=!1;break}else{if(S.getLength()!==0){let f=h;S.forValue((p,v,C)=>{f=Math.max(v+(C.colSpan||1)-1,f)}),t.endColumn=f}else t.endColumn=h;if(t.startColumn=t.endColumn,!c&&g){u=!1;break}c=g,d=!1}}}return m.alignToMergedCellsBorders(t,e,!0)}function Za(n,i,e){return It(n,i,e,void 0,!1,1,!1)}function lu(n,i,e){const t=Ss(n,i,e);return m.alignToMergedCellsBorders(a.Rectangle.union(t,n),e,!0)}function cu(n,i,e){const t=Za(n,i,e),r={startRow:Math.min(n.startRow,t.startRow),startColumn:Math.min(n.startColumn,t.startColumn),endRow:Math.max(n.endRow,t.endRow),endColumn:Math.max(n.endColumn,t.endColumn)};return m.alignToMergedCellsBorders(a.Rectangle.union(n,r),e)}function du(n,i,e,t){const r=a.getReverseDirection(e),o=Ss(tr(n,r,t),e,t);return e===a.Direction.UP&&o.startRow<=n.startRow?m.alignToMergedCellsBorders({...i,startColumn:n.startColumn,endColumn:n.endColumn},t,!0):e===a.Direction.DOWN&&o.endRow>=n.endRow?m.alignToMergedCellsBorders({...i,startColumn:n.startColumn,endColumn:n.endColumn},t,!0):e===a.Direction.LEFT&&o.startColumn<=n.startColumn?m.alignToMergedCellsBorders({...i,startRow:n.startRow,endRow:n.endRow},t,!0):e===a.Direction.RIGHT&&o.endColumn>=n.endColumn?m.alignToMergedCellsBorders({...i,startRow:n.startRow,endRow:n.endRow},t,!0):a.Rectangle.union(a.Rectangle.clone(i),o)}function uu(n,i,e){const t=a.getReverseDirection(i),r=tr(n,t,e),o=tr(n,i,e),s=Za(r,i,e);return m.alignToMergedCellsBorders(a.Rectangle.union(o,s),e,!1)}function $s(n){return{startRow:0,startColumn:0,endRow:n.getRowCount()-1,endColumn:n.getColumnCount()-1,rangeType:a.RANGE_TYPE.ALL}}function tr(n,i,e){let t;switch(i){case a.Direction.UP:t={startRow:n.startRow,startColumn:n.startColumn,endRow:n.startRow,endColumn:n.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.DOWN:t={startRow:n.endRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.LEFT:t={startRow:n.startRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.startColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.RIGHT:t={startRow:n.startRow,startColumn:n.endColumn,endRow:n.endRow,endColumn:n.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;default:throw new Error("Invalid direction")}return m.alignToMergedCellsBorders(t,e,!1)}function Ln(n,i,e,t,r){let o=!1;const s=n.getMatrixWithMergedCells(i,e,t,r).forValue((l,c,d)=>{if(mu(d))return o=!0,!1});return{hasValue:o,matrix:s}}function Uo(n,i,e){const t=a.Rectangle.clone(n);if(i==null)return t;switch(e){case a.Direction.UP:case a.Direction.DOWN:t.startColumn=t.endColumn=i.actualColumn;break;case a.Direction.LEFT:case a.Direction.RIGHT:t.startRow=t.endRow=i.actualRow;break}return t}function hu(n,i,e){var l,c,d,u;const{primary:t,range:r}=n,o=a.Rectangle.clone(r);switch(i){case a.Direction.UP:case a.Direction.DOWN:o.startRow=(l=t==null?void 0:t.startRow)!=null?l:r.startRow,o.endRow=(c=t==null?void 0:t.endRow)!=null?c:r.startRow;break;case a.Direction.LEFT:case a.Direction.RIGHT:o.startColumn=(d=t==null?void 0:t.startColumn)!=null?d:r.startColumn,o.endColumn=(u=t==null?void 0:t.endColumn)!=null?u:r.startColumn;break}const s=tr(o,i,e);switch(i){case a.Direction.DOWN:return r.startRow<s.startRow;case a.Direction.UP:return r.endRow>s.endRow;case a.Direction.LEFT:return s.endColumn<r.endColumn;case a.Direction.RIGHT:return s.startColumn>r.startColumn}}function Ka(n,i){let e=n[0].startRow,t=n[0].endRow;n.forEach(o=>{const{startRow:s,endRow:l}=o;e=Math.min(e,s),t=Math.max(t,l)});const r=new Array(t-e+1).fill(!1);return i.forEach(o=>{const{startRow:s,endRow:l}=o;for(let c=Math.max(s,e);c<=Math.min(l,t);c++)r[c-e]=!0}),n.every(o=>{const{startRow:s,endRow:l}=o;for(let c=s;c<=l;c++)if(!r[c-e])return!1;return!0})}function qa(n,i){let e=n[0].startColumn,t=n[0].endColumn;n.forEach(o=>{const{startColumn:s,endColumn:l}=o;e=Math.min(e,s),t=Math.max(t,l)});const r=new Array(t-e+1).fill(!1);return i.forEach(o=>{const{startColumn:s,endColumn:l}=o;for(let c=Math.max(s,e);c<=Math.min(l,t);c++)r[c-e]=!0}),n.every(o=>{const{startColumn:s,endColumn:l}=o;for(let c=s;c<=l;c++)if(!r[c-e])return!1;return!0})}function fs(n,i){return i?n==="mergeAll"?i.filter(e=>!(e.startRow===e.endRow&&e.startColumn===e.endColumn)):n==="mergeVertical"?i.filter(e=>e.startRow!==e.endRow):n==="mergeHorizontal"?i.filter(e=>e.startColumn!==e.endColumn):i:null}function mu(n){return n.v!==void 0&&n.v!==null&&n.v!==""||n.p!==void 0}var Je=(n=>(n[n.moveStopeOne=0]="moveStopeOne",n[n.moveGap=1]="moveGap",n[n.moveStepPage=2]="moveStepPage",n[n.moveStepEnd=3]="moveStepEnd",n))(Je||{});const xe={id:"sheet.command.move-selection",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const{workbook:t,worksheet:r}=e,o=m.getSelectionsService(n,i.fromCurrentSelection).getCurrentLastSelection();if(!o)return!1;const{direction:s,jumpOver:l,extra:c}=i,{range:d,primary:u}=o,h=Uo(d,u,s),g=l===1?Ss(h,s,r):It(h,s,r),S=m.getCellAtRowCol(g.startRow,g.startColumn,r);if(a.Rectangle.equals(S,h))return!1;const f=t.getUnitId();n.get(bn).remove({unitId:f,sheetId:r.getSheetId(),keycode:_.KeyCode.TAB});const p=[{range:a.Rectangle.clone(S),primary:{startRow:S.startRow,startColumn:S.startColumn,endRow:S.endRow,endColumn:S.endColumn,actualRow:g.startRow,actualColumn:g.startColumn,isMerged:S.isMerged,isMergedMainCell:S.startRow===g.startRow&&S.startColumn===g.startColumn}}];return n.get(a.ICommandService).executeCommand(m.SetSelectionsOperation.id,{unitId:t.getUnitId(),subUnitId:r.getSheetId(),selections:p,type:m.SelectionMoveType.MOVE_END,extra:c,reveal:!0})}},$e={id:"sheet.command.move-selection-enter-tab",type:a.CommandType.COMMAND,handler:(n,i)=>{var U;if(!i)return!1;const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const{workbook:t,worksheet:r}=e,o=m.getSelectionsService(n),{direction:s,keycode:l}=i,c=s===a.Direction.LEFT||s===a.Direction.UP,d=o.getCurrentSelections().concat(),u=d.findIndex(L=>L.primary),h=d[u];if(!h)return!1;const g=c?-1:1,S=u+g!==d.length?d[u+g]:d[0],f=d.findIndex(L=>L===S),p=t.getUnitId(),v=r.getSheetId();if(!h)return!1;const{range:C}=h,I=h.primary;let R=Uo(C,I,s);const w=n.get(bn),M=w.getCurrentBySearch({unitId:p,sheetId:v,keycode:_.KeyCode.TAB});let y;const{startRow:P,endRow:x,startColumn:A,endColumn:k}=C,D=c?I.startRow===P&&I.startColumn===A:I.endRow===x&&I.endColumn===k;if(a.Rectangle.equals(C,I)){if(l===_.KeyCode.TAB)M==null&&w.addOrUpdate({unitId:p,sheetId:v,keycode:_.KeyCode.TAB,selection:h});else{const B=M==null?void 0:M.selection;if(B!=null){const{range:j,primary:z}=B;R=Uo(j,z,s)}w.remove({unitId:p,sheetId:v,keycode:_.KeyCode.TAB})}const L=It(R,s,r),F=m.getCellAtRowCol(L.startRow,L.startColumn,r);if(a.Rectangle.equals(F,R))return!1;y={range:a.Rectangle.clone(F),primary:{startRow:F.startRow,startColumn:F.startColumn,endRow:F.endRow,endColumn:F.endColumn,actualRow:L.startRow,actualColumn:L.startColumn,isMerged:F.isMerged,isMergedMainCell:F.startRow===L.startRow&&F.startColumn===L.startColumn}}}else{w.remove({unitId:p,sheetId:v,keycode:_.KeyCode.TAB});const L=a.Tools.deepClone(I),F=D?S.range:It({startRow:L.startRow,startColumn:L.startColumn,endRow:L.endRow,endColumn:L.endColumn},s,r,{startRow:P,endRow:x,startColumn:A,endColumn:k}),B=D&&c,j=B?m.getCellAtRowCol(F.endRow,F.endColumn,r):m.getCellAtRowCol(F.startRow,F.startColumn,r);y={range:D?S.range:a.Rectangle.clone(C),primary:{startRow:j.startRow,startColumn:j.startColumn,endRow:j.endRow,endColumn:j.endColumn,actualRow:B?j.startRow:F.startRow,actualColumn:B?j.startColumn:F.startColumn,isMerged:j.isMerged,isMergedMainCell:j.startRow===F.startRow&&j.startColumn===F.startColumn},style:D?S.style:h.style}}D?(d[u].primary=null,d[f]=y,o.setSelections(p,v,[],m.SelectionMoveType.MOVE_END)):d[u]=y;const H=n.get(a.ICommandService).executeCommand(m.SetSelectionsOperation.id,{unitId:p,subUnitId:v,type:m.SelectionMoveType.MOVE_END,selections:d,reveal:!0,extra:i.extra}),N=(U=n.get(T.IRenderManagerService).getRenderById(p))==null?void 0:U.with(ve);return N==null||N.refreshSelectionMoveEnd(),H}},Ne={id:"sheet.command.expand-selection",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const{worksheet:t,unitId:r,subUnitId:o}=e,s=m.getSelectionsService(n).getCurrentLastSelection();if(!s)return!1;const{range:l,primary:c}=s,{jumpOver:d,direction:u,extra:h}=i,S=hu(s,u,t)?d===1?du(l,{...a.Rectangle.clone(c),rangeType:a.RANGE_TYPE.NORMAL},u,t):uu(l,u,t):d===1?lu(l,u,t):cu(l,u,t);return S.rangeType=s.range.rangeType,a.Rectangle.equals(S,l)?!1:n.get(a.ICommandService).syncExecuteCommand(m.SetSelectionsOperation.id,{unitId:r,subUnitId:o,type:m.SelectionMoveType.MOVE_END,selections:[{range:S,primary:c}],extra:h,reveal:!0})}},Di={id:"sheet.command.select-all",type:a.CommandType.COMMAND,handler:async(n,i={expandToGapFirst:!0,loop:!1})=>{const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const t=m.getSelectionsService(n).getCurrentLastSelection();if(!t)return!1;const r=n.get(gs),{worksheet:o,unitId:s,subUnitId:l}=e,c=`${s}|${l}`;c!==r.selectedRangeWorksheet&&(r.rangesStack=[],r.selectedRangeWorksheet=c);const d=o.getMaxRows(),u=o.getMaxColumns(),{expandToGapFirst:h,loop:g}=i,{range:S,primary:f}=t,p=S.endColumn===u-1&&S.endRow===d-1&&S.startRow===0&&S.startColumn===0;r.rangesStack.some(C=>a.Rectangle.equals(C,S))||(r.rangesStack=[],r.rangesStack.push(S));let v;if(p)if(g){if(r.rangesStack.findIndex(I=>a.Rectangle.equals(I,S))!==r.rangesStack.length-1)return!1;v=r.rangesStack[0]}else return!1;else h?(v=m.expandToContinuousRange(S,{left:!0,right:!0,up:!0,down:!0},o),a.Rectangle.equals(v,S)&&(v=$s(o))):v=$s(o);return r.rangesStack.some(C=>a.Rectangle.equals(C,v))||r.rangesStack.push(v),n.get(a.ICommandService).executeCommand(m.SetSelectionsOperation.id,{unitId:s,subUnitId:l,reveal:!0,selections:[{range:v,primary:f}]})}};var gu=Object.getOwnPropertyDescriptor,Su=(n,i,e,t)=>{for(var r=t>1?void 0:t?gu(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},fu=(n,i)=>(e,t)=>i(e,t,n);exports.SheetScrollManagerService=class{constructor(i,e){E(this,"_scrollStateMap",new Map);E(this,"_rawScrollInfo$",new O.BehaviorSubject(null));E(this,"rawScrollInfo$",this._rawScrollInfo$.asObservable());E(this,"validViewportScrollInfo$",new O.BehaviorSubject(null));E(this,"_searchParamForScroll",null);this._context=i,this._sheetSkeletonManagerService=e}dispose(){this._rawScrollInfo$.complete()}calcViewportScrollFromRowColOffset(i){if(!i)return{viewportScrollX:0,viewportScrollY:0};let{sheetViewStartColumn:e,sheetViewStartRow:t,offsetX:r,offsetY:o}=i;t=t||0,o=o||0;const s=this._sheetSkeletonManagerService.getCurrentSkeleton(),l=(s==null?void 0:s.rowHeightAccumulation[t-1])||0,d=((s==null?void 0:s.columnWidthAccumulation[e-1])||0)+r,u=l+o;return{viewportScrollX:d,viewportScrollY:u}}setSearchParam(i){this._searchParamForScroll=i}getScrollStateByParam(i){return this._getCurrentScroll(i)}getCurrentScrollState(){return this._getCurrentScroll(this._searchParamForScroll)}setValidScrollState(i){this._setScrollState(i)}emitRawScrollParam(i){this._emitRawScroll(i)}setValidScrollStateToCurrSheet(i){if(this._searchParamForScroll==null)return;this._setScrollState({...this._searchParamForScroll,...i});const e=this._searchParamForScroll.sheetId,t=this._sheetSkeletonManagerService.getSkeleton(e);t&&t.setScroll(i.viewportScrollX,i.viewportScrollY)}clear(){this._searchParamForScroll!=null&&this._clearByParamAndNotify(this._searchParamForScroll)}_setScrollState(i){const{unitId:e,sheetId:t,sheetViewStartColumn:r,sheetViewStartRow:o,offsetX:s,offsetY:l}=i;this._scrollStateMap.has(e)||this._scrollStateMap.set(e,new Map);const c=this._scrollStateMap.get(e),d={sheetViewStartRow:o,sheetViewStartColumn:r,offsetX:s,offsetY:l};c.set(t,d)}_clearByParamAndNotify(i){this._setScrollState({...i,sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),this._emitRawScroll({sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0})}_getCurrentScroll(i){var s;const e={sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0};if(i==null)return e;const{unitId:t,sheetId:r}=i;return((s=this._scrollStateMap.get(t))==null?void 0:s.get(r))||e}_emitRawScroll(i){this._rawScrollInfo$.next(i)}};exports.SheetScrollManagerService=Su([fu(1,a.Inject(exports.SheetSkeletonManagerService))],exports.SheetScrollManagerService);const je={id:"sheet.operation.set-scroll",type:a.CommandType.OPERATION,handler:(n,i)=>{if(!i)return!1;const{unitId:e,sheetId:t,offsetX:r,offsetY:o,sheetViewStartColumn:s,sheetViewStartRow:l}=i;return n.get(T.IRenderManagerService).getRenderById(e).with(exports.SheetScrollManagerService).emitRawScrollParam({unitId:e,sheetId:t,offsetX:r,offsetY:o,sheetViewStartRow:l,sheetViewStartColumn:s}),!0}},Rn={id:"sheet.command.set-scroll-relative",type:a.CommandType.COMMAND,handler:async(n,i)=>{const e=n.get(a.ICommandService),t=n.get(a.IUniverInstanceService),r=n.get(T.IRenderManagerService),o=m.getSheetCommandTarget(t);if(!o)return!1;const{unitId:s,subUnitId:l}=o,d=r.getRenderById(s).with(exports.SheetScrollManagerService).getCurrentScrollState(),{offsetX:u=0,offsetY:h=0}=i||{},{sheetViewStartRow:g=0,sheetViewStartColumn:S=0,offsetX:f=0,offsetY:p=0}=d||{};return e.executeCommand(je.id,{unitId:s,sheetId:l,sheetViewStartRow:g,sheetViewStartColumn:S,offsetX:f+u,offsetY:p+h})}},ze={id:"sheet.command.scroll-view",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const e=n.get(a.IUniverInstanceService),t=n.get(T.IRenderManagerService),r=m.getSheetCommandTarget(e);if(!r)return!1;const{workbook:o,worksheet:s,unitId:l}=r,d=t.getRenderById(l).with(exports.SheetScrollManagerService).getCurrentScrollState();if(!s)return!1;const{sheetViewStartRow:u,sheetViewStartColumn:h,offsetX:g,offsetY:S}=i,{sheetViewStartColumn:f,sheetViewStartRow:p,offsetX:v,offsetY:C}=d||{},{xSplit:I,ySplit:R}=r.worksheet.getConfig().freeze;return n.get(a.ICommandService).syncExecuteCommand(je.id,{unitId:o.getUnitId(),sheetId:s.getSheetId(),sheetViewStartRow:u!=null?u:p!=null?p:0+R,sheetViewStartColumn:h!=null?h:f!=null?f:0+I,offsetX:g!=null?g:v,offsetY:S!=null?S:C})}},ps={id:"sheet.command.scroll-to-cell",type:a.CommandType.COMMAND,handler:(n,i)=>{const e=n.get(a.IUniverInstanceService);return n.get(T.IRenderManagerService).getRenderById(e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(exports.SheetsScrollRenderController).scrollToRange(i.range,i.forceTop,i.forceLeft)}},pu={id:"sheet.command.scroll-view-reset",type:a.CommandType.COMMAND,handler:async n=>{const i=n.get(a.IUniverInstanceService),e=m.getSheetCommandTarget(i);if(!e)return!1;const{subUnitId:t,unitId:r}=e;return n.get(a.ICommandService).executeCommand(je.id,{unitId:r,sheetId:t,sheetViewStartRow:0,sheetViewStartColumn:0})}};var vu=Object.getOwnPropertyDescriptor,Cu=(n,i,e,t)=>{for(var r=t>1?void 0:t?vu(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},on=(n,i)=>(e,t)=>i(e,t,n);xe.id,$e.id;const _u=3;exports.SheetsScrollRenderController=class extends a.Disposable{constructor(i,e,t,r,o,s,l){super(),this._context=i,this._injector=e,this._sheetSkeletonManagerService=t,this._contextService=r,this._commandService=o,this._renderManagerService=s,this._scrollManagerService=l,this._initCommandListener(),this._wheelEventListener(),this._scrollBarEventListener(),this._initSkeletonListener()}_wheelEventListener(){const{scene:i}=this._context;if(!i)return;const e=i.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);e&&this.disposeWithMe(i.onMouseWheel$.subscribeEvent((t,r)=>{if(t.ctrlKey||!this._contextService.getContextValue(a.FOCUSING_SHEET))return;let o=0,s=0;o=t.deltaX,t.shiftKey?o=(t.deltaY||t.deltaX)*_u:s=t.deltaY,this._commandService.executeCommand(Rn.id,{offsetX:o,offsetY:s}),this._context.scene.makeDirty(!0);const l=e.limitedScroll(e.scrollX+o,e.scrollY+s);l&&!l.isLimitedX&&!l.isLimitedY&&(t.preventDefault(),i.getParent().classType===T.RENDER_CLASS_TYPE.SCENE_VIEWER&&r.stopPropagation()),e.isWheelPreventDefaultX&&e.isWheelPreventDefaultY&&t.preventDefault()}))}_scrollBarEventListener(){const{scene:i}=this._context;if(i==null)return;const e=i.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);e&&(this.disposeWithMe(a.toDisposable(this._scrollManagerService.rawScrollInfo$.subscribe(t=>{var S;const r=(S=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:S.skeleton;if(!r)return;if(t==null){e.scrollToViewportPos({viewportScrollX:0,viewportScrollY:0});return}const{sheetViewStartRow:o,sheetViewStartColumn:s,offsetX:l,offsetY:c}=t,{startX:d,startY:u}=r.getCellWithCoordByIndex(o,s,!1),h=d+l,g=u+c;e.scrollToViewportPos({viewportScrollX:h,viewportScrollY:g})}))),this.disposeWithMe(e.onScrollAfter$.subscribeEvent(t=>{var p;const r=(p=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:p.skeleton;if(r==null||t.isTrigger===!1)return;const o=this._getSheetObject();if(r==null||o==null)return;const{viewportScrollX:s,viewportScrollY:l,scrollX:c,scrollY:d}=t,{row:u,column:h,rowOffset:g,columnOffset:S}=r.getOffsetRelativeToRowCol(s,l),f={sheetViewStartRow:u,sheetViewStartColumn:h,offsetX:S,offsetY:g,viewportScrollX:s,viewportScrollY:l,scrollX:c,scrollY:d};this._scrollManagerService.setValidScrollStateToCurrSheet(f),this._scrollManagerService.validViewportScrollInfo$.next({...f,viewportScrollX:s,viewportScrollY:l,scrollX:c,scrollY:d})})),this.disposeWithMe(e.onScrollByBar$.subscribeEvent(t=>{var g;const r=(g=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:g.skeleton;if(r==null||t.isTrigger===!1)return;const o=this._getSheetObject();if(r==null||o==null)return;const{viewportScrollX:s=0,viewportScrollY:l=0}=t;this._getFreeze();const{row:c,column:d,rowOffset:u,columnOffset:h}=r.getOffsetRelativeToRowCol(s,l);this._commandService.executeCommand(ze.id,{sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:h,offsetY:u})})))}_initSkeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeletonBefore$.subscribe(i=>{if(i==null)return;const e={unitId:i.unitId,sheetId:i.sheetId};if(this._scrollManagerService.setSearchParam(e),!this._getSheetObject())return;const r=this._scrollManagerService.getScrollStateByParam(e),{viewportScrollX:o,viewportScrollY:s}=this._scrollManagerService.calcViewportScrollFromRowColOffset(r);r&&this._updateViewportScroll(o,s)})))}_updateViewportScroll(i=0,e=0){const t=this._getSheetObject();if(!t)return;const r=t.scene,o=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),s=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT),l=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM),c=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT),d=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);o&&(o.viewportScrollX=i,o.viewportScrollY=e),l&&(l.viewportScrollY=e),s&&(s.viewportScrollX=i),c&&(c.viewportScrollY=e),d&&(d.viewportScrollX=i)}scrollToRange(i,e,t){let{endRow:r,endColumn:o,startColumn:s,startRow:l}=i;const c=this._getViewportBounding();if(i.rangeType===a.RANGE_TYPE.ROW?(s=0,o=0):i.rangeType===a.RANGE_TYPE.COLUMN&&(l=0,r=0),c&&!e&&!t){const d=c.startRow>r?l:r,u=c.startColumn>o?s:o;return this._scrollToCell(d,u)}else return this._scrollToCell(l,s,e,t)}scrollToCell(i,e){const t=this._context.unit.getActiveSheet(),{ySplit:r,xSplit:o}=t.getFreeze();return this._commandService.syncExecuteCommand(ze.id,{sheetViewStartRow:i-r,sheetViewStartColumn:e-o,offsetX:0,offsetY:0})}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{switch(i.id){case m.SetSelectionsOperation.id:{const e=i.params;e.unitId===this._context.unitId&&e.reveal&&this._scrollToSelection()}break;case m.ScrollToCellOperation.id:{const e=i.params;if(e.unitId===this._context.unitId){const t=e.range;this.scrollToRange(t)}}break;case Ne.id:{const e=i.params;this._scrollToSelectionForExpand(e)}break}}))}_scrollToSelectionForExpand(i){setTimeout(()=>{const e=this._getSelectionsService().getCurrentLastSelection();if(e==null)return;const{startRow:t,startColumn:r,endRow:o,endColumn:s}=e.range,l=this._getViewportBounding();if(l==null)return;const{startRow:c,startColumn:d,endRow:u,endColumn:h}=l;let g=0,S=0;t>c?g=o:o<u?g=t:g=c,r>d?S=s:s<h?S=r:S=d,i.direction===a.Direction.DOWN?g=o:i.direction===a.Direction.UP?g=t:i.direction===a.Direction.RIGHT?S=s:i.direction===a.Direction.LEFT&&(S=r),this._scrollToCell(g,S)},0)}_getFreeze(){var e;const i=(e=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:e.skeleton.getWorksheetConfig();if(i!=null)return i.freeze}_updateSceneSize(i){var h;if(i==null)return;const{unitId:e}=this._context,{skeleton:t}=i,r=(h=this._renderManagerService.getRenderById(e))==null?void 0:h.scene;if(t==null||r==null)return;const{rowTotalHeight:o,columnTotalWidth:s,rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:c}=t;this._context.unit.getActiveSheet()&&(r==null||r.transformByState({width:l+s,height:c+o}))}_getSheetObject(){return Ge(this._context.unit,this._context)}_scrollToSelectionByDirection(i){const e=this._getViewportBounding();if(e==null)return!1;const{startRow:t,startColumn:r,endRow:o,endColumn:s}=e;let l=0,c=0;const{startRow:d,startColumn:u,endRow:h,endColumn:g}=i;d>=t&&(l=h),h<=o&&(l=d),u>=r&&(c=g),g<=s&&(c=u),this._scrollToCell(l,c)}_scrollToSelection(i=!0){var d;const e=this._getSelectionsService().getCurrentLastSelection();if(!e)return;const{startRow:t,startColumn:r,actualRow:o,actualColumn:s}=(d=e.primary)!=null?d:e.range,l=i&&o!=null?o:t,c=i&&s!=null?s:r;this._scrollToCell(l,c)}_getSelectionsService(){return m.getSelectionsService(this._injector)}_getViewportBounding(){var o,s;const i=(o=this._getSheetObject())==null?void 0:o.scene;if(i==null)return;const e=i.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(e==null)return;const t=(s=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:s.skeleton;if(t==null)return;const r=e.calcViewportInfo();return t.getRangeByViewBound(r.viewBound)}_scrollToCell(i,e,t=!1,r=!1){var k,D,H;const{rowHeightAccumulation:o,columnWidthAccumulation:s}=(k=this._sheetSkeletonManagerService.getCurrentSkeleton())!=null?k:{};if(o==null||s==null)return!1;const l=(D=this._getSheetObject())==null?void 0:D.scene;if(l==null)return!1;const c=l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(c==null)return!1;const d=(H=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:H.skeleton;if(d==null)return!1;const u=this._context.unit.getActiveSheet();if(!u)return!1;i=a.Tools.clamp(i,0,o.length-1),e=a.Tools.clamp(e,0,s.length-1);const{startColumn:h,startRow:g,ySplit:S,xSplit:f}=u.getFreeze(),p=this._getViewportBounding();if(p==null)return!1;const{startRow:v,startColumn:C,endRow:I,endColumn:R}=p;let w,M;if(i>=g&&e>=h-S&&(i<=v&&(w=i,t=!0),i>=I)){const W=o[i]-c.height;for(let N=v;N<=i&&(w=N+1,!(o[N]>=W));N++);}if(e>=h&&i>=g-S&&(e<=C&&(M=e,r=!0),e>=R)){const W=s[e]-c.width;for(let N=C;N<=e&&(M=N+1,!(s[N]>=W));N++);}if(w===void 0&&M===void 0)return!1;let{offsetX:y,offsetY:P,sheetViewStartRow:x,sheetViewStartColumn:A}=this._scrollManagerService.getCurrentScrollState()||{};if(w=w?Math.min(w,i):x+S,M=M?Math.min(M,e):A+f,r){y=0,M=e;const W=d.getHiddenColumnsInRange({startColumn:M-f,endColumn:M});M=M-W.length}if(t){P=0,w=i;const W=d.getHiddenRowsInRange({startRow:w-S,endRow:w});w=w-W.length}return this._commandService.syncExecuteCommand(ze.id,{sheetViewStartRow:Math.max(0,w-S),sheetViewStartColumn:Math.max(0,M-f),offsetX:y,offsetY:P})}};exports.SheetsScrollRenderController=Cu([on(1,a.Inject(a.Injector)),on(2,a.Inject(exports.SheetSkeletonManagerService)),on(3,a.IContextService),on(4,a.ICommandService),on(5,T.IRenderManagerService),on(6,a.Inject(exports.SheetScrollManagerService))],exports.SheetsScrollRenderController);const vs={id:"sheet.operation.scroll-to-range",type:a.CommandType.OPERATION,handler:(n,i)=>{if(!i)return!1;const e=n.get(a.IUniverInstanceService);return n.get(T.IRenderManagerService).getRenderById(e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(exports.SheetsScrollRenderController).scrollToRange(i.range,i.forceTop,i.forceLeft)}};class Qa{constructor(){E(this,"_state",null);E(this,"_rect",null);E(this,"_state$",new O.BehaviorSubject(null));E(this,"state$",this._state$.asObservable());E(this,"_rect$",new O.BehaviorSubject(null));E(this,"rect$",this._rect$.asObservable());E(this,"_focus",!1);E(this,"_focus$",new O.BehaviorSubject(this._focus));E(this,"focus$",this._focus$.asObservable())}dispose(){this._state$.complete(),this._state=null,this._rect$.complete(),this._rect=null}setState(i){this._state=i,this._refresh(i)}getRect(){return this._rect}setRect(i){this._rect=i,this._rect$.next(i)}getState(){return this._state}setFocus(i=!1){this._focus=i,this._focus$.next(i)}_refresh(i){this._state$.next(i)}}const mr=a.createIdentifier("univer.sheet-cell-editor-manager.service");var Ve=function(){return Ve=Object.assign||function(n){for(var i,e=1,t=arguments.length;e<t;e++){i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(n[r]=i[r])}return n},Ve.apply(this,arguments)},Iu=function(n,i){var e={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&i.indexOf(t)<0&&(e[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(n);r<t.length;r++)i.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(n,t[r])&&(e[t[r]]=n[t[r]]);return e},Ee=V.forwardRef(function(n,i){var e=n.icon,t=n.id,r=n.className,o=n.extend,s=Iu(n,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),c=V.useRef("_".concat(Eu()));return Ja(e,"".concat(t),{defIds:e.defIds,idSuffix:c.current},Ve({ref:i,className:l},s),o)});function Ja(n,i,e,t,r){return V.createElement(n.tag,Ve(Ve({key:i},bu(n,e,r)),t),(Ru(n,e).children||[]).map(function(o,s){return Ja(o,"".concat(i,"-").concat(n.tag,"-").concat(s),e,void 0,r)}))}function bu(n,i,e){var t=Ve({},n.attrs);e!=null&&e.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=e.colorChannel1),n.tag==="mask"&&t.id&&(t.id=t.id+i.idSuffix),Object.entries(t).forEach(function(o){var s=o[0],l=o[1];s==="mask"&&typeof l=="string"&&(t[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))});var r=i.defIds;return!r||r.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+i.idSuffix),Object.entries(t).forEach(function(o){var s=o[0],l=o[1];typeof l=="string"&&(t[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),t}function Ru(n,i){var e,t=i.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((e=n.children)===null||e===void 0)&&e.length)?Ve(Ve({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?Ve(Ve({},r),{attrs:Ve(Ve({},r.attrs),{id:r.attrs.id+i.idSuffix})}):r})}):n}function Eu(){return Math.random().toString(36).substring(2,8)}Ee.displayName="UniverIcon";var wu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z",fillRule:"evenodd",clipRule:"evenodd"}}]},$a=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"autofill",ref:i,icon:wu}))});$a.displayName="Autofill";var Tu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Zt=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"check-mark-single",ref:i,icon:Tu}))});Zt.displayName="CheckMarkSingle";var yu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},el=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"close-single",ref:i,icon:yu}))});el.displayName="CloseSingle";var Mu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"g",attrs:{fill:"currentColor",clipPath:"url(#convert-single_clip0_911_593)"},children:[{tag:"path",attrs:{d:"M2.44766.848145C1.564.848145.847656 1.56449.847656 2.44814V6.44814C.847656 7.3318 1.564 8.04814 2.44766 8.04814H6.44766C7.33131 8.04814 8.04766 7.3318 8.04766 6.44814V2.44814C8.04766 1.56449 7.33131.848145 6.44766.848145H2.44766zM2.04766 6.44814V5.04824H3.84775V6.84814H2.44766C2.22674 6.84814 2.04766 6.66906 2.04766 6.44814zM2.04766 3.84824H3.84775V2.04814H2.44766C2.22674 2.04814 2.04766 2.22723 2.04766 2.44814V3.84824zM5.04775 6.84814V5.04824H6.84766V6.44814C6.84766 6.66906 6.66857 6.84814 6.44766 6.84814H5.04775zM5.04775 3.84824H6.84766V2.44814C6.84766 2.22723 6.66857 2.04814 6.44766 2.04814H5.04775V3.84824zM9.55215 7.95166C8.66849 7.95166 7.95215 8.668 7.95215 9.55166V13.5517C7.95215 14.4353 8.66849 15.1517 9.55215 15.1517L11.5522 15.1517 13.5521 15.1517C14.4358 15.1517 15.1521 14.4353 15.1521 13.5517L15.1521 11.5518 15.1521 9.55166C15.1521 8.668 14.4358 7.95166 13.5521 7.95166H9.55215zM13.9521 10.9518V9.55166C13.9521 9.33075 13.7731 9.15166 13.5521 9.15166H12.1522V10.9518H13.9521zM10.9522 10.9518V9.15166H9.55215C9.33123 9.15166 9.15215 9.33075 9.15215 9.55166V10.9518H10.9522zM9.15215 12.1518H10.9522V13.9517H9.55215C9.33123 13.9517 9.15215 13.7726 9.15215 13.5517V12.1518zM12.1522 12.1518H13.9521V13.5517C13.9521 13.7726 13.7731 13.9517 13.5521 13.9517H12.1522V12.1518z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{d:"M9.62158 2.44912C9.62158 2.11775 9.89021 1.84912 10.2216 1.84912H12.7516C13.6352 1.84912 14.3516 2.56547 14.3516 3.44912V5.9791C14.3516 6.31047 14.0829 6.5791 13.7516 6.5791 13.4202 6.5791 13.1516 6.31047 13.1516 5.9791V3.44912C13.1516 3.22821 12.9725 3.04912 12.7516 3.04912H10.2216C9.89021 3.04912 9.62158 2.78049 9.62158 2.44912zM5.77871 14.1507C6.11008 14.1507 6.37871 13.8821 6.37871 13.5507 6.37871 13.2193 6.11008 12.9507 5.77871 12.9507L3.24873 12.9507C3.02782 12.9507 2.84873 12.7716 2.84873 12.5507L2.84873 10.0207C2.84873 9.68933 2.5801 9.4207 2.24873 9.4207 1.91736 9.4207 1.64873 9.68933 1.64873 10.0207L1.64873 12.5507C1.64873 13.4343 2.36507 14.1507 3.24873 14.1507H5.77871z"}}]},{tag:"defs",attrs:{},children:[{tag:"clipPath",attrs:{id:"convert-single_clip0_911_593"},children:[{tag:"path",attrs:{fill:"#fff",d:"M0 0H16V16H0z"}}]}]}],defIds:["convert-single_clip0_911_593"]},tl=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"convert-single",ref:i,icon:Mu}))});tl.displayName="ConvertSingle";var Pu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ni=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"delete-single",ref:i,icon:Pu}))});Ni.displayName="DeleteSingle";var Ou={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.85869 12.9216C8.38445 13.4708 7.61555 13.4708 7.14131 12.9216L0.358114 5.06726C-0.406895 4.18144 0.134916 2.66683 1.2168 2.66683L14.7832 2.66683C15.8651 2.66683 16.4069 4.18144 15.6419 5.06726L8.85869 12.9216Z"}}]},Lo=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"dropdown-single",ref:i,icon:Ou}))});Lo.displayName="DropdownSingle";var xu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M15 8C15 11.866 11.866 15 8 15C4.13401 15 1 11.866 1 8C1 4.13401 4.13401 1 8 1C11.866 1 15 4.13401 15 8ZM10.3097 5.69014C10.544 5.92445 10.544 6.30435 10.3097 6.53867L8.84843 7.9999L10.3099 9.46137C10.5442 9.69569 10.5442 10.0756 10.3099 10.3099C10.0756 10.5442 9.69569 10.5442 9.46137 10.3099L7.9999 8.84843L6.53842 10.3099C6.30411 10.5442 5.92421 10.5442 5.6899 10.3099C5.45558 10.0756 5.45558 9.69569 5.6899 9.46137L7.15137 7.9999L5.69014 6.53867C5.45583 6.30435 5.45583 5.92445 5.69014 5.69014C5.92445 5.45583 6.30435 5.45583 6.53867 5.69014L7.9999 7.15137L9.46113 5.69014C9.69544 5.45583 10.0753 5.45583 10.3097 5.69014Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Cs=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"error-single",ref:i,icon:xu}))});Cs.displayName="ErrorSingle";var Au={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.28096 4.6541C1.57489 4.50109 1.93721 4.61533 2.09022 4.90926C2.27315 5.26067 2.55999 5.60455 2.94829 5.92278C4.04628 6.82266 5.87505 7.44865 7.99828 7.44865C10.1215 7.44865 11.9503 6.82267 13.0482 5.92279C13.4366 5.60455 13.7234 5.26067 13.9063 4.90927C14.0594 4.61533 14.4217 4.50109 14.7156 4.65409C15.0095 4.8071 15.1238 5.16941 14.9708 5.46334C14.6995 5.98445 14.2981 6.44997 13.8089 6.8509C13.7298 6.91575 13.6481 6.97914 13.564 7.041L15.2245 8.70153C15.4588 8.93585 15.4588 9.31575 15.2245 9.55006C14.9902 9.78438 14.6103 9.78438 14.376 9.55006L12.5041 7.67822C11.8977 7.97568 11.2181 8.21208 10.4884 8.37706L11.0996 10.6581C11.1853 10.9782 10.9954 11.3072 10.6753 11.393C10.3552 11.4787 10.0262 11.2888 9.94045 10.9687L9.29949 8.57652C8.8758 8.62404 8.44081 8.64865 7.99828 8.64865C7.55276 8.64865 7.11487 8.62371 6.68846 8.57555L6.04723 10.9687C5.96147 11.2888 5.63247 11.4788 5.31239 11.393C4.99231 11.3073 4.80236 10.9783 4.88812 10.6582L5.49983 8.37516C4.7743 8.2105 4.09843 7.9752 3.49498 7.67947L1.62436 9.55009C1.39005 9.78441 1.01015 9.78441 0.775835 9.5501C0.54152 9.31578 0.541518 8.93588 0.775832 8.70157L2.43478 7.04261C2.34987 6.98024 2.26746 6.91632 2.18764 6.8509C1.69842 6.44997 1.29706 5.98445 1.0258 5.46335C0.872791 5.16942 0.987031 4.80711 1.28096 4.6541Z"}}]},nl=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"eyelash-single",ref:i,icon:Au}))});nl.displayName="EyelashSingle";var ku={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6.06409 5.53454C5.93592 5.53454 5.84083 5.41567 5.86897 5.29063L5.95442 4.9109C6.05444 4.48178 6.23806 4.11547 6.51182 3.81952 6.81082 3.49628 7.25398 3.35405 7.79738 3.35405 7.99847 3.35405 8.21359 3.37775 8.44188 3.42245 8.46089 3.42617 8.47974 3.43006 8.49846 3.4341 8.7099 3.4798 8.93698 3.38478 9.02031 3.18514L9.24767 2.6404C9.33457 2.43219 9.23178 2.19404 9.01582 2.12874 8.98358 2.11899 8.95028 2.10912 8.91591 2.09914 8.62745 2.01631 8.28392 1.97217 7.88074 1.97217 6.82015 1.97217 6.02714 2.23936 5.4746 2.7444 4.90987 3.26069 4.50889 3.99917 4.28413 4.9762L2.83703 11.1909C2.76126 11.5286 2.666 11.8917 2.54844 12.2812 2.42975 12.6734 2.2873 13.0595 2.12221 13.4373 1.95577 13.8159 1.76813 14.1762 1.55955 14.5171 1.49345 14.6251 1.42515 14.7282 1.35467 14.8263 1.26508 14.9509 1.3347 15.133 1.48655 15.1554 2.13635 15.2509 2.8179 15.0763 3.18197 14.5296 3.32661 14.3124 3.46779 14.0646 3.60509 13.7851 3.96635 13.0497 4.30522 12.0103 4.61867 10.6574L5.469 7.01534C5.49013 6.92483 5.57082 6.86081 5.66376 6.86081H7.62478C7.8097 6.86081 7.97051 6.73405 8.01371 6.55425L8.14014 6.02798C8.20057 5.77642 8.00992 5.53454 7.75121 5.53454H6.06409zM14.3211 5.72037L12.5124 7.96963 11.4089 5.77754C11.3422 5.63012 11.1954 5.5354 11.0336 5.5354H10.3129C10.0085 5.5354 9.80921 5.85428 9.9427 6.1279L11.4089 9.05502 8.79783 12.1493C8.56587 12.4158 8.75519 12.8315 9.10855 12.8315H9.68607C9.80672 12.8315 9.9605 12.7822 10.0388 12.6904L12.1108 10.2648 13.1176 12.561C13.1786 12.7231 13.333 12.8315 13.5061 12.8315H14.3C14.5831 12.8315 14.7417 12.6175 14.6426 12.3524L13.1728 9.28628C13.1728 9.28628 15.4009 6.45542 15.6013 6.17892 15.7966 5.90929 15.6023 5.5354 15.2693 5.5354H14.6661C14.5275 5.5354 14.4333 5.58887 14.3211 5.72037z"}}]},rl=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"fx-single",ref:i,icon:ku}))});rl.displayName="FxSingle";var Du={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M6.4833 1.65005C6.4833 1.31868 6.21467 1.05005 5.8833 1.05005C5.55193 1.05005 5.2833 1.31868 5.2833 1.65005V5.28345H1.65029C1.31892 5.28345 1.05029 5.55208 1.05029 5.88345C1.05029 6.21482 1.31892 6.48345 1.65029 6.48345H5.2833V9.51684H1.65029C1.31892 9.51684 1.05029 9.78547 1.05029 10.1168C1.05029 10.4482 1.31892 10.7168 1.65029 10.7168H5.2833V14.35C5.2833 14.6814 5.55193 14.95 5.8833 14.95C6.21467 14.95 6.4833 14.6814 6.4833 14.35V10.7168H9.5167V14.35C9.5167 14.6814 9.78533 14.95 10.1167 14.95C10.4481 14.95 10.7167 14.6814 10.7167 14.35V10.7168H14.3503C14.6817 10.7168 14.9503 10.4482 14.9503 10.1168C14.9503 9.78547 14.6817 9.51685 14.3503 9.51685H10.7167V6.48345H14.3503C14.6817 6.48345 14.9503 6.21482 14.9503 5.88345C14.9503 5.55208 14.6817 5.28345 14.3503 5.28345H10.7167V1.65005C10.7167 1.31868 10.4481 1.05005 10.1167 1.05005C9.78533 1.05005 9.5167 1.31868 9.5167 1.65005V5.28345L6.4833 5.28345V1.65005ZM6.4833 6.48345V9.51684L9.5167 9.51685V6.48345L6.4833 6.48345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.0498 3.65005C1.0498 2.21411 2.21386 1.05005 3.6498 1.05005H12.3498C13.7857 1.05005 14.9498 2.21411 14.9498 3.65005V12.3501C14.9498 13.786 13.7857 14.95 12.3498 14.95H3.6498C2.21386 14.95 1.0498 13.786 1.0498 12.35V3.65005ZM3.6498 2.25005C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H3.6498Z",fillRule:"evenodd",clipRule:"evenodd"}}]},il=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"hide-gridlines",ref:i,icon:Du}))});il.displayName="HideGridlines";var Nu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},_s=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"increase-single",ref:i,icon:Nu}))});_s.displayName="IncreaseSingle";var Hu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.62402 7.72905C2.58427 7.72905 2.55205 7.76127 2.55205 7.80102V13.6782C2.55205 13.7179 2.58427 13.7502 2.62402 13.7502H13.3755C13.4152 13.7502 13.4474 13.7179 13.4474 13.6782V7.80102C13.4474 7.76127 13.4152 7.72905 13.3755 7.72905H2.62402ZM1.35205 7.80102C1.35205 7.09853 1.92153 6.52905 2.62402 6.52905H13.3755C14.0779 6.52905 14.6474 7.09853 14.6474 7.80102V13.6782C14.6474 14.3807 14.0779 14.9502 13.3755 14.9502H2.62402C1.92153 14.9502 1.35205 14.3807 1.35205 13.6782V7.80102Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M8 2.25005C6.69847 2.25003 5.64336 3.30513 5.64336 4.60666V7.12895C5.64336 7.46032 5.37473 7.72895 5.04336 7.72895 4.71199 7.72895 4.44336 7.46032 4.44336 7.12895V4.60666C4.44336 2.64239 6.04451 1.05565 8.00879 1.05566M8 2.25005L8.00879 1.05566 8 2.25005zM8.00879 1.05566L8 2.25005C9.30154 2.25003 10.3567 3.30513 10.3567 4.60666V7.12895C10.3567 7.46032 10.6253 7.72895 10.9567 7.72895 11.288 7.72895 11.5567 7.46032 11.5567 7.12895V4.60666C11.5567 2.64239 9.97306 1.05565 8.00879 1.05566zM8.00039 9.4668C8.33176 9.4668 8.60039 9.73543 8.60039 10.0668V12.0827C8.60039 12.4141 8.33176 12.6827 8.00039 12.6827 7.66902 12.6827 7.40039 12.4141 7.40039 12.0827V10.0668C7.40039 9.73543 7.66902 9.4668 8.00039 9.4668z",fillRule:"evenodd",clipRule:"evenodd"}}]},Is=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"lock-single",ref:i,icon:Hu}))});Is.displayName="LockSingle";var Vu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},En=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"more-down-single",ref:i,icon:Vu}))});En.displayName="MoreDownSingle";var Wu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.90913 3.57564C6.14345 3.34132 6.52335 3.34132 6.75766 3.57564L10.7577 7.57564C10.992 7.80995 10.992 8.18985 10.7577 8.42417L6.75766 12.4242C6.52335 12.6585 6.14345 12.6585 5.90913 12.4242C5.67482 12.1899 5.67482 11.81 5.90913 11.5756L9.48487 7.9999L5.90913 4.42417C5.67482 4.18985 5.67482 3.80995 5.90913 3.57564Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Bo=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"more-single",ref:i,icon:Wu}))});Bo.displayName="MoreSingle";var Uu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.01281 1.36643C8.79386 0.585377 10.0602 0.585378 10.8412 1.36643L12.9223 3.44752C13.7034 4.22857 13.7034 5.4949 12.9223 6.27595L9.36445 9.83383C8.5834 10.6149 7.31707 10.6149 6.53602 9.83383L4.45493 7.75273C3.67388 6.97168 3.67388 5.70535 4.45493 4.9243L8.01281 1.36643ZM9.9927 2.21495C9.68028 1.90253 9.17375 1.90253 8.86133 2.21495L5.30346 5.77283L5.29671 5.77966L10.839 6.66224L12.0738 5.42742C12.3862 5.115 12.3862 4.60847 12.0738 4.29605L9.9927 2.21495Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.5179 9.48875C14.5179 9.99175 14.1101 10.3995 13.607 10.3995C13.1041 10.3995 12.6963 9.99175 12.6963 9.48875C12.6963 9.1773 13.0455 8.59966 13.3114 8.20487C13.4549 7.99177 13.7591 7.99177 13.9027 8.20486C14.1687 8.59965 14.5179 9.1773 14.5179 9.48875Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}}]},ol=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"paint-bucket",ref:i,icon:Uu}))});ol.displayName="PaintBucket";var Lu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1138",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_1138)"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M7.74692 9.12463C7.74692 9.46018 8.01893 9.73219 8.35448 9.73219H11.4933C11.8288 9.73219 12.1009 9.46018 12.1009 9.12463 12.1009 8.78909 11.8288 8.51707 11.4933 8.51707H8.35448C8.01893 8.51707 7.74692 8.78909 7.74692 9.12463zM10.8636 10.8523C10.8636 11.1879 10.5915 11.4599 10.256 11.4599H8.35448C8.01893 11.4599 7.74692 11.1879 7.74692 10.8523 7.74692 10.5168 8.01893 10.2447 8.35448 10.2447H10.256C10.5915 10.2447 10.8636 10.5168 10.8636 10.8523z"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.4791 1.98268C5.47913 1.71529 5.87912 1.49854 6.37252 1.49854C6.86593 1.49854 7.26592 1.71529 7.26595 1.98268H7.62187C8.22277 1.98268 8.72459 2.39534 8.84412 2.9452H9.39563C10.0856 2.9452 10.6449 3.48923 10.6449 4.16032V6.00569H12.1261C13.161 6.00569 14 6.82174 14 7.82838V11.334C14 11.8174 13.8025 12.281 13.4511 12.6228L12.0693 13.9647C11.7179 14.3065 11.2412 14.4985 10.7442 14.4985H7.91116C7.05024 14.4985 6.32492 14.0431 6.10535 13.2737H3.34925C2.6593 13.2737 2.09998 12.7297 2.09998 12.0586V4.16032C2.09998 3.48923 2.6593 2.9452 3.34925 2.9452H3.90107C4.0206 2.39534 4.52241 1.98268 5.12332 1.98268H5.4791ZM3.97249 4.16032H3.24925L3.24925 12.0586H6.03725V7.82838C6.03725 6.82174 6.87623 6.00569 7.91116 6.00569H9.49563V4.16032H8.7727C8.58289 4.59611 8.13909 4.90183 7.62187 4.90183H5.12332C4.6061 4.90183 4.1623 4.59611 3.97249 4.16032ZM5.12332 2.89403H7.62187C7.79436 2.89403 7.93419 3.03003 7.93419 3.19781V3.68671C7.93419 3.85448 7.79436 3.99049 7.62187 3.99049H5.12332C4.95083 3.99049 4.811 3.85448 4.811 3.68671V3.19781C4.811 3.03003 4.95083 2.89403 5.12332 2.89403ZM7.91116 7.11157C7.56618 7.11157 7.28652 7.38359 7.28652 7.71913V12.7851C7.28652 13.1206 7.56618 13.3927 7.91116 13.3927H10.7442C10.8401 13.3927 10.9337 13.3712 11.0182 13.3311C11.1373 13.2746 11.1859 13.1423 11.1859 13.0134V12.0066C11.1859 11.8724 11.2978 11.7636 11.4358 11.7636H12.4709C12.6034 11.7636 12.7394 11.7163 12.7975 11.6004C12.8388 11.5182 12.8608 11.4272 12.8608 11.334V7.71913C12.8608 7.38359 12.5811 7.11157 12.2362 7.11157H7.91116Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},sl=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"paste-special",ref:i,icon:Lu}))});sl.displayName="PasteSpecial";var Bu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.785 6.77762C5.78908 6.7777 5.79316 6.77774 5.79725 6.77774C5.80134 6.77774 5.80543 6.7777 5.8095 6.77762H10.0184C10.0225 6.7777 10.0266 6.77774 10.0307 6.77774C10.0347 6.77774 10.0388 6.7777 10.0429 6.77762H13.6638V7.63727C13.6638 7.96864 13.9324 8.23727 14.2638 8.23727C14.5951 8.23727 14.8638 7.96864 14.8638 7.63727V3.9999C14.8638 2.56395 13.6997 1.39989 12.2637 1.3999L3.56389 1.39999C2.12797 1.40001 0.96393 2.56405 0.96392 3.99998L0.963867 11.6666C0.963857 13.1025 2.12792 14.2666 3.56387 14.2666H8.0542C8.38557 14.2666 8.6542 13.9979 8.6542 13.6666C8.6542 13.3352 8.38557 13.0666 8.0542 13.0666H3.56387C2.79067 13.0666 2.16386 12.4398 2.16387 11.6666L2.1639 6.77762H5.785ZM6.39725 2.59996L9.43065 2.59993V5.57762H6.39725V2.59996ZM5.19725 5.57762V2.59998L3.56391 2.59999C2.79072 2.6 2.16393 3.22679 2.16392 3.99998L2.16391 5.57762H5.19725ZM13.6638 5.57762V3.9999C13.6638 3.2267 13.037 2.59989 12.2638 2.5999L10.6307 2.59992V5.57762H13.6638Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.1223 10.2333V10.7496C14.7087 10.9869 15.1223 11.5618 15.1223 12.2333V12.8999C15.1223 13.7836 14.406 14.4999 13.5223 14.4999H11.5223C10.6387 14.4999 9.92235 13.7836 9.92235 12.8999V12.2333C9.92235 11.5618 10.336 10.9869 10.9223 10.7496V10.2333C10.9223 9.34961 11.6387 8.63328 12.5223 8.63328C13.406 8.63328 14.1223 9.34961 14.1223 10.2333ZM11.1223 12.2333C11.1223 12.0124 11.3014 11.8333 11.5223 11.8333H13.5223C13.7433 11.8333 13.9223 12.0124 13.9223 12.2333V12.8999C13.9223 13.1209 13.7433 13.2999 13.5223 13.2999H11.5223C11.3014 13.2999 11.1223 13.1209 11.1223 12.8999V12.2333ZM12.9223 10.2333V10.6333H12.1223V10.2333C12.1223 10.0124 12.3014 9.83328 12.5223 9.83328C12.7433 9.83328 12.9223 10.0124 12.9223 10.2333Z",fillRule:"evenodd",clipRule:"evenodd"}}]},al=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"protect-single",ref:i,icon:Bu}))});al.displayName="ProtectSingle";var Fu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M15 8C15 11.866 11.866 15 8 15C4.13401 15 1 11.866 1 8C1 4.13401 4.13401 1 8 1C11.866 1 15 4.13401 15 8ZM8.00008 12.3671C8.46031 12.3671 8.83342 11.994 8.83342 11.5338C8.83342 11.0735 8.46031 10.7004 8.00008 10.7004C7.53985 10.7004 7.16675 11.0735 7.16675 11.5338C7.16675 11.994 7.53985 12.3671 8.00008 12.3671ZM8.5999 4.4335C8.5999 4.10213 8.33127 3.8335 7.9999 3.8335C7.66853 3.8335 7.3999 4.10213 7.3999 4.4335V9.36683C7.3999 9.6982 7.66853 9.96683 7.9999 9.96683C8.33127 9.96683 8.5999 9.6982 8.5999 9.36683V4.4335Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Fo=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"warning-single",ref:i,icon:Fu}))});Fo.displayName="WarningSingle";var ju={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},bs=V.forwardRef(function(n,i){return V.createElement(Ee,Object.assign({},n,{id:"write-single",ref:i,icon:ju}))});bs.displayName="WriteSingle";const zu=()=>{const[,n]=V.useState({});return V.useCallback(()=>n(i=>!i),[])},Xu=()=>{const n=_.useDependency(a.ICommandService),i=_.useDependency(a.IUniverInstanceService),e=_.useDependency(T.IRenderManagerService),t=_.useDependency(wt),r=_.useDependency(a.LocaleService),[o,s]=V.useState([]),[l,c]=V.useState(!1),[d,u]=V.useState({row:-1,col:-1}),[h,g]=V.useState(le.SERIES),[S,f]=V.useState(!1),p=gt(),{sheetSkeletonManagerService:v,selectionRenderService:C}=V.useMemo(()=>{if(p){const z=e.getRenderById(p.getUnitId());return{sheetSkeletonManagerService:z==null?void 0:z.with(exports.SheetSkeletonManagerService),selectionRenderService:z==null?void 0:z.with(ve)}}return{sheetSkeletonManagerService:null,selectionRenderService:null}},[p,e]),I=()=>{f(!0)},R=()=>{f(!1)},w=zu();if(V.useEffect(()=>n.onCommandExecuted((K,ne)=>{K.id===je.id&&w()}).dispose,[w,n]),V.useEffect(()=>{const z=v&&a.toDisposable(v.currentSkeleton$.subscribe(K=>{K&&w()}));return z==null?void 0:z.dispose},[v,w]),V.useEffect(()=>a.toDisposable(t.menu$.subscribe(K=>{s(K.map(ne=>({...ne,index:K.indexOf(ne)})))})).dispose,[t]),V.useEffect(()=>a.toDisposable(t.showMenu$.subscribe(K=>{const{source:ne,target:Q}=t.autoFillLocation||{source:null,target:null};if(K&&ne&&Q){const se=Math.max(ne.rows[ne.rows.length-1],Q.rows[Q.rows.length-1]),ce=Math.max(ne.cols[ne.cols.length-1],Q.cols[Q.cols.length-1]);u({row:se,col:ce})}else u({row:-1,col:-1})})).dispose,[t]),V.useEffect(()=>a.toDisposable(t.applyType$.subscribe(K=>{g(K)})).dispose,[t]),V.useEffect(()=>{function z(){c(!1)}return document.addEventListener("wheel",z),()=>{document.removeEventListener("wheel",z)}},[l]),d.col<0||d.row<0)return null;const M=Ge(i,e);if(!M||!C)return null;const{scene:y}=M,P=v==null?void 0:v.getCurrentSkeleton(),x=C.getViewPort(),A=y==null?void 0:y.scaleX,k=y==null?void 0:y.scaleY,D=y==null?void 0:y.getViewportScrollXY(x);if(!A||!y||!A||!k||!D)return null;const H=(P==null?void 0:P.getNoMergeCellWithCoordByIndex(d.row,d.col).endX)||0,W=(P==null?void 0:P.getNoMergeCellWithCoordByIndex(d.row,d.col).endY)||0,N=T.convertTransformToOffsetX(H,A,D),U=T.convertTransformToOffsetY(W,k,D);if(N==null||U==null)return null;const L=z=>{c(z)},F=z=>{n.executeCommand(ur.id,{type:z.value}),c(!1)},B=l||S,j=o.filter(z=>!z.disable);return b.jsx("div",{className:"univer-absolute univer-inset-0 univer-z-10 univer-size-0",children:b.jsx("div",{style:{left:`${N+2}px`,top:`${U+2}px`,position:"absolute"},onMouseEnter:I,onMouseLeave:R,children:b.jsx(Y.DropdownMenu,{align:"start",items:j.map(z=>({type:"radio",value:h,options:[{label:r.t(z.label),value:z.value}],onSelect:()=>F(z)})),open:l,onOpenChange:L,children:b.jsxs("div",{className:Y.clsx(`
2
2
  univer-flex univer-items-center univer-gap-2 univer-rounded univer-border univer-border-solid
3
3
  univer-border-gray-200 univer-p-1
4
4
  hover:univer-bg-gray-100
@@ -55,7 +55,7 @@
55
55
  `,g={...u,body:{dataStream:h,textRuns:c.textRuns,paragraphs:Gi(h)}};d==null||d.reset(g),o=d==null?void 0:d.getSnapshot(),r=c.dataStream}else r=Bm(i.innerHTML.replace(/[\r\n]/g,""));return{cellText:r,cellRichStyle:o}}_generateDocumentDataModelSnapshot(i){var l;const e=this._getCurrentSkeleton();if(e==null)return null;const{skeleton:t}=e,r=(l=t.getBlankCellDocumentModel())==null?void 0:l.documentModel,s={...r==null?void 0:r.getSnapshot(),...i};return r==null||r.reset(s),r==null?void 0:r.getSnapshot()}process(i,e,t,r){var o,s,l;for(const c of e)if(c.nodeName.toLowerCase()==="table")r.push({index:((o=t==null?void 0:t.paragraphs)==null?void 0:o.length)||0});else if(c.nodeType===Node.TEXT_NODE){if(((s=c.nodeValue)==null?void 0:s.trim())==="")continue;const d=(l=c.nodeValue)==null?void 0:l.replace(/[\r\n]/g,"");let u;i&&this._styleCache.has(i)&&(u=this._styleCache.get(i));const h={dataStream:"",textRuns:[]};t.dataStream+=d,h.dataStream+=d,u&&Object.getOwnPropertyNames(u).length&&(t.textRuns.push({st:t.dataStream.length-d.length,ed:t.dataStream.length,ts:u}),h.textRuns.push({st:t.dataStream.length-d.length,ed:t.dataStream.length,ts:u}))}else{if(a.skipParseTagNames.includes(c.nodeName.toLowerCase()))continue;if(c.nodeName.toLowerCase()==="br")t.paragraphs||(t.paragraphs=[]),t.paragraphs.push({startIndex:t.dataStream.length}),t.dataStream+="\r";else if(c.nodeType===Node.ELEMENT_NODE){if(c.nodeName==="STYLE")continue;const d=c,u=this._processBeforeLink(d,{body:t}),h=i?this._styleCache.get(i):{},g=this._styleRules.find(({filter:v})=>ua(c,v)),S=g?g.getStyle(c):ii(c);this._styleCache.set(c,{...h,...S});const{childNodes:f}=c;this.process(c,f,t,r);const p=this._afterProcessRules.find(({filter:v})=>ua(c,v));p&&p.handler(t,c),this._processAfterLink(d,{body:t},u)}}}_processBeforeLink(i,e){return e.body.dataStream.length}_processAfterLink(i,e,t){var s,l;const r=e.body,o=i;o.tagName.toUpperCase()==="A"&&(r.customRanges=(s=r.customRanges)!=null?s:[],r.customRanges.push({startIndex:t,endIndex:r.dataStream.length-1,rangeId:(l=o.dataset.rangeid)!=null?l:a.generateRandomId(),rangeType:a.CustomRangeType.HYPERLINK,properties:{url:o.href}}))}dispose(){this._dom=null,this._styleCache.clear(),this._styleMap.clear()}};E(yi,"_pluginList",[]);let wn=yi;function Um(n){const i=/<tr([\s\S]*?)>([\s\S]*?)<\/tr>/gi,e=n.matchAll(i);if(!e)return{rowProperties:[],rowCount:0};const r=Array.from(e).map(o=>Al(o[1])).map(o=>{if(!o.height){const s=o.style,l=s&&s.match(/height\s*:\s*(\d+(\.\d+)?)px/);o.height=`${l?Number.parseInt(l[1],10):a.DEFAULT_WORKSHEET_ROW_HEIGHT}`}return o});return{rowProperties:r,rowCount:r.length}}function ha(n){const i={};return n.split(";").forEach(t=>{const[r,o]=t.split(":");i[r]=o}),i}function Al(n){if(!n)return{};const i={},e=/([\w-]+)\s*=\s*(?:(['"])([^'"]*)\2|(\S+))/g;let t;for(;(t=e.exec(n))!==null;){const[,r,,o,s]=t,l=o!==void 0?o:s;i[r]=l}return i}function Lm(n){const i=/<colgroup([\s\S]*?)>(.*?)<\/colgroup>/,e=n.match(i),t=/<col([\s\S]*?)>/g;let r;if(e!=null&&e[2]?r=e[2].matchAll(t):r=n.matchAll(t),!r)return null;const o=Array.from(r).map(l=>Al(l[1])),s=[];return o.forEach(l=>{const c=Number(l.span);if(c)for(let d=0;d<c;d++){const u={...l};delete u.span,s.push(u)}else s.push(l)}),s}function Bm(n){const i={"&lt;":"<","&gt;":">","&amp;":"&","&quot;":'"',"&#39;":"'","&nbsp;":" "};return n.replace(/&lt;|&gt;|&amp;|&quot;|&#39;|&nbsp;|<br>/g,e=>i[e])}function ma(n,i){if(!n||!i)return null;const e=new RegExp(`(${i}\\s*:\\s*[^;]+);`,"i"),t=n.match(e);return t?t[1]:null}function Fm(n,i,e,t){const{rowSpan:r,colSpan:o,rowIndex:s,colSetValueIndex:l}=t;for(let c=s;c<s+r;c++)for(let d=l;d<l+o;d++)c===s&&d===l?n.setValue(c,d,{...e,style:i}):n.setValue(c,d,{style:i})}const jm={name:"univer-doc-paste-plugin-lark",checkPasteType(n){return/lark-record-clipboard/i.test(n)},stylesRules:[{filter:["s"],getStyle(n){const i=ii(n);return{st:{s:a.BooleanNumber.TRUE},...i}}}],afterProcessRules:[{filter(n){return n.tagName==="DIV"&&/ace-line/i.test(n.className)},handler(n){n.paragraphs==null&&(n.paragraphs=[]),n.paragraphs.push({startIndex:n.dataStream.length}),n.dataStream+="\r"}}]},zm={name:"univer-doc-paste-plugin-univer",checkPasteType(n){return/UniverNormal/i.test(n)},stylesRules:[],afterProcessRules:[{filter(n){return n.tagName==="P"&&/UniverNormal/i.test(n.className)},handler(n,i){n.paragraphs==null&&(n.paragraphs=[]);const e={startIndex:n.dataStream.length},t=xl(i);t&&(e.paragraphStyle=t),n.paragraphs.push(e),n.dataStream+="\r"}}]},Xm={name:"univer-doc-paste-plugin-word",checkPasteType(n){return/word|mso/i.test(n)},stylesRules:[{filter:["b"],getStyle(n){const i=ii(n);return{bl:a.BooleanNumber.TRUE,...i}}}],afterProcessRules:[{filter(n){return n.tagName==="P"&&/mso/i.test(n.className)},handler(n,i){n.paragraphs==null&&(n.paragraphs=[]);const e={startIndex:n.dataStream.length},t=xl(i);t&&(e.paragraphStyle=t),n.paragraphs.push(e),n.dataStream+="\r"}}]};var ct=(n=>(n.COPY="COPY",n.CUT="CUT",n))(ct||{});function Ym(n,i,e,t,r){const o=e.map(d=>{var u;return(u=d.onCopyRow)==null?void 0:u.call(d,n)}).filter(d=>!!d),s=ws(o),l=Ts(s),c=i.map(d=>{if(!r.has(`${n}-${d}`)){const u=t.getValue(n,d);if(u!=null&&u.rowSpan&&(u!=null&&u.colSpan))for(let h=n;h<n+u.rowSpan;h++)for(let g=d;g<d+u.colSpan;g++)r.add(`${h}-${g}`);return Gm(n,d,e,t)}return null}).filter(d=>!!d).join("");return`<tr${l}>${c}</tr>`}function Gm(n,i,e,t){const r=t.getValue(n,i),o=e.map(d=>{var u;return(u=d.onCopyCellStyle)==null?void 0:u.call(d,n,i,r==null?void 0:r.rowSpan,r==null?void 0:r.colSpan)}).filter(d=>!!d),s=ws(o),l=Ts(s),c=e.reduce((d,u)=>{var h;return d||((h=u.onCopyCellContent)==null?void 0:h.call(u,n,i))||""},"");return`<td${l}>${c}</td>`}function Zm(n,i){return`<colgroup>${n.map(t=>{const r=i.map(l=>{var c;return(c=l.onCopyColumn)==null?void 0:c.call(l,t)}).filter(l=>!!l),o=ws(r);return`<col ${Ts(o)} />`}).join("")}</colgroup>`}function ws(n){return n.reduce((i,e)=>(Object.keys(e).forEach(r=>{i[r]?i[r]+=`;${e[r]}`:i[r]=e[r]}),i),{})}function Ts(n){return Object.keys(n).reduce((i,e)=>`${i} ${e}="${n[e]}"`,"")}class Km{convert(i,e,t){const{cols:r,rows:o}=e;if(!r.length)return"";const s=Zm(r,t),l=[],c=new Set;return o.forEach(u=>{l.push(Ym(u,r,t,i,c))}),`<google-sheets-html-origin><table xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none">${s}
56
56
  <tbody>${l.join("")}</tbody></table>`}}const qm=(n,i,e=!1)=>{const t=h=>h.endRow-h.startRow+1,r=h=>h.endColumn-h.startColumn+1,o=t(i)%t(n),s=r(i)%r(n),l={startRow:0,endRow:t(n)-1,startColumn:0,endColumn:r(n)-1},c=Math.floor(t(i)/t(n)),d=Math.floor(r(i)/r(n)),u=[];if(!o&&!s)for(let h=1;h<=c;h++)for(let g=1;g<=d;g++){const S=t(n)*(h-1),f=r(n)*(g-1),p={startRow:S+i.startRow,endRow:S+i.startRow,startColumn:f+i.startColumn,endColumn:f+i.startColumn};u.push({repeatRelativeRange:l,startRange:p})}else if(!o&&s&&!e)for(let h=1;h<=c;h++){const g=t(n)*(h-1),S=0,f={startRow:g+i.startRow,endRow:g+i.startRow,startColumn:S+i.startColumn,endColumn:S+i.startColumn};u.push({repeatRelativeRange:l,startRange:f})}else if(o&&!s&&!e)for(let h=1;h<=d;h++){const S=r(n)*(h-1),f={startRow:0+i.startRow,endRow:0+i.startRow,startColumn:S+i.startColumn,endColumn:S+i.startColumn};u.push({repeatRelativeRange:l,startRange:f})}else{const h={startRow:i.startRow,endRow:i.startRow,startColumn:i.startColumn,endColumn:i.startColumn};u.push({startRange:h,repeatRelativeRange:l})}return u};function ga(n){return n?[/<td[^>]*class=".*?xl.*?"[^>]*>/i,/xmlns:x="urn:schemas-microsoft-com:office:excel"/i,/ProgId="Excel.Sheet"/i,/xmlns:o="urn:schemas-microsoft-com:office:office"/i,/@mso-|mso-excel/i,/<x:ExcelWorkbook>/i].some(e=>e.test(n)):!1}function Qm(n){if(!n)return!1;const i=/<img[^>]*src\s*=\s*["']data:image\/[^;]+;base64,[^"']*["'][^>]*>/i;return(n.match(i)||[]).length>0}function Jm(...n){if(n.length===1)return n[0];const i=new a.ObjectMatrix;return n.forEach(e=>{e&&new a.ObjectMatrix(e).forValue((r,o,s)=>{i.setValue(r,o,{...i.getValue(r,o),...s})})}),i.getMatrix()}function $m(n,i){return n.id===i.id&&n.params.unitId===i.params.unitId&&n.params.subUnitId===i.params.subUnitId}function Xo(n){const i=[];for(let e=0;e<n.length;){let t=1;if(n[e].id===m.SetRangeValuesMutation.id){const r=n[e],o=[r];for(;e+t<n.length&&$m(r,n[e+t]);)o.push(n[e+t]),t+=1;const s=Jm(...o.map(l=>l.params.cellValue||{}));i.push({...r,params:{...r.params,cellValue:s}})}else i.push(n[e]);e+=t}return i}function Zi(n,i){const{startRow:e,endRow:t,startColumn:r,endColumn:o}=n;for(let s=e;s<=t;s++)for(let l=r;l<=o;l++)if(i.rows.includes(s)&&i.cols.includes(l))return!0}function Sa(n,i){const{startRow:e,endRow:t,startColumn:r,endColumn:o}=i;for(let s=e;s<=t;s++)if(!n.rows.includes(s))return!1;for(let s=r;s<=o;s++)if(!n.cols.includes(s))return!1;return!0}function eg(n){const i=n.trim().split(`
57
57
  `);let e="<table>";return i.forEach(t=>{const r=t.split(" ");e+="<tr>",r.forEach(o=>{e+=`<td>${o}</td>`}),e+="</tr>"}),e+="</table>",e}var tg=Object.getOwnPropertyDescriptor,ng=(n,i,e,t)=>{for(var r=t>1?void 0:t?tg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Oe=(n,i)=>(e,t)=>i(e,t,n);const ge={DEFAULT_COPY:"default-copy",DEFAULT_PASTE:"default-paste",SPECIAL_PASTE_VALUE:"special-paste-value",SPECIAL_PASTE_FORMAT:"special-paste-format",SPECIAL_PASTE_COL_WIDTH:"special-paste-col-width",SPECIAL_PASTE_BESIDES_BORDER:"special-paste-besides-border",SPECIAL_PASTE_FORMULA:"special-paste-formula"},rg={[_.FILE_PNG_CLIPBOARD_MIME_TYPE]:"png",[_.FILE__JPEG_CLIPBOARD_MIME_TYPE]:"jpg",[_.FILE__WEBP_CLIPBOARD_MIME_TYPE]:"webp",[_.FILE__BMP_CLIPBOARD_MIME_TYPE]:"bmp"};wn.use(Xm);wn.use(jm);wn.use(zm);const Be=a.createIdentifier("sheet.clipboard-service");exports.SheetClipboardService=class extends a.Disposable{constructor(e,t,r,o,s,l,c,d,u,h,g,S,f,p){super();E(this,"_clipboardHooks",[]);E(this,"_clipboardHooks$",new O.BehaviorSubject([]));E(this,"clipboardHooks$",this._clipboardHooks$.asObservable());E(this,"_htmlToUSM");E(this,"_usmToHtml");E(this,"_copyContentCache");E(this,"_copyMarkId",null);E(this,"_pasteOptionsCache$",new O.BehaviorSubject(null));E(this,"pasteOptionsCache$",this._pasteOptionsCache$.asObservable());E(this,"_showMenu$",new O.BehaviorSubject(!1));E(this,"showMenu$",this._showMenu$.asObservable());this._logService=e,this._univerInstanceService=t,this._selectionManagerService=r,this._clipboardInterfaceService=o,this._undoRedoService=s,this._commandService=l,this._markSelectionService=c,this._notificationService=d,this._platformService=u,this._renderManagerService=h,this._themeService=g,this._localeService=S,this._errorService=f,this._injector=p,this._htmlToUSM=new wn({getCurrentSkeleton:()=>{var v;return(v=T.withCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,exports.SheetSkeletonManagerService,this._univerInstanceService,this._renderManagerService))==null?void 0:v.getCurrentParam()}}),this._usmToHtml=new Km,this._copyContentCache=new Hm,this.disposeWithMe(this._htmlToUSM),this._initUnitDisposed()}setShowMenu(e){this._showMenu$.next(e)}getPasteMenuVisible(){return this._showMenu$.getValue()}getPasteOptionsCache(){return this._pasteOptionsCache$.getValue()}copyContentCache(){return this._copyContentCache}generateCopyContent(e,t,r,o=ct.COPY){const s=this._clipboardHooks;s.forEach(c=>{var d;return(d=c.onBeforeCopy)==null?void 0:d.call(c,e,t,r,o)});const l=this._generateCopyContent(e,t,r,this._clipboardHooks);return s.forEach(c=>{var d;return(d=c.onAfterCopy)==null?void 0:d.call(c)}),l}async copy(e=ct.COPY){const t=this._selectionManagerService.getCurrentLastSelection();if(!t)return!1;const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=r.getActiveSheet();if(!o)return!1;const s=r.getUnitId(),l=o.getSheetId(),c=this.generateCopyContent(s,l,t.range);if(!c)return!1;const{html:d,plain:u,matrixFragment:h,copyId:g,discreteRange:S}=c;this._copyContentCache.set(g,{unitId:r.getUnitId(),subUnitId:o.getSheetId(),range:S,matrix:h,copyType:e}),await this._clipboardInterfaceService.write(u,d),this._markSelectionService.removeAllShapes();const f=Ol(this._themeService);return this._copyMarkId=this._markSelectionService.addShape({...t,style:f}),!0}async cut(){return this.copy(ct.CUT)}async paste(e,t=ge.DEFAULT_PASTE){const r=e.types,o=r.indexOf(_.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(_.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(d=>d&&d.text()):"",s=r.indexOf(_.HTML_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(_.HTML_CLIPBOARD_MIME_TYPE).then(d=>d&&d.text()):"",l=r.findIndex(d=>_.imageMimeTypeSet.has(d)),c=l===-1||!Qm(s);if(s&&c)return this._platformService.isWindows&&ga(s)&&this._notificationService.show({type:"warning",title:this._localeService.t("clipboard.shortCutNotify.title"),content:this._localeService.t("clipboard.shortCutNotify.useShortCutInstead")}),this._pasteHTML(s,t);if(l!==-1){const d=r[l],u=await e.getType(d);if(u){const h=rg[d],g=new File([u],`clipboard-image.${h}`,{type:d});return this._pasteFiles([g],t)}}return o?this._pastePlainText(o,t):(this._logService.error("[SheetClipboardService]","No valid data on clipboard"),!1)}async legacyPaste(e,t,r){const o=ga(e!=null?e:"");return r&&!o?this._pasteFiles(r,ge.DEFAULT_PASTE):e?this._pasteHTML(e,ge.DEFAULT_PASTE):t?/[\n\t]/.test(t)?this._pasteHTML(eg(t),ge.DEFAULT_PASTE):this._pastePlainText(t,ge.DEFAULT_PASTE):this._pasteUnrecognized()}rePasteWithPasteType(e){const t=this._pasteOptionsCache$.getValue();if(!t)return!1;const r=this._injector.get(a.IUndoRedoService),o=r.pitchTopUndoElement();o&&a.sequenceExecute(o.undoMutations,this._commandService)&&r.popUndoToRedo();const{cellMatrix:s,rowProperties:l=[],colProperties:c=[],source:d,target:u}=t;return this._pasteUSM({cellMatrix:s,colProperties:c,rowProperties:l},u,ge[e],d),!0}updatePasteOptionsCache(e){this._pasteOptionsCache$.next(e)}addClipboardHook(e){if(this._clipboardHooks.findIndex(r=>r.id===e.id)!==-1)return this._logService.error("[SheetClipboardService]","hook already exists",e.id),{dispose:()=>{}};const t=this._clipboardHooks.findIndex(r=>{const o=r.priority||0;return(e.priority||0)<o});return this._clipboardHooks.splice(t!==-1?t:this._clipboardHooks.length,0,e),this._notifyClipboardHook(),a.toDisposable(()=>{const r=this._clipboardHooks.indexOf(e);r>-1&&(this._clipboardHooks.splice(r,1),this._notifyClipboardHook())})}getClipboardHooks(){return this._clipboardHooks}_generateCopyContent(e,t,r,o){const s=this._univerInstanceService.getUniverSheetInstance(e),l=s==null?void 0:s.getSheetBySheetId(t);if(!s||!l)return null;const c=o.reduce((M,y)=>{var x;const P=(x=y.getFilteredOutRows)==null?void 0:x.call(y,r);return P==null||P.forEach(A=>M.add(A)),M},new Set),{startColumn:d,startRow:u,endColumn:h,endRow:g}=r,S=l.getMatrixWithMergedCells(u,d,g,h,a.CellModeEnum.Both),f=new a.ObjectMatrix;let p=u;const v=new a.ObjectMatrix,C={rows:[],cols:[]};for(let M=u;M<=g;M++)if(!c.has(M)){C.rows.push(M);for(let y=d;y<=h;y++){const P=S.getValue(M,y);if(P){const x=a.Tools.deepClone(P);v.setValue(p-u,y-d,{...Bn(),...x}),delete x.displayV,f.setValue(p-u,y-d,{...Bn(),...x})}else v.setValue(p-u,y-d,Bn()),f.setValue(p-u,y-d,Bn()),S.setValue(M,y,Bn())}p+=1}for(let M=d;M<=h;M++)C.cols.push(M);let I=this._usmToHtml.convert(S,C,o);const R=kl(v),w=Dm();return I=I.replace(/(<[a-z]+)/,(M,y)=>`${y} data-copy-id="${w}"`),{copyId:w,plain:R,html:I,matrixFragment:f,discreteRange:C}}_notifyClipboardHook(){this._clipboardHooks$.next(this._clipboardHooks)}async _executePaste(e){const t=this._getPastingTarget();if(!t.subUnitId||!t.selection)return!1;const r=this._injector.invoke(S=>m.rangeToDiscreteRange(t.selection.range,S,t.unitId,t.subUnitId));if(!r)return!1;const{unitId:o,subUnitId:s}=t,l=this._clipboardHooks,c=[];if(l.some(S=>{var f;return c.push(S)&&((f=S.onBeforePaste)==null?void 0:f.call(S,{unitId:o,subUnitId:s,range:r}))===!1}))return c.forEach(S=>{var f;return(f=S.onAfterPaste)==null?void 0:f.call(S,!1)}),!1;const u=[],h=[];c.forEach(S=>{const f=e(S,{unitId:o,subUnitId:s,range:r});f&&(u.push(...f.redos),h.push(...f.undos))});const g=u.every(S=>this._commandService.executeCommand(S.id,S.params));return g&&this._undoRedoService.pushUndoRedo({unitID:this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),undoMutations:h,redoMutations:u}),g}async _pasteFiles(e,t){return this._executePaste((r,o)=>{var s;return(s=r.onPasteFiles)==null?void 0:s.call(r,o,e,{pasteType:t})})}async _pastePlainText(e,t){return this._executePaste((r,o)=>{var s;return(s=r.onPastePlainText)==null?void 0:s.call(r,o,e,{pasteType:t})})}_pasteUnrecognized(){return this._executePaste((e,t)=>{var r;return(r=e.onPasteUnrecognized)==null?void 0:r.call(e,t)})}async _pasteHTML(e,t){const r=Nm(e);return r&&this._copyContentCache.get(r)?this._pasteInternal(r,t):this._pasteExternal(e,t)}async _pasteExternal(e,t){var h;const{rowProperties:r,colProperties:o,cellMatrix:s}=this._htmlToUSM.convert(e);if(!s)return!1;const l=this._getPastedRange(s);if(!l)return!1;const c=(h=this._univerInstanceService.getUniverSheetInstance(l.unitId))==null?void 0:h.getSheetBySheetId(l.subUnitId);if(!c)return!1;const d=c==null?void 0:c.getMergeData();return d.length&&d.some(S=>Zi(S,l.pastedRange)&&!Sa(l.pastedRange,S))?(this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1):this._pasteUSM({rowProperties:r,colProperties:o,cellMatrix:s},l,t)}async _pasteInternal(e,t){var y,P;const r=a.Tools.deepClone(this._copyContentCache.get(e)),{range:o,matrix:s,unitId:l,subUnitId:c}=r||{};if(!s||!r||!o||!l||!c||!s||!r)return!1;const d=(y=this._univerInstanceService.getUniverSheetInstance(l))==null?void 0:y.getStyles();s.forValue((x,A,k)=>{if(typeof k.s=="string"){const D=a.Tools.deepClone(k);D.s=d==null?void 0:d.getStyleByCell(k),s.setValue(x,A,D)}if(k.colSpan||k.rowSpan)for(let D=0;D<k.rowSpan;D++)for(let H=0;H<k.colSpan;H++){if(D===0&&H===0)continue;const W=x+D,N=A+H;s.setValue(W,N,{s:d==null?void 0:d.getStyleByCell(k)})}});const u=this._getPastedRange(s);if(!u)return!1;const h=(P=this._univerInstanceService.getUniverSheetInstance(u.unitId))==null?void 0:P.getSheetBySheetId(u.subUnitId);if(!h)return!1;const g=h==null?void 0:h.getMergeData();if(g&&g.some(A=>Zi(A,u.pastedRange)&&!Sa(u.pastedRange,A)))return this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1;const S=this._univerInstanceService.getUnit(l);if(!S)return!1;const f=S.getSheetBySheetId(c);if(!f)return!1;const p=f.getColumnManager(),v=f.getRowManager(),C=f.getConfig().defaultColumnWidth,I=f.getConfig().defaultRowHeight,R=[],w=[];if(o.cols.forEach(x=>{const A=p.getColumnOrCreate(x);R.push({width:`${A.w||C}`})}),o.rows.forEach(x=>{const A=v.getRowOrCreate(x),{ah:k=I,h:D=I}=A,H=Math.max(k,D);w.push({height:`${H}`})}),r.copyType===ct.CUT){const x=u.pastedRange.rows[0],A=o.rows[o.rows.length-1]-o.rows[0]+x;u.pastedRange.rows=Array.from(new Array(A+1).keys()).slice(x)}const M=this._pasteUSM({cellMatrix:s,colProperties:R,rowProperties:w},u,t,{range:o,unitId:r.unitId,subUnitId:r.subUnitId,copyType:r.copyType,copyId:e});return r.copyType===ct.CUT&&(this._copyContentCache.set(e,{...r,matrix:null}),this._copyMarkId&&this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null),M}_pasteUSM(e,t,r,o){const{rowProperties:s,colProperties:l,cellMatrix:c}=e,{unitId:d,subUnitId:u,pastedRange:h}=t,g=h.cols.length,S=this._clipboardHooks,f=[];if(S.some(P=>{var x;return f.push(P)&&((x=P.onBeforePaste)==null?void 0:x.call(P,{unitId:d,subUnitId:u,range:h}))===!1}))return f.forEach(P=>{var x;return(x=P.onAfterPaste)==null?void 0:x.call(P,!1)}),!1;if(!c)return!1;const v=o?{unitId:o.unitId,subUnitId:o.subUnitId,range:o.range}:null,C={copyType:(o==null?void 0:o.copyType)||ct.COPY,copyId:o==null?void 0:o.copyId,pasteType:r};let I=[],R=[];const w=f.filter(P=>!P.specialPasteInfo&&P.id!==ge.DEFAULT_PASTE||r===P.id);w.forEach(P=>{var k,D,H;if(s){const W=(k=P.onPasteRows)==null?void 0:k.call(P,{range:h,unitId:d,subUnitId:u},s,{pasteType:r});W&&(I.push(...W.redos),R.push(...W.undos))}const x=(D=P.onPasteColumns)==null?void 0:D.call(P,{range:h,unitId:d,subUnitId:u},l||new Array(g).map(()=>({})),{pasteType:r});x&&(I.push(...x.redos),R.push(...x.undos));const A=(H=P.onPasteCells)==null?void 0:H.call(P,v,{range:h,unitId:d,subUnitId:u},c,C);A&&(I.push(...A.redos),R.push(...A.undos))});const M=this._getSetSelectionOperation(d,u,h,c,r);M&&I.push(M),I=Xo(I),R=Xo(R),R.push({id:m.SetWorksheetActiveOperation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId}}),this._logService.log("[SheetClipboardService]","pasting mutations",{undoMutationsInfo:R,redoMutationsInfo:I});const y=I.every(P=>this._commandService.syncExecuteCommand(P.id,P.params));return y&&(this._undoRedoService.pushUndoRedo({unitID:d,undoMutations:R,redoMutations:I}),this.updatePasteOptionsCache({target:{pastedRange:h,unitId:d,subUnitId:u},cellMatrix:c,rowProperties:s,colProperties:l,pasteType:r,source:o}),this.setShowMenu(!0)),w.forEach(P=>{var x;return(x=P.onAfterPaste)==null?void 0:x.call(P,y)}),y}_getSetSelectionOperation(e,t,r,o,s){var M;const l=(M=this._univerInstanceService.getUniverSheetInstance(e))==null?void 0:M.getSheetBySheetId(t);if(!l)return null;const{rows:c,cols:d}=r,u=c[0],h=d[0],g=c[c.length-1],S=d[d.length-1],f={startRow:u,endRow:u,startColumn:h,endColumn:h},p=m.getPrimaryForRange(f,l),v=o.getValue(0,0),C=(v==null?void 0:v.rowSpan)||1,I=(v==null?void 0:v.colSpan)||1;if((s===ge.DEFAULT_PASTE||s===ge.SPECIAL_PASTE_BESIDES_BORDER||s===ge.SPECIAL_PASTE_FORMAT)&&(C>1||I>1)){const y={startRow:u,endRow:u+C-1,startColumn:h,endColumn:h+I-1};p.startRow=y.startRow,p.endRow=y.endRow,p.startColumn=y.startColumn,p.endColumn=y.endColumn,p.isMerged=!0,p.isMergedMainCell=!0}const w={unitId:e,subUnitId:t,selections:[{range:{startRow:u,endRow:g,startColumn:h,endColumn:S},primary:p,style:null}]};return{id:m.SetSelectionsOperation.id,params:w}}_getPastingTarget(){const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),t=e.getActiveSheet(),r=this._selectionManagerService.getCurrentLastSelection();return{unitId:e.getUnitId(),subUnitId:t==null?void 0:t.getSheetId(),selection:r}}_transformPastedData(e,t,r){const o=this._getPastingTarget(),{selection:s,unitId:l,subUnitId:c}=o;if(!c||!s)return null;const d=this._injector.invoke(D=>m.rangeToDiscreteRange(s.range,D,l,c));if(!d)return null;const{ranges:[u],mapFunc:h}=Gt([d]),{startRow:g,startColumn:S,endRow:f,endColumn:p}=u,v=f-g+1,C=p-S+1,I=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),R=I==null?void 0:I.getActiveSheet();if(!R)return null;const M=R.getMergeData().filter(D=>d.rows.includes(D.startRow)&&d.cols.includes(D.startColumn)),y=M[0];let P=0,x=0,A=0,k=0;if(y&&(P=y.startRow,x=y.startColumn,A=y.endRow,k=y.endColumn),v%e===0&&C%t===0)if(M.length>0&&(v!==e||C!==t))if(P===d.rows[0]&&x===d.cols[0]&&A===d.rows[v-1]&&k===d.cols[C-1])if(ag(r))for(let H=0;H<v;H++)for(let W=0;W<C;W++){const N=r.getValue(H%e,W%t);N&&r.setValue(H,W,N)}else r.forValue((H,W,N)=>{N.s=null,delete N.colSpan,delete N.rowSpan});else for(let D=0;D<v;D++)for(let H=0;H<C;H++){const W=r.getValue(D%e,H%t);W&&r.setValue(D,H,W)}else for(let D=0;D<v;D++)for(let H=0;H<C;H++){const W=r.getValue(D%e,H%t);W&&r.setValue(D,H,W)}else if(M.length>0){const{row:D,col:H}=h(g,S);if(this._topLeftCellsMatch(e,t,{topRow:D,leftCol:H})){const N=this._expandOrShrinkRowsCols(l,c,d,t,e);d.rows=N.rows,d.cols=N.cols}else{if(f>y.endRow||p>y.endColumn)return null;r.forValue((N,U,L)=>{L.s=null,delete L.colSpan,delete L.rowSpan})}}else{const D=this._expandOrShrinkRowsCols(l,c,d,t,e);d.rows=D.rows,d.cols=D.cols}return{pastedRange:d,unitId:l,subUnitId:c}}_getPastedRange(e){var R;const t=this._getPastingTarget(),{selection:r,unitId:o,subUnitId:s}=t;if(!s||!r)return null;const l=this._injector.invoke(w=>m.rangeToDiscreteRange(r.range,w,o,s));if(!l)return null;const{startColumn:c,endColumn:d,startRow:u,endRow:h}=e.getDataRange(),g=h-u+1,S=d-c+1;if(g<=0||S<=0)return null;const f=l.rows.length,p=l.cols.length,v=(R=this._univerInstanceService.getUniverSheetInstance(o))==null?void 0:R.getSheetBySheetId(s);if(!v)return null;const C=v==null?void 0:v.getMergeData();if(f%g===0&&p%S===0&&!(C==null?void 0:C.some(M=>Zi(M,l)))){for(let M=0;M<f;M++)for(let y=0;y<p;y++){const P=e.getValue(M%g,y%S);P&&e.setValue(M,y,P)}return{pastedRange:l,unitId:o,subUnitId:s}}const I=this._expandOrShrinkRowsCols(o,s,l,S,g);return l.rows=I.rows,l.cols=I.cols,{pastedRange:l,unitId:o,subUnitId:s}}_expandOrShrinkRowsCols(e,t,r,o,s){const{rows:l,cols:c}=r,d=this._univerInstanceService.getUniverSheetInstance(e),u=d==null?void 0:d.getSheetBySheetId(t);let h,g;if(l.length>=s)h=l.slice(0,s);else{h=l.slice(0);let S=l[l.length-1]+1;for(;h.length<s;)u.getRowFiltered(S)||h.push(S),S++}if(c.length>=o)g=c.slice(0,o);else{g=c.slice(0);let S=c[c.length-1]+1;for(;g.length<o;)g.push(S),S++}return{rows:h,cols:g}}_topLeftCellsMatch(e,t,r){const o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=o==null?void 0:o.getActiveSheet();if(!s)return!1;const{topRow:l,leftCol:c}=r,d=og(l+e-1,c,c+t-1,s),u=sg(c+t-1,l,l+e-1,s);return!d&&!u}removeMarkSelection(){this._copyMarkId&&(this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null)}_initUnitDisposed(){this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e&&this.copyContentCache().clearWithUnitId(e.getUnitId())}))}disposePasteOptionsCache(){this.setShowMenu(!1),this.updatePasteOptionsCache(null)}};exports.SheetClipboardService=ng([Oe(0,a.ILogService),Oe(1,a.IUniverInstanceService),Oe(2,a.Inject(m.SheetsSelectionsService)),Oe(3,_.IClipboardInterfaceService),Oe(4,a.IUndoRedoService),Oe(5,a.ICommandService),Oe(6,qt),Oe(7,_.INotificationService),Oe(8,_.IPlatformService),Oe(9,T.IRenderManagerService),Oe(10,a.Inject(a.ThemeService)),Oe(11,a.Inject(a.LocaleService)),Oe(12,a.Inject(a.ErrorService)),Oe(13,a.Inject(a.Injector))],exports.SheetClipboardService);function kl(n){let i="";const e=n.getLength();return n.forRow((t,r)=>{const o=[];r.forEach(s=>{const l=n.getValue(t,s);if(l){const c=ig(l);o.push(c)}}),i+=o.join(" "),t!==e-1&&(i+=`
58
- `)}),i}function ig(n){return a.isNotNullOrUndefined(n.displayV)?n.displayV:a.extractPureTextFromCell(n)}function og(n,i,e,t){return t.getMergeData().some(r=>r.startRow<=n&&n<r.endRow&&i<=r.startColumn&&r.startColumn<=e)}function sg(n,i,e,t){return t.getMergeData().some(r=>r.startColumn<=n&&n<r.endColumn&&i<=r.startRow&&r.startRow<=e)}function ag(n){let i=0;return n.forValue((e,t,r)=>{if(r&&i++,i>1)return!1}),i>1}function Bn(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const ys=998,Xe={id:_.CopyCommand.id,name:"sheet.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:ys,preconditions:Es,handler:async n=>n.get(Be).copy()},Ms={id:_.CutCommand.id,name:"sheet.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:ys,preconditions:Es,handler:async n=>n.get(Be).cut()},Ye={id:_.PasteCommand.id,type:a.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:ys,preconditions:Es,handler:async(n,i)=>{const t=await n.get(_.IClipboardInterfaceService).read(),r=n.get(Be);return t.length!==0?r.paste(t[0],i==null?void 0:i.value):!1}},oi={id:_.SheetPasteShortKeyCommandName,type:a.CommandType.COMMAND,handler:async(n,i)=>{const e=n.get(Be),{htmlContent:t,textContent:r,files:o}=i;return e.legacyPaste(t,r,o),!0}},gn={id:"sheet.command.paste-value",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_VALUE})},Sn={id:"sheet.command.paste-format",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_FORMAT})},Vt={id:"sheet.command.paste-col-width",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_COL_WIDTH})},fn={id:"sheet.command.paste-besides-border",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_BESIDES_BORDER})},Dl={id:"sheet.command.optional-paste",type:a.CommandType.COMMAND,handler:async(n,{type:i})=>n.get(Be).rePasteWithPasteType(i)},fr={id:"sheet.command.hide-row-confirm",type:a.CommandType.COMMAND,handler:async n=>{var c;const e=(c=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const t=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),o=m.getSheetCommandTarget(r);if(!o)return!1;const{worksheet:s}=o,l=s.getVisibleRows();if(Ka(l,e)){const d=n.get(_.IConfirmService),u=n.get(a.LocaleService);return await d.confirm({id:"sheet.confirm.hide-row",title:{title:u.t("info.problem")},children:{title:u.t("rightClick.hideAllRowsAlert")},cancelText:u.t("button.cancel"),confirmText:u.t("button.confirm")}),!1}return await t.executeCommand(m.SetRowHiddenCommand.id),!0}},pr={id:"sheet.command.hide-col-confirm",type:a.CommandType.COMMAND,handler:async n=>{var c;const e=(c=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const t=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),o=m.getSheetCommandTarget(r);if(!o)return!1;const{worksheet:s}=o,l=s.getVisibleCols();if(qa(l,e)){const d=n.get(_.IConfirmService),u=n.get(a.LocaleService);return await d.confirm({id:"sheet.confirm.hide-col",title:{title:u.t("info.problem")},children:{title:u.t("rightClick.hideAllColumnsAlert")},cancelText:u.t("button.cancel"),confirmText:u.t("button.confirm")}),!1}return await t.executeCommand(m.SetColHiddenCommand.id),!0}},Qt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(ee.SetInlineFormatBoldCommand.id):i.executeCommand(m.SetBoldCommand.id)}},Jt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(ee.SetInlineFormatItalicCommand.id):i.executeCommand(m.SetItalicCommand.id)}},$t={type:a.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(ee.SetInlineFormatUnderlineCommand.id):i.executeCommand(m.SetUnderlineCommand.id)}},en={type:a.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(ee.SetInlineFormatStrikethroughCommand.id):i.executeCommand(m.SetStrikeThroughCommand.id)}},Ps={type:a.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(ee.SetInlineFormatSubscriptCommand.id):!1}},Os={type:a.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(ee.SetInlineFormatSuperscriptCommand.id):!1}},vr={type:a.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(n,i)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(ee.SetInlineFormatFontSizeCommand.id,i):e.executeCommand(m.SetFontSizeCommand.id,i)}},Cr={type:a.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(n,i)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(ee.SetInlineFormatFontFamilyCommand.id,i):e.executeCommand(m.SetFontFamilyCommand.id,i)}},Tn={type:a.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(n,i)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(ee.SetInlineFormatTextColorCommand.id,i):e.executeCommand(m.SetTextColorCommand.id,i)}},xs={type:a.CommandType.COMMAND,id:"sheet.command.reset-range-text-color",handler:async n=>{const i=n.get(a.ICommandService),t=n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED),r=n.get(a.ThemeService);return t?i.executeCommand(ee.SetInlineFormatTextColorCommand.id,{value:null}):i.executeCommand(m.SetTextColorCommand.id,{value:r.getCurrentTheme().textColor})}};var lg=Object.getOwnPropertyDescriptor,cg=(n,i,e,t)=>{for(var r=t>1?void 0:t?lg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},ln=(n,i)=>(e,t)=>i(e,t,n),De=(n=>(n[n.OFF=0]="OFF",n[n.ONCE=1]="ONCE",n[n.INFINITE=2]="INFINITE",n))(De||{});const et=a.createIdentifier("univer.format-painter-service");let si=class extends a.Disposable{constructor(i,e,t,r,o,s){super();E(this,"status$");E(this,"_selectionFormat");E(this,"_markId",null);E(this,"_status$");E(this,"_defaultHook",null);E(this,"_extendHooks",[]);this._selectionManagerService=i,this._themeService=e,this._markSelectionService=t,this._logService=r,this._commandService=o,this._undoRedoService=s,this._status$=new O.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new a.ObjectMatrix,merges:[]}}addHook(i){var e,t,r;i.isDefaultHook&&((e=i.priority)!=null?e:0)>((r=(t=this._defaultHook)==null?void 0:t.priority)!=null?r:-1)?this._defaultHook=i:(this._extendHooks.push(i),this._extendHooks.sort((o,s)=>(o.priority||0)-(s.priority||0)))}getHooks(){return this._defaultHook?[this._defaultHook,...this._extendHooks]:this._extendHooks}setStatus(i){this._updateRangeMark(i),this._status$.next(i),this.getHooks().forEach(t=>{t.onStatusChange!==void 0&&t.onStatusChange(i)})}getStatus(){return this._status$.getValue()}setSelectionFormat(i){this._selectionFormat=i}getSelectionFormat(){return this._selectionFormat}applyFormatPainter(i,e,t){const r=this.getHooks(),o=[],s=[];r.forEach(c=>{if(c.onApply!==void 0){const d=c.onApply(i,e,t,this._selectionFormat);d&&(o.push(...d.redos),s.push(...d.undos))}});for(const c of r)if(c.onBeforeApply!==void 0&&!c.onBeforeApply({unitId:i,subUnitId:e,range:t,redoMutationsInfo:o,format:this._selectionFormat,undoMutationsInfo:s}))return!1;this._logService.log("[FormatPainterService]","apply mutations",{undoMutationsInfo:s,redoMutationsInfo:o});const l=o.every(c=>this._commandService.executeCommand(c.id,c.params));return l&&this._undoRedoService.pushUndoRedo({unitID:i,undoMutations:s,redoMutations:o}),l}_updateRangeMark(i){if(this._markSelectionService.removeAllShapes(),i!==0){const e=this._selectionManagerService.getCurrentLastSelection();if(e){const t=Ol(this._themeService);i===2?this._markId=this._markSelectionService.addShape({...e,style:t}):this._markId=this._markSelectionService.addShape({...e,style:t},[m.SetRangeValuesMutation.id])}}}};si=cg([ln(0,a.Inject(m.SheetsSelectionsService)),ln(1,a.Inject(a.ThemeService)),ln(2,qt),ln(3,a.ILogService),ln(4,a.ICommandService),ln(5,a.IUndoRedoService)],si);const _r={id:"sheet.operation.set-format-painter",type:a.CommandType.OPERATION,handler:(n,i)=>i?(n.get(et).setStatus(i.status),!0):!1},Vi={type:a.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async n=>{const e=n.get(et).getStatus();let t;return e!==De.OFF?t=De.OFF:t=De.INFINITE,n.get(a.ICommandService).executeCommand(_r.id,{status:t})}},kn={type:a.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async n=>{const e=n.get(et).getStatus();let t;return e!==De.OFF?t=De.OFF:t=De.ONCE,n.get(a.ICommandService).executeCommand(_r.id,{status:t})}},Ir={type:a.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(n,i)=>n.get(et).applyFormatPainter(i.unitId,i.subUnitId,i.range)},ht={type:a.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(n,i)=>{const{type:e}=i||{},t=n.get(a.IUniverInstanceService),r=n.get(a.IUndoRedoService),o=m.getSheetCommandTarget(t);if(!o)return!1;const{unitId:s,subUnitId:l}=o,c=n.get(a.ICommandService),u=n.get(m.SheetsSelectionsService).getCurrentSelections();if(!u)return!1;const h=u[(u==null?void 0:u.length)-1],{range:g}=h,f=n.get(T.IRenderManagerService).getRenderById(s).with(exports.SheetScrollManagerService),{sheetViewStartRow:p=0,sheetViewStartColumn:v=0}=f.getCurrentScrollState()||{};let C,I,R,w;const{startRow:M,startColumn:y,rangeType:P}=g;if(P===a.RANGE_TYPE.ROW||e===1)C=M,R=M-p,I=-1,w=0;else if(P===a.RANGE_TYPE.COLUMN||e===2)C=-1,R=0,I=y,w=y-v;else if(P===a.RANGE_TYPE.NORMAL)C=M,R=M-p,I=y,w=y-v;else return!1;const x={unitId:s,subUnitId:l,startRow:C,startColumn:I,xSplit:I>0?Math.max(1,w):w,ySplit:C>0?Math.max(1,R):R},A=m.SetFrozenMutationFactory(n,x);return c.syncExecuteCommand(m.SetFrozenMutation.id,x)&&r.pushUndoRedo({unitID:s,undoMutations:[{id:m.SetFrozenMutation.id,params:A}],redoMutations:[{id:m.SetFrozenMutation.id,params:x}]}),!0}},br={type:a.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand(ht.id,{type:1}),!0)},Rr={type:a.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand(ht.id,{type:2}),!0)};var dg=Object.getOwnPropertyDescriptor,ug=(n,i,e,t)=>{for(var r=t>1?void 0:t?dg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},fa=(n,i)=>(e,t)=>i(e,t,n);const hg=(n,i)=>{const{unitId:e,subUnitId:t,ranges:r}=n,o={},s=i.getColumnManager();for(let l=0;l<r.length;l++){const c=r[l];for(let d=c.startColumn;d<c.endColumn+1;d++){const u=s.getColumnOrCreate(d);o[d]=u.w}}return{unitId:e,subUnitId:t,ranges:r,colWidth:o}};exports.AutoWidthController=class extends a.Disposable{constructor(i,e){super(),this._renderManagerService=i,this._univerInstanceService=e}getUndoRedoParamsOfColWidth(i){const e={redos:[],undos:[]},{_univerInstanceService:t}=this,r=m.getSheetCommandTarget(t);if(!r)return e;const{unitId:o,subUnitId:s,worksheet:l}=r,c=this._renderManagerService.getRenderById(o).with(exports.SheetSkeletonManagerService);if(!c.getCurrentParam())return e;const{skeleton:d}=c.getCurrentParam(),u=d.calculateAutoWidthInRange(i.ranges),h={};for(const{col:f,width:p}of u)h[f]=p;const g={subUnitId:s,unitId:o,ranges:i.ranges,colWidth:h},S=hg(g,l);return{undos:[{id:m.SetWorksheetColWidthMutation.id,params:S}],redos:[{id:m.SetWorksheetColWidthMutation.id,params:g}]}}};exports.AutoWidthController=ug([fa(0,T.IRenderManagerService),fa(1,a.Inject(a.IUniverInstanceService))],exports.AutoWidthController);const Er={type:a.CommandType.COMMAND,id:"sheet.command.set-col-auto-width",handler:(n,i)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o,i);if(!s)return!1;const{unitId:l,subUnitId:c}=s;let d=[];if(i!=null&&i.ranges)d=[...i.ranges];else{const f=r.getCurrentSelections();for(let p=0;p<f.length;p++)d.push(f[p].range)}if(!(d!=null&&d.length))return!1;const u={unitId:l,subUnitId:c,ranges:d},{redos:h,undos:g}=n.get(exports.AutoWidthController).getUndoRedoParamsOfColWidth(u);return a.sequenceExecute([...h],e).result?(t.pushUndoRedo({unitID:l,undoMutations:[...g],redoMutations:[...h]}),!0):!1}},Dn="UI_PLUGIN_SHEETS",wr=`${Dn}_COLOR_PICKER_COMPONENT`,Wi=`${Dn}_FONT_FAMILY_COMPONENT`,Ui=`${Dn}_FONT_FAMILY_ITEM_COMPONENT`,Li=`${Dn}_FONT_SIZE_COMPONENT`,tt=`${Dn}_MENU_ITEM_INPUT_COMPONENT`,mg="univer-sheets-ui-context-menu-input",gg="univer-sheets-ui-context-menu-input-container",Sg="univer-sheets-ui-context-menu-input-number",Ki={sheetsUiContextMenuInput:mg,sheetsUiContextMenuInputContainer:gg,sheetsUiContextMenuInputNumber:Sg},Nl=n=>{const{prefix:i,suffix:e,value:t,onChange:r,min:o=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=n,l=_.useDependency(a.LocaleService),c=_.useDependency(_.IContextMenuService),[d,u]=V.useState(),h=S=>{var f;u(S==null?void 0:S.toString()),r((f=S==null?void 0:S.toString())!=null?f:"")};V.useEffect(()=>{c.visible||u(t)},[c.visible]),V.useEffect(()=>{u(t)},[t]);function g(S){S.key==="Backspace"&&S.stopPropagation()}return b.jsxs("div",{className:Ki.sheetsUiContextMenuInput,children:[l.t(i),b.jsx("span",{className:Ki.sheetsUiContextMenuInputContainer,onClick:S=>S.stopPropagation(),children:b.jsx(Y.InputNumber,{className:Ki.sheetsUiContextMenuInputNumber,value:Number(d),precision:0,onKeyDown:g,onChange:h,min:o,max:s})}),l.t(e)]})};function fg(n){return n.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(me.switchMap(i=>i?i.activeSheet$.pipe(me.map(e=>e?{workbook:i,worksheet:e}:null)):O.of(null)))}function be(n,i,e){return fg(n).pipe(me.switchMap(t=>t?e(t):O.of(i)))}function Hl(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.IExclusiveRangeService),r=n.get(m.SheetsSelectionsService);return e.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(me.switchMap(s=>s?O.combineLatest([r.selectionMoveEnd$,s.activeSheet$]).pipe(me.switchMap(([l,c])=>{if(!c||l.length===0)return O.of(!1);const d=t.getInterestGroupId(l);if(i){const u=d.filter(h=>i.has(h));return O.of(u.length>0)}else return O.of(d.length>0)})):O.of(!1)))}function tn(n,i,e){return O.combineLatest([i,Hl(n,e)]).pipe(me.map(([t,r])=>t||r))}function te(n,i={},e=!1){var g;const r=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),o=n.get(a.UserManagerService),s=n.has(Se)?n.get(Se):null,l=n.get(a.IContextService),c=new O.BehaviorSubject(!1),d=(g=s==null?void 0:s.visible$)!=null?g:O.of(null),u=l.subscribeContextValue$(a.FOCUSING_FX_BAR_EDITOR).subscribe(S=>{c.next(S)});return O.combineLatest([o.currentUser$,r,d,c]).pipe(me.finalize(()=>{u.unsubscribe(),c.complete()}),me.switchMap(([S,f,p,v])=>!f||p!=null&&p.visible&&p.unitId===f.getUnitId()&&!e||v&&!e?O.of(!0):f.activeSheet$.pipe(me.switchMap(C=>{if(!C)return O.of(!0);const I=n.get(m.SheetsSelectionsService),R=n.get(m.RangeProtectionRuleModel),w=n.get(m.WorksheetProtectionRuleModel),y=n.get(a.IContextService).subscribeContextValue$(a.FOCUSING_COMMON_DRAWINGS).pipe(me.startWith(!1));return O.combineLatest([I.selectionMoveEnd$,y]).pipe(me.switchMap(([P,x])=>{if(x)return O.of(!0);const A=f.getUnitId(),k=C.getSheetId(),D=n.get(a.IPermissionService),{workbookTypes:H=[m.WorkbookEditablePermission],worksheetTypes:W,rangeTypes:N}=i,U=[];if(H==null||H.forEach(j=>{U.push(new j(A).id)}),W==null||W.forEach(j=>{U.push(new j(A,k).id)}),w.getRule(A,k))return D.composePermission$(U).pipe(me.map(j=>j.some(z=>z.value===!1)));const F=P==null?void 0:P.map(j=>j.range),B=R.getSubunitRuleList(A,k).filter(j=>F==null?void 0:F.some(z=>j.ranges.some(K=>a.Rectangle.intersects(z,K))));return N==null||N.forEach(j=>{B.forEach(z=>{U.push(new j(A,k,z.permissionId).id)})}),D.composePermission$(U).pipe(me.map(j=>j.some(z=>z.value===!1)))}))}))))}function Nn(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(m.RangeProtectionRuleModel),r=n.get(a.IPermissionService);return O.merge(e.selectionMoveEnd$,r.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var h;const o=(h=e.getCurrentLastSelection())==null?void 0:h.range;if(!o)return!0;const s=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s==null?void 0:s.getActiveSheet();if(!s||!l)return!0;const c=s.getUnitId(),d=l.getSheetId(),u=[new m.WorkbookEditablePermission(c).id,new m.WorksheetEditPermission(c,d).id];return t.getSubunitRuleList(c,d).filter(g=>g.ranges.some(S=>a.Rectangle.intersects(o,S))).forEach(g=>{u.push(new m.RangeProtectionPermissionEditPoint(c,d,g.permissionId).id)}),r.composePermission(u).some(g=>g.value===!1)}))}function Vl(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return O.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var g;const s=(g=t.getCurrentLastSelection())==null?void 0:g.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id];return r.getSubunitRuleList(d,u).filter(S=>i==="row"?S.ranges.some(f=>s.startRow>f.startRow&&s.startRow<=f.endRow):S.ranges.some(f=>s.startColumn>f.startColumn&&s.startColumn<=f.endColumn)).forEach(S=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,S.permissionId).id)}),o.composePermission(h).some(S=>S.value===!1)}))}function Wl(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return O.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var S;const s=(S=t.getCurrentLastSelection())==null?void 0:S.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id],g=a.Tools.deepClone(s);return i==="row"?(g.startColumn=0,g.endColumn=c.getColumnCount()-1):(g.startRow=0,g.endRow=c.getRowCount()-1),r.getSubunitRuleList(d,u).filter(f=>f.ranges.some(p=>a.Rectangle.intersects(g,p))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),o.composePermission(h).some(f=>f.value===!1)}))}function Bi(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return O.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var S;const s=(S=t.getCurrentLastSelection())==null?void 0:S.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id],g=a.Tools.deepClone(s);return i==="row"?g.endRow=c.getRowCount()-1:g.endColumn=c.getColumnCount()-1,r.getSubunitRuleList(d,u).filter(f=>f.ranges.some(p=>a.Rectangle.intersects(g,p))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),o.composePermission(h).some(f=>f.value===!1)}))}function Hn(n,i){const t=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),r=n.get(m.WorksheetProtectionRuleModel),o=n.get(m.RangeProtectionRuleModel),s=n.get(a.IPermissionService),l=n.get(a.UserManagerService);return O.combineLatest([l.currentUser$,t]).pipe(me.switchMap(([c,d])=>d?d.activeSheet$.pipe(me.switchMap(u=>{if(!u)return O.of(!0);const h=d.getUnitId(),g=[];return i.forEach(f=>g.push(new f(h).id)),s.composePermission$(g).pipe(me.map(f=>f.every(p=>p.value===!0))).pipe(me.map(f=>{if(!f)return!0;const p=u.getSheetId(),v=r.getRule(h,p),C=o.getSubunitRuleList(h,p);return!!(v||C.length)}))})):O.of(!0)))}var Ul=(n=>(n.ROW_HEADER_CONTEXT_MENU="ROW_HEADER_CONTEXT_MENU",n.COL_HEADER_CONTEXT_MENU="COL_HEADER_CONTEXT_MENU",n.SHEET_BAR="SHEET_BAR",n.SHEET_FOOTER="SHEET_FOOTER",n))(Ul||{});function pg(n){const i=n.get(et);return{id:kn.id,subId:Vi.id,type:_.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",activated$:new O.Observable(e=>{let t=!1;const r=i.status$.subscribe(o=>{t=o!==De.OFF,e.next(t)});return e.next(t),()=>{r.unsubscribe()}}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetCopyPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function vg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IContextService),r=n.get(m.SheetsSelectionsService);return{id:Qt.id,type:_.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=r.getCurrentLastSelection())==null?void 0:S.primary;let v=a.FontWeight.NORMAL;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getFontWeight()}s.next(v===a.FontWeight.BOLD)}if((g===Re.SetTextSelectionsOperation.id||g===ee.SetInlineFormatCommand.id)&&t.getContextValue(a.EDITOR_ACTIVATED)&&t.getContextValue(a.FOCUSING_SHEET)){const p=yr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.bl;s.next(v===a.BooleanNumber.TRUE)}}),c=(u=r.getCurrentLastSelection())==null?void 0:u.primary;if(!o){s.next(!1);return}let d=a.FontWeight.NORMAL;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontWeight()}return s.next(d===a.FontWeight.BOLD),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Cg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService);return{id:Jt.id,type:_.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let v=a.FontItalic.NORMAL;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getFontStyle()}s.next(v===a.FontItalic.ITALIC)}if((g===Re.SetTextSelectionsOperation.id||g===ee.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const p=yr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.it;s.next(v===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d=a.FontItalic.NORMAL;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontStyle()}return s.next(d===a.FontItalic.ITALIC),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function _g(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService);return{id:$t.id,type:_.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",activated$:be(e,!1,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let v;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getUnderline()}s.next(!!(v&&v.s))}if((g===Re.SetTextSelectionsOperation.id||g===ee.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const p=yr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.ul;s.next((v==null?void 0:v.s)===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getUnderline()}return s.next(!!(d&&d.s)),l.dispose})),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ig(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService);return{id:en.id,type:_.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let v;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getStrikeThrough()}s.next(!!(v&&v.s))}if((g===Re.SetTextSelectionsOperation.id||g===ee.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const p=yr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.st;s.next((v==null?void 0:v.s)===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getStrikeThrough()}return s.next(!!(d&&d.s)),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function bg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=a.DEFAULT_STYLES.ff;return{id:Cr.id,tooltip:"toolbar.font",type:_.MenuItemType.SELECTOR,label:Wi,selections:_.FONT_FAMILY_LIST.map(o=>({label:{name:Ui},value:o.value})),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),value$:be(e,r,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var p;const g=h.id;if(g!==m.SetRangeValuesMutation.id&&g!==m.SetSelectionsOperation.id&&g!==m.SetWorksheetActiveOperation.id)return;const S=(p=t.getCurrentLastSelection())==null?void 0:p.primary;let f;if(S!=null){const v=o.getRange(S.startRow,S.startColumn);f=v==null?void 0:v.getFontFamily()}s.next(f!=null?f:r)}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontFamily()}return s.next(d!=null?d:r),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Rg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService),o=a.DEFAULT_STYLES.fs,s=te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0);return{id:vr.id,type:_.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:Li,props:{min:1,max:400,disabled$:s}},selections:_.FONT_SIZE_LIST,disabled$:s,value$:be(e,o,({worksheet:l})=>new O.Observable(c=>{var g;const d=i.onCommandExecuted(S=>{var p,v;const f=S.id;if(f===m.SetRangeValuesMutation.id||f===m.SetSelectionsOperation.id||f===m.SetWorksheetActiveOperation.id){const C=(p=t.getCurrentLastSelection())==null?void 0:p.primary;let I;if(C!=null){const R=l.getRange(C.startRow,C.startColumn);I=R==null?void 0:R.getFontSize()}c.next(I!=null?I:o)}if((f===Re.SetTextSelectionsOperation.id||f===ee.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const C=yr(n);if(C==null)return;const I=(v=C.ts)==null?void 0:v.fs;c.next(I!=null?I:o)}}),u=(g=t.getCurrentLastSelection())==null?void 0:g.primary;let h;if(u!=null){const S=l.getRange(u.startRow,u.startColumn);h=S==null?void 0:S.getFontSize()}return c.next(h!=null?h:o),d.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Eg(n){return{id:xs.id,type:_.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function wg(n){const i=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:Tn.id,icon:"FontColor",tooltip:"toolbar.textColor.main",type:_.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:wr,hoverable:!1,selectable:!1}}],value$:new O.Observable(t=>{const r=e.getCurrentTheme().textColor,o=i.onCommandExecuted(s=>{if(s.id===Tn.id){const l=s.params.value;t.next(l!=null?l:r)}});return t.next(r),o.dispose}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function Tg(n){return{id:m.ResetBackgroundColorCommand.id,type:_.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function yg(n){const i=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:m.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",type:_.MenuItemType.BUTTON_SELECTOR,icon:"PaintBucket",selections:[{label:{name:wr,hoverable:!1,selectable:!1}}],value$:new O.Observable(t=>{const r=e.getCurrentTheme().primaryColor,o=i.onCommandExecuted(s=>{if(s.id===m.SetBackgroundColorCommand.id){const l=s.params.value;t.next(l!=null?l:r)}});return t.next(r),o.dispose}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const pa=[{label:"align.left",icon:"LeftJustifyingSingle",value:a.HorizontalAlign.LEFT},{label:"align.center",icon:"HorizontallySingle",value:a.HorizontalAlign.CENTER},{label:"align.right",icon:"RightJustifyingSingle",value:a.HorizontalAlign.RIGHT}];function Mg(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.HorizontalAlign.LEFT;return{id:m.SetHorizontalTextAlignCommand.id,icon:pa[0].icon,tooltip:"toolbar.horizontalAlignMode.main",type:_.MenuItemType.SELECTOR,selections:pa,value$:be(i,t,({worksheet:r})=>new O.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetHorizontalTextAlignCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);S=p==null?void 0:p.getHorizontalAlignment()}o.next(S!=null?S:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=r.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getHorizontalAlignment()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const va=[{label:"align.top",icon:"AlignTopSingle",value:a.VerticalAlign.TOP},{label:"align.middle",icon:"VerticalCenterSingle",value:a.VerticalAlign.MIDDLE},{label:"align.bottom",icon:"AlignBottomSingle",value:a.VerticalAlign.BOTTOM}];function Pg(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.VerticalAlign.BOTTOM;return{id:m.SetVerticalTextAlignCommand.id,icon:va[2].icon,tooltip:"toolbar.verticalAlignMode.main",type:_.MenuItemType.SELECTOR,selections:va,value$:be(i,t,({worksheet:r})=>new O.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetVerticalTextAlignCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);S=p==null?void 0:p.getVerticalAlignment()}o.next(S!=null?S:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=r.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getVerticalAlignment()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const Ca=[{label:"textWrap.overflow",icon:"OverflowSingle",value:a.WrapStrategy.OVERFLOW},{label:"textWrap.wrap",icon:"AutowrapSingle",value:a.WrapStrategy.WRAP},{label:"textWrap.clip",icon:"TruncationSingle",value:a.WrapStrategy.CLIP}];function Og(n){const i=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=a.WrapStrategy.OVERFLOW;return{id:m.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:Ca[0].icon,type:_.MenuItemType.SELECTOR,selections:Ca,value$:be(e,t,({worksheet:r})=>new O.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetTextWrapCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=i.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);S=p==null?void 0:p.getWrapStrategy()}o.next(S!=null?S:t)}),l=(d=i.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=r.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getWrapStrategy()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const _a=[{label:"textRotate.none",icon:"NoRotationSingle",value:0},{label:"textRotate.angleUp",icon:"LeftRotationFortyFiveDegreesSingle",value:-45},{label:"textRotate.angleDown",icon:"RightRotationFortyFiveDegreesSingle",value:45},{label:"textRotate.vertical",icon:"VerticalTextSingle",value:"v"},{label:"textRotate.rotationUp",icon:"LeftRotationNinetyDegreesSingle",value:-90},{label:"textRotate.rotationDown",icon:"RightRotationNinetyDegreesSingle",value:90}];function xg(n){const i=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=0;return{id:m.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:_a[0].icon,type:_.MenuItemType.SELECTOR,selections:_a,value$:be(e,t,({worksheet:r})=>new O.Observable(o=>{var d,u;const s=n.get(a.ICommandService).onCommandExecuted(h=>{var p,v;const g=h.id;if(g!==m.SetTextRotationCommand.id&&g!==m.SetSelectionsOperation.id&&g!==m.SetWorksheetActiveOperation.id)return;const S=(p=i.getCurrentLastSelection())==null?void 0:p.primary;let f;if(S!=null){const C=r.getRange(S.startRow,S.startColumn);f=C==null?void 0:C.getTextRotation()}(f==null?void 0:f.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((v=f&&f.a)!=null?v:t)}),l=(d=i.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const h=r.getRange(l.startRow,l.startColumn);c=h==null?void 0:h.getTextRotation()}return(c==null?void 0:c.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((u=c&&c.a)!=null?u:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Tr(n){return new O.Observable(e=>e.next(!n.get(_.IClipboardInterfaceService).supportClipboard))}function pn(n){return{id:Xe.name,commandId:Xe.id,type:_.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",disabled$:te(n,{workbookTypes:[m.WorkbookCopyPermission],worksheetTypes:[m.WorksheetCopyPermission],rangeTypes:[m.RangeProtectionPermissionViewPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function qi(n){return{id:Ye.name,commandId:Ye.id,type:_.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Jn="sheet.menu.paste-special";function Qi(n){return{id:Jn,type:_.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",hidden$:tn(n,_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET))}}function Ji(n){return{id:gn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteValue",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellValuePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function $i(n){return{id:Sn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteFormat",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function eo(n){return{id:Vt.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e))}}function to(n){return{id:fn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission,m.WorksheetSetRowStylePermission,m.WorksheetSetColumnStylePermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ag(n){return{id:m.SetWorksheetRowIsAutoHeightCommand.id,type:_.MenuItemType.BUTTON,icon:"AutoHeight",title:"rightClick.fitContent",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function kg(n){return{id:Er.id,type:_.MenuItemType.BUTTON,icon:"AutoWidth",title:"rightClick.fitContent",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Ll="sheet.menu.sheet-frozen";function Dg(n){return{id:Ll,type:_.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Yo="sheet.header-menu.sheet-frozen";function Ia(n){return{id:Yo,type:_.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function no(n){return{id:ht.id,type:_.MenuItemType.BUTTON,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ng(n){return{id:br.id,type:_.MenuItemType.BUTTON,title:"rightClick.freezeRow",icon:"FreezeRowSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Hg(n){return{id:Rr.id,type:_.MenuItemType.BUTTON,title:"rightClick.freezeCol",icon:"FreezeColumnSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function ro(n){return{id:m.CancelFrozenCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Vg(n){return{id:fr.id,type:_.MenuItemType.BUTTON,icon:"Hide",title:"rightClick.hideSelectedRow",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Wg(n){return{id:pr.id,type:_.MenuItemType.BUTTON,icon:"Hide",title:"rightClick.hideSelectedColumn",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ug(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),r=[m.SetSelectionsOperation,m.SetRowHiddenMutation,m.SetRowVisibleMutation].map(o=>o.id);return{id:m.SetSelectedRowsVisibleCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.showHideRow",hidden$:be(i,!0,({worksheet:o})=>new O.Observable(s=>{function l(){var u;const d=(u=e.getCurrentSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.ROW);return!!(d!=null&&d.some(h=>{for(let g=h.startRow;g<=h.endRow;g++)if(!o.getRowRawVisible(g))return!0;return!1}))}const c=t.onCommandExecuted(d=>{r.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Lg(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),r=[m.SetSelectionsOperation,m.SetColHiddenMutation,m.SetColVisibleMutation].map(o=>o.id);return{id:m.SetSelectedColsVisibleCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.showHideColumn",hidden$:be(i,!0,({worksheet:o})=>new O.Observable(s=>{function l(){var u;const d=(u=e.getCurrentSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.COLUMN);return!d||d.length===0?!1:!!d.some(h=>{for(let g=h.startColumn;g<=h.endColumn;g++)if(!o.getColVisible(g))return!0;return!1})}const c=t.onCommandExecuted(d=>{r.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Bg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=0;return{id:m.SetRowHeightCommand.id,type:_.MenuItemType.BUTTON,icon:"AdjustHeight",label:{name:tt,props:{prefix:"rightClick.rowHeight",suffix:"px",min:2,max:1e3}},value$:be(e,r,({worksheet:o})=>new O.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary,u=d?o.getRowHeight(d.startRow):r;s.next(u)}const c=i.onCommandExecuted(d=>{const u=d.id;if(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetRowIsAutoHeightMutation.id)return l()});return l(),c.dispose})),hidden$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Fg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=0;return{id:m.SetColWidthCommand.id,type:_.MenuItemType.BUTTON,icon:"AdjustWidth",label:{name:tt,props:{prefix:"rightClick.columnWidth",suffix:"px",min:2,max:1e3}},value$:be(e,r,({worksheet:o})=>new O.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary;let u=r;d!=null&&(u=o.getColumnWidth(d.startColumn)),s.next(u)}const c=i.onCommandExecuted(d=>{const u=d.id;if(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetColWidthMutation.id)return l()});return l(),c.dispose})),hidden$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function yr(n){var c;const i=n.get(a.IUniverInstanceService),e=n.get(Re.DocSelectionManagerService),t=i.getUniverDocInstance(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),r=e.getActiveTextRange();if(t==null||r==null)return null;const o=(c=t.getBody())==null?void 0:c.textRuns;if(o==null)return;const{startOffset:s}=r;return o.find(({st:d,ed:u})=>s>=d&&s<=u)}var jg=Object.getOwnPropertyDescriptor,zg=(n,i,e,t)=>{for(var r=t>1?void 0:t?jg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},xt=(n,i)=>(e,t)=>i(e,t,n);const Xg="__SpreadsheetFreezeRowMainName__",Yg="__SpreadsheetFreezeRowHeaderName__",Gg="__SpreadsheetFreezeColumnMainName__",Zg="__SpreadsheetFreezeColumnHeaderName__",io=2,Kg=.01,Fn=a.createInterceptorKey("freezePermissionCheck");exports.HeaderFreezeRenderController=class extends a.Disposable{constructor(e,t,r,o,s,l,c,d){super();E(this,"_rowFreezeHeaderRect");E(this,"_rowFreezeMainRect");E(this,"_columnFreezeHeaderRect");E(this,"_columnFreezeMainRect");E(this,"_freezeDownSubs");E(this,"_freezePointerEnterSubs");E(this,"_freezePointerLeaveSubs");E(this,"_scenePointerMoveSub");E(this,"_scenePointerUpSub");E(this,"_changeToRow",-1);E(this,"_changeToColumn",-1);E(this,"_changeToOffsetX",0);E(this,"_changeToOffsetY",0);E(this,"_activeViewport",null);E(this,"_freezeNormalHeaderColor","");E(this,"_freezeNormalMainColor","");E(this,"_freezeActiveColor","");E(this,"_freezeHoverColor","");E(this,"_lastFreeze");E(this,"interceptor",new a.InterceptorManager({FREEZE_PERMISSION_CHECK:Fn}));this._context=e,this._sheetSkeletonManagerService=t,this._commandService=r,this._selectionManagerService=o,this._scrollManagerService=s,this._themeService=l,this._sheetInterceptorService=c,this._injector=d,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._themeChangeListener(),this._interceptorCommands(),this._bindViewportScroll(),this._zoomRefresh()}_createFreeze(e=0,t){var x;const r=t!=null?t:this._getFreeze();if(r==null)return null;const o=(x=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:x.skeleton,{startRow:s,startColumn:l}=r,c=this._getPositionByIndex(s,l);if(c==null||o==null)return null;const d=this._getSheetObject(),u=d.engine,h=(u==null?void 0:u.width)||0,g=(u==null?void 0:u.height)||0,S=d.scene,{startX:f,startY:p}=c,{rowTotalHeight:v,columnTotalWidth:C,rowHeaderWidthAndMarginLeft:I,columnHeaderHeightAndMarginTop:R}=o,w=h>C+I?h:C+R,M=g>v+R?g:v+R;this._changeToRow=s,this._changeToColumn=l,this._changeToOffsetX=f,this._changeToOffsetY=p;const y=Math.max(S.scaleX,S.scaleY);let P=io/Math.max(1,y);if(e===0){(s===-1||s===0)&&(P=P*2);const A=P;this._rowFreezeHeaderRect=new T.Rect(Yg,{fill:this._freezeNormalHeaderColor,width:I,height:P,left:0,top:p-A,zIndex:3});let k=this._freezeNormalHeaderColor;(s===-1||s===0)&&(k=this._freezeNormalMainColor),this._rowFreezeMainRect=new T.Rect(Xg,{fill:k,width:w*2/y,height:P,left:I,top:p-A,zIndex:3}),S.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],bt)}else{(l===-1||l===0)&&(P=P*2);const A=P;this._columnFreezeHeaderRect=new T.Rect(Zg,{fill:this._freezeNormalHeaderColor,width:P,height:R,left:f-A,top:0,zIndex:3});let k=this._freezeNormalHeaderColor;(l===-1||l===0)&&(k=this._freezeNormalMainColor),this._columnFreezeMainRect=new T.Rect(Gg,{fill:k,width:P,height:M*2/y,left:f-A,top:R,zIndex:3}),S.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],bt)}this._eventBinding(e)}_eventBinding(e=0){let t=this._rowFreezeHeaderRect,r=this._rowFreezeMainRect;e===1&&(t=this._columnFreezeHeaderRect,r=this._columnFreezeMainRect);const o=this._getSheetObject();if(o==null)return;const{scene:s}=o;if(this._freezePointerEnterSubs=new O.Subscription,this._freezePointerLeaveSubs=new O.Subscription,this._freezeDownSubs=new O.Subscription,r){const d=r.onPointerEnter$.subscribeEvent(()=>{if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(T.CURSOR_TYPE.GRAB)});this._freezePointerEnterSubs.add(d);const u=r.onPointerLeave$.subscribeEvent(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),s.resetCursor()});this._freezePointerLeaveSubs.add(u)}if(t){const d=t.onPointerEnter$.subscribeEvent(()=>{if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(T.CURSOR_TYPE.GRAB)});this._freezePointerEnterSubs.add(d);const u=t.onPointerLeave$.subscribeEvent(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),s.resetCursor()});this._freezePointerLeaveSubs.add(u)}const l=t==null?void 0:t.onPointerDown$.subscribeEvent(d=>{this._freezeDown(d,t,r,e)});l&&this._freezeDownSubs.add(l);const c=r==null?void 0:r.onPointerDown$.subscribeEvent(d=>{this._freezeDown(d,t,r,e)});c&&this._freezeDownSubs.add(c)}_getCurrentLastVisible(){var C,I,R,w,M,y,P;const e=this._getSheetObject();if(e==null)return;const t=(C=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:C.skeleton;if(t==null)return;const r=e.scene,o=Math.max(r.scaleX,r.scaleY),s=this._scrollManagerService.getCurrentScrollState(),l=(e.engine.height-t.columnHeaderHeight)/o,c=(e.engine.width-t.rowHeaderWidth)/o,d=(I=s==null?void 0:s.sheetViewStartRow)!=null?I:0,u=d===0?-((R=s==null?void 0:s.offsetY)!=null?R:0):t.rowHeightAccumulation[d-1]-((w=s==null?void 0:s.offsetY)!=null?w:0);let h=0,g=!1;for(let x=d,A=t.rowHeightAccumulation.length;x<A;x++)if(t.rowHeightAccumulation[x]-u>l){h=x,g=!0;break}g||(h=t.rowHeightAccumulation.length-1);const S=(M=s==null?void 0:s.sheetViewStartColumn)!=null?M:0,f=S===0?-((y=s==null?void 0:s.offsetX)!=null?y:0):t.columnWidthAccumulation[S-1]-((P=s==null?void 0:s.offsetX)!=null?P:0);let p=0,v=!1;for(let x=S,A=t.columnWidthAccumulation.length;x<A;x++)if(t.columnWidthAccumulation[x]-f>c){p=x,v=!0;break}return v||(p=t.columnWidthAccumulation.length-1),{lastRow:h,lastColumn:p}}_getActiveViewport(e){var r;const t=(r=this._getSheetObject())==null?void 0:r.scene.getViewports();return t&&t.find(o=>o.isHit(new T.Vector2(e.offsetX,e.offsetY)))||null}_freezeDown(e,t,r,o=0){var f;const s=(f=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:f.skeleton;if(s==null)return;const l=this._getSheetObject();if(l==null)return;if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;const{scene:d}=l;d.setCursor(T.CURSOR_TYPE.GRABBING),d.disableObjectsEvent();const u=this._getCurrentLastVisible(),h=u===void 0?Number.POSITIVE_INFINITY:s.rowHeightAccumulation[u.lastRow],g=u===void 0?Number.POSITIVE_INFINITY:s.columnWidthAccumulation[u.lastColumn-1]+s.rowHeaderWidth;this._activeViewport=null;const S=this._getFreeze();S&&(this._changeToColumn=S.startColumn,this._changeToRow=S.startRow),this._scenePointerMoveSub=d.onPointerMove$.subscribeEvent(p=>{var P,x,A,k;const v=this._getActiveViewport(p),{startX:C,startY:I,row:R,column:w}=qe(p.offsetX,p.offsetY,d,s,v||void 0,!0);if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;d.setCursor(T.CURSOR_TYPE.GRABBING);const y=io/Math.max(d.scaleX,d.scaleY);o===0?((P=t.transformByState({top:Math.min(I,h)-y/2}))==null||P.setProps({fill:this._freezeActiveColor}),(x=r.transformByState({top:Math.min(I,h)-y/2}))==null||x.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=u===void 0?R:Math.min(R,u.lastRow),this._changeToOffsetY=Math.min(I,h),this._activeViewport=v):((A=t.transformByState({left:Math.min(C,g)-y/2}))==null||A.setProps({fill:this._freezeActiveColor}),(k=r.transformByState({left:Math.min(C,g)-y/2}))==null||k.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=u===void 0?w:Math.min(w,u.lastColumn),this._changeToOffsetX=C,this._activeViewport=v)}),this._scenePointerUpSub=d.onPointerUp$.subscribeEvent(()=>{var D,H;d.resetCursor(),d.enableObjectsEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:p,columnHeaderHeightAndMarginTop:v}=s;o===0&&(this._changeToRow===0||this._changeToRow===-1)||o===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(t.setProps({fill:this._freezeNormalHeaderColor}),r.setProps({fill:this._freezeNormalMainColor})):(t==null||t.setProps({fill:this._freezeNormalHeaderColor}),r==null||r.setProps({fill:this._freezeNormalHeaderColor}));const C=io/Math.max(d.scaleX,d.scaleY);o===0?(this._changeToRow===0||this._changeToRow===-1)&&(t.transformByState({top:v-C}),r.transformByState({top:v-C})):(this._changeToColumn===0||this._changeToColumn===-1)&&(t.transformByState({left:p-C}),r.transformByState({left:p-C}));const I=this._scrollManagerService.getCurrentScrollState()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:R,sheetViewStartColumn:w}=I;if(w==null||R==null)return;const M=this._context.unit,y=M.getActiveSheet();if(!y)return;const P=(D=y.getConfig())==null?void 0:D.freeze;let x=(P==null?void 0:P.xSplit)||0,A=(P==null?void 0:P.ySplit)||0;const k=(H=this._activeViewport)==null?void 0:H.viewportKey;o===0&&(!k||k===T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP?A=this._changeToRow-(P.startRow-P.ySplit):A=this._changeToRow-R,A=A<0?0:A),o===1&&(!k||k===T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT||k===T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT?x=this._changeToColumn-(P.startColumn-P.xSplit):x=this._changeToColumn-w,x=x<0?0:x),this._commandService.executeCommand(m.SetFrozenCommand.id,{startRow:A===0?-1:this._changeToRow,startColumn:x===0?-1:this._changeToColumn,ySplit:A,xSplit:x,unitId:M.getUnitId(),subUnitId:y.getSheetId()})})}_getViewports(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e,r=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT),o=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT),s=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP),l=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM),c=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP),d=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),u=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP),h=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT),g=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(!(r==null||o==null||s==null||l==null||c==null||d==null||u==null||h==null||g==null))return{viewMain:d,viewMainLeftTop:u,viewMainLeft:h,viewMainTop:g,viewColumnLeft:r,viewColumnRight:o,viewRowTop:s,viewRowBottom:l,viewLeftTop:c}}_bindViewportScroll(){const e=this._getViewports();if(!e)return;const{viewRowBottom:t,viewColumnRight:r,viewMainLeft:o,viewMainTop:s}=e;this.disposeWithMe(this._scrollManagerService.validViewportScrollInfo$.subscribe(l=>{if(!l)return;const{scrollX:c,scrollY:d,viewportScrollX:u,viewportScrollY:h}=l;t.isActive&&t.updateScrollVal({scrollY:d,viewportScrollY:h}),r.isActive&&r.updateScrollVal({scrollX:c,viewportScrollX:u}),o.isActive&&o.updateScrollVal({scrollY:d,viewportScrollY:h}),s.isActive&&s.updateScrollVal({scrollX:c,viewportScrollX:u})}))}_updateViewport(e=-1,t=-1,r=0,o=0,s=3){var x;const l=(x=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:x.skeleton;if(l==null)return;const{rowHeaderWidthAndMarginLeft:c,columnHeaderHeightAndMarginTop:d}=l,u=this._getViewports();if(!u)return;const{viewMain:h,viewMainLeftTop:g,viewMainLeft:S,viewMainTop:f,viewColumnLeft:p,viewColumnRight:v,viewRowTop:C,viewRowBottom:I,viewLeftTop:R}=u;v.resizeWhenFreezeChange({left:c,top:0,height:d+1,right:0}),I.resizeWhenFreezeChange({left:0,top:d,bottom:0,width:c+1}),R.resizeWhenFreezeChange({left:0,top:0,width:c+1,height:d});let w=!0,M=!0;g.enable(),(e===-1||e===0)&&(w=!1),(t===-1||t===0)&&(M=!1);const y=l.getNoMergeCellWithCoordByIndex(e-r,t-o,!1),P=l.getNoMergeCellWithCoordByIndex(e,t,!1);if(g.disable(),f.disable(),S.disable(),C.disable(),p.disable(),g.resetPadding(),f.resetPadding(),S.resetPadding(),C.resetPadding(),p.resetPadding(),w===!1&&M===!1)h.resizeWhenFreezeChange({left:c,top:d,bottom:0,right:0}),h.resetPadding(),S.resizeWhenFreezeChange({left:c,top:d,bottom:0,width:0}),f.resizeWhenFreezeChange({left:c,top:d,height:0,right:0}),g.resizeWhenFreezeChange({left:c,top:d,width:0,height:0}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:0}),p.resizeWhenFreezeChange({left:0,top:0,height:d+1,width:0});else if(w===!0&&M===!1){const A=P.startY-y.startY;h.resizeWhenFreezeChange({left:c,top:d+A,bottom:0,right:0}),h.setPadding({startY:y.startY,endY:P.startY,startX:0,endX:0}),s&2&&this._commandService.executeCommand(ze.id,{sheetViewStartRow:0,offsetY:0}),f.resizeWhenFreezeChange({left:c,top:d,height:A,right:0}),f.updateScrollVal({viewportScrollY:y.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:A}),C.updateScrollVal({viewportScrollY:y.startY}),I.resizeWhenFreezeChange({left:0,top:d+A,bottom:0,width:c+1}),f.enable(),C.enable()}else if(w===!1&&M===!0){const A=P.startX-y.startX;h.resizeWhenFreezeChange({left:c+A,top:d,bottom:0,right:0}),h.setPadding({startX:y.startX,endX:P.startX,startY:0,endY:0}),s&1&&this._commandService.executeCommand(ze.id,{sheetViewStartColumn:0,offsetX:0}),S.resizeWhenFreezeChange({left:c,top:d,width:A,bottom:0,right:0}),S.updateScrollVal({viewportScrollX:y.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),p.resizeWhenFreezeChange({left:c,top:0,width:A,height:d+1}),p.updateScrollVal({viewportScrollX:y.startX}),v.resizeWhenFreezeChange({left:c+A,top:0,height:d+1,right:0}),S.enable(),p.enable()}else{const A=P.startX-y.startX,k=P.startY-y.startY;h.resizeWhenFreezeChange({left:c+A,top:d+k,bottom:0,right:0}),h.setPadding({startY:y.startY,endY:P.startY,startX:y.startX,endX:P.startX}),s&&this._commandService.executeCommand(ze.id,{...s&1?{sheetViewStartColumn:0,offsetX:0}:null,...s&2?{sheetViewStartRow:0,offsetY:0}:null}),S.resizeWhenFreezeChange({left:c,top:d+k,width:A,bottom:0}),S.updateScrollVal({viewportScrollX:y.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),f.resizeWhenFreezeChange({left:c+A,top:d,height:k,right:0}),f.updateScrollVal({viewportScrollY:y.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),g.resizeWhenFreezeChange({left:c,top:d,width:A,height:k}),g.updateScrollVal({viewportScrollX:y.startX,viewportScrollY:y.startY}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:k}),C.updateScrollVal({viewportScrollY:y.startY}),I.resizeWhenFreezeChange({left:0,top:d+k,bottom:0,width:c+1}),p.resizeWhenFreezeChange({left:c,top:0,width:A,height:d+1}),p.updateScrollVal({viewportScrollX:y.startX}),v.resizeWhenFreezeChange({left:c+A,top:0,height:d+1,right:0}),g.enable(),f.enable(),S.enable(),C.enable(),p.enable()}}_skeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{[m.SetWorksheetActiveOperation.id,m.InsertRangeMoveDownCommand.id,m.InsertRangeMoveRightCommand.id].includes((e==null?void 0:e.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const t=this._context.unit.getActiveSheet();if(!t)return;const r=t.getConfig().freeze,{startRow:o=-1,startColumn:s=-1,ySplit:l=0,xSplit:c=0}=r;this._refreshFreeze(o,s,l,c,0)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(this._themeService.currentTheme$.subscribe(e=>{this._clearFreeze(),this._themeChange(e),this._refreshCurrent()}))}_themeChange(e){this._freezeNormalHeaderColor=e.grey400,this._freezeNormalMainColor=new a.ColorKit(e.grey400).setAlpha(Kg).toRgbString(),this._freezeActiveColor=e.primaryColor,this._freezeHoverColor=e.grey500}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{const t={redos:[],undos:[]},r=this._getFreeze();if(!r)return t;const o=s=>{const l=this._context.unit,c=l.getUnitId(),d=l.getActiveSheet();if(!d)return t;const u=d.getSheetId();this._refreshFreeze(s.startRow,s.startColumn,s.ySplit,s.xSplit,0);const h={...s,unitId:c,subUnitId:u,resetScroll:!1},g=m.SetFrozenMutationFactory(this._injector,h);return{undos:[{id:m.SetFrozenMutation.id,params:g}],redos:[{id:m.SetFrozenMutation.id,params:h}]}};if(e.id===m.InsertRowCommand.id){const s=e.params,{range:l,direction:c}=s,d=l.endRow-l.startRow+1;if(l.startRow+1<r.startRow||l.startRow+1===r.startRow&&c===a.Direction.UP){const u={...r,startRow:Math.max(1,r.startRow+d),ySplit:Math.max(1,r.ySplit+d)};return o(u)}}if(e.id===m.InsertColCommand.id){const s=e.params,{range:l,direction:c}=s,d=l.endColumn-l.startColumn+1;if(l.startColumn+1<r.startColumn||l.startColumn+1===r.startColumn&&c===a.Direction.LEFT){const u={...r,startColumn:Math.max(1,r.startColumn+d),xSplit:Math.max(1,r.xSplit+d)};return o(u)}}if(e.id===m.MoveColsCommand.id){const s=this._selectionManagerService.getCurrentSelections(),{fromRange:{startColumn:l},toRange:{startColumn:c}}=e.params,d=s==null?void 0:s.filter(C=>C.range.rangeType===a.RANGE_TYPE.COLUMN&&C.range.startColumn<=l&&l<=C.range.endColumn);if(!(d!=null&&d.length))return t;const u=d[0].range,h={...u,startColumn:c,endColumn:c+u.endColumn-u.startColumn};if(!r||r.startColumn<=0||u.startColumn>=r.startColumn&&h.startColumn>=r.startColumn||u.startColumn===h.startColumn||u.endColumn<r.startColumn&&h.startColumn<r.startColumn)return t;const g=u.endColumn-u.startColumn+1,S=Math.max(Math.min(r.startColumn,u.endColumn+1)-u.startColumn,0);let f,p;h.startColumn>=r.startColumn?(f=Math.max(r.startColumn-S,1),p=Math.max(r.xSplit-S,1)):(f=r.startColumn+g-S,p=r.xSplit+g-S);const v={...r,startColumn:f,xSplit:p};return o(v)}if(e.id===m.MoveRowsCommand.id){const s=this._selectionManagerService.getCurrentSelections(),{fromRange:{startRow:l},toRange:{startRow:c}}=e.params,d=s==null?void 0:s.filter(C=>C.range.rangeType===a.RANGE_TYPE.ROW&&C.range.startRow<=l&&l<=C.range.endRow);if(!(d!=null&&d.length))return t;const u=d[0].range,h={...u,startRow:c,endRow:c+u.endRow-u.startRow};if(!r||r.startRow<=0||u.startRow>=r.startRow&&h.startRow>=r.startRow||u.startRow===h.startRow||u.endRow<r.startRow&&h.startRow<r.startRow)return t;const g=u.endRow-u.startRow+1,S=Math.max(Math.min(r.startRow,u.endRow+1)-u.startRow,0);let f,p;h.startRow>=r.startRow?(f=Math.max(r.startRow-S,1),p=Math.max(r.ySplit-S,1)):(f=r.startRow+g-S,p=r.ySplit+g-S);const v={...r,startRow:f,ySplit:p};return o(v)}if(e.id===m.RemoveColCommand.id||e.id===m.RemoveRowCommand.id){const s=e.params,l=s.range;if(l.rangeType===a.RANGE_TYPE.COLUMN&&l.startColumn<r.startColumn){const c=Math.min(r.startColumn,l.endColumn+1)-l.startColumn,d={...r,startColumn:Math.max(1,r.startColumn-c),xSplit:Math.max(1,r.xSplit-c)};return o(d)}if(s.range.rangeType===a.RANGE_TYPE.ROW&&l.startRow<r.startRow){const c=Math.min(r.startRow,l.endRow+1)-l.startRow,d={...r,startRow:Math.max(1,r.startRow-c),ySplit:Math.max(1,r.ySplit-c)};return o(d)}}return t}}))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{switch(e.id){case m.SetFrozenMutation.id:case Le.id:{const t=this._lastFreeze,r=this._context.unit,o=r.getActiveSheet(),s=e.params,{unitId:l,subUnitId:c}=s;if(!(l===r.getUnitId()&&c===(o==null?void 0:o.getSheetId())))return;const d=o.getConfig().freeze;if(this._lastFreeze=d,d==null)return;let u=0;const{startRow:h=-1,startColumn:g=-1,ySplit:S=0,xSplit:f=0}=d;(!t||t.startRow!==h||t.ySplit!==S)&&(u|=2),(!t||t.startColumn!==g||t.xSplit!==f)&&(u|=1),s.resetScroll===!1&&(u=0),this._refreshFreeze(h,g,S,f,u)}break;case m.SetWorksheetRowHeightMutation.id:{const t=this._getFreeze(),r=t&&e.params.ranges.some(o=>o.startRow<t.startRow);e.params&&r&&this._refreshCurrent()}break;case m.SetWorksheetColWidthMutation.id:{const t=this._getFreeze();e.params&&t&&e.params.ranges.some(r=>r.startColumn<t.startColumn)&&this._refreshCurrent()}break;case m.SetWorksheetRowAutoHeightMutation.id:{const t=e.params,r=this._getFreeze();if(r&&r.startRow>-1&&t.rowsAutoHeightInfo.some(o=>o.row<r.startRow)){const o=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{o.unsubscribe()})})}}break;case m.SetColHiddenMutation.id:case m.SetColVisibleMutation.id:{const t=e.params,r=this._getFreeze(),o=t.ranges;r&&r.startColumn>-1&&o.some(s=>s.startColumn<r.startColumn)&&this._refreshCurrent()}break;case m.SetRowHiddenMutation.id:case m.SetRowVisibleMutation.id:{const t=e.params,r=this._getFreeze(),o=t.ranges;r&&r.startRow>-1&&o.some(s=>s.startRow<r.startRow)&&this._refreshCurrent()}break;case Oi.id:case xi.id:this._refreshCurrent()}}))}_zoomRefresh(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this.disposeWithMe(t.onTransformChange$.subscribeEvent(r=>{[T.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale,T.TRANSFORM_CHANGE_OBSERVABLE_TYPE.all].includes(r.type)&&this._refreshCurrent()}))}_clearObserverEvent(){var t,r;this._getSheetObject()!=null&&((t=this._scenePointerMoveSub)==null||t.unsubscribe(),(r=this._scenePointerUpSub)==null||r.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null)}_clearFreeze(){var t,r,o,s,l,c;(t=this._rowFreezeHeaderRect)==null||t.dispose(),(r=this._rowFreezeMainRect)==null||r.dispose(),(o=this._columnFreezeHeaderRect)==null||o.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose(),this._getSheetObject()!=null&&([this._freezeDownSubs,this._freezePointerEnterSubs,this._freezePointerLeaveSubs].forEach(d=>{d==null||d.unsubscribe()}),this._freezeDownSubs=null,this._freezePointerEnterSubs=null,this._freezePointerLeaveSubs=null,(l=this._scenePointerMoveSub)==null||l.unsubscribe(),(c=this._scenePointerUpSub)==null||c.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null)}_getPositionByIndex(e,t){var d;if(this._getSheetObject()==null)return;const o=(d=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:d.skeleton,s=o==null?void 0:o.getNoMergeCellWithCoordByIndex(e,t);if(o==null)return;if(s!=null&&(!isNaN(s.endX)||!isNaN(s.endY)))return s;const{rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:c}=o;return{startX:l,endX:l,startY:c,endY:c}}_getFreeze(){var t;const e=(t=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:t.skeleton.getWorksheetConfig();if(e!=null)return e.freeze}_getSheetObject(){return Ge(this._context.unit,this._context)}_refreshFreeze(e,t,r,o,s){var c;const l={startRow:e,startColumn:t,ySplit:r,xSplit:o};this._clearFreeze(),this._createFreeze(0,l),this._createFreeze(1,l),this._updateViewport(e,t,r,o,s),(c=this._getSheetObject())==null||c.spreadsheet.makeForceDirty()}};exports.HeaderFreezeRenderController=zg([xt(1,a.Inject(exports.SheetSkeletonManagerService)),xt(2,a.ICommandService),xt(3,a.Inject(m.SheetsSelectionsService)),xt(4,a.Inject(exports.SheetScrollManagerService)),xt(5,a.Inject(a.ThemeService)),xt(6,a.Inject(m.SheetInterceptorService)),xt(7,a.Inject(a.Injector))],exports.HeaderFreezeRenderController);function qg(n){const i=n.get(m.SheetsSelectionsService),e=n.get(m.RangeProtectionRuleModel),t=n.get(a.IUniverInstanceService),r=n.get(m.MergeCellController),o=t.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET);return O.combineLatest([i.selectionMoveEnd$,o.pipe(O.map(s=>{var l;return(l=s==null?void 0:s.getUnitId())!=null?l:""})),o.pipe(O.switchMap(s=>{var l;return(l=s==null?void 0:s.activeSheet$)!=null?l:O.of(null)}))]).pipe(O.map(([s,l,c])=>{if(!c||!s||s.length===0)return!1;const d=c.getSheetId(),u=s.map(S=>S.range);if(r.interceptor.fetchThroughInterceptors(m.MERGE_CELL_INTERCEPTOR_CHECK)(!1,u))return!0;const g=e.getSubunitRuleList(l,d).map(S=>S.ranges).flat();if(s.length<2){const S=s[0].range;return g.some(p=>a.Rectangle.intersects(p,S)&&!a.Rectangle.contains(p,S))}for(let S=0;S<s.length;S++)for(let f=S+1;f<s.length;f++)if(a.Rectangle.intersects(s[S].range,s[f].range))return!0;return!1}))}function Bl(n,i){return!!ir(n,i,a.RANGE_TYPE.ROW)}function Fl(n,i){return!!ir(n,i,a.RANGE_TYPE.COLUMN)}function ir(n,i,e){return n.find(r=>{const o=r.range,{startRow:s,endRow:l,startColumn:c,endColumn:d,rangeType:u}=o;return u===a.RANGE_TYPE.ALL||u===a.RANGE_TYPE.NORMAL?!1:u===e&&(e===a.RANGE_TYPE.COLUMN&&c<=i&&i<=d||e===a.RANGE_TYPE.ROW&&s<=i&&i<=l)})}var Qg=Object.getOwnPropertyDescriptor,Jg=(n,i,e,t)=>{for(var r=t>1?void 0:t?Qg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},oo=(n,i)=>(e,t)=>i(e,t,n);const $g="__SpreadsheetHeaderMoveControllerBackground__",eS="__SpreadsheetHeaderMoveControllerShapeLine__",tS="rgba(0, 0, 0, 0.1)",nS="rgb(119, 119, 119)",rS=4,so=a.createInterceptorKey("headerMovePermissionCheck");exports.HeaderMoveRenderController=class extends a.Disposable{constructor(e,t,r,o){super();E(this,"_startOffsetX",Number.NEGATIVE_INFINITY);E(this,"_startOffsetY",Number.NEGATIVE_INFINITY);E(this,"_moveHelperBackgroundShape");E(this,"_moveHelperLineShape");E(this,"_headerPointerDownSubs");E(this,"_headerPointerMoveSubs");E(this,"_headerPointerLeaveSubs");E(this,"_dragHeaderMoveSub");E(this,"_scenePointerUpSub");E(this,"_scrollTimer");E(this,"_changeFromColumn",-1);E(this,"_changeFromRow",-1);E(this,"_changeToColumn",-1);E(this,"_changeToRow",-1);E(this,"interceptor",new a.InterceptorManager({HEADER_MOVE_PERMISSION_CHECK:so}));E(this,"_workbookSelections");this._context=e,this._sheetSkeletonManagerService=r,this._commandService=o,this._workbookSelections=t.getWorkbookSelections(this._context.unitId),this._init()}dispose(){var e,t,r,o,s,l,c,d;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose(),(r=this._headerPointerMoveSubs)==null||r.unsubscribe(),(o=this._headerPointerLeaveSubs)==null||o.unsubscribe(),(s=this._headerPointerDownSubs)==null||s.unsubscribe(),this._headerPointerMoveSubs=null,this._headerPointerLeaveSubs=null,this._headerPointerDownSubs=null,(l=this._dragHeaderMoveSub)==null||l.unsubscribe(),(c=this._scenePointerUpSub)==null||c.unsubscribe(),this._dragHeaderMoveSub=null,this._scenePointerUpSub=null,(d=this._scrollTimer)==null||d.dispose()}_init(){this._initialRowOrColumn(a.RANGE_TYPE.ROW),this._initialRowOrColumn(a.RANGE_TYPE.COLUMN)}_initialRowOrColumn(e=a.RANGE_TYPE.ROW){const t=this._context.components.get(he.COLUMN),r=this._context.components.get(he.ROW),o=this._context.scene,s=e===a.RANGE_TYPE.ROW?r:t,l=u=>{var I,R;const h=(I=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:I.skeleton;if(h==null)return;const g=(R=this._workbookSelections.getCurrentLastSelection())==null?void 0:R.range;if(!g||!this.interceptor.fetchThroughInterceptors(so)(!1,g))return;const f=this._workbookSelections.getCurrentSelections(),{row:p,column:v}=qe(u.offsetX,u.offsetY,o,h);if(!ir(f,e===a.RANGE_TYPE.ROW?p:v,e)){o.resetCursor();return}o.setCursor(T.CURSOR_TYPE.GRAB)},c=()=>{var u,h;(u=this._moveHelperBackgroundShape)==null||u.hide(),(h=this._moveHelperLineShape)==null||h.hide(),o.resetCursor()},d=(u,h)=>{var W,N;if(h.isStopPropagation)return;const g=(W=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:W.skeleton;if(g==null)return;const S=(N=this._workbookSelections.getCurrentLastSelection())==null?void 0:N.range;if(!S||!this.interceptor.fetchThroughInterceptors(so)(!1,S))return;const{offsetX:p,offsetY:v}=u,C=o.getCoordRelativeToViewport(T.Vector2.FromArray([p,v])),{x:I,y:R}=C;this._startOffsetX=I,this._startOffsetY=R;const{row:w,column:M}=qe(u.offsetX,u.offsetY,o,g);let y;e===a.RANGE_TYPE.ROW?(this._changeFromRow=w,y=T.ScrollTimerType.Y):(this._changeFromColumn=M,y=T.ScrollTimerType.X);const P=this._workbookSelections.getCurrentSelections(),x=ir(P,e===a.RANGE_TYPE.ROW?w:M,e);if(!x)return;const A=o.getScrollXYInfoByViewport(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),o.setCursor(T.CURSOR_TYPE.GRABBING),o.disableObjectsEvent();let k=!1,D;const H=()=>{if(k)return;D=T.ScrollTimer.create(o,y),this._scrollTimer=D;const U=o.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);D.startScroll(I,R,U),k=!0};this._dragHeaderMoveSub=o.onPointerMove$.subscribeEvent(U=>{H();const{offsetX:L,offsetY:F}=U,{x:B,y:j}=o.getCoordRelativeToViewport(T.Vector2.FromArray([L,F]));this._rowColumnMoving(B,j,x,A,e),D.scrolling(B,j,()=>{this._rowColumnMoving(B,j,x,A,e)})}),this._scenePointerUpSub=o.onPointerUp$.subscribeEvent(()=>{var L,F,B;this._disposeBackgroundAndLine(),o.resetCursor(),o.enableObjectsEvent(),this._clearObserverEvent(),(L=this._scrollTimer)==null||L.dispose();const U=this._workbookSelections.getCurrentSelections();if(e===a.RANGE_TYPE.ROW){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const z=(F=((U==null?void 0:U.filter(K=>K.range.rangeType===a.RANGE_TYPE.ROW&&K.range.startRow<=this._changeFromRow&&this._changeFromRow<=K.range.endRow))||[])[0])==null?void 0:F.range;z&&this._commandService.executeCommand(m.MoveRowsCommand.id,{fromRange:z,toRange:{...z,startRow:this._changeToRow,endRow:this._changeToRow+z.endRow-z.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const z=(B=((U==null?void 0:U.filter(K=>K.range.rangeType===a.RANGE_TYPE.COLUMN&&K.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=K.range.endColumn))||[])[0])==null?void 0:B.range;z&&this._commandService.executeCommand(m.MoveColsCommand.id,{fromRange:z,toRange:{...z,startColumn:this._changeToColumn,endColumn:this._changeToColumn+z.endColumn-z.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})};this._headerPointerMoveSubs=new O.Subscription,this._headerPointerMoveSubs.add(s.onPointerMove$.subscribeEvent(l)),this._headerPointerLeaveSubs=new O.Subscription,this._headerPointerLeaveSubs.add(s==null?void 0:s.onPointerLeave$.subscribeEvent(c)),this._headerPointerDownSubs=new O.Subscription,this._headerPointerDownSubs.add(s==null?void 0:s.onPointerDown$.subscribeEvent(d))}_rowColumnMoving(e,t,r,o,s){var j,z,K,ne,Q,se,ce;const l=this._context.scene,c=(j=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:j.skeleton;if(c==null)return;const{rowHeaderWidth:d,columnHeaderHeight:u,rowTotalHeight:h,columnTotalWidth:g}=c,S=l.getViewportScrollXY(l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN)),{scaleX:f,scaleY:p}=l.getAncestorScale(),v=c.getCellIndexByOffset(e,t,f,p,S),{row:C,column:I}=v,R=c.getNoMergeCellWithCoordByIndex(C,I),{startX:w,startY:M,endX:y,endY:P}=R,x=this._sheetSkeletonManagerService.attachRangeWithCoord(r.range);if(x==null)return;const A=Math.max(f,f),{startX:k,endX:D,startY:H,endY:W,startRow:N,startColumn:U,endRow:L,endColumn:F}=x;s===a.RANGE_TYPE.ROW?(z=this._moveHelperBackgroundShape)==null||z.transformByState({height:W-H,width:g+d,left:0,top:H+(t-this._startOffsetY)/A+S.y-o.y}):(K=this._moveHelperBackgroundShape)==null||K.transformByState({height:h+u,width:D-k,left:k+(e-this._startOffsetX)/A+S.x-o.x,top:0}),(ne=this._moveHelperBackgroundShape)==null||ne.show();const B=rS/A;if(s===a.RANGE_TYPE.ROW){let X=0;if(C<=N)X=M-B/2,this._changeToRow=C;else if(C>L)X=P-B/2,this._changeToRow=C+1;else return;(Q=this._moveHelperLineShape)==null||Q.transformByState({height:B,width:g,left:d,top:X})}else{let X=0;if(I<=U)X=w-B/2,this._changeToColumn=I;else if(I>F)X=y-B/2,this._changeToColumn=I+1;else return;(se=this._moveHelperLineShape)==null||se.transformByState({height:h,width:B,left:X,top:u})}(ce=this._moveHelperLineShape)==null||ce.show()}_clearObserverEvent(){var e,t;(e=this._dragHeaderMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._dragHeaderMoveSub=null,this._scenePointerUpSub=null}_newBackgroundAndLine(){const e=this._context.scene;this._moveHelperBackgroundShape=new T.Rect($g,{fill:tS,evented:!1,zIndex:100}),this._moveHelperLineShape=new T.Rect(eS,{fill:nS,evented:!1,zIndex:100}),e.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],bt)}_disposeBackgroundAndLine(){var e,t;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose()}};exports.HeaderMoveRenderController=Jg([oo(1,a.Inject(m.SheetsSelectionsService)),oo(2,a.Inject(exports.SheetSkeletonManagerService)),oo(3,a.ICommandService)],exports.HeaderMoveRenderController);var Go=(n=>(n[n.VERTICAL=0]="VERTICAL",n[n.HORIZONTAL=1]="HORIZONTAL",n))(Go||{});const iS="rgba(120, 120, 120, 0.01)",ao="rgb(68, 71, 70)",Zn=12,oS=44,Zo=4;class ba extends T.Shape{constructor(e,t){super(e,t);E(this,"_size",Zn);E(this,"_color",ao);E(this,"_mode",0);this.setShapeProps(t)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(e){const t=this.getScene();if(!t)return;const{scaleX:r,scaleY:o}=t.getAncestorScale(),s=Math.max(r,o),l=Zn/s,c=Zo/s;let{width:d,height:u}=this,h=0,g=0;this.mode===0?(d=c,h=l-c):(u=c,g=l-c),T.Rect.drawWith(e,{width:this.width,height:this.height,left:0,top:0,fill:iS}),T.Rect.drawWith(e,{width:d,height:u,fill:ao,radius:c}),e.save(),e.transform(1,0,0,1,h,g),T.Rect.drawWith(e,{width:d,height:u,fill:ao,radius:c}),e.restore()}setShapeProps(e){return e!=null&&e.size&&(this._size=e.size),e!=null&&e.mode&&(this._mode=e.mode),e!=null&&e.color&&(this._color=e.color),this.mode===0?this.transformByState({width:Zn,height:this.size}):this.transformByState({width:this.size,height:Zn}),this}}var sS=Object.getOwnPropertyDescriptor,aS=(n,i,e,t)=>{for(var r=t>1?void 0:t?sS(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},lo=(n,i)=>(e,t)=>i(e,t,n);const lS="__SpreadsheetHeaderResizeControllerShapeRow__",cS="__SpreadsheetHeaderResizeControllerShapeColumn__",Ra="__SpreadsheetHeaderResizeControllerShapeHelper__",Ea="rgb(199, 199, 199)",dS=2,co=a.createInterceptorKey("headerResizePermissionCheck");exports.HeaderResizeRenderController=class extends a.Disposable{constructor(e,t,r,o){super();E(this,"_currentRow",0);E(this,"_currentColumn",0);E(this,"_rowResizeRect");E(this,"_columnResizeRect");E(this,"_headerPointerSubs");E(this,"_scenePointerMoveSub");E(this,"_scenePointerUpSub");E(this,"_resizeHelperShape");E(this,"_startOffsetX",Number.POSITIVE_INFINITY);E(this,"_startOffsetY",Number.POSITIVE_INFINITY);E(this,"interceptor",new a.InterceptorManager({HEADER_RESIZE_PERMISSION_CHECK:co}));this._context=e,this._sheetSkeletonManagerService=t,this._selectionManagerService=r,this._commandService=o,this._init()}dispose(){var e,t,r;(e=this._rowResizeRect)==null||e.dispose(),this._rowResizeRect=null,(t=this._columnResizeRect)==null||t.dispose(),this._columnResizeRect=null,(r=this._headerPointerSubs)==null||r.unsubscribe(),this._headerPointerSubs=null}_init(){const e=this._context.scene;this._rowResizeRect=new ba(lS,{visible:!1,mode:Go.HORIZONTAL,zIndex:100}),this._columnResizeRect=new ba(cS,{visible:!1,mode:Go.VERTICAL,zIndex:100}),e.addObjects([this._rowResizeRect,this._columnResizeRect],bt),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(e=0){const t=this._context.components.get(he.COLUMN),r=this._context.components.get(he.ROW),o=this._context.scene,s=e===0?r:t,l=(d,u)=>{var h,g;(h=this._rowResizeRect)==null||h.hide(),(g=this._columnResizeRect)==null||g.hide()},c=(d,u)=>{var A;const h=(A=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:A.skeleton;if(h==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:g,columnHeaderHeight:S}=h,{startX:f,startY:p,endX:v,endY:C,row:I,column:R}=qe(d.offsetX,d.offsetY,o,h),w=Qn(d.offsetX,d.offsetY,o),{scaleX:M,scaleY:y}=o.getAncestorScale(),P=Math.max(M,y),x=Zn/P;if(e===0){let k=p-x/2;if(w.y<=p+x/2&&w.y>=p)this._currentRow=I-1;else if(w.y>=C-x/2&&w.y<=C)this._currentRow=I,k=C-x/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;if(!this.interceptor.fetchThroughInterceptors(co)(null,{row:this._currentRow}))return!1;const H=Math.min(oS,g/3);this._rowResizeRect.transformByState({left:g/2-H/2,top:k}),this._rowResizeRect.setShapeProps({size:H}),this._rowResizeRect.show()}else{let k=f-x/2;if(w.x<=f+x/2&&w.x>=f)this._currentColumn=R-1;else if(w.x>=v-x/2&&w.x<=v)this._currentColumn=R,k=v-x/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;if(!this.interceptor.fetchThroughInterceptors(co)(null,{col:this._currentColumn}))return!1;const H=S*.7;this._columnResizeRect.transformByState({left:k,top:S/2-H/2}),this._columnResizeRect.setShapeProps({size:H}),this._columnResizeRect.show()}};this._headerPointerSubs=new O.Subscription,this._headerPointerSubs.add(s==null?void 0:s.onPointerMove$.subscribeEvent(c)),this._headerPointerSubs.add(s==null?void 0:s.onPointerLeave$.subscribeEvent(l))}_initialHoverResize(e=0){const t=this._context.scene,r=e===0?this._rowResizeRect:this._columnResizeRect;r!=null&&(this.disposeWithMe(r.onPointerEnter$.subscribeEvent(()=>{r!=null&&(r.show(),t.setCursor(e===0?T.CURSOR_TYPE.ROW_RESIZE:T.CURSOR_TYPE.COLUMN_RESIZE))})),this.disposeWithMe(r.onPointerLeave$.subscribeEvent(()=>{r!=null&&(r.hide(),t.resetCursor())})),this.disposeWithMe(r.onPointerDown$.subscribeEvent(o=>{var F,B,j,z,K,ne,Q;const s=(F=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:F.skeleton;if(s==null)return;const l=this._context.scene,c=l.getEngine(),d=(c==null?void 0:c.height)||0,u=(c==null?void 0:c.width)||0,h=l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),g=(((j=(B=h==null?void 0:h.getScrollBar())==null?void 0:B.horizonScrollTrack)==null?void 0:j.height)||0)+10,S=(((K=(z=h==null?void 0:h.getScrollBar())==null?void 0:z.verticalScrollTrack)==null?void 0:K.width)||0)+10,f=Qn(o.offsetX,o.offsetY,l),{scaleX:p,scaleY:v}=l.getAncestorScale();this._startOffsetX=f.x,this._startOffsetY=f.y;const C=s.getOffsetByColumn(this._currentColumn),I=s.getOffsetByRow(this._currentRow),R=s.getNoMergeCellWithCoordByIndex(this._currentRow,this._currentColumn);let w=!1,M=0,y=0;const{columnTotalWidth:P,rowHeaderWidth:x,rowTotalHeight:A,columnHeaderHeight:k}=s,D=u>P+x?u:P+x,H=d>A+k?d:A+k,W=Math.max(p,v),N=Zo/W;e===0?this._resizeHelperShape=new T.Rect(Ra,{width:D,height:N,fill:Ea,left:0,top:I-N/2}):this._resizeHelperShape=new T.Rect(Ra,{width:N,height:H,fill:Ea,left:C-N/2,top:0});const U=((ne=this._columnResizeRect)==null?void 0:ne.left)||0,L=((Q=this._rowResizeRect)==null?void 0:Q.top)||0;l.addObject(this._resizeHelperShape,bt),l.disableObjectsEvent(),this._scenePointerMoveSub=l.onPointerMove$.subscribeEvent(se=>{var fe,Te,we,Fe,St,Mt;const ce=l.getCoordRelativeToViewport(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),X=l.getScrollXYInfoByViewport(ce,h),G=Qn(se.offsetX,se.offsetY,l),{x:q,y:ie}=G,{scaleX:oe,scaleY:$}=l.getAncestorScale(),J=Math.max(oe,$),de=Zo/J;M=q-this._startOffsetX-de/2,y=ie-this._startOffsetY-de/2,Math.abs(e===0?y:M)>=dS&&(w=!0),e===0?(y>d-g+X.y-R.startY&&(y=d-g+X.y-R.startY),y<-(R.endY-R.startY)+2&&(y=-(R.endY-R.startY)+2),w&&((fe=this._resizeHelperShape)==null||fe.transformByState({top:I+y}),(Te=this._rowResizeRect)==null||Te.transformByState({top:L+y+de/2}),(we=this._rowResizeRect)==null||we.show(),l.setCursor(T.CURSOR_TYPE.ROW_RESIZE))):(M>u-S+X.x-R.startX&&(M=u-S+X.x-R.startX),M<-(R.endX-R.startX)+2&&(M=-(R.endX-R.startX)+2),w&&((Fe=this._resizeHelperShape)==null||Fe.transformByState({left:C+M}),(St=this._columnResizeRect)==null||St.transformByState({left:U+M+de/2}),(Mt=this._columnResizeRect)==null||Mt.show(),l.setCursor(T.CURSOR_TYPE.COLUMN_RESIZE)))}),this._scenePointerUpSub=l.onPointerUp$.subscribeEvent(se=>{var X,G,q;const ce=this._context.scene;this._clearObserverEvent(),(X=this._resizeHelperShape)==null||X.dispose(),this._resizeHelperShape=null,ce.enableObjectsEvent(),w&&(ce.resetCursor(),(G=this._rowResizeRect)==null||G.hide(),(q=this._columnResizeRect)==null||q.hide(),e===0?this._commandService.executeCommand(m.DeltaRowHeightCommand.id,{deltaY:y,anchorRow:this._currentRow}):this._commandService.executeCommand(m.DeltaColumnWidthCommand.id,{deltaX:M,anchorCol:this._currentColumn}))})})),this.disposeWithMe(r.onDblclick$.subscribeEvent(()=>{var h,g,S;this._context.scene.resetCursor();const s=(h=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:h.skeleton;if(!s)return;const l=0,c=0,d=s.worksheet.getRowCount()-1||0,u=s.worksheet.getColumnCount()-1||0;switch(e){case 1:{const f=this._selectionManagerService.getCurrentSelections(),p=[];for(let v=0;v<f.length;v++){const C=f[v];C.range.rangeType===a.RANGE_TYPE.COLUMN&&this._currentColumn<=C.range.endColumn&&this._currentColumn>=C.range.startColumn&&p.push({startColumn:C.range.startColumn,endColumn:C.range.endColumn,startRow:l,endRow:d})}p.length===0&&p.push({startColumn:this._currentColumn,endColumn:this._currentColumn,startRow:l,endRow:d}),this._commandService.executeCommand(Er.id,{ranges:p}),(g=this._columnResizeRect)==null||g.hide();break}case 0:this._commandService.executeCommand(m.SetWorksheetRowIsAutoHeightCommand.id,{ranges:[{startRow:this._currentRow,endRow:this._currentRow,startColumn:c,endColumn:u}]}),(S=this._rowResizeRect)==null||S.hide();break}})))}_clearObserverEvent(){var e,t;(e=this._scenePointerMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null}};exports.HeaderResizeRenderController=aS([lo(1,a.Inject(exports.SheetSkeletonManagerService)),lo(2,a.Inject(m.SheetsSelectionsService)),lo(3,a.ICommandService)],exports.HeaderResizeRenderController);var uS=Object.getOwnPropertyDescriptor,hS=(n,i,e,t)=>{for(var r=t>1?void 0:t?uS(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Lr=(n,i)=>(e,t)=>i(e,t,n);const mS=60;exports.SheetRenderController=class extends a.RxDisposable{constructor(e,t,r,o,s){super();E(this,"_renderMetric$",new O.Subject);E(this,"renderMetric$",this._renderMetric$.asObservable());E(this,"_renderFrameTimeMetric",null);E(this,"_renderFrameTags",{});E(this,"_afterRenderMetric$",new O.Subject);this._context=e,this._sheetSkeletonManagerService=t,this._sheetRenderService=r,this._commandService=o,this._telemetryService=s,this._addNewRender(),this._initRenderMetricSubscriber()}_addNewRender(){const{scene:e,engine:t,unit:r}=this._context;this._addComponent(r),this._initRerenderScheduler(),this._initCommandListener();const o=this._context.unit.getActiveSheet();if(!o)throw new Error("No active sheet found");const s=o.getSheetId();this._sheetSkeletonManagerService.setCurrent({sheetId:s});const l=()=>e.render();this.disposeWithMe(this._context.activated$.subscribe(c=>{c?t.runRenderLoop(l):t.stopRenderLoop(l)}))}_initRenderMetricSubscriber(){const{engine:e}=this._context;e.beginFrame$.subscribe(()=>{this._renderFrameTimeMetric=null,this._renderFrameTags={}}),e.endFrame$.subscribe(()=>{this._renderFrameTimeMetric&&Object.keys(this._renderFrameTimeMetric).filter(o=>o.startsWith(T.SHEET_EXTENSION_PREFIX)).length>0&&this._afterRenderMetric$.next({frameTimeMetric:this._renderFrameTimeMetric,tags:this._renderFrameTags})}),e.renderFrameTimeMetric$.subscribe(([r,o])=>{this._renderFrameTimeMetric||(this._renderFrameTimeMetric={}),this._renderFrameTimeMetric[r]||(this._renderFrameTimeMetric[r]=[]),this._renderFrameTimeMetric[r].push(Math.round(o*100)/100)}),e.renderFrameTags$.subscribe(([r,o])=>{this._renderFrameTags[r]=o});const t=[];this._afterRenderMetric$.pipe(O.withLatestFrom(e.endFrame$)).subscribe(([r,o])=>{t.push({FPS:o.FPS,elapsedTime:o.elapsedTime,frameTime:Math.round(o.frameTime*100)/100,...r.frameTimeMetric,...r.tags}),t.length>mS&&(this._captureRenderMetric(t),t.length=0)})}_captureRenderMetric(e){var g;const t=e;if(t.length===0)return;const r=S=>{let f=0;const v=Object.entries(S).filter(([I,R])=>Array.isArray(R)).map(([I])=>I).reduce((I,R)=>{const w=S[R].reduce((M,y)=>M+y,0);return I[R]=w,I},{});return Object.keys(S).filter(I=>I.startsWith(T.SHEET_EXTENSION_PREFIX)).forEach(I=>{f+=v[I]}),{...v,extensionTotal:f}},o=e.map(S=>({...S,...r(S)})),l=(S=>Object.entries(S[0]).filter(([v,C])=>!["elapsedTime"].includes(v)).filter(([v,C])=>typeof C=="number").map(([v])=>v).reduce((v,C)=>{const I=S.map(y=>y[C]),R=Math.max(...I),w=Math.min(...I),M=I.reduce((y,P)=>y+P,0)/I.length;return v[C]={max:Math.round(R*100)/100,min:Math.round(w*100)/100,avg:Math.round(M*100)/100},v},{}))(o),c=t[t.length-1].elapsedTime,d=this._context.unit.getActiveSheet().getSheetId(),u=this._context.unit.getUnitId(),h={sheetId:d,unitId:u,elapsedTimeToStart:c,...l};this._renderMetric$.next(h),(g=this._telemetryService)==null||g.capture("sheet_render_cost",h)}_addComponent(e){const{scene:t,components:r}=this._context,o=e.getActiveSheet(),s=new T.Spreadsheet(he.MAIN);this._addViewport(o);const l=new T.SpreadsheetRowHeader(he.ROW),c=new T.SpreadsheetColumnHeader(he.COLUMN),d=new T.Rect(he.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});this._context.mainComponent=s,r.set(he.MAIN,s),r.set(he.ROW,l),r.set(he.COLUMN,c),r.set(he.LEFT_TOP,d),t.addObjects([s],Bs),t.addObjects([l,c,d],bt),t.enableLayerCache(Bs,bt)}_initViewports(e,t,r){const l=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN,e,{left:t.width,top:r.height,bottom:0,right:0,isWheelPreventDefaultX:!0,allowCache:!0,bufferEdgeX:100,bufferEdgeY:100}),c=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:0}),d=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:100}),u=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:100,bufferEdgeY:0}),h=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP,e,{active:!1,isWheelPreventDefaultX:!0}),g=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM,e,{left:0,top:r.height,bottom:0,width:t.width+1,isWheelPreventDefaultX:!0}),S=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT,e,{active:!1,isWheelPreventDefaultX:!0}),f=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT,e,{left:t.width,top:0,height:r.height+1,right:0,isWheelPreventDefaultX:!0}),p=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP,e,{left:0,top:0,width:t.width,height:r.height,isWheelPreventDefaultX:!0});return{viewMain:l,viewLeftTop:p,viewMainLeftTop:c,viewMainLeft:d,viewMainTop:u,viewColumnLeft:S,viewRowTop:h,viewRowBottom:g,viewColumnRight:f}}_addViewport(e){const t=this._context.scene,{rowHeader:r,columnHeader:o}=e.getConfig(),{viewMain:s}=this._initViewports(t,r,o);return new T.ScrollBar(s),t.attachControl(),s}_initRerenderScheduler(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(!e)return null;const{skeleton:t,sheetId:r}=e,o=this._context.unit,s=o==null?void 0:o.getSheetBySheetId(r);if(o==null||s==null)return;const{mainComponent:l,components:c}=this._context,d=l,u=c.get(he.ROW),h=c.get(he.COLUMN),g=c.get(he.LEFT_TOP),{rowHeaderWidth:S,columnHeaderHeight:f}=t;d==null||d.updateSkeleton(t),u==null||u.updateSkeleton(t),h==null||h.updateSkeleton(t),g==null||g.transformByState({width:S,height:f})}))}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{const{unit:t}=this._context,{id:r}=e;if(m.COMMAND_LISTENER_SKELETON_CHANGE.includes(r)||this._sheetRenderService.checkMutationShouldTriggerRerender(r)){const o=e.params,{unitId:s,subUnitId:l}=o,c=t.getActiveSheet();if(!c)return;const d=this._context.unitId,u=c.getSheetId();if(s!==d||l!==u)return;this._sheetSkeletonManagerService.makeDirty({sheetId:u,commandId:r},!0),this._sheetSkeletonManagerService.setCurrent({sheetId:u,commandId:r})}else m.COMMAND_LISTENER_VALUE_CHANGE.includes(r)&&this._sheetSkeletonManagerService.reCalculate();e.type===a.CommandType.MUTATION&&this._markUnitDirty(e)}))}_markUnitDirty(e){const{mainComponent:t,scene:r}=this._context;if(e.id===Z.SetFormulaCalculationNotificationMutation.id&&e.params.stageInfo!=null||(t&&t.makeDirty(),r.makeDirty(),!e.params))return;const o=e.params,s=this._spreadsheetViewports(r);if(e.id===m.SetRangeValuesMutation.id&&o.cellValue){const l=this._cellValueToRange(o.cellValue),c=this._rangeToBounds([l]);this._markViewportDirty(s,c),t.setDirtyArea(c)}if(e.id===m.MoveRangeMutation.id&&o.from&&o.to){const l=o.fromRange||this._cellValueToRange(o.from.value),c=o.toRange||this._cellValueToRange(o.to.value),d=this._rangeToBounds([l,c]);this._markViewportDirty(s,d),t.setDirtyArea(d)}}_cellValueToRange(e){let t=0,r=0,o=0,s=0;for(const[h,g]of Object.entries(e)){for(const S in g)t>Number(S)&&(t=Number(S)),r<Number(S)&&(r=Number(S));o>Number(h)&&(o=Number(h)),s<Number(h)&&(s=Number(h))}return{startRow:o,endRow:s,startColumn:t,endColumn:r}}_rangeToBounds(e){const t=this._sheetSkeletonManagerService.getCurrentParam().skeleton,{rowHeightAccumulation:r,columnWidthAccumulation:o,rowHeaderWidth:s,columnHeaderHeight:l}=t,c=[];for(const d of e){const{startRow:u,endRow:h,startColumn:g,endColumn:S}=d,f=u===0?0:r[u-1]+l,p=r[h]+l,v=g===0?0:o[g-1]+s,C=o[S]+s;c.push({top:f,left:v,bottom:p,right:C,width:C-v,height:p-f})}return c}_markViewportDirty(e,t){const r=e.filter(o=>o.isActive&&o.cacheBound);for(const o of r)for(const s of t)a.Rectangle.hasIntersectionBetweenTwoRect(o.cacheBound,s)&&o.markDirty(!0)}_spreadsheetViewports(e){return e.getViewports().filter(t=>["viewMain","viewMainLeftTop","viewMainTop","viewMainLeft"].includes(t.viewportKey))}};exports.SheetRenderController=hS([Lr(1,a.Inject(exports.SheetSkeletonManagerService)),Lr(2,a.Inject(exports.SheetsRenderService)),Lr(3,a.ICommandService),Lr(4,a.Optional(md.ITelemetryService))],exports.SheetRenderController);function gS(n,i){if(n.length!==i.length)return!1;const e=n.sort((r,o)=>r.id.localeCompare(o.id)),t=i.sort((r,o)=>r.id.localeCompare(o.id));return e.every((r,o)=>{var s,l;return((s=r.subject)==null?void 0:s.userID)===((l=t[o].subject)==null?void 0:l.userID)&&r.role===t[o].role})}function jl(n,i){return i.some(e=>SS(n,e))}function SS(n,i){const{startRow:e,startColumn:t,endColumn:r,endRow:o}=i,s=n.getMatrixWithMergedCells(e,t,o,r);let l=!1;return s.forValue((c,d,u)=>{if(u&&(c!==e||d!==t)&&n.cellHasValue(u))return l=!0,!1}),l}function zl(n,i,e,t){const r=[],o=[],s=e.getSheetId();return t.forEach(l=>{const c=fS(e,l),d={unitId:i,subUnitId:s,cellValue:c.getData()},u=m.SetRangeValuesUndoMutationFactory(n,d);r.push({id:m.SetRangeValuesMutation.id,params:u}),o.push({id:m.SetRangeValuesMutation.id,params:d})}),{undos:r,redos:o}}function fS(n,i){const{startRow:e,startColumn:t,endColumn:r,endRow:o}=i,s=n.getMatrixWithMergedCells(e,t,o,r,a.CellModeEnum.Intercepted),l=new a.ObjectMatrix;let c=null;return s.forValue((d,u,h)=>{var g,S,f,p;h&&d>=e&&u>=t&&(!c&&n.cellHasValue(h)&&(h.v!==""||((p=(f=(S=(g=h.p)==null?void 0:g.body)==null?void 0:S.dataStream)==null?void 0:f.length)!=null?p:0)>2)&&(c=h),l.setValue(d,u,null))}),l.setValue(e,t,c),l}function pS(n,i,e,t){const r=e.getActiveViewportByCoord(T.Vector2.FromArray([n,i]));if(!r)return;const{scaleX:o,scaleY:s}=e.getAncestorScale(),l={x:r.viewportScrollX,y:r.viewportScrollY},c=t.getCellIndexByOffset(n,i,o,s,l),d=t.worksheet.getMergedCell(c.row,c.column);return{actualRow:d?d.startRow:c.row,actualCol:d?d.startColumn:c.column,mergeCell:d,row:c.row,col:c.column}}function wa(n,i,e,t){const r=t.getFreeze();if(!r||r.startRow<=0&&r.startColumn<=0||n>=r.startRow&&i>=r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(n<r.startRow&&i<r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP);if(n<r.startRow&&i>=r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(n>=r.startRow&&i<r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)}function vS(n,i,e,t){const r=Ta(n.left,n.top,i,e,t),o=Ta(n.right,n.bottom,i,e,t);return{left:r.x,top:r.y,right:o.x,bottom:o.y}}function Ta(n,i,e,t,r){const{scaleX:o,scaleY:s}=e.getAncestorScale(),l=e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(!l)return{x:n,y:i};const c=r.getFreeze(),{startColumn:d,startRow:u,xSplit:h,ySplit:g}=c,S=t.getNoMergeCellWithCoordByIndex(u-g,d-h,!1),f=t.getNoMergeCellWithCoordByIndex(u,d,!1),{rowHeaderWidth:p,columnHeaderHeight:v}=t,C=f.startX-S.startX,I=f.startY-S.startY,{top:R,left:w,viewportScrollX:M,viewportScrollY:y}=l;let P;n>w?P=(n-M)*o:P=(C+p-(w-n))*o;let x;return i>R?x=(i-y)*s:x=(I+v-(R-i))*o,{x:P,y:x}}function Xl(n,i,e,t,r){let o=t,s=r;e.overflowCache.forValue((d,u,h)=>{h.startRow<=o&&h.endRow>=o&&h.startColumn<=s&&h.endColumn>=s&&(s=u,o=d)});const l=e.getCellWithCoordByIndex(o,s);return{unitId:n.getUnitId(),subUnitId:i.getSheetId(),workbook:n,worksheet:i,row:l.actualRow,col:l.actualColumn}}function Yl(n,i,e,t,r,o){const{scene:s}=n,l=i.getUnitId(),{skeleton:c,sheetId:d}=t,u=pS(r,o,s,c);if(!u)return null;let{actualCol:h,actualRow:g}=u;const S={unitId:l,subUnitId:d,workbook:i,worksheet:e,row:g,col:h};c.overflowCache.forValue((y,P,x)=>{x.startRow<=g&&x.endRow>=g&&x.startColumn<=h&&x.endColumn>=h&&(h=P,g=y)});const f=c.getCellWithCoordByIndex(g,h),p=Xl(i,e,c,g,h);let v;f.mergeInfo?v=f.mergeInfo:v={startRow:p.row,endRow:p.row,startColumn:p.col,endColumn:p.col};const C=s.getActiveViewportByCoord(T.Vector2.FromArray([r,o]));if(!C)return;const{scaleX:I,scaleY:R}=s.getAncestorScale(),w={x:C.viewportScrollX,y:C.viewportScrollY};return{position:{startX:(c.getOffsetByColumn(v.startColumn-1)-w.x)*I,endX:(c.getOffsetByColumn(v.endColumn)-w.x)*I,startY:(c.getOffsetByRow(v.startRow-1)-w.y)*R,endY:(c.getOffsetByRow(v.endRow)-w.y)*R},location:S,overflowLocation:p}}const Tt={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(n,i)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),r=n.get(a.IUniverInstanceService),o=n.get(_.IConfirmService),s=n.get(a.LocaleService),l=i.unitId,c=i.subUnitId,d=i.selections,u=m.getAddMergeMutationRangeByType(d,i.value),h=r.getUniverSheetInstance(l).getSheetBySheetId(c),g=[],S=[],f=jl(h,u);if(f&&!i.defaultMerge&&!await o.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:"merge.confirm.title"},cancelText:s.t("merge.confirm.cancel"),confirmText:s.t("merge.confirm.confirm")}))return!1;const p={unitId:l,subUnitId:c,ranges:a.Tools.deepClone(u)},v={unitId:l,subUnitId:c,ranges:a.Tools.deepClone(u)},C=m.RemoveMergeUndoMutationFactory(n,p),I=m.AddMergeUndoMutationFactory(n,v);if(C.ranges.length>0&&g.push({id:m.RemoveWorksheetMergeMutation.id,params:C}),g.push({id:m.AddWorksheetMergeMutation.id,params:v}),S.push({id:m.RemoveWorksheetMergeMutation.id,params:I}),C.ranges.length>0&&S.push({id:m.AddWorksheetMergeMutation.id,params:C}),f){const x=zl(n,l,h,u);g.unshift(...x.redos),S.push(...x.undos)}const R=m.AddMergeRedoSelectionsOperationFactory(n,i,u);R&&g.push(R);const w=m.AddMergeUndoSelectionsOperationFactory(n,i);w&&S.push(w);const y=n.get(m.SheetInterceptorService).onCommandExecute({id:Tt.id,params:{unitId:l,subUnitId:c,ranges:u}});return g.push(...y.redos),S.push(...y.undos),a.sequenceExecute(g,e).result?(t.pushUndoRedo({unitID:l,undoMutations:S,redoMutations:g}),!0):!1}},As={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async n=>{var u;const i=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),r=fs(ki.MergeAll,t);if(!(r!=null&&r.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return i.executeCommand(Tt.id,{selections:r,unitId:c,subUnitId:d})}},ks={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async n=>{var u;const i=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),r=fs(ki.MergeVertical,t);if(!(r!=null&&r.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return i.executeCommand(Tt.id,{value:a.Dimension.COLUMNS,selections:r,unitId:c,subUnitId:d})}},Ds={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async n=>{var u;const i=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),r=fs(ki.MergeHorizontal,t);if(!(r!=null&&r.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return i.executeCommand(Tt.id,{value:a.Dimension.ROWS,selections:r,unitId:c,subUnitId:d})}},Vn={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-left-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Vn.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.DeleteRangeMoveLeftCommand.id):!0}},Xt={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-up-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getRowCount()-1};for(let S=d.startRow;S<=d.endRow;S++)if(c.getRowFiltered(S)&&await i.confirm({id:Xt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Xt.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.DeleteRangeMoveUpCommand.id):!0}},Yt={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-down-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getRowCount()-1};for(let S=d.startRow;S<=d.endRow;S++)if(c.getRowFiltered(S)&&await i.confirm({id:Yt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Yt.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.InsertRangeMoveDownCommand.id):!0}},Wn={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-right-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Wn.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.InsertRangeMoveRightCommand.id):!0}};var Gl=(n=>(n[n.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",n[n.UNIVER_DOC=1]="UNIVER_DOC",n[n.UNIVER_SHEET=2]="UNIVER_SHEET",n[n.UNIVER_SLIDE=3]="UNIVER_SLIDE",n[n.UNIVER_PROJECT=4]="UNIVER_PROJECT",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(Gl||{}),re=(n=>(n[n.View=0]="View",n[n.Edit=1]="Edit",n[n.ManageCollaborator=2]="ManageCollaborator",n[n.Print=3]="Print",n[n.Duplicate=4]="Duplicate",n[n.Comment=5]="Comment",n[n.Copy=6]="Copy",n[n.Share=7]="Share",n[n.Export=8]="Export",n[n.MoveWorksheet=9]="MoveWorksheet",n[n.DeleteWorksheet=10]="DeleteWorksheet",n[n.HideWorksheet=11]="HideWorksheet",n[n.RenameWorksheet=12]="RenameWorksheet",n[n.CreateWorksheet=13]="CreateWorksheet",n[n.SetWorksheetStyle=14]="SetWorksheetStyle",n[n.EditWorksheetCell=15]="EditWorksheetCell",n[n.InsertHyperlink=16]="InsertHyperlink",n[n.Sort=17]="Sort",n[n.Filter=18]="Filter",n[n.PivotTable=19]="PivotTable",n[n.FloatImg=20]="FloatImg",n[n.History=21]="History",n[n.RwHgtClWdt=22]="RwHgtClWdt",n[n.ViemRwHgtClWdt=23]="ViemRwHgtClWdt",n[n.ViewFilter=24]="ViewFilter",n[n.MoveSheet=25]="MoveSheet",n[n.DeleteSheet=26]="DeleteSheet",n[n.HideSheet=27]="HideSheet",n[n.CopySheet=28]="CopySheet",n[n.RenameSheet=29]="RenameSheet",n[n.CreateSheet=30]="CreateSheet",n[n.SelectProtectedCells=31]="SelectProtectedCells",n[n.SelectUnProtectedCells=32]="SelectUnProtectedCells",n[n.SetCellStyle=33]="SetCellStyle",n[n.SetCellValue=34]="SetCellValue",n[n.SetRowStyle=35]="SetRowStyle",n[n.SetColumnStyle=36]="SetColumnStyle",n[n.InsertRow=37]="InsertRow",n[n.InsertColumn=38]="InsertColumn",n[n.DeleteRow=39]="DeleteRow",n[n.DeleteColumn=40]="DeleteColumn",n[n.EditExtraObject=41]="EditExtraObject",n[n.Delete=42]="Delete",n[n.RecoverHistory=43]="RecoverHistory",n[n.ViewHistory=44]="ViewHistory",n[n.CreatePermissionObject=45]="CreatePermissionObject",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(re||{}),ke=(n=>(n[n.Reader=0]="Reader",n[n.Editor=1]="Editor",n[n.Owner=2]="Owner",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(ke||{}),dt=(n=>(n[n.Unkonwn=0]="Unkonwn",n[n.Workbook=1]="Workbook",n[n.Worksheet=2]="Worksheet",n[n.SelectRange=3]="SelectRange",n[n.Document=4]="Document",n[n.Slide=5]="Slide",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(dt||{}),Ke=(n=>(n[n.SomeCollaborator=0]="SomeCollaborator",n[n.AllCollaborator=1]="AllCollaborator",n[n.OneSelf=2]="OneSelf",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(Ke||{});const or="UNIVER_SHEET_PERMISSION_PANEL",ai="UNIVER_SHEET_PERMISSION_USER_PART",Ns="UNIVER_SHEET_PERMISSION_BACKGROUND",Zl="UNIVER_SHEET_PERMISSION_USER_DIALOG",Kl="UNIVER_SHEET_PERMISSION_DIALOG",li="UNIVER_SHEET_PERMISSION_USER_DIALOG_ID",ci="UNIVER_SHEET_PERMISSION_DIALOG_ID",Br={[re.Copy]:"Copy",[re.SetCellStyle]:"SetCellStyle",[re.SetCellValue]:"SetCellValue",[re.SetRowStyle]:"SetRowStyle",[re.SetColumnStyle]:"SetColumnStyle",[re.InsertRow]:"InsertRow",[re.InsertColumn]:"InsertColumn",[re.InsertHyperlink]:"InsertHyperlink",[re.DeleteRow]:"DeleteRow",[re.DeleteColumn]:"DeleteColumn",[re.Sort]:"Sort",[re.Filter]:"Filter",[re.PivotTable]:"PivotTable",[re.EditExtraObject]:"EditExtraObject"},CS=[re.Copy,re.SetCellStyle,re.SetCellValue,re.SetRowStyle,re.SetColumnStyle,re.InsertRow,re.InsertColumn,re.InsertHyperlink,re.DeleteRow,re.DeleteColumn,re.Sort,re.Filter,re.PivotTable,re.EditExtraObject,re.View],ql="sheet-permission-menu-icon",_S="sheet-permission-delete-icon",IS="sheet-permission-edit-icon",bS="sheet-permission-check-icon",Ql="sheet-permission-lock-icon",RS={unitId:"",subUnitId:"",permissionId:"",unitType:m.UnitObject.SelectRange,id:"",ranges:[],viewState:m.ViewStateEnum.OthersCanView,editState:m.EditStateEnum.OnlyMe};class yn{constructor(){E(this,"_rule",RS);E(this,"_visible",!1)}setVisible(i){this._visible=i}getVisible(){return this._visible}reset(){this.setVisible(!1)}}class yt{constructor(){E(this,"_userList",[]);E(this,"_userList$",new O.BehaviorSubject(this._userList));E(this,"userList$",this._userList$.asObservable());E(this,"_oldCollaboratorList",[]);E(this,"_selectUserList",[]);E(this,"_selectUserList$",new O.BehaviorSubject(this._selectUserList));E(this,"selectUserList$",this._selectUserList$.asObservable())}get userList(){return this._userList}setCanEditUserList(i){this._userList=i,this._userList$.next(i)}reset(){this._userList=[],this._oldCollaboratorList=[],this._selectUserList=[],this._selectUserList$.next([])}get oldCollaboratorList(){return this._oldCollaboratorList}setOldCollaboratorList(i){this._oldCollaboratorList=i}get selectUserList(){return this._selectUserList}setSelectUserList(i){this._selectUserList=i,this._selectUserList$.next(i)}}const Qe={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openPanel",async handler(n,i={}){const e=n.get(_.ISidebarService),t=n.get(yn),r=n.get(yt),{showDetail:o=!0,fromSheetBar:s=!1,rule:l,oldRule:c}=i,d={header:{title:"permission.panel.title"},children:{label:or,showDetail:o,fromSheetBar:s,rule:l,oldRule:c},width:330,onClose:()=>{t.reset(),r.reset()}};return t.setVisible(!0),e.open(d),!0}},Mr={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-toolbar",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{showDetail:!0}),!0}},Wt={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{showDetail:!0}),!0}},Ut={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{showDetail:!1}),!0}},Pr={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{fromSheetBar:!0,showDetail:!0}),!0}},Or={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{showDetail:!1}),!0}},Lt={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-protection-from-context-menu",async handler(n){var h;const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IUndoRedoService),r=n.get(m.SheetsSelectionsService),o=n.get(m.WorksheetProtectionRuleModel),s=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s.getActiveSheet(),c=s.getUnitId(),d=l.getSheetId(),u=o.getRule(c,d);if(u!=null&&u.permissionId)return i.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d,rule:u});{const g=(h=r.getCurrentLastSelection())==null?void 0:h.range;if(!g)return!1;const p=n.get(m.RangeProtectionRuleModel).getSubunitRuleList(c,d).find(v=>v.ranges.some(C=>a.Rectangle.intersects(C,g)));if(p){const v={unitId:c,subUnitId:d,ruleIds:[p.id]};return await i.executeCommand(m.DeleteRangeProtectionMutation.id,v)&&t.pushUndoRedo({unitID:c,redoMutations:[{id:m.DeleteRangeProtectionMutation.id,params:v}],undoMutations:[{id:m.AddRangeProtectionMutation.id,params:{unitId:c,subUnitId:d,rules:[p]}}]}),!0}else return!1}}},Bt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-protection-from-context-menu",async handler(n){var u;const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.WorksheetProtectionRuleModel),o=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=o.getActiveSheet(),l=o.getUnitId(),c=s.getSheetId(),d=r.getRule(l,c);if(d!=null&&d.permissionId){const h={...d,unitId:l,subUnitId:c,ranges:[]};return await i.executeCommand(Qe.id,{showDetail:!0,rule:a.Tools.deepClone(h),oldRule:a.Tools.deepClone(h)}),!0}else{const h=(u=t.getCurrentLastSelection())==null?void 0:u.range;if(!h)return!1;const f=n.get(m.RangeProtectionRuleModel).getSubunitRuleList(l,c).find(p=>{var v;return(v=p==null?void 0:p.ranges)==null?void 0:v.some(C=>a.Rectangle.intersects(C,h))});if(f){const p={...f,unitId:l,subUnitId:c};return await i.executeCommand(Qe.id,{showDetail:!0,rule:a.Tools.deepClone(p),oldRule:a.Tools.deepClone(p)}),!0}else return!1}}},Mn={id:"sheet.command.remove-row-confirm",type:a.CommandType.COMMAND,handler:async(n,i)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=i==null?void 0:i.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const r=n.get(a.ICommandService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleRows();if(Ka(c,[t])){const u=n.get(_.IConfirmService),h=n.get(a.LocaleService);return await u.confirm({id:"sheet.confirm.remove-row",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllRowsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await r.executeCommand(m.RemoveRowCommand.id,{range:t}),!0}},Pn={id:"sheet.command.remove-col-confirm",type:a.CommandType.COMMAND,handler:async(n,i)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=i==null?void 0:i.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const r=n.get(a.ICommandService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleCols();if(qa(c,[t])){const u=n.get(_.IConfirmService),h=n.get(a.LocaleService);return await u.confirm({id:"sheet.confirm.remove-col",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllColumnsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await r.executeCommand(m.RemoveColCommand.id,{range:t}),!0}},xr={id:"sheet.command.remove-sheet-confirm",type:a.CommandType.COMMAND,handler:async(n,i)=>{const{subUnitId:e}=i,t=n.get(_.IConfirmService),r=n.get(a.ICommandService),o=n.get(a.LocaleService);return await t.confirm({id:"sheet.confirm.remove-sheet",title:{title:o.t("sheetConfig.deleteSheet")},children:{title:o.t("sheetConfig.deleteSheetContent")},cancelText:o.t("button.cancel"),confirmText:o.t("button.confirm")})?(await r.executeCommand(m.RemoveSheetCommand.id,{subUnitId:e}),!0):!1}},Ar={id:"ui-sheet.command.show-menu-list",type:a.CommandType.OPERATION,handler:async n=>(n.get(Kt).triggerSheetBarMenu(),!0)},kr={type:a.CommandType.COMMAND,id:"sheet.command.delete-worksheet-protection-from-sheet-bar",async handler(n,i){if(!i)return!1;const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),r=n.get(m.WorksheetProtectionRuleModel),s=n.get(a.IUniverInstanceService).getCurrentUnitForType(Gl.UNIVER_SHEET),l=s==null?void 0:s.getActiveSheet(),c=s.getUnitId();if(!l)return!1;const d=l.getSheetId(),u=r.getRule(c,d);if(await e.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d})){const g=[{id:m.DeleteWorksheetProtectionCommand.id,params:{unitId:c,subUnitId:d}}],S=[{id:m.AddWorksheetProtectionCommand.id,params:{unitId:c,rule:u}}];t.pushUndoRedo({unitID:c,redoMutations:g,undoMutations:S})}return!0}},Dr={type:a.CommandType.COMMAND,id:"sheet.command.change-sheet-protection-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand("sheet-permission.operation.openDialog"),!0}},Fi={id:"sheet.operation.set-activate-cell-edit",type:a.CommandType.OPERATION,handler:(n,i)=>(n.get(Se).setEditCell(i),!0)},Nr={id:"sheet.operation.rename-sheet",type:a.CommandType.OPERATION,handler:async(n,i)=>{const e=n.get(Kt);return i&&e.setRenameId(i.subUnitId),!0}},Hs={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openDialog",async handler(n,i){const e=n.get(_.IDialogService);return e.close("DESKTOP_FIND_REPLACE_DIALOG"),e.open({id:ci,title:{title:"permission.dialog.allowedPermissionType"},children:{label:Kl},width:393,destroyOnClose:!0,onClose:()=>e.close(ci)}),!0}},ES=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M0.98999 1.08218H-0.0100098V0.0821838H0.98999V1.08218Z",fill:"black"}),b.jsx("path",{d:"M5.78992 1.08218H2.78992V0.0821838H5.78992V1.08218Z",fill:"black"}),b.jsx("path",{d:"M7.58984 1.08218H8.58984V0.0821838H7.58984V1.08218Z",fill:"black"}),b.jsx("path",{d:"M14.9152 1.08218H13.9152V0.0821838H14.9152V1.08218Z",fill:"black"}),b.jsx("path",{d:"M16.7151 1.08218H19.7151V0.0821838H16.7151V1.08218Z",fill:"black"}),b.jsx("path",{d:"M22.515 1.08218H21.515V0.0821838H22.515V1.08218Z",fill:"black"}),b.jsx("path",{d:"M27.8405 1.08218H28.8405V0.0821838H27.8405V1.08218Z",fill:"black"}),b.jsx("path",{d:"M33.6404 1.08218H30.6404V0.0821838H33.6404V1.08218Z",fill:"black"}),b.jsx("path",{d:"M35.4403 1.08218H36.4403V0.0821838H35.4403V1.08218Z",fill:"black"}),b.jsx("path",{d:"M42.7657 1.08218H41.7657V0.0821838H42.7657V1.08218Z",fill:"black"}),b.jsx("path",{d:"M44.5657 1.08218H47.5657V0.0821838H44.5657V1.08218Z",fill:"black"}),b.jsx("path",{d:"M50.3656 1.08218H49.3656V0.0821838H50.3656V1.08218Z",fill:"black"}),b.jsx("path",{d:"M55.691 1.08218H56.691V0.0821838H55.691V1.08218Z",fill:"black"}),b.jsx("path",{d:"M61.491 1.08218H58.491V0.0821838H61.491V1.08218Z",fill:"black"}),b.jsx("path",{d:"M63.2909 1.08218H64.2909V0.0821838H63.2909V1.08218Z",fill:"black"}),b.jsx("path",{d:"M70.6163 1.08218H69.6163V0.0821838H70.6163V1.08218Z",fill:"black"}),b.jsx("path",{d:"M72.4163 1.08218H75.4163V0.0821838H72.4163V1.08218Z",fill:"black"}),b.jsx("path",{d:"M78.2162 1.08218H77.2162V0.0821838H78.2162V1.08218Z",fill:"black"}),b.jsx("path",{d:"M83.5416 1.08218H84.5416V0.0821838H83.5416V1.08218Z",fill:"black"}),b.jsx("path",{d:"M89.3416 1.08218H86.3416V0.0821838H89.3416V1.08218Z",fill:"black"}),b.jsx("path",{d:"M91.1415 1.08218H92.1415V0.0821838H91.1415V1.08218Z",fill:"black"}),b.jsx("path",{d:"M98.4669 1.08218H97.4669V0.0821838H98.4669V1.08218Z",fill:"black"}),b.jsx("path",{d:"M100.267 1.08218H103.267V0.0821838H100.267V1.08218Z",fill:"black"}),b.jsx("path",{d:"M106.067 1.08218H105.067V0.0821838H106.067V1.08218Z",fill:"black"}),b.jsx("path",{d:"M111.392 1.08218H112.392V0.0821838H111.392V1.08218Z",fill:"black"}),b.jsx("path",{d:"M117.192 1.08218H114.192V0.0821838H117.192V1.08218Z",fill:"black"}),b.jsx("path",{d:"M118.992 1.08218H119.992V0.0821838H118.992V1.08218Z",fill:"black"})]}),wS=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.0100098 1.15771H0.98999V0.157715H-0.0100098V1.15771Z",fill:"black"}),b.jsx("path",{d:"M2.78992 1.15771H5.78992V0.157715H2.78992V1.15771Z",fill:"black"}),b.jsx("path",{d:"M8.58984 1.15771H7.58984V0.157715H8.58984V1.15771Z",fill:"black"}),b.jsx("path",{d:"M10.3899 1.15771H11.3899V0.157715H10.3899V1.15771Z",fill:"black"}),b.jsx("path",{d:"M19.0903 1.15771H18.0903V0.157715H19.0903V1.15771Z",fill:"black"}),b.jsx("path",{d:"M20.8903 1.15771H23.8903V0.157715H20.8903V1.15771Z",fill:"black"}),b.jsx("path",{d:"M26.6902 1.15771H25.6902V0.157715H26.6902V1.15771Z",fill:"black"}),b.jsx("path",{d:"M28.4902 1.15771H29.4902V0.157715H28.4902V1.15771Z",fill:"black"}),b.jsx("path",{d:"M37.1907 1.15771H36.1907V0.157715H37.1907V1.15771Z",fill:"black"}),b.jsx("path",{d:"M38.9906 1.15771H41.9906V0.157715H38.9906V1.15771Z",fill:"black"}),b.jsx("path",{d:"M44.7905 1.15771H43.7905V0.157715H44.7905V1.15771Z",fill:"black"}),b.jsx("path",{d:"M46.5906 1.15771H47.5906V0.157715H46.5906V1.15771Z",fill:"black"}),b.jsx("path",{d:"M55.291 1.15771H54.291V0.157715H55.291V1.15771Z",fill:"black"}),b.jsx("path",{d:"M57.0909 1.15771H60.0909V0.157715H57.0909V1.15771Z",fill:"black"}),b.jsx("path",{d:"M62.8909 1.15771H61.8909V0.157715H62.8909V1.15771Z",fill:"black"}),b.jsx("path",{d:"M64.6909 1.15771H65.6909V0.157715H64.6909V1.15771Z",fill:"black"}),b.jsx("path",{d:"M73.3914 1.15771H72.3914V0.157715H73.3914V1.15771Z",fill:"black"}),b.jsx("path",{d:"M75.1913 1.15771H78.1913V0.157715H75.1913V1.15771Z",fill:"black"}),b.jsx("path",{d:"M80.9912 1.15771H79.9912V0.157715H80.9912V1.15771Z",fill:"black"}),b.jsx("path",{d:"M82.7913 1.15771H83.7913V0.157715H82.7913V1.15771Z",fill:"black"}),b.jsx("path",{d:"M91.4917 1.15771H90.4917V0.157715H91.4917V1.15771Z",fill:"black"}),b.jsx("path",{d:"M93.2916 1.15771H96.2916V0.157715H93.2916V1.15771Z",fill:"black"}),b.jsx("path",{d:"M99.0916 1.15771H98.0916V0.157715H99.0916V1.15771Z",fill:"black"}),b.jsx("path",{d:"M100.892 1.15771H101.892V0.157715H100.892V1.15771Z",fill:"black"}),b.jsx("path",{d:"M109.592 1.15771H108.592V0.157715H109.592V1.15771Z",fill:"black"}),b.jsx("path",{d:"M111.392 1.15771H114.392V0.157715H111.392V1.15771Z",fill:"black"}),b.jsx("path",{d:"M117.192 1.15771H116.192V0.157715H117.192V1.15771Z",fill:"black"}),b.jsx("path",{d:"M118.992 1.15771H119.992V0.157715H118.992V1.15771Z",fill:"black"})]}),TS=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.00842285 1.22449H2.99158V0.224487H-0.00842285V1.22449Z",fill:"black"}),b.jsx("path",{d:"M6.14941 1.22449H9.14941V0.224487H6.14941V1.22449Z",fill:"black"}),b.jsx("path",{d:"M15.3073 1.22449H12.3073V0.224487H15.3073V1.22449Z",fill:"black"}),b.jsx("path",{d:"M18.4651 1.22449H21.4651V0.224487H18.4651V1.22449Z",fill:"black"}),b.jsx("path",{d:"M27.6229 1.22449H24.6229V0.224487H27.6229V1.22449Z",fill:"black"}),b.jsx("path",{d:"M30.7808 1.22449H33.7808V0.224487H30.7808V1.22449Z",fill:"black"}),b.jsx("path",{d:"M39.9386 1.22449H36.9386V0.224487H39.9386V1.22449Z",fill:"black"}),b.jsx("path",{d:"M43.0964 1.22449H46.0964V0.224487H43.0964V1.22449Z",fill:"black"}),b.jsx("path",{d:"M52.2543 1.22449H49.2543V0.224487H52.2543V1.22449Z",fill:"black"}),b.jsx("path",{d:"M55.4121 1.22449H58.4121V0.224487H55.4121V1.22449Z",fill:"black"}),b.jsx("path",{d:"M64.5699 1.22449H61.5699V0.224487H64.5699V1.22449Z",fill:"black"}),b.jsx("path",{d:"M67.7278 1.22449H70.7278V0.224487H67.7278V1.22449Z",fill:"black"}),b.jsx("path",{d:"M76.8856 1.22449H73.8856V0.224487H76.8856V1.22449Z",fill:"black"}),b.jsx("path",{d:"M80.0435 1.22449H83.0435V0.224487H80.0435V1.22449Z",fill:"black"}),b.jsx("path",{d:"M89.2013 1.22449H86.2013V0.224487H89.2013V1.22449Z",fill:"black"}),b.jsx("path",{d:"M92.3591 1.22449H95.3591V0.224487H92.3591V1.22449Z",fill:"black"}),b.jsx("path",{d:"M101.517 1.22449H98.517V0.224487H101.517V1.22449Z",fill:"black"}),b.jsx("path",{d:"M104.675 1.22449H107.675V0.224487H104.675V1.22449Z",fill:"black"}),b.jsx("path",{d:"M113.833 1.22449H110.833V0.224487H113.833V1.22449Z",fill:"black"}),b.jsx("path",{d:"M116.99 1.22449H119.99V0.224487H116.99V1.22449Z",fill:"black"})]}),yS=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.00976562 1.65707H0.990234V0.657074H-0.00976562V1.65707Z",fill:"black"}),b.jsx("path",{d:"M2.32361 1.65707H3.32361V0.657074H2.32361V1.65707Z",fill:"black"}),b.jsx("path",{d:"M5.65698 1.65707H4.65698V0.657074H5.65698V1.65707Z",fill:"black"}),b.jsx("path",{d:"M6.99036 1.65707H7.99036V0.657074H6.99036V1.65707Z",fill:"black"}),b.jsx("path",{d:"M10.3237 1.65707H9.32373V0.657074H10.3237V1.65707Z",fill:"black"}),b.jsx("path",{d:"M11.6571 1.65707H12.6571V0.657074H11.6571V1.65707Z",fill:"black"}),b.jsx("path",{d:"M14.9905 1.65707H13.9905V0.657074H14.9905V1.65707Z",fill:"black"}),b.jsx("path",{d:"M16.3239 1.65707H17.3239V0.657074H16.3239V1.65707Z",fill:"black"}),b.jsx("path",{d:"M19.6572 1.65707H18.6572V0.657074H19.6572V1.65707Z",fill:"black"}),b.jsx("path",{d:"M20.9906 1.65707H21.9906V0.657074H20.9906V1.65707Z",fill:"black"}),b.jsx("path",{d:"M24.324 1.65707H23.324V0.657074H24.324V1.65707Z",fill:"black"}),b.jsx("path",{d:"M25.6573 1.65707H26.6573V0.657074H25.6573V1.65707Z",fill:"black"}),b.jsx("path",{d:"M28.9907 1.65707H27.9907V0.657074H28.9907V1.65707Z",fill:"black"}),b.jsx("path",{d:"M30.3241 1.65707H31.3241V0.657074H30.3241V1.65707Z",fill:"black"}),b.jsx("path",{d:"M33.6575 1.65707H32.6575V0.657074H33.6575V1.65707Z",fill:"black"}),b.jsx("path",{d:"M34.9908 1.65707H35.9908V0.657074H34.9908V1.65707Z",fill:"black"}),b.jsx("path",{d:"M38.3242 1.65707H37.3242V0.657074H38.3242V1.65707Z",fill:"black"}),b.jsx("path",{d:"M39.6576 1.65707H40.6576V0.657074H39.6576V1.65707Z",fill:"black"}),b.jsx("path",{d:"M42.991 1.65707H41.991V0.657074H42.991V1.65707Z",fill:"black"}),b.jsx("path",{d:"M44.3243 1.65707H45.3243V0.657074H44.3243V1.65707Z",fill:"black"}),b.jsx("path",{d:"M47.6577 1.65707H46.6577V0.657074H47.6577V1.65707Z",fill:"black"}),b.jsx("path",{d:"M48.9911 1.65707H49.9911V0.657074H48.9911V1.65707Z",fill:"black"}),b.jsx("path",{d:"M52.3245 1.65707H51.3245V0.657074H52.3245V1.65707Z",fill:"black"}),b.jsx("path",{d:"M53.6578 1.65707H54.6578V0.657074H53.6578V1.65707Z",fill:"black"}),b.jsx("path",{d:"M56.9912 1.65707H55.9912V0.657074H56.9912V1.65707Z",fill:"black"}),b.jsx("path",{d:"M58.3246 1.65707H59.3246V0.657074H58.3246V1.65707Z",fill:"black"}),b.jsx("path",{d:"M61.658 1.65707H60.658V0.657074H61.658V1.65707Z",fill:"black"}),b.jsx("path",{d:"M62.9913 1.65707H63.9913V0.657074H62.9913V1.65707Z",fill:"black"}),b.jsx("path",{d:"M66.3247 1.65707H65.3247V0.657074H66.3247V1.65707Z",fill:"black"}),b.jsx("path",{d:"M67.6581 1.65707H68.6581V0.657074H67.6581V1.65707Z",fill:"black"}),b.jsx("path",{d:"M70.9915 1.65707H69.9915V0.657074H70.9915V1.65707Z",fill:"black"}),b.jsx("path",{d:"M72.3248 1.65707H73.3248V0.657074H72.3248V1.65707Z",fill:"black"}),b.jsx("path",{d:"M75.6582 1.65707H74.6582V0.657074H75.6582V1.65707Z",fill:"black"}),b.jsx("path",{d:"M76.9916 1.65707H77.9916V0.657074H76.9916V1.65707Z",fill:"black"}),b.jsx("path",{d:"M80.325 1.65707H79.325V0.657074H80.325V1.65707Z",fill:"black"}),b.jsx("path",{d:"M81.6583 1.65707H82.6583V0.657074H81.6583V1.65707Z",fill:"black"}),b.jsx("path",{d:"M84.9917 1.65707H83.9917V0.657074H84.9917V1.65707Z",fill:"black"}),b.jsx("path",{d:"M86.3251 1.65707H87.3251V0.657074H86.3251V1.65707Z",fill:"black"}),b.jsx("path",{d:"M89.6584 1.65707H88.6584V0.657074H89.6584V1.65707Z",fill:"black"}),b.jsx("path",{d:"M90.9918 1.65707H91.9918V0.657074H90.9918V1.65707Z",fill:"black"}),b.jsx("path",{d:"M94.3252 1.65707H93.3252V0.657074H94.3252V1.65707Z",fill:"black"}),b.jsx("path",{d:"M95.6586 1.65707H96.6586V0.657074H95.6586V1.65707Z",fill:"black"}),b.jsx("path",{d:"M98.9919 1.65707H97.9919V0.657074H98.9919V1.65707Z",fill:"black"}),b.jsx("path",{d:"M100.325 1.65707H101.325V0.657074H100.325V1.65707Z",fill:"black"}),b.jsx("path",{d:"M103.659 1.65707H102.659V0.657074H103.659V1.65707Z",fill:"black"}),b.jsx("path",{d:"M104.992 1.65707H105.992V0.657074H104.992V1.65707Z",fill:"black"}),b.jsx("path",{d:"M108.325 1.65707H107.325V0.657074H108.325V1.65707Z",fill:"black"}),b.jsx("path",{d:"M109.659 1.65707H110.659V0.657074H109.659V1.65707Z",fill:"black"}),b.jsx("path",{d:"M112.992 1.65707H111.992V0.657074H112.992V1.65707Z",fill:"black"}),b.jsx("path",{d:"M114.325 1.65707H115.325V0.657074H114.325V1.65707Z",fill:"black"}),b.jsx("path",{d:"M117.659 1.65707H116.659V0.657074H117.659V1.65707Z",fill:"black"}),b.jsx("path",{d:"M118.992 1.65707H119.992V0.657074H118.992V1.65707Z",fill:"black"})]}),MS=()=>b.jsx("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 2.42035H-0.0090332V0.420349H119.991V2.42035Z",fill:"black"})}),PS=()=>b.jsxs("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.0100098 2.47614H1.98999V0.476135H-0.0100098V2.47614Z",fill:"black"}),b.jsx("path",{d:"M3.99014 2.47614H9.99014V0.476135H3.99014V2.47614Z",fill:"black"}),b.jsx("path",{d:"M13.9901 2.47614H11.9901V0.476135H13.9901V2.47614Z",fill:"black"}),b.jsx("path",{d:"M21.1904 2.47614H23.1904V0.476135H21.1904V2.47614Z",fill:"black"}),b.jsx("path",{d:"M31.1906 2.47614H25.1906V0.476135H31.1906V2.47614Z",fill:"black"}),b.jsx("path",{d:"M33.1906 2.47614H35.1906V0.476135H33.1906V2.47614Z",fill:"black"}),b.jsx("path",{d:"M44.3909 2.47614H42.3909V0.476135H44.3909V2.47614Z",fill:"black"}),b.jsx("path",{d:"M46.391 2.47614H52.391V0.476135H46.391V2.47614Z",fill:"black"}),b.jsx("path",{d:"M56.391 2.47614H54.391V0.476135H56.391V2.47614Z",fill:"black"}),b.jsx("path",{d:"M63.5913 2.47614H65.5913V0.476135H63.5913V2.47614Z",fill:"black"}),b.jsx("path",{d:"M73.5915 2.47614H67.5915V0.476135H73.5915V2.47614Z",fill:"black"}),b.jsx("path",{d:"M75.5915 2.47614H77.5915V0.476135H75.5915V2.47614Z",fill:"black"}),b.jsx("path",{d:"M86.7917 2.47614H84.7917V0.476135H86.7917V2.47614Z",fill:"black"}),b.jsx("path",{d:"M88.7919 2.47614H94.7919V0.476135H88.7919V2.47614Z",fill:"black"}),b.jsx("path",{d:"M98.7919 2.47614H96.7919V0.476135H98.7919V2.47614Z",fill:"black"}),b.jsx("path",{d:"M105.992 2.47614H107.992V0.476135H105.992V2.47614Z",fill:"black"}),b.jsx("path",{d:"M115.992 2.47614H109.992V0.476135H115.992V2.47614Z",fill:"black"}),b.jsx("path",{d:"M117.992 2.47614H119.992V0.476135H117.992V2.47614Z",fill:"black"})]}),OS=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.0100098 2.00415H1.98999V0.00415039H-0.0100098V2.00415Z",fill:"black"}),b.jsx("path",{d:"M3.99014 2.00415H9.99014V0.00415039H3.99014V2.00415Z",fill:"black"}),b.jsx("path",{d:"M13.9901 2.00415H11.9901V0.00415039H13.9901V2.00415Z",fill:"black"}),b.jsx("path",{d:"M15.9901 2.00415H17.9901V0.00415039H15.9901V2.00415Z",fill:"black"}),b.jsx("path",{d:"M27.4905 2.00415H25.4905V0.00415039H27.4905V2.00415Z",fill:"black"}),b.jsx("path",{d:"M29.4906 2.00415H35.4906V0.00415039H29.4906V2.00415Z",fill:"black"}),b.jsx("path",{d:"M39.4906 2.00415H37.4906V0.00415039H39.4906V2.00415Z",fill:"black"}),b.jsx("path",{d:"M41.4906 2.00415H43.4906V0.00415039H41.4906V2.00415Z",fill:"black"}),b.jsx("path",{d:"M52.991 2.00415H50.991V0.00415039H52.991V2.00415Z",fill:"black"}),b.jsx("path",{d:"M54.9911 2.00415H60.9911V0.00415039H54.9911V2.00415Z",fill:"black"}),b.jsx("path",{d:"M64.9911 2.00415H62.9911V0.00415039H64.9911V2.00415Z",fill:"black"}),b.jsx("path",{d:"M66.9911 2.00415H68.9911V0.00415039H66.9911V2.00415Z",fill:"black"}),b.jsx("path",{d:"M78.4915 2.00415H76.4915V0.00415039H78.4915V2.00415Z",fill:"black"}),b.jsx("path",{d:"M80.4916 2.00415H86.4916V0.00415039H80.4916V2.00415Z",fill:"black"}),b.jsx("path",{d:"M90.4916 2.00415H88.4916V0.00415039H90.4916V2.00415Z",fill:"black"}),b.jsx("path",{d:"M92.4916 2.00415H94.4916V0.00415039H92.4916V2.00415Z",fill:"black"}),b.jsx("path",{d:"M103.992 2.00415H101.992V0.00415039H103.992V2.00415Z",fill:"black"}),b.jsx("path",{d:"M105.992 2.00415H111.992V0.00415039H105.992V2.00415Z",fill:"black"}),b.jsx("path",{d:"M115.992 2.00415H113.992V0.00415039H115.992V2.00415Z",fill:"black"}),b.jsx("path",{d:"M117.992 2.00415H119.992V0.00415039H117.992V2.00415Z",fill:"black"})]}),xS=()=>b.jsxs("svg",{width:"118",height:"3",viewBox:"0 0 118 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.00854492 2.94815H1.99146V0.948151H-0.00854492V2.94815Z",fill:"black"}),b.jsx("path",{d:"M6.09668 2.94815H8.09668V0.948151H6.09668V2.94815Z",fill:"black"}),b.jsx("path",{d:"M14.2019 2.94815H12.2019V0.948151H14.2019V2.94815Z",fill:"black"}),b.jsx("path",{d:"M18.3071 2.94815H20.3071V0.948151H18.3071V2.94815Z",fill:"black"}),b.jsx("path",{d:"M26.4124 2.94815H24.4124V0.948151H26.4124V2.94815Z",fill:"black"}),b.jsx("path",{d:"M30.5176 2.94815H32.5176V0.948151H30.5176V2.94815Z",fill:"black"}),b.jsx("path",{d:"M38.6228 2.94815H36.6228V0.948151H38.6228V2.94815Z",fill:"black"}),b.jsx("path",{d:"M42.728 2.94815H44.728V0.948151H42.728V2.94815Z",fill:"black"}),b.jsx("path",{d:"M50.8333 2.94815H48.8333V0.948151H50.8333V2.94815Z",fill:"black"}),b.jsx("path",{d:"M54.9385 2.94815H56.9385V0.948151H54.9385V2.94815Z",fill:"black"}),b.jsx("path",{d:"M63.0437 2.94815H61.0437V0.948151H63.0437V2.94815Z",fill:"black"}),b.jsx("path",{d:"M67.1489 2.94815H69.1489V0.948151H67.1489V2.94815Z",fill:"black"}),b.jsx("path",{d:"M75.2542 2.94815H73.2542V0.948151H75.2542V2.94815Z",fill:"black"}),b.jsx("path",{d:"M79.3594 2.94815H81.3594V0.948151H79.3594V2.94815Z",fill:"black"}),b.jsx("path",{d:"M87.4645 2.94815H85.4645V0.948151H87.4645V2.94815Z",fill:"black"}),b.jsx("path",{d:"M91.5697 2.94815H93.5697V0.948151H91.5697V2.94815Z",fill:"black"}),b.jsx("path",{d:"M99.6749 2.94815H97.6749V0.948151H99.6749V2.94815Z",fill:"black"}),b.jsx("path",{d:"M103.78 2.94815H105.78V0.948151H103.78V2.94815Z",fill:"black"}),b.jsx("path",{d:"M111.885 2.94815H109.885V0.948151H111.885V2.94815Z",fill:"black"}),b.jsx("path",{d:"M115.991 2.94815H117.991V0.948151H115.991V2.94815Z",fill:"black"})]}),AS=()=>b.jsx("svg",{width:"120",height:"4",viewBox:"0 0 120 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 3.86215H-0.0090332V0.862152H119.991V3.86215Z",fill:"black"})}),ya=()=>b.jsx("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 1.15668H-0.0090332V0.156677H119.991V1.15668Z",fill:"black"})});function Ma(n){const{type:i=a.BorderStyleTypes.THIN}=n;switch(i){case a.BorderStyleTypes.DASH_DOT:return b.jsx(ES,{});case a.BorderStyleTypes.DASH_DOT_DOT:return b.jsx(wS,{});case a.BorderStyleTypes.DASHED:return b.jsx(TS,{});case a.BorderStyleTypes.HAIR:return b.jsx(yS,{});case a.BorderStyleTypes.MEDIUM:return b.jsx(MS,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT:return b.jsx(PS,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return b.jsx(OS,{});case a.BorderStyleTypes.MEDIUM_DASHED:return b.jsx(xS,{});case a.BorderStyleTypes.THICK:return b.jsx(AS,{});case a.BorderStyleTypes.THIN:return b.jsx(ya,{});default:return b.jsx(ya,{})}}const Vs=`${Dn}_BORDER_PANEL_COMPONENT`,Jl=[{label:"borderLine.borderTop",icon:"UpBorder",value:"top"},{label:"borderLine.borderBottom",icon:"DownBorder",value:"bottom"},{label:"borderLine.borderLeft",icon:"LeftBorder",value:"left"},{label:"borderLine.borderRight",icon:"RightBorder",value:"right"},{label:"borderLine.borderNone",icon:"NoBorderSingle",value:"none"},{label:"borderLine.borderAll",icon:"AllBorderSingle",value:"all"},{label:"borderLine.borderOutside",icon:"OuterBorder",value:"outside"},{label:"borderLine.borderInside",icon:"InnerBorder",value:"inside"},{label:"borderLine.borderHorizontal",icon:"HorizontalBorder",value:"horizontal"},{label:"borderLine.borderVertical",icon:"VerticalBorder",value:"vertical"},{label:"borderLine.borderTlbr",icon:"BackSlashSingle",value:"tlbr"},{label:"borderLine.borderTlbcTlmr",icon:"LeftDoubleDiagonalSingle",value:"tlbc_tlmr"},{label:"borderLine.borderTlbrTlbcTlmr",icon:"LeftTridiagonalSingle",value:"tlbr_tlbc_tlmr"},{label:"borderLine.borderBlTr",icon:"SlashSingle",value:"bltr"},{label:"borderLine.borderMltrBctr",icon:"RightDoubleDiagonalSingle",value:"mltr_bctr"}],kS=[{label:a.BorderStyleTypes.THIN,value:a.BorderStyleTypes.THIN},{label:a.BorderStyleTypes.HAIR,value:a.BorderStyleTypes.HAIR},{label:a.BorderStyleTypes.DOTTED,value:a.BorderStyleTypes.DOTTED},{label:a.BorderStyleTypes.DASHED,value:a.BorderStyleTypes.DASHED},{label:a.BorderStyleTypes.DASH_DOT,value:a.BorderStyleTypes.DASH_DOT},{label:a.BorderStyleTypes.DASH_DOT_DOT,value:a.BorderStyleTypes.DASH_DOT_DOT},{label:a.BorderStyleTypes.MEDIUM,value:a.BorderStyleTypes.MEDIUM},{label:a.BorderStyleTypes.MEDIUM_DASHED,value:a.BorderStyleTypes.MEDIUM_DASHED},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT},{label:a.BorderStyleTypes.THICK,value:a.BorderStyleTypes.THICK}];function $l(n){var l;const i=_.useDependency(_.ComponentManager),e=_.useDependency(m.BorderStyleManagerService),{onChange:t,value:r}=n;function o(c,d){t==null||t({...r,[d]:c})}function s(c){const d=i.get(c);return d&&b.jsx(d,{extend:{colorChannel1:"#2c53f1"}})}return b.jsxs("section",{className:"univer-box-border univer-grid univer-gap-2 univer-p-1.5",children:[b.jsx("div",{className:"univer-box-border univer-grid univer-grid-cols-5 univer-gap-2",children:Jl.map(c=>b.jsx("a",{className:Y.clsx(`
58
+ `)}),i}function ig(n){return a.isNotNullOrUndefined(n.displayV)?n.displayV:a.extractPureTextFromCell(n)}function og(n,i,e,t){return t.getMergeData().some(r=>r.startRow<=n&&n<r.endRow&&i<=r.startColumn&&r.startColumn<=e)}function sg(n,i,e,t){return t.getMergeData().some(r=>r.startColumn<=n&&n<r.endColumn&&i<=r.startRow&&r.startRow<=e)}function ag(n){let i=0;return n.forValue((e,t,r)=>{if(r&&i++,i>1)return!1}),i>1}function Bn(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const ys=998,Xe={id:_.CopyCommand.id,name:"sheet.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:ys,preconditions:Es,handler:async n=>n.get(Be).copy()},Ms={id:_.CutCommand.id,name:"sheet.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:ys,preconditions:Es,handler:async n=>n.get(Be).cut()},Ye={id:_.PasteCommand.id,type:a.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:ys,preconditions:Es,handler:async(n,i)=>{const t=await n.get(_.IClipboardInterfaceService).read(),r=n.get(Be);return t.length!==0?r.paste(t[0],i==null?void 0:i.value):!1}},oi={id:_.SheetPasteShortKeyCommandName,type:a.CommandType.COMMAND,handler:async(n,i)=>{const e=n.get(Be),{htmlContent:t,textContent:r,files:o}=i;return e.legacyPaste(t,r,o),!0}},gn={id:"sheet.command.paste-value",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_VALUE})},Sn={id:"sheet.command.paste-format",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_FORMAT})},Vt={id:"sheet.command.paste-col-width",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_COL_WIDTH})},fn={id:"sheet.command.paste-besides-border",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_BESIDES_BORDER})},Dl={id:"sheet.command.optional-paste",type:a.CommandType.COMMAND,handler:async(n,{type:i})=>n.get(Be).rePasteWithPasteType(i)},fr={id:"sheet.command.hide-row-confirm",type:a.CommandType.COMMAND,handler:async n=>{var c;const e=(c=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const t=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),o=m.getSheetCommandTarget(r);if(!o)return!1;const{worksheet:s}=o,l=s.getVisibleRows();if(Ka(l,e)){const d=n.get(_.IConfirmService),u=n.get(a.LocaleService);return await d.confirm({id:"sheet.confirm.hide-row",title:{title:u.t("info.problem")},children:{title:u.t("rightClick.hideAllRowsAlert")},cancelText:u.t("button.cancel"),confirmText:u.t("button.confirm")}),!1}return await t.executeCommand(m.SetRowHiddenCommand.id),!0}},pr={id:"sheet.command.hide-col-confirm",type:a.CommandType.COMMAND,handler:async n=>{var c;const e=(c=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const t=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),o=m.getSheetCommandTarget(r);if(!o)return!1;const{worksheet:s}=o,l=s.getVisibleCols();if(qa(l,e)){const d=n.get(_.IConfirmService),u=n.get(a.LocaleService);return await d.confirm({id:"sheet.confirm.hide-col",title:{title:u.t("info.problem")},children:{title:u.t("rightClick.hideAllColumnsAlert")},cancelText:u.t("button.cancel"),confirmText:u.t("button.confirm")}),!1}return await t.executeCommand(m.SetColHiddenCommand.id),!0}},Qt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(ee.SetInlineFormatBoldCommand.id):i.executeCommand(m.SetBoldCommand.id)}},Jt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(ee.SetInlineFormatItalicCommand.id):i.executeCommand(m.SetItalicCommand.id)}},$t={type:a.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(ee.SetInlineFormatUnderlineCommand.id):i.executeCommand(m.SetUnderlineCommand.id)}},en={type:a.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(ee.SetInlineFormatStrikethroughCommand.id):i.executeCommand(m.SetStrikeThroughCommand.id)}},Ps={type:a.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(ee.SetInlineFormatSubscriptCommand.id):!1}},Os={type:a.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(ee.SetInlineFormatSuperscriptCommand.id):!1}},vr={type:a.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(n,i)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(ee.SetInlineFormatFontSizeCommand.id,i):e.executeCommand(m.SetFontSizeCommand.id,i)}},Cr={type:a.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(n,i)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(ee.SetInlineFormatFontFamilyCommand.id,i):e.executeCommand(m.SetFontFamilyCommand.id,i)}},Tn={type:a.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(n,i)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(ee.SetInlineFormatTextColorCommand.id,i):e.executeCommand(m.SetTextColorCommand.id,i)}},xs={type:a.CommandType.COMMAND,id:"sheet.command.reset-range-text-color",handler:async n=>{const i=n.get(a.ICommandService),t=n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED),r=n.get(a.ThemeService);return t?i.executeCommand(ee.SetInlineFormatTextColorCommand.id,{value:null}):i.executeCommand(m.SetTextColorCommand.id,{value:r.getCurrentTheme().textColor})}};var lg=Object.getOwnPropertyDescriptor,cg=(n,i,e,t)=>{for(var r=t>1?void 0:t?lg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},ln=(n,i)=>(e,t)=>i(e,t,n),De=(n=>(n[n.OFF=0]="OFF",n[n.ONCE=1]="ONCE",n[n.INFINITE=2]="INFINITE",n))(De||{});const et=a.createIdentifier("univer.format-painter-service");let si=class extends a.Disposable{constructor(i,e,t,r,o,s){super();E(this,"status$");E(this,"_selectionFormat");E(this,"_markId",null);E(this,"_status$");E(this,"_defaultHook",null);E(this,"_extendHooks",[]);this._selectionManagerService=i,this._themeService=e,this._markSelectionService=t,this._logService=r,this._commandService=o,this._undoRedoService=s,this._status$=new O.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new a.ObjectMatrix,merges:[]}}addHook(i){var e,t,r;i.isDefaultHook&&((e=i.priority)!=null?e:0)>((r=(t=this._defaultHook)==null?void 0:t.priority)!=null?r:-1)?this._defaultHook=i:(this._extendHooks.push(i),this._extendHooks.sort((o,s)=>(o.priority||0)-(s.priority||0)))}getHooks(){return this._defaultHook?[this._defaultHook,...this._extendHooks]:this._extendHooks}setStatus(i){this._updateRangeMark(i),this._status$.next(i),this.getHooks().forEach(t=>{t.onStatusChange!==void 0&&t.onStatusChange(i)})}getStatus(){return this._status$.getValue()}setSelectionFormat(i){this._selectionFormat=i}getSelectionFormat(){return this._selectionFormat}applyFormatPainter(i,e,t){const r=this.getHooks(),o=[],s=[];r.forEach(c=>{if(c.onApply!==void 0){const d=c.onApply(i,e,t,this._selectionFormat);d&&(o.push(...d.redos),s.push(...d.undos))}});for(const c of r)if(c.onBeforeApply!==void 0&&!c.onBeforeApply({unitId:i,subUnitId:e,range:t,redoMutationsInfo:o,format:this._selectionFormat,undoMutationsInfo:s}))return!1;this._logService.log("[FormatPainterService]","apply mutations",{undoMutationsInfo:s,redoMutationsInfo:o});const l=o.every(c=>this._commandService.executeCommand(c.id,c.params));return l&&this._undoRedoService.pushUndoRedo({unitID:i,undoMutations:s,redoMutations:o}),l}_updateRangeMark(i){if(this._markSelectionService.removeAllShapes(),i!==0){const e=this._selectionManagerService.getCurrentLastSelection();if(e){const t=Ol(this._themeService);i===2?this._markId=this._markSelectionService.addShape({...e,style:t}):this._markId=this._markSelectionService.addShape({...e,style:t},[m.SetRangeValuesMutation.id])}}}};si=cg([ln(0,a.Inject(m.SheetsSelectionsService)),ln(1,a.Inject(a.ThemeService)),ln(2,qt),ln(3,a.ILogService),ln(4,a.ICommandService),ln(5,a.IUndoRedoService)],si);const _r={id:"sheet.operation.set-format-painter",type:a.CommandType.OPERATION,handler:(n,i)=>i?(n.get(et).setStatus(i.status),!0):!1},Vi={type:a.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async n=>{const e=n.get(et).getStatus();let t;return e!==De.OFF?t=De.OFF:t=De.INFINITE,n.get(a.ICommandService).executeCommand(_r.id,{status:t})}},kn={type:a.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async n=>{const e=n.get(et).getStatus();let t;return e!==De.OFF?t=De.OFF:t=De.ONCE,n.get(a.ICommandService).executeCommand(_r.id,{status:t})}},Ir={type:a.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(n,i)=>n.get(et).applyFormatPainter(i.unitId,i.subUnitId,i.range)},ht={type:a.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(n,i)=>{const{type:e}=i||{},t=n.get(a.IUniverInstanceService),r=n.get(a.IUndoRedoService),o=m.getSheetCommandTarget(t);if(!o)return!1;const{unitId:s,subUnitId:l}=o,c=n.get(a.ICommandService),u=n.get(m.SheetsSelectionsService).getCurrentSelections();if(!u)return!1;const h=u[(u==null?void 0:u.length)-1],{range:g}=h,f=n.get(T.IRenderManagerService).getRenderById(s).with(exports.SheetScrollManagerService),{sheetViewStartRow:p=0,sheetViewStartColumn:v=0}=f.getCurrentScrollState()||{};let C,I,R,w;const{startRow:M,startColumn:y,rangeType:P}=g;if(P===a.RANGE_TYPE.ROW||e===1)C=M,R=M-p,I=-1,w=0;else if(P===a.RANGE_TYPE.COLUMN||e===2)C=-1,R=0,I=y,w=y-v;else if(P===a.RANGE_TYPE.NORMAL)C=M,R=M-p,I=y,w=y-v;else return!1;const x={unitId:s,subUnitId:l,startRow:C,startColumn:I,xSplit:I>0?Math.max(1,w):w,ySplit:C>0?Math.max(1,R):R},A=m.SetFrozenMutationFactory(n,x);return c.syncExecuteCommand(m.SetFrozenMutation.id,x)&&r.pushUndoRedo({unitID:s,undoMutations:[{id:m.SetFrozenMutation.id,params:A}],redoMutations:[{id:m.SetFrozenMutation.id,params:x}]}),!0}},br={type:a.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand(ht.id,{type:1}),!0)},Rr={type:a.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand(ht.id,{type:2}),!0)};var dg=Object.getOwnPropertyDescriptor,ug=(n,i,e,t)=>{for(var r=t>1?void 0:t?dg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},fa=(n,i)=>(e,t)=>i(e,t,n);const hg=(n,i)=>{const{unitId:e,subUnitId:t,ranges:r}=n,o={},s=i.getColumnManager();for(let l=0;l<r.length;l++){const c=r[l];for(let d=c.startColumn;d<c.endColumn+1;d++){const u=s.getColumnOrCreate(d);o[d]=u.w}}return{unitId:e,subUnitId:t,ranges:r,colWidth:o}};exports.AutoWidthController=class extends a.Disposable{constructor(i,e){super(),this._renderManagerService=i,this._univerInstanceService=e}getUndoRedoParamsOfColWidth(i){const e={redos:[],undos:[]},{_univerInstanceService:t}=this,r=m.getSheetCommandTarget(t);if(!r)return e;const{unitId:o,subUnitId:s,worksheet:l}=r,c=this._renderManagerService.getRenderById(o).with(exports.SheetSkeletonManagerService);if(!c.getCurrentParam())return e;const{skeleton:d}=c.getCurrentParam(),u=d.calculateAutoWidthInRange(i.ranges),h={};for(const{col:f,width:p}of u)h[f]=p;const g={subUnitId:s,unitId:o,ranges:i.ranges,colWidth:h},S=hg(g,l);return{undos:[{id:m.SetWorksheetColWidthMutation.id,params:S}],redos:[{id:m.SetWorksheetColWidthMutation.id,params:g}]}}};exports.AutoWidthController=ug([fa(0,T.IRenderManagerService),fa(1,a.Inject(a.IUniverInstanceService))],exports.AutoWidthController);const Er={type:a.CommandType.COMMAND,id:"sheet.command.set-col-auto-width",handler:(n,i)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o,i);if(!s)return!1;const{unitId:l,subUnitId:c}=s;let d=[];if(i!=null&&i.ranges)d=[...i.ranges];else{const f=r.getCurrentSelections();for(let p=0;p<f.length;p++)d.push(f[p].range)}if(!(d!=null&&d.length))return!1;const u={unitId:l,subUnitId:c,ranges:d},{redos:h,undos:g}=n.get(exports.AutoWidthController).getUndoRedoParamsOfColWidth(u);return a.sequenceExecute([...h],e).result?(t.pushUndoRedo({unitID:l,undoMutations:[...g],redoMutations:[...h]}),!0):!1}},Dn="UI_PLUGIN_SHEETS",wr=`${Dn}_COLOR_PICKER_COMPONENT`,Wi=`${Dn}_FONT_FAMILY_COMPONENT`,Ui=`${Dn}_FONT_FAMILY_ITEM_COMPONENT`,Li=`${Dn}_FONT_SIZE_COMPONENT`,tt=`${Dn}_MENU_ITEM_INPUT_COMPONENT`,mg="univer-sheets-ui-context-menu-input",gg="univer-sheets-ui-context-menu-input-container",Sg="univer-sheets-ui-context-menu-input-number",Ki={sheetsUiContextMenuInput:mg,sheetsUiContextMenuInputContainer:gg,sheetsUiContextMenuInputNumber:Sg},Nl=n=>{const{prefix:i,suffix:e,value:t,onChange:r,min:o=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=n,l=_.useDependency(a.LocaleService),c=_.useDependency(_.IContextMenuService),[d,u]=V.useState(),h=S=>{var f;u(S==null?void 0:S.toString()),r((f=S==null?void 0:S.toString())!=null?f:"")};V.useEffect(()=>{c.visible||u(t)},[c.visible]),V.useEffect(()=>{u(t)},[t]);function g(S){S.key==="Backspace"&&S.stopPropagation()}return b.jsxs("div",{className:Ki.sheetsUiContextMenuInput,children:[l.t(i),b.jsx("span",{className:Ki.sheetsUiContextMenuInputContainer,onClick:S=>S.stopPropagation(),children:b.jsx(Y.InputNumber,{className:Ki.sheetsUiContextMenuInputNumber,value:Number(d),precision:0,onKeyDown:g,onChange:h,min:o,max:s})}),l.t(e)]})};function fg(n){return n.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(me.switchMap(i=>i?i.activeSheet$.pipe(me.map(e=>e?{workbook:i,worksheet:e}:null)):O.of(null)))}function be(n,i,e){return fg(n).pipe(me.switchMap(t=>t?e(t):O.of(i)))}function Hl(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.IExclusiveRangeService),r=n.get(m.SheetsSelectionsService);return e.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(me.switchMap(s=>s?O.combineLatest([r.selectionMoveEnd$,s.activeSheet$]).pipe(me.switchMap(([l,c])=>{if(!c||l.length===0)return O.of(!1);const d=t.getInterestGroupId(l);if(i){const u=d.filter(h=>i.has(h));return O.of(u.length>0)}else return O.of(d.length>0)})):O.of(!1)))}function tn(n,i,e){return O.combineLatest([i,Hl(n,e)]).pipe(me.map(([t,r])=>t||r))}function te(n,i={},e=!1){var g;const r=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),o=n.get(a.UserManagerService),s=n.has(Se)?n.get(Se):null,l=n.get(a.IContextService),c=new O.BehaviorSubject(!1),d=(g=s==null?void 0:s.visible$)!=null?g:O.of(null),u=l.subscribeContextValue$(a.FOCUSING_FX_BAR_EDITOR).subscribe(S=>{c.next(S)});return O.combineLatest([o.currentUser$,r,d,c]).pipe(me.finalize(()=>{u.unsubscribe(),c.complete()}),me.switchMap(([S,f,p,v])=>!f||p!=null&&p.visible&&p.unitId===f.getUnitId()&&!e||v&&!e?O.of(!0):f.activeSheet$.pipe(me.switchMap(C=>{if(!C)return O.of(!0);const I=n.get(m.SheetsSelectionsService),R=n.get(m.RangeProtectionRuleModel),w=n.get(m.WorksheetProtectionRuleModel),y=n.get(a.IContextService).subscribeContextValue$(a.FOCUSING_COMMON_DRAWINGS).pipe(me.startWith(!1));return O.combineLatest([I.selectionMoveEnd$,y]).pipe(me.switchMap(([P,x])=>{if(x)return O.of(!0);const A=f.getUnitId(),k=C.getSheetId(),D=n.get(a.IPermissionService),{workbookTypes:H=[m.WorkbookEditablePermission],worksheetTypes:W,rangeTypes:N}=i,U=[];if(H==null||H.forEach(j=>{U.push(new j(A).id)}),W==null||W.forEach(j=>{U.push(new j(A,k).id)}),w.getRule(A,k))return D.composePermission$(U).pipe(me.map(j=>j.some(z=>z.value===!1)));const F=P==null?void 0:P.map(j=>j.range),B=R.getSubunitRuleList(A,k).filter(j=>F==null?void 0:F.some(z=>j.ranges.some(K=>a.Rectangle.intersects(z,K))));return N==null||N.forEach(j=>{B.forEach(z=>{U.push(new j(A,k,z.permissionId).id)})}),D.composePermission$(U).pipe(me.map(j=>j.some(z=>z.value===!1)))}))}))))}function Nn(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(m.RangeProtectionRuleModel),r=n.get(a.IPermissionService);return O.merge(e.selectionMoveEnd$,r.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var h;const o=(h=e.getCurrentLastSelection())==null?void 0:h.range;if(!o)return!0;const s=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s==null?void 0:s.getActiveSheet();if(!s||!l)return!0;const c=s.getUnitId(),d=l.getSheetId(),u=[new m.WorkbookEditablePermission(c).id,new m.WorksheetEditPermission(c,d).id];return t.getSubunitRuleList(c,d).filter(g=>g.ranges.some(S=>a.Rectangle.intersects(o,S))).forEach(g=>{u.push(new m.RangeProtectionPermissionEditPoint(c,d,g.permissionId).id)}),r.composePermission(u).some(g=>g.value===!1)}))}function Vl(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return O.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var g;const s=(g=t.getCurrentLastSelection())==null?void 0:g.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id];return r.getSubunitRuleList(d,u).filter(S=>i==="row"?S.ranges.some(f=>s.startRow>f.startRow&&s.startRow<=f.endRow):S.ranges.some(f=>s.startColumn>f.startColumn&&s.startColumn<=f.endColumn)).forEach(S=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,S.permissionId).id)}),o.composePermission(h).some(S=>S.value===!1)}))}function Wl(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return O.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var S;const s=(S=t.getCurrentLastSelection())==null?void 0:S.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id],g=a.Tools.deepClone(s);return i==="row"?(g.startColumn=0,g.endColumn=c.getColumnCount()-1):(g.startRow=0,g.endRow=c.getRowCount()-1),r.getSubunitRuleList(d,u).filter(f=>f.ranges.some(p=>a.Rectangle.intersects(g,p))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),o.composePermission(h).some(f=>f.value===!1)}))}function Bi(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return O.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var S;const s=(S=t.getCurrentLastSelection())==null?void 0:S.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id],g=a.Tools.deepClone(s);return i==="row"?g.endRow=c.getRowCount()-1:g.endColumn=c.getColumnCount()-1,r.getSubunitRuleList(d,u).filter(f=>f.ranges.some(p=>a.Rectangle.intersects(g,p))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),o.composePermission(h).some(f=>f.value===!1)}))}function Hn(n,i){const t=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),r=n.get(m.WorksheetProtectionRuleModel),o=n.get(m.RangeProtectionRuleModel),s=n.get(a.IPermissionService),l=n.get(a.UserManagerService);return O.combineLatest([l.currentUser$,t]).pipe(me.switchMap(([c,d])=>d?d.activeSheet$.pipe(me.switchMap(u=>{if(!u)return O.of(!0);const h=d.getUnitId(),g=[];return i.forEach(f=>g.push(new f(h).id)),s.composePermission$(g).pipe(me.map(f=>f.every(p=>p.value===!0))).pipe(me.map(f=>{if(!f)return!0;const p=u.getSheetId(),v=r.getRule(h,p),C=o.getSubunitRuleList(h,p);return!!(v||C.length)}))})):O.of(!0)))}var Ul=(n=>(n.ROW_HEADER_CONTEXT_MENU="ROW_HEADER_CONTEXT_MENU",n.COL_HEADER_CONTEXT_MENU="COL_HEADER_CONTEXT_MENU",n.SHEET_BAR="SHEET_BAR",n.SHEET_FOOTER="SHEET_FOOTER",n))(Ul||{});function pg(n){const i=n.get(et);return{id:kn.id,subId:Vi.id,type:_.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",activated$:new O.Observable(e=>{let t=!1;const r=i.status$.subscribe(o=>{t=o!==De.OFF,e.next(t)});return e.next(t),()=>{r.unsubscribe()}}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetCopyPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function vg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IContextService),r=n.get(m.SheetsSelectionsService);return{id:Qt.id,type:_.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=r.getCurrentLastSelection())==null?void 0:S.primary;let v=a.FontWeight.NORMAL;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getFontWeight()}s.next(v===a.FontWeight.BOLD)}if((g===Re.SetTextSelectionsOperation.id||g===ee.SetInlineFormatCommand.id)&&t.getContextValue(a.EDITOR_ACTIVATED)&&t.getContextValue(a.FOCUSING_SHEET)){const p=yr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.bl;s.next(v===a.BooleanNumber.TRUE)}}),c=(u=r.getCurrentLastSelection())==null?void 0:u.primary;if(!o){s.next(!1);return}let d=a.FontWeight.NORMAL;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontWeight()}return s.next(d===a.FontWeight.BOLD),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Cg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService);return{id:Jt.id,type:_.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let v=a.FontItalic.NORMAL;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getFontStyle()}s.next(v===a.FontItalic.ITALIC)}if((g===Re.SetTextSelectionsOperation.id||g===ee.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const p=yr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.it;s.next(v===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d=a.FontItalic.NORMAL;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontStyle()}return s.next(d===a.FontItalic.ITALIC),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function _g(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService);return{id:$t.id,type:_.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",activated$:be(e,!1,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let v;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getUnderline()}s.next(!!(v&&v.s))}if((g===Re.SetTextSelectionsOperation.id||g===ee.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const p=yr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.ul;s.next((v==null?void 0:v.s)===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getUnderline()}return s.next(!!(d&&d.s)),l.dispose})),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ig(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService);return{id:en.id,type:_.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let v;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getStrikeThrough()}s.next(!!(v&&v.s))}if((g===Re.SetTextSelectionsOperation.id||g===ee.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const p=yr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.st;s.next((v==null?void 0:v.s)===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getStrikeThrough()}return s.next(!!(d&&d.s)),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function bg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=a.DEFAULT_STYLES.ff;return{id:Cr.id,tooltip:"toolbar.font",type:_.MenuItemType.SELECTOR,label:Wi,selections:_.FONT_FAMILY_LIST.map(o=>({label:{name:Ui},value:o.value})),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),value$:be(e,r,({worksheet:o})=>new O.Observable(s=>{const l=()=>{var h;let d=r;const u=(h=t.getCurrentLastSelection())==null?void 0:h.primary;if(u!=null){const g=o.getCellStyle(u.startRow,u.startColumn),S=o.getDefaultCellStyleInternal(),f=o.getRowStyle(u.startRow),p=o.getColumnStyle(u.startColumn),v=a.composeStyles(S,f,p,g);v.ff&&(d=v.ff)}s.next(d)},c=i.onCommandExecuted(d=>{const u=d.id;(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetActiveOperation.id)&&l()});return l(),c.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Rg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService),o=a.DEFAULT_STYLES.fs,s=te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0);return{id:vr.id,type:_.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:Li,props:{min:1,max:400,disabled$:s}},selections:_.FONT_SIZE_LIST,disabled$:s,value$:be(e,o,({worksheet:l})=>new O.Observable(c=>{const d=()=>{var f;let g=o;const S=(f=t.getCurrentLastSelection())==null?void 0:f.primary;if(S!=null){const p=l.getCellStyle(S.startRow,S.startColumn),v=l.getDefaultCellStyleInternal(),C=l.getRowStyle(S.startRow),I=l.getColumnStyle(S.startColumn),R=a.composeStyles(v,C,I,p);R.fs&&(g=R.fs)}c.next(g)},u=()=>{var S,f;const g=yr(n);if(g!=null){const p=(f=(S=g.ts)==null?void 0:S.fs)!=null?f:o;c.next(p)}},h=i.onCommandExecuted(g=>{const S=g.id;(S===m.SetRangeValuesMutation.id||S===m.SetSelectionsOperation.id||S===m.SetWorksheetActiveOperation.id)&&d(),(S===Re.SetTextSelectionsOperation.id||S===ee.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)&&u()});return d(),h.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Eg(n){return{id:xs.id,type:_.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function wg(n){const i=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:Tn.id,icon:"FontColor",tooltip:"toolbar.textColor.main",type:_.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:wr,hoverable:!1,selectable:!1}}],value$:new O.Observable(t=>{const r=e.getCurrentTheme().textColor,o=i.onCommandExecuted(s=>{if(s.id===Tn.id){const l=s.params.value;t.next(l!=null?l:r)}});return t.next(r),o.dispose}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function Tg(n){return{id:m.ResetBackgroundColorCommand.id,type:_.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function yg(n){const i=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:m.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",type:_.MenuItemType.BUTTON_SELECTOR,icon:"PaintBucket",selections:[{label:{name:wr,hoverable:!1,selectable:!1}}],value$:new O.Observable(t=>{const r=e.getCurrentTheme().primaryColor,o=i.onCommandExecuted(s=>{if(s.id===m.SetBackgroundColorCommand.id){const l=s.params.value;t.next(l!=null?l:r)}});return t.next(r),o.dispose}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const pa=[{label:"align.left",icon:"LeftJustifyingSingle",value:a.HorizontalAlign.LEFT},{label:"align.center",icon:"HorizontallySingle",value:a.HorizontalAlign.CENTER},{label:"align.right",icon:"RightJustifyingSingle",value:a.HorizontalAlign.RIGHT}];function Mg(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.HorizontalAlign.LEFT;return{id:m.SetHorizontalTextAlignCommand.id,icon:pa[0].icon,tooltip:"toolbar.horizontalAlignMode.main",type:_.MenuItemType.SELECTOR,selections:pa,value$:be(i,t,({worksheet:r})=>new O.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetHorizontalTextAlignCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);S=p==null?void 0:p.getHorizontalAlignment()}o.next(S!=null?S:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=r.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getHorizontalAlignment()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const va=[{label:"align.top",icon:"AlignTopSingle",value:a.VerticalAlign.TOP},{label:"align.middle",icon:"VerticalCenterSingle",value:a.VerticalAlign.MIDDLE},{label:"align.bottom",icon:"AlignBottomSingle",value:a.VerticalAlign.BOTTOM}];function Pg(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.VerticalAlign.BOTTOM;return{id:m.SetVerticalTextAlignCommand.id,icon:va[2].icon,tooltip:"toolbar.verticalAlignMode.main",type:_.MenuItemType.SELECTOR,selections:va,value$:be(i,t,({worksheet:r})=>new O.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetVerticalTextAlignCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);S=p==null?void 0:p.getVerticalAlignment()}o.next(S!=null?S:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=r.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getVerticalAlignment()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const Ca=[{label:"textWrap.overflow",icon:"OverflowSingle",value:a.WrapStrategy.OVERFLOW},{label:"textWrap.wrap",icon:"AutowrapSingle",value:a.WrapStrategy.WRAP},{label:"textWrap.clip",icon:"TruncationSingle",value:a.WrapStrategy.CLIP}];function Og(n){const i=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=a.WrapStrategy.OVERFLOW;return{id:m.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:Ca[0].icon,type:_.MenuItemType.SELECTOR,selections:Ca,value$:be(e,t,({worksheet:r})=>new O.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetTextWrapCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=i.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);S=p==null?void 0:p.getWrapStrategy()}o.next(S!=null?S:t)}),l=(d=i.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=r.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getWrapStrategy()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const _a=[{label:"textRotate.none",icon:"NoRotationSingle",value:0},{label:"textRotate.angleUp",icon:"LeftRotationFortyFiveDegreesSingle",value:-45},{label:"textRotate.angleDown",icon:"RightRotationFortyFiveDegreesSingle",value:45},{label:"textRotate.vertical",icon:"VerticalTextSingle",value:"v"},{label:"textRotate.rotationUp",icon:"LeftRotationNinetyDegreesSingle",value:-90},{label:"textRotate.rotationDown",icon:"RightRotationNinetyDegreesSingle",value:90}];function xg(n){const i=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=0;return{id:m.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:_a[0].icon,type:_.MenuItemType.SELECTOR,selections:_a,value$:be(e,t,({worksheet:r})=>new O.Observable(o=>{var d,u;const s=n.get(a.ICommandService).onCommandExecuted(h=>{var p,v;const g=h.id;if(g!==m.SetTextRotationCommand.id&&g!==m.SetSelectionsOperation.id&&g!==m.SetWorksheetActiveOperation.id)return;const S=(p=i.getCurrentLastSelection())==null?void 0:p.primary;let f;if(S!=null){const C=r.getRange(S.startRow,S.startColumn);f=C==null?void 0:C.getTextRotation()}(f==null?void 0:f.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((v=f&&f.a)!=null?v:t)}),l=(d=i.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const h=r.getRange(l.startRow,l.startColumn);c=h==null?void 0:h.getTextRotation()}return(c==null?void 0:c.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((u=c&&c.a)!=null?u:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Tr(n){return new O.Observable(e=>e.next(!n.get(_.IClipboardInterfaceService).supportClipboard))}function pn(n){return{id:Xe.name,commandId:Xe.id,type:_.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",disabled$:te(n,{workbookTypes:[m.WorkbookCopyPermission],worksheetTypes:[m.WorksheetCopyPermission],rangeTypes:[m.RangeProtectionPermissionViewPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function qi(n){return{id:Ye.name,commandId:Ye.id,type:_.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Jn="sheet.menu.paste-special";function Qi(n){return{id:Jn,type:_.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",hidden$:tn(n,_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET))}}function Ji(n){return{id:gn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteValue",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellValuePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function $i(n){return{id:Sn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteFormat",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function eo(n){return{id:Vt.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e))}}function to(n){return{id:fn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission,m.WorksheetSetRowStylePermission,m.WorksheetSetColumnStylePermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ag(n){return{id:m.SetWorksheetRowIsAutoHeightCommand.id,type:_.MenuItemType.BUTTON,icon:"AutoHeight",title:"rightClick.fitContent",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function kg(n){return{id:Er.id,type:_.MenuItemType.BUTTON,icon:"AutoWidth",title:"rightClick.fitContent",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Ll="sheet.menu.sheet-frozen";function Dg(n){return{id:Ll,type:_.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Yo="sheet.header-menu.sheet-frozen";function Ia(n){return{id:Yo,type:_.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function no(n){return{id:ht.id,type:_.MenuItemType.BUTTON,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ng(n){return{id:br.id,type:_.MenuItemType.BUTTON,title:"rightClick.freezeRow",icon:"FreezeRowSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Hg(n){return{id:Rr.id,type:_.MenuItemType.BUTTON,title:"rightClick.freezeCol",icon:"FreezeColumnSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function ro(n){return{id:m.CancelFrozenCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Vg(n){return{id:fr.id,type:_.MenuItemType.BUTTON,icon:"Hide",title:"rightClick.hideSelectedRow",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Wg(n){return{id:pr.id,type:_.MenuItemType.BUTTON,icon:"Hide",title:"rightClick.hideSelectedColumn",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ug(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),r=[m.SetSelectionsOperation,m.SetRowHiddenMutation,m.SetRowVisibleMutation].map(o=>o.id);return{id:m.SetSelectedRowsVisibleCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.showHideRow",hidden$:be(i,!0,({worksheet:o})=>new O.Observable(s=>{function l(){var u;const d=(u=e.getCurrentSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.ROW);return!!(d!=null&&d.some(h=>{for(let g=h.startRow;g<=h.endRow;g++)if(!o.getRowRawVisible(g))return!0;return!1}))}const c=t.onCommandExecuted(d=>{r.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Lg(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),r=[m.SetSelectionsOperation,m.SetColHiddenMutation,m.SetColVisibleMutation].map(o=>o.id);return{id:m.SetSelectedColsVisibleCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.showHideColumn",hidden$:be(i,!0,({worksheet:o})=>new O.Observable(s=>{function l(){var u;const d=(u=e.getCurrentSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.COLUMN);return!d||d.length===0?!1:!!d.some(h=>{for(let g=h.startColumn;g<=h.endColumn;g++)if(!o.getColVisible(g))return!0;return!1})}const c=t.onCommandExecuted(d=>{r.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Bg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=0;return{id:m.SetRowHeightCommand.id,type:_.MenuItemType.BUTTON,icon:"AdjustHeight",label:{name:tt,props:{prefix:"rightClick.rowHeight",suffix:"px",min:2,max:1e3}},value$:be(e,r,({worksheet:o})=>new O.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary,u=d?o.getRowHeight(d.startRow):r;s.next(u)}const c=i.onCommandExecuted(d=>{const u=d.id;if(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetRowIsAutoHeightMutation.id)return l()});return l(),c.dispose})),hidden$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Fg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=0;return{id:m.SetColWidthCommand.id,type:_.MenuItemType.BUTTON,icon:"AdjustWidth",label:{name:tt,props:{prefix:"rightClick.columnWidth",suffix:"px",min:2,max:1e3}},value$:be(e,r,({worksheet:o})=>new O.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary;let u=r;d!=null&&(u=o.getColumnWidth(d.startColumn)),s.next(u)}const c=i.onCommandExecuted(d=>{const u=d.id;if(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetColWidthMutation.id)return l()});return l(),c.dispose})),hidden$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function yr(n){var c;const i=n.get(a.IUniverInstanceService),e=n.get(Re.DocSelectionManagerService),t=i.getUniverDocInstance(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),r=e.getActiveTextRange();if(t==null||r==null)return null;const o=(c=t.getBody())==null?void 0:c.textRuns;if(o==null)return;const{startOffset:s}=r;return o.find(({st:d,ed:u})=>s>=d&&s<=u)}var jg=Object.getOwnPropertyDescriptor,zg=(n,i,e,t)=>{for(var r=t>1?void 0:t?jg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},xt=(n,i)=>(e,t)=>i(e,t,n);const Xg="__SpreadsheetFreezeRowMainName__",Yg="__SpreadsheetFreezeRowHeaderName__",Gg="__SpreadsheetFreezeColumnMainName__",Zg="__SpreadsheetFreezeColumnHeaderName__",io=2,Kg=.01,Fn=a.createInterceptorKey("freezePermissionCheck");exports.HeaderFreezeRenderController=class extends a.Disposable{constructor(e,t,r,o,s,l,c,d){super();E(this,"_rowFreezeHeaderRect");E(this,"_rowFreezeMainRect");E(this,"_columnFreezeHeaderRect");E(this,"_columnFreezeMainRect");E(this,"_freezeDownSubs");E(this,"_freezePointerEnterSubs");E(this,"_freezePointerLeaveSubs");E(this,"_scenePointerMoveSub");E(this,"_scenePointerUpSub");E(this,"_changeToRow",-1);E(this,"_changeToColumn",-1);E(this,"_changeToOffsetX",0);E(this,"_changeToOffsetY",0);E(this,"_activeViewport",null);E(this,"_freezeNormalHeaderColor","");E(this,"_freezeNormalMainColor","");E(this,"_freezeActiveColor","");E(this,"_freezeHoverColor","");E(this,"_lastFreeze");E(this,"interceptor",new a.InterceptorManager({FREEZE_PERMISSION_CHECK:Fn}));this._context=e,this._sheetSkeletonManagerService=t,this._commandService=r,this._selectionManagerService=o,this._scrollManagerService=s,this._themeService=l,this._sheetInterceptorService=c,this._injector=d,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._themeChangeListener(),this._interceptorCommands(),this._bindViewportScroll(),this._zoomRefresh()}_createFreeze(e=0,t){var x;const r=t!=null?t:this._getFreeze();if(r==null)return null;const o=(x=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:x.skeleton,{startRow:s,startColumn:l}=r,c=this._getPositionByIndex(s,l);if(c==null||o==null)return null;const d=this._getSheetObject(),u=d.engine,h=(u==null?void 0:u.width)||0,g=(u==null?void 0:u.height)||0,S=d.scene,{startX:f,startY:p}=c,{rowTotalHeight:v,columnTotalWidth:C,rowHeaderWidthAndMarginLeft:I,columnHeaderHeightAndMarginTop:R}=o,w=h>C+I?h:C+R,M=g>v+R?g:v+R;this._changeToRow=s,this._changeToColumn=l,this._changeToOffsetX=f,this._changeToOffsetY=p;const y=Math.max(S.scaleX,S.scaleY);let P=io/Math.max(1,y);if(e===0){(s===-1||s===0)&&(P=P*2);const A=P;this._rowFreezeHeaderRect=new T.Rect(Yg,{fill:this._freezeNormalHeaderColor,width:I,height:P,left:0,top:p-A,zIndex:3});let k=this._freezeNormalHeaderColor;(s===-1||s===0)&&(k=this._freezeNormalMainColor),this._rowFreezeMainRect=new T.Rect(Xg,{fill:k,width:w*2/y,height:P,left:I,top:p-A,zIndex:3}),S.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],bt)}else{(l===-1||l===0)&&(P=P*2);const A=P;this._columnFreezeHeaderRect=new T.Rect(Zg,{fill:this._freezeNormalHeaderColor,width:P,height:R,left:f-A,top:0,zIndex:3});let k=this._freezeNormalHeaderColor;(l===-1||l===0)&&(k=this._freezeNormalMainColor),this._columnFreezeMainRect=new T.Rect(Gg,{fill:k,width:P,height:M*2/y,left:f-A,top:R,zIndex:3}),S.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],bt)}this._eventBinding(e)}_eventBinding(e=0){let t=this._rowFreezeHeaderRect,r=this._rowFreezeMainRect;e===1&&(t=this._columnFreezeHeaderRect,r=this._columnFreezeMainRect);const o=this._getSheetObject();if(o==null)return;const{scene:s}=o;if(this._freezePointerEnterSubs=new O.Subscription,this._freezePointerLeaveSubs=new O.Subscription,this._freezeDownSubs=new O.Subscription,r){const d=r.onPointerEnter$.subscribeEvent(()=>{if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(T.CURSOR_TYPE.GRAB)});this._freezePointerEnterSubs.add(d);const u=r.onPointerLeave$.subscribeEvent(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),s.resetCursor()});this._freezePointerLeaveSubs.add(u)}if(t){const d=t.onPointerEnter$.subscribeEvent(()=>{if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(T.CURSOR_TYPE.GRAB)});this._freezePointerEnterSubs.add(d);const u=t.onPointerLeave$.subscribeEvent(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),s.resetCursor()});this._freezePointerLeaveSubs.add(u)}const l=t==null?void 0:t.onPointerDown$.subscribeEvent(d=>{this._freezeDown(d,t,r,e)});l&&this._freezeDownSubs.add(l);const c=r==null?void 0:r.onPointerDown$.subscribeEvent(d=>{this._freezeDown(d,t,r,e)});c&&this._freezeDownSubs.add(c)}_getCurrentLastVisible(){var C,I,R,w,M,y,P;const e=this._getSheetObject();if(e==null)return;const t=(C=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:C.skeleton;if(t==null)return;const r=e.scene,o=Math.max(r.scaleX,r.scaleY),s=this._scrollManagerService.getCurrentScrollState(),l=(e.engine.height-t.columnHeaderHeight)/o,c=(e.engine.width-t.rowHeaderWidth)/o,d=(I=s==null?void 0:s.sheetViewStartRow)!=null?I:0,u=d===0?-((R=s==null?void 0:s.offsetY)!=null?R:0):t.rowHeightAccumulation[d-1]-((w=s==null?void 0:s.offsetY)!=null?w:0);let h=0,g=!1;for(let x=d,A=t.rowHeightAccumulation.length;x<A;x++)if(t.rowHeightAccumulation[x]-u>l){h=x,g=!0;break}g||(h=t.rowHeightAccumulation.length-1);const S=(M=s==null?void 0:s.sheetViewStartColumn)!=null?M:0,f=S===0?-((y=s==null?void 0:s.offsetX)!=null?y:0):t.columnWidthAccumulation[S-1]-((P=s==null?void 0:s.offsetX)!=null?P:0);let p=0,v=!1;for(let x=S,A=t.columnWidthAccumulation.length;x<A;x++)if(t.columnWidthAccumulation[x]-f>c){p=x,v=!0;break}return v||(p=t.columnWidthAccumulation.length-1),{lastRow:h,lastColumn:p}}_getActiveViewport(e){var r;const t=(r=this._getSheetObject())==null?void 0:r.scene.getViewports();return t&&t.find(o=>o.isHit(new T.Vector2(e.offsetX,e.offsetY)))||null}_freezeDown(e,t,r,o=0){var f;const s=(f=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:f.skeleton;if(s==null)return;const l=this._getSheetObject();if(l==null)return;if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;const{scene:d}=l;d.setCursor(T.CURSOR_TYPE.GRABBING),d.disableObjectsEvent();const u=this._getCurrentLastVisible(),h=u===void 0?Number.POSITIVE_INFINITY:s.rowHeightAccumulation[u.lastRow],g=u===void 0?Number.POSITIVE_INFINITY:s.columnWidthAccumulation[u.lastColumn-1]+s.rowHeaderWidth;this._activeViewport=null;const S=this._getFreeze();S&&(this._changeToColumn=S.startColumn,this._changeToRow=S.startRow),this._scenePointerMoveSub=d.onPointerMove$.subscribeEvent(p=>{var P,x,A,k;const v=this._getActiveViewport(p),{startX:C,startY:I,row:R,column:w}=qe(p.offsetX,p.offsetY,d,s,v||void 0,!0);if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;d.setCursor(T.CURSOR_TYPE.GRABBING);const y=io/Math.max(d.scaleX,d.scaleY);o===0?((P=t.transformByState({top:Math.min(I,h)-y/2}))==null||P.setProps({fill:this._freezeActiveColor}),(x=r.transformByState({top:Math.min(I,h)-y/2}))==null||x.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=u===void 0?R:Math.min(R,u.lastRow),this._changeToOffsetY=Math.min(I,h),this._activeViewport=v):((A=t.transformByState({left:Math.min(C,g)-y/2}))==null||A.setProps({fill:this._freezeActiveColor}),(k=r.transformByState({left:Math.min(C,g)-y/2}))==null||k.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=u===void 0?w:Math.min(w,u.lastColumn),this._changeToOffsetX=C,this._activeViewport=v)}),this._scenePointerUpSub=d.onPointerUp$.subscribeEvent(()=>{var D,H;d.resetCursor(),d.enableObjectsEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:p,columnHeaderHeightAndMarginTop:v}=s;o===0&&(this._changeToRow===0||this._changeToRow===-1)||o===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(t.setProps({fill:this._freezeNormalHeaderColor}),r.setProps({fill:this._freezeNormalMainColor})):(t==null||t.setProps({fill:this._freezeNormalHeaderColor}),r==null||r.setProps({fill:this._freezeNormalHeaderColor}));const C=io/Math.max(d.scaleX,d.scaleY);o===0?(this._changeToRow===0||this._changeToRow===-1)&&(t.transformByState({top:v-C}),r.transformByState({top:v-C})):(this._changeToColumn===0||this._changeToColumn===-1)&&(t.transformByState({left:p-C}),r.transformByState({left:p-C}));const I=this._scrollManagerService.getCurrentScrollState()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:R,sheetViewStartColumn:w}=I;if(w==null||R==null)return;const M=this._context.unit,y=M.getActiveSheet();if(!y)return;const P=(D=y.getConfig())==null?void 0:D.freeze;let x=(P==null?void 0:P.xSplit)||0,A=(P==null?void 0:P.ySplit)||0;const k=(H=this._activeViewport)==null?void 0:H.viewportKey;o===0&&(!k||k===T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP?A=this._changeToRow-(P.startRow-P.ySplit):A=this._changeToRow-R,A=A<0?0:A),o===1&&(!k||k===T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT||k===T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT?x=this._changeToColumn-(P.startColumn-P.xSplit):x=this._changeToColumn-w,x=x<0?0:x),this._commandService.executeCommand(m.SetFrozenCommand.id,{startRow:A===0?-1:this._changeToRow,startColumn:x===0?-1:this._changeToColumn,ySplit:A,xSplit:x,unitId:M.getUnitId(),subUnitId:y.getSheetId()})})}_getViewports(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e,r=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT),o=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT),s=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP),l=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM),c=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP),d=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),u=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP),h=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT),g=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(!(r==null||o==null||s==null||l==null||c==null||d==null||u==null||h==null||g==null))return{viewMain:d,viewMainLeftTop:u,viewMainLeft:h,viewMainTop:g,viewColumnLeft:r,viewColumnRight:o,viewRowTop:s,viewRowBottom:l,viewLeftTop:c}}_bindViewportScroll(){const e=this._getViewports();if(!e)return;const{viewRowBottom:t,viewColumnRight:r,viewMainLeft:o,viewMainTop:s}=e;this.disposeWithMe(this._scrollManagerService.validViewportScrollInfo$.subscribe(l=>{if(!l)return;const{scrollX:c,scrollY:d,viewportScrollX:u,viewportScrollY:h}=l;t.isActive&&t.updateScrollVal({scrollY:d,viewportScrollY:h}),r.isActive&&r.updateScrollVal({scrollX:c,viewportScrollX:u}),o.isActive&&o.updateScrollVal({scrollY:d,viewportScrollY:h}),s.isActive&&s.updateScrollVal({scrollX:c,viewportScrollX:u})}))}_updateViewport(e=-1,t=-1,r=0,o=0,s=3){var x;const l=(x=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:x.skeleton;if(l==null)return;const{rowHeaderWidthAndMarginLeft:c,columnHeaderHeightAndMarginTop:d}=l,u=this._getViewports();if(!u)return;const{viewMain:h,viewMainLeftTop:g,viewMainLeft:S,viewMainTop:f,viewColumnLeft:p,viewColumnRight:v,viewRowTop:C,viewRowBottom:I,viewLeftTop:R}=u;v.resizeWhenFreezeChange({left:c,top:0,height:d+1,right:0}),I.resizeWhenFreezeChange({left:0,top:d,bottom:0,width:c+1}),R.resizeWhenFreezeChange({left:0,top:0,width:c+1,height:d});let w=!0,M=!0;g.enable(),(e===-1||e===0)&&(w=!1),(t===-1||t===0)&&(M=!1);const y=l.getNoMergeCellWithCoordByIndex(e-r,t-o,!1),P=l.getNoMergeCellWithCoordByIndex(e,t,!1);if(g.disable(),f.disable(),S.disable(),C.disable(),p.disable(),g.resetPadding(),f.resetPadding(),S.resetPadding(),C.resetPadding(),p.resetPadding(),w===!1&&M===!1)h.resizeWhenFreezeChange({left:c,top:d,bottom:0,right:0}),h.resetPadding(),S.resizeWhenFreezeChange({left:c,top:d,bottom:0,width:0}),f.resizeWhenFreezeChange({left:c,top:d,height:0,right:0}),g.resizeWhenFreezeChange({left:c,top:d,width:0,height:0}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:0}),p.resizeWhenFreezeChange({left:0,top:0,height:d+1,width:0});else if(w===!0&&M===!1){const A=P.startY-y.startY;h.resizeWhenFreezeChange({left:c,top:d+A,bottom:0,right:0}),h.setPadding({startY:y.startY,endY:P.startY,startX:0,endX:0}),s&2&&this._commandService.executeCommand(ze.id,{sheetViewStartRow:0,offsetY:0}),f.resizeWhenFreezeChange({left:c,top:d,height:A,right:0}),f.updateScrollVal({viewportScrollY:y.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:A}),C.updateScrollVal({viewportScrollY:y.startY}),I.resizeWhenFreezeChange({left:0,top:d+A,bottom:0,width:c+1}),f.enable(),C.enable()}else if(w===!1&&M===!0){const A=P.startX-y.startX;h.resizeWhenFreezeChange({left:c+A,top:d,bottom:0,right:0}),h.setPadding({startX:y.startX,endX:P.startX,startY:0,endY:0}),s&1&&this._commandService.executeCommand(ze.id,{sheetViewStartColumn:0,offsetX:0}),S.resizeWhenFreezeChange({left:c,top:d,width:A,bottom:0,right:0}),S.updateScrollVal({viewportScrollX:y.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),p.resizeWhenFreezeChange({left:c,top:0,width:A,height:d+1}),p.updateScrollVal({viewportScrollX:y.startX}),v.resizeWhenFreezeChange({left:c+A,top:0,height:d+1,right:0}),S.enable(),p.enable()}else{const A=P.startX-y.startX,k=P.startY-y.startY;h.resizeWhenFreezeChange({left:c+A,top:d+k,bottom:0,right:0}),h.setPadding({startY:y.startY,endY:P.startY,startX:y.startX,endX:P.startX}),s&&this._commandService.executeCommand(ze.id,{...s&1?{sheetViewStartColumn:0,offsetX:0}:null,...s&2?{sheetViewStartRow:0,offsetY:0}:null}),S.resizeWhenFreezeChange({left:c,top:d+k,width:A,bottom:0}),S.updateScrollVal({viewportScrollX:y.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),f.resizeWhenFreezeChange({left:c+A,top:d,height:k,right:0}),f.updateScrollVal({viewportScrollY:y.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),g.resizeWhenFreezeChange({left:c,top:d,width:A,height:k}),g.updateScrollVal({viewportScrollX:y.startX,viewportScrollY:y.startY}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:k}),C.updateScrollVal({viewportScrollY:y.startY}),I.resizeWhenFreezeChange({left:0,top:d+k,bottom:0,width:c+1}),p.resizeWhenFreezeChange({left:c,top:0,width:A,height:d+1}),p.updateScrollVal({viewportScrollX:y.startX}),v.resizeWhenFreezeChange({left:c+A,top:0,height:d+1,right:0}),g.enable(),f.enable(),S.enable(),C.enable(),p.enable()}}_skeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{[m.SetWorksheetActiveOperation.id,m.InsertRangeMoveDownCommand.id,m.InsertRangeMoveRightCommand.id].includes((e==null?void 0:e.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const t=this._context.unit.getActiveSheet();if(!t)return;const r=t.getConfig().freeze,{startRow:o=-1,startColumn:s=-1,ySplit:l=0,xSplit:c=0}=r;this._refreshFreeze(o,s,l,c,0)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(this._themeService.currentTheme$.subscribe(e=>{this._clearFreeze(),this._themeChange(e),this._refreshCurrent()}))}_themeChange(e){this._freezeNormalHeaderColor=e.grey400,this._freezeNormalMainColor=new a.ColorKit(e.grey400).setAlpha(Kg).toRgbString(),this._freezeActiveColor=e.primaryColor,this._freezeHoverColor=e.grey500}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{const t={redos:[],undos:[]},r=this._getFreeze();if(!r)return t;const o=s=>{const l=this._context.unit,c=l.getUnitId(),d=l.getActiveSheet();if(!d)return t;const u=d.getSheetId();this._refreshFreeze(s.startRow,s.startColumn,s.ySplit,s.xSplit,0);const h={...s,unitId:c,subUnitId:u,resetScroll:!1},g=m.SetFrozenMutationFactory(this._injector,h);return{undos:[{id:m.SetFrozenMutation.id,params:g}],redos:[{id:m.SetFrozenMutation.id,params:h}]}};if(e.id===m.InsertRowCommand.id){const s=e.params,{range:l,direction:c}=s,d=l.endRow-l.startRow+1;if(l.startRow+1<r.startRow||l.startRow+1===r.startRow&&c===a.Direction.UP){const u={...r,startRow:Math.max(1,r.startRow+d),ySplit:Math.max(1,r.ySplit+d)};return o(u)}}if(e.id===m.InsertColCommand.id){const s=e.params,{range:l,direction:c}=s,d=l.endColumn-l.startColumn+1;if(l.startColumn+1<r.startColumn||l.startColumn+1===r.startColumn&&c===a.Direction.LEFT){const u={...r,startColumn:Math.max(1,r.startColumn+d),xSplit:Math.max(1,r.xSplit+d)};return o(u)}}if(e.id===m.MoveColsCommand.id){const s=this._selectionManagerService.getCurrentSelections(),{fromRange:{startColumn:l},toRange:{startColumn:c}}=e.params,d=s==null?void 0:s.filter(C=>C.range.rangeType===a.RANGE_TYPE.COLUMN&&C.range.startColumn<=l&&l<=C.range.endColumn);if(!(d!=null&&d.length))return t;const u=d[0].range,h={...u,startColumn:c,endColumn:c+u.endColumn-u.startColumn};if(!r||r.startColumn<=0||u.startColumn>=r.startColumn&&h.startColumn>=r.startColumn||u.startColumn===h.startColumn||u.endColumn<r.startColumn&&h.startColumn<r.startColumn)return t;const g=u.endColumn-u.startColumn+1,S=Math.max(Math.min(r.startColumn,u.endColumn+1)-u.startColumn,0);let f,p;h.startColumn>=r.startColumn?(f=Math.max(r.startColumn-S,1),p=Math.max(r.xSplit-S,1)):(f=r.startColumn+g-S,p=r.xSplit+g-S);const v={...r,startColumn:f,xSplit:p};return o(v)}if(e.id===m.MoveRowsCommand.id){const s=this._selectionManagerService.getCurrentSelections(),{fromRange:{startRow:l},toRange:{startRow:c}}=e.params,d=s==null?void 0:s.filter(C=>C.range.rangeType===a.RANGE_TYPE.ROW&&C.range.startRow<=l&&l<=C.range.endRow);if(!(d!=null&&d.length))return t;const u=d[0].range,h={...u,startRow:c,endRow:c+u.endRow-u.startRow};if(!r||r.startRow<=0||u.startRow>=r.startRow&&h.startRow>=r.startRow||u.startRow===h.startRow||u.endRow<r.startRow&&h.startRow<r.startRow)return t;const g=u.endRow-u.startRow+1,S=Math.max(Math.min(r.startRow,u.endRow+1)-u.startRow,0);let f,p;h.startRow>=r.startRow?(f=Math.max(r.startRow-S,1),p=Math.max(r.ySplit-S,1)):(f=r.startRow+g-S,p=r.ySplit+g-S);const v={...r,startRow:f,ySplit:p};return o(v)}if(e.id===m.RemoveColCommand.id||e.id===m.RemoveRowCommand.id){const s=e.params,l=s.range;if(l.rangeType===a.RANGE_TYPE.COLUMN&&l.startColumn<r.startColumn){const c=Math.min(r.startColumn,l.endColumn+1)-l.startColumn,d={...r,startColumn:Math.max(1,r.startColumn-c),xSplit:Math.max(1,r.xSplit-c)};return o(d)}if(s.range.rangeType===a.RANGE_TYPE.ROW&&l.startRow<r.startRow){const c=Math.min(r.startRow,l.endRow+1)-l.startRow,d={...r,startRow:Math.max(1,r.startRow-c),ySplit:Math.max(1,r.ySplit-c)};return o(d)}}return t}}))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{switch(e.id){case m.SetFrozenMutation.id:case Le.id:{const t=this._lastFreeze,r=this._context.unit,o=r.getActiveSheet(),s=e.params,{unitId:l,subUnitId:c}=s;if(!(l===r.getUnitId()&&c===(o==null?void 0:o.getSheetId())))return;const d=o.getConfig().freeze;if(this._lastFreeze=d,d==null)return;let u=0;const{startRow:h=-1,startColumn:g=-1,ySplit:S=0,xSplit:f=0}=d;(!t||t.startRow!==h||t.ySplit!==S)&&(u|=2),(!t||t.startColumn!==g||t.xSplit!==f)&&(u|=1),s.resetScroll===!1&&(u=0),this._refreshFreeze(h,g,S,f,u)}break;case m.SetWorksheetRowHeightMutation.id:{const t=this._getFreeze(),r=t&&e.params.ranges.some(o=>o.startRow<t.startRow);e.params&&r&&this._refreshCurrent()}break;case m.SetWorksheetColWidthMutation.id:{const t=this._getFreeze();e.params&&t&&e.params.ranges.some(r=>r.startColumn<t.startColumn)&&this._refreshCurrent()}break;case m.SetWorksheetRowAutoHeightMutation.id:{const t=e.params,r=this._getFreeze();if(r&&r.startRow>-1&&t.rowsAutoHeightInfo.some(o=>o.row<r.startRow)){const o=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{o.unsubscribe()})})}}break;case m.SetColHiddenMutation.id:case m.SetColVisibleMutation.id:{const t=e.params,r=this._getFreeze(),o=t.ranges;r&&r.startColumn>-1&&o.some(s=>s.startColumn<r.startColumn)&&this._refreshCurrent()}break;case m.SetRowHiddenMutation.id:case m.SetRowVisibleMutation.id:{const t=e.params,r=this._getFreeze(),o=t.ranges;r&&r.startRow>-1&&o.some(s=>s.startRow<r.startRow)&&this._refreshCurrent()}break;case Oi.id:case xi.id:this._refreshCurrent()}}))}_zoomRefresh(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this.disposeWithMe(t.onTransformChange$.subscribeEvent(r=>{[T.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale,T.TRANSFORM_CHANGE_OBSERVABLE_TYPE.all].includes(r.type)&&this._refreshCurrent()}))}_clearObserverEvent(){var t,r;this._getSheetObject()!=null&&((t=this._scenePointerMoveSub)==null||t.unsubscribe(),(r=this._scenePointerUpSub)==null||r.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null)}_clearFreeze(){var t,r,o,s,l,c;(t=this._rowFreezeHeaderRect)==null||t.dispose(),(r=this._rowFreezeMainRect)==null||r.dispose(),(o=this._columnFreezeHeaderRect)==null||o.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose(),this._getSheetObject()!=null&&([this._freezeDownSubs,this._freezePointerEnterSubs,this._freezePointerLeaveSubs].forEach(d=>{d==null||d.unsubscribe()}),this._freezeDownSubs=null,this._freezePointerEnterSubs=null,this._freezePointerLeaveSubs=null,(l=this._scenePointerMoveSub)==null||l.unsubscribe(),(c=this._scenePointerUpSub)==null||c.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null)}_getPositionByIndex(e,t){var d;if(this._getSheetObject()==null)return;const o=(d=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:d.skeleton,s=o==null?void 0:o.getNoMergeCellWithCoordByIndex(e,t);if(o==null)return;if(s!=null&&(!isNaN(s.endX)||!isNaN(s.endY)))return s;const{rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:c}=o;return{startX:l,endX:l,startY:c,endY:c}}_getFreeze(){var t;const e=(t=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:t.skeleton.getWorksheetConfig();if(e!=null)return e.freeze}_getSheetObject(){return Ge(this._context.unit,this._context)}_refreshFreeze(e,t,r,o,s){var c;const l={startRow:e,startColumn:t,ySplit:r,xSplit:o};this._clearFreeze(),this._createFreeze(0,l),this._createFreeze(1,l),this._updateViewport(e,t,r,o,s),(c=this._getSheetObject())==null||c.spreadsheet.makeForceDirty()}};exports.HeaderFreezeRenderController=zg([xt(1,a.Inject(exports.SheetSkeletonManagerService)),xt(2,a.ICommandService),xt(3,a.Inject(m.SheetsSelectionsService)),xt(4,a.Inject(exports.SheetScrollManagerService)),xt(5,a.Inject(a.ThemeService)),xt(6,a.Inject(m.SheetInterceptorService)),xt(7,a.Inject(a.Injector))],exports.HeaderFreezeRenderController);function qg(n){const i=n.get(m.SheetsSelectionsService),e=n.get(m.RangeProtectionRuleModel),t=n.get(a.IUniverInstanceService),r=n.get(m.MergeCellController),o=t.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET);return O.combineLatest([i.selectionMoveEnd$,o.pipe(O.map(s=>{var l;return(l=s==null?void 0:s.getUnitId())!=null?l:""})),o.pipe(O.switchMap(s=>{var l;return(l=s==null?void 0:s.activeSheet$)!=null?l:O.of(null)}))]).pipe(O.map(([s,l,c])=>{if(!c||!s||s.length===0)return!1;const d=c.getSheetId(),u=s.map(S=>S.range);if(r.interceptor.fetchThroughInterceptors(m.MERGE_CELL_INTERCEPTOR_CHECK)(!1,u))return!0;const g=e.getSubunitRuleList(l,d).map(S=>S.ranges).flat();if(s.length<2){const S=s[0].range;return g.some(p=>a.Rectangle.intersects(p,S)&&!a.Rectangle.contains(p,S))}for(let S=0;S<s.length;S++)for(let f=S+1;f<s.length;f++)if(a.Rectangle.intersects(s[S].range,s[f].range))return!0;return!1}))}function Bl(n,i){return!!ir(n,i,a.RANGE_TYPE.ROW)}function Fl(n,i){return!!ir(n,i,a.RANGE_TYPE.COLUMN)}function ir(n,i,e){return n.find(r=>{const o=r.range,{startRow:s,endRow:l,startColumn:c,endColumn:d,rangeType:u}=o;return u===a.RANGE_TYPE.ALL||u===a.RANGE_TYPE.NORMAL?!1:u===e&&(e===a.RANGE_TYPE.COLUMN&&c<=i&&i<=d||e===a.RANGE_TYPE.ROW&&s<=i&&i<=l)})}var Qg=Object.getOwnPropertyDescriptor,Jg=(n,i,e,t)=>{for(var r=t>1?void 0:t?Qg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},oo=(n,i)=>(e,t)=>i(e,t,n);const $g="__SpreadsheetHeaderMoveControllerBackground__",eS="__SpreadsheetHeaderMoveControllerShapeLine__",tS="rgba(0, 0, 0, 0.1)",nS="rgb(119, 119, 119)",rS=4,so=a.createInterceptorKey("headerMovePermissionCheck");exports.HeaderMoveRenderController=class extends a.Disposable{constructor(e,t,r,o){super();E(this,"_startOffsetX",Number.NEGATIVE_INFINITY);E(this,"_startOffsetY",Number.NEGATIVE_INFINITY);E(this,"_moveHelperBackgroundShape");E(this,"_moveHelperLineShape");E(this,"_headerPointerDownSubs");E(this,"_headerPointerMoveSubs");E(this,"_headerPointerLeaveSubs");E(this,"_dragHeaderMoveSub");E(this,"_scenePointerUpSub");E(this,"_scrollTimer");E(this,"_changeFromColumn",-1);E(this,"_changeFromRow",-1);E(this,"_changeToColumn",-1);E(this,"_changeToRow",-1);E(this,"interceptor",new a.InterceptorManager({HEADER_MOVE_PERMISSION_CHECK:so}));E(this,"_workbookSelections");this._context=e,this._sheetSkeletonManagerService=r,this._commandService=o,this._workbookSelections=t.getWorkbookSelections(this._context.unitId),this._init()}dispose(){var e,t,r,o,s,l,c,d;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose(),(r=this._headerPointerMoveSubs)==null||r.unsubscribe(),(o=this._headerPointerLeaveSubs)==null||o.unsubscribe(),(s=this._headerPointerDownSubs)==null||s.unsubscribe(),this._headerPointerMoveSubs=null,this._headerPointerLeaveSubs=null,this._headerPointerDownSubs=null,(l=this._dragHeaderMoveSub)==null||l.unsubscribe(),(c=this._scenePointerUpSub)==null||c.unsubscribe(),this._dragHeaderMoveSub=null,this._scenePointerUpSub=null,(d=this._scrollTimer)==null||d.dispose()}_init(){this._initialRowOrColumn(a.RANGE_TYPE.ROW),this._initialRowOrColumn(a.RANGE_TYPE.COLUMN)}_initialRowOrColumn(e=a.RANGE_TYPE.ROW){const t=this._context.components.get(he.COLUMN),r=this._context.components.get(he.ROW),o=this._context.scene,s=e===a.RANGE_TYPE.ROW?r:t,l=u=>{var I,R;const h=(I=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:I.skeleton;if(h==null)return;const g=(R=this._workbookSelections.getCurrentLastSelection())==null?void 0:R.range;if(!g||!this.interceptor.fetchThroughInterceptors(so)(!1,g))return;const f=this._workbookSelections.getCurrentSelections(),{row:p,column:v}=qe(u.offsetX,u.offsetY,o,h);if(!ir(f,e===a.RANGE_TYPE.ROW?p:v,e)){o.resetCursor();return}o.setCursor(T.CURSOR_TYPE.GRAB)},c=()=>{var u,h;(u=this._moveHelperBackgroundShape)==null||u.hide(),(h=this._moveHelperLineShape)==null||h.hide(),o.resetCursor()},d=(u,h)=>{var W,N;if(h.isStopPropagation)return;const g=(W=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:W.skeleton;if(g==null)return;const S=(N=this._workbookSelections.getCurrentLastSelection())==null?void 0:N.range;if(!S||!this.interceptor.fetchThroughInterceptors(so)(!1,S))return;const{offsetX:p,offsetY:v}=u,C=o.getCoordRelativeToViewport(T.Vector2.FromArray([p,v])),{x:I,y:R}=C;this._startOffsetX=I,this._startOffsetY=R;const{row:w,column:M}=qe(u.offsetX,u.offsetY,o,g);let y;e===a.RANGE_TYPE.ROW?(this._changeFromRow=w,y=T.ScrollTimerType.Y):(this._changeFromColumn=M,y=T.ScrollTimerType.X);const P=this._workbookSelections.getCurrentSelections(),x=ir(P,e===a.RANGE_TYPE.ROW?w:M,e);if(!x)return;const A=o.getScrollXYInfoByViewport(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),o.setCursor(T.CURSOR_TYPE.GRABBING),o.disableObjectsEvent();let k=!1,D;const H=()=>{if(k)return;D=T.ScrollTimer.create(o,y),this._scrollTimer=D;const U=o.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);D.startScroll(I,R,U),k=!0};this._dragHeaderMoveSub=o.onPointerMove$.subscribeEvent(U=>{H();const{offsetX:L,offsetY:F}=U,{x:B,y:j}=o.getCoordRelativeToViewport(T.Vector2.FromArray([L,F]));this._rowColumnMoving(B,j,x,A,e),D.scrolling(B,j,()=>{this._rowColumnMoving(B,j,x,A,e)})}),this._scenePointerUpSub=o.onPointerUp$.subscribeEvent(()=>{var L,F,B;this._disposeBackgroundAndLine(),o.resetCursor(),o.enableObjectsEvent(),this._clearObserverEvent(),(L=this._scrollTimer)==null||L.dispose();const U=this._workbookSelections.getCurrentSelections();if(e===a.RANGE_TYPE.ROW){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const z=(F=((U==null?void 0:U.filter(K=>K.range.rangeType===a.RANGE_TYPE.ROW&&K.range.startRow<=this._changeFromRow&&this._changeFromRow<=K.range.endRow))||[])[0])==null?void 0:F.range;z&&this._commandService.executeCommand(m.MoveRowsCommand.id,{fromRange:z,toRange:{...z,startRow:this._changeToRow,endRow:this._changeToRow+z.endRow-z.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const z=(B=((U==null?void 0:U.filter(K=>K.range.rangeType===a.RANGE_TYPE.COLUMN&&K.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=K.range.endColumn))||[])[0])==null?void 0:B.range;z&&this._commandService.executeCommand(m.MoveColsCommand.id,{fromRange:z,toRange:{...z,startColumn:this._changeToColumn,endColumn:this._changeToColumn+z.endColumn-z.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})};this._headerPointerMoveSubs=new O.Subscription,this._headerPointerMoveSubs.add(s.onPointerMove$.subscribeEvent(l)),this._headerPointerLeaveSubs=new O.Subscription,this._headerPointerLeaveSubs.add(s==null?void 0:s.onPointerLeave$.subscribeEvent(c)),this._headerPointerDownSubs=new O.Subscription,this._headerPointerDownSubs.add(s==null?void 0:s.onPointerDown$.subscribeEvent(d))}_rowColumnMoving(e,t,r,o,s){var j,z,K,ne,Q,se,ce;const l=this._context.scene,c=(j=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:j.skeleton;if(c==null)return;const{rowHeaderWidth:d,columnHeaderHeight:u,rowTotalHeight:h,columnTotalWidth:g}=c,S=l.getViewportScrollXY(l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN)),{scaleX:f,scaleY:p}=l.getAncestorScale(),v=c.getCellIndexByOffset(e,t,f,p,S),{row:C,column:I}=v,R=c.getNoMergeCellWithCoordByIndex(C,I),{startX:w,startY:M,endX:y,endY:P}=R,x=this._sheetSkeletonManagerService.attachRangeWithCoord(r.range);if(x==null)return;const A=Math.max(f,f),{startX:k,endX:D,startY:H,endY:W,startRow:N,startColumn:U,endRow:L,endColumn:F}=x;s===a.RANGE_TYPE.ROW?(z=this._moveHelperBackgroundShape)==null||z.transformByState({height:W-H,width:g+d,left:0,top:H+(t-this._startOffsetY)/A+S.y-o.y}):(K=this._moveHelperBackgroundShape)==null||K.transformByState({height:h+u,width:D-k,left:k+(e-this._startOffsetX)/A+S.x-o.x,top:0}),(ne=this._moveHelperBackgroundShape)==null||ne.show();const B=rS/A;if(s===a.RANGE_TYPE.ROW){let X=0;if(C<=N)X=M-B/2,this._changeToRow=C;else if(C>L)X=P-B/2,this._changeToRow=C+1;else return;(Q=this._moveHelperLineShape)==null||Q.transformByState({height:B,width:g,left:d,top:X})}else{let X=0;if(I<=U)X=w-B/2,this._changeToColumn=I;else if(I>F)X=y-B/2,this._changeToColumn=I+1;else return;(se=this._moveHelperLineShape)==null||se.transformByState({height:h,width:B,left:X,top:u})}(ce=this._moveHelperLineShape)==null||ce.show()}_clearObserverEvent(){var e,t;(e=this._dragHeaderMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._dragHeaderMoveSub=null,this._scenePointerUpSub=null}_newBackgroundAndLine(){const e=this._context.scene;this._moveHelperBackgroundShape=new T.Rect($g,{fill:tS,evented:!1,zIndex:100}),this._moveHelperLineShape=new T.Rect(eS,{fill:nS,evented:!1,zIndex:100}),e.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],bt)}_disposeBackgroundAndLine(){var e,t;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose()}};exports.HeaderMoveRenderController=Jg([oo(1,a.Inject(m.SheetsSelectionsService)),oo(2,a.Inject(exports.SheetSkeletonManagerService)),oo(3,a.ICommandService)],exports.HeaderMoveRenderController);var Go=(n=>(n[n.VERTICAL=0]="VERTICAL",n[n.HORIZONTAL=1]="HORIZONTAL",n))(Go||{});const iS="rgba(120, 120, 120, 0.01)",ao="rgb(68, 71, 70)",Zn=12,oS=44,Zo=4;class ba extends T.Shape{constructor(e,t){super(e,t);E(this,"_size",Zn);E(this,"_color",ao);E(this,"_mode",0);this.setShapeProps(t)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(e){const t=this.getScene();if(!t)return;const{scaleX:r,scaleY:o}=t.getAncestorScale(),s=Math.max(r,o),l=Zn/s,c=Zo/s;let{width:d,height:u}=this,h=0,g=0;this.mode===0?(d=c,h=l-c):(u=c,g=l-c),T.Rect.drawWith(e,{width:this.width,height:this.height,left:0,top:0,fill:iS}),T.Rect.drawWith(e,{width:d,height:u,fill:ao,radius:c}),e.save(),e.transform(1,0,0,1,h,g),T.Rect.drawWith(e,{width:d,height:u,fill:ao,radius:c}),e.restore()}setShapeProps(e){return e!=null&&e.size&&(this._size=e.size),e!=null&&e.mode&&(this._mode=e.mode),e!=null&&e.color&&(this._color=e.color),this.mode===0?this.transformByState({width:Zn,height:this.size}):this.transformByState({width:this.size,height:Zn}),this}}var sS=Object.getOwnPropertyDescriptor,aS=(n,i,e,t)=>{for(var r=t>1?void 0:t?sS(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},lo=(n,i)=>(e,t)=>i(e,t,n);const lS="__SpreadsheetHeaderResizeControllerShapeRow__",cS="__SpreadsheetHeaderResizeControllerShapeColumn__",Ra="__SpreadsheetHeaderResizeControllerShapeHelper__",Ea="rgb(199, 199, 199)",dS=2,co=a.createInterceptorKey("headerResizePermissionCheck");exports.HeaderResizeRenderController=class extends a.Disposable{constructor(e,t,r,o){super();E(this,"_currentRow",0);E(this,"_currentColumn",0);E(this,"_rowResizeRect");E(this,"_columnResizeRect");E(this,"_headerPointerSubs");E(this,"_scenePointerMoveSub");E(this,"_scenePointerUpSub");E(this,"_resizeHelperShape");E(this,"_startOffsetX",Number.POSITIVE_INFINITY);E(this,"_startOffsetY",Number.POSITIVE_INFINITY);E(this,"interceptor",new a.InterceptorManager({HEADER_RESIZE_PERMISSION_CHECK:co}));this._context=e,this._sheetSkeletonManagerService=t,this._selectionManagerService=r,this._commandService=o,this._init()}dispose(){var e,t,r;(e=this._rowResizeRect)==null||e.dispose(),this._rowResizeRect=null,(t=this._columnResizeRect)==null||t.dispose(),this._columnResizeRect=null,(r=this._headerPointerSubs)==null||r.unsubscribe(),this._headerPointerSubs=null}_init(){const e=this._context.scene;this._rowResizeRect=new ba(lS,{visible:!1,mode:Go.HORIZONTAL,zIndex:100}),this._columnResizeRect=new ba(cS,{visible:!1,mode:Go.VERTICAL,zIndex:100}),e.addObjects([this._rowResizeRect,this._columnResizeRect],bt),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(e=0){const t=this._context.components.get(he.COLUMN),r=this._context.components.get(he.ROW),o=this._context.scene,s=e===0?r:t,l=(d,u)=>{var h,g;(h=this._rowResizeRect)==null||h.hide(),(g=this._columnResizeRect)==null||g.hide()},c=(d,u)=>{var A;const h=(A=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:A.skeleton;if(h==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:g,columnHeaderHeight:S}=h,{startX:f,startY:p,endX:v,endY:C,row:I,column:R}=qe(d.offsetX,d.offsetY,o,h),w=Qn(d.offsetX,d.offsetY,o),{scaleX:M,scaleY:y}=o.getAncestorScale(),P=Math.max(M,y),x=Zn/P;if(e===0){let k=p-x/2;if(w.y<=p+x/2&&w.y>=p)this._currentRow=I-1;else if(w.y>=C-x/2&&w.y<=C)this._currentRow=I,k=C-x/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;if(!this.interceptor.fetchThroughInterceptors(co)(null,{row:this._currentRow}))return!1;const H=Math.min(oS,g/3);this._rowResizeRect.transformByState({left:g/2-H/2,top:k}),this._rowResizeRect.setShapeProps({size:H}),this._rowResizeRect.show()}else{let k=f-x/2;if(w.x<=f+x/2&&w.x>=f)this._currentColumn=R-1;else if(w.x>=v-x/2&&w.x<=v)this._currentColumn=R,k=v-x/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;if(!this.interceptor.fetchThroughInterceptors(co)(null,{col:this._currentColumn}))return!1;const H=S*.7;this._columnResizeRect.transformByState({left:k,top:S/2-H/2}),this._columnResizeRect.setShapeProps({size:H}),this._columnResizeRect.show()}};this._headerPointerSubs=new O.Subscription,this._headerPointerSubs.add(s==null?void 0:s.onPointerMove$.subscribeEvent(c)),this._headerPointerSubs.add(s==null?void 0:s.onPointerLeave$.subscribeEvent(l))}_initialHoverResize(e=0){const t=this._context.scene,r=e===0?this._rowResizeRect:this._columnResizeRect;r!=null&&(this.disposeWithMe(r.onPointerEnter$.subscribeEvent(()=>{r!=null&&(r.show(),t.setCursor(e===0?T.CURSOR_TYPE.ROW_RESIZE:T.CURSOR_TYPE.COLUMN_RESIZE))})),this.disposeWithMe(r.onPointerLeave$.subscribeEvent(()=>{r!=null&&(r.hide(),t.resetCursor())})),this.disposeWithMe(r.onPointerDown$.subscribeEvent(o=>{var F,B,j,z,K,ne,Q;const s=(F=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:F.skeleton;if(s==null)return;const l=this._context.scene,c=l.getEngine(),d=(c==null?void 0:c.height)||0,u=(c==null?void 0:c.width)||0,h=l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),g=(((j=(B=h==null?void 0:h.getScrollBar())==null?void 0:B.horizonScrollTrack)==null?void 0:j.height)||0)+10,S=(((K=(z=h==null?void 0:h.getScrollBar())==null?void 0:z.verticalScrollTrack)==null?void 0:K.width)||0)+10,f=Qn(o.offsetX,o.offsetY,l),{scaleX:p,scaleY:v}=l.getAncestorScale();this._startOffsetX=f.x,this._startOffsetY=f.y;const C=s.getOffsetByColumn(this._currentColumn),I=s.getOffsetByRow(this._currentRow),R=s.getNoMergeCellWithCoordByIndex(this._currentRow,this._currentColumn);let w=!1,M=0,y=0;const{columnTotalWidth:P,rowHeaderWidth:x,rowTotalHeight:A,columnHeaderHeight:k}=s,D=u>P+x?u:P+x,H=d>A+k?d:A+k,W=Math.max(p,v),N=Zo/W;e===0?this._resizeHelperShape=new T.Rect(Ra,{width:D,height:N,fill:Ea,left:0,top:I-N/2}):this._resizeHelperShape=new T.Rect(Ra,{width:N,height:H,fill:Ea,left:C-N/2,top:0});const U=((ne=this._columnResizeRect)==null?void 0:ne.left)||0,L=((Q=this._rowResizeRect)==null?void 0:Q.top)||0;l.addObject(this._resizeHelperShape,bt),l.disableObjectsEvent(),this._scenePointerMoveSub=l.onPointerMove$.subscribeEvent(se=>{var fe,Te,we,Fe,St,Mt;const ce=l.getCoordRelativeToViewport(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),X=l.getScrollXYInfoByViewport(ce,h),G=Qn(se.offsetX,se.offsetY,l),{x:q,y:ie}=G,{scaleX:oe,scaleY:$}=l.getAncestorScale(),J=Math.max(oe,$),de=Zo/J;M=q-this._startOffsetX-de/2,y=ie-this._startOffsetY-de/2,Math.abs(e===0?y:M)>=dS&&(w=!0),e===0?(y>d-g+X.y-R.startY&&(y=d-g+X.y-R.startY),y<-(R.endY-R.startY)+2&&(y=-(R.endY-R.startY)+2),w&&((fe=this._resizeHelperShape)==null||fe.transformByState({top:I+y}),(Te=this._rowResizeRect)==null||Te.transformByState({top:L+y+de/2}),(we=this._rowResizeRect)==null||we.show(),l.setCursor(T.CURSOR_TYPE.ROW_RESIZE))):(M>u-S+X.x-R.startX&&(M=u-S+X.x-R.startX),M<-(R.endX-R.startX)+2&&(M=-(R.endX-R.startX)+2),w&&((Fe=this._resizeHelperShape)==null||Fe.transformByState({left:C+M}),(St=this._columnResizeRect)==null||St.transformByState({left:U+M+de/2}),(Mt=this._columnResizeRect)==null||Mt.show(),l.setCursor(T.CURSOR_TYPE.COLUMN_RESIZE)))}),this._scenePointerUpSub=l.onPointerUp$.subscribeEvent(se=>{var X,G,q;const ce=this._context.scene;this._clearObserverEvent(),(X=this._resizeHelperShape)==null||X.dispose(),this._resizeHelperShape=null,ce.enableObjectsEvent(),w&&(ce.resetCursor(),(G=this._rowResizeRect)==null||G.hide(),(q=this._columnResizeRect)==null||q.hide(),e===0?this._commandService.executeCommand(m.DeltaRowHeightCommand.id,{deltaY:y,anchorRow:this._currentRow}):this._commandService.executeCommand(m.DeltaColumnWidthCommand.id,{deltaX:M,anchorCol:this._currentColumn}))})})),this.disposeWithMe(r.onDblclick$.subscribeEvent(()=>{var h,g,S;this._context.scene.resetCursor();const s=(h=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:h.skeleton;if(!s)return;const l=0,c=0,d=s.worksheet.getRowCount()-1||0,u=s.worksheet.getColumnCount()-1||0;switch(e){case 1:{const f=this._selectionManagerService.getCurrentSelections(),p=[];for(let v=0;v<f.length;v++){const C=f[v];C.range.rangeType===a.RANGE_TYPE.COLUMN&&this._currentColumn<=C.range.endColumn&&this._currentColumn>=C.range.startColumn&&p.push({startColumn:C.range.startColumn,endColumn:C.range.endColumn,startRow:l,endRow:d})}p.length===0&&p.push({startColumn:this._currentColumn,endColumn:this._currentColumn,startRow:l,endRow:d}),this._commandService.executeCommand(Er.id,{ranges:p}),(g=this._columnResizeRect)==null||g.hide();break}case 0:this._commandService.executeCommand(m.SetWorksheetRowIsAutoHeightCommand.id,{ranges:[{startRow:this._currentRow,endRow:this._currentRow,startColumn:c,endColumn:u}]}),(S=this._rowResizeRect)==null||S.hide();break}})))}_clearObserverEvent(){var e,t;(e=this._scenePointerMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null}};exports.HeaderResizeRenderController=aS([lo(1,a.Inject(exports.SheetSkeletonManagerService)),lo(2,a.Inject(m.SheetsSelectionsService)),lo(3,a.ICommandService)],exports.HeaderResizeRenderController);var uS=Object.getOwnPropertyDescriptor,hS=(n,i,e,t)=>{for(var r=t>1?void 0:t?uS(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Lr=(n,i)=>(e,t)=>i(e,t,n);const mS=60;exports.SheetRenderController=class extends a.RxDisposable{constructor(e,t,r,o,s){super();E(this,"_renderMetric$",new O.Subject);E(this,"renderMetric$",this._renderMetric$.asObservable());E(this,"_renderFrameTimeMetric",null);E(this,"_renderFrameTags",{});E(this,"_afterRenderMetric$",new O.Subject);this._context=e,this._sheetSkeletonManagerService=t,this._sheetRenderService=r,this._commandService=o,this._telemetryService=s,this._addNewRender(),this._initRenderMetricSubscriber()}_addNewRender(){const{scene:e,engine:t,unit:r}=this._context;this._addComponent(r),this._initRerenderScheduler(),this._initCommandListener();const o=this._context.unit.getActiveSheet();if(!o)throw new Error("No active sheet found");const s=o.getSheetId();this._sheetSkeletonManagerService.setCurrent({sheetId:s});const l=()=>e.render();this.disposeWithMe(this._context.activated$.subscribe(c=>{c?t.runRenderLoop(l):t.stopRenderLoop(l)}))}_initRenderMetricSubscriber(){const{engine:e}=this._context;e.beginFrame$.subscribe(()=>{this._renderFrameTimeMetric=null,this._renderFrameTags={}}),e.endFrame$.subscribe(()=>{this._renderFrameTimeMetric&&Object.keys(this._renderFrameTimeMetric).filter(o=>o.startsWith(T.SHEET_EXTENSION_PREFIX)).length>0&&this._afterRenderMetric$.next({frameTimeMetric:this._renderFrameTimeMetric,tags:this._renderFrameTags})}),e.renderFrameTimeMetric$.subscribe(([r,o])=>{this._renderFrameTimeMetric||(this._renderFrameTimeMetric={}),this._renderFrameTimeMetric[r]||(this._renderFrameTimeMetric[r]=[]),this._renderFrameTimeMetric[r].push(Math.round(o*100)/100)}),e.renderFrameTags$.subscribe(([r,o])=>{this._renderFrameTags[r]=o});const t=[];this._afterRenderMetric$.pipe(O.withLatestFrom(e.endFrame$)).subscribe(([r,o])=>{t.push({FPS:o.FPS,elapsedTime:o.elapsedTime,frameTime:Math.round(o.frameTime*100)/100,...r.frameTimeMetric,...r.tags}),t.length>mS&&(this._captureRenderMetric(t),t.length=0)})}_captureRenderMetric(e){var g;const t=e;if(t.length===0)return;const r=S=>{let f=0;const v=Object.entries(S).filter(([I,R])=>Array.isArray(R)).map(([I])=>I).reduce((I,R)=>{const w=S[R].reduce((M,y)=>M+y,0);return I[R]=w,I},{});return Object.keys(S).filter(I=>I.startsWith(T.SHEET_EXTENSION_PREFIX)).forEach(I=>{f+=v[I]}),{...v,extensionTotal:f}},o=e.map(S=>({...S,...r(S)})),l=(S=>Object.entries(S[0]).filter(([v,C])=>!["elapsedTime"].includes(v)).filter(([v,C])=>typeof C=="number").map(([v])=>v).reduce((v,C)=>{const I=S.map(y=>y[C]),R=Math.max(...I),w=Math.min(...I),M=I.reduce((y,P)=>y+P,0)/I.length;return v[C]={max:Math.round(R*100)/100,min:Math.round(w*100)/100,avg:Math.round(M*100)/100},v},{}))(o),c=t[t.length-1].elapsedTime,d=this._context.unit.getActiveSheet().getSheetId(),u=this._context.unit.getUnitId(),h={sheetId:d,unitId:u,elapsedTimeToStart:c,...l};this._renderMetric$.next(h),(g=this._telemetryService)==null||g.capture("sheet_render_cost",h)}_addComponent(e){const{scene:t,components:r}=this._context,o=e.getActiveSheet(),s=new T.Spreadsheet(he.MAIN);this._addViewport(o);const l=new T.SpreadsheetRowHeader(he.ROW),c=new T.SpreadsheetColumnHeader(he.COLUMN),d=new T.Rect(he.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});this._context.mainComponent=s,r.set(he.MAIN,s),r.set(he.ROW,l),r.set(he.COLUMN,c),r.set(he.LEFT_TOP,d),t.addObjects([s],Bs),t.addObjects([l,c,d],bt),t.enableLayerCache(Bs,bt)}_initViewports(e,t,r){const l=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN,e,{left:t.width,top:r.height,bottom:0,right:0,isWheelPreventDefaultX:!0,allowCache:!0,bufferEdgeX:100,bufferEdgeY:100}),c=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:0}),d=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:100}),u=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:100,bufferEdgeY:0}),h=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP,e,{active:!1,isWheelPreventDefaultX:!0}),g=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM,e,{left:0,top:r.height,bottom:0,width:t.width+1,isWheelPreventDefaultX:!0}),S=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT,e,{active:!1,isWheelPreventDefaultX:!0}),f=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT,e,{left:t.width,top:0,height:r.height+1,right:0,isWheelPreventDefaultX:!0}),p=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP,e,{left:0,top:0,width:t.width,height:r.height,isWheelPreventDefaultX:!0});return{viewMain:l,viewLeftTop:p,viewMainLeftTop:c,viewMainLeft:d,viewMainTop:u,viewColumnLeft:S,viewRowTop:h,viewRowBottom:g,viewColumnRight:f}}_addViewport(e){const t=this._context.scene,{rowHeader:r,columnHeader:o}=e.getConfig(),{viewMain:s}=this._initViewports(t,r,o);return new T.ScrollBar(s),t.attachControl(),s}_initRerenderScheduler(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(!e)return null;const{skeleton:t,sheetId:r}=e,o=this._context.unit,s=o==null?void 0:o.getSheetBySheetId(r);if(o==null||s==null)return;const{mainComponent:l,components:c}=this._context,d=l,u=c.get(he.ROW),h=c.get(he.COLUMN),g=c.get(he.LEFT_TOP),{rowHeaderWidth:S,columnHeaderHeight:f}=t;d==null||d.updateSkeleton(t),u==null||u.updateSkeleton(t),h==null||h.updateSkeleton(t),g==null||g.transformByState({width:S,height:f})}))}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{const{unit:t}=this._context,{id:r}=e;if(m.COMMAND_LISTENER_SKELETON_CHANGE.includes(r)||this._sheetRenderService.checkMutationShouldTriggerRerender(r)){const o=e.params,{unitId:s,subUnitId:l}=o,c=t.getActiveSheet();if(!c)return;const d=this._context.unitId,u=c.getSheetId();if(s!==d||l!==u)return;this._sheetSkeletonManagerService.makeDirty({sheetId:u,commandId:r},!0),this._sheetSkeletonManagerService.setCurrent({sheetId:u,commandId:r})}else m.COMMAND_LISTENER_VALUE_CHANGE.includes(r)&&this._sheetSkeletonManagerService.reCalculate();e.type===a.CommandType.MUTATION&&this._markUnitDirty(e)}))}_markUnitDirty(e){const{mainComponent:t,scene:r}=this._context;if(e.id===Z.SetFormulaCalculationNotificationMutation.id&&e.params.stageInfo!=null||(t&&t.makeDirty(),r.makeDirty(),!e.params))return;const o=e.params,s=this._spreadsheetViewports(r);if(e.id===m.SetRangeValuesMutation.id&&o.cellValue){const l=this._cellValueToRange(o.cellValue),c=this._rangeToBounds([l]);this._markViewportDirty(s,c),t.setDirtyArea(c)}if(e.id===m.MoveRangeMutation.id&&o.from&&o.to){const l=o.fromRange||this._cellValueToRange(o.from.value),c=o.toRange||this._cellValueToRange(o.to.value),d=this._rangeToBounds([l,c]);this._markViewportDirty(s,d),t.setDirtyArea(d)}}_cellValueToRange(e){let t=0,r=0,o=0,s=0;for(const[h,g]of Object.entries(e)){for(const S in g)t>Number(S)&&(t=Number(S)),r<Number(S)&&(r=Number(S));o>Number(h)&&(o=Number(h)),s<Number(h)&&(s=Number(h))}return{startRow:o,endRow:s,startColumn:t,endColumn:r}}_rangeToBounds(e){const t=this._sheetSkeletonManagerService.getCurrentParam().skeleton,{rowHeightAccumulation:r,columnWidthAccumulation:o,rowHeaderWidth:s,columnHeaderHeight:l}=t,c=[];for(const d of e){const{startRow:u,endRow:h,startColumn:g,endColumn:S}=d,f=u===0?0:r[u-1]+l,p=r[h]+l,v=g===0?0:o[g-1]+s,C=o[S]+s;c.push({top:f,left:v,bottom:p,right:C,width:C-v,height:p-f})}return c}_markViewportDirty(e,t){const r=e.filter(o=>o.isActive&&o.cacheBound);for(const o of r)for(const s of t)a.Rectangle.hasIntersectionBetweenTwoRect(o.cacheBound,s)&&o.markDirty(!0)}_spreadsheetViewports(e){return e.getViewports().filter(t=>["viewMain","viewMainLeftTop","viewMainTop","viewMainLeft"].includes(t.viewportKey))}};exports.SheetRenderController=hS([Lr(1,a.Inject(exports.SheetSkeletonManagerService)),Lr(2,a.Inject(exports.SheetsRenderService)),Lr(3,a.ICommandService),Lr(4,a.Optional(md.ITelemetryService))],exports.SheetRenderController);function gS(n,i){if(n.length!==i.length)return!1;const e=n.sort((r,o)=>r.id.localeCompare(o.id)),t=i.sort((r,o)=>r.id.localeCompare(o.id));return e.every((r,o)=>{var s,l;return((s=r.subject)==null?void 0:s.userID)===((l=t[o].subject)==null?void 0:l.userID)&&r.role===t[o].role})}function jl(n,i){return i.some(e=>SS(n,e))}function SS(n,i){const{startRow:e,startColumn:t,endColumn:r,endRow:o}=i,s=n.getMatrixWithMergedCells(e,t,o,r);let l=!1;return s.forValue((c,d,u)=>{if(u&&(c!==e||d!==t)&&n.cellHasValue(u))return l=!0,!1}),l}function zl(n,i,e,t){const r=[],o=[],s=e.getSheetId();return t.forEach(l=>{const c=fS(e,l),d={unitId:i,subUnitId:s,cellValue:c.getData()},u=m.SetRangeValuesUndoMutationFactory(n,d);r.push({id:m.SetRangeValuesMutation.id,params:u}),o.push({id:m.SetRangeValuesMutation.id,params:d})}),{undos:r,redos:o}}function fS(n,i){const{startRow:e,startColumn:t,endColumn:r,endRow:o}=i,s=n.getMatrixWithMergedCells(e,t,o,r,a.CellModeEnum.Intercepted),l=new a.ObjectMatrix;let c=null;return s.forValue((d,u,h)=>{var g,S,f,p;h&&d>=e&&u>=t&&(!c&&n.cellHasValue(h)&&(h.v!==""||((p=(f=(S=(g=h.p)==null?void 0:g.body)==null?void 0:S.dataStream)==null?void 0:f.length)!=null?p:0)>2)&&(c=h),l.setValue(d,u,null))}),l.setValue(e,t,c),l}function pS(n,i,e,t){const r=e.getActiveViewportByCoord(T.Vector2.FromArray([n,i]));if(!r)return;const{scaleX:o,scaleY:s}=e.getAncestorScale(),l={x:r.viewportScrollX,y:r.viewportScrollY},c=t.getCellIndexByOffset(n,i,o,s,l),d=t.worksheet.getMergedCell(c.row,c.column);return{actualRow:d?d.startRow:c.row,actualCol:d?d.startColumn:c.column,mergeCell:d,row:c.row,col:c.column}}function wa(n,i,e,t){const r=t.getFreeze();if(!r||r.startRow<=0&&r.startColumn<=0||n>=r.startRow&&i>=r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(n<r.startRow&&i<r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP);if(n<r.startRow&&i>=r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(n>=r.startRow&&i<r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)}function vS(n,i,e,t){const r=Ta(n.left,n.top,i,e,t),o=Ta(n.right,n.bottom,i,e,t);return{left:r.x,top:r.y,right:o.x,bottom:o.y}}function Ta(n,i,e,t,r){const{scaleX:o,scaleY:s}=e.getAncestorScale(),l=e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(!l)return{x:n,y:i};const c=r.getFreeze(),{startColumn:d,startRow:u,xSplit:h,ySplit:g}=c,S=t.getNoMergeCellWithCoordByIndex(u-g,d-h,!1),f=t.getNoMergeCellWithCoordByIndex(u,d,!1),{rowHeaderWidth:p,columnHeaderHeight:v}=t,C=f.startX-S.startX,I=f.startY-S.startY,{top:R,left:w,viewportScrollX:M,viewportScrollY:y}=l;let P;n>w?P=(n-M)*o:P=(C+p-(w-n))*o;let x;return i>R?x=(i-y)*s:x=(I+v-(R-i))*o,{x:P,y:x}}function Xl(n,i,e,t,r){let o=t,s=r;e.overflowCache.forValue((d,u,h)=>{h.startRow<=o&&h.endRow>=o&&h.startColumn<=s&&h.endColumn>=s&&(s=u,o=d)});const l=e.getCellWithCoordByIndex(o,s);return{unitId:n.getUnitId(),subUnitId:i.getSheetId(),workbook:n,worksheet:i,row:l.actualRow,col:l.actualColumn}}function Yl(n,i,e,t,r,o){const{scene:s}=n,l=i.getUnitId(),{skeleton:c,sheetId:d}=t,u=pS(r,o,s,c);if(!u)return null;let{actualCol:h,actualRow:g}=u;const S={unitId:l,subUnitId:d,workbook:i,worksheet:e,row:g,col:h};c.overflowCache.forValue((y,P,x)=>{x.startRow<=g&&x.endRow>=g&&x.startColumn<=h&&x.endColumn>=h&&(h=P,g=y)});const f=c.getCellWithCoordByIndex(g,h),p=Xl(i,e,c,g,h);let v;f.mergeInfo?v=f.mergeInfo:v={startRow:p.row,endRow:p.row,startColumn:p.col,endColumn:p.col};const C=s.getActiveViewportByCoord(T.Vector2.FromArray([r,o]));if(!C)return;const{scaleX:I,scaleY:R}=s.getAncestorScale(),w={x:C.viewportScrollX,y:C.viewportScrollY};return{position:{startX:(c.getOffsetByColumn(v.startColumn-1)-w.x)*I,endX:(c.getOffsetByColumn(v.endColumn)-w.x)*I,startY:(c.getOffsetByRow(v.startRow-1)-w.y)*R,endY:(c.getOffsetByRow(v.endRow)-w.y)*R},location:S,overflowLocation:p}}const Tt={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(n,i)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),r=n.get(a.IUniverInstanceService),o=n.get(_.IConfirmService),s=n.get(a.LocaleService),l=i.unitId,c=i.subUnitId,d=i.selections,u=m.getAddMergeMutationRangeByType(d,i.value),h=r.getUniverSheetInstance(l).getSheetBySheetId(c),g=[],S=[],f=jl(h,u);if(f&&!i.defaultMerge&&!await o.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:"merge.confirm.title"},cancelText:s.t("merge.confirm.cancel"),confirmText:s.t("merge.confirm.confirm")}))return!1;const p={unitId:l,subUnitId:c,ranges:a.Tools.deepClone(u)},v={unitId:l,subUnitId:c,ranges:a.Tools.deepClone(u)},C=m.RemoveMergeUndoMutationFactory(n,p),I=m.AddMergeUndoMutationFactory(n,v);if(C.ranges.length>0&&g.push({id:m.RemoveWorksheetMergeMutation.id,params:C}),g.push({id:m.AddWorksheetMergeMutation.id,params:v}),S.push({id:m.RemoveWorksheetMergeMutation.id,params:I}),C.ranges.length>0&&S.push({id:m.AddWorksheetMergeMutation.id,params:C}),f){const x=zl(n,l,h,u);g.unshift(...x.redos),S.push(...x.undos)}const R=m.AddMergeRedoSelectionsOperationFactory(n,i,u);R&&g.push(R);const w=m.AddMergeUndoSelectionsOperationFactory(n,i);w&&S.push(w);const y=n.get(m.SheetInterceptorService).onCommandExecute({id:Tt.id,params:{unitId:l,subUnitId:c,ranges:u}});return g.push(...y.redos),S.push(...y.undos),a.sequenceExecute(g,e).result?(t.pushUndoRedo({unitID:l,undoMutations:S,redoMutations:g}),!0):!1}},As={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async n=>{var u;const i=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),r=fs(ki.MergeAll,t);if(!(r!=null&&r.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return i.executeCommand(Tt.id,{selections:r,unitId:c,subUnitId:d})}},ks={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async n=>{var u;const i=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),r=fs(ki.MergeVertical,t);if(!(r!=null&&r.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return i.executeCommand(Tt.id,{value:a.Dimension.COLUMNS,selections:r,unitId:c,subUnitId:d})}},Ds={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async n=>{var u;const i=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),r=fs(ki.MergeHorizontal,t);if(!(r!=null&&r.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return i.executeCommand(Tt.id,{value:a.Dimension.ROWS,selections:r,unitId:c,subUnitId:d})}},Vn={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-left-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Vn.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.DeleteRangeMoveLeftCommand.id):!0}},Xt={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-up-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getRowCount()-1};for(let S=d.startRow;S<=d.endRow;S++)if(c.getRowFiltered(S)&&await i.confirm({id:Xt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Xt.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.DeleteRangeMoveUpCommand.id):!0}},Yt={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-down-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getRowCount()-1};for(let S=d.startRow;S<=d.endRow;S++)if(c.getRowFiltered(S)&&await i.confirm({id:Yt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Yt.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.InsertRangeMoveDownCommand.id):!0}},Wn={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-right-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Wn.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.InsertRangeMoveRightCommand.id):!0}};var Gl=(n=>(n[n.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",n[n.UNIVER_DOC=1]="UNIVER_DOC",n[n.UNIVER_SHEET=2]="UNIVER_SHEET",n[n.UNIVER_SLIDE=3]="UNIVER_SLIDE",n[n.UNIVER_PROJECT=4]="UNIVER_PROJECT",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(Gl||{}),re=(n=>(n[n.View=0]="View",n[n.Edit=1]="Edit",n[n.ManageCollaborator=2]="ManageCollaborator",n[n.Print=3]="Print",n[n.Duplicate=4]="Duplicate",n[n.Comment=5]="Comment",n[n.Copy=6]="Copy",n[n.Share=7]="Share",n[n.Export=8]="Export",n[n.MoveWorksheet=9]="MoveWorksheet",n[n.DeleteWorksheet=10]="DeleteWorksheet",n[n.HideWorksheet=11]="HideWorksheet",n[n.RenameWorksheet=12]="RenameWorksheet",n[n.CreateWorksheet=13]="CreateWorksheet",n[n.SetWorksheetStyle=14]="SetWorksheetStyle",n[n.EditWorksheetCell=15]="EditWorksheetCell",n[n.InsertHyperlink=16]="InsertHyperlink",n[n.Sort=17]="Sort",n[n.Filter=18]="Filter",n[n.PivotTable=19]="PivotTable",n[n.FloatImg=20]="FloatImg",n[n.History=21]="History",n[n.RwHgtClWdt=22]="RwHgtClWdt",n[n.ViemRwHgtClWdt=23]="ViemRwHgtClWdt",n[n.ViewFilter=24]="ViewFilter",n[n.MoveSheet=25]="MoveSheet",n[n.DeleteSheet=26]="DeleteSheet",n[n.HideSheet=27]="HideSheet",n[n.CopySheet=28]="CopySheet",n[n.RenameSheet=29]="RenameSheet",n[n.CreateSheet=30]="CreateSheet",n[n.SelectProtectedCells=31]="SelectProtectedCells",n[n.SelectUnProtectedCells=32]="SelectUnProtectedCells",n[n.SetCellStyle=33]="SetCellStyle",n[n.SetCellValue=34]="SetCellValue",n[n.SetRowStyle=35]="SetRowStyle",n[n.SetColumnStyle=36]="SetColumnStyle",n[n.InsertRow=37]="InsertRow",n[n.InsertColumn=38]="InsertColumn",n[n.DeleteRow=39]="DeleteRow",n[n.DeleteColumn=40]="DeleteColumn",n[n.EditExtraObject=41]="EditExtraObject",n[n.Delete=42]="Delete",n[n.RecoverHistory=43]="RecoverHistory",n[n.ViewHistory=44]="ViewHistory",n[n.CreatePermissionObject=45]="CreatePermissionObject",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(re||{}),ke=(n=>(n[n.Reader=0]="Reader",n[n.Editor=1]="Editor",n[n.Owner=2]="Owner",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(ke||{}),dt=(n=>(n[n.Unkonwn=0]="Unkonwn",n[n.Workbook=1]="Workbook",n[n.Worksheet=2]="Worksheet",n[n.SelectRange=3]="SelectRange",n[n.Document=4]="Document",n[n.Slide=5]="Slide",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(dt||{}),Ke=(n=>(n[n.SomeCollaborator=0]="SomeCollaborator",n[n.AllCollaborator=1]="AllCollaborator",n[n.OneSelf=2]="OneSelf",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(Ke||{});const or="UNIVER_SHEET_PERMISSION_PANEL",ai="UNIVER_SHEET_PERMISSION_USER_PART",Ns="UNIVER_SHEET_PERMISSION_BACKGROUND",Zl="UNIVER_SHEET_PERMISSION_USER_DIALOG",Kl="UNIVER_SHEET_PERMISSION_DIALOG",li="UNIVER_SHEET_PERMISSION_USER_DIALOG_ID",ci="UNIVER_SHEET_PERMISSION_DIALOG_ID",Br={[re.Copy]:"Copy",[re.SetCellStyle]:"SetCellStyle",[re.SetCellValue]:"SetCellValue",[re.SetRowStyle]:"SetRowStyle",[re.SetColumnStyle]:"SetColumnStyle",[re.InsertRow]:"InsertRow",[re.InsertColumn]:"InsertColumn",[re.InsertHyperlink]:"InsertHyperlink",[re.DeleteRow]:"DeleteRow",[re.DeleteColumn]:"DeleteColumn",[re.Sort]:"Sort",[re.Filter]:"Filter",[re.PivotTable]:"PivotTable",[re.EditExtraObject]:"EditExtraObject"},CS=[re.Copy,re.SetCellStyle,re.SetCellValue,re.SetRowStyle,re.SetColumnStyle,re.InsertRow,re.InsertColumn,re.InsertHyperlink,re.DeleteRow,re.DeleteColumn,re.Sort,re.Filter,re.PivotTable,re.EditExtraObject,re.View],ql="sheet-permission-menu-icon",_S="sheet-permission-delete-icon",IS="sheet-permission-edit-icon",bS="sheet-permission-check-icon",Ql="sheet-permission-lock-icon",RS={unitId:"",subUnitId:"",permissionId:"",unitType:m.UnitObject.SelectRange,id:"",ranges:[],viewState:m.ViewStateEnum.OthersCanView,editState:m.EditStateEnum.OnlyMe};class yn{constructor(){E(this,"_rule",RS);E(this,"_visible",!1)}setVisible(i){this._visible=i}getVisible(){return this._visible}reset(){this.setVisible(!1)}}class yt{constructor(){E(this,"_userList",[]);E(this,"_userList$",new O.BehaviorSubject(this._userList));E(this,"userList$",this._userList$.asObservable());E(this,"_oldCollaboratorList",[]);E(this,"_selectUserList",[]);E(this,"_selectUserList$",new O.BehaviorSubject(this._selectUserList));E(this,"selectUserList$",this._selectUserList$.asObservable())}get userList(){return this._userList}setCanEditUserList(i){this._userList=i,this._userList$.next(i)}reset(){this._userList=[],this._oldCollaboratorList=[],this._selectUserList=[],this._selectUserList$.next([])}get oldCollaboratorList(){return this._oldCollaboratorList}setOldCollaboratorList(i){this._oldCollaboratorList=i}get selectUserList(){return this._selectUserList}setSelectUserList(i){this._selectUserList=i,this._selectUserList$.next(i)}}const Qe={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openPanel",async handler(n,i={}){const e=n.get(_.ISidebarService),t=n.get(yn),r=n.get(yt),{showDetail:o=!0,fromSheetBar:s=!1,rule:l,oldRule:c}=i,d={header:{title:"permission.panel.title"},children:{label:or,showDetail:o,fromSheetBar:s,rule:l,oldRule:c},width:330,onClose:()=>{t.reset(),r.reset()}};return t.setVisible(!0),e.open(d),!0}},Mr={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-toolbar",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{showDetail:!0}),!0}},Wt={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{showDetail:!0}),!0}},Ut={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{showDetail:!1}),!0}},Pr={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{fromSheetBar:!0,showDetail:!0}),!0}},Or={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{showDetail:!1}),!0}},Lt={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-protection-from-context-menu",async handler(n){var h;const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IUndoRedoService),r=n.get(m.SheetsSelectionsService),o=n.get(m.WorksheetProtectionRuleModel),s=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s.getActiveSheet(),c=s.getUnitId(),d=l.getSheetId(),u=o.getRule(c,d);if(u!=null&&u.permissionId)return i.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d,rule:u});{const g=(h=r.getCurrentLastSelection())==null?void 0:h.range;if(!g)return!1;const p=n.get(m.RangeProtectionRuleModel).getSubunitRuleList(c,d).find(v=>v.ranges.some(C=>a.Rectangle.intersects(C,g)));if(p){const v={unitId:c,subUnitId:d,ruleIds:[p.id]};return await i.executeCommand(m.DeleteRangeProtectionMutation.id,v)&&t.pushUndoRedo({unitID:c,redoMutations:[{id:m.DeleteRangeProtectionMutation.id,params:v}],undoMutations:[{id:m.AddRangeProtectionMutation.id,params:{unitId:c,subUnitId:d,rules:[p]}}]}),!0}else return!1}}},Bt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-protection-from-context-menu",async handler(n){var u;const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.WorksheetProtectionRuleModel),o=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=o.getActiveSheet(),l=o.getUnitId(),c=s.getSheetId(),d=r.getRule(l,c);if(d!=null&&d.permissionId){const h={...d,unitId:l,subUnitId:c,ranges:[]};return await i.executeCommand(Qe.id,{showDetail:!0,rule:a.Tools.deepClone(h),oldRule:a.Tools.deepClone(h)}),!0}else{const h=(u=t.getCurrentLastSelection())==null?void 0:u.range;if(!h)return!1;const f=n.get(m.RangeProtectionRuleModel).getSubunitRuleList(l,c).find(p=>{var v;return(v=p==null?void 0:p.ranges)==null?void 0:v.some(C=>a.Rectangle.intersects(C,h))});if(f){const p={...f,unitId:l,subUnitId:c};return await i.executeCommand(Qe.id,{showDetail:!0,rule:a.Tools.deepClone(p),oldRule:a.Tools.deepClone(p)}),!0}else return!1}}},Mn={id:"sheet.command.remove-row-confirm",type:a.CommandType.COMMAND,handler:async(n,i)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=i==null?void 0:i.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const r=n.get(a.ICommandService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleRows();if(Ka(c,[t])){const u=n.get(_.IConfirmService),h=n.get(a.LocaleService);return await u.confirm({id:"sheet.confirm.remove-row",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllRowsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await r.executeCommand(m.RemoveRowCommand.id,{range:t}),!0}},Pn={id:"sheet.command.remove-col-confirm",type:a.CommandType.COMMAND,handler:async(n,i)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=i==null?void 0:i.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const r=n.get(a.ICommandService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleCols();if(qa(c,[t])){const u=n.get(_.IConfirmService),h=n.get(a.LocaleService);return await u.confirm({id:"sheet.confirm.remove-col",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllColumnsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await r.executeCommand(m.RemoveColCommand.id,{range:t}),!0}},xr={id:"sheet.command.remove-sheet-confirm",type:a.CommandType.COMMAND,handler:async(n,i)=>{const{subUnitId:e}=i,t=n.get(_.IConfirmService),r=n.get(a.ICommandService),o=n.get(a.LocaleService);return await t.confirm({id:"sheet.confirm.remove-sheet",title:{title:o.t("sheetConfig.deleteSheet")},children:{title:o.t("sheetConfig.deleteSheetContent")},cancelText:o.t("button.cancel"),confirmText:o.t("button.confirm")})?(await r.executeCommand(m.RemoveSheetCommand.id,{subUnitId:e}),!0):!1}},Ar={id:"ui-sheet.command.show-menu-list",type:a.CommandType.OPERATION,handler:async n=>(n.get(Kt).triggerSheetBarMenu(),!0)},kr={type:a.CommandType.COMMAND,id:"sheet.command.delete-worksheet-protection-from-sheet-bar",async handler(n,i){if(!i)return!1;const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),r=n.get(m.WorksheetProtectionRuleModel),s=n.get(a.IUniverInstanceService).getCurrentUnitForType(Gl.UNIVER_SHEET),l=s==null?void 0:s.getActiveSheet(),c=s.getUnitId();if(!l)return!1;const d=l.getSheetId(),u=r.getRule(c,d);if(await e.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d})){const g=[{id:m.DeleteWorksheetProtectionCommand.id,params:{unitId:c,subUnitId:d}}],S=[{id:m.AddWorksheetProtectionCommand.id,params:{unitId:c,rule:u}}];t.pushUndoRedo({unitID:c,redoMutations:g,undoMutations:S})}return!0}},Dr={type:a.CommandType.COMMAND,id:"sheet.command.change-sheet-protection-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand("sheet-permission.operation.openDialog"),!0}},Fi={id:"sheet.operation.set-activate-cell-edit",type:a.CommandType.OPERATION,handler:(n,i)=>(n.get(Se).setEditCell(i),!0)},Nr={id:"sheet.operation.rename-sheet",type:a.CommandType.OPERATION,handler:async(n,i)=>{const e=n.get(Kt);return i&&e.setRenameId(i.subUnitId),!0}},Hs={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openDialog",async handler(n,i){const e=n.get(_.IDialogService);return e.close("DESKTOP_FIND_REPLACE_DIALOG"),e.open({id:ci,title:{title:"permission.dialog.allowedPermissionType"},children:{label:Kl},width:393,destroyOnClose:!0,onClose:()=>e.close(ci)}),!0}},ES=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M0.98999 1.08218H-0.0100098V0.0821838H0.98999V1.08218Z",fill:"black"}),b.jsx("path",{d:"M5.78992 1.08218H2.78992V0.0821838H5.78992V1.08218Z",fill:"black"}),b.jsx("path",{d:"M7.58984 1.08218H8.58984V0.0821838H7.58984V1.08218Z",fill:"black"}),b.jsx("path",{d:"M14.9152 1.08218H13.9152V0.0821838H14.9152V1.08218Z",fill:"black"}),b.jsx("path",{d:"M16.7151 1.08218H19.7151V0.0821838H16.7151V1.08218Z",fill:"black"}),b.jsx("path",{d:"M22.515 1.08218H21.515V0.0821838H22.515V1.08218Z",fill:"black"}),b.jsx("path",{d:"M27.8405 1.08218H28.8405V0.0821838H27.8405V1.08218Z",fill:"black"}),b.jsx("path",{d:"M33.6404 1.08218H30.6404V0.0821838H33.6404V1.08218Z",fill:"black"}),b.jsx("path",{d:"M35.4403 1.08218H36.4403V0.0821838H35.4403V1.08218Z",fill:"black"}),b.jsx("path",{d:"M42.7657 1.08218H41.7657V0.0821838H42.7657V1.08218Z",fill:"black"}),b.jsx("path",{d:"M44.5657 1.08218H47.5657V0.0821838H44.5657V1.08218Z",fill:"black"}),b.jsx("path",{d:"M50.3656 1.08218H49.3656V0.0821838H50.3656V1.08218Z",fill:"black"}),b.jsx("path",{d:"M55.691 1.08218H56.691V0.0821838H55.691V1.08218Z",fill:"black"}),b.jsx("path",{d:"M61.491 1.08218H58.491V0.0821838H61.491V1.08218Z",fill:"black"}),b.jsx("path",{d:"M63.2909 1.08218H64.2909V0.0821838H63.2909V1.08218Z",fill:"black"}),b.jsx("path",{d:"M70.6163 1.08218H69.6163V0.0821838H70.6163V1.08218Z",fill:"black"}),b.jsx("path",{d:"M72.4163 1.08218H75.4163V0.0821838H72.4163V1.08218Z",fill:"black"}),b.jsx("path",{d:"M78.2162 1.08218H77.2162V0.0821838H78.2162V1.08218Z",fill:"black"}),b.jsx("path",{d:"M83.5416 1.08218H84.5416V0.0821838H83.5416V1.08218Z",fill:"black"}),b.jsx("path",{d:"M89.3416 1.08218H86.3416V0.0821838H89.3416V1.08218Z",fill:"black"}),b.jsx("path",{d:"M91.1415 1.08218H92.1415V0.0821838H91.1415V1.08218Z",fill:"black"}),b.jsx("path",{d:"M98.4669 1.08218H97.4669V0.0821838H98.4669V1.08218Z",fill:"black"}),b.jsx("path",{d:"M100.267 1.08218H103.267V0.0821838H100.267V1.08218Z",fill:"black"}),b.jsx("path",{d:"M106.067 1.08218H105.067V0.0821838H106.067V1.08218Z",fill:"black"}),b.jsx("path",{d:"M111.392 1.08218H112.392V0.0821838H111.392V1.08218Z",fill:"black"}),b.jsx("path",{d:"M117.192 1.08218H114.192V0.0821838H117.192V1.08218Z",fill:"black"}),b.jsx("path",{d:"M118.992 1.08218H119.992V0.0821838H118.992V1.08218Z",fill:"black"})]}),wS=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.0100098 1.15771H0.98999V0.157715H-0.0100098V1.15771Z",fill:"black"}),b.jsx("path",{d:"M2.78992 1.15771H5.78992V0.157715H2.78992V1.15771Z",fill:"black"}),b.jsx("path",{d:"M8.58984 1.15771H7.58984V0.157715H8.58984V1.15771Z",fill:"black"}),b.jsx("path",{d:"M10.3899 1.15771H11.3899V0.157715H10.3899V1.15771Z",fill:"black"}),b.jsx("path",{d:"M19.0903 1.15771H18.0903V0.157715H19.0903V1.15771Z",fill:"black"}),b.jsx("path",{d:"M20.8903 1.15771H23.8903V0.157715H20.8903V1.15771Z",fill:"black"}),b.jsx("path",{d:"M26.6902 1.15771H25.6902V0.157715H26.6902V1.15771Z",fill:"black"}),b.jsx("path",{d:"M28.4902 1.15771H29.4902V0.157715H28.4902V1.15771Z",fill:"black"}),b.jsx("path",{d:"M37.1907 1.15771H36.1907V0.157715H37.1907V1.15771Z",fill:"black"}),b.jsx("path",{d:"M38.9906 1.15771H41.9906V0.157715H38.9906V1.15771Z",fill:"black"}),b.jsx("path",{d:"M44.7905 1.15771H43.7905V0.157715H44.7905V1.15771Z",fill:"black"}),b.jsx("path",{d:"M46.5906 1.15771H47.5906V0.157715H46.5906V1.15771Z",fill:"black"}),b.jsx("path",{d:"M55.291 1.15771H54.291V0.157715H55.291V1.15771Z",fill:"black"}),b.jsx("path",{d:"M57.0909 1.15771H60.0909V0.157715H57.0909V1.15771Z",fill:"black"}),b.jsx("path",{d:"M62.8909 1.15771H61.8909V0.157715H62.8909V1.15771Z",fill:"black"}),b.jsx("path",{d:"M64.6909 1.15771H65.6909V0.157715H64.6909V1.15771Z",fill:"black"}),b.jsx("path",{d:"M73.3914 1.15771H72.3914V0.157715H73.3914V1.15771Z",fill:"black"}),b.jsx("path",{d:"M75.1913 1.15771H78.1913V0.157715H75.1913V1.15771Z",fill:"black"}),b.jsx("path",{d:"M80.9912 1.15771H79.9912V0.157715H80.9912V1.15771Z",fill:"black"}),b.jsx("path",{d:"M82.7913 1.15771H83.7913V0.157715H82.7913V1.15771Z",fill:"black"}),b.jsx("path",{d:"M91.4917 1.15771H90.4917V0.157715H91.4917V1.15771Z",fill:"black"}),b.jsx("path",{d:"M93.2916 1.15771H96.2916V0.157715H93.2916V1.15771Z",fill:"black"}),b.jsx("path",{d:"M99.0916 1.15771H98.0916V0.157715H99.0916V1.15771Z",fill:"black"}),b.jsx("path",{d:"M100.892 1.15771H101.892V0.157715H100.892V1.15771Z",fill:"black"}),b.jsx("path",{d:"M109.592 1.15771H108.592V0.157715H109.592V1.15771Z",fill:"black"}),b.jsx("path",{d:"M111.392 1.15771H114.392V0.157715H111.392V1.15771Z",fill:"black"}),b.jsx("path",{d:"M117.192 1.15771H116.192V0.157715H117.192V1.15771Z",fill:"black"}),b.jsx("path",{d:"M118.992 1.15771H119.992V0.157715H118.992V1.15771Z",fill:"black"})]}),TS=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.00842285 1.22449H2.99158V0.224487H-0.00842285V1.22449Z",fill:"black"}),b.jsx("path",{d:"M6.14941 1.22449H9.14941V0.224487H6.14941V1.22449Z",fill:"black"}),b.jsx("path",{d:"M15.3073 1.22449H12.3073V0.224487H15.3073V1.22449Z",fill:"black"}),b.jsx("path",{d:"M18.4651 1.22449H21.4651V0.224487H18.4651V1.22449Z",fill:"black"}),b.jsx("path",{d:"M27.6229 1.22449H24.6229V0.224487H27.6229V1.22449Z",fill:"black"}),b.jsx("path",{d:"M30.7808 1.22449H33.7808V0.224487H30.7808V1.22449Z",fill:"black"}),b.jsx("path",{d:"M39.9386 1.22449H36.9386V0.224487H39.9386V1.22449Z",fill:"black"}),b.jsx("path",{d:"M43.0964 1.22449H46.0964V0.224487H43.0964V1.22449Z",fill:"black"}),b.jsx("path",{d:"M52.2543 1.22449H49.2543V0.224487H52.2543V1.22449Z",fill:"black"}),b.jsx("path",{d:"M55.4121 1.22449H58.4121V0.224487H55.4121V1.22449Z",fill:"black"}),b.jsx("path",{d:"M64.5699 1.22449H61.5699V0.224487H64.5699V1.22449Z",fill:"black"}),b.jsx("path",{d:"M67.7278 1.22449H70.7278V0.224487H67.7278V1.22449Z",fill:"black"}),b.jsx("path",{d:"M76.8856 1.22449H73.8856V0.224487H76.8856V1.22449Z",fill:"black"}),b.jsx("path",{d:"M80.0435 1.22449H83.0435V0.224487H80.0435V1.22449Z",fill:"black"}),b.jsx("path",{d:"M89.2013 1.22449H86.2013V0.224487H89.2013V1.22449Z",fill:"black"}),b.jsx("path",{d:"M92.3591 1.22449H95.3591V0.224487H92.3591V1.22449Z",fill:"black"}),b.jsx("path",{d:"M101.517 1.22449H98.517V0.224487H101.517V1.22449Z",fill:"black"}),b.jsx("path",{d:"M104.675 1.22449H107.675V0.224487H104.675V1.22449Z",fill:"black"}),b.jsx("path",{d:"M113.833 1.22449H110.833V0.224487H113.833V1.22449Z",fill:"black"}),b.jsx("path",{d:"M116.99 1.22449H119.99V0.224487H116.99V1.22449Z",fill:"black"})]}),yS=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.00976562 1.65707H0.990234V0.657074H-0.00976562V1.65707Z",fill:"black"}),b.jsx("path",{d:"M2.32361 1.65707H3.32361V0.657074H2.32361V1.65707Z",fill:"black"}),b.jsx("path",{d:"M5.65698 1.65707H4.65698V0.657074H5.65698V1.65707Z",fill:"black"}),b.jsx("path",{d:"M6.99036 1.65707H7.99036V0.657074H6.99036V1.65707Z",fill:"black"}),b.jsx("path",{d:"M10.3237 1.65707H9.32373V0.657074H10.3237V1.65707Z",fill:"black"}),b.jsx("path",{d:"M11.6571 1.65707H12.6571V0.657074H11.6571V1.65707Z",fill:"black"}),b.jsx("path",{d:"M14.9905 1.65707H13.9905V0.657074H14.9905V1.65707Z",fill:"black"}),b.jsx("path",{d:"M16.3239 1.65707H17.3239V0.657074H16.3239V1.65707Z",fill:"black"}),b.jsx("path",{d:"M19.6572 1.65707H18.6572V0.657074H19.6572V1.65707Z",fill:"black"}),b.jsx("path",{d:"M20.9906 1.65707H21.9906V0.657074H20.9906V1.65707Z",fill:"black"}),b.jsx("path",{d:"M24.324 1.65707H23.324V0.657074H24.324V1.65707Z",fill:"black"}),b.jsx("path",{d:"M25.6573 1.65707H26.6573V0.657074H25.6573V1.65707Z",fill:"black"}),b.jsx("path",{d:"M28.9907 1.65707H27.9907V0.657074H28.9907V1.65707Z",fill:"black"}),b.jsx("path",{d:"M30.3241 1.65707H31.3241V0.657074H30.3241V1.65707Z",fill:"black"}),b.jsx("path",{d:"M33.6575 1.65707H32.6575V0.657074H33.6575V1.65707Z",fill:"black"}),b.jsx("path",{d:"M34.9908 1.65707H35.9908V0.657074H34.9908V1.65707Z",fill:"black"}),b.jsx("path",{d:"M38.3242 1.65707H37.3242V0.657074H38.3242V1.65707Z",fill:"black"}),b.jsx("path",{d:"M39.6576 1.65707H40.6576V0.657074H39.6576V1.65707Z",fill:"black"}),b.jsx("path",{d:"M42.991 1.65707H41.991V0.657074H42.991V1.65707Z",fill:"black"}),b.jsx("path",{d:"M44.3243 1.65707H45.3243V0.657074H44.3243V1.65707Z",fill:"black"}),b.jsx("path",{d:"M47.6577 1.65707H46.6577V0.657074H47.6577V1.65707Z",fill:"black"}),b.jsx("path",{d:"M48.9911 1.65707H49.9911V0.657074H48.9911V1.65707Z",fill:"black"}),b.jsx("path",{d:"M52.3245 1.65707H51.3245V0.657074H52.3245V1.65707Z",fill:"black"}),b.jsx("path",{d:"M53.6578 1.65707H54.6578V0.657074H53.6578V1.65707Z",fill:"black"}),b.jsx("path",{d:"M56.9912 1.65707H55.9912V0.657074H56.9912V1.65707Z",fill:"black"}),b.jsx("path",{d:"M58.3246 1.65707H59.3246V0.657074H58.3246V1.65707Z",fill:"black"}),b.jsx("path",{d:"M61.658 1.65707H60.658V0.657074H61.658V1.65707Z",fill:"black"}),b.jsx("path",{d:"M62.9913 1.65707H63.9913V0.657074H62.9913V1.65707Z",fill:"black"}),b.jsx("path",{d:"M66.3247 1.65707H65.3247V0.657074H66.3247V1.65707Z",fill:"black"}),b.jsx("path",{d:"M67.6581 1.65707H68.6581V0.657074H67.6581V1.65707Z",fill:"black"}),b.jsx("path",{d:"M70.9915 1.65707H69.9915V0.657074H70.9915V1.65707Z",fill:"black"}),b.jsx("path",{d:"M72.3248 1.65707H73.3248V0.657074H72.3248V1.65707Z",fill:"black"}),b.jsx("path",{d:"M75.6582 1.65707H74.6582V0.657074H75.6582V1.65707Z",fill:"black"}),b.jsx("path",{d:"M76.9916 1.65707H77.9916V0.657074H76.9916V1.65707Z",fill:"black"}),b.jsx("path",{d:"M80.325 1.65707H79.325V0.657074H80.325V1.65707Z",fill:"black"}),b.jsx("path",{d:"M81.6583 1.65707H82.6583V0.657074H81.6583V1.65707Z",fill:"black"}),b.jsx("path",{d:"M84.9917 1.65707H83.9917V0.657074H84.9917V1.65707Z",fill:"black"}),b.jsx("path",{d:"M86.3251 1.65707H87.3251V0.657074H86.3251V1.65707Z",fill:"black"}),b.jsx("path",{d:"M89.6584 1.65707H88.6584V0.657074H89.6584V1.65707Z",fill:"black"}),b.jsx("path",{d:"M90.9918 1.65707H91.9918V0.657074H90.9918V1.65707Z",fill:"black"}),b.jsx("path",{d:"M94.3252 1.65707H93.3252V0.657074H94.3252V1.65707Z",fill:"black"}),b.jsx("path",{d:"M95.6586 1.65707H96.6586V0.657074H95.6586V1.65707Z",fill:"black"}),b.jsx("path",{d:"M98.9919 1.65707H97.9919V0.657074H98.9919V1.65707Z",fill:"black"}),b.jsx("path",{d:"M100.325 1.65707H101.325V0.657074H100.325V1.65707Z",fill:"black"}),b.jsx("path",{d:"M103.659 1.65707H102.659V0.657074H103.659V1.65707Z",fill:"black"}),b.jsx("path",{d:"M104.992 1.65707H105.992V0.657074H104.992V1.65707Z",fill:"black"}),b.jsx("path",{d:"M108.325 1.65707H107.325V0.657074H108.325V1.65707Z",fill:"black"}),b.jsx("path",{d:"M109.659 1.65707H110.659V0.657074H109.659V1.65707Z",fill:"black"}),b.jsx("path",{d:"M112.992 1.65707H111.992V0.657074H112.992V1.65707Z",fill:"black"}),b.jsx("path",{d:"M114.325 1.65707H115.325V0.657074H114.325V1.65707Z",fill:"black"}),b.jsx("path",{d:"M117.659 1.65707H116.659V0.657074H117.659V1.65707Z",fill:"black"}),b.jsx("path",{d:"M118.992 1.65707H119.992V0.657074H118.992V1.65707Z",fill:"black"})]}),MS=()=>b.jsx("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 2.42035H-0.0090332V0.420349H119.991V2.42035Z",fill:"black"})}),PS=()=>b.jsxs("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.0100098 2.47614H1.98999V0.476135H-0.0100098V2.47614Z",fill:"black"}),b.jsx("path",{d:"M3.99014 2.47614H9.99014V0.476135H3.99014V2.47614Z",fill:"black"}),b.jsx("path",{d:"M13.9901 2.47614H11.9901V0.476135H13.9901V2.47614Z",fill:"black"}),b.jsx("path",{d:"M21.1904 2.47614H23.1904V0.476135H21.1904V2.47614Z",fill:"black"}),b.jsx("path",{d:"M31.1906 2.47614H25.1906V0.476135H31.1906V2.47614Z",fill:"black"}),b.jsx("path",{d:"M33.1906 2.47614H35.1906V0.476135H33.1906V2.47614Z",fill:"black"}),b.jsx("path",{d:"M44.3909 2.47614H42.3909V0.476135H44.3909V2.47614Z",fill:"black"}),b.jsx("path",{d:"M46.391 2.47614H52.391V0.476135H46.391V2.47614Z",fill:"black"}),b.jsx("path",{d:"M56.391 2.47614H54.391V0.476135H56.391V2.47614Z",fill:"black"}),b.jsx("path",{d:"M63.5913 2.47614H65.5913V0.476135H63.5913V2.47614Z",fill:"black"}),b.jsx("path",{d:"M73.5915 2.47614H67.5915V0.476135H73.5915V2.47614Z",fill:"black"}),b.jsx("path",{d:"M75.5915 2.47614H77.5915V0.476135H75.5915V2.47614Z",fill:"black"}),b.jsx("path",{d:"M86.7917 2.47614H84.7917V0.476135H86.7917V2.47614Z",fill:"black"}),b.jsx("path",{d:"M88.7919 2.47614H94.7919V0.476135H88.7919V2.47614Z",fill:"black"}),b.jsx("path",{d:"M98.7919 2.47614H96.7919V0.476135H98.7919V2.47614Z",fill:"black"}),b.jsx("path",{d:"M105.992 2.47614H107.992V0.476135H105.992V2.47614Z",fill:"black"}),b.jsx("path",{d:"M115.992 2.47614H109.992V0.476135H115.992V2.47614Z",fill:"black"}),b.jsx("path",{d:"M117.992 2.47614H119.992V0.476135H117.992V2.47614Z",fill:"black"})]}),OS=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.0100098 2.00415H1.98999V0.00415039H-0.0100098V2.00415Z",fill:"black"}),b.jsx("path",{d:"M3.99014 2.00415H9.99014V0.00415039H3.99014V2.00415Z",fill:"black"}),b.jsx("path",{d:"M13.9901 2.00415H11.9901V0.00415039H13.9901V2.00415Z",fill:"black"}),b.jsx("path",{d:"M15.9901 2.00415H17.9901V0.00415039H15.9901V2.00415Z",fill:"black"}),b.jsx("path",{d:"M27.4905 2.00415H25.4905V0.00415039H27.4905V2.00415Z",fill:"black"}),b.jsx("path",{d:"M29.4906 2.00415H35.4906V0.00415039H29.4906V2.00415Z",fill:"black"}),b.jsx("path",{d:"M39.4906 2.00415H37.4906V0.00415039H39.4906V2.00415Z",fill:"black"}),b.jsx("path",{d:"M41.4906 2.00415H43.4906V0.00415039H41.4906V2.00415Z",fill:"black"}),b.jsx("path",{d:"M52.991 2.00415H50.991V0.00415039H52.991V2.00415Z",fill:"black"}),b.jsx("path",{d:"M54.9911 2.00415H60.9911V0.00415039H54.9911V2.00415Z",fill:"black"}),b.jsx("path",{d:"M64.9911 2.00415H62.9911V0.00415039H64.9911V2.00415Z",fill:"black"}),b.jsx("path",{d:"M66.9911 2.00415H68.9911V0.00415039H66.9911V2.00415Z",fill:"black"}),b.jsx("path",{d:"M78.4915 2.00415H76.4915V0.00415039H78.4915V2.00415Z",fill:"black"}),b.jsx("path",{d:"M80.4916 2.00415H86.4916V0.00415039H80.4916V2.00415Z",fill:"black"}),b.jsx("path",{d:"M90.4916 2.00415H88.4916V0.00415039H90.4916V2.00415Z",fill:"black"}),b.jsx("path",{d:"M92.4916 2.00415H94.4916V0.00415039H92.4916V2.00415Z",fill:"black"}),b.jsx("path",{d:"M103.992 2.00415H101.992V0.00415039H103.992V2.00415Z",fill:"black"}),b.jsx("path",{d:"M105.992 2.00415H111.992V0.00415039H105.992V2.00415Z",fill:"black"}),b.jsx("path",{d:"M115.992 2.00415H113.992V0.00415039H115.992V2.00415Z",fill:"black"}),b.jsx("path",{d:"M117.992 2.00415H119.992V0.00415039H117.992V2.00415Z",fill:"black"})]}),xS=()=>b.jsxs("svg",{width:"118",height:"3",viewBox:"0 0 118 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.00854492 2.94815H1.99146V0.948151H-0.00854492V2.94815Z",fill:"black"}),b.jsx("path",{d:"M6.09668 2.94815H8.09668V0.948151H6.09668V2.94815Z",fill:"black"}),b.jsx("path",{d:"M14.2019 2.94815H12.2019V0.948151H14.2019V2.94815Z",fill:"black"}),b.jsx("path",{d:"M18.3071 2.94815H20.3071V0.948151H18.3071V2.94815Z",fill:"black"}),b.jsx("path",{d:"M26.4124 2.94815H24.4124V0.948151H26.4124V2.94815Z",fill:"black"}),b.jsx("path",{d:"M30.5176 2.94815H32.5176V0.948151H30.5176V2.94815Z",fill:"black"}),b.jsx("path",{d:"M38.6228 2.94815H36.6228V0.948151H38.6228V2.94815Z",fill:"black"}),b.jsx("path",{d:"M42.728 2.94815H44.728V0.948151H42.728V2.94815Z",fill:"black"}),b.jsx("path",{d:"M50.8333 2.94815H48.8333V0.948151H50.8333V2.94815Z",fill:"black"}),b.jsx("path",{d:"M54.9385 2.94815H56.9385V0.948151H54.9385V2.94815Z",fill:"black"}),b.jsx("path",{d:"M63.0437 2.94815H61.0437V0.948151H63.0437V2.94815Z",fill:"black"}),b.jsx("path",{d:"M67.1489 2.94815H69.1489V0.948151H67.1489V2.94815Z",fill:"black"}),b.jsx("path",{d:"M75.2542 2.94815H73.2542V0.948151H75.2542V2.94815Z",fill:"black"}),b.jsx("path",{d:"M79.3594 2.94815H81.3594V0.948151H79.3594V2.94815Z",fill:"black"}),b.jsx("path",{d:"M87.4645 2.94815H85.4645V0.948151H87.4645V2.94815Z",fill:"black"}),b.jsx("path",{d:"M91.5697 2.94815H93.5697V0.948151H91.5697V2.94815Z",fill:"black"}),b.jsx("path",{d:"M99.6749 2.94815H97.6749V0.948151H99.6749V2.94815Z",fill:"black"}),b.jsx("path",{d:"M103.78 2.94815H105.78V0.948151H103.78V2.94815Z",fill:"black"}),b.jsx("path",{d:"M111.885 2.94815H109.885V0.948151H111.885V2.94815Z",fill:"black"}),b.jsx("path",{d:"M115.991 2.94815H117.991V0.948151H115.991V2.94815Z",fill:"black"})]}),AS=()=>b.jsx("svg",{width:"120",height:"4",viewBox:"0 0 120 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 3.86215H-0.0090332V0.862152H119.991V3.86215Z",fill:"black"})}),ya=()=>b.jsx("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 1.15668H-0.0090332V0.156677H119.991V1.15668Z",fill:"black"})});function Ma(n){const{type:i=a.BorderStyleTypes.THIN}=n;switch(i){case a.BorderStyleTypes.DASH_DOT:return b.jsx(ES,{});case a.BorderStyleTypes.DASH_DOT_DOT:return b.jsx(wS,{});case a.BorderStyleTypes.DASHED:return b.jsx(TS,{});case a.BorderStyleTypes.HAIR:return b.jsx(yS,{});case a.BorderStyleTypes.MEDIUM:return b.jsx(MS,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT:return b.jsx(PS,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return b.jsx(OS,{});case a.BorderStyleTypes.MEDIUM_DASHED:return b.jsx(xS,{});case a.BorderStyleTypes.THICK:return b.jsx(AS,{});case a.BorderStyleTypes.THIN:return b.jsx(ya,{});default:return b.jsx(ya,{})}}const Vs=`${Dn}_BORDER_PANEL_COMPONENT`,Jl=[{label:"borderLine.borderTop",icon:"UpBorder",value:"top"},{label:"borderLine.borderBottom",icon:"DownBorder",value:"bottom"},{label:"borderLine.borderLeft",icon:"LeftBorder",value:"left"},{label:"borderLine.borderRight",icon:"RightBorder",value:"right"},{label:"borderLine.borderNone",icon:"NoBorderSingle",value:"none"},{label:"borderLine.borderAll",icon:"AllBorderSingle",value:"all"},{label:"borderLine.borderOutside",icon:"OuterBorder",value:"outside"},{label:"borderLine.borderInside",icon:"InnerBorder",value:"inside"},{label:"borderLine.borderHorizontal",icon:"HorizontalBorder",value:"horizontal"},{label:"borderLine.borderVertical",icon:"VerticalBorder",value:"vertical"},{label:"borderLine.borderTlbr",icon:"BackSlashSingle",value:"tlbr"},{label:"borderLine.borderTlbcTlmr",icon:"LeftDoubleDiagonalSingle",value:"tlbc_tlmr"},{label:"borderLine.borderTlbrTlbcTlmr",icon:"LeftTridiagonalSingle",value:"tlbr_tlbc_tlmr"},{label:"borderLine.borderBlTr",icon:"SlashSingle",value:"bltr"},{label:"borderLine.borderMltrBctr",icon:"RightDoubleDiagonalSingle",value:"mltr_bctr"}],kS=[{label:a.BorderStyleTypes.THIN,value:a.BorderStyleTypes.THIN},{label:a.BorderStyleTypes.HAIR,value:a.BorderStyleTypes.HAIR},{label:a.BorderStyleTypes.DOTTED,value:a.BorderStyleTypes.DOTTED},{label:a.BorderStyleTypes.DASHED,value:a.BorderStyleTypes.DASHED},{label:a.BorderStyleTypes.DASH_DOT,value:a.BorderStyleTypes.DASH_DOT},{label:a.BorderStyleTypes.DASH_DOT_DOT,value:a.BorderStyleTypes.DASH_DOT_DOT},{label:a.BorderStyleTypes.MEDIUM,value:a.BorderStyleTypes.MEDIUM},{label:a.BorderStyleTypes.MEDIUM_DASHED,value:a.BorderStyleTypes.MEDIUM_DASHED},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT},{label:a.BorderStyleTypes.THICK,value:a.BorderStyleTypes.THICK}];function $l(n){var l;const i=_.useDependency(_.ComponentManager),e=_.useDependency(m.BorderStyleManagerService),{onChange:t,value:r}=n;function o(c,d){t==null||t({...r,[d]:c})}function s(c){const d=i.get(c);return d&&b.jsx(d,{extend:{colorChannel1:"#2c53f1"}})}return b.jsxs("section",{className:"univer-box-border univer-grid univer-gap-2 univer-p-1.5",children:[b.jsx("div",{className:"univer-box-border univer-grid univer-grid-cols-5 univer-gap-2",children:Jl.map(c=>b.jsx("a",{className:Y.clsx(`
59
59
  univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center
60
60
  univer-justify-self-center univer-rounded
61
61
  hover:univer-bg-gray-100