@univerjs/sheets-ui 0.1.0-beta.2 → 0.1.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{LICENSE.txt → LICENSE} +0 -2
- package/lib/cjs/index.js +10 -10
- package/lib/es/index.js +6614 -7180
- package/lib/index.css +1 -1
- package/lib/types/commands/commands/__tests__/create-command-test-bed.d.ts +25 -0
- package/lib/types/{components/font-size/FontSize.d.ts → commands/commands/__tests__/hide-row-col-confirm.command.spec.d.ts} +1 -3
- package/lib/types/{components/font-family/FontFamily.d.ts → commands/commands/__tests__/remove-row-col-confirm.command.spec.d.ts} +1 -3
- package/lib/types/{components/font-family/FontFamilyItem.d.ts → commands/commands/__tests__/selection-utils.spec.d.ts} +1 -3
- package/lib/types/commands/commands/delete-range-move-left-confirm.command .d.ts +17 -0
- package/lib/types/commands/commands/delete-range-move-up-confirm.command.d.ts +17 -0
- package/lib/types/commands/commands/hide-row-col-confirm.command.d.ts +18 -0
- package/lib/types/commands/commands/insert-range-move-down-confirm.command.d.ts +17 -0
- package/lib/types/commands/commands/insert-range-move-right-confirm.command.d.ts +17 -0
- package/lib/types/commands/commands/remove-row-col-confirm.command.d.ts +18 -0
- package/lib/types/commands/commands/utils/selection-utils.d.ts +14 -0
- package/lib/types/components/font-family/index.d.ts +2 -2
- package/lib/types/components/font-family/interface.d.ts +0 -7
- package/lib/types/components/font-size/index.d.ts +1 -1
- package/lib/types/components/font-size/interface.d.ts +0 -9
- package/lib/types/controllers/clipboard/clipboard.controller.d.ts +9 -5
- package/lib/types/controllers/freeze.controller.d.ts +1 -0
- package/lib/types/controllers/header-menu.controller.d.ts +4 -2
- package/lib/types/controllers/menu/menu.d.ts +6 -14
- package/lib/types/controllers/menu/sheet.menu.d.ts +3 -3
- package/lib/types/controllers/shortcuts/utils.d.ts +24 -5
- package/lib/types/controllers/shortcuts/view.shortcut.d.ts +3 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/locale/en-US.d.ts +7 -18
- package/lib/types/locale/zh-CN.d.ts +7 -18
- package/lib/types/services/auto-fill/rules.d.ts +1 -0
- package/lib/types/services/auto-fill/tools.d.ts +2 -2
- package/lib/types/services/clipboard/clipboard.service.d.ts +2 -1
- package/lib/types/services/clipboard/copy-content-cache.d.ts +2 -2
- package/lib/types/services/selection/selection-shape.d.ts +1 -0
- package/lib/types/services/shortcut-experience.service.d.ts +45 -0
- package/lib/types/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.d.ts +3 -1
- package/lib/umd/index.js +11 -11
- package/package.json +48 -46
- /package/lib/types/views/count-bar/{zoom-slider.d.ts → ZoomSlider.d.ts} +0 -0
package/lib/cjs/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";var Ms=Object.defineProperty;var ws=(i,e,t)=>e in i?Ms(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var v=(i,e,t)=>(ws(i,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@univerjs/core"),p=require("@univerjs/sheets"),R=require("@univerjs/ui"),j=require("@wendellhu/redi"),J=require("rxjs"),y=require("@univerjs/engine-render"),X=require("react"),Ye=require("@univerjs/design"),me=require("@wendellhu/redi/react-bindings"),pe=require("@univerjs/docs"),uo=require("rxjs/operators"),Re=require("@univerjs/engine-formula"),bn=require("clsx"),ho={InsertRow:!0,InsertColumn:!0,AddRowTop:!1,AddRowBottom:!1,AddColumnLeft:!1,AddColumnRight:!1,DeleteRow:!0,DeleteColumn:!0,HideRow:!1,ShowRow:!1,RowHeight:!1,HideColumn:!1,ShowColumn:!1,ColumnWidth:!1,DeleteCell:!0,ClearContent:!0,Matrix:!1},mo={undo:!0,redo:!0,paintFormat:!0,currencyFormat:!0,percentageFormat:!0,numberDecrease:!0,numberIncrease:!0,moreFormats:!0,font:!0,fontSize:!0,bold:!0,italic:!0,strikethrough:!0,underline:!0,textColor:!0,fillColor:!0,border:!0,horizontalAlignMode:!0,verticalAlignMode:!0,textWrapMode:!0,textRotateMode:!0,mergeCell:!0},go={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0,formulaBar:!0,rightMenu:!0,countBar:!0,sheetBar:!0},Ts={layout:{sheetContainerConfig:go,rightMenuConfig:ho,toolbarConfig:mo}},_o="SheetUI";function wi(i,e){if(i==null)return;const t=e.getRenderById(i);if(t==null)return;const{mainComponent:n,scene:r,engine:o}=t;return{document:n,scene:r,engine:o}}const Zi={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},Si=["零","一","二","三","四","五","六","七","八","九"],Tr=["","万","亿","万亿","亿亿"],ys=["","十","百","千"],po={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function It(i){if(!i)return 0;let e=0,t=0,n=0,r=!1;const o=i.split("");for(let s=0;s<o.length;s++){const a=Zi[o[s]];if(typeof a<"u")n=a,s===o.length-1&&(t+=n);else{const c=po[o[s]],d=c.value;r=c.secUnit,r?(t=(t+n)*d,e+=t,t=0):t+=n*d,n=0}}return e+t}function Es(i){let e="",t="",n=0,r=!0;for(;i>0;){const o=i%10;o===0?r||(r=!0,t=Si[o]+t):(r=!1,e=Si[o],e+=ys[n],t=e+t),n++,i=Math.floor(i/10)}return t}function Os(i){let e=0,t="",n="",r=!1;if(i===0)return Si[0];for(;i>0;){const o=i%1e4;r&&(n=Si[0]+n),t=Es(o),t+=o!==0?Tr[e]:Tr[0],n=t+n,r=o<1e3&&o>0,i=Math.floor(i/1e4),e++}return n}function xs(i){if(!i)return!1;let e=!0;if(i)if(i.length===1)i==="日"||i in Zi?e=!0:e=!1;else{const t=i.split("");for(let n=0;n<t.length;n++)if(!(t[n]in Zi||t[n]in po)){e=!1;break}}return e}function Un(i){if(!i)return{isExtendNumber:!1};const e=/0|([1-9]+[0-9]*)/g,t=e.test(i);if(t){const n=i.match(e);if(n&&n.length>0){const r=n[n.length-1],o=i.lastIndexOf(r),s=i.substr(0,o),a=i.substr(o+r.length);return{isExtendNumber:!0,matchTxt:Number(r),beforeTxt:s,afterTxt:a}}return{isExtendNumber:!1}}return{isExtendNumber:t}}function As(i){let e;return i.length===2&&(i==="周一"||i==="周二"||i==="周三"||i==="周四"||i==="周五"||i==="周六"||i==="周日")?e=!0:e=!1,e}function Ns(i){let e;return i.length===3&&(i==="星期一"||i==="星期二"||i==="星期三"||i==="星期四"||i==="星期五"||i==="星期六"||i==="星期日")?e=!0:e=!1,e}function Ds(i,e){let t=0;for(let n=0;n<i.length&&i[n]<e;n++)t++;return t}function En(i){let e=!0;const t=i[1]-i[0];for(let n=1;n<i.length;n++)if(i[n]-i[n-1]!==t){e=!1;break}return e}function Ps(i,e,t){const n=[],r=Math.floor(e/i),o=e%i;let s=0;if(r>0){for(let a=0;a<r;a++)for(let c=0;c<t.length;c++)n[t[c]+a*i]=s,s++;for(let a=0;a<t.length&&t[a]<o;a++)n[t[a]+i*r]=s,s++}else for(let a=0;a<t.length&&t[a]<o;a++)n[t[a]]=s,s++;return n}function Bt(i,e){const t=[];for(let n=1;n<=e;n++){const r=(n-1)%i.length,o=l.Tools.deepClone(i[r]);t.push({v:null,s:null,p:null,f:null,si:null,t:null,...o})}return t}function Hs(i,e){var n;const t=[];for(let r=1;r<=e;r++){const o=(r-1)%i.length,s={s:(n=i[o])==null?void 0:n.s};t.push(s)}return t}function Ls(i){let e=!0;const t=i[1]/i[0];for(let n=1;n<i.length;n++)if(i[n]/i[n-1]!==t){e=!1;break}return e}function Us(i){const e=[];for(let t=1;t<=i;t++)e.push(t);return e}function yr(i,e,t){var o,s,a,c;const n=[],r=[];for(let d=0;d<i.length;d++)r.push(Number((o=i[d])==null?void 0:o.v));if(i.length>2&&Ls(r))for(let d=1;d<=e;d++){const u=(d-1)%i.length,h=l.Tools.deepClone(i[u]),m=Number((s=i[i.length-1])==null?void 0:s.v)*(Number((a=i[1])==null?void 0:a.v)/Number((c=i[0])==null?void 0:c.v))**d;h&&(h.v=m,n.push(h))}else{const d=Us(i.length);for(let u=1;u<=e;u++){const h=(u-1)%i.length,m=l.Tools.deepClone(i[h]),g=ks(i.length+u,r,d);m&&(m.v=g,n.push(m))}}return n}function ks(i,e,t){function n(u){let h=0;for(let m=0;m<u.length;m++)h+=u[m];return h/u.length}const r=n(t),o=n(e);let s=0,a=0;for(let u=0;u<t.length;u++)s+=(t[u]-r)*(e[u]-o),a+=(t[u]-r)*(t[u]-r);let c;a===0?c=1:c=s/a;const d=o-c*r;return Math.round((d+c*i)*1e5)/1e5}function Er(i,e,t){var o;const n=[],r=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=e;s++){const a=(s-1)%i.length,c=l.Tools.deepClone(i[a]),d=`${(o=i[i.length-1])==null?void 0:o.v}`,u=d==null?void 0:d.match(r),h=u==null?void 0:u[u.length-1],m=Math.abs(Number(h)+t*s);if(!d||!h)continue;const g=d.lastIndexOf(h),_=d.substr(0,g)+m.toString()+d.substr(g+h.length);c&&(c.v=_,n.push(c))}return n}function en(i,e,t,n=0){var a,c;const r=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(n>=r.length)return[];const o=r[n],s=[];for(let d=1;d<=e;d++){const u=(d-1)%i.length,h=l.Tools.deepClone(i[u]);let m=0;if(((a=i[i.length-1])==null?void 0:a.v)===o[0])m=7+t*d;else{const _=`${(c=i[i.length-1])==null?void 0:c.v}`;if(_){const f=_.substr(_.length-1,1);m=It(f)+t*d}}m<0&&(m=Math.ceil(Math.abs(m)/7)*7+m);const g=m%7;h&&(h.v=o[g],s.push(h))}return s}function Or(i,e,t){var r;const n=[];for(let o=1;o<=e;o++){const s=(o-1)%i.length,a=l.Tools.deepClone(i[s]),c=`${(r=i[i.length-1])==null?void 0:r.v}`,d=It(c)+t*o;let u;d<=0?u="零":u=Os(d),a&&(a.v=u,n.push(a))}return n}const In={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 Vs(i){let e=!1;return Object.keys(In).forEach(t=>{In[t].includes(i)&&(e=!0)}),e}function Pi(i){let e="";const t=[];return Object.keys(In).forEach(n=>{In[n].includes(i)&&(e=n,t.push(...In[n]))}),{name:e,series:t}}function xr(i,e,t,n){var s;const r=n.length,o=[];for(let a=1;a<=e;a++){const c=(a-1)%i.length,d=l.Tools.deepClone(i[c]),u=`${(s=i[i.length-1])==null?void 0:s.v}`,m=(n.indexOf(u)+t*a)%r;d&&(d.v=n[m],o.push(d))}return o}function Fs(i,e){const t=[];let n;if(e.startRow<i.startRow)n=l.Direction.UP;else if(e.endRow>i.endRow)n=l.Direction.DOWN;else if(e.startColumn<i.startColumn)n=l.Direction.LEFT;else if(e.endColumn>i.endColumn)n=l.Direction.RIGHT;else return[];if(n===l.Direction.DOWN||n===l.Direction.UP){const r=i.endRow-i.startRow+1,o=e.endRow-e.startRow+1,s=o/r,a=o%r,c={startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:i.endColumn-i.startColumn};if(n===l.Direction.DOWN){for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow+(d+1)*r,col:i.startColumn},relativeRange:c});a>0&&t.push({repeatStartCell:{row:i.startRow+(s+1)*r,col:i.startColumn},relativeRange:{startRow:0,startColumn:0,endRow:a-1,endColumn:i.endColumn-i.startColumn}})}else{for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow-(d+1)*r,col:i.startColumn},relativeRange:c});a>0&&t.push({repeatStartCell:{row:i.startRow-(s+1)*r,col:i.startColumn},relativeRange:{startRow:r-a,endRow:r-1,startColumn:0,endColumn:i.endColumn-i.startColumn}})}}if(n===l.Direction.RIGHT||n===l.Direction.LEFT){const r=i.endColumn-i.startColumn+1,o=e.endColumn-e.startColumn+1,s=o/r,a=o%r,c={startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:i.endColumn-i.startColumn};if(n===l.Direction.RIGHT){for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow,col:i.startColumn+(d+1)*r},relativeRange:c});a>0&&t.push({repeatStartCell:{row:i.startRow,col:i.startColumn+(s+1)*r},relativeRange:{startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:a-1}})}else{for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow,col:i.startColumn-(d+1)*r},relativeRange:c});a>0&&t.push({repeatStartCell:{row:i.startRow,col:i.startColumn-(s+1)*r},relativeRange:{startRow:0,startColumn:r-a,endRow:i.endRow-i.startRow,endColumn:r-1}})}}return t}function fo(i){const e=new l.ObjectMatrix;return i.forEach(t=>{const{startRow:n,startColumn:r,endRow:o,endColumn:s}=t;for(let a=n;a<=o;a++)for(let c=r;c<=s;c++)e.setValue(a,c,{v:null,p:null,f:null,si:null})}),e.getData()}const So={type:l.CommandType.COMMAND,id:"sheet.command.auto-fill",handler:async(i,e)=>!0},zn={id:"sheet.command.auto-clear-content",type:l.CommandType.COMMAND,handler:async(i,e)=>{const t=i.get(l.IUniverInstanceService),n=i.get(l.ICommandService),r=i.get(l.IUndoRedoService),o=t.getCurrentUniverSheetInstance(),s=o.getUnitId(),c=o.getActiveSheet().getSheetId(),{clearRange:d,selectionRange:u}=e,h={subUnitId:c,unitId:s,cellValue:fo([d])},m=p.SetRangeValuesUndoMutationFactory(i,h);return n.executeCommand(p.SetSelectionsOperation.id,{selections:[{primary:{...u},range:{...u}}],unitId:s,subUnitId:c}),n.syncExecuteCommand(p.SetRangeValuesMutation.id,h)?(r.pushUndoRedo({unitID:s,undoMutations:[{id:p.SetRangeValuesMutation.id,params:m}],redoMutations:[{id:p.SetRangeValuesMutation.id,params:h}],undo(){return n.syncExecuteCommand(p.SetRangeValuesMutation.id,m)},redo(){return n.syncExecuteCommand(p.SetRangeValuesMutation.id,h)}}),!0):!1}};function ye(i){return i.getContextValue(l.FOCUSING_SHEET)&&!i.getContextValue(l.FOCUSING_EDITOR)}function vo(i){return i.getContextValue(l.FOCUSING_SHEET)&&i.getContextValue(l.FOCUSING_EDITOR)}function Bs(i){return i.getContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN)&&!i.getContextValue(l.FOCUSING_EDITOR)}function js(i){return i.getContextValue(l.FOCUSING_EDITOR)&&i.getContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN)}function Co(i){return i.getContextValue(l.FOCUSING_FORMULA_EDITOR)}function Ws(i){return i.getContextValue(l.FOCUSING_SHEET)&&i.getContextValue(l.FOCUSING_EDITOR)&&i.getContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA)}function vi(i){return i.getContextValue(l.FOCUSING_SHEET)&&i.getContextValue(l.FOCUSING_EDITOR)&&!i.getContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA)}var Xe=(i=>(i.MAIN="__SpreadsheetRender__",i.ROW="__SpreadsheetRowHeader__",i.COLUMN="__SpreadsheetColumnHeader__",i.LEFT_TOP="__SpreadsheetLeftTopPlaceholder__",i))(Xe||{}),Q=(i=>(i.VIEW_MAIN="viewMain",i.VIEW_MAIN_LEFT_TOP="viewMainLeftTop",i.VIEW_MAIN_TOP="viewMainTop",i.VIEW_MAIN_LEFT="viewMainLeft",i.VIEW_ROW_TOP="viewRowTop",i.VIEW_ROW_BOTTOM="viewRowBottom",i.VIEW_COLUMN_LEFT="viewColumnLeft",i.VIEW_COLUMN_RIGHT="viewColumnRight",i.VIEW_LEFT_TOP="viewLeftTop",i))(Q||{});const Ar=0,At=2,zs=3,Gi=[10,400],Nr=1001;var $s=Object.defineProperty,Ys=Object.getOwnPropertyDescriptor,Xs=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ys(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&$s(e,t,r),r},Dr=(i,e)=>(t,n)=>e(t,n,i);exports.SheetSkeletonManagerService=class{constructor(e,t){v(this,"_currentSkeleton",{unitId:"",sheetId:""});v(this,"_sheetSkeletonParam",[]);v(this,"_currentSkeleton$",new J.BehaviorSubject(null));v(this,"currentSkeleton$",this._currentSkeleton$.asObservable());v(this,"_currentSkeletonBefore$",new J.BehaviorSubject(null));v(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._currentUniverService=e,this._localeService=t}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParam=[]}getCurrent(){return this._getCurrentBySearch(this._currentSkeleton)}setCurrent(e){const t=this._getCurrentBySearch(e);if(t!=null)this._reCalculate(t);else{const{unitId:r,sheetId:o}=e,s=this._currentUniverService.getUniverSheetInstance(e.unitId),a=s==null?void 0:s.getSheetBySheetId(e.sheetId);if(a==null||s==null)return;const c=this._buildSkeleton(a,s);this._sheetSkeletonParam.push({unitId:r,sheetId:o,skeleton:c,dirty:!1})}this._currentSkeleton=e;const n=this.getCurrent();return this._currentSkeletonBefore$.next(n),this._currentSkeleton$.next(n),this.getCurrent()}reCalculate(){const e=this.getCurrent();e!=null&&this._reCalculate(e)}_reCalculate(e){e.dirty&&(e.skeleton.makeDirty(!0),e.dirty=!1),e.skeleton.calculate()}makeDirtyCurrent(e=!0){this.makeDirty(this._currentSkeleton,e)}makeDirty(e,t=!0){const n=this._getCurrentBySearch(e);n!=null&&(n.dirty=t)}_getCurrentBySearch(e){const t=this._sheetSkeletonParam.find(n=>n.unitId===e.unitId&&n.sheetId===e.sheetId);return t!=null&&(t.commandId=e.commandId),t}_buildSkeleton(e,t){const n=e.getConfig();return y.SpreadsheetSkeleton.create(e,n,e.getCellMatrix(),t.getStyles(),this._localeService)}};exports.SheetSkeletonManagerService=Xs([Dr(0,l.IUniverInstanceService),Dr(1,j.Inject(l.LocaleService))],exports.SheetSkeletonManagerService);class Zs{constructor(){v(this,"_startColumn",-1);v(this,"_startRow",-1);v(this,"_endColumn",-1);v(this,"_endRow",-1);v(this,"_startX",0);v(this,"_startY",0);v(this,"_endX",0);v(this,"_endY",0);v(this,"_currentCell");v(this,"_rangeType",l.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._currentCell}get rangeType(){return this._rangeType}isEqual(e){const{startColumn:t,startRow:n,endColumn:r,endRow:o}=this,{startColumn:s,startRow:a,endColumn:c,endRow:d}=e;return t===s&&n===a&&r===c&&o===d}isInclude(e){const{startColumn:t,startRow:n,endColumn:r,endRow:o}=this,{startColumn:s,startRow:a,endColumn:c,endRow:d}=e;return!(c<t||s>r||a>o||d<n)}highlightToSelection(){return l.makeCellToSelection(this._currentCell)}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._currentCell}getRangeType(){return this._rangeType}getValue(){return{rangeWithCoord:{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},primaryWithCoord:this._currentCell}}setValue(e,t){const{startColumn:n,startRow:r,endColumn:o,endRow:s,startX:a,startY:c,endX:d,endY:u,rangeType:h}=e;this._startColumn=n,this._startRow=r,this._endColumn=o,this._endRow=s,this._startX=a,this._startY=c,this._endX=d,this._endY=u,h!=null&&(this._rangeType=h),this.setCurrentCell(t)}setCurrentCell(e){e&&(this._currentCell=e)}clearCurrentCell(){this._currentCell=null}}const Pr=.3;class Ci{constructor(e,t,n=!0,r){v(this,"_leftControl");v(this,"_rightControl");v(this,"_topControl");v(this,"_bottomControl");v(this,"_backgroundControlTop");v(this,"_backgroundControlBottom");v(this,"_backgroundControlMiddleLeft");v(this,"_backgroundControlMiddleRight");v(this,"_fillControl");v(this,"_selectionShape");v(this,"_rowHeaderBackground");v(this,"_rowHeaderBorder");v(this,"_rowHeaderGroup");v(this,"_rowHeaderHighlight");v(this,"_columnHeaderBackground");v(this,"_columnHeaderBorder");v(this,"_columnHeaderGroup");v(this,"_columnHeaderHighlight");v(this,"_topLeftWidget");v(this,"_topCenterWidget");v(this,"_topRightWidget");v(this,"_middleLeftWidget");v(this,"_middleRightWidget");v(this,"_bottomLeftWidget");v(this,"_bottomCenterWidget");v(this,"_bottomRightWidget");v(this,"_dashRect");v(this,"_selectionModel");v(this,"_selectionStyle");v(this,"_rowHeaderWidth",0);v(this,"_columnHeaderHeight",0);v(this,"_widgetRects",[]);v(this,"_dispose$",new J.BehaviorSubject(this));v(this,"dispose$",this._dispose$.asObservable());v(this,"selectionMoving$",new J.Subject);v(this,"selectionMoved$",new J.Subject);v(this,"selectionScaling$",new J.Subject);v(this,"selectionScaled$",new J.Subject);v(this,"selectionFilling$",new J.Subject);v(this,"_selectionFilled$",new J.Subject);v(this,"selectionFilled$",this._selectionFilled$.asObservable());v(this,"_defaultStyle");v(this,"_isHelperSelection",!0);this._scene=e,this._zIndex=t,this._isHeaderHighlight=n,this._themeService=r,this._initialize()}get zIndex(){return this._zIndex}get leftControl(){return this._leftControl}get rightControl(){return this._rightControl}get topControl(){return this._topControl}get bottomControl(){return this._bottomControl}get fillControl(){return this._fillControl}get backgroundControlTop(){return this._backgroundControlTop}get backgroundControlBottom(){return this._backgroundControlBottom}get backgroundControlMiddleLeft(){return this._backgroundControlMiddleLeft}get backgroundControlMiddleRight(){return this._backgroundControlMiddleRight}get selectionShape(){return this._selectionShape}get model(){return this._selectionModel}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 selectionStyle(){return this._selectionStyle}get dashRect(){return this._dashRect}get isHelperSelection(){return this._isHelperSelection}setEvent(e){this.leftControl.evented=e,this.rightControl.evented=e,this.topControl.evented=e,this.bottomControl.evented=e}enableHeaderHighlight(){this._isHelperSelection=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}refreshSelectionFilled(e){this._selectionFilled$.next(e)}updateStyle(e){this._updateControl(e,this._rowHeaderWidth,this._columnHeaderHeight)}update(e,t=0,n=0,r,o){this._selectionModel.setValue(e,o),r==null&&(r=this._selectionStyle),this._updateControl(r,t,n)}clearHighlight(){this._selectionModel.clearCurrentCell(),this._updateControl(this._selectionStyle,this._rowHeaderWidth,this._columnHeaderHeight)}getScene(){return this._scene}dispose(){var e,t,n,r,o,s,a,c,d,u,h,m,g,_,f,C,I,w,E,O,x,N,D,P,L;(e=this._leftControl)==null||e.dispose(),(t=this._rightControl)==null||t.dispose(),(n=this._topControl)==null||n.dispose(),(r=this._bottomControl)==null||r.dispose(),(o=this._backgroundControlTop)==null||o.dispose(),(s=this._backgroundControlMiddleLeft)==null||s.dispose(),(a=this._backgroundControlMiddleRight)==null||a.dispose(),(c=this._backgroundControlBottom)==null||c.dispose(),(d=this._fillControl)==null||d.dispose(),(u=this._selectionShape)==null||u.dispose(),(h=this._rowHeaderBackground)==null||h.dispose(),(m=this._rowHeaderBorder)==null||m.dispose(),(g=this._rowHeaderGroup)==null||g.dispose(),(_=this._rowHeaderBackground)==null||_.dispose(),(f=this._columnHeaderBackground)==null||f.dispose(),(C=this._columnHeaderBorder)==null||C.dispose(),(I=this._columnHeaderGroup)==null||I.dispose(),(w=this._topLeftWidget)==null||w.dispose(),(E=this._topCenterWidget)==null||E.dispose(),(O=this._topRightWidget)==null||O.dispose(),(x=this._middleLeftWidget)==null||x.dispose(),(N=this._middleRightWidget)==null||N.dispose(),(D=this._bottomLeftWidget)==null||D.dispose(),(P=this._bottomCenterWidget)==null||P.dispose(),(L=this._bottomRightWidget)==null||L.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let t;if(e.isMerged){const n=e.mergeInfo;t={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn,startX:n.startX,endX:n.endX,startY:n.startY,endY:n.endY}}else{const{actualRow:n,actualColumn:r,startX:o,endX:s,startY:a,endY:c}=e;t={startRow:n,endRow:n,startColumn:r,endColumn:r,startX:o,endX:s,startY:a,endY:c}}return t}}getValue(){return{...this._selectionModel.getValue(),style:this._selectionStyle}}getRange(){return this._selectionModel.getValue().rangeWithCoord}enableHelperSelection(){this._isHelperSelection=!0}disableHelperSelection(){this._isHelperSelection=!1}updateStyleId(e){this._selectionStyle!=null&&(this._selectionStyle.id=e)}_updateControl(e,t,n){const{startX:r,startY:o,endX:s,endY:a}=this._selectionModel,c=this._defaultStyle;e==null&&(e=c);const{stroke:d=c.stroke,widgets:u=c.widgets,hasAutoFill:h=c.hasAutoFill,AutofillStroke:m=c.AutofillStroke,strokeDash:g}=e;let{strokeWidth:_=c.strokeWidth,AutofillSize:f=c.AutofillSize,AutofillStrokeWidth:C=c.AutofillStrokeWidth}=e;const I=this._getScale(),w=(_+p.SELECTION_CONTROL_BORDER_BUFFER_WIDTH)/2/I;_/=I,f/=I,C/=I<1?1:I;const E=p.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/I,O=y.FIX_ONE_PIXEL_BLUR_OFFSET/I;this.leftControl.transformByState({height:a-o,left:-w+O,width:_,strokeWidth:E,top:-E/2+O}),this.leftControl.setProps({fill:d,stroke:p.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:a-o,left:s-r-w+O,width:_,strokeWidth:E,top:-E/2+O}),this.rightControl.setProps({fill:d,stroke:p.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:s-r+_,top:-w+O,left:-w+O,height:_,strokeWidth:E}),this.topControl.setProps({fill:d,stroke:p.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:s-r+_,top:a-o-w+O,height:_,left:-w+O,strokeWidth:E}),this.bottomControl.setProps({fill:d,stroke:p.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),g==null?this.dashRect.hide():(this.dashRect.transformByState({height:a-o-_/2,width:s-r-_/2,strokeWidth:_,left:_/2-1/I,top:_/2-1/I}),this.dashRect.setProps({strokeDashArray:[0,g]}),this.dashRect.show()),h===!0&&!this._hasWidgets(u)?(this.fillControl.setProps({fill:d,stroke:m,strokeScaleEnabled:!1}),this.fillControl.transformByState({width:f-C,height:f-C,left:s-r-f/2+C/2,top:a-o-f/2+C/2,strokeWidth:C}),this.fillControl.show()):this.fillControl.hide(),this._updateBackgroundControl(e),this._updateBackgroundTitle(e,t,n),this._updateWidgets(e),this.selectionShape.show(),this.selectionShape.translate(r,o),this._selectionStyle=e,this._rowHeaderWidth=t||0,this._columnHeaderHeight=n||0,this.selectionShape.makeDirtyNoDebounce(!0)}_initialize(){this._defaultStyle=p.getNormalSelectionStyle(this._themeService),this._selectionModel=new Zs;const e=this._zIndex;this._leftControl=new y.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightControl=new y.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topControl=new y.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomControl=new y.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new y.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new y.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new y.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new y.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._fillControl=new y.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._dashRect=new y.Rect("__SpreadsheetDragDashControl__"+e,{zIndex:e+2,evented:!1,stroke:"#fff"});const t=[this._fillControl,this._leftControl,this._rightControl,this._topControl,this._bottomControl,this._backgroundControlTop,this._backgroundControlMiddleLeft,this._backgroundControlMiddleRight,this._backgroundControlBottom,this._dashRect];this._widgetRects=this._initialWidget(),this._selectionShape=new y.Group("__SpreadsheetSelectionShape__"+e,...t,...this._widgetRects),this._selectionShape.hide(),this._selectionShape.evented=!1,this._selectionShape.zIndex=e,this.getScene().addObject(this._selectionShape,zs),this._initialTitle()}_initialTitle(){const e=this._zIndex;this._rowHeaderBackground=new y.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new y.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new y.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new y.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new y.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new y.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],y.DEFAULT_SELECTION_LAYER_INDEX)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new y.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new y.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new y.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new y.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new y.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new y.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new y.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new y.Rect("__SpreadSheetSelectionBottomRightWidget__"+e,{zIndex:e+1}),[this._topLeftWidget,this._topCenterWidget,this._topRightWidget,this._middleLeftWidget,this._middleRightWidget,this._bottomLeftWidget,this._bottomCenterWidget,this._bottomRightWidget]}_updateBackgroundTitle(e,t,n){const{startX:r,startY:o,endX:s,endY:a,rangeType:c}=this._selectionModel,d=this._defaultStyle;e==null&&(e=d);const u=this._getScale(),{stroke:h,hasRowHeader:m,rowHeaderFill:g=d.rowHeaderFill,rowHeaderStroke:_=d.rowHeaderStroke,hasColumnHeader:f,columnHeaderFill:C=d.columnHeaderFill,columnHeaderStroke:I=d.columnHeaderStroke}=e;let{rowHeaderStrokeWidth:w=d.rowHeaderStrokeWidth,columnHeaderStrokeWidth:E=d.columnHeaderStrokeWidth}=e;if(w/=u,E/=u,f===!0){let O=C;this._isHeaderHighlight&&c===l.RANGE_TYPE.COLUMN&&(O=new l.ColorKit(h).setAlpha(Pr).toString()),this._columnHeaderBackground.setProps({fill:O}),this._columnHeaderBackground.resize(s-r,n),this._columnHeaderBorder.setProps({fill:I}),this._columnHeaderBorder.transformByState({width:s-r,height:E,top:n-E+1/u}),this._columnHeaderGroup.show(),this._columnHeaderGroup.translate(r,0)}else this._columnHeaderGroup.hide();if(this._columnHeaderGroup.makeDirty(!0),m===!0){let O=g;this._isHeaderHighlight&&c===l.RANGE_TYPE.ROW&&(O=new l.ColorKit(h).setAlpha(Pr).toString()),this._rowHeaderBackground.setProps({fill:O}),this._rowHeaderBackground.resize(t,a-o),this._rowHeaderBorder.setProps({fill:_}),this._rowHeaderBorder.transformByState({width:w,height:a-o,left:t-w+1/u}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,o)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){const{startX:t,startY:n,endX:r,endY:o}=this._selectionModel,s=this._defaultStyle;e==null&&(e=s);const a=this._getScale(),{fill:c=s.fill}=e;let{strokeWidth:d=s.strokeWidth}=e;d/=a;const u=this._selectionModel.highlightToSelection();if(!u){this._backgroundControlTop.resize(r-t,o-n),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:m,endX:g,endY:_}=u,f=d/2,C={left:-f,top:-f,width:r-t+f*2,height:m-n+f};C.height<0&&(C.width=0,C.height=0),this._backgroundControlTop.transformByState(C);const I={left:-f,top:m-n,width:h-t+f,height:_-m};I.width<0&&(I.width=0,I.height=0),this._backgroundControlMiddleLeft.transformByState(I);const w={left:g-t-f,top:m-n,width:r-g+f*2,height:_-m};w.width<0&&(w.width=0,w.height=0),this._backgroundControlMiddleRight.transformByState(w);const E={left:-f,top:_-n,width:r-t+f*2,height:o-_+f};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:n,endX:r,endY:o}=this._selectionModel,s=this._defaultStyle;e==null&&(e=s);const{stroke:a=s.stroke,widgets:c=s.widgets,widgetStroke:d=s.widgetStroke}=e,u=this._getScale();let{widgetSize:h=s.widgetSize,widgetStrokeWidth:m=s.widgetStrokeWidth}=e;h/=u,m/=u;const g={left:-h/2+m/2,center:(r-t)/2-h/2+m/2,right:r-t-h/2+m/2,top:-h/2,middle:(o-n)/2-h/2,bottom:o-n-h/2+m/2},_=h-m;this._widgetRects.forEach(f=>{f.setProps({fill:a,stroke:d})}),c.tl===!0?(this._topLeftWidget.transformByState({height:_,width:_,left:g.left,top:g.top,strokeWidth:m}),this._topLeftWidget.show()):this._topLeftWidget.hide(),c.tc===!0?(this._topCenterWidget.transformByState({height:_,width:_,left:g.center,top:g.top,strokeWidth:m}),this._topCenterWidget.show()):this._topCenterWidget.hide(),c.tr===!0?(this._topRightWidget.transformByState({height:_,width:_,left:g.right,top:g.top,strokeWidth:m}),this._topRightWidget.show()):this._topRightWidget.hide(),c.ml===!0?(this._middleLeftWidget.transformByState({height:_,width:_,left:g.left,top:g.middle,strokeWidth:m}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),c.mr===!0?(this._middleRightWidget.transformByState({height:_,width:_,left:g.right,top:g.middle,strokeWidth:m}),this._middleRightWidget.show()):this._middleRightWidget.hide(),c.bl===!0?(this._bottomLeftWidget.transformByState({height:_,width:_,left:g.left,top:g.bottom,strokeWidth:m}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),c.bc===!0?(this._bottomCenterWidget.transformByState({height:_,width:_,left:g.center,top:g.bottom,strokeWidth:m}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),c.br===!0?(this._bottomRightWidget.transformByState({height:_,width:_,left:g.right,top:g.bottom,strokeWidth:m}),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 n of t)if(e[n]===!0)return!0;return!0}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}}const Hr="__SpreadsheetHelperSelectionTempRect",Gs=35;class Lr{constructor(e,t,n,r,o){v(this,"_startOffsetX",0);v(this,"_startOffsetY",0);v(this,"_relativeSelectionPositionRow",0);v(this,"_relativeSelectionPositionColumn",0);v(this,"_relativeSelectionRowLength",0);v(this,"_relativeSelectionColumnLength",0);v(this,"_moveObserver");v(this,"_upObserver");v(this,"_helperSelection");v(this,"_scrollTimer");v(this,"_activeViewport");v(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});v(this,"_isInMergeState",!1);v(this,"_fillControlColors",[]);this._control=e,this._skeleton=t,this._scene=n,this._themeService=r,this._injector=o,this._initialControl(),this._initialWidget(),this._initialFill(),this._control.dispose$.subscribe(()=>{this.dispose()})}get isHelperSelection(){return this._control.isHelperSelection}dispose(){var e,t;(e=this._scrollTimer)==null||e.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(t=this._helperSelection)==null||t.dispose()}_getFreeze(){var t;return(t=this._injector.get(exports.SheetSkeletonManagerService).getCurrent())==null?void 0:t.skeleton.getWorksheetConfig().freeze}_isSelectionInViewport(e,t){const n=this._getFreeze()||{startRow:-1,startColumn:-1,xSplit:0,ySplit:0};switch(t.viewPortKey){case Q.VIEW_MAIN:return e.endRow>=n.startRow&&e.endColumn>=n.startColumn;case Q.VIEW_MAIN_TOP:case Q.VIEW_COLUMN_RIGHT:return e.endColumn>=n.startColumn&&e.startRow<n.startRow;case Q.VIEW_MAIN_LEFT:case Q.VIEW_ROW_BOTTOM:return e.endRow>=n.startRow&&e.startColumn<n.startColumn;case Q.VIEW_MAIN_LEFT_TOP:case Q.VIEW_COLUMN_LEFT:case Q.VIEW_ROW_TOP:case Q.VIEW_LEFT_TOP:return e.startRow<n.startRow&&e.startColumn<n.startColumn}}_clearObserverEvent(){this._scene.onPointerMoveObserver.remove(this._moveObserver),this._scene.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_initialControl(){const{leftControl:e,rightControl:t,topControl:n,bottomControl:r}=this._control;[e,t,n,r].forEach(o=>{o.onPointerEnterObserver.add(()=>{o.setCursor(y.CURSOR_TYPE.MOVE)}),o.onPointerLeaveObserver.add(()=>{o.resetCursor()}),o.onPointerDownObserver.add(this._controlEvent.bind(this))})}_controlMoving(e,t){var N;const n=this._scene,r=n.getScrollXYByRelativeCoords(y.Vector2.FromArray([e,t])),{scaleX:o,scaleY:s}=n.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(e,t,o,s,r),{row:c,column:d}=a,u=this._skeleton.getRowCount()-1,h=this._skeleton.getColumnCount()-1;let m=c+this._relativeSelectionPositionRow;m<0&&(m=0);let g=m+this._relativeSelectionRowLength;g>u&&(g=u,g-m<this._relativeSelectionRowLength&&(m=g-this._relativeSelectionRowLength));let _=d+this._relativeSelectionPositionColumn;_<0&&(_=0);let f=_+this._relativeSelectionColumnLength;f>h&&(f=h,f-_<this._relativeSelectionColumnLength&&(_=f-this._relativeSelectionColumnLength));const C=this._skeleton.getNoMergeCellPositionByIndex(m,_),I=this._skeleton.getNoMergeCellPositionByIndex(g,f),w=(C==null?void 0:C.startY)||0,E=(I==null?void 0:I.endY)||0,O=(C==null?void 0:C.startX)||0,x=(I==null?void 0:I.endX)||0;(N=this._helperSelection)==null||N.transformByState({left:O,top:w,width:x-O,height:E-w}),this._targetSelection={startY:w,endY:E,startX:O,endX:x,startRow:m,endRow:g,startColumn:_,endColumn:f},this._control.selectionMoving$.next(this._targetSelection)}_controlEvent(e){const{offsetX:t,offsetY:n}=e,r=this._scene,o=r.getRelativeCoord(y.Vector2.FromArray([t,n])),{x:s,y:a}=o,c=r.getScrollXYByRelativeCoords(o),{scaleX:d,scaleY:u}=r.getAncestorScale(),h=this._skeleton.getCellPositionByOffset(s,a,d,u,c);this._startOffsetX=s,this._startOffsetY=a;const{row:m,column:g}=h,{startRow:_,startColumn:f,endRow:C,endColumn:I}=this._control.model;let w=0,E=0;m<_?w-=1:m>C&&(w+=1),g<f?E-=1:g>I&&(E+=1),this._relativeSelectionPositionRow=_-m+w,this._relativeSelectionPositionColumn=f-g+E,this._relativeSelectionRowLength=C-_,this._relativeSelectionColumnLength=I-f;const O=this._control.selectionStyle,x=this._getScale();this.isHelperSelection&&(this._helperSelection=new y.Rect(Hr,{stroke:O.stroke,strokeWidth:O.strokeWidth/x}),r.addObject(this._helperSelection));const N=r.getViewport(Q.VIEW_MAIN),D=y.ScrollTimer.create(r);D.startScroll(s,a,N),this._scrollTimer=D,r.disableEvent(),this._moveObserver=r.onPointerMoveObserver.add(P=>{const{offsetX:L,offsetY:G}=P,{x:k,y:ee}=r.getRelativeCoord(y.Vector2.FromArray([L,G]));this._controlMoving(k,ee),r.setCursor(y.CURSOR_TYPE.MOVE),D.scrolling(k,ee,()=>{this._controlMoving(k,ee)})}),this._upObserver=r.onPointerUpObserver.add(()=>{var L,G;(L=this._helperSelection)==null||L.dispose();const P=this._scene;P.resetCursor(),this._clearObserverEvent(),P.enableEvent(),(G=this._scrollTimer)==null||G.dispose(),this._control.selectionMoved$.next(this._targetSelection)})}_initialWidget(){const{topLeftWidget:e,topCenterWidget:t,topRightWidget:n,middleLeftWidget:r,middleRightWidget:o,bottomLeftWidget:s,bottomCenterWidget:a,bottomRightWidget:c}=this._control,d=[y.CURSOR_TYPE.NORTH_WEST_RESIZE,y.CURSOR_TYPE.NORTH_RESIZE,y.CURSOR_TYPE.NORTH_EAST_RESIZE,y.CURSOR_TYPE.WEST_RESIZE,y.CURSOR_TYPE.EAST_RESIZE,y.CURSOR_TYPE.SOUTH_WEST_RESIZE,y.CURSOR_TYPE.SOUTH_RESIZE,y.CURSOR_TYPE.SOUTH_EAST_RESIZE];[e,t,n,r,o,s,a,c].forEach((u,h)=>{u.onPointerEnterObserver.add(()=>{u.setCursor(d[h])}),u.onPointerLeaveObserver.add(()=>{u.resetCursor()}),u.onPointerDownObserver.add(m=>{this._widgetEvent(m,d[h])})})}_widgetMoving(e,t,n){const r=this._scene,o=r.getScrollXYByRelativeCoords(y.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:a}=r.getAncestorScale(),c=this._skeleton.getCellPositionByOffset(e,t,s,a,o),{row:d,column:u}=c,{rowHeaderWidth:h,columnHeaderHeight:m}=this._skeleton;let g=this._relativeSelectionPositionRow,_=this._relativeSelectionPositionColumn,f=d,C=u;n===y.CURSOR_TYPE.NORTH_WEST_RESIZE?(g=d,_=u,f=this._relativeSelectionPositionRow,C=this._relativeSelectionPositionColumn):n===y.CURSOR_TYPE.NORTH_RESIZE?(g=d,_=this._relativeSelectionPositionColumn,f=this._relativeSelectionPositionRow,C=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):n===y.CURSOR_TYPE.NORTH_EAST_RESIZE?(g=d,_=this._relativeSelectionPositionColumn,f=this._relativeSelectionPositionRow,C=u):n===y.CURSOR_TYPE.WEST_RESIZE?(g=this._relativeSelectionPositionRow,_=u,f=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,C=this._relativeSelectionPositionColumn):n===y.CURSOR_TYPE.EAST_RESIZE?f=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:n===y.CURSOR_TYPE.SOUTH_WEST_RESIZE?(g=this._relativeSelectionPositionRow,_=u,f=d,C=this._relativeSelectionPositionColumn):n===y.CURSOR_TYPE.SOUTH_RESIZE&&(g=this._relativeSelectionPositionRow,_=this._relativeSelectionPositionColumn,f=d,C=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const{startRow:I,startColumn:w,endRow:E,endColumn:O}=this._swapPositions(g,_,f,C),x=this._skeleton.getNoMergeCellPositionByIndex(I,w),N=this._skeleton.getNoMergeCellPositionByIndex(E,O),D=(x==null?void 0:x.startY)||0,P=(N==null?void 0:N.endY)||0,L=(x==null?void 0:x.startX)||0,G=(N==null?void 0:N.endX)||0;this._targetSelection={startY:D,endY:P,startX:L,endX:G,startRow:g,endRow:f,startColumn:_,endColumn:C},this._control.update(this._targetSelection,h,m,this._control.selectionStyle),this._control.clearHighlight(),this._control.selectionScaling$.next(this._targetSelection)}_widgetEvent(e,t){const{offsetX:n,offsetY:r}=e,o=this._scene,s=o.getRelativeCoord(y.Vector2.FromArray([n,r])),{x:a,y:c}=s;this._startOffsetX=n,this._startOffsetY=r;const{startRow:d,startColumn:u,endRow:h,endColumn:m}=this._control.model;this._relativeSelectionPositionRow=d,this._relativeSelectionPositionColumn=u,this._relativeSelectionRowLength=h-d,this._relativeSelectionColumnLength=m-u,t===y.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=h,this._relativeSelectionPositionColumn=m):t===y.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=h:t===y.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=h:t===y.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=m:t===y.CURSOR_TYPE.SOUTH_WEST_RESIZE&&(this._relativeSelectionPositionColumn=m);const g=y.ScrollTimer.create(o);g.startScroll(a,c),this._scrollTimer=g,o.disableEvent(),this._moveObserver=o.onPointerMoveObserver.add(_=>{const{offsetX:f,offsetY:C}=_,{x:I,y:w}=o.getRelativeCoord(y.Vector2.FromArray([f,C]));this._widgetMoving(I,w,t),o.setCursor(t),g.scrolling(I,w,()=>{this._widgetMoving(I,w,t)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var f;const _=this._scene;_.resetCursor(),this._clearObserverEvent(),_.enableEvent(),(f=this._scrollTimer)==null||f.dispose(),this._control.selectionScaled$.next(this._targetSelection)})}_initialFill(){const{fillControl:e}=this._control;e.onPointerEnterObserver.add(()=>{e.setCursor(y.CURSOR_TYPE.CROSSHAIR)}),e.onPointerLeaveObserver.add(()=>{e.resetCursor()}),e.onPointerDownObserver.add(this._fillEvent.bind(this))}_fillMoving(e,t){var G,k,ee;const n=this._scene,r=n.getScrollXY(this._activeViewport),{scaleX:o,scaleY:s}=n.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(e,t,o,s,r),{row:c,column:d}=a,u=n.getRelativeCoord(y.Vector2.FromArray([e,t])),h=this._skeleton.getRowCount()-1,m=this._skeleton.getColumnCount()-1;let g=this._relativeSelectionPositionRow,_=this._relativeSelectionPositionColumn,f=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,C=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,I=!1,w=!0;if((d<_||d>C)&&c>=g&&c<=f){const te=this._fillRuler(d,_,C,this._relativeSelectionColumnLength,m);_=te.startRowOrColumn,C=te.endRowOrColumn,I=te.isLighten,w=!1}else if((c<g||c>f)&&d>=_&&d<=C){const te=this._fillRuler(c,g,f,this._relativeSelectionRowLength,h);g=te.startRowOrColumn,f=te.endRowOrColumn,I=te.isLighten}else if(Math.abs(this._startOffsetX-u.x-r.x)/2>Math.abs(this._startOffsetY-u.y-r.y)){const te=this._fillRuler(d,_,C,this._relativeSelectionColumnLength,m);_=te.startRowOrColumn,C=te.endRowOrColumn,I=te.isLighten,w=!1}else{const te=this._fillRuler(c,g,f,this._relativeSelectionRowLength,h);g=te.startRowOrColumn,f=te.endRowOrColumn,I=te.isLighten}const E=this._skeleton.getNoMergeCellPositionByIndex(g,_),O=this._skeleton.getNoMergeCellPositionByIndex(f,C),x=(E==null?void 0:E.startY)||0,N=(O==null?void 0:O.endY)||0,D=(E==null?void 0:E.startX)||0,P=(O==null?void 0:O.endX)||0;I?this._controlHandler((te,W)=>{const V=new l.ColorKit(this._fillControlColors[W]).lighten(Gs).toRgbString();te.setProps({fill:V})}):this._controlHandler((te,W)=>{te.setProps({fill:this._fillControlColors[W]})});const L=p.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();g===f&&w===!0||_===C&&w===!1?(G=this._helperSelection)==null||G.hide():((k=this._helperSelection)==null||k.transformByState({left:D-L/2,top:x-L/2,width:P-D,height:N-x}),(ee=this._helperSelection)==null||ee.show()),this._targetSelection={startY:x,endY:N,startX:D,endX:P,startRow:g,endRow:f,startColumn:_,endColumn:C},this._control.selectionFilling$.next(this._targetSelection)}_fillEvent(e){const{offsetX:t,offsetY:n}=e,r=this._scene,o=r.getRelativeCoord(y.Vector2.FromArray([t,n])),{x:s,y:a}=o;this._startOffsetX=s,this._startOffsetY=a;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 m=this._control.selectionStyle;let g=m==null?void 0:m.stroke,_=m==null?void 0:m.strokeWidth;const f=p.getNormalSelectionStyle(this._themeService);g==null&&(g=f.stroke),_==null&&(_=f.strokeWidth);const C=this._getScale();_/=C;const I=p.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/C,w=new l.ColorKit(g).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new y.Rect(Hr,{stroke:w,strokeWidth:_+I/2}),r.addObject(this._helperSelection)),this._activeViewport=r.getActiveViewportByCoord(y.Vector2.FromArray([t,n]));const E=r.getViewport(Q.VIEW_MAIN),O=y.ScrollTimer.create(r,this._activeViewport.viewPortKey===Q.VIEW_MAIN?y.ScrollTimerType.ALL:y.ScrollTimerType.NONE);O.startScroll(s,a,E),this._scrollTimer=O,r.disableEvent(),this._controlHandler(x=>{this._fillControlColors.push(x.fill)}),this._moveObserver=r.onPointerMoveObserver.add(x=>{var ee;const{offsetX:N,offsetY:D}=x,P=r.getActiveViewportByCoord(y.Vector2.FromArray([N,D])),{x:L,y:G}=r.getRelativeCoord(y.Vector2.FromArray([N,D]));this._fillMoving(L,G),r.setCursor(y.CURSOR_TYPE.CROSSHAIR);const k=this._targetSelection;if(E&&P&&((ee=this._activeViewport)==null?void 0:ee.viewPortKey)!==(P==null?void 0:P.viewPortKey)){let te;k.startRow!==c?(O.scrollTimerType=y.ScrollTimerType.Y,te={...k,endRow:k.startRow}):k.endRow!==u?(O.scrollTimerType=y.ScrollTimerType.Y,te={...k,startRow:k.endRow}):k.startColumn!==d?(O.scrollTimerType=y.ScrollTimerType.X,te={...k,endColumn:k.startColumn}):(O.scrollTimerType=y.ScrollTimerType.X,te={...k,startColumn:k.endColumn}),this._isSelectionInViewport(te,P)&&(E.scrollTo({x:O.scrollTimerType===y.ScrollTimerType.X?0:void 0,y:O.scrollTimerType===y.ScrollTimerType.Y?0:void 0}),this._activeViewport=P)}O.scrolling(L,G,()=>{this._fillMoving(L,G)})}),this._upObserver=r.onPointerUpObserver.add(()=>{var N,D;(N=this._helperSelection)==null||N.dispose();const x=this._scene;x.resetCursor(),this._clearObserverEvent(),x.enableEvent(),(D=this._scrollTimer)==null||D.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((P,L)=>{P.setProps({fill:this._fillControlColors[L]})}),this._fillControlColors=[]})}_hasMergeInRange(e,t,n,r){const o=this._skeleton.mergeData;if(!o)return!1;for(const s of o){const{startRow:a,startColumn:c,endRow:d,endColumn:u}=s,h={left:t,top:e,right:r,bottom:n},m={left:c,top:a,right:u,bottom:d};if(y.isRectIntersect(h,m))return!0}return!1}_swapPositions(e,t,n,r){const o=Math.min(e,n),s=Math.min(t,r),a=Math.max(e,n),c=Math.max(t,r);return{startRow:o,startColumn:s,endRow:a,endColumn:c}}_controlHandler(e){const{leftControl:t,rightControl:n,topControl:r,bottomControl:o,backgroundControlTop:s,backgroundControlMiddleLeft:a,backgroundControlMiddleRight:c,backgroundControlBottom:d,fillControl:u}=this._control,h=[t,n,r,o,s,a,c,d,u];for(let m=0,g=h.length;m<g;m++){const _=h[m];e(_,m)}}_fillRuler(e,t,n,r,o){let s=!1;if(e<t)if(this._isInMergeState&&e<t){const a=t-e,c=r+1,d=Math.ceil(a/c);let u=t-d*c;u<0&&(u=t-(d-1)*c),t=u}else t=e;else if(e>=t&&e<=n)s=!0,n=e;else if(this._isInMergeState&&e>n){const a=e-n,c=r+1,d=Math.ceil(a/c);let u=n+d*c;u>o&&(u=n+(d-1)*c),n=u}else n=e;return{rowOrColumn:e,startRowOrColumn:t,endRowOrColumn:n,isLighten:s}}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}}var Ks=Object.defineProperty,qs=Object.getOwnPropertyDescriptor,Js=(i,e,t,n)=>{for(var r=n>1?void 0:n?qs(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ks(e,t,r),r},kn=(i,e)=>(t,n)=>e(t,n,i);exports.SelectionRenderService=class{constructor(e,t,n,r){v(this,"hasSelection",!1);v(this,"_downObserver");v(this,"_moveObserver");v(this,"_upObserver");v(this,"_controlFillConfig$",new J.BehaviorSubject(null));v(this,"controlFillConfig$",this._controlFillConfig$.asObservable());v(this,"_selectionControls",[]);v(this,"_startSelectionRange",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});v(this,"_startOffsetX",0);v(this,"_startOffsetY",0);v(this,"_scrollTimer");v(this,"_cancelDownObserver");v(this,"_cancelUpObserver");v(this,"_skeleton");v(this,"_scene");v(this,"_isHeaderHighlight",!0);v(this,"_isDetectMergedCell",!0);v(this,"_selectionStyle");v(this,"_isSelectionEnabled",!0);v(this,"_isShowPreviousEnable",0);v(this,"_isRemainLastEnable",!0);v(this,"_isSkipRemainLastEnable",!1);v(this,"_selectionMoveEnd$",new J.BehaviorSubject([]));v(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());v(this,"_selectionMoving$",new J.Subject);v(this,"selectionMoving$",this._selectionMoving$.asObservable());v(this,"_selectionMoveStart$",new J.Subject);v(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());v(this,"_activeViewport");this._themeService=e,this._shortcutService=t,this._sheetSkeletonManagerService=n,this._injector=r,this._selectionStyle=p.getNormalSelectionStyle(this._themeService)}enableHeaderHighlight(){this._isHeaderHighlight=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}enableDetectMergedCell(){this._isDetectMergedCell=!0}disableDetectMergedCell(){this._isDetectMergedCell=!1}setStyle(e){this._selectionStyle=e}resetStyle(){this.setStyle(p.getNormalSelectionStyle(this._themeService))}enableSelection(){this._isSelectionEnabled=!0}disableSelection(){this._isSelectionEnabled=!1}enableShowPrevious(){this._isShowPreviousEnable=!0}disableShowPrevious(){this._isShowPreviousEnable=!1}enableRemainLast(){this._isRemainLastEnable=!0}disableRemainLast(){this._isRemainLastEnable=!1}enableSkipRemainLast(){this._isSkipRemainLastEnable=!0}disableSkipRemainLast(){this._isSkipRemainLastEnable=!1}getViewPort(){return this._activeViewport}addControlToCurrentByRangeData(e){const t=this.getCurrentControls();if(!t)return;const{rangeWithCoord:n,primaryWithCoord:r}=e,o=this._skeleton;let s=e.style;s==null&&(s=p.getNormalSelectionStyle(this._themeService));const a=this._scene;if(a==null||o==null)return;const c=new Ci(a,t.length,this._isHeaderHighlight,this._themeService);new Lr(c,o,a,this._themeService,this._injector);const{rowHeaderWidth:d,columnHeaderHeight:u}=o;c.update(n,d,u,s,r),this._isHeaderHighlight?c.enableHeaderHighlight():c.disableHeaderHighlight(),t.push(c)}updateControlForCurrentByRangeData(e){const t=this.getCurrentControls();if(!t)return;const n=this._skeleton;if(n==null)return;const{rowHeaderWidth:r,columnHeaderHeight:o}=n;for(let s=0,a=e.length;s<a;s++){const{rangeWithCoord:c,primaryWithCoord:d,style:u}=e[s];t[s].update(c,r,o,u,d)}}refreshSelectionMoveStart(){this._selectionMoveStart$.next(this.getSelectionDataWithStyle())}changeRuntime(e,t,n){this._skeleton=e,this._scene=t,this._activeViewport=n||t.getViewports()[0]}getSelectionDataWithStyle(){return this._selectionControls.map(t=>t.getValue())}getCurrentControls(){return this._selectionControls}_clearSelectionControls(){const e=this.getCurrentControls();if(e.length>0){for(const t of e)t.dispose();e.length=0}}_getFreeze(){var t;return(t=this._sheetSkeletonManagerService.getCurrent())==null?void 0:t.skeleton.getWorksheetConfig().freeze}_getViewportByCell(e,t){if(!this._scene||e===void 0||t===void 0)return null;const n=this._getFreeze();if(!n||n.startRow<=0&&n.startColumn<=0)return this._scene.getViewport(Q.VIEW_MAIN);if(e>n.startRow&&t>n.startColumn)return this._scene.getViewport(Q.VIEW_MAIN);if(e<=n.startRow&&t<=n.startColumn)return this._scene.getViewport(Q.VIEW_MAIN_LEFT_TOP);if(e<=n.startRow&&t>n.startColumn)return this._scene.getViewport(Q.VIEW_MAIN_TOP);if(e>n.startRow&&t<=n.startColumn)return this._scene.getViewport(Q.VIEW_MAIN_LEFT)}getActiveSelections(){const e=this.getCurrentControls();if(e&&e.length>0)return e==null?void 0:e.map(n=>{const r=n.model,o=r.currentCell;let s=null;return o&&(s={actualRow:o.actualRow,actualColumn:o.actualColumn,isMerged:o.isMerged,isMergedMainCell:o.isMergedMainCell,startRow:o.mergeInfo.startRow,startColumn:o.mergeInfo.startColumn,endRow:o.mergeInfo.endRow,endColumn:o.mergeInfo.endColumn}),{range:{startRow:r.startRow,startColumn:r.startColumn,endRow:r.endRow,endColumn:r.endColumn},primary:s}})}getActiveRange(){const e=this.getCurrentControls(),t=e&&e[e.length-1].model;return t&&{startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}}getActiveSelection(){const e=this.getCurrentControls();return e&&e[e.length-1]}endSelection(){this._endSelection()}reset(){this._clearSelectionControls(),this._moveObserver=null,this._upObserver=null,this._downObserver=null}resetAndEndSelection(){this.endSelection(),this.reset()}eventTrigger(e,t=0,n=l.RANGE_TYPE.NORMAL,r,o=y.ScrollTimerType.ALL){if(this._isSelectionEnabled===!1)return;const s=this._skeleton,{offsetX:a,offsetY:c}=e,d=this._scene;if(d==null||s==null)return;r!=null&&(this._activeViewport=r);const u=d.getViewport(Q.VIEW_MAIN),h=d.getRelativeCoord(y.Vector2.FromArray([a,c]));let{x:m,y:g}=h;this._startOffsetX=m,this._startOffsetY=g;const _=d.getScrollXYByRelativeCoords(h),{scaleX:f,scaleY:C}=d.getAncestorScale();n===l.RANGE_TYPE.ROW?m=0:n===l.RANGE_TYPE.COLUMN&&(g=0);const I=this._getSelectedRangeWithMerge(m,g,f,C,_);if(!I)return!1;const{rangeWithCoord:w,primaryWithCoord:E}=I,{startRow:O,startColumn:x,endColumn:N,endRow:D,startY:P,endY:L,startX:G,endX:k}=w,{rowHeaderWidth:ee,columnHeaderHeight:te}=s,W={startColumn:x,startRow:O,endColumn:N,endRow:D,startY:P,endY:L,startX:G,endX:k,rangeType:n};this._startSelectionRange=W;let V=this.getActiveSelection();const re=this.getCurrentControls();if(!re)return!1;for(const Oe of re){if(e.button===2&&Oe.model.isInclude(W)){V=Oe;return}if(Oe.model.isEqual(W)){V=Oe;break}e.shiftKey||Oe.clearHighlight()}if(re.length>0&&!e.ctrlKey&&!e.shiftKey&&!this._isShowPreviousEnable&&!this._isRemainLastEnable){for(const Oe of re)Oe.dispose();re.length=0}const q=V&&V.model.currentCell;if(V&&e.shiftKey&&q){const{actualRow:Oe,actualColumn:Le,mergeInfo:Se}=q,he=Math.min(Oe,W.startRow,Se.startRow),ge=Math.max(Oe,W.endRow,Se.endRow),Ae=Math.min(Le,W.startColumn,Se.startColumn),we=Math.max(Le,W.endColumn,Se.endColumn),Pe=s.getMergeBounding(he,Ae,ge,we),Ue=s.getNoMergeCellPositionByIndex(Pe.startRow,Pe.startColumn),Ne=s.getNoMergeCellPositionByIndex(Pe.endRow,Pe.endColumn),it={startColumn:Pe.startColumn,startRow:Pe.startRow,endColumn:Pe.endColumn,endRow:Pe.endRow,startY:Ue.startY,endY:Ne.endY,startX:Ue.startX,endX:Ne.endX,rangeType:n},Fe=s.getCellByIndex(Oe,Le);this._startSelectionRange={startColumn:Fe.mergeInfo.startColumn,startRow:Fe.mergeInfo.startRow,endColumn:Fe.mergeInfo.endColumn,endRow:Fe.mergeInfo.endRow,startY:Fe.mergeInfo.startY||0,endY:Fe.mergeInfo.endY||0,startX:Fe.mergeInfo.startX||0,endX:Fe.mergeInfo.endX||0,rangeType:n},V.update(it,ee,te,this._selectionStyle,q)}else this._isRemainLastEnable&&V&&!e.ctrlKey&&!e.shiftKey&&!this._isSkipRemainLastEnable?V.update(W,ee,te,this._selectionStyle,E):(V=new Ci(d,re.length+t,this._isHeaderHighlight,this._themeService),new Lr(V,s,d,this._themeService,this._injector),V.update(W,ee,te,this._selectionStyle,E),re.push(V));this._selectionMoveStart$.next(this.getSelectionDataWithStyle()),this.hasSelection=!0,this._endSelection(),d.disableEvent();const ae=d.getActiveViewportByCoord(y.Vector2.FromArray([m,g])),Ie=y.ScrollTimer.create(this._scene,o);Ie.startScroll((u==null?void 0:u.left)??0,(u==null?void 0:u.top)??0,u),this._scrollTimer=Ie,this._addCancelObserver(),(n===l.RANGE_TYPE.ROW||n===l.RANGE_TYPE.COLUMN)&&this._moving(m,g,V,n);let de=0,Ee=0,be=m,De=g;this._moveObserver=d.onPointerMoveObserver.add(Oe=>{var Fe;const{offsetX:Le,offsetY:Se}=Oe,{x:he,y:ge}=d.getRelativeCoord(y.Vector2.FromArray([Le,Se]));this._moving(he,ge,V,n);let Ae=he,we=ge;const Pe=this.getActiveSelection(),Ue=(Fe=this._sheetSkeletonManagerService.getCurrent())==null?void 0:Fe.skeleton.getWorksheetConfig().freeze,Ne=Pe==null?void 0:Pe.model,it=d.getActiveViewportByCoord(y.Vector2.FromArray([Le,Se]))??this._getViewportByCell(Ne==null?void 0:Ne.endRow,Ne==null?void 0:Ne.endColumn);if(ae&&it&&u){const pt=be<u.left&&he>u.left||be>u.left&&he<u.left,ft=De<u.top&&ge>u.top||De>u.top&&ge<u.top;pt&&(de+=1),ft&&(Ee+=1);const $e=ae.viewPortKey,Ve=it.viewPortKey;if($e===Q.VIEW_ROW_TOP)Se<u.top&&((Ne==null?void 0:Ne.endRow)??0)<((Ue==null?void 0:Ue.startRow)??0)?we=u.top:ft&&Ee%2===1&&u.scrollTo({y:0});else if($e===Q.VIEW_COLUMN_LEFT)Le<u.left&&((Ne==null?void 0:Ne.endColumn)??0)<((Ue==null?void 0:Ue.startColumn)??0)?Ae=u.left:pt&&de%2===1&&u.scrollTo({x:0});else if($e===Ve){let He=!1,Qe=!1;$e===Q.VIEW_MAIN_LEFT_TOP?(He=!0,Qe=!0):$e===Q.VIEW_MAIN_TOP?Qe=!0:$e===Q.VIEW_MAIN_LEFT&&(He=!0),((Ne==null?void 0:Ne.endRow)??0)>((Ue==null?void 0:Ue.startRow)??0)&&(Qe=!1),((Ne==null?void 0:Ne.endColumn)??0)>((Ue==null?void 0:Ue.startColumn)??0)&&(He=!1),He&&(Ae=u.left),Qe&&(we=u.top)}else{const He={x:ae.scrollX,y:ae.scrollY},Qe={x:it.scrollX,y:it.scrollY},dn=He.x!==Qe.x&&pt&&de%2===1,un=He.y!==Qe.y&&ft&&Ee%2===1;(dn||un)&&(u.scrollTo({x:dn?He.x:void 0,y:un?He.y:void 0}),dn||(Ae=u.left),un||(we=u.top)),($e===Q.VIEW_MAIN_LEFT_TOP&&Ve===Q.VIEW_MAIN_LEFT||Ve===Q.VIEW_MAIN_LEFT_TOP&&$e===Q.VIEW_MAIN_LEFT)&&(Ae=u.left),($e===Q.VIEW_MAIN_LEFT_TOP&&Ve===Q.VIEW_MAIN_TOP||Ve===Q.VIEW_MAIN_LEFT_TOP&&$e===Q.VIEW_MAIN_TOP)&&(we=u.top)}be=he,De=ge}Ie.scrolling(Ae,we,()=>{this._moving(he,ge,V,n)})}),this._upObserver=d.onPointerUpObserver.add(Oe=>{this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}),this._shortcutService.setDisable(!0)}convertSelectionRangeToData(e){const{range:t,primary:n,style:r}=e;let o=this.convertRangeDataToSelection(t);return o==null&&(o={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1,startY:0,endY:0,startX:0,endX:0,rangeType:l.RANGE_TYPE.NORMAL}),{rangeWithCoord:o,primaryWithCoord:this.convertCellRangeToInfo(n),style:r}}convertRangeDataToSelection(e){const{startRow:t,startColumn:n,endRow:r,endColumn:o,rangeType:s}=e,a=this._scene,c=this._skeleton;if(a==null||c==null)return;a.getAncestorScale();const d=c.getNoMergeCellPositionByIndex(t,n),u=c.getNoMergeCellPositionByIndex(r,o);return{startRow:t,startColumn:n,endRow:r,endColumn:o,rangeType:s,startY:(d==null?void 0:d.startY)||0,endY:(u==null?void 0:u.endY)||0,startX:(d==null?void 0:d.startX)||0,endX:(u==null?void 0:u.endX)||0}}convertCellRangeToInfo(e){if(e==null)return;const t=this._scene,n=this._skeleton;if(t==null||n==null)return;const{actualRow:r,actualColumn:o,isMerged:s,isMergedMainCell:a,startRow:c,startColumn:d,endRow:u,endColumn:h}=e,m=n.getNoMergeCellPositionByIndex(r,o),g=n.getNoMergeCellPositionByIndex(c,d),_=n.getNoMergeCellPositionByIndex(u,h);return{actualRow:r,actualColumn:o,isMerged:s,isMergedMainCell:a,startX:m.startX,startY:m.startY,endX:m.endX,endY:m.endY,mergeInfo:{startRow:c,startColumn:d,endRow:u,endColumn:h,startY:(g==null?void 0:g.startY)||0,endY:(_==null?void 0:_.endY)||0,startX:(g==null?void 0:g.startX)||0,endX:(_==null?void 0:_.endX)||0}}}_moving(e,t,n,r){const o=this._skeleton,s=this._scene;if(s==null||o==null)return!1;const{startRow:a,startColumn:c,endRow:d,endColumn:u}=this._startSelectionRange,{startRow:h,endRow:m,startColumn:g,endColumn:_}=(n==null?void 0:n.model)||{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1},f=s.getViewport(Q.VIEW_MAIN),C=this._getViewportByCell(m,_)??f,I=s.getScrollXYByRelativeCoords(y.Vector2.FromArray([this._startOffsetX,this._startOffsetY]),C),{scaleX:w,scaleY:E}=s.getAncestorScale(),{rowHeaderWidth:O,columnHeaderHeight:x}=o;r===l.RANGE_TYPE.ROW?e=1/0:r===l.RANGE_TYPE.COLUMN&&(t=1/0);const N=this._getSelectedRangeWithMerge(e,t,w,E,I);if(!N)return!1;const{rangeWithCoord:D,primaryWithCoord:P}=N,{startRow:L,startColumn:G,endColumn:k,endRow:ee}=D,te=Math.min(L,a),W=Math.min(G,c),V=Math.max(ee,d),re=Math.max(k,u);let q={startRow:te,startColumn:W,endRow:V,endColumn:re};if(this._isDetectMergedCell&&(q=o.getSelectionBounding(te,W,V,re)),!q)return!1;const{startRow:ae,startColumn:Ie,endRow:de,endColumn:Ee}=q,be=o.getNoMergeCellPositionByIndex(ae,Ie),De=o.getNoMergeCellPositionByIndex(de,Ee),Oe={startColumn:Ie,startRow:ae,endColumn:Ee,endRow:de,startY:(be==null?void 0:be.startY)||0,endY:(De==null?void 0:De.endY)||0,startX:(be==null?void 0:be.startX)||0,endX:(De==null?void 0:De.endX)||0};(g!==Ie||h!==ae||_!==Ee||m!==de)&&n!=null&&(n.update(Oe,O,x),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_endSelection(){var n,r;const e=this._scene;if(e==null)return;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),e.enableEvent(),(n=this._scrollTimer)==null||n.dispose();const t=(r=e.getEngine())==null?void 0:r.activeScene;t==null||t.onPointerDownObserver.remove(this._cancelDownObserver),t==null||t.onPointerUpObserver.remove(this._cancelUpObserver)}_addCancelObserver(){var n;const e=this._scene;if(e==null)return;const t=(n=e.getEngine())==null?void 0:n.activeScene;t==null||t===e||(t.onPointerDownObserver.remove(this._cancelDownObserver),t.onPointerUpObserver.remove(this._cancelUpObserver),this._cancelDownObserver=t.onPointerDownObserver.add(r=>{this._endSelection()}),this._cancelUpObserver=t.onPointerUpObserver.add(r=>{this._endSelection()}))}_getSelectedRangeWithMerge(e,t,n,r,o){var I;if(this._isDetectMergedCell){const w=(I=this._skeleton)==null?void 0:I.calculateCellIndexByPosition(e,t,n,r,o),E=l.makeCellToSelection(w);return E==null?void 0:{primaryWithCoord:w,rangeWithCoord:E}}const s=this._skeleton;if(s==null)return;const a=s.getCellPositionByOffset(e,t,n,r,o),{row:c,column:d}=a,u=s.getNoMergeCellPositionByIndex(c,d),{startX:h,startY:m,endX:g,endY:_}=u,f={startY:m,endY:_,startX:h,endX:g,startRow:c,endRow:c,startColumn:d,endColumn:d};return{primaryWithCoord:{actualRow:c,actualColumn:d,isMerged:!1,isMergedMainCell:!1,startY:m,endY:_,startX:h,endX:g,mergeInfo:f},rangeWithCoord:f}}};exports.SelectionRenderService=Js([kn(0,j.Inject(l.ThemeService)),kn(1,R.IShortcutService),kn(2,j.Inject(exports.SheetSkeletonManagerService)),kn(3,j.Inject(j.Injector))],exports.SelectionRenderService);const Ze=j.createIdentifier("deprecated.univer.sheet.selection-render-service");var Qs=Object.defineProperty,ea=Object.getOwnPropertyDescriptor,ta=(i,e,t,n)=>{for(var r=n>1?void 0:n?ea(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Qs(e,t,r),r},Pt=(i,e)=>(t,n)=>e(t,n,i);const na=1e4,On=j.createIdentifier("univer.mark-selection-service");exports.MarkSelectionService=class extends l.Disposable{constructor(t,n,r,o,s,a,c){super();v(this,"_shapeMap",new Map);this._currentService=t,this._renderManagerService=n,this._selectionRenderService=r,this._commandService=o,this._sheetSkeletonManagerService=s,this._themeService=a,this._selectionManagerService=c}addShape(t,n=[],r=na){const o=this._currentService.getCurrentUniverSheetInstance(),s=o.getActiveSheet().getSheetId(),a=l.Tools.generateRandomId();return this._shapeMap.set(a,{selection:t,subUnitId:s,unitId:o.getUnitId(),zIndex:r,control:null,exits:n}),this.refreshShapes(),a}refreshShapes(){const t=this._currentService.getCurrentUniverSheetInstance().getUnitId(),n=this._currentService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();this._shapeMap.forEach(r=>{var w;const{unitId:o,subUnitId:s,selection:a,control:c,zIndex:d}=r;if(c&&c.dispose(),o!==t||s!==n)return;const{style:u}=a,{scene:h}=this._renderManagerService.getRenderById(o)||{},{rangeWithCoord:m,primaryWithCoord:g}=this._selectionRenderService.convertSelectionRangeToData(a),_=(w=this._sheetSkeletonManagerService.getCurrent())==null?void 0:w.skeleton;if(!h||!_)return;const{rowHeaderWidth:f,columnHeaderHeight:C}=_,I=new Ci(h,d,!1,this._themeService);I.update(m,f,C,u,g),r.control=I})}getShapeMap(){return this._shapeMap}removeShape(t){const n=this._shapeMap.get(t);if(!n)return;const{control:r}=n;r&&r.dispose(),this._shapeMap.delete(t)}removeAllShapes(){for(const t of this._shapeMap.values()){const{control:n}=t;n&&n.dispose()}this._shapeMap.clear()}};exports.MarkSelectionService=ta([Pt(0,l.IUniverInstanceService),Pt(1,y.IRenderManagerService),Pt(2,Ze),Pt(3,l.ICommandService),Pt(4,j.Inject(exports.SheetSkeletonManagerService)),Pt(5,j.Inject(l.ThemeService)),Pt(6,j.Inject(p.SelectionManagerService))],exports.MarkSelectionService);const ia=10,ra=6;function oa(){return l.Tools.generateRandomId(ra)}function sa(i){const e=i.match(/data-copy-id="([^\s]+)"/);return e&&e[1]?e[1]:null}class aa{constructor(){v(this,"_cache",new l.LRUMap(ia))}set(e,t){this._cache.set(e,t)}get(e){return this._cache.get(e)}del(e){this._cache.delete(e)}clear(){this._cache.clear()}}const Vn=new aa;var Vt=(i=>(i.COPY="COPY",i.CUT="CUT",i))(Vt||{});function la(i,e,t,n,r){const o=[],s=[];if(n.copyType===Vt.CUT){const{undos:a,redos:c}=ca(i,e,r);o.push(...c),s.push(...a)}else{const{undos:a,redos:c}=bo(e,t,r);o.push(...c),s.push(...a);const{undos:d,redos:u}=Ro(e,t,r);o.push(...u),s.push(...d);const{undos:h,redos:m}=Io(e,t,r);o.push(...m),s.push(...h);const{undos:g,redos:_}=Ki(e,t,r);o.push(..._),s.push(...g)}return{undos:s,redos:o}}function ca(i,e,t){let n=[],r=[];const{range:o,subUnitId:s,unitId:a}=i,{range:c,subUnitId:d}=e;if(o&&c){const u=t.get(l.IUniverInstanceService),h=t.get(p.SheetInterceptorService),m=u.getUniverSheetInstance(a),g=m==null?void 0:m.getSheetBySheetId(s),_=m==null?void 0:m.getSheetBySheetId(d);if(g&&_){const f=new l.ObjectMatrix,C=new l.ObjectMatrix,I=(q,ae)=>({startRow:q,endRow:q,startColumn:ae,endColumn:ae}),w=g.getCellMatrix(),E=_.getCellMatrix();l.Range.foreach(o,(q,ae)=>{f.setValue(q,ae,w.getValue(q,ae)),C.setValue(q,ae,null)});const O=new l.ObjectMatrix;l.Range.foreach(c,(q,ae)=>{O.setValue(q,ae,E.getValue(q,ae))});const x=new l.ObjectMatrix;l.Range.foreach(o,(q,ae)=>{const Ie=I(q,ae),de=l.Rectangle.getRelativeRange(Ie,o),Ee=l.Rectangle.getPositionRange(de,c);x.setValue(Ee.startRow,Ee.startColumn,w.getValue(q,ae))});const N={from:{value:C.getMatrix(),subUnitId:s},to:{value:x.getMatrix(),subUnitId:d},unitId:a},D={from:{value:f.getMatrix(),subUnitId:s},to:{value:O.getMatrix(),subUnitId:d},unitId:a},P=h.onCommandExecute({id:p.MoveRangeCommand.id,params:{toRange:c,fromRange:o}}),L=g.getMergeData(),G=_.getMergeData(),k=L.filter(q=>l.Rectangle.intersects(q,o)),ee=G.filter(q=>l.Rectangle.intersects(q,c)),te=k.map(q=>l.Rectangle.getRelativeRange(q,o)).map(q=>l.Rectangle.getPositionRange(q,c)),W=p.getAddMergeMutationRangeByType(te).filter(q=>!G.some(ae=>l.Rectangle.equals(q,ae))),V=[{id:p.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:k}},{id:p.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:ee}},{id:p.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:d,ranges:W}}],re=[{id:p.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:d,ranges:W}},{id:p.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:d,ranges:ee}},{id:p.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:k}}];n=[{id:p.MoveRangeMutation.id,params:N},...P.redos,...V,{id:p.SetSelectionsOperation.id,params:{unitId:a,sheetId:d,pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:c}]}}],r=[{id:p.SetSelectionsOperation.id,params:{unitId:a,sheetId:s,pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:o}]}},...P.undos,...re,{id:p.MoveRangeMutation.id,params:D}]}}return{undos:r,redos:n}}function Ro(i,e,t){const{unitId:n,subUnitId:r,range:o}=i,s=[],a=[],{startColumn:c,startRow:d}=o,u=new l.ObjectMatrix;e.forValue((g,_,f)=>{u.setValue(g+d,_+c,{v:f.v})});const h={unitId:n,subUnitId:r,cellValue:u.getData()};s.push({id:p.SetRangeValuesMutation.id,params:h});const m=p.SetRangeValuesUndoMutationFactory(t,h);return a.push({id:p.SetRangeValuesMutation.id,params:m}),{undos:a,redos:s}}function Io(i,e,t){const n=[],r=[],{unitId:o,subUnitId:s,range:a}=i,{startColumn:c,startRow:d}=a,u=new l.ObjectMatrix;e.forValue((g,_,f)=>{var I;const C={s:f.s};(I=f.p)!=null&&I.body&&(C.p=f.p),u.setValue(g+d,_+c,C)});const h={unitId:o,subUnitId:s,cellValue:u.getData()};n.push({id:p.SetRangeValuesMutation.id,params:h});const m=p.SetRangeValuesUndoMutationFactory(t,h);return r.push({id:p.SetRangeValuesMutation.id,params:m}),{undos:r,redos:n}}function bo(i,e,t){const n=[],r=[],o=new l.ObjectMatrix,{unitId:s,subUnitId:a,range:c}=i,{startColumn:d,startRow:u}=c;if(e.forValue((h,m,g)=>{g.s&&o.setValue(h+u,m+d,{s:null})}),o.getLength()>0){const h={subUnitId:a,unitId:s,cellValue:o.getData()};n.push({id:p.SetRangeValuesMutation.id,params:h});const m=p.SetRangeValuesUndoMutationFactory(t,h);r.push({id:p.SetRangeValuesMutation.id,params:m})}return{undos:r,redos:n}}function Ki(i,e,t){const n=[],r=[],{unitId:o,subUnitId:s,range:a}=i,{startColumn:c,startRow:d,endColumn:u,endRow:h}=a;let m=!1;const g=[];if(e.forValue((C,I,w)=>{if(w.rowSpan){const E=w.colSpan||1,O={startRow:d+C,endRow:d+C+w.rowSpan-1,startColumn:c+I,endColumn:c+I+E-1};g.push(O),m=!0}else if(w.colSpan){const E=w.rowSpan||1,O={startRow:d+C,endRow:d+C+E-1,startColumn:c+I,endColumn:c+I+w.colSpan-1};g.push(O),m=!0}}),m){const I=t.get(l.IUniverInstanceService).getUniverSheetInstance(o),w=I==null?void 0:I.getSheetBySheetId(s);if(I&&w){const O=w.getMergeData().filter(D=>l.Rectangle.intersects({startRow:d,startColumn:c,endRow:h,endColumn:u},D)),x={unitId:o,subUnitId:s,ranges:O};n.push({id:p.RemoveWorksheetMergeMutation.id,params:x});const N=p.RemoveMergeUndoMutationFactory(t,x);r.push({id:p.AddWorksheetMergeMutation.id,params:N})}}const _={unitId:o,subUnitId:s,ranges:g};n.push({id:p.AddWorksheetMergeMutation.id,params:_});const f=p.AddMergeUndoMutationFactory(t,_);return r.push({id:p.RemoveWorksheetMergeMutation.id,params:f}),{undos:r,redos:n}}function Mo(i){let e=i.replace(/(\r\n|\n)/g,"\r");e.endsWith(`\r
|
|
1
|
+
"use strict";var os=Object.defineProperty;var ss=(i,e,t)=>e in i?os(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var C=(i,e,t)=>(ss(i,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@univerjs/core"),S=require("@univerjs/sheets"),I=require("@univerjs/ui"),D=require("@wendellhu/redi"),N=require("rxjs"),b=require("@univerjs/engine-render"),P=require("react"),ge=require("@univerjs/design"),K=require("@wendellhu/redi/react-bindings"),J=require("@univerjs/docs"),jr=require("rxjs/operators"),te=require("@univerjs/engine-formula"),zt=require("clsx"),as=require("@univerjs/engine-numfmt"),$r={InsertRow:!0,InsertColumn:!0,AddRowTop:!1,AddRowBottom:!1,AddColumnLeft:!1,AddColumnRight:!1,DeleteRow:!0,DeleteColumn:!0,HideRow:!1,ShowRow:!1,RowHeight:!1,HideColumn:!1,ShowColumn:!1,ColumnWidth:!1,DeleteCell:!0,ClearContent:!0,Matrix:!1},zr={undo:!0,redo:!0,paintFormat:!0,currencyFormat:!0,percentageFormat:!0,numberDecrease:!0,numberIncrease:!0,moreFormats:!0,font:!0,fontSize:!0,bold:!0,italic:!0,strikethrough:!0,underline:!0,textColor:!0,fillColor:!0,border:!0,horizontalAlignMode:!0,verticalAlignMode:!0,textWrapMode:!0,textRotateMode:!0,mergeCell:!0},Xr={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0,formulaBar:!0,rightMenu:!0,countBar:!0,sheetBar:!0},ls={layout:{sheetContainerConfig:Xr,rightMenuConfig:$r,toolbarConfig:zr}},Yr="SheetUI";function Yn(i,e){if(i==null)return;const t=e.getRenderById(i);if(t==null)return;const{mainComponent:n,scene:r,engine:o}=t;return{document:n,scene:r,engine:o}}const Ci={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},Bn=["零","一","二","三","四","五","六","七","八","九"],or=["","万","亿","万亿","亿亿"],cs=["","十","百","千"],Zr={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function $e(i){if(!i)return 0;let e=0,t=0,n=0,r=!1;const o=i.split("");for(let s=0;s<o.length;s++){const a=Ci[o[s]];if(typeof a<"u")n=a,s===o.length-1&&(t+=n);else{const c=Zr[o[s]],d=c.value;r=c.secUnit,r?(t=(t+n)*d,e+=t,t=0):t+=n*d,n=0}}return e+t}function ds(i){let e="",t="",n=0,r=!0;for(;i>0;){const o=i%10;o===0?r||(r=!0,t=Bn[o]+t):(r=!1,e=Bn[o],e+=cs[n],t=e+t),n++,i=Math.floor(i/10)}return t}function us(i){let e=0,t="",n="",r=!1;if(i===0)return Bn[0];for(;i>0;){const o=i%1e4;r&&(n=Bn[0]+n),t=ds(o),t+=o!==0?or[e]:or[0],n=t+n,r=o<1e3&&o>0,i=Math.floor(i/1e4),e++}return n}function hs(i){if(!i)return!1;let e=!0;if(i)if(i.length===1)i==="日"||i in Ci?e=!0:e=!1;else{const t=i.split("");for(let n=0;n<t.length;n++)if(!(t[n]in Ci||t[n]in Zr)){e=!1;break}}return e}function on(i){if(!i)return{isExtendNumber:!1};const e=/0|([1-9]+[0-9]*)/g,t=e.test(i);if(t){const n=i.match(e);if(n&&n.length>0){const r=n[n.length-1],o=i.lastIndexOf(r),s=i.substr(0,o),a=i.substr(o+r.length);return{isExtendNumber:!0,matchTxt:Number(r),beforeTxt:s,afterTxt:a}}return{isExtendNumber:!1}}return{isExtendNumber:t}}function ms(i){let e;return i.length===2&&(i==="周一"||i==="周二"||i==="周三"||i==="周四"||i==="周五"||i==="周六"||i==="周日")?e=!0:e=!1,e}function gs(i){let e;return i.length===3&&(i==="星期一"||i==="星期二"||i==="星期三"||i==="星期四"||i==="星期五"||i==="星期六"||i==="星期日")?e=!0:e=!1,e}function _s(i,e){let t=0;for(let n=0;n<i.length&&i[n]<e;n++)t++;return t}function Kt(i){let e=!0;const t=i[1]-i[0];for(let n=1;n<i.length;n++)if(i[n]-i[n-1]!==t){e=!1;break}return e}function Ss(i,e,t){const n=[],r=Math.floor(e/i),o=e%i;let s=0;if(r>0){for(let a=0;a<r;a++)for(let c=0;c<t.length;c++)n[t[c]+a*i]=s,s++;for(let a=0;a<t.length&&t[a]<o;a++)n[t[a]+i*r]=s,s++}else for(let a=0;a<t.length&&t[a]<o;a++)n[t[a]]=s,s++;return n}function at(i,e){const t=[];for(let n=1;n<=e;n++){const r=(n-1)%i.length,o=l.Tools.deepClone(i[r]);t.push({v:null,s:null,p:null,f:null,si:null,t:null,...o})}return t}function fs(i,e){var n;const t=[];for(let r=1;r<=e;r++){const o=(r-1)%i.length,s={s:(n=i[o])==null?void 0:n.s};t.push(s)}return t}function ps(i){let e=!0;const t=i[1]/i[0];for(let n=1;n<i.length;n++)if(i[n]/i[n-1]!==t){e=!1;break}return e}function vs(i){const e=[];for(let t=1;t<=i;t++)e.push(t);return e}function sr(i,e,t){var o,s,a,c;const n=[],r=[];for(let d=0;d<i.length;d++)r.push(Number((o=i[d])==null?void 0:o.v));if(i.length>2&&ps(r))for(let d=1;d<=e;d++){const u=(d-1)%i.length,h=l.Tools.deepClone(i[u]),m=Number((s=i[i.length-1])==null?void 0:s.v)*(Number((a=i[1])==null?void 0:a.v)/Number((c=i[0])==null?void 0:c.v))**d;h&&(h.v=m,n.push(h))}else{const d=vs(i.length);for(let u=1;u<=e;u++){const h=(u-1)%i.length,m=l.Tools.deepClone(i[h]),g=t===l.Direction.DOWN||t===l.Direction.RIGHT,_=Cs(i.length+u,r,d,g);m&&(m.v=_,n.push(m))}}return n}function Cs(i,e,t,n=!0){function r(h){let m=0;for(let g=0;g<h.length;g++)m+=h[g];return m/h.length}const o=r(t),s=r(e);let a=0,c=0;for(let h=0;h<t.length;h++)a+=(t[h]-o)*(e[h]-s),c+=(t[h]-o)*(t[h]-o);let d;c===0?d=n?1:-1:d=a/c;const u=s-d*o;return Math.round((u+d*i)*1e5)/1e5}function ar(i,e,t){var o;const n=[],r=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=e;s++){const a=(s-1)%i.length,c=l.Tools.deepClone(i[a]),d=`${(o=i[i.length-1])==null?void 0:o.v}`,u=d==null?void 0:d.match(r),h=u==null?void 0:u[u.length-1],m=Math.abs(Number(h)+t*s);if(!d||!h)continue;const g=d.lastIndexOf(h),_=d.substr(0,g)+m.toString()+d.substr(g+h.length);c&&(c.v=_,n.push(c))}return n}function It(i,e,t,n=0){var a,c;const r=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(n>=r.length)return[];const o=r[n],s=[];for(let d=1;d<=e;d++){const u=(d-1)%i.length,h=l.Tools.deepClone(i[u]);let m=0;if(((a=i[i.length-1])==null?void 0:a.v)===o[0])m=7+t*d;else{const _=`${(c=i[i.length-1])==null?void 0:c.v}`;if(_){const f=_.substr(_.length-1,1);m=$e(f)+t*d}}m<0&&(m=Math.ceil(Math.abs(m)/7)*7+m);const g=m%7;h&&(h.v=o[g],s.push(h))}return s}function lr(i,e,t){var r;const n=[];for(let o=1;o<=e;o++){const s=(o-1)%i.length,a=l.Tools.deepClone(i[s]),c=`${(r=i[i.length-1])==null?void 0:r.v}`,d=$e(c)+t*o;let u;d<=0?u="零":u=us(d),a&&(a.v=u,n.push(a))}return n}const $t={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 Is(i){let e=!1;return Object.keys($t).forEach(t=>{$t[t].includes(i)&&(e=!0)}),e}function si(i){let e="";const t=[];return Object.keys($t).forEach(n=>{$t[n].includes(i)&&(e=n,t.push(...$t[n]))}),{name:e,series:t}}function cr(i,e,t,n){var s;const r=n.length,o=[];for(let a=1;a<=e;a++){const c=(a-1)%i.length,d=l.Tools.deepClone(i[c]),u=`${(s=i[i.length-1])==null?void 0:s.v}`;let h=n.indexOf(u)+t*a;h<0&&(h+=Math.abs(t)*r);const m=h%r;d&&(d.v=n[m],o.push(d))}return o}function Rs(i,e){const t=[];let n;if(e.startRow<i.startRow)n=l.Direction.UP;else if(e.endRow>i.endRow)n=l.Direction.DOWN;else if(e.startColumn<i.startColumn)n=l.Direction.LEFT;else if(e.endColumn>i.endColumn)n=l.Direction.RIGHT;else return[];if(n===l.Direction.DOWN||n===l.Direction.UP){const r=i.endRow-i.startRow+1,o=e.endRow-e.startRow+1,s=Math.floor(o/r),a=o%r,c={startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:i.endColumn-i.startColumn};if(n===l.Direction.DOWN){for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow+(d+1)*r,col:i.startColumn},relativeRange:c});a>0&&t.push({repeatStartCell:{row:i.startRow+(s+1)*r,col:i.startColumn},relativeRange:{startRow:0,startColumn:0,endRow:a-1,endColumn:i.endColumn-i.startColumn}})}else{for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow-(d+1)*r,col:i.startColumn},relativeRange:c});a>0&&t.push({repeatStartCell:{row:i.startRow-(s+1)*r,col:i.startColumn},relativeRange:{startRow:r-a,endRow:r-1,startColumn:0,endColumn:i.endColumn-i.startColumn}})}}if(n===l.Direction.RIGHT||n===l.Direction.LEFT){const r=i.endColumn-i.startColumn+1,o=e.endColumn-e.startColumn+1,s=Math.floor(o/r),a=o%r,c={startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:i.endColumn-i.startColumn};if(n===l.Direction.RIGHT){for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow,col:i.startColumn+(d+1)*r},relativeRange:c});a>0&&t.push({repeatStartCell:{row:i.startRow,col:i.startColumn+(s+1)*r},relativeRange:{startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:a-1}})}else{for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow,col:i.startColumn-(d+1)*r},relativeRange:c});a>0&&t.push({repeatStartCell:{row:i.startRow,col:i.startColumn-(s+1)*r},relativeRange:{startRow:0,startColumn:r-a,endRow:i.endRow-i.startRow,endColumn:r-1}})}}return t}function Gr(i){const e=new l.ObjectMatrix;return i.forEach(t=>{const{startRow:n,startColumn:r,endRow:o,endColumn:s}=t;for(let a=n;a<=o;a++)for(let c=r;c<=s;c++)e.setValue(a,c,{v:null,p:null,f:null,si:null})}),e.getData()}const Kr={type:l.CommandType.COMMAND,id:"sheet.command.auto-fill",handler:async(i,e)=>!0},hn={id:"sheet.command.auto-clear-content",type:l.CommandType.COMMAND,handler:async(i,e)=>{const t=i.get(l.IUniverInstanceService),n=i.get(l.ICommandService),r=i.get(l.IUndoRedoService),o=t.getCurrentUniverSheetInstance(),s=o.getUnitId(),c=o.getActiveSheet().getSheetId(),{clearRange:d,selectionRange:u}=e,h={subUnitId:c,unitId:s,cellValue:Gr([d])},m=S.SetRangeValuesUndoMutationFactory(i,h);return n.executeCommand(S.SetSelectionsOperation.id,{selections:[{primary:{...u},range:{...u}}],unitId:s,subUnitId:c}),n.syncExecuteCommand(S.SetRangeValuesMutation.id,h)?(r.pushUndoRedo({unitID:s,undoMutations:[{id:S.SetRangeValuesMutation.id,params:m}],redoMutations:[{id:S.SetRangeValuesMutation.id,params:h}],undo(){return n.syncExecuteCommand(S.SetRangeValuesMutation.id,m)},redo(){return n.syncExecuteCommand(S.SetRangeValuesMutation.id,h)}}),!0):!1}};function ne(i){return i.getContextValue(l.FOCUSING_SHEET)&&i.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&!i.getContextValue(l.EDITOR_ACTIVATED)}function Di(i){return i.getContextValue(l.FOCUSING_SHEET)&&i.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&i.getContextValue(l.EDITOR_ACTIVATED)}function Ms(i){return i.getContextValue(l.EDITOR_ACTIVATED)}function qr(i){return i.getContextValue(l.FOCUSING_FORMULA_EDITOR)&&i.getContextValue(l.FOCUSING_UNIVER_EDITOR)}function bs(i){return i.getContextValue(l.FOCUSING_SHEET)&&i.getContextValue(l.EDITOR_ACTIVATED)&&i.getContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA)&&i.getContextValue(l.FOCUSING_UNIVER_EDITOR)}function Fn(i){return i.getContextValue(l.FOCUSING_SHEET)&&i.getContextValue(l.EDITOR_ACTIVATED)&&!i.getContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA)}var Se=(i=>(i.MAIN="__SpreadsheetRender__",i.ROW="__SpreadsheetRowHeader__",i.COLUMN="__SpreadsheetColumnHeader__",i.LEFT_TOP="__SpreadsheetLeftTopPlaceholder__",i))(Se||{}),V=(i=>(i.VIEW_MAIN="viewMain",i.VIEW_MAIN_LEFT_TOP="viewMainLeftTop",i.VIEW_MAIN_TOP="viewMainTop",i.VIEW_MAIN_LEFT="viewMainLeft",i.VIEW_ROW_TOP="viewRowTop",i.VIEW_ROW_BOTTOM="viewRowBottom",i.VIEW_COLUMN_LEFT="viewColumnLeft",i.VIEW_COLUMN_RIGHT="viewColumnRight",i.VIEW_LEFT_TOP="viewLeftTop",i))(V||{});const dr=0,qe=2,ws=3,Ii=[10,400],ur=1001;var Ts=Object.defineProperty,Es=Object.getOwnPropertyDescriptor,ys=(i,e,t,n)=>{for(var r=n>1?void 0:n?Es(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ts(e,t,r),r},hr=(i,e)=>(t,n)=>e(t,n,i);exports.SheetSkeletonManagerService=class{constructor(e,t){C(this,"_currentSkeleton",{unitId:"",sheetId:""});C(this,"_sheetSkeletonParam",[]);C(this,"_currentSkeleton$",new N.BehaviorSubject(null));C(this,"currentSkeleton$",this._currentSkeleton$.asObservable());C(this,"_currentSkeletonBefore$",new N.BehaviorSubject(null));C(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._currentUniverService=e,this._localeService=t}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParam=[]}getCurrent(){return this._getCurrentBySearch(this._currentSkeleton)}setCurrent(e){const t=this._getCurrentBySearch(e);if(t!=null)this._reCalculate(t);else{const{unitId:r,sheetId:o}=e,s=this._currentUniverService.getUniverSheetInstance(e.unitId),a=s==null?void 0:s.getSheetBySheetId(e.sheetId);if(a==null||s==null)return;const c=this._buildSkeleton(a,s);this._sheetSkeletonParam.push({unitId:r,sheetId:o,skeleton:c,dirty:!1})}this._currentSkeleton=e;const n=this.getCurrent();return this._currentSkeletonBefore$.next(n),this._currentSkeleton$.next(n),this.getCurrent()}reCalculate(){const e=this.getCurrent();e!=null&&this._reCalculate(e)}_reCalculate(e){e.dirty&&(e.skeleton.makeDirty(!0),e.dirty=!1),e.skeleton.calculate()}makeDirtyCurrent(e=!0){this.makeDirty(this._currentSkeleton,e)}makeDirty(e,t=!0){const n=this._getCurrentBySearch(e);n!=null&&(n.dirty=t)}_getCurrentBySearch(e){const t=this._sheetSkeletonParam.find(n=>n.unitId===e.unitId&&n.sheetId===e.sheetId);return t!=null&&(t.commandId=e.commandId),t}_buildSkeleton(e,t){const n=e.getConfig();return b.SpreadsheetSkeleton.create(e,n,e.getCellMatrix(),t.getStyles(),this._localeService)}};exports.SheetSkeletonManagerService=ys([hr(0,l.IUniverInstanceService),hr(1,D.Inject(l.LocaleService))],exports.SheetSkeletonManagerService);class Os{constructor(){C(this,"_startColumn",-1);C(this,"_startRow",-1);C(this,"_endColumn",-1);C(this,"_endRow",-1);C(this,"_startX",0);C(this,"_startY",0);C(this,"_endX",0);C(this,"_endY",0);C(this,"_currentCell");C(this,"_rangeType",l.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._currentCell}get rangeType(){return this._rangeType}isEqual(e){const{startColumn:t,startRow:n,endColumn:r,endRow:o}=this,{startColumn:s,startRow:a,endColumn:c,endRow:d}=e;return t===s&&n===a&&r===c&&o===d}isInclude(e){const{startColumn:t,startRow:n,endColumn:r,endRow:o}=this,{startColumn:s,startRow:a,endColumn:c,endRow:d}=e;return!(c<t||s>r||a>o||d<n)}highlightToSelection(){return l.makeCellToSelection(this._currentCell)}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._currentCell}getRangeType(){return this._rangeType}getValue(){return{rangeWithCoord:{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},primaryWithCoord:this._currentCell}}setValue(e,t){const{startColumn:n,startRow:r,endColumn:o,endRow:s,startX:a,startY:c,endX:d,endY:u,rangeType:h}=e;this._startColumn=n,this._startRow=r,this._endColumn=o,this._endRow=s,this._startX=a,this._startY=c,this._endX=d,this._endY=u,h!=null&&(this._rangeType=h),this.setCurrentCell(t)}setCurrentCell(e){e&&(this._currentCell=e)}clearCurrentCell(){this._currentCell=null}}const mr=.3;class Wn{constructor(e,t,n=!0,r){C(this,"_leftControl");C(this,"_rightControl");C(this,"_topControl");C(this,"_bottomControl");C(this,"_backgroundControlTop");C(this,"_backgroundControlBottom");C(this,"_backgroundControlMiddleLeft");C(this,"_backgroundControlMiddleRight");C(this,"_fillControl");C(this,"_selectionShape");C(this,"_rowHeaderBackground");C(this,"_rowHeaderBorder");C(this,"_rowHeaderGroup");C(this,"_rowHeaderHighlight");C(this,"_columnHeaderBackground");C(this,"_columnHeaderBorder");C(this,"_columnHeaderGroup");C(this,"_columnHeaderHighlight");C(this,"_topLeftWidget");C(this,"_topCenterWidget");C(this,"_topRightWidget");C(this,"_middleLeftWidget");C(this,"_middleRightWidget");C(this,"_bottomLeftWidget");C(this,"_bottomCenterWidget");C(this,"_bottomRightWidget");C(this,"_dashRect");C(this,"_selectionModel");C(this,"_selectionStyle");C(this,"_rowHeaderWidth",0);C(this,"_columnHeaderHeight",0);C(this,"_widgetRects",[]);C(this,"_dispose$",new N.BehaviorSubject(this));C(this,"dispose$",this._dispose$.asObservable());C(this,"selectionMoving$",new N.Subject);C(this,"selectionMoved$",new N.Subject);C(this,"selectionScaling$",new N.Subject);C(this,"selectionScaled$",new N.Subject);C(this,"selectionFilling$",new N.Subject);C(this,"_selectionFilled$",new N.Subject);C(this,"selectionFilled$",this._selectionFilled$.asObservable());C(this,"_defaultStyle");C(this,"_currentStyle");C(this,"_isHelperSelection",!0);this._scene=e,this._zIndex=t,this._isHeaderHighlight=n,this._themeService=r,this._initialize()}get zIndex(){return this._zIndex}get leftControl(){return this._leftControl}get rightControl(){return this._rightControl}get topControl(){return this._topControl}get bottomControl(){return this._bottomControl}get fillControl(){return this._fillControl}get backgroundControlTop(){return this._backgroundControlTop}get backgroundControlBottom(){return this._backgroundControlBottom}get backgroundControlMiddleLeft(){return this._backgroundControlMiddleLeft}get backgroundControlMiddleRight(){return this._backgroundControlMiddleRight}get selectionShape(){return this._selectionShape}get model(){return this._selectionModel}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 selectionStyle(){return this._selectionStyle}get dashRect(){return this._dashRect}get isHelperSelection(){return this._isHelperSelection}setEvent(e){this.leftControl.evented=e,this.rightControl.evented=e,this.topControl.evented=e,this.bottomControl.evented=e}enableHeaderHighlight(){this._isHelperSelection=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}refreshSelectionFilled(e){this._selectionFilled$.next(e)}updateStyle(e){this._updateControl(e,this._rowHeaderWidth,this._columnHeaderHeight)}update(e,t=0,n=0,r,o){this._selectionModel.setValue(e,o),r==null&&(r=this._selectionStyle),this._updateControl(r,t,n)}clearHighlight(){this._selectionModel.clearCurrentCell(),this._updateControl(this._selectionStyle,this._rowHeaderWidth,this._columnHeaderHeight)}getScene(){return this._scene}dispose(){var e,t,n,r,o,s,a,c,d,u,h,m,g,_,f,v,R,M,T,w,E,y,x,O,A;(e=this._leftControl)==null||e.dispose(),(t=this._rightControl)==null||t.dispose(),(n=this._topControl)==null||n.dispose(),(r=this._bottomControl)==null||r.dispose(),(o=this._backgroundControlTop)==null||o.dispose(),(s=this._backgroundControlMiddleLeft)==null||s.dispose(),(a=this._backgroundControlMiddleRight)==null||a.dispose(),(c=this._backgroundControlBottom)==null||c.dispose(),(d=this._fillControl)==null||d.dispose(),(u=this._selectionShape)==null||u.dispose(),(h=this._rowHeaderBackground)==null||h.dispose(),(m=this._rowHeaderBorder)==null||m.dispose(),(g=this._rowHeaderGroup)==null||g.dispose(),(_=this._rowHeaderBackground)==null||_.dispose(),(f=this._columnHeaderBackground)==null||f.dispose(),(v=this._columnHeaderBorder)==null||v.dispose(),(R=this._columnHeaderGroup)==null||R.dispose(),(M=this._topLeftWidget)==null||M.dispose(),(T=this._topCenterWidget)==null||T.dispose(),(w=this._topRightWidget)==null||w.dispose(),(E=this._middleLeftWidget)==null||E.dispose(),(y=this._middleRightWidget)==null||y.dispose(),(x=this._bottomLeftWidget)==null||x.dispose(),(O=this._bottomCenterWidget)==null||O.dispose(),(A=this._bottomRightWidget)==null||A.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let t;if(e.isMerged){const n=e.mergeInfo;t={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn,startX:n.startX,endX:n.endX,startY:n.startY,endY:n.endY}}else{const{actualRow:n,actualColumn:r,startX:o,endX:s,startY:a,endY:c}=e;t={startRow:n,endRow:n,startColumn:r,endColumn:r,startX:o,endX:s,startY:a,endY:c}}return t}}getValue(){return{...this._selectionModel.getValue(),style:this._selectionStyle}}getRange(){return this._selectionModel.getValue().rangeWithCoord}enableHelperSelection(){this._isHelperSelection=!0}disableHelperSelection(){this._isHelperSelection=!1}updateStyleId(e){this._selectionStyle!=null&&(this._selectionStyle.id=e)}_updateControl(e,t,n){const{startX:r,startY:o,endX:s,endY:a}=this._selectionModel,c=this._defaultStyle;e==null&&(e=c),this._currentStyle=e;const{stroke:d=c.stroke,widgets:u=c.widgets,hasAutoFill:h=c.hasAutoFill,AutofillStroke:m=c.AutofillStroke,strokeDash:g}=e;let{strokeWidth:_=c.strokeWidth,AutofillSize:f=c.AutofillSize,AutofillStrokeWidth:v=c.AutofillStrokeWidth}=e;const R=this._getScale(),M=(_+S.SELECTION_CONTROL_BORDER_BUFFER_WIDTH)/2/R;_/=R,f/=R,v/=R<1?1:R;const T=S.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/R,w=b.FIX_ONE_PIXEL_BLUR_OFFSET/R;this.leftControl.transformByState({height:a-o,left:-M+w,width:_,strokeWidth:T,top:-T/2+w}),this.leftControl.setProps({fill:d,stroke:S.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:a-o,left:s-r-M+w,width:_,strokeWidth:T,top:-T/2+w}),this.rightControl.setProps({fill:d,stroke:S.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:s-r+_,top:-M+w,left:-M+w,height:_,strokeWidth:T}),this.topControl.setProps({fill:d,stroke:S.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:s-r+_,top:a-o-M+w,height:_,left:-M+w,strokeWidth:T}),this.bottomControl.setProps({fill:d,stroke:S.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),g==null?this.dashRect.hide():(this.dashRect.transformByState({height:a-o-_/2,width:s-r-_/2,strokeWidth:_,left:_/2-1/R,top:_/2-1/R}),this.dashRect.setProps({strokeDashArray:[0,g]}),this.dashRect.show()),h===!0&&!this._hasWidgets(u)?(this.fillControl.setProps({fill:d,stroke:m,strokeScaleEnabled:!1}),this.fillControl.transformByState({width:f-v,height:f-v,left:s-r-f/2+v/2,top:a-o-f/2+v/2,strokeWidth:v}),this.fillControl.show()):this.fillControl.hide(),this._updateBackgroundControl(e),this._updateBackgroundTitle(e,t,n),this._updateWidgets(e),this.selectionShape.show(),this.selectionShape.translate(r,o),this._selectionStyle=e,this._rowHeaderWidth=t||0,this._columnHeaderHeight=n||0,this.selectionShape.makeDirtyNoDebounce(!0)}_initialize(){this._defaultStyle=S.getNormalSelectionStyle(this._themeService),this._selectionModel=new Os;const e=this._zIndex;this._leftControl=new b.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightControl=new b.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topControl=new b.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomControl=new b.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new b.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new b.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new b.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new b.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._fillControl=new b.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._dashRect=new b.Rect("__SpreadsheetDragDashControl__"+e,{zIndex:e+2,evented:!1,stroke:"#fff"});const t=[this._fillControl,this._leftControl,this._rightControl,this._topControl,this._bottomControl,this._backgroundControlTop,this._backgroundControlMiddleLeft,this._backgroundControlMiddleRight,this._backgroundControlBottom,this._dashRect];this._widgetRects=this._initialWidget(),this._selectionShape=new b.Group("__SpreadsheetSelectionShape__"+e,...t,...this._widgetRects),this._selectionShape.hide(),this._selectionShape.evented=!1,this._selectionShape.zIndex=e;const n=this.getScene();n.addObject(this._selectionShape,ws),n.onTransformChangeObservable.add(r=>{r.type===b.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&this._updateControl(this._currentStyle,this._rowHeaderWidth,this._columnHeaderHeight)}),this._initialTitle()}_initialTitle(){const e=this._zIndex;this._rowHeaderBackground=new b.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new b.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new b.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new b.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new b.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new b.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],b.DEFAULT_SELECTION_LAYER_INDEX)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new b.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new b.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new b.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new b.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new b.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new b.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new b.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new b.Rect("__SpreadSheetSelectionBottomRightWidget__"+e,{zIndex:e+1}),[this._topLeftWidget,this._topCenterWidget,this._topRightWidget,this._middleLeftWidget,this._middleRightWidget,this._bottomLeftWidget,this._bottomCenterWidget,this._bottomRightWidget]}_updateBackgroundTitle(e,t,n){const{startX:r,startY:o,endX:s,endY:a,rangeType:c}=this._selectionModel,d=this._defaultStyle;e==null&&(e=d);const u=this._getScale(),{stroke:h,hasRowHeader:m,rowHeaderFill:g=d.rowHeaderFill,rowHeaderStroke:_=d.rowHeaderStroke,hasColumnHeader:f,columnHeaderFill:v=d.columnHeaderFill,columnHeaderStroke:R=d.columnHeaderStroke}=e;let{rowHeaderStrokeWidth:M=d.rowHeaderStrokeWidth,columnHeaderStrokeWidth:T=d.columnHeaderStrokeWidth}=e;if(M/=u,T/=u,f===!0){let w=v;this._isHeaderHighlight&&c===l.RANGE_TYPE.COLUMN&&(w=new l.ColorKit(h).setAlpha(mr).toString()),this._columnHeaderBackground.setProps({fill:w}),this._columnHeaderBackground.resize(s-r,n),this._columnHeaderBorder.setProps({fill:R}),this._columnHeaderBorder.transformByState({width:s-r,height:T,top:n-T+1/u}),this._columnHeaderGroup.show(),this._columnHeaderGroup.translate(r,0)}else this._columnHeaderGroup.hide();if(this._columnHeaderGroup.makeDirty(!0),m===!0){let w=g;this._isHeaderHighlight&&c===l.RANGE_TYPE.ROW&&(w=new l.ColorKit(h).setAlpha(mr).toString()),this._rowHeaderBackground.setProps({fill:w}),this._rowHeaderBackground.resize(t,a-o),this._rowHeaderBorder.setProps({fill:_}),this._rowHeaderBorder.transformByState({width:M,height:a-o,left:t-M+1/u}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,o)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){const{startX:t,startY:n,endX:r,endY:o}=this._selectionModel,s=this._defaultStyle;e==null&&(e=s);const a=this._getScale(),{fill:c=s.fill}=e;let{strokeWidth:d=s.strokeWidth}=e;d/=a;const u=this._selectionModel.highlightToSelection();if(!u){this._backgroundControlTop.resize(r-t,o-n),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:m,endX:g,endY:_}=u,f=d/2,v={left:-f,top:-f,width:r-t+f*2,height:m-n+f};v.height<0&&(v.width=0,v.height=0),this._backgroundControlTop.transformByState(v);const R={left:-f,top:m-n,width:h-t+f,height:_-m};R.width<0&&(R.width=0,R.height=0),this._backgroundControlMiddleLeft.transformByState(R);const M={left:g-t-f,top:m-n,width:r-g+f*2,height:_-m};M.width<0&&(M.width=0,M.height=0),this._backgroundControlMiddleRight.transformByState(M);const T={left:-f,top:_-n,width:r-t+f*2,height:o-_+f};T.height<0&&(T.width=0,T.height=0),this._backgroundControlBottom.transformByState(T),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:n,endX:r,endY:o}=this._selectionModel,s=this._defaultStyle;e==null&&(e=s);const{stroke:a=s.stroke,widgets:c=s.widgets,widgetStroke:d=s.widgetStroke}=e,u=this._getScale();let{widgetSize:h=s.widgetSize,widgetStrokeWidth:m=s.widgetStrokeWidth}=e;h/=u,m/=u;const g={left:-h/2+m/2,center:(r-t)/2-h/2+m/2,right:r-t-h/2+m/2,top:-h/2,middle:(o-n)/2-h/2,bottom:o-n-h/2+m/2},_=h-m;this._widgetRects.forEach(f=>{f.setProps({fill:a,stroke:d})}),c.tl===!0?(this._topLeftWidget.transformByState({height:_,width:_,left:g.left,top:g.top,strokeWidth:m}),this._topLeftWidget.show()):this._topLeftWidget.hide(),c.tc===!0?(this._topCenterWidget.transformByState({height:_,width:_,left:g.center,top:g.top,strokeWidth:m}),this._topCenterWidget.show()):this._topCenterWidget.hide(),c.tr===!0?(this._topRightWidget.transformByState({height:_,width:_,left:g.right,top:g.top,strokeWidth:m}),this._topRightWidget.show()):this._topRightWidget.hide(),c.ml===!0?(this._middleLeftWidget.transformByState({height:_,width:_,left:g.left,top:g.middle,strokeWidth:m}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),c.mr===!0?(this._middleRightWidget.transformByState({height:_,width:_,left:g.right,top:g.middle,strokeWidth:m}),this._middleRightWidget.show()):this._middleRightWidget.hide(),c.bl===!0?(this._bottomLeftWidget.transformByState({height:_,width:_,left:g.left,top:g.bottom,strokeWidth:m}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),c.bc===!0?(this._bottomCenterWidget.transformByState({height:_,width:_,left:g.center,top:g.bottom,strokeWidth:m}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),c.br===!0?(this._bottomRightWidget.transformByState({height:_,width:_,left:g.right,top:g.bottom,strokeWidth:m}),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 n of t)if(e[n]===!0)return!0;return!0}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}}const gr="__SpreadsheetHelperSelectionTempRect",xs=35;class _r{constructor(e,t,n,r,o){C(this,"_startOffsetX",0);C(this,"_startOffsetY",0);C(this,"_relativeSelectionPositionRow",0);C(this,"_relativeSelectionPositionColumn",0);C(this,"_relativeSelectionRowLength",0);C(this,"_relativeSelectionColumnLength",0);C(this,"_moveObserver");C(this,"_upObserver");C(this,"_helperSelection");C(this,"_scrollTimer");C(this,"_activeViewport");C(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});C(this,"_isInMergeState",!1);C(this,"_fillControlColors",[]);this._control=e,this._skeleton=t,this._scene=n,this._themeService=r,this._injector=o,this._initialControl(),this._initialWidget(),this._initialFill(),this._control.dispose$.subscribe(()=>{this.dispose()})}get isHelperSelection(){return this._control.isHelperSelection}dispose(){var e,t;(e=this._scrollTimer)==null||e.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(t=this._helperSelection)==null||t.dispose()}_getFreeze(){var t;return(t=this._injector.get(exports.SheetSkeletonManagerService).getCurrent())==null?void 0:t.skeleton.getWorksheetConfig().freeze}_isSelectionInViewport(e,t){const n=this._getFreeze()||{startRow:-1,startColumn:-1,xSplit:0,ySplit:0};switch(t.viewPortKey){case V.VIEW_MAIN:return e.endRow>=n.startRow&&e.endColumn>=n.startColumn;case V.VIEW_MAIN_TOP:case V.VIEW_COLUMN_RIGHT:return e.endColumn>=n.startColumn&&e.startRow<n.startRow;case V.VIEW_MAIN_LEFT:case V.VIEW_ROW_BOTTOM:return e.endRow>=n.startRow&&e.startColumn<n.startColumn;case V.VIEW_MAIN_LEFT_TOP:case V.VIEW_COLUMN_LEFT:case V.VIEW_ROW_TOP:case V.VIEW_LEFT_TOP:return e.startRow<n.startRow&&e.startColumn<n.startColumn}}_clearObserverEvent(){this._scene.onPointerMoveObserver.remove(this._moveObserver),this._scene.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_initialControl(){const{leftControl:e,rightControl:t,topControl:n,bottomControl:r}=this._control;[e,t,n,r].forEach(o=>{o.onPointerEnterObserver.add(()=>{o.setCursor(b.CURSOR_TYPE.MOVE)}),o.onPointerLeaveObserver.add(()=>{o.resetCursor()}),o.onPointerDownObserver.add(this._controlEvent.bind(this))})}_controlMoving(e,t){var y;const n=this._scene,r=n.getScrollXYByRelativeCoords(b.Vector2.FromArray([e,t])),{scaleX:o,scaleY:s}=n.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(e,t,o,s,r),{row:c,column:d}=a,u=this._skeleton.getRowCount()-1,h=this._skeleton.getColumnCount()-1;let m=c+this._relativeSelectionPositionRow;m<0&&(m=0);let g=m+this._relativeSelectionRowLength;g>u&&(g=u,g-m<this._relativeSelectionRowLength&&(m=g-this._relativeSelectionRowLength));let _=d+this._relativeSelectionPositionColumn;_<0&&(_=0);let f=_+this._relativeSelectionColumnLength;f>h&&(f=h,f-_<this._relativeSelectionColumnLength&&(_=f-this._relativeSelectionColumnLength));const v=this._skeleton.getNoMergeCellPositionByIndex(m,_),R=this._skeleton.getNoMergeCellPositionByIndex(g,f),M=(v==null?void 0:v.startY)||0,T=(R==null?void 0:R.endY)||0,w=(v==null?void 0:v.startX)||0,E=(R==null?void 0:R.endX)||0;(y=this._helperSelection)==null||y.transformByState({left:w,top:M,width:E-w,height:T-M}),this._targetSelection={startY:M,endY:T,startX:w,endX:E,startRow:m,endRow:g,startColumn:_,endColumn:f},this._control.selectionMoving$.next(this._targetSelection)}_controlEvent(e){const{offsetX:t,offsetY:n}=e,r=this._scene,o=r.getRelativeCoord(b.Vector2.FromArray([t,n])),{x:s,y:a}=o,c=r.getScrollXYByRelativeCoords(o),{scaleX:d,scaleY:u}=r.getAncestorScale(),h=this._skeleton.getCellPositionByOffset(s,a,d,u,c);this._startOffsetX=s,this._startOffsetY=a;const{row:m,column:g}=h,{startRow:_,startColumn:f,endRow:v,endColumn:R}=this._control.model;let M=0,T=0;m<_?M-=1:m>v&&(M+=1),g<f?T-=1:g>R&&(T+=1),this._relativeSelectionPositionRow=_-m+M,this._relativeSelectionPositionColumn=f-g+T,this._relativeSelectionRowLength=v-_,this._relativeSelectionColumnLength=R-f;const w=this._control.selectionStyle,E=this._getScale();this.isHelperSelection&&(this._helperSelection=new b.Rect(gr,{stroke:w.stroke,strokeWidth:w.strokeWidth/E}),r.addObject(this._helperSelection));const y=r.getViewport(V.VIEW_MAIN),x=b.ScrollTimer.create(r);x.startScroll(s,a,y),this._scrollTimer=x,r.disableEvent(),this._moveObserver=r.onPointerMoveObserver.add(O=>{const{offsetX:A,offsetY:k}=O,{x:H,y:B}=r.getRelativeCoord(b.Vector2.FromArray([A,k]));this._controlMoving(H,B),r.setCursor(b.CURSOR_TYPE.MOVE),x.scrolling(H,B,()=>{this._controlMoving(H,B)})}),this._upObserver=r.onPointerUpObserver.add(()=>{var A,k;(A=this._helperSelection)==null||A.dispose();const O=this._scene;O.resetCursor(),this._clearObserverEvent(),O.enableEvent(),(k=this._scrollTimer)==null||k.dispose(),this._control.selectionMoved$.next(this._targetSelection)})}_initialWidget(){const{topLeftWidget:e,topCenterWidget:t,topRightWidget:n,middleLeftWidget:r,middleRightWidget:o,bottomLeftWidget:s,bottomCenterWidget:a,bottomRightWidget:c}=this._control,d=[b.CURSOR_TYPE.NORTH_WEST_RESIZE,b.CURSOR_TYPE.NORTH_RESIZE,b.CURSOR_TYPE.NORTH_EAST_RESIZE,b.CURSOR_TYPE.WEST_RESIZE,b.CURSOR_TYPE.EAST_RESIZE,b.CURSOR_TYPE.SOUTH_WEST_RESIZE,b.CURSOR_TYPE.SOUTH_RESIZE,b.CURSOR_TYPE.SOUTH_EAST_RESIZE];[e,t,n,r,o,s,a,c].forEach((u,h)=>{u.onPointerEnterObserver.add(()=>{u.setCursor(d[h])}),u.onPointerLeaveObserver.add(()=>{u.resetCursor()}),u.onPointerDownObserver.add(m=>{this._widgetEvent(m,d[h])})})}_widgetMoving(e,t,n){const r=this._scene,o=r.getScrollXYByRelativeCoords(b.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:a}=r.getAncestorScale(),c=this._skeleton.getCellPositionByOffset(e,t,s,a,o),{row:d,column:u}=c,{rowHeaderWidth:h,columnHeaderHeight:m}=this._skeleton;let g=this._relativeSelectionPositionRow,_=this._relativeSelectionPositionColumn,f=d,v=u;n===b.CURSOR_TYPE.NORTH_WEST_RESIZE?(g=d,_=u,f=this._relativeSelectionPositionRow,v=this._relativeSelectionPositionColumn):n===b.CURSOR_TYPE.NORTH_RESIZE?(g=d,_=this._relativeSelectionPositionColumn,f=this._relativeSelectionPositionRow,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):n===b.CURSOR_TYPE.NORTH_EAST_RESIZE?(g=d,_=this._relativeSelectionPositionColumn,f=this._relativeSelectionPositionRow,v=u):n===b.CURSOR_TYPE.WEST_RESIZE?(g=this._relativeSelectionPositionRow,_=u,f=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,v=this._relativeSelectionPositionColumn):n===b.CURSOR_TYPE.EAST_RESIZE?f=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:n===b.CURSOR_TYPE.SOUTH_WEST_RESIZE?(g=this._relativeSelectionPositionRow,_=u,f=d,v=this._relativeSelectionPositionColumn):n===b.CURSOR_TYPE.SOUTH_RESIZE&&(g=this._relativeSelectionPositionRow,_=this._relativeSelectionPositionColumn,f=d,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const{startRow:R,startColumn:M,endRow:T,endColumn:w}=this._swapPositions(g,_,f,v),E=this._skeleton.getNoMergeCellPositionByIndex(R,M),y=this._skeleton.getNoMergeCellPositionByIndex(T,w),x=(E==null?void 0:E.startY)||0,O=(y==null?void 0:y.endY)||0,A=(E==null?void 0:E.startX)||0,k=(y==null?void 0:y.endX)||0;this._targetSelection={startY:x,endY:O,startX:A,endX:k,startRow:g,endRow:f,startColumn:_,endColumn:v},this._control.update(this._targetSelection,h,m,this._control.selectionStyle),this._control.clearHighlight(),this._control.selectionScaling$.next(this._targetSelection)}_widgetEvent(e,t){const{offsetX:n,offsetY:r}=e,o=this._scene,s=o.getRelativeCoord(b.Vector2.FromArray([n,r])),{x:a,y:c}=s;this._startOffsetX=n,this._startOffsetY=r;const{startRow:d,startColumn:u,endRow:h,endColumn:m}=this._control.model;this._relativeSelectionPositionRow=d,this._relativeSelectionPositionColumn=u,this._relativeSelectionRowLength=h-d,this._relativeSelectionColumnLength=m-u,t===b.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=h,this._relativeSelectionPositionColumn=m):t===b.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=h:t===b.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=h:t===b.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=m:t===b.CURSOR_TYPE.SOUTH_WEST_RESIZE&&(this._relativeSelectionPositionColumn=m);const g=b.ScrollTimer.create(o);g.startScroll(a,c),this._scrollTimer=g,o.disableEvent(),this._moveObserver=o.onPointerMoveObserver.add(_=>{const{offsetX:f,offsetY:v}=_,{x:R,y:M}=o.getRelativeCoord(b.Vector2.FromArray([f,v]));this._widgetMoving(R,M,t),o.setCursor(t),g.scrolling(R,M,()=>{this._widgetMoving(R,M,t)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var f;const _=this._scene;_.resetCursor(),this._clearObserverEvent(),_.enableEvent(),(f=this._scrollTimer)==null||f.dispose(),this._control.selectionScaled$.next(this._targetSelection)})}_initialFill(){const{fillControl:e}=this._control;e.onPointerEnterObserver.add(()=>{e.setCursor(b.CURSOR_TYPE.CROSSHAIR)}),e.onPointerLeaveObserver.add(()=>{e.resetCursor()}),e.onPointerDownObserver.add(this._fillEvent.bind(this))}_fillMoving(e,t){var k,H,B;const n=this._scene,r=n.getScrollXY(this._activeViewport),{scaleX:o,scaleY:s}=n.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(e,t,o,s,r),{row:c,column:d}=a,u=n.getRelativeCoord(b.Vector2.FromArray([e,t])),h=this._skeleton.getRowCount()-1,m=this._skeleton.getColumnCount()-1;let g=this._relativeSelectionPositionRow,_=this._relativeSelectionPositionColumn,f=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,R=!1,M=!0;if((d<_||d>v)&&c>=g&&c<=f){const F=this._fillRuler(d,_,v,this._relativeSelectionColumnLength,m);_=F.startRowOrColumn,v=F.endRowOrColumn,R=F.isLighten,M=!1}else if((c<g||c>f)&&d>=_&&d<=v){const F=this._fillRuler(c,g,f,this._relativeSelectionRowLength,h);g=F.startRowOrColumn,f=F.endRowOrColumn,R=F.isLighten}else if(Math.abs(this._startOffsetX-u.x-r.x)/2>Math.abs(this._startOffsetY-u.y-r.y)){const F=this._fillRuler(d,_,v,this._relativeSelectionColumnLength,m);_=F.startRowOrColumn,v=F.endRowOrColumn,R=F.isLighten,M=!1}else{const F=this._fillRuler(c,g,f,this._relativeSelectionRowLength,h);g=F.startRowOrColumn,f=F.endRowOrColumn,R=F.isLighten}const T=this._skeleton.getNoMergeCellPositionByIndex(g,_),w=this._skeleton.getNoMergeCellPositionByIndex(f,v),E=(T==null?void 0:T.startY)||0,y=(w==null?void 0:w.endY)||0,x=(T==null?void 0:T.startX)||0,O=(w==null?void 0:w.endX)||0;R?this._controlHandler((F,j)=>{const z=new l.ColorKit(this._fillControlColors[j]).lighten(xs).toRgbString();F.setProps({fill:z})}):this._controlHandler((F,j)=>{F.setProps({fill:this._fillControlColors[j]})});const A=S.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();g===f&&M===!0||_===v&&M===!1?(k=this._helperSelection)==null||k.hide():((H=this._helperSelection)==null||H.transformByState({left:x-A/2,top:E-A/2,width:O-x,height:y-E}),(B=this._helperSelection)==null||B.show()),this._targetSelection={startY:E,endY:y,startX:x,endX:O,startRow:g,endRow:f,startColumn:_,endColumn:v},this._control.selectionFilling$.next(this._targetSelection)}_fillEvent(e){const{offsetX:t,offsetY:n}=e,r=this._scene,o=r.getRelativeCoord(b.Vector2.FromArray([t,n])),{x:s,y:a}=o;this._startOffsetX=s,this._startOffsetY=a;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 m=this._control.selectionStyle;let g=m==null?void 0:m.stroke,_=m==null?void 0:m.strokeWidth;const f=S.getNormalSelectionStyle(this._themeService);g==null&&(g=f.stroke),_==null&&(_=f.strokeWidth);const v=this._getScale();_/=v;const R=S.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/v,M=new l.ColorKit(g).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new b.Rect(gr,{stroke:M,strokeWidth:_+R/2}),r.addObject(this._helperSelection)),this._activeViewport=r.getActiveViewportByCoord(b.Vector2.FromArray([t,n]));const T=r.getViewport(V.VIEW_MAIN),w=b.ScrollTimer.create(r,this._activeViewport.viewPortKey===V.VIEW_MAIN?b.ScrollTimerType.ALL:b.ScrollTimerType.NONE);w.startScroll(s,a,T),this._scrollTimer=w,r.disableEvent(),this._controlHandler(E=>{this._fillControlColors.push(E.fill)}),this._moveObserver=r.onPointerMoveObserver.add(E=>{var B;const{offsetX:y,offsetY:x}=E,O=r.getActiveViewportByCoord(b.Vector2.FromArray([y,x])),{x:A,y:k}=r.getRelativeCoord(b.Vector2.FromArray([y,x]));this._fillMoving(A,k),r.setCursor(b.CURSOR_TYPE.CROSSHAIR);const H=this._targetSelection;if(T&&O&&((B=this._activeViewport)==null?void 0:B.viewPortKey)!==(O==null?void 0:O.viewPortKey)){let F;H.startRow!==c?(w.scrollTimerType=b.ScrollTimerType.Y,F={...H,endRow:H.startRow}):H.endRow!==u?(w.scrollTimerType=b.ScrollTimerType.Y,F={...H,startRow:H.endRow}):H.startColumn!==d?(w.scrollTimerType=b.ScrollTimerType.X,F={...H,endColumn:H.startColumn}):(w.scrollTimerType=b.ScrollTimerType.X,F={...H,startColumn:H.endColumn}),this._isSelectionInViewport(F,O)&&(T.scrollTo({x:w.scrollTimerType===b.ScrollTimerType.X?0:void 0,y:w.scrollTimerType===b.ScrollTimerType.Y?0:void 0}),this._activeViewport=O)}w.scrolling(A,k,()=>{this._fillMoving(A,k)})}),this._upObserver=r.onPointerUpObserver.add(()=>{var y,x;(y=this._helperSelection)==null||y.dispose();const E=this._scene;E.resetCursor(),this._clearObserverEvent(),E.enableEvent(),(x=this._scrollTimer)==null||x.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((O,A)=>{O.setProps({fill:this._fillControlColors[A]})}),this._fillControlColors=[]})}_hasMergeInRange(e,t,n,r){const o=this._skeleton.mergeData;if(!o)return!1;for(const s of o){const{startRow:a,startColumn:c,endRow:d,endColumn:u}=s,h={left:t,top:e,right:r,bottom:n},m={left:c,top:a,right:u,bottom:d};if(b.isRectIntersect(h,m))return!0}return!1}_swapPositions(e,t,n,r){const o=Math.min(e,n),s=Math.min(t,r),a=Math.max(e,n),c=Math.max(t,r);return{startRow:o,startColumn:s,endRow:a,endColumn:c}}_controlHandler(e){const{leftControl:t,rightControl:n,topControl:r,bottomControl:o,backgroundControlTop:s,backgroundControlMiddleLeft:a,backgroundControlMiddleRight:c,backgroundControlBottom:d,fillControl:u}=this._control,h=[t,n,r,o,s,a,c,d,u];for(let m=0,g=h.length;m<g;m++){const _=h[m];e(_,m)}}_fillRuler(e,t,n,r,o){let s=!1;if(e<t)if(this._isInMergeState&&e<t){const a=t-e,c=r+1,d=Math.ceil(a/c);let u=t-d*c;u<0&&(u=t-(d-1)*c),t=u}else t=e;else if(e>=t&&e<=n)s=!0,n=e;else if(this._isInMergeState&&e>n){const a=e-n,c=r+1,d=Math.ceil(a/c);let u=n+d*c;u>o&&(u=n+(d-1)*c),n=u}else n=e;return{rowOrColumn:e,startRowOrColumn:t,endRowOrColumn:n,isLighten:s}}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}}var As=Object.defineProperty,Ds=Object.getOwnPropertyDescriptor,Ns=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ds(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&As(e,t,r),r},sn=(i,e)=>(t,n)=>e(t,n,i);exports.SelectionRenderService=class{constructor(e,t,n,r){C(this,"hasSelection",!1);C(this,"_downObserver");C(this,"_moveObserver");C(this,"_upObserver");C(this,"_controlFillConfig$",new N.BehaviorSubject(null));C(this,"controlFillConfig$",this._controlFillConfig$.asObservable());C(this,"_selectionControls",[]);C(this,"_startSelectionRange",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});C(this,"_startOffsetX",0);C(this,"_startOffsetY",0);C(this,"_scrollTimer");C(this,"_cancelDownObserver");C(this,"_cancelUpObserver");C(this,"_skeleton");C(this,"_scene");C(this,"_isHeaderHighlight",!0);C(this,"_isDetectMergedCell",!0);C(this,"_selectionStyle");C(this,"_isSelectionEnabled",!0);C(this,"_isShowPreviousEnable",0);C(this,"_isRemainLastEnable",!0);C(this,"_isSkipRemainLastEnable",!1);C(this,"_selectionMoveEnd$",new N.BehaviorSubject([]));C(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());C(this,"_selectionMoving$",new N.Subject);C(this,"selectionMoving$",this._selectionMoving$.asObservable());C(this,"_selectionMoveStart$",new N.Subject);C(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());C(this,"_activeViewport");this._themeService=e,this._shortcutService=t,this._sheetSkeletonManagerService=n,this._injector=r,this._selectionStyle=S.getNormalSelectionStyle(this._themeService)}enableHeaderHighlight(){this._isHeaderHighlight=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}enableDetectMergedCell(){this._isDetectMergedCell=!0}disableDetectMergedCell(){this._isDetectMergedCell=!1}setStyle(e){this._selectionStyle=e}resetStyle(){this.setStyle(S.getNormalSelectionStyle(this._themeService))}enableSelection(){this._isSelectionEnabled=!0}disableSelection(){this._isSelectionEnabled=!1}enableShowPrevious(){this._isShowPreviousEnable=!0}disableShowPrevious(){this._isShowPreviousEnable=!1}enableRemainLast(){this._isRemainLastEnable=!0}disableRemainLast(){this._isRemainLastEnable=!1}enableSkipRemainLast(){this._isSkipRemainLastEnable=!0}disableSkipRemainLast(){this._isSkipRemainLastEnable=!1}getViewPort(){return this._activeViewport}addControlToCurrentByRangeData(e){const t=this.getCurrentControls();if(!t)return;const{rangeWithCoord:n,primaryWithCoord:r}=e,o=this._skeleton;let s=e.style;s==null&&(s=S.getNormalSelectionStyle(this._themeService));const a=this._scene;if(a==null||o==null)return;const c=new Wn(a,t.length,this._isHeaderHighlight,this._themeService);new _r(c,o,a,this._themeService,this._injector);const{rowHeaderWidth:d,columnHeaderHeight:u}=o;c.update(n,d,u,s,r),this._isHeaderHighlight?c.enableHeaderHighlight():c.disableHeaderHighlight(),t.push(c)}updateControlForCurrentByRangeData(e){const t=this.getCurrentControls();if(!t)return;const n=this._skeleton;if(n==null)return;const{rowHeaderWidth:r,columnHeaderHeight:o}=n;for(let s=0,a=e.length;s<a;s++){const{rangeWithCoord:c,primaryWithCoord:d,style:u}=e[s];t[s].update(c,r,o,u,d)}}refreshSelectionMoveStart(){this._selectionMoveStart$.next(this.getSelectionDataWithStyle())}changeRuntime(e,t,n){this._skeleton=e,this._scene=t,this._activeViewport=n||t.getViewports()[0]}getSelectionDataWithStyle(){return this._selectionControls.map(t=>t.getValue())}getCurrentControls(){return this._selectionControls}_clearSelectionControls(){const e=this.getCurrentControls();if(e.length>0){for(const t of e)t.dispose();e.length=0}}_getFreeze(){var t;return(t=this._sheetSkeletonManagerService.getCurrent())==null?void 0:t.skeleton.getWorksheetConfig().freeze}_getViewportByCell(e,t){if(!this._scene||e===void 0||t===void 0)return null;const n=this._getFreeze();if(!n||n.startRow<=0&&n.startColumn<=0)return this._scene.getViewport(V.VIEW_MAIN);if(e>n.startRow&&t>n.startColumn)return this._scene.getViewport(V.VIEW_MAIN);if(e<=n.startRow&&t<=n.startColumn)return this._scene.getViewport(V.VIEW_MAIN_LEFT_TOP);if(e<=n.startRow&&t>n.startColumn)return this._scene.getViewport(V.VIEW_MAIN_TOP);if(e>n.startRow&&t<=n.startColumn)return this._scene.getViewport(V.VIEW_MAIN_LEFT)}getActiveSelections(){const e=this.getCurrentControls();if(e&&e.length>0)return e==null?void 0:e.map(n=>{const r=n.model,o=r.currentCell;let s=null;return o&&(s={actualRow:o.actualRow,actualColumn:o.actualColumn,isMerged:o.isMerged,isMergedMainCell:o.isMergedMainCell,startRow:o.mergeInfo.startRow,startColumn:o.mergeInfo.startColumn,endRow:o.mergeInfo.endRow,endColumn:o.mergeInfo.endColumn}),{range:{startRow:r.startRow,startColumn:r.startColumn,endRow:r.endRow,endColumn:r.endColumn},primary:s}})}getActiveRange(){const e=this.getCurrentControls(),t=e&&e[e.length-1].model;return t&&{startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}}getActiveSelection(){const e=this.getCurrentControls();return e&&e[e.length-1]}endSelection(){this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}reset(){this._clearSelectionControls(),this._moveObserver=null,this._upObserver=null,this._downObserver=null}resetAndEndSelection(){this.endSelection(),this.reset()}eventTrigger(e,t=0,n=l.RANGE_TYPE.NORMAL,r,o=b.ScrollTimerType.ALL){var q,oe;if(this._isSelectionEnabled===!1)return;const s=this._skeleton,{offsetX:a,offsetY:c}=e,d=this._scene;if(d==null||s==null)return;r!=null&&(this._activeViewport=r);const u=d.getViewport(V.VIEW_MAIN),h=d.getRelativeCoord(b.Vector2.FromArray([a,c]));let{x:m,y:g}=h;this._startOffsetX=m,this._startOffsetY=g;const _=d.getScrollXYByRelativeCoords(h),{scaleX:f,scaleY:v}=d.getAncestorScale();n===l.RANGE_TYPE.ROW?m=0:n===l.RANGE_TYPE.COLUMN&&(g=0);const R=this._getSelectedRangeWithMerge(m,g,f,v,_);if(!R)return!1;const{rangeWithCoord:M,primaryWithCoord:T}=R,{startRow:w,startColumn:E,endColumn:y,endRow:x,startY:O,endY:A,startX:k,endX:H}=M,{rowHeaderWidth:B,columnHeaderHeight:F}=s,j={startColumn:E,startRow:w,endColumn:y,endRow:x,startY:O,endY:A,startX:k,endX:H,rangeType:n};this._startSelectionRange=j;let z=this.getActiveSelection();const ee=this.getCurrentControls();if(!ee)return!1;for(const $ of ee){if(e.button===2&&$.model.isInclude(j)){z=$;return}if($.model.isEqual(j)){z=$;break}e.shiftKey||$.clearHighlight()}if(ee.length>0&&!e.ctrlKey&&!e.shiftKey&&!this._isShowPreviousEnable&&!this._isRemainLastEnable){for(const $ of ee)$.dispose();ee.length=0}const W=z&&z.model.currentCell;if(z&&e.shiftKey&&W){const{actualRow:$,actualColumn:Z,mergeInfo:G}=W,le=Math.min($,j.startRow,G.startRow),se=Math.max($,j.endRow,G.endRow),me=Math.min(Z,j.startColumn,G.startColumn),ke=Math.max(Z,j.endColumn,G.endColumn),pe=s.getMergeBounding(le,me,se,ke),ue=s.getNoMergeCellPositionByIndex(pe.startRow,pe.startColumn),ae=s.getNoMergeCellPositionByIndex(pe.endRow,pe.endColumn),Ve={startColumn:pe.startColumn,startRow:pe.startRow,endColumn:pe.endColumn,endRow:pe.endRow,startY:ue.startY,endY:ae.endY,startX:ue.startX,endX:ae.endX,rangeType:n},ve=s.getCellByIndex($,Z);this._startSelectionRange={startColumn:ve.mergeInfo.startColumn,startRow:ve.mergeInfo.startRow,endColumn:ve.mergeInfo.endColumn,endRow:ve.mergeInfo.endRow,startY:ve.mergeInfo.startY||0,endY:ve.mergeInfo.endY||0,startX:ve.mergeInfo.startX||0,endX:ve.mergeInfo.endX||0,rangeType:n},z.update(Ve,B,F,this._selectionStyle,W)}else this._isRemainLastEnable&&z&&!e.ctrlKey&&!e.shiftKey&&!this._isSkipRemainLastEnable?z.update(j,B,F,this._selectionStyle,T):(z=new Wn(d,ee.length+t,this._isHeaderHighlight,this._themeService),new _r(z,s,d,this._themeService,this._injector),z.update(j,B,F,this._selectionStyle,T),ee.push(z));this._selectionMoveStart$.next(this.getSelectionDataWithStyle()),this.hasSelection=!0,this._endSelection(),d.disableEvent();const Q=d.getActiveViewportByCoord(b.Vector2.FromArray([m,g])),re=b.ScrollTimer.create(this._scene,o);re.startScroll((q=u==null?void 0:u.left)!=null?q:0,(oe=u==null?void 0:u.top)!=null?oe:0,u),this._scrollTimer=re,this._addCancelObserver(),(n===l.RANGE_TYPE.ROW||n===l.RANGE_TYPE.COLUMN)&&this._moving(m,g,z,n);let Y=0,L=0,U=m,X=g;this._moveObserver=d.onPointerMoveObserver.add($=>{var ve,At,Dt,Nt,Ht,er,tr,nr,ir,rr;const{offsetX:Z,offsetY:G}=$,{x:le,y:se}=d.getRelativeCoord(b.Vector2.FromArray([Z,G]));this._moving(le,se,z,n);let me=le,ke=se;const pe=this.getActiveSelection(),ue=(ve=this._sheetSkeletonManagerService.getCurrent())==null?void 0:ve.skeleton.getWorksheetConfig().freeze,ae=pe==null?void 0:pe.model,Ve=(At=d.getActiveViewportByCoord(b.Vector2.FromArray([Z,G])))!=null?At:this._getViewportByCell(ae==null?void 0:ae.endRow,ae==null?void 0:ae.endColumn);if(Q&&Ve&&u){const ni=U<u.left&&le>u.left||U>u.left&&le<u.left,ii=X<u.top&&se>u.top||X>u.top&&se<u.top;ni&&(Y+=1),ii&&(L+=1);const xe=Q.viewPortKey,Pt=Ve.viewPortKey;if(xe===V.VIEW_ROW_TOP)G<u.top&&((Dt=ae==null?void 0:ae.endRow)!=null?Dt:0)<((Nt=ue==null?void 0:ue.startRow)!=null?Nt:0)?ke=u.top:ii&&L%2===1&&u.scrollTo({y:0});else if(xe===V.VIEW_COLUMN_LEFT)Z<u.left&&((Ht=ae==null?void 0:ae.endColumn)!=null?Ht:0)<((er=ue==null?void 0:ue.startColumn)!=null?er:0)?me=u.left:ni&&Y%2===1&&u.scrollTo({x:0});else if(xe===Pt){let Be=!1,Qe=!1;xe===V.VIEW_MAIN_LEFT_TOP?(Be=!0,Qe=!0):xe===V.VIEW_MAIN_TOP?Qe=!0:xe===V.VIEW_MAIN_LEFT&&(Be=!0),((tr=ae==null?void 0:ae.endRow)!=null?tr:0)>((nr=ue==null?void 0:ue.startRow)!=null?nr:0)&&(Qe=!1),((ir=ae==null?void 0:ae.endColumn)!=null?ir:0)>((rr=ue==null?void 0:ue.startColumn)!=null?rr:0)&&(Be=!1),Be&&(me=u.left),Qe&&(ke=u.top)}else{const Be={x:Q.scrollX,y:Q.scrollY},Qe={x:Ve.scrollX,y:Ve.scrollY},ri=Be.x!==Qe.x&&ni&&Y%2===1,oi=Be.y!==Qe.y&&ii&&L%2===1;(ri||oi)&&(u.scrollTo({x:ri?Be.x:void 0,y:oi?Be.y:void 0}),ri||(me=u.left),oi||(ke=u.top)),(xe===V.VIEW_MAIN_LEFT_TOP&&Pt===V.VIEW_MAIN_LEFT||Pt===V.VIEW_MAIN_LEFT_TOP&&xe===V.VIEW_MAIN_LEFT)&&(me=u.left),(xe===V.VIEW_MAIN_LEFT_TOP&&Pt===V.VIEW_MAIN_TOP||Pt===V.VIEW_MAIN_LEFT_TOP&&xe===V.VIEW_MAIN_TOP)&&(ke=u.top)}U=le,X=se}re.scrolling(me,ke,()=>{this._moving(le,se,z,n)})}),this._upObserver=d.onPointerUpObserver.add($=>{this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}),this._shortcutService.setDisable(!0)}convertSelectionRangeToData(e){const{range:t,primary:n,style:r}=e;let o=this.convertRangeDataToSelection(t);return o==null&&(o={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1,startY:0,endY:0,startX:0,endX:0,rangeType:l.RANGE_TYPE.NORMAL}),{rangeWithCoord:o,primaryWithCoord:this.convertCellRangeToInfo(n),style:r}}convertRangeDataToSelection(e){const{startRow:t,startColumn:n,endRow:r,endColumn:o,rangeType:s}=e,a=this._scene,c=this._skeleton;if(a==null||c==null)return;a.getAncestorScale();const d=c.getNoMergeCellPositionByIndex(t,n),u=c.getNoMergeCellPositionByIndex(r,o);return{startRow:t,startColumn:n,endRow:r,endColumn:o,rangeType:s,startY:(d==null?void 0:d.startY)||0,endY:(u==null?void 0:u.endY)||0,startX:(d==null?void 0:d.startX)||0,endX:(u==null?void 0:u.endX)||0}}convertCellRangeToInfo(e){if(e==null)return;const t=this._scene,n=this._skeleton;if(t==null||n==null)return;const{actualRow:r,actualColumn:o,isMerged:s,isMergedMainCell:a,startRow:c,startColumn:d,endRow:u,endColumn:h}=e,m=n.getNoMergeCellPositionByIndex(r,o),g=n.getNoMergeCellPositionByIndex(c,d),_=n.getNoMergeCellPositionByIndex(u,h);return{actualRow:r,actualColumn:o,isMerged:s,isMergedMainCell:a,startX:m.startX,startY:m.startY,endX:m.endX,endY:m.endY,mergeInfo:{startRow:c,startColumn:d,endRow:u,endColumn:h,startY:(g==null?void 0:g.startY)||0,endY:(_==null?void 0:_.endY)||0,startX:(g==null?void 0:g.startX)||0,endX:(_==null?void 0:_.endX)||0}}}_moving(e,t,n,r){var oe;const o=this._skeleton,s=this._scene;if(s==null||o==null)return!1;const{startRow:a,startColumn:c,endRow:d,endColumn:u}=this._startSelectionRange,{startRow:h,endRow:m,startColumn:g,endColumn:_}=(n==null?void 0:n.model)||{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1},f=s.getViewport(V.VIEW_MAIN),v=(oe=this._getViewportByCell(m,_))!=null?oe:f,R=s.getScrollXYByRelativeCoords(b.Vector2.FromArray([this._startOffsetX,this._startOffsetY]),v),{scaleX:M,scaleY:T}=s.getAncestorScale(),{rowHeaderWidth:w,columnHeaderHeight:E}=o;r===l.RANGE_TYPE.ROW?e=Number.POSITIVE_INFINITY:r===l.RANGE_TYPE.COLUMN&&(t=Number.POSITIVE_INFINITY);const y=this._getSelectedRangeWithMerge(e,t,M,T,R);if(!y)return!1;const{rangeWithCoord:x,primaryWithCoord:O}=y,{startRow:A,startColumn:k,endColumn:H,endRow:B}=x,F=Math.min(A,a),j=Math.min(k,c),z=Math.max(B,d),ee=Math.max(H,u);let W={startRow:F,startColumn:j,endRow:z,endColumn:ee};if(this._isDetectMergedCell&&(W=o.getSelectionBounding(F,j,z,ee)),!W)return!1;const{startRow:Q,startColumn:re,endRow:Y,endColumn:L}=W,U=o.getNoMergeCellPositionByIndex(Q,re),X=o.getNoMergeCellPositionByIndex(Y,L),q={startColumn:re,startRow:Q,endColumn:L,endRow:Y,startY:(U==null?void 0:U.startY)||0,endY:(X==null?void 0:X.endY)||0,startX:(U==null?void 0:U.startX)||0,endX:(X==null?void 0:X.endX)||0};(g!==re||h!==Q||_!==L||m!==Y)&&n!=null&&(n.update(q,w,E),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_endSelection(){var n,r;const e=this._scene;if(e==null)return;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),e.enableEvent(),(n=this._scrollTimer)==null||n.dispose();const t=(r=e.getEngine())==null?void 0:r.activeScene;t==null||t.onPointerDownObserver.remove(this._cancelDownObserver),t==null||t.onPointerUpObserver.remove(this._cancelUpObserver)}_addCancelObserver(){var n;const e=this._scene;if(e==null)return;const t=(n=e.getEngine())==null?void 0:n.activeScene;t==null||t===e||(t.onPointerDownObserver.remove(this._cancelDownObserver),t.onPointerUpObserver.remove(this._cancelUpObserver),this._cancelDownObserver=t.onPointerDownObserver.add(r=>{this._endSelection()}),this._cancelUpObserver=t.onPointerUpObserver.add(r=>{this._endSelection()}))}_getSelectedRangeWithMerge(e,t,n,r,o){var R;if(this._isDetectMergedCell){const M=(R=this._skeleton)==null?void 0:R.calculateCellIndexByPosition(e,t,n,r,o),T=l.makeCellToSelection(M);return T==null?void 0:{primaryWithCoord:M,rangeWithCoord:T}}const s=this._skeleton;if(s==null)return;const a=s.getCellPositionByOffset(e,t,n,r,o),{row:c,column:d}=a,u=s.getNoMergeCellPositionByIndex(c,d),{startX:h,startY:m,endX:g,endY:_}=u,f={startY:m,endY:_,startX:h,endX:g,startRow:c,endRow:c,startColumn:d,endColumn:d};return{primaryWithCoord:{actualRow:c,actualColumn:d,isMerged:!1,isMergedMainCell:!1,startY:m,endY:_,startX:h,endX:g,mergeInfo:f},rangeWithCoord:f}}};exports.SelectionRenderService=Ns([sn(0,D.Inject(l.ThemeService)),sn(1,I.IShortcutService),sn(2,D.Inject(exports.SheetSkeletonManagerService)),sn(3,D.Inject(D.Injector))],exports.SelectionRenderService);const _e=D.createIdentifier("deprecated.univer.sheet.selection-render-service");var Hs=Object.defineProperty,Ps=Object.getOwnPropertyDescriptor,Ls=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ps(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Hs(e,t,r),r},et=(i,e)=>(t,n)=>e(t,n,i);const Us=1e4,qt=D.createIdentifier("univer.mark-selection-service");exports.MarkSelectionService=class extends l.Disposable{constructor(t,n,r,o,s,a,c){super();C(this,"_shapeMap",new Map);this._currentService=t,this._renderManagerService=n,this._selectionRenderService=r,this._commandService=o,this._sheetSkeletonManagerService=s,this._themeService=a,this._selectionManagerService=c}addShape(t,n=[],r=Us){const o=this._currentService.getCurrentUniverSheetInstance(),s=o.getActiveSheet().getSheetId(),a=l.Tools.generateRandomId();return this._shapeMap.set(a,{selection:t,subUnitId:s,unitId:o.getUnitId(),zIndex:r,control:null,exits:n}),this.refreshShapes(),a}refreshShapes(){const t=this._currentService.getCurrentUniverSheetInstance().getUnitId(),n=this._currentService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();this._shapeMap.forEach(r=>{var M;const{unitId:o,subUnitId:s,selection:a,control:c,zIndex:d}=r;if(c&&c.dispose(),o!==t||s!==n)return;const{style:u}=a,{scene:h}=this._renderManagerService.getRenderById(o)||{},{rangeWithCoord:m,primaryWithCoord:g}=this._selectionRenderService.convertSelectionRangeToData(a),_=(M=this._sheetSkeletonManagerService.getCurrent())==null?void 0:M.skeleton;if(!h||!_)return;const{rowHeaderWidth:f,columnHeaderHeight:v}=_,R=new Wn(h,d,!1,this._themeService);R.update(m,f,v,u,g),r.control=R})}getShapeMap(){return this._shapeMap}removeShape(t){const n=this._shapeMap.get(t);if(!n)return;const{control:r}=n;r&&r.dispose(),this._shapeMap.delete(t)}removeAllShapes(){for(const t of this._shapeMap.values()){const{control:n}=t;n&&n.dispose()}this._shapeMap.clear()}};exports.MarkSelectionService=Ls([et(0,l.IUniverInstanceService),et(1,b.IRenderManagerService),et(2,_e),et(3,l.ICommandService),et(4,D.Inject(exports.SheetSkeletonManagerService)),et(5,D.Inject(l.ThemeService)),et(6,D.Inject(S.SelectionManagerService))],exports.MarkSelectionService);const ks=10,Vs=6;function Bs(){return l.Tools.generateRandomId(Vs)}function Fs(i){const e=i.match(/data-copy-id="([^\s]+)"/);return e&&e[1]?e[1]:null}class Ws{constructor(){C(this,"_cache",new l.LRUMap(ks))}set(e,t){this._cache.set(e,t)}get(e){return this._cache.get(e)}del(e){this._cache.delete(e)}clear(){this._cache.clear()}}const an=new Ws;var ot=(i=>(i.COPY="COPY",i.CUT="CUT",i))(ot||{});function js(i,e,t,n,r){const o=[],s=[];if(n.copyType===ot.CUT){const{undos:a,redos:c}=$s(i,e,r);o.push(...c),s.push(...a)}else{const{undos:a,redos:c}=eo(e,t,r);o.push(...c),s.push(...a);const{undos:d,redos:u}=Jr(e,t,r);o.push(...u),s.push(...d);const{undos:h,redos:m}=Qr(e,t,r);o.push(...m),s.push(...h);const{undos:g,redos:_}=Ri(e,t,r);o.push(..._),s.push(...g)}return{undos:s,redos:o}}function $s(i,e,t){let n=[],r=[];const{range:o,subUnitId:s,unitId:a}=i,{range:c,subUnitId:d}=e;if(o&&c){const u=t.get(l.IUniverInstanceService),h=t.get(S.SheetInterceptorService),m=u.getUniverSheetInstance(a),g=m==null?void 0:m.getSheetBySheetId(s),_=m==null?void 0:m.getSheetBySheetId(d);if(g&&_){const f=new l.ObjectMatrix,v=new l.ObjectMatrix,R=(W,Q)=>({startRow:W,endRow:W,startColumn:Q,endColumn:Q}),M=g.getCellMatrix(),T=_.getCellMatrix();l.Range.foreach(o,(W,Q)=>{f.setValue(W,Q,M.getValue(W,Q)),v.setValue(W,Q,null)});const w=new l.ObjectMatrix;l.Range.foreach(c,(W,Q)=>{w.setValue(W,Q,T.getValue(W,Q))});const E=new l.ObjectMatrix;l.Range.foreach(o,(W,Q)=>{const re=R(W,Q),Y=l.Rectangle.getRelativeRange(re,o),L=l.Rectangle.getPositionRange(Y,c);E.setValue(L.startRow,L.startColumn,M.getValue(W,Q))});const y={from:{value:v.getMatrix(),subUnitId:s},to:{value:E.getMatrix(),subUnitId:d},unitId:a},x={from:{value:f.getMatrix(),subUnitId:s},to:{value:w.getMatrix(),subUnitId:d},unitId:a},O=h.onCommandExecute({id:S.MoveRangeCommand.id,params:{toRange:c,fromRange:o}}),A=g.getMergeData(),k=_.getMergeData(),H=A.filter(W=>l.Rectangle.intersects(W,o)),B=k.filter(W=>l.Rectangle.intersects(W,c)),F=H.map(W=>l.Rectangle.getRelativeRange(W,o)).map(W=>l.Rectangle.getPositionRange(W,c)),j=S.getAddMergeMutationRangeByType(F).filter(W=>!k.some(Q=>l.Rectangle.equals(W,Q))),z=[{id:S.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:H}},{id:S.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:B}},{id:S.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:d,ranges:j}}],ee=[{id:S.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:d,ranges:j}},{id:S.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:d,ranges:B}},{id:S.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:H}}];n=[{id:S.MoveRangeMutation.id,params:y},...O.redos,...z,{id:S.SetSelectionsOperation.id,params:{unitId:a,sheetId:d,pluginName:S.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:c}]}}],r=[{id:S.SetSelectionsOperation.id,params:{unitId:a,sheetId:s,pluginName:S.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:o}]}},...O.undos,...ee,{id:S.MoveRangeMutation.id,params:x}]}}return{undos:r,redos:n}}function Jr(i,e,t){const{unitId:n,subUnitId:r,range:o}=i,s=[],a=[],{startColumn:c,startRow:d}=o,u=new l.ObjectMatrix;e.forValue((g,_,f)=>{u.setValue(g+d,_+c,{v:f.v})});const h={unitId:n,subUnitId:r,cellValue:u.getData()};s.push({id:S.SetRangeValuesMutation.id,params:h});const m=S.SetRangeValuesUndoMutationFactory(t,h);return a.push({id:S.SetRangeValuesMutation.id,params:m}),{undos:a,redos:s}}function Qr(i,e,t){const n=[],r=[],{unitId:o,subUnitId:s,range:a}=i,{startColumn:c,startRow:d}=a,u=new l.ObjectMatrix;e.forValue((g,_,f)=>{var R;const v={s:f.s};(R=f.p)!=null&&R.body&&(v.p=f.p),u.setValue(g+d,_+c,v)});const h={unitId:o,subUnitId:s,cellValue:u.getData()};n.push({id:S.SetRangeValuesMutation.id,params:h});const m=S.SetRangeValuesUndoMutationFactory(t,h);return r.push({id:S.SetRangeValuesMutation.id,params:m}),{undos:r,redos:n}}function eo(i,e,t){const n=[],r=[],o=new l.ObjectMatrix,{unitId:s,subUnitId:a,range:c}=i,{startColumn:d,startRow:u}=c;if(e.forValue((h,m,g)=>{g.s&&o.setValue(h+u,m+d,{s:null})}),o.getLength()>0){const h={subUnitId:a,unitId:s,cellValue:o.getData()};n.push({id:S.SetRangeValuesMutation.id,params:h});const m=S.SetRangeValuesUndoMutationFactory(t,h);r.push({id:S.SetRangeValuesMutation.id,params:m})}return{undos:r,redos:n}}function Ri(i,e,t){const n=[],r=[],{unitId:o,subUnitId:s,range:a}=i,{startColumn:c,startRow:d,endColumn:u,endRow:h}=a;let m=!1;const g=[];if(e.forValue((v,R,M)=>{if(M.rowSpan){const T=M.colSpan||1,w={startRow:d+v,endRow:d+v+M.rowSpan-1,startColumn:c+R,endColumn:c+R+T-1};g.push(w),m=!0}else if(M.colSpan){const T=M.rowSpan||1,w={startRow:d+v,endRow:d+v+T-1,startColumn:c+R,endColumn:c+R+M.colSpan-1};g.push(w),m=!0}}),m){const R=t.get(l.IUniverInstanceService).getUniverSheetInstance(o),M=R==null?void 0:R.getSheetBySheetId(s);if(R&&M){const w=M.getMergeData().filter(x=>l.Rectangle.intersects({startRow:d,startColumn:c,endRow:h,endColumn:u},x)),E={unitId:o,subUnitId:s,ranges:w};n.push({id:S.RemoveWorksheetMergeMutation.id,params:E});const y=S.RemoveMergeUndoMutationFactory(t,E);r.push({id:S.AddWorksheetMergeMutation.id,params:y})}}const _={unitId:o,subUnitId:s,ranges:g};n.push({id:S.AddWorksheetMergeMutation.id,params:_});const f=S.AddMergeUndoMutationFactory(t,_);return r.push({id:S.RemoveWorksheetMergeMutation.id,params:f}),{undos:r,redos:n}}function to(i){let e=i.replace(/(\r\n|\n)/g,"\r");e.endsWith(`\r
|
|
2
2
|
`)||(e+=`\r
|
|
3
3
|
`);const t=[];for(let n=0;n<e.length;n++)e[n]==="\r"&&t.push({startIndex:n});return{dataStream:e,paragraphs:t,sectionBreaks:[{startIndex:e.indexOf(`
|
|
4
|
-
`)}]}}function
|
|
4
|
+
`)}]}}function zs(i){const e=new DOMParser,t=`<x-univer id="univer-root">${i}</x-univer>`;return e.parseFromString(t,"text/html").querySelector("#univer-root")}function Xs(i){const e=i.style,t={};for(let n=0;n<e.length;n++){const r=e[n],o=e.getPropertyValue(r);switch(r){case"margin-top":{const s=parseInt(o);t.spaceAbove=/pt/.test(o)?Mi(s):s;break}case"margin-bottom":{const s=parseInt(o);t.spaceBelow=/pt/.test(o)?Mi(s):s;break}}}return Object.getOwnPropertyNames(t).length?t:null}function Mi(i){return i/.75}function Sr(i,e){const t=[];for(let n=0,r=i.length;n<r;n++)i[n]===l.DataStreamTreeTokenType.PARAGRAPH&&t.push({startIndex:n});if(e)for(const n of t)e.bullet&&(n.bullet=l.Tools.deepClone(e.bullet)),e.paragraphStyle&&(n.paragraphStyle=l.Tools.deepClone(e.paragraphStyle));return t}function Ni(i){const e=i.style,t={},n=i.tagName.toLowerCase();switch(n){case"b":case"em":case"strong":{t.bl=l.BooleanNumber.TRUE;break}case"s":{t.st={s:l.BooleanNumber.TRUE};break}case"u":{t.ul={s:l.BooleanNumber.TRUE};break}case"i":{t.it=l.BooleanNumber.TRUE;break}case"sub":case"sup":{t.va=n==="sup"?l.BaselineOffset.SUPERSCRIPT:l.BaselineOffset.SUBSCRIPT;break}}for(let r=0;r<e.length;r++){const o=e[r],s=e.getPropertyValue(o);switch(o){case"font-family":{t.ff=s;break}case"font-size":{const a=parseInt(s);Number.isNaN(a)||(t.fs=/pt$/.test(s)?Mi(a):a);break}case"font-style":{s==="italic"&&(t.it=l.BooleanNumber.TRUE);break}case"font-weight":{Number(s)>400&&(t.bl=l.BooleanNumber.TRUE);break}case"text-decoration":{/underline/.test(s)?t.ul={s:l.BooleanNumber.TRUE}:/overline/.test(s)?t.ol={s:l.BooleanNumber.TRUE}:/line-through/.test(s)&&(t.st={s:l.BooleanNumber.TRUE});break}case"color":{const a=new l.ColorKit(s);a.isValid&&(t.cl={rgb:a.toRgbString()});break}case"background-color":{const a=new l.ColorKit(s);a.isValid&&(t.bg={rgb:a.toRgbString()});break}}}return t}function fr(i,e){const t=i.tagName.toLowerCase();return typeof e=="string"?t===e:Array.isArray(e)?e.some(n=>n===t):e(i)}const Xn=class Xn{constructor(e){C(this,"styleCache",new Map);C(this,"styleRules",[]);C(this,"afterProcessRules",[]);C(this,"getCurrentSkeleton");this.getCurrentSkeleton=e.getCurrentSkeleton}static use(e){if(this.pluginList.includes(e))throw new Error(`Univer paste plugin ${e.name} already added`);this.pluginList.push(e)}convert(e){const t=Xn.pluginList.find(m=>m.checkPasteType(e));t&&(this.styleRules=[...t.stylesRules],this.afterProcessRules=[...t.afterProcessRules]);const n=new l.ObjectMatrix,r=zs(e),o={dataStream:"",textRuns:[]},s=[],a=e.match(/<table\b[^>]*>([\s\S]*?)<\/table>/gi),c=[];this.process(null,r==null?void 0:r.childNodes,o,c);const{paragraphs:d,dataStream:u,textRuns:h}=o;if(d){const m=d.map(g=>g.startIndex+1);m.unshift(0);for(let g=0;g<m.length;g++){let _;g===m.length-1?_=`${u.substring(m[g])}\r
|
|
5
5
|
`:_=`${u.substring(m[g],m[g+1]-1)}\r
|
|
6
|
-
`;const f=[];h==null||h.forEach(
|
|
7
|
-
`,g={dataStream:m,textRuns:h,paragraphs:
|
|
8
|
-
<tbody>${a.join("")}</tbody></table>`}}var wa=Object.defineProperty,Ta=Object.getOwnPropertyDescriptor,ya=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ta(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&wa(e,t,r),r},Tt=(i,e)=>(t,n)=>e(t,n,i);const Ke={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"};Mn.use(va);Mn.use(fa);const nn=j.createIdentifier("sheet.clipboard-service");exports.SheetClipboardService=class extends l.Disposable{constructor(t,n,r,o,s,a,c,d){super();v(this,"_clipboardHooks",[]);v(this,"_clipboardHooks$",new J.BehaviorSubject([]));v(this,"clipboardHooks$",this._clipboardHooks$.asObservable());v(this,"_htmlToUSM");v(this,"_usmToHtml");v(this,"_copyMarkId",null);v(this,"_pasteType",Ke.DEFAULT_PASTE);this._logService=t,this._currentUniverService=n,this._selectionManagerService=r,this._clipboardInterfaceService=o,this._undoRedoService=s,this._commandService=a,this._markSelectionService=c,this._sheetSkeletonManagerService=d,this._htmlToUSM=new Mn({getCurrentSkeleton:()=>this._sheetSkeletonManagerService.getCurrent()}),this._usmToHtml=new Ma}async copy(t=Vt.COPY){const n=this._selectionManagerService.getLast();if(!n)return!1;const r=this._clipboardHooks;r.reduce((I,w)=>{var O;const E=(O=w.getFilteredOutRows)==null?void 0:O.call(w);return E==null||E.forEach(x=>I.add(x)),I},new Set);const{startColumn:o,startRow:s,endColumn:a,endRow:c}=n.range,d=this._currentUniverService.getCurrentUniverSheetInstance(),u=d.getActiveSheet(),h=u.getMatrixWithMergedCells(s,o,c,a),m=new l.ObjectMatrix;for(let I=s;I<=c;I++)for(let w=o;w<=a;w++){const E=h.getValue(I,w);E?m.setValue(I-s,w-o,{...Vr(),...l.Tools.deepClone(E)}):m.setValue(I-s,w-o,Vr())}r.forEach(I=>{var w;return(w=I.onBeforeCopy)==null?void 0:w.call(I,d.getUnitId(),u.getSheetId(),n.range)});let g=this._usmToHtml.convert(h,n.range,r);const _=Ea(m),f=oa();g=g.replace(/(<[a-z]+)/,(I,w)=>`${w} data-copy-id="${f}"`),Vn.set(f,{unitId:d.getUnitId(),subUnitId:u.getSheetId(),range:n.range,matrix:m,copyType:t}),await this._clipboardInterfaceService.write(_,g),this._markSelectionService.removeAllShapes();const C=this._selectionManagerService.createCopyPasteSelection();return this._copyMarkId=this._markSelectionService.addShape({...n,style:C}),r.forEach(I=>{var w;return(w=I.onAfterCopy)==null?void 0:w.call(I)}),!0}async cut(){return this.copy(Vt.CUT)}async paste(t,n=Ke.DEFAULT_PASTE){const r=t.types,o=r.indexOf(R.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await t.getType(R.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()):"",s=r.indexOf(R.HTML_CLIPBOARD_MIME_TYPE)!==-1?await t.getType(R.HTML_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()):"";return s?this._pasteHTML(s,n):o?this._pastePlainText(o,n):(this._logService.error("[SheetClipboardService]","No valid data on clipboard"),!1)}addClipboardHook(t){if(this._clipboardHooks.findIndex(r=>r.id===t.id)!==-1)return this._logService.error("[SheetClipboardService]","hook already exists",t.id),{dispose:()=>{}};const n=this._clipboardHooks.findIndex(r=>{const o=r.priority||0;return(t.priority||0)<o});return this._clipboardHooks.splice(n!==-1?n:this._clipboardHooks.length,0,t),this._notifyClipboardHook(),l.toDisposable(()=>{const r=this._clipboardHooks.indexOf(t);r>-1&&(this._clipboardHooks.splice(r,1),this._notifyClipboardHook())})}getClipboardHooks(){return this._clipboardHooks}_notifyClipboardHook(){this._clipboardHooks$.next(this._clipboardHooks)}async _pastePlainText(t,n){const r=this._getPastingTarget();if(!r.selection)return!1;const o=r.selection.range,{unitId:s,subUnitId:a}=r,c=this._clipboardHooks,d=[];if(c.some(_=>{var f;return d.push(_)&&((f=_.onBeforePaste)==null?void 0:f.call(_,{unitId:s,subUnitId:a,range:o}))===!1}))return d.forEach(_=>{var f;return(f=_.onAfterPaste)==null?void 0:f.call(_,!1)}),!1;const h=[],m=[];d.forEach(_=>{var C;const f=(C=_.onPastePlainText)==null?void 0:C.call(_,{unitId:s,subUnitId:a,range:o},t,{pasteType:n});f&&(h.push(...f.redos),m.push(...f.undos))});const g=h.every(_=>this._commandService.executeCommand(_.id,_.params));return g&&this._undoRedoService.pushUndoRedo({unitID:this._currentUniverService.getCurrentUniverSheetInstance().getUnitId(),undoMutations:m,redoMutations:h}),g}async _pasteHTML(t,n){const r=sa(t);return r&&Vn.get(r)?this._pasteInternal(r,n):this._pasteExternal(t,n)}async _pasteExternal(t,n){const r=this._getPastingTarget(),{selection:o,unitId:s,subUnitId:a}=r;if(!o)return!1;const{rowProperties:c,colProperties:d,cellMatrix:u}=this._htmlToUSM.convert(t),{startColumn:h,endColumn:m,startRow:g,endRow:_}=u.getDataRange(),f=_-g+1,C=m-h+1;if(!u||m<h||_<g)return!1;const I=this._transformPastedData(f,C,u,o.range);return I?this._pasteUSM({rowProperties:c,colProperties:d,cellMatrix:u},{unitId:s,subUnitId:a,pastedRange:I},n):!1}async _pasteInternal(t,n){var P,L;const r=this._getPastingTarget(),{selection:o,unitId:s,subUnitId:a}=r,c=l.Tools.deepClone(Vn.get(t)),{range:d,matrix:u,unitId:h,subUnitId:m}=c||{};if(!o||!u||!c||!d||!h||!m||!o||!u||!c)return!1;const g=(P=this._currentUniverService.getUniverSheetInstance(h))==null?void 0:P.getStyles();u.forValue((G,k,ee)=>{if(typeof ee.s=="string"){const te=l.Tools.deepClone(ee);te.s=g==null?void 0:g.getStyleByCell(ee),u.setValue(G,k,te)}});const{startColumn:_,endColumn:f,startRow:C,endRow:I}=d,w=this._transformPastedData(I-C+1,f-_+1,u,o.range);if(!w)return!1;const E=(L=this._currentUniverService.getUniverSheetInstance(h))==null?void 0:L.getSheetBySheetId(m);if(!E)return!1;const O=E.getColumnManager(),x=E.getConfig().defaultColumnWidth,N=[];for(let G=_;G<=f;G++){const k=O.getColumnOrCreate(G);N.push({width:`${k.w||x}`})}const D=this._pasteUSM({cellMatrix:u,colProperties:N},{unitId:s,subUnitId:a,pastedRange:w},n,{range:d,unitId:c.unitId,subUnitId:c.subUnitId,copyType:c.copyType,copyId:t});return c.copyType===Vt.CUT&&(Vn.del(t),this._copyMarkId&&this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null),D}_pasteUSM(t,n,r,o){const{rowProperties:s,colProperties:a,cellMatrix:c}=t,{unitId:d,subUnitId:u,pastedRange:h}=n,{startColumn:m,endColumn:g}=h,_=g-m+1,f=this._clipboardHooks,C=[];if(f.some(L=>{var G;return C.push(L)&&((G=L.onBeforePaste)==null?void 0:G.call(L,{unitId:d,subUnitId:u,range:h}))===!1}))return C.forEach(L=>{var G;return(G=L.onAfterPaste)==null?void 0:G.call(L,!1)}),!1;if(!c)return!1;const w=o?{unitId:o.unitId,subUnitId:o.subUnitId,range:o.range}:null,E={copyType:(o==null?void 0:o.copyType)||Vt.COPY,copyId:o==null?void 0:o.copyId,pasteType:r},O=[],x=[];C.filter(L=>!L.specialPasteInfo&&L.id!==Ke.DEFAULT_PASTE||r===L.id).forEach(L=>{var ee,te,W;if(s){const V=(ee=L.onPasteRows)==null?void 0:ee.call(L,{range:h,unitId:d,subUnitId:u},s,{pasteType:r});V&&(O.push(...V.redos),x.push(...V.undos))}const G=(te=L.onPasteColumns)==null?void 0:te.call(L,{range:h,unitId:d,subUnitId:u},a||new Array(_).map(()=>({})),{pasteType:r});G&&(O.push(...G.redos),x.push(...G.undos));const k=(W=L.onPasteCells)==null?void 0:W.call(L,w,{range:h,unitId:d,subUnitId:u},c,E);k&&(O.push(...k.redos),x.push(...k.undos))});const D=this._getSetSelectionOperation(d,u,h,c);D&&O.push(D),this._logService.log("[SheetClipboardService]","pasting mutations",{undoMutationsInfo:x,redoMutationsInfo:O});const P=O.every(L=>this._commandService.executeCommand(L.id,L.params));return P&&this._undoRedoService.pushUndoRedo({unitID:d,undoMutations:x,redoMutations:O}),P}_getSetSelectionOperation(t,n,r,o){var f;const s=(f=this._currentUniverService.getUniverSheetInstance(t))==null?void 0:f.getSheetBySheetId(n);if(!s)return null;const{startRow:a,startColumn:c}=r,d={startRow:a,endRow:a,startColumn:c,endColumn:c},u=p.getPrimaryForRange(d,s),h=o.getValue(0,0),m=(h==null?void 0:h.rowSpan)||1,g=(h==null?void 0:h.colSpan)||1;if(m>1||g>1){const C={startRow:a,endRow:a+m-1,startColumn:c,endColumn:c+g-1};u.startRow=C.startRow,u.endRow=C.endRow,u.startColumn=C.startColumn,u.endColumn=C.endColumn,u.isMerged=!0,u.isMergedMainCell=!0}const _={unitId:t,subUnitId:n,pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:r,primary:u,style:null}]};return{id:p.SetSelectionsOperation.id,params:_}}_getPastingTarget(){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet(),r=this._selectionManagerService.getLast();return{unitId:t.getUnitId(),subUnitId:n.getSheetId(),selection:r}}_transformPastedData(t,n,r,o){const{startRow:s,startColumn:a,endRow:c,endColumn:d}=o,u=c-s+1,h=d-a+1,f=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData().filter(x=>l.Rectangle.intersects({startRow:s,startColumn:a,endRow:c,endColumn:d},x)),C=f[0];let I=0,w=0,E=0,O=0;if(C&&(I=C.startRow,w=C.startColumn,E=C.endRow,O=C.endColumn),u%t===0&&h%n===0)if(f.length>0&&(u!==t||h!==n))if(I===s&&w===a&&E===c&&O===d)if(Da(r))for(let N=0;N<u;N++)for(let D=0;D<h;D++){const P=r.getValue(N%t,D%n);P&&r.setValue(N,D,P)}else r.forValue((N,D,P)=>{P.s=null,delete P.colSpan,delete P.rowSpan});else for(let x=0;x<u;x++)for(let N=0;N<h;N++){const D=r.getValue(x%t,N%n);D&&r.setValue(x,N,D)}else for(let x=0;x<u;x++)for(let N=0;N<h;N++){const D=r.getValue(x%t,N%n);D&&r.setValue(x,N,D)}else if(f.length>0)if(this._topLeftCellsMatch(t,n,o))o.endRow=s+t-1,o.endColumn=a+n-1;else{if(c>C.endRow||d>C.endColumn)return null;r.forValue((N,D,P)=>{P.s=null,delete P.colSpan,delete P.rowSpan})}else o.endRow=s+t-1,o.endColumn=a+n-1;return o}_topLeftCellsMatch(t,n,r){const s=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet(),{startRow:a,startColumn:c,endRow:d,endColumn:u}=r,h=Aa(a+t-1,c,c+t-1,s),m=Na(c+n-1,a,a+t-1,s);return!h&&!m}};exports.SheetClipboardService=ya([Tt(0,l.ILogService),Tt(1,l.IUniverInstanceService),Tt(2,j.Inject(p.SelectionManagerService)),Tt(3,R.IClipboardInterfaceService),Tt(4,l.IUndoRedoService),Tt(5,l.ICommandService),Tt(6,On),Tt(7,j.Inject(exports.SheetSkeletonManagerService))],exports.SheetClipboardService);function Ea(i){let e="";return i.forRow((t,n)=>{const r=[];n.forEach(o=>{const s=i.getValue(t,o);if(s){const a=Oa(s);r.push(a)}}),e+=r.join(" "),t!==i.getLength()-1&&(e+=`
|
|
9
|
-
`)}),e}function Oa(i){const e=i.v;return xa((e==null?void 0:e.toString())||"")}const xa=i=>i.replace(/&/g,"&").replace(/\ufeff/g,"").replace(/</g,"<").replace(/>/g,">");function Aa(i,e,t,n){return n.getMergeData().some(r=>r.startRow<=i&&i<r.endRow&&e<=r.startColumn&&r.startColumn<=t)}function Na(i,e,t,n){return n.getMergeData().some(r=>r.startColumn<=i&&i<r.endColumn&&e<=r.startRow&&r.startRow<=t)}function Da(i){let e=0;return i.forValue((t,n,r)=>{if(r&&e++,e>1)return!1}),e>1}function Vr(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const wo={id:R.CopyCommand.id,name:"sheet.command.copy",type:l.CommandType.COMMAND,multi:!0,priority:1e3,preconditions:ye,handler:async i=>i.get(nn).copy()},Pa={id:R.CutCommand.id,name:"sheet.command.cut",type:l.CommandType.COMMAND,multi:!0,priority:1e3,preconditions:ye,handler:async i=>i.get(nn).cut()},rn={id:R.PasteCommand.id,type:l.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:1e3,preconditions:ye,handler:async(i,e)=>{const t=i.get(l.ILogService);if(t.log("[SheetPasteCommand]","the focusing element is",document.activeElement),!document.execCommand("paste")){t.log("[SheetPasteCommand]","failed to execute paste command on the activeElement, trying to use clipboard API.");const o=await i.get(R.IClipboardInterfaceService).read(),s=i.get(nn);return o.length!==0?s.paste(o[0],e==null?void 0:e.value):!1}return!1}},To={id:"sheet.command.paste-value",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(rn.id,{value:Ke.SPECIAL_PASTE_VALUE})},yo={id:"sheet.command.paste-format",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(rn.id,{value:Ke.SPECIAL_PASTE_FORMAT})},Eo={id:"sheet.command.paste-col-width",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(rn.id,{value:Ke.SPECIAL_PASTE_COL_WIDTH})},Oo={id:"sheet.command.paste-besides-border",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(rn.id,{value:Ke.SPECIAL_PASTE_BESIDES_BORDER})};function xt(i,e,t,n,r=!0,o=1,s=!0){let a={...i};n==null&&(n={startRow:0,endRow:t.getRowCount()-1,startColumn:0,endColumn:t.getColumnCount()-1});let c;switch(e){case l.Direction.UP:for(c=i.startRow-o;c>-1&&!t.getRowVisible(c);)c-=1;c>=n.startRow?(a.startRow=c,a.endRow=c):s&&(a.startRow=n.endRow,a.endRow=n.endRow,r&&(a=xt(a,l.Direction.LEFT,t,n,!1)));break;case l.Direction.DOWN:for(c=i.endRow+o;c<t.getRowCount()&&!t.getRowVisible(c);)c+=1;c<=n.endRow?(a.startRow=c,a.endRow=c):s&&(a.startRow=n.startRow,a.endRow=n.startRow,r&&(a=xt(a,l.Direction.RIGHT,t,n,!1)));break;case l.Direction.LEFT:for(c=i.startColumn-o;c>-1&&!t.getColVisible(c);)c-=1;c>=n.startColumn?(a.startColumn=c,a.endColumn=c):s&&(a.startColumn=n.endColumn,a.endColumn=n.endColumn,r&&(a=xt(a,l.Direction.UP,t,n,!1)));break;case l.Direction.RIGHT:for(c=i.endColumn+o;c<t.getColumnCount()&&!t.getColVisible(c);)c+=1;c<=n.endColumn?(a.startColumn=c,a.endColumn=c):s&&(a.startColumn=n.startColumn,a.endColumn=n.startColumn,r&&(a=xt(a,l.Direction.DOWN,t,n,!1)));break}return a}function dr(i,e,t){const n={...i},{startRow:r,startColumn:o,endRow:s,endColumn:a}=wn(i,e,t);let c=mn(t,r,o,s,a).hasValue,d=!0,u=!0;for(;u;){if(l.Direction.UP===e){let h=n.startRow-1;for(;h>-1&&!t.getRowVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:g}=mn(t,h,n.startColumn,h,n.endColumn);if(c&&!m&&!d){u=!1;break}else{if(g.getLength()!==0){let _=h;g.forValue(f=>{_=Math.min(f,_)}),n.startRow=_}else n.startRow=h;if(n.endRow=n.startRow,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.DOWN===e){let h=n.endRow+1;for(;h<t.getRowCount()&&!t.getRowVisible(h);)h+=1;if(h===t.getRowCount()){u=!1;break}const{hasValue:m,matrix:g}=mn(t,h,n.startColumn,h,n.endColumn);if(c&&!m&&!d){u=!1;break}else{if(g.getLength()!==0){let _=h;g.forValue((f,C,I)=>{_=Math.max(f+(I.rowSpan||1)-1,_)}),n.endRow=_}else n.endRow=h;if(n.startRow=n.endRow,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.LEFT===e){let h=n.startColumn-1;for(;h>-1&&!t.getColVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:g}=mn(t,n.startRow,h,n.endRow,h);if(c&&!m&&!d){u=!1;break}else{if(g.getLength()!==0){let _=h;g.forValue((f,C)=>{_=Math.min(C,_)}),n.startColumn=_}else n.startColumn=h;if(n.endColumn=n.startColumn,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.RIGHT===e){let h=n.endColumn+1;for(;h<t.getColumnCount()&&!t.getColVisible(h);)h+=1;if(h===t.getColumnCount()){u=!1;break}const{hasValue:m,matrix:g}=mn(t,n.startRow,h,n.endRow,h);if(c&&!m&&!d){u=!1;break}else{if(g.getLength()!==0){let _=h;g.forValue((f,C,I)=>{_=Math.max(C+(I.colSpan||1)-1,_)}),n.endColumn=_}else n.endColumn=h;if(n.startColumn=n.endColumn,!c&&m){u=!1;break}c=m,d=!1}}}return p.alignToMergedCellsBorders(n,t,!0)}function xo(i,e,t){return xt(i,e,t,void 0,!1,1,!1)}function Ha(i,e,t){const n=dr(i,e,t);return p.alignToMergedCellsBorders(l.Rectangle.union(n,i),t,!0)}function La(i,e,t){const n=xo(i,e,t),r={startRow:Math.min(i.startRow,n.startRow),startColumn:Math.min(i.startColumn,n.startColumn),endRow:Math.max(i.endRow,n.endRow),endColumn:Math.max(i.endColumn,n.endColumn)};return p.alignToMergedCellsBorders(l.Rectangle.union(i,r),t)}function Ua(i,e,t,n){const r=l.getReverseDirection(t),o=dr(wn(i,r,n),t,n);return t===l.Direction.UP&&o.startRow<=i.startRow?p.alignToMergedCellsBorders({...e,startColumn:i.startColumn,endColumn:i.endColumn},n,!0):t===l.Direction.DOWN&&o.endRow>=i.endRow?p.alignToMergedCellsBorders({...e,startColumn:i.startColumn,endColumn:i.endColumn},n,!0):t===l.Direction.LEFT&&o.startColumn<=i.startColumn?p.alignToMergedCellsBorders({...e,startRow:i.startRow,endRow:i.endRow},n,!0):t===l.Direction.RIGHT&&o.endColumn>=i.endColumn?p.alignToMergedCellsBorders({...e,startRow:i.startRow,endRow:i.endRow},n,!0):l.Rectangle.union(l.Rectangle.clone(e),o)}function ka(i,e,t){const n=l.getReverseDirection(e),r=wn(i,n,t),o=wn(i,e,t),s=xo(r,e,t);return p.alignToMergedCellsBorders(l.Rectangle.union(o,s),t,!1)}function Va(i,e,t){const{left:n,right:r,up:o,down:s}=e,a=t.getMaxRows(),c=t.getMaxColumns();let d=!0;const u={...i};for(;d;){if(d=!1,o&&u.startRow!==0){const h=u.startRow-1;t.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((g,_,f)=>{f.v&&(u.startRow=Math.min(g,u.startRow),u.startColumn=Math.min(_,u.startColumn),u.endColumn=Math.max(_,u.endColumn),d=!0)})}if(s&&u.endRow!==a-1){const h=u.endRow+1;t.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((g,_,f)=>{f.v&&(u.endRow=Math.max(g+(f.rowSpan!==void 0?f.rowSpan-1:0),u.endRow),u.startColumn=Math.min(_,u.startColumn),u.endColumn=Math.max(_,u.endColumn),d=!0)})}if(n&&u.startColumn!==0){const h=u.startColumn-1;t.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((g,_,f)=>{f.v&&(u.startColumn=Math.min(_,u.startColumn),u.startRow=Math.min(g,u.startRow),u.endRow=Math.max(g,u.endRow),d=!0)})}if(r&&u.endColumn!==c-1){const h=u.endColumn+1;t.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((g,_,f)=>{f.v&&(u.endColumn=Math.max(_+(f.colSpan!==void 0?f.colSpan-1:0),u.endColumn),u.startRow=Math.min(g,u.startRow),u.endRow=Math.max(g,u.endRow),d=!0)})}}return u}function Fr(i){return{startRow:0,startColumn:0,endRow:i.getRowCount()-1,endColumn:i.getColumnCount()-1,rangeType:l.RANGE_TYPE.ALL}}function wn(i,e,t){let n;switch(e){case l.Direction.UP:n={startRow:i.startRow,startColumn:i.startColumn,endRow:i.startRow,endColumn:i.endColumn,rangeType:l.RANGE_TYPE.NORMAL};break;case l.Direction.DOWN:n={startRow:i.endRow,startColumn:i.startColumn,endRow:i.endRow,endColumn:i.endColumn,rangeType:l.RANGE_TYPE.NORMAL};break;case l.Direction.LEFT:n={startRow:i.startRow,startColumn:i.startColumn,endRow:i.endRow,endColumn:i.startColumn,rangeType:l.RANGE_TYPE.NORMAL};break;case l.Direction.RIGHT:n={startRow:i.startRow,startColumn:i.endColumn,endRow:i.endRow,endColumn:i.endColumn,rangeType:l.RANGE_TYPE.NORMAL};break;default:throw new Error("Invalid direction")}return p.alignToMergedCellsBorders(n,t,!1)}function mn(i,e,t,n,r){let o=!1;const s=i.getMatrixWithMergedCells(e,t,n,r).forValue((a,c,d)=>{if(d.v)return o=!0,!1});return{hasValue:o,matrix:s}}function Ji(i,e,t){const n=l.Rectangle.clone(i);if(e==null)return n;switch(t){case l.Direction.UP:case l.Direction.DOWN:n.startColumn=n.endColumn=e.actualColumn;break;case l.Direction.LEFT:case l.Direction.RIGHT:n.startRow=n.endRow=e.actualRow;break}return n}function Fa(i,e,t){const{primary:n,range:r}=i,o=l.Rectangle.clone(r);switch(e){case l.Direction.UP:case l.Direction.DOWN:o.startRow=n.startRow,o.endRow=n.endRow;break;case l.Direction.LEFT:case l.Direction.RIGHT:o.startColumn=n.startColumn,o.endColumn=n.endColumn;break}const s=wn(o,e,t);switch(e){case l.Direction.DOWN:return r.startRow<s.startRow;case l.Direction.UP:return r.endRow>s.endRow;case l.Direction.LEFT:return s.endColumn<r.endColumn;case l.Direction.RIGHT:return s.startColumn>r.startColumn}}var gt=(i=>(i[i.moveStopeOne=0]="moveStopeOne",i[i.moveGap=1]="moveGap",i[i.moveStepPage=2]="moveStepPage",i[i.moveStepEnd=3]="moveStepEnd",i))(gt||{});const nt={id:"sheet.command.move-selection",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const t=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=t.getActiveSheet(),r=i.get(p.SelectionManagerService).getLast();if(!r)return!1;const{direction:o,jumpOver:s}=e,{range:a,primary:c}=r,d=Ji(a,c,o),u=s===1?dr(d,o,n):xt(d,o,n),h=p.getCellAtRowCol(u.startRow,u.startColumn,n);return l.Rectangle.equals(h,d)?!1:(i.get(R.ShortcutExperienceService).remove({unitId:t.getUnitId(),sheetId:n.getSheetId(),keycode:R.KeyCode.TAB}),i.get(l.ICommandService).executeCommand(p.SetSelectionsOperation.id,{unitId:t.getUnitId(),subUnitId:n.getSheetId(),pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:l.Rectangle.clone(h),primary:{startRow:h.startRow,startColumn:h.startColumn,endRow:h.endRow,endColumn:h.endColumn,actualRow:u.startRow,actualColumn:u.startColumn,isMerged:h.isMerged,isMergedMainCell:h.startRow===u.startRow&&h.startColumn===u.startColumn}}]}))}},jt={id:"sheet.command.move-selection-enter-tab",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const t=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=t.getActiveSheet(),r=i.get(p.SelectionManagerService).getLast(),o=t.getUnitId(),s=n.getSheetId();if(!r)return!1;const{direction:a,keycode:c}=e,{range:d,primary:u}=r;let h=Ji(d,u,a);const m=i.get(R.ShortcutExperienceService),g=m.getCurrentBySearch({unitId:o,sheetId:s,keycode:R.KeyCode.TAB});let _;const{startRow:f,endRow:C,startColumn:I,endColumn:w}=d;if(l.Rectangle.equals(d,u)){if(c===R.KeyCode.TAB)g==null&&m.addOrUpdate({unitId:o,sheetId:s,keycode:R.KeyCode.TAB,selection:r});else{const x=g==null?void 0:g.selection;if(x!=null){const{range:N,primary:D}=x;h=Ji(N,D,a)}m.remove({unitId:o,sheetId:s,keycode:R.KeyCode.TAB})}const E=xt(h,a,n),O=p.getCellAtRowCol(E.startRow,E.startColumn,n);if(l.Rectangle.equals(O,h))return!1;_={range:l.Rectangle.clone(O),primary:{startRow:O.startRow,startColumn:O.startColumn,endRow:O.endRow,endColumn:O.endColumn,actualRow:E.startRow,actualColumn:E.startColumn,isMerged:O.isMerged,isMergedMainCell:O.startRow===E.startRow&&O.startColumn===E.startColumn}}}else{m.remove({unitId:o,sheetId:s,keycode:R.KeyCode.TAB});const E=l.Tools.deepClone(u),O=xt({startRow:E.startRow,startColumn:E.startColumn,endRow:E.endRow,endColumn:E.endColumn},a,n,{startRow:f,endRow:C,startColumn:I,endColumn:w}),x=p.getCellAtRowCol(O.startRow,O.startColumn,n);_={range:l.Rectangle.clone(d),primary:{startRow:x.startRow,startColumn:x.startColumn,endRow:x.endRow,endColumn:x.endColumn,actualRow:O.startRow,actualColumn:O.startColumn,isMerged:x.isMerged,isMergedMainCell:x.startRow===O.startRow&&x.startColumn===O.startColumn}}}return i.get(l.ICommandService).executeCommand(p.SetSelectionsOperation.id,{unitId:o,subUnitId:s,pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[_]})}},_t={id:"sheet.command.expand-selection",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const t=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=t.getActiveSheet(),r=i.get(p.SelectionManagerService).getLast();if(!r)return!1;const{range:o,primary:s}=r,{jumpOver:a,direction:c}=e,u=Fa(r,c,n)?a===1?Ua(o,{...l.Rectangle.clone(s),rangeType:l.RANGE_TYPE.NORMAL},c,n):ka(o,c,n):a===1?Ha(o,c,n):La(o,c,n);return l.Rectangle.equals(u,o)?!1:i.get(l.ICommandService).executeCommand(p.SetSelectionsOperation.id,{unitId:t.getUnitId(),subUnitId:n.getSheetId(),pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:u,primary:s}]})}};let ct=[],Hi="";const Ao={id:"sheet.command.select-all",type:l.CommandType.COMMAND,onDispose(){ct=[],Hi=""},handler:async(i,e={expandToGapFirst:!0,loop:!1})=>{const t=i.get(p.SelectionManagerService).getLast(),n=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),r=n.getActiveSheet();if(!t||!r)return!1;const o=`${n.getUnitId()}|${r.getSheetId()}`;o!==Hi&&(ct=[],Hi=o);const s=r.getMaxRows(),a=r.getMaxColumns(),{expandToGapFirst:c,loop:d}=e,{range:u,primary:h}=t,m=u.endColumn===a-1&&u.endRow===s-1&&u.startRow===0&&u.startColumn===0;ct.some(_=>l.Rectangle.equals(_,u))||(ct=[],ct.push(u));let g;if(m)if(d){if(ct.findIndex(f=>l.Rectangle.equals(f,u))!==ct.length-1)return!1;g=ct[0]}else return!1;else c?(g=Va(u,{left:!0,right:!0,up:!0,down:!0},r),l.Rectangle.equals(g,u)&&(g=Fr(r))):g=Fr(r);return ct.some(_=>l.Rectangle.equals(_,g))||ct.push(g),i.get(l.ICommandService).executeCommand(p.SetSelectionsOperation.id,{unitId:n.getUnitId(),subUnitId:r.getSheetId(),pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:g,primary:h}]})}};var Ba=Object.defineProperty,ja=Object.getOwnPropertyDescriptor,Wa=(i,e,t,n)=>{for(var r=n>1?void 0:n?ja(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ba(e,t,r),r},Fn=(i,e)=>(t,n)=>e(t,n,i);const za=l.createInterceptorKey("BEFORE_CELL_EDIT"),$a=l.createInterceptorKey("AFTER_CELL_EDIT");exports.EditorBridgeService=class extends l.Disposable{constructor(t,n,r,o){super();v(this,"_editorUnitId",l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);v(this,"_isForceKeepVisible",!1);v(this,"_editorIsDirty",!1);v(this,"_visible",{visible:!1,eventType:y.DeviceInputEventType.Dblclick});v(this,"_currentEditCell",null);v(this,"_currentEditCellState",null);v(this,"_currentEditCellState$",new J.BehaviorSubject(null));v(this,"currentEditCellState$",this._currentEditCellState$.asObservable());v(this,"_visible$",new J.BehaviorSubject(this._visible));v(this,"visible$",this._visible$.asObservable());v(this,"_afterVisible$",new J.BehaviorSubject(this._visible));v(this,"afterVisible$",this._afterVisible$.asObservable());v(this,"interceptor",new l.InterceptorManager({BEFORE_CELL_EDIT:za,AFTER_CELL_EDIT:$a}));this._sheetSkeletonManagerService=t,this._selectionRenderService=n,this._themeService=r,this._currentUniverService=o,this.disposeWithMe(l.toDisposable(()=>{this._currentEditCellState$.complete(),this._currentEditCell=null})),this.disposeWithMe(l.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{priority:-1,handler:s=>s}))),this.disposeWithMe(l.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{priority:-1,handler:s=>s})))}refreshEditCellState(){const t=this.getLatestEditCellState();this._currentEditCellState=t,this._currentEditCellState$.next(t)}setEditCell(t){this._currentEditCell=t;const n=this.getLatestEditCellState();this._currentEditCellState=n,this._currentEditCellState$.next(n)}getEditCellState(){return this._currentEditCellState}getLatestEditCellState(){var te,W;const t=this._currentEditCell;if(t==null)return;const n=this._sheetSkeletonManagerService.getCurrent();if(n==null)return;const{skeleton:r}=n,{primary:o,unitId:s,sheetId:a,scene:c,engine:d}=t,{startRow:u,startColumn:h}=o,m=this._selectionRenderService.convertCellRangeToInfo(o);if(m==null)return;const g=l.makeCellToSelection(m);if(g==null)return;const _=y.getCanvasOffsetByEngine(d);let{startX:f,startY:C,endX:I,endY:w}=g;const{scaleX:E,scaleY:O}=c.getAncestorScale(),{scaleX:x,scaleY:N}=c.getPrecisionScale(),D=c.getScrollXY(this._selectionRenderService.getViewPort());f=y.fixLineWidthByScale(r.convertTransformToOffsetX(f,E,D),x),C=y.fixLineWidthByScale(r.convertTransformToOffsetY(C,O,D),N),I=y.fixLineWidthByScale(r.convertTransformToOffsetX(I,E,D),x),w=y.fixLineWidthByScale(r.convertTransformToOffsetY(w,O,D),N);const P=this._currentUniverService.getCurrentUniverSheetInstance(),L=P.getActiveSheet(),G={workbook:P,worksheet:L,unitId:P.getUnitId(),subUnitId:L.getSheetId(),row:u,col:h},k=this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT)(L.getCell(u,h),G);let ee=k&&r.getCellDocumentModelWithFormula(k);if((!ee||ee.documentModel==null)&&(ee=r.getBlankCellDocumentModel(k)),(te=ee.documentModel)==null||te.setZoomRatio(Math.max(E,O)),(k==null?void 0:k.isInArrayFormulaRange)===!0){const V=(W=ee.documentModel)==null?void 0:W.getBody();V&&(V.textRuns=[{st:0,ed:V.dataStream.length-2,ts:{cl:{rgb:this._themeService.getCurrentTheme().textColorSecondary}}}])}return{position:{startX:f,startY:C,endX:I,endY:w},scaleX:E,scaleY:O,canvasOffset:_,row:u,column:h,unitId:s,sheetId:a,documentLayoutObject:ee,editorUnitId:this._editorUnitId,isInArrayFormulaRange:k==null?void 0:k.isInArrayFormulaRange}}getCurrentEditorId(){return this._editorUnitId}changeVisible(t){this._visible=t,t.visible&&(this._editorIsDirty=!1),this._visible$.next(this._visible),this._afterVisible$.next(this._visible)}isVisible(){return this._visible}enableForceKeepVisible(){this._isForceKeepVisible=!0}disableForceKeepVisible(){this._isForceKeepVisible=!1}isForceKeepVisible(){return this._isForceKeepVisible}changeEditorDirty(t){this._editorIsDirty=t}getEditorDirty(){return this._editorIsDirty}};exports.EditorBridgeService=Wa([Fn(0,j.Inject(exports.SheetSkeletonManagerService)),Fn(1,Ze),Fn(2,j.Inject(l.ThemeService)),Fn(3,l.IUniverInstanceService)],exports.EditorBridgeService);const at=j.createIdentifier("univer.sheet-editor-bridge.service"),mt={id:"sheet.operation.set-cell-edit-visible",type:l.CommandType.OPERATION,handler:(i,e)=>{const t=i.get(at);return e==null?!1:(t.changeVisible(e),!0)}},Tn={id:"sheet.operation.set-cell-edit-visible-arrow",type:l.CommandType.OPERATION,handler:()=>!0};class Nt{constructor(){v(this,"_scrollInfo",new Map);v(this,"_currentScroll",null);v(this,"_scrollInfo$",new J.BehaviorSubject(null));v(this,"scrollInfo$",this._scrollInfo$.asObservable())}dispose(){this._scrollInfo$.complete()}setCurrentScroll(e){this._currentScroll=e,this._refresh(e)}getScrollByParam(e){return this._getCurrentScroll(e)}getCurrentScroll(){return this._getCurrentScroll(this._currentScroll)}addOrReplace(e){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...e})}addOrReplaceNoRefresh(e){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...e},!1)}addOrReplaceByParam(e){this._addByParam(e)}clear(){this._currentScroll!=null&&this._clearByParam(this._currentScroll)}_addByParam(e,t=!0){const{unitId:n,sheetId:r,sheetViewStartColumn:o,sheetViewStartRow:s,offsetX:a,offsetY:c}=e;this._scrollInfo.has(n)||this._scrollInfo.set(n,new Map),this._scrollInfo.get(n).set(r,{sheetViewStartRow:s,sheetViewStartColumn:o,offsetX:a,offsetY:c}),t===!0&&this._refresh({unitId:n,sheetId:r})}_clearByParam(e){this._addByParam({...e,sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),this._refresh(e)}_getCurrentScroll(e){var r;if(e==null)return;const{unitId:t,sheetId:n}=e;return(r=this._scrollInfo.get(t))==null?void 0:r.get(n)}_refresh(e){this._scrollInfo$.next(this._getCurrentScroll(e))}}const on={id:"sheet.operation.set-scroll",type:l.CommandType.OPERATION,handler:(i,e)=>{if(e==null)return!1;const t=i.get(Nt),o=i.get(l.IUniverInstanceService).getUniverSheetInstance(e.unitId).getSheetBySheetId(e.sheetId),{xSplit:s,ySplit:a}=o.getConfig().freeze;return t.addOrReplaceByParam({...e,sheetViewStartRow:e.sheetViewStartRow-a,sheetViewStartColumn:e.sheetViewStartColumn-s}),!0}},Ti={id:"sheet.operation.set-editor-resize",type:l.CommandType.OPERATION,handler:(i,e)=>!0},bt={id:"sheet.operation.set-zoom-ratio",type:l.CommandType.OPERATION,handler:(i,e)=>{const t=i.get(l.IUniverInstanceService).getUniverSheetInstance(e.unitId);if(!t)return!1;const n=t.getSheetBySheetId(e.subUnitId);return n?(n.getConfig().zoomRatio=e.zoomRatio,!0):!1}};var Ya=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xa(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var No={exports:{}},yi={};/**
|
|
6
|
+
`;const f=[];h==null||h.forEach(R=>{R.st>=m[g]&&R.ed<=m[g+1]&&f.push({st:R.st-m[g],ed:R.ed-m[g],ts:R.ts})});const v=this._generateDocumentDataModelSnapshot({body:{dataStream:_,textRuns:f,paragraphs:Sr(_)}});n.setValue(n.getLength(),0,{v:_,p:v}),s.push({}),a&&c.forEach(R=>{const M=n.getDataRange().endRow+1;if(R.index===g){const T=a.shift(),{cellMatrix:w,colProperties:E,rowProperties:y}=this._parseTable(T);w&&w.forValue((x,O,A)=>{n.setValue(M+x,O,A)}),s.push(...y)}})}}else{if(u){const m=`${u}\r
|
|
7
|
+
`,g={dataStream:m,textRuns:h,paragraphs:Sr(m)},_=this._generateDocumentDataModelSnapshot({body:g});n.setValue(0,0,{v:u,p:_}),s.push({})}a&&a.forEach(m=>{const g=n.getDataRange().endRow+1,{cellMatrix:_}=this._parseTable(m);_&&_.forValue((f,v,R)=>{const{rowSpan:M=1,colSpan:T=1}=R;for(let w=0;w<M;w++)for(let E=0;E<T;E++)n.setValue(g+f+w,v+E,{v:""});n.setValue(g+f,v,R)}),s.push(...s)})}return{rowProperties:[],colProperties:[],cellMatrix:n}}_parseTable(e){const t=new l.ObjectMatrix;Gs(e);const{rowProperties:n,rowCount:r,cellMatrix:o}=Ys(e);return o&&o.forValue((s,a,c)=>{var u;const d=I.handleStringToStyle(void 0,(u=c.properties)==null?void 0:u.style);if(/\r|\n/.test(c.content)){const h=to(c.content),m=this._generateDocumentDataModelSnapshot({body:h});t.setValue(s,a,{v:c.content,p:m,s:d,rowSpan:c.rowSpan,colSpan:c.colSpan})}else t.setValue(s,a,{v:c.content,s:d,rowSpan:c.rowSpan,colSpan:c.colSpan})}),{rowProperties:[],colProperties:[],cellMatrix:t}}_generateDocumentDataModelSnapshot(e){var a;const t=this.getCurrentSkeleton();if(t==null)return null;const{skeleton:n}=t,r=(a=n.getBlankCellDocumentModel())==null?void 0:a.documentModel,s={...r==null?void 0:r.getSnapshot(),...e};return r==null||r.reset(s),r==null?void 0:r.getSnapshot()}process(e,t,n,r){var o,s;for(const a of t)if(a.nodeName.toLowerCase()==="table")r.push({index:((o=n==null?void 0:n.paragraphs)==null?void 0:o.length)||0});else if(a.nodeType===Node.TEXT_NODE){const c=(s=a.nodeValue)==null?void 0:s.replace(/[\r\n]/g,"");let d;e&&this.styleCache.has(e)&&(d=this.styleCache.get(e));const u={dataStream:"",textRuns:[]};n.dataStream+=c,u.dataStream+=c,d&&Object.getOwnPropertyNames(d).length&&(n.textRuns.push({st:n.dataStream.length-c.length,ed:n.dataStream.length,ts:d}),u.textRuns.push({st:n.dataStream.length-c.length,ed:n.dataStream.length,ts:d}))}else if(a.nodeType===Node.ELEMENT_NODE){const c=e?this.styleCache.get(e):{},d=this.styleRules.find(({filter:g})=>fr(a,g)),u=d?d.getStyle(a):Ni(a);this.styleCache.set(a,{...c,...u});const{childNodes:h}=a;this.process(a,h,n,r);const m=this.afterProcessRules.find(({filter:g})=>fr(a,g));m&&m.handler(n,a)}}};C(Xn,"pluginList",[]);let Xt=Xn;function Ys(i){const e=/<tr([\s\S]*?)>([\s\S]*?)<\/tr>/gi,t=i.matchAll(e);if(!t)return{rowProperties:[],rowCount:0,colCount:0,cellMatrix:null};const n=Array.from(t),r=n.map(a=>Hi(a[1])),{colCount:o,cellMatrix:s}=Zs(n.map(a=>a[2]));return{rowProperties:r,rowCount:r.length,colCount:o,cellMatrix:s}}function Zs(i){const e=new l.ObjectMatrix,t=new Map,n=/<td([\s\S]*?)>([\s\S]*?)<\/td>/gi;let r=0,o=0,s=0;return i.forEach((a,c)=>{const d=c===0,u=a.matchAll(n);o=0,Array.from(u).forEach(h=>{const m=Hi(h[1]),g=Ks(h[2].replace("<br>","\r").replace(/<\/?[^>]*>/g,"")),_=m.rowspan?+m.rowspan:1,f=m.colspan?+m.colspan:1;if(!d){for(let R=o;R<r;R++)if(!(t.get(R)>=s)){o=R;break}}const v={content:g,properties:m};f>1&&(v.colSpan=+f),_>1&&(v.rowSpan=+_),d&&(r+=f);for(let R=o;R<o+f;R++)t.set(R,s+_-1);e.setValue(s,o,v),o+=f}),s+=1}),{colCount:r,cellMatrix:e}}function Hi(i){if(!i)return{};const e=/([\w-]+)="([^"]*)"/gi,t=i.matchAll(e),n={};return Array.from(t).forEach(r=>{const[o,s,a]=r;n[s]=a}),n}function Gs(i){const e=/<colgroup([\s\S]*?)>(.*?)<\/colgroup>/,t=i.match(e);if(!t||!t[2])return null;const n=/<col([\s\S]*?)>/g,r=t[2].matchAll(n);return r?Array.from(r).map(o=>Hi(o[1])):null}function Ks(i){const e={"<":"<",">":">","&":"&",""":'"',"'":"'"," ":" "};return i.replace(/<|>|&|"|'| |<br>/g,t=>e[t])}const qs={name:"univer-doc-paste-plugin-lark",checkPasteType(i){return/lark-record-clipboard/i.test(i)},stylesRules:[{filter:["s"],getStyle(i){const e=Ni(i);return{st:{s:l.BooleanNumber.TRUE},...e}}}],afterProcessRules:[{filter(i){return i.tagName==="DIV"&&/ace-line/i.test(i.className)},handler(i){i.paragraphs==null&&(i.paragraphs=[]),i.paragraphs.push({startIndex:i.dataStream.length}),i.dataStream+="\r"}}]},Js=qs,Qs={name:"univer-doc-paste-plugin-word",checkPasteType(i){return/word|mso/i.test(i)},stylesRules:[{filter:["b"],getStyle(i){const e=Ni(i);return{bl:l.BooleanNumber.TRUE,...e}}}],afterProcessRules:[{filter(i){return i.tagName==="P"&&/mso/i.test(i.className)},handler(i,e){i.paragraphs==null&&(i.paragraphs=[]);const t={startIndex:i.dataStream.length},n=Xs(e);n&&(t.paragraphStyle=n),i.paragraphs.push(t),i.dataStream+="\r"}}]},ea=Qs;function ta(i,e,t,n){const r=t.map(c=>{var d;return(d=c.onCopyRow)==null?void 0:d.call(c,i)}).filter(c=>!!c),o=Pi(r),s=Li(o),a=e.map(c=>na(i,c,t,n)).filter(c=>!!c).join("");return`<tr${s}>${a}</tr>`}function na(i,e,t,n){const r=n.getValue(i,e),o=t.map(d=>{var u;return(u=d.onCopyCellStyle)==null?void 0:u.call(d,i,e,r==null?void 0:r.rowSpan,r==null?void 0:r.colSpan)}).filter(d=>!!d),s=Pi(o),a=Li(s),c=t.reduce((d,u)=>{var h;return d||((h=u.onCopyCellContent)==null?void 0:h.call(u,i,e))||""},"");return`<td${a}>${c}</td>`}function ia(i,e){return`<colgroup>${i.map(n=>{const r=e.map(a=>{var c;return(c=a.onCopyColumn)==null?void 0:c.call(a,n)}).filter(a=>!!a),o=Pi(r);return`<col ${Li(o)}>`}).join("")}</colgroup>`}function Pi(i){return i.reduce((e,t)=>(Object.keys(t).forEach(r=>{e[r]?e[r]+=`;${t[r]}`:e[r]=t[r]}),e),{})}function Li(i){return Object.keys(i).reduce((e,t)=>(e+=` ${t}="${i[t]}"`,e),"")}function ra(i,e){const t=[];for(let n=i;n<=e;n++)t.push(n);return t}class oa{convert(e,t,n){const{startColumn:r,endColumn:o}=t,s=ia(ra(r,o),n),a=[],{startRow:c,endRow:d,startColumn:u,endColumn:h}=e.getDataRange();for(let g=c;g<=d;g++){const _=Array.from({length:h-u+1},(f,v)=>u+v);a.push(ta(g,_,n,e))}return`<google-sheets-html-origin><table xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" border="1" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none">${s}
|
|
8
|
+
<tbody>${a.join("")}</tbody></table>`}}var sa=Object.defineProperty,aa=Object.getOwnPropertyDescriptor,la=(i,e,t,n)=>{for(var r=n>1?void 0:n?aa(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&sa(e,t,r),r},Ye=(i,e)=>(t,n)=>e(t,n,i);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"};Xt.use(ea);Xt.use(Js);const Mt=D.createIdentifier("sheet.clipboard-service");exports.SheetClipboardService=class extends l.Disposable{constructor(t,n,r,o,s,a,c,d){super();C(this,"_clipboardHooks",[]);C(this,"_clipboardHooks$",new N.BehaviorSubject([]));C(this,"clipboardHooks$",this._clipboardHooks$.asObservable());C(this,"_htmlToUSM");C(this,"_usmToHtml");C(this,"_copyMarkId",null);this._logService=t,this._currentUniverService=n,this._selectionManagerService=r,this._clipboardInterfaceService=o,this._undoRedoService=s,this._commandService=a,this._markSelectionService=c,this._sheetSkeletonManagerService=d,this._htmlToUSM=new Xt({getCurrentSkeleton:()=>this._sheetSkeletonManagerService.getCurrent()}),this._usmToHtml=new oa}async copy(t=ot.COPY){const n=this._selectionManagerService.getLast();if(!n)return!1;const r=this._clipboardHooks;r.reduce((R,M)=>{var w;const T=(w=M.getFilteredOutRows)==null?void 0:w.call(M);return T==null||T.forEach(E=>R.add(E)),R},new Set);const{startColumn:o,startRow:s,endColumn:a,endRow:c}=n.range,d=this._currentUniverService.getCurrentUniverSheetInstance(),u=d.getActiveSheet(),h=u.getMatrixWithMergedCells(s,o,c,a),m=new l.ObjectMatrix;for(let R=s;R<=c;R++)for(let M=o;M<=a;M++){const T=h.getValue(R,M);T?m.setValue(R-s,M-o,{...pr(),...l.Tools.deepClone(T)}):m.setValue(R-s,M-o,pr())}r.forEach(R=>{var M;return(M=R.onBeforeCopy)==null?void 0:M.call(R,d.getUnitId(),u.getSheetId(),n.range)});let g=this._usmToHtml.convert(h,n.range,r);const _=ca(m),f=Bs();g=g.replace(/(<[a-z]+)/,(R,M)=>`${M} data-copy-id="${f}"`),an.set(f,{unitId:d.getUnitId(),subUnitId:u.getSheetId(),range:n.range,matrix:m,copyType:t}),await this._clipboardInterfaceService.write(_,g),this._markSelectionService.removeAllShapes();const v=this._selectionManagerService.createCopyPasteSelection();return this._copyMarkId=this._markSelectionService.addShape({...n,style:v}),r.forEach(R=>{var M;return(M=R.onAfterCopy)==null?void 0:M.call(R)}),!0}async cut(){return this.copy(ot.CUT)}async paste(t,n=fe.DEFAULT_PASTE){const r=t.types,o=r.indexOf(I.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await t.getType(I.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()):"",s=r.indexOf(I.HTML_CLIPBOARD_MIME_TYPE)!==-1?await t.getType(I.HTML_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()):"";return s?this._pasteHTML(s,n):o?this._pastePlainText(o,n):(this._logService.error("[SheetClipboardService]","No valid data on clipboard"),!1)}legacyPaste(t,n){return t?this._pasteHTML(t,fe.DEFAULT_PASTE):n?this._pastePlainText(n,fe.DEFAULT_PASTE):Promise.resolve(!1)}addClipboardHook(t){if(this._clipboardHooks.findIndex(r=>r.id===t.id)!==-1)return this._logService.error("[SheetClipboardService]","hook already exists",t.id),{dispose:()=>{}};const n=this._clipboardHooks.findIndex(r=>{const o=r.priority||0;return(t.priority||0)<o});return this._clipboardHooks.splice(n!==-1?n:this._clipboardHooks.length,0,t),this._notifyClipboardHook(),l.toDisposable(()=>{const r=this._clipboardHooks.indexOf(t);r>-1&&(this._clipboardHooks.splice(r,1),this._notifyClipboardHook())})}getClipboardHooks(){return this._clipboardHooks}_notifyClipboardHook(){this._clipboardHooks$.next(this._clipboardHooks)}async _pastePlainText(t,n){const r=this._getPastingTarget();if(!r.selection)return!1;const o=r.selection.range,{unitId:s,subUnitId:a}=r,c=this._clipboardHooks,d=[];if(c.some(_=>{var f;return d.push(_)&&((f=_.onBeforePaste)==null?void 0:f.call(_,{unitId:s,subUnitId:a,range:o}))===!1}))return d.forEach(_=>{var f;return(f=_.onAfterPaste)==null?void 0:f.call(_,!1)}),!1;const h=[],m=[];d.forEach(_=>{var v;const f=(v=_.onPastePlainText)==null?void 0:v.call(_,{unitId:s,subUnitId:a,range:o},t,{pasteType:n});f&&(h.push(...f.redos),m.push(...f.undos))});const g=h.every(_=>this._commandService.executeCommand(_.id,_.params));return g&&this._undoRedoService.pushUndoRedo({unitID:this._currentUniverService.getCurrentUniverSheetInstance().getUnitId(),undoMutations:m,redoMutations:h}),g}async _pasteHTML(t,n){const r=Fs(t);return r&&an.get(r)?this._pasteInternal(r,n):this._pasteExternal(t,n)}async _pasteExternal(t,n){const r=this._getPastingTarget(),{selection:o,unitId:s,subUnitId:a}=r;if(!o)return!1;const{rowProperties:c,colProperties:d,cellMatrix:u}=this._htmlToUSM.convert(t),{startColumn:h,endColumn:m,startRow:g,endRow:_}=u.getDataRange(),f=_-g+1,v=m-h+1;if(!u||m<h||_<g)return!1;const R=this._transformPastedData(f,v,u,o.range);return R?this._pasteUSM({rowProperties:c,colProperties:d,cellMatrix:u},{unitId:s,subUnitId:a,pastedRange:R},n):!1}async _pasteInternal(t,n){var O,A;const r=this._getPastingTarget(),{selection:o,unitId:s,subUnitId:a}=r,c=l.Tools.deepClone(an.get(t)),{range:d,matrix:u,unitId:h,subUnitId:m}=c||{};if(!o||!u||!c||!d||!h||!m||!o||!u||!c)return!1;const g=(O=this._currentUniverService.getUniverSheetInstance(h))==null?void 0:O.getStyles();u.forValue((k,H,B)=>{if(typeof B.s=="string"){const F=l.Tools.deepClone(B);F.s=g==null?void 0:g.getStyleByCell(B),u.setValue(k,H,F)}});const{startColumn:_,endColumn:f,startRow:v,endRow:R}=d,M=this._transformPastedData(R-v+1,f-_+1,u,o.range);if(!M)return!1;const T=(A=this._currentUniverService.getUniverSheetInstance(h))==null?void 0:A.getSheetBySheetId(m);if(!T)return!1;const w=T.getColumnManager(),E=T.getConfig().defaultColumnWidth,y=[];for(let k=_;k<=f;k++){const H=w.getColumnOrCreate(k);y.push({width:`${H.w||E}`})}const x=this._pasteUSM({cellMatrix:u,colProperties:y},{unitId:s,subUnitId:a,pastedRange:M},n,{range:d,unitId:c.unitId,subUnitId:c.subUnitId,copyType:c.copyType,copyId:t});return c.copyType===ot.CUT&&(an.set(t,{...c,matrix:null}),this._copyMarkId&&this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null),x}_pasteUSM(t,n,r,o){const{rowProperties:s,colProperties:a,cellMatrix:c}=t,{unitId:d,subUnitId:u,pastedRange:h}=n,{startColumn:m,endColumn:g}=h,_=g-m+1,f=this._clipboardHooks,v=[];if(f.some(A=>{var k;return v.push(A)&&((k=A.onBeforePaste)==null?void 0:k.call(A,{unitId:d,subUnitId:u,range:h}))===!1}))return v.forEach(A=>{var k;return(k=A.onAfterPaste)==null?void 0:k.call(A,!1)}),!1;if(!c)return!1;const M=o?{unitId:o.unitId,subUnitId:o.subUnitId,range:o.range}:null,T={copyType:(o==null?void 0:o.copyType)||ot.COPY,copyId:o==null?void 0:o.copyId,pasteType:r},w=[],E=[];v.filter(A=>!A.specialPasteInfo&&A.id!==fe.DEFAULT_PASTE||r===A.id).forEach(A=>{var B,F,j;if(s){const z=(B=A.onPasteRows)==null?void 0:B.call(A,{range:h,unitId:d,subUnitId:u},s,{pasteType:r});z&&(w.push(...z.redos),E.push(...z.undos))}const k=(F=A.onPasteColumns)==null?void 0:F.call(A,{range:h,unitId:d,subUnitId:u},a||new Array(_).map(()=>({})),{pasteType:r});k&&(w.push(...k.redos),E.push(...k.undos));const H=(j=A.onPasteCells)==null?void 0:j.call(A,M,{range:h,unitId:d,subUnitId:u},c,T);H&&(w.push(...H.redos),E.push(...H.undos))});const x=this._getSetSelectionOperation(d,u,h,c);x&&w.push(x),this._logService.log("[SheetClipboardService]","pasting mutations",{undoMutationsInfo:E,redoMutationsInfo:w});const O=w.every(A=>this._commandService.executeCommand(A.id,A.params));return O&&this._undoRedoService.pushUndoRedo({unitID:d,undoMutations:E,redoMutations:w}),O}_getSetSelectionOperation(t,n,r,o){var f;const s=(f=this._currentUniverService.getUniverSheetInstance(t))==null?void 0:f.getSheetBySheetId(n);if(!s)return null;const{startRow:a,startColumn:c}=r,d={startRow:a,endRow:a,startColumn:c,endColumn:c},u=S.getPrimaryForRange(d,s),h=o.getValue(0,0),m=(h==null?void 0:h.rowSpan)||1,g=(h==null?void 0:h.colSpan)||1;if(m>1||g>1){const v={startRow:a,endRow:a+m-1,startColumn:c,endColumn:c+g-1};u.startRow=v.startRow,u.endRow=v.endRow,u.startColumn=v.startColumn,u.endColumn=v.endColumn,u.isMerged=!0,u.isMergedMainCell=!0}const _={unitId:t,subUnitId:n,pluginName:S.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:r,primary:u,style:null}]};return{id:S.SetSelectionsOperation.id,params:_}}_getPastingTarget(){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet(),r=this._selectionManagerService.getLast();return{unitId:t.getUnitId(),subUnitId:n.getSheetId(),selection:r}}_transformPastedData(t,n,r,o){const{startRow:s,startColumn:a,endRow:c,endColumn:d}=o,u=c-s+1,h=d-a+1,f=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData().filter(E=>l.Rectangle.intersects({startRow:s,startColumn:a,endRow:c,endColumn:d},E)),v=f[0];let R=0,M=0,T=0,w=0;if(v&&(R=v.startRow,M=v.startColumn,T=v.endRow,w=v.endColumn),u%t===0&&h%n===0)if(f.length>0&&(u!==t||h!==n))if(R===s&&M===a&&T===c&&w===d)if(ga(r))for(let y=0;y<u;y++)for(let x=0;x<h;x++){const O=r.getValue(y%t,x%n);O&&r.setValue(y,x,O)}else r.forValue((y,x,O)=>{O.s=null,delete O.colSpan,delete O.rowSpan});else for(let E=0;E<u;E++)for(let y=0;y<h;y++){const x=r.getValue(E%t,y%n);x&&r.setValue(E,y,x)}else for(let E=0;E<u;E++)for(let y=0;y<h;y++){const x=r.getValue(E%t,y%n);x&&r.setValue(E,y,x)}else if(f.length>0)if(this._topLeftCellsMatch(t,n,o))o.endRow=s+t-1,o.endColumn=a+n-1;else{if(c>v.endRow||d>v.endColumn)return null;r.forValue((y,x,O)=>{O.s=null,delete O.colSpan,delete O.rowSpan})}else o.endRow=s+t-1,o.endColumn=a+n-1;return o}_topLeftCellsMatch(t,n,r){const s=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet(),{startRow:a,startColumn:c,endRow:d,endColumn:u}=r,h=ha(a+t-1,c,c+t-1,s),m=ma(c+n-1,a,a+t-1,s);return!h&&!m}};exports.SheetClipboardService=la([Ye(0,l.ILogService),Ye(1,l.IUniverInstanceService),Ye(2,D.Inject(S.SelectionManagerService)),Ye(3,I.IClipboardInterfaceService),Ye(4,l.IUndoRedoService),Ye(5,l.ICommandService),Ye(6,qt),Ye(7,D.Inject(exports.SheetSkeletonManagerService))],exports.SheetClipboardService);function ca(i){let e="";return i.forRow((t,n)=>{const r=[];n.forEach(o=>{const s=i.getValue(t,o);if(s){const a=da(s);r.push(a)}}),e+=r.join(" "),t!==i.getLength()-1&&(e+=`
|
|
9
|
+
`)}),e}function da(i){const e=i.v;return ua((e==null?void 0:e.toString())||"")}const ua=i=>i.replace(/&/g,"&").replace(/\uFEFF/g,"").replace(/</g,"<").replace(/>/g,">");function ha(i,e,t,n){return n.getMergeData().some(r=>r.startRow<=i&&i<r.endRow&&e<=r.startColumn&&r.startColumn<=t)}function ma(i,e,t,n){return n.getMergeData().some(r=>r.startColumn<=i&&i<r.endColumn&&e<=r.startRow&&r.startRow<=t)}function ga(i){let e=0;return i.forValue((t,n,r)=>{if(r&&e++,e>1)return!1}),e>1}function pr(){return{p:null,v:null,s:null,f:null,si:null,t:null}}function no(i){return ne(i)&&!i.getContextValue(l.EDITOR_ACTIVATED)}const Ui=998,io={id:I.CopyCommand.id,name:"sheet.command.copy",type:l.CommandType.COMMAND,multi:!0,priority:Ui,preconditions:no,handler:async i=>i.get(Mt).copy()},_a={id:I.CutCommand.id,name:"sheet.command.cut",type:l.CommandType.COMMAND,multi:!0,priority:Ui,preconditions:Di,handler:async i=>i.get(Mt).cut()},bt={id:I.PasteCommand.id,type:l.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:Ui,preconditions:no,handler:async(i,e)=>{const t=i.get(l.ILogService);if(t.debug("[SheetPasteCommand]","the focusing element is",document.activeElement),!document.execCommand("paste")){t.debug("[SheetPasteCommand]","failed to execute paste command on the activeElement, trying to use clipboard API.");const o=await i.get(I.IClipboardInterfaceService).read(),s=i.get(Mt);return o.length!==0?s.paste(o[0],e==null?void 0:e.value):!1}return!1}},ro={id:"sheet.command.paste-value",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(bt.id,{value:fe.SPECIAL_PASTE_VALUE})},oo={id:"sheet.command.paste-format",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(bt.id,{value:fe.SPECIAL_PASTE_FORMAT})},so={id:"sheet.command.paste-col-width",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(bt.id,{value:fe.SPECIAL_PASTE_COL_WIDTH})},ao={id:"sheet.command.paste-besides-border",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(bt.id,{value:fe.SPECIAL_PASTE_BESIDES_BORDER})};var Sa=Object.defineProperty,fa=Object.getOwnPropertyDescriptor,pa=(i,e,t,n)=>{for(var r=n>1?void 0:n?fa(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Sa(e,t,r),r},vr=(i,e)=>(t,n)=>e(t,n,i);let Yt=class{constructor(i,e){C(this,"_current",null);C(this,"_shortcutParam",[]);this._currentUniverService=i,this._localeService=e}dispose(){this._shortcutParam=[]}getCurrentBySearch(i){return this._getCurrentBySearch(i)}getCurrent(){return this._getCurrentBySearch(this._current)}addOrUpdate(i){const e=this._getCurrentBySearch({unitId:i.unitId,sheetId:i.sheetId,keycode:i.keycode});if(e!=null){const t=this._shortcutParam.indexOf(e);this._shortcutParam.splice(t,1)}return this._shortcutParam.push(i),e}remove(i){if(i==null)return;const e=this._getCurrentBySearch(i);if(e==null)return;const t=this._shortcutParam.indexOf(e);return this._shortcutParam.splice(t,1)[0]}_getCurrentBySearch(i){return i==null?void 0:this._shortcutParam.find(t=>t.unitId===i.unitId&&t.sheetId===i.sheetId&&t.keycode===i.keycode)}};Yt=pa([vr(0,l.IUniverInstanceService),vr(1,D.Inject(l.LocaleService))],Yt);function Ke(i,e,t,n,r=!0,o=1,s=!0){let a={...i};n==null&&(n={startRow:0,endRow:t.getRowCount()-1,startColumn:0,endColumn:t.getColumnCount()-1});let c;switch(e){case l.Direction.UP:for(c=i.startRow-o;c>-1&&!t.getRowVisible(c);)c-=1;c>=n.startRow?(a.startRow=c,a.endRow=c):s&&(a.startRow=n.endRow,a.endRow=n.endRow,r&&(a=Ke(a,l.Direction.LEFT,t,n,!1)));break;case l.Direction.DOWN:for(c=i.endRow+o;c<t.getRowCount()&&!t.getRowVisible(c);)c+=1;c<=n.endRow?(a.startRow=c,a.endRow=c):s&&(a.startRow=n.startRow,a.endRow=n.startRow,r&&(a=Ke(a,l.Direction.RIGHT,t,n,!1)));break;case l.Direction.LEFT:for(c=i.startColumn-o;c>-1&&!t.getColVisible(c);)c-=1;c>=n.startColumn?(a.startColumn=c,a.endColumn=c):s&&(a.startColumn=n.endColumn,a.endColumn=n.endColumn,r&&(a=Ke(a,l.Direction.UP,t,n,!1)));break;case l.Direction.RIGHT:for(c=i.endColumn+o;c<t.getColumnCount()&&!t.getColVisible(c);)c+=1;c<=n.endColumn?(a.startColumn=c,a.endColumn=c):s&&(a.startColumn=n.startColumn,a.endColumn=n.startColumn,r&&(a=Ke(a,l.Direction.DOWN,t,n,!1)));break}return a}function ki(i,e,t){const n={...i},{startRow:r,startColumn:o,endRow:s,endColumn:a}=Zt(i,e,t);let c=Lt(t,r,o,s,a).hasValue,d=!0,u=!0;for(;u;){if(l.Direction.UP===e){let h=n.startRow-1;for(;h>-1&&!t.getRowVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:g}=Lt(t,h,n.startColumn,h,n.endColumn);if(c&&!m&&!d){u=!1;break}else{if(g.getLength()!==0){let _=h;g.forValue(f=>{_=Math.min(f,_)}),n.startRow=_}else n.startRow=h;if(n.endRow=n.startRow,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.DOWN===e){let h=n.endRow+1;for(;h<t.getRowCount()&&!t.getRowVisible(h);)h+=1;if(h===t.getRowCount()){u=!1;break}const{hasValue:m,matrix:g}=Lt(t,h,n.startColumn,h,n.endColumn);if(c&&!m&&!d){u=!1;break}else{if(g.getLength()!==0){let _=h;g.forValue((f,v,R)=>{_=Math.max(f+(R.rowSpan||1)-1,_)}),n.endRow=_}else n.endRow=h;if(n.startRow=n.endRow,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.LEFT===e){let h=n.startColumn-1;for(;h>-1&&!t.getColVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:g}=Lt(t,n.startRow,h,n.endRow,h);if(c&&!m&&!d){u=!1;break}else{if(g.getLength()!==0){let _=h;g.forValue((f,v)=>{_=Math.min(v,_)}),n.startColumn=_}else n.startColumn=h;if(n.endColumn=n.startColumn,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.RIGHT===e){let h=n.endColumn+1;for(;h<t.getColumnCount()&&!t.getColVisible(h);)h+=1;if(h===t.getColumnCount()){u=!1;break}const{hasValue:m,matrix:g}=Lt(t,n.startRow,h,n.endRow,h);if(c&&!m&&!d){u=!1;break}else{if(g.getLength()!==0){let _=h;g.forValue((f,v,R)=>{_=Math.max(v+(R.colSpan||1)-1,_)}),n.endColumn=_}else n.endColumn=h;if(n.startColumn=n.endColumn,!c&&m){u=!1;break}c=m,d=!1}}}return S.alignToMergedCellsBorders(n,t,!0)}function lo(i,e,t){return Ke(i,e,t,void 0,!1,1,!1)}function va(i,e,t){const n=ki(i,e,t);return S.alignToMergedCellsBorders(l.Rectangle.union(n,i),t,!0)}function Ca(i,e,t){const n=lo(i,e,t),r={startRow:Math.min(i.startRow,n.startRow),startColumn:Math.min(i.startColumn,n.startColumn),endRow:Math.max(i.endRow,n.endRow),endColumn:Math.max(i.endColumn,n.endColumn)};return S.alignToMergedCellsBorders(l.Rectangle.union(i,r),t)}function Ia(i,e,t,n){const r=l.getReverseDirection(t),o=ki(Zt(i,r,n),t,n);return t===l.Direction.UP&&o.startRow<=i.startRow?S.alignToMergedCellsBorders({...e,startColumn:i.startColumn,endColumn:i.endColumn},n,!0):t===l.Direction.DOWN&&o.endRow>=i.endRow?S.alignToMergedCellsBorders({...e,startColumn:i.startColumn,endColumn:i.endColumn},n,!0):t===l.Direction.LEFT&&o.startColumn<=i.startColumn?S.alignToMergedCellsBorders({...e,startRow:i.startRow,endRow:i.endRow},n,!0):t===l.Direction.RIGHT&&o.endColumn>=i.endColumn?S.alignToMergedCellsBorders({...e,startRow:i.startRow,endRow:i.endRow},n,!0):l.Rectangle.union(l.Rectangle.clone(e),o)}function Ra(i,e,t){const n=l.getReverseDirection(e),r=Zt(i,n,t),o=Zt(i,e,t),s=lo(r,e,t);return S.alignToMergedCellsBorders(l.Rectangle.union(o,s),t,!1)}function Ma(i,e,t){const{left:n,right:r,up:o,down:s}=e,a=t.getMaxRows(),c=t.getMaxColumns();let d=!0;const u={...i};for(;d;){if(d=!1,o&&u.startRow!==0){const h=u.startRow-1;t.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((g,_,f)=>{f.v&&(u.startRow=Math.min(g,u.startRow),u.startColumn=Math.min(_,u.startColumn),u.endColumn=Math.max(_,u.endColumn),d=!0)})}if(s&&u.endRow!==a-1){const h=u.endRow+1;t.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((g,_,f)=>{f.v&&(u.endRow=Math.max(g+(f.rowSpan!==void 0?f.rowSpan-1:0),u.endRow),u.startColumn=Math.min(_,u.startColumn),u.endColumn=Math.max(_,u.endColumn),d=!0)})}if(n&&u.startColumn!==0){const h=u.startColumn-1;t.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((g,_,f)=>{f.v&&(u.startColumn=Math.min(_,u.startColumn),u.startRow=Math.min(g,u.startRow),u.endRow=Math.max(g,u.endRow),d=!0)})}if(r&&u.endColumn!==c-1){const h=u.endColumn+1;t.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((g,_,f)=>{f.v&&(u.endColumn=Math.max(_+(f.colSpan!==void 0?f.colSpan-1:0),u.endColumn),u.startRow=Math.min(g,u.startRow),u.endRow=Math.max(g,u.endRow),d=!0)})}}return u}function Cr(i){return{startRow:0,startColumn:0,endRow:i.getRowCount()-1,endColumn:i.getColumnCount()-1,rangeType:l.RANGE_TYPE.ALL}}function Zt(i,e,t){let n;switch(e){case l.Direction.UP:n={startRow:i.startRow,startColumn:i.startColumn,endRow:i.startRow,endColumn:i.endColumn,rangeType:l.RANGE_TYPE.NORMAL};break;case l.Direction.DOWN:n={startRow:i.endRow,startColumn:i.startColumn,endRow:i.endRow,endColumn:i.endColumn,rangeType:l.RANGE_TYPE.NORMAL};break;case l.Direction.LEFT:n={startRow:i.startRow,startColumn:i.startColumn,endRow:i.endRow,endColumn:i.startColumn,rangeType:l.RANGE_TYPE.NORMAL};break;case l.Direction.RIGHT:n={startRow:i.startRow,startColumn:i.endColumn,endRow:i.endRow,endColumn:i.endColumn,rangeType:l.RANGE_TYPE.NORMAL};break;default:throw new Error("Invalid direction")}return S.alignToMergedCellsBorders(n,t,!1)}function Lt(i,e,t,n,r){let o=!1;const s=i.getMatrixWithMergedCells(e,t,n,r).forValue((a,c,d)=>{if(d.v)return o=!0,!1});return{hasValue:o,matrix:s}}function bi(i,e,t){const n=l.Rectangle.clone(i);if(e==null)return n;switch(t){case l.Direction.UP:case l.Direction.DOWN:n.startColumn=n.endColumn=e.actualColumn;break;case l.Direction.LEFT:case l.Direction.RIGHT:n.startRow=n.endRow=e.actualRow;break}return n}function ba(i,e,t){const{primary:n,range:r}=i,o=l.Rectangle.clone(r);switch(e){case l.Direction.UP:case l.Direction.DOWN:o.startRow=n.startRow,o.endRow=n.endRow;break;case l.Direction.LEFT:case l.Direction.RIGHT:o.startColumn=n.startColumn,o.endColumn=n.endColumn;break}const s=Zt(o,e,t);switch(e){case l.Direction.DOWN:return r.startRow<s.startRow;case l.Direction.UP:return r.endRow>s.endRow;case l.Direction.LEFT:return s.endColumn<r.endColumn;case l.Direction.RIGHT:return s.startColumn>r.startColumn}}function co(i,e){let t=i[0].startRow,n=i[0].endRow;i.forEach(o=>{const{startRow:s,endRow:a}=o;t=Math.min(t,s),n=Math.max(n,a)});const r=new Array(n-t+1).fill(!1);return e.forEach(o=>{const{startRow:s,endRow:a}=o;for(let c=Math.max(s,t);c<=Math.min(a,n);c++)r[c-t]=!0}),i.every(o=>{const{startRow:s,endRow:a}=o;for(let c=s;c<=a;c++)if(!r[c-t])return!1;return!0})}function uo(i,e){let t=i[0].startColumn,n=i[0].endColumn;i.forEach(o=>{const{startColumn:s,endColumn:a}=o;t=Math.min(t,s),n=Math.max(n,a)});const r=new Array(n-t+1).fill(!1);return e.forEach(o=>{const{startColumn:s,endColumn:a}=o;for(let c=Math.max(s,t);c<=Math.min(a,n);c++)r[c-t]=!0}),i.every(o=>{const{startColumn:s,endColumn:a}=o;for(let c=s;c<=a;c++)if(!r[c-t])return!1;return!0})}var Le=(i=>(i[i.moveStopeOne=0]="moveStopeOne",i[i.moveGap=1]="moveGap",i[i.moveStepPage=2]="moveStepPage",i[i.moveStepEnd=3]="moveStepEnd",i))(Le||{});const we={id:"sheet.command.move-selection",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const t=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=t.getActiveSheet(),r=i.get(S.SelectionManagerService).getLast();if(!r)return!1;const{direction:o,jumpOver:s}=e,{range:a,primary:c}=r,d=bi(a,c,o),u=s===1?ki(d,o,n):Ke(d,o,n),h=S.getCellAtRowCol(u.startRow,u.startColumn,n);return l.Rectangle.equals(h,d)?!1:(i.get(Yt).remove({unitId:t.getUnitId(),sheetId:n.getSheetId(),keycode:I.KeyCode.TAB}),i.get(l.ICommandService).executeCommand(S.SetSelectionsOperation.id,{unitId:t.getUnitId(),subUnitId:n.getSheetId(),pluginName:S.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:l.Rectangle.clone(h),primary:{startRow:h.startRow,startColumn:h.startColumn,endRow:h.endRow,endColumn:h.endColumn,actualRow:u.startRow,actualColumn:u.startColumn,isMerged:h.isMerged,isMergedMainCell:h.startRow===u.startRow&&h.startColumn===u.startColumn}}]}))}},lt={id:"sheet.command.move-selection-enter-tab",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const t=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=t.getActiveSheet(),r=i.get(S.SelectionManagerService).getLast(),o=t.getUnitId(),s=n.getSheetId();if(!r)return!1;const{direction:a,keycode:c}=e,{range:d,primary:u}=r;let h=bi(d,u,a);const m=i.get(Yt),g=m.getCurrentBySearch({unitId:o,sheetId:s,keycode:I.KeyCode.TAB});let _;const{startRow:f,endRow:v,startColumn:R,endColumn:M}=d;if(l.Rectangle.equals(d,u)){if(c===I.KeyCode.TAB)g==null&&m.addOrUpdate({unitId:o,sheetId:s,keycode:I.KeyCode.TAB,selection:r});else{const E=g==null?void 0:g.selection;if(E!=null){const{range:y,primary:x}=E;h=bi(y,x,a)}m.remove({unitId:o,sheetId:s,keycode:I.KeyCode.TAB})}const T=Ke(h,a,n),w=S.getCellAtRowCol(T.startRow,T.startColumn,n);if(l.Rectangle.equals(w,h))return!1;_={range:l.Rectangle.clone(w),primary:{startRow:w.startRow,startColumn:w.startColumn,endRow:w.endRow,endColumn:w.endColumn,actualRow:T.startRow,actualColumn:T.startColumn,isMerged:w.isMerged,isMergedMainCell:w.startRow===T.startRow&&w.startColumn===T.startColumn}}}else{m.remove({unitId:o,sheetId:s,keycode:I.KeyCode.TAB});const T=l.Tools.deepClone(u),w=Ke({startRow:T.startRow,startColumn:T.startColumn,endRow:T.endRow,endColumn:T.endColumn},a,n,{startRow:f,endRow:v,startColumn:R,endColumn:M}),E=S.getCellAtRowCol(w.startRow,w.startColumn,n);_={range:l.Rectangle.clone(d),primary:{startRow:E.startRow,startColumn:E.startColumn,endRow:E.endRow,endColumn:E.endColumn,actualRow:w.startRow,actualColumn:w.startColumn,isMerged:E.isMerged,isMergedMainCell:E.startRow===w.startRow&&E.startColumn===w.startColumn}}}return i.get(l.ICommandService).executeCommand(S.SetSelectionsOperation.id,{unitId:o,subUnitId:s,pluginName:S.NORMAL_SELECTION_PLUGIN_NAME,selections:[_]})}},Ue={id:"sheet.command.expand-selection",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const t=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=t.getActiveSheet(),r=i.get(S.SelectionManagerService).getLast();if(!r)return!1;const{range:o,primary:s}=r,{jumpOver:a,direction:c}=e,u=ba(r,c,n)?a===1?Ia(o,{...l.Rectangle.clone(s),rangeType:l.RANGE_TYPE.NORMAL},c,n):Ra(o,c,n):a===1?va(o,c,n):Ca(o,c,n);return l.Rectangle.equals(u,o)?!1:i.get(l.ICommandService).executeCommand(S.SetSelectionsOperation.id,{unitId:t.getUnitId(),subUnitId:n.getSheetId(),pluginName:S.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:u,primary:s}]})}};let Ae=[],ai="";const ho={id:"sheet.command.select-all",type:l.CommandType.COMMAND,onDispose(){Ae=[],ai=""},handler:async(i,e={expandToGapFirst:!0,loop:!1})=>{const t=i.get(S.SelectionManagerService).getLast(),n=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),r=n.getActiveSheet();if(!t||!r)return!1;const o=`${n.getUnitId()}|${r.getSheetId()}`;o!==ai&&(Ae=[],ai=o);const s=r.getMaxRows(),a=r.getMaxColumns(),{expandToGapFirst:c,loop:d}=e,{range:u,primary:h}=t,m=u.endColumn===a-1&&u.endRow===s-1&&u.startRow===0&&u.startColumn===0;Ae.some(_=>l.Rectangle.equals(_,u))||(Ae=[],Ae.push(u));let g;if(m)if(d){if(Ae.findIndex(f=>l.Rectangle.equals(f,u))!==Ae.length-1)return!1;g=Ae[0]}else return!1;else c?(g=Ma(u,{left:!0,right:!0,up:!0,down:!0},r),l.Rectangle.equals(g,u)&&(g=Cr(r))):g=Cr(r);return Ae.some(_=>l.Rectangle.equals(_,g))||Ae.push(g),i.get(l.ICommandService).executeCommand(S.SetSelectionsOperation.id,{unitId:n.getUnitId(),subUnitId:r.getSheetId(),pluginName:S.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:g,primary:h}]})}};var wa=Object.defineProperty,Ta=Object.getOwnPropertyDescriptor,Ea=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ta(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&wa(e,t,r),r},ln=(i,e)=>(t,n)=>e(t,n,i);const ya=l.createInterceptorKey("BEFORE_CELL_EDIT"),Oa=l.createInterceptorKey("AFTER_CELL_EDIT");exports.EditorBridgeService=class extends l.Disposable{constructor(t,n,r,o){super();C(this,"_editorUnitId",l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);C(this,"_isForceKeepVisible",!1);C(this,"_editorIsDirty",!1);C(this,"_visible",{visible:!1,eventType:b.DeviceInputEventType.Dblclick});C(this,"_currentEditCell",null);C(this,"_currentEditCellState",null);C(this,"_currentEditCellState$",new N.BehaviorSubject(null));C(this,"currentEditCellState$",this._currentEditCellState$.asObservable());C(this,"_visible$",new N.BehaviorSubject(this._visible));C(this,"visible$",this._visible$.asObservable());C(this,"_afterVisible$",new N.BehaviorSubject(this._visible));C(this,"afterVisible$",this._afterVisible$.asObservable());C(this,"interceptor",new l.InterceptorManager({BEFORE_CELL_EDIT:ya,AFTER_CELL_EDIT:Oa}));this._sheetSkeletonManagerService=t,this._selectionRenderService=n,this._themeService=r,this._currentUniverService=o,this.disposeWithMe(l.toDisposable(()=>{this._currentEditCellState$.complete(),this._currentEditCell=null})),this.disposeWithMe(l.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{priority:-1,handler:s=>s}))),this.disposeWithMe(l.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{priority:-1,handler:s=>s})))}refreshEditCellState(){const t=this.getLatestEditCellState();this._currentEditCellState=t,this._currentEditCellState$.next(t)}setEditCell(t){this._currentEditCell=t;const n=this.getLatestEditCellState();this._currentEditCellState=n,this._currentEditCellState$.next(n)}getEditCellState(){return this._currentEditCellState}getLatestEditCellState(){var F,j;const t=this._currentEditCell;if(t==null)return;const n=this._sheetSkeletonManagerService.getCurrent();if(n==null)return;const{skeleton:r}=n,{primary:o,unitId:s,sheetId:a,scene:c,engine:d}=t,{startRow:u,startColumn:h}=o,m=this._selectionRenderService.convertCellRangeToInfo(o);if(m==null)return;const g=l.makeCellToSelection(m);if(g==null)return;const _=b.getCanvasOffsetByEngine(d);let{startX:f,startY:v,endX:R,endY:M}=g;const{scaleX:T,scaleY:w}=c.getAncestorScale(),{scaleX:E,scaleY:y}=c.getPrecisionScale(),x=c.getScrollXY(this._selectionRenderService.getViewPort());f=b.fixLineWidthByScale(r.convertTransformToOffsetX(f,T,x),E),v=b.fixLineWidthByScale(r.convertTransformToOffsetY(v,w,x),y),R=b.fixLineWidthByScale(r.convertTransformToOffsetX(R,T,x),E),M=b.fixLineWidthByScale(r.convertTransformToOffsetY(M,w,x),y);const O=this._currentUniverService.getCurrentUniverSheetInstance(),A=O.getActiveSheet(),k={workbook:O,worksheet:A,unitId:O.getUnitId(),subUnitId:A.getSheetId(),row:u,col:h},H=this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT)(A.getCell(u,h),k);let B=H&&r.getCellDocumentModelWithFormula(H);if((!B||B.documentModel==null)&&(B=r.getBlankCellDocumentModel(H)),(F=B.documentModel)==null||F.setZoomRatio(Math.max(T,w)),(H==null?void 0:H.isInArrayFormulaRange)===!0){const z=(j=B.documentModel)==null?void 0:j.getBody();z&&(z.textRuns=[{st:0,ed:z.dataStream.length-2,ts:{cl:{rgb:this._themeService.getCurrentTheme().textColorSecondary}}}])}return{position:{startX:f,startY:v,endX:R,endY:M},scaleX:T,scaleY:w,canvasOffset:_,row:u,column:h,unitId:s,sheetId:a,documentLayoutObject:B,editorUnitId:this._editorUnitId,isInArrayFormulaRange:H==null?void 0:H.isInArrayFormulaRange}}getCurrentEditorId(){return this._editorUnitId}changeVisible(t){this._visible=t,t.visible&&(this._editorIsDirty=!1),this._visible$.next(this._visible),this._afterVisible$.next(this._visible)}isVisible(){return this._visible}enableForceKeepVisible(){this._isForceKeepVisible=!0}disableForceKeepVisible(){this._isForceKeepVisible=!1}isForceKeepVisible(){return this._isForceKeepVisible}changeEditorDirty(t){this._editorIsDirty=t}getEditorDirty(){return this._editorIsDirty}};exports.EditorBridgeService=Ea([ln(0,D.Inject(exports.SheetSkeletonManagerService)),ln(1,_e),ln(2,D.Inject(l.ThemeService)),ln(3,l.IUniverInstanceService)],exports.EditorBridgeService);const Te=D.createIdentifier("univer.sheet-editor-bridge.service"),Pe={id:"sheet.operation.set-cell-edit-visible",type:l.CommandType.OPERATION,handler:(i,e)=>{const t=i.get(Te);return e==null?!1:(t.changeVisible(e),!0)}},Gt={id:"sheet.operation.set-cell-edit-visible-arrow",type:l.CommandType.OPERATION,handler:()=>!0};class Je{constructor(){C(this,"_scrollInfo",new Map);C(this,"_currentScroll",null);C(this,"_scrollInfo$",new N.BehaviorSubject(null));C(this,"scrollInfo$",this._scrollInfo$.asObservable())}dispose(){this._scrollInfo$.complete()}setCurrentScroll(e){this._currentScroll=e,this._refresh(e)}getScrollByParam(e){return this._getCurrentScroll(e)}getCurrentScroll(){return this._getCurrentScroll(this._currentScroll)}addOrReplace(e){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...e})}addOrReplaceNoRefresh(e){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...e},!1)}addOrReplaceByParam(e){this._addByParam(e)}clear(){this._currentScroll!=null&&this._clearByParam(this._currentScroll)}_addByParam(e,t=!0){const{unitId:n,sheetId:r,sheetViewStartColumn:o,sheetViewStartRow:s,offsetX:a,offsetY:c}=e;this._scrollInfo.has(n)||this._scrollInfo.set(n,new Map),this._scrollInfo.get(n).set(r,{sheetViewStartRow:s,sheetViewStartColumn:o,offsetX:a,offsetY:c}),t===!0&&this._refresh({unitId:n,sheetId:r})}_clearByParam(e){this._addByParam({...e,sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),this._refresh(e)}_getCurrentScroll(e){var r;if(e==null)return;const{unitId:t,sheetId:n}=e;return(r=this._scrollInfo.get(t))==null?void 0:r.get(n)}_refresh(e){this._scrollInfo$.next(this._getCurrentScroll(e))}}const wt={id:"sheet.operation.set-scroll",type:l.CommandType.OPERATION,handler:(i,e)=>{if(e==null)return!1;const t=i.get(Je),o=i.get(l.IUniverInstanceService).getUniverSheetInstance(e.unitId).getSheetBySheetId(e.sheetId),{xSplit:s,ySplit:a}=o.getConfig().freeze;return t.addOrReplaceByParam({...e,sheetViewStartRow:e.sheetViewStartRow-a,sheetViewStartColumn:e.sheetViewStartColumn-s}),!0}},Zn={id:"sheet.operation.set-editor-resize",type:l.CommandType.OPERATION,handler:(i,e)=>!0},ze={id:"sheet.operation.set-zoom-ratio",type:l.CommandType.OPERATION,handler:(i,e)=>{const t=i.get(l.IUniverInstanceService).getUniverSheetInstance(e.unitId),n=t==null?void 0:t.getSheetBySheetId(e.subUnitId);return n==null?!1:(n.getConfig().zoomRatio=e.zoomRatio,!0)}};var mo={exports:{}},Gn={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.production.min.js
|
|
12
12
|
*
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Za=X,Ga=Symbol.for("react.element"),Ka=Symbol.for("react.fragment"),qa=Object.prototype.hasOwnProperty,Ja=Za.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Qa={key:!0,ref:!0,__self:!0,__source:!0};function Do(i,e,t){var n,r={},o=null,s=null;t!==void 0&&(o=""+t),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)qa.call(e,n)&&!Qa.hasOwnProperty(n)&&(r[n]=e[n]);if(i&&i.defaultProps)for(n in e=i.defaultProps,e)r[n]===void 0&&(r[n]=e[n]);return{$$typeof:Ga,type:i,key:o,ref:s,props:r,_owner:Ja.current}}yi.Fragment=Ka;yi.jsx=Do;yi.jsxs=Do;No.exports=yi;var S=No.exports,tt=function(){return tt=Object.assign||function(i){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},tt.apply(this,arguments)},el=function(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(t[n[r]]=i[n[r]]);return t},Je=X.forwardRef(function(i,e){var t=i.icon,n=i.id,r=i.className,o=i.extend,s=el(i,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),c=X.useRef("_".concat(il()));return Po(t,"".concat(n),{defIds:t.defIds,idSuffix:c.current},tt({ref:e,className:a},s),o)});function Po(i,e,t,n,r){return X.createElement(i.tag,tt(tt({key:e},tl(i,t,r)),n),(nl(i,t).children||[]).map(function(o,s){return Po(o,"".concat(e,"-").concat(i.tag,"-").concat(s),t,void 0,r)}))}function tl(i,e,t){var n=tt({},i.attrs);t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1);var r=e.defIds;return!r||r.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(o){var s=o[0],a=o[1];typeof a=="string"&&(n[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function nl(i,e){var t,n=e.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?tt(tt({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?tt(tt({},r),{attrs:tt(tt({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function il(){return Math.random().toString(36).substring(2,8)}Je.displayName="UniverIcon";var rl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.5261 12.834V14.634C11.5261 14.9654 11.7948 15.234 12.1261 15.234V15.234C12.4575 15.234 12.7261 14.9654 12.7261 14.634V12.834H14.5262C14.8576 12.834 15.1262 12.5654 15.1262 12.234V12.234C15.1262 11.9027 14.8576 11.634 14.5262 11.634H12.7261V9.83401C12.7261 9.50264 12.4575 9.23401 12.1261 9.23401V9.23401C11.7948 9.23401 11.5261 9.50264 11.5261 9.83401V11.634H9.72622C9.39485 11.634 9.12622 11.9027 9.12622 12.234V12.234C9.12622 12.5654 9.39485 12.834 9.72622 12.834H11.5261Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.05352 1.9613C2.39077 1.9613 1.85352 2.49856 1.85352 3.1613V6.7613C1.85352 7.42405 2.39077 7.9613 3.05352 7.9613H6.65352C7.31626 7.9613 7.85352 7.42405 7.85352 6.7613V3.1613C7.85352 2.49856 7.31626 1.9613 6.65352 1.9613H3.05352zM6.65352 3.1613H3.05352L3.05352 6.7613H6.65352V3.1613zM3.05352 9.23401C2.39077 9.23401 1.85352 9.77127 1.85352 10.434V14.034C1.85352 14.6968 2.39077 15.234 3.05352 15.234H6.65352C7.31626 15.234 7.85352 14.6968 7.85352 14.034V10.434C7.85352 9.77127 7.31626 9.23401 6.65352 9.23401H3.05352zM6.65352 10.434H3.05352L3.05352 14.034H6.65352V10.434zM10.3262 7.9613C9.66348 7.9613 9.12622 7.42405 9.12622 6.7613V3.1613C9.12622 2.49856 9.66348 1.9613 10.3262 1.9613H13.9262C14.589 1.9613 15.1262 2.49856 15.1262 3.1613V6.7613C15.1262 7.42405 14.589 7.9613 13.9262 7.9613H10.3262zM10.3262 6.7613V3.1613L13.9262 3.1613V6.7613H10.3262z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ho=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"autofill",ref:e,icon:rl}))});Ho.displayName="Autofill";const ol=Ho;var sl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.6152 4.52067C14.8732 4.77869 14.8732 5.19703 14.6152 5.45505L6.61862 13.4514C6.46241 13.6077 6.20915 13.6077 6.05294 13.4514L1.73512 9.13354C1.4771 8.87551 1.4771 8.45718 1.73513 8.19915C1.99315 7.94113 2.41149 7.94114 2.66951 8.19916L6.19436 11.7241C6.27247 11.8022 6.3991 11.8022 6.47721 11.7241L13.6808 4.52067C13.9388 4.26264 14.3571 4.26264 14.6152 4.52067Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Lo=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"check-mark-single",ref:e,icon:sl}))});Lo.displayName="CheckMarkSingle";const Ri=Lo;var al={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.48712 4.59907C5.23328 4.34523 4.82172 4.34523 4.56788 4.59907C4.31404 4.85291 4.31404 5.26447 4.56788 5.51831L7.9973 8.94773L4.56773 12.3773C4.31389 12.6311 4.31389 13.0427 4.56773 13.2965C4.82157 13.5504 5.23313 13.5504 5.48697 13.2965L8.91654 9.86697L12.3461 13.2965C12.5999 13.5503 13.0114 13.5503 13.2653 13.2965C13.5191 13.0426 13.5191 12.6311 13.2653 12.3772L9.83577 8.94773L13.2651 5.51836C13.519 5.26452 13.519 4.85296 13.2651 4.59912C13.0113 4.34528 12.5997 4.34528 12.3459 4.59912L8.91654 8.02849L5.48712 4.59907Z"}}]},Uo=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"close-single",ref:e,icon:al}))});Uo.displayName="CloseSingle";const ll=Uo;var cl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1213",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0.54 0.32H16.54V16.32H0.54z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_102_1213)"},children:[{tag:"path",attrs:{d:"M1.76539 1.27148C1.89532 1.2465 2.05784 1.23193 2.25712 1.23193H7.39957C7.59852 1.23193 7.76228 1.24644 7.89394 1.27682 8.02979 1.30817 8.13912 1.36697 8.22237 1.45577 8.30591 1.54488 8.35813 1.6636 8.38857 1.80057L8.38913 1.80311C8.41406 1.93772 8.42854 2.10966 8.42854 2.31825V7.47982C8.42854 7.67924 8.41396 7.84153 8.38908 7.97584 8.36281 8.11247 8.3041 8.22717 8.22073 8.31054 8.13704 8.39424 8.02807 8.4472 7.89934 8.4781 7.77208 8.50864 7.60803 8.52313 7.41869 8.52313H2.25712C2.06419 8.52313 1.90591 8.51354 1.77494 8.48836 1.64209 8.46281 1.53156 8.41527 1.4464 8.33054 1.3606 8.24999 1.30815 8.13434 1.27781 8.00286 1.2476 7.87192 1.22815 7.69892 1.22815 7.47982V2.27524C1.22815 2.07123 1.24271 1.90413 1.26761 1.76966 1.29388 1.63303 1.35259 1.51833 1.43596 1.43496 1.52104 1.34988 1.63137 1.30236 1.76275 1.27204L1.76539 1.27148zM2.56975 2.39137C2.49306 2.39568 2.45433 2.41469 2.43395 2.43562 2.41191 2.46884 2.39718 2.51452 2.39715 2.57614L2.40631 4.24285H4.26296V2.39137H2.56975zM5.44152 2.39615V4.24285H7.24998V2.51898C7.24998 2.47398 7.24652 2.44245 7.24141 2.42201 7.23917 2.41305 7.23709 2.40806 7.23591 2.40567 7.22586 2.40059 7.20631 2.39615 7.16061 2.39615H5.44152zM2.40708 5.39751L2.41626 7.22616C2.41626 7.26829 2.41965 7.29933 2.42492 7.32085 2.42882 7.33675 2.43309 7.34502 2.43572 7.34893 2.43572 7.34893 2.43928 7.35079 2.44202 7.35193 2.44831 7.35455 2.45718 7.35739 2.46908 7.35996 2.49304 7.36512 2.52583 7.36847 2.56777 7.36847H4.26774V5.39751H2.40708zM5.44152 5.39751V7.36847H7.09848C7.1739 7.36847 7.21416 7.35941 7.23151 7.35088 7.23281 7.34891 7.23591 7.34357 7.23933 7.33216 7.24553 7.3115 7.24998 7.27978 7.24998 7.23608V5.39751H5.44152zM9.19356 8.15082C9.3235 8.12583 9.48601 8.11127 9.6853 8.11127H14.8277C15.0267 8.11127 15.1905 8.12577 15.3221 8.15616 15.458 8.18751 15.5673 8.2463 15.6506 8.33511 15.7341 8.42421 15.7863 8.54294 15.8167 8.67991L15.8173 8.68245C15.8422 8.81705 15.8567 8.98899 15.8567 9.19759V14.3592C15.8567 14.5586 15.8421 14.7209 15.8173 14.8552 15.791 14.9918 15.7323 15.1065 15.6489 15.1899 15.5652 15.2736 15.4562 15.3265 15.3275 15.3574 15.2003 15.388 15.0362 15.4025 14.8469 15.4025H9.6853C9.49237 15.4025 9.33408 15.3929 9.20312 15.3677 9.07027 15.3421 8.95974 15.2946 8.87458 15.2099 8.78878 15.1293 8.73633 15.0137 8.70599 14.8822 8.67578 14.7513 8.65633 14.5783 8.65633 14.3592V9.15457C8.65633 8.95057 8.67088 8.78346 8.69579 8.649 8.72206 8.51237 8.78077 8.39767 8.86414 8.3143 8.94922 8.22922 9.05955 8.1817 9.19093 8.15138L9.19356 8.15082zM9.99793 9.27071C9.92124 9.27501 9.88251 9.29403 9.86212 9.31496 9.84009 9.34817 9.82536 9.39386 9.82533 9.45548L9.83448 11.1222H11.6911V9.27071H9.99793zM12.8697 9.27549V11.1222H14.6782V9.39831C14.6782 9.35332 14.6747 9.32178 14.6696 9.30135 14.6673 9.29238 14.6653 9.2874 14.6641 9.285 14.654 9.27992 14.6345 9.27549 14.5888 9.27549H12.8697zM9.83525 12.2768L9.84444 14.1055C9.84444 14.1476 9.84783 14.1787 9.8531 14.2002 9.85699 14.2161 9.86127 14.2244 9.86389 14.2283L9.86689 14.2298 9.87019 14.2313C9.87648 14.2339 9.88535 14.2367 9.89726 14.2393 9.92122 14.2445 9.95401 14.2478 9.99594 14.2478H11.6959V12.2768H9.83525zM12.8697 12.2768V14.2478H14.5267C14.6021 14.2478 14.6423 14.2387 14.6597 14.2302 14.661 14.2282 14.6641 14.2229 14.6675 14.2115 14.6737 14.1908 14.6782 14.1591 14.6782 14.1154V12.2768H12.8697z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{d:"M10.0049 2.46747C10.0049 2.06363 10.3323 1.73625 10.7361 1.73625H12.9298C14.1413 1.73625 15.1234 2.71838 15.1234 3.9299V6.12354C15.1234 6.52738 14.796 6.85476 14.3922 6.85476 13.9883 6.85476 13.661 6.52738 13.661 6.12354V3.9299C13.661 3.52606 13.3336 3.19868 12.9298 3.19868H10.7361C10.3323 3.19868 10.0049 2.87131 10.0049 2.46747zM3.42396 10.5108C3.42396 10.107 3.09658 9.77962 2.69274 9.77962 2.2889 9.77962 1.96152 10.107 1.96152 10.5108V12.7045C1.96152 13.916 2.94365 14.8981 4.15517 14.8981H6.34882C6.75266 14.8981 7.08003 14.5707 7.08003 14.1669 7.08003 13.7631 6.75266 13.4357 6.34882 13.4357H4.15517C3.75134 13.4357 3.42396 13.1083 3.42396 12.7045V10.5108z"}}]}]},ko=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"convert-single",ref:e,icon:cl}))});ko.displayName="ConvertSingle";const dl=ko;var ul={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_371_77",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0.87 0.63H16.87V16.63H0.87z"}}]},{tag:"g",attrs:{mask:"url(#mask0_371_77)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.72636 13.5549C9.25212 14.1041 8.48323 14.1041 8.00899 13.5549L1.22579 5.70056C0.46078 4.81474 1.00259 3.30013 2.08448 3.30013L15.6509 3.30013C16.7328 3.30013 17.2746 4.81474 16.5096 5.70056L9.72636 13.5549Z"}}]}]},Vo=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"dropdown-single",ref:e,icon:ul}))});Vo.displayName="DropdownSingle";const Br=Vo;var hl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.90535 4.99197C2.23194 4.82196 2.63451 4.94889 2.80452 5.27548C2.96702 5.58764 3.22397 5.8971 3.57667 6.18615C4.57587 7.00507 6.2535 7.58331 8.21318 7.58331C10.1728 7.58331 11.8505 7.00508 12.8497 6.18616C13.2024 5.8971 13.4593 5.58763 13.6218 5.27549C13.7918 4.94889 14.1944 4.82196 14.521 4.99196C14.8476 5.16197 14.9745 5.56454 14.8045 5.89113C14.5439 6.39185 14.1596 6.83646 13.6948 7.2174C13.6514 7.25301 13.6071 7.28815 13.5621 7.3228L15.0214 8.78205C15.2817 9.0424 15.2817 9.46451 15.0214 9.72486C14.761 9.98521 14.3389 9.98521 14.0785 9.72486L12.3889 8.03522C11.8643 8.28584 11.2846 8.48827 10.6659 8.63563L11.2065 10.6532C11.3018 11.0088 11.0907 11.3744 10.7351 11.4697C10.3794 11.565 10.0139 11.3539 9.91857 10.9983L9.34529 8.85869C8.97555 8.89693 8.59724 8.91664 8.21318 8.91664C7.82639 8.91664 7.44544 8.89665 7.07321 8.85788L6.49971 10.9983C6.40441 11.354 6.03886 11.565 5.68321 11.4697C5.32757 11.3744 5.11651 11.0089 5.2118 10.6532L5.75288 8.63382C5.13793 8.48682 4.5615 8.28539 4.03968 8.03629L2.35121 9.72477C2.09086 9.98512 1.66875 9.98512 1.4084 9.72477C1.14805 9.46442 1.14805 9.04231 1.4084 8.78196L2.86611 7.32424C2.82044 7.28912 2.77557 7.2535 2.73152 7.2174C2.26668 6.83645 1.88248 6.39184 1.62183 5.89114C1.45182 5.56455 1.57876 5.16198 1.90535 4.99197Z"}}]},Fo=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"eyelash-single",ref:e,icon:hl}))});Fo.displayName="EyelashSingle";const ml=Fo;var gl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_367_60",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.06 0.78H16.06V16.78H0.06z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_367_60)"},children:[{tag:"path",attrs:{d:"M5.54303 5.67809C5.41486 5.67809 5.31977 5.55923 5.34791 5.43419L5.43336 5.05446C5.53338 4.62534 5.71701 4.25903 5.99076 3.96308 6.28977 3.63984 6.73293 3.49761 7.27633 3.49761 7.47741 3.49761 7.69254 3.52131 7.92082 3.56601 7.93983 3.56973 7.95869 3.57361 7.9774 3.57766 8.18885 3.62335 8.41593 3.52833 8.49925 3.32869L8.72661 2.78395C8.81351 2.57574 8.71072 2.3376 8.49476 2.27229 8.46253 2.26255 8.42923 2.25268 8.39485 2.24269 8.10639 2.15986 7.76287 2.11572 7.35969 2.11572 6.29909 2.11572 5.50608 2.38292 4.95354 2.88796 4.38882 3.40424 3.98783 4.14273 3.76308 5.11976L2.31598 11.3345C2.2402 11.6722 2.14495 12.0353 2.02739 12.4247 1.90869 12.8169 1.76625 13.2031 1.60116 13.5809 1.43472 13.9595 1.24707 14.3197 1.0385 14.6607.972389 14.7687.904093 14.8718.833608 14.9698.744025 15.0945.813644 15.2766.965497 15.2989 1.6153 15.3945 2.29684 15.2198 2.66091 14.6732 2.80556 14.456 2.94673 14.2082 3.08403 13.9287 3.44529 13.1932 3.78416 12.1538 4.09761 10.801L4.94794 7.15889C4.96907 7.06839 5.04977 7.00436 5.14271 7.00436H7.10372C7.28864 7.00436 7.44946 6.87761 7.49265 6.6978L7.61908 6.17153C7.67951 5.91998 7.48886 5.67809 7.23015 5.67809H5.54303zM13.8 5.86392L11.9914 8.11319 10.8878 5.92109C10.8211 5.77368 10.6743 5.67896 10.5125 5.67896H9.79183C9.48739 5.67896 9.28816 5.99784 9.42165 6.27145L10.8878 9.19857 8.27677 12.2928C8.04481 12.5594 8.23414 12.9751 8.58749 12.9751H9.16501C9.28566 12.9751 9.43944 12.9258 9.5177 12.834L11.5897 10.4084 12.5966 12.7046C12.6575 12.8666 12.8119 12.9751 12.9851 12.9751H13.779C14.062 12.9751 14.2207 12.7611 14.1216 12.4959L12.6517 9.42983C12.6517 9.42983 14.8799 6.59898 15.0802 6.32247 15.2756 6.05285 15.0812 5.67896 14.7482 5.67896H14.145C14.0064 5.67896 13.9122 5.73242 13.8 5.86392z"}}]}]},Bo=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"fx-single",ref:e,icon:gl}))});Bo.displayName="FxSingle";const _l=Bo;var pl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_249",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.37 0.77H16.37V16.77H0.37z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_249)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.12107 2.86418C9.12107 2.45648 8.78669 2.12598 8.37422 2.12598C7.96175 2.12598 7.62737 2.45648 7.62737 2.86418V8.03164H2.39931C1.98684 8.03164 1.65247 8.36214 1.65247 8.76984C1.65247 9.17754 1.98684 9.50805 2.39931 9.50805H7.62737V14.6754C7.62737 15.0831 7.96175 15.4136 8.37422 15.4136C8.78669 15.4136 9.12107 15.0831 9.12107 14.6754V9.50805H14.3489C14.7613 9.50805 15.0957 9.17754 15.0957 8.76984C15.0957 8.36214 14.7613 8.03164 14.3489 8.03164H9.12107V2.86418Z"}}]}]},jo=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"increase-single",ref:e,icon:pl}))});jo.displayName="IncreaseSingle";const fl=jo;var Sl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_556",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.56 0.77H16.56V16.77H0.56z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_556)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.19318 4.76988C1.70089 4.26222 2.524 4.26226 3.03166 4.76997L8.13929 9.87808C8.3736 10.1124 8.75352 10.1124 8.98784 9.8781L14.0959 4.77C14.6036 4.26232 15.4267 4.26232 15.9344 4.77C16.4421 5.27768 16.4421 6.1008 15.9344 6.60848L9.97775 12.5651C9.19667 13.3462 7.93029 13.3462 7.14925 12.5651L1.1931 6.60836C0.685438 6.10065 0.685477 5.27753 1.19318 4.76988Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},Wo=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"more-down-single",ref:e,icon:Sl}))});Wo.displayName="MoreDownSingle";const Qi=Wo;var vl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.52628 3.57095C5.81918 3.26411 6.29405 3.26411 6.58695 3.57095L11.0869 8.28525C11.3798 8.59209 11.3798 9.08958 11.0869 9.39642L6.51623 14.04C6.22334 14.3468 5.74846 14.3468 5.45557 14.04C5.16268 13.7331 5.16268 13.2357 5.45557 12.9288L9.35939 8.979C9.43544 8.90205 9.43652 8.77857 9.36182 8.70031L5.52628 4.68212C5.23339 4.37528 5.23339 3.87779 5.52628 3.57095Z",fillRule:"evenodd",clipRule:"evenodd"}}]},zo=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"more-single",ref:e,icon:vl}))});zo.displayName="MoreSingle";const jr=zo;var Cl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1204",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0.25 0.41H16.25V16.41H0.25z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_1204)"},children:[{tag:"rect",attrs:{width:12.62,height:2.79,x:1.94,y:12.66,fill:"colorChannel1",rx:1.4}},{tag:"path",attrs:{fill:"currentColor",d:"M7.99664 2.57069C7.59302 2.05771 7.10966 1.68854 6.63466 1.50243C6.11882 1.30028 5.40184 1.25862 4.95066 1.83566C4.5486 2.34994 4.581 3.10899 4.82709 3.91045C4.93826 4.27259 5.11865 4.62903 5.37541 4.97266C5.38713 4.98834 5.39945 5.00329 5.41229 5.01752C5.4217 5.02789 5.4314 5.03788 5.44133 5.04746C5.45477 5.06043 5.46874 5.07267 5.48315 5.08419L3.75659 6.81071C3.51774 7.04955 3.51774 7.43683 3.75659 7.67569L7.48775 11.4068C7.72666 11.6457 8.11394 11.6457 8.35278 11.4068L13.0831 6.67651C13.3219 6.43766 13.3219 6.05039 13.0831 5.81155L9.35191 2.08037C9.11306 1.84153 8.72579 1.84153 8.48695 2.08037L7.99664 2.57069ZM7.71181 4.91288C7.72271 4.98224 7.73182 5.05302 7.73898 5.12518C7.77251 5.46131 8.07213 5.70663 8.40825 5.6731C8.74438 5.6396 8.98972 5.33994 8.9562 5.00382C8.90804 4.52113 8.79269 4.0731 8.6291 3.66819L8.91946 3.37784L11.7856 6.24403L10.8608 7.16886H5.12843L7.6582 4.63909C7.67903 4.72777 7.69702 4.81905 7.71181 4.91288ZM7.12302 3.44433C6.8246 3.02658 6.47279 2.75283 6.18833 2.64136C6.05252 2.58814 5.96546 2.58477 5.92656 2.58984C5.92268 2.59037 5.91947 2.59093 5.91678 2.59147L5.91208 2.59257C5.89185 2.62604 5.78612 2.86628 5.99645 3.5514C6.0626 3.76685 6.1728 3.99252 6.34325 4.2241L7.12302 3.44433Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.4434 11.9528C12.8956 11.9528 13.2622 11.5862 13.2622 11.134C13.2622 10.854 12.9483 10.3347 12.7092 9.9798C12.5801 9.78823 12.3066 9.78823 12.1776 9.97981C11.9385 10.3347 11.6246 10.854 11.6246 11.134C11.6246 11.5862 11.9912 11.9528 12.4434 11.9528Z"}}]}]},$o=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"paint-bucket",ref:e,icon:Cl}))});$o.displayName="PaintBucket";const Rl=$o;var Il={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.80805 1.53809C2.10674 1.53809 1.53821 2.10661 1.53821 2.80793V13.6016C1.53821 14.3029 2.10674 14.8714 2.80805 14.8714H9.74456C10.2968 14.8714 10.7446 14.4237 10.7446 13.8714V13.6016V11.128C10.7446 10.9623 10.8789 10.828 11.0446 10.828H13.6017H13.8715C14.4238 10.828 14.8715 10.3803 14.8715 9.82802V2.80793C14.8715 2.10661 14.303 1.53809 13.6017 1.53809H2.80805ZM9.17472 13.6016C9.3404 13.6016 9.47472 13.4673 9.47472 13.3016V11.128C9.47472 10.9623 9.3404 10.828 9.17472 10.828H6.91757C6.75189 10.828 6.61757 10.9623 6.61757 11.128V13.3016C6.61757 13.4673 6.75189 13.6016 6.91757 13.6016H9.17472ZM13.6017 9.25817C13.6017 9.42386 13.4674 9.55818 13.3017 9.55818H11.0446C10.8789 9.55818 10.7446 9.42386 10.7446 9.25818V7.17177C10.7446 7.00608 10.8789 6.87177 11.0446 6.87177H13.3017C13.4674 6.87177 13.6017 7.00608 13.6017 7.17177V9.25817ZM9.17472 9.55818C9.3404 9.55818 9.47472 9.42386 9.47472 9.25818V7.17177C9.47472 7.00608 9.3404 6.87177 9.17472 6.87177H6.91757C6.75189 6.87177 6.61757 7.00608 6.61757 7.17177V9.25817C6.61757 9.42386 6.75189 9.55818 6.91757 9.55818H9.17472ZM13.6017 5.30193C13.6017 5.46761 13.4674 5.60193 13.3017 5.60193H11.0446C10.8789 5.60193 10.7446 5.46761 10.7446 5.30193V3.10793C10.7446 2.94224 10.8789 2.80793 11.0446 2.80793H13.3017C13.4674 2.80793 13.6017 2.94224 13.6017 3.10793V5.30193ZM9.17472 5.60193C9.3404 5.60193 9.47472 5.46761 9.47472 5.30193V3.10793C9.47472 2.94224 9.3404 2.80793 9.17472 2.80793H6.91757C6.75189 2.80793 6.61757 2.94224 6.61757 3.10793V5.30193C6.61757 5.46761 6.75189 5.60193 6.91757 5.60193H9.17472ZM5.34773 3.10793C5.34773 2.94224 5.21342 2.80793 5.04773 2.80793H3.10805C2.94236 2.80793 2.80805 2.94224 2.80805 3.10793V5.30193C2.80805 5.46761 2.94236 5.60193 3.10805 5.60193H5.04773C5.21342 5.60193 5.34773 5.46761 5.34773 5.30193V3.10793ZM5.34773 7.17177C5.34773 7.00608 5.21342 6.87177 5.04773 6.87177H3.10805C2.94236 6.87177 2.80805 7.00608 2.80805 7.17177V9.25817C2.80805 9.42386 2.94236 9.55818 3.10805 9.55818H5.04773C5.21342 9.55818 5.34773 9.42386 5.34773 9.25818V7.17177ZM5.34773 11.128C5.34773 10.9623 5.21342 10.828 5.04773 10.828H3.10805C2.94236 10.828 2.80805 10.9623 2.80805 11.128V13.3016C2.80805 13.4673 2.94236 13.6016 3.10805 13.6016H5.04773C5.21342 13.6016 5.34773 13.4673 5.34773 13.3016V11.128Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.3869 12.1183C12.361 11.9546 12.5342 11.8323 12.6798 11.9114L14.9901 13.1655C15.1577 13.2565 15.1137 13.5049 14.932 13.5378C14.9212 13.5398 14.9102 13.5417 14.8996 13.5446L13.8966 13.8224L13.1603 14.7467C13.0651 14.9084 12.8197 14.8618 12.7904 14.6764L12.3869 12.1183Z"}}]},Yo=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"select-range-single",ref:e,icon:Il}))});Yo.displayName="SelectRangeSingle";const bl=Yo,Ml="univer-range-selector",wl="univer-range-selector-editor",Tl="univer-range-selector-icon",yl="univer-range-selector-active",Ht={rangeSelector:Ml,rangeSelectorEditor:wl,rangeSelectorIcon:Tl,rangeSelectorActive:yl};function El(i){const{onChange:e,onActive:t}=i,[n,r]=X.useState(!1),o=X.useRef(null),s=me.useDependency(l.LocaleService),a=me.useDependency(p.SelectionManagerService);X.useEffect(()=>{var m;if(n){t(n);const g=a.selectionMoveEnd$.subscribe(_=>{const f=["A1","B2:C3","Sheet2!A1:B2","D10:E11,F1:G2,H3:I4"],C=Math.floor(Math.random()*f.length),I=f[C];o.current&&(o.current.innerHTML=I)});return document.addEventListener("click",c),()=>{document.removeEventListener("click",c),g.unsubscribe()}}e(((m=o.current)==null?void 0:m.innerHTML)||"")},[n]);function c(m){var C,I,w;if(((C=m.target)==null?void 0:C.closest('[data-range-selector="true"]'))||m.target===o.current)return;const _=(I=m.target)==null?void 0:I.closest(`.${Ht.rangeSelector}`);(_==null?void 0:_.querySelector(`.${Ht.rangeSelectorEditor}`))!==o.current&&(r(!1),(w=o.current)==null||w.blur())}function d(m){m.stopPropagation(),m.key==="Enter"&&(m.preventDefault(),m.currentTarget.blur(),r(!1))}function u(){r(!0)}function h(){var m;if(!n){(m=o.current)==null||m.focus();return}r(!n)}return S.jsxs("div",{className:n?`${Ht.rangeSelector} ${Ht.rangeSelectorActive}`:Ht.rangeSelector,children:[S.jsx("div",{ref:o,className:Ht.rangeSelectorEditor,contentEditable:!0,"data-placeholder":s.t("rangeSelector.placeholder"),onKeyDown:d,onFocus:u}),S.jsx(Ye.Tooltip,{title:s.t("rangeSelector.tooltip"),placement:"bottom",children:S.jsx("button",{className:Ht.rangeSelectorIcon,onClick:h,children:S.jsx(bl,{})})})]})}var Kt=(i=>(i.Append="APPEND",i.Default="DEFAULT",i.Only="ONLY",i))(Kt||{}),We=(i=>(i.NUMBER="number",i.DATE="date",i.EXTEND_NUMBER="extendNumber",i.CHN_NUMBER="chnNumber",i.CHN_WEEK2="chnWeek2",i.CHN_WEEK3="chnWeek3",i.LOOP_SERIES="loopSeries",i.FORMULA="formula",i.OTHER="other",i))(We||{}),Te=(i=>(i.COPY="0",i.SERIES="1",i.ONLY_FORMAT="2",i.NO_FORMAT="3",i))(Te||{});const Ol={type:We.NUMBER,priority:1e3,match:i=>typeof(i==null?void 0:i.v)=="number"||!isNaN(Number(i==null?void 0:i.v)),isContinue:(i,e)=>i.type===We.NUMBER,applyFunctions:{[Te.SERIES]:(i,e,t)=>{const{data:n}=i;return t===l.Direction.LEFT||t===l.Direction.UP?(n.reverse(),yr(n,e).reverse()):yr(n,e)}}},Xo={type:We.OTHER,priority:0,match:()=>!0,isContinue:(i,e)=>i.type===We.OTHER},xl={type:We.EXTEND_NUMBER,priority:900,match:i=>Un(`${i==null?void 0:i.v}`||"").isExtendNumber,isContinue:(i,e)=>{var t;if(i.type===We.EXTEND_NUMBER){const{beforeTxt:n,afterTxt:r}=Un(`${(t=i.cellData)==null?void 0:t.v}`||""),{beforeTxt:o,afterTxt:s}=Un(`${e==null?void 0:e.v}`||"");if(n===o&&r===s)return!0}return!1},applyFunctions:{[Te.SERIES]:(i,e,t)=>{var s;const{data:n}=i;let r;if(n.length===1)return r=t===l.Direction.DOWN||t===l.Direction.RIGHT?1:-1,Er(n,e,r);const o=[];for(let a=0;a<n.length;a++){const c=`${(s=n[a])==null?void 0:s.v}`;c&&o.push(Number(Un(c).matchTxt))}return(t===l.Direction.UP||t===l.Direction.LEFT)&&(n.reverse(),o.reverse()),En(o)?(r=o[1]-o[0],Er(n,e,r)):Bt(n,e)}}},Al={type:We.CHN_NUMBER,priority:830,match:i=>!!xs(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>i.type===We.CHN_NUMBER,applyFunctions:{[Te.SERIES]:(i,e,t)=>{var c,d,u;const{data:n}=i,r=t===l.Direction.LEFT||t===l.Direction.UP;if(n.length===1){const h=`${(c=n[0])==null?void 0:c.v}`;let m;return r?m=-1:m=1,h&&(h==="日"||It(h)<7)?en(n,e,m):Or(n,e,m)}let o=!1;for(let h=0;h<n.length;h++)if(((d=n[h])==null?void 0:d.v)==="日"){o=!0;break}const s=[];let a=0;for(let h=0;h<n.length;h++){const m=`${(u=n[h])==null?void 0:u.v}`;m==="日"?h===0?s.push(0):(a++,s.push(a*7)):o&&It(m)>0&&It(m)<7?s.push(It(m)+a*7):s.push(It(m))}if(r&&(n.reverse(),s.reverse()),En(s)){if(o||s[s.length-1]<6&&s[0]>0||s[0]<6&&s[s.length-1]>0){const m=s[1]-s[0];return en(n,e,m)}const h=s[1]-s[0];return Or(n,e,h)}return Bt(n,e)}}},Nl={type:We.CHN_WEEK2,priority:820,match:i=>!!As(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>i.type===We.CHN_WEEK2,applyFunctions:{[Te.SERIES]:(i,e,t)=>{var a;const{data:n}=i,r=t===l.Direction.LEFT||t===l.Direction.UP;if(n.length===1){let c;return r?c=-1:c=1,en(n,e,c,1)}const o=[];let s=0;for(let c=0;c<n.length;c++){const d=`${(a=n[c])==null?void 0:a.v}`,u=d==null?void 0:d.substr(d.length-1,1);d==="周日"?c===0?o.push(0):(s++,o.push(s*7)):o.push(It(u)+s*7)}if(r&&(n.reverse(),o.reverse()),En(o)){const c=o[1]-o[0];return en(n,e,c,1)}return Bt(n,e)}}},Dl={type:We.CHN_WEEK3,priority:810,match:i=>Ns(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>i.type===We.CHN_WEEK3,applyFunctions:{[Te.SERIES]:(i,e,t)=>{var a;const{data:n}=i,r=t===l.Direction.LEFT||t===l.Direction.UP;if(n.length===1){let c;return r?c=-1:c=1,en(n,e,c,2)}const o=[];let s=0;for(let c=0;c<n.length;c++){const d=`${(a=n[c])==null?void 0:a.v}`;if(d){const u=d.substr(d.length-1,1);d==="星期日"?c===0?o.push(0):(s++,o.push(s*7)):o.push(It(u)+s*7)}}if(r&&(n.reverse(),o.reverse()),En(o)){const c=o[1]-o[0];return en(n,e,c,2)}return Bt(n,e)}}},Pl={type:We.LOOP_SERIES,priority:800,match:i=>Vs(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>{var t;return i.type===We.LOOP_SERIES?Pi(`${(t=i.cellData)==null?void 0:t.v}`||"").name===Pi(`${e==null?void 0:e.v}`||"").name:!1},applyFunctions:{[Te.SERIES]:(i,e,t)=>{var c,d;const{data:n}=i,r=t===l.Direction.LEFT||t===l.Direction.UP,{series:o}=Pi(`${(c=n[0])==null?void 0:c.v}`||"");if(n.length===1){let u;return r?u=-1:u=1,xr(n,e,u,o)}const s=[];let a=0;for(let u=0;u<n.length;u++){const h=`${(d=n[u])==null?void 0:d.v}`;h&&(h===o[0]?u===0?s.push(0):(a++,s.push(a*o.length)):s.push(o.indexOf(h)+a*7))}if(r&&(n.reverse(),s.reverse()),En(s)){const u=s[1]-s[0];return xr(n,e,u,o)}return Bt(n,e)}}};var Hl=Object.defineProperty,Ll=Object.getOwnPropertyDescriptor,Ul=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ll(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Hl(e,t,r),r},Li=(i,e)=>(t,n)=>e(t,n,i);exports.AutoFillService=class extends l.Disposable{constructor(t,n,r){super();v(this,"_rules",[]);v(this,"_hooks",[]);v(this,"_applyType$",new J.BehaviorSubject(Te.SERIES));v(this,"_isFillingStyle",!0);v(this,"_autoFillLocation$",new J.BehaviorSubject(null));v(this,"autoFillLocation$",this._autoFillLocation$.asObservable());v(this,"_showMenu$",new J.BehaviorSubject(!1));v(this,"showMenu$",this._showMenu$.asObservable());v(this,"_direction",l.Direction.DOWN);v(this,"applyType$",this._applyType$.asObservable());v(this,"_menu$",new J.BehaviorSubject([{label:"autoFill.copy",value:Te.COPY,disable:!1},{label:"autoFill.series",value:Te.SERIES,disable:!1},{label:"autoFill.formatOnly",value:Te.ONLY_FORMAT,disable:!1},{label:"autoFill.noFormat",value:Te.NO_FORMAT,disable:!1}]));v(this,"menu$",this._menu$.asObservable());this._sheetInterceptorService=t,this._univerInstanceService=n,this._selectionManagerService=r,this._init()}_init(){this._rules=[Ol,xl,Al,Nl,Dl,Pl,Xo].sort((t,n)=>n.priority-t.priority),this._isFillingStyle=!0}getOneByPriority(t){return t.length<=0?[]:[t.reduce((r,o)=>(o.priority||0)>(r.priority||0)?o:r,t[0])]}addHook(t){if(this._hooks.find(n=>n.id===t.id))throw new Error(`Add hook failed, hook id '${t.id}' already exist!`);return t.priority===void 0&&(t.priority=0),t.type===void 0&&(t.type=Kt.Append),this._hooks.push(t),l.toDisposable(()=>{const n=this._hooks.findIndex(r=>r===t);n>-1&&this._hooks.splice(n,1)})}registerRule(t){if(this._rules.find(r=>r.type===t.type))throw new Error(`Registry rule failed, type '${t.type}' already exist!`);const n=this._rules.findIndex(r=>r.priority<t.priority);this._rules.splice(n===-1?this._rules.length:n,0,t)}getRules(){return this._rules}getAllHooks(){return this._hooks}getActiveHooks(){const{source:t,target:n,unitId:r,subUnitId:o}=this.autoFillLocation||{};if(!t||!n||!r||!o)return[];const s=this._hooks.filter(u=>{var h;return!((h=u.disable)!=null&&h.call(u,{source:t,target:n,unitId:r,subUnitId:o},this._direction,this.applyType))}),a=s.filter(u=>u.type===Kt.Only);if(a.length>0)return this.getOneByPriority(a);const c=this.getOneByPriority(s.filter(u=>u.type===Kt.Default)),d=s.filter(u=>u.type===Kt.Append)||[];return[...c,...d]}get applyType(){return this._applyType$.getValue()}set applyType(t){this._applyType$.next(t)}get menu(){return this._menu$.getValue()}get direction(){return this._direction}set direction(t){this._direction=t}isFillingStyle(){return this._isFillingStyle}setFillingStyle(t){this._isFillingStyle=t}get autoFillLocation(){return this._autoFillLocation$.getValue()}set autoFillLocation(t){this._autoFillLocation$.next(t)}setDisableApplyType(t,n){this._menu$.next(this._menu$.getValue().map(r=>r.value===t?{...r,disable:n}:r))}setShowMenu(t){this._showMenu$.next(t)}};exports.AutoFillService=Ul([l.OnLifecycle(l.LifecycleStages.Rendered,exports.AutoFillService),Li(0,j.Inject(p.SheetInterceptorService)),Li(1,j.Inject(l.IUniverInstanceService)),Li(2,j.Inject(p.SelectionManagerService))],exports.AutoFillService);const xn=j.createIdentifier("univer.auto-fill-service");var kl=Object.defineProperty,Vl=Object.getOwnPropertyDescriptor,Fl=(i,e,t,n)=>{for(var r=n>1?void 0:n?Vl(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&kl(e,t,r),r},vt=(i,e)=>(t,n)=>e(t,n,i);exports.AutoFillController=class extends l.Disposable{constructor(t,n,r,o,s,a,c,d,u){super();v(this,"_beforeApplyData",[]);v(this,"_copyData",[]);v(this,"_defaultHook");this._univerInstanceService=t,this._selectionRenderService=n,this._commandService=r,this._undoRedoService=o,this._autoFillService=s,this._editorBridgeService=a,this._sheetInterceptorService=c,this._selectionManagerService=d,this._injector=u,this._defaultHook={id:"default",type:Kt.Default,priority:0,onBeforeFillData:(h,m)=>{this._presetAndCacheData(h,m)},onFillData:(h,m,g)=>this._fillData(h,m,g)},this._init()}_init(){this._initDefaultHook(),this._onSelectionControlFillChanged(),this._onApplyTypeChanged(),[So,zn].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initDefaultHook(){this._autoFillService.addHook(this._defaultHook)}_onSelectionControlFillChanged(){const t=new l.DisposableCollection;this.disposeWithMe(this._commandService.onCommandExecuted(n=>{if(n.id!==p.SetSelectionsOperation.id)return;const r=this._selectionManagerService.getCurrent();if((r==null?void 0:r.pluginName)!==p.NORMAL_SELECTION_PLUGIN_NAME)return;t.dispose(),this._selectionRenderService.getCurrentControls().forEach(s=>{t.add(l.toDisposable(s.selectionFilled$.subscribe(a=>{if(a==null||a.startColumn===-1||a.startRow===-1||a.endColumn===-1||a.endRow===-1)return;const c={startColumn:s.model.startColumn,endColumn:s.model.endColumn,startRow:s.model.startRow,endRow:s.model.endRow},d={startColumn:a.startColumn,endColumn:a.endColumn,startRow:a.startRow,endRow:a.endRow};this._triggerAutoFill(c,d)}))),t.add(l.toDisposable(s.fillControl.onDblclickObserver.add(()=>{const a={startColumn:s.model.startColumn,endColumn:s.model.endColumn,startRow:s.model.startRow,endRow:s.model.endRow};this._handleDbClickFill(a)}))),t.add(l.toDisposable(s.fillControl.onPointerDownObserver.add(()=>{this._editorBridgeService.isVisible().visible&&this._editorBridgeService.changeVisible({visible:!1,eventType:y.DeviceInputEventType.PointerDown})})))})}))}_onApplyTypeChanged(){this.disposeWithMe(l.toDisposable(this._autoFillService.applyType$.subscribe(()=>{this._handleFillData()})))}_triggerAutoFill(t,n){var d;if(t.startColumn===n.startColumn&&t.startRow===n.startRow&&t.endColumn===n.endColumn&&t.endRow===n.endRow)return;if(n.endColumn<t.endColumn&&n.endColumn>t.startColumn){this._commandService.executeCommand(zn.id,{clearRange:{startRow:n.startRow,endRow:n.endRow,startColumn:n.endColumn+1,endColumn:t.endColumn},selectionRange:n});return}if(n.endRow<t.endRow&&n.endRow>t.startRow){this._commandService.executeCommand(zn.id,{clearRange:{startRow:n.endRow+1,endRow:t.endRow,startColumn:n.startColumn,endColumn:n.endColumn},selectionRange:n});return}const r={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn};let o=null;if(n.startRow<t.startRow)o=l.Direction.UP,r.endRow=t.startRow-1;else if(n.endRow>t.endRow)o=l.Direction.DOWN,r.startRow=t.endRow+1;else if(n.startColumn<t.startColumn)o=l.Direction.LEFT,r.endColumn=t.startColumn-1;else if(n.endColumn>t.endColumn)o=l.Direction.RIGHT,r.startColumn=t.endColumn+1;else return;const s=this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),a=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();this._autoFillService.direction=o,this._autoFillService.autoFillLocation={source:t,target:r,unitId:s,subUnitId:a},this._autoFillService.getActiveHooks().forEach(u=>{var h;(h=u==null?void 0:u.onBeforeFillData)==null||h.call(u,{source:t,target:r,unitId:s,subUnitId:a},o)}),(d=this._autoFillService.menu.find(u=>u.value===Te.SERIES))!=null&&d.disable?this._autoFillService.applyType=Te.COPY:this._autoFillService.applyType=Te.SERIES}_handleDbClickFill(t){const n=this._detectFillRange(t);n.endRow<=t.endRow||this._triggerAutoFill(t,n)}_detectFillRange(t){var m,g,_,f,C,I;const{startRow:n,endRow:r,startColumn:o,endColumn:s}=t,a=(m=this._univerInstanceService.getCurrentUniverSheetInstance())==null?void 0:m.getActiveSheet();if(!a)return t;const c=a.getCellMatrix(),d=a.getMaxRows()-1,u=a.getMaxColumns()-1;let h=r;if(o>0&&((g=c.getValue(n,o-1))==null?void 0:g.v)!=null){let w=n;for(;((_=c.getValue(w,o-1))==null?void 0:_.v)!=null&&w<d;)w+=1;h=w-1}else if(s<u&&((f=c.getValue(r,s+1))==null?void 0:f.v)!=null){let w=n;for(;((C=c.getValue(w,s+1))==null?void 0:C.v)!=null&&w<d;)w+=1;h=w-1}for(let w=r+1;w<=h;w++)for(let E=o;E<=s;E++)if(((I=c.getValue(w,E))==null?void 0:I.v)!=null){h=w-1;break}return{startColumn:o,endColumn:s,startRow:n,endRow:h}}_handleFillData(){const{source:t,target:n,unitId:r=this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),subUnitId:o=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId()}=this._autoFillService.autoFillLocation||{},s=this._autoFillService.direction;if(!t||!n)return;const a=l.Rectangle.union(t,n),c=this._autoFillService.applyType,d=this._autoFillService.getActiveHooks();this._commandService.syncExecuteCommand(p.SetSelectionsOperation.id,{selections:[{primary:{...a,actualRow:a.startRow,actualColumn:a.startColumn,endColumn:a.startColumn,endRow:a.startRow},range:{...a,rangeType:l.RANGE_TYPE.NORMAL}}],unitId:r,subUnitId:o});const u=[],h=[];d.forEach(g=>{var C;const{undos:_,redos:f}=((C=g.onFillData)==null?void 0:C.call(g,{source:t,target:n,unitId:r,subUnitId:o},s,c))||{};_&&u.push(..._),f&&h.push(...f)}),h.every(g=>this._commandService.syncExecuteCommand(g.id,g.params))&&this._undoRedoService.pushUndoRedo({unitID:r,undoMutations:u,redoMutations:h}),d.forEach(g=>{var _;(_=g.onAfterFillData)==null||_.call(g,{source:t,target:n,unitId:r,subUnitId:o},s,c)}),this._autoFillService.setShowMenu(!0)}_getApplyData(t,n,r,o,s,a=!0){const c=[],d=Math.floor(r/n),u=r%n,h=this._autoFillService.getRules();if(!a&&s===Te.ONLY_FORMAT)return console.error("ERROR: only format can not be applied when hasStyle is false"),[];const m={};h.forEach(g=>{m[g.type]=[]}),h.forEach(g=>{const{type:_,applyFunctions:f={}}=g,C=t[_];C&&C.forEach(I=>{const w=Ds(I.index,u),E=I.index.length*d+w,O=this._applyFunctions(I,E,o,s,f,t),x=Ps(n,r,I.index);m[_].push({data:O,index:x})})});for(let g=0;g<r;g++)h.forEach(_=>{const{type:f}=_,C=m[f];for(let I=0;I<C.length;I++)g in C[I].index&&c.push(C[I].data[C[I].index[g]])});return c}_applyFunctions(t,n,r,o,s,a){const{data:c}=t,d=r===l.Direction.UP||r===l.Direction.LEFT;if(o===Te.COPY){const u=s==null?void 0:s[Te.COPY];return u?u(t,n,r,a):(d&&c.reverse(),Bt(c,n))}if(o===Te.SERIES){const u=s==null?void 0:s[Te.SERIES];return u?u(t,n,r,a):(d&&c.reverse(),s!=null&&s[Te.COPY]?s[Te.COPY](t,n,r,a):Bt(c,n))}if(o===Te.ONLY_FORMAT){const u=s==null?void 0:s[Te.ONLY_FORMAT];return u?u(t,n,r,a):Hs(c,n)}}_getCopyData(t,n){const{startRow:r,startColumn:o,endRow:s,endColumn:a}=t,c=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getCellMatrix(),d=this._autoFillService.getRules(),u=[],h=n===l.Direction.DOWN||n===l.Direction.UP;let m,g,_,f;h?(m=o,g=a,_=r,f=s):(m=r,g=s,_=o,f=a);for(let C=m;C<=g;C++){const I=this._getEmptyCopyDataPiece(),w={type:void 0,cellData:void 0};for(let E=_;E<=f;E++){let O;h?O=c.getValue(E,C):O=c.getValue(C,E);const{type:x,isContinue:N}=d.find(D=>D.match(O))||Xo;if(N(w,O)){const D=I[x],P=D[D.length-1];P.data.push(O),P.index.push(E-_)}else{const D=I[x];D?D.push({data:[O],index:[E-_]}):I[x]=[{data:[O],index:[E-_]}]}w.type=x,w.cellData=O}u.push(I)}return u}_getEmptyCopyDataPiece(){const t={};return this._autoFillService.getRules().forEach(n=>{t[n.type]=[]}),t}_getMergeApplyData(t,n,r,o){const s=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData(),a=[];for(let c=t.startRow;c<=t.endRow;c++)for(let d=t.startColumn;d<=t.endColumn;d++){const{isMergedMainCell:u,startRow:h,startColumn:m,endRow:g,endColumn:_}=y.getCellInfoInMergeData(c,d,s);if(u){if(r===l.Direction.DOWN){let f=h+o,C=g+o;for(;C<=n.endRow;)a.push({startRow:f,startColumn:m,endRow:C,endColumn:_}),f+=o,C+=o}else if(r===l.Direction.UP){let f=h-o,C=g-o;for(;f>=n.startRow;)a.push({startRow:f,startColumn:m,endRow:C,endColumn:_}),f-=o,C-=o}else if(r===l.Direction.RIGHT){let f=m+o,C=_+o;for(;C<=n.endColumn;)a.push({startRow:h,startColumn:f,endRow:g,endColumn:C}),f+=o,C+=o}else if(r===l.Direction.LEFT){let f=m-o,C=_-o;for(;f>=n.startColumn;)a.push({startRow:h,startColumn:f,endRow:g,endColumn:C}),f-=o,C-=o}}}return a}_presetAndCacheData(t,n){const{source:r,target:o}=t,s=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getCellMatrix(),a=[];for(let c=o.startRow;c<=o.endRow;c++){const d=[];for(let u=o.startColumn;u<=o.endColumn;u++)d.push(l.Tools.deepClone(s.getValue(c,u)));a.push(d)}this._beforeApplyData=a,this._copyData=this._getCopyData(r,n),this._hasSeries(this._copyData)?this._autoFillService.setDisableApplyType(Te.SERIES,!1):this._autoFillService.setDisableApplyType(Te.SERIES,!0)}_fillData(t,n,r){var Oe,Le;const o=[],s=[];let a=!0;r===Te.NO_FORMAT&&(a=!1,r=Te.SERIES);const{source:c,target:d,unitId:u,subUnitId:h}=t;if(!c||!d||n==null)return{undos:o,redos:s};const{startRow:m,startColumn:g,endRow:_,endColumn:f}=c,{startRow:C,startColumn:I,endRow:w,endColumn:E}=d,O=this._copyData;let x;n===l.Direction.DOWN||n===l.Direction.UP?x=_-m+1:x=f-g+1;const N=[];if(n===l.Direction.DOWN||n===l.Direction.UP){const Se=w-C+1,he=[];for(let ge=I;ge<=E;ge++){const Ae=O[ge-I],we=this._getApplyData(Ae,x,Se,n,r,a);he.push(we)}for(let ge=0;ge<he[0].length;ge++){const Ae=[];for(let we=0;we<he.length;we++)Ae.push({s:null,...he[we][ge]});N.push(Ae)}}else{const Se=E-I+1;for(let he=C;he<=w;he++){const ge=O[he-C],Ae=this._getApplyData(ge,x,Se,n,r,a),we=[];for(let Pe=0;Pe<Ae.length;Pe++)we.push({s:null,...Ae[Pe]});N.push(we)}}let D=[];const P=this._univerInstanceService.getCurrentUniverSheetInstance().getStyles();a?(D=this._getMergeApplyData(c,d,n,x),N.forEach(Se=>{Se.forEach(he=>{he&&P&&P&&(he.s=P.getStyleByCell(he))})})):N.forEach((Se,he)=>{Se.forEach((ge,Ae)=>{ge&&P&&(ge.s=P.getStyleByCell(this._beforeApplyData[he][Ae])||null)})}),r===Te.ONLY_FORMAT&&N.forEach((Se,he)=>{Se.forEach((ge,Ae)=>{if(ge){const we=this._beforeApplyData[he][Ae]||{};ge.f=we.f,ge.si=we.si,ge.t=we.t,ge.v=we.v}})});const L={get:this._injector.get.bind(this._injector)},G=[],k=(Le=(Oe=this._univerInstanceService.getUniverSheetInstance(u))==null?void 0:Oe.getSheetBySheetId(h))==null?void 0:Le.getMergeData();k&&k.forEach(Se=>{l.Rectangle.intersects(Se,d)&&G.push(Se)});const ee={unitId:u,subUnitId:h,ranges:G},te=p.RemoveMergeUndoMutationFactory(L,ee);s.push({id:p.RemoveWorksheetMergeMutation.id,params:ee}),o.push({id:p.AddWorksheetMergeMutation.id,params:te});const W={subUnitId:h,unitId:u,cellValue:fo([d])},V=p.SetRangeValuesUndoMutationFactory(L,W),re=this._sheetInterceptorService.onCommandExecute({id:p.ClearSelectionContentCommand.id});s.push({id:p.SetRangeValuesMutation.id,params:W},...re.redos),o.push(...re.undos,{id:p.SetRangeValuesMutation.id,params:V});const q=new l.ObjectMatrix,{startRow:ae,startColumn:Ie,endRow:de,endColumn:Ee}=d;for(let Se=0;Se<=de-ae;Se++)for(let he=0;he<=Ee-Ie;he++)N[Se][he]&&q.setValue(Se+ae,he+Ie,N[Se][he]);const be={subUnitId:h,unitId:u,cellValue:q.getMatrix()},De=p.SetRangeValuesUndoMutationFactory(L,be);if(o.push({id:p.SetRangeValuesMutation.id,params:De}),s.push({id:p.SetRangeValuesMutation.id,params:be}),D!=null&&D.length){const Se=p.getAddMergeMutationRangeByType(D),he={unitId:u,subUnitId:h,ranges:Se},ge=p.AddMergeUndoMutationFactory(L,he);o.push({id:p.RemoveWorksheetMergeMutation.id,params:ge}),s.push({id:p.AddWorksheetMergeMutation.id,params:he})}return{undos:o,redos:s}}_hasSeries(t){return t.some(n=>Object.keys(n).some(o=>{var s;return!!((s=n[o])!=null&&s.length&&![We.OTHER,We.FORMULA].includes(o))}))}};exports.AutoFillController=Fl([l.OnLifecycle(l.LifecycleStages.Steady,exports.AutoFillController),vt(0,l.IUniverInstanceService),vt(1,Ze),vt(2,l.ICommandService),vt(3,l.IUndoRedoService),vt(4,xn),vt(5,at),vt(6,j.Inject(p.SheetInterceptorService)),vt(7,j.Inject(p.SelectionManagerService)),vt(8,j.Inject(j.Injector))],exports.AutoFillController);const ur={type:l.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(pe.SetInlineFormatBoldCommand.id):e.executeCommand(p.SetBoldCommand.id)}},hr={type:l.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(pe.SetInlineFormatItalicCommand.id):e.executeCommand(p.SetItalicCommand.id)}},mr={type:l.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(pe.SetInlineFormatUnderlineCommand.id):e.executeCommand(p.SetUnderlineCommand.id)}},gr={type:l.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(pe.SetInlineFormatStrikethroughCommand.id):e.executeCommand(p.SetStrikeThroughCommand.id)}},Bl={type:l.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(pe.SetInlineFormatSubscriptCommand.id):!1}},jl={type:l.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(pe.SetInlineFormatSuperscriptCommand.id):!1}},Zo={type:l.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(i,e)=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?t.executeCommand(pe.SetInlineFormatFontSizeCommand.id,e):t.executeCommand(p.SetFontSizeCommand.id,e)}},Go={type:l.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(i,e)=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?t.executeCommand(pe.SetInlineFormatFontFamilyCommand.id,e):t.executeCommand(p.SetFontFamilyCommand.id,e)}},Ii={type:l.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(i,e)=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?t.executeCommand(pe.SetInlineFormatTextColorCommand.id,e):t.executeCommand(p.SetTextColorCommand.id,e)}};function Ko(i,e){return e.some(t=>Wl(i,t))}function Wl(i,e){const{startRow:t,startColumn:n,endColumn:r,endRow:o}=e,s=i.getMatrixWithMergedCells(t,n,o,r);let a=!1;return s.forValue((c,d,u)=>{if(u&&(c!==t||d!==n)&&i.cellHasValue(u))return a=!0,!1}),a}function qo(i,e,t,n){const r=[],o=[],s=t.getSheetId();return n.forEach(a=>{const c=zl(t,a),d={unitId:e,subUnitId:s,cellValue:c.getData()},u=p.SetRangeValuesUndoMutationFactory(i,d);r.push({id:p.SetRangeValuesMutation.id,params:u}),o.push({id:p.SetRangeValuesMutation.id,params:d})}),{undos:r,redos:o}}function zl(i,e){const{startRow:t,startColumn:n,endColumn:r,endRow:o}=e,s=i.getMatrixWithMergedCells(t,n,o,r),a=new l.ObjectMatrix;return s.forValue((c,d,u)=>{u&&(c!==t||d!==n)&&a.setValue(c,d,null)}),a}var $l=Object.defineProperty,Yl=Object.getOwnPropertyDescriptor,Xl=(i,e,t,n)=>{for(var r=n>1?void 0:n?Yl(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&$l(e,t,r),r},Ui=(i,e)=>(t,n)=>e(t,n,i),st=(i=>(i[i.OFF=0]="OFF",i[i.ONCE=1]="ONCE",i[i.INFINITE=2]="INFINITE",i))(st||{});const sn=j.createIdentifier("univer.format-painter-service");let er=class extends l.Disposable{constructor(e,t,n){super();v(this,"status$");v(this,"_selectionFormat");v(this,"_markId",null);v(this,"_status$");this._selectionManagerService=e,this._univerInstanceService=t,this._markSelectionService=n,this._status$=new J.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new l.ObjectMatrix,merges:[]}}setStatus(e){e!==0&&this._getSelectionRangeFormat(),this._updateRangeMark(e),this._status$.next(e)}getStatus(){return this._status$.getValue()}_updateRangeMark(e){if(this._markSelectionService.removeAllShapes(),this._markId=null,e!==0){const t=this._selectionManagerService.getLast();if(t){const n=this._selectionManagerService.createCopyPasteSelection();e===2?this._markId=this._markSelectionService.addShape({...t,style:n}):this._markId=this._markSelectionService.addShape({...t,style:n},[p.SetRangeValuesMutation.id])}}}_getSelectionRangeFormat(){const e=this._selectionManagerService.getLast(),t=e==null?void 0:e.range;if(!t)return;const{startRow:n,endRow:r,startColumn:o,endColumn:s}=t,a=this._univerInstanceService.getCurrentUniverSheetInstance(),d=(a==null?void 0:a.getActiveSheet()).getCellMatrix(),u=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData(),h=a.getStyles(),m=new l.ObjectMatrix;for(let g=n;g<=r;g++)for(let _=o;_<=s;_++){const f=d.getValue(g,_);m.setValue(g,_,h.getStyleByCell(f)||{});const{isMergedMainCell:C,...I}=y.getCellInfoInMergeData(g,_,u);C&&this._selectionFormat.merges.push({startRow:I.startRow,startColumn:I.startColumn,endRow:I.endRow,endColumn:I.endColumn})}this._selectionFormat.styles=m}getSelectionFormat(){return this._selectionFormat}};er=Xl([Ui(0,j.Inject(p.SelectionManagerService)),Ui(1,l.IUniverInstanceService),Ui(2,On)],er);const _r={id:"sheet.operation.set-format-painter",type:l.CommandType.OPERATION,handler:(i,e)=>e?(i.get(sn).setStatus(e.status),!0):!1},Jo={type:l.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async i=>{const t=i.get(sn).getStatus();let n;return t!==st.OFF?n=st.OFF:n=st.INFINITE,i.get(l.ICommandService).executeCommand(_r.id,{status:n})}},pr={type:l.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async i=>{const t=i.get(sn).getStatus();let n;return t!==st.OFF?n=st.OFF:n=st.ONCE,i.get(l.ICommandService).executeCommand(_r.id,{status:n})}},Qo={type:l.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(i,e)=>{const t=i.get(l.ICommandService),n=i.get(l.IUndoRedoService),r=i.get(l.IUniverInstanceService),o=i.get(p.SelectionManagerService),s=i.get(p.SheetInterceptorService),{styleValues:a,styleRange:c,mergeRanges:d,unitId:u=r.getCurrentUniverSheetInstance().getUnitId(),subUnitId:h=r.getCurrentUniverSheetInstance().getActiveSheet().getSheetId()}=e,m=c?[c]:o.getSelectionRanges();if(!m||!m.length)return!1;const g=new l.ObjectMatrix;let _;if(l.Tools.isArray(a))for(let W=0;W<m.length;W++){const{startRow:V,startColumn:re,endRow:q,endColumn:ae}=m[W];for(let Ie=0;Ie<=q-V;Ie++)for(let de=0;de<=ae-re;de++)g.setValue(Ie+V,de+re,a[Ie][de])}else if(l.isICellData(a))for(let W=0;W<m.length;W++){const{startRow:V,startColumn:re}=m[W];g.setValue(V,re,a)}else _=a;const f={subUnitId:h,unitId:u,cellValue:_??g.getMatrix()},C=p.SetRangeValuesUndoMutationFactory(i,f);if(!s.fetchThroughInterceptors(p.INTERCEPTOR_POINT.PERMISSION)(null,{id:p.SetRangeValuesCommand.id,params:f}))return!1;const I=t.syncExecuteCommand(p.SetRangeValuesMutation.id,f),{undos:w,redos:E}=s.onCommandExecute({id:p.SetRangeValuesCommand.id,params:{...f,range:m}}),O=p.getAddMergeMutationRangeByType(d),x=r.getUniverSheetInstance(u).getSheetBySheetId(h),N=[],D=[],P=Ko(x,O),L={unitId:u,subUnitId:h,ranges:O},G={unitId:u,subUnitId:h,ranges:O};N.push({id:p.RemoveWorksheetMergeMutation.id,params:L}),N.push({id:p.AddWorksheetMergeMutation.id,params:G});const k=p.RemoveMergeUndoMutationFactory(i,L),ee=p.AddMergeUndoMutationFactory(i,G);if(D.push({id:p.RemoveWorksheetMergeMutation.id,params:ee}),D.push({id:p.AddWorksheetMergeMutation.id,params:k}),P){const W=qo(i,u,x,O);N.unshift(...W.redos),D.push(...W.undos)}const te=await l.sequenceExecute([...E,...N],t);return I&&te.result?(n.pushUndoRedo({unitID:u,undoMutations:[{id:p.SetRangeValuesMutation.id,params:C},...w,...D],redoMutations:[{id:p.SetRangeValuesMutation.id,params:f},...E,...N]}),!0):!1}},Ei={type:l.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(i,e)=>{const{type:t}=e||{},n=i.get(l.IUniverInstanceService),r=i.get(l.IUndoRedoService),o=n.getCurrentUniverSheetInstance().getUnitId(),s=n.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),a=i.get(l.ICommandService),d=i.get(p.SelectionManagerService).getSelections();if(!d)return!1;const u=d[(d==null?void 0:d.length)-1],{range:h}=u,m=i.get(Nt),{sheetViewStartRow:g=0,sheetViewStartColumn:_=0}=m.getCurrentScroll()||{};let f,C,I,w;const{startRow:E,startColumn:O,rangeType:x}=h;if(x===l.RANGE_TYPE.ROW||t===1)f=E,I=E-g,C=-1,w=0;else if(x===l.RANGE_TYPE.COLUMN||t===2)f=-1,I=0,C=O,w=O-_;else if(x===l.RANGE_TYPE.NORMAL)f=E,I=E-g,C=O,w=O-_;else return!1;const N={unitId:o,subUnitId:s,startRow:f,startColumn:C,xSplit:C>0?Math.max(1,w):w,ySplit:f>0?Math.max(1,I):I},D=p.SetFrozenMutationFactory(i,N);return a.syncExecuteCommand(p.SetFrozenMutation.id,N)&&r.pushUndoRedo({unitID:o,undoMutations:[{id:p.SetFrozenMutation.id,params:D}],redoMutations:[{id:p.SetFrozenMutation.id,params:N}]}),!0}},es={type:l.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async i=>(i.get(l.ICommandService).executeCommand(Ei.id,{type:1}),!0)},ts={type:l.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async i=>(i.get(l.ICommandService).executeCommand(Ei.id,{type:2}),!0)},ns={type:l.CommandType.COMMAND,id:"sheet.command.cancel-frozen",handler:async i=>{const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(l.IUndoRedoService),r=t.getCurrentUniverSheetInstance().getUnitId(),o=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),s={unitId:r,subUnitId:o,startRow:-1,startColumn:-1,xSplit:0,ySplit:0},a=p.SetFrozenMutationFactory(i,s);return e.syncExecuteCommand(p.SetFrozenMutation.id,s)&&n.pushUndoRedo({unitID:r,undoMutations:[{id:p.SetFrozenMutation.id,params:a}],redoMutations:[{id:p.SetFrozenMutation.id,params:s}]}),!0}},an="UI_PLUGIN_SHEETS",Oi=`${an}_COLOR_PICKER_COMPONENT`,Zl="univer-ui-plugin-sheets-font-family",Gl="univer-ui-plugin-sheets-font-family-item",is={uiPluginSheetsFontFamily:Zl,uiPluginSheetsFontFamilyItem:Gl},Kl=i=>{const{value:e}=i,t=me.useDependency(l.LocaleService);return S.jsx("div",{className:is.uiPluginSheetsFontFamily,style:{fontFamily:e},children:t.t(`fontFamily.${(`${e}`??"").replace(/\s/g,"")}`)})},ql=i=>{const{value:e}=i,t=me.useDependency(l.LocaleService);return S.jsx("span",{className:is.uiPluginSheetsFontFamilyItem,style:{fontFamily:e},children:t.t(`fontFamily.${(`${e}`??"").replace(/\s/g,"")}`)})},rs=`${an}_FONT_FAMILY_COMPONENT`,Ge=`${an}_FONT_FAMILY_ITEM_COMPONENT`,Jl="univer-ui-plugin-sheets-font-size",Ql="univer-ui-plugin-sheets-font-size-input",Wr={uiPluginSheetsFontSize:Jl,uiPluginSheetsFontSizeInput:Ql},ec=i=>{const{value:e,min:t,max:n,onChange:r,disabled$:o}=i,s=R.useObservable(o??new J.Observable(m=>m.next(!1))),[a,c]=X.useState(Number(e??0)),d=X.useMemo(()=>Number(e??a),[e]);function u(m){m!==null&&c(m)}function h(m){m.stopPropagation(),m.code==="Enter"&&r(a.toString())}return S.jsx("div",{className:Wr.uiPluginSheetsFontSize,children:S.jsx(Ye.InputNumber,{className:Wr.uiPluginSheetsFontSizeInput,value:d,controls:!1,min:t,max:n,onKeyDown:h,onChange:u,disabled:s})})},os=`${an}_FONT_SIZE_COMPONENT`,fr=`${an}_MENU_ITEM_INPUT_COMPONENT`,tc="univer-sheets-ui-context-menu-input",nc="univer-sheets-ui-context-menu-input-container",ic="univer-sheets-ui-context-menu-input-number",ki={sheetsUiContextMenuInput:tc,sheetsUiContextMenuInputContainer:nc,sheetsUiContextMenuInputNumber:ic},rc=i=>{const{prefix:e,suffix:t,value:n,onChange:r,min:o=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=i,a=me.useDependency(l.LocaleService),[c,d]=X.useState(),u=m=>{d(m==null?void 0:m.toString()),r((m==null?void 0:m.toString())??"")};X.useEffect(()=>{d(n)},[n]);function h(m){m.key==="Backspace"&&m.stopPropagation()}return S.jsxs("div",{className:ki.sheetsUiContextMenuInput,children:[a.t(e),S.jsx("span",{className:ki.sheetsUiContextMenuInputContainer,onClick:m=>m.stopPropagation(),children:S.jsx(Ye.InputNumber,{className:ki.sheetsUiContextMenuInputNumber,value:Number(c),precision:0,onKeyDown:h,onChange:u,min:o,max:s})}),a.t(t)]})};var Be=(i=>(i.ROW_HEADER_CONTEXT_MENU="rowHeaderContextMenu",i.COL_HEADER_CONTEXT_MENU="colHeaderContextMenu",i.SHEET_BAR="sheetBar",i))(Be||{});function oc(i){const e=i.get(sn);return{id:pr.id,subId:Jo.id,group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",positions:[R.MenuPosition.TOOLBAR_START],activated$:new J.Observable(t=>{let n=!1;const r=e.status$.subscribe(o=>{n=o!==st.OFF,t.next(n)});return t.next(n),()=>{r.unsubscribe()}}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:p.getCurrentSheetDisabled$(i)}}function sc(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(l.IContextService),r=i.get(p.SelectionManagerService);return{id:ur.id,group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[R.MenuPosition.TOOLBAR_START],disabled$:p.getCurrentSheetDisabled$(i),activated$:new J.Observable(o=>{const s=e.onCommandExecuted(a=>{var d,u;const c=a.id;if(c===p.SetRangeValuesMutation.id||c===p.SetSelectionsOperation.id){const h=(d=r.getLast())==null?void 0:d.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let g=l.FontWeight.NORMAL;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);g=_==null?void 0:_.getFontWeight()}o.next(g===l.FontWeight.BOLD)}if((c===pe.SetTextSelectionsOperation.id||c===pe.SetInlineFormatCommand.id)&&n.getContextValue(l.FOCUSING_EDITOR)&&n.getContextValue(l.FOCUSING_SHEET)){const h=Nn(i);if(h==null)return;const m=(u=h.ts)==null?void 0:u.bl;o.next(m===l.BooleanNumber.TRUE)}});return o.next(!1),s.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function ac(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(p.SelectionManagerService),r=i.get(l.IContextService);return{id:hr.id,group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[R.MenuPosition.TOOLBAR_START],disabled$:p.getCurrentSheetDisabled$(i),activated$:new J.Observable(o=>{const s=e.onCommandExecuted(a=>{var d,u;const c=a.id;if(c===p.SetRangeValuesMutation.id||c===p.SetSelectionsOperation.id){const h=(d=n.getLast())==null?void 0:d.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let g=l.FontItalic.NORMAL;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);g=_==null?void 0:_.getFontStyle()}o.next(g===l.FontItalic.ITALIC)}if((c===pe.SetTextSelectionsOperation.id||c===pe.SetInlineFormatCommand.id)&&r.getContextValue(l.FOCUSING_EDITOR)&&r.getContextValue(l.FOCUSING_SHEET)){const h=Nn(i);if(h==null)return;const m=(u=h.ts)==null?void 0:u.it;o.next(m===l.BooleanNumber.TRUE)}});return o.next(!1),s.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function lc(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(p.SelectionManagerService),r=i.get(l.IContextService);return{id:mr.id,group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[R.MenuPosition.TOOLBAR_START],disabled$:p.getCurrentSheetDisabled$(i),activated$:new J.Observable(o=>{const s=e.onCommandExecuted(a=>{var d,u;const c=a.id;if(c===p.SetRangeValuesMutation.id||c===p.SetSelectionsOperation.id){const h=(d=n.getLast())==null?void 0:d.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let g;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);g=_==null?void 0:_.getUnderline()}o.next(!!(g&&g.s))}if((c===pe.SetTextSelectionsOperation.id||c===pe.SetInlineFormatCommand.id)&&r.getContextValue(l.FOCUSING_EDITOR)&&r.getContextValue(l.FOCUSING_SHEET)){const h=Nn(i);if(h==null)return;const m=(u=h.ts)==null?void 0:u.ul;o.next((m==null?void 0:m.s)===l.BooleanNumber.TRUE)}});return o.next(!1),s.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function cc(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(p.SelectionManagerService),r=i.get(l.IContextService);return{id:gr.id,group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[R.MenuPosition.TOOLBAR_START],disabled$:p.getCurrentSheetDisabled$(i),activated$:new J.Observable(o=>{const s=e.onCommandExecuted(a=>{var d,u;const c=a.id;if(c===p.SetRangeValuesMutation.id||c===p.SetSelectionsOperation.id){const h=(d=n.getLast())==null?void 0:d.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let g;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);g=_==null?void 0:_.getStrikeThrough()}o.next(!!(g&&g.s))}if((c===pe.SetTextSelectionsOperation.id||c===pe.SetInlineFormatCommand.id)&&r.getContextValue(l.FOCUSING_EDITOR)&&r.getContextValue(l.FOCUSING_SHEET)){const h=Nn(i);if(h==null)return;const m=(u=h.ts)==null?void 0:u.st;o.next((m==null?void 0:m.s)===l.BooleanNumber.TRUE)}});return o.next(!1),s.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}const dc=[{label:"9",value:9},{label:"10",value:10},{label:"11",value:11},{label:"12",value:12},{label:"14",value:14},{label:"16",value:16},{label:"18",value:18},{label:"20",value:20},{label:"22",value:22},{label:"24",value:24},{label:"26",value:26},{label:"28",value:28},{label:"36",value:36},{label:"48",value:48},{label:"72",value:72}],zr=[{label:Ge,value:"Times New Roman"},{label:Ge,value:"Arial"},{label:Ge,value:"Tahoma"},{label:Ge,value:"Verdana"},{label:Ge,value:"Microsoft YaHei"},{label:Ge,value:"SimSun"},{label:Ge,value:"SimHei"},{label:Ge,value:"Kaiti"},{label:Ge,value:"FangSong"},{label:Ge,value:"NSimSun"},{label:Ge,value:"STXinwei"},{label:Ge,value:"STXingkai"},{label:Ge,value:"STLiti"}];function uc(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(p.SelectionManagerService);return{id:Go.id,tooltip:"toolbar.font",group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.SELECTOR,label:rs,positions:[R.MenuPosition.TOOLBAR_START],selections:zr,disabled$:p.getCurrentSheetDisabled$(i),value$:new J.Observable(r=>{const o=zr[0].value,s=e.onCommandExecuted(a=>{var m;const c=a.id;if(c!==p.SetRangeValuesMutation.id&&c!==p.SetSelectionsOperation.id)return;const d=(m=n.getLast())==null?void 0:m.primary,u=t.getCurrentUniverSheetInstance().getActiveSheet();let h;if(d!=null){const g=u.getRange(d.startRow,d.startColumn);h=g==null?void 0:g.getFontFamily()}r.next(h??o)});return r.next(o),s.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function hc(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(p.SelectionManagerService),r=i.get(l.IContextService),o=p.getCurrentSheetDisabled$(i);return{id:Zo.id,group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:os,props:{min:1,max:400,disabled$:o}},positions:[R.MenuPosition.TOOLBAR_START],selections:dc,disabled$:o,value$:new J.Observable(s=>{const c=e.onCommandExecuted(d=>{var h,m;const u=d.id;if(u===p.SetRangeValuesMutation.id||u===p.SetSelectionsOperation.id){const g=(h=n.getLast())==null?void 0:h.primary,_=t.getCurrentUniverSheetInstance().getActiveSheet();let f;if(g!=null){const C=_.getRange(g.startRow,g.startColumn);f=C==null?void 0:C.getFontSize()}s.next(f??14)}if((u===pe.SetTextSelectionsOperation.id||u===pe.SetInlineFormatCommand.id)&&r.getContextValue(l.FOCUSING_EDITOR)&&r.getContextValue(l.FOCUSING_SHEET)){const g=Nn(i);if(g==null)return;const _=(m=g.ts)==null?void 0:m.fs;s.next(_??14)}});return s.next(14),c.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function mc(i){return{id:p.ResetTextColorCommand.id,type:R.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:Ii.id,disabled$:p.getCurrentSheetDisabled$(i)}}function gc(i){const e=i.get(l.ICommandService),t=i.get(l.ThemeService);return{id:Ii.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON_SELECTOR,positions:[R.MenuPosition.TOOLBAR_START],selections:[{label:{name:Oi,hoverable:!1}}],value$:new J.Observable(n=>{const r=t.getCurrentTheme().textColor,o=e.onCommandExecuted(s=>{if(s.id===Ii.id){const a=s.params.value;n.next(a??r)}});return n.next(r),o.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:p.getCurrentSheetDisabled$(i)}}function _c(i){return{id:p.ResetBackgroundColorCommand.id,type:R.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:p.SetBackgroundColorCommand.id,disabled$:p.getCurrentSheetDisabled$(i)}}function pc(i){const e=i.get(l.ICommandService),t=i.get(l.ThemeService);return{id:p.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON_SELECTOR,positions:[R.MenuPosition.TOOLBAR_START],icon:"PaintBucket",selections:[{label:{name:Oi,hoverable:!1}}],value$:new J.Observable(n=>{const r=t.getCurrentTheme().primaryColor,o=e.onCommandExecuted(s=>{if(s.id===p.SetBackgroundColorCommand.id){const a=s.params.value;n.next(a??r)}});return n.next(r),o.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:p.getCurrentSheetDisabled$(i)}}const $r=[{label:"align.left",icon:"LeftJustifyingSingle",value:l.HorizontalAlign.LEFT},{label:"align.center",icon:"HorizontallySingle",value:l.HorizontalAlign.CENTER},{label:"align.right",icon:"RightJustifyingSingle",value:l.HorizontalAlign.RIGHT}];function fc(i){const e=i.get(l.IUniverInstanceService),t=i.get(p.SelectionManagerService);return{id:p.SetHorizontalTextAlignCommand.id,icon:$r[0].icon,positions:[R.MenuPosition.TOOLBAR_START],tooltip:"toolbar.horizontalAlignMode.main",group:R.MenuGroup.TOOLBAR_LAYOUT,type:R.MenuItemType.SELECTOR,selections:$r,value$:new J.Observable(n=>{const r=i.get(l.ICommandService).onCommandExecuted(o=>{var u;const s=o.id;if(s!==p.SetHorizontalTextAlignCommand.id&&s!==p.SetSelectionsOperation.id)return;const a=(u=t.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const h=c.getRange(a.startRow,a.startColumn);d=h==null?void 0:h.getHorizontalAlignment()}n.next(d??l.HorizontalAlign.LEFT)});return n.next(l.HorizontalAlign.LEFT),r.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:p.getCurrentSheetDisabled$(i)}}const Yr=[{label:"align.top",icon:"AlignTopSingle",value:l.VerticalAlign.TOP},{label:"align.middle",icon:"VerticalCenterSingle",value:l.VerticalAlign.MIDDLE},{label:"align.bottom",icon:"AlignBottomSingle",value:l.VerticalAlign.BOTTOM}];function Sc(i){const e=i.get(l.IUniverInstanceService),t=i.get(p.SelectionManagerService);return{id:p.SetVerticalTextAlignCommand.id,icon:Yr[0].icon,tooltip:"toolbar.verticalAlignMode.main",group:R.MenuGroup.TOOLBAR_LAYOUT,type:R.MenuItemType.SELECTOR,positions:[R.MenuPosition.TOOLBAR_START],selections:Yr,value$:new J.Observable(n=>{const r=i.get(l.ICommandService).onCommandExecuted(o=>{var u;const s=o.id;if(s!==p.SetVerticalTextAlignCommand.id&&s!==p.SetSelectionsOperation.id)return;const a=(u=t.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const h=c.getRange(a.startRow,a.startColumn);d=h==null?void 0:h.getVerticalAlignment()}n.next(d??l.VerticalAlign.TOP)});return n.next(l.VerticalAlign.TOP),r.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:p.getCurrentSheetDisabled$(i)}}const Xr=[{label:"textWrap.overflow",icon:"OverflowSingle",value:l.WrapStrategy.OVERFLOW},{label:"textWrap.wrap",icon:"AutowrapSingle",value:l.WrapStrategy.WRAP},{label:"textWrap.clip",icon:"TruncationSingle",value:l.WrapStrategy.CLIP}];function vc(i){const e=i.get(p.SelectionManagerService),t=i.get(l.IUniverInstanceService);return{id:p.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:Xr[0].icon,group:R.MenuGroup.TOOLBAR_LAYOUT,type:R.MenuItemType.SELECTOR,positions:[R.MenuPosition.TOOLBAR_START],selections:Xr,value$:new J.Observable(n=>{const r=i.get(l.ICommandService).onCommandExecuted(o=>{var u;const s=o.id;if(s!==p.SetTextWrapCommand.id&&s!==p.SetSelectionsOperation.id)return;const a=(u=e.getLast())==null?void 0:u.primary,c=t.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const h=c.getRange(a.startRow,a.startColumn);d=h==null?void 0:h.getWrapStrategy()}n.next(d??l.WrapStrategy.OVERFLOW)});return n.next(l.WrapStrategy.OVERFLOW),r.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:p.getCurrentSheetDisabled$(i)}}const Zr=[{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 Cc(i){const e=i.get(p.SelectionManagerService),t=i.get(l.IUniverInstanceService);return{id:p.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:Zr[0].icon,group:R.MenuGroup.TOOLBAR_LAYOUT,type:R.MenuItemType.SELECTOR,selections:Zr,positions:[R.MenuPosition.TOOLBAR_START],value$:new J.Observable(n=>{const r=i.get(l.ICommandService).onCommandExecuted(o=>{var u;const s=o.id;if(s!==p.SetTextRotationCommand.id&&s!==p.SetSelectionsOperation.id)return;const a=(u=e.getLast())==null?void 0:u.primary,c=t.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const h=c.getRange(a.startRow,a.startColumn);d=h==null?void 0:h.getTextRotation()}(d==null?void 0:d.v)===l.BooleanNumber.TRUE?n.next("v"):n.next((d&&d.a)??0)});return n.next(0),r.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:p.getCurrentSheetDisabled$(i)}}function Rc(){return{id:R.CopyCommand.id,group:R.MenuGroup.CONTEXT_MENU_FORMAT,type:R.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",positions:[R.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function Ic(){return{id:R.PasteCommand.id,group:R.MenuGroup.CONTEXT_MENU_FORMAT,type:R.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",positions:[R.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}const ln="sheet.menu.paste-special";function bc(){return{id:ln,group:R.MenuGroup.CONTEXT_MENU_FORMAT,type:R.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",positions:[R.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function Mc(){return{id:To.id,type:R.MenuItemType.BUTTON,title:"rightClick.pasteValue",positions:[ln]}}function wc(){return{id:yo.id,type:R.MenuItemType.BUTTON,title:"rightClick.pasteFormat",positions:[ln]}}function Tc(){return{id:Eo.id,type:R.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",positions:[ln]}}function yc(){return{id:Oo.id,type:R.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",positions:[ln]}}function Ec(){return{id:p.SetWorksheetRowIsAutoHeightCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"AutoHeight",title:"rightClick.fitContent"}}const An="sheet.menu.sheet-frozen";function Oc(){return{id:An,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:[R.MenuPosition.CONTEXT_MENU]}}const Sr="sheet.header-menu.sheet-frozen";function xc(){return{id:Sr,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:["rowHeaderContextMenu","colHeaderContextMenu"]}}function Ac(){return{id:Ei.id,type:R.MenuItemType.BUTTON,positions:[An,Sr],title:"rightClick.freeze",icon:"FreezeToSelectedSingle"}}function Nc(){return{id:es.id,type:R.MenuItemType.BUTTON,positions:[An],title:"rightClick.freezeRow",icon:"FreezeRowSingle"}}function Dc(){return{id:ts.id,type:R.MenuItemType.BUTTON,positions:[An],title:"rightClick.freezeCol",icon:"FreezeColumnSingle"}}function Pc(){return{id:ns.id,type:R.MenuItemType.BUTTON,positions:[An,Sr],title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle"}}function Hc(){return{id:p.SetRowHiddenCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedRow"}}function Lc(){return{id:p.SetColHiddenCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedColumn"}}function Uc(i){const e=i.get(l.IUniverInstanceService),t=i.get(p.SelectionManagerService);function n(){var a;const o=e.getCurrentUniverSheetInstance().getActiveSheet(),s=(a=t.getSelections())==null?void 0:a.map(c=>c.range).filter(c=>c.rangeType===l.RANGE_TYPE.ROW);return!!(s!=null&&s.some(c=>{for(let d=c.startRow;d<=c.endRow;d++)if(!o.getRowVisible(d))return!0;return!1}))}const r=i.get(l.ICommandService);return{id:p.SetSelectedRowsVisibleCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],title:"rightClick.showHideRow",hidden$:new J.Observable(o=>{const s=r.onCommandExecuted(a=>{(a.id===p.SetSelectionsOperation.id||a.id===p.SetRowHiddenMutation.id||a.id===p.SetRowVisibleMutation.id)&&o.next(!n())});return o.next(!n()),()=>s.dispose()})}}function kc(i){const e=i.get(l.IUniverInstanceService),t=i.get(p.SelectionManagerService);function n(){var a;const o=e.getCurrentUniverSheetInstance().getActiveSheet(),s=(a=t.getSelections())==null?void 0:a.map(c=>c.range).filter(c=>c.rangeType===l.RANGE_TYPE.COLUMN);return!s||s.length===0?!1:!!s.some(c=>{for(let d=c.startColumn;d<=c.endColumn;d++)if(!o.getColVisible(d))return!0;return!1})}const r=i.get(l.ICommandService);return{id:p.SetSelectedColsVisibleCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],title:"rightClick.showHideColumn",hidden$:new J.Observable(o=>{const s=r.onCommandExecuted(a=>{(a.id===p.SetSelectionsOperation.id||a.id===p.SetColHiddenMutation.id||a.id===p.SetColVisibleMutation.id)&&o.next(!n())});return o.next(!n()),()=>s.dispose()})}}function Vc(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(p.SelectionManagerService);return{id:p.SetRowHeightCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,icon:"AdjustHeight",positions:["rowHeaderContextMenu"],label:{name:fr,props:{prefix:"rightClick.rowHeight",suffix:"px",min:2,max:1e3}},value$:new J.Observable(r=>{function o(){var u;const a=(u=n.getLast())==null?void 0:u.primary,c=t.getCurrentUniverSheetInstance().getActiveSheet();let d;a!=null&&(d=c.getRowHeight(a.startRow)),r.next(d??0)}const s=e.onCommandExecuted(a=>{const c=a.id;if(c===p.SetRangeValuesMutation.id||c===p.SetSelectionsOperation.id)return o()});return o(),s.dispose})}}function Fc(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(p.SelectionManagerService);return{id:p.SetColWidthCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,icon:"AdjustWidth",positions:["colHeaderContextMenu"],label:{name:fr,props:{prefix:"rightClick.columnWidth",suffix:"px",min:2,max:1e3}},value$:new J.Observable(r=>{function o(){var u;const a=(u=n.getLast())==null?void 0:u.primary,c=t.getCurrentUniverSheetInstance().getActiveSheet();let d=0;a!=null&&(d=c.getColumnWidth(a.startColumn)),r.next(d)}const s=e.onCommandExecuted(a=>{const c=a.id;if(c===p.SetRangeValuesMutation.id||c===p.SetSelectionsOperation.id)return o()});return o(),s.dispose})}}function Nn(i){var c;const e=i.get(l.IUniverInstanceService),t=i.get(pe.TextSelectionManagerService),n=e.getUniverDocInstance(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),r=t.getActiveRange();if(n==null||r==null)return;const o=(c=n.getBody())==null?void 0:c.textRuns;if(o==null)return;const{startOffset:s}=r;return o.find(({st:d,ed:u})=>s>=d&&s<u)}function qe(i,e){const n=i.getCurrentUniverSheetInstance().getUnitId(),r=e.getRenderById(n);if(r==null)return;const{components:o,mainComponent:s,scene:a,engine:c}=r,d=s,u=o.get(Xe.ROW),h=o.get(Xe.COLUMN),m=o.get(Xe.LEFT_TOP);return{spreadsheet:d,spreadsheetRowHeader:u,spreadsheetColumnHeader:h,spreadsheetLeftTopPlaceholder:m,scene:a,engine:c}}function tr(i,e,t,n){const{startX:r,startY:o,endX:s,endY:a}=n.getCellByIndex(i,e);return{startX:r,startY:o,endX:s,endY:a}}function tn(i,e,t,n,r){const o=t.getRelativeCoord(y.Vector2.FromArray([i,e])),{x:s,y:a}=o,c=t.getScrollXYByRelativeCoords(o,r),{scaleX:d,scaleY:u}=t.getAncestorScale(),h=n.getCellPositionByOffset(s,a,d,u,c),{row:m,column:g}=h,_=n.getNoMergeCellPositionByIndex(m,g),{startX:f,startY:C,endX:I,endY:w}=_;return{startX:f,startY:C,endX:I,endY:w,row:m,column:g}}function $n(i,e,t,n){const r=t.getRelativeCoord(y.Vector2.FromArray([i,e])),o=t.getViewport(Q.VIEW_MAIN),s=t.getScrollXYByRelativeCoords(r,o),{scaleX:a,scaleY:c}=t.getAncestorScale(),{x:d,y:u}=s,h=i/a+d,m=e/c+u;return{x:h,y:m}}const Bc={spreadsheetLabel:"Spreadsheet",spreadsheetRightLabel:"more Sheets",toolbar:{undo:"Undo",redo:"Redo",formatPainter:"Paint format",currencyFormat:"Format as currency",percentageFormat:"Format as percent",numberDecrease:"Decrease decimal places",numberIncrease:"Increase decimal places",moreFormats:"More formats",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript",underline:"Underline",textColor:{main:"Text color",right:"Choose color"},resetColor:"Reset",customColor:"CUSTOM",alternatingColors:"Alternating colors",confirmColor:"OK",cancelColor:"Cancel",collapse:"Collapse",fillColor:{main:"Fill color",right:"Choose color"},border:{main:"Border",right:"Border style"},mergeCell:{main:"Merge cells",right:"Choose merge type"},horizontalAlignMode:{main:"Horizontal align",right:"Alignment"},verticalAlignMode:{main:"Vertical align",right:"Alignment"},textWrapMode:{main:"Text wrap",right:"Text wrap mode"},textRotateMode:{main:"Text rotate",right:"Text rotate mode"},freezeTopRow:"Freeze top row",sortAndFilter:"Sort and filter",findAndReplace:"Find and replace",sum:"SUM",autoSum:"Auto SUM",moreFunction:"More functions",conditionalFormat:"Conditional format",comment:"Comment",pivotTable:"Pivot Table",chart:"Chart",screenshot:"Screenshot",splitColumn:"Split text",insertImage:"Insert image",insertLink:"Insert link",dataValidation:"Data validation",protection:"Protect the sheet",clearText:"Clear color",noColorSelectedText:"No color is selected",toolMore:"More",toolLess:"Less",toolClose:"Close",toolMoreTip:"More features",moreOptions:"More options",cellFormat:"Cell format config",print:"Print",borderMethod:{top:"Upper frame line",bottom:"Lower frame line",left:"Left frame line",right:"Right frame line"},more:"More"},defaultFmt:{Automatic:{text:"Automatic",value:"General",example:""},Number:{text:"Number",value:"##0.00",example:"1000.12"},Percent:{text:"Percent",value:"#0.00%",example:"12.21%"},PlainText:{text:"Plain text",value:"@",example:""},Scientific:{text:"Scientific",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"Accounting",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"Ten Thousand",value:"w",example:"1亿2000万2500"},Currency:{text:"Currency",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"Date",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"Time",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"Time 24H",value:"hh:mm",example:"15:00"},DateTime:{text:"Date time",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"Date time 24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"Custom Formats",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"More currency formats",moreDateTime:"More date and time formats",moreNumber:"More number formats",titleCurrency:"Currency formats",decimalPlaces:"Decimal places",titleDateTime:"Date and time formats",titleNumber:"Number formats"},fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"Microsoft YaHei",SimSun:"SimSun",SimHei:"SimHei",Kaiti:"Kaiti",FangSong:"FangSong",NSimSun:"NSimSun",STXinwei:"STXinwei",STXingkai:"STXingkai",STLiti:"STLiti",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},print:{normalBtn:"Normal",layoutBtn:"Page Layout",pageBtn:"Page break preview",menuItemPrint:"Print (Ctrl+P)",menuItemAreas:"Print areas",menuItemRows:"Print title rows",menuItemColumns:"Print title columns"},align:{left:"left",center:"center",right:"right",top:"top",middle:"middle",bottom:"bottom"},dateFmtList:[{name:"1930-08-05",value:"yyyy-MM-dd"},{name:"1930/8/5",value:"yyyy/MM/dd"},{name:"08-05",value:"MM-dd"},{name:"8-5",value:"M-d"},{name:"13:30:30",value:"h:mm:ss"},{name:"13:30",value:"h:mm"},{name:"PM 01:30",value:"AM/PM hh:mm"},{name:"PM 1:30",value:"AM/PM h:mm"},{name:"PM 1:30:30",value:"AM/PM h:mm:ss"},{name:"08-05 PM 01:30",value:"MM-dd AM/PM hh:mm"}],numFmtList:[{name:"1235",value:"0"},{name:"1234.56",value:"0.00"},{name:"1,235",value:"#,##0"},{name:"1,234.56",value:"#,##0.00"},{name:"1,235",value:"#,##0_);(#,##0)"},{name:"1,235",value:"#,##0_);[Red](#,##0)"},{name:"1,234.56",value:"#,##0.00_);(#,##0.00)"},{name:"1,234.56",value:"#,##0.00_);[Red](#,##0.00)"},{name:"$1,235",value:"$#,##0_);($#,##0)"},{name:"$1,235",value:"$#,##0_);[Red]($#,##0)"},{name:"$1,234.56",value:"$#,##0.00_);($#,##0.00)"},{name:"$1,234.56",value:"$#,##0.00_);[Red]($#,##0.00)"},{name:"1234.56",value:"@"},{name:"123456%",value:"0%"},{name:"123456.00%",value:"0.00%"},{name:"1.23E+03",value:"0.00E+00"},{name:"1.2E+3",value:"##0.0E+0"},{name:"1234 5/9",value:"# ?/?"},{name:"1234 14/25",value:"# ??/??"},{name:"$ 1,235",value:'_($* #,##0_);_(...($* "-"_);_(@_)'},{name:"1,235",value:'_(* #,##0_);_(*..._(* "-"_);_(@_)'},{name:"$ 1,234.56",value:'_($* #,##0.00_);_(...($* "-"_);_(@_)'},{name:"1,234.56",value:'_(* #,##0.00_);...* "-"??_);_(@_)'}],button:{confirm:"OK",cancel:"Cancel",close:"Close",update:"Update",delete:"Delete",insert:"Insert",prevPage:"Previous",nextPage:"Next",total:"total:"},punctuation:{tab:"Tab",semicolon:"semicolond",comma:"comma",space:"space"},colorPicker:{collapse:"Collapse",customColor:"CUSTOM",change:"Change",confirmColor:"OK",cancelColor:"Cancel"},borderLine:{borderTop:"borderTop",borderBottom:"borderBottom",borderLeft:"borderLeft",borderRight:"borderRight",borderNone:"borderNone",borderAll:"borderAll",borderOutside:"borderOutside",borderInside:"borderInside",borderHorizontal:"borderHorizontal",borderVertical:"borderVertical",borderColor:"borderColor",borderSize:"borderSize",borderType:"borderType"},merge:{all:"Merge all",vertical:"Vertical merge",horizontal:"Horizontal merge",cancel:"Cancel merge",overlappingError:"Cannot merge overlapping areas",partiallyError:"Cannot perform this operation on partially merged cells",confirm:{title:"Continue merging would only keep the upper-left cell value, discard other values. Are you sure to continue?",cancel:"Cancel merging",confirm:"Continue merging"}},textWrap:{overflow:"Overflow",wrap:"Wrap",clip:"Clip"},textRotate:{none:"None",angleUp:"Tilt Up",angleDown:"Tilt Down",vertical:"Stack Vertically",rotationUp:"Rotate Up",rotationDown:"Rotate Down"},sheetConfig:{delete:"Delete",copy:"Copy",rename:"Rename",changeColor:"Change color",hide:"Hide",unhide:"Unhide",moveLeft:"Move left",moveRight:"Move right",resetColor:"Reset color",cancelText:"Cancel",chooseText:"Confirm color",tipNameRepeat:"The name of the tab page cannot be repeated! Please revise",noMoreSheet:"The workbook contains at least one visual worksheet. To delete the selected worksheet, please insert a new worksheet or show a hidden worksheet.",confirmDelete:"Are you sure to delete",redoDelete:"Can be undo by Ctrl+Z",noHide:"Can't hide, at least keep one sheet tag",chartEditNoOpt:"This operation is not allowed in chart editing mode!",sheetNameErrorTitle:"There was a problem",sheetNameSpecCharError:`The name cannot contain:[ ] : ? * / ' "`,sheetNameCannotIsEmptyError:"The sheet name cannot be empty.",sheetNameAlreadyExistsError:"The sheet name already exists. Please enter another name.",deleteSheet:"Delete worksheet",deleteSheetContent:"Confirm to delete this worksheet. It will not be retrieved after deletion. Are you sure you want to delete it?"},rightClick:{copy:"Copy",copyAs:"Copy as",cut:"Cut",paste:"Paste",pasteSpecial:"Paste Special",pasteValue:"Paste Value",pasteFormat:"Paste Format",pasteColWidth:"Paste Column Width",pasteBesidesBorder:"Paste Besides Border Styles",insert:"Insert",insertRow:"Insert Row",insertRowBefore:"Insert Row Before",insertColumn:"Insert Column",insertColumnBefore:"Insert Column Before",delete:"Delete",deleteCell:"Delete Cell",insertCell:"Insert Cell",deleteSelected:"Delete Selected ",hide:"Hide",hideSelected:"Hide Selected ",showHide:"Show Hidden",toTopAdd:"Towards Top Add",toBottomAdd:"Towards Bottom Add",toLeftAdd:"Towards Left Add",toRightAdd:"Towards Right Add",deleteSelectedRow:"Delete Selected row",deleteSelectedColumn:"Delete Selected column",hideSelectedRow:"Hide Selected Row",showHideRow:"Show Selected Row",rowHeight:"Row Height",hideSelectedColumn:"Hide Selected Column",showHideColumn:"Show Hide Column",columnWidth:"Column Width",to:"Towards",left:"Left",right:"Right",top:"Top",bottom:"Bottom",moveLeft:"Move Left",moveUp:"Move up",moveRight:"Move Right",moveDown:"Move Down",add:"Add",row:"Row",column:"Column",width:"Width",height:"Height",number:"Number",confirm:"Confirm",orderAZ:"A-Z order",orderZA:"Z-A order",clearSelection:"Clear",clearContent:"Clear Contents",clearFormat:"Clear Formats",clearAll:"Clear All",matrix:"Matrix operation",sortSelection:"Sort",filterSelection:"Filter",chartGeneration:"Create Chart",firstLineTitle:"First Line Title",untitled:"Untitled",array1:"One-dimensional array",array2:"Two-dimensional array",array3:"Multidimensional Arrays",diagonal:"Diagonal",antiDiagonal:"Anti-diagonal",diagonalOffset:"Diagonal offset",offset:"Offset",boolean:"Boolean",flip:"Flip",upAndDown:"Up and down",leftAndRight:"Left and right",clockwise:"Clockwise",counterclockwise:"Counterclockwise",transpose:"Transpose",matrixCalculation:"Matrix Calculation",plus:"Plus",minus:"Minus",multiply:"Multiply",divided:"Divided",power:"Power",root:"Root",log:"Log",delete0:"Delete 0 values at both ends",removeDuplicate:"Remove duplicate values",byRow:"By row",byCol:"By column",generateNewMatrix:"Generate new matrix",fitContent:"Fit for data",freeze:"Freeze",freezeCol:"Freeze to this column",freezeRow:"Freeze to this row",cancelFreeze:"Cancel freeze",zenEditor:"Full Screen Editor"},info:{tooltip:"Tooltip",notChangeMerge:"You cannot make partial changes to the merged cells",detailUpdate:"New opened",detailSave:"Local cache restored",row:"",column:"",loading:"Loading...",copy:"Copy",return:"Exit",rename:"Rename",tips:"Rename",noName:"Untitled spreadsheet",wait:"waiting for update",add:"Add",addLast:"more rows at bottom",backTop:"Back to the top",pageInfo:"Total ${total},${totalPage} page,current ${currentPage}",nextPage:"Next",tipInputNumber:"Please enter the number",tipInputNumberLimit:"The increase range is limited to 1-100",tipRowHeightLimit:"Row height must be between 0 ~ 545",tipColumnWidthLimit:"The column width must be between 0 ~ 2038",pageInfoFull:"Total ${total},${totalPage} page,All data displayed"},clipboard:{paste:{exceedMaxCells:"The number of cells pasted exceeds the maximum number of cells"}},statusbar:{sum:"Sum",average:"Average",min:"Min",max:"Max",count:"Numerical Count",countA:"Count",clickToCopy:"Click to Copy",copied:"Copied"},autoFill:{copy:"Copy Cell",series:"Fill Series",formatOnly:"Format Only",noFormat:"No Format"},rangeSelector:{placeholder:"Select range or input value",tooltip:"Select range"},shortcut:{sheet:{"zoom-in":"Zoom in","zoom-out":"Zoom out","reset-zoom":"Reset zoom level","select-below-cell":"Select the cell below","select-up-cell":"Select the cell above","select-left-cell":"Select the left cell","select-right-cell":"Select the right cell","select-next-cell":"Select the next cell","select-previous-cell":"Select the previous cell","select-up-value-cell":"Select the cell above that has value","select-below-value-cell":"Select the cell below that has value","select-left-value-cell":"Select the cell left that has value","select-right-value-cell":"Select the cell right that has value","expand-selection-down":"Expand selection down","expand-selection-up":"Expand selection up","expand-selection-left":"Expand selection left","expand-selection-right":"Expand selection right","expand-selection-to-left-gap":"Expand selection to the left gap","expand-selection-to-below-gap":"Expand selection to the below gap","expand-selection-to-right-gap":"Expand selection to the right gap","expand-selection-to-up-gap":"Expand selection to the up gap","select-all":"Select all","toggle-editing":"Toggle editing","delete-and-start-editing":"Clear and start editing","abort-editing":"Abort editing","break-line":"Break line","set-bold":"Toggle bold","set-italic":"Toggle italic","set-underline":"Toggle underline","set-strike-through":"Toggle strike through"}},"sheet-view":"Sheet View","sheet-edit":"Sheet Edit"},ss={spreadsheetLabel:"插件",spreadsheetRightLabel:"更多 Sheets",toolbar:{undo:"撤销",redo:"重做",formatPainter:"格式刷",currencyFormat:"货币格式",percentageFormat:"百分比格式",numberDecrease:"减少小数位数",numberIncrease:"增加小数位数",moreFormats:"更多格式",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},resetColor:"重置颜色",customColor:"自定义",alternatingColors:"交替颜色",confirmColor:"确定颜色",cancelColor:"取消",collapse:"收起",fillColor:{main:"单元格颜色",right:"颜色选择"},border:{main:"边框",right:"边框类型"},mergeCell:{main:"合并单元格",right:"选择合并类型"},horizontalAlignMode:{main:"水平对齐",right:"对齐方式"},verticalAlignMode:{main:"垂直对齐",right:"对齐方式"},textWrapMode:{main:"文本换行",right:"换行方式"},textRotateMode:{main:"文本旋转",right:"旋转方式"},freezeTopRow:"冻结首行",sortAndFilter:"排序和筛选",findAndReplace:"查找替换",sum:"求和",autoSum:"自动求和",moreFunction:"更多函数",conditionalalFormat:"条件格式",comment:"批注",pivotTable:"数据透视表",chart:"图表",screenshot:"截图",splitColumn:"分列",insertImage:"插入图片",insertLink:"插入链接",dataValidation:"数据验证",protection:"保护工作表内容",clearText:"清除颜色选择",noColorSelectedText:"没有颜色被选择",toolMore:"更多",toolLess:"少于",toolClose:"收起",toolMoreTip:"更多功能",moreOptions:"更多选项",cellFormat:"设置单元格格式",print:"打印",borderMethod:{top:"上框线",bottom:"下框线",left:"左框线",right:"右框线"},more:"更多"},defaultFmt:{Automatic:{text:"自动",value:"General",example:""},Number:{text:"数字",value:"##0.00",example:"1000.12"},Percent:{text:"百分比",value:"#0.00%",example:"12.21%"},PlainText:{text:"纯文本",value:"@",example:""},Scientific:{text:"科学计数",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"会计",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"万元",value:"w",example:"1亿2000万2500"},Currency:{text:"货币",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"日期",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"时间",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"时间24H",value:"hh:mm",example:"15:00"},DateTime:{text:"日期时间",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"日期时间24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"自定义格式",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"更多货币格式",moreDateTime:"更多日期与时间格式",moreNumber:"更多数字格式",titleCurrency:"货币格式",decimalPlaces:"小数位数",titleDateTime:"日期与时间格式",titleNumber:"数字格式"},fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"微软雅黑",SimSun:"宋体",SimHei:"黑体",Kaiti:"楷体",FangSong:"仿宋",NSimSun:"新宋体",STXinwei:"华文新魏",STXingkai:"华文行楷",STLiti:"华文隶书",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},print:{normalBtn:"常规视图",layoutBtn:"页面布局",pageBtn:"分页预览",menuItemPrint:"打印(Ctrl+P)",menuItemAreas:"打印区域",menuItemRows:"打印标题行",menuItemColumns:"打印标题列"},align:{left:"左对齐",center:"中间对齐",right:"右对齐",top:"顶部对齐",middle:"居中对齐",bottom:"底部对齐"},button:{confirm:"确定",cancel:"取消",close:"关闭",update:"Update",delete:"Delete",insert:"新建",prevPage:"上一页",nextPage:"下一页",total:"总共:"},punctuation:{tab:"Tab 键",semicolon:"分号",comma:"逗号",space:"空格"},colorPicker:{collapse:"收起",customColor:"自定义",change:"切换",confirmColor:"确定",cancelColor:"取消"},borderLine:{borderTop:"上框线",borderBottom:"下框线",borderLeft:"左框线",borderRight:"右框线",borderNone:"无",borderAll:"所有",borderOutside:"外侧",borderInside:"内侧",borderHorizontal:"内侧横线",borderVertical:"内侧竖线",borderColor:"边框颜色",borderSize:"边框粗细",borderType:"边框线类型"},merge:{all:"全部合并",vertical:"垂直合并",horizontal:"水平合并",cancel:"取消合并",overlappingError:"不能合并重叠区域",partiallyError:"无法对部分合并单元格执行此操作",confirm:{title:"合并单元格仅保存左上角单元格的值,是否继续?",cancel:"取消合并",confirm:"继续合并"}},textWrap:{overflow:"溢出",wrap:"自动换行",clip:"截断"},textRotate:{none:"无旋转",angleUp:"向上倾斜",angleDown:"向下倾斜",vertical:"竖排文字",rotationUp:"向上90°",rotationDown:"向下90°"},sheetConfig:{delete:"删除",copy:"复制",rename:"重命名",changeColor:"更改颜色",hide:"隐藏",unhide:"取消隐藏",moveLeft:"向左移",moveRight:"向右移",resetColor:"重置颜色",cancelText:"取消",chooseText:"确定颜色",tipNameRepeat:"标签页的名称不能重复!请重新修改",noMoreSheet:"工作薄内至少含有一张可视工作表。若需删除选定的工作表,请先插入一张新工作表或显示一张隐藏的工作表。",confirmDelete:"是否删除",redoDelete:"可以通过Ctrl+Z撤销删除",noHide:"不能隐藏, 至少保留一个sheet标签",chartEditNoOpt:"图表编辑模式下不允许该操作!",sheetNameErrorTitle:"错误",sheetNameSpecCharError:`名称不能超过31个字符,首尾不能是' 且名称不能包含:\r
|
|
18
|
-
[ ] : \\ ? * /`,sheetNameCannotIsEmptyError:"名称不能为空。",sheetNameAlreadyExistsError:"工作表已存在,请输入其它名称。",deleteSheet:"删除工作表",deleteSheetContent:"确认删除此工作表,删除后将不可找回,确定要删除吗?"},rightClick:{copy:"复制",copyAs:"复制为",cut:"剪切",paste:"粘贴",pasteSpecial:"选择性粘贴",pasteValue:"仅粘贴值",pasteFormat:"仅粘贴格式",pasteColWidth:"仅粘贴列宽",pasteBesidesBorder:"仅粘贴边框以外内容",insert:"插入",delete:"删除",insertRow:"插入行",insertRowBefore:"在上方插入行",insertColumn:"插入列",insertColumnBefore:"在左侧插入列",deleteCell:"删除单元格",insertCell:"插入单元格",deleteSelected:"删除选中",hide:"隐藏",hideSelected:"隐藏选中",showHide:"显示隐藏",toTopAdd:"向上增加",toBottomAdd:"向下增加",toLeftAdd:"向左增加",toRightAdd:"向右增加",deleteSelectedRow:"删除选中行",deleteSelectedColumn:"删除选中列",hideSelectedRow:"隐藏选中行",showHideRow:"显示隐藏行",rowHeight:"行高",hideSelectedColumn:"隐藏选中列",showHideColumn:"显示隐藏列",columnWidth:"列宽",to:"向",left:"左",right:"右",top:"上",bottom:"下",moveLeft:"左移",moveUp:"上移",moveRight:"右移",moveDown:"下移",add:"增加",row:"行",column:"列",width:"宽",height:"高",number:"数字",confirm:"确认",orderAZ:"A-Z顺序排列",orderZA:"Z-A降序排列",clearSelection:"清除",clearContent:"清除内容",clearFormat:"清除格式",clearAll:"清除全部",matrix:"矩阵操作选区",sortSelection:"排序选区",filterSelection:"筛选选区",chartGeneration:"图表生成",firstLineTitle:"首行为标题",untitled:"无标题",array1:"一维数组",array2:"二维数组",array3:"多维数组",diagonal:"对角线",antiDiagonal:"反对角线",diagonalOffset:"对角偏移",offset:"偏移量",boolean:"布尔值",flip:"翻转",upAndDown:"上下",leftAndRight:"左右",clockwise:"顺时针",counterclockwise:"逆时针",transpose:"转置",matrixCalculation:"矩阵计算",plus:"加",minus:"减",multiply:"乘",divided:"除",power:"次方",root:"次方根",log:"log",delete0:"删除两端0值",removeDuplicate:"删除重复值",byRow:"按行",byCol:"按列",generateNewMatrix:"生成新矩阵",fitContent:"适合数据",freeze:"冻结",freezeCol:"冻结列",freezeRow:"冻结行",cancelFreeze:"取消冻结",zenEditor:"禅模式编辑"},info:{tooltip:"提示",notChangeMerge:"不能对合并单元格做部分更改",detailUpdate:"新打开",detailSave:"已恢复本地缓存",row:"行",column:"列",loading:"渲染中···",copy:"副本",return:"返回",rename:"重命名",tips:"重命名",noName:"无标题的电子表格",wait:"待更新",add:"添加",addLast:"在底部添加",backTop:"回到顶部",pageInfo:"共${total}条,${totalPage}页,当前已显示${currentPage}页",nextPage:"下一页",tipInputNumber:"请输入数字",tipInputNumberLimit:"增加范围限制在1-100",tipRowHeightLimit:"行高必须在0 ~ 545之间",tipColumnWidthLimit:"列宽必须在0 ~ 2038之间",pageInfoFull:"共${total}条,${totalPage}页,已显示全部数据"},clipboard:{paste:{exceedMaxCells:"粘贴区域超出最大单元格数"}},statusbar:{sum:"求和",average:"平均值",min:"最小值",max:"最大值",count:"数值计数",countA:"计数",clickToCopy:"点击复制数值",copied:"已复制"},autoFill:{copy:"复制单元格",series:"填充序列",formatOnly:"仅填充格式",noFormat:"不带格式填充"},rangeSelector:{placeholder:"选择范围或输入值",tooltip:"选择范围"},shortcut:{sheet:{"zoom-in":"放大","zoom-out":"缩小","reset-zoom":"恢复缩放","select-below-cell":"选择下方单元格","select-up-cell":"选择上方单元格","select-left-cell":"选择左侧单元格","select-right-cell":"选择右侧单元格","select-next-cell":"选择后一个单元格","select-previous-cell":"选择前一个单元格","select-up-value-cell":"选择上方有值的单元格","select-below-value-cell":"选择下方有值的单元格","select-left-value-cell":"选择左侧有值的单元格","select-right-value-cell":"选择右侧有值的单元格","expand-selection-down":"向下扩展选区","expand-selection-up":"向上扩展选区","expand-selection-left":"向左扩展选区","expand-selection-right":"向右扩展选区","expand-selection-to-left-gap":"向左扩展选区到下一个边界","expand-selection-to-below-gap":"向下扩展选区到下一个边界","expand-selection-to-right-gap":"向右扩展选区到下一个边界","expand-selection-to-up-gap":"向上扩展选区到下一个边界","select-all":"全选","toggle-editing":"开始 / 结束编辑","delete-and-start-editing":"清空并开始编辑","abort-editing":"放弃编辑","break-line":"换行","set-bold":"切换粗体","set-italic":"切换斜体","set-underline":"切换下划线","set-strike-through":"切换删除线"}},"sheet-view":"浏览表格","sheet-edit":"编辑表格"},jc=(i,e,t=!1)=>{const n=h=>h.endRow-h.startRow+1,r=h=>h.endColumn-h.startColumn+1,o=n(e)%n(i),s=r(e)%r(i),a={startRow:0,endRow:n(i)-1,startColumn:0,endColumn:r(i)-1},c=Math.floor(n(e)/n(i)),d=Math.floor(r(e)/r(i)),u=[];if(!o&&!s)for(let h=1;h<=c;h++)for(let m=1;m<=d;m++){const g=n(i)*(h-1),_=r(i)*(m-1),f={startRow:g+e.startRow,endRow:g+e.startRow,startColumn:_+e.startColumn,endColumn:_+e.startColumn};u.push({repeatRelativeRange:a,startRange:f})}else if(!o&&s&&!t)for(let h=1;h<=c;h++){const m=n(i)*(h-1),g=0,_={startRow:m+e.startRow,endRow:m+e.startRow,startColumn:g+e.startColumn,endColumn:g+e.startColumn};u.push({repeatRelativeRange:a,startRange:_})}else if(o&&!s&&!t)for(let h=1;h<=d;h++){const g=r(i)*(h-1),_={startRow:0+e.startRow,endRow:0+e.startRow,startColumn:g+e.startColumn,endColumn:g+e.startColumn};u.push({repeatRelativeRange:a,startRange:_})}else{const h={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};u.push({startRange:h,repeatRelativeRange:a})}return u};class as{constructor(){v(this,"_state",null);v(this,"_rect",null);v(this,"_focus",!1);v(this,"_state$",new J.BehaviorSubject(null));v(this,"state$",this._state$.asObservable());v(this,"_rect$",new J.BehaviorSubject(null));v(this,"rect$",this._rect$.asObservable());v(this,"_focus$",new J.BehaviorSubject(this._focus));v(this,"focus$",this._focus$.asObservable())}dispose(){this._state$.complete(),this._state=null,this._rect$.complete(),this._rect=null}setState(e){this._state=e,this._refresh(e)}getRect(){return this._rect}setRect(e){this._rect=e,this._rect$.next(e)}getState(){return this._state}setFocus(e=!1){this._focus=e,this._focus$.next(e)}_refresh(e){this._state$.next(e)}}const Dn=j.createIdentifier("univer.sheet-cell-editor-manager.service");class Wc{constructor(){v(this,"_position",null);v(this,"_position$",new J.BehaviorSubject(null));v(this,"position$",this._position$.asObservable());v(this,"_focus",!1);v(this,"_focus$",new J.BehaviorSubject(this._focus));v(this,"focus$",this._focus$.asObservable());v(this,"_fxBtnClick$",new J.BehaviorSubject(!1));v(this,"fxBtnClick$",this._fxBtnClick$.asObservable());v(this,"_foldBtnStatus$",new J.BehaviorSubject(!1));v(this,"foldBtnStatus$",this._foldBtnStatus$.asObservable())}dispose(){this._position$.complete(),this._focus$.complete(),this._position=null,this._focus=!1}setPosition(e){this._position=e,this._refresh(e)}getPosition(){return this._position}setFocus(e=!1){this._focus=e,this._focus$.next(e)}handleFxBtnClick(e){this._fxBtnClick$.next(e)}handleFoldBtnClick(e){this._foldBtnStatus$.next(e)}_refresh(e){this._position$.next(e)}}const xi=j.createIdentifier("univer.sheet-formula-editor-manager.service");var zc=Object.defineProperty,$c=Object.getOwnPropertyDescriptor,Yc=(i,e,t,n)=>{for(var r=n>1?void 0:n?$c(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&zc(e,t,r),r},Gr=(i,e)=>(t,n)=>e(t,n,i);let Yn=class extends l.Disposable{constructor(e,t){super();v(this,"_previousSheetIndex",-1);this._commandService=e,this._univerInstanceService=t,this.disposeWithMe(this._commandService.beforeCommandExecuted((n,r)=>{if(n.id===p.RemoveSheetMutation.id)return this._beforeAdjustActiveSheetOnRemoveSheet(n)})),this.disposeWithMe(this._commandService.onCommandExecuted((n,r)=>{if(n.id===p.RemoveSheetMutation.id)return this._adjustActiveSheetOnRemoveSheet(n);if(n.id===p.SetWorksheetHideMutation.id&&n.params.hidden)return this._adjustActiveSheetOnHideSheet(n);if(!(r!=null&&r.fromCollab)){if(n.id===p.InsertSheetMutation.id)return this._adjustActiveSheetOnInsertSheet(n);if(n.id===p.SetWorksheetHideMutation.id&&!n.params.hidden)return this._adjustActiveSheetOnShowSheet(n)}}))}_adjustActiveSheetOnHideSheet(e){const{unitId:t,subUnitId:n}=e.params,r=this._univerInstanceService.getUniverSheetInstance(t);if(!r||(r==null?void 0:r.getRawActiveSheet())!==n)return;const s=r.getActiveSheetIndex(),a=Xc(r,s);this._switchToNextSheet(t,a)}_beforeAdjustActiveSheetOnRemoveSheet(e){const{unitId:t,subUnitId:n}=e.params,r=this._univerInstanceService.getUniverSheetInstance(t);if(!r)return;const o=r.getSheetBySheetId(n);o&&(this._previousSheetIndex=r.getSheetIndex(o))}_adjustActiveSheetOnRemoveSheet(e){if(this._previousSheetIndex===-1)return;const{unitId:t}=e.params,n=this._univerInstanceService.getUniverSheetInstance(t);if(!n||n.getRawActiveSheet())return;const o=this._previousSheetIndex,s=o>=1?o-1:0,a=n.getSheetByIndex(s);if(!a)throw new Error("[ActiveWorksheetController]: cannot find the next sheet!");this._switchToNextSheet(t,a.getSheetId())}_adjustActiveSheetOnInsertSheet(e){const{unitId:t,sheet:n}=e.params;this._switchToNextSheet(t,n.id)}_adjustActiveSheetOnShowSheet(e){const{unitId:t,subUnitId:n}=e.params;this._switchToNextSheet(t,n)}_switchToNextSheet(e,t){this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t})}};Yn=Yc([l.OnLifecycle(l.LifecycleStages.Ready,Yn),Gr(0,l.ICommandService),Gr(1,l.IUniverInstanceService)],Yn);function Xc(i,e){const t=i.getSheetSize();for(let n=e;n>-1;n--){const r=i.getSheetByIndex(n);if(!r.getConfig().hidden)return r.getSheetId()}for(let n=e;n<t;n++){const r=i.getSheetByIndex(n);if(!r.getConfig().hidden)return r.getSheetId()}throw new Error("[ActiveWorksheetController]: could not find the next unhidden sheet! Collaboration error perhaps.")}var Zc=Object.defineProperty,Gc=Object.getOwnPropertyDescriptor,Kc=(i,e,t,n)=>{for(var r=n>1?void 0:n?Gc(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Zc(e,t,r),r},gn=(i,e)=>(t,n)=>e(t,n,i);let Xn=class{constructor(i,e,t,n,r){this._injector=i,this._sheetInterceptorService=e,this._selectionManagerService=t,this._univerInstanceService=n,this._sheetSkeletonManagerService=r,this._initialize()}_getUndoRedoParamsOfAutoHeight(i){const{_univerInstanceService:e,_sheetSkeletonManagerService:t,_injector:n}=this,{skeleton:r}=t.getCurrent(),o=r.calculateAutoHeightInRange(i),s=e.getCurrentUniverSheetInstance(),a=s.getUnitId(),d={subUnitId:s.getActiveSheet().getSheetId(),unitId:a,rowsAutoHeightInfo:o},u=p.SetWorksheetRowAutoHeightMutationFactory(n,d);return{undos:[{id:p.SetWorksheetRowAutoHeightMutation.id,params:u}],redos:[{id:p.SetWorksheetRowAutoHeightMutation.id,params:d}]}}_initialize(){const{_sheetInterceptorService:i,_selectionManagerService:e}=this;i.interceptCommand({getMutations:t=>t.id!==p.SetRangeValuesCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(t.params.range)}),i.interceptCommand({getMutations:t=>t.id!==p.SetWorksheetRowIsAutoHeightCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(t.params.ranges)}),i.interceptCommand({getMutations:t=>{var o;if(t.id!==p.SetStyleCommand.id)return{redos:[],undos:[]};if(!["ff","fs","tr","tb"].includes((o=t.params)==null?void 0:o.style.type))return{redos:[],undos:[]};const r=e.getSelectionRanges();return r!=null&&r.length?this._getUndoRedoParamsOfAutoHeight(r):{redos:[],undos:[]}}})}};Xn=Kc([l.OnLifecycle(l.LifecycleStages.Ready,Xn),gn(0,j.Inject(j.Injector)),gn(1,j.Inject(p.SheetInterceptorService)),gn(2,j.Inject(p.SelectionManagerService)),gn(3,j.Inject(l.IUniverInstanceService)),gn(4,j.Inject(exports.SheetSkeletonManagerService))],Xn);var qc=Object.defineProperty,Jc=Object.getOwnPropertyDescriptor,Qc=(i,e,t,n)=>{for(var r=n>1?void 0:n?Jc(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&qc(e,t,r),r},yt=(i,e)=>(t,n)=>e(t,n,i);let Zn=class extends l.Disposable{constructor(i,e,t,n,r,o,s,a){super(),this._currentUniverSheet=i,this._commandService=e,this._configService=t,this._sheetClipboardService=n,this._messageService=r,this._sheetSkeletonManagerService=o,this._injector=s,this._localService=a,this._init()}_init(){[wo,Pa,rn].forEach(e=>this.disposeWithMe(this._commandService.registerMultipleCommand(e))),[To,yo,Eo,Oo].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e))),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initCopyingHooks())),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingHook()));const i=this._initSpecialPasteHooks().map(e=>this._sheetClipboardService.addClipboardHook(e));this.disposeWithMe({dispose:()=>i.forEach(e=>e.dispose())})}_initCopyingHooks(){const i=this;let e=null;return{id:Ke.DEFAULT_COPY,isDefaultHook:!0,onBeforeCopy(t,n){e=i._getWorksheet(t,n)},onCopyCellContent(t,n){const r=e.getCell(t,n);return`${(r==null?void 0:r.v)||""}`},onCopyCellStyle:(t,n,r,o)=>{const s={};(r||o)&&(s.rowspan=`${r||1}`,s.colspan=`${o||1}`);const c=e.getRange(t,n).getTextStyle();let d="";return c&&(d=l.handleStyleToString(c)),d&&(s.style=d),s},onCopyColumn(t){return{width:`${e.getColumnWidth(t)}`}},onCopyRow(t){return{style:`height: ${e.getRowHeight(t)}px;`}},onAfterCopy(){e=null}}}_initPastingHook(){const i=this;let e=null,t=null,n=null;return{id:Ke.DEFAULT_PASTE,isDefaultHook:!0,onBeforePaste({unitId:r,subUnitId:o,range:s}){n=i._getWorksheet(r,o),e=r,t=o;const a=i._configService.getConfig(p.MAX_CELL_PER_SHEET_KEY),{endRow:c,endColumn:d}=s;return a&&c*d>a?(i._messageService.show({type:Ye.MessageType.Error,content:i._localService.t("clipboard.paste.exceedMaxCells")}),!1):!0},onPasteRows(r,o){const{range:s}=r,a=[],c=n.getMaxRows(),d=s.endRow-c,u=o.length-d;if(d>0){const g={};o.slice(u).forEach((f,C)=>{const I=f==null?void 0:f.style;if(!I)return;const w=I.split(";");let E=l.DEFAULT_WORKSHEET_ROW_HEIGHT;w.find(O=>{O=O.toLowerCase();const x=R.textTrim(O.substr(0,O.indexOf(":"))),N=R.textTrim(O.substr(O.indexOf(":")+1));return x==="height"?(E=parseFloat(N),!0):!1}),g[C]={h:E,hd:l.BooleanNumber.FALSE}});const _={unitId:e,subUnitId:t,range:{...s,startRow:c},rowInfo:g};a.push({id:p.InsertRowMutation.id,params:_})}const h={};o.slice(0,u).forEach((g,_)=>{const f=g.style;if(!f)return;const C=f.split(";");let I=l.DEFAULT_WORKSHEET_ROW_HEIGHT;C.find(w=>{w=w.toLowerCase();const E=R.textTrim(w.substr(0,w.indexOf(":"))),O=R.textTrim(w.substr(w.indexOf(":")+1));return E==="height"?(I=parseFloat(O),!0):!1}),h[_]=I});const m={unitId:e,subUnitId:t,ranges:[{...s,endRow:Math.min(s.endRow,c)}],rowHeight:h};return a.push({id:p.SetWorksheetRowHeightMutation.id,params:m}),{redos:a,undos:[]}},onPasteColumns(r,o,s){const{range:a}=r,c=[],d=n.getMaxColumns(),u=a.endColumn-d,h=o.length-u;if(u>0){const g={unitId:e,subUnitId:t,range:{...a,startColumn:d},colInfo:o.slice(h).map(_=>({w:_.width?+_.width:l.DEFAULT_WORKSHEET_COLUMN_WIDTH,hd:l.BooleanNumber.FALSE}))};c.push({id:p.InsertColMutation.id,params:g})}const m={unitId:e,subUnitId:t,ranges:[{...a,endRow:Math.min(a.endColumn,d)}],colWidth:o.slice(0,h).map(g=>g.width?+g.width:l.DEFAULT_WORKSHEET_COLUMN_WIDTH)};return c.push({id:p.SetWorksheetColWidthMutation.id,params:m}),{redos:c,undos:[]}},onPastePlainText(r,o,s){return i._onPastePlainText(r,o,s)},onPasteCells(r,o,s,a){return i._onPasteCells(r,o,s,a)},onAfterPaste(r){n=null}}}_generateDocumentDataModelSnapshot(i){var s;const e=this._sheetSkeletonManagerService.getCurrent();if(e==null)return null;const{skeleton:t}=e,n=(s=t.getBlankCellDocumentModel())==null?void 0:s.documentModel,o={...n==null?void 0:n.getSnapshot(),...i};return n==null||n.reset(o),n==null?void 0:n.getSnapshot()}_onPastePlainText(i,e,t){const{range:n,unitId:r,subUnitId:o}=i;let s;if(/\r|\n/.test(e)){const c=Mo(e),d=this._generateDocumentDataModelSnapshot({body:c});s={[n.startRow]:{[n.startColumn]:{p:d}}}}else s={[n.startRow]:{[n.startColumn]:{v:e}}};const a={unitId:r,subUnitId:o,cellValue:s};return{redos:[{id:p.SetRangeValuesMutation.id,params:a}],undos:[{id:p.SetRangeValuesMutation.id,params:p.SetRangeValuesUndoMutationFactory(this._injector,a)}]}}_onPasteCells(i,e,t,n){const r={get:this._injector.get.bind(this._injector)};return la(i,e,t,n,r)}_initSpecialPasteHooks(){const i={get:this._injector.get.bind(this._injector)},e=this,t={id:Ke.SPECIAL_PASTE_VALUE,specialPasteInfo:{label:"specialPaste.value"},onPasteCells:(s,a,c,d)=>{const u=e._currentUniverSheet.getCurrentUniverSheetInstance();return u.getUnitId(),u.getActiveSheet().getSheetId(),Ro(a,c,i)}},n={id:Ke.SPECIAL_PASTE_FORMAT,specialPasteInfo:{label:"specialPaste.format"},onPasteCells(s,a,c,d){const u=e._currentUniverSheet.getCurrentUniverSheetInstance();u.getUnitId(),u.getActiveSheet().getSheetId();const h=[],m=[],{undos:g,redos:_}=bo(a,c,i);h.push(..._),m.push(...g);const{undos:f,redos:C}=Ki(a,c,i);h.push(...C),m.push(...f);const{undos:I,redos:w}=Io(a,c,i);return h.push(...w),m.push(...I),{undos:m,redos:h}}},r={id:Ke.SPECIAL_PASTE_COL_WIDTH,specialPasteInfo:{label:"specialPaste.colWidth"},onPasteCells(){return{undos:[],redos:[]}},onPasteColumns(s,a,c){const d=e._currentUniverSheet.getCurrentUniverSheetInstance(),u=d.getUnitId(),h=d.getActiveSheet().getSheetId(),m=[],g=e._getWorksheet(u,h),{range:_}=s,f=g.getMaxColumns(),C=_.endColumn-f,I=a.length-C,w={unitId:u,subUnitId:h,ranges:[{..._,endRow:Math.min(_.endColumn,f)}],colWidth:a.slice(0,I).map(E=>E.width?+E.width:l.DEFAULT_WORKSHEET_COLUMN_WIDTH)};return m.push({id:p.SetWorksheetColWidthMutation.id,params:w}),m.push({id:p.SetWorksheetColWidthMutation.id,params:w}),{redos:m,undos:[]}}},o={id:Ke.SPECIAL_PASTE_BESIDES_BORDER,specialPasteInfo:{label:"specialPaste.besidesBorder"},onPasteCells(s,a,c,d){e._currentUniverSheet.getCurrentUniverSheetInstance();const u=[],h=[],{range:m,unitId:g,subUnitId:_}=a,{startColumn:f,startRow:C,endColumn:I,endRow:w}=m,E=new l.ObjectMatrix;c.forValue((P,L,G)=>{const k=G.s;typeof k=="object"&&E.setValue(P+C,L+f,{s:{...k,bd:void 0},v:G.v})});const O={unitId:g,subUnitId:_,cellValue:E.getData()};u.push({id:p.SetRangeValuesMutation.id,params:O});const x=p.SetRangeValuesUndoMutationFactory(i,O);h.push({id:p.SetRangeValuesMutation.id,params:x});const{undos:N,redos:D}=Ki(a,c,i);return h.push(...N),u.push(...D),{redos:u,undos:h}}};return[t,n,r,o]}_getWorksheet(i,e){var n;const t=(n=this._currentUniverSheet.getUniverSheetInstance(i))==null?void 0:n.getSheetBySheetId(e);if(!t)throw new Error(`[SheetClipboardController]: cannot find a worksheet with unitId ${i} and subUnitId ${e}.`);return t}};Zn=Qc([l.OnLifecycle(l.LifecycleStages.Ready,Zn),yt(0,l.IUniverInstanceService),yt(1,l.ICommandService),yt(2,l.IConfigService),yt(3,nn),yt(4,R.IMessageService),yt(5,j.Inject(exports.SheetSkeletonManagerService)),yt(6,j.Inject(j.Injector)),yt(7,j.Inject(l.LocaleService))],Zn);var ed=Object.defineProperty,td=Object.getOwnPropertyDescriptor,nd=(i,e,t,n)=>{for(var r=n>1?void 0:n?td(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&ed(e,t,r),r},_n=(i,e)=>(t,n)=>e(t,n,i);let Gn=class extends l.Disposable{constructor(i,e,t,n,r){super(),this._currentUniverService=i,this._contextMenuService=e,this._renderManagerService=t,this._selectionManagerService=n,this._selectionRenderService=r,this._currentUniverService.currentSheet$.subscribe(o=>{if(o==null)throw new Error("workbook is null");this._addListeners()})}_addListeners(){const i=qe(this._currentUniverService,this._renderManagerService);if(!i)return;const e=i.spreadsheet.onPointerDownObserver,t=e.add(a=>{if(a.button===2){const c=this._selectionManagerService.getSelections(),d=c==null?void 0:c[0];if(!d)return;const u=d.range.rangeType,h=this._selectionRenderService.convertSelectionRangeToData(d).rangeWithCoord,m=()=>{if(!h)return!1;const _=a.offsetX,f=a.offsetY;switch(u){case l.RANGE_TYPE.ROW:return h.startY<=f&&h.endY>=f;case l.RANGE_TYPE.COLUMN:return h.startX<=_&&h.endX>=_;default:return h.startX<=_&&h.endX>=_&&h.startY<=f&&h.endY>=f}},g=_=>{this._contextMenuService.triggerContextMenu(a,_)};m()?u===l.RANGE_TYPE.COLUMN?g(Be.COL_HEADER_CONTEXT_MENU):u===l.RANGE_TYPE.ROW?g(Be.ROW_HEADER_CONTEXT_MENU):g(R.MenuPosition.CONTEXT_MENU):g(R.MenuPosition.CONTEXT_MENU)}});this.disposeWithMe(l.toDisposable(()=>e.remove(t)));const r=i.spreadsheetRowHeader.onPointerDownObserver.add(a=>{a.button===2&&this._contextMenuService.triggerContextMenu(a,Be.ROW_HEADER_CONTEXT_MENU)});this.disposeWithMe(l.toDisposable(()=>e.remove(r)));const s=i.spreadsheetColumnHeader.onPointerDownObserver.add(a=>{a.button===2&&this._contextMenuService.triggerContextMenu(a,Be.COL_HEADER_CONTEXT_MENU)});this.disposeWithMe(l.toDisposable(()=>e.remove(s)))}};Gn=nd([l.OnLifecycle(l.LifecycleStages.Rendered,Gn),_n(0,l.IUniverInstanceService),_n(1,R.IContextMenuService),_n(2,y.IRenderManagerService),_n(3,j.Inject(p.SelectionManagerService)),_n(4,Ze)],Gn);var id=Object.defineProperty,rd=Object.getOwnPropertyDescriptor,od=(i,e,t,n)=>{for(var r=n>1?void 0:n?rd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&id(e,t,r),r},Vi=(i,e)=>(t,n)=>e(t,n,i);let Kn=class extends l.RxDisposable{constructor(i,e,t){super(),this._currentUniverService=i,this._renderManagerService=e,this._undoRedoService=t,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialNormalInput(),this._listenEditorBlur()}_listenEditorBlur(){this._currentUniverService.currentDoc$.pipe(J.takeUntil(this.dispose$)).subscribe(i=>{if(i==null)return;i.getUnitId()!==l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._undoRedoService.clearUndoRedo(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})}_initialNormalInput(){const i={};this._currentUniverService.getCurrentUniverSheetInstance().getSheets().forEach(e=>{const t=e.getConfig();i[e.getSheetId()]={cellData:new l.ObjectMatrix(t.cellData),rowCount:t.rowCount,columnCount:t.columnCount}})}_commandExecutedListener(){}_getDocObject(){return pe.getDocObject(this._currentUniverService,this._renderManagerService)}};Kn=od([l.OnLifecycle(l.LifecycleStages.Steady,Kn),Vi(0,l.IUniverInstanceService),Vi(1,y.IRenderManagerService),Vi(2,j.Inject(l.IUndoRedoService))],Kn);const ls=[R.KeyCode.ARROW_DOWN,R.KeyCode.ARROW_UP,R.KeyCode.ARROW_LEFT,R.KeyCode.ARROW_RIGHT],sd=[R.KeyCode.ENTER,R.KeyCode.TAB,...ls];function ad(){const i=[];for(const e of ls)i.push({id:Tn.id,binding:e,preconditions:t=>vi(t),staticParameters:{visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:e,isShift:!1}}),i.push({id:Tn.id,binding:e|R.MetaKeys.SHIFT,preconditions:t=>vi(t),staticParameters:{visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:e,isShift:!0}});return i}const ld={id:mt.id,binding:R.KeyCode.ENTER,description:"shortcut.sheet.toggle-editing",group:"4_sheet-edit",preconditions:i=>vi(i),staticParameters:{visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:R.KeyCode.ENTER}},cd={id:mt.id,binding:R.KeyCode.TAB,preconditions:i=>vi(i),staticParameters:{visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:R.KeyCode.TAB}},dd={id:mt.id,binding:R.KeyCode.ESC,description:"shortcut.sheet.abort-editing",group:"4_sheet-edit",preconditions:i=>vo(i),staticParameters:{visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:R.KeyCode.ESC}},ud={id:pe.BreakLineCommand.id,description:"shortcut.sheet.break-line",group:"4_sheet-edit",preconditions:i=>vo(i),binding:R.KeyCode.ENTER|R.MetaKeys.ALT},hd={id:pe.DeleteLeftCommand.id,preconditions:i=>js(i)||Co(i),binding:R.KeyCode.BACKSPACE},md={id:mt.id,description:"shortcut.sheet.delete-and-start-editing",group:"4_sheet-edit",preconditions:i=>Bs(i)&&!Co(i),binding:R.KeyCode.BACKSPACE,staticParameters:{visible:!0,eventType:y.DeviceInputEventType.Keyboard,keycode:R.KeyCode.BACKSPACE}};var gd=Object.defineProperty,_d=Object.getOwnPropertyDescriptor,pd=(i,e,t,n)=>{for(var r=n>1?void 0:n?_d(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&gd(e,t,r),r},dt=(i,e)=>(t,n)=>e(t,n,i);function fd(i){const{textRuns:e=[],paragraphs:t=[]}=i;return e.some(n=>n.ts&&!l.Tools.isEmptyObject(n.ts))||t.some(n=>n.bullet)}let qn=class extends l.Disposable{constructor(e,t,n,r,o,s,a,c,d,u){super();v(this,"_onInputSubscription");v(this,"_cursorChangeObservers");v(this,"_editorVisiblePrevious",!1);v(this,"_isCursorChange",0);this._currentUniverService=e,this._renderManagerService=t,this._commandService=n,this._editorBridgeService=r,this._contextService=o,this._cellEditorManagerService=s,this._lexerTreeBuilder=a,this._undoRedoService=c,this._sheetInterceptorService=d,this._selectionManagerService=u,this._initialize(),this._commandExecutedListener()}dispose(){var n;(n=this._onInputSubscription)==null||n.unsubscribe();const e=this._getEditorObject();if(e==null)return;const{document:t}=e;t.onPointerDownObserver.remove(this._cursorChangeObservers)}_initialize(){this._initialExitInput(),this._cursorStateListener()}_initialExitInput(){this._onInputSubscription=this._editorBridgeService.visible$.subscribe(e=>{const{visible:t,keycode:n,eventType:r}=e;if(t===this._editorVisiblePrevious)return;if(this._editorVisiblePrevious=t,t===!0){this._isCursorChange=r===y.DeviceInputEventType.PointerDown?2:1;return}this._isCursorChange=0;const o=this._selectionManagerService.getSelections(),s=this._selectionManagerService.getCurrent();if(s==null)return;const{unitId:a,sheetId:c,pluginName:d}=s;if(this._exitInput(e),n===R.KeyCode.ESC){this._commandService.syncExecuteCommand(p.SetSelectionsOperation.id,{unitId:a,subUnitId:c,pluginName:d,selections:o});return}const u=this._editorBridgeService.getEditCellState();if(u==null)return;const{unitId:h,sheetId:m,row:g,column:_,documentLayoutObject:f}=u;if(this._moveCursor(n),this._editorBridgeService.getEditorDirty()===!1)return;const I=this._currentUniverService.getUniverSheetInstance(h),w=I==null?void 0:I.getSheetBySheetId(m);if(w==null)return;const E=Sd(w.getCellRaw(g,_)||{},f,this._lexerTreeBuilder);if(E==null)return;const O={subUnitId:m,unitId:h,workbook:I,worksheet:w,row:g,col:_},x=this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT)(E,O);this._commandService.executeCommand(p.SetRangeValuesCommand.id,{subUnitId:m,unitId:h,range:{startRow:g,startColumn:_,endRow:g,endColumn:_},value:x}),a===h&&m!==c&&this._commandService.executeCommand(p.SetWorksheetActivateCommand.id,{subUnitId:m,unitId:h})})}_exitInput(e){this._contextService.setContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA,!1),this._contextService.setContextValue(l.FOCUSING_EDITOR,!1),this._contextService.setContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN,!1),this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!1),this._cellEditorManagerService.setState({show:e.visible});const t=this._editorBridgeService.getCurrentEditorId();t!=null&&(this._undoRedoService.clearUndoRedo(t),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))}_moveCursor(e){if(e==null||!sd.includes(e))return;let t=l.Direction.LEFT;switch(e){case R.KeyCode.ENTER:t=l.Direction.DOWN;break;case R.KeyCode.TAB:t=l.Direction.RIGHT;break;case R.KeyCode.ARROW_DOWN:t=l.Direction.DOWN;break;case R.KeyCode.ARROW_UP:t=l.Direction.UP;break;case R.KeyCode.ARROW_LEFT:t=l.Direction.LEFT;break;case R.KeyCode.ARROW_RIGHT:t=l.Direction.RIGHT;break}e===R.KeyCode.ENTER||e===R.KeyCode.TAB?this._commandService.executeCommand(jt.id,{keycode:e,direction:t}):this._commandService.executeCommand(nt.id,{direction:t})}_cursorStateListener(){const e=this._getEditorObject();if(e==null)return;const{document:t}=e;this._cursorChangeObservers=t.onPointerDownObserver.add(()=>{this._isCursorChange===1&&(this._isCursorChange=2)})}_commandExecutedListener(){const e=[Tn.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=t.params,{keycode:r,isShift:o}=n;if(r!=null&&this._isCursorChange===2){this._moveInEditor(r,o);return}this._editorBridgeService.changeVisible(n)}}))}_moveInEditor(e,t){let n=l.Direction.LEFT;e===R.KeyCode.ARROW_DOWN?n=l.Direction.DOWN:e===R.KeyCode.ARROW_UP?n=l.Direction.UP:e===R.KeyCode.ARROW_RIGHT&&(n=l.Direction.RIGHT),t?this._commandService.executeCommand(pe.MoveSelectionOperation.id,{direction:n}):this._commandService.executeCommand(pe.MoveCursorOperation.id,{direction:n})}_getEditorObject(){return wi(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};qn=pd([l.OnLifecycle(l.LifecycleStages.Steady,qn),dt(0,l.IUniverInstanceService),dt(1,y.IRenderManagerService),dt(2,l.ICommandService),dt(3,at),dt(4,l.IContextService),dt(5,Dn),dt(6,j.Inject(Re.LexerTreeBuilder)),dt(7,l.IUndoRedoService),dt(8,j.Inject(p.SheetInterceptorService)),dt(9,j.Inject(p.SelectionManagerService))],qn);function Sd(i,e,t){i=l.Tools.deepClone(i);const{documentModel:n}=e;if(n==null)return null;const r=n.getSnapshot(),{body:o}=r;if(o==null)return null;const s=o.dataStream;let c=s.substring(s.length-2,s.length)===l.DEFAULT_EMPTY_DOCUMENT_VALUE?s.substring(0,s.length-2):s;if(l.isFormulaString(c)){if(i.f===c)return null;const d=t.checkIfAddBracket(c);for(let u=0;u<d;u++)c+=Re.matchToken.CLOSE_BRACKET;i.f=c,i.v=null,i.p=null}else if(fd(o))o.dataStream===`\r
|
|
19
|
-
`?(i.v="",i.f=null,i.si=null,i.p=null):(i.p=r,i.v=null,i.f=null,i.si=null);else{if((c===i.v||c===""&&i.v==null)&&i.p==null)return null;i.v=c,i.f=null,i.si=null,i.p=null}return i}var
|
|
20
|
-
`,r=[{startIndex:0}]):e.isInArrayFormulaRange===!0&&(o=(t==null?void 0:t.textRuns)||[]),this._syncContentAndRender(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,n,r,o),this._autoScroll())}_commandExecutedListener(){const e=[pe.RichTextEditingMutation.id,Ti.id],t=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(r=>{var o,s;if(e.includes(r.id)){const a=r.params,{unitId:c}=a;if(t.includes(c)){const d=this._univerInstanceService.getUniverDocInstance(c),u=(o=d==null?void 0:d.getBody())==null?void 0:o.dataStream,h=(s=d==null?void 0:d.getBody())==null?void 0:s.paragraphs,m=c===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;if(u==null||h==null)return;this._syncContentAndRender(m,u,h),this._autoScroll()}}}));const n=[p.SetRangeValuesMutation.id,p.MoveRangeMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(r=>{var o,s,a,c,d;if(n.includes(r.id)){const u=this._editorBridgeService.getLatestEditCellState();if(u==null)return;let h=!1;const{row:m,column:g}=u;if(r.id===p.SetRangeValuesMutation.id&&r.params?(s=(o=r.params.cellValue)==null?void 0:o[m])!=null&&s[g]&&(h=!0):r.id===p.MoveRangeMutation.id&&r.params&&(c=(a=r.params.to.value)==null?void 0:a[m])!=null&&c[g]&&(h=!0),h){const _=(d=u.documentLayoutObject.documentModel)==null?void 0:d.getBody();if(_==null)return;const{dataStream:f,paragraphs:C=[]}=_;this._syncContentAndRender(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,f,C),this._autoScroll()}}}))}_syncContentAndRender(e,t,n,r=[]){var h;const o=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=this._docSkeletonManagerService.getSkeletonByUnitId(e),a=this._univerInstanceService.getUniverDocInstance(e),c=this._docViewModelManagerService.getViewModel(e);if(a==null||c==null||s==null)return;a.getBody().dataStream=t,a.getBody().paragraphs=this._clearParagraph(n),e===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(a.getBody().textRuns=[]),r.length>0&&(a.getBody().textRuns=r),c.reset(a);const{skeleton:d}=s,u=this._renderManagerService.getRenderById(e);u!=null&&(d.calculate(),o.includes(e)&&((h=u.mainComponent)==null||h.makeDirty()))}_clearParagraph(e){const t=l.Tools.deepClone(e);for(const n of t)n.paragraphStyle&&(n.paragraphStyle.horizontalAlign=l.HorizontalAlign.UNSPECIFIED);return t}_autoScroll(){var _,f;const e=(_=this._docSkeletonManagerService.getSkeletonByUnitId(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))==null?void 0:_.skeleton,t=this._formulaEditorManagerService.getPosition(),n=this._renderManagerService.getRenderById(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),r=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(e==null||t==null||n==null||r==null)return;const{marginTop:o=0,marginBottom:s=0}=r.getSnapshot().documentStyle,{scene:a,mainComponent:c}=n;let{actualHeight:d}=e.getActualSize();d+=o+s;const{width:u,height:h}=t,m=a.getViewport(pe.VIEWPORT_KEY.VIEW_MAIN);let g=m==null?void 0:m.getScrollBar();a.transformByState({width:u,height:d}),c==null||c.resize(u,d),d>h?g==null?m&&new y.ScrollBar(m,{enableHorizontal:!1,barSize:8}):m==null||m.resetSizeAndScrollBar():(g=null,m==null||m.scrollTo({x:0,y:0}),(f=m==null?void 0:m.getScrollBar())==null||f.dispose())}};Jn=Rd([l.OnLifecycle(l.LifecycleStages.Steady,Jn),ut(0,l.IUniverInstanceService),ut(1,y.IRenderManagerService),ut(2,at),ut(3,j.Inject(pe.DocSkeletonManagerService)),ut(4,j.Inject(pe.DocViewModelManagerService)),ut(5,l.ICommandService),ut(6,l.IContextService),ut(7,xi),ut(8,l.IUndoRedoService),ut(9,j.Inject(pe.TextSelectionManagerService))],Jn);var Id=Object.defineProperty,bd=Object.getOwnPropertyDescriptor,Md=(i,e,t,n)=>{for(var r=n>1?void 0:n?bd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Id(e,t,r),r},wd=(i,e)=>(t,n)=>e(t,n,i);let Qn=class extends l.Disposable{constructor(i){super(),this._currentUniverService=i,setTimeout(()=>{this._initialize()},0)}_initialize(){this._currentUniverService.createDoc({id:l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:{dataStream:`${l.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{}});const i={id:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:`${l.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:1/0,height:1/0},marginTop:5,marginBottom:5,marginRight:0,marginLeft:0,paragraphLineGapDefault:0,renderConfig:{horizontalAlign:l.HorizontalAlign.UNSPECIFIED,verticalAlign:l.VerticalAlign.UNSPECIFIED,centerAngle:0,vertexAngle:0,wrapStrategy:l.WrapStrategy.WRAP}}};this._currentUniverService.createDoc(i)}};Qn=Md([l.OnLifecycle(l.LifecycleStages.Rendered,Qn),wd(0,l.IUniverInstanceService)],Qn);const Td="36",yd="univer-sheet-container",cs={sheetFooterBarHeight:Td,sheetContainer:yd};var Ed=Object.defineProperty,Od=Object.getOwnPropertyDescriptor,xd=(i,e,t,n)=>{for(var r=n>1?void 0:n?Od(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ed(e,t,r),r},rt=(i,e)=>(t,n)=>e(t,n,i);const Kr=-1e3,qr=5,Ad=2;let ei=class extends l.Disposable{constructor(e,t,n,r,o,s,a,c,d,u,h){super();v(this,"_onInputSubscription");v(this,"_onInputActivateSubscription");v(this,"_editorVisiblePrevious",!1);this._docSkeletonManagerService=e,this._docViewModelManagerService=t,this._contextService=n,this._currentUniverService=r,this._renderManagerService=o,this._editorBridgeService=s,this._cellEditorManagerService=a,this._textSelectionRenderManager=c,this._textSelectionManagerService=d,this._commandService=u,this._localService=h,this._initialize(),this._commandExecutedListener()}dispose(){var e,t;(e=this._onInputSubscription)==null||e.unsubscribe(),(t=this._onInputActivateSubscription)==null||t.unsubscribe()}_initialize(){this._initialEditFocusListener(),this._initialStartEdit(),this._initialKeyboardListener(),this._initialCursorSync(),this._listenEditorFocus()}_listenEditorFocus(){const e=this._getEditorObject();e!=null&&this.disposeWithMe(l.toDisposable(e.document.onPointerDownObserver.add(()=>{var t;if(this._editorBridgeService.isVisible()){const n=this._editorBridgeService.getEditCellState(),r=this._editorBridgeService.getCurrentEditorId();if(n==null||r==null)return;const o=(t=this._docSkeletonManagerService.getSkeletonByUnitId(r))==null?void 0:t.skeleton;if(o==null)return;const{position:s,documentLayoutObject:a,canvasOffset:c,scaleX:d,scaleY:u}=n;this._fitTextSize(s,c,o,a,d,u)}})))}_initialCursorSync(){this._cellEditorManagerService.focus$.subscribe(()=>{this._textSelectionRenderManager.sync()})}_initialEditFocusListener(){this._onInputSubscription=this._editorBridgeService.currentEditCellState$.subscribe(e=>{if(e==null||this._editorBridgeService.isForceKeepVisible())return;const{position:t,documentLayoutObject:n,scaleX:r,editorUnitId:o}=e;if(this._getEditorObject()==null)return;const{startX:a,endX:c}=t,{textRotation:d,wrapStrategy:u,documentModel:h}=n,{a:m}=d;h.updateDocumentId(o),u===l.WrapStrategy.WRAP&&m===0&&h.updateDocumentDataPageSize((c-a)/r),this._currentUniverService.changeDoc(o,h),this._contextService.setContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN,!0),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}]),this._textSelectionRenderManager.activate(Kr,Kr)})}_fitTextSize(e,t,n,r,o=1,s=1){const{startX:a,startY:c,endX:d,endY:u}=e,h=r.documentModel;if(h==null)return;const{actualWidth:m,actualHeight:g}=this._predictingSize(e,t,n,r,o,s),{verticalAlign:_,paddingData:f,fill:C}=r;let I=d-a,w=u-c;if(I<m&&(I=m),w<g)w=g,h.updateDocumentDataMargin(f);else{let E=f.t||0;_===l.VerticalAlign.MIDDLE?E=(w-g)/2:_===l.VerticalAlign.BOTTOM&&(E=w-g),E/=s,E=E<(f.t||0)?f.t||0:E,h.updateDocumentDataMargin({t:E})}n.calculate(),this._editAreaProcessing(I,w,e,t,C,o,s)}_predictingSize(e,t,n,r,o=1,s=1){const{startX:a,endX:c}=e,{textRotation:d,wrapStrategy:u}=r,h=r.documentModel,{a:m}=d,g=document.body.clientWidth;if(u===l.WrapStrategy.WRAP&&m===0){const{actualWidth:C,actualHeight:I}=n.getActualSize();return{actualWidth:C*o,actualHeight:I*s}}h==null||h.updateDocumentDataPageSize((g-a-t.left)/o),n.calculate();const _=n.getActualSize();let f=c-a;return f<_.actualWidth*o+qr*o&&(f=_.actualWidth*o+qr*o),h==null||h.updateDocumentDataPageSize(f/o),h==null||h.updateDocumentRenderConfig({horizontalAlign:l.HorizontalAlign.UNSPECIFIED}),{actualWidth:f,actualHeight:_.actualHeight*s}}_editAreaProcessing(e,t,n,r,o,s=1,a=1){var x;const c=this._getEditorObject();if(c==null)return;let{startX:d,startY:u}=n;const{document:h,scene:m,engine:g}=c,_=m.getViewport(pe.VIEWPORT_KEY.VIEW_MAIN),f=document.body.clientHeight-u-parseFloat(cs.sheetFooterBarHeight)-r.top-Ad*2,C=document.body.clientWidth-d-r.left;let I=t,w=_==null?void 0:_.getScrollBar();I>f?(I=f,w==null?_&&new y.ScrollBar(_,{enableHorizontal:!1,barSize:8}):_==null||_.resetSizeAndScrollBar()):(w=null,(x=_==null?void 0:_.getScrollBar())==null||x.dispose()),e+=(w==null?void 0:w.barSize)||0,e>C&&(e=C),d-=y.FIX_ONE_PIXEL_BLUR_OFFSET,u-=y.FIX_ONE_PIXEL_BLUR_OFFSET,this._addBackground(m,e/s,t/a,o);const{scaleX:E,scaleY:O}=m.getPrecisionScale();m.transformByState({width:e/s,height:t/a,scaleX:s,scaleY:a}),h.resize(e/s,t/a),requestIdleCallback(()=>{g.resizeBySize(y.fixLineWidthByScale(e,E),y.fixLineWidthByScale(I,O))}),this._cellEditorManagerService.setState({startX:d,startY:u,endX:e+d,endY:I+u,show:!0})}_addBackground(e,t,n,r){const o="_backgroundRectHelperColor_",s=e.getObject(o);s==null&&r==null||(s==null?e.addObjects([new y.Rect(o,{width:t,height:n,fill:r,evented:!1})],pe.DOCS_COMPONENT_MAIN_LAYER_INDEX):r==null?s.dispose():(s.setProps({fill:r}),s.transformByState({width:t,height:n})))}_initialStartEdit(){this._onInputActivateSubscription=this._editorBridgeService.visible$.subscribe(e=>{var O,x,N;const{visible:t,eventType:n,keycode:r}=e;if(t===this._editorVisiblePrevious||(this._editorVisiblePrevious=t,t===!1))return;const o=this._editorBridgeService.getEditCellState();if(o==null)return;const{position:s,documentLayoutObject:a,canvasOffset:c,scaleX:d,scaleY:u,editorUnitId:h,unitId:m,isInArrayFormulaRange:g=!1}=o,_=this._getEditorObject();if(_==null)return;const{document:f,scene:C}=_;this._contextService.setContextValue(l.FOCUSING_EDITOR,!0);const{documentModel:I}=a,w=this._docSkeletonManagerService.getSkeletonByUnitId(h);if(w==null||I==null)return;const{skeleton:E}=w;if(this._fitTextSize(s,c,E,a,d,u),n===y.DeviceInputEventType.Keyboard||n===y.DeviceInputEventType.Dblclick&&g){const D=l.Tools.deepClone(I.snapshot),P=(O=this._docViewModelManagerService.getCurrent())==null?void 0:O.docViewModel;this._resetBodyStyle(D.body),I.reset(D),P.reset(I),f.makeDirty(),(r===R.KeyCode.BACKSPACE||n===y.DeviceInputEventType.Dblclick)&&(E.calculate(),this._editorBridgeService.changeEditorDirty(!0)),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}])}else if(n===y.DeviceInputEventType.Dblclick){const D=I.getBody().dataStream.length-2||0;(x=C.getViewport(pe.VIEWPORT_KEY.VIEW_MAIN))==null||x.scrollTo({y:1/0}),this._textSelectionManagerService.replaceTextRanges([{startOffset:D,endOffset:D}])}(N=this._renderManagerService.getRenderById(m))==null||N.scene.resetCursor()})}_resetBodyStyle(e){e.dataStream=l.DEFAULT_EMPTY_DOCUMENT_VALUE,e.textRuns!=null&&(e.textRuns.length===1?(e.textRuns[0].st=0,e.textRuns[0].ed=1):e.textRuns=void 0),e.paragraphs!=null&&(e.paragraphs.length===1?e.paragraphs[0].startIndex=0:e.paragraphs=[{startIndex:0}]),e.sectionBreaks!=null&&(e.sectionBreaks=void 0),e.tables!=null&&(e.tables=void 0),e.customRanges!=null&&(e.customRanges=void 0),e.customBlocks!=null&&(e.customBlocks=void 0)}_initialKeyboardListener(){this._textSelectionRenderManager.onInputBefore$.subscribe(e=>{const t=this._contextService.getContextValue(l.FOCUSING_FORMULA_EDITOR);this._contextService.getContextValue(l.FOCUSING_SHEET)&&!t&&this._showEditorByKeyboard(e)})}_showEditorByKeyboard(e){if(e==null)return;const t=e.event;this._commandService.executeCommand(mt.id,{visible:!0,eventType:y.DeviceInputEventType.Keyboard,keycode:t.which})}_commandExecutedListener(){const e=[pe.RichTextEditingMutation.id,Ti.id],t=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var r;if(e.includes(n.id)){const o=n.params,{unitId:s}=o,a=this._editorBridgeService.getCurrentEditorId();if(a==null)return;this._editorBridgeService.changeEditorDirty(!0);const c=(r=this._docSkeletonManagerService.getSkeletonByUnitId(a))==null?void 0:r.skeleton;if(c==null||!t.includes(s))return;const d=this._editorBridgeService.getEditCellState();if(d==null)return;const{position:u,documentLayoutObject:h,canvasOffset:m,scaleX:g,scaleY:_}=d;this._fitTextSize(u,m,c,h,g,_)}}))}_getEditorObject(){return wi(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};ei=xd([l.OnLifecycle(l.LifecycleStages.Steady,ei),rt(0,j.Inject(pe.DocSkeletonManagerService)),rt(1,j.Inject(pe.DocViewModelManagerService)),rt(2,l.IContextService),rt(3,l.IUniverInstanceService),rt(4,y.IRenderManagerService),rt(5,at),rt(6,Dn),rt(7,y.ITextSelectionRenderManager),rt(8,j.Inject(pe.TextSelectionManagerService)),rt(9,l.ICommandService),rt(10,j.Inject(l.LocaleService))],ei);const ds={id:"sheet.operation.set-activate-cell-edit",type:l.CommandType.OPERATION,handler:(i,e)=>(i.get(at).setEditCell(e),!0)};var Nd=Object.defineProperty,Dd=Object.getOwnPropertyDescriptor,Pd=(i,e,t,n)=>{for(var r=n>1?void 0:n?Dd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Nd(e,t,r),r},zt=(i,e)=>(t,n)=>e(t,n,i);let ti=class extends l.RxDisposable{constructor(i,e,t,n,r,o){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._editorBridgeService=r,this._selectionManagerService=o,this._initialize(),this._commandExecutedListener()}dispose(){}_initialize(){this._initSelectionChangeListener(),this._initialEventListener()}_initSelectionChangeListener(){J.merge(this._selectionManagerService.selectionMoveEnd$,this._selectionManagerService.selectionMoveStart$).pipe(J.takeUntil(this.dispose$)).subscribe(i=>this._handleSelectionListener(i))}_handleSelectionListener(i){const e=this._selectionManagerService.getCurrent();if((e==null?void 0:e.pluginName)!==p.NORMAL_SELECTION_PLUGIN_NAME||this._editorBridgeService.isVisible().visible===!0)return;const t=this._sheetSkeletonManagerService.getCurrent();if(t==null||i==null||i.length===0||i[i.length-1]==null)return;const{primary:n}=i[i.length-1];if(n==null)return;const r=this._getSheetObject();if(r==null)return;const{unitId:o,sheetId:s}=t,{scene:a,engine:c}=r;this._commandService.executeCommand(ds.id,{scene:a,engine:c,primary:n,unitId:o,sheetId:s})}_initialEventListener(){const i=this._getSheetObject();if(i==null)return;const{spreadsheet:e,spreadsheetColumnHeader:t,spreadsheetLeftTopPlaceholder:n,spreadsheetRowHeader:r}=i;e.onDblclickObserver.add(o=>{o.button!==2&&this._commandService.executeCommand(mt.id,{visible:!0,eventType:y.DeviceInputEventType.Dblclick})}),e.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),t.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),n.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),r.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this))}_keepVisibleHideEditor(){this._editorBridgeService.isForceKeepVisible()||this._hideEditor()}_hideEditor(){this._editorBridgeService.isVisible().visible===!0&&(this._selectionManagerService.makeDirty(!1),this._commandService.executeCommand(mt.id,{visible:!1,eventType:y.DeviceInputEventType.PointerDown}),setTimeout(()=>{this._selectionManagerService.makeDirty(!0)},0))}_getSheetObject(){return qe(this._currentUniverService,this._renderManagerService)}_commandExecutedListener(){const i=p.COMMAND_LISTENER_SKELETON_CHANGE;this.disposeWithMe(this._commandService.onCommandExecuted((e,t)=>{t!=null&&t.fromCollab||(e.id===p.SetWorksheetActiveOperation.id?this._keepVisibleHideEditor():i.includes(e.id)&&this._hideEditor())}))}};ti=Pd([l.OnLifecycle(l.LifecycleStages.Rendered,ti),zt(0,j.Inject(exports.SheetSkeletonManagerService)),zt(1,l.IUniverInstanceService),zt(2,l.ICommandService),zt(3,y.IRenderManagerService),zt(4,at),zt(5,j.Inject(p.SelectionManagerService))],ti);var Hd=Object.defineProperty,Ld=Object.getOwnPropertyDescriptor,Ud=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ld(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Hd(e,t,r),r},pn=(i,e)=>(t,n)=>e(t,n,i);let ni=class extends l.Disposable{constructor(i,e,t,n,r){super(),this._commandService=i,this._formatPainterService=e,this._currentUniverService=t,this._renderManagerService=n,this._selectionRenderService=r,this._initialize()}_initialize(){this._commandExecutedListener(),this._bindFormatPainterStatus()}_bindFormatPainterStatus(){this._formatPainterService.status$.subscribe(i=>{const{scene:e}=this._getSheetObject()||{};e&&(i!==st.OFF?e.setDefaultCursor(y.CURSOR_TYPE.CELL):e.setDefaultCursor(y.CURSOR_TYPE.DEFAULT))})}_commandExecutedListener(){this.disposeWithMe(l.toDisposable(this._selectionRenderService.selectionMoveEnd$.subscribe(i=>{if(this._formatPainterService.getStatus()!==st.OFF){const{rangeWithCoord:e}=i[i.length-1];this._applyFormatPainter({startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}),this._formatPainterService.getStatus()===st.ONCE&&this._commandService.executeCommand(pr.id)}})))}async _applyFormatPainter(i){const{styles:e,merges:t}=this._formatPainterService.getSelectionFormat(),n=this._currentUniverService.getCurrentUniverSheetInstance().getUnitId(),r=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();if(!e)return;const{startRow:o,startColumn:s,endRow:a,endColumn:c}=e.getDataRange(),d=a-o+1,u=c-s+1,h=Array.from({length:i.endRow-i.startRow+1},()=>Array.from({length:i.endColumn-i.startColumn+1},()=>({}))),m=[];h.forEach((_,f)=>{_.forEach((C,I)=>{const w=f%d+o,E=I%u+s,O=e.getValue(w,E);O&&(h[f][I].s=O)})}),t.forEach(_=>{const f={startRow:_.startRow-o,startColumn:_.startColumn-s,endRow:_.endRow-o,endColumn:_.endColumn-s},C=Math.max(1,Math.floor((i.endRow-i.startRow+1)/d)),I=Math.max(1,Math.floor((i.endColumn-i.startColumn+1)/u));for(let w=0;w<C;w++)for(let E=0;E<I;E++)m.push({startRow:f.startRow+w*d+i.startRow,startColumn:f.startColumn+E*u+i.startColumn,endRow:f.endRow+w*d+i.startRow,endColumn:f.endColumn+E*u+i.startColumn})});const g={subUnitId:r,unitId:n,styleRange:i,styleValues:h,mergeRanges:m};await this._commandService.executeCommand(Qo.id,g)}_getSheetObject(){return qe(this._currentUniverService,this._renderManagerService)}};ni=Ud([l.OnLifecycle(l.LifecycleStages.Rendered,ni),pn(0,l.ICommandService),pn(1,sn),pn(2,l.IUniverInstanceService),pn(3,y.IRenderManagerService),pn(4,Ze)],ni);const ii={id:"sheet.command.set-scroll-relative",type:l.CommandType.COMMAND,handler:async(i,e={offsetX:0,offsetY:0})=>{const t=i.get(l.ICommandService),n=i.get(Nt),o=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),s=o.getActiveSheet(),{xSplit:a,ySplit:c}=s.getConfig().freeze,d=n.getCurrentScroll(),{offsetX:u=0,offsetY:h=0}=e||{},{sheetViewStartRow:m=0,sheetViewStartColumn:g=0,offsetX:_=0,offsetY:f=0}=d||{};return t.executeCommand(on.id,{unitId:o.getUnitId(),sheetId:s.getSheetId(),sheetViewStartRow:m+c,sheetViewStartColumn:g+a,offsetX:_+u,offsetY:f+h})}},Jt={id:"sheet.command.scroll-view",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const n=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),r=n.getActiveSheet(),s=i.get(Nt).getCurrentScroll();if(!r)return!1;const a=i.get(l.ICommandService),{sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:u,offsetY:h}=e,{sheetViewStartColumn:m,sheetViewStartRow:g,offsetX:_,offsetY:f}=s||{},{xSplit:C,ySplit:I}=r.getConfig().freeze;return a.executeCommand(on.id,{unitId:n.getUnitId(),sheetId:r.getSheetId(),sheetViewStartRow:c??(g??0)+I,sheetViewStartColumn:d??(m??0)+C,offsetX:u??_,offsetY:h??f})}};l.CommandType.COMMAND;var kd=Object.defineProperty,Vd=Object.getOwnPropertyDescriptor,Fd=(i,e,t,n)=>{for(var r=n>1?void 0:n?Vd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&kd(e,t,r),r},ht=(i,e)=>(t,n)=>e(t,n,i);const Bd="__SpreadsheetFreezeRowMainName__",jd="__SpreadsheetFreezeRowHeaderName__",Wd="__SpreadsheetFreezeColumnMainName__",zd="__SpreadsheetFreezeColumnHeaderName__",Fi=4,$d=.01;let ri=class extends l.Disposable{constructor(e,t,n,r,o,s,a,c,d,u){super();v(this,"_rowFreezeHeaderRect");v(this,"_rowFreezeMainRect");v(this,"_columnFreezeHeaderRect");v(this,"_columnFreezeMainRect");v(this,"_freezeDownObservers",[]);v(this,"_freezeMoveObservers",[]);v(this,"_freezeLeaveObservers",[]);v(this,"_moveObserver");v(this,"_upObserver");v(this,"_changeToRow",-1);v(this,"_changeToColumn",-1);v(this,"_changeToOffsetX",0);v(this,"_changeToOffsetY",0);v(this,"_activeViewport",null);v(this,"_freezeNormalHeaderColor","");v(this,"_freezeNormalMainColor","");v(this,"_freezeActiveColor","");v(this,"_freezeHoverColor","");v(this,"_lastFreeze");this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._commandService=n,this._renderManagerService=r,this._selectionRenderService=o,this._selectionManagerService=s,this._scrollManagerService=a,this._themeService=c,this._sheetInterceptorService=d,this._injector=u,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._themeChangeListener(),this._interceptorCommands(),this._bindViewportScroll()}_createFreeze(e=0,t){var D;const n=t??this._getFreeze();if(n==null)return;const r=(D=this._sheetSkeletonManagerService.getCurrent())==null?void 0:D.skeleton;if(r==null)return;const{startRow:o,startColumn:s}=n,a=this._getPositionByIndex(o,s);if(a==null)return;const c=this._getSheetObject();if(c==null)return;const d=c.engine,u=(d==null?void 0:d.width)||0,h=(d==null?void 0:d.height)||0,m=c.scene,{startX:g,startY:_}=a,{rowTotalHeight:f,columnTotalWidth:C,rowHeaderWidthAndMarginLeft:I,columnHeaderHeightAndMarginTop:w}=r,E=u>C+I?u:C+w,O=h>f+w?h:f+w;this._changeToRow=o,this._changeToColumn=s,this._changeToOffsetX=g,this._changeToOffsetY=_;const x=Math.max(m.scaleX,m.scaleY),N=Fi/(x<1?1:x);if(e===0){const P=N;this._rowFreezeHeaderRect=new y.Rect(jd,{fill:this._freezeNormalHeaderColor,width:I,height:N,left:0,top:_-P,zIndex:3});let L=this._freezeNormalHeaderColor;(o===-1||o===0)&&(L=this._freezeNormalMainColor),this._rowFreezeMainRect=new y.Rect(Bd,{fill:L,width:E*2,height:N,left:I,top:_-P,zIndex:3}),m.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],At)}else{const P=N;this._columnFreezeHeaderRect=new y.Rect(zd,{fill:this._freezeNormalHeaderColor,width:N,height:w,left:g-P,top:0,zIndex:3});let L=this._freezeNormalHeaderColor;(s===-1||s===0)&&(L=this._freezeNormalMainColor),this._columnFreezeMainRect=new y.Rect(Wd,{fill:L,width:N,height:O*2,left:g-P,top:w,zIndex:3}),m.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],At)}this._eventBinding(e)}_eventBinding(e=0){let t=this._rowFreezeHeaderRect,n=this._rowFreezeMainRect;e===1&&(t=this._columnFreezeHeaderRect,n=this._columnFreezeMainRect);const r=this._getSheetObject();if(r==null)return;const{scene:o}=r;this._freezeMoveObservers.push(t==null?void 0:t.onPointerEnterObserver.add(()=>{t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),o.setCursor(y.CURSOR_TYPE.GRAB)})),this._freezeMoveObservers.push(n==null?void 0:n.onPointerEnterObserver.add(()=>{t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),o.setCursor(y.CURSOR_TYPE.GRAB)})),this._freezeLeaveObservers.push(t==null?void 0:t.onPointerLeaveObserver.add(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),o.resetCursor()})),this._freezeLeaveObservers.push(n==null?void 0:n.onPointerLeaveObserver.add(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),o.resetCursor()})),this._freezeDownObservers.push(t==null?void 0:t.onPointerDownObserver.add(s=>{this._freezeDown(s,t,n,e)})),this._freezeDownObservers.push(n==null?void 0:n.onPointerDownObserver.add(s=>{this._freezeDown(s,t,n,e)}))}_getCurrentLastVisibleRow(){var h;const e=this._getSheetObject();if(e==null)return;const t=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(t==null)return;const n=e.scene,r=Math.max(n.scaleX,n.scaleY),o=this._scrollManagerService.getCurrentScroll(),s=(e.engine.height-t.columnHeaderHeight)/r,a=(o==null?void 0:o.sheetViewStartRow)??0,c=a===0?-((o==null?void 0:o.offsetY)??0):t.rowHeightAccumulation[a-1]-((o==null?void 0:o.offsetY)??0);let d=0,u=!1;for(let m=a,g=t.rowHeightAccumulation.length;m<g;m++)if(t.rowHeightAccumulation[m]-c>s){d=m,u=!0;break}return u||(d=t.rowHeightAccumulation.length-1),d}_getActiveViewport(e){var n;const t=(n=this._getSheetObject())==null?void 0:n.scene.getViewports();return t&&t.find(r=>r.isHit(new y.Vector2(e.offsetX,e.offsetY)))||null}_freezeDown(e,t,n,r=0){var h;const o=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(o==null)return;const s=this._getSheetObject();if(s==null)return;const{scene:a}=s;a.setCursor(y.CURSOR_TYPE.GRABBING),a.disableEvent();const c=this._getCurrentLastVisibleRow(),d=c===void 0?1/0:o.rowHeightAccumulation[c];this._activeViewport=null;const u=this._getFreeze();u&&(this._changeToColumn=u.startColumn,this._changeToRow=u.startRow),this._moveObserver=a.onPointerMoveObserver.add(m=>{var E,O,x,N;const g=this._getActiveViewport(m),{startX:_,startY:f,row:C,column:I}=tn(m.offsetX,m.offsetY,a,o,g||void 0);a.setCursor(y.CURSOR_TYPE.GRABBING);const w=Fi/Math.max(a.scaleX,a.scaleY);r===0?((E=t.transformByState({top:Math.min(f,d)-w/2}))==null||E.setProps({fill:this._freezeActiveColor}),(O=n.transformByState({top:Math.min(f,d)-w/2}))==null||O.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=c===void 0?C:Math.min(C,c),this._changeToOffsetY=Math.min(f,d),this._activeViewport=g):((x=t.transformByState({left:_-w/2}))==null||x.setProps({fill:this._freezeActiveColor}),(N=n.transformByState({left:_-w/2}))==null||N.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=I,this._changeToOffsetX=_,this._activeViewport=g)}),this._upObserver=a.onPointerUpObserver.add(()=>{var P,L;a.resetCursor(),a.enableEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:m,columnHeaderHeightAndMarginTop:g}=o;r===0&&(this._changeToRow===0||this._changeToRow===-1)||r===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(t.setProps({fill:this._freezeNormalHeaderColor}),n.setProps({fill:this._freezeNormalMainColor})):(t==null||t.setProps({fill:this._freezeNormalHeaderColor}),n==null||n.setProps({fill:this._freezeNormalHeaderColor}));const _=Fi/Math.max(a.scaleX,a.scaleY);r===0?(this._changeToRow===0||this._changeToRow===-1)&&(t.transformByState({top:g-_}),n.transformByState({top:g-_})):(this._changeToColumn===0||this._changeToColumn===-1)&&(t.transformByState({left:m-_}),n.transformByState({left:m-_}));const f=this._scrollManagerService.getCurrentScroll()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:C,sheetViewStartColumn:I}=f;if(I==null||C==null)return;const w=this._currentUniverService.getCurrentUniverSheetInstance(),E=w.getActiveSheet(),O=(P=E.getConfig())==null?void 0:P.freeze;let x=(O==null?void 0:O.xSplit)||0,N=(O==null?void 0:O.ySplit)||0;const D=(L=this._activeViewport)==null?void 0:L.viewPortKey;r===0&&(!D||D===Q.VIEW_LEFT_TOP||D===Q.VIEW_MAIN_LEFT_TOP||D===Q.VIEW_MAIN_TOP||D===Q.VIEW_ROW_TOP?N=this._changeToRow-(O.startRow-O.ySplit):N=this._changeToRow-C,N=N<0?0:N),r===1&&(!D||D===Q.VIEW_LEFT_TOP||D===Q.VIEW_MAIN_LEFT_TOP||D===Q.VIEW_MAIN_LEFT||D===Q.VIEW_COLUMN_LEFT?x=this._changeToColumn-(O.startColumn-O.xSplit):x=this._changeToColumn-I,x=x<0?0:x),this._commandService.executeCommand(p.SetFrozenCommand.id,{startRow:N===0?-1:this._changeToRow,startColumn:x===0?-1:this._changeToColumn,ySplit:N,xSplit:x,unitId:w.getUnitId(),subUnitId:E.getSheetId()})})}_getViewports(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e,n=t.getViewport(Q.VIEW_COLUMN_LEFT),r=t.getViewport(Q.VIEW_COLUMN_RIGHT),o=t.getViewport(Q.VIEW_ROW_TOP),s=t.getViewport(Q.VIEW_ROW_BOTTOM),a=t.getViewport(Q.VIEW_LEFT_TOP),c=t.getViewport(Q.VIEW_MAIN),d=t.getViewport(Q.VIEW_MAIN_LEFT_TOP),u=t.getViewport(Q.VIEW_MAIN_LEFT),h=t.getViewport(Q.VIEW_MAIN_TOP);if(!(n==null||r==null||o==null||s==null||a==null||c==null||d==null||u==null||h==null))return{viewMain:c,viewMainLeftTop:d,viewMainLeft:u,viewMainTop:h,viewColumnLeft:n,viewColumnRight:r,viewRowTop:o,viewRowBottom:s,viewLeftTop:a}}_bindViewportScroll(){const e=this._getViewports();if(!e)return;const{viewMain:t,viewRowBottom:n,viewColumnRight:r,viewMainLeft:o,viewMainTop:s}=e;this.disposeWithMe(t.onScrollAfterObserver.add(a=>{const{scrollX:c,scrollY:d,actualScrollX:u,actualScrollY:h}=a;n.isActive&&n.updateScroll({scrollY:d,actualScrollY:h}).makeDirty(!0),r.isActive&&r.updateScroll({scrollX:c,actualScrollX:u}).makeDirty(!0),o.isActive&&o.updateScroll({scrollY:d,actualScrollY:h}).makeDirty(!0),s.isActive&&s.updateScroll({scrollX:c,actualScrollX:u}).makeDirty(!0)}))}_updateViewport(e=-1,t=-1,n=0,r=0,o=3){var D;const s=(D=this._sheetSkeletonManagerService.getCurrent())==null?void 0:D.skeleton;if(s==null)return;const{rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:c}=s,d=this._getViewports();if(!d)return;const{viewMain:u,viewMainLeftTop:h,viewMainLeft:m,viewMainTop:g,viewColumnLeft:_,viewColumnRight:f,viewRowTop:C,viewRowBottom:I,viewLeftTop:w}=d;f.resize({left:a,top:0,height:c,right:0}),I.resize({left:0,top:c,bottom:0,width:a}),w.resize({left:0,top:0,width:a,height:c});let E=!0,O=!0;h.enable(),(e===-1||e===0)&&(E=!1),(t===-1||t===0)&&(O=!1);const x=s.getNoMergeCellPositionByIndexWithNoHeader(e-n,t-r),N=s.getNoMergeCellPositionByIndexWithNoHeader(e,t);if(h.disable(),g.disable(),m.disable(),C.disable(),_.disable(),h.resetPadding(),g.resetPadding(),m.resetPadding(),C.resetPadding(),_.resetPadding(),E===!1&&O===!1)u.resize({left:a,top:c,bottom:0,right:0}),u.resetPadding();else if(E===!0&&O===!1){const P=N.startY-x.startY;u.resize({left:a,top:c+P,bottom:0,right:0}),u.setPadding({startY:x.startY,endY:N.startY,startX:0,endX:0}),o&2&&this._commandService.executeCommand(Jt.id,{sheetViewStartRow:0,offsetY:0}),g.resize({left:a,top:c,height:P,right:0}),g.updateScroll({actualScrollY:x.startY,x:u.scrollX,actualScrollX:u.actualScrollX}).makeDirty(!0),C.resize({left:0,top:c,width:a,height:P}),C.updateScroll({actualScrollY:x.startY}).makeDirty(!0),I.resize({left:0,top:c+P,bottom:0,width:a}),g.enable(),C.enable()}else if(E===!1&&O===!0){const P=N.startX-x.startX;u.resize({left:a+P,top:c,bottom:0,right:0}),u.setPadding({startX:x.startX,endX:N.startX,startY:0,endY:0}),o&1&&this._commandService.executeCommand(Jt.id,{sheetViewStartColumn:0,offsetX:0}),m.resize({left:a,top:c,width:P,bottom:0,right:0}),m.updateScroll({actualScrollX:x.startX,y:u.scrollY,actualScrollY:u.actualScrollY}).makeDirty(!0),_.resize({left:a,top:0,width:P,height:c}),_.updateScroll({actualScrollX:x.startX}).makeDirty(!0),f.resize({left:a+P,top:0,height:c,right:0}),m.enable(),_.enable()}else{const P=N.startX-x.startX,L=N.startY-x.startY;u.resize({left:a+P,top:c+L,bottom:0,right:0}),u.setPadding({startY:x.startY,endY:N.startY,startX:x.startX,endX:N.startX}),o&&this._commandService.executeCommand(Jt.id,{...o&1?{sheetViewStartColumn:0,offsetX:0}:null,...o&2?{sheetViewStartRow:0,offsetY:0}:null}),m.resize({left:a,top:c+L,width:P,bottom:0}),m.updateScroll({actualScrollX:x.startX,y:u.scrollY,actualScrollY:u.actualScrollY}).makeDirty(!0),g.resize({left:a+P,top:c,height:L,right:0}),g.updateScroll({actualScrollY:x.startY,x:u.scrollX,actualScrollX:u.actualScrollX}).makeDirty(!0),h.resize({left:a,top:c,width:P,height:L}),h.updateScroll({actualScrollX:x.startX,actualScrollY:x.startY}).makeDirty(!0),C.resize({left:0,top:c,width:a,height:L}),C.updateScroll({actualScrollY:x.startY}).makeDirty(!0),I.resize({left:0,top:c+L,bottom:0,width:a}),_.resize({left:a,top:0,width:P,height:c}),_.updateScroll({actualScrollX:x.startX}).makeDirty(!0),f.resize({left:a+P,top:0,height:c,right:0}),h.enable(),g.enable(),m.enable(),C.enable(),_.enable()}}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{[p.SetWorksheetActiveOperation.id].includes((e==null?void 0:e.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const n=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getConfig().freeze,{startRow:r=-1,startColumn:o=-1,ySplit:s=0,xSplit:a=0}=n;this._refreshFreeze(r,o,s,a,0)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(l.toDisposable(this._themeService.currentTheme$.subscribe(e=>{this._clearFreeze(),this._themeChange(e),this._refreshCurrent()})))}_themeChange(e){this._freezeNormalHeaderColor=e.grey400,this._freezeNormalMainColor=new l.ColorKit(e.grey400).setAlpha($d).toRgbString(),this._freezeActiveColor=e.primaryColor,this._freezeHoverColor=e.grey500}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{const t={redos:[],undos:[]},n=this._getFreeze();if(!n)return t;const r=o=>{const s=this._currentUniverService.getCurrentUniverSheetInstance(),a=s.getUnitId(),d=s.getActiveSheet().getSheetId();this._refreshFreeze(o.startRow,o.startColumn,o.ySplit,o.xSplit,0);const u={...o,unitId:a,subUnitId:d,resetScroll:!1},h=p.SetFrozenMutationFactory(this._injector,u);return{undos:[{id:p.SetFrozenMutation.id,params:h}],redos:[{id:p.SetFrozenMutation.id,params:u}]}};if(e.id===p.MoveColsCommand.id){const o=this._selectionManagerService.getSelections(),{fromRange:{startColumn:s},toRange:{startColumn:a}}=e.params,c=o==null?void 0:o.filter(C=>C.range.rangeType===l.RANGE_TYPE.COLUMN&&C.range.startColumn<=s&&s<=C.range.endColumn);if(!(c!=null&&c.length))return t;const d=c[0].range,u={...d,startColumn:a,endColumn:a+d.endColumn-d.startColumn};if(!n||n.startColumn<=0||d.startColumn>=n.startColumn&&u.startColumn>=n.startColumn||d.startColumn===u.startColumn||d.endColumn<n.startColumn&&u.startColumn<n.startColumn)return t;const h=d.endColumn-d.startColumn+1,m=Math.max(Math.min(n.startColumn,d.endColumn+1)-d.startColumn,0);let g,_;u.startColumn>=n.startColumn?(g=Math.max(n.startColumn-m,1),_=Math.max(n.xSplit-m,1)):(g=n.startColumn+h-m,_=n.xSplit+h-m);const f={...n,startColumn:g,xSplit:_};return r(f)}if(e.id===p.MoveRowsCommand.id){const o=this._selectionManagerService.getSelections(),{fromRange:{startRow:s},toRange:{startRow:a}}=e.params,c=o==null?void 0:o.filter(C=>C.range.rangeType===l.RANGE_TYPE.ROW&&C.range.startRow<=s&&s<=C.range.endRow);if(!(c!=null&&c.length))return t;const d=c[0].range,u={...d,startRow:a,endRow:a+d.endRow-d.startRow};if(!n||n.startRow<=0||d.startRow>=n.startRow&&u.startRow>=n.startRow||d.startRow===u.startRow||d.endRow<n.startRow&&u.startRow<n.startRow)return t;const h=d.endRow-d.startRow+1,m=Math.max(Math.min(n.startRow,d.endRow+1)-d.startRow,0);let g,_;u.startRow>=n.startRow?(g=Math.max(n.startRow-m,1),_=Math.max(n.ySplit-m,1)):(g=n.startRow+h-m,_=n.ySplit+h-m);const f={...n,startRow:g,ySplit:_};return r(f)}if(e.id===p.RemoveColCommand.id||e.id===p.RemoveRowCommand.id){const o=e.params,s=o.range;if(s.rangeType===l.RANGE_TYPE.COLUMN&&s.startColumn<n.startColumn){const a=Math.min(n.startColumn,s.endColumn+1)-s.startColumn,c={...n,startColumn:Math.max(1,n.startColumn-a),xSplit:Math.max(1,n.xSplit-a)};return r(c)}if(o.range.rangeType===l.RANGE_TYPE.ROW&&s.startRow<n.startRow){const a=Math.min(n.startRow,s.endRow+1)-s.startRow,c={...n,startRow:Math.max(1,n.startRow-a),ySplit:Math.max(1,n.ySplit-a)};return r(c)}}return t}}))}_commandExecutedListener(){const e=[p.SetFrozenMutation.id,bt.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=this._lastFreeze,r=this._currentUniverService.getCurrentUniverSheetInstance(),o=r.getActiveSheet(),s=t.params,{unitId:a,subUnitId:c}=s;if(!(a===r.getUnitId()&&c===o.getSheetId()))return;const d=o.getConfig().freeze;if(this._lastFreeze=d,d==null)return;let u=0;const{startRow:h=-1,startColumn:m=-1,ySplit:g=0,xSplit:_=0}=d;(!n||n.startRow!==h||n.ySplit!==g)&&(u|=2),(!n||n.startColumn!==m||n.xSplit!==_)&&(u|=1),s.resetScroll===!1&&(u=0),this._refreshFreeze(h,m,g,_,u)}else if(t.id===p.DeltaRowHeightCommand.id){const n=this._getFreeze();t.params&&n&&t.params.anchorRow<n.startRow&&this._refreshCurrent()}else if(t.id===p.DeltaColumnWidthCommand.id){const n=this._getFreeze();t.params&&n&&t.params.anchorCol<n.startColumn&&this._refreshCurrent()}else if(t.id===p.SetWorksheetRowAutoHeightMutation.id){const n=t.params,r=this._getFreeze();if(r&&r.startRow>-1&&n.rowsAutoHeightInfo.some(o=>o.row<r.startRow)){const o=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{o.unsubscribe()})})}}else if(t.id===p.SetColHiddenMutation.id||t.id===p.SetColVisibleMutation.id){const n=t.params,r=this._getFreeze(),o=n.ranges;r&&r.startColumn>-1&&o.some(s=>s.startColumn<r.startColumn)&&this._refreshCurrent()}else if(t.id===p.SetRowHiddenMutation.id||t.id===p.SetRowVisibleMutation.id){const n=t.params,r=this._getFreeze(),o=n.ranges;r&&r.startRow>-1&&o.some(s=>s.startRow<r.startRow)&&this._refreshCurrent()}}))}_clearObserverEvent(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_clearFreeze(){var n,r,o,s;(n=this._rowFreezeHeaderRect)==null||n.dispose(),(r=this._rowFreezeMainRect)==null||r.dispose(),(o=this._columnFreezeHeaderRect)==null||o.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose();const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;[...this._freezeDownObservers,...this._freezeMoveObservers,...this._freezeLeaveObservers].forEach(a=>{t.onPointerDownObserver.remove(a),t.onPointerMoveObserver.remove(a),t.onPointerLeaveObserver.remove(a)}),t.onPointerEnterObserver.remove(this._moveObserver),t.onPointerMoveObserver.remove(this._upObserver)}_getPositionByIndex(e,t){var c;if(this._getSheetObject()==null)return;const r=(c=this._sheetSkeletonManagerService.getCurrent())==null?void 0:c.skeleton,o=r==null?void 0:r.getNoMergeCellPositionByIndex(e,t);if(r==null)return;if(o!=null&&(!isNaN(o.endX)||!isNaN(o.endY)))return o;const{rowHeaderWidthAndMarginLeft:s,columnHeaderHeightAndMarginTop:a}=r;return{startX:s,endX:s,startY:a,endY:a}}_getFreeze(){var t;const e=(t=this._sheetSkeletonManagerService.getCurrent())==null?void 0:t.skeleton.getWorksheetConfig();if(e!=null)return e.freeze}_getSheetObject(){return qe(this._currentUniverService,this._renderManagerService)}_refreshFreeze(e,t,n,r,o){var a;const s={startRow:e,startColumn:t,ySplit:n,xSplit:r};this._clearFreeze(),this._createFreeze(0,s),this._createFreeze(1,s),this._updateViewport(e,t,n,r,o),(a=this._getSheetObject())==null||a.spreadsheet.makeForceDirty()}};ri=Fd([l.OnLifecycle(l.LifecycleStages.Rendered,ri),ht(0,j.Inject(exports.SheetSkeletonManagerService)),ht(1,l.IUniverInstanceService),ht(2,l.ICommandService),ht(3,y.IRenderManagerService),ht(4,Ze),ht(5,j.Inject(p.SelectionManagerService)),ht(6,j.Inject(Nt)),ht(7,j.Inject(l.ThemeService)),ht(8,j.Inject(p.SheetInterceptorService)),ht(9,j.Inject(j.Injector))],ri);var nr=(i=>(i[i.NORMAL=0]="NORMAL",i[i.HIGHLIGHT=1]="HIGHLIGHT",i))(nr||{});const Yd="rgba(0, 0, 0, 0.15)",Rt="rgb(0, 0, 0)",Bn="rgb(255, 255, 255, 1)";class Xd extends y.Shape{constructor(t,n){super(t,n);v(this,"_size",12);v(this,"_iconRatio",.4);v(this,"_mode",0);this.setShapeProps(n)}setShapeProps(t){t!=null&&t.size&&(this._size=t.size),t!=null&&t.mode&&(this._mode=t.mode),this.transformByState({width:this._size,height:this._size})}_draw(t){this._mode===1&&y.Rect.drawWith(t,{width:this._size,height:this._size,radius:this._size,fill:Yd});const n=this._size*.5*this._iconRatio,r=Math.PI/180*60,o=n*Math.sin(r),s=n*Math.cos(r);y.RegularPolygon.drawWith(t,{pointsGroup:[[{x:-o+this._size/2,y:-s+this._size/2},{x:o+this._size/2,y:-s+this._size/2},{x:this._size/2,y:n+this._size/2}]],fill:Rt})}}var Zd=Object.defineProperty,Gd=Object.getOwnPropertyDescriptor,Kd=(i,e,t,n)=>{for(var r=n>1?void 0:n?Gd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Zd(e,t,r),r},fn=(i,e)=>(t,n)=>e(t,n,i);const qd="__SpreadsheetHeaderMenuSHAPEControllerShape__",Jd="__SpreadsheetHeaderMenuMAINControllerShape__",Qd="rgba(0, 0, 0, 0.1)";let oi=class extends l.Disposable{constructor(e,t,n,r,o){super();v(this,"_hoverRect");v(this,"_hoverMenu");v(this,"_currentColumn",1/0);v(this,"_observers",[]);this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._contextMenuService=r,this._selectionManagerService=o,this._initialize()}dispose(){var r,o;(r=this._hoverRect)==null||r.dispose(),(o=this._hoverMenu)==null||o.dispose();const e=this._getSheetObject();if(e==null)return;const{spreadsheetRowHeader:t,spreadsheetColumnHeader:n}=e;this._observers.forEach(s=>{t.onPointerEnterObserver.remove(s),t.onPointerMoveObserver.remove(s),t.onPointerLeaveObserver.remove(s),n.onPointerEnterObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)})}_initialize(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this._hoverRect=new y.Rect(qd,{fill:Qd,evented:!1}),this._hoverMenu=new Xd(Jd,{zIndex:100,visible:!1}),t.addObjects([this._hoverRect,this._hoverMenu],At),this._initialHover(0),this._initialHover(1),this._initialHoverMenu()}_initialHover(e=0){const t=this._getSheetObject();if(t==null)return;const{spreadsheetColumnHeader:n,spreadsheetRowHeader:r}=t,o=e===0?r:n;this._observers.push(o==null?void 0:o.onPointerEnterObserver.add(()=>{var s;(s=this._hoverRect)==null||s.show()})),this._observers.push(o==null?void 0:o.onPointerMoveObserver.add(s=>{var C,I,w;const a=(C=this._sheetSkeletonManagerService.getCurrent())==null?void 0:C.skeleton;if(a==null)return;const c=this._getSheetObject();if(c==null)return;const{rowHeaderWidth:d,columnHeaderHeight:u}=a,{startX:h,startY:m,endX:g,endY:_,column:f}=tn(s.offsetX,s.offsetY,c.scene,a);if(e===0)(I=this._hoverRect)==null||I.transformByState({width:d,height:_-m,left:0,top:m});else{if(this._currentColumn=f,(w=this._hoverRect)==null||w.transformByState({width:g-h,height:u,left:h,top:0}),this._hoverMenu==null)return;if(g-h<u*2){this._hoverMenu.hide();return}const E=u*.8;this._hoverMenu.transformByState({left:g-u,top:u/2-E/2}),this._hoverMenu.setShapeProps({size:E}),this._hoverMenu.show()}})),this._observers.push(o==null?void 0:o.onPointerLeaveObserver.add(()=>{var s,a;(s=this._hoverRect)==null||s.hide(),(a=this._hoverMenu)==null||a.hide()}))}_initialHoverMenu(){this._hoverMenu!=null&&(this._hoverMenu.onPointerEnterObserver.add(()=>{if(this._hoverMenu==null)return;const e=this._getSheetObject();e!=null&&(this._hoverMenu.setProps({mode:nr.HIGHLIGHT,visible:!0}),e.scene.setCursor(y.CURSOR_TYPE.POINTER))}),this._hoverMenu.onPointerLeaveObserver.add(()=>{if(this._hoverMenu==null)return;const e=this._getSheetObject();e!=null&&(this._hoverMenu.setProps({mode:nr.NORMAL,visible:!1}),e.scene.resetCursor())}),this._hoverMenu.onPointerDownObserver.add(e=>{const t=this._getSheetObject();if(!t)return;const n=this._currentColumn,r=this._selectionManagerService.getSelectionRanges();!!(r!=null&&r.filter(s=>s.rangeType===l.RANGE_TYPE.COLUMN).find(s=>{const{startColumn:a,endColumn:c}=s;return n>=a&&n<=c}))||t.spreadsheetColumnHeader.onPointerDownObserver.notifyObservers(e),e.stopPropagation(),e.preventDefault(),this._contextMenuService.triggerContextMenu(e,Be.COL_HEADER_CONTEXT_MENU)}))}_getSheetObject(){return qe(this._currentUniverService,this._renderManagerService)}};oi=Kd([l.OnLifecycle(l.LifecycleStages.Rendered,oi),fn(0,j.Inject(exports.SheetSkeletonManagerService)),fn(1,l.IUniverInstanceService),fn(2,y.IRenderManagerService),fn(3,R.IContextMenuService),fn(4,j.Inject(p.SelectionManagerService))],oi);var eu=Object.defineProperty,tu=Object.getOwnPropertyDescriptor,nu=(i,e,t,n)=>{for(var r=n>1?void 0:n?tu(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&eu(e,t,r),r},$t=(i,e)=>(t,n)=>e(t,n,i);const iu="__SpreadsheetHeaderMoveControllerBackground__",ru="__SpreadsheetHeaderMoveControllerShapeLine__",ou="rgba(0, 0, 0, 0.1)",su="rgb(119, 119, 119)",au=4;let si=class extends l.Disposable{constructor(e,t,n,r,o,s){super();v(this,"_startOffsetX",-1/0);v(this,"_startOffsetY",-1/0);v(this,"_moveHelperBackgroundShape");v(this,"_moveHelperLineShape");v(this,"_sheetObject");v(this,"_rowOrColumnDownObservers",[]);v(this,"_rowOrColumnMoveObservers",[]);v(this,"_rowOrColumnLeaveObservers",[]);v(this,"_moveObserver");v(this,"_upObserver");v(this,"_scrollTimer");v(this,"_changeFromColumn",-1);v(this,"_changeFromRow",-1);v(this,"_changeToColumn",-1);v(this,"_changeToRow",-1);this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._commandService=r,this._selectionRenderService=o,this._selectionManagerService=s,this._initialize()}dispose(){var o,s;(o=this._moveHelperBackgroundShape)==null||o.dispose(),(s=this._moveHelperLineShape)==null||s.dispose();const e=this._getSheetObject();if(e==null)return;const{spreadsheetRowHeader:t,spreadsheetColumnHeader:n,scene:r}=e;[...this._rowOrColumnDownObservers,...this._rowOrColumnMoveObservers,...this._rowOrColumnLeaveObservers].forEach(a=>{t.onPointerDownObserver.remove(a),n.onPointerDownObserver.remove(a)}),r.onPointerMoveObserver.remove(this._moveObserver),r.onPointerUpObserver.remove(this._upObserver),this._scrollTimer.dispose()}_initialize(){const e=this._getSheetObject();e!=null&&(this._sheetObject=e,this._initialRowOrColumn(0),this._initialRowOrColumn(1))}_initialRowOrColumn(e=0){const{spreadsheetColumnHeader:t,spreadsheetRowHeader:n,scene:r}=this._sheetObject,o=e===0?n:t;this._rowOrColumnMoveObservers.push(o==null?void 0:o.onPointerMoveObserver.add(s=>{var h;const a=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(a==null)return;const{row:c,column:d}=tn(s.offsetX,s.offsetY,r,a);if(this._checkInHeaderRange(e===0?c:d,e)===!1){r.resetCursor(),this._selectionRenderService.enableSelection();return}r.setCursor(y.CURSOR_TYPE.GRAB),this._selectionRenderService.disableSelection()})),this._rowOrColumnLeaveObservers.push(o==null?void 0:o.onPointerLeaveObserver.add(()=>{var s,a;(s=this._moveHelperBackgroundShape)==null||s.hide(),(a=this._moveHelperLineShape)==null||a.hide(),r.resetCursor(),this._selectionRenderService.enableSelection()})),this._rowOrColumnDownObservers.push(o==null?void 0:o.onPointerDownObserver.add(s=>{var x;const a=(x=this._sheetSkeletonManagerService.getCurrent())==null?void 0:x.skeleton;if(a==null)return;const{offsetX:c,offsetY:d}=s,u=r.getRelativeCoord(y.Vector2.FromArray([c,d])),{x:h,y:m}=u;this._startOffsetX=h,this._startOffsetY=m;const{row:g,column:_}=tn(s.offsetX,s.offsetY,r,a);let f;e===0?(this._changeFromRow=g,f=y.ScrollTimerType.Y):(this._changeFromColumn=_,f=y.ScrollTimerType.X);const C=this._checkInHeaderRange(e===0?g:_,e);if(C===!1)return;const I=r.getScrollXYByRelativeCoords(y.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),r.setCursor(y.CURSOR_TYPE.GRABBING),r.disableEvent();let w=!1,E;const O=()=>{if(w)return;E=y.ScrollTimer.create(r,f);const N=r.getViewport(Q.VIEW_MAIN);E.startScroll(h,m,N),this._scrollTimer=E,w=!0};this._moveObserver=r.onPointerMoveObserver.add(N=>{O();const{offsetX:D,offsetY:P}=N,{x:L,y:G}=r.getRelativeCoord(y.Vector2.FromArray([D,P]));r.setCursor(y.CURSOR_TYPE.GRABBING),this._rowColumnMoving(L,G,C,I,e),E.scrolling(L,G,()=>{this._rowColumnMoving(L,G,C,I,e)})}),this._upObserver=r.onPointerUpObserver.add(()=>{var D,P,L;this._disposeBackgroundAndLine(),r.resetCursor(),r.enableEvent(),this._clearObserverEvent(),(D=this._scrollTimer)==null||D.dispose();const N=this._selectionManagerService.getSelections();if(e===0){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const k=(P=((N==null?void 0:N.filter(ee=>ee.range.rangeType===l.RANGE_TYPE.ROW&&ee.range.startRow<=this._changeFromRow&&this._changeFromRow<=ee.range.endRow))||[])[0])==null?void 0:P.range;k&&this._commandService.executeCommand(p.MoveRowsCommand.id,{fromRange:k,toRange:{...k,startRow:this._changeToRow,endRow:this._changeToRow+k.endRow-k.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const k=(L=((N==null?void 0:N.filter(ee=>ee.range.rangeType===l.RANGE_TYPE.COLUMN&&ee.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=ee.range.endColumn))||[])[0])==null?void 0:L.range;k&&this._commandService.executeCommand(p.MoveColsCommand.id,{fromRange:k,toRange:{...k,startColumn:this._changeToColumn,endColumn:this._changeToColumn+k.endColumn-k.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})}))}_rowColumnMoving(e,t,n,r,o){var ae,Ie,de,Ee,be,De,Oe;const{scene:s}=this._sheetObject,a=(ae=this._sheetSkeletonManagerService.getCurrent())==null?void 0:ae.skeleton;if(a==null)return;const{rowHeaderWidth:c,columnHeaderHeight:d,rowTotalHeight:u,columnTotalWidth:h}=a,m=s.getScrollXY(s.getViewport(Q.VIEW_MAIN)),{scaleX:g,scaleY:_}=s.getAncestorScale(),f=a.getCellPositionByOffset(e,t,g,_,m),{row:C,column:I}=f,w=a.getNoMergeCellPositionByIndex(C,I),{startX:E,startY:O,endX:x,endY:N}=w,D=this._selectionRenderService.convertRangeDataToSelection(n.range);if(D==null)return;const P=Math.max(g,g),{startX:L,endX:G,startY:k,endY:ee,startRow:te,startColumn:W,endRow:V,endColumn:re}=D;o===0?(Ie=this._moveHelperBackgroundShape)==null||Ie.transformByState({height:ee-k,width:h+c,left:0,top:k+(t-this._startOffsetY)/P+m.y-r.y}):(de=this._moveHelperBackgroundShape)==null||de.transformByState({height:u+d,width:G-L,left:L+(e-this._startOffsetX)/P+m.x-r.x,top:0}),(Ee=this._moveHelperBackgroundShape)==null||Ee.show();const q=au/P;if(o===0){let Le=0;if(C<=te)Le=O-q/2,this._changeToRow=C;else if(C>V)Le=N-q/2,this._changeToRow=C+1;else return;(be=this._moveHelperLineShape)==null||be.transformByState({height:q,width:h,left:c,top:Le})}else{let Le=0;if(I<=W)Le=E-q/2,this._changeToColumn=I;else if(I>re)Le=x-q/2,this._changeToColumn=I+1;else return;(De=this._moveHelperLineShape)==null||De.transformByState({height:u,width:q,left:Le,top:d})}(Oe=this._moveHelperLineShape)==null||Oe.show()}_checkInHeaderRange(e,t=0){var a;const n=this._selectionManagerService.getSelections();if(((a=this._selectionManagerService.getCurrent())==null?void 0:a.pluginName)!==p.NORMAL_SELECTION_PLUGIN_NAME)return!1;const o=n==null?void 0:n.find(c=>{const d=c.range,{startRow:u,endRow:h,startColumn:m,endColumn:g}=d;return t===1?e>=m&&e<=g:e>=u&&e<=h}),s=o==null?void 0:o.range;return o==null||s==null||s.rangeType===l.RANGE_TYPE.ALL||s.rangeType===l.RANGE_TYPE.NORMAL||s.rangeType===l.RANGE_TYPE.ROW&&t!==0||s.rangeType===l.RANGE_TYPE.COLUMN&&t!==1?!1:o}_clearObserverEvent(){const{scene:e}=this._sheetObject;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_newBackgroundAndLine(){const{scene:e}=this._sheetObject;this._moveHelperBackgroundShape=new y.Rect(iu,{fill:ou,evented:!1,zIndex:100}),this._moveHelperLineShape=new y.Rect(ru,{fill:su,evented:!1,zIndex:100}),e.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],At)}_disposeBackgroundAndLine(){var e,t;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose()}_getSheetObject(){return qe(this._currentUniverService,this._renderManagerService)}};si=nu([l.OnLifecycle(l.LifecycleStages.Rendered,si),$t(0,j.Inject(exports.SheetSkeletonManagerService)),$t(1,l.IUniverInstanceService),$t(2,y.IRenderManagerService),$t(3,l.ICommandService),$t(4,Ze),$t(5,j.Inject(p.SelectionManagerService))],si);var ir=(i=>(i[i.VERTICAL=0]="VERTICAL",i[i.HORIZONTAL=1]="HORIZONTAL",i))(ir||{});const lu="rgba(120, 120, 120, 0.01)",Bi="rgb(68, 71, 70)",Cn=12,rr=4;class Jr extends y.Shape{constructor(t,n){super(t,n);v(this,"_size",Cn);v(this,"_color",Bi);v(this,"_mode",0);this.setShapeProps(n)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(t){let{width:n,height:r}=this,o=0,s=0;const a=this.getScene(),{scaleX:c,scaleY:d}=a.getAncestorScale(),u=Math.max(c,d),h=Cn/u,m=rr/u;this.mode===0?(n=m,o=h-m):(r=m,s=h-m),y.Rect.drawWith(t,{width:this.width,height:this.height,left:0,top:0,fill:lu}),y.Rect.drawWith(t,{width:n,height:r,fill:Bi,radius:m}),t.save(),t.transform(1,0,0,1,o,s),y.Rect.drawWith(t,{width:n,height:r,fill:Bi,radius:m}),t.restore()}setShapeProps(t){return t!=null&&t.size&&(this._size=t.size),t!=null&&t.mode&&(this._mode=t.mode),t!=null&&t.color&&(this._color=t.color),this.mode===0?this.transformByState({width:Cn,height:this.size}):this.transformByState({width:this.size,height:Cn}),this}}var cu=Object.defineProperty,du=Object.getOwnPropertyDescriptor,uu=(i,e,t,n)=>{for(var r=n>1?void 0:n?du(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&cu(e,t,r),r},Sn=(i,e)=>(t,n)=>e(t,n,i);const hu="__SpreadsheetHeaderResizeControllerShapeRow__",mu="__SpreadsheetHeaderResizeControllerShapeColumn__",Qr="__SpreadsheetHeaderResizeControllerShapeHelper__",eo="rgb(199, 199, 199)",gu=2;let ai=class extends l.Disposable{constructor(e,t,n,r,o){super();v(this,"_currentRow",0);v(this,"_currentColumn",0);v(this,"_rowResizeRect");v(this,"_columnResizeRect");v(this,"_observers",[]);v(this,"_moveObserver");v(this,"_upObserver");v(this,"_resizeHelperShape");v(this,"_startOffsetX",1/0);v(this,"_startOffsetY",1/0);this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._commandService=n,this._renderManagerService=r,this._editorBridgeService=o,this._initialize()}dispose(){var r,o;(r=this._rowResizeRect)==null||r.dispose(),this._rowResizeRect=null,(o=this._columnResizeRect)==null||o.dispose(),this._columnResizeRect=null;const e=this._getSheetObject();if(e==null)throw new Error("sheetObject is null");const{spreadsheetRowHeader:t,spreadsheetColumnHeader:n}=e;this._observers.forEach(s=>{t.onPointerMoveObserver.remove(s),t.onPointerLeaveObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)}),this._observers=[]}_initialize(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this._rowResizeRect=new Jr(hu,{visible:!1,mode:ir.HORIZONTAL,zIndex:100}),this._columnResizeRect=new Jr(mu,{visible:!1,mode:ir.VERTICAL,zIndex:100}),t.addObjects([this._rowResizeRect,this._columnResizeRect],At),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(e=0){const t=this._getSheetObject();if(t==null)return;const{spreadsheetRowHeader:n,spreadsheetColumnHeader:r,scene:o}=t,s=e===0?n:r;this._observers.push(s==null?void 0:s.onPointerMoveObserver.add((a,c)=>{var D;const d=(D=this._sheetSkeletonManagerService.getCurrent())==null?void 0:D.skeleton;if(d==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:u,columnHeaderHeight:h}=d,{startX:m,startY:g,endX:_,endY:f,row:C,column:I}=tn(a.offsetX,a.offsetY,o,d),w=$n(a.offsetX,a.offsetY,o),{scaleX:E,scaleY:O}=o.getAncestorScale(),x=Math.max(E,O),N=Cn/x;if(e===0){let P=g-N/2;if(w.y<=g+N/2&&w.y>=g)this._currentRow=C-1;else if(w.y>=f-N/2&&w.y<=f)this._currentRow=C,P=f-N/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;const L=u/3;this._rowResizeRect.transformByState({left:u/2-L/2,top:P}),this._rowResizeRect.setShapeProps({size:L}),this._rowResizeRect.show()}else{let P=m-N/2;if(w.x<=m+N/2&&w.x>=m)this._currentColumn=I-1;else if(w.x>=_-N/2&&w.x<=_)this._currentColumn=I,P=_-N/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;const L=h*.7;this._columnResizeRect.transformByState({left:P,top:h/2-L/2}),this._columnResizeRect.setShapeProps({size:L}),this._columnResizeRect.show()}})),this._observers.push(s==null?void 0:s.onPointerLeaveObserver.add((a,c)=>{var d,u;(d=this._rowResizeRect)==null||d.hide(),(u=this._columnResizeRect)==null||u.hide()}))}_initialHoverResize(e=0){const t=this._getSheetObject();if(t==null)return;const{scene:n}=t,r=e===0?this._rowResizeRect:this._columnResizeRect;if(r==null)return;const o=n.getEngine(),s=(o==null?void 0:o.width)||0,a=(o==null?void 0:o.height)||0;this.disposeWithMe(l.toDisposable(r.onPointerEnterObserver.add(()=>{r!=null&&(r.show(),n.setCursor(e===0?y.CURSOR_TYPE.ROW_RESIZE:y.CURSOR_TYPE.COLUMN_RESIZE))}))),this.disposeWithMe(l.toDisposable(r.onPointerLeaveObserver.add(()=>{r!=null&&(r.hide(),n.resetCursor())}))),this.disposeWithMe(l.toDisposable(r.onPointerDownObserver.add((c,d)=>{var Ie,de,Ee,be,De,Oe,Le;const u=(Ie=this._sheetSkeletonManagerService.getCurrent())==null?void 0:Ie.skeleton;if(u==null)return;const h=this._getSheetObject();if(h==null)return;const{scene:m}=h,g=m.getViewport(Q.VIEW_MAIN),_=(((Ee=(de=g==null?void 0:g.getScrollBar())==null?void 0:de.horizonBarRect)==null?void 0:Ee.height)||0)+10,f=(((De=(be=g==null?void 0:g.getScrollBar())==null?void 0:be.verticalBarRect)==null?void 0:De.width)||0)+10,C=$n(c.offsetX,c.offsetY,m),{scaleX:I,scaleY:w}=m.getAncestorScale();this._startOffsetX=C.x,this._startOffsetY=C.y;const E=u.getOffsetByPositionX(this._currentColumn),O=u.getOffsetByPositionY(this._currentRow),x=u.getNoMergeCellPositionByIndex(this._currentRow,this._currentColumn);let N=!1,D=0,P=0;const{columnTotalWidth:L,rowHeaderWidth:G,rowTotalHeight:k,columnHeaderHeight:ee}=u,te=s>L+G?s:L+G,W=a>k+ee?a:k+ee,V=Math.max(I,w),re=rr/V;e===0?this._resizeHelperShape=new y.Rect(Qr,{width:te,height:re,fill:eo,left:0,top:O-re/2}):this._resizeHelperShape=new y.Rect(Qr,{width:re,height:W,fill:eo,left:E-re/2,top:0});const q=((Oe=this._columnResizeRect)==null?void 0:Oe.left)||0,ae=((Le=this._rowResizeRect)==null?void 0:Le.top)||0;m.addObject(this._resizeHelperShape,At),m.disableEvent(),this._editorBridgeService.changeVisible({visible:!1,eventType:y.DeviceInputEventType.PointerDown}),this._moveObserver=m.onPointerMoveObserver.add(Se=>{var pt,ft,$e,Ve,He,Qe;const he=m.getRelativeCoord(y.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),ge=m.getScrollXYByRelativeCoords(he,g),Ae=$n(Se.offsetX,Se.offsetY,m),{x:we,y:Pe}=Ae,{scaleX:Ue,scaleY:Ne}=m.getAncestorScale(),it=Math.max(Ue,Ne),Fe=rr/it;D=we-this._startOffsetX-Fe/2,P=Pe-this._startOffsetY-Fe/2,Math.abs(e===0?P:D)>=gu&&(N=!0),e===0?(P>a-_+ge.y-x.startY&&(P=a-_+ge.y-x.startY),P<-(x.endY-x.startY)+2&&(P=-(x.endY-x.startY)+2),N&&((pt=this._resizeHelperShape)==null||pt.transformByState({top:O+P}),(ft=this._rowResizeRect)==null||ft.transformByState({top:ae+P+Fe/2}),($e=this._rowResizeRect)==null||$e.show(),m.setCursor(y.CURSOR_TYPE.ROW_RESIZE))):(D>s-f+ge.x-x.startX&&(D=s-f+ge.x-x.startX),D<-(x.endX-x.startX)+2&&(D=-(x.endX-x.startX)+2),N&&((Ve=this._resizeHelperShape)==null||Ve.transformByState({left:E+D}),(He=this._columnResizeRect)==null||He.transformByState({left:q+D+Fe/2}),(Qe=this._columnResizeRect)==null||Qe.show(),m.setCursor(y.CURSOR_TYPE.COLUMN_RESIZE)))}),this._upObserver=m.onPointerUpObserver.add(Se=>{var Ae,we,Pe;const he=qe(this._currentUniverService,this._renderManagerService);if(he==null)return;this._clearObserverEvent(),(Ae=this._resizeHelperShape)==null||Ae.dispose(),this._resizeHelperShape=null;const{scene:ge}=he;ge.enableEvent(),N&&(ge.resetCursor(),(we=this._rowResizeRect)==null||we.hide(),(Pe=this._columnResizeRect)==null||Pe.hide(),e===0?this._commandService.executeCommand(p.DeltaRowHeightCommand.id,{deltaY:P,anchorRow:this._currentRow}):this._commandService.executeCommand(p.DeltaColumnWidthCommand.id,{deltaX:D,anchorCol:this._currentColumn}))})}))),this.disposeWithMe(l.toDisposable(r.onDblclickObserver.add(()=>{var c;if(e===0){const d=this._getSheetObject();if(d==null)return;const{scene:u}=d;u.resetCursor(),this._commandService.executeCommand(p.SetWorksheetRowIsAutoHeightCommand.id,{anchorRow:this._currentRow}),(c=this._rowResizeRect)==null||c.hide()}})))}_clearObserverEvent(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_getSheetObject(){return qe(this._currentUniverService,this._renderManagerService)}};ai=uu([l.OnLifecycle(l.LifecycleStages.Rendered,ai),Sn(0,j.Inject(exports.SheetSkeletonManagerService)),Sn(1,l.IUniverInstanceService),Sn(2,l.ICommandService),Sn(3,y.IRenderManagerService),Sn(4,at)],ai);var or=(i=>(i[i.ROW=0]="ROW",i[i.COLUMN=1]="COLUMN",i))(or||{});const Rn=12,_u=.4;class to extends y.Shape{constructor(t,n,r){super(t,n);v(this,"_size",Rn);v(this,"_iconRatio",_u);v(this,"_hovered",!0);v(this,"_hasPrevious",!0);v(this,"_hasNext",!0);v(this,"_unhideType");n&&this.setShapeProps(n),this.onPointerEnterObserver.add(()=>this.setShapeProps({hovered:!0})),this.onPointerLeaveObserver.add(()=>this.setShapeProps({hovered:!1})),this.onPointerDownObserver.add(()=>r==null?void 0:r())}setShapeProps(t){t.type!==void 0&&(this._unhideType=t.type),t.hovered!==void 0&&(this._hovered=t.hovered),t.hasPrevious!==void 0&&(this._hasPrevious=t.hasPrevious),t.hasNext!==void 0&&(this._hasNext=t.hasNext),this.transformByState({width:this._size*(this._unhideType===1?2:1),height:this._size*(this._unhideType===0?2:1)})}_draw(t){this._unhideType===0?this._drawOnRow(t):this._drawOnCol(t)}_drawOnRow(t){this._hovered&&(!this._hasNext||!this._hasPrevious?y.Rect.drawWith(t,{width:this._size,height:this._size,stroke:Rt,fill:Bn}):y.Rect.drawWith(t,{width:this._size,height:2*this._size,stroke:Rt,fill:Bn}));const n=this._size*.5*this._iconRatio,r=Math.PI/3,o=n*Math.cos(r),s=n*Math.sin(r);if(this._hasPrevious&&y.RegularPolygon.drawWith(t,{pointsGroup:[[{x:this._size/2,y:this._size/2-s},{x:this._size/2-s,y:this._size/2+o},{x:this._size/2+s,y:this._size/2+o}]],fill:Rt}),this._hasNext){const a=this._hasPrevious?3:1;y.RegularPolygon.drawWith(t,{pointsGroup:[[{x:this._size/2,y:this._size*a/2+s},{x:this._size/2-s,y:this._size*a/2-o},{x:this._size/2+s,y:this._size*a/2-o}]],fill:Rt})}}_drawOnCol(t){this._hovered&&(!this._hasNext||!this._hasPrevious?y.Rect.drawWith(t,{width:this._size,height:this._size,stroke:Rt,fill:Bn}):y.Rect.drawWith(t,{width:2*this._size,height:this._size,stroke:Rt,fill:Bn}));const n=this._size*.5*this._iconRatio,r=Math.PI/3,o=n*Math.cos(r),s=n*Math.sin(r);if(this._hasPrevious&&y.RegularPolygon.drawWith(t,{pointsGroup:[[{x:-o+this._size/2,y:this._size/2},{x:this._size/2+s,y:this._size/2-s},{x:this._size/2+s,y:this._size/2+s}]],fill:Rt}),this._hasNext){const a=this._hasPrevious?3:1;y.RegularPolygon.drawWith(t,{pointsGroup:[[{x:o+this._size*a/2,y:this._size/2},{x:-s+this._size*a/2,y:this._size/2-s},{x:-s+this._size*a/2,y:this._size/2+s}]],fill:Rt})}}}var pu=Object.defineProperty,fu=Object.getOwnPropertyDescriptor,Su=(i,e,t,n)=>{for(var r=n>1?void 0:n?fu(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&pu(e,t,r),r},jn=(i,e)=>(t,n)=>e(t,n,i);const no="__SpreadsheetHeaderUnhideSHAPEControllerShape__",vu=[p.SetRowHiddenMutation.id,p.SetRowVisibleMutation.id,p.SetColHiddenMutation.id,p.SetColVisibleMutation.id];let li=class extends l.RxDisposable{constructor(e,t,n,r){super();v(this,"_shapes",new Map);this._sheetSkeletonManagerService=e,this._cmdSrv=t,this._univerInstanceService=n,this._rendererManagerService=r,this._init()}dispose(){super.dispose()}_init(){if(!this._getSheetObject())return;const t=this._univerInstanceService.getCurrentUniverSheetInstance(),n=t.getActiveSheet();n&&this._initForWorksheet(t,n),this._sheetSkeletonManagerService.currentSkeleton$.pipe(J.takeUntil(this.dispose$)).subscribe(r=>{if(r){const o=this._univerInstanceService.getUniverSheetInstance(r.unitId),s=o.getSheetBySheetId(r.sheetId);this._updateWorksheet(o,s)}}),this.disposeWithMe(this._cmdSrv.onCommandExecuted(r=>{if(!vu.includes(r.id)||!r.params||!r.params.unitId||!r.params.subUnitId)return;const o=this._univerInstanceService.getUniverSheetInstance(r.params.unitId),s=o==null?void 0:o.getSheetBySheetId(r.params.subUnitId);s&&this._updateWorksheet(o,s)}))}_initForWorksheet(e,t){var m;const n=(m=this._sheetSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(!n)return;const r=t.getHiddenRows(),o=t.getHiddenCols(),s=this._getSheetObject();if(!s)return;const{scene:a}=s,c=t.getRowCount(),d=r.map(g=>{const{startRow:_,endRow:f}=g,C=tr(_,0,a,n),I=_!==0,w=f!==c-1;return new to(no,{type:or.ROW,hovered:!1,hasPrevious:I,hasNext:w,top:C.startY-(I?Rn:0),left:C.startX-Rn},()=>this._cmdSrv.executeCommand(p.SetSpecificRowsVisibleCommand.id,{unitId:e.getUnitId(),subUnitId:t.getSheetId(),ranges:[g]}))}),u=t.getColumnCount(),h=o.map(g=>{const{startColumn:_,endColumn:f}=g,C=tr(0,_,a,n),I=_!==0,w=f!==u-1;return new to(no,{type:or.COLUMN,hovered:!1,hasPrevious:I,hasNext:w,left:C.startX-(I?Rn:0),top:20-Rn},()=>this._cmdSrv.executeCommand(p.SetSpecificColsVisibleCommand.id,{unitId:e.getUnitId(),subUnitId:t.getSheetId(),ranges:[g]}))});a.addObjects(h,Nr),a.addObjects(d,Nr),this._shapes.set(l.getWorksheetUID(e,t),{cols:h,rows:d})}_updateWorksheet(e,t){const n=this._shapes.get(l.getWorksheetUID(e,t));n==null||n.cols.forEach(r=>r.dispose()),n==null||n.rows.forEach(r=>r.dispose()),this._initForWorksheet(e,t)}_getSheetObject(){return qe(this._univerInstanceService,this._rendererManagerService)}};li=Su([l.OnLifecycle(l.LifecycleStages.Rendered,li),jn(0,j.Inject(exports.SheetSkeletonManagerService)),jn(1,l.ICommandService),jn(2,l.IUniverInstanceService),jn(3,y.IRenderManagerService)],li);var Cu=Object.defineProperty,Ru=Object.getOwnPropertyDescriptor,Iu=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ru(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Cu(e,t,r),r},ji=(i,e)=>(t,n)=>e(t,n,i);let ci=class extends l.Disposable{constructor(i,e,t){super(),this._markSelectionService=i,this._commandService=e,this._sheetSkeletonManagerService=t,this._initListeners()}_initListeners(){this._addRemoveListener(),this._addRefreshListener()}_addRemoveListener(){const i=[mt.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{i.includes(e.id)?this._markSelectionService.removeAllShapes():this._markSelectionService.getShapeMap().forEach((n,r)=>{n.exits.includes(e.id)&&this._markSelectionService.removeShape(r)})}))}_addRefreshListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{i&&this._markSelectionService.refreshShapes()})))}};ci=Iu([l.OnLifecycle(l.LifecycleStages.Steady,ci),ji(0,j.Inject(On)),ji(1,l.ICommandService),ji(2,j.Inject(exports.SheetSkeletonManagerService))],ci);var bu=Object.defineProperty,Mu=Object.getOwnPropertyDescriptor,wu=(i,e,t,n)=>{for(var r=n>1?void 0:n?Mu(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&bu(e,t,r),r},Wi=(i,e)=>(t,n)=>e(t,n,i);let di=class extends l.Disposable{constructor(e,t,n){super();v(this,"_initialize",()=>{const e=new l.DisposableCollection;this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(()=>{e.dispose();const t=this._selectionManagerService.getCurrent();if((t==null?void 0:t.pluginName)!==p.NORMAL_SELECTION_PLUGIN_NAME)return;this._selectionRenderService.getCurrentControls().forEach(r=>{e.add(l.toDisposable(r.selectionMoved$.subscribe(o=>{if(!o)return;const s=r.model.getRange(),a={startRow:s.startRow,startColumn:s.startColumn,endRow:s.endRow,endColumn:s.endColumn,rangeType:s.rangeType},c={startRow:o.startRow,startColumn:o.startColumn,endRow:o.endRow,endColumn:o.endColumn,rangeType:s.rangeType};if(a.startRow===c.startRow&&a.startColumn===c.startColumn||c.startRow<0||c.startColumn<0)return;const d={fromRange:a,toRange:c};this._commandService.executeCommand(p.MoveRangeCommand.id,d)})))})})))});this._selectionRenderService=e,this._selectionManagerService=t,this._commandService=n,this._initialize()}};di=wu([l.OnLifecycle(l.LifecycleStages.Steady,di),Wi(0,j.Inject(Ze)),Wi(1,j.Inject(p.SelectionManagerService)),Wi(2,j.Inject(l.ICommandService))],di);var Tu=Object.defineProperty,yu=Object.getOwnPropertyDescriptor,Eu=(i,e,t,n)=>{for(var r=n>1?void 0:n?yu(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Tu(e,t,r),r},Yt=(i,e)=>(t,n)=>e(t,n,i);let Qt=class extends l.Disposable{constructor(i,e,t,n,r,o){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._selectionManagerService=r,this._scrollManagerService=o,this._initialize()}scrollToVisible(i=!0){var W,V,re;let e,t;const n=this._selectionManagerService.getLast();if(n==null)return;const{startRow:r,startColumn:o,actualRow:s,actualColumn:a}=n.primary,c=i?s:r,d=i?a:o,{rowHeightAccumulation:u,columnWidthAccumulation:h}=((W=this._sheetSkeletonManagerService.getCurrent())==null?void 0:W.skeleton)??{};if(u==null||h==null)return;const m=(V=this._getSheetObject())==null?void 0:V.scene;if(m==null)return;const g=m.getViewport(Q.VIEW_MAIN);if(g==null||this._getSheetObject()==null)return;const f=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet(),{startColumn:C,startRow:I,ySplit:w,xSplit:E}=f.getFreeze(),O=g.getBounding(),x=(re=this._sheetSkeletonManagerService.getCurrent())==null?void 0:re.skeleton;if(x==null)return;const{startRow:N,startColumn:D,endRow:P,endColumn:L}=x.getRowColumnSegment(O);if(c>=I&&d>=C-E&&(c<=N&&(e=c),c>=P)){const q=u[c]-g.height;for(let ae=N;ae<=c;ae++)if(u[ae]>=q){e=ae+1;break}}if(d>=C&&c>=I-w&&(d<=D&&(t=d),d>=L)){const q=h[d]-g.width;for(let ae=D;ae<=d;ae++)if(h[ae]>=q){t=ae+1;break}}if(e===void 0&&t===void 0)return;const{sheetViewStartColumn:G,sheetViewStartRow:k,offsetX:ee,offsetY:te}=this._scrollManagerService.getCurrentScroll()||{};this._commandService.executeCommand(Jt.id,{sheetViewStartRow:e??k,sheetViewStartColumn:t??G,offsetX:t===void 0?ee:0,offsetY:e===void 0?te:0})}dispose(){super.dispose()}_initialize(){this._scrollEventBinding(),this._scrollSubscribeBinding(),this._skeletonListener()}_getFreeze(){var e;const i=(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig();if(i!=null)return i.freeze}_scrollEventBinding(){var t;const i=(t=this._getSheetObject())==null?void 0:t.scene;if(i==null)return;const e=i.getViewport(Q.VIEW_MAIN);this.disposeWithMe(l.toDisposable(e==null?void 0:e.onScrollAfterObserver.add(n=>{var m;const r=(m=this._sheetSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(r==null||n.isTrigger===!1)return;const o=this._getSheetObject();if(r==null||o==null)return;const{actualScrollX:s=0,actualScrollY:a=0}=n,{row:c,column:d,rowOffset:u,columnOffset:h}=r.getDecomposedOffset(s,a);this._scrollManagerService.addOrReplaceNoRefresh({sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:h,offsetY:u})}))),this.disposeWithMe(l.toDisposable(e==null?void 0:e.onScrollByBarObserver.add(n=>{var g;const r=(g=this._sheetSkeletonManagerService.getCurrent())==null?void 0:g.skeleton;if(r==null||n.isTrigger===!1)return;const o=this._getSheetObject();if(r==null||o==null)return;const{actualScrollX:s=0,actualScrollY:a=0}=n,c=this._getFreeze(),{row:d,column:u,rowOffset:h,columnOffset:m}=r.getDecomposedOffset(s,a);this._commandService.executeCommand(Jt.id,{sheetViewStartRow:d+((c==null?void 0:c.ySplit)||0),sheetViewStartColumn:u+((c==null?void 0:c.xSplit)||0),offsetX:m,offsetY:h})})))}_scrollSubscribeBinding(){this.disposeWithMe(l.toDisposable(this._scrollManagerService.scrollInfo$.subscribe(i=>{var _;const e=(_=this._sheetSkeletonManagerService.getCurrent())==null?void 0:_.skeleton,t=this._getSheetObject();if(e==null||t==null)return;const n=t.scene;t.scene.getAncestorScale();const r=n.getViewport(Q.VIEW_MAIN);if(r==null)return;if(i==null){r.scrollTo({x:0,y:0});return}const{sheetViewStartRow:o,sheetViewStartColumn:s,offsetX:a,offsetY:c}=i,{startX:d,startY:u}=e.getCellByIndexWithNoHeader(o,s),h=d+a,m=u+c,g=r.getBarScroll(h,m);r.scrollTo(g)})))}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{unitId:e,sheetId:t}=i;this._renderManagerService.getRenderById(e)!=null&&(this._updateSceneSize(i),this._scrollManagerService.setCurrentScroll({unitId:e,sheetId:t}))})))}_updateSceneSize(i){var c;if(i==null)return;const{skeleton:e,unitId:t}=i,n=(c=this._renderManagerService.getRenderById(t))==null?void 0:c.scene;if(e==null||n==null)return;const{rowTotalHeight:r,columnTotalWidth:o,rowHeaderWidthAndMarginLeft:s,columnHeaderHeightAndMarginTop:a}=e;n==null||n.transformByState({width:s+o,height:a+r})}_getSheetObject(){return qe(this._currentUniverService,this._renderManagerService)}};Qt=Eu([l.OnLifecycle(l.LifecycleStages.Rendered,Qt),Yt(0,j.Inject(exports.SheetSkeletonManagerService)),Yt(1,l.IUniverInstanceService),Yt(2,l.ICommandService),Yt(3,y.IRenderManagerService),Yt(4,j.Inject(p.SelectionManagerService)),Yt(5,j.Inject(Nt))],Qt);var Ou=Object.defineProperty,xu=Object.getOwnPropertyDescriptor,Au=(i,e,t,n)=>{for(var r=n>1?void 0:n?xu(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ou(e,t,r),r},io=(i,e)=>(t,n)=>e(t,n,i);const Nu=[nt.id,jt.id];let ui=class extends l.Disposable{constructor(i,e){super(),this._commandService=i,this._scrollController=e,this.disposeWithMe(this._commandService.onCommandExecuted(t=>{Nu.includes(t.id)&&this._scrollController.scrollToVisible()}))}};ui=Au([l.OnLifecycle(l.LifecycleStages.Rendered,ui),io(0,l.ICommandService),io(1,j.Inject(Qt))],ui);var Du=Object.defineProperty,Pu=Object.getOwnPropertyDescriptor,Hu=(i,e,t,n)=>{for(var r=n>1?void 0:n?Pu(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Du(e,t,r),r},Et=(i,e)=>(t,n)=>e(t,n,i);let hi=class extends l.Disposable{constructor(i,e,t,n,r,o,s,a){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._selectionRenderService=r,this._selectionManagerService=o,this._themeService=s,this._scrollController=a,this._initialize()}_initialize(){const i=this._currentUniverService.getCurrentUniverSheetInstance(),e=i.getActiveSheet(),t=this._getSheetObject();if(t==null)return;this._initViewMainListener(t),this._initRowHeader(t),this._initColumnHeader(t),this._initLeftTop(t),this._initSelectionChangeListener(),this._initThemeChangeListener(),this._initSkeletonChangeListener(),this._initCommandListener(),this._initUserActionSyncListener();const n=i.getUnitId(),r=e.getSheetId();this._selectionManagerService.setCurrentSelection({pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,unitId:n,sheetId:r})}_getActiveViewport(i){const e=this._getSheetObject();return e==null?void 0:e.scene.getActiveViewportByCoord(y.Vector2.FromArray([i.offsetX,i.offsetY]))}_initViewMainListener(i){const{spreadsheet:e}=i;this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((t,n)=>{this._selectionRenderService.enableDetectMergedCell(),this._selectionRenderService.eventTrigger(t,e.zIndex+1,l.RANGE_TYPE.NORMAL,this._getActiveViewport(t)),t.button!==2&&n.stopPropagation()})))}_initThemeChangeListener(){this.disposeWithMe(l.toDisposable(this._themeService.currentTheme$.subscribe(()=>{this._selectionRenderService.resetStyle();const i=this._selectionManagerService.getSelections(),e=this._selectionManagerService.getCurrent();i==null||(e==null?void 0:e.pluginName)!==p.NORMAL_SELECTION_PLUGIN_NAME||this._refreshSelection(i)})))}_refreshSelection(i){const e=i.map(t=>{const n=this._selectionRenderService.convertSelectionRangeToData(t);return n.style=p.getNormalSelectionStyle(this._themeService),n});this._selectionRenderService.updateControlForCurrentByRangeData(e)}_initRowHeader(i){const{spreadsheetRowHeader:e,spreadsheet:t}=i;this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((n,r)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(n,((t==null?void 0:t.zIndex)||1)+1,l.RANGE_TYPE.ROW,this._getActiveViewport(n),y.ScrollTimerType.Y),n.button!==2&&r.stopPropagation()})))}_initColumnHeader(i){const{spreadsheetColumnHeader:e,spreadsheet:t}=i;this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((n,r)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(n,((t==null?void 0:t.zIndex)||1)+1,l.RANGE_TYPE.COLUMN,this._getActiveViewport(n),y.ScrollTimerType.X),n.button!==2&&r.stopPropagation()})))}_initLeftTop(i){const{spreadsheetLeftTopPlaceholder:e}=i;this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((t,n)=>{var a;const r=(a=this._sheetSkeletonManagerService.getCurrent())==null?void 0:a.skeleton;if(r==null)return;this._selectionRenderService.reset();const o=this._getAllRange(r),s=this._selectionRenderService.convertSelectionRangeToData(o);this._selectionRenderService.addControlToCurrentByRangeData(s),this._selectionRenderService.refreshSelectionMoveStart(),t.button!==2&&n.stopPropagation()})))}_initSelectionChangeListener(){this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(i=>{if(this._selectionRenderService.reset(),i!=null)for(const e of i){if(e==null)continue;const t=this._selectionRenderService.convertSelectionRangeToData(e);this._selectionRenderService.addControlToCurrentByRangeData(t)}})))}_initUserActionSyncListener(){this._selectionRenderService.selectionMoveStart$.subscribe(i=>{this._move(i,p.SelectionMoveType.MOVE_START)}),this._selectionRenderService.selectionMoving$.subscribe(i=>{this._move(i,p.SelectionMoveType.MOVING)}),this._selectionRenderService.selectionMoveEnd$.subscribe(i=>{this._move(i,p.SelectionMoveType.MOVE_END),this._scrollController.scrollToVisible(!1)})}_move(i,e){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getUnitId(),r=t.getActiveSheet().getSheetId(),o=this._selectionManagerService.getCurrent();i==null||i.length===0||this._commandService.executeCommand(p.SetSelectionsOperation.id,{unitId:n,subUnitId:r,type:e,pluginName:(o==null?void 0:o.pluginName)||p.NORMAL_SELECTION_PLUGIN_NAME,selections:i.map(s=>p.convertSelectionDataToRange(s))})}_getSheetObject(){return qe(this._currentUniverService,this._renderManagerService)}_initCommandListener(){const i=[bt.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet(),r=e.params,{unitId:o,subUnitId:s}=r;if(!(o===t.getUnitId()&&s===n.getSheetId()))return;this._selectionManagerService.refreshSelection()}}))}_initSkeletonChangeListener(){this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{unitId:e,sheetId:t,skeleton:n}=i,r=this._renderManagerService.getRenderById(e);if(r==null)return;const{scene:o}=r,s=o.getViewport(Q.VIEW_MAIN);this._selectionRenderService.changeRuntime(n,o,s);const a=this._selectionManagerService.getCurrent(),c=(a==null?void 0:a.pluginName)||p.NORMAL_SELECTION_PLUGIN_NAME;if((a==null?void 0:a.unitId)===e&&a.sheetId===t){const d=this._selectionManagerService.getSelections();d!=null&&this._refreshSelection(d)}else this._selectionManagerService.setCurrentSelection({pluginName:c,unitId:e,sheetId:t});c===p.NORMAL_SELECTION_PLUGIN_NAME&&this._selectionManagerService.getLast()==null&&this._selectionManagerService.add([this._getZeroRange(n)])})}_getAllRange(i){return{range:{startRow:0,startColumn:0,endRow:i.getRowCount()-1,endColumn:i.getColumnCount()-1,rangeType:l.RANGE_TYPE.ALL},primary:this._getZeroRange(i).primary,style:null}}_getZeroRange(i){const e=i.mergeData;return p.transformCellDataToSelectionData(0,0,e)||{range:{startRow:0,startColumn:0,endRow:0,endColumn:0},primary:{actualRow:0,actualColumn:0,startRow:0,startColumn:0,endRow:0,endColumn:0,isMerged:!1,isMergedMainCell:!1},style:null}}};hi=Hu([l.OnLifecycle(l.LifecycleStages.Rendered,hi),Et(0,j.Inject(exports.SheetSkeletonManagerService)),Et(1,l.IUniverInstanceService),Et(2,l.ICommandService),Et(3,y.IRenderManagerService),Et(4,Ze),Et(5,j.Inject(p.SelectionManagerService)),Et(6,j.Inject(l.ThemeService)),Et(7,j.Inject(Qt))],hi);var Lu=Object.defineProperty,Uu=Object.getOwnPropertyDescriptor,ku=(i,e,t,n)=>{for(var r=n>1?void 0:n?Uu(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Lu(e,t,r),r},Xt=(i,e)=>(t,n)=>e(t,n,i);let mi=class extends l.Disposable{constructor(i,e,t,n,r,o){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._renderManagerService=t,this._commandService=n,this._selectionRenderService=r,this._selectionManagerService=o,this._initialize(),this._commandExecutedListener()}dispose(){super.dispose()}_initialize(){this._initialRenderRefresh()}_initialRenderRefresh(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{skeleton:e,unitId:t,sheetId:n}=i,r=this._currentUniverService.getUniverSheetInstance(t),o=r==null?void 0:r.getSheetBySheetId(n);if(r==null||o==null)return;const s=this._renderManagerService.getRenderById(t);if(s==null)return;const{mainComponent:a,components:c,scene:d}=s,u=a,h=c.get(Xe.ROW),m=c.get(Xe.COLUMN),g=c.get(Xe.LEFT_TOP),{rowHeaderWidth:_,columnHeaderHeight:f}=e;u==null||u.updateSkeleton(e),h==null||h.updateSkeleton(e),m==null||m.updateSkeleton(e),g==null||g.transformByState({width:_,height:f})})))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted((i,e)=>{var r,o;const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getUnitId();if(p.COMMAND_LISTENER_SKELETON_CHANGE.includes(i.id)){const s=t.getActiveSheet(),a=s.getSheetId(),c=i.params,{unitId:d,subUnitId:u}=c;if(!(d===t.getUnitId()&&u===s.getSheetId()))return;i.id!==p.SetWorksheetActiveOperation.id&&this._sheetSkeletonManagerService.makeDirty({unitId:d,sheetId:a,commandId:i.id},!0),this._sheetSkeletonManagerService.setCurrent({unitId:d,sheetId:a,commandId:i.id})}else p.COMMAND_LISTENER_VALUE_CHANGE.includes(i.id)&&this._sheetSkeletonManagerService.reCalculate();i.type===l.CommandType.MUTATION&&((o=(r=this._renderManagerService.getRenderById(n))==null?void 0:r.mainComponent)==null||o.makeDirty())}))}};mi=ku([l.OnLifecycle(l.LifecycleStages.Ready,mi),Xt(0,j.Inject(exports.SheetSkeletonManagerService)),Xt(1,l.IUniverInstanceService),Xt(2,y.IRenderManagerService),Xt(3,l.ICommandService),Xt(4,Ze),Xt(5,j.Inject(p.SelectionManagerService))],mi);const Mt={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(i,e)=>{const t=i.get(l.ICommandService),n=i.get(l.IUndoRedoService),r=i.get(l.IUniverInstanceService),o=i.get(R.IConfirmService),s=i.get(l.LocaleService),a=e.unitId,c=e.subUnitId,d=e.selections,u=p.getAddMergeMutationRangeByType(d,e.value),h=r.getUniverSheetInstance(a).getSheetBySheetId(c),m=[],g=[],_=Ko(h,u);if(_&&!await o.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:"merge.confirm.title"},cancelText:s.t("merge.confirm.cancel"),confirmText:s.t("merge.confirm.confirm")}))return!1;const f={unitId:a,subUnitId:c,ranges:u},C={unitId:a,subUnitId:c,ranges:u};m.push({id:p.RemoveWorksheetMergeMutation.id,params:f}),m.push({id:p.AddWorksheetMergeMutation.id,params:C});const I=p.RemoveMergeUndoMutationFactory(i,f),w=p.AddMergeUndoMutationFactory(i,C);if(g.push({id:p.RemoveWorksheetMergeMutation.id,params:w}),g.push({id:p.AddWorksheetMergeMutation.id,params:I}),_){const O=qo(i,a,h,u);m.unshift(...O.redos),g.push(...O.undos)}return l.sequenceExecute(m,t).result?(n.pushUndoRedo({unitID:a,undoMutations:g,redoMutations:m}),!0):!1}},us={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async i=>{const e=i.get(l.ICommandService),n=i.get(p.SelectionManagerService).getSelectionRanges();if(!(n!=null&&n.length))return!1;const o=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!o)return!1;const s=o.getActiveSheet();if(!s)return!1;const a=o.getUnitId(),c=s.getSheetId();return e.executeCommand(Mt.id,{selections:n,unitId:a,subUnitId:c})}},hs={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async i=>{const e=i.get(l.ICommandService),n=i.get(p.SelectionManagerService).getSelectionRanges();if(!(n!=null&&n.length))return!1;const o=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!o)return!1;const s=o.getActiveSheet();if(!s)return!1;const a=o.getUnitId(),c=s.getSheetId();return e.executeCommand(Mt.id,{value:l.Dimension.COLUMNS,selections:n,unitId:a,subUnitId:c})}},ms={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async i=>{const e=i.get(l.ICommandService),n=i.get(p.SelectionManagerService).getSelectionRanges();if(!(n!=null&&n.length))return!1;const o=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!o)return!1;const s=o.getActiveSheet();if(!s)return!1;const a=o.getUnitId(),c=s.getSheetId();return e.executeCommand(Mt.id,{value:l.Dimension.ROWS,selections:n,unitId:a,subUnitId:c})}},gs={id:"sheet.command.refill",type:l.CommandType.COMMAND,handler:async(i,e)=>{const t=i.get(xn);return t.applyType=e.type,!0}},_s={id:"sheet.command.remove-sheet-confirm",type:l.CommandType.COMMAND,handler:async(i,e)=>{const{subUnitId:t}=e,n=i.get(R.IConfirmService),r=i.get(l.ICommandService),o=i.get(l.LocaleService);return await n.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:o.t("sheetConfig.deleteSheet")},children:{title:o.t("sheetConfig.deleteSheetContent")},cancelText:o.t("button.cancel"),confirmText:o.t("button.confirm")})?(await r.executeCommand(p.RemoveSheetCommand.id,{subUnitId:t}),!0):!1}},Ai={id:"sheet.command.change-zoom-ratio",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const{delta:t,reset:n}=e,r=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),o=r.getActiveSheet(),s=r.getUnitId(),a=o.getSheetId();let c=n?100:Math.round((o.getConfig().zoomRatio+t)*100);c=Math.max(Gi[0],c),c=Math.min(Gi[1],c);const d=c/100;return i.get(l.ICommandService).executeCommand(bt.id,{unitId:s,subUnitId:a,zoomRatio:d})}},vr={id:"sheet.command.set-zoom-ratio",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const{unitId:t,subUnitId:n,zoomRatio:r}=e;return i.get(l.ICommandService).executeCommand(bt.id,{unitId:t,subUnitId:n,zoomRatio:r})}},cn=j.createIdentifier("univer.sheetbar-service");class Vu extends l.Disposable{constructor(){super();v(this,"renameId$");v(this,"removeId$");v(this,"scroll$");v(this,"scrollX$");v(this,"addSheet$");v(this,"_renameId$");v(this,"_removeId$");v(this,"_scroll$");v(this,"_scrollX$");v(this,"_addSheet$");v(this,"_currentHandler",null);this._renameId$=new J.Subject,this.renameId$=this._renameId$.asObservable(),this._removeId$=new J.Subject,this.removeId$=this._removeId$.asObservable(),this._scroll$=new J.Subject,this.scroll$=this._scroll$.asObservable(),this._scrollX$=new J.Subject,this.scrollX$=this._scrollX$.asObservable(),this._addSheet$=new J.Subject,this.addSheet$=this._addSheet$.asObservable()}setRenameId(t){this._renameId$.next(t)}setRemoveId(t){this._removeId$.next(t)}setScroll(t){this._scroll$.next(t)}setScrollX(t){this._scrollX$.next(t)}setAddSheet(t){this._addSheet$.next(t)}triggerSheetBarMenu(){var t;(t=this._currentHandler)==null||t.handleSheetBarMenu()}registerSheetBarMenuHandler(t){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=t,l.toDisposable(()=>{this._currentHandler=null})}}const ps={id:"ui-sheet.command.show-menu-list",type:l.CommandType.OPERATION,handler:async i=>(i.get(cn).triggerSheetBarMenu(),!0)},fs={id:"sheet.operation.rename-sheet",type:l.CommandType.OPERATION,handler:async(i,e)=>{const t=i.get(cn);return e&&t.setRenameId(e.subUnitId),!0}},Fu=()=>S.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[S.jsx("path",{d:"M0.98999 1.08218H-0.0100098V0.0821838H0.98999V1.08218Z",fill:"black"}),S.jsx("path",{d:"M5.78992 1.08218H2.78992V0.0821838H5.78992V1.08218Z",fill:"black"}),S.jsx("path",{d:"M7.58984 1.08218H8.58984V0.0821838H7.58984V1.08218Z",fill:"black"}),S.jsx("path",{d:"M14.9152 1.08218H13.9152V0.0821838H14.9152V1.08218Z",fill:"black"}),S.jsx("path",{d:"M16.7151 1.08218H19.7151V0.0821838H16.7151V1.08218Z",fill:"black"}),S.jsx("path",{d:"M22.515 1.08218H21.515V0.0821838H22.515V1.08218Z",fill:"black"}),S.jsx("path",{d:"M27.8405 1.08218H28.8405V0.0821838H27.8405V1.08218Z",fill:"black"}),S.jsx("path",{d:"M33.6404 1.08218H30.6404V0.0821838H33.6404V1.08218Z",fill:"black"}),S.jsx("path",{d:"M35.4403 1.08218H36.4403V0.0821838H35.4403V1.08218Z",fill:"black"}),S.jsx("path",{d:"M42.7657 1.08218H41.7657V0.0821838H42.7657V1.08218Z",fill:"black"}),S.jsx("path",{d:"M44.5657 1.08218H47.5657V0.0821838H44.5657V1.08218Z",fill:"black"}),S.jsx("path",{d:"M50.3656 1.08218H49.3656V0.0821838H50.3656V1.08218Z",fill:"black"}),S.jsx("path",{d:"M55.691 1.08218H56.691V0.0821838H55.691V1.08218Z",fill:"black"}),S.jsx("path",{d:"M61.491 1.08218H58.491V0.0821838H61.491V1.08218Z",fill:"black"}),S.jsx("path",{d:"M63.2909 1.08218H64.2909V0.0821838H63.2909V1.08218Z",fill:"black"}),S.jsx("path",{d:"M70.6163 1.08218H69.6163V0.0821838H70.6163V1.08218Z",fill:"black"}),S.jsx("path",{d:"M72.4163 1.08218H75.4163V0.0821838H72.4163V1.08218Z",fill:"black"}),S.jsx("path",{d:"M78.2162 1.08218H77.2162V0.0821838H78.2162V1.08218Z",fill:"black"}),S.jsx("path",{d:"M83.5416 1.08218H84.5416V0.0821838H83.5416V1.08218Z",fill:"black"}),S.jsx("path",{d:"M89.3416 1.08218H86.3416V0.0821838H89.3416V1.08218Z",fill:"black"}),S.jsx("path",{d:"M91.1415 1.08218H92.1415V0.0821838H91.1415V1.08218Z",fill:"black"}),S.jsx("path",{d:"M98.4669 1.08218H97.4669V0.0821838H98.4669V1.08218Z",fill:"black"}),S.jsx("path",{d:"M100.267 1.08218H103.267V0.0821838H100.267V1.08218Z",fill:"black"}),S.jsx("path",{d:"M106.067 1.08218H105.067V0.0821838H106.067V1.08218Z",fill:"black"}),S.jsx("path",{d:"M111.392 1.08218H112.392V0.0821838H111.392V1.08218Z",fill:"black"}),S.jsx("path",{d:"M117.192 1.08218H114.192V0.0821838H117.192V1.08218Z",fill:"black"}),S.jsx("path",{d:"M118.992 1.08218H119.992V0.0821838H118.992V1.08218Z",fill:"black"})]}),Bu=()=>S.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[S.jsx("path",{d:"M-0.0100098 1.15771H0.98999V0.157715H-0.0100098V1.15771Z",fill:"black"}),S.jsx("path",{d:"M2.78992 1.15771H5.78992V0.157715H2.78992V1.15771Z",fill:"black"}),S.jsx("path",{d:"M8.58984 1.15771H7.58984V0.157715H8.58984V1.15771Z",fill:"black"}),S.jsx("path",{d:"M10.3899 1.15771H11.3899V0.157715H10.3899V1.15771Z",fill:"black"}),S.jsx("path",{d:"M19.0903 1.15771H18.0903V0.157715H19.0903V1.15771Z",fill:"black"}),S.jsx("path",{d:"M20.8903 1.15771H23.8903V0.157715H20.8903V1.15771Z",fill:"black"}),S.jsx("path",{d:"M26.6902 1.15771H25.6902V0.157715H26.6902V1.15771Z",fill:"black"}),S.jsx("path",{d:"M28.4902 1.15771H29.4902V0.157715H28.4902V1.15771Z",fill:"black"}),S.jsx("path",{d:"M37.1907 1.15771H36.1907V0.157715H37.1907V1.15771Z",fill:"black"}),S.jsx("path",{d:"M38.9906 1.15771H41.9906V0.157715H38.9906V1.15771Z",fill:"black"}),S.jsx("path",{d:"M44.7905 1.15771H43.7905V0.157715H44.7905V1.15771Z",fill:"black"}),S.jsx("path",{d:"M46.5906 1.15771H47.5906V0.157715H46.5906V1.15771Z",fill:"black"}),S.jsx("path",{d:"M55.291 1.15771H54.291V0.157715H55.291V1.15771Z",fill:"black"}),S.jsx("path",{d:"M57.0909 1.15771H60.0909V0.157715H57.0909V1.15771Z",fill:"black"}),S.jsx("path",{d:"M62.8909 1.15771H61.8909V0.157715H62.8909V1.15771Z",fill:"black"}),S.jsx("path",{d:"M64.6909 1.15771H65.6909V0.157715H64.6909V1.15771Z",fill:"black"}),S.jsx("path",{d:"M73.3914 1.15771H72.3914V0.157715H73.3914V1.15771Z",fill:"black"}),S.jsx("path",{d:"M75.1913 1.15771H78.1913V0.157715H75.1913V1.15771Z",fill:"black"}),S.jsx("path",{d:"M80.9912 1.15771H79.9912V0.157715H80.9912V1.15771Z",fill:"black"}),S.jsx("path",{d:"M82.7913 1.15771H83.7913V0.157715H82.7913V1.15771Z",fill:"black"}),S.jsx("path",{d:"M91.4917 1.15771H90.4917V0.157715H91.4917V1.15771Z",fill:"black"}),S.jsx("path",{d:"M93.2916 1.15771H96.2916V0.157715H93.2916V1.15771Z",fill:"black"}),S.jsx("path",{d:"M99.0916 1.15771H98.0916V0.157715H99.0916V1.15771Z",fill:"black"}),S.jsx("path",{d:"M100.892 1.15771H101.892V0.157715H100.892V1.15771Z",fill:"black"}),S.jsx("path",{d:"M109.592 1.15771H108.592V0.157715H109.592V1.15771Z",fill:"black"}),S.jsx("path",{d:"M111.392 1.15771H114.392V0.157715H111.392V1.15771Z",fill:"black"}),S.jsx("path",{d:"M117.192 1.15771H116.192V0.157715H117.192V1.15771Z",fill:"black"}),S.jsx("path",{d:"M118.992 1.15771H119.992V0.157715H118.992V1.15771Z",fill:"black"})]}),ju=()=>S.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[S.jsx("path",{d:"M-0.00842285 1.22449H2.99158V0.224487H-0.00842285V1.22449Z",fill:"black"}),S.jsx("path",{d:"M6.14941 1.22449H9.14941V0.224487H6.14941V1.22449Z",fill:"black"}),S.jsx("path",{d:"M15.3073 1.22449H12.3073V0.224487H15.3073V1.22449Z",fill:"black"}),S.jsx("path",{d:"M18.4651 1.22449H21.4651V0.224487H18.4651V1.22449Z",fill:"black"}),S.jsx("path",{d:"M27.6229 1.22449H24.6229V0.224487H27.6229V1.22449Z",fill:"black"}),S.jsx("path",{d:"M30.7808 1.22449H33.7808V0.224487H30.7808V1.22449Z",fill:"black"}),S.jsx("path",{d:"M39.9386 1.22449H36.9386V0.224487H39.9386V1.22449Z",fill:"black"}),S.jsx("path",{d:"M43.0964 1.22449H46.0964V0.224487H43.0964V1.22449Z",fill:"black"}),S.jsx("path",{d:"M52.2543 1.22449H49.2543V0.224487H52.2543V1.22449Z",fill:"black"}),S.jsx("path",{d:"M55.4121 1.22449H58.4121V0.224487H55.4121V1.22449Z",fill:"black"}),S.jsx("path",{d:"M64.5699 1.22449H61.5699V0.224487H64.5699V1.22449Z",fill:"black"}),S.jsx("path",{d:"M67.7278 1.22449H70.7278V0.224487H67.7278V1.22449Z",fill:"black"}),S.jsx("path",{d:"M76.8856 1.22449H73.8856V0.224487H76.8856V1.22449Z",fill:"black"}),S.jsx("path",{d:"M80.0435 1.22449H83.0435V0.224487H80.0435V1.22449Z",fill:"black"}),S.jsx("path",{d:"M89.2013 1.22449H86.2013V0.224487H89.2013V1.22449Z",fill:"black"}),S.jsx("path",{d:"M92.3591 1.22449H95.3591V0.224487H92.3591V1.22449Z",fill:"black"}),S.jsx("path",{d:"M101.517 1.22449H98.517V0.224487H101.517V1.22449Z",fill:"black"}),S.jsx("path",{d:"M104.675 1.22449H107.675V0.224487H104.675V1.22449Z",fill:"black"}),S.jsx("path",{d:"M113.833 1.22449H110.833V0.224487H113.833V1.22449Z",fill:"black"}),S.jsx("path",{d:"M116.99 1.22449H119.99V0.224487H116.99V1.22449Z",fill:"black"})]}),Wu=()=>S.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[S.jsx("path",{d:"M-0.00976562 1.65707H0.990234V0.657074H-0.00976562V1.65707Z",fill:"black"}),S.jsx("path",{d:"M2.32361 1.65707H3.32361V0.657074H2.32361V1.65707Z",fill:"black"}),S.jsx("path",{d:"M5.65698 1.65707H4.65698V0.657074H5.65698V1.65707Z",fill:"black"}),S.jsx("path",{d:"M6.99036 1.65707H7.99036V0.657074H6.99036V1.65707Z",fill:"black"}),S.jsx("path",{d:"M10.3237 1.65707H9.32373V0.657074H10.3237V1.65707Z",fill:"black"}),S.jsx("path",{d:"M11.6571 1.65707H12.6571V0.657074H11.6571V1.65707Z",fill:"black"}),S.jsx("path",{d:"M14.9905 1.65707H13.9905V0.657074H14.9905V1.65707Z",fill:"black"}),S.jsx("path",{d:"M16.3239 1.65707H17.3239V0.657074H16.3239V1.65707Z",fill:"black"}),S.jsx("path",{d:"M19.6572 1.65707H18.6572V0.657074H19.6572V1.65707Z",fill:"black"}),S.jsx("path",{d:"M20.9906 1.65707H21.9906V0.657074H20.9906V1.65707Z",fill:"black"}),S.jsx("path",{d:"M24.324 1.65707H23.324V0.657074H24.324V1.65707Z",fill:"black"}),S.jsx("path",{d:"M25.6573 1.65707H26.6573V0.657074H25.6573V1.65707Z",fill:"black"}),S.jsx("path",{d:"M28.9907 1.65707H27.9907V0.657074H28.9907V1.65707Z",fill:"black"}),S.jsx("path",{d:"M30.3241 1.65707H31.3241V0.657074H30.3241V1.65707Z",fill:"black"}),S.jsx("path",{d:"M33.6575 1.65707H32.6575V0.657074H33.6575V1.65707Z",fill:"black"}),S.jsx("path",{d:"M34.9908 1.65707H35.9908V0.657074H34.9908V1.65707Z",fill:"black"}),S.jsx("path",{d:"M38.3242 1.65707H37.3242V0.657074H38.3242V1.65707Z",fill:"black"}),S.jsx("path",{d:"M39.6576 1.65707H40.6576V0.657074H39.6576V1.65707Z",fill:"black"}),S.jsx("path",{d:"M42.991 1.65707H41.991V0.657074H42.991V1.65707Z",fill:"black"}),S.jsx("path",{d:"M44.3243 1.65707H45.3243V0.657074H44.3243V1.65707Z",fill:"black"}),S.jsx("path",{d:"M47.6577 1.65707H46.6577V0.657074H47.6577V1.65707Z",fill:"black"}),S.jsx("path",{d:"M48.9911 1.65707H49.9911V0.657074H48.9911V1.65707Z",fill:"black"}),S.jsx("path",{d:"M52.3245 1.65707H51.3245V0.657074H52.3245V1.65707Z",fill:"black"}),S.jsx("path",{d:"M53.6578 1.65707H54.6578V0.657074H53.6578V1.65707Z",fill:"black"}),S.jsx("path",{d:"M56.9912 1.65707H55.9912V0.657074H56.9912V1.65707Z",fill:"black"}),S.jsx("path",{d:"M58.3246 1.65707H59.3246V0.657074H58.3246V1.65707Z",fill:"black"}),S.jsx("path",{d:"M61.658 1.65707H60.658V0.657074H61.658V1.65707Z",fill:"black"}),S.jsx("path",{d:"M62.9913 1.65707H63.9913V0.657074H62.9913V1.65707Z",fill:"black"}),S.jsx("path",{d:"M66.3247 1.65707H65.3247V0.657074H66.3247V1.65707Z",fill:"black"}),S.jsx("path",{d:"M67.6581 1.65707H68.6581V0.657074H67.6581V1.65707Z",fill:"black"}),S.jsx("path",{d:"M70.9915 1.65707H69.9915V0.657074H70.9915V1.65707Z",fill:"black"}),S.jsx("path",{d:"M72.3248 1.65707H73.3248V0.657074H72.3248V1.65707Z",fill:"black"}),S.jsx("path",{d:"M75.6582 1.65707H74.6582V0.657074H75.6582V1.65707Z",fill:"black"}),S.jsx("path",{d:"M76.9916 1.65707H77.9916V0.657074H76.9916V1.65707Z",fill:"black"}),S.jsx("path",{d:"M80.325 1.65707H79.325V0.657074H80.325V1.65707Z",fill:"black"}),S.jsx("path",{d:"M81.6583 1.65707H82.6583V0.657074H81.6583V1.65707Z",fill:"black"}),S.jsx("path",{d:"M84.9917 1.65707H83.9917V0.657074H84.9917V1.65707Z",fill:"black"}),S.jsx("path",{d:"M86.3251 1.65707H87.3251V0.657074H86.3251V1.65707Z",fill:"black"}),S.jsx("path",{d:"M89.6584 1.65707H88.6584V0.657074H89.6584V1.65707Z",fill:"black"}),S.jsx("path",{d:"M90.9918 1.65707H91.9918V0.657074H90.9918V1.65707Z",fill:"black"}),S.jsx("path",{d:"M94.3252 1.65707H93.3252V0.657074H94.3252V1.65707Z",fill:"black"}),S.jsx("path",{d:"M95.6586 1.65707H96.6586V0.657074H95.6586V1.65707Z",fill:"black"}),S.jsx("path",{d:"M98.9919 1.65707H97.9919V0.657074H98.9919V1.65707Z",fill:"black"}),S.jsx("path",{d:"M100.325 1.65707H101.325V0.657074H100.325V1.65707Z",fill:"black"}),S.jsx("path",{d:"M103.659 1.65707H102.659V0.657074H103.659V1.65707Z",fill:"black"}),S.jsx("path",{d:"M104.992 1.65707H105.992V0.657074H104.992V1.65707Z",fill:"black"}),S.jsx("path",{d:"M108.325 1.65707H107.325V0.657074H108.325V1.65707Z",fill:"black"}),S.jsx("path",{d:"M109.659 1.65707H110.659V0.657074H109.659V1.65707Z",fill:"black"}),S.jsx("path",{d:"M112.992 1.65707H111.992V0.657074H112.992V1.65707Z",fill:"black"}),S.jsx("path",{d:"M114.325 1.65707H115.325V0.657074H114.325V1.65707Z",fill:"black"}),S.jsx("path",{d:"M117.659 1.65707H116.659V0.657074H117.659V1.65707Z",fill:"black"}),S.jsx("path",{d:"M118.992 1.65707H119.992V0.657074H118.992V1.65707Z",fill:"black"})]}),zu=()=>S.jsx("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 2.42035H-0.0090332V0.420349H119.991V2.42035Z",fill:"black"})}),$u=()=>S.jsxs("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[S.jsx("path",{d:"M-0.0100098 2.47614H1.98999V0.476135H-0.0100098V2.47614Z",fill:"black"}),S.jsx("path",{d:"M3.99014 2.47614H9.99014V0.476135H3.99014V2.47614Z",fill:"black"}),S.jsx("path",{d:"M13.9901 2.47614H11.9901V0.476135H13.9901V2.47614Z",fill:"black"}),S.jsx("path",{d:"M21.1904 2.47614H23.1904V0.476135H21.1904V2.47614Z",fill:"black"}),S.jsx("path",{d:"M31.1906 2.47614H25.1906V0.476135H31.1906V2.47614Z",fill:"black"}),S.jsx("path",{d:"M33.1906 2.47614H35.1906V0.476135H33.1906V2.47614Z",fill:"black"}),S.jsx("path",{d:"M44.3909 2.47614H42.3909V0.476135H44.3909V2.47614Z",fill:"black"}),S.jsx("path",{d:"M46.391 2.47614H52.391V0.476135H46.391V2.47614Z",fill:"black"}),S.jsx("path",{d:"M56.391 2.47614H54.391V0.476135H56.391V2.47614Z",fill:"black"}),S.jsx("path",{d:"M63.5913 2.47614H65.5913V0.476135H63.5913V2.47614Z",fill:"black"}),S.jsx("path",{d:"M73.5915 2.47614H67.5915V0.476135H73.5915V2.47614Z",fill:"black"}),S.jsx("path",{d:"M75.5915 2.47614H77.5915V0.476135H75.5915V2.47614Z",fill:"black"}),S.jsx("path",{d:"M86.7917 2.47614H84.7917V0.476135H86.7917V2.47614Z",fill:"black"}),S.jsx("path",{d:"M88.7919 2.47614H94.7919V0.476135H88.7919V2.47614Z",fill:"black"}),S.jsx("path",{d:"M98.7919 2.47614H96.7919V0.476135H98.7919V2.47614Z",fill:"black"}),S.jsx("path",{d:"M105.992 2.47614H107.992V0.476135H105.992V2.47614Z",fill:"black"}),S.jsx("path",{d:"M115.992 2.47614H109.992V0.476135H115.992V2.47614Z",fill:"black"}),S.jsx("path",{d:"M117.992 2.47614H119.992V0.476135H117.992V2.47614Z",fill:"black"})]}),Yu=()=>S.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[S.jsx("path",{d:"M-0.0100098 2.00415H1.98999V0.00415039H-0.0100098V2.00415Z",fill:"black"}),S.jsx("path",{d:"M3.99014 2.00415H9.99014V0.00415039H3.99014V2.00415Z",fill:"black"}),S.jsx("path",{d:"M13.9901 2.00415H11.9901V0.00415039H13.9901V2.00415Z",fill:"black"}),S.jsx("path",{d:"M15.9901 2.00415H17.9901V0.00415039H15.9901V2.00415Z",fill:"black"}),S.jsx("path",{d:"M27.4905 2.00415H25.4905V0.00415039H27.4905V2.00415Z",fill:"black"}),S.jsx("path",{d:"M29.4906 2.00415H35.4906V0.00415039H29.4906V2.00415Z",fill:"black"}),S.jsx("path",{d:"M39.4906 2.00415H37.4906V0.00415039H39.4906V2.00415Z",fill:"black"}),S.jsx("path",{d:"M41.4906 2.00415H43.4906V0.00415039H41.4906V2.00415Z",fill:"black"}),S.jsx("path",{d:"M52.991 2.00415H50.991V0.00415039H52.991V2.00415Z",fill:"black"}),S.jsx("path",{d:"M54.9911 2.00415H60.9911V0.00415039H54.9911V2.00415Z",fill:"black"}),S.jsx("path",{d:"M64.9911 2.00415H62.9911V0.00415039H64.9911V2.00415Z",fill:"black"}),S.jsx("path",{d:"M66.9911 2.00415H68.9911V0.00415039H66.9911V2.00415Z",fill:"black"}),S.jsx("path",{d:"M78.4915 2.00415H76.4915V0.00415039H78.4915V2.00415Z",fill:"black"}),S.jsx("path",{d:"M80.4916 2.00415H86.4916V0.00415039H80.4916V2.00415Z",fill:"black"}),S.jsx("path",{d:"M90.4916 2.00415H88.4916V0.00415039H90.4916V2.00415Z",fill:"black"}),S.jsx("path",{d:"M92.4916 2.00415H94.4916V0.00415039H92.4916V2.00415Z",fill:"black"}),S.jsx("path",{d:"M103.992 2.00415H101.992V0.00415039H103.992V2.00415Z",fill:"black"}),S.jsx("path",{d:"M105.992 2.00415H111.992V0.00415039H105.992V2.00415Z",fill:"black"}),S.jsx("path",{d:"M115.992 2.00415H113.992V0.00415039H115.992V2.00415Z",fill:"black"}),S.jsx("path",{d:"M117.992 2.00415H119.992V0.00415039H117.992V2.00415Z",fill:"black"})]}),Xu=()=>S.jsxs("svg",{width:"118",height:"3",viewBox:"0 0 118 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[S.jsx("path",{d:"M-0.00854492 2.94815H1.99146V0.948151H-0.00854492V2.94815Z",fill:"black"}),S.jsx("path",{d:"M6.09668 2.94815H8.09668V0.948151H6.09668V2.94815Z",fill:"black"}),S.jsx("path",{d:"M14.2019 2.94815H12.2019V0.948151H14.2019V2.94815Z",fill:"black"}),S.jsx("path",{d:"M18.3071 2.94815H20.3071V0.948151H18.3071V2.94815Z",fill:"black"}),S.jsx("path",{d:"M26.4124 2.94815H24.4124V0.948151H26.4124V2.94815Z",fill:"black"}),S.jsx("path",{d:"M30.5176 2.94815H32.5176V0.948151H30.5176V2.94815Z",fill:"black"}),S.jsx("path",{d:"M38.6228 2.94815H36.6228V0.948151H38.6228V2.94815Z",fill:"black"}),S.jsx("path",{d:"M42.728 2.94815H44.728V0.948151H42.728V2.94815Z",fill:"black"}),S.jsx("path",{d:"M50.8333 2.94815H48.8333V0.948151H50.8333V2.94815Z",fill:"black"}),S.jsx("path",{d:"M54.9385 2.94815H56.9385V0.948151H54.9385V2.94815Z",fill:"black"}),S.jsx("path",{d:"M63.0437 2.94815H61.0437V0.948151H63.0437V2.94815Z",fill:"black"}),S.jsx("path",{d:"M67.1489 2.94815H69.1489V0.948151H67.1489V2.94815Z",fill:"black"}),S.jsx("path",{d:"M75.2542 2.94815H73.2542V0.948151H75.2542V2.94815Z",fill:"black"}),S.jsx("path",{d:"M79.3594 2.94815H81.3594V0.948151H79.3594V2.94815Z",fill:"black"}),S.jsx("path",{d:"M87.4645 2.94815H85.4645V0.948151H87.4645V2.94815Z",fill:"black"}),S.jsx("path",{d:"M91.5697 2.94815H93.5697V0.948151H91.5697V2.94815Z",fill:"black"}),S.jsx("path",{d:"M99.6749 2.94815H97.6749V0.948151H99.6749V2.94815Z",fill:"black"}),S.jsx("path",{d:"M103.78 2.94815H105.78V0.948151H103.78V2.94815Z",fill:"black"}),S.jsx("path",{d:"M111.885 2.94815H109.885V0.948151H111.885V2.94815Z",fill:"black"}),S.jsx("path",{d:"M115.991 2.94815H117.991V0.948151H115.991V2.94815Z",fill:"black"})]}),Zu=()=>S.jsx("svg",{width:"120",height:"4",viewBox:"0 0 120 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 3.86215H-0.0090332V0.862152H119.991V3.86215Z",fill:"black"})}),ro=()=>S.jsx("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 1.15668H-0.0090332V0.156677H119.991V1.15668Z",fill:"black"})});function oo(i){const{type:e=l.BorderStyleTypes.THIN}=i;switch(e){case l.BorderStyleTypes.DASH_DOT:return S.jsx(Fu,{});case l.BorderStyleTypes.DASH_DOT_DOT:return S.jsx(Bu,{});case l.BorderStyleTypes.DASHED:return S.jsx(ju,{});case l.BorderStyleTypes.HAIR:return S.jsx(Wu,{});case l.BorderStyleTypes.MEDIUM:return S.jsx(zu,{});case l.BorderStyleTypes.MEDIUM_DASH_DOT:return S.jsx($u,{});case l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return S.jsx(Yu,{});case l.BorderStyleTypes.MEDIUM_DASHED:return S.jsx(Xu,{});case l.BorderStyleTypes.THICK:return S.jsx(Zu,{});case l.BorderStyleTypes.THIN:return S.jsx(ro,{});default:return S.jsx(ro,{})}}const Gu="univer-ui-plugin-sheets-border-panel",Ku="univer-ui-plugin-sheets-border-panel-position",qu="univer-ui-plugin-sheets-border-panel-position-item",Ju="univer-ui-plugin-sheets-border-panel-styles",Qu="univer-ui-plugin-sheets-border-panel-board",eh="univer-ui-plugin-sheets-border-panel-button",th="univer-ui-plugin-sheets-border-panel-more-icon",Ct={uiPluginSheetsBorderPanel:Gu,uiPluginSheetsBorderPanelPosition:Ku,uiPluginSheetsBorderPanelPositionItem:qu,uiPluginSheetsBorderPanelStyles:Ju,uiPluginSheetsBorderPanelBoard:Qu,uiPluginSheetsBorderPanelButton:eh,uiPluginSheetsBorderPanelMoreIcon:th},Ss=`${an}_BORDER_PANEL_COMPONENT`,vs=[{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:"InnerBorder",value:"horizontal"},{label:"borderLine.borderVertical",icon:"InnerBorder",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"}],nh=[{label:l.BorderStyleTypes.THIN,value:l.BorderStyleTypes.THIN},{label:l.BorderStyleTypes.HAIR,value:l.BorderStyleTypes.HAIR},{label:l.BorderStyleTypes.DOTTED,value:l.BorderStyleTypes.DOTTED},{label:l.BorderStyleTypes.DASHED,value:l.BorderStyleTypes.DASHED},{label:l.BorderStyleTypes.DASH_DOT,value:l.BorderStyleTypes.DASH_DOT},{label:l.BorderStyleTypes.DASH_DOT_DOT,value:l.BorderStyleTypes.DASH_DOT_DOT},{label:l.BorderStyleTypes.MEDIUM,value:l.BorderStyleTypes.MEDIUM},{label:l.BorderStyleTypes.MEDIUM_DASHED,value:l.BorderStyleTypes.MEDIUM_DASHED},{label:l.BorderStyleTypes.MEDIUM_DASH_DOT,value:l.BorderStyleTypes.MEDIUM_DASH_DOT},{label:l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT,value:l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT},{label:l.BorderStyleTypes.THICK,value:l.BorderStyleTypes.THICK}];function ih(i){const e=me.useDependency(R.ComponentManager),{onChange:t,value:n}=i;function r(a,c){t==null||t({...n,[c]:a})}function o(a){const c=e.get(a);return c&&S.jsx(c,{extend:{colorChannel1:"rgb(var(--primary-color))"}})}function s(a){a.stopPropagation()}return S.jsxs("section",{className:Ct.uiPluginSheetsBorderPanel,children:[S.jsx("div",{className:Ct.uiPluginSheetsBorderPanelPosition,children:vs.map(a=>S.jsx("div",{className:Ct.uiPluginSheetsBorderPanelPositionItem,onClick:()=>r(a.value,"type"),children:o(a.icon)},a.value))}),S.jsxs("div",{className:Ct.uiPluginSheetsBorderPanelStyles,children:[S.jsx("div",{children:S.jsx(Ye.Dropdown,{align:{offset:[0,18]},overlay:S.jsx("section",{className:Ct.uiPluginSheetsBorderPanelBoard,onClick:s,children:S.jsx(Ye.ColorPicker,{onChange:a=>r(a,"color")})}),children:S.jsxs("a",{className:Ct.uiPluginSheetsBorderPanelButton,onClick:s,children:[S.jsx(Rl,{extend:{colorChannel1:n.color??"rgb(var(--primary-color))"}}),S.jsx("span",{className:Ct.uiPluginSheetsBorderPanelMoreIcon,children:S.jsx(Qi,{})})]})})}),S.jsx("div",{children:S.jsx(Ye.Dropdown,{align:{offset:[0,18]},overlay:S.jsx("section",{onClick:s,children:S.jsx(Ye.Menu,{children:nh.map(a=>S.jsx(Ye.MenuItem,{eventKey:a.value.toString(),onClick:()=>r(a.value,"style"),children:S.jsx(oo,{type:a.value})},a.value))})}),children:S.jsxs("a",{className:Ct.uiPluginSheetsBorderPanelButton,onClick:s,children:[S.jsx(oo,{type:l.BorderStyleTypes.THIN}),S.jsx("span",{className:Ct.uiPluginSheetsBorderPanelMoreIcon,children:S.jsx(Qi,{})})]})})})]})]})}const rh="univer-count-bar",oh={countBar:rh},sh=[50,80,100,130,150,170,200,400];function ah(){const i=me.useDependency(l.ICommandService),e=me.useDependency(l.IUniverInstanceService),t=o(),[n,r]=X.useState(t);X.useEffect(()=>i.onCommandExecuted(c=>{if(c.id===bt.id||c.id===p.SetWorksheetActivateCommand.id){const d=o();r(d)}}).dispose,[i]);function o(){const a=e.getCurrentUniverSheetInstance().getActiveSheet().getZoomRatio()*100||100;return Math.round(a)}function s(a){r(a);const c=e.getCurrentUniverSheetInstance();if(!c)return;const d=c.getActiveSheet();if(!d)return;const u=a/100;i.executeCommand(vr.id,{unitId:c.getUnitId(),subUnitId:d.getSheetId(),zoomRatio:u})}return S.jsx(Ye.Slider,{min:Gi[0],value:n,shortcuts:sh,onChange:s})}function lh(i){return S.jsx("section",{className:oh.countBar,children:S.jsx(ah,{})})}const ch="univer-editor-container",dh="univer-editor-input",so={editorContainer:ch,editorInput:dh},bi=-1e3,ao={width:0,height:0,top:bi,left:bi},uh=()=>{const[i,e]=X.useState({...ao}),t=X.useRef(null),n=me.useDependency(y.IRenderManagerService),r=me.useDependency(Dn);return X.useEffect(()=>{const o=t.current;if(!o)return;const s=n.currentRender$.pipe(uo.switchMap(()=>{var c;const a=(c=n.getRenderById(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY))==null?void 0:c.engine;return a==null||a.setContainer(o),r.state$})).subscribe(a=>{if(a==null)return;const{startX:c=bi,startY:d=bi,endX:u=0,endY:h=0,show:m=!1}=a;if(!m)e({...ao});else{e({width:u-c,height:h-d,left:c,top:d});const g=t.current;if(!g)return;const{left:_,top:f,width:C,height:I}=g.getBoundingClientRect();r.setRect({left:_,top:f,width:C,height:I})}});return()=>{s.unsubscribe()}},[]),X.useEffect(()=>{r.setFocus(!0)},[i]),S.jsx("div",{className:so.editorContainer,style:{left:i.left,top:i.top,width:i.width,height:i.height},children:S.jsx("div",{className:so.editorInput,ref:t})})},hh="univer-formula-box",mh="univer-name-ranges",gh="univer-name-ranges-input",_h="univer-formula-bar",ph="univer-formula-icon",fh="univer-formula-icon-wrapper",Sh="univer-icon-container",vh="univer-icon-container-success",Ch="univer-formula-active",Rh="univer-icon-container-error",Ih="univer-formula-input",bh="univer-formula-content",Mh="univer-arrow-container",ze={formulaBox:hh,nameRanges:mh,nameRangesInput:gh,formulaBar:_h,formulaIcon:ph,formulaIconWrapper:fh,iconContainer:Sh,iconContainerSuccess:vh,formulaActive:Ch,iconContainerError:Rh,formulaInput:Ih,formulaContent:bh,arrowContainer:Mh};function wh(){const[i,e]=X.useState(ze.formulaGrey),[t,n]=X.useState(0),r=X.useRef(null),o=me.useDependency(y.IRenderManagerService),s=me.useDependency(xi),a=me.useDependency(at);X.useEffect(()=>{const m=r.current;if(!m)return;const g=o.currentRender$.subscribe(f=>{var I;if(f!==l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)return;const C=(I=o.getRenderById(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))==null?void 0:I.engine;C==null||C.setContainer(m)}),_=new ResizeObserver(()=>{const f=m.getBoundingClientRect();s.setPosition(f)});return _.observe(m),a.visible$.subscribe(f=>{e(f.visible?ze.formulaActive:ze.formulaGrey)}),()=>{_.unobserve(m),g.unsubscribe()}},[]);function c(){n(t===0?1:0),setTimeout(()=>{s.handleFoldBtnClick(t===1)},150)}function d(){a.isVisible().visible&&a.changeVisible({visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:R.KeyCode.ESC})}function u(){a.isVisible().visible&&a.changeVisible({visible:!1,eventType:y.DeviceInputEventType.PointerDown})}function h(){s.handleFxBtnClick(!0)}return S.jsxs("div",{className:ze.formulaBox,style:{height:t===0?"28px":"82px"},children:[S.jsx("div",{className:ze.nameRanges,children:S.jsx("div",{className:ze.nameRangesInput})}),S.jsxs("div",{className:ze.formulaBar,children:[S.jsx("div",{className:ze.formulaIcon,children:S.jsxs("div",{className:ze.formulaIconWrapper,children:[S.jsx("span",{className:bn(ze.iconContainer,ze.iconContainerError,i),onClick:d,children:S.jsx(ll,{})}),S.jsx("span",{className:bn(ze.iconContainer,ze.iconContainerSuccess,i),onClick:u,children:S.jsx(Ri,{})}),S.jsx("span",{className:ze.iconContainer,onClick:h,children:S.jsx(_l,{})})]})}),S.jsxs("div",{className:ze.formulaInput,children:[S.jsx("div",{onContextMenu:m=>m.preventDefault(),className:ze.formulaContent,ref:r}),S.jsx("div",{className:ze.arrowContainer,onClick:c,children:t===0?S.jsx(Br,{}):S.jsx(Br,{style:{transform:"rotateZ(180deg)"}})})]})]})]})}const Th="univer-operate-container",yh="univer-auto-fill-popup-menu",Eh="univer-auto-fill-popup-menu-item",Oh="univer-auto-fill-popup-menu-item-icon",xh="univer-auto-fill-popup-menu-item-title",Ah="univer-auto-fill-popup-menu-item-hide",Nh="univer-btn-container",Dh="univer-btn-container-expand",kt={operateContainer:Th,autoFillPopupMenu:yh,autoFillPopupMenuItem:Eh,autoFillPopupMenuItemIcon:Oh,autoFillPopupMenuItemTitle:xh,autoFillPopupMenuItemHide:Ah,btnContainer:Nh,btnContainerExpand:Dh},Ph=()=>{const[,i]=X.useState({});return X.useCallback(()=>i(e=>!e),[])},Hh=()=>{var Ie;const i=me.useDependency(l.ICommandService),e=me.useDependency(exports.SheetSkeletonManagerService),t=me.useDependency(l.IUniverInstanceService),n=me.useDependency(y.IRenderManagerService),r=me.useDependency(Ze),o=me.useDependency(xn),s=me.useDependency(l.LocaleService),[a,c]=X.useState([]),[d,u]=X.useState(!1),[h,m]=X.useState({row:-1,col:-1}),[g,_]=X.useState(Te.SERIES),[f,C]=X.useState(!1),I=()=>{C(!0)},w=()=>{C(!1)},E=Ph(),O=qe(t,n);if(O==null)return null;const{scene:x}=O;if(X.useEffect(()=>{const de=[mt.id,zn.id,bt.id,p.SetRangeValuesMutation.id,p.SetWorksheetActiveOperation.id];return i.onCommandExecuted(be=>{be.id===on.id&&E(),de.includes(be.id)&&m({row:-1,col:-1})}).dispose},[E,i]),X.useEffect(()=>l.toDisposable(o.menu$.subscribe(Ee=>{c(Ee.map(be=>({...be,index:Ee.indexOf(be)})))})).dispose,[o]),X.useEffect(()=>l.toDisposable(o.showMenu$.subscribe(Ee=>{const{source:be,target:De}=o.autoFillLocation||{source:null,target:null};if(Ee&&be&&De){const Oe=l.Rectangle.union(be,De);m({row:Oe.endRow,col:Oe.endColumn})}})).dispose,[o]),X.useEffect(()=>l.toDisposable(o.applyType$.subscribe(Ee=>{_(Ee)})).dispose,[o]),X.useEffect(()=>{function de(){u(!1)}return document.addEventListener("wheel",de),()=>{document.removeEventListener("wheel",de)}},[d]),h.col<0||h.row<0)return null;const N=(Ie=e.getCurrent())==null?void 0:Ie.skeleton,D=r.getViewPort(),P=x==null?void 0:x.scaleX,L=x==null?void 0:x.scaleY,G=x==null?void 0:x.getScrollXY(D);if(!P||!x||!P||!L||!G)return null;const k=(N==null?void 0:N.getNoMergeCellPositionByIndex(h.row,h.col).endX)||0,ee=(N==null?void 0:N.getNoMergeCellPositionByIndex(h.row,h.col).endY)||0,te=N==null?void 0:N.convertTransformToOffsetX(k,P,G),W=N==null?void 0:N.convertTransformToOffsetY(ee,L,G);if(te==null||W==null)return null;const V=de=>{u(de)},re=de=>{i.executeCommand(gs.id,{type:de.value})},q=d||f,ae=a.filter(de=>!de.disable);return S.jsx("div",{onMouseEnter:I,onMouseLeave:w,style:{left:`${te+2}px`,top:`${W+2}px`,position:"absolute"},children:S.jsx(Ye.Dropdown,{placement:"bottomLeft",trigger:["click"],overlay:S.jsx("ul",{className:kt.autoFillPopupMenu,children:ae.map(de=>S.jsxs("li",{onClick:()=>re(de),className:kt.autoFillPopupMenuItem,children:[S.jsx("span",{className:kt.autoFillPopupMenuItemIcon,children:de.value===g&&S.jsx(Ri,{style:{color:"rgb(var(--green-700, #409f11))"}})}),S.jsx("span",{className:kt.autoFillPopupMenuItemTitle,children:s.t(de.label)})]},de.index))}),visible:d,onVisibleChange:V,children:S.jsxs("div",{className:bn(kt.btnContainer,{[kt.btnContainerExpand]:d}),children:[S.jsx(ol,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),q&&S.jsx(Qi,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},Lh=()=>S.jsx("div",{className:kt.operateContainer,children:S.jsx(Hh,{})}),Uh="univer-sheet-bar",kh="univer-sheet-bar-options",Vh="univer-sheet-bar-options-divider",Wn={sheetBar:Uh,sheetBarOptions:kh,sheetBarOptionsDivider:Vh},Fh="univer-sheet-bar-btn",Bh={sheetBarBtn:Fh};function gi(i){const{children:e,className:t,style:n,disabled:r=!1,onClick:o,...s}=i,a=c=>{if(r){c.preventDefault();return}o&&o(c)};return S.jsx("button",{className:Bh.sheetBarBtn,style:n,disabled:r,onClick:a,...s,children:e})}const jh="univer-sheet-bar-menu",Wh="univer-sheet-bar-menu-item",zh="univer-sheet-bar-menu-item-icon",$h="univer-sheet-bar-menu-item-hide",Yh="univer-sheet-bar-menu-item-select",Xh="univer-sheet-bar-menu-item-label",Ot={sheetBarMenu:jh,sheetBarMenuItem:Wh,sheetBarMenuItemIcon:zh,sheetBarMenuItemHide:$h,sheetBarMenuItemSelect:Yh,sheetBarMenuItemLabel:Xh};function Zh(i){const{style:e}=i,[t,n]=X.useState([]),[r,o]=X.useState(!1),s=me.useDependency(l.IUniverInstanceService),a=me.useDependency(l.ICommandService),c=me.useDependency(cn),d=s.getCurrentUniverSheetInstance(),u=f=>{const{sheetId:C}=f;C&&(f.hidden?a.executeCommand(p.SetWorksheetShowCommand.id,{value:C}):f.selected||a.executeCommand(p.SetWorksheetActivateCommand.id,{unitId:d.getUnitId(),subUnitId:C}),o(!1))};X.useEffect(()=>{m();const f=new l.DisposableCollection;return f.add(h()),f.add(c.registerSheetBarMenuHandler({handleSheetBarMenu:g})),()=>{f.dispose()}},[]);const h=()=>a.onCommandExecuted(f=>{switch(f.id){case p.SetWorksheetHideMutation.id:case p.RemoveSheetMutation.id:case p.SetWorksheetNameMutation.id:case p.InsertSheetMutation.id:case p.SetWorksheetOrderMutation.id:case p.SetWorksheetActiveOperation.id:m();break}}),m=()=>{const C=d.getSheets().map((I,w)=>({label:I.getName(),index:`${w}`,sheetId:I.getSheetId(),hidden:I.isSheetHidden()===l.BooleanNumber.TRUE,selected:I.getStatus()===l.BooleanNumber.TRUE}));n(C)};function g(){o(!0)}const _=f=>{o(f)};return S.jsx(Ye.Dropdown,{placement:"topLeft",trigger:["click"],overlay:S.jsx("ul",{className:Ot.sheetBarMenu,style:{...e},children:t.map(f=>S.jsxs("li",{onClick:()=>u(f),className:f.selected?`${Ot.sheetBarMenuItem} ${Ot.sheetBarMenuItemSelect}`:f.hidden?`${Ot.sheetBarMenuItem} ${Ot.sheetBarMenuItemHide}`:Ot.sheetBarMenuItem,children:[S.jsx("span",{className:Ot.sheetBarMenuItemIcon,children:f.selected?S.jsx(Ri,{}):f.hidden?S.jsx(ml,{}):S.jsx(Ri,{})}),S.jsx("span",{className:Ot.sheetBarMenuItemLabel,children:f.label})]},f.index))}),visible:r,onVisibleChange:_,children:S.jsx(gi,{children:S.jsx(dl,{})})})}const Gh="univer-slide-tab-bar-container",Kh="univer-slide-tab-bar",qh="univer-slide-tab-item",Jh="univer-slide-tab-active",Qh="univer-slide-tab-span",em="univer-slide-tab-span-edit",ot={slideTabBarContainer:Gh,slideTabBar:Kh,slideTabItem:qh,slideTabActive:Jh,slideTabSpan:Qh,slideTabSpanEdit:em};function tm(i){const{sheetId:e,label:t,color:n,selected:r}=i,[o,s]=X.useState(!1),[a,c]=X.useState(r),d=me.useDependency(l.ICommandService),u=me.useDependency(l.ThemeService);X.useEffect(()=>{c(r)},[r]);const h=g=>{s(g)},m=g=>{const _=u.getCurrentTheme(),f=_.textColor,C=_.colorWhite;return new l.ColorKit(g).isDark()?C:f};return S.jsx(Ye.Dropdown,{visible:o,trigger:["contextMenu"],overlay:S.jsx(R.Menu,{menuType:Be.SHEET_BAR,onOptionSelect:g=>{const{label:_,value:f}=g;d.executeCommand(_,{value:f,subUnitId:e}),s(!1)}}),onVisibleChange:h,children:S.jsx("div",{"data-id":e,className:a?`${ot.slideTabActive} ${ot.slideTabItem}`:ot.slideTabItem,style:{backgroundColor:!a&&n?n:"",color:!a&&n?m(n):"",boxShadow:a&&n?`0px 0px 8px rgba(0, 0, 0, 0.08), inset 0px -2px 0px 0px ${n}`:""},children:S.jsx("span",{className:ot.slideTabSpan,children:t})},e)})}const nm={easeOutStrong(i,e,t,n){return-t*((i=i/n-1)*i*i*i-1)+e},backOut(i,e,t,n,r){return typeof r>"u"&&(r=.7),t*((i=i/n-1)*i*((r+1)*i+r)+1)+e}},im={loop:!1,begin:0,end:0,duration:300,delay:0,type:"easeOutStrong",receive(i){},success(i){},cancel(i){},complete(i){}};class rm{constructor(e){v(this,"_config");v(this,"_status",0);v(this,"_start",0);v(this,"_handle",0);v(this,"_delayHandle",null);this._config={...im,...e},this._config.loop&&(this._config.complete=()=>{},this._config.success=()=>{this.request()})}static success(...e){let t=0;return new Promise(n=>{for(let r=0;r<e.length;r++){const o=e[r],s=o._config,a=s.success;s.loop||(s.success=d=>{t++,a&&a.call(o,d),t===e.length&&n()})}})}request(){this._config.delay===0?(this._status=0,this._start=Date.now(),this._fakeHandle()):(this._delayHandle&&clearTimeout(this._delayHandle),this._delayHandle=setTimeout(()=>{this._status=0,this._start=Date.now(),this._fakeHandle()},this._config.delay))}cancel(){this._status=1,this._delayHandle&&clearTimeout(this._delayHandle),cancelAnimationFrame(this._handle)}_fakeHandle(){let e=Date.now()-this._start;e=e>=this._config.duration?this._config.duration:e;const n=nm[this._config.type](e,this._config.begin,this._config.end-this._config.begin,this._config.duration,.7).toFixed(2);if(this._config.receive(n),this._status===1){this._config.cancel(n),this._config.complete(n);return}if(e===this._config.duration){this._config.success(n),this._config.complete(n);return}this._handle=requestAnimationFrame(()=>{this._fakeHandle()})}}class Ft{constructor(e,t){v(this,"_slideTabItem");v(this,"_animate");v(this,"_midline",0);v(this,"_translateX");v(this,"_scrollbar");v(this,"_slideTabBar");v(this,"_editMode");v(this,"_placeholder");this._slideTabItem=e,this._animate=null,this._translateX=0,this._editMode=!1,this._slideTabBar=t,this._placeholder=null,this._scrollbar=t.getScrollbar(),this.update()}static midline(e){return e.getBoundingRect().x+e.getBoundingRect().width/2}static leftLine(e){return e.getBoundingRect().x}static rightLine(e){return e.getBoundingRect().x+e.getBoundingRect().width}static make(e,t){const n=[];return e.forEach(r=>n.push(new Ft(r,t))),n}getSlideTabItem(){return this._slideTabItem}getEditor(){return this._slideTabItem.querySelector("span")}isEditMode(){return this._editMode}classList(){return this._slideTabItem.classList}translateX(e){return this._translateX=e,this._slideTabItem.style.transform=`translateX(${e}px)`,this.getTranslateXDirection()}setEditor(e){let t=!0;if(this._editMode===!1){const n=this._slideTabItem.querySelector("span"),r=d=>{if(!this.nameCheck()){if(this._editMode=!1,n&&(n.removeAttribute("contentEditable"),n.removeEventListener("blur",r),n.removeEventListener("compositionstart",s),n.removeEventListener("compositionend",a),n.removeEventListener("input",c),n.removeEventListener("keydown",o),n.classList.remove(this._slideTabBar.getConfig().slideTabBarSpanEditClassName)),this._slideTabBar.removeListener(),this._slideTabBar.updateItems(),this._slideTabBar.getConfig().onChangeName){const u=(n==null?void 0:n.innerText)||"",h=this.getId();this._slideTabBar.getConfig().onChangeName(h,u)}e&&e(d)}};let o=d=>{n&&(d.stopPropagation(),d.key==="Enter"&&n.blur())};const s=d=>{t=!1},a=d=>{t=!0},c=d=>{if(!n)return;const u=50;setTimeout(()=>{if(t){const h=n.innerText;h.length>u&&(n.innerText=h.substring(0,u),yn.keepLastIndex(n))}},0)};n&&(n.setAttribute("contentEditable","true"),n.addEventListener("blur",r),n.addEventListener("compositionstart",s),n.addEventListener("compositionend",a),n.addEventListener("input",c),n.addEventListener("keydown",o),n.classList.add(this._slideTabBar.getConfig().slideTabBarSpanEditClassName),this._editMode=!0,yn.keepSelectAll(n))}}nameCheck(){const e=this._slideTabItem.querySelector("span");if(!e)return!1;const t=e.innerText;return this._slideTabBar.getConfig().onNameCheckAlert(t)}animate(){return{translateX:e=>{this._translateX!==e&&(this._animate&&(this._animate.cancel(),this._animate=null),this._animate=new rm({begin:this._translateX,end:e,receive:t=>{this._slideTabItem.style.transform=`translateX(${t}px)`}}),this._translateX=e,this._animate.request())},cancel:()=>{this._animate&&(this._animate.cancel(),this._animate=null)}}}after(e){this._slideTabItem.after(e._slideTabItem||e)}update(){this._midline=Ft.midline(this)}disableFixed(){if(this._placeholder){const e=this._slideTabBar.primeval();this._slideTabItem.style.removeProperty("position"),this._slideTabItem.style.removeProperty("left"),this._slideTabItem.style.removeProperty("top"),this._slideTabItem.style.removeProperty("width"),this._slideTabItem.style.removeProperty("height"),this._slideTabItem.style.removeProperty("background"),this._slideTabItem.style.removeProperty("padding"),this._slideTabItem.style.removeProperty("box-sizing"),this._slideTabItem.style.removeProperty("font-size"),this._slideTabItem.style.removeProperty("font-family"),this._slideTabItem.style.removeProperty("font-weight"),this._slideTabItem.style.removeProperty("color"),this._slideTabItem.style.removeProperty("border-radius"),this._placeholder.after(this._slideTabItem),e.removeChild(this._placeholder),this._placeholder=null}}enableFixed(){const e=document.createElement("div"),t=this.getBoundingRect(),n=getComputedStyle(this._slideTabItem),r=this._slideTabItem.querySelector("span");if(this._placeholder=e,this._placeholder.style.width=`${t.width}px`,this._placeholder.style.height=`${t.height}px`,this._placeholder.style.flexShrink="0",this._placeholder.style.margin=n.margin,this._slideTabItem.style.background=n.background,r){const o=getComputedStyle(r).padding;this._slideTabItem.style.padding=o}this._slideTabItem.style.boxSizing=n.boxSizing,this._slideTabItem.style.fontSize=n.fontSize,this._slideTabItem.style.fontFamily=n.fontFamily,this._slideTabItem.style.fontWeight=n.fontWeight,this._slideTabItem.style.color=n.color,this._slideTabItem.style.borderRadius=n.borderRadius,this._slideTabItem.style.left=`${t.x-this.getScrollbar().getScrollX()}px`,this._slideTabItem.style.top=`${t.y}px`,this._slideTabItem.style.width=`${t.width}px`,this._slideTabItem.style.height=`${t.height}px`,this._slideTabItem.style.position="fixed",this._slideTabItem.after(e),document.body.appendChild(this._slideTabItem)}addEventListener(e,t,n){this._slideTabItem.addEventListener(e,t,n)}removeEventListener(e,t,n){this._slideTabItem.removeEventListener(e,t,n)}getScrollbar(){return this._scrollbar}getMidLine(){return this._midline}getBoundingRect(){const e=this._slideTabItem.getBoundingClientRect();return e.x+=this._scrollbar.getScrollX(),e}getWidth(){return this.getBoundingRect().width}getTranslateXDirection(){const e=Ft.midline(this);return e>this._midline?1:e<this._midline?-1:0}equals(e){return e&&e._slideTabItem===this._slideTabItem}getId(){return this._slideTabItem.dataset.id||""}}class om{constructor(e){v(this,"_slideTabBar");v(this,"_scrollX");const t=e.primeval();this._scrollX=t.scrollLeft,this._slideTabBar=e}scrollX(e){const t=this._slideTabBar.primeval();t.scrollLeft=e,this._scrollX=t.scrollLeft}scrollRight(){const e=this._slideTabBar.primeval();e.scrollLeft=e.scrollWidth,this._scrollX=e.scrollLeft}getScrollX(){return this._scrollX}}const qt=class qt{constructor(e){v(this,"_activeTabItemIndex",0);v(this,"_slideTabBar");v(this,"_slideTabItems",[]);v(this,"_config");v(this,"_downActionX",0);v(this,"_moveActionX",0);v(this,"_compareIndex",0);v(this,"_activeTabItem",null);v(this,"_moveAction");v(this,"_upAction");v(this,"_downAction");v(this,"_wheelAction");v(this,"_scrollIncremental",0);v(this,"_compareDirection",0);v(this,"_autoScrollTime",null);v(this,"_slideScrollbar");v(this,"_longPressTimer",null);v(this,"_leftBoundingLine",0);v(this,"_rightBoundingLine",0);v(this,"_leftMoveX",0);v(this,"_rightMoveX",0);if(e.slideTabBarContainer==null)throw new Error("not found slide-tab-bar root element");const t=e.slideTabBarContainer.querySelector(`.${e.slideTabBarClassName??"slide-tab-bar"}`);if(t==null)throw new Error("not found slide-tab-bar");this._slideTabBar=t,this._slideScrollbar=new om(this),this._config=e,this._initConfig();let n=0,r=0,o=0;this._downAction=s=>{var x,N,D,P,L,G;if((x=this._activeTabItem)!=null&&x.isEditMode())return;const a=(D=(N=s.target)==null?void 0:N.closest(`.${e.slideTabBarItemClassName}`))==null?void 0:D.getAttribute("data-id"),c=this._slideTabItems.findIndex(k=>k.getId()===a);if(a==null||c===-1)return;if(this._activeTabItemIndex!==c){(P=this._activeTabItem)==null||P.removeEventListener("pointermove",this._moveAction),(L=this._activeTabItem)==null||L.removeEventListener("pointerup",this._upAction),this.removeListener(),this._config.onChangeTab(s,a);return}if(this._compareIndex=c,this._downActionX=s.pageX,this._moveActionX=0,this._scrollIncremental=0,this._activeTabItem=this._slideTabItems[c],!this._activeTabItem){console.error("Not found active slide-tab-item in sheet bar");return}const d=this._activeTabItem.getSlideTabItem();d==null||d.setPointerCapture(s.pointerId),(G=this._activeTabItem)==null||G.addEventListener("pointerup",this._upAction);const{x:u,width:h}=this._activeTabItem.getBoundingRect(),{x:m,width:g}=this.getBoundingRect(),_=this._slideScrollbar.getScrollX();if(this._leftBoundingLine=this._downActionX-(u-_),this._rightBoundingLine=u-_+h-this._downActionX,this._leftMoveX=u-m-_,this._rightMoveX=m+g-(u+h)+_,s.button===2||this._hasEditItem())return;const{pageX:f,pageY:C}=s,I=Date.now(),w=I-o<=qt.DoubleClickDelay,E=Math.abs(f-n)<10,O=Math.abs(C-r)<10;w&&E&&O&&this._activeTabItem.setEditor(),n=f,r=C,o=I,this._longPressTimer=setTimeout(()=>{var k,ee;(k=this._activeTabItem)==null||k.enableFixed(),this._startAutoScroll(),d&&(d.setPointerCapture(s.pointerId),d.style.cursor="move",(ee=this._activeTabItem)==null||ee.addEventListener("pointermove",this._moveAction))},qt.LongPressDelay)},this._upAction=s=>{var c,d,u;if(this._longPressTimer&&(clearTimeout(this._longPressTimer),this._longPressTimer=null),!this._activeTabItem)return;this._closeAutoScroll(),this._activeTabItem.disableFixed(),this.updateItems();const a=(c=this._activeTabItem)==null?void 0:c.getSlideTabItem();a&&(a.style.cursor="",a.releasePointerCapture(s.pointerId),(d=this._activeTabItem)==null||d.removeEventListener("pointermove",this._moveAction),(u=this._activeTabItem)==null||u.removeEventListener("pointerup",this._upAction),this._config.onSlideEnd&&this._activeTabItemIndex!==this._compareIndex&&(this.removeListener(),this._config.onSlideEnd(s,this._compareIndex||0)),this._scrollIncremental=0,this._downActionX=0,this._moveActionX=0,this._compareIndex=0)},this._moveAction=s=>{this._activeTabItem&&(this._moveActionX=s.pageX-this._downActionX,this._moveActionX<=-this._leftMoveX?this._moveActionX=-this._leftMoveX:this._moveActionX>=this._rightMoveX&&(this._moveActionX=this._rightMoveX),this._scrollIncremental=0,this._scrollLeft(s),this._scrollRight(s))},this._wheelAction=s=>{this.setScroll(s.deltaY)},this.addListener()}static checkedSkipSlide(e){let t=e.target;for(;t!=null&&t!==document.body;){if(t.getAttribute("data-slide-skip"))return!0;t=t.parentElement}return!1}static keepLastIndex(e){setTimeout(()=>{const t=window.getSelection();t&&(t.selectAllChildren(e),t.collapseToEnd())})}static keepSelectAll(e){setTimeout(()=>{const t=window.getSelection();if(!t)return;const n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)})}update(e){this._config.currentIndex=e,this._initConfig(),this.removeListener(),this.addListener()}primeval(){return this._slideTabBar}updateItems(){for(let e=0;e<this._slideTabItems.length;e++)this._slideTabItems[e].animate().cancel(),this._slideTabItems[e].translateX(0),this._slideTabItems[e].update()}getScrollbar(){return this._slideScrollbar}getConfig(){return this._config}getBoundingRect(){return this._slideTabBar.getBoundingClientRect()}getSlideTabItems(){return this._slideTabItems}getActiveItem(){return this._activeTabItem}isLeftEnd(){return this._slideTabBar.scrollLeft===0}isRightEnd(){const e=this._slideTabBar.parentElement;return e?this._slideTabBar.scrollWidth-e.clientWidth===this._slideTabBar.scrollLeft:!1}addListener(){this._slideTabBar.addEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(e=>{e.addEventListener("pointerdown",this._downAction)})}removeListener(){this._slideTabBar.removeEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(e=>{e.removeEventListener("pointerdown",this._downAction)})}setScroll(e){if(this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e),e>0){const t=this.calculateLeftScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}else if(e<0){const t=this.calculateRightScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}flipPage(e){if(e>0){const t=this.calculateLeftScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}else if(e<0){const t=this.calculateRightScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}calculateLeftScrollX(e){let t=0;const n=4;return this._slideTabItems.some(r=>{const o=this._slideTabBar.getBoundingClientRect(),s=o.left+o.width,a=r.getSlideTabItem().getBoundingClientRect(),c=a.left,d=a.width;return c<s&&c+d+n*2>s?(t=e?c-o.left-n:c+d-s+n,!0):!1}),t}calculateRightScrollX(e){let t=0;const n=4;return this._slideTabItems.some(r=>{const o=this._slideTabBar.getBoundingClientRect(),s=o.left,a=r.getSlideTabItem().getBoundingClientRect(),c=a.left,d=a.width;return c-n*2<s&&c+d>s?(t=e?c+d-o.left-o.width+n:c-s-n,!0):!1}),t}destroy(){this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=[],this._activeTabItem=null,this.removeListener()}_hasEditItem(){for(let e=0;e<this._slideTabItems.length;e++)if(this._slideTabItems[e].isEditMode())return!0;return!1}_autoScrollFrame(){if(this._activeTabItem)switch(this._compareDirection=this._activeTabItem.translateX(this._moveActionX),this._compareDirection){case 1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareRight();break}case 0:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareIndex=this._activeTabItemIndex;break}case-1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareLeft();break}}this._autoScrollTime=requestAnimationFrame(()=>{this._autoScrollFrame()})}_startAutoScroll(){this._autoScrollTime==null&&this._autoScrollFrame()}_closeAutoScroll(){this._autoScrollTime&&cancelAnimationFrame(this._autoScrollTime),this._autoScrollTime=null}_scrollLeft(e){const t=this.getBoundingRect(),n=e.pageX-t.x;n<this._leftBoundingLine&&(this._scrollIncremental=-Math.min(Math.abs(n-this._leftBoundingLine)*.1,50))}_scrollRight(e){const t=this.getBoundingRect(),n=e.pageX-t.x;n>t.width-this._rightBoundingLine&&(this._scrollIncremental=Math.min(Math.abs(n-(t.width-this._rightBoundingLine))*.1,50))}_sortedItems(){if(this._activeTabItem!=null&&this._activeTabItemIndex!=null&&this._compareIndex!=null&&(this._slideTabItems.splice(this._activeTabItemIndex,1),this._slideTabItems.splice(this._compareIndex,0,this._activeTabItem),this._config.slideTabBarItemAutoSort))for(let e=0;e<this._slideTabItems.length;e++){const t=this._slideTabItems[e],n=this._slideTabItems[e+1];n&&t.after(n)}}_compareLeft(){if(this._activeTabItem&&this._activeTabItemIndex){const e=this._slideTabItems.findIndex(o=>o.equals(this._activeTabItem)),t=this._slideTabItems.length,n=[];for(let o=0;o<e&&!(o>=e);o++)n.push(this._slideTabItems[o]);for(let o=e+1;o<t;o++)this._slideTabItems[o].animate().translateX(0);let r=!0;for(let o=n.length-1;o>=0;o--){const s=n[o];Ft.leftLine(this._activeTabItem)<s.getMidLine()?(s.animate().translateX(this._activeTabItem.getWidth()),this._compareIndex=o,r=!1):(s.animate().translateX(0),r&&(this._compareIndex=this._activeTabItemIndex))}}}_compareRight(){if(this._activeTabItem){const e=this._slideTabItems.findIndex(o=>o.equals(this._activeTabItem)),t=this._slideTabItems.length,n=[];for(let o=e+1;o<t;o++)n.push(this._slideTabItems[o]);for(let o=0;o<e;o++)this._slideTabItems[o].animate().translateX(0);let r=!0;for(let o=0;o<n.length;o++){const s=n[o];Ft.rightLine(this._activeTabItem)>s.getMidLine()?(s.animate().translateX(-this._activeTabItem.getWidth()),this._compareIndex=e+o+1,r=!1):(s.animate().translateX(0),r&&(this._compareIndex=this._activeTabItemIndex))}}}_initConfig(){const e=this._slideTabBar.querySelectorAll(`.${this._config.slideTabBarItemClassName??"slide-tab-item"}`);this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=Ft.make(e,this),this._activeTabItemIndex=this._config.currentIndex,this._activeTabItem=this._slideTabItems[this._activeTabItemIndex]}};v(qt,"LongPressDelay",500),v(qt,"DoubleClickDelay",300);let yn=qt;function sm(){const[i,e]=X.useState([]),[t,n]=X.useState(""),[r,o]=X.useState(""),s=X.useRef({slideTabBar:null}),a=X.useRef(null),c=me.useDependency(l.IUniverInstanceService),d=me.useDependency(l.ICommandService),u=me.useDependency(cn),h=me.useDependency(l.LocaleService),m=me.useDependency(R.IConfirmService),g=me.useInjector(),_=c.getCurrentUniverSheetInstance();X.useEffect(()=>{N();const W=f(),V=x(),re=[D(),P(),L(),G()];return()=>{V.dispose(),W.destroy(),re.forEach(q=>q.unsubscribe())}},[]),X.useEffect(()=>{i.length>0&&O()},[i]);const f=()=>{const W=new yn({slideTabBarClassName:ot.slideTabBar,slideTabBarItemActiveClassName:ot.slideTabActive,slideTabBarItemClassName:ot.slideTabItem,slideTabBarSpanEditClassName:ot.slideTabSpanEdit,slideTabBarItemAutoSort:!0,slideTabBarContainer:a.current,currentIndex:0,onChangeName:(V,re)=>{d.executeCommand(p.SetWorksheetNameCommand.id,{subUnitId:V,name:re})},onSlideEnd:(V,re)=>{d.executeCommand(p.SetWorksheetOrderCommand.id,{order:re})},onChangeTab:(V,re)=>{d.executeCommand(p.SetWorksheetActivateCommand.id,{subUnitId:re,unitId:_.getUnitId()}),setTimeout(()=>{g.get(y.ITextSelectionRenderManager).focus()},0)},onScroll:V=>{u.setScroll(V)},onNameCheckAlert:V=>C(V)||I(V)});return s.current.slideTabBar=W,te(W),W},C=W=>{if(W.trim()===""){const V="sheetNameEmptyAlert";return m.open({id:V,title:{title:h.t("sheetConfig.sheetNameErrorTitle")},children:{title:h.t("sheetConfig.sheetNameCannotIsEmptyError")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm"),onClose(){m.close(V),w()},onConfirm(){m.close(V),w()}}),!0}return!1},I=W=>{const V=c.getCurrentUniverSheetInstance();if(V.getActiveSheet().getName()===W)return!1;const ae=V.checkSheetName(W);if(ae){const Ie="sheetNameRepeatAlert";m.open({id:Ie,title:{title:h.t("sheetConfig.sheetNameErrorTitle")},children:{title:h.t("sheetConfig.sheetNameAlreadyExistsError")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm"),onClose(){m.close(Ie),E()},onConfirm(){m.close(Ie),E()}})}return ae},w=()=>{var V,re;const W=(re=(V=s.current.slideTabBar)==null?void 0:V.getActiveItem())==null?void 0:re.getEditor();W&&W.focus()},E=()=>{var W,V;(V=(W=s.current.slideTabBar)==null?void 0:W.getActiveItem())==null||V.setEditor()},O=()=>{var V;const W=i.findIndex(re=>re.selected);(V=s.current.slideTabBar)==null||V.update(W)},x=()=>d.onCommandExecuted(W=>{switch(W.id){case p.SetTabColorMutation.id:case p.SetWorksheetHideMutation.id:case p.RemoveSheetMutation.id:case p.SetWorksheetNameMutation.id:case p.InsertSheetMutation.id:case p.SetWorksheetOrderMutation.id:case p.SetWorksheetActiveOperation.id:N();break}}),N=()=>{const W=_.getActiveSheet().getSheetId();n(W);const re=_.getSheets().filter(q=>!q.isSheetHidden()).map((q,ae)=>({sheetId:q.getSheetId(),label:q.getName(),index:ae,selected:q.getStatus()===l.BooleanNumber.TRUE,color:q.getTabColor()??void 0}));e(re)},D=()=>u.scroll$.subscribe(W=>{k(W)}),P=()=>u.scrollX$.subscribe(W=>{var V;(V=s.current.slideTabBar)==null||V.flipPage(W)}),L=()=>u.renameId$.subscribe(()=>{E()}),G=()=>u.addSheet$.subscribe(()=>{var W;(W=s.current.slideTabBar)==null||W.getScrollbar().scrollRight()}),k=W=>{const{leftEnd:V,rightEnd:re}=W;let q="";V&&re?q="":V&&!re?q="inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!V&&re?q="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!V&&!re&&(q="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2), inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)"),o(q)},ee=W=>{u.setScroll({leftEnd:W.isLeftEnd(),rightEnd:W.isRightEnd()})},te=W=>{var q;const V=(q=a.current)==null?void 0:q.querySelector(`.${ot.slideTabBar}`);if(!V)return;new ResizeObserver(()=>{ee(W)}).observe(V)};return S.jsx("div",{className:ot.slideTabBarContainer,ref:a,children:S.jsx("div",{className:ot.slideTabBar,style:{boxShadow:r},children:i.map(W=>X.createElement(tm,{...W,key:W.sheetId,selected:t===W.sheetId}))})})}const lo=100,am=()=>{const[i,e]=X.useState(!0),[t,n]=X.useState(!0),r=me.useDependency(l.ICommandService),o=me.useDependency(cn);X.useEffect(()=>{const u=o.scroll$.subscribe(h=>{s(h)});return()=>{u.unsubscribe()}},[]);const s=u=>{const{leftEnd:h,rightEnd:m}=u;e(h),n(m)},a=()=>{r.executeCommand(p.InsertSheetCommand.id),setTimeout(()=>{o.setAddSheet(0)},0)},c=()=>{o.setScrollX(-lo)},d=()=>{o.setScrollX(lo)};return S.jsxs("div",{className:Wn.sheetBar,children:[S.jsxs("div",{className:Wn.sheetBarOptions,children:[S.jsx(gi,{onClick:a,children:S.jsx(fl,{})}),S.jsx(Zh,{})]}),S.jsx(sm,{}),(!i||!t)&&S.jsxs("div",{className:`${Wn.sheetBarOptions} ${Wn.sheetBarOptionsDivider}`,children:[S.jsx(gi,{disabled:i,onClick:c,children:S.jsx(jr,{style:{transform:"rotateZ(180deg)"}})}),S.jsx(gi,{disabled:t,onClick:d,children:S.jsx(jr,{})})]})]})};class lm{constructor(){v(this,"_functions",[{func:Re.FUNCTION_NAMES_STATISTICAL.MAX,filter:e=>{var t,n;return(((t=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}},{func:Re.FUNCTION_NAMES_STATISTICAL.MIN,filter:e=>{var t,n;return(((t=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}},{func:Re.FUNCTION_NAMES_MATH.SUM,filter:e=>{var t,n;return(((t=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}},{func:Re.FUNCTION_NAMES_STATISTICAL.COUNTA,filter:e=>{var t;return(((t=e.values.find(n=>n.func===Re.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1}},{func:Re.FUNCTION_NAMES_STATISTICAL.COUNT,filter:e=>{var t,n;return(((t=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}},{func:Re.FUNCTION_NAMES_STATISTICAL.AVERAGE,filter:e=>{var t,n;return(((t=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}}]);v(this,"_state$",new J.BehaviorSubject(null));v(this,"state$",this._state$.asObservable())}dispose(){this._state$.complete()}setState(e){const t={values:[],pattern:null};e==null||e.values.forEach(n=>{const r=this._functions.find(o=>o.func===n.func);r&&(r.filter===void 0||r.filter(e))&&t.values.push(n)}),t.pattern=(e==null?void 0:e.pattern)??null,this._state$.next(t)}getState(){return this._state$.getValue()}getFunctions(){return this._functions}addFunctions(e){this._functions.push(...e)}}const Cr=j.createIdentifier("univer.sheet-status-bar.service");var Cs={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(typeof self<"u"?self:Ya,function(){return function(){var t={d:function(M,b){for(var T in b)t.o(b,T)&&!t.o(M,T)&&Object.defineProperty(M,T,{enumerable:!0,get:b[T]})},o:function(M,b){return Object.prototype.hasOwnProperty.call(M,b)}},n={};t.d(n,{default:function(){return bs}});var r={1078:"af",1052:"sq",1118:"am",5121:"ar_DZ",15361:"ar_BH",3073:"ar_EG",2049:"ar_IQ",11265:"ar_JO",13313:"ar_KW",12289:"ar_LB",4097:"ar_LY",6145:"ar_MA",8193:"ar_OM",16385:"ar_QA",1025:"ar_SA",10241:"ar_SY",7169:"ar_TN",14337:"ar_AE",9217:"ar_YE",1067:"hy",1101:"as",2092:"az_AZ",1068:"az_AZ",1069:"eu",1059:"be",2117:"bn",1093:"bn_IN",5146:"bs",1026:"bg",1109:"my",1027:"ca",2052:"zh_CN",3076:"zh_HK",5124:"zh_MO",4100:"zh_SG",1028:"zh_TW",1050:"hr",1029:"cs",1030:"da",1125:"dv",2067:"nl_BE",1043:"nl_NL",1126:"bin",3081:"en_AU",10249:"en_BZ",4105:"en_CA",9225:"en_CB",2057:"en_GB",16393:"en_IN",6153:"en_IE",8201:"en_JM",5129:"en_NZ",13321:"en_PH",7177:"en_ZA",11273:"en_TT",1033:"en_US",12297:"en_ZW",1061:"et",1071:"mk",1080:"fo",1065:"fa",1124:"fil",1035:"fi",2060:"fr_BE",11276:"fr_CM",3084:"fr_CA",9228:"fr_CG",12300:"fr_CI",1036:"fr_FR",5132:"fr_LU",13324:"fr_ML",6156:"fr_MC",14348:"fr_MA",10252:"fr_SN",4108:"fr_CH",7180:"fr",1122:"fy_NL",2108:"gd_IE",1084:"gd",1110:"gl",1079:"ka",3079:"de_AT",1031:"de_DE",5127:"de_LI",4103:"de_LU",2055:"de_CH",1032:"el",1140:"gn",1095:"gu",1279:"en",1037:"he",1081:"hi",1038:"hu",1039:"is",1136:"ig_NG",1057:"id",1040:"it_IT",2064:"it_CH",1041:"ja",1099:"kn",1120:"ks",1087:"kk",1107:"km",1111:"kok",1042:"ko",1088:"ky",1108:"lo",1142:"la",1062:"lv",1063:"lt",2110:"ms_BN",1086:"ms_MY",1100:"ml",1082:"mt",1112:"mni",1153:"mi",1102:"mr",1104:"mn",2128:"mn",1121:"ne",1044:"no_NO",2068:"no_NO",1096:"or",1045:"pl",1046:"pt_BR",2070:"pt_PT",1094:"pa",1047:"rm",2072:"ro_MO",1048:"ro_RO",1049:"ru",2073:"ru_MO",1083:"se",1103:"sa",3098:"sr_SP",2074:"sr_SP",1072:"st",1074:"tn",1113:"sd",1115:"si",1051:"sk",1060:"sl",1143:"so",1070:"sb",11274:"es_AR",16394:"es_BO",13322:"es_CL",9226:"es_CO",5130:"es_CR",7178:"es_DO",12298:"es_EC",17418:"es_SV",4106:"es_GT",18442:"es_HN",2058:"es_MX",19466:"es_NI",6154:"es_PA",15370:"es_PY",10250:"es_PE",20490:"es_PR",1034:"es_ES",14346:"es_UY",8202:"es_VE",1089:"sw",2077:"sv_FI",1053:"sv_SE",1114:"syc",1064:"tg",1097:"ta",1092:"tt",1098:"te",1054:"th",1105:"bo",1073:"ts",1055:"tr",1090:"tk",1058:"uk",1056:"ur",2115:"uz_UZ",1091:"uz_UZ",1075:"ve",1066:"vi",1106:"cy",1076:"xh",1085:"yi",1077:"zu"};const o=/^([a-z\d]+)(?:[_-]([a-z\d]+))?(?:\.([a-z\d]+))?(?:@([a-z\d]+))?$/i,s={},a={group:" ",decimal:".",positive:"+",negative:"-",percent:"%",exponent:"E",nan:"NaN",infinity:"∞",ampm:["AM","PM"],mmmm6:["Muharram","Safar","Rabiʻ I","Rabiʻ II","Jumada I","Jumada II","Rajab","Shaʻban","Ramadan","Shawwal","Dhuʻl-Qiʻdah","Dhuʻl-Hijjah"],mmm6:["Muh.","Saf.","Rab. I","Rab. II","Jum. I","Jum. II","Raj.","Sha.","Ram.","Shaw.","Dhuʻl-Q.","Dhuʻl-H."],mmmm:["January","February","March","April","May","June","July","August","September","October","November","December"],mmm:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dddd:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ddd:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]};function c(M){const b=o.exec(M);if(!b)throw new SyntaxError("Malformed locale: ".concat(M));return{lang:b[1]+(b[2]?"_"+b[2]:""),language:b[1],territory:b[2]||"",codeset:b[3]||"",modifier:b[4]||""}}function d(M){if(typeof M=="number")return r[65535&M]||null;const b=parseInt(M,16);return isFinite(b)&&r[65535&b]?r[65535&b]||null:o.test(M)?M:null}function u(M){const b=d(M);let T=null;if(b){const H=c(b);T=s[H.lang]||s[H.language]||null}return T}function h(M){return Object.assign({},a,M)}function m(M,b){const T=typeof b=="object"?b:c(b);return s[T.lang]=h(M),T.language===T.lang||s[T.language]||(s[T.language]=h(M)),s[T.lang]}const g=h({group:","});function _(M,b){if(typeof M!="number")return M;if(M<0)return-_(-M,b);if(b){const T=10**(b||0)||1;return _(M*T,0)/T}return Math.round(M)}g.isDefault=!0,m({group:",",ampm:["上午","下午"],mmmm:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],mmm:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],dddd:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],ddd:["周日","周一","周二","周三","周四","周五","周六"]},"zh_CN"),m({group:",",nan:"非數值",ampm:["上午","下午"],mmmm:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],mmm:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],dddd:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],ddd:["週日","週一","週二","週三","週四","週五","週六"]},"zh_TW"),m({group:",",ampm:["午前","午後"],mmmm:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],mmm:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],dddd:["日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日"],ddd:["日","月","火","水","木","金","土"]},"ja"),m({group:",",ampm:["오전","오후"],mmmm:["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"],mmm:["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"],dddd:["일요일","월요일","화요일","수요일","목요일","금요일","토요일"],ddd:["일","월","화","수","목","금","토"]},"ko"),m({group:",",ampm:["ก่อนเที่ยง","หลังเที่ยง"],mmmm:["มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม"],mmm:["ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค."],dddd:["วันอาทิตย์","วันจันทร์","วันอังคาร","วันพุธ","วันพฤหัสบดี","วันศุกร์","วันเสาร์"],ddd:["อา.","จ.","อ.","พ.","พฤ.","ศ.","ส."]},"th"),m({decimal:",",ampm:["dop.","odp."],mmmm:["ledna","února","března","dubna","května","června","července","srpna","září","října","listopadu","prosince"],mmm:["led","úno","bře","dub","kvě","čvn","čvc","srp","zář","říj","lis","pro"],dddd:["neděle","pondělí","úterý","středa","čtvrtek","pátek","sobota"],ddd:["ne","po","út","st","čt","pá","so"]},"cs"),m({group:".",decimal:",",mmmm:["januar","februar","marts","april","maj","juni","juli","august","september","oktober","november","december"],mmm:["jan.","feb.","mar.","apr.","maj","jun.","jul.","aug.","sep.","okt.","nov.","dec."],dddd:["søndag","mandag","tirsdag","onsdag","torsdag","fredag","lørdag"],ddd:["søn.","man.","tir.","ons.","tor.","fre.","lør."]},"da"),m({group:".",decimal:",",ampm:["a.m.","p.m."],mmmm:["januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"],mmm:["jan.","feb.","mrt.","apr.","mei","jun.","jul.","aug.","sep.","okt.","nov.","dec."],dddd:["zondag","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag"],ddd:["zo","ma","di","wo","do","vr","za"]},"nl"),m({group:","},"en"),m({decimal:",",nan:"epäluku",ampm:["ap.","ip."],mmmm:["tammikuuta","helmikuuta","maaliskuuta","huhtikuuta","toukokuuta","kesäkuuta","heinäkuuta","elokuuta","syyskuuta","lokakuuta","marraskuuta","joulukuuta"],mmm:["tammik.","helmik.","maalisk.","huhtik.","toukok.","kesäk.","heinäk.","elok.","syysk.","lokak.","marrask.","jouluk."],dddd:["sunnuntaina","maanantaina","tiistaina","keskiviikkona","torstaina","perjantaina","lauantaina"],ddd:["su","ma","ti","ke","to","pe","la"]},"fi"),m({group:" ",decimal:",",mmmm:["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"],mmm:["janv.","févr.","mars","avr.","mai","juin","juil.","août","sept.","oct.","nov.","déc."],dddd:["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"],ddd:["dim.","lun.","mar.","mer.","jeu.","ven.","sam."]},"fr"),m({group:".",decimal:",",mmmm:["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],mmm:["Jan.","Feb.","März","Apr.","Mai","Juni","Juli","Aug.","Sept.","Okt.","Nov.","Dez."],dddd:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],ddd:["So.","Mo.","Di.","Mi.","Do.","Fr.","Sa."]},"de"),m({group:".",decimal:",",ampm:["π.μ.","μ.μ."],mmmm:["Ιανουαρίου","Φεβρουαρίου","Μαρτίου","Απριλίου","Μαΐου","Ιουνίου","Ιουλίου","Αυγούστου","Σεπτεμβρίου","Οκτωβρίου","Νοεμβρίου","Δεκεμβρίου"],mmm:["Ιαν","Φεβ","Μαρ","Απρ","Μαΐ","Ιουν","Ιουλ","Αυγ","Σεπ","Οκτ","Νοε","Δεκ"],dddd:["Κυριακή","Δευτέρα","Τρίτη","Τετάρτη","Πέμπτη","Παρασκευή","Σάββατο"],ddd:["Κυρ","Δευ","Τρί","Τετ","Πέμ","Παρ","Σάβ"]},"el"),m({decimal:",",ampm:["de.","du."],mmmm:["január","február","március","április","május","június","július","augusztus","szeptember","október","november","december"],mmm:["jan.","febr.","márc.","ápr.","máj.","jún.","júl.","aug.","szept.","okt.","nov.","dec."],dddd:["vasárnap","hétfő","kedd","szerda","csütörtök","péntek","szombat"],ddd:["V","H","K","Sze","Cs","P","Szo"]},"hu"),m({group:".",decimal:",",ampm:["f.h.","e.h."],mmmm:["janúar","febrúar","mars","apríl","maí","júní","júlí","ágúst","september","október","nóvember","desember"],mmm:["jan.","feb.","mar.","apr.","maí","jún.","júl.","ágú.","sep.","okt.","nóv.","des."],dddd:["sunnudagur","mánudagur","þriðjudagur","miðvikudagur","fimmtudagur","föstudagur","laugardagur"],ddd:["sun.","mán.","þri.","mið.","fim.","fös.","lau."]},"is"),m({group:".",decimal:",",mmmm:["Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"],mmm:["Jan","Feb","Mar","Apr","Mei","Jun","Jul","Agu","Sep","Okt","Nov","Des"],dddd:["Minggu","Senin","Selasa","Rabu","Kamis","Jumat","Sabtu"],ddd:["Min","Sen","Sel","Rab","Kam","Jum","Sab"]},"id"),m({group:".",decimal:",",mmmm:["gennaio","febbraio","marzo","aprile","maggio","giugno","luglio","agosto","settembre","ottobre","novembre","dicembre"],mmm:["gen","feb","mar","apr","mag","giu","lug","ago","set","ott","nov","dic"],dddd:["domenica","lunedì","martedì","mercoledì","giovedì","venerdì","sabato"],ddd:["dom","lun","mar","mer","gio","ven","sab"]},"it"),m({decimal:",",ampm:["a.m.","p.m."],mmmm:["januar","februar","mars","april","mai","juni","juli","august","september","oktober","november","desember"],mmm:["jan.","feb.","mar.","apr.","mai","jun.","jul.","aug.","sep.","okt.","nov.","des."],dddd:["søndag","mandag","tirsdag","onsdag","torsdag","fredag","lørdag"],ddd:["søn.","man.","tir.","ons.","tor.","fre.","lør."]},"nb"),m({decimal:",",mmmm:["stycznia","lutego","marca","kwietnia","maja","czerwca","lipca","sierpnia","września","października","listopada","grudnia"],mmm:["sty","lut","mar","kwi","maj","cze","lip","sie","wrz","paź","lis","gru"],dddd:["niedziela","poniedziałek","wtorek","środa","czwartek","piątek","sobota"],ddd:["niedz.","pon.","wt.","śr.","czw.","pt.","sob."]},"pl"),m({group:".",decimal:",",mmmm:["janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"],mmm:["jan.","fev.","mar.","abr.","mai.","jun.","jul.","ago.","set.","out.","nov.","dez."],dddd:["domingo","segunda-feira","terça-feira","quarta-feira","quinta-feira","sexta-feira","sábado"],ddd:["dom.","seg.","ter.","qua.","qui.","sex.","sáb."]},"pt"),m({decimal:",",nan:"не число",mmmm:["января","февраля","марта","апреля","мая","июня","июля","августа","сентября","октября","ноября","декабря"],mmm:["янв.","февр.","мар.","апр.","мая","июн.","июл.","авг.","сент.","окт.","нояб.","дек."],dddd:["воскресенье","понедельник","вторник","среда","четверг","пятница","суббота"],ddd:["вс","пн","вт","ср","чт","пт","сб"]},"ru"),m({decimal:",",mmmm:["januára","februára","marca","apríla","mája","júna","júla","augusta","septembra","októbra","novembra","decembra"],mmm:["jan","feb","mar","apr","máj","jún","júl","aug","sep","okt","nov","dec"],dddd:["nedeľa","pondelok","utorok","streda","štvrtok","piatok","sobota"],ddd:["ne","po","ut","st","št","pi","so"]},"sk"),m({group:".",decimal:",",ampm:["a. m.","p. m."],mmmm:["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"],mmm:["ene.","feb.","mar.","abr.","may.","jun.","jul.","ago.","sept.","oct.","nov.","dic."],dddd:["domingo","lunes","martes","miércoles","jueves","viernes","sábado"],ddd:["dom.","lun.","mar.","mié.","jue.","vie.","sáb."]},"es"),m({decimal:",",ampm:["fm","em"],mmmm:["januari","februari","mars","april","maj","juni","juli","augusti","september","oktober","november","december"],mmm:["jan.","feb.","mars","apr.","maj","juni","juli","aug.","sep.","okt.","nov.","dec."],dddd:["söndag","måndag","tisdag","onsdag","torsdag","fredag","lördag"],ddd:["sön","mån","tis","ons","tors","fre","lör"]},"sv"),m({group:".",decimal:",",ampm:["ÖÖ","ÖS"],mmmm:["Ocak","Şubat","Mart","Nisan","Mayıs","Haziran","Temmuz","Ağustos","Eylül","Ekim","Kasım","Aralık"],mmm:["Oca","Şub","Mar","Nis","May","Haz","Tem","Ağu","Eyl","Eki","Kas","Ara"],dddd:["Pazar","Pazartesi","Salı","Çarşamba","Perşembe","Cuma","Cumartesi"],ddd:["Paz","Pzt","Sal","Çar","Per","Cum","Cmt"]},"tr");function f(M,b,T){const H=M<0?-1:1,F=10**(b||2),Y=10**(T||2);let B,U,A=Math.abs(M),K=0,oe=0,z=0,se=1;if((M=A)%1==0)U=[M*H,1];else if(M<1e-19)U=[H,1e19];else if(M>1e19)U=[1e19*H,1];else{do if(A=1/(A-Math.floor(A)),B=se,se=se*Math.floor(A)+K,K=B,oe=z,z=Math.floor(M*se+.5),z>=F||se>=Y)return[H*oe,K];while(Math.abs(M-z/se)>=1e-10&&A!==Math.floor(A));U=[H*z,se]}return U}const C={overflow:"######",dateErrorThrows:!1,dateErrorNumber:!0,dateSpanLarge:!0,leap1900:!0,nbsp:!0,throws:!0,invalid:"######",locale:"",ignoreTimezone:!1},I=Object.assign({},C);function w(M){if(M===null&&(M=C),M){for(const b in M)if(b in C){const T=M[b];I[b]=T??C[b]}}return{...I}}const E={"#":"",0:"0","?":" "},O={"@":"text","-":"minus","+":"plus"},x=["#000","#FFF","#F00","#0F0","#00F","#FF0","#F0F","#0FF","#000","#FFF","#F00","#0F0","#00F","#FF0","#F0F","#0FF","#800","#080","#008","#880","#808","#088","#CCC","#888","#99F","#936","#FFC","#CFF","#606","#F88","#06C","#CCF","#008","#F0F","#FF0","#0FF","#808","#800","#088","#00F","#0CF","#CFF","#CFC","#FF9","#9CF","#F9C","#C9F","#FC9","#36F","#3CC","#9C0","#FC0"],N=["¤","$","£","¥","֏","؋","৳","฿","៛","₡","₦","₩","₪","₫","€","₭","₮","₱","₲","₴","₸","₹","₺","₼","₽","₾","₿"],D=new RegExp("["+N.join("")+"]");function P(M,b,T){return b[T+"_max"]=M.length,b[T+"_min"]=M.replace(/#/g,"").length,b}const L={};function G(M){if(!(M in L)){const b=[],T=M.replace(/^[#,]+/,"").replace(/[1-9]\d*/g,H=>"?".repeat(H.length));for(let H=0;H<T.length;H++){const F=T.charAt(H);b[H]=F in E?E[F]:F}L[M]=b.join("")}return L[M]}function k(M,b){typeof M=="string"&&(M={type:"string",value:M=M.replace(/ /g,E["?"])}),b.push(M)}function ee(M){const b=[],T={scale:1,percent:!1,text:!1,date:0,date_eval:!1,date_system:1,sec_decimals:0,general:!1,clock:24,int_pattern:[],frac_pattern:[],man_pattern:[],den_pattern:[],num_pattern:[],tokens:b};let H=M+"",F="int",Y=!1,B=null;const U=[];let A,K,oe=!1;for(;H&&!Y;){if(A=/^General/i.exec(H))T.general=!0,k({type:"general"},b);else if(F==="int"&&(A=/^[#?0]+(?:,[#?0]+)*/.exec(H))||F==="den"&&(A=/^[#?\d]+/.exec(H))||(A=/^[#?0]+/.exec(H)))T[F+"_pattern"].push(A[0]),B={type:F,num:A[0]},k(B,b);else if((A=/^\//.exec(H))&&T[F+"_pattern"].length){if(!B)throw new SyntaxError("Missing a numerator in pattern ".concat(M));T.fractions=!0,T.num_pattern.push(T[F+"_pattern"].pop()),B.type="num",F="den",k({type:"div"},b)}else if(A=/^,+/.exec(H)){const $=H.charAt(1)in E;K.slice(-1)in E&&(A[0].length>1||!$)?T.scale=.001**A[0].length:T.dec_fractions||k(A[0],b)}else{if(A=/^;/.exec(H)){Y=!0;break}if(A=/^[@+-]/.exec(H))A[0]==="@"&&(T.text=!0),k({type:O[A[0]]},b);else if(A=/^(?:\[(h+|m+|s+)\])/i.exec(H)){const $=A[1].toLowerCase(),ie=$[0],ce={type:"",size:0,date:1,raw:A[0],pad:$.length};ie==="h"?(ce.size=16,ce.type="hour-elap"):ie==="m"?(ce.size=32,ce.type="min-elap"):(ce.size=64,ce.type="sec-elap"),T.date=T.date|ce.size,U.push(ce),k(ce,b)}else if(A=/^(?:B2)/i.exec(H))oe||(T.date_system=6);else if(A=/^(?:B1)/i.exec(H))oe||(T.date_system=1);else if(A=/^(?:([hHmMsSyYbBdDegG])\1*)/.exec(H)){const $={type:"",size:0,date:1,raw:A[0]},ie=A[0].toLowerCase(),ce=ie[0];if(ie==="y"||ie==="yy")$.size=2,$.type="year-short";else if(ce==="y"||ce==="e")$.size=2,$.type="year";else if(ie==="b"||ie==="bb")$.size=2,$.type="b-year-short";else if(ce==="b")$.size=2,$.type="b-year";else if(ie==="d"||ie==="dd")$.size=8,$.type="day",$.pad=/dd/.test(ie);else if(ie==="ddd")$.size=8,$.type="weekday-short";else if(ce==="d")$.size=8,$.type="weekday";else if(ce==="h")$.size=16,$.type="hour",$.pad=/hh/i.test(ie);else if(ce==="m"){ie.length===3?($.size=4,$.type="monthname-short"):ie.length===5?($.size=4,$.type="monthname-single"):ie.length>=4&&($.size=4,$.type="monthname");const _e=U[U.length-1];!$.type&&_e&&!_e.used&&80&_e.size&&(_e.used=!0,$.size=32,$.type="min",$.pad=/mm/.test(ie)),$.type||($.size=4,$.type="month",$.pad=/mm/.test(ie),$.indeterminate=!0)}else if(ce==="s"){$.size=64,$.type="sec",$.pad=/ss/.test(ie);const _e=U[U.length-1];_e&&32&_e.size?$.used=!0:_e&&_e.indeterminate&&(delete _e.indeterminate,_e.size=32,_e.type="min",$.used=!0)}T.date=T.date|$.size,T.date_eval=!0,U.push($),k($,b)}else if(A=/^(?:AM\/PM|am\/pm|A\/P)/.exec(H))T.clock=12,T.date=16|T.date,T.date_eval=!0,k({type:"am",short:A[0]==="A/P"},b);else if(T.date&&(A=/^\.0{1,3}/i.exec(H))){const $=A[0].length-1,ie=[64,128,256,512][$];T.date=T.date|ie,T.date_eval=!0,T.sec_decimals=Math.max(T.sec_decimals,$),k({type:"subsec",size:ie,decimals:$,date:1,raw:A[0]},b)}else if((A=/^\\(.)/.exec(H))||(A=/^"([^"]*?)"/.exec(H)))k(A[1],b);else if(A=/^\[(<[=>]?|>=?|=)\s*(-?[.\d]+)\]/.exec(H))T.condition=[A[1],parseFloat(A[2],10)];else if(A=/^\[\$([^\]]+)\]/.exec(H)){const $=A[1].split("-"),ie=$.length<2?"":$[$.length-1],ce=$[0];ce&&k(ce,b);const _e=d(ie);_e&&(T.locale=_e);const Ce=parseInt(ie,16);isFinite(Ce)&&16711680&Ce&&(Ce>>16&255)===6&&(T.date_system=6),oe=!0}else if(A=/^\[(black|blue|cyan|green|magenta|red|white|yellow|color\s*(\d+))\]/i.exec(H))T.color=A[2]?x[parseInt(A[2],10)]||"#000":A[1].toLowerCase();else if(!(A=/^\[(DBNum1|ENG|HIJ|JPN|TWN)\]/i.exec(H))){if(A=/^%/.exec(H))T.scale=100,T.percent=!0,k("%",b);else if(A=/^_(\\.|.)/.exec(H))k(" ",b);else if(A=/^\./.exec(H))k({type:"point",value:A[0]},b),T.dec_fractions=!0,F="frac";else if(A=/^[Ee]([+-]?|(?=[0#?]))/.exec(H))T.exponential=!0,T.exp_plus=A[1]==="+",F="man",k({type:"exp",plus:A[1]==="+"},b);else if(!(A=/^\*(\\.|.)/.exec(H))){if(A=/^[BENn[]/.exec(H))throw new SyntaxError("Unexpected char ".concat(H.charAt(0)," in pattern ").concat(M));H[0]==="("&&(T.parens=!0),A=[H[0]],k(A[0],b)}}}K=A[0],H=H.slice(A?A[0].length:1)}if(T.pattern=M.slice(0,M.length-H.length),/^((?:\[[^\]]+\])+)(;|$)/.test(T.pattern)&&!/^\[(?:h+|m+|s+)\]/.test(T.pattern)&&k({type:"text"},b),T.fractions&&T.dec_fractions||T.fractions&&T.exponential)throw new SyntaxError("Invalid pattern: ".concat(T.pattern));const z=T.int_pattern.join("");if(T.grouping=z.indexOf(",")>=0,T.grouping){const $=z.split(","),ie=$.length;ie===2?(T.group_pri=$[1].length,T.group_sec=T.group_pri):ie>2&&(T.group_pri=$[ie-1].length,T.group_sec=$[ie-2].length)}else T.group_pri=0,T.group_sec=0;P(z.replace(/[,]/g,""),T,"int"),P(T.frac_pattern.join(""),T,"frac"),P(T.man_pattern.join(""),T,"man");let se=T.num_pattern.join(""),ue=T.den_pattern.join("");const le=/\?/.test(ue)||/\?/.test(se);return ue=ue.replace(/\d/g,le?"?":"#"),le&&(ue=ue.replace(/#$/g,"?")),P(se,T,"num"),P(ue,T,"den"),le&&(se=se.replace(/#$/g,"?")),T.int_padding=G(T.int_pattern.join("")),T.man_padding=G(T.man_pattern.join("")),T.num_padding=G(se),T.den_padding=G(ue),T.den_pattern.length&&(T.denominator=parseInt(T.den_pattern.join("").replace(/\D/g,""),10)),T.integer=!!T.int_pattern.join("").length,T.fractions&&b.forEach(($,ie)=>{const ce=b[ie+1];$.type==="string"&&ce&&(ce.type==="num"?$.rule="num+int":ce.type==="div"?$.rule="num":ce.type==="den"&&($.rule="den"))}),T}const te=M=>{const b=M.condition;b&&b[1]<0&&(b[0]==="<"||b[0]==="<="||b[0]==="=")||M.tokens.unshift({type:"minus",volatile:!0})};function W(M){const b=[];let T,H=!1,F=null,Y=M,B=0,U=!1,A=0,K=0;do{if(U=ee(Y),(U.date||U.general)&&(U.int_pattern.length||U.frac_pattern.length||U.scale!==1||U.text))throw new Error("Illegal format");if(U.condition&&(K++,H=!0),U.text){if(F)throw new Error("Unexpected partition");F=U}U.locale&&(T=d(U.locale)),b.push(U),B=Y.charAt(U.pattern.length)===";"?1:0,Y=Y.slice(U.pattern.length+B),A++}while(B&&A<4&&K<3);if(B)throw new Error("Unexpected partition");if(K>2)throw new Error("Unexpected condition");const oe=b[3];if(oe&&(oe.int_pattern.length||oe.frac_pattern.length||oe.date))throw new Error("Unexpected partition");if(H){const z=b.length;if(z===1&&(b[1]=ee("General"),b[1].generated=!0),z<3){const se=b[0],ue=b[1];if(te(se),ue.condition)te(ue);else{const le=se.condition;(le[0]==="="||le[1]>=0&&(le[0]===">"||le[0]===">="))&&ue.tokens.unshift({type:"minus",volatile:!0})}}else b.forEach(te)}else{if(b.length<4&&F)for(let z=0,se=b.length;z<se;z++)b[z]===F&&b.splice(z,1);if(b.length<1&&F&&(b[0]=ee("General"),b[0].generated=!0),b.length<2){const z=ee(b[0].pattern);z.tokens.unshift({type:"minus",volatile:!0}),z.generated=!0,b.push(z)}if(b.length<3){const z=ee(b[0].pattern);z.generated=!0,b.push(z)}if(b.length<4)if(F)b.push(F);else{const z=ee("@");z.generated=!0,b.push(z)}b[0].condition=[">",0],b[1].condition=["<",0],b[2].condition=null}return{pattern:M,partitions:b,locale:T}}const V=Math.floor;function re(M){if((!(arguments.length>1&&arguments[1]!==void 0)||arguments[1])&&M>=0){if(M===0)return[1900,1,0];if(M===60)return[1900,2,29];if(M<60)return[1900,M<32?1:2,(M-1)%31+1]}let T=M+68569+2415019;const H=V(4*T/146097);T-=V((146097*H+3)/4);const F=V(4e3*(T+1)/1461001);T=T-V(1461*F/4)+31;const Y=V(80*T/2447),B=T-V(2447*Y/80);T=V(Y/11);const U=Y+2-12*T;return[0|100*(H-49)+F+T,0|U,0|B]}function q(M){return re(M+1462)}function ae(M){if(M===60)throw new Error("#VALUE!");if(M<=1)return[1317,8,29];if(M<60)return[1317,M<32?9:10,1+(M-2)%30];const b=10631/30,T=.1335;let H=M+466935;const F=V(H/10631);H-=10631*F;const Y=V((H-T)/b);H-=V(Y*b+T);const B=V((H+28.5001)/29.5);return B===13?[30*F+Y,12,30]:[30*F+Y,B,H-V(29.5001*B-29)]}function Ie(M){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,T=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];const H=V(M);return b===6?ae(H):b===-1?q(H):re(H,T)}const de=Math.floor,Ee=86400;function be(M,b){let T=null;if(Array.isArray(M)){const[H,F,Y,B,U,A]=M;T=Date.UTC(H,F==null?0:F-1,Y??1,B||0,U||0,A||0)}else if(M instanceof Date&&(T=1*M,!b||!b.ignoreTimezone)){const H=new Date;H.setUTCFullYear(M.getFullYear(),M.getMonth(),M.getDate()),H.setUTCHours(M.getHours(),M.getMinutes(),M.getSeconds(),M.getMilliseconds()),T=1*H}if(T!=null&&isFinite(T)){const H=T/864e5;return H-(H<=-25509?-25568:-25569)}return M}function De(M,b){let T=0|M;const H=Ee*(M-T);let F=de(H);H-F>.9999&&(F+=1,F===Ee&&(F=0,T+=1));const Y=F<0?Ee+F:F,[B,U,A]=Ie(M,0,b&&b.leap1900),K=de(Y/60/60)%60,oe=de(Y/60)%60,z=de(Y)%60;if(b&&b.nativeDate){const se=new Date(0);return se.setUTCFullYear(B,U-1,A),se.setUTCHours(K,oe,z),se}return[B,U,A,K,oe,z]}function Oe(M){return!!(M[0]&&M[0].percent||M[1]&&M[1].percent||M[2]&&M[2].percent||M[3]&&M[3].percent)}function Le(M){return!!(M[0]&&M[0].date||M[1]&&M[1].date||M[2]&&M[2].date||M[3]&&M[3].date)}function Se(M){const[b,T,H,F]=M;return!(b&&!b.generated||T&&!T.generated||H&&!H.generated||!F||!F.text||F.generated)}const he={text:15,datetime:10.8,date:10.8,time:10.8,percent:10.6,currency:10.4,grouped:10.2,scientific:6,number:4,fraction:2,general:0,error:0},ge=[["DMY",1],["DM",2],["MY",3],["MDY",4],["MD",5],["hmsa",6],["hma",7],["hms",8],["hm",9]],Ae={total:1,sign:0,period:0,int:1,frac:0},we=(M,b)=>M.replace(/\./,b.decimal);function Pe(M,b,T,H){const F=0|T;if(typeof T=="string")M.push(T);else if(T===F)M.push(Math.abs(F));else{const Y=Math.abs(T);let B=Y?Math.floor(Math.log10(Y)):0,U=B<0?Y*10**-B:Y/10**B;U===10&&(U=1,B++);const A=function(oe){let z=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];const se=Math.abs(oe);if(!se)return Ae;const ue=z&&oe<0?1:0,le=Math.floor(se),$=Math.floor(Math.log10(se)+1);let ie=0,ce=0;if(le!==se){ie=1;const _e=String(_($<0?se*10**-$:se/10**$,15));let Ce=_e.length,ve=!0,je=0;for(;je<=_e.length;){if(_e[je]==="."){Ce--;break}_e[je]==="0"&&ve?Ce--:ve=!1,je++}ce=Ce-$,ce<0&&(ce=0,ie=0)}return{total:ue+Math.max($,1)+ie+ce,digits:Math.max($,0)+ce,sign:ue,period:ie,int:Math.max($,1),frac:ce}}(Y),K=()=>{const oe=Math.abs(B);let z;z=U===1?U:_(U,5),M.push(we(z+"",H),H.exponent,B<0?H.negative:H.positive,oe<10?"0":"",oe)};if(B>=-4&&B<=-1){const oe=Y.toPrecision(10+B).replace(/\.?0+$/,"");M.push(we(oe,H))}else if(B===10){const oe=Y.toFixed(10).slice(0,12).replace(/\.$/,"");M.push(we(oe,H))}else if(Math.abs(B)<=9)if(A.total<=11){const oe=_(Y,9).toFixed(A.frac);M.push(we(oe,H))}else B===9?M.push(Math.floor(Y)):B>=0&&B<9?M.push(_(Y,9-B)):K();else A.total>=12?K():Math.floor(Y)===Y?M.push(Math.floor(Y)):M.push(we(_(Y,9).toFixed(A.frac),H))}return M}const Ue=86400,Ne={int:"integer",frac:"fraction",man:"mantissa",num:"numerator",den:"denominator"},it=function(M){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;const T=Math.floor(Math.log10(M));return b>1?Math.floor(T/b)*b:T};function Fe(M,b,T,H){let F="",Y="",B="",U="",A="",K=0,oe=0|M,z=0,se=0,ue=1,le=0,$=0,ie=0,ce=0,_e=0,Ce=0;const ve=H||g;if(!b.text&&isFinite(b.scale)&&b.scale!==1&&(M=function(fe){if(fe===0)return fe;const Me=Math.ceil(Math.log10(fe<0?-fe:fe)),Z=10**(16-Math.floor(Me));return Math.round(fe*Z)/Z}(M*b.scale)),b.exponential){let fe=Math.abs(M);if(fe){const Me=10**-it(fe,b.int_max),Z=_(fe*Me,b.frac_max)/Me;K=it(Z,b.int_max)}fe/=10**K,M=M<0?-fe:fe,F+=Math.abs(K)}if(b.integer){const fe=Math.abs(_(M,b.fractions?1:b.frac_max));A+=fe<1?"":Math.floor(fe)}if(b.grouping){let fe="",Me=A.length;for(Me>b.group_pri&&(Me-=b.group_pri,fe=ve.group+A.slice(Me,Me+b.group_pri)+fe);Me>b.group_sec;)Me-=b.group_sec,fe=ve.group+A.slice(Me,Me+b.group_sec)+fe;A=Me?A.slice(0,Me)+fe:fe}b.dec_fractions&&(U=String(_(M,b.frac_max)).split(".")[1]||"");let je=!1;if(b.fractions){const fe=Math.abs(b.integer?M%1:M);if(fe)if(je=!0,isFinite(b.denominator))B+=b.denominator,Y+=_(fe*b.denominator),Y==="0"&&(Y="",B="",je=!1,A||(A="0"));else{const Me=f(fe,b.integer?b.num_max:1/0,b.den_max);Y+=Me[0],B+=Me[1],b.integer&&Y==="0"&&(A||(A="0"),Y="",B="",je=!1)}}if(b.date){oe=Math.trunc(M);const fe=Ue*(M-oe);if(z=Math.floor(fe),Ce=fe-z,Math.abs(Ce)<1e-6?Ce=0:Ce>.9999&&(Ce=0,z+=1,z===Ue&&(z=0,oe+=1)),Ce){const Me=512&b.date||256&b.date||128&b.date;(Me===512&&Ce>.9995||Me===256&&Ce>.995||Me===128&&Ce>.95||!Me&&Ce>=.5)&&(z++,Ce=0)}if(oe||b.date_system){const Me=Ie(M,b.date_system,T.leap1900);se=Me[0],ue=Me[1],le=Me[2]}if(z){const Me=z<0?Ue+z:z;_e=Math.floor(Me)%60,ce=Math.floor(Me/60)%60,ie=Math.floor(Me/60/60)%60}if($=(6+oe)%7,b.date_eval&&(St=M,Dt=oe+z/Ue,T.dateSpanLarge?St<-694324||Dt>=35830291:St<0||Dt>=2958466)){if(T.dateErrorThrows)throw new Error("Date out of bounds");return T.dateErrorNumber?Pe(M<0?[ve.negative]:[],0,M,ve).join(""):T.overflow}}var St,Dt;if(b.int_padding&&(A=b.int_padding.length===1?A||b.int_padding:b.int_padding.substring(0,b.int_padding.length-A.length)+A),b.num_padding&&(Y=b.num_padding.length===1?Y||b.num_padding:b.num_padding.substring(0,b.num_padding.length-Y.length)+Y),b.den_padding&&(B=b.den_padding.length===1?B||b.den_padding:B+b.den_padding.slice(B.length)),b.man_padding){const fe=b.exp_plus?"+":"";F=b.man_padding.length===1?(K<0?"-":fe)+(F||b.man_padding):(K<0?"-":fe)+b.man_padding.slice(0,b.man_padding.length-F.length)+F}const ne=[];let et=0;const wt={int:0,frac:0,man:0,num:0,den:0};for(let fe=0,Me=b.tokens.length;fe<Me;fe++){const Z=b.tokens[fe],Ln=Z.num?Z.num.length:0;if(Z.type==="string")Z.rule?Z.rule==="num"?je?ne.push(Z.value):(b.num_min>0||b.den_min>0)&&ne.push(Z.value.replace(/./g,E["?"])):Z.rule==="num+int"?je&&A?ne.push(Z.value):b.den_min>0&&(A||b.num_min)&&ne.push(Z.value.replace(/./g,E["?"])):Z.rule==="den"&&(je?ne.push(Z.value):(b.den_min>0||b.den_min>0)&&ne.push(Z.value.replace(/./g,E["?"]))):ne.push(Z.value);else if(Z.type==="error")ne.push(T.invalid);else if(Z.type==="point")ne.push(b.date?Z.value:ve.decimal);else if(Z.type==="general")Pe(ne,0,M,ve);else if(Z.type==="exp")ne.push(ve.exponent);else if(Z.type==="minus")Z.volatile&&b.date||Z.volatile&&(M>=0||typeof M!="number")||(Z.volatile&&!b.fractions&&(b.integer||b.dec_fractions)?(M<0&&A&&A!=="0"||U)&&ne.push(ve.negative):ne.push(ve.negative));else if(Z.type==="plus")ne.push(ve.positive);else if(Z.type==="text")ne.push(M);else if(Z.type==="div")je?ne.push("/"):b.num_min>0||b.den_min>0?ne.push(E["?"]):ne.push(E["#"]);else if(Z.type==="int")if(b.int_pattern.length===1)ne.push(A);else{const ke=et?b.int_pattern.join("").length-wt.int:1/0,Wt=et===b.int_pattern.length-1?0:b.int_pattern.join("").length-(wt.int+Z.num.length);ne.push(A.substring(A.length-ke,A.length-Wt)),et++,wt.int+=Z.num.length}else if(Z.type==="frac"){const ke=wt.frac;for(let Wt=0;Wt<Ln;Wt++)ne.push(U[Wt+ke]||E[Z.num[Wt]]);wt.frac+=Ln}else if(Z.type in Ne)b[Z.type+"_pattern"].length===1?(Z.type==="int"&&ne.push(A),Z.type==="frac"&&ne.push(U),Z.type==="man"&&ne.push(F),Z.type==="num"&&ne.push(Y),Z.type==="den"&&ne.push(B)):(ne.push(Ne[Z.type].slice(wt[Z.type],wt[Z.type]+Ln)),wt[Z.type]+=Ln);else if(Z.type==="year")se<0&&ne.push(ve.negative),ne.push(String(Math.abs(se)).padStart(4,"0"));else if(Z.type==="year-short"){const ke=se%100;ne.push(ke<10?"0":"",ke)}else if(Z.type==="month")ne.push(Z.pad&&ue<10?"0":"",ue);else if(Z.type==="monthname-single")b.date_system===6?ne.push(ve.mmmm6[ue-1].charAt(0)):ne.push(ve.mmmm[ue-1].charAt(0));else if(Z.type==="monthname-short")b.date_system===6?ne.push(ve.mmm6[ue-1]):ne.push(ve.mmm[ue-1]);else if(Z.type==="monthname")b.date_system===6?ne.push(ve.mmmm6[ue-1]):ne.push(ve.mmmm[ue-1]);else if(Z.type==="weekday-short")ne.push(ve.ddd[$]);else if(Z.type==="weekday")ne.push(ve.dddd[$]);else if(Z.type==="day")ne.push(Z.pad&&le<10?"0":"",le);else if(Z.type==="hour"){const ke=ie%b.clock||(b.clock<24?b.clock:0);ne.push(Z.pad&&ke<10?"0":"",ke)}else if(Z.type==="min")ne.push(Z.pad&&ce<10?"0":"",ce);else if(Z.type==="sec")ne.push(Z.pad&&_e<10?"0":"",_e);else if(Z.type==="subsec"){ne.push(ve.decimal);const ke=Ce.toFixed(b.sec_decimals);ne.push(ke.slice(2,2+Z.decimals))}else if(Z.type==="am"){const ke=ie<12?0:1;Z.short&&!H?ne.push("AP"[ke]):ne.push(ve.ampm[ke])}else if(Z.type==="hour-elap"){M<0&&ne.push(ve.negative);const ke=24*oe+Math.floor(Math.abs(z)/3600);ne.push(String(Math.abs(ke)).padStart(Z.pad,"0"))}else if(Z.type==="min-elap"){M<0&&ne.push(ve.negative);const ke=1440*oe+Math.floor(Math.abs(z)/60);ne.push(String(Math.abs(ke)).padStart(Z.pad,"0"))}else if(Z.type==="sec-elap"){M<0&&ne.push(ve.negative);const ke=oe*Ue+Math.abs(z);ne.push(String(Math.abs(ke)).padStart(Z.pad,"0"))}else if(Z.type==="b-year")ne.push(se+543);else if(Z.type==="b-year-short"){const ke=(se+543)%100;ne.push(ke<10?"0":"",ke)}}return T.nbsp?ne.join(""):ne.join("").replace(/\u00a0/g," ")}function pt(M,b){for(let T=0;T<3;T++){const H=b[T];if(H){let F;if(H.condition){const Y=H.condition[0],B=H.condition[1];Y==="="?F=M===B:Y===">"?F=M>B:Y==="<"?F=M<B:Y===">="?F=M>=B:Y==="<="?F=M<=B:Y==="<>"&&(F=M!==B)}else F=!0;if(F)return H}}}const ft=ee("@"),$e="black",Ve={};function He(M,b){if(M){const T=M[0];b[T]=b[T]||{},He(M.slice(1),b[T])}else b.$=!0}["d-F-y","d-F-Y","d-M-y","d-M-Y","F-d-y","F-d-Y","F-j-y","F-j-Y","j-F-y","j-F-Y","j-M-y","j-M-Y","M-d-y","M-d-Y","M-j-y","M-j-Y","m-d-y","m-d-Y","m-j-y","m-j-Y","n-d-y","n-d-Y","n-j-y","n-j-Y","y-F-d","y-F-j","y-M-d","y-M-j","Y-F-d","Y-F-j","Y-M-d","Y-m-d","Y-M-j","Y-m-j","Y-n-d","Y-n-j","j-F","j-M","d-F","d-M","n-d","n-j","n-Y","m-d","m-j","m-Y","M-Y","M-y","F-y","F-Y","Y-M","Y-n","Y-m","Y-F","Y-M"].forEach(M=>{He(M,Ve),He(M+" x",Ve),He(M+" l",Ve),He(M+" l x",Ve),He("l "+M,Ve),He("l "+M+" x",Ve),He(M+" D",Ve),He(M+" D x",Ve),He("D "+M,Ve),He("D "+M+" x",Ve)});const Qe={jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12},dn={january:1,february:2,march:3,april:4,june:6,july:7,august:8,september:9,october:10,november:11,december:12},un={sunday:"l",monday:"l",tuesday:"l",wednesday:"l",thursday:"l",friday:"l",saturday:"l",sun:"D",mon:"D",tue:"D",wed:"D",thu:"D",fri:"D",sat:"D"},Rs=new Date().getUTCFullYear();function br(M){const b=new RegExp("^([\\s+%"+N.join("")+"(-]*)(((?:(?:\\d[\\d,]*)(?:\\.\\d*)?|(?:\\.\\d+)))([eE][+-]?\\d+)?)([\\s%"+N.join("")+")]*)$").exec(M);if(b){const[,T,H,F,Y,B]=b;let U=1,A="",K=!1,oe=!1,z=!1,se=!1,ue=!1,le=null,$=!1,ie=parseFloat(H.replace(/,/g,""));if(!isFinite(ie))return null;for(let _e=0;_e<T.length;_e++){const Ce=T[_e];if(Ce==="-"){if(K||oe)return null;K=!0,U=-1}else if(D.test(Ce)){if(ue)return null;ue=!0,le=Ce}else if(Ce==="("){if(oe||K)return null;oe=!0,U=-1}else if(Ce==="%"){if(se)return null;se=!0}}for(let _e=0;_e<B.length;_e++){const Ce=B[_e];if(D.test(Ce)){if(ue)return null;ue=!0,le=Ce,$=!0}else if(Ce===")"){if(z||!oe)return null;z=!0}else if(Ce==="%"){if(se)return null;se=!0}}if(Y){if(se||ue)return null;A="0.00E+00"}else if(se){if(ue)return null;A=F.includes(".")?"0.00%":"0%",ie*=.01}else if(ue){const _e=F.includes(".")?"#,##0.00":"#,##0";A=$?_e+le:le+_e}else F.includes(",")&&(A=F.includes(".")?"#,##0.00":"#,##0");const ce={v:ie*U};return A&&(ce.z=A),ce}}const lt=(M,b,T)=>{const H=T.path||"",F=Object.keys(b);for(let Y=0;Y<F.length;Y++){let B;const U=F[Y];if(b[U]){if(U==="$"||U==="€")M||(B=T);else if(U==="-"){const A=/^(\s*([./-]|,\s)\s*|\s+)/.exec(M);if(A){const K=A[1]==="-"||A[1]==="/"||A[1]==="."?A[1]:" ";if(!T.sep||T.sep===K){const oe=A[0].replace(/\s+/g," ");B=lt(M.slice(A[0].length),b[U],{...T,sep:K,path:H+oe})}}}else if(U===" "){const A=/^[,.]?\s+/.exec(M);if(A){const K=A[0].replace(/\s+/g," ");B=lt(M.slice(A[0].length),b[U],{...T,path:H+K})}}else if(U==="j"||U==="d"){const A=/^(0?[1-9]|1\d|2\d|3[01])\b/.exec(M);A&&(B=lt(M.slice(A[0].length),b[U],{...T,day:A[0],path:H+U}))}else if(U==="n"||U==="m"){const A=/^(0?[1-9]|1[012])\b/.exec(M);A&&(B=lt(M.slice(A[0].length),b[U],{...T,month:+A[0],_mon:A[0],path:H+U}))}else if(U==="F"||U==="M"){const A=/^([a-z]{3,9})\b/i.exec(M),K=A&&(U==="F"?dn:Qe)[A[0].toLowerCase()];K&&(B=lt(M.slice(A[0].length),b[U],{...T,month:K,_mon:A[0],path:H+U}))}else if(U==="l"||U==="D"){const A=/^([a-z]{3,9})\b/i.exec(M);(A&&un[A[0].toLowerCase()])===U&&(B=lt(M.slice(A[0].length),b[U],{...T,path:H+U}))}else if(U==="y"){const A=/^\d\d\b/.exec(M);if(A){const K=+A[0]>=30?+A[0]+1900:+A[0]+2e3;B=lt(M.slice(A[0].length),b[U],{...T,year:K,path:H+U})}}else if(U==="Y"){const A=/^\d\d\d\d\b/.exec(M);A&&(B=lt(M.slice(A[0].length),b[U],{...T,year:+A[0],path:H+U}))}else{if(U!=="x")throw new Error('Unknown date token "'.concat(U,'"'));{const A=Di(M);A&&(B=lt("",b[U],{...T,time:A.v,tf:A.z,path:H+U}))}}if(B)return B}}};function Mr(M,b){const T=lt(M.trim(),Ve,{path:""});if(T){var H;if(T.sep==="."&&T.path.length===3)return null;const F=+((H=T.year)!==null&&H!==void 0?H:Rs);if(T.day||(T.day=1),!function(U,A,K){if(K<1||A<1||A>12)return!1;if(A===2){if(K>(U%4==0&&U%100!=0||U%400==0||U===1900?29:28))return!1}else if((A===4||A===6||A===9||A===11)&&K>30||(A===1||A===3||A===5||A===7||A===8||A===10||A===12)&&K>31)return!1;return!0}(F,T.month,T.day))return null;let Y=-1/0;if(F<1900)return null;F<=1900&&T.month<=2?Y=25568:F<1e4&&(Y=25569);const B=Date.UTC(F,T.month-1,T.day)/864e5+Y+(T.time||0);if(B>=0&&B<=2958465){const U=T._mon[0]==="0"||T.day[0]==="0"||T._mon.length===2&&T.day.length===2,A=T.path.replace(/[jdlDnmMFyYx-]/g,K=>K==="j"||K==="d"?U?"dd":"d":K==="D"?"ddd":K==="l"?"dddd":K==="n"||K==="m"?U?"mm":"m":K==="M"?"mmm":K==="F"?"mmmm":K==="y"?"yy":K==="x"?T.tf||"":K==="Y"?"yyyy":K);return b&&b.nativeDate?{v:De(B,b),z:A}:{v:B,z:A}}}return null}function Di(M){const b=/^\s*([10]?\d|2[0-4])(?::([0-5]\d|\d))?(?::([0-5]\d|\d))?(\.\d{1,10})?(?:\s*([AP])M?)?\s*$/i.exec(M);if(b){const[,T,H,F,Y,B]=b;if(Y&&!F||!B&&!H&&!F)return null;let U=1*(T||0);if(B){if(U>=13)return null;B[0]!=="p"&&B[0]!=="P"||(U+=12)}return{v:(60*U*60+60*(1*(H||0))+1*(F||0)+1*(Y||0))/86400,z:(T.length===2?"hh":"h")+":mm"+(F?":ss":"")+(B?" AM/PM":"")}}return null}function wr(M){return/^\s*true\s*$/i.test(M)?{v:!0}:/^\s*false\s*$/i.test(M)?{v:!1}:null}const hn={};function Is(M,b){const{pattern:T,partitions:H,locale:F}=M,Y=A=>{const K=Object.assign({},w(),b,A);return F&&(K.locale=F),K},B=(A,K)=>{const oe=Y(K);return function(z,se,ue){const le=u(ue.locale),$=se[3]?se[3]:ft;if(typeof z=="boolean"&&(z=z?"TRUE":"FALSE"),z==null)return"";if(typeof z!="number")return Fe(z,$,ue,le);if(!isFinite(z)){const ce=le||g;return isNaN(z)?ce.nan:(z<0?ce.negative:"")+ce.infinity}const ie=pt(z,se);return ie?Fe(z,ie,ue,le):ue.overflow}(be(A,oe),H,oe)};B.color=(A,K)=>function(oe,z){if(typeof oe!="number"||!isFinite(oe))return(z[3]?z[3].color:ft.color)||$e;const se=pt(oe,z);return se&&se.color||$e}(be(A,Y(K)),H);const U=function(A){var K;let oe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;const[z,se]=A,ue=z.frac_max,le={type:"general",isDate:Le(A),isText:Se(A),isPercent:Oe(A),maxDecimals:z.general?9:ue,scale:(K=z.scale)!==null&&K!==void 0?K:1,color:0,parentheses:0,grouped:z.grouping?1:0,_partitions:A},$=!le.isDate&&!le.isText&&!z.error&&z.tokens.some(ve=>ve.type==="string"&&(oe?ve.value===oe:D.test(ve.value)));let ie="G",ce=ue>=0?Math.min(15,ue):"",_e="",Ce="";if(se&&se.color&&(Ce="-",le.color=1),z.parens&&(_e="()",le.parentheses=1),$)ie="C",le.type="currency";else if(z.error)le.type="error",le.maxDecimals=0;else if(le.isDate){let ve=0,je=0,St="";z.tokens.forEach(ne=>{const et=ne.type;/^(b-)?year/.test(et)?(St+="Y",je++):et.startsWith("month")?(St+="M",je++):/^(week)?day/.test(et)?(St+="D",je++):et!=="hour"&&et!=="min"&&et!=="sec"&&et!=="am"||(St+=et[0],ve++)}),le.type="date",je&&ve?le.type="datetime":!je&&ve&&(le.type="time");const Dt=ge.find(ne=>St.startsWith(ne[0]));ie=Dt?"D":"G",ce=Dt?Dt[1]:""}else le.isText?(ie="G",le.type="text",ce="",le.maxDecimals=0):z.general?(ie="G",le.type="general",ce=""):z.fractions?(ie="G",le.type="fraction",ce=""):z.exponential?(ie="S",le.type="scientific"):le.isPercent?(ie="P",le.type="percent"):z.grouping?(ie=",",le.type="grouped"):(z.int_max||ue)&&(ie="F",le.type="number");return le.code=ie+ce+Ce+_e,le.level=he[le.type],Object.freeze(le)}(H,(b||{}).currency)||new SyntaxError;return B.info=U,B.dateInfo=function(A){const[K]=A;return{year:!!(2&K.date),month:!!(4&K.date),day:!!(8&K.date),hours:!!(16&K.date),minutes:!!(32&K.date),seconds:!!(64&K.date),clockType:K.clock===12?12:24}}(H),B.isPercent=()=>!!U.isPercent,B.isDate=()=>!!U.isDate,B.isText=()=>!!U.isText,B.pattern=T,M.error&&(B.error=M.error),B.options=Y,B.locale=F||b&&b.locale||"",Object.freeze(B)}function xe(M,b){M||(M="General");let T=null;return hn[M]?T=hn[M]:(T=Object.assign({},w(),b).throws?W(M):function(H){try{return W(H)}catch(F){const Y={tokens:[{type:"error"}],error:F.message};return{pattern:H,partitions:[Y,Y,Y,Y],error:F.message,locale:null}}}(M),T.error||(hn[M]=T)),Is(T,b)}xe.isDate=M=>xe(M,{throws:!1}).isDate(),xe.isPercent=M=>xe(M,{throws:!1}).isPercent(),xe.isText=M=>xe(M,{throws:!1}).isText(),xe.getInfo=(M,b)=>xe(M,{...b,throws:!1}).info,xe.getDateInfo=(M,b)=>xe(M,{...b,throws:!1}).dateInfo,xe.dateToSerial=be,xe.dateFromSerial=De,xe.options=w,xe.dec2frac=f,xe.round=_,xe.codeToLocale=r,xe.parseLocale=c,xe.getLocale=u,xe.addLocale=(M,b)=>{const T=c(b);return delete hn[T.lang],delete hn[T.language],m(M,T)},xe.format=function(M,b,T){let H=arguments.length>3&&arguments[3]!==void 0&&arguments[3];const F=T&&typeof T=="object"?T:{locale:T,throws:!H};return xe(M,F)(be(b,F),F)},xe.is_date=xe.isDate,xe.parseNumber=br,xe.parseDate=Mr,xe.parseTime=Di,xe.parseBool=wr,xe.parseValue=function(M,b){var T,H,F;return(T=(H=(F=br(M))!==null&&F!==void 0?F:Mr(M,b))!==null&&H!==void 0?H:Di(M))!==null&&T!==void 0?T:wr(M)};var bs=xe;return n=n.default}()})})(Cs);var cm=Cs.exports,dm=cm;const um=Xa(dm),hm="univer-status-bar",mm="univer-single-mode",gm="univer-status-bar-div",_m="univer-statistic-list",pm="univer-statistic-list-column",fm="univer-statistic-item",Sm="univer-statistic-picker",vm="univer-statistic-picker-item",Cm="univer-statistic-more",Gt={statusBar:hm,singleMode:mm,statusBarDiv:gm,statisticList:_m,statisticListColumn:pm,statisticItem:fm,statisticPicker:Sm,statisticPickerItem:vm,statisticMore:Cm},Rm=[Re.FUNCTION_NAMES_MATH.SUM,Re.FUNCTION_NAMES_STATISTICAL.AVERAGE,Re.FUNCTION_NAMES_STATISTICAL.MIN,Re.FUNCTION_NAMES_STATISTICAL.MAX],zi={[Re.FUNCTION_NAMES_MATH.SUM]:"statusbar.sum",[Re.FUNCTION_NAMES_STATISTICAL.AVERAGE]:"statusbar.average",[Re.FUNCTION_NAMES_STATISTICAL.MIN]:"statusbar.min",[Re.FUNCTION_NAMES_STATISTICAL.MAX]:"statusbar.max",[Re.FUNCTION_NAMES_STATISTICAL.COUNT]:"statusbar.count",[Re.FUNCTION_NAMES_STATISTICAL.COUNTA]:"statusbar.countA",[Re.FUNCTION_NAMES_TEXT.CONCATENATE]:"concatenate"},$i=i=>{const e=me.useDependency(l.LocaleService),t=me.useDependency(R.IMessageService),n=me.useDependency(R.IClipboardInterfaceService),r=Im(i),o=async()=>{await n.writeText(i.value.toString()),t.show({type:Ye.MessageType.Success,content:e.t("statusbar.copied")})};return S.jsx(Ye.Tooltip,{title:e.t("statusbar.clickToCopy"),placement:"top",children:S.jsx("div",{className:Gt.statisticItem,onClick:o,children:S.jsx("span",{children:`${e.t((zi==null?void 0:zi[i.name])||i.name)}: ${r}`})},i.name)})};function Im(i){const{pattern:e,value:t}=i;return typeof t!="number"?"Invalid input":t>=1e8?t.toExponential(2):e&&Rm.includes(i.name)?um.format(e,t):t.toLocaleString()}const co=800,bm=3,Mm=()=>{const[i,e]=X.useState(window.innerWidth<co),[t,n]=X.useState(!0),r=me.useDependency(Cr),o=r.getFunctions().map((m,g)=>({name:m.func,value:0,show:!0,disable:!1,pattern:null})),[s,a]=X.useState(o),c=s.find(m=>m.show&&!m.disable),d=i&&c?[c]:s.filter(m=>m.show&&!m.disable);X.useEffect(()=>{const m=r.state$.subscribe(g=>{const _=g==null?void 0:g.values;if(!_||_.length===0)n(!1);else{n(!0);const f=s.map(C=>{const I=_.find(w=>w.func===C.name);return I?(C.value=I.value,C.disable=!1):C.disable=!0,C.pattern=(g==null?void 0:g.pattern)??null,C});a(f)}});return()=>{m.unsubscribe()}},[r]);const u=wm(()=>{const m=window.innerWidth<co;i!==m&&e(m)},100);X.useEffect(()=>(window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}),[i]);let h=null;if(d.length>bm){const m=[];d.forEach((g,_)=>{_%2===0&&m.push(d.slice(_,_+2))}),h=S.jsxs(S.Fragment,{children:[" ",m.map((g,_)=>S.jsxs("div",{className:Gt.statisticListColumn,children:[(g==null?void 0:g[0])&&S.jsx($i,{...g==null?void 0:g[0]},g==null?void 0:g[0].name),(g==null?void 0:g[1])&&S.jsx($i,{...g==null?void 0:g[1]},g==null?void 0:g[1].name)]},`stat-col-${_}`))," "]})}else h=S.jsx(S.Fragment,{children:d.map(m=>S.jsx($i,{...m},m.name))});return t&&S.jsxs("div",{className:bn(Gt.statusBar,{[Gt.singleMode]:i}),children:[S.jsx("div",{className:bn(Gt.statisticList),children:h}),S.jsx("div",{className:Gt.statusBarDiv})]})};function wm(i,e){let t;return function(...n){const r=this,o=function(){t=null,i.apply(r,n)};clearTimeout(t),t=setTimeout(o,e)}}function Tm(){return S.jsxs("section",{className:cs.sheetContainer,"data-range-selector":!0,children:[S.jsx(am,{}),S.jsx(Mm,{}),S.jsx(lh,{})]})}function ym(){return S.jsx(S.Fragment,{children:S.jsx(wh,{})})}function Em(){return S.jsxs(S.Fragment,{children:[S.jsx(uh,{}),S.jsx(Lh,{})]})}function Om(i){const e=i.get(p.BorderStyleManagerService),t=p.getCurrentSheetDisabled$(i);return{id:p.SetBorderBasicCommand.id,icon:new J.Observable(n=>{const r="AllBorderSingle",o=i.get(p.BorderStyleManagerService),s=i.get(l.ICommandService).onCommandExecuted(a=>{if(a.id!==p.SetBorderBasicCommand.id)return;const{type:d}=o.getBorderInfo(),u=vs.find(m=>m.value===d),h=(u==null?void 0:u.icon)??r;n.next(h)});return n.next(r),s.dispose}),group:R.MenuGroup.TOOLBAR_FORMAT,tooltip:"toolbar.border.main",positions:[R.MenuPosition.TOOLBAR_START],type:R.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:Ss,hoverable:!1},value$:e.borderInfo$}],value$:e.borderInfo$,hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:t}}const Ni="sheet.menu.clear-selection";function xm(){return{id:Ni,group:R.MenuGroup.CONTEXT_MENU_FORMAT,type:R.MenuItemType.SUBITEMS,icon:"ClearFormat",title:"rightClick.clearSelection",positions:[R.MenuPosition.CONTEXT_MENU,Be.COL_HEADER_CONTEXT_MENU,Be.ROW_HEADER_CONTEXT_MENU]}}function Am(){return{id:p.ClearSelectionContentCommand.id,type:R.MenuItemType.BUTTON,title:"rightClick.clearContent",positions:[Ni]}}function Nm(){return{id:p.ClearSelectionFormatCommand.id,type:R.MenuItemType.BUTTON,title:"rightClick.clearFormat",positions:[Ni]}}function Dm(){return{id:p.ClearSelectionAllCommand.id,type:R.MenuItemType.BUTTON,title:"rightClick.clearAll",positions:[Ni]}}const Pn="sheet.menu.delete";function Pm(){return{id:Pn,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.SUBITEMS,title:"rightClick.delete",icon:"Reduce",positions:[R.MenuPosition.CONTEXT_MENU]}}function Hm(){return{id:p.RemoveColCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,icon:"DeleteColumn",positions:[Pn,Be.COL_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedColumn"}}function Lm(){return{id:p.RemoveRowCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,icon:"DeleteRow",positions:[Pn,Be.ROW_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedRow"}}function Um(){return{id:p.DeleteRangeMoveLeftCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,title:"rightClick.moveLeft",icon:"DeleteCellShiftLeft",positions:[Pn]}}function km(){return{id:p.DeleteRangeMoveUpCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,title:"rightClick.moveUp",icon:"DeleteCellShiftUp",positions:[Pn]}}const Rr="sheet.menu.col-insert";function Vm(){return{id:Rr,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[Be.COL_HEADER_CONTEXT_MENU]}}const Ir="sheet.menu.row-insert";function Fm(){return{id:Ir,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[Be.ROW_HEADER_CONTEXT_MENU]}}const Hn="sheet.menu.cell-insert";function Bm(){return{id:Hn,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[R.MenuPosition.CONTEXT_MENU]}}function jm(i){const e=i.get(p.SelectionManagerService);return{id:p.InsertRowBeforeCommand.id,type:R.MenuItemType.BUTTON,title:"rightClick.insertRowBefore",icon:"InsertRowAbove",positions:[Ir,Hn],hidden$:new J.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function Wm(i){const e=i.get(p.SelectionManagerService);return{id:p.InsertRowAfterCommand.id,type:R.MenuItemType.BUTTON,positions:[Ir],title:"rightClick.insertRow",icon:"InsertRowBelow",hidden$:new J.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function zm(i){const e=i.get(p.SelectionManagerService);return{id:p.InsertColBeforeCommand.id,type:R.MenuItemType.BUTTON,positions:[Rr,Hn],title:"rightClick.insertColumnBefore",icon:"LeftInsertColumn",hidden$:new J.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function $m(i){const e=i.get(p.SelectionManagerService);return{id:p.InsertColAfterCommand.id,type:R.MenuItemType.BUTTON,positions:[Rr],title:"rightClick.insertColumn",icon:"RightInsertColumn",hidden$:new J.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function Ym(){return{id:p.InsertRangeMoveRightCommand.id,type:R.MenuItemType.BUTTON,title:"rightClick.moveRight",icon:"InsertCellShiftRight",positions:[Hn]}}function Xm(){return{id:p.InsertRangeMoveDownCommand.id,type:R.MenuItemType.BUTTON,title:"rightClick.moveDown",icon:"InsertCellDown",positions:[Hn]}}function Zm(i){const e=p.getCurrentSheetDisabled$(i);return{id:Mt.id,icon:"MergeAllSingle",tooltip:"toolbar.mergeCell.main",positions:[R.MenuPosition.TOOLBAR_START],group:R.MenuGroup.TOOLBAR_LAYOUT,type:R.MenuItemType.SUBITEMS,hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:e}}function Gm(i){return{id:us.id,type:R.MenuItemType.BUTTON,title:"merge.all",icon:"MergeAllSingle",positions:[Mt.id]}}function Km(i){return{id:hs.id,type:R.MenuItemType.BUTTON,title:"merge.vertical",icon:"VerticalIntegrationSingle",positions:[Mt.id]}}function qm(i){return{id:ms.id,type:R.MenuItemType.BUTTON,title:"merge.horizontal",icon:"HorizontalMergeSingle",positions:[Mt.id]}}function Jm(i){return{id:p.RemoveWorksheetMergeCommand.id,type:R.MenuItemType.BUTTON,title:"merge.cancel",icon:"CancelMergeSingle",positions:[Mt.id]}}function Qm(){return{id:_s.id,type:R.MenuItemType.BUTTON,positions:[Be.SHEET_BAR],title:"sheetConfig.delete"}}function eg(){return{id:p.CopySheetCommand.id,type:R.MenuItemType.BUTTON,positions:[Be.SHEET_BAR],title:"sheetConfig.copy"}}function tg(){return{id:fs.id,type:R.MenuItemType.BUTTON,positions:[Be.SHEET_BAR],title:"sheetConfig.rename"}}function ng(){return{id:p.SetTabColorCommand.id,title:"sheetConfig.changeColor",positions:[Be.SHEET_BAR],type:R.MenuItemType.SELECTOR,selections:[{label:{name:Oi,hoverable:!1}}]}}function ig(){return{id:p.SetWorksheetHideCommand.id,type:R.MenuItemType.BUTTON,positions:[Be.SHEET_BAR],title:"sheetConfig.hide"}}function rg(){return{id:ps.id,type:R.MenuItemType.BUTTON,positions:[Be.SHEET_BAR],title:"sheetConfig.unhide"}}const og={id:p.SetRowHiddenCommand.id,preconditions:i=>ye(i),binding:R.KeyCode.Digit9|R.MetaKeys.CTRL_COMMAND},sg={id:p.SetColHiddenCommand.id,preconditions:i=>ye(i),binding:R.KeyCode.Digit0|R.MetaKeys.CTRL_COMMAND|R.MetaKeys.SHIFT},ag={id:nt.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_DOWN,priority:100,preconditions:ye,staticParameters:{direction:l.Direction.DOWN}},lg={id:nt.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_UP,priority:100,preconditions:ye,staticParameters:{direction:l.Direction.UP}},cg={id:nt.id,description:"shortcut.sheet.select-left-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_LEFT,priority:100,preconditions:ye,staticParameters:{direction:l.Direction.LEFT}},dg={id:nt.id,description:"shortcut.sheet.select-right-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_RIGHT,priority:100,preconditions:ye,staticParameters:{direction:l.Direction.RIGHT}},ug={id:jt.id,description:"shortcut.sheet.select-next-cell",group:"3_sheet-view",binding:R.KeyCode.TAB,priority:100,preconditions:ye,staticParameters:{direction:l.Direction.RIGHT,keycode:R.KeyCode.TAB}},hg={id:jt.id,description:"shortcut.sheet.select-previous-cell",group:"3_sheet-view",binding:R.KeyCode.TAB|R.MetaKeys.SHIFT,priority:100,preconditions:ye,staticParameters:{direction:l.Direction.LEFT,keycode:R.KeyCode.TAB}},mg={id:jt.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:R.KeyCode.ENTER,priority:100,preconditions:ye,staticParameters:{direction:l.Direction.DOWN,keycode:R.KeyCode.ENTER}},gg={id:jt.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:R.KeyCode.ENTER|R.MetaKeys.SHIFT,priority:100,preconditions:ye,staticParameters:{direction:l.Direction.UP,keycode:R.KeyCode.ENTER}},_g={id:nt.id,description:"shortcut.sheet.select-below-value-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_DOWN|R.MetaKeys.CTRL_COMMAND,preconditions:ye,staticParameters:{direction:l.Direction.DOWN,jumpOver:gt.moveGap}},pg={id:nt.id,description:"shortcut.sheet.select-up-value-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_UP|R.MetaKeys.CTRL_COMMAND,preconditions:ye,staticParameters:{direction:l.Direction.UP,jumpOver:gt.moveGap}},fg={id:nt.id,description:"shortcut.sheet.select-left-value-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_LEFT|R.MetaKeys.CTRL_COMMAND,preconditions:ye,staticParameters:{direction:l.Direction.LEFT,jumpOver:gt.moveGap}},Sg={id:nt.id,description:"shortcut.sheet.select-right-value-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_RIGHT|R.MetaKeys.CTRL_COMMAND,preconditions:ye,staticParameters:{direction:l.Direction.RIGHT,jumpOver:gt.moveGap}},vg={id:_t.id,description:"shortcut.sheet.expand-selection-down",group:"3_sheet-view",binding:R.KeyCode.ARROW_DOWN|R.MetaKeys.SHIFT,preconditions:ye,staticParameters:{direction:l.Direction.DOWN}},Cg={id:_t.id,description:"shortcut.sheet.expand-selection-up",group:"3_sheet-view",binding:R.KeyCode.ARROW_UP|R.MetaKeys.SHIFT,preconditions:ye,staticParameters:{direction:l.Direction.UP}},Rg={id:_t.id,description:"shortcut.sheet.expand-selection-left",group:"3_sheet-view",binding:R.KeyCode.ARROW_LEFT|R.MetaKeys.SHIFT,preconditions:ye,staticParameters:{direction:l.Direction.LEFT}},Ig={id:_t.id,description:"shortcut.sheet.expand-selection-right",group:"3_sheet-view",binding:R.KeyCode.ARROW_RIGHT|R.MetaKeys.SHIFT,preconditions:ye,staticParameters:{direction:l.Direction.RIGHT}},bg={id:_t.id,description:"shortcut.sheet.expand-selection-to-below-gap",group:"3_sheet-view",binding:R.KeyCode.ARROW_DOWN|R.MetaKeys.SHIFT|R.MetaKeys.CTRL_COMMAND,preconditions:ye,staticParameters:{direction:l.Direction.DOWN,jumpOver:gt.moveGap}},Mg={id:_t.id,description:"shortcut.sheet.expand-selection-to-up-gap",group:"3_sheet-view",binding:R.KeyCode.ARROW_UP|R.MetaKeys.SHIFT|R.MetaKeys.CTRL_COMMAND,preconditions:ye,staticParameters:{direction:l.Direction.UP,jumpOver:gt.moveGap}},wg={id:_t.id,description:"shortcut.sheet.expand-selection-to-left-gap",group:"3_sheet-view",binding:R.KeyCode.ARROW_LEFT|R.MetaKeys.SHIFT|R.MetaKeys.CTRL_COMMAND,preconditions:ye,staticParameters:{direction:l.Direction.LEFT,jumpOver:gt.moveGap}},Tg={id:_t.id,description:"shortcut.sheet.expand-selection-to-right-gap",group:"3_sheet-view",binding:R.KeyCode.ARROW_RIGHT|R.MetaKeys.SHIFT|R.MetaKeys.CTRL_COMMAND,preconditions:ye,staticParameters:{direction:l.Direction.RIGHT,jumpOver:gt.moveGap}},yg={id:Ao.id,description:"shortcut.sheet.select-all",group:"3_sheet-view",binding:R.KeyCode.A|R.MetaKeys.CTRL_COMMAND,preconditions:ye,staticParameters:{expandToGapFirst:!0,loop:!0}},Eg={id:ur.id,description:"shortcut.sheet.set-bold",group:"4_sheet-edit",preconditions:i=>ye(i),binding:R.KeyCode.B|R.MetaKeys.CTRL_COMMAND},Og={id:hr.id,description:"shortcut.sheet.set-italic",group:"4_sheet-edit",preconditions:i=>ye(i),binding:R.KeyCode.I|R.MetaKeys.CTRL_COMMAND},xg={id:mr.id,description:"shortcut.sheet.set-underline",group:"4_sheet-edit",preconditions:i=>ye(i),binding:R.KeyCode.U|R.MetaKeys.CTRL_COMMAND},Ag={id:gr.id,description:"shortcut.sheet.set-strike-through",group:"4_sheet-edit",preconditions:i=>ye(i),binding:R.KeyCode.X|R.MetaKeys.SHIFT|R.MetaKeys.CTRL_COMMAND},Ng={id:p.ClearSelectionContentCommand.id,preconditions:i=>ye(i),binding:R.KeyCode.DELETE,mac:R.KeyCode.BACKSPACE},Dg={id:Ai.id,description:"shortcut.sheet.zoom-in",binding:R.KeyCode.EQUAL|R.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",staticParameters:{delta:.2}},Pg={id:Ai.id,description:"shortcut.sheet.zoom-out",binding:R.KeyCode.MINUS|R.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",staticParameters:{delta:-.2}},Hg={id:Ai.id,description:"shortcut.sheet.reset-zoom",binding:R.KeyCode.Digit0|R.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",staticParameters:{reset:!0}};var Lg=Object.defineProperty,Ug=Object.getOwnPropertyDescriptor,kg=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ug(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Lg(e,t,r),r},Zt=(i,e)=>(t,n)=>e(t,n,i);let _i=class extends l.Disposable{constructor(i,e,t,n,r,o){super(),this._injector=i,this._componentManager=e,this._commandService=t,this._shortcutService=n,this._menuService=r,this._uiController=o,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(fr,rc)),this.disposeWithMe(i.register(Ss,ih)),this.disposeWithMe(i.register(Oi,Ye.ColorPicker)),this.disposeWithMe(i.register(rs,Kl)),this.disposeWithMe(i.register(Ge,ql)),this.disposeWithMe(i.register(os,ec))}_initCommands(){[us,Mt,ms,hs,Ai,_t,nt,jt,fs,_s,Jt,Ao,ds,Ti,p.SetBoldCommand,Tn,mt,ur,hr,mr,gr,Bl,jl,Zo,Go,Ii,p.SetItalicCommand,p.SetStrikeThroughCommand,p.SetFontFamilyCommand,p.SetFontSizeCommand,_r,Jo,pr,Qo,on,ii,Ei,es,ts,ns,p.SetUnderlineCommand,vr,bt,ps,gs].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initMenus(){[Rc,Ic,bc,Mc,wc,Tc,yc,Am,Nm,Dm,xm,Vm,Fm,Bm,jm,Wm,zm,$m,Lm,Hc,Uc,Lc,kc,Hm,Vc,Ec,Fc,Pm,Um,km,Ym,Xm,Ac,Nc,Dc,Pc,Oc,xc,oc,sc,ac,lc,cc,uc,hc,mc,gc,_c,pc,Om,Zm,Gm,Km,qm,Jm,fc,Sc,vc,Cc,Qm,eg,tg,ng,ig,rg].forEach(i=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i)))})}_initShortcuts(){[ag,lg,cg,dg,ug,hg,mg,gg,_g,pg,fg,Sg,vg,Cg,Rg,Ig,bg,Mg,wg,Tg,yg,Dg,Pg,Hg,Eg,Og,xg,Ag,Ng,...ad(),ld,cd,ud,hd,md,dd,og,sg].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_initWorkbenchParts(){this.disposeWithMe(this._uiController.registerHeaderComponent(()=>me.connectInjector(ym,this._injector))),this.disposeWithMe(this._uiController.registerFooterComponent(()=>me.connectInjector(Tm,this._injector))),this.disposeWithMe(this._uiController.registerContentComponent(()=>me.connectInjector(Em,this._injector)))}_init(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts(),this._initWorkbenchParts()}};_i=kg([l.OnLifecycle(l.LifecycleStages.Ready,_i),Zt(0,j.Inject(j.Injector)),Zt(1,j.Inject(R.ComponentManager)),Zt(2,l.ICommandService),Zt(3,R.IShortcutService),Zt(4,R.IMenuService),Zt(5,R.IUIController)],_i);var Vg=Object.defineProperty,Fg=Object.getOwnPropertyDescriptor,Bg=(i,e,t,n)=>{for(var r=n>1?void 0:n?Fg(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Vg(e,t,r),r},Lt=(i,e)=>(t,n)=>e(t,n,i);let pi=class extends l.Disposable{constructor(e,t,n,r,o,s,a){super();v(this,"_calculateTimeout",-1);this._univerInstanceService=e,this._selectionManagerService=t,this._functionService=n,this._statusBarService=r,this._commandService=o,this._formulaDataModel=s,this._numfmtService=a,this._init()}_init(){this._registerSelectionListener()}_registerSelectionListener(){this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoving$.subscribe(e=>{var t;((t=this._selectionManagerService.getCurrent())==null?void 0:t.pluginName)===p.NORMAL_SELECTION_PLUGIN_NAME&&e&&(clearTimeout(this._calculateTimeout),this._calculateTimeout=setTimeout(()=>{const n=e[e.length-1].primary;this._calculateSelection(e.map(r=>r.range),n)},100))}))),this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(e=>{var t;if(((t=this._selectionManagerService.getCurrent())==null?void 0:t.pluginName)===p.NORMAL_SELECTION_PLUGIN_NAME&&e){const n=e[e.length-1].primary;this._calculateSelection(e.map(r=>r.range),n)}}))),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===p.SetRangeValuesMutation.id){const t=this._selectionManagerService.getSelections();t&&(clearTimeout(this._calculateTimeout),this._calculateTimeout=setTimeout(()=>{this._calculateSelection(t.map(n=>n.range))},100))}}))}_calculateSelection(e,t){var c;const n=this._univerInstanceService.getCurrentUniverSheetInstance(),r=n.getUnitId(),o=n.getActiveSheet().getSheetId(),s={},a=this._formulaDataModel.getArrayFormulaCellData();if(this._univerInstanceService.getCurrentUniverSheetInstance().getSheets().forEach(d=>{const u=d.getConfig();s[d.getSheetId()]={cellData:new l.ObjectMatrix(u.cellData),rowCount:u.rowCount,columnCount:u.columnCount}}),e!=null&&e.length){const d=e.map(f=>new Re.RangeReferenceObject(f,o,r));d.forEach(f=>{f.setUnitData({[r]:s}),a&&f.setArrayFormulaCellData(Re.convertUnitDataToRuntime(a))});const h=this._statusBarService.getFunctions().map(f=>{const C=this._functionService.getExecutor(f.func);if(!C)return;const I=d.map(E=>E.toArrayValueObject(!1));if((C==null?void 0:C.calculate(...I)).getValue)return{func:f.func,value:(C==null?void 0:C.calculate(...I)).getValue()}});if(h.every(f=>f===void 0))return;let m=null;if(t){const{actualRow:f,actualColumn:C}=t;m=(c=this._numfmtService.getValue(r,o,f,C))==null?void 0:c.pattern}const _={values:h.filter(f=>f!==void 0),pattern:m};this._statusBarService.setState(_)}else this._statusBarService.setState(null)}_isSingleCell(e){return e.startRow===e.endRow&&e.startColumn===e.endColumn}};pi=Bg([l.OnLifecycle(l.LifecycleStages.Ready,pi),Lt(0,l.IUniverInstanceService),Lt(1,j.Inject(p.SelectionManagerService)),Lt(2,Re.IFunctionService),Lt(3,Cr),Lt(4,l.ICommandService),Lt(5,j.Inject(Re.FormulaDataModel)),Lt(6,j.Inject(p.INumfmtService))],pi);var jg=Object.defineProperty,Wg=Object.getOwnPropertyDescriptor,zg=(i,e,t,n)=>{for(var r=n>1?void 0:n?Wg(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&jg(e,t,r),r},Ut=(i,e)=>(t,n)=>e(t,n,i);let fi=class extends l.Disposable{constructor(i,e,t,n,r,o,s){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._selectionRenderService=r,this._selectionManagerService=o,this._scrollManagerService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._zoomEventBinding()}_zoomEventBinding(){var e;const i=(e=this._getSheetObject())==null?void 0:e.scene;i!=null&&(i.getViewport(Q.VIEW_MAIN),this.disposeWithMe(l.toDisposable(i.onMouseWheelObserver.add((t,n)=>{if(!t.ctrlKey)return;const r=Math.abs(t.deltaX);let o=r<40?.2:r<80?.4:.2;o*=t.deltaY>0?-1:1,i.scaleX<1&&(o/=2);const s=this._currentUniverService.getCurrentUniverSheetInstance(),a=s.getActiveSheet(),c=a.getZoomRatio();let d=+parseFloat(`${c+o}`).toFixed(1);d=d>=4?4:d<=.1?.1:d,this._commandService.executeCommand(vr.id,{zoomRatio:Math.round(d*10)/10,unitId:s.getUnitId(),subUnitId:a.getSheetId()}),t.preventDefault()}))))}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeletonBefore$.subscribe(i=>{if(i==null)return;const n=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getZoomRatio()||1;this._updateViewZoom(n)})))}_commandExecutedListener(){const i=[bt.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet(),r=e.params,{unitId:o,subUnitId:s}=r;if(!(o===t.getUnitId()&&s===n.getSheetId()))return;const a=n.getConfig().zoomRatio||1;this._updateViewZoom(a)}}))}_updateViewZoom(i){const e=this._getSheetObject();e==null||e.scene.scale(i,i),e==null||e.spreadsheet.makeForceDirty()}_getSheetObject(){return qe(this._currentUniverService,this._renderManagerService)}};fi=zg([l.OnLifecycle(l.LifecycleStages.Rendered,fi),Ut(0,j.Inject(exports.SheetSkeletonManagerService)),Ut(1,l.IUniverInstanceService),Ut(2,l.ICommandService),Ut(3,y.IRenderManagerService),Ut(4,Ze),Ut(5,j.Inject(p.SelectionManagerService)),Ut(6,j.Inject(Nt))],fi);var $g=Object.defineProperty,Yg=Object.getOwnPropertyDescriptor,Xg=(i,e,t,n)=>{for(var r=n>1?void 0:n?Yg(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&$g(e,t,r),r},vn=(i,e)=>(t,n)=>e(t,n,i);exports.SheetCanvasView=class extends l.RxDisposable{constructor(t,n,r,o,s){super();v(this,"_scene");v(this,"_currentWorkbook");v(this,"_loadedMap",new Set);v(this,"_isLoadedEditor",!1);v(this,"_fps$",new J.BehaviorSubject(""));v(this,"fps$",this._fps$.asObservable());this._currentUniverService=t,this._commandService=n,this._renderManagerService=r,this._selectionRenderService=o,this._sheetSkeletonManagerService=s,this._currentUniverService.currentSheet$.subscribe(a=>{if(a==null)return;const c=a.getUnitId();this._loadedMap.has(c)||(this._currentWorkbook=a,this._addNewRender(),this._loadedMap.add(c))})}dispose(){this._fps$.complete()}_addNewRender(){const t=this._currentWorkbook,n=t.getUnitId(),r=t.getContainer(),o=t.getParentRenderUnitId();if(r!=null&&o!=null)throw new Error("container or parentRenderUnitId can only exist one");const s=r==null&&o!=null;s?this._renderManagerService.createRenderWithParent(n,o):this._renderManagerService.createRender(n);const a=this._renderManagerService.getRenderById(n);if(a==null)return;const{scene:c,engine:d}=a;c.openTransformer(),this._scene=c,c.addLayer(new y.Layer(c,[],0),new y.Layer(c,[],2)),a!=null&&this._addComponent(a),t.getShouldRenderLoopImmediately()&&!s&&d.runRenderLoop(()=>{c.render(),this._fps$.next(Math.round(d.getFps()).toString())}),this._renderManagerService.setCurrent(n)}_addComponent(t){const n=this._scene,r=this._currentWorkbook,o=r.getActiveSheet(),s=r.getUnitId(),a=o.getSheetId();this._addViewport(o);const c=new y.Spreadsheet(Xe.MAIN),d=new y.SpreadsheetRowHeader(Xe.ROW),u=new y.SpreadsheetColumnHeader(Xe.COLUMN),h=new y.Rect(Xe.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});t.mainComponent=c,t.components.set(Xe.MAIN,c),t.components.set(Xe.ROW,d),t.components.set(Xe.COLUMN,u),t.components.set(Xe.LEFT_TOP,h),n.addObjects([c],Ar),n.addObjects([d,u,h],At),n.enableLayerCache(Ar,At),this._sheetSkeletonManagerService.setCurrent({sheetId:a,unitId:s})}_addViewport(t){const n=this._scene;if(n==null)return;const{rowHeader:r,columnHeader:o}=t.getConfig(),s=new y.Viewport(Q.VIEW_MAIN,n,{left:r.width,top:o.height,bottom:0,right:0,isWheelPreventDefaultX:!0});return new y.Viewport(Q.VIEW_ROW_TOP,n,{active:!1,isWheelPreventDefaultX:!0}),new y.Viewport(Q.VIEW_ROW_BOTTOM,n,{left:0,top:o.height,bottom:0,width:r.width,isWheelPreventDefaultX:!0}),new y.Viewport(Q.VIEW_COLUMN_LEFT,n,{active:!1,isWheelPreventDefaultX:!0}),new y.Viewport(Q.VIEW_COLUMN_RIGHT,n,{left:r.width,top:0,height:o.height,right:0,isWheelPreventDefaultX:!0}),new y.Viewport(Q.VIEW_LEFT_TOP,n,{left:0,top:0,width:r.width,height:o.height,isWheelPreventDefaultX:!0}),new y.Viewport(Q.VIEW_MAIN_LEFT_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),new y.Viewport(Q.VIEW_MAIN_LEFT,n,{isWheelPreventDefaultX:!0,active:!1}),new y.Viewport(Q.VIEW_MAIN_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),n.onMouseWheelObserver.add((a,c)=>{if(a.ctrlKey)return;let d=0,u=0;const h=s.limitedScroll();if(a.inputIndex===y.PointerInput.MouseWheelX){const g=Math.abs(a.deltaX);a.deltaX>0?d=g:d=-g,this._commandService.executeCommand(ii.id,{offsetX:d}),n.getParent().classType===y.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedX||c.stopPropagation():s.isWheelPreventDefaultX?a.preventDefault():h!=null&&h.isLimitedX||a.preventDefault()}if(a.inputIndex===y.PointerInput.MouseWheelY){let g=Math.abs(a.deltaY);a.shiftKey?(g*=3,a.deltaY>0?d=g:d=-g,this._commandService.executeCommand(ii.id,{offsetX:d}),n.getParent().classType===y.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedX||c.stopPropagation():s.isWheelPreventDefaultX?a.preventDefault():h!=null&&h.isLimitedX||a.preventDefault()):(a.deltaY>0?u=g:u=-g,this._commandService.executeCommand(ii.id,{offsetY:u}),n.getParent().classType===y.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedY||c.stopPropagation():s.isWheelPreventDefaultY?a.preventDefault():h!=null&&h.isLimitedY||a.preventDefault())}a.inputIndex,y.PointerInput.MouseWheelZ,this._scene.makeDirty(!0)}),new y.ScrollBar(s),n.attachControl(),s}};exports.SheetCanvasView=Xg([l.OnLifecycle(l.LifecycleStages.Ready,exports.SheetCanvasView),vn(0,l.IUniverInstanceService),vn(1,l.ICommandService),vn(2,y.IRenderManagerService),vn(3,Ze),vn(4,j.Inject(exports.SheetSkeletonManagerService))],exports.SheetCanvasView);var Zg=Object.defineProperty,Gg=Object.getOwnPropertyDescriptor,Kg=(i,e,t,n)=>{for(var r=n>1?void 0:n?Gg(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Zg(e,t,r),r},Yi=(i,e)=>(t,n)=>e(t,n,i),Xi;exports.UniverSheetsUIPlugin=(Xi=class extends l.Plugin{constructor(e,t,n,r){super(_o),this._injector=t,this._localeService=n,this._currentUniverService=r,this._localeService.load({zhCN:ss})}onStarting(e){[[exports.SheetCanvasView],[at,{useClass:exports.EditorBridgeService}],[nn,{useClass:exports.SheetClipboardService}],[cn,{useClass:Vu}],[sn,{useClass:er}],[Dn,{useClass:as}],[xi,{useClass:Wc}],[xn,{useClass:exports.AutoFillService}],[Nt],[exports.SheetSkeletonManagerService],[Ze,{useClass:exports.SelectionRenderService}],[Cr,{useClass:lm}],[On,{useClass:exports.MarkSelectionService}],[Yn],[Xn],[ti],[qn],[Jn],[ni],[ri],[oi],[si],[ai],[li],[Qn],[di],[Qt],[hi],[Zn],[Gn],[ui],[mi],[_i],[ei],[fi],[exports.AutoFillController],[pi],[Kn],[ci]].forEach(t=>e.add(t))}onReady(){this._markSheetAsFocused()}_markSheetAsFocused(){const e=this._currentUniverService;e.currentSheet$.pipe(uo.filter(t=>!!t)).subscribe(t=>{e.focusUniverInstance(t.getUnitId())})}},v(Xi,"type",l.PluginType.Sheet),Xi);exports.UniverSheetsUIPlugin=Kg([Yi(1,j.Inject(j.Injector)),Yi(2,j.Inject(l.LocaleService)),Yi(3,l.IUniverInstanceService)],exports.UniverSheetsUIPlugin);exports.APPLY_TYPE=Te;exports.AutoFillCommand=So;exports.COPY_TYPE=Vt;exports.CellEditorManagerService=as;exports.DATA_TYPE=We;exports.DefaultRightMenuConfig=ho;exports.DefaultSheetContainerConfig=go;exports.DefaultSheetUIConfig=Ts;exports.DefaultToolbarConfig=mo;exports.ExpandSelectionCommand=_t;exports.IAutoFillService=xn;exports.ICellEditorManagerService=Dn;exports.IEditorBridgeService=at;exports.IFormulaEditorManagerService=xi;exports.IMarkSelectionService=On;exports.ISelectionRenderService=Ze;exports.ISheetClipboardService=nn;exports.JumpOver=gt;exports.MoveSelectionCommand=nt;exports.PASTE_SPECIAL_MENU_ID=ln;exports.PREDEFINED_HOOK_NAME=Ke;exports.RangeSelector=El;exports.SHEET_UI_PLUGIN_NAME=_o;exports.SelectionShape=Ci;exports.SetCellEditVisibleArrowOperation=Tn;exports.SetEditorResizeOperation=Ti;exports.SetScrollOperation=on;exports.SetZoomRatioOperation=bt;exports.SheetCopyCommand=wo;exports.SheetPasteCommand=rn;exports.VIEWPORT_KEY=Q;exports.enUS=Bc;exports.getAutoFillRepeatRange=Fs;exports.getCoordByCell=tr;exports.getCoordByOffset=tn;exports.getEditorObject=wi;exports.getRepeatRange=jc;exports.getSheetObject=qe;exports.getTransformCoord=$n;exports.whenEditorInputFormulaActivated=Ws;exports.zhCN=ss;
|
|
17
|
+
*/var xa=P,Aa=Symbol.for("react.element"),Da=Symbol.for("react.fragment"),Na=Object.prototype.hasOwnProperty,Ha=xa.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Pa={key:!0,ref:!0,__self:!0,__source:!0};function go(i,e,t){var n,r={},o=null,s=null;t!==void 0&&(o=""+t),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)Na.call(e,n)&&!Pa.hasOwnProperty(n)&&(r[n]=e[n]);if(i&&i.defaultProps)for(n in e=i.defaultProps,e)r[n]===void 0&&(r[n]=e[n]);return{$$typeof:Aa,type:i,key:o,ref:s,props:r,_owner:Ha.current}}Gn.Fragment=Da;Gn.jsx=go;Gn.jsxs=go;mo.exports=Gn;var p=mo.exports,Me=function(){return Me=Object.assign||function(i){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},Me.apply(this,arguments)},La=function(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(t[n[r]]=i[n[r]]);return t},Ie=P.forwardRef(function(i,e){var t=i.icon,n=i.id,r=i.className,o=i.extend,s=La(i,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),c=P.useRef("_".concat(Va()));return _o(t,"".concat(n),{defIds:t.defIds,idSuffix:c.current},Me({ref:e,className:a},s),o)});function _o(i,e,t,n,r){return P.createElement(i.tag,Me(Me({key:e},Ua(i,t,r)),n),(ka(i,t).children||[]).map(function(o,s){return _o(o,"".concat(e,"-").concat(i.tag,"-").concat(s),t,void 0,r)}))}function Ua(i,e,t){var n=Me({},i.attrs);t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1);var r=e.defIds;return!r||r.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(o){var s=o[0],a=o[1];typeof a=="string"&&(n[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function ka(i,e){var t,n=e.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?Me(Me({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?Me(Me({},r),{attrs:Me(Me({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function Va(){return Math.random().toString(36).substring(2,8)}Ie.displayName="UniverIcon";var Ba={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"}}]},So=P.forwardRef(function(i,e){return P.createElement(Ie,Object.assign({},i,{id:"autofill",ref:e,icon:Ba}))});So.displayName="Autofill";const Fa=So;var Wa={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.44 3.57291C14.698 3.83093 14.698 4.24927 14.44 4.50729L6.44342 12.5037C6.28721 12.6599 6.03395 12.6599 5.87774 12.5037L1.55992 8.18578C1.3019 7.92776 1.3019 7.50942 1.55993 7.2514C1.81795 6.99338 2.23629 6.99338 2.49431 7.25141L6.01916 10.7763C6.09727 10.8544 6.2239 10.8544 6.30201 10.7763L13.5056 3.57291C13.7636 3.31489 14.1819 3.31489 14.44 3.57291Z",fillRule:"evenodd",clipRule:"evenodd"}}]},fo=P.forwardRef(function(i,e){return P.createElement(Ie,Object.assign({},i,{id:"check-mark-single",ref:e,icon:Wa}))});fo.displayName="CheckMarkSingle";const jn=fo;var ja={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.57061 3.65132C4.31677 3.39748 3.90521 3.39748 3.65137 3.65132C3.39753 3.90516 3.39753 4.31672 3.65137 4.57056L7.08079 7.99998L3.65123 11.4295C3.39739 11.6834 3.39739 12.0949 3.65123 12.3488C3.90507 12.6026 4.31662 12.6026 4.57047 12.3488L8.00003 8.91921L11.4295 12.3487C11.6834 12.6026 12.0949 12.6026 12.3488 12.3487C12.6026 12.0949 12.6026 11.6833 12.3488 11.4295L8.91927 7.99998L12.3486 4.57061C12.6025 4.31677 12.6025 3.90521 12.3486 3.65137C12.0948 3.39753 11.6832 3.39753 11.4294 3.65137L8.00003 7.08074L4.57061 3.65132Z"}}]},po=P.forwardRef(function(i,e){return P.createElement(Ie,Object.assign({},i,{id:"close-single",ref:e,icon:ja}))});po.displayName="CloseSingle";const $a=po;var za={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1213",style:{"mask-type":"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_102_1213)"},children:[{tag:"path",attrs:{d:"M1.22297.954345C1.3529.929358 1.51542.914795 1.7147.914795H6.85715C7.0561.914795 7.21986.929297 7.35152.959681 7.48737.991031 7.5967 1.04983 7.67995 1.13863 7.76349 1.22774 7.81571 1.34646 7.84615 1.48343L7.84671 1.48597C7.87164 1.62058 7.88612 1.79252 7.88612 2.00111V7.16269C7.88612 7.36211 7.87154 7.52439 7.84667 7.6587 7.82039 7.79533 7.76169 7.91004 7.67831 7.9934 7.59462 8.0771 7.48565 8.13006 7.35692 8.16096 7.22966 8.1915 7.06561 8.20599 6.87627 8.20599H1.7147C1.52177 8.20599 1.36349 8.19641 1.23252 8.17122 1.09967 8.14567.98914 8.09813.90398 8.0134.818184 7.93285.765734 7.8172.735395 7.68573.705177 7.55478.68573 7.38178.68573 7.16269V1.9581C.68573 1.7541.700286 1.58699.725186 1.45253.751461 1.31589.810166 1.20119.893537 1.11782.978617 1.03274 1.08895.98522 1.22033.954901L1.22297.954345zM2.02733 2.07424C1.95064 2.07854 1.91191 2.09755 1.89153 2.11849 1.86949 2.1517 1.85476 2.19738 1.85473 2.25901L1.86389 3.92571H3.72054V2.07424H2.02733zM4.8991 2.07901V3.92571H6.70756V2.20184C6.70756 2.15684 6.7041 2.12531 6.69899 2.10487 6.69675 2.09591 6.69467 2.09093 6.69349 2.08853 6.68344 2.08345 6.66389 2.07901 6.61819 2.07901H4.8991zM1.86466 5.08037L1.87384 6.90902C1.87384 6.95115 1.87723 6.98219 1.8825 7.00371 1.8864 7.01961 1.89067 7.02788 1.8933 7.03179 1.8933 7.03179 1.89686 7.03365 1.8996 7.03479 1.90589 7.03741 1.91476 7.04025 1.92666 7.04282 1.95062 7.04799 1.98341 7.05133 2.02535 7.05133H3.72532V5.08037H1.86466zM4.8991 5.08037V7.05133H6.55606C6.63148 7.05133 6.67174 7.04228 6.68909 7.03374 6.69039 7.03177 6.69349 7.02643 6.69691 7.01502 6.70311 6.99436 6.70756 6.96264 6.70756 6.91894V5.08037H4.8991zM8.65114 7.83368C8.78108 7.80869 8.94359 7.79413 9.14288 7.79413H14.2853C14.4843 7.79413 14.648 7.80863 14.7797 7.83902 14.9155 7.87037 15.0249 7.92916 15.1081 8.01797 15.1917 8.10707 15.2439 8.2258 15.2743 8.36277L15.2749 8.36531C15.2998 8.49991 15.3143 8.67185 15.3143 8.88045V14.042C15.3143 14.2414 15.2997 14.4037 15.2748 14.538 15.2486 14.6747 15.1899 14.7894 15.1065 14.8727 15.0228 14.9564 14.9138 15.0094 14.7851 15.0403 14.6578 15.0708 14.4938 15.0853 14.3044 15.0853H9.14288C8.94995 15.0853 8.79166 15.0757 8.6607 15.0506 8.52785 15.025 8.41732 14.9775 8.33216 14.8927 8.24636 14.8122 8.19391 14.6965 8.16358 14.5651 8.13336 14.4341 8.11391 14.2611 8.11391 14.042V8.83744C8.11391 8.63343 8.12847 8.46633 8.15337 8.33186 8.17964 8.19523 8.23835 8.08053 8.32172 7.99716 8.4068 7.91208 8.51713 7.86456 8.64851 7.83424L8.65114 7.83368zM9.45551 8.95357C9.37882 8.95788 9.34009 8.97689 9.3197 8.99782 9.29767 9.03103 9.28294 9.07672 9.28291 9.13834L9.29206 10.805H11.1487V8.95357H9.45551zM12.3273 8.95835V10.805H14.1357V9.08118C14.1357 9.03618 14.1323 9.00465 14.1272 8.98421 14.1249 8.97524 14.1228 8.97026 14.1217 8.96786 14.1116 8.96278 14.0921 8.95835 14.0464 8.95835H12.3273zM9.29283 11.9597L9.30202 13.7884C9.30202 13.8305 9.30541 13.8615 9.31068 13.883 9.31457 13.8989 9.31885 13.9072 9.32148 13.9111L9.32448 13.9127 9.32778 13.9141C9.33407 13.9167 9.34293 13.9196 9.35484 13.9222 9.3788 13.9273 9.41159 13.9307 9.45353 13.9307H11.1535V11.9597H9.29283zM12.3273 11.9597V13.9307H13.9842C14.0597 13.9307 14.0999 13.9216 14.1173 13.9131 14.1186 13.9111 14.1217 13.9058 14.1251 13.8944 14.1313 13.8737 14.1357 13.842 14.1357 13.7983V11.9597H12.3273z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{d:"M9.46247 2.15033C9.46247 1.74649 9.78985 1.41911 10.1937 1.41911H12.3873C13.5988 1.41911 14.581 2.40124 14.581 3.61276V5.80641C14.581 6.21025 14.2536 6.53762 13.8498 6.53762 13.4459 6.53762 13.1185 6.21025 13.1185 5.80641V3.61276C13.1185 3.20893 12.7912 2.88154 12.3873 2.88154H10.1937C9.78985 2.88154 9.46247 2.55417 9.46247 2.15033zM2.88154 10.1937C2.88154 9.78986 2.55416 9.46248 2.15032 9.46248 1.74648 9.46248 1.4191 9.78986 1.4191 10.1937V12.3873C1.4191 13.5988 2.40123 14.581 3.61275 14.581H5.8064C6.21024 14.581 6.53761 14.2536 6.53761 13.8498 6.53761 13.4459 6.21024 13.1186 5.8064 13.1186H3.61275C3.20892 13.1186 2.88154 12.7912 2.88154 12.3873V10.1937z"}}]}]},vo=P.forwardRef(function(i,e){return P.createElement(Ie,Object.assign({},i,{id:"convert-single",ref:e,icon:za}))});vo.displayName="ConvertSingle";const Xa=vo;var Ya={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_371_77",style:{"mask-type":"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_371_77)"},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"}}]}]},Co=P.forwardRef(function(i,e){return P.createElement(Ie,Object.assign({},i,{id:"dropdown-single",ref:e,icon:Ya}))});Co.displayName="DropdownSingle";const Ir=Co;var Za={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.6905 4.78738C2.01709 4.61737 2.41966 4.7443 2.58967 5.07089C2.75217 5.38305 3.00913 5.69251 3.36183 5.98156C4.36103 6.80048 6.03866 7.37872 7.99833 7.37872C9.958 7.37872 11.6356 6.80049 12.6348 5.98157C12.9875 5.69251 13.2445 5.38304 13.407 5.0709C13.577 4.7443 13.9796 4.61737 14.3062 4.78737C14.6327 4.95738 14.7597 5.35995 14.5897 5.68654C14.329 6.18726 13.9448 6.63187 13.48 7.01281C13.4365 7.04842 13.3923 7.08356 13.3473 7.11821L14.8065 8.57746C15.0669 8.83781 15.0669 9.25992 14.8065 9.52027C14.5462 9.78062 14.124 9.78062 13.8637 9.52027L12.1741 7.83063C11.6495 8.08125 11.0697 8.28368 10.451 8.43104L10.9916 10.4486C11.0869 10.8042 10.8759 11.1698 10.5202 11.2651C10.1646 11.3604 9.79902 11.1493 9.70373 10.7937L9.13044 8.6541C8.7607 8.69234 8.38239 8.71205 7.99833 8.71205C7.61155 8.71205 7.2306 8.69206 6.85837 8.65329L6.28486 10.7937C6.18957 11.1494 5.82401 11.3604 5.46837 11.2651C5.11272 11.1698 4.90167 10.8043 4.99696 10.4486L5.53804 8.42923C4.92309 8.28224 4.34666 8.0808 3.82483 7.8317L2.13636 9.52018C1.87602 9.78053 1.45391 9.78053 1.19355 9.52018C0.933204 9.25983 0.933203 8.83772 1.19355 8.57737L2.65127 7.11965C2.60559 7.08453 2.56072 7.04892 2.51667 7.01281C2.05184 6.63186 1.66764 6.18725 1.40699 5.68655C1.23698 5.35996 1.36391 4.95739 1.6905 4.78738Z"}}]},Io=P.forwardRef(function(i,e){return P.createElement(Ie,Object.assign({},i,{id:"eyelash-single",ref:e,icon:Za}))});Io.displayName="EyelashSingle";const Ga=Io;var Ka={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_367_60",style:{"mask-type":"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_367_60)"},children:[{tag:"path",attrs:{d:"M5.48334 4.89587C5.35517 4.89587 5.26008 4.777 5.28822 4.65196L5.37367 4.27223C5.47369 3.84311 5.65731 3.4768 5.93107 3.18085 6.23007 2.85761 6.67323 2.71538 7.21663 2.71538 7.41772 2.71538 7.63284 2.73908 7.86113 2.78378 7.88014 2.7875 7.89899 2.79139 7.91771 2.79543 8.12915 2.84113 8.35624 2.74611 8.43956 2.54647L8.66692 2.00173C8.75382 1.79351 8.65103 1.55537 8.43507 1.49007 8.40283 1.48032 8.36953 1.47045 8.33516 1.46047 8.0467 1.37763 7.70317 1.3335 7.29999 1.3335 6.2394 1.3335 5.44639 1.60069 4.89385 2.10573 4.32912 2.62202 3.92814 3.3605 3.70338 4.33753L2.25629 10.5523C2.18051 10.8899 2.08525 11.253 1.96769 11.6425 1.849 12.0347 1.70655 12.4208 1.54146 12.7986 1.37502 13.1773 1.18738 13.5375.978805 13.8784.912697 13.9865.8444 14.0896.773916 14.1876.684332 14.3122.753952 14.4944.905805 14.5167 1.5556 14.6123 2.23715 14.4376 2.60122 13.8909 2.74587 13.6737 2.88704 13.426 3.02434 13.1464 3.3856 12.411 3.72447 11.3716 4.03792 10.0188L4.88825 6.37667C4.90938 6.28616 4.99007 6.22214 5.08301 6.22214H7.04403C7.22895 6.22214 7.38976 6.09538 7.43296 5.91557L7.55939 5.3893C7.61982 5.13775 7.42917 4.89587 7.17046 4.89587H5.48334zM13.7403 5.0817L11.9317 7.33096 10.8281 5.13886C10.7615 4.99145 10.6146 4.89673 10.4529 4.89673H9.73214C9.4277 4.89673 9.22847 5.21561 9.36195 5.48923L10.8281 8.41635 8.21708 11.5106C7.98512 11.7771 8.17444 12.1929 8.5278 12.1929H9.10532C9.22597 12.1929 9.37975 12.1436 9.45801 12.0518L11.53 9.62616 12.5369 11.9223C12.5978 12.0844 12.7522 12.1929 12.9254 12.1929H13.7193C14.0023 12.1929 14.161 11.9788 14.0619 11.7137L12.592 8.64761C12.592 8.64761 14.8202 5.81675 15.0205 5.54025 15.2159 5.27062 15.0215 4.89673 14.6886 4.89673H14.0854C13.9467 4.89673 13.8525 4.9502 13.7403 5.0817z"}}]}]},Ro=P.forwardRef(function(i,e){return P.createElement(Ie,Object.assign({},i,{id:"fx-single",ref:e,icon:Ka}))});Ro.displayName="FxSingle";const qa=Ro;var Ja={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_249",style:{"mask-type":"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_249)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.74717 2.0944C8.74717 1.68671 8.41279 1.3562 8.00032 1.3562C7.58785 1.3562 7.25347 1.68671 7.25347 2.0944V7.26186H2.02541C1.61294 7.26186 1.27856 7.59237 1.27856 8.00007C1.27856 8.40777 1.61294 8.73827 2.02541 8.73827H7.25347V13.9057C7.25347 14.3134 7.58785 14.6439 8.00032 14.6439C8.41279 14.6439 8.74717 14.3134 8.74717 13.9057V8.73827H13.975C14.3874 8.73827 14.7218 8.40777 14.7218 8.00007C14.7218 7.59237 14.3874 7.26186 13.975 7.26186H8.74717V2.0944Z"}}]}]},Mo=P.forwardRef(function(i,e){return P.createElement(Ie,Object.assign({},i,{id:"increase-single",ref:e,icon:Ja}))});Mo.displayName="IncreaseSingle";const Qa=Mo;var el={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_556",style:{"mask-type":"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_556)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M0.629584 3.99986C1.13729 3.4922 1.9604 3.49224 2.46806 3.99995L7.57569 9.10806C7.81 9.3424 8.18992 9.3424 8.42424 9.10808L13.5323 3.99998C14.04 3.4923 14.8631 3.4923 15.3708 3.99998C15.8785 4.50766 15.8785 5.33078 15.3708 5.83846L9.41415 11.7951C8.63307 12.5762 7.36669 12.5762 6.58565 11.7951L0.629497 5.83834C0.121839 5.33063 0.121879 4.50752 0.629584 3.99986Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},bo=P.forwardRef(function(i,e){return P.createElement(Ie,Object.assign({},i,{id:"more-down-single",ref:e,icon:el}))});bo.displayName="MoreDownSingle";const wi=bo;var tl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.45493 2.80093C5.74783 2.49409 6.2227 2.49409 6.5156 2.80093L11.0156 7.51523C11.3085 7.82207 11.3085 8.31956 11.0156 8.6264L6.44488 13.27C6.15199 13.5768 5.67711 13.5768 5.38422 13.27C5.09133 12.9631 5.09133 12.4656 5.38422 12.1588L9.28804 8.20898C9.36409 8.13203 9.36517 8.00855 9.29047 7.93029L5.45493 3.9121C5.16204 3.60526 5.16204 3.10777 5.45493 2.80093Z",fillRule:"evenodd",clipRule:"evenodd"}}]},wo=P.forwardRef(function(i,e){return P.createElement(Ie,Object.assign({},i,{id:"more-single",ref:e,icon:tl}))});wo.displayName="MoreSingle";const Rr=wo;var nl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1204",style:{"mask-type":"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_1204)"},children:[{tag:"rect",attrs:{width:12.62,height:2.79,x:1.69,y:12.25,fill:"colorChannel1",rx:1.4}},{tag:"path",attrs:{fill:"currentColor",d:"M7.74646 2.1642C7.34284 1.65121 6.85947 1.28205 6.38447 1.09593C5.86863 0.893787 5.15166 0.852126 4.70047 1.42917C4.29842 1.94344 4.33082 2.70249 4.57691 3.50395C4.68808 3.8661 4.86846 4.22254 5.12522 4.56617C5.13695 4.58185 5.14927 4.5968 5.16211 4.61102C5.17152 4.6214 5.18122 4.63139 5.19115 4.64096C5.20459 4.65393 5.21855 4.66618 5.23296 4.6777L3.5064 6.40422C3.26756 6.64306 3.26756 7.03033 3.5064 7.26919L7.23756 11.0004C7.47648 11.2392 7.86375 11.2392 8.1026 11.0004L12.8329 6.27001C13.0717 6.03117 13.0717 5.6439 12.8329 5.40505L9.10172 1.67387C8.86288 1.43503 8.47561 1.43503 8.23676 1.67387L7.74646 2.1642ZM7.46162 4.50638C7.47252 4.57574 7.48163 4.64652 7.4888 4.71868C7.52232 5.05481 7.82194 5.30013 8.15807 5.26661C8.4942 5.23311 8.73954 4.93345 8.70601 4.59732C8.65786 4.11463 8.54251 3.6666 8.37892 3.26169L8.66928 2.97135L11.5354 5.83753L10.6106 6.76237H4.87824L7.40802 4.2326C7.42885 4.32128 7.44684 4.41255 7.46162 4.50638ZM6.87284 3.03784C6.57441 2.62008 6.22261 2.34634 5.93815 2.23487C5.80233 2.18165 5.71528 2.17827 5.67638 2.18335C5.6725 2.18387 5.66929 2.18443 5.6666 2.18497L5.6619 2.18607C5.64166 2.21954 5.53594 2.45979 5.74626 3.1449C5.81241 3.36036 5.92262 3.58602 6.09307 3.81761L6.87284 3.03784Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.1932 11.5463C12.6454 11.5463 13.012 11.1797 13.012 10.7275C13.012 10.4475 12.6981 9.92821 12.459 9.5733C12.3299 9.38173 12.0564 9.38174 11.9274 9.57331C11.6883 9.92822 11.3744 10.4475 11.3744 10.7275C11.3744 11.1797 11.741 11.5463 12.1932 11.5463Z"}}]}]},To=P.forwardRef(function(i,e){return P.createElement(Ie,Object.assign({},i,{id:"paint-bucket",ref:e,icon:nl}))});To.displayName="PaintBucket";const il=To;var rl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.49152 1.3335C1.79021 1.3335 1.22168 1.90202 1.22168 2.60334V13.397C1.22168 14.0983 1.79021 14.6668 2.49152 14.6668H9.42803C9.98031 14.6668 10.428 14.2191 10.428 13.6668V13.397V10.9234C10.428 10.7577 10.5623 10.6234 10.728 10.6234H13.2852H13.555C14.1073 10.6234 14.555 10.1757 14.555 9.62343V2.60334C14.555 1.90202 13.9865 1.3335 13.2852 1.3335H2.49152ZM8.85819 13.397C9.02387 13.397 9.15819 13.2627 9.15819 13.097V10.9234C9.15819 10.7577 9.02387 10.6234 8.85819 10.6234H6.60104C6.43536 10.6234 6.30104 10.7577 6.30104 10.9234V13.097C6.30104 13.2627 6.43536 13.397 6.60104 13.397H8.85819ZM13.2852 9.05359C13.2852 9.21927 13.1509 9.35359 12.9852 9.35359H10.728C10.5623 9.35359 10.428 9.21927 10.428 9.05359V6.96718C10.428 6.80149 10.5623 6.66718 10.728 6.66718H12.9852C13.1509 6.66718 13.2852 6.80149 13.2852 6.96718V9.05359ZM8.85819 9.35359C9.02387 9.35359 9.15819 9.21927 9.15819 9.05359V6.96718C9.15819 6.80149 9.02387 6.66718 8.85819 6.66718H6.60104C6.43536 6.66718 6.30104 6.80149 6.30104 6.96718V9.05359C6.30104 9.21927 6.43536 9.35359 6.60104 9.35359H8.85819ZM13.2852 5.09734C13.2852 5.26302 13.1509 5.39734 12.9852 5.39734H10.728C10.5623 5.39734 10.428 5.26302 10.428 5.09734V2.90334C10.428 2.73765 10.5623 2.60334 10.728 2.60334H12.9852C13.1509 2.60334 13.2852 2.73765 13.2852 2.90334V5.09734ZM8.85819 5.39734C9.02387 5.39734 9.15819 5.26302 9.15819 5.09734V2.90334C9.15819 2.73765 9.02387 2.60334 8.85819 2.60334H6.60104C6.43536 2.60334 6.30104 2.73765 6.30104 2.90334V5.09734C6.30104 5.26302 6.43536 5.39734 6.60104 5.39734H8.85819ZM5.0312 2.90334C5.0312 2.73765 4.89689 2.60334 4.7312 2.60334H2.79152C2.62584 2.60334 2.49152 2.73765 2.49152 2.90334V5.09734C2.49152 5.26302 2.62584 5.39734 2.79152 5.39734H4.7312C4.89689 5.39734 5.0312 5.26302 5.0312 5.09734V2.90334ZM5.0312 6.96718C5.0312 6.80149 4.89689 6.66718 4.7312 6.66718H2.79152C2.62584 6.66718 2.49152 6.80149 2.49152 6.96718V9.05359C2.49152 9.21927 2.62584 9.35359 2.79152 9.35359H4.7312C4.89689 9.35359 5.0312 9.21927 5.0312 9.05359V6.96718ZM5.0312 10.9234C5.0312 10.7577 4.89689 10.6234 4.7312 10.6234H2.79152C2.62584 10.6234 2.49152 10.7577 2.49152 10.9234V13.097C2.49152 13.2627 2.62584 13.397 2.79152 13.397H4.7312C4.89689 13.397 5.0312 13.2627 5.0312 13.097V10.9234Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.0703 11.9137C12.0445 11.75 12.2176 11.6277 12.3633 11.7068L14.6735 12.9609C14.8412 13.052 14.7972 13.3003 14.6155 13.3333C14.6046 13.3352 14.5937 13.3371 14.5831 13.34L13.58 13.6178L12.8438 14.5421C12.7486 14.7038 12.5031 14.6572 12.4739 14.4718L12.0703 11.9137Z"}}]},Eo=P.forwardRef(function(i,e){return P.createElement(Ie,Object.assign({},i,{id:"select-range-single",ref:e,icon:rl}))});Eo.displayName="SelectRangeSingle";const ol=Eo,sl="univer-range-selector",al="univer-range-selector-editor",ll="univer-range-selector-icon",cl="univer-range-selector-active",tt={rangeSelector:sl,rangeSelectorEditor:al,rangeSelectorIcon:ll,rangeSelectorActive:cl};function dl(i){const{onChange:e,onActive:t}=i,[n,r]=P.useState(!1),o=P.useRef(null),s=K.useDependency(l.LocaleService),a=K.useDependency(S.SelectionManagerService);P.useEffect(()=>{var m;if(n){t(n);const g=a.selectionMoveEnd$.subscribe(_=>{const f=["A1","B2:C3","Sheet2!A1:B2","D10:E11,F1:G2,H3:I4"],v=Math.floor(Math.random()*f.length),R=f[v];o.current&&(o.current.innerHTML=R)});return document.addEventListener("click",c),()=>{document.removeEventListener("click",c),g.unsubscribe()}}e(((m=o.current)==null?void 0:m.innerHTML)||"")},[n]);function c(m){var v,R,M;if(((v=m.target)==null?void 0:v.closest('[data-range-selector="true"]'))||m.target===o.current)return;const _=(R=m.target)==null?void 0:R.closest(`.${tt.rangeSelector}`);(_==null?void 0:_.querySelector(`.${tt.rangeSelectorEditor}`))!==o.current&&(r(!1),(M=o.current)==null||M.blur())}function d(m){m.stopPropagation(),m.key==="Enter"&&(m.preventDefault(),m.currentTarget.blur(),r(!1))}function u(){r(!0)}function h(){var m;if(!n){(m=o.current)==null||m.focus();return}r(!n)}return p.jsxs("div",{className:n?`${tt.rangeSelector} ${tt.rangeSelectorActive}`:tt.rangeSelector,children:[p.jsx("div",{ref:o,className:tt.rangeSelectorEditor,contentEditable:!0,"data-placeholder":s.t("rangeSelector.placeholder"),onKeyDown:d,onFocus:u}),p.jsx(ge.Tooltip,{title:s.t("rangeSelector.tooltip"),placement:"bottom",children:p.jsx("button",{className:tt.rangeSelectorIcon,onClick:h,children:p.jsx(ol,{})})})]})}var St=(i=>(i.Append="APPEND",i.Default="DEFAULT",i.Only="ONLY",i))(St||{}),de=(i=>(i.NUMBER="number",i.DATE="date",i.EXTEND_NUMBER="extendNumber",i.CHN_NUMBER="chnNumber",i.CHN_WEEK2="chnWeek2",i.CHN_WEEK3="chnWeek3",i.LOOP_SERIES="loopSeries",i.FORMULA="formula",i.OTHER="other",i))(de||{}),ie=(i=>(i.COPY="0",i.SERIES="1",i.ONLY_FORMAT="2",i.NO_FORMAT="3",i))(ie||{});const ul={type:de.NUMBER,priority:1e3,match:i=>typeof(i==null?void 0:i.v)=="number"||(i==null?void 0:i.t)===l.CellValueType.NUMBER,isContinue:(i,e)=>i.type===de.NUMBER,applyFunctions:{[ie.SERIES]:(i,e,t)=>{const{data:n}=i;return t===l.Direction.LEFT||t===l.Direction.UP?(n.reverse(),sr(n,e,t).reverse()):sr(n,e,t)}}},yo={type:de.OTHER,priority:0,match:()=>!0,isContinue:(i,e)=>i.type===de.OTHER},hl={type:de.EXTEND_NUMBER,priority:900,match:i=>on(`${i==null?void 0:i.v}`||"").isExtendNumber,isContinue:(i,e)=>{var t;if(i.type===de.EXTEND_NUMBER){const{beforeTxt:n,afterTxt:r}=on(`${(t=i.cellData)==null?void 0:t.v}`||""),{beforeTxt:o,afterTxt:s}=on(`${e==null?void 0:e.v}`||"");if(n===o&&r===s)return!0}return!1},applyFunctions:{[ie.SERIES]:(i,e,t)=>{var a;const{data:n}=i,r=t===l.Direction.UP||t===l.Direction.LEFT;let o;if(n.length===1)return o=r?-1:1,be(ar(n,e,o),r);const s=[];for(let c=0;c<n.length;c++){const d=`${(a=n[c])==null?void 0:a.v}`;d&&s.push(Number(on(d).matchTxt))}return r&&(n.reverse(),s.reverse()),Kt(s)?(o=s[1]-s[0],be(ar(n,e,o),r)):at(n,e)}}},ml={type:de.CHN_NUMBER,priority:830,match:i=>!!hs(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>i.type===de.CHN_NUMBER,applyFunctions:{[ie.SERIES]:(i,e,t)=>{var c,d,u;const{data:n}=i,r=t===l.Direction.LEFT||t===l.Direction.UP;if(n.length===1){const h=`${(c=n[0])==null?void 0:c.v}`;let m;return r?m=-1:m=1,h&&(h==="日"||$e(h)<7)?be(It(n,e,m),r):be(lr(n,e,m),r)}let o=!1;for(let h=0;h<n.length;h++)if(((d=n[h])==null?void 0:d.v)==="日"){o=!0;break}const s=[];let a=0;for(let h=0;h<n.length;h++){const m=`${(u=n[h])==null?void 0:u.v}`;m==="日"?h===0?s.push(0):(a++,s.push(a*7)):o&&$e(m)>0&&$e(m)<7?s.push($e(m)+a*7):s.push($e(m))}if(r&&(n.reverse(),s.reverse()),Kt(s)){if(o||s[s.length-1]<6&&s[0]>0||s[0]<6&&s[s.length-1]>0){const m=s[1]-s[0];return be(It(n,e,m),r)}const h=s[1]-s[0];return be(lr(n,e,h),r)}return at(n,e)}}},gl={type:de.CHN_WEEK2,priority:820,match:i=>!!ms(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>i.type===de.CHN_WEEK2,applyFunctions:{[ie.SERIES]:(i,e,t)=>{var a;const{data:n}=i,r=t===l.Direction.LEFT||t===l.Direction.UP;if(n.length===1){let c;return r?c=-1:c=1,be(It(n,e,c,1),r)}const o=[];let s=0;for(let c=0;c<n.length;c++){const d=`${(a=n[c])==null?void 0:a.v}`,u=d==null?void 0:d.substr(d.length-1,1);d==="周日"?c===0?o.push(0):(s++,o.push(s*7)):o.push($e(u)+s*7)}if(r&&(n.reverse(),o.reverse()),Kt(o)){const c=o[1]-o[0];return be(It(n,e,c,1),r)}return at(n,e)}}},_l={type:de.CHN_WEEK3,priority:810,match:i=>gs(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>i.type===de.CHN_WEEK3,applyFunctions:{[ie.SERIES]:(i,e,t)=>{var a;const{data:n}=i,r=t===l.Direction.LEFT||t===l.Direction.UP;if(n.length===1){let c;return r?c=-1:c=1,be(It(n,e,c,2),r)}const o=[];let s=0;for(let c=0;c<n.length;c++){const d=`${(a=n[c])==null?void 0:a.v}`;if(d){const u=d.substr(d.length-1,1);d==="星期日"?c===0?o.push(0):(s++,o.push(s*7)):o.push($e(u)+s*7)}}if(r&&(n.reverse(),o.reverse()),Kt(o)){const c=o[1]-o[0];return be(It(n,e,c,2),r)}return at(n,e)}}},Sl={type:de.LOOP_SERIES,priority:800,match:i=>Is(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>{var t;return i.type===de.LOOP_SERIES?si(`${(t=i.cellData)==null?void 0:t.v}`||"").name===si(`${e==null?void 0:e.v}`||"").name:!1},applyFunctions:{[ie.SERIES]:(i,e,t)=>{var c,d;const{data:n}=i,r=t===l.Direction.LEFT||t===l.Direction.UP,{series:o}=si(`${(c=n[0])==null?void 0:c.v}`||"");if(n.length===1){let u;return r?u=-1:u=1,be(cr(n,e,u,o),r)}const s=[];let a=0;for(let u=0;u<n.length;u++){const h=`${(d=n[u])==null?void 0:d.v}`;h&&(h===o[0]?u===0?s.push(0):(a++,s.push(a*o.length)):s.push(o.indexOf(h)+a*7))}if(r&&(n.reverse(),s.reverse()),Kt(s)){const u=s[1]-s[0];return be(cr(n,e,u,o),r)}return at(n,e)}}};function be(i,e){return e?i.reverse():i}var fl=Object.defineProperty,pl=Object.getOwnPropertyDescriptor,vl=(i,e,t,n)=>{for(var r=n>1?void 0:n?pl(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&fl(e,t,r),r},li=(i,e)=>(t,n)=>e(t,n,i);exports.AutoFillService=class extends l.Disposable{constructor(t,n,r){super();C(this,"_rules",[]);C(this,"_hooks",[]);C(this,"_applyType$",new N.BehaviorSubject(ie.SERIES));C(this,"_isFillingStyle",!0);C(this,"_autoFillLocation$",new N.BehaviorSubject(null));C(this,"autoFillLocation$",this._autoFillLocation$.asObservable());C(this,"_showMenu$",new N.BehaviorSubject(!1));C(this,"showMenu$",this._showMenu$.asObservable());C(this,"_direction",l.Direction.DOWN);C(this,"applyType$",this._applyType$.asObservable());C(this,"_menu$",new N.BehaviorSubject([{label:"autoFill.copy",value:ie.COPY,disable:!1},{label:"autoFill.series",value:ie.SERIES,disable:!1},{label:"autoFill.formatOnly",value:ie.ONLY_FORMAT,disable:!1},{label:"autoFill.noFormat",value:ie.NO_FORMAT,disable:!1}]));C(this,"menu$",this._menu$.asObservable());this._sheetInterceptorService=t,this._univerInstanceService=n,this._selectionManagerService=r,this._init()}_init(){this._rules=[ul,hl,ml,gl,_l,Sl,yo].sort((t,n)=>n.priority-t.priority),this._isFillingStyle=!0}getOneByPriority(t){return t.length<=0?[]:[t.reduce((r,o)=>(o.priority||0)>(r.priority||0)?o:r,t[0])]}addHook(t){if(this._hooks.find(n=>n.id===t.id))throw new Error(`Add hook failed, hook id '${t.id}' already exist!`);return t.priority===void 0&&(t.priority=0),t.type===void 0&&(t.type=St.Append),this._hooks.push(t),l.toDisposable(()=>{const n=this._hooks.findIndex(r=>r===t);n>-1&&this._hooks.splice(n,1)})}registerRule(t){if(this._rules.find(r=>r.type===t.type))throw new Error(`Registry rule failed, type '${t.type}' already exist!`);const n=this._rules.findIndex(r=>r.priority<t.priority);this._rules.splice(n===-1?this._rules.length:n,0,t)}getRules(){return this._rules}getAllHooks(){return this._hooks}getActiveHooks(){const{source:t,target:n,unitId:r,subUnitId:o}=this.autoFillLocation||{};if(!t||!n||!r||!o)return[];const s=this._hooks.filter(u=>{var h;return!((h=u.disable)!=null&&h.call(u,{source:t,target:n,unitId:r,subUnitId:o},this._direction,this.applyType))}),a=s.filter(u=>u.type===St.Only);if(a.length>0)return this.getOneByPriority(a);const c=this.getOneByPriority(s.filter(u=>u.type===St.Default)),d=s.filter(u=>u.type===St.Append)||[];return[...c,...d]}get applyType(){return this._applyType$.getValue()}set applyType(t){this._applyType$.next(t)}get menu(){return this._menu$.getValue()}get direction(){return this._direction}set direction(t){this._direction=t}isFillingStyle(){return this._isFillingStyle}setFillingStyle(t){this._isFillingStyle=t}get autoFillLocation(){return this._autoFillLocation$.getValue()}set autoFillLocation(t){this._autoFillLocation$.next(t)}setDisableApplyType(t,n){this._menu$.next(this._menu$.getValue().map(r=>r.value===t?{...r,disable:n}:r))}setShowMenu(t){this._showMenu$.next(t)}};exports.AutoFillService=vl([l.OnLifecycle(l.LifecycleStages.Rendered,exports.AutoFillService),li(0,D.Inject(S.SheetInterceptorService)),li(1,D.Inject(l.IUniverInstanceService)),li(2,D.Inject(S.SelectionManagerService))],exports.AutoFillService);const Jt=D.createIdentifier("univer.auto-fill-service");var Cl=Object.defineProperty,Il=Object.getOwnPropertyDescriptor,Rl=(i,e,t,n)=>{for(var r=n>1?void 0:n?Il(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Cl(e,t,r),r},Fe=(i,e)=>(t,n)=>e(t,n,i);exports.AutoFillController=class extends l.Disposable{constructor(t,n,r,o,s,a,c,d,u){super();C(this,"_beforeApplyData",[]);C(this,"_copyData",[]);C(this,"_defaultHook");this._univerInstanceService=t,this._selectionRenderService=n,this._commandService=r,this._undoRedoService=o,this._autoFillService=s,this._editorBridgeService=a,this._sheetInterceptorService=c,this._selectionManagerService=d,this._injector=u,this._defaultHook={id:"default",type:St.Default,priority:0,onBeforeFillData:(h,m)=>{this._presetAndCacheData(h,m)},onFillData:(h,m,g)=>this._fillData(h,m,g)},this._init()}_init(){this._initDefaultHook(),this._onSelectionControlFillChanged(),this._onApplyTypeChanged(),[Kr,hn].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initDefaultHook(){this._autoFillService.addHook(this._defaultHook)}_onSelectionControlFillChanged(){const t=new l.DisposableCollection;this.disposeWithMe(this._commandService.onCommandExecuted(n=>{if(n.id!==S.SetSelectionsOperation.id)return;const r=this._selectionManagerService.getCurrent();if((r==null?void 0:r.pluginName)!==S.NORMAL_SELECTION_PLUGIN_NAME)return;t.dispose(),this._selectionRenderService.getCurrentControls().forEach(s=>{t.add(l.toDisposable(s.selectionFilled$.subscribe(a=>{if(a==null||a.startColumn===-1||a.startRow===-1||a.endColumn===-1||a.endRow===-1)return;const c={startColumn:s.model.startColumn,endColumn:s.model.endColumn,startRow:s.model.startRow,endRow:s.model.endRow},d={startColumn:a.startColumn,endColumn:a.endColumn,startRow:a.startRow,endRow:a.endRow};this._triggerAutoFill(c,d)}))),t.add(l.toDisposable(s.fillControl.onDblclickObserver.add(()=>{const a={startColumn:s.model.startColumn,endColumn:s.model.endColumn,startRow:s.model.startRow,endRow:s.model.endRow};this._handleDbClickFill(a)}))),t.add(l.toDisposable(s.fillControl.onPointerDownObserver.add(()=>{this._editorBridgeService.isVisible().visible&&this._editorBridgeService.changeVisible({visible:!1,eventType:b.DeviceInputEventType.PointerDown})})))})}))}_onApplyTypeChanged(){this.disposeWithMe(l.toDisposable(this._autoFillService.applyType$.subscribe(()=>{this._handleFillData()})))}_triggerAutoFill(t,n){var d;if(t.startColumn===n.startColumn&&t.startRow===n.startRow&&t.endColumn===n.endColumn&&t.endRow===n.endRow)return;if(n.endColumn<t.endColumn&&n.endColumn>t.startColumn){this._commandService.executeCommand(hn.id,{clearRange:{startRow:n.startRow,endRow:n.endRow,startColumn:n.endColumn+1,endColumn:t.endColumn},selectionRange:n});return}if(n.endRow<t.endRow&&n.endRow>t.startRow){this._commandService.executeCommand(hn.id,{clearRange:{startRow:n.endRow+1,endRow:t.endRow,startColumn:n.startColumn,endColumn:n.endColumn},selectionRange:n});return}const r={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn};let o=null;if(n.startRow<t.startRow)o=l.Direction.UP,r.endRow=t.startRow-1;else if(n.endRow>t.endRow)o=l.Direction.DOWN,r.startRow=t.endRow+1;else if(n.startColumn<t.startColumn)o=l.Direction.LEFT,r.endColumn=t.startColumn-1;else if(n.endColumn>t.endColumn)o=l.Direction.RIGHT,r.startColumn=t.endColumn+1;else return;const s=this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),a=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();this._autoFillService.direction=o,this._autoFillService.autoFillLocation={source:t,target:r,unitId:s,subUnitId:a},this._autoFillService.getActiveHooks().forEach(u=>{var h;(h=u==null?void 0:u.onBeforeFillData)==null||h.call(u,{source:t,target:r,unitId:s,subUnitId:a},o)}),(d=this._autoFillService.menu.find(u=>u.value===ie.SERIES))!=null&&d.disable?this._autoFillService.applyType=ie.COPY:this._autoFillService.applyType=ie.SERIES}_handleDbClickFill(t){const n=this._detectFillRange(t);n.endRow<=t.endRow||this._triggerAutoFill(t,n)}_detectFillRange(t){var m,g,_,f,v,R;const{startRow:n,endRow:r,startColumn:o,endColumn:s}=t,a=(m=this._univerInstanceService.getCurrentUniverSheetInstance())==null?void 0:m.getActiveSheet();if(!a)return t;const c=a.getCellMatrix(),d=a.getMaxRows()-1,u=a.getMaxColumns()-1;let h=r;if(o>0&&((g=c.getValue(n,o-1))==null?void 0:g.v)!=null){let M=n;for(;((_=c.getValue(M,o-1))==null?void 0:_.v)!=null&&M<d;)M+=1;h=M-1}else if(s<u&&((f=c.getValue(r,s+1))==null?void 0:f.v)!=null){let M=n;for(;((v=c.getValue(M,s+1))==null?void 0:v.v)!=null&&M<d;)M+=1;h=M-1}for(let M=r+1;M<=h;M++)for(let T=o;T<=s;T++)if(((R=c.getValue(M,T))==null?void 0:R.v)!=null){h=M-1;break}return{startColumn:o,endColumn:s,startRow:n,endRow:h}}_handleFillData(){const{source:t,target:n,unitId:r=this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),subUnitId:o=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId()}=this._autoFillService.autoFillLocation||{},s=this._autoFillService.direction;if(!t||!n)return;const a=l.Rectangle.union(t,n),c=this._autoFillService.applyType,d=this._autoFillService.getActiveHooks();this._commandService.syncExecuteCommand(S.SetSelectionsOperation.id,{selections:[{primary:{...a,actualRow:a.startRow,actualColumn:a.startColumn,endColumn:a.startColumn,endRow:a.startRow},range:{...a,rangeType:l.RANGE_TYPE.NORMAL}}],unitId:r,subUnitId:o});const u=[],h=[];d.forEach(g=>{var v;const{undos:_,redos:f}=((v=g.onFillData)==null?void 0:v.call(g,{source:t,target:n,unitId:r,subUnitId:o},s,c))||{};_&&u.push(..._),f&&h.push(...f)}),h.every(g=>this._commandService.syncExecuteCommand(g.id,g.params))&&this._undoRedoService.pushUndoRedo({unitID:r,undoMutations:u,redoMutations:h}),d.forEach(g=>{var _;(_=g.onAfterFillData)==null||_.call(g,{source:t,target:n,unitId:r,subUnitId:o},s,c)}),this._autoFillService.setShowMenu(!0)}_getApplyData(t,n,r,o,s,a=!0){const c=[],d=Math.floor(r/n),u=r%n,h=this._autoFillService.getRules();if(!a&&s===ie.ONLY_FORMAT)return console.error("ERROR: only format can not be applied when hasStyle is false"),[];const m={};h.forEach(g=>{m[g.type]=[]}),h.forEach(g=>{const{type:_,applyFunctions:f={}}=g,v=t[_];v&&v.forEach(R=>{const M=_s(R.index,u),T=R.index.length*d+M,w=this._applyFunctions(R,T,o,s,f,t),E=Ss(n,r,R.index);m[_].push({data:w,index:E})})});for(let g=0;g<r;g++)h.forEach(_=>{const{type:f}=_,v=m[f];for(let R=0;R<v.length;R++)g in v[R].index&&c.push(v[R].data[v[R].index[g]])});return c}_applyFunctions(t,n,r,o,s,a){const{data:c}=t,d=r===l.Direction.UP||r===l.Direction.LEFT;if(o===ie.COPY){const u=s==null?void 0:s[ie.COPY];return u?u(t,n,r,a):(d&&c.reverse(),at(c,n))}if(o===ie.SERIES){const u=s==null?void 0:s[ie.SERIES];return u?u(t,n,r,a):(d&&c.reverse(),s!=null&&s[ie.COPY]?s[ie.COPY](t,n,r,a):at(c,n))}if(o===ie.ONLY_FORMAT){const u=s==null?void 0:s[ie.ONLY_FORMAT];return u?u(t,n,r,a):fs(c,n)}}_getCopyData(t,n){const{startRow:r,startColumn:o,endRow:s,endColumn:a}=t,c=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getCellMatrix(),d=this._autoFillService.getRules(),u=[],h=n===l.Direction.DOWN||n===l.Direction.UP;let m,g,_,f;h?(m=o,g=a,_=r,f=s):(m=r,g=s,_=o,f=a);for(let v=m;v<=g;v++){const R=this._getEmptyCopyDataPiece(),M={type:void 0,cellData:void 0};for(let T=_;T<=f;T++){let w;h?w=c.getValue(T,v):w=c.getValue(v,T);const{type:E,isContinue:y}=d.find(x=>x.match(w))||yo;if(y(M,w)){const x=R[E],O=x[x.length-1];O.data.push(w),O.index.push(T-_)}else{const x=R[E];x?x.push({data:[w],index:[T-_]}):R[E]=[{data:[w],index:[T-_]}]}M.type=E,M.cellData=w}u.push(R)}return u}_getEmptyCopyDataPiece(){const t={};return this._autoFillService.getRules().forEach(n=>{t[n.type]=[]}),t}_getMergeApplyData(t,n,r,o){const s=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData(),a=[];for(let c=t.startRow;c<=t.endRow;c++)for(let d=t.startColumn;d<=t.endColumn;d++){const{isMergedMainCell:u,startRow:h,startColumn:m,endRow:g,endColumn:_}=b.getCellInfoInMergeData(c,d,s);if(u){if(r===l.Direction.DOWN){let f=h+o,v=g+o;for(;v<=n.endRow;)a.push({startRow:f,startColumn:m,endRow:v,endColumn:_}),f+=o,v+=o}else if(r===l.Direction.UP){let f=h-o,v=g-o;for(;f>=n.startRow;)a.push({startRow:f,startColumn:m,endRow:v,endColumn:_}),f-=o,v-=o}else if(r===l.Direction.RIGHT){let f=m+o,v=_+o;for(;v<=n.endColumn;)a.push({startRow:h,startColumn:f,endRow:g,endColumn:v}),f+=o,v+=o}else if(r===l.Direction.LEFT){let f=m-o,v=_-o;for(;f>=n.startColumn;)a.push({startRow:h,startColumn:f,endRow:g,endColumn:v}),f-=o,v-=o}}}return a}_presetAndCacheData(t,n){const{source:r,target:o}=t,s=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getCellMatrix(),a=[];for(let c=o.startRow;c<=o.endRow;c++){const d=[];for(let u=o.startColumn;u<=o.endColumn;u++)d.push(l.Tools.deepClone(s.getValue(c,u)));a.push(d)}this._beforeApplyData=a,this._copyData=this._getCopyData(r,n),this._hasSeries(this._copyData)?this._autoFillService.setDisableApplyType(ie.SERIES,!1):this._autoFillService.setDisableApplyType(ie.SERIES,!0)}_fillData(t,n,r){var q,oe;const o=[],s=[];let a=!0;r===ie.NO_FORMAT&&(a=!1,r=ie.SERIES);const{source:c,target:d,unitId:u,subUnitId:h}=t;if(!c||!d||n==null)return{undos:o,redos:s};const{startRow:m,startColumn:g,endRow:_,endColumn:f}=c,{startRow:v,startColumn:R,endRow:M,endColumn:T}=d,w=this._copyData;let E;n===l.Direction.DOWN||n===l.Direction.UP?E=_-m+1:E=f-g+1;const y=[];if(n===l.Direction.DOWN||n===l.Direction.UP){const $=M-v+1,Z=[];for(let G=R;G<=T;G++){const le=w[G-R],se=this._getApplyData(le,E,$,n,r,a);Z.push(se)}for(let G=0;G<Z[0].length;G++){const le=[];for(let se=0;se<Z.length;se++)le.push({s:null,...Z[se][G]});y.push(le)}}else{const $=T-R+1;for(let Z=v;Z<=M;Z++){const G=w[Z-v],le=this._getApplyData(G,E,$,n,r,a),se=[];for(let me=0;me<le.length;me++)se.push({s:null,...le[me]});y.push(se)}}let x=[];const O=this._univerInstanceService.getCurrentUniverSheetInstance().getStyles();a?(x=this._getMergeApplyData(c,d,n,E),y.forEach($=>{$.forEach(Z=>{Z&&O&&O&&(Z.s=O.getStyleByCell(Z))})})):y.forEach(($,Z)=>{$.forEach((G,le)=>{G&&O&&(G.s=O.getStyleByCell(this._beforeApplyData[Z][le])||null)})}),r===ie.ONLY_FORMAT&&y.forEach(($,Z)=>{$.forEach((G,le)=>{if(G){const se=this._beforeApplyData[Z][le]||{};G.f=se.f,G.si=se.si,G.t=se.t,G.v=se.v}})});const A={get:this._injector.get.bind(this._injector)},k=[],H=(oe=(q=this._univerInstanceService.getUniverSheetInstance(u))==null?void 0:q.getSheetBySheetId(h))==null?void 0:oe.getMergeData();H&&H.forEach($=>{l.Rectangle.intersects($,d)&&k.push($)});const B={unitId:u,subUnitId:h,ranges:k},F=S.RemoveMergeUndoMutationFactory(A,B);s.push({id:S.RemoveWorksheetMergeMutation.id,params:B}),o.push({id:S.AddWorksheetMergeMutation.id,params:F});const j={subUnitId:h,unitId:u,cellValue:Gr([d])},z=S.SetRangeValuesUndoMutationFactory(A,j),ee=this._sheetInterceptorService.onCommandExecute({id:S.ClearSelectionContentCommand.id});s.push({id:S.SetRangeValuesMutation.id,params:j},...ee.redos),o.push(...ee.undos,{id:S.SetRangeValuesMutation.id,params:z});const W=new l.ObjectMatrix,{startRow:Q,startColumn:re,endRow:Y,endColumn:L}=d;for(let $=0;$<=Y-Q;$++)for(let Z=0;Z<=L-re;Z++)y[$][Z]&&W.setValue($+Q,Z+re,y[$][Z]);const U={subUnitId:h,unitId:u,cellValue:W.getMatrix()},X=S.SetRangeValuesUndoMutationFactory(A,U);if(o.push({id:S.SetRangeValuesMutation.id,params:X}),s.push({id:S.SetRangeValuesMutation.id,params:U}),x!=null&&x.length){const $=S.getAddMergeMutationRangeByType(x),Z={unitId:u,subUnitId:h,ranges:$},G=S.AddMergeUndoMutationFactory(A,Z);o.push({id:S.RemoveWorksheetMergeMutation.id,params:G}),s.push({id:S.AddWorksheetMergeMutation.id,params:Z})}return{undos:o,redos:s}}_hasSeries(t){return t.some(n=>Object.keys(n).some(o=>{var s;return!!((s=n[o])!=null&&s.length&&![de.OTHER,de.FORMULA].includes(o))}))}};exports.AutoFillController=Rl([l.OnLifecycle(l.LifecycleStages.Steady,exports.AutoFillController),Fe(0,l.IUniverInstanceService),Fe(1,_e),Fe(2,l.ICommandService),Fe(3,l.IUndoRedoService),Fe(4,Jt),Fe(5,Te),Fe(6,D.Inject(S.SheetInterceptorService)),Fe(7,D.Inject(S.SelectionManagerService)),Fe(8,D.Inject(D.Injector))],exports.AutoFillController);const Oo={id:"sheet.command.hide-row-confirm",type:l.CommandType.COMMAND,handler:async i=>{var c;const t=(c=i.get(S.SelectionManagerService).getSelections())==null?void 0:c.map(d=>d.range);if(!(t!=null&&t.length))return!1;const n=i.get(l.ICommandService),a=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance().getActiveSheet().getVisibleRows();if(co(a,t)){const d=i.get(I.IConfirmService),u=i.get(l.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 n.executeCommand(S.SetRowHiddenCommand.id),!0}},xo={id:"sheet.command.hide-col-confirm",type:l.CommandType.COMMAND,handler:async i=>{var c;const t=(c=i.get(S.SelectionManagerService).getSelections())==null?void 0:c.map(d=>d.range);if(!(t!=null&&t.length))return!1;const n=i.get(l.ICommandService),a=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance().getActiveSheet().getVisibleCols();if(uo(a,t)){const d=i.get(I.IConfirmService),u=i.get(l.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 n.executeCommand(S.SetColHiddenCommand.id),!0}},Vi={type:l.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?e.executeCommand(J.SetInlineFormatBoldCommand.id):e.executeCommand(S.SetBoldCommand.id)}},Bi={type:l.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?e.executeCommand(J.SetInlineFormatItalicCommand.id):e.executeCommand(S.SetItalicCommand.id)}},Fi={type:l.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?e.executeCommand(J.SetInlineFormatUnderlineCommand.id):e.executeCommand(S.SetUnderlineCommand.id)}},Wi={type:l.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?e.executeCommand(J.SetInlineFormatStrikethroughCommand.id):e.executeCommand(S.SetStrikeThroughCommand.id)}},Ml={type:l.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?e.executeCommand(J.SetInlineFormatSubscriptCommand.id):!1}},bl={type:l.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?e.executeCommand(J.SetInlineFormatSuperscriptCommand.id):!1}},Ao={type:l.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(i,e)=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(J.SetInlineFormatFontSizeCommand.id,e):t.executeCommand(S.SetFontSizeCommand.id,e)}},Do={type:l.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(i,e)=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(J.SetInlineFormatFontFamilyCommand.id,e):t.executeCommand(S.SetFontFamilyCommand.id,e)}},$n={type:l.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(i,e)=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(J.SetInlineFormatTextColorCommand.id,e):t.executeCommand(S.SetTextColorCommand.id,e)}};function No(i,e){return e.some(t=>wl(i,t))}function wl(i,e){const{startRow:t,startColumn:n,endColumn:r,endRow:o}=e,s=i.getMatrixWithMergedCells(t,n,o,r);let a=!1;return s.forValue((c,d,u)=>{if(u&&(c!==t||d!==n)&&i.cellHasValue(u))return a=!0,!1}),a}function Ho(i,e,t,n){const r=[],o=[],s=t.getSheetId();return n.forEach(a=>{const c=Tl(t,a),d={unitId:e,subUnitId:s,cellValue:c.getData()},u=S.SetRangeValuesUndoMutationFactory(i,d);r.push({id:S.SetRangeValuesMutation.id,params:u}),o.push({id:S.SetRangeValuesMutation.id,params:d})}),{undos:r,redos:o}}function Tl(i,e){const{startRow:t,startColumn:n,endColumn:r,endRow:o}=e,s=i.getMatrixWithMergedCells(t,n,o,r),a=new l.ObjectMatrix;return s.forValue((c,d,u)=>{u&&(c!==t||d!==n)&&a.setValue(c,d,null)}),a}var El=Object.defineProperty,yl=Object.getOwnPropertyDescriptor,Ol=(i,e,t,n)=>{for(var r=n>1?void 0:n?yl(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&El(e,t,r),r},ci=(i,e)=>(t,n)=>e(t,n,i),Oe=(i=>(i[i.OFF=0]="OFF",i[i.ONCE=1]="ONCE",i[i.INFINITE=2]="INFINITE",i))(Oe||{});const Tt=D.createIdentifier("univer.format-painter-service");let Ti=class extends l.Disposable{constructor(e,t,n){super();C(this,"status$");C(this,"_selectionFormat");C(this,"_markId",null);C(this,"_status$");this._selectionManagerService=e,this._univerInstanceService=t,this._markSelectionService=n,this._status$=new N.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new l.ObjectMatrix,merges:[]}}setStatus(e){e!==0&&this._getSelectionRangeFormat(),this._updateRangeMark(e),this._status$.next(e)}getStatus(){return this._status$.getValue()}_updateRangeMark(e){if(this._markSelectionService.removeAllShapes(),this._markId=null,e!==0){const t=this._selectionManagerService.getLast();if(t){const n=this._selectionManagerService.createCopyPasteSelection();e===2?this._markId=this._markSelectionService.addShape({...t,style:n}):this._markId=this._markSelectionService.addShape({...t,style:n},[S.SetRangeValuesMutation.id])}}}_getSelectionRangeFormat(){const e=this._selectionManagerService.getLast(),t=e==null?void 0:e.range;if(!t)return;const{startRow:n,endRow:r,startColumn:o,endColumn:s}=t,a=this._univerInstanceService.getCurrentUniverSheetInstance(),d=(a==null?void 0:a.getActiveSheet()).getCellMatrix(),u=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData(),h=a.getStyles(),m=new l.ObjectMatrix;for(let g=n;g<=r;g++)for(let _=o;_<=s;_++){const f=d.getValue(g,_);m.setValue(g,_,h.getStyleByCell(f)||{});const{isMergedMainCell:v,...R}=b.getCellInfoInMergeData(g,_,u);v&&this._selectionFormat.merges.push({startRow:R.startRow,startColumn:R.startColumn,endRow:R.endRow,endColumn:R.endColumn})}this._selectionFormat.styles=m}getSelectionFormat(){return this._selectionFormat}};Ti=Ol([ci(0,D.Inject(S.SelectionManagerService)),ci(1,l.IUniverInstanceService),ci(2,qt)],Ti);const ji={id:"sheet.operation.set-format-painter",type:l.CommandType.OPERATION,handler:(i,e)=>e?(i.get(Tt).setStatus(e.status),!0):!1},Po={type:l.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async i=>{const t=i.get(Tt).getStatus();let n;return t!==Oe.OFF?n=Oe.OFF:n=Oe.INFINITE,i.get(l.ICommandService).executeCommand(ji.id,{status:n})}},$i={type:l.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async i=>{const t=i.get(Tt).getStatus();let n;return t!==Oe.OFF?n=Oe.OFF:n=Oe.ONCE,i.get(l.ICommandService).executeCommand(ji.id,{status:n})}},Lo={type:l.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(i,e)=>{const t=i.get(l.ICommandService),n=i.get(l.IUndoRedoService),r=i.get(l.IUniverInstanceService),o=i.get(S.SelectionManagerService),s=i.get(S.SheetInterceptorService),{styleValues:a,styleRange:c,mergeRanges:d,unitId:u=r.getCurrentUniverSheetInstance().getUnitId(),subUnitId:h=r.getCurrentUniverSheetInstance().getActiveSheet().getSheetId()}=e,m=c?[c]:o.getSelectionRanges();if(!m||!m.length)return!1;const g=new l.ObjectMatrix;let _;if(l.Tools.isArray(a))for(let j=0;j<m.length;j++){const{startRow:z,startColumn:ee,endRow:W,endColumn:Q}=m[j];for(let re=0;re<=W-z;re++)for(let Y=0;Y<=Q-ee;Y++)g.setValue(re+z,Y+ee,a[re][Y])}else if(l.isICellData(a))for(let j=0;j<m.length;j++){const{startRow:z,startColumn:ee}=m[j];g.setValue(z,ee,a)}else _=a;const f={subUnitId:h,unitId:u,cellValue:_!=null?_:g.getMatrix()},v=S.SetRangeValuesUndoMutationFactory(i,f);if(!s.fetchThroughInterceptors(S.INTERCEPTOR_POINT.PERMISSION)(null,{id:S.SetRangeValuesCommand.id,params:f}))return!1;const R=t.syncExecuteCommand(S.SetRangeValuesMutation.id,f),{undos:M,redos:T}=s.onCommandExecute({id:S.SetRangeValuesCommand.id,params:{...f,range:m}}),w=S.getAddMergeMutationRangeByType(d),E=r.getUniverSheetInstance(u).getSheetBySheetId(h),y=[],x=[],O=No(E,w),A={unitId:u,subUnitId:h,ranges:w},k={unitId:u,subUnitId:h,ranges:w};y.push({id:S.RemoveWorksheetMergeMutation.id,params:A}),y.push({id:S.AddWorksheetMergeMutation.id,params:k});const H=S.RemoveMergeUndoMutationFactory(i,A),B=S.AddMergeUndoMutationFactory(i,k);if(x.push({id:S.RemoveWorksheetMergeMutation.id,params:B}),x.push({id:S.AddWorksheetMergeMutation.id,params:H}),O){const j=Ho(i,u,E,w);y.unshift(...j.redos),x.push(...j.undos)}const F=await l.sequenceExecute([...T,...y],t);return R&&F.result?(n.pushUndoRedo({unitID:u,undoMutations:[{id:S.SetRangeValuesMutation.id,params:v},...M,...x],redoMutations:[{id:S.SetRangeValuesMutation.id,params:f},...T,...y]}),!0):!1}},Kn={type:l.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(i,e)=>{const{type:t}=e||{},n=i.get(l.IUniverInstanceService),r=i.get(l.IUndoRedoService),o=n.getCurrentUniverSheetInstance().getUnitId(),s=n.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),a=i.get(l.ICommandService),d=i.get(S.SelectionManagerService).getSelections();if(!d)return!1;const u=d[(d==null?void 0:d.length)-1],{range:h}=u,m=i.get(Je),{sheetViewStartRow:g=0,sheetViewStartColumn:_=0}=m.getCurrentScroll()||{};let f,v,R,M;const{startRow:T,startColumn:w,rangeType:E}=h;if(E===l.RANGE_TYPE.ROW||t===1)f=T,R=T-g,v=-1,M=0;else if(E===l.RANGE_TYPE.COLUMN||t===2)f=-1,R=0,v=w,M=w-_;else if(E===l.RANGE_TYPE.NORMAL)f=T,R=T-g,v=w,M=w-_;else return!1;const y={unitId:o,subUnitId:s,startRow:f,startColumn:v,xSplit:v>0?Math.max(1,M):M,ySplit:f>0?Math.max(1,R):R},x=S.SetFrozenMutationFactory(i,y);return a.syncExecuteCommand(S.SetFrozenMutation.id,y)&&r.pushUndoRedo({unitID:o,undoMutations:[{id:S.SetFrozenMutation.id,params:x}],redoMutations:[{id:S.SetFrozenMutation.id,params:y}]}),!0}},Uo={type:l.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async i=>(i.get(l.ICommandService).executeCommand(Kn.id,{type:1}),!0)},ko={type:l.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async i=>(i.get(l.ICommandService).executeCommand(Kn.id,{type:2}),!0)},Vo={type:l.CommandType.COMMAND,id:"sheet.command.cancel-frozen",handler:async i=>{const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(l.IUndoRedoService),r=t.getCurrentUniverSheetInstance().getUnitId(),o=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),s={unitId:r,subUnitId:o,startRow:-1,startColumn:-1,xSplit:0,ySplit:0},a=S.SetFrozenMutationFactory(i,s);return e.syncExecuteCommand(S.SetFrozenMutation.id,s)&&n.pushUndoRedo({unitID:r,undoMutations:[{id:S.SetFrozenMutation.id,params:a}],redoMutations:[{id:S.SetFrozenMutation.id,params:s}]}),!0}},Et="UI_PLUGIN_SHEETS",qn=`${Et}_COLOR_PICKER_COMPONENT`,Bo=`${Et}_FONT_FAMILY_COMPONENT`,Fo=`${Et}_FONT_FAMILY_ITEM_COMPONENT`,Wo=`${Et}_FONT_SIZE_COMPONENT`,zi=`${Et}_MENU_ITEM_INPUT_COMPONENT`,xl="univer-sheets-ui-context-menu-input",Al="univer-sheets-ui-context-menu-input-container",Dl="univer-sheets-ui-context-menu-input-number",di={sheetsUiContextMenuInput:xl,sheetsUiContextMenuInputContainer:Al,sheetsUiContextMenuInputNumber:Dl},Nl=i=>{const{prefix:e,suffix:t,value:n,onChange:r,min:o=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=i,a=K.useDependency(l.LocaleService),[c,d]=P.useState(),u=m=>{var g;d(m==null?void 0:m.toString()),r((g=m==null?void 0:m.toString())!=null?g:"")};P.useEffect(()=>{d(n)},[n]);function h(m){m.key==="Backspace"&&m.stopPropagation()}return p.jsxs("div",{className:di.sheetsUiContextMenuInput,children:[a.t(e),p.jsx("span",{className:di.sheetsUiContextMenuInputContainer,onClick:m=>m.stopPropagation(),children:p.jsx(ge.InputNumber,{className:di.sheetsUiContextMenuInputNumber,value:Number(c),precision:0,onKeyDown:h,onChange:u,min:o,max:s})}),a.t(t)]})};var ce=(i=>(i.ROW_HEADER_CONTEXT_MENU="rowHeaderContextMenu",i.COL_HEADER_CONTEXT_MENU="colHeaderContextMenu",i.SHEET_BAR="sheetBar",i))(ce||{});function Hl(i){const e=i.get(Tt);return{id:$i.id,subId:Po.id,group:I.MenuGroup.TOOLBAR_FORMAT,type:I.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",positions:[I.MenuPosition.TOOLBAR_START],activated$:new N.Observable(t=>{let n=!1;const r=e.status$.subscribe(o=>{n=o!==Oe.OFF,t.next(n)});return t.next(n),()=>{r.unsubscribe()}}),hidden$:I.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:S.getCurrentSheetDisabled$(i)}}function Pl(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(l.IContextService),r=i.get(S.SelectionManagerService);return{id:Vi.id,group:I.MenuGroup.TOOLBAR_FORMAT,type:I.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[I.MenuPosition.TOOLBAR_START],disabled$:S.getCurrentSheetDisabled$(i),activated$:new N.Observable(o=>{const s=e.onCommandExecuted(a=>{var d,u;const c=a.id;if(c===S.SetRangeValuesMutation.id||c===S.SetSelectionsOperation.id){const h=(d=r.getLast())==null?void 0:d.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let g=l.FontWeight.NORMAL;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);g=_==null?void 0:_.getFontWeight()}o.next(g===l.FontWeight.BOLD)}if((c===J.SetTextSelectionsOperation.id||c===J.SetInlineFormatCommand.id)&&n.getContextValue(l.EDITOR_ACTIVATED)&&n.getContextValue(l.FOCUSING_SHEET)){const h=en(i);if(h==null)return;const m=(u=h.ts)==null?void 0:u.bl;o.next(m===l.BooleanNumber.TRUE)}});return o.next(!1),s.dispose}),hidden$:I.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function Ll(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(S.SelectionManagerService),r=i.get(l.IContextService);return{id:Bi.id,group:I.MenuGroup.TOOLBAR_FORMAT,type:I.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[I.MenuPosition.TOOLBAR_START],disabled$:S.getCurrentSheetDisabled$(i),activated$:new N.Observable(o=>{const s=e.onCommandExecuted(a=>{var d,u;const c=a.id;if(c===S.SetRangeValuesMutation.id||c===S.SetSelectionsOperation.id){const h=(d=n.getLast())==null?void 0:d.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let g=l.FontItalic.NORMAL;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);g=_==null?void 0:_.getFontStyle()}o.next(g===l.FontItalic.ITALIC)}if((c===J.SetTextSelectionsOperation.id||c===J.SetInlineFormatCommand.id)&&r.getContextValue(l.EDITOR_ACTIVATED)&&r.getContextValue(l.FOCUSING_SHEET)){const h=en(i);if(h==null)return;const m=(u=h.ts)==null?void 0:u.it;o.next(m===l.BooleanNumber.TRUE)}});return o.next(!1),s.dispose}),hidden$:I.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function Ul(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(S.SelectionManagerService),r=i.get(l.IContextService);return{id:Fi.id,group:I.MenuGroup.TOOLBAR_FORMAT,type:I.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[I.MenuPosition.TOOLBAR_START],disabled$:S.getCurrentSheetDisabled$(i),activated$:new N.Observable(o=>{const s=e.onCommandExecuted(a=>{var d,u;const c=a.id;if(c===S.SetRangeValuesMutation.id||c===S.SetSelectionsOperation.id){const h=(d=n.getLast())==null?void 0:d.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let g;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);g=_==null?void 0:_.getUnderline()}o.next(!!(g&&g.s))}if((c===J.SetTextSelectionsOperation.id||c===J.SetInlineFormatCommand.id)&&r.getContextValue(l.EDITOR_ACTIVATED)&&r.getContextValue(l.FOCUSING_SHEET)){const h=en(i);if(h==null)return;const m=(u=h.ts)==null?void 0:u.ul;o.next((m==null?void 0:m.s)===l.BooleanNumber.TRUE)}});return o.next(!1),s.dispose}),hidden$:I.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function kl(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(S.SelectionManagerService),r=i.get(l.IContextService);return{id:Wi.id,group:I.MenuGroup.TOOLBAR_FORMAT,type:I.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[I.MenuPosition.TOOLBAR_START],disabled$:S.getCurrentSheetDisabled$(i),activated$:new N.Observable(o=>{const s=e.onCommandExecuted(a=>{var d,u;const c=a.id;if(c===S.SetRangeValuesMutation.id||c===S.SetSelectionsOperation.id){const h=(d=n.getLast())==null?void 0:d.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let g;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);g=_==null?void 0:_.getStrikeThrough()}o.next(!!(g&&g.s))}if((c===J.SetTextSelectionsOperation.id||c===J.SetInlineFormatCommand.id)&&r.getContextValue(l.EDITOR_ACTIVATED)&&r.getContextValue(l.FOCUSING_SHEET)){const h=en(i);if(h==null)return;const m=(u=h.ts)==null?void 0:u.st;o.next((m==null?void 0:m.s)===l.BooleanNumber.TRUE)}});return o.next(!1),s.dispose}),hidden$:I.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function Vl(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(S.SelectionManagerService);return{id:Do.id,tooltip:"toolbar.font",group:I.MenuGroup.TOOLBAR_FORMAT,type:I.MenuItemType.SELECTOR,label:Bo,positions:[I.MenuPosition.TOOLBAR_START],selections:I.FONT_FAMILY_LIST.map(r=>({label:{name:Fo,hoverable:!0},value:r.value})),disabled$:S.getCurrentSheetDisabled$(i),value$:new N.Observable(r=>{const o=I.FONT_FAMILY_LIST[0].value,s=e.onCommandExecuted(a=>{var m;const c=a.id;if(c!==S.SetRangeValuesMutation.id&&c!==S.SetSelectionsOperation.id)return;const d=(m=n.getLast())==null?void 0:m.primary,u=t.getCurrentUniverSheetInstance().getActiveSheet();let h;if(d!=null){const g=u.getRange(d.startRow,d.startColumn);h=g==null?void 0:g.getFontFamily()}r.next(h!=null?h:o)});return r.next(o),s.dispose}),hidden$:I.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function Bl(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(S.SelectionManagerService),r=i.get(l.IContextService),o=S.getCurrentSheetDisabled$(i);return{id:Ao.id,group:I.MenuGroup.TOOLBAR_FORMAT,type:I.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:Wo,props:{min:1,max:400,disabled$:o}},positions:[I.MenuPosition.TOOLBAR_START],selections:I.FONT_SIZE_LIST,disabled$:o,value$:new N.Observable(s=>{const c=e.onCommandExecuted(d=>{var h,m;const u=d.id;if(u===S.SetRangeValuesMutation.id||u===S.SetSelectionsOperation.id){const g=(h=n.getLast())==null?void 0:h.primary,_=t.getCurrentUniverSheetInstance().getActiveSheet();let f;if(g!=null){const v=_.getRange(g.startRow,g.startColumn);f=v==null?void 0:v.getFontSize()}s.next(f!=null?f:14)}if((u===J.SetTextSelectionsOperation.id||u===J.SetInlineFormatCommand.id)&&r.getContextValue(l.EDITOR_ACTIVATED)&&r.getContextValue(l.FOCUSING_SHEET)){const g=en(i);if(g==null)return;const _=(m=g.ts)==null?void 0:m.fs;s.next(_!=null?_:14)}});return s.next(14),c.dispose}),hidden$:I.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function Fl(i){return{id:S.ResetTextColorCommand.id,type:I.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:$n.id,disabled$:S.getCurrentSheetDisabled$(i)}}function Wl(i){const e=i.get(l.ICommandService),t=i.get(l.ThemeService);return{id:$n.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:I.MenuGroup.TOOLBAR_FORMAT,type:I.MenuItemType.BUTTON_SELECTOR,positions:[I.MenuPosition.TOOLBAR_START],selections:[{label:{name:qn,hoverable:!1}}],value$:new N.Observable(n=>{const r=t.getCurrentTheme().textColor,o=e.onCommandExecuted(s=>{if(s.id===$n.id){const a=s.params.value;n.next(a!=null?a:r)}});return n.next(r),o.dispose}),hidden$:I.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:S.getCurrentSheetDisabled$(i)}}function jl(i){return{id:S.ResetBackgroundColorCommand.id,type:I.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:S.SetBackgroundColorCommand.id,disabled$:S.getCurrentSheetDisabled$(i)}}function $l(i){const e=i.get(l.ICommandService),t=i.get(l.ThemeService);return{id:S.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",group:I.MenuGroup.TOOLBAR_FORMAT,type:I.MenuItemType.BUTTON_SELECTOR,positions:[I.MenuPosition.TOOLBAR_START],icon:"PaintBucket",selections:[{label:{name:qn,hoverable:!1}}],value$:new N.Observable(n=>{const r=t.getCurrentTheme().primaryColor,o=e.onCommandExecuted(s=>{if(s.id===S.SetBackgroundColorCommand.id){const a=s.params.value;n.next(a!=null?a:r)}});return n.next(r),o.dispose}),hidden$:I.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:S.getCurrentSheetDisabled$(i)}}const Mr=[{label:"align.left",icon:"LeftJustifyingSingle",value:l.HorizontalAlign.LEFT},{label:"align.center",icon:"HorizontallySingle",value:l.HorizontalAlign.CENTER},{label:"align.right",icon:"RightJustifyingSingle",value:l.HorizontalAlign.RIGHT}];function zl(i){const e=i.get(l.IUniverInstanceService),t=i.get(S.SelectionManagerService);return{id:S.SetHorizontalTextAlignCommand.id,icon:Mr[0].icon,positions:[I.MenuPosition.TOOLBAR_START],tooltip:"toolbar.horizontalAlignMode.main",group:I.MenuGroup.TOOLBAR_LAYOUT,type:I.MenuItemType.SELECTOR,selections:Mr,value$:new N.Observable(n=>{const r=i.get(l.ICommandService).onCommandExecuted(o=>{var u;const s=o.id;if(s!==S.SetHorizontalTextAlignCommand.id&&s!==S.SetSelectionsOperation.id)return;const a=(u=t.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const h=c.getRange(a.startRow,a.startColumn);d=h==null?void 0:h.getHorizontalAlignment()}n.next(d!=null?d:l.HorizontalAlign.LEFT)});return n.next(l.HorizontalAlign.LEFT),r.dispose}),hidden$:I.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:S.getCurrentSheetDisabled$(i)}}const br=[{label:"align.top",icon:"AlignTopSingle",value:l.VerticalAlign.TOP},{label:"align.middle",icon:"VerticalCenterSingle",value:l.VerticalAlign.MIDDLE},{label:"align.bottom",icon:"AlignBottomSingle",value:l.VerticalAlign.BOTTOM}];function Xl(i){const e=i.get(l.IUniverInstanceService),t=i.get(S.SelectionManagerService);return{id:S.SetVerticalTextAlignCommand.id,icon:br[0].icon,tooltip:"toolbar.verticalAlignMode.main",group:I.MenuGroup.TOOLBAR_LAYOUT,type:I.MenuItemType.SELECTOR,positions:[I.MenuPosition.TOOLBAR_START],selections:br,value$:new N.Observable(n=>{const r=i.get(l.ICommandService).onCommandExecuted(o=>{var u;const s=o.id;if(s!==S.SetVerticalTextAlignCommand.id&&s!==S.SetSelectionsOperation.id)return;const a=(u=t.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const h=c.getRange(a.startRow,a.startColumn);d=h==null?void 0:h.getVerticalAlignment()}n.next(d!=null?d:l.VerticalAlign.TOP)});return n.next(l.VerticalAlign.TOP),r.dispose}),hidden$:I.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:S.getCurrentSheetDisabled$(i)}}const wr=[{label:"textWrap.overflow",icon:"OverflowSingle",value:l.WrapStrategy.OVERFLOW},{label:"textWrap.wrap",icon:"AutowrapSingle",value:l.WrapStrategy.WRAP},{label:"textWrap.clip",icon:"TruncationSingle",value:l.WrapStrategy.CLIP}];function Yl(i){const e=i.get(S.SelectionManagerService),t=i.get(l.IUniverInstanceService);return{id:S.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:wr[0].icon,group:I.MenuGroup.TOOLBAR_LAYOUT,type:I.MenuItemType.SELECTOR,positions:[I.MenuPosition.TOOLBAR_START],selections:wr,value$:new N.Observable(n=>{const r=i.get(l.ICommandService).onCommandExecuted(o=>{var u;const s=o.id;if(s!==S.SetTextWrapCommand.id&&s!==S.SetSelectionsOperation.id)return;const a=(u=e.getLast())==null?void 0:u.primary,c=t.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const h=c.getRange(a.startRow,a.startColumn);d=h==null?void 0:h.getWrapStrategy()}n.next(d!=null?d:l.WrapStrategy.OVERFLOW)});return n.next(l.WrapStrategy.OVERFLOW),r.dispose}),hidden$:I.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:S.getCurrentSheetDisabled$(i)}}const Tr=[{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 Zl(i){const e=i.get(S.SelectionManagerService),t=i.get(l.IUniverInstanceService);return{id:S.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:Tr[0].icon,group:I.MenuGroup.TOOLBAR_LAYOUT,type:I.MenuItemType.SELECTOR,selections:Tr,positions:[I.MenuPosition.TOOLBAR_START],value$:new N.Observable(n=>{const r=i.get(l.ICommandService).onCommandExecuted(o=>{var u,h;const s=o.id;if(s!==S.SetTextRotationCommand.id&&s!==S.SetSelectionsOperation.id)return;const a=(u=e.getLast())==null?void 0:u.primary,c=t.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const m=c.getRange(a.startRow,a.startColumn);d=m==null?void 0:m.getTextRotation()}(d==null?void 0:d.v)===l.BooleanNumber.TRUE?n.next("v"):n.next((h=d&&d.a)!=null?h:0)});return n.next(0),r.dispose}),hidden$:I.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:S.getCurrentSheetDisabled$(i)}}function yt(i){return new N.Observable(e=>e.next(!i.get(I.IClipboardInterfaceService).supportClipboard))}function Gl(){return{id:I.CopyCommand.id,group:I.MenuGroup.CONTEXT_MENU_FORMAT,type:I.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",positions:[I.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function Kl(i){return{id:I.PasteCommand.id,group:I.MenuGroup.CONTEXT_MENU_FORMAT,type:I.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",disabled$:yt(i),positions:[I.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}const Ot="sheet.menu.paste-special";function ql(i){return{id:Ot,group:I.MenuGroup.CONTEXT_MENU_FORMAT,type:I.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",disabled$:yt(i),positions:[I.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function Jl(i){return{id:ro.id,type:I.MenuItemType.BUTTON,title:"rightClick.pasteValue",positions:[Ot],disabled$:yt(i)}}function Ql(i){return{id:oo.id,type:I.MenuItemType.BUTTON,title:"rightClick.pasteFormat",positions:[Ot],disabled$:yt(i)}}function ec(i){return{id:so.id,type:I.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",positions:[Ot],disabled$:yt(i)}}function tc(i){return{id:ao.id,type:I.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",positions:[Ot],disabled$:yt(i)}}function nc(){return{id:S.SetWorksheetRowIsAutoHeightCommand.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"AutoHeight",title:"rightClick.fitContent"}}const Qt="sheet.menu.sheet-frozen";function ic(){return{id:Qt,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:[I.MenuPosition.CONTEXT_MENU]}}const Xi="sheet.header-menu.sheet-frozen";function rc(){return{id:Xi,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:["rowHeaderContextMenu","colHeaderContextMenu"]}}function oc(){return{id:Kn.id,type:I.MenuItemType.BUTTON,positions:[Qt,Xi],title:"rightClick.freeze",icon:"FreezeToSelectedSingle"}}function sc(){return{id:Uo.id,type:I.MenuItemType.BUTTON,positions:[Qt],title:"rightClick.freezeRow",icon:"FreezeRowSingle"}}function ac(){return{id:ko.id,type:I.MenuItemType.BUTTON,positions:[Qt],title:"rightClick.freezeCol",icon:"FreezeColumnSingle"}}function lc(){return{id:Vo.id,type:I.MenuItemType.BUTTON,positions:[Qt,Xi],title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle"}}function cc(){return{id:Oo.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedRow"}}function dc(){return{id:xo.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedColumn"}}function uc(i){const e=i.get(l.IUniverInstanceService),t=i.get(S.SelectionManagerService);function n(){var a;const o=e.getCurrentUniverSheetInstance().getActiveSheet(),s=(a=t.getSelections())==null?void 0:a.map(c=>c.range).filter(c=>c.rangeType===l.RANGE_TYPE.ROW);return!!(s!=null&&s.some(c=>{for(let d=c.startRow;d<=c.endRow;d++)if(!o.getRowVisible(d))return!0;return!1}))}const r=i.get(l.ICommandService);return{id:S.SetSelectedRowsVisibleCommand.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],title:"rightClick.showHideRow",hidden$:new N.Observable(o=>{const s=r.onCommandExecuted(a=>{(a.id===S.SetSelectionsOperation.id||a.id===S.SetRowHiddenMutation.id||a.id===S.SetRowVisibleMutation.id)&&o.next(!n())});return o.next(!n()),()=>s.dispose()})}}function hc(i){const e=i.get(l.IUniverInstanceService),t=i.get(S.SelectionManagerService);function n(){var a;const o=e.getCurrentUniverSheetInstance().getActiveSheet(),s=(a=t.getSelections())==null?void 0:a.map(c=>c.range).filter(c=>c.rangeType===l.RANGE_TYPE.COLUMN);return!s||s.length===0?!1:!!s.some(c=>{for(let d=c.startColumn;d<=c.endColumn;d++)if(!o.getColVisible(d))return!0;return!1})}const r=i.get(l.ICommandService);return{id:S.SetSelectedColsVisibleCommand.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],title:"rightClick.showHideColumn",hidden$:new N.Observable(o=>{const s=r.onCommandExecuted(a=>{(a.id===S.SetSelectionsOperation.id||a.id===S.SetColHiddenMutation.id||a.id===S.SetColVisibleMutation.id)&&o.next(!n())});return o.next(!n()),()=>s.dispose()})}}function mc(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(S.SelectionManagerService);return{id:S.SetRowHeightCommand.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,icon:"AdjustHeight",positions:["rowHeaderContextMenu"],label:{name:zi,props:{prefix:"rightClick.rowHeight",suffix:"px",min:2,max:1e3}},value$:new N.Observable(r=>{function o(){var u;const a=(u=n.getLast())==null?void 0:u.primary,c=t.getCurrentUniverSheetInstance().getActiveSheet();let d;a!=null&&(d=c.getRowHeight(a.startRow)),r.next(d!=null?d:0)}const s=e.onCommandExecuted(a=>{const c=a.id;if(c===S.SetRangeValuesMutation.id||c===S.SetSelectionsOperation.id)return o()});return o(),s.dispose})}}function gc(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(S.SelectionManagerService);return{id:S.SetColWidthCommand.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,icon:"AdjustWidth",positions:["colHeaderContextMenu"],label:{name:zi,props:{prefix:"rightClick.columnWidth",suffix:"px",min:2,max:1e3}},value$:new N.Observable(r=>{function o(){var u;const a=(u=n.getLast())==null?void 0:u.primary,c=t.getCurrentUniverSheetInstance().getActiveSheet();let d=0;a!=null&&(d=c.getColumnWidth(a.startColumn)),r.next(d)}const s=e.onCommandExecuted(a=>{const c=a.id;if(c===S.SetRangeValuesMutation.id||c===S.SetSelectionsOperation.id)return o()});return o(),s.dispose})}}function en(i){var c;const e=i.get(l.IUniverInstanceService),t=i.get(J.TextSelectionManagerService),n=e.getUniverDocInstance(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),r=t.getActiveRange();if(n==null||r==null)return;const o=(c=n.getBody())==null?void 0:c.textRuns;if(o==null)return;const{startOffset:s}=r;return o.find(({st:d,ed:u})=>s>=d&&s<u)}function Ce(i,e){const n=i.getCurrentUniverSheetInstance().getUnitId(),r=e.getRenderById(n);if(r==null)return;const{components:o,mainComponent:s,scene:a,engine:c}=r,d=s,u=o.get(Se.ROW),h=o.get(Se.COLUMN),m=o.get(Se.LEFT_TOP);return{spreadsheet:d,spreadsheetRowHeader:u,spreadsheetColumnHeader:h,spreadsheetLeftTopPlaceholder:m,scene:a,engine:c}}function Ei(i,e,t,n){const{startX:r,startY:o,endX:s,endY:a}=n.getCellByIndex(i,e);return{startX:r,startY:o,endX:s,endY:a}}function Rt(i,e,t,n,r){const o=t.getRelativeCoord(b.Vector2.FromArray([i,e])),{x:s,y:a}=o,c=t.getScrollXYByRelativeCoords(o,r),{scaleX:d,scaleY:u}=t.getAncestorScale(),h=n.getCellPositionByOffset(s,a,d,u,c),{row:m,column:g}=h,_=n.getNoMergeCellPositionByIndex(m,g),{startX:f,startY:v,endX:R,endY:M}=_;return{startX:f,startY:v,endX:R,endY:M,row:m,column:g}}function mn(i,e,t,n){const r=t.getRelativeCoord(b.Vector2.FromArray([i,e])),o=t.getViewport(V.VIEW_MAIN),s=t.getScrollXYByRelativeCoords(r,o),{scaleX:a,scaleY:c}=t.getAncestorScale(),{x:d,y:u}=s,h=i/a+d,m=e/c+u;return{x:h,y:m}}const _c={spreadsheetLabel:"Spreadsheet",spreadsheetRightLabel:"more Sheets",toolbar:{undo:"Undo",redo:"Redo",formatPainter:"Paint format",currencyFormat:"Format as currency",percentageFormat:"Format as percent",numberDecrease:"Decrease decimal places",numberIncrease:"Increase decimal places",moreFormats:"More formats",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript",underline:"Underline",textColor:{main:"Text color",right:"Choose color"},resetColor:"Reset",customColor:"CUSTOM",alternatingColors:"Alternating colors",confirmColor:"OK",cancelColor:"Cancel",collapse:"Collapse",fillColor:{main:"Fill color",right:"Choose color"},border:{main:"Border",right:"Border style"},mergeCell:{main:"Merge cells",right:"Choose merge type"},horizontalAlignMode:{main:"Horizontal align",right:"Alignment"},verticalAlignMode:{main:"Vertical align",right:"Alignment"},textWrapMode:{main:"Text wrap",right:"Text wrap mode"},textRotateMode:{main:"Text rotate",right:"Text rotate mode"},freezeTopRow:"Freeze top row",sortAndFilter:"Sort and filter",findAndReplace:"Find and replace",sum:"SUM",autoSum:"Auto SUM",moreFunction:"More functions",conditionalFormat:"Conditional format",comment:"Comment",pivotTable:"Pivot Table",chart:"Chart",screenshot:"Screenshot",splitColumn:"Split text",insertImage:"Insert image",insertLink:"Insert link",dataValidation:"Data validation",protection:"Protect the sheet",clearText:"Clear color",noColorSelectedText:"No color is selected",toolMore:"More",toolLess:"Less",toolClose:"Close",toolMoreTip:"More features",moreOptions:"More options",cellFormat:"Cell format config",print:"Print",borderMethod:{top:"Upper frame line",bottom:"Lower frame line",left:"Left frame line",right:"Right frame line"},more:"More"},defaultFmt:{Automatic:{text:"Automatic",value:"General",example:""},Number:{text:"Number",value:"##0.00",example:"1000.12"},Percent:{text:"Percent",value:"#0.00%",example:"12.21%"},PlainText:{text:"Plain text",value:"@",example:""},Scientific:{text:"Scientific",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"Accounting",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"Ten Thousand",value:"w",example:"1亿2000万2500"},Currency:{text:"Currency",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"Date",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"Time",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"Time 24H",value:"hh:mm",example:"15:00"},DateTime:{text:"Date time",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"Date time 24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"Custom Formats",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"More currency formats",moreDateTime:"More date and time formats",moreNumber:"More number formats",titleCurrency:"Currency formats",decimalPlaces:"Decimal places",titleDateTime:"Date and time formats",titleNumber:"Number formats"},print:{normalBtn:"Normal",layoutBtn:"Page Layout",pageBtn:"Page break preview",menuItemPrint:"Print (Ctrl+P)",menuItemAreas:"Print areas",menuItemRows:"Print title rows",menuItemColumns:"Print title columns"},align:{left:"left",center:"center",right:"right",top:"top",middle:"middle",bottom:"bottom"},dateFmtList:[{name:"1930-08-05",value:"yyyy-MM-dd"},{name:"1930/8/5",value:"yyyy/MM/dd"},{name:"08-05",value:"MM-dd"},{name:"8-5",value:"M-d"},{name:"13:30:30",value:"h:mm:ss"},{name:"13:30",value:"h:mm"},{name:"PM 01:30",value:"AM/PM hh:mm"},{name:"PM 1:30",value:"AM/PM h:mm"},{name:"PM 1:30:30",value:"AM/PM h:mm:ss"},{name:"08-05 PM 01:30",value:"MM-dd AM/PM hh:mm"}],numFmtList:[{name:"1235",value:"0"},{name:"1234.56",value:"0.00"},{name:"1,235",value:"#,##0"},{name:"1,234.56",value:"#,##0.00"},{name:"1,235",value:"#,##0_);(#,##0)"},{name:"1,235",value:"#,##0_);[Red](#,##0)"},{name:"1,234.56",value:"#,##0.00_);(#,##0.00)"},{name:"1,234.56",value:"#,##0.00_);[Red](#,##0.00)"},{name:"$1,235",value:"$#,##0_);($#,##0)"},{name:"$1,235",value:"$#,##0_);[Red]($#,##0)"},{name:"$1,234.56",value:"$#,##0.00_);($#,##0.00)"},{name:"$1,234.56",value:"$#,##0.00_);[Red]($#,##0.00)"},{name:"1234.56",value:"@"},{name:"123456%",value:"0%"},{name:"123456.00%",value:"0.00%"},{name:"1.23E+03",value:"0.00E+00"},{name:"1.2E+3",value:"##0.0E+0"},{name:"1234 5/9",value:"# ?/?"},{name:"1234 14/25",value:"# ??/??"},{name:"$ 1,235",value:'_($* #,##0_);_(...($* "-"_);_(@_)'},{name:"1,235",value:'_(* #,##0_);_(*..._(* "-"_);_(@_)'},{name:"$ 1,234.56",value:'_($* #,##0.00_);_(...($* "-"_);_(@_)'},{name:"1,234.56",value:'_(* #,##0.00_);...* "-"??_);_(@_)'}],button:{confirm:"OK",cancel:"Cancel",close:"Close",update:"Update",delete:"Delete",insert:"Insert",prevPage:"Previous",nextPage:"Next",total:"total:"},punctuation:{tab:"Tab",semicolon:"semicolond",comma:"comma",space:"space"},colorPicker:{collapse:"Collapse",customColor:"CUSTOM",change:"Change",confirmColor:"OK",cancelColor:"Cancel"},borderLine:{borderTop:"borderTop",borderBottom:"borderBottom",borderLeft:"borderLeft",borderRight:"borderRight",borderNone:"borderNone",borderAll:"borderAll",borderOutside:"borderOutside",borderInside:"borderInside",borderHorizontal:"borderHorizontal",borderVertical:"borderVertical",borderColor:"borderColor",borderSize:"borderSize",borderType:"borderType"},merge:{all:"Merge all",vertical:"Vertical merge",horizontal:"Horizontal merge",cancel:"Cancel merge",overlappingError:"Cannot merge overlapping areas",partiallyError:"Cannot perform this operation on partially merged cells",confirm:{title:"Continue merging would only keep the upper-left cell value, discard other values. Are you sure to continue?",cancel:"Cancel merging",confirm:"Continue merging",waring:"Waring",dismantleMergeCellWaring:"This will cause some merged cells to be split. Do you want to continue?"}},textWrap:{overflow:"Overflow",wrap:"Wrap",clip:"Clip"},textRotate:{none:"None",angleUp:"Tilt Up",angleDown:"Tilt Down",vertical:"Stack Vertically",rotationUp:"Rotate Up",rotationDown:"Rotate Down"},sheetConfig:{delete:"Delete",copy:"Copy",rename:"Rename",changeColor:"Change color",hide:"Hide",unhide:"Unhide",moveLeft:"Move left",moveRight:"Move right",resetColor:"Reset color",cancelText:"Cancel",chooseText:"Confirm color",tipNameRepeat:"The name of the tab page cannot be repeated! Please revise",noMoreSheet:"The workbook contains at least one visual worksheet. To delete the selected worksheet, please insert a new worksheet or show a hidden worksheet.",confirmDelete:"Are you sure to delete",redoDelete:"Can be undo by Ctrl+Z",noHide:"Can't hide, at least keep one sheet tag",chartEditNoOpt:"This operation is not allowed in chart editing mode!",sheetNameErrorTitle:"There was a problem",sheetNameSpecCharError:`The name cannot contain:[ ] : ? * / ' "`,sheetNameCannotIsEmptyError:"The sheet name cannot be empty.",sheetNameAlreadyExistsError:"The sheet name already exists. Please enter another name.",deleteSheet:"Delete worksheet",deleteSheetContent:"Confirm to delete this worksheet. It will not be retrieved after deletion. Are you sure you want to delete it?"},rightClick:{copy:"Copy",copyAs:"Copy as",cut:"Cut",paste:"Paste",pasteSpecial:"Paste Special",pasteValue:"Paste Value",pasteFormat:"Paste Format",pasteColWidth:"Paste Column Width",pasteBesidesBorder:"Paste Besides Border Styles",insert:"Insert",insertRow:"Insert Row",insertRowBefore:"Insert Row Before",insertColumn:"Insert Column",insertColumnBefore:"Insert Column Before",delete:"Delete",deleteCell:"Delete Cell",insertCell:"Insert Cell",deleteSelected:"Delete Selected ",hide:"Hide",hideSelected:"Hide Selected ",showHide:"Show Hidden",toTopAdd:"Towards Top Add",toBottomAdd:"Towards Bottom Add",toLeftAdd:"Towards Left Add",toRightAdd:"Towards Right Add",deleteSelectedRow:"Delete Selected row",deleteSelectedColumn:"Delete Selected column",hideSelectedRow:"Hide Selected Row",showHideRow:"Show Selected Row",rowHeight:"Row Height",hideSelectedColumn:"Hide Selected Column",showHideColumn:"Show Hide Column",columnWidth:"Column Width",to:"Towards",left:"Left",right:"Right",top:"Top",bottom:"Bottom",moveLeft:"Move Left",moveUp:"Move up",moveRight:"Move Right",moveDown:"Move Down",add:"Add",row:"Row",column:"Column",width:"Width",height:"Height",number:"Number",confirm:"Confirm",orderAZ:"A-Z order",orderZA:"Z-A order",clearSelection:"Clear",clearContent:"Clear Contents",clearFormat:"Clear Formats",clearAll:"Clear All",matrix:"Matrix operation",sortSelection:"Sort",filterSelection:"Filter",chartGeneration:"Create Chart",firstLineTitle:"First Line Title",untitled:"Untitled",array1:"One-dimensional array",array2:"Two-dimensional array",array3:"Multidimensional Arrays",diagonal:"Diagonal",antiDiagonal:"Anti-diagonal",diagonalOffset:"Diagonal offset",offset:"Offset",boolean:"Boolean",flip:"Flip",upAndDown:"Up and down",leftAndRight:"Left and right",clockwise:"Clockwise",counterclockwise:"Counterclockwise",transpose:"Transpose",matrixCalculation:"Matrix Calculation",plus:"Plus",minus:"Minus",multiply:"Multiply",divided:"Divided",power:"Power",root:"Root",log:"Log",delete0:"Delete 0 values at both ends",removeDuplicate:"Remove duplicate values",byRow:"By row",byCol:"By column",generateNewMatrix:"Generate new matrix",fitContent:"Fit for data",freeze:"Freeze",freezeCol:"Freeze to this column",freezeRow:"Freeze to this row",cancelFreeze:"Cancel freeze",zenEditor:"Full Screen Editor",deleteAllRowsAlert:"You can't delete all the rows on the sheet",deleteAllColumnsAlert:"You can't delete all the columns on the sheet",hideAllRowsAlert:"You can't hide all the rows on the sheet",hideAllColumnsAlert:"You can't hide all the columns on the sheet"},info:{tooltip:"Tooltip",notChangeMerge:"You cannot make partial changes to the merged cells",detailUpdate:"New opened",detailSave:"Local cache restored",row:"",column:"",loading:"Loading...",copy:"Copy",return:"Exit",rename:"Rename",tips:"Rename",noName:"Untitled spreadsheet",wait:"waiting for update",add:"Add",addLast:"more rows at bottom",backTop:"Back to the top",pageInfo:"Total ${total},${totalPage} page,current ${currentPage}",nextPage:"Next",tipInputNumber:"Please enter the number",tipInputNumberLimit:"The increase range is limited to 1-100",tipRowHeightLimit:"Row height must be between 0 ~ 545",tipColumnWidthLimit:"The column width must be between 0 ~ 2038",pageInfoFull:"Total ${total},${totalPage} page,All data displayed",problem:"There was a problem"},clipboard:{paste:{exceedMaxCells:"The number of cells pasted exceeds the maximum number of cells"}},statusbar:{sum:"Sum",average:"Average",min:"Min",max:"Max",count:"Numerical Count",countA:"Count",clickToCopy:"Click to Copy",copied:"Copied"},autoFill:{copy:"Copy Cell",series:"Fill Series",formatOnly:"Format Only",noFormat:"No Format"},rangeSelector:{placeholder:"Select range or input value",tooltip:"Select range"},shortcut:{sheet:{"zoom-in":"Zoom in","zoom-out":"Zoom out","reset-zoom":"Reset zoom level","select-below-cell":"Select the cell below","select-up-cell":"Select the cell above","select-left-cell":"Select the left cell","select-right-cell":"Select the right cell","select-next-cell":"Select the next cell","select-previous-cell":"Select the previous cell","select-up-value-cell":"Select the cell above that has value","select-below-value-cell":"Select the cell below that has value","select-left-value-cell":"Select the cell left that has value","select-right-value-cell":"Select the cell right that has value","expand-selection-down":"Expand selection down","expand-selection-up":"Expand selection up","expand-selection-left":"Expand selection left","expand-selection-right":"Expand selection right","expand-selection-to-left-gap":"Expand selection to the left gap","expand-selection-to-below-gap":"Expand selection to the below gap","expand-selection-to-right-gap":"Expand selection to the right gap","expand-selection-to-up-gap":"Expand selection to the up gap","select-all":"Select all","toggle-editing":"Toggle editing","delete-and-start-editing":"Clear and start editing","abort-editing":"Abort editing","break-line":"Break line","set-bold":"Toggle bold","set-italic":"Toggle italic","set-underline":"Toggle underline","set-strike-through":"Toggle strike through"}},"sheet-view":"Sheet View","sheet-edit":"Sheet Edit"},jo={spreadsheetLabel:"插件",spreadsheetRightLabel:"更多 Sheets",toolbar:{undo:"撤销",redo:"重做",formatPainter:"格式刷",currencyFormat:"货币格式",percentageFormat:"百分比格式",numberDecrease:"减少小数位数",numberIncrease:"增加小数位数",moreFormats:"更多格式",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},resetColor:"重置颜色",customColor:"自定义",alternatingColors:"交替颜色",confirmColor:"确定颜色",cancelColor:"取消",collapse:"收起",fillColor:{main:"单元格颜色",right:"颜色选择"},border:{main:"边框",right:"边框类型"},mergeCell:{main:"合并单元格",right:"选择合并类型"},horizontalAlignMode:{main:"水平对齐",right:"对齐方式"},verticalAlignMode:{main:"垂直对齐",right:"对齐方式"},textWrapMode:{main:"文本换行",right:"换行方式"},textRotateMode:{main:"文本旋转",right:"旋转方式"},freezeTopRow:"冻结首行",sortAndFilter:"排序和筛选",findAndReplace:"查找替换",sum:"求和",autoSum:"自动求和",moreFunction:"更多函数",conditionalalFormat:"条件格式",comment:"批注",pivotTable:"数据透视表",chart:"图表",screenshot:"截图",splitColumn:"分列",insertImage:"插入图片",insertLink:"插入链接",dataValidation:"数据验证",protection:"保护工作表内容",clearText:"清除颜色选择",noColorSelectedText:"没有颜色被选择",toolMore:"更多",toolLess:"少于",toolClose:"收起",toolMoreTip:"更多功能",moreOptions:"更多选项",cellFormat:"设置单元格格式",print:"打印",borderMethod:{top:"上框线",bottom:"下框线",left:"左框线",right:"右框线"},more:"更多"},defaultFmt:{Automatic:{text:"自动",value:"General",example:""},Number:{text:"数字",value:"##0.00",example:"1000.12"},Percent:{text:"百分比",value:"#0.00%",example:"12.21%"},PlainText:{text:"纯文本",value:"@",example:""},Scientific:{text:"科学计数",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"会计",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"万元",value:"w",example:"1亿2000万2500"},Currency:{text:"货币",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"日期",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"时间",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"时间24H",value:"hh:mm",example:"15:00"},DateTime:{text:"日期时间",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"日期时间24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"自定义格式",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"更多货币格式",moreDateTime:"更多日期与时间格式",moreNumber:"更多数字格式",titleCurrency:"货币格式",decimalPlaces:"小数位数",titleDateTime:"日期与时间格式",titleNumber:"数字格式"},print:{normalBtn:"常规视图",layoutBtn:"页面布局",pageBtn:"分页预览",menuItemPrint:"打印(Ctrl+P)",menuItemAreas:"打印区域",menuItemRows:"打印标题行",menuItemColumns:"打印标题列"},align:{left:"左对齐",center:"中间对齐",right:"右对齐",top:"顶部对齐",middle:"居中对齐",bottom:"底部对齐"},button:{confirm:"确定",cancel:"取消",close:"关闭",update:"Update",delete:"Delete",insert:"新建",prevPage:"上一页",nextPage:"下一页",total:"总共:"},punctuation:{tab:"Tab 键",semicolon:"分号",comma:"逗号",space:"空格"},colorPicker:{collapse:"收起",customColor:"自定义",change:"切换",confirmColor:"确定",cancelColor:"取消"},borderLine:{borderTop:"上框线",borderBottom:"下框线",borderLeft:"左框线",borderRight:"右框线",borderNone:"无",borderAll:"所有",borderOutside:"外侧",borderInside:"内侧",borderHorizontal:"内侧横线",borderVertical:"内侧竖线",borderColor:"边框颜色",borderSize:"边框粗细",borderType:"边框线类型"},merge:{all:"全部合并",vertical:"垂直合并",horizontal:"水平合并",cancel:"取消合并",overlappingError:"不能合并重叠区域",partiallyError:"无法对部分合并单元格执行此操作",confirm:{title:"合并单元格仅保存左上角单元格的值,是否继续?",cancel:"取消合并",confirm:"继续合并",waring:"警告",dismantleMergeCellWaring:"此操作会导致一些合并单元格被拆散,是否继续?"}},textWrap:{overflow:"溢出",wrap:"自动换行",clip:"截断"},textRotate:{none:"无旋转",angleUp:"向上倾斜",angleDown:"向下倾斜",vertical:"竖排文字",rotationUp:"向上90°",rotationDown:"向下90°"},sheetConfig:{delete:"删除",copy:"复制",rename:"重命名",changeColor:"更改颜色",hide:"隐藏",unhide:"取消隐藏",moveLeft:"向左移",moveRight:"向右移",resetColor:"重置颜色",cancelText:"取消",chooseText:"确定颜色",tipNameRepeat:"标签页的名称不能重复!请重新修改",noMoreSheet:"工作薄内至少含有一张可视工作表。若需删除选定的工作表,请先插入一张新工作表或显示一张隐藏的工作表。",confirmDelete:"是否删除",redoDelete:"可以通过Ctrl+Z撤销删除",noHide:"不能隐藏, 至少保留一个sheet标签",chartEditNoOpt:"图表编辑模式下不允许该操作!",sheetNameErrorTitle:"错误",sheetNameSpecCharError:`名称不能超过31个字符,首尾不能是' 且名称不能包含:\r
|
|
18
|
+
[ ] : \\ ? * /`,sheetNameCannotIsEmptyError:"名称不能为空。",sheetNameAlreadyExistsError:"工作表已存在,请输入其它名称。",deleteSheet:"删除工作表",deleteSheetContent:"确认删除此工作表,删除后将不可找回,确定要删除吗?"},rightClick:{copy:"复制",copyAs:"复制为",cut:"剪切",paste:"粘贴",pasteSpecial:"选择性粘贴",pasteValue:"仅粘贴值",pasteFormat:"仅粘贴格式",pasteColWidth:"仅粘贴列宽",pasteBesidesBorder:"仅粘贴边框以外内容",insert:"插入",delete:"删除",insertRow:"插入行",insertRowBefore:"在上方插入行",insertColumn:"插入列",insertColumnBefore:"在左侧插入列",deleteCell:"删除单元格",insertCell:"插入单元格",deleteSelected:"删除选中",hide:"隐藏",hideSelected:"隐藏选中",showHide:"显示隐藏",toTopAdd:"向上增加",toBottomAdd:"向下增加",toLeftAdd:"向左增加",toRightAdd:"向右增加",deleteSelectedRow:"删除选中行",deleteSelectedColumn:"删除选中列",hideSelectedRow:"隐藏选中行",showHideRow:"显示隐藏行",rowHeight:"行高",hideSelectedColumn:"隐藏选中列",showHideColumn:"显示隐藏列",columnWidth:"列宽",to:"向",left:"左",right:"右",top:"上",bottom:"下",moveLeft:"左移",moveUp:"上移",moveRight:"右移",moveDown:"下移",add:"增加",row:"行",column:"列",width:"宽",height:"高",number:"数字",confirm:"确认",orderAZ:"A-Z顺序排列",orderZA:"Z-A降序排列",clearSelection:"清除",clearContent:"清除内容",clearFormat:"清除格式",clearAll:"清除全部",matrix:"矩阵操作选区",sortSelection:"排序选区",filterSelection:"筛选选区",chartGeneration:"图表生成",firstLineTitle:"首行为标题",untitled:"无标题",array1:"一维数组",array2:"二维数组",array3:"多维数组",diagonal:"对角线",antiDiagonal:"反对角线",diagonalOffset:"对角偏移",offset:"偏移量",boolean:"布尔值",flip:"翻转",upAndDown:"上下",leftAndRight:"左右",clockwise:"顺时针",counterclockwise:"逆时针",transpose:"转置",matrixCalculation:"矩阵计算",plus:"加",minus:"减",multiply:"乘",divided:"除",power:"次方",root:"次方根",log:"log",delete0:"删除两端0值",removeDuplicate:"删除重复值",byRow:"按行",byCol:"按列",generateNewMatrix:"生成新矩阵",fitContent:"适合数据",freeze:"冻结",freezeCol:"冻结列",freezeRow:"冻结行",cancelFreeze:"取消冻结",zenEditor:"禅模式编辑",deleteAllRowsAlert:"您无法删除工作表上的所有行",deleteAllColumnsAlert:"您无法删除工作表上的所有列",hideAllRowsAlert:"您无法隐藏工作表上的所有行",hideAllColumnsAlert:"您无法隐藏工作表上的所有列"},info:{tooltip:"提示",notChangeMerge:"不能对合并单元格做部分更改",detailUpdate:"新打开",detailSave:"已恢复本地缓存",row:"行",column:"列",loading:"渲染中···",copy:"副本",return:"返回",rename:"重命名",tips:"重命名",noName:"无标题的电子表格",wait:"待更新",add:"添加",addLast:"在底部添加",backTop:"回到顶部",pageInfo:"共${total}条,${totalPage}页,当前已显示${currentPage}页",nextPage:"下一页",tipInputNumber:"请输入数字",tipInputNumberLimit:"增加范围限制在1-100",tipRowHeightLimit:"行高必须在0 ~ 545之间",tipColumnWidthLimit:"列宽必须在0 ~ 2038之间",pageInfoFull:"共${total}条,${totalPage}页,已显示全部数据",problem:"出现了一个问题"},clipboard:{paste:{exceedMaxCells:"粘贴区域超出最大单元格数"}},statusbar:{sum:"求和",average:"平均值",min:"最小值",max:"最大值",count:"数值计数",countA:"计数",clickToCopy:"点击复制数值",copied:"已复制"},autoFill:{copy:"复制单元格",series:"填充序列",formatOnly:"仅填充格式",noFormat:"不带格式填充"},rangeSelector:{placeholder:"选择范围或输入值",tooltip:"选择范围"},shortcut:{sheet:{"zoom-in":"放大","zoom-out":"缩小","reset-zoom":"恢复缩放","select-below-cell":"选择下方单元格","select-up-cell":"选择上方单元格","select-left-cell":"选择左侧单元格","select-right-cell":"选择右侧单元格","select-next-cell":"选择后一个单元格","select-previous-cell":"选择前一个单元格","select-up-value-cell":"选择上方有值的单元格","select-below-value-cell":"选择下方有值的单元格","select-left-value-cell":"选择左侧有值的单元格","select-right-value-cell":"选择右侧有值的单元格","expand-selection-down":"向下扩展选区","expand-selection-up":"向上扩展选区","expand-selection-left":"向左扩展选区","expand-selection-right":"向右扩展选区","expand-selection-to-left-gap":"向左扩展选区到下一个边界","expand-selection-to-below-gap":"向下扩展选区到下一个边界","expand-selection-to-right-gap":"向右扩展选区到下一个边界","expand-selection-to-up-gap":"向上扩展选区到下一个边界","select-all":"全选","toggle-editing":"开始 / 结束编辑","delete-and-start-editing":"清空并开始编辑","abort-editing":"放弃编辑","break-line":"换行","set-bold":"切换粗体","set-italic":"切换斜体","set-underline":"切换下划线","set-strike-through":"切换删除线"}},"sheet-view":"浏览表格","sheet-edit":"编辑表格"},Sc=(i,e,t=!1)=>{const n=h=>h.endRow-h.startRow+1,r=h=>h.endColumn-h.startColumn+1,o=n(e)%n(i),s=r(e)%r(i),a={startRow:0,endRow:n(i)-1,startColumn:0,endColumn:r(i)-1},c=Math.floor(n(e)/n(i)),d=Math.floor(r(e)/r(i)),u=[];if(!o&&!s)for(let h=1;h<=c;h++)for(let m=1;m<=d;m++){const g=n(i)*(h-1),_=r(i)*(m-1),f={startRow:g+e.startRow,endRow:g+e.startRow,startColumn:_+e.startColumn,endColumn:_+e.startColumn};u.push({repeatRelativeRange:a,startRange:f})}else if(!o&&s&&!t)for(let h=1;h<=c;h++){const m=n(i)*(h-1),g=0,_={startRow:m+e.startRow,endRow:m+e.startRow,startColumn:g+e.startColumn,endColumn:g+e.startColumn};u.push({repeatRelativeRange:a,startRange:_})}else if(o&&!s&&!t)for(let h=1;h<=d;h++){const g=r(i)*(h-1),_={startRow:0+e.startRow,endRow:0+e.startRow,startColumn:g+e.startColumn,endColumn:g+e.startColumn};u.push({repeatRelativeRange:a,startRange:_})}else{const h={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};u.push({startRange:h,repeatRelativeRange:a})}return u};class $o{constructor(){C(this,"_state",null);C(this,"_rect",null);C(this,"_focus",!1);C(this,"_state$",new N.BehaviorSubject(null));C(this,"state$",this._state$.asObservable());C(this,"_rect$",new N.BehaviorSubject(null));C(this,"rect$",this._rect$.asObservable());C(this,"_focus$",new N.BehaviorSubject(this._focus));C(this,"focus$",this._focus$.asObservable())}dispose(){this._state$.complete(),this._state=null,this._rect$.complete(),this._rect=null}setState(e){this._state=e,this._refresh(e)}getRect(){return this._rect}setRect(e){this._rect=e,this._rect$.next(e)}getState(){return this._state}setFocus(e=!1){this._focus=e,this._focus$.next(e)}_refresh(e){this._state$.next(e)}}const tn=D.createIdentifier("univer.sheet-cell-editor-manager.service");class fc{constructor(){C(this,"_position",null);C(this,"_position$",new N.BehaviorSubject(null));C(this,"position$",this._position$.asObservable());C(this,"_focus",!1);C(this,"_focus$",new N.BehaviorSubject(this._focus));C(this,"focus$",this._focus$.asObservable());C(this,"_fxBtnClick$",new N.BehaviorSubject(!1));C(this,"fxBtnClick$",this._fxBtnClick$.asObservable());C(this,"_foldBtnStatus$",new N.BehaviorSubject(!1));C(this,"foldBtnStatus$",this._foldBtnStatus$.asObservable())}dispose(){this._position$.complete(),this._focus$.complete(),this._position=null,this._focus=!1}setPosition(e){this._position=e,this._refresh(e)}getPosition(){return this._position}setFocus(e=!1){this._focus=e,this._focus$.next(e)}handleFxBtnClick(e){this._fxBtnClick$.next(e)}handleFoldBtnClick(e){this._foldBtnStatus$.next(e)}_refresh(e){this._position$.next(e)}}const Jn=D.createIdentifier("univer.sheet-formula-editor-manager.service");var pc=Object.defineProperty,vc=Object.getOwnPropertyDescriptor,Cc=(i,e,t,n)=>{for(var r=n>1?void 0:n?vc(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&pc(e,t,r),r},Er=(i,e)=>(t,n)=>e(t,n,i);let gn=class extends l.Disposable{constructor(e,t){super();C(this,"_previousSheetIndex",-1);this._commandService=e,this._univerInstanceService=t,this.disposeWithMe(this._commandService.beforeCommandExecuted((n,r)=>{if(n.id===S.RemoveSheetMutation.id)return this._beforeAdjustActiveSheetOnRemoveSheet(n)})),this.disposeWithMe(this._commandService.onCommandExecuted((n,r)=>{if(n.id===S.RemoveSheetMutation.id)return this._adjustActiveSheetOnRemoveSheet(n);if(n.id===S.SetWorksheetHideMutation.id&&n.params.hidden)return this._adjustActiveSheetOnHideSheet(n);if(!(r!=null&&r.fromCollab)){if(n.id===S.InsertSheetMutation.id)return this._adjustActiveSheetOnInsertSheet(n);if(n.id===S.SetWorksheetHideMutation.id&&!n.params.hidden)return this._adjustActiveSheetOnShowSheet(n)}}))}_adjustActiveSheetOnHideSheet(e){const{unitId:t,subUnitId:n}=e.params,r=this._univerInstanceService.getUniverSheetInstance(t);if(!r||(r==null?void 0:r.getRawActiveSheet())!==n)return;const s=r.getActiveSheetIndex(),a=yr(r,s);this._switchToNextSheet(t,a)}_beforeAdjustActiveSheetOnRemoveSheet(e){const{unitId:t,subUnitId:n}=e.params,r=this._univerInstanceService.getUniverSheetInstance(t);if(!r)return;const o=r.getSheetBySheetId(n);o&&(this._previousSheetIndex=r.getSheetIndex(o))}_adjustActiveSheetOnRemoveSheet(e){if(this._previousSheetIndex===-1)return;const{unitId:t}=e.params,n=this._univerInstanceService.getUniverSheetInstance(t);if(!n||n.getRawActiveSheet())return;const o=this._previousSheetIndex,s=o>=1?o-1:0,a=yr(n,s);this._switchToNextSheet(t,a)}_adjustActiveSheetOnInsertSheet(e){const{unitId:t,sheet:n}=e.params;this._switchToNextSheet(t,n.id)}_adjustActiveSheetOnShowSheet(e){const{unitId:t,subUnitId:n}=e.params;this._switchToNextSheet(t,n)}_switchToNextSheet(e,t){this._commandService.executeCommand(S.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t})}};gn=Cc([l.OnLifecycle(l.LifecycleStages.Ready,gn),Er(0,l.ICommandService),Er(1,l.IUniverInstanceService)],gn);function yr(i,e){const t=i.getSheetSize();for(let n=e;n>-1;n--){const r=i.getSheetByIndex(n);if(!r.getConfig().hidden)return r.getSheetId()}for(let n=e;n<t;n++){const r=i.getSheetByIndex(n);if(!r.getConfig().hidden)return r.getSheetId()}throw new Error("[ActiveWorksheetController]: could not find the next unhidden sheet! Collaboration error perhaps.")}var Ic=Object.defineProperty,Rc=Object.getOwnPropertyDescriptor,Mc=(i,e,t,n)=>{for(var r=n>1?void 0:n?Rc(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ic(e,t,r),r},Ut=(i,e)=>(t,n)=>e(t,n,i);let _n=class{constructor(i,e,t,n,r){this._injector=i,this._sheetInterceptorService=e,this._selectionManagerService=t,this._univerInstanceService=n,this._sheetSkeletonManagerService=r,this._initialize()}_getUndoRedoParamsOfAutoHeight(i){const{_univerInstanceService:e,_sheetSkeletonManagerService:t,_injector:n}=this,{skeleton:r}=t.getCurrent(),o=r.calculateAutoHeightInRange(i),s=e.getCurrentUniverSheetInstance(),a=s.getUnitId(),d={subUnitId:s.getActiveSheet().getSheetId(),unitId:a,rowsAutoHeightInfo:o},u=S.SetWorksheetRowAutoHeightMutationFactory(n,d);return{undos:[{id:S.SetWorksheetRowAutoHeightMutation.id,params:u}],redos:[{id:S.SetWorksheetRowAutoHeightMutation.id,params:d}]}}_initialize(){const{_sheetInterceptorService:i,_selectionManagerService:e}=this;i.interceptCommand({getMutations:t=>t.id!==S.SetRangeValuesCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(t.params.range)}),i.interceptCommand({getMutations:t=>t.id!==S.SetWorksheetRowIsAutoHeightCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(t.params.ranges)}),i.interceptCommand({getMutations:t=>{var o;if(t.id!==S.SetStyleCommand.id)return{redos:[],undos:[]};if(!["ff","fs","tr","tb"].includes((o=t.params)==null?void 0:o.style.type))return{redos:[],undos:[]};const r=e.getSelectionRanges();return r!=null&&r.length?this._getUndoRedoParamsOfAutoHeight(r):{redos:[],undos:[]}}})}};_n=Mc([l.OnLifecycle(l.LifecycleStages.Ready,_n),Ut(0,D.Inject(D.Injector)),Ut(1,D.Inject(S.SheetInterceptorService)),Ut(2,D.Inject(S.SelectionManagerService)),Ut(3,D.Inject(l.IUniverInstanceService)),Ut(4,D.Inject(exports.SheetSkeletonManagerService))],_n);var bc=Object.defineProperty,wc=Object.getOwnPropertyDescriptor,Tc=(i,e,t,n)=>{for(var r=n>1?void 0:n?wc(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&bc(e,t,r),r},Ee=(i,e)=>(t,n)=>e(t,n,i);let Sn=class extends l.RxDisposable{constructor(i,e,t,n,r,o,s,a,c,d,u){var h;super(),this._injector=i,this._currentUniverSheet=e,this._commandService=t,this._contextService=n,this._configService=r,this._sheetClipboardService=o,this._clipboardInterfaceService=s,this._messageService=a,this._sheetSkeletonManagerService=c,this._localService=d,this._textSelectionRenderManager=u,this._init(),this._clipboardInterfaceService.supportClipboard||(h=this._textSelectionRenderManager)==null||h.onPaste$.pipe(N.takeUntil(this.dispose$)).subscribe(m=>{var v,R;if(!ne(this._contextService))return;m.event.preventDefault();const g=m.event,_=(v=g.clipboardData)==null?void 0:v.getData("text/html"),f=(R=g.clipboardData)==null?void 0:R.getData("text/plain");this._sheetClipboardService.legacyPaste(_,f)})}_init(){[io,_a,bt].forEach(e=>this.disposeWithMe(this._commandService.registerMultipleCommand(e))),[ro,oo,so,ao].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e))),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initCopyingHooks())),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingHook()));const i=this._initSpecialPasteHooks().map(e=>this._sheetClipboardService.addClipboardHook(e));this.disposeWithMe({dispose:()=>i.forEach(e=>e.dispose())})}_initCopyingHooks(){const i=this;let e=null;return{id:fe.DEFAULT_COPY,isDefaultHook:!0,onBeforeCopy(t,n){e=i._getWorksheet(t,n)},onCopyCellContent(t,n){const r=e.getCell(t,n);return`${(r==null?void 0:r.v)||""}`},onCopyCellStyle:(t,n,r,o)=>{const s={};(r||o)&&(s.rowspan=`${r||1}`,s.colspan=`${o||1}`);const c=e.getRange(t,n).getTextStyle();let d="";return c&&(d=l.handleStyleToString(c)),d&&(s.style=d),s},onCopyColumn(t){return{width:`${e.getColumnWidth(t)}`}},onCopyRow(t){return{style:`height: ${e.getRowHeight(t)}px;`}},onAfterCopy(){e=null}}}_initPastingHook(){const i=this;let e=null,t=null,n=null;return{id:fe.DEFAULT_PASTE,isDefaultHook:!0,onBeforePaste({unitId:r,subUnitId:o,range:s}){n=i._getWorksheet(r,o),e=r,t=o;const a=i._configService.getConfig(S.MAX_CELL_PER_SHEET_KEY),{endRow:c,endColumn:d}=s;return a&&c*d>a?(i._messageService.show({type:ge.MessageType.Error,content:i._localService.t("clipboard.paste.exceedMaxCells")}),!1):!0},onPasteRows(r,o){const{range:s}=r,a=[],c=n.getMaxRows(),d=s.endRow-c,u=o.length-d;if(d>0){const g={};o.slice(u).forEach((f,v)=>{const R=f==null?void 0:f.style;if(!R)return;const M=R.split(";");let T=l.DEFAULT_WORKSHEET_ROW_HEIGHT;M.find(w=>{w=w.toLowerCase();const E=I.textTrim(w.substr(0,w.indexOf(":"))),y=I.textTrim(w.substr(w.indexOf(":")+1));return E==="height"?(T=Number.parseFloat(y),!0):!1}),g[v]={h:T,hd:l.BooleanNumber.FALSE}});const _={unitId:e,subUnitId:t,range:{...s,startRow:c},rowInfo:g};a.push({id:S.InsertRowMutation.id,params:_})}const h={};o.slice(0,u).forEach((g,_)=>{const f=g.style;if(!f)return;const v=f.split(";");let R=l.DEFAULT_WORKSHEET_ROW_HEIGHT;v.find(M=>{M=M.toLowerCase();const T=I.textTrim(M.substr(0,M.indexOf(":"))),w=I.textTrim(M.substr(M.indexOf(":")+1));return T==="height"?(R=Number.parseFloat(w),!0):!1}),h[_]=R});const m={unitId:e,subUnitId:t,ranges:[{...s,endRow:Math.min(s.endRow,c)}],rowHeight:h};return a.push({id:S.SetWorksheetRowHeightMutation.id,params:m}),{redos:a,undos:[]}},onPasteColumns(r,o,s){const{range:a}=r,c=[],d=n.getMaxColumns(),u=a.endColumn-d,h=o.length-u;if(u>0){const g={unitId:e,subUnitId:t,range:{...a,startColumn:d},colInfo:o.slice(h).map(_=>({w:_.width?+_.width:l.DEFAULT_WORKSHEET_COLUMN_WIDTH,hd:l.BooleanNumber.FALSE}))};c.push({id:S.InsertColMutation.id,params:g})}const m={unitId:e,subUnitId:t,ranges:[{...a,endRow:Math.min(a.endColumn,d)}],colWidth:o.slice(0,h).map(g=>g.width?+g.width:l.DEFAULT_WORKSHEET_COLUMN_WIDTH)};return c.push({id:S.SetWorksheetColWidthMutation.id,params:m}),{redos:c,undos:[]}},onPastePlainText(r,o,s){return i._onPastePlainText(r,o,s)},onPasteCells(r,o,s,a){return i._onPasteCells(r,o,s,a)},onAfterPaste(r){n=null}}}_generateDocumentDataModelSnapshot(i){var s;const e=this._sheetSkeletonManagerService.getCurrent();if(e==null)return null;const{skeleton:t}=e,n=(s=t.getBlankCellDocumentModel())==null?void 0:s.documentModel,o={...n==null?void 0:n.getSnapshot(),...i};return n==null||n.reset(o),n==null?void 0:n.getSnapshot()}_onPastePlainText(i,e,t){const{range:n,unitId:r,subUnitId:o}=i;let s;if(/\r|\n/.test(e)){const c=to(e),d=this._generateDocumentDataModelSnapshot({body:c});s={[n.startRow]:{[n.startColumn]:{p:d}}}}else s={[n.startRow]:{[n.startColumn]:{v:e}}};const a={unitId:r,subUnitId:o,cellValue:s};return{redos:[{id:S.SetRangeValuesMutation.id,params:a}],undos:[{id:S.SetRangeValuesMutation.id,params:S.SetRangeValuesUndoMutationFactory(this._injector,a)}]}}_onPasteCells(i,e,t,n){const r={get:this._injector.get.bind(this._injector)};return js(i,e,t,n,r)}_initSpecialPasteHooks(){const i={get:this._injector.get.bind(this._injector)},e=this,t={id:fe.SPECIAL_PASTE_VALUE,specialPasteInfo:{label:"specialPaste.value"},onPasteCells:(s,a,c,d)=>{const u=e._currentUniverSheet.getCurrentUniverSheetInstance();return u.getUnitId(),u.getActiveSheet().getSheetId(),Jr(a,c,i)}},n={id:fe.SPECIAL_PASTE_FORMAT,specialPasteInfo:{label:"specialPaste.format"},onPasteCells(s,a,c,d){const u=e._currentUniverSheet.getCurrentUniverSheetInstance();u.getUnitId(),u.getActiveSheet().getSheetId();const h=[],m=[],{undos:g,redos:_}=eo(a,c,i);h.push(..._),m.push(...g);const{undos:f,redos:v}=Ri(a,c,i);h.push(...v),m.push(...f);const{undos:R,redos:M}=Qr(a,c,i);return h.push(...M),m.push(...R),{undos:m,redos:h}}},r={id:fe.SPECIAL_PASTE_COL_WIDTH,specialPasteInfo:{label:"specialPaste.colWidth"},onPasteCells(){return{undos:[],redos:[]}},onPasteColumns(s,a,c){const d=e._currentUniverSheet.getCurrentUniverSheetInstance(),u=d.getUnitId(),h=d.getActiveSheet().getSheetId(),m=[],g=e._getWorksheet(u,h),{range:_}=s,f=g.getMaxColumns(),v=_.endColumn-f,R=a.length-v,M={unitId:u,subUnitId:h,ranges:[{..._,endRow:Math.min(_.endColumn,f)}],colWidth:a.slice(0,R).map(T=>T.width?+T.width:l.DEFAULT_WORKSHEET_COLUMN_WIDTH)};return m.push({id:S.SetWorksheetColWidthMutation.id,params:M}),m.push({id:S.SetWorksheetColWidthMutation.id,params:M}),{redos:m,undos:[]}}},o={id:fe.SPECIAL_PASTE_BESIDES_BORDER,specialPasteInfo:{label:"specialPaste.besidesBorder"},onPasteCells(s,a,c,d){e._currentUniverSheet.getCurrentUniverSheetInstance();const u=[],h=[],{range:m,unitId:g,subUnitId:_}=a,{startColumn:f,startRow:v,endColumn:R,endRow:M}=m,T=new l.ObjectMatrix;c.forValue((O,A,k)=>{const H=k.s;typeof H=="object"&&T.setValue(O+v,A+f,{s:{...H,bd:void 0},v:k.v})});const w={unitId:g,subUnitId:_,cellValue:T.getData()};u.push({id:S.SetRangeValuesMutation.id,params:w});const E=S.SetRangeValuesUndoMutationFactory(i,w);h.push({id:S.SetRangeValuesMutation.id,params:E});const{undos:y,redos:x}=Ri(a,c,i);return h.push(...y),u.push(...x),{redos:u,undos:h}}};return[t,n,r,o]}_getWorksheet(i,e){var n;const t=(n=this._currentUniverSheet.getUniverSheetInstance(i))==null?void 0:n.getSheetBySheetId(e);if(!t)throw new Error(`[SheetClipboardController]: cannot find a worksheet with unitId ${i} and subUnitId ${e}.`);return t}};Sn=Tc([l.OnLifecycle(l.LifecycleStages.Steady,Sn),Ee(0,D.Inject(D.Injector)),Ee(1,l.IUniverInstanceService),Ee(2,l.ICommandService),Ee(3,l.IContextService),Ee(4,l.IConfigService),Ee(5,Mt),Ee(6,I.IClipboardInterfaceService),Ee(7,I.IMessageService),Ee(8,D.Inject(exports.SheetSkeletonManagerService)),Ee(9,D.Inject(l.LocaleService)),Ee(10,D.Optional(b.ITextSelectionRenderManager))],Sn);var Ec=Object.defineProperty,yc=Object.getOwnPropertyDescriptor,Oc=(i,e,t,n)=>{for(var r=n>1?void 0:n?yc(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ec(e,t,r),r},kt=(i,e)=>(t,n)=>e(t,n,i);let fn=class extends l.Disposable{constructor(i,e,t,n,r){super(),this._currentUniverService=i,this._contextMenuService=e,this._renderManagerService=t,this._selectionManagerService=n,this._selectionRenderService=r,this._currentUniverService.currentSheet$.subscribe(o=>{if(o==null)throw new Error("workbook is null");this._addListeners()})}_addListeners(){const i=Ce(this._currentUniverService,this._renderManagerService);if(!i)return;const e=i.spreadsheet.onPointerDownObserver,t=e.add(a=>{if(a.button===2){const c=this._selectionManagerService.getSelections(),d=c==null?void 0:c[0];if(!d)return;const u=d.range.rangeType,h=this._selectionRenderService.convertSelectionRangeToData(d).rangeWithCoord,m=()=>{if(!h)return!1;const _=a.offsetX,f=a.offsetY;switch(u){case l.RANGE_TYPE.ROW:return h.startY<=f&&h.endY>=f;case l.RANGE_TYPE.COLUMN:return h.startX<=_&&h.endX>=_;default:return h.startX<=_&&h.endX>=_&&h.startY<=f&&h.endY>=f}},g=_=>{this._contextMenuService.triggerContextMenu(a,_)};m()?u===l.RANGE_TYPE.COLUMN?g(ce.COL_HEADER_CONTEXT_MENU):u===l.RANGE_TYPE.ROW?g(ce.ROW_HEADER_CONTEXT_MENU):g(I.MenuPosition.CONTEXT_MENU):g(I.MenuPosition.CONTEXT_MENU)}});this.disposeWithMe(l.toDisposable(()=>e.remove(t)));const r=i.spreadsheetRowHeader.onPointerDownObserver.add(a=>{a.button===2&&this._contextMenuService.triggerContextMenu(a,ce.ROW_HEADER_CONTEXT_MENU)});this.disposeWithMe(l.toDisposable(()=>e.remove(r)));const s=i.spreadsheetColumnHeader.onPointerDownObserver.add(a=>{a.button===2&&this._contextMenuService.triggerContextMenu(a,ce.COL_HEADER_CONTEXT_MENU)});this.disposeWithMe(l.toDisposable(()=>e.remove(s)))}};fn=Oc([l.OnLifecycle(l.LifecycleStages.Rendered,fn),kt(0,l.IUniverInstanceService),kt(1,I.IContextMenuService),kt(2,b.IRenderManagerService),kt(3,D.Inject(S.SelectionManagerService)),kt(4,_e)],fn);var xc=Object.defineProperty,Ac=Object.getOwnPropertyDescriptor,Dc=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ac(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&xc(e,t,r),r},ui=(i,e)=>(t,n)=>e(t,n,i);let pn=class extends l.RxDisposable{constructor(i,e,t){super(),this._currentUniverService=i,this._renderManagerService=e,this._undoRedoService=t,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialNormalInput(),this._listenEditorBlur()}_listenEditorBlur(){this._currentUniverService.currentDoc$.pipe(N.takeUntil(this.dispose$)).subscribe(i=>{if(i==null)return;i.getUnitId()!==l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._undoRedoService.clearUndoRedo(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})}_initialNormalInput(){const i={};this._currentUniverService.getCurrentUniverSheetInstance().getSheets().forEach(e=>{const t=e.getConfig();i[e.getSheetId()]={cellData:new l.ObjectMatrix(t.cellData),rowCount:t.rowCount,columnCount:t.columnCount}})}_commandExecutedListener(){}_getDocObject(){return J.getDocObject(this._currentUniverService,this._renderManagerService)}};pn=Dc([l.OnLifecycle(l.LifecycleStages.Steady,pn),ui(0,l.IUniverInstanceService),ui(1,b.IRenderManagerService),ui(2,D.Inject(l.IUndoRedoService))],pn);const zo=[I.KeyCode.ARROW_DOWN,I.KeyCode.ARROW_UP,I.KeyCode.ARROW_LEFT,I.KeyCode.ARROW_RIGHT],Nc=[I.KeyCode.ENTER,I.KeyCode.TAB,...zo];function Hc(){const i=[];for(const e of zo)i.push({id:Gt.id,binding:e,preconditions:t=>Fn(t),staticParameters:{visible:!1,eventType:b.DeviceInputEventType.Keyboard,keycode:e,isShift:!1}}),i.push({id:Gt.id,binding:e|I.MetaKeys.SHIFT,preconditions:t=>Fn(t),staticParameters:{visible:!1,eventType:b.DeviceInputEventType.Keyboard,keycode:e,isShift:!0}});return i}const Pc={id:Pe.id,binding:I.KeyCode.ENTER,description:"shortcut.sheet.toggle-editing",group:"4_sheet-edit",preconditions:i=>Fn(i),staticParameters:{visible:!1,eventType:b.DeviceInputEventType.Keyboard,keycode:I.KeyCode.ENTER}},Lc={id:Pe.id,binding:I.KeyCode.TAB,preconditions:i=>Fn(i),staticParameters:{visible:!1,eventType:b.DeviceInputEventType.Keyboard,keycode:I.KeyCode.TAB}},Uc={id:Pe.id,binding:I.KeyCode.ESC,description:"shortcut.sheet.abort-editing",group:"4_sheet-edit",preconditions:i=>Di(i),staticParameters:{visible:!1,eventType:b.DeviceInputEventType.Keyboard,keycode:I.KeyCode.ESC}},kc={id:J.BreakLineCommand.id,description:"shortcut.sheet.break-line",group:"4_sheet-edit",preconditions:i=>Di(i),binding:I.KeyCode.ENTER|I.MetaKeys.ALT},Vc={id:J.DeleteLeftCommand.id,preconditions:i=>Ms(i)||qr(i),binding:I.KeyCode.BACKSPACE},Bc={id:Pe.id,description:"shortcut.sheet.delete-and-start-editing",group:"4_sheet-edit",preconditions:i=>ne(i)&&!qr(i),binding:I.KeyCode.BACKSPACE,staticParameters:{visible:!0,eventType:b.DeviceInputEventType.Keyboard,keycode:I.KeyCode.BACKSPACE}};var Fc=Object.defineProperty,Wc=Object.getOwnPropertyDescriptor,jc=(i,e,t,n)=>{for(var r=n>1?void 0:n?Wc(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Fc(e,t,r),r},De=(i,e)=>(t,n)=>e(t,n,i);function $c(i){const{textRuns:e=[],paragraphs:t=[]}=i;return e.some(n=>n.ts&&!l.Tools.isEmptyObject(n.ts))||t.some(n=>n.bullet)||t.length>=2}let vn=class extends l.Disposable{constructor(e,t,n,r,o,s,a,c,d,u){super();C(this,"_onInputSubscription");C(this,"_cursorChangeObservers");C(this,"_editorVisiblePrevious",!1);C(this,"_isCursorChange",0);this._currentUniverService=e,this._renderManagerService=t,this._commandService=n,this._editorBridgeService=r,this._contextService=o,this._cellEditorManagerService=s,this._lexerTreeBuilder=a,this._undoRedoService=c,this._sheetInterceptorService=d,this._selectionManagerService=u,this._initialize(),this._commandExecutedListener()}dispose(){var n;(n=this._onInputSubscription)==null||n.unsubscribe();const e=this._getEditorObject();if(e==null)return;const{document:t}=e;t.onPointerDownObserver.remove(this._cursorChangeObservers)}_initialize(){this._initialExitInput(),this._cursorStateListener()}_initialExitInput(){this._onInputSubscription=this._editorBridgeService.visible$.subscribe(e=>{const{visible:t,keycode:n,eventType:r}=e;if(t===this._editorVisiblePrevious)return;if(this._editorVisiblePrevious=t,t===!0){this._isCursorChange=r===b.DeviceInputEventType.PointerDown?2:1;return}this._isCursorChange=0;const o=this._selectionManagerService.getSelections(),s=this._selectionManagerService.getCurrent();if(s==null)return;const{unitId:a,sheetId:c,pluginName:d}=s;if(this._exitInput(e),n===I.KeyCode.ESC){this._commandService.syncExecuteCommand(S.SetSelectionsOperation.id,{unitId:a,subUnitId:c,pluginName:d,selections:o});return}const u=this._editorBridgeService.getEditCellState();if(u==null)return;const{unitId:h,sheetId:m,row:g,column:_,documentLayoutObject:f}=u;if(this._editorBridgeService.getEditorDirty()===!1){this._moveCursor(n);return}const R=this._currentUniverService.getUniverSheetInstance(h),M=R==null?void 0:R.getSheetBySheetId(m);if(M==null)return;const T=zc(M.getCellRaw(g,_)||{},f,this._lexerTreeBuilder);if(T==null){this._moveCursor(n);return}const w={subUnitId:m,unitId:h,workbook:R,worksheet:M,row:g,col:_},E=this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT)(T,w);this._commandService.executeCommand(S.SetRangeValuesCommand.id,{subUnitId:m,unitId:h,range:{startRow:g,startColumn:_,endRow:g,endColumn:_},value:E}),this._moveCursor(n),a===h&&m!==c&&this._editorBridgeService.isForceKeepVisible()&&this._commandService.executeCommand(S.SetWorksheetActivateCommand.id,{subUnitId:m,unitId:h}),this._selectionManagerService.refreshSelection()})}_exitInput(e){this._contextService.setContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA,!1),this._contextService.setContextValue(l.EDITOR_ACTIVATED,!1),this._contextService.setContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN,!1),this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!1),this._cellEditorManagerService.setState({show:e.visible});const t=this._editorBridgeService.getCurrentEditorId();t!=null&&(this._undoRedoService.clearUndoRedo(t),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))}_moveCursor(e){if(e==null||!Nc.includes(e))return;let t=l.Direction.LEFT;switch(e){case I.KeyCode.ENTER:t=l.Direction.DOWN;break;case I.KeyCode.TAB:t=l.Direction.RIGHT;break;case I.KeyCode.ARROW_DOWN:t=l.Direction.DOWN;break;case I.KeyCode.ARROW_UP:t=l.Direction.UP;break;case I.KeyCode.ARROW_LEFT:t=l.Direction.LEFT;break;case I.KeyCode.ARROW_RIGHT:t=l.Direction.RIGHT;break}e===I.KeyCode.ENTER||e===I.KeyCode.TAB?this._commandService.executeCommand(lt.id,{keycode:e,direction:t}):this._commandService.executeCommand(we.id,{direction:t})}_cursorStateListener(){const e=this._getEditorObject();if(e==null)return;const{document:t}=e;this._cursorChangeObservers=t.onPointerDownObserver.add(()=>{this._isCursorChange===1&&(this._isCursorChange=2)})}_commandExecutedListener(){const e=[Gt.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=t.params,{keycode:r,isShift:o}=n;if(r!=null&&this._isCursorChange===2){this._moveInEditor(r,o);return}this._editorBridgeService.changeVisible(n)}}))}_moveInEditor(e,t){let n=l.Direction.LEFT;e===I.KeyCode.ARROW_DOWN?n=l.Direction.DOWN:e===I.KeyCode.ARROW_UP?n=l.Direction.UP:e===I.KeyCode.ARROW_RIGHT&&(n=l.Direction.RIGHT),t?this._commandService.executeCommand(J.MoveSelectionOperation.id,{direction:n}):this._commandService.executeCommand(J.MoveCursorOperation.id,{direction:n})}_getEditorObject(){return Yn(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};vn=jc([l.OnLifecycle(l.LifecycleStages.Steady,vn),De(0,l.IUniverInstanceService),De(1,b.IRenderManagerService),De(2,l.ICommandService),De(3,Te),De(4,l.IContextService),De(5,tn),De(6,D.Inject(te.LexerTreeBuilder)),De(7,l.IUndoRedoService),De(8,D.Inject(S.SheetInterceptorService)),De(9,D.Inject(S.SelectionManagerService))],vn);function zc(i,e,t){i=l.Tools.deepClone(i);const{documentModel:n}=e;if(n==null)return null;const r=n.getSnapshot(),{body:o}=r;if(o==null)return null;const s=o.dataStream;let c=s.substring(s.length-2,s.length)===l.DEFAULT_EMPTY_DOCUMENT_VALUE?s.substring(0,s.length-2):s;if(l.isFormulaString(c)){if(i.f===c)return null;const d=t.checkIfAddBracket(c);for(let u=0;u<d;u++)c+=te.matchToken.CLOSE_BRACKET;i.f=c,i.v=null,i.p=null}else if($c(o))o.dataStream===`\r
|
|
19
|
+
`?(i.v="",i.f=null,i.si=null,i.p=null):(i.p=r,i.v=null,i.f=null,i.si=null);else{if((c===i.v||c===""&&i.v==null)&&i.p==null)return null;i.v=c,i.f=null,i.si=null,i.p=null}return i}var Xc=Object.defineProperty,Yc=Object.getOwnPropertyDescriptor,Zc=(i,e,t,n)=>{for(var r=n>1?void 0:n?Yc(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Xc(e,t,r),r},Ne=(i,e)=>(t,n)=>e(t,n,i);let Cn=class extends l.RxDisposable{constructor(e,t,n,r,o,s,a,c,d,u){super();C(this,"_loadedMap",new Set);this._univerInstanceService=e,this._renderManagerService=t,this._editorBridgeService=n,this._docSkeletonManagerService=r,this._docViewModelManagerService=o,this._commandService=s,this._contextService=a,this._formulaEditorManagerService=c,this._undoRedoService=d,this._textSelectionManagerService=u,this._initialize()}_initialize(){this._syncFormulaEditorContent(),this._commandExecutedListener(),this._syncEditorSize(),this._listenFxBtnClick(),this._listenFoldBtnClick(),this._renderManagerService.currentRender$.pipe(N.takeUntil(this.dispose$)).subscribe(e=>{e===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(this._loadedMap.has(e)||(this._initialMain(e),this._loadedMap.add(e)))}),this._textSelectionManagerService.textSelection$.pipe(N.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const{unitId:t}=e;t!==l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!1),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))})}_listenFxBtnClick(){this._formulaEditorManagerService.fxBtnClick$.pipe(N.takeUntil(this.dispose$)).subscribe(()=>{var t;if(this._contextService.getContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN)&&!this._contextService.getContextValue(l.EDITOR_ACTIVATED)){this._univerInstanceService.setCurrentUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!0);const n=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:b.DeviceInputEventType.PointerDown});const o=(t=n==null?void 0:n.getBody())==null?void 0:t.dataStream;if(o==null)return;let s=o.startsWith("=")?o:`=${o}`;s=s.replace(/\r\n$/,"");const a=[{startOffset:s.length,endOffset:s.length}],c={unitId:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:s},segmentId:""};this._commandService.executeCommand(J.CoverContentCommand.id,c),this._textSelectionManagerService.replaceTextRanges(a)}})}_listenFoldBtnClick(){this._formulaEditorManagerService.foldBtnStatus$.pipe(N.takeUntil(this.dispose$)).subscribe(()=>{this._textSelectionManagerService.refreshSelection()})}_initialMain(e){const t=this._renderManagerService.getRenderById(e);if(t==null)return;const{mainComponent:n}=t;n!=null&&this.disposeWithMe(l.toDisposable(n.onPointerDownObserver.add(()=>{this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!0),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:b.DeviceInputEventType.PointerDown})})))}_syncEditorSize(){this._formulaEditorManagerService.position$.pipe(N.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const t=Yn(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,this._renderManagerService),n=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(t==null||n==null)return;const{width:r,height:o}=e,{engine:s}=t;n.updateDocumentDataPageSize(r),this._autoScroll(),requestIdleCallback(()=>{s.resizeBySize(r,o)})})}_syncFormulaEditorContent(){this._editorBridgeService.currentEditCellState$.pipe(N.takeUntil(this.dispose$)).subscribe(e=>{e==null||this._editorBridgeService.isForceKeepVisible()||this._editorSyncHandler(e)}),this._editorBridgeService.visible$.pipe(N.takeUntil(this.dispose$)).subscribe(e=>{if(e==null||e.visible===!1||this._editorBridgeService.isForceKeepVisible())return;const t=this._editorBridgeService.getLatestEditCellState();t!=null&&this._editorSyncHandler(t)})}_editorSyncHandler(e){var s;const t=(s=e.documentLayoutObject.documentModel)==null?void 0:s.getBody();let n=t==null?void 0:t.dataStream,r=t==null?void 0:t.paragraphs,o=[];n==null||r==null||(e.isInArrayFormulaRange===!0&&this._editorBridgeService.isVisible().eventType===b.DeviceInputEventType.Dblclick?(n=`\r
|
|
20
|
+
`,r=[{startIndex:0}]):e.isInArrayFormulaRange===!0&&(o=(t==null?void 0:t.textRuns)||[]),this._syncContentAndRender(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,n,r,o),this._autoScroll())}_commandExecutedListener(){const e=[J.RichTextEditingMutation.id,Zn.id],t=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(r=>{var o,s;if(e.includes(r.id)){const a=r.params,{unitId:c}=a;if(t.includes(c)){const d=this._univerInstanceService.getUniverDocInstance(c),u=(o=d==null?void 0:d.getBody())==null?void 0:o.dataStream,h=(s=d==null?void 0:d.getBody())==null?void 0:s.paragraphs,m=c===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;if(u==null||h==null)return;this._syncContentAndRender(m,u,h),this._autoScroll()}}}));const n=[S.SetRangeValuesMutation.id,S.MoveRangeMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(r=>{var o,s,a,c,d;if(n.includes(r.id)){const u=this._editorBridgeService.getLatestEditCellState();if(u==null)return;let h=!1;const{row:m,column:g}=u;if(r.id===S.SetRangeValuesMutation.id&&r.params?(s=(o=r.params.cellValue)==null?void 0:o[m])!=null&&s[g]&&(h=!0):r.id===S.MoveRangeMutation.id&&r.params&&(c=(a=r.params.to.value)==null?void 0:a[m])!=null&&c[g]&&(h=!0),h){const _=(d=u.documentLayoutObject.documentModel)==null?void 0:d.getBody();if(_==null)return;const{dataStream:f,paragraphs:v=[]}=_;this._syncContentAndRender(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,f,v),this._autoScroll()}}}))}_syncContentAndRender(e,t,n,r=[]){var h;const o=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=this._docSkeletonManagerService.getSkeletonByUnitId(e),a=this._univerInstanceService.getUniverDocInstance(e),c=this._docViewModelManagerService.getViewModel(e);if(a==null||c==null||s==null)return;a.getBody().dataStream=t,a.getBody().paragraphs=this._clearParagraph(n),e===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(a.getBody().textRuns=[]),r.length>0&&(a.getBody().textRuns=r),c.reset(a);const{skeleton:d}=s,u=this._renderManagerService.getRenderById(e);u!=null&&(d.calculate(),o.includes(e)&&((h=u.mainComponent)==null||h.makeDirty()))}_clearParagraph(e){const t=l.Tools.deepClone(e);for(const n of t)n.paragraphStyle&&(n.paragraphStyle.horizontalAlign=l.HorizontalAlign.UNSPECIFIED);return t}_autoScroll(){var _,f;const e=(_=this._docSkeletonManagerService.getSkeletonByUnitId(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))==null?void 0:_.skeleton,t=this._formulaEditorManagerService.getPosition(),n=this._renderManagerService.getRenderById(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),r=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(e==null||t==null||n==null||r==null)return;const{marginTop:o=0,marginBottom:s=0}=r.getSnapshot().documentStyle,{scene:a,mainComponent:c}=n;let{actualHeight:d}=e.getActualSize();d+=o+s;const{width:u,height:h}=t,m=a.getViewport(J.VIEWPORT_KEY.VIEW_MAIN);let g=m==null?void 0:m.getScrollBar();a.transformByState({width:u,height:d}),c==null||c.resize(u,d),d>h?g==null?m&&new b.ScrollBar(m,{enableHorizontal:!1,barSize:8}):m==null||m.resetSizeAndScrollBar():(g=null,m==null||m.scrollTo({x:0,y:0}),(f=m==null?void 0:m.getScrollBar())==null||f.dispose())}};Cn=Zc([l.OnLifecycle(l.LifecycleStages.Steady,Cn),Ne(0,l.IUniverInstanceService),Ne(1,b.IRenderManagerService),Ne(2,Te),Ne(3,D.Inject(J.DocSkeletonManagerService)),Ne(4,D.Inject(J.DocViewModelManagerService)),Ne(5,l.ICommandService),Ne(6,l.IContextService),Ne(7,Jn),Ne(8,l.IUndoRedoService),Ne(9,D.Inject(J.TextSelectionManagerService))],Cn);var Gc=Object.defineProperty,Kc=Object.getOwnPropertyDescriptor,qc=(i,e,t,n)=>{for(var r=n>1?void 0:n?Kc(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Gc(e,t,r),r},Jc=(i,e)=>(t,n)=>e(t,n,i);let In=class extends l.Disposable{constructor(i){super(),this._currentUniverService=i,setTimeout(()=>{this._initialize()},0)}_initialize(){this._currentUniverService.createDoc({id:l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:{dataStream:`${l.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{}});const i={id:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:`${l.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:1/0,height:1/0},marginTop:5,marginBottom:5,marginRight:0,marginLeft:0,paragraphLineGapDefault:0,renderConfig:{horizontalAlign:l.HorizontalAlign.UNSPECIFIED,verticalAlign:l.VerticalAlign.UNSPECIFIED,centerAngle:0,vertexAngle:0,wrapStrategy:l.WrapStrategy.WRAP}}};this._currentUniverService.createDoc(i)}};In=qc([l.OnLifecycle(l.LifecycleStages.Rendered,In),Jc(0,l.IUniverInstanceService)],In);const Qc="36",ed="univer-sheet-container",Xo={sheetFooterBarHeight:Qc,sheetContainer:ed};var td=Object.defineProperty,nd=Object.getOwnPropertyDescriptor,id=(i,e,t,n)=>{for(var r=n>1?void 0:n?nd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&td(e,t,r),r},ye=(i,e)=>(t,n)=>e(t,n,i);const Or=-1e3,xr=5,rd=2;let Rn=class extends l.Disposable{constructor(e,t,n,r,o,s,a,c,d,u,h){super();C(this,"_onInputSubscription");C(this,"_onInputActivateSubscription");C(this,"_editorVisiblePrevious",!1);this._docSkeletonManagerService=e,this._docViewModelManagerService=t,this._contextService=n,this._currentUniverService=r,this._renderManagerService=o,this._editorBridgeService=s,this._cellEditorManagerService=a,this._textSelectionRenderManager=c,this._textSelectionManagerService=d,this._commandService=u,this._localService=h,this._initialize(),this._commandExecutedListener()}dispose(){var e,t;(e=this._onInputSubscription)==null||e.unsubscribe(),(t=this._onInputActivateSubscription)==null||t.unsubscribe()}_initialize(){this._initialEditFocusListener(),this._initialStartEdit(),this._initialKeyboardListener(),this._initialCursorSync(),this._listenEditorFocus()}_listenEditorFocus(){const e=this._getEditorObject();e!=null&&this.disposeWithMe(l.toDisposable(e.document.onPointerDownObserver.add(()=>{var t;if(this._editorBridgeService.isVisible()){const n=this._editorBridgeService.getEditCellState(),r=this._editorBridgeService.getCurrentEditorId();if(n==null||r==null)return;const o=(t=this._docSkeletonManagerService.getSkeletonByUnitId(r))==null?void 0:t.skeleton;if(o==null)return;const{position:s,documentLayoutObject:a,canvasOffset:c,scaleX:d,scaleY:u}=n;this._fitTextSize(s,c,o,a,d,u)}})))}_initialCursorSync(){this._cellEditorManagerService.focus$.subscribe(()=>{this._textSelectionRenderManager.sync()})}_initialEditFocusListener(){this._onInputSubscription=this._editorBridgeService.currentEditCellState$.subscribe(e=>{if(e==null||this._editorBridgeService.isForceKeepVisible())return;const{position:t,documentLayoutObject:n,scaleX:r,editorUnitId:o}=e;if(this._getEditorObject()==null)return;const{startX:a,endX:c}=t,{textRotation:d,wrapStrategy:u,documentModel:h}=n,{a:m}=d;h.updateDocumentId(o),u===l.WrapStrategy.WRAP&&m===0&&h.updateDocumentDataPageSize((c-a)/r),this._currentUniverService.changeDoc(o,h),this._contextService.setContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN,!0),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}]),this._textSelectionRenderManager.activate(Or,Or)})}_fitTextSize(e,t,n,r,o=1,s=1){const{startX:a,startY:c,endX:d,endY:u}=e,h=r.documentModel;if(h==null)return;const{actualWidth:m,actualHeight:g}=this._predictingSize(e,t,n,r,o,s),{verticalAlign:_,paddingData:f,fill:v}=r;let R=d-a,M=u-c;if(R<m&&(R=m),M<g)M=g,h.updateDocumentDataMargin(f);else{let T=f.t||0;_===l.VerticalAlign.MIDDLE?T=(M-g)/2:_===l.VerticalAlign.BOTTOM&&(T=M-g),T/=s,T=T<(f.t||0)?f.t||0:T,h.updateDocumentDataMargin({t:T})}n.calculate(),this._editAreaProcessing(R,M,e,t,v,o,s)}_predictingSize(e,t,n,r,o=1,s=1){const{startX:a,endX:c}=e,{textRotation:d,wrapStrategy:u}=r,h=r.documentModel,{a:m}=d,g=document.body.clientWidth;if(u===l.WrapStrategy.WRAP&&m===0){const{actualWidth:v,actualHeight:R}=n.getActualSize();return{actualWidth:v*o,actualHeight:R*s}}h==null||h.updateDocumentDataPageSize((g-a-t.left)/o),n.calculate();const _=n.getActualSize();let f=c-a;return f<_.actualWidth*o+xr*o&&(f=_.actualWidth*o+xr*o),h==null||h.updateDocumentDataPageSize(f/o),h==null||h.updateDocumentRenderConfig({horizontalAlign:l.HorizontalAlign.UNSPECIFIED}),{actualWidth:f,actualHeight:_.actualHeight*s}}_editAreaProcessing(e,t,n,r,o,s=1,a=1){var E;const c=this._getEditorObject();if(c==null)return;let{startX:d,startY:u}=n;const{document:h,scene:m,engine:g}=c,_=m.getViewport(J.VIEWPORT_KEY.VIEW_MAIN),f=document.body.clientHeight-u-parseFloat(Xo.sheetFooterBarHeight)-r.top-rd*2,v=document.body.clientWidth-d-r.left;let R=t,M=_==null?void 0:_.getScrollBar();R>f?(R=f,M==null?_&&new b.ScrollBar(_,{enableHorizontal:!1,barSize:8}):_==null||_.resetSizeAndScrollBar()):(M=null,(E=_==null?void 0:_.getScrollBar())==null||E.dispose()),e+=(M==null?void 0:M.barSize)||0,e>v&&(e=v),d-=b.FIX_ONE_PIXEL_BLUR_OFFSET,u-=b.FIX_ONE_PIXEL_BLUR_OFFSET,this._addBackground(m,e/s,t/a,o);const{scaleX:T,scaleY:w}=m.getPrecisionScale();m.transformByState({width:e/s,height:t/a,scaleX:s,scaleY:a}),h.resize(e/s,t/a),requestIdleCallback(()=>{g.resizeBySize(b.fixLineWidthByScale(e,T),b.fixLineWidthByScale(R,w))}),this._cellEditorManagerService.setState({startX:d,startY:u,endX:e+d,endY:R+u,show:!0})}_addBackground(e,t,n,r){const o="_backgroundRectHelperColor_",s=e.getObject(o);s==null&&r==null||(s==null?e.addObjects([new b.Rect(o,{width:t,height:n,fill:r,evented:!1})],J.DOCS_COMPONENT_MAIN_LAYER_INDEX):r==null?s.dispose():(s.setProps({fill:r}),s.transformByState({width:t,height:n})))}_initialStartEdit(){this._onInputActivateSubscription=this._editorBridgeService.visible$.subscribe(e=>{var w,E,y;const{visible:t,eventType:n,keycode:r}=e;if(t===this._editorVisiblePrevious||(this._editorVisiblePrevious=t,t===!1))return;const o=this._editorBridgeService.getEditCellState();if(o==null)return;const{position:s,documentLayoutObject:a,canvasOffset:c,scaleX:d,scaleY:u,editorUnitId:h,unitId:m,isInArrayFormulaRange:g=!1}=o,_=this._getEditorObject();if(_==null)return;const{document:f,scene:v}=_;this._contextService.setContextValue(l.EDITOR_ACTIVATED,!0);const{documentModel:R}=a,M=this._docSkeletonManagerService.getSkeletonByUnitId(h);if(M==null||R==null)return;const{skeleton:T}=M;if(this._fitTextSize(s,c,T,a,d,u),n===b.DeviceInputEventType.Keyboard||n===b.DeviceInputEventType.Dblclick&&g){const x=l.Tools.deepClone(R.snapshot),O=(w=this._docViewModelManagerService.getCurrent())==null?void 0:w.docViewModel;this._resetBodyStyle(x.body),R.reset(x),O.reset(R),f.makeDirty(),(r===I.KeyCode.BACKSPACE||n===b.DeviceInputEventType.Dblclick)&&(T.calculate(),this._editorBridgeService.changeEditorDirty(!0)),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}])}else if(n===b.DeviceInputEventType.Dblclick){const x=R.getBody().dataStream.length-2||0;(E=v.getViewport(J.VIEWPORT_KEY.VIEW_MAIN))==null||E.scrollTo({y:1/0}),this._textSelectionManagerService.replaceTextRanges([{startOffset:x,endOffset:x}])}(y=this._renderManagerService.getRenderById(m))==null||y.scene.resetCursor()})}_resetBodyStyle(e){e.dataStream=l.DEFAULT_EMPTY_DOCUMENT_VALUE,e.textRuns!=null&&(e.textRuns.length===1?(e.textRuns[0].st=0,e.textRuns[0].ed=1):e.textRuns=void 0),e.paragraphs!=null&&(e.paragraphs.length===1?e.paragraphs[0].startIndex=0:e.paragraphs=[{startIndex:0}]),e.sectionBreaks!=null&&(e.sectionBreaks=void 0),e.tables!=null&&(e.tables=void 0),e.customRanges!=null&&(e.customRanges=void 0),e.customBlocks!=null&&(e.customBlocks=void 0)}_initialKeyboardListener(){this._textSelectionRenderManager.onInputBefore$.subscribe(e=>{const t=this._contextService.getContextValue(l.FOCUSING_FORMULA_EDITOR);this._contextService.getContextValue(l.FOCUSING_SHEET)&&!t&&this._showEditorByKeyboard(e)})}_showEditorByKeyboard(e){if(e==null)return;const t=e.event;this._commandService.executeCommand(Pe.id,{visible:!0,eventType:b.DeviceInputEventType.Keyboard,keycode:t.which})}_commandExecutedListener(){const e=[J.RichTextEditingMutation.id,Zn.id],t=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var r;if(e.includes(n.id)){const o=n.params,{unitId:s}=o,a=this._editorBridgeService.getCurrentEditorId();if(a==null)return;this._editorBridgeService.changeEditorDirty(!0);const c=(r=this._docSkeletonManagerService.getSkeletonByUnitId(a))==null?void 0:r.skeleton;if(c==null||!t.includes(s))return;const d=this._editorBridgeService.getEditCellState();if(d==null)return;const{position:u,documentLayoutObject:h,canvasOffset:m,scaleX:g,scaleY:_}=d;this._fitTextSize(u,m,c,h,g,_)}}))}_getEditorObject(){return Yn(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};Rn=id([l.OnLifecycle(l.LifecycleStages.Steady,Rn),ye(0,D.Inject(J.DocSkeletonManagerService)),ye(1,D.Inject(J.DocViewModelManagerService)),ye(2,l.IContextService),ye(3,l.IUniverInstanceService),ye(4,b.IRenderManagerService),ye(5,Te),ye(6,tn),ye(7,b.ITextSelectionRenderManager),ye(8,D.Inject(J.TextSelectionManagerService)),ye(9,l.ICommandService),ye(10,D.Inject(l.LocaleService))],Rn);const Qn={id:"sheet.command.change-zoom-ratio",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const{delta:t,reset:n}=e,r=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),o=r.getActiveSheet(),s=r.getUnitId(),a=o.getSheetId();let c=n?100:Math.round((o.getConfig().zoomRatio+t)*100);c=Math.max(Ii[0],c),c=Math.min(Ii[1],c);const d=c/100;return i.get(l.ICommandService).executeCommand(ze.id,{unitId:s,subUnitId:a,zoomRatio:d})}},ei={id:"sheet.command.set-zoom-ratio",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const{unitId:t,subUnitId:n,zoomRatio:r}=e;return i.get(l.ICommandService).executeCommand(ze.id,{unitId:t,subUnitId:n,zoomRatio:r})}},Yo={id:"sheet.operation.set-activate-cell-edit",type:l.CommandType.OPERATION,handler:(i,e)=>(i.get(Te).setEditCell(e),!0)};var od=Object.defineProperty,sd=Object.getOwnPropertyDescriptor,ad=(i,e,t,n)=>{for(var r=n>1?void 0:n?sd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&od(e,t,r),r},ct=(i,e)=>(t,n)=>e(t,n,i);let Mn=class extends l.RxDisposable{constructor(i,e,t,n,r,o){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._editorBridgeService=r,this._selectionManagerService=o,this._initialize(),this._commandExecutedListener()}dispose(){}_initialize(){this._initSelectionChangeListener(),this._initialEventListener()}_initSelectionChangeListener(){N.merge(this._selectionManagerService.selectionMoveEnd$,this._selectionManagerService.selectionMoveStart$).pipe(N.takeUntil(this.dispose$)).subscribe(i=>this._handleSelectionListener(i))}_handleSelectionListener(i){const e=this._selectionManagerService.getCurrent();if((e==null?void 0:e.pluginName)!==S.NORMAL_SELECTION_PLUGIN_NAME||this._editorBridgeService.isVisible().visible===!0)return;const t=this._sheetSkeletonManagerService.getCurrent();if(t==null||i==null||i.length===0||i[i.length-1]==null)return;const{primary:n}=i[i.length-1];if(n==null)return;const r=this._getSheetObject();if(r==null)return;const{unitId:o,sheetId:s}=t,{scene:a,engine:c}=r;this._commandService.executeCommand(Yo.id,{scene:a,engine:c,primary:n,unitId:o,sheetId:s})}_initialEventListener(){const i=this._getSheetObject();if(i==null)return;const{spreadsheet:e,spreadsheetColumnHeader:t,spreadsheetLeftTopPlaceholder:n,spreadsheetRowHeader:r}=i;e.onDblclickObserver.add(o=>{o.button!==2&&this._commandService.executeCommand(Pe.id,{visible:!0,eventType:b.DeviceInputEventType.Dblclick})}),e.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),t.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),n.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),r.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this))}_keepVisibleHideEditor(){this._editorBridgeService.isForceKeepVisible()||this._hideEditor()}_hideEditor(){this._editorBridgeService.isVisible().visible===!0&&(this._selectionManagerService.makeDirty(!1),this._commandService.executeCommand(Pe.id,{visible:!1,eventType:b.DeviceInputEventType.PointerDown}),setTimeout(()=>{this._selectionManagerService.makeDirty(!0)},0))}_getSheetObject(){return Ce(this._currentUniverService,this._renderManagerService)}_commandExecutedListener(){const i=S.COMMAND_LISTENER_SKELETON_CHANGE;this.disposeWithMe(this._commandService.onCommandExecuted((e,t)=>{t!=null&&t.fromCollab||(e.id===S.SetWorksheetActiveOperation.id?this._keepVisibleHideEditor():i.includes(e.id)&&this._hideEditor())})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{e.id===ei.id&&this._editorBridgeService.refreshEditCellState()}))}};Mn=ad([l.OnLifecycle(l.LifecycleStages.Rendered,Mn),ct(0,D.Inject(exports.SheetSkeletonManagerService)),ct(1,l.IUniverInstanceService),ct(2,l.ICommandService),ct(3,b.IRenderManagerService),ct(4,Te),ct(5,D.Inject(S.SelectionManagerService))],Mn);var ld=Object.defineProperty,cd=Object.getOwnPropertyDescriptor,dd=(i,e,t,n)=>{for(var r=n>1?void 0:n?cd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&ld(e,t,r),r},Vt=(i,e)=>(t,n)=>e(t,n,i);let bn=class extends l.Disposable{constructor(i,e,t,n,r){super(),this._commandService=i,this._formatPainterService=e,this._currentUniverService=t,this._renderManagerService=n,this._selectionRenderService=r,this._initialize()}_initialize(){this._commandExecutedListener(),this._bindFormatPainterStatus()}_bindFormatPainterStatus(){this._formatPainterService.status$.subscribe(i=>{const{scene:e}=this._getSheetObject()||{};e&&(i!==Oe.OFF?e.setDefaultCursor(b.CURSOR_TYPE.CELL):e.setDefaultCursor(b.CURSOR_TYPE.DEFAULT))})}_commandExecutedListener(){this.disposeWithMe(l.toDisposable(this._selectionRenderService.selectionMoveEnd$.subscribe(i=>{if(this._formatPainterService.getStatus()!==Oe.OFF){const{rangeWithCoord:e}=i[i.length-1];this._applyFormatPainter({startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}),this._formatPainterService.getStatus()===Oe.ONCE&&this._commandService.executeCommand($i.id)}})))}async _applyFormatPainter(i){const{styles:e,merges:t}=this._formatPainterService.getSelectionFormat(),n=this._currentUniverService.getCurrentUniverSheetInstance().getUnitId(),r=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();if(!e)return;const{startRow:o,startColumn:s,endRow:a,endColumn:c}=e.getDataRange(),d=a-o+1,u=c-s+1,h=Array.from({length:i.endRow-i.startRow+1},()=>Array.from({length:i.endColumn-i.startColumn+1},()=>({}))),m=[];h.forEach((_,f)=>{_.forEach((v,R)=>{const M=f%d+o,T=R%u+s,w=e.getValue(M,T);w&&(h[f][R].s=w)})}),t.forEach(_=>{const f={startRow:_.startRow-o,startColumn:_.startColumn-s,endRow:_.endRow-o,endColumn:_.endColumn-s},v=Math.max(1,Math.floor((i.endRow-i.startRow+1)/d)),R=Math.max(1,Math.floor((i.endColumn-i.startColumn+1)/u));for(let M=0;M<v;M++)for(let T=0;T<R;T++)m.push({startRow:f.startRow+M*d+i.startRow,startColumn:f.startColumn+T*u+i.startColumn,endRow:f.endRow+M*d+i.startRow,endColumn:f.endColumn+T*u+i.startColumn})});const g={subUnitId:r,unitId:n,styleRange:i,styleValues:h,mergeRanges:m};await this._commandService.executeCommand(Lo.id,g)}_getSheetObject(){return Ce(this._currentUniverService,this._renderManagerService)}};bn=dd([l.OnLifecycle(l.LifecycleStages.Rendered,bn),Vt(0,l.ICommandService),Vt(1,Tt),Vt(2,l.IUniverInstanceService),Vt(3,b.IRenderManagerService),Vt(4,_e)],bn);const wn={id:"sheet.command.set-scroll-relative",type:l.CommandType.COMMAND,handler:async(i,e={offsetX:0,offsetY:0})=>{const t=i.get(l.ICommandService),n=i.get(Je),o=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),s=o.getActiveSheet(),{xSplit:a,ySplit:c}=s.getConfig().freeze,d=n.getCurrentScroll(),{offsetX:u=0,offsetY:h=0}=e||{},{sheetViewStartRow:m=0,sheetViewStartColumn:g=0,offsetX:_=0,offsetY:f=0}=d||{};return t.executeCommand(wt.id,{unitId:o.getUnitId(),sheetId:s.getSheetId(),sheetViewStartRow:m+c,sheetViewStartColumn:g+a,offsetX:_+u,offsetY:f+h})}},pt={id:"sheet.command.scroll-view",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const n=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),r=n.getActiveSheet(),s=i.get(Je).getCurrentScroll();if(!r)return!1;const a=i.get(l.ICommandService),{sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:u,offsetY:h}=e,{sheetViewStartColumn:m,sheetViewStartRow:g,offsetX:_,offsetY:f}=s||{},{xSplit:v,ySplit:R}=r.getConfig().freeze;return a.executeCommand(wt.id,{unitId:n.getUnitId(),sheetId:r.getSheetId(),sheetViewStartRow:c!=null?c:(g!=null?g:0)+R,sheetViewStartColumn:d!=null?d:(m!=null?m:0)+v,offsetX:u!=null?u:_,offsetY:h!=null?h:f})}};l.CommandType.COMMAND;var ud=Object.defineProperty,hd=Object.getOwnPropertyDescriptor,md=(i,e,t,n)=>{for(var r=n>1?void 0:n?hd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&ud(e,t,r),r},He=(i,e)=>(t,n)=>e(t,n,i);const gd="__SpreadsheetFreezeRowMainName__",_d="__SpreadsheetFreezeRowHeaderName__",Sd="__SpreadsheetFreezeColumnMainName__",fd="__SpreadsheetFreezeColumnHeaderName__",hi=4,pd=.01;let Tn=class extends l.Disposable{constructor(e,t,n,r,o,s,a,c,d,u){super();C(this,"_rowFreezeHeaderRect");C(this,"_rowFreezeMainRect");C(this,"_columnFreezeHeaderRect");C(this,"_columnFreezeMainRect");C(this,"_freezeDownObservers",[]);C(this,"_freezeMoveObservers",[]);C(this,"_freezeLeaveObservers",[]);C(this,"_moveObserver");C(this,"_upObserver");C(this,"_changeToRow",-1);C(this,"_changeToColumn",-1);C(this,"_changeToOffsetX",0);C(this,"_changeToOffsetY",0);C(this,"_activeViewport",null);C(this,"_freezeNormalHeaderColor","");C(this,"_freezeNormalMainColor","");C(this,"_freezeActiveColor","");C(this,"_freezeHoverColor","");C(this,"_lastFreeze");this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._commandService=n,this._renderManagerService=r,this._selectionRenderService=o,this._selectionManagerService=s,this._scrollManagerService=a,this._themeService=c,this._sheetInterceptorService=d,this._injector=u,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._themeChangeListener(),this._interceptorCommands(),this._bindViewportScroll(),this._zoomRefresh()}_createFreeze(e=0,t){var x;const n=t!=null?t:this._getFreeze();if(n==null)return;const r=(x=this._sheetSkeletonManagerService.getCurrent())==null?void 0:x.skeleton;if(r==null)return;const{startRow:o,startColumn:s}=n,a=this._getPositionByIndex(o,s);if(a==null)return;const c=this._getSheetObject();if(c==null)return;const d=c.engine,u=(d==null?void 0:d.width)||0,h=(d==null?void 0:d.height)||0,m=c.scene,{startX:g,startY:_}=a,{rowTotalHeight:f,columnTotalWidth:v,rowHeaderWidthAndMarginLeft:R,columnHeaderHeightAndMarginTop:M}=r,T=u>v+R?u:v+M,w=h>f+M?h:f+M;this._changeToRow=o,this._changeToColumn=s,this._changeToOffsetX=g,this._changeToOffsetY=_;const E=Math.max(m.scaleX,m.scaleY),y=hi/(E<1?1:E);if(e===0){const O=y;this._rowFreezeHeaderRect=new b.Rect(_d,{fill:this._freezeNormalHeaderColor,width:R,height:y,left:0,top:_-O,zIndex:3});let A=this._freezeNormalHeaderColor;(o===-1||o===0)&&(A=this._freezeNormalMainColor),this._rowFreezeMainRect=new b.Rect(gd,{fill:A,width:T*2,height:y,left:R,top:_-O,zIndex:3}),m.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],qe)}else{const O=y;this._columnFreezeHeaderRect=new b.Rect(fd,{fill:this._freezeNormalHeaderColor,width:y,height:M,left:g-O,top:0,zIndex:3});let A=this._freezeNormalHeaderColor;(s===-1||s===0)&&(A=this._freezeNormalMainColor),this._columnFreezeMainRect=new b.Rect(Sd,{fill:A,width:y,height:w*2,left:g-O,top:M,zIndex:3}),m.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],qe)}this._eventBinding(e)}_eventBinding(e=0){let t=this._rowFreezeHeaderRect,n=this._rowFreezeMainRect;e===1&&(t=this._columnFreezeHeaderRect,n=this._columnFreezeMainRect);const r=this._getSheetObject();if(r==null)return;const{scene:o}=r;this._freezeMoveObservers.push(t==null?void 0:t.onPointerEnterObserver.add(()=>{t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),o.setCursor(b.CURSOR_TYPE.GRAB)})),this._freezeMoveObservers.push(n==null?void 0:n.onPointerEnterObserver.add(()=>{t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),o.setCursor(b.CURSOR_TYPE.GRAB)})),this._freezeLeaveObservers.push(t==null?void 0:t.onPointerLeaveObserver.add(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),o.resetCursor()})),this._freezeLeaveObservers.push(n==null?void 0:n.onPointerLeaveObserver.add(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),o.resetCursor()})),this._freezeDownObservers.push(t==null?void 0:t.onPointerDownObserver.add(s=>{this._freezeDown(s,t,n,e)})),this._freezeDownObservers.push(n==null?void 0:n.onPointerDownObserver.add(s=>{this._freezeDown(s,t,n,e)}))}_getCurrentLastVisibleRow(){var h,m,g,_;const e=this._getSheetObject();if(e==null)return;const t=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(t==null)return;const n=e.scene,r=Math.max(n.scaleX,n.scaleY),o=this._scrollManagerService.getCurrentScroll(),s=(e.engine.height-t.columnHeaderHeight)/r,a=(m=o==null?void 0:o.sheetViewStartRow)!=null?m:0,c=a===0?-((g=o==null?void 0:o.offsetY)!=null?g:0):t.rowHeightAccumulation[a-1]-((_=o==null?void 0:o.offsetY)!=null?_:0);let d=0,u=!1;for(let f=a,v=t.rowHeightAccumulation.length;f<v;f++)if(t.rowHeightAccumulation[f]-c>s){d=f,u=!0;break}return u||(d=t.rowHeightAccumulation.length-1),d}_getActiveViewport(e){var n;const t=(n=this._getSheetObject())==null?void 0:n.scene.getViewports();return t&&t.find(r=>r.isHit(new b.Vector2(e.offsetX,e.offsetY)))||null}_freezeDown(e,t,n,r=0){var h;const o=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(o==null)return;const s=this._getSheetObject();if(s==null)return;const{scene:a}=s;a.setCursor(b.CURSOR_TYPE.GRABBING),a.disableEvent();const c=this._getCurrentLastVisibleRow(),d=c===void 0?Number.POSITIVE_INFINITY:o.rowHeightAccumulation[c];this._activeViewport=null;const u=this._getFreeze();u&&(this._changeToColumn=u.startColumn,this._changeToRow=u.startRow),this._moveObserver=a.onPointerMoveObserver.add(m=>{var T,w,E,y;const g=this._getActiveViewport(m),{startX:_,startY:f,row:v,column:R}=Rt(m.offsetX,m.offsetY,a,o,g||void 0);a.setCursor(b.CURSOR_TYPE.GRABBING);const M=hi/Math.max(a.scaleX,a.scaleY);r===0?((T=t.transformByState({top:Math.min(f,d)-M/2}))==null||T.setProps({fill:this._freezeActiveColor}),(w=n.transformByState({top:Math.min(f,d)-M/2}))==null||w.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=c===void 0?v:Math.min(v,c),this._changeToOffsetY=Math.min(f,d),this._activeViewport=g):((E=t.transformByState({left:_-M/2}))==null||E.setProps({fill:this._freezeActiveColor}),(y=n.transformByState({left:_-M/2}))==null||y.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=R,this._changeToOffsetX=_,this._activeViewport=g)}),this._upObserver=a.onPointerUpObserver.add(()=>{var O,A;a.resetCursor(),a.enableEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:m,columnHeaderHeightAndMarginTop:g}=o;r===0&&(this._changeToRow===0||this._changeToRow===-1)||r===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(t.setProps({fill:this._freezeNormalHeaderColor}),n.setProps({fill:this._freezeNormalMainColor})):(t==null||t.setProps({fill:this._freezeNormalHeaderColor}),n==null||n.setProps({fill:this._freezeNormalHeaderColor}));const _=hi/Math.max(a.scaleX,a.scaleY);r===0?(this._changeToRow===0||this._changeToRow===-1)&&(t.transformByState({top:g-_}),n.transformByState({top:g-_})):(this._changeToColumn===0||this._changeToColumn===-1)&&(t.transformByState({left:m-_}),n.transformByState({left:m-_}));const f=this._scrollManagerService.getCurrentScroll()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:v,sheetViewStartColumn:R}=f;if(R==null||v==null)return;const M=this._currentUniverService.getCurrentUniverSheetInstance(),T=M.getActiveSheet(),w=(O=T.getConfig())==null?void 0:O.freeze;let E=(w==null?void 0:w.xSplit)||0,y=(w==null?void 0:w.ySplit)||0;const x=(A=this._activeViewport)==null?void 0:A.viewPortKey;r===0&&(!x||x===V.VIEW_LEFT_TOP||x===V.VIEW_MAIN_LEFT_TOP||x===V.VIEW_MAIN_TOP||x===V.VIEW_ROW_TOP?y=this._changeToRow-(w.startRow-w.ySplit):y=this._changeToRow-v,y=y<0?0:y),r===1&&(!x||x===V.VIEW_LEFT_TOP||x===V.VIEW_MAIN_LEFT_TOP||x===V.VIEW_MAIN_LEFT||x===V.VIEW_COLUMN_LEFT?E=this._changeToColumn-(w.startColumn-w.xSplit):E=this._changeToColumn-R,E=E<0?0:E),this._commandService.executeCommand(S.SetFrozenCommand.id,{startRow:y===0?-1:this._changeToRow,startColumn:E===0?-1:this._changeToColumn,ySplit:y,xSplit:E,unitId:M.getUnitId(),subUnitId:T.getSheetId()})})}_getViewports(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e,n=t.getViewport(V.VIEW_COLUMN_LEFT),r=t.getViewport(V.VIEW_COLUMN_RIGHT),o=t.getViewport(V.VIEW_ROW_TOP),s=t.getViewport(V.VIEW_ROW_BOTTOM),a=t.getViewport(V.VIEW_LEFT_TOP),c=t.getViewport(V.VIEW_MAIN),d=t.getViewport(V.VIEW_MAIN_LEFT_TOP),u=t.getViewport(V.VIEW_MAIN_LEFT),h=t.getViewport(V.VIEW_MAIN_TOP);if(!(n==null||r==null||o==null||s==null||a==null||c==null||d==null||u==null||h==null))return{viewMain:c,viewMainLeftTop:d,viewMainLeft:u,viewMainTop:h,viewColumnLeft:n,viewColumnRight:r,viewRowTop:o,viewRowBottom:s,viewLeftTop:a}}_bindViewportScroll(){const e=this._getViewports();if(!e)return;const{viewMain:t,viewRowBottom:n,viewColumnRight:r,viewMainLeft:o,viewMainTop:s}=e;this.disposeWithMe(t.onScrollAfterObserver.add(a=>{const{scrollX:c,scrollY:d,actualScrollX:u,actualScrollY:h}=a;n.isActive&&n.updateScroll({scrollY:d,actualScrollY:h}).makeDirty(!0),r.isActive&&r.updateScroll({scrollX:c,actualScrollX:u}).makeDirty(!0),o.isActive&&o.updateScroll({scrollY:d,actualScrollY:h}).makeDirty(!0),s.isActive&&s.updateScroll({scrollX:c,actualScrollX:u}).makeDirty(!0)}))}_updateViewport(e=-1,t=-1,n=0,r=0,o=3){var x;const s=(x=this._sheetSkeletonManagerService.getCurrent())==null?void 0:x.skeleton;if(s==null)return;const{rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:c}=s,d=this._getViewports();if(!d)return;const{viewMain:u,viewMainLeftTop:h,viewMainLeft:m,viewMainTop:g,viewColumnLeft:_,viewColumnRight:f,viewRowTop:v,viewRowBottom:R,viewLeftTop:M}=d;f.resize({left:a,top:0,height:c,right:0}),R.resize({left:0,top:c,bottom:0,width:a}),M.resize({left:0,top:0,width:a,height:c});let T=!0,w=!0;h.enable(),(e===-1||e===0)&&(T=!1),(t===-1||t===0)&&(w=!1);const E=s.getNoMergeCellPositionByIndexWithNoHeader(e-n,t-r),y=s.getNoMergeCellPositionByIndexWithNoHeader(e,t);if(h.disable(),g.disable(),m.disable(),v.disable(),_.disable(),h.resetPadding(),g.resetPadding(),m.resetPadding(),v.resetPadding(),_.resetPadding(),T===!1&&w===!1)u.resize({left:a,top:c,bottom:0,right:0}),u.resetPadding();else if(T===!0&&w===!1){const O=y.startY-E.startY;u.resize({left:a,top:c+O,bottom:0,right:0}),u.setPadding({startY:E.startY,endY:y.startY,startX:0,endX:0}),o&2&&this._commandService.executeCommand(pt.id,{sheetViewStartRow:0,offsetY:0}),g.resize({left:a,top:c,height:O,right:0}),g.updateScroll({actualScrollY:E.startY,x:u.scrollX,actualScrollX:u.actualScrollX}).makeDirty(!0),v.resize({left:0,top:c,width:a,height:O}),v.updateScroll({actualScrollY:E.startY}).makeDirty(!0),R.resize({left:0,top:c+O,bottom:0,width:a}),g.enable(),v.enable()}else if(T===!1&&w===!0){const O=y.startX-E.startX;u.resize({left:a+O,top:c,bottom:0,right:0}),u.setPadding({startX:E.startX,endX:y.startX,startY:0,endY:0}),o&1&&this._commandService.executeCommand(pt.id,{sheetViewStartColumn:0,offsetX:0}),m.resize({left:a,top:c,width:O,bottom:0,right:0}),m.updateScroll({actualScrollX:E.startX,y:u.scrollY,actualScrollY:u.actualScrollY}).makeDirty(!0),_.resize({left:a,top:0,width:O,height:c}),_.updateScroll({actualScrollX:E.startX}).makeDirty(!0),f.resize({left:a+O,top:0,height:c,right:0}),m.enable(),_.enable()}else{const O=y.startX-E.startX,A=y.startY-E.startY;u.resize({left:a+O,top:c+A,bottom:0,right:0}),u.setPadding({startY:E.startY,endY:y.startY,startX:E.startX,endX:y.startX}),o&&this._commandService.executeCommand(pt.id,{...o&1?{sheetViewStartColumn:0,offsetX:0}:null,...o&2?{sheetViewStartRow:0,offsetY:0}:null}),m.resize({left:a,top:c+A,width:O,bottom:0}),m.updateScroll({actualScrollX:E.startX,y:u.scrollY,actualScrollY:u.actualScrollY}).makeDirty(!0),g.resize({left:a+O,top:c,height:A,right:0}),g.updateScroll({actualScrollY:E.startY,x:u.scrollX,actualScrollX:u.actualScrollX}).makeDirty(!0),h.resize({left:a,top:c,width:O,height:A}),h.updateScroll({actualScrollX:E.startX,actualScrollY:E.startY}).makeDirty(!0),v.resize({left:0,top:c,width:a,height:A}),v.updateScroll({actualScrollY:E.startY}).makeDirty(!0),R.resize({left:0,top:c+A,bottom:0,width:a}),_.resize({left:a,top:0,width:O,height:c}),_.updateScroll({actualScrollX:E.startX}).makeDirty(!0),f.resize({left:a+O,top:0,height:c,right:0}),h.enable(),g.enable(),m.enable(),v.enable(),_.enable()}}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{[S.SetWorksheetActiveOperation.id,S.InsertRangeMoveDownCommand.id,S.InsertRangeMoveRightCommand.id].includes((e==null?void 0:e.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const n=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getConfig().freeze,{startRow:r=-1,startColumn:o=-1,ySplit:s=0,xSplit:a=0}=n;this._refreshFreeze(r,o,s,a,0)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(l.toDisposable(this._themeService.currentTheme$.subscribe(e=>{this._clearFreeze(),this._themeChange(e),this._refreshCurrent()})))}_themeChange(e){this._freezeNormalHeaderColor=e.grey400,this._freezeNormalMainColor=new l.ColorKit(e.grey400).setAlpha(pd).toRgbString(),this._freezeActiveColor=e.primaryColor,this._freezeHoverColor=e.grey500}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{const t={redos:[],undos:[]},n=this._getFreeze();if(!n)return t;const r=o=>{const s=this._currentUniverService.getCurrentUniverSheetInstance(),a=s.getUnitId(),d=s.getActiveSheet().getSheetId();this._refreshFreeze(o.startRow,o.startColumn,o.ySplit,o.xSplit,0);const u={...o,unitId:a,subUnitId:d,resetScroll:!1},h=S.SetFrozenMutationFactory(this._injector,u);return{undos:[{id:S.SetFrozenMutation.id,params:h}],redos:[{id:S.SetFrozenMutation.id,params:u}]}};if(e.id===S.MoveColsCommand.id){const o=this._selectionManagerService.getSelections(),{fromRange:{startColumn:s},toRange:{startColumn:a}}=e.params,c=o==null?void 0:o.filter(v=>v.range.rangeType===l.RANGE_TYPE.COLUMN&&v.range.startColumn<=s&&s<=v.range.endColumn);if(!(c!=null&&c.length))return t;const d=c[0].range,u={...d,startColumn:a,endColumn:a+d.endColumn-d.startColumn};if(!n||n.startColumn<=0||d.startColumn>=n.startColumn&&u.startColumn>=n.startColumn||d.startColumn===u.startColumn||d.endColumn<n.startColumn&&u.startColumn<n.startColumn)return t;const h=d.endColumn-d.startColumn+1,m=Math.max(Math.min(n.startColumn,d.endColumn+1)-d.startColumn,0);let g,_;u.startColumn>=n.startColumn?(g=Math.max(n.startColumn-m,1),_=Math.max(n.xSplit-m,1)):(g=n.startColumn+h-m,_=n.xSplit+h-m);const f={...n,startColumn:g,xSplit:_};return r(f)}if(e.id===S.MoveRowsCommand.id){const o=this._selectionManagerService.getSelections(),{fromRange:{startRow:s},toRange:{startRow:a}}=e.params,c=o==null?void 0:o.filter(v=>v.range.rangeType===l.RANGE_TYPE.ROW&&v.range.startRow<=s&&s<=v.range.endRow);if(!(c!=null&&c.length))return t;const d=c[0].range,u={...d,startRow:a,endRow:a+d.endRow-d.startRow};if(!n||n.startRow<=0||d.startRow>=n.startRow&&u.startRow>=n.startRow||d.startRow===u.startRow||d.endRow<n.startRow&&u.startRow<n.startRow)return t;const h=d.endRow-d.startRow+1,m=Math.max(Math.min(n.startRow,d.endRow+1)-d.startRow,0);let g,_;u.startRow>=n.startRow?(g=Math.max(n.startRow-m,1),_=Math.max(n.ySplit-m,1)):(g=n.startRow+h-m,_=n.ySplit+h-m);const f={...n,startRow:g,ySplit:_};return r(f)}if(e.id===S.RemoveColCommand.id||e.id===S.RemoveRowCommand.id){const o=e.params,s=o.range;if(s.rangeType===l.RANGE_TYPE.COLUMN&&s.startColumn<n.startColumn){const a=Math.min(n.startColumn,s.endColumn+1)-s.startColumn,c={...n,startColumn:Math.max(1,n.startColumn-a),xSplit:Math.max(1,n.xSplit-a)};return r(c)}if(o.range.rangeType===l.RANGE_TYPE.ROW&&s.startRow<n.startRow){const a=Math.min(n.startRow,s.endRow+1)-s.startRow,c={...n,startRow:Math.max(1,n.startRow-a),ySplit:Math.max(1,n.ySplit-a)};return r(c)}}return t}}))}_commandExecutedListener(){const e=[S.SetFrozenMutation.id,ze.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=this._lastFreeze,r=this._currentUniverService.getCurrentUniverSheetInstance(),o=r.getActiveSheet(),s=t.params,{unitId:a,subUnitId:c}=s;if(!(a===r.getUnitId()&&c===o.getSheetId()))return;const d=o.getConfig().freeze;if(this._lastFreeze=d,d==null)return;let u=0;const{startRow:h=-1,startColumn:m=-1,ySplit:g=0,xSplit:_=0}=d;(!n||n.startRow!==h||n.ySplit!==g)&&(u|=2),(!n||n.startColumn!==m||n.xSplit!==_)&&(u|=1),s.resetScroll===!1&&(u=0),this._refreshFreeze(h,m,g,_,u)}else if(t.id===S.SetWorksheetRowHeightMutation.id){const n=this._getFreeze();t.params&&n&&t.params.ranges.some(r=>r.startRow<n.startRow)&&this._refreshCurrent()}else if(t.id===S.SetWorksheetColWidthMutation.id){const n=this._getFreeze();t.params&&n&&t.params.ranges.some(r=>r.startColumn<n.startColumn)&&this._refreshCurrent()}else if(t.id===S.SetWorksheetRowAutoHeightMutation.id){const n=t.params,r=this._getFreeze();if(r&&r.startRow>-1&&n.rowsAutoHeightInfo.some(o=>o.row<r.startRow)){const o=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{o.unsubscribe()})})}}else if(t.id===S.SetColHiddenMutation.id||t.id===S.SetColVisibleMutation.id){const n=t.params,r=this._getFreeze(),o=n.ranges;r&&r.startColumn>-1&&o.some(s=>s.startColumn<r.startColumn)&&this._refreshCurrent()}else if(t.id===S.SetRowHiddenMutation.id||t.id===S.SetRowVisibleMutation.id){const n=t.params,r=this._getFreeze(),o=n.ranges;r&&r.startRow>-1&&o.some(s=>s.startRow<r.startRow)&&this._refreshCurrent()}}))}_zoomRefresh(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;t.onTransformChangeObservable.add(n=>{n.type===b.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&this._refreshCurrent()})}_clearObserverEvent(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_clearFreeze(){var n,r,o,s;(n=this._rowFreezeHeaderRect)==null||n.dispose(),(r=this._rowFreezeMainRect)==null||r.dispose(),(o=this._columnFreezeHeaderRect)==null||o.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose();const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;[...this._freezeDownObservers,...this._freezeMoveObservers,...this._freezeLeaveObservers].forEach(a=>{t.onPointerDownObserver.remove(a),t.onPointerMoveObserver.remove(a),t.onPointerLeaveObserver.remove(a)}),t.onPointerEnterObserver.remove(this._moveObserver),t.onPointerMoveObserver.remove(this._upObserver)}_getPositionByIndex(e,t){var c;if(this._getSheetObject()==null)return;const r=(c=this._sheetSkeletonManagerService.getCurrent())==null?void 0:c.skeleton,o=r==null?void 0:r.getNoMergeCellPositionByIndex(e,t);if(r==null)return;if(o!=null&&(!isNaN(o.endX)||!isNaN(o.endY)))return o;const{rowHeaderWidthAndMarginLeft:s,columnHeaderHeightAndMarginTop:a}=r;return{startX:s,endX:s,startY:a,endY:a}}_getFreeze(){var t;const e=(t=this._sheetSkeletonManagerService.getCurrent())==null?void 0:t.skeleton.getWorksheetConfig();if(e!=null)return e.freeze}_getSheetObject(){return Ce(this._currentUniverService,this._renderManagerService)}_refreshFreeze(e,t,n,r,o){var a;const s={startRow:e,startColumn:t,ySplit:n,xSplit:r};this._clearFreeze(),this._createFreeze(0,s),this._createFreeze(1,s),this._updateViewport(e,t,n,r,o),(a=this._getSheetObject())==null||a.spreadsheet.makeForceDirty()}};Tn=md([l.OnLifecycle(l.LifecycleStages.Rendered,Tn),He(0,D.Inject(exports.SheetSkeletonManagerService)),He(1,l.IUniverInstanceService),He(2,l.ICommandService),He(3,b.IRenderManagerService),He(4,_e),He(5,D.Inject(S.SelectionManagerService)),He(6,D.Inject(Je)),He(7,D.Inject(l.ThemeService)),He(8,D.Inject(S.SheetInterceptorService)),He(9,D.Inject(D.Injector))],Tn);var yi=(i=>(i[i.NORMAL=0]="NORMAL",i[i.HIGHLIGHT=1]="HIGHLIGHT",i))(yi||{});const vd="rgba(0, 0, 0, 0.15)",je="rgb(0, 0, 0)",cn="rgb(255, 255, 255, 1)";class Cd extends b.Shape{constructor(t,n){super(t,n);C(this,"_size",12);C(this,"_iconRatio",.4);C(this,"_mode",0);this.setShapeProps(n)}setShapeProps(t){t!=null&&t.size&&(this._size=t.size),t!=null&&t.mode&&(this._mode=t.mode),this.transformByState({width:this._size,height:this._size})}_draw(t){this._mode===1&&b.Rect.drawWith(t,{width:this._size,height:this._size,radius:this._size,fill:vd});const n=this._size*.5*this._iconRatio,r=Math.PI/180*60,o=n*Math.sin(r),s=n*Math.cos(r);b.RegularPolygon.drawWith(t,{pointsGroup:[[{x:-o+this._size/2,y:-s+this._size/2},{x:o+this._size/2,y:-s+this._size/2},{x:this._size/2,y:n+this._size/2}]],fill:je})}}var Id=Object.defineProperty,Rd=Object.getOwnPropertyDescriptor,Md=(i,e,t,n)=>{for(var r=n>1?void 0:n?Rd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Id(e,t,r),r},dt=(i,e)=>(t,n)=>e(t,n,i);const bd="__SpreadsheetHeaderMenuSHAPEControllerShape__",wd="__SpreadsheetHeaderMenuMAINControllerShape__",Td="rgba(0, 0, 0, 0.1)";let En=class extends l.Disposable{constructor(e,t,n,r,o,s){super();C(this,"_hoverRect");C(this,"_hoverMenu");C(this,"_currentColumn",1/0);C(this,"_observers",[]);this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._contextMenuService=r,this._commandService=o,this._selectionManagerService=s,this._initialize()}dispose(){var r,o;(r=this._hoverRect)==null||r.dispose(),(o=this._hoverMenu)==null||o.dispose();const e=this._getSheetObject();if(e==null)return;const{spreadsheetRowHeader:t,spreadsheetColumnHeader:n}=e;this._observers.forEach(s=>{t.onPointerEnterObserver.remove(s),t.onPointerMoveObserver.remove(s),t.onPointerLeaveObserver.remove(s),n.onPointerEnterObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)})}_initialize(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this._hoverRect=new b.Rect(bd,{fill:Td,evented:!1}),this._hoverMenu=new Cd(wd,{zIndex:100,visible:!1}),t.addObjects([this._hoverRect,this._hoverMenu],qe),this._initialHover(0),this._initialHover(1),this._initialHoverMenu()}_initialHover(e=0){const t=this._getSheetObject();if(t==null)return;const{spreadsheetColumnHeader:n,spreadsheetRowHeader:r}=t,o=e===0?r:n;this._observers.push(o==null?void 0:o.onPointerEnterObserver.add(()=>{var s;(s=this._hoverRect)==null||s.show()})),this._observers.push(o==null?void 0:o.onPointerMoveObserver.add(s=>{var v,R,M;const a=(v=this._sheetSkeletonManagerService.getCurrent())==null?void 0:v.skeleton;if(a==null)return;const c=this._getSheetObject();if(c==null)return;const{rowHeaderWidth:d,columnHeaderHeight:u}=a,{startX:h,startY:m,endX:g,endY:_,column:f}=Rt(s.offsetX,s.offsetY,c.scene,a);if(e===0)(R=this._hoverRect)==null||R.transformByState({width:d,height:_-m,left:0,top:m});else{if(this._currentColumn=f,(M=this._hoverRect)==null||M.transformByState({width:g-h,height:u,left:h,top:0}),this._hoverMenu==null)return;if(g-h<u*2){this._hoverMenu.hide();return}const T=u*.8;this._hoverMenu.transformByState({left:g-u,top:u/2-T/2}),this._hoverMenu.setShapeProps({size:T}),this._hoverMenu.show()}})),this._observers.push(o==null?void 0:o.onPointerLeaveObserver.add(()=>{var s,a;(s=this._hoverRect)==null||s.hide(),(a=this._hoverMenu)==null||a.hide()}))}_initialHoverMenu(){this._hoverMenu!=null&&(this._hoverMenu.onPointerEnterObserver.add(()=>{if(this._hoverMenu==null)return;const e=this._getSheetObject();e!=null&&(this._hoverMenu.setProps({mode:yi.HIGHLIGHT,visible:!0}),e.scene.setCursor(b.CURSOR_TYPE.POINTER))}),this._hoverMenu.onPointerLeaveObserver.add(()=>{if(this._hoverMenu==null)return;const e=this._getSheetObject();e!=null&&(this._hoverMenu.setProps({mode:yi.NORMAL,visible:!1}),e.scene.resetCursor())}),this._hoverMenu.onPointerDownObserver.add(e=>{if(!this._getSheetObject())return;const n=this._currentColumn,r=this._selectionManagerService.getSelectionRanges();if(!!!(r!=null&&r.filter(s=>s.rangeType===l.RANGE_TYPE.COLUMN).find(s=>{const{startColumn:a,endColumn:c}=s;return n>=a&&n<=c}))){const s=this._getSelectionOnColumn(n);this._commandService.syncExecuteCommand(S.SetSelectionsOperation.id,s)}e.stopPropagation(),e.preventDefault(),this._contextMenuService.triggerContextMenu(e,ce.COL_HEADER_CONTEXT_MENU)}))}_getSheetObject(){return Ce(this._currentUniverService,this._renderManagerService)}_getSelectionOnColumn(e){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet();return{unitId:t.getUnitId(),subUnitId:n.getSheetId(),pluginName:S.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:{startRow:0,startColumn:e,endRow:n.getRowCount()-1,endColumn:e,rangeType:l.RANGE_TYPE.COLUMN},primary:{startRow:0,startColumn:e,endRow:0,endColumn:e,actualRow:0,actualColumn:e,isMerged:!1,isMergedMainCell:!1},style:null}]}}};En=Md([l.OnLifecycle(l.LifecycleStages.Rendered,En),dt(0,D.Inject(exports.SheetSkeletonManagerService)),dt(1,l.IUniverInstanceService),dt(2,b.IRenderManagerService),dt(3,I.IContextMenuService),dt(4,l.ICommandService),dt(5,D.Inject(S.SelectionManagerService))],En);var Ed=Object.defineProperty,yd=Object.getOwnPropertyDescriptor,Od=(i,e,t,n)=>{for(var r=n>1?void 0:n?yd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ed(e,t,r),r},ut=(i,e)=>(t,n)=>e(t,n,i);const xd="__SpreadsheetHeaderMoveControllerBackground__",Ad="__SpreadsheetHeaderMoveControllerShapeLine__",Dd="rgba(0, 0, 0, 0.1)",Nd="rgb(119, 119, 119)",Hd=4;let yn=class extends l.Disposable{constructor(e,t,n,r,o,s){super();C(this,"_startOffsetX",-1/0);C(this,"_startOffsetY",-1/0);C(this,"_moveHelperBackgroundShape");C(this,"_moveHelperLineShape");C(this,"_sheetObject");C(this,"_rowOrColumnDownObservers",[]);C(this,"_rowOrColumnMoveObservers",[]);C(this,"_rowOrColumnLeaveObservers",[]);C(this,"_moveObserver");C(this,"_upObserver");C(this,"_scrollTimer");C(this,"_changeFromColumn",-1);C(this,"_changeFromRow",-1);C(this,"_changeToColumn",-1);C(this,"_changeToRow",-1);this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._commandService=r,this._selectionRenderService=o,this._selectionManagerService=s,this._initialize()}dispose(){var o,s;(o=this._moveHelperBackgroundShape)==null||o.dispose(),(s=this._moveHelperLineShape)==null||s.dispose();const e=this._getSheetObject();if(e==null)return;const{spreadsheetRowHeader:t,spreadsheetColumnHeader:n,scene:r}=e;[...this._rowOrColumnDownObservers,...this._rowOrColumnMoveObservers,...this._rowOrColumnLeaveObservers].forEach(a=>{t.onPointerDownObserver.remove(a),n.onPointerDownObserver.remove(a)}),r.onPointerMoveObserver.remove(this._moveObserver),r.onPointerUpObserver.remove(this._upObserver),this._scrollTimer.dispose()}_initialize(){const e=this._getSheetObject();e!=null&&(this._sheetObject=e,this._initialRowOrColumn(0),this._initialRowOrColumn(1))}_initialRowOrColumn(e=0){const{spreadsheetColumnHeader:t,spreadsheetRowHeader:n,scene:r}=this._sheetObject,o=e===0?n:t;this._rowOrColumnMoveObservers.push(o==null?void 0:o.onPointerMoveObserver.add(s=>{var h;const a=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(a==null)return;const{row:c,column:d}=Rt(s.offsetX,s.offsetY,r,a);if(this._checkInHeaderRange(e===0?c:d,e)===!1){r.resetCursor(),this._selectionRenderService.enableSelection();return}r.setCursor(b.CURSOR_TYPE.GRAB),this._selectionRenderService.disableSelection()})),this._rowOrColumnLeaveObservers.push(o==null?void 0:o.onPointerLeaveObserver.add(()=>{var s,a;(s=this._moveHelperBackgroundShape)==null||s.hide(),(a=this._moveHelperLineShape)==null||a.hide(),r.resetCursor(),this._selectionRenderService.enableSelection()})),this._rowOrColumnDownObservers.push(o==null?void 0:o.onPointerDownObserver.add(s=>{var E;const a=(E=this._sheetSkeletonManagerService.getCurrent())==null?void 0:E.skeleton;if(a==null)return;const{offsetX:c,offsetY:d}=s,u=r.getRelativeCoord(b.Vector2.FromArray([c,d])),{x:h,y:m}=u;this._startOffsetX=h,this._startOffsetY=m;const{row:g,column:_}=Rt(s.offsetX,s.offsetY,r,a);let f;e===0?(this._changeFromRow=g,f=b.ScrollTimerType.Y):(this._changeFromColumn=_,f=b.ScrollTimerType.X);const v=this._checkInHeaderRange(e===0?g:_,e);if(v===!1)return;const R=r.getScrollXYByRelativeCoords(b.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),r.setCursor(b.CURSOR_TYPE.GRABBING),r.disableEvent();let M=!1,T;const w=()=>{if(M)return;T=b.ScrollTimer.create(r,f);const y=r.getViewport(V.VIEW_MAIN);T.startScroll(h,m,y),this._scrollTimer=T,M=!0};this._moveObserver=r.onPointerMoveObserver.add(y=>{w();const{offsetX:x,offsetY:O}=y,{x:A,y:k}=r.getRelativeCoord(b.Vector2.FromArray([x,O]));r.setCursor(b.CURSOR_TYPE.GRABBING),this._rowColumnMoving(A,k,v,R,e),T.scrolling(A,k,()=>{this._rowColumnMoving(A,k,v,R,e)})}),this._upObserver=r.onPointerUpObserver.add(()=>{var x,O,A;this._disposeBackgroundAndLine(),r.resetCursor(),r.enableEvent(),this._clearObserverEvent(),(x=this._scrollTimer)==null||x.dispose();const y=this._selectionManagerService.getSelections();if(e===0){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const H=(O=((y==null?void 0:y.filter(B=>B.range.rangeType===l.RANGE_TYPE.ROW&&B.range.startRow<=this._changeFromRow&&this._changeFromRow<=B.range.endRow))||[])[0])==null?void 0:O.range;H&&this._commandService.executeCommand(S.MoveRowsCommand.id,{fromRange:H,toRange:{...H,startRow:this._changeToRow,endRow:this._changeToRow+H.endRow-H.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const H=(A=((y==null?void 0:y.filter(B=>B.range.rangeType===l.RANGE_TYPE.COLUMN&&B.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=B.range.endColumn))||[])[0])==null?void 0:A.range;H&&this._commandService.executeCommand(S.MoveColsCommand.id,{fromRange:H,toRange:{...H,startColumn:this._changeToColumn,endColumn:this._changeToColumn+H.endColumn-H.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})}))}_rowColumnMoving(e,t,n,r,o){var Q,re,Y,L,U,X,q;const{scene:s}=this._sheetObject,a=(Q=this._sheetSkeletonManagerService.getCurrent())==null?void 0:Q.skeleton;if(a==null)return;const{rowHeaderWidth:c,columnHeaderHeight:d,rowTotalHeight:u,columnTotalWidth:h}=a,m=s.getScrollXY(s.getViewport(V.VIEW_MAIN)),{scaleX:g,scaleY:_}=s.getAncestorScale(),f=a.getCellPositionByOffset(e,t,g,_,m),{row:v,column:R}=f,M=a.getNoMergeCellPositionByIndex(v,R),{startX:T,startY:w,endX:E,endY:y}=M,x=this._selectionRenderService.convertRangeDataToSelection(n.range);if(x==null)return;const O=Math.max(g,g),{startX:A,endX:k,startY:H,endY:B,startRow:F,startColumn:j,endRow:z,endColumn:ee}=x;o===0?(re=this._moveHelperBackgroundShape)==null||re.transformByState({height:B-H,width:h+c,left:0,top:H+(t-this._startOffsetY)/O+m.y-r.y}):(Y=this._moveHelperBackgroundShape)==null||Y.transformByState({height:u+d,width:k-A,left:A+(e-this._startOffsetX)/O+m.x-r.x,top:0}),(L=this._moveHelperBackgroundShape)==null||L.show();const W=Hd/O;if(o===0){let oe=0;if(v<=F)oe=w-W/2,this._changeToRow=v;else if(v>z)oe=y-W/2,this._changeToRow=v+1;else return;(U=this._moveHelperLineShape)==null||U.transformByState({height:W,width:h,left:c,top:oe})}else{let oe=0;if(R<=j)oe=T-W/2,this._changeToColumn=R;else if(R>ee)oe=E-W/2,this._changeToColumn=R+1;else return;(X=this._moveHelperLineShape)==null||X.transformByState({height:u,width:W,left:oe,top:d})}(q=this._moveHelperLineShape)==null||q.show()}_checkInHeaderRange(e,t=0){var a;const n=this._selectionManagerService.getSelections();if(((a=this._selectionManagerService.getCurrent())==null?void 0:a.pluginName)!==S.NORMAL_SELECTION_PLUGIN_NAME)return!1;const o=n==null?void 0:n.find(c=>{const d=c.range,{startRow:u,endRow:h,startColumn:m,endColumn:g,rangeType:_}=d;return t===1?e>=m&&e<=g&&l.RANGE_TYPE.COLUMN===_:e>=u&&e<=h&&l.RANGE_TYPE.ROW===_}),s=o==null?void 0:o.range;return o==null||s==null||s.rangeType===l.RANGE_TYPE.ALL||s.rangeType===l.RANGE_TYPE.NORMAL||s.rangeType===l.RANGE_TYPE.ROW&&t!==0||s.rangeType===l.RANGE_TYPE.COLUMN&&t!==1?!1:o}_clearObserverEvent(){const{scene:e}=this._sheetObject;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_newBackgroundAndLine(){const{scene:e}=this._sheetObject;this._moveHelperBackgroundShape=new b.Rect(xd,{fill:Dd,evented:!1,zIndex:100}),this._moveHelperLineShape=new b.Rect(Ad,{fill:Nd,evented:!1,zIndex:100}),e.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],qe)}_disposeBackgroundAndLine(){var e,t;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose()}_getSheetObject(){return Ce(this._currentUniverService,this._renderManagerService)}};yn=Od([l.OnLifecycle(l.LifecycleStages.Rendered,yn),ut(0,D.Inject(exports.SheetSkeletonManagerService)),ut(1,l.IUniverInstanceService),ut(2,b.IRenderManagerService),ut(3,l.ICommandService),ut(4,_e),ut(5,D.Inject(S.SelectionManagerService))],yn);var Oi=(i=>(i[i.VERTICAL=0]="VERTICAL",i[i.HORIZONTAL=1]="HORIZONTAL",i))(Oi||{});const Pd="rgba(120, 120, 120, 0.01)",mi="rgb(68, 71, 70)",Wt=12,xi=4;class Ar extends b.Shape{constructor(t,n){super(t,n);C(this,"_size",Wt);C(this,"_color",mi);C(this,"_mode",0);this.setShapeProps(n)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(t){let{width:n,height:r}=this,o=0,s=0;const a=this.getScene(),{scaleX:c,scaleY:d}=a.getAncestorScale(),u=Math.max(c,d),h=Wt/u,m=xi/u;this.mode===0?(n=m,o=h-m):(r=m,s=h-m),b.Rect.drawWith(t,{width:this.width,height:this.height,left:0,top:0,fill:Pd}),b.Rect.drawWith(t,{width:n,height:r,fill:mi,radius:m}),t.save(),t.transform(1,0,0,1,o,s),b.Rect.drawWith(t,{width:n,height:r,fill:mi,radius:m}),t.restore()}setShapeProps(t){return t!=null&&t.size&&(this._size=t.size),t!=null&&t.mode&&(this._mode=t.mode),t!=null&&t.color&&(this._color=t.color),this.mode===0?this.transformByState({width:Wt,height:this.size}):this.transformByState({width:this.size,height:Wt}),this}}var Ld=Object.defineProperty,Ud=Object.getOwnPropertyDescriptor,kd=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ud(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ld(e,t,r),r},Bt=(i,e)=>(t,n)=>e(t,n,i);const Vd="__SpreadsheetHeaderResizeControllerShapeRow__",Bd="__SpreadsheetHeaderResizeControllerShapeColumn__",Dr="__SpreadsheetHeaderResizeControllerShapeHelper__",Nr="rgb(199, 199, 199)",Fd=2;let On=class extends l.Disposable{constructor(e,t,n,r,o){super();C(this,"_currentRow",0);C(this,"_currentColumn",0);C(this,"_rowResizeRect");C(this,"_columnResizeRect");C(this,"_observers",[]);C(this,"_moveObserver");C(this,"_upObserver");C(this,"_resizeHelperShape");C(this,"_startOffsetX",1/0);C(this,"_startOffsetY",1/0);this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._commandService=n,this._renderManagerService=r,this._editorBridgeService=o,this._initialize()}dispose(){var r,o;(r=this._rowResizeRect)==null||r.dispose(),this._rowResizeRect=null,(o=this._columnResizeRect)==null||o.dispose(),this._columnResizeRect=null;const e=this._getSheetObject();if(e==null)return;const{spreadsheetRowHeader:t,spreadsheetColumnHeader:n}=e;this._observers.forEach(s=>{t.onPointerMoveObserver.remove(s),t.onPointerLeaveObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)}),this._observers=[]}_initialize(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this._rowResizeRect=new Ar(Vd,{visible:!1,mode:Oi.HORIZONTAL,zIndex:100}),this._columnResizeRect=new Ar(Bd,{visible:!1,mode:Oi.VERTICAL,zIndex:100}),t.addObjects([this._rowResizeRect,this._columnResizeRect],qe),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(e=0){const t=this._getSheetObject();if(t==null)return;const{spreadsheetRowHeader:n,spreadsheetColumnHeader:r,scene:o}=t,s=e===0?n:r;this._observers.push(s==null?void 0:s.onPointerMoveObserver.add((a,c)=>{var x;const d=(x=this._sheetSkeletonManagerService.getCurrent())==null?void 0:x.skeleton;if(d==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:u,columnHeaderHeight:h}=d,{startX:m,startY:g,endX:_,endY:f,row:v,column:R}=Rt(a.offsetX,a.offsetY,o,d),M=mn(a.offsetX,a.offsetY,o),{scaleX:T,scaleY:w}=o.getAncestorScale(),E=Math.max(T,w),y=Wt/E;if(e===0){let O=g-y/2;if(M.y<=g+y/2&&M.y>=g)this._currentRow=v-1;else if(M.y>=f-y/2&&M.y<=f)this._currentRow=v,O=f-y/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;const A=u/3;this._rowResizeRect.transformByState({left:u/2-A/2,top:O}),this._rowResizeRect.setShapeProps({size:A}),this._rowResizeRect.show()}else{let O=m-y/2;if(M.x<=m+y/2&&M.x>=m)this._currentColumn=R-1;else if(M.x>=_-y/2&&M.x<=_)this._currentColumn=R,O=_-y/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;const A=h*.7;this._columnResizeRect.transformByState({left:O,top:h/2-A/2}),this._columnResizeRect.setShapeProps({size:A}),this._columnResizeRect.show()}})),this._observers.push(s==null?void 0:s.onPointerLeaveObserver.add((a,c)=>{var d,u;(d=this._rowResizeRect)==null||d.hide(),(u=this._columnResizeRect)==null||u.hide()}))}_initialHoverResize(e=0){const t=this._getSheetObject();if(t==null)return;const{scene:n}=t,r=e===0?this._rowResizeRect:this._columnResizeRect;if(r==null)return;const o=n.getEngine(),s=(o==null?void 0:o.width)||0,a=(o==null?void 0:o.height)||0;this.disposeWithMe(l.toDisposable(r.onPointerEnterObserver.add(()=>{r!=null&&(r.show(),n.setCursor(e===0?b.CURSOR_TYPE.ROW_RESIZE:b.CURSOR_TYPE.COLUMN_RESIZE))}))),this.disposeWithMe(l.toDisposable(r.onPointerLeaveObserver.add(()=>{r!=null&&(r.hide(),n.resetCursor())}))),this.disposeWithMe(l.toDisposable(r.onPointerDownObserver.add((c,d)=>{var re,Y,L,U,X,q,oe;const u=(re=this._sheetSkeletonManagerService.getCurrent())==null?void 0:re.skeleton;if(u==null)return;const h=this._getSheetObject();if(h==null)return;const{scene:m}=h,g=m.getViewport(V.VIEW_MAIN),_=(((L=(Y=g==null?void 0:g.getScrollBar())==null?void 0:Y.horizonBarRect)==null?void 0:L.height)||0)+10,f=(((X=(U=g==null?void 0:g.getScrollBar())==null?void 0:U.verticalBarRect)==null?void 0:X.width)||0)+10,v=mn(c.offsetX,c.offsetY,m),{scaleX:R,scaleY:M}=m.getAncestorScale();this._startOffsetX=v.x,this._startOffsetY=v.y;const T=u.getOffsetByPositionX(this._currentColumn),w=u.getOffsetByPositionY(this._currentRow),E=u.getNoMergeCellPositionByIndex(this._currentRow,this._currentColumn);let y=!1,x=0,O=0;const{columnTotalWidth:A,rowHeaderWidth:k,rowTotalHeight:H,columnHeaderHeight:B}=u,F=s>A+k?s:A+k,j=a>H+B?a:H+B,z=Math.max(R,M),ee=xi/z;e===0?this._resizeHelperShape=new b.Rect(Dr,{width:F,height:ee,fill:Nr,left:0,top:w-ee/2}):this._resizeHelperShape=new b.Rect(Dr,{width:ee,height:j,fill:Nr,left:T-ee/2,top:0});const W=((q=this._columnResizeRect)==null?void 0:q.left)||0,Q=((oe=this._rowResizeRect)==null?void 0:oe.top)||0;m.addObject(this._resizeHelperShape,qe),m.disableEvent(),this._editorBridgeService.changeVisible({visible:!1,eventType:b.DeviceInputEventType.PointerDown}),this._moveObserver=m.onPointerMoveObserver.add($=>{var Ve,ve,At,Dt,Nt,Ht;const Z=m.getRelativeCoord(b.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),G=m.getScrollXYByRelativeCoords(Z,g),le=mn($.offsetX,$.offsetY,m),{x:se,y:me}=le,{scaleX:ke,scaleY:pe}=m.getAncestorScale(),ue=Math.max(ke,pe),ae=xi/ue;x=se-this._startOffsetX-ae/2,O=me-this._startOffsetY-ae/2,Math.abs(e===0?O:x)>=Fd&&(y=!0),e===0?(O>a-_+G.y-E.startY&&(O=a-_+G.y-E.startY),O<-(E.endY-E.startY)+2&&(O=-(E.endY-E.startY)+2),y&&((Ve=this._resizeHelperShape)==null||Ve.transformByState({top:w+O}),(ve=this._rowResizeRect)==null||ve.transformByState({top:Q+O+ae/2}),(At=this._rowResizeRect)==null||At.show(),m.setCursor(b.CURSOR_TYPE.ROW_RESIZE))):(x>s-f+G.x-E.startX&&(x=s-f+G.x-E.startX),x<-(E.endX-E.startX)+2&&(x=-(E.endX-E.startX)+2),y&&((Dt=this._resizeHelperShape)==null||Dt.transformByState({left:T+x}),(Nt=this._columnResizeRect)==null||Nt.transformByState({left:W+x+ae/2}),(Ht=this._columnResizeRect)==null||Ht.show(),m.setCursor(b.CURSOR_TYPE.COLUMN_RESIZE)))}),this._upObserver=m.onPointerUpObserver.add($=>{var le,se,me;const Z=Ce(this._currentUniverService,this._renderManagerService);if(Z==null)return;this._clearObserverEvent(),(le=this._resizeHelperShape)==null||le.dispose(),this._resizeHelperShape=null;const{scene:G}=Z;G.enableEvent(),y&&(G.resetCursor(),(se=this._rowResizeRect)==null||se.hide(),(me=this._columnResizeRect)==null||me.hide(),e===0?this._commandService.executeCommand(S.DeltaRowHeightCommand.id,{deltaY:O,anchorRow:this._currentRow}):this._commandService.executeCommand(S.DeltaColumnWidthCommand.id,{deltaX:x,anchorCol:this._currentColumn}))})}))),this.disposeWithMe(l.toDisposable(r.onDblclickObserver.add(()=>{var c;if(e===0){const d=this._getSheetObject();if(d==null)return;const{scene:u}=d;u.resetCursor(),this._commandService.executeCommand(S.SetWorksheetRowIsAutoHeightCommand.id,{anchorRow:this._currentRow}),(c=this._rowResizeRect)==null||c.hide()}})))}_clearObserverEvent(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_getSheetObject(){return Ce(this._currentUniverService,this._renderManagerService)}};On=kd([l.OnLifecycle(l.LifecycleStages.Rendered,On),Bt(0,D.Inject(exports.SheetSkeletonManagerService)),Bt(1,l.IUniverInstanceService),Bt(2,l.ICommandService),Bt(3,b.IRenderManagerService),Bt(4,Te)],On);var Ai=(i=>(i[i.ROW=0]="ROW",i[i.COLUMN=1]="COLUMN",i))(Ai||{});const jt=12,Wd=.4;class Hr extends b.Shape{constructor(t,n,r){super(t,n);C(this,"_size",jt);C(this,"_iconRatio",Wd);C(this,"_hovered",!0);C(this,"_hasPrevious",!0);C(this,"_hasNext",!0);C(this,"_unhideType");n&&this.setShapeProps(n),this.onPointerEnterObserver.add(()=>this.setShapeProps({hovered:!0})),this.onPointerLeaveObserver.add(()=>this.setShapeProps({hovered:!1})),this.onPointerDownObserver.add(()=>r==null?void 0:r())}setShapeProps(t){t.type!==void 0&&(this._unhideType=t.type),t.hovered!==void 0&&(this._hovered=t.hovered),t.hasPrevious!==void 0&&(this._hasPrevious=t.hasPrevious),t.hasNext!==void 0&&(this._hasNext=t.hasNext),this.transformByState({width:this._size*(this._unhideType===1?2:1),height:this._size*(this._unhideType===0?2:1)})}_draw(t){this._unhideType===0?this._drawOnRow(t):this._drawOnCol(t)}_drawOnRow(t){this._hovered&&(!this._hasNext||!this._hasPrevious?b.Rect.drawWith(t,{width:this._size,height:this._size,stroke:je,fill:cn}):b.Rect.drawWith(t,{width:this._size,height:2*this._size,stroke:je,fill:cn}));const n=this._size*.5*this._iconRatio,r=Math.PI/3,o=n*Math.cos(r),s=n*Math.sin(r);if(this._hasPrevious&&b.RegularPolygon.drawWith(t,{pointsGroup:[[{x:this._size/2,y:this._size/2-s},{x:this._size/2-s,y:this._size/2+o},{x:this._size/2+s,y:this._size/2+o}]],fill:je}),this._hasNext){const a=this._hasPrevious?3:1;b.RegularPolygon.drawWith(t,{pointsGroup:[[{x:this._size/2,y:this._size*a/2+s},{x:this._size/2-s,y:this._size*a/2-o},{x:this._size/2+s,y:this._size*a/2-o}]],fill:je})}}_drawOnCol(t){this._hovered&&(!this._hasNext||!this._hasPrevious?b.Rect.drawWith(t,{width:this._size,height:this._size,stroke:je,fill:cn}):b.Rect.drawWith(t,{width:2*this._size,height:this._size,stroke:je,fill:cn}));const n=this._size*.5*this._iconRatio,r=Math.PI/3,o=n*Math.cos(r),s=n*Math.sin(r);if(this._hasPrevious&&b.RegularPolygon.drawWith(t,{pointsGroup:[[{x:-o+this._size/2,y:this._size/2},{x:this._size/2+s,y:this._size/2-s},{x:this._size/2+s,y:this._size/2+s}]],fill:je}),this._hasNext){const a=this._hasPrevious?3:1;b.RegularPolygon.drawWith(t,{pointsGroup:[[{x:o+this._size*a/2,y:this._size/2},{x:-s+this._size*a/2,y:this._size/2-s},{x:-s+this._size*a/2,y:this._size/2+s}]],fill:je})}}}var jd=Object.defineProperty,$d=Object.getOwnPropertyDescriptor,zd=(i,e,t,n)=>{for(var r=n>1?void 0:n?$d(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&jd(e,t,r),r},dn=(i,e)=>(t,n)=>e(t,n,i);const Pr="__SpreadsheetHeaderUnhideSHAPEControllerShape__",Xd=[S.SetRowHiddenMutation.id,S.SetRowVisibleMutation.id,S.SetColHiddenMutation.id,S.SetColVisibleMutation.id];let xn=class extends l.RxDisposable{constructor(e,t,n,r){super();C(this,"_shapes",new Map);this._sheetSkeletonManagerService=e,this._cmdSrv=t,this._univerInstanceService=n,this._rendererManagerService=r,this._init()}dispose(){super.dispose()}_init(){if(!this._getSheetObject())return;const t=this._univerInstanceService.getCurrentUniverSheetInstance(),n=t.getActiveSheet();n&&this._initForWorksheet(t,n),this._sheetSkeletonManagerService.currentSkeleton$.pipe(N.takeUntil(this.dispose$),N.startWith(void 0),N.pairwise()).subscribe(([r,o])=>{if(o){const s=this._univerInstanceService.getUniverSheetInstance(o.unitId),a=s.getSheetBySheetId(o.sheetId);this._updateWorksheet(s,a,r==null?void 0:r.sheetId)}}),this.disposeWithMe(this._cmdSrv.onCommandExecuted(r=>{if(!Xd.includes(r.id)||!r.params||!r.params.unitId||!r.params.subUnitId)return;const o=this._univerInstanceService.getUniverSheetInstance(r.params.unitId),s=o==null?void 0:o.getSheetBySheetId(r.params.subUnitId);s&&this._updateWorksheet(o,s,s.getSheetId())}))}_initForWorksheet(e,t){var m;const n=(m=this._sheetSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(!n)return;const r=t.getHiddenRows(),o=t.getHiddenCols(),s=this._getSheetObject();if(!s)return;const{scene:a}=s,c=t.getRowCount(),d=r.map(g=>{const{startRow:_,endRow:f}=g,v=Ei(_,0,a,n),R=_!==0,M=f!==c-1;return new Hr(Pr,{type:Ai.ROW,hovered:!1,hasPrevious:R,hasNext:M,top:v.startY-(R?jt:0),left:v.startX-jt},()=>this._cmdSrv.executeCommand(S.SetSpecificRowsVisibleCommand.id,{unitId:e.getUnitId(),subUnitId:t.getSheetId(),ranges:[g]}))}),u=t.getColumnCount(),h=o.map(g=>{const{startColumn:_,endColumn:f}=g,v=Ei(0,_,a,n),R=_!==0,M=f!==u-1;return new Hr(Pr,{type:Ai.COLUMN,hovered:!1,hasPrevious:R,hasNext:M,left:v.startX-(R?jt:0),top:20-jt},()=>this._cmdSrv.executeCommand(S.SetSpecificColsVisibleCommand.id,{unitId:e.getUnitId(),subUnitId:t.getSheetId(),ranges:[g]}))});a.addObjects(h,ur),a.addObjects(d,ur),this._shapes.set(l.getWorksheetUID(e,t),{cols:h,rows:d})}_updateWorksheet(e,t,n){if(n){const r=this._shapes.get(`${e.getUnitId()}|${n}`);r==null||r.cols.forEach(o=>o.dispose()),r==null||r.rows.forEach(o=>o.dispose())}this._initForWorksheet(e,t)}_getSheetObject(){return Ce(this._univerInstanceService,this._rendererManagerService)}};xn=zd([l.OnLifecycle(l.LifecycleStages.Rendered,xn),dn(0,D.Inject(exports.SheetSkeletonManagerService)),dn(1,l.ICommandService),dn(2,l.IUniverInstanceService),dn(3,b.IRenderManagerService)],xn);var Yd=Object.defineProperty,Zd=Object.getOwnPropertyDescriptor,Gd=(i,e,t,n)=>{for(var r=n>1?void 0:n?Zd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Yd(e,t,r),r},gi=(i,e)=>(t,n)=>e(t,n,i);let An=class extends l.Disposable{constructor(i,e,t){super(),this._markSelectionService=i,this._commandService=e,this._sheetSkeletonManagerService=t,this._initListeners()}_initListeners(){this._addRemoveListener(),this._addRefreshListener()}_addRemoveListener(){const i=[Pe.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{i.includes(e.id)?this._markSelectionService.removeAllShapes():this._markSelectionService.getShapeMap().forEach((n,r)=>{n.exits.includes(e.id)&&this._markSelectionService.removeShape(r)})}))}_addRefreshListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{i&&this._markSelectionService.refreshShapes()})))}};An=Gd([l.OnLifecycle(l.LifecycleStages.Steady,An),gi(0,D.Inject(qt)),gi(1,l.ICommandService),gi(2,D.Inject(exports.SheetSkeletonManagerService))],An);var Kd=Object.defineProperty,qd=Object.getOwnPropertyDescriptor,Jd=(i,e,t,n)=>{for(var r=n>1?void 0:n?qd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Kd(e,t,r),r},_i=(i,e)=>(t,n)=>e(t,n,i);let Dn=class extends l.Disposable{constructor(e,t,n){super();C(this,"_initialize",()=>{const e=new l.DisposableCollection;this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(()=>{e.dispose();const t=this._selectionManagerService.getCurrent();if((t==null?void 0:t.pluginName)!==S.NORMAL_SELECTION_PLUGIN_NAME)return;this._selectionRenderService.getCurrentControls().forEach(r=>{e.add(l.toDisposable(r.selectionMoved$.subscribe(o=>{if(!o)return;const s=r.model.getRange(),a={startRow:s.startRow,startColumn:s.startColumn,endRow:s.endRow,endColumn:s.endColumn,rangeType:s.rangeType},c={startRow:o.startRow,startColumn:o.startColumn,endRow:o.endRow,endColumn:o.endColumn,rangeType:s.rangeType};if(a.startRow===c.startRow&&a.startColumn===c.startColumn||c.startRow<0||c.startColumn<0)return;const d={fromRange:a,toRange:c};this._commandService.executeCommand(S.MoveRangeCommand.id,d)})))})})))});this._selectionRenderService=e,this._selectionManagerService=t,this._commandService=n,this._initialize()}};Dn=Jd([l.OnLifecycle(l.LifecycleStages.Steady,Dn),_i(0,D.Inject(_e)),_i(1,D.Inject(S.SelectionManagerService)),_i(2,D.Inject(l.ICommandService))],Dn);var Qd=Object.defineProperty,eu=Object.getOwnPropertyDescriptor,tu=(i,e,t,n)=>{for(var r=n>1?void 0:n?eu(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Qd(e,t,r),r},ht=(i,e)=>(t,n)=>e(t,n,i);let vt=class extends l.Disposable{constructor(i,e,t,n,r,o){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._selectionManagerService=r,this._scrollManagerService=o,this._initialize()}scrollToVisible(i=!0){var B,F,j,z;let e,t;const n=this._selectionManagerService.getLast();if(n==null)return;const{startRow:r,startColumn:o,actualRow:s,actualColumn:a}=n.primary,c=i?s:r,d=i?a:o,{rowHeightAccumulation:u,columnWidthAccumulation:h}=(F=(B=this._sheetSkeletonManagerService.getCurrent())==null?void 0:B.skeleton)!=null?F:{};if(u==null||h==null)return;const m=(j=this._getSheetObject())==null?void 0:j.scene;if(m==null)return;const g=m.getViewport(V.VIEW_MAIN);if(g==null||this._getSheetObject()==null)return;const f=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet(),{startColumn:v,startRow:R,ySplit:M,xSplit:T}=f.getFreeze(),w=g.getBounding(),E=(z=this._sheetSkeletonManagerService.getCurrent())==null?void 0:z.skeleton;if(E==null)return;const{startRow:y,startColumn:x,endRow:O,endColumn:A}=E.getRowColumnSegment(w);if(c>=R&&d>=v-T&&(c<=y&&(e=c),c>=O)){const ee=u[c]-g.height;for(let W=y;W<=c;W++)if(u[W]>=ee){e=W+1;break}}if(d>=v&&c>=R-M&&(d<=x&&(t=d),d>=A)){const ee=h[d]-g.width;for(let W=x;W<=d;W++)if(h[W]>=ee){t=W+1;break}}if(e===void 0&&t===void 0)return;const{offsetX:k,offsetY:H}=this._scrollManagerService.getCurrentScroll()||{};this._commandService.executeCommand(pt.id,{sheetViewStartRow:e,sheetViewStartColumn:t,offsetX:t===void 0?k:0,offsetY:e===void 0?H:0})}dispose(){super.dispose()}_initialize(){this._scrollEventBinding(),this._scrollSubscribeBinding(),this._skeletonListener()}_getFreeze(){var e;const i=(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig();if(i!=null)return i.freeze}_scrollEventBinding(){var t;const i=(t=this._getSheetObject())==null?void 0:t.scene;if(i==null)return;const e=i.getViewport(V.VIEW_MAIN);this.disposeWithMe(l.toDisposable(e==null?void 0:e.onScrollAfterObserver.add(n=>{var m;const r=(m=this._sheetSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(r==null||n.isTrigger===!1)return;const o=this._getSheetObject();if(r==null||o==null)return;const{actualScrollX:s=0,actualScrollY:a=0}=n,{row:c,column:d,rowOffset:u,columnOffset:h}=r.getDecomposedOffset(s,a);this._scrollManagerService.addOrReplaceNoRefresh({sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:h,offsetY:u})}))),this.disposeWithMe(l.toDisposable(e==null?void 0:e.onScrollByBarObserver.add(n=>{var g;const r=(g=this._sheetSkeletonManagerService.getCurrent())==null?void 0:g.skeleton;if(r==null||n.isTrigger===!1)return;const o=this._getSheetObject();if(r==null||o==null)return;const{actualScrollX:s=0,actualScrollY:a=0}=n,c=this._getFreeze(),{row:d,column:u,rowOffset:h,columnOffset:m}=r.getDecomposedOffset(s,a);this._commandService.executeCommand(pt.id,{sheetViewStartRow:d+((c==null?void 0:c.ySplit)||0),sheetViewStartColumn:u+((c==null?void 0:c.xSplit)||0),offsetX:m,offsetY:h})})))}_scrollSubscribeBinding(){this.disposeWithMe(l.toDisposable(this._scrollManagerService.scrollInfo$.subscribe(i=>{var _;const e=(_=this._sheetSkeletonManagerService.getCurrent())==null?void 0:_.skeleton,t=this._getSheetObject();if(e==null||t==null)return;const n=t.scene;t.scene.getAncestorScale();const r=n.getViewport(V.VIEW_MAIN);if(r==null)return;if(i==null){r.scrollTo({x:0,y:0});return}const{sheetViewStartRow:o,sheetViewStartColumn:s,offsetX:a,offsetY:c}=i,{startX:d,startY:u}=e.getCellByIndexWithNoHeader(o,s),h=d+a,m=u+c,g=r.getBarScroll(h,m);r.scrollTo(g)})))}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{unitId:e,sheetId:t}=i;this._renderManagerService.getRenderById(e)!=null&&(this._updateSceneSize(i),this._scrollManagerService.setCurrentScroll({unitId:e,sheetId:t}))})))}_updateSceneSize(i){var c;if(i==null)return;const{skeleton:e,unitId:t}=i,n=(c=this._renderManagerService.getRenderById(t))==null?void 0:c.scene;if(e==null||n==null)return;const{rowTotalHeight:r,columnTotalWidth:o,rowHeaderWidthAndMarginLeft:s,columnHeaderHeightAndMarginTop:a}=e;n==null||n.transformByState({width:s+o,height:a+r})}_getSheetObject(){return Ce(this._currentUniverService,this._renderManagerService)}};vt=tu([l.OnLifecycle(l.LifecycleStages.Rendered,vt),ht(0,D.Inject(exports.SheetSkeletonManagerService)),ht(1,l.IUniverInstanceService),ht(2,l.ICommandService),ht(3,b.IRenderManagerService),ht(4,D.Inject(S.SelectionManagerService)),ht(5,D.Inject(Je))],vt);var nu=Object.defineProperty,iu=Object.getOwnPropertyDescriptor,ru=(i,e,t,n)=>{for(var r=n>1?void 0:n?iu(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&nu(e,t,r),r},Lr=(i,e)=>(t,n)=>e(t,n,i);const ou=[we.id,lt.id];let Nn=class extends l.Disposable{constructor(i,e){super(),this._commandService=i,this._scrollController=e,this.disposeWithMe(this._commandService.onCommandExecuted(t=>{ou.includes(t.id)&&this._scrollController.scrollToVisible()}))}};Nn=ru([l.OnLifecycle(l.LifecycleStages.Rendered,Nn),Lr(0,l.ICommandService),Lr(1,D.Inject(vt))],Nn);var su=Object.defineProperty,au=Object.getOwnPropertyDescriptor,lu=(i,e,t,n)=>{for(var r=n>1?void 0:n?au(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&su(e,t,r),r},Ze=(i,e)=>(t,n)=>e(t,n,i);let Hn=class extends l.Disposable{constructor(i,e,t,n,r,o,s,a){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._selectionRenderService=r,this._selectionManagerService=o,this._themeService=s,this._scrollController=a,this._initialize()}_initialize(){const i=this._currentUniverService.getCurrentUniverSheetInstance(),e=i.getActiveSheet(),t=this._getSheetObject();if(t==null)return;this._initViewMainListener(t),this._initRowHeader(t),this._initColumnHeader(t),this._initLeftTop(t),this._initSelectionChangeListener(),this._initThemeChangeListener(),this._initSkeletonChangeListener(),this._initCommandListener(),this._initUserActionSyncListener();const n=i.getUnitId(),r=e.getSheetId();this._selectionManagerService.setCurrentSelection({pluginName:S.NORMAL_SELECTION_PLUGIN_NAME,unitId:n,sheetId:r})}_getActiveViewport(i){const e=this._getSheetObject();return e==null?void 0:e.scene.getActiveViewportByCoord(b.Vector2.FromArray([i.offsetX,i.offsetY]))}_initViewMainListener(i){const{spreadsheet:e}=i;this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((t,n)=>{this._selectionRenderService.enableDetectMergedCell(),this._selectionRenderService.eventTrigger(t,e.zIndex+1,l.RANGE_TYPE.NORMAL,this._getActiveViewport(t)),t.button!==2&&n.stopPropagation()})))}_initThemeChangeListener(){this.disposeWithMe(l.toDisposable(this._themeService.currentTheme$.subscribe(()=>{this._selectionRenderService.resetStyle();const i=this._selectionManagerService.getSelections(),e=this._selectionManagerService.getCurrent();i==null||(e==null?void 0:e.pluginName)!==S.NORMAL_SELECTION_PLUGIN_NAME||this._refreshSelection(i)})))}_refreshSelection(i){const e=i.map(t=>{const n=this._selectionRenderService.convertSelectionRangeToData(t);return n.style=S.getNormalSelectionStyle(this._themeService),n});this._selectionRenderService.updateControlForCurrentByRangeData(e)}_initRowHeader(i){const{spreadsheetRowHeader:e,spreadsheet:t}=i;this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((n,r)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(n,((t==null?void 0:t.zIndex)||1)+1,l.RANGE_TYPE.ROW,this._getActiveViewport(n),b.ScrollTimerType.Y),n.button!==2&&r.stopPropagation()})))}_initColumnHeader(i){const{spreadsheetColumnHeader:e,spreadsheet:t}=i;this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((n,r)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(n,((t==null?void 0:t.zIndex)||1)+1,l.RANGE_TYPE.COLUMN,this._getActiveViewport(n),b.ScrollTimerType.X),n.button!==2&&r.stopPropagation()})))}_initLeftTop(i){const{spreadsheetLeftTopPlaceholder:e}=i;this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((t,n)=>{var a;const r=(a=this._sheetSkeletonManagerService.getCurrent())==null?void 0:a.skeleton;if(r==null)return;this._selectionRenderService.reset();const o=this._getAllRange(r),s=this._selectionRenderService.convertSelectionRangeToData(o);this._selectionRenderService.addControlToCurrentByRangeData(s),this._selectionRenderService.refreshSelectionMoveStart(),t.button!==2&&n.stopPropagation()})))}_initSelectionChangeListener(){this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(i=>{if(this._selectionRenderService.reset(),i!=null)for(const e of i){if(e==null)continue;const t=this._selectionRenderService.convertSelectionRangeToData(e);this._selectionRenderService.addControlToCurrentByRangeData(t)}})))}_initUserActionSyncListener(){this._selectionRenderService.selectionMoveStart$.subscribe(i=>{this._move(i,S.SelectionMoveType.MOVE_START)}),this._selectionRenderService.selectionMoving$.subscribe(i=>{this._move(i,S.SelectionMoveType.MOVING)}),this._selectionRenderService.selectionMoveEnd$.subscribe(i=>{this._move(i,S.SelectionMoveType.MOVE_END)})}_move(i,e){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getUnitId(),r=t.getActiveSheet().getSheetId(),o=this._selectionManagerService.getCurrent();i==null||i.length===0||this._commandService.executeCommand(S.SetSelectionsOperation.id,{unitId:n,subUnitId:r,type:e,pluginName:(o==null?void 0:o.pluginName)||S.NORMAL_SELECTION_PLUGIN_NAME,selections:i.map(s=>S.convertSelectionDataToRange(s))})}_getSheetObject(){return Ce(this._currentUniverService,this._renderManagerService)}_initCommandListener(){const i=[ze.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet(),r=e.params,{unitId:o,subUnitId:s}=r;if(!(o===t.getUnitId()&&s===n.getSheetId()))return;this._selectionManagerService.refreshSelection()}}))}_initSkeletonChangeListener(){this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{unitId:e,sheetId:t,skeleton:n}=i,r=this._renderManagerService.getRenderById(e);if(r==null)return;const{scene:o}=r,s=o.getViewport(V.VIEW_MAIN);this._selectionRenderService.changeRuntime(n,o,s);const a=this._selectionManagerService.getCurrent(),c=(a==null?void 0:a.pluginName)||S.NORMAL_SELECTION_PLUGIN_NAME;if((a==null?void 0:a.unitId)===e&&a.sheetId===t){const d=this._selectionManagerService.getSelections();d!=null&&this._refreshSelection(d)}else this._selectionManagerService.setCurrentSelection({pluginName:c,unitId:e,sheetId:t});c===S.NORMAL_SELECTION_PLUGIN_NAME&&this._selectionManagerService.getLast()==null&&this._selectionManagerService.add([this._getZeroRange(n)])})}_getAllRange(i){return{range:{startRow:0,startColumn:0,endRow:i.getRowCount()-1,endColumn:i.getColumnCount()-1,rangeType:l.RANGE_TYPE.ALL},primary:this._getZeroRange(i).primary,style:null}}_getZeroRange(i){const e=i.mergeData;return S.transformCellDataToSelectionData(0,0,e)||{range:{startRow:0,startColumn:0,endRow:0,endColumn:0},primary:{actualRow:0,actualColumn:0,startRow:0,startColumn:0,endRow:0,endColumn:0,isMerged:!1,isMergedMainCell:!1},style:null}}};Hn=lu([l.OnLifecycle(l.LifecycleStages.Rendered,Hn),Ze(0,D.Inject(exports.SheetSkeletonManagerService)),Ze(1,l.IUniverInstanceService),Ze(2,l.ICommandService),Ze(3,b.IRenderManagerService),Ze(4,_e),Ze(5,D.Inject(S.SelectionManagerService)),Ze(6,D.Inject(l.ThemeService)),Ze(7,D.Inject(vt))],Hn);var cu=Object.defineProperty,du=Object.getOwnPropertyDescriptor,uu=(i,e,t,n)=>{for(var r=n>1?void 0:n?du(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&cu(e,t,r),r},mt=(i,e)=>(t,n)=>e(t,n,i);let Pn=class extends l.Disposable{constructor(i,e,t,n,r,o){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._renderManagerService=t,this._commandService=n,this._selectionRenderService=r,this._selectionManagerService=o,this._initialize(),this._commandExecutedListener()}dispose(){super.dispose()}_initialize(){this._initialRenderRefresh()}_initialRenderRefresh(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{skeleton:e,unitId:t,sheetId:n}=i,r=this._currentUniverService.getUniverSheetInstance(t),o=r==null?void 0:r.getSheetBySheetId(n);if(r==null||o==null)return;const s=this._renderManagerService.getRenderById(t);if(s==null)return;const{mainComponent:a,components:c,scene:d}=s,u=a,h=c.get(Se.ROW),m=c.get(Se.COLUMN),g=c.get(Se.LEFT_TOP),{rowHeaderWidth:_,columnHeaderHeight:f}=e;u==null||u.updateSkeleton(e),h==null||h.updateSkeleton(e),m==null||m.updateSkeleton(e),g==null||g.transformByState({width:_,height:f})})))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted((i,e)=>{var r,o;const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getUnitId();if(S.COMMAND_LISTENER_SKELETON_CHANGE.includes(i.id)){const s=t.getActiveSheet(),a=s.getSheetId(),c=i.params,{unitId:d,subUnitId:u}=c;if(!(d===t.getUnitId()&&u===s.getSheetId()))return;i.id!==S.SetWorksheetActiveOperation.id&&this._sheetSkeletonManagerService.makeDirty({unitId:d,sheetId:a,commandId:i.id},!0),this._sheetSkeletonManagerService.setCurrent({unitId:d,sheetId:a,commandId:i.id})}else S.COMMAND_LISTENER_VALUE_CHANGE.includes(i.id)&&this._sheetSkeletonManagerService.reCalculate();i.type===l.CommandType.MUTATION&&((o=(r=this._renderManagerService.getRenderById(n))==null?void 0:r.mainComponent)==null||o.makeDirty())}))}};Pn=uu([l.OnLifecycle(l.LifecycleStages.Ready,Pn),mt(0,D.Inject(exports.SheetSkeletonManagerService)),mt(1,l.IUniverInstanceService),mt(2,b.IRenderManagerService),mt(3,l.ICommandService),mt(4,_e),mt(5,D.Inject(S.SelectionManagerService))],Pn);const Xe={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(i,e)=>{const t=i.get(l.ICommandService),n=i.get(l.IUndoRedoService),r=i.get(l.IUniverInstanceService),o=i.get(I.IConfirmService),s=i.get(l.LocaleService),a=e.unitId,c=e.subUnitId,d=e.selections,u=S.getAddMergeMutationRangeByType(d,e.value),h=r.getUniverSheetInstance(a).getSheetBySheetId(c),m=[],g=[],_=No(h,u);if(_&&!await o.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:"merge.confirm.title"},cancelText:s.t("merge.confirm.cancel"),confirmText:s.t("merge.confirm.confirm")}))return!1;const f={unitId:a,subUnitId:c,ranges:u},v={unitId:a,subUnitId:c,ranges:u};m.push({id:S.RemoveWorksheetMergeMutation.id,params:f}),m.push({id:S.AddWorksheetMergeMutation.id,params:v});const R=S.RemoveMergeUndoMutationFactory(i,f),M=S.AddMergeUndoMutationFactory(i,v);if(g.push({id:S.RemoveWorksheetMergeMutation.id,params:M}),g.push({id:S.AddWorksheetMergeMutation.id,params:R}),_){const w=Ho(i,a,h,u);m.unshift(...w.redos),g.push(...w.undos)}return l.sequenceExecute(m,t).result?(n.pushUndoRedo({unitID:a,undoMutations:g,redoMutations:m}),!0):!1}},Zo={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async i=>{const e=i.get(l.ICommandService),n=i.get(S.SelectionManagerService).getSelectionRanges();if(!(n!=null&&n.length))return!1;const o=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!o)return!1;const s=o.getActiveSheet();if(!s)return!1;const a=o.getUnitId(),c=s.getSheetId();return e.executeCommand(Xe.id,{selections:n,unitId:a,subUnitId:c})}},Go={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async i=>{const e=i.get(l.ICommandService),n=i.get(S.SelectionManagerService).getSelectionRanges();if(!(n!=null&&n.length))return!1;const o=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!o)return!1;const s=o.getActiveSheet();if(!s)return!1;const a=o.getUnitId(),c=s.getSheetId();return e.executeCommand(Xe.id,{value:l.Dimension.COLUMNS,selections:n,unitId:a,subUnitId:c})}},Ko={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async i=>{const e=i.get(l.ICommandService),n=i.get(S.SelectionManagerService).getSelectionRanges();if(!(n!=null&&n.length))return!1;const o=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!o)return!1;const s=o.getActiveSheet();if(!s)return!1;const a=o.getUnitId(),c=s.getSheetId();return e.executeCommand(Xe.id,{value:l.Dimension.ROWS,selections:n,unitId:a,subUnitId:c})}},Yi={type:l.CommandType.COMMAND,id:"sheet.command.delete-range-move-left-confirm",handler:async i=>{const e=i.get(I.IConfirmService),t=i.get(l.ICommandService),n=i.get(l.LocaleService),r=i.get(S.SelectionManagerService),o=i.get(l.IUniverInstanceService),s=r.getSelections();if(!s)return!1;const c=o.getCurrentUniverSheetInstance().getActiveSheet();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 _=l.Rectangle.getIntersects(g,d);return _?u(g)>u(_):!1})||await e.confirm({id:Yi.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?t.executeCommand(S.DeleteRangeMoveLeftCommand.id):!0}},Zi={type:l.CommandType.COMMAND,id:"sheet.command.delete-range-move-up-confirm",handler:async i=>{const e=i.get(I.IConfirmService),t=i.get(l.ICommandService),n=i.get(l.LocaleService),r=i.get(S.SelectionManagerService),o=i.get(l.IUniverInstanceService),s=r.getSelections();if(!s)return!1;const c=o.getCurrentUniverSheetInstance().getActiveSheet();let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getColumnCount()-1};const u=g=>g.endColumn-g.startColumn;return!c.getMergeData().find(g=>{const _=l.Rectangle.getIntersects(g,d);return _?u(g)>u(_):!1})||await e.confirm({id:Zi.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?t.executeCommand(S.DeleteRangeMoveUpCommand.id):!0}},Gi={type:l.CommandType.COMMAND,id:"sheet.command.insert-range-move-down-confirm",handler:async i=>{const e=i.get(I.IConfirmService),t=i.get(l.ICommandService),n=i.get(l.LocaleService),r=i.get(S.SelectionManagerService),o=i.get(l.IUniverInstanceService),s=r.getSelections();if(!s)return!1;const c=o.getCurrentUniverSheetInstance().getActiveSheet();let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getColumnCount()-1};const u=g=>g.endColumn-g.startColumn;return!c.getMergeData().find(g=>{const _=l.Rectangle.getIntersects(g,d);return _?u(g)>u(_):!1})||await e.confirm({id:Gi.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?t.executeCommand(S.InsertRangeMoveDownCommand.id):!0}},Ki={type:l.CommandType.COMMAND,id:"sheet.command.insert-range-move-right-confirm",handler:async i=>{const e=i.get(I.IConfirmService),t=i.get(l.ICommandService),n=i.get(l.LocaleService),r=i.get(S.SelectionManagerService),o=i.get(l.IUniverInstanceService),s=r.getSelections();if(!s)return!1;const c=o.getCurrentUniverSheetInstance().getActiveSheet();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 _=l.Rectangle.getIntersects(g,d);return _?u(g)>u(_):!1})||await e.confirm({id:Ki.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?t.executeCommand(S.InsertRangeMoveRightCommand.id):!0}},qo={id:"sheet.command.refill",type:l.CommandType.COMMAND,handler:async(i,e)=>{const t=i.get(Jt);return t.applyType=e.type,!0}},Jo={id:"sheet.command.remove-row-confirm",type:l.CommandType.COMMAND,handler:async(i,e)=>{var d;const t=i.get(S.SelectionManagerService);let n=e==null?void 0:e.range;if(n||(n=(d=t.getLast())==null?void 0:d.range),!n)return!1;const r=i.get(l.ICommandService),c=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance().getActiveSheet().getVisibleRows();if(co(c,[n])){const u=i.get(I.IConfirmService),h=i.get(l.LocaleService);return await u.confirm({id:"sheet.confirm.remove-row",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllRowsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await r.executeCommand(S.RemoveRowCommand.id,{range:n}),!0}},Qo={id:"sheet.command.remove-col-confirm",type:l.CommandType.COMMAND,handler:async(i,e)=>{var d;const t=i.get(S.SelectionManagerService);let n=e==null?void 0:e.range;if(n||(n=(d=t.getLast())==null?void 0:d.range),!n)return!1;const r=i.get(l.ICommandService),c=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance().getActiveSheet().getVisibleCols();if(uo(c,[n])){const u=i.get(I.IConfirmService),h=i.get(l.LocaleService);return await u.confirm({id:"sheet.confirm.remove-col",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllColumnsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await r.executeCommand(S.RemoveColCommand.id,{range:n}),!0}},es={id:"sheet.command.remove-sheet-confirm",type:l.CommandType.COMMAND,handler:async(i,e)=>{const{subUnitId:t}=e,n=i.get(I.IConfirmService),r=i.get(l.ICommandService),o=i.get(l.LocaleService);return await n.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:o.t("sheetConfig.deleteSheet")},children:{title:o.t("sheetConfig.deleteSheetContent")},cancelText:o.t("button.cancel"),confirmText:o.t("button.confirm")})?(await r.executeCommand(S.RemoveSheetCommand.id,{subUnitId:t}),!0):!1}},xt=D.createIdentifier("univer.sheetbar-service");class hu extends l.Disposable{constructor(){super();C(this,"renameId$");C(this,"removeId$");C(this,"scroll$");C(this,"scrollX$");C(this,"addSheet$");C(this,"_renameId$");C(this,"_removeId$");C(this,"_scroll$");C(this,"_scrollX$");C(this,"_addSheet$");C(this,"_currentHandler",null);this._renameId$=new N.Subject,this.renameId$=this._renameId$.asObservable(),this._removeId$=new N.Subject,this.removeId$=this._removeId$.asObservable(),this._scroll$=new N.Subject,this.scroll$=this._scroll$.asObservable(),this._scrollX$=new N.Subject,this.scrollX$=this._scrollX$.asObservable(),this._addSheet$=new N.Subject,this.addSheet$=this._addSheet$.asObservable()}setRenameId(t){this._renameId$.next(t)}setRemoveId(t){this._removeId$.next(t)}setScroll(t){this._scroll$.next(t)}setScrollX(t){this._scrollX$.next(t)}setAddSheet(t){this._addSheet$.next(t)}triggerSheetBarMenu(){var t;(t=this._currentHandler)==null||t.handleSheetBarMenu()}registerSheetBarMenuHandler(t){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=t,l.toDisposable(()=>{this._currentHandler=null})}}const ts={id:"ui-sheet.command.show-menu-list",type:l.CommandType.OPERATION,handler:async i=>(i.get(xt).triggerSheetBarMenu(),!0)},ns={id:"sheet.operation.rename-sheet",type:l.CommandType.OPERATION,handler:async(i,e)=>{const t=i.get(xt);return e&&t.setRenameId(e.subUnitId),!0}},mu=()=>p.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M0.98999 1.08218H-0.0100098V0.0821838H0.98999V1.08218Z",fill:"black"}),p.jsx("path",{d:"M5.78992 1.08218H2.78992V0.0821838H5.78992V1.08218Z",fill:"black"}),p.jsx("path",{d:"M7.58984 1.08218H8.58984V0.0821838H7.58984V1.08218Z",fill:"black"}),p.jsx("path",{d:"M14.9152 1.08218H13.9152V0.0821838H14.9152V1.08218Z",fill:"black"}),p.jsx("path",{d:"M16.7151 1.08218H19.7151V0.0821838H16.7151V1.08218Z",fill:"black"}),p.jsx("path",{d:"M22.515 1.08218H21.515V0.0821838H22.515V1.08218Z",fill:"black"}),p.jsx("path",{d:"M27.8405 1.08218H28.8405V0.0821838H27.8405V1.08218Z",fill:"black"}),p.jsx("path",{d:"M33.6404 1.08218H30.6404V0.0821838H33.6404V1.08218Z",fill:"black"}),p.jsx("path",{d:"M35.4403 1.08218H36.4403V0.0821838H35.4403V1.08218Z",fill:"black"}),p.jsx("path",{d:"M42.7657 1.08218H41.7657V0.0821838H42.7657V1.08218Z",fill:"black"}),p.jsx("path",{d:"M44.5657 1.08218H47.5657V0.0821838H44.5657V1.08218Z",fill:"black"}),p.jsx("path",{d:"M50.3656 1.08218H49.3656V0.0821838H50.3656V1.08218Z",fill:"black"}),p.jsx("path",{d:"M55.691 1.08218H56.691V0.0821838H55.691V1.08218Z",fill:"black"}),p.jsx("path",{d:"M61.491 1.08218H58.491V0.0821838H61.491V1.08218Z",fill:"black"}),p.jsx("path",{d:"M63.2909 1.08218H64.2909V0.0821838H63.2909V1.08218Z",fill:"black"}),p.jsx("path",{d:"M70.6163 1.08218H69.6163V0.0821838H70.6163V1.08218Z",fill:"black"}),p.jsx("path",{d:"M72.4163 1.08218H75.4163V0.0821838H72.4163V1.08218Z",fill:"black"}),p.jsx("path",{d:"M78.2162 1.08218H77.2162V0.0821838H78.2162V1.08218Z",fill:"black"}),p.jsx("path",{d:"M83.5416 1.08218H84.5416V0.0821838H83.5416V1.08218Z",fill:"black"}),p.jsx("path",{d:"M89.3416 1.08218H86.3416V0.0821838H89.3416V1.08218Z",fill:"black"}),p.jsx("path",{d:"M91.1415 1.08218H92.1415V0.0821838H91.1415V1.08218Z",fill:"black"}),p.jsx("path",{d:"M98.4669 1.08218H97.4669V0.0821838H98.4669V1.08218Z",fill:"black"}),p.jsx("path",{d:"M100.267 1.08218H103.267V0.0821838H100.267V1.08218Z",fill:"black"}),p.jsx("path",{d:"M106.067 1.08218H105.067V0.0821838H106.067V1.08218Z",fill:"black"}),p.jsx("path",{d:"M111.392 1.08218H112.392V0.0821838H111.392V1.08218Z",fill:"black"}),p.jsx("path",{d:"M117.192 1.08218H114.192V0.0821838H117.192V1.08218Z",fill:"black"}),p.jsx("path",{d:"M118.992 1.08218H119.992V0.0821838H118.992V1.08218Z",fill:"black"})]}),gu=()=>p.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M-0.0100098 1.15771H0.98999V0.157715H-0.0100098V1.15771Z",fill:"black"}),p.jsx("path",{d:"M2.78992 1.15771H5.78992V0.157715H2.78992V1.15771Z",fill:"black"}),p.jsx("path",{d:"M8.58984 1.15771H7.58984V0.157715H8.58984V1.15771Z",fill:"black"}),p.jsx("path",{d:"M10.3899 1.15771H11.3899V0.157715H10.3899V1.15771Z",fill:"black"}),p.jsx("path",{d:"M19.0903 1.15771H18.0903V0.157715H19.0903V1.15771Z",fill:"black"}),p.jsx("path",{d:"M20.8903 1.15771H23.8903V0.157715H20.8903V1.15771Z",fill:"black"}),p.jsx("path",{d:"M26.6902 1.15771H25.6902V0.157715H26.6902V1.15771Z",fill:"black"}),p.jsx("path",{d:"M28.4902 1.15771H29.4902V0.157715H28.4902V1.15771Z",fill:"black"}),p.jsx("path",{d:"M37.1907 1.15771H36.1907V0.157715H37.1907V1.15771Z",fill:"black"}),p.jsx("path",{d:"M38.9906 1.15771H41.9906V0.157715H38.9906V1.15771Z",fill:"black"}),p.jsx("path",{d:"M44.7905 1.15771H43.7905V0.157715H44.7905V1.15771Z",fill:"black"}),p.jsx("path",{d:"M46.5906 1.15771H47.5906V0.157715H46.5906V1.15771Z",fill:"black"}),p.jsx("path",{d:"M55.291 1.15771H54.291V0.157715H55.291V1.15771Z",fill:"black"}),p.jsx("path",{d:"M57.0909 1.15771H60.0909V0.157715H57.0909V1.15771Z",fill:"black"}),p.jsx("path",{d:"M62.8909 1.15771H61.8909V0.157715H62.8909V1.15771Z",fill:"black"}),p.jsx("path",{d:"M64.6909 1.15771H65.6909V0.157715H64.6909V1.15771Z",fill:"black"}),p.jsx("path",{d:"M73.3914 1.15771H72.3914V0.157715H73.3914V1.15771Z",fill:"black"}),p.jsx("path",{d:"M75.1913 1.15771H78.1913V0.157715H75.1913V1.15771Z",fill:"black"}),p.jsx("path",{d:"M80.9912 1.15771H79.9912V0.157715H80.9912V1.15771Z",fill:"black"}),p.jsx("path",{d:"M82.7913 1.15771H83.7913V0.157715H82.7913V1.15771Z",fill:"black"}),p.jsx("path",{d:"M91.4917 1.15771H90.4917V0.157715H91.4917V1.15771Z",fill:"black"}),p.jsx("path",{d:"M93.2916 1.15771H96.2916V0.157715H93.2916V1.15771Z",fill:"black"}),p.jsx("path",{d:"M99.0916 1.15771H98.0916V0.157715H99.0916V1.15771Z",fill:"black"}),p.jsx("path",{d:"M100.892 1.15771H101.892V0.157715H100.892V1.15771Z",fill:"black"}),p.jsx("path",{d:"M109.592 1.15771H108.592V0.157715H109.592V1.15771Z",fill:"black"}),p.jsx("path",{d:"M111.392 1.15771H114.392V0.157715H111.392V1.15771Z",fill:"black"}),p.jsx("path",{d:"M117.192 1.15771H116.192V0.157715H117.192V1.15771Z",fill:"black"}),p.jsx("path",{d:"M118.992 1.15771H119.992V0.157715H118.992V1.15771Z",fill:"black"})]}),_u=()=>p.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M-0.00842285 1.22449H2.99158V0.224487H-0.00842285V1.22449Z",fill:"black"}),p.jsx("path",{d:"M6.14941 1.22449H9.14941V0.224487H6.14941V1.22449Z",fill:"black"}),p.jsx("path",{d:"M15.3073 1.22449H12.3073V0.224487H15.3073V1.22449Z",fill:"black"}),p.jsx("path",{d:"M18.4651 1.22449H21.4651V0.224487H18.4651V1.22449Z",fill:"black"}),p.jsx("path",{d:"M27.6229 1.22449H24.6229V0.224487H27.6229V1.22449Z",fill:"black"}),p.jsx("path",{d:"M30.7808 1.22449H33.7808V0.224487H30.7808V1.22449Z",fill:"black"}),p.jsx("path",{d:"M39.9386 1.22449H36.9386V0.224487H39.9386V1.22449Z",fill:"black"}),p.jsx("path",{d:"M43.0964 1.22449H46.0964V0.224487H43.0964V1.22449Z",fill:"black"}),p.jsx("path",{d:"M52.2543 1.22449H49.2543V0.224487H52.2543V1.22449Z",fill:"black"}),p.jsx("path",{d:"M55.4121 1.22449H58.4121V0.224487H55.4121V1.22449Z",fill:"black"}),p.jsx("path",{d:"M64.5699 1.22449H61.5699V0.224487H64.5699V1.22449Z",fill:"black"}),p.jsx("path",{d:"M67.7278 1.22449H70.7278V0.224487H67.7278V1.22449Z",fill:"black"}),p.jsx("path",{d:"M76.8856 1.22449H73.8856V0.224487H76.8856V1.22449Z",fill:"black"}),p.jsx("path",{d:"M80.0435 1.22449H83.0435V0.224487H80.0435V1.22449Z",fill:"black"}),p.jsx("path",{d:"M89.2013 1.22449H86.2013V0.224487H89.2013V1.22449Z",fill:"black"}),p.jsx("path",{d:"M92.3591 1.22449H95.3591V0.224487H92.3591V1.22449Z",fill:"black"}),p.jsx("path",{d:"M101.517 1.22449H98.517V0.224487H101.517V1.22449Z",fill:"black"}),p.jsx("path",{d:"M104.675 1.22449H107.675V0.224487H104.675V1.22449Z",fill:"black"}),p.jsx("path",{d:"M113.833 1.22449H110.833V0.224487H113.833V1.22449Z",fill:"black"}),p.jsx("path",{d:"M116.99 1.22449H119.99V0.224487H116.99V1.22449Z",fill:"black"})]}),Su=()=>p.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M-0.00976562 1.65707H0.990234V0.657074H-0.00976562V1.65707Z",fill:"black"}),p.jsx("path",{d:"M2.32361 1.65707H3.32361V0.657074H2.32361V1.65707Z",fill:"black"}),p.jsx("path",{d:"M5.65698 1.65707H4.65698V0.657074H5.65698V1.65707Z",fill:"black"}),p.jsx("path",{d:"M6.99036 1.65707H7.99036V0.657074H6.99036V1.65707Z",fill:"black"}),p.jsx("path",{d:"M10.3237 1.65707H9.32373V0.657074H10.3237V1.65707Z",fill:"black"}),p.jsx("path",{d:"M11.6571 1.65707H12.6571V0.657074H11.6571V1.65707Z",fill:"black"}),p.jsx("path",{d:"M14.9905 1.65707H13.9905V0.657074H14.9905V1.65707Z",fill:"black"}),p.jsx("path",{d:"M16.3239 1.65707H17.3239V0.657074H16.3239V1.65707Z",fill:"black"}),p.jsx("path",{d:"M19.6572 1.65707H18.6572V0.657074H19.6572V1.65707Z",fill:"black"}),p.jsx("path",{d:"M20.9906 1.65707H21.9906V0.657074H20.9906V1.65707Z",fill:"black"}),p.jsx("path",{d:"M24.324 1.65707H23.324V0.657074H24.324V1.65707Z",fill:"black"}),p.jsx("path",{d:"M25.6573 1.65707H26.6573V0.657074H25.6573V1.65707Z",fill:"black"}),p.jsx("path",{d:"M28.9907 1.65707H27.9907V0.657074H28.9907V1.65707Z",fill:"black"}),p.jsx("path",{d:"M30.3241 1.65707H31.3241V0.657074H30.3241V1.65707Z",fill:"black"}),p.jsx("path",{d:"M33.6575 1.65707H32.6575V0.657074H33.6575V1.65707Z",fill:"black"}),p.jsx("path",{d:"M34.9908 1.65707H35.9908V0.657074H34.9908V1.65707Z",fill:"black"}),p.jsx("path",{d:"M38.3242 1.65707H37.3242V0.657074H38.3242V1.65707Z",fill:"black"}),p.jsx("path",{d:"M39.6576 1.65707H40.6576V0.657074H39.6576V1.65707Z",fill:"black"}),p.jsx("path",{d:"M42.991 1.65707H41.991V0.657074H42.991V1.65707Z",fill:"black"}),p.jsx("path",{d:"M44.3243 1.65707H45.3243V0.657074H44.3243V1.65707Z",fill:"black"}),p.jsx("path",{d:"M47.6577 1.65707H46.6577V0.657074H47.6577V1.65707Z",fill:"black"}),p.jsx("path",{d:"M48.9911 1.65707H49.9911V0.657074H48.9911V1.65707Z",fill:"black"}),p.jsx("path",{d:"M52.3245 1.65707H51.3245V0.657074H52.3245V1.65707Z",fill:"black"}),p.jsx("path",{d:"M53.6578 1.65707H54.6578V0.657074H53.6578V1.65707Z",fill:"black"}),p.jsx("path",{d:"M56.9912 1.65707H55.9912V0.657074H56.9912V1.65707Z",fill:"black"}),p.jsx("path",{d:"M58.3246 1.65707H59.3246V0.657074H58.3246V1.65707Z",fill:"black"}),p.jsx("path",{d:"M61.658 1.65707H60.658V0.657074H61.658V1.65707Z",fill:"black"}),p.jsx("path",{d:"M62.9913 1.65707H63.9913V0.657074H62.9913V1.65707Z",fill:"black"}),p.jsx("path",{d:"M66.3247 1.65707H65.3247V0.657074H66.3247V1.65707Z",fill:"black"}),p.jsx("path",{d:"M67.6581 1.65707H68.6581V0.657074H67.6581V1.65707Z",fill:"black"}),p.jsx("path",{d:"M70.9915 1.65707H69.9915V0.657074H70.9915V1.65707Z",fill:"black"}),p.jsx("path",{d:"M72.3248 1.65707H73.3248V0.657074H72.3248V1.65707Z",fill:"black"}),p.jsx("path",{d:"M75.6582 1.65707H74.6582V0.657074H75.6582V1.65707Z",fill:"black"}),p.jsx("path",{d:"M76.9916 1.65707H77.9916V0.657074H76.9916V1.65707Z",fill:"black"}),p.jsx("path",{d:"M80.325 1.65707H79.325V0.657074H80.325V1.65707Z",fill:"black"}),p.jsx("path",{d:"M81.6583 1.65707H82.6583V0.657074H81.6583V1.65707Z",fill:"black"}),p.jsx("path",{d:"M84.9917 1.65707H83.9917V0.657074H84.9917V1.65707Z",fill:"black"}),p.jsx("path",{d:"M86.3251 1.65707H87.3251V0.657074H86.3251V1.65707Z",fill:"black"}),p.jsx("path",{d:"M89.6584 1.65707H88.6584V0.657074H89.6584V1.65707Z",fill:"black"}),p.jsx("path",{d:"M90.9918 1.65707H91.9918V0.657074H90.9918V1.65707Z",fill:"black"}),p.jsx("path",{d:"M94.3252 1.65707H93.3252V0.657074H94.3252V1.65707Z",fill:"black"}),p.jsx("path",{d:"M95.6586 1.65707H96.6586V0.657074H95.6586V1.65707Z",fill:"black"}),p.jsx("path",{d:"M98.9919 1.65707H97.9919V0.657074H98.9919V1.65707Z",fill:"black"}),p.jsx("path",{d:"M100.325 1.65707H101.325V0.657074H100.325V1.65707Z",fill:"black"}),p.jsx("path",{d:"M103.659 1.65707H102.659V0.657074H103.659V1.65707Z",fill:"black"}),p.jsx("path",{d:"M104.992 1.65707H105.992V0.657074H104.992V1.65707Z",fill:"black"}),p.jsx("path",{d:"M108.325 1.65707H107.325V0.657074H108.325V1.65707Z",fill:"black"}),p.jsx("path",{d:"M109.659 1.65707H110.659V0.657074H109.659V1.65707Z",fill:"black"}),p.jsx("path",{d:"M112.992 1.65707H111.992V0.657074H112.992V1.65707Z",fill:"black"}),p.jsx("path",{d:"M114.325 1.65707H115.325V0.657074H114.325V1.65707Z",fill:"black"}),p.jsx("path",{d:"M117.659 1.65707H116.659V0.657074H117.659V1.65707Z",fill:"black"}),p.jsx("path",{d:"M118.992 1.65707H119.992V0.657074H118.992V1.65707Z",fill:"black"})]}),fu=()=>p.jsx("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:p.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 2.42035H-0.0090332V0.420349H119.991V2.42035Z",fill:"black"})}),pu=()=>p.jsxs("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M-0.0100098 2.47614H1.98999V0.476135H-0.0100098V2.47614Z",fill:"black"}),p.jsx("path",{d:"M3.99014 2.47614H9.99014V0.476135H3.99014V2.47614Z",fill:"black"}),p.jsx("path",{d:"M13.9901 2.47614H11.9901V0.476135H13.9901V2.47614Z",fill:"black"}),p.jsx("path",{d:"M21.1904 2.47614H23.1904V0.476135H21.1904V2.47614Z",fill:"black"}),p.jsx("path",{d:"M31.1906 2.47614H25.1906V0.476135H31.1906V2.47614Z",fill:"black"}),p.jsx("path",{d:"M33.1906 2.47614H35.1906V0.476135H33.1906V2.47614Z",fill:"black"}),p.jsx("path",{d:"M44.3909 2.47614H42.3909V0.476135H44.3909V2.47614Z",fill:"black"}),p.jsx("path",{d:"M46.391 2.47614H52.391V0.476135H46.391V2.47614Z",fill:"black"}),p.jsx("path",{d:"M56.391 2.47614H54.391V0.476135H56.391V2.47614Z",fill:"black"}),p.jsx("path",{d:"M63.5913 2.47614H65.5913V0.476135H63.5913V2.47614Z",fill:"black"}),p.jsx("path",{d:"M73.5915 2.47614H67.5915V0.476135H73.5915V2.47614Z",fill:"black"}),p.jsx("path",{d:"M75.5915 2.47614H77.5915V0.476135H75.5915V2.47614Z",fill:"black"}),p.jsx("path",{d:"M86.7917 2.47614H84.7917V0.476135H86.7917V2.47614Z",fill:"black"}),p.jsx("path",{d:"M88.7919 2.47614H94.7919V0.476135H88.7919V2.47614Z",fill:"black"}),p.jsx("path",{d:"M98.7919 2.47614H96.7919V0.476135H98.7919V2.47614Z",fill:"black"}),p.jsx("path",{d:"M105.992 2.47614H107.992V0.476135H105.992V2.47614Z",fill:"black"}),p.jsx("path",{d:"M115.992 2.47614H109.992V0.476135H115.992V2.47614Z",fill:"black"}),p.jsx("path",{d:"M117.992 2.47614H119.992V0.476135H117.992V2.47614Z",fill:"black"})]}),vu=()=>p.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M-0.0100098 2.00415H1.98999V0.00415039H-0.0100098V2.00415Z",fill:"black"}),p.jsx("path",{d:"M3.99014 2.00415H9.99014V0.00415039H3.99014V2.00415Z",fill:"black"}),p.jsx("path",{d:"M13.9901 2.00415H11.9901V0.00415039H13.9901V2.00415Z",fill:"black"}),p.jsx("path",{d:"M15.9901 2.00415H17.9901V0.00415039H15.9901V2.00415Z",fill:"black"}),p.jsx("path",{d:"M27.4905 2.00415H25.4905V0.00415039H27.4905V2.00415Z",fill:"black"}),p.jsx("path",{d:"M29.4906 2.00415H35.4906V0.00415039H29.4906V2.00415Z",fill:"black"}),p.jsx("path",{d:"M39.4906 2.00415H37.4906V0.00415039H39.4906V2.00415Z",fill:"black"}),p.jsx("path",{d:"M41.4906 2.00415H43.4906V0.00415039H41.4906V2.00415Z",fill:"black"}),p.jsx("path",{d:"M52.991 2.00415H50.991V0.00415039H52.991V2.00415Z",fill:"black"}),p.jsx("path",{d:"M54.9911 2.00415H60.9911V0.00415039H54.9911V2.00415Z",fill:"black"}),p.jsx("path",{d:"M64.9911 2.00415H62.9911V0.00415039H64.9911V2.00415Z",fill:"black"}),p.jsx("path",{d:"M66.9911 2.00415H68.9911V0.00415039H66.9911V2.00415Z",fill:"black"}),p.jsx("path",{d:"M78.4915 2.00415H76.4915V0.00415039H78.4915V2.00415Z",fill:"black"}),p.jsx("path",{d:"M80.4916 2.00415H86.4916V0.00415039H80.4916V2.00415Z",fill:"black"}),p.jsx("path",{d:"M90.4916 2.00415H88.4916V0.00415039H90.4916V2.00415Z",fill:"black"}),p.jsx("path",{d:"M92.4916 2.00415H94.4916V0.00415039H92.4916V2.00415Z",fill:"black"}),p.jsx("path",{d:"M103.992 2.00415H101.992V0.00415039H103.992V2.00415Z",fill:"black"}),p.jsx("path",{d:"M105.992 2.00415H111.992V0.00415039H105.992V2.00415Z",fill:"black"}),p.jsx("path",{d:"M115.992 2.00415H113.992V0.00415039H115.992V2.00415Z",fill:"black"}),p.jsx("path",{d:"M117.992 2.00415H119.992V0.00415039H117.992V2.00415Z",fill:"black"})]}),Cu=()=>p.jsxs("svg",{width:"118",height:"3",viewBox:"0 0 118 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M-0.00854492 2.94815H1.99146V0.948151H-0.00854492V2.94815Z",fill:"black"}),p.jsx("path",{d:"M6.09668 2.94815H8.09668V0.948151H6.09668V2.94815Z",fill:"black"}),p.jsx("path",{d:"M14.2019 2.94815H12.2019V0.948151H14.2019V2.94815Z",fill:"black"}),p.jsx("path",{d:"M18.3071 2.94815H20.3071V0.948151H18.3071V2.94815Z",fill:"black"}),p.jsx("path",{d:"M26.4124 2.94815H24.4124V0.948151H26.4124V2.94815Z",fill:"black"}),p.jsx("path",{d:"M30.5176 2.94815H32.5176V0.948151H30.5176V2.94815Z",fill:"black"}),p.jsx("path",{d:"M38.6228 2.94815H36.6228V0.948151H38.6228V2.94815Z",fill:"black"}),p.jsx("path",{d:"M42.728 2.94815H44.728V0.948151H42.728V2.94815Z",fill:"black"}),p.jsx("path",{d:"M50.8333 2.94815H48.8333V0.948151H50.8333V2.94815Z",fill:"black"}),p.jsx("path",{d:"M54.9385 2.94815H56.9385V0.948151H54.9385V2.94815Z",fill:"black"}),p.jsx("path",{d:"M63.0437 2.94815H61.0437V0.948151H63.0437V2.94815Z",fill:"black"}),p.jsx("path",{d:"M67.1489 2.94815H69.1489V0.948151H67.1489V2.94815Z",fill:"black"}),p.jsx("path",{d:"M75.2542 2.94815H73.2542V0.948151H75.2542V2.94815Z",fill:"black"}),p.jsx("path",{d:"M79.3594 2.94815H81.3594V0.948151H79.3594V2.94815Z",fill:"black"}),p.jsx("path",{d:"M87.4645 2.94815H85.4645V0.948151H87.4645V2.94815Z",fill:"black"}),p.jsx("path",{d:"M91.5697 2.94815H93.5697V0.948151H91.5697V2.94815Z",fill:"black"}),p.jsx("path",{d:"M99.6749 2.94815H97.6749V0.948151H99.6749V2.94815Z",fill:"black"}),p.jsx("path",{d:"M103.78 2.94815H105.78V0.948151H103.78V2.94815Z",fill:"black"}),p.jsx("path",{d:"M111.885 2.94815H109.885V0.948151H111.885V2.94815Z",fill:"black"}),p.jsx("path",{d:"M115.991 2.94815H117.991V0.948151H115.991V2.94815Z",fill:"black"})]}),Iu=()=>p.jsx("svg",{width:"120",height:"4",viewBox:"0 0 120 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:p.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 3.86215H-0.0090332V0.862152H119.991V3.86215Z",fill:"black"})}),Ur=()=>p.jsx("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:p.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 1.15668H-0.0090332V0.156677H119.991V1.15668Z",fill:"black"})});function kr(i){const{type:e=l.BorderStyleTypes.THIN}=i;switch(e){case l.BorderStyleTypes.DASH_DOT:return p.jsx(mu,{});case l.BorderStyleTypes.DASH_DOT_DOT:return p.jsx(gu,{});case l.BorderStyleTypes.DASHED:return p.jsx(_u,{});case l.BorderStyleTypes.HAIR:return p.jsx(Su,{});case l.BorderStyleTypes.MEDIUM:return p.jsx(fu,{});case l.BorderStyleTypes.MEDIUM_DASH_DOT:return p.jsx(pu,{});case l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return p.jsx(vu,{});case l.BorderStyleTypes.MEDIUM_DASHED:return p.jsx(Cu,{});case l.BorderStyleTypes.THICK:return p.jsx(Iu,{});case l.BorderStyleTypes.THIN:return p.jsx(Ur,{});default:return p.jsx(Ur,{})}}const Ru="univer-ui-plugin-sheets-border-panel",Mu="univer-ui-plugin-sheets-border-panel-position",bu="univer-ui-plugin-sheets-border-panel-position-item",wu="univer-ui-plugin-sheets-border-panel-styles",Tu="univer-ui-plugin-sheets-border-panel-board",Eu="univer-ui-plugin-sheets-border-panel-button",yu="univer-ui-plugin-sheets-border-panel-more-icon",We={uiPluginSheetsBorderPanel:Ru,uiPluginSheetsBorderPanelPosition:Mu,uiPluginSheetsBorderPanelPositionItem:bu,uiPluginSheetsBorderPanelStyles:wu,uiPluginSheetsBorderPanelBoard:Tu,uiPluginSheetsBorderPanelButton:Eu,uiPluginSheetsBorderPanelMoreIcon:yu},is=`${Et}_BORDER_PANEL_COMPONENT`,rs=[{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:"InnerBorder",value:"horizontal"},{label:"borderLine.borderVertical",icon:"InnerBorder",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"}],Ou=[{label:l.BorderStyleTypes.THIN,value:l.BorderStyleTypes.THIN},{label:l.BorderStyleTypes.HAIR,value:l.BorderStyleTypes.HAIR},{label:l.BorderStyleTypes.DOTTED,value:l.BorderStyleTypes.DOTTED},{label:l.BorderStyleTypes.DASHED,value:l.BorderStyleTypes.DASHED},{label:l.BorderStyleTypes.DASH_DOT,value:l.BorderStyleTypes.DASH_DOT},{label:l.BorderStyleTypes.DASH_DOT_DOT,value:l.BorderStyleTypes.DASH_DOT_DOT},{label:l.BorderStyleTypes.MEDIUM,value:l.BorderStyleTypes.MEDIUM},{label:l.BorderStyleTypes.MEDIUM_DASHED,value:l.BorderStyleTypes.MEDIUM_DASHED},{label:l.BorderStyleTypes.MEDIUM_DASH_DOT,value:l.BorderStyleTypes.MEDIUM_DASH_DOT},{label:l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT,value:l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT},{label:l.BorderStyleTypes.THICK,value:l.BorderStyleTypes.THICK}];function xu(i){var a;const e=K.useDependency(I.ComponentManager),{onChange:t,value:n}=i;function r(c,d){t==null||t({...n,[d]:c})}function o(c){const d=e.get(c);return d&&p.jsx(d,{extend:{colorChannel1:"rgb(var(--primary-color))"}})}function s(c){c.stopPropagation()}return p.jsxs("section",{className:We.uiPluginSheetsBorderPanel,children:[p.jsx("div",{className:We.uiPluginSheetsBorderPanelPosition,children:rs.map(c=>p.jsx("div",{className:We.uiPluginSheetsBorderPanelPositionItem,onClick:()=>r(c.value,"type"),children:o(c.icon)},c.value))}),p.jsxs("div",{className:We.uiPluginSheetsBorderPanelStyles,children:[p.jsx("div",{children:p.jsx(ge.Dropdown,{align:{offset:[0,18]},overlay:p.jsx("section",{className:We.uiPluginSheetsBorderPanelBoard,onClick:s,children:p.jsx(ge.ColorPicker,{onChange:c=>r(c,"color")})}),children:p.jsxs("a",{className:We.uiPluginSheetsBorderPanelButton,onClick:s,children:[p.jsx(il,{extend:{colorChannel1:(a=n.color)!=null?a:"rgb(var(--primary-color))"}}),p.jsx("span",{className:We.uiPluginSheetsBorderPanelMoreIcon,children:p.jsx(wi,{})})]})})}),p.jsx("div",{children:p.jsx(ge.Dropdown,{align:{offset:[0,18]},overlay:p.jsx("section",{onClick:s,children:p.jsx(ge.Menu,{children:Ou.map(c=>p.jsx(ge.MenuItem,{eventKey:c.value.toString(),onClick:()=>r(c.value,"style"),children:p.jsx(kr,{type:c.value})},c.value))})}),children:p.jsxs("a",{className:We.uiPluginSheetsBorderPanelButton,onClick:s,children:[p.jsx(kr,{type:l.BorderStyleTypes.THIN}),p.jsx("span",{className:We.uiPluginSheetsBorderPanelMoreIcon,children:p.jsx(wi,{})})]})})})]})]})}const Au="univer-count-bar",Du={countBar:Au},Nu=[50,80,100,130,150,170,200,400],Hu=100;function Pu(){const i=K.useDependency(l.ICommandService),e=K.useDependency(l.IUniverInstanceService),t=K.useDependency(l.IContextService),n=c(),[r,o]=P.useState(n),a=!ge.useObservable(()=>N.combineLatest(t.subscribeContextValue$(l.FOCUSING_UNIVER_EDITOR),t.subscribeContextValue$(l.EDITOR_ACTIVATED)).pipe(N.map(([u,h])=>u&&!h),N.debounceTime(Hu)),!1,!0,[l.FOCUSING_UNIVER_EDITOR]);P.useEffect(()=>i.onCommandExecuted(h=>{if(h.id===ze.id||h.id===S.SetWorksheetActivateCommand.id){const m=c();o(m)}}).dispose,[i]);function c(){const u=e.getCurrentUniverSheetInstance().getActiveSheet().getZoomRatio()*100||100;return Math.round(u)}function d(u){o(u);const h=e.getCurrentUniverSheetInstance(),m=h==null?void 0:h.getActiveSheet();if(m==null)return;const g=u/100;i.executeCommand(ei.id,{unitId:h.getUnitId(),subUnitId:m.getSheetId(),zoomRatio:g})}return p.jsx(ge.Slider,{disabled:a,min:Ii[0],value:r,shortcuts:Nu,onChange:d})}function Lu(i){return p.jsx("section",{className:Du.countBar,children:p.jsx(Pu,{})})}const Uu="univer-editor-container",ku="univer-editor-input",Vr={editorContainer:Uu,editorInput:ku},zn=-1e3,Br={width:0,height:0,top:zn,left:zn},Vu=()=>{const[i,e]=P.useState({...Br}),t=P.useRef(null),n=K.useDependency(b.IRenderManagerService),r=K.useDependency(tn);return P.useEffect(()=>{const o=t.current;if(!o)return;const s=n.currentRender$.pipe(jr.switchMap(()=>{var c;const a=(c=n.getRenderById(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY))==null?void 0:c.engine;return a==null||a.setContainer(o),r.state$})).subscribe(a=>{if(a==null)return;const{startX:c=zn,startY:d=zn,endX:u=0,endY:h=0,show:m=!1}=a;if(!m)e({...Br});else{e({width:u-c,height:h-d,left:c,top:d});const g=t.current;if(!g)return;const{left:_,top:f,width:v,height:R}=g.getBoundingClientRect();r.setRect({left:_,top:f,width:v,height:R})}});return()=>{s.unsubscribe()}},[]),P.useEffect(()=>{r.setFocus(!0)},[i]),p.jsx("div",{className:Vr.editorContainer,style:{left:i.left,top:i.top,width:i.width,height:i.height},children:p.jsx("div",{className:Vr.editorInput,ref:t})})},Bu="univer-formula-box",Fu="univer-name-ranges",Wu="univer-name-ranges-input",ju="univer-formula-bar",$u="univer-formula-icon",zu="univer-formula-icon-wrapper",Xu="univer-icon-container",Yu="univer-icon-container-success",Zu="univer-formula-active",Gu="univer-icon-container-error",Ku="univer-formula-input",qu="univer-formula-content",Ju="univer-arrow-container",he={formulaBox:Bu,nameRanges:Fu,nameRangesInput:Wu,formulaBar:ju,formulaIcon:$u,formulaIconWrapper:zu,iconContainer:Xu,iconContainerSuccess:Yu,formulaActive:Zu,iconContainerError:Gu,formulaInput:Ku,formulaContent:qu,arrowContainer:Ju};function Qu(){const[i,e]=P.useState(he.formulaGrey),[t,n]=P.useState(0),r=P.useRef(null),o=K.useDependency(b.IRenderManagerService),s=K.useDependency(Jn),a=K.useDependency(Te);P.useEffect(()=>{const m=r.current;if(!m)return;const g=o.currentRender$.subscribe(f=>{var R;if(f!==l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)return;const v=(R=o.getRenderById(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))==null?void 0:R.engine;v==null||v.setContainer(m)}),_=new ResizeObserver(()=>{const f=m.getBoundingClientRect();s.setPosition(f)});return _.observe(m),a.visible$.subscribe(f=>{e(f.visible?he.formulaActive:he.formulaGrey)}),()=>{_.unobserve(m),g.unsubscribe()}},[]);function c(){n(t===0?1:0),setTimeout(()=>{s.handleFoldBtnClick(t===1)},150)}function d(){a.isVisible().visible&&a.changeVisible({visible:!1,eventType:b.DeviceInputEventType.Keyboard,keycode:I.KeyCode.ESC})}function u(){a.isVisible().visible&&a.changeVisible({visible:!1,eventType:b.DeviceInputEventType.PointerDown})}function h(){s.handleFxBtnClick(!0)}return p.jsxs("div",{className:he.formulaBox,style:{height:t===0?"28px":"82px"},children:[p.jsx("div",{className:he.nameRanges,children:p.jsx("div",{className:he.nameRangesInput})}),p.jsxs("div",{className:he.formulaBar,children:[p.jsx("div",{className:he.formulaIcon,children:p.jsxs("div",{className:he.formulaIconWrapper,children:[p.jsx("span",{className:zt(he.iconContainer,he.iconContainerError,i),onClick:d,children:p.jsx($a,{})}),p.jsx("span",{className:zt(he.iconContainer,he.iconContainerSuccess,i),onClick:u,children:p.jsx(jn,{})}),p.jsx("span",{className:he.iconContainer,onClick:h,children:p.jsx(qa,{})})]})}),p.jsxs("div",{className:he.formulaInput,children:[p.jsx("div",{onContextMenu:m=>m.preventDefault(),className:he.formulaContent,ref:r}),p.jsx("div",{className:he.arrowContainer,onClick:c,children:t===0?p.jsx(Ir,{}):p.jsx(Ir,{style:{transform:"rotateZ(180deg)"}})})]})]})]})}const eh="univer-operate-container",th="univer-auto-fill-popup-menu",nh="univer-auto-fill-popup-menu-item",ih="univer-auto-fill-popup-menu-item-icon",rh="univer-auto-fill-popup-menu-item-title",oh="univer-auto-fill-popup-menu-item-hide",sh="univer-btn-container",ah="univer-btn-container-expand",rt={operateContainer:eh,autoFillPopupMenu:th,autoFillPopupMenuItem:nh,autoFillPopupMenuItemIcon:ih,autoFillPopupMenuItemTitle:rh,autoFillPopupMenuItemHide:oh,btnContainer:sh,btnContainerExpand:ah},lh=()=>{const[,i]=P.useState({});return P.useCallback(()=>i(e=>!e),[])},ch=()=>{var re;const i=K.useDependency(l.ICommandService),e=K.useDependency(exports.SheetSkeletonManagerService),t=K.useDependency(l.IUniverInstanceService),n=K.useDependency(b.IRenderManagerService),r=K.useDependency(_e),o=K.useDependency(Jt),s=K.useDependency(l.LocaleService),[a,c]=P.useState([]),[d,u]=P.useState(!1),[h,m]=P.useState({row:-1,col:-1}),[g,_]=P.useState(ie.SERIES),[f,v]=P.useState(!1),R=()=>{v(!0)},M=()=>{v(!1)},T=lh(),w=Ce(t,n);if(w==null)return null;const{scene:E}=w;if(P.useEffect(()=>{const Y=[Pe.id,hn.id,ze.id,S.SetWorksheetActiveOperation.id,S.MoveRangeMutation.id];return i.onCommandExecuted(U=>{U.id===wt.id&&T(),Y.includes(U.id)&&m({row:-1,col:-1})}).dispose},[T,i]),P.useEffect(()=>l.toDisposable(o.menu$.subscribe(L=>{c(L.map(U=>({...U,index:L.indexOf(U)})))})).dispose,[o]),P.useEffect(()=>l.toDisposable(o.showMenu$.subscribe(L=>{const{source:U,target:X}=o.autoFillLocation||{source:null,target:null};if(L&&U&&X){const q=l.Rectangle.union(U,X);m({row:q.endRow,col:q.endColumn})}})).dispose,[o]),P.useEffect(()=>l.toDisposable(o.applyType$.subscribe(L=>{_(L)})).dispose,[o]),P.useEffect(()=>{function Y(){u(!1)}return document.addEventListener("wheel",Y),()=>{document.removeEventListener("wheel",Y)}},[d]),h.col<0||h.row<0)return null;const y=(re=e.getCurrent())==null?void 0:re.skeleton,x=r.getViewPort(),O=E==null?void 0:E.scaleX,A=E==null?void 0:E.scaleY,k=E==null?void 0:E.getScrollXY(x);if(!O||!E||!O||!A||!k)return null;const H=(y==null?void 0:y.getNoMergeCellPositionByIndex(h.row,h.col).endX)||0,B=(y==null?void 0:y.getNoMergeCellPositionByIndex(h.row,h.col).endY)||0,F=y==null?void 0:y.convertTransformToOffsetX(H,O,k),j=y==null?void 0:y.convertTransformToOffsetY(B,A,k);if(F==null||j==null)return null;const z=Y=>{u(Y)},ee=Y=>{i.executeCommand(qo.id,{type:Y.value})},W=d||f,Q=a.filter(Y=>!Y.disable);return p.jsx("div",{onMouseEnter:R,onMouseLeave:M,style:{left:`${F+2}px`,top:`${j+2}px`,position:"absolute"},children:p.jsx(ge.Dropdown,{placement:"bottomLeft",trigger:["click"],overlay:p.jsx("ul",{className:rt.autoFillPopupMenu,children:Q.map(Y=>p.jsxs("li",{onClick:()=>ee(Y),className:rt.autoFillPopupMenuItem,children:[p.jsx("span",{className:rt.autoFillPopupMenuItemIcon,children:Y.value===g&&p.jsx(jn,{style:{color:"rgb(var(--green-700, #409f11))"}})}),p.jsx("span",{className:rt.autoFillPopupMenuItemTitle,children:s.t(Y.label)})]},Y.index))}),visible:d,onVisibleChange:z,children:p.jsxs("div",{className:zt(rt.btnContainer,{[rt.btnContainerExpand]:d}),children:[p.jsx(Fa,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),W&&p.jsx(wi,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},dh=()=>p.jsx("div",{className:rt.operateContainer,children:p.jsx(ch,{})}),uh="univer-sheet-bar",hh="univer-sheet-bar-options",mh="univer-sheet-bar-options-divider",un={sheetBar:uh,sheetBarOptions:hh,sheetBarOptionsDivider:mh},gh="univer-sheet-bar-btn",_h={sheetBarBtn:gh};function Ln(i){const{children:e,className:t,style:n,disabled:r=!1,onClick:o,...s}=i,a=c=>{if(r){c.preventDefault();return}o&&o(c)};return p.jsx("button",{className:_h.sheetBarBtn,style:n,disabled:r,onClick:a,...s,children:e})}const Sh="univer-sheet-bar-menu",fh="univer-sheet-bar-menu-item",ph="univer-sheet-bar-menu-item-icon",vh="univer-sheet-bar-menu-item-hide",Ch="univer-sheet-bar-menu-item-select",Ih="univer-sheet-bar-menu-item-label",Ge={sheetBarMenu:Sh,sheetBarMenuItem:fh,sheetBarMenuItemIcon:ph,sheetBarMenuItemHide:vh,sheetBarMenuItemSelect:Ch,sheetBarMenuItemLabel:Ih};function Rh(i){const{style:e}=i,[t,n]=P.useState([]),[r,o]=P.useState(!1),s=K.useDependency(l.IUniverInstanceService),a=K.useDependency(l.ICommandService),c=K.useDependency(xt),d=s.getCurrentUniverSheetInstance(),u=f=>{const{sheetId:v}=f;v&&(f.hidden?a.executeCommand(S.SetWorksheetShowCommand.id,{value:v}):f.selected||a.executeCommand(S.SetWorksheetActivateCommand.id,{unitId:d.getUnitId(),subUnitId:v}),o(!1))};P.useEffect(()=>{m();const f=new l.DisposableCollection;return f.add(h()),f.add(c.registerSheetBarMenuHandler({handleSheetBarMenu:g})),()=>{f.dispose()}},[]);const h=()=>a.onCommandExecuted(f=>{switch(f.id){case S.SetWorksheetHideMutation.id:case S.RemoveSheetMutation.id:case S.SetWorksheetNameMutation.id:case S.InsertSheetMutation.id:case S.SetWorksheetOrderMutation.id:case S.SetWorksheetActiveOperation.id:m();break}}),m=()=>{const v=d.getSheets().map((R,M)=>({label:R.getName(),index:`${M}`,sheetId:R.getSheetId(),hidden:R.isSheetHidden()===l.BooleanNumber.TRUE,selected:R.getStatus()===l.BooleanNumber.TRUE}));n(v)};function g(){o(!0)}const _=f=>{o(f)};return p.jsx(ge.Dropdown,{placement:"topLeft",trigger:["click"],overlay:p.jsx("ul",{className:Ge.sheetBarMenu,style:{...e},children:t.map(f=>p.jsxs("li",{onClick:()=>u(f),className:f.selected?`${Ge.sheetBarMenuItem} ${Ge.sheetBarMenuItemSelect}`:f.hidden?`${Ge.sheetBarMenuItem} ${Ge.sheetBarMenuItemHide}`:Ge.sheetBarMenuItem,children:[p.jsx("span",{className:Ge.sheetBarMenuItemIcon,children:f.selected?p.jsx(jn,{}):f.hidden?p.jsx(Ga,{}):p.jsx(jn,{})}),p.jsx("span",{className:Ge.sheetBarMenuItemLabel,children:f.label})]},f.index))}),visible:r,onVisibleChange:_,children:p.jsx(Ln,{children:p.jsx(Xa,{})})})}const Mh="univer-slide-tab-bar-container",bh="univer-slide-tab-bar",wh="univer-slide-tab-item",Th="univer-slide-tab-active",Eh="univer-slide-tab-span",yh="univer-slide-tab-span-edit",Oh="univer-slide-tab-item-dropdown",Re={slideTabBarContainer:Mh,slideTabBar:bh,slideTabItem:wh,slideTabActive:Th,slideTabSpan:Eh,slideTabSpanEdit:yh,slideTabItemDropdown:Oh};function xh(i){const{sheetId:e,label:t,color:n,selected:r}=i,[o,s]=P.useState(r),a=K.useDependency(l.ThemeService);P.useEffect(()=>{s(r)},[r]);const c=d=>{const u=a.getCurrentTheme(),h=u.textColor,m=u.colorWhite;return new l.ColorKit(d).isDark()?m:h};return p.jsx("div",{"data-id":e,className:o?`${Re.slideTabActive} ${Re.slideTabItem}`:Re.slideTabItem,style:{backgroundColor:!o&&n?n:"",color:!o&&n?c(n):"",boxShadow:o&&n?`0px 0px 8px rgba(0, 0, 0, 0.08), inset 0px -2px 0px 0px ${n}`:""},children:p.jsx("span",{className:Re.slideTabSpan,children:t})},e)}const Ah={easeOutStrong(i,e,t,n){return-t*((i=i/n-1)*i*i*i-1)+e},backOut(i,e,t,n,r){return typeof r>"u"&&(r=.7),t*((i=i/n-1)*i*((r+1)*i+r)+1)+e}},Dh={loop:!1,begin:0,end:0,duration:300,delay:0,type:"easeOutStrong",receive(i){},success(i){},cancel(i){},complete(i){}};class Nh{constructor(e){C(this,"_config");C(this,"_status",0);C(this,"_start",0);C(this,"_handle",0);C(this,"_delayHandle",null);this._config={...Dh,...e},this._config.loop&&(this._config.complete=()=>{},this._config.success=()=>{this.request()})}static success(...e){let t=0;return new Promise(n=>{for(let r=0;r<e.length;r++){const o=e[r],s=o._config,a=s.success;s.loop||(s.success=d=>{t++,a&&a.call(o,d),t===e.length&&n()})}})}request(){this._config.delay===0?(this._status=0,this._start=Date.now(),this._fakeHandle()):(this._delayHandle&&clearTimeout(this._delayHandle),this._delayHandle=setTimeout(()=>{this._status=0,this._start=Date.now(),this._fakeHandle()},this._config.delay))}cancel(){this._status=1,this._delayHandle&&clearTimeout(this._delayHandle),cancelAnimationFrame(this._handle)}_fakeHandle(){let e=Date.now()-this._start;e=e>=this._config.duration?this._config.duration:e;const n=Ah[this._config.type](e,this._config.begin,this._config.end-this._config.begin,this._config.duration,.7).toFixed(2);if(this._config.receive(n),this._status===1){this._config.cancel(n),this._config.complete(n);return}if(e===this._config.duration){this._config.success(n),this._config.complete(n);return}this._handle=requestAnimationFrame(()=>{this._fakeHandle()})}}class st{constructor(e,t){C(this,"_slideTabItem");C(this,"_animate");C(this,"_midline",0);C(this,"_translateX");C(this,"_scrollbar");C(this,"_slideTabBar");C(this,"_editMode");C(this,"_placeholder");this._slideTabItem=e,this._animate=null,this._translateX=0,this._editMode=!1,this._slideTabBar=t,this._placeholder=null,this._scrollbar=t.getScrollbar(),this.update()}static midline(e){return e.getBoundingRect().x+e.getBoundingRect().width/2}static leftLine(e){return e.getBoundingRect().x}static rightLine(e){return e.getBoundingRect().x+e.getBoundingRect().width}static make(e,t){const n=[];return e.forEach(r=>n.push(new st(r,t))),n}getSlideTabItem(){return this._slideTabItem}getEditor(){return this._slideTabItem.querySelector("span")}focus(){var e;(e=this.getEditor())==null||e.focus()}selectAll(){const e=this.getEditor();e&&Ct.keepSelectAll(e)}isEditMode(){return this._editMode}classList(){return this._slideTabItem.classList}translateX(e){return this._translateX=e,this._slideTabItem.style.transform=`translateX(${e}px)`,this.getTranslateXDirection()}setEditor(e){let t=!0;if(this._editMode===!1){const n=this._slideTabItem.querySelector("span"),r=d=>{if(!this.nameCheck()){if(this._editMode=!1,n&&(n.removeAttribute("contentEditable"),n.removeEventListener("blur",r),n.removeEventListener("compositionstart",s),n.removeEventListener("compositionend",a),n.removeEventListener("input",c),n.removeEventListener("keydown",o),n.classList.remove(this._slideTabBar.getConfig().slideTabBarSpanEditClassName)),this._slideTabBar.removeListener(),this._slideTabBar.updateItems(),this._slideTabBar.getConfig().onChangeName){const u=(n==null?void 0:n.innerText)||"",h=this.getId();this._slideTabBar.getConfig().onChangeName(h,u)}e&&e(d)}};let o=d=>{n&&(d.stopPropagation(),d.key==="Enter"&&n.blur())};const s=d=>{t=!1},a=d=>{t=!0},c=d=>{if(!n)return;const u=50;setTimeout(()=>{if(t){const h=n.innerText;h.length>u&&(n.innerText=h.substring(0,u),Ct.keepLastIndex(n))}},0)};n&&(n.setAttribute("contentEditable","true"),n.addEventListener("blur",r),n.addEventListener("compositionstart",s),n.addEventListener("compositionend",a),n.addEventListener("input",c),n.addEventListener("keydown",o),n.classList.add(this._slideTabBar.getConfig().slideTabBarSpanEditClassName),this._editMode=!0,Ct.keepSelectAll(n))}}nameCheck(){const e=this._slideTabItem.querySelector("span");if(!e)return!1;const t=e.innerText;return this._slideTabBar.getConfig().onNameCheckAlert(t)}animate(){return{translateX:e=>{this._translateX!==e&&(this._animate&&(this._animate.cancel(),this._animate=null),this._animate=new Nh({begin:this._translateX,end:e,receive:t=>{this._slideTabItem.style.transform=`translateX(${t}px)`}}),this._translateX=e,this._animate.request())},cancel:()=>{this._animate&&(this._animate.cancel(),this._animate=null)}}}after(e){this._slideTabItem.after(e._slideTabItem||e)}update(){this._midline=st.midline(this)}disableFixed(){if(this._placeholder){const e=this._slideTabBar.primeval();this._slideTabItem.style.removeProperty("position"),this._slideTabItem.style.removeProperty("left"),this._slideTabItem.style.removeProperty("top"),this._slideTabItem.style.removeProperty("width"),this._slideTabItem.style.removeProperty("height"),this._slideTabItem.style.removeProperty("background"),this._slideTabItem.style.removeProperty("padding"),this._slideTabItem.style.removeProperty("box-sizing"),this._slideTabItem.style.removeProperty("font-size"),this._slideTabItem.style.removeProperty("font-family"),this._slideTabItem.style.removeProperty("font-weight"),this._slideTabItem.style.removeProperty("color"),this._slideTabItem.style.removeProperty("border-radius"),this._placeholder.after(this._slideTabItem),e.removeChild(this._placeholder),this._placeholder=null}}enableFixed(){const e=document.createElement("div"),t=this.getBoundingRect(),n=getComputedStyle(this._slideTabItem),r=this._slideTabItem.querySelector("span");if(this._placeholder=e,this._placeholder.style.width=`${t.width}px`,this._placeholder.style.height=`${t.height}px`,this._placeholder.style.flexShrink="0",this._placeholder.style.margin=n.margin,this._slideTabItem.style.background=n.background,r){const o=getComputedStyle(r).padding;this._slideTabItem.style.padding=o}this._slideTabItem.style.boxSizing=n.boxSizing,this._slideTabItem.style.fontSize=n.fontSize,this._slideTabItem.style.fontFamily=n.fontFamily,this._slideTabItem.style.fontWeight=n.fontWeight,this._slideTabItem.style.color=n.color,this._slideTabItem.style.borderRadius=n.borderRadius,this._slideTabItem.style.left=`${t.x-this.getScrollbar().getScrollX()}px`,this._slideTabItem.style.top=`${t.y}px`,this._slideTabItem.style.width=`${t.width}px`,this._slideTabItem.style.height=`${t.height}px`,this._slideTabItem.style.position="fixed",this._slideTabItem.after(e),document.body.appendChild(this._slideTabItem)}addEventListener(e,t,n){this._slideTabItem.addEventListener(e,t,n)}removeEventListener(e,t,n){this._slideTabItem.removeEventListener(e,t,n)}getScrollbar(){return this._scrollbar}getMidLine(){return this._midline}getBoundingRect(){const e=this._slideTabItem.getBoundingClientRect();return e.x+=this._scrollbar.getScrollX(),e}getWidth(){return this.getBoundingRect().width}getTranslateXDirection(){const e=st.midline(this);return e>this._midline?1:e<this._midline?-1:0}equals(e){return e&&e._slideTabItem===this._slideTabItem}getId(){return this._slideTabItem.dataset.id||""}}class Hh{constructor(e){C(this,"_slideTabBar");C(this,"_scrollX");const t=e.primeval();this._scrollX=t.scrollLeft,this._slideTabBar=e}scrollX(e){const t=this._slideTabBar.primeval();t.scrollLeft=e,this._scrollX=t.scrollLeft}scrollRight(){const e=this._slideTabBar.primeval();e.scrollLeft=e.scrollWidth,this._scrollX=e.scrollLeft}getScrollX(){return this._scrollX}}const ft=class ft{constructor(e){C(this,"_activeTabItemIndex",0);C(this,"_slideTabBar");C(this,"_slideTabItems",[]);C(this,"_config");C(this,"_downActionX",0);C(this,"_moveActionX",0);C(this,"_compareIndex",0);C(this,"_activeTabItem",null);C(this,"_moveAction");C(this,"_upAction");C(this,"_downAction");C(this,"_wheelAction");C(this,"_scrollIncremental",0);C(this,"_compareDirection",0);C(this,"_autoScrollTime",null);C(this,"_slideScrollbar");C(this,"_longPressTimer",null);C(this,"_leftBoundingLine",0);C(this,"_rightBoundingLine",0);C(this,"_leftMoveX",0);C(this,"_rightMoveX",0);var s;if(e.slideTabBarContainer==null)throw new Error("not found slide-tab-bar root element");const t=e.slideTabBarContainer.querySelector(`.${(s=e.slideTabBarClassName)!=null?s:"slide-tab-bar"}`);if(t==null)throw new Error("not found slide-tab-bar");this._slideTabBar=t,this._slideScrollbar=new Hh(this),this._config=e,this._initConfig();let n=0,r=0,o=0;this._downAction=a=>{var y,x,O,A,k,H;if((y=this._activeTabItem)!=null&&y.isEditMode())return;const c=(O=(x=a.target)==null?void 0:x.closest(`.${e.slideTabBarItemClassName}`))==null?void 0:O.getAttribute("data-id"),d=this._slideTabItems.findIndex(B=>B.getId()===c);if(c==null||d===-1)return;if(this._activeTabItemIndex!==d){(A=this._activeTabItem)==null||A.removeEventListener("pointermove",this._moveAction),(k=this._activeTabItem)==null||k.removeEventListener("pointerup",this._upAction),this.removeListener(),this._config.onChangeTab(a,c);return}if(this._compareIndex=d,this._downActionX=a.pageX,this._moveActionX=0,this._scrollIncremental=0,this._activeTabItem=this._slideTabItems[d],!this._activeTabItem){console.error("Not found active slide-tab-item in sheet bar");return}const u=this._activeTabItem.getSlideTabItem();u==null||u.setPointerCapture(a.pointerId),(H=this._activeTabItem)==null||H.addEventListener("pointerup",this._upAction);const{x:h,width:m}=this._activeTabItem.getBoundingRect(),{x:g,width:_}=this.getBoundingRect(),f=this._slideScrollbar.getScrollX();if(this._leftBoundingLine=this._downActionX-(h-f),this._rightBoundingLine=h-f+m-this._downActionX,this._leftMoveX=h-g-f,this._rightMoveX=g+_-(h+m)+f,a.button===2||this._hasEditItem())return;const{pageX:v,pageY:R}=a,M=Date.now(),T=M-o<=ft.DoubleClickDelay,w=Math.abs(v-n)<10,E=Math.abs(R-r)<10;T&&w&&E&&this._activeTabItem.setEditor(),n=v,r=R,o=M,this._longPressTimer=setTimeout(()=>{var B,F;(B=this._activeTabItem)==null||B.enableFixed(),this._startAutoScroll(),u&&(u.setPointerCapture(a.pointerId),u.style.cursor="move",(F=this._activeTabItem)==null||F.addEventListener("pointermove",this._moveAction))},ft.LongPressDelay)},this._upAction=a=>{var d,u,h;if(this._longPressTimer&&(clearTimeout(this._longPressTimer),this._longPressTimer=null),!this._activeTabItem)return;this._closeAutoScroll(),this._activeTabItem.disableFixed(),this.updateItems();const c=(d=this._activeTabItem)==null?void 0:d.getSlideTabItem();c&&(c.style.cursor="",c.releasePointerCapture(a.pointerId),(u=this._activeTabItem)==null||u.removeEventListener("pointermove",this._moveAction),(h=this._activeTabItem)==null||h.removeEventListener("pointerup",this._upAction),this._config.onSlideEnd&&this._activeTabItemIndex!==this._compareIndex&&(this.removeListener(),this._config.onSlideEnd(a,this._compareIndex||0)),this._scrollIncremental=0,this._downActionX=0,this._moveActionX=0,this._compareIndex=0)},this._moveAction=a=>{this._activeTabItem&&(this._moveActionX=a.pageX-this._downActionX,this._moveActionX<=-this._leftMoveX?this._moveActionX=-this._leftMoveX:this._moveActionX>=this._rightMoveX&&(this._moveActionX=this._rightMoveX),this._scrollIncremental=0,this._scrollLeft(a),this._scrollRight(a))},this._wheelAction=a=>{this.setScroll(a.deltaY)},this.addListener()}static checkedSkipSlide(e){let t=e.target;for(;t!=null&&t!==document.body;){if(t.getAttribute("data-slide-skip"))return!0;t=t.parentElement}return!1}static keepLastIndex(e){setTimeout(()=>{const t=window.getSelection();t&&(t.selectAllChildren(e),t.collapseToEnd())})}static keepSelectAll(e){setTimeout(()=>{const t=window.getSelection();if(!t)return;const n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)})}update(e){this._config.currentIndex=e,this._initConfig(),this.removeListener(),this.addListener()}primeval(){return this._slideTabBar}updateItems(){for(let e=0;e<this._slideTabItems.length;e++)this._slideTabItems[e].animate().cancel(),this._slideTabItems[e].translateX(0),this._slideTabItems[e].update()}getScrollbar(){return this._slideScrollbar}getConfig(){return this._config}getBoundingRect(){return this._slideTabBar.getBoundingClientRect()}getSlideTabItems(){return this._slideTabItems}getActiveItem(){return this._activeTabItem}isLeftEnd(){return this._slideTabBar.scrollLeft===0}isRightEnd(){const e=this._slideTabBar.parentElement;return e?this._slideTabBar.scrollWidth-e.clientWidth===this._slideTabBar.scrollLeft:!1}addListener(){this._slideTabBar.addEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(e=>{e.addEventListener("pointerdown",this._downAction)})}removeListener(){this._slideTabBar.removeEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(e=>{e.removeEventListener("pointerdown",this._downAction)})}setScroll(e){if(this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e),e>0){const t=this.calculateLeftScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}else if(e<0){const t=this.calculateRightScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}flipPage(e){if(e>0){const t=this.calculateLeftScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}else if(e<0){const t=this.calculateRightScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}calculateLeftScrollX(e){let t=0;const n=4;return this._slideTabItems.some(r=>{const o=this._slideTabBar.getBoundingClientRect(),s=o.left+o.width,a=r.getSlideTabItem().getBoundingClientRect(),c=a.left,d=a.width;return c<s&&c+d+n*2>s?(t=e?c-o.left-n:c+d-s+n,!0):!1}),t}calculateRightScrollX(e){let t=0;const n=4;return this._slideTabItems.some(r=>{const o=this._slideTabBar.getBoundingClientRect(),s=o.left,a=r.getSlideTabItem().getBoundingClientRect(),c=a.left,d=a.width;return c-n*2<s&&c+d>s?(t=e?c+d-o.left-o.width+n:c-s-n,!0):!1}),t}destroy(){this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=[],this._activeTabItem=null,this.removeListener()}_hasEditItem(){for(let e=0;e<this._slideTabItems.length;e++)if(this._slideTabItems[e].isEditMode())return!0;return!1}_autoScrollFrame(){if(this._activeTabItem)switch(this._compareDirection=this._activeTabItem.translateX(this._moveActionX),this._compareDirection){case 1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareRight();break}case 0:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareIndex=this._activeTabItemIndex;break}case-1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareLeft();break}}this._autoScrollTime=requestAnimationFrame(()=>{this._autoScrollFrame()})}_startAutoScroll(){this._autoScrollTime==null&&this._autoScrollFrame()}_closeAutoScroll(){this._autoScrollTime&&cancelAnimationFrame(this._autoScrollTime),this._autoScrollTime=null}_scrollLeft(e){const t=this.getBoundingRect(),n=e.pageX-t.x;n<this._leftBoundingLine&&(this._scrollIncremental=-Math.min(Math.abs(n-this._leftBoundingLine)*.1,50))}_scrollRight(e){const t=this.getBoundingRect(),n=e.pageX-t.x;n>t.width-this._rightBoundingLine&&(this._scrollIncremental=Math.min(Math.abs(n-(t.width-this._rightBoundingLine))*.1,50))}_sortedItems(){if(this._activeTabItem!=null&&this._activeTabItemIndex!=null&&this._compareIndex!=null&&(this._slideTabItems.splice(this._activeTabItemIndex,1),this._slideTabItems.splice(this._compareIndex,0,this._activeTabItem),this._config.slideTabBarItemAutoSort))for(let e=0;e<this._slideTabItems.length;e++){const t=this._slideTabItems[e],n=this._slideTabItems[e+1];n&&t.after(n)}}_compareLeft(){if(this._activeTabItem&&this._activeTabItemIndex){const e=this._slideTabItems.findIndex(o=>o.equals(this._activeTabItem)),t=this._slideTabItems.length,n=[];for(let o=0;o<e&&!(o>=e);o++)n.push(this._slideTabItems[o]);for(let o=e+1;o<t;o++)this._slideTabItems[o].animate().translateX(0);let r=!0;for(let o=n.length-1;o>=0;o--){const s=n[o];st.leftLine(this._activeTabItem)<s.getMidLine()?(s.animate().translateX(this._activeTabItem.getWidth()),this._compareIndex=o,r=!1):(s.animate().translateX(0),r&&(this._compareIndex=this._activeTabItemIndex))}}}_compareRight(){if(this._activeTabItem){const e=this._slideTabItems.findIndex(o=>o.equals(this._activeTabItem)),t=this._slideTabItems.length,n=[];for(let o=e+1;o<t;o++)n.push(this._slideTabItems[o]);for(let o=0;o<e;o++)this._slideTabItems[o].animate().translateX(0);let r=!0;for(let o=0;o<n.length;o++){const s=n[o];st.rightLine(this._activeTabItem)>s.getMidLine()?(s.animate().translateX(-this._activeTabItem.getWidth()),this._compareIndex=e+o+1,r=!1):(s.animate().translateX(0),r&&(this._compareIndex=this._activeTabItemIndex))}}}_initConfig(){var t;const e=this._slideTabBar.querySelectorAll(`.${(t=this._config.slideTabBarItemClassName)!=null?t:"slide-tab-item"}`);this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=st.make(e,this),this._activeTabItemIndex=this._config.currentIndex,this._activeTabItem=this._slideTabItems[this._activeTabItemIndex]}};C(ft,"LongPressDelay",500),C(ft,"DoubleClickDelay",300);let Ct=ft;function Ph(){const[i,e]=P.useState([]),[t,n]=P.useState(""),[r,o]=P.useState(""),[s,a]=P.useState(!1),[c,d]=P.useState([0,0]),u=P.useRef({slideTabBar:null}),h=P.useRef(null),m=K.useDependency(l.IUniverInstanceService),g=K.useDependency(l.ICommandService),_=K.useDependency(xt),f=K.useDependency(l.LocaleService),v=K.useDependency(I.IConfirmService),R=K.useDependency(_e),M=K.useDependency(Te),T=K.useInjector(),w=m.getCurrentUniverSheetInstance();P.useEffect(()=>{B();const L=E(),U=H(),X=[F(),j(),z(),ee()];return()=>{U.dispose(),L.destroy(),X.forEach(q=>q.unsubscribe())}},[]),P.useEffect(()=>{i.length>0&&k()},[i]);const E=()=>{const L=new Ct({slideTabBarClassName:Re.slideTabBar,slideTabBarItemActiveClassName:Re.slideTabActive,slideTabBarItemClassName:Re.slideTabItem,slideTabBarSpanEditClassName:Re.slideTabSpanEdit,slideTabBarItemAutoSort:!0,slideTabBarContainer:h.current,currentIndex:0,onChangeName:(U,X)=>{g.executeCommand(S.SetWorksheetNameCommand.id,{subUnitId:U,name:X})},onSlideEnd:(U,X)=>{g.executeCommand(S.SetWorksheetOrderCommand.id,{order:X})},onChangeTab:(U,X)=>{g.executeCommand(S.SetWorksheetActivateCommand.id,{subUnitId:X,unitId:w.getUnitId()}).then(()=>{U.button===2&&Y(!0)}),setTimeout(()=>{T.get(b.ITextSelectionRenderManager).focus()},0)},onScroll:U=>{_.setScroll(U)},onNameCheckAlert:U=>y(U)||x(U)});return u.current.slideTabBar=L,re(L),L},y=L=>{if(L.trim()===""){const U="sheetNameEmptyAlert";return v.open({id:U,title:{title:f.t("sheetConfig.sheetNameErrorTitle")},children:{title:f.t("sheetConfig.sheetNameCannotIsEmptyError")},cancelText:f.t("button.cancel"),confirmText:f.t("button.confirm"),onClose(){O(),v.close(U)},onConfirm(){O(),v.close(U)}}),!0}return!1},x=L=>{const U=m.getCurrentUniverSheetInstance();if(U.getActiveSheet().getName()===L)return!1;const oe=U.checkSheetName(L);if(oe){const $="sheetNameRepeatAlert";v.open({id:$,title:{title:f.t("sheetConfig.sheetNameErrorTitle")},children:{title:f.t("sheetConfig.sheetNameAlreadyExistsError")},cancelText:f.t("button.cancel"),confirmText:f.t("button.confirm"),onClose(){v.close($),O()},onConfirm(){v.close($),O()}})}return oe},O=()=>{R.endSelection(),setTimeout(()=>{var U;const L=(U=u.current.slideTabBar)==null?void 0:U.getActiveItem();L&&(L.focus(),L.selectAll())},0)},A=()=>{var L,U;(U=(L=u.current.slideTabBar)==null?void 0:L.getActiveItem())==null||U.setEditor()},k=()=>{var U;const L=i.findIndex(X=>X.selected);(U=u.current.slideTabBar)==null||U.update(L)},H=()=>g.onCommandExecuted(L=>{switch(L.id){case S.SetTabColorMutation.id:case S.SetWorksheetHideMutation.id:case S.RemoveSheetMutation.id:case S.SetWorksheetNameMutation.id:case S.InsertSheetMutation.id:case S.SetWorksheetOrderMutation.id:case S.SetWorksheetActiveOperation.id:B();break}}),B=()=>{const L=w.getActiveSheet().getSheetId();n(L);const X=w.getSheets().filter(q=>!q.isSheetHidden()).map((q,oe)=>{var $;return{sheetId:q.getSheetId(),label:q.getName(),index:oe,selected:q.getStatus()===l.BooleanNumber.TRUE,color:($=q.getTabColor())!=null?$:void 0}});e(X)},F=()=>_.scroll$.subscribe(L=>{W(L)}),j=()=>_.scrollX$.subscribe(L=>{var U;(U=u.current.slideTabBar)==null||U.flipPage(L)}),z=()=>_.renameId$.subscribe(()=>{A()}),ee=()=>_.addSheet$.subscribe(()=>{var L;(L=u.current.slideTabBar)==null||L.getScrollbar().scrollRight()}),W=L=>{const{leftEnd:U,rightEnd:X}=L;let q="";U&&X?q="":U&&!X?q="inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!U&&X?q="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!U&&!X&&(q="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2), inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)"),o(q)},Q=L=>{_.setScroll({leftEnd:L.isLeftEnd(),rightEnd:L.isRightEnd()})},re=L=>{var q;const U=(q=h.current)==null?void 0:q.querySelector(`.${Re.slideTabBar}`);if(!U)return;new ResizeObserver(()=>{Q(L)}).observe(U)},Y=L=>{var U,X,q,oe,$;if(!M.isForceKeepVisible()){if(L){const{left:Z}=(X=(U=h.current)==null?void 0:U.getBoundingClientRect())!=null?X:{},{left:G}=($=(oe=(q=u.current.slideTabBar)==null?void 0:q.getActiveItem())==null?void 0:oe.getSlideTabItem().getBoundingClientRect())!=null?$:{};Z!==void 0&&G!==void 0&&d([G-Z,0])}a(L)}};return p.jsx(ge.Dropdown,{className:Re.slideTabItemDropdown,visible:s,align:{offset:c},trigger:["contextMenu"],overlay:p.jsx(I.Menu,{menuType:ce.SHEET_BAR,onOptionSelect:L=>{const{label:U,value:X}=L;g.executeCommand(U,{value:X,subUnitId:t}),a(!1)}}),onVisibleChange:Y,children:p.jsx("div",{className:Re.slideTabBarContainer,ref:h,children:p.jsx("div",{className:Re.slideTabBar,style:{boxShadow:r},children:i.map(L=>P.createElement(xh,{...L,key:L.sheetId,selected:t===L.sheetId}))})})})}const Fr=100,Lh=()=>{const[i,e]=P.useState(!0),[t,n]=P.useState(!0),r=K.useDependency(l.ICommandService),o=K.useDependency(xt);P.useEffect(()=>{const u=o.scroll$.subscribe(h=>{s(h)});return()=>{u.unsubscribe()}},[]);const s=u=>{const{leftEnd:h,rightEnd:m}=u;e(h),n(m)},a=()=>{r.executeCommand(S.InsertSheetCommand.id),setTimeout(()=>{o.setAddSheet(0)},0)},c=()=>{o.setScrollX(-Fr)},d=()=>{o.setScrollX(Fr)};return p.jsxs("div",{className:un.sheetBar,children:[p.jsxs("div",{className:un.sheetBarOptions,children:[p.jsx(Ln,{onClick:a,children:p.jsx(Qa,{})}),p.jsx(Rh,{})]}),p.jsx(Ph,{}),(!i||!t)&&p.jsxs("div",{className:`${un.sheetBarOptions} ${un.sheetBarOptionsDivider}`,children:[p.jsx(Ln,{disabled:i,onClick:c,children:p.jsx(Rr,{style:{transform:"rotateZ(180deg)"}})}),p.jsx(Ln,{disabled:t,onClick:d,children:p.jsx(Rr,{})})]})]})};class Uh{constructor(){C(this,"_functions",[{func:te.FUNCTION_NAMES_STATISTICAL.MAX,filter:e=>{var t,n,r,o;return((n=(t=e.values.find(s=>s.func===te.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)!=null?n:0)>1&&((o=(r=e.values.find(s=>s.func===te.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:r.value)!=null?o:0)>0}},{func:te.FUNCTION_NAMES_STATISTICAL.MIN,filter:e=>{var t,n,r,o;return((n=(t=e.values.find(s=>s.func===te.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)!=null?n:0)>1&&((o=(r=e.values.find(s=>s.func===te.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:r.value)!=null?o:0)>0}},{func:te.FUNCTION_NAMES_MATH.SUM,filter:e=>{var t,n,r,o;return((n=(t=e.values.find(s=>s.func===te.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)!=null?n:0)>1&&((o=(r=e.values.find(s=>s.func===te.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:r.value)!=null?o:0)>0}},{func:te.FUNCTION_NAMES_STATISTICAL.COUNTA,filter:e=>{var t,n;return((n=(t=e.values.find(r=>r.func===te.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)!=null?n:0)>1}},{func:te.FUNCTION_NAMES_STATISTICAL.COUNT,filter:e=>{var t,n,r,o;return((n=(t=e.values.find(s=>s.func===te.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)!=null?n:0)>1&&((o=(r=e.values.find(s=>s.func===te.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:r.value)!=null?o:0)>0}},{func:te.FUNCTION_NAMES_STATISTICAL.AVERAGE,filter:e=>{var t,n,r,o;return((n=(t=e.values.find(s=>s.func===te.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)!=null?n:0)>1&&((o=(r=e.values.find(s=>s.func===te.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:r.value)!=null?o:0)>0}}]);C(this,"_state$",new N.BehaviorSubject(null));C(this,"state$",this._state$.asObservable())}dispose(){this._state$.complete()}setState(e){var n;const t={values:[],pattern:null};e==null||e.values.forEach(r=>{const o=this._functions.find(s=>s.func===r.func);o&&(o.filter===void 0||o.filter(e))&&t.values.push(r)}),t.pattern=(n=e==null?void 0:e.pattern)!=null?n:null,this._state$.next(t)}getState(){return this._state$.getValue()}getFunctions(){return this._functions}addFunctions(e){this._functions.push(...e)}}const qi=D.createIdentifier("univer.sheet-status-bar.service"),kh="univer-status-bar",Vh="univer-single-mode",Bh="univer-status-bar-div",Fh="univer-statistic-list",Wh="univer-statistic-list-column",jh="univer-statistic-item",$h="univer-statistic-picker",zh="univer-statistic-picker-item",Xh="univer-statistic-more",_t={statusBar:kh,singleMode:Vh,statusBarDiv:Bh,statisticList:Fh,statisticListColumn:Wh,statisticItem:jh,statisticPicker:$h,statisticPickerItem:zh,statisticMore:Xh},Yh=[te.FUNCTION_NAMES_MATH.SUM,te.FUNCTION_NAMES_STATISTICAL.AVERAGE,te.FUNCTION_NAMES_STATISTICAL.MIN,te.FUNCTION_NAMES_STATISTICAL.MAX],Si={[te.FUNCTION_NAMES_MATH.SUM]:"statusbar.sum",[te.FUNCTION_NAMES_STATISTICAL.AVERAGE]:"statusbar.average",[te.FUNCTION_NAMES_STATISTICAL.MIN]:"statusbar.min",[te.FUNCTION_NAMES_STATISTICAL.MAX]:"statusbar.max",[te.FUNCTION_NAMES_STATISTICAL.COUNT]:"statusbar.count",[te.FUNCTION_NAMES_STATISTICAL.COUNTA]:"statusbar.countA",[te.FUNCTION_NAMES_TEXT.CONCATENATE]:"concatenate"},fi=i=>{const e=K.useDependency(l.LocaleService),t=K.useDependency(I.IMessageService),n=K.useDependency(I.IClipboardInterfaceService),r=Zh(i),o=async()=>{await n.writeText(i.value.toString()),t.show({type:ge.MessageType.Success,content:e.t("statusbar.copied")})};return p.jsx(ge.Tooltip,{title:e.t("statusbar.clickToCopy"),placement:"top",children:p.jsx("div",{className:_t.statisticItem,onClick:o,children:p.jsx("span",{children:`${e.t((Si==null?void 0:Si[i.name])||i.name)}: ${r}`})},i.name)})};function Zh(i){const{pattern:e,value:t}=i;return typeof t!="number"?"Invalid input":t>=1e8?t.toExponential(2):e&&Yh.includes(i.name)?as.format(e,t):t.toLocaleString()}const Wr=800,Gh=3,Kh=()=>{const[i,e]=P.useState(window.innerWidth<Wr),[t,n]=P.useState(!0),r=K.useDependency(qi),o=r.getFunctions().map((m,g)=>({name:m.func,value:0,show:!0,disable:!1,pattern:null})),[s,a]=P.useState(o),c=s.find(m=>m.show&&!m.disable),d=i&&c?[c]:s.filter(m=>m.show&&!m.disable);P.useEffect(()=>{const m=r.state$.subscribe(g=>{const _=g==null?void 0:g.values;if(!_||_.length===0)n(!1);else{n(!0);const f=s.map(v=>{var M;const R=_.find(T=>T.func===v.name);return R?(v.value=R.value,v.disable=!1):v.disable=!0,v.pattern=(M=g==null?void 0:g.pattern)!=null?M:null,v});a(f)}});return()=>{m.unsubscribe()}},[r]);const u=qh(()=>{const m=window.innerWidth<Wr;i!==m&&e(m)},100);P.useEffect(()=>(window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}),[i]);let h=null;if(d.length>Gh){const m=[];d.forEach((g,_)=>{_%2===0&&m.push(d.slice(_,_+2))}),h=p.jsxs(p.Fragment,{children:[" ",m.map((g,_)=>p.jsxs("div",{className:_t.statisticListColumn,children:[(g==null?void 0:g[0])&&p.jsx(fi,{...g==null?void 0:g[0]},g==null?void 0:g[0].name),(g==null?void 0:g[1])&&p.jsx(fi,{...g==null?void 0:g[1]},g==null?void 0:g[1].name)]},`stat-col-${_}`))," "]})}else h=p.jsx(p.Fragment,{children:d.map(m=>p.jsx(fi,{...m},m.name))});return t&&p.jsxs("div",{className:zt(_t.statusBar,{[_t.singleMode]:i}),children:[p.jsx("div",{className:zt(_t.statisticList),children:h}),p.jsx("div",{className:_t.statusBarDiv})]})};function qh(i,e){let t;return function(...n){const r=this,o=function(){t=null,i.apply(r,n)};clearTimeout(t),t=setTimeout(o,e)}}function Jh(){return p.jsxs("section",{className:Xo.sheetContainer,"data-range-selector":!0,children:[p.jsx(Lh,{}),p.jsx(Kh,{}),p.jsx(Lu,{})]})}function Qh(){return p.jsx(p.Fragment,{children:p.jsx(Qu,{})})}function em(){return p.jsxs(p.Fragment,{children:[p.jsx(Vu,{}),p.jsx(dh,{})]})}function tm(i){const e=i.get(S.BorderStyleManagerService),t=S.getCurrentSheetDisabled$(i);return{id:S.SetBorderBasicCommand.id,icon:new N.Observable(n=>{const r="AllBorderSingle",o=i.get(S.BorderStyleManagerService),s=i.get(l.ICommandService).onCommandExecuted(a=>{var m;if(a.id!==S.SetBorderBasicCommand.id)return;const{type:d}=o.getBorderInfo(),u=rs.find(g=>g.value===d),h=(m=u==null?void 0:u.icon)!=null?m:r;n.next(h)});return n.next(r),s.dispose}),group:I.MenuGroup.TOOLBAR_FORMAT,tooltip:"toolbar.border.main",positions:[I.MenuPosition.TOOLBAR_START],type:I.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:is,hoverable:!1},value$:e.borderInfo$}],value$:e.borderInfo$,hidden$:I.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:t}}const ti="sheet.menu.clear-selection";function nm(){return{id:ti,group:I.MenuGroup.CONTEXT_MENU_FORMAT,type:I.MenuItemType.SUBITEMS,icon:"ClearFormat",title:"rightClick.clearSelection",positions:[I.MenuPosition.CONTEXT_MENU,ce.COL_HEADER_CONTEXT_MENU,ce.ROW_HEADER_CONTEXT_MENU]}}function im(){return{id:S.ClearSelectionContentCommand.id,type:I.MenuItemType.BUTTON,title:"rightClick.clearContent",positions:[ti]}}function rm(){return{id:S.ClearSelectionFormatCommand.id,type:I.MenuItemType.BUTTON,title:"rightClick.clearFormat",positions:[ti]}}function om(){return{id:S.ClearSelectionAllCommand.id,type:I.MenuItemType.BUTTON,title:"rightClick.clearAll",positions:[ti]}}const nn="sheet.menu.delete";function sm(){return{id:nn,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.SUBITEMS,title:"rightClick.delete",icon:"Reduce",positions:[I.MenuPosition.CONTEXT_MENU]}}function am(){return{id:Qo.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,icon:"DeleteColumn",positions:[nn,ce.COL_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedColumn"}}function lm(){return{id:Jo.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,icon:"DeleteRow",positions:[nn,ce.ROW_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedRow"}}function cm(){return{id:Yi.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,title:"rightClick.moveLeft",icon:"DeleteCellShiftLeft",positions:[nn]}}function dm(){return{id:Zi.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,title:"rightClick.moveUp",icon:"DeleteCellShiftUp",positions:[nn]}}const Ji="sheet.menu.col-insert";function um(){return{id:Ji,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[ce.COL_HEADER_CONTEXT_MENU]}}const Qi="sheet.menu.row-insert";function hm(){return{id:Qi,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[ce.ROW_HEADER_CONTEXT_MENU]}}const rn="sheet.menu.cell-insert";function mm(){return{id:rn,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[I.MenuPosition.CONTEXT_MENU]}}function gm(i){const e=i.get(S.SelectionManagerService);return{id:S.InsertRowBeforeCommand.id,type:I.MenuItemType.BUTTON,title:"rightClick.insertRowBefore",icon:"InsertRowAbove",positions:[Qi,rn],hidden$:new N.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function _m(i){const e=i.get(S.SelectionManagerService);return{id:S.InsertRowAfterCommand.id,type:I.MenuItemType.BUTTON,positions:[Qi],title:"rightClick.insertRow",icon:"InsertRowBelow",hidden$:new N.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function Sm(i){const e=i.get(S.SelectionManagerService);return{id:S.InsertColBeforeCommand.id,type:I.MenuItemType.BUTTON,positions:[Ji,rn],title:"rightClick.insertColumnBefore",icon:"LeftInsertColumn",hidden$:new N.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function fm(i){const e=i.get(S.SelectionManagerService);return{id:S.InsertColAfterCommand.id,type:I.MenuItemType.BUTTON,positions:[Ji],title:"rightClick.insertColumn",icon:"RightInsertColumn",hidden$:new N.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function pm(){return{id:Ki.id,type:I.MenuItemType.BUTTON,title:"rightClick.moveRight",icon:"InsertCellShiftRight",positions:[rn]}}function vm(){return{id:Gi.id,type:I.MenuItemType.BUTTON,title:"rightClick.moveDown",icon:"InsertCellDown",positions:[rn]}}function Cm(i){const e=S.getCurrentSheetDisabled$(i);return{id:Xe.id,icon:"MergeAllSingle",tooltip:"toolbar.mergeCell.main",positions:[I.MenuPosition.TOOLBAR_START],group:I.MenuGroup.TOOLBAR_LAYOUT,type:I.MenuItemType.SUBITEMS,hidden$:I.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:e}}function Im(i){return{id:Zo.id,type:I.MenuItemType.BUTTON,title:"merge.all",icon:"MergeAllSingle",positions:[Xe.id]}}function Rm(i){return{id:Go.id,type:I.MenuItemType.BUTTON,title:"merge.vertical",icon:"VerticalIntegrationSingle",positions:[Xe.id]}}function Mm(i){return{id:Ko.id,type:I.MenuItemType.BUTTON,title:"merge.horizontal",icon:"HorizontalMergeSingle",positions:[Xe.id]}}function bm(i){return{id:S.RemoveWorksheetMergeCommand.id,type:I.MenuItemType.BUTTON,title:"merge.cancel",icon:"CancelMergeSingle",positions:[Xe.id]}}function wm(i){const e=i.get(l.IUniverInstanceService),t=i.get(l.ICommandService);return{id:es.id,type:I.MenuItemType.BUTTON,positions:[ce.SHEET_BAR],title:"sheetConfig.delete",disabled$:new N.Observable(n=>{const r=t.onCommandExecuted(o=>{const s=o.id;if(s===S.RemoveSheetMutation.id||s===S.InsertSheetMutation.id||s===S.SetWorksheetHideMutation.id){const a=e.getCurrentUniverSheetInstance().getWorksheets(),c=Array.from(a.values()).filter(d=>d.getConfig().hidden===l.BooleanNumber.FALSE);n.next(c.length===1)}});return n.next(!1),r.dispose})}}function Tm(){return{id:S.CopySheetCommand.id,type:I.MenuItemType.BUTTON,positions:[ce.SHEET_BAR],title:"sheetConfig.copy"}}function Em(){return{id:ns.id,type:I.MenuItemType.BUTTON,positions:[ce.SHEET_BAR],title:"sheetConfig.rename"}}function ym(){return{id:S.SetTabColorCommand.id,title:"sheetConfig.changeColor",positions:[ce.SHEET_BAR],type:I.MenuItemType.SELECTOR,selections:[{label:{name:qn,hoverable:!1}}]}}function Om(i){const e=i.get(l.IUniverInstanceService),t=i.get(l.ICommandService);return{id:S.SetWorksheetHideCommand.id,type:I.MenuItemType.BUTTON,positions:[ce.SHEET_BAR],title:"sheetConfig.hide",disabled$:new N.Observable(n=>{const r=t.onCommandExecuted(o=>{const s=o.id;if(s===S.RemoveSheetMutation.id||s===S.InsertSheetMutation.id||s===S.SetWorksheetHideMutation.id){const a=e.getCurrentUniverSheetInstance().getWorksheets(),c=Array.from(a.values()).filter(d=>d.getConfig().hidden===l.BooleanNumber.FALSE);n.next(c.length===1)}});return n.next(!1),r.dispose})}}function xm(i){const e=i.get(l.IUniverInstanceService),t=i.get(l.ICommandService);return{id:ts.id,type:I.MenuItemType.BUTTON,positions:[ce.SHEET_BAR],title:"sheetConfig.unhide",disabled$:new N.Observable(n=>{const r=t.onCommandExecuted(o=>{const s=o.id;if(s===S.RemoveSheetMutation.id||s===S.InsertSheetMutation.id||s===S.SetWorksheetHideMutation.id){const a=e.getCurrentUniverSheetInstance().getWorksheets(),c=Array.from(a.values());n.next(c.length===1)}});return n.next(!1),r.dispose})}}const Am={id:S.SetRowHiddenCommand.id,preconditions:i=>ne(i),binding:I.KeyCode.Digit9|I.MetaKeys.CTRL_COMMAND},Dm={id:S.SetColHiddenCommand.id,preconditions:i=>ne(i),binding:I.KeyCode.Digit0|I.MetaKeys.CTRL_COMMAND|I.MetaKeys.SHIFT},Nm={id:we.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:I.KeyCode.ARROW_DOWN,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.DOWN}},Hm={id:we.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:I.KeyCode.ARROW_UP,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.UP}},Pm={id:we.id,description:"shortcut.sheet.select-left-cell",group:"3_sheet-view",binding:I.KeyCode.ARROW_LEFT,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.LEFT}},Lm={id:we.id,description:"shortcut.sheet.select-right-cell",group:"3_sheet-view",binding:I.KeyCode.ARROW_RIGHT,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.RIGHT}},Um={id:lt.id,description:"shortcut.sheet.select-next-cell",group:"3_sheet-view",binding:I.KeyCode.TAB,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.RIGHT,keycode:I.KeyCode.TAB}},km={id:lt.id,description:"shortcut.sheet.select-previous-cell",group:"3_sheet-view",binding:I.KeyCode.TAB|I.MetaKeys.SHIFT,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.LEFT,keycode:I.KeyCode.TAB}},Vm={id:lt.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:I.KeyCode.ENTER,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.DOWN,keycode:I.KeyCode.ENTER}},Bm={id:lt.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:I.KeyCode.ENTER|I.MetaKeys.SHIFT,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.UP,keycode:I.KeyCode.ENTER}},Fm={id:we.id,description:"shortcut.sheet.select-below-value-cell",group:"3_sheet-view",binding:I.KeyCode.ARROW_DOWN|I.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.DOWN,jumpOver:Le.moveGap}},Wm={id:we.id,description:"shortcut.sheet.select-up-value-cell",group:"3_sheet-view",binding:I.KeyCode.ARROW_UP|I.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.UP,jumpOver:Le.moveGap}},jm={id:we.id,description:"shortcut.sheet.select-left-value-cell",group:"3_sheet-view",binding:I.KeyCode.ARROW_LEFT|I.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.LEFT,jumpOver:Le.moveGap}},$m={id:we.id,description:"shortcut.sheet.select-right-value-cell",group:"3_sheet-view",binding:I.KeyCode.ARROW_RIGHT|I.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.RIGHT,jumpOver:Le.moveGap}},zm={id:Ue.id,description:"shortcut.sheet.expand-selection-down",group:"3_sheet-view",binding:I.KeyCode.ARROW_DOWN|I.MetaKeys.SHIFT,preconditions:ne,staticParameters:{direction:l.Direction.DOWN}},Xm={id:Ue.id,description:"shortcut.sheet.expand-selection-up",group:"3_sheet-view",binding:I.KeyCode.ARROW_UP|I.MetaKeys.SHIFT,preconditions:ne,staticParameters:{direction:l.Direction.UP}},Ym={id:Ue.id,description:"shortcut.sheet.expand-selection-left",group:"3_sheet-view",binding:I.KeyCode.ARROW_LEFT|I.MetaKeys.SHIFT,preconditions:ne,staticParameters:{direction:l.Direction.LEFT}},Zm={id:Ue.id,description:"shortcut.sheet.expand-selection-right",group:"3_sheet-view",binding:I.KeyCode.ARROW_RIGHT|I.MetaKeys.SHIFT,preconditions:ne,staticParameters:{direction:l.Direction.RIGHT}},Gm={id:Ue.id,description:"shortcut.sheet.expand-selection-to-below-gap",group:"3_sheet-view",binding:I.KeyCode.ARROW_DOWN|I.MetaKeys.SHIFT|I.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.DOWN,jumpOver:Le.moveGap}},Km={id:Ue.id,description:"shortcut.sheet.expand-selection-to-up-gap",group:"3_sheet-view",binding:I.KeyCode.ARROW_UP|I.MetaKeys.SHIFT|I.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.UP,jumpOver:Le.moveGap}},qm={id:Ue.id,description:"shortcut.sheet.expand-selection-to-left-gap",group:"3_sheet-view",binding:I.KeyCode.ARROW_LEFT|I.MetaKeys.SHIFT|I.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.LEFT,jumpOver:Le.moveGap}},Jm={id:Ue.id,description:"shortcut.sheet.expand-selection-to-right-gap",group:"3_sheet-view",binding:I.KeyCode.ARROW_RIGHT|I.MetaKeys.SHIFT|I.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.RIGHT,jumpOver:Le.moveGap}},Qm={id:ho.id,description:"shortcut.sheet.select-all",group:"3_sheet-view",binding:I.KeyCode.A|I.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{expandToGapFirst:!0,loop:!0}},eg={id:Vi.id,description:"shortcut.sheet.set-bold",group:"4_sheet-edit",preconditions:i=>ne(i),binding:I.KeyCode.B|I.MetaKeys.CTRL_COMMAND},tg={id:Bi.id,description:"shortcut.sheet.set-italic",group:"4_sheet-edit",preconditions:i=>ne(i),binding:I.KeyCode.I|I.MetaKeys.CTRL_COMMAND},ng={id:Fi.id,description:"shortcut.sheet.set-underline",group:"4_sheet-edit",preconditions:i=>ne(i),binding:I.KeyCode.U|I.MetaKeys.CTRL_COMMAND},ig={id:Wi.id,description:"shortcut.sheet.set-strike-through",group:"4_sheet-edit",preconditions:i=>ne(i),binding:I.KeyCode.X|I.MetaKeys.SHIFT|I.MetaKeys.CTRL_COMMAND},rg={id:S.ClearSelectionContentCommand.id,preconditions:i=>ne(i),binding:I.KeyCode.DELETE,mac:I.KeyCode.BACKSPACE},og={id:Qn.id,description:"shortcut.sheet.zoom-in",binding:I.KeyCode.EQUAL|I.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",preconditions:ne,priority:1,staticParameters:{delta:.2}},sg={id:l.NilCommand.id,binding:I.KeyCode.EQUAL|I.MetaKeys.CTRL_COMMAND},ag={id:Qn.id,description:"shortcut.sheet.zoom-out",binding:I.KeyCode.MINUS|I.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",preconditions:ne,priority:1,staticParameters:{delta:-.2}},lg={id:l.NilCommand.id,binding:I.KeyCode.MINUS|I.MetaKeys.CTRL_COMMAND},cg={id:Qn.id,description:"shortcut.sheet.reset-zoom",binding:I.KeyCode.Digit0|I.MetaKeys.CTRL_COMMAND,preconditions:ne,group:"3_sheet-view",priority:1,staticParameters:{reset:!0}},dg={id:l.NilCommand.id,binding:I.KeyCode.Digit0|I.MetaKeys.CTRL_COMMAND};var ug=Object.defineProperty,hg=Object.getOwnPropertyDescriptor,mg=(i,e,t,n)=>{for(var r=n>1?void 0:n?hg(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&ug(e,t,r),r},gt=(i,e)=>(t,n)=>e(t,n,i);let Un=class extends l.Disposable{constructor(i,e,t,n,r,o){super(),this._injector=i,this._componentManager=e,this._commandService=t,this._shortcutService=n,this._menuService=r,this._uiController=o,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(zi,Nl)),this.disposeWithMe(i.register(is,xu)),this.disposeWithMe(i.register(qn,ge.ColorPicker)),this.disposeWithMe(i.register(Bo,I.FontFamily)),this.disposeWithMe(i.register(Fo,I.FontFamilyItem)),this.disposeWithMe(i.register(Wo,I.FontSize))}_initCommands(){[Zo,Xe,Ko,Go,Qn,Ue,we,lt,ns,es,Jo,Qo,Oo,xo,pt,ho,Yo,Zn,S.SetBoldCommand,Gt,Pe,Vi,Bi,Fi,Wi,Ml,bl,Ao,Do,$n,S.SetItalicCommand,S.SetStrikeThroughCommand,S.SetFontFamilyCommand,S.SetFontSizeCommand,ji,Po,$i,Lo,wt,wn,Kn,Uo,ko,Vo,S.SetUnderlineCommand,ei,ze,ts,qo,Gi,Zi,Ki,Yi].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initMenus(){[Gl,Kl,ql,Jl,Ql,ec,tc,im,rm,om,nm,um,hm,mm,gm,_m,Sm,fm,lm,cc,uc,dc,hc,am,mc,nc,gc,sm,cm,dm,pm,vm,oc,sc,ac,lc,ic,rc,Hl,Pl,Ll,Ul,kl,Vl,Bl,Fl,Wl,jl,$l,tm,Cm,Im,Rm,Mm,bm,zl,Xl,Yl,Zl,wm,Tm,Em,ym,Om,xm].forEach(i=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i)))})}_initShortcuts(){[Nm,Hm,Pm,Lm,Um,km,Vm,Bm,Fm,Wm,jm,$m,zm,Xm,Ym,Zm,Gm,Km,qm,Jm,Qm,og,ag,cg,dg,sg,lg,eg,tg,ng,ig,rg,...Hc(),Pc,Lc,kc,Vc,Bc,Uc,Am,Dm].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_initWorkbenchParts(){this.disposeWithMe(this._uiController.registerHeaderComponent(()=>K.connectInjector(Qh,this._injector))),this.disposeWithMe(this._uiController.registerFooterComponent(()=>K.connectInjector(Jh,this._injector))),this.disposeWithMe(this._uiController.registerContentComponent(()=>K.connectInjector(em,this._injector)))}_init(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts(),this._initWorkbenchParts()}};Un=mg([l.OnLifecycle(l.LifecycleStages.Ready,Un),gt(0,D.Inject(D.Injector)),gt(1,D.Inject(I.ComponentManager)),gt(2,l.ICommandService),gt(3,I.IShortcutService),gt(4,I.IMenuService),gt(5,I.IUIController)],Un);var gg=Object.defineProperty,_g=Object.getOwnPropertyDescriptor,Sg=(i,e,t,n)=>{for(var r=n>1?void 0:n?_g(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&gg(e,t,r),r},nt=(i,e)=>(t,n)=>e(t,n,i);let kn=class extends l.Disposable{constructor(e,t,n,r,o,s,a){super();C(this,"_calculateTimeout",-1);this._univerInstanceService=e,this._selectionManagerService=t,this._functionService=n,this._statusBarService=r,this._commandService=o,this._formulaDataModel=s,this._numfmtService=a,this._init()}_init(){this._registerSelectionListener()}_registerSelectionListener(){this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoving$.subscribe(e=>{var t;((t=this._selectionManagerService.getCurrent())==null?void 0:t.pluginName)===S.NORMAL_SELECTION_PLUGIN_NAME&&e&&(clearTimeout(this._calculateTimeout),this._calculateTimeout=setTimeout(()=>{const n=e[e.length-1].primary;this._calculateSelection(e.map(r=>r.range),n)},100))}))),this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(e=>{var t;if(((t=this._selectionManagerService.getCurrent())==null?void 0:t.pluginName)===S.NORMAL_SELECTION_PLUGIN_NAME&&e){const n=e[e.length-1].primary;this._calculateSelection(e.map(r=>r.range),n)}}))),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===S.SetRangeValuesMutation.id){const t=this._selectionManagerService.getSelections();t&&(clearTimeout(this._calculateTimeout),this._calculateTimeout=setTimeout(()=>{this._calculateSelection(t.map(n=>n.range))},100))}}))}_calculateSelection(e,t){var c;const n=this._univerInstanceService.getCurrentUniverSheetInstance(),r=n.getUnitId(),o=n.getActiveSheet().getSheetId(),s={},a=this._formulaDataModel.getArrayFormulaCellData();if(this._univerInstanceService.getCurrentUniverSheetInstance().getSheets().forEach(d=>{const u=d.getConfig();s[d.getSheetId()]={cellData:new l.ObjectMatrix(u.cellData),rowCount:u.rowCount,columnCount:u.columnCount}}),e!=null&&e.length){const d=e.map(f=>new te.RangeReferenceObject(f,o,r));d.forEach(f=>{f.setUnitData({[r]:s}),a&&f.setArrayFormulaCellData(te.convertUnitDataToRuntime(a))});const h=this._statusBarService.getFunctions().map(f=>{const v=this._functionService.getExecutor(f.func);if(!v)return;const R=d.map(T=>T.toArrayValueObject(!1));if((v==null?void 0:v.calculate(...R)).getValue)return{func:f.func,value:(v==null?void 0:v.calculate(...R)).getValue()}});if(h.every(f=>f===void 0))return;let m=null;if(t){const{actualRow:f,actualColumn:v}=t;m=(c=this._numfmtService.getValue(r,o,f,v))==null?void 0:c.pattern}const _={values:h.filter(f=>f!==void 0),pattern:m};this._statusBarService.setState(_)}else this._statusBarService.setState(null)}_isSingleCell(e){return e.startRow===e.endRow&&e.startColumn===e.endColumn}};kn=Sg([l.OnLifecycle(l.LifecycleStages.Ready,kn),nt(0,l.IUniverInstanceService),nt(1,D.Inject(S.SelectionManagerService)),nt(2,te.IFunctionService),nt(3,qi),nt(4,l.ICommandService),nt(5,D.Inject(te.FormulaDataModel)),nt(6,D.Inject(S.INumfmtService))],kn);var fg=Object.defineProperty,pg=Object.getOwnPropertyDescriptor,vg=(i,e,t,n)=>{for(var r=n>1?void 0:n?pg(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&fg(e,t,r),r},it=(i,e)=>(t,n)=>e(t,n,i);let Vn=class extends l.Disposable{constructor(i,e,t,n,r,o,s){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._selectionRenderService=r,this._selectionManagerService=o,this._scrollManagerService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._zoomEventBinding()}_zoomEventBinding(){var e;const i=(e=this._getSheetObject())==null?void 0:e.scene;i!=null&&(i.getViewport(V.VIEW_MAIN),this.disposeWithMe(l.toDisposable(i.onMouseWheelObserver.add((t,n)=>{if(!t.ctrlKey)return;const r=Math.abs(t.deltaX);let o=r<40?.2:r<80?.4:.2;o*=t.deltaY>0?-1:1,i.scaleX<1&&(o/=2);const s=this._currentUniverService.getCurrentUniverSheetInstance(),a=s.getActiveSheet(),c=a.getZoomRatio();let d=+Number.parseFloat(`${c+o}`).toFixed(1);d=d>=4?4:d<=.1?.1:d,this._commandService.executeCommand(ei.id,{zoomRatio:Math.round(d*10)/10,unitId:s.getUnitId(),subUnitId:a.getSheetId()}),t.preventDefault()}))))}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeletonBefore$.subscribe(i=>{if(i==null)return;const n=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getZoomRatio()||1;this._updateViewZoom(n)})))}_commandExecutedListener(){const i=[ze.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet(),r=e.params,{unitId:o,subUnitId:s}=r;if(!(o===t.getUnitId()&&s===n.getSheetId()))return;const a=n.getConfig().zoomRatio||1;this._updateViewZoom(a)}}))}_updateViewZoom(i){const e=this._getSheetObject();e==null||e.scene.scale(i,i),e==null||e.spreadsheet.makeForceDirty()}_getSheetObject(){return Ce(this._currentUniverService,this._renderManagerService)}};Vn=vg([l.OnLifecycle(l.LifecycleStages.Rendered,Vn),it(0,D.Inject(exports.SheetSkeletonManagerService)),it(1,l.IUniverInstanceService),it(2,l.ICommandService),it(3,b.IRenderManagerService),it(4,_e),it(5,D.Inject(S.SelectionManagerService)),it(6,D.Inject(Je))],Vn);var Cg=Object.defineProperty,Ig=Object.getOwnPropertyDescriptor,Rg=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ig(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Cg(e,t,r),r},Ft=(i,e)=>(t,n)=>e(t,n,i);exports.SheetCanvasView=class extends l.RxDisposable{constructor(t,n,r,o,s){super();C(this,"_scene");C(this,"_currentWorkbook");C(this,"_loadedMap",new Set);C(this,"_isLoadedEditor",!1);C(this,"_fps$",new N.BehaviorSubject(""));C(this,"fps$",this._fps$.asObservable());this._currentUniverService=t,this._commandService=n,this._renderManagerService=r,this._selectionRenderService=o,this._sheetSkeletonManagerService=s,this._currentUniverService.currentSheet$.subscribe(a=>{if(a==null)return;const c=a.getUnitId();this._loadedMap.has(c)||(this._currentWorkbook=a,this._addNewRender(),this._loadedMap.add(c))})}dispose(){this._fps$.complete()}_addNewRender(){const t=this._currentWorkbook,n=t.getUnitId(),r=t.getContainer(),o=t.getParentRenderUnitId();if(r!=null&&o!=null)throw new Error("container or parentRenderUnitId can only exist one");const s=r==null&&o!=null;s?this._renderManagerService.createRenderWithParent(n,o):this._renderManagerService.createRender(n);const a=this._renderManagerService.getRenderById(n);if(a==null)return;const{scene:c,engine:d}=a;c.openTransformer(),this._scene=c,c.addLayer(new b.Layer(c,[],0),new b.Layer(c,[],2)),a!=null&&this._addComponent(a),t.getShouldRenderLoopImmediately()&&!s&&d.runRenderLoop(()=>{c.render(),this._fps$.next(Math.round(d.getFps()).toString())}),this._renderManagerService.setCurrent(n)}_addComponent(t){const n=this._scene,r=this._currentWorkbook,o=r.getActiveSheet(),s=r.getUnitId(),a=o.getSheetId();this._addViewport(o);const c=new b.Spreadsheet(Se.MAIN),d=new b.SpreadsheetRowHeader(Se.ROW),u=new b.SpreadsheetColumnHeader(Se.COLUMN),h=new b.Rect(Se.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});t.mainComponent=c,t.components.set(Se.MAIN,c),t.components.set(Se.ROW,d),t.components.set(Se.COLUMN,u),t.components.set(Se.LEFT_TOP,h),n.addObjects([c],dr),n.addObjects([d,u,h],qe),n.enableLayerCache(dr,qe),this._sheetSkeletonManagerService.setCurrent({sheetId:a,unitId:s})}_addViewport(t){const n=this._scene;if(n==null)return;const{rowHeader:r,columnHeader:o}=t.getConfig(),s=new b.Viewport(V.VIEW_MAIN,n,{left:r.width,top:o.height,bottom:0,right:0,isWheelPreventDefaultX:!0});return new b.Viewport(V.VIEW_ROW_TOP,n,{active:!1,isWheelPreventDefaultX:!0}),new b.Viewport(V.VIEW_ROW_BOTTOM,n,{left:0,top:o.height,bottom:0,width:r.width,isWheelPreventDefaultX:!0}),new b.Viewport(V.VIEW_COLUMN_LEFT,n,{active:!1,isWheelPreventDefaultX:!0}),new b.Viewport(V.VIEW_COLUMN_RIGHT,n,{left:r.width,top:0,height:o.height,right:0,isWheelPreventDefaultX:!0}),new b.Viewport(V.VIEW_LEFT_TOP,n,{left:0,top:0,width:r.width,height:o.height,isWheelPreventDefaultX:!0}),new b.Viewport(V.VIEW_MAIN_LEFT_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),new b.Viewport(V.VIEW_MAIN_LEFT,n,{isWheelPreventDefaultX:!0,active:!1}),new b.Viewport(V.VIEW_MAIN_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),n.onMouseWheelObserver.add((a,c)=>{if(a.ctrlKey)return;let d=0,u=0;const h=s.limitedScroll();if(a.inputIndex===b.PointerInput.MouseWheelX){const g=Math.abs(a.deltaX);a.deltaX>0?d=g:d=-g,this._commandService.executeCommand(wn.id,{offsetX:d}),n.getParent().classType===b.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedX||c.stopPropagation():s.isWheelPreventDefaultX?a.preventDefault():h!=null&&h.isLimitedX||a.preventDefault()}if(a.inputIndex===b.PointerInput.MouseWheelY){let g=Math.abs(a.deltaY);a.shiftKey?(g*=3,a.deltaY>0?d=g:d=-g,this._commandService.executeCommand(wn.id,{offsetX:d}),n.getParent().classType===b.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedX||c.stopPropagation():s.isWheelPreventDefaultX?a.preventDefault():h!=null&&h.isLimitedX||a.preventDefault()):(a.deltaY>0?u=g:u=-g,this._commandService.executeCommand(wn.id,{offsetY:u}),n.getParent().classType===b.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedY||c.stopPropagation():s.isWheelPreventDefaultY?a.preventDefault():h!=null&&h.isLimitedY||a.preventDefault())}a.inputIndex,b.PointerInput.MouseWheelZ,this._scene.makeDirty(!0)}),new b.ScrollBar(s),n.attachControl(),s}};exports.SheetCanvasView=Rg([l.OnLifecycle(l.LifecycleStages.Ready,exports.SheetCanvasView),Ft(0,l.IUniverInstanceService),Ft(1,l.ICommandService),Ft(2,b.IRenderManagerService),Ft(3,_e),Ft(4,D.Inject(exports.SheetSkeletonManagerService))],exports.SheetCanvasView);var Mg=Object.defineProperty,bg=Object.getOwnPropertyDescriptor,wg=(i,e,t,n)=>{for(var r=n>1?void 0:n?bg(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Mg(e,t,r),r},pi=(i,e)=>(t,n)=>e(t,n,i),vi;exports.UniverSheetsUIPlugin=(vi=class extends l.Plugin{constructor(e,t,n,r){super(Yr),this._injector=t,this._localeService=n,this._currentUniverService=r,this._localeService.load({zhCN:jo})}onStarting(e){[[exports.SheetCanvasView],[Yt],[Te,{useClass:exports.EditorBridgeService}],[Mt,{useClass:exports.SheetClipboardService}],[xt,{useClass:hu}],[Tt,{useClass:Ti}],[tn,{useClass:$o}],[Jn,{useClass:fc}],[Jt,{useClass:exports.AutoFillService}],[Je],[exports.SheetSkeletonManagerService],[_e,{useClass:exports.SelectionRenderService}],[qi,{useClass:Uh}],[qt,{useClass:exports.MarkSelectionService}],[gn],[_n],[Mn],[vn],[Cn],[bn],[Tn],[En],[yn],[On],[xn],[In],[Dn],[vt],[Hn],[Sn],[fn],[Nn],[Pn],[Un],[Rn],[Vn],[exports.AutoFillController],[kn],[pn],[An]].forEach(t=>e.add(t))}onReady(){this._markSheetAsFocused()}_markSheetAsFocused(){const e=this._currentUniverService;e.currentSheet$.pipe(jr.filter(t=>!!t)).subscribe(t=>{e.focusUniverInstance(t.getUnitId())})}},C(vi,"type",l.PluginType.Sheet),vi);exports.UniverSheetsUIPlugin=wg([pi(1,D.Inject(D.Injector)),pi(2,D.Inject(l.LocaleService)),pi(3,l.IUniverInstanceService)],exports.UniverSheetsUIPlugin);exports.APPLY_TYPE=ie;exports.AutoFillCommand=Kr;exports.COPY_TYPE=ot;exports.CellEditorManagerService=$o;exports.DATA_TYPE=de;exports.DefaultRightMenuConfig=$r;exports.DefaultSheetContainerConfig=Xr;exports.DefaultSheetUIConfig=ls;exports.DefaultToolbarConfig=zr;exports.ExpandSelectionCommand=Ue;exports.IAutoFillService=Jt;exports.ICellEditorManagerService=tn;exports.IEditorBridgeService=Te;exports.IFormulaEditorManagerService=Jn;exports.IMarkSelectionService=qt;exports.ISelectionRenderService=_e;exports.ISheetClipboardService=Mt;exports.JumpOver=Le;exports.MoveSelectionCommand=we;exports.PASTE_SPECIAL_MENU_ID=Ot;exports.PREDEFINED_HOOK_NAME=fe;exports.RangeSelector=dl;exports.SHEET_UI_PLUGIN_NAME=Yr;exports.SelectionShape=Wn;exports.SetCellEditVisibleArrowOperation=Gt;exports.SetEditorResizeOperation=Zn;exports.SetScrollOperation=wt;exports.SetZoomRatioOperation=ze;exports.SheetCopyCommand=io;exports.SheetPasteCommand=bt;exports.VIEWPORT_KEY=V;exports.enUS=_c;exports.getAutoFillRepeatRange=Rs;exports.getCoordByCell=Ei;exports.getCoordByOffset=Rt;exports.getEditorObject=Yn;exports.getRepeatRange=Sc;exports.getSheetObject=Ce;exports.getTransformCoord=mn;exports.whenFormulaEditorActivated=bs;exports.zhCN=jo;
|