@univerjs/sheets-ui 0.6.7-nightly.202503261607 → 0.6.7-nightly.202503291606
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/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(y,Q){typeof exports=="object"&&typeof module<"u"?Q(exports,require("@univerjs/docs-ui"),require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("react"),require("rxjs"),require("@univerjs/sheets"),require("@univerjs/docs"),require("@univerjs/engine-formula"),require("@univerjs/engine-numfmt"),require("react/jsx-runtime"),require("@univerjs/design"),require("rxjs/operators"),require("@univerjs/telemetry")):typeof define=="function"&&define.amd?define(["exports","@univerjs/docs-ui","@univerjs/core","@univerjs/engine-render","@univerjs/ui","react","rxjs","@univerjs/sheets","@univerjs/docs","@univerjs/engine-formula","@univerjs/engine-numfmt","react/jsx-runtime","@univerjs/design","rxjs/operators","@univerjs/telemetry"],Q):(y=typeof globalThis<"u"?globalThis:y||self,Q(y.UniverSheetsUi={},y.UniverDocsUi,y.UniverCore,y.UniverEngineRender,y.UniverUi,y.React,y.rxjs,y.UniverSheets,y.UniverDocs,y.UniverEngineFormula,y.UniverEngineNumfmt,y.React,y.UniverDesign,y.rxjs.operators,y.UniverTelemetry))})(this,function(y,Q,a,M,I,L,k,m,we,q,ad,b,G,Se,ld){"use strict";var $p=Object.defineProperty;var ev=(y,Q,a)=>Q in y?$p(y,Q,{enumerable:!0,configurable:!0,writable:!0,value:a}):y[Q]=a;var w=(y,Q,a)=>ev(y,typeof Q!="symbol"?Q+"":Q,a);function Li(n,o){if(n==null)return;const e=o.getRenderById(n);if(e==null)return;const{mainComponent:t,scene:i,engine:r,components:s}=e,l=t,c=s.get(Q.DOCS_VIEW_KEY.BACKGROUND);return{document:l,docBackground:c,scene:i,engine:r}}const jo=[10,400],Go="RANGE_SELECTOR_COMPONENT_KEY",Ui="EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY";var he=(n=>(n.MAIN="__SpreadsheetRender__",n.ROW="__SpreadsheetRowHeader__",n.COLUMN="__SpreadsheetColumnHeader__",n.LEFT_TOP="__SpreadsheetLeftTopPlaceholder__",n))(he||{});const zs=0,Bi=1,ft=10,cd=11,Xs=12,xi={id:"sheet.command.set-row-header-width",type:a.CommandType.COMMAND,handler:async(n,o)=>{if(!o)return!1;const e=n.get(M.IRenderManagerService);if(!e)return!1;const{unitId:t,subUnitId:i,size:r}=o,s=e.getRenderById(t);if(s){e.getRenderById(t).with(y.SheetSkeletonManagerService).setRowHeaderSize(s,i,r);const{components:c}=s,d=c.get(he.ROW);d&&d.setCustomHeader({headerStyle:{size:r}})}return!0}},Fi={id:"sheet.command.set-col-header-height",type:a.CommandType.COMMAND,handler:async(n,o)=>{if(!o)return!1;const e=n.get(M.IRenderManagerService);if(!e)return!1;const{unitId:t,subUnitId:i,size:r}=o,s=e.getRenderById(t);if(s){e.getRenderById(t).with(y.SheetSkeletonManagerService).setColumnHeaderSize(s,i,r);const{components:c}=s,d=c.get(he.COLUMN);d&&d.setCustomHeader({headerStyle:{size:r}})}return!0}},Zo=a.createInterceptorKey("rangeMovePermissionCheck"),Ko=a.createInterceptorKey("rangeFillPermissionCheck");var qo=(n=>(n[n.FORMULA_EDITOR_SHOW=100]="FORMULA_EDITOR_SHOW",n[n.MARK_SELECTION=1e4]="MARK_SELECTION",n))(qo||{});function pt(n){const o=n.getCurrentTheme(),e=new a.ColorKit(o.primaryColor).setAlpha(.07).toRgbString();return{strokeWidth:1,stroke:o.primaryColor,fill:e,widgets:{},widgetSize:6,widgetStrokeWidth:1,widgetStroke:o.colorWhite,autofillSize:6,autofillStrokeWidth:1,autofillStroke:o.colorWhite,rowHeaderFill:e,rowHeaderStroke:o.primaryColor,rowHeaderStrokeWidth:1,columnHeaderFill:e,columnHeaderStroke:o.primaryColor,columnHeaderStrokeWidth:1,expandCornerSize:40}}class dd{constructor(){w(this,"_startColumn",-1);w(this,"_startRow",-1);w(this,"_endColumn",-1);w(this,"_endRow",-1);w(this,"_startX",0);w(this,"_startY",0);w(this,"_endX",0);w(this,"_endY",0);w(this,"_primary");w(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(o){const{startColumn:e,startRow:t,endColumn:i,endRow:r}=this,{startColumn:s,startRow:l,endColumn:c,endRow:d}=o;return e===s&&t===l&&i===c&&r===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(o){this._rangeType=o}getValue(){return{rangeWithCoord:this.getRange(),primaryWithCoord:this._primary}}setValue(o,e){const{startColumn:t,startRow:i,endColumn:r,endRow:s,startX:l,startY:c,endX:d,endY:u,rangeType:h}=o;this._startColumn=t,this._startRow=i,this._endColumn=r,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(o){this._primary=o}clearCurrentCell(){this._primary=null}}function on(n,o){const{startRow:e,startColumn:t,endRow:i,endColumn:r,rangeType:s}=o,l=i<e?i:e,c=i<e?e:i,d=r<t?r:t,u=r<t?t:r,h=n.getNoMergeCellWithCoordByIndex(l,d),S=n.getNoMergeCellWithCoordByIndex(c,u);return{startRow:e,startColumn:t,endRow:i,endColumn:r,rangeType:s,startY:(h==null?void 0:h.startY)||0,endY:(S==null?void 0:S.endY)||0,startX:(h==null?void 0:h.startX)||0,endX:(S==null?void 0:S.endX)||0}}function Re(n,o){const{range:e,primary:t,style:i}=n,r=on(o,e),s=t&&Bn(o,t);return{rangeWithCoord:r,primaryWithCoord:s,style:i}}function Bn(n,o){const{actualRow:e,actualColumn:t,isMerged:i,isMergedMainCell:r,startRow:s,startColumn:l,endRow:c,endColumn:d}=o,u=n.getNoMergeCellWithCoordByIndex(e,t),h=n.getNoMergeCellWithCoordByIndex(s,l),S=n.getNoMergeCellWithCoordByIndex(c,d);return{actualRow:e,actualColumn:t,isMerged:i,isMergedMainCell:r,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:(S==null?void 0:S.endY)||0,startX:(h==null?void 0:h.startX)||0,endX:(S==null?void 0:S.endX)||0}}}const Ys="__SpreadsheetHelperSelectionTempRect",ud=35;class js{constructor(o,e){w(this,"_startOffsetX",0);w(this,"_startOffsetY",0);w(this,"_relativeSelectionPositionRow",0);w(this,"_relativeSelectionPositionColumn",0);w(this,"_relativeSelectionRowLength",0);w(this,"_relativeSelectionColumnLength",0);w(this,"_scenePointerMoveSub");w(this,"_scenePointerUpSub");w(this,"_helperSelection");w(this,"_scrollTimer");w(this,"_activeViewport");w(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});w(this,"_isInMergeState",!1);w(this,"_fillControlColors",[]);w(this,"_skeleton");w(this,"_scene");w(this,"_themeService");w(this,"_injector");w(this,"_selectionHooks");this._control=o,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 o,e;(o=this._scrollTimer)==null||o.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(e=this._helperSelection)==null||e.dispose()}_getFreeze(){var e,t;return(t=(e=M.withCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,y.SheetSkeletonManagerService,this._injector.get(a.IUniverInstanceService),this._injector.get(M.IRenderManagerService)))==null?void 0:e.getCurrentParam())==null?void 0:t.skeleton.getWorksheetConfig().freeze}_isSelectionInViewport(o,e){const t=this._getFreeze()||{startRow:-1,startColumn:-1};switch(e.viewportKey){case M.SHEET_VIEWPORT_KEY.VIEW_MAIN:return o.endRow>=t.startRow&&o.endColumn>=t.startColumn;case M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP:case M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT:return o.endColumn>=t.startColumn&&o.startRow<t.startRow;case M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT:case M.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM:return o.endRow>=t.startRow&&o.startColumn<t.startColumn;case M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP:case M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT:case M.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP:case M.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP:return o.startRow<t.startRow&&o.startColumn<t.startColumn}}_clearObserverEvent(){var o,e;(o=this._scenePointerMoveSub)==null||o.unsubscribe(),(e=this._scenePointerUpSub)==null||e.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null}_initialControl(){const{leftControl:o,rightControl:e,topControl:t,bottomControl:i}=this._control;[o,e,t,i].forEach(r=>{r.onPointerEnter$.subscribeEvent(()=>{var l;((l=this._injector.get(ve,a.Quantity.OPTIONAL))==null?void 0:l.interceptor.fetchThroughInterceptors(Zo)(!1,null))!==!1&&r.setCursor(M.CURSOR_TYPE.MOVE)}),r.onPointerLeave$.subscribeEvent(()=>{r.resetCursor()}),r.onPointerDown$.subscribeEvent(this._controlPointerDownHandler.bind(this))})}_controlMoving(o,e){var N;const t=this._scene,i=t.getScrollXYInfoByViewport(M.Vector2.FromArray([o,e])),{scaleX:r,scaleY:s}=t.getAncestorScale(),l=this._skeleton.getCellIndexByOffset(o,e,r,s,i),{row:c,column:d}=l,u=this._skeleton.getRowCount()-1,h=this._skeleton.getColumnCount()-1;let S=Math.max(0,c+this._relativeSelectionPositionRow),g=S+this._relativeSelectionRowLength;g>u&&(g=u,g-S<this._relativeSelectionRowLength&&(S=g-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(S,f),_=Re({range:{startRow:S,endRow:g,startColumn:f,endColumn:p},primary:v,style:null},this._skeleton),E=this._skeleton.getNoMergeCellWithCoordByIndex(S,f),T=this._skeleton.getNoMergeCellWithCoordByIndex(g,p),P=(E==null?void 0:E.startY)||0,R=(T==null?void 0:T.endY)||0,O=(E==null?void 0:E.startX)||0,A=(T==null?void 0:T.endX)||0;(N=this._helperSelection)==null||N.transformByState({left:O,top:P,width:A-O,height:R-P}),this._targetSelection={..._.rangeWithCoord},this._control.selectionMoving$.next(_.rangeWithCoord)}_controlPointerDownHandler(o){const{offsetX:e,offsetY:t}=o,i=this._scene,r=i.getCoordRelativeToViewport(M.Vector2.FromArray([e,t])),{x:s,y:l}=r,c=i.getScrollXYInfoByViewport(r),{scaleX:d,scaleY:u}=i.getAncestorScale(),h=this._skeleton.getCellIndexByOffset(s,l,d,u,c);this._startOffsetX=s,this._startOffsetY=l;const{row:S,column:g}=h,{startRow:f,startColumn:p,endRow:v,endColumn:C}=this._control.model;let _=0,E=0;S<f?_-=1:S>v&&(_+=1),g<p?E-=1:g>C&&(E+=1),this._relativeSelectionPositionRow=f-S+_,this._relativeSelectionPositionColumn=p-g+E,this._relativeSelectionRowLength=v-f,this._relativeSelectionColumnLength=C-p;const T=this._control.currentStyle,P=this._getScale();this.isHelperSelection&&(this._helperSelection=new M.Rect(Ys,{stroke:T.stroke,strokeWidth:T.strokeWidth/P}),i.addObject(this._helperSelection));const R=i.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN),O=M.ScrollTimer.create(i);this._scrollTimer=O,O.startScroll(s,l,R),i.disableObjectsEvent(),this._scenePointerMoveSub=i.onPointerMove$.subscribeEvent(A=>{var V;const{offsetX:N,offsetY:D}=A;if(((V=this._injector.get(ve,a.Quantity.OPTIONAL))==null?void 0:V.interceptor.fetchThroughInterceptors(Zo)(!1,null))===!1)return;const{x:W,y:U}=i.getCoordRelativeToViewport(M.Vector2.FromArray([N,D]));this._controlMoving(W,U),i.setCursor(M.CURSOR_TYPE.MOVE),O.scrolling(W,U,()=>{this._controlMoving(W,U)})}),this._scenePointerUpSub=i.onPointerUp$.subscribeEvent(()=>{var N,D,H,W;(N=this._helperSelection)==null||N.dispose();const A=this._scene;A.resetCursor(),this._clearObserverEvent(),A.enableObjectsEvent(),(D=this._scrollTimer)==null||D.dispose(),this._control.selectionMoveEnd$.next(this._targetSelection),(W=(H=this._selectionHooks).selectionMoveEnd)==null||W.call(H)})}_initialWidget(){const{topLeftWidget:o,topCenterWidget:e,topRightWidget:t,middleLeftWidget:i,middleRightWidget:r,bottomLeftWidget:s,bottomCenterWidget:l,bottomRightWidget:c}=this._control,d=[M.CURSOR_TYPE.NORTH_WEST_RESIZE,M.CURSOR_TYPE.NORTH_RESIZE,M.CURSOR_TYPE.NORTH_EAST_RESIZE,M.CURSOR_TYPE.WEST_RESIZE,M.CURSOR_TYPE.EAST_RESIZE,M.CURSOR_TYPE.SOUTH_WEST_RESIZE,M.CURSOR_TYPE.SOUTH_RESIZE,M.CURSOR_TYPE.SOUTH_EAST_RESIZE];[o,e,t,i,r,s,l,c].forEach((u,h)=>{u.onPointerEnter$.subscribeEvent(()=>{u.setCursor(d[h])}),u.onPointerLeave$.subscribeEvent(()=>{u.resetCursor()}),u.onPointerDown$.subscribeEvent(S=>{this._widgetPointerDownEvent(S,d[h])})})}_widgetPointerDownEvent(o,e){const t=this._scene,{offsetX:i,offsetY:r}=o,s=t.getCoordRelativeToViewport(M.Vector2.FromArray([i,r])),{x:l,y:c}=s;this._startOffsetX=i,this._startOffsetY=r;const{startRow:d,startColumn:u,endRow:h,endColumn:S}=this._control.model,g=Math.min(d,h),f=Math.min(u,S),p=Math.max(d,h),v=Math.max(u,S);this._relativeSelectionPositionRow=g,this._relativeSelectionPositionColumn=f,this._relativeSelectionRowLength=p-g,this._relativeSelectionColumnLength=v-f,e===M.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=p,this._relativeSelectionPositionColumn=v):e===M.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=p:e===M.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=p:e===M.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=v:e===M.CURSOR_TYPE.SOUTH_WEST_RESIZE?this._relativeSelectionPositionColumn=v:e===M.CURSOR_TYPE.SOUTH_RESIZE&&(this._relativeSelectionPositionRow=g);const C=M.ScrollTimer.create(t),_=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN);C.startScroll(l,c,_),this._scrollTimer=C,t.disableObjectsEvent(),this._scenePointerMoveSub=t.onPointerMove$.subscribeEvent(E=>{const{offsetX:T,offsetY:P}=E,{x:R,y:O}=t.getCoordRelativeToViewport(M.Vector2.FromArray([T,P]));this._widgetMoving(R,O,e),t.setCursor(e),C.scrolling(R,O,()=>{this._widgetMoving(R,O,e)})}),this._scenePointerUpSub=t.onPointerUp$.subscribeEvent(()=>{var T,P,R;const E=this._scene;E.resetCursor(),this._clearObserverEvent(),E.enableObjectsEvent(),(T=this._scrollTimer)==null||T.dispose(),this._control.selectionScaled$.next(this._targetSelection),(R=(P=this._selectionHooks).selectionMoveEnd)==null||R.call(P)})}_widgetMoving(o,e,t){const i=this._scene,r=i.getScrollXYInfoByViewport(M.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:l}=i.getAncestorScale(),c=this._skeleton.getCellIndexByOffset(o,e,s,l,r),{row:d,column:u}=c;let h=this._relativeSelectionPositionRow,S=this._relativeSelectionPositionColumn,g=d,f=u;t===M.CURSOR_TYPE.NORTH_WEST_RESIZE?(h=d,S=u,g=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn):t===M.CURSOR_TYPE.NORTH_RESIZE?(h=d,S=this._relativeSelectionPositionColumn,g=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):t===M.CURSOR_TYPE.NORTH_EAST_RESIZE?(h=d,S=this._relativeSelectionPositionColumn,g=this._relativeSelectionPositionRow,f=u):t===M.CURSOR_TYPE.WEST_RESIZE?(h=this._relativeSelectionPositionRow,S=u,g=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,f=this._relativeSelectionPositionColumn):t===M.CURSOR_TYPE.EAST_RESIZE?g=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:t===M.CURSOR_TYPE.SOUTH_WEST_RESIZE?(h=this._relativeSelectionPositionRow,S=u,g=d,f=this._relativeSelectionPositionColumn):t===M.CURSOR_TYPE.SOUTH_RESIZE&&(h=this._relativeSelectionPositionRow,S=this._relativeSelectionPositionColumn,g=d,f=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const p=this._swapPositions(h,S,g,f),v=this._skeleton.getCellWithMergeInfoByIndex(h,S),_=Re({range:p,primary:v,style:null},this._skeleton);this._targetSelection={..._.rangeWithCoord},this._control.updateRangeBySelectionWithCoord(_),this._control.selectionScaling$.next(this._targetSelection)}_initialAutoFill(){const{fillControl:o}=this._control;o.onPointerEnter$.subscribeEvent(e=>{this._injector.get(ve).interceptor.fetchThroughInterceptors(Ko)(!1,{x:e.offsetX,y:e.offsetY,skeleton:this._skeleton,scene:this._scene})&&o.setCursor(M.CURSOR_TYPE.CROSSHAIR)}),o.onPointerLeave$.subscribeEvent(()=>{o.resetCursor()}),o.onPointerDown$.subscribeEvent(this._autoFillForPointerdown.bind(this))}_autoFillMoving(o,e){var D,H,W;const t=this._scene,i=t.getViewportScrollXY(this._activeViewport),{scaleX:r,scaleY:s}=t.getAncestorScale(),l=this._skeleton.getCellIndexByOffset(o,e,r,s,i),{row:c,column:d}=l,u=t.getCoordRelativeToViewport(M.Vector2.FromArray([o,e])),h=this._skeleton.getRowCount()-1,S=this._skeleton.getColumnCount()-1;let g=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn,p=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,C=!1,_=!0;if((d<f||d>v)&&c>=g&&c<=p){const U=this._fillRuler(d,f,v,this._relativeSelectionColumnLength,S);f=U.startRowOrColumn,v=U.endRowOrColumn,C=U.isLighten,_=!1}else if((c<g||c>p)&&d>=f&&d<=v){const U=this._fillRuler(c,g,p,this._relativeSelectionRowLength,h);g=U.startRowOrColumn,p=U.endRowOrColumn,C=U.isLighten}else if(Math.abs(this._startOffsetX-u.x-i.x)/2>Math.abs(this._startOffsetY-u.y-i.y)){const U=this._fillRuler(d,f,v,this._relativeSelectionColumnLength,S);f=U.startRowOrColumn,v=U.endRowOrColumn,C=U.isLighten,_=!1}else{const U=this._fillRuler(c,g,p,this._relativeSelectionRowLength,h);g=U.startRowOrColumn,p=U.endRowOrColumn,C=U.isLighten}const E=this._skeleton.getNoMergeCellWithCoordByIndex(g,f),T=this._skeleton.getNoMergeCellWithCoordByIndex(p,v),P=(E==null?void 0:E.startY)||0,R=(T==null?void 0:T.endY)||0,O=(E==null?void 0:E.startX)||0,A=(T==null?void 0:T.endX)||0;C?this._controlHandler((U,V)=>{const B=new a.ColorKit(this._fillControlColors[V]).lighten(ud).toRgbString();U.setProps({fill:B})}):this._controlHandler((U,V)=>{U.setProps({fill:this._fillControlColors[V]})});const N=m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();g===p&&_===!0||f===v&&_===!1?(D=this._helperSelection)==null||D.hide():((H=this._helperSelection)==null||H.transformByState({left:O-N/2,top:P-N/2,width:A-O,height:R-P}),(W=this._helperSelection)==null||W.show()),this._targetSelection={startY:P,endY:R,startX:O,endX:A,startRow:g,endRow:p,startColumn:f,endColumn:v},this._control.selectionFilling$.next(this._targetSelection)}_autoFillForPointerdown(o){const{offsetX:e,offsetY:t}=o,i=this._scene,r=i.getCoordRelativeToViewport(M.Vector2.FromArray([e,t])),{x:s,y:l}=r;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 S=this._control.currentStyle;let g=S==null?void 0:S.stroke,f=S==null?void 0:S.strokeWidth;const p=pt(this._themeService);g==null&&(g=p.stroke),f==null&&(f=p.strokeWidth);const v=this._getScale();f/=v;const C=m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/v,_=new a.ColorKit(g).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new M.Rect(Ys,{stroke:_,strokeWidth:f+C/2}),i.addObject(this._helperSelection)),this._activeViewport=i.getActiveViewportByCoord(M.Vector2.FromArray([e,t]));const E=i.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN),T=M.ScrollTimer.create(i,this._activeViewport.viewportKey===M.SHEET_VIEWPORT_KEY.VIEW_MAIN?M.ScrollTimerType.ALL:M.ScrollTimerType.NONE);T.startScroll(s,l,E),this._scrollTimer=T,i.disableObjectsEvent(),this._controlHandler(P=>{this._fillControlColors.push(P.fill)}),this._scenePointerMoveSub=i.onPointerMove$.subscribeEvent(P=>{var U;const{offsetX:R,offsetY:O}=P,A=i.getActiveViewportByCoord(M.Vector2.FromArray([R,O]));if(!this._injector.get(ve).interceptor.fetchThroughInterceptors(Ko)(!1,{x:o.offsetX,y:o.offsetY,skeleton:this._skeleton,scene:this._scene}))return;const{x:D,y:H}=i.getCoordRelativeToViewport(M.Vector2.FromArray([R,O]));this._autoFillMoving(D,H),i.setCursor(M.CURSOR_TYPE.CROSSHAIR);const W=this._targetSelection;if(E&&A&&((U=this._activeViewport)==null?void 0:U.viewportKey)!==(A==null?void 0:A.viewportKey)){let V;W.startRow!==c?(T.scrollTimerType=M.ScrollTimerType.Y,V={...W,endRow:W.startRow}):W.endRow!==u?(T.scrollTimerType=M.ScrollTimerType.Y,V={...W,startRow:W.endRow}):W.startColumn!==d?(T.scrollTimerType=M.ScrollTimerType.X,V={...W,endColumn:W.startColumn}):(T.scrollTimerType=M.ScrollTimerType.X,V={...W,startColumn:W.endColumn}),this._isSelectionInViewport(V,A)&&(E.scrollToBarPos({x:T.scrollTimerType===M.ScrollTimerType.X?0:void 0,y:T.scrollTimerType===M.ScrollTimerType.Y?0:void 0}),this._activeViewport=A)}T.scrolling(D,H,()=>{this._autoFillMoving(D,H)})}),this._scenePointerUpSub=i.onPointerUp$.subscribeEvent(()=>{var R,O;(R=this._helperSelection)==null||R.dispose();const P=this._scene;P.resetCursor(),this._clearObserverEvent(),P.enableObjectsEvent(),(O=this._scrollTimer)==null||O.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((A,N)=>{A.setProps({fill:this._fillControlColors[N]})}),this._fillControlColors=[]})}_hasMergeInRange(o,e,t,i){return this._skeleton.worksheet.getMergedCellRange(o,e,t,i).length>0}_swapPositions(o,e,t,i){const r=Math.min(o,t),s=Math.min(e,i),l=Math.max(o,t),c=Math.max(e,i);return{startRow:r,startColumn:s,endRow:l,endColumn:c}}_controlHandler(o){const{leftControl:e,rightControl:t,topControl:i,bottomControl:r,backgroundControlTop:s,backgroundControlMiddleLeft:l,backgroundControlMiddleRight:c,backgroundControlBottom:d,fillControl:u}=this._control,h=[e,t,i,r,s,l,c,d,u];for(let S=0,g=h.length;S<g;S++){const f=h[S];o(f,S)}}_fillRuler(o,e,t,i,r){let s=!1;if(o<e)if(this._isInMergeState&&o<e){const l=e-o,c=i+1,d=Math.ceil(l/c);let u=e-d*c;u<0&&(u=e-(d-1)*c),e=u}else e=o;else if(o>=e&&o<=t)s=!0,this._isInMergeState||(t=o);else if(this._isInMergeState&&o>t){const l=o-t,c=i+1,d=Math.ceil(l/c);let u=t+d*c;u>r&&(u=t+(d-1)*c),t=u}else t=o;return{rowOrColumn:o,startRowOrColumn:e,endRowOrColumn:t,isLighten:s}}_getScale(){const{scaleX:o,scaleY:e}=this._scene.getAncestorScale();return Math.max(o,e)}}var Qo=(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))(Qo||{});const Gs=.3;class xn extends a.Disposable{constructor(e,t,i,r){var s,l,c,d;super();w(this,"_isHelperSelection",!0);w(this,"_enableAutoFill",!0);w(this,"_showAutoFill",!1);w(this,"_highlightHeader",!0);w(this,"_selectionRenderModel");w(this,"_leftBorder");w(this,"_rightBorder");w(this,"_topBorder");w(this,"_bottomBorder");w(this,"_backgroundControlTop");w(this,"_backgroundControlBottom");w(this,"_backgroundControlMiddleLeft");w(this,"_backgroundControlMiddleRight");w(this,"_autoFillControl");w(this,"_selectionShapeGroup");w(this,"_rowHeaderBackground");w(this,"_rowHeaderBorder");w(this,"_rowHeaderGroup");w(this,"_columnHeaderBackground");w(this,"_columnHeaderBorder");w(this,"_columnHeaderGroup");w(this,"_dashedRect");w(this,"_topLeftWidget");w(this,"_topCenterWidget");w(this,"_topRightWidget");w(this,"_middleLeftWidget");w(this,"_middleRightWidget");w(this,"_bottomLeftWidget");w(this,"_bottomCenterWidget");w(this,"_bottomRightWidget");w(this,"_defaultStyle");w(this,"_currentStyle");w(this,"_rowHeaderWidth",0);w(this,"_columnHeaderHeight",0);w(this,"_widgetRects",[]);w(this,"_controlExtension");w(this,"_dispose$",new k.BehaviorSubject(this));w(this,"dispose$",this._dispose$.asObservable());w(this,"selectionMoving$",new k.Subject);w(this,"selectionMoveEnd$",new k.Subject);w(this,"selectionScaling$",new k.Subject);w(this,"selectionScaled$",new k.Subject);w(this,"selectionFilling$",new k.Subject);w(this,"_selectionFilled$",new k.Subject);w(this,"selectionFilled$",this._selectionFilled$.asObservable());w(this,"_antLineOffset",0);w(this,"_antRequestNewFrame",-1);this._scene=e,this._zIndex=t,this._themeService=i,this._enableAutoFill=(s=r==null?void 0:r.enableAutoFill)!=null?s:!0,this._highlightHeader=(l=r==null?void 0:r.highlightHeader)!=null?l:!0,this._rowHeaderWidth=(c=r==null?void 0:r.rowHeaderWidth)!=null?c:0,this._columnHeaderHeight=(d=r==null?void 0:r.columnHeaderHeight)!=null?d:0,this._initializeSheetBody(),this._initialHeader()}_initializeSheetBody(){this._defaultStyle=pt(this._themeService),this._currentStyle=pt(this._themeService),this._selectionRenderModel=new dd;const e=this._zIndex;this._leftBorder=new M.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightBorder=new M.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topBorder=new M.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomBorder=new M.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new M.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new M.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new M.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new M.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._autoFillControl=new M.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._autoFillControl.hide(),this._dashedRect=new M.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 M.Group("__SpreadsheetSelectionShape__"+e,...t,...this._widgetRects),this._selectionShapeGroup.hide(),this._selectionShapeGroup.evented=!1,this._selectionShapeGroup.zIndex=e;const i=this.getScene();i.addObject(this._selectionShapeGroup,Bi),this.disposeWithMe(a.toDisposable(i.onTransformChange$.subscribeEvent(r=>{r.type===M.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&(this._updateLayoutOfSelectionControl(this._currentStyle),this._updateControlCoord())})))}_initialHeader(){const e=this._zIndex;this._rowHeaderBackground=new M.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new M.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new M.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new M.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new M.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new M.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],cd)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new M.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new M.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new M.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new M.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new M.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new M.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new M.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new M.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 js(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:i,widgets:r,autofillStroke:s,strokeDash:l,isAnimationDash:c}=t;let d=t.autofillSize,u=t.strokeWidth,h=t.autofillStrokeWidth;const S=this._getScale(),g=(u+m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH)/2/S;u/=S,d/=S,h/=S<1?1:S;const f=m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/S,p=M.FIX_ONE_PIXEL_BLUR_OFFSET/S,{startX:v,startY:C,endX:_,endY:E}=this._selectionRenderModel;if(this.leftControl.transformByState({height:E-C,left:-g+p,width:u,strokeWidth:f,top:-f/2+p}),this.leftControl.setProps({fill:i,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:E-C,left:_-v-g+p,width:u,strokeWidth:f,top:-f/2+p}),this.rightControl.setProps({fill:i,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:_-v+u,top:-g+p,left:-g+p,height:u,strokeWidth:f}),this.topControl.setProps({fill:i,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:_-v+u,top:E-C-g+p,height:u,left:-g+p,strokeWidth:f}),this.bottomControl.setProps({fill:i,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),l==null)this.dashedRect.hide(),this._stopAntLineAnimation();else{const T=t.strokeWidth*2/S;this.dashedRect.transformByState({height:E-C,width:_-v,strokeWidth:T,left:-T/2+p,top:-T/2+p}),this.dashedRect.setProps({strokeDashArray:[0,l/S]}),this._stopAntLineAnimation(),c!==!1&&this._startAntLineAnimation(),this.dashedRect.show()}if(this._showAutoFill=this._showAutoFill&&this._enableAutoFill,this._showAutoFill&&!this._hasWidgets(r)){const T={fill:i,stroke:s,strokeScaleEnabled:!1},P={width:d-h,height:d-h,left:_-v-d/2+h/2-p,top:E-C-d/2+h/2-p,strokeWidth:h};this._autoFillControl.setProps(T),this._autoFillControl.transformByState(P),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,i=0,r,s){this._rowHeaderWidth=t,this._columnHeaderHeight=i,this.updateRangeBySelectionWithCoord({rangeWithCoord:e,primaryWithCoord:s,style:r}),r&&this.updateStyle(r)}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,i,r,s,l,c,d,u,h,S,g,f,p,v,C,_,E,T,P,R,O,A,N,D;(e=this._leftBorder)==null||e.dispose(),(t=this._rightBorder)==null||t.dispose(),(i=this._topBorder)==null||i.dispose(),(r=this._bottomBorder)==null||r.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(),(S=this._rowHeaderBorder)==null||S.dispose(),(g=this._rowHeaderGroup)==null||g.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(),(_=this._topLeftWidget)==null||_.dispose(),(E=this._topCenterWidget)==null||E.dispose(),(T=this._topRightWidget)==null||T.dispose(),(P=this._middleLeftWidget)==null||P.dispose(),(R=this._middleRightWidget)==null||R.dispose(),(O=this._bottomLeftWidget)==null||O.dispose(),(A=this._bottomCenterWidget)==null||A.dispose(),(N=this._bottomRightWidget)==null||N.dispose(),(D=this._controlExtension)==null||D.dispose(),super.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let t;if(e.isMerged){const i=e.mergeInfo;t={startRow:i.startRow,endRow:i.endRow,startColumn:i.startColumn,endColumn:i.endColumn,startX:i.startX,endX:i.endX,startY:i.startY,endY:i.endY}}else{const{actualRow:i,actualColumn:r,startX:s,endX:l,startY:c,endY:d}=e;t={startRow:i,endRow:i,startColumn:r,endColumn:r,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:i,endX:r,endY:s,rangeType:l}=this._selectionRenderModel,c=this._currentStyle,d=this._getScale(),{stroke:u,rowHeaderFill:h=c.rowHeaderFill,rowHeaderStroke:S=c.rowHeaderStroke,columnHeaderFill:g=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,_=this._columnHeaderHeight;if(this._highlightHeader&&_>0){let E=g;l===a.RANGE_TYPE.COLUMN&&(E=new a.ColorKit(u).setAlpha(Gs).toString()),this._columnHeaderBackground.setProps({fill:E}),this._columnHeaderBackground.resize(r-t,_),this._columnHeaderBorder.setProps({fill:f}),this._columnHeaderBorder.transformByState({width:r-t,height:v,top:_-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 E=h;l===a.RANGE_TYPE.ROW&&(E=new a.ColorKit(u).setAlpha(Gs).toString()),this._rowHeaderBackground.setProps({fill:E}),this._rowHeaderBackground.resize(C,s-i),this._rowHeaderBorder.setProps({fill:S}),this._rowHeaderBorder.transformByState({width:p,height:s-i,left:C-p+1/d}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,i)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){const{startX:t,startY:i,endX:r,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(r-t,s-i),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:S,endX:g,endY:f}=u,p=d/2,v={left:-p,top:-p,width:r-t+p*2,height:S-i+p};v.height<0&&(v.width=0,v.height=0),this._backgroundControlTop.transformByState(v);const C={left:-p,top:S-i,width:h-t+p,height:f-S};C.width<0&&(C.width=0,C.height=0),this._backgroundControlMiddleLeft.transformByState(C);const _={left:g-t-p,top:S-i,width:r-g+p*2,height:f-S};_.width<0&&(_.width=0,_.height=0),this._backgroundControlMiddleRight.transformByState(_);const E={left:-p,top:f-i,width:r-t+p*2,height:s-f+p};E.height<0&&(E.width=0,E.height=0),this._backgroundControlBottom.transformByState(E),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:i,endX:r,endY:s}=this._selectionRenderModel,{stroke:l=e.stroke,widgets:c=e.widgets,widgetStroke:d=e.widgetStroke}=e,u=this._getScale();let{widgetSize:h,widgetStrokeWidth:S}=e;h/=u,S/=u;const g={left:-h/2+S/2,center:(r-t)/2-h/2+S/2,right:r-t-h/2+S/2,top:-h/2,middle:(s-i)/2-h/2,bottom:s-i-h/2+S/2},f=h-S;this._widgetRects.forEach(p=>{p.setProps({fill:l,stroke:d})}),c.tl===!0?(this._topLeftWidget.transformByState({height:f,width:f,left:g.left,top:g.top,strokeWidth:S}),this._topLeftWidget.show()):this._topLeftWidget.hide(),c.tc===!0?(this._topCenterWidget.transformByState({height:f,width:f,left:g.center,top:g.top,strokeWidth:S}),this._topCenterWidget.show()):this._topCenterWidget.hide(),c.tr===!0?(this._topRightWidget.transformByState({height:f,width:f,left:g.right,top:g.top,strokeWidth:S}),this._topRightWidget.show()):this._topRightWidget.hide(),c.ml===!0?(this._middleLeftWidget.transformByState({height:f,width:f,left:g.left,top:g.middle,strokeWidth:S}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),c.mr===!0?(this._middleRightWidget.transformByState({height:f,width:f,left:g.right,top:g.middle,strokeWidth:S}),this._middleRightWidget.show()):this._middleRightWidget.hide(),c.bl===!0?(this._bottomLeftWidget.transformByState({height:f,width:f,left:g.left,top:g.bottom,strokeWidth:S}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),c.bc===!0?(this._bottomCenterWidget.transformByState({height:f,width:f,left:g.center,top:g.bottom,strokeWidth:S}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),c.br===!0?(this._bottomRightWidget.transformByState({height:f,width:f,left:g.right,top:g.bottom,strokeWidth:S}),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 i of t)if(e[i]===!0)return!0;return!1}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}_stopAntLineAnimation(){this._antLineOffset=0,M.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=M.requestNewFrame(()=>{this._startAntLineAnimation()})}}class hd extends M.Layer{render(o,e=!1){const t=a.Tools.now();return super.render(o,e),this._afterRender(t),this}_afterRender(o){this.scene.getEngine().renderFrameTimeMetric$.next(["selectionLayer",a.Tools.now()-o])}}const ve=a.createIdentifier("univer.sheet.selection-render-service");class Jo extends a.Disposable{constructor(e,t,i,r,s){super();w(this,"_downObserver");w(this,"_scenePointerMoveSub");w(this,"_scenePointerUpSub");w(this,"_controlFillConfig$",new k.BehaviorSubject(null));w(this,"controlFillConfig$",this._controlFillConfig$.asObservable());w(this,"_selectionControls",[]);w(this,"_startRangeWhenPointerDown",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});w(this,"_activeControlIndex",-1);w(this,"_startViewportPosX",0);w(this,"_startViewportPosY",0);w(this,"_scrollTimer");w(this,"_cancelDownSubscription");w(this,"_cancelUpSubscription");w(this,"_skeleton");w(this,"_scene");w(this,"_highlightHeader",!0);w(this,"_rangeType",a.RANGE_TYPE.NORMAL);w(this,"_selectionStyle");w(this,"_remainLastEnabled",!1);w(this,"_skipLastEnabled",!1);w(this,"_singleSelectionEnabled",!1);w(this,"_selectionMoveEnd$",new k.BehaviorSubject([]));w(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());w(this,"_selectionMoving$",new k.Subject);w(this,"selectionMoving$",this._selectionMoving$.asObservable());w(this,"_selectionMoveStart$",new k.Subject);w(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());w(this,"_selectionMoving",!1);w(this,"_selectionTheme");w(this,"_activeViewport");w(this,"interceptor",new a.InterceptorManager({RANGE_MOVE_PERMISSION_CHECK:Zo,RANGE_FILL_PERMISSION_CHECK:Ko}));w(this,"_escapeShortcutDisposable",null);this._injector=e,this._themeService=t,this._shortcutService=i,this._sheetSkeletonManagerService=r,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,i){const r=this.getSelectionControls().length,{rowHeaderWidth:s,columnHeaderHeight:l}=t,c=new xn(e,r,this._selectionTheme,{highlightHeader:this._highlightHeader,rowHeaderWidth:s,columnHeaderHeight:l});this._selectionControls.push(c);const d=Re(i,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(),i=this._skeleton;if(!(!t||!i)){for(let r=0,s=e.length;r<s;r++){const l=e[r],c=Re(l,this._skeleton),d=t[r];d?d.updateRangeBySelectionWithCoord(c,i):this.isSelectionEnabled()&&this.newSelectionControl(this._scene,i,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,i){this._skeleton=e,this._scene=t,this._activeViewport=i||(t==null?void 0:t.getViewports()[0]),t.findLayerByZIndex(Bi)||t.addLayer(new hd(t,[],Bi))}getSkeleton(){return this._skeleton}getSelectionDataWithStyle(){const e=this._selectionControls,[t,i]=this._skeleton.getLocation();return e.map(r=>{const s=r.getValue();return s.rangeWithCoord.sheetId=i,s.rangeWithCoord.unitId=t,s})}getSelectionControls(){return this._selectionControls}_addSelectionControlByModelData(e){var l;const t=this._skeleton,i=(l=e.style)!=null?l:pt(this._selectionTheme),r=this._scene;return e.style=i,this.newSelectionControl(r,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 i=this._getFreeze();if(!i||i.startRow<=0&&i.startColumn<=0)return this._scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(e>i.startRow&&t>i.startColumn)return this._scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(e<=i.startRow&&t<=i.startColumn)return this._scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP);if(e<=i.startRow&&t>i.startColumn)return this._scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(e>i.startRow&&t<=i.startColumn)return this._scene.getViewport(M.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,i,r=M.ScrollTimerType.ALL,s,l){var f,p;let c=0,d=0,u=s,h=l;this._scrollTimer=M.ScrollTimer.create(this._scene,r),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 S=this._scene,g=S.getActiveViewportByCoord(M.Vector2.FromArray([s,l]));this._scenePointerMoveSub=S.onPointerMove$.subscribeEvent(v=>{var W,U,V,B,x,z,F,Y,X;const{offsetX:C,offsetY:_}=v,{x:E,y:T}=S.getCoordRelativeToViewport(M.Vector2.FromArray([C,_]));this._movingHandler(E,T,t,i);let P=E,R=T;const O=this.getActiveSelectionControl(),A=this._getFreeze(),N=O==null?void 0:O.model,D=(W=S.getActiveViewportByCoord(M.Vector2.FromArray([C,_])))!=null?W:this._getViewportByCell(N==null?void 0:N.endRow,N==null?void 0:N.endColumn);if((()=>{if(!g||!D||!e)return!1;const Z=[M.SHEET_VIEWPORT_KEY.VIEW_MAIN,M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP,M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP,M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT];return Z.includes(g.viewportKey)&&Z.includes(D.viewportKey)})()){if(!g||!D||!e)return!1;const Z=u<e.left&&E>e.left||u>e.left&&E<e.left,ne=h<e.top&&T>e.top||h>e.top&&T<e.top;Z&&(c+=1),ne&&(d+=1);const J=g.viewportKey,ae=D.viewportKey;if(J===M.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP)_<e.top&&((U=N==null?void 0:N.endRow)!=null?U:0)<((V=A==null?void 0:A.startRow)!=null?V:0)?R=e.top:ne&&d%2===1&&e.scrollToViewportPos({viewportScrollY:0});else if(J===M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT)C<e.left&&((B=N==null?void 0:N.endColumn)!=null?B:0)<((x=A==null?void 0:A.startColumn)!=null?x:0)?P=e.left:Z&&c%2===1&&e.scrollToViewportPos({viewportScrollX:0});else if(J===ae){let ue=!1,j=!1;J===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP?(ue=!0,j=!0):J===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP?j=!0:J===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT&&(ue=!0),((z=N==null?void 0:N.endRow)!=null?z:0)>((F=A==null?void 0:A.startRow)!=null?F:0)&&(j=!1),((Y=N==null?void 0:N.endColumn)!=null?Y:0)>((X=A==null?void 0:A.startColumn)!=null?X:0)&&(ue=!1),ue&&(P=e.left),j&&(R=e.top)}else{const ue={x:g.scrollX,y:g.scrollY},j={x:D.scrollX,y:D.scrollY},K=ue.x!==j.x&&Z&&c%2===1,$=ue.y!==j.y&&ne&&d%2===1;(K||$)&&(e.scrollToBarPos({x:K?ue.x:void 0,y:$?ue.y:void 0}),K||(P=e.left),$||(R=e.top)),(J===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&ae===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT||ae===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&J===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)&&(P=e.left),(J===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&ae===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP||ae===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&J===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP)&&(R=e.top)}u=E,h=T}this._scrollTimer.scrolling(P,R,()=>{this._movingHandler(E,T,t,i)})})}attachSelectionWithCoord(e){return Re(e,this._skeleton)}attachPrimaryWithCoord(e){return Bn(this._skeleton,e)}getSelectionCellByPosition(e,t){return this.getCellWithCoordByOffset(e,t)}getCellWithCoordByOffset(e,t,i){const r=this._scene,s=i!=null?i:this._skeleton,l=r.getViewportScrollXY(r.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN)),{scaleX:c,scaleY:d}=r.getAncestorScale();return s.getCellWithCoordByOffset(e,t,c,d,l)}_movingHandler(e,t,i,r){var P,R,O,A,N;const s=this._skeleton,l=this._scene,[c,d]=s.getLocation(),u={startRow:(P=i==null?void 0:i.model.startRow)!=null?P:-1,endRow:(R=i==null?void 0:i.model.endRow)!=null?R:-1,startColumn:(O=i==null?void 0:i.model.startColumn)!=null?O:-1,endColumn:(A=i==null?void 0:i.model.endColumn)!=null?A:-1},h=l.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN),S=(N=this._getViewportByCell(u.endRow,u.endColumn))!=null?N:h,g=l.getScrollXYInfoByViewport(M.Vector2.FromArray([this._startViewportPosX,this._startViewportPosY]),S),{scaleX:f,scaleY:p}=l.getAncestorScale();r===a.RANGE_TYPE.ROW?e=Number.POSITIVE_INFINITY:r===a.RANGE_TYPE.COLUMN&&(t=Number.POSITIVE_INFINITY);const v=this._skeleton.getCellByOffset(e,t,f,p,g);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 E=Re({range:C,primary:void 0,style:null},s);E.rangeWithCoord.unitId=c,E.rangeWithCoord.sheetId=d,E.rangeWithCoord.rangeType=r;const T=u.startRow!==C.startRow||u.startColumn!==C.startColumn||u.endRow!==C.endRow||u.endColumn!==C.endColumn;i!=null&&T&&(i.updateRangeBySelectionWithCoord(E),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_clearUpdatingListeners(){var t,i,r,s,l;this._scene.enableObjectsEvent(),(t=this._scenePointerMoveSub)==null||t.unsubscribe(),this._scenePointerMoveSub=null,(i=this._scenePointerUpSub)==null||i.unsubscribe(),this._scenePointerUpSub=null,(r=this._cancelDownSubscription)==null||r.unsubscribe(),this._cancelDownSubscription=null,(s=this._cancelUpSubscription)==null||s.unsubscribe(),this._cancelUpSubscription=null,(l=this._scrollTimer)==null||l.dispose()}_addEndingListeners(){var i,r,s;const e=this._scene,t=(i=e.getEngine())==null?void 0:i.activeScene;!t||t===e||((r=this._cancelDownSubscription)==null||r.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,i,r,s){const l=this._skeleton;if(l==null)return null;if(this._shouldDetectMergedCells){const C=l==null?void 0:l.getCellWithCoordByOffset(e,t,i,r,s,{firstMatch:!0});if(!C)return;const _=a.convertCellToRange(C);return{primaryWithCoord:C,rangeWithCoord:_}}const{row:c,column:d}=l.getCellIndexByOffset(e,t,i,r,s),u=l.getNoMergeCellWithCoordByIndex(c,d),{startX:h,startY:S,endX:g,endY:f}=u,p={startY:S,endY:f,startX:h,endX:g,startRow:c,endRow:c,startColumn:d,endColumn:d};return{primaryWithCoord:{mergeInfo:p,actualRow:c,actualColumn:d,isMerged:!1,isMergedMainCell:!1,startY:S,endY:f,startX:h,endX:g},rangeWithCoord:p}}_checkClearPreviousControls(e){this.getSelectionControls().length!==0&&(!e.ctrlKey&&!e.shiftKey&&!this._remainLastEnabled||this._singleSelectionEnabled&&!e.shiftKey)&&this._clearAllSelectionControls()}_makeSelectionByTwoCells(e,t,i,r,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),S=Math.min(c,t.startColumn,d.startColumn),g=Math.max(c,t.endColumn,d.endColumn),p={range:i.expandRangeByMerge({startRow:u,startColumn:S,endRow:h,endColumn:g}),primary:null,style:null},v=Re(p,i);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 $o(n){return{range:{startRow:0,startColumn:0,endRow:n.getRowCount()-1,endColumn:n.getColumnCount()-1,rangeType:a.RANGE_TYPE.ALL},primary:zi(n).primary,style:null}}function zi(n){return Zs(n,{startRow:0,startColumn:0,endRow:0,endColumn:0})}function Zs(n,o){const e=n.worksheet.getCellInfoInMergeData(o.startRow,o.startColumn),t=n.worksheet.getCellInfoInMergeData(o.endRow,o.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 md=Object.getOwnPropertyDescriptor,Sd=(n,o,e,t)=>{for(var i=t>1?void 0:t?md(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},Ks=(n,o)=>(e,t)=>o(e,t,n);y.SheetSkeletonManagerService=class extends a.Disposable{constructor(e,t,i){super();w(this,"_sheetId","");w(this,"_sheetSkeletonParamStore",new Map);w(this,"_currentSkeleton$",new k.BehaviorSubject(null));w(this,"currentSkeleton$",this._currentSkeleton$.asObservable());w(this,"_currentSkeletonBefore$",new k.BehaviorSubject(null));w(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._context=e,this._injector=t,this._sheetSkService=i,this.disposeWithMe(()=>{this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParamStore.forEach(r=>this.disposeSkeleton(r.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 i=this._getSkeletonParam(t);return i!=null&&(i.unitId=e),i}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),i=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:i,sheetId:e,skeleton:d,dirty:!1})}const r=this._getSkeletonParam(e);this._currentSkeletonBefore$.next(r),this._currentSkeleton$.next(r)}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 i=this._getSkeletonParam(e.sheetId);i!=null&&(i.dirty=t)}getOrCreateSkeleton(e){return this.ensureSkeleton(e.sheetId)}ensureSkeleton(e){const t=this._getSkeletonParam(e);if(t)return t.skeleton;const r=this._context.unit.getSheetBySheetId(e);if(!r)return;const s=this._buildSkeleton(r);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?on(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(M.SpreadsheetSkeleton,e,this._context.unit.getStyles())}setColumnHeaderSize(e,t,i){var u;if(!e)return;const r=(u=this.getWorksheetSkeleton(t))==null?void 0:u.skeleton;if(!r)return;r.columnHeaderHeight=i,e.scene.getViewports()[0].top=i,e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).setViewportSize({height:i}),e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT).setViewportSize({height:i}),e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM).setViewportSize({top:i}),e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP).setViewportSize({top:i}),e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).setViewportSize({height:i});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=Fi.id,this._currentSkeleton$.next(d))}setRowHeaderSize(e,t,i){var f;const r=(f=this.getWorksheetSkeleton(t))==null?void 0:f.skeleton;if(!e||!r)return;r.rowHeaderWidth=i;const s=e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).width||46,l=i-s,c=e.scene.getViewports()[0].left;e.scene.getViewports()[0].left=c+l,e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM).setViewportSize({width:i}),e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP).setViewportSize({width:i}),e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT).setViewportSize({left:i});const d=e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).left||0;e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).setViewportSize({left:d+l}),e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).setViewportSize({width:i});const u=e==null?void 0:e.with(m.SheetsSelectionsService),h=e==null?void 0:e.with(ve),S=u.getCurrentSelections();h.resetSelectionsByModelData(S);const g=this.getCurrent();g&&(g.commandId=xi.id,this._currentSkeleton$.next(g))}},y.SheetSkeletonManagerService=Sd([Ks(1,a.Inject(a.Injector)),Ks(2,a.Inject(m.SheetSkeletonService))],y.SheetSkeletonManagerService);function ot(){const n=I.useDependency(a.IUniverInstanceService),o=I.useObservable(()=>n.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return o!=null?o:null}function gd(n){return I.useObservable(()=>{var e;return(e=n==null?void 0:n.activeSheet$)!=null?e:k.of(null)},void 0,void 0,[n])}function fd(){const n=I.useDependency(a.IUniverInstanceService);return I.useObservable(()=>k.merge([n.getTypeOfUnitAdded$(a.UniverInstanceType.UNIVER_SHEET),n.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET)]).pipe(k.map(()=>n.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET)),k.startWith(n.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET))),[],void 0,[n])}const pd="SheetUI";var er=(n=>(n.FILTER_PANEL_EMBED_POINT="filter-panel-embed-point",n.SHEETS_FOOTER="sheets-footer",n.FORMULA_AUX="formula-aux",n))(er||{});const Ke="sheets-ui.config",tr={formulaBar:!0,statusBarStatistic:!0,maxAutoHeightCount:1e3};var vd=Object.getOwnPropertyDescriptor,Cd=(n,o,e,t)=>{for(var i=t>1?void 0:t?vd(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},Fn=(n,o)=>(e,t)=>o(e,t,n);const nr=["ff","fs","tr","tb"];y.AutoHeightController=class extends a.Disposable{constructor(o,e,t,i,r){super(),this._renderManagerService=o,this._sheetInterceptorService=e,this._selectionManagerService=t,this._univerInstanceService=i,this._configService=r,this._initialize()}_getRangesScope(o){let e,t;for(const{startRow:i,endRow:r}of o)e=e===void 0?i:Math.min(e,i),t=t===void 0?r:Math.max(t,r);return t-e+1}getUndoRedoParamsOfAutoHeight(o,e){var _;const{_univerInstanceService:t,_configService:i}=this,r=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=r.getUnitId();let l=r.getActiveSheet(),c=l.getSheetId();if(e){const E=m.getSheetCommandTarget(t,{unitId:s,subUnitId:e});E&&(l=E.worksheet,c=l.getSheetId())}const u=this._renderManagerService.getRenderById(s).with(y.SheetSkeletonManagerService).ensureSkeleton(c);if(!u)return{redos:[],undos:[]};const h=i.getConfig(Ke);let S=o;Array.isArray(o)||(o&&o.startRow!==void 0&&o.startRow!==void 0?S=[o]:S=[]);const g=this._getRangesScope(S);if(((_=h==null?void 0:h.maxAutoHeightCount)!=null?_:1e3)<g)return{redos:[],undos:[]};const p=u.calculateAutoHeightInRange(o),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:o,_selectionManagerService:e}=this;this.disposeWithMe(o.interceptCommand({getMutations:t=>{if(t.id===m.SetRangeValuesCommand.id){const i=t.params;return this.getUndoRedoParamsOfAutoHeight(i.range,i.subUnitId)}return{redos:[],undos:[]}}})),this.disposeWithMe(o.interceptCommand({getMutations:t=>t.id!==m.SetWorksheetRowIsAutoHeightCommand.id?{redos:[],undos:[]}:this.getUndoRedoParamsOfAutoHeight(t.params.ranges,t.params.subUnitId)})),this.disposeWithMe(o.interceptCommand({getMutations:t=>{var r,s;if(t.id!==m.SetStyleCommand.id)return{redos:[],undos:[]};if(!nr.includes((r=t.params)==null?void 0:r.style.type))return{redos:[],undos:[]};const i=(s=e.getCurrentSelections())==null?void 0:s.map(l=>l.range);return i!=null&&i.length?this.getUndoRedoParamsOfAutoHeight(i,t.params.subUnitId):{redos:[],undos:[]}}})),this.disposeWithMe(o.interceptAfterCommand({getMutations:t=>{if(t.id===m.MoveRangeCommand.id){const i=t.params;return this.getUndoRedoParamsOfAutoHeight([i.fromRange,i.toRange])}if(t.id===m.ReorderRangeCommand.id){const i=t.params;return this.getUndoRedoParamsOfAutoHeight([i.range])}return{redos:[],undos:[]}}}))}},y.AutoHeightController=Cd([Fn(0,M.IRenderManagerService),Fn(1,a.Inject(m.SheetInterceptorService)),Fn(2,a.Inject(m.SheetsSelectionsService)),Fn(3,a.Inject(a.IUniverInstanceService)),Fn(4,a.IConfigService)],y.AutoHeightController);function vt(n){const{rows:o,cols:e}=n;return{startRow:o[0],endRow:o[o.length-1],startColumn:e[0],endColumn:e[e.length-1]}}function Ot(n){let o=[],e=[];const t=[];return n.forEach(i=>{o=o.concat(i.rows),e=e.concat(i.cols)}),o=Array.from(new Set(o)).sort((i,r)=>i-r),e=Array.from(new Set(e)).sort((i,r)=>i-r),n.forEach(i=>{t.push({startRow:o.findIndex(r=>r===i.rows[0]),endRow:o.findIndex(r=>r===i.rows[i.rows.length-1]),startColumn:e.findIndex(r=>r===i.cols[0]),endColumn:e.findIndex(r=>r===i.cols[i.cols.length-1])})}),{ranges:t,mapFunc:(i,r)=>({row:o[i],col:e[r]})}}function Id(n){const o=new a.ObjectMatrix;return n.forEach(e=>{const{rows:t,cols:i}=e;t.forEach(r=>{i.forEach(s=>{o.setValue(r,s,{v:null,p:null,f:null,si:null,custom:null})})})}),o.getData()}const ir={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},Xi=["零","一","二","三","四","五","六","七","八","九"],qs=["","万","亿","万亿","亿亿"],_d=["","十","百","千"],Qs={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function rt(n){if(!n)return 0;let o=0,e=0,t=0,i=!1;const r=n.split("");for(let s=0;s<r.length;s++){const l=ir[r[s]];if(typeof l<"u")t=l,s===r.length-1&&(e+=t);else{const c=Qs[r[s]],d=c.value;i=c.secUnit,i?(e=(e+t)*d,o+=e,e=0):e+=t*d,t=0}}return o+e}function bd(n){let o="",e="",t=0,i=!0;for(;n>0;){const r=n%10;r===0?i||(i=!0,e=Xi[r]+e):(i=!1,o=Xi[r],o+=_d[t],e=o+e),t++,n=Math.floor(n/10)}return e}function Ed(n){let o=0,e="",t="",i=!1;if(n===0)return Xi[0];for(;n>0;){const r=n%1e4;i&&(t=Xi[0]+t),e=bd(r),e+=r!==0?qs[o]:qs[0],t=e+t,i=r<1e3&&r>0,n=Math.floor(n/1e4),o++}return t}function wd(n){if(!n)return!1;let o=!0;if(n)if(n.length===1)n==="日"||n in ir?o=!0:o=!1;else{const e=n.split("");for(let t=0;t<e.length;t++)if(!(e[t]in ir||e[t]in Qs)){o=!1;break}}return o}function Yi(n){if(!n)return{isExtendNumber:!1};const o=/0|([1-9]+[0-9]*)/g,e=o.test(n);if(e){const t=n.match(o);if(t&&t.length>0){const i=t[t.length-1],r=n.lastIndexOf(i),s=n.substr(0,r),l=n.substr(r+i.length);return{isExtendNumber:!0,matchTxt:Number(i),beforeTxt:s,afterTxt:l}}return{isExtendNumber:!1}}return{isExtendNumber:e}}function Td(n){let o;return n.length===2&&(n==="周一"||n==="周二"||n==="周三"||n==="周四"||n==="周五"||n==="周六"||n==="周日")?o=!0:o=!1,o}function yd(n){let o;return n.length===3&&(n==="星期一"||n==="星期二"||n==="星期三"||n==="星期四"||n==="星期五"||n==="星期六"||n==="星期日")?o=!0:o=!1,o}function Md(n,o){let e=0;for(let t=0;t<n.length&&n[t]<o;t++)e++;return e}function zn(n){let o=!0;const e=n[1]-n[0];for(let t=1;t<n.length;t++)if(n[t]-n[t-1]!==e){o=!1;break}return o}function Rd(n,o,e){const t=[],i=Math.floor(o/n),r=o%n;let s=0;if(i>0){for(let l=0;l<i;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]<r;l++)t[e[l]+n*i]=s,s++}else for(let l=0;l<e.length&&e[l]<r;l++)t[e[l]]=s,s++;return t}function At(n,o){const e=[];for(let t=1;t<=o;t++){const i=(t-1)%n.length,r=a.Tools.deepClone(n[i]);kt(r),e.push({v:null,s:null,p:null,f:null,si:null,t:null,...r})}return e}function Pd(n,o){var t;const e=[];for(let i=1;i<=o;i++){const r=(i-1)%n.length,s={s:(t=n[r])==null?void 0:t.s};e.push(s)}return e}function Od(n){let o=!0;const e=n[1]/n[0];for(let t=1;t<n.length;t++)if(n[t]/n[t-1]!==e){o=!1;break}return o}function Ad(n){const o=[];for(let e=1;e<=n;e++)o.push(e);return o}function ji(n,o,e){var r,s,l,c;const t=[],i=[];for(let d=0;d<n.length;d++)i.push(Number((r=n[d])==null?void 0:r.v));if(n.length>2&&Od(i))for(let d=1;d<=o;d++){const u=(d-1)%n.length,h=a.Tools.deepClone(n[u]);kt(h);const S=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&&(ta(h)&&(h.v=S),t.push(h))}else{const d=Ad(n.length);for(let u=1;u<=o;u++){const h=(u-1)%n.length,S=a.Tools.deepClone(n[h]);kt(S);const g=e===a.Direction.DOWN||e===a.Direction.RIGHT,f=kd(n.length+u,i,d,g);S&&(ta(S)&&(S.v=f),t.push(S))}}return t}function kd(n,o,e,t=!0){function i(h){let S=0;for(let g=0;g<h.length;g++)S+=h[g];return S/h.length}const r=i(e),s=i(o);let l=0,c=0;for(let h=0;h<e.length;h++)l+=(e[h]-r)*(o[h]-s),c+=(e[h]-r)*(e[h]-r);let d;c===0?d=t?1:-1:d=l/c;const u=s-d*r;return Math.round((u+d*n)*1e5)/1e5}function Js(n,o,e){var r;const t=[],i=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=o;s++){const l=(s-1)%n.length,c=a.Tools.deepClone(n[l]);kt(c);const d=`${(r=n[n.length-1])==null?void 0:r.v}`,u=d==null?void 0:d.match(i),h=u==null?void 0:u[u.length-1],S=Math.abs(Number(h)+e*s);if(!d||!h)continue;const g=d.lastIndexOf(h),f=d.substr(0,g)+S.toString()+d.substr(g+h.length);c&&(c.v=f,t.push(c))}return t}function rn(n,o,e,t=0){var l,c;const i=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(t>=i.length)return[];const r=i[t],s=[];for(let d=1;d<=o;d++){const u=(d-1)%n.length,h=a.Tools.deepClone(n[u]);kt(h);let S=0;if(((l=n[n.length-1])==null?void 0:l.v)===r[0])S=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);S=rt(p)+e*d}}S<0&&(S=Math.ceil(Math.abs(S)/7)*7+S);const g=S%7;h&&(h.v=r[g],s.push(h))}return s}function $s(n,o,e){var i;const t=[];for(let r=1;r<=o;r++){const s=(r-1)%n.length,l=a.Tools.deepClone(n[s]);kt(l);const c=`${(i=n[n.length-1])==null?void 0:i.v}`,d=rt(c)+e*r;let u;d<=0?u="零":u=Ed(d),l&&(l.v=u,t.push(l))}return t}const Xn={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 Dd(n){let o=!1;return Object.keys(Xn).forEach(e=>{Xn[e].includes(n)&&(o=!0)}),o}function or(n){let o="";const e=[];return Object.keys(Xn).forEach(t=>{Xn[t].includes(n)&&(o=t,e.push(...Xn[t]))}),{name:o,series:e}}function ea(n,o,e,t){var s;const i=t.length,r=[];for(let l=1;l<=o;l++){const c=(l-1)%n.length,d=a.Tools.deepClone(n[c]);kt(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)*i);const S=h%i;d&&(d.v=t[S],r.push(d))}return r}function Nd(n,o){const e=[];let t;if(o.startRow<n.startRow)t=a.Direction.UP;else if(o.endRow>n.endRow)t=a.Direction.DOWN;else if(o.startColumn<n.startColumn)t=a.Direction.LEFT;else if(o.endColumn>n.endColumn)t=a.Direction.RIGHT;else return[];if(t===a.Direction.DOWN||t===a.Direction.UP){const i=n.endRow-n.startRow+1,r=o.endRow-o.startRow+1,s=Math.floor(r/i),l=r%i,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)*i,col:n.startColumn},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow+(s+1)*i,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)*i,col:n.startColumn},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow-(s+1)*i,col:n.startColumn},relativeRange:{startRow:i-l,endRow:i-1,startColumn:0,endColumn:n.endColumn-n.startColumn}})}}if(t===a.Direction.RIGHT||t===a.Direction.LEFT){const i=n.endColumn-n.startColumn+1,r=o.endColumn-o.startColumn+1,s=Math.floor(r/i),l=r%i,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)*i},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow,col:n.startColumn+(s+1)*i},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)*i},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow,col:n.startColumn-(s+1)*i},relativeRange:{startRow:0,startColumn:i-l,endRow:n.endRow-n.startRow,endColumn:i-1}})}}return e}function ta(n){return!(a.isFormulaString(n.f)||a.isFormulaId(n.si)||n.t===a.CellValueType.BOOLEAN)}function kt(n){n&&"custom"in n&&delete n.custom}var sn=(n=>(n.Append="APPEND",n.Default="DEFAULT",n.Only="ONLY",n))(sn||{}),_e=(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))(_e||{}),de=(n=>(n.COPY="COPY",n.SERIES="SERIES",n.ONLY_FORMAT="ONLY_FORMAT",n.NO_FORMAT="NO_FORMAT",n))(de||{});const Hd={type:_e.DATE,priority:1100,match:(n,o)=>{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 i=o.get(a.IUniverInstanceService).getFocusedUnit().getStyles().get(n.s),r=(e=i==null?void 0:i.n)==null?void 0:e.pattern;if(r)return a.numfmt.getInfo(r).isDate}else if(n.s.n&&a.numfmt.getInfo(n.s.n.pattern).isDate)return!0}return!1},isContinue:(n,o)=>n.type===_e.DATE,applyFunctions:{[de.SERIES]:(n,o,e)=>{const{data:t}=n;return e===a.Direction.LEFT||e===a.Direction.UP?(t.reverse(),ji(t,o,e).reverse()):ji(t,o,e)}}},Vd={type:_e.NUMBER,priority:1e3,match:n=>typeof(n==null?void 0:n.v)=="number"||(n==null?void 0:n.t)===a.CellValueType.NUMBER,isContinue:(n,o)=>n.type===_e.NUMBER,applyFunctions:{[de.SERIES]:(n,o,e)=>{const{data:t}=n;return e===a.Direction.LEFT||e===a.Direction.UP?(t.reverse(),ji(t,o,e).reverse()):ji(t,o,e)}}},na={type:_e.OTHER,priority:0,match:()=>!0,isContinue:(n,o)=>n.type===_e.OTHER},Wd={type:_e.EXTEND_NUMBER,priority:900,match:n=>Yi(`${n==null?void 0:n.v}`||"").isExtendNumber,isContinue:(n,o)=>{var e;if(n.type===_e.EXTEND_NUMBER){const{beforeTxt:t,afterTxt:i}=Yi(`${(e=n.cellData)==null?void 0:e.v}`||""),{beforeTxt:r,afterTxt:s}=Yi(`${o==null?void 0:o.v}`||"");if(t===r&&i===s)return!0}return!1},applyFunctions:{[de.SERIES]:(n,o,e)=>{var l;const{data:t}=n,i=e===a.Direction.UP||e===a.Direction.LEFT;let r;if(t.length===1)return r=i?-1:1,We(Js(t,o,r),i);const s=[];for(let c=0;c<t.length;c++){const d=`${(l=t[c])==null?void 0:l.v}`;d&&s.push(Number(Yi(d).matchTxt))}return i&&(t.reverse(),s.reverse()),zn(s)?(r=s[1]-s[0],We(Js(t,o,r),i)):At(t,o)}}},Ld={type:_e.CHN_NUMBER,priority:830,match:n=>!!wd(`${n==null?void 0:n.v}`||""),isContinue:(n,o)=>n.type===_e.CHN_NUMBER,applyFunctions:{[de.SERIES]:(n,o,e)=>{var c,d,u;const{data:t}=n,i=e===a.Direction.LEFT||e===a.Direction.UP;if(t.length===1){const h=`${(c=t[0])==null?void 0:c.v}`;let S;return i?S=-1:S=1,h&&(h==="日"||rt(h)<7)?We(rn(t,o,S),i):We($s(t,o,S),i)}let r=!1;for(let h=0;h<t.length;h++)if(((d=t[h])==null?void 0:d.v)==="日"){r=!0;break}const s=[];let l=0;for(let h=0;h<t.length;h++){const S=`${(u=t[h])==null?void 0:u.v}`;S==="日"?h===0?s.push(0):(l++,s.push(l*7)):r&&rt(S)>0&&rt(S)<7?s.push(rt(S)+l*7):s.push(rt(S))}if(i&&(t.reverse(),s.reverse()),zn(s)){if(r||s[s.length-1]<6&&s[0]>0||s[0]<6&&s[s.length-1]>0){const S=s[1]-s[0];return We(rn(t,o,S),i)}const h=s[1]-s[0];return We($s(t,o,h),i)}return At(t,o)}}},Ud={type:_e.CHN_WEEK2,priority:820,match:n=>!!Td(`${n==null?void 0:n.v}`||""),isContinue:(n,o)=>n.type===_e.CHN_WEEK2,applyFunctions:{[de.SERIES]:(n,o,e)=>{var l;const{data:t}=n,i=e===a.Direction.LEFT||e===a.Direction.UP;if(t.length===1){let c;return i?c=-1:c=1,We(rn(t,o,c,1),i)}const r=[];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?r.push(0):(s++,r.push(s*7)):r.push(rt(u)+s*7)}if(i&&(t.reverse(),r.reverse()),zn(r)){const c=r[1]-r[0];return We(rn(t,o,c,1),i)}return At(t,o)}}},Bd={type:_e.CHN_WEEK3,priority:810,match:n=>yd(`${n==null?void 0:n.v}`||""),isContinue:(n,o)=>n.type===_e.CHN_WEEK3,applyFunctions:{[de.SERIES]:(n,o,e)=>{var l;const{data:t}=n,i=e===a.Direction.LEFT||e===a.Direction.UP;if(t.length===1){let c;return i?c=-1:c=1,We(rn(t,o,c,2),i)}const r=[];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?r.push(0):(s++,r.push(s*7)):r.push(rt(u)+s*7)}}if(i&&(t.reverse(),r.reverse()),zn(r)){const c=r[1]-r[0];return We(rn(t,o,c,2),i)}return At(t,o)}}},xd={type:_e.LOOP_SERIES,priority:800,match:n=>Dd(`${n==null?void 0:n.v}`||""),isContinue:(n,o)=>{var e;return n.type===_e.LOOP_SERIES?or(`${(e=n.cellData)==null?void 0:e.v}`||"").name===or(`${o==null?void 0:o.v}`||"").name:!1},applyFunctions:{[de.SERIES]:(n,o,e)=>{var c,d;const{data:t}=n,i=e===a.Direction.LEFT||e===a.Direction.UP,{series:r}=or(`${(c=t[0])==null?void 0:c.v}`||"");if(t.length===1){let u;return i?u=-1:u=1,We(ea(t,o,u,r),i)}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===r[0]?u===0?s.push(0):(l++,s.push(l*r.length)):s.push(r.indexOf(h)+l*7))}if(i&&(t.reverse(),s.reverse()),zn(s)){const u=s[1]-s[0];return We(ea(t,o,u,r),i)}return At(t,o)}}};function We(n,o){return o?n.reverse():n}var Fd=Object.getOwnPropertyDescriptor,zd=(n,o,e,t)=>{for(var i=t>1?void 0:t?Fd(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},an=(n,o)=>(e,t)=>o(e,t,n);y.AutoFillService=class extends a.Disposable{constructor(e,t,i,r,s,l){super();w(this,"_rules",[]);w(this,"_hooks",[]);w(this,"_applyType$",new k.BehaviorSubject(de.SERIES));w(this,"_isFillingStyle",!0);w(this,"_prevUndos",[]);w(this,"_autoFillLocation$",new k.BehaviorSubject(null));w(this,"autoFillLocation$",this._autoFillLocation$.asObservable());w(this,"_showMenu$",new k.BehaviorSubject(!1));w(this,"showMenu$",this._showMenu$.asObservable());w(this,"_direction",a.Direction.DOWN);w(this,"applyType$",this._applyType$.asObservable());w(this,"_menu$",new k.BehaviorSubject([{label:"autoFill.copy",value:de.COPY,disable:!1},{label:"autoFill.series",value:de.SERIES,disable:!1},{label:"autoFill.formatOnly",value:de.ONLY_FORMAT,disable:!1},{label:"autoFill.noFormat",value:de.NO_FORMAT,disable:!1}]));w(this,"menu$",this._menu$.asObservable());this._commandService=e,this._undoRedoService=t,this._renderManagerService=i,this._univerInstanceService=r,this._selectionManagerService=s,this._injector=l,this._init()}_init(){this._rules=[Hd,Vd,Wd,Ld,Ud,Bd,xd,na].sort((e,t)=>t.priority-e.priority),this._isFillingStyle=!0}_getOneByPriority(e){return e.length<=0?[]:[e.reduce((i,r)=>(r.priority||0)>(i.priority||0)?r:i,e[0])]}_initPrevUndo(){this._prevUndos=[]}async triggerAutoFill(e,t,i,r){var g;if(i.startColumn===r.startColumn&&i.startRow===r.startRow&&i.endColumn===r.endColumn&&i.endRow===r.endRow)return!1;if(r.endColumn<i.endColumn&&r.endColumn>i.startColumn)return this._commandService.executeCommand(ln.id,{clearRange:{startRow:r.startRow,endRow:r.endRow,startColumn:r.endColumn+1,endColumn:i.endColumn},selectionRange:r});if(r.endRow<i.endRow&&r.endRow>i.startRow)return this._commandService.executeCommand(ln.id,{clearRange:{startRow:r.endRow+1,endRow:i.endRow,startColumn:r.startColumn,endColumn:r.endColumn},selectionRange:r});const s={startRow:r.startRow,endRow:r.endRow,startColumn:r.startColumn,endColumn:r.endColumn};let l=null;if(r.startRow<i.startRow)l=a.Direction.UP,s.endRow=i.startRow-1;else if(r.endRow>i.endRow)l=a.Direction.DOWN,s.startRow=i.endRow+1;else if(r.startColumn<i.startColumn)l=a.Direction.LEFT,s.endColumn=i.startColumn-1;else if(r.endColumn>i.endColumn)l=a.Direction.RIGHT,s.startColumn=i.endColumn+1;else return!1;this.direction=l;const c=this._injector.invoke(f=>m.rangeToDiscreteRange(i,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 S=(g=this.menu.find(f=>f.disable===!1))==null?void 0:g.value;return S?this.fillData(S):!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=sn.Append),this._hooks.push(e),a.toDisposable(()=>{const t=this._hooks.findIndex(i=>i===e);t>-1&&this._hooks.splice(t,1)})}registerRule(e){if(this._rules.find(i=>i.type===e.type))throw new Error(`Registry rule failed, type '${e.type}' already exist!`);const t=this._rules.findIndex(i=>i.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:i,subUnitId:r}=this.autoFillLocation||{};if(!e||!t||!i||!r)return[];const s=this._hooks.filter(u=>{var h;return!((h=u.disable)!=null&&h.call(u,{source:e,target:t,unitId:i,subUnitId:r},this._direction,this.applyType))}),l=s.filter(u=>u.type===sn.Only);if(l.length>0)return this._getOneByPriority(l);const c=this._getOneByPriority(s.filter(u=>u.type===sn.Default)),d=s.filter(u=>u.type===sn.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(i=>i.value===e?{...i,disable:t}:i))}setShowMenu(e){this._showMenu$.next(e)}fillData(e){var C,_,E;this.applyType=e;const{source:t,target:i,unitId:r=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||!i||!r||!s)return!1;const l=this.direction;this._prevUndos.length>0&&this._prevUndos.forEach(T=>{this._commandService.syncExecuteCommand(T.id,T.params)}),this._prevUndos=[];const c=a.Rectangle.union(vt(t),vt(i)),d=this.getActiveHooks(),u=this._univerInstanceService.getUnit(r,a.UniverInstanceType.UNIVER_SHEET);this._commandService.syncExecuteCommand(m.SetSelectionsOperation.id,{selections:[{primary:{...(E=(_=this._selectionManagerService.getCurrentLastSelection())==null?void 0:_.primary)!=null?E:c},range:{...c,rangeType:a.RANGE_TYPE.NORMAL}}],unitId:r,subUnitId:s});const h=[],S=[];d.forEach(T=>{var O;const{undos:P,redos:R}=((O=T.onFillData)==null?void 0:O.call(T,{source:t,target:i,unitId:r,subUnitId:s},l,e))||{};P&&h.push(...P),R&&S.push(...R)});const g=S.every(T=>this._commandService.syncExecuteCommand(T.id,T.params)),f=[];e!==de.NO_FORMAT&&S.forEach(T=>{if(T.id===m.SetRangeValuesMutation.id){const{cellValue:P}=T.params;new a.ObjectMatrix(P).forValue((O,A,N)=>{const D=Object.keys(u.getStyles().get(N==null?void 0:N.s)||{});(N!=null&&N.p||D.length&&nr.some(H=>D.includes(H)))&&f.push({startRow:O,endRow:O,startColumn:A,endColumn:A})})}});const p=this._getAutoHeightUndoRedos(r,s,f);return p.redos.every(T=>this._commandService.syncExecuteCommand(T.id,T.params))&&(h.push(...p.undos),S.push(...p.redos)),g&&(this._prevUndos=h,this._undoRedoService.pushUndoRedo({unitID:r,undoMutations:h,redoMutations:S})),d.forEach(T=>{var P;(P=T.onAfterFillData)==null||P.call(T,{source:t,target:i,unitId:r,subUnitId:s},l,e)}),this.setShowMenu(!0),!0}_getAutoHeightUndoRedos(e,t,i){var h,S;const r=(h=this._renderManagerService.getRenderById(e))==null?void 0:h.with(y.SheetSkeletonManagerService),s=(S=r==null?void 0:r.getCurrentParam())==null?void 0:S.skeleton;if(!s)return{redos:[],undos:[]};const l=s.calculateAutoHeightInRange(i),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}]}}},y.AutoFillService=zd([an(0,a.ICommandService),an(1,a.IUndoRedoService),an(2,M.IRenderManagerService),an(3,a.Inject(a.IUniverInstanceService)),an(4,a.Inject(m.SheetsSelectionsService)),an(5,a.Inject(a.Injector))],y.AutoFillService);const Ct=a.createIdentifier("univer.auto-fill-service"),It={type:a.CommandType.COMMAND,id:"sheet.command.auto-fill",handler:async(n,o)=>{const e=n.get(Ct),t=n.get(a.IUniverInstanceService),{sourceRange:i,targetRange:r}=o,s=m.getSheetCommandTarget(t);if(!s)return!1;const{subUnitId:l,unitId:c}=s;return e.triggerAutoFill(c,l,i,r)}},ln={id:"sheet.command.auto-clear-content",type:a.CommandType.COMMAND,handler:async(n,o)=>{const e=n.get(a.IUniverInstanceService),t=n.get(a.ICommandService),i=n.get(a.IUndoRedoService),r=n.get(m.SheetInterceptorService),s=m.getSheetCommandTarget(e);if(!s)return!1;const{unitId:l,subUnitId:c}=s,{clearRange:d,selectionRange:u}=o,h={subUnitId:c,unitId:l,cellValue:m.generateNullCellValue([d])},S=m.SetRangeValuesUndoMutationFactory(n,h),{startColumn:g,startRow:f}=u,p={selections:[{primary:{startColumn:g,startRow:f,endColumn:g,endRow:f,actualRow:f,actualColumn:g,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=r.afterCommandExecute({id:m.SetRangeValuesMutation.id,params:h});return a.sequenceExecute(C.redos,t),i.pushUndoRedo({unitID:l,undoMutations:[{id:m.SetRangeValuesMutation.id,params:S},...C.undos],redoMutations:[{id:m.SetRangeValuesMutation.id,params:h},...C.redos]}),!0}return!1}},Yn={id:"sheet.command.refill",type:a.CommandType.COMMAND,handler:async(n,o)=>n.get(Ct).fillData(o.type)};var Xd=Object.getOwnPropertyDescriptor,Yd=(n,o,e,t)=>{for(var i=t>1?void 0:t?Xd(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},Dt=(n,o)=>(e,t)=>o(e,t,n);y.EditorBridgeService=class extends a.Disposable{constructor(e,t,i,r,s,l,c){super();w(this,"_editorUnitId",a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);w(this,"_editorIsDirty",!1);w(this,"_isDisabled",!1);w(this,"_visible",{visible:!1,eventType:M.DeviceInputEventType.Dblclick,unitId:""});w(this,"_currentEditCell",null);w(this,"_currentEditCellState",null);w(this,"_currentEditCellLayout",null);w(this,"_currentEditCellState$",new k.BehaviorSubject(null));w(this,"currentEditCellState$",this._currentEditCellState$.asObservable());w(this,"_currentEditCellLayout$",new k.BehaviorSubject(null));w(this,"currentEditCellLayout$",this._currentEditCellLayout$.asObservable());w(this,"currentEditCell$",this._currentEditCellState$.pipe(k.switchMap(e=>this._currentEditCellLayout$.pipe(k.map(t=>e&&t?{...e,...t}:null)))));w(this,"_visible$",new k.BehaviorSubject(this._visible));w(this,"visible$",this._visible$.asObservable());w(this,"_afterVisible$",new k.BehaviorSubject(this._visible));w(this,"afterVisible$",this._afterVisible$.asObservable());w(this,"_forceKeepVisible$",new k.BehaviorSubject(!1));w(this,"forceKeepVisible$",this._forceKeepVisible$.asObservable());this._sheetInterceptorService=e,this._renderManagerService=t,this._themeService=i,this._univerInstanceService=r,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:i,scaleY:r,canvasOffset:s,...l}=e;this._currentEditCellState=l,this._currentEditCellLayout={position:t,scaleX:i,scaleY:r,canvasOffset:s},this._currentEditCellState$.next(this._currentEditCellState),this._currentEditCellLayout$.next(this._currentEditCellLayout)}refreshEditCellPosition(e){var O;const t=this._currentEditCell;if(t==null)return;const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!i)return;const r=this._renderManagerService.getRenderUnitById(i.getUnitId());if(!r)return;const s=(O=r.with(y.SheetSkeletonManagerService).getSkeletonParam(t.sheetId))==null?void 0:O.skeleton,l=r.with(ve);if(!s||!this._currentEditCellState)return;const{primary:c,unitId:d,sheetId:u,scene:h,engine:S}=t,g=Bn(s,c);if(g==null)return;const f=a.convertCellToRange(g),p=Q.getCanvasOffsetByEngine(S);let{startX:v,startY:C,endX:_,endY:E}=f;const{scaleX:T,scaleY:P}=h.getAncestorScale(),R=h.getViewportScrollXY(l.getViewPort());v=M.convertTransformToOffsetX(v,T,R),C=M.convertTransformToOffsetY(C,P,R),_=M.convertTransformToOffsetX(_,T,R),E=M.convertTransformToOffsetY(E,P,R),e&&this._currentEditCellLayout&&(_=_-v+this._currentEditCellLayout.position.startX,E=E-C+this._currentEditCellLayout.position.startY,v=this._currentEditCellLayout.position.startX,C=this._currentEditCellLayout.position.startY),this._currentEditCellLayout={position:{startX:v,startY:C,endX:_,endY:E},canvasOffset:p,scaleX:T,scaleY:P},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:i,canvasOffset:r,scaleX:s,scaleY:l,...c}=t;this._currentEditCellState=c,this._currentEditCellLayout={position:i,canvasOffset:r,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 U,V,B;const e=this._currentEditCell;if(e==null)return;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const i=this._renderManagerService.getRenderUnitById(t.getUnitId());if(!i)return;const r=i.with(y.SheetSkeletonManagerService).getCurrentSkeleton(),s=i.with(ve);if(!r)return;const{primary:l,unitId:c,sheetId:d,scene:u,engine:h}=e,{startRow:S,startColumn:g}=l,f=Bn(r,l);if(f==null)return;const p=a.convertCellToRange(f),v=Q.getCanvasOffsetByEngine(h);let{startX:C,startY:_,endX:E,endY:T}=p;const{scaleX:P,scaleY:R}=u.getAncestorScale(),O=u.getViewportScrollXY(s.getViewPort());C=M.convertTransformToOffsetX(C,P,O),_=M.convertTransformToOffsetY(_,R,O),E=M.convertTransformToOffsetX(E,P,O),T=M.convertTransformToOffsetY(T,R,O);const A=t.getActiveSheet();if(!A)return;const N={workbook:t,worksheet:A,unitId:t.getUnitId(),subUnitId:A.getSheetId(),row:S,col:g,origin:A.getCellRaw(S,g)};let D;const H=this._sheetInterceptorService.writeCellInterceptor.fetchThroughInterceptors(m.BEFORE_CELL_EDIT)(A.getCell(S,g),N);D=H&&r.getCellDocumentModelWithFormula(H);const W=(U=D==null?void 0:D.documentModel)==null?void 0:U.documentStyle.renderConfig;if(W!=null&&(W.cellValueType=a.CellValueType.STRING),!D||D.documentModel==null){const x=r.getBlankCellDocumentModel(H);if(D!=null){const{verticalAlign:z,horizontalAlign:F,wrapStrategy:Y,textRotation:X,fill:Z}=D,{centerAngle:ne,vertexAngle:J}=M.convertTextRotation(X);x.documentModel.documentStyle.renderConfig={...W,verticalAlign:z,horizontalAlign:F,wrapStrategy:Y,background:{rgb:Z},centerAngle:ne,vertexAngle:J}}D=x}if(D.fill=D.fill||"#fff",(V=D.documentModel)==null||V.setZoomRatio(Math.max(P,R)),(H==null?void 0:H.isInArrayFormulaRange)===!0){const x=(B=D.documentModel)==null?void 0:B.getBody();x&&(x.textRuns=[{st:0,ed:x.dataStream.length-2,ts:{cl:{rgb:this._themeService.getCurrentTheme().textColorSecondary}}}])}return{position:{startX:C,startY:_,endX:E,endY:T},scaleX:P,scaleY:R,canvasOffset:v,row:S,column:g,unitId:c,sheetId:d,documentLayoutObject:D,editorUnitId:this._editorUnitId,isInArrayFormulaRange:H==null?void 0:H.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}},y.EditorBridgeService=Yd([Dt(0,a.Inject(m.SheetInterceptorService)),Dt(1,M.IRenderManagerService),Dt(2,a.Inject(a.ThemeService)),Dt(3,a.IUniverInstanceService),Dt(4,Q.IEditorService),Dt(5,m.IRefSelectionsService),Dt(6,a.IContextService)],y.EditorBridgeService);const ge=a.createIdentifier("univer.sheet-editor-bridge.service"),Ce={id:"sheet.operation.set-cell-edit-visible",type:a.CommandType.OPERATION,handler:(n,o)=>{if(!o)return!1;const{unitId:e}=o,i=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return i?(n.get(ge).changeVisible({...o,unitId:e!=null?e:i.getUnitId()}),!0):!1}},jn={id:"sheet.operation.set-cell-edit-visible-f2",type:a.CommandType.OPERATION,handler:(n,o)=>{const e=n.get(a.ICommandService),i=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return i?(e.syncExecuteCommand(Ce.id,{...o,unitId:i.getUnitId()}),!0):!1}},Nt={id:"sheet.operation.set-cell-edit-visible-arrow",type:a.CommandType.OPERATION,handler:()=>!0},cn={id:"sheet.command.change-zoom-ratio",type:a.CommandType.COMMAND,handler:(n,o)=>{if(!o)return!1;const e=n.get(a.IUniverInstanceService),t=m.getSheetCommandTarget(e);if(!t)return!1;const{worksheet:i,subUnitId:r,unitId:s}=t,{delta:l,reset:c}=o;let d=c?100:Math.round((i.getConfig().zoomRatio+l)*100);d=Math.max(jo[0],d),d=Math.min(jo[1],d);const u=d/100,S=n.get(ge).isVisible();return(S.unitId===s||S.unitId===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)&&S.visible?!1:n.get(a.ICommandService).executeCommand(Le.id,{unitId:s,subUnitId:r,zoomRatio:u})}},dn={id:"sheet.command.set-zoom-ratio",type:a.CommandType.COMMAND,handler:(n,o)=>{if(!o)return!1;const{unitId:e,subUnitId:t,zoomRatio:i}=o,s=n.get(ge).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:i})}};function jd(n){return typeof n.isMainScene>"u"}function ze(n,o){const e=n instanceof a.Workbook?n:n.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return null;const t=e.getUnitId();let i,r,s,l;if(jd(o)){const S=o.getRenderById(t);if(S==null)return null;i=S.components,i=S.components,r=S.mainComponent,s=S.scene,l=S.engine}else i=o.components,r=o.mainComponent,s=o.scene,l=o.engine;if(!i||!r)return null;const c=r,d=i.get(he.ROW),u=i.get(he.COLUMN),h=i.get(he.LEFT_TOP);return{spreadsheet:c,spreadsheetRowHeader:d,spreadsheetColumnHeader:u,spreadsheetLeftTopPlaceholder:h,scene:s,engine:l}}function rr(n,o,e,t){const{startX:i,startY:r,endX:s,endY:l}=t.getCellWithCoordByIndex(n,o);return{startX:i,startY:r,endX:s,endY:l}}function qe(n,o,e,t,i,r){const s=e.getCoordRelativeToViewport(M.Vector2.FromArray([n,o])),{x:l,y:c}=s,d=e.getScrollXYInfoByViewport(s,i),{scaleX:u,scaleY:h}=e.getAncestorScale(),S=t.getCellIndexByOffset(l,c,u,h,d,{closeFirst:r}),{row:g,column:f}=S,p=t.getNoMergeCellWithCoordByIndex(g,f),{startX:v,startY:C,endX:_,endY:E}=p;return{startX:v,startY:C,endX:_,endY:E,row:g,column:f}}function Gn(n,o,e,t){const i=e.getCoordRelativeToViewport(M.Vector2.FromArray([n,o])),r=e.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN),s=e.getScrollXYInfoByViewport(i,r),{scaleX:l,scaleY:c}=e.getAncestorScale(),{x:d,y:u}=s,h=n/l+d,S=o/c+u;return{x:h,y:S}}var Gd=Object.getOwnPropertyDescriptor,Zd=(n,o,e,t)=>{for(var i=t>1?void 0:t?Gd(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},Gi=(n,o)=>(e,t)=>o(e,t,n);let Zn=class extends a.Disposable{constructor(o,e,t,i,r){super();w(this,"_zoom");this._context=o,this._sheetSkeletonManagerService=e,this._commandService=t,this._contextService=i,this._editorBridgeService=r,this._initSkeletonListener(),this._initZoomEventListener()}updateZoom(o,e){const t=this._context.unit.getSheetBySheetId(o);return t?(t.getConfig().zoomRatio=e,t===this._context.unit.getActiveSheet()&&this._updateViewZoom(e),!0):!1}_initZoomEventListener(){const o=this._getSheetObject().scene;this.disposeWithMe(o.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 i=t<40?.2:t<80?.4:.2;i*=e.deltaY>0?-1:1,o.scaleX<1&&(i/=2);const r=this._context.unit,s=r.getActiveSheet();if(!s)return;const l=s.getZoomRatio();let c=+Number.parseFloat(`${l+i}`).toFixed(1);c=c>=4?4:c<=.1?.1:c,this._commandService.executeCommand(dn.id,{zoomRatio:Math.round(c*10)/10,unitId:r.getUnitId(),subUnitId:s.getSheetId()}),e.preventDefault()}))}_initSkeletonListener(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(o=>{if(o==null)return;const t=this._context.unit.getActiveSheet();if(!t)return;const i=t.getZoomRatio()||1;this._zoom!==i&&this._updateViewZoom(i),this._zoom=i}))}_updateViewZoom(o){const e=this._getSheetObject();e==null||e.scene.scale(o,o),e==null||e.spreadsheet.makeForceDirty()}_getSheetObject(){return ze(this._context.unit,this._context)}};Zn=Zd([Gi(1,a.Inject(y.SheetSkeletonManagerService)),Gi(2,a.ICommandService),Gi(3,a.IContextService),Gi(4,a.Optional(ge))],Zn);const Le={id:"sheet.operation.set-zoom-ratio",type:a.CommandType.OPERATION,handler:(n,o)=>{const t=n.get(M.IRenderManagerService).getRenderById(o.unitId);return t?t.with(Zn).updateZoom(o.subUnitId,o.zoomRatio):!1}};var Kd=Object.getOwnPropertyDescriptor,qd=(n,o,e,t)=>{for(var i=t>1?void 0:t?Kd(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},sr=(n,o)=>(e,t)=>o(e,t,n);const ia="univer-sheet-main-canvas";y.SheetsRenderService=class extends a.RxDisposable{constructor(e,t,i){super();w(this,"_skeletonChangeMutations",new Set);this._contextService=e,this._instanceSrv=t,this._renderManagerService=i,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(k.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(k.takeUntil(this.dispose$)).subscribe(e=>this._disposeRenderer(e))}_createRenderer(e){const t=e.getUnitId();this._renderManagerService.created$.subscribe(i=>{i.unitId===t&&(i.engine.getCanvas().setId(`${ia}_${t}`),i.engine.getCanvas().getContext().setId(`${ia}_${t}`))}),this._renderManagerService.createRender(t)}_disposeRenderer(e){const t=e.getUnitId();this._renderManagerService.removeRender(t)}_initContextListener(){this.disposeWithMe(this._contextService.subscribeContextValue$(M.RENDER_RAW_FORMULA_KEY).pipe(k.distinctUntilChanged()).subscribe(()=>{this._renderManagerService.getRenderAll().forEach(e=>{e.mainComponent instanceof M.Spreadsheet&&e.mainComponent.makeForceDirty(!0)})}))}},y.SheetsRenderService=qd([sr(0,a.IContextService),sr(1,a.IUniverInstanceService),sr(2,M.IRenderManagerService)],y.SheetsRenderService);var Qd=Object.getOwnPropertyDescriptor,Jd=(n,o,e,t)=>{for(var i=t>1?void 0:t?Qd(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},Ht=(n,o)=>(e,t)=>o(e,t,n);y.AutoFillController=class extends a.Disposable{constructor(e,t,i,r,s,l,c){super();w(this,"_beforeApplyData",[]);w(this,"_currentLocation",null);w(this,"_copyData",[]);w(this,"_defaultHook");this._univerInstanceService=e,this._commandService=t,this._autoFillService=i,this._editorBridgeService=r,this._renderManagerService=s,this._injector=l,this._sheetsRenderService=c,this._defaultHook={id:"default",type:sn.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(It.id))}_initDefaultHook(){this.disposeWithMe(this._autoFillService.addHook(this._defaultHook))}_initQuitListener(){const e=[Ce.id,ln.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,i)=>{var c,d;const r=i==null?void 0:i.fromCollab,s=i==null?void 0:i.fromSync,l=i==null?void 0:i.fromFormula;e.includes(t.id)&&!r&&!s&&!l&&t.params.trigger!==It.id&&t.params.trigger!==Yn.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 i;t.getUnitId()===((i=this._currentLocation)==null?void 0:i.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 i=M.getCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService);if(!i)return;i.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(It.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:M.DeviceInputEventType.PointerDown,unitId:i.unitId})}))})};t(),this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.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(It.id,{sourceRange:e,targetRange:t})}_detectFillRange(e){var S,g,f,p,v,C;const{startRow:t,endRow:i,startColumn:r,endColumn:s}=e,l=(S=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getActiveSheet();if(!l)return e;const c=l.getCellMatrix(),d=l.getMaxRows()-1,u=l.getMaxColumns()-1;let h=i;if(r>0&&((g=c.getValue(t,r-1))==null?void 0:g.v)!=null){let _=t;for(;((f=c.getValue(_,r-1))==null?void 0:f.v)!=null&&_<d;)_+=1;h=_-1}else if(s<u&&((p=c.getValue(i,s+1))==null?void 0:p.v)!=null){let _=t;for(;((v=c.getValue(_,s+1))==null?void 0:v.v)!=null&&_<d;)_+=1;h=_-1}for(let _=i+1;_<=h;_++)for(let E=r;E<=s;E++)if(((C=c.getValue(_,E))==null?void 0:C.v)!=null){h=_-1;break}return{startColumn:r,endColumn:s,startRow:t,endRow:h}}_getApplyData(e,t,i,r,s,l=!0,c){const d=[],u=Math.floor(i/t),h=i%t,S=this._autoFillService.getRules();if(!l&&s===de.ONLY_FORMAT)return console.error("ERROR: only format can not be applied when hasStyle is false"),[];const g={};S.forEach(f=>{g[f.type]=[]}),S.forEach(f=>{const{type:p,applyFunctions:v={}}=f,C=e[p];C&&C.forEach(_=>{const E=Md(_.index,h),T=_.index.length*u+E,P=this._applyFunctions(_,T,r,s,v,e,c),R=Rd(t,i,_.index);g[p].push({data:P,index:R})})});for(let f=0;f<i;f++)S.forEach(p=>{const{type:v}=p,C=g[v];for(let _=0;_<C.length;_++)f in C[_].index&&d.push(C[_].data[C[_].index[f]])});return d}_applyFunctions(e,t,i,r,s,l,c){const{data:d}=e,u=i===a.Direction.UP||i===a.Direction.LEFT;if(r===de.COPY){const h=s==null?void 0:s[de.COPY];return h?h(e,t,i,l,c):(u&&d.reverse(),At(d,t))}if(r===de.SERIES){const h=s==null?void 0:s[de.SERIES];return h?h(e,t,i,l):(u&&d.reverse(),s!=null&&s[de.COPY]?s[de.COPY](e,t,i,l,c):At(d,t))}if(r===de.ONLY_FORMAT){const h=s==null?void 0:s[de.ONLY_FORMAT];return h?h(e,t,i,l):Pd(d,t)}}_getCopyData(e,t){const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!i)throw new Error("No active sheet found");const r=i.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 S=this._getEmptyCopyDataPiece(),g={type:void 0,cellData:void 0};u.forEach(f=>{let p;c?p=r.getValue(f,h):p=r.getValue(h,f);const{type:v,isContinue:C}=s.find(_=>_.match(p,this._injector))||na;if(C(g,p)){const _=S[v],E=_[_.length-1];E.data.push(p),E.index.push(f-u[0])}else{const _=S[v];_?_.push({data:[p],index:[f-u[0]]}):S[v]=[{data:[p],index:[f-u[0]]}]}g.type=v,g.cellData=p}),l.push(S)}),l}_getEmptyCopyDataPiece(){const e={};return this._autoFillService.getRules().forEach(t=>{e[t.type]=[]}),e}_getMergeApplyData(e,t,i,r){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:S,endRow:g,endColumn:f}=s.getCellInfoInMergeData(c,d);if(u){if(i===a.Direction.DOWN){let p=h+r,v=g+r;for(;v<=t.endRow;)l.push({startRow:p,startColumn:S,endRow:v,endColumn:f}),p+=r,v+=r}else if(i===a.Direction.UP){let p=h-r,v=g-r;for(;p>=t.startRow;)l.push({startRow:p,startColumn:S,endRow:v,endColumn:f}),p-=r,v-=r}else if(i===a.Direction.RIGHT){let p=S+r,v=f+r;for(;v<=t.endColumn;)l.push({startRow:h,startColumn:p,endRow:g,endColumn:v}),p+=r,v+=r}else if(i===a.Direction.LEFT){let p=S-r,v=f-r;for(;p>=t.startColumn;)l.push({startRow:h,startColumn:p,endRow:g,endColumn:v}),p-=r,v-=r}}}return l}_presetAndCacheData(e,t){const{source:i,target:r}=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 r.rows.forEach(d=>{const u=[];r.cols.forEach(h=>{u.push(a.Tools.deepClone(l.getValue(d,h)))}),c.push(u)}),this._beforeApplyData=c,this._copyData=this._getCopyData(i,t),this._currentLocation=e,this._shouldDisableSeries(this._copyData)?(this._autoFillService.setDisableApplyType(de.SERIES,!0),de.COPY):(this._autoFillService.setDisableApplyType(de.SERIES,!1),this._getPreferredApplyType(this._copyData))}_fillData(e,t,i){var U,V;const r=[],s=[];let l=!0;i===de.NO_FORMAT&&(l=!1,i=de.SERIES);const{source:c,target:d,unitId:u,subUnitId:h}=e;if(!c||!d||t==null)return{undos:r,redos:s};const S=vt(c),g=vt(d),{cols:f,rows:p}=d,{cols:v,rows:C}=c,_=this._copyData;let E;t===a.Direction.DOWN||t===a.Direction.UP?E=C.length:E=v.length;const T=[];if(t===a.Direction.DOWN||t===a.Direction.UP){const B=p.length,x=[];f.forEach((z,F)=>{const Y=_[F],X=this._getApplyData(Y,E,B,t,i,l,e);x.push(X)});for(let z=0;z<x[0].length;z++){const F=[];for(let Y=0;Y<x.length;Y++)F.push({s:null,...x[Y][z]});T.push(F)}}else{const B=f.length;p.forEach((x,z)=>{const F=_[z],Y=this._getApplyData(F,E,B,t,i,l,e),X=[];for(let Z=0;Z<Y.length;Z++)X.push({s:null,...Y[Z]});T.push(X)})}let P=[];const R=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getStyles();if(l?(P=this._getMergeApplyData(S,g,t,E),T.forEach(B=>{B.forEach(x=>{x&&R&&R&&(x.s=R.getStyleByCell(x))})})):T.forEach((B,x)=>{B.forEach((z,F)=>{z&&R&&(z.s=R.getStyleByCell(this._beforeApplyData[x][F])||null)})}),i===de.ONLY_FORMAT&&T.forEach((B,x)=>{B.forEach((z,F)=>{if(z){const Y=this._beforeApplyData[x][F]||{};z.f=Y.f,z.si=Y.si,z.t=Y.t,z.v=Y.v}})}),l){const B=[],x=(V=(U=this._univerInstanceService.getUniverSheetInstance(u))==null?void 0:U.getSheetBySheetId(h))==null?void 0:V.getMergeData();x&&x.forEach(Y=>{a.Rectangle.intersects(Y,g)&&B.push(Y)});const z={unitId:u,subUnitId:h,ranges:B},F=this._injector.invoke(m.RemoveMergeUndoMutationFactory,z);B.length&&(s.push({id:m.RemoveWorksheetMergeMutation.id,params:z}),r.unshift({id:m.AddWorksheetMergeMutation.id,params:F}))}const O={subUnitId:h,unitId:u,cellValue:Id([d])},A=this._injector.invoke(m.SetRangeValuesUndoMutationFactory,O);s.push({id:m.SetRangeValuesMutation.id,params:O}),r.unshift({id:m.SetRangeValuesMutation.id,params:A});const N=new a.ObjectMatrix;p.forEach((B,x)=>{f.forEach((z,F)=>{T[x][F]&&N.setValue(B,z,T[x][F])})});const D=N.getMatrix(),H={subUnitId:h,unitId:u,cellValue:D},W=this._injector.invoke(m.SetRangeValuesUndoMutationFactory,H);if(this._autoFillService.getActiveHooks().forEach(B=>{var x;(x=B.onBeforeSubmit)==null||x.call(B,e,t,i,D)}),r.unshift({id:m.SetRangeValuesMutation.id,params:W}),s.push({id:m.SetRangeValuesMutation.id,params:H}),P!=null&&P.length){const B=m.getAddMergeMutationRangeByType(P),x={unitId:u,subUnitId:h,ranges:B},z=this._injector.invoke(m.AddMergeUndoMutationFactory,x);r.unshift({id:m.RemoveWorksheetMergeMutation.id,params:z}),s.push({id:m.AddWorksheetMergeMutation.id,params:x})}return{undos:r,redos:s}}_shouldDisableSeries(e){return e.every(t=>Object.keys(t).every(i=>{var r;return((r=t[i])==null?void 0:r.length)===0||[_e.OTHER,_e.FORMULA].includes(i)}))}_getPreferredApplyType(e){return e.every(i=>Object.keys(i).every(r=>{var s,l;return((s=i[r])==null?void 0:s.length)===0||((l=i[r])==null?void 0:l.length)===1&&i[r][0].data.length===1&&_e.NUMBER===r}))?de.COPY:de.SERIES}},y.AutoFillController=Jd([Ht(0,a.IUniverInstanceService),Ht(1,a.ICommandService),Ht(2,Ct),Ht(3,ge),Ht(4,M.IRenderManagerService),Ht(5,a.Inject(a.Injector)),Ht(6,a.Inject(y.SheetsRenderService))],y.AutoFillController);var $d=Object.getOwnPropertyDescriptor,eu=(n,o,e,t)=>{for(var i=t>1?void 0:t?$d(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},ar=(n,o)=>(e,t)=>o(e,t,n);y.CellCustomRenderController=class extends a.Disposable{constructor(e,t,i,r){super();w(this,"_enterActiveRender");this._context=e,this._sheetSkeletonManagerService=t,this._renderManagerService=i,this._permissionService=r,this._initEventBinding()}_initEventBinding(){const e=new a.DisposableCollection,t=this._context.unit,i=r=>{if(e.dispose(),!r)return;const s=this._context.unitId,{skeleton:l}=r,c=this._renderManagerService.getRenderById(s);if(c&&c.mainComponent){const d=c.mainComponent,u=g=>{const{offsetX:f,offsetY:p}=g,v=c.scene,C=t.getActiveSheet();if(!C)return;const _=v.getActiveViewportByCoord(M.Vector2.FromArray([f,p]));if(!_)return;const{scaleX:E,scaleY:T}=v.getAncestorScale(),P={x:_.viewportScrollX,y:_.viewportScrollY},R=l.getCellIndexByOffset(f,p,E,T,P),O=l.worksheet.getMergedCell(R.row,R.column),A={actualRow:O?O.startRow:R.row,actualCol:O?O.startColumn:R.column,row:R.row,col:R.column};if(!A||!l)return;const N=C.getCell(A.actualRow,A.actualCol);if(!N)return;const D=N.customRender;if(!(D!=null&&D.length))return;const H=A.actualRow,W=A.actualCol,U=D.sort(a.sortRules),V=C.getSheetId(),B={data:N,style:l.getStyles().getStyleByCell(N),primaryWithCoord:l.getCellWithCoordByIndex(A.actualRow,A.actualCol),unitId:s,subUnitId:V,row:H,col:W,workbook:t,worksheet:C},x={x:P.x+f/E,y:P.y+p/T},z=U.find(F=>{var Y;return(Y=F.isHit)==null?void 0:Y.call(F,x,B)});if(z)return[z,B]},h=d.onPointerDown$.subscribeEvent(g=>{var p,v,C,_;const f=u(g);if(f){const[E,T]=f,{row:P,col:R,worksheet:O,unitId:A,subUnitId:N}=T;if(!((p=this._permissionService.composePermission([new m.WorkbookEditablePermission(A).id,new m.WorksheetEditPermission(A,N).id]))==null?void 0:p.every(W=>W.value)))return!1;const H=(C=(v=O.getCell(P,R))==null?void 0:v.selectionProtection)==null?void 0:C[0];if((H==null?void 0:H[m.UnitAction.Edit])===!1)return!1;(_=E.onPointerDown)==null||_.call(E,T,g)}}),S=a.fromEventSubject(d.onPointerMove$).pipe(k.throttleTime(30)).subscribe(g=>{var p,v,C,_,E,T;const f=u(g);if(f){const[P,R]=f;this._enterActiveRender?this._enterActiveRender.render!==P&&((v=(p=this._enterActiveRender.render).onPointerLeave)==null||v.call(p,this._enterActiveRender.cellContext,g),this._enterActiveRender={render:P,cellContext:R},(C=P.onPointerEnter)==null||C.call(P,R,g)):(this._enterActiveRender={render:P,cellContext:R},(_=P.onPointerEnter)==null||_.call(P,R,g))}else this._enterActiveRender&&((T=(E=this._enterActiveRender.render).onPointerLeave)==null||T.call(E,this._enterActiveRender.cellContext,g),this._enterActiveRender=null)});h&&e.add(h),S&&e.add(S)}};this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i)),i(this._sheetSkeletonManagerService.getCurrentParam()),this.disposeWithMe(e)}},y.CellCustomRenderController=eu([ar(1,a.Inject(y.SheetSkeletonManagerService)),ar(2,M.IRenderManagerService),ar(3,a.IPermissionService)],y.CellCustomRenderController);class lr extends a.Disposable{constructor(){super(...arguments);w(this,"rangesStack",[]);w(this,"selectedRangeWorksheet","")}}var tu=Object.getOwnPropertyDescriptor,nu=(n,o,e,t)=>{for(var i=t>1?void 0:t?tu(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},oa=(n,o)=>(e,t)=>o(e,t,n);let un=class{constructor(n,o){w(this,"_current",null);w(this,"_shortcutParam",[]);this._univerInstanceService=n,this._localeService=o}dispose(){this._shortcutParam=[]}getCurrentBySearch(n){return this._getCurrentBySearch(n)}getCurrent(){return this._getCurrentBySearch(this._current)}addOrUpdate(n){const o=this._getCurrentBySearch({unitId:n.unitId,sheetId:n.sheetId,keycode:n.keycode});if(o!=null){const e=this._shortcutParam.indexOf(o);this._shortcutParam.splice(e,1)}return this._shortcutParam.push(n),o}remove(n){if(n==null)return;const o=this._getCurrentBySearch(n);if(o==null)return;const e=this._shortcutParam.indexOf(o);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)}};un=nu([oa(0,a.IUniverInstanceService),oa(1,a.Inject(a.LocaleService))],un);var Zi=(n=>(n.MergeAll="mergeAll",n.MergeVertical="mergeVertical",n.MergeHorizontal="mergeHorizontal",n))(Zi||{});function _t(n,o,e,t,i=!0,r=1,s=!0){let l={...n};t==null&&(t={startRow:0,endRow:e.getRowCount()-1,startColumn:0,endColumn:e.getColumnCount()-1});let c;switch(o){case a.Direction.UP:for(c=n.startRow-r;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,i&&(l=_t(l,a.Direction.LEFT,e,t,!1)));break;case a.Direction.DOWN:for(c=n.endRow+r;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,i&&(l=_t(l,a.Direction.RIGHT,e,t,!1)));break;case a.Direction.LEFT:for(c=n.startColumn-r;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,i&&(l=_t(l,a.Direction.UP,e,t,!1)));break;case a.Direction.RIGHT:for(c=n.endColumn+r;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,i&&(l=_t(l,a.Direction.DOWN,e,t,!1)));break}return l}function cr(n,o,e){const t={...n},{startRow:i,startColumn:r,endRow:s,endColumn:l}=Kn(n,o,e);let c=qn(e,i,r,s,l).hasValue,d=!0,u=!0;for(;u;){if(a.Direction.UP===o){let h=t.startRow-1;for(;h>-1&&!e.getRowVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:S,matrix:g}=qn(e,h,t.startColumn,h,t.endColumn);if(c&&!S&&!d){u=!1;break}else{if(g.getLength()!==0){let f=h;g.forValue(p=>{f=Math.min(p,f)}),t.startRow=f}else t.startRow=h;if(t.endRow=t.startRow,!c&&S){u=!1;break}c=S,d=!1}}if(a.Direction.DOWN===o){let h=t.endRow+1;for(;h<e.getRowCount()&&!e.getRowVisible(h);)h+=1;if(h===e.getRowCount()){u=!1;break}const{hasValue:S,matrix:g}=qn(e,h,t.startColumn,h,t.endColumn);if(c&&!S&&!d){u=!1;break}else{if(g.getLength()!==0){let f=h;g.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&&S){u=!1;break}c=S,d=!1}}if(a.Direction.LEFT===o){let h=t.startColumn-1;for(;h>-1&&!e.getColVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:S,matrix:g}=qn(e,t.startRow,h,t.endRow,h);if(c&&!S&&!d){u=!1;break}else{if(g.getLength()!==0){let f=h;g.forValue((p,v)=>{f=Math.min(v,f)}),t.startColumn=f}else t.startColumn=h;if(t.endColumn=t.startColumn,!c&&S){u=!1;break}c=S,d=!1}}if(a.Direction.RIGHT===o){let h=t.endColumn+1;for(;h<e.getColumnCount()&&!e.getColVisible(h);)h+=1;if(h===e.getColumnCount()){u=!1;break}const{hasValue:S,matrix:g}=qn(e,t.startRow,h,t.endRow,h);if(c&&!S&&!d){u=!1;break}else{if(g.getLength()!==0){let f=h;g.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&&S){u=!1;break}c=S,d=!1}}}return m.alignToMergedCellsBorders(t,e,!0)}function ra(n,o,e){return _t(n,o,e,void 0,!1,1,!1)}function iu(n,o,e){const t=cr(n,o,e);return m.alignToMergedCellsBorders(a.Rectangle.union(t,n),e,!0)}function ou(n,o,e){const t=ra(n,o,e),i={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,i),e)}function ru(n,o,e,t){const i=a.getReverseDirection(e),r=cr(Kn(n,i,t),e,t);return e===a.Direction.UP&&r.startRow<=n.startRow?m.alignToMergedCellsBorders({...o,startColumn:n.startColumn,endColumn:n.endColumn},t,!0):e===a.Direction.DOWN&&r.endRow>=n.endRow?m.alignToMergedCellsBorders({...o,startColumn:n.startColumn,endColumn:n.endColumn},t,!0):e===a.Direction.LEFT&&r.startColumn<=n.startColumn?m.alignToMergedCellsBorders({...o,startRow:n.startRow,endRow:n.endRow},t,!0):e===a.Direction.RIGHT&&r.endColumn>=n.endColumn?m.alignToMergedCellsBorders({...o,startRow:n.startRow,endRow:n.endRow},t,!0):a.Rectangle.union(a.Rectangle.clone(o),r)}function su(n,o,e){const t=a.getReverseDirection(o),i=Kn(n,t,e),r=Kn(n,o,e),s=ra(i,o,e);return m.alignToMergedCellsBorders(a.Rectangle.union(r,s),e,!1)}function sa(n){return{startRow:0,startColumn:0,endRow:n.getRowCount()-1,endColumn:n.getColumnCount()-1,rangeType:a.RANGE_TYPE.ALL}}function Kn(n,o,e){let t;switch(o){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 qn(n,o,e,t,i){let r=!1;const s=n.getMatrixWithMergedCells(o,e,t,i).forValue((l,c,d)=>{if(lu(d))return r=!0,!1});return{hasValue:r,matrix:s}}function dr(n,o,e){const t=a.Rectangle.clone(n);if(o==null)return t;switch(e){case a.Direction.UP:case a.Direction.DOWN:t.startColumn=t.endColumn=o.actualColumn;break;case a.Direction.LEFT:case a.Direction.RIGHT:t.startRow=t.endRow=o.actualRow;break}return t}function au(n,o,e){var l,c,d,u;const{primary:t,range:i}=n,r=a.Rectangle.clone(i);switch(o){case a.Direction.UP:case a.Direction.DOWN:r.startRow=(l=t==null?void 0:t.startRow)!=null?l:i.startRow,r.endRow=(c=t==null?void 0:t.endRow)!=null?c:i.startRow;break;case a.Direction.LEFT:case a.Direction.RIGHT:r.startColumn=(d=t==null?void 0:t.startColumn)!=null?d:i.startColumn,r.endColumn=(u=t==null?void 0:t.endColumn)!=null?u:i.startColumn;break}const s=Kn(r,o,e);switch(o){case a.Direction.DOWN:return i.startRow<s.startRow;case a.Direction.UP:return i.endRow>s.endRow;case a.Direction.LEFT:return s.endColumn<i.endColumn;case a.Direction.RIGHT:return s.startColumn>i.startColumn}}function aa(n,o){let e=n[0].startRow,t=n[0].endRow;n.forEach(r=>{const{startRow:s,endRow:l}=r;e=Math.min(e,s),t=Math.max(t,l)});const i=new Array(t-e+1).fill(!1);return o.forEach(r=>{const{startRow:s,endRow:l}=r;for(let c=Math.max(s,e);c<=Math.min(l,t);c++)i[c-e]=!0}),n.every(r=>{const{startRow:s,endRow:l}=r;for(let c=s;c<=l;c++)if(!i[c-e])return!1;return!0})}function la(n,o){let e=n[0].startColumn,t=n[0].endColumn;n.forEach(r=>{const{startColumn:s,endColumn:l}=r;e=Math.min(e,s),t=Math.max(t,l)});const i=new Array(t-e+1).fill(!1);return o.forEach(r=>{const{startColumn:s,endColumn:l}=r;for(let c=Math.max(s,e);c<=Math.min(l,t);c++)i[c-e]=!0}),n.every(r=>{const{startColumn:s,endColumn:l}=r;for(let c=s;c<=l;c++)if(!i[c-e])return!1;return!0})}function ur(n,o){return o?n==="mergeAll"?o.filter(e=>!(e.startRow===e.endRow&&e.startColumn===e.endColumn)):n==="mergeVertical"?o.filter(e=>e.startRow!==e.endRow):n==="mergeHorizontal"?o.filter(e=>e.startColumn!==e.endColumn):o:null}function lu(n){return n.v!==void 0&&n.v!==null&&n.v!==""||n.p!==void 0}var Qe=(n=>(n[n.moveStopeOne=0]="moveStopeOne",n[n.moveGap=1]="moveGap",n[n.moveStepPage=2]="moveStepPage",n[n.moveStepEnd=3]="moveStepEnd",n))(Qe||{});const Ae={id:"sheet.command.move-selection",type:a.CommandType.COMMAND,handler:(n,o)=>{if(!o)return!1;const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const{workbook:t,worksheet:i}=e,r=m.getSelectionsService(n,o.fromCurrentSelection).getCurrentLastSelection();if(!r)return!1;const{direction:s,jumpOver:l,extra:c}=o,{range:d,primary:u}=r,h=dr(d,u,s),S=l===1?cr(h,s,i):_t(h,s,i),g=m.getCellAtRowCol(S.startRow,S.startColumn,i);if(a.Rectangle.equals(g,h))return!1;const f=t.getUnitId();n.get(un).remove({unitId:f,sheetId:i.getSheetId(),keycode:I.KeyCode.TAB});const p=[{range:a.Rectangle.clone(g),primary:{startRow:g.startRow,startColumn:g.startColumn,endRow:g.endRow,endColumn:g.endColumn,actualRow:S.startRow,actualColumn:S.startColumn,isMerged:g.isMerged,isMergedMainCell:g.startRow===S.startRow&&g.startColumn===S.startColumn}}];return n.get(a.ICommandService).executeCommand(m.SetSelectionsOperation.id,{unitId:t.getUnitId(),subUnitId:i.getSheetId(),selections:p,type:m.SelectionMoveType.MOVE_END,extra:c,reveal:!0})}},Je={id:"sheet.command.move-selection-enter-tab",type:a.CommandType.COMMAND,handler:(n,o)=>{var B;if(!o)return!1;const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const{workbook:t,worksheet:i}=e,r=m.getSelectionsService(n),{direction:s,keycode:l}=o,c=s===a.Direction.LEFT||s===a.Direction.UP,d=r.getCurrentSelections().concat(),u=d.findIndex(x=>x.primary),h=d[u];if(!h)return!1;const S=c?-1:1,g=u+S!==d.length?d[u+S]:d[0],f=d.findIndex(x=>x===g),p=t.getUnitId(),v=i.getSheetId();if(!h)return!1;const{range:C}=h,_=h.primary;let E=dr(C,_,s);const T=n.get(un),P=T.getCurrentBySearch({unitId:p,sheetId:v,keycode:I.KeyCode.TAB});let R;const{startRow:O,endRow:A,startColumn:N,endColumn:D}=C,H=c?_.startRow===O&&_.startColumn===N:_.endRow===A&&_.endColumn===D;if(a.Rectangle.equals(C,_)){if(l===I.KeyCode.TAB)P==null&&T.addOrUpdate({unitId:p,sheetId:v,keycode:I.KeyCode.TAB,selection:h});else{const F=P==null?void 0:P.selection;if(F!=null){const{range:Y,primary:X}=F;E=dr(Y,X,s)}T.remove({unitId:p,sheetId:v,keycode:I.KeyCode.TAB})}const x=_t(E,s,i),z=m.getCellAtRowCol(x.startRow,x.startColumn,i);if(a.Rectangle.equals(z,E))return!1;R={range:a.Rectangle.clone(z),primary:{startRow:z.startRow,startColumn:z.startColumn,endRow:z.endRow,endColumn:z.endColumn,actualRow:x.startRow,actualColumn:x.startColumn,isMerged:z.isMerged,isMergedMainCell:z.startRow===x.startRow&&z.startColumn===x.startColumn}}}else{T.remove({unitId:p,sheetId:v,keycode:I.KeyCode.TAB});const x=a.Tools.deepClone(_),z=H?g.range:_t({startRow:x.startRow,startColumn:x.startColumn,endRow:x.endRow,endColumn:x.endColumn},s,i,{startRow:O,endRow:A,startColumn:N,endColumn:D}),F=H&&c,Y=F?m.getCellAtRowCol(z.endRow,z.endColumn,i):m.getCellAtRowCol(z.startRow,z.startColumn,i);R={range:H?g.range:a.Rectangle.clone(C),primary:{startRow:Y.startRow,startColumn:Y.startColumn,endRow:Y.endRow,endColumn:Y.endColumn,actualRow:F?Y.startRow:z.startRow,actualColumn:F?Y.startColumn:z.startColumn,isMerged:Y.isMerged,isMergedMainCell:Y.startRow===z.startRow&&Y.startColumn===z.startColumn},style:H?g.style:h.style}}H?(d[u].primary=null,d[f]=R,r.setSelections(p,v,[],m.SelectionMoveType.MOVE_END)):d[u]=R;const W=n.get(a.ICommandService).executeCommand(m.SetSelectionsOperation.id,{unitId:p,subUnitId:v,type:m.SelectionMoveType.MOVE_END,selections:d,reveal:!0,extra:o.extra}),V=(B=n.get(M.IRenderManagerService).getRenderById(p))==null?void 0:B.with(ve);return V==null||V.refreshSelectionMoveEnd(),W}},De={id:"sheet.command.expand-selection",type:a.CommandType.COMMAND,handler:(n,o)=>{if(!o)return!1;const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const{worksheet:t,unitId:i,subUnitId:r}=e,s=m.getSelectionsService(n).getCurrentLastSelection();if(!s)return!1;const{range:l,primary:c}=s,{jumpOver:d,direction:u,extra:h}=o,g=au(s,u,t)?d===1?ru(l,{...a.Rectangle.clone(c),rangeType:a.RANGE_TYPE.NORMAL},u,t):su(l,u,t):d===1?iu(l,u,t):ou(l,u,t);return g.rangeType=s.range.rangeType,a.Rectangle.equals(g,l)?!1:n.get(a.ICommandService).syncExecuteCommand(m.SetSelectionsOperation.id,{unitId:i,subUnitId:r,type:m.SelectionMoveType.MOVE_END,selections:[{range:g,primary:c}],extra:h,reveal:!0})}},Ki={id:"sheet.command.select-all",type:a.CommandType.COMMAND,handler:async(n,o={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 i=n.get(lr),{worksheet:r,unitId:s,subUnitId:l}=e,c=`${s}|${l}`;c!==i.selectedRangeWorksheet&&(i.rangesStack=[],i.selectedRangeWorksheet=c);const d=r.getMaxRows(),u=r.getMaxColumns(),{expandToGapFirst:h,loop:S}=o,{range:g,primary:f}=t,p=g.endColumn===u-1&&g.endRow===d-1&&g.startRow===0&&g.startColumn===0;i.rangesStack.some(C=>a.Rectangle.equals(C,g))||(i.rangesStack=[],i.rangesStack.push(g));let v;if(p)if(S){if(i.rangesStack.findIndex(_=>a.Rectangle.equals(_,g))!==i.rangesStack.length-1)return!1;v=i.rangesStack[0]}else return!1;else h?(v=m.expandToContinuousRange(g,{left:!0,right:!0,up:!0,down:!0},r),a.Rectangle.equals(v,g)&&(v=sa(r))):v=sa(r);return i.rangesStack.some(C=>a.Rectangle.equals(C,v))||i.rangesStack.push(v),n.get(a.ICommandService).executeCommand(m.SetSelectionsOperation.id,{unitId:s,subUnitId:l,reveal:!0,selections:[{range:v,primary:f}]})}};var cu=Object.getOwnPropertyDescriptor,du=(n,o,e,t)=>{for(var i=t>1?void 0:t?cu(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},uu=(n,o)=>(e,t)=>o(e,t,n);y.SheetScrollManagerService=class{constructor(o,e){w(this,"_scrollStateMap",new Map);w(this,"_rawScrollInfo$",new k.BehaviorSubject(null));w(this,"rawScrollInfo$",this._rawScrollInfo$.asObservable());w(this,"validViewportScrollInfo$",new k.BehaviorSubject(null));w(this,"_searchParamForScroll",null);this._context=o,this._sheetSkeletonManagerService=e}dispose(){this._rawScrollInfo$.complete()}calcViewportScrollFromRowColOffset(o){if(!o)return{viewportScrollX:0,viewportScrollY:0};let{sheetViewStartColumn:e,sheetViewStartRow:t,offsetX:i,offsetY:r}=o;t=t||0,r=r||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)+i,u=l+r;return{viewportScrollX:d,viewportScrollY:u}}setSearchParam(o){this._searchParamForScroll=o}getScrollStateByParam(o){return this._getCurrentScroll(o)}getCurrentScrollState(){return this._getCurrentScroll(this._searchParamForScroll)}setValidScrollState(o){this._setScrollState(o)}emitRawScrollParam(o){this._emitRawScroll(o)}setValidScrollStateToCurrSheet(o){if(this._searchParamForScroll==null)return;this._setScrollState({...this._searchParamForScroll,...o});const e=this._searchParamForScroll.sheetId,t=this._sheetSkeletonManagerService.getSkeleton(e);t&&t.setScroll(o.viewportScrollX,o.viewportScrollY)}clear(){this._searchParamForScroll!=null&&this._clearByParamAndNotify(this._searchParamForScroll)}_setScrollState(o){const{unitId:e,sheetId:t,sheetViewStartColumn:i,sheetViewStartRow:r,offsetX:s,offsetY:l}=o;this._scrollStateMap.has(e)||this._scrollStateMap.set(e,new Map);const c=this._scrollStateMap.get(e),d={sheetViewStartRow:r,sheetViewStartColumn:i,offsetX:s,offsetY:l};c.set(t,d)}_clearByParamAndNotify(o){this._setScrollState({...o,sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),this._emitRawScroll({sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0})}_getCurrentScroll(o){var s;const e={sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0};if(o==null)return e;const{unitId:t,sheetId:i}=o;return((s=this._scrollStateMap.get(t))==null?void 0:s.get(i))||e}_emitRawScroll(o){this._rawScrollInfo$.next(o)}},y.SheetScrollManagerService=du([uu(1,a.Inject(y.SheetSkeletonManagerService))],y.SheetScrollManagerService);const Xe={id:"sheet.operation.set-scroll",type:a.CommandType.OPERATION,handler:(n,o)=>{if(!o)return!1;const{unitId:e,sheetId:t,offsetX:i,offsetY:r,sheetViewStartColumn:s,sheetViewStartRow:l}=o;return n.get(M.IRenderManagerService).getRenderById(e).with(y.SheetScrollManagerService).emitRawScrollParam({unitId:e,sheetId:t,offsetX:i,offsetY:r,sheetViewStartRow:l,sheetViewStartColumn:s}),!0}},hn={id:"sheet.command.set-scroll-relative",type:a.CommandType.COMMAND,handler:async(n,o)=>{const e=n.get(a.ICommandService),t=n.get(a.IUniverInstanceService),i=n.get(M.IRenderManagerService),r=m.getSheetCommandTarget(t);if(!r)return!1;const{unitId:s,subUnitId:l}=r,d=i.getRenderById(s).with(y.SheetScrollManagerService).getCurrentScrollState(),{offsetX:u=0,offsetY:h=0}=o||{},{sheetViewStartRow:S=0,sheetViewStartColumn:g=0,offsetX:f=0,offsetY:p=0}=d||{};return e.executeCommand(Xe.id,{unitId:s,sheetId:l,sheetViewStartRow:S,sheetViewStartColumn:g,offsetX:f+u,offsetY:p+h})}},Ye={id:"sheet.command.scroll-view",type:a.CommandType.COMMAND,handler:(n,o)=>{if(!o)return!1;const e=n.get(a.IUniverInstanceService),t=n.get(M.IRenderManagerService),i=m.getSheetCommandTarget(e);if(!i)return!1;const{workbook:r,worksheet:s,unitId:l}=i,d=t.getRenderById(l).with(y.SheetScrollManagerService).getCurrentScrollState();if(!s)return!1;const{sheetViewStartRow:u,sheetViewStartColumn:h,offsetX:S,offsetY:g}=o,{sheetViewStartColumn:f,sheetViewStartRow:p,offsetX:v,offsetY:C}=d||{},{xSplit:_,ySplit:E}=i.worksheet.getConfig().freeze;return n.get(a.ICommandService).syncExecuteCommand(Xe.id,{unitId:r.getUnitId(),sheetId:s.getSheetId(),sheetViewStartRow:u!=null?u:p!=null?p:0+E,sheetViewStartColumn:h!=null?h:f!=null?f:0+_,offsetX:S!=null?S:v,offsetY:g!=null?g:C})}},hr={id:"sheet.command.scroll-to-cell",type:a.CommandType.COMMAND,handler:(n,o)=>{const e=n.get(a.IUniverInstanceService);return n.get(M.IRenderManagerService).getRenderById(e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(y.SheetsScrollRenderController).scrollToRange(o.range,o.forceTop,o.forceLeft)}},hu={id:"sheet.command.scroll-view-reset",type:a.CommandType.COMMAND,handler:async n=>{const o=n.get(a.IUniverInstanceService),e=m.getSheetCommandTarget(o);if(!e)return!1;const{subUnitId:t,unitId:i}=e;return n.get(a.ICommandService).executeCommand(Xe.id,{unitId:i,sheetId:t,sheetViewStartRow:0,sheetViewStartColumn:0})}};var mu=Object.getOwnPropertyDescriptor,Su=(n,o,e,t)=>{for(var i=t>1?void 0:t?mu(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},mn=(n,o)=>(e,t)=>o(e,t,n);Ae.id,Je.id;const gu=3;y.SheetsScrollRenderController=class extends a.Disposable{constructor(o,e,t,i,r,s,l){super(),this._context=o,this._injector=e,this._sheetSkeletonManagerService=t,this._contextService=i,this._commandService=r,this._renderManagerService=s,this._scrollManagerService=l,this._initCommandListener(),this._wheelEventListener(),this._scrollBarEventListener(),this._initSkeletonListener()}_wheelEventListener(){const{scene:o}=this._context;if(!o)return;const e=o.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN);e&&this.disposeWithMe(o.onMouseWheel$.subscribeEvent((t,i)=>{if(t.ctrlKey||!this._contextService.getContextValue(a.FOCUSING_SHEET))return;let r=0,s=0;r=t.deltaX,t.shiftKey?r=(t.deltaY||t.deltaX)*gu:s=t.deltaY,this._commandService.executeCommand(hn.id,{offsetX:r,offsetY:s}),this._context.scene.makeDirty(!0);const l=e.limitedScroll(e.scrollX+r,e.scrollY+s);l&&!l.isLimitedX&&!l.isLimitedY&&(t.preventDefault(),o.getParent().classType===M.RENDER_CLASS_TYPE.SCENE_VIEWER&&i.stopPropagation()),e.isWheelPreventDefaultX&&e.isWheelPreventDefaultY&&t.preventDefault()}))}_scrollBarEventListener(){const{scene:o}=this._context;if(o==null)return;const e=o.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN);e&&(this.disposeWithMe(a.toDisposable(this._scrollManagerService.rawScrollInfo$.subscribe(t=>{var g;const i=(g=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:g.skeleton;if(!i)return;if(t==null){e.scrollToViewportPos({viewportScrollX:0,viewportScrollY:0});return}const{sheetViewStartRow:r,sheetViewStartColumn:s,offsetX:l,offsetY:c}=t,{startX:d,startY:u}=i.getCellWithCoordByIndex(r,s,!1),h=d+l,S=u+c;e.scrollToViewportPos({viewportScrollX:h,viewportScrollY:S})}))),this.disposeWithMe(e.onScrollAfter$.subscribeEvent(t=>{var p;const i=(p=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:p.skeleton;if(i==null||t.isTrigger===!1)return;const r=this._getSheetObject();if(i==null||r==null)return;const{viewportScrollX:s,viewportScrollY:l,scrollX:c,scrollY:d}=t,{row:u,column:h,rowOffset:S,columnOffset:g}=i.getOffsetRelativeToRowCol(s,l),f={sheetViewStartRow:u,sheetViewStartColumn:h,offsetX:g,offsetY:S,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 S;const i=(S=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:S.skeleton;if(i==null||t.isTrigger===!1)return;const r=this._getSheetObject();if(i==null||r==null)return;const{viewportScrollX:s=0,viewportScrollY:l=0}=t;this._getFreeze();const{row:c,column:d,rowOffset:u,columnOffset:h}=i.getOffsetRelativeToRowCol(s,l);this._commandService.executeCommand(Ye.id,{sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:h,offsetY:u})})))}_initSkeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeletonBefore$.subscribe(o=>{if(o==null)return;const e={unitId:o.unitId,sheetId:o.sheetId};if(this._scrollManagerService.setSearchParam(e),!this._getSheetObject())return;const i=this._scrollManagerService.getScrollStateByParam(e),{viewportScrollX:r,viewportScrollY:s}=this._scrollManagerService.calcViewportScrollFromRowColOffset(i);i&&this._updateViewportScroll(r,s)})))}_updateViewportScroll(o=0,e=0){const t=this._getSheetObject();if(!t)return;const i=t.scene,r=i.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN),s=i.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT),l=i.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM),c=i.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT),d=i.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);r&&(r.viewportScrollX=o,r.viewportScrollY=e),l&&(l.viewportScrollY=e),s&&(s.viewportScrollX=o),c&&(c.viewportScrollY=e),d&&(d.viewportScrollX=o)}scrollToRange(o,e,t){let{endRow:i,endColumn:r,startColumn:s,startRow:l}=o;const c=this._getViewportBounding();if(o.rangeType===a.RANGE_TYPE.ROW?(s=0,r=0):o.rangeType===a.RANGE_TYPE.COLUMN&&(l=0,i=0),c&&!e&&!t){const d=c.startRow>i?l:i,u=c.startColumn>r?s:r;return this._scrollToCell(d,u)}else return this._scrollToCell(l,s,e,t)}scrollToCell(o,e){const t=this._context.unit.getActiveSheet(),{ySplit:i,xSplit:r}=t.getFreeze();return this._commandService.syncExecuteCommand(Ye.id,{sheetViewStartRow:o-i,sheetViewStartColumn:e-r,offsetX:0,offsetY:0})}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(o=>{switch(o.id){case m.SetSelectionsOperation.id:{const e=o.params;e.unitId===this._context.unitId&&e.reveal&&this._scrollToSelection()}break;case m.ScrollToCellOperation.id:{const e=o.params;if(e.unitId===this._context.unitId){const t=e.range;this.scrollToRange(t)}}break;case De.id:{const e=o.params;this._scrollToSelectionForExpand(e)}break}}))}_scrollToSelectionForExpand(o){setTimeout(()=>{const e=this._getSelectionsService().getCurrentLastSelection();if(e==null)return;const{startRow:t,startColumn:i,endRow:r,endColumn:s}=e.range,l=this._getViewportBounding();if(l==null)return;const{startRow:c,startColumn:d,endRow:u,endColumn:h}=l;let S=0,g=0;t>c?S=r:r<u?S=t:S=c,i>d?g=s:s<h?g=i:g=d,o.direction===a.Direction.DOWN?S=r:o.direction===a.Direction.UP?S=t:o.direction===a.Direction.RIGHT?g=s:o.direction===a.Direction.LEFT&&(g=i),this._scrollToCell(S,g)},0)}_getFreeze(){var e;const o=(e=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:e.skeleton.getWorksheetConfig();if(o!=null)return o.freeze}_updateSceneSize(o){var h;if(o==null)return;const{unitId:e}=this._context,{skeleton:t}=o,i=(h=this._renderManagerService.getRenderById(e))==null?void 0:h.scene;if(t==null||i==null)return;const{rowTotalHeight:r,columnTotalWidth:s,rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:c}=t;this._context.unit.getActiveSheet()&&(i==null||i.transformByState({width:l+s,height:c+r}))}_getSheetObject(){return ze(this._context.unit,this._context)}_scrollToSelectionByDirection(o){const e=this._getViewportBounding();if(e==null)return!1;const{startRow:t,startColumn:i,endRow:r,endColumn:s}=e;let l=0,c=0;const{startRow:d,startColumn:u,endRow:h,endColumn:S}=o;d>=t&&(l=h),h<=r&&(l=d),u>=i&&(c=S),S<=s&&(c=u),this._scrollToCell(l,c)}_scrollToSelection(o=!0){var d;const e=this._getSelectionsService().getCurrentLastSelection();if(!e)return;const{startRow:t,startColumn:i,actualRow:r,actualColumn:s}=(d=e.primary)!=null?d:e.range,l=o&&r!=null?r:t,c=o&&s!=null?s:i;this._scrollToCell(l,c)}_getSelectionsService(){return m.getSelectionsService(this._injector)}_getViewportBounding(){var r,s;const o=(r=this._getSheetObject())==null?void 0:r.scene;if(o==null)return;const e=o.getViewport(M.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 i=e.calcViewportInfo();return t.getRangeByViewBound(i.viewBound)}_scrollToCell(o,e,t=!1,i=!1){var D,H,W;const{rowHeightAccumulation:r,columnWidthAccumulation:s}=(D=this._sheetSkeletonManagerService.getCurrentSkeleton())!=null?D:{};if(r==null||s==null)return!1;const l=(H=this._getSheetObject())==null?void 0:H.scene;if(l==null)return!1;const c=l.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(c==null)return!1;const d=(W=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:W.skeleton;if(d==null)return!1;const u=this._context.unit.getActiveSheet();if(!u)return!1;o=a.Tools.clamp(o,0,r.length-1),e=a.Tools.clamp(e,0,s.length-1);const{startColumn:h,startRow:S,ySplit:g,xSplit:f}=u.getFreeze(),p=this._getViewportBounding();if(p==null)return!1;const{startRow:v,startColumn:C,endRow:_,endColumn:E}=p;let T,P;if(o>=S&&e>=h-g&&(o<=v&&(T=o,t=!0),o>=_)){const U=r[o]-c.height;for(let V=v;V<=o&&(T=V+1,!(r[V]>=U));V++);}if(e>=h&&o>=S-g&&(e<=C&&(P=e,i=!0),e>=E)){const U=s[e]-c.width;for(let V=C;V<=e&&(P=V+1,!(s[V]>=U));V++);}if(T===void 0&&P===void 0)return!1;let{offsetX:R,offsetY:O,sheetViewStartRow:A,sheetViewStartColumn:N}=this._scrollManagerService.getCurrentScrollState()||{};if(T=T?Math.min(T,o):A+g,P=P?Math.min(P,e):N+f,i){R=0,P=e;const U=d.getHiddenColumnsInRange({startColumn:P-f,endColumn:P});P=P-U.length}if(t){O=0,T=o;const U=d.getHiddenRowsInRange({startRow:T-g,endRow:T});T=T-U.length}return this._commandService.syncExecuteCommand(Ye.id,{sheetViewStartRow:Math.max(0,T-g),sheetViewStartColumn:Math.max(0,P-f),offsetX:R,offsetY:O})}},y.SheetsScrollRenderController=Su([mn(1,a.Inject(a.Injector)),mn(2,a.Inject(y.SheetSkeletonManagerService)),mn(3,a.IContextService),mn(4,a.ICommandService),mn(5,M.IRenderManagerService),mn(6,a.Inject(y.SheetScrollManagerService))],y.SheetsScrollRenderController);const mr={id:"sheet.operation.scroll-to-range",type:a.CommandType.OPERATION,handler:(n,o)=>{if(!o)return!1;const e=n.get(a.IUniverInstanceService);return n.get(M.IRenderManagerService).getRenderById(e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(y.SheetsScrollRenderController).scrollToRange(o.range,o.forceTop,o.forceLeft)}};class ca{constructor(){w(this,"_state",null);w(this,"_rect",null);w(this,"_state$",new k.BehaviorSubject(null));w(this,"state$",this._state$.asObservable());w(this,"_rect$",new k.BehaviorSubject(null));w(this,"rect$",this._rect$.asObservable());w(this,"_focus",!1);w(this,"_focus$",new k.BehaviorSubject(this._focus));w(this,"focus$",this._focus$.asObservable())}dispose(){this._state$.complete(),this._state=null,this._rect$.complete(),this._rect=null}setState(o){this._state=o,this._refresh(o)}getRect(){return this._rect}setRect(o){this._rect=o,this._rect$.next(o)}getState(){return this._state}setFocus(o=!1){this._focus=o,this._focus$.next(o)}_refresh(o){this._state$.next(o)}}const Qn=a.createIdentifier("univer.sheet-cell-editor-manager.service");var Ue=function(){return Ue=Object.assign||function(n){for(var o,e=1,t=arguments.length;e<t;e++){o=arguments[e];for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])}return n},Ue.apply(this,arguments)},fu=function(n,o){var e={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&o.indexOf(t)<0&&(e[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,t=Object.getOwnPropertySymbols(n);i<t.length;i++)o.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(n,t[i])&&(e[t[i]]=n[t[i]]);return e},Te=L.forwardRef(function(n,o){var e=n.icon,t=n.id,i=n.className,r=n.extend,s=fu(n,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(t," ").concat(i||"").trim(),c=L.useRef("_".concat(Cu()));return da(e,"".concat(t),{defIds:e.defIds,idSuffix:c.current},Ue({ref:o,className:l},s),r)});function da(n,o,e,t,i){return L.createElement(n.tag,Ue(Ue({key:o},pu(n,e,i)),t),(vu(n,e).children||[]).map(function(r,s){return da(r,"".concat(o,"-").concat(n.tag,"-").concat(s),e,void 0,i)}))}function pu(n,o,e){var t=Ue({},n.attrs);e!=null&&e.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=e.colorChannel1),n.tag==="mask"&&t.id&&(t.id=t.id+o.idSuffix),Object.entries(t).forEach(function(r){var s=r[0],l=r[1];s==="mask"&&typeof l=="string"&&(t[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(o.idSuffix,")")))});var i=o.defIds;return!i||i.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+o.idSuffix),Object.entries(t).forEach(function(r){var s=r[0],l=r[1];typeof l=="string"&&(t[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(o.idSuffix,")")))})),t}function vu(n,o){var e,t=o.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((e=n.children)===null||e===void 0)&&e.length)?Ue(Ue({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&t&&t.indexOf(i.attrs.id)>-1?Ue(Ue({},i),{attrs:Ue(Ue({},i.attrs),{id:i.attrs.id+o.idSuffix})}):i})}):n}function Cu(){return Math.random().toString(36).substring(2,8)}Te.displayName="UniverIcon";var Iu={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"}}]},ua=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"autofill",ref:o,icon:Iu}))});ua.displayName="Autofill";var _u={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"}}]},Vt=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"check-mark-single",ref:o,icon:_u}))});Vt.displayName="CheckMarkSingle";var bu={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"}}]},ha=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"close-single",ref:o,icon:bu}))});ha.displayName="CloseSingle";var Eu={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"]},ma=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"convert-single",ref:o,icon:Eu}))});ma.displayName="ConvertSingle";var wu={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"}}]},qi=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"delete-single",ref:o,icon:wu}))});qi.displayName="DeleteSingle";var Tu={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"}}]},Sr=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"dropdown-single",ref:o,icon:Tu}))});Sr.displayName="DropdownSingle";var yu={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"}}]},gr=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"error-single",ref:o,icon:yu}))});gr.displayName="ErrorSingle";var Mu={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"}}]},Sa=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"eyelash-single",ref:o,icon:Mu}))});Sa.displayName="EyelashSingle";var Ru={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"}}]},ga=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"fx-single",ref:o,icon:Ru}))});ga.displayName="FxSingle";var Pu={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"}}]},fa=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"hide-gridlines",ref:o,icon:Pu}))});fa.displayName="HideGridlines";var Ou={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"}}]},fr=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"increase-single",ref:o,icon:Ou}))});fr.displayName="IncreaseSingle";var Au={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"}}]},pr=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"lock-single",ref:o,icon:Au}))});pr.displayName="LockSingle";var ku={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"}}]},Sn=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"more-down-single",ref:o,icon:ku}))});Sn.displayName="MoreDownSingle";var Du={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"}}]},vr=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"more-single",ref:o,icon:Du}))});vr.displayName="MoreSingle";var Nu={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"}}]},pa=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"paint-bucket",ref:o,icon:Nu}))});pa.displayName="PaintBucket";var Hu={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"}}]}]},va=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"paste-special",ref:o,icon:Hu}))});va.displayName="PasteSpecial";var Vu={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"}}]},Ca=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"protect-single",ref:o,icon:Vu}))});Ca.displayName="ProtectSingle";var Wu={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"}}]},Cr=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"warning-single",ref:o,icon:Wu}))});Cr.displayName="WarningSingle";var Lu={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"}}]},Ir=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"write-single",ref:o,icon:Lu}))});Ir.displayName="WriteSingle";const Uu=()=>{const[,n]=L.useState({});return L.useCallback(()=>n(o=>!o),[])},Bu=()=>{const n=I.useDependency(a.ICommandService),o=I.useDependency(a.IUniverInstanceService),e=I.useDependency(M.IRenderManagerService),t=I.useDependency(Ct),i=I.useDependency(a.LocaleService),[r,s]=L.useState([]),[l,c]=L.useState(!1),[d,u]=L.useState({row:-1,col:-1}),[h,S]=L.useState(de.SERIES),[g,f]=L.useState(!1),p=ot(),{sheetSkeletonManagerService:v,selectionRenderService:C}=L.useMemo(()=>{if(p){const X=e.getRenderById(p.getUnitId());return{sheetSkeletonManagerService:X==null?void 0:X.with(y.SheetSkeletonManagerService),selectionRenderService:X==null?void 0:X.with(ve)}}return{sheetSkeletonManagerService:null,selectionRenderService:null}},[p,e]),_=()=>{f(!0)},E=()=>{f(!1)},T=Uu();if(L.useEffect(()=>n.onCommandExecuted((Z,ne)=>{Z.id===Xe.id&&T()}).dispose,[T,n]),L.useEffect(()=>{const X=v&&a.toDisposable(v.currentSkeleton$.subscribe(Z=>{Z&&T()}));return X==null?void 0:X.dispose},[v,T]),L.useEffect(()=>a.toDisposable(t.menu$.subscribe(Z=>{s(Z.map(ne=>({...ne,index:Z.indexOf(ne)})))})).dispose,[t]),L.useEffect(()=>a.toDisposable(t.showMenu$.subscribe(Z=>{const{source:ne,target:J}=t.autoFillLocation||{source:null,target:null};if(Z&&ne&&J){const ae=Math.max(ne.rows[ne.rows.length-1],J.rows[J.rows.length-1]),ue=Math.max(ne.cols[ne.cols.length-1],J.cols[J.cols.length-1]);u({row:ae,col:ue})}else u({row:-1,col:-1})})).dispose,[t]),L.useEffect(()=>a.toDisposable(t.applyType$.subscribe(Z=>{S(Z)})).dispose,[t]),L.useEffect(()=>{function X(){c(!1)}return document.addEventListener("wheel",X),()=>{document.removeEventListener("wheel",X)}},[l]),d.col<0||d.row<0)return null;const P=ze(o,e);if(!P||!C)return null;const{scene:R}=P,O=v==null?void 0:v.getCurrentSkeleton(),A=C.getViewPort(),N=R==null?void 0:R.scaleX,D=R==null?void 0:R.scaleY,H=R==null?void 0:R.getViewportScrollXY(A);if(!N||!R||!N||!D||!H)return null;const W=(O==null?void 0:O.getNoMergeCellWithCoordByIndex(d.row,d.col).endX)||0,U=(O==null?void 0:O.getNoMergeCellWithCoordByIndex(d.row,d.col).endY)||0,V=M.convertTransformToOffsetX(W,N,H),B=M.convertTransformToOffsetY(U,D,H);if(V==null||B==null)return null;const x=X=>{c(X)},z=X=>{n.executeCommand(Yn.id,{type:X.value}),c(!1)},F=l||g,Y=r.filter(X=>!X.disable);return b.jsx("div",{className:"univer-absolute univer-inset-0 univer-z-10 univer-size-0",children:b.jsx("div",{className:"univer-absolute",style:{left:`${V+2}px`,top:`${B+2}px`},onMouseEnter:_,onMouseLeave:E,children:b.jsx(G.DropdownMenu,{align:"start",items:Y.map(X=>({type:"radio",value:h,options:[{label:i.t(X.label),value:X.value}],onSelect:()=>z(X)})),open:l,onOpenChange:x,children:b.jsxs("div",{className:G.clsx(`
|
|
1
|
+
(function(y,Q){typeof exports=="object"&&typeof module<"u"?Q(exports,require("@univerjs/docs-ui"),require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("react"),require("rxjs"),require("@univerjs/sheets"),require("@univerjs/docs"),require("@univerjs/engine-formula"),require("@univerjs/engine-numfmt"),require("react/jsx-runtime"),require("@univerjs/design"),require("rxjs/operators"),require("@univerjs/telemetry")):typeof define=="function"&&define.amd?define(["exports","@univerjs/docs-ui","@univerjs/core","@univerjs/engine-render","@univerjs/ui","react","rxjs","@univerjs/sheets","@univerjs/docs","@univerjs/engine-formula","@univerjs/engine-numfmt","react/jsx-runtime","@univerjs/design","rxjs/operators","@univerjs/telemetry"],Q):(y=typeof globalThis<"u"?globalThis:y||self,Q(y.UniverSheetsUi={},y.UniverDocsUi,y.UniverCore,y.UniverEngineRender,y.UniverUi,y.React,y.rxjs,y.UniverSheets,y.UniverDocs,y.UniverEngineFormula,y.UniverEngineNumfmt,y.React,y.UniverDesign,y.rxjs.operators,y.UniverTelemetry))})(this,function(y,Q,a,M,I,L,k,m,we,q,ad,b,G,Se,ld){"use strict";var $p=Object.defineProperty;var ev=(y,Q,a)=>Q in y?$p(y,Q,{enumerable:!0,configurable:!0,writable:!0,value:a}):y[Q]=a;var w=(y,Q,a)=>ev(y,typeof Q!="symbol"?Q+"":Q,a);function Li(n,o){if(n==null)return;const e=o.getRenderById(n);if(e==null)return;const{mainComponent:t,scene:i,engine:r,components:s}=e,l=t,c=s.get(Q.DOCS_VIEW_KEY.BACKGROUND);return{document:l,docBackground:c,scene:i,engine:r}}const jo=[10,400],Go="RANGE_SELECTOR_COMPONENT_KEY",Ui="EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY";var he=(n=>(n.MAIN="__SpreadsheetRender__",n.ROW="__SpreadsheetRowHeader__",n.COLUMN="__SpreadsheetColumnHeader__",n.LEFT_TOP="__SpreadsheetLeftTopPlaceholder__",n))(he||{});const zs=0,Bi=1,ft=10,cd=11,Xs=12,xi={id:"sheet.command.set-row-header-width",type:a.CommandType.COMMAND,handler:async(n,o)=>{if(!o)return!1;const e=n.get(M.IRenderManagerService);if(!e)return!1;const{unitId:t,subUnitId:i,size:r}=o,s=e.getRenderById(t);if(s){e.getRenderById(t).with(y.SheetSkeletonManagerService).setRowHeaderSize(s,i,r);const{components:c}=s,d=c.get(he.ROW);d&&d.setCustomHeader({headerStyle:{size:r}})}return!0}},Fi={id:"sheet.command.set-col-header-height",type:a.CommandType.COMMAND,handler:async(n,o)=>{if(!o)return!1;const e=n.get(M.IRenderManagerService);if(!e)return!1;const{unitId:t,subUnitId:i,size:r}=o,s=e.getRenderById(t);if(s){e.getRenderById(t).with(y.SheetSkeletonManagerService).setColumnHeaderSize(s,i,r);const{components:c}=s,d=c.get(he.COLUMN);d&&d.setCustomHeader({headerStyle:{size:r}})}return!0}},Zo=a.createInterceptorKey("rangeMovePermissionCheck"),Ko=a.createInterceptorKey("rangeFillPermissionCheck");var qo=(n=>(n[n.FORMULA_EDITOR_SHOW=100]="FORMULA_EDITOR_SHOW",n[n.MARK_SELECTION=1e4]="MARK_SELECTION",n))(qo||{});function pt(n){const o=n.getCurrentTheme(),e=new a.ColorKit(o.primaryColor).setAlpha(.07).toRgbString();return{strokeWidth:1,stroke:o.primaryColor,fill:e,widgets:{},widgetSize:6,widgetStrokeWidth:1,widgetStroke:o.colorWhite,autofillSize:6,autofillStrokeWidth:1,autofillStroke:o.colorWhite,rowHeaderFill:e,rowHeaderStroke:o.primaryColor,rowHeaderStrokeWidth:1,columnHeaderFill:e,columnHeaderStroke:o.primaryColor,columnHeaderStrokeWidth:1,expandCornerSize:40}}class dd{constructor(){w(this,"_startColumn",-1);w(this,"_startRow",-1);w(this,"_endColumn",-1);w(this,"_endRow",-1);w(this,"_startX",0);w(this,"_startY",0);w(this,"_endX",0);w(this,"_endY",0);w(this,"_primary");w(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(o){const{startColumn:e,startRow:t,endColumn:i,endRow:r}=this,{startColumn:s,startRow:l,endColumn:c,endRow:d}=o;return e===s&&t===l&&i===c&&r===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(o){this._rangeType=o}getValue(){return{rangeWithCoord:this.getRange(),primaryWithCoord:this._primary}}setValue(o,e){const{startColumn:t,startRow:i,endColumn:r,endRow:s,startX:l,startY:c,endX:d,endY:u,rangeType:h}=o;this._startColumn=t,this._startRow=i,this._endColumn=r,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(o){this._primary=o}clearCurrentCell(){this._primary=null}}function on(n,o){const{startRow:e,startColumn:t,endRow:i,endColumn:r,rangeType:s}=o,l=i<e?i:e,c=i<e?e:i,d=r<t?r:t,u=r<t?t:r,h=n.getNoMergeCellWithCoordByIndex(l,d),S=n.getNoMergeCellWithCoordByIndex(c,u);return{startRow:e,startColumn:t,endRow:i,endColumn:r,rangeType:s,startY:(h==null?void 0:h.startY)||0,endY:(S==null?void 0:S.endY)||0,startX:(h==null?void 0:h.startX)||0,endX:(S==null?void 0:S.endX)||0}}function Re(n,o){const{range:e,primary:t,style:i}=n,r=on(o,e),s=t&&Bn(o,t);return{rangeWithCoord:r,primaryWithCoord:s,style:i}}function Bn(n,o){const{actualRow:e,actualColumn:t,isMerged:i,isMergedMainCell:r,startRow:s,startColumn:l,endRow:c,endColumn:d}=o,u=n.getNoMergeCellWithCoordByIndex(e,t),h=n.getNoMergeCellWithCoordByIndex(s,l),S=n.getNoMergeCellWithCoordByIndex(c,d);return{actualRow:e,actualColumn:t,isMerged:i,isMergedMainCell:r,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:(S==null?void 0:S.endY)||0,startX:(h==null?void 0:h.startX)||0,endX:(S==null?void 0:S.endX)||0}}}const Ys="__SpreadsheetHelperSelectionTempRect",ud=35;class js{constructor(o,e){w(this,"_startOffsetX",0);w(this,"_startOffsetY",0);w(this,"_relativeSelectionPositionRow",0);w(this,"_relativeSelectionPositionColumn",0);w(this,"_relativeSelectionRowLength",0);w(this,"_relativeSelectionColumnLength",0);w(this,"_scenePointerMoveSub");w(this,"_scenePointerUpSub");w(this,"_disabled",!1);w(this,"_helperSelection");w(this,"_scrollTimer");w(this,"_activeViewport");w(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});w(this,"_isInMergeState",!1);w(this,"_fillControlColors",[]);w(this,"_skeleton");w(this,"_scene");w(this,"_themeService");w(this,"_injector");w(this,"_selectionHooks");this._control=o,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 o,e;(o=this._scrollTimer)==null||o.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(e=this._helperSelection)==null||e.dispose()}setDisabled(o){this._disabled=o}_getFreeze(){var e,t;return(t=(e=M.withCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,y.SheetSkeletonManagerService,this._injector.get(a.IUniverInstanceService),this._injector.get(M.IRenderManagerService)))==null?void 0:e.getCurrentParam())==null?void 0:t.skeleton.getWorksheetConfig().freeze}_isSelectionInViewport(o,e){const t=this._getFreeze()||{startRow:-1,startColumn:-1};switch(e.viewportKey){case M.SHEET_VIEWPORT_KEY.VIEW_MAIN:return o.endRow>=t.startRow&&o.endColumn>=t.startColumn;case M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP:case M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT:return o.endColumn>=t.startColumn&&o.startRow<t.startRow;case M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT:case M.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM:return o.endRow>=t.startRow&&o.startColumn<t.startColumn;case M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP:case M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT:case M.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP:case M.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP:return o.startRow<t.startRow&&o.startColumn<t.startColumn}}_clearObserverEvent(){var o,e;(o=this._scenePointerMoveSub)==null||o.unsubscribe(),(e=this._scenePointerUpSub)==null||e.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null}_initialControl(){const{leftControl:o,rightControl:e,topControl:t,bottomControl:i}=this._control;[o,e,t,i].forEach(r=>{r.onPointerEnter$.subscribeEvent(()=>{var l;((l=this._injector.get(ve,a.Quantity.OPTIONAL))==null?void 0:l.interceptor.fetchThroughInterceptors(Zo)(!1,null))!==!1&&r.setCursor(M.CURSOR_TYPE.MOVE)}),r.onPointerLeave$.subscribeEvent(()=>{r.resetCursor()}),r.onPointerDown$.subscribeEvent(this._controlPointerDownHandler.bind(this))})}_controlMoving(o,e){var N;const t=this._scene,i=t.getScrollXYInfoByViewport(M.Vector2.FromArray([o,e])),{scaleX:r,scaleY:s}=t.getAncestorScale(),l=this._skeleton.getCellIndexByOffset(o,e,r,s,i),{row:c,column:d}=l,u=this._skeleton.getRowCount()-1,h=this._skeleton.getColumnCount()-1;let S=Math.max(0,c+this._relativeSelectionPositionRow),g=S+this._relativeSelectionRowLength;g>u&&(g=u,g-S<this._relativeSelectionRowLength&&(S=g-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(S,f),_=Re({range:{startRow:S,endRow:g,startColumn:f,endColumn:p},primary:v,style:null},this._skeleton),E=this._skeleton.getNoMergeCellWithCoordByIndex(S,f),T=this._skeleton.getNoMergeCellWithCoordByIndex(g,p),P=(E==null?void 0:E.startY)||0,R=(T==null?void 0:T.endY)||0,O=(E==null?void 0:E.startX)||0,A=(T==null?void 0:T.endX)||0;(N=this._helperSelection)==null||N.transformByState({left:O,top:P,width:A-O,height:R-P}),this._targetSelection={..._.rangeWithCoord},this._control.selectionMoving$.next(_.rangeWithCoord)}_controlPointerDownHandler(o){const{offsetX:e,offsetY:t}=o,i=this._scene,r=i.getCoordRelativeToViewport(M.Vector2.FromArray([e,t])),{x:s,y:l}=r,c=i.getScrollXYInfoByViewport(r),{scaleX:d,scaleY:u}=i.getAncestorScale(),h=this._skeleton.getCellIndexByOffset(s,l,d,u,c);this._startOffsetX=s,this._startOffsetY=l;const{row:S,column:g}=h,{startRow:f,startColumn:p,endRow:v,endColumn:C}=this._control.model;let _=0,E=0;S<f?_-=1:S>v&&(_+=1),g<p?E-=1:g>C&&(E+=1),this._relativeSelectionPositionRow=f-S+_,this._relativeSelectionPositionColumn=p-g+E,this._relativeSelectionRowLength=v-f,this._relativeSelectionColumnLength=C-p;const T=this._control.currentStyle,P=this._getScale();this.isHelperSelection&&(this._helperSelection=new M.Rect(Ys,{stroke:T.stroke,strokeWidth:T.strokeWidth/P}),i.addObject(this._helperSelection));const R=i.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN),O=M.ScrollTimer.create(i);this._scrollTimer=O,O.startScroll(s,l,R),i.disableObjectsEvent(),this._scenePointerMoveSub=i.onPointerMove$.subscribeEvent(A=>{var V;if(this._disabled)return;const{offsetX:N,offsetY:D}=A;if(((V=this._injector.get(ve,a.Quantity.OPTIONAL))==null?void 0:V.interceptor.fetchThroughInterceptors(Zo)(!1,null))===!1)return;const{x:W,y:U}=i.getCoordRelativeToViewport(M.Vector2.FromArray([N,D]));this._controlMoving(W,U),i.setCursor(M.CURSOR_TYPE.MOVE),O.scrolling(W,U,()=>{this._controlMoving(W,U)})}),this._scenePointerUpSub=i.onPointerUp$.subscribeEvent(()=>{var N,D,H,W;(N=this._helperSelection)==null||N.dispose();const A=this._scene;A.resetCursor(),this._clearObserverEvent(),A.enableObjectsEvent(),(D=this._scrollTimer)==null||D.dispose(),this._control.selectionMoveEnd$.next(this._targetSelection),(W=(H=this._selectionHooks).selectionMoveEnd)==null||W.call(H)})}_initialWidget(){const{topLeftWidget:o,topCenterWidget:e,topRightWidget:t,middleLeftWidget:i,middleRightWidget:r,bottomLeftWidget:s,bottomCenterWidget:l,bottomRightWidget:c}=this._control,d=[M.CURSOR_TYPE.NORTH_WEST_RESIZE,M.CURSOR_TYPE.NORTH_RESIZE,M.CURSOR_TYPE.NORTH_EAST_RESIZE,M.CURSOR_TYPE.WEST_RESIZE,M.CURSOR_TYPE.EAST_RESIZE,M.CURSOR_TYPE.SOUTH_WEST_RESIZE,M.CURSOR_TYPE.SOUTH_RESIZE,M.CURSOR_TYPE.SOUTH_EAST_RESIZE];[o,e,t,i,r,s,l,c].forEach((u,h)=>{u.onPointerEnter$.subscribeEvent(()=>{u.setCursor(d[h])}),u.onPointerLeave$.subscribeEvent(()=>{u.resetCursor()}),u.onPointerDown$.subscribeEvent(S=>{this._widgetPointerDownEvent(S,d[h])})})}_widgetPointerDownEvent(o,e){const t=this._scene,{offsetX:i,offsetY:r}=o,s=t.getCoordRelativeToViewport(M.Vector2.FromArray([i,r])),{x:l,y:c}=s;this._startOffsetX=i,this._startOffsetY=r;const{startRow:d,startColumn:u,endRow:h,endColumn:S}=this._control.model,g=Math.min(d,h),f=Math.min(u,S),p=Math.max(d,h),v=Math.max(u,S);this._relativeSelectionPositionRow=g,this._relativeSelectionPositionColumn=f,this._relativeSelectionRowLength=p-g,this._relativeSelectionColumnLength=v-f,e===M.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=p,this._relativeSelectionPositionColumn=v):e===M.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=p:e===M.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=p:e===M.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=v:e===M.CURSOR_TYPE.SOUTH_WEST_RESIZE?this._relativeSelectionPositionColumn=v:e===M.CURSOR_TYPE.SOUTH_RESIZE&&(this._relativeSelectionPositionRow=g);const C=M.ScrollTimer.create(t),_=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN);C.startScroll(l,c,_),this._scrollTimer=C,t.disableObjectsEvent(),this._scenePointerMoveSub=t.onPointerMove$.subscribeEvent(E=>{const{offsetX:T,offsetY:P}=E,{x:R,y:O}=t.getCoordRelativeToViewport(M.Vector2.FromArray([T,P]));this._widgetMoving(R,O,e),t.setCursor(e),C.scrolling(R,O,()=>{this._widgetMoving(R,O,e)})}),this._scenePointerUpSub=t.onPointerUp$.subscribeEvent(()=>{var T,P,R;const E=this._scene;E.resetCursor(),this._clearObserverEvent(),E.enableObjectsEvent(),(T=this._scrollTimer)==null||T.dispose(),this._control.selectionScaled$.next(this._targetSelection),(R=(P=this._selectionHooks).selectionMoveEnd)==null||R.call(P)})}_widgetMoving(o,e,t){const i=this._scene,r=i.getScrollXYInfoByViewport(M.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:l}=i.getAncestorScale(),c=this._skeleton.getCellIndexByOffset(o,e,s,l,r),{row:d,column:u}=c;let h=this._relativeSelectionPositionRow,S=this._relativeSelectionPositionColumn,g=d,f=u;t===M.CURSOR_TYPE.NORTH_WEST_RESIZE?(h=d,S=u,g=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn):t===M.CURSOR_TYPE.NORTH_RESIZE?(h=d,S=this._relativeSelectionPositionColumn,g=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):t===M.CURSOR_TYPE.NORTH_EAST_RESIZE?(h=d,S=this._relativeSelectionPositionColumn,g=this._relativeSelectionPositionRow,f=u):t===M.CURSOR_TYPE.WEST_RESIZE?(h=this._relativeSelectionPositionRow,S=u,g=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,f=this._relativeSelectionPositionColumn):t===M.CURSOR_TYPE.EAST_RESIZE?g=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:t===M.CURSOR_TYPE.SOUTH_WEST_RESIZE?(h=this._relativeSelectionPositionRow,S=u,g=d,f=this._relativeSelectionPositionColumn):t===M.CURSOR_TYPE.SOUTH_RESIZE&&(h=this._relativeSelectionPositionRow,S=this._relativeSelectionPositionColumn,g=d,f=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const p=this._swapPositions(h,S,g,f),v=this._skeleton.getCellWithMergeInfoByIndex(h,S),_=Re({range:p,primary:v,style:null},this._skeleton);this._targetSelection={..._.rangeWithCoord},this._control.updateRangeBySelectionWithCoord(_),this._control.selectionScaling$.next(this._targetSelection)}_initialAutoFill(){const{fillControl:o}=this._control;o.onPointerEnter$.subscribeEvent(e=>{this._injector.get(ve).interceptor.fetchThroughInterceptors(Ko)(!1,{x:e.offsetX,y:e.offsetY,skeleton:this._skeleton,scene:this._scene})&&o.setCursor(M.CURSOR_TYPE.CROSSHAIR)}),o.onPointerLeave$.subscribeEvent(()=>{o.resetCursor()}),o.onPointerDown$.subscribeEvent(this._autoFillForPointerdown.bind(this))}_autoFillMoving(o,e){var D,H,W;const t=this._scene,i=t.getViewportScrollXY(this._activeViewport),{scaleX:r,scaleY:s}=t.getAncestorScale(),l=this._skeleton.getCellIndexByOffset(o,e,r,s,i),{row:c,column:d}=l,u=t.getCoordRelativeToViewport(M.Vector2.FromArray([o,e])),h=this._skeleton.getRowCount()-1,S=this._skeleton.getColumnCount()-1;let g=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn,p=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,C=!1,_=!0;if((d<f||d>v)&&c>=g&&c<=p){const U=this._fillRuler(d,f,v,this._relativeSelectionColumnLength,S);f=U.startRowOrColumn,v=U.endRowOrColumn,C=U.isLighten,_=!1}else if((c<g||c>p)&&d>=f&&d<=v){const U=this._fillRuler(c,g,p,this._relativeSelectionRowLength,h);g=U.startRowOrColumn,p=U.endRowOrColumn,C=U.isLighten}else if(Math.abs(this._startOffsetX-u.x-i.x)/2>Math.abs(this._startOffsetY-u.y-i.y)){const U=this._fillRuler(d,f,v,this._relativeSelectionColumnLength,S);f=U.startRowOrColumn,v=U.endRowOrColumn,C=U.isLighten,_=!1}else{const U=this._fillRuler(c,g,p,this._relativeSelectionRowLength,h);g=U.startRowOrColumn,p=U.endRowOrColumn,C=U.isLighten}const E=this._skeleton.getNoMergeCellWithCoordByIndex(g,f),T=this._skeleton.getNoMergeCellWithCoordByIndex(p,v),P=(E==null?void 0:E.startY)||0,R=(T==null?void 0:T.endY)||0,O=(E==null?void 0:E.startX)||0,A=(T==null?void 0:T.endX)||0;C?this._controlHandler((U,V)=>{const B=new a.ColorKit(this._fillControlColors[V]).lighten(ud).toRgbString();U.setProps({fill:B})}):this._controlHandler((U,V)=>{U.setProps({fill:this._fillControlColors[V]})});const N=m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();g===p&&_===!0||f===v&&_===!1?(D=this._helperSelection)==null||D.hide():((H=this._helperSelection)==null||H.transformByState({left:O-N/2,top:P-N/2,width:A-O,height:R-P}),(W=this._helperSelection)==null||W.show()),this._targetSelection={startY:P,endY:R,startX:O,endX:A,startRow:g,endRow:p,startColumn:f,endColumn:v},this._control.selectionFilling$.next(this._targetSelection)}_autoFillForPointerdown(o){const{offsetX:e,offsetY:t}=o,i=this._scene,r=i.getCoordRelativeToViewport(M.Vector2.FromArray([e,t])),{x:s,y:l}=r;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 S=this._control.currentStyle;let g=S==null?void 0:S.stroke,f=S==null?void 0:S.strokeWidth;const p=pt(this._themeService);g==null&&(g=p.stroke),f==null&&(f=p.strokeWidth);const v=this._getScale();f/=v;const C=m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/v,_=new a.ColorKit(g).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new M.Rect(Ys,{stroke:_,strokeWidth:f+C/2}),i.addObject(this._helperSelection)),this._activeViewport=i.getActiveViewportByCoord(M.Vector2.FromArray([e,t]));const E=i.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN),T=M.ScrollTimer.create(i,this._activeViewport.viewportKey===M.SHEET_VIEWPORT_KEY.VIEW_MAIN?M.ScrollTimerType.ALL:M.ScrollTimerType.NONE);T.startScroll(s,l,E),this._scrollTimer=T,i.disableObjectsEvent(),this._controlHandler(P=>{this._fillControlColors.push(P.fill)}),this._scenePointerMoveSub=i.onPointerMove$.subscribeEvent(P=>{var U;const{offsetX:R,offsetY:O}=P,A=i.getActiveViewportByCoord(M.Vector2.FromArray([R,O]));if(!this._injector.get(ve).interceptor.fetchThroughInterceptors(Ko)(!1,{x:o.offsetX,y:o.offsetY,skeleton:this._skeleton,scene:this._scene}))return;const{x:D,y:H}=i.getCoordRelativeToViewport(M.Vector2.FromArray([R,O]));this._autoFillMoving(D,H),i.setCursor(M.CURSOR_TYPE.CROSSHAIR);const W=this._targetSelection;if(E&&A&&((U=this._activeViewport)==null?void 0:U.viewportKey)!==(A==null?void 0:A.viewportKey)){let V;W.startRow!==c?(T.scrollTimerType=M.ScrollTimerType.Y,V={...W,endRow:W.startRow}):W.endRow!==u?(T.scrollTimerType=M.ScrollTimerType.Y,V={...W,startRow:W.endRow}):W.startColumn!==d?(T.scrollTimerType=M.ScrollTimerType.X,V={...W,endColumn:W.startColumn}):(T.scrollTimerType=M.ScrollTimerType.X,V={...W,startColumn:W.endColumn}),this._isSelectionInViewport(V,A)&&(E.scrollToBarPos({x:T.scrollTimerType===M.ScrollTimerType.X?0:void 0,y:T.scrollTimerType===M.ScrollTimerType.Y?0:void 0}),this._activeViewport=A)}T.scrolling(D,H,()=>{this._autoFillMoving(D,H)})}),this._scenePointerUpSub=i.onPointerUp$.subscribeEvent(()=>{var R,O;(R=this._helperSelection)==null||R.dispose();const P=this._scene;P.resetCursor(),this._clearObserverEvent(),P.enableObjectsEvent(),(O=this._scrollTimer)==null||O.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((A,N)=>{A.setProps({fill:this._fillControlColors[N]})}),this._fillControlColors=[]})}_hasMergeInRange(o,e,t,i){return this._skeleton.worksheet.getMergedCellRange(o,e,t,i).length>0}_swapPositions(o,e,t,i){const r=Math.min(o,t),s=Math.min(e,i),l=Math.max(o,t),c=Math.max(e,i);return{startRow:r,startColumn:s,endRow:l,endColumn:c}}_controlHandler(o){const{leftControl:e,rightControl:t,topControl:i,bottomControl:r,backgroundControlTop:s,backgroundControlMiddleLeft:l,backgroundControlMiddleRight:c,backgroundControlBottom:d,fillControl:u}=this._control,h=[e,t,i,r,s,l,c,d,u];for(let S=0,g=h.length;S<g;S++){const f=h[S];o(f,S)}}_fillRuler(o,e,t,i,r){let s=!1;if(o<e)if(this._isInMergeState&&o<e){const l=e-o,c=i+1,d=Math.ceil(l/c);let u=e-d*c;u<0&&(u=e-(d-1)*c),e=u}else e=o;else if(o>=e&&o<=t)s=!0,this._isInMergeState||(t=o);else if(this._isInMergeState&&o>t){const l=o-t,c=i+1,d=Math.ceil(l/c);let u=t+d*c;u>r&&(u=t+(d-1)*c),t=u}else t=o;return{rowOrColumn:o,startRowOrColumn:e,endRowOrColumn:t,isLighten:s}}_getScale(){const{scaleX:o,scaleY:e}=this._scene.getAncestorScale();return Math.max(o,e)}}var Qo=(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))(Qo||{});const Gs=.3;class xn extends a.Disposable{constructor(e,t,i,r){var s,l,c,d;super();w(this,"_isHelperSelection",!0);w(this,"_enableAutoFill",!0);w(this,"_showAutoFill",!1);w(this,"_highlightHeader",!0);w(this,"_selectionRenderModel");w(this,"_leftBorder");w(this,"_rightBorder");w(this,"_topBorder");w(this,"_bottomBorder");w(this,"_backgroundControlTop");w(this,"_backgroundControlBottom");w(this,"_backgroundControlMiddleLeft");w(this,"_backgroundControlMiddleRight");w(this,"_autoFillControl");w(this,"_selectionShapeGroup");w(this,"_rowHeaderBackground");w(this,"_rowHeaderBorder");w(this,"_rowHeaderGroup");w(this,"_columnHeaderBackground");w(this,"_columnHeaderBorder");w(this,"_columnHeaderGroup");w(this,"_dashedRect");w(this,"_topLeftWidget");w(this,"_topCenterWidget");w(this,"_topRightWidget");w(this,"_middleLeftWidget");w(this,"_middleRightWidget");w(this,"_bottomLeftWidget");w(this,"_bottomCenterWidget");w(this,"_bottomRightWidget");w(this,"_defaultStyle");w(this,"_currentStyle");w(this,"_rowHeaderWidth",0);w(this,"_columnHeaderHeight",0);w(this,"_widgetRects",[]);w(this,"_controlExtension");w(this,"_dispose$",new k.BehaviorSubject(this));w(this,"dispose$",this._dispose$.asObservable());w(this,"selectionMoving$",new k.Subject);w(this,"selectionMoveEnd$",new k.Subject);w(this,"selectionScaling$",new k.Subject);w(this,"selectionScaled$",new k.Subject);w(this,"selectionFilling$",new k.Subject);w(this,"_selectionFilled$",new k.Subject);w(this,"selectionFilled$",this._selectionFilled$.asObservable());w(this,"_antLineOffset",0);w(this,"_antRequestNewFrame",-1);this._scene=e,this._zIndex=t,this._themeService=i,this._enableAutoFill=(s=r==null?void 0:r.enableAutoFill)!=null?s:!0,this._highlightHeader=(l=r==null?void 0:r.highlightHeader)!=null?l:!0,this._rowHeaderWidth=(c=r==null?void 0:r.rowHeaderWidth)!=null?c:0,this._columnHeaderHeight=(d=r==null?void 0:r.columnHeaderHeight)!=null?d:0,this._initializeSheetBody(),this._initialHeader()}_initializeSheetBody(){this._defaultStyle=pt(this._themeService),this._currentStyle=pt(this._themeService),this._selectionRenderModel=new dd;const e=this._zIndex;this._leftBorder=new M.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightBorder=new M.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topBorder=new M.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomBorder=new M.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new M.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new M.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new M.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new M.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._autoFillControl=new M.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._autoFillControl.hide(),this._dashedRect=new M.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 M.Group("__SpreadsheetSelectionShape__"+e,...t,...this._widgetRects),this._selectionShapeGroup.hide(),this._selectionShapeGroup.evented=!1,this._selectionShapeGroup.zIndex=e;const i=this.getScene();i.addObject(this._selectionShapeGroup,Bi),this.disposeWithMe(a.toDisposable(i.onTransformChange$.subscribeEvent(r=>{r.type===M.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&(this._updateLayoutOfSelectionControl(this._currentStyle),this._updateControlCoord())})))}_initialHeader(){const e=this._zIndex;this._rowHeaderBackground=new M.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new M.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new M.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new M.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new M.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new M.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],cd)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new M.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new M.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new M.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new M.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new M.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new M.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new M.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new M.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 js(this,e)}setControlExtensionDisable(e){this._controlExtension&&this._controlExtension.setDisabled(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:i,widgets:r,autofillStroke:s,strokeDash:l,isAnimationDash:c}=t;let d=t.autofillSize,u=t.strokeWidth,h=t.autofillStrokeWidth;const S=this._getScale(),g=(u+m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH)/2/S;u/=S,d/=S,h/=S<1?1:S;const f=m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/S,p=M.FIX_ONE_PIXEL_BLUR_OFFSET/S,{startX:v,startY:C,endX:_,endY:E}=this._selectionRenderModel;if(this.leftControl.transformByState({height:E-C,left:-g+p,width:u,strokeWidth:f,top:-f/2+p}),this.leftControl.setProps({fill:i,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:E-C,left:_-v-g+p,width:u,strokeWidth:f,top:-f/2+p}),this.rightControl.setProps({fill:i,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:_-v+u,top:-g+p,left:-g+p,height:u,strokeWidth:f}),this.topControl.setProps({fill:i,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:_-v+u,top:E-C-g+p,height:u,left:-g+p,strokeWidth:f}),this.bottomControl.setProps({fill:i,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),l==null)this.dashedRect.hide(),this._stopAntLineAnimation();else{const T=t.strokeWidth*2/S;this.dashedRect.transformByState({height:E-C,width:_-v,strokeWidth:T,left:-T/2+p,top:-T/2+p}),this.dashedRect.setProps({strokeDashArray:[0,l/S]}),this._stopAntLineAnimation(),c!==!1&&this._startAntLineAnimation(),this.dashedRect.show()}if(this._showAutoFill=this._showAutoFill&&this._enableAutoFill,this._showAutoFill&&!this._hasWidgets(r)){const T={fill:i,stroke:s,strokeScaleEnabled:!1},P={width:d-h,height:d-h,left:_-v-d/2+h/2-p,top:E-C-d/2+h/2-p,strokeWidth:h};this._autoFillControl.setProps(T),this._autoFillControl.transformByState(P),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,i=0,r,s){this._rowHeaderWidth=t,this._columnHeaderHeight=i,this.updateRangeBySelectionWithCoord({rangeWithCoord:e,primaryWithCoord:s,style:r}),r&&this.updateStyle(r)}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,i,r,s,l,c,d,u,h,S,g,f,p,v,C,_,E,T,P,R,O,A,N,D;(e=this._leftBorder)==null||e.dispose(),(t=this._rightBorder)==null||t.dispose(),(i=this._topBorder)==null||i.dispose(),(r=this._bottomBorder)==null||r.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(),(S=this._rowHeaderBorder)==null||S.dispose(),(g=this._rowHeaderGroup)==null||g.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(),(_=this._topLeftWidget)==null||_.dispose(),(E=this._topCenterWidget)==null||E.dispose(),(T=this._topRightWidget)==null||T.dispose(),(P=this._middleLeftWidget)==null||P.dispose(),(R=this._middleRightWidget)==null||R.dispose(),(O=this._bottomLeftWidget)==null||O.dispose(),(A=this._bottomCenterWidget)==null||A.dispose(),(N=this._bottomRightWidget)==null||N.dispose(),(D=this._controlExtension)==null||D.dispose(),super.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let t;if(e.isMerged){const i=e.mergeInfo;t={startRow:i.startRow,endRow:i.endRow,startColumn:i.startColumn,endColumn:i.endColumn,startX:i.startX,endX:i.endX,startY:i.startY,endY:i.endY}}else{const{actualRow:i,actualColumn:r,startX:s,endX:l,startY:c,endY:d}=e;t={startRow:i,endRow:i,startColumn:r,endColumn:r,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:i,endX:r,endY:s,rangeType:l}=this._selectionRenderModel,c=this._currentStyle,d=this._getScale(),{stroke:u,rowHeaderFill:h=c.rowHeaderFill,rowHeaderStroke:S=c.rowHeaderStroke,columnHeaderFill:g=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,_=this._columnHeaderHeight;if(this._highlightHeader&&_>0){let E=g;l===a.RANGE_TYPE.COLUMN&&(E=new a.ColorKit(u).setAlpha(Gs).toString()),this._columnHeaderBackground.setProps({fill:E}),this._columnHeaderBackground.resize(r-t,_),this._columnHeaderBorder.setProps({fill:f}),this._columnHeaderBorder.transformByState({width:r-t,height:v,top:_-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 E=h;l===a.RANGE_TYPE.ROW&&(E=new a.ColorKit(u).setAlpha(Gs).toString()),this._rowHeaderBackground.setProps({fill:E}),this._rowHeaderBackground.resize(C,s-i),this._rowHeaderBorder.setProps({fill:S}),this._rowHeaderBorder.transformByState({width:p,height:s-i,left:C-p+1/d}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,i)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){const{startX:t,startY:i,endX:r,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(r-t,s-i),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:S,endX:g,endY:f}=u,p=d/2,v={left:-p,top:-p,width:r-t+p*2,height:S-i+p};v.height<0&&(v.width=0,v.height=0),this._backgroundControlTop.transformByState(v);const C={left:-p,top:S-i,width:h-t+p,height:f-S};C.width<0&&(C.width=0,C.height=0),this._backgroundControlMiddleLeft.transformByState(C);const _={left:g-t-p,top:S-i,width:r-g+p*2,height:f-S};_.width<0&&(_.width=0,_.height=0),this._backgroundControlMiddleRight.transformByState(_);const E={left:-p,top:f-i,width:r-t+p*2,height:s-f+p};E.height<0&&(E.width=0,E.height=0),this._backgroundControlBottom.transformByState(E),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:i,endX:r,endY:s}=this._selectionRenderModel,{stroke:l=e.stroke,widgets:c=e.widgets,widgetStroke:d=e.widgetStroke}=e,u=this._getScale();let{widgetSize:h,widgetStrokeWidth:S}=e;h/=u,S/=u;const g={left:-h/2+S/2,center:(r-t)/2-h/2+S/2,right:r-t-h/2+S/2,top:-h/2,middle:(s-i)/2-h/2,bottom:s-i-h/2+S/2},f=h-S;this._widgetRects.forEach(p=>{p.setProps({fill:l,stroke:d})}),c.tl===!0?(this._topLeftWidget.transformByState({height:f,width:f,left:g.left,top:g.top,strokeWidth:S}),this._topLeftWidget.show()):this._topLeftWidget.hide(),c.tc===!0?(this._topCenterWidget.transformByState({height:f,width:f,left:g.center,top:g.top,strokeWidth:S}),this._topCenterWidget.show()):this._topCenterWidget.hide(),c.tr===!0?(this._topRightWidget.transformByState({height:f,width:f,left:g.right,top:g.top,strokeWidth:S}),this._topRightWidget.show()):this._topRightWidget.hide(),c.ml===!0?(this._middleLeftWidget.transformByState({height:f,width:f,left:g.left,top:g.middle,strokeWidth:S}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),c.mr===!0?(this._middleRightWidget.transformByState({height:f,width:f,left:g.right,top:g.middle,strokeWidth:S}),this._middleRightWidget.show()):this._middleRightWidget.hide(),c.bl===!0?(this._bottomLeftWidget.transformByState({height:f,width:f,left:g.left,top:g.bottom,strokeWidth:S}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),c.bc===!0?(this._bottomCenterWidget.transformByState({height:f,width:f,left:g.center,top:g.bottom,strokeWidth:S}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),c.br===!0?(this._bottomRightWidget.transformByState({height:f,width:f,left:g.right,top:g.bottom,strokeWidth:S}),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 i of t)if(e[i]===!0)return!0;return!1}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}_stopAntLineAnimation(){this._antLineOffset=0,M.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=M.requestNewFrame(()=>{this._startAntLineAnimation()})}}class hd extends M.Layer{render(o,e=!1){const t=a.Tools.now();return super.render(o,e),this._afterRender(t),this}_afterRender(o){this.scene.getEngine().renderFrameTimeMetric$.next(["selectionLayer",a.Tools.now()-o])}}const ve=a.createIdentifier("univer.sheet.selection-render-service");class Jo extends a.Disposable{constructor(e,t,i,r,s){super();w(this,"_downObserver");w(this,"_scenePointerMoveSub");w(this,"_scenePointerUpSub");w(this,"_controlFillConfig$",new k.BehaviorSubject(null));w(this,"controlFillConfig$",this._controlFillConfig$.asObservable());w(this,"_selectionControls",[]);w(this,"_startRangeWhenPointerDown",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});w(this,"_activeControlIndex",-1);w(this,"_startViewportPosX",0);w(this,"_startViewportPosY",0);w(this,"_scrollTimer");w(this,"_cancelDownSubscription");w(this,"_cancelUpSubscription");w(this,"_skeleton");w(this,"_scene");w(this,"_highlightHeader",!0);w(this,"_rangeType",a.RANGE_TYPE.NORMAL);w(this,"_selectionStyle");w(this,"_remainLastEnabled",!1);w(this,"_skipLastEnabled",!1);w(this,"_singleSelectionEnabled",!1);w(this,"_selectionMoveEnd$",new k.BehaviorSubject([]));w(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());w(this,"_selectionMoving$",new k.Subject);w(this,"selectionMoving$",this._selectionMoving$.asObservable());w(this,"_selectionMoveStart$",new k.Subject);w(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());w(this,"_selectionMoving",!1);w(this,"_selectionTheme");w(this,"_activeViewport");w(this,"interceptor",new a.InterceptorManager({RANGE_MOVE_PERMISSION_CHECK:Zo,RANGE_FILL_PERMISSION_CHECK:Ko}));w(this,"_escapeShortcutDisposable",null);this._injector=e,this._themeService=t,this._shortcutService=i,this._sheetSkeletonManagerService=r,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,i){const r=this.getSelectionControls().length,{rowHeaderWidth:s,columnHeaderHeight:l}=t,c=new xn(e,r,this._selectionTheme,{highlightHeader:this._highlightHeader,rowHeaderWidth:s,columnHeaderHeight:l});this._selectionControls.push(c);const d=Re(i,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(),i=this._skeleton;if(!(!t||!i)){for(let r=0,s=e.length;r<s;r++){const l=e[r],c=Re(l,this._skeleton),d=t[r];d?d.updateRangeBySelectionWithCoord(c,i):this.isSelectionEnabled()&&this.newSelectionControl(this._scene,i,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,i){this._skeleton=e,this._scene=t,this._activeViewport=i||(t==null?void 0:t.getViewports()[0]),t.findLayerByZIndex(Bi)||t.addLayer(new hd(t,[],Bi))}getSkeleton(){return this._skeleton}getSelectionDataWithStyle(){const e=this._selectionControls,[t,i]=this._skeleton.getLocation();return e.map(r=>{const s=r.getValue();return s.rangeWithCoord.sheetId=i,s.rangeWithCoord.unitId=t,s})}getSelectionControls(){return this._selectionControls}_addSelectionControlByModelData(e){var l;const t=this._skeleton,i=(l=e.style)!=null?l:pt(this._selectionTheme),r=this._scene;return e.style=i,this.newSelectionControl(r,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 i=this._getFreeze();if(!i||i.startRow<=0&&i.startColumn<=0)return this._scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(e>i.startRow&&t>i.startColumn)return this._scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(e<=i.startRow&&t<=i.startColumn)return this._scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP);if(e<=i.startRow&&t>i.startColumn)return this._scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(e>i.startRow&&t<=i.startColumn)return this._scene.getViewport(M.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,i,r=M.ScrollTimerType.ALL,s,l){var f,p;let c=0,d=0,u=s,h=l;this._scrollTimer=M.ScrollTimer.create(this._scene,r),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 S=this._scene,g=S.getActiveViewportByCoord(M.Vector2.FromArray([s,l]));this._scenePointerMoveSub=S.onPointerMove$.subscribeEvent(v=>{var W,U,V,B,x,z,F,Y,X;const{offsetX:C,offsetY:_}=v,{x:E,y:T}=S.getCoordRelativeToViewport(M.Vector2.FromArray([C,_]));this._movingHandler(E,T,t,i);let P=E,R=T;const O=this.getActiveSelectionControl(),A=this._getFreeze(),N=O==null?void 0:O.model,D=(W=S.getActiveViewportByCoord(M.Vector2.FromArray([C,_])))!=null?W:this._getViewportByCell(N==null?void 0:N.endRow,N==null?void 0:N.endColumn);if((()=>{if(!g||!D||!e)return!1;const Z=[M.SHEET_VIEWPORT_KEY.VIEW_MAIN,M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP,M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP,M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT];return Z.includes(g.viewportKey)&&Z.includes(D.viewportKey)})()){if(!g||!D||!e)return!1;const Z=u<e.left&&E>e.left||u>e.left&&E<e.left,ne=h<e.top&&T>e.top||h>e.top&&T<e.top;Z&&(c+=1),ne&&(d+=1);const J=g.viewportKey,ae=D.viewportKey;if(J===M.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP)_<e.top&&((U=N==null?void 0:N.endRow)!=null?U:0)<((V=A==null?void 0:A.startRow)!=null?V:0)?R=e.top:ne&&d%2===1&&e.scrollToViewportPos({viewportScrollY:0});else if(J===M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT)C<e.left&&((B=N==null?void 0:N.endColumn)!=null?B:0)<((x=A==null?void 0:A.startColumn)!=null?x:0)?P=e.left:Z&&c%2===1&&e.scrollToViewportPos({viewportScrollX:0});else if(J===ae){let ue=!1,j=!1;J===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP?(ue=!0,j=!0):J===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP?j=!0:J===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT&&(ue=!0),((z=N==null?void 0:N.endRow)!=null?z:0)>((F=A==null?void 0:A.startRow)!=null?F:0)&&(j=!1),((Y=N==null?void 0:N.endColumn)!=null?Y:0)>((X=A==null?void 0:A.startColumn)!=null?X:0)&&(ue=!1),ue&&(P=e.left),j&&(R=e.top)}else{const ue={x:g.scrollX,y:g.scrollY},j={x:D.scrollX,y:D.scrollY},K=ue.x!==j.x&&Z&&c%2===1,$=ue.y!==j.y&&ne&&d%2===1;(K||$)&&(e.scrollToBarPos({x:K?ue.x:void 0,y:$?ue.y:void 0}),K||(P=e.left),$||(R=e.top)),(J===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&ae===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT||ae===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&J===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)&&(P=e.left),(J===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&ae===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP||ae===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&J===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP)&&(R=e.top)}u=E,h=T}this._scrollTimer.scrolling(P,R,()=>{this._movingHandler(E,T,t,i)})})}attachSelectionWithCoord(e){return Re(e,this._skeleton)}attachPrimaryWithCoord(e){return Bn(this._skeleton,e)}getSelectionCellByPosition(e,t){return this.getCellWithCoordByOffset(e,t)}getCellWithCoordByOffset(e,t,i){const r=this._scene,s=i!=null?i:this._skeleton,l=r.getViewportScrollXY(r.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN)),{scaleX:c,scaleY:d}=r.getAncestorScale();return s.getCellWithCoordByOffset(e,t,c,d,l)}_movingHandler(e,t,i,r){var P,R,O,A,N;const s=this._skeleton,l=this._scene,[c,d]=s.getLocation(),u={startRow:(P=i==null?void 0:i.model.startRow)!=null?P:-1,endRow:(R=i==null?void 0:i.model.endRow)!=null?R:-1,startColumn:(O=i==null?void 0:i.model.startColumn)!=null?O:-1,endColumn:(A=i==null?void 0:i.model.endColumn)!=null?A:-1},h=l.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN),S=(N=this._getViewportByCell(u.endRow,u.endColumn))!=null?N:h,g=l.getScrollXYInfoByViewport(M.Vector2.FromArray([this._startViewportPosX,this._startViewportPosY]),S),{scaleX:f,scaleY:p}=l.getAncestorScale();r===a.RANGE_TYPE.ROW?e=Number.POSITIVE_INFINITY:r===a.RANGE_TYPE.COLUMN&&(t=Number.POSITIVE_INFINITY);const v=this._skeleton.getCellByOffset(e,t,f,p,g);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 E=Re({range:C,primary:void 0,style:null},s);E.rangeWithCoord.unitId=c,E.rangeWithCoord.sheetId=d,E.rangeWithCoord.rangeType=r;const T=u.startRow!==C.startRow||u.startColumn!==C.startColumn||u.endRow!==C.endRow||u.endColumn!==C.endColumn;i!=null&&T&&(i.updateRangeBySelectionWithCoord(E),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_clearUpdatingListeners(){var t,i,r,s,l;this._scene.enableObjectsEvent(),(t=this._scenePointerMoveSub)==null||t.unsubscribe(),this._scenePointerMoveSub=null,(i=this._scenePointerUpSub)==null||i.unsubscribe(),this._scenePointerUpSub=null,(r=this._cancelDownSubscription)==null||r.unsubscribe(),this._cancelDownSubscription=null,(s=this._cancelUpSubscription)==null||s.unsubscribe(),this._cancelUpSubscription=null,(l=this._scrollTimer)==null||l.dispose()}_addEndingListeners(){var i,r,s;const e=this._scene,t=(i=e.getEngine())==null?void 0:i.activeScene;!t||t===e||((r=this._cancelDownSubscription)==null||r.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,i,r,s){const l=this._skeleton;if(l==null)return null;if(this._shouldDetectMergedCells){const C=l==null?void 0:l.getCellWithCoordByOffset(e,t,i,r,s,{firstMatch:!0});if(!C)return;const _=a.convertCellToRange(C);return{primaryWithCoord:C,rangeWithCoord:_}}const{row:c,column:d}=l.getCellIndexByOffset(e,t,i,r,s),u=l.getNoMergeCellWithCoordByIndex(c,d),{startX:h,startY:S,endX:g,endY:f}=u,p={startY:S,endY:f,startX:h,endX:g,startRow:c,endRow:c,startColumn:d,endColumn:d};return{primaryWithCoord:{mergeInfo:p,actualRow:c,actualColumn:d,isMerged:!1,isMergedMainCell:!1,startY:S,endY:f,startX:h,endX:g},rangeWithCoord:p}}_checkClearPreviousControls(e){this.getSelectionControls().length!==0&&(!e.ctrlKey&&!e.shiftKey&&!this._remainLastEnabled||this._singleSelectionEnabled&&!e.shiftKey)&&this._clearAllSelectionControls()}_makeSelectionByTwoCells(e,t,i,r,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),S=Math.min(c,t.startColumn,d.startColumn),g=Math.max(c,t.endColumn,d.endColumn),p={range:i.expandRangeByMerge({startRow:u,startColumn:S,endRow:h,endColumn:g}),primary:null,style:null},v=Re(p,i);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 $o(n){return{range:{startRow:0,startColumn:0,endRow:n.getRowCount()-1,endColumn:n.getColumnCount()-1,rangeType:a.RANGE_TYPE.ALL},primary:zi(n).primary,style:null}}function zi(n){return Zs(n,{startRow:0,startColumn:0,endRow:0,endColumn:0})}function Zs(n,o){const e=n.worksheet.getCellInfoInMergeData(o.startRow,o.startColumn),t=n.worksheet.getCellInfoInMergeData(o.endRow,o.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 md=Object.getOwnPropertyDescriptor,Sd=(n,o,e,t)=>{for(var i=t>1?void 0:t?md(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},Ks=(n,o)=>(e,t)=>o(e,t,n);y.SheetSkeletonManagerService=class extends a.Disposable{constructor(e,t,i){super();w(this,"_sheetId","");w(this,"_sheetSkeletonParamStore",new Map);w(this,"_currentSkeleton$",new k.BehaviorSubject(null));w(this,"currentSkeleton$",this._currentSkeleton$.asObservable());w(this,"_currentSkeletonBefore$",new k.BehaviorSubject(null));w(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._context=e,this._injector=t,this._sheetSkService=i,this.disposeWithMe(()=>{this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParamStore.forEach(r=>this.disposeSkeleton(r.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 i=this._getSkeletonParam(t);return i!=null&&(i.unitId=e),i}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),i=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:i,sheetId:e,skeleton:d,dirty:!1})}const r=this._getSkeletonParam(e);this._currentSkeletonBefore$.next(r),this._currentSkeleton$.next(r)}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 i=this._getSkeletonParam(e.sheetId);i!=null&&(i.dirty=t)}getOrCreateSkeleton(e){return this.ensureSkeleton(e.sheetId)}ensureSkeleton(e){const t=this._getSkeletonParam(e);if(t)return t.skeleton;const r=this._context.unit.getSheetBySheetId(e);if(!r)return;const s=this._buildSkeleton(r);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?on(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(M.SpreadsheetSkeleton,e,this._context.unit.getStyles())}setColumnHeaderSize(e,t,i){var u;if(!e)return;const r=(u=this.getWorksheetSkeleton(t))==null?void 0:u.skeleton;if(!r)return;r.columnHeaderHeight=i,e.scene.getViewports()[0].top=i,e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).setViewportSize({height:i}),e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT).setViewportSize({height:i}),e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM).setViewportSize({top:i}),e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP).setViewportSize({top:i}),e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).setViewportSize({height:i});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=Fi.id,this._currentSkeleton$.next(d))}setRowHeaderSize(e,t,i){var f;const r=(f=this.getWorksheetSkeleton(t))==null?void 0:f.skeleton;if(!e||!r)return;r.rowHeaderWidth=i;const s=e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).width||46,l=i-s,c=e.scene.getViewports()[0].left;e.scene.getViewports()[0].left=c+l,e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM).setViewportSize({width:i}),e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP).setViewportSize({width:i}),e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT).setViewportSize({left:i});const d=e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).left||0;e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).setViewportSize({left:d+l}),e.scene.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).setViewportSize({width:i});const u=e==null?void 0:e.with(m.SheetsSelectionsService),h=e==null?void 0:e.with(ve),S=u.getCurrentSelections();h.resetSelectionsByModelData(S);const g=this.getCurrent();g&&(g.commandId=xi.id,this._currentSkeleton$.next(g))}},y.SheetSkeletonManagerService=Sd([Ks(1,a.Inject(a.Injector)),Ks(2,a.Inject(m.SheetSkeletonService))],y.SheetSkeletonManagerService);function ot(){const n=I.useDependency(a.IUniverInstanceService),o=I.useObservable(()=>n.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return o!=null?o:null}function gd(n){return I.useObservable(()=>{var e;return(e=n==null?void 0:n.activeSheet$)!=null?e:k.of(null)},void 0,void 0,[n])}function fd(){const n=I.useDependency(a.IUniverInstanceService);return I.useObservable(()=>k.merge([n.getTypeOfUnitAdded$(a.UniverInstanceType.UNIVER_SHEET),n.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET)]).pipe(k.map(()=>n.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET)),k.startWith(n.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET))),[],void 0,[n])}const pd="SheetUI";var er=(n=>(n.FILTER_PANEL_EMBED_POINT="filter-panel-embed-point",n.SHEETS_FOOTER="sheets-footer",n.FORMULA_AUX="formula-aux",n))(er||{});const Ke="sheets-ui.config",tr={formulaBar:!0,statusBarStatistic:!0,maxAutoHeightCount:1e3};var vd=Object.getOwnPropertyDescriptor,Cd=(n,o,e,t)=>{for(var i=t>1?void 0:t?vd(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},Fn=(n,o)=>(e,t)=>o(e,t,n);const nr=["ff","fs","tr","tb"];y.AutoHeightController=class extends a.Disposable{constructor(o,e,t,i,r){super(),this._renderManagerService=o,this._sheetInterceptorService=e,this._selectionManagerService=t,this._univerInstanceService=i,this._configService=r,this._initialize()}_getRangesScope(o){let e,t;for(const{startRow:i,endRow:r}of o)e=e===void 0?i:Math.min(e,i),t=t===void 0?r:Math.max(t,r);return t-e+1}getUndoRedoParamsOfAutoHeight(o,e){var _;const{_univerInstanceService:t,_configService:i}=this,r=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=r.getUnitId();let l=r.getActiveSheet(),c=l.getSheetId();if(e){const E=m.getSheetCommandTarget(t,{unitId:s,subUnitId:e});E&&(l=E.worksheet,c=l.getSheetId())}const u=this._renderManagerService.getRenderById(s).with(y.SheetSkeletonManagerService).ensureSkeleton(c);if(!u)return{redos:[],undos:[]};const h=i.getConfig(Ke);let S=o;Array.isArray(o)||(o&&o.startRow!==void 0&&o.startRow!==void 0?S=[o]:S=[]);const g=this._getRangesScope(S);if(((_=h==null?void 0:h.maxAutoHeightCount)!=null?_:1e3)<g)return{redos:[],undos:[]};const p=u.calculateAutoHeightInRange(o),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:o,_selectionManagerService:e}=this;this.disposeWithMe(o.interceptCommand({getMutations:t=>{if(t.id===m.SetRangeValuesCommand.id){const i=t.params;return this.getUndoRedoParamsOfAutoHeight(i.range,i.subUnitId)}return{redos:[],undos:[]}}})),this.disposeWithMe(o.interceptCommand({getMutations:t=>t.id!==m.SetWorksheetRowIsAutoHeightCommand.id?{redos:[],undos:[]}:this.getUndoRedoParamsOfAutoHeight(t.params.ranges,t.params.subUnitId)})),this.disposeWithMe(o.interceptCommand({getMutations:t=>{var r,s;if(t.id!==m.SetStyleCommand.id)return{redos:[],undos:[]};if(!nr.includes((r=t.params)==null?void 0:r.style.type))return{redos:[],undos:[]};const i=(s=e.getCurrentSelections())==null?void 0:s.map(l=>l.range);return i!=null&&i.length?this.getUndoRedoParamsOfAutoHeight(i,t.params.subUnitId):{redos:[],undos:[]}}})),this.disposeWithMe(o.interceptAfterCommand({getMutations:t=>{if(t.id===m.MoveRangeCommand.id){const i=t.params;return this.getUndoRedoParamsOfAutoHeight([i.fromRange,i.toRange])}if(t.id===m.ReorderRangeCommand.id){const i=t.params;return this.getUndoRedoParamsOfAutoHeight([i.range])}return{redos:[],undos:[]}}}))}},y.AutoHeightController=Cd([Fn(0,M.IRenderManagerService),Fn(1,a.Inject(m.SheetInterceptorService)),Fn(2,a.Inject(m.SheetsSelectionsService)),Fn(3,a.Inject(a.IUniverInstanceService)),Fn(4,a.IConfigService)],y.AutoHeightController);function vt(n){const{rows:o,cols:e}=n;return{startRow:o[0],endRow:o[o.length-1],startColumn:e[0],endColumn:e[e.length-1]}}function Ot(n){let o=[],e=[];const t=[];return n.forEach(i=>{o=o.concat(i.rows),e=e.concat(i.cols)}),o=Array.from(new Set(o)).sort((i,r)=>i-r),e=Array.from(new Set(e)).sort((i,r)=>i-r),n.forEach(i=>{t.push({startRow:o.findIndex(r=>r===i.rows[0]),endRow:o.findIndex(r=>r===i.rows[i.rows.length-1]),startColumn:e.findIndex(r=>r===i.cols[0]),endColumn:e.findIndex(r=>r===i.cols[i.cols.length-1])})}),{ranges:t,mapFunc:(i,r)=>({row:o[i],col:e[r]})}}function Id(n){const o=new a.ObjectMatrix;return n.forEach(e=>{const{rows:t,cols:i}=e;t.forEach(r=>{i.forEach(s=>{o.setValue(r,s,{v:null,p:null,f:null,si:null,custom:null})})})}),o.getData()}const ir={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},Xi=["零","一","二","三","四","五","六","七","八","九"],qs=["","万","亿","万亿","亿亿"],_d=["","十","百","千"],Qs={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function rt(n){if(!n)return 0;let o=0,e=0,t=0,i=!1;const r=n.split("");for(let s=0;s<r.length;s++){const l=ir[r[s]];if(typeof l<"u")t=l,s===r.length-1&&(e+=t);else{const c=Qs[r[s]],d=c.value;i=c.secUnit,i?(e=(e+t)*d,o+=e,e=0):e+=t*d,t=0}}return o+e}function bd(n){let o="",e="",t=0,i=!0;for(;n>0;){const r=n%10;r===0?i||(i=!0,e=Xi[r]+e):(i=!1,o=Xi[r],o+=_d[t],e=o+e),t++,n=Math.floor(n/10)}return e}function Ed(n){let o=0,e="",t="",i=!1;if(n===0)return Xi[0];for(;n>0;){const r=n%1e4;i&&(t=Xi[0]+t),e=bd(r),e+=r!==0?qs[o]:qs[0],t=e+t,i=r<1e3&&r>0,n=Math.floor(n/1e4),o++}return t}function wd(n){if(!n)return!1;let o=!0;if(n)if(n.length===1)n==="日"||n in ir?o=!0:o=!1;else{const e=n.split("");for(let t=0;t<e.length;t++)if(!(e[t]in ir||e[t]in Qs)){o=!1;break}}return o}function Yi(n){if(!n)return{isExtendNumber:!1};const o=/0|([1-9]+[0-9]*)/g,e=o.test(n);if(e){const t=n.match(o);if(t&&t.length>0){const i=t[t.length-1],r=n.lastIndexOf(i),s=n.substr(0,r),l=n.substr(r+i.length);return{isExtendNumber:!0,matchTxt:Number(i),beforeTxt:s,afterTxt:l}}return{isExtendNumber:!1}}return{isExtendNumber:e}}function Td(n){let o;return n.length===2&&(n==="周一"||n==="周二"||n==="周三"||n==="周四"||n==="周五"||n==="周六"||n==="周日")?o=!0:o=!1,o}function yd(n){let o;return n.length===3&&(n==="星期一"||n==="星期二"||n==="星期三"||n==="星期四"||n==="星期五"||n==="星期六"||n==="星期日")?o=!0:o=!1,o}function Md(n,o){let e=0;for(let t=0;t<n.length&&n[t]<o;t++)e++;return e}function zn(n){let o=!0;const e=n[1]-n[0];for(let t=1;t<n.length;t++)if(n[t]-n[t-1]!==e){o=!1;break}return o}function Rd(n,o,e){const t=[],i=Math.floor(o/n),r=o%n;let s=0;if(i>0){for(let l=0;l<i;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]<r;l++)t[e[l]+n*i]=s,s++}else for(let l=0;l<e.length&&e[l]<r;l++)t[e[l]]=s,s++;return t}function At(n,o){const e=[];for(let t=1;t<=o;t++){const i=(t-1)%n.length,r=a.Tools.deepClone(n[i]);kt(r),e.push({v:null,s:null,p:null,f:null,si:null,t:null,...r})}return e}function Pd(n,o){var t;const e=[];for(let i=1;i<=o;i++){const r=(i-1)%n.length,s={s:(t=n[r])==null?void 0:t.s};e.push(s)}return e}function Od(n){let o=!0;const e=n[1]/n[0];for(let t=1;t<n.length;t++)if(n[t]/n[t-1]!==e){o=!1;break}return o}function Ad(n){const o=[];for(let e=1;e<=n;e++)o.push(e);return o}function ji(n,o,e){var r,s,l,c;const t=[],i=[];for(let d=0;d<n.length;d++)i.push(Number((r=n[d])==null?void 0:r.v));if(n.length>2&&Od(i))for(let d=1;d<=o;d++){const u=(d-1)%n.length,h=a.Tools.deepClone(n[u]);kt(h);const S=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&&(ta(h)&&(h.v=S),t.push(h))}else{const d=Ad(n.length);for(let u=1;u<=o;u++){const h=(u-1)%n.length,S=a.Tools.deepClone(n[h]);kt(S);const g=e===a.Direction.DOWN||e===a.Direction.RIGHT,f=kd(n.length+u,i,d,g);S&&(ta(S)&&(S.v=f),t.push(S))}}return t}function kd(n,o,e,t=!0){function i(h){let S=0;for(let g=0;g<h.length;g++)S+=h[g];return S/h.length}const r=i(e),s=i(o);let l=0,c=0;for(let h=0;h<e.length;h++)l+=(e[h]-r)*(o[h]-s),c+=(e[h]-r)*(e[h]-r);let d;c===0?d=t?1:-1:d=l/c;const u=s-d*r;return Math.round((u+d*n)*1e5)/1e5}function Js(n,o,e){var r;const t=[],i=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=o;s++){const l=(s-1)%n.length,c=a.Tools.deepClone(n[l]);kt(c);const d=`${(r=n[n.length-1])==null?void 0:r.v}`,u=d==null?void 0:d.match(i),h=u==null?void 0:u[u.length-1],S=Math.abs(Number(h)+e*s);if(!d||!h)continue;const g=d.lastIndexOf(h),f=d.substr(0,g)+S.toString()+d.substr(g+h.length);c&&(c.v=f,t.push(c))}return t}function rn(n,o,e,t=0){var l,c;const i=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(t>=i.length)return[];const r=i[t],s=[];for(let d=1;d<=o;d++){const u=(d-1)%n.length,h=a.Tools.deepClone(n[u]);kt(h);let S=0;if(((l=n[n.length-1])==null?void 0:l.v)===r[0])S=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);S=rt(p)+e*d}}S<0&&(S=Math.ceil(Math.abs(S)/7)*7+S);const g=S%7;h&&(h.v=r[g],s.push(h))}return s}function $s(n,o,e){var i;const t=[];for(let r=1;r<=o;r++){const s=(r-1)%n.length,l=a.Tools.deepClone(n[s]);kt(l);const c=`${(i=n[n.length-1])==null?void 0:i.v}`,d=rt(c)+e*r;let u;d<=0?u="零":u=Ed(d),l&&(l.v=u,t.push(l))}return t}const Xn={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 Dd(n){let o=!1;return Object.keys(Xn).forEach(e=>{Xn[e].includes(n)&&(o=!0)}),o}function or(n){let o="";const e=[];return Object.keys(Xn).forEach(t=>{Xn[t].includes(n)&&(o=t,e.push(...Xn[t]))}),{name:o,series:e}}function ea(n,o,e,t){var s;const i=t.length,r=[];for(let l=1;l<=o;l++){const c=(l-1)%n.length,d=a.Tools.deepClone(n[c]);kt(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)*i);const S=h%i;d&&(d.v=t[S],r.push(d))}return r}function Nd(n,o){const e=[];let t;if(o.startRow<n.startRow)t=a.Direction.UP;else if(o.endRow>n.endRow)t=a.Direction.DOWN;else if(o.startColumn<n.startColumn)t=a.Direction.LEFT;else if(o.endColumn>n.endColumn)t=a.Direction.RIGHT;else return[];if(t===a.Direction.DOWN||t===a.Direction.UP){const i=n.endRow-n.startRow+1,r=o.endRow-o.startRow+1,s=Math.floor(r/i),l=r%i,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)*i,col:n.startColumn},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow+(s+1)*i,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)*i,col:n.startColumn},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow-(s+1)*i,col:n.startColumn},relativeRange:{startRow:i-l,endRow:i-1,startColumn:0,endColumn:n.endColumn-n.startColumn}})}}if(t===a.Direction.RIGHT||t===a.Direction.LEFT){const i=n.endColumn-n.startColumn+1,r=o.endColumn-o.startColumn+1,s=Math.floor(r/i),l=r%i,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)*i},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow,col:n.startColumn+(s+1)*i},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)*i},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow,col:n.startColumn-(s+1)*i},relativeRange:{startRow:0,startColumn:i-l,endRow:n.endRow-n.startRow,endColumn:i-1}})}}return e}function ta(n){return!(a.isFormulaString(n.f)||a.isFormulaId(n.si)||n.t===a.CellValueType.BOOLEAN)}function kt(n){n&&"custom"in n&&delete n.custom}var sn=(n=>(n.Append="APPEND",n.Default="DEFAULT",n.Only="ONLY",n))(sn||{}),_e=(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))(_e||{}),de=(n=>(n.COPY="COPY",n.SERIES="SERIES",n.ONLY_FORMAT="ONLY_FORMAT",n.NO_FORMAT="NO_FORMAT",n))(de||{});const Hd={type:_e.DATE,priority:1100,match:(n,o)=>{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 i=o.get(a.IUniverInstanceService).getFocusedUnit().getStyles().get(n.s),r=(e=i==null?void 0:i.n)==null?void 0:e.pattern;if(r)return a.numfmt.getInfo(r).isDate}else if(n.s.n&&a.numfmt.getInfo(n.s.n.pattern).isDate)return!0}return!1},isContinue:(n,o)=>n.type===_e.DATE,applyFunctions:{[de.SERIES]:(n,o,e)=>{const{data:t}=n;return e===a.Direction.LEFT||e===a.Direction.UP?(t.reverse(),ji(t,o,e).reverse()):ji(t,o,e)}}},Vd={type:_e.NUMBER,priority:1e3,match:n=>typeof(n==null?void 0:n.v)=="number"||(n==null?void 0:n.t)===a.CellValueType.NUMBER,isContinue:(n,o)=>n.type===_e.NUMBER,applyFunctions:{[de.SERIES]:(n,o,e)=>{const{data:t}=n;return e===a.Direction.LEFT||e===a.Direction.UP?(t.reverse(),ji(t,o,e).reverse()):ji(t,o,e)}}},na={type:_e.OTHER,priority:0,match:()=>!0,isContinue:(n,o)=>n.type===_e.OTHER},Wd={type:_e.EXTEND_NUMBER,priority:900,match:n=>Yi(`${n==null?void 0:n.v}`||"").isExtendNumber,isContinue:(n,o)=>{var e;if(n.type===_e.EXTEND_NUMBER){const{beforeTxt:t,afterTxt:i}=Yi(`${(e=n.cellData)==null?void 0:e.v}`||""),{beforeTxt:r,afterTxt:s}=Yi(`${o==null?void 0:o.v}`||"");if(t===r&&i===s)return!0}return!1},applyFunctions:{[de.SERIES]:(n,o,e)=>{var l;const{data:t}=n,i=e===a.Direction.UP||e===a.Direction.LEFT;let r;if(t.length===1)return r=i?-1:1,We(Js(t,o,r),i);const s=[];for(let c=0;c<t.length;c++){const d=`${(l=t[c])==null?void 0:l.v}`;d&&s.push(Number(Yi(d).matchTxt))}return i&&(t.reverse(),s.reverse()),zn(s)?(r=s[1]-s[0],We(Js(t,o,r),i)):At(t,o)}}},Ld={type:_e.CHN_NUMBER,priority:830,match:n=>!!wd(`${n==null?void 0:n.v}`||""),isContinue:(n,o)=>n.type===_e.CHN_NUMBER,applyFunctions:{[de.SERIES]:(n,o,e)=>{var c,d,u;const{data:t}=n,i=e===a.Direction.LEFT||e===a.Direction.UP;if(t.length===1){const h=`${(c=t[0])==null?void 0:c.v}`;let S;return i?S=-1:S=1,h&&(h==="日"||rt(h)<7)?We(rn(t,o,S),i):We($s(t,o,S),i)}let r=!1;for(let h=0;h<t.length;h++)if(((d=t[h])==null?void 0:d.v)==="日"){r=!0;break}const s=[];let l=0;for(let h=0;h<t.length;h++){const S=`${(u=t[h])==null?void 0:u.v}`;S==="日"?h===0?s.push(0):(l++,s.push(l*7)):r&&rt(S)>0&&rt(S)<7?s.push(rt(S)+l*7):s.push(rt(S))}if(i&&(t.reverse(),s.reverse()),zn(s)){if(r||s[s.length-1]<6&&s[0]>0||s[0]<6&&s[s.length-1]>0){const S=s[1]-s[0];return We(rn(t,o,S),i)}const h=s[1]-s[0];return We($s(t,o,h),i)}return At(t,o)}}},Ud={type:_e.CHN_WEEK2,priority:820,match:n=>!!Td(`${n==null?void 0:n.v}`||""),isContinue:(n,o)=>n.type===_e.CHN_WEEK2,applyFunctions:{[de.SERIES]:(n,o,e)=>{var l;const{data:t}=n,i=e===a.Direction.LEFT||e===a.Direction.UP;if(t.length===1){let c;return i?c=-1:c=1,We(rn(t,o,c,1),i)}const r=[];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?r.push(0):(s++,r.push(s*7)):r.push(rt(u)+s*7)}if(i&&(t.reverse(),r.reverse()),zn(r)){const c=r[1]-r[0];return We(rn(t,o,c,1),i)}return At(t,o)}}},Bd={type:_e.CHN_WEEK3,priority:810,match:n=>yd(`${n==null?void 0:n.v}`||""),isContinue:(n,o)=>n.type===_e.CHN_WEEK3,applyFunctions:{[de.SERIES]:(n,o,e)=>{var l;const{data:t}=n,i=e===a.Direction.LEFT||e===a.Direction.UP;if(t.length===1){let c;return i?c=-1:c=1,We(rn(t,o,c,2),i)}const r=[];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?r.push(0):(s++,r.push(s*7)):r.push(rt(u)+s*7)}}if(i&&(t.reverse(),r.reverse()),zn(r)){const c=r[1]-r[0];return We(rn(t,o,c,2),i)}return At(t,o)}}},xd={type:_e.LOOP_SERIES,priority:800,match:n=>Dd(`${n==null?void 0:n.v}`||""),isContinue:(n,o)=>{var e;return n.type===_e.LOOP_SERIES?or(`${(e=n.cellData)==null?void 0:e.v}`||"").name===or(`${o==null?void 0:o.v}`||"").name:!1},applyFunctions:{[de.SERIES]:(n,o,e)=>{var c,d;const{data:t}=n,i=e===a.Direction.LEFT||e===a.Direction.UP,{series:r}=or(`${(c=t[0])==null?void 0:c.v}`||"");if(t.length===1){let u;return i?u=-1:u=1,We(ea(t,o,u,r),i)}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===r[0]?u===0?s.push(0):(l++,s.push(l*r.length)):s.push(r.indexOf(h)+l*7))}if(i&&(t.reverse(),s.reverse()),zn(s)){const u=s[1]-s[0];return We(ea(t,o,u,r),i)}return At(t,o)}}};function We(n,o){return o?n.reverse():n}var Fd=Object.getOwnPropertyDescriptor,zd=(n,o,e,t)=>{for(var i=t>1?void 0:t?Fd(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},an=(n,o)=>(e,t)=>o(e,t,n);y.AutoFillService=class extends a.Disposable{constructor(e,t,i,r,s,l){super();w(this,"_rules",[]);w(this,"_hooks",[]);w(this,"_applyType$",new k.BehaviorSubject(de.SERIES));w(this,"_isFillingStyle",!0);w(this,"_prevUndos",[]);w(this,"_autoFillLocation$",new k.BehaviorSubject(null));w(this,"autoFillLocation$",this._autoFillLocation$.asObservable());w(this,"_showMenu$",new k.BehaviorSubject(!1));w(this,"showMenu$",this._showMenu$.asObservable());w(this,"_direction",a.Direction.DOWN);w(this,"applyType$",this._applyType$.asObservable());w(this,"_menu$",new k.BehaviorSubject([{label:"autoFill.copy",value:de.COPY,disable:!1},{label:"autoFill.series",value:de.SERIES,disable:!1},{label:"autoFill.formatOnly",value:de.ONLY_FORMAT,disable:!1},{label:"autoFill.noFormat",value:de.NO_FORMAT,disable:!1}]));w(this,"menu$",this._menu$.asObservable());this._commandService=e,this._undoRedoService=t,this._renderManagerService=i,this._univerInstanceService=r,this._selectionManagerService=s,this._injector=l,this._init()}_init(){this._rules=[Hd,Vd,Wd,Ld,Ud,Bd,xd,na].sort((e,t)=>t.priority-e.priority),this._isFillingStyle=!0}_getOneByPriority(e){return e.length<=0?[]:[e.reduce((i,r)=>(r.priority||0)>(i.priority||0)?r:i,e[0])]}_initPrevUndo(){this._prevUndos=[]}async triggerAutoFill(e,t,i,r){var g;if(i.startColumn===r.startColumn&&i.startRow===r.startRow&&i.endColumn===r.endColumn&&i.endRow===r.endRow)return!1;if(r.endColumn<i.endColumn&&r.endColumn>i.startColumn)return this._commandService.executeCommand(ln.id,{clearRange:{startRow:r.startRow,endRow:r.endRow,startColumn:r.endColumn+1,endColumn:i.endColumn},selectionRange:r});if(r.endRow<i.endRow&&r.endRow>i.startRow)return this._commandService.executeCommand(ln.id,{clearRange:{startRow:r.endRow+1,endRow:i.endRow,startColumn:r.startColumn,endColumn:r.endColumn},selectionRange:r});const s={startRow:r.startRow,endRow:r.endRow,startColumn:r.startColumn,endColumn:r.endColumn};let l=null;if(r.startRow<i.startRow)l=a.Direction.UP,s.endRow=i.startRow-1;else if(r.endRow>i.endRow)l=a.Direction.DOWN,s.startRow=i.endRow+1;else if(r.startColumn<i.startColumn)l=a.Direction.LEFT,s.endColumn=i.startColumn-1;else if(r.endColumn>i.endColumn)l=a.Direction.RIGHT,s.startColumn=i.endColumn+1;else return!1;this.direction=l;const c=this._injector.invoke(f=>m.rangeToDiscreteRange(i,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 S=(g=this.menu.find(f=>f.disable===!1))==null?void 0:g.value;return S?this.fillData(S):!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=sn.Append),this._hooks.push(e),a.toDisposable(()=>{const t=this._hooks.findIndex(i=>i===e);t>-1&&this._hooks.splice(t,1)})}registerRule(e){if(this._rules.find(i=>i.type===e.type))throw new Error(`Registry rule failed, type '${e.type}' already exist!`);const t=this._rules.findIndex(i=>i.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:i,subUnitId:r}=this.autoFillLocation||{};if(!e||!t||!i||!r)return[];const s=this._hooks.filter(u=>{var h;return!((h=u.disable)!=null&&h.call(u,{source:e,target:t,unitId:i,subUnitId:r},this._direction,this.applyType))}),l=s.filter(u=>u.type===sn.Only);if(l.length>0)return this._getOneByPriority(l);const c=this._getOneByPriority(s.filter(u=>u.type===sn.Default)),d=s.filter(u=>u.type===sn.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(i=>i.value===e?{...i,disable:t}:i))}setShowMenu(e){this._showMenu$.next(e)}fillData(e){var C,_,E;this.applyType=e;const{source:t,target:i,unitId:r=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||!i||!r||!s)return!1;const l=this.direction;this._prevUndos.length>0&&this._prevUndos.forEach(T=>{this._commandService.syncExecuteCommand(T.id,T.params)}),this._prevUndos=[];const c=a.Rectangle.union(vt(t),vt(i)),d=this.getActiveHooks(),u=this._univerInstanceService.getUnit(r,a.UniverInstanceType.UNIVER_SHEET);this._commandService.syncExecuteCommand(m.SetSelectionsOperation.id,{selections:[{primary:{...(E=(_=this._selectionManagerService.getCurrentLastSelection())==null?void 0:_.primary)!=null?E:c},range:{...c,rangeType:a.RANGE_TYPE.NORMAL}}],unitId:r,subUnitId:s});const h=[],S=[];d.forEach(T=>{var O;const{undos:P,redos:R}=((O=T.onFillData)==null?void 0:O.call(T,{source:t,target:i,unitId:r,subUnitId:s},l,e))||{};P&&h.push(...P),R&&S.push(...R)});const g=S.every(T=>this._commandService.syncExecuteCommand(T.id,T.params)),f=[];e!==de.NO_FORMAT&&S.forEach(T=>{if(T.id===m.SetRangeValuesMutation.id){const{cellValue:P}=T.params;new a.ObjectMatrix(P).forValue((O,A,N)=>{const D=Object.keys(u.getStyles().get(N==null?void 0:N.s)||{});(N!=null&&N.p||D.length&&nr.some(H=>D.includes(H)))&&f.push({startRow:O,endRow:O,startColumn:A,endColumn:A})})}});const p=this._getAutoHeightUndoRedos(r,s,f);return p.redos.every(T=>this._commandService.syncExecuteCommand(T.id,T.params))&&(h.push(...p.undos),S.push(...p.redos)),g&&(this._prevUndos=h,this._undoRedoService.pushUndoRedo({unitID:r,undoMutations:h,redoMutations:S})),d.forEach(T=>{var P;(P=T.onAfterFillData)==null||P.call(T,{source:t,target:i,unitId:r,subUnitId:s},l,e)}),this.setShowMenu(!0),!0}_getAutoHeightUndoRedos(e,t,i){var h,S;const r=(h=this._renderManagerService.getRenderById(e))==null?void 0:h.with(y.SheetSkeletonManagerService),s=(S=r==null?void 0:r.getCurrentParam())==null?void 0:S.skeleton;if(!s)return{redos:[],undos:[]};const l=s.calculateAutoHeightInRange(i),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}]}}},y.AutoFillService=zd([an(0,a.ICommandService),an(1,a.IUndoRedoService),an(2,M.IRenderManagerService),an(3,a.Inject(a.IUniverInstanceService)),an(4,a.Inject(m.SheetsSelectionsService)),an(5,a.Inject(a.Injector))],y.AutoFillService);const Ct=a.createIdentifier("univer.auto-fill-service"),It={type:a.CommandType.COMMAND,id:"sheet.command.auto-fill",handler:async(n,o)=>{const e=n.get(Ct),t=n.get(a.IUniverInstanceService),{sourceRange:i,targetRange:r}=o,s=m.getSheetCommandTarget(t);if(!s)return!1;const{subUnitId:l,unitId:c}=s;return e.triggerAutoFill(c,l,i,r)}},ln={id:"sheet.command.auto-clear-content",type:a.CommandType.COMMAND,handler:async(n,o)=>{const e=n.get(a.IUniverInstanceService),t=n.get(a.ICommandService),i=n.get(a.IUndoRedoService),r=n.get(m.SheetInterceptorService),s=m.getSheetCommandTarget(e);if(!s)return!1;const{unitId:l,subUnitId:c}=s,{clearRange:d,selectionRange:u}=o,h={subUnitId:c,unitId:l,cellValue:m.generateNullCellValue([d])},S=m.SetRangeValuesUndoMutationFactory(n,h),{startColumn:g,startRow:f}=u,p={selections:[{primary:{startColumn:g,startRow:f,endColumn:g,endRow:f,actualRow:f,actualColumn:g,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=r.afterCommandExecute({id:m.SetRangeValuesMutation.id,params:h});return a.sequenceExecute(C.redos,t),i.pushUndoRedo({unitID:l,undoMutations:[{id:m.SetRangeValuesMutation.id,params:S},...C.undos],redoMutations:[{id:m.SetRangeValuesMutation.id,params:h},...C.redos]}),!0}return!1}},Yn={id:"sheet.command.refill",type:a.CommandType.COMMAND,handler:async(n,o)=>n.get(Ct).fillData(o.type)};var Xd=Object.getOwnPropertyDescriptor,Yd=(n,o,e,t)=>{for(var i=t>1?void 0:t?Xd(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},Dt=(n,o)=>(e,t)=>o(e,t,n);y.EditorBridgeService=class extends a.Disposable{constructor(e,t,i,r,s,l,c){super();w(this,"_editorUnitId",a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);w(this,"_editorIsDirty",!1);w(this,"_isDisabled",!1);w(this,"_visible",{visible:!1,eventType:M.DeviceInputEventType.Dblclick,unitId:""});w(this,"_currentEditCell",null);w(this,"_currentEditCellState",null);w(this,"_currentEditCellLayout",null);w(this,"_currentEditCellState$",new k.BehaviorSubject(null));w(this,"currentEditCellState$",this._currentEditCellState$.asObservable());w(this,"_currentEditCellLayout$",new k.BehaviorSubject(null));w(this,"currentEditCellLayout$",this._currentEditCellLayout$.asObservable());w(this,"currentEditCell$",this._currentEditCellState$.pipe(k.switchMap(e=>this._currentEditCellLayout$.pipe(k.map(t=>e&&t?{...e,...t}:null)))));w(this,"_visible$",new k.BehaviorSubject(this._visible));w(this,"visible$",this._visible$.asObservable());w(this,"_afterVisible$",new k.BehaviorSubject(this._visible));w(this,"afterVisible$",this._afterVisible$.asObservable());w(this,"_forceKeepVisible$",new k.BehaviorSubject(!1));w(this,"forceKeepVisible$",this._forceKeepVisible$.asObservable());this._sheetInterceptorService=e,this._renderManagerService=t,this._themeService=i,this._univerInstanceService=r,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:i,scaleY:r,canvasOffset:s,...l}=e;this._currentEditCellState=l,this._currentEditCellLayout={position:t,scaleX:i,scaleY:r,canvasOffset:s},this._currentEditCellState$.next(this._currentEditCellState),this._currentEditCellLayout$.next(this._currentEditCellLayout)}refreshEditCellPosition(e){var O;const t=this._currentEditCell;if(t==null)return;const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!i)return;const r=this._renderManagerService.getRenderUnitById(i.getUnitId());if(!r)return;const s=(O=r.with(y.SheetSkeletonManagerService).getSkeletonParam(t.sheetId))==null?void 0:O.skeleton,l=r.with(ve);if(!s||!this._currentEditCellState)return;const{primary:c,unitId:d,sheetId:u,scene:h,engine:S}=t,g=Bn(s,c);if(g==null)return;const f=a.convertCellToRange(g),p=Q.getCanvasOffsetByEngine(S);let{startX:v,startY:C,endX:_,endY:E}=f;const{scaleX:T,scaleY:P}=h.getAncestorScale(),R=h.getViewportScrollXY(l.getViewPort());v=M.convertTransformToOffsetX(v,T,R),C=M.convertTransformToOffsetY(C,P,R),_=M.convertTransformToOffsetX(_,T,R),E=M.convertTransformToOffsetY(E,P,R),e&&this._currentEditCellLayout&&(_=_-v+this._currentEditCellLayout.position.startX,E=E-C+this._currentEditCellLayout.position.startY,v=this._currentEditCellLayout.position.startX,C=this._currentEditCellLayout.position.startY),this._currentEditCellLayout={position:{startX:v,startY:C,endX:_,endY:E},canvasOffset:p,scaleX:T,scaleY:P},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:i,canvasOffset:r,scaleX:s,scaleY:l,...c}=t;this._currentEditCellState=c,this._currentEditCellLayout={position:i,canvasOffset:r,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 U,V,B;const e=this._currentEditCell;if(e==null)return;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const i=this._renderManagerService.getRenderUnitById(t.getUnitId());if(!i)return;const r=i.with(y.SheetSkeletonManagerService).getCurrentSkeleton(),s=i.with(ve);if(!r)return;const{primary:l,unitId:c,sheetId:d,scene:u,engine:h}=e,{startRow:S,startColumn:g}=l,f=Bn(r,l);if(f==null)return;const p=a.convertCellToRange(f),v=Q.getCanvasOffsetByEngine(h);let{startX:C,startY:_,endX:E,endY:T}=p;const{scaleX:P,scaleY:R}=u.getAncestorScale(),O=u.getViewportScrollXY(s.getViewPort());C=M.convertTransformToOffsetX(C,P,O),_=M.convertTransformToOffsetY(_,R,O),E=M.convertTransformToOffsetX(E,P,O),T=M.convertTransformToOffsetY(T,R,O);const A=t.getActiveSheet();if(!A)return;const N={workbook:t,worksheet:A,unitId:t.getUnitId(),subUnitId:A.getSheetId(),row:S,col:g,origin:A.getCellRaw(S,g)};let D;const H=this._sheetInterceptorService.writeCellInterceptor.fetchThroughInterceptors(m.BEFORE_CELL_EDIT)(A.getCell(S,g),N);D=H&&r.getCellDocumentModelWithFormula(H);const W=(U=D==null?void 0:D.documentModel)==null?void 0:U.documentStyle.renderConfig;if(W!=null&&(W.cellValueType=a.CellValueType.STRING),!D||D.documentModel==null){const x=r.getBlankCellDocumentModel(H);if(D!=null){const{verticalAlign:z,horizontalAlign:F,wrapStrategy:Y,textRotation:X,fill:Z}=D,{centerAngle:ne,vertexAngle:J}=M.convertTextRotation(X);x.documentModel.documentStyle.renderConfig={...W,verticalAlign:z,horizontalAlign:F,wrapStrategy:Y,background:{rgb:Z},centerAngle:ne,vertexAngle:J}}D=x}if(D.fill=D.fill||"#fff",(V=D.documentModel)==null||V.setZoomRatio(Math.max(P,R)),(H==null?void 0:H.isInArrayFormulaRange)===!0){const x=(B=D.documentModel)==null?void 0:B.getBody();x&&(x.textRuns=[{st:0,ed:x.dataStream.length-2,ts:{cl:{rgb:this._themeService.getCurrentTheme().textColorSecondary}}}])}return{position:{startX:C,startY:_,endX:E,endY:T},scaleX:P,scaleY:R,canvasOffset:v,row:S,column:g,unitId:c,sheetId:d,documentLayoutObject:D,editorUnitId:this._editorUnitId,isInArrayFormulaRange:H==null?void 0:H.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}},y.EditorBridgeService=Yd([Dt(0,a.Inject(m.SheetInterceptorService)),Dt(1,M.IRenderManagerService),Dt(2,a.Inject(a.ThemeService)),Dt(3,a.IUniverInstanceService),Dt(4,Q.IEditorService),Dt(5,m.IRefSelectionsService),Dt(6,a.IContextService)],y.EditorBridgeService);const ge=a.createIdentifier("univer.sheet-editor-bridge.service"),Ce={id:"sheet.operation.set-cell-edit-visible",type:a.CommandType.OPERATION,handler:(n,o)=>{if(!o)return!1;const{unitId:e}=o,i=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return i?(n.get(ge).changeVisible({...o,unitId:e!=null?e:i.getUnitId()}),!0):!1}},jn={id:"sheet.operation.set-cell-edit-visible-f2",type:a.CommandType.OPERATION,handler:(n,o)=>{const e=n.get(a.ICommandService),i=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return i?(e.syncExecuteCommand(Ce.id,{...o,unitId:i.getUnitId()}),!0):!1}},Nt={id:"sheet.operation.set-cell-edit-visible-arrow",type:a.CommandType.OPERATION,handler:()=>!0},cn={id:"sheet.command.change-zoom-ratio",type:a.CommandType.COMMAND,handler:(n,o)=>{if(!o)return!1;const e=n.get(a.IUniverInstanceService),t=m.getSheetCommandTarget(e);if(!t)return!1;const{worksheet:i,subUnitId:r,unitId:s}=t,{delta:l,reset:c}=o;let d=c?100:Math.round((i.getConfig().zoomRatio+l)*100);d=Math.max(jo[0],d),d=Math.min(jo[1],d);const u=d/100,S=n.get(ge).isVisible();return(S.unitId===s||S.unitId===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)&&S.visible?!1:n.get(a.ICommandService).executeCommand(Le.id,{unitId:s,subUnitId:r,zoomRatio:u})}},dn={id:"sheet.command.set-zoom-ratio",type:a.CommandType.COMMAND,handler:(n,o)=>{if(!o)return!1;const{unitId:e,subUnitId:t,zoomRatio:i}=o,s=n.get(ge).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:i})}};function jd(n){return typeof n.isMainScene>"u"}function ze(n,o){const e=n instanceof a.Workbook?n:n.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return null;const t=e.getUnitId();let i,r,s,l;if(jd(o)){const S=o.getRenderById(t);if(S==null)return null;i=S.components,i=S.components,r=S.mainComponent,s=S.scene,l=S.engine}else i=o.components,r=o.mainComponent,s=o.scene,l=o.engine;if(!i||!r)return null;const c=r,d=i.get(he.ROW),u=i.get(he.COLUMN),h=i.get(he.LEFT_TOP);return{spreadsheet:c,spreadsheetRowHeader:d,spreadsheetColumnHeader:u,spreadsheetLeftTopPlaceholder:h,scene:s,engine:l}}function rr(n,o,e,t){const{startX:i,startY:r,endX:s,endY:l}=t.getCellWithCoordByIndex(n,o);return{startX:i,startY:r,endX:s,endY:l}}function qe(n,o,e,t,i,r){const s=e.getCoordRelativeToViewport(M.Vector2.FromArray([n,o])),{x:l,y:c}=s,d=e.getScrollXYInfoByViewport(s,i),{scaleX:u,scaleY:h}=e.getAncestorScale(),S=t.getCellIndexByOffset(l,c,u,h,d,{closeFirst:r}),{row:g,column:f}=S,p=t.getNoMergeCellWithCoordByIndex(g,f),{startX:v,startY:C,endX:_,endY:E}=p;return{startX:v,startY:C,endX:_,endY:E,row:g,column:f}}function Gn(n,o,e,t){const i=e.getCoordRelativeToViewport(M.Vector2.FromArray([n,o])),r=e.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN),s=e.getScrollXYInfoByViewport(i,r),{scaleX:l,scaleY:c}=e.getAncestorScale(),{x:d,y:u}=s,h=n/l+d,S=o/c+u;return{x:h,y:S}}var Gd=Object.getOwnPropertyDescriptor,Zd=(n,o,e,t)=>{for(var i=t>1?void 0:t?Gd(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},Gi=(n,o)=>(e,t)=>o(e,t,n);let Zn=class extends a.Disposable{constructor(o,e,t,i,r){super();w(this,"_zoom");this._context=o,this._sheetSkeletonManagerService=e,this._commandService=t,this._contextService=i,this._editorBridgeService=r,this._initSkeletonListener(),this._initZoomEventListener()}updateZoom(o,e){const t=this._context.unit.getSheetBySheetId(o);return t?(t.getConfig().zoomRatio=e,t===this._context.unit.getActiveSheet()&&this._updateViewZoom(e),!0):!1}_initZoomEventListener(){const o=this._getSheetObject().scene;this.disposeWithMe(o.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 i=t<40?.2:t<80?.4:.2;i*=e.deltaY>0?-1:1,o.scaleX<1&&(i/=2);const r=this._context.unit,s=r.getActiveSheet();if(!s)return;const l=s.getZoomRatio();let c=+Number.parseFloat(`${l+i}`).toFixed(1);c=c>=4?4:c<=.1?.1:c,this._commandService.executeCommand(dn.id,{zoomRatio:Math.round(c*10)/10,unitId:r.getUnitId(),subUnitId:s.getSheetId()}),e.preventDefault()}))}_initSkeletonListener(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(o=>{if(o==null)return;const t=this._context.unit.getActiveSheet();if(!t)return;const i=t.getZoomRatio()||1;this._zoom!==i&&this._updateViewZoom(i),this._zoom=i}))}_updateViewZoom(o){const e=this._getSheetObject();e==null||e.scene.scale(o,o),e==null||e.spreadsheet.makeForceDirty()}_getSheetObject(){return ze(this._context.unit,this._context)}};Zn=Zd([Gi(1,a.Inject(y.SheetSkeletonManagerService)),Gi(2,a.ICommandService),Gi(3,a.IContextService),Gi(4,a.Optional(ge))],Zn);const Le={id:"sheet.operation.set-zoom-ratio",type:a.CommandType.OPERATION,handler:(n,o)=>{const t=n.get(M.IRenderManagerService).getRenderById(o.unitId);return t?t.with(Zn).updateZoom(o.subUnitId,o.zoomRatio):!1}};var Kd=Object.getOwnPropertyDescriptor,qd=(n,o,e,t)=>{for(var i=t>1?void 0:t?Kd(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},sr=(n,o)=>(e,t)=>o(e,t,n);const ia="univer-sheet-main-canvas";y.SheetsRenderService=class extends a.RxDisposable{constructor(e,t,i){super();w(this,"_skeletonChangeMutations",new Set);this._contextService=e,this._instanceSrv=t,this._renderManagerService=i,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(k.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(k.takeUntil(this.dispose$)).subscribe(e=>this._disposeRenderer(e))}_createRenderer(e){const t=e.getUnitId();this._renderManagerService.created$.subscribe(i=>{i.unitId===t&&(i.engine.getCanvas().setId(`${ia}_${t}`),i.engine.getCanvas().getContext().setId(`${ia}_${t}`))}),this._renderManagerService.createRender(t)}_disposeRenderer(e){const t=e.getUnitId();this._renderManagerService.removeRender(t)}_initContextListener(){this.disposeWithMe(this._contextService.subscribeContextValue$(M.RENDER_RAW_FORMULA_KEY).pipe(k.distinctUntilChanged()).subscribe(()=>{this._renderManagerService.getRenderAll().forEach(e=>{e.mainComponent instanceof M.Spreadsheet&&e.mainComponent.makeForceDirty(!0)})}))}},y.SheetsRenderService=qd([sr(0,a.IContextService),sr(1,a.IUniverInstanceService),sr(2,M.IRenderManagerService)],y.SheetsRenderService);var Qd=Object.getOwnPropertyDescriptor,Jd=(n,o,e,t)=>{for(var i=t>1?void 0:t?Qd(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},Ht=(n,o)=>(e,t)=>o(e,t,n);y.AutoFillController=class extends a.Disposable{constructor(e,t,i,r,s,l,c){super();w(this,"_beforeApplyData",[]);w(this,"_currentLocation",null);w(this,"_copyData",[]);w(this,"_defaultHook");this._univerInstanceService=e,this._commandService=t,this._autoFillService=i,this._editorBridgeService=r,this._renderManagerService=s,this._injector=l,this._sheetsRenderService=c,this._defaultHook={id:"default",type:sn.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(It.id))}_initDefaultHook(){this.disposeWithMe(this._autoFillService.addHook(this._defaultHook))}_initQuitListener(){const e=[Ce.id,ln.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,i)=>{var c,d;const r=i==null?void 0:i.fromCollab,s=i==null?void 0:i.fromSync,l=i==null?void 0:i.fromFormula;e.includes(t.id)&&!r&&!s&&!l&&t.params.trigger!==It.id&&t.params.trigger!==Yn.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 i;t.getUnitId()===((i=this._currentLocation)==null?void 0:i.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 i=M.getCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService);if(!i)return;i.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(It.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:M.DeviceInputEventType.PointerDown,unitId:i.unitId})}))})};t(),this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.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(It.id,{sourceRange:e,targetRange:t})}_detectFillRange(e){var S,g,f,p,v,C;const{startRow:t,endRow:i,startColumn:r,endColumn:s}=e,l=(S=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getActiveSheet();if(!l)return e;const c=l.getCellMatrix(),d=l.getMaxRows()-1,u=l.getMaxColumns()-1;let h=i;if(r>0&&((g=c.getValue(t,r-1))==null?void 0:g.v)!=null){let _=t;for(;((f=c.getValue(_,r-1))==null?void 0:f.v)!=null&&_<d;)_+=1;h=_-1}else if(s<u&&((p=c.getValue(i,s+1))==null?void 0:p.v)!=null){let _=t;for(;((v=c.getValue(_,s+1))==null?void 0:v.v)!=null&&_<d;)_+=1;h=_-1}for(let _=i+1;_<=h;_++)for(let E=r;E<=s;E++)if(((C=c.getValue(_,E))==null?void 0:C.v)!=null){h=_-1;break}return{startColumn:r,endColumn:s,startRow:t,endRow:h}}_getApplyData(e,t,i,r,s,l=!0,c){const d=[],u=Math.floor(i/t),h=i%t,S=this._autoFillService.getRules();if(!l&&s===de.ONLY_FORMAT)return console.error("ERROR: only format can not be applied when hasStyle is false"),[];const g={};S.forEach(f=>{g[f.type]=[]}),S.forEach(f=>{const{type:p,applyFunctions:v={}}=f,C=e[p];C&&C.forEach(_=>{const E=Md(_.index,h),T=_.index.length*u+E,P=this._applyFunctions(_,T,r,s,v,e,c),R=Rd(t,i,_.index);g[p].push({data:P,index:R})})});for(let f=0;f<i;f++)S.forEach(p=>{const{type:v}=p,C=g[v];for(let _=0;_<C.length;_++)f in C[_].index&&d.push(C[_].data[C[_].index[f]])});return d}_applyFunctions(e,t,i,r,s,l,c){const{data:d}=e,u=i===a.Direction.UP||i===a.Direction.LEFT;if(r===de.COPY){const h=s==null?void 0:s[de.COPY];return h?h(e,t,i,l,c):(u&&d.reverse(),At(d,t))}if(r===de.SERIES){const h=s==null?void 0:s[de.SERIES];return h?h(e,t,i,l):(u&&d.reverse(),s!=null&&s[de.COPY]?s[de.COPY](e,t,i,l,c):At(d,t))}if(r===de.ONLY_FORMAT){const h=s==null?void 0:s[de.ONLY_FORMAT];return h?h(e,t,i,l):Pd(d,t)}}_getCopyData(e,t){const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!i)throw new Error("No active sheet found");const r=i.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 S=this._getEmptyCopyDataPiece(),g={type:void 0,cellData:void 0};u.forEach(f=>{let p;c?p=r.getValue(f,h):p=r.getValue(h,f);const{type:v,isContinue:C}=s.find(_=>_.match(p,this._injector))||na;if(C(g,p)){const _=S[v],E=_[_.length-1];E.data.push(p),E.index.push(f-u[0])}else{const _=S[v];_?_.push({data:[p],index:[f-u[0]]}):S[v]=[{data:[p],index:[f-u[0]]}]}g.type=v,g.cellData=p}),l.push(S)}),l}_getEmptyCopyDataPiece(){const e={};return this._autoFillService.getRules().forEach(t=>{e[t.type]=[]}),e}_getMergeApplyData(e,t,i,r){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:S,endRow:g,endColumn:f}=s.getCellInfoInMergeData(c,d);if(u){if(i===a.Direction.DOWN){let p=h+r,v=g+r;for(;v<=t.endRow;)l.push({startRow:p,startColumn:S,endRow:v,endColumn:f}),p+=r,v+=r}else if(i===a.Direction.UP){let p=h-r,v=g-r;for(;p>=t.startRow;)l.push({startRow:p,startColumn:S,endRow:v,endColumn:f}),p-=r,v-=r}else if(i===a.Direction.RIGHT){let p=S+r,v=f+r;for(;v<=t.endColumn;)l.push({startRow:h,startColumn:p,endRow:g,endColumn:v}),p+=r,v+=r}else if(i===a.Direction.LEFT){let p=S-r,v=f-r;for(;p>=t.startColumn;)l.push({startRow:h,startColumn:p,endRow:g,endColumn:v}),p-=r,v-=r}}}return l}_presetAndCacheData(e,t){const{source:i,target:r}=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 r.rows.forEach(d=>{const u=[];r.cols.forEach(h=>{u.push(a.Tools.deepClone(l.getValue(d,h)))}),c.push(u)}),this._beforeApplyData=c,this._copyData=this._getCopyData(i,t),this._currentLocation=e,this._shouldDisableSeries(this._copyData)?(this._autoFillService.setDisableApplyType(de.SERIES,!0),de.COPY):(this._autoFillService.setDisableApplyType(de.SERIES,!1),this._getPreferredApplyType(this._copyData))}_fillData(e,t,i){var U,V;const r=[],s=[];let l=!0;i===de.NO_FORMAT&&(l=!1,i=de.SERIES);const{source:c,target:d,unitId:u,subUnitId:h}=e;if(!c||!d||t==null)return{undos:r,redos:s};const S=vt(c),g=vt(d),{cols:f,rows:p}=d,{cols:v,rows:C}=c,_=this._copyData;let E;t===a.Direction.DOWN||t===a.Direction.UP?E=C.length:E=v.length;const T=[];if(t===a.Direction.DOWN||t===a.Direction.UP){const B=p.length,x=[];f.forEach((z,F)=>{const Y=_[F],X=this._getApplyData(Y,E,B,t,i,l,e);x.push(X)});for(let z=0;z<x[0].length;z++){const F=[];for(let Y=0;Y<x.length;Y++)F.push({s:null,...x[Y][z]});T.push(F)}}else{const B=f.length;p.forEach((x,z)=>{const F=_[z],Y=this._getApplyData(F,E,B,t,i,l,e),X=[];for(let Z=0;Z<Y.length;Z++)X.push({s:null,...Y[Z]});T.push(X)})}let P=[];const R=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getStyles();if(l?(P=this._getMergeApplyData(S,g,t,E),T.forEach(B=>{B.forEach(x=>{x&&R&&R&&(x.s=R.getStyleByCell(x))})})):T.forEach((B,x)=>{B.forEach((z,F)=>{z&&R&&(z.s=R.getStyleByCell(this._beforeApplyData[x][F])||null)})}),i===de.ONLY_FORMAT&&T.forEach((B,x)=>{B.forEach((z,F)=>{if(z){const Y=this._beforeApplyData[x][F]||{};z.f=Y.f,z.si=Y.si,z.t=Y.t,z.v=Y.v}})}),l){const B=[],x=(V=(U=this._univerInstanceService.getUniverSheetInstance(u))==null?void 0:U.getSheetBySheetId(h))==null?void 0:V.getMergeData();x&&x.forEach(Y=>{a.Rectangle.intersects(Y,g)&&B.push(Y)});const z={unitId:u,subUnitId:h,ranges:B},F=this._injector.invoke(m.RemoveMergeUndoMutationFactory,z);B.length&&(s.push({id:m.RemoveWorksheetMergeMutation.id,params:z}),r.unshift({id:m.AddWorksheetMergeMutation.id,params:F}))}const O={subUnitId:h,unitId:u,cellValue:Id([d])},A=this._injector.invoke(m.SetRangeValuesUndoMutationFactory,O);s.push({id:m.SetRangeValuesMutation.id,params:O}),r.unshift({id:m.SetRangeValuesMutation.id,params:A});const N=new a.ObjectMatrix;p.forEach((B,x)=>{f.forEach((z,F)=>{T[x][F]&&N.setValue(B,z,T[x][F])})});const D=N.getMatrix(),H={subUnitId:h,unitId:u,cellValue:D},W=this._injector.invoke(m.SetRangeValuesUndoMutationFactory,H);if(this._autoFillService.getActiveHooks().forEach(B=>{var x;(x=B.onBeforeSubmit)==null||x.call(B,e,t,i,D)}),r.unshift({id:m.SetRangeValuesMutation.id,params:W}),s.push({id:m.SetRangeValuesMutation.id,params:H}),P!=null&&P.length){const B=m.getAddMergeMutationRangeByType(P),x={unitId:u,subUnitId:h,ranges:B},z=this._injector.invoke(m.AddMergeUndoMutationFactory,x);r.unshift({id:m.RemoveWorksheetMergeMutation.id,params:z}),s.push({id:m.AddWorksheetMergeMutation.id,params:x})}return{undos:r,redos:s}}_shouldDisableSeries(e){return e.every(t=>Object.keys(t).every(i=>{var r;return((r=t[i])==null?void 0:r.length)===0||[_e.OTHER,_e.FORMULA].includes(i)}))}_getPreferredApplyType(e){return e.every(i=>Object.keys(i).every(r=>{var s,l;return((s=i[r])==null?void 0:s.length)===0||((l=i[r])==null?void 0:l.length)===1&&i[r][0].data.length===1&&_e.NUMBER===r}))?de.COPY:de.SERIES}},y.AutoFillController=Jd([Ht(0,a.IUniverInstanceService),Ht(1,a.ICommandService),Ht(2,Ct),Ht(3,ge),Ht(4,M.IRenderManagerService),Ht(5,a.Inject(a.Injector)),Ht(6,a.Inject(y.SheetsRenderService))],y.AutoFillController);var $d=Object.getOwnPropertyDescriptor,eu=(n,o,e,t)=>{for(var i=t>1?void 0:t?$d(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},ar=(n,o)=>(e,t)=>o(e,t,n);y.CellCustomRenderController=class extends a.Disposable{constructor(e,t,i,r){super();w(this,"_enterActiveRender");this._context=e,this._sheetSkeletonManagerService=t,this._renderManagerService=i,this._permissionService=r,this._initEventBinding()}_initEventBinding(){const e=new a.DisposableCollection,t=this._context.unit,i=r=>{if(e.dispose(),!r)return;const s=this._context.unitId,{skeleton:l}=r,c=this._renderManagerService.getRenderById(s);if(c&&c.mainComponent){const d=c.mainComponent,u=g=>{const{offsetX:f,offsetY:p}=g,v=c.scene,C=t.getActiveSheet();if(!C)return;const _=v.getActiveViewportByCoord(M.Vector2.FromArray([f,p]));if(!_)return;const{scaleX:E,scaleY:T}=v.getAncestorScale(),P={x:_.viewportScrollX,y:_.viewportScrollY},R=l.getCellIndexByOffset(f,p,E,T,P),O=l.worksheet.getMergedCell(R.row,R.column),A={actualRow:O?O.startRow:R.row,actualCol:O?O.startColumn:R.column,row:R.row,col:R.column};if(!A||!l)return;const N=C.getCell(A.actualRow,A.actualCol);if(!N)return;const D=N.customRender;if(!(D!=null&&D.length))return;const H=A.actualRow,W=A.actualCol,U=D.sort(a.sortRules),V=C.getSheetId(),B={data:N,style:l.getStyles().getStyleByCell(N),primaryWithCoord:l.getCellWithCoordByIndex(A.actualRow,A.actualCol),unitId:s,subUnitId:V,row:H,col:W,workbook:t,worksheet:C},x={x:P.x+f/E,y:P.y+p/T},z=U.find(F=>{var Y;return(Y=F.isHit)==null?void 0:Y.call(F,x,B)});if(z)return[z,B]},h=d.onPointerDown$.subscribeEvent(g=>{var p,v,C,_;const f=u(g);if(f){const[E,T]=f,{row:P,col:R,worksheet:O,unitId:A,subUnitId:N}=T;if(!((p=this._permissionService.composePermission([new m.WorkbookEditablePermission(A).id,new m.WorksheetEditPermission(A,N).id]))==null?void 0:p.every(W=>W.value)))return!1;const H=(C=(v=O.getCell(P,R))==null?void 0:v.selectionProtection)==null?void 0:C[0];if((H==null?void 0:H[m.UnitAction.Edit])===!1)return!1;(_=E.onPointerDown)==null||_.call(E,T,g)}}),S=a.fromEventSubject(d.onPointerMove$).pipe(k.throttleTime(30)).subscribe(g=>{var p,v,C,_,E,T;const f=u(g);if(f){const[P,R]=f;this._enterActiveRender?this._enterActiveRender.render!==P&&((v=(p=this._enterActiveRender.render).onPointerLeave)==null||v.call(p,this._enterActiveRender.cellContext,g),this._enterActiveRender={render:P,cellContext:R},(C=P.onPointerEnter)==null||C.call(P,R,g)):(this._enterActiveRender={render:P,cellContext:R},(_=P.onPointerEnter)==null||_.call(P,R,g))}else this._enterActiveRender&&((T=(E=this._enterActiveRender.render).onPointerLeave)==null||T.call(E,this._enterActiveRender.cellContext,g),this._enterActiveRender=null)});h&&e.add(h),S&&e.add(S)}};this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i)),i(this._sheetSkeletonManagerService.getCurrentParam()),this.disposeWithMe(e)}},y.CellCustomRenderController=eu([ar(1,a.Inject(y.SheetSkeletonManagerService)),ar(2,M.IRenderManagerService),ar(3,a.IPermissionService)],y.CellCustomRenderController);class lr extends a.Disposable{constructor(){super(...arguments);w(this,"rangesStack",[]);w(this,"selectedRangeWorksheet","")}}var tu=Object.getOwnPropertyDescriptor,nu=(n,o,e,t)=>{for(var i=t>1?void 0:t?tu(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},oa=(n,o)=>(e,t)=>o(e,t,n);let un=class{constructor(n,o){w(this,"_current",null);w(this,"_shortcutParam",[]);this._univerInstanceService=n,this._localeService=o}dispose(){this._shortcutParam=[]}getCurrentBySearch(n){return this._getCurrentBySearch(n)}getCurrent(){return this._getCurrentBySearch(this._current)}addOrUpdate(n){const o=this._getCurrentBySearch({unitId:n.unitId,sheetId:n.sheetId,keycode:n.keycode});if(o!=null){const e=this._shortcutParam.indexOf(o);this._shortcutParam.splice(e,1)}return this._shortcutParam.push(n),o}remove(n){if(n==null)return;const o=this._getCurrentBySearch(n);if(o==null)return;const e=this._shortcutParam.indexOf(o);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)}};un=nu([oa(0,a.IUniverInstanceService),oa(1,a.Inject(a.LocaleService))],un);var Zi=(n=>(n.MergeAll="mergeAll",n.MergeVertical="mergeVertical",n.MergeHorizontal="mergeHorizontal",n))(Zi||{});function _t(n,o,e,t,i=!0,r=1,s=!0){let l={...n};t==null&&(t={startRow:0,endRow:e.getRowCount()-1,startColumn:0,endColumn:e.getColumnCount()-1});let c;switch(o){case a.Direction.UP:for(c=n.startRow-r;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,i&&(l=_t(l,a.Direction.LEFT,e,t,!1)));break;case a.Direction.DOWN:for(c=n.endRow+r;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,i&&(l=_t(l,a.Direction.RIGHT,e,t,!1)));break;case a.Direction.LEFT:for(c=n.startColumn-r;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,i&&(l=_t(l,a.Direction.UP,e,t,!1)));break;case a.Direction.RIGHT:for(c=n.endColumn+r;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,i&&(l=_t(l,a.Direction.DOWN,e,t,!1)));break}return l}function cr(n,o,e){const t={...n},{startRow:i,startColumn:r,endRow:s,endColumn:l}=Kn(n,o,e);let c=qn(e,i,r,s,l).hasValue,d=!0,u=!0;for(;u;){if(a.Direction.UP===o){let h=t.startRow-1;for(;h>-1&&!e.getRowVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:S,matrix:g}=qn(e,h,t.startColumn,h,t.endColumn);if(c&&!S&&!d){u=!1;break}else{if(g.getLength()!==0){let f=h;g.forValue(p=>{f=Math.min(p,f)}),t.startRow=f}else t.startRow=h;if(t.endRow=t.startRow,!c&&S){u=!1;break}c=S,d=!1}}if(a.Direction.DOWN===o){let h=t.endRow+1;for(;h<e.getRowCount()&&!e.getRowVisible(h);)h+=1;if(h===e.getRowCount()){u=!1;break}const{hasValue:S,matrix:g}=qn(e,h,t.startColumn,h,t.endColumn);if(c&&!S&&!d){u=!1;break}else{if(g.getLength()!==0){let f=h;g.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&&S){u=!1;break}c=S,d=!1}}if(a.Direction.LEFT===o){let h=t.startColumn-1;for(;h>-1&&!e.getColVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:S,matrix:g}=qn(e,t.startRow,h,t.endRow,h);if(c&&!S&&!d){u=!1;break}else{if(g.getLength()!==0){let f=h;g.forValue((p,v)=>{f=Math.min(v,f)}),t.startColumn=f}else t.startColumn=h;if(t.endColumn=t.startColumn,!c&&S){u=!1;break}c=S,d=!1}}if(a.Direction.RIGHT===o){let h=t.endColumn+1;for(;h<e.getColumnCount()&&!e.getColVisible(h);)h+=1;if(h===e.getColumnCount()){u=!1;break}const{hasValue:S,matrix:g}=qn(e,t.startRow,h,t.endRow,h);if(c&&!S&&!d){u=!1;break}else{if(g.getLength()!==0){let f=h;g.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&&S){u=!1;break}c=S,d=!1}}}return m.alignToMergedCellsBorders(t,e,!0)}function ra(n,o,e){return _t(n,o,e,void 0,!1,1,!1)}function iu(n,o,e){const t=cr(n,o,e);return m.alignToMergedCellsBorders(a.Rectangle.union(t,n),e,!0)}function ou(n,o,e){const t=ra(n,o,e),i={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,i),e)}function ru(n,o,e,t){const i=a.getReverseDirection(e),r=cr(Kn(n,i,t),e,t);return e===a.Direction.UP&&r.startRow<=n.startRow?m.alignToMergedCellsBorders({...o,startColumn:n.startColumn,endColumn:n.endColumn},t,!0):e===a.Direction.DOWN&&r.endRow>=n.endRow?m.alignToMergedCellsBorders({...o,startColumn:n.startColumn,endColumn:n.endColumn},t,!0):e===a.Direction.LEFT&&r.startColumn<=n.startColumn?m.alignToMergedCellsBorders({...o,startRow:n.startRow,endRow:n.endRow},t,!0):e===a.Direction.RIGHT&&r.endColumn>=n.endColumn?m.alignToMergedCellsBorders({...o,startRow:n.startRow,endRow:n.endRow},t,!0):a.Rectangle.union(a.Rectangle.clone(o),r)}function su(n,o,e){const t=a.getReverseDirection(o),i=Kn(n,t,e),r=Kn(n,o,e),s=ra(i,o,e);return m.alignToMergedCellsBorders(a.Rectangle.union(r,s),e,!1)}function sa(n){return{startRow:0,startColumn:0,endRow:n.getRowCount()-1,endColumn:n.getColumnCount()-1,rangeType:a.RANGE_TYPE.ALL}}function Kn(n,o,e){let t;switch(o){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 qn(n,o,e,t,i){let r=!1;const s=n.getMatrixWithMergedCells(o,e,t,i).forValue((l,c,d)=>{if(lu(d))return r=!0,!1});return{hasValue:r,matrix:s}}function dr(n,o,e){const t=a.Rectangle.clone(n);if(o==null)return t;switch(e){case a.Direction.UP:case a.Direction.DOWN:t.startColumn=t.endColumn=o.actualColumn;break;case a.Direction.LEFT:case a.Direction.RIGHT:t.startRow=t.endRow=o.actualRow;break}return t}function au(n,o,e){var l,c,d,u;const{primary:t,range:i}=n,r=a.Rectangle.clone(i);switch(o){case a.Direction.UP:case a.Direction.DOWN:r.startRow=(l=t==null?void 0:t.startRow)!=null?l:i.startRow,r.endRow=(c=t==null?void 0:t.endRow)!=null?c:i.startRow;break;case a.Direction.LEFT:case a.Direction.RIGHT:r.startColumn=(d=t==null?void 0:t.startColumn)!=null?d:i.startColumn,r.endColumn=(u=t==null?void 0:t.endColumn)!=null?u:i.startColumn;break}const s=Kn(r,o,e);switch(o){case a.Direction.DOWN:return i.startRow<s.startRow;case a.Direction.UP:return i.endRow>s.endRow;case a.Direction.LEFT:return s.endColumn<i.endColumn;case a.Direction.RIGHT:return s.startColumn>i.startColumn}}function aa(n,o){let e=n[0].startRow,t=n[0].endRow;n.forEach(r=>{const{startRow:s,endRow:l}=r;e=Math.min(e,s),t=Math.max(t,l)});const i=new Array(t-e+1).fill(!1);return o.forEach(r=>{const{startRow:s,endRow:l}=r;for(let c=Math.max(s,e);c<=Math.min(l,t);c++)i[c-e]=!0}),n.every(r=>{const{startRow:s,endRow:l}=r;for(let c=s;c<=l;c++)if(!i[c-e])return!1;return!0})}function la(n,o){let e=n[0].startColumn,t=n[0].endColumn;n.forEach(r=>{const{startColumn:s,endColumn:l}=r;e=Math.min(e,s),t=Math.max(t,l)});const i=new Array(t-e+1).fill(!1);return o.forEach(r=>{const{startColumn:s,endColumn:l}=r;for(let c=Math.max(s,e);c<=Math.min(l,t);c++)i[c-e]=!0}),n.every(r=>{const{startColumn:s,endColumn:l}=r;for(let c=s;c<=l;c++)if(!i[c-e])return!1;return!0})}function ur(n,o){return o?n==="mergeAll"?o.filter(e=>!(e.startRow===e.endRow&&e.startColumn===e.endColumn)):n==="mergeVertical"?o.filter(e=>e.startRow!==e.endRow):n==="mergeHorizontal"?o.filter(e=>e.startColumn!==e.endColumn):o:null}function lu(n){return n.v!==void 0&&n.v!==null&&n.v!==""||n.p!==void 0}var Qe=(n=>(n[n.moveStopeOne=0]="moveStopeOne",n[n.moveGap=1]="moveGap",n[n.moveStepPage=2]="moveStepPage",n[n.moveStepEnd=3]="moveStepEnd",n))(Qe||{});const Ae={id:"sheet.command.move-selection",type:a.CommandType.COMMAND,handler:(n,o)=>{if(!o)return!1;const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const{workbook:t,worksheet:i}=e,r=m.getSelectionsService(n,o.fromCurrentSelection).getCurrentLastSelection();if(!r)return!1;const{direction:s,jumpOver:l,extra:c}=o,{range:d,primary:u}=r,h=dr(d,u,s),S=l===1?cr(h,s,i):_t(h,s,i),g=m.getCellAtRowCol(S.startRow,S.startColumn,i);if(a.Rectangle.equals(g,h))return!1;const f=t.getUnitId();n.get(un).remove({unitId:f,sheetId:i.getSheetId(),keycode:I.KeyCode.TAB});const p=[{range:a.Rectangle.clone(g),primary:{startRow:g.startRow,startColumn:g.startColumn,endRow:g.endRow,endColumn:g.endColumn,actualRow:S.startRow,actualColumn:S.startColumn,isMerged:g.isMerged,isMergedMainCell:g.startRow===S.startRow&&g.startColumn===S.startColumn}}];return n.get(a.ICommandService).executeCommand(m.SetSelectionsOperation.id,{unitId:t.getUnitId(),subUnitId:i.getSheetId(),selections:p,type:m.SelectionMoveType.MOVE_END,extra:c,reveal:!0})}},Je={id:"sheet.command.move-selection-enter-tab",type:a.CommandType.COMMAND,handler:(n,o)=>{var B;if(!o)return!1;const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const{workbook:t,worksheet:i}=e,r=m.getSelectionsService(n),{direction:s,keycode:l}=o,c=s===a.Direction.LEFT||s===a.Direction.UP,d=r.getCurrentSelections().concat(),u=d.findIndex(x=>x.primary),h=d[u];if(!h)return!1;const S=c?-1:1,g=u+S!==d.length?d[u+S]:d[0],f=d.findIndex(x=>x===g),p=t.getUnitId(),v=i.getSheetId();if(!h)return!1;const{range:C}=h,_=h.primary;let E=dr(C,_,s);const T=n.get(un),P=T.getCurrentBySearch({unitId:p,sheetId:v,keycode:I.KeyCode.TAB});let R;const{startRow:O,endRow:A,startColumn:N,endColumn:D}=C,H=c?_.startRow===O&&_.startColumn===N:_.endRow===A&&_.endColumn===D;if(a.Rectangle.equals(C,_)){if(l===I.KeyCode.TAB)P==null&&T.addOrUpdate({unitId:p,sheetId:v,keycode:I.KeyCode.TAB,selection:h});else{const F=P==null?void 0:P.selection;if(F!=null){const{range:Y,primary:X}=F;E=dr(Y,X,s)}T.remove({unitId:p,sheetId:v,keycode:I.KeyCode.TAB})}const x=_t(E,s,i),z=m.getCellAtRowCol(x.startRow,x.startColumn,i);if(a.Rectangle.equals(z,E))return!1;R={range:a.Rectangle.clone(z),primary:{startRow:z.startRow,startColumn:z.startColumn,endRow:z.endRow,endColumn:z.endColumn,actualRow:x.startRow,actualColumn:x.startColumn,isMerged:z.isMerged,isMergedMainCell:z.startRow===x.startRow&&z.startColumn===x.startColumn}}}else{T.remove({unitId:p,sheetId:v,keycode:I.KeyCode.TAB});const x=a.Tools.deepClone(_),z=H?g.range:_t({startRow:x.startRow,startColumn:x.startColumn,endRow:x.endRow,endColumn:x.endColumn},s,i,{startRow:O,endRow:A,startColumn:N,endColumn:D}),F=H&&c,Y=F?m.getCellAtRowCol(z.endRow,z.endColumn,i):m.getCellAtRowCol(z.startRow,z.startColumn,i);R={range:H?g.range:a.Rectangle.clone(C),primary:{startRow:Y.startRow,startColumn:Y.startColumn,endRow:Y.endRow,endColumn:Y.endColumn,actualRow:F?Y.startRow:z.startRow,actualColumn:F?Y.startColumn:z.startColumn,isMerged:Y.isMerged,isMergedMainCell:Y.startRow===z.startRow&&Y.startColumn===z.startColumn},style:H?g.style:h.style}}H?(d[u].primary=null,d[f]=R,r.setSelections(p,v,[],m.SelectionMoveType.MOVE_END)):d[u]=R;const W=n.get(a.ICommandService).executeCommand(m.SetSelectionsOperation.id,{unitId:p,subUnitId:v,type:m.SelectionMoveType.MOVE_END,selections:d,reveal:!0,extra:o.extra}),V=(B=n.get(M.IRenderManagerService).getRenderById(p))==null?void 0:B.with(ve);return V==null||V.refreshSelectionMoveEnd(),W}},De={id:"sheet.command.expand-selection",type:a.CommandType.COMMAND,handler:(n,o)=>{if(!o)return!1;const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const{worksheet:t,unitId:i,subUnitId:r}=e,s=m.getSelectionsService(n).getCurrentLastSelection();if(!s)return!1;const{range:l,primary:c}=s,{jumpOver:d,direction:u,extra:h}=o,g=au(s,u,t)?d===1?ru(l,{...a.Rectangle.clone(c),rangeType:a.RANGE_TYPE.NORMAL},u,t):su(l,u,t):d===1?iu(l,u,t):ou(l,u,t);return g.rangeType=s.range.rangeType,a.Rectangle.equals(g,l)?!1:n.get(a.ICommandService).syncExecuteCommand(m.SetSelectionsOperation.id,{unitId:i,subUnitId:r,type:m.SelectionMoveType.MOVE_END,selections:[{range:g,primary:c}],extra:h,reveal:!0})}},Ki={id:"sheet.command.select-all",type:a.CommandType.COMMAND,handler:async(n,o={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 i=n.get(lr),{worksheet:r,unitId:s,subUnitId:l}=e,c=`${s}|${l}`;c!==i.selectedRangeWorksheet&&(i.rangesStack=[],i.selectedRangeWorksheet=c);const d=r.getMaxRows(),u=r.getMaxColumns(),{expandToGapFirst:h,loop:S}=o,{range:g,primary:f}=t,p=g.endColumn===u-1&&g.endRow===d-1&&g.startRow===0&&g.startColumn===0;i.rangesStack.some(C=>a.Rectangle.equals(C,g))||(i.rangesStack=[],i.rangesStack.push(g));let v;if(p)if(S){if(i.rangesStack.findIndex(_=>a.Rectangle.equals(_,g))!==i.rangesStack.length-1)return!1;v=i.rangesStack[0]}else return!1;else h?(v=m.expandToContinuousRange(g,{left:!0,right:!0,up:!0,down:!0},r),a.Rectangle.equals(v,g)&&(v=sa(r))):v=sa(r);return i.rangesStack.some(C=>a.Rectangle.equals(C,v))||i.rangesStack.push(v),n.get(a.ICommandService).executeCommand(m.SetSelectionsOperation.id,{unitId:s,subUnitId:l,reveal:!0,selections:[{range:v,primary:f}]})}};var cu=Object.getOwnPropertyDescriptor,du=(n,o,e,t)=>{for(var i=t>1?void 0:t?cu(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},uu=(n,o)=>(e,t)=>o(e,t,n);y.SheetScrollManagerService=class{constructor(o,e){w(this,"_scrollStateMap",new Map);w(this,"_rawScrollInfo$",new k.BehaviorSubject(null));w(this,"rawScrollInfo$",this._rawScrollInfo$.asObservable());w(this,"validViewportScrollInfo$",new k.BehaviorSubject(null));w(this,"_searchParamForScroll",null);this._context=o,this._sheetSkeletonManagerService=e}dispose(){this._rawScrollInfo$.complete()}calcViewportScrollFromRowColOffset(o){if(!o)return{viewportScrollX:0,viewportScrollY:0};let{sheetViewStartColumn:e,sheetViewStartRow:t,offsetX:i,offsetY:r}=o;t=t||0,r=r||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)+i,u=l+r;return{viewportScrollX:d,viewportScrollY:u}}setSearchParam(o){this._searchParamForScroll=o}getScrollStateByParam(o){return this._getCurrentScroll(o)}getCurrentScrollState(){return this._getCurrentScroll(this._searchParamForScroll)}setValidScrollState(o){this._setScrollState(o)}emitRawScrollParam(o){this._emitRawScroll(o)}setValidScrollStateToCurrSheet(o){if(this._searchParamForScroll==null)return;this._setScrollState({...this._searchParamForScroll,...o});const e=this._searchParamForScroll.sheetId,t=this._sheetSkeletonManagerService.getSkeleton(e);t&&t.setScroll(o.viewportScrollX,o.viewportScrollY)}clear(){this._searchParamForScroll!=null&&this._clearByParamAndNotify(this._searchParamForScroll)}_setScrollState(o){const{unitId:e,sheetId:t,sheetViewStartColumn:i,sheetViewStartRow:r,offsetX:s,offsetY:l}=o;this._scrollStateMap.has(e)||this._scrollStateMap.set(e,new Map);const c=this._scrollStateMap.get(e),d={sheetViewStartRow:r,sheetViewStartColumn:i,offsetX:s,offsetY:l};c.set(t,d)}_clearByParamAndNotify(o){this._setScrollState({...o,sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),this._emitRawScroll({sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0})}_getCurrentScroll(o){var s;const e={sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0};if(o==null)return e;const{unitId:t,sheetId:i}=o;return((s=this._scrollStateMap.get(t))==null?void 0:s.get(i))||e}_emitRawScroll(o){this._rawScrollInfo$.next(o)}},y.SheetScrollManagerService=du([uu(1,a.Inject(y.SheetSkeletonManagerService))],y.SheetScrollManagerService);const Xe={id:"sheet.operation.set-scroll",type:a.CommandType.OPERATION,handler:(n,o)=>{if(!o)return!1;const{unitId:e,sheetId:t,offsetX:i,offsetY:r,sheetViewStartColumn:s,sheetViewStartRow:l}=o;return n.get(M.IRenderManagerService).getRenderById(e).with(y.SheetScrollManagerService).emitRawScrollParam({unitId:e,sheetId:t,offsetX:i,offsetY:r,sheetViewStartRow:l,sheetViewStartColumn:s}),!0}},hn={id:"sheet.command.set-scroll-relative",type:a.CommandType.COMMAND,handler:async(n,o)=>{const e=n.get(a.ICommandService),t=n.get(a.IUniverInstanceService),i=n.get(M.IRenderManagerService),r=m.getSheetCommandTarget(t);if(!r)return!1;const{unitId:s,subUnitId:l}=r,d=i.getRenderById(s).with(y.SheetScrollManagerService).getCurrentScrollState(),{offsetX:u=0,offsetY:h=0}=o||{},{sheetViewStartRow:S=0,sheetViewStartColumn:g=0,offsetX:f=0,offsetY:p=0}=d||{};return e.executeCommand(Xe.id,{unitId:s,sheetId:l,sheetViewStartRow:S,sheetViewStartColumn:g,offsetX:f+u,offsetY:p+h})}},Ye={id:"sheet.command.scroll-view",type:a.CommandType.COMMAND,handler:(n,o)=>{if(!o)return!1;const e=n.get(a.IUniverInstanceService),t=n.get(M.IRenderManagerService),i=m.getSheetCommandTarget(e);if(!i)return!1;const{workbook:r,worksheet:s,unitId:l}=i,d=t.getRenderById(l).with(y.SheetScrollManagerService).getCurrentScrollState();if(!s)return!1;const{sheetViewStartRow:u,sheetViewStartColumn:h,offsetX:S,offsetY:g}=o,{sheetViewStartColumn:f,sheetViewStartRow:p,offsetX:v,offsetY:C}=d||{},{xSplit:_,ySplit:E}=i.worksheet.getConfig().freeze;return n.get(a.ICommandService).syncExecuteCommand(Xe.id,{unitId:r.getUnitId(),sheetId:s.getSheetId(),sheetViewStartRow:u!=null?u:p!=null?p:0+E,sheetViewStartColumn:h!=null?h:f!=null?f:0+_,offsetX:S!=null?S:v,offsetY:g!=null?g:C})}},hr={id:"sheet.command.scroll-to-cell",type:a.CommandType.COMMAND,handler:(n,o)=>{const e=n.get(a.IUniverInstanceService);return n.get(M.IRenderManagerService).getRenderById(e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(y.SheetsScrollRenderController).scrollToRange(o.range,o.forceTop,o.forceLeft)}},hu={id:"sheet.command.scroll-view-reset",type:a.CommandType.COMMAND,handler:async n=>{const o=n.get(a.IUniverInstanceService),e=m.getSheetCommandTarget(o);if(!e)return!1;const{subUnitId:t,unitId:i}=e;return n.get(a.ICommandService).executeCommand(Xe.id,{unitId:i,sheetId:t,sheetViewStartRow:0,sheetViewStartColumn:0})}};var mu=Object.getOwnPropertyDescriptor,Su=(n,o,e,t)=>{for(var i=t>1?void 0:t?mu(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},mn=(n,o)=>(e,t)=>o(e,t,n);Ae.id,Je.id;const gu=3;y.SheetsScrollRenderController=class extends a.Disposable{constructor(o,e,t,i,r,s,l){super(),this._context=o,this._injector=e,this._sheetSkeletonManagerService=t,this._contextService=i,this._commandService=r,this._renderManagerService=s,this._scrollManagerService=l,this._initCommandListener(),this._wheelEventListener(),this._scrollBarEventListener(),this._initSkeletonListener()}_wheelEventListener(){const{scene:o}=this._context;if(!o)return;const e=o.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN);e&&this.disposeWithMe(o.onMouseWheel$.subscribeEvent((t,i)=>{if(t.ctrlKey||!this._contextService.getContextValue(a.FOCUSING_SHEET))return;let r=0,s=0;r=t.deltaX,t.shiftKey?r=(t.deltaY||t.deltaX)*gu:s=t.deltaY,this._commandService.executeCommand(hn.id,{offsetX:r,offsetY:s}),this._context.scene.makeDirty(!0);const l=e.limitedScroll(e.scrollX+r,e.scrollY+s);l&&!l.isLimitedX&&!l.isLimitedY&&(t.preventDefault(),o.getParent().classType===M.RENDER_CLASS_TYPE.SCENE_VIEWER&&i.stopPropagation()),e.isWheelPreventDefaultX&&e.isWheelPreventDefaultY&&t.preventDefault()}))}_scrollBarEventListener(){const{scene:o}=this._context;if(o==null)return;const e=o.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN);e&&(this.disposeWithMe(a.toDisposable(this._scrollManagerService.rawScrollInfo$.subscribe(t=>{var g;const i=(g=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:g.skeleton;if(!i)return;if(t==null){e.scrollToViewportPos({viewportScrollX:0,viewportScrollY:0});return}const{sheetViewStartRow:r,sheetViewStartColumn:s,offsetX:l,offsetY:c}=t,{startX:d,startY:u}=i.getCellWithCoordByIndex(r,s,!1),h=d+l,S=u+c;e.scrollToViewportPos({viewportScrollX:h,viewportScrollY:S})}))),this.disposeWithMe(e.onScrollAfter$.subscribeEvent(t=>{var p;const i=(p=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:p.skeleton;if(i==null||t.isTrigger===!1)return;const r=this._getSheetObject();if(i==null||r==null)return;const{viewportScrollX:s,viewportScrollY:l,scrollX:c,scrollY:d}=t,{row:u,column:h,rowOffset:S,columnOffset:g}=i.getOffsetRelativeToRowCol(s,l),f={sheetViewStartRow:u,sheetViewStartColumn:h,offsetX:g,offsetY:S,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 S;const i=(S=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:S.skeleton;if(i==null||t.isTrigger===!1)return;const r=this._getSheetObject();if(i==null||r==null)return;const{viewportScrollX:s=0,viewportScrollY:l=0}=t;this._getFreeze();const{row:c,column:d,rowOffset:u,columnOffset:h}=i.getOffsetRelativeToRowCol(s,l);this._commandService.executeCommand(Ye.id,{sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:h,offsetY:u})})))}_initSkeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeletonBefore$.subscribe(o=>{if(o==null)return;const e={unitId:o.unitId,sheetId:o.sheetId};if(this._scrollManagerService.setSearchParam(e),!this._getSheetObject())return;const i=this._scrollManagerService.getScrollStateByParam(e),{viewportScrollX:r,viewportScrollY:s}=this._scrollManagerService.calcViewportScrollFromRowColOffset(i);i&&this._updateViewportScroll(r,s)})))}_updateViewportScroll(o=0,e=0){const t=this._getSheetObject();if(!t)return;const i=t.scene,r=i.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN),s=i.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT),l=i.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM),c=i.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT),d=i.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);r&&(r.viewportScrollX=o,r.viewportScrollY=e),l&&(l.viewportScrollY=e),s&&(s.viewportScrollX=o),c&&(c.viewportScrollY=e),d&&(d.viewportScrollX=o)}scrollToRange(o,e,t){let{endRow:i,endColumn:r,startColumn:s,startRow:l}=o;const c=this._getViewportBounding();if(o.rangeType===a.RANGE_TYPE.ROW?(s=0,r=0):o.rangeType===a.RANGE_TYPE.COLUMN&&(l=0,i=0),c&&!e&&!t){const d=c.startRow>i?l:i,u=c.startColumn>r?s:r;return this._scrollToCell(d,u)}else return this._scrollToCell(l,s,e,t)}scrollToCell(o,e){const t=this._context.unit.getActiveSheet(),{ySplit:i,xSplit:r}=t.getFreeze();return this._commandService.syncExecuteCommand(Ye.id,{sheetViewStartRow:o-i,sheetViewStartColumn:e-r,offsetX:0,offsetY:0})}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(o=>{switch(o.id){case m.SetSelectionsOperation.id:{const e=o.params;e.unitId===this._context.unitId&&e.reveal&&this._scrollToSelection()}break;case m.ScrollToCellOperation.id:{const e=o.params;if(e.unitId===this._context.unitId){const t=e.range;this.scrollToRange(t)}}break;case De.id:{const e=o.params;this._scrollToSelectionForExpand(e)}break}}))}_scrollToSelectionForExpand(o){setTimeout(()=>{const e=this._getSelectionsService().getCurrentLastSelection();if(e==null)return;const{startRow:t,startColumn:i,endRow:r,endColumn:s}=e.range,l=this._getViewportBounding();if(l==null)return;const{startRow:c,startColumn:d,endRow:u,endColumn:h}=l;let S=0,g=0;t>c?S=r:r<u?S=t:S=c,i>d?g=s:s<h?g=i:g=d,o.direction===a.Direction.DOWN?S=r:o.direction===a.Direction.UP?S=t:o.direction===a.Direction.RIGHT?g=s:o.direction===a.Direction.LEFT&&(g=i),this._scrollToCell(S,g)},0)}_getFreeze(){var e;const o=(e=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:e.skeleton.getWorksheetConfig();if(o!=null)return o.freeze}_updateSceneSize(o){var h;if(o==null)return;const{unitId:e}=this._context,{skeleton:t}=o,i=(h=this._renderManagerService.getRenderById(e))==null?void 0:h.scene;if(t==null||i==null)return;const{rowTotalHeight:r,columnTotalWidth:s,rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:c}=t;this._context.unit.getActiveSheet()&&(i==null||i.transformByState({width:l+s,height:c+r}))}_getSheetObject(){return ze(this._context.unit,this._context)}_scrollToSelectionByDirection(o){const e=this._getViewportBounding();if(e==null)return!1;const{startRow:t,startColumn:i,endRow:r,endColumn:s}=e;let l=0,c=0;const{startRow:d,startColumn:u,endRow:h,endColumn:S}=o;d>=t&&(l=h),h<=r&&(l=d),u>=i&&(c=S),S<=s&&(c=u),this._scrollToCell(l,c)}_scrollToSelection(o=!0){var d;const e=this._getSelectionsService().getCurrentLastSelection();if(!e)return;const{startRow:t,startColumn:i,actualRow:r,actualColumn:s}=(d=e.primary)!=null?d:e.range,l=o&&r!=null?r:t,c=o&&s!=null?s:i;this._scrollToCell(l,c)}_getSelectionsService(){return m.getSelectionsService(this._injector)}_getViewportBounding(){var r,s;const o=(r=this._getSheetObject())==null?void 0:r.scene;if(o==null)return;const e=o.getViewport(M.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 i=e.calcViewportInfo();return t.getRangeByViewBound(i.viewBound)}_scrollToCell(o,e,t=!1,i=!1){var D,H,W;const{rowHeightAccumulation:r,columnWidthAccumulation:s}=(D=this._sheetSkeletonManagerService.getCurrentSkeleton())!=null?D:{};if(r==null||s==null)return!1;const l=(H=this._getSheetObject())==null?void 0:H.scene;if(l==null)return!1;const c=l.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(c==null)return!1;const d=(W=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:W.skeleton;if(d==null)return!1;const u=this._context.unit.getActiveSheet();if(!u)return!1;o=a.Tools.clamp(o,0,r.length-1),e=a.Tools.clamp(e,0,s.length-1);const{startColumn:h,startRow:S,ySplit:g,xSplit:f}=u.getFreeze(),p=this._getViewportBounding();if(p==null)return!1;const{startRow:v,startColumn:C,endRow:_,endColumn:E}=p;let T,P;if(o>=S&&e>=h-g&&(o<=v&&(T=o,t=!0),o>=_)){const U=r[o]-c.height;for(let V=v;V<=o&&(T=V+1,!(r[V]>=U));V++);}if(e>=h&&o>=S-g&&(e<=C&&(P=e,i=!0),e>=E)){const U=s[e]-c.width;for(let V=C;V<=e&&(P=V+1,!(s[V]>=U));V++);}if(T===void 0&&P===void 0)return!1;let{offsetX:R,offsetY:O,sheetViewStartRow:A,sheetViewStartColumn:N}=this._scrollManagerService.getCurrentScrollState()||{};if(T=T?Math.min(T,o):A+g,P=P?Math.min(P,e):N+f,i){R=0,P=e;const U=d.getHiddenColumnsInRange({startColumn:P-f,endColumn:P});P=P-U.length}if(t){O=0,T=o;const U=d.getHiddenRowsInRange({startRow:T-g,endRow:T});T=T-U.length}return this._commandService.syncExecuteCommand(Ye.id,{sheetViewStartRow:Math.max(0,T-g),sheetViewStartColumn:Math.max(0,P-f),offsetX:R,offsetY:O})}},y.SheetsScrollRenderController=Su([mn(1,a.Inject(a.Injector)),mn(2,a.Inject(y.SheetSkeletonManagerService)),mn(3,a.IContextService),mn(4,a.ICommandService),mn(5,M.IRenderManagerService),mn(6,a.Inject(y.SheetScrollManagerService))],y.SheetsScrollRenderController);const mr={id:"sheet.operation.scroll-to-range",type:a.CommandType.OPERATION,handler:(n,o)=>{if(!o)return!1;const e=n.get(a.IUniverInstanceService);return n.get(M.IRenderManagerService).getRenderById(e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(y.SheetsScrollRenderController).scrollToRange(o.range,o.forceTop,o.forceLeft)}};class ca{constructor(){w(this,"_state",null);w(this,"_rect",null);w(this,"_state$",new k.BehaviorSubject(null));w(this,"state$",this._state$.asObservable());w(this,"_rect$",new k.BehaviorSubject(null));w(this,"rect$",this._rect$.asObservable());w(this,"_focus",!1);w(this,"_focus$",new k.BehaviorSubject(this._focus));w(this,"focus$",this._focus$.asObservable())}dispose(){this._state$.complete(),this._state=null,this._rect$.complete(),this._rect=null}setState(o){this._state=o,this._refresh(o)}getRect(){return this._rect}setRect(o){this._rect=o,this._rect$.next(o)}getState(){return this._state}setFocus(o=!1){this._focus=o,this._focus$.next(o)}_refresh(o){this._state$.next(o)}}const Qn=a.createIdentifier("univer.sheet-cell-editor-manager.service");var Ue=function(){return Ue=Object.assign||function(n){for(var o,e=1,t=arguments.length;e<t;e++){o=arguments[e];for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])}return n},Ue.apply(this,arguments)},fu=function(n,o){var e={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&o.indexOf(t)<0&&(e[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,t=Object.getOwnPropertySymbols(n);i<t.length;i++)o.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(n,t[i])&&(e[t[i]]=n[t[i]]);return e},Te=L.forwardRef(function(n,o){var e=n.icon,t=n.id,i=n.className,r=n.extend,s=fu(n,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(t," ").concat(i||"").trim(),c=L.useRef("_".concat(Cu()));return da(e,"".concat(t),{defIds:e.defIds,idSuffix:c.current},Ue({ref:o,className:l},s),r)});function da(n,o,e,t,i){return L.createElement(n.tag,Ue(Ue({key:o},pu(n,e,i)),t),(vu(n,e).children||[]).map(function(r,s){return da(r,"".concat(o,"-").concat(n.tag,"-").concat(s),e,void 0,i)}))}function pu(n,o,e){var t=Ue({},n.attrs);e!=null&&e.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=e.colorChannel1),n.tag==="mask"&&t.id&&(t.id=t.id+o.idSuffix),Object.entries(t).forEach(function(r){var s=r[0],l=r[1];s==="mask"&&typeof l=="string"&&(t[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(o.idSuffix,")")))});var i=o.defIds;return!i||i.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+o.idSuffix),Object.entries(t).forEach(function(r){var s=r[0],l=r[1];typeof l=="string"&&(t[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(o.idSuffix,")")))})),t}function vu(n,o){var e,t=o.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((e=n.children)===null||e===void 0)&&e.length)?Ue(Ue({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&t&&t.indexOf(i.attrs.id)>-1?Ue(Ue({},i),{attrs:Ue(Ue({},i.attrs),{id:i.attrs.id+o.idSuffix})}):i})}):n}function Cu(){return Math.random().toString(36).substring(2,8)}Te.displayName="UniverIcon";var Iu={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"}}]},ua=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"autofill",ref:o,icon:Iu}))});ua.displayName="Autofill";var _u={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"}}]},Vt=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"check-mark-single",ref:o,icon:_u}))});Vt.displayName="CheckMarkSingle";var bu={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"}}]},ha=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"close-single",ref:o,icon:bu}))});ha.displayName="CloseSingle";var Eu={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"]},ma=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"convert-single",ref:o,icon:Eu}))});ma.displayName="ConvertSingle";var wu={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"}}]},qi=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"delete-single",ref:o,icon:wu}))});qi.displayName="DeleteSingle";var Tu={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"}}]},Sr=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"dropdown-single",ref:o,icon:Tu}))});Sr.displayName="DropdownSingle";var yu={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"}}]},gr=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"error-single",ref:o,icon:yu}))});gr.displayName="ErrorSingle";var Mu={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"}}]},Sa=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"eyelash-single",ref:o,icon:Mu}))});Sa.displayName="EyelashSingle";var Ru={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"}}]},ga=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"fx-single",ref:o,icon:Ru}))});ga.displayName="FxSingle";var Pu={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"}}]},fa=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"hide-gridlines",ref:o,icon:Pu}))});fa.displayName="HideGridlines";var Ou={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"}}]},fr=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"increase-single",ref:o,icon:Ou}))});fr.displayName="IncreaseSingle";var Au={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"}}]},pr=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"lock-single",ref:o,icon:Au}))});pr.displayName="LockSingle";var ku={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"}}]},Sn=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"more-down-single",ref:o,icon:ku}))});Sn.displayName="MoreDownSingle";var Du={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"}}]},vr=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"more-single",ref:o,icon:Du}))});vr.displayName="MoreSingle";var Nu={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"}}]},pa=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"paint-bucket",ref:o,icon:Nu}))});pa.displayName="PaintBucket";var Hu={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"}}]}]},va=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"paste-special",ref:o,icon:Hu}))});va.displayName="PasteSpecial";var Vu={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"}}]},Ca=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"protect-single",ref:o,icon:Vu}))});Ca.displayName="ProtectSingle";var Wu={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"}}]},Cr=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"warning-single",ref:o,icon:Wu}))});Cr.displayName="WarningSingle";var Lu={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"}}]},Ir=L.forwardRef(function(n,o){return L.createElement(Te,Object.assign({},n,{id:"write-single",ref:o,icon:Lu}))});Ir.displayName="WriteSingle";const Uu=()=>{const[,n]=L.useState({});return L.useCallback(()=>n(o=>!o),[])},Bu=()=>{const n=I.useDependency(a.ICommandService),o=I.useDependency(a.IUniverInstanceService),e=I.useDependency(M.IRenderManagerService),t=I.useDependency(Ct),i=I.useDependency(a.LocaleService),[r,s]=L.useState([]),[l,c]=L.useState(!1),[d,u]=L.useState({row:-1,col:-1}),[h,S]=L.useState(de.SERIES),[g,f]=L.useState(!1),p=ot(),{sheetSkeletonManagerService:v,selectionRenderService:C}=L.useMemo(()=>{if(p){const X=e.getRenderById(p.getUnitId());return{sheetSkeletonManagerService:X==null?void 0:X.with(y.SheetSkeletonManagerService),selectionRenderService:X==null?void 0:X.with(ve)}}return{sheetSkeletonManagerService:null,selectionRenderService:null}},[p,e]),_=()=>{f(!0)},E=()=>{f(!1)},T=Uu();if(L.useEffect(()=>n.onCommandExecuted((Z,ne)=>{Z.id===Xe.id&&T()}).dispose,[T,n]),L.useEffect(()=>{const X=v&&a.toDisposable(v.currentSkeleton$.subscribe(Z=>{Z&&T()}));return X==null?void 0:X.dispose},[v,T]),L.useEffect(()=>a.toDisposable(t.menu$.subscribe(Z=>{s(Z.map(ne=>({...ne,index:Z.indexOf(ne)})))})).dispose,[t]),L.useEffect(()=>a.toDisposable(t.showMenu$.subscribe(Z=>{const{source:ne,target:J}=t.autoFillLocation||{source:null,target:null};if(Z&&ne&&J){const ae=Math.max(ne.rows[ne.rows.length-1],J.rows[J.rows.length-1]),ue=Math.max(ne.cols[ne.cols.length-1],J.cols[J.cols.length-1]);u({row:ae,col:ue})}else u({row:-1,col:-1})})).dispose,[t]),L.useEffect(()=>a.toDisposable(t.applyType$.subscribe(Z=>{S(Z)})).dispose,[t]),L.useEffect(()=>{function X(){c(!1)}return document.addEventListener("wheel",X),()=>{document.removeEventListener("wheel",X)}},[l]),d.col<0||d.row<0)return null;const P=ze(o,e);if(!P||!C)return null;const{scene:R}=P,O=v==null?void 0:v.getCurrentSkeleton(),A=C.getViewPort(),N=R==null?void 0:R.scaleX,D=R==null?void 0:R.scaleY,H=R==null?void 0:R.getViewportScrollXY(A);if(!N||!R||!N||!D||!H)return null;const W=(O==null?void 0:O.getNoMergeCellWithCoordByIndex(d.row,d.col).endX)||0,U=(O==null?void 0:O.getNoMergeCellWithCoordByIndex(d.row,d.col).endY)||0,V=M.convertTransformToOffsetX(W,N,H),B=M.convertTransformToOffsetY(U,D,H);if(V==null||B==null)return null;const x=X=>{c(X)},z=X=>{n.executeCommand(Yn.id,{type:X.value}),c(!1)},F=l||g,Y=r.filter(X=>!X.disable);return b.jsx("div",{className:"univer-absolute univer-inset-0 univer-z-10 univer-size-0",children:b.jsx("div",{className:"univer-absolute",style:{left:`${V+2}px`,top:`${B+2}px`},onMouseEnter:_,onMouseLeave:E,children:b.jsx(G.DropdownMenu,{align:"start",items:Y.map(X=>({type:"radio",value:h,options:[{label:i.t(X.label),value:X.value}],onSelect:()=>z(X)})),open:l,onOpenChange:x,children:b.jsxs("div",{className:G.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
|
`,S={...u,body:{dataStream:h,textRuns:c.textRuns,paragraphs:yr(h)}};d==null||d.reset(S),r=d==null?void 0:d.getSnapshot(),i=c.dataStream}else i=xh(o.innerHTML.replace(/[\r\n]/g,""));return{cellText:i,cellRichStyle:r}}_generateDocumentDataModelSnapshot(o){var l;const e=this._getCurrentSkeleton();if(e==null)return null;const{skeleton:t}=e,i=(l=t.getBlankCellDocumentModel())==null?void 0:l.documentModel,s={...i==null?void 0:i.getSnapshot(),...o};return i==null||i.reset(s),i==null?void 0:i.getSnapshot()}process(o,e,t,i){var r,s,l;for(const c of e)if(c.nodeName.toLowerCase()==="table")i.push({index:((r=t==null?void 0:t.paragraphs)==null?void 0:r.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;o&&this._styleCache.has(o)&&(u=this._styleCache.get(o));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=o?this._styleCache.get(o):{},S=this._styleRules.find(({filter:v})=>tl(c,v)),g=S?S.getStyle(c):no(c);this._styleCache.set(c,{...h,...g});const{childNodes:f}=c;this.process(c,f,t,i);const p=this._afterProcessRules.find(({filter:v})=>tl(c,v));p&&p.handler(t,c),this._processAfterLink(d,{body:t},u)}}}_processBeforeLink(o,e){return e.body.dataStream.length}_processAfterLink(o,e,t){var s,l;const i=e.body,r=o;r.tagName.toUpperCase()==="A"&&(i.customRanges=(s=i.customRanges)!=null?s:[],i.customRanges.push({startIndex:t,endIndex:i.dataStream.length-1,rangeId:(l=r.dataset.rangeid)!=null?l:a.generateRandomId(),rangeType:a.CustomRangeType.HYPERLINK,properties:{url:r.href}}))}dispose(){this._dom=null,this._styleCache.clear(),this._styleMap.clear()}};w(zo,"_pluginList",[]);let vn=zo;function Uh(n){const o=/<tr([\s\S]*?)>([\s\S]*?)<\/tr>/gi,e=n.matchAll(o);if(!e)return{rowProperties:[],rowCount:0};const i=Array.from(e).map(r=>il(r[1])).map(r=>{if(!r.height){const s=r.style,l=s&&s.match(/height\s*:\s*(\d+(\.\d+)?)px/);r.height=`${l?Number.parseInt(l[1],10):a.DEFAULT_WORKSHEET_ROW_HEIGHT}`}return r});return{rowProperties:i,rowCount:i.length}}function nl(n){const o={};return n.split(";").forEach(t=>{const[i,r]=t.split(":");o[i]=r}),o}function il(n){if(!n)return{};const o={},e=/([\w-]+)\s*=\s*(?:(['"])([^'"]*)\2|(\S+))/g;let t;for(;(t=e.exec(n))!==null;){const[,i,,r,s]=t,l=r!==void 0?r:s;o[i]=l}return o}function Bh(n){const o=/<colgroup([\s\S]*?)>(.*?)<\/colgroup>/,e=n.match(o),t=/<col([\s\S]*?)>/g;let i;if(e!=null&&e[2]?i=e[2].matchAll(t):i=n.matchAll(t),!i)return null;const r=Array.from(i).map(l=>il(l[1])),s=[];return r.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 xh(n){const o={"<":"<",">":">","&":"&",""":'"',"'":"'"," ":" "};return n.replace(/<|>|&|"|'| |<br>/g,e=>o[e])}function ol(n,o){if(!n||!o)return null;const e=new RegExp(`(${o}\\s*:\\s*[^;]+);`,"i"),t=n.match(e);return t?t[1]:null}function Fh(n,o,e,t){const{rowSpan:i,colSpan:r,rowIndex:s,colSetValueIndex:l}=t;for(let c=s;c<s+i;c++)for(let d=l;d<l+r;d++)c===s&&d===l?n.setValue(c,d,{...e,style:o}):n.setValue(c,d,{style:o})}const zh={name:"univer-doc-paste-plugin-lark",checkPasteType(n){return/lark-record-clipboard/i.test(n)},stylesRules:[{filter:["s"],getStyle(n){const o=no(n);return{st:{s:a.BooleanNumber.TRUE},...o}}}],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"}}]},Xh={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,o){n.paragraphs==null&&(n.paragraphs=[]);const e={startIndex:n.dataStream.length},t=Ja(o);t&&(e.paragraphStyle=t),n.paragraphs.push(e),n.dataStream+="\r"}}]},Yh={name:"univer-doc-paste-plugin-word",checkPasteType(n){return/word|mso/i.test(n)},stylesRules:[{filter:["b"],getStyle(n){const o=no(n);return{bl:a.BooleanNumber.TRUE,...o}}}],afterProcessRules:[{filter(n){return n.tagName==="P"&&/mso/i.test(n.className)},handler(n,o){n.paragraphs==null&&(n.paragraphs=[]);const e={startIndex:n.dataStream.length},t=Ja(o);t&&(e.paragraphStyle=t),n.paragraphs.push(e),n.dataStream+="\r"}}]};var st=(n=>(n.COPY="COPY",n.CUT="CUT",n))(st||{});function jh(n,o,e,t,i){const r=e.map(d=>{var u;return(u=d.onCopyRow)==null?void 0:u.call(d,n)}).filter(d=>!!d),s=Mr(r),l=Rr(s),c=o.map(d=>{if(!i.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 S=d;S<d+u.colSpan;S++)i.add(`${h}-${S}`);return Gh(n,d,e,t)}return null}).filter(d=>!!d).join("");return`<tr${l}>${c}</tr>`}function Gh(n,o,e,t){const i=t.getValue(n,o),r=e.map(d=>{var u;return(u=d.onCopyCellStyle)==null?void 0:u.call(d,n,o,i==null?void 0:i.rowSpan,i==null?void 0:i.colSpan)}).filter(d=>!!d),s=Mr(r),l=Rr(s),c=e.reduce((d,u)=>{var h;return d||((h=u.onCopyCellContent)==null?void 0:h.call(u,n,o))||""},"");return`<td${l}>${c}</td>`}function Zh(n,o){return`<colgroup>${n.map(t=>{const i=o.map(l=>{var c;return(c=l.onCopyColumn)==null?void 0:c.call(l,t)}).filter(l=>!!l),r=Mr(i);return`<col ${Rr(r)} />`}).join("")}</colgroup>`}function Mr(n){return n.reduce((o,e)=>(Object.keys(e).forEach(i=>{o[i]?o[i]+=`;${e[i]}`:o[i]=e[i]}),o),{})}function Rr(n){return Object.keys(n).reduce((o,e)=>`${o} ${e}="${n[e]}"`,"")}class Kh{convert(o,e,t){const{cols:i,rows:r}=e;if(!i.length)return"";const s=Zh(i,t),l=[],c=new Set;return r.forEach(u=>{l.push(jh(u,i,t,o,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 qh=(n,o,e=!1)=>{const t=h=>h.endRow-h.startRow+1,i=h=>h.endColumn-h.startColumn+1,r=t(o)%t(n),s=i(o)%i(n),l={startRow:0,endRow:t(n)-1,startColumn:0,endColumn:i(n)-1},c=Math.floor(t(o)/t(n)),d=Math.floor(i(o)/i(n)),u=[];if(!r&&!s)for(let h=1;h<=c;h++)for(let S=1;S<=d;S++){const g=t(n)*(h-1),f=i(n)*(S-1),p={startRow:g+o.startRow,endRow:g+o.startRow,startColumn:f+o.startColumn,endColumn:f+o.startColumn};u.push({repeatRelativeRange:l,startRange:p})}else if(!r&&s&&!e)for(let h=1;h<=c;h++){const S=t(n)*(h-1),g=0,f={startRow:S+o.startRow,endRow:S+o.startRow,startColumn:g+o.startColumn,endColumn:g+o.startColumn};u.push({repeatRelativeRange:l,startRange:f})}else if(r&&!s&&!e)for(let h=1;h<=d;h++){const g=i(n)*(h-1),f={startRow:0+o.startRow,endRow:0+o.startRow,startColumn:g+o.startColumn,endColumn:g+o.startColumn};u.push({repeatRelativeRange:l,startRange:f})}else{const h={startRow:o.startRow,endRow:o.startRow,startColumn:o.startColumn,endColumn:o.startColumn};u.push({startRange:h,repeatRelativeRange:l})}return u};function rl(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 Qh(n){if(!n)return!1;const o=/<img[^>]*src\s*=\s*["']data:image\/[^;]+;base64,[^"']*["'][^>]*>/i;return(n.match(o)||[]).length>0}function Jh(...n){if(n.length===1)return n[0];const o=new a.ObjectMatrix;return n.forEach(e=>{e&&new a.ObjectMatrix(e).forValue((i,r,s)=>{o.setValue(i,r,{...o.getValue(i,r),...s})})}),o.getMatrix()}function $h(n,o){return n.id===o.id&&n.params.unitId===o.params.unitId&&n.params.subUnitId===o.params.subUnitId}function Pr(n){const o=[];for(let e=0;e<n.length;){let t=1;if(n[e].id===m.SetRangeValuesMutation.id){const i=n[e],r=[i];for(;e+t<n.length&&$h(i,n[e+t]);)r.push(n[e+t]),t+=1;const s=Jh(...r.map(l=>l.params.cellValue||{}));o.push({...i,params:{...i.params,cellValue:s}})}else o.push(n[e]);e+=t}return o}function Or(n,o){const{startRow:e,endRow:t,startColumn:i,endColumn:r}=n;for(let s=e;s<=t;s++)for(let l=i;l<=r;l++)if(o.rows.includes(s)&&o.cols.includes(l))return!0}function sl(n,o){const{startRow:e,endRow:t,startColumn:i,endColumn:r}=o;for(let s=e;s<=t;s++)if(!n.rows.includes(s))return!1;for(let s=i;s<=r;s++)if(!n.cols.includes(s))return!1;return!0}function em(n){const o=n.trim().split(`
|
|
57
57
|
`);let e="<table>";return o.forEach(t=>{const i=t.split(" ");e+="<tr>",i.forEach(r=>{e+=`<td>${r}</td>`}),e+="</tr>"}),e+="</table>",e}var tm=Object.getOwnPropertyDescriptor,nm=(n,o,e,t)=>{for(var i=t>1?void 0:t?tm(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},ke=(n,o)=>(e,t)=>o(e,t,n);const fe={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"},im={[I.FILE_PNG_CLIPBOARD_MIME_TYPE]:"png",[I.FILE__JPEG_CLIPBOARD_MIME_TYPE]:"jpg",[I.FILE__WEBP_CLIPBOARD_MIME_TYPE]:"webp",[I.FILE__BMP_CLIPBOARD_MIME_TYPE]:"bmp"};vn.use(Yh),vn.use(zh),vn.use(Xh);const xe=a.createIdentifier("sheet.clipboard-service");y.SheetClipboardService=class extends a.Disposable{constructor(e,t,i,r,s,l,c,d,u,h,S,g,f,p){super();w(this,"_clipboardHooks",[]);w(this,"_clipboardHooks$",new k.BehaviorSubject([]));w(this,"clipboardHooks$",this._clipboardHooks$.asObservable());w(this,"_htmlToUSM");w(this,"_usmToHtml");w(this,"_copyContentCache");w(this,"_copyMarkId",null);w(this,"_pasteOptionsCache$",new k.BehaviorSubject(null));w(this,"pasteOptionsCache$",this._pasteOptionsCache$.asObservable());w(this,"_showMenu$",new k.BehaviorSubject(!1));w(this,"showMenu$",this._showMenu$.asObservable());this._logService=e,this._univerInstanceService=t,this._selectionManagerService=i,this._clipboardInterfaceService=r,this._undoRedoService=s,this._commandService=l,this._markSelectionService=c,this._notificationService=d,this._platformService=u,this._renderManagerService=h,this._themeService=S,this._localeService=g,this._errorService=f,this._injector=p,this._htmlToUSM=new vn({getCurrentSkeleton:()=>{var v;return(v=M.withCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,y.SheetSkeletonManagerService,this._univerInstanceService,this._renderManagerService))==null?void 0:v.getCurrentParam()}}),this._usmToHtml=new Kh,this._copyContentCache=new Vh,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,i,r=st.COPY){const s=this._clipboardHooks;s.forEach(c=>{var d;return(d=c.onBeforeCopy)==null?void 0:d.call(c,e,t,i,r)});const l=this._generateCopyContent(e,t,i,this._clipboardHooks);return s.forEach(c=>{var d;return(d=c.onAfterCopy)==null?void 0:d.call(c)}),l}async copy(e=st.COPY){const t=this._selectionManagerService.getCurrentLastSelection();if(!t)return!1;const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),r=i.getActiveSheet();if(!r)return!1;const s=i.getUnitId(),l=r.getSheetId(),c=this.generateCopyContent(s,l,t.range);if(!c)return!1;const{html:d,plain:u,matrixFragment:h,copyId:S,discreteRange:g}=c;this._copyContentCache.set(S,{unitId:i.getUnitId(),subUnitId:r.getSheetId(),range:g,matrix:h,copyType:e}),await this._clipboardInterfaceService.write(u,d),this._markSelectionService.removeAllShapes();const f=qa(this._themeService);return this._copyMarkId=this._markSelectionService.addShape({...t,style:f}),!0}async cut(){return this.copy(st.CUT)}async paste(e,t=fe.DEFAULT_PASTE){const i=e.types,r=i.indexOf(I.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(I.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(d=>d&&d.text()):"",s=i.indexOf(I.HTML_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(I.HTML_CLIPBOARD_MIME_TYPE).then(d=>d&&d.text()):"",l=i.findIndex(d=>I.imageMimeTypeSet.has(d)),c=l===-1||!Qh(s);if(s&&c)return this._platformService.isWindows&&rl(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=i[l],u=await e.getType(d);if(u){const h=im[d],S=new File([u],`clipboard-image.${h}`,{type:d});return this._pasteFiles([S],t)}}return r?this._pastePlainText(r,t):(this._logService.error("[SheetClipboardService]","No valid data on clipboard"),!1)}async legacyPaste(e,t,i){const r=rl(e!=null?e:"");return i&&!r?this._pasteFiles(i,fe.DEFAULT_PASTE):e?this._pasteHTML(e,fe.DEFAULT_PASTE):t?/[\n\t]/.test(t)?this._pasteHTML(em(t),fe.DEFAULT_PASTE):this._pastePlainText(t,fe.DEFAULT_PASTE):this._pasteUnrecognized()}rePasteWithPasteType(e){const t=this._pasteOptionsCache$.getValue();if(!t)return!1;const i=this._injector.get(a.IUndoRedoService),r=i.pitchTopUndoElement();r&&a.sequenceExecute(r.undoMutations,this._commandService)&&i.popUndoToRedo();const{cellMatrix:s,rowProperties:l=[],colProperties:c=[],source:d,target:u}=t;return this._pasteUSM({cellMatrix:s,colProperties:c,rowProperties:l},u,fe[e],d),!0}updatePasteOptionsCache(e){this._pasteOptionsCache$.next(e)}addClipboardHook(e){if(this._clipboardHooks.findIndex(i=>i.id===e.id)!==-1)return this._logService.error("[SheetClipboardService]","hook already exists",e.id),{dispose:()=>{}};const t=this._clipboardHooks.findIndex(i=>{const r=i.priority||0;return(e.priority||0)<r});return this._clipboardHooks.splice(t!==-1?t:this._clipboardHooks.length,0,e),this._notifyClipboardHook(),a.toDisposable(()=>{const i=this._clipboardHooks.indexOf(e);i>-1&&(this._clipboardHooks.splice(i,1),this._notifyClipboardHook())})}getClipboardHooks(){return this._clipboardHooks}_generateCopyContent(e,t,i,r){const s=this._univerInstanceService.getUniverSheetInstance(e),l=s==null?void 0:s.getSheetBySheetId(t);if(!s||!l)return null;const c=r.reduce((P,R)=>{var A;const O=(A=R.getFilteredOutRows)==null?void 0:A.call(R,i);return O==null||O.forEach(N=>P.add(N)),P},new Set),{startColumn:d,startRow:u,endColumn:h,endRow:S}=i,g=l.getMatrixWithMergedCells(u,d,S,h,a.CellModeEnum.Both),f=new a.ObjectMatrix;let p=u;const v=new a.ObjectMatrix,C={rows:[],cols:[]};for(let P=u;P<=S;P++)if(!c.has(P)){C.rows.push(P);for(let R=d;R<=h;R++){const O=g.getValue(P,R);if(O){const A=a.Tools.deepClone(O);v.setValue(p-u,R-d,{...ii(),...A}),delete A.displayV,f.setValue(p-u,R-d,{...ii(),...A})}else v.setValue(p-u,R-d,ii()),f.setValue(p-u,R-d,ii()),g.setValue(P,R,ii())}p+=1}for(let P=d;P<=h;P++)C.cols.push(P);let _=this._usmToHtml.convert(g,C,r);const E=al(v),T=Nh();return _=_.replace(/(<[a-z]+)/,(P,R)=>`${R} data-copy-id="${T}"`),{copyId:T,plain:E,html:_,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 i=this._injector.invoke(g=>m.rangeToDiscreteRange(t.selection.range,g,t.unitId,t.subUnitId));if(!i)return!1;const{unitId:r,subUnitId:s}=t,l=this._clipboardHooks,c=[];if(l.some(g=>{var f;return c.push(g)&&((f=g.onBeforePaste)==null?void 0:f.call(g,{unitId:r,subUnitId:s,range:i}))===!1}))return c.forEach(g=>{var f;return(f=g.onAfterPaste)==null?void 0:f.call(g,!1)}),!1;const u=[],h=[];c.forEach(g=>{const f=e(g,{unitId:r,subUnitId:s,range:i});f&&(u.push(...f.redos),h.push(...f.undos))});const S=u.every(g=>this._commandService.executeCommand(g.id,g.params));return S&&this._undoRedoService.pushUndoRedo({unitID:this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),undoMutations:h,redoMutations:u}),S}async _pasteFiles(e,t){return this._executePaste((i,r)=>{var s;return(s=i.onPasteFiles)==null?void 0:s.call(i,r,e,{pasteType:t})})}async _pastePlainText(e,t){return this._executePaste((i,r)=>{var s;return(s=i.onPastePlainText)==null?void 0:s.call(i,r,e,{pasteType:t})})}_pasteUnrecognized(){return this._executePaste((e,t)=>{var i;return(i=e.onPasteUnrecognized)==null?void 0:i.call(e,t)})}async _pasteHTML(e,t){const i=Hh(e);return i&&this._copyContentCache.get(i)?this._pasteInternal(i,t):this._pasteExternal(e,t)}async _pasteExternal(e,t){var h;const{rowProperties:i,colProperties:r,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(g=>Or(g,l.pastedRange)&&!sl(l.pastedRange,g))?(this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1):this._pasteUSM({rowProperties:i,colProperties:r,cellMatrix:s},l,t)}async _pasteInternal(e,t){var R,O;const i=a.Tools.deepClone(this._copyContentCache.get(e)),{range:r,matrix:s,unitId:l,subUnitId:c}=i||{};if(!s||!i||!r||!l||!c||!s||!i)return!1;const d=(R=this._univerInstanceService.getUniverSheetInstance(l))==null?void 0:R.getStyles();s.forValue((A,N,D)=>{if(typeof D.s=="string"){const H=a.Tools.deepClone(D);H.s=d==null?void 0:d.getStyleByCell(D),s.setValue(A,N,H)}if(D.colSpan||D.rowSpan)for(let H=0;H<D.rowSpan;H++)for(let W=0;W<D.colSpan;W++){if(H===0&&W===0)continue;const U=A+H,V=N+W;s.setValue(U,V,{s:d==null?void 0:d.getStyleByCell(D)})}});const u=this._getPastedRange(s);if(!u)return!1;const h=(O=this._univerInstanceService.getUniverSheetInstance(u.unitId))==null?void 0:O.getSheetBySheetId(u.subUnitId);if(!h)return!1;const S=h==null?void 0:h.getMergeData();if(S&&S.some(N=>Or(N,u.pastedRange)&&!sl(u.pastedRange,N)))return this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1;const g=this._univerInstanceService.getUnit(l);if(!g)return!1;const f=g.getSheetBySheetId(c);if(!f)return!1;const p=f.getColumnManager(),v=f.getRowManager(),C=f.getConfig().defaultColumnWidth,_=f.getConfig().defaultRowHeight,E=[],T=[];if(r.cols.forEach(A=>{const N=p.getColumnOrCreate(A);E.push({width:`${N.w||C}`})}),r.rows.forEach(A=>{const N=v.getRowOrCreate(A),{ah:D=_,h:H=_}=N,W=Math.max(D,H);T.push({height:`${W}`})}),i.copyType===st.CUT){const A=u.pastedRange.rows[0],N=r.rows[r.rows.length-1]-r.rows[0]+A;u.pastedRange.rows=Array.from(new Array(N+1).keys()).slice(A)}const P=this._pasteUSM({cellMatrix:s,colProperties:E,rowProperties:T},u,t,{range:r,unitId:i.unitId,subUnitId:i.subUnitId,copyType:i.copyType,copyId:e});return i.copyType===st.CUT&&(this._copyContentCache.set(e,{...i,matrix:null}),this._copyMarkId&&this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null),P}_pasteUSM(e,t,i,r){const{rowProperties:s,colProperties:l,cellMatrix:c}=e,{unitId:d,subUnitId:u,pastedRange:h}=t,S=h.cols.length,g=this._clipboardHooks,f=[];if(g.some(O=>{var A;return f.push(O)&&((A=O.onBeforePaste)==null?void 0:A.call(O,{unitId:d,subUnitId:u,range:h}))===!1}))return f.forEach(O=>{var A;return(A=O.onAfterPaste)==null?void 0:A.call(O,!1)}),!1;if(!c)return!1;const v=r?{unitId:r.unitId,subUnitId:r.subUnitId,range:r.range}:null,C={copyType:(r==null?void 0:r.copyType)||st.COPY,copyId:r==null?void 0:r.copyId,pasteType:i};let _=[],E=[];const T=f.filter(O=>!O.specialPasteInfo&&O.id!==fe.DEFAULT_PASTE||i===O.id);T.forEach(O=>{var D,H,W;if(s){const U=(D=O.onPasteRows)==null?void 0:D.call(O,{range:h,unitId:d,subUnitId:u},s,{pasteType:i});U&&(_.push(...U.redos),E.push(...U.undos))}const A=(H=O.onPasteColumns)==null?void 0:H.call(O,{range:h,unitId:d,subUnitId:u},l||new Array(S).map(()=>({})),{pasteType:i});A&&(_.push(...A.redos),E.push(...A.undos));const N=(W=O.onPasteCells)==null?void 0:W.call(O,v,{range:h,unitId:d,subUnitId:u},c,C);N&&(_.push(...N.redos),E.push(...N.undos))});const P=this._getSetSelectionOperation(d,u,h,c,i);P&&_.push(P),_=Pr(_),E=Pr(E),E.push({id:m.SetWorksheetActiveOperation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId}}),this._logService.log("[SheetClipboardService]","pasting mutations",{undoMutationsInfo:E,redoMutationsInfo:_});const R=_.every(O=>this._commandService.syncExecuteCommand(O.id,O.params));return R&&(this._undoRedoService.pushUndoRedo({unitID:d,undoMutations:E,redoMutations:_}),this.updatePasteOptionsCache({target:{pastedRange:h,unitId:d,subUnitId:u},cellMatrix:c,rowProperties:s,colProperties:l,pasteType:i,source:r}),this.setShowMenu(!0)),T.forEach(O=>{var A;return(A=O.onAfterPaste)==null?void 0:A.call(O,R)}),R}_getSetSelectionOperation(e,t,i,r,s){var P;const l=(P=this._univerInstanceService.getUniverSheetInstance(e))==null?void 0:P.getSheetBySheetId(t);if(!l)return null;const{rows:c,cols:d}=i,u=c[0],h=d[0],S=c[c.length-1],g=d[d.length-1],f={startRow:u,endRow:u,startColumn:h,endColumn:h},p=m.getPrimaryForRange(f,l),v=r.getValue(0,0),C=(v==null?void 0:v.rowSpan)||1,_=(v==null?void 0:v.colSpan)||1;if((s===fe.DEFAULT_PASTE||s===fe.SPECIAL_PASTE_BESIDES_BORDER||s===fe.SPECIAL_PASTE_FORMAT)&&(C>1||_>1)){const R={startRow:u,endRow:u+C-1,startColumn:h,endColumn:h+_-1};p.startRow=R.startRow,p.endRow=R.endRow,p.startColumn=R.startColumn,p.endColumn=R.endColumn,p.isMerged=!0,p.isMergedMainCell=!0}const T={unitId:e,subUnitId:t,selections:[{range:{startRow:u,endRow:S,startColumn:h,endColumn:g},primary:p,style:null}]};return{id:m.SetSelectionsOperation.id,params:T}}_getPastingTarget(){const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),t=e.getActiveSheet(),i=this._selectionManagerService.getCurrentLastSelection();return{unitId:e.getUnitId(),subUnitId:t==null?void 0:t.getSheetId(),selection:i}}_transformPastedData(e,t,i){const r=this._getPastingTarget(),{selection:s,unitId:l,subUnitId:c}=r;if(!c||!s)return null;const d=this._injector.invoke(H=>m.rangeToDiscreteRange(s.range,H,l,c));if(!d)return null;const{ranges:[u],mapFunc:h}=Ot([d]),{startRow:S,startColumn:g,endRow:f,endColumn:p}=u,v=f-S+1,C=p-g+1,_=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),E=_==null?void 0:_.getActiveSheet();if(!E)return null;const P=E.getMergeData().filter(H=>d.rows.includes(H.startRow)&&d.cols.includes(H.startColumn)),R=P[0];let O=0,A=0,N=0,D=0;if(R&&(O=R.startRow,A=R.startColumn,N=R.endRow,D=R.endColumn),v%e===0&&C%t===0)if(P.length>0&&(v!==e||C!==t))if(O===d.rows[0]&&A===d.cols[0]&&N===d.rows[v-1]&&D===d.cols[C-1])if(am(i))for(let W=0;W<v;W++)for(let U=0;U<C;U++){const V=i.getValue(W%e,U%t);V&&i.setValue(W,U,V)}else i.forValue((W,U,V)=>{V.s=null,delete V.colSpan,delete V.rowSpan});else for(let H=0;H<v;H++)for(let W=0;W<C;W++){const U=i.getValue(H%e,W%t);U&&i.setValue(H,W,U)}else for(let H=0;H<v;H++)for(let W=0;W<C;W++){const U=i.getValue(H%e,W%t);U&&i.setValue(H,W,U)}else if(P.length>0){const{row:H,col:W}=h(S,g);if(this._topLeftCellsMatch(e,t,{topRow:H,leftCol:W})){const V=this._expandOrShrinkRowsCols(l,c,d,t,e);d.rows=V.rows,d.cols=V.cols}else{if(f>R.endRow||p>R.endColumn)return null;i.forValue((V,B,x)=>{x.s=null,delete x.colSpan,delete x.rowSpan})}}else{const H=this._expandOrShrinkRowsCols(l,c,d,t,e);d.rows=H.rows,d.cols=H.cols}return{pastedRange:d,unitId:l,subUnitId:c}}_getPastedRange(e){var E;const t=this._getPastingTarget(),{selection:i,unitId:r,subUnitId:s}=t;if(!s||!i)return null;const l=this._injector.invoke(T=>m.rangeToDiscreteRange(i.range,T,r,s));if(!l)return null;const{startColumn:c,endColumn:d,startRow:u,endRow:h}=e.getDataRange(),S=h-u+1,g=d-c+1;if(S<=0||g<=0)return null;const f=l.rows.length,p=l.cols.length,v=(E=this._univerInstanceService.getUniverSheetInstance(r))==null?void 0:E.getSheetBySheetId(s);if(!v)return null;const C=v==null?void 0:v.getMergeData();if(f%S===0&&p%g===0&&!(C==null?void 0:C.some(P=>Or(P,l)))){for(let P=0;P<f;P++)for(let R=0;R<p;R++){const O=e.getValue(P%S,R%g);O&&e.setValue(P,R,O)}return{pastedRange:l,unitId:r,subUnitId:s}}const _=this._expandOrShrinkRowsCols(r,s,l,g,S);return l.rows=_.rows,l.cols=_.cols,{pastedRange:l,unitId:r,subUnitId:s}}_expandOrShrinkRowsCols(e,t,i,r,s){const{rows:l,cols:c}=i,d=this._univerInstanceService.getUniverSheetInstance(e),u=d==null?void 0:d.getSheetBySheetId(t);let h,S;if(l.length>=s)h=l.slice(0,s);else{h=l.slice(0);let g=l[l.length-1]+1;for(;h.length<s;)u.getRowFiltered(g)||h.push(g),g++}if(c.length>=r)S=c.slice(0,r);else{S=c.slice(0);let g=c[c.length-1]+1;for(;S.length<r;)S.push(g),g++}return{rows:h,cols:S}}_topLeftCellsMatch(e,t,i){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=r==null?void 0:r.getActiveSheet();if(!s)return!1;const{topRow:l,leftCol:c}=i,d=rm(l+e-1,c,c+t-1,s),u=sm(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)}},y.SheetClipboardService=nm([ke(0,a.ILogService),ke(1,a.IUniverInstanceService),ke(2,a.Inject(m.SheetsSelectionsService)),ke(3,I.IClipboardInterfaceService),ke(4,a.IUndoRedoService),ke(5,a.ICommandService),ke(6,Ut),ke(7,I.INotificationService),ke(8,I.IPlatformService),ke(9,M.IRenderManagerService),ke(10,a.Inject(a.ThemeService)),ke(11,a.Inject(a.LocaleService)),ke(12,a.Inject(a.ErrorService)),ke(13,a.Inject(a.Injector))],y.SheetClipboardService);function al(n){let o="";const e=n.getLength();return n.forRow((t,i)=>{const r=[];i.forEach(s=>{const l=n.getValue(t,s);if(l){const c=om(l);r.push(c)}}),o+=r.join(" "),t!==e-1&&(o+=`
|
|
58
|
-
`)}),o}function om(n){return a.isNotNullOrUndefined(n.displayV)?n.displayV:a.extractPureTextFromCell(n)}function rm(n,o,e,t){return t.getMergeData().some(i=>i.startRow<=n&&n<i.endRow&&o<=i.startColumn&&i.startColumn<=e)}function sm(n,o,e,t){return t.getMergeData().some(i=>i.startColumn<=n&&n<i.endColumn&&o<=i.startRow&&i.startRow<=e)}function am(n){let o=0;return n.forValue((e,t,i)=>{if(i&&o++,o>1)return!1}),o>1}function ii(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const Ar=998,je={id:I.CopyCommand.id,name:"sheet.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:Ar,preconditions:br,handler:async n=>n.get(xe).copy()},kr={id:I.CutCommand.id,name:"sheet.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:Ar,preconditions:br,handler:async n=>n.get(xe).cut()},Ge={id:I.PasteCommand.id,type:a.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:Ar,preconditions:br,handler:async(n,o)=>{const t=await n.get(I.IClipboardInterfaceService).read(),i=n.get(xe);return t.length!==0?i.paste(t[0],o==null?void 0:o.value):!1}},io={id:I.SheetPasteShortKeyCommandName,type:a.CommandType.COMMAND,handler:async(n,o)=>{const e=n.get(xe),{htmlContent:t,textContent:i,files:r}=o;return e.legacyPaste(t,i,r),!0}},Cn={id:"sheet.command.paste-value",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ge.id,{value:fe.SPECIAL_PASTE_VALUE})},In={id:"sheet.command.paste-format",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ge.id,{value:fe.SPECIAL_PASTE_FORMAT})},Bt={id:"sheet.command.paste-col-width",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ge.id,{value:fe.SPECIAL_PASTE_COL_WIDTH})},_n={id:"sheet.command.paste-besides-border",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ge.id,{value:fe.SPECIAL_PASTE_BESIDES_BORDER})},ll={id:"sheet.command.optional-paste",type:a.CommandType.COMMAND,handler:async(n,{type:o})=>n.get(xe).rePasteWithPasteType(o)},oi={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),i=n.get(a.IUniverInstanceService),r=m.getSheetCommandTarget(i);if(!r)return!1;const{worksheet:s}=r,l=s.getVisibleRows();if(aa(l,e)){const d=n.get(I.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}},ri={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),i=n.get(a.IUniverInstanceService),r=m.getSheetCommandTarget(i);if(!r)return!1;const{worksheet:s}=r,l=s.getVisibleCols();if(la(l,e)){const d=n.get(I.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}},xt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async n=>{const o=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?o.executeCommand(Q.SetInlineFormatBoldCommand.id):o.executeCommand(m.SetBoldCommand.id)}},Ft={type:a.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async n=>{const o=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?o.executeCommand(Q.SetInlineFormatItalicCommand.id):o.executeCommand(m.SetItalicCommand.id)}},zt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async n=>{const o=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?o.executeCommand(Q.SetInlineFormatUnderlineCommand.id):o.executeCommand(m.SetUnderlineCommand.id)}},Xt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async n=>{const o=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?o.executeCommand(Q.SetInlineFormatStrikethroughCommand.id):o.executeCommand(m.SetStrikeThroughCommand.id)}},Dr={type:a.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async n=>{const o=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?o.executeCommand(Q.SetInlineFormatSubscriptCommand.id):!1}},Nr={type:a.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async n=>{const o=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?o.executeCommand(Q.SetInlineFormatSuperscriptCommand.id):!1}},si={type:a.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(n,o)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(Q.SetInlineFormatFontSizeCommand.id,o):e.executeCommand(m.SetFontSizeCommand.id,o)}},ai={type:a.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(n,o)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(Q.SetInlineFormatFontFamilyCommand.id,o):e.executeCommand(m.SetFontFamilyCommand.id,o)}},bn={type:a.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(n,o)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(Q.SetInlineFormatTextColorCommand.id,o):e.executeCommand(m.SetTextColorCommand.id,o)}},Hr={type:a.CommandType.COMMAND,id:"sheet.command.reset-range-text-color",handler:async n=>{const o=n.get(a.ICommandService),t=n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED),i=n.get(a.ThemeService);return t?o.executeCommand(Q.SetInlineFormatTextColorCommand.id,{value:null}):o.executeCommand(m.SetTextColorCommand.id,{value:i.getCurrentTheme().textColor})}};var lm=Object.getOwnPropertyDescriptor,cm=(n,o,e,t)=>{for(var i=t>1?void 0:t?lm(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},En=(n,o)=>(e,t)=>o(e,t,n),Ne=(n=>(n[n.OFF=0]="OFF",n[n.ONCE=1]="ONCE",n[n.INFINITE=2]="INFINITE",n))(Ne||{});const $e=a.createIdentifier("univer.format-painter-service");let oo=class extends a.Disposable{constructor(o,e,t,i,r,s){super();w(this,"status$");w(this,"_selectionFormat");w(this,"_markId",null);w(this,"_status$");w(this,"_defaultHook",null);w(this,"_extendHooks",[]);this._selectionManagerService=o,this._themeService=e,this._markSelectionService=t,this._logService=i,this._commandService=r,this._undoRedoService=s,this._status$=new k.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new a.ObjectMatrix,merges:[]}}addHook(o){var e,t,i;o.isDefaultHook&&((e=o.priority)!=null?e:0)>((i=(t=this._defaultHook)==null?void 0:t.priority)!=null?i:-1)?this._defaultHook=o:(this._extendHooks.push(o),this._extendHooks.sort((r,s)=>(r.priority||0)-(s.priority||0)))}getHooks(){return this._defaultHook?[this._defaultHook,...this._extendHooks]:this._extendHooks}setStatus(o){this._updateRangeMark(o),this._status$.next(o),this.getHooks().forEach(t=>{t.onStatusChange!==void 0&&t.onStatusChange(o)})}getStatus(){return this._status$.getValue()}setSelectionFormat(o){this._selectionFormat=o}getSelectionFormat(){return this._selectionFormat}applyFormatPainter(o,e,t){const i=this.getHooks(),r=[],s=[];i.forEach(c=>{if(c.onApply!==void 0){const d=c.onApply(o,e,t,this._selectionFormat);d&&(r.push(...d.redos),s.push(...d.undos))}});for(const c of i)if(c.onBeforeApply!==void 0&&!c.onBeforeApply({unitId:o,subUnitId:e,range:t,redoMutationsInfo:r,format:this._selectionFormat,undoMutationsInfo:s}))return!1;this._logService.log("[FormatPainterService]","apply mutations",{undoMutationsInfo:s,redoMutationsInfo:r});const l=r.every(c=>this._commandService.executeCommand(c.id,c.params));return l&&this._undoRedoService.pushUndoRedo({unitID:o,undoMutations:s,redoMutations:r}),l}_updateRangeMark(o){if(this._markSelectionService.removeAllShapes(),o!==0){const e=this._selectionManagerService.getCurrentLastSelection();if(e){const t=qa(this._themeService);o===2?this._markId=this._markSelectionService.addShape({...e,style:t}):this._markId=this._markSelectionService.addShape({...e,style:t},[m.SetRangeValuesMutation.id])}}}};oo=cm([En(0,a.Inject(m.SheetsSelectionsService)),En(1,a.Inject(a.ThemeService)),En(2,Ut),En(3,a.ILogService),En(4,a.ICommandService),En(5,a.IUndoRedoService)],oo);const li={id:"sheet.operation.set-format-painter",type:a.CommandType.OPERATION,handler:(n,o)=>o?(n.get($e).setStatus(o.status),!0):!1},ro={type:a.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async n=>{const e=n.get($e).getStatus();let t;return e!==Ne.OFF?t=Ne.OFF:t=Ne.INFINITE,n.get(a.ICommandService).executeCommand(li.id,{status:t})}},wn={type:a.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async n=>{const e=n.get($e).getStatus();let t;return e!==Ne.OFF?t=Ne.OFF:t=Ne.ONCE,n.get(a.ICommandService).executeCommand(li.id,{status:t})}},ci={type:a.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(n,o)=>n.get($e).applyFormatPainter(o.unitId,o.subUnitId,o.range)},at={type:a.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(n,o)=>{const{type:e}=o||{},t=n.get(a.IUniverInstanceService),i=n.get(a.IUndoRedoService),r=m.getSheetCommandTarget(t);if(!r)return!1;const{unitId:s,subUnitId:l}=r,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:S}=h,f=n.get(M.IRenderManagerService).getRenderById(s).with(y.SheetScrollManagerService),{sheetViewStartRow:p=0,sheetViewStartColumn:v=0}=f.getCurrentScrollState()||{};let C,_,E,T;const{startRow:P,startColumn:R,rangeType:O}=S;if(O===a.RANGE_TYPE.ROW||e===1)C=P,E=P-p,_=-1,T=0;else if(O===a.RANGE_TYPE.COLUMN||e===2)C=-1,E=0,_=R,T=R-v;else if(O===a.RANGE_TYPE.NORMAL)C=P,E=P-p,_=R,T=R-v;else return!1;const A={unitId:s,subUnitId:l,startRow:C,startColumn:_,xSplit:_>0?Math.max(1,T):T,ySplit:C>0?Math.max(1,E):E},N=m.SetFrozenMutationFactory(n,A);return c.syncExecuteCommand(m.SetFrozenMutation.id,A)&&i.pushUndoRedo({unitID:s,undoMutations:[{id:m.SetFrozenMutation.id,params:N}],redoMutations:[{id:m.SetFrozenMutation.id,params:A}]}),!0}},di={type:a.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand(at.id,{type:1}),!0)},ui={type:a.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand(at.id,{type:2}),!0)};var dm=Object.getOwnPropertyDescriptor,um=(n,o,e,t)=>{for(var i=t>1?void 0:t?dm(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},cl=(n,o)=>(e,t)=>o(e,t,n);const hm=(n,o)=>{const{unitId:e,subUnitId:t,ranges:i}=n,r={},s=o.getColumnManager();for(let l=0;l<i.length;l++){const c=i[l];for(let d=c.startColumn;d<c.endColumn+1;d++){const u=s.getColumnOrCreate(d);r[d]=u.w}}return{unitId:e,subUnitId:t,ranges:i,colWidth:r}};y.AutoWidthController=class extends a.Disposable{constructor(o,e){super(),this._renderManagerService=o,this._univerInstanceService=e}getUndoRedoParamsOfColWidth(o){const e={redos:[],undos:[]},{_univerInstanceService:t}=this,i=m.getSheetCommandTarget(t);if(!i)return e;const{unitId:r,subUnitId:s,worksheet:l}=i,c=this._renderManagerService.getRenderById(r).with(y.SheetSkeletonManagerService);if(!c.getCurrentParam())return e;const{skeleton:d}=c.getCurrentParam(),u=d.calculateAutoWidthInRange(o.ranges),h={};for(const{col:f,width:p}of u)h[f]=p;const S={subUnitId:s,unitId:r,ranges:o.ranges,colWidth:h},g=hm(S,l);return{undos:[{id:m.SetWorksheetColWidthMutation.id,params:g}],redos:[{id:m.SetWorksheetColWidthMutation.id,params:S}]}}},y.AutoWidthController=um([cl(0,M.IRenderManagerService),cl(1,a.Inject(a.IUniverInstanceService))],y.AutoWidthController);const hi={type:a.CommandType.COMMAND,id:"sheet.command.set-col-auto-width",handler:(n,o)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),i=n.get(m.SheetsSelectionsService),r=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(r,o);if(!s)return!1;const{unitId:l,subUnitId:c}=s;let d=[];if(o!=null&&o.ranges)d=[...o.ranges];else{const f=i.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:S}=n.get(y.AutoWidthController).getUndoRedoParamsOfColWidth(u);return a.sequenceExecute([...h],e).result?(t.pushUndoRedo({unitID:l,undoMutations:[...S],redoMutations:[...h]}),!0):!1}},Tn="UI_PLUGIN_SHEETS",mi=`${Tn}_COLOR_PICKER_COMPONENT`,so=`${Tn}_FONT_FAMILY_COMPONENT`,ao=`${Tn}_FONT_FAMILY_ITEM_COMPONENT`,lo=`${Tn}_FONT_SIZE_COMPONENT`,et=`${Tn}_MENU_ITEM_INPUT_COMPONENT`,Vr={sheetsUiContextMenuInput:"univer-sheets-ui-context-menu-input",sheetsUiContextMenuInputContainer:"univer-sheets-ui-context-menu-input-container",sheetsUiContextMenuInputNumber:"univer-sheets-ui-context-menu-input-number"},dl=n=>{const{prefix:o,suffix:e,value:t,onChange:i,min:r=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=n,l=I.useDependency(a.LocaleService),c=I.useDependency(I.IContextMenuService),[d,u]=L.useState(),h=g=>{var f;u(g==null?void 0:g.toString()),i((f=g==null?void 0:g.toString())!=null?f:"")};L.useEffect(()=>{c.visible||u(t)},[c.visible]),L.useEffect(()=>{u(t)},[t]);function S(g){g.key==="Backspace"&&g.stopPropagation()}return b.jsxs("div",{className:Vr.sheetsUiContextMenuInput,children:[l.t(o),b.jsx("span",{className:Vr.sheetsUiContextMenuInputContainer,onClick:g=>g.stopPropagation(),children:b.jsx(G.InputNumber,{className:Vr.sheetsUiContextMenuInputNumber,value:Number(d),precision:0,onKeyDown:S,onChange:h,min:r,max:s})}),l.t(e)]})};function mm(n){return n.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(Se.switchMap(o=>o?o.activeSheet$.pipe(Se.map(e=>e?{workbook:o,worksheet:e}:null)):k.of(null)))}function Ee(n,o,e){return mm(n).pipe(Se.switchMap(t=>t?e(t):k.of(o)))}function ul(n,o){const e=n.get(a.IUniverInstanceService),t=n.get(m.IExclusiveRangeService),i=n.get(m.SheetsSelectionsService);return e.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(Se.switchMap(s=>s?k.combineLatest([i.selectionMoveEnd$,s.activeSheet$]).pipe(Se.switchMap(([l,c])=>{if(!c||l.length===0)return k.of(!1);const d=t.getInterestGroupId(l);if(o){const u=d.filter(h=>o.has(h));return k.of(u.length>0)}else return k.of(d.length>0)})):k.of(!1)))}function Yt(n,o,e){return k.combineLatest([o,ul(n,e)]).pipe(Se.map(([t,i])=>t||i))}function ee(n,o={},e=!1){const i=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),r=n.get(a.UserManagerService),s=n.has(ge)?n.get(ge):null,l=n.get(a.IContextService),c=new k.BehaviorSubject(!1),d=s==null?void 0:s.visible$,u=new k.BehaviorSubject(null),h=l.subscribeContextValue$(a.FOCUSING_FX_BAR_EDITOR).subscribe(f=>{c.next(f)}),S=d==null?void 0:d.subscribe(f=>{u.next(f)});return k.combineLatest([r.currentUser$,i,u,c]).pipe(Se.finalize(()=>{h.unsubscribe(),S==null||S.unsubscribe(),c.complete()}),Se.switchMap(([f,p,v,C])=>!p||v!=null&&v.visible&&v.unitId===p.getUnitId()&&!e||C&&!e?k.of(!0):p.activeSheet$.pipe(Se.switchMap(_=>{if(!_)return k.of(!0);const E=n.get(m.SheetsSelectionsService),T=n.get(m.RangeProtectionRuleModel),P=n.get(m.WorksheetProtectionRuleModel),O=n.get(a.IContextService).subscribeContextValue$(a.FOCUSING_COMMON_DRAWINGS).pipe(Se.startWith(!1));return k.combineLatest([E.selectionMoveEnd$,O]).pipe(Se.switchMap(([A,N])=>{if(N)return k.of(!0);const D=p.getUnitId(),H=_.getSheetId(),W=n.get(a.IPermissionService),{workbookTypes:U=[m.WorkbookEditablePermission],worksheetTypes:V,rangeTypes:B}=o,x=[];if(U==null||U.forEach(X=>{x.push(new X(D).id)}),V==null||V.forEach(X=>{x.push(new X(D,H).id)}),P.getRule(D,H))return W.composePermission$(x).pipe(Se.map(X=>X.some(Z=>Z.value===!1)));const F=A==null?void 0:A.map(X=>X.range),Y=T.getSubunitRuleList(D,H).filter(X=>F==null?void 0:F.some(Z=>X.ranges.some(ne=>a.Rectangle.intersects(Z,ne))));return B==null||B.forEach(X=>{Y.forEach(Z=>{x.push(new X(D,H,Z.permissionId).id)})}),W.composePermission$(x).pipe(Se.map(X=>X.some(Z=>Z.value===!1)))}))}))))}function yn(n){const o=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(m.RangeProtectionRuleModel),i=n.get(a.IPermissionService);return k.merge(e.selectionMoveEnd$,i.permissionPointUpdate$.pipe(Se.debounceTime(100))).pipe(Se.map(()=>{var h;const r=(h=e.getCurrentLastSelection())==null?void 0:h.range;if(!r)return!0;const s=o.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(S=>S.ranges.some(g=>a.Rectangle.intersects(r,g))).forEach(S=>{u.push(new m.RangeProtectionPermissionEditPoint(c,d,S.permissionId).id)}),i.composePermission(u).some(S=>S.value===!1)}))}function hl(n,o){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(m.RangeProtectionRuleModel),r=n.get(a.IPermissionService);return k.merge(t.selectionMoveEnd$,r.permissionPointUpdate$.pipe(Se.debounceTime(100))).pipe(Se.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];return i.getSubunitRuleList(d,u).filter(g=>o==="row"?g.ranges.some(f=>s.startRow>f.startRow&&s.startRow<=f.endRow):g.ranges.some(f=>s.startColumn>f.startColumn&&s.startColumn<=f.endColumn)).forEach(g=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,g.permissionId).id)}),r.composePermission(h).some(g=>g.value===!1)}))}function ml(n,o){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(m.RangeProtectionRuleModel),r=n.get(a.IPermissionService);return k.merge(t.selectionMoveEnd$,r.permissionPointUpdate$.pipe(Se.debounceTime(100))).pipe(Se.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],S=a.Tools.deepClone(s);return o==="row"?(S.startColumn=0,S.endColumn=c.getColumnCount()-1):(S.startRow=0,S.endRow=c.getRowCount()-1),i.getSubunitRuleList(d,u).filter(f=>f.ranges.some(p=>a.Rectangle.intersects(S,p))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),r.composePermission(h).some(f=>f.value===!1)}))}function co(n,o){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(m.RangeProtectionRuleModel),r=n.get(a.IPermissionService);return k.merge(t.selectionMoveEnd$,r.permissionPointUpdate$.pipe(Se.debounceTime(100))).pipe(Se.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],S=a.Tools.deepClone(s);return o==="row"?S.endRow=c.getRowCount()-1:S.endColumn=c.getColumnCount()-1,i.getSubunitRuleList(d,u).filter(f=>f.ranges.some(p=>a.Rectangle.intersects(S,p))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),r.composePermission(h).some(f=>f.value===!1)}))}function Mn(n,o){const t=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(m.WorksheetProtectionRuleModel),r=n.get(m.RangeProtectionRuleModel),s=n.get(a.IPermissionService),l=n.get(a.UserManagerService);return k.combineLatest([l.currentUser$,t]).pipe(Se.switchMap(([c,d])=>d?d.activeSheet$.pipe(Se.switchMap(u=>{if(!u)return k.of(!0);const h=d.getUnitId(),S=[];return o.forEach(f=>S.push(new f(h).id)),s.composePermission$(S).pipe(Se.map(f=>f.every(p=>p.value===!0))).pipe(Se.map(f=>{if(!f)return!0;const p=u.getSheetId(),v=i.getRule(h,p),C=r.getSubunitRuleList(h,p);return!!(v||C.length)}))})):k.of(!0)))}var Sl=(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))(Sl||{});function Sm(n){const o=n.get($e);return{id:wn.id,subId:ro.id,type:I.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",activated$:new k.Observable(e=>{let t=!1;const i=o.status$.subscribe(r=>{t=r!==Ne.OFF,e.next(t)});return e.next(t),()=>{i.unsubscribe()}}),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetCopyPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function gm(n){const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IContextService),i=n.get(m.SheetsSelectionsService);return{id:xt.id,type:I.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:Ee(e,!1,({worksheet:r})=>new k.Observable(s=>{var u;const l=o.onCommandExecuted(h=>{var g,f;const S=h.id;if(S===m.SetRangeValuesMutation.id||S===m.SetSelectionsOperation.id||S===m.SetWorksheetActiveOperation.id){const p=(g=i.getCurrentLastSelection())==null?void 0:g.primary;let v=a.FontWeight.NORMAL;if(p!=null){const C=r.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getFontWeight()}s.next(v===a.FontWeight.BOLD)}if((S===we.SetTextSelectionsOperation.id||S===Q.SetInlineFormatCommand.id)&&t.getContextValue(a.EDITOR_ACTIVATED)&&t.getContextValue(a.FOCUSING_SHEET)){const p=fi(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.bl;s.next(v===a.BooleanNumber.TRUE)}}),c=(u=i.getCurrentLastSelection())==null?void 0:u.primary;if(!r){s.next(!1);return}let d=a.FontWeight.NORMAL;if(c!=null){const h=r.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontWeight()}return s.next(d===a.FontWeight.BOLD),l.dispose})),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function fm(n){const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(a.IContextService);return{id:Ft.id,type:I.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:Ee(e,!1,({worksheet:r})=>new k.Observable(s=>{var u;const l=o.onCommandExecuted(h=>{var g,f;const S=h.id;if(S===m.SetRangeValuesMutation.id||S===m.SetSelectionsOperation.id||S===m.SetWorksheetActiveOperation.id){const p=(g=t.getCurrentLastSelection())==null?void 0:g.primary;let v=a.FontItalic.NORMAL;if(p!=null){const C=r.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getFontStyle()}s.next(v===a.FontItalic.ITALIC)}if((S===we.SetTextSelectionsOperation.id||S===Q.SetInlineFormatCommand.id)&&i.getContextValue(a.EDITOR_ACTIVATED)&&i.getContextValue(a.FOCUSING_SHEET)){const p=fi(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=r.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontStyle()}return s.next(d===a.FontItalic.ITALIC),l.dispose})),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function pm(n){const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(a.IContextService);return{id:zt.id,type:I.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",activated$:Ee(e,!1,({worksheet:r})=>new k.Observable(s=>{var u;const l=o.onCommandExecuted(h=>{var g,f;const S=h.id;if(S===m.SetRangeValuesMutation.id||S===m.SetSelectionsOperation.id||S===m.SetWorksheetActiveOperation.id){const p=(g=t.getCurrentLastSelection())==null?void 0:g.primary;let v;if(p!=null){const C=r.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getUnderline()}s.next(!!(v&&v.s))}if((S===we.SetTextSelectionsOperation.id||S===Q.SetInlineFormatCommand.id)&&i.getContextValue(a.EDITOR_ACTIVATED)&&i.getContextValue(a.FOCUSING_SHEET)){const p=fi(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=r.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getUnderline()}return s.next(!!(d&&d.s)),l.dispose})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function vm(n){const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(a.IContextService);return{id:Xt.id,type:I.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:Ee(e,!1,({worksheet:r})=>new k.Observable(s=>{var u;const l=o.onCommandExecuted(h=>{var g,f;const S=h.id;if(S===m.SetRangeValuesMutation.id||S===m.SetSelectionsOperation.id||S===m.SetWorksheetActiveOperation.id){const p=(g=t.getCurrentLastSelection())==null?void 0:g.primary;let v;if(p!=null){const C=r.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getStrikeThrough()}s.next(!!(v&&v.s))}if((S===we.SetTextSelectionsOperation.id||S===Q.SetInlineFormatCommand.id)&&i.getContextValue(a.EDITOR_ACTIVATED)&&i.getContextValue(a.FOCUSING_SHEET)){const p=fi(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=r.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getStrikeThrough()}return s.next(!!(d&&d.s)),l.dispose})),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Cm(n){const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=a.DEFAULT_STYLES.ff;return{id:ai.id,tooltip:"toolbar.font",type:I.MenuItemType.SELECTOR,label:so,selections:I.FONT_FAMILY_LIST.map(r=>({label:{name:ao},value:r.value})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),value$:Ee(e,i,({worksheet:r})=>new k.Observable(s=>{const l=()=>{var h;let d=i;const u=(h=t.getCurrentLastSelection())==null?void 0:h.primary;if(u!=null){const S=r.getCellStyle(u.startRow,u.startColumn),g=r.getDefaultCellStyleInternal(),f=r.getRowStyle(u.startRow),p=r.getColumnStyle(u.startColumn),v=a.composeStyles(g,f,p,S);v.ff&&(d=v.ff)}s.next(d)},c=o.onCommandExecuted(d=>{const u=d.id;(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetActiveOperation.id)&&l()});return l(),c.dispose})),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Im(n){const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(a.IContextService),r=a.DEFAULT_STYLES.fs,s=ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0);return{id:si.id,type:I.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:lo,props:{min:1,max:400,disabled$:s}},selections:I.FONT_SIZE_LIST,disabled$:s,value$:Ee(e,r,({worksheet:l})=>new k.Observable(c=>{const d=()=>{var f;let S=r;const g=(f=t.getCurrentLastSelection())==null?void 0:f.primary;if(g!=null){const p=l.getCellStyle(g.startRow,g.startColumn),v=l.getDefaultCellStyleInternal(),C=l.getRowStyle(g.startRow),_=l.getColumnStyle(g.startColumn),E=a.composeStyles(v,C,_,p);E.fs&&(S=E.fs)}c.next(S)},u=()=>{var g,f;const S=fi(n);if(S!=null){const p=(f=(g=S.ts)==null?void 0:g.fs)!=null?f:r;c.next(p)}},h=o.onCommandExecuted(S=>{const g=S.id;(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id)&&d(),(g===we.SetTextSelectionsOperation.id||g===Q.SetInlineFormatCommand.id)&&i.getContextValue(a.EDITOR_ACTIVATED)&&i.getContextValue(a.FOCUSING_SHEET)&&u()});return d(),h.dispose})),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function _m(n){return{id:Hr.id,type:I.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function bm(n){const o=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:bn.id,icon:"FontColor",tooltip:"toolbar.textColor.main",type:I.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:mi,hoverable:!1,selectable:!1}}],value$:new k.Observable(t=>{const i=e.getCurrentTheme().textColor,r=o.onCommandExecuted(s=>{if(s.id===bn.id){const l=s.params.value;t.next(l!=null?l:i)}});return t.next(i),r.dispose}),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function Em(n){return{id:m.ResetBackgroundColorCommand.id,type:I.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function wm(n){const o=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:m.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",type:I.MenuItemType.BUTTON_SELECTOR,icon:"PaintBucket",selections:[{label:{name:mi,hoverable:!1,selectable:!1}}],value$:new k.Observable(t=>{const i=e.getCurrentTheme().primaryColor,r=o.onCommandExecuted(s=>{if(s.id===m.SetBackgroundColorCommand.id){const l=s.params.value;t.next(l!=null?l:i)}});return t.next(i),r.dispose}),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const gl=[{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 Tm(n){const o=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.HorizontalAlign.LEFT;return{id:m.SetHorizontalTextAlignCommand.id,icon:gl[0].icon,tooltip:"toolbar.horizontalAlignMode.main",type:I.MenuItemType.SELECTOR,selections:gl,value$:Ee(o,t,({worksheet:i})=>new k.Observable(r=>{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 S=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let g;if(S!=null){const p=i.getRange(S.startRow,S.startColumn);g=p==null?void 0:p.getHorizontalAlignment()}r.next(g!=null?g:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=i.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getHorizontalAlignment()}return r.next(c!=null?c:t),s.dispose})),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const fl=[{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 ym(n){const o=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.VerticalAlign.BOTTOM;return{id:m.SetVerticalTextAlignCommand.id,icon:fl[2].icon,tooltip:"toolbar.verticalAlignMode.main",type:I.MenuItemType.SELECTOR,selections:fl,value$:Ee(o,t,({worksheet:i})=>new k.Observable(r=>{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 S=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let g;if(S!=null){const p=i.getRange(S.startRow,S.startColumn);g=p==null?void 0:p.getVerticalAlignment()}r.next(g!=null?g:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=i.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getVerticalAlignment()}return r.next(c!=null?c:t),s.dispose})),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const pl=[{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 Mm(n){const o=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=a.WrapStrategy.OVERFLOW;return{id:m.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:pl[0].icon,type:I.MenuItemType.SELECTOR,selections:pl,value$:Ee(e,t,({worksheet:i})=>new k.Observable(r=>{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 S=(f=o.getCurrentLastSelection())==null?void 0:f.primary;let g;if(S!=null){const p=i.getRange(S.startRow,S.startColumn);g=p==null?void 0:p.getWrapStrategy()}r.next(g!=null?g:t)}),l=(d=o.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=i.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getWrapStrategy()}return r.next(c!=null?c:t),s.dispose})),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const vl=[{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 Rm(n){const o=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=0;return{id:m.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:vl[0].icon,type:I.MenuItemType.SELECTOR,selections:vl,value$:Ee(e,t,({worksheet:i})=>new k.Observable(r=>{var d,u;const s=n.get(a.ICommandService).onCommandExecuted(h=>{var p,v;const S=h.id;if(S!==m.SetTextRotationCommand.id&&S!==m.SetSelectionsOperation.id&&S!==m.SetWorksheetActiveOperation.id)return;const g=(p=o.getCurrentLastSelection())==null?void 0:p.primary;let f;if(g!=null){const C=i.getRange(g.startRow,g.startColumn);f=C==null?void 0:C.getTextRotation()}(f==null?void 0:f.v)===a.BooleanNumber.TRUE?r.next("v"):r.next((v=f&&f.a)!=null?v:t)}),l=(d=o.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const h=i.getRange(l.startRow,l.startColumn);c=h==null?void 0:h.getTextRotation()}return(c==null?void 0:c.v)===a.BooleanNumber.TRUE?r.next("v"):r.next((u=c&&c.a)!=null?u:t),s.dispose})),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Si(n){return new k.Observable(e=>e.next(!n.get(I.IClipboardInterfaceService).supportClipboard))}function Rn(n){return{id:je.name,commandId:je.id,type:I.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",disabled$:ee(n,{workbookTypes:[m.WorkbookCopyPermission],worksheetTypes:[m.WorksheetCopyPermission],rangeTypes:[m.RangeProtectionPermissionViewPoint]}),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Wr(n){return{id:Ge.name,commandId:Ge.id,type:I.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",disabled$:Si(n).pipe(k.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission],workbookTypes:[m.WorkbookEditablePermission]})),k.map(([o,e])=>o||e)),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const gi="sheet.menu.paste-special";function Lr(n){return{id:gi,type:I.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",hidden$:Yt(n,I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET))}}function Ur(n){return{id:Cn.id,type:I.MenuItemType.BUTTON,title:"rightClick.pasteValue",disabled$:Si(n).pipe(k.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellValuePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),k.map(([o,e])=>o||e)),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Br(n){return{id:In.id,type:I.MenuItemType.BUTTON,title:"rightClick.pasteFormat",disabled$:Si(n).pipe(k.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),k.map(([o,e])=>o||e)),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function xr(n){return{id:Bt.id,type:I.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",disabled$:Si(n).pipe(k.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),k.map(([o,e])=>o||e))}}function Fr(n){return{id:_n.id,type:I.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",disabled$:Si(n).pipe(k.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission,m.WorksheetSetRowStylePermission,m.WorksheetSetColumnStylePermission],workbookTypes:[m.WorkbookEditablePermission]})),k.map(([o,e])=>o||e)),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Pm(n){return{id:m.SetWorksheetRowIsAutoHeightCommand.id,type:I.MenuItemType.BUTTON,icon:"AutoHeight",title:"rightClick.fitContent",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Om(n){return{id:hi.id,type:I.MenuItemType.BUTTON,icon:"AutoWidth",title:"rightClick.fitContent",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Cl="sheet.menu.sheet-frozen";function Am(n){return{id:Cl,type:I.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const zr="sheet.header-menu.sheet-frozen";function Il(n){return{id:zr,type:I.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Xr(n){return{id:at.id,type:I.MenuItemType.BUTTON,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function km(n){return{id:di.id,type:I.MenuItemType.BUTTON,title:"rightClick.freezeRow",icon:"FreezeRowSingle",hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Dm(n){return{id:ui.id,type:I.MenuItemType.BUTTON,title:"rightClick.freezeCol",icon:"FreezeColumnSingle",hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Yr(n){return{id:m.CancelFrozenCommand.id,type:I.MenuItemType.BUTTON,title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle",hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Nm(n){return{id:oi.id,type:I.MenuItemType.BUTTON,icon:"Hide",title:"rightClick.hideSelectedRow",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Hm(n){return{id:ri.id,type:I.MenuItemType.BUTTON,icon:"Hide",title:"rightClick.hideSelectedColumn",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Vm(n){const o=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=[m.SetSelectionsOperation,m.SetRowHiddenMutation,m.SetRowVisibleMutation].map(r=>r.id);return{id:m.SetSelectedRowsVisibleCommand.id,type:I.MenuItemType.BUTTON,title:"rightClick.showHideRow",hidden$:Ee(o,!0,({worksheet:r})=>new k.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 S=h.startRow;S<=h.endRow;S++)if(!r.getRowRawVisible(S))return!0;return!1}))}const c=t.onCommandExecuted(d=>{i.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Wm(n){const o=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=[m.SetSelectionsOperation,m.SetColHiddenMutation,m.SetColVisibleMutation].map(r=>r.id);return{id:m.SetSelectedColsVisibleCommand.id,type:I.MenuItemType.BUTTON,title:"rightClick.showHideColumn",hidden$:Ee(o,!0,({worksheet:r})=>new k.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 S=h.startColumn;S<=h.endColumn;S++)if(!r.getColVisible(S))return!0;return!1})}const c=t.onCommandExecuted(d=>{i.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Lm(n){const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=0;return{id:m.SetRowHeightCommand.id,type:I.MenuItemType.BUTTON,icon:"AdjustHeight",label:{name:et,props:{prefix:"rightClick.rowHeight",suffix:"px",min:2,max:1e3}},value$:Ee(e,i,({worksheet:r})=>new k.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary,u=d?r.getRowHeight(d.startRow):i;s.next(u)}const c=o.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$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Um(n){const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=0;return{id:m.SetColWidthCommand.id,type:I.MenuItemType.BUTTON,icon:"AdjustWidth",label:{name:et,props:{prefix:"rightClick.columnWidth",suffix:"px",min:2,max:1e3}},value$:Ee(e,i,({worksheet:r})=>new k.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary;let u=i;d!=null&&(u=r.getColumnWidth(d.startColumn)),s.next(u)}const c=o.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$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function fi(n){var c;const o=n.get(a.IUniverInstanceService),e=n.get(we.DocSelectionManagerService),t=o.getUniverDocInstance(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),i=e.getActiveTextRange();if(t==null||i==null)return null;const r=(c=t.getBody())==null?void 0:c.textRuns;if(r==null)return;const{startOffset:s}=i;return r.find(({st:d,ed:u})=>s>=d&&s<=u)}var Bm=Object.getOwnPropertyDescriptor,xm=(n,o,e,t)=>{for(var i=t>1?void 0:t?Bm(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},jt=(n,o)=>(e,t)=>o(e,t,n);const Fm="__SpreadsheetFreezeRowMainName__",zm="__SpreadsheetFreezeRowHeaderName__",Xm="__SpreadsheetFreezeColumnMainName__",Ym="__SpreadsheetFreezeColumnHeaderName__",jr=2,jm=.01,pi=a.createInterceptorKey("freezePermissionCheck");y.HeaderFreezeRenderController=class extends a.Disposable{constructor(e,t,i,r,s,l,c,d){super();w(this,"_rowFreezeHeaderRect");w(this,"_rowFreezeMainRect");w(this,"_columnFreezeHeaderRect");w(this,"_columnFreezeMainRect");w(this,"_freezeDownSubs");w(this,"_freezePointerEnterSubs");w(this,"_freezePointerLeaveSubs");w(this,"_scenePointerMoveSub");w(this,"_scenePointerUpSub");w(this,"_changeToRow",-1);w(this,"_changeToColumn",-1);w(this,"_changeToOffsetX",0);w(this,"_changeToOffsetY",0);w(this,"_activeViewport",null);w(this,"_freezeNormalHeaderColor","");w(this,"_freezeNormalMainColor","");w(this,"_freezeActiveColor","");w(this,"_freezeHoverColor","");w(this,"_lastFreeze");w(this,"interceptor",new a.InterceptorManager({FREEZE_PERMISSION_CHECK:pi}));this._context=e,this._sheetSkeletonManagerService=t,this._commandService=i,this._selectionManagerService=r,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 A;const i=t!=null?t:this._getFreeze();if(i==null)return null;const r=(A=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:A.skeleton,{startRow:s,startColumn:l}=i,c=this._getPositionByIndex(s,l);if(c==null||r==null)return null;const d=this._getSheetObject(),u=d.engine,h=(u==null?void 0:u.width)||0,S=(u==null?void 0:u.height)||0,g=d.scene,{startX:f,startY:p}=c,{rowTotalHeight:v,columnTotalWidth:C,rowHeaderWidthAndMarginLeft:_,columnHeaderHeightAndMarginTop:E}=r,T=h>C+_?h:C+E,P=S>v+E?S:v+E;this._changeToRow=s,this._changeToColumn=l,this._changeToOffsetX=f,this._changeToOffsetY=p;const R=Math.max(g.scaleX,g.scaleY);let O=jr/Math.max(1,R);if(e===0){(s===-1||s===0)&&(O=O*2);const N=O;this._rowFreezeHeaderRect=new M.Rect(zm,{fill:this._freezeNormalHeaderColor,width:_,height:O,left:0,top:p-N,zIndex:3});let D=this._freezeNormalHeaderColor;(s===-1||s===0)&&(D=this._freezeNormalMainColor),this._rowFreezeMainRect=new M.Rect(Fm,{fill:D,width:T*2/R,height:O,left:_,top:p-N,zIndex:3}),g.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],ft)}else{(l===-1||l===0)&&(O=O*2);const N=O;this._columnFreezeHeaderRect=new M.Rect(Ym,{fill:this._freezeNormalHeaderColor,width:O,height:E,left:f-N,top:0,zIndex:3});let D=this._freezeNormalHeaderColor;(l===-1||l===0)&&(D=this._freezeNormalMainColor),this._columnFreezeMainRect=new M.Rect(Xm,{fill:D,width:O,height:P*2/R,left:f-N,top:E,zIndex:3}),g.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],ft)}this._eventBinding(e)}_eventBinding(e=0){let t=this._rowFreezeHeaderRect,i=this._rowFreezeMainRect;e===1&&(t=this._columnFreezeHeaderRect,i=this._columnFreezeMainRect);const r=this._getSheetObject();if(r==null)return;const{scene:s}=r;if(this._freezePointerEnterSubs=new k.Subscription,this._freezePointerLeaveSubs=new k.Subscription,this._freezeDownSubs=new k.Subscription,i){const d=i.onPointerEnter$.subscribeEvent(()=>{if(!this.interceptor.fetchThroughInterceptors(pi)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(M.CURSOR_TYPE.GRAB)});this._freezePointerEnterSubs.add(d);const u=i.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(pi)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(M.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,i,e)});l&&this._freezeDownSubs.add(l);const c=i==null?void 0:i.onPointerDown$.subscribeEvent(d=>{this._freezeDown(d,t,i,e)});c&&this._freezeDownSubs.add(c)}_getCurrentLastVisible(){var C,_,E,T,P,R,O;const e=this._getSheetObject();if(e==null)return;const t=(C=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:C.skeleton;if(t==null)return;const i=e.scene,r=Math.max(i.scaleX,i.scaleY),s=this._scrollManagerService.getCurrentScrollState(),l=(e.engine.height-t.columnHeaderHeight)/r,c=(e.engine.width-t.rowHeaderWidth)/r,d=(_=s==null?void 0:s.sheetViewStartRow)!=null?_:0,u=d===0?-((E=s==null?void 0:s.offsetY)!=null?E:0):t.rowHeightAccumulation[d-1]-((T=s==null?void 0:s.offsetY)!=null?T:0);let h=0,S=!1;for(let A=d,N=t.rowHeightAccumulation.length;A<N;A++)if(t.rowHeightAccumulation[A]-u>l){h=A,S=!0;break}S||(h=t.rowHeightAccumulation.length-1);const g=(P=s==null?void 0:s.sheetViewStartColumn)!=null?P:0,f=g===0?-((R=s==null?void 0:s.offsetX)!=null?R:0):t.columnWidthAccumulation[g-1]-((O=s==null?void 0:s.offsetX)!=null?O:0);let p=0,v=!1;for(let A=g,N=t.columnWidthAccumulation.length;A<N;A++)if(t.columnWidthAccumulation[A]-f>c){p=A,v=!0;break}return v||(p=t.columnWidthAccumulation.length-1),{lastRow:h,lastColumn:p}}_getActiveViewport(e){var i;const t=(i=this._getSheetObject())==null?void 0:i.scene.getViewports();return t&&t.find(r=>r.isHit(new M.Vector2(e.offsetX,e.offsetY)))||null}_freezeDown(e,t,i,r=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(pi)(!0,null))return!1;const{scene:d}=l;d.setCursor(M.CURSOR_TYPE.GRABBING),d.disableObjectsEvent();const u=this._getCurrentLastVisible(),h=u===void 0?Number.POSITIVE_INFINITY:s.rowHeightAccumulation[u.lastRow],S=u===void 0?Number.POSITIVE_INFINITY:s.columnWidthAccumulation[u.lastColumn-1]+s.rowHeaderWidth;this._activeViewport=null;const g=this._getFreeze();g&&(this._changeToColumn=g.startColumn,this._changeToRow=g.startRow),this._scenePointerMoveSub=d.onPointerMove$.subscribeEvent(p=>{var O,A,N,D;const v=this._getActiveViewport(p),{startX:C,startY:_,row:E,column:T}=qe(p.offsetX,p.offsetY,d,s,v||void 0,!0);if(!this.interceptor.fetchThroughInterceptors(pi)(!0,null))return!1;d.setCursor(M.CURSOR_TYPE.GRABBING);const R=jr/Math.max(d.scaleX,d.scaleY);r===0?((O=t.transformByState({top:Math.min(_,h)-R/2}))==null||O.setProps({fill:this._freezeActiveColor}),(A=i.transformByState({top:Math.min(_,h)-R/2}))==null||A.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=u===void 0?E:Math.min(E,u.lastRow),this._changeToOffsetY=Math.min(_,h),this._activeViewport=v):((N=t.transformByState({left:Math.min(C,S)-R/2}))==null||N.setProps({fill:this._freezeActiveColor}),(D=i.transformByState({left:Math.min(C,S)-R/2}))==null||D.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=u===void 0?T:Math.min(T,u.lastColumn),this._changeToOffsetX=C,this._activeViewport=v)}),this._scenePointerUpSub=d.onPointerUp$.subscribeEvent(()=>{var H,W;d.resetCursor(),d.enableObjectsEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:p,columnHeaderHeightAndMarginTop:v}=s;r===0&&(this._changeToRow===0||this._changeToRow===-1)||r===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(t.setProps({fill:this._freezeNormalHeaderColor}),i.setProps({fill:this._freezeNormalMainColor})):(t==null||t.setProps({fill:this._freezeNormalHeaderColor}),i==null||i.setProps({fill:this._freezeNormalHeaderColor}));const C=jr/Math.max(d.scaleX,d.scaleY);r===0?(this._changeToRow===0||this._changeToRow===-1)&&(t.transformByState({top:v-C}),i.transformByState({top:v-C})):(this._changeToColumn===0||this._changeToColumn===-1)&&(t.transformByState({left:p-C}),i.transformByState({left:p-C}));const _=this._scrollManagerService.getCurrentScrollState()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:E,sheetViewStartColumn:T}=_;if(T==null||E==null)return;const P=this._context.unit,R=P.getActiveSheet();if(!R)return;const O=(H=R.getConfig())==null?void 0:H.freeze;let A=(O==null?void 0:O.xSplit)||0,N=(O==null?void 0:O.ySplit)||0;const D=(W=this._activeViewport)==null?void 0:W.viewportKey;r===0&&(!D||D===M.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||D===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||D===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP||D===M.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP?N=this._changeToRow-(O.startRow-O.ySplit):N=this._changeToRow-E,N=N<0?0:N),r===1&&(!D||D===M.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||D===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||D===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT||D===M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT?A=this._changeToColumn-(O.startColumn-O.xSplit):A=this._changeToColumn-T,A=A<0?0:A),this._commandService.executeCommand(m.SetFrozenCommand.id,{startRow:N===0?-1:this._changeToRow,startColumn:A===0?-1:this._changeToColumn,ySplit:N,xSplit:A,unitId:P.getUnitId(),subUnitId:R.getSheetId()})})}_getViewports(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e,i=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT),r=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT),s=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP),l=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM),c=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP),d=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN),u=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP),h=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT),S=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(!(i==null||r==null||s==null||l==null||c==null||d==null||u==null||h==null||S==null))return{viewMain:d,viewMainLeftTop:u,viewMainLeft:h,viewMainTop:S,viewColumnLeft:i,viewColumnRight:r,viewRowTop:s,viewRowBottom:l,viewLeftTop:c}}_bindViewportScroll(){const e=this._getViewports();if(!e)return;const{viewRowBottom:t,viewColumnRight:i,viewMainLeft:r,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}),i.isActive&&i.updateScrollVal({scrollX:c,viewportScrollX:u}),r.isActive&&r.updateScrollVal({scrollY:d,viewportScrollY:h}),s.isActive&&s.updateScrollVal({scrollX:c,viewportScrollX:u})}))}_updateViewport(e=-1,t=-1,i=0,r=0,s=3){var A;const l=(A=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:A.skeleton;if(l==null)return;const{rowHeaderWidthAndMarginLeft:c,columnHeaderHeightAndMarginTop:d}=l,u=this._getViewports();if(!u)return;const{viewMain:h,viewMainLeftTop:S,viewMainLeft:g,viewMainTop:f,viewColumnLeft:p,viewColumnRight:v,viewRowTop:C,viewRowBottom:_,viewLeftTop:E}=u;v.resizeWhenFreezeChange({left:c,top:0,height:d+1,right:0}),_.resizeWhenFreezeChange({left:0,top:d,bottom:0,width:c+1}),E.resizeWhenFreezeChange({left:0,top:0,width:c+1,height:d});let T=!0,P=!0;S.enable(),(e===-1||e===0)&&(T=!1),(t===-1||t===0)&&(P=!1);const R=l.getNoMergeCellWithCoordByIndex(e-i,t-r,!1),O=l.getNoMergeCellWithCoordByIndex(e,t,!1);if(S.disable(),f.disable(),g.disable(),C.disable(),p.disable(),S.resetPadding(),f.resetPadding(),g.resetPadding(),C.resetPadding(),p.resetPadding(),T===!1&&P===!1)h.resizeWhenFreezeChange({left:c,top:d,bottom:0,right:0}),h.resetPadding(),g.resizeWhenFreezeChange({left:c,top:d,bottom:0,width:0}),f.resizeWhenFreezeChange({left:c,top:d,height:0,right:0}),S.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(T===!0&&P===!1){const N=O.startY-R.startY;h.resizeWhenFreezeChange({left:c,top:d+N,bottom:0,right:0}),h.setPadding({startY:R.startY,endY:O.startY,startX:0,endX:0}),s&2&&this._commandService.executeCommand(Ye.id,{sheetViewStartRow:0,offsetY:0}),f.resizeWhenFreezeChange({left:c,top:d,height:N,right:0}),f.updateScrollVal({viewportScrollY:R.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:N}),C.updateScrollVal({viewportScrollY:R.startY}),_.resizeWhenFreezeChange({left:0,top:d+N,bottom:0,width:c+1}),f.enable(),C.enable()}else if(T===!1&&P===!0){const N=O.startX-R.startX;h.resizeWhenFreezeChange({left:c+N,top:d,bottom:0,right:0}),h.setPadding({startX:R.startX,endX:O.startX,startY:0,endY:0}),s&1&&this._commandService.executeCommand(Ye.id,{sheetViewStartColumn:0,offsetX:0}),g.resizeWhenFreezeChange({left:c,top:d,width:N,bottom:0,right:0}),g.updateScrollVal({viewportScrollX:R.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),p.resizeWhenFreezeChange({left:c,top:0,width:N,height:d+1}),p.updateScrollVal({viewportScrollX:R.startX}),v.resizeWhenFreezeChange({left:c+N,top:0,height:d+1,right:0}),g.enable(),p.enable()}else{const N=O.startX-R.startX,D=O.startY-R.startY;h.resizeWhenFreezeChange({left:c+N,top:d+D,bottom:0,right:0}),h.setPadding({startY:R.startY,endY:O.startY,startX:R.startX,endX:O.startX}),s&&this._commandService.executeCommand(Ye.id,{...s&1?{sheetViewStartColumn:0,offsetX:0}:null,...s&2?{sheetViewStartRow:0,offsetY:0}:null}),g.resizeWhenFreezeChange({left:c,top:d+D,width:N,bottom:0}),g.updateScrollVal({viewportScrollX:R.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),f.resizeWhenFreezeChange({left:c+N,top:d,height:D,right:0}),f.updateScrollVal({viewportScrollY:R.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),S.resizeWhenFreezeChange({left:c,top:d,width:N,height:D}),S.updateScrollVal({viewportScrollX:R.startX,viewportScrollY:R.startY}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:D}),C.updateScrollVal({viewportScrollY:R.startY}),_.resizeWhenFreezeChange({left:0,top:d+D,bottom:0,width:c+1}),p.resizeWhenFreezeChange({left:c,top:0,width:N,height:d+1}),p.updateScrollVal({viewportScrollX:R.startX}),v.resizeWhenFreezeChange({left:c+N,top:0,height:d+1,right:0}),S.enable(),f.enable(),g.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 i=t.getConfig().freeze,{startRow:r=-1,startColumn:s=-1,ySplit:l=0,xSplit:c=0}=i;this._refreshFreeze(r,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(jm).toRgbString(),this._freezeActiveColor=e.primaryColor,this._freezeHoverColor=e.grey500}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{const t={redos:[],undos:[]},i=this._getFreeze();if(!i)return t;const r=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},S=m.SetFrozenMutationFactory(this._injector,h);return{undos:[{id:m.SetFrozenMutation.id,params:S}],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<i.startRow||l.startRow+1===i.startRow&&c===a.Direction.UP){const u={...i,startRow:Math.max(1,i.startRow+d),ySplit:Math.max(1,i.ySplit+d)};return r(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<i.startColumn||l.startColumn+1===i.startColumn&&c===a.Direction.LEFT){const u={...i,startColumn:Math.max(1,i.startColumn+d),xSplit:Math.max(1,i.xSplit+d)};return r(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(!i||i.startColumn<=0||u.startColumn>=i.startColumn&&h.startColumn>=i.startColumn||u.startColumn===h.startColumn||u.endColumn<i.startColumn&&h.startColumn<i.startColumn)return t;const S=u.endColumn-u.startColumn+1,g=Math.max(Math.min(i.startColumn,u.endColumn+1)-u.startColumn,0);let f,p;h.startColumn>=i.startColumn?(f=Math.max(i.startColumn-g,1),p=Math.max(i.xSplit-g,1)):(f=i.startColumn+S-g,p=i.xSplit+S-g);const v={...i,startColumn:f,xSplit:p};return r(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(!i||i.startRow<=0||u.startRow>=i.startRow&&h.startRow>=i.startRow||u.startRow===h.startRow||u.endRow<i.startRow&&h.startRow<i.startRow)return t;const S=u.endRow-u.startRow+1,g=Math.max(Math.min(i.startRow,u.endRow+1)-u.startRow,0);let f,p;h.startRow>=i.startRow?(f=Math.max(i.startRow-g,1),p=Math.max(i.ySplit-g,1)):(f=i.startRow+S-g,p=i.ySplit+S-g);const v={...i,startRow:f,ySplit:p};return r(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<i.startColumn){const c=Math.min(i.startColumn,l.endColumn+1)-l.startColumn,d={...i,startColumn:Math.max(1,i.startColumn-c),xSplit:Math.max(1,i.xSplit-c)};return r(d)}if(s.range.rangeType===a.RANGE_TYPE.ROW&&l.startRow<i.startRow){const c=Math.min(i.startRow,l.endRow+1)-l.startRow,d={...i,startRow:Math.max(1,i.startRow-c),ySplit:Math.max(1,i.ySplit-c)};return r(d)}}return t}}))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{switch(e.id){case m.SetFrozenMutation.id:case Le.id:{const t=this._lastFreeze,i=this._context.unit,r=i.getActiveSheet(),s=e.params,{unitId:l,subUnitId:c}=s;if(!(l===i.getUnitId()&&c===(r==null?void 0:r.getSheetId())))return;const d=r.getConfig().freeze;if(this._lastFreeze=d,d==null)return;let u=0;const{startRow:h=-1,startColumn:S=-1,ySplit:g=0,xSplit:f=0}=d;(!t||t.startRow!==h||t.ySplit!==g)&&(u|=2),(!t||t.startColumn!==S||t.xSplit!==f)&&(u|=1),s.resetScroll===!1&&(u=0),this._refreshFreeze(h,S,g,f,u)}break;case m.SetWorksheetRowHeightMutation.id:{const t=this._getFreeze(),i=t&&e.params.ranges.some(r=>r.startRow<t.startRow);e.params&&i&&this._refreshCurrent()}break;case m.SetWorksheetColWidthMutation.id:{const t=this._getFreeze();e.params&&t&&e.params.ranges.some(i=>i.startColumn<t.startColumn)&&this._refreshCurrent()}break;case m.SetWorksheetRowAutoHeightMutation.id:{const t=e.params,i=this._getFreeze();if(i&&i.startRow>-1&&t.rowsAutoHeightInfo.some(r=>r.row<i.startRow)){const r=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{r.unsubscribe()})})}}break;case m.SetColHiddenMutation.id:case m.SetColVisibleMutation.id:{const t=e.params,i=this._getFreeze(),r=t.ranges;i&&i.startColumn>-1&&r.some(s=>s.startColumn<i.startColumn)&&this._refreshCurrent()}break;case m.SetRowHiddenMutation.id:case m.SetRowVisibleMutation.id:{const t=e.params,i=this._getFreeze(),r=t.ranges;i&&i.startRow>-1&&r.some(s=>s.startRow<i.startRow)&&this._refreshCurrent()}break;case xi.id:case Fi.id:this._refreshCurrent()}}))}_zoomRefresh(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this.disposeWithMe(t.onTransformChange$.subscribeEvent(i=>{[M.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale,M.TRANSFORM_CHANGE_OBSERVABLE_TYPE.all].includes(i.type)&&this._refreshCurrent()}))}_clearObserverEvent(){var t,i;this._getSheetObject()!=null&&((t=this._scenePointerMoveSub)==null||t.unsubscribe(),(i=this._scenePointerUpSub)==null||i.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null)}_clearFreeze(){var t,i,r,s,l,c;(t=this._rowFreezeHeaderRect)==null||t.dispose(),(i=this._rowFreezeMainRect)==null||i.dispose(),(r=this._columnFreezeHeaderRect)==null||r.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 r=(d=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:d.skeleton,s=r==null?void 0:r.getNoMergeCellWithCoordByIndex(e,t);if(r==null)return;if(s!=null&&(!isNaN(s.endX)||!isNaN(s.endY)))return s;const{rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:c}=r;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 ze(this._context.unit,this._context)}_refreshFreeze(e,t,i,r,s){var c;const l={startRow:e,startColumn:t,ySplit:i,xSplit:r};this._clearFreeze(),this._createFreeze(0,l),this._createFreeze(1,l),this._updateViewport(e,t,i,r,s),(c=this._getSheetObject())==null||c.spreadsheet.makeForceDirty()}},y.HeaderFreezeRenderController=xm([jt(1,a.Inject(y.SheetSkeletonManagerService)),jt(2,a.ICommandService),jt(3,a.Inject(m.SheetsSelectionsService)),jt(4,a.Inject(y.SheetScrollManagerService)),jt(5,a.Inject(a.ThemeService)),jt(6,a.Inject(m.SheetInterceptorService)),jt(7,a.Inject(a.Injector))],y.HeaderFreezeRenderController);function Gm(n){const o=n.get(m.SheetsSelectionsService),e=n.get(m.RangeProtectionRuleModel),t=n.get(a.IUniverInstanceService),i=n.get(m.MergeCellController),r=t.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET);return k.combineLatest([o.selectionMoveEnd$,r.pipe(k.map(s=>{var l;return(l=s==null?void 0:s.getUnitId())!=null?l:""})),r.pipe(k.switchMap(s=>{var l;return(l=s==null?void 0:s.activeSheet$)!=null?l:k.of(null)}))]).pipe(k.map(([s,l,c])=>{if(!c||!s||s.length===0)return!1;const d=c.getSheetId(),u=s.map(g=>g.range);if(i.interceptor.fetchThroughInterceptors(m.MERGE_CELL_INTERCEPTOR_CHECK)(!1,u))return!0;const S=e.getSubunitRuleList(l,d).map(g=>g.ranges).flat();if(s.length<2){const g=s[0].range;return S.some(p=>a.Rectangle.intersects(p,g)&&!a.Rectangle.contains(p,g))}for(let g=0;g<s.length;g++)for(let f=g+1;f<s.length;f++)if(a.Rectangle.intersects(s[g].range,s[f].range))return!0;return!1}))}function _l(n,o){return!!vi(n,o,a.RANGE_TYPE.ROW)}function bl(n,o){return!!vi(n,o,a.RANGE_TYPE.COLUMN)}function vi(n,o,e){return n.find(i=>{const r=i.range,{startRow:s,endRow:l,startColumn:c,endColumn:d,rangeType:u}=r;return u===a.RANGE_TYPE.ALL||u===a.RANGE_TYPE.NORMAL?!1:u===e&&(e===a.RANGE_TYPE.COLUMN&&c<=o&&o<=d||e===a.RANGE_TYPE.ROW&&s<=o&&o<=l)})}var Zm=Object.getOwnPropertyDescriptor,Km=(n,o,e,t)=>{for(var i=t>1?void 0:t?Zm(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},Gr=(n,o)=>(e,t)=>o(e,t,n);const qm="__SpreadsheetHeaderMoveControllerBackground__",Qm="__SpreadsheetHeaderMoveControllerShapeLine__",Jm="rgba(0, 0, 0, 0.1)",$m="rgb(119, 119, 119)",eS=4,Zr=a.createInterceptorKey("headerMovePermissionCheck");y.HeaderMoveRenderController=class extends a.Disposable{constructor(e,t,i,r){super();w(this,"_startOffsetX",Number.NEGATIVE_INFINITY);w(this,"_startOffsetY",Number.NEGATIVE_INFINITY);w(this,"_moveHelperBackgroundShape");w(this,"_moveHelperLineShape");w(this,"_headerPointerDownSubs");w(this,"_headerPointerMoveSubs");w(this,"_headerPointerLeaveSubs");w(this,"_dragHeaderMoveSub");w(this,"_scenePointerUpSub");w(this,"_scrollTimer");w(this,"_changeFromColumn",-1);w(this,"_changeFromRow",-1);w(this,"_changeToColumn",-1);w(this,"_changeToRow",-1);w(this,"interceptor",new a.InterceptorManager({HEADER_MOVE_PERMISSION_CHECK:Zr}));w(this,"_workbookSelections");this._context=e,this._sheetSkeletonManagerService=i,this._commandService=r,this._workbookSelections=t.getWorkbookSelections(this._context.unitId),this._init()}dispose(){var e,t,i,r,s,l,c,d;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose(),(i=this._headerPointerMoveSubs)==null||i.unsubscribe(),(r=this._headerPointerLeaveSubs)==null||r.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),i=this._context.components.get(he.ROW),r=this._context.scene,s=e===a.RANGE_TYPE.ROW?i:t,l=u=>{var _,E;const h=(_=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:_.skeleton;if(h==null)return;const S=(E=this._workbookSelections.getCurrentLastSelection())==null?void 0:E.range;if(!S||!this.interceptor.fetchThroughInterceptors(Zr)(!1,S))return;const f=this._workbookSelections.getCurrentSelections(),{row:p,column:v}=qe(u.offsetX,u.offsetY,r,h);if(!vi(f,e===a.RANGE_TYPE.ROW?p:v,e)){r.resetCursor();return}r.setCursor(M.CURSOR_TYPE.GRAB)},c=()=>{var u,h;(u=this._moveHelperBackgroundShape)==null||u.hide(),(h=this._moveHelperLineShape)==null||h.hide(),r.resetCursor()},d=(u,h)=>{var U,V;if(h.isStopPropagation)return;const S=(U=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:U.skeleton;if(S==null)return;const g=(V=this._workbookSelections.getCurrentLastSelection())==null?void 0:V.range;if(!g||!this.interceptor.fetchThroughInterceptors(Zr)(!1,g))return;const{offsetX:p,offsetY:v}=u,C=r.getCoordRelativeToViewport(M.Vector2.FromArray([p,v])),{x:_,y:E}=C;this._startOffsetX=_,this._startOffsetY=E;const{row:T,column:P}=qe(u.offsetX,u.offsetY,r,S);let R;e===a.RANGE_TYPE.ROW?(this._changeFromRow=T,R=M.ScrollTimerType.Y):(this._changeFromColumn=P,R=M.ScrollTimerType.X);const O=this._workbookSelections.getCurrentSelections(),A=vi(O,e===a.RANGE_TYPE.ROW?T:P,e);if(!A)return;const N=r.getScrollXYInfoByViewport(M.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),r.setCursor(M.CURSOR_TYPE.GRABBING),r.disableObjectsEvent();let D=!1,H;const W=()=>{if(D)return;H=M.ScrollTimer.create(r,R),this._scrollTimer=H;const B=r.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN);H.startScroll(_,E,B),D=!0};this._dragHeaderMoveSub=r.onPointerMove$.subscribeEvent(B=>{W();const{offsetX:x,offsetY:z}=B,{x:F,y:Y}=r.getCoordRelativeToViewport(M.Vector2.FromArray([x,z]));this._rowColumnMoving(F,Y,A,N,e),H.scrolling(F,Y,()=>{this._rowColumnMoving(F,Y,A,N,e)})}),this._scenePointerUpSub=r.onPointerUp$.subscribeEvent(()=>{var x,z,F;this._disposeBackgroundAndLine(),r.resetCursor(),r.enableObjectsEvent(),this._clearObserverEvent(),(x=this._scrollTimer)==null||x.dispose();const B=this._workbookSelections.getCurrentSelections();if(e===a.RANGE_TYPE.ROW){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const X=(z=((B==null?void 0:B.filter(Z=>Z.range.rangeType===a.RANGE_TYPE.ROW&&Z.range.startRow<=this._changeFromRow&&this._changeFromRow<=Z.range.endRow))||[])[0])==null?void 0:z.range;X&&this._commandService.executeCommand(m.MoveRowsCommand.id,{fromRange:X,toRange:{...X,startRow:this._changeToRow,endRow:this._changeToRow+X.endRow-X.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const X=(F=((B==null?void 0:B.filter(Z=>Z.range.rangeType===a.RANGE_TYPE.COLUMN&&Z.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=Z.range.endColumn))||[])[0])==null?void 0:F.range;X&&this._commandService.executeCommand(m.MoveColsCommand.id,{fromRange:X,toRange:{...X,startColumn:this._changeToColumn,endColumn:this._changeToColumn+X.endColumn-X.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})};this._headerPointerMoveSubs=new k.Subscription,this._headerPointerMoveSubs.add(s.onPointerMove$.subscribeEvent(l)),this._headerPointerLeaveSubs=new k.Subscription,this._headerPointerLeaveSubs.add(s==null?void 0:s.onPointerLeave$.subscribeEvent(c)),this._headerPointerDownSubs=new k.Subscription,this._headerPointerDownSubs.add(s==null?void 0:s.onPointerDown$.subscribeEvent(d))}_rowColumnMoving(e,t,i,r,s){var Y,X,Z,ne,J,ae,ue;const l=this._context.scene,c=(Y=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:Y.skeleton;if(c==null)return;const{rowHeaderWidth:d,columnHeaderHeight:u,rowTotalHeight:h,columnTotalWidth:S}=c,g=l.getViewportScrollXY(l.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN)),{scaleX:f,scaleY:p}=l.getAncestorScale(),v=c.getCellIndexByOffset(e,t,f,p,g),{row:C,column:_}=v,E=c.getNoMergeCellWithCoordByIndex(C,_),{startX:T,startY:P,endX:R,endY:O}=E,A=this._sheetSkeletonManagerService.attachRangeWithCoord(i.range);if(A==null)return;const N=Math.max(f,f),{startX:D,endX:H,startY:W,endY:U,startRow:V,startColumn:B,endRow:x,endColumn:z}=A;s===a.RANGE_TYPE.ROW?(X=this._moveHelperBackgroundShape)==null||X.transformByState({height:U-W,width:S+d,left:0,top:W+(t-this._startOffsetY)/N+g.y-r.y}):(Z=this._moveHelperBackgroundShape)==null||Z.transformByState({height:h+u,width:H-D,left:D+(e-this._startOffsetX)/N+g.x-r.x,top:0}),(ne=this._moveHelperBackgroundShape)==null||ne.show();const F=eS/N;if(s===a.RANGE_TYPE.ROW){let j=0;if(C<=V)j=P-F/2,this._changeToRow=C;else if(C>x)j=O-F/2,this._changeToRow=C+1;else return;(J=this._moveHelperLineShape)==null||J.transformByState({height:F,width:S,left:d,top:j})}else{let j=0;if(_<=B)j=T-F/2,this._changeToColumn=_;else if(_>z)j=R-F/2,this._changeToColumn=_+1;else return;(ae=this._moveHelperLineShape)==null||ae.transformByState({height:h,width:F,left:j,top:u})}(ue=this._moveHelperLineShape)==null||ue.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 M.Rect(qm,{fill:Jm,evented:!1,zIndex:100}),this._moveHelperLineShape=new M.Rect(Qm,{fill:$m,evented:!1,zIndex:100}),e.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],ft)}_disposeBackgroundAndLine(){var e,t;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose()}},y.HeaderMoveRenderController=Km([Gr(1,a.Inject(m.SheetsSelectionsService)),Gr(2,a.Inject(y.SheetSkeletonManagerService)),Gr(3,a.ICommandService)],y.HeaderMoveRenderController);var Kr=(n=>(n[n.VERTICAL=0]="VERTICAL",n[n.HORIZONTAL=1]="HORIZONTAL",n))(Kr||{});const tS="rgba(120, 120, 120, 0.01)",qr="rgb(68, 71, 70)",Ci=12,nS=44,Qr=4;class El extends M.Shape{constructor(e,t){super(e,t);w(this,"_size",Ci);w(this,"_color",qr);w(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:i,scaleY:r}=t.getAncestorScale(),s=Math.max(i,r),l=Ci/s,c=Qr/s;let{width:d,height:u}=this,h=0,S=0;this.mode===0?(d=c,h=l-c):(u=c,S=l-c),M.Rect.drawWith(e,{width:this.width,height:this.height,left:0,top:0,fill:tS}),M.Rect.drawWith(e,{width:d,height:u,fill:qr,radius:c}),e.save(),e.transform(1,0,0,1,h,S),M.Rect.drawWith(e,{width:d,height:u,fill:qr,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:Ci,height:this.size}):this.transformByState({width:this.size,height:Ci}),this}}var iS=Object.getOwnPropertyDescriptor,oS=(n,o,e,t)=>{for(var i=t>1?void 0:t?iS(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},Jr=(n,o)=>(e,t)=>o(e,t,n);const rS="__SpreadsheetHeaderResizeControllerShapeRow__",sS="__SpreadsheetHeaderResizeControllerShapeColumn__",wl="__SpreadsheetHeaderResizeControllerShapeHelper__",Tl="rgb(199, 199, 199)",aS=2,$r=a.createInterceptorKey("headerResizePermissionCheck");y.HeaderResizeRenderController=class extends a.Disposable{constructor(e,t,i,r){super();w(this,"_currentRow",0);w(this,"_currentColumn",0);w(this,"_rowResizeRect");w(this,"_columnResizeRect");w(this,"_headerPointerSubs");w(this,"_scenePointerMoveSub");w(this,"_scenePointerUpSub");w(this,"_resizeHelperShape");w(this,"_startOffsetX",Number.POSITIVE_INFINITY);w(this,"_startOffsetY",Number.POSITIVE_INFINITY);w(this,"interceptor",new a.InterceptorManager({HEADER_RESIZE_PERMISSION_CHECK:$r}));this._context=e,this._sheetSkeletonManagerService=t,this._selectionManagerService=i,this._commandService=r,this._init()}dispose(){var e,t,i;(e=this._rowResizeRect)==null||e.dispose(),this._rowResizeRect=null,(t=this._columnResizeRect)==null||t.dispose(),this._columnResizeRect=null,(i=this._headerPointerSubs)==null||i.unsubscribe(),this._headerPointerSubs=null}_init(){const e=this._context.scene;this._rowResizeRect=new El(rS,{visible:!1,mode:Kr.HORIZONTAL,zIndex:100}),this._columnResizeRect=new El(sS,{visible:!1,mode:Kr.VERTICAL,zIndex:100}),e.addObjects([this._rowResizeRect,this._columnResizeRect],ft),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(e=0){const t=this._context.components.get(he.COLUMN),i=this._context.components.get(he.ROW),r=this._context.scene,s=e===0?i:t,l=(d,u)=>{var h,S;(h=this._rowResizeRect)==null||h.hide(),(S=this._columnResizeRect)==null||S.hide()},c=(d,u)=>{var N;const h=(N=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:N.skeleton;if(h==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:S,columnHeaderHeight:g}=h,{startX:f,startY:p,endX:v,endY:C,row:_,column:E}=qe(d.offsetX,d.offsetY,r,h),T=Gn(d.offsetX,d.offsetY,r),{scaleX:P,scaleY:R}=r.getAncestorScale(),O=Math.max(P,R),A=Ci/O;if(e===0){let D=p-A/2;if(T.y<=p+A/2&&T.y>=p)this._currentRow=_-1;else if(T.y>=C-A/2&&T.y<=C)this._currentRow=_,D=C-A/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;if(!this.interceptor.fetchThroughInterceptors($r)(null,{row:this._currentRow}))return!1;const W=Math.min(nS,S/3);this._rowResizeRect.transformByState({left:S/2-W/2,top:D}),this._rowResizeRect.setShapeProps({size:W}),this._rowResizeRect.show()}else{let D=f-A/2;if(T.x<=f+A/2&&T.x>=f)this._currentColumn=E-1;else if(T.x>=v-A/2&&T.x<=v)this._currentColumn=E,D=v-A/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;if(!this.interceptor.fetchThroughInterceptors($r)(null,{col:this._currentColumn}))return!1;const W=g*.7;this._columnResizeRect.transformByState({left:D,top:g/2-W/2}),this._columnResizeRect.setShapeProps({size:W}),this._columnResizeRect.show()}};this._headerPointerSubs=new k.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,i=e===0?this._rowResizeRect:this._columnResizeRect;i!=null&&(this.disposeWithMe(i.onPointerEnter$.subscribeEvent(()=>{i!=null&&(i.show(),t.setCursor(e===0?M.CURSOR_TYPE.ROW_RESIZE:M.CURSOR_TYPE.COLUMN_RESIZE))})),this.disposeWithMe(i.onPointerLeave$.subscribeEvent(()=>{i!=null&&(i.hide(),t.resetCursor())})),this.disposeWithMe(i.onPointerDown$.subscribeEvent(r=>{var z,F,Y,X,Z,ne,J;const s=(z=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:z.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(M.SHEET_VIEWPORT_KEY.VIEW_MAIN),S=(((Y=(F=h==null?void 0:h.getScrollBar())==null?void 0:F.horizonScrollTrack)==null?void 0:Y.height)||0)+10,g=(((Z=(X=h==null?void 0:h.getScrollBar())==null?void 0:X.verticalScrollTrack)==null?void 0:Z.width)||0)+10,f=Gn(r.offsetX,r.offsetY,l),{scaleX:p,scaleY:v}=l.getAncestorScale();this._startOffsetX=f.x,this._startOffsetY=f.y;const C=s.getOffsetByColumn(this._currentColumn),_=s.getOffsetByRow(this._currentRow),E=s.getNoMergeCellWithCoordByIndex(this._currentRow,this._currentColumn);let T=!1,P=0,R=0;const{columnTotalWidth:O,rowHeaderWidth:A,rowTotalHeight:N,columnHeaderHeight:D}=s,H=u>O+A?u:O+A,W=d>N+D?d:N+D,U=Math.max(p,v),V=Qr/U;e===0?this._resizeHelperShape=new M.Rect(wl,{width:H,height:V,fill:Tl,left:0,top:_-V/2}):this._resizeHelperShape=new M.Rect(wl,{width:V,height:W,fill:Tl,left:C-V/2,top:0});const B=((ne=this._columnResizeRect)==null?void 0:ne.left)||0,x=((J=this._rowResizeRect)==null?void 0:J.top)||0;l.addObject(this._resizeHelperShape,ft),l.disableObjectsEvent(),this._scenePointerMoveSub=l.onPointerMove$.subscribeEvent(ae=>{var pe,Me,ye,Ze,Rt,Pt;const ue=l.getCoordRelativeToViewport(M.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),j=l.getScrollXYInfoByViewport(ue,h),K=Gn(ae.offsetX,ae.offsetY,l),{x:$,y:oe}=K,{scaleX:re,scaleY:le}=l.getAncestorScale(),se=Math.max(re,le),ie=Qr/se;P=$-this._startOffsetX-ie/2,R=oe-this._startOffsetY-ie/2,Math.abs(e===0?R:P)>=aS&&(T=!0),e===0?(R>d-S+j.y-E.startY&&(R=d-S+j.y-E.startY),R<-(E.endY-E.startY)+2&&(R=-(E.endY-E.startY)+2),T&&((pe=this._resizeHelperShape)==null||pe.transformByState({top:_+R}),(Me=this._rowResizeRect)==null||Me.transformByState({top:x+R+ie/2}),(ye=this._rowResizeRect)==null||ye.show(),l.setCursor(M.CURSOR_TYPE.ROW_RESIZE))):(P>u-g+j.x-E.startX&&(P=u-g+j.x-E.startX),P<-(E.endX-E.startX)+2&&(P=-(E.endX-E.startX)+2),T&&((Ze=this._resizeHelperShape)==null||Ze.transformByState({left:C+P}),(Rt=this._columnResizeRect)==null||Rt.transformByState({left:B+P+ie/2}),(Pt=this._columnResizeRect)==null||Pt.show(),l.setCursor(M.CURSOR_TYPE.COLUMN_RESIZE)))}),this._scenePointerUpSub=l.onPointerUp$.subscribeEvent(ae=>{var j,K,$;const ue=this._context.scene;this._clearObserverEvent(),(j=this._resizeHelperShape)==null||j.dispose(),this._resizeHelperShape=null,ue.enableObjectsEvent(),T&&(ue.resetCursor(),(K=this._rowResizeRect)==null||K.hide(),($=this._columnResizeRect)==null||$.hide(),e===0?this._commandService.executeCommand(m.DeltaRowHeightCommand.id,{deltaY:R,anchorRow:this._currentRow}):this._commandService.executeCommand(m.DeltaColumnWidthCommand.id,{deltaX:P,anchorCol:this._currentColumn}))})})),this.disposeWithMe(i.onDblclick$.subscribeEvent(()=>{var h,S,g;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(hi.id,{ranges:p}),(S=this._columnResizeRect)==null||S.hide();break}case 0:this._commandService.executeCommand(m.SetWorksheetRowIsAutoHeightCommand.id,{ranges:[{startRow:this._currentRow,endRow:this._currentRow,startColumn:c,endColumn:u}]}),(g=this._rowResizeRect)==null||g.hide();break}})))}_clearObserverEvent(){var e,t;(e=this._scenePointerMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null}},y.HeaderResizeRenderController=oS([Jr(1,a.Inject(y.SheetSkeletonManagerService)),Jr(2,a.Inject(m.SheetsSelectionsService)),Jr(3,a.ICommandService)],y.HeaderResizeRenderController);var lS=Object.getOwnPropertyDescriptor,cS=(n,o,e,t)=>{for(var i=t>1?void 0:t?lS(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},Ii=(n,o)=>(e,t)=>o(e,t,n);const dS=60;y.SheetRenderController=class extends a.RxDisposable{constructor(e,t,i,r,s,l){super();w(this,"_renderMetric$",new k.Subject);w(this,"renderMetric$",this._renderMetric$.asObservable());w(this,"_renderFrameTimeMetric",null);w(this,"_renderFrameTags",{});w(this,"_afterRenderMetric$",new k.Subject);this._context=e,this._configService=t,this._sheetSkeletonManagerService=i,this._sheetRenderService=r,this._commandService=s,this._telemetryService=l,this._addNewRender(),this._initRenderMetricSubscriber()}_addNewRender(){const{scene:e,engine:t,unit:i}=this._context;this._addComponent(i),this._initRerenderScheduler(),this._initCommandListener();const r=this._context.unit.getActiveSheet();if(!r)throw new Error("No active sheet found");const s=r.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(r=>r.startsWith(M.SHEET_EXTENSION_PREFIX)).length>0&&this._afterRenderMetric$.next({frameTimeMetric:this._renderFrameTimeMetric,tags:this._renderFrameTags})}),e.renderFrameTimeMetric$.subscribe(([i,r])=>{this._renderFrameTimeMetric||(this._renderFrameTimeMetric={}),this._renderFrameTimeMetric[i]||(this._renderFrameTimeMetric[i]=[]),this._renderFrameTimeMetric[i].push(Math.round(r*100)/100)}),e.renderFrameTags$.subscribe(([i,r])=>{this._renderFrameTags[i]=r});const t=[];this._afterRenderMetric$.pipe(k.withLatestFrom(e.endFrame$)).subscribe(([i,r])=>{t.push({FPS:r.FPS,elapsedTime:r.elapsedTime,frameTime:Math.round(r.frameTime*100)/100,...i.frameTimeMetric,...i.tags}),t.length>dS&&(this._captureRenderMetric(t),t.length=0)})}_captureRenderMetric(e){var S;const t=e;if(t.length===0)return;const i=g=>{let f=0;const v=Object.entries(g).filter(([_,E])=>Array.isArray(E)).map(([_])=>_).reduce((_,E)=>{const T=g[E].reduce((P,R)=>P+R,0);return _[E]=T,_},{});return Object.keys(g).filter(_=>_.startsWith(M.SHEET_EXTENSION_PREFIX)).forEach(_=>{f+=v[_]}),{...v,extensionTotal:f}},r=e.map(g=>({...g,...i(g)})),l=(g=>Object.entries(g[0]).filter(([v,C])=>!["elapsedTime"].includes(v)).filter(([v,C])=>typeof C=="number").map(([v])=>v).reduce((v,C)=>{const _=g.map(R=>R[C]),E=Math.max(..._),T=Math.min(..._),P=_.reduce((R,O)=>R+O,0)/_.length;return v[C]={max:Math.round(E*100)/100,min:Math.round(T*100)/100,avg:Math.round(P*100)/100},v},{}))(r),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),(S=this._telemetryService)==null||S.capture("sheet_render_cost",h)}_addComponent(e){const{scene:t,components:i}=this._context,r=e.getActiveSheet(),s=new M.Spreadsheet(he.MAIN);this._addViewport(r);const l=new M.SpreadsheetRowHeader(he.ROW),c=new M.SpreadsheetColumnHeader(he.COLUMN),d=new M.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,i.set(he.MAIN,s),i.set(he.ROW,l),i.set(he.COLUMN,c),i.set(he.LEFT_TOP,d),t.addObjects([s],zs),t.addObjects([l,c,d],ft),t.enableLayerCache(zs,ft)}_initViewports(e,t,i){const l=new M.Viewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN,e,{left:t.width,top:i.height,bottom:0,right:0,isWheelPreventDefaultX:!0,allowCache:!0,bufferEdgeX:100,bufferEdgeY:100}),c=new M.Viewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:0}),d=new M.Viewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:100}),u=new M.Viewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:100,bufferEdgeY:0}),h=new M.Viewport(M.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP,e,{active:!1,isWheelPreventDefaultX:!0}),S=new M.Viewport(M.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM,e,{left:0,top:i.height,bottom:0,width:t.width+1,isWheelPreventDefaultX:!0}),g=new M.Viewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT,e,{active:!1,isWheelPreventDefaultX:!0}),f=new M.Viewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT,e,{left:t.width,top:0,height:i.height+1,right:0,isWheelPreventDefaultX:!0}),p=new M.Viewport(M.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP,e,{left:0,top:0,width:t.width,height:i.height,isWheelPreventDefaultX:!0});return{viewMain:l,viewLeftTop:p,viewMainLeftTop:c,viewMainLeft:d,viewMainTop:u,viewColumnLeft:g,viewRowTop:h,viewRowBottom:S,viewColumnRight:f}}_addViewport(e){const t=this._context.scene,{rowHeader:i,columnHeader:r}=e.getConfig(),{viewMain:s}=this._initViewports(t,i,r),l=this._configService.getConfig(Ke),c=l==null?void 0:l.scrollConfig;return new M.ScrollBar(s,c),t.attachControl(),s}_initRerenderScheduler(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(!e)return null;const{skeleton:t,sheetId:i}=e,r=this._context.unit,s=r==null?void 0:r.getSheetBySheetId(i);if(r==null||s==null)return;const{mainComponent:l,components:c}=this._context,d=l,u=c.get(he.ROW),h=c.get(he.COLUMN),S=c.get(he.LEFT_TOP),{rowHeaderWidth:g,columnHeaderHeight:f}=t;d==null||d.updateSkeleton(t),u==null||u.updateSkeleton(t),h==null||h.updateSkeleton(t),S==null||S.transformByState({width:g,height:f})}))}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{const{unit:t}=this._context,{id:i}=e;if(m.COMMAND_LISTENER_SKELETON_CHANGE.includes(i)||this._sheetRenderService.checkMutationShouldTriggerRerender(i)){const r=e.params,{unitId:s,subUnitId:l}=r,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:i},!0),this._sheetSkeletonManagerService.setCurrent({sheetId:u,commandId:i})}else m.COMMAND_LISTENER_VALUE_CHANGE.includes(i)&&this._sheetSkeletonManagerService.reCalculate();e.type===a.CommandType.MUTATION&&this._markUnitDirty(e)}))}_markUnitDirty(e){const{mainComponent:t,scene:i}=this._context;if(e.id===q.SetFormulaCalculationNotificationMutation.id&&e.params.stageInfo!=null||(t&&t.makeDirty(),i.makeDirty(),!e.params))return;const r=e.params,s=this._spreadsheetViewports(i);if(e.id===m.SetRangeValuesMutation.id&&r.cellValue){const l=this._cellValueToRange(r.cellValue),c=this._rangeToBounds([l]);this._markViewportDirty(s,c),t.setDirtyArea(c)}if(e.id===m.MoveRangeMutation.id&&r.from&&r.to){const l=r.fromRange||this._cellValueToRange(r.from.value),c=r.toRange||this._cellValueToRange(r.to.value),d=this._rangeToBounds([l,c]);this._markViewportDirty(s,d),t.setDirtyArea(d)}}_cellValueToRange(e){let t=0,i=0,r=0,s=0;for(const[h,S]of Object.entries(e)){for(const g in S)t>Number(g)&&(t=Number(g)),i<Number(g)&&(i=Number(g));r>Number(h)&&(r=Number(h)),s<Number(h)&&(s=Number(h))}return{startRow:r,endRow:s,startColumn:t,endColumn:i}}_rangeToBounds(e){const t=this._sheetSkeletonManagerService.getCurrentParam().skeleton,{rowHeightAccumulation:i,columnWidthAccumulation:r,rowHeaderWidth:s,columnHeaderHeight:l}=t,c=[];for(const d of e){const{startRow:u,endRow:h,startColumn:S,endColumn:g}=d,f=u===0?0:i[u-1]+l,p=i[h]+l,v=S===0?0:r[S-1]+s,C=r[g]+s;c.push({top:f,left:v,bottom:p,right:C,width:C-v,height:p-f})}return c}_markViewportDirty(e,t){const i=e.filter(r=>r.isActive&&r.cacheBound);for(const r of i)for(const s of t)a.Rectangle.hasIntersectionBetweenTwoRect(r.cacheBound,s)&&r.markDirty(!0)}_spreadsheetViewports(e){return e.getViewports().filter(t=>["viewMain","viewMainLeftTop","viewMainTop","viewMainLeft"].includes(t.viewportKey))}},y.SheetRenderController=cS([Ii(1,a.Inject(a.IConfigService)),Ii(2,a.Inject(y.SheetSkeletonManagerService)),Ii(3,a.Inject(y.SheetsRenderService)),Ii(4,a.ICommandService),Ii(5,a.Optional(ld.ITelemetryService))],y.SheetRenderController);function uS(n,o){if(n.length!==o.length)return!1;const e=n.sort((i,r)=>i.id.localeCompare(r.id)),t=o.sort((i,r)=>i.id.localeCompare(r.id));return e.every((i,r)=>{var s,l;return((s=i.subject)==null?void 0:s.userID)===((l=t[r].subject)==null?void 0:l.userID)&&i.role===t[r].role})}function yl(n,o){return o.some(e=>hS(n,e))}function hS(n,o){const{startRow:e,startColumn:t,endColumn:i,endRow:r}=o,s=n.getMatrixWithMergedCells(e,t,r,i);let l=!1;return s.forValue((c,d,u)=>{if(u&&(c!==e||d!==t)&&n.cellHasValue(u))return l=!0,!1}),l}function Ml(n,o,e,t){const i=[],r=[],s=e.getSheetId();return t.forEach(l=>{const c=mS(e,l),d={unitId:o,subUnitId:s,cellValue:c.getData()},u=m.SetRangeValuesUndoMutationFactory(n,d);i.push({id:m.SetRangeValuesMutation.id,params:u}),r.push({id:m.SetRangeValuesMutation.id,params:d})}),{undos:i,redos:r}}function mS(n,o){const{startRow:e,startColumn:t,endColumn:i,endRow:r}=o,s=n.getMatrixWithMergedCells(e,t,r,i,a.CellModeEnum.Intercepted),l=new a.ObjectMatrix;let c=null;return s.forValue((d,u,h)=>{var S,g,f,p;h&&d>=e&&u>=t&&(!c&&n.cellHasValue(h)&&(h.v!==""||((p=(f=(g=(S=h.p)==null?void 0:S.body)==null?void 0:g.dataStream)==null?void 0:f.length)!=null?p:0)>2)&&(c=h),l.setValue(d,u,null))}),l.setValue(e,t,c),l}function SS(n,o,e,t){const i=e.getActiveViewportByCoord(M.Vector2.FromArray([n,o]));if(!i)return;const{scaleX:r,scaleY:s}=e.getAncestorScale(),l={x:i.viewportScrollX,y:i.viewportScrollY},c=t.getCellIndexByOffset(n,o,r,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 Rl(n,o,e,t){const i=t.getFreeze();if(!i||i.startRow<=0&&i.startColumn<=0||n>=i.startRow&&o>=i.startColumn)return e.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(n<i.startRow&&o<i.startColumn)return e.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP);if(n<i.startRow&&o>=i.startColumn)return e.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(n>=i.startRow&&o<i.startColumn)return e.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)}function gS(n,o,e,t){const i=Pl(n.left,n.top,o,e,t),r=Pl(n.right,n.bottom,o,e,t);return{left:i.x,top:i.y,right:r.x,bottom:r.y}}function Pl(n,o,e,t,i){const{scaleX:r,scaleY:s}=e.getAncestorScale(),l=e.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(!l)return{x:n,y:o};const c=i.getFreeze(),{startColumn:d,startRow:u,xSplit:h,ySplit:S}=c,g=t.getNoMergeCellWithCoordByIndex(u-S,d-h,!1),f=t.getNoMergeCellWithCoordByIndex(u,d,!1),{rowHeaderWidth:p,columnHeaderHeight:v}=t,C=f.startX-g.startX,_=f.startY-g.startY,{top:E,left:T,viewportScrollX:P,viewportScrollY:R}=l;let O;n>T?O=(n-P)*r:O=(C+p-(T-n))*r;let A;return o>E?A=(o-R)*s:A=(_+v-(E-o))*r,{x:O,y:A}}function Ol(n,o,e,t,i){let r=t,s=i;e.overflowCache.forValue((d,u,h)=>{h.startRow<=r&&h.endRow>=r&&h.startColumn<=s&&h.endColumn>=s&&(s=u,r=d)});const l=e.getCellWithCoordByIndex(r,s);return{unitId:n.getUnitId(),subUnitId:o.getSheetId(),workbook:n,worksheet:o,row:l.actualRow,col:l.actualColumn}}function Al(n,o,e,t,i,r){const{scene:s}=n,l=o.getUnitId(),{skeleton:c,sheetId:d}=t,u=SS(i,r,s,c);if(!u)return null;let{actualCol:h,actualRow:S}=u;const g={unitId:l,subUnitId:d,workbook:o,worksheet:e,row:S,col:h};c.overflowCache.forValue((R,O,A)=>{A.startRow<=S&&A.endRow>=S&&A.startColumn<=h&&A.endColumn>=h&&(h=O,S=R)});const f=c.getCellWithCoordByIndex(S,h),p=Ol(o,e,c,S,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(M.Vector2.FromArray([i,r]));if(!C)return;const{scaleX:_,scaleY:E}=s.getAncestorScale(),T={x:C.viewportScrollX,y:C.viewportScrollY};return{position:{startX:(c.getOffsetByColumn(v.startColumn-1)-T.x)*_,endX:(c.getOffsetByColumn(v.endColumn)-T.x)*_,startY:(c.getOffsetByRow(v.startRow-1)-T.y)*E,endY:(c.getOffsetByRow(v.endRow)-T.y)*E},location:g,overflowLocation:p}}const bt={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(n,o)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),i=n.get(a.IUniverInstanceService),r=n.get(I.IConfirmService),s=n.get(a.LocaleService),l=o.unitId,c=o.subUnitId,d=o.selections,u=m.getAddMergeMutationRangeByType(d,o.value),h=i.getUniverSheetInstance(l).getSheetBySheetId(c),S=[],g=[],f=yl(h,u);if(f&&!o.defaultMerge&&!await r.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),_=m.AddMergeUndoMutationFactory(n,v);if(C.ranges.length>0&&S.push({id:m.RemoveWorksheetMergeMutation.id,params:C}),S.push({id:m.AddWorksheetMergeMutation.id,params:v}),g.push({id:m.RemoveWorksheetMergeMutation.id,params:_}),C.ranges.length>0&&g.push({id:m.AddWorksheetMergeMutation.id,params:C}),f){const A=Ml(n,l,h,u);S.unshift(...A.redos),g.push(...A.undos)}const E=m.AddMergeRedoSelectionsOperationFactory(n,o,u);E&&S.push(E);const T=m.AddMergeUndoSelectionsOperationFactory(n,o);T&&g.push(T);const R=n.get(m.SheetInterceptorService).onCommandExecute({id:bt.id,params:{unitId:l,subUnitId:c,ranges:u}});return S.push(...R.redos),g.push(...R.undos),a.sequenceExecute(S,e).result?(t.pushUndoRedo({unitID:l,undoMutations:g,redoMutations:S}),!0):!1}},es={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async n=>{var u;const o=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),i=ur(Zi.MergeAll,t);if(!(i!=null&&i.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 o.executeCommand(bt.id,{selections:i,unitId:c,subUnitId:d})}},ts={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async n=>{var u;const o=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),i=ur(Zi.MergeVertical,t);if(!(i!=null&&i.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 o.executeCommand(bt.id,{value:a.Dimension.COLUMNS,selections:i,unitId:c,subUnitId:d})}},ns={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async n=>{var u;const o=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),i=ur(Zi.MergeHorizontal,t);if(!(i!=null&&i.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 o.executeCommand(bt.id,{value:a.Dimension.ROWS,selections:i,unitId:c,subUnitId:d})}},Pn={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-left-confirm",handler:async n=>{const o=n.get(I.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),i=n.get(m.SheetsSelectionsService),r=n.get(a.IUniverInstanceService),s=i.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(r);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=g=>g.endRow-g.startRow;return!c.getMergeData().find(g=>{const f=a.Rectangle.getIntersects(g,d);return f?u(g)>u(f):!1})||await o.confirm({id:Pn.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}},Gt={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-up-confirm",handler:async n=>{const o=n.get(I.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),i=n.get(m.SheetsSelectionsService),r=n.get(a.IUniverInstanceService),s=i.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(r);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 g=d.startRow;g<=d.endRow;g++)if(c.getRowFiltered(g)&&await o.confirm({id:Gt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=g=>g.endColumn-g.startColumn;return!c.getMergeData().find(g=>{const f=a.Rectangle.getIntersects(g,d);return f?u(g)>u(f):!1})||await o.confirm({id:Gt.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}},Zt={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-down-confirm",handler:async n=>{const o=n.get(I.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),i=n.get(m.SheetsSelectionsService),r=n.get(a.IUniverInstanceService),s=i.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(r);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 g=d.startRow;g<=d.endRow;g++)if(c.getRowFiltered(g)&&await o.confirm({id:Zt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=g=>g.endColumn-g.startColumn;return!c.getMergeData().find(g=>{const f=a.Rectangle.getIntersects(g,d);return f?u(g)>u(f):!1})||await o.confirm({id:Zt.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}},On={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-right-confirm",handler:async n=>{const o=n.get(I.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),i=n.get(m.SheetsSelectionsService),r=n.get(a.IUniverInstanceService),s=i.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(r);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=g=>g.endRow-g.startRow;return!c.getMergeData().find(g=>{const f=a.Rectangle.getIntersects(g,d);return f?u(g)>u(f):!1})||await o.confirm({id:On.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 kl=(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))(kl||{}),te=(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))(te||{}),He=(n=>(n[n.Reader=0]="Reader",n[n.Editor=1]="Editor",n[n.Owner=2]="Owner",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(He||{}),lt=(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))(lt||{}),tt=(n=>(n[n.SomeCollaborator=0]="SomeCollaborator",n[n.AllCollaborator=1]="AllCollaborator",n[n.OneSelf=2]="OneSelf",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(tt||{});const _i="UNIVER_SHEET_PERMISSION_PANEL",uo="UNIVER_SHEET_PERMISSION_USER_PART",is="UNIVER_SHEET_PERMISSION_BACKGROUND",Dl="UNIVER_SHEET_PERMISSION_USER_DIALOG",Nl="UNIVER_SHEET_PERMISSION_DIALOG",ho="UNIVER_SHEET_PERMISSION_USER_DIALOG_ID",mo="UNIVER_SHEET_PERMISSION_DIALOG_ID",So={[te.Copy]:"Copy",[te.SetCellStyle]:"SetCellStyle",[te.SetCellValue]:"SetCellValue",[te.SetRowStyle]:"SetRowStyle",[te.SetColumnStyle]:"SetColumnStyle",[te.InsertRow]:"InsertRow",[te.InsertColumn]:"InsertColumn",[te.InsertHyperlink]:"InsertHyperlink",[te.DeleteRow]:"DeleteRow",[te.DeleteColumn]:"DeleteColumn",[te.Sort]:"Sort",[te.Filter]:"Filter",[te.PivotTable]:"PivotTable",[te.EditExtraObject]:"EditExtraObject"},fS=[te.Copy,te.SetCellStyle,te.SetCellValue,te.SetRowStyle,te.SetColumnStyle,te.InsertRow,te.InsertColumn,te.InsertHyperlink,te.DeleteRow,te.DeleteColumn,te.Sort,te.Filter,te.PivotTable,te.EditExtraObject,te.View],Hl="sheet-permission-menu-icon",pS="sheet-permission-delete-icon",vS="sheet-permission-edit-icon",CS="sheet-permission-check-icon",Vl="sheet-permission-lock-icon",IS={unitId:"",subUnitId:"",permissionId:"",unitType:m.UnitObject.SelectRange,id:"",ranges:[],viewState:m.ViewStateEnum.OthersCanView,editState:m.EditStateEnum.OnlyMe};class An{constructor(){w(this,"_rule",IS);w(this,"_visible",!1)}setVisible(o){this._visible=o}getVisible(){return this._visible}reset(){this.setVisible(!1)}}class Et{constructor(){w(this,"_userList",[]);w(this,"_userList$",new k.BehaviorSubject(this._userList));w(this,"userList$",this._userList$.asObservable());w(this,"_oldCollaboratorList",[]);w(this,"_selectUserList",[]);w(this,"_selectUserList$",new k.BehaviorSubject(this._selectUserList));w(this,"selectUserList$",this._selectUserList$.asObservable())}get userList(){return this._userList}setCanEditUserList(o){this._userList=o,this._userList$.next(o)}reset(){this._userList=[],this._oldCollaboratorList=[],this._selectUserList=[],this._selectUserList$.next([])}get oldCollaboratorList(){return this._oldCollaboratorList}setOldCollaboratorList(o){this._oldCollaboratorList=o}get selectUserList(){return this._selectUserList}setSelectUserList(o){this._selectUserList=o,this._selectUserList$.next(o)}}const nt={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openPanel",async handler(n,o={}){const e=n.get(I.ISidebarService),t=n.get(An),i=n.get(Et),{showDetail:r=!0,fromSheetBar:s=!1,rule:l,oldRule:c}=o,d={header:{title:"permission.panel.title"},children:{label:_i,showDetail:r,fromSheetBar:s,rule:l,oldRule:c},width:330,onClose:()=>{t.reset(),i.reset()}};return t.setVisible(!0),e.open(d),!0}},bi={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-toolbar",async handler(n){return await n.get(a.ICommandService).executeCommand(nt.id,{showDetail:!0}),!0}},Kt={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(nt.id,{showDetail:!0}),!0}},qt={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(nt.id,{showDetail:!1}),!0}},Ei={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(nt.id,{fromSheetBar:!0,showDetail:!0}),!0}},wi={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(nt.id,{showDetail:!1}),!0}},Qt={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-protection-from-context-menu",async handler(n){var h;const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IUndoRedoService),i=n.get(m.SheetsSelectionsService),r=n.get(m.WorksheetProtectionRuleModel),s=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s.getActiveSheet(),c=s.getUnitId(),d=l.getSheetId(),u=r.getRule(c,d);if(u!=null&&u.permissionId)return o.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d,rule:u});{const S=(h=i.getCurrentLastSelection())==null?void 0:h.range;if(!S)return!1;const p=n.get(m.RangeProtectionRuleModel).getSubunitRuleList(c,d).find(v=>v.ranges.some(C=>a.Rectangle.intersects(C,S)));if(p){const v={unitId:c,subUnitId:d,ruleIds:[p.id]};return await o.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}}},Jt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-protection-from-context-menu",async handler(n){var u;const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(m.WorksheetProtectionRuleModel),r=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=r.getActiveSheet(),l=r.getUnitId(),c=s.getSheetId(),d=i.getRule(l,c);if(d!=null&&d.permissionId){const h={...d,unitId:l,subUnitId:c,ranges:[]};return await o.executeCommand(nt.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 o.executeCommand(nt.id,{showDetail:!0,rule:a.Tools.deepClone(p),oldRule:a.Tools.deepClone(p)}),!0}else return!1}}},kn={id:"sheet.command.remove-row-confirm",type:a.CommandType.COMMAND,handler:async(n,o)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=o==null?void 0:o.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const i=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(r);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleRows();if(aa(c,[t])){const u=n.get(I.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 i.executeCommand(m.RemoveRowCommand.id,{range:t}),!0}},Dn={id:"sheet.command.remove-col-confirm",type:a.CommandType.COMMAND,handler:async(n,o)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=o==null?void 0:o.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const i=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(r);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleCols();if(la(c,[t])){const u=n.get(I.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 i.executeCommand(m.RemoveColCommand.id,{range:t}),!0}},Ti={id:"sheet.command.remove-sheet-confirm",type:a.CommandType.COMMAND,handler:async(n,o)=>{const{subUnitId:e}=o,t=n.get(I.IConfirmService),i=n.get(a.ICommandService),r=n.get(a.LocaleService);return await t.confirm({id:"sheet.confirm.remove-sheet",title:{title:r.t("sheetConfig.deleteSheet")},children:{title:r.t("sheetConfig.deleteSheetContent")},cancelText:r.t("button.cancel"),confirmText:r.t("button.confirm")})?(await i.executeCommand(m.RemoveSheetCommand.id,{subUnitId:e}),!0):!1}},yi={id:"ui-sheet.command.show-menu-list",type:a.CommandType.OPERATION,handler:async n=>(n.get(Wt).triggerSheetBarMenu(),!0)},Mi={type:a.CommandType.COMMAND,id:"sheet.command.delete-worksheet-protection-from-sheet-bar",async handler(n,o){if(!o)return!1;const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),i=n.get(m.WorksheetProtectionRuleModel),s=n.get(a.IUniverInstanceService).getCurrentUnitForType(kl.UNIVER_SHEET),l=s==null?void 0:s.getActiveSheet(),c=s.getUnitId();if(!l)return!1;const d=l.getSheetId(),u=i.getRule(c,d);if(await e.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d})){const S=[{id:m.DeleteWorksheetProtectionCommand.id,params:{unitId:c,subUnitId:d}}],g=[{id:m.AddWorksheetProtectionCommand.id,params:{unitId:c,rule:u}}];t.pushUndoRedo({unitID:c,redoMutations:S,undoMutations:g})}return!0}},Ri={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}},go={id:"sheet.operation.set-activate-cell-edit",type:a.CommandType.OPERATION,handler:(n,o)=>(n.get(ge).setEditCell(o),!0)},Pi={id:"sheet.operation.rename-sheet",type:a.CommandType.OPERATION,handler:async(n,o)=>{const e=n.get(Wt);return o&&e.setRenameId(o.subUnitId),!0}},os={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openDialog",async handler(n,o){const e=n.get(I.IDialogService);return e.close("DESKTOP_FIND_REPLACE_DIALOG"),e.open({id:mo,title:{title:"permission.dialog.allowedPermissionType"},children:{label:Nl},width:393,destroyOnClose:!0,onClose:()=>e.close(mo)}),!0}},_S=()=>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"})]}),bS=()=>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"})]}),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:"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"})]}),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.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"})]}),TS=()=>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"})}),yS=()=>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"})]}),MS=()=>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"})]}),RS=()=>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"})]}),PS=()=>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"})}),Wl=()=>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 Ll(n){const{type:o=a.BorderStyleTypes.THIN}=n;switch(o){case a.BorderStyleTypes.DASH_DOT:return b.jsx(_S,{});case a.BorderStyleTypes.DASH_DOT_DOT:return b.jsx(bS,{});case a.BorderStyleTypes.DASHED:return b.jsx(ES,{});case a.BorderStyleTypes.HAIR:return b.jsx(wS,{});case a.BorderStyleTypes.MEDIUM:return b.jsx(TS,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT:return b.jsx(yS,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return b.jsx(MS,{});case a.BorderStyleTypes.MEDIUM_DASHED:return b.jsx(RS,{});case a.BorderStyleTypes.THICK:return b.jsx(PS,{});case a.BorderStyleTypes.THIN:return b.jsx(Wl,{});default:return b.jsx(Wl,{})}}const rs=`${Tn}_BORDER_PANEL_COMPONENT`,Ul=[{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"}],OS=[{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 Bl(n){var l;const o=I.useDependency(I.ComponentManager),e=I.useDependency(m.BorderStyleManagerService),{onChange:t,value:i}=n;function r(c,d){t==null||t({...i,[d]:c})}function s(c){const d=o.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:Ul.map(c=>b.jsx("a",{className:G.clsx(`
|
|
58
|
+
`)}),o}function om(n){return a.isNotNullOrUndefined(n.displayV)?n.displayV:a.extractPureTextFromCell(n)}function rm(n,o,e,t){return t.getMergeData().some(i=>i.startRow<=n&&n<i.endRow&&o<=i.startColumn&&i.startColumn<=e)}function sm(n,o,e,t){return t.getMergeData().some(i=>i.startColumn<=n&&n<i.endColumn&&o<=i.startRow&&i.startRow<=e)}function am(n){let o=0;return n.forValue((e,t,i)=>{if(i&&o++,o>1)return!1}),o>1}function ii(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const Ar=998,je={id:I.CopyCommand.id,name:"sheet.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:Ar,preconditions:br,handler:async n=>n.get(xe).copy()},kr={id:I.CutCommand.id,name:"sheet.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:Ar,preconditions:br,handler:async n=>n.get(xe).cut()},Ge={id:I.PasteCommand.id,type:a.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:Ar,preconditions:br,handler:async(n,o)=>{const t=await n.get(I.IClipboardInterfaceService).read(),i=n.get(xe);return t.length!==0?i.paste(t[0],o==null?void 0:o.value):!1}},io={id:I.SheetPasteShortKeyCommandName,type:a.CommandType.COMMAND,handler:async(n,o)=>{const e=n.get(xe),{htmlContent:t,textContent:i,files:r}=o;return e.legacyPaste(t,i,r),!0}},Cn={id:"sheet.command.paste-value",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ge.id,{value:fe.SPECIAL_PASTE_VALUE})},In={id:"sheet.command.paste-format",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ge.id,{value:fe.SPECIAL_PASTE_FORMAT})},Bt={id:"sheet.command.paste-col-width",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ge.id,{value:fe.SPECIAL_PASTE_COL_WIDTH})},_n={id:"sheet.command.paste-besides-border",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ge.id,{value:fe.SPECIAL_PASTE_BESIDES_BORDER})},ll={id:"sheet.command.optional-paste",type:a.CommandType.COMMAND,handler:async(n,{type:o})=>n.get(xe).rePasteWithPasteType(o)},oi={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),i=n.get(a.IUniverInstanceService),r=m.getSheetCommandTarget(i);if(!r)return!1;const{worksheet:s}=r,l=s.getVisibleRows();if(aa(l,e)){const d=n.get(I.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}},ri={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),i=n.get(a.IUniverInstanceService),r=m.getSheetCommandTarget(i);if(!r)return!1;const{worksheet:s}=r,l=s.getVisibleCols();if(la(l,e)){const d=n.get(I.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}},xt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async n=>{const o=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?o.executeCommand(Q.SetInlineFormatBoldCommand.id):o.executeCommand(m.SetBoldCommand.id)}},Ft={type:a.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async n=>{const o=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?o.executeCommand(Q.SetInlineFormatItalicCommand.id):o.executeCommand(m.SetItalicCommand.id)}},zt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async n=>{const o=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?o.executeCommand(Q.SetInlineFormatUnderlineCommand.id):o.executeCommand(m.SetUnderlineCommand.id)}},Xt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async n=>{const o=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?o.executeCommand(Q.SetInlineFormatStrikethroughCommand.id):o.executeCommand(m.SetStrikeThroughCommand.id)}},Dr={type:a.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async n=>{const o=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?o.executeCommand(Q.SetInlineFormatSubscriptCommand.id):!1}},Nr={type:a.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async n=>{const o=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?o.executeCommand(Q.SetInlineFormatSuperscriptCommand.id):!1}},si={type:a.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(n,o)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(Q.SetInlineFormatFontSizeCommand.id,o):e.executeCommand(m.SetFontSizeCommand.id,o)}},ai={type:a.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(n,o)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(Q.SetInlineFormatFontFamilyCommand.id,o):e.executeCommand(m.SetFontFamilyCommand.id,o)}},bn={type:a.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(n,o)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(Q.SetInlineFormatTextColorCommand.id,o):e.executeCommand(m.SetTextColorCommand.id,o)}},Hr={type:a.CommandType.COMMAND,id:"sheet.command.reset-range-text-color",handler:async n=>{const o=n.get(a.ICommandService),t=n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED),i=n.get(a.ThemeService);return t?o.executeCommand(Q.SetInlineFormatTextColorCommand.id,{value:null}):o.executeCommand(m.SetTextColorCommand.id,{value:i.getCurrentTheme().textColor})}};var lm=Object.getOwnPropertyDescriptor,cm=(n,o,e,t)=>{for(var i=t>1?void 0:t?lm(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},En=(n,o)=>(e,t)=>o(e,t,n),Ne=(n=>(n[n.OFF=0]="OFF",n[n.ONCE=1]="ONCE",n[n.INFINITE=2]="INFINITE",n))(Ne||{});const $e=a.createIdentifier("univer.format-painter-service");let oo=class extends a.Disposable{constructor(o,e,t,i,r,s){super();w(this,"status$");w(this,"_selectionFormat");w(this,"_markId",null);w(this,"_status$");w(this,"_defaultHook",null);w(this,"_extendHooks",[]);this._selectionManagerService=o,this._themeService=e,this._markSelectionService=t,this._logService=i,this._commandService=r,this._undoRedoService=s,this._status$=new k.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new a.ObjectMatrix,merges:[]}}addHook(o){var e,t,i;o.isDefaultHook&&((e=o.priority)!=null?e:0)>((i=(t=this._defaultHook)==null?void 0:t.priority)!=null?i:-1)?this._defaultHook=o:(this._extendHooks.push(o),this._extendHooks.sort((r,s)=>(r.priority||0)-(s.priority||0)))}getHooks(){return this._defaultHook?[this._defaultHook,...this._extendHooks]:this._extendHooks}setStatus(o){this._updateRangeMark(o),this._status$.next(o),this.getHooks().forEach(t=>{t.onStatusChange!==void 0&&t.onStatusChange(o)})}getStatus(){return this._status$.getValue()}setSelectionFormat(o){this._selectionFormat=o}getSelectionFormat(){return this._selectionFormat}applyFormatPainter(o,e,t){const i=this.getHooks(),r=[],s=[];i.forEach(c=>{if(c.onApply!==void 0){const d=c.onApply(o,e,t,this._selectionFormat);d&&(r.push(...d.redos),s.push(...d.undos))}});for(const c of i)if(c.onBeforeApply!==void 0&&!c.onBeforeApply({unitId:o,subUnitId:e,range:t,redoMutationsInfo:r,format:this._selectionFormat,undoMutationsInfo:s}))return!1;this._logService.log("[FormatPainterService]","apply mutations",{undoMutationsInfo:s,redoMutationsInfo:r});const l=r.every(c=>this._commandService.executeCommand(c.id,c.params));return l&&this._undoRedoService.pushUndoRedo({unitID:o,undoMutations:s,redoMutations:r}),l}_updateRangeMark(o){if(this._markSelectionService.removeAllShapes(),o!==0){const e=this._selectionManagerService.getCurrentLastSelection();if(e){const t=qa(this._themeService);o===2?this._markId=this._markSelectionService.addShape({...e,style:t}):this._markId=this._markSelectionService.addShape({...e,style:t},[m.SetRangeValuesMutation.id])}}}};oo=cm([En(0,a.Inject(m.SheetsSelectionsService)),En(1,a.Inject(a.ThemeService)),En(2,Ut),En(3,a.ILogService),En(4,a.ICommandService),En(5,a.IUndoRedoService)],oo);const li={id:"sheet.operation.set-format-painter",type:a.CommandType.OPERATION,handler:(n,o)=>o?(n.get($e).setStatus(o.status),!0):!1},ro={type:a.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async n=>{const e=n.get($e).getStatus();let t;return e!==Ne.OFF?t=Ne.OFF:t=Ne.INFINITE,n.get(a.ICommandService).executeCommand(li.id,{status:t})}},wn={type:a.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async n=>{const e=n.get($e).getStatus();let t;return e!==Ne.OFF?t=Ne.OFF:t=Ne.ONCE,n.get(a.ICommandService).executeCommand(li.id,{status:t})}},ci={type:a.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(n,o)=>n.get($e).applyFormatPainter(o.unitId,o.subUnitId,o.range)},at={type:a.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(n,o)=>{const{type:e}=o||{},t=n.get(a.IUniverInstanceService),i=n.get(a.IUndoRedoService),r=m.getSheetCommandTarget(t);if(!r)return!1;const{unitId:s,subUnitId:l}=r,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:S}=h,f=n.get(M.IRenderManagerService).getRenderById(s).with(y.SheetScrollManagerService),{sheetViewStartRow:p=0,sheetViewStartColumn:v=0}=f.getCurrentScrollState()||{};let C,_,E,T;const{startRow:P,startColumn:R,rangeType:O}=S;if(O===a.RANGE_TYPE.ROW||e===1)C=P,E=P-p,_=-1,T=0;else if(O===a.RANGE_TYPE.COLUMN||e===2)C=-1,E=0,_=R,T=R-v;else if(O===a.RANGE_TYPE.NORMAL)C=P,E=P-p,_=R,T=R-v;else return!1;const A={unitId:s,subUnitId:l,startRow:C,startColumn:_,xSplit:_>0?Math.max(1,T):T,ySplit:C>0?Math.max(1,E):E},N=m.SetFrozenMutationFactory(n,A);return c.syncExecuteCommand(m.SetFrozenMutation.id,A)&&i.pushUndoRedo({unitID:s,undoMutations:[{id:m.SetFrozenMutation.id,params:N}],redoMutations:[{id:m.SetFrozenMutation.id,params:A}]}),!0}},di={type:a.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand(at.id,{type:1}),!0)},ui={type:a.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand(at.id,{type:2}),!0)};var dm=Object.getOwnPropertyDescriptor,um=(n,o,e,t)=>{for(var i=t>1?void 0:t?dm(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},cl=(n,o)=>(e,t)=>o(e,t,n);const hm=(n,o)=>{const{unitId:e,subUnitId:t,ranges:i}=n,r={},s=o.getColumnManager();for(let l=0;l<i.length;l++){const c=i[l];for(let d=c.startColumn;d<c.endColumn+1;d++){const u=s.getColumnOrCreate(d);r[d]=u.w}}return{unitId:e,subUnitId:t,ranges:i,colWidth:r}};y.AutoWidthController=class extends a.Disposable{constructor(o,e){super(),this._renderManagerService=o,this._univerInstanceService=e}getUndoRedoParamsOfColWidth(o){const e={redos:[],undos:[]},{_univerInstanceService:t}=this,i=m.getSheetCommandTarget(t);if(!i)return e;const{unitId:r,subUnitId:s,worksheet:l}=i,c=this._renderManagerService.getRenderById(r).with(y.SheetSkeletonManagerService);if(!c.getCurrentParam())return e;const{skeleton:d}=c.getCurrentParam(),u=d.calculateAutoWidthInRange(o.ranges),h={};for(const{col:f,width:p}of u)h[f]=p;const S={subUnitId:s,unitId:r,ranges:o.ranges,colWidth:h},g=hm(S,l);return{undos:[{id:m.SetWorksheetColWidthMutation.id,params:g}],redos:[{id:m.SetWorksheetColWidthMutation.id,params:S}]}}},y.AutoWidthController=um([cl(0,M.IRenderManagerService),cl(1,a.Inject(a.IUniverInstanceService))],y.AutoWidthController);const hi={type:a.CommandType.COMMAND,id:"sheet.command.set-col-auto-width",handler:(n,o)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),i=n.get(m.SheetsSelectionsService),r=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(r,o);if(!s)return!1;const{unitId:l,subUnitId:c}=s;let d=[];if(o!=null&&o.ranges)d=[...o.ranges];else{const f=i.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:S}=n.get(y.AutoWidthController).getUndoRedoParamsOfColWidth(u);return a.sequenceExecute([...h],e).result?(t.pushUndoRedo({unitID:l,undoMutations:[...S],redoMutations:[...h]}),!0):!1}},Tn="UI_PLUGIN_SHEETS",mi=`${Tn}_COLOR_PICKER_COMPONENT`,so=`${Tn}_FONT_FAMILY_COMPONENT`,ao=`${Tn}_FONT_FAMILY_ITEM_COMPONENT`,lo=`${Tn}_FONT_SIZE_COMPONENT`,et=`${Tn}_MENU_ITEM_INPUT_COMPONENT`,Vr={sheetsUiContextMenuInput:"univer-sheets-ui-context-menu-input",sheetsUiContextMenuInputContainer:"univer-sheets-ui-context-menu-input-container",sheetsUiContextMenuInputNumber:"univer-sheets-ui-context-menu-input-number"},dl=n=>{const{prefix:o,suffix:e,value:t,onChange:i,min:r=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=n,l=I.useDependency(a.LocaleService),c=I.useDependency(I.IContextMenuService),[d,u]=L.useState(),h=g=>{var f;u(g==null?void 0:g.toString()),i((f=g==null?void 0:g.toString())!=null?f:"")};L.useEffect(()=>{c.visible||u(t)},[c.visible]),L.useEffect(()=>{u(t)},[t]);function S(g){g.key==="Backspace"&&g.stopPropagation()}return b.jsxs("div",{className:Vr.sheetsUiContextMenuInput,children:[l.t(o),b.jsx("span",{className:Vr.sheetsUiContextMenuInputContainer,onClick:g=>g.stopPropagation(),children:b.jsx(G.InputNumber,{className:Vr.sheetsUiContextMenuInputNumber,value:Number(d),precision:0,onKeyDown:S,onChange:h,min:r,max:s})}),l.t(e)]})};function mm(n){return n.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(Se.switchMap(o=>o?o.activeSheet$.pipe(Se.map(e=>e?{workbook:o,worksheet:e}:null)):k.of(null)))}function Ee(n,o,e){return mm(n).pipe(Se.switchMap(t=>t?e(t):k.of(o)))}function ul(n,o){const e=n.get(a.IUniverInstanceService),t=n.get(m.IExclusiveRangeService),i=n.get(m.SheetsSelectionsService);return e.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(Se.switchMap(s=>s?k.combineLatest([i.selectionMoveEnd$,s.activeSheet$]).pipe(Se.switchMap(([l,c])=>{if(!c||l.length===0)return k.of(!1);const d=t.getInterestGroupId(l);if(o){const u=d.filter(h=>o.has(h));return k.of(u.length>0)}else return k.of(d.length>0)})):k.of(!1)))}function Yt(n,o,e){return k.combineLatest([o,ul(n,e)]).pipe(Se.map(([t,i])=>t||i))}function ee(n,o={},e=!1){const i=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),r=n.get(a.UserManagerService),s=n.has(ge)?n.get(ge):null,l=n.get(a.IContextService),c=new k.BehaviorSubject(!1),d=s==null?void 0:s.visible$,u=new k.BehaviorSubject(null),h=l.subscribeContextValue$(a.FOCUSING_FX_BAR_EDITOR).subscribe(f=>{c.next(f)}),S=d==null?void 0:d.subscribe(f=>{u.next(f)});return k.combineLatest([r.currentUser$,i,u,c]).pipe(Se.finalize(()=>{h.unsubscribe(),S==null||S.unsubscribe(),c.complete()}),Se.switchMap(([f,p,v,C])=>!p||v!=null&&v.visible&&v.unitId===p.getUnitId()&&!e||C&&!e?k.of(!0):p.activeSheet$.pipe(Se.switchMap(_=>{if(!_)return k.of(!0);const E=n.get(m.SheetsSelectionsService),T=n.get(m.RangeProtectionRuleModel),P=n.get(m.WorksheetProtectionRuleModel),O=n.get(a.IContextService).subscribeContextValue$(a.FOCUSING_COMMON_DRAWINGS).pipe(Se.startWith(!1));return k.combineLatest([E.selectionMoveEnd$,O]).pipe(Se.switchMap(([A,N])=>{if(N)return k.of(!0);const D=p.getUnitId(),H=_.getSheetId(),W=n.get(a.IPermissionService),{workbookTypes:U=[m.WorkbookEditablePermission],worksheetTypes:V,rangeTypes:B}=o,x=[];if(U==null||U.forEach(X=>{x.push(new X(D).id)}),V==null||V.forEach(X=>{x.push(new X(D,H).id)}),P.getRule(D,H))return W.composePermission$(x).pipe(Se.map(X=>X.some(Z=>Z.value===!1)));const F=A==null?void 0:A.map(X=>X.range),Y=T.getSubunitRuleList(D,H).filter(X=>F==null?void 0:F.some(Z=>X.ranges.some(ne=>a.Rectangle.intersects(Z,ne))));return B==null||B.forEach(X=>{Y.forEach(Z=>{x.push(new X(D,H,Z.permissionId).id)})}),W.composePermission$(x).pipe(Se.map(X=>X.some(Z=>Z.value===!1)))}))}))))}function yn(n){const o=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(m.RangeProtectionRuleModel),i=n.get(a.IPermissionService);return k.merge(e.selectionMoveEnd$,i.permissionPointUpdate$.pipe(Se.debounceTime(100))).pipe(Se.map(()=>{var h;const r=(h=e.getCurrentLastSelection())==null?void 0:h.range;if(!r)return!0;const s=o.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(S=>S.ranges.some(g=>a.Rectangle.intersects(r,g))).forEach(S=>{u.push(new m.RangeProtectionPermissionEditPoint(c,d,S.permissionId).id)}),i.composePermission(u).some(S=>S.value===!1)}))}function hl(n,o){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(m.RangeProtectionRuleModel),r=n.get(a.IPermissionService);return k.merge(t.selectionMoveEnd$,r.permissionPointUpdate$.pipe(Se.debounceTime(100))).pipe(Se.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];return i.getSubunitRuleList(d,u).filter(g=>o==="row"?g.ranges.some(f=>s.startRow>f.startRow&&s.startRow<=f.endRow):g.ranges.some(f=>s.startColumn>f.startColumn&&s.startColumn<=f.endColumn)).forEach(g=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,g.permissionId).id)}),r.composePermission(h).some(g=>g.value===!1)}))}function ml(n,o){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(m.RangeProtectionRuleModel),r=n.get(a.IPermissionService);return k.merge(t.selectionMoveEnd$,r.permissionPointUpdate$.pipe(Se.debounceTime(100))).pipe(Se.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],S=a.Tools.deepClone(s);return o==="row"?(S.startColumn=0,S.endColumn=c.getColumnCount()-1):(S.startRow=0,S.endRow=c.getRowCount()-1),i.getSubunitRuleList(d,u).filter(f=>f.ranges.some(p=>a.Rectangle.intersects(S,p))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),r.composePermission(h).some(f=>f.value===!1)}))}function co(n,o){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(m.RangeProtectionRuleModel),r=n.get(a.IPermissionService);return k.merge(t.selectionMoveEnd$,r.permissionPointUpdate$.pipe(Se.debounceTime(100))).pipe(Se.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],S=a.Tools.deepClone(s);return o==="row"?S.endRow=c.getRowCount()-1:S.endColumn=c.getColumnCount()-1,i.getSubunitRuleList(d,u).filter(f=>f.ranges.some(p=>a.Rectangle.intersects(S,p))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),r.composePermission(h).some(f=>f.value===!1)}))}function Mn(n,o){const t=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(m.WorksheetProtectionRuleModel),r=n.get(m.RangeProtectionRuleModel),s=n.get(a.IPermissionService),l=n.get(a.UserManagerService);return k.combineLatest([l.currentUser$,t]).pipe(Se.switchMap(([c,d])=>d?d.activeSheet$.pipe(Se.switchMap(u=>{if(!u)return k.of(!0);const h=d.getUnitId(),S=[];return o.forEach(f=>S.push(new f(h).id)),s.composePermission$(S).pipe(Se.map(f=>f.every(p=>p.value===!0))).pipe(Se.map(f=>{if(!f)return!0;const p=u.getSheetId(),v=i.getRule(h,p),C=r.getSubunitRuleList(h,p);return!!(v||C.length)}))})):k.of(!0)))}var Sl=(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))(Sl||{});function Sm(n){const o=n.get($e);return{id:wn.id,subId:ro.id,type:I.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",activated$:new k.Observable(e=>{let t=!1;const i=o.status$.subscribe(r=>{t=r!==Ne.OFF,e.next(t)});return e.next(t),()=>{i.unsubscribe()}}),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetCopyPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function gm(n){const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IContextService),i=n.get(m.SheetsSelectionsService);return{id:xt.id,type:I.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:Ee(e,!1,({worksheet:r})=>new k.Observable(s=>{var u;const l=o.onCommandExecuted(h=>{var g,f;const S=h.id;if(S===m.SetRangeValuesMutation.id||S===m.SetSelectionsOperation.id||S===m.SetWorksheetActiveOperation.id){const p=(g=i.getCurrentLastSelection())==null?void 0:g.primary;let v=a.FontWeight.NORMAL;if(p!=null){const C=r.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getFontWeight()}s.next(v===a.FontWeight.BOLD)}if((S===we.SetTextSelectionsOperation.id||S===Q.SetInlineFormatCommand.id)&&t.getContextValue(a.EDITOR_ACTIVATED)&&t.getContextValue(a.FOCUSING_SHEET)){const p=fi(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.bl;s.next(v===a.BooleanNumber.TRUE)}}),c=(u=i.getCurrentLastSelection())==null?void 0:u.primary;if(!r){s.next(!1);return}let d=a.FontWeight.NORMAL;if(c!=null){const h=r.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontWeight()}return s.next(d===a.FontWeight.BOLD),l.dispose})),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function fm(n){const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(a.IContextService);return{id:Ft.id,type:I.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:Ee(e,!1,({worksheet:r})=>new k.Observable(s=>{var u;const l=o.onCommandExecuted(h=>{var g,f;const S=h.id;if(S===m.SetRangeValuesMutation.id||S===m.SetSelectionsOperation.id||S===m.SetWorksheetActiveOperation.id){const p=(g=t.getCurrentLastSelection())==null?void 0:g.primary;let v=a.FontItalic.NORMAL;if(p!=null){const C=r.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getFontStyle()}s.next(v===a.FontItalic.ITALIC)}if((S===we.SetTextSelectionsOperation.id||S===Q.SetInlineFormatCommand.id)&&i.getContextValue(a.EDITOR_ACTIVATED)&&i.getContextValue(a.FOCUSING_SHEET)){const p=fi(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=r.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontStyle()}return s.next(d===a.FontItalic.ITALIC),l.dispose})),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function pm(n){const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(a.IContextService);return{id:zt.id,type:I.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",activated$:Ee(e,!1,({worksheet:r})=>new k.Observable(s=>{var u;const l=o.onCommandExecuted(h=>{var g,f;const S=h.id;if(S===m.SetRangeValuesMutation.id||S===m.SetSelectionsOperation.id||S===m.SetWorksheetActiveOperation.id){const p=(g=t.getCurrentLastSelection())==null?void 0:g.primary;let v;if(p!=null){const C=r.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getUnderline()}s.next(!!(v&&v.s))}if((S===we.SetTextSelectionsOperation.id||S===Q.SetInlineFormatCommand.id)&&i.getContextValue(a.EDITOR_ACTIVATED)&&i.getContextValue(a.FOCUSING_SHEET)){const p=fi(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=r.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getUnderline()}return s.next(!!(d&&d.s)),l.dispose})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function vm(n){const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(a.IContextService);return{id:Xt.id,type:I.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:Ee(e,!1,({worksheet:r})=>new k.Observable(s=>{var u;const l=o.onCommandExecuted(h=>{var g,f;const S=h.id;if(S===m.SetRangeValuesMutation.id||S===m.SetSelectionsOperation.id||S===m.SetWorksheetActiveOperation.id){const p=(g=t.getCurrentLastSelection())==null?void 0:g.primary;let v;if(p!=null){const C=r.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getStrikeThrough()}s.next(!!(v&&v.s))}if((S===we.SetTextSelectionsOperation.id||S===Q.SetInlineFormatCommand.id)&&i.getContextValue(a.EDITOR_ACTIVATED)&&i.getContextValue(a.FOCUSING_SHEET)){const p=fi(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=r.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getStrikeThrough()}return s.next(!!(d&&d.s)),l.dispose})),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Cm(n){const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=a.DEFAULT_STYLES.ff;return{id:ai.id,tooltip:"toolbar.font",type:I.MenuItemType.SELECTOR,label:so,selections:I.FONT_FAMILY_LIST.map(r=>({label:{name:ao},value:r.value})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),value$:Ee(e,i,({worksheet:r})=>new k.Observable(s=>{const l=()=>{var h;let d=i;const u=(h=t.getCurrentLastSelection())==null?void 0:h.primary;if(u!=null){const S=r.getCellStyle(u.startRow,u.startColumn),g=r.getDefaultCellStyleInternal(),f=r.getRowStyle(u.startRow),p=r.getColumnStyle(u.startColumn),v=a.composeStyles(g,f,p,S);v.ff&&(d=v.ff)}s.next(d)},c=o.onCommandExecuted(d=>{const u=d.id;(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetActiveOperation.id)&&l()});return l(),c.dispose})),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Im(n){const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(a.IContextService),r=a.DEFAULT_STYLES.fs,s=ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0);return{id:si.id,type:I.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:lo,props:{min:1,max:400,disabled$:s}},selections:I.FONT_SIZE_LIST,disabled$:s,value$:Ee(e,r,({worksheet:l})=>new k.Observable(c=>{const d=()=>{var f;let S=r;const g=(f=t.getCurrentLastSelection())==null?void 0:f.primary;if(g!=null){const p=l.getCellStyle(g.startRow,g.startColumn),v=l.getDefaultCellStyleInternal(),C=l.getRowStyle(g.startRow),_=l.getColumnStyle(g.startColumn),E=a.composeStyles(v,C,_,p);E.fs&&(S=E.fs)}c.next(S)},u=()=>{var g,f;const S=fi(n);if(S!=null){const p=(f=(g=S.ts)==null?void 0:g.fs)!=null?f:r;c.next(p)}},h=o.onCommandExecuted(S=>{const g=S.id;(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id)&&d(),(g===we.SetTextSelectionsOperation.id||g===Q.SetInlineFormatCommand.id)&&i.getContextValue(a.EDITOR_ACTIVATED)&&i.getContextValue(a.FOCUSING_SHEET)&&u()});return d(),h.dispose})),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function _m(n){return{id:Hr.id,type:I.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function bm(n){const o=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:bn.id,icon:"FontColor",tooltip:"toolbar.textColor.main",type:I.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:mi,hoverable:!1,selectable:!1}}],value$:new k.Observable(t=>{const i=e.getCurrentTheme().textColor,r=o.onCommandExecuted(s=>{if(s.id===bn.id){const l=s.params.value;t.next(l!=null?l:i)}});return t.next(i),r.dispose}),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function Em(n){return{id:m.ResetBackgroundColorCommand.id,type:I.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function wm(n){const o=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:m.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",type:I.MenuItemType.BUTTON_SELECTOR,icon:"PaintBucket",selections:[{label:{name:mi,hoverable:!1,selectable:!1}}],value$:new k.Observable(t=>{const i=e.getCurrentTheme().primaryColor,r=o.onCommandExecuted(s=>{if(s.id===m.SetBackgroundColorCommand.id){const l=s.params.value;t.next(l!=null?l:i)}});return t.next(i),r.dispose}),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const gl=[{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 Tm(n){const o=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.HorizontalAlign.LEFT;return{id:m.SetHorizontalTextAlignCommand.id,icon:gl[0].icon,tooltip:"toolbar.horizontalAlignMode.main",type:I.MenuItemType.SELECTOR,selections:gl,value$:Ee(o,t,({worksheet:i})=>new k.Observable(r=>{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 S=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let g;if(S!=null){const p=i.getRange(S.startRow,S.startColumn);g=p==null?void 0:p.getHorizontalAlignment()}r.next(g!=null?g:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=i.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getHorizontalAlignment()}return r.next(c!=null?c:t),s.dispose})),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const fl=[{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 ym(n){const o=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.VerticalAlign.BOTTOM;return{id:m.SetVerticalTextAlignCommand.id,icon:fl[2].icon,tooltip:"toolbar.verticalAlignMode.main",type:I.MenuItemType.SELECTOR,selections:fl,value$:Ee(o,t,({worksheet:i})=>new k.Observable(r=>{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 S=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let g;if(S!=null){const p=i.getRange(S.startRow,S.startColumn);g=p==null?void 0:p.getVerticalAlignment()}r.next(g!=null?g:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=i.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getVerticalAlignment()}return r.next(c!=null?c:t),s.dispose})),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const pl=[{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 Mm(n){const o=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=a.WrapStrategy.OVERFLOW;return{id:m.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:pl[0].icon,type:I.MenuItemType.SELECTOR,selections:pl,value$:Ee(e,t,({worksheet:i})=>new k.Observable(r=>{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 S=(f=o.getCurrentLastSelection())==null?void 0:f.primary;let g;if(S!=null){const p=i.getRange(S.startRow,S.startColumn);g=p==null?void 0:p.getWrapStrategy()}r.next(g!=null?g:t)}),l=(d=o.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=i.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getWrapStrategy()}return r.next(c!=null?c:t),s.dispose})),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const vl=[{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 Rm(n){const o=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=0;return{id:m.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:vl[0].icon,type:I.MenuItemType.SELECTOR,selections:vl,value$:Ee(e,t,({worksheet:i})=>new k.Observable(r=>{var d,u;const s=n.get(a.ICommandService).onCommandExecuted(h=>{var p,v;const S=h.id;if(S!==m.SetTextRotationCommand.id&&S!==m.SetSelectionsOperation.id&&S!==m.SetWorksheetActiveOperation.id)return;const g=(p=o.getCurrentLastSelection())==null?void 0:p.primary;let f;if(g!=null){const C=i.getRange(g.startRow,g.startColumn);f=C==null?void 0:C.getTextRotation()}(f==null?void 0:f.v)===a.BooleanNumber.TRUE?r.next("v"):r.next((v=f&&f.a)!=null?v:t)}),l=(d=o.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const h=i.getRange(l.startRow,l.startColumn);c=h==null?void 0:h.getTextRotation()}return(c==null?void 0:c.v)===a.BooleanNumber.TRUE?r.next("v"):r.next((u=c&&c.a)!=null?u:t),s.dispose})),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Si(n){return new k.Observable(e=>e.next(!n.get(I.IClipboardInterfaceService).supportClipboard))}function Rn(n){return{id:je.name,commandId:je.id,type:I.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",disabled$:ee(n,{workbookTypes:[m.WorkbookCopyPermission],worksheetTypes:[m.WorksheetCopyPermission],rangeTypes:[m.RangeProtectionPermissionViewPoint]}),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Wr(n){return{id:Ge.name,commandId:Ge.id,type:I.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",disabled$:Si(n).pipe(k.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission],workbookTypes:[m.WorkbookEditablePermission]})),k.map(([o,e])=>o||e)),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const gi="sheet.menu.paste-special";function Lr(n){return{id:gi,type:I.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",hidden$:Yt(n,I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET))}}function Ur(n){return{id:Cn.id,type:I.MenuItemType.BUTTON,title:"rightClick.pasteValue",disabled$:Si(n).pipe(k.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellValuePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),k.map(([o,e])=>o||e)),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Br(n){return{id:In.id,type:I.MenuItemType.BUTTON,title:"rightClick.pasteFormat",disabled$:Si(n).pipe(k.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),k.map(([o,e])=>o||e)),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function xr(n){return{id:Bt.id,type:I.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",disabled$:Si(n).pipe(k.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),k.map(([o,e])=>o||e))}}function Fr(n){return{id:_n.id,type:I.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",disabled$:Si(n).pipe(k.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission,m.WorksheetSetRowStylePermission,m.WorksheetSetColumnStylePermission],workbookTypes:[m.WorkbookEditablePermission]})),k.map(([o,e])=>o||e)),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Pm(n){return{id:m.SetWorksheetRowIsAutoHeightCommand.id,type:I.MenuItemType.BUTTON,icon:"AutoHeight",title:"rightClick.fitContent",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Om(n){return{id:hi.id,type:I.MenuItemType.BUTTON,icon:"AutoWidth",title:"rightClick.fitContent",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Cl="sheet.menu.sheet-frozen";function Am(n){return{id:Cl,type:I.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const zr="sheet.header-menu.sheet-frozen";function Il(n){return{id:zr,type:I.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Xr(n){return{id:at.id,type:I.MenuItemType.BUTTON,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function km(n){return{id:di.id,type:I.MenuItemType.BUTTON,title:"rightClick.freezeRow",icon:"FreezeRowSingle",hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Dm(n){return{id:ui.id,type:I.MenuItemType.BUTTON,title:"rightClick.freezeCol",icon:"FreezeColumnSingle",hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Yr(n){return{id:m.CancelFrozenCommand.id,type:I.MenuItemType.BUTTON,title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle",hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Nm(n){return{id:oi.id,type:I.MenuItemType.BUTTON,icon:"Hide",title:"rightClick.hideSelectedRow",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Hm(n){return{id:ri.id,type:I.MenuItemType.BUTTON,icon:"Hide",title:"rightClick.hideSelectedColumn",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:I.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Vm(n){const o=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=[m.SetSelectionsOperation,m.SetRowHiddenMutation,m.SetRowVisibleMutation].map(r=>r.id);return{id:m.SetSelectedRowsVisibleCommand.id,type:I.MenuItemType.BUTTON,title:"rightClick.showHideRow",hidden$:Ee(o,!0,({worksheet:r})=>new k.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 S=h.startRow;S<=h.endRow;S++)if(!r.getRowRawVisible(S))return!0;return!1}))}const c=t.onCommandExecuted(d=>{i.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Wm(n){const o=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=[m.SetSelectionsOperation,m.SetColHiddenMutation,m.SetColVisibleMutation].map(r=>r.id);return{id:m.SetSelectedColsVisibleCommand.id,type:I.MenuItemType.BUTTON,title:"rightClick.showHideColumn",hidden$:Ee(o,!0,({worksheet:r})=>new k.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 S=h.startColumn;S<=h.endColumn;S++)if(!r.getColVisible(S))return!0;return!1})}const c=t.onCommandExecuted(d=>{i.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Lm(n){const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=0;return{id:m.SetRowHeightCommand.id,type:I.MenuItemType.BUTTON,icon:"AdjustHeight",label:{name:et,props:{prefix:"rightClick.rowHeight",suffix:"px",min:2,max:1e3}},value$:Ee(e,i,({worksheet:r})=>new k.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary,u=d?r.getRowHeight(d.startRow):i;s.next(u)}const c=o.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$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Um(n){const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=0;return{id:m.SetColWidthCommand.id,type:I.MenuItemType.BUTTON,icon:"AdjustWidth",label:{name:et,props:{prefix:"rightClick.columnWidth",suffix:"px",min:2,max:1e3}},value$:Ee(e,i,({worksheet:r})=>new k.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary;let u=i;d!=null&&(u=r.getColumnWidth(d.startColumn)),s.next(u)}const c=o.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$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function fi(n){var c;const o=n.get(a.IUniverInstanceService),e=n.get(we.DocSelectionManagerService),t=o.getUniverDocInstance(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),i=e.getActiveTextRange();if(t==null||i==null)return null;const r=(c=t.getBody())==null?void 0:c.textRuns;if(r==null)return;const{startOffset:s}=i;return r.find(({st:d,ed:u})=>s>=d&&s<=u)}var Bm=Object.getOwnPropertyDescriptor,xm=(n,o,e,t)=>{for(var i=t>1?void 0:t?Bm(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},jt=(n,o)=>(e,t)=>o(e,t,n);const Fm="__SpreadsheetFreezeRowMainName__",zm="__SpreadsheetFreezeRowHeaderName__",Xm="__SpreadsheetFreezeColumnMainName__",Ym="__SpreadsheetFreezeColumnHeaderName__",jr=2,jm=.01,pi=a.createInterceptorKey("freezePermissionCheck");y.HeaderFreezeRenderController=class extends a.Disposable{constructor(e,t,i,r,s,l,c,d){super();w(this,"_rowFreezeHeaderRect");w(this,"_rowFreezeMainRect");w(this,"_columnFreezeHeaderRect");w(this,"_columnFreezeMainRect");w(this,"_freezeDownSubs");w(this,"_freezePointerEnterSubs");w(this,"_freezePointerLeaveSubs");w(this,"_scenePointerMoveSub");w(this,"_scenePointerUpSub");w(this,"_changeToRow",-1);w(this,"_changeToColumn",-1);w(this,"_changeToOffsetX",0);w(this,"_changeToOffsetY",0);w(this,"_activeViewport",null);w(this,"_freezeNormalHeaderColor","");w(this,"_freezeNormalMainColor","");w(this,"_freezeActiveColor","");w(this,"_freezeHoverColor","");w(this,"_lastFreeze");w(this,"interceptor",new a.InterceptorManager({FREEZE_PERMISSION_CHECK:pi}));this._context=e,this._sheetSkeletonManagerService=t,this._commandService=i,this._selectionManagerService=r,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 A;const i=t!=null?t:this._getFreeze();if(i==null)return null;const r=(A=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:A.skeleton,{startRow:s,startColumn:l}=i,c=this._getPositionByIndex(s,l);if(c==null||r==null)return null;const d=this._getSheetObject(),u=d.engine,h=(u==null?void 0:u.width)||0,S=(u==null?void 0:u.height)||0,g=d.scene,{startX:f,startY:p}=c,{rowTotalHeight:v,columnTotalWidth:C,rowHeaderWidthAndMarginLeft:_,columnHeaderHeightAndMarginTop:E}=r,T=h>C+_?h:C+E,P=S>v+E?S:v+E;this._changeToRow=s,this._changeToColumn=l,this._changeToOffsetX=f,this._changeToOffsetY=p;const R=Math.max(g.scaleX,g.scaleY);let O=jr/Math.max(1,R);if(e===0){(s===-1||s===0)&&(O=O*2);const N=O;this._rowFreezeHeaderRect=new M.Rect(zm,{fill:this._freezeNormalHeaderColor,width:_,height:O,left:0,top:p-N,zIndex:3});let D=this._freezeNormalHeaderColor;(s===-1||s===0)&&(D=this._freezeNormalMainColor),this._rowFreezeMainRect=new M.Rect(Fm,{fill:D,width:T*2/R,height:O,left:_,top:p-N,zIndex:3}),g.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],ft)}else{(l===-1||l===0)&&(O=O*2);const N=O;this._columnFreezeHeaderRect=new M.Rect(Ym,{fill:this._freezeNormalHeaderColor,width:O,height:E,left:f-N,top:0,zIndex:3});let D=this._freezeNormalHeaderColor;(l===-1||l===0)&&(D=this._freezeNormalMainColor),this._columnFreezeMainRect=new M.Rect(Xm,{fill:D,width:O,height:P*2/R,left:f-N,top:E,zIndex:3}),g.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],ft)}this._eventBinding(e)}_eventBinding(e=0){let t=this._rowFreezeHeaderRect,i=this._rowFreezeMainRect;e===1&&(t=this._columnFreezeHeaderRect,i=this._columnFreezeMainRect);const r=this._getSheetObject();if(r==null)return;const{scene:s}=r;if(this._freezePointerEnterSubs=new k.Subscription,this._freezePointerLeaveSubs=new k.Subscription,this._freezeDownSubs=new k.Subscription,i){const d=i.onPointerEnter$.subscribeEvent(()=>{if(!this.interceptor.fetchThroughInterceptors(pi)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(M.CURSOR_TYPE.GRAB)});this._freezePointerEnterSubs.add(d);const u=i.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(pi)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(M.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,i,e)});l&&this._freezeDownSubs.add(l);const c=i==null?void 0:i.onPointerDown$.subscribeEvent(d=>{this._freezeDown(d,t,i,e)});c&&this._freezeDownSubs.add(c)}_getCurrentLastVisible(){var C,_,E,T,P,R,O;const e=this._getSheetObject();if(e==null)return;const t=(C=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:C.skeleton;if(t==null)return;const i=e.scene,r=Math.max(i.scaleX,i.scaleY),s=this._scrollManagerService.getCurrentScrollState(),l=(e.engine.height-t.columnHeaderHeight)/r,c=(e.engine.width-t.rowHeaderWidth)/r,d=(_=s==null?void 0:s.sheetViewStartRow)!=null?_:0,u=d===0?-((E=s==null?void 0:s.offsetY)!=null?E:0):t.rowHeightAccumulation[d-1]-((T=s==null?void 0:s.offsetY)!=null?T:0);let h=0,S=!1;for(let A=d,N=t.rowHeightAccumulation.length;A<N;A++)if(t.rowHeightAccumulation[A]-u>l){h=A,S=!0;break}S||(h=t.rowHeightAccumulation.length-1);const g=(P=s==null?void 0:s.sheetViewStartColumn)!=null?P:0,f=g===0?-((R=s==null?void 0:s.offsetX)!=null?R:0):t.columnWidthAccumulation[g-1]-((O=s==null?void 0:s.offsetX)!=null?O:0);let p=0,v=!1;for(let A=g,N=t.columnWidthAccumulation.length;A<N;A++)if(t.columnWidthAccumulation[A]-f>c){p=A,v=!0;break}return v||(p=t.columnWidthAccumulation.length-1),{lastRow:h,lastColumn:p}}_getActiveViewport(e){var i;const t=(i=this._getSheetObject())==null?void 0:i.scene.getViewports();return t&&t.find(r=>r.isHit(new M.Vector2(e.offsetX,e.offsetY)))||null}_freezeDown(e,t,i,r=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(pi)(!0,null))return!1;const{scene:d}=l;d.setCursor(M.CURSOR_TYPE.GRABBING),d.disableObjectsEvent();const u=this._getCurrentLastVisible(),h=u===void 0?Number.POSITIVE_INFINITY:s.rowHeightAccumulation[u.lastRow],S=u===void 0?Number.POSITIVE_INFINITY:s.columnWidthAccumulation[u.lastColumn-1]+s.rowHeaderWidth;this._activeViewport=null;const g=this._getFreeze();g&&(this._changeToColumn=g.startColumn,this._changeToRow=g.startRow),this._scenePointerMoveSub=d.onPointerMove$.subscribeEvent(p=>{var O,A,N,D;const v=this._getActiveViewport(p),{startX:C,startY:_,row:E,column:T}=qe(p.offsetX,p.offsetY,d,s,v||void 0,!0);if(!this.interceptor.fetchThroughInterceptors(pi)(!0,null))return!1;d.setCursor(M.CURSOR_TYPE.GRABBING);const R=jr/Math.max(d.scaleX,d.scaleY);r===0?((O=t.transformByState({top:Math.min(_,h)-R/2}))==null||O.setProps({fill:this._freezeActiveColor}),(A=i.transformByState({top:Math.min(_,h)-R/2}))==null||A.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=u===void 0?E:Math.min(E,u.lastRow),this._changeToOffsetY=Math.min(_,h),this._activeViewport=v):((N=t.transformByState({left:Math.min(C,S)-R/2}))==null||N.setProps({fill:this._freezeActiveColor}),(D=i.transformByState({left:Math.min(C,S)-R/2}))==null||D.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=u===void 0?T:Math.min(T,u.lastColumn),this._changeToOffsetX=C,this._activeViewport=v)}),this._scenePointerUpSub=d.onPointerUp$.subscribeEvent(()=>{var H,W;d.resetCursor(),d.enableObjectsEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:p,columnHeaderHeightAndMarginTop:v}=s;r===0&&(this._changeToRow===0||this._changeToRow===-1)||r===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(t.setProps({fill:this._freezeNormalHeaderColor}),i.setProps({fill:this._freezeNormalMainColor})):(t==null||t.setProps({fill:this._freezeNormalHeaderColor}),i==null||i.setProps({fill:this._freezeNormalHeaderColor}));const C=jr/Math.max(d.scaleX,d.scaleY);r===0?(this._changeToRow===0||this._changeToRow===-1)&&(t.transformByState({top:v-C}),i.transformByState({top:v-C})):(this._changeToColumn===0||this._changeToColumn===-1)&&(t.transformByState({left:p-C}),i.transformByState({left:p-C}));const _=this._scrollManagerService.getCurrentScrollState()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:E,sheetViewStartColumn:T}=_;if(T==null||E==null)return;const P=this._context.unit,R=P.getActiveSheet();if(!R)return;const O=(H=R.getConfig())==null?void 0:H.freeze;let A=(O==null?void 0:O.xSplit)||0,N=(O==null?void 0:O.ySplit)||0;const D=(W=this._activeViewport)==null?void 0:W.viewportKey;r===0&&(!D||D===M.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||D===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||D===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP||D===M.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP?N=this._changeToRow-(O.startRow-O.ySplit):N=this._changeToRow-E,N=N<0?0:N),r===1&&(!D||D===M.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||D===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||D===M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT||D===M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT?A=this._changeToColumn-(O.startColumn-O.xSplit):A=this._changeToColumn-T,A=A<0?0:A),this._commandService.executeCommand(m.SetFrozenCommand.id,{startRow:N===0?-1:this._changeToRow,startColumn:A===0?-1:this._changeToColumn,ySplit:N,xSplit:A,unitId:P.getUnitId(),subUnitId:R.getSheetId()})})}_getViewports(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e,i=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT),r=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT),s=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP),l=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM),c=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP),d=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN),u=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP),h=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT),S=t.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(!(i==null||r==null||s==null||l==null||c==null||d==null||u==null||h==null||S==null))return{viewMain:d,viewMainLeftTop:u,viewMainLeft:h,viewMainTop:S,viewColumnLeft:i,viewColumnRight:r,viewRowTop:s,viewRowBottom:l,viewLeftTop:c}}_bindViewportScroll(){const e=this._getViewports();if(!e)return;const{viewRowBottom:t,viewColumnRight:i,viewMainLeft:r,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}),i.isActive&&i.updateScrollVal({scrollX:c,viewportScrollX:u}),r.isActive&&r.updateScrollVal({scrollY:d,viewportScrollY:h}),s.isActive&&s.updateScrollVal({scrollX:c,viewportScrollX:u})}))}_updateViewport(e=-1,t=-1,i=0,r=0,s=3){var A;const l=(A=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:A.skeleton;if(l==null)return;const{rowHeaderWidthAndMarginLeft:c,columnHeaderHeightAndMarginTop:d}=l,u=this._getViewports();if(!u)return;const{viewMain:h,viewMainLeftTop:S,viewMainLeft:g,viewMainTop:f,viewColumnLeft:p,viewColumnRight:v,viewRowTop:C,viewRowBottom:_,viewLeftTop:E}=u;v.resizeWhenFreezeChange({left:c,top:0,height:d+1,right:0}),_.resizeWhenFreezeChange({left:0,top:d,bottom:0,width:c+1}),E.resizeWhenFreezeChange({left:0,top:0,width:c+1,height:d});let T=!0,P=!0;S.enable(),(e===-1||e===0)&&(T=!1),(t===-1||t===0)&&(P=!1);const R=l.getNoMergeCellWithCoordByIndex(e-i,t-r,!1),O=l.getNoMergeCellWithCoordByIndex(e,t,!1);if(S.disable(),f.disable(),g.disable(),C.disable(),p.disable(),S.resetPadding(),f.resetPadding(),g.resetPadding(),C.resetPadding(),p.resetPadding(),T===!1&&P===!1)h.resizeWhenFreezeChange({left:c,top:d,bottom:0,right:0}),h.resetPadding(),g.resizeWhenFreezeChange({left:c,top:d,bottom:0,width:0}),f.resizeWhenFreezeChange({left:c,top:d,height:0,right:0}),S.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(T===!0&&P===!1){const N=O.startY-R.startY;h.resizeWhenFreezeChange({left:c,top:d+N,bottom:0,right:0}),h.setPadding({startY:R.startY,endY:O.startY,startX:0,endX:0}),s&2&&this._commandService.executeCommand(Ye.id,{sheetViewStartRow:0,offsetY:0}),f.resizeWhenFreezeChange({left:c,top:d,height:N,right:0}),f.updateScrollVal({viewportScrollY:R.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:N}),C.updateScrollVal({viewportScrollY:R.startY}),_.resizeWhenFreezeChange({left:0,top:d+N,bottom:0,width:c+1}),f.enable(),C.enable()}else if(T===!1&&P===!0){const N=O.startX-R.startX;h.resizeWhenFreezeChange({left:c+N,top:d,bottom:0,right:0}),h.setPadding({startX:R.startX,endX:O.startX,startY:0,endY:0}),s&1&&this._commandService.executeCommand(Ye.id,{sheetViewStartColumn:0,offsetX:0}),g.resizeWhenFreezeChange({left:c,top:d,width:N,bottom:0,right:0}),g.updateScrollVal({viewportScrollX:R.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),p.resizeWhenFreezeChange({left:c,top:0,width:N,height:d+1}),p.updateScrollVal({viewportScrollX:R.startX}),v.resizeWhenFreezeChange({left:c+N,top:0,height:d+1,right:0}),g.enable(),p.enable()}else{const N=O.startX-R.startX,D=O.startY-R.startY;h.resizeWhenFreezeChange({left:c+N,top:d+D,bottom:0,right:0}),h.setPadding({startY:R.startY,endY:O.startY,startX:R.startX,endX:O.startX}),s&&this._commandService.executeCommand(Ye.id,{...s&1?{sheetViewStartColumn:0,offsetX:0}:null,...s&2?{sheetViewStartRow:0,offsetY:0}:null}),g.resizeWhenFreezeChange({left:c,top:d+D,width:N,bottom:0}),g.updateScrollVal({viewportScrollX:R.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),f.resizeWhenFreezeChange({left:c+N,top:d,height:D,right:0}),f.updateScrollVal({viewportScrollY:R.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),S.resizeWhenFreezeChange({left:c,top:d,width:N,height:D}),S.updateScrollVal({viewportScrollX:R.startX,viewportScrollY:R.startY}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:D}),C.updateScrollVal({viewportScrollY:R.startY}),_.resizeWhenFreezeChange({left:0,top:d+D,bottom:0,width:c+1}),p.resizeWhenFreezeChange({left:c,top:0,width:N,height:d+1}),p.updateScrollVal({viewportScrollX:R.startX}),v.resizeWhenFreezeChange({left:c+N,top:0,height:d+1,right:0}),S.enable(),f.enable(),g.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 i=t.getConfig().freeze,{startRow:r=-1,startColumn:s=-1,ySplit:l=0,xSplit:c=0}=i;this._refreshFreeze(r,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(jm).toRgbString(),this._freezeActiveColor=e.primaryColor,this._freezeHoverColor=e.grey500}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{const t={redos:[],undos:[]},i=this._getFreeze();if(!i)return t;const r=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},S=m.SetFrozenMutationFactory(this._injector,h);return{undos:[{id:m.SetFrozenMutation.id,params:S}],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<i.startRow||l.startRow+1===i.startRow&&c===a.Direction.UP){const u={...i,startRow:Math.max(1,i.startRow+d),ySplit:Math.max(1,i.ySplit+d)};return r(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<i.startColumn||l.startColumn+1===i.startColumn&&c===a.Direction.LEFT){const u={...i,startColumn:Math.max(1,i.startColumn+d),xSplit:Math.max(1,i.xSplit+d)};return r(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(!i||i.startColumn<=0||u.startColumn>=i.startColumn&&h.startColumn>=i.startColumn||u.startColumn===h.startColumn||u.endColumn<i.startColumn&&h.startColumn<i.startColumn)return t;const S=u.endColumn-u.startColumn+1,g=Math.max(Math.min(i.startColumn,u.endColumn+1)-u.startColumn,0);let f,p;h.startColumn>=i.startColumn?(f=Math.max(i.startColumn-g,1),p=Math.max(i.xSplit-g,1)):(f=i.startColumn+S-g,p=i.xSplit+S-g);const v={...i,startColumn:f,xSplit:p};return r(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(!i||i.startRow<=0||u.startRow>=i.startRow&&h.startRow>=i.startRow||u.startRow===h.startRow||u.endRow<i.startRow&&h.startRow<i.startRow)return t;const S=u.endRow-u.startRow+1,g=Math.max(Math.min(i.startRow,u.endRow+1)-u.startRow,0);let f,p;h.startRow>=i.startRow?(f=Math.max(i.startRow-g,1),p=Math.max(i.ySplit-g,1)):(f=i.startRow+S-g,p=i.ySplit+S-g);const v={...i,startRow:f,ySplit:p};return r(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<i.startColumn){const c=Math.min(i.startColumn,l.endColumn+1)-l.startColumn,d={...i,startColumn:Math.max(1,i.startColumn-c),xSplit:Math.max(1,i.xSplit-c)};return r(d)}if(s.range.rangeType===a.RANGE_TYPE.ROW&&l.startRow<i.startRow){const c=Math.min(i.startRow,l.endRow+1)-l.startRow,d={...i,startRow:Math.max(1,i.startRow-c),ySplit:Math.max(1,i.ySplit-c)};return r(d)}}return t}}))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{switch(e.id){case m.SetFrozenMutation.id:case Le.id:{const t=this._lastFreeze,i=this._context.unit,r=i.getActiveSheet(),s=e.params,{unitId:l,subUnitId:c}=s;if(!(l===i.getUnitId()&&c===(r==null?void 0:r.getSheetId())))return;const d=r.getConfig().freeze;if(this._lastFreeze=d,d==null)return;let u=0;const{startRow:h=-1,startColumn:S=-1,ySplit:g=0,xSplit:f=0}=d;(!t||t.startRow!==h||t.ySplit!==g)&&(u|=2),(!t||t.startColumn!==S||t.xSplit!==f)&&(u|=1),s.resetScroll===!1&&(u=0),this._refreshFreeze(h,S,g,f,u)}break;case m.SetWorksheetRowHeightMutation.id:{const t=this._getFreeze(),i=t&&e.params.ranges.some(r=>r.startRow<t.startRow);e.params&&i&&this._refreshCurrent()}break;case m.SetWorksheetColWidthMutation.id:{const t=this._getFreeze();e.params&&t&&e.params.ranges.some(i=>i.startColumn<t.startColumn)&&this._refreshCurrent()}break;case m.SetWorksheetRowAutoHeightMutation.id:{const t=e.params,i=this._getFreeze();if(i&&i.startRow>-1&&t.rowsAutoHeightInfo.some(r=>r.row<i.startRow)){const r=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{r.unsubscribe()})})}}break;case m.SetColHiddenMutation.id:case m.SetColVisibleMutation.id:{const t=e.params,i=this._getFreeze(),r=t.ranges;i&&i.startColumn>-1&&r.some(s=>s.startColumn<i.startColumn)&&this._refreshCurrent()}break;case m.SetRowHiddenMutation.id:case m.SetRowVisibleMutation.id:{const t=e.params,i=this._getFreeze(),r=t.ranges;i&&i.startRow>-1&&r.some(s=>s.startRow<i.startRow)&&this._refreshCurrent()}break;case xi.id:case Fi.id:this._refreshCurrent()}}))}_zoomRefresh(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this.disposeWithMe(t.onTransformChange$.subscribeEvent(i=>{[M.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale,M.TRANSFORM_CHANGE_OBSERVABLE_TYPE.all].includes(i.type)&&this._refreshCurrent()}))}_clearObserverEvent(){var t,i;this._getSheetObject()!=null&&((t=this._scenePointerMoveSub)==null||t.unsubscribe(),(i=this._scenePointerUpSub)==null||i.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null)}_clearFreeze(){var t,i,r,s,l,c;(t=this._rowFreezeHeaderRect)==null||t.dispose(),(i=this._rowFreezeMainRect)==null||i.dispose(),(r=this._columnFreezeHeaderRect)==null||r.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 r=(d=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:d.skeleton,s=r==null?void 0:r.getNoMergeCellWithCoordByIndex(e,t);if(r==null)return;if(s!=null&&(!isNaN(s.endX)||!isNaN(s.endY)))return s;const{rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:c}=r;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 ze(this._context.unit,this._context)}_refreshFreeze(e,t,i,r,s){var c;const l={startRow:e,startColumn:t,ySplit:i,xSplit:r};this._clearFreeze(),this._createFreeze(0,l),this._createFreeze(1,l),this._updateViewport(e,t,i,r,s),(c=this._getSheetObject())==null||c.spreadsheet.makeForceDirty()}},y.HeaderFreezeRenderController=xm([jt(1,a.Inject(y.SheetSkeletonManagerService)),jt(2,a.ICommandService),jt(3,a.Inject(m.SheetsSelectionsService)),jt(4,a.Inject(y.SheetScrollManagerService)),jt(5,a.Inject(a.ThemeService)),jt(6,a.Inject(m.SheetInterceptorService)),jt(7,a.Inject(a.Injector))],y.HeaderFreezeRenderController);function Gm(n){const o=n.get(m.SheetsSelectionsService),e=n.get(m.RangeProtectionRuleModel),t=n.get(a.IUniverInstanceService),i=n.get(m.MergeCellController),r=t.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET);return k.combineLatest([o.selectionMoveEnd$,r.pipe(k.map(s=>{var l;return(l=s==null?void 0:s.getUnitId())!=null?l:""})),r.pipe(k.switchMap(s=>{var l;return(l=s==null?void 0:s.activeSheet$)!=null?l:k.of(null)}))]).pipe(k.map(([s,l,c])=>{if(!c||!s||s.length===0)return!1;const d=c.getSheetId(),u=s.map(g=>g.range);if(i.interceptor.fetchThroughInterceptors(m.MERGE_CELL_INTERCEPTOR_CHECK)(!1,u))return!0;const S=e.getSubunitRuleList(l,d).map(g=>g.ranges).flat();if(s.length<2){const g=s[0].range;return S.some(p=>a.Rectangle.intersects(p,g)&&!a.Rectangle.contains(p,g))}for(let g=0;g<s.length;g++)for(let f=g+1;f<s.length;f++)if(a.Rectangle.intersects(s[g].range,s[f].range))return!0;return!1}))}function _l(n,o){return!!vi(n,o,a.RANGE_TYPE.ROW)}function bl(n,o){return!!vi(n,o,a.RANGE_TYPE.COLUMN)}function vi(n,o,e){return n.find(i=>{const r=i.range,{startRow:s,endRow:l,startColumn:c,endColumn:d,rangeType:u}=r;return u===a.RANGE_TYPE.ALL||u===a.RANGE_TYPE.NORMAL?!1:u===e&&(e===a.RANGE_TYPE.COLUMN&&c<=o&&o<=d||e===a.RANGE_TYPE.ROW&&s<=o&&o<=l)})}var Zm=Object.getOwnPropertyDescriptor,Km=(n,o,e,t)=>{for(var i=t>1?void 0:t?Zm(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},Gr=(n,o)=>(e,t)=>o(e,t,n);const qm="__SpreadsheetHeaderMoveControllerBackground__",Qm="__SpreadsheetHeaderMoveControllerShapeLine__",Jm="rgba(0, 0, 0, 0.1)",$m="rgb(119, 119, 119)",eS=4,Zr=a.createInterceptorKey("headerMovePermissionCheck");y.HeaderMoveRenderController=class extends a.Disposable{constructor(e,t,i,r){super();w(this,"_startOffsetX",Number.NEGATIVE_INFINITY);w(this,"_startOffsetY",Number.NEGATIVE_INFINITY);w(this,"_moveHelperBackgroundShape");w(this,"_moveHelperLineShape");w(this,"_headerPointerDownSubs");w(this,"_headerPointerMoveSubs");w(this,"_headerPointerLeaveSubs");w(this,"_dragHeaderMoveSub");w(this,"_scenePointerUpSub");w(this,"_scrollTimer");w(this,"_changeFromColumn",-1);w(this,"_changeFromRow",-1);w(this,"_changeToColumn",-1);w(this,"_changeToRow",-1);w(this,"interceptor",new a.InterceptorManager({HEADER_MOVE_PERMISSION_CHECK:Zr}));w(this,"_workbookSelections");this._context=e,this._sheetSkeletonManagerService=i,this._commandService=r,this._workbookSelections=t.getWorkbookSelections(this._context.unitId),this._init()}dispose(){var e,t,i,r,s,l,c,d;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose(),(i=this._headerPointerMoveSubs)==null||i.unsubscribe(),(r=this._headerPointerLeaveSubs)==null||r.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),i=this._context.components.get(he.ROW),r=this._context.scene,s=e===a.RANGE_TYPE.ROW?i:t,l=u=>{var _,E;const h=(_=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:_.skeleton;if(h==null)return;const S=(E=this._workbookSelections.getCurrentLastSelection())==null?void 0:E.range;if(!S||!this.interceptor.fetchThroughInterceptors(Zr)(!1,S))return;const f=this._workbookSelections.getCurrentSelections(),{row:p,column:v}=qe(u.offsetX,u.offsetY,r,h);if(!vi(f,e===a.RANGE_TYPE.ROW?p:v,e)){r.resetCursor();return}r.setCursor(M.CURSOR_TYPE.GRAB)},c=()=>{var u,h;(u=this._moveHelperBackgroundShape)==null||u.hide(),(h=this._moveHelperLineShape)==null||h.hide(),r.resetCursor()},d=(u,h)=>{var U,V;if(h.isStopPropagation)return;const S=(U=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:U.skeleton;if(S==null)return;const g=(V=this._workbookSelections.getCurrentLastSelection())==null?void 0:V.range;if(!g||!this.interceptor.fetchThroughInterceptors(Zr)(!1,g))return;const{offsetX:p,offsetY:v}=u,C=r.getCoordRelativeToViewport(M.Vector2.FromArray([p,v])),{x:_,y:E}=C;this._startOffsetX=_,this._startOffsetY=E;const{row:T,column:P}=qe(u.offsetX,u.offsetY,r,S);let R;e===a.RANGE_TYPE.ROW?(this._changeFromRow=T,R=M.ScrollTimerType.Y):(this._changeFromColumn=P,R=M.ScrollTimerType.X);const O=this._workbookSelections.getCurrentSelections(),A=vi(O,e===a.RANGE_TYPE.ROW?T:P,e);if(!A)return;const N=r.getScrollXYInfoByViewport(M.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),r.setCursor(M.CURSOR_TYPE.GRABBING),r.disableObjectsEvent();let D=!1,H;const W=()=>{if(D)return;H=M.ScrollTimer.create(r,R),this._scrollTimer=H;const B=r.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN);H.startScroll(_,E,B),D=!0};this._dragHeaderMoveSub=r.onPointerMove$.subscribeEvent(B=>{W();const{offsetX:x,offsetY:z}=B,{x:F,y:Y}=r.getCoordRelativeToViewport(M.Vector2.FromArray([x,z]));this._rowColumnMoving(F,Y,A,N,e),H.scrolling(F,Y,()=>{this._rowColumnMoving(F,Y,A,N,e)})}),this._scenePointerUpSub=r.onPointerUp$.subscribeEvent(()=>{var x,z,F;this._disposeBackgroundAndLine(),r.resetCursor(),r.enableObjectsEvent(),this._clearObserverEvent(),(x=this._scrollTimer)==null||x.dispose();const B=this._workbookSelections.getCurrentSelections();if(e===a.RANGE_TYPE.ROW){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const X=(z=((B==null?void 0:B.filter(Z=>Z.range.rangeType===a.RANGE_TYPE.ROW&&Z.range.startRow<=this._changeFromRow&&this._changeFromRow<=Z.range.endRow))||[])[0])==null?void 0:z.range;X&&this._commandService.executeCommand(m.MoveRowsCommand.id,{fromRange:X,toRange:{...X,startRow:this._changeToRow,endRow:this._changeToRow+X.endRow-X.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const X=(F=((B==null?void 0:B.filter(Z=>Z.range.rangeType===a.RANGE_TYPE.COLUMN&&Z.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=Z.range.endColumn))||[])[0])==null?void 0:F.range;X&&this._commandService.executeCommand(m.MoveColsCommand.id,{fromRange:X,toRange:{...X,startColumn:this._changeToColumn,endColumn:this._changeToColumn+X.endColumn-X.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})};this._headerPointerMoveSubs=new k.Subscription,this._headerPointerMoveSubs.add(s.onPointerMove$.subscribeEvent(l)),this._headerPointerLeaveSubs=new k.Subscription,this._headerPointerLeaveSubs.add(s==null?void 0:s.onPointerLeave$.subscribeEvent(c)),this._headerPointerDownSubs=new k.Subscription,this._headerPointerDownSubs.add(s==null?void 0:s.onPointerDown$.subscribeEvent(d))}_rowColumnMoving(e,t,i,r,s){var Y,X,Z,ne,J,ae,ue;const l=this._context.scene,c=(Y=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:Y.skeleton;if(c==null)return;const{rowHeaderWidth:d,columnHeaderHeight:u,rowTotalHeight:h,columnTotalWidth:S}=c,g=l.getViewportScrollXY(l.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN)),{scaleX:f,scaleY:p}=l.getAncestorScale(),v=c.getCellIndexByOffset(e,t,f,p,g),{row:C,column:_}=v,E=c.getNoMergeCellWithCoordByIndex(C,_),{startX:T,startY:P,endX:R,endY:O}=E,A=this._sheetSkeletonManagerService.attachRangeWithCoord(i.range);if(A==null)return;const N=Math.max(f,f),{startX:D,endX:H,startY:W,endY:U,startRow:V,startColumn:B,endRow:x,endColumn:z}=A;s===a.RANGE_TYPE.ROW?(X=this._moveHelperBackgroundShape)==null||X.transformByState({height:U-W,width:S+d,left:0,top:W+(t-this._startOffsetY)/N+g.y-r.y}):(Z=this._moveHelperBackgroundShape)==null||Z.transformByState({height:h+u,width:H-D,left:D+(e-this._startOffsetX)/N+g.x-r.x,top:0}),(ne=this._moveHelperBackgroundShape)==null||ne.show();const F=eS/N;if(s===a.RANGE_TYPE.ROW){let j=0;if(C<=V)j=P-F/2,this._changeToRow=C;else if(C>x)j=O-F/2,this._changeToRow=C+1;else return;(J=this._moveHelperLineShape)==null||J.transformByState({height:F,width:S,left:d,top:j})}else{let j=0;if(_<=B)j=T-F/2,this._changeToColumn=_;else if(_>z)j=R-F/2,this._changeToColumn=_+1;else return;(ae=this._moveHelperLineShape)==null||ae.transformByState({height:h,width:F,left:j,top:u})}(ue=this._moveHelperLineShape)==null||ue.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 M.Rect(qm,{fill:Jm,evented:!1,zIndex:100}),this._moveHelperLineShape=new M.Rect(Qm,{fill:$m,evented:!1,zIndex:100}),e.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],ft)}_disposeBackgroundAndLine(){var e,t;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose()}},y.HeaderMoveRenderController=Km([Gr(1,a.Inject(m.SheetsSelectionsService)),Gr(2,a.Inject(y.SheetSkeletonManagerService)),Gr(3,a.ICommandService)],y.HeaderMoveRenderController);var Kr=(n=>(n[n.VERTICAL=0]="VERTICAL",n[n.HORIZONTAL=1]="HORIZONTAL",n))(Kr||{});const tS="rgba(120, 120, 120, 0.01)",qr="rgb(68, 71, 70)",Ci=12,nS=44,Qr=4;class El extends M.Shape{constructor(e,t){super(e,t);w(this,"_size",Ci);w(this,"_color",qr);w(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:i,scaleY:r}=t.getAncestorScale(),s=Math.max(i,r),l=Ci/s,c=Qr/s;let{width:d,height:u}=this,h=0,S=0;this.mode===0?(d=c,h=l-c):(u=c,S=l-c),M.Rect.drawWith(e,{width:this.width,height:this.height,left:0,top:0,fill:tS}),M.Rect.drawWith(e,{width:d,height:u,fill:qr,radius:c}),e.save(),e.transform(1,0,0,1,h,S),M.Rect.drawWith(e,{width:d,height:u,fill:qr,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:Ci,height:this.size}):this.transformByState({width:this.size,height:Ci}),this}}var iS=Object.getOwnPropertyDescriptor,oS=(n,o,e,t)=>{for(var i=t>1?void 0:t?iS(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},Jr=(n,o)=>(e,t)=>o(e,t,n);const rS="__SpreadsheetHeaderResizeControllerShapeRow__",sS="__SpreadsheetHeaderResizeControllerShapeColumn__",wl="__SpreadsheetHeaderResizeControllerShapeHelper__",Tl="rgb(199, 199, 199)",aS=2,$r=a.createInterceptorKey("headerResizePermissionCheck");y.HeaderResizeRenderController=class extends a.Disposable{constructor(e,t,i,r){super();w(this,"_currentRow",0);w(this,"_currentColumn",0);w(this,"_rowResizeRect");w(this,"_columnResizeRect");w(this,"_headerPointerSubs");w(this,"_scenePointerMoveSub");w(this,"_scenePointerUpSub");w(this,"_resizeHelperShape");w(this,"_startOffsetX",Number.POSITIVE_INFINITY);w(this,"_startOffsetY",Number.POSITIVE_INFINITY);w(this,"interceptor",new a.InterceptorManager({HEADER_RESIZE_PERMISSION_CHECK:$r}));this._context=e,this._sheetSkeletonManagerService=t,this._selectionManagerService=i,this._commandService=r,this._init()}dispose(){var e,t,i;(e=this._rowResizeRect)==null||e.dispose(),this._rowResizeRect=null,(t=this._columnResizeRect)==null||t.dispose(),this._columnResizeRect=null,(i=this._headerPointerSubs)==null||i.unsubscribe(),this._headerPointerSubs=null}_init(){const e=this._context.scene;this._rowResizeRect=new El(rS,{visible:!1,mode:Kr.HORIZONTAL,zIndex:100}),this._columnResizeRect=new El(sS,{visible:!1,mode:Kr.VERTICAL,zIndex:100}),e.addObjects([this._rowResizeRect,this._columnResizeRect],ft),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(e=0){const t=this._context.components.get(he.COLUMN),i=this._context.components.get(he.ROW),r=this._context.scene,s=e===0?i:t,l=(d,u)=>{var h,S;(h=this._rowResizeRect)==null||h.hide(),(S=this._columnResizeRect)==null||S.hide()},c=(d,u)=>{var N;const h=(N=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:N.skeleton;if(h==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:S,columnHeaderHeight:g}=h,{startX:f,startY:p,endX:v,endY:C,row:_,column:E}=qe(d.offsetX,d.offsetY,r,h),T=Gn(d.offsetX,d.offsetY,r),{scaleX:P,scaleY:R}=r.getAncestorScale(),O=Math.max(P,R),A=Ci/O;if(e===0){let D=p-A/2;if(T.y<=p+A/2&&T.y>=p)this._currentRow=_-1;else if(T.y>=C-A/2&&T.y<=C)this._currentRow=_,D=C-A/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;if(!this.interceptor.fetchThroughInterceptors($r)(null,{row:this._currentRow}))return!1;const W=Math.min(nS,S/3);this._rowResizeRect.transformByState({left:S/2-W/2,top:D}),this._rowResizeRect.setShapeProps({size:W}),this._rowResizeRect.show()}else{let D=f-A/2;if(T.x<=f+A/2&&T.x>=f)this._currentColumn=E-1;else if(T.x>=v-A/2&&T.x<=v)this._currentColumn=E,D=v-A/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;if(!this.interceptor.fetchThroughInterceptors($r)(null,{col:this._currentColumn}))return!1;const W=g*.7;this._columnResizeRect.transformByState({left:D,top:g/2-W/2}),this._columnResizeRect.setShapeProps({size:W}),this._columnResizeRect.show()}};this._headerPointerSubs=new k.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,i=e===0?this._rowResizeRect:this._columnResizeRect;i!=null&&(this.disposeWithMe(i.onPointerEnter$.subscribeEvent(()=>{i!=null&&(i.show(),t.setCursor(e===0?M.CURSOR_TYPE.ROW_RESIZE:M.CURSOR_TYPE.COLUMN_RESIZE))})),this.disposeWithMe(i.onPointerLeave$.subscribeEvent(()=>{i!=null&&(i.hide(),t.resetCursor())})),this.disposeWithMe(i.onPointerDown$.subscribeEvent(r=>{var z,F,Y,X,Z,ne,J;const s=(z=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:z.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(M.SHEET_VIEWPORT_KEY.VIEW_MAIN),S=(((Y=(F=h==null?void 0:h.getScrollBar())==null?void 0:F.horizonScrollTrack)==null?void 0:Y.height)||0)+10,g=(((Z=(X=h==null?void 0:h.getScrollBar())==null?void 0:X.verticalScrollTrack)==null?void 0:Z.width)||0)+10,f=Gn(r.offsetX,r.offsetY,l),{scaleX:p,scaleY:v}=l.getAncestorScale();this._startOffsetX=f.x,this._startOffsetY=f.y;const C=s.getOffsetByColumn(this._currentColumn),_=s.getOffsetByRow(this._currentRow),E=s.getNoMergeCellWithCoordByIndex(this._currentRow,this._currentColumn);let T=!1,P=0,R=0;const{columnTotalWidth:O,rowHeaderWidth:A,rowTotalHeight:N,columnHeaderHeight:D}=s,H=u>O+A?u:O+A,W=d>N+D?d:N+D,U=Math.max(p,v),V=Qr/U;e===0?this._resizeHelperShape=new M.Rect(wl,{width:H,height:V,fill:Tl,left:0,top:_-V/2}):this._resizeHelperShape=new M.Rect(wl,{width:V,height:W,fill:Tl,left:C-V/2,top:0});const B=((ne=this._columnResizeRect)==null?void 0:ne.left)||0,x=((J=this._rowResizeRect)==null?void 0:J.top)||0;l.addObject(this._resizeHelperShape,ft),l.disableObjectsEvent(),this._scenePointerMoveSub=l.onPointerMove$.subscribeEvent(ae=>{var pe,Me,ye,Ze,Rt,Pt;const ue=l.getCoordRelativeToViewport(M.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),j=l.getScrollXYInfoByViewport(ue,h),K=Gn(ae.offsetX,ae.offsetY,l),{x:$,y:oe}=K,{scaleX:re,scaleY:le}=l.getAncestorScale(),se=Math.max(re,le),ie=Qr/se;P=$-this._startOffsetX-ie/2,R=oe-this._startOffsetY-ie/2,Math.abs(e===0?R:P)>=aS&&(T=!0),e===0?(R>d-S+j.y-E.startY&&(R=d-S+j.y-E.startY),R<-(E.endY-E.startY)+2&&(R=-(E.endY-E.startY)+2),T&&((pe=this._resizeHelperShape)==null||pe.transformByState({top:_+R}),(Me=this._rowResizeRect)==null||Me.transformByState({top:x+R+ie/2}),(ye=this._rowResizeRect)==null||ye.show(),l.setCursor(M.CURSOR_TYPE.ROW_RESIZE))):(P>u-g+j.x-E.startX&&(P=u-g+j.x-E.startX),P<-(E.endX-E.startX)+2&&(P=-(E.endX-E.startX)+2),T&&((Ze=this._resizeHelperShape)==null||Ze.transformByState({left:C+P}),(Rt=this._columnResizeRect)==null||Rt.transformByState({left:B+P+ie/2}),(Pt=this._columnResizeRect)==null||Pt.show(),l.setCursor(M.CURSOR_TYPE.COLUMN_RESIZE)))}),this._scenePointerUpSub=l.onPointerUp$.subscribeEvent(ae=>{var j,K,$;const ue=this._context.scene;this._clearObserverEvent(),(j=this._resizeHelperShape)==null||j.dispose(),this._resizeHelperShape=null,ue.enableObjectsEvent(),T&&(ue.resetCursor(),(K=this._rowResizeRect)==null||K.hide(),($=this._columnResizeRect)==null||$.hide(),e===0?this._commandService.executeCommand(m.DeltaRowHeightCommand.id,{deltaY:R,anchorRow:this._currentRow}):this._commandService.executeCommand(m.DeltaColumnWidthCommand.id,{deltaX:P,anchorCol:this._currentColumn}))})})),this.disposeWithMe(i.onDblclick$.subscribeEvent(()=>{var h,S,g;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(hi.id,{ranges:p}),(S=this._columnResizeRect)==null||S.hide();break}case 0:this._commandService.executeCommand(m.SetWorksheetRowIsAutoHeightCommand.id,{ranges:[{startRow:this._currentRow,endRow:this._currentRow,startColumn:c,endColumn:u}]}),(g=this._rowResizeRect)==null||g.hide();break}})))}_clearObserverEvent(){var e,t;(e=this._scenePointerMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null}},y.HeaderResizeRenderController=oS([Jr(1,a.Inject(y.SheetSkeletonManagerService)),Jr(2,a.Inject(m.SheetsSelectionsService)),Jr(3,a.ICommandService)],y.HeaderResizeRenderController);var lS=Object.getOwnPropertyDescriptor,cS=(n,o,e,t)=>{for(var i=t>1?void 0:t?lS(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},Ii=(n,o)=>(e,t)=>o(e,t,n);const dS=60;y.SheetRenderController=class extends a.RxDisposable{constructor(e,t,i,r,s,l){super();w(this,"_renderMetric$",new k.Subject);w(this,"renderMetric$",this._renderMetric$.asObservable());w(this,"_renderFrameTimeMetric",null);w(this,"_renderFrameTags",{});w(this,"_afterRenderMetric$",new k.Subject);this._context=e,this._configService=t,this._sheetSkeletonManagerService=i,this._sheetRenderService=r,this._commandService=s,this._telemetryService=l,this._addNewRender(),this._initRenderMetricSubscriber()}_addNewRender(){const{scene:e,engine:t,unit:i}=this._context;this._addComponent(i),this._initRerenderScheduler(),this._initCommandListener();const r=this._context.unit.getActiveSheet();if(!r)throw new Error("No active sheet found");const s=r.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(r=>r.startsWith(M.SHEET_EXTENSION_PREFIX)).length>0&&this._afterRenderMetric$.next({frameTimeMetric:this._renderFrameTimeMetric,tags:this._renderFrameTags})}),e.renderFrameTimeMetric$.subscribe(([i,r])=>{this._renderFrameTimeMetric||(this._renderFrameTimeMetric={}),this._renderFrameTimeMetric[i]||(this._renderFrameTimeMetric[i]=[]),this._renderFrameTimeMetric[i].push(Math.round(r*100)/100)}),e.renderFrameTags$.subscribe(([i,r])=>{this._renderFrameTags[i]=r});const t=[];this._afterRenderMetric$.pipe(k.withLatestFrom(e.endFrame$)).subscribe(([i,r])=>{t.push({FPS:r.FPS,elapsedTime:r.elapsedTime,frameTime:Math.round(r.frameTime*100)/100,...i.frameTimeMetric,...i.tags}),t.length>dS&&(this._captureRenderMetric(t),t.length=0)})}_captureRenderMetric(e){var S;const t=e;if(t.length===0)return;const i=g=>{let f=0;const v=Object.entries(g).filter(([_,E])=>Array.isArray(E)).map(([_])=>_).reduce((_,E)=>{const T=g[E].reduce((P,R)=>P+R,0);return _[E]=T,_},{});return Object.keys(g).filter(_=>_.startsWith(M.SHEET_EXTENSION_PREFIX)).forEach(_=>{f+=v[_]}),{...v,extensionTotal:f}},r=e.map(g=>({...g,...i(g)})),l=(g=>Object.entries(g[0]).filter(([v,C])=>!["elapsedTime"].includes(v)).filter(([v,C])=>typeof C=="number").map(([v])=>v).reduce((v,C)=>{const _=g.map(R=>R[C]),E=Math.max(..._),T=Math.min(..._),P=_.reduce((R,O)=>R+O,0)/_.length;return v[C]={max:Math.round(E*100)/100,min:Math.round(T*100)/100,avg:Math.round(P*100)/100},v},{}))(r),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),(S=this._telemetryService)==null||S.capture("sheet_render_cost",h)}_addComponent(e){const{scene:t,components:i}=this._context,r=e.getActiveSheet(),s=new M.Spreadsheet(he.MAIN);this._addViewport(r);const l=new M.SpreadsheetRowHeader(he.ROW),c=new M.SpreadsheetColumnHeader(he.COLUMN),d=new M.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,i.set(he.MAIN,s),i.set(he.ROW,l),i.set(he.COLUMN,c),i.set(he.LEFT_TOP,d),t.addObjects([s],zs),t.addObjects([l,c,d],ft),t.enableLayerCache(zs,ft)}_initViewports(e,t,i){const l=new M.Viewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN,e,{left:t.width,top:i.height,bottom:0,right:0,isWheelPreventDefaultX:!0,allowCache:!0,bufferEdgeX:100,bufferEdgeY:100}),c=new M.Viewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:0}),d=new M.Viewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:100}),u=new M.Viewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:100,bufferEdgeY:0}),h=new M.Viewport(M.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP,e,{active:!1,isWheelPreventDefaultX:!0}),S=new M.Viewport(M.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM,e,{left:0,top:i.height,bottom:0,width:t.width+1,isWheelPreventDefaultX:!0}),g=new M.Viewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT,e,{active:!1,isWheelPreventDefaultX:!0}),f=new M.Viewport(M.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT,e,{left:t.width,top:0,height:i.height+1,right:0,isWheelPreventDefaultX:!0}),p=new M.Viewport(M.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP,e,{left:0,top:0,width:t.width,height:i.height,isWheelPreventDefaultX:!0});return{viewMain:l,viewLeftTop:p,viewMainLeftTop:c,viewMainLeft:d,viewMainTop:u,viewColumnLeft:g,viewRowTop:h,viewRowBottom:S,viewColumnRight:f}}_addViewport(e){const t=this._context.scene,{rowHeader:i,columnHeader:r}=e.getConfig(),{viewMain:s}=this._initViewports(t,i,r),l=this._configService.getConfig(Ke),c=l==null?void 0:l.scrollConfig;return new M.ScrollBar(s,c),t.attachControl(),s}_initRerenderScheduler(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(!e)return null;const{skeleton:t,sheetId:i}=e,r=this._context.unit,s=r==null?void 0:r.getSheetBySheetId(i);if(r==null||s==null)return;const{mainComponent:l,components:c}=this._context,d=l,u=c.get(he.ROW),h=c.get(he.COLUMN),S=c.get(he.LEFT_TOP),{rowHeaderWidth:g,columnHeaderHeight:f}=t;d==null||d.updateSkeleton(t),u==null||u.updateSkeleton(t),h==null||h.updateSkeleton(t),S==null||S.transformByState({width:g,height:f})}))}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{const{unit:t}=this._context,{id:i}=e;if(m.COMMAND_LISTENER_SKELETON_CHANGE.includes(i)||this._sheetRenderService.checkMutationShouldTriggerRerender(i)){const r=e.params,{unitId:s,subUnitId:l}=r,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:i},!0),this._sheetSkeletonManagerService.setCurrent({sheetId:u,commandId:i})}else m.COMMAND_LISTENER_VALUE_CHANGE.includes(i)&&this._sheetSkeletonManagerService.reCalculate();e.type===a.CommandType.MUTATION&&this._markUnitDirty(e)}))}_markUnitDirty(e){const{mainComponent:t,scene:i}=this._context;if(e.id===q.SetFormulaCalculationNotificationMutation.id&&e.params.stageInfo!=null||(t&&t.makeDirty(),i.makeDirty(),!e.params))return;const r=e.params,s=this._spreadsheetViewports(i);if(e.id===m.SetRangeValuesMutation.id&&r.cellValue){const l=this._cellValueToRange(r.cellValue),c=this._rangeToBounds([l]);this._markViewportDirty(s,c),t.setDirtyArea(c)}if(e.id===m.MoveRangeMutation.id&&r.from&&r.to){const l=r.fromRange||this._cellValueToRange(r.from.value),c=r.toRange||this._cellValueToRange(r.to.value),d=this._rangeToBounds([l,c]);this._markViewportDirty(s,d),t.setDirtyArea(d)}}_cellValueToRange(e){let t=0,i=0,r=0,s=0;for(const[h,S]of Object.entries(e)){for(const g in S)t>Number(g)&&(t=Number(g)),i<Number(g)&&(i=Number(g));r>Number(h)&&(r=Number(h)),s<Number(h)&&(s=Number(h))}return{startRow:r,endRow:s,startColumn:t,endColumn:i}}_rangeToBounds(e){const t=this._sheetSkeletonManagerService.getCurrentParam().skeleton,{rowHeightAccumulation:i,columnWidthAccumulation:r,rowHeaderWidth:s,columnHeaderHeight:l}=t,c=[];for(const d of e){const{startRow:u,endRow:h,startColumn:S,endColumn:g}=d,f=u===0?0:i[u-1]+l,p=i[h]+l,v=S===0?0:r[S-1]+s,C=r[g]+s;c.push({top:f,left:v,bottom:p,right:C,width:C-v,height:p-f})}return c}_markViewportDirty(e,t){const i=e.filter(r=>r.isActive&&r.cacheBound);for(const r of i)for(const s of t)a.Rectangle.hasIntersectionBetweenTwoRect(r.cacheBound,s)&&r.markDirty(!0)}_spreadsheetViewports(e){return e.getViewports().filter(t=>["viewMain","viewMainLeftTop","viewMainTop","viewMainLeft"].includes(t.viewportKey))}},y.SheetRenderController=cS([Ii(1,a.Inject(a.IConfigService)),Ii(2,a.Inject(y.SheetSkeletonManagerService)),Ii(3,a.Inject(y.SheetsRenderService)),Ii(4,a.ICommandService),Ii(5,a.Optional(ld.ITelemetryService))],y.SheetRenderController);function uS(n,o){if(n.length!==o.length)return!1;const e=n.sort((i,r)=>i.id.localeCompare(r.id)),t=o.sort((i,r)=>i.id.localeCompare(r.id));return e.every((i,r)=>{var s,l;return((s=i.subject)==null?void 0:s.userID)===((l=t[r].subject)==null?void 0:l.userID)&&i.role===t[r].role})}function yl(n,o){return o.some(e=>hS(n,e))}function hS(n,o){const{startRow:e,startColumn:t,endColumn:i,endRow:r}=o,s=n.getMatrixWithMergedCells(e,t,r,i);let l=!1;return s.forValue((c,d,u)=>{if(u&&(c!==e||d!==t)&&n.cellHasValue(u))return l=!0,!1}),l}function Ml(n,o,e,t){const i=[],r=[],s=e.getSheetId();return t.forEach(l=>{const c=mS(e,l),d={unitId:o,subUnitId:s,cellValue:c.getData()},u=m.SetRangeValuesUndoMutationFactory(n,d);i.push({id:m.SetRangeValuesMutation.id,params:u}),r.push({id:m.SetRangeValuesMutation.id,params:d})}),{undos:i,redos:r}}function mS(n,o){const{startRow:e,startColumn:t,endColumn:i,endRow:r}=o,s=n.getMatrixWithMergedCells(e,t,r,i,a.CellModeEnum.Raw),l=new a.ObjectMatrix;let c=null;return s.forValue((d,u,h)=>{var S,g,f,p;h&&d>=e&&u>=t&&(!c&&n.cellHasValue(h)&&(h.v!==""||((p=(f=(g=(S=h.p)==null?void 0:S.body)==null?void 0:g.dataStream)==null?void 0:f.length)!=null?p:0)>2)&&(c=h),l.setValue(d,u,null))}),l.setValue(e,t,c),l}function SS(n,o,e,t){const i=e.getActiveViewportByCoord(M.Vector2.FromArray([n,o]));if(!i)return;const{scaleX:r,scaleY:s}=e.getAncestorScale(),l={x:i.viewportScrollX,y:i.viewportScrollY},c=t.getCellIndexByOffset(n,o,r,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 Rl(n,o,e,t){const i=t.getFreeze();if(!i||i.startRow<=0&&i.startColumn<=0||n>=i.startRow&&o>=i.startColumn)return e.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(n<i.startRow&&o<i.startColumn)return e.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP);if(n<i.startRow&&o>=i.startColumn)return e.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(n>=i.startRow&&o<i.startColumn)return e.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)}function gS(n,o,e,t){const i=Pl(n.left,n.top,o,e,t),r=Pl(n.right,n.bottom,o,e,t);return{left:i.x,top:i.y,right:r.x,bottom:r.y}}function Pl(n,o,e,t,i){const{scaleX:r,scaleY:s}=e.getAncestorScale(),l=e.getViewport(M.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(!l)return{x:n,y:o};const c=i.getFreeze(),{startColumn:d,startRow:u,xSplit:h,ySplit:S}=c,g=t.getNoMergeCellWithCoordByIndex(u-S,d-h,!1),f=t.getNoMergeCellWithCoordByIndex(u,d,!1),{rowHeaderWidth:p,columnHeaderHeight:v}=t,C=f.startX-g.startX,_=f.startY-g.startY,{top:E,left:T,viewportScrollX:P,viewportScrollY:R}=l;let O;n>T?O=(n-P)*r:O=(C+p-(T-n))*r;let A;return o>E?A=(o-R)*s:A=(_+v-(E-o))*r,{x:O,y:A}}function Ol(n,o,e,t,i){let r=t,s=i;e.overflowCache.forValue((d,u,h)=>{h.startRow<=r&&h.endRow>=r&&h.startColumn<=s&&h.endColumn>=s&&(s=u,r=d)});const l=e.getCellWithCoordByIndex(r,s);return{unitId:n.getUnitId(),subUnitId:o.getSheetId(),workbook:n,worksheet:o,row:l.actualRow,col:l.actualColumn}}function Al(n,o,e,t,i,r){const{scene:s}=n,l=o.getUnitId(),{skeleton:c,sheetId:d}=t,u=SS(i,r,s,c);if(!u)return null;let{actualCol:h,actualRow:S}=u;const g={unitId:l,subUnitId:d,workbook:o,worksheet:e,row:S,col:h};c.overflowCache.forValue((R,O,A)=>{A.startRow<=S&&A.endRow>=S&&A.startColumn<=h&&A.endColumn>=h&&(h=O,S=R)});const f=c.getCellWithCoordByIndex(S,h),p=Ol(o,e,c,S,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(M.Vector2.FromArray([i,r]));if(!C)return;const{scaleX:_,scaleY:E}=s.getAncestorScale(),T={x:C.viewportScrollX,y:C.viewportScrollY};return{position:{startX:(c.getOffsetByColumn(v.startColumn-1)-T.x)*_,endX:(c.getOffsetByColumn(v.endColumn)-T.x)*_,startY:(c.getOffsetByRow(v.startRow-1)-T.y)*E,endY:(c.getOffsetByRow(v.endRow)-T.y)*E},location:g,overflowLocation:p}}const bt={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(n,o)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),i=n.get(a.IUniverInstanceService),r=n.get(I.IConfirmService),s=n.get(a.LocaleService),l=o.unitId,c=o.subUnitId,d=o.selections,u=m.getAddMergeMutationRangeByType(d,o.value),h=i.getUniverSheetInstance(l).getSheetBySheetId(c),S=[],g=[],f=yl(h,u);if(f&&!o.defaultMerge&&!await r.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),_=m.AddMergeUndoMutationFactory(n,v);if(C.ranges.length>0&&S.push({id:m.RemoveWorksheetMergeMutation.id,params:C}),S.push({id:m.AddWorksheetMergeMutation.id,params:v}),g.push({id:m.RemoveWorksheetMergeMutation.id,params:_}),C.ranges.length>0&&g.push({id:m.AddWorksheetMergeMutation.id,params:C}),f){const A=Ml(n,l,h,u);S.unshift(...A.redos),g.push(...A.undos)}const E=m.AddMergeRedoSelectionsOperationFactory(n,o,u);E&&S.push(E);const T=m.AddMergeUndoSelectionsOperationFactory(n,o);T&&g.push(T);const R=n.get(m.SheetInterceptorService).onCommandExecute({id:bt.id,params:{unitId:l,subUnitId:c,ranges:u}});return S.push(...R.redos),g.push(...R.undos),a.sequenceExecute(S,e).result?(t.pushUndoRedo({unitID:l,undoMutations:g,redoMutations:S}),!0):!1}},es={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async n=>{var u;const o=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),i=ur(Zi.MergeAll,t);if(!(i!=null&&i.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 o.executeCommand(bt.id,{selections:i,unitId:c,subUnitId:d})}},ts={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async n=>{var u;const o=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),i=ur(Zi.MergeVertical,t);if(!(i!=null&&i.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 o.executeCommand(bt.id,{value:a.Dimension.COLUMNS,selections:i,unitId:c,subUnitId:d})}},ns={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async n=>{var u;const o=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),i=ur(Zi.MergeHorizontal,t);if(!(i!=null&&i.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 o.executeCommand(bt.id,{value:a.Dimension.ROWS,selections:i,unitId:c,subUnitId:d})}},Pn={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-left-confirm",handler:async n=>{const o=n.get(I.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),i=n.get(m.SheetsSelectionsService),r=n.get(a.IUniverInstanceService),s=i.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(r);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=g=>g.endRow-g.startRow;return!c.getMergeData().find(g=>{const f=a.Rectangle.getIntersects(g,d);return f?u(g)>u(f):!1})||await o.confirm({id:Pn.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}},Gt={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-up-confirm",handler:async n=>{const o=n.get(I.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),i=n.get(m.SheetsSelectionsService),r=n.get(a.IUniverInstanceService),s=i.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(r);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 g=d.startRow;g<=d.endRow;g++)if(c.getRowFiltered(g)&&await o.confirm({id:Gt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=g=>g.endColumn-g.startColumn;return!c.getMergeData().find(g=>{const f=a.Rectangle.getIntersects(g,d);return f?u(g)>u(f):!1})||await o.confirm({id:Gt.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}},Zt={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-down-confirm",handler:async n=>{const o=n.get(I.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),i=n.get(m.SheetsSelectionsService),r=n.get(a.IUniverInstanceService),s=i.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(r);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 g=d.startRow;g<=d.endRow;g++)if(c.getRowFiltered(g)&&await o.confirm({id:Zt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=g=>g.endColumn-g.startColumn;return!c.getMergeData().find(g=>{const f=a.Rectangle.getIntersects(g,d);return f?u(g)>u(f):!1})||await o.confirm({id:Zt.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}},On={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-right-confirm",handler:async n=>{const o=n.get(I.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),i=n.get(m.SheetsSelectionsService),r=n.get(a.IUniverInstanceService),s=i.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(r);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=g=>g.endRow-g.startRow;return!c.getMergeData().find(g=>{const f=a.Rectangle.getIntersects(g,d);return f?u(g)>u(f):!1})||await o.confirm({id:On.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 kl=(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))(kl||{}),te=(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))(te||{}),He=(n=>(n[n.Reader=0]="Reader",n[n.Editor=1]="Editor",n[n.Owner=2]="Owner",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(He||{}),lt=(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))(lt||{}),tt=(n=>(n[n.SomeCollaborator=0]="SomeCollaborator",n[n.AllCollaborator=1]="AllCollaborator",n[n.OneSelf=2]="OneSelf",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(tt||{});const _i="UNIVER_SHEET_PERMISSION_PANEL",uo="UNIVER_SHEET_PERMISSION_USER_PART",is="UNIVER_SHEET_PERMISSION_BACKGROUND",Dl="UNIVER_SHEET_PERMISSION_USER_DIALOG",Nl="UNIVER_SHEET_PERMISSION_DIALOG",ho="UNIVER_SHEET_PERMISSION_USER_DIALOG_ID",mo="UNIVER_SHEET_PERMISSION_DIALOG_ID",So={[te.Copy]:"Copy",[te.SetCellStyle]:"SetCellStyle",[te.SetCellValue]:"SetCellValue",[te.SetRowStyle]:"SetRowStyle",[te.SetColumnStyle]:"SetColumnStyle",[te.InsertRow]:"InsertRow",[te.InsertColumn]:"InsertColumn",[te.InsertHyperlink]:"InsertHyperlink",[te.DeleteRow]:"DeleteRow",[te.DeleteColumn]:"DeleteColumn",[te.Sort]:"Sort",[te.Filter]:"Filter",[te.PivotTable]:"PivotTable",[te.EditExtraObject]:"EditExtraObject"},fS=[te.Copy,te.SetCellStyle,te.SetCellValue,te.SetRowStyle,te.SetColumnStyle,te.InsertRow,te.InsertColumn,te.InsertHyperlink,te.DeleteRow,te.DeleteColumn,te.Sort,te.Filter,te.PivotTable,te.EditExtraObject,te.View],Hl="sheet-permission-menu-icon",pS="sheet-permission-delete-icon",vS="sheet-permission-edit-icon",CS="sheet-permission-check-icon",Vl="sheet-permission-lock-icon",IS={unitId:"",subUnitId:"",permissionId:"",unitType:m.UnitObject.SelectRange,id:"",ranges:[],viewState:m.ViewStateEnum.OthersCanView,editState:m.EditStateEnum.OnlyMe};class An{constructor(){w(this,"_rule",IS);w(this,"_visible",!1)}setVisible(o){this._visible=o}getVisible(){return this._visible}reset(){this.setVisible(!1)}}class Et{constructor(){w(this,"_userList",[]);w(this,"_userList$",new k.BehaviorSubject(this._userList));w(this,"userList$",this._userList$.asObservable());w(this,"_oldCollaboratorList",[]);w(this,"_selectUserList",[]);w(this,"_selectUserList$",new k.BehaviorSubject(this._selectUserList));w(this,"selectUserList$",this._selectUserList$.asObservable())}get userList(){return this._userList}setCanEditUserList(o){this._userList=o,this._userList$.next(o)}reset(){this._userList=[],this._oldCollaboratorList=[],this._selectUserList=[],this._selectUserList$.next([])}get oldCollaboratorList(){return this._oldCollaboratorList}setOldCollaboratorList(o){this._oldCollaboratorList=o}get selectUserList(){return this._selectUserList}setSelectUserList(o){this._selectUserList=o,this._selectUserList$.next(o)}}const nt={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openPanel",async handler(n,o={}){const e=n.get(I.ISidebarService),t=n.get(An),i=n.get(Et),{showDetail:r=!0,fromSheetBar:s=!1,rule:l,oldRule:c}=o,d={header:{title:"permission.panel.title"},children:{label:_i,showDetail:r,fromSheetBar:s,rule:l,oldRule:c},width:330,onClose:()=>{t.reset(),i.reset()}};return t.setVisible(!0),e.open(d),!0}},bi={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-toolbar",async handler(n){return await n.get(a.ICommandService).executeCommand(nt.id,{showDetail:!0}),!0}},Kt={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(nt.id,{showDetail:!0}),!0}},qt={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(nt.id,{showDetail:!1}),!0}},Ei={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(nt.id,{fromSheetBar:!0,showDetail:!0}),!0}},wi={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(nt.id,{showDetail:!1}),!0}},Qt={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-protection-from-context-menu",async handler(n){var h;const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IUndoRedoService),i=n.get(m.SheetsSelectionsService),r=n.get(m.WorksheetProtectionRuleModel),s=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s.getActiveSheet(),c=s.getUnitId(),d=l.getSheetId(),u=r.getRule(c,d);if(u!=null&&u.permissionId)return o.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d,rule:u});{const S=(h=i.getCurrentLastSelection())==null?void 0:h.range;if(!S)return!1;const p=n.get(m.RangeProtectionRuleModel).getSubunitRuleList(c,d).find(v=>v.ranges.some(C=>a.Rectangle.intersects(C,S)));if(p){const v={unitId:c,subUnitId:d,ruleIds:[p.id]};return await o.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}}},Jt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-protection-from-context-menu",async handler(n){var u;const o=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(m.WorksheetProtectionRuleModel),r=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=r.getActiveSheet(),l=r.getUnitId(),c=s.getSheetId(),d=i.getRule(l,c);if(d!=null&&d.permissionId){const h={...d,unitId:l,subUnitId:c,ranges:[]};return await o.executeCommand(nt.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 o.executeCommand(nt.id,{showDetail:!0,rule:a.Tools.deepClone(p),oldRule:a.Tools.deepClone(p)}),!0}else return!1}}},kn={id:"sheet.command.remove-row-confirm",type:a.CommandType.COMMAND,handler:async(n,o)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=o==null?void 0:o.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const i=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(r);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleRows();if(aa(c,[t])){const u=n.get(I.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 i.executeCommand(m.RemoveRowCommand.id,{range:t}),!0}},Dn={id:"sheet.command.remove-col-confirm",type:a.CommandType.COMMAND,handler:async(n,o)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=o==null?void 0:o.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const i=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(r);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleCols();if(la(c,[t])){const u=n.get(I.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 i.executeCommand(m.RemoveColCommand.id,{range:t}),!0}},Ti={id:"sheet.command.remove-sheet-confirm",type:a.CommandType.COMMAND,handler:async(n,o)=>{const{subUnitId:e}=o,t=n.get(I.IConfirmService),i=n.get(a.ICommandService),r=n.get(a.LocaleService);return await t.confirm({id:"sheet.confirm.remove-sheet",title:{title:r.t("sheetConfig.deleteSheet")},children:{title:r.t("sheetConfig.deleteSheetContent")},cancelText:r.t("button.cancel"),confirmText:r.t("button.confirm")})?(await i.executeCommand(m.RemoveSheetCommand.id,{subUnitId:e}),!0):!1}},yi={id:"ui-sheet.command.show-menu-list",type:a.CommandType.OPERATION,handler:async n=>(n.get(Wt).triggerSheetBarMenu(),!0)},Mi={type:a.CommandType.COMMAND,id:"sheet.command.delete-worksheet-protection-from-sheet-bar",async handler(n,o){if(!o)return!1;const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),i=n.get(m.WorksheetProtectionRuleModel),s=n.get(a.IUniverInstanceService).getCurrentUnitForType(kl.UNIVER_SHEET),l=s==null?void 0:s.getActiveSheet(),c=s.getUnitId();if(!l)return!1;const d=l.getSheetId(),u=i.getRule(c,d);if(await e.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d})){const S=[{id:m.DeleteWorksheetProtectionCommand.id,params:{unitId:c,subUnitId:d}}],g=[{id:m.AddWorksheetProtectionCommand.id,params:{unitId:c,rule:u}}];t.pushUndoRedo({unitID:c,redoMutations:S,undoMutations:g})}return!0}},Ri={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}},go={id:"sheet.operation.set-activate-cell-edit",type:a.CommandType.OPERATION,handler:(n,o)=>(n.get(ge).setEditCell(o),!0)},Pi={id:"sheet.operation.rename-sheet",type:a.CommandType.OPERATION,handler:async(n,o)=>{const e=n.get(Wt);return o&&e.setRenameId(o.subUnitId),!0}},os={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openDialog",async handler(n,o){const e=n.get(I.IDialogService);return e.close("DESKTOP_FIND_REPLACE_DIALOG"),e.open({id:mo,title:{title:"permission.dialog.allowedPermissionType"},children:{label:Nl},width:393,destroyOnClose:!0,onClose:()=>e.close(mo)}),!0}},_S=()=>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"})]}),bS=()=>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"})]}),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:"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"})]}),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.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"})]}),TS=()=>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"})}),yS=()=>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"})]}),MS=()=>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"})]}),RS=()=>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"})]}),PS=()=>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"})}),Wl=()=>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 Ll(n){const{type:o=a.BorderStyleTypes.THIN}=n;switch(o){case a.BorderStyleTypes.DASH_DOT:return b.jsx(_S,{});case a.BorderStyleTypes.DASH_DOT_DOT:return b.jsx(bS,{});case a.BorderStyleTypes.DASHED:return b.jsx(ES,{});case a.BorderStyleTypes.HAIR:return b.jsx(wS,{});case a.BorderStyleTypes.MEDIUM:return b.jsx(TS,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT:return b.jsx(yS,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return b.jsx(MS,{});case a.BorderStyleTypes.MEDIUM_DASHED:return b.jsx(RS,{});case a.BorderStyleTypes.THICK:return b.jsx(PS,{});case a.BorderStyleTypes.THIN:return b.jsx(Wl,{});default:return b.jsx(Wl,{})}}const rs=`${Tn}_BORDER_PANEL_COMPONENT`,Ul=[{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"}],OS=[{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 Bl(n){var l;const o=I.useDependency(I.ComponentManager),e=I.useDependency(m.BorderStyleManagerService),{onChange:t,value:i}=n;function r(c,d){t==null||t({...i,[d]:c})}function s(c){const d=o.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:Ul.map(c=>b.jsx("a",{className:G.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
|