@univerjs/sheets-ui 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +11 -11
- package/lib/es/index.js +3883 -3821
- package/lib/index.css +1 -1
- package/lib/types/commands/operations/cell-edit.operation.d.ts +1 -0
- package/lib/types/controllers/editor/end-edit.controller.d.ts +1 -1
- package/lib/types/controllers/shortcuts/editor.shortcut.d.ts +1 -0
- package/lib/types/controllers/shortcuts/utils.d.ts +1 -0
- package/lib/types/services/canvas-pop-manager.service.d.ts +5 -5
- package/lib/types/services/editor/cell-editor-manager.service.d.ts +1 -1
- package/lib/types/services/hover-manager.service.d.ts +1 -1
- package/lib/umd/index.js +11 -11
- package/package.json +24 -24
package/lib/umd/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
(function(x,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@wendellhu/redi"),require("rxjs"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("@univerjs/docs"),require("rxjs/operators"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@wendellhu/redi/react-bindings"),require("react"),require("clsx"),require("@univerjs/engine-numfmt")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/ui","@wendellhu/redi","rxjs","@univerjs/docs-ui","@univerjs/engine-render","@univerjs/docs","rxjs/operators","@univerjs/design","@univerjs/engine-formula","@wendellhu/redi/react-bindings","react","clsx","@univerjs/engine-numfmt"],l):(x=typeof globalThis<"u"?globalThis:x||self,l(x.UniverSheetsUi={},x.UniverCore,x.UniverSheets,x.UniverUi,x["@wendellhu/redi"],x.rxjs,x.UniverDocsUi,x.UniverEngineRender,x.UniverDocs,x.rxjs.operators,x.UniverDesign,x.UniverEngineFormula,x["@wendellhu/redi/react-bindings"],x.React,x.clsx,x.UniverEngineNumfmt))})(this,function(x,l,f,C,P,V,ri,w,te,vs,le,G,K,H,xe,Cs){"use strict";var Xm=Object.defineProperty;var $m=(x,l,f)=>l in x?Xm(x,l,{enumerable:!0,configurable:!0,writable:!0,value:f}):x[l]=f;var I=(x,l,f)=>($m(x,typeof l!="symbol"?l+"":l,f),f);var io;const lo="SheetUI";function hn(i,t){if(i==null)return;const e=t.getRenderById(i);if(e==null)return;const{mainComponent:n,scene:o,engine:r}=e;return{document:n,scene:o,engine:r}}const si={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},mn=["零","一","二","三","四","五","六","七","八","九"],co=["","万","亿","万亿","亿亿"],Is=["","十","百","千"],uo={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function Ye(i){if(!i)return 0;let t=0,e=0,n=0,o=!1;const r=i.split("");for(let s=0;s<r.length;s++){const a=si[r[s]];if(typeof a<"u")n=a,s===r.length-1&&(e+=n);else{const c=uo[r[s]],d=c.value;o=c.secUnit,o?(e=(e+n)*d,t+=e,e=0):e+=n*d,n=0}}return t+e}function Ms(i){let t="",e="",n=0,o=!0;for(;i>0;){const r=i%10;r===0?o||(o=!0,e=mn[r]+e):(o=!1,t=mn[r],t+=Is[n],e=t+e),n++,i=Math.floor(i/10)}return e}function Rs(i){let t=0,e="",n="",o=!1;if(i===0)return mn[0];for(;i>0;){const r=i%1e4;o&&(n=mn[0]+n),e=Ms(r),e+=r!==0?co[t]:co[0],n=e+n,o=r<1e3&&r>0,i=Math.floor(i/1e4),t++}return n}function bs(i){if(!i)return!1;let t=!0;if(i)if(i.length===1)i==="日"||i in si?t=!0:t=!1;else{const e=i.split("");for(let n=0;n<e.length;n++)if(!(e[n]in si||e[n]in uo)){t=!1;break}}return t}function Sn(i){if(!i)return{isExtendNumber:!1};const t=/0|([1-9]+[0-9]*)/g,e=t.test(i);if(e){const n=i.match(t);if(n&&n.length>0){const o=n[n.length-1],r=i.lastIndexOf(o),s=i.substr(0,r),a=i.substr(r+o.length);return{isExtendNumber:!0,matchTxt:Number(o),beforeTxt:s,afterTxt:a}}return{isExtendNumber:!1}}return{isExtendNumber:e}}function ws(i){let t;return i.length===2&&(i==="周一"||i==="周二"||i==="周三"||i==="周四"||i==="周五"||i==="周六"||i==="周日")?t=!0:t=!1,t}function Ts(i){let t;return i.length===3&&(i==="星期一"||i==="星期二"||i==="星期三"||i==="星期四"||i==="星期五"||i==="星期六"||i==="星期日")?t=!0:t=!1,t}function Es(i,t){let e=0;for(let n=0;n<i.length&&i[n]<t;n++)e++;return e}function Dt(i){let t=!0;const e=i[1]-i[0];for(let n=1;n<i.length;n++)if(i[n]-i[n-1]!==e){t=!1;break}return t}function ys(i,t,e){const n=[],o=Math.floor(t/i),r=t%i;let s=0;if(o>0){for(let a=0;a<o;a++)for(let c=0;c<e.length;c++)n[e[c]+a*i]=s,s++;for(let a=0;a<e.length&&e[a]<r;a++)n[e[a]+i*o]=s,s++}else for(let a=0;a<e.length&&e[a]<r;a++)n[e[a]]=s,s++;return n}function rt(i,t){const e=[];for(let n=1;n<=t;n++){const o=(n-1)%i.length,r=l.Tools.deepClone(i[o]);e.push({v:null,s:null,p:null,f:null,si:null,t:null,...r})}return e}function Os(i,t){var n;const e=[];for(let o=1;o<=t;o++){const r=(o-1)%i.length,s={s:(n=i[r])==null?void 0:n.s};e.push(s)}return e}function xs(i){let t=!0;const e=i[1]/i[0];for(let n=1;n<i.length;n++)if(i[n]/i[n-1]!==e){t=!1;break}return t}function Ns(i){const t=[];for(let e=1;e<=i;e++)t.push(e);return t}function ho(i,t,e){var r,s,a,c;const n=[],o=[];for(let d=0;d<i.length;d++)o.push(Number((r=i[d])==null?void 0:r.v));if(i.length>2&&xs(o))for(let d=1;d<=t;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.t!==l.CellValueType.BOOLEAN&&(h.v=m),n.push(h))}else{const d=Ns(i.length);for(let u=1;u<=t;u++){const h=(u-1)%i.length,m=l.Tools.deepClone(i[h]),S=e===l.Direction.DOWN||e===l.Direction.RIGHT,_=As(i.length+u,o,d,S);m&&(m.t!==l.CellValueType.BOOLEAN&&(m.v=_),n.push(m))}}return n}function As(i,t,e,n=!0){function o(h){let m=0;for(let S=0;S<h.length;S++)m+=h[S];return m/h.length}const r=o(e),s=o(t);let a=0,c=0;for(let h=0;h<e.length;h++)a+=(e[h]-r)*(t[h]-s),c+=(e[h]-r)*(e[h]-r);let d;c===0?d=n?1:-1:d=a/c;const u=s-d*r;return Math.round((u+d*i)*1e5)/1e5}function mo(i,t,e){var r;const n=[],o=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=t;s++){const a=(s-1)%i.length,c=l.Tools.deepClone(i[a]),d=`${(r=i[i.length-1])==null?void 0:r.v}`,u=d==null?void 0:d.match(o),h=u==null?void 0:u[u.length-1],m=Math.abs(Number(h)+e*s);if(!d||!h)continue;const S=d.lastIndexOf(h),_=d.substr(0,S)+m.toString()+d.substr(S+h.length);c&&(c.v=_,n.push(c))}return n}function ft(i,t,e,n=0){var a,c;const o=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(n>=o.length)return[];const r=o[n],s=[];for(let d=1;d<=t;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)===r[0])m=7+e*d;else{const _=`${(c=i[i.length-1])==null?void 0:c.v}`;if(_){const g=_.substr(_.length-1,1);m=Ye(g)+e*d}}m<0&&(m=Math.ceil(Math.abs(m)/7)*7+m);const S=m%7;h&&(h.v=r[S],s.push(h))}return s}function So(i,t,e){var o;const n=[];for(let r=1;r<=t;r++){const s=(r-1)%i.length,a=l.Tools.deepClone(i[s]),c=`${(o=i[i.length-1])==null?void 0:o.v}`,d=Ye(c)+e*r;let u;d<=0?u="零":u=Rs(d),a&&(a.v=u,n.push(a))}return n}const Pt={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 Ds(i){let t=!1;return Object.keys(Pt).forEach(e=>{Pt[e].includes(i)&&(t=!0)}),t}function ai(i){let t="";const e=[];return Object.keys(Pt).forEach(n=>{Pt[n].includes(i)&&(t=n,e.push(...Pt[n]))}),{name:t,series:e}}function _o(i,t,e,n){var s;const o=n.length,r=[];for(let a=1;a<=t;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)+e*a;h<0&&(h+=Math.abs(e)*o);const m=h%o;d&&(d.v=n[m],r.push(d))}return r}function Ps(i,t){const e=[];let n;if(t.startRow<i.startRow)n=l.Direction.UP;else if(t.endRow>i.endRow)n=l.Direction.DOWN;else if(t.startColumn<i.startColumn)n=l.Direction.LEFT;else if(t.endColumn>i.endColumn)n=l.Direction.RIGHT;else return[];if(n===l.Direction.DOWN||n===l.Direction.UP){const o=i.endRow-i.startRow+1,r=t.endRow-t.startRow+1,s=Math.floor(r/o),a=r%o,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++)e.push({repeatStartCell:{row:i.startRow+(d+1)*o,col:i.startColumn},relativeRange:c});a>0&&e.push({repeatStartCell:{row:i.startRow+(s+1)*o,col:i.startColumn},relativeRange:{startRow:0,startColumn:0,endRow:a-1,endColumn:i.endColumn-i.startColumn}})}else{for(let d=0;d<s;d++)e.push({repeatStartCell:{row:i.startRow-(d+1)*o,col:i.startColumn},relativeRange:c});a>0&&e.push({repeatStartCell:{row:i.startRow-(s+1)*o,col:i.startColumn},relativeRange:{startRow:o-a,endRow:o-1,startColumn:0,endColumn:i.endColumn-i.startColumn}})}}if(n===l.Direction.RIGHT||n===l.Direction.LEFT){const o=i.endColumn-i.startColumn+1,r=t.endColumn-t.startColumn+1,s=Math.floor(r/o),a=r%o,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++)e.push({repeatStartCell:{row:i.startRow,col:i.startColumn+(d+1)*o},relativeRange:c});a>0&&e.push({repeatStartCell:{row:i.startRow,col:i.startColumn+(s+1)*o},relativeRange:{startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:a-1}})}else{for(let d=0;d<s;d++)e.push({repeatStartCell:{row:i.startRow,col:i.startColumn-(d+1)*o},relativeRange:c});a>0&&e.push({repeatStartCell:{row:i.startRow,col:i.startColumn-(s+1)*o},relativeRange:{startRow:0,startColumn:o-a,endRow:i.endRow-i.startRow,endColumn:o-1}})}}return e}function fo(i){const t=new l.ObjectMatrix;return i.forEach(e=>{const{startRow:n,startColumn:o,endRow:r,endColumn:s}=e;for(let a=n;a<=r;a++)for(let c=o;c<=s;c++)t.setValue(a,c,{v:null,p:null,f:null,si:null})}),t.getData()}const go={type:l.CommandType.COMMAND,id:"sheet.command.auto-fill",handler:async(i,t)=>!0},_n={id:"sheet.command.auto-clear-content",type:l.CommandType.COMMAND,handler:async(i,t)=>{const e=i.get(l.IUniverInstanceService);i.get(f.SelectionManagerService);const n=i.get(l.ICommandService),o=i.get(l.IUndoRedoService),r=e.getCurrentUniverSheetInstance(),s=r.getUnitId(),c=r.getActiveSheet().getSheetId(),{clearRange:d,selectionRange:u}=t,h={subUnitId:c,unitId:s,cellValue:fo([d])},m=f.SetRangeValuesUndoMutationFactory(i,h),{startColumn:S,startRow:_}=u;return n.executeCommand(f.SetSelectionsOperation.id,{selections:[{primary:{startColumn:S,startRow:_,endColumn:S,endRow:_,actualRow:_,actualColumn:S,isMerge:!1,isMergedMainCell:!1},range:{...u}}],unitId:s,subUnitId:c}),n.syncExecuteCommand(f.SetRangeValuesMutation.id,h)?(o.pushUndoRedo({unitID:s,undoMutations:[{id:f.SetRangeValuesMutation.id,params:m}],redoMutations:[{id:f.SetRangeValuesMutation.id,params:h}]}),!0):!1}};function li(i){return i.getContextValue(l.FOCUSING_SHEET)}function ie(i){return i.getContextValue(l.FOCUSING_SHEET)&&i.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&!i.getContextValue(l.EDITOR_ACTIVATED)}function po(i){return i.getContextValue(l.FOCUSING_SHEET)&&i.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&i.getContextValue(l.EDITOR_ACTIVATED)}function Ls(i){return i.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&i.getContextValue(l.EDITOR_ACTIVATED)}function vo(i){return i.getContextValue(l.FOCUSING_FORMULA_EDITOR)&&i.getContextValue(l.FOCUSING_UNIVER_EDITOR)}function Hs(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.FOCUSING_UNIVER_EDITOR)&&i.getContextValue(l.EDITOR_ACTIVATED)&&!i.getContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA)&&!i.getContextValue(l.FOCUSING_EDITOR_STANDALONE)}var fe=(i=>(i.MAIN="__SpreadsheetRender__",i.ROW="__SpreadsheetRowHeader__",i.COLUMN="__SpreadsheetColumnHeader__",i.LEFT_TOP="__SpreadsheetLeftTopPlaceholder__",i))(fe||{}),F=(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))(F||{});const Co=0,et=2,Us=3,ci=[10,400],Io=1001;var Vs=Object.defineProperty,ks=Object.getOwnPropertyDescriptor,Bs=(i,t,e,n)=>{for(var o=n>1?void 0:n?ks(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Vs(t,e,o),o},di=(i,t)=>(e,n)=>t(e,n,i);x.SheetSkeletonManagerService=class{constructor(t,e,n){I(this,"_currentSkeleton",{unitId:"",sheetId:""});I(this,"_sheetSkeletonParam",[]);I(this,"_currentSkeleton$",new V.BehaviorSubject(null));I(this,"currentSkeleton$",this._currentSkeleton$.asObservable());I(this,"_currentSkeletonBefore$",new V.BehaviorSubject(null));I(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._currentUniverService=t,this._injector=e,this._localeService=n}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParam=[]}getCurrent(){return this._getCurrentBySearch(this._currentSkeleton)}setCurrent(t){this._setCurrent(t)}_compareSearch(t,e){return t==null||e==null?!1:t.commandId===e.commandId&&t.sheetId===e.sheetId&&t.unitId===e.unitId}_setCurrent(t){const e=this._getCurrentBySearch(t);if(e!=null)this._reCalculate(e);else{const{unitId:o,sheetId:r}=t,s=this._currentUniverService.getUniverSheetInstance(t.unitId),a=s==null?void 0:s.getSheetBySheetId(t.sheetId);if(a==null||s==null)return;const c=this._buildSkeleton(a,s);this._sheetSkeletonParam.push({unitId:o,sheetId:r,skeleton:c,dirty:!1})}this._currentSkeleton=t;const n=this.getCurrent();this._currentSkeletonBefore$.next(n),this._currentSkeleton$.next(n)}reCalculate(){const t=this.getCurrent();t!=null&&this._reCalculate(t)}_reCalculate(t){t.dirty&&(t.skeleton.makeDirty(!0),t.dirty=!1),t.skeleton.calculate()}makeDirtyCurrent(t=!0){this.makeDirty(this._currentSkeleton,t)}makeDirty(t,e=!0){const n=this._getCurrentBySearch(t);n!=null&&(n.dirty=e)}getOrCreateSkeleton(t){const e=this._getCurrentBySearch(t);if(e)return e.skeleton;const n=this._currentUniverService.getUniverSheetInstance(t.unitId),o=n==null?void 0:n.getSheetBySheetId(t.sheetId);if(!o||!n)return;const r=this._buildSkeleton(o,n);return this._sheetSkeletonParam.push({unitId:t.unitId,sheetId:t.sheetId,skeleton:r,dirty:!1}),r}_getCurrentBySearch(t){const e=this._sheetSkeletonParam.find(n=>n.unitId===t.unitId&&n.sheetId===t.sheetId);return e!=null&&(e.commandId=t.commandId),e}_buildSkeleton(t,e){const n=t.getConfig();return this._injector.createInstance(w.SpreadsheetSkeleton,t,n,t.getCellMatrix(),e.getStyles())}},x.SheetSkeletonManagerService=Bs([di(0,l.IUniverInstanceService),di(1,P.Inject(P.Injector)),di(2,P.Inject(l.LocaleService))],x.SheetSkeletonManagerService);class Fs{constructor(){I(this,"_startColumn",-1);I(this,"_startRow",-1);I(this,"_endColumn",-1);I(this,"_endRow",-1);I(this,"_startX",0);I(this,"_startY",0);I(this,"_endX",0);I(this,"_endY",0);I(this,"_currentCell");I(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(t){const{startColumn:e,startRow:n,endColumn:o,endRow:r}=this,{startColumn:s,startRow:a,endColumn:c,endRow:d}=t;return e===s&&n===a&&o===c&&r===d}isInclude(t){const{startColumn:e,startRow:n,endColumn:o,endRow:r}=this,{startColumn:s,startRow:a,endColumn:c,endRow:d}=t;return!(c<e||s>o||a>r||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(t,e){const{startColumn:n,startRow:o,endColumn:r,endRow:s,startX:a,startY:c,endX:d,endY:u,rangeType:h}=t;this._startColumn=n,this._startRow=o,this._endColumn=r,this._endRow=s,this._startX=a,this._startY=c,this._endX=d,this._endY=u,h!=null&&(this._rangeType=h),this.setCurrentCell(e)}setCurrentCell(t){t&&(this._currentCell=t)}clearCurrentCell(){this._currentCell=null}}const Mo=.3;class gn extends l.Disposable{constructor(e,n,o=!0,r){super();I(this,"_leftControl");I(this,"_rightControl");I(this,"_topControl");I(this,"_bottomControl");I(this,"_backgroundControlTop");I(this,"_backgroundControlBottom");I(this,"_backgroundControlMiddleLeft");I(this,"_backgroundControlMiddleRight");I(this,"_fillControl");I(this,"_selectionShape");I(this,"_rowHeaderBackground");I(this,"_rowHeaderBorder");I(this,"_rowHeaderGroup");I(this,"_rowHeaderHighlight");I(this,"_columnHeaderBackground");I(this,"_columnHeaderBorder");I(this,"_columnHeaderGroup");I(this,"_columnHeaderHighlight");I(this,"_topLeftWidget");I(this,"_topCenterWidget");I(this,"_topRightWidget");I(this,"_middleLeftWidget");I(this,"_middleRightWidget");I(this,"_bottomLeftWidget");I(this,"_bottomCenterWidget");I(this,"_bottomRightWidget");I(this,"_dashRect");I(this,"_selectionModel");I(this,"_selectionStyle");I(this,"_rowHeaderWidth",0);I(this,"_columnHeaderHeight",0);I(this,"_widgetRects",[]);I(this,"_dispose$",new V.BehaviorSubject(this));I(this,"dispose$",this._dispose$.asObservable());I(this,"selectionMoving$",new V.Subject);I(this,"selectionMoved$",new V.Subject);I(this,"selectionScaling$",new V.Subject);I(this,"selectionScaled$",new V.Subject);I(this,"selectionFilling$",new V.Subject);I(this,"_selectionFilled$",new V.Subject);I(this,"selectionFilled$",this._selectionFilled$.asObservable());I(this,"_defaultStyle");I(this,"_currentStyle");I(this,"_isHelperSelection",!0);I(this,"_antLineOffset",0);I(this,"_antRequestNewFrame",-1);this._scene=e,this._zIndex=n,this._isHeaderHighlight=o,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,n=0,o=0,r,s){this._selectionModel.setValue(e,s),r==null&&(r=this._selectionStyle),this._updateControl(r,n,o)}clearHighlight(){this._selectionModel.clearCurrentCell(),this._updateControl(this._selectionStyle,this._rowHeaderWidth,this._columnHeaderHeight)}getScene(){return this._scene}dispose(){var e,n,o,r,s,a,c,d,u,h,m,S,_,g,v,M,R,b,E,T,y,O,N,D,k;(e=this._leftControl)==null||e.dispose(),(n=this._rightControl)==null||n.dispose(),(o=this._topControl)==null||o.dispose(),(r=this._bottomControl)==null||r.dispose(),(s=this._backgroundControlTop)==null||s.dispose(),(a=this._backgroundControlMiddleLeft)==null||a.dispose(),(c=this._backgroundControlMiddleRight)==null||c.dispose(),(d=this._backgroundControlBottom)==null||d.dispose(),(u=this._fillControl)==null||u.dispose(),(h=this._selectionShape)==null||h.dispose(),(m=this._rowHeaderBackground)==null||m.dispose(),(S=this._rowHeaderBorder)==null||S.dispose(),(_=this._rowHeaderGroup)==null||_.dispose(),(g=this._rowHeaderBackground)==null||g.dispose(),(v=this._columnHeaderBackground)==null||v.dispose(),(M=this._columnHeaderBorder)==null||M.dispose(),(R=this._columnHeaderGroup)==null||R.dispose(),(b=this._topLeftWidget)==null||b.dispose(),(E=this._topCenterWidget)==null||E.dispose(),(T=this._topRightWidget)==null||T.dispose(),(y=this._middleLeftWidget)==null||y.dispose(),(O=this._middleRightWidget)==null||O.dispose(),(N=this._bottomLeftWidget)==null||N.dispose(),(D=this._bottomCenterWidget)==null||D.dispose(),(k=this._bottomRightWidget)==null||k.dispose(),super.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let n;if(e.isMerged){const o=e.mergeInfo;n={startRow:o.startRow,endRow:o.endRow,startColumn:o.startColumn,endColumn:o.endColumn,startX:o.startX,endX:o.endX,startY:o.startY,endY:o.endY}}else{const{actualRow:o,actualColumn:r,startX:s,endX:a,startY:c,endY:d}=e;n={startRow:o,endRow:o,startColumn:r,endColumn:r,startX:s,endX:a,startY:c,endY:d}}return n}}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,n,o){const{startX:r,startY:s,endX:a,endY:c}=this._selectionModel,d=this._defaultStyle;e==null&&(e=d),this._currentStyle=e;const{stroke:u=d.stroke,widgets:h=d.widgets,hasAutoFill:m=d.hasAutoFill,AutofillStroke:S=d.AutofillStroke,strokeDash:_,isAnimationDash:g}=e;let{strokeWidth:v=d.strokeWidth,AutofillSize:M=d.AutofillSize,AutofillStrokeWidth:R=d.AutofillStrokeWidth}=e;const b=this._getScale(),E=(v+f.SELECTION_CONTROL_BORDER_BUFFER_WIDTH)/2/b;v/=b,M/=b,R/=b<1?1:b;const T=f.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/b,y=w.FIX_ONE_PIXEL_BLUR_OFFSET/b;if(this.leftControl.transformByState({height:c-s,left:-E+y,width:v,strokeWidth:T,top:-T/2+y}),this.leftControl.setProps({fill:u,stroke:f.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:c-s,left:a-r-E+y,width:v,strokeWidth:T,top:-T/2+y}),this.rightControl.setProps({fill:u,stroke:f.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:a-r+v,top:-E+y,left:-E+y,height:v,strokeWidth:T}),this.topControl.setProps({fill:u,stroke:f.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:a-r+v,top:c-s-E+y,height:v,left:-E+y,strokeWidth:T}),this.bottomControl.setProps({fill:u,stroke:f.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),_==null)this.dashRect.hide(),this._stopAntLineAnimation();else{const O=e.strokeWidth*2/b;this.dashRect.transformByState({height:c-s,width:a-r,strokeWidth:O,left:-O/2+y,top:-O/2+y}),this.dashRect.setProps({strokeDashArray:[0,_/b]}),this._stopAntLineAnimation(),g!==!1&&this._startAntLineAnimation(),this.dashRect.show()}m===!0&&!this._hasWidgets(h)?(this.fillControl.setProps({fill:u,stroke:S,strokeScaleEnabled:!1}),this.fillControl.transformByState({width:M-R,height:M-R,left:a-r-M/2+R/2,top:c-s-M/2+R/2,strokeWidth:R}),this.fillControl.show()):this.fillControl.hide(),this._updateBackgroundControl(e),this._updateBackgroundTitle(e,n,o),this._updateWidgets(e),this.selectionShape.show(),this.selectionShape.translate(r,s),this._selectionStyle=e,this._rowHeaderWidth=n||0,this._columnHeaderHeight=o||0,this.selectionShape.makeDirtyNoDebounce(!0)}_initialize(){this._defaultStyle=f.getNormalSelectionStyle(this._themeService),this._selectionModel=new Fs;const e=this._zIndex;this._leftControl=new w.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightControl=new w.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topControl=new w.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomControl=new w.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new w.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new w.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new w.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new w.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._fillControl=new w.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._dashRect=new w.Rect("__SpreadsheetDragDashControl__"+e,{zIndex:e+2,evented:!1,stroke:"#fff"});const n=[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 w.Group("__SpreadsheetSelectionShape__"+e,...n,...this._widgetRects),this._selectionShape.hide(),this._selectionShape.evented=!1,this._selectionShape.zIndex=e;const o=this.getScene();o.addObject(this._selectionShape,Us),this.disposeWithMe(l.toDisposable(o.onTransformChangeObservable.add(r=>{r.type===w.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&this._updateControl(this._currentStyle,this._rowHeaderWidth,this._columnHeaderHeight)}))),this._initialTitle()}_initialTitle(){const e=this._zIndex;this._rowHeaderBackground=new w.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new w.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new w.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new w.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new w.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new w.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],w.DEFAULT_SELECTION_LAYER_INDEX)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new w.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new w.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new w.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new w.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new w.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new w.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new w.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new w.Rect("__SpreadSheetSelectionBottomRightWidget__"+e,{zIndex:e+1}),[this._topLeftWidget,this._topCenterWidget,this._topRightWidget,this._middleLeftWidget,this._middleRightWidget,this._bottomLeftWidget,this._bottomCenterWidget,this._bottomRightWidget]}_updateBackgroundTitle(e,n,o){const{startX:r,startY:s,endX:a,endY:c,rangeType:d}=this._selectionModel,u=this._defaultStyle;e==null&&(e=u);const h=this._getScale(),{stroke:m,hasRowHeader:S,rowHeaderFill:_=u.rowHeaderFill,rowHeaderStroke:g=u.rowHeaderStroke,hasColumnHeader:v,columnHeaderFill:M=u.columnHeaderFill,columnHeaderStroke:R=u.columnHeaderStroke}=e;let{rowHeaderStrokeWidth:b=u.rowHeaderStrokeWidth,columnHeaderStrokeWidth:E=u.columnHeaderStrokeWidth}=e;if(b/=h,E/=h,v===!0){let T=M;this._isHeaderHighlight&&d===l.RANGE_TYPE.COLUMN&&(T=new l.ColorKit(m).setAlpha(Mo).toString()),this._columnHeaderBackground.setProps({fill:T}),this._columnHeaderBackground.resize(a-r,o),this._columnHeaderBorder.setProps({fill:R}),this._columnHeaderBorder.transformByState({width:a-r,height:E,top:o-E+1/h}),this._columnHeaderGroup.show(),this._columnHeaderGroup.translate(r,0)}else this._columnHeaderGroup.hide();if(this._columnHeaderGroup.makeDirty(!0),S===!0){let T=_;this._isHeaderHighlight&&d===l.RANGE_TYPE.ROW&&(T=new l.ColorKit(m).setAlpha(Mo).toString()),this._rowHeaderBackground.setProps({fill:T}),this._rowHeaderBackground.resize(n,c-s),this._rowHeaderBorder.setProps({fill:g}),this._rowHeaderBorder.transformByState({width:b,height:c-s,left:n-b+1/h}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,s)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){const{startX:n,startY:o,endX:r,endY:s}=this._selectionModel,a=this._defaultStyle;e==null&&(e=a);const c=this._getScale(),{fill:d=a.fill}=e;let{strokeWidth:u=a.strokeWidth}=e;u/=c;const h=this._selectionModel.highlightToSelection();if(!h){this._backgroundControlTop.resize(r-n,s-o),this._backgroundControlTop.setProps({fill:d}),this._backgroundControlBottom.resize(0,0),this._backgroundControlMiddleLeft.resize(0,0),this._backgroundControlMiddleRight.resize(0,0);return}const{startX:m,startY:S,endX:_,endY:g}=h,v=u/2,M={left:-v,top:-v,width:r-n+v*2,height:S-o+v};M.height<0&&(M.width=0,M.height=0),this._backgroundControlTop.transformByState(M);const R={left:-v,top:S-o,width:m-n+v,height:g-S};R.width<0&&(R.width=0,R.height=0),this._backgroundControlMiddleLeft.transformByState(R);const b={left:_-n-v,top:S-o,width:r-_+v*2,height:g-S};b.width<0&&(b.width=0,b.height=0),this._backgroundControlMiddleRight.transformByState(b);const E={left:-v,top:g-o,width:r-n+v*2,height:s-g+v};E.height<0&&(E.width=0,E.height=0),this._backgroundControlBottom.transformByState(E),this._backgroundControlTop.setProps({fill:d}),this._backgroundControlMiddleLeft.setProps({fill:d}),this._backgroundControlMiddleRight.setProps({fill:d}),this._backgroundControlBottom.setProps({fill:d})}_updateWidgets(e){const{startX:n,startY:o,endX:r,endY:s}=this._selectionModel,a=this._defaultStyle;e==null&&(e=a);const{stroke:c=a.stroke,widgets:d=a.widgets,widgetStroke:u=a.widgetStroke}=e,h=this._getScale();let{widgetSize:m=a.widgetSize,widgetStrokeWidth:S=a.widgetStrokeWidth}=e;m/=h,S/=h;const _={left:-m/2+S/2,center:(r-n)/2-m/2+S/2,right:r-n-m/2+S/2,top:-m/2,middle:(s-o)/2-m/2,bottom:s-o-m/2+S/2},g=m-S;this._widgetRects.forEach(v=>{v.setProps({fill:c,stroke:u})}),d.tl===!0?(this._topLeftWidget.transformByState({height:g,width:g,left:_.left,top:_.top,strokeWidth:S}),this._topLeftWidget.show()):this._topLeftWidget.hide(),d.tc===!0?(this._topCenterWidget.transformByState({height:g,width:g,left:_.center,top:_.top,strokeWidth:S}),this._topCenterWidget.show()):this._topCenterWidget.hide(),d.tr===!0?(this._topRightWidget.transformByState({height:g,width:g,left:_.right,top:_.top,strokeWidth:S}),this._topRightWidget.show()):this._topRightWidget.hide(),d.ml===!0?(this._middleLeftWidget.transformByState({height:g,width:g,left:_.left,top:_.middle,strokeWidth:S}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),d.mr===!0?(this._middleRightWidget.transformByState({height:g,width:g,left:_.right,top:_.middle,strokeWidth:S}),this._middleRightWidget.show()):this._middleRightWidget.hide(),d.bl===!0?(this._bottomLeftWidget.transformByState({height:g,width:g,left:_.left,top:_.bottom,strokeWidth:S}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),d.bc===!0?(this._bottomCenterWidget.transformByState({height:g,width:g,left:_.center,top:_.bottom,strokeWidth:S}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),d.br===!0?(this._bottomRightWidget.transformByState({height:g,width:g,left:_.right,top:_.bottom,strokeWidth:S}),this._bottomRightWidget.show()):this._bottomRightWidget.hide()}_hasWidgets(e){if(e==null)return!1;const n=Object.keys(e);if(n.length===0)return!1;for(const o of n)if(e[o]===!0)return!0;return!0}_getScale(){const{scaleX:e,scaleY:n}=this._scene.getAncestorScale();return Math.max(e,n)}_stopAntLineAnimation(){this._antLineOffset=0,w.cancelRequestFrame(this._antRequestNewFrame)}_startAntLineAnimation(){const e=this._getScale();this._antLineOffset+=.6/e,this._antLineOffset>16/e&&(this._antLineOffset=0),this.dashRect.setProps({strokeDashOffset:-this._antLineOffset}),this._antRequestNewFrame=w.requestNewFrame(()=>{this._startAntLineAnimation()})}}const Ro="__SpreadsheetHelperSelectionTempRect",Ws=35;class bo{constructor(t,e,n,o,r){I(this,"_startOffsetX",0);I(this,"_startOffsetY",0);I(this,"_relativeSelectionPositionRow",0);I(this,"_relativeSelectionPositionColumn",0);I(this,"_relativeSelectionRowLength",0);I(this,"_relativeSelectionColumnLength",0);I(this,"_moveObserver");I(this,"_upObserver");I(this,"_helperSelection");I(this,"_scrollTimer");I(this,"_activeViewport");I(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});I(this,"_isInMergeState",!1);I(this,"_fillControlColors",[]);this._control=t,this._skeleton=e,this._scene=n,this._themeService=o,this._injector=r,this._initialControl(),this._initialWidget(),this._initialFill(),this._control.dispose$.subscribe(()=>{this.dispose()})}get isHelperSelection(){return this._control.isHelperSelection}dispose(){var t,e;(t=this._scrollTimer)==null||t.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(e=this._helperSelection)==null||e.dispose()}_getFreeze(){var e;return(e=this._injector.get(x.SheetSkeletonManagerService).getCurrent())==null?void 0:e.skeleton.getWorksheetConfig().freeze}_isSelectionInViewport(t,e){const n=this._getFreeze()||{startRow:-1,startColumn:-1,xSplit:0,ySplit:0};switch(e.viewPortKey){case F.VIEW_MAIN:return t.endRow>=n.startRow&&t.endColumn>=n.startColumn;case F.VIEW_MAIN_TOP:case F.VIEW_COLUMN_RIGHT:return t.endColumn>=n.startColumn&&t.startRow<n.startRow;case F.VIEW_MAIN_LEFT:case F.VIEW_ROW_BOTTOM:return t.endRow>=n.startRow&&t.startColumn<n.startColumn;case F.VIEW_MAIN_LEFT_TOP:case F.VIEW_COLUMN_LEFT:case F.VIEW_ROW_TOP:case F.VIEW_LEFT_TOP:return t.startRow<n.startRow&&t.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:t,rightControl:e,topControl:n,bottomControl:o}=this._control;[t,e,n,o].forEach(r=>{r.onPointerEnterObserver.add(()=>{r.setCursor(w.CURSOR_TYPE.MOVE)}),r.onPointerLeaveObserver.add(()=>{r.resetCursor()}),r.onPointerDownObserver.add(this._controlEvent.bind(this))})}_controlMoving(t,e){var y;const n=this._scene,o=n.getScrollXYByRelativeCoords(w.Vector2.FromArray([t,e])),{scaleX:r,scaleY:s}=n.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(t,e,r,s,o),{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 S=m+this._relativeSelectionRowLength;S>u&&(S=u,S-m<this._relativeSelectionRowLength&&(m=S-this._relativeSelectionRowLength));let _=d+this._relativeSelectionPositionColumn;_<0&&(_=0);let g=_+this._relativeSelectionColumnLength;g>h&&(g=h,g-_<this._relativeSelectionColumnLength&&(_=g-this._relativeSelectionColumnLength));const v=this._skeleton.getNoMergeCellPositionByIndex(m,_),M=this._skeleton.getNoMergeCellPositionByIndex(S,g),R=(v==null?void 0:v.startY)||0,b=(M==null?void 0:M.endY)||0,E=(v==null?void 0:v.startX)||0,T=(M==null?void 0:M.endX)||0;(y=this._helperSelection)==null||y.transformByState({left:E,top:R,width:T-E,height:b-R}),this._targetSelection={startY:R,endY:b,startX:E,endX:T,startRow:m,endRow:S,startColumn:_,endColumn:g},this._control.selectionMoving$.next(this._targetSelection)}_controlEvent(t){const{offsetX:e,offsetY:n}=t,o=this._scene,r=o.getRelativeCoord(w.Vector2.FromArray([e,n])),{x:s,y:a}=r,c=o.getScrollXYByRelativeCoords(r),{scaleX:d,scaleY:u}=o.getAncestorScale(),h=this._skeleton.getCellPositionByOffset(s,a,d,u,c);this._startOffsetX=s,this._startOffsetY=a;const{row:m,column:S}=h,{startRow:_,startColumn:g,endRow:v,endColumn:M}=this._control.model;let R=0,b=0;m<_?R-=1:m>v&&(R+=1),S<g?b-=1:S>M&&(b+=1),this._relativeSelectionPositionRow=_-m+R,this._relativeSelectionPositionColumn=g-S+b,this._relativeSelectionRowLength=v-_,this._relativeSelectionColumnLength=M-g;const E=this._control.selectionStyle,T=this._getScale();this.isHelperSelection&&(this._helperSelection=new w.Rect(Ro,{stroke:E.stroke,strokeWidth:E.strokeWidth/T}),o.addObject(this._helperSelection));const y=o.getViewport(F.VIEW_MAIN),O=w.ScrollTimer.create(o);O.startScroll(s,a,y),this._scrollTimer=O,o.disableEvent(),this._moveObserver=o.onPointerMoveObserver.add(N=>{const{offsetX:D,offsetY:k}=N,{x:A,y:L}=o.getRelativeCoord(w.Vector2.FromArray([D,k]));this._controlMoving(A,L),o.setCursor(w.CURSOR_TYPE.MOVE),O.scrolling(A,L,()=>{this._controlMoving(A,L)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var D,k;(D=this._helperSelection)==null||D.dispose();const N=this._scene;N.resetCursor(),this._clearObserverEvent(),N.enableEvent(),(k=this._scrollTimer)==null||k.dispose(),this._control.selectionMoved$.next(this._targetSelection)})}_initialWidget(){const{topLeftWidget:t,topCenterWidget:e,topRightWidget:n,middleLeftWidget:o,middleRightWidget:r,bottomLeftWidget:s,bottomCenterWidget:a,bottomRightWidget:c}=this._control,d=[w.CURSOR_TYPE.NORTH_WEST_RESIZE,w.CURSOR_TYPE.NORTH_RESIZE,w.CURSOR_TYPE.NORTH_EAST_RESIZE,w.CURSOR_TYPE.WEST_RESIZE,w.CURSOR_TYPE.EAST_RESIZE,w.CURSOR_TYPE.SOUTH_WEST_RESIZE,w.CURSOR_TYPE.SOUTH_RESIZE,w.CURSOR_TYPE.SOUTH_EAST_RESIZE];[t,e,n,o,r,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(t,e,n){const o=this._scene,r=o.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:a}=o.getAncestorScale(),c=this._skeleton.getCellPositionByOffset(t,e,s,a,r),{row:d,column:u}=c,{rowHeaderWidth:h,columnHeaderHeight:m}=this._skeleton;let S=this._relativeSelectionPositionRow,_=this._relativeSelectionPositionColumn,g=d,v=u;n===w.CURSOR_TYPE.NORTH_WEST_RESIZE?(S=d,_=u,g=this._relativeSelectionPositionRow,v=this._relativeSelectionPositionColumn):n===w.CURSOR_TYPE.NORTH_RESIZE?(S=d,_=this._relativeSelectionPositionColumn,g=this._relativeSelectionPositionRow,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):n===w.CURSOR_TYPE.NORTH_EAST_RESIZE?(S=d,_=this._relativeSelectionPositionColumn,g=this._relativeSelectionPositionRow,v=u):n===w.CURSOR_TYPE.WEST_RESIZE?(S=this._relativeSelectionPositionRow,_=u,g=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,v=this._relativeSelectionPositionColumn):n===w.CURSOR_TYPE.EAST_RESIZE?g=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:n===w.CURSOR_TYPE.SOUTH_WEST_RESIZE?(S=this._relativeSelectionPositionRow,_=u,g=d,v=this._relativeSelectionPositionColumn):n===w.CURSOR_TYPE.SOUTH_RESIZE&&(S=this._relativeSelectionPositionRow,_=this._relativeSelectionPositionColumn,g=d,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const{startRow:M,startColumn:R,endRow:b,endColumn:E}=this._swapPositions(S,_,g,v),T=this._skeleton.getNoMergeCellPositionByIndex(M,R),y=this._skeleton.getNoMergeCellPositionByIndex(b,E),O=(T==null?void 0:T.startY)||0,N=(y==null?void 0:y.endY)||0,D=(T==null?void 0:T.startX)||0,k=(y==null?void 0:y.endX)||0;this._targetSelection={startY:O,endY:N,startX:D,endX:k,startRow:S,endRow:g,startColumn:_,endColumn:v},this._control.update(this._targetSelection,h,m,this._control.selectionStyle),this._control.clearHighlight(),this._control.selectionScaling$.next(this._targetSelection)}_widgetEvent(t,e){const{offsetX:n,offsetY:o}=t,r=this._scene,s=r.getRelativeCoord(w.Vector2.FromArray([n,o])),{x:a,y:c}=s;this._startOffsetX=n,this._startOffsetY=o;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,e===w.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=h,this._relativeSelectionPositionColumn=m):e===w.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=h:e===w.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=h:e===w.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=m:e===w.CURSOR_TYPE.SOUTH_WEST_RESIZE&&(this._relativeSelectionPositionColumn=m);const S=w.ScrollTimer.create(r);S.startScroll(a,c),this._scrollTimer=S,r.disableEvent(),this._moveObserver=r.onPointerMoveObserver.add(_=>{const{offsetX:g,offsetY:v}=_,{x:M,y:R}=r.getRelativeCoord(w.Vector2.FromArray([g,v]));this._widgetMoving(M,R,e),r.setCursor(e),S.scrolling(M,R,()=>{this._widgetMoving(M,R,e)})}),this._upObserver=r.onPointerUpObserver.add(()=>{var g;const _=this._scene;_.resetCursor(),this._clearObserverEvent(),_.enableEvent(),(g=this._scrollTimer)==null||g.dispose(),this._control.selectionScaled$.next(this._targetSelection)})}_initialFill(){const{fillControl:t}=this._control;t.onPointerEnterObserver.add(()=>{t.setCursor(w.CURSOR_TYPE.CROSSHAIR)}),t.onPointerLeaveObserver.add(()=>{t.resetCursor()}),t.onPointerDownObserver.add(this._fillEvent.bind(this))}_fillMoving(t,e){var k,A,L;const n=this._scene,o=n.getScrollXY(this._activeViewport),{scaleX:r,scaleY:s}=n.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(t,e,r,s,o),{row:c,column:d}=a,u=n.getRelativeCoord(w.Vector2.FromArray([t,e])),h=this._skeleton.getRowCount()-1,m=this._skeleton.getColumnCount()-1;let S=this._relativeSelectionPositionRow,_=this._relativeSelectionPositionColumn,g=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,M=!1,R=!0;if((d<_||d>v)&&c>=S&&c<=g){const B=this._fillRuler(d,_,v,this._relativeSelectionColumnLength,m);_=B.startRowOrColumn,v=B.endRowOrColumn,M=B.isLighten,R=!1}else if((c<S||c>g)&&d>=_&&d<=v){const B=this._fillRuler(c,S,g,this._relativeSelectionRowLength,h);S=B.startRowOrColumn,g=B.endRowOrColumn,M=B.isLighten}else if(Math.abs(this._startOffsetX-u.x-o.x)/2>Math.abs(this._startOffsetY-u.y-o.y)){const B=this._fillRuler(d,_,v,this._relativeSelectionColumnLength,m);_=B.startRowOrColumn,v=B.endRowOrColumn,M=B.isLighten,R=!1}else{const B=this._fillRuler(c,S,g,this._relativeSelectionRowLength,h);S=B.startRowOrColumn,g=B.endRowOrColumn,M=B.isLighten}const b=this._skeleton.getNoMergeCellPositionByIndex(S,_),E=this._skeleton.getNoMergeCellPositionByIndex(g,v),T=(b==null?void 0:b.startY)||0,y=(E==null?void 0:E.endY)||0,O=(b==null?void 0:b.startX)||0,N=(E==null?void 0:E.endX)||0;M?this._controlHandler((B,j)=>{const X=new l.ColorKit(this._fillControlColors[j]).lighten(Ws).toRgbString();B.setProps({fill:X})}):this._controlHandler((B,j)=>{B.setProps({fill:this._fillControlColors[j]})});const D=f.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();S===g&&R===!0||_===v&&R===!1?(k=this._helperSelection)==null||k.hide():((A=this._helperSelection)==null||A.transformByState({left:O-D/2,top:T-D/2,width:N-O,height:y-T}),(L=this._helperSelection)==null||L.show()),this._targetSelection={startY:T,endY:y,startX:O,endX:N,startRow:S,endRow:g,startColumn:_,endColumn:v},this._control.selectionFilling$.next(this._targetSelection)}_fillEvent(t){const{offsetX:e,offsetY:n}=t,o=this._scene,r=o.getRelativeCoord(w.Vector2.FromArray([e,n])),{x:s,y:a}=r;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 S=m==null?void 0:m.stroke,_=m==null?void 0:m.strokeWidth;const g=f.getNormalSelectionStyle(this._themeService);S==null&&(S=g.stroke),_==null&&(_=g.strokeWidth);const v=this._getScale();_/=v;const M=f.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/v,R=new l.ColorKit(S).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new w.Rect(Ro,{stroke:R,strokeWidth:_+M/2}),o.addObject(this._helperSelection)),this._activeViewport=o.getActiveViewportByCoord(w.Vector2.FromArray([e,n]));const b=o.getViewport(F.VIEW_MAIN),E=w.ScrollTimer.create(o,this._activeViewport.viewPortKey===F.VIEW_MAIN?w.ScrollTimerType.ALL:w.ScrollTimerType.NONE);E.startScroll(s,a,b),this._scrollTimer=E,o.disableEvent(),this._controlHandler(T=>{this._fillControlColors.push(T.fill)}),this._moveObserver=o.onPointerMoveObserver.add(T=>{var L;const{offsetX:y,offsetY:O}=T,N=o.getActiveViewportByCoord(w.Vector2.FromArray([y,O])),{x:D,y:k}=o.getRelativeCoord(w.Vector2.FromArray([y,O]));this._fillMoving(D,k),o.setCursor(w.CURSOR_TYPE.CROSSHAIR);const A=this._targetSelection;if(b&&N&&((L=this._activeViewport)==null?void 0:L.viewPortKey)!==(N==null?void 0:N.viewPortKey)){let B;A.startRow!==c?(E.scrollTimerType=w.ScrollTimerType.Y,B={...A,endRow:A.startRow}):A.endRow!==u?(E.scrollTimerType=w.ScrollTimerType.Y,B={...A,startRow:A.endRow}):A.startColumn!==d?(E.scrollTimerType=w.ScrollTimerType.X,B={...A,endColumn:A.startColumn}):(E.scrollTimerType=w.ScrollTimerType.X,B={...A,startColumn:A.endColumn}),this._isSelectionInViewport(B,N)&&(b.scrollTo({x:E.scrollTimerType===w.ScrollTimerType.X?0:void 0,y:E.scrollTimerType===w.ScrollTimerType.Y?0:void 0}),this._activeViewport=N)}E.scrolling(D,k,()=>{this._fillMoving(D,k)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var y,O;(y=this._helperSelection)==null||y.dispose();const T=this._scene;T.resetCursor(),this._clearObserverEvent(),T.enableEvent(),(O=this._scrollTimer)==null||O.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((N,D)=>{N.setProps({fill:this._fillControlColors[D]})}),this._fillControlColors=[]})}_hasMergeInRange(t,e,n,o){const r=this._skeleton.mergeData;if(!r)return!1;for(const s of r){const{startRow:a,startColumn:c,endRow:d,endColumn:u}=s,h={left:e,top:t,right:o,bottom:n},m={left:c,top:a,right:u,bottom:d};if(w.isRectIntersect(h,m))return!0}return!1}_swapPositions(t,e,n,o){const r=Math.min(t,n),s=Math.min(e,o),a=Math.max(t,n),c=Math.max(e,o);return{startRow:r,startColumn:s,endRow:a,endColumn:c}}_controlHandler(t){const{leftControl:e,rightControl:n,topControl:o,bottomControl:r,backgroundControlTop:s,backgroundControlMiddleLeft:a,backgroundControlMiddleRight:c,backgroundControlBottom:d,fillControl:u}=this._control,h=[e,n,o,r,s,a,c,d,u];for(let m=0,S=h.length;m<S;m++){const _=h[m];t(_,m)}}_fillRuler(t,e,n,o,r){let s=!1;if(t<e)if(this._isInMergeState&&t<e){const a=e-t,c=o+1,d=Math.ceil(a/c);let u=e-d*c;u<0&&(u=e-(d-1)*c),e=u}else e=t;else if(t>=e&&t<=n)s=!0,this._isInMergeState||(n=t);else if(this._isInMergeState&&t>n){const a=t-n,c=o+1,d=Math.ceil(a/c);let u=n+d*c;u>r&&(u=n+(d-1)*c),n=u}else n=t;return{rowOrColumn:t,startRowOrColumn:e,endRowOrColumn:n,isLighten:s}}_getScale(){const{scaleX:t,scaleY:e}=this._scene.getAncestorScale();return Math.max(t,e)}}var js=Object.defineProperty,zs=Object.getOwnPropertyDescriptor,Ys=(i,t,e,n)=>{for(var o=n>1?void 0:n?zs(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&js(t,e,o),o},pn=(i,t)=>(e,n)=>t(e,n,i);x.SelectionRenderService=class{constructor(t,e,n,o){I(this,"hasSelection",!1);I(this,"_downObserver");I(this,"_moveObserver");I(this,"_upObserver");I(this,"_controlFillConfig$",new V.BehaviorSubject(null));I(this,"controlFillConfig$",this._controlFillConfig$.asObservable());I(this,"_selectionControls",[]);I(this,"_startSelectionRange",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});I(this,"_startOffsetX",0);I(this,"_startOffsetY",0);I(this,"_scrollTimer");I(this,"_cancelDownObserver");I(this,"_cancelUpObserver");I(this,"_skeleton");I(this,"_scene");I(this,"_isHeaderHighlight",!0);I(this,"_isDetectMergedCell",!0);I(this,"_selectionStyle");I(this,"_isSelectionEnabled",!0);I(this,"_isShowPreviousEnable",0);I(this,"_isRemainLastEnable",!0);I(this,"_isSkipRemainLastEnable",!1);I(this,"_isSingleSelection",!1);I(this,"_selectionMoveEnd$",new V.BehaviorSubject([]));I(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());I(this,"_selectionMoving$",new V.Subject);I(this,"selectionMoving$",this._selectionMoving$.asObservable());I(this,"_selectionMoveStart$",new V.Subject);I(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());I(this,"_activeViewport");this._themeService=t,this._shortcutService=e,this._sheetSkeletonManagerService=n,this._injector=o,this._selectionStyle=f.getNormalSelectionStyle(this._themeService)}enableHeaderHighlight(){this._isHeaderHighlight=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}enableDetectMergedCell(){this._isDetectMergedCell=!0}disableDetectMergedCell(){this._isDetectMergedCell=!1}setStyle(t){this._selectionStyle=t}resetStyle(){this.setStyle(f.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}enableSingleSelection(){this._isSingleSelection=!0}disableSingleSelection(){this._isSingleSelection=!1}getViewPort(){return this._activeViewport}addControlToCurrentByRangeData(t){const e=this.getCurrentControls();if(!e)return;const{rangeWithCoord:n,primaryWithCoord:o}=t,r=this._skeleton;let s=t.style;s==null&&(s=f.getNormalSelectionStyle(this._themeService));const a=this._scene;if(a==null||r==null)return;const c=new gn(a,e.length,this._isHeaderHighlight,this._themeService);new bo(c,r,a,this._themeService,this._injector);const{rowHeaderWidth:d,columnHeaderHeight:u}=r;c.update(n,d,u,s,o),this._isHeaderHighlight?c.enableHeaderHighlight():c.disableHeaderHighlight(),e.push(c)}updateControlForCurrentByRangeData(t){const e=this.getCurrentControls();if(!e)return;const n=this._skeleton;if(n==null)return;const{rowHeaderWidth:o,columnHeaderHeight:r}=n;for(let s=0,a=t.length;s<a;s++){const{rangeWithCoord:c,primaryWithCoord:d,style:u}=t[s];e[s].update(c,o,r,u,d)}}refreshSelectionMoveStart(){this._selectionMoveStart$.next(this.getSelectionDataWithStyle())}changeRuntime(t,e,n){this._skeleton=t,this._scene=e,this._activeViewport=n||e.getViewports()[0]}getSelectionDataWithStyle(){return this._selectionControls.map(e=>e.getValue())}getCurrentControls(){return this._selectionControls}_clearSelectionControls(){const t=this.getCurrentControls();if(t.length>0){for(const e of t)e.dispose();t.length=0}}_getFreeze(){var e;return(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig().freeze}_getViewportByCell(t,e){if(!this._scene||t===void 0||e===void 0)return null;const n=this._getFreeze();if(!n||n.startRow<=0&&n.startColumn<=0)return this._scene.getViewport(F.VIEW_MAIN);if(t>n.startRow&&e>n.startColumn)return this._scene.getViewport(F.VIEW_MAIN);if(t<=n.startRow&&e<=n.startColumn)return this._scene.getViewport(F.VIEW_MAIN_LEFT_TOP);if(t<=n.startRow&&e>n.startColumn)return this._scene.getViewport(F.VIEW_MAIN_TOP);if(t>n.startRow&&e<=n.startColumn)return this._scene.getViewport(F.VIEW_MAIN_LEFT)}getActiveSelections(){const t=this.getCurrentControls();if(t&&t.length>0)return t==null?void 0:t.map(n=>{const o=n.model,r=o.currentCell;let s=null;return r&&(s={actualRow:r.actualRow,actualColumn:r.actualColumn,isMerged:r.isMerged,isMergedMainCell:r.isMergedMainCell,startRow:r.mergeInfo.startRow,startColumn:r.mergeInfo.startColumn,endRow:r.mergeInfo.endRow,endColumn:r.mergeInfo.endColumn}),{range:{startRow:o.startRow,startColumn:o.startColumn,endRow:o.endRow,endColumn:o.endColumn},primary:s}})}getActiveRange(){const t=this.getCurrentControls(),e=t&&t[t.length-1].model;return e&&{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}}getActiveSelection(){const t=this.getCurrentControls();return t&&t[t.length-1]}endSelection(){this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}reset(){var t,e,n;this._clearSelectionControls(),(t=this._moveObserver)==null||t.dispose(),(e=this._upObserver)==null||e.dispose(),(n=this._downObserver)==null||n.dispose(),this._moveObserver=null,this._upObserver=null,this._downObserver=null}resetAndEndSelection(){this.endSelection(),this.reset()}eventTrigger(t,e=0,n=l.RANGE_TYPE.NORMAL,o,r=w.ScrollTimerType.ALL){var re,se;if(this._isSelectionEnabled===!1)return;const s=this._skeleton,{offsetX:a,offsetY:c}=t,d=this._scene;if(d==null||s==null)return;o!=null&&(this._activeViewport=o);const u=d.getViewport(F.VIEW_MAIN),h=d.getRelativeCoord(w.Vector2.FromArray([a,c]));let{x:m,y:S}=h;this._startOffsetX=m,this._startOffsetY=S;const _=d.getScrollXYByRelativeCoords(h),{scaleX:g,scaleY:v}=d.getAncestorScale();n===l.RANGE_TYPE.ROW?m=0:n===l.RANGE_TYPE.COLUMN&&(S=0);const M=this._getSelectedRangeWithMerge(m,S,g,v,_);if(!M)return!1;const{rangeWithCoord:R,primaryWithCoord:b}=M,{startRow:E,startColumn:T,endColumn:y,endRow:O,startY:N,endY:D,startX:k,endX:A}=R,{rowHeaderWidth:L,columnHeaderHeight:B}=s,j={startColumn:T,startRow:E,endColumn:y,endRow:O,startY:N,endY:D,startX:k,endX:A,rangeType:n};this._startSelectionRange=j;let X=this.getActiveSelection();const z=this.getCurrentControls();if(!z)return!1;for(const Y of z){if(t.button===2&&Y.model.isInclude(j)){X=Y;return}if(Y.model.isEqual(j)){X=Y;break}t.shiftKey||Y.clearHighlight()}if(z.length>0&&!t.ctrlKey&&!t.shiftKey&&!this._isShowPreviousEnable&&!this._isRemainLastEnable||z.length>0&&this._isSingleSelection&&!t.shiftKey){for(const Y of z)Y.dispose();z.length=0}const Z=X&&X.model.currentCell;if(X&&t.shiftKey&&Z){const{actualRow:Y,actualColumn:Q,mergeInfo:J}=Z,ae=Math.min(Y,j.startRow,J.startRow),ce=Math.max(Y,j.endRow,J.endRow),pe=Math.min(Q,j.startColumn,J.startColumn),Qe=Math.max(Q,j.endColumn,J.endColumn),Me=s.getMergeBounding(ae,pe,ce,Qe),_e=s.getNoMergeCellPositionByIndex(Me.startRow,Me.startColumn),de=s.getNoMergeCellPositionByIndex(Me.endRow,Me.endColumn),Je={startColumn:Me.startColumn,startRow:Me.startRow,endColumn:Me.endColumn,endRow:Me.endRow,startY:_e.startY,endY:de.endY,startX:_e.startX,endX:de.endX,rangeType:n},Re=s.getCellByIndex(Y,Q);this._startSelectionRange={startColumn:Re.mergeInfo.startColumn,startRow:Re.mergeInfo.startRow,endColumn:Re.mergeInfo.endColumn,endRow:Re.mergeInfo.endRow,startY:Re.mergeInfo.startY||0,endY:Re.mergeInfo.endY||0,startX:Re.mergeInfo.startX||0,endX:Re.mergeInfo.endX||0,rangeType:n},X.update(Je,L,B,this._selectionStyle,Z)}else this._isRemainLastEnable&&X&&!t.ctrlKey&&!t.shiftKey&&!this._isSkipRemainLastEnable&&!this._isSingleSelection?X.update(j,L,B,this._selectionStyle,b):(X=new gn(d,z.length+e,this._isHeaderHighlight,this._themeService),new bo(X,s,d,this._themeService,this._injector),X.update(j,L,B,this._selectionStyle,b),z.push(X));this._selectionMoveStart$.next(this.getSelectionDataWithStyle()),this.hasSelection=!0,this._endSelection(),d.disableEvent();const ee=d.getActiveViewportByCoord(w.Vector2.FromArray([m,S])),ne=w.ScrollTimer.create(this._scene,r);ne.startScroll((re=u==null?void 0:u.left)!=null?re:0,(se=u==null?void 0:u.top)!=null?se:0,u),this._scrollTimer=ne,this._addCancelObserver(),(n===l.RANGE_TYPE.ROW||n===l.RANGE_TYPE.COLUMN)&&this._moving(m,S,X,n);let U=0,W=0,$=m,q=S;this._moveObserver=d.onPointerMoveObserver.add(Y=>{var Re,an,ln,cn,dn,Ss,_s,fs,gs,ps;const{offsetX:Q,offsetY:J}=Y,{x:ae,y:ce}=d.getRelativeCoord(w.Vector2.FromArray([Q,J]));this._moving(ae,ce,X,n);let pe=ae,Qe=ce;const Me=this.getActiveSelection(),_e=(Re=this._sheetSkeletonManagerService.getCurrent())==null?void 0:Re.skeleton.getWorksheetConfig().freeze,de=Me==null?void 0:Me.model,Je=(an=d.getActiveViewportByCoord(w.Vector2.FromArray([Q,J])))!=null?an:this._getViewportByCell(de==null?void 0:de.endRow,de==null?void 0:de.endColumn);if(ee&&Je&&u){const oo=$<u.left&&ae>u.left||$>u.left&&ae<u.left,ro=q<u.top&&ce>u.top||q>u.top&&ce<u.top;oo&&(U+=1),ro&&(W+=1);const ze=ee.viewPortKey,un=Je.viewPortKey;if(ze===F.VIEW_ROW_TOP)J<u.top&&((ln=de==null?void 0:de.endRow)!=null?ln:0)<((cn=_e==null?void 0:_e.startRow)!=null?cn:0)?Qe=u.top:ro&&W%2===1&&u.scrollTo({y:0});else if(ze===F.VIEW_COLUMN_LEFT)Q<u.left&&((dn=de==null?void 0:de.endColumn)!=null?dn:0)<((Ss=_e==null?void 0:_e.startColumn)!=null?Ss:0)?pe=u.left:oo&&U%2===1&&u.scrollTo({x:0});else if(ze===un){let qe=!1,_t=!1;ze===F.VIEW_MAIN_LEFT_TOP?(qe=!0,_t=!0):ze===F.VIEW_MAIN_TOP?_t=!0:ze===F.VIEW_MAIN_LEFT&&(qe=!0),((_s=de==null?void 0:de.endRow)!=null?_s:0)>((fs=_e==null?void 0:_e.startRow)!=null?fs:0)&&(_t=!1),((gs=de==null?void 0:de.endColumn)!=null?gs:0)>((ps=_e==null?void 0:_e.startColumn)!=null?ps:0)&&(qe=!1),qe&&(pe=u.left),_t&&(Qe=u.top)}else{const qe={x:ee.scrollX,y:ee.scrollY},_t={x:Je.scrollX,y:Je.scrollY},so=qe.x!==_t.x&&oo&&U%2===1,ao=qe.y!==_t.y&&ro&&W%2===1;(so||ao)&&(u.scrollTo({x:so?qe.x:void 0,y:ao?qe.y:void 0}),so||(pe=u.left),ao||(Qe=u.top)),(ze===F.VIEW_MAIN_LEFT_TOP&&un===F.VIEW_MAIN_LEFT||un===F.VIEW_MAIN_LEFT_TOP&&ze===F.VIEW_MAIN_LEFT)&&(pe=u.left),(ze===F.VIEW_MAIN_LEFT_TOP&&un===F.VIEW_MAIN_TOP||un===F.VIEW_MAIN_LEFT_TOP&&ze===F.VIEW_MAIN_TOP)&&(Qe=u.top)}$=ae,q=ce}ne.scrolling(pe,Qe,()=>{this._moving(ae,ce,X,n)})}),this._upObserver=d.onPointerUpObserver.add(Y=>{this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}),this._shortcutService.setDisable(!0)}convertSelectionRangeToData(t){const{range:e,primary:n,style:o}=t;let r=this.convertRangeDataToSelection(e);return r==null&&(r={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1,startY:0,endY:0,startX:0,endX:0,rangeType:l.RANGE_TYPE.NORMAL}),{rangeWithCoord:r,primaryWithCoord:this.convertCellRangeToInfo(n),style:o}}convertRangeDataToSelection(t){const{startRow:e,startColumn:n,endRow:o,endColumn:r,rangeType:s}=t,a=this._scene,c=this._skeleton;if(a==null||c==null)return;a.getAncestorScale();const d=c.getNoMergeCellPositionByIndex(e,n),u=c.getNoMergeCellPositionByIndex(o,r);return{startRow:e,startColumn:n,endRow:o,endColumn:r,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(t){if(t==null)return;const e=this._scene,n=this._skeleton;if(e==null||n==null)return;const{actualRow:o,actualColumn:r,isMerged:s,isMergedMainCell:a,startRow:c,startColumn:d,endRow:u,endColumn:h}=t,m=n.getNoMergeCellPositionByIndex(o,r),S=n.getNoMergeCellPositionByIndex(c,d),_=n.getNoMergeCellPositionByIndex(u,h);return{actualRow:o,actualColumn:r,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:(S==null?void 0:S.startY)||0,endY:(_==null?void 0:_.endY)||0,startX:(S==null?void 0:S.startX)||0,endX:(_==null?void 0:_.endX)||0}}}_moving(t,e,n,o){var se;const r=this._skeleton,s=this._scene;if(s==null||r==null)return!1;const{startRow:a,startColumn:c,endRow:d,endColumn:u}=this._startSelectionRange,{startRow:h,endRow:m,startColumn:S,endColumn:_}=(n==null?void 0:n.model)||{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1},g=s.getViewport(F.VIEW_MAIN),v=(se=this._getViewportByCell(m,_))!=null?se:g,M=s.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY]),v),{scaleX:R,scaleY:b}=s.getAncestorScale(),{rowHeaderWidth:E,columnHeaderHeight:T}=r;o===l.RANGE_TYPE.ROW?t=Number.POSITIVE_INFINITY:o===l.RANGE_TYPE.COLUMN&&(e=Number.POSITIVE_INFINITY);const y=this._getSelectedRangeWithMerge(t,e,R,b,M);if(!y)return!1;const{rangeWithCoord:O,primaryWithCoord:N}=y,{startRow:D,startColumn:k,endColumn:A,endRow:L}=O,B=Math.min(D,a),j=Math.min(k,c),X=Math.max(L,d),z=Math.max(A,u);let Z={startRow:B,startColumn:j,endRow:X,endColumn:z};if(this._isDetectMergedCell&&(Z=r.getSelectionBounding(B,j,X,z)),!Z)return!1;const{startRow:ee,startColumn:ne,endRow:U,endColumn:W}=Z,$=r.getNoMergeCellPositionByIndex(ee,ne),q=r.getNoMergeCellPositionByIndex(U,W),re={startColumn:ne,startRow:ee,endColumn:W,endRow:U,startY:($==null?void 0:$.startY)||0,endY:(q==null?void 0:q.endY)||0,startX:($==null?void 0:$.startX)||0,endX:(q==null?void 0:q.endX)||0};(S!==ne||h!==ee||_!==W||m!==U)&&n!=null&&(n.update(re,E,T),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_endSelection(){var n,o;const t=this._scene;if(t==null)return;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),t.enableEvent(),(n=this._scrollTimer)==null||n.dispose();const e=(o=t.getEngine())==null?void 0:o.activeScene;e==null||e.onPointerDownObserver.remove(this._cancelDownObserver),e==null||e.onPointerUpObserver.remove(this._cancelUpObserver)}_addCancelObserver(){var n;const t=this._scene;if(t==null)return;const e=(n=t.getEngine())==null?void 0:n.activeScene;e==null||e===t||(e.onPointerDownObserver.remove(this._cancelDownObserver),e.onPointerUpObserver.remove(this._cancelUpObserver),this._cancelDownObserver=e.onPointerDownObserver.add(o=>{this._endSelection()}),this._cancelUpObserver=e.onPointerUpObserver.add(o=>{this._endSelection()}))}_getSelectedRangeWithMerge(t,e,n,o,r){var M;if(this._isDetectMergedCell){const R=(M=this._skeleton)==null?void 0:M.calculateCellIndexByPosition(t,e,n,o,r),b=l.makeCellToSelection(R);return b==null?void 0:{primaryWithCoord:R,rangeWithCoord:b}}const s=this._skeleton;if(s==null)return;const a=s.getCellPositionByOffset(t,e,n,o,r),{row:c,column:d}=a,u=s.getNoMergeCellPositionByIndex(c,d),{startX:h,startY:m,endX:S,endY:_}=u,g={startY:m,endY:_,startX:h,endX:S,startRow:c,endRow:c,startColumn:d,endColumn:d};return{primaryWithCoord:{actualRow:c,actualColumn:d,isMerged:!1,isMergedMainCell:!1,startY:m,endY:_,startX:h,endX:S,mergeInfo:g},rangeWithCoord:g}}},x.SelectionRenderService=Ys([pn(0,P.Inject(l.ThemeService)),pn(1,C.IShortcutService),pn(2,P.Inject(x.SheetSkeletonManagerService)),pn(3,P.Inject(P.Injector))],x.SelectionRenderService);const ge=P.createIdentifier("deprecated.univer.sheet.selection-render-service");var Xs=Object.defineProperty,$s=Object.getOwnPropertyDescriptor,Zs=(i,t,e,n)=>{for(var o=n>1?void 0:n?$s(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Xs(t,e,o),o},st=(i,t)=>(e,n)=>t(e,n,i);const Gs=1e4,Lt=P.createIdentifier("univer.mark-selection-service");x.MarkSelectionService=class extends l.Disposable{constructor(e,n,o,r,s,a,c){super();I(this,"_shapeMap",new Map);this._currentService=e,this._renderManagerService=n,this._selectionRenderService=o,this._commandService=r,this._sheetSkeletonManagerService=s,this._themeService=a,this._selectionManagerService=c}addShape(e,n=[],o=Gs){const r=this._currentService.getCurrentUniverSheetInstance(),s=r.getActiveSheet().getSheetId(),a=l.Tools.generateRandomId();return this._shapeMap.set(a,{selection:e,subUnitId:s,unitId:r.getUnitId(),zIndex:o,control:null,exits:n}),this.refreshShapes(),a}refreshShapes(){const e=this._currentService.getCurrentUniverSheetInstance().getUnitId(),n=this._currentService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();this._shapeMap.forEach(o=>{var R;const{unitId:r,subUnitId:s,selection:a,control:c,zIndex:d}=o;if(c&&c.dispose(),r!==e||s!==n)return;const{style:u}=a,{scene:h}=this._renderManagerService.getRenderById(r)||{},{rangeWithCoord:m,primaryWithCoord:S}=this._selectionRenderService.convertSelectionRangeToData(a),_=(R=this._sheetSkeletonManagerService.getCurrent())==null?void 0:R.skeleton;if(!h||!_)return;const{rowHeaderWidth:g,columnHeaderHeight:v}=_,M=new gn(h,d,!1,this._themeService);M.update(m,g,v,u,S),o.control=M})}getShapeMap(){return this._shapeMap}removeShape(e){const n=this._shapeMap.get(e);if(!n)return;const{control:o}=n;o&&o.dispose(),this._shapeMap.delete(e)}removeAllShapes(){for(const e of this._shapeMap.values()){const{control:n}=e;n&&n.dispose()}this._shapeMap.clear()}},x.MarkSelectionService=Zs([st(0,l.IUniverInstanceService),st(1,w.IRenderManagerService),st(2,ge),st(3,l.ICommandService),st(4,P.Inject(x.SheetSkeletonManagerService)),st(5,P.Inject(l.ThemeService)),st(6,P.Inject(f.SelectionManagerService))],x.MarkSelectionService);const Ks=10,Qs=6;function Js(){return l.Tools.generateRandomId(Qs)}function qs(i){const t=i.match(/data-copy-id="([^\s]+)"/);return t&&t[1]?t[1]:null}class ea{constructor(){I(this,"_cache",new l.LRUMap(Ks))}set(t,e){this._cache.set(t,e)}get(t){return this._cache.get(t)}del(t){this._cache.delete(t)}clear(){this._cache.clear()}}var at=(i=>(i.COPY="COPY",i.CUT="CUT",i))(at||{});function ta(i,t,e,n,o){const r=[],s=[];if(n.copyType===at.CUT){const{undos:a,redos:c}=na(i,t,o);r.push(...c),s.push(...a)}else{const{undos:a,redos:c}=Eo(t,e,o);r.push(...c),s.push(...a);const{undos:d,redos:u}=wo(t,e,o);r.push(...u),s.push(...d);const{undos:h,redos:m}=To(t,e,o);r.push(...m),s.push(...h);const{undos:S,redos:_}=ui(t,e,o);r.push(..._),s.push(...S)}return{undos:s,redos:r}}function na(i,t,e){let n=[],o=[];const{range:r,subUnitId:s,unitId:a}=i,{range:c,subUnitId:d}=t;if(r&&c){const u=e.get(l.IUniverInstanceService),h=e.get(f.SheetInterceptorService),m=u.getUniverSheetInstance(a),S=m==null?void 0:m.getSheetBySheetId(s),_=m==null?void 0:m.getSheetBySheetId(d);if(S&&_){const g=new l.ObjectMatrix,v=new l.ObjectMatrix,M=S.getCellMatrix(),R=_.getCellMatrix();l.Range.foreach(r,(z,Z)=>{g.setValue(z,Z,l.Tools.deepClone(M.getValue(z,Z))),v.setValue(z,Z,null)});const b=new l.ObjectMatrix;l.Range.foreach(c,(z,Z)=>{b.setValue(z,Z,l.Tools.deepClone(R.getValue(z,Z)))});const E=new l.ObjectMatrix;l.Range.foreach(r,(z,Z)=>{const ee=l.cellToRange(z,Z),ne=l.Rectangle.getRelativeRange(ee,r),U=l.Rectangle.getPositionRange(ne,c);E.setValue(U.startRow,U.startColumn,M.getValue(z,Z))});const T={from:{value:v.getMatrix(),subUnitId:s},to:{value:E.getMatrix(),subUnitId:d},unitId:a},y={from:{value:g.getMatrix(),subUnitId:s},to:{value:b.getMatrix(),subUnitId:d},unitId:a},O=h.onCommandExecute({id:f.MoveRangeCommand.id,params:{toRange:c,fromRange:r}}),N=S.getMergeData(),D=_.getMergeData(),k=N.filter(z=>l.Rectangle.intersects(z,r)),A=D.filter(z=>l.Rectangle.intersects(z,c)),L=k.map(z=>l.Rectangle.getRelativeRange(z,r)).map(z=>l.Rectangle.getPositionRange(z,c)),B=f.getAddMergeMutationRangeByType(L).filter(z=>!D.some(Z=>l.Rectangle.equals(z,Z))),j=[{id:f.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:k}},{id:f.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:A}},{id:f.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:d,ranges:B}}],X=[{id:f.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:d,ranges:B}},{id:f.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:d,ranges:A}},{id:f.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:k}}];n=[{id:f.MoveRangeMutation.id,params:T},...O.redos,...j,{id:f.SetSelectionsOperation.id,params:{unitId:a,subUnitId:d,pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:c}]}}],o=[{id:f.SetSelectionsOperation.id,params:{unitId:a,sheetId:s,pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:r}]}},...O.undos,...X,{id:f.MoveRangeMutation.id,params:y}]}}return{undos:o,redos:n}}function wo(i,t,e){const{unitId:n,subUnitId:o,range:r}=i,s=[],a=[],{startColumn:c,startRow:d}=r,u=new l.ObjectMatrix;t.forValue((S,_,g)=>{u.setValue(S+d,_+c,l.Tools.deepClone(g))});const h={unitId:n,subUnitId:o,cellValue:u.getData()};s.push({id:f.SetRangeValuesMutation.id,params:h});const m=f.SetRangeValuesUndoMutationFactory(e,h);return a.push({id:f.SetRangeValuesMutation.id,params:m}),{undos:a,redos:s}}function To(i,t,e){const n=[],o=[],{unitId:r,subUnitId:s,range:a}=i,{startColumn:c,startRow:d}=a,u=new l.ObjectMatrix;t.forValue((S,_,g)=>{var M;const v={s:g.s};(M=g.p)!=null&&M.body&&(v.p=g.p),u.setValue(S+d,_+c,v)});const h={unitId:r,subUnitId:s,cellValue:u.getData()};n.push({id:f.SetRangeValuesMutation.id,params:h});const m=f.SetRangeValuesUndoMutationFactory(e,h);return o.push({id:f.SetRangeValuesMutation.id,params:m}),{undos:o,redos:n}}function Eo(i,t,e){const n=[],o=[],r=new l.ObjectMatrix,{unitId:s,subUnitId:a,range:c}=i,{startColumn:d,startRow:u}=c;if(t.forValue((h,m,S)=>{S.s&&r.setValue(h+u,m+d,{s:null})}),r.getLength()>0){const h={subUnitId:a,unitId:s,cellValue:r.getData()};n.push({id:f.SetRangeValuesMutation.id,params:h});const m=f.SetRangeValuesUndoMutationFactory(e,h);o.push({id:f.SetRangeValuesMutation.id,params:m})}return{undos:o,redos:n}}function ui(i,t,e){const n=[],o=[],{unitId:r,subUnitId:s,range:a}=i,{startColumn:c,startRow:d,endColumn:u,endRow:h}=a;let m=!1;const S=[];if(t.forValue((v,M,R)=>{if(R.rowSpan){const b=R.colSpan||1,E={startRow:d+v,endRow:d+v+R.rowSpan-1,startColumn:c+M,endColumn:c+M+b-1};S.push(E),m=!0}else if(R.colSpan){const b=R.rowSpan||1,E={startRow:d+v,endRow:d+v+b-1,startColumn:c+M,endColumn:c+M+R.colSpan-1};S.push(E),m=!0}}),m){const M=e.get(l.IUniverInstanceService).getUniverSheetInstance(r),R=M==null?void 0:M.getSheetBySheetId(s);if(M&&R){const E=R.getMergeData().filter(O=>l.Rectangle.intersects({startRow:d,startColumn:c,endRow:h,endColumn:u},O)),T={unitId:r,subUnitId:s,ranges:E};n.push({id:f.RemoveWorksheetMergeMutation.id,params:T});const y=f.RemoveMergeUndoMutationFactory(e,T);o.push({id:f.AddWorksheetMergeMutation.id,params:y})}}const _={unitId:r,subUnitId:s,ranges:S};S.length>0&&n.push({id:f.AddWorksheetMergeMutation.id,params:_});const g=f.AddMergeUndoMutationFactory(e,_);return S.length>0&&o.push({id:f.RemoveWorksheetMergeMutation.id,params:g}),{undos:o,redos:n}}function yo(i){let t=i.replace(/(\r\n|\n)/g,"\r");t.endsWith(`\r
|
|
1
|
+
(function(A,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@wendellhu/redi"),require("rxjs"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("@univerjs/docs"),require("rxjs/operators"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@wendellhu/redi/react-bindings"),require("react"),require("clsx"),require("@univerjs/engine-numfmt")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/ui","@wendellhu/redi","rxjs","@univerjs/docs-ui","@univerjs/engine-render","@univerjs/docs","rxjs/operators","@univerjs/design","@univerjs/engine-formula","@wendellhu/redi/react-bindings","react","clsx","@univerjs/engine-numfmt"],l):(A=typeof globalThis<"u"?globalThis:A||self,l(A.UniverSheetsUi={},A.UniverCore,A.UniverSheets,A.UniverUi,A["@wendellhu/redi"],A.rxjs,A.UniverDocsUi,A.UniverEngineRender,A.UniverDocs,A.rxjs.operators,A.UniverDesign,A.UniverEngineFormula,A["@wendellhu/redi/react-bindings"],A.React,A.clsx,A.UniverEngineNumfmt))})(this,function(A,l,f,C,P,k,ri,w,te,Is,le,K,Z,L,xe,Ms){"use strict";var Gm=Object.defineProperty;var Km=(A,l,f)=>l in A?Gm(A,l,{enumerable:!0,configurable:!0,writable:!0,value:f}):A[l]=f;var I=(A,l,f)=>(Km(A,typeof l!="symbol"?l+"":l,f),f);var oo;const co="SheetUI";function hn(i,t){if(i==null)return;const e=t.getRenderById(i);if(e==null)return;const{mainComponent:n,scene:o,engine:r}=e;return{document:n,scene:o,engine:r}}const si={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},mn=["零","一","二","三","四","五","六","七","八","九"],uo=["","万","亿","万亿","亿亿"],Rs=["","十","百","千"],ho={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function Ye(i){if(!i)return 0;let t=0,e=0,n=0,o=!1;const r=i.split("");for(let s=0;s<r.length;s++){const a=si[r[s]];if(typeof a<"u")n=a,s===r.length-1&&(e+=n);else{const c=ho[r[s]],d=c.value;o=c.secUnit,o?(e=(e+n)*d,t+=e,e=0):e+=n*d,n=0}}return t+e}function bs(i){let t="",e="",n=0,o=!0;for(;i>0;){const r=i%10;r===0?o||(o=!0,e=mn[r]+e):(o=!1,t=mn[r],t+=Rs[n],e=t+e),n++,i=Math.floor(i/10)}return e}function ws(i){let t=0,e="",n="",o=!1;if(i===0)return mn[0];for(;i>0;){const r=i%1e4;o&&(n=mn[0]+n),e=bs(r),e+=r!==0?uo[t]:uo[0],n=e+n,o=r<1e3&&r>0,i=Math.floor(i/1e4),t++}return n}function Ts(i){if(!i)return!1;let t=!0;if(i)if(i.length===1)i==="日"||i in si?t=!0:t=!1;else{const e=i.split("");for(let n=0;n<e.length;n++)if(!(e[n]in si||e[n]in ho)){t=!1;break}}return t}function Sn(i){if(!i)return{isExtendNumber:!1};const t=/0|([1-9]+[0-9]*)/g,e=t.test(i);if(e){const n=i.match(t);if(n&&n.length>0){const o=n[n.length-1],r=i.lastIndexOf(o),s=i.substr(0,r),a=i.substr(r+o.length);return{isExtendNumber:!0,matchTxt:Number(o),beforeTxt:s,afterTxt:a}}return{isExtendNumber:!1}}return{isExtendNumber:e}}function Es(i){let t;return i.length===2&&(i==="周一"||i==="周二"||i==="周三"||i==="周四"||i==="周五"||i==="周六"||i==="周日")?t=!0:t=!1,t}function ys(i){let t;return i.length===3&&(i==="星期一"||i==="星期二"||i==="星期三"||i==="星期四"||i==="星期五"||i==="星期六"||i==="星期日")?t=!0:t=!1,t}function Os(i,t){let e=0;for(let n=0;n<i.length&&i[n]<t;n++)e++;return e}function Pt(i){let t=!0;const e=i[1]-i[0];for(let n=1;n<i.length;n++)if(i[n]-i[n-1]!==e){t=!1;break}return t}function As(i,t,e){const n=[],o=Math.floor(t/i),r=t%i;let s=0;if(o>0){for(let a=0;a<o;a++)for(let c=0;c<e.length;c++)n[e[c]+a*i]=s,s++;for(let a=0;a<e.length&&e[a]<r;a++)n[e[a]+i*o]=s,s++}else for(let a=0;a<e.length&&e[a]<r;a++)n[e[a]]=s,s++;return n}function rt(i,t){const e=[];for(let n=1;n<=t;n++){const o=(n-1)%i.length,r=l.Tools.deepClone(i[o]);e.push({v:null,s:null,p:null,f:null,si:null,t:null,...r})}return e}function xs(i,t){var n;const e=[];for(let o=1;o<=t;o++){const r=(o-1)%i.length,s={s:(n=i[r])==null?void 0:n.s};e.push(s)}return e}function Ns(i){let t=!0;const e=i[1]/i[0];for(let n=1;n<i.length;n++)if(i[n]/i[n-1]!==e){t=!1;break}return t}function Ds(i){const t=[];for(let e=1;e<=i;e++)t.push(e);return t}function mo(i,t,e){var r,s,a,c;const n=[],o=[];for(let d=0;d<i.length;d++)o.push(Number((r=i[d])==null?void 0:r.v));if(i.length>2&&Ns(o))for(let d=1;d<=t;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.t!==l.CellValueType.BOOLEAN&&(h.v=m),n.push(h))}else{const d=Ds(i.length);for(let u=1;u<=t;u++){const h=(u-1)%i.length,m=l.Tools.deepClone(i[h]),S=e===l.Direction.DOWN||e===l.Direction.RIGHT,g=Ps(i.length+u,o,d,S);m&&(m.t!==l.CellValueType.BOOLEAN&&(m.v=g),n.push(m))}}return n}function Ps(i,t,e,n=!0){function o(h){let m=0;for(let S=0;S<h.length;S++)m+=h[S];return m/h.length}const r=o(e),s=o(t);let a=0,c=0;for(let h=0;h<e.length;h++)a+=(e[h]-r)*(t[h]-s),c+=(e[h]-r)*(e[h]-r);let d;c===0?d=n?1:-1:d=a/c;const u=s-d*r;return Math.round((u+d*i)*1e5)/1e5}function So(i,t,e){var r;const n=[],o=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=t;s++){const a=(s-1)%i.length,c=l.Tools.deepClone(i[a]),d=`${(r=i[i.length-1])==null?void 0:r.v}`,u=d==null?void 0:d.match(o),h=u==null?void 0:u[u.length-1],m=Math.abs(Number(h)+e*s);if(!d||!h)continue;const S=d.lastIndexOf(h),g=d.substr(0,S)+m.toString()+d.substr(S+h.length);c&&(c.v=g,n.push(c))}return n}function _t(i,t,e,n=0){var a,c;const o=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(n>=o.length)return[];const r=o[n],s=[];for(let d=1;d<=t;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)===r[0])m=7+e*d;else{const g=`${(c=i[i.length-1])==null?void 0:c.v}`;if(g){const _=g.substr(g.length-1,1);m=Ye(_)+e*d}}m<0&&(m=Math.ceil(Math.abs(m)/7)*7+m);const S=m%7;h&&(h.v=r[S],s.push(h))}return s}function go(i,t,e){var o;const n=[];for(let r=1;r<=t;r++){const s=(r-1)%i.length,a=l.Tools.deepClone(i[s]),c=`${(o=i[i.length-1])==null?void 0:o.v}`,d=Ye(c)+e*r;let u;d<=0?u="零":u=ws(d),a&&(a.v=u,n.push(a))}return n}const Lt={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 Ls(i){let t=!1;return Object.keys(Lt).forEach(e=>{Lt[e].includes(i)&&(t=!0)}),t}function ai(i){let t="";const e=[];return Object.keys(Lt).forEach(n=>{Lt[n].includes(i)&&(t=n,e.push(...Lt[n]))}),{name:t,series:e}}function _o(i,t,e,n){var s;const o=n.length,r=[];for(let a=1;a<=t;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)+e*a;h<0&&(h+=Math.abs(e)*o);const m=h%o;d&&(d.v=n[m],r.push(d))}return r}function Us(i,t){const e=[];let n;if(t.startRow<i.startRow)n=l.Direction.UP;else if(t.endRow>i.endRow)n=l.Direction.DOWN;else if(t.startColumn<i.startColumn)n=l.Direction.LEFT;else if(t.endColumn>i.endColumn)n=l.Direction.RIGHT;else return[];if(n===l.Direction.DOWN||n===l.Direction.UP){const o=i.endRow-i.startRow+1,r=t.endRow-t.startRow+1,s=Math.floor(r/o),a=r%o,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++)e.push({repeatStartCell:{row:i.startRow+(d+1)*o,col:i.startColumn},relativeRange:c});a>0&&e.push({repeatStartCell:{row:i.startRow+(s+1)*o,col:i.startColumn},relativeRange:{startRow:0,startColumn:0,endRow:a-1,endColumn:i.endColumn-i.startColumn}})}else{for(let d=0;d<s;d++)e.push({repeatStartCell:{row:i.startRow-(d+1)*o,col:i.startColumn},relativeRange:c});a>0&&e.push({repeatStartCell:{row:i.startRow-(s+1)*o,col:i.startColumn},relativeRange:{startRow:o-a,endRow:o-1,startColumn:0,endColumn:i.endColumn-i.startColumn}})}}if(n===l.Direction.RIGHT||n===l.Direction.LEFT){const o=i.endColumn-i.startColumn+1,r=t.endColumn-t.startColumn+1,s=Math.floor(r/o),a=r%o,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++)e.push({repeatStartCell:{row:i.startRow,col:i.startColumn+(d+1)*o},relativeRange:c});a>0&&e.push({repeatStartCell:{row:i.startRow,col:i.startColumn+(s+1)*o},relativeRange:{startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:a-1}})}else{for(let d=0;d<s;d++)e.push({repeatStartCell:{row:i.startRow,col:i.startColumn-(d+1)*o},relativeRange:c});a>0&&e.push({repeatStartCell:{row:i.startRow,col:i.startColumn-(s+1)*o},relativeRange:{startRow:0,startColumn:o-a,endRow:i.endRow-i.startRow,endColumn:o-1}})}}return e}function fo(i){const t=new l.ObjectMatrix;return i.forEach(e=>{const{startRow:n,startColumn:o,endRow:r,endColumn:s}=e;for(let a=n;a<=r;a++)for(let c=o;c<=s;c++)t.setValue(a,c,{v:null,p:null,f:null,si:null})}),t.getData()}const po={type:l.CommandType.COMMAND,id:"sheet.command.auto-fill",handler:async(i,t)=>!0},gn={id:"sheet.command.auto-clear-content",type:l.CommandType.COMMAND,handler:async(i,t)=>{const e=i.get(l.IUniverInstanceService);i.get(f.SelectionManagerService);const n=i.get(l.ICommandService),o=i.get(l.IUndoRedoService),r=e.getCurrentUniverSheetInstance(),s=r.getUnitId(),c=r.getActiveSheet().getSheetId(),{clearRange:d,selectionRange:u}=t,h={subUnitId:c,unitId:s,cellValue:fo([d])},m=f.SetRangeValuesUndoMutationFactory(i,h),{startColumn:S,startRow:g}=u;return n.executeCommand(f.SetSelectionsOperation.id,{selections:[{primary:{startColumn:S,startRow:g,endColumn:S,endRow:g,actualRow:g,actualColumn:S,isMerge:!1,isMergedMainCell:!1},range:{...u}}],unitId:s,subUnitId:c}),n.syncExecuteCommand(f.SetRangeValuesMutation.id,h)?(o.pushUndoRedo({unitID:s,undoMutations:[{id:f.SetRangeValuesMutation.id,params:m}],redoMutations:[{id:f.SetRangeValuesMutation.id,params:h}]}),!0):!1}};function li(i){return i.getContextValue(l.FOCUSING_SHEET)}function ie(i){return i.getContextValue(l.FOCUSING_SHEET)&&i.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&!i.getContextValue(l.EDITOR_ACTIVATED)}function vo(i){return i.getContextValue(l.FOCUSING_SHEET)&&i.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&!i.getContextValue(l.EDITOR_ACTIVATED)&&!i.getContextValue(l.FOCUSING_FORMULA_EDITOR)}function Co(i){return i.getContextValue(l.FOCUSING_SHEET)&&i.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&i.getContextValue(l.EDITOR_ACTIVATED)}function Hs(i){return i.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&i.getContextValue(l.EDITOR_ACTIVATED)}function Io(i){return i.getContextValue(l.FOCUSING_FORMULA_EDITOR)&&i.getContextValue(l.FOCUSING_UNIVER_EDITOR)}function Vs(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 _n(i){return i.getContextValue(l.FOCUSING_SHEET)&&i.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&i.getContextValue(l.EDITOR_ACTIVATED)&&!i.getContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA)&&!i.getContextValue(l.FOCUSING_EDITOR_STANDALONE)}var _e=(i=>(i.MAIN="__SpreadsheetRender__",i.ROW="__SpreadsheetRowHeader__",i.COLUMN="__SpreadsheetColumnHeader__",i.LEFT_TOP="__SpreadsheetLeftTopPlaceholder__",i))(_e||{}),F=(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))(F||{});const Mo=0,et=2,ks=3,ci=[10,400],Ro=1001;var Bs=Object.defineProperty,Fs=Object.getOwnPropertyDescriptor,Ws=(i,t,e,n)=>{for(var o=n>1?void 0:n?Fs(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Bs(t,e,o),o},di=(i,t)=>(e,n)=>t(e,n,i);A.SheetSkeletonManagerService=class{constructor(t,e,n){I(this,"_currentSkeleton",{unitId:"",sheetId:""});I(this,"_sheetSkeletonParam",[]);I(this,"_currentSkeleton$",new k.BehaviorSubject(null));I(this,"currentSkeleton$",this._currentSkeleton$.asObservable());I(this,"_currentSkeletonBefore$",new k.BehaviorSubject(null));I(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._currentUniverService=t,this._injector=e,this._localeService=n}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParam=[]}getCurrent(){return this._getCurrentBySearch(this._currentSkeleton)}setCurrent(t){this._setCurrent(t)}_compareSearch(t,e){return t==null||e==null?!1:t.commandId===e.commandId&&t.sheetId===e.sheetId&&t.unitId===e.unitId}_setCurrent(t){const e=this._getCurrentBySearch(t);if(e!=null)this._reCalculate(e);else{const{unitId:o,sheetId:r}=t,s=this._currentUniverService.getUniverSheetInstance(t.unitId),a=s==null?void 0:s.getSheetBySheetId(t.sheetId);if(a==null||s==null)return;const c=this._buildSkeleton(a,s);this._sheetSkeletonParam.push({unitId:o,sheetId:r,skeleton:c,dirty:!1})}this._currentSkeleton=t;const n=this.getCurrent();this._currentSkeletonBefore$.next(n),this._currentSkeleton$.next(n)}reCalculate(){const t=this.getCurrent();t!=null&&this._reCalculate(t)}_reCalculate(t){t.dirty&&(t.skeleton.makeDirty(!0),t.dirty=!1),t.skeleton.calculate()}makeDirtyCurrent(t=!0){this.makeDirty(this._currentSkeleton,t)}makeDirty(t,e=!0){const n=this._getCurrentBySearch(t);n!=null&&(n.dirty=e)}getOrCreateSkeleton(t){const e=this._getCurrentBySearch(t);if(e)return e.skeleton;const n=this._currentUniverService.getUniverSheetInstance(t.unitId),o=n==null?void 0:n.getSheetBySheetId(t.sheetId);if(!o||!n)return;const r=this._buildSkeleton(o,n);return this._sheetSkeletonParam.push({unitId:t.unitId,sheetId:t.sheetId,skeleton:r,dirty:!1}),r}_getCurrentBySearch(t){const e=this._sheetSkeletonParam.find(n=>n.unitId===t.unitId&&n.sheetId===t.sheetId);return e!=null&&(e.commandId=t.commandId),e}_buildSkeleton(t,e){const n=t.getConfig();return this._injector.createInstance(w.SpreadsheetSkeleton,t,n,t.getCellMatrix(),e.getStyles())}},A.SheetSkeletonManagerService=Ws([di(0,l.IUniverInstanceService),di(1,P.Inject(P.Injector)),di(2,P.Inject(l.LocaleService))],A.SheetSkeletonManagerService);class js{constructor(){I(this,"_startColumn",-1);I(this,"_startRow",-1);I(this,"_endColumn",-1);I(this,"_endRow",-1);I(this,"_startX",0);I(this,"_startY",0);I(this,"_endX",0);I(this,"_endY",0);I(this,"_currentCell");I(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(t){const{startColumn:e,startRow:n,endColumn:o,endRow:r}=this,{startColumn:s,startRow:a,endColumn:c,endRow:d}=t;return e===s&&n===a&&o===c&&r===d}isInclude(t){const{startColumn:e,startRow:n,endColumn:o,endRow:r}=this,{startColumn:s,startRow:a,endColumn:c,endRow:d}=t;return!(c<e||s>o||a>r||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(t,e){const{startColumn:n,startRow:o,endColumn:r,endRow:s,startX:a,startY:c,endX:d,endY:u,rangeType:h}=t;this._startColumn=n,this._startRow=o,this._endColumn=r,this._endRow=s,this._startX=a,this._startY=c,this._endX=d,this._endY=u,h!=null&&(this._rangeType=h),this.setCurrentCell(e)}setCurrentCell(t){t&&(this._currentCell=t)}clearCurrentCell(){this._currentCell=null}}const bo=.3;class fn extends l.Disposable{constructor(e,n,o=!0,r){super();I(this,"_leftControl");I(this,"_rightControl");I(this,"_topControl");I(this,"_bottomControl");I(this,"_backgroundControlTop");I(this,"_backgroundControlBottom");I(this,"_backgroundControlMiddleLeft");I(this,"_backgroundControlMiddleRight");I(this,"_fillControl");I(this,"_selectionShape");I(this,"_rowHeaderBackground");I(this,"_rowHeaderBorder");I(this,"_rowHeaderGroup");I(this,"_rowHeaderHighlight");I(this,"_columnHeaderBackground");I(this,"_columnHeaderBorder");I(this,"_columnHeaderGroup");I(this,"_columnHeaderHighlight");I(this,"_topLeftWidget");I(this,"_topCenterWidget");I(this,"_topRightWidget");I(this,"_middleLeftWidget");I(this,"_middleRightWidget");I(this,"_bottomLeftWidget");I(this,"_bottomCenterWidget");I(this,"_bottomRightWidget");I(this,"_dashRect");I(this,"_selectionModel");I(this,"_selectionStyle");I(this,"_rowHeaderWidth",0);I(this,"_columnHeaderHeight",0);I(this,"_widgetRects",[]);I(this,"_dispose$",new k.BehaviorSubject(this));I(this,"dispose$",this._dispose$.asObservable());I(this,"selectionMoving$",new k.Subject);I(this,"selectionMoved$",new k.Subject);I(this,"selectionScaling$",new k.Subject);I(this,"selectionScaled$",new k.Subject);I(this,"selectionFilling$",new k.Subject);I(this,"_selectionFilled$",new k.Subject);I(this,"selectionFilled$",this._selectionFilled$.asObservable());I(this,"_defaultStyle");I(this,"_currentStyle");I(this,"_isHelperSelection",!0);I(this,"_antLineOffset",0);I(this,"_antRequestNewFrame",-1);this._scene=e,this._zIndex=n,this._isHeaderHighlight=o,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,n=0,o=0,r,s){this._selectionModel.setValue(e,s),r==null&&(r=this._selectionStyle),this._updateControl(r,n,o)}clearHighlight(){this._selectionModel.clearCurrentCell(),this._updateControl(this._selectionStyle,this._rowHeaderWidth,this._columnHeaderHeight)}getScene(){return this._scene}dispose(){var e,n,o,r,s,a,c,d,u,h,m,S,g,_,v,M,R,b,E,T,y,O,x,N,V;(e=this._leftControl)==null||e.dispose(),(n=this._rightControl)==null||n.dispose(),(o=this._topControl)==null||o.dispose(),(r=this._bottomControl)==null||r.dispose(),(s=this._backgroundControlTop)==null||s.dispose(),(a=this._backgroundControlMiddleLeft)==null||a.dispose(),(c=this._backgroundControlMiddleRight)==null||c.dispose(),(d=this._backgroundControlBottom)==null||d.dispose(),(u=this._fillControl)==null||u.dispose(),(h=this._selectionShape)==null||h.dispose(),(m=this._rowHeaderBackground)==null||m.dispose(),(S=this._rowHeaderBorder)==null||S.dispose(),(g=this._rowHeaderGroup)==null||g.dispose(),(_=this._rowHeaderBackground)==null||_.dispose(),(v=this._columnHeaderBackground)==null||v.dispose(),(M=this._columnHeaderBorder)==null||M.dispose(),(R=this._columnHeaderGroup)==null||R.dispose(),(b=this._topLeftWidget)==null||b.dispose(),(E=this._topCenterWidget)==null||E.dispose(),(T=this._topRightWidget)==null||T.dispose(),(y=this._middleLeftWidget)==null||y.dispose(),(O=this._middleRightWidget)==null||O.dispose(),(x=this._bottomLeftWidget)==null||x.dispose(),(N=this._bottomCenterWidget)==null||N.dispose(),(V=this._bottomRightWidget)==null||V.dispose(),super.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let n;if(e.isMerged){const o=e.mergeInfo;n={startRow:o.startRow,endRow:o.endRow,startColumn:o.startColumn,endColumn:o.endColumn,startX:o.startX,endX:o.endX,startY:o.startY,endY:o.endY}}else{const{actualRow:o,actualColumn:r,startX:s,endX:a,startY:c,endY:d}=e;n={startRow:o,endRow:o,startColumn:r,endColumn:r,startX:s,endX:a,startY:c,endY:d}}return n}}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,n,o){const{startX:r,startY:s,endX:a,endY:c}=this._selectionModel,d=this._defaultStyle;e==null&&(e=d),this._currentStyle=e;const{stroke:u=d.stroke,widgets:h=d.widgets,hasAutoFill:m=d.hasAutoFill,AutofillStroke:S=d.AutofillStroke,strokeDash:g,isAnimationDash:_}=e;let{strokeWidth:v=d.strokeWidth,AutofillSize:M=d.AutofillSize,AutofillStrokeWidth:R=d.AutofillStrokeWidth}=e;const b=this._getScale(),E=(v+f.SELECTION_CONTROL_BORDER_BUFFER_WIDTH)/2/b;v/=b,M/=b,R/=b<1?1:b;const T=f.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/b,y=w.FIX_ONE_PIXEL_BLUR_OFFSET/b;if(this.leftControl.transformByState({height:c-s,left:-E+y,width:v,strokeWidth:T,top:-T/2+y}),this.leftControl.setProps({fill:u,stroke:f.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:c-s,left:a-r-E+y,width:v,strokeWidth:T,top:-T/2+y}),this.rightControl.setProps({fill:u,stroke:f.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:a-r+v,top:-E+y,left:-E+y,height:v,strokeWidth:T}),this.topControl.setProps({fill:u,stroke:f.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:a-r+v,top:c-s-E+y,height:v,left:-E+y,strokeWidth:T}),this.bottomControl.setProps({fill:u,stroke:f.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),g==null)this.dashRect.hide(),this._stopAntLineAnimation();else{const O=e.strokeWidth*2/b;this.dashRect.transformByState({height:c-s,width:a-r,strokeWidth:O,left:-O/2+y,top:-O/2+y}),this.dashRect.setProps({strokeDashArray:[0,g/b]}),this._stopAntLineAnimation(),_!==!1&&this._startAntLineAnimation(),this.dashRect.show()}m===!0&&!this._hasWidgets(h)?(this.fillControl.setProps({fill:u,stroke:S,strokeScaleEnabled:!1}),this.fillControl.transformByState({width:M-R,height:M-R,left:a-r-M/2+R/2-y,top:c-s-M/2+R/2-y,strokeWidth:R}),this.fillControl.show()):this.fillControl.hide(),this._updateBackgroundControl(e),this._updateBackgroundTitle(e,n,o),this._updateWidgets(e),this.selectionShape.show(),this.selectionShape.translate(r,s),this._selectionStyle=e,this._rowHeaderWidth=n||0,this._columnHeaderHeight=o||0,this.selectionShape.makeDirtyNoDebounce(!0)}_initialize(){this._defaultStyle=f.getNormalSelectionStyle(this._themeService),this._selectionModel=new js;const e=this._zIndex;this._leftControl=new w.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightControl=new w.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topControl=new w.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomControl=new w.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new w.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new w.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new w.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new w.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._fillControl=new w.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._dashRect=new w.Rect("__SpreadsheetDragDashControl__"+e,{zIndex:e+2,evented:!1,stroke:"#fff"});const n=[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 w.Group("__SpreadsheetSelectionShape__"+e,...n,...this._widgetRects),this._selectionShape.hide(),this._selectionShape.evented=!1,this._selectionShape.zIndex=e;const o=this.getScene();o.addObject(this._selectionShape,ks),this.disposeWithMe(l.toDisposable(o.onTransformChangeObservable.add(r=>{r.type===w.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&this._updateControl(this._currentStyle,this._rowHeaderWidth,this._columnHeaderHeight)}))),this._initialTitle()}_initialTitle(){const e=this._zIndex;this._rowHeaderBackground=new w.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new w.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new w.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new w.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new w.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new w.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],w.DEFAULT_SELECTION_LAYER_INDEX)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new w.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new w.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new w.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new w.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new w.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new w.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new w.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new w.Rect("__SpreadSheetSelectionBottomRightWidget__"+e,{zIndex:e+1}),[this._topLeftWidget,this._topCenterWidget,this._topRightWidget,this._middleLeftWidget,this._middleRightWidget,this._bottomLeftWidget,this._bottomCenterWidget,this._bottomRightWidget]}_updateBackgroundTitle(e,n,o){const{startX:r,startY:s,endX:a,endY:c,rangeType:d}=this._selectionModel,u=this._defaultStyle;e==null&&(e=u);const h=this._getScale(),{stroke:m,hasRowHeader:S,rowHeaderFill:g=u.rowHeaderFill,rowHeaderStroke:_=u.rowHeaderStroke,hasColumnHeader:v,columnHeaderFill:M=u.columnHeaderFill,columnHeaderStroke:R=u.columnHeaderStroke}=e;let{rowHeaderStrokeWidth:b=u.rowHeaderStrokeWidth,columnHeaderStrokeWidth:E=u.columnHeaderStrokeWidth}=e;if(b/=h,E/=h,v===!0){let T=M;this._isHeaderHighlight&&d===l.RANGE_TYPE.COLUMN&&(T=new l.ColorKit(m).setAlpha(bo).toString()),this._columnHeaderBackground.setProps({fill:T}),this._columnHeaderBackground.resize(a-r,o),this._columnHeaderBorder.setProps({fill:R}),this._columnHeaderBorder.transformByState({width:a-r,height:E,top:o-E+1/h}),this._columnHeaderGroup.show(),this._columnHeaderGroup.translate(r,0)}else this._columnHeaderGroup.hide();if(this._columnHeaderGroup.makeDirty(!0),S===!0){let T=g;this._isHeaderHighlight&&d===l.RANGE_TYPE.ROW&&(T=new l.ColorKit(m).setAlpha(bo).toString()),this._rowHeaderBackground.setProps({fill:T}),this._rowHeaderBackground.resize(n,c-s),this._rowHeaderBorder.setProps({fill:_}),this._rowHeaderBorder.transformByState({width:b,height:c-s,left:n-b+1/h}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,s)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){const{startX:n,startY:o,endX:r,endY:s}=this._selectionModel,a=this._defaultStyle;e==null&&(e=a);const c=this._getScale(),{fill:d=a.fill}=e;let{strokeWidth:u=a.strokeWidth}=e;u/=c;const h=this._selectionModel.highlightToSelection();if(!h){this._backgroundControlTop.resize(r-n,s-o),this._backgroundControlTop.setProps({fill:d}),this._backgroundControlBottom.resize(0,0),this._backgroundControlMiddleLeft.resize(0,0),this._backgroundControlMiddleRight.resize(0,0);return}const{startX:m,startY:S,endX:g,endY:_}=h,v=u/2,M={left:-v,top:-v,width:r-n+v*2,height:S-o+v};M.height<0&&(M.width=0,M.height=0),this._backgroundControlTop.transformByState(M);const R={left:-v,top:S-o,width:m-n+v,height:_-S};R.width<0&&(R.width=0,R.height=0),this._backgroundControlMiddleLeft.transformByState(R);const b={left:g-n-v,top:S-o,width:r-g+v*2,height:_-S};b.width<0&&(b.width=0,b.height=0),this._backgroundControlMiddleRight.transformByState(b);const E={left:-v,top:_-o,width:r-n+v*2,height:s-_+v};E.height<0&&(E.width=0,E.height=0),this._backgroundControlBottom.transformByState(E),this._backgroundControlTop.setProps({fill:d}),this._backgroundControlMiddleLeft.setProps({fill:d}),this._backgroundControlMiddleRight.setProps({fill:d}),this._backgroundControlBottom.setProps({fill:d})}_updateWidgets(e){const{startX:n,startY:o,endX:r,endY:s}=this._selectionModel,a=this._defaultStyle;e==null&&(e=a);const{stroke:c=a.stroke,widgets:d=a.widgets,widgetStroke:u=a.widgetStroke}=e,h=this._getScale();let{widgetSize:m=a.widgetSize,widgetStrokeWidth:S=a.widgetStrokeWidth}=e;m/=h,S/=h;const g={left:-m/2+S/2,center:(r-n)/2-m/2+S/2,right:r-n-m/2+S/2,top:-m/2,middle:(s-o)/2-m/2,bottom:s-o-m/2+S/2},_=m-S;this._widgetRects.forEach(v=>{v.setProps({fill:c,stroke:u})}),d.tl===!0?(this._topLeftWidget.transformByState({height:_,width:_,left:g.left,top:g.top,strokeWidth:S}),this._topLeftWidget.show()):this._topLeftWidget.hide(),d.tc===!0?(this._topCenterWidget.transformByState({height:_,width:_,left:g.center,top:g.top,strokeWidth:S}),this._topCenterWidget.show()):this._topCenterWidget.hide(),d.tr===!0?(this._topRightWidget.transformByState({height:_,width:_,left:g.right,top:g.top,strokeWidth:S}),this._topRightWidget.show()):this._topRightWidget.hide(),d.ml===!0?(this._middleLeftWidget.transformByState({height:_,width:_,left:g.left,top:g.middle,strokeWidth:S}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),d.mr===!0?(this._middleRightWidget.transformByState({height:_,width:_,left:g.right,top:g.middle,strokeWidth:S}),this._middleRightWidget.show()):this._middleRightWidget.hide(),d.bl===!0?(this._bottomLeftWidget.transformByState({height:_,width:_,left:g.left,top:g.bottom,strokeWidth:S}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),d.bc===!0?(this._bottomCenterWidget.transformByState({height:_,width:_,left:g.center,top:g.bottom,strokeWidth:S}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),d.br===!0?(this._bottomRightWidget.transformByState({height:_,width:_,left:g.right,top:g.bottom,strokeWidth:S}),this._bottomRightWidget.show()):this._bottomRightWidget.hide()}_hasWidgets(e){if(e==null)return!1;const n=Object.keys(e);if(n.length===0)return!1;for(const o of n)if(e[o]===!0)return!0;return!0}_getScale(){const{scaleX:e,scaleY:n}=this._scene.getAncestorScale();return Math.max(e,n)}_stopAntLineAnimation(){this._antLineOffset=0,w.cancelRequestFrame(this._antRequestNewFrame)}_startAntLineAnimation(){const e=this._getScale();this._antLineOffset+=.6/e,this._antLineOffset>16/e&&(this._antLineOffset=0),this.dashRect.setProps({strokeDashOffset:-this._antLineOffset}),this._antRequestNewFrame=w.requestNewFrame(()=>{this._startAntLineAnimation()})}}const wo="__SpreadsheetHelperSelectionTempRect",zs=35;class To{constructor(t,e,n,o,r){I(this,"_startOffsetX",0);I(this,"_startOffsetY",0);I(this,"_relativeSelectionPositionRow",0);I(this,"_relativeSelectionPositionColumn",0);I(this,"_relativeSelectionRowLength",0);I(this,"_relativeSelectionColumnLength",0);I(this,"_moveObserver");I(this,"_upObserver");I(this,"_helperSelection");I(this,"_scrollTimer");I(this,"_activeViewport");I(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});I(this,"_isInMergeState",!1);I(this,"_fillControlColors",[]);this._control=t,this._skeleton=e,this._scene=n,this._themeService=o,this._injector=r,this._initialControl(),this._initialWidget(),this._initialFill(),this._control.dispose$.subscribe(()=>{this.dispose()})}get isHelperSelection(){return this._control.isHelperSelection}dispose(){var t,e;(t=this._scrollTimer)==null||t.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(e=this._helperSelection)==null||e.dispose()}_getFreeze(){var e;return(e=this._injector.get(A.SheetSkeletonManagerService).getCurrent())==null?void 0:e.skeleton.getWorksheetConfig().freeze}_isSelectionInViewport(t,e){const n=this._getFreeze()||{startRow:-1,startColumn:-1,xSplit:0,ySplit:0};switch(e.viewPortKey){case F.VIEW_MAIN:return t.endRow>=n.startRow&&t.endColumn>=n.startColumn;case F.VIEW_MAIN_TOP:case F.VIEW_COLUMN_RIGHT:return t.endColumn>=n.startColumn&&t.startRow<n.startRow;case F.VIEW_MAIN_LEFT:case F.VIEW_ROW_BOTTOM:return t.endRow>=n.startRow&&t.startColumn<n.startColumn;case F.VIEW_MAIN_LEFT_TOP:case F.VIEW_COLUMN_LEFT:case F.VIEW_ROW_TOP:case F.VIEW_LEFT_TOP:return t.startRow<n.startRow&&t.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:t,rightControl:e,topControl:n,bottomControl:o}=this._control;[t,e,n,o].forEach(r=>{r.onPointerEnterObserver.add(()=>{r.setCursor(w.CURSOR_TYPE.MOVE)}),r.onPointerLeaveObserver.add(()=>{r.resetCursor()}),r.onPointerDownObserver.add(this._controlEvent.bind(this))})}_controlMoving(t,e){var y;const n=this._scene,o=n.getScrollXYByRelativeCoords(w.Vector2.FromArray([t,e])),{scaleX:r,scaleY:s}=n.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(t,e,r,s,o),{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 S=m+this._relativeSelectionRowLength;S>u&&(S=u,S-m<this._relativeSelectionRowLength&&(m=S-this._relativeSelectionRowLength));let g=d+this._relativeSelectionPositionColumn;g<0&&(g=0);let _=g+this._relativeSelectionColumnLength;_>h&&(_=h,_-g<this._relativeSelectionColumnLength&&(g=_-this._relativeSelectionColumnLength));const v=this._skeleton.getNoMergeCellPositionByIndex(m,g),M=this._skeleton.getNoMergeCellPositionByIndex(S,_),R=(v==null?void 0:v.startY)||0,b=(M==null?void 0:M.endY)||0,E=(v==null?void 0:v.startX)||0,T=(M==null?void 0:M.endX)||0;(y=this._helperSelection)==null||y.transformByState({left:E,top:R,width:T-E,height:b-R}),this._targetSelection={startY:R,endY:b,startX:E,endX:T,startRow:m,endRow:S,startColumn:g,endColumn:_},this._control.selectionMoving$.next(this._targetSelection)}_controlEvent(t){const{offsetX:e,offsetY:n}=t,o=this._scene,r=o.getRelativeCoord(w.Vector2.FromArray([e,n])),{x:s,y:a}=r,c=o.getScrollXYByRelativeCoords(r),{scaleX:d,scaleY:u}=o.getAncestorScale(),h=this._skeleton.getCellPositionByOffset(s,a,d,u,c);this._startOffsetX=s,this._startOffsetY=a;const{row:m,column:S}=h,{startRow:g,startColumn:_,endRow:v,endColumn:M}=this._control.model;let R=0,b=0;m<g?R-=1:m>v&&(R+=1),S<_?b-=1:S>M&&(b+=1),this._relativeSelectionPositionRow=g-m+R,this._relativeSelectionPositionColumn=_-S+b,this._relativeSelectionRowLength=v-g,this._relativeSelectionColumnLength=M-_;const E=this._control.selectionStyle,T=this._getScale();this.isHelperSelection&&(this._helperSelection=new w.Rect(wo,{stroke:E.stroke,strokeWidth:E.strokeWidth/T}),o.addObject(this._helperSelection));const y=o.getViewport(F.VIEW_MAIN),O=w.ScrollTimer.create(o);O.startScroll(s,a,y),this._scrollTimer=O,o.disableEvent(),this._moveObserver=o.onPointerMoveObserver.add(x=>{const{offsetX:N,offsetY:V}=x,{x:D,y:H}=o.getRelativeCoord(w.Vector2.FromArray([N,V]));this._controlMoving(D,H),o.setCursor(w.CURSOR_TYPE.MOVE),O.scrolling(D,H,()=>{this._controlMoving(D,H)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var N,V;(N=this._helperSelection)==null||N.dispose();const x=this._scene;x.resetCursor(),this._clearObserverEvent(),x.enableEvent(),(V=this._scrollTimer)==null||V.dispose(),this._control.selectionMoved$.next(this._targetSelection)})}_initialWidget(){const{topLeftWidget:t,topCenterWidget:e,topRightWidget:n,middleLeftWidget:o,middleRightWidget:r,bottomLeftWidget:s,bottomCenterWidget:a,bottomRightWidget:c}=this._control,d=[w.CURSOR_TYPE.NORTH_WEST_RESIZE,w.CURSOR_TYPE.NORTH_RESIZE,w.CURSOR_TYPE.NORTH_EAST_RESIZE,w.CURSOR_TYPE.WEST_RESIZE,w.CURSOR_TYPE.EAST_RESIZE,w.CURSOR_TYPE.SOUTH_WEST_RESIZE,w.CURSOR_TYPE.SOUTH_RESIZE,w.CURSOR_TYPE.SOUTH_EAST_RESIZE];[t,e,n,o,r,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(t,e,n){const o=this._scene,r=o.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:a}=o.getAncestorScale(),c=this._skeleton.getCellPositionByOffset(t,e,s,a,r),{row:d,column:u}=c,{rowHeaderWidth:h,columnHeaderHeight:m}=this._skeleton;let S=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,_=d,v=u;n===w.CURSOR_TYPE.NORTH_WEST_RESIZE?(S=d,g=u,_=this._relativeSelectionPositionRow,v=this._relativeSelectionPositionColumn):n===w.CURSOR_TYPE.NORTH_RESIZE?(S=d,g=this._relativeSelectionPositionColumn,_=this._relativeSelectionPositionRow,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):n===w.CURSOR_TYPE.NORTH_EAST_RESIZE?(S=d,g=this._relativeSelectionPositionColumn,_=this._relativeSelectionPositionRow,v=u):n===w.CURSOR_TYPE.WEST_RESIZE?(S=this._relativeSelectionPositionRow,g=u,_=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,v=this._relativeSelectionPositionColumn):n===w.CURSOR_TYPE.EAST_RESIZE?_=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:n===w.CURSOR_TYPE.SOUTH_WEST_RESIZE?(S=this._relativeSelectionPositionRow,g=u,_=d,v=this._relativeSelectionPositionColumn):n===w.CURSOR_TYPE.SOUTH_RESIZE&&(S=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,_=d,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const{startRow:M,startColumn:R,endRow:b,endColumn:E}=this._swapPositions(S,g,_,v),T=this._skeleton.getNoMergeCellPositionByIndex(M,R),y=this._skeleton.getNoMergeCellPositionByIndex(b,E),O=(T==null?void 0:T.startY)||0,x=(y==null?void 0:y.endY)||0,N=(T==null?void 0:T.startX)||0,V=(y==null?void 0:y.endX)||0;this._targetSelection={startY:O,endY:x,startX:N,endX:V,startRow:S,endRow:_,startColumn:g,endColumn:v},this._control.update(this._targetSelection,h,m,this._control.selectionStyle),this._control.clearHighlight(),this._control.selectionScaling$.next(this._targetSelection)}_widgetEvent(t,e){const{offsetX:n,offsetY:o}=t,r=this._scene,s=r.getRelativeCoord(w.Vector2.FromArray([n,o])),{x:a,y:c}=s;this._startOffsetX=n,this._startOffsetY=o;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,e===w.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=h,this._relativeSelectionPositionColumn=m):e===w.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=h:e===w.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=h:e===w.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=m:e===w.CURSOR_TYPE.SOUTH_WEST_RESIZE&&(this._relativeSelectionPositionColumn=m);const S=w.ScrollTimer.create(r);S.startScroll(a,c),this._scrollTimer=S,r.disableEvent(),this._moveObserver=r.onPointerMoveObserver.add(g=>{const{offsetX:_,offsetY:v}=g,{x:M,y:R}=r.getRelativeCoord(w.Vector2.FromArray([_,v]));this._widgetMoving(M,R,e),r.setCursor(e),S.scrolling(M,R,()=>{this._widgetMoving(M,R,e)})}),this._upObserver=r.onPointerUpObserver.add(()=>{var _;const g=this._scene;g.resetCursor(),this._clearObserverEvent(),g.enableEvent(),(_=this._scrollTimer)==null||_.dispose(),this._control.selectionScaled$.next(this._targetSelection)})}_initialFill(){const{fillControl:t}=this._control;t.onPointerEnterObserver.add(()=>{t.setCursor(w.CURSOR_TYPE.CROSSHAIR)}),t.onPointerLeaveObserver.add(()=>{t.resetCursor()}),t.onPointerDownObserver.add(this._fillEvent.bind(this))}_fillMoving(t,e){var V,D,H;const n=this._scene,o=n.getScrollXY(this._activeViewport),{scaleX:r,scaleY:s}=n.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(t,e,r,s,o),{row:c,column:d}=a,u=n.getRelativeCoord(w.Vector2.FromArray([t,e])),h=this._skeleton.getRowCount()-1,m=this._skeleton.getColumnCount()-1;let S=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,_=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,M=!1,R=!0;if((d<g||d>v)&&c>=S&&c<=_){const B=this._fillRuler(d,g,v,this._relativeSelectionColumnLength,m);g=B.startRowOrColumn,v=B.endRowOrColumn,M=B.isLighten,R=!1}else if((c<S||c>_)&&d>=g&&d<=v){const B=this._fillRuler(c,S,_,this._relativeSelectionRowLength,h);S=B.startRowOrColumn,_=B.endRowOrColumn,M=B.isLighten}else if(Math.abs(this._startOffsetX-u.x-o.x)/2>Math.abs(this._startOffsetY-u.y-o.y)){const B=this._fillRuler(d,g,v,this._relativeSelectionColumnLength,m);g=B.startRowOrColumn,v=B.endRowOrColumn,M=B.isLighten,R=!1}else{const B=this._fillRuler(c,S,_,this._relativeSelectionRowLength,h);S=B.startRowOrColumn,_=B.endRowOrColumn,M=B.isLighten}const b=this._skeleton.getNoMergeCellPositionByIndex(S,g),E=this._skeleton.getNoMergeCellPositionByIndex(_,v),T=(b==null?void 0:b.startY)||0,y=(E==null?void 0:E.endY)||0,O=(b==null?void 0:b.startX)||0,x=(E==null?void 0:E.endX)||0;M?this._controlHandler((B,j)=>{const X=new l.ColorKit(this._fillControlColors[j]).lighten(zs).toRgbString();B.setProps({fill:X})}):this._controlHandler((B,j)=>{B.setProps({fill:this._fillControlColors[j]})});const N=f.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();S===_&&R===!0||g===v&&R===!1?(V=this._helperSelection)==null||V.hide():((D=this._helperSelection)==null||D.transformByState({left:O-N/2,top:T-N/2,width:x-O,height:y-T}),(H=this._helperSelection)==null||H.show()),this._targetSelection={startY:T,endY:y,startX:O,endX:x,startRow:S,endRow:_,startColumn:g,endColumn:v},this._control.selectionFilling$.next(this._targetSelection)}_fillEvent(t){const{offsetX:e,offsetY:n}=t,o=this._scene,r=o.getRelativeCoord(w.Vector2.FromArray([e,n])),{x:s,y:a}=r;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 S=m==null?void 0:m.stroke,g=m==null?void 0:m.strokeWidth;const _=f.getNormalSelectionStyle(this._themeService);S==null&&(S=_.stroke),g==null&&(g=_.strokeWidth);const v=this._getScale();g/=v;const M=f.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/v,R=new l.ColorKit(S).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new w.Rect(wo,{stroke:R,strokeWidth:g+M/2}),o.addObject(this._helperSelection)),this._activeViewport=o.getActiveViewportByCoord(w.Vector2.FromArray([e,n]));const b=o.getViewport(F.VIEW_MAIN),E=w.ScrollTimer.create(o,this._activeViewport.viewPortKey===F.VIEW_MAIN?w.ScrollTimerType.ALL:w.ScrollTimerType.NONE);E.startScroll(s,a,b),this._scrollTimer=E,o.disableEvent(),this._controlHandler(T=>{this._fillControlColors.push(T.fill)}),this._moveObserver=o.onPointerMoveObserver.add(T=>{var H;const{offsetX:y,offsetY:O}=T,x=o.getActiveViewportByCoord(w.Vector2.FromArray([y,O])),{x:N,y:V}=o.getRelativeCoord(w.Vector2.FromArray([y,O]));this._fillMoving(N,V),o.setCursor(w.CURSOR_TYPE.CROSSHAIR);const D=this._targetSelection;if(b&&x&&((H=this._activeViewport)==null?void 0:H.viewPortKey)!==(x==null?void 0:x.viewPortKey)){let B;D.startRow!==c?(E.scrollTimerType=w.ScrollTimerType.Y,B={...D,endRow:D.startRow}):D.endRow!==u?(E.scrollTimerType=w.ScrollTimerType.Y,B={...D,startRow:D.endRow}):D.startColumn!==d?(E.scrollTimerType=w.ScrollTimerType.X,B={...D,endColumn:D.startColumn}):(E.scrollTimerType=w.ScrollTimerType.X,B={...D,startColumn:D.endColumn}),this._isSelectionInViewport(B,x)&&(b.scrollTo({x:E.scrollTimerType===w.ScrollTimerType.X?0:void 0,y:E.scrollTimerType===w.ScrollTimerType.Y?0:void 0}),this._activeViewport=x)}E.scrolling(N,V,()=>{this._fillMoving(N,V)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var y,O;(y=this._helperSelection)==null||y.dispose();const T=this._scene;T.resetCursor(),this._clearObserverEvent(),T.enableEvent(),(O=this._scrollTimer)==null||O.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((x,N)=>{x.setProps({fill:this._fillControlColors[N]})}),this._fillControlColors=[]})}_hasMergeInRange(t,e,n,o){const r=this._skeleton.mergeData;if(!r)return!1;for(const s of r){const{startRow:a,startColumn:c,endRow:d,endColumn:u}=s,h={left:e,top:t,right:o,bottom:n},m={left:c,top:a,right:u,bottom:d};if(w.isRectIntersect(h,m))return!0}return!1}_swapPositions(t,e,n,o){const r=Math.min(t,n),s=Math.min(e,o),a=Math.max(t,n),c=Math.max(e,o);return{startRow:r,startColumn:s,endRow:a,endColumn:c}}_controlHandler(t){const{leftControl:e,rightControl:n,topControl:o,bottomControl:r,backgroundControlTop:s,backgroundControlMiddleLeft:a,backgroundControlMiddleRight:c,backgroundControlBottom:d,fillControl:u}=this._control,h=[e,n,o,r,s,a,c,d,u];for(let m=0,S=h.length;m<S;m++){const g=h[m];t(g,m)}}_fillRuler(t,e,n,o,r){let s=!1;if(t<e)if(this._isInMergeState&&t<e){const a=e-t,c=o+1,d=Math.ceil(a/c);let u=e-d*c;u<0&&(u=e-(d-1)*c),e=u}else e=t;else if(t>=e&&t<=n)s=!0,this._isInMergeState||(n=t);else if(this._isInMergeState&&t>n){const a=t-n,c=o+1,d=Math.ceil(a/c);let u=n+d*c;u>r&&(u=n+(d-1)*c),n=u}else n=t;return{rowOrColumn:t,startRowOrColumn:e,endRowOrColumn:n,isLighten:s}}_getScale(){const{scaleX:t,scaleY:e}=this._scene.getAncestorScale();return Math.max(t,e)}}var Ys=Object.defineProperty,Xs=Object.getOwnPropertyDescriptor,$s=(i,t,e,n)=>{for(var o=n>1?void 0:n?Xs(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Ys(t,e,o),o},pn=(i,t)=>(e,n)=>t(e,n,i);A.SelectionRenderService=class{constructor(t,e,n,o){I(this,"hasSelection",!1);I(this,"_downObserver");I(this,"_moveObserver");I(this,"_upObserver");I(this,"_controlFillConfig$",new k.BehaviorSubject(null));I(this,"controlFillConfig$",this._controlFillConfig$.asObservable());I(this,"_selectionControls",[]);I(this,"_startSelectionRange",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});I(this,"_startOffsetX",0);I(this,"_startOffsetY",0);I(this,"_scrollTimer");I(this,"_cancelDownObserver");I(this,"_cancelUpObserver");I(this,"_skeleton");I(this,"_scene");I(this,"_isHeaderHighlight",!0);I(this,"_isDetectMergedCell",!0);I(this,"_selectionStyle");I(this,"_isSelectionEnabled",!0);I(this,"_isShowPreviousEnable",0);I(this,"_isRemainLastEnable",!0);I(this,"_isSkipRemainLastEnable",!1);I(this,"_isSingleSelection",!1);I(this,"_selectionMoveEnd$",new k.BehaviorSubject([]));I(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());I(this,"_selectionMoving$",new k.Subject);I(this,"selectionMoving$",this._selectionMoving$.asObservable());I(this,"_selectionMoveStart$",new k.Subject);I(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());I(this,"_activeViewport");this._themeService=t,this._shortcutService=e,this._sheetSkeletonManagerService=n,this._injector=o,this._selectionStyle=f.getNormalSelectionStyle(this._themeService)}enableHeaderHighlight(){this._isHeaderHighlight=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}enableDetectMergedCell(){this._isDetectMergedCell=!0}disableDetectMergedCell(){this._isDetectMergedCell=!1}setStyle(t){this._selectionStyle=t}resetStyle(){this.setStyle(f.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}enableSingleSelection(){this._isSingleSelection=!0}disableSingleSelection(){this._isSingleSelection=!1}getViewPort(){return this._activeViewport}addControlToCurrentByRangeData(t){const e=this.getCurrentControls();if(!e)return;const{rangeWithCoord:n,primaryWithCoord:o}=t,r=this._skeleton;let s=t.style;s==null&&(s=f.getNormalSelectionStyle(this._themeService));const a=this._scene;if(a==null||r==null)return;const c=new fn(a,e.length,this._isHeaderHighlight,this._themeService);new To(c,r,a,this._themeService,this._injector);const{rowHeaderWidth:d,columnHeaderHeight:u}=r;c.update(n,d,u,s,o),this._isHeaderHighlight?c.enableHeaderHighlight():c.disableHeaderHighlight(),e.push(c)}updateControlForCurrentByRangeData(t){const e=this.getCurrentControls();if(!e)return;const n=this._skeleton;if(n==null)return;const{rowHeaderWidth:o,columnHeaderHeight:r}=n;for(let s=0,a=t.length;s<a;s++){const{rangeWithCoord:c,primaryWithCoord:d,style:u}=t[s];e[s].update(c,o,r,u,d)}}refreshSelectionMoveStart(){this._selectionMoveStart$.next(this.getSelectionDataWithStyle())}changeRuntime(t,e,n){this._skeleton=t,this._scene=e,this._activeViewport=n||e.getViewports()[0]}getSelectionDataWithStyle(){return this._selectionControls.map(e=>e.getValue())}getCurrentControls(){return this._selectionControls}_clearSelectionControls(){const t=this.getCurrentControls();if(t.length>0){for(const e of t)e.dispose();t.length=0}}_getFreeze(){var e;return(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig().freeze}_getViewportByCell(t,e){if(!this._scene||t===void 0||e===void 0)return null;const n=this._getFreeze();if(!n||n.startRow<=0&&n.startColumn<=0)return this._scene.getViewport(F.VIEW_MAIN);if(t>n.startRow&&e>n.startColumn)return this._scene.getViewport(F.VIEW_MAIN);if(t<=n.startRow&&e<=n.startColumn)return this._scene.getViewport(F.VIEW_MAIN_LEFT_TOP);if(t<=n.startRow&&e>n.startColumn)return this._scene.getViewport(F.VIEW_MAIN_TOP);if(t>n.startRow&&e<=n.startColumn)return this._scene.getViewport(F.VIEW_MAIN_LEFT)}getActiveSelections(){const t=this.getCurrentControls();if(t&&t.length>0)return t==null?void 0:t.map(n=>{const o=n.model,r=o.currentCell;let s=null;return r&&(s={actualRow:r.actualRow,actualColumn:r.actualColumn,isMerged:r.isMerged,isMergedMainCell:r.isMergedMainCell,startRow:r.mergeInfo.startRow,startColumn:r.mergeInfo.startColumn,endRow:r.mergeInfo.endRow,endColumn:r.mergeInfo.endColumn}),{range:{startRow:o.startRow,startColumn:o.startColumn,endRow:o.endRow,endColumn:o.endColumn},primary:s}})}getActiveRange(){const t=this.getCurrentControls(),e=t&&t[t.length-1].model;return e&&{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}}getActiveSelection(){const t=this.getCurrentControls();return t&&t[t.length-1]}endSelection(){this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}reset(){var t,e,n;this._clearSelectionControls(),(t=this._moveObserver)==null||t.dispose(),(e=this._upObserver)==null||e.dispose(),(n=this._downObserver)==null||n.dispose(),this._moveObserver=null,this._upObserver=null,this._downObserver=null}resetAndEndSelection(){this.endSelection(),this.reset()}eventTrigger(t,e=0,n=l.RANGE_TYPE.NORMAL,o,r=w.ScrollTimerType.ALL){var re,se;if(this._isSelectionEnabled===!1)return;const s=this._skeleton,{offsetX:a,offsetY:c}=t,d=this._scene;if(d==null||s==null)return;o!=null&&(this._activeViewport=o);const u=d.getViewport(F.VIEW_MAIN),h=d.getRelativeCoord(w.Vector2.FromArray([a,c]));let{x:m,y:S}=h;this._startOffsetX=m,this._startOffsetY=S;const g=d.getScrollXYByRelativeCoords(h),{scaleX:_,scaleY:v}=d.getAncestorScale();n===l.RANGE_TYPE.ROW?m=0:n===l.RANGE_TYPE.COLUMN&&(S=0);const M=this._getSelectedRangeWithMerge(m,S,_,v,g);if(!M)return!1;const{rangeWithCoord:R,primaryWithCoord:b}=M,{startRow:E,startColumn:T,endColumn:y,endRow:O,startY:x,endY:N,startX:V,endX:D}=R,{rowHeaderWidth:H,columnHeaderHeight:B}=s,j={startColumn:T,startRow:E,endColumn:y,endRow:O,startY:x,endY:N,startX:V,endX:D,rangeType:n};this._startSelectionRange=j;let X=this.getActiveSelection();const z=this.getCurrentControls();if(!z)return!1;for(const Y of z){if(t.button===2&&Y.model.isInclude(j)){X=Y;return}if(Y.model.isEqual(j)){X=Y;break}t.shiftKey||Y.clearHighlight()}if(z.length>0&&!t.ctrlKey&&!t.shiftKey&&!this._isShowPreviousEnable&&!this._isRemainLastEnable||z.length>0&&this._isSingleSelection&&!t.shiftKey){for(const Y of z)Y.dispose();z.length=0}const $=X&&X.model.currentCell;if(X&&t.shiftKey&&$){const{actualRow:Y,actualColumn:Q,mergeInfo:J}=$,ae=Math.min(Y,j.startRow,J.startRow),ce=Math.max(Y,j.endRow,J.endRow),pe=Math.min(Q,j.startColumn,J.startColumn),Qe=Math.max(Q,j.endColumn,J.endColumn),Me=s.getMergeBounding(ae,pe,ce,Qe),ge=s.getNoMergeCellPositionByIndex(Me.startRow,Me.startColumn),de=s.getNoMergeCellPositionByIndex(Me.endRow,Me.endColumn),Je={startColumn:Me.startColumn,startRow:Me.startRow,endColumn:Me.endColumn,endRow:Me.endRow,startY:ge.startY,endY:de.endY,startX:ge.startX,endX:de.endX,rangeType:n},Re=s.getCellByIndex(Y,Q);this._startSelectionRange={startColumn:Re.mergeInfo.startColumn,startRow:Re.mergeInfo.startRow,endColumn:Re.mergeInfo.endColumn,endRow:Re.mergeInfo.endRow,startY:Re.mergeInfo.startY||0,endY:Re.mergeInfo.endY||0,startX:Re.mergeInfo.startX||0,endX:Re.mergeInfo.endX||0,rangeType:n},X.update(Je,H,B,this._selectionStyle,$)}else this._isRemainLastEnable&&X&&!t.ctrlKey&&!t.shiftKey&&!this._isSkipRemainLastEnable&&!this._isSingleSelection?X.update(j,H,B,this._selectionStyle,b):(X=new fn(d,z.length+e,this._isHeaderHighlight,this._themeService),new To(X,s,d,this._themeService,this._injector),X.update(j,H,B,this._selectionStyle,b),z.push(X));this._selectionMoveStart$.next(this.getSelectionDataWithStyle()),this.hasSelection=!0,this._endSelection(),d.disableEvent();const ee=d.getActiveViewportByCoord(w.Vector2.FromArray([m,S])),ne=w.ScrollTimer.create(this._scene,r);ne.startScroll((re=u==null?void 0:u.left)!=null?re:0,(se=u==null?void 0:u.top)!=null?se:0,u),this._scrollTimer=ne,this._addCancelObserver(),(n===l.RANGE_TYPE.ROW||n===l.RANGE_TYPE.COLUMN)&&this._moving(m,S,X,n);let U=0,W=0,G=m,q=S;this._moveObserver=d.onPointerMoveObserver.add(Y=>{var Re,an,ln,cn,dn,_s,fs,ps,vs,Cs;const{offsetX:Q,offsetY:J}=Y,{x:ae,y:ce}=d.getRelativeCoord(w.Vector2.FromArray([Q,J]));this._moving(ae,ce,X,n);let pe=ae,Qe=ce;const Me=this.getActiveSelection(),ge=(Re=this._sheetSkeletonManagerService.getCurrent())==null?void 0:Re.skeleton.getWorksheetConfig().freeze,de=Me==null?void 0:Me.model,Je=(an=d.getActiveViewportByCoord(w.Vector2.FromArray([Q,J])))!=null?an:this._getViewportByCell(de==null?void 0:de.endRow,de==null?void 0:de.endColumn);if(ee&&Je&&u){const ro=G<u.left&&ae>u.left||G>u.left&&ae<u.left,so=q<u.top&&ce>u.top||q>u.top&&ce<u.top;ro&&(U+=1),so&&(W+=1);const ze=ee.viewPortKey,un=Je.viewPortKey;if(ze===F.VIEW_ROW_TOP)J<u.top&&((ln=de==null?void 0:de.endRow)!=null?ln:0)<((cn=ge==null?void 0:ge.startRow)!=null?cn:0)?Qe=u.top:so&&W%2===1&&u.scrollTo({y:0});else if(ze===F.VIEW_COLUMN_LEFT)Q<u.left&&((dn=de==null?void 0:de.endColumn)!=null?dn:0)<((_s=ge==null?void 0:ge.startColumn)!=null?_s:0)?pe=u.left:ro&&U%2===1&&u.scrollTo({x:0});else if(ze===un){let qe=!1,gt=!1;ze===F.VIEW_MAIN_LEFT_TOP?(qe=!0,gt=!0):ze===F.VIEW_MAIN_TOP?gt=!0:ze===F.VIEW_MAIN_LEFT&&(qe=!0),((fs=de==null?void 0:de.endRow)!=null?fs:0)>((ps=ge==null?void 0:ge.startRow)!=null?ps:0)&&(gt=!1),((vs=de==null?void 0:de.endColumn)!=null?vs:0)>((Cs=ge==null?void 0:ge.startColumn)!=null?Cs:0)&&(qe=!1),qe&&(pe=u.left),gt&&(Qe=u.top)}else{const qe={x:ee.scrollX,y:ee.scrollY},gt={x:Je.scrollX,y:Je.scrollY},ao=qe.x!==gt.x&&ro&&U%2===1,lo=qe.y!==gt.y&&so&&W%2===1;(ao||lo)&&(u.scrollTo({x:ao?qe.x:void 0,y:lo?qe.y:void 0}),ao||(pe=u.left),lo||(Qe=u.top)),(ze===F.VIEW_MAIN_LEFT_TOP&&un===F.VIEW_MAIN_LEFT||un===F.VIEW_MAIN_LEFT_TOP&&ze===F.VIEW_MAIN_LEFT)&&(pe=u.left),(ze===F.VIEW_MAIN_LEFT_TOP&&un===F.VIEW_MAIN_TOP||un===F.VIEW_MAIN_LEFT_TOP&&ze===F.VIEW_MAIN_TOP)&&(Qe=u.top)}G=ae,q=ce}ne.scrolling(pe,Qe,()=>{this._moving(ae,ce,X,n)})}),this._upObserver=d.onPointerUpObserver.add(Y=>{this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}),this._shortcutService.setDisable(!0)}convertSelectionRangeToData(t){const{range:e,primary:n,style:o}=t;let r=this.convertRangeDataToSelection(e);return r==null&&(r={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1,startY:0,endY:0,startX:0,endX:0,rangeType:l.RANGE_TYPE.NORMAL}),{rangeWithCoord:r,primaryWithCoord:this.convertCellRangeToInfo(n),style:o}}convertRangeDataToSelection(t){const{startRow:e,startColumn:n,endRow:o,endColumn:r,rangeType:s}=t,a=this._scene,c=this._skeleton;if(a==null||c==null)return;a.getAncestorScale();const d=c.getNoMergeCellPositionByIndex(e,n),u=c.getNoMergeCellPositionByIndex(o,r);return{startRow:e,startColumn:n,endRow:o,endColumn:r,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(t){if(t==null)return;const e=this._scene,n=this._skeleton;if(e==null||n==null)return;const{actualRow:o,actualColumn:r,isMerged:s,isMergedMainCell:a,startRow:c,startColumn:d,endRow:u,endColumn:h}=t,m=n.getNoMergeCellPositionByIndex(o,r),S=n.getNoMergeCellPositionByIndex(c,d),g=n.getNoMergeCellPositionByIndex(u,h);return{actualRow:o,actualColumn:r,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:(S==null?void 0:S.startY)||0,endY:(g==null?void 0:g.endY)||0,startX:(S==null?void 0:S.startX)||0,endX:(g==null?void 0:g.endX)||0}}}_moving(t,e,n,o){var se;const r=this._skeleton,s=this._scene;if(s==null||r==null)return!1;const{startRow:a,startColumn:c,endRow:d,endColumn:u}=this._startSelectionRange,{startRow:h,endRow:m,startColumn:S,endColumn:g}=(n==null?void 0:n.model)||{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1},_=s.getViewport(F.VIEW_MAIN),v=(se=this._getViewportByCell(m,g))!=null?se:_,M=s.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY]),v),{scaleX:R,scaleY:b}=s.getAncestorScale(),{rowHeaderWidth:E,columnHeaderHeight:T}=r;o===l.RANGE_TYPE.ROW?t=Number.POSITIVE_INFINITY:o===l.RANGE_TYPE.COLUMN&&(e=Number.POSITIVE_INFINITY);const y=this._getSelectedRangeWithMerge(t,e,R,b,M);if(!y)return!1;const{rangeWithCoord:O,primaryWithCoord:x}=y,{startRow:N,startColumn:V,endColumn:D,endRow:H}=O,B=Math.min(N,a),j=Math.min(V,c),X=Math.max(H,d),z=Math.max(D,u);let $={startRow:B,startColumn:j,endRow:X,endColumn:z};if(this._isDetectMergedCell&&($=r.getSelectionBounding(B,j,X,z)),!$)return!1;const{startRow:ee,startColumn:ne,endRow:U,endColumn:W}=$,G=r.getNoMergeCellPositionByIndex(ee,ne),q=r.getNoMergeCellPositionByIndex(U,W),re={startColumn:ne,startRow:ee,endColumn:W,endRow:U,startY:(G==null?void 0:G.startY)||0,endY:(q==null?void 0:q.endY)||0,startX:(G==null?void 0:G.startX)||0,endX:(q==null?void 0:q.endX)||0};(S!==ne||h!==ee||g!==W||m!==U)&&n!=null&&(n.update(re,E,T),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_endSelection(){var n,o;const t=this._scene;if(t==null)return;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),t.enableEvent(),(n=this._scrollTimer)==null||n.dispose();const e=(o=t.getEngine())==null?void 0:o.activeScene;e==null||e.onPointerDownObserver.remove(this._cancelDownObserver),e==null||e.onPointerUpObserver.remove(this._cancelUpObserver)}_addCancelObserver(){var n;const t=this._scene;if(t==null)return;const e=(n=t.getEngine())==null?void 0:n.activeScene;e==null||e===t||(e.onPointerDownObserver.remove(this._cancelDownObserver),e.onPointerUpObserver.remove(this._cancelUpObserver),this._cancelDownObserver=e.onPointerDownObserver.add(o=>{this._endSelection()}),this._cancelUpObserver=e.onPointerUpObserver.add(o=>{this._endSelection()}))}_getSelectedRangeWithMerge(t,e,n,o,r){var M;if(this._isDetectMergedCell){const R=(M=this._skeleton)==null?void 0:M.calculateCellIndexByPosition(t,e,n,o,r),b=l.makeCellToSelection(R);return b==null?void 0:{primaryWithCoord:R,rangeWithCoord:b}}const s=this._skeleton;if(s==null)return;const a=s.getCellPositionByOffset(t,e,n,o,r),{row:c,column:d}=a,u=s.getNoMergeCellPositionByIndex(c,d),{startX:h,startY:m,endX:S,endY:g}=u,_={startY:m,endY:g,startX:h,endX:S,startRow:c,endRow:c,startColumn:d,endColumn:d};return{primaryWithCoord:{actualRow:c,actualColumn:d,isMerged:!1,isMergedMainCell:!1,startY:m,endY:g,startX:h,endX:S,mergeInfo:_},rangeWithCoord:_}}},A.SelectionRenderService=$s([pn(0,P.Inject(l.ThemeService)),pn(1,C.IShortcutService),pn(2,P.Inject(A.SheetSkeletonManagerService)),pn(3,P.Inject(P.Injector))],A.SelectionRenderService);const fe=P.createIdentifier("deprecated.univer.sheet.selection-render-service");var Zs=Object.defineProperty,Gs=Object.getOwnPropertyDescriptor,Ks=(i,t,e,n)=>{for(var o=n>1?void 0:n?Gs(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Zs(t,e,o),o},st=(i,t)=>(e,n)=>t(e,n,i);const Qs=1e4,Ut=P.createIdentifier("univer.mark-selection-service");A.MarkSelectionService=class extends l.Disposable{constructor(e,n,o,r,s,a,c){super();I(this,"_shapeMap",new Map);this._currentService=e,this._renderManagerService=n,this._selectionRenderService=o,this._commandService=r,this._sheetSkeletonManagerService=s,this._themeService=a,this._selectionManagerService=c}addShape(e,n=[],o=Qs){const r=this._currentService.getCurrentUniverSheetInstance(),s=r.getActiveSheet().getSheetId(),a=l.Tools.generateRandomId();return this._shapeMap.set(a,{selection:e,subUnitId:s,unitId:r.getUnitId(),zIndex:o,control:null,exits:n}),this.refreshShapes(),a}refreshShapes(){const e=this._currentService.getCurrentUniverSheetInstance().getUnitId(),n=this._currentService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();this._shapeMap.forEach(o=>{var R;const{unitId:r,subUnitId:s,selection:a,control:c,zIndex:d}=o;if(c&&c.dispose(),r!==e||s!==n)return;const{style:u}=a,{scene:h}=this._renderManagerService.getRenderById(r)||{},{rangeWithCoord:m,primaryWithCoord:S}=this._selectionRenderService.convertSelectionRangeToData(a),g=(R=this._sheetSkeletonManagerService.getCurrent())==null?void 0:R.skeleton;if(!h||!g)return;const{rowHeaderWidth:_,columnHeaderHeight:v}=g,M=new fn(h,d,!1,this._themeService);M.update(m,_,v,u,S),o.control=M})}getShapeMap(){return this._shapeMap}removeShape(e){const n=this._shapeMap.get(e);if(!n)return;const{control:o}=n;o&&o.dispose(),this._shapeMap.delete(e)}removeAllShapes(){for(const e of this._shapeMap.values()){const{control:n}=e;n&&n.dispose()}this._shapeMap.clear()}},A.MarkSelectionService=Ks([st(0,l.IUniverInstanceService),st(1,w.IRenderManagerService),st(2,fe),st(3,l.ICommandService),st(4,P.Inject(A.SheetSkeletonManagerService)),st(5,P.Inject(l.ThemeService)),st(6,P.Inject(f.SelectionManagerService))],A.MarkSelectionService);const Js=10,qs=6;function ea(){return l.Tools.generateRandomId(qs)}function ta(i){const t=i.match(/data-copy-id="([^\s]+)"/);return t&&t[1]?t[1]:null}class na{constructor(){I(this,"_cache",new l.LRUMap(Js))}set(t,e){this._cache.set(t,e)}get(t){return this._cache.get(t)}del(t){this._cache.delete(t)}clear(){this._cache.clear()}}var at=(i=>(i.COPY="COPY",i.CUT="CUT",i))(at||{});function ia(i,t,e,n,o){const r=[],s=[];if(n.copyType===at.CUT){const{undos:a,redos:c}=oa(i,t,o);r.push(...c),s.push(...a)}else{const{undos:a,redos:c}=Oo(t,e,o);r.push(...c),s.push(...a);const{undos:d,redos:u}=Eo(t,e,o);r.push(...u),s.push(...d);const{undos:h,redos:m}=yo(t,e,o);r.push(...m),s.push(...h);const{undos:S,redos:g}=ui(t,e,o);r.push(...g),s.push(...S)}return{undos:s,redos:r}}function oa(i,t,e){let n=[],o=[];const{range:r,subUnitId:s,unitId:a}=i,{range:c,subUnitId:d}=t;if(r&&c){const u=e.get(l.IUniverInstanceService),h=e.get(f.SheetInterceptorService),m=u.getUniverSheetInstance(a),S=m==null?void 0:m.getSheetBySheetId(s),g=m==null?void 0:m.getSheetBySheetId(d);if(S&&g){const _=new l.ObjectMatrix,v=new l.ObjectMatrix,M=S.getCellMatrix(),R=g.getCellMatrix();l.Range.foreach(r,(z,$)=>{_.setValue(z,$,l.Tools.deepClone(M.getValue(z,$))),v.setValue(z,$,null)});const b=new l.ObjectMatrix;l.Range.foreach(c,(z,$)=>{b.setValue(z,$,l.Tools.deepClone(R.getValue(z,$)))});const E=new l.ObjectMatrix;l.Range.foreach(r,(z,$)=>{const ee=l.cellToRange(z,$),ne=l.Rectangle.getRelativeRange(ee,r),U=l.Rectangle.getPositionRange(ne,c);E.setValue(U.startRow,U.startColumn,M.getValue(z,$))});const T={from:{value:v.getMatrix(),subUnitId:s},to:{value:E.getMatrix(),subUnitId:d},unitId:a},y={from:{value:_.getMatrix(),subUnitId:s},to:{value:b.getMatrix(),subUnitId:d},unitId:a},O=h.onCommandExecute({id:f.MoveRangeCommand.id,params:{toRange:c,fromRange:r}}),x=S.getMergeData(),N=g.getMergeData(),V=x.filter(z=>l.Rectangle.intersects(z,r)),D=N.filter(z=>l.Rectangle.intersects(z,c)),H=V.map(z=>l.Rectangle.getRelativeRange(z,r)).map(z=>l.Rectangle.getPositionRange(z,c)),B=f.getAddMergeMutationRangeByType(H).filter(z=>!N.some($=>l.Rectangle.equals(z,$))),j=[{id:f.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:V}},{id:f.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:D}},{id:f.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:d,ranges:B}}],X=[{id:f.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:d,ranges:B}},{id:f.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:d,ranges:D}},{id:f.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:V}}];n=[{id:f.MoveRangeMutation.id,params:T},...O.redos,...j,{id:f.SetSelectionsOperation.id,params:{unitId:a,subUnitId:d,pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:c}]}}],o=[{id:f.SetSelectionsOperation.id,params:{unitId:a,sheetId:s,pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:r}]}},...O.undos,...X,{id:f.MoveRangeMutation.id,params:y}]}}return{undos:o,redos:n}}function Eo(i,t,e){const{unitId:n,subUnitId:o,range:r}=i,s=[],a=[],{startColumn:c,startRow:d}=r,u=new l.ObjectMatrix;t.forValue((S,g,_)=>{u.setValue(S+d,g+c,l.Tools.deepClone(_))});const h={unitId:n,subUnitId:o,cellValue:u.getData()};s.push({id:f.SetRangeValuesMutation.id,params:h});const m=f.SetRangeValuesUndoMutationFactory(e,h);return a.push({id:f.SetRangeValuesMutation.id,params:m}),{undos:a,redos:s}}function yo(i,t,e){const n=[],o=[],{unitId:r,subUnitId:s,range:a}=i,{startColumn:c,startRow:d}=a,u=new l.ObjectMatrix;t.forValue((S,g,_)=>{var M;const v={s:_.s};(M=_.p)!=null&&M.body&&(v.p=_.p),u.setValue(S+d,g+c,v)});const h={unitId:r,subUnitId:s,cellValue:u.getData()};n.push({id:f.SetRangeValuesMutation.id,params:h});const m=f.SetRangeValuesUndoMutationFactory(e,h);return o.push({id:f.SetRangeValuesMutation.id,params:m}),{undos:o,redos:n}}function Oo(i,t,e){const n=[],o=[],r=new l.ObjectMatrix,{unitId:s,subUnitId:a,range:c}=i,{startColumn:d,startRow:u}=c;if(t.forValue((h,m,S)=>{S.s&&r.setValue(h+u,m+d,{s:null})}),r.getLength()>0){const h={subUnitId:a,unitId:s,cellValue:r.getData()};n.push({id:f.SetRangeValuesMutation.id,params:h});const m=f.SetRangeValuesUndoMutationFactory(e,h);o.push({id:f.SetRangeValuesMutation.id,params:m})}return{undos:o,redos:n}}function ui(i,t,e){const n=[],o=[],{unitId:r,subUnitId:s,range:a}=i,{startColumn:c,startRow:d,endColumn:u,endRow:h}=a;let m=!1;const S=[];if(t.forValue((v,M,R)=>{if(R.rowSpan){const b=R.colSpan||1,E={startRow:d+v,endRow:d+v+R.rowSpan-1,startColumn:c+M,endColumn:c+M+b-1};S.push(E),m=!0}else if(R.colSpan){const b=R.rowSpan||1,E={startRow:d+v,endRow:d+v+b-1,startColumn:c+M,endColumn:c+M+R.colSpan-1};S.push(E),m=!0}}),m){const M=e.get(l.IUniverInstanceService).getUniverSheetInstance(r),R=M==null?void 0:M.getSheetBySheetId(s);if(M&&R){const E=R.getMergeData().filter(O=>l.Rectangle.intersects({startRow:d,startColumn:c,endRow:h,endColumn:u},O)),T={unitId:r,subUnitId:s,ranges:E};n.push({id:f.RemoveWorksheetMergeMutation.id,params:T});const y=f.RemoveMergeUndoMutationFactory(e,T);o.push({id:f.AddWorksheetMergeMutation.id,params:y})}}const g={unitId:r,subUnitId:s,ranges:S};S.length>0&&n.push({id:f.AddWorksheetMergeMutation.id,params:g});const _=f.AddMergeUndoMutationFactory(e,g);return S.length>0&&o.push({id:f.RemoveWorksheetMergeMutation.id,params:_}),{undos:o,redos:n}}function Ao(i){let t=i.replace(/(\r\n|\n)/g,"\r");t.endsWith(`\r
|
|
2
2
|
`)||(t+=`\r
|
|
3
3
|
`);const e=[];for(let n=0;n<t.length;n++)t[n]==="\r"&&e.push({startIndex:n});return{dataStream:t,paragraphs:e,sectionBreaks:[{startIndex:t.indexOf(`
|
|
4
|
-
`)}]}}function
|
|
5
|
-
`:
|
|
6
|
-
`;const v=[];m==null||m.forEach(R=>{R.st>=S[
|
|
7
|
-
`,
|
|
8
|
-
<tbody>${a.join("")}</tbody></table>`}}const _a=(i,t,e=!1)=>{const n=h=>h.endRow-h.startRow+1,o=h=>h.endColumn-h.startColumn+1,r=n(t)%n(i),s=o(t)%o(i),a={startRow:0,endRow:n(i)-1,startColumn:0,endColumn:o(i)-1},c=Math.floor(n(t)/n(i)),d=Math.floor(o(t)/o(i)),u=[];if(!r&&!s)for(let h=1;h<=c;h++)for(let m=1;m<=d;m++){const S=n(i)*(h-1),_=o(i)*(m-1),g={startRow:S+t.startRow,endRow:S+t.startRow,startColumn:_+t.startColumn,endColumn:_+t.startColumn};u.push({repeatRelativeRange:a,startRange:g})}else if(!r&&s&&!e)for(let h=1;h<=c;h++){const m=n(i)*(h-1),S=0,_={startRow:m+t.startRow,endRow:m+t.startRow,startColumn:S+t.startColumn,endColumn:S+t.startColumn};u.push({repeatRelativeRange:a,startRange:_})}else if(r&&!s&&!e)for(let h=1;h<=d;h++){const S=o(i)*(h-1),_={startRow:0+t.startRow,endRow:0+t.startRow,startColumn:S+t.startColumn,endColumn:S+t.startColumn};u.push({repeatRelativeRange:a,startRange:_})}else{const h={startRow:t.startRow,endRow:t.startRow,startColumn:t.startColumn,endColumn:t.startColumn};u.push({startRange:h,repeatRelativeRange:a})}return u};async function fa(i){return i?/<td[^>]*class=".*?xl.*?"[^>]*>.*?<\/td>/.test(i):!1}function ga(...i){if(i.length===1)return i[0];const t=new l.ObjectMatrix;return i.forEach(e=>{e&&new l.ObjectMatrix(e).forValue((o,r,s)=>{t.setValue(o,r,{...t.getValue(o,r),...s})})}),t.getMatrix()}function pa(i,t){return i.id===t.id&&i.params.unitId===t.params.unitId&&i.params.subUnitId===t.params.subUnitId}function _i(i){const t=[];for(let e=0;e<i.length;){let n=1;if(i[e].id===f.SetRangeValuesMutation.id){const o=i[e],r=[o];for(;e+n<i.length&&pa(o,i[e+n]);)r.push(i[e+n]),n+=1;const s=ga(...r.map(a=>a.params.cellValue||{}));t.push({...o,params:{...o.params,cellValue:s}})}else t.push(i[e]);e+=n}return t}var va=Object.defineProperty,Ca=Object.getOwnPropertyDescriptor,Ia=(i,t,e,n)=>{for(var o=n>1?void 0:n?Ca(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&va(t,e,o),o},Ne=(i,t)=>(e,n)=>t(e,n,i);const ve={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"};gt.use(ri.PastePluginWord),gt.use(ri.PastePluginLark),gt.use(ri.PastePluginUniver);const pt=P.createIdentifier("sheet.clipboard-service");x.SheetClipboardService=class extends l.Disposable{constructor(e,n,o,r,s,a,c,d,u,h,m){super();I(this,"_clipboardHooks",[]);I(this,"_clipboardHooks$",new V.BehaviorSubject([]));I(this,"clipboardHooks$",this._clipboardHooks$.asObservable());I(this,"_htmlToUSM");I(this,"_usmToHtml");I(this,"_copyContentCache");I(this,"_copyMarkId",null);this._logService=e,this._currentUniverService=n,this._selectionManagerService=o,this._clipboardInterfaceService=r,this._undoRedoService=s,this._commandService=a,this._markSelectionService=c,this._sheetSkeletonManagerService=d,this._notificationService=u,this._platformService=h,this._localeService=m,this._htmlToUSM=new gt({getCurrentSkeleton:()=>this._sheetSkeletonManagerService.getCurrent()}),this._usmToHtml=new Sa,this._copyContentCache=new ea,this.disposeWithMe(this._htmlToUSM)}copyContentCache(){return this._copyContentCache}async copy(e=at.COPY){const n=this._selectionManagerService.getLast();if(!n)return!1;const o=this._currentUniverService.getCurrentUniverSheetInstance(),r=o.getActiveSheet(),s=this._clipboardHooks;s.forEach(S=>{var _;return(_=S.onBeforeCopy)==null?void 0:_.call(S,o.getUnitId(),r.getSheetId(),n.range)});const a=this._generateCopyContent(o.getUnitId(),r.getSheetId(),n.range,s);if(!a)return!1;const{html:c,plain:d,matrixFragment:u,copyId:h}=a;this._copyContentCache.set(h,{unitId:o.getUnitId(),subUnitId:r.getSheetId(),range:n.range,matrix:u,copyType:e}),await this._clipboardInterfaceService.write(d,c),this._markSelectionService.removeAllShapes();const m=this._selectionManagerService.createCopyPasteSelection();return this._copyMarkId=this._markSelectionService.addShape({...n,style:m}),s.forEach(S=>{var _;return(_=S.onAfterCopy)==null?void 0:_.call(S)}),!0}async cut(){return this.copy(at.CUT)}async paste(e,n=ve.DEFAULT_PASTE){const o=e.types,r=o.indexOf(C.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(C.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()):"",s=o.indexOf(C.HTML_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(C.HTML_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()):"";return s?this._platformService.isWindows&&await fa(s)?(this._notificationService.show({type:"warning",title:this._localeService.t("clipboard.shortCutNotify.title"),content:this._localeService.t("clipboard.shortCutNotify.useShortCutInstead")}),!1):this._pasteHTML(s,n):r?this._pastePlainText(r,n):(this._logService.error("[SheetClipboardService]","No valid data on clipboard"),!1)}legacyPaste(e,n){return e?this._pasteHTML(e,ve.DEFAULT_PASTE):n?this._pastePlainText(n,ve.DEFAULT_PASTE):Promise.resolve(!1)}addClipboardHook(e){if(this._clipboardHooks.findIndex(o=>o.id===e.id)!==-1)return this._logService.error("[SheetClipboardService]","hook already exists",e.id),{dispose:()=>{}};const n=this._clipboardHooks.findIndex(o=>{const r=o.priority||0;return(e.priority||0)<r});return this._clipboardHooks.splice(n!==-1?n:this._clipboardHooks.length,0,e),this._notifyClipboardHook(),l.toDisposable(()=>{const o=this._clipboardHooks.indexOf(e);o>-1&&(this._clipboardHooks.splice(o,1),this._notifyClipboardHook())})}getClipboardHooks(){return this._clipboardHooks}_generateCopyContent(e,n,o,r){const s=this._currentUniverService.getUniverSheetInstance(e),a=s==null?void 0:s.getSheetBySheetId(n);if(!s||!a)return null;r.reduce((M,R)=>{var E;const b=(E=R.getFilteredOutRows)==null?void 0:E.call(R);return b==null||b.forEach(T=>M.add(T)),M},new Set);const{startColumn:c,startRow:d,endColumn:u,endRow:h}=o,m=a.getMatrixWithMergedCells(d,c,h,u),S=new l.ObjectMatrix;for(let M=d;M<=h;M++)for(let R=c;R<=u;R++){const b=m.getValue(M,R);b?S.setValue(M-d,R-c,{...No(),...l.Tools.deepClone(b)}):S.setValue(M-d,R-c,No())}let _=this._usmToHtml.convert(m,o,r);const g=Ma(S),v=Js();return _=_.replace(/(<[a-z]+)/,(M,R)=>`${R} data-copy-id="${v}"`),{copyId:v,plain:g,html:_,matrixFragment:S}}_notifyClipboardHook(){this._clipboardHooks$.next(this._clipboardHooks)}async _pastePlainText(e,n){const o=this._getPastingTarget();if(!o.selection)return!1;const r=o.selection.range,{unitId:s,subUnitId:a}=o,c=this._clipboardHooks,d=[];if(c.some(_=>{var g;return d.push(_)&&((g=_.onBeforePaste)==null?void 0:g.call(_,{unitId:s,subUnitId:a,range:r}))===!1}))return d.forEach(_=>{var g;return(g=_.onAfterPaste)==null?void 0:g.call(_,!1)}),!1;const h=[],m=[];d.forEach(_=>{var v;const g=(v=_.onPastePlainText)==null?void 0:v.call(_,{unitId:s,subUnitId:a,range:r},e,{pasteType:n});g&&(h.push(...g.redos),m.push(...g.undos))});const S=h.every(_=>this._commandService.executeCommand(_.id,_.params));return S&&this._undoRedoService.pushUndoRedo({unitID:this._currentUniverService.getCurrentUniverSheetInstance().getUnitId(),undoMutations:m,redoMutations:h}),S}async _pasteHTML(e,n){const o=qs(e);return o&&this._copyContentCache.get(o)?this._pasteInternal(o,n):this._pasteExternal(e,n)}async _pasteExternal(e,n){const o=this._getPastingTarget(),{selection:r,unitId:s,subUnitId:a}=o;if(!r)return!1;const{rowProperties:c,colProperties:d,cellMatrix:u}=this._htmlToUSM.convert(e),{startColumn:h,endColumn:m,startRow:S,endRow:_}=u.getDataRange(),g=_-S+1,v=m-h+1;if(!u||m<h||_<S)return!1;const M=this._transformPastedData(g,v,u,r.range);return M?this._pasteUSM({rowProperties:c,colProperties:d,cellMatrix:u},{unitId:s,subUnitId:a,pastedRange:M},n):!1}async _pasteInternal(e,n){var A,L;const o=this._getPastingTarget(),{selection:r,unitId:s,subUnitId:a}=o,c=l.Tools.deepClone(this._copyContentCache.get(e)),{range:d,matrix:u,unitId:h,subUnitId:m}=c||{};if(!r||!u||!c||!d||!h||!m||!r||!u||!c)return!1;const S=(A=this._currentUniverService.getUniverSheetInstance(h))==null?void 0:A.getStyles();u.forValue((B,j,X)=>{if(typeof X.s=="string"){const z=l.Tools.deepClone(X);z.s=S==null?void 0:S.getStyleByCell(X),u.setValue(B,j,z)}});const{startColumn:_,endColumn:g,startRow:v,endRow:M}=d,R=this._transformPastedData(M-v+1,g-_+1,u,r.range);if(!R)return!1;const b=(L=this._currentUniverService.getUniverSheetInstance(h))==null?void 0:L.getSheetBySheetId(m);if(!b)return!1;const E=b.getColumnManager(),T=b.getRowManager(),y=b.getConfig().defaultColumnWidth,O=b.getConfig().defaultRowHeight,N=[],D=[];for(let B=_;B<=g;B++){const j=E.getColumnOrCreate(B);N.push({width:`${j.w||y}`})}for(let B=v;B<=M;B++){const j=T.getRowOrCreate(B);D.push({height:`${j.h||O}`})}const k=this._pasteUSM({cellMatrix:u,colProperties:N,rowProperties:D},{unitId:s,subUnitId:a,pastedRange:R},n,{range:d,unitId:c.unitId,subUnitId:c.subUnitId,copyType:c.copyType,copyId:e});return c.copyType===at.CUT&&(this._copyContentCache.set(e,{...c,matrix:null}),this._copyMarkId&&this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null),k}_pasteUSM(e,n,o,r){const{rowProperties:s,colProperties:a,cellMatrix:c}=e,{unitId:d,subUnitId:u,pastedRange:h}=n,{startColumn:m,endColumn:S}=h,_=S-m+1,g=this._clipboardHooks,v=[];if(g.some(D=>{var k;return v.push(D)&&((k=D.onBeforePaste)==null?void 0:k.call(D,{unitId:d,subUnitId:u,range:h}))===!1}))return v.forEach(D=>{var k;return(k=D.onAfterPaste)==null?void 0:k.call(D,!1)}),!1;if(!c)return!1;const R=r?{unitId:r.unitId,subUnitId:r.subUnitId,range:r.range}:null,b={copyType:(r==null?void 0:r.copyType)||at.COPY,copyId:r==null?void 0:r.copyId,pasteType:o};let E=[],T=[];v.filter(D=>!D.specialPasteInfo&&D.id!==ve.DEFAULT_PASTE||o===D.id).forEach(D=>{var L,B,j;if(s){const X=(L=D.onPasteRows)==null?void 0:L.call(D,{range:h,unitId:d,subUnitId:u},s,{pasteType:o});X&&(E.push(...X.redos),T.push(...X.undos))}const k=(B=D.onPasteColumns)==null?void 0:B.call(D,{range:h,unitId:d,subUnitId:u},a||new Array(_).map(()=>({})),{pasteType:o});k&&(E.push(...k.redos),T.push(...k.undos));const A=(j=D.onPasteCells)==null?void 0:j.call(D,R,{range:h,unitId:d,subUnitId:u},c,b);A&&(E.push(...A.redos),T.push(...A.undos))});const O=this._getSetSelectionOperation(d,u,h,c);O&&E.push(O),E=_i(E),T=_i(T),this._logService.log("[SheetClipboardService]","pasting mutations",{undoMutationsInfo:T,redoMutationsInfo:E});const N=E.every(D=>this._commandService.executeCommand(D.id,D.params));return N&&this._undoRedoService.pushUndoRedo({unitID:d,undoMutations:T,redoMutations:E}),N}_getSetSelectionOperation(e,n,o,r){var g;const s=(g=this._currentUniverService.getUniverSheetInstance(e))==null?void 0:g.getSheetBySheetId(n);if(!s)return null;const{startRow:a,startColumn:c}=o,d={startRow:a,endRow:a,startColumn:c,endColumn:c},u=f.getPrimaryForRange(d,s),h=r.getValue(0,0),m=(h==null?void 0:h.rowSpan)||1,S=(h==null?void 0:h.colSpan)||1;if(m>1||S>1){const v={startRow:a,endRow:a+m-1,startColumn:c,endColumn:c+S-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:e,subUnitId:n,pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:o,primary:u,style:null}]};return{id:f.SetSelectionsOperation.id,params:_}}_getPastingTarget(){const e=this._currentUniverService.getCurrentUniverSheetInstance(),n=e.getActiveSheet(),o=this._selectionManagerService.getLast();return{unitId:e.getUnitId(),subUnitId:n.getSheetId(),selection:o}}_transformPastedData(e,n,o,r){const{startRow:s,startColumn:a,endRow:c,endColumn:d}=r,u=c-s+1,h=d-a+1,g=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData().filter(T=>l.Rectangle.intersects({startRow:s,startColumn:a,endRow:c,endColumn:d},T)),v=g[0];let M=0,R=0,b=0,E=0;if(v&&(M=v.startRow,R=v.startColumn,b=v.endRow,E=v.endColumn),u%e===0&&h%n===0)if(g.length>0&&(u!==e||h!==n))if(M===s&&R===a&&b===c&&E===d)if(Ea(o))for(let y=0;y<u;y++)for(let O=0;O<h;O++){const N=o.getValue(y%e,O%n);N&&o.setValue(y,O,N)}else o.forValue((y,O,N)=>{N.s=null,delete N.colSpan,delete N.rowSpan});else for(let T=0;T<u;T++)for(let y=0;y<h;y++){const O=o.getValue(T%e,y%n);O&&o.setValue(T,y,O)}else for(let T=0;T<u;T++)for(let y=0;y<h;y++){const O=o.getValue(T%e,y%n);O&&o.setValue(T,y,O)}else if(g.length>0)if(this._topLeftCellsMatch(e,n,r))r.endRow=s+e-1,r.endColumn=a+n-1;else{if(c>v.endRow||d>v.endColumn)return null;o.forValue((y,O,N)=>{N.s=null,delete N.colSpan,delete N.rowSpan})}else r.endRow=s+e-1,r.endColumn=a+n-1;return r}_topLeftCellsMatch(e,n,o){const s=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet(),{startRow:a,startColumn:c,endRow:d,endColumn:u}=o,h=wa(a+e-1,c,c+e-1,s),m=Ta(c+n-1,a,a+e-1,s);return!h&&!m}},x.SheetClipboardService=Ia([Ne(0,l.ILogService),Ne(1,l.IUniverInstanceService),Ne(2,P.Inject(f.SelectionManagerService)),Ne(3,C.IClipboardInterfaceService),Ne(4,l.IUndoRedoService),Ne(5,l.ICommandService),Ne(6,Lt),Ne(7,P.Inject(x.SheetSkeletonManagerService)),Ne(8,C.INotificationService),Ne(9,C.IPlatformService),Ne(10,P.Inject(l.LocaleService))],x.SheetClipboardService);function Ma(i){let t="";return i.forRow((e,n)=>{const o=[];n.forEach(r=>{const s=i.getValue(e,r);if(s){const a=Ra(s);o.push(a)}}),t+=o.join(" "),e!==i.getLength()-1&&(t+=`
|
|
9
|
-
`)}),t}function Ra(i){const t=l.extractPureTextFromCell(i);return ba((t==null?void 0:t.toString())||"")}const ba=i=>i.replace(/&/g,"&").replace(/\uFEFF/g,"").replace(/</g,"<").replace(/>/g,">");function wa(i,t,e,n){return n.getMergeData().some(o=>o.startRow<=i&&i<o.endRow&&t<=o.startColumn&&o.startColumn<=e)}function Ta(i,t,e,n){return n.getMergeData().some(o=>o.startColumn<=i&&i<o.endColumn&&t<=o.startRow&&o.startRow<=e)}function Ea(i){let t=0;return i.forValue((e,n,o)=>{if(o&&t++,t>1)return!1}),t>1}function No(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const fi=998,Ao={id:C.CopyCommand.id,name:"sheet.command.copy",type:l.CommandType.COMMAND,multi:!0,priority:fi,preconditions:li,handler:async i=>i.get(pt).copy()},ya={id:C.CutCommand.id,name:"sheet.command.cut",type:l.CommandType.COMMAND,multi:!0,priority:fi,preconditions:li,handler:async i=>i.get(pt).cut()},vt={id:C.PasteCommand.id,type:l.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:fi,preconditions:li,handler:async(i,t)=>{const n=await i.get(C.IClipboardInterfaceService).read(),o=i.get(pt);return n.length!==0?o.paste(n[0],t==null?void 0:t.value):!1}},Do={id:"sheet.command.paste-value",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(vt.id,{value:ve.SPECIAL_PASTE_VALUE})},Po={id:"sheet.command.paste-format",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(vt.id,{value:ve.SPECIAL_PASTE_FORMAT})},Lo={id:"sheet.command.paste-col-width",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(vt.id,{value:ve.SPECIAL_PASTE_COL_WIDTH})},Ho={id:"sheet.command.paste-besides-border",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(vt.id,{value:ve.SPECIAL_PASTE_BESIDES_BORDER})};var Oa=Object.defineProperty,xa=Object.getOwnPropertyDescriptor,Na=(i,t,e,n)=>{for(var o=n>1?void 0:n?xa(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Oa(t,e,o),o},Uo=(i,t)=>(e,n)=>t(e,n,i);let Ht=class{constructor(i,t){I(this,"_current",null);I(this,"_shortcutParam",[]);this._currentUniverService=i,this._localeService=t}dispose(){this._shortcutParam=[]}getCurrentBySearch(i){return this._getCurrentBySearch(i)}getCurrent(){return this._getCurrentBySearch(this._current)}addOrUpdate(i){const t=this._getCurrentBySearch({unitId:i.unitId,sheetId:i.sheetId,keycode:i.keycode});if(t!=null){const e=this._shortcutParam.indexOf(t);this._shortcutParam.splice(e,1)}return this._shortcutParam.push(i),t}remove(i){if(i==null)return;const t=this._getCurrentBySearch(i);if(t==null)return;const e=this._shortcutParam.indexOf(t);return this._shortcutParam.splice(e,1)[0]}_getCurrentBySearch(i){return i==null?void 0:this._shortcutParam.find(e=>e.unitId===i.unitId&&e.sheetId===i.sheetId&&e.keycode===i.keycode)}};Ht=Na([Uo(0,l.IUniverInstanceService),Uo(1,P.Inject(l.LocaleService))],Ht);var vn=(i=>(i.MergeAll="mergeAll",i.MergeVertical="mergeVertical",i.MergeHorizontal="mergeHorizontal",i))(vn||{});function tt(i,t,e,n,o=!0,r=1,s=!0){let a={...i};n==null&&(n={startRow:0,endRow:e.getRowCount()-1,startColumn:0,endColumn:e.getColumnCount()-1});let c;switch(t){case l.Direction.UP:for(c=i.startRow-r;c>-1&&!e.getRowVisible(c);)c-=1;c>=n.startRow?(a.startRow=c,a.endRow=c):s&&(a.startRow=n.endRow,a.endRow=n.endRow,o&&(a=tt(a,l.Direction.LEFT,e,n,!1)));break;case l.Direction.DOWN:for(c=i.endRow+r;c<e.getRowCount()&&!e.getRowVisible(c);)c+=1;c<=n.endRow?(a.startRow=c,a.endRow=c):s&&(a.startRow=n.startRow,a.endRow=n.startRow,o&&(a=tt(a,l.Direction.RIGHT,e,n,!1)));break;case l.Direction.LEFT:for(c=i.startColumn-r;c>-1&&!e.getColVisible(c);)c-=1;c>=n.startColumn?(a.startColumn=c,a.endColumn=c):s&&(a.startColumn=n.endColumn,a.endColumn=n.endColumn,o&&(a=tt(a,l.Direction.UP,e,n,!1)));break;case l.Direction.RIGHT:for(c=i.endColumn+r;c<e.getColumnCount()&&!e.getColVisible(c);)c+=1;c<=n.endColumn?(a.startColumn=c,a.endColumn=c):s&&(a.startColumn=n.startColumn,a.endColumn=n.startColumn,o&&(a=tt(a,l.Direction.DOWN,e,n,!1)));break}return a}function gi(i,t,e){const n={...i},{startRow:o,startColumn:r,endRow:s,endColumn:a}=Ut(i,t,e);let c=Vt(e,o,r,s,a).hasValue,d=!0,u=!0;for(;u;){if(l.Direction.UP===t){let h=n.startRow-1;for(;h>-1&&!e.getRowVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:S}=Vt(e,h,n.startColumn,h,n.endColumn);if(c&&!m&&!d){u=!1;break}else{if(S.getLength()!==0){let _=h;S.forValue(g=>{_=Math.min(g,_)}),n.startRow=_}else n.startRow=h;if(n.endRow=n.startRow,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.DOWN===t){let h=n.endRow+1;for(;h<e.getRowCount()&&!e.getRowVisible(h);)h+=1;if(h===e.getRowCount()){u=!1;break}const{hasValue:m,matrix:S}=Vt(e,h,n.startColumn,h,n.endColumn);if(c&&!m&&!d){u=!1;break}else{if(S.getLength()!==0){let _=h;S.forValue((g,v,M)=>{_=Math.max(g+(M.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===t){let h=n.startColumn-1;for(;h>-1&&!e.getColVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:S}=Vt(e,n.startRow,h,n.endRow,h);if(c&&!m&&!d){u=!1;break}else{if(S.getLength()!==0){let _=h;S.forValue((g,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===t){let h=n.endColumn+1;for(;h<e.getColumnCount()&&!e.getColVisible(h);)h+=1;if(h===e.getColumnCount()){u=!1;break}const{hasValue:m,matrix:S}=Vt(e,n.startRow,h,n.endRow,h);if(c&&!m&&!d){u=!1;break}else{if(S.getLength()!==0){let _=h;S.forValue((g,v,M)=>{_=Math.max(v+(M.colSpan||1)-1,_)}),n.endColumn=_}else n.endColumn=h;if(n.startColumn=n.endColumn,!c&&m){u=!1;break}c=m,d=!1}}}return f.alignToMergedCellsBorders(n,e,!0)}function Vo(i,t,e){return tt(i,t,e,void 0,!1,1,!1)}function Aa(i,t,e){const n=gi(i,t,e);return f.alignToMergedCellsBorders(l.Rectangle.union(n,i),e,!0)}function Da(i,t,e){const n=Vo(i,t,e),o={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 f.alignToMergedCellsBorders(l.Rectangle.union(i,o),e)}function Pa(i,t,e,n){const o=l.getReverseDirection(e),r=gi(Ut(i,o,n),e,n);return e===l.Direction.UP&&r.startRow<=i.startRow?f.alignToMergedCellsBorders({...t,startColumn:i.startColumn,endColumn:i.endColumn},n,!0):e===l.Direction.DOWN&&r.endRow>=i.endRow?f.alignToMergedCellsBorders({...t,startColumn:i.startColumn,endColumn:i.endColumn},n,!0):e===l.Direction.LEFT&&r.startColumn<=i.startColumn?f.alignToMergedCellsBorders({...t,startRow:i.startRow,endRow:i.endRow},n,!0):e===l.Direction.RIGHT&&r.endColumn>=i.endColumn?f.alignToMergedCellsBorders({...t,startRow:i.startRow,endRow:i.endRow},n,!0):l.Rectangle.union(l.Rectangle.clone(t),r)}function La(i,t,e){const n=l.getReverseDirection(t),o=Ut(i,n,e),r=Ut(i,t,e),s=Vo(o,t,e);return f.alignToMergedCellsBorders(l.Rectangle.union(r,s),e,!1)}function Ha(i,t,e){const{left:n,right:o,up:r,down:s}=t,a=e.getMaxRows(),c=e.getMaxColumns();let d=!0;const u={...i};for(;d;){if(d=!1,r&&u.startRow!==0){const h=u.startRow-1;e.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((S,_,g)=>{g.v&&(u.startRow=Math.min(S,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;e.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((S,_,g)=>{g.v&&(u.endRow=Math.max(S+(g.rowSpan!==void 0?g.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;e.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((S,_,g)=>{g.v&&(u.startColumn=Math.min(_,u.startColumn),u.startRow=Math.min(S,u.startRow),u.endRow=Math.max(S,u.endRow),d=!0)})}if(o&&u.endColumn!==c-1){const h=u.endColumn+1;e.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((S,_,g)=>{g.v&&(u.endColumn=Math.max(_+(g.colSpan!==void 0?g.colSpan-1:0),u.endColumn),u.startRow=Math.min(S,u.startRow),u.endRow=Math.max(S,u.endRow),d=!0)})}}return u}function ko(i){return{startRow:0,startColumn:0,endRow:i.getRowCount()-1,endColumn:i.getColumnCount()-1,rangeType:l.RANGE_TYPE.ALL}}function Ut(i,t,e){let n;switch(t){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 f.alignToMergedCellsBorders(n,e,!1)}function Vt(i,t,e,n,o){let r=!1;const s=i.getMatrixWithMergedCells(t,e,n,o).forValue((a,c,d)=>{if(d.v)return r=!0,!1});return{hasValue:r,matrix:s}}function pi(i,t,e){const n=l.Rectangle.clone(i);if(t==null)return n;switch(e){case l.Direction.UP:case l.Direction.DOWN:n.startColumn=n.endColumn=t.actualColumn;break;case l.Direction.LEFT:case l.Direction.RIGHT:n.startRow=n.endRow=t.actualRow;break}return n}function Ua(i,t,e){const{primary:n,range:o}=i,r=l.Rectangle.clone(o);switch(t){case l.Direction.UP:case l.Direction.DOWN:r.startRow=n.startRow,r.endRow=n.endRow;break;case l.Direction.LEFT:case l.Direction.RIGHT:r.startColumn=n.startColumn,r.endColumn=n.endColumn;break}const s=Ut(r,t,e);switch(t){case l.Direction.DOWN:return o.startRow<s.startRow;case l.Direction.UP:return o.endRow>s.endRow;case l.Direction.LEFT:return s.endColumn<o.endColumn;case l.Direction.RIGHT:return s.startColumn>o.startColumn}}function Bo(i,t){let e=i[0].startRow,n=i[0].endRow;i.forEach(r=>{const{startRow:s,endRow:a}=r;e=Math.min(e,s),n=Math.max(n,a)});const o=new Array(n-e+1).fill(!1);return t.forEach(r=>{const{startRow:s,endRow:a}=r;for(let c=Math.max(s,e);c<=Math.min(a,n);c++)o[c-e]=!0}),i.every(r=>{const{startRow:s,endRow:a}=r;for(let c=s;c<=a;c++)if(!o[c-e])return!1;return!0})}function Fo(i,t){let e=i[0].startColumn,n=i[0].endColumn;i.forEach(r=>{const{startColumn:s,endColumn:a}=r;e=Math.min(e,s),n=Math.max(n,a)});const o=new Array(n-e+1).fill(!1);return t.forEach(r=>{const{startColumn:s,endColumn:a}=r;for(let c=Math.max(s,e);c<=Math.min(a,n);c++)o[c-e]=!0}),i.every(r=>{const{startColumn:s,endColumn:a}=r;for(let c=s;c<=a;c++)if(!o[c-e])return!1;return!0})}function vi(i,t){return t?i==="mergeAll"?t.filter(e=>!(e.startRow===e.endRow&&e.startColumn===e.endColumn)):i==="mergeVertical"?t.filter(e=>e.startRow!==e.endRow):i==="mergeHorizontal"?t.filter(e=>e.startColumn!==e.endColumn):t:null}var ke=(i=>(i[i.moveStopeOne=0]="moveStopeOne",i[i.moveGap=1]="moveGap",i[i.moveStepPage=2]="moveStepPage",i[i.moveStepEnd=3]="moveStepEnd",i))(ke||{});const be={id:"sheet.command.move-selection",type:l.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const e=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=e.getActiveSheet(),o=i.get(f.SelectionManagerService).getLast();if(!o)return!1;const{direction:r,jumpOver:s}=t,{range:a,primary:c}=o,d=pi(a,c,r),u=s===1?gi(d,r,n):tt(d,r,n),h=f.getCellAtRowCol(u.startRow,u.startColumn,n);return l.Rectangle.equals(h,d)?!1:(i.get(Ht).remove({unitId:e.getUnitId(),sheetId:n.getSheetId(),keycode:C.KeyCode.TAB}),i.get(l.ICommandService).executeCommand(f.SetSelectionsOperation.id,{unitId:e.getUnitId(),subUnitId:n.getSheetId(),pluginName:f.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,t)=>{if(!t)return!1;const e=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=e.getActiveSheet(),o=i.get(f.SelectionManagerService).getLast(),r=e.getUnitId(),s=n.getSheetId();if(!o)return!1;const{direction:a,keycode:c}=t,{range:d,primary:u}=o;let h=pi(d,u,a);const m=i.get(Ht),S=m.getCurrentBySearch({unitId:r,sheetId:s,keycode:C.KeyCode.TAB});let _;const{startRow:g,endRow:v,startColumn:M,endColumn:R}=d;if(l.Rectangle.equals(d,u)){if(c===C.KeyCode.TAB)S==null&&m.addOrUpdate({unitId:r,sheetId:s,keycode:C.KeyCode.TAB,selection:o});else{const T=S==null?void 0:S.selection;if(T!=null){const{range:y,primary:O}=T;h=pi(y,O,a)}m.remove({unitId:r,sheetId:s,keycode:C.KeyCode.TAB})}const b=tt(h,a,n),E=f.getCellAtRowCol(b.startRow,b.startColumn,n);if(l.Rectangle.equals(E,h))return!1;_={range:l.Rectangle.clone(E),primary:{startRow:E.startRow,startColumn:E.startColumn,endRow:E.endRow,endColumn:E.endColumn,actualRow:b.startRow,actualColumn:b.startColumn,isMerged:E.isMerged,isMergedMainCell:E.startRow===b.startRow&&E.startColumn===b.startColumn}}}else{m.remove({unitId:r,sheetId:s,keycode:C.KeyCode.TAB});const b=l.Tools.deepClone(u),E=tt({startRow:b.startRow,startColumn:b.startColumn,endRow:b.endRow,endColumn:b.endColumn},a,n,{startRow:g,endRow:v,startColumn:M,endColumn:R}),T=f.getCellAtRowCol(E.startRow,E.startColumn,n);_={range:l.Rectangle.clone(d),primary:{startRow:T.startRow,startColumn:T.startColumn,endRow:T.endRow,endColumn:T.endColumn,actualRow:E.startRow,actualColumn:E.startColumn,isMerged:T.isMerged,isMergedMainCell:T.startRow===E.startRow&&T.startColumn===E.startColumn}}}return i.get(l.ICommandService).executeCommand(f.SetSelectionsOperation.id,{unitId:r,subUnitId:s,pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[_]})}},Ae={id:"sheet.command.expand-selection",type:l.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const e=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=e.getActiveSheet(),o=i.get(f.SelectionManagerService).getLast();if(!o)return!1;const{range:r,primary:s}=o,{jumpOver:a,direction:c}=t,u=Ua(o,c,n)?a===1?Pa(r,{...l.Rectangle.clone(s),rangeType:l.RANGE_TYPE.NORMAL},c,n):La(r,c,n):a===1?Aa(r,c,n):Da(r,c,n);return l.Rectangle.equals(u,r)?!1:i.get(l.ICommandService).executeCommand(f.SetSelectionsOperation.id,{unitId:e.getUnitId(),subUnitId:n.getSheetId(),pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:u,primary:s}]})}};let Be=[],Ci="";const Wo={id:"sheet.command.select-all",type:l.CommandType.COMMAND,onDispose(){Be=[],Ci=""},handler:async(i,t={expandToGapFirst:!0,loop:!1})=>{const e=i.get(f.SelectionManagerService).getLast(),n=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),o=n.getActiveSheet();if(!e||!o)return!1;const r=`${n.getUnitId()}|${o.getSheetId()}`;r!==Ci&&(Be=[],Ci=r);const s=o.getMaxRows(),a=o.getMaxColumns(),{expandToGapFirst:c,loop:d}=t,{range:u,primary:h}=e,m=u.endColumn===a-1&&u.endRow===s-1&&u.startRow===0&&u.startColumn===0;Be.some(_=>l.Rectangle.equals(_,u))||(Be=[],Be.push(u));let S;if(m)if(d){if(Be.findIndex(g=>l.Rectangle.equals(g,u))!==Be.length-1)return!1;S=Be[0]}else return!1;else c?(S=Ha(u,{left:!0,right:!0,up:!0,down:!0},o),l.Rectangle.equals(S,u)&&(S=ko(o))):S=ko(o);return Be.some(_=>l.Rectangle.equals(_,S))||Be.push(S),i.get(l.ICommandService).executeCommand(f.SetSelectionsOperation.id,{unitId:n.getUnitId(),subUnitId:o.getSheetId(),pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:S,primary:h}]})}};var Va=Object.defineProperty,ka=Object.getOwnPropertyDescriptor,Ba=(i,t,e,n)=>{for(var o=n>1?void 0:n?ka(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Va(t,e,o),o},kt=(i,t)=>(e,n)=>t(e,n,i);const Fa=l.createInterceptorKey("BEFORE_CELL_EDIT"),Wa=l.createInterceptorKey("AFTER_CELL_EDIT"),ja=l.createInterceptorKey("AFTER_CELL_EDIT_ASYNC");x.EditorBridgeService=class extends l.Disposable{constructor(e,n,o,r,s){super();I(this,"_editorUnitId",l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);I(this,"_isForceKeepVisible",!1);I(this,"_editorIsDirty",!1);I(this,"_visible",{visible:!1,eventType:w.DeviceInputEventType.Dblclick});I(this,"_currentEditCell",null);I(this,"_currentEditCellState",null);I(this,"_currentEditCellState$",new V.BehaviorSubject(null));I(this,"currentEditCellState$",this._currentEditCellState$.asObservable());I(this,"_visible$",new V.BehaviorSubject(this._visible));I(this,"visible$",this._visible$.asObservable());I(this,"_afterVisible$",new V.BehaviorSubject(this._visible));I(this,"afterVisible$",this._afterVisible$.asObservable());I(this,"interceptor",new l.InterceptorManager({BEFORE_CELL_EDIT:Fa,AFTER_CELL_EDIT:Wa,AFTER_CELL_EDIT_ASYNC:ja}));this._sheetSkeletonManagerService=e,this._selectionRenderService=n,this._themeService=o,this._currentUniverService=r,this._editorService=s,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:a=>a}))),this.disposeWithMe(l.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{priority:-1,handler:a=>a}))),this.disposeWithMe(l.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().AFTER_CELL_EDIT_ASYNC,{priority:-1,handler:a=>a})))}refreshEditCellState(){const e=this.getLatestEditCellState();this._currentEditCellState=e,this._currentEditCellState$.next(e)}setEditCell(e){this._currentEditCell=e;const n=this.getLatestEditCellState();this._currentEditCellState=n,this._currentEditCellState$.next(n)}getEditCellState(){return this._currentEditCellState}getLatestEditCellState(){var B,j;const e=this._currentEditCell;if(e==null)return;const n=this._sheetSkeletonManagerService.getCurrent();if(n==null)return;const{skeleton:o}=n,{primary:r,unitId:s,sheetId:a,scene:c,engine:d}=e,{startRow:u,startColumn:h}=r,m=this._selectionRenderService.convertCellRangeToInfo(r);if(m==null)return;const S=l.makeCellToSelection(m);if(S==null)return;const _=w.getCanvasOffsetByEngine(d);let{startX:g,startY:v,endX:M,endY:R}=S;const{scaleX:b,scaleY:E}=c.getAncestorScale(),{scaleX:T,scaleY:y}=c.getPrecisionScale(),O=c.getScrollXY(this._selectionRenderService.getViewPort());g=w.fixLineWidthByScale(o.convertTransformToOffsetX(g,b,O),T),v=w.fixLineWidthByScale(o.convertTransformToOffsetY(v,E,O),y),M=w.fixLineWidthByScale(o.convertTransformToOffsetX(M,b,O),T),R=w.fixLineWidthByScale(o.convertTransformToOffsetY(R,E,O),y);const N=this._currentUniverService.getCurrentUniverSheetInstance(),D=N.getActiveSheet(),k={workbook:N,worksheet:D,unitId:N.getUnitId(),subUnitId:D.getSheetId(),row:u,col:h},A=this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT)(D.getCell(u,h),k);let L=A&&o.getCellDocumentModelWithFormula(A);if(!L||L.documentModel==null){const X=o.getBlankCellDocumentModel(A);if(L!=null){const{verticalAlign:z,horizontalAlign:Z,wrapStrategy:ee,textRotation:ne,fill:U}=L,{centerAngle:W,vertexAngle:$}=w.convertTextRotation(ne);X.documentModel.documentStyle.renderConfig={verticalAlign:z,horizontalAlign:Z,wrapStrategy:ee,background:{rgb:U},centerAngle:W,vertexAngle:$}}L=X}if((B=L.documentModel)==null||B.setZoomRatio(Math.max(b,E)),(A==null?void 0:A.isInArrayFormulaRange)===!0){const X=(j=L.documentModel)==null?void 0:j.getBody();X&&(X.textRuns=[{st:0,ed:X.dataStream.length-2,ts:{cl:{rgb:this._themeService.getCurrentTheme().textColorSecondary}}}])}return this._editorService.setOperationSheetUnitId(s),this._editorService.setOperationSheetSubUnitId(a),{position:{startX:g,startY:v,endX:M,endY:R},scaleX:b,scaleY:E,canvasOffset:_,row:u,column:h,unitId:s,sheetId:a,documentLayoutObject:L,editorUnitId:this._editorUnitId,isInArrayFormulaRange:A==null?void 0:A.isInArrayFormulaRange}}getCurrentEditorId(){return this._editorUnitId}changeVisible(e){this._visible=e,e.visible&&(this._editorIsDirty=!1),this._visible$.next(this._visible),this._afterVisible$.next(this._visible)}isVisible(){return this._visible}enableForceKeepVisible(){this._isForceKeepVisible=!0}disableForceKeepVisible(){this._isForceKeepVisible=!1}isForceKeepVisible(){return this._isForceKeepVisible}changeEditorDirty(e){this._editorIsDirty=e}getEditorDirty(){return this._editorIsDirty}},x.EditorBridgeService=Ba([kt(0,P.Inject(x.SheetSkeletonManagerService)),kt(1,ge),kt(2,P.Inject(l.ThemeService)),kt(3,l.IUniverInstanceService),kt(4,C.IEditorService)],x.EditorBridgeService);const we=P.createIdentifier("univer.sheet-editor-bridge.service"),De={id:"sheet.operation.set-cell-edit-visible",type:l.CommandType.OPERATION,handler:(i,t)=>{const e=i.get(we);return t==null?!1:(e.changeVisible(t),!0)}},Bt={id:"sheet.operation.set-cell-edit-visible-arrow",type:l.CommandType.OPERATION,handler:()=>!0};class Xe{constructor(){I(this,"_scrollInfo",new Map);I(this,"_scrollInfo$",new V.BehaviorSubject(null));I(this,"scrollInfo$",this._scrollInfo$.asObservable());I(this,"_currentScroll",null)}dispose(){this._scrollInfo$.complete()}setCurrentScroll(t){this._currentScroll=t,this._refresh(t)}getScrollByParam(t){return this._getCurrentScroll(t)}getCurrentScroll(){return this._getCurrentScroll(this._currentScroll)}addOrReplace(t){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...t})}addOrReplaceNoRefresh(t){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...t},!1)}addOrReplaceByParam(t){this._addByParam(t)}clear(){this._currentScroll!=null&&this._clearByParam(this._currentScroll)}_addByParam(t,e=!0){const{unitId:n,sheetId:o,sheetViewStartColumn:r,sheetViewStartRow:s,offsetX:a,offsetY:c}=t;this._scrollInfo.has(n)||this._scrollInfo.set(n,new Map),this._scrollInfo.get(n).set(o,{sheetViewStartRow:s,sheetViewStartColumn:r,offsetX:a,offsetY:c}),e===!0&&this._refresh({unitId:n,sheetId:o})}_clearByParam(t){this._addByParam({...t,sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),this._refresh(t)}_getCurrentScroll(t){var o;if(t==null)return;const{unitId:e,sheetId:n}=t;return(o=this._scrollInfo.get(e))==null?void 0:o.get(n)}_refresh(t){this._scrollInfo$.next(this._getCurrentScroll(t))}}const nt={id:"sheet.operation.set-scroll",type:l.CommandType.OPERATION,handler:(i,t)=>{if(t==null)return!1;const e=i.get(Xe),r=i.get(l.IUniverInstanceService).getUniverSheetInstance(t.unitId).getSheetBySheetId(t.sheetId),{xSplit:s,ySplit:a}=r.getConfig().freeze;return e.addOrReplaceByParam({...t,sheetViewStartRow:t.sheetViewStartRow-a,sheetViewStartColumn:t.sheetViewStartColumn-s}),!0}},Ft={id:"sheet.command.set-scroll-relative",type:l.CommandType.COMMAND,handler:async(i,t={offsetX:0,offsetY:0})=>{const e=i.get(l.ICommandService),n=i.get(Xe),r=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),s=r.getActiveSheet(),{xSplit:a,ySplit:c}=s.getConfig().freeze,d=n.getCurrentScroll(),{offsetX:u=0,offsetY:h=0}=t||{},{sheetViewStartRow:m=0,sheetViewStartColumn:S=0,offsetX:_=0,offsetY:g=0}=d||{};return e.executeCommand(nt.id,{unitId:r.getUnitId(),sheetId:s.getSheetId(),sheetViewStartRow:m+c,sheetViewStartColumn:S+a,offsetX:_+u,offsetY:g+h})}},ct={id:"sheet.command.scroll-view",type:l.CommandType.COMMAND,handler:(i,t)=>{if(!t)return!1;const e=i.get(l.IUniverInstanceService),n=i.get(Xe),o=e.getCurrentUniverSheetInstance(),r=o.getActiveSheet(),s=n.getCurrentScroll();if(!r)return!1;const{sheetViewStartRow:a,sheetViewStartColumn:c,offsetX:d,offsetY:u}=t,{sheetViewStartColumn:h,sheetViewStartRow:m,offsetX:S,offsetY:_}=s||{},{xSplit:g,ySplit:v}=r.getConfig().freeze;return i.get(l.ICommandService).syncExecuteCommand(nt.id,{unitId:o.getUnitId(),sheetId:r.getSheetId(),sheetViewStartRow:a!=null?a:(m!=null?m:0)+v,sheetViewStartColumn:c!=null?c:(h!=null?h:0)+g,offsetX:d!=null?d:S,offsetY:u!=null?u:_})}},jo={id:"sheet.command.scroll-to-cell",type:l.CommandType.COMMAND,handler:(i,t)=>i.get(x.ScrollController).scrollToRange(t.range)},za={id:"sheet.command.scroll-view-reset",type:l.CommandType.COMMAND,handler:async i=>{const e=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=e.getActiveSheet();return n?i.get(l.ICommandService).executeCommand(nt.id,{unitId:e.getUnitId(),sheetId:n.getSheetId(),sheetViewStartRow:0,sheetViewStartColumn:0}):!1}};function Ie(i,t){const n=i.getCurrentUniverSheetInstance().getUnitId(),o=t.getRenderById(n);if(o==null)return;const{components:r,mainComponent:s,scene:a,engine:c}=o,d=s,u=r.get(fe.ROW),h=r.get(fe.COLUMN),m=r.get(fe.LEFT_TOP);return{spreadsheet:d,spreadsheetRowHeader:u,spreadsheetColumnHeader:h,spreadsheetLeftTopPlaceholder:m,scene:a,engine:c}}function Ii(i,t,e,n){const{startX:o,startY:r,endX:s,endY:a}=n.getCellByIndex(i,t);return{startX:o,startY:r,endX:s,endY:a}}function Ct(i,t,e,n,o){const r=e.getRelativeCoord(w.Vector2.FromArray([i,t])),{x:s,y:a}=r,c=e.getScrollXYByRelativeCoords(r,o),{scaleX:d,scaleY:u}=e.getAncestorScale(),h=n.getCellPositionByOffset(s,a,d,u,c),{row:m,column:S}=h,_=n.getNoMergeCellPositionByIndex(m,S),{startX:g,startY:v,endX:M,endY:R}=_;return{startX:g,startY:v,endX:M,endY:R,row:m,column:S}}function Cn(i,t,e,n){const o=e.getRelativeCoord(w.Vector2.FromArray([i,t])),r=e.getViewport(F.VIEW_MAIN),s=e.getScrollXYByRelativeCoords(o,r),{scaleX:a,scaleY:c}=e.getAncestorScale(),{x:d,y:u}=s,h=i/a+d,m=t/c+u;return{x:h,y:m}}var Ya=Object.defineProperty,Xa=Object.getOwnPropertyDescriptor,$a=(i,t,e,n)=>{for(var o=n>1?void 0:n?Xa(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Ya(t,e,o),o},It=(i,t)=>(e,n)=>t(e,n,i);const Za=[be.id,lt.id];x.ScrollController=class extends l.Disposable{constructor(t,e,n,o,r,s){super(),this._sheetSkeletonManagerService=t,this._currentUniverService=e,this._commandService=n,this._renderManagerService=o,this._selectionManagerService=r,this._scrollManagerService=s,this._init()}scrollToRange(t){const{startRow:e,startColumn:n}=t;return this._scrollToCell(e,n)}_init(){this._initCommandListener(),this._initScrollEventListener(),this._scrollSubscribeBinding(),this._initSkeletonListener()}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(Za.includes(t.id))this._scrollToSelection();else if(t.id===f.ScrollToCellOperation.id){const e=t.params;this._scrollToSelectionByDirection(e)}else if(t.id===Ae.id){const e=t.params;this._scrollToSelectionForExpand(e)}}))}_scrollToSelectionForExpand(t){setTimeout(()=>{const e=this._selectionManagerService.getLast();if(e==null)return;const{startRow:n,startColumn:o,endRow:r,endColumn:s}=e.range,a=this._getViewportBounding();if(a==null)return;const{startRow:c,startColumn:d,endRow:u,endColumn:h}=a;let m=0,S=0;n>c?m=r:r<u?m=n:m=c,o>d?S=s:s<h?S=o:S=d,t.direction===l.Direction.DOWN?m=r:t.direction===l.Direction.UP?m=n:t.direction===l.Direction.RIGHT?S=s:t.direction===l.Direction.LEFT&&(S=o),this._scrollToCell(m,S)},0)}_getFreeze(){var e;const t=(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig();if(t!=null)return t.freeze}_initScrollEventListener(){var n;const t=(n=this._getSheetObject())==null?void 0:n.scene;if(t==null)return;const e=t.getViewport(F.VIEW_MAIN);this.disposeWithMe(l.toDisposable(e==null?void 0:e.onScrollAfterObserver.add(o=>{var S;const r=(S=this._sheetSkeletonManagerService.getCurrent())==null?void 0:S.skeleton;if(r==null||o.isTrigger===!1)return;const s=this._getSheetObject();if(r==null||s==null)return;const{actualScrollX:a=0,actualScrollY:c=0}=o,{row:d,column:u,rowOffset:h,columnOffset:m}=r.getDecomposedOffset(a,c);this._scrollManagerService.addOrReplaceNoRefresh({sheetViewStartRow:d,sheetViewStartColumn:u,offsetX:m,offsetY:h})}))),this.disposeWithMe(l.toDisposable(e==null?void 0:e.onScrollByBarObserver.add(o=>{var _;const r=(_=this._sheetSkeletonManagerService.getCurrent())==null?void 0:_.skeleton;if(r==null||o.isTrigger===!1)return;const s=this._getSheetObject();if(r==null||s==null)return;const{actualScrollX:a=0,actualScrollY:c=0}=o,d=this._getFreeze(),{row:u,column:h,rowOffset:m,columnOffset:S}=r.getDecomposedOffset(a,c);this._commandService.executeCommand(ct.id,{sheetViewStartRow:u+((d==null?void 0:d.ySplit)||0),sheetViewStartColumn:h+((d==null?void 0:d.xSplit)||0),offsetX:S,offsetY:m})})))}_scrollSubscribeBinding(){this.disposeWithMe(l.toDisposable(this._scrollManagerService.scrollInfo$.subscribe(t=>{var g;const e=(g=this._sheetSkeletonManagerService.getCurrent())==null?void 0:g.skeleton,n=this._getSheetObject();if(e==null||n==null)return;const o=n.scene;n.scene.getAncestorScale();const r=o.getViewport(F.VIEW_MAIN);if(r==null)return;if(t==null){r.scrollTo({x:0,y:0});return}const{sheetViewStartRow:s,sheetViewStartColumn:a,offsetX:c,offsetY:d}=t,{startX:u,startY:h}=e.getCellByIndexWithNoHeader(s,a),m=u+c,S=h+d,_=r.getBarScroll(m,S);r.scrollTo(_)})))}_initSkeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(t=>{if(t==null)return;const{unitId:e,sheetId:n}=t;this._renderManagerService.getRenderById(e)!=null&&(this._updateSceneSize(t),this._scrollManagerService.setCurrentScroll({unitId:e,sheetId:n}))})))}_updateSceneSize(t){var d;if(t==null)return;const{skeleton:e,unitId:n}=t,o=(d=this._renderManagerService.getRenderById(n))==null?void 0:d.scene;if(e==null||o==null)return;const{rowTotalHeight:r,columnTotalWidth:s,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:c}=e;o==null||o.transformByState({width:a+s,height:c+r})}_getSheetObject(){return Ie(this._currentUniverService,this._renderManagerService)}_scrollToSelectionByDirection(t){const e=this._getViewportBounding();if(e==null)return!1;const{startRow:n,startColumn:o,endRow:r,endColumn:s}=e;let a=0,c=0;const{startRow:d,startColumn:u,endRow:h,endColumn:m}=t;d>=n&&(a=h),h<=r&&(a=d),u>=o&&(c=m),m<=s&&(c=u),this._scrollToCell(a,c)}_scrollToSelection(t=!0){const e=this._selectionManagerService.getLast();if(e==null)return;const{startRow:n,startColumn:o,actualRow:r,actualColumn:s}=e.primary,a=t?r:n,c=t?s:o;this._scrollToCell(a,c)}_getViewportBounding(){var r,s;const t=(r=this._getSheetObject())==null?void 0:r.scene;if(t==null)return;const e=t.getViewport(F.VIEW_MAIN);if(e==null)return;const n=(s=this._sheetSkeletonManagerService.getCurrent())==null?void 0:s.skeleton;if(n==null)return;const o=e.getBounding();return n.getRowColumnSegment(o)}_scrollToCell(t,e){var O,N,D,k;const{rowHeightAccumulation:n,columnWidthAccumulation:o}=(N=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton)!=null?N:{};if(n==null||o==null)return!1;const r=(D=this._getSheetObject())==null?void 0:D.scene;if(r==null)return!1;const s=r.getViewport(F.VIEW_MAIN);if(s==null||this._getSheetObject()==null||((k=this._sheetSkeletonManagerService.getCurrent())==null?void 0:k.skeleton)==null)return!1;const d=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet(),{startColumn:u,startRow:h,ySplit:m,xSplit:S}=d.getFreeze(),_=this._getViewportBounding();if(_==null)return!1;const{startRow:g,startColumn:v,endRow:M,endColumn:R}=_;let b,E;if(t>=h&&e>=u-S&&(t<=g&&(b=t),t>=M)){const A=n[t]-s.height;for(let L=g;L<=t;L++)if(n[L]>=A){b=L+1;break}}if(e>=u&&t>=h-m&&(e<=v&&(E=e),e>=R)){const A=o[e]-s.width;for(let L=v;L<=e;L++)if(o[L]>=A){E=L+1;break}}if(b===void 0&&E===void 0)return!1;const{offsetX:T,offsetY:y}=this._scrollManagerService.getCurrentScroll()||{};return this._commandService.syncExecuteCommand(ct.id,{sheetViewStartRow:b,sheetViewStartColumn:E,offsetX:E===void 0?T:0,offsetY:b===void 0?y:0})}},x.ScrollController=$a([l.OnLifecycle(l.LifecycleStages.Rendered,x.ScrollController),It(0,P.Inject(x.SheetSkeletonManagerService)),It(1,l.IUniverInstanceService),It(2,l.ICommandService),It(3,w.IRenderManagerService),It(4,P.Inject(f.SelectionManagerService)),It(5,P.Inject(Xe))],x.ScrollController);const Pe={id:"sheet.operation.set-zoom-ratio",type:l.CommandType.OPERATION,handler:(i,t)=>{const e=i.get(l.IUniverInstanceService).getUniverSheetInstance(t.unitId),n=e==null?void 0:e.getSheetBySheetId(t.subUnitId);return n==null?!1:(n.getConfig().zoomRatio=t.zoomRatio,!0)}};var Mt=(i=>(i.Append="APPEND",i.Default="DEFAULT",i.Only="ONLY",i))(Mt||{}),me=(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))(me||{}),oe=(i=>(i.COPY="0",i.SERIES="1",i.ONLY_FORMAT="2",i.NO_FORMAT="3",i))(oe||{});const Ga={type:me.NUMBER,priority:1e3,match:i=>typeof(i==null?void 0:i.v)=="number"||(i==null?void 0:i.t)===l.CellValueType.NUMBER,isContinue:(i,t)=>i.type===me.NUMBER,applyFunctions:{[oe.SERIES]:(i,t,e)=>{const{data:n}=i;return e===l.Direction.LEFT||e===l.Direction.UP?(n.reverse(),ho(n,t,e).reverse()):ho(n,t,e)}}},zo={type:me.OTHER,priority:0,match:()=>!0,isContinue:(i,t)=>i.type===me.OTHER},Ka={type:me.EXTEND_NUMBER,priority:900,match:i=>Sn(`${i==null?void 0:i.v}`||"").isExtendNumber,isContinue:(i,t)=>{var e;if(i.type===me.EXTEND_NUMBER){const{beforeTxt:n,afterTxt:o}=Sn(`${(e=i.cellData)==null?void 0:e.v}`||""),{beforeTxt:r,afterTxt:s}=Sn(`${t==null?void 0:t.v}`||"");if(n===r&&o===s)return!0}return!1},applyFunctions:{[oe.SERIES]:(i,t,e)=>{var a;const{data:n}=i,o=e===l.Direction.UP||e===l.Direction.LEFT;let r;if(n.length===1)return r=o?-1:1,Te(mo(n,t,r),o);const s=[];for(let c=0;c<n.length;c++){const d=`${(a=n[c])==null?void 0:a.v}`;d&&s.push(Number(Sn(d).matchTxt))}return o&&(n.reverse(),s.reverse()),Dt(s)?(r=s[1]-s[0],Te(mo(n,t,r),o)):rt(n,t)}}},Qa={type:me.CHN_NUMBER,priority:830,match:i=>!!bs(`${i==null?void 0:i.v}`||""),isContinue:(i,t)=>i.type===me.CHN_NUMBER,applyFunctions:{[oe.SERIES]:(i,t,e)=>{var c,d,u;const{data:n}=i,o=e===l.Direction.LEFT||e===l.Direction.UP;if(n.length===1){const h=`${(c=n[0])==null?void 0:c.v}`;let m;return o?m=-1:m=1,h&&(h==="日"||Ye(h)<7)?Te(ft(n,t,m),o):Te(So(n,t,m),o)}let r=!1;for(let h=0;h<n.length;h++)if(((d=n[h])==null?void 0:d.v)==="日"){r=!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)):r&&Ye(m)>0&&Ye(m)<7?s.push(Ye(m)+a*7):s.push(Ye(m))}if(o&&(n.reverse(),s.reverse()),Dt(s)){if(r||s[s.length-1]<6&&s[0]>0||s[0]<6&&s[s.length-1]>0){const m=s[1]-s[0];return Te(ft(n,t,m),o)}const h=s[1]-s[0];return Te(So(n,t,h),o)}return rt(n,t)}}},Ja={type:me.CHN_WEEK2,priority:820,match:i=>!!ws(`${i==null?void 0:i.v}`||""),isContinue:(i,t)=>i.type===me.CHN_WEEK2,applyFunctions:{[oe.SERIES]:(i,t,e)=>{var a;const{data:n}=i,o=e===l.Direction.LEFT||e===l.Direction.UP;if(n.length===1){let c;return o?c=-1:c=1,Te(ft(n,t,c,1),o)}const r=[];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?r.push(0):(s++,r.push(s*7)):r.push(Ye(u)+s*7)}if(o&&(n.reverse(),r.reverse()),Dt(r)){const c=r[1]-r[0];return Te(ft(n,t,c,1),o)}return rt(n,t)}}},qa={type:me.CHN_WEEK3,priority:810,match:i=>Ts(`${i==null?void 0:i.v}`||""),isContinue:(i,t)=>i.type===me.CHN_WEEK3,applyFunctions:{[oe.SERIES]:(i,t,e)=>{var a;const{data:n}=i,o=e===l.Direction.LEFT||e===l.Direction.UP;if(n.length===1){let c;return o?c=-1:c=1,Te(ft(n,t,c,2),o)}const r=[];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?r.push(0):(s++,r.push(s*7)):r.push(Ye(u)+s*7)}}if(o&&(n.reverse(),r.reverse()),Dt(r)){const c=r[1]-r[0];return Te(ft(n,t,c,2),o)}return rt(n,t)}}},el={type:me.LOOP_SERIES,priority:800,match:i=>Ds(`${i==null?void 0:i.v}`||""),isContinue:(i,t)=>{var e;return i.type===me.LOOP_SERIES?ai(`${(e=i.cellData)==null?void 0:e.v}`||"").name===ai(`${t==null?void 0:t.v}`||"").name:!1},applyFunctions:{[oe.SERIES]:(i,t,e)=>{var c,d;const{data:n}=i,o=e===l.Direction.LEFT||e===l.Direction.UP,{series:r}=ai(`${(c=n[0])==null?void 0:c.v}`||"");if(n.length===1){let u;return o?u=-1:u=1,Te(_o(n,t,u,r),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===r[0]?u===0?s.push(0):(a++,s.push(a*r.length)):s.push(r.indexOf(h)+a*7))}if(o&&(n.reverse(),s.reverse()),Dt(s)){const u=s[1]-s[0];return Te(_o(n,t,u,r),o)}return rt(n,t)}}};function Te(i,t){return t?i.reverse():i}var tl=Object.defineProperty,nl=Object.getOwnPropertyDescriptor,il=(i,t,e,n)=>{for(var o=n>1?void 0:n?nl(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&tl(t,e,o),o},Mi=(i,t)=>(e,n)=>t(e,n,i);x.AutoFillService=class extends l.Disposable{constructor(e,n,o){super();I(this,"_rules",[]);I(this,"_hooks",[]);I(this,"_applyType$",new V.BehaviorSubject(oe.SERIES));I(this,"_isFillingStyle",!0);I(this,"_autoFillLocation$",new V.BehaviorSubject(null));I(this,"autoFillLocation$",this._autoFillLocation$.asObservable());I(this,"_showMenu$",new V.BehaviorSubject(!1));I(this,"showMenu$",this._showMenu$.asObservable());I(this,"_direction",l.Direction.DOWN);I(this,"applyType$",this._applyType$.asObservable());I(this,"_menu$",new V.BehaviorSubject([{label:"autoFill.copy",value:oe.COPY,disable:!1},{label:"autoFill.series",value:oe.SERIES,disable:!1},{label:"autoFill.formatOnly",value:oe.ONLY_FORMAT,disable:!1},{label:"autoFill.noFormat",value:oe.NO_FORMAT,disable:!1}]));I(this,"menu$",this._menu$.asObservable());this._sheetInterceptorService=e,this._univerInstanceService=n,this._selectionManagerService=o,this._init()}_init(){this._rules=[Ga,Ka,Qa,Ja,qa,el,zo].sort((e,n)=>n.priority-e.priority),this._isFillingStyle=!0}getOneByPriority(e){return e.length<=0?[]:[e.reduce((o,r)=>(r.priority||0)>(o.priority||0)?r:o,e[0])]}addHook(e){if(this._hooks.find(n=>n.id===e.id))throw new Error(`Add hook failed, hook id '${e.id}' already exist!`);return e.priority===void 0&&(e.priority=0),e.type===void 0&&(e.type=Mt.Append),this._hooks.push(e),l.toDisposable(()=>{const n=this._hooks.findIndex(o=>o===e);n>-1&&this._hooks.splice(n,1)})}registerRule(e){if(this._rules.find(o=>o.type===e.type))throw new Error(`Registry rule failed, type '${e.type}' already exist!`);const n=this._rules.findIndex(o=>o.priority<e.priority);this._rules.splice(n===-1?this._rules.length:n,0,e)}getRules(){return this._rules}getAllHooks(){return this._hooks}getActiveHooks(){const{source:e,target:n,unitId:o,subUnitId:r}=this.autoFillLocation||{};if(!e||!n||!o||!r)return[];const s=this._hooks.filter(u=>{var h;return!((h=u.disable)!=null&&h.call(u,{source:e,target:n,unitId:o,subUnitId:r},this._direction,this.applyType))}),a=s.filter(u=>u.type===Mt.Only);if(a.length>0)return this.getOneByPriority(a);const c=this.getOneByPriority(s.filter(u=>u.type===Mt.Default)),d=s.filter(u=>u.type===Mt.Append)||[];return[...c,...d]}get applyType(){return this._applyType$.getValue()}set applyType(e){this._applyType$.next(e)}get menu(){return this._menu$.getValue()}get direction(){return this._direction}set direction(e){this._direction=e}isFillingStyle(){return this._isFillingStyle}setFillingStyle(e){this._isFillingStyle=e}get autoFillLocation(){return this._autoFillLocation$.getValue()}set autoFillLocation(e){this._autoFillLocation$.next(e)}setDisableApplyType(e,n){this._menu$.next(this._menu$.getValue().map(o=>o.value===e?{...o,disable:n}:o))}setShowMenu(e){this._showMenu$.next(e)}},x.AutoFillService=il([l.OnLifecycle(l.LifecycleStages.Rendered,x.AutoFillService),Mi(0,P.Inject(f.SheetInterceptorService)),Mi(1,P.Inject(l.IUniverInstanceService)),Mi(2,P.Inject(f.SelectionManagerService))],x.AutoFillService);const Wt=P.createIdentifier("univer.auto-fill-service");var ol=Object.defineProperty,rl=Object.getOwnPropertyDescriptor,sl=(i,t,e,n)=>{for(var o=n>1?void 0:n?rl(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&ol(t,e,o),o},$e=(i,t)=>(e,n)=>t(e,n,i);x.AutoFillController=class extends l.Disposable{constructor(e,n,o,r,s,a,c,d,u){super();I(this,"_beforeApplyData",[]);I(this,"_copyData",[]);I(this,"_defaultHook");this._univerInstanceService=e,this._selectionRenderService=n,this._commandService=o,this._undoRedoService=r,this._autoFillService=s,this._editorBridgeService=a,this._sheetInterceptorService=c,this._selectionManagerService=d,this._injector=u,this._defaultHook={id:"default",type:Mt.Default,priority:0,onBeforeFillData:(h,m)=>{this._presetAndCacheData(h,m)},onFillData:(h,m,S)=>this._fillData(h,m,S)},this._init()}_init(){this._initDefaultHook(),this._onSelectionControlFillChanged(),this._onApplyTypeChanged(),[go,_n].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initDefaultHook(){this._autoFillService.addHook(this._defaultHook)}_onSelectionControlFillChanged(){const e=new l.DisposableCollection,n=o=>{const r=this._selectionManagerService.getCurrent();if((r==null?void 0:r.pluginName)!==f.NORMAL_SELECTION_PLUGIN_NAME)return;o.dispose(),this._selectionRenderService.getCurrentControls().forEach(a=>{o.add(l.toDisposable(a.selectionFilled$.subscribe(c=>{if(c==null||c.startColumn===-1||c.startRow===-1||c.endColumn===-1||c.endRow===-1)return;const d={startColumn:a.model.startColumn,endColumn:a.model.endColumn,startRow:a.model.startRow,endRow:a.model.endRow},u={startColumn:c.startColumn,endColumn:c.endColumn,startRow:c.startRow,endRow:c.endRow};this._triggerAutoFill(d,u)}))),o.add(l.toDisposable(a.fillControl.onDblclickObserver.add(()=>{const c={startColumn:a.model.startColumn,endColumn:a.model.endColumn,startRow:a.model.startRow,endRow:a.model.endRow};this._handleDbClickFill(c)}))),o.add(l.toDisposable(a.fillControl.onPointerDownObserver.add(()=>{this._editorBridgeService.isVisible().visible&&this._editorBridgeService.changeVisible({visible:!1,eventType:w.DeviceInputEventType.PointerDown})})))})};n(e),this.disposeWithMe(this._commandService.onCommandExecuted(o=>{o.id===f.SetSelectionsOperation.id&&n(e)}))}_onApplyTypeChanged(){this.disposeWithMe(l.toDisposable(this._autoFillService.applyType$.subscribe(()=>{this._handleFillData()})))}_triggerAutoFill(e,n){var d;if(e.startColumn===n.startColumn&&e.startRow===n.startRow&&e.endColumn===n.endColumn&&e.endRow===n.endRow)return;if(n.endColumn<e.endColumn&&n.endColumn>e.startColumn){this._commandService.executeCommand(_n.id,{clearRange:{startRow:n.startRow,endRow:n.endRow,startColumn:n.endColumn+1,endColumn:e.endColumn},selectionRange:n});return}if(n.endRow<e.endRow&&n.endRow>e.startRow){this._commandService.executeCommand(_n.id,{clearRange:{startRow:n.endRow+1,endRow:e.endRow,startColumn:n.startColumn,endColumn:n.endColumn},selectionRange:n});return}const o={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn};let r=null;if(n.startRow<e.startRow)r=l.Direction.UP,o.endRow=e.startRow-1;else if(n.endRow>e.endRow)r=l.Direction.DOWN,o.startRow=e.endRow+1;else if(n.startColumn<e.startColumn)r=l.Direction.LEFT,o.endColumn=e.startColumn-1;else if(n.endColumn>e.endColumn)r=l.Direction.RIGHT,o.startColumn=e.endColumn+1;else return;const s=this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),a=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();this._autoFillService.direction=r,this._autoFillService.autoFillLocation={source:e,target:o,unitId:s,subUnitId:a},this._autoFillService.getActiveHooks().forEach(u=>{var h;(h=u==null?void 0:u.onBeforeFillData)==null||h.call(u,{source:e,target:o,unitId:s,subUnitId:a},r)}),(d=this._autoFillService.menu.find(u=>u.value===oe.SERIES))!=null&&d.disable?this._autoFillService.applyType=oe.COPY:this._autoFillService.applyType=oe.SERIES}_handleDbClickFill(e){const n=this._detectFillRange(e);n.endRow<=e.endRow||this._triggerAutoFill(e,n)}_detectFillRange(e){var m,S,_,g,v,M;const{startRow:n,endRow:o,startColumn:r,endColumn:s}=e,a=(m=this._univerInstanceService.getCurrentUniverSheetInstance())==null?void 0:m.getActiveSheet();if(!a)return e;const c=a.getCellMatrix(),d=a.getMaxRows()-1,u=a.getMaxColumns()-1;let h=o;if(r>0&&((S=c.getValue(n,r-1))==null?void 0:S.v)!=null){let R=n;for(;((_=c.getValue(R,r-1))==null?void 0:_.v)!=null&&R<d;)R+=1;h=R-1}else if(s<u&&((g=c.getValue(o,s+1))==null?void 0:g.v)!=null){let R=n;for(;((v=c.getValue(R,s+1))==null?void 0:v.v)!=null&&R<d;)R+=1;h=R-1}for(let R=o+1;R<=h;R++)for(let b=r;b<=s;b++)if(((M=c.getValue(R,b))==null?void 0:M.v)!=null){h=R-1;break}return{startColumn:r,endColumn:s,startRow:n,endRow:h}}_handleFillData(){var S,_;const{source:e,target:n,unitId:o=this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),subUnitId:r=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId()}=this._autoFillService.autoFillLocation||{},s=this._autoFillService.direction;if(!e||!n)return;const a=l.Rectangle.union(e,n),c=this._autoFillService.applyType,d=this._autoFillService.getActiveHooks();this._commandService.syncExecuteCommand(f.SetSelectionsOperation.id,{selections:[{primary:{...(_=(S=this._selectionManagerService.getLast())==null?void 0:S.primary)!=null?_:a},range:{...a,rangeType:l.RANGE_TYPE.NORMAL}}],unitId:o,subUnitId:r});const u=[],h=[];d.forEach(g=>{var R;const{undos:v,redos:M}=((R=g.onFillData)==null?void 0:R.call(g,{source:e,target:n,unitId:o,subUnitId:r},s,c))||{};v&&u.push(...v),M&&h.push(...M)}),h.every(g=>this._commandService.syncExecuteCommand(g.id,g.params))&&this._undoRedoService.pushUndoRedo({unitID:o,undoMutations:u,redoMutations:h}),d.forEach(g=>{var v;(v=g.onAfterFillData)==null||v.call(g,{source:e,target:n,unitId:o,subUnitId:r},s,c)}),this._autoFillService.setShowMenu(!0)}_getApplyData(e,n,o,r,s,a=!0){const c=[],d=Math.floor(o/n),u=o%n,h=this._autoFillService.getRules();if(!a&&s===oe.ONLY_FORMAT)return console.error("ERROR: only format can not be applied when hasStyle is false"),[];const m={};h.forEach(S=>{m[S.type]=[]}),h.forEach(S=>{const{type:_,applyFunctions:g={}}=S,v=e[_];v&&v.forEach(M=>{const R=Es(M.index,u),b=M.index.length*d+R,E=this._applyFunctions(M,b,r,s,g,e),T=ys(n,o,M.index);m[_].push({data:E,index:T})})});for(let S=0;S<o;S++)h.forEach(_=>{const{type:g}=_,v=m[g];for(let M=0;M<v.length;M++)S in v[M].index&&c.push(v[M].data[v[M].index[S]])});return c}_applyFunctions(e,n,o,r,s,a){const{data:c}=e,d=o===l.Direction.UP||o===l.Direction.LEFT;if(r===oe.COPY){const u=s==null?void 0:s[oe.COPY];return u?u(e,n,o,a):(d&&c.reverse(),rt(c,n))}if(r===oe.SERIES){const u=s==null?void 0:s[oe.SERIES];return u?u(e,n,o,a):(d&&c.reverse(),s!=null&&s[oe.COPY]?s[oe.COPY](e,n,o,a):rt(c,n))}if(r===oe.ONLY_FORMAT){const u=s==null?void 0:s[oe.ONLY_FORMAT];return u?u(e,n,o,a):Os(c,n)}}_getCopyData(e,n){const{startRow:o,startColumn:r,endRow:s,endColumn:a}=e,c=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getCellMatrix(),d=this._autoFillService.getRules(),u=[],h=n===l.Direction.DOWN||n===l.Direction.UP;let m,S,_,g;h?(m=r,S=a,_=o,g=s):(m=o,S=s,_=r,g=a);for(let v=m;v<=S;v++){const M=this._getEmptyCopyDataPiece(),R={type:void 0,cellData:void 0};for(let b=_;b<=g;b++){let E;h?E=c.getValue(b,v):E=c.getValue(v,b);const{type:T,isContinue:y}=d.find(O=>O.match(E))||zo;if(y(R,E)){const O=M[T],N=O[O.length-1];N.data.push(E),N.index.push(b-_)}else{const O=M[T];O?O.push({data:[E],index:[b-_]}):M[T]=[{data:[E],index:[b-_]}]}R.type=T,R.cellData=E}u.push(M)}return u}_getEmptyCopyDataPiece(){const e={};return this._autoFillService.getRules().forEach(n=>{e[n.type]=[]}),e}_getMergeApplyData(e,n,o,r){const s=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData(),a=[];for(let c=e.startRow;c<=e.endRow;c++)for(let d=e.startColumn;d<=e.endColumn;d++){const{isMergedMainCell:u,startRow:h,startColumn:m,endRow:S,endColumn:_}=w.getCellInfoInMergeData(c,d,s);if(u){if(o===l.Direction.DOWN){let g=h+r,v=S+r;for(;v<=n.endRow;)a.push({startRow:g,startColumn:m,endRow:v,endColumn:_}),g+=r,v+=r}else if(o===l.Direction.UP){let g=h-r,v=S-r;for(;g>=n.startRow;)a.push({startRow:g,startColumn:m,endRow:v,endColumn:_}),g-=r,v-=r}else if(o===l.Direction.RIGHT){let g=m+r,v=_+r;for(;v<=n.endColumn;)a.push({startRow:h,startColumn:g,endRow:S,endColumn:v}),g+=r,v+=r}else if(o===l.Direction.LEFT){let g=m-r,v=_-r;for(;g>=n.startColumn;)a.push({startRow:h,startColumn:g,endRow:S,endColumn:v}),g-=r,v-=r}}}return a}_presetAndCacheData(e,n){const{source:o,target:r}=e,s=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getCellMatrix(),a=[];for(let c=r.startRow;c<=r.endRow;c++){const d=[];for(let u=r.startColumn;u<=r.endColumn;u++)d.push(l.Tools.deepClone(s.getValue(c,u)));a.push(d)}this._beforeApplyData=a,this._copyData=this._getCopyData(o,n),this._hasSeries(this._copyData)?this._autoFillService.setDisableApplyType(oe.SERIES,!1):this._autoFillService.setDisableApplyType(oe.SERIES,!0)}_fillData(e,n,o){var re,se;const r=[],s=[];let a=!0;o===oe.NO_FORMAT&&(a=!1,o=oe.SERIES);const{source:c,target:d,unitId:u,subUnitId:h}=e;if(!c||!d||n==null)return{undos:r,redos:s};const{startRow:m,startColumn:S,endRow:_,endColumn:g}=c,{startRow:v,startColumn:M,endRow:R,endColumn:b}=d,E=this._copyData;let T;n===l.Direction.DOWN||n===l.Direction.UP?T=_-m+1:T=g-S+1;const y=[];if(n===l.Direction.DOWN||n===l.Direction.UP){const Y=R-v+1,Q=[];for(let J=M;J<=b;J++){const ae=E[J-M],ce=this._getApplyData(ae,T,Y,n,o,a);Q.push(ce)}for(let J=0;J<Q[0].length;J++){const ae=[];for(let ce=0;ce<Q.length;ce++)ae.push({s:null,...Q[ce][J]});y.push(ae)}}else{const Y=b-M+1;for(let Q=v;Q<=R;Q++){const J=E[Q-v],ae=this._getApplyData(J,T,Y,n,o,a),ce=[];for(let pe=0;pe<ae.length;pe++)ce.push({s:null,...ae[pe]});y.push(ce)}}let O=[];const N=this._univerInstanceService.getCurrentUniverSheetInstance().getStyles();a?(O=this._getMergeApplyData(c,d,n,T),y.forEach(Y=>{Y.forEach(Q=>{Q&&N&&N&&(Q.s=N.getStyleByCell(Q))})})):y.forEach((Y,Q)=>{Y.forEach((J,ae)=>{J&&N&&(J.s=N.getStyleByCell(this._beforeApplyData[Q][ae])||null)})}),o===oe.ONLY_FORMAT&&y.forEach((Y,Q)=>{Y.forEach((J,ae)=>{if(J){const ce=this._beforeApplyData[Q][ae]||{};J.f=ce.f,J.si=ce.si,J.t=ce.t,J.v=ce.v}})});const D={get:this._injector.get.bind(this._injector)},k=[],A=(se=(re=this._univerInstanceService.getUniverSheetInstance(u))==null?void 0:re.getSheetBySheetId(h))==null?void 0:se.getMergeData();A&&A.forEach(Y=>{l.Rectangle.intersects(Y,d)&&k.push(Y)});const L={unitId:u,subUnitId:h,ranges:k},B=f.RemoveMergeUndoMutationFactory(D,L);s.push({id:f.RemoveWorksheetMergeMutation.id,params:L}),r.push({id:f.AddWorksheetMergeMutation.id,params:B});const j={subUnitId:h,unitId:u,cellValue:fo([d])},X=f.SetRangeValuesUndoMutationFactory(D,j),z=this._sheetInterceptorService.onCommandExecute({id:f.ClearSelectionContentCommand.id});s.push({id:f.SetRangeValuesMutation.id,params:j},...z.redos),r.push(...z.undos,{id:f.SetRangeValuesMutation.id,params:X});const Z=new l.ObjectMatrix,{startRow:ee,startColumn:ne,endRow:U,endColumn:W}=d;for(let Y=0;Y<=U-ee;Y++)for(let Q=0;Q<=W-ne;Q++)y[Y][Q]&&Z.setValue(Y+ee,Q+ne,y[Y][Q]);const $={subUnitId:h,unitId:u,cellValue:Z.getMatrix()},q=f.SetRangeValuesUndoMutationFactory(D,$);if(r.push({id:f.SetRangeValuesMutation.id,params:q}),s.push({id:f.SetRangeValuesMutation.id,params:$}),O!=null&&O.length){const Y=f.getAddMergeMutationRangeByType(O),Q={unitId:u,subUnitId:h,ranges:Y},J=f.AddMergeUndoMutationFactory(D,Q);r.push({id:f.RemoveWorksheetMergeMutation.id,params:J}),s.push({id:f.AddWorksheetMergeMutation.id,params:Q})}return{undos:r,redos:s}}_hasSeries(e){return e.some(n=>Object.keys(n).some(r=>{var s;return!!((s=n[r])!=null&&s.length&&![me.OTHER,me.FORMULA].includes(r))}))}},x.AutoFillController=sl([l.OnLifecycle(l.LifecycleStages.Steady,x.AutoFillController),$e(0,l.IUniverInstanceService),$e(1,ge),$e(2,l.ICommandService),$e(3,l.IUndoRedoService),$e(4,Wt),$e(5,we),$e(6,P.Inject(f.SheetInterceptorService)),$e(7,P.Inject(f.SelectionManagerService)),$e(8,P.Inject(P.Injector))],x.AutoFillController);var al=Object.defineProperty,ll=Object.getOwnPropertyDescriptor,cl=(i,t,e,n)=>{for(var o=n>1?void 0:n?ll(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&al(t,e,o),o},Ri=(i,t)=>(e,n)=>t(e,n,i);x.CellCustomRenderController=class extends l.Disposable{constructor(e,n,o){super();I(this,"_enterActiveRender");this._sheetSkeletonManagerService=e,this._renderManagerService=n,this._univerInstanceService=o,this._initEventBinding()}_initEventBinding(){const e=new l.DisposableCollection;this._univerInstanceService.currentSheet$.subscribe(n=>{if(n){const o=n.getUnitId(),r=this._renderManagerService.getRenderById(n.getUnitId());if(r&&r.mainComponent){e.dispose();const s=r.mainComponent,a=u=>{var z;const h=(z=this._sheetSkeletonManagerService.getCurrent())==null?void 0:z.skeleton,{offsetX:m,offsetY:S}=u,_=r.scene,g=n.getActiveSheet(),v=_.getActiveViewportByCoord(w.Vector2.FromArray([m,S]));if(!v)return;const{scaleX:M,scaleY:R}=_.getAncestorScale(),b={x:v.actualScrollX,y:v.actualScrollY},E=h.getCellPositionByOffset(m,S,M,R,b),T=h.mergeData.find(Z=>{const{startColumn:ee,startRow:ne,endColumn:U,endRow:W}=Z;return E.row>=ne&&E.column>=ee&&E.row<=W&&E.column<=U}),y={actualRow:T?T.startRow:E.row,actualCol:T?T.startColumn:E.column,mergeCell:T,row:E.row,col:E.column};if(!y||!h)return;const O=g.getCell(y.actualRow,y.actualCol);if(!O)return;const N=O.customRender;if(!(N!=null&&N.length))return;const D=y.actualRow,k=y.actualCol,A=N.sort(l.sortRules),L=n.getActiveSheet().getSheetId(),B={data:O,style:h.getsStyles().getStyleByCell(O),primaryWithCoord:h.getCellByIndex(y.actualRow,y.actualCol),unitId:o,subUnitId:L,row:D,col:k},j={x:b.x+m/M,y:b.y+S/R},X=A.find(Z=>{var ee;return(ee=Z.isHit)==null?void 0:ee.call(Z,j,B)});if(X)return[X,B]},c=s.onPointerDownObserver.add(u=>{var m;const h=a(u);if(h){const[S,_]=h;(m=S.onPointerDown)==null||m.call(S,_,u)}}),d=s.onPointerMoveObserver.add(u=>{var m,S,_,g;const h=a(u);if(h){const[v,M]=h;this._enterActiveRender?this._enterActiveRender.render!==v&&((S=(m=this._enterActiveRender.render).onPointerLeave)==null||S.call(m,this._enterActiveRender.cellContext,u),this._enterActiveRender={render:v,cellContext:M},(_=v.onPointerEnter)==null||_.call(v,M,u)):(this._enterActiveRender={render:v,cellContext:M},(g=v.onPointerEnter)==null||g.call(v,M,u))}});c&&e.add(c),d&&e.add(d)}}}),this.disposeWithMe(e)}},x.CellCustomRenderController=cl([l.OnLifecycle(l.LifecycleStages.Ready,x.CellCustomRenderController),Ri(0,P.Inject(x.SheetSkeletonManagerService)),Ri(1,w.IRenderManagerService),Ri(2,l.IUniverInstanceService)],x.CellCustomRenderController);const Yo={id:"sheet.command.hide-row-confirm",type:l.CommandType.COMMAND,handler:async i=>{var c;const e=(c=i.get(f.SelectionManagerService).getSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const n=i.get(l.ICommandService),a=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance().getActiveSheet().getVisibleRows();if(Bo(a,e)){const d=i.get(C.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(f.SetRowHiddenCommand.id),!0}},Xo={id:"sheet.command.hide-col-confirm",type:l.CommandType.COMMAND,handler:async i=>{var c;const e=(c=i.get(f.SelectionManagerService).getSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const n=i.get(l.ICommandService),a=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance().getActiveSheet().getVisibleCols();if(Fo(a,e)){const d=i.get(C.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(f.SetColHiddenCommand.id),!0}},bi={type:l.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async i=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatBoldCommand.id):t.executeCommand(f.SetBoldCommand.id)}},wi={type:l.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async i=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatItalicCommand.id):t.executeCommand(f.SetItalicCommand.id)}},Ti={type:l.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async i=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatUnderlineCommand.id):t.executeCommand(f.SetUnderlineCommand.id)}},Ei={type:l.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async i=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatStrikethroughCommand.id):t.executeCommand(f.SetStrikeThroughCommand.id)}},dl={type:l.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async i=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatSubscriptCommand.id):!1}},ul={type:l.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async i=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatSuperscriptCommand.id):!1}},$o={type:l.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(i,t)=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?e.executeCommand(te.SetInlineFormatFontSizeCommand.id,t):e.executeCommand(f.SetFontSizeCommand.id,t)}},Zo={type:l.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(i,t)=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?e.executeCommand(te.SetInlineFormatFontFamilyCommand.id,t):e.executeCommand(f.SetFontFamilyCommand.id,t)}},In={type:l.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(i,t)=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?e.executeCommand(te.SetInlineFormatTextColorCommand.id,t):e.executeCommand(f.SetTextColorCommand.id,t)}};function Go(i,t){return t.some(e=>hl(i,e))}function hl(i,t){const{startRow:e,startColumn:n,endColumn:o,endRow:r}=t,s=i.getMatrixWithMergedCells(e,n,r,o);let a=!1;return s.forValue((c,d,u)=>{if(u&&(c!==e||d!==n)&&i.cellHasValue(u))return a=!0,!1}),a}function Ko(i,t,e,n){const o=[],r=[],s=e.getSheetId();return n.forEach(a=>{const c=ml(e,a),d={unitId:t,subUnitId:s,cellValue:c.getData()},u=f.SetRangeValuesUndoMutationFactory(i,d);o.push({id:f.SetRangeValuesMutation.id,params:u}),r.push({id:f.SetRangeValuesMutation.id,params:d})}),{undos:o,redos:r}}function ml(i,t){const{startRow:e,startColumn:n,endColumn:o,endRow:r}=t,s=i.getMatrixWithMergedCells(e,n,r,o),a=new l.ObjectMatrix;return s.forValue((c,d,u)=>{u&&(c!==e||d!==n)&&a.setValue(c,d,null)}),a}function Sl(i,t,e,n){const o=e.getActiveViewportByCoord(w.Vector2.FromArray([i,t]));if(!o)return;const{scaleX:r,scaleY:s}=e.getAncestorScale(),a={x:o.actualScrollX,y:o.actualScrollY},c=n.getCellPositionByOffset(i,t,r,s,a),d=n.mergeData.find(h=>{const{startColumn:m,startRow:S,endColumn:_,endRow:g}=h;return c.row>=S&&c.column>=m&&c.row<=g&&c.column<=_});return{actualRow:d?d.startRow:c.row,actualCol:d?d.startColumn:c.column,mergeCell:d,row:c.row,col:c.column}}function _l(i,t,e,n){const o=n.getFreeze();if(!o||o.startRow<=0&&o.startColumn<=0||i>o.startRow&&t>o.startColumn)return e.getViewport(F.VIEW_MAIN);if(i<=o.startRow&&t<=o.startColumn)return e.getViewport(F.VIEW_MAIN_LEFT_TOP);if(i<=o.startRow&&t>o.startColumn)return e.getViewport(F.VIEW_MAIN_TOP);if(i>o.startRow&&t<=o.startColumn)return e.getViewport(F.VIEW_MAIN_LEFT)}function fl(i,t,e,n){const o=Qo(i.left,i.top,t,e,n),r=Qo(i.right,i.bottom,t,e,n);return{left:o.x,top:o.y,right:r.x,bottom:r.y}}function Qo(i,t,e,n,o){const{scaleX:r,scaleY:s}=e.getAncestorScale(),a=e.getViewport(F.VIEW_MAIN);if(!a)return{x:i,y:t};const c=o.getFreeze(),{startColumn:d,startRow:u,xSplit:h,ySplit:m}=c,S=n.getNoMergeCellPositionByIndexWithNoHeader(u-m,d-h),_=n.getNoMergeCellPositionByIndexWithNoHeader(u,d),{rowHeaderWidth:g,columnHeaderHeight:v}=n,M=_.startX-S.startX,R=_.startY-S.startY,{top:b,left:E,actualScrollX:T,actualScrollY:y}=a;let O;i>E?O=(i-T)*r:O=(M+g-(E-i))*r;let N;return t>b?N=(t-y)*s:N=(R+v-(b-t))*r,{x:O,y:N}}var gl=Object.defineProperty,pl=Object.getOwnPropertyDescriptor,vl=(i,t,e,n)=>{for(var o=n>1?void 0:n?pl(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&gl(t,e,o),o},yi=(i,t)=>(e,n)=>t(e,n,i),Le=(i=>(i[i.OFF=0]="OFF",i[i.ONCE=1]="ONCE",i[i.INFINITE=2]="INFINITE",i))(Le||{});const Rt=P.createIdentifier("univer.format-painter-service");let Oi=class extends l.Disposable{constructor(t,e,n){super();I(this,"status$");I(this,"_selectionFormat");I(this,"_markId",null);I(this,"_status$");this._selectionManagerService=t,this._univerInstanceService=e,this._markSelectionService=n,this._status$=new V.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new l.ObjectMatrix,merges:[]}}setStatus(t){t!==0&&this._getSelectionRangeFormat(),this._updateRangeMark(t),this._status$.next(t)}getStatus(){return this._status$.getValue()}_updateRangeMark(t){if(this._markSelectionService.removeAllShapes(),this._markId=null,t!==0){const e=this._selectionManagerService.getLast();if(e){const n=this._selectionManagerService.createCopyPasteSelection();t===2?this._markId=this._markSelectionService.addShape({...e,style:n}):this._markId=this._markSelectionService.addShape({...e,style:n},[f.SetRangeValuesMutation.id])}}}_getSelectionRangeFormat(){const t=this._selectionManagerService.getLast(),e=t==null?void 0:t.range;if(!e)return;const{startRow:n,endRow:o,startColumn:r,endColumn:s}=e,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;this._selectionFormat.merges=[];for(let S=n;S<=o;S++)for(let _=r;_<=s;_++){const g=d.getValue(S,_);m.setValue(S,_,h.getStyleByCell(g)||{});const{isMergedMainCell:v,...M}=w.getCellInfoInMergeData(S,_,u);v&&this._selectionFormat.merges.push({startRow:M.startRow,startColumn:M.startColumn,endRow:M.endRow,endColumn:M.endColumn})}this._selectionFormat.styles=m}getSelectionFormat(){return this._selectionFormat}};Oi=vl([yi(0,P.Inject(f.SelectionManagerService)),yi(1,l.IUniverInstanceService),yi(2,Lt)],Oi);const xi={id:"sheet.operation.set-format-painter",type:l.CommandType.OPERATION,handler:(i,t)=>t?(i.get(Rt).setStatus(t.status),!0):!1},Jo={type:l.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async i=>{const e=i.get(Rt).getStatus();let n;return e!==Le.OFF?n=Le.OFF:n=Le.INFINITE,i.get(l.ICommandService).executeCommand(xi.id,{status:n})}},Ni={type:l.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async i=>{const e=i.get(Rt).getStatus();let n;return e!==Le.OFF?n=Le.OFF:n=Le.ONCE,i.get(l.ICommandService).executeCommand(xi.id,{status:n})}},qo={type:l.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(i,t)=>{const e=i.get(l.ICommandService),n=i.get(l.IUndoRedoService),o=i.get(l.IUniverInstanceService),r=i.get(f.SelectionManagerService),s=i.get(f.SheetInterceptorService),{styleValues:a,styleRange:c,mergeRanges:d,unitId:u=o.getCurrentUniverSheetInstance().getUnitId(),subUnitId:h=o.getCurrentUniverSheetInstance().getActiveSheet().getSheetId()}=t,m=c?[c]:r.getSelectionRanges();if(!m||!m.length)return!1;const S=new l.ObjectMatrix;let _;if(l.Tools.isArray(a))for(let j=0;j<m.length;j++){const{startRow:X,startColumn:z,endRow:Z,endColumn:ee}=m[j];for(let ne=0;ne<=Z-X;ne++)for(let U=0;U<=ee-z;U++)S.setValue(ne+X,U+z,a[ne][U])}else if(l.isICellData(a))for(let j=0;j<m.length;j++){const{startRow:X,startColumn:z}=m[j];S.setValue(X,z,a)}else _=a;const g={subUnitId:h,unitId:u,cellValue:_!=null?_:S.getMatrix()},v=f.SetRangeValuesUndoMutationFactory(i,g);if(!s.fetchThroughInterceptors(f.INTERCEPTOR_POINT.PERMISSION)(null,{id:f.SetRangeValuesCommand.id,params:g}))return!1;const M=e.syncExecuteCommand(f.SetRangeValuesMutation.id,g),{undos:R,redos:b}=s.onCommandExecute({id:f.SetRangeValuesCommand.id,params:{...g,range:m}}),E=f.getAddMergeMutationRangeByType(d),T=o.getUniverSheetInstance(u).getSheetBySheetId(h),y=[],O=[],N=Go(T,E),D={unitId:u,subUnitId:h,ranges:E},k={unitId:u,subUnitId:h,ranges:E};y.push({id:f.RemoveWorksheetMergeMutation.id,params:D}),y.push({id:f.AddWorksheetMergeMutation.id,params:k});const A=f.RemoveMergeUndoMutationFactory(i,D),L=f.AddMergeUndoMutationFactory(i,k);if(O.push({id:f.RemoveWorksheetMergeMutation.id,params:L}),O.push({id:f.AddWorksheetMergeMutation.id,params:A}),N){const j=Ko(i,u,T,E);y.unshift(...j.redos),O.push(...j.undos)}const B=await l.sequenceExecute([...b,...y],e);return M&&B.result?(n.pushUndoRedo({unitID:u,undoMutations:[{id:f.SetRangeValuesMutation.id,params:v},...R,...O],redoMutations:[{id:f.SetRangeValuesMutation.id,params:g},...b,...y]}),!0):!1}},Mn={type:l.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(i,t)=>{const{type:e}=t||{},n=i.get(l.IUniverInstanceService),o=i.get(l.IUndoRedoService),r=n.getCurrentUniverSheetInstance().getUnitId(),s=n.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),a=i.get(l.ICommandService),d=i.get(f.SelectionManagerService).getSelections();if(!d)return!1;const u=d[(d==null?void 0:d.length)-1],{range:h}=u,m=i.get(Xe),{sheetViewStartRow:S=0,sheetViewStartColumn:_=0}=m.getCurrentScroll()||{};let g,v,M,R;const{startRow:b,startColumn:E,rangeType:T}=h;if(T===l.RANGE_TYPE.ROW||e===1)g=b,M=b-S,v=-1,R=0;else if(T===l.RANGE_TYPE.COLUMN||e===2)g=-1,M=0,v=E,R=E-_;else if(T===l.RANGE_TYPE.NORMAL)g=b,M=b-S,v=E,R=E-_;else return!1;const y={unitId:r,subUnitId:s,startRow:g,startColumn:v,xSplit:v>0?Math.max(1,R):R,ySplit:g>0?Math.max(1,M):M},O=f.SetFrozenMutationFactory(i,y);return a.syncExecuteCommand(f.SetFrozenMutation.id,y)&&o.pushUndoRedo({unitID:r,undoMutations:[{id:f.SetFrozenMutation.id,params:O}],redoMutations:[{id:f.SetFrozenMutation.id,params:y}]}),!0}},er={type:l.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async i=>(i.get(l.ICommandService).executeCommand(Mn.id,{type:1}),!0)},tr={type:l.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async i=>(i.get(l.ICommandService).executeCommand(Mn.id,{type:2}),!0)},nr={type:l.CommandType.COMMAND,id:"sheet.command.cancel-frozen",handler:async i=>{const t=i.get(l.ICommandService),e=i.get(l.IUniverInstanceService),n=i.get(l.IUndoRedoService),o=e.getCurrentUniverSheetInstance().getUnitId(),r=e.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),s={unitId:o,subUnitId:r,startRow:-1,startColumn:-1,xSplit:0,ySplit:0},a=f.SetFrozenMutationFactory(i,s);return t.syncExecuteCommand(f.SetFrozenMutation.id,s)&&n.pushUndoRedo({unitID:o,undoMutations:[{id:f.SetFrozenMutation.id,params:a}],redoMutations:[{id:f.SetFrozenMutation.id,params:s}]}),!0}},bt="UI_PLUGIN_SHEETS",Rn=`${bt}_COLOR_PICKER_COMPONENT`,ir=`${bt}_FONT_FAMILY_COMPONENT`,or=`${bt}_FONT_FAMILY_ITEM_COMPONENT`,rr=`${bt}_FONT_SIZE_COMPONENT`,Ai=`${bt}_MENU_ITEM_INPUT_COMPONENT`;var sr={exports:{}},bn={};/**
|
|
4
|
+
`)}]}}function ra(i){const t=i.style,e={},n=i.tagName.toLowerCase();switch(n){case"b":case"em":case"strong":{e.bl=l.BooleanNumber.TRUE;break}case"s":{e.st={s:l.BooleanNumber.TRUE};break}case"u":{e.ul={s:l.BooleanNumber.TRUE};break}case"i":{e.it=l.BooleanNumber.TRUE;break}case"sub":case"sup":{e.va=n==="sup"?l.BaselineOffset.SUPERSCRIPT:l.BaselineOffset.SUBSCRIPT;break}}for(let o=0;o<t.length;o++){const r=t[o],s=t.getPropertyValue(r);switch(r){case"font-family":{e.ff=s;break}case"font-size":{const a=Number.parseInt(s);Number.isNaN(a)||(s.endsWith("pt")?e.fs=a:s.endsWith("px")&&(e.fs=w.pixelToPt(a)));break}case"font-style":{s==="italic"&&(e.it=l.BooleanNumber.TRUE);break}case"font-weight":{Number(s)>400&&(e.bl=l.BooleanNumber.TRUE);break}case"text-decoration":{/underline/.test(s)?e.ul={s:l.BooleanNumber.TRUE}:/overline/.test(s)?e.ol={s:l.BooleanNumber.TRUE}:/line-through/.test(s)&&(e.st={s:l.BooleanNumber.TRUE});break}case"color":{const a=new l.ColorKit(s);a.isValid&&(e.cl={rgb:a.toRgbString()});break}case"background-color":{const a=new l.ColorKit(s);a.isValid&&(e.bg={rgb:a.toRgbString()});break}}}return e}function sa(i){const t=new DOMParser,e=`<x-univer id="univer-root">${i}</x-univer>`;return t.parseFromString(e,"text/html").querySelector("#univer-root")}function xo(i,t){const e=[];for(let n=0,o=i.length;n<o;n++)i[n]===l.DataStreamTreeTokenType.PARAGRAPH&&e.push({startIndex:n});if(t)for(const n of e)t.bullet&&(n.bullet=l.Tools.deepClone(t.bullet)),t.paragraphStyle&&(n.paragraphStyle=l.Tools.deepClone(t.paragraphStyle));return e}function No(i,t){const e=i.tagName.toLowerCase();return typeof t=="string"?e===t:Array.isArray(t)?t.some(n=>n===e):t(i)}function aa(i){i.style.display="none",i.style.width="0",i.style.height="0",i.setAttribute("tabindex","-1"),i.setAttribute("aria-hidden","true"),i.setAttribute("title","hidden iframe")}const oi=class oi{constructor(t){I(this,"styleCache",new Map);I(this,"styleRules",[]);I(this,"afterProcessRules",[]);I(this,"htmlElement");I(this,"getCurrentSkeleton");this.getCurrentSkeleton=t.getCurrentSkeleton,this.htmlElement=document.createElement("iframe"),this.htmlElement.style.display="none",document.body.appendChild(this.htmlElement),aa(this.htmlElement)}static use(t){if(this.pluginList.includes(t))throw new Error(`Univer paste plugin ${t.name} already added`);this.pluginList.push(t)}convert(t){this.htmlElement.contentDocument&&(this.htmlElement.contentDocument.open(),this.htmlElement.contentDocument.write(t),this.htmlElement.contentDocument.close()),t=t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style[\s\S]*?<\/style>/g,"");const e=oi.pluginList.find(S=>S.checkPasteType(t));e&&(this.styleRules=[...e.stylesRules],this.afterProcessRules=[...e.afterProcessRules]);const n=new l.ObjectMatrix,o=sa(t),r={dataStream:"",textRuns:[]},s=[],a=[],c=t.match(/<table\b[^>]*>([\s\S]*?)<\/table>/gi),d=[];this.process(null,o==null?void 0:o.childNodes,r,d);const{paragraphs:u,dataStream:h,textRuns:m}=r;if(u){const S=u.map(g=>g.startIndex+1);S.unshift(0);for(let g=0;g<S.length;g++){let _;g===S.length-1?_=`${h.substring(S[g])}\r
|
|
5
|
+
`:_=`${h.substring(S[g],S[g+1]-1)}\r
|
|
6
|
+
`;const v=[];m==null||m.forEach(R=>{R.st>=S[g]&&R.ed<=S[g+1]&&v.push({st:R.st-S[g],ed:R.ed-S[g],ts:R.ts})});const M=this._generateDocumentDataModelSnapshot({body:{dataStream:_,textRuns:v,paragraphs:xo(_)}});n.setValue(n.getLength(),0,{v:_,p:M}),s.push({}),c&&d.forEach(R=>{const b=n.getDataRange().endRow+1;if(R.index===g){const E=c.shift(),{cellMatrix:T,colProperties:y,rowProperties:O}=this._parseTable(E);T&&T.forValue((x,N,V)=>{n.setValue(b+x,N,V)}),y&&a.push(...y),s.push(...O)}})}}else{if(h){const S=`${h}\r
|
|
7
|
+
`,g={dataStream:S,textRuns:m,paragraphs:xo(S)},_=this._generateDocumentDataModelSnapshot({body:g});n.setValue(0,0,{v:h,p:_}),s.push({})}c&&c.forEach(S=>{const g=n.getDataRange().endRow+1,{cellMatrix:_,rowProperties:v,colProperties:M}=this._parseTable(S);_&&_.forValue((R,b,E)=>{const{rowSpan:T=1,colSpan:y=1}=E;for(let O=0;O<T;O++)for(let x=0;x<y;x++)n.setValue(g+R+O,b+x,{v:""});n.setValue(g+R,b,E)}),M&&a.push(...M),s.push(...v)})}return{rowProperties:s,colProperties:a,cellMatrix:n}}_parseTable(t){const e=new l.ObjectMatrix,n=da(t),{rowProperties:o,rowCount:r,cellMatrix:s}=la(t);return s&&s.forValue((a,c,d)=>{var S,g,_,v;let u=(S=d.properties)==null?void 0:S.style;const h=(g=d.properties)==null?void 0:g.class;if(h){const M=(v=(_=this.htmlElement.contentDocument)==null?void 0:_.getElementsByClassName(h))==null?void 0:v[0];if(M){const R=window.getComputedStyle(M,null),{fontSize:b,fontFamily:E,border:T,borderLeft:y,borderRight:O,borderTop:x,borderBottom:N,verticalAlign:V}=R;b&&(u+=`;font-size: ${w.pixelToPt(Number.parseInt(b))}pt`),E&&(u+=`;font-family: ${E}`),T&&(u+=`;border: ${T}`),y&&(u+=`;border-left: ${y}`),O&&(u+=`;border-right: ${O}`),x&&(u+=`;border-top: ${x}`),N&&(u+=`;border-bottom: ${N}`),V&&(u+=`;vertical-align: ${V}`)}}const m=C.handleStringToStyle(void 0,u);if(/\r|\n/.test(d.content)){const M=Ao(d.content),R=this._generateDocumentDataModelSnapshot({body:M});e.setValue(a,c,{v:d.content,p:R,s:m,rowSpan:d.rowSpan,colSpan:d.colSpan})}else e.setValue(a,c,{v:d.content,s:m,rowSpan:d.rowSpan,colSpan:d.colSpan})}),{rowProperties:o,colProperties:n,cellMatrix:e}}_generateDocumentDataModelSnapshot(t){var a;const e=this.getCurrentSkeleton();if(e==null)return null;const{skeleton:n}=e,o=(a=n.getBlankCellDocumentModel())==null?void 0:a.documentModel,s={...o==null?void 0:o.getSnapshot(),...t};return o==null||o.reset(s),o==null?void 0:o.getSnapshot()}process(t,e,n,o){var r,s;for(const a of e)if(a.nodeName.toLowerCase()==="table")o.push({index:((r=n==null?void 0:n.paragraphs)==null?void 0:r.length)||0});else if(a.nodeType===Node.TEXT_NODE){const c=(s=a.nodeValue)==null?void 0:s.replace(/[\r\n]/g,"");let d;t&&this.styleCache.has(t)&&(d=this.styleCache.get(t));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=t?this.styleCache.get(t):{},d=this.styleRules.find(({filter:S})=>No(a,S)),u=d?d.getStyle(a):ra(a);this.styleCache.set(a,{...c,...u});const{childNodes:h}=a;this.process(a,h,n,o);const m=this.afterProcessRules.find(({filter:S})=>No(a,S));m&&m.handler(n,a)}}dispose(){document.body.removeChild(this.htmlElement)}};I(oi,"pluginList",[]);let ft=oi;function la(i){const t=/<tr([\s\S]*?)>([\s\S]*?)<\/tr>/gi,e=i.matchAll(t);if(!e)return{rowProperties:[],rowCount:0,colCount:0,cellMatrix:null};const n=Array.from(e),o=n.map(a=>hi(a[1])),{colCount:r,cellMatrix:s}=ca(n.map(a=>a[2]));return{rowProperties:o,rowCount:o.length,colCount:r,cellMatrix:s}}function ca(i){const t=new l.ObjectMatrix,e=new Map,n=/<td([\s\S]*?)>([\s\S]*?)<\/td>/gi;let o=0,r=0,s=0;return i.forEach((a,c)=>{const d=c===0,u=a.matchAll(n);r=0,Array.from(u).forEach(h=>{const m=hi(h[1]),S=ua(h[2].replace("<br>","\r").replace(/<\/?[^>]*>/g,"")),g=m.rowspan?+m.rowspan:1,_=m.colspan?+m.colspan:1;if(!d){for(let M=r;M<o;M++)if(!(e.get(M)>=s)){r=M;break}}const v={content:S,properties:m};_>1&&(v.colSpan=+_),g>1&&(v.rowSpan=+g),d&&(o+=_);for(let M=r;M<r+_;M++)e.set(M,s+g-1);t.setValue(s,r,v),r+=_}),s+=1}),{colCount:o,cellMatrix:t}}function hi(i){if(!i)return{};const t={},e=/([\w-]+)\s*=\s*(?:(['"])([^'"]*)\2|(\S+))/g;let n;for(;(n=e.exec(i))!==null;){const[,o,,r,s]=n,a=r!==void 0?r:s;t[o]=a}return t}function da(i){const t=/<colgroup([\s\S]*?)>(.*?)<\/colgroup>/,e=i.match(t);if(!e||!e[2])return null;const n=/<col([\s\S]*?)>/g,o=e[2].matchAll(n);return o?Array.from(o).map(r=>hi(r[1])):null}function ua(i){const t={"<":"<",">":">","&":"&",""":'"',"'":"'"," ":" "};return i.replace(/<|>|&|"|'| |<br>/g,e=>t[e])}function ha(i,t,e,n){const o=e.map(c=>{var d;return(d=c.onCopyRow)==null?void 0:d.call(c,i)}).filter(c=>!!c),r=mi(o),s=Si(r),a=t.map(c=>ma(i,c,e,n)).filter(c=>!!c).join("");return`<tr${s}>${a}</tr>`}function ma(i,t,e,n){const o=n.getValue(i,t),r=e.map(d=>{var u;return(u=d.onCopyCellStyle)==null?void 0:u.call(d,i,t,o==null?void 0:o.rowSpan,o==null?void 0:o.colSpan)}).filter(d=>!!d),s=mi(r),a=Si(s),c=e.reduce((d,u)=>{var h;return d||((h=u.onCopyCellContent)==null?void 0:h.call(u,i,t))||""},"");return`<td${a}>${c}</td>`}function Sa(i,t){return`<colgroup>${i.map(n=>{const o=t.map(a=>{var c;return(c=a.onCopyColumn)==null?void 0:c.call(a,n)}).filter(a=>!!a),r=mi(o);return`<col ${Si(r)}>`}).join("")}</colgroup>`}function mi(i){return i.reduce((t,e)=>(Object.keys(e).forEach(o=>{t[o]?t[o]+=`;${e[o]}`:t[o]=e[o]}),t),{})}function Si(i){return Object.keys(i).reduce((t,e)=>(t+=` ${e}="${i[e]}"`,t),"")}function ga(i,t){const e=[];for(let n=i;n<=t;n++)e.push(n);return e}class _a{convert(t,e,n){const{startColumn:o,endColumn:r}=e,s=Sa(ga(o,r),n),a=[],{startRow:c,endRow:d,startColumn:u,endColumn:h}=t.getDataRange();for(let S=c;S<=d;S++){const g=Array.from({length:h-u+1},(_,v)=>u+v);a.push(ha(S,g,n,t))}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>`}}const fa=(i,t,e=!1)=>{const n=h=>h.endRow-h.startRow+1,o=h=>h.endColumn-h.startColumn+1,r=n(t)%n(i),s=o(t)%o(i),a={startRow:0,endRow:n(i)-1,startColumn:0,endColumn:o(i)-1},c=Math.floor(n(t)/n(i)),d=Math.floor(o(t)/o(i)),u=[];if(!r&&!s)for(let h=1;h<=c;h++)for(let m=1;m<=d;m++){const S=n(i)*(h-1),g=o(i)*(m-1),_={startRow:S+t.startRow,endRow:S+t.startRow,startColumn:g+t.startColumn,endColumn:g+t.startColumn};u.push({repeatRelativeRange:a,startRange:_})}else if(!r&&s&&!e)for(let h=1;h<=c;h++){const m=n(i)*(h-1),S=0,g={startRow:m+t.startRow,endRow:m+t.startRow,startColumn:S+t.startColumn,endColumn:S+t.startColumn};u.push({repeatRelativeRange:a,startRange:g})}else if(r&&!s&&!e)for(let h=1;h<=d;h++){const S=o(i)*(h-1),g={startRow:0+t.startRow,endRow:0+t.startRow,startColumn:S+t.startColumn,endColumn:S+t.startColumn};u.push({repeatRelativeRange:a,startRange:g})}else{const h={startRow:t.startRow,endRow:t.startRow,startColumn:t.startColumn,endColumn:t.startColumn};u.push({startRange:h,repeatRelativeRange:a})}return u};async function pa(i){return i?/<td[^>]*class=".*?xl.*?"[^>]*>.*?<\/td>/.test(i):!1}function va(...i){if(i.length===1)return i[0];const t=new l.ObjectMatrix;return i.forEach(e=>{e&&new l.ObjectMatrix(e).forValue((o,r,s)=>{t.setValue(o,r,{...t.getValue(o,r),...s})})}),t.getMatrix()}function Ca(i,t){return i.id===t.id&&i.params.unitId===t.params.unitId&&i.params.subUnitId===t.params.subUnitId}function gi(i){const t=[];for(let e=0;e<i.length;){let n=1;if(i[e].id===f.SetRangeValuesMutation.id){const o=i[e],r=[o];for(;e+n<i.length&&Ca(o,i[e+n]);)r.push(i[e+n]),n+=1;const s=va(...r.map(a=>a.params.cellValue||{}));t.push({...o,params:{...o.params,cellValue:s}})}else t.push(i[e]);e+=n}return t}var Ia=Object.defineProperty,Ma=Object.getOwnPropertyDescriptor,Ra=(i,t,e,n)=>{for(var o=n>1?void 0:n?Ma(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Ia(t,e,o),o},Ne=(i,t)=>(e,n)=>t(e,n,i);const ve={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"};ft.use(ri.PastePluginWord),ft.use(ri.PastePluginLark),ft.use(ri.PastePluginUniver);const pt=P.createIdentifier("sheet.clipboard-service");A.SheetClipboardService=class extends l.Disposable{constructor(e,n,o,r,s,a,c,d,u,h,m){super();I(this,"_clipboardHooks",[]);I(this,"_clipboardHooks$",new k.BehaviorSubject([]));I(this,"clipboardHooks$",this._clipboardHooks$.asObservable());I(this,"_htmlToUSM");I(this,"_usmToHtml");I(this,"_copyContentCache");I(this,"_copyMarkId",null);this._logService=e,this._currentUniverService=n,this._selectionManagerService=o,this._clipboardInterfaceService=r,this._undoRedoService=s,this._commandService=a,this._markSelectionService=c,this._sheetSkeletonManagerService=d,this._notificationService=u,this._platformService=h,this._localeService=m,this._htmlToUSM=new ft({getCurrentSkeleton:()=>this._sheetSkeletonManagerService.getCurrent()}),this._usmToHtml=new _a,this._copyContentCache=new na,this.disposeWithMe(this._htmlToUSM)}copyContentCache(){return this._copyContentCache}async copy(e=at.COPY){const n=this._selectionManagerService.getLast();if(!n)return!1;const o=this._currentUniverService.getCurrentUniverSheetInstance(),r=o.getActiveSheet(),s=this._clipboardHooks;s.forEach(S=>{var g;return(g=S.onBeforeCopy)==null?void 0:g.call(S,o.getUnitId(),r.getSheetId(),n.range)});const a=this._generateCopyContent(o.getUnitId(),r.getSheetId(),n.range,s);if(!a)return!1;const{html:c,plain:d,matrixFragment:u,copyId:h}=a;this._copyContentCache.set(h,{unitId:o.getUnitId(),subUnitId:r.getSheetId(),range:n.range,matrix:u,copyType:e}),await this._clipboardInterfaceService.write(d,c),this._markSelectionService.removeAllShapes();const m=this._selectionManagerService.createCopyPasteSelection();return this._copyMarkId=this._markSelectionService.addShape({...n,style:m}),s.forEach(S=>{var g;return(g=S.onAfterCopy)==null?void 0:g.call(S)}),!0}async cut(){return this.copy(at.CUT)}async paste(e,n=ve.DEFAULT_PASTE){const o=e.types,r=o.indexOf(C.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(C.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()):"",s=o.indexOf(C.HTML_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(C.HTML_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()):"";return s?this._platformService.isWindows&&await pa(s)?(this._notificationService.show({type:"warning",title:this._localeService.t("clipboard.shortCutNotify.title"),content:this._localeService.t("clipboard.shortCutNotify.useShortCutInstead")}),!1):this._pasteHTML(s,n):r?this._pastePlainText(r,n):(this._logService.error("[SheetClipboardService]","No valid data on clipboard"),!1)}legacyPaste(e,n){return e?this._pasteHTML(e,ve.DEFAULT_PASTE):n?this._pastePlainText(n,ve.DEFAULT_PASTE):Promise.resolve(!1)}addClipboardHook(e){if(this._clipboardHooks.findIndex(o=>o.id===e.id)!==-1)return this._logService.error("[SheetClipboardService]","hook already exists",e.id),{dispose:()=>{}};const n=this._clipboardHooks.findIndex(o=>{const r=o.priority||0;return(e.priority||0)<r});return this._clipboardHooks.splice(n!==-1?n:this._clipboardHooks.length,0,e),this._notifyClipboardHook(),l.toDisposable(()=>{const o=this._clipboardHooks.indexOf(e);o>-1&&(this._clipboardHooks.splice(o,1),this._notifyClipboardHook())})}getClipboardHooks(){return this._clipboardHooks}_generateCopyContent(e,n,o,r){const s=this._currentUniverService.getUniverSheetInstance(e),a=s==null?void 0:s.getSheetBySheetId(n);if(!s||!a)return null;r.reduce((M,R)=>{var E;const b=(E=R.getFilteredOutRows)==null?void 0:E.call(R);return b==null||b.forEach(T=>M.add(T)),M},new Set);const{startColumn:c,startRow:d,endColumn:u,endRow:h}=o,m=a.getMatrixWithMergedCells(d,c,h,u),S=new l.ObjectMatrix;for(let M=d;M<=h;M++)for(let R=c;R<=u;R++){const b=m.getValue(M,R);b?S.setValue(M-d,R-c,{...Do(),...l.Tools.deepClone(b)}):S.setValue(M-d,R-c,Do())}let g=this._usmToHtml.convert(m,o,r);const _=ba(S),v=ea();return g=g.replace(/(<[a-z]+)/,(M,R)=>`${R} data-copy-id="${v}"`),{copyId:v,plain:_,html:g,matrixFragment:S}}_notifyClipboardHook(){this._clipboardHooks$.next(this._clipboardHooks)}async _pastePlainText(e,n){const o=this._getPastingTarget();if(!o.selection)return!1;const r=o.selection.range,{unitId:s,subUnitId:a}=o,c=this._clipboardHooks,d=[];if(c.some(g=>{var _;return d.push(g)&&((_=g.onBeforePaste)==null?void 0:_.call(g,{unitId:s,subUnitId:a,range:r}))===!1}))return d.forEach(g=>{var _;return(_=g.onAfterPaste)==null?void 0:_.call(g,!1)}),!1;const h=[],m=[];d.forEach(g=>{var v;const _=(v=g.onPastePlainText)==null?void 0:v.call(g,{unitId:s,subUnitId:a,range:r},e,{pasteType:n});_&&(h.push(..._.redos),m.push(..._.undos))});const S=h.every(g=>this._commandService.executeCommand(g.id,g.params));return S&&this._undoRedoService.pushUndoRedo({unitID:this._currentUniverService.getCurrentUniverSheetInstance().getUnitId(),undoMutations:m,redoMutations:h}),S}async _pasteHTML(e,n){const o=ta(e);return o&&this._copyContentCache.get(o)?this._pasteInternal(o,n):this._pasteExternal(e,n)}async _pasteExternal(e,n){const o=this._getPastingTarget(),{selection:r,unitId:s,subUnitId:a}=o;if(!r)return!1;const{rowProperties:c,colProperties:d,cellMatrix:u}=this._htmlToUSM.convert(e),{startColumn:h,endColumn:m,startRow:S,endRow:g}=u.getDataRange(),_=g-S+1,v=m-h+1;if(!u||m<h||g<S)return!1;const M=this._transformPastedData(_,v,u,r.range);return M?this._pasteUSM({rowProperties:c,colProperties:d,cellMatrix:u},{unitId:s,subUnitId:a,pastedRange:M},n):!1}async _pasteInternal(e,n){var D,H;const o=this._getPastingTarget(),{selection:r,unitId:s,subUnitId:a}=o,c=l.Tools.deepClone(this._copyContentCache.get(e)),{range:d,matrix:u,unitId:h,subUnitId:m}=c||{};if(!r||!u||!c||!d||!h||!m||!r||!u||!c)return!1;const S=(D=this._currentUniverService.getUniverSheetInstance(h))==null?void 0:D.getStyles();u.forValue((B,j,X)=>{if(typeof X.s=="string"){const z=l.Tools.deepClone(X);z.s=S==null?void 0:S.getStyleByCell(X),u.setValue(B,j,z)}});const{startColumn:g,endColumn:_,startRow:v,endRow:M}=d,R=this._transformPastedData(M-v+1,_-g+1,u,r.range);if(!R)return!1;const b=(H=this._currentUniverService.getUniverSheetInstance(h))==null?void 0:H.getSheetBySheetId(m);if(!b)return!1;const E=b.getColumnManager(),T=b.getRowManager(),y=b.getConfig().defaultColumnWidth,O=b.getConfig().defaultRowHeight,x=[],N=[];for(let B=g;B<=_;B++){const j=E.getColumnOrCreate(B);x.push({width:`${j.w||y}`})}for(let B=v;B<=M;B++){const j=T.getRowOrCreate(B);N.push({height:`${j.h||O}`})}const V=this._pasteUSM({cellMatrix:u,colProperties:x,rowProperties:N},{unitId:s,subUnitId:a,pastedRange:R},n,{range:d,unitId:c.unitId,subUnitId:c.subUnitId,copyType:c.copyType,copyId:e});return c.copyType===at.CUT&&(this._copyContentCache.set(e,{...c,matrix:null}),this._copyMarkId&&this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null),V}_pasteUSM(e,n,o,r){const{rowProperties:s,colProperties:a,cellMatrix:c}=e,{unitId:d,subUnitId:u,pastedRange:h}=n,{startColumn:m,endColumn:S}=h,g=S-m+1,_=this._clipboardHooks,v=[];if(_.some(N=>{var V;return v.push(N)&&((V=N.onBeforePaste)==null?void 0:V.call(N,{unitId:d,subUnitId:u,range:h}))===!1}))return v.forEach(N=>{var V;return(V=N.onAfterPaste)==null?void 0:V.call(N,!1)}),!1;if(!c)return!1;const R=r?{unitId:r.unitId,subUnitId:r.subUnitId,range:r.range}:null,b={copyType:(r==null?void 0:r.copyType)||at.COPY,copyId:r==null?void 0:r.copyId,pasteType:o};let E=[],T=[];v.filter(N=>!N.specialPasteInfo&&N.id!==ve.DEFAULT_PASTE||o===N.id).forEach(N=>{var H,B,j;if(s){const X=(H=N.onPasteRows)==null?void 0:H.call(N,{range:h,unitId:d,subUnitId:u},s,{pasteType:o});X&&(E.push(...X.redos),T.push(...X.undos))}const V=(B=N.onPasteColumns)==null?void 0:B.call(N,{range:h,unitId:d,subUnitId:u},a||new Array(g).map(()=>({})),{pasteType:o});V&&(E.push(...V.redos),T.push(...V.undos));const D=(j=N.onPasteCells)==null?void 0:j.call(N,R,{range:h,unitId:d,subUnitId:u},c,b);D&&(E.push(...D.redos),T.push(...D.undos))});const O=this._getSetSelectionOperation(d,u,h,c);O&&E.push(O),E=gi(E),T=gi(T),this._logService.log("[SheetClipboardService]","pasting mutations",{undoMutationsInfo:T,redoMutationsInfo:E});const x=E.every(N=>this._commandService.executeCommand(N.id,N.params));return x&&this._undoRedoService.pushUndoRedo({unitID:d,undoMutations:T,redoMutations:E}),x}_getSetSelectionOperation(e,n,o,r){var _;const s=(_=this._currentUniverService.getUniverSheetInstance(e))==null?void 0:_.getSheetBySheetId(n);if(!s)return null;const{startRow:a,startColumn:c}=o,d={startRow:a,endRow:a,startColumn:c,endColumn:c},u=f.getPrimaryForRange(d,s),h=r.getValue(0,0),m=(h==null?void 0:h.rowSpan)||1,S=(h==null?void 0:h.colSpan)||1;if(m>1||S>1){const v={startRow:a,endRow:a+m-1,startColumn:c,endColumn:c+S-1};u.startRow=v.startRow,u.endRow=v.endRow,u.startColumn=v.startColumn,u.endColumn=v.endColumn,u.isMerged=!0,u.isMergedMainCell=!0}const g={unitId:e,subUnitId:n,pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:o,primary:u,style:null}]};return{id:f.SetSelectionsOperation.id,params:g}}_getPastingTarget(){const e=this._currentUniverService.getCurrentUniverSheetInstance(),n=e.getActiveSheet(),o=this._selectionManagerService.getLast();return{unitId:e.getUnitId(),subUnitId:n.getSheetId(),selection:o}}_transformPastedData(e,n,o,r){const{startRow:s,startColumn:a,endRow:c,endColumn:d}=r,u=c-s+1,h=d-a+1,_=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData().filter(T=>l.Rectangle.intersects({startRow:s,startColumn:a,endRow:c,endColumn:d},T)),v=_[0];let M=0,R=0,b=0,E=0;if(v&&(M=v.startRow,R=v.startColumn,b=v.endRow,E=v.endColumn),u%e===0&&h%n===0)if(_.length>0&&(u!==e||h!==n))if(M===s&&R===a&&b===c&&E===d)if(Oa(o))for(let y=0;y<u;y++)for(let O=0;O<h;O++){const x=o.getValue(y%e,O%n);x&&o.setValue(y,O,x)}else o.forValue((y,O,x)=>{x.s=null,delete x.colSpan,delete x.rowSpan});else for(let T=0;T<u;T++)for(let y=0;y<h;y++){const O=o.getValue(T%e,y%n);O&&o.setValue(T,y,O)}else for(let T=0;T<u;T++)for(let y=0;y<h;y++){const O=o.getValue(T%e,y%n);O&&o.setValue(T,y,O)}else if(_.length>0)if(this._topLeftCellsMatch(e,n,r))r.endRow=s+e-1,r.endColumn=a+n-1;else{if(c>v.endRow||d>v.endColumn)return null;o.forValue((y,O,x)=>{x.s=null,delete x.colSpan,delete x.rowSpan})}else r.endRow=s+e-1,r.endColumn=a+n-1;return r}_topLeftCellsMatch(e,n,o){const s=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet(),{startRow:a,startColumn:c,endRow:d,endColumn:u}=o,h=Ea(a+e-1,c,c+e-1,s),m=ya(c+n-1,a,a+e-1,s);return!h&&!m}},A.SheetClipboardService=Ra([Ne(0,l.ILogService),Ne(1,l.IUniverInstanceService),Ne(2,P.Inject(f.SelectionManagerService)),Ne(3,C.IClipboardInterfaceService),Ne(4,l.IUndoRedoService),Ne(5,l.ICommandService),Ne(6,Ut),Ne(7,P.Inject(A.SheetSkeletonManagerService)),Ne(8,C.INotificationService),Ne(9,C.IPlatformService),Ne(10,P.Inject(l.LocaleService))],A.SheetClipboardService);function ba(i){let t="";return i.forRow((e,n)=>{const o=[];n.forEach(r=>{const s=i.getValue(e,r);if(s){const a=wa(s);o.push(a)}}),t+=o.join(" "),e!==i.getLength()-1&&(t+=`
|
|
9
|
+
`)}),t}function wa(i){const t=l.extractPureTextFromCell(i);return Ta((t==null?void 0:t.toString())||"")}const Ta=i=>i.replace(/&/g,"&").replace(/\uFEFF/g,"").replace(/</g,"<").replace(/>/g,">");function Ea(i,t,e,n){return n.getMergeData().some(o=>o.startRow<=i&&i<o.endRow&&t<=o.startColumn&&o.startColumn<=e)}function ya(i,t,e,n){return n.getMergeData().some(o=>o.startColumn<=i&&i<o.endColumn&&t<=o.startRow&&o.startRow<=e)}function Oa(i){let t=0;return i.forValue((e,n,o)=>{if(o&&t++,t>1)return!1}),t>1}function Do(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const _i=998,Po={id:C.CopyCommand.id,name:"sheet.command.copy",type:l.CommandType.COMMAND,multi:!0,priority:_i,preconditions:li,handler:async i=>i.get(pt).copy()},Aa={id:C.CutCommand.id,name:"sheet.command.cut",type:l.CommandType.COMMAND,multi:!0,priority:_i,preconditions:li,handler:async i=>i.get(pt).cut()},vt={id:C.PasteCommand.id,type:l.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:_i,preconditions:li,handler:async(i,t)=>{const n=await i.get(C.IClipboardInterfaceService).read(),o=i.get(pt);return n.length!==0?o.paste(n[0],t==null?void 0:t.value):!1}},Lo={id:"sheet.command.paste-value",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(vt.id,{value:ve.SPECIAL_PASTE_VALUE})},Uo={id:"sheet.command.paste-format",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(vt.id,{value:ve.SPECIAL_PASTE_FORMAT})},Ho={id:"sheet.command.paste-col-width",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(vt.id,{value:ve.SPECIAL_PASTE_COL_WIDTH})},Vo={id:"sheet.command.paste-besides-border",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(vt.id,{value:ve.SPECIAL_PASTE_BESIDES_BORDER})};var xa=Object.defineProperty,Na=Object.getOwnPropertyDescriptor,Da=(i,t,e,n)=>{for(var o=n>1?void 0:n?Na(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&xa(t,e,o),o},ko=(i,t)=>(e,n)=>t(e,n,i);let Ht=class{constructor(i,t){I(this,"_current",null);I(this,"_shortcutParam",[]);this._currentUniverService=i,this._localeService=t}dispose(){this._shortcutParam=[]}getCurrentBySearch(i){return this._getCurrentBySearch(i)}getCurrent(){return this._getCurrentBySearch(this._current)}addOrUpdate(i){const t=this._getCurrentBySearch({unitId:i.unitId,sheetId:i.sheetId,keycode:i.keycode});if(t!=null){const e=this._shortcutParam.indexOf(t);this._shortcutParam.splice(e,1)}return this._shortcutParam.push(i),t}remove(i){if(i==null)return;const t=this._getCurrentBySearch(i);if(t==null)return;const e=this._shortcutParam.indexOf(t);return this._shortcutParam.splice(e,1)[0]}_getCurrentBySearch(i){return i==null?void 0:this._shortcutParam.find(e=>e.unitId===i.unitId&&e.sheetId===i.sheetId&&e.keycode===i.keycode)}};Ht=Da([ko(0,l.IUniverInstanceService),ko(1,P.Inject(l.LocaleService))],Ht);var vn=(i=>(i.MergeAll="mergeAll",i.MergeVertical="mergeVertical",i.MergeHorizontal="mergeHorizontal",i))(vn||{});function tt(i,t,e,n,o=!0,r=1,s=!0){let a={...i};n==null&&(n={startRow:0,endRow:e.getRowCount()-1,startColumn:0,endColumn:e.getColumnCount()-1});let c;switch(t){case l.Direction.UP:for(c=i.startRow-r;c>-1&&!e.getRowVisible(c);)c-=1;c>=n.startRow?(a.startRow=c,a.endRow=c):s&&(a.startRow=n.endRow,a.endRow=n.endRow,o&&(a=tt(a,l.Direction.LEFT,e,n,!1)));break;case l.Direction.DOWN:for(c=i.endRow+r;c<e.getRowCount()&&!e.getRowVisible(c);)c+=1;c<=n.endRow?(a.startRow=c,a.endRow=c):s&&(a.startRow=n.startRow,a.endRow=n.startRow,o&&(a=tt(a,l.Direction.RIGHT,e,n,!1)));break;case l.Direction.LEFT:for(c=i.startColumn-r;c>-1&&!e.getColVisible(c);)c-=1;c>=n.startColumn?(a.startColumn=c,a.endColumn=c):s&&(a.startColumn=n.endColumn,a.endColumn=n.endColumn,o&&(a=tt(a,l.Direction.UP,e,n,!1)));break;case l.Direction.RIGHT:for(c=i.endColumn+r;c<e.getColumnCount()&&!e.getColVisible(c);)c+=1;c<=n.endColumn?(a.startColumn=c,a.endColumn=c):s&&(a.startColumn=n.startColumn,a.endColumn=n.startColumn,o&&(a=tt(a,l.Direction.DOWN,e,n,!1)));break}return a}function fi(i,t,e){const n={...i},{startRow:o,startColumn:r,endRow:s,endColumn:a}=Vt(i,t,e);let c=kt(e,o,r,s,a).hasValue,d=!0,u=!0;for(;u;){if(l.Direction.UP===t){let h=n.startRow-1;for(;h>-1&&!e.getRowVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:S}=kt(e,h,n.startColumn,h,n.endColumn);if(c&&!m&&!d){u=!1;break}else{if(S.getLength()!==0){let g=h;S.forValue(_=>{g=Math.min(_,g)}),n.startRow=g}else n.startRow=h;if(n.endRow=n.startRow,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.DOWN===t){let h=n.endRow+1;for(;h<e.getRowCount()&&!e.getRowVisible(h);)h+=1;if(h===e.getRowCount()){u=!1;break}const{hasValue:m,matrix:S}=kt(e,h,n.startColumn,h,n.endColumn);if(c&&!m&&!d){u=!1;break}else{if(S.getLength()!==0){let g=h;S.forValue((_,v,M)=>{g=Math.max(_+(M.rowSpan||1)-1,g)}),n.endRow=g}else n.endRow=h;if(n.startRow=n.endRow,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.LEFT===t){let h=n.startColumn-1;for(;h>-1&&!e.getColVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:S}=kt(e,n.startRow,h,n.endRow,h);if(c&&!m&&!d){u=!1;break}else{if(S.getLength()!==0){let g=h;S.forValue((_,v)=>{g=Math.min(v,g)}),n.startColumn=g}else n.startColumn=h;if(n.endColumn=n.startColumn,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.RIGHT===t){let h=n.endColumn+1;for(;h<e.getColumnCount()&&!e.getColVisible(h);)h+=1;if(h===e.getColumnCount()){u=!1;break}const{hasValue:m,matrix:S}=kt(e,n.startRow,h,n.endRow,h);if(c&&!m&&!d){u=!1;break}else{if(S.getLength()!==0){let g=h;S.forValue((_,v,M)=>{g=Math.max(v+(M.colSpan||1)-1,g)}),n.endColumn=g}else n.endColumn=h;if(n.startColumn=n.endColumn,!c&&m){u=!1;break}c=m,d=!1}}}return f.alignToMergedCellsBorders(n,e,!0)}function Bo(i,t,e){return tt(i,t,e,void 0,!1,1,!1)}function Pa(i,t,e){const n=fi(i,t,e);return f.alignToMergedCellsBorders(l.Rectangle.union(n,i),e,!0)}function La(i,t,e){const n=Bo(i,t,e),o={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 f.alignToMergedCellsBorders(l.Rectangle.union(i,o),e)}function Ua(i,t,e,n){const o=l.getReverseDirection(e),r=fi(Vt(i,o,n),e,n);return e===l.Direction.UP&&r.startRow<=i.startRow?f.alignToMergedCellsBorders({...t,startColumn:i.startColumn,endColumn:i.endColumn},n,!0):e===l.Direction.DOWN&&r.endRow>=i.endRow?f.alignToMergedCellsBorders({...t,startColumn:i.startColumn,endColumn:i.endColumn},n,!0):e===l.Direction.LEFT&&r.startColumn<=i.startColumn?f.alignToMergedCellsBorders({...t,startRow:i.startRow,endRow:i.endRow},n,!0):e===l.Direction.RIGHT&&r.endColumn>=i.endColumn?f.alignToMergedCellsBorders({...t,startRow:i.startRow,endRow:i.endRow},n,!0):l.Rectangle.union(l.Rectangle.clone(t),r)}function Ha(i,t,e){const n=l.getReverseDirection(t),o=Vt(i,n,e),r=Vt(i,t,e),s=Bo(o,t,e);return f.alignToMergedCellsBorders(l.Rectangle.union(r,s),e,!1)}function Va(i,t,e){const{left:n,right:o,up:r,down:s}=t,a=e.getMaxRows(),c=e.getMaxColumns();let d=!0;const u={...i};for(;d;){if(d=!1,r&&u.startRow!==0){const h=u.startRow-1;e.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((S,g,_)=>{_.v&&(u.startRow=Math.min(S,u.startRow),u.startColumn=Math.min(g,u.startColumn),u.endColumn=Math.max(g,u.endColumn),d=!0)})}if(s&&u.endRow!==a-1){const h=u.endRow+1;e.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((S,g,_)=>{_.v&&(u.endRow=Math.max(S+(_.rowSpan!==void 0?_.rowSpan-1:0),u.endRow),u.startColumn=Math.min(g,u.startColumn),u.endColumn=Math.max(g,u.endColumn),d=!0)})}if(n&&u.startColumn!==0){const h=u.startColumn-1;e.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((S,g,_)=>{_.v&&(u.startColumn=Math.min(g,u.startColumn),u.startRow=Math.min(S,u.startRow),u.endRow=Math.max(S,u.endRow),d=!0)})}if(o&&u.endColumn!==c-1){const h=u.endColumn+1;e.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((S,g,_)=>{_.v&&(u.endColumn=Math.max(g+(_.colSpan!==void 0?_.colSpan-1:0),u.endColumn),u.startRow=Math.min(S,u.startRow),u.endRow=Math.max(S,u.endRow),d=!0)})}}return u}function Fo(i){return{startRow:0,startColumn:0,endRow:i.getRowCount()-1,endColumn:i.getColumnCount()-1,rangeType:l.RANGE_TYPE.ALL}}function Vt(i,t,e){let n;switch(t){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 f.alignToMergedCellsBorders(n,e,!1)}function kt(i,t,e,n,o){let r=!1;const s=i.getMatrixWithMergedCells(t,e,n,o).forValue((a,c,d)=>{if(d.v)return r=!0,!1});return{hasValue:r,matrix:s}}function pi(i,t,e){const n=l.Rectangle.clone(i);if(t==null)return n;switch(e){case l.Direction.UP:case l.Direction.DOWN:n.startColumn=n.endColumn=t.actualColumn;break;case l.Direction.LEFT:case l.Direction.RIGHT:n.startRow=n.endRow=t.actualRow;break}return n}function ka(i,t,e){const{primary:n,range:o}=i,r=l.Rectangle.clone(o);switch(t){case l.Direction.UP:case l.Direction.DOWN:r.startRow=n.startRow,r.endRow=n.endRow;break;case l.Direction.LEFT:case l.Direction.RIGHT:r.startColumn=n.startColumn,r.endColumn=n.endColumn;break}const s=Vt(r,t,e);switch(t){case l.Direction.DOWN:return o.startRow<s.startRow;case l.Direction.UP:return o.endRow>s.endRow;case l.Direction.LEFT:return s.endColumn<o.endColumn;case l.Direction.RIGHT:return s.startColumn>o.startColumn}}function Wo(i,t){let e=i[0].startRow,n=i[0].endRow;i.forEach(r=>{const{startRow:s,endRow:a}=r;e=Math.min(e,s),n=Math.max(n,a)});const o=new Array(n-e+1).fill(!1);return t.forEach(r=>{const{startRow:s,endRow:a}=r;for(let c=Math.max(s,e);c<=Math.min(a,n);c++)o[c-e]=!0}),i.every(r=>{const{startRow:s,endRow:a}=r;for(let c=s;c<=a;c++)if(!o[c-e])return!1;return!0})}function jo(i,t){let e=i[0].startColumn,n=i[0].endColumn;i.forEach(r=>{const{startColumn:s,endColumn:a}=r;e=Math.min(e,s),n=Math.max(n,a)});const o=new Array(n-e+1).fill(!1);return t.forEach(r=>{const{startColumn:s,endColumn:a}=r;for(let c=Math.max(s,e);c<=Math.min(a,n);c++)o[c-e]=!0}),i.every(r=>{const{startColumn:s,endColumn:a}=r;for(let c=s;c<=a;c++)if(!o[c-e])return!1;return!0})}function vi(i,t){return t?i==="mergeAll"?t.filter(e=>!(e.startRow===e.endRow&&e.startColumn===e.endColumn)):i==="mergeVertical"?t.filter(e=>e.startRow!==e.endRow):i==="mergeHorizontal"?t.filter(e=>e.startColumn!==e.endColumn):t:null}var ke=(i=>(i[i.moveStopeOne=0]="moveStopeOne",i[i.moveGap=1]="moveGap",i[i.moveStepPage=2]="moveStepPage",i[i.moveStepEnd=3]="moveStepEnd",i))(ke||{});const be={id:"sheet.command.move-selection",type:l.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const e=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=e.getActiveSheet(),o=i.get(f.SelectionManagerService).getLast();if(!o)return!1;const{direction:r,jumpOver:s}=t,{range:a,primary:c}=o,d=pi(a,c,r),u=s===1?fi(d,r,n):tt(d,r,n),h=f.getCellAtRowCol(u.startRow,u.startColumn,n);return l.Rectangle.equals(h,d)?!1:(i.get(Ht).remove({unitId:e.getUnitId(),sheetId:n.getSheetId(),keycode:C.KeyCode.TAB}),i.get(l.ICommandService).executeCommand(f.SetSelectionsOperation.id,{unitId:e.getUnitId(),subUnitId:n.getSheetId(),pluginName:f.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,t)=>{if(!t)return!1;const e=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=e.getActiveSheet(),o=i.get(f.SelectionManagerService).getLast(),r=e.getUnitId(),s=n.getSheetId();if(!o)return!1;const{direction:a,keycode:c}=t,{range:d,primary:u}=o;let h=pi(d,u,a);const m=i.get(Ht),S=m.getCurrentBySearch({unitId:r,sheetId:s,keycode:C.KeyCode.TAB});let g;const{startRow:_,endRow:v,startColumn:M,endColumn:R}=d;if(l.Rectangle.equals(d,u)){if(c===C.KeyCode.TAB)S==null&&m.addOrUpdate({unitId:r,sheetId:s,keycode:C.KeyCode.TAB,selection:o});else{const T=S==null?void 0:S.selection;if(T!=null){const{range:y,primary:O}=T;h=pi(y,O,a)}m.remove({unitId:r,sheetId:s,keycode:C.KeyCode.TAB})}const b=tt(h,a,n),E=f.getCellAtRowCol(b.startRow,b.startColumn,n);if(l.Rectangle.equals(E,h))return!1;g={range:l.Rectangle.clone(E),primary:{startRow:E.startRow,startColumn:E.startColumn,endRow:E.endRow,endColumn:E.endColumn,actualRow:b.startRow,actualColumn:b.startColumn,isMerged:E.isMerged,isMergedMainCell:E.startRow===b.startRow&&E.startColumn===b.startColumn}}}else{m.remove({unitId:r,sheetId:s,keycode:C.KeyCode.TAB});const b=l.Tools.deepClone(u),E=tt({startRow:b.startRow,startColumn:b.startColumn,endRow:b.endRow,endColumn:b.endColumn},a,n,{startRow:_,endRow:v,startColumn:M,endColumn:R}),T=f.getCellAtRowCol(E.startRow,E.startColumn,n);g={range:l.Rectangle.clone(d),primary:{startRow:T.startRow,startColumn:T.startColumn,endRow:T.endRow,endColumn:T.endColumn,actualRow:E.startRow,actualColumn:E.startColumn,isMerged:T.isMerged,isMergedMainCell:T.startRow===E.startRow&&T.startColumn===E.startColumn}}}return i.get(l.ICommandService).executeCommand(f.SetSelectionsOperation.id,{unitId:r,subUnitId:s,pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[g]})}},De={id:"sheet.command.expand-selection",type:l.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const e=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=e.getActiveSheet(),o=i.get(f.SelectionManagerService).getLast();if(!o)return!1;const{range:r,primary:s}=o,{jumpOver:a,direction:c}=t,u=ka(o,c,n)?a===1?Ua(r,{...l.Rectangle.clone(s),rangeType:l.RANGE_TYPE.NORMAL},c,n):Ha(r,c,n):a===1?Pa(r,c,n):La(r,c,n);return l.Rectangle.equals(u,r)?!1:i.get(l.ICommandService).executeCommand(f.SetSelectionsOperation.id,{unitId:e.getUnitId(),subUnitId:n.getSheetId(),pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:u,primary:s}]})}};let Be=[],Ci="";const zo={id:"sheet.command.select-all",type:l.CommandType.COMMAND,onDispose(){Be=[],Ci=""},handler:async(i,t={expandToGapFirst:!0,loop:!1})=>{const e=i.get(f.SelectionManagerService).getLast(),n=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),o=n.getActiveSheet();if(!e||!o)return!1;const r=`${n.getUnitId()}|${o.getSheetId()}`;r!==Ci&&(Be=[],Ci=r);const s=o.getMaxRows(),a=o.getMaxColumns(),{expandToGapFirst:c,loop:d}=t,{range:u,primary:h}=e,m=u.endColumn===a-1&&u.endRow===s-1&&u.startRow===0&&u.startColumn===0;Be.some(g=>l.Rectangle.equals(g,u))||(Be=[],Be.push(u));let S;if(m)if(d){if(Be.findIndex(_=>l.Rectangle.equals(_,u))!==Be.length-1)return!1;S=Be[0]}else return!1;else c?(S=Va(u,{left:!0,right:!0,up:!0,down:!0},o),l.Rectangle.equals(S,u)&&(S=Fo(o))):S=Fo(o);return Be.some(g=>l.Rectangle.equals(g,S))||Be.push(S),i.get(l.ICommandService).executeCommand(f.SetSelectionsOperation.id,{unitId:n.getUnitId(),subUnitId:o.getSheetId(),pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:S,primary:h}]})}};var Ba=Object.defineProperty,Fa=Object.getOwnPropertyDescriptor,Wa=(i,t,e,n)=>{for(var o=n>1?void 0:n?Fa(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Ba(t,e,o),o},Bt=(i,t)=>(e,n)=>t(e,n,i);const ja=l.createInterceptorKey("BEFORE_CELL_EDIT"),za=l.createInterceptorKey("AFTER_CELL_EDIT"),Ya=l.createInterceptorKey("AFTER_CELL_EDIT_ASYNC");A.EditorBridgeService=class extends l.Disposable{constructor(e,n,o,r,s){super();I(this,"_editorUnitId",l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);I(this,"_isForceKeepVisible",!1);I(this,"_editorIsDirty",!1);I(this,"_visible",{visible:!1,eventType:w.DeviceInputEventType.Dblclick});I(this,"_currentEditCell",null);I(this,"_currentEditCellState",null);I(this,"_currentEditCellState$",new k.BehaviorSubject(null));I(this,"currentEditCellState$",this._currentEditCellState$.asObservable());I(this,"_visible$",new k.BehaviorSubject(this._visible));I(this,"visible$",this._visible$.asObservable());I(this,"_afterVisible$",new k.BehaviorSubject(this._visible));I(this,"afterVisible$",this._afterVisible$.asObservable());I(this,"interceptor",new l.InterceptorManager({BEFORE_CELL_EDIT:ja,AFTER_CELL_EDIT:za,AFTER_CELL_EDIT_ASYNC:Ya}));this._sheetSkeletonManagerService=e,this._selectionRenderService=n,this._themeService=o,this._currentUniverService=r,this._editorService=s,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:a=>a}))),this.disposeWithMe(l.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{priority:-1,handler:a=>a}))),this.disposeWithMe(l.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().AFTER_CELL_EDIT_ASYNC,{priority:-1,handler:a=>a})))}refreshEditCellState(){const e=this.getLatestEditCellState();this._currentEditCellState=e,this._currentEditCellState$.next(e)}setEditCell(e){this._currentEditCell=e;const n=this.getLatestEditCellState();this._currentEditCellState=n,this._currentEditCellState$.next(n)}getEditCellState(){return this._currentEditCellState}getLatestEditCellState(){var D,H;const e=this._currentEditCell;if(e==null)return;const n=this._sheetSkeletonManagerService.getCurrent();if(n==null)return;const{skeleton:o}=n,{primary:r,unitId:s,sheetId:a,scene:c,engine:d}=e,{startRow:u,startColumn:h}=r,m=this._selectionRenderService.convertCellRangeToInfo(r);if(m==null)return;const S=l.makeCellToSelection(m);if(S==null)return;const g=w.getCanvasOffsetByEngine(d);let{startX:_,startY:v,endX:M,endY:R}=S;const{scaleX:b,scaleY:E}=c.getAncestorScale();c.getPrecisionScale();const T=c.getScrollXY(this._selectionRenderService.getViewPort());_=o.convertTransformToOffsetX(_,b,T),v=o.convertTransformToOffsetY(v,E,T),M=o.convertTransformToOffsetX(M,b,T),R=o.convertTransformToOffsetY(R,E,T);const y=this._currentUniverService.getCurrentUniverSheetInstance(),O=y.getActiveSheet(),x={workbook:y,worksheet:O,unitId:y.getUnitId(),subUnitId:O.getSheetId(),row:u,col:h},N=this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT)(O.getCell(u,h),x);let V=N&&o.getCellDocumentModelWithFormula(N);if(!V||V.documentModel==null){const B=o.getBlankCellDocumentModel(N);if(V!=null){const{verticalAlign:j,horizontalAlign:X,wrapStrategy:z,textRotation:$,fill:ee}=V,{centerAngle:ne,vertexAngle:U}=w.convertTextRotation($);B.documentModel.documentStyle.renderConfig={verticalAlign:j,horizontalAlign:X,wrapStrategy:z,background:{rgb:ee},centerAngle:ne,vertexAngle:U}}V=B}if((D=V.documentModel)==null||D.setZoomRatio(Math.max(b,E)),(N==null?void 0:N.isInArrayFormulaRange)===!0){const B=(H=V.documentModel)==null?void 0:H.getBody();B&&(B.textRuns=[{st:0,ed:B.dataStream.length-2,ts:{cl:{rgb:this._themeService.getCurrentTheme().textColorSecondary}}}])}return this._editorService.setOperationSheetUnitId(s),this._editorService.setOperationSheetSubUnitId(a),{position:{startX:_,startY:v,endX:M,endY:R},scaleX:b,scaleY:E,canvasOffset:g,row:u,column:h,unitId:s,sheetId:a,documentLayoutObject:V,editorUnitId:this._editorUnitId,isInArrayFormulaRange:N==null?void 0:N.isInArrayFormulaRange}}getCurrentEditorId(){return this._editorUnitId}changeVisible(e){this._visible=e,e.visible&&(this._editorIsDirty=!1),this._visible$.next(this._visible),this._afterVisible$.next(this._visible)}isVisible(){return this._visible}enableForceKeepVisible(){this._isForceKeepVisible=!0}disableForceKeepVisible(){this._isForceKeepVisible=!1}isForceKeepVisible(){return this._isForceKeepVisible}changeEditorDirty(e){this._editorIsDirty=e}getEditorDirty(){return this._editorIsDirty}},A.EditorBridgeService=Wa([Bt(0,P.Inject(A.SheetSkeletonManagerService)),Bt(1,fe),Bt(2,P.Inject(l.ThemeService)),Bt(3,l.IUniverInstanceService),Bt(4,C.IEditorService)],A.EditorBridgeService);const we=P.createIdentifier("univer.sheet-editor-bridge.service"),Te={id:"sheet.operation.set-cell-edit-visible",type:l.CommandType.OPERATION,handler:(i,t)=>{const e=i.get(we);return t==null?!1:(e.changeVisible(t),!0)}},Ii={id:"sheet.operation.set-cell-edit-visible-f2",type:l.CommandType.OPERATION,handler:(i,t)=>(i.get(l.ICommandService).syncExecuteCommand(Te.id,t),!0)},Ft={id:"sheet.operation.set-cell-edit-visible-arrow",type:l.CommandType.OPERATION,handler:()=>!0};class Xe{constructor(){I(this,"_scrollInfo",new Map);I(this,"_scrollInfo$",new k.BehaviorSubject(null));I(this,"scrollInfo$",this._scrollInfo$.asObservable());I(this,"_currentScroll",null)}dispose(){this._scrollInfo$.complete()}setCurrentScroll(t){this._currentScroll=t,this._refresh(t)}getScrollByParam(t){return this._getCurrentScroll(t)}getCurrentScroll(){return this._getCurrentScroll(this._currentScroll)}addOrReplace(t){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...t})}addOrReplaceNoRefresh(t){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...t},!1)}addOrReplaceByParam(t){this._addByParam(t)}clear(){this._currentScroll!=null&&this._clearByParam(this._currentScroll)}_addByParam(t,e=!0){const{unitId:n,sheetId:o,sheetViewStartColumn:r,sheetViewStartRow:s,offsetX:a,offsetY:c}=t;this._scrollInfo.has(n)||this._scrollInfo.set(n,new Map),this._scrollInfo.get(n).set(o,{sheetViewStartRow:s,sheetViewStartColumn:r,offsetX:a,offsetY:c}),e===!0&&this._refresh({unitId:n,sheetId:o})}_clearByParam(t){this._addByParam({...t,sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),this._refresh(t)}_getCurrentScroll(t){var o;if(t==null)return;const{unitId:e,sheetId:n}=t;return(o=this._scrollInfo.get(e))==null?void 0:o.get(n)}_refresh(t){this._scrollInfo$.next(this._getCurrentScroll(t))}}const nt={id:"sheet.operation.set-scroll",type:l.CommandType.OPERATION,handler:(i,t)=>{if(t==null)return!1;const e=i.get(Xe),r=i.get(l.IUniverInstanceService).getUniverSheetInstance(t.unitId).getSheetBySheetId(t.sheetId),{xSplit:s,ySplit:a}=r.getConfig().freeze;return e.addOrReplaceByParam({...t,sheetViewStartRow:t.sheetViewStartRow-a,sheetViewStartColumn:t.sheetViewStartColumn-s}),!0}},Wt={id:"sheet.command.set-scroll-relative",type:l.CommandType.COMMAND,handler:async(i,t={offsetX:0,offsetY:0})=>{const e=i.get(l.ICommandService),n=i.get(Xe),r=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),s=r.getActiveSheet(),{xSplit:a,ySplit:c}=s.getConfig().freeze,d=n.getCurrentScroll(),{offsetX:u=0,offsetY:h=0}=t||{},{sheetViewStartRow:m=0,sheetViewStartColumn:S=0,offsetX:g=0,offsetY:_=0}=d||{};return e.executeCommand(nt.id,{unitId:r.getUnitId(),sheetId:s.getSheetId(),sheetViewStartRow:m+c,sheetViewStartColumn:S+a,offsetX:g+u,offsetY:_+h})}},ct={id:"sheet.command.scroll-view",type:l.CommandType.COMMAND,handler:(i,t)=>{if(!t)return!1;const e=i.get(l.IUniverInstanceService),n=i.get(Xe),o=e.getCurrentUniverSheetInstance(),r=o.getActiveSheet(),s=n.getCurrentScroll();if(!r)return!1;const{sheetViewStartRow:a,sheetViewStartColumn:c,offsetX:d,offsetY:u}=t,{sheetViewStartColumn:h,sheetViewStartRow:m,offsetX:S,offsetY:g}=s||{},{xSplit:_,ySplit:v}=r.getConfig().freeze;return i.get(l.ICommandService).syncExecuteCommand(nt.id,{unitId:o.getUnitId(),sheetId:r.getSheetId(),sheetViewStartRow:a!=null?a:(m!=null?m:0)+v,sheetViewStartColumn:c!=null?c:(h!=null?h:0)+_,offsetX:d!=null?d:S,offsetY:u!=null?u:g})}},Yo={id:"sheet.command.scroll-to-cell",type:l.CommandType.COMMAND,handler:(i,t)=>i.get(A.ScrollController).scrollToRange(t.range)},Xa={id:"sheet.command.scroll-view-reset",type:l.CommandType.COMMAND,handler:async i=>{const e=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=e.getActiveSheet();return n?i.get(l.ICommandService).executeCommand(nt.id,{unitId:e.getUnitId(),sheetId:n.getSheetId(),sheetViewStartRow:0,sheetViewStartColumn:0}):!1}};function Ie(i,t){const n=i.getCurrentUniverSheetInstance().getUnitId(),o=t.getRenderById(n);if(o==null)return;const{components:r,mainComponent:s,scene:a,engine:c}=o,d=s,u=r.get(_e.ROW),h=r.get(_e.COLUMN),m=r.get(_e.LEFT_TOP);return{spreadsheet:d,spreadsheetRowHeader:u,spreadsheetColumnHeader:h,spreadsheetLeftTopPlaceholder:m,scene:a,engine:c}}function Mi(i,t,e,n){const{startX:o,startY:r,endX:s,endY:a}=n.getCellByIndex(i,t);return{startX:o,startY:r,endX:s,endY:a}}function Ct(i,t,e,n,o){const r=e.getRelativeCoord(w.Vector2.FromArray([i,t])),{x:s,y:a}=r,c=e.getScrollXYByRelativeCoords(r,o),{scaleX:d,scaleY:u}=e.getAncestorScale(),h=n.getCellPositionByOffset(s,a,d,u,c),{row:m,column:S}=h,g=n.getNoMergeCellPositionByIndex(m,S),{startX:_,startY:v,endX:M,endY:R}=g;return{startX:_,startY:v,endX:M,endY:R,row:m,column:S}}function Cn(i,t,e,n){const o=e.getRelativeCoord(w.Vector2.FromArray([i,t])),r=e.getViewport(F.VIEW_MAIN),s=e.getScrollXYByRelativeCoords(o,r),{scaleX:a,scaleY:c}=e.getAncestorScale(),{x:d,y:u}=s,h=i/a+d,m=t/c+u;return{x:h,y:m}}var $a=Object.defineProperty,Za=Object.getOwnPropertyDescriptor,Ga=(i,t,e,n)=>{for(var o=n>1?void 0:n?Za(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&$a(t,e,o),o},It=(i,t)=>(e,n)=>t(e,n,i);const Ka=[be.id,lt.id];A.ScrollController=class extends l.Disposable{constructor(t,e,n,o,r,s){super(),this._sheetSkeletonManagerService=t,this._currentUniverService=e,this._commandService=n,this._renderManagerService=o,this._selectionManagerService=r,this._scrollManagerService=s,this._init()}scrollToRange(t){const{startRow:e,startColumn:n}=t;return this._scrollToCell(e,n)}_init(){this._initCommandListener(),this._initScrollEventListener(),this._scrollSubscribeBinding(),this._initSkeletonListener()}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(Ka.includes(t.id))this._scrollToSelection();else if(t.id===f.ScrollToCellOperation.id){const e=t.params;this._scrollToSelectionByDirection(e)}else if(t.id===De.id){const e=t.params;this._scrollToSelectionForExpand(e)}}))}_scrollToSelectionForExpand(t){setTimeout(()=>{const e=this._selectionManagerService.getLast();if(e==null)return;const{startRow:n,startColumn:o,endRow:r,endColumn:s}=e.range,a=this._getViewportBounding();if(a==null)return;const{startRow:c,startColumn:d,endRow:u,endColumn:h}=a;let m=0,S=0;n>c?m=r:r<u?m=n:m=c,o>d?S=s:s<h?S=o:S=d,t.direction===l.Direction.DOWN?m=r:t.direction===l.Direction.UP?m=n:t.direction===l.Direction.RIGHT?S=s:t.direction===l.Direction.LEFT&&(S=o),this._scrollToCell(m,S)},0)}_getFreeze(){var e;const t=(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig();if(t!=null)return t.freeze}_initScrollEventListener(){var n;const t=(n=this._getSheetObject())==null?void 0:n.scene;if(t==null)return;const e=t.getViewport(F.VIEW_MAIN);this.disposeWithMe(l.toDisposable(e==null?void 0:e.onScrollAfterObserver.add(o=>{var S;const r=(S=this._sheetSkeletonManagerService.getCurrent())==null?void 0:S.skeleton;if(r==null||o.isTrigger===!1)return;const s=this._getSheetObject();if(r==null||s==null)return;const{actualScrollX:a=0,actualScrollY:c=0}=o,{row:d,column:u,rowOffset:h,columnOffset:m}=r.getDecomposedOffset(a,c);this._scrollManagerService.addOrReplaceNoRefresh({sheetViewStartRow:d,sheetViewStartColumn:u,offsetX:m,offsetY:h})}))),this.disposeWithMe(l.toDisposable(e==null?void 0:e.onScrollByBarObserver.add(o=>{var g;const r=(g=this._sheetSkeletonManagerService.getCurrent())==null?void 0:g.skeleton;if(r==null||o.isTrigger===!1)return;const s=this._getSheetObject();if(r==null||s==null)return;const{actualScrollX:a=0,actualScrollY:c=0}=o,d=this._getFreeze(),{row:u,column:h,rowOffset:m,columnOffset:S}=r.getDecomposedOffset(a,c);this._commandService.executeCommand(ct.id,{sheetViewStartRow:u+((d==null?void 0:d.ySplit)||0),sheetViewStartColumn:h+((d==null?void 0:d.xSplit)||0),offsetX:S,offsetY:m})})))}_scrollSubscribeBinding(){this.disposeWithMe(l.toDisposable(this._scrollManagerService.scrollInfo$.subscribe(t=>{var _;const e=(_=this._sheetSkeletonManagerService.getCurrent())==null?void 0:_.skeleton,n=this._getSheetObject();if(e==null||n==null)return;const o=n.scene;n.scene.getAncestorScale();const r=o.getViewport(F.VIEW_MAIN);if(r==null)return;if(t==null){r.scrollTo({x:0,y:0});return}const{sheetViewStartRow:s,sheetViewStartColumn:a,offsetX:c,offsetY:d}=t,{startX:u,startY:h}=e.getCellByIndexWithNoHeader(s,a),m=u+c,S=h+d,g=r.getBarScroll(m,S);r.scrollTo(g)})))}_initSkeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(t=>{if(t==null)return;const{unitId:e,sheetId:n}=t;this._renderManagerService.getRenderById(e)!=null&&(this._updateSceneSize(t),this._scrollManagerService.setCurrentScroll({unitId:e,sheetId:n}))})))}_updateSceneSize(t){var d;if(t==null)return;const{skeleton:e,unitId:n}=t,o=(d=this._renderManagerService.getRenderById(n))==null?void 0:d.scene;if(e==null||o==null)return;const{rowTotalHeight:r,columnTotalWidth:s,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:c}=e;o==null||o.transformByState({width:a+s,height:c+r})}_getSheetObject(){return Ie(this._currentUniverService,this._renderManagerService)}_scrollToSelectionByDirection(t){const e=this._getViewportBounding();if(e==null)return!1;const{startRow:n,startColumn:o,endRow:r,endColumn:s}=e;let a=0,c=0;const{startRow:d,startColumn:u,endRow:h,endColumn:m}=t;d>=n&&(a=h),h<=r&&(a=d),u>=o&&(c=m),m<=s&&(c=u),this._scrollToCell(a,c)}_scrollToSelection(t=!0){const e=this._selectionManagerService.getLast();if(e==null)return;const{startRow:n,startColumn:o,actualRow:r,actualColumn:s}=e.primary,a=t?r:n,c=t?s:o;this._scrollToCell(a,c)}_getViewportBounding(){var r,s;const t=(r=this._getSheetObject())==null?void 0:r.scene;if(t==null)return;const e=t.getViewport(F.VIEW_MAIN);if(e==null)return;const n=(s=this._sheetSkeletonManagerService.getCurrent())==null?void 0:s.skeleton;if(n==null)return;const o=e.getBounding();return n.getRowColumnSegment(o)}_scrollToCell(t,e){var O,x,N,V;const{rowHeightAccumulation:n,columnWidthAccumulation:o}=(x=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton)!=null?x:{};if(n==null||o==null)return!1;const r=(N=this._getSheetObject())==null?void 0:N.scene;if(r==null)return!1;const s=r.getViewport(F.VIEW_MAIN);if(s==null||this._getSheetObject()==null||((V=this._sheetSkeletonManagerService.getCurrent())==null?void 0:V.skeleton)==null)return!1;const d=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet(),{startColumn:u,startRow:h,ySplit:m,xSplit:S}=d.getFreeze(),g=this._getViewportBounding();if(g==null)return!1;const{startRow:_,startColumn:v,endRow:M,endColumn:R}=g;let b,E;if(t>=h&&e>=u-S&&(t<=_&&(b=t),t>=M)){const D=n[t]-s.height;for(let H=_;H<=t;H++)if(n[H]>=D){b=H+1;break}}if(e>=u&&t>=h-m&&(e<=v&&(E=e),e>=R)){const D=o[e]-s.width;for(let H=v;H<=e;H++)if(o[H]>=D){E=H+1;break}}if(b===void 0&&E===void 0)return!1;const{offsetX:T,offsetY:y}=this._scrollManagerService.getCurrentScroll()||{};return this._commandService.syncExecuteCommand(ct.id,{sheetViewStartRow:b,sheetViewStartColumn:E,offsetX:E===void 0?T:0,offsetY:b===void 0?y:0})}},A.ScrollController=Ga([l.OnLifecycle(l.LifecycleStages.Rendered,A.ScrollController),It(0,P.Inject(A.SheetSkeletonManagerService)),It(1,l.IUniverInstanceService),It(2,l.ICommandService),It(3,w.IRenderManagerService),It(4,P.Inject(f.SelectionManagerService)),It(5,P.Inject(Xe))],A.ScrollController);const Pe={id:"sheet.operation.set-zoom-ratio",type:l.CommandType.OPERATION,handler:(i,t)=>{const e=i.get(l.IUniverInstanceService).getUniverSheetInstance(t.unitId),n=e==null?void 0:e.getSheetBySheetId(t.subUnitId);return n==null?!1:(n.getConfig().zoomRatio=t.zoomRatio,!0)}};var Mt=(i=>(i.Append="APPEND",i.Default="DEFAULT",i.Only="ONLY",i))(Mt||{}),me=(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))(me||{}),oe=(i=>(i.COPY="0",i.SERIES="1",i.ONLY_FORMAT="2",i.NO_FORMAT="3",i))(oe||{});const Qa={type:me.NUMBER,priority:1e3,match:i=>typeof(i==null?void 0:i.v)=="number"||(i==null?void 0:i.t)===l.CellValueType.NUMBER,isContinue:(i,t)=>i.type===me.NUMBER,applyFunctions:{[oe.SERIES]:(i,t,e)=>{const{data:n}=i;return e===l.Direction.LEFT||e===l.Direction.UP?(n.reverse(),mo(n,t,e).reverse()):mo(n,t,e)}}},Xo={type:me.OTHER,priority:0,match:()=>!0,isContinue:(i,t)=>i.type===me.OTHER},Ja={type:me.EXTEND_NUMBER,priority:900,match:i=>Sn(`${i==null?void 0:i.v}`||"").isExtendNumber,isContinue:(i,t)=>{var e;if(i.type===me.EXTEND_NUMBER){const{beforeTxt:n,afterTxt:o}=Sn(`${(e=i.cellData)==null?void 0:e.v}`||""),{beforeTxt:r,afterTxt:s}=Sn(`${t==null?void 0:t.v}`||"");if(n===r&&o===s)return!0}return!1},applyFunctions:{[oe.SERIES]:(i,t,e)=>{var a;const{data:n}=i,o=e===l.Direction.UP||e===l.Direction.LEFT;let r;if(n.length===1)return r=o?-1:1,Ee(So(n,t,r),o);const s=[];for(let c=0;c<n.length;c++){const d=`${(a=n[c])==null?void 0:a.v}`;d&&s.push(Number(Sn(d).matchTxt))}return o&&(n.reverse(),s.reverse()),Pt(s)?(r=s[1]-s[0],Ee(So(n,t,r),o)):rt(n,t)}}},qa={type:me.CHN_NUMBER,priority:830,match:i=>!!Ts(`${i==null?void 0:i.v}`||""),isContinue:(i,t)=>i.type===me.CHN_NUMBER,applyFunctions:{[oe.SERIES]:(i,t,e)=>{var c,d,u;const{data:n}=i,o=e===l.Direction.LEFT||e===l.Direction.UP;if(n.length===1){const h=`${(c=n[0])==null?void 0:c.v}`;let m;return o?m=-1:m=1,h&&(h==="日"||Ye(h)<7)?Ee(_t(n,t,m),o):Ee(go(n,t,m),o)}let r=!1;for(let h=0;h<n.length;h++)if(((d=n[h])==null?void 0:d.v)==="日"){r=!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)):r&&Ye(m)>0&&Ye(m)<7?s.push(Ye(m)+a*7):s.push(Ye(m))}if(o&&(n.reverse(),s.reverse()),Pt(s)){if(r||s[s.length-1]<6&&s[0]>0||s[0]<6&&s[s.length-1]>0){const m=s[1]-s[0];return Ee(_t(n,t,m),o)}const h=s[1]-s[0];return Ee(go(n,t,h),o)}return rt(n,t)}}},el={type:me.CHN_WEEK2,priority:820,match:i=>!!Es(`${i==null?void 0:i.v}`||""),isContinue:(i,t)=>i.type===me.CHN_WEEK2,applyFunctions:{[oe.SERIES]:(i,t,e)=>{var a;const{data:n}=i,o=e===l.Direction.LEFT||e===l.Direction.UP;if(n.length===1){let c;return o?c=-1:c=1,Ee(_t(n,t,c,1),o)}const r=[];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?r.push(0):(s++,r.push(s*7)):r.push(Ye(u)+s*7)}if(o&&(n.reverse(),r.reverse()),Pt(r)){const c=r[1]-r[0];return Ee(_t(n,t,c,1),o)}return rt(n,t)}}},tl={type:me.CHN_WEEK3,priority:810,match:i=>ys(`${i==null?void 0:i.v}`||""),isContinue:(i,t)=>i.type===me.CHN_WEEK3,applyFunctions:{[oe.SERIES]:(i,t,e)=>{var a;const{data:n}=i,o=e===l.Direction.LEFT||e===l.Direction.UP;if(n.length===1){let c;return o?c=-1:c=1,Ee(_t(n,t,c,2),o)}const r=[];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?r.push(0):(s++,r.push(s*7)):r.push(Ye(u)+s*7)}}if(o&&(n.reverse(),r.reverse()),Pt(r)){const c=r[1]-r[0];return Ee(_t(n,t,c,2),o)}return rt(n,t)}}},nl={type:me.LOOP_SERIES,priority:800,match:i=>Ls(`${i==null?void 0:i.v}`||""),isContinue:(i,t)=>{var e;return i.type===me.LOOP_SERIES?ai(`${(e=i.cellData)==null?void 0:e.v}`||"").name===ai(`${t==null?void 0:t.v}`||"").name:!1},applyFunctions:{[oe.SERIES]:(i,t,e)=>{var c,d;const{data:n}=i,o=e===l.Direction.LEFT||e===l.Direction.UP,{series:r}=ai(`${(c=n[0])==null?void 0:c.v}`||"");if(n.length===1){let u;return o?u=-1:u=1,Ee(_o(n,t,u,r),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===r[0]?u===0?s.push(0):(a++,s.push(a*r.length)):s.push(r.indexOf(h)+a*7))}if(o&&(n.reverse(),s.reverse()),Pt(s)){const u=s[1]-s[0];return Ee(_o(n,t,u,r),o)}return rt(n,t)}}};function Ee(i,t){return t?i.reverse():i}var il=Object.defineProperty,ol=Object.getOwnPropertyDescriptor,rl=(i,t,e,n)=>{for(var o=n>1?void 0:n?ol(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&il(t,e,o),o},Ri=(i,t)=>(e,n)=>t(e,n,i);A.AutoFillService=class extends l.Disposable{constructor(e,n,o){super();I(this,"_rules",[]);I(this,"_hooks",[]);I(this,"_applyType$",new k.BehaviorSubject(oe.SERIES));I(this,"_isFillingStyle",!0);I(this,"_autoFillLocation$",new k.BehaviorSubject(null));I(this,"autoFillLocation$",this._autoFillLocation$.asObservable());I(this,"_showMenu$",new k.BehaviorSubject(!1));I(this,"showMenu$",this._showMenu$.asObservable());I(this,"_direction",l.Direction.DOWN);I(this,"applyType$",this._applyType$.asObservable());I(this,"_menu$",new k.BehaviorSubject([{label:"autoFill.copy",value:oe.COPY,disable:!1},{label:"autoFill.series",value:oe.SERIES,disable:!1},{label:"autoFill.formatOnly",value:oe.ONLY_FORMAT,disable:!1},{label:"autoFill.noFormat",value:oe.NO_FORMAT,disable:!1}]));I(this,"menu$",this._menu$.asObservable());this._sheetInterceptorService=e,this._univerInstanceService=n,this._selectionManagerService=o,this._init()}_init(){this._rules=[Qa,Ja,qa,el,tl,nl,Xo].sort((e,n)=>n.priority-e.priority),this._isFillingStyle=!0}getOneByPriority(e){return e.length<=0?[]:[e.reduce((o,r)=>(r.priority||0)>(o.priority||0)?r:o,e[0])]}addHook(e){if(this._hooks.find(n=>n.id===e.id))throw new Error(`Add hook failed, hook id '${e.id}' already exist!`);return e.priority===void 0&&(e.priority=0),e.type===void 0&&(e.type=Mt.Append),this._hooks.push(e),l.toDisposable(()=>{const n=this._hooks.findIndex(o=>o===e);n>-1&&this._hooks.splice(n,1)})}registerRule(e){if(this._rules.find(o=>o.type===e.type))throw new Error(`Registry rule failed, type '${e.type}' already exist!`);const n=this._rules.findIndex(o=>o.priority<e.priority);this._rules.splice(n===-1?this._rules.length:n,0,e)}getRules(){return this._rules}getAllHooks(){return this._hooks}getActiveHooks(){const{source:e,target:n,unitId:o,subUnitId:r}=this.autoFillLocation||{};if(!e||!n||!o||!r)return[];const s=this._hooks.filter(u=>{var h;return!((h=u.disable)!=null&&h.call(u,{source:e,target:n,unitId:o,subUnitId:r},this._direction,this.applyType))}),a=s.filter(u=>u.type===Mt.Only);if(a.length>0)return this.getOneByPriority(a);const c=this.getOneByPriority(s.filter(u=>u.type===Mt.Default)),d=s.filter(u=>u.type===Mt.Append)||[];return[...c,...d]}get applyType(){return this._applyType$.getValue()}set applyType(e){this._applyType$.next(e)}get menu(){return this._menu$.getValue()}get direction(){return this._direction}set direction(e){this._direction=e}isFillingStyle(){return this._isFillingStyle}setFillingStyle(e){this._isFillingStyle=e}get autoFillLocation(){return this._autoFillLocation$.getValue()}set autoFillLocation(e){this._autoFillLocation$.next(e)}setDisableApplyType(e,n){this._menu$.next(this._menu$.getValue().map(o=>o.value===e?{...o,disable:n}:o))}setShowMenu(e){this._showMenu$.next(e)}},A.AutoFillService=rl([l.OnLifecycle(l.LifecycleStages.Rendered,A.AutoFillService),Ri(0,P.Inject(f.SheetInterceptorService)),Ri(1,P.Inject(l.IUniverInstanceService)),Ri(2,P.Inject(f.SelectionManagerService))],A.AutoFillService);const jt=P.createIdentifier("univer.auto-fill-service");var sl=Object.defineProperty,al=Object.getOwnPropertyDescriptor,ll=(i,t,e,n)=>{for(var o=n>1?void 0:n?al(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&sl(t,e,o),o},$e=(i,t)=>(e,n)=>t(e,n,i);A.AutoFillController=class extends l.Disposable{constructor(e,n,o,r,s,a,c,d,u){super();I(this,"_beforeApplyData",[]);I(this,"_copyData",[]);I(this,"_defaultHook");this._univerInstanceService=e,this._selectionRenderService=n,this._commandService=o,this._undoRedoService=r,this._autoFillService=s,this._editorBridgeService=a,this._sheetInterceptorService=c,this._selectionManagerService=d,this._injector=u,this._defaultHook={id:"default",type:Mt.Default,priority:0,onBeforeFillData:(h,m)=>{this._presetAndCacheData(h,m)},onFillData:(h,m,S)=>this._fillData(h,m,S)},this._init()}_init(){this._initDefaultHook(),this._onSelectionControlFillChanged(),this._onApplyTypeChanged(),[po,gn].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initDefaultHook(){this._autoFillService.addHook(this._defaultHook)}_onSelectionControlFillChanged(){const e=new l.DisposableCollection,n=o=>{const r=this._selectionManagerService.getCurrent();if((r==null?void 0:r.pluginName)!==f.NORMAL_SELECTION_PLUGIN_NAME)return;o.dispose(),this._selectionRenderService.getCurrentControls().forEach(a=>{o.add(l.toDisposable(a.selectionFilled$.subscribe(c=>{if(c==null||c.startColumn===-1||c.startRow===-1||c.endColumn===-1||c.endRow===-1)return;const d={startColumn:a.model.startColumn,endColumn:a.model.endColumn,startRow:a.model.startRow,endRow:a.model.endRow},u={startColumn:c.startColumn,endColumn:c.endColumn,startRow:c.startRow,endRow:c.endRow};this._triggerAutoFill(d,u)}))),o.add(l.toDisposable(a.fillControl.onDblclickObserver.add(()=>{const c={startColumn:a.model.startColumn,endColumn:a.model.endColumn,startRow:a.model.startRow,endRow:a.model.endRow};this._handleDbClickFill(c)}))),o.add(l.toDisposable(a.fillControl.onPointerDownObserver.add(()=>{this._editorBridgeService.isVisible().visible&&this._editorBridgeService.changeVisible({visible:!1,eventType:w.DeviceInputEventType.PointerDown})})))})};n(e),this.disposeWithMe(this._commandService.onCommandExecuted(o=>{o.id===f.SetSelectionsOperation.id&&n(e)}))}_onApplyTypeChanged(){this.disposeWithMe(l.toDisposable(this._autoFillService.applyType$.subscribe(()=>{this._handleFillData()})))}_triggerAutoFill(e,n){var d;if(e.startColumn===n.startColumn&&e.startRow===n.startRow&&e.endColumn===n.endColumn&&e.endRow===n.endRow)return;if(n.endColumn<e.endColumn&&n.endColumn>e.startColumn){this._commandService.executeCommand(gn.id,{clearRange:{startRow:n.startRow,endRow:n.endRow,startColumn:n.endColumn+1,endColumn:e.endColumn},selectionRange:n});return}if(n.endRow<e.endRow&&n.endRow>e.startRow){this._commandService.executeCommand(gn.id,{clearRange:{startRow:n.endRow+1,endRow:e.endRow,startColumn:n.startColumn,endColumn:n.endColumn},selectionRange:n});return}const o={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn};let r=null;if(n.startRow<e.startRow)r=l.Direction.UP,o.endRow=e.startRow-1;else if(n.endRow>e.endRow)r=l.Direction.DOWN,o.startRow=e.endRow+1;else if(n.startColumn<e.startColumn)r=l.Direction.LEFT,o.endColumn=e.startColumn-1;else if(n.endColumn>e.endColumn)r=l.Direction.RIGHT,o.startColumn=e.endColumn+1;else return;const s=this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),a=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();this._autoFillService.direction=r,this._autoFillService.autoFillLocation={source:e,target:o,unitId:s,subUnitId:a},this._autoFillService.getActiveHooks().forEach(u=>{var h;(h=u==null?void 0:u.onBeforeFillData)==null||h.call(u,{source:e,target:o,unitId:s,subUnitId:a},r)}),(d=this._autoFillService.menu.find(u=>u.value===oe.SERIES))!=null&&d.disable?this._autoFillService.applyType=oe.COPY:this._autoFillService.applyType=oe.SERIES}_handleDbClickFill(e){const n=this._detectFillRange(e);n.endRow<=e.endRow||this._triggerAutoFill(e,n)}_detectFillRange(e){var m,S,g,_,v,M;const{startRow:n,endRow:o,startColumn:r,endColumn:s}=e,a=(m=this._univerInstanceService.getCurrentUniverSheetInstance())==null?void 0:m.getActiveSheet();if(!a)return e;const c=a.getCellMatrix(),d=a.getMaxRows()-1,u=a.getMaxColumns()-1;let h=o;if(r>0&&((S=c.getValue(n,r-1))==null?void 0:S.v)!=null){let R=n;for(;((g=c.getValue(R,r-1))==null?void 0:g.v)!=null&&R<d;)R+=1;h=R-1}else if(s<u&&((_=c.getValue(o,s+1))==null?void 0:_.v)!=null){let R=n;for(;((v=c.getValue(R,s+1))==null?void 0:v.v)!=null&&R<d;)R+=1;h=R-1}for(let R=o+1;R<=h;R++)for(let b=r;b<=s;b++)if(((M=c.getValue(R,b))==null?void 0:M.v)!=null){h=R-1;break}return{startColumn:r,endColumn:s,startRow:n,endRow:h}}_handleFillData(){var S,g;const{source:e,target:n,unitId:o=this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),subUnitId:r=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId()}=this._autoFillService.autoFillLocation||{},s=this._autoFillService.direction;if(!e||!n)return;const a=l.Rectangle.union(e,n),c=this._autoFillService.applyType,d=this._autoFillService.getActiveHooks();this._commandService.syncExecuteCommand(f.SetSelectionsOperation.id,{selections:[{primary:{...(g=(S=this._selectionManagerService.getLast())==null?void 0:S.primary)!=null?g:a},range:{...a,rangeType:l.RANGE_TYPE.NORMAL}}],unitId:o,subUnitId:r});const u=[],h=[];d.forEach(_=>{var R;const{undos:v,redos:M}=((R=_.onFillData)==null?void 0:R.call(_,{source:e,target:n,unitId:o,subUnitId:r},s,c))||{};v&&u.push(...v),M&&h.push(...M)}),h.every(_=>this._commandService.syncExecuteCommand(_.id,_.params))&&this._undoRedoService.pushUndoRedo({unitID:o,undoMutations:u,redoMutations:h}),d.forEach(_=>{var v;(v=_.onAfterFillData)==null||v.call(_,{source:e,target:n,unitId:o,subUnitId:r},s,c)}),this._autoFillService.setShowMenu(!0)}_getApplyData(e,n,o,r,s,a=!0){const c=[],d=Math.floor(o/n),u=o%n,h=this._autoFillService.getRules();if(!a&&s===oe.ONLY_FORMAT)return console.error("ERROR: only format can not be applied when hasStyle is false"),[];const m={};h.forEach(S=>{m[S.type]=[]}),h.forEach(S=>{const{type:g,applyFunctions:_={}}=S,v=e[g];v&&v.forEach(M=>{const R=Os(M.index,u),b=M.index.length*d+R,E=this._applyFunctions(M,b,r,s,_,e),T=As(n,o,M.index);m[g].push({data:E,index:T})})});for(let S=0;S<o;S++)h.forEach(g=>{const{type:_}=g,v=m[_];for(let M=0;M<v.length;M++)S in v[M].index&&c.push(v[M].data[v[M].index[S]])});return c}_applyFunctions(e,n,o,r,s,a){const{data:c}=e,d=o===l.Direction.UP||o===l.Direction.LEFT;if(r===oe.COPY){const u=s==null?void 0:s[oe.COPY];return u?u(e,n,o,a):(d&&c.reverse(),rt(c,n))}if(r===oe.SERIES){const u=s==null?void 0:s[oe.SERIES];return u?u(e,n,o,a):(d&&c.reverse(),s!=null&&s[oe.COPY]?s[oe.COPY](e,n,o,a):rt(c,n))}if(r===oe.ONLY_FORMAT){const u=s==null?void 0:s[oe.ONLY_FORMAT];return u?u(e,n,o,a):xs(c,n)}}_getCopyData(e,n){const{startRow:o,startColumn:r,endRow:s,endColumn:a}=e,c=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getCellMatrix(),d=this._autoFillService.getRules(),u=[],h=n===l.Direction.DOWN||n===l.Direction.UP;let m,S,g,_;h?(m=r,S=a,g=o,_=s):(m=o,S=s,g=r,_=a);for(let v=m;v<=S;v++){const M=this._getEmptyCopyDataPiece(),R={type:void 0,cellData:void 0};for(let b=g;b<=_;b++){let E;h?E=c.getValue(b,v):E=c.getValue(v,b);const{type:T,isContinue:y}=d.find(O=>O.match(E))||Xo;if(y(R,E)){const O=M[T],x=O[O.length-1];x.data.push(E),x.index.push(b-g)}else{const O=M[T];O?O.push({data:[E],index:[b-g]}):M[T]=[{data:[E],index:[b-g]}]}R.type=T,R.cellData=E}u.push(M)}return u}_getEmptyCopyDataPiece(){const e={};return this._autoFillService.getRules().forEach(n=>{e[n.type]=[]}),e}_getMergeApplyData(e,n,o,r){const s=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData(),a=[];for(let c=e.startRow;c<=e.endRow;c++)for(let d=e.startColumn;d<=e.endColumn;d++){const{isMergedMainCell:u,startRow:h,startColumn:m,endRow:S,endColumn:g}=w.getCellInfoInMergeData(c,d,s);if(u){if(o===l.Direction.DOWN){let _=h+r,v=S+r;for(;v<=n.endRow;)a.push({startRow:_,startColumn:m,endRow:v,endColumn:g}),_+=r,v+=r}else if(o===l.Direction.UP){let _=h-r,v=S-r;for(;_>=n.startRow;)a.push({startRow:_,startColumn:m,endRow:v,endColumn:g}),_-=r,v-=r}else if(o===l.Direction.RIGHT){let _=m+r,v=g+r;for(;v<=n.endColumn;)a.push({startRow:h,startColumn:_,endRow:S,endColumn:v}),_+=r,v+=r}else if(o===l.Direction.LEFT){let _=m-r,v=g-r;for(;_>=n.startColumn;)a.push({startRow:h,startColumn:_,endRow:S,endColumn:v}),_-=r,v-=r}}}return a}_presetAndCacheData(e,n){const{source:o,target:r}=e,s=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getCellMatrix(),a=[];for(let c=r.startRow;c<=r.endRow;c++){const d=[];for(let u=r.startColumn;u<=r.endColumn;u++)d.push(l.Tools.deepClone(s.getValue(c,u)));a.push(d)}this._beforeApplyData=a,this._copyData=this._getCopyData(o,n),this._hasSeries(this._copyData)?this._autoFillService.setDisableApplyType(oe.SERIES,!1):this._autoFillService.setDisableApplyType(oe.SERIES,!0)}_fillData(e,n,o){var re,se;const r=[],s=[];let a=!0;o===oe.NO_FORMAT&&(a=!1,o=oe.SERIES);const{source:c,target:d,unitId:u,subUnitId:h}=e;if(!c||!d||n==null)return{undos:r,redos:s};const{startRow:m,startColumn:S,endRow:g,endColumn:_}=c,{startRow:v,startColumn:M,endRow:R,endColumn:b}=d,E=this._copyData;let T;n===l.Direction.DOWN||n===l.Direction.UP?T=g-m+1:T=_-S+1;const y=[];if(n===l.Direction.DOWN||n===l.Direction.UP){const Y=R-v+1,Q=[];for(let J=M;J<=b;J++){const ae=E[J-M],ce=this._getApplyData(ae,T,Y,n,o,a);Q.push(ce)}for(let J=0;J<Q[0].length;J++){const ae=[];for(let ce=0;ce<Q.length;ce++)ae.push({s:null,...Q[ce][J]});y.push(ae)}}else{const Y=b-M+1;for(let Q=v;Q<=R;Q++){const J=E[Q-v],ae=this._getApplyData(J,T,Y,n,o,a),ce=[];for(let pe=0;pe<ae.length;pe++)ce.push({s:null,...ae[pe]});y.push(ce)}}let O=[];const x=this._univerInstanceService.getCurrentUniverSheetInstance().getStyles();a?(O=this._getMergeApplyData(c,d,n,T),y.forEach(Y=>{Y.forEach(Q=>{Q&&x&&x&&(Q.s=x.getStyleByCell(Q))})})):y.forEach((Y,Q)=>{Y.forEach((J,ae)=>{J&&x&&(J.s=x.getStyleByCell(this._beforeApplyData[Q][ae])||null)})}),o===oe.ONLY_FORMAT&&y.forEach((Y,Q)=>{Y.forEach((J,ae)=>{if(J){const ce=this._beforeApplyData[Q][ae]||{};J.f=ce.f,J.si=ce.si,J.t=ce.t,J.v=ce.v}})});const N={get:this._injector.get.bind(this._injector)},V=[],D=(se=(re=this._univerInstanceService.getUniverSheetInstance(u))==null?void 0:re.getSheetBySheetId(h))==null?void 0:se.getMergeData();D&&D.forEach(Y=>{l.Rectangle.intersects(Y,d)&&V.push(Y)});const H={unitId:u,subUnitId:h,ranges:V},B=f.RemoveMergeUndoMutationFactory(N,H);s.push({id:f.RemoveWorksheetMergeMutation.id,params:H}),r.push({id:f.AddWorksheetMergeMutation.id,params:B});const j={subUnitId:h,unitId:u,cellValue:fo([d])},X=f.SetRangeValuesUndoMutationFactory(N,j),z=this._sheetInterceptorService.onCommandExecute({id:f.ClearSelectionContentCommand.id});s.push({id:f.SetRangeValuesMutation.id,params:j},...z.redos),r.push(...z.undos,{id:f.SetRangeValuesMutation.id,params:X});const $=new l.ObjectMatrix,{startRow:ee,startColumn:ne,endRow:U,endColumn:W}=d;for(let Y=0;Y<=U-ee;Y++)for(let Q=0;Q<=W-ne;Q++)y[Y][Q]&&$.setValue(Y+ee,Q+ne,y[Y][Q]);const G={subUnitId:h,unitId:u,cellValue:$.getMatrix()},q=f.SetRangeValuesUndoMutationFactory(N,G);if(r.push({id:f.SetRangeValuesMutation.id,params:q}),s.push({id:f.SetRangeValuesMutation.id,params:G}),O!=null&&O.length){const Y=f.getAddMergeMutationRangeByType(O),Q={unitId:u,subUnitId:h,ranges:Y},J=f.AddMergeUndoMutationFactory(N,Q);r.push({id:f.RemoveWorksheetMergeMutation.id,params:J}),s.push({id:f.AddWorksheetMergeMutation.id,params:Q})}return{undos:r,redos:s}}_hasSeries(e){return e.some(n=>Object.keys(n).some(r=>{var s;return!!((s=n[r])!=null&&s.length&&![me.OTHER,me.FORMULA].includes(r))}))}},A.AutoFillController=ll([l.OnLifecycle(l.LifecycleStages.Steady,A.AutoFillController),$e(0,l.IUniverInstanceService),$e(1,fe),$e(2,l.ICommandService),$e(3,l.IUndoRedoService),$e(4,jt),$e(5,we),$e(6,P.Inject(f.SheetInterceptorService)),$e(7,P.Inject(f.SelectionManagerService)),$e(8,P.Inject(P.Injector))],A.AutoFillController);var cl=Object.defineProperty,dl=Object.getOwnPropertyDescriptor,ul=(i,t,e,n)=>{for(var o=n>1?void 0:n?dl(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&cl(t,e,o),o},bi=(i,t)=>(e,n)=>t(e,n,i);A.CellCustomRenderController=class extends l.Disposable{constructor(e,n,o){super();I(this,"_enterActiveRender");this._sheetSkeletonManagerService=e,this._renderManagerService=n,this._univerInstanceService=o,this._initEventBinding()}_initEventBinding(){const e=new l.DisposableCollection;this._univerInstanceService.currentSheet$.subscribe(n=>{if(n){const o=n.getUnitId(),r=this._renderManagerService.getRenderById(n.getUnitId());if(r&&r.mainComponent){e.dispose();const s=r.mainComponent,a=u=>{var z;const h=(z=this._sheetSkeletonManagerService.getCurrent())==null?void 0:z.skeleton,{offsetX:m,offsetY:S}=u,g=r.scene,_=n.getActiveSheet(),v=g.getActiveViewportByCoord(w.Vector2.FromArray([m,S]));if(!v)return;const{scaleX:M,scaleY:R}=g.getAncestorScale(),b={x:v.actualScrollX,y:v.actualScrollY},E=h.getCellPositionByOffset(m,S,M,R,b),T=h.mergeData.find($=>{const{startColumn:ee,startRow:ne,endColumn:U,endRow:W}=$;return E.row>=ne&&E.column>=ee&&E.row<=W&&E.column<=U}),y={actualRow:T?T.startRow:E.row,actualCol:T?T.startColumn:E.column,mergeCell:T,row:E.row,col:E.column};if(!y||!h)return;const O=_.getCell(y.actualRow,y.actualCol);if(!O)return;const x=O.customRender;if(!(x!=null&&x.length))return;const N=y.actualRow,V=y.actualCol,D=x.sort(l.sortRules),H=n.getActiveSheet().getSheetId(),B={data:O,style:h.getsStyles().getStyleByCell(O),primaryWithCoord:h.getCellByIndex(y.actualRow,y.actualCol),unitId:o,subUnitId:H,row:N,col:V},j={x:b.x+m/M,y:b.y+S/R},X=D.find($=>{var ee;return(ee=$.isHit)==null?void 0:ee.call($,j,B)});if(X)return[X,B]},c=s.onPointerDownObserver.add(u=>{var m;const h=a(u);if(h){const[S,g]=h;(m=S.onPointerDown)==null||m.call(S,g,u)}}),d=s.onPointerMoveObserver.add(u=>{var m,S,g,_;const h=a(u);if(h){const[v,M]=h;this._enterActiveRender?this._enterActiveRender.render!==v&&((S=(m=this._enterActiveRender.render).onPointerLeave)==null||S.call(m,this._enterActiveRender.cellContext,u),this._enterActiveRender={render:v,cellContext:M},(g=v.onPointerEnter)==null||g.call(v,M,u)):(this._enterActiveRender={render:v,cellContext:M},(_=v.onPointerEnter)==null||_.call(v,M,u))}});c&&e.add(c),d&&e.add(d)}}}),this.disposeWithMe(e)}},A.CellCustomRenderController=ul([l.OnLifecycle(l.LifecycleStages.Rendered,A.CellCustomRenderController),bi(0,P.Inject(A.SheetSkeletonManagerService)),bi(1,w.IRenderManagerService),bi(2,l.IUniverInstanceService)],A.CellCustomRenderController);const $o={id:"sheet.command.hide-row-confirm",type:l.CommandType.COMMAND,handler:async i=>{var c;const e=(c=i.get(f.SelectionManagerService).getSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const n=i.get(l.ICommandService),a=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance().getActiveSheet().getVisibleRows();if(Wo(a,e)){const d=i.get(C.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(f.SetRowHiddenCommand.id),!0}},Zo={id:"sheet.command.hide-col-confirm",type:l.CommandType.COMMAND,handler:async i=>{var c;const e=(c=i.get(f.SelectionManagerService).getSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const n=i.get(l.ICommandService),a=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance().getActiveSheet().getVisibleCols();if(jo(a,e)){const d=i.get(C.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(f.SetColHiddenCommand.id),!0}},wi={type:l.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async i=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatBoldCommand.id):t.executeCommand(f.SetBoldCommand.id)}},Ti={type:l.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async i=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatItalicCommand.id):t.executeCommand(f.SetItalicCommand.id)}},Ei={type:l.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async i=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatUnderlineCommand.id):t.executeCommand(f.SetUnderlineCommand.id)}},yi={type:l.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async i=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatStrikethroughCommand.id):t.executeCommand(f.SetStrikeThroughCommand.id)}},hl={type:l.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async i=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatSubscriptCommand.id):!1}},ml={type:l.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async i=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatSuperscriptCommand.id):!1}},Go={type:l.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(i,t)=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?e.executeCommand(te.SetInlineFormatFontSizeCommand.id,t):e.executeCommand(f.SetFontSizeCommand.id,t)}},Ko={type:l.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(i,t)=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?e.executeCommand(te.SetInlineFormatFontFamilyCommand.id,t):e.executeCommand(f.SetFontFamilyCommand.id,t)}},In={type:l.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(i,t)=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?e.executeCommand(te.SetInlineFormatTextColorCommand.id,t):e.executeCommand(f.SetTextColorCommand.id,t)}};function Qo(i,t){return t.some(e=>Sl(i,e))}function Sl(i,t){const{startRow:e,startColumn:n,endColumn:o,endRow:r}=t,s=i.getMatrixWithMergedCells(e,n,r,o);let a=!1;return s.forValue((c,d,u)=>{if(u&&(c!==e||d!==n)&&i.cellHasValue(u))return a=!0,!1}),a}function Jo(i,t,e,n){const o=[],r=[],s=e.getSheetId();return n.forEach(a=>{const c=gl(e,a),d={unitId:t,subUnitId:s,cellValue:c.getData()},u=f.SetRangeValuesUndoMutationFactory(i,d);o.push({id:f.SetRangeValuesMutation.id,params:u}),r.push({id:f.SetRangeValuesMutation.id,params:d})}),{undos:o,redos:r}}function gl(i,t){const{startRow:e,startColumn:n,endColumn:o,endRow:r}=t,s=i.getMatrixWithMergedCells(e,n,r,o),a=new l.ObjectMatrix;return s.forValue((c,d,u)=>{u&&(c!==e||d!==n)&&a.setValue(c,d,null)}),a}function _l(i,t,e,n){const o=e.getActiveViewportByCoord(w.Vector2.FromArray([i,t]));if(!o)return;const{scaleX:r,scaleY:s}=e.getAncestorScale(),a={x:o.actualScrollX,y:o.actualScrollY},c=n.getCellPositionByOffset(i,t,r,s,a),d=n.mergeData.find(h=>{const{startColumn:m,startRow:S,endColumn:g,endRow:_}=h;return c.row>=S&&c.column>=m&&c.row<=_&&c.column<=g});return{actualRow:d?d.startRow:c.row,actualCol:d?d.startColumn:c.column,mergeCell:d,row:c.row,col:c.column}}function fl(i,t,e,n){const o=n.getFreeze();if(!o||o.startRow<=0&&o.startColumn<=0||i>o.startRow&&t>o.startColumn)return e.getViewport(F.VIEW_MAIN);if(i<=o.startRow&&t<=o.startColumn)return e.getViewport(F.VIEW_MAIN_LEFT_TOP);if(i<=o.startRow&&t>o.startColumn)return e.getViewport(F.VIEW_MAIN_TOP);if(i>o.startRow&&t<=o.startColumn)return e.getViewport(F.VIEW_MAIN_LEFT)}function pl(i,t,e,n){const o=qo(i.left,i.top,t,e,n),r=qo(i.right,i.bottom,t,e,n);return{left:o.x,top:o.y,right:r.x,bottom:r.y}}function qo(i,t,e,n,o){const{scaleX:r,scaleY:s}=e.getAncestorScale(),a=e.getViewport(F.VIEW_MAIN);if(!a)return{x:i,y:t};const c=o.getFreeze(),{startColumn:d,startRow:u,xSplit:h,ySplit:m}=c,S=n.getNoMergeCellPositionByIndexWithNoHeader(u-m,d-h),g=n.getNoMergeCellPositionByIndexWithNoHeader(u,d),{rowHeaderWidth:_,columnHeaderHeight:v}=n,M=g.startX-S.startX,R=g.startY-S.startY,{top:b,left:E,actualScrollX:T,actualScrollY:y}=a;let O;i>E?O=(i-T)*r:O=(M+_-(E-i))*r;let x;return t>b?x=(t-y)*s:x=(R+v-(b-t))*r,{x:O,y:x}}var vl=Object.defineProperty,Cl=Object.getOwnPropertyDescriptor,Il=(i,t,e,n)=>{for(var o=n>1?void 0:n?Cl(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&vl(t,e,o),o},Oi=(i,t)=>(e,n)=>t(e,n,i),Le=(i=>(i[i.OFF=0]="OFF",i[i.ONCE=1]="ONCE",i[i.INFINITE=2]="INFINITE",i))(Le||{});const Rt=P.createIdentifier("univer.format-painter-service");let Ai=class extends l.Disposable{constructor(t,e,n){super();I(this,"status$");I(this,"_selectionFormat");I(this,"_markId",null);I(this,"_status$");this._selectionManagerService=t,this._univerInstanceService=e,this._markSelectionService=n,this._status$=new k.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new l.ObjectMatrix,merges:[]}}setStatus(t){t!==0&&this._getSelectionRangeFormat(),this._updateRangeMark(t),this._status$.next(t)}getStatus(){return this._status$.getValue()}_updateRangeMark(t){if(this._markSelectionService.removeAllShapes(),this._markId=null,t!==0){const e=this._selectionManagerService.getLast();if(e){const n=this._selectionManagerService.createCopyPasteSelection();t===2?this._markId=this._markSelectionService.addShape({...e,style:n}):this._markId=this._markSelectionService.addShape({...e,style:n},[f.SetRangeValuesMutation.id])}}}_getSelectionRangeFormat(){const t=this._selectionManagerService.getLast(),e=t==null?void 0:t.range;if(!e)return;const{startRow:n,endRow:o,startColumn:r,endColumn:s}=e,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;this._selectionFormat.merges=[];for(let S=n;S<=o;S++)for(let g=r;g<=s;g++){const _=d.getValue(S,g);m.setValue(S,g,h.getStyleByCell(_)||{});const{isMergedMainCell:v,...M}=w.getCellInfoInMergeData(S,g,u);v&&this._selectionFormat.merges.push({startRow:M.startRow,startColumn:M.startColumn,endRow:M.endRow,endColumn:M.endColumn})}this._selectionFormat.styles=m}getSelectionFormat(){return this._selectionFormat}};Ai=Il([Oi(0,P.Inject(f.SelectionManagerService)),Oi(1,l.IUniverInstanceService),Oi(2,Ut)],Ai);const xi={id:"sheet.operation.set-format-painter",type:l.CommandType.OPERATION,handler:(i,t)=>t?(i.get(Rt).setStatus(t.status),!0):!1},er={type:l.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async i=>{const e=i.get(Rt).getStatus();let n;return e!==Le.OFF?n=Le.OFF:n=Le.INFINITE,i.get(l.ICommandService).executeCommand(xi.id,{status:n})}},Ni={type:l.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async i=>{const e=i.get(Rt).getStatus();let n;return e!==Le.OFF?n=Le.OFF:n=Le.ONCE,i.get(l.ICommandService).executeCommand(xi.id,{status:n})}},tr={type:l.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(i,t)=>{const e=i.get(l.ICommandService),n=i.get(l.IUndoRedoService),o=i.get(l.IUniverInstanceService),r=i.get(f.SelectionManagerService),s=i.get(f.SheetInterceptorService),{styleValues:a,styleRange:c,mergeRanges:d,unitId:u=o.getCurrentUniverSheetInstance().getUnitId(),subUnitId:h=o.getCurrentUniverSheetInstance().getActiveSheet().getSheetId()}=t,m=c?[c]:r.getSelectionRanges();if(!m||!m.length)return!1;const S=new l.ObjectMatrix;let g;if(l.Tools.isArray(a))for(let j=0;j<m.length;j++){const{startRow:X,startColumn:z,endRow:$,endColumn:ee}=m[j];for(let ne=0;ne<=$-X;ne++)for(let U=0;U<=ee-z;U++)S.setValue(ne+X,U+z,a[ne][U])}else if(l.isICellData(a))for(let j=0;j<m.length;j++){const{startRow:X,startColumn:z}=m[j];S.setValue(X,z,a)}else g=a;const _={subUnitId:h,unitId:u,cellValue:g!=null?g:S.getMatrix()},v=f.SetRangeValuesUndoMutationFactory(i,_);if(!s.fetchThroughInterceptors(f.INTERCEPTOR_POINT.PERMISSION)(null,{id:f.SetRangeValuesCommand.id,params:_}))return!1;const M=e.syncExecuteCommand(f.SetRangeValuesMutation.id,_),{undos:R,redos:b}=s.onCommandExecute({id:f.SetRangeValuesCommand.id,params:{..._,range:m}}),E=f.getAddMergeMutationRangeByType(d),T=o.getUniverSheetInstance(u).getSheetBySheetId(h),y=[],O=[],x=Qo(T,E),N={unitId:u,subUnitId:h,ranges:E},V={unitId:u,subUnitId:h,ranges:E};y.push({id:f.RemoveWorksheetMergeMutation.id,params:N}),y.push({id:f.AddWorksheetMergeMutation.id,params:V});const D=f.RemoveMergeUndoMutationFactory(i,N),H=f.AddMergeUndoMutationFactory(i,V);if(O.push({id:f.RemoveWorksheetMergeMutation.id,params:H}),O.push({id:f.AddWorksheetMergeMutation.id,params:D}),x){const j=Jo(i,u,T,E);y.unshift(...j.redos),O.push(...j.undos)}const B=await l.sequenceExecute([...b,...y],e);return M&&B.result?(n.pushUndoRedo({unitID:u,undoMutations:[{id:f.SetRangeValuesMutation.id,params:v},...R,...O],redoMutations:[{id:f.SetRangeValuesMutation.id,params:_},...b,...y]}),!0):!1}},Mn={type:l.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(i,t)=>{const{type:e}=t||{},n=i.get(l.IUniverInstanceService),o=i.get(l.IUndoRedoService),r=n.getCurrentUniverSheetInstance().getUnitId(),s=n.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),a=i.get(l.ICommandService),d=i.get(f.SelectionManagerService).getSelections();if(!d)return!1;const u=d[(d==null?void 0:d.length)-1],{range:h}=u,m=i.get(Xe),{sheetViewStartRow:S=0,sheetViewStartColumn:g=0}=m.getCurrentScroll()||{};let _,v,M,R;const{startRow:b,startColumn:E,rangeType:T}=h;if(T===l.RANGE_TYPE.ROW||e===1)_=b,M=b-S,v=-1,R=0;else if(T===l.RANGE_TYPE.COLUMN||e===2)_=-1,M=0,v=E,R=E-g;else if(T===l.RANGE_TYPE.NORMAL)_=b,M=b-S,v=E,R=E-g;else return!1;const y={unitId:r,subUnitId:s,startRow:_,startColumn:v,xSplit:v>0?Math.max(1,R):R,ySplit:_>0?Math.max(1,M):M},O=f.SetFrozenMutationFactory(i,y);return a.syncExecuteCommand(f.SetFrozenMutation.id,y)&&o.pushUndoRedo({unitID:r,undoMutations:[{id:f.SetFrozenMutation.id,params:O}],redoMutations:[{id:f.SetFrozenMutation.id,params:y}]}),!0}},nr={type:l.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async i=>(i.get(l.ICommandService).executeCommand(Mn.id,{type:1}),!0)},ir={type:l.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async i=>(i.get(l.ICommandService).executeCommand(Mn.id,{type:2}),!0)},or={type:l.CommandType.COMMAND,id:"sheet.command.cancel-frozen",handler:async i=>{const t=i.get(l.ICommandService),e=i.get(l.IUniverInstanceService),n=i.get(l.IUndoRedoService),o=e.getCurrentUniverSheetInstance().getUnitId(),r=e.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),s={unitId:o,subUnitId:r,startRow:-1,startColumn:-1,xSplit:0,ySplit:0},a=f.SetFrozenMutationFactory(i,s);return t.syncExecuteCommand(f.SetFrozenMutation.id,s)&&n.pushUndoRedo({unitID:o,undoMutations:[{id:f.SetFrozenMutation.id,params:a}],redoMutations:[{id:f.SetFrozenMutation.id,params:s}]}),!0}},bt="UI_PLUGIN_SHEETS",Rn=`${bt}_COLOR_PICKER_COMPONENT`,rr=`${bt}_FONT_FAMILY_COMPONENT`,sr=`${bt}_FONT_FAMILY_ITEM_COMPONENT`,ar=`${bt}_FONT_SIZE_COMPONENT`,Di=`${bt}_MENU_ITEM_INPUT_COMPONENT`;var lr={exports:{}},bn={};/**
|
|
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 Cl=H,Il=Symbol.for("react.element"),Ml=Symbol.for("react.fragment"),Rl=Object.prototype.hasOwnProperty,bl=Cl.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,wl={key:!0,ref:!0,__self:!0,__source:!0};function ar(i,t,e){var n,o={},r=null,s=null;e!==void 0&&(r=""+e),t.key!==void 0&&(r=""+t.key),t.ref!==void 0&&(s=t.ref);for(n in t)Rl.call(t,n)&&!wl.hasOwnProperty(n)&&(o[n]=t[n]);if(i&&i.defaultProps)for(n in t=i.defaultProps,t)o[n]===void 0&&(o[n]=t[n]);return{$$typeof:Il,type:i,key:r,ref:s,props:o,_owner:bl.current}}bn.Fragment=Ml,bn.jsx=ar,bn.jsxs=ar,sr.exports=bn;var p=sr.exports;const Di={sheetsUiContextMenuInput:"univer-sheets-ui-context-menu-input",sheetsUiContextMenuInputContainer:"univer-sheets-ui-context-menu-input-container",sheetsUiContextMenuInputNumber:"univer-sheets-ui-context-menu-input-number"},Tl=i=>{const{prefix:t,suffix:e,value:n,onChange:o,min:r=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=i,a=K.useDependency(l.LocaleService),[c,d]=H.useState(),u=m=>{var S;d(m==null?void 0:m.toString()),o((S=m==null?void 0:m.toString())!=null?S:"")};H.useEffect(()=>{d(n)},[n]);function h(m){m.key==="Backspace"&&m.stopPropagation()}return p.jsxs("div",{className:Di.sheetsUiContextMenuInput,children:[a.t(t),p.jsx("span",{className:Di.sheetsUiContextMenuInputContainer,onClick:m=>m.stopPropagation(),children:p.jsx(le.InputNumber,{className:Di.sheetsUiContextMenuInputNumber,value:Number(c),precision:0,onKeyDown:h,onChange:u,min:r,max:s})}),a.t(e)]})};var he=(i=>(i.ROW_HEADER_CONTEXT_MENU="rowHeaderContextMenu",i.COL_HEADER_CONTEXT_MENU="colHeaderContextMenu",i.SHEET_BAR="sheetBar",i))(he||{});function El(i){const t=i.get(Rt);return{id:Ni.id,subId:Jo.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",positions:[C.MenuPosition.TOOLBAR_START],activated$:new V.Observable(e=>{let n=!1;const o=t.status$.subscribe(r=>{n=r!==Le.OFF,e.next(n)});return e.next(n),()=>{o.unsubscribe()}}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:f.getCurrentSheetDisabled$(i)}}function yl(i){const t=i.get(l.ICommandService),e=i.get(l.IUniverInstanceService),n=i.get(l.IContextService),o=i.get(f.SelectionManagerService);return{id:bi.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[C.MenuPosition.TOOLBAR_START],disabled$:f.getCurrentSheetDisabled$(i),activated$:new V.Observable(r=>{const s=t.onCommandExecuted(a=>{var d,u;const c=a.id;if(c===f.SetRangeValuesMutation.id||c===f.SetSelectionsOperation.id){const h=(d=o.getLast())==null?void 0:d.primary,m=e.getCurrentUniverSheetInstance().getActiveSheet();let S=l.FontWeight.NORMAL;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);S=_==null?void 0:_.getFontWeight()}r.next(S===l.FontWeight.BOLD)}if((c===te.SetTextSelectionsOperation.id||c===te.SetInlineFormatCommand.id)&&n.getContextValue(l.EDITOR_ACTIVATED)&&n.getContextValue(l.FOCUSING_SHEET)){const h=zt(i);if(h==null)return;const m=(u=h.ts)==null?void 0:u.bl;r.next(m===l.BooleanNumber.TRUE)}});return r.next(!1),s.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function Ol(i){const t=i.get(l.ICommandService),e=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService),o=i.get(l.IContextService);return{id:wi.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[C.MenuPosition.TOOLBAR_START],disabled$:f.getCurrentSheetDisabled$(i),activated$:new V.Observable(r=>{const s=t.onCommandExecuted(a=>{var d,u;const c=a.id;if(c===f.SetRangeValuesMutation.id||c===f.SetSelectionsOperation.id){const h=(d=n.getLast())==null?void 0:d.primary,m=e.getCurrentUniverSheetInstance().getActiveSheet();let S=l.FontItalic.NORMAL;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);S=_==null?void 0:_.getFontStyle()}r.next(S===l.FontItalic.ITALIC)}if((c===te.SetTextSelectionsOperation.id||c===te.SetInlineFormatCommand.id)&&o.getContextValue(l.EDITOR_ACTIVATED)&&o.getContextValue(l.FOCUSING_SHEET)){const h=zt(i);if(h==null)return;const m=(u=h.ts)==null?void 0:u.it;r.next(m===l.BooleanNumber.TRUE)}});return r.next(!1),s.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function xl(i){const t=i.get(l.ICommandService),e=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService),o=i.get(l.IContextService);return{id:Ti.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[C.MenuPosition.TOOLBAR_START],disabled$:f.getCurrentSheetDisabled$(i),activated$:new V.Observable(r=>{const s=t.onCommandExecuted(a=>{var d,u;const c=a.id;if(c===f.SetRangeValuesMutation.id||c===f.SetSelectionsOperation.id){const h=(d=n.getLast())==null?void 0:d.primary,m=e.getCurrentUniverSheetInstance().getActiveSheet();let S;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);S=_==null?void 0:_.getUnderline()}r.next(!!(S&&S.s))}if((c===te.SetTextSelectionsOperation.id||c===te.SetInlineFormatCommand.id)&&o.getContextValue(l.EDITOR_ACTIVATED)&&o.getContextValue(l.FOCUSING_SHEET)){const h=zt(i);if(h==null)return;const m=(u=h.ts)==null?void 0:u.ul;r.next((m==null?void 0:m.s)===l.BooleanNumber.TRUE)}});return r.next(!1),s.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function Nl(i){const t=i.get(l.ICommandService),e=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService),o=i.get(l.IContextService);return{id:Ei.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[C.MenuPosition.TOOLBAR_START],disabled$:f.getCurrentSheetDisabled$(i),activated$:new V.Observable(r=>{const s=t.onCommandExecuted(a=>{var d,u;const c=a.id;if(c===f.SetRangeValuesMutation.id||c===f.SetSelectionsOperation.id){const h=(d=n.getLast())==null?void 0:d.primary,m=e.getCurrentUniverSheetInstance().getActiveSheet();let S;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);S=_==null?void 0:_.getStrikeThrough()}r.next(!!(S&&S.s))}if((c===te.SetTextSelectionsOperation.id||c===te.SetInlineFormatCommand.id)&&o.getContextValue(l.EDITOR_ACTIVATED)&&o.getContextValue(l.FOCUSING_SHEET)){const h=zt(i);if(h==null)return;const m=(u=h.ts)==null?void 0:u.st;r.next((m==null?void 0:m.s)===l.BooleanNumber.TRUE)}});return r.next(!1),s.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function Al(i){const t=i.get(l.ICommandService),e=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService);return{id:Zo.id,tooltip:"toolbar.font",group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.SELECTOR,label:ir,positions:[C.MenuPosition.TOOLBAR_START],selections:C.FONT_FAMILY_LIST.map(o=>({label:{name:or,hoverable:!0},value:o.value})),disabled$:f.getCurrentSheetDisabled$(i),value$:new V.Observable(o=>{const r=C.FONT_FAMILY_LIST[0].value,s=t.onCommandExecuted(a=>{var m;const c=a.id;if(c!==f.SetRangeValuesMutation.id&&c!==f.SetSelectionsOperation.id)return;const d=(m=n.getLast())==null?void 0:m.primary,u=e.getCurrentUniverSheetInstance().getActiveSheet();let h;if(d!=null){const S=u.getRange(d.startRow,d.startColumn);h=S==null?void 0:S.getFontFamily()}o.next(h!=null?h:r)});return o.next(r),s.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function Dl(i){const t=i.get(l.ICommandService),e=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService),o=i.get(l.IContextService),r=f.getCurrentSheetDisabled$(i);return{id:$o.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:rr,props:{min:1,max:400,disabled$:r}},positions:[C.MenuPosition.TOOLBAR_START],selections:C.FONT_SIZE_LIST,disabled$:r,value$:new V.Observable(s=>{const c=t.onCommandExecuted(d=>{var h,m;const u=d.id;if(u===f.SetRangeValuesMutation.id||u===f.SetSelectionsOperation.id){const S=(h=n.getLast())==null?void 0:h.primary,_=e.getCurrentUniverSheetInstance().getActiveSheet();let g;if(S!=null){const v=_.getRange(S.startRow,S.startColumn);g=v==null?void 0:v.getFontSize()}s.next(g!=null?g:14)}if((u===te.SetTextSelectionsOperation.id||u===te.SetInlineFormatCommand.id)&&o.getContextValue(l.EDITOR_ACTIVATED)&&o.getContextValue(l.FOCUSING_SHEET)){const S=zt(i);if(S==null)return;const _=(m=S.ts)==null?void 0:m.fs;s.next(_!=null?_:14)}});return s.next(14),c.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function Pl(i){return{id:f.ResetTextColorCommand.id,type:C.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:In.id,disabled$:f.getCurrentSheetDisabled$(i)}}function Ll(i){const t=i.get(l.ICommandService),e=i.get(l.ThemeService);return{id:In.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON_SELECTOR,positions:[C.MenuPosition.TOOLBAR_START],selections:[{label:{name:Rn,hoverable:!1}}],value$:new V.Observable(n=>{const o=e.getCurrentTheme().textColor,r=t.onCommandExecuted(s=>{if(s.id===In.id){const a=s.params.value;n.next(a!=null?a:o)}});return n.next(o),r.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:f.getCurrentSheetDisabled$(i)}}function Hl(i){return{id:f.ResetBackgroundColorCommand.id,type:C.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:f.SetBackgroundColorCommand.id,disabled$:f.getCurrentSheetDisabled$(i)}}function Ul(i){const t=i.get(l.ICommandService),e=i.get(l.ThemeService);return{id:f.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON_SELECTOR,positions:[C.MenuPosition.TOOLBAR_START],icon:"PaintBucket",selections:[{label:{name:Rn,hoverable:!1}}],value$:new V.Observable(n=>{const o=e.getCurrentTheme().primaryColor,r=t.onCommandExecuted(s=>{if(s.id===f.SetBackgroundColorCommand.id){const a=s.params.value;n.next(a!=null?a:o)}});return n.next(o),r.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:f.getCurrentSheetDisabled$(i)}}const lr=[{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 Vl(i){const t=i.get(l.IUniverInstanceService),e=i.get(f.SelectionManagerService);return{id:f.SetHorizontalTextAlignCommand.id,icon:lr[0].icon,positions:[C.MenuPosition.TOOLBAR_START],tooltip:"toolbar.horizontalAlignMode.main",group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SELECTOR,selections:lr,value$:new V.Observable(n=>{const o=i.get(l.ICommandService).onCommandExecuted(r=>{var u;const s=r.id;if(s!==f.SetHorizontalTextAlignCommand.id&&s!==f.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.getHorizontalAlignment()}n.next(d!=null?d:l.HorizontalAlign.LEFT)});return n.next(l.HorizontalAlign.LEFT),o.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:f.getCurrentSheetDisabled$(i)}}const cr=[{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 kl(i){const t=i.get(l.IUniverInstanceService),e=i.get(f.SelectionManagerService);return{id:f.SetVerticalTextAlignCommand.id,icon:cr[0].icon,tooltip:"toolbar.verticalAlignMode.main",group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SELECTOR,positions:[C.MenuPosition.TOOLBAR_START],selections:cr,value$:new V.Observable(n=>{const o=i.get(l.ICommandService).onCommandExecuted(r=>{var u;const s=r.id;if(s!==f.SetVerticalTextAlignCommand.id&&s!==f.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.getVerticalAlignment()}n.next(d!=null?d:l.VerticalAlign.TOP)});return n.next(l.VerticalAlign.TOP),o.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:f.getCurrentSheetDisabled$(i)}}const dr=[{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 Bl(i){const t=i.get(f.SelectionManagerService),e=i.get(l.IUniverInstanceService);return{id:f.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:dr[0].icon,group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SELECTOR,positions:[C.MenuPosition.TOOLBAR_START],selections:dr,value$:new V.Observable(n=>{const o=i.get(l.ICommandService).onCommandExecuted(r=>{var u;const s=r.id;if(s!==f.SetTextWrapCommand.id&&s!==f.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.getWrapStrategy()}n.next(d!=null?d:l.WrapStrategy.OVERFLOW)});return n.next(l.WrapStrategy.OVERFLOW),o.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:f.getCurrentSheetDisabled$(i)}}const ur=[{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 Fl(i){const t=i.get(f.SelectionManagerService),e=i.get(l.IUniverInstanceService);return{id:f.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:ur[0].icon,group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SELECTOR,selections:ur,positions:[C.MenuPosition.TOOLBAR_START],value$:new V.Observable(n=>{const o=i.get(l.ICommandService).onCommandExecuted(r=>{var u,h;const s=r.id;if(s!==f.SetTextRotationCommand.id&&s!==f.SetSelectionsOperation.id)return;const a=(u=t.getLast())==null?void 0:u.primary,c=e.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),o.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:f.getCurrentSheetDisabled$(i)}}function wt(i){return new V.Observable(t=>t.next(!i.get(C.IClipboardInterfaceService).supportClipboard))}function Wl(){return{id:C.CopyCommand.id,group:C.MenuGroup.CONTEXT_MENU_FORMAT,type:C.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",positions:[C.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function jl(i){return{id:C.PasteCommand.id,group:C.MenuGroup.CONTEXT_MENU_FORMAT,type:C.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",disabled$:wt(i),positions:[C.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}const Tt="sheet.menu.paste-special";function zl(i){return{id:Tt,group:C.MenuGroup.CONTEXT_MENU_FORMAT,type:C.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",disabled$:wt(i),positions:[C.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function Yl(i){return{id:Do.id,type:C.MenuItemType.BUTTON,title:"rightClick.pasteValue",positions:[Tt],disabled$:wt(i)}}function Xl(i){return{id:Po.id,type:C.MenuItemType.BUTTON,title:"rightClick.pasteFormat",positions:[Tt],disabled$:wt(i)}}function $l(i){return{id:Lo.id,type:C.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",positions:[Tt],disabled$:wt(i)}}function Zl(i){return{id:Ho.id,type:C.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",positions:[Tt],disabled$:wt(i)}}function Gl(){return{id:f.SetWorksheetRowIsAutoHeightCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"AutoHeight",title:"rightClick.fitContent"}}const jt="sheet.menu.sheet-frozen";function Kl(){return{id:jt,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:[C.MenuPosition.CONTEXT_MENU]}}const Pi="sheet.header-menu.sheet-frozen";function Ql(){return{id:Pi,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:["rowHeaderContextMenu","colHeaderContextMenu"]}}function Jl(){return{id:Mn.id,type:C.MenuItemType.BUTTON,positions:[jt,Pi],title:"rightClick.freeze",icon:"FreezeToSelectedSingle"}}function ql(){return{id:er.id,type:C.MenuItemType.BUTTON,positions:[jt],title:"rightClick.freezeRow",icon:"FreezeRowSingle"}}function ec(){return{id:tr.id,type:C.MenuItemType.BUTTON,positions:[jt],title:"rightClick.freezeCol",icon:"FreezeColumnSingle"}}function tc(){return{id:nr.id,type:C.MenuItemType.BUTTON,positions:[jt,Pi],title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle"}}function nc(){return{id:Yo.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedRow"}}function ic(){return{id:Xo.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedColumn"}}function oc(i){const t=i.get(l.IUniverInstanceService),e=i.get(f.SelectionManagerService);function n(){var a;const r=t.getCurrentUniverSheetInstance().getActiveSheet(),s=(a=e.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(!r.getRowVisible(d))return!0;return!1}))}const o=i.get(l.ICommandService);return{id:f.SetSelectedRowsVisibleCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],title:"rightClick.showHideRow",hidden$:new V.Observable(r=>{const s=o.onCommandExecuted(a=>{(a.id===f.SetSelectionsOperation.id||a.id===f.SetRowHiddenMutation.id||a.id===f.SetRowVisibleMutation.id)&&r.next(!n())});return r.next(!n()),()=>s.dispose()})}}function rc(i){const t=i.get(l.IUniverInstanceService),e=i.get(f.SelectionManagerService);function n(){var a;const r=t.getCurrentUniverSheetInstance().getActiveSheet(),s=(a=e.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(!r.getColVisible(d))return!0;return!1})}const o=i.get(l.ICommandService);return{id:f.SetSelectedColsVisibleCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],title:"rightClick.showHideColumn",hidden$:new V.Observable(r=>{const s=o.onCommandExecuted(a=>{(a.id===f.SetSelectionsOperation.id||a.id===f.SetColHiddenMutation.id||a.id===f.SetColVisibleMutation.id)&&r.next(!n())});return r.next(!n()),()=>s.dispose()})}}function sc(i){const t=i.get(l.ICommandService),e=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService);return{id:f.SetRowHeightCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,icon:"AdjustHeight",positions:["rowHeaderContextMenu"],label:{name:Ai,props:{prefix:"rightClick.rowHeight",suffix:"px",min:2,max:1e3}},value$:new V.Observable(o=>{function r(){var u;const a=(u=n.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;a!=null&&(d=c.getRowHeight(a.startRow)),o.next(d!=null?d:0)}const s=t.onCommandExecuted(a=>{const c=a.id;if(c===f.SetRangeValuesMutation.id||c===f.SetSelectionsOperation.id)return r()});return r(),s.dispose})}}function ac(i){const t=i.get(l.ICommandService),e=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService);return{id:f.SetColWidthCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,icon:"AdjustWidth",positions:["colHeaderContextMenu"],label:{name:Ai,props:{prefix:"rightClick.columnWidth",suffix:"px",min:2,max:1e3}},value$:new V.Observable(o=>{function r(){var u;const a=(u=n.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d=0;a!=null&&(d=c.getColumnWidth(a.startColumn)),o.next(d)}const s=t.onCommandExecuted(a=>{const c=a.id;if(c===f.SetRangeValuesMutation.id||c===f.SetSelectionsOperation.id)return r()});return r(),s.dispose})}}function zt(i){var c;const t=i.get(l.IUniverInstanceService),e=i.get(te.TextSelectionManagerService),n=t.getUniverDocInstance(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),o=e.getActiveRange();if(n==null||o==null)return;const r=(c=n.getBody())==null?void 0:c.textRuns;if(r==null)return;const{startOffset:s}=o;return r.find(({st:d,ed:u})=>s>=d&&s<=u)}const lc={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",conditionalFormatting:"Conditional formatting",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"},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"},shortCutNotify:{title:"Kindly paste using keyboard shortcuts.",useShortCutInstead:"Detected Excel content. Use keyboard shortcut to paste."}},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",definedName:{managerTitle:"Manager named",managerDescription:"Create a defined name by selecting cells or formulas, and entering the desired name into the text box.",addButton:"Add a defined name",featureTitle:"Defined names",ratioRange:"Range",ratioFormula:"Formula",confirm:"Confirm",cancel:"Cancel",scopeWorkbook:"Workbook",inputNamePlaceholder:"Please enter a name(No space allowed)",inputCommentPlaceholder:"Please enter a comment",inputRangePlaceholder:"Please input range(No space allowed)",inputFormulaPlaceholder:"Please input a formula(No space allowed)",nameEmpty:"Name cannot be empty",nameDuplicate:"Name already exists",formulaOrRefStringEmpty:"Formula or reference string cannot be empty",formulaOrRefStringInvalid:"Invalid formula or reference string",defaultName:"DefinedName",updateButton:"Update",deleteButton:"Delete",deleteConfirmText:"Are you sure you want to delete this defined name?",nameConflict:"The name conflicts with the function name",nameInvalid:"The name is invalid",nameSheetConflict:"The name conflicts with the sheet name"}},hr={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:"更多函数",conditionalFormatting:"条件格式",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:"粘贴区域超出最大单元格数"},shortCutNotify:{title:"请使用快捷键粘贴",useShortCutInstead:"检测到 Excel 内容,请使用快捷键粘贴"}},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":"编辑表格",definedName:{managerTitle:"名称管理器",managerDescription:"通过选择单元格或公式,并在文本框中输入您想要的名称来创建一个定义名称。",addButton:"新建名称",featureTitle:"定义名称",ratioRange:"范围",ratioFormula:"公式",confirm:"确认",cancel:"取消",scopeWorkbook:"工作簿",inputNamePlaceholder:"请输入名称(必填)",inputCommentPlaceholder:"请输入备注",inputRangePlaceholder:"请输入范围(必填)",inputFormulaPlaceholder:"请输入公式(必填)",nameEmpty:"名称不能为空",nameDuplicate:"名称重复",formulaOrRefStringEmpty:"公式或引用字符串不能为空",formulaOrRefStringInvalid:"公式或引用字符串无效",defaultName:"DefinedName",updateButton:"修改",deleteButton:"删除",deleteConfirmText:"确定删除定义名称?",nameConflict:"与函数名称冲突",nameInvalid:"名称不包含空格或不允许的字符",nameSheetConflict:"名称与工作表名称冲突"}};class mr{constructor(){I(this,"_state",null);I(this,"_rect",null);I(this,"_focus",!1);I(this,"_state$",new V.BehaviorSubject(null));I(this,"state$",this._state$.asObservable());I(this,"_rect$",new V.BehaviorSubject(null));I(this,"rect$",this._rect$.asObservable());I(this,"_focus$",new V.BehaviorSubject(this._focus));I(this,"focus$",this._focus$.asObservable())}dispose(){this._state$.complete(),this._state=null,this._rect$.complete(),this._rect=null}setState(t){this._state=t,this._refresh(t)}getRect(){return this._rect}setRect(t){this._rect=t,this._rect$.next(t)}getState(){return this._state}setFocus(t=!1){this._focus=t,this._focus$.next(t)}_refresh(t){this._state$.next(t)}}const Yt=P.createIdentifier("univer.sheet-cell-editor-manager.service");class cc{constructor(){I(this,"_position",null);I(this,"_position$",new V.BehaviorSubject(null));I(this,"position$",this._position$.asObservable());I(this,"_focus",!1);I(this,"_focus$",new V.BehaviorSubject(this._focus));I(this,"focus$",this._focus$.asObservable());I(this,"_fxBtnClick$",new V.Subject);I(this,"fxBtnClick$",this._fxBtnClick$.asObservable());I(this,"_foldBtnStatus$",new V.Subject);I(this,"foldBtnStatus$",this._foldBtnStatus$.asObservable())}dispose(){this._position$.complete(),this._focus$.complete(),this._position=null,this._focus=!1}setPosition(t){this._position=t,this._refresh(t)}getPosition(){return this._position}setFocus(t=!1){this._focus=t,this._focus$.next(t)}handleFxBtnClick(t){this._fxBtnClick$.next(t)}handleFoldBtnClick(t){this._foldBtnStatus$.next(t)}_refresh(t){this._position$.next(t)}}const wn=P.createIdentifier("univer.sheet-formula-editor-manager.service");var dc=Object.defineProperty,uc=Object.getOwnPropertyDescriptor,hc=(i,t,e,n)=>{for(var o=n>1?void 0:n?uc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&dc(t,e,o),o},Sr=(i,t)=>(e,n)=>t(e,n,i);let Tn=class extends l.Disposable{constructor(t,e){super();I(this,"_previousSheetIndex",-1);this._commandService=t,this._univerInstanceService=e,this.disposeWithMe(this._commandService.beforeCommandExecuted(n=>{if(n.id===f.RemoveSheetMutation.id)return this._beforeAdjustActiveSheetOnRemoveSheet(n)})),this.disposeWithMe(this._commandService.onCommandExecuted((n,o)=>{if(n.id===f.RemoveSheetMutation.id)return this._adjustActiveSheetOnRemoveSheet(n);if(n.id===f.SetWorksheetHideMutation.id&&n.params.hidden)return this._adjustActiveSheetOnHideSheet(n);if(!(o!=null&&o.fromCollab)){if(n.id===f.InsertSheetMutation.id)return this._adjustActiveSheetOnInsertSheet(n);if(n.id===f.SetWorksheetHideMutation.id&&!n.params.hidden)return this._adjustActiveSheetOnShowSheet(n)}}))}_adjustActiveSheetOnHideSheet(t){const{unitId:e,subUnitId:n}=t.params,o=this._univerInstanceService.getUniverSheetInstance(e);if(!o||o.getActiveSheet().getSheetId()!==n)return;const s=o.getActiveSheetIndex(),a=_r(o,s);this._switchToNextSheet(e,a)}_beforeAdjustActiveSheetOnRemoveSheet(t){const{unitId:e,subUnitId:n}=t.params,o=this._univerInstanceService.getUniverSheetInstance(e);if(!o)return;const r=o.getSheetBySheetId(n);r&&(this._previousSheetIndex=o.getSheetIndex(r))}_adjustActiveSheetOnRemoveSheet(t){if(this._previousSheetIndex===-1)return;const{unitId:e}=t.params,n=this._univerInstanceService.getUniverSheetInstance(e);if(!n||n.getRawActiveSheet())return;const r=this._previousSheetIndex,s=r>=1?r-1:0,a=_r(n,s);this._switchToNextSheet(e,a)}_adjustActiveSheetOnInsertSheet(t){const{unitId:e,sheet:n}=t.params;this._switchToNextSheet(e,n.id)}_adjustActiveSheetOnShowSheet(t){const{unitId:e,subUnitId:n}=t.params;this._switchToNextSheet(e,n)}_switchToNextSheet(t,e){this._commandService.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:e})}};Tn=hc([l.OnLifecycle(l.LifecycleStages.Ready,Tn),Sr(0,l.ICommandService),Sr(1,l.IUniverInstanceService)],Tn);function _r(i,t){const e=i.getSheetSize();for(let n=t;n>-1;n--){const o=i.getSheetByIndex(n);if(!o.getConfig().hidden)return o.getSheetId()}for(let n=t;n<e;n++){const o=i.getSheetByIndex(n);if(!o.getConfig().hidden)return o.getSheetId()}throw new Error("[ActiveWorksheetController]: could not find the next unhidden sheet! Collaboration error perhaps.")}var mc=Object.defineProperty,Sc=Object.getOwnPropertyDescriptor,_c=(i,t,e,n)=>{for(var o=n>1?void 0:n?Sc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&mc(t,e,o),o},Xt=(i,t)=>(e,n)=>t(e,n,i);let En=class{constructor(i,t,e,n,o){this._injector=i,this._sheetInterceptorService=t,this._selectionManagerService=e,this._univerInstanceService=n,this._sheetSkeletonManagerService=o,this._initialize()}_getUndoRedoParamsOfAutoHeight(i){const{_univerInstanceService:t,_sheetSkeletonManagerService:e,_injector:n}=this,{skeleton:o}=e.getCurrent(),r=o.calculateAutoHeightInRange(i),s=t.getCurrentUniverSheetInstance(),a=s.getUnitId(),d={subUnitId:s.getActiveSheet().getSheetId(),unitId:a,rowsAutoHeightInfo:r},u=f.SetWorksheetRowAutoHeightMutationFactory(n,d);return{undos:[{id:f.SetWorksheetRowAutoHeightMutation.id,params:u}],redos:[{id:f.SetWorksheetRowAutoHeightMutation.id,params:d}]}}_initialize(){const{_sheetInterceptorService:i,_selectionManagerService:t}=this;i.interceptCommand({getMutations:e=>e.id!==f.SetRangeValuesCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(e.params.range)}),i.interceptCommand({getMutations:e=>e.id!==f.SetWorksheetRowIsAutoHeightCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(e.params.ranges)}),i.interceptCommand({getMutations:e=>{var r;if(e.id!==f.SetStyleCommand.id)return{redos:[],undos:[]};if(!["ff","fs","tr","tb"].includes((r=e.params)==null?void 0:r.style.type))return{redos:[],undos:[]};const o=t.getSelectionRanges();return o!=null&&o.length?this._getUndoRedoParamsOfAutoHeight(o):{redos:[],undos:[]}}})}};En=_c([l.OnLifecycle(l.LifecycleStages.Ready,En),Xt(0,P.Inject(P.Injector)),Xt(1,P.Inject(f.SheetInterceptorService)),Xt(2,P.Inject(f.SelectionManagerService)),Xt(3,P.Inject(l.IUniverInstanceService)),Xt(4,P.Inject(x.SheetSkeletonManagerService))],En);var fc=Object.defineProperty,gc=Object.getOwnPropertyDescriptor,pc=(i,t,e,n)=>{for(var o=n>1?void 0:n?gc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&fc(t,e,o),o},He=(i,t)=>(e,n)=>t(e,n,i);let yn=class extends l.RxDisposable{constructor(i,t,e,n,o,r,s,a,c,d,u){var h;super(),this._injector=i,this._currentUniverSheet=t,this._commandService=e,this._contextService=n,this._configService=o,this._sheetClipboardService=r,this._clipboardInterfaceService=s,this._messageService=a,this._sheetSkeletonManagerService=c,this._localService=d,this._textSelectionRenderManager=u,this._init(),(h=this._textSelectionRenderManager)==null||h.onPaste$.pipe(V.takeUntil(this.dispose$)).subscribe(m=>{var v,M;if(!ie(this._contextService))return;m.event.preventDefault();const S=m.event,_=(v=S.clipboardData)==null?void 0:v.getData("text/html"),g=(M=S.clipboardData)==null?void 0:M.getData("text/plain");this._sheetClipboardService.legacyPaste(_,g)})}_init(){[Ao,ya,vt].forEach(t=>this.disposeWithMe(this._commandService.registerMultipleCommand(t))),[Do,Po,Lo,Ho].forEach(t=>this.disposeWithMe(this._commandService.registerCommand(t))),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initCopyingHooks())),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingHook()));const i=this._initSpecialPasteHooks().map(t=>this._sheetClipboardService.addClipboardHook(t));this.disposeWithMe({dispose:()=>i.forEach(t=>t.dispose())})}_initCopyingHooks(){const i=this;let t=null;return{id:ve.DEFAULT_COPY,isDefaultHook:!0,onBeforeCopy(e,n){t=i._getWorksheet(e,n)},onCopyCellContent(e,n){const o=t.getCell(e,n);return o?l.extractPureTextFromCell(o):""},onCopyCellStyle:(e,n,o,r)=>{const s={};(o||r)&&(s.rowspan=`${o||1}`,s.colspan=`${r||1}`);const c=t.getRange(e,n).getTextStyle();let d="";return c&&(d=l.handleStyleToString(c)),d&&(s.style=d),s},onCopyColumn(e){return{width:`${t.getColumnWidth(e)}`}},onCopyRow(e){return{style:`height: ${t.getRowHeight(e)}px;`}},onAfterCopy(){t=null}}}_initPastingHook(){const i=this;let t=null,e=null,n=null;return{id:ve.DEFAULT_PASTE,isDefaultHook:!0,onBeforePaste({unitId:o,subUnitId:r,range:s}){n=i._getWorksheet(o,r),t=o,e=r;const a=i._configService.getConfig(f.MAX_CELL_PER_SHEET_KEY),{endRow:c,endColumn:d}=s;return a&&c*d>a?(i._messageService.show({type:le.MessageType.Error,content:i._localService.t("clipboard.paste.exceedMaxCells")}),!1):!0},onPasteRows(o,r){const{range:s}=o,a=[],c=n.getMaxRows(),d=s.endRow-c,u=r.length-d;if(d>0){const S={};r.slice(u).forEach((g,v)=>{const{style:M,height:R}=g||{};if(M){const b=M.split(";");let E=l.DEFAULT_WORKSHEET_ROW_HEIGHT;b.find(T=>{T=T.toLowerCase();const y=C.textTrim(T.substr(0,T.indexOf(":"))),O=C.textTrim(T.substr(T.indexOf(":")+1));return y==="height"?(E=Number.parseFloat(O),!0):!1}),S[v]={h:E,hd:l.BooleanNumber.FALSE}}else R&&(S[v]={h:Number.parseFloat(R),hd:l.BooleanNumber.FALSE})});const _={unitId:t,subUnitId:e,range:{...s,startRow:c},rowInfo:S};a.push({id:f.InsertRowMutation.id,params:_})}const h={};r.slice(0,u).forEach((S,_)=>{const{style:g,height:v}=S;if(g){const M=g.split(";");let R=l.DEFAULT_WORKSHEET_ROW_HEIGHT;M.find(b=>{b=b.toLowerCase();const E=C.textTrim(b.substr(0,b.indexOf(":"))),T=C.textTrim(b.substr(b.indexOf(":")+1));return E==="height"?(R=Number.parseFloat(T),!0):!1}),h[_+s.startRow]=R}else v&&(h[_+s.startRow]=Number.parseFloat(v))});const m={unitId:t,subUnitId:e,ranges:[{...s,endRow:Math.min(s.endRow,c)}],rowHeight:h};return a.push({id:f.SetWorksheetRowHeightMutation.id,params:m}),{redos:a,undos:[]}},onPasteColumns(o,r,s){var _;const{range:a}=o,c=[],d=n.getMaxColumns(),u=a.endColumn-d,h=r.length-u,m=(_=i._configService.getConfig(l.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?_:l.DEFAULT_WORKSHEET_COLUMN_WIDTH;if(u>0){const g={unitId:t,subUnitId:e,range:{...a,startColumn:d},colInfo:r.slice(h).map(v=>({w:v.width?+v.width:m,hd:l.BooleanNumber.FALSE}))};c.push({id:f.InsertColMutation.id,params:g})}const S={unitId:t,subUnitId:e,ranges:[{...a,endRow:Math.min(a.endColumn,d)}],colWidth:r.slice(0,h).map(g=>g.width?+g.width:m)};return c.push({id:f.SetWorksheetColWidthMutation.id,params:S}),{redos:c,undos:[]}},onPastePlainText(o,r,s){return i._onPastePlainText(o,r,s)},onPasteCells(o,r,s,a){return i._onPasteCells(o,r,s,a)},onAfterPaste(o){n=null}}}_generateDocumentDataModelSnapshot(i){var s;const t=this._sheetSkeletonManagerService.getCurrent();if(t==null)return null;const{skeleton:e}=t,n=(s=e.getBlankCellDocumentModel())==null?void 0:s.documentModel,r={...n==null?void 0:n.getSnapshot(),...i};return n==null||n.reset(r),n==null?void 0:n.getSnapshot()}_onPastePlainText(i,t,e){const{range:n,unitId:o,subUnitId:r}=i;let s;if(/\r|\n/.test(t)){const c=yo(t),d=this._generateDocumentDataModelSnapshot({body:c});s={[n.startRow]:{[n.startColumn]:{p:d}}}}else s={[n.startRow]:{[n.startColumn]:{v:t}}};const a={unitId:o,subUnitId:r,cellValue:s};return{redos:[{id:f.SetRangeValuesMutation.id,params:a}],undos:[{id:f.SetRangeValuesMutation.id,params:f.SetRangeValuesUndoMutationFactory(this._injector,a)}]}}_onPasteCells(i,t,e,n){const o={get:this._injector.get.bind(this._injector)};return ta(i,t,e,n,o)}_initSpecialPasteHooks(){const i={get:this._injector.get.bind(this._injector)},t=this,e={id:ve.SPECIAL_PASTE_VALUE,specialPasteInfo:{label:"specialPaste.value"},onPasteCells:(s,a,c,d)=>{const u=t._currentUniverSheet.getCurrentUniverSheetInstance();return u.getUnitId(),u.getActiveSheet().getSheetId(),wo(a,c,i)}},n={id:ve.SPECIAL_PASTE_FORMAT,specialPasteInfo:{label:"specialPaste.format"},onPasteCells(s,a,c,d){const u=t._currentUniverSheet.getCurrentUniverSheetInstance();u.getUnitId(),u.getActiveSheet().getSheetId();const h=[],m=[],{undos:S,redos:_}=Eo(a,c,i);h.push(..._),m.push(...S);const{undos:g,redos:v}=ui(a,c,i);h.push(...v),m.push(...g);const{undos:M,redos:R}=To(a,c,i);return h.push(...R),m.push(...M),{undos:m,redos:h}}},o={id:ve.SPECIAL_PASTE_COL_WIDTH,specialPasteInfo:{label:"specialPaste.colWidth"},onPasteCells(){return{undos:[],redos:[]}},onPasteColumns(s,a,c){var E;const d=t._currentUniverSheet.getCurrentUniverSheetInstance(),u=d.getUnitId(),h=d.getActiveSheet().getSheetId(),m=[],S=t._getWorksheet(u,h),{range:_}=s,g=S.getMaxColumns(),v=_.endColumn-g,M=a.length-v,R=(E=t._configService.getConfig(l.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?E:l.DEFAULT_WORKSHEET_COLUMN_WIDTH,b={unitId:u,subUnitId:h,ranges:[{..._,endRow:Math.min(_.endColumn,g)}],colWidth:a.slice(0,M).map(T=>T.width?+T.width:R)};return m.push({id:f.SetWorksheetColWidthMutation.id,params:b}),m.push({id:f.SetWorksheetColWidthMutation.id,params:b}),{redos:m,undos:[]}}},r={id:ve.SPECIAL_PASTE_BESIDES_BORDER,specialPasteInfo:{label:"specialPaste.besidesBorder"},onPasteCells(s,a,c,d){t._currentUniverSheet.getCurrentUniverSheetInstance();const u=[],h=[],{range:m,unitId:S,subUnitId:_}=a,{startColumn:g,startRow:v,endColumn:M,endRow:R}=m,b=new l.ObjectMatrix;c.forValue((N,D,k)=>{const A=k.s;typeof A=="object"&&b.setValue(N+v,D+g,{s:{...A,bd:void 0},v:k.v})});const E={unitId:S,subUnitId:_,cellValue:b.getData()};u.push({id:f.SetRangeValuesMutation.id,params:E});const T=f.SetRangeValuesUndoMutationFactory(i,E);h.push({id:f.SetRangeValuesMutation.id,params:T});const{undos:y,redos:O}=ui(a,c,i);return h.push(...y),u.push(...O),{redos:u,undos:h}}};return[e,n,o,r]}_getWorksheet(i,t){var n;const e=(n=this._currentUniverSheet.getUniverSheetInstance(i))==null?void 0:n.getSheetBySheetId(t);if(!e)throw new Error(`[SheetClipboardController]: cannot find a worksheet with unitId ${i} and subUnitId ${t}.`);return e}};yn=pc([l.OnLifecycle(l.LifecycleStages.Steady,yn),He(0,P.Inject(P.Injector)),He(1,l.IUniverInstanceService),He(2,l.ICommandService),He(3,l.IContextService),He(4,l.IConfigService),He(5,pt),He(6,C.IClipboardInterfaceService),He(7,C.IMessageService),He(8,P.Inject(x.SheetSkeletonManagerService)),He(9,P.Inject(l.LocaleService)),He(10,P.Optional(w.ITextSelectionRenderManager))],yn);var vc=Object.defineProperty,Cc=Object.getOwnPropertyDescriptor,Ic=(i,t,e,n)=>{for(var o=n>1?void 0:n?Cc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&vc(t,e,o),o},$t=(i,t)=>(e,n)=>t(e,n,i);let On=class extends l.Disposable{constructor(i,t,e,n,o){super(),this._currentUniverService=i,this._contextMenuService=t,this._renderManagerService=e,this._selectionManagerService=n,this._selectionRenderService=o,this._currentUniverService.currentSheet$.subscribe(r=>{if(r==null)throw new Error("workbook is null");this._addListeners()})}_addListeners(){const i=Ie(this._currentUniverService,this._renderManagerService);if(!i)return;const t=i.spreadsheet.onPointerDownObserver,e=t.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,g=a.offsetY;switch(u){case l.RANGE_TYPE.ROW:return h.startY<=g&&h.endY>=g;case l.RANGE_TYPE.COLUMN:return h.startX<=_&&h.endX>=_;default:return h.startX<=_&&h.endX>=_&&h.startY<=g&&h.endY>=g}},S=_=>{this._contextMenuService.triggerContextMenu(a,_)};m()?u===l.RANGE_TYPE.COLUMN?S(he.COL_HEADER_CONTEXT_MENU):u===l.RANGE_TYPE.ROW?S(he.ROW_HEADER_CONTEXT_MENU):S(C.MenuPosition.CONTEXT_MENU):S(C.MenuPosition.CONTEXT_MENU)}});this.disposeWithMe(l.toDisposable(()=>t.remove(e)));const o=i.spreadsheetRowHeader.onPointerDownObserver.add(a=>{a.button===2&&this._contextMenuService.triggerContextMenu(a,he.ROW_HEADER_CONTEXT_MENU)});this.disposeWithMe(l.toDisposable(()=>t.remove(o)));const s=i.spreadsheetColumnHeader.onPointerDownObserver.add(a=>{a.button===2&&this._contextMenuService.triggerContextMenu(a,he.COL_HEADER_CONTEXT_MENU)});this.disposeWithMe(l.toDisposable(()=>t.remove(s)))}};On=Ic([l.OnLifecycle(l.LifecycleStages.Rendered,On),$t(0,l.IUniverInstanceService),$t(1,C.IContextMenuService),$t(2,w.IRenderManagerService),$t(3,P.Inject(f.SelectionManagerService)),$t(4,ge)],On);var Mc=Object.defineProperty,Rc=Object.getOwnPropertyDescriptor,bc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Rc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Mc(t,e,o),o},Li=(i,t)=>(e,n)=>t(e,n,i);let xn=class extends l.RxDisposable{constructor(i,t,e){super(),this._currentUniverService=i,this._renderManagerService=t,this._undoRedoService=e,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialNormalInput(),this._listenEditorBlur()}_listenEditorBlur(){this._currentUniverService.currentDoc$.pipe(V.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(t=>{const e=t.getConfig();i[t.getSheetId()]={cellData:new l.ObjectMatrix(e.cellData),rowCount:e.rowCount,columnCount:e.columnCount,rowData:e.rowData,columnData:e.columnData}})}_commandExecutedListener(){}_getDocObject(){return te.getDocObject(this._currentUniverService,this._renderManagerService)}};xn=bc([l.OnLifecycle(l.LifecycleStages.Rendered,xn),Li(0,l.IUniverInstanceService),Li(1,w.IRenderManagerService),Li(2,P.Inject(l.IUndoRedoService))],xn);const fr=[C.KeyCode.ARROW_DOWN,C.KeyCode.ARROW_UP,C.KeyCode.ARROW_LEFT,C.KeyCode.ARROW_RIGHT],wc=[C.KeyCode.ENTER,C.KeyCode.TAB,...fr];function Tc(){const i=[];for(const t of fr)i.push({id:Bt.id,binding:t,preconditions:e=>fn(e),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:t,isShift:!1}}),i.push({id:Bt.id,binding:t|C.MetaKeys.SHIFT,preconditions:e=>fn(e),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:t,isShift:!0}});return i}const Ec={id:De.id,binding:C.KeyCode.ENTER,description:"shortcut.sheet.toggle-editing",group:"4_sheet-edit",preconditions:i=>fn(i),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:C.KeyCode.ENTER}},yc={id:De.id,binding:C.KeyCode.TAB,preconditions:i=>fn(i),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:C.KeyCode.TAB}},Oc={id:De.id,binding:C.KeyCode.ESC,description:"shortcut.sheet.abort-editing",group:"4_sheet-edit",preconditions:i=>po(i),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:C.KeyCode.ESC}},xc={id:te.BreakLineCommand.id,description:"shortcut.sheet.break-line",group:"4_sheet-edit",preconditions:i=>po(i),binding:C.KeyCode.ENTER|C.MetaKeys.ALT},Nc={id:te.DeleteLeftCommand.id,preconditions:i=>Ls(i)||vo(i),binding:C.KeyCode.BACKSPACE},Ac={id:De.id,description:"shortcut.sheet.delete-and-start-editing",group:"4_sheet-edit",preconditions:i=>ie(i)&&!vo(i),binding:C.KeyCode.BACKSPACE,staticParameters:{visible:!0,eventType:w.DeviceInputEventType.Keyboard,keycode:C.KeyCode.BACKSPACE}};var Dc=Object.defineProperty,Pc=Object.getOwnPropertyDescriptor,Lc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Pc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Dc(t,e,o),o},Fe=(i,t)=>(e,n)=>t(e,n,i);function Hc(i){const{textRuns:t=[],paragraphs:e=[]}=i;return t.some(n=>n.ts&&!l.Tools.isEmptyObject(n.ts))||e.some(n=>n.bullet)||e.length>=2}let Nn=class extends l.Disposable{constructor(t,e,n,o,r,s,a,c,d,u){super();I(this,"_cursorChangeObservers");I(this,"_editorVisiblePrevious",!1);I(this,"_isCursorChange",0);this._currentUniverService=t,this._renderManagerService=e,this._commandService=n,this._editorBridgeService=o,this._contextService=r,this._cellEditorManagerService=s,this._lexerTreeBuilder=a,this._undoRedoService=c,this._selectionManagerService=d,this._editorService=u,this._initialize(),this._commandExecutedListener()}dispose(){const t=this._getEditorObject();if(t==null)return;const{document:e}=t;e.onPointerDownObserver.remove(this._cursorChangeObservers),super.dispose()}_initialize(){this._initialExitInput(),this._cursorStateListener()}_initialExitInput(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(async t=>{const{visible:e,keycode:n,eventType:o}=t;if(e===this._editorVisiblePrevious)return;if(this._editorVisiblePrevious=e,e===!0){this._isCursorChange=o===w.DeviceInputEventType.PointerDown?2:1;return}this._isCursorChange=0;const r=this._selectionManagerService.getSelections(),s=this._selectionManagerService.getCurrent();if(s==null)return;const{unitId:a,sheetId:c,pluginName:d}=s;if(this._exitInput(t),n===C.KeyCode.ESC){r&&this._commandService.syncExecuteCommand(f.SetSelectionsOperation.id,{unitId:a,subUnitId:c,pluginName:d,selections:r});return}const u=this._editorBridgeService.getEditCellState();if(u==null)return;const{unitId:h,sheetId:m,row:S,column:_,documentLayoutObject:g}=u;if(this._editorBridgeService.getEditorDirty()===!1){this._moveCursor(n);return}const M=this._currentUniverService.getUniverSheetInstance(h),R=M==null?void 0:M.getSheetBySheetId(m);if(R==null)return;const b=Uc(R.getCellRaw(S,_)||{},g,this._lexerTreeBuilder);if(b==null){this._moveCursor(n);return}const E={subUnitId:m,unitId:h,workbook:M,worksheet:R,row:S,col:_};a===h&&m!==c&&this._editorBridgeService.isForceKeepVisible()&&this._commandService.executeCommand(f.SetWorksheetActivateCommand.id,{subUnitId:m,unitId:h}),this._selectionManagerService.refreshSelection();const T=this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT)(b,E),y=await this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT_ASYNC)(Promise.resolve(T),E);this._commandService.executeCommand(f.SetRangeValuesCommand.id,{subUnitId:m,unitId:h,range:{startRow:S,startColumn:_,endRow:S,endColumn:_},value:y}),this._moveCursor(n)}))}_exitInput(t){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:t.visible});const e=this._editorBridgeService.getCurrentEditorId();e==null||!this._editorService.isSheetEditor(e)||(this._undoRedoService.clearUndoRedo(e),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))}_moveCursor(t){if(t==null||!wc.includes(t))return;let e=l.Direction.LEFT;switch(t){case C.KeyCode.ENTER:e=l.Direction.DOWN;break;case C.KeyCode.TAB:e=l.Direction.RIGHT;break;case C.KeyCode.ARROW_DOWN:e=l.Direction.DOWN;break;case C.KeyCode.ARROW_UP:e=l.Direction.UP;break;case C.KeyCode.ARROW_LEFT:e=l.Direction.LEFT;break;case C.KeyCode.ARROW_RIGHT:e=l.Direction.RIGHT;break}t===C.KeyCode.ENTER||t===C.KeyCode.TAB?this._commandService.executeCommand(lt.id,{keycode:t,direction:e}):this._commandService.executeCommand(be.id,{direction:e})}_cursorStateListener(){const t=this._getEditorObject();if(t==null)return;const{document:e}=t;this.disposeWithMe(l.toDisposable(e.onPointerDownObserver.add(()=>{this._isCursorChange===1&&(this._isCursorChange=2)})))}_commandExecutedListener(){const t=[Bt.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(t.includes(e.id)){const n=e.params,{keycode:o,isShift:r}=n;if(o!=null&&this._isCursorChange===2){this._moveInEditor(o,r);return}this._editorBridgeService.changeVisible(n)}}))}_moveInEditor(t,e){let n=l.Direction.LEFT;t===C.KeyCode.ARROW_DOWN?n=l.Direction.DOWN:t===C.KeyCode.ARROW_UP?n=l.Direction.UP:t===C.KeyCode.ARROW_RIGHT&&(n=l.Direction.RIGHT),e?this._commandService.executeCommand(te.MoveSelectionOperation.id,{direction:n}):this._commandService.executeCommand(te.MoveCursorOperation.id,{direction:n})}_getEditorObject(){return hn(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};Nn=Lc([l.OnLifecycle(l.LifecycleStages.Rendered,Nn),Fe(0,l.IUniverInstanceService),Fe(1,w.IRenderManagerService),Fe(2,l.ICommandService),Fe(3,we),Fe(4,l.IContextService),Fe(5,Yt),Fe(6,P.Inject(G.LexerTreeBuilder)),Fe(7,l.IUndoRedoService),Fe(8,P.Inject(f.SelectionManagerService)),Fe(9,C.IEditorService)],Nn);function Uc(i,t,e){i=l.Tools.deepClone(i);const{documentModel:n}=t;if(n==null)return null;const o=n.getSnapshot(),{body:r}=o;if(r==null)return null;i.t=void 0;const s=r.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=e.checkIfAddBracket(c);for(let u=0;u<d;u++)c+=G.matchToken.CLOSE_BRACKET;i.f=c,i.v=null,i.p=null}else if(Hc(r))r.dataStream===`\r
|
|
19
|
-
`?(i.v="",i.f=null,i.si=null,i.p=null):(i.p=o,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
|
-
`,o=[{startIndex:0}]):t.isInArrayFormulaRange===!0&&(r=(e==null?void 0:e.textRuns)||[]),this._syncContentAndRender(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,n,o,r),this._autoScroll())}_commandExecutedListener(){const t=[te.RichTextEditingMutation.id,C.SetEditorResizeOperation.id],e=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(o=>{var r,s;if(t.includes(o.id)){const a=o.params,{unitId:c}=a;if(e.includes(c)){const d=this._univerInstanceService.getUniverDocInstance(c),u=(r=d==null?void 0:d.getBody())==null?void 0:r.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=[f.SetRangeValuesMutation.id,f.MoveRangeMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(o=>{var r,s,a,c,d;if(n.includes(o.id)){const u=this._editorBridgeService.getLatestEditCellState();if(u==null)return;let h=!1;const{row:m,column:S}=u;if(o.id===f.SetRangeValuesMutation.id&&o.params?(s=(r=o.params.cellValue)==null?void 0:r[m])!=null&&s[S]&&(h=!0):o.id===f.MoveRangeMutation.id&&o.params&&(c=(a=o.params.to.value)==null?void 0:a[m])!=null&&c[S]&&(h=!0),h){const _=(d=u.documentLayoutObject.documentModel)==null?void 0:d.getBody();if(_==null)return;const{dataStream:g,paragraphs:v=[]}=_;this._syncContentAndRender(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,g,v),this._autoScroll()}}}))}_syncContentAndRender(t,e,n,o=[]){var h;const r=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=this._docSkeletonManagerService.getSkeletonByUnitId(t),a=this._univerInstanceService.getUniverDocInstance(t),c=this._docViewModelManagerService.getViewModel(t);if(a==null||c==null||s==null)return;a.getBody().dataStream=e,a.getBody().paragraphs=this._clearParagraph(n),t===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(a.getBody().textRuns=[]),o.length>0&&(a.getBody().textRuns=o),c.reset(a);const{skeleton:d}=s,u=this._renderManagerService.getRenderById(t);u!=null&&(d.calculate(),r.includes(t)&&((h=u.mainComponent)==null||h.makeDirty()))}_clearParagraph(t){const e=l.Tools.deepClone(t);for(const n of e)n.paragraphStyle&&(n.paragraphStyle.horizontalAlign=l.HorizontalAlign.UNSPECIFIED);return e}_autoScroll(){var _,g;const t=(_=this._docSkeletonManagerService.getSkeletonByUnitId(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))==null?void 0:_.skeleton,e=this._formulaEditorManagerService.getPosition(),n=this._renderManagerService.getRenderById(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),o=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(t==null||e==null||n==null||o==null)return;const{marginTop:r=0,marginBottom:s=0}=o.getSnapshot().documentStyle,{scene:a,mainComponent:c}=n;let{actualHeight:d}=t.getActualSize();d+=r+s;const{width:u,height:h}=e,m=a.getViewport(te.VIEWPORT_KEY.VIEW_MAIN);let S=m==null?void 0:m.getScrollBar();a.transformByState({width:u,height:d}),c==null||c.resize(u,d),d>h?S==null?m&&new w.ScrollBar(m,{enableHorizontal:!1,barSize:8}):m==null||m.resetSizeAndScrollBar():(S=null,m==null||m.scrollTo({x:0,y:0}),(g=m==null?void 0:m.getScrollBar())==null||g.dispose())}};An=Bc([l.OnLifecycle(l.LifecycleStages.Steady,An),We(0,l.IUniverInstanceService),We(1,w.IRenderManagerService),We(2,we),We(3,l.ICommandService),We(4,l.IContextService),We(5,wn),We(6,l.IUndoRedoService),We(7,P.Inject(te.DocSkeletonManagerService)),We(8,P.Inject(te.DocViewModelManagerService)),We(9,P.Inject(te.TextSelectionManagerService))],An);const gr={sheetFooterBarHeight:"36",sheetContainer:"univer-sheet-container"};var Fc=Object.defineProperty,Wc=Object.getOwnPropertyDescriptor,jc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Wc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Fc(t,e,o),o},Ee=(i,t)=>(e,n)=>t(e,n,i);const pr=-1e3,vr=5,zc=2;let Dn=class extends l.Disposable{constructor(t,e,n,o,r,s,a,c,d,u,h,m){super();I(this,"_editorVisiblePrevious",!1);this._docSkeletonManagerService=t,this._docViewModelManagerService=e,this._contextService=n,this._currentUniverService=o,this._renderManagerService=r,this._editorBridgeService=s,this._cellEditorManagerService=a,this._textSelectionRenderManager=c,this._textSelectionManagerService=d,this._commandService=u,this._localService=h,this._editorService=m,this._initialize(),this._commandExecutedListener()}dispose(){super.dispose()}_initialize(){this._initialEditFocusListener(),this._initialStartEdit(),this._initialKeyboardListener(),this._initialCursorSync(),this._listenEditorFocus()}_listenEditorFocus(){const t=this._getEditorObject();t!=null&&this.disposeWithMe(l.toDisposable(t.document.onPointerDownObserver.add(()=>{var e;if(this._editorBridgeService.isVisible()){const n=this._editorBridgeService.getEditCellState(),o=this._editorBridgeService.getCurrentEditorId();if(n==null||o==null||!this._editorService.isSheetEditor(o))return;const r=(e=this._docSkeletonManagerService.getSkeletonByUnitId(o))==null?void 0:e.skeleton;if(r==null)return;const{position:s,documentLayoutObject:a,canvasOffset:c,scaleX:d,scaleY:u}=n;this._fitTextSize(s,c,r,a,d,u)}})))}_initialCursorSync(){this.disposeWithMe(this._cellEditorManagerService.focus$.subscribe(()=>{this._textSelectionRenderManager.sync()}))}_initialEditFocusListener(){this.disposeWithMe(this._editorBridgeService.currentEditCellState$.subscribe(t=>{if(t==null||this._editorBridgeService.isForceKeepVisible())return;const{position:e,documentLayoutObject:n,scaleX:o,editorUnitId:r}=t;if(this._getEditorObject()==null)return;const{startX:a,endX:c}=e,{textRotation:d,wrapStrategy:u,documentModel:h}=n,{vertexAngle:m}=w.convertTextRotation(d);h.updateDocumentId(r),u===l.WrapStrategy.WRAP&&m===0&&h.updateDocumentDataPageSize((c-a)/o),this._currentUniverService.changeDoc(r,h),this._contextService.setContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN,!0),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}]),this._textSelectionRenderManager.activate(pr,pr)}))}_fitTextSize(t,e,n,o,r=1,s=1){const{startX:a,startY:c,endX:d,endY:u}=t,h=o.documentModel;if(h==null)return;const{actualWidth:m,actualHeight:S}=this._predictingSize(t,e,n,o,r,s),{verticalAlign:_,paddingData:g,fill:v}=o;let M=d-a,R=u-c;if(M<m&&(M=m),R<S)R=S,h.updateDocumentDataMargin(g);else{let b=R-S||0;_===l.VerticalAlign.MIDDLE?b=(R-S)/2:_===l.VerticalAlign.TOP&&(b=g.t||0),b/=s,b=b<(g.t||0)?g.t||0:b,h.updateDocumentDataMargin({t:b})}n.calculate(),this._editAreaProcessing(M,R,t,e,v,r,s)}_predictingSize(t,e,n,o,r=1,s=1){const{startX:a,endX:c}=t,{textRotation:d,wrapStrategy:u}=o,h=o.documentModel,{vertexAngle:m}=w.convertTextRotation(d),S=document.body.clientWidth;if(u===l.WrapStrategy.WRAP&&m===0){const{actualWidth:v,actualHeight:M}=n.getActualSize();return{actualWidth:v*r,actualHeight:M*s}}h==null||h.updateDocumentDataPageSize((S-a-e.left)/r),n.calculate();const _=n.getActualSize();let g=c-a;return g<_.actualWidth*r+vr*r&&(g=_.actualWidth*r+vr*r),h==null||h.updateDocumentDataPageSize(g/r),h==null||h.updateDocumentRenderConfig({horizontalAlign:l.HorizontalAlign.UNSPECIFIED,cellValueType:void 0}),{actualWidth:g,actualHeight:_.actualHeight*s}}_editAreaProcessing(t,e,n,o,r,s=1,a=1){var T;const c=this._getEditorObject();if(c==null)return;let{startX:d,startY:u}=n;const{document:h,scene:m,engine:S}=c,_=m.getViewport(te.VIEWPORT_KEY.VIEW_MAIN),g=document.body.clientHeight-u-Number.parseFloat(gr.sheetFooterBarHeight)-o.top-zc*2,v=document.body.clientWidth-d-o.left;let M=e,R=_==null?void 0:_.getScrollBar();M>g?(M=g,R==null?_&&new w.ScrollBar(_,{enableHorizontal:!1,barSize:8}):_==null||_.resetSizeAndScrollBar()):(R=null,(T=_==null?void 0:_.getScrollBar())==null||T.dispose()),t+=(R==null?void 0:R.barSize)||0,t>v&&(t=v),d-=w.FIX_ONE_PIXEL_BLUR_OFFSET,u-=w.FIX_ONE_PIXEL_BLUR_OFFSET,this._addBackground(m,t/s,e/a,r);const{scaleX:b,scaleY:E}=m.getPrecisionScale();m.transformByState({width:t/s,height:e/a,scaleX:s,scaleY:a}),h.resize(t/s,e/a),requestIdleCallback(()=>{S.resizeBySize(w.fixLineWidthByScale(t,b),w.fixLineWidthByScale(M,E))}),this._cellEditorManagerService.setState({startX:d,startY:u,endX:t+d,endY:M+u,show:!0})}_addBackground(t,e,n,o){const r="_backgroundRectHelperColor_",s=t.getObject(r);s==null&&o==null||(s==null?t.addObjects([new w.Rect(r,{width:e,height:n,fill:o,evented:!1})],te.DOCS_COMPONENT_MAIN_LAYER_INDEX):o==null?s.dispose():(s.setProps({fill:o}),s.transformByState({width:e,height:n})))}_initialStartEdit(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{var T,y;const{visible:e,eventType:n,keycode:o}=t;if(e===this._editorVisiblePrevious)return;if(this._editorVisiblePrevious=e,e===!1){this._setOpenForCurrent(null,null);return}const r=this._editorBridgeService.getEditCellState();if(r==null)return;const{position:s,documentLayoutObject:a,canvasOffset:c,scaleX:d,scaleY:u,editorUnitId:h,unitId:m,sheetId:S,isInArrayFormulaRange:_=!1}=r,g=this._getEditorObject();if(g==null)return;this._setOpenForCurrent(m,S);const{document:v,scene:M}=g;this._contextService.setContextValue(l.EDITOR_ACTIVATED,!0);const{documentModel:R}=a,b=this._docSkeletonManagerService.getSkeletonByUnitId(h);if(b==null||R==null)return;const{skeleton:E}=b;if(this._fitTextSize(s,c,E,a,d,u),n===w.DeviceInputEventType.Keyboard||n===w.DeviceInputEventType.Dblclick&&_){const O=l.Tools.deepClone(R.snapshot),N=this._docViewModelManagerService.getViewModel(h);if(N==null)return;this._resetBodyStyle(O.body,!!_),R.reset(O),N.reset(R),v.makeDirty(),(o===C.KeyCode.BACKSPACE||n===w.DeviceInputEventType.Dblclick)&&(E.calculate(),this._editorBridgeService.changeEditorDirty(!0)),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}])}else if(n===w.DeviceInputEventType.Dblclick){const O=R.getBody().dataStream.length-2||0;(T=M.getViewport(te.VIEWPORT_KEY.VIEW_MAIN))==null||T.scrollTo({y:Number.POSITIVE_INFINITY}),this._textSelectionManagerService.replaceTextRanges([{startOffset:O,endOffset:O}])}(y=this._renderManagerService.getRenderById(m))==null||y.scene.resetCursor()}))}_resetBodyStyle(t,e=!1){t.dataStream=l.DEFAULT_EMPTY_DOCUMENT_VALUE,t.textRuns!=null&&(t.textRuns.length===1&&!e?(t.textRuns[0].st=0,t.textRuns[0].ed=1):t.textRuns=void 0),t.paragraphs!=null&&(t.paragraphs.length===1?t.paragraphs[0].startIndex=0:t.paragraphs=[{startIndex:0}]),t.sectionBreaks!=null&&(t.sectionBreaks=void 0),t.tables!=null&&(t.tables=void 0),t.customRanges!=null&&(t.customRanges=void 0),t.customBlocks!=null&&(t.customBlocks=void 0)}_initialKeyboardListener(){this.disposeWithMe(this._textSelectionRenderManager.onInputBefore$.subscribe(t=>{const e=this._contextService.getContextValue(l.FOCUSING_FORMULA_EDITOR),n=this._contextService.getContextValue(l.FOCUSING_SHEET),o=this._currentUniverService.getCurrentUniverDocInstance().getUnitId();n&&!e&&this._editorService.isSheetEditor(o)&&this._showEditorByKeyboard(t)}))}_showEditorByKeyboard(t){if(t==null)return;const e=t.event;this._commandService.executeCommand(De.id,{visible:!0,eventType:w.DeviceInputEventType.Keyboard,keycode:e.which})}_commandExecutedListener(){const t=[te.RichTextEditingMutation.id,C.SetEditorResizeOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var n;if(t.includes(e.id)){const o=e.params,{unitId:r}=o;if(!this._editorService.isSheetEditor(r))return;const s=this._editorBridgeService.getCurrentEditorId();if(s==null)return;this._editorBridgeService.changeEditorDirty(!0);const a=(n=this._docSkeletonManagerService.getSkeletonByUnitId(s))==null?void 0:n.skeleton;if(a==null)return;const c=this._editorBridgeService.getEditCellState();if(c==null)return;const{position:d,documentLayoutObject:u,canvasOffset:h,scaleX:m,scaleY:S}=c;this._fitTextSize(d,h,a,u,m,S)}}))}_setOpenForCurrent(t,e){const n=this._editorService.getAllEditor();for(const[o,r]of n)r.isSheetEditor()&&(r.setOpenForSheetUnitId(t),r.setOpenForSheetSubUnitId(e))}_getEditorObject(){return hn(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};Dn=jc([l.OnLifecycle(l.LifecycleStages.Rendered,Dn),Ee(0,P.Inject(te.DocSkeletonManagerService)),Ee(1,P.Inject(te.DocViewModelManagerService)),Ee(2,l.IContextService),Ee(3,l.IUniverInstanceService),Ee(4,w.IRenderManagerService),Ee(5,we),Ee(6,Yt),Ee(7,w.ITextSelectionRenderManager),Ee(8,P.Inject(te.TextSelectionManagerService)),Ee(9,l.ICommandService),Ee(10,P.Inject(l.LocaleService)),Ee(11,C.IEditorService)],Dn);const Pn={id:"sheet.command.change-zoom-ratio",type:l.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const{delta:e,reset:n}=t,o=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),r=o.getActiveSheet(),s=o.getUnitId(),a=r.getSheetId();let c=n?100:Math.round((r.getConfig().zoomRatio+e)*100);c=Math.max(ci[0],c),c=Math.min(ci[1],c);const d=c/100;return i.get(l.ICommandService).executeCommand(Pe.id,{unitId:s,subUnitId:a,zoomRatio:d})}},Ln={id:"sheet.command.set-zoom-ratio",type:l.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const{unitId:e,subUnitId:n,zoomRatio:o}=t;return i.get(l.ICommandService).executeCommand(Pe.id,{unitId:e,subUnitId:n,zoomRatio:o})}},Cr={id:"sheet.operation.set-activate-cell-edit",type:l.CommandType.OPERATION,handler:(i,t)=>(i.get(we).setEditCell(t),!0)};var Yc=Object.defineProperty,Xc=Object.getOwnPropertyDescriptor,$c=(i,t,e,n)=>{for(var o=n>1?void 0:n?Xc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Yc(t,e,o),o},Ue=(i,t)=>(e,n)=>t(e,n,i);let Hn=class extends l.RxDisposable{constructor(i,t,e,n,o,r,s,a,c,d,u){super(),this._injector=i,this._sheetSkeletonManagerService=t,this._currentUniverService=e,this._commandService=n,this._renderManagerService=o,this._editorBridgeService=r,this._layoutService=s,this._editorService=a,this._contextService=c,this._selectionManagerService=d,this._rangeSelectorService=u,this._initialize(),this._commandExecutedListener()}dispose(){}_initialize(){this._initSelectionChangeListener(),this._initialEventListener(),this._initialChangeEditorListener(),this._initialRangeSelector()}_initSelectionChangeListener(){V.merge(this._selectionManagerService.selectionMoveEnd$,this._selectionManagerService.selectionMoveStart$).pipe(V.takeUntil(this.dispose$)).subscribe(i=>this._handleSelectionListener(i))}_handleSelectionListener(i){const t=this._selectionManagerService.getCurrent();if((t==null?void 0:t.pluginName)!==f.NORMAL_SELECTION_PLUGIN_NAME||this._editorBridgeService.isVisible().visible===!0)return;const e=this._injector.get(w.ITextSelectionRenderManager,P.Quantity.OPTIONAL);if(!this._layoutService.checkCanvasIsFocused()&&e&&!e.hasFocus())return;const n=this._sheetSkeletonManagerService.getCurrent();if(n==null||i==null||i.length===0||i[i.length-1]==null)return;const{primary:o}=i[i.length-1];if(o==null)return;const r=this._getSheetObject();if(r==null)return;const{unitId:s,sheetId:a}=n,{scene:c,engine:d}=r;this._commandService.executeCommand(Cr.id,{scene:c,engine:d,primary:o,unitId:s,sheetId:a})}_initialEventListener(){const i=this._getSheetObject();if(i==null)return;const{spreadsheet:t,spreadsheetColumnHeader:e,spreadsheetLeftTopPlaceholder:n,spreadsheetRowHeader:o}=i;t.onDblclickObserver.add(r=>{r.button!==2&&this._commandService.executeCommand(De.id,{visible:!0,eventType:w.DeviceInputEventType.Dblclick})}),t.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),e.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),n.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),o.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this))}_initialChangeEditorListener(){this.disposeWithMe(this._currentUniverService.currentDoc$.subscribe(i=>{if(i==null)return;const t=i.getUnitId();this._editorService.isEditor(t)&&(this._editorService.isSheetEditor(t)?(this._contextService.setContextValue(l.FOCUSING_DOC,!1),this._contextService.setContextValue(l.FOCUSING_SHEET,!0)):(this._contextService.setContextValue(l.FOCUSING_SHEET,!1),this._contextService.setContextValue(l.FOCUSING_DOC,!0),this._hideEditor()))}))}_keepVisibleHideEditor(){this._editorBridgeService.isForceKeepVisible()||this._hideEditor()}_hideEditor(){this._editorBridgeService.isVisible().visible===!0&&(this._selectionManagerService.makeDirty(!1),this._commandService.executeCommand(De.id,{visible:!1,eventType:w.DeviceInputEventType.PointerDown}),setTimeout(()=>{this._selectionManagerService.makeDirty(!0)},0))}_initialRangeSelector(){this.disposeWithMe(this._selectionManagerService.selectionMoving$.subscribe(this._rangeSelector.bind(this))),this.disposeWithMe(this._selectionManagerService.selectionMoveStart$.subscribe(this._rangeSelector.bind(this))),this.disposeWithMe(this._rangeSelectorService.openSelector$.subscribe(()=>{const i=this._selectionManagerService.getSelections(),{unitId:t,sheetId:e,sheetName:n}=this._getCurrentUnitIdAndSheetId(),o=i==null?void 0:i.map(r=>({range:r.range,unitId:t,sheetId:e,sheetName:n}));o&&this._rangeSelectorService.selectionChange(o)}))}_rangeSelector(i){if(!i)return;const{unitId:t,sheetId:e,sheetName:n}=this._getCurrentUnitIdAndSheetId(),o=i.map(r=>({range:r.range,unitId:t,sheetId:e,sheetName:n}));this._rangeSelectorService.selectionChange(o)}_getCurrentUnitIdAndSheetId(){const i=this._currentUniverService.getCurrentUniverSheetInstance(),t=i.getActiveSheet();return{unitId:i.getUnitId(),sheetId:t.getSheetId(),sheetName:t.getName()}}_getSheetObject(){return Ie(this._currentUniverService,this._renderManagerService)}_commandExecutedListener(){const i=f.COMMAND_LISTENER_SKELETON_CHANGE;this.disposeWithMe(this._commandService.onCommandExecuted((t,e)=>{e!=null&&e.fromCollab||(t.id===f.SetWorksheetActiveOperation.id?this._keepVisibleHideEditor():i.includes(t.id)&&this._hideEditor())})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{t.id===Ln.id&&this._editorBridgeService.refreshEditCellState()}))}};Hn=$c([l.OnLifecycle(l.LifecycleStages.Rendered,Hn),Ue(0,P.Inject(P.Injector)),Ue(1,P.Inject(x.SheetSkeletonManagerService)),Ue(2,l.IUniverInstanceService),Ue(3,l.ICommandService),Ue(4,w.IRenderManagerService),Ue(5,we),Ue(6,C.ILayoutService),Ue(7,C.IEditorService),Ue(8,l.IContextService),Ue(9,P.Inject(f.SelectionManagerService)),Ue(10,C.IRangeSelectorService)],Hn);var Zc=Object.defineProperty,Gc=Object.getOwnPropertyDescriptor,Kc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Gc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Zc(t,e,o),o},Zt=(i,t)=>(e,n)=>t(e,n,i);let Un=class extends l.Disposable{constructor(i,t,e,n,o){super(),this._commandService=i,this._formatPainterService=t,this._currentUniverService=e,this._renderManagerService=n,this._selectionRenderService=o,this._initialize()}_initialize(){this._commandExecutedListener(),this._bindFormatPainterStatus()}_bindFormatPainterStatus(){this._formatPainterService.status$.subscribe(i=>{const{scene:t}=this._getSheetObject()||{};t&&(i!==Le.OFF?t.setDefaultCursor(w.CURSOR_TYPE.CELL):t.setDefaultCursor(w.CURSOR_TYPE.DEFAULT))})}_commandExecutedListener(){this.disposeWithMe(l.toDisposable(this._selectionRenderService.selectionMoveEnd$.subscribe(i=>{if(this._formatPainterService.getStatus()!==Le.OFF){const{rangeWithCoord:t}=i[i.length-1];this._applyFormatPainter({startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}),this._formatPainterService.getStatus()===Le.ONCE&&this._commandService.executeCommand(Ni.id)}})))}async _applyFormatPainter(i){const{styles:t,merges:e}=this._formatPainterService.getSelectionFormat(),n=this._currentUniverService.getCurrentUniverSheetInstance().getUnitId(),o=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();if(!t)return;const{startRow:r,startColumn:s,endRow:a,endColumn:c}=t.getDataRange(),d=a-r+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((_,g)=>{_.forEach((v,M)=>{const R=g%d+r,b=M%u+s,E=t.getValue(R,b);E&&(h[g][M].s=E)})}),e.forEach(_=>{const g={startRow:_.startRow-r,startColumn:_.startColumn-s,endRow:_.endRow-r,endColumn:_.endColumn-s},v=Math.max(1,Math.floor((i.endRow-i.startRow+1)/d)),M=Math.max(1,Math.floor((i.endColumn-i.startColumn+1)/u));for(let R=0;R<v;R++)for(let b=0;b<M;b++)m.push({startRow:g.startRow+R*d+i.startRow,startColumn:g.startColumn+b*u+i.startColumn,endRow:g.endRow+R*d+i.startRow,endColumn:g.endColumn+b*u+i.startColumn})});const S={subUnitId:o,unitId:n,styleRange:i,styleValues:h,mergeRanges:m};await this._commandService.executeCommand(qo.id,S)}_getSheetObject(){return Ie(this._currentUniverService,this._renderManagerService)}};Un=Kc([l.OnLifecycle(l.LifecycleStages.Rendered,Un),Zt(0,l.ICommandService),Zt(1,Rt),Zt(2,l.IUniverInstanceService),Zt(3,w.IRenderManagerService),Zt(4,ge)],Un);var Qc=Object.defineProperty,Jc=Object.getOwnPropertyDescriptor,qc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Jc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Qc(t,e,o),o},je=(i,t)=>(e,n)=>t(e,n,i);const ed="__SpreadsheetFreezeRowMainName__",td="__SpreadsheetFreezeRowHeaderName__",nd="__SpreadsheetFreezeColumnMainName__",id="__SpreadsheetFreezeColumnHeaderName__",Hi=4,od=.01;let Vn=class extends l.Disposable{constructor(t,e,n,o,r,s,a,c,d,u){super();I(this,"_rowFreezeHeaderRect");I(this,"_rowFreezeMainRect");I(this,"_columnFreezeHeaderRect");I(this,"_columnFreezeMainRect");I(this,"_freezeDownObservers",[]);I(this,"_freezeMoveObservers",[]);I(this,"_freezeLeaveObservers",[]);I(this,"_moveObserver");I(this,"_upObserver");I(this,"_changeToRow",-1);I(this,"_changeToColumn",-1);I(this,"_changeToOffsetX",0);I(this,"_changeToOffsetY",0);I(this,"_activeViewport",null);I(this,"_freezeNormalHeaderColor","");I(this,"_freezeNormalMainColor","");I(this,"_freezeActiveColor","");I(this,"_freezeHoverColor","");I(this,"_lastFreeze");this._sheetSkeletonManagerService=t,this._currentUniverService=e,this._commandService=n,this._renderManagerService=o,this._selectionRenderService=r,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(t=0,e){var O;const n=e!=null?e:this._getFreeze();if(n==null)return;const o=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton;if(o==null)return;const{startRow:r,startColumn:s}=n,a=this._getPositionByIndex(r,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:S,startY:_}=a,{rowTotalHeight:g,columnTotalWidth:v,rowHeaderWidthAndMarginLeft:M,columnHeaderHeightAndMarginTop:R}=o,b=u>v+M?u:v+R,E=h>g+R?h:g+R;this._changeToRow=r,this._changeToColumn=s,this._changeToOffsetX=S,this._changeToOffsetY=_;const T=Math.max(m.scaleX,m.scaleY),y=Hi/(T<1?1:T);if(t===0){const N=y;this._rowFreezeHeaderRect=new w.Rect(td,{fill:this._freezeNormalHeaderColor,width:M,height:y,left:0,top:_-N,zIndex:3});let D=this._freezeNormalHeaderColor;(r===-1||r===0)&&(D=this._freezeNormalMainColor),this._rowFreezeMainRect=new w.Rect(ed,{fill:D,width:b*2,height:y,left:M,top:_-N,zIndex:3}),m.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],et)}else{const N=y;this._columnFreezeHeaderRect=new w.Rect(id,{fill:this._freezeNormalHeaderColor,width:y,height:R,left:S-N,top:0,zIndex:3});let D=this._freezeNormalHeaderColor;(s===-1||s===0)&&(D=this._freezeNormalMainColor),this._columnFreezeMainRect=new w.Rect(nd,{fill:D,width:y,height:E*2,left:S-N,top:R,zIndex:3}),m.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],et)}this._eventBinding(t)}_eventBinding(t=0){let e=this._rowFreezeHeaderRect,n=this._rowFreezeMainRect;t===1&&(e=this._columnFreezeHeaderRect,n=this._columnFreezeMainRect);const o=this._getSheetObject();if(o==null)return;const{scene:r}=o;this._freezeMoveObservers.push(e==null?void 0:e.onPointerEnterObserver.add(()=>{e==null||e.setProps({fill:this._freezeHoverColor,zIndex:4}),r.setCursor(w.CURSOR_TYPE.GRAB)})),this._freezeMoveObservers.push(n==null?void 0:n.onPointerEnterObserver.add(()=>{e==null||e.setProps({fill:this._freezeHoverColor,zIndex:4}),r.setCursor(w.CURSOR_TYPE.GRAB)})),this._freezeLeaveObservers.push(e==null?void 0:e.onPointerLeaveObserver.add(()=>{e==null||e.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),r.resetCursor()})),this._freezeLeaveObservers.push(n==null?void 0:n.onPointerLeaveObserver.add(()=>{e==null||e.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),r.resetCursor()})),this._freezeDownObservers.push(e==null?void 0:e.onPointerDownObserver.add(s=>{this._freezeDown(s,e,n,t)})),this._freezeDownObservers.push(n==null?void 0:n.onPointerDownObserver.add(s=>{this._freezeDown(s,e,n,t)}))}_getCurrentLastVisibleRow(){var h,m,S,_;const t=this._getSheetObject();if(t==null)return;const e=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(e==null)return;const n=t.scene,o=Math.max(n.scaleX,n.scaleY),r=this._scrollManagerService.getCurrentScroll(),s=(t.engine.height-e.columnHeaderHeight)/o,a=(m=r==null?void 0:r.sheetViewStartRow)!=null?m:0,c=a===0?-((S=r==null?void 0:r.offsetY)!=null?S:0):e.rowHeightAccumulation[a-1]-((_=r==null?void 0:r.offsetY)!=null?_:0);let d=0,u=!1;for(let g=a,v=e.rowHeightAccumulation.length;g<v;g++)if(e.rowHeightAccumulation[g]-c>s){d=g,u=!0;break}return u||(d=e.rowHeightAccumulation.length-1),d}_getActiveViewport(t){var n;const e=(n=this._getSheetObject())==null?void 0:n.scene.getViewports();return e&&e.find(o=>o.isHit(new w.Vector2(t.offsetX,t.offsetY)))||null}_freezeDown(t,e,n,o=0){var h;const r=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(r==null)return;const s=this._getSheetObject();if(s==null)return;const{scene:a}=s;a.setCursor(w.CURSOR_TYPE.GRABBING),a.disableEvent();const c=this._getCurrentLastVisibleRow(),d=c===void 0?Number.POSITIVE_INFINITY:r.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 b,E,T,y;const S=this._getActiveViewport(m),{startX:_,startY:g,row:v,column:M}=Ct(m.offsetX,m.offsetY,a,r,S||void 0);a.setCursor(w.CURSOR_TYPE.GRABBING);const R=Hi/Math.max(a.scaleX,a.scaleY);o===0?((b=e.transformByState({top:Math.min(g,d)-R/2}))==null||b.setProps({fill:this._freezeActiveColor}),(E=n.transformByState({top:Math.min(g,d)-R/2}))==null||E.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=c===void 0?v:Math.min(v,c),this._changeToOffsetY=Math.min(g,d),this._activeViewport=S):((T=e.transformByState({left:_-R/2}))==null||T.setProps({fill:this._freezeActiveColor}),(y=n.transformByState({left:_-R/2}))==null||y.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=M,this._changeToOffsetX=_,this._activeViewport=S)}),this._upObserver=a.onPointerUpObserver.add(()=>{var N,D;a.resetCursor(),a.enableEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:m,columnHeaderHeightAndMarginTop:S}=r;o===0&&(this._changeToRow===0||this._changeToRow===-1)||o===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(e.setProps({fill:this._freezeNormalHeaderColor}),n.setProps({fill:this._freezeNormalMainColor})):(e==null||e.setProps({fill:this._freezeNormalHeaderColor}),n==null||n.setProps({fill:this._freezeNormalHeaderColor}));const _=Hi/Math.max(a.scaleX,a.scaleY);o===0?(this._changeToRow===0||this._changeToRow===-1)&&(e.transformByState({top:S-_}),n.transformByState({top:S-_})):(this._changeToColumn===0||this._changeToColumn===-1)&&(e.transformByState({left:m-_}),n.transformByState({left:m-_}));const g=this._scrollManagerService.getCurrentScroll()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:v,sheetViewStartColumn:M}=g;if(M==null||v==null)return;const R=this._currentUniverService.getCurrentUniverSheetInstance(),b=R.getActiveSheet(),E=(N=b.getConfig())==null?void 0:N.freeze;let T=(E==null?void 0:E.xSplit)||0,y=(E==null?void 0:E.ySplit)||0;const O=(D=this._activeViewport)==null?void 0:D.viewPortKey;o===0&&(!O||O===F.VIEW_LEFT_TOP||O===F.VIEW_MAIN_LEFT_TOP||O===F.VIEW_MAIN_TOP||O===F.VIEW_ROW_TOP?y=this._changeToRow-(E.startRow-E.ySplit):y=this._changeToRow-v,y=y<0?0:y),o===1&&(!O||O===F.VIEW_LEFT_TOP||O===F.VIEW_MAIN_LEFT_TOP||O===F.VIEW_MAIN_LEFT||O===F.VIEW_COLUMN_LEFT?T=this._changeToColumn-(E.startColumn-E.xSplit):T=this._changeToColumn-M,T=T<0?0:T),this._commandService.executeCommand(f.SetFrozenCommand.id,{startRow:y===0?-1:this._changeToRow,startColumn:T===0?-1:this._changeToColumn,ySplit:y,xSplit:T,unitId:R.getUnitId(),subUnitId:b.getSheetId()})})}_getViewports(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t,n=e.getViewport(F.VIEW_COLUMN_LEFT),o=e.getViewport(F.VIEW_COLUMN_RIGHT),r=e.getViewport(F.VIEW_ROW_TOP),s=e.getViewport(F.VIEW_ROW_BOTTOM),a=e.getViewport(F.VIEW_LEFT_TOP),c=e.getViewport(F.VIEW_MAIN),d=e.getViewport(F.VIEW_MAIN_LEFT_TOP),u=e.getViewport(F.VIEW_MAIN_LEFT),h=e.getViewport(F.VIEW_MAIN_TOP);if(!(n==null||o==null||r==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:o,viewRowTop:r,viewRowBottom:s,viewLeftTop:a}}_bindViewportScroll(){const t=this._getViewports();if(!t)return;const{viewMain:e,viewRowBottom:n,viewColumnRight:o,viewMainLeft:r,viewMainTop:s}=t;this.disposeWithMe(e.onScrollAfterObserver.add(a=>{const{scrollX:c,scrollY:d,actualScrollX:u,actualScrollY:h}=a;n.isActive&&n.updateScroll({scrollY:d,actualScrollY:h}),o.isActive&&o.updateScroll({scrollX:c,actualScrollX:u}),r.isActive&&r.updateScroll({scrollY:d,actualScrollY:h}),s.isActive&&s.updateScroll({scrollX:c,actualScrollX:u})}))}_updateViewport(t=-1,e=-1,n=0,o=0,r=3){var O;const s=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.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:S,viewColumnLeft:_,viewColumnRight:g,viewRowTop:v,viewRowBottom:M,viewLeftTop:R}=d;g.resize({left:a,top:0,height:c,right:0}),M.resize({left:0,top:c,bottom:0,width:a}),R.resize({left:0,top:0,width:a,height:c});let b=!0,E=!0;h.enable(),(t===-1||t===0)&&(b=!1),(e===-1||e===0)&&(E=!1);const T=s.getNoMergeCellPositionByIndexWithNoHeader(t-n,e-o),y=s.getNoMergeCellPositionByIndexWithNoHeader(t,e);if(h.disable(),S.disable(),m.disable(),v.disable(),_.disable(),h.resetPadding(),S.resetPadding(),m.resetPadding(),v.resetPadding(),_.resetPadding(),b===!1&&E===!1)u.resize({left:a,top:c,bottom:0,right:0}),u.resetPadding();else if(b===!0&&E===!1){const N=y.startY-T.startY;u.resize({left:a,top:c+N,bottom:0,right:0}),u.setPadding({startY:T.startY,endY:y.startY,startX:0,endX:0}),r&2&&this._commandService.executeCommand(ct.id,{sheetViewStartRow:0,offsetY:0}),S.resize({left:a,top:c,height:N,right:0}),S.updateScroll({actualScrollY:T.startY,x:u.scrollX,actualScrollX:u.actualScrollX}),v.resize({left:0,top:c,width:a,height:N}),v.updateScroll({actualScrollY:T.startY}),M.resize({left:0,top:c+N,bottom:0,width:a}),S.enable(),v.enable()}else if(b===!1&&E===!0){const N=y.startX-T.startX;u.resize({left:a+N,top:c,bottom:0,right:0}),u.setPadding({startX:T.startX,endX:y.startX,startY:0,endY:0}),r&1&&this._commandService.executeCommand(ct.id,{sheetViewStartColumn:0,offsetX:0}),m.resize({left:a,top:c,width:N,bottom:0,right:0}),m.updateScroll({actualScrollX:T.startX,y:u.scrollY,actualScrollY:u.actualScrollY}),_.resize({left:a,top:0,width:N,height:c}),_.updateScroll({actualScrollX:T.startX}),g.resize({left:a+N,top:0,height:c,right:0}),m.enable(),_.enable()}else{const N=y.startX-T.startX,D=y.startY-T.startY;u.resize({left:a+N,top:c+D,bottom:0,right:0}),u.setPadding({startY:T.startY,endY:y.startY,startX:T.startX,endX:y.startX}),r&&this._commandService.executeCommand(ct.id,{...r&1?{sheetViewStartColumn:0,offsetX:0}:null,...r&2?{sheetViewStartRow:0,offsetY:0}:null}),m.resize({left:a,top:c+D,width:N,bottom:0}),m.updateScroll({actualScrollX:T.startX,y:u.scrollY,actualScrollY:u.actualScrollY}),S.resize({left:a+N,top:c,height:D,right:0}),S.updateScroll({actualScrollY:T.startY,x:u.scrollX,actualScrollX:u.actualScrollX}),h.resize({left:a,top:c,width:N,height:D}),h.updateScroll({actualScrollX:T.startX,actualScrollY:T.startY}),v.resize({left:0,top:c,width:a,height:D}),v.updateScroll({actualScrollY:T.startY}),M.resize({left:0,top:c+D,bottom:0,width:a}),_.resize({left:a,top:0,width:N,height:c}),_.updateScroll({actualScrollX:T.startX}),g.resize({left:a+N,top:0,height:c,right:0}),h.enable(),S.enable(),m.enable(),v.enable(),_.enable()}}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(t=>{[f.SetWorksheetActiveOperation.id,f.InsertRangeMoveDownCommand.id,f.InsertRangeMoveRightCommand.id].includes((t==null?void 0:t.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const n=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getConfig().freeze,{startRow:o=-1,startColumn:r=-1,ySplit:s=0,xSplit:a=0}=n;this._refreshFreeze(o,r,s,a,0)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(l.toDisposable(this._themeService.currentTheme$.subscribe(t=>{this._clearFreeze(),this._themeChange(t),this._refreshCurrent()})))}_themeChange(t){this._freezeNormalHeaderColor=t.grey400,this._freezeNormalMainColor=new l.ColorKit(t.grey400).setAlpha(od).toRgbString(),this._freezeActiveColor=t.primaryColor,this._freezeHoverColor=t.grey500}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:t=>{const e={redos:[],undos:[]},n=this._getFreeze();if(!n)return e;const o=r=>{const s=this._currentUniverService.getCurrentUniverSheetInstance(),a=s.getUnitId(),d=s.getActiveSheet().getSheetId();this._refreshFreeze(r.startRow,r.startColumn,r.ySplit,r.xSplit,0);const u={...r,unitId:a,subUnitId:d,resetScroll:!1},h=f.SetFrozenMutationFactory(this._injector,u);return{undos:[{id:f.SetFrozenMutation.id,params:h}],redos:[{id:f.SetFrozenMutation.id,params:u}]}};if(t.id===f.InsertRowCommand.id){const s=t.params.range,a=s.endRow-s.startRow+1;if(s.startRow<=n.startRow){const c={...n,startRow:Math.max(1,n.startRow+a),ySplit:Math.max(1,n.ySplit+a)};return o(c)}}if(t.id===f.InsertColCommand.id){const s=t.params.range,a=s.endColumn-s.startColumn+1;if(s.startColumn<=n.startColumn){const c={...n,startColumn:Math.max(1,n.startColumn+a),xSplit:Math.max(1,n.xSplit+a)};return o(c)}}if(t.id===f.MoveColsCommand.id){const r=this._selectionManagerService.getSelections(),{fromRange:{startColumn:s},toRange:{startColumn:a}}=t.params,c=r==null?void 0:r.filter(v=>v.range.rangeType===l.RANGE_TYPE.COLUMN&&v.range.startColumn<=s&&s<=v.range.endColumn);if(!(c!=null&&c.length))return e;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 e;const h=d.endColumn-d.startColumn+1,m=Math.max(Math.min(n.startColumn,d.endColumn+1)-d.startColumn,0);let S,_;u.startColumn>=n.startColumn?(S=Math.max(n.startColumn-m,1),_=Math.max(n.xSplit-m,1)):(S=n.startColumn+h-m,_=n.xSplit+h-m);const g={...n,startColumn:S,xSplit:_};return o(g)}if(t.id===f.MoveRowsCommand.id){const r=this._selectionManagerService.getSelections(),{fromRange:{startRow:s},toRange:{startRow:a}}=t.params,c=r==null?void 0:r.filter(v=>v.range.rangeType===l.RANGE_TYPE.ROW&&v.range.startRow<=s&&s<=v.range.endRow);if(!(c!=null&&c.length))return e;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 e;const h=d.endRow-d.startRow+1,m=Math.max(Math.min(n.startRow,d.endRow+1)-d.startRow,0);let S,_;u.startRow>=n.startRow?(S=Math.max(n.startRow-m,1),_=Math.max(n.ySplit-m,1)):(S=n.startRow+h-m,_=n.ySplit+h-m);const g={...n,startRow:S,ySplit:_};return o(g)}if(t.id===f.RemoveColCommand.id||t.id===f.RemoveRowCommand.id){const r=t.params,s=r.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 o(c)}if(r.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 o(c)}}return e}}))}_commandExecutedListener(){const t=[f.SetFrozenMutation.id,Pe.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(t.includes(e.id)){const n=this._lastFreeze,o=this._currentUniverService.getCurrentUniverSheetInstance(),r=o.getActiveSheet(),s=e.params,{unitId:a,subUnitId:c}=s;if(!(a===o.getUnitId()&&c===r.getSheetId()))return;const d=r.getConfig().freeze;if(this._lastFreeze=d,d==null)return;let u=0;const{startRow:h=-1,startColumn:m=-1,ySplit:S=0,xSplit:_=0}=d;(!n||n.startRow!==h||n.ySplit!==S)&&(u|=2),(!n||n.startColumn!==m||n.xSplit!==_)&&(u|=1),s.resetScroll===!1&&(u=0),this._refreshFreeze(h,m,S,_,u)}else if(e.id===f.SetWorksheetRowHeightMutation.id){const n=this._getFreeze();e.params&&n&&e.params.ranges.some(o=>o.startRow<n.startRow)&&this._refreshCurrent()}else if(e.id===f.SetWorksheetColWidthMutation.id){const n=this._getFreeze();e.params&&n&&e.params.ranges.some(o=>o.startColumn<n.startColumn)&&this._refreshCurrent()}else if(e.id===f.SetWorksheetRowAutoHeightMutation.id){const n=e.params,o=this._getFreeze();if(o&&o.startRow>-1&&n.rowsAutoHeightInfo.some(r=>r.row<o.startRow)){const r=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{r.unsubscribe()})})}}else if(e.id===f.SetColHiddenMutation.id||e.id===f.SetColVisibleMutation.id){const n=e.params,o=this._getFreeze(),r=n.ranges;o&&o.startColumn>-1&&r.some(s=>s.startColumn<o.startColumn)&&this._refreshCurrent()}else if(e.id===f.SetRowHiddenMutation.id||e.id===f.SetRowVisibleMutation.id){const n=e.params,o=this._getFreeze(),r=n.ranges;o&&o.startRow>-1&&r.some(s=>s.startRow<o.startRow)&&this._refreshCurrent()}}))}_zoomRefresh(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;e.onTransformChangeObservable.add(n=>{n.type===w.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&this._refreshCurrent()})}_clearObserverEvent(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_clearFreeze(){var n,o,r,s;(n=this._rowFreezeHeaderRect)==null||n.dispose(),(o=this._rowFreezeMainRect)==null||o.dispose(),(r=this._columnFreezeHeaderRect)==null||r.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose();const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;[...this._freezeDownObservers,...this._freezeMoveObservers,...this._freezeLeaveObservers].forEach(a=>{e.onPointerDownObserver.remove(a),e.onPointerMoveObserver.remove(a),e.onPointerLeaveObserver.remove(a)}),e.onPointerEnterObserver.remove(this._moveObserver),e.onPointerMoveObserver.remove(this._upObserver)}_getPositionByIndex(t,e){var c;if(this._getSheetObject()==null)return;const o=(c=this._sheetSkeletonManagerService.getCurrent())==null?void 0:c.skeleton,r=o==null?void 0:o.getNoMergeCellPositionByIndex(t,e);if(o==null)return;if(r!=null&&(!isNaN(r.endX)||!isNaN(r.endY)))return r;const{rowHeaderWidthAndMarginLeft:s,columnHeaderHeightAndMarginTop:a}=o;return{startX:s,endX:s,startY:a,endY:a}}_getFreeze(){var e;const t=(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig();if(t!=null)return t.freeze}_getSheetObject(){return Ie(this._currentUniverService,this._renderManagerService)}_refreshFreeze(t,e,n,o,r){var a;const s={startRow:t,startColumn:e,ySplit:n,xSplit:o};this._clearFreeze(),this._createFreeze(0,s),this._createFreeze(1,s),this._updateViewport(t,e,n,o,r),(a=this._getSheetObject())==null||a.spreadsheet.makeForceDirty()}};Vn=qc([l.OnLifecycle(l.LifecycleStages.Rendered,Vn),je(0,P.Inject(x.SheetSkeletonManagerService)),je(1,l.IUniverInstanceService),je(2,l.ICommandService),je(3,w.IRenderManagerService),je(4,ge),je(5,P.Inject(f.SelectionManagerService)),je(6,P.Inject(Xe)),je(7,P.Inject(l.ThemeService)),je(8,P.Inject(f.SheetInterceptorService)),je(9,P.Inject(P.Injector))],Vn);var Ui=(i=>(i[i.NORMAL=0]="NORMAL",i[i.HIGHLIGHT=1]="HIGHLIGHT",i))(Ui||{});const rd="rgba(0, 0, 0, 0.15)",Ze="rgb(0, 0, 0)",kn="rgb(255, 255, 255, 1)";class sd extends w.Shape{constructor(e,n){super(e,n);I(this,"_size",12);I(this,"_iconRatio",.4);I(this,"_mode",0);this.setShapeProps(n)}setShapeProps(e){e!=null&&e.size&&(this._size=e.size),e!=null&&e.mode&&(this._mode=e.mode),this.transformByState({width:this._size,height:this._size})}_draw(e){this._mode===1&&w.Rect.drawWith(e,{width:this._size,height:this._size,radius:this._size,fill:rd});const n=this._size*.5*this._iconRatio,o=Math.PI/180*60,r=n*Math.sin(o),s=n*Math.cos(o);w.RegularPolygon.drawWith(e,{pointsGroup:[[{x:-r+this._size/2,y:-s+this._size/2},{x:r+this._size/2,y:-s+this._size/2},{x:this._size/2,y:n+this._size/2}]],fill:Ze})}}var ad=Object.defineProperty,ld=Object.getOwnPropertyDescriptor,cd=(i,t,e,n)=>{for(var o=n>1?void 0:n?ld(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&ad(t,e,o),o},Et=(i,t)=>(e,n)=>t(e,n,i);const dd="__SpreadsheetHeaderMenuSHAPEControllerShape__",ud="__SpreadsheetHeaderMenuMAINControllerShape__",hd="rgba(0, 0, 0, 0.1)";let Bn=class extends l.Disposable{constructor(t,e,n,o,r,s){super();I(this,"_hoverRect");I(this,"_hoverMenu");I(this,"_currentColumn",Number.POSITIVE_INFINITY);I(this,"_observers",[]);this._sheetSkeletonManagerService=t,this._currentUniverService=e,this._renderManagerService=n,this._contextMenuService=o,this._commandService=r,this._selectionManagerService=s,this._initialize()}dispose(){var o,r;(o=this._hoverRect)==null||o.dispose(),(r=this._hoverMenu)==null||r.dispose();const t=this._getSheetObject();if(t==null)return;const{spreadsheetRowHeader:e,spreadsheetColumnHeader:n}=t;this._observers.forEach(s=>{e.onPointerEnterObserver.remove(s),e.onPointerMoveObserver.remove(s),e.onPointerLeaveObserver.remove(s),n.onPointerEnterObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)})}_initialize(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;this._hoverRect=new w.Rect(dd,{fill:hd,evented:!1}),this._hoverMenu=new sd(ud,{zIndex:100,visible:!1}),e.addObjects([this._hoverRect,this._hoverMenu],et),this._initialHover(0),this._initialHover(1),this._initialHoverMenu()}_initialHover(t=0){const e=this._getSheetObject();if(e==null)return;const{spreadsheetColumnHeader:n,spreadsheetRowHeader:o}=e,r=t===0?o:n;this._observers.push(r==null?void 0:r.onPointerEnterObserver.add(()=>{var s;(s=this._hoverRect)==null||s.show()})),this._observers.push(r==null?void 0:r.onPointerMoveObserver.add(s=>{var v,M,R;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:S,endY:_,column:g}=Ct(s.offsetX,s.offsetY,c.scene,a);if(t===0)(M=this._hoverRect)==null||M.transformByState({width:d,height:_-m,left:0,top:m});else{if(this._currentColumn=g,(R=this._hoverRect)==null||R.transformByState({width:S-h,height:u,left:h,top:0}),this._hoverMenu==null)return;if(S-h<u*2){this._hoverMenu.hide();return}const b=u*.8;this._hoverMenu.transformByState({left:S-u,top:u/2-b/2}),this._hoverMenu.setShapeProps({size:b}),this._hoverMenu.show()}})),this._observers.push(r==null?void 0:r.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 t=this._getSheetObject();t!=null&&(this._hoverMenu.setProps({mode:Ui.HIGHLIGHT,visible:!0}),t.scene.setCursor(w.CURSOR_TYPE.POINTER))}),this._hoverMenu.onPointerLeaveObserver.add(()=>{if(this._hoverMenu==null)return;const t=this._getSheetObject();t!=null&&(this._hoverMenu.setProps({mode:Ui.NORMAL,visible:!1}),t.scene.resetCursor())}),this._hoverMenu.onPointerDownObserver.add(t=>{if(!this._getSheetObject())return;const n=this._currentColumn,o=this._selectionManagerService.getSelectionRanges();if(!!!(o!=null&&o.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(f.SetSelectionsOperation.id,s)}t.stopPropagation(),t.preventDefault(),this._contextMenuService.triggerContextMenu(t,he.COL_HEADER_CONTEXT_MENU)}))}_getSheetObject(){return Ie(this._currentUniverService,this._renderManagerService)}_getSelectionOnColumn(t){const e=this._currentUniverService.getCurrentUniverSheetInstance(),n=e.getActiveSheet();return{unitId:e.getUnitId(),subUnitId:n.getSheetId(),pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:{startRow:0,startColumn:t,endRow:n.getRowCount()-1,endColumn:t,rangeType:l.RANGE_TYPE.COLUMN},primary:{startRow:0,startColumn:t,endRow:0,endColumn:t,actualRow:0,actualColumn:t,isMerged:!1,isMergedMainCell:!1},style:null}]}}};Bn=cd([l.OnLifecycle(l.LifecycleStages.Rendered,Bn),Et(0,P.Inject(x.SheetSkeletonManagerService)),Et(1,l.IUniverInstanceService),Et(2,w.IRenderManagerService),Et(3,C.IContextMenuService),Et(4,l.ICommandService),Et(5,P.Inject(f.SelectionManagerService))],Bn);var md=Object.defineProperty,Sd=Object.getOwnPropertyDescriptor,_d=(i,t,e,n)=>{for(var o=n>1?void 0:n?Sd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&md(t,e,o),o},yt=(i,t)=>(e,n)=>t(e,n,i);const fd="__SpreadsheetHeaderMoveControllerBackground__",gd="__SpreadsheetHeaderMoveControllerShapeLine__",pd="rgba(0, 0, 0, 0.1)",vd="rgb(119, 119, 119)",Cd=4;let Fn=class extends l.Disposable{constructor(t,e,n,o,r,s){super();I(this,"_startOffsetX",Number.NEGATIVE_INFINITY);I(this,"_startOffsetY",Number.NEGATIVE_INFINITY);I(this,"_moveHelperBackgroundShape");I(this,"_moveHelperLineShape");I(this,"_sheetObject");I(this,"_rowOrColumnDownObservers",[]);I(this,"_rowOrColumnMoveObservers",[]);I(this,"_rowOrColumnLeaveObservers",[]);I(this,"_moveObserver");I(this,"_upObserver");I(this,"_scrollTimer");I(this,"_changeFromColumn",-1);I(this,"_changeFromRow",-1);I(this,"_changeToColumn",-1);I(this,"_changeToRow",-1);this._sheetSkeletonManagerService=t,this._currentUniverService=e,this._renderManagerService=n,this._commandService=o,this._selectionRenderService=r,this._selectionManagerService=s,this._initialize()}dispose(){var r,s;(r=this._moveHelperBackgroundShape)==null||r.dispose(),(s=this._moveHelperLineShape)==null||s.dispose();const t=this._getSheetObject();if(t==null)return;const{spreadsheetRowHeader:e,spreadsheetColumnHeader:n,scene:o}=t;[...this._rowOrColumnDownObservers,...this._rowOrColumnMoveObservers,...this._rowOrColumnLeaveObservers].forEach(a=>{e.onPointerDownObserver.remove(a),n.onPointerDownObserver.remove(a)}),o.onPointerMoveObserver.remove(this._moveObserver),o.onPointerUpObserver.remove(this._upObserver),this._scrollTimer.dispose()}_initialize(){const t=this._getSheetObject();t!=null&&(this._sheetObject=t,this._initialRowOrColumn(0),this._initialRowOrColumn(1))}_initialRowOrColumn(t=0){const{spreadsheetColumnHeader:e,spreadsheetRowHeader:n,scene:o}=this._sheetObject,r=t===0?n:e;this._rowOrColumnMoveObservers.push(r==null?void 0:r.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}=Ct(s.offsetX,s.offsetY,o,a);if(this._checkInHeaderRange(t===0?c:d,t)===!1){o.resetCursor(),this._selectionRenderService.enableSelection();return}o.setCursor(w.CURSOR_TYPE.GRAB),this._selectionRenderService.disableSelection()})),this._rowOrColumnLeaveObservers.push(r==null?void 0:r.onPointerLeaveObserver.add(()=>{var s,a;(s=this._moveHelperBackgroundShape)==null||s.hide(),(a=this._moveHelperLineShape)==null||a.hide(),o.resetCursor(),this._selectionRenderService.enableSelection()})),this._rowOrColumnDownObservers.push(r==null?void 0:r.onPointerDownObserver.add(s=>{var T;const a=(T=this._sheetSkeletonManagerService.getCurrent())==null?void 0:T.skeleton;if(a==null)return;const{offsetX:c,offsetY:d}=s,u=o.getRelativeCoord(w.Vector2.FromArray([c,d])),{x:h,y:m}=u;this._startOffsetX=h,this._startOffsetY=m;const{row:S,column:_}=Ct(s.offsetX,s.offsetY,o,a);let g;t===0?(this._changeFromRow=S,g=w.ScrollTimerType.Y):(this._changeFromColumn=_,g=w.ScrollTimerType.X);const v=this._checkInHeaderRange(t===0?S:_,t);if(v===!1)return;const M=o.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),o.setCursor(w.CURSOR_TYPE.GRABBING),o.disableEvent();let R=!1,b;const E=()=>{if(R)return;b=w.ScrollTimer.create(o,g);const y=o.getViewport(F.VIEW_MAIN);b.startScroll(h,m,y),this._scrollTimer=b,R=!0};this._moveObserver=o.onPointerMoveObserver.add(y=>{E();const{offsetX:O,offsetY:N}=y,{x:D,y:k}=o.getRelativeCoord(w.Vector2.FromArray([O,N]));o.setCursor(w.CURSOR_TYPE.GRABBING),this._rowColumnMoving(D,k,v,M,t),b.scrolling(D,k,()=>{this._rowColumnMoving(D,k,v,M,t)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var O,N,D;this._disposeBackgroundAndLine(),o.resetCursor(),o.enableEvent(),this._clearObserverEvent(),(O=this._scrollTimer)==null||O.dispose();const y=this._selectionManagerService.getSelections();if(t===0){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const A=(N=((y==null?void 0:y.filter(L=>L.range.rangeType===l.RANGE_TYPE.ROW&&L.range.startRow<=this._changeFromRow&&this._changeFromRow<=L.range.endRow))||[])[0])==null?void 0:N.range;A&&this._commandService.executeCommand(f.MoveRowsCommand.id,{fromRange:A,toRange:{...A,startRow:this._changeToRow,endRow:this._changeToRow+A.endRow-A.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const A=(D=((y==null?void 0:y.filter(L=>L.range.rangeType===l.RANGE_TYPE.COLUMN&&L.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=L.range.endColumn))||[])[0])==null?void 0:D.range;A&&this._commandService.executeCommand(f.MoveColsCommand.id,{fromRange:A,toRange:{...A,startColumn:this._changeToColumn,endColumn:this._changeToColumn+A.endColumn-A.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})}))}_rowColumnMoving(t,e,n,o,r){var ee,ne,U,W,$,q,re;const{scene:s}=this._sheetObject,a=(ee=this._sheetSkeletonManagerService.getCurrent())==null?void 0:ee.skeleton;if(a==null)return;const{rowHeaderWidth:c,columnHeaderHeight:d,rowTotalHeight:u,columnTotalWidth:h}=a,m=s.getScrollXY(s.getViewport(F.VIEW_MAIN)),{scaleX:S,scaleY:_}=s.getAncestorScale(),g=a.getCellPositionByOffset(t,e,S,_,m),{row:v,column:M}=g,R=a.getNoMergeCellPositionByIndex(v,M),{startX:b,startY:E,endX:T,endY:y}=R,O=this._selectionRenderService.convertRangeDataToSelection(n.range);if(O==null)return;const N=Math.max(S,S),{startX:D,endX:k,startY:A,endY:L,startRow:B,startColumn:j,endRow:X,endColumn:z}=O;r===0?(ne=this._moveHelperBackgroundShape)==null||ne.transformByState({height:L-A,width:h+c,left:0,top:A+(e-this._startOffsetY)/N+m.y-o.y}):(U=this._moveHelperBackgroundShape)==null||U.transformByState({height:u+d,width:k-D,left:D+(t-this._startOffsetX)/N+m.x-o.x,top:0}),(W=this._moveHelperBackgroundShape)==null||W.show();const Z=Cd/N;if(r===0){let se=0;if(v<=B)se=E-Z/2,this._changeToRow=v;else if(v>X)se=y-Z/2,this._changeToRow=v+1;else return;($=this._moveHelperLineShape)==null||$.transformByState({height:Z,width:h,left:c,top:se})}else{let se=0;if(M<=j)se=b-Z/2,this._changeToColumn=M;else if(M>z)se=T-Z/2,this._changeToColumn=M+1;else return;(q=this._moveHelperLineShape)==null||q.transformByState({height:u,width:Z,left:se,top:d})}(re=this._moveHelperLineShape)==null||re.show()}_checkInHeaderRange(t,e=0){var a;const n=this._selectionManagerService.getSelections();if(((a=this._selectionManagerService.getCurrent())==null?void 0:a.pluginName)!==f.NORMAL_SELECTION_PLUGIN_NAME)return!1;const r=n==null?void 0:n.find(c=>{const d=c.range,{startRow:u,endRow:h,startColumn:m,endColumn:S,rangeType:_}=d;return e===1?t>=m&&t<=S&&l.RANGE_TYPE.COLUMN===_:t>=u&&t<=h&&l.RANGE_TYPE.ROW===_}),s=r==null?void 0:r.range;return r==null||s==null||s.rangeType===l.RANGE_TYPE.ALL||s.rangeType===l.RANGE_TYPE.NORMAL||s.rangeType===l.RANGE_TYPE.ROW&&e!==0||s.rangeType===l.RANGE_TYPE.COLUMN&&e!==1?!1:r}_clearObserverEvent(){const{scene:t}=this._sheetObject;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_newBackgroundAndLine(){const{scene:t}=this._sheetObject;this._moveHelperBackgroundShape=new w.Rect(fd,{fill:pd,evented:!1,zIndex:100}),this._moveHelperLineShape=new w.Rect(gd,{fill:vd,evented:!1,zIndex:100}),t.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],et)}_disposeBackgroundAndLine(){var t,e;(t=this._moveHelperBackgroundShape)==null||t.dispose(),(e=this._moveHelperLineShape)==null||e.dispose()}_getSheetObject(){return Ie(this._currentUniverService,this._renderManagerService)}};Fn=_d([l.OnLifecycle(l.LifecycleStages.Rendered,Fn),yt(0,P.Inject(x.SheetSkeletonManagerService)),yt(1,l.IUniverInstanceService),yt(2,w.IRenderManagerService),yt(3,l.ICommandService),yt(4,ge),yt(5,P.Inject(f.SelectionManagerService))],Fn);var Vi=(i=>(i[i.VERTICAL=0]="VERTICAL",i[i.HORIZONTAL=1]="HORIZONTAL",i))(Vi||{});const Id="rgba(120, 120, 120, 0.01)",ki="rgb(68, 71, 70)",Gt=12,Bi=4;class Ir extends w.Shape{constructor(e,n){super(e,n);I(this,"_size",Gt);I(this,"_color",ki);I(this,"_mode",0);this.setShapeProps(n)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(e){let{width:n,height:o}=this,r=0,s=0;const a=this.getScene(),{scaleX:c,scaleY:d}=a.getAncestorScale(),u=Math.max(c,d),h=Gt/u,m=Bi/u;this.mode===0?(n=m,r=h-m):(o=m,s=h-m),w.Rect.drawWith(e,{width:this.width,height:this.height,left:0,top:0,fill:Id}),w.Rect.drawWith(e,{width:n,height:o,fill:ki,radius:m}),e.save(),e.transform(1,0,0,1,r,s),w.Rect.drawWith(e,{width:n,height:o,fill:ki,radius:m}),e.restore()}setShapeProps(e){return e!=null&&e.size&&(this._size=e.size),e!=null&&e.mode&&(this._mode=e.mode),e!=null&&e.color&&(this._color=e.color),this.mode===0?this.transformByState({width:Gt,height:this.size}):this.transformByState({width:this.size,height:Gt}),this}}var Md=Object.defineProperty,Rd=Object.getOwnPropertyDescriptor,bd=(i,t,e,n)=>{for(var o=n>1?void 0:n?Rd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Md(t,e,o),o},Kt=(i,t)=>(e,n)=>t(e,n,i);const wd="__SpreadsheetHeaderResizeControllerShapeRow__",Td="__SpreadsheetHeaderResizeControllerShapeColumn__",Mr="__SpreadsheetHeaderResizeControllerShapeHelper__",Rr="rgb(199, 199, 199)",Ed=2;let Wn=class extends l.Disposable{constructor(t,e,n,o,r){super();I(this,"_currentRow",0);I(this,"_currentColumn",0);I(this,"_rowResizeRect");I(this,"_columnResizeRect");I(this,"_observers",[]);I(this,"_moveObserver");I(this,"_upObserver");I(this,"_resizeHelperShape");I(this,"_startOffsetX",Number.POSITIVE_INFINITY);I(this,"_startOffsetY",Number.POSITIVE_INFINITY);this._sheetSkeletonManagerService=t,this._currentUniverService=e,this._commandService=n,this._renderManagerService=o,this._editorBridgeService=r,this._initialize()}dispose(){var o,r;(o=this._rowResizeRect)==null||o.dispose(),this._rowResizeRect=null,(r=this._columnResizeRect)==null||r.dispose(),this._columnResizeRect=null;const t=this._getSheetObject();if(t==null)return;const{spreadsheetRowHeader:e,spreadsheetColumnHeader:n}=t;this._observers.forEach(s=>{e.onPointerMoveObserver.remove(s),e.onPointerLeaveObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)}),this._observers=[]}_initialize(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;this._rowResizeRect=new Ir(wd,{visible:!1,mode:Vi.HORIZONTAL,zIndex:100}),this._columnResizeRect=new Ir(Td,{visible:!1,mode:Vi.VERTICAL,zIndex:100}),e.addObjects([this._rowResizeRect,this._columnResizeRect],et),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(t=0){const e=this._getSheetObject();if(e==null)return;const{spreadsheetRowHeader:n,spreadsheetColumnHeader:o,scene:r}=e,s=t===0?n:o;this._observers.push(s==null?void 0:s.onPointerMoveObserver.add((a,c)=>{var O;const d=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton;if(d==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:u,columnHeaderHeight:h}=d,{startX:m,startY:S,endX:_,endY:g,row:v,column:M}=Ct(a.offsetX,a.offsetY,r,d),R=Cn(a.offsetX,a.offsetY,r),{scaleX:b,scaleY:E}=r.getAncestorScale(),T=Math.max(b,E),y=Gt/T;if(t===0){let N=S-y/2;if(R.y<=S+y/2&&R.y>=S)this._currentRow=v-1;else if(R.y>=g-y/2&&R.y<=g)this._currentRow=v,N=g-y/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;const D=u/3;this._rowResizeRect.transformByState({left:u/2-D/2,top:N}),this._rowResizeRect.setShapeProps({size:D}),this._rowResizeRect.show()}else{let N=m-y/2;if(R.x<=m+y/2&&R.x>=m)this._currentColumn=M-1;else if(R.x>=_-y/2&&R.x<=_)this._currentColumn=M,N=_-y/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;const D=h*.7;this._columnResizeRect.transformByState({left:N,top:h/2-D/2}),this._columnResizeRect.setShapeProps({size:D}),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(t=0){const e=this._getSheetObject();if(e==null)return;const{scene:n}=e,o=t===0?this._rowResizeRect:this._columnResizeRect;if(o==null)return;const r=n.getEngine(),s=(r==null?void 0:r.width)||0,a=(r==null?void 0:r.height)||0;this.disposeWithMe(l.toDisposable(o.onPointerEnterObserver.add(()=>{o!=null&&(o.show(),n.setCursor(t===0?w.CURSOR_TYPE.ROW_RESIZE:w.CURSOR_TYPE.COLUMN_RESIZE))}))),this.disposeWithMe(l.toDisposable(o.onPointerLeaveObserver.add(()=>{o!=null&&(o.hide(),n.resetCursor())}))),this.disposeWithMe(l.toDisposable(o.onPointerDownObserver.add((c,d)=>{var ne,U,W,$,q,re,se;const u=(ne=this._sheetSkeletonManagerService.getCurrent())==null?void 0:ne.skeleton;if(u==null)return;const h=this._getSheetObject();if(h==null)return;const{scene:m}=h,S=m.getViewport(F.VIEW_MAIN),_=(((W=(U=S==null?void 0:S.getScrollBar())==null?void 0:U.horizonBarRect)==null?void 0:W.height)||0)+10,g=(((q=($=S==null?void 0:S.getScrollBar())==null?void 0:$.verticalBarRect)==null?void 0:q.width)||0)+10,v=Cn(c.offsetX,c.offsetY,m),{scaleX:M,scaleY:R}=m.getAncestorScale();this._startOffsetX=v.x,this._startOffsetY=v.y;const b=u.getOffsetByPositionX(this._currentColumn),E=u.getOffsetByPositionY(this._currentRow),T=u.getNoMergeCellPositionByIndex(this._currentRow,this._currentColumn);let y=!1,O=0,N=0;const{columnTotalWidth:D,rowHeaderWidth:k,rowTotalHeight:A,columnHeaderHeight:L}=u,B=s>D+k?s:D+k,j=a>A+L?a:A+L,X=Math.max(M,R),z=Bi/X;t===0?this._resizeHelperShape=new w.Rect(Mr,{width:B,height:z,fill:Rr,left:0,top:E-z/2}):this._resizeHelperShape=new w.Rect(Mr,{width:z,height:j,fill:Rr,left:b-z/2,top:0});const Z=((re=this._columnResizeRect)==null?void 0:re.left)||0,ee=((se=this._rowResizeRect)==null?void 0:se.top)||0;m.addObject(this._resizeHelperShape,et),m.disableEvent(),this._editorBridgeService.changeVisible({visible:!1,eventType:w.DeviceInputEventType.PointerDown}),this._moveObserver=m.onPointerMoveObserver.add(Y=>{var Je,Re,an,ln,cn,dn;const Q=m.getRelativeCoord(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),J=m.getScrollXYByRelativeCoords(Q,S),ae=Cn(Y.offsetX,Y.offsetY,m),{x:ce,y:pe}=ae,{scaleX:Qe,scaleY:Me}=m.getAncestorScale(),_e=Math.max(Qe,Me),de=Bi/_e;O=ce-this._startOffsetX-de/2,N=pe-this._startOffsetY-de/2,Math.abs(t===0?N:O)>=Ed&&(y=!0),t===0?(N>a-_+J.y-T.startY&&(N=a-_+J.y-T.startY),N<-(T.endY-T.startY)+2&&(N=-(T.endY-T.startY)+2),y&&((Je=this._resizeHelperShape)==null||Je.transformByState({top:E+N}),(Re=this._rowResizeRect)==null||Re.transformByState({top:ee+N+de/2}),(an=this._rowResizeRect)==null||an.show(),m.setCursor(w.CURSOR_TYPE.ROW_RESIZE))):(O>s-g+J.x-T.startX&&(O=s-g+J.x-T.startX),O<-(T.endX-T.startX)+2&&(O=-(T.endX-T.startX)+2),y&&((ln=this._resizeHelperShape)==null||ln.transformByState({left:b+O}),(cn=this._columnResizeRect)==null||cn.transformByState({left:Z+O+de/2}),(dn=this._columnResizeRect)==null||dn.show(),m.setCursor(w.CURSOR_TYPE.COLUMN_RESIZE)))}),this._upObserver=m.onPointerUpObserver.add(Y=>{var ae,ce,pe;const Q=Ie(this._currentUniverService,this._renderManagerService);if(Q==null)return;this._clearObserverEvent(),(ae=this._resizeHelperShape)==null||ae.dispose(),this._resizeHelperShape=null;const{scene:J}=Q;J.enableEvent(),y&&(J.resetCursor(),(ce=this._rowResizeRect)==null||ce.hide(),(pe=this._columnResizeRect)==null||pe.hide(),t===0?this._commandService.executeCommand(f.DeltaRowHeightCommand.id,{deltaY:N,anchorRow:this._currentRow}):this._commandService.executeCommand(f.DeltaColumnWidthCommand.id,{deltaX:O,anchorCol:this._currentColumn}))})}))),this.disposeWithMe(l.toDisposable(o.onDblclickObserver.add(()=>{var c;if(t===0){const d=this._getSheetObject();if(d==null)return;const{scene:u}=d;u.resetCursor(),this._commandService.executeCommand(f.SetWorksheetRowIsAutoHeightCommand.id,{anchorRow:this._currentRow}),(c=this._rowResizeRect)==null||c.hide()}})))}_clearObserverEvent(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_getSheetObject(){return Ie(this._currentUniverService,this._renderManagerService)}};Wn=bd([l.OnLifecycle(l.LifecycleStages.Rendered,Wn),Kt(0,P.Inject(x.SheetSkeletonManagerService)),Kt(1,l.IUniverInstanceService),Kt(2,l.ICommandService),Kt(3,w.IRenderManagerService),Kt(4,we)],Wn);var Fi=(i=>(i[i.ROW=0]="ROW",i[i.COLUMN=1]="COLUMN",i))(Fi||{});const Qt=12,yd=.4;class br extends w.Shape{constructor(e,n,o){super(e,n);I(this,"_size",Qt);I(this,"_iconRatio",yd);I(this,"_hovered",!0);I(this,"_hasPrevious",!0);I(this,"_hasNext",!0);I(this,"_unhideType");n&&this.setShapeProps(n),this.onPointerEnterObserver.add(()=>this.setShapeProps({hovered:!0})),this.onPointerLeaveObserver.add(()=>this.setShapeProps({hovered:!1})),this.onPointerDownObserver.add(()=>o==null?void 0:o())}setShapeProps(e){e.type!==void 0&&(this._unhideType=e.type),e.hovered!==void 0&&(this._hovered=e.hovered),e.hasPrevious!==void 0&&(this._hasPrevious=e.hasPrevious),e.hasNext!==void 0&&(this._hasNext=e.hasNext),this.transformByState({width:this._size*(this._unhideType===1?2:1),height:this._size*(this._unhideType===0?2:1)})}_draw(e){this._unhideType===0?this._drawOnRow(e):this._drawOnCol(e)}_drawOnRow(e){this._hovered&&(!this._hasNext||!this._hasPrevious?w.Rect.drawWith(e,{width:this._size,height:this._size,stroke:Ze,fill:kn}):w.Rect.drawWith(e,{width:this._size,height:2*this._size,stroke:Ze,fill:kn}));const n=this._size*.5*this._iconRatio,o=Math.PI/3,r=n*Math.cos(o),s=n*Math.sin(o);if(this._hasPrevious&&w.RegularPolygon.drawWith(e,{pointsGroup:[[{x:this._size/2,y:this._size/2-s},{x:this._size/2-s,y:this._size/2+r},{x:this._size/2+s,y:this._size/2+r}]],fill:Ze}),this._hasNext){const a=this._hasPrevious?3:1;w.RegularPolygon.drawWith(e,{pointsGroup:[[{x:this._size/2,y:this._size*a/2+s},{x:this._size/2-s,y:this._size*a/2-r},{x:this._size/2+s,y:this._size*a/2-r}]],fill:Ze})}}_drawOnCol(e){this._hovered&&(!this._hasNext||!this._hasPrevious?w.Rect.drawWith(e,{width:this._size,height:this._size,stroke:Ze,fill:kn}):w.Rect.drawWith(e,{width:2*this._size,height:this._size,stroke:Ze,fill:kn}));const n=this._size*.5*this._iconRatio,o=Math.PI/3,r=n*Math.cos(o),s=n*Math.sin(o);if(this._hasPrevious&&w.RegularPolygon.drawWith(e,{pointsGroup:[[{x:-r+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:Ze}),this._hasNext){const a=this._hasPrevious?3:1;w.RegularPolygon.drawWith(e,{pointsGroup:[[{x:r+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:Ze})}}}var Od=Object.defineProperty,xd=Object.getOwnPropertyDescriptor,Nd=(i,t,e,n)=>{for(var o=n>1?void 0:n?xd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Od(t,e,o),o},jn=(i,t)=>(e,n)=>t(e,n,i);const wr="__SpreadsheetHeaderUnhideSHAPEControllerShape__",Ad=[f.SetRowHiddenMutation.id,f.SetRowVisibleMutation.id,f.SetColHiddenMutation.id,f.SetColVisibleMutation.id];let zn=class extends l.RxDisposable{constructor(t,e,n,o){super();I(this,"_shapes",new Map);this._sheetSkeletonManagerService=t,this._cmdSrv=e,this._univerInstanceService=n,this._rendererManagerService=o,this._init()}dispose(){super.dispose()}_init(){this._getSheetObject()&&(this._sheetSkeletonManagerService.currentSkeleton$.pipe(V.takeUntil(this.dispose$),V.startWith(void 0),V.pairwise()).subscribe(([e,n])=>{if(n){const o=this._univerInstanceService.getUniverSheetInstance(n.unitId),r=o.getSheetBySheetId(n.sheetId);this._updateWorksheet(o,r,e==null?void 0:e.sheetId)}}),this.disposeWithMe(this._cmdSrv.onCommandExecuted(e=>{if(!Ad.includes(e.id)||!e.params||!e.params.unitId||!e.params.subUnitId)return;const n=this._univerInstanceService.getUniverSheetInstance(e.params.unitId),o=n==null?void 0:n.getSheetBySheetId(e.params.subUnitId);o&&this._updateWorksheet(n,o,o.getSheetId())})))}_initForWorksheet(t,e){var m;const n=(m=this._sheetSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(!n)return;const o=e.getHiddenRows(),r=e.getHiddenCols(),s=this._getSheetObject();if(!s)return;const{scene:a}=s,c=e.getRowCount(),d=o.map(S=>{const{startRow:_,endRow:g}=S,v=Ii(_,0,a,n),M=_!==0,R=g!==c-1;return new br(wr,{type:Fi.ROW,hovered:!1,hasPrevious:M,hasNext:R,top:v.startY-(M?Qt:0),left:v.startX-Qt},()=>this._cmdSrv.executeCommand(f.SetSpecificRowsVisibleCommand.id,{unitId:t.getUnitId(),subUnitId:e.getSheetId(),ranges:[S]}))}),u=e.getColumnCount(),h=r.map(S=>{const{startColumn:_,endColumn:g}=S,v=Ii(0,_,a,n),M=_!==0,R=g!==u-1;return new br(wr,{type:Fi.COLUMN,hovered:!1,hasPrevious:M,hasNext:R,left:v.startX-(M?Qt:0),top:20-Qt},()=>this._cmdSrv.executeCommand(f.SetSpecificColsVisibleCommand.id,{unitId:t.getUnitId(),subUnitId:e.getSheetId(),ranges:[S]}))});a.addObjects(h,Io),a.addObjects(d,Io),this._shapes.set(l.getWorksheetUID(t,e),{cols:h,rows:d})}_updateWorksheet(t,e,n){if(n){const o=this._shapes.get(`${t.getUnitId()}|${n}`);o==null||o.cols.forEach(r=>r.dispose()),o==null||o.rows.forEach(r=>r.dispose())}this._initForWorksheet(t,e)}_getSheetObject(){return Ie(this._univerInstanceService,this._rendererManagerService)}};zn=Nd([l.OnLifecycle(l.LifecycleStages.Rendered,zn),jn(0,P.Inject(x.SheetSkeletonManagerService)),jn(1,l.ICommandService),jn(2,l.IUniverInstanceService),jn(3,w.IRenderManagerService)],zn);var Dd=Object.defineProperty,Pd=Object.getOwnPropertyDescriptor,Ld=(i,t,e,n)=>{for(var o=n>1?void 0:n?Pd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Dd(t,e,o),o},Wi=(i,t)=>(e,n)=>t(e,n,i);let Yn=class extends l.Disposable{constructor(i,t,e){super(),this._markSelectionService=i,this._commandService=t,this._sheetSkeletonManagerService=e,this._initListeners()}_initListeners(){this._addRemoveListener(),this._addRefreshListener()}_addRemoveListener(){const i=[De.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{i.includes(t.id)?this._markSelectionService.removeAllShapes():this._markSelectionService.getShapeMap().forEach((n,o)=>{n.exits.includes(t.id)&&this._markSelectionService.removeShape(o)})}))}_addRefreshListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{i&&this._markSelectionService.refreshShapes()})))}};Yn=Ld([l.OnLifecycle(l.LifecycleStages.Steady,Yn),Wi(0,P.Inject(Lt)),Wi(1,l.ICommandService),Wi(2,P.Inject(x.SheetSkeletonManagerService))],Yn);var Hd=Object.defineProperty,Ud=Object.getOwnPropertyDescriptor,Vd=(i,t,e,n)=>{for(var o=n>1?void 0:n?Ud(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Hd(t,e,o),o},ji=(i,t)=>(e,n)=>t(e,n,i);let Xn=class extends l.Disposable{constructor(t,e,n){super();I(this,"_initialize",()=>{const t=new l.DisposableCollection;this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(()=>{t.dispose();const e=this._selectionManagerService.getCurrent();if((e==null?void 0:e.pluginName)!==f.NORMAL_SELECTION_PLUGIN_NAME)return;this._selectionRenderService.getCurrentControls().forEach(o=>{t.add(l.toDisposable(o.selectionMoved$.subscribe(r=>{if(!r)return;const s=o.model.getRange(),a={startRow:s.startRow,startColumn:s.startColumn,endRow:s.endRow,endColumn:s.endColumn,rangeType:s.rangeType},c={startRow:r.startRow,startColumn:r.startColumn,endRow:r.endRow,endColumn:r.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(f.MoveRangeCommand.id,d)})))})})))});this._selectionRenderService=t,this._selectionManagerService=e,this._commandService=n,this._initialize()}};Xn=Vd([l.OnLifecycle(l.LifecycleStages.Steady,Xn),ji(0,P.Inject(ge)),ji(1,P.Inject(f.SelectionManagerService)),ji(2,P.Inject(l.ICommandService))],Xn);var kd=Object.defineProperty,Bd=Object.getOwnPropertyDescriptor,Fd=(i,t,e,n)=>{for(var o=n>1?void 0:n?Bd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&kd(t,e,o),o},it=(i,t)=>(e,n)=>t(e,n,i);let $n=class extends l.Disposable{constructor(i,t,e,n,o,r,s,a){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=t,this._commandService=e,this._renderManagerService=n,this._selectionRenderService=o,this._selectionManagerService=r,this._themeService=s,this._definedNamesService=a,this._initialize()}_initialize(){const i=this._currentUniverService.getCurrentUniverSheetInstance(),t=i.getActiveSheet(),e=this._getSheetObject();if(e==null)return;this._initViewMainListener(e),this._initRowHeader(e),this._initColumnHeader(e),this._initLeftTop(e),this._initSelectionChangeListener(),this._initThemeChangeListener(),this._initSkeletonChangeListener(),this._initCommandListener(),this._initUserActionSyncListener(),this._initDefinedNameListener();const n=i.getUnitId(),o=t.getSheetId();this._selectionManagerService.setCurrentSelection({pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,unitId:n,sheetId:o})}_initDefinedNameListener(){this.disposeWithMe(l.toDisposable(this._definedNamesService.focusRange$.subscribe(async i=>{if(i==null)return;const{unitId:t}=i;let{formulaOrRefString:e}=i;const n=this._currentUniverService.getCurrentUniverSheetInstance();if(t!==n.getUnitId())return;e.substring(0,1)===G.operatorToken.EQUALS&&(e=e.substring(1));const o=e.split(",");if(!o.every(c=>G.isReferenceString(c.trim())))return;let s=n.getActiveSheet();const a=[];for(let c=0;c<o.length;c++){const d=o[c].trim(),u=G.deserializeRangeWithSheet(d.trim());if(c===0){const m=n.getSheetBySheetName(u.sheetName);m&&s.getSheetId()!==m.getSheetId()&&(s=m,await this._commandService.executeCommand(f.SetWorksheetActivateCommand.id,{subUnitId:s.getSheetId(),unitId:t}))}if(s.getName()!==u.sheetName)continue;let h=null;if(c===o.length-1){const m=u.range,{startRow:S,startColumn:_,endRow:g,endColumn:v}=m;h=f.getPrimaryForRange({startRow:S,startColumn:_,endRow:g,endColumn:v},s)}a.push({range:u.range,style:f.getNormalSelectionStyle(this._themeService),primary:h})}this._selectionManagerService.replace(a),this._commandService.executeCommand(f.ScrollToCellOperation.id,a[0].range)})))}_getActiveViewport(i){const t=this._getSheetObject();return t==null?void 0:t.scene.getActiveViewportByCoord(w.Vector2.FromArray([i.offsetX,i.offsetY]))}_initViewMainListener(i){const{spreadsheet:t}=i;this.disposeWithMe(l.toDisposable(t==null?void 0:t.onPointerDownObserver.add((e,n)=>{this._selectionRenderService.enableDetectMergedCell(),this._selectionRenderService.eventTrigger(e,t.zIndex+1,l.RANGE_TYPE.NORMAL,this._getActiveViewport(e)),e.button!==2&&n.stopPropagation()})))}_initThemeChangeListener(){this.disposeWithMe(l.toDisposable(this._themeService.currentTheme$.subscribe(()=>{this._selectionRenderService.resetStyle();const i=this._selectionManagerService.getSelections(),t=this._selectionManagerService.getCurrent();i==null||(t==null?void 0:t.pluginName)!==f.NORMAL_SELECTION_PLUGIN_NAME||this._refreshSelection(i)})))}_refreshSelection(i){const t=i.map(e=>{const n=this._selectionRenderService.convertSelectionRangeToData(e);return n.style=f.getNormalSelectionStyle(this._themeService),n});this._selectionRenderService.updateControlForCurrentByRangeData(t)}_initRowHeader(i){const{spreadsheetRowHeader:t,spreadsheet:e}=i;this.disposeWithMe(l.toDisposable(t==null?void 0:t.onPointerDownObserver.add((n,o)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(n,((e==null?void 0:e.zIndex)||1)+1,l.RANGE_TYPE.ROW,this._getActiveViewport(n),w.ScrollTimerType.Y),n.button!==2&&o.stopPropagation()})))}_initColumnHeader(i){const{spreadsheetColumnHeader:t,spreadsheet:e}=i;this.disposeWithMe(l.toDisposable(t==null?void 0:t.onPointerDownObserver.add((n,o)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(n,((e==null?void 0:e.zIndex)||1)+1,l.RANGE_TYPE.COLUMN,this._getActiveViewport(n),w.ScrollTimerType.X),n.button!==2&&o.stopPropagation()})))}_initLeftTop(i){const{spreadsheetLeftTopPlaceholder:t}=i;this.disposeWithMe(l.toDisposable(t==null?void 0:t.onPointerDownObserver.add((e,n)=>{var a;const o=(a=this._sheetSkeletonManagerService.getCurrent())==null?void 0:a.skeleton;if(o==null)return;this._selectionRenderService.reset();const r=this._getAllRange(o),s=this._selectionRenderService.convertSelectionRangeToData(r);this._selectionRenderService.addControlToCurrentByRangeData(s),this._selectionRenderService.refreshSelectionMoveStart(),e.button!==2&&n.stopPropagation()})))}_initSelectionChangeListener(){this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(i=>{if(this._selectionRenderService.reset(),i!=null){for(const t of i){if(t==null)continue;const e=this._selectionRenderService.convertSelectionRangeToData(t);this._selectionRenderService.addControlToCurrentByRangeData(e)}this._syncDefinedNameRange(i)}}))),this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoving$.subscribe(i=>{i!=null&&this._syncDefinedNameRange(i)}))),this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveStart$.subscribe(i=>{i!=null&&this._syncDefinedNameRange(i)})))}_syncDefinedNameRange(i){if(i.length===0)return;const t=i[i.length-1],e=this._currentUniverService.getCurrentUniverSheetInstance(),n=e.getActiveSheet();this._commandService.executeCommand(G.SetDefinedNameCurrentMutation.id,{range:t.range,unitId:e.getUnitId(),sheetId:n.getSheetId()})}_initUserActionSyncListener(){this._selectionRenderService.selectionMoveStart$.subscribe(i=>{this._move(i,f.SelectionMoveType.MOVE_START)}),this._selectionRenderService.selectionMoving$.subscribe(i=>{this._move(i,f.SelectionMoveType.MOVING)}),this._selectionRenderService.selectionMoveEnd$.subscribe(i=>{this._move(i,f.SelectionMoveType.MOVE_END)})}_move(i,t){const e=this._currentUniverService.getCurrentUniverSheetInstance(),n=e.getUnitId(),o=e.getActiveSheet().getSheetId(),r=this._selectionManagerService.getCurrent();i==null||i.length===0||this._commandService.executeCommand(f.SetSelectionsOperation.id,{unitId:n,subUnitId:o,type:t,pluginName:(r==null?void 0:r.pluginName)||f.NORMAL_SELECTION_PLUGIN_NAME,selections:i.map(s=>f.convertSelectionDataToRange(s))})}_getSheetObject(){return Ie(this._currentUniverService,this._renderManagerService)}_initCommandListener(){const i=[Pe.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(i.includes(t.id)){const e=this._currentUniverService.getCurrentUniverSheetInstance(),n=e.getActiveSheet(),o=t.params,{unitId:r,subUnitId:s}=o;if(!(r===e.getUnitId()&&s===n.getSheetId()))return;this._selectionManagerService.refreshSelection()}}))}_initSkeletonChangeListener(){this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{unitId:t,sheetId:e,skeleton:n}=i,o=this._renderManagerService.getRenderById(t);if(o==null)return;const{scene:r}=o,s=r.getViewport(F.VIEW_MAIN);this._selectionRenderService.changeRuntime(n,r,s);const a=this._selectionManagerService.getCurrent(),c=(a==null?void 0:a.pluginName)||f.NORMAL_SELECTION_PLUGIN_NAME;if((a==null?void 0:a.unitId)===t&&a.sheetId===e){const d=this._selectionManagerService.getSelections();d!=null&&this._refreshSelection(d)}else this._selectionManagerService.setCurrentSelection({pluginName:c,unitId:t,sheetId:e});c===f.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 t=i.mergeData;return f.transformCellDataToSelectionData(0,0,t)||{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}}};$n=Fd([l.OnLifecycle(l.LifecycleStages.Rendered,$n),it(0,P.Inject(x.SheetSkeletonManagerService)),it(1,l.IUniverInstanceService),it(2,l.ICommandService),it(3,w.IRenderManagerService),it(4,ge),it(5,P.Inject(f.SelectionManagerService)),it(6,P.Inject(l.ThemeService)),it(7,G.IDefinedNamesService)],$n);var Wd=Object.defineProperty,jd=Object.getOwnPropertyDescriptor,zd=(i,t,e,n)=>{for(var o=n>1?void 0:n?jd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Wd(t,e,o),o},Jt=(i,t)=>(e,n)=>t(e,n,i);let Zn=class extends l.Disposable{constructor(i,t,e,n,o){super(),this._sheetSkeletonManagerService=i,this._contextService=t,this._currentUniverService=e,this._renderManagerService=n,this._commandService=o,this._init()}_init(){this._initialRenderRefresh(),this._initCommandListener(),this._initContextListener()}_initialRenderRefresh(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{skeleton:t,unitId:e,sheetId:n}=i,o=this._currentUniverService.getUniverSheetInstance(e),r=o==null?void 0:o.getSheetBySheetId(n);if(o==null||r==null)return;const s=this._renderManagerService.getRenderById(e);if(s==null)return;const{mainComponent:a,components:c}=s,d=a,u=c.get(fe.ROW),h=c.get(fe.COLUMN),m=c.get(fe.LEFT_TOP),{rowHeaderWidth:S,columnHeaderHeight:_}=t;d==null||d.updateSkeleton(t),u==null||u.updateSkeleton(t),h==null||h.updateSkeleton(t),m==null||m.transformByState({width:S,height:_})}))}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{var n,o;const t=this._currentUniverService.getCurrentUniverSheetInstance(),e=t.getUnitId();if(f.COMMAND_LISTENER_SKELETON_CHANGE.includes(i.id)){const r=t.getActiveSheet(),s=r.getSheetId(),a=i.params,{unitId:c,subUnitId:d}=a;if(!(c===t.getUnitId()&&d===r.getSheetId()))return;i.id!==f.SetWorksheetActiveOperation.id&&this._sheetSkeletonManagerService.makeDirty({unitId:c,sheetId:s,commandId:i.id},!0),this._sheetSkeletonManagerService.setCurrent({unitId:c,sheetId:s,commandId:i.id})}else f.COMMAND_LISTENER_VALUE_CHANGE.includes(i.id)&&this._sheetSkeletonManagerService.reCalculate();i.type===l.CommandType.MUTATION&&((o=(n=this._renderManagerService.getRenderById(e))==null?void 0:n.mainComponent)==null||o.makeDirty())}))}_initContextListener(){this._contextService.subscribeContextValue$(w.RENDER_RAW_FORMULA_KEY).pipe(V.distinctUntilChanged()).subscribe(()=>{this._renderManagerService.getRenderAll().forEach(i=>{i.mainComponent instanceof w.Spreadsheet&&i.mainComponent.makeForceDirty(!0)})})}};Zn=zd([l.OnLifecycle(l.LifecycleStages.Ready,Zn),Jt(0,P.Inject(x.SheetSkeletonManagerService)),Jt(1,l.IContextService),Jt(2,l.IUniverInstanceService),Jt(3,w.IRenderManagerService),Jt(4,l.ICommandService)],Zn);const Ge={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(i,t)=>{const e=i.get(l.ICommandService),n=i.get(l.IUndoRedoService),o=i.get(l.IUniverInstanceService),r=i.get(C.IConfirmService),s=i.get(l.LocaleService),a=t.unitId,c=t.subUnitId,d=t.selections,u=f.getAddMergeMutationRangeByType(d,t.value),h=o.getUniverSheetInstance(a).getSheetBySheetId(c),m=[],S=[],_=Go(h,u);if(_&&!await r.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:"merge.confirm.title"},cancelText:s.t("merge.confirm.cancel"),confirmText:s.t("merge.confirm.confirm")}))return!1;const g={unitId:a,subUnitId:c,ranges:u},v={unitId:a,subUnitId:c,ranges:u},M=f.RemoveMergeUndoMutationFactory(i,g),R=f.AddMergeUndoMutationFactory(i,v);if(M.ranges.length>0&&m.push({id:f.RemoveWorksheetMergeMutation.id,params:M}),m.push({id:f.AddWorksheetMergeMutation.id,params:v}),S.push({id:f.RemoveWorksheetMergeMutation.id,params:R}),M.ranges.length>0&&S.push({id:f.AddWorksheetMergeMutation.id,params:M}),_){const y=Ko(i,a,h,u);m.unshift(...y.redos),S.push(...y.undos)}const b=f.AddMergeRedoSelectionsOperationFactory(i,t,u);b&&m.push(b);const E=f.AddMergeUndoSelectionsOperationFactory(i,t);return E&&S.push(E),l.sequenceExecute(m,e).result?(n.pushUndoRedo({unitID:a,undoMutations:S,redoMutations:m}),!0):!1}},Tr={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async i=>{const t=i.get(l.ICommandService),n=i.get(f.SelectionManagerService).getSelectionRanges(),o=vi(vn.MergeAll,n);if(!(o!=null&&o.length))return!1;const s=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!s)return!1;const a=s.getActiveSheet();if(!a)return!1;const c=s.getUnitId(),d=a.getSheetId();return t.executeCommand(Ge.id,{selections:o,unitId:c,subUnitId:d})}},Er={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async i=>{const t=i.get(l.ICommandService),n=i.get(f.SelectionManagerService).getSelectionRanges(),o=vi(vn.MergeVertical,n);if(!(o!=null&&o.length))return!1;const s=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!s)return!1;const a=s.getActiveSheet();if(!a)return!1;const c=s.getUnitId(),d=a.getSheetId();return t.executeCommand(Ge.id,{value:l.Dimension.COLUMNS,selections:o,unitId:c,subUnitId:d})}},yr={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async i=>{const t=i.get(l.ICommandService),n=i.get(f.SelectionManagerService).getSelectionRanges(),o=vi(vn.MergeHorizontal,n);if(!(o!=null&&o.length))return!1;const s=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!s)return!1;const a=s.getActiveSheet();if(!a)return!1;const c=s.getUnitId(),d=a.getSheetId();return t.executeCommand(Ge.id,{value:l.Dimension.ROWS,selections:o,unitId:c,subUnitId:d})}},zi={type:l.CommandType.COMMAND,id:"sheet.command.delete-range-move-left-confirm",handler:async i=>{const t=i.get(C.IConfirmService),e=i.get(l.ICommandService),n=i.get(l.LocaleService),o=i.get(f.SelectionManagerService),r=i.get(l.IUniverInstanceService),s=o.getSelections();if(!s)return!1;const c=r.getCurrentUniverSheetInstance().getActiveSheet();let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const _=l.Rectangle.getIntersects(S,d);return _?u(S)>u(_):!1})||await t.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")})?e.executeCommand(f.DeleteRangeMoveLeftCommand.id):!0}},Yi={type:l.CommandType.COMMAND,id:"sheet.command.delete-range-move-up-confirm",handler:async i=>{const t=i.get(C.IConfirmService),e=i.get(l.ICommandService),n=i.get(l.LocaleService),o=i.get(f.SelectionManagerService),r=i.get(l.IUniverInstanceService),s=o.getSelections();if(!s)return!1;const c=r.getCurrentUniverSheetInstance().getActiveSheet();let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getColumnCount()-1};const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const _=l.Rectangle.getIntersects(S,d);return _?u(S)>u(_):!1})||await t.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")})?e.executeCommand(f.DeleteRangeMoveUpCommand.id):!0}},Xi={type:l.CommandType.COMMAND,id:"sheet.command.insert-range-move-down-confirm",handler:async i=>{const t=i.get(C.IConfirmService),e=i.get(l.ICommandService),n=i.get(l.LocaleService),o=i.get(f.SelectionManagerService),r=i.get(l.IUniverInstanceService),s=o.getSelections();if(!s)return!1;const c=r.getCurrentUniverSheetInstance().getActiveSheet();let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getColumnCount()-1};const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const _=l.Rectangle.getIntersects(S,d);return _?u(S)>u(_):!1})||await t.confirm({id:Xi.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")})?e.executeCommand(f.InsertRangeMoveDownCommand.id):!0}},$i={type:l.CommandType.COMMAND,id:"sheet.command.insert-range-move-right-confirm",handler:async i=>{const t=i.get(C.IConfirmService),e=i.get(l.ICommandService),n=i.get(l.LocaleService),o=i.get(f.SelectionManagerService),r=i.get(l.IUniverInstanceService),s=o.getSelections();if(!s)return!1;const c=r.getCurrentUniverSheetInstance().getActiveSheet();let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const _=l.Rectangle.getIntersects(S,d);return _?u(S)>u(_):!1})||await t.confirm({id:$i.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")})?e.executeCommand(f.InsertRangeMoveRightCommand.id):!0}},Or={id:"sheet.command.refill",type:l.CommandType.COMMAND,handler:async(i,t)=>{const e=i.get(Wt);return e.applyType=t.type,!0}},xr={id:"sheet.command.remove-row-confirm",type:l.CommandType.COMMAND,handler:async(i,t)=>{var d;const e=i.get(f.SelectionManagerService);let n=t==null?void 0:t.range;if(n||(n=(d=e.getLast())==null?void 0:d.range),!n)return!1;const o=i.get(l.ICommandService),c=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance().getActiveSheet().getVisibleRows();if(Bo(c,[n])){const u=i.get(C.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 o.executeCommand(f.RemoveRowCommand.id,{range:n}),!0}},Nr={id:"sheet.command.remove-col-confirm",type:l.CommandType.COMMAND,handler:async(i,t)=>{var d;const e=i.get(f.SelectionManagerService);let n=t==null?void 0:t.range;if(n||(n=(d=e.getLast())==null?void 0:d.range),!n)return!1;const o=i.get(l.ICommandService),c=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance().getActiveSheet().getVisibleCols();if(Fo(c,[n])){const u=i.get(C.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 o.executeCommand(f.RemoveColCommand.id,{range:n}),!0}},Ar={id:"sheet.command.remove-sheet-confirm",type:l.CommandType.COMMAND,handler:async(i,t)=>{const{subUnitId:e}=t,n=i.get(C.IConfirmService),o=i.get(l.ICommandService),r=i.get(l.LocaleService);return await n.confirm({id:"sheet.confirm.remove-sheet",title:{title:r.t("sheetConfig.deleteSheet")},children:{title:r.t("sheetConfig.deleteSheetContent")},cancelText:r.t("button.cancel"),confirmText:r.t("button.confirm")})?(await o.executeCommand(f.RemoveSheetCommand.id,{subUnitId:e}),!0):!1}},Ot=P.createIdentifier("univer.sheetbar-service");class Yd extends l.Disposable{constructor(){super();I(this,"renameId$");I(this,"removeId$");I(this,"scroll$");I(this,"scrollX$");I(this,"addSheet$");I(this,"_renameId$");I(this,"_removeId$");I(this,"_scroll$");I(this,"_scrollX$");I(this,"_addSheet$");I(this,"_currentHandler",null);this._renameId$=new V.Subject,this.renameId$=this._renameId$.asObservable(),this._removeId$=new V.Subject,this.removeId$=this._removeId$.asObservable(),this._scroll$=new V.Subject,this.scroll$=this._scroll$.asObservable(),this._scrollX$=new V.Subject,this.scrollX$=this._scrollX$.asObservable(),this._addSheet$=new V.Subject,this.addSheet$=this._addSheet$.asObservable()}setRenameId(e){this._renameId$.next(e)}setRemoveId(e){this._removeId$.next(e)}setScroll(e){this._scroll$.next(e)}setScrollX(e){this._scrollX$.next(e)}setAddSheet(e){this._addSheet$.next(e)}triggerSheetBarMenu(){var e;(e=this._currentHandler)==null||e.handleSheetBarMenu()}registerSheetBarMenuHandler(e){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=e,l.toDisposable(()=>{this._currentHandler=null})}}const Dr={id:"ui-sheet.command.show-menu-list",type:l.CommandType.OPERATION,handler:async i=>(i.get(Ot).triggerSheetBarMenu(),!0)},Pr={id:"sheet.operation.rename-sheet",type:l.CommandType.OPERATION,handler:async(i,t)=>{const e=i.get(Ot);return t&&e.setRenameId(t.subUnitId),!0}};var ye=function(){return ye=Object.assign||function(i){for(var t,e=1,n=arguments.length;e<n;e++){t=arguments[e];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(i[o]=t[o])}return i},ye.apply(this,arguments)},Xd=function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(i);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(i,n[o])&&(e[n[o]]=i[n[o]]);return e},Ce=H.forwardRef(function(i,t){var e=i.icon,n=i.id,o=i.className,r=i.extend,s=Xd(i,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),c=H.useRef("_".concat(Gd()));return Lr(e,"".concat(n),{defIds:e.defIds,idSuffix:c.current},ye({ref:t,className:a},s),r)});function Lr(i,t,e,n,o){return H.createElement(i.tag,ye(ye({key:t},$d(i,e,o)),n),(Zd(i,e).children||[]).map(function(r,s){return Lr(r,"".concat(t,"-").concat(i.tag,"-").concat(s),e,void 0,o)}))}function $d(i,t,e){var n=ye({},i.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1);var o=t.defIds;return!o||o.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],a=r[1];typeof a=="string"&&(n[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Zd(i,t){var e,n=t.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((e=i.children)===null||e===void 0)&&e.length)?ye(ye({},i),{children:i.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?ye(ye({},o),{attrs:ye(ye({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):i}function Gd(){return Math.random().toString(36).substring(2,8)}Ce.displayName="UniverIcon";var Kd={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"}}]},Hr=H.forwardRef(function(i,t){return H.createElement(Ce,Object.assign({},i,{id:"autofill",ref:t,icon:Kd}))});Hr.displayName="Autofill";const Qd=Hr;var Jd={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"}}]},Ur=H.forwardRef(function(i,t){return H.createElement(Ce,Object.assign({},i,{id:"check-mark-single",ref:t,icon:Jd}))});Ur.displayName="CheckMarkSingle";const qt=Ur;var qd={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"}}]},Vr=H.forwardRef(function(i,t){return H.createElement(Ce,Object.assign({},i,{id:"close-single",ref:t,icon:qd}))});Vr.displayName="CloseSingle";const eu=Vr;var tu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1213",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{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"}}]}]},kr=H.forwardRef(function(i,t){return H.createElement(Ce,Object.assign({},i,{id:"convert-single",ref:t,icon:tu}))});kr.displayName="ConvertSingle";const nu=kr;var iu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6.78662 6.17993C7.12169 6.17993 7.39331 6.45156 7.39331 6.78662V10.7301C7.39331 11.0652 7.12169 11.3368 6.78662 11.3368 6.45156 11.3368 6.17993 11.0652 6.17993 10.7301V6.78662C6.17993 6.45156 6.45156 6.17993 6.78662 6.17993zM9.82007 6.78662C9.82007 6.45156 9.54844 6.17993 9.21338 6.17993 8.87831 6.17993 8.60669 6.45156 8.60669 6.78662V10.7301C8.60669 11.0652 8.87831 11.3368 9.21338 11.3368 9.54844 11.3368 9.82007 11.0652 9.82007 10.7301V6.78662z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.57094 1.32642C6.34938 1.32642 6.14544 1.44719 6.03894 1.64148L5.21395 3.14648H1.93311C1.59804 3.14648 1.32642 3.41811 1.32642 3.75317C1.32642 4.08824 1.59804 4.35986 1.93311 4.35986H2.84314V14.0669C2.84314 14.402 3.11476 14.6736 3.44983 14.6736H12.5502C12.8852 14.6736 13.1569 14.402 13.1569 14.0669V4.35986H14.0669C14.402 4.35986 14.6736 4.08824 14.6736 3.75317C14.6736 3.41811 14.402 3.14648 14.0669 3.14648H10.7895L9.98357 1.64602C9.87785 1.4492 9.67252 1.32642 9.44911 1.32642H6.57094ZM9.4122 3.14648L9.08632 2.53979H6.93024L6.59767 3.14648H9.4122ZM4.05652 4.35986V13.4602H11.9435V4.35986H4.05652Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Br=H.forwardRef(function(i,t){return H.createElement(Ce,Object.assign({},i,{id:"delete-single",ref:t,icon:iu}))});Br.displayName="DeleteSingle";const ou=Br;var ru={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_371_77",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_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"}}]}]},Fr=H.forwardRef(function(i,t){return H.createElement(Ce,Object.assign({},i,{id:"dropdown-single",ref:t,icon:ru}))});Fr.displayName="DropdownSingle";const Wr=Fr;var su={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M0 0H16V16H0z",opacity:.01}},{tag:"path",attrs:{fill:"currentColor",d:"M8.09973 1.50049C4.51022 1.50049 1.59973 4.41098 1.59973 8.00049C1.59973 11.59 4.51022 14.5005 8.09973 14.5005C11.6892 14.5005 14.5997 11.59 14.5997 8.00049C14.5997 4.41098 11.6892 1.50049 8.09973 1.50049ZM10.4995 10.4701L9.5419 10.4657L8.09971 8.74643L6.65897 10.4643L5.69993 10.4686C5.63609 10.4686 5.58386 10.4179 5.58386 10.3526C5.58386 10.325 5.59402 10.2989 5.61143 10.2771L7.49904 8.02824L5.61143 5.7808C5.59402 5.75904 5.58386 5.73292 5.58386 5.70536C5.58386 5.64152 5.63609 5.58929 5.69993 5.58929L6.65897 5.59364L8.09971 7.31295L9.54045 5.59509L10.498 5.59074C10.5619 5.59074 10.6141 5.64152 10.6141 5.70681C10.6141 5.73438 10.604 5.76049 10.5865 5.78225L8.70183 8.02969L10.588 10.2786C10.6054 10.3003 10.6156 10.3265 10.6156 10.354C10.6156 10.4179 10.5633 10.4701 10.4995 10.4701Z",fillRule:"evenodd",clipRule:"evenodd"}}]},jr=H.forwardRef(function(i,t){return H.createElement(Ce,Object.assign({},i,{id:"error-single",ref:t,icon:su}))});jr.displayName="ErrorSingle";const zr=jr;var au={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"}}]},Yr=H.forwardRef(function(i,t){return H.createElement(Ce,Object.assign({},i,{id:"eyelash-single",ref:t,icon:au}))});Yr.displayName="EyelashSingle";const lu=Yr;var cu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_367_60",style:{maskType:"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"}}]}]},Xr=H.forwardRef(function(i,t){return H.createElement(Ce,Object.assign({},i,{id:"fx-single",ref:t,icon:cu}))});Xr.displayName="FxSingle";const du=Xr;var uu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_249",style:{maskType:"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"}}]}]},$r=H.forwardRef(function(i,t){return H.createElement(Ce,Object.assign({},i,{id:"increase-single",ref:t,icon:uu}))});$r.displayName="IncreaseSingle";const Zr=$r;var hu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_556",style:{maskType:"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"}}]}]},Gr=H.forwardRef(function(i,t){return H.createElement(Ce,Object.assign({},i,{id:"more-down-single",ref:t,icon:hu}))});Gr.displayName="MoreDownSingle";const Gn=Gr;var mu={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"}}]},Kr=H.forwardRef(function(i,t){return H.createElement(Ce,Object.assign({},i,{id:"more-single",ref:t,icon:mu}))});Kr.displayName="MoreSingle";const Qr=Kr;var Su={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1204",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_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"}}]}]},Jr=H.forwardRef(function(i,t){return H.createElement(Ce,Object.assign({},i,{id:"paint-bucket",ref:t,icon:Su}))});Jr.displayName="PaintBucket";const _u=Jr;var fu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.40051 8.00049C1.40051 4.41098 4.311 1.50049 7.90051 1.50049C11.49 1.50049 14.4005 4.41098 14.4005 8.00049C14.4005 11.59 11.49 14.5005 7.90051 14.5005C4.311 14.5005 1.40051 11.59 1.40051 8.00049ZM7.31368 5.3379L7.56087 9.33424H8.24066L8.49816 5.3379L8.51876 4.12252H7.28278L7.31368 5.3379ZM7.07678 11.0646C7.07678 11.5693 7.44758 11.8783 7.90077 11.8783C8.35396 11.8783 8.72476 11.5693 8.72476 11.0646C8.72476 10.5805 8.35396 10.2612 7.90077 10.2612C7.44758 10.2612 7.07678 10.5805 7.07678 11.0646Z",fillRule:"evenodd",clipRule:"evenodd"}}]},qr=H.forwardRef(function(i,t){return H.createElement(Ce,Object.assign({},i,{id:"warning-single",ref:t,icon:fu}))});qr.displayName="WarningSingle";const es=qr,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:"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"})]}),pu=()=>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"})]}),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.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"})]}),Cu=()=>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"})]}),Iu=()=>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"})}),Mu=()=>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"})]}),Ru=()=>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"})]}),bu=()=>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"})]}),wu=()=>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"})}),ts=()=>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 ns(i){const{type:t=l.BorderStyleTypes.THIN}=i;switch(t){case l.BorderStyleTypes.DASH_DOT:return p.jsx(gu,{});case l.BorderStyleTypes.DASH_DOT_DOT:return p.jsx(pu,{});case l.BorderStyleTypes.DASHED:return p.jsx(vu,{});case l.BorderStyleTypes.HAIR:return p.jsx(Cu,{});case l.BorderStyleTypes.MEDIUM:return p.jsx(Iu,{});case l.BorderStyleTypes.MEDIUM_DASH_DOT:return p.jsx(Mu,{});case l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return p.jsx(Ru,{});case l.BorderStyleTypes.MEDIUM_DASHED:return p.jsx(bu,{});case l.BorderStyleTypes.THICK:return p.jsx(wu,{});case l.BorderStyleTypes.THIN:return p.jsx(ts,{});default:return p.jsx(ts,{})}}const Ve={uiPluginSheetsBorderPanel:"univer-ui-plugin-sheets-border-panel",uiPluginSheetsBorderPanelPosition:"univer-ui-plugin-sheets-border-panel-position",uiPluginSheetsBorderPanelPositionItem:"univer-ui-plugin-sheets-border-panel-position-item",uiPluginSheetsBorderPanelPositionItemActive:"univer-ui-plugin-sheets-border-panel-position-item-active",uiPluginSheetsBorderPanelStyles:"univer-ui-plugin-sheets-border-panel-styles",uiPluginSheetsBorderPanelBoard:"univer-ui-plugin-sheets-border-panel-board",uiPluginSheetsBorderPanelButton:"univer-ui-plugin-sheets-border-panel-button",uiPluginSheetsBorderPanelMoreIcon:"univer-ui-plugin-sheets-border-panel-more-icon"},is=`${bt}_BORDER_PANEL_COMPONENT`,os=[{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"}],Tu=[{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 Eu(i){var c;const t=K.useDependency(C.ComponentManager),e=K.useDependency(f.BorderStyleManagerService),{onChange:n,value:o}=i;function r(d,u){n==null||n({...o,[u]:d})}function s(d){const u=t.get(d);return u&&p.jsx(u,{extend:{colorChannel1:"rgb(var(--primary-color))"}})}function a(d){d.stopPropagation()}return p.jsxs("section",{className:Ve.uiPluginSheetsBorderPanel,children:[p.jsx("div",{className:Ve.uiPluginSheetsBorderPanelPosition,children:os.map(d=>p.jsx("div",{className:e.getBorderInfo().type===d.value?`${Ve.uiPluginSheetsBorderPanelPositionItemActive} ${Ve.uiPluginSheetsBorderPanelPositionItem}`:Ve.uiPluginSheetsBorderPanelPositionItem,onClick:u=>{u.stopPropagation(),r(d.value,"type")},children:s(d.icon)},d.value))}),p.jsxs("div",{className:Ve.uiPluginSheetsBorderPanelStyles,children:[p.jsx("div",{children:p.jsx(le.Dropdown,{align:{offset:[0,18]},overlay:p.jsx("section",{className:Ve.uiPluginSheetsBorderPanelBoard,onClick:a,children:p.jsx(le.ColorPicker,{onChange:d=>r(d,"color")})}),children:p.jsxs("a",{className:Ve.uiPluginSheetsBorderPanelButton,onClick:a,children:[p.jsx(_u,{extend:{colorChannel1:(c=o.color)!=null?c:"rgb(var(--primary-color))"}}),p.jsx("span",{className:Ve.uiPluginSheetsBorderPanelMoreIcon,children:p.jsx(Gn,{})})]})})}),p.jsx("div",{children:p.jsx(le.Dropdown,{align:{offset:[0,18]},overlay:p.jsx("section",{onClick:a,children:p.jsx(le.Menu,{children:Tu.map(d=>p.jsx(le.MenuItem,{eventKey:d.value.toString(),onClick:()=>r(d.value,"style"),children:p.jsx(ns,{type:d.value})},d.value))})}),children:p.jsxs("a",{className:Ve.uiPluginSheetsBorderPanelButton,onClick:a,children:[p.jsx(ns,{type:l.BorderStyleTypes.THIN}),p.jsx("span",{className:Ve.uiPluginSheetsBorderPanelMoreIcon,children:p.jsx(Gn,{})})]})})})]})]})}const yu={countBar:"univer-count-bar"},Ou=[50,80,100,130,150,170,200,400];function xu(){const i=K.useDependency(l.ICommandService),t=K.useDependency(l.IUniverInstanceService),e=H.useCallback(()=>{const s=t.getCurrentUniverSheetInstance().getActiveSheet().getZoomRatio()*100||100;return Math.round(s)},[t]),[n,o]=H.useState(()=>e());H.useEffect(()=>i.onCommandExecuted(a=>{if(a.id===Pe.id||a.id===f.SetWorksheetActivateCommand.id){const c=e();o(c)}}).dispose,[i,e]);function r(s){o(s);const a=t.getCurrentUniverSheetInstance(),c=a==null?void 0:a.getActiveSheet();if(c==null)return;const d=s/100;i.executeCommand(Ln.id,{unitId:a.getUnitId(),subUnitId:c.getSheetId(),zoomRatio:d})}return p.jsx(le.Slider,{min:ci[0],value:n,shortcuts:Ou,onChange:r})}function Nu(i){return p.jsx("section",{className:yu.countBar,children:p.jsx(xu,{})})}const rs={editorContainer:"univer-editor-container",editorInput:"univer-editor-input"},Kn=-1e3,ss={width:0,height:0,top:Kn,left:Kn},Au=()=>{const[i,t]=H.useState({...ss}),e=K.useDependency(Yt),n=K.useDependency(C.IEditorService),o={id:l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:{dataStream:`${l.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{}};return H.useEffect(()=>{e.state$.subscribe(r=>{if(r==null)return;const{startX:s=Kn,startY:a=Kn,endX:c=0,endY:d=0,show:u=!1}=r;if(!u)t({...ss});else{t({width:c-s-w.FIX_ONE_PIXEL_BLUR_OFFSET*2,height:d-a-w.FIX_ONE_PIXEL_BLUR_OFFSET*2,left:s+w.FIX_ONE_PIXEL_BLUR_OFFSET,top:a+w.FIX_ONE_PIXEL_BLUR_OFFSET});const h=n.getEditor(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(h==null)return;const{left:m,top:S,width:_,height:g}=h.getBoundingClientRect();e.setRect({left:m,top:S,width:_,height:g})}})},[]),H.useEffect(()=>{e.setFocus(!0)},[i]),p.jsx("div",{className:rs.editorContainer,style:{left:i.left,top:i.top,width:i.width,height:i.height},children:p.jsx(C.TextEditor,{id:l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,className:rs.editorInput,snapshot:o,cancelDefaultResizeListener:!0,isSheetEditor:!0,isSingle:!1})})},ue={definedName:"univer-defined-name",definedNameDropDown:"univer-defined-name-drop-down",definedNameOverlay:"univer-defined-name-overlay",definedNameOverlayContainer:"univer-defined-name-overlay-container",definedNameOverlayItem:"univer-defined-name-overlay-item",definedNameOverlayItemName:"univer-defined-name-overlay-item-name",definedNameOverlayItemNameForSheet:"univer-defined-name-overlay-item-name-for-sheet",definedNameOverlayItemFormula:"univer-defined-name-overlay-item-formula",definedNameOverlayManager:"univer-defined-name-overlay-manager",definedNameOverlayManagerTitle:"univer-defined-name-overlay-manager-title",definedNameOverlayManagerContent:"univer-defined-name-overlay-manager-content",definedNameContainer:"univer-defined-name-container",definedNameContainerScroll:"univer-defined-name-container-scroll",definedNameContainerAddButton:"univer-defined-name-container-addButton",definedNameContainerAddButtonText:"univer-defined-name-container-addButton-text",definedNameContainerItem:"univer-defined-name-container-item",definedNameContainerItemName:"univer-defined-name-container-item-name",definedNameContainerItemNameForSheet:"univer-defined-name-container-item-name-for-sheet",definedNameContainerItemFormulaOrRefString:"univer-defined-name-container-item-formula-or-refString",definedNameContainerItemUpdate:"univer-defined-name-container-item-update",definedNameContainerItemDelete:"univer-defined-name-container-item-delete",definedNameContainerItemShow:"univer-defined-name-container-item-show",definedNameInput:"univer-defined-name-input",definedNameInputValidation:"univer-defined-name-input-validation"},as="DefinedNameContainer",Zi="AllDefaultWorkbook",ls={id:"sidebar.operation.defined-name",type:l.CommandType.COMMAND,handler:async(i,t)=>{const e=i.get(C.ISidebarService),n=i.get(C.IEditorService),o=i.get(l.LocaleService),s=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();switch(t.value){case"open":n.setOperationSheetUnitId(s.getUnitId()),e.open({header:{title:o.t("definedName.featureTitle")},children:{label:as},onClose:()=>{n.closeRangePrompt()},width:333});break;case"close":default:e.close();break}return!0}};function Du(i){const t=K.useDependency(l.ICommandService),e=K.useDependency(l.LocaleService),n=K.useDependency(G.IDefinedNamesService),s=K.useDependency(l.IUniverInstanceService).getCurrentUniverSheetInstance().getUnitId(),a=()=>{const m=n.getDefinedNameMap(s);return m?Array.from(Object.values(m)):[]},[c,d]=H.useState(a());H.useEffect(()=>{const m=n.update$.subscribe(()=>{d(a())});return()=>{m.unsubscribe()}},[]);const u=()=>{t.executeCommand(ls.id,{value:"open"})},h=m=>{n.focusRange(s,m.id)};return p.jsxs("div",{className:ue.definedNameOverlay,children:[p.jsx("div",{className:ue.definedNameOverlayContainer,children:c.map((m,S)=>p.jsxs("div",{className:ue.definedNameOverlayItem,onClick:()=>{h(m)},children:[p.jsx("div",{className:ue.definedNameOverlayItemName,title:m.name,children:m.name}),p.jsx("div",{className:ue.definedNameOverlayItemFormula,title:m.formulaOrRefString,children:m.formulaOrRefString})]},S))}),p.jsxs("div",{className:ue.definedNameOverlayManager,onClick:u,children:[p.jsx("div",{className:ue.definedNameOverlayManagerTitle,children:e.t("definedName.managerTitle")}),p.jsx("div",{className:ue.definedNameOverlayManagerContent,children:e.t("definedName.managerDescription")})]})]})}function Pu(){const[i,t]=H.useState(""),e=K.useDependency(G.IDefinedNamesService);return H.useEffect(()=>{const n=e.currentRange$.subscribe(()=>{t(e.getCurrentRangeForString())});return()=>{n.unsubscribe()}},[]),p.jsxs("div",{className:ue.definedName,children:[p.jsx(le.Input,{value:i,type:"text",size:"small",affixWrapperStyle:{border:"none",padding:"6px"}}),p.jsx(le.Dropdown,{overlay:p.jsx(Du,{}),children:p.jsx("div",{className:ue.definedNameDropDown,children:p.jsx(Gn,{})})})]})}const Se={formulaBox:"univer-formula-box",nameRanges:"univer-name-ranges",formulaBar:"univer-formula-bar",formulaIcon:"univer-formula-icon",formulaIconWrapper:"univer-formula-icon-wrapper",iconContainer:"univer-icon-container",iconContainerSuccess:"univer-icon-container-success",formulaActive:"univer-formula-active",iconContainerError:"univer-icon-container-error",iconContainerFx:"univer-icon-container-fx",formulaInput:"univer-formula-input",formulaContent:"univer-formula-content",arrowContainer:"univer-arrow-container"};function Lu(){const[i,t]=H.useState(Se.formulaGrey),[e,n]=H.useState(0),o=K.useDependency(wn),r=K.useDependency(we),s={id:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:`${l.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},marginTop:5,marginBottom:5,marginRight:0,marginLeft:0,paragraphLineGapDefault:0,renderConfig:{horizontalAlign:l.HorizontalAlign.UNSPECIFIED,verticalAlign:l.VerticalAlign.TOP,centerAngle:0,vertexAngle:0,wrapStrategy:l.WrapStrategy.WRAP}}};H.useEffect(()=>{r.visible$.subscribe(m=>{t(m.visible?Se.formulaActive:Se.formulaGrey)})},[]);function a(m){if(m==null)return;const S=m.getBoundingClientRect();o.setPosition(S)}function c(){n(e===0?1:0),setTimeout(()=>{o.handleFoldBtnClick(e===1)},150)}function d(){r.isVisible().visible&&r.changeVisible({visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:C.KeyCode.ESC})}function u(){r.isVisible().visible&&r.changeVisible({visible:!1,eventType:w.DeviceInputEventType.PointerDown})}function h(){o.handleFxBtnClick(!0)}return p.jsxs("div",{className:Se.formulaBox,style:{height:e===0?"28px":"82px"},children:[p.jsx("div",{className:Se.nameRanges,children:p.jsx(Pu,{})}),p.jsxs("div",{className:Se.formulaBar,children:[p.jsx("div",{className:Se.formulaIcon,children:p.jsxs("div",{className:Se.formulaIconWrapper,children:[p.jsx("span",{className:xe(Se.iconContainer,Se.iconContainerError,i),onClick:d,children:p.jsx(eu,{})}),p.jsx("span",{className:xe(Se.iconContainer,Se.iconContainerSuccess,i),onClick:u,children:p.jsx(qt,{})}),p.jsx("span",{className:xe(Se.iconContainer,Se.iconContainerFx),onClick:h,children:p.jsx(du,{})})]})}),p.jsxs("div",{className:Se.formulaInput,children:[p.jsx(C.TextEditor,{id:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,isSheetEditor:!0,resizeCallBack:a,cancelDefaultResizeListener:!0,onContextMenu:m=>m.preventDefault(),className:Se.formulaContent,snapshot:s,isSingle:!1}),p.jsx("div",{className:Se.arrowContainer,onClick:c,children:e===0?p.jsx(Wr,{}):p.jsx(Wr,{style:{transform:"rotateZ(180deg)"}})})]})]})]})}const dt={operateContainer:"univer-operate-container",autoFillPopupMenu:"univer-auto-fill-popup-menu",autoFillPopupMenuItem:"univer-auto-fill-popup-menu-item",autoFillPopupMenuItemIcon:"univer-auto-fill-popup-menu-item-icon",autoFillPopupMenuItemTitle:"univer-auto-fill-popup-menu-item-title",autoFillPopupMenuItemHide:"univer-auto-fill-popup-menu-item-hide",btnContainer:"univer-btn-container",btnContainerExpand:"univer-btn-container-expand"},Hu=()=>{const[,i]=H.useState({});return H.useCallback(()=>i(t=>!t),[])},Uu=()=>{var ne;const i=K.useDependency(l.ICommandService),t=K.useDependency(x.SheetSkeletonManagerService),e=K.useDependency(l.IUniverInstanceService),n=K.useDependency(w.IRenderManagerService),o=K.useDependency(ge),r=K.useDependency(Wt),s=K.useDependency(l.LocaleService),[a,c]=H.useState([]),[d,u]=H.useState(!1),[h,m]=H.useState({row:-1,col:-1}),[S,_]=H.useState(oe.SERIES),[g,v]=H.useState(!1),M=()=>{v(!0)},R=()=>{v(!1)},b=Hu(),E=Ie(e,n);if(E==null)return null;const{scene:T}=E;if(H.useEffect(()=>{const U=[De.id,_n.id,Pe.id,f.SetWorksheetActiveOperation.id,f.MoveRangeMutation.id];return i.onCommandExecuted($=>{$.id===nt.id&&b(),U.includes($.id)&&m({row:-1,col:-1})}).dispose},[b,i]),H.useEffect(()=>l.toDisposable(r.menu$.subscribe(W=>{c(W.map($=>({...$,index:W.indexOf($)})))})).dispose,[r]),H.useEffect(()=>l.toDisposable(r.showMenu$.subscribe(W=>{const{source:$,target:q}=r.autoFillLocation||{source:null,target:null};if(W&&$&&q){const re=l.Rectangle.union($,q);m({row:re.endRow,col:re.endColumn})}})).dispose,[r]),H.useEffect(()=>l.toDisposable(r.applyType$.subscribe(W=>{_(W)})).dispose,[r]),H.useEffect(()=>{function U(){u(!1)}return document.addEventListener("wheel",U),()=>{document.removeEventListener("wheel",U)}},[d]),h.col<0||h.row<0)return null;const y=(ne=t.getCurrent())==null?void 0:ne.skeleton,O=o.getViewPort(),N=T==null?void 0:T.scaleX,D=T==null?void 0:T.scaleY,k=T==null?void 0:T.getScrollXY(O);if(!N||!T||!N||!D||!k)return null;const A=(y==null?void 0:y.getNoMergeCellPositionByIndex(h.row,h.col).endX)||0,L=(y==null?void 0:y.getNoMergeCellPositionByIndex(h.row,h.col).endY)||0,B=y==null?void 0:y.convertTransformToOffsetX(A,N,k),j=y==null?void 0:y.convertTransformToOffsetY(L,D,k);if(B==null||j==null)return null;const X=U=>{u(U)},z=U=>{i.executeCommand(Or.id,{type:U.value})},Z=d||g,ee=a.filter(U=>!U.disable);return p.jsx("div",{onMouseEnter:M,onMouseLeave:R,style:{left:`${B+2}px`,top:`${j+2}px`,position:"absolute"},children:p.jsx(le.Dropdown,{placement:"bottomLeft",trigger:["click"],overlay:p.jsx("ul",{className:dt.autoFillPopupMenu,children:ee.map(U=>p.jsxs("li",{onClick:()=>z(U),className:dt.autoFillPopupMenuItem,children:[p.jsx("span",{className:dt.autoFillPopupMenuItemIcon,children:U.value===S&&p.jsx(qt,{style:{color:"rgb(var(--green-700, #409f11))"}})}),p.jsx("span",{className:dt.autoFillPopupMenuItemTitle,children:s.t(U.label)})]},U.index))}),visible:d,onVisibleChange:X,children:p.jsxs("div",{className:xe(dt.btnContainer,{[dt.btnContainerExpand]:d}),children:[p.jsx(Qd,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),Z&&p.jsx(Gn,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},Vu=()=>p.jsx("div",{className:dt.operateContainer,children:p.jsx(Uu,{})}),Qn={sheetBar:"univer-sheet-bar",sheetBarOptions:"univer-sheet-bar-options",sheetBarOptionsDivider:"univer-sheet-bar-options-divider"},ku={sheetBarBtn:"univer-sheet-bar-btn"};function Jn(i){const{children:t,className:e,style:n,disabled:o=!1,onClick:r,...s}=i,a=c=>{if(o){c.preventDefault();return}r&&r(c)};return p.jsx("button",{className:ku.sheetBarBtn,style:n,disabled:o,onClick:a,...s,children:t})}const ot={sheetBarMenu:"univer-sheet-bar-menu",sheetBarMenuItem:"univer-sheet-bar-menu-item",sheetBarMenuItemIcon:"univer-sheet-bar-menu-item-icon",sheetBarMenuItemHide:"univer-sheet-bar-menu-item-hide",sheetBarMenuItemSelect:"univer-sheet-bar-menu-item-select",sheetBarMenuItemLabel:"univer-sheet-bar-menu-item-label"};function Bu(i){const{style:t}=i,[e,n]=H.useState([]),[o,r]=H.useState(!1),s=K.useDependency(l.IUniverInstanceService),a=K.useDependency(l.ICommandService),c=K.useDependency(Ot),d=s.getCurrentUniverSheetInstance(),u=g=>{const{sheetId:v}=g;v&&(g.hidden?a.executeCommand(f.SetWorksheetShowCommand.id,{value:v}):g.selected||a.executeCommand(f.SetWorksheetActivateCommand.id,{unitId:d.getUnitId(),subUnitId:v}),r(!1))};H.useEffect(()=>{m();const g=new l.DisposableCollection;return g.add(h()),g.add(c.registerSheetBarMenuHandler({handleSheetBarMenu:S})),()=>{g.dispose()}},[]);const h=()=>a.onCommandExecuted(g=>{switch(g.id){case f.SetWorksheetHideMutation.id:case f.RemoveSheetMutation.id:case f.SetWorksheetNameMutation.id:case f.InsertSheetMutation.id:case f.SetWorksheetOrderMutation.id:case f.SetWorksheetActiveOperation.id:m();break}}),m=()=>{const g=d.getSheets(),v=d.getActiveSheet(),M=g.map((R,b)=>({label:R.getName(),index:`${b}`,sheetId:R.getSheetId(),hidden:R.isSheetHidden()===l.BooleanNumber.TRUE,selected:v===R}));n(M)};function S(){r(!0)}const _=g=>{r(g)};return p.jsx(le.Dropdown,{placement:"topLeft",trigger:["click"],overlay:p.jsx("ul",{className:ot.sheetBarMenu,style:{...t},children:e.map(g=>p.jsxs("li",{onClick:()=>u(g),className:g.selected?`${ot.sheetBarMenuItem} ${ot.sheetBarMenuItemSelect}`:g.hidden?`${ot.sheetBarMenuItem} ${ot.sheetBarMenuItemHide}`:ot.sheetBarMenuItem,children:[p.jsx("span",{className:ot.sheetBarMenuItemIcon,children:g.selected?p.jsx(qt,{}):g.hidden?p.jsx(lu,{}):p.jsx(qt,{})}),p.jsx("span",{className:ot.sheetBarMenuItemLabel,children:g.label})]},g.index))}),visible:o,onVisibleChange:_,children:p.jsx(Jn,{children:p.jsx(nu,{})})})}const Oe={slideTabBarContainer:"univer-slide-tab-bar-container",slideTabBar:"univer-slide-tab-bar",slideTabItem:"univer-slide-tab-item",slideTabActive:"univer-slide-tab-active",slideTabSpan:"univer-slide-tab-span",slideTabSpanEdit:"univer-slide-tab-span-edit",slideTabItemDropdown:"univer-slide-tab-item-dropdown"};function Fu(i){const{sheetId:t,label:e,color:n,selected:o}=i,[r,s]=H.useState(o),a=K.useDependency(l.ThemeService);H.useEffect(()=>{s(o)},[o]);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":t,className:r?`${Oe.slideTabActive} ${Oe.slideTabItem}`:Oe.slideTabItem,style:{backgroundColor:!r&&n?n:"",color:!r&&n?c(n):"",boxShadow:r&&n?`0px 0px 8px rgba(0, 0, 0, 0.08), inset 0px -2px 0px 0px ${n}`:""},children:p.jsx("span",{className:Oe.slideTabSpan,children:e})},t)}const Wu={easeOutStrong(i,t,e,n){return-e*((i=i/n-1)*i*i*i-1)+t},backOut(i,t,e,n,o){return typeof o>"u"&&(o=.7),e*((i=i/n-1)*i*((o+1)*i+o)+1)+t}},ju={loop:!1,begin:0,end:0,duration:300,delay:0,type:"easeOutStrong",receive(i){},success(i){},cancel(i){},complete(i){}};class zu{constructor(t){I(this,"_config");I(this,"_status",0);I(this,"_start",0);I(this,"_handle",0);I(this,"_delayHandle",null);this._config={...ju,...t},this._config.loop&&(this._config.complete=()=>{},this._config.success=()=>{this.request()})}static success(...t){let e=0;return new Promise(n=>{for(let o=0;o<t.length;o++){const r=t[o],s=r._config,a=s.success;s.loop||(s.success=d=>{e++,a&&a.call(r,d),e===t.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 t=Date.now()-this._start;t=t>=this._config.duration?this._config.duration:t;const n=Wu[this._config.type](t,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(t===this._config.duration){this._config.success(n),this._config.complete(n);return}this._handle=requestAnimationFrame(()=>{this._fakeHandle()})}}class ut{constructor(t,e){I(this,"_slideTabItem");I(this,"_animate");I(this,"_midline",0);I(this,"_translateX");I(this,"_scrollbar");I(this,"_slideTabBar");I(this,"_editMode");I(this,"_placeholder");this._slideTabItem=t,this._animate=null,this._translateX=0,this._editMode=!1,this._slideTabBar=e,this._placeholder=null,this._scrollbar=e.getScrollbar(),this.update()}static midline(t){return t.getBoundingRect().x+t.getBoundingRect().width/2}static leftLine(t){return t.getBoundingRect().x}static rightLine(t){return t.getBoundingRect().x+t.getBoundingRect().width}static make(t,e){const n=[];return t.forEach(o=>n.push(new ut(o,e))),n}getSlideTabItem(){return this._slideTabItem}getEditor(){return this._slideTabItem.querySelector("span")}focus(){var t;(t=this.getEditor())==null||t.focus()}selectAll(){const t=this.getEditor();t&&xt.keepSelectAll(t)}isEditMode(){return this._editMode}classList(){return this._slideTabItem.classList}translateX(t){return this._translateX=t,this._slideTabItem.style.transform=`translateX(${t}px)`,this.getTranslateXDirection()}setEditor(t){let e=!0;if(this._editMode===!1){const n=this._slideTabItem.querySelector("span"),o=d=>{if(!this.nameCheck()){if(this._editMode=!1,n&&(n.removeAttribute("contentEditable"),n.removeEventListener("blur",o),n.removeEventListener("compositionstart",s),n.removeEventListener("compositionend",a),n.removeEventListener("input",c),n.removeEventListener("keydown",r),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)}t&&t(d)}};let r=d=>{n&&(d.stopPropagation(),d.key==="Enter"&&n.blur())};const s=d=>{e=!1},a=d=>{e=!0},c=d=>{if(!n)return;const u=50;setTimeout(()=>{if(e){const h=n.innerText;h.length>u&&(n.innerText=h.substring(0,u),xt.keepLastIndex(n))}},0)};n&&(n.setAttribute("contentEditable","true"),n.addEventListener("blur",o),n.addEventListener("compositionstart",s),n.addEventListener("compositionend",a),n.addEventListener("input",c),n.addEventListener("keydown",r),n.classList.add(this._slideTabBar.getConfig().slideTabBarSpanEditClassName),this._editMode=!0,xt.keepSelectAll(n))}}nameCheck(){const t=this._slideTabItem.querySelector("span");if(!t)return!1;const e=t.innerText;return this._slideTabBar.getConfig().onNameCheckAlert(e)}animate(){return{translateX:t=>{this._translateX!==t&&(this._animate&&(this._animate.cancel(),this._animate=null),this._animate=new zu({begin:this._translateX,end:t,receive:e=>{this._slideTabItem.style.transform=`translateX(${e}px)`}}),this._translateX=t,this._animate.request())},cancel:()=>{this._animate&&(this._animate.cancel(),this._animate=null)}}}after(t){this._slideTabItem.after(t._slideTabItem||t)}update(){this._midline=ut.midline(this)}disableFixed(){if(this._placeholder){const t=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),t.removeChild(this._placeholder),this._placeholder=null}}enableFixed(){const t=document.createElement("div"),e=this.getBoundingRect(),n=getComputedStyle(this._slideTabItem),o=this._slideTabItem.querySelector("span");if(this._placeholder=t,this._placeholder.style.width=`${e.width}px`,this._placeholder.style.height=`${e.height}px`,this._placeholder.style.flexShrink="0",this._placeholder.style.margin=n.margin,this._slideTabItem.style.background=n.background,o){const r=getComputedStyle(o).padding;this._slideTabItem.style.padding=r}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=`${e.x-this.getScrollbar().getScrollX()}px`,this._slideTabItem.style.top=`${e.y}px`,this._slideTabItem.style.width=`${e.width}px`,this._slideTabItem.style.height=`${e.height}px`,this._slideTabItem.style.position="fixed",this._slideTabItem.after(t),document.body.appendChild(this._slideTabItem)}addEventListener(t,e,n){this._slideTabItem.addEventListener(t,e,n)}removeEventListener(t,e,n){this._slideTabItem.removeEventListener(t,e,n)}getScrollbar(){return this._scrollbar}getMidLine(){return this._midline}getBoundingRect(){const t=this._slideTabItem.getBoundingClientRect();return t.x+=this._scrollbar.getScrollX(),t}getWidth(){return this.getBoundingRect().width}getTranslateXDirection(){const t=ut.midline(this);return t>this._midline?1:t<this._midline?-1:0}equals(t){return t&&t._slideTabItem===this._slideTabItem}getId(){return this._slideTabItem.dataset.id||""}}class Yu{constructor(t){I(this,"_slideTabBar");I(this,"_scrollX");const e=t.primeval();this._scrollX=e.scrollLeft,this._slideTabBar=t}scrollX(t){const e=this._slideTabBar.primeval();e.scrollLeft=t,this._scrollX=e.scrollLeft}scrollRight(){const t=this._slideTabBar.primeval();t.scrollLeft=t.scrollWidth,this._scrollX=t.scrollLeft}getScrollX(){return this._scrollX}}const At=class At{constructor(t){I(this,"_activeTabItemIndex",0);I(this,"_slideTabBar");I(this,"_slideTabItems",[]);I(this,"_config");I(this,"_downActionX",0);I(this,"_moveActionX",0);I(this,"_compareIndex",0);I(this,"_activeTabItem",null);I(this,"_moveAction");I(this,"_upAction");I(this,"_downAction");I(this,"_wheelAction");I(this,"_scrollIncremental",0);I(this,"_compareDirection",0);I(this,"_autoScrollTime",null);I(this,"_slideScrollbar");I(this,"_longPressTimer",null);I(this,"_leftBoundingLine",0);I(this,"_rightBoundingLine",0);I(this,"_leftMoveX",0);I(this,"_rightMoveX",0);var s;if(t.slideTabBarContainer==null)throw new Error("not found slide-tab-bar root element");const e=t.slideTabBarContainer.querySelector(`.${(s=t.slideTabBarClassName)!=null?s:"slide-tab-bar"}`);if(e==null)throw new Error("not found slide-tab-bar");this._slideTabBar=e,this._slideScrollbar=new Yu(this),this._config=t,this._initConfig();let n=0,o=0,r=0;this._downAction=a=>{var y,O,N,D,k,A;if((y=this._activeTabItem)!=null&&y.isEditMode())return;const c=(N=(O=a.target)==null?void 0:O.closest(`.${t.slideTabBarItemClassName}`))==null?void 0:N.getAttribute("data-id"),d=this._slideTabItems.findIndex(L=>L.getId()===c);if(c==null||d===-1)return;if(this._activeTabItemIndex!==d){(D=this._activeTabItem)==null||D.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),(A=this._activeTabItem)==null||A.addEventListener("pointerup",this._upAction);const{x:h,width:m}=this._activeTabItem.getBoundingRect(),{x:S,width:_}=this.getBoundingRect(),g=this._slideScrollbar.getScrollX();if(this._leftBoundingLine=this._downActionX-(h-g),this._rightBoundingLine=h-g+m-this._downActionX,this._leftMoveX=h-S-g,this._rightMoveX=S+_-(h+m)+g,a.button===2||this._hasEditItem())return;const{pageX:v,pageY:M}=a,R=Date.now(),b=R-r<=At.DoubleClickDelay,E=Math.abs(v-n)<10,T=Math.abs(M-o)<10;b&&E&&T&&this._activeTabItem.setEditor(),n=v,o=M,r=R,this._longPressTimer=setTimeout(()=>{var L,B;(L=this._activeTabItem)==null||L.enableFixed(),this._startAutoScroll(),u&&(u.setPointerCapture(a.pointerId),u.style.cursor="move",(B=this._activeTabItem)==null||B.addEventListener("pointermove",this._moveAction))},At.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(t){let e=t.target;for(;e!=null&&e!==document.body;){if(e.getAttribute("data-slide-skip"))return!0;e=e.parentElement}return!1}static keepLastIndex(t){setTimeout(()=>{const e=window.getSelection();e&&(e.selectAllChildren(t),e.collapseToEnd())})}static keepSelectAll(t){setTimeout(()=>{const e=window.getSelection();if(!e)return;const n=document.createRange();n.selectNodeContents(t),e.removeAllRanges(),e.addRange(n)})}update(t){this._config.currentIndex=t,this._initConfig(),this.removeListener(),this.addListener()}primeval(){return this._slideTabBar}updateItems(){for(let t=0;t<this._slideTabItems.length;t++)this._slideTabItems[t].animate().cancel(),this._slideTabItems[t].translateX(0),this._slideTabItems[t].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 t=this._slideTabBar.parentElement;return t?this._slideTabBar.scrollWidth-t.clientWidth===this._slideTabBar.scrollLeft:!1}addListener(){this._slideTabBar.addEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(t=>{t.addEventListener("pointerdown",this._downAction)})}removeListener(){this._slideTabBar.removeEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(t=>{t.removeEventListener("pointerdown",this._downAction)})}setScroll(t){if(this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t),t>0){const e=this.calculateLeftScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}else if(t<0){const e=this.calculateRightScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}flipPage(t){if(t>0){const e=this.calculateLeftScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}else if(t<0){const e=this.calculateRightScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}calculateLeftScrollX(t){let e=0;const n=4;return this._slideTabItems.some(o=>{const r=this._slideTabBar.getBoundingClientRect(),s=r.left+r.width,a=o.getSlideTabItem().getBoundingClientRect(),c=a.left,d=a.width;return c<s&&c+d+n*2>s?(e=t?c-r.left-n:c+d-s+n,!0):!1}),e}calculateRightScrollX(t){let e=0;const n=4;return this._slideTabItems.some(o=>{const r=this._slideTabBar.getBoundingClientRect(),s=r.left,a=o.getSlideTabItem().getBoundingClientRect(),c=a.left,d=a.width;return c-n*2<s&&c+d>s?(e=t?c+d-r.left-r.width+n:c-s-n,!0):!1}),e}destroy(){this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=[],this._activeTabItem=null,this.removeListener()}_hasEditItem(){for(let t=0;t<this._slideTabItems.length;t++)if(this._slideTabItems[t].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(t){const e=this.getBoundingRect(),n=t.pageX-e.x;n<this._leftBoundingLine&&(this._scrollIncremental=-Math.min(Math.abs(n-this._leftBoundingLine)*.1,50))}_scrollRight(t){const e=this.getBoundingRect(),n=t.pageX-e.x;n>e.width-this._rightBoundingLine&&(this._scrollIncremental=Math.min(Math.abs(n-(e.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 t=0;t<this._slideTabItems.length;t++){const e=this._slideTabItems[t],n=this._slideTabItems[t+1];n&&e.after(n)}}_compareLeft(){if(this._activeTabItem&&this._activeTabItemIndex){const t=this._slideTabItems.findIndex(r=>r.equals(this._activeTabItem)),e=this._slideTabItems.length,n=[];for(let r=0;r<t&&!(r>=t);r++)n.push(this._slideTabItems[r]);for(let r=t+1;r<e;r++)this._slideTabItems[r].animate().translateX(0);let o=!0;for(let r=n.length-1;r>=0;r--){const s=n[r];ut.leftLine(this._activeTabItem)<s.getMidLine()?(s.animate().translateX(this._activeTabItem.getWidth()),this._compareIndex=r,o=!1):(s.animate().translateX(0),o&&(this._compareIndex=this._activeTabItemIndex))}}}_compareRight(){if(this._activeTabItem){const t=this._slideTabItems.findIndex(r=>r.equals(this._activeTabItem)),e=this._slideTabItems.length,n=[];for(let r=t+1;r<e;r++)n.push(this._slideTabItems[r]);for(let r=0;r<t;r++)this._slideTabItems[r].animate().translateX(0);let o=!0;for(let r=0;r<n.length;r++){const s=n[r];ut.rightLine(this._activeTabItem)>s.getMidLine()?(s.animate().translateX(-this._activeTabItem.getWidth()),this._compareIndex=t+r+1,o=!1):(s.animate().translateX(0),o&&(this._compareIndex=this._activeTabItemIndex))}}}_initConfig(){var e;const t=this._slideTabBar.querySelectorAll(`.${(e=this._config.slideTabBarItemClassName)!=null?e:"slide-tab-item"}`);this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=ut.make(t,this),this._activeTabItemIndex=this._config.currentIndex,this._activeTabItem=this._slideTabItems[this._activeTabItemIndex]}};I(At,"LongPressDelay",500),I(At,"DoubleClickDelay",300);let xt=At;function Xu(){const[i,t]=H.useState([]),[e,n]=H.useState(""),[o,r]=H.useState(""),[s,a]=H.useState(!1),[c,d]=H.useState([0,0]),u=H.useRef({slideTabBar:null}),h=H.useRef(null),m=K.useDependency(l.IUniverInstanceService),S=K.useDependency(l.ICommandService),_=K.useDependency(Ot),g=K.useDependency(l.LocaleService),v=K.useDependency(C.IConfirmService),M=K.useDependency(ge),R=K.useDependency(we);K.useInjector();const b=m.getCurrentUniverSheetInstance();H.useEffect(()=>{A();const U=E(),W=k(),$=[L(),B(),j(),X()];return()=>{W.dispose(),U.destroy(),$.forEach(q=>q.unsubscribe())}},[]),H.useEffect(()=>{i.length>0&&D()},[i]);const E=()=>{const U=new xt({slideTabBarClassName:Oe.slideTabBar,slideTabBarItemActiveClassName:Oe.slideTabActive,slideTabBarItemClassName:Oe.slideTabItem,slideTabBarSpanEditClassName:Oe.slideTabSpanEdit,slideTabBarItemAutoSort:!0,slideTabBarContainer:h.current,currentIndex:0,onChangeName:(W,$)=>{S.executeCommand(f.SetWorksheetNameCommand.id,{subUnitId:W,name:$})},onSlideEnd:(W,$)=>{S.executeCommand(f.SetWorksheetOrderCommand.id,{order:$})},onChangeTab:(W,$)=>{S.executeCommand(f.SetWorksheetActiveOperation.id,{subUnitId:$,unitId:b.getUnitId()}).then(()=>{W.button===2&&ne(!0)})},onScroll:W=>{_.setScroll(W)},onNameCheckAlert:W=>T(W)||y(W)});return u.current.slideTabBar=U,ee(U),U},T=U=>{if(U.trim()===""){const W="sheetNameEmptyAlert";return v.open({id:W,title:{title:g.t("sheetConfig.sheetNameErrorTitle")},children:{title:g.t("sheetConfig.sheetNameCannotIsEmptyError")},cancelText:g.t("button.cancel"),confirmText:g.t("button.confirm"),onClose(){O(),v.close(W)},onConfirm(){O(),v.close(W)}}),!0}return!1},y=U=>{const W=m.getCurrentUniverSheetInstance();if(W.getActiveSheet().getName()===U)return!1;const re=W.checkSheetName(U);if(re){const se="sheetNameRepeatAlert";v.open({id:se,title:{title:g.t("sheetConfig.sheetNameErrorTitle")},children:{title:g.t("sheetConfig.sheetNameAlreadyExistsError")},cancelText:g.t("button.cancel"),confirmText:g.t("button.confirm"),onClose(){v.close(se),O()},onConfirm(){v.close(se),O()}})}return re},O=()=>{M.endSelection(),setTimeout(()=>{var W;const U=(W=u.current.slideTabBar)==null?void 0:W.getActiveItem();U&&(U.focus(),U.selectAll())},0)},N=()=>{var U,W;(W=(U=u.current.slideTabBar)==null?void 0:U.getActiveItem())==null||W.setEditor()},D=()=>{var W;const U=i.findIndex($=>$.selected);(W=u.current.slideTabBar)==null||W.update(U)},k=()=>S.onCommandExecuted(U=>{switch(U.id){case f.SetTabColorMutation.id:case f.SetWorksheetHideMutation.id:case f.RemoveSheetMutation.id:case f.SetWorksheetNameMutation.id:case f.InsertSheetMutation.id:case f.SetWorksheetOrderMutation.id:case f.SetWorksheetActiveOperation.id:A();break}}),A=()=>{const U=b.getActiveSheet().getSheetId();n(U);const W=b.getSheets(),$=b.getActiveSheet(),q=W.filter(re=>!re.isSheetHidden()).map((re,se)=>{var Y;return{sheetId:re.getSheetId(),label:re.getName(),index:se,selected:$===re,color:(Y=re.getTabColor())!=null?Y:void 0}});t(q)},L=()=>_.scroll$.subscribe(U=>{z(U)}),B=()=>_.scrollX$.subscribe(U=>{var W;(W=u.current.slideTabBar)==null||W.flipPage(U)}),j=()=>_.renameId$.subscribe(()=>{N()}),X=()=>_.addSheet$.subscribe(()=>{var U;(U=u.current.slideTabBar)==null||U.getScrollbar().scrollRight()}),z=U=>{const{leftEnd:W,rightEnd:$}=U;let q="";W&&$?q="":W&&!$?q="inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!W&&$?q="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!W&&!$&&(q="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2), inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)"),r(q)},Z=U=>{_.setScroll({leftEnd:U.isLeftEnd(),rightEnd:U.isRightEnd()})},ee=U=>{var q;const W=(q=h.current)==null?void 0:q.querySelector(`.${Oe.slideTabBar}`);if(!W)return;new ResizeObserver(()=>{Z(U)}).observe(W)},ne=U=>{var W,$,q,re,se;if(!R.isForceKeepVisible()){if(U){const{left:Y}=($=(W=h.current)==null?void 0:W.getBoundingClientRect())!=null?$:{},{left:Q}=(se=(re=(q=u.current.slideTabBar)==null?void 0:q.getActiveItem())==null?void 0:re.getSlideTabItem().getBoundingClientRect())!=null?se:{};Y!==void 0&&Q!==void 0&&d([Q-Y,0])}a(U)}};return p.jsx(le.Dropdown,{className:Oe.slideTabItemDropdown,visible:s,align:{offset:c},trigger:["contextMenu"],overlay:p.jsx(C.Menu,{menuType:he.SHEET_BAR,onOptionSelect:U=>{const{label:W,value:$}=U;S.executeCommand(W,{value:$,subUnitId:e}),a(!1)}}),onVisibleChange:ne,children:p.jsx("div",{className:Oe.slideTabBarContainer,ref:h,children:p.jsx("div",{className:Oe.slideTabBar,style:{boxShadow:o},children:i.map(U=>H.createElement(Fu,{...U,key:U.sheetId,selected:e===U.sheetId}))})})})}const cs=100,$u=()=>{const[i,t]=H.useState(!0),[e,n]=H.useState(!0),o=K.useDependency(l.ICommandService),r=K.useDependency(Ot);H.useEffect(()=>{const u=r.scroll$.subscribe(h=>{s(h)});return()=>{u.unsubscribe()}},[]);const s=u=>{const{leftEnd:h,rightEnd:m}=u;t(h),n(m)},a=()=>{o.executeCommand(f.InsertSheetCommand.id),setTimeout(()=>{r.setAddSheet(0)},0)},c=()=>{r.setScrollX(-cs)},d=()=>{r.setScrollX(cs)};return p.jsxs("div",{className:Qn.sheetBar,children:[p.jsxs("div",{className:Qn.sheetBarOptions,children:[p.jsx(Jn,{onClick:a,children:p.jsx(Zr,{})}),p.jsx(Bu,{})]}),p.jsx(Xu,{}),(!i||!e)&&p.jsxs("div",{className:`${Qn.sheetBarOptions} ${Qn.sheetBarOptionsDivider}`,children:[p.jsx(Jn,{disabled:i,onClick:c,children:p.jsx(Qr,{style:{transform:"rotateZ(180deg)"}})}),p.jsx(Jn,{disabled:e,onClick:d,children:p.jsx(Qr,{})})]})]})};class Zu{constructor(){I(this,"_functions",[{func:G.FUNCTION_NAMES_STATISTICAL.MAX,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===G.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===G.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}},{func:G.FUNCTION_NAMES_STATISTICAL.MIN,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===G.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===G.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}},{func:G.FUNCTION_NAMES_MATH.SUM,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===G.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===G.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}},{func:G.FUNCTION_NAMES_STATISTICAL.COUNTA,filter:t=>{var e,n;return((n=(e=t.values.find(o=>o.func===G.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1}},{func:G.FUNCTION_NAMES_STATISTICAL.COUNT,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===G.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===G.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}},{func:G.FUNCTION_NAMES_STATISTICAL.AVERAGE,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===G.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===G.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}}]);I(this,"_state$",new V.BehaviorSubject(null));I(this,"state$",this._state$.asObservable())}dispose(){this._state$.complete()}setState(t){var n;const e={values:[],pattern:null};t==null||t.values.forEach(o=>{const r=this._functions.find(s=>s.func===o.func);r&&(r.filter===void 0||r.filter(t))&&e.values.push(o)}),e.pattern=(n=t==null?void 0:t.pattern)!=null?n:null,this._state$.next(e)}getState(){return this._state$.getValue()}getFunctions(){return this._functions}addFunctions(t){this._functions.push(...t)}}const Gi=P.createIdentifier("univer.sheet-status-bar.service"),Nt={statusBar:"univer-status-bar",singleMode:"univer-single-mode",statusBarDiv:"univer-status-bar-div",statisticList:"univer-statistic-list",statisticListColumn:"univer-statistic-list-column",statisticItem:"univer-statistic-item",statisticPicker:"univer-statistic-picker",statisticPickerItem:"univer-statistic-picker-item",statisticMore:"univer-statistic-more"},Gu=[G.FUNCTION_NAMES_MATH.SUM,G.FUNCTION_NAMES_STATISTICAL.AVERAGE,G.FUNCTION_NAMES_STATISTICAL.MIN,G.FUNCTION_NAMES_STATISTICAL.MAX],Ki={[G.FUNCTION_NAMES_MATH.SUM]:"statusbar.sum",[G.FUNCTION_NAMES_STATISTICAL.AVERAGE]:"statusbar.average",[G.FUNCTION_NAMES_STATISTICAL.MIN]:"statusbar.min",[G.FUNCTION_NAMES_STATISTICAL.MAX]:"statusbar.max",[G.FUNCTION_NAMES_STATISTICAL.COUNT]:"statusbar.count",[G.FUNCTION_NAMES_STATISTICAL.COUNTA]:"statusbar.countA",[G.FUNCTION_NAMES_TEXT.CONCATENATE]:"concatenate"},Qi=i=>{const t=K.useDependency(l.LocaleService),e=K.useDependency(C.IMessageService),n=K.useDependency(C.IClipboardInterfaceService),o=Ku(i),r=async()=>{await n.writeText(i.value.toString()),e.show({type:le.MessageType.Success,content:t.t("statusbar.copied")})};return p.jsx(le.Tooltip,{title:t.t("statusbar.clickToCopy"),placement:"top",children:p.jsx("div",{className:Nt.statisticItem,onClick:r,children:p.jsx("span",{children:`${t.t((Ki==null?void 0:Ki[i.name])||i.name)}: ${o}`})},i.name)})};function Ku(i){const{pattern:t,value:e}=i;return typeof e!="number"?"Invalid input":e>=1e8?e.toExponential(2):t&&Gu.includes(i.name)?Cs.format(t,e):e.toLocaleString()}const ds=800,Qu=3,Ju=()=>{const[i,t]=H.useState(window.innerWidth<ds),[e,n]=H.useState(!0),o=K.useDependency(Gi),r=o.getFunctions().map((m,S)=>({name:m.func,value:0,show:!0,disable:!1,pattern:null})),[s,a]=H.useState(r),c=s.find(m=>m.show&&!m.disable),d=i&&c?[c]:s.filter(m=>m.show&&!m.disable);H.useEffect(()=>{const m=o.state$.subscribe(S=>{const _=S==null?void 0:S.values;if(!_||_.length===0)n(!1);else{n(!0);const g=s.map(v=>{var R;const M=_.find(b=>b.func===v.name);return M?(v.value=M.value,v.disable=!1):v.disable=!0,v.pattern=(R=S==null?void 0:S.pattern)!=null?R:null,v});a(g)}});return()=>{m.unsubscribe()}},[o]);const u=l.debounce(()=>{const m=window.innerWidth<ds;i!==m&&t(m)},100);H.useEffect(()=>(window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}),[i]);let h=null;if(d.length>Qu){const m=[];d.forEach((S,_)=>{_%2===0&&m.push(d.slice(_,_+2))}),h=p.jsxs(p.Fragment,{children:[" ",m.map((S,_)=>p.jsxs("div",{className:Nt.statisticListColumn,children:[(S==null?void 0:S[0])&&p.jsx(Qi,{...S==null?void 0:S[0]},S==null?void 0:S[0].name),(S==null?void 0:S[1])&&p.jsx(Qi,{...S==null?void 0:S[1]},S==null?void 0:S[1].name)]},`stat-col-${_}`))," "]})}else h=p.jsx(p.Fragment,{children:d.map(m=>p.jsx(Qi,{...m},m.name))});return e&&p.jsxs("div",{className:xe(Nt.statusBar,{[Nt.singleMode]:i}),children:[p.jsx("div",{className:xe(Nt.statisticList),children:h}),p.jsx("div",{className:Nt.statusBarDiv})]})};function qu(){return p.jsxs("section",{className:gr.sheetContainer,"data-range-selector":!0,children:[p.jsx($u,{}),p.jsx(Ju,{}),p.jsx(Nu,{})]})}function eh(){return p.jsx(Lu,{})}function th(){return p.jsxs(p.Fragment,{children:[p.jsx(Au,{}),p.jsx(Vu,{})]})}const Ji={width:"100%"},us=i=>{const{inputId:t,state:e=!1,type:n="range",confirm:o,cancel:r,name:s,formulaOrRefString:a,comment:c="",localSheetId:d=Zi,hidden:u=!1,id:h}=i,S=K.useDependency(l.IUniverInstanceService).getCurrentUniverSheetInstance(),_=K.useDependency(l.LocaleService),g=K.useDependency(G.IDefinedNamesService),v=K.useDependency(G.IFunctionService),M=K.useDependency(G.LexerTreeBuilder);if(S==null)return;const R=S.getUnitId();S.getActiveSheet().getSheetId();const[b,E]=H.useState(s),[T,y]=H.useState(a),[O,N]=H.useState(c),[D,k]=H.useState(d),[A,L]=H.useState(""),[B,j]=H.useState(n),[X,z]=H.useState(!0),[Z,ee]=H.useState(a),ne=[{label:_.t("definedName.scopeWorkbook"),value:Zi}];H.useEffect(()=>{z(!0),E(s),N(c),k(d);let Y=a;a.substring(0,1)===G.operatorToken.EQUALS?j("formula"):U(a)?(j("formula"),Y=G.operatorToken.EQUALS+a):j("range"),y(Y),ee(Y),L("")},[e]);const U=Y=>!Y.split(",").every(Q=>G.isReferenceString(Q.trim()));S.getSheetOrders().forEach(Y=>{const Q=S.getSheetBySheetId(Y);ne.push({label:(Q==null?void 0:Q.getName())||"",value:Y})});const W=Y=>Y.map(J=>{var ae;return G.serializeRangeToRefString({...J,sheetName:((ae=S.getSheetBySheetId(J.sheetId))==null?void 0:ae.getName())||""})}).join(","),$=Y=>{ee(W(Y))},q=Y=>{ee(Y||"")},re=()=>{if(b.length===0){L(_.t("definedName.nameEmpty"));return}if(g.getValueByName(R,b)!=null&&(h==null||h.length===0)){L(_.t("definedName.nameDuplicate"));return}if(!l.Tools.isValidParameter(b)||!l.Tools.isStartValidPosition(b)&&!w.hasCJKText(b.substring(0,1))){L(_.t("definedName.nameInvalid"));return}if(S.getSheetOrders().map(Q=>{var J;return((J=S.getSheetBySheetId(Q))==null?void 0:J.getName())||""}).includes(b)){L(_.t("definedName.nameSheetConflict"));return}if(Z.length===0){L(_.t("definedName.formulaOrRefStringEmpty"));return}if(!X){L(_.t("definedName.formulaOrRefStringInvalid"));return}if(v.hasExecutor(b.toUpperCase())){L(_.t("definedName.nameConflict"));return}o&&o({id:h||"",name:b,formulaOrRefString:M.convertRefersToAbsolute(Z,l.AbsoluteRefType.ALL,l.AbsoluteRefType.ALL),comment:O,localSheetId:D})},se=Y=>{const Q=Y;Q==="formula"&&T.substring(0,1)!==G.operatorToken.EQUALS?(ee(`${G.operatorToken.EQUALS}`),y(`${G.operatorToken.EQUALS}`)):T.substring(0,1)===G.operatorToken.EQUALS&&(ee(""),y("")),j(Q)};return p.jsxs("div",{className:ue.definedNameInput,style:{display:e?"block":"none"},children:[p.jsx("div",{children:p.jsx(le.Input,{placeholder:_.t("definedName.inputNamePlaceholder"),value:b,allowClear:!0,onChange:E,affixWrapperStyle:Ji})}),p.jsx("div",{children:p.jsxs(le.RadioGroup,{value:B,onChange:se,children:[p.jsx(le.Radio,{value:"range",children:_.t("definedName.ratioRange")}),p.jsx(le.Radio,{value:"formula",children:_.t("definedName.ratioFormula")})]})}),p.jsx("div",{style:{display:B==="range"?"block":"none"},children:p.jsx(C.RangeSelector,{value:T,onValid:z,onChange:$,placeholder:_.t("definedName.inputRangePlaceholder"),id:`${t}-rangeSelector`,width:"99%",openForSheetUnitId:R},`${t}-rangeSelector`)}),p.jsx("div",{style:{display:B==="range"?"none":"block"},children:p.jsx(C.TextEditor,{value:T,onValid:z,onChange:q,id:`${t}-editor`,placeholder:_.t("definedName.inputFormulaPlaceholder"),openForSheetUnitId:R,onlyInputFormula:!0,style:{width:"99%"},canvasStyle:{fontSize:10}},`${t}-editor`)}),p.jsx("div",{children:p.jsx(le.Select,{style:Ji,value:D,options:ne,onChange:k})}),p.jsx("div",{children:p.jsx(le.Input,{affixWrapperStyle:Ji,placeholder:_.t("definedName.inputCommentPlaceholder"),value:O,onChange:N})}),p.jsxs("div",{style:{display:A.length===0?"none":"flex"},className:ue.definedNameInputValidation,children:[p.jsx("span",{children:A}),p.jsx(zr,{})]}),p.jsxs("div",{children:[p.jsx(le.Button,{onClick:()=>{r&&r()},children:_.t("definedName.cancel")}),p.jsx(le.Button,{style:{marginLeft:15},type:"primary",onClick:re,children:_.t("definedName.confirm")})]})]})},nh=()=>{const i=K.useDependency(l.ICommandService),e=K.useDependency(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=K.useDependency(l.LocaleService),o=K.useDependency(G.IDefinedNamesService),r=K.useDependency(f.SelectionManagerService);if(e==null)return;const s=e.getUnitId(),a=()=>{const A=o.getDefinedNameMap(s);return A?Array.from(Object.values(A)):[]},[c,d]=H.useState(!1),[u,h]=H.useState(a()),[m,S]=H.useState(null),[_,g]=H.useState();H.useEffect(()=>{const A=o.update$.subscribe(()=>{h(a())});return()=>{A.unsubscribe()}},[]);const v=A=>{const{name:L,formulaOrRefString:B,comment:j,localSheetId:X,hidden:z}=A;let Z=A.id;if(Z==null||Z.length===0)Z=l.Tools.generateRandomId(10),i.executeCommand(f.InsertDefinedNameCommand.id,{id:Z,unitId:s,name:L,formulaOrRefString:B,comment:j,localSheetId:X,hidden:z});else{const ee=o.getValueById(s,Z),ne={id:Z,unitId:s,name:L,formulaOrRefString:B,comment:j,localSheetId:X,hidden:z};i.executeCommand(f.SetDefinedNameCommand.id,{unitId:s,oldDefinedName:ee,newDefinedName:ne})}d(!1),S(null)},M=A=>{g(A)};function R(){g(null)}function b(A){const L=o.getValueById(s,A);i.executeCommand(f.RemoveDefinedNameCommand.id,{...L,unitId:s}),g(null)}const E=A=>{o.focusRange(s,A.id)},T=()=>{const A=u.length+1,L=n.t("definedName.defaultName")+A;if(o.getValueByName(s,L)==null)return L;let B=A+1;for(;;){const j=n.t("definedName.defaultName")+B;if(o.getValueByName(s,j)==null)return j;B++}},y=()=>{const A=e.getActiveSheet().getName(),L=r.getSelections();return L==null?"":L.map(j=>G.serializeRangeWithSheet(A,j.range)).join(",")},O=()=>{d(!1),S(null)},N=()=>{d(!0),S(null)},D=A=>{d(!1),S(A)},k=A=>{const L=e.getSheetBySheetId(A);return L==null?"":L.getName()};return p.jsx("div",{className:ue.definedNameContainer,children:p.jsxs("div",{className:ue.definedNameContainerScroll,children:[p.jsxs("div",{children:[p.jsxs("div",{onClick:N,className:ue.definedNameContainerAddButton,style:{display:c?"none":"flex"},children:[p.jsx(Zr,{}),p.jsx("span",{className:ue.definedNameContainerAddButtonText,children:n.t("definedName.addButton")})]}),p.jsx(us,{confirm:v,cancel:O,state:c,inputId:"insertDefinedName",name:T(),formulaOrRefString:y()})]},"insertDefinedName"),u.map((A,L)=>p.jsxs("div",{children:[p.jsxs("div",{onClick:()=>{E(A)},className:ue.definedNameContainerItem,style:{display:A.id===m?"none":"flex"},children:[p.jsxs("div",{title:A.comment,children:[p.jsxs("div",{className:ue.definedNameContainerItemName,children:[A.name,p.jsx("span",{className:ue.definedNameContainerItemNameForSheet,children:A.localSheetId===Zi||A.localSheetId==null?"":k(A.localSheetId)})]}),p.jsx("div",{className:ue.definedNameContainerItemFormulaOrRefString,children:A.formulaOrRefString})]}),p.jsx(le.Tooltip,{title:n.t("definedName.updateButton"),placement:"top",style:{pointerEvents:"none"},children:p.jsx("div",{className:xe(ue.definedNameContainerItemUpdate,ue.definedNameContainerItemShow),onClick:()=>{D(A.id)},children:p.jsx(qt,{})})}),p.jsx(le.Tooltip,{title:n.t("definedName.deleteButton"),placement:"top",style:{pointerEvents:"none"},children:p.jsx("div",{className:xe(ue.definedNameContainerItemDelete,ue.definedNameContainerItemShow),onClick:()=>{M(A.id)},children:p.jsx(ou,{})})})]}),p.jsx(le.Confirm,{visible:_===A.id,onClose:R,onConfirm:()=>{b(A.id)},children:n.t("definedName.deleteConfirmText")}),p.jsx(us,{confirm:v,cancel:O,state:A.id===m,id:A.id,inputId:A.id+L,name:A.name,formulaOrRefString:A.formulaOrRefString,comment:A.comment,localSheetId:A.localSheetId})]},L))]})})};function ih(i){const t=i.get(f.BorderStyleManagerService),e=f.getCurrentSheetDisabled$(i);return{id:f.SetBorderBasicCommand.id,icon:new V.Observable(n=>{const o="AllBorderSingle",r=i.get(f.BorderStyleManagerService),s=i.get(l.ICommandService).onCommandExecuted(a=>{var m;if(a.id!==f.SetBorderBasicCommand.id)return;const{type:d}=r.getBorderInfo(),u=os.find(S=>S.value===d),h=(m=u==null?void 0:u.icon)!=null?m:o;n.next(h)});return n.next(o),s.dispose}),group:C.MenuGroup.TOOLBAR_FORMAT,tooltip:"toolbar.border.main",positions:[C.MenuPosition.TOOLBAR_START],type:C.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:is,hoverable:!1},value$:t.borderInfo$}],value$:t.borderInfo$,hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:e}}const qn="sheet.menu.clear-selection";function oh(){return{id:qn,group:C.MenuGroup.CONTEXT_MENU_FORMAT,type:C.MenuItemType.SUBITEMS,icon:"ClearFormat",title:"rightClick.clearSelection",positions:[C.MenuPosition.CONTEXT_MENU,he.COL_HEADER_CONTEXT_MENU,he.ROW_HEADER_CONTEXT_MENU]}}function rh(){return{id:f.ClearSelectionContentCommand.id,type:C.MenuItemType.BUTTON,title:"rightClick.clearContent",positions:[qn]}}function sh(){return{id:f.ClearSelectionFormatCommand.id,type:C.MenuItemType.BUTTON,title:"rightClick.clearFormat",positions:[qn]}}function ah(){return{id:f.ClearSelectionAllCommand.id,type:C.MenuItemType.BUTTON,title:"rightClick.clearAll",positions:[qn]}}const en="sheet.menu.delete";function lh(){return{id:en,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.delete",icon:"Reduce",positions:[C.MenuPosition.CONTEXT_MENU]}}function ch(){return{id:Nr.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,icon:"DeleteColumn",positions:[en,he.COL_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedColumn"}}function dh(){return{id:xr.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,icon:"DeleteRow",positions:[en,he.ROW_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedRow"}}function uh(){return{id:zi.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,title:"rightClick.moveLeft",icon:"DeleteCellShiftLeft",positions:[en]}}function hh(){return{id:Yi.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,title:"rightClick.moveUp",icon:"DeleteCellShiftUp",positions:[en]}}const qi="sheet.menu.col-insert";function mh(){return{id:qi,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[he.COL_HEADER_CONTEXT_MENU]}}const eo="sheet.menu.row-insert";function Sh(){return{id:eo,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[he.ROW_HEADER_CONTEXT_MENU]}}const tn="sheet.menu.cell-insert";function _h(){return{id:tn,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[C.MenuPosition.CONTEXT_MENU]}}function fh(i){const t=i.get(f.SelectionManagerService);return{id:f.InsertRowBeforeCommand.id,type:C.MenuItemType.BUTTON,title:"rightClick.insertRowBefore",icon:"InsertRowAbove",positions:[eo,tn],hidden$:new V.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function gh(i){const t=i.get(f.SelectionManagerService);return{id:f.InsertRowAfterCommand.id,type:C.MenuItemType.BUTTON,positions:[eo],title:"rightClick.insertRow",icon:"InsertRowBelow",hidden$:new V.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function ph(i){const t=i.get(f.SelectionManagerService);return{id:f.InsertColBeforeCommand.id,type:C.MenuItemType.BUTTON,positions:[qi,tn],title:"rightClick.insertColumnBefore",icon:"LeftInsertColumn",hidden$:new V.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function vh(i){const t=i.get(f.SelectionManagerService);return{id:f.InsertColAfterCommand.id,type:C.MenuItemType.BUTTON,positions:[qi],title:"rightClick.insertColumn",icon:"RightInsertColumn",hidden$:new V.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function Ch(){return{id:$i.id,type:C.MenuItemType.BUTTON,title:"rightClick.moveRight",icon:"InsertCellShiftRight",positions:[tn]}}function Ih(){return{id:Xi.id,type:C.MenuItemType.BUTTON,title:"rightClick.moveDown",icon:"InsertCellDown",positions:[tn]}}function Mh(i){return i.get(f.SelectionManagerService).selectionMoveEnd$.pipe(V.filter(e=>e!=null&&e.length>=2),V.map(e=>{if(!e)return!1;for(let n=0;n<e.length;n++)for(let o=n+1;o<e.length;o++)if(l.Rectangle.intersects(e[n].range,e[o].range))return!0;return!1}))}function Rh(i){const t=f.getCurrentSheetDisabled$(i),e=Mh(i);return{id:Ge.id,icon:"MergeAllSingle",tooltip:"toolbar.mergeCell.main",positions:[C.MenuPosition.TOOLBAR_START],group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SUBITEMS,hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:t.pipe(V.combineLatestWith(e),V.map(([n,o])=>n||o))}}function bh(i){return{id:Tr.id,type:C.MenuItemType.BUTTON,title:"merge.all",icon:"MergeAllSingle",positions:[Ge.id]}}function wh(i){return{id:Er.id,type:C.MenuItemType.BUTTON,title:"merge.vertical",icon:"VerticalIntegrationSingle",positions:[Ge.id]}}function Th(i){return{id:yr.id,type:C.MenuItemType.BUTTON,title:"merge.horizontal",icon:"HorizontalMergeSingle",positions:[Ge.id]}}function Eh(i){return{id:f.RemoveWorksheetMergeCommand.id,type:C.MenuItemType.BUTTON,title:"merge.cancel",icon:"CancelMergeSingle",positions:[Ge.id]}}function yh(i){const t=i.get(l.IUniverInstanceService),e=i.get(l.ICommandService);return{id:Ar.id,type:C.MenuItemType.BUTTON,positions:[he.SHEET_BAR],title:"sheetConfig.delete",disabled$:new V.Observable(n=>{const o=e.onCommandExecuted(r=>{const s=r.id;if(s===f.RemoveSheetMutation.id||s===f.InsertSheetMutation.id||s===f.SetWorksheetHideMutation.id){const a=t.getCurrentUniverSheetInstance().getWorksheets(),c=Array.from(a.values()).filter(d=>d.getConfig().hidden===l.BooleanNumber.FALSE);n.next(c.length===1)}});return n.next(!1),o.dispose})}}function Oh(){return{id:f.CopySheetCommand.id,type:C.MenuItemType.BUTTON,positions:[he.SHEET_BAR],title:"sheetConfig.copy"}}function xh(){return{id:Pr.id,type:C.MenuItemType.BUTTON,positions:[he.SHEET_BAR],title:"sheetConfig.rename"}}function Nh(){return{id:f.SetTabColorCommand.id,title:"sheetConfig.changeColor",positions:[he.SHEET_BAR],type:C.MenuItemType.SELECTOR,selections:[{label:{name:Rn,hoverable:!1}}]}}function Ah(i){const t=i.get(l.IUniverInstanceService),e=i.get(l.ICommandService);return{id:f.SetWorksheetHideCommand.id,type:C.MenuItemType.BUTTON,positions:[he.SHEET_BAR],title:"sheetConfig.hide",disabled$:new V.Observable(n=>{const o=e.onCommandExecuted(r=>{const s=r.id;if(s===f.RemoveSheetMutation.id||s===f.InsertSheetMutation.id||s===f.SetWorksheetHideMutation.id){const a=t.getCurrentUniverSheetInstance().getWorksheets(),c=Array.from(a.values()).filter(d=>d.getConfig().hidden===l.BooleanNumber.FALSE);n.next(c.length===1)}});return n.next(!1),o.dispose})}}function Dh(i){const t=i.get(l.IUniverInstanceService),e=i.get(l.ICommandService);return{id:Dr.id,type:C.MenuItemType.BUTTON,positions:[he.SHEET_BAR],title:"sheetConfig.unhide",disabled$:new V.Observable(n=>{const o=e.onCommandExecuted(r=>{const s=r.id;if(s===f.RemoveSheetMutation.id||s===f.InsertSheetMutation.id||s===f.SetWorksheetHideMutation.id){const a=t.getCurrentUniverSheetInstance().getWorksheets(),c=Array.from(a.values());n.next(c.length===1)}});return n.next(!1),o.dispose})}}const Ph={id:f.SetRowHiddenCommand.id,preconditions:i=>ie(i),binding:C.KeyCode.Digit9|C.MetaKeys.CTRL_COMMAND},Lh={id:f.SetColHiddenCommand.id,preconditions:i=>ie(i),binding:C.KeyCode.Digit0|C.MetaKeys.CTRL_COMMAND|C.MetaKeys.SHIFT},Hh={id:be.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_DOWN,priority:100,preconditions:ie,staticParameters:{direction:l.Direction.DOWN}},Uh={id:be.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_UP,priority:100,preconditions:ie,staticParameters:{direction:l.Direction.UP}},Vh={id:be.id,description:"shortcut.sheet.select-left-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_LEFT,priority:100,preconditions:ie,staticParameters:{direction:l.Direction.LEFT}},kh={id:be.id,description:"shortcut.sheet.select-right-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_RIGHT,priority:100,preconditions:ie,staticParameters:{direction:l.Direction.RIGHT}},Bh={id:lt.id,description:"shortcut.sheet.select-next-cell",group:"3_sheet-view",binding:C.KeyCode.TAB,priority:100,preconditions:ie,staticParameters:{direction:l.Direction.RIGHT,keycode:C.KeyCode.TAB}},Fh={id:lt.id,description:"shortcut.sheet.select-previous-cell",group:"3_sheet-view",binding:C.KeyCode.TAB|C.MetaKeys.SHIFT,priority:100,preconditions:ie,staticParameters:{direction:l.Direction.LEFT,keycode:C.KeyCode.TAB}},Wh={id:lt.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:C.KeyCode.ENTER,priority:100,preconditions:ie,staticParameters:{direction:l.Direction.DOWN,keycode:C.KeyCode.ENTER}},jh={id:lt.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:C.KeyCode.ENTER|C.MetaKeys.SHIFT,priority:100,preconditions:ie,staticParameters:{direction:l.Direction.UP,keycode:C.KeyCode.ENTER}},zh={id:be.id,description:"shortcut.sheet.select-below-value-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_DOWN|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:l.Direction.DOWN,jumpOver:ke.moveGap}},Yh={id:be.id,description:"shortcut.sheet.select-up-value-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_UP|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:l.Direction.UP,jumpOver:ke.moveGap}},Xh={id:be.id,description:"shortcut.sheet.select-left-value-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_LEFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:l.Direction.LEFT,jumpOver:ke.moveGap}},$h={id:be.id,description:"shortcut.sheet.select-right-value-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_RIGHT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:l.Direction.RIGHT,jumpOver:ke.moveGap}},Zh={id:Ae.id,description:"shortcut.sheet.expand-selection-down",group:"3_sheet-view",binding:C.KeyCode.ARROW_DOWN|C.MetaKeys.SHIFT,preconditions:ie,staticParameters:{direction:l.Direction.DOWN}},Gh={id:Ae.id,description:"shortcut.sheet.expand-selection-up",group:"3_sheet-view",binding:C.KeyCode.ARROW_UP|C.MetaKeys.SHIFT,preconditions:ie,staticParameters:{direction:l.Direction.UP}},Kh={id:Ae.id,description:"shortcut.sheet.expand-selection-left",group:"3_sheet-view",binding:C.KeyCode.ARROW_LEFT|C.MetaKeys.SHIFT,preconditions:ie,staticParameters:{direction:l.Direction.LEFT}},Qh={id:Ae.id,description:"shortcut.sheet.expand-selection-right",group:"3_sheet-view",binding:C.KeyCode.ARROW_RIGHT|C.MetaKeys.SHIFT,preconditions:ie,staticParameters:{direction:l.Direction.RIGHT}},Jh={id:Ae.id,description:"shortcut.sheet.expand-selection-to-below-gap",group:"3_sheet-view",binding:C.KeyCode.ARROW_DOWN|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:l.Direction.DOWN,jumpOver:ke.moveGap}},qh={id:Ae.id,description:"shortcut.sheet.expand-selection-to-up-gap",group:"3_sheet-view",binding:C.KeyCode.ARROW_UP|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:l.Direction.UP,jumpOver:ke.moveGap}},em={id:Ae.id,description:"shortcut.sheet.expand-selection-to-left-gap",group:"3_sheet-view",binding:C.KeyCode.ARROW_LEFT|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:l.Direction.LEFT,jumpOver:ke.moveGap}},tm={id:Ae.id,description:"shortcut.sheet.expand-selection-to-right-gap",group:"3_sheet-view",binding:C.KeyCode.ARROW_RIGHT|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:l.Direction.RIGHT,jumpOver:ke.moveGap}},nm={id:Wo.id,description:"shortcut.sheet.select-all",group:"3_sheet-view",binding:C.KeyCode.A|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{expandToGapFirst:!0,loop:!0}},im={id:bi.id,description:"shortcut.sheet.set-bold",group:"4_sheet-edit",preconditions:i=>ie(i),binding:C.KeyCode.B|C.MetaKeys.CTRL_COMMAND},om={id:wi.id,description:"shortcut.sheet.set-italic",group:"4_sheet-edit",preconditions:i=>ie(i),binding:C.KeyCode.I|C.MetaKeys.CTRL_COMMAND},rm={id:Ti.id,description:"shortcut.sheet.set-underline",group:"4_sheet-edit",preconditions:i=>ie(i),binding:C.KeyCode.U|C.MetaKeys.CTRL_COMMAND},sm={id:Ei.id,description:"shortcut.sheet.set-strike-through",group:"4_sheet-edit",preconditions:i=>ie(i),binding:C.KeyCode.X|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND},am={id:f.ClearSelectionContentCommand.id,preconditions:i=>ie(i),binding:C.KeyCode.DELETE,mac:C.KeyCode.BACKSPACE},lm={id:Pn.id,description:"shortcut.sheet.zoom-in",binding:C.KeyCode.EQUAL|C.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",preconditions:ie,priority:1,staticParameters:{delta:.2}},cm={id:l.NilCommand.id,binding:C.KeyCode.EQUAL|C.MetaKeys.CTRL_COMMAND},dm={id:Pn.id,description:"shortcut.sheet.zoom-out",binding:C.KeyCode.MINUS|C.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",preconditions:ie,priority:1,staticParameters:{delta:-.2}},um={id:l.NilCommand.id,binding:C.KeyCode.MINUS|C.MetaKeys.CTRL_COMMAND},hm={id:Pn.id,description:"shortcut.sheet.reset-zoom",binding:C.KeyCode.Digit0|C.MetaKeys.CTRL_COMMAND,preconditions:ie,group:"3_sheet-view",priority:1,staticParameters:{reset:!0}},mm={id:l.NilCommand.id,binding:C.KeyCode.Digit0|C.MetaKeys.CTRL_COMMAND};var Sm=Object.defineProperty,_m=Object.getOwnPropertyDescriptor,fm=(i,t,e,n)=>{for(var o=n>1?void 0:n?_m(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Sm(t,e,o),o},ht=(i,t)=>(e,n)=>t(e,n,i);let ei=class extends l.Disposable{constructor(i,t,e,n,o,r,s){super(),this._injector=i,this._componentManager=t,this._layoutService=e,this._commandService=n,this._shortcutService=o,this._menuService=r,this._uiController=s,this._init()}_init(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts(),this._initWorkbenchParts(),this._initFocusHandler()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Ai,Tl)),this.disposeWithMe(i.register(is,Eu)),this.disposeWithMe(i.register(Rn,le.ColorPicker)),this.disposeWithMe(i.register(ir,C.FontFamily)),this.disposeWithMe(i.register(or,C.FontFamilyItem)),this.disposeWithMe(i.register(rr,C.FontSize)),this.disposeWithMe(i.register(as,nh))}_initCommands(){[Tr,Ge,yr,Er,Pn,Ae,be,lt,Pr,Ar,xr,Nr,Yo,Xo,ct,jo,Wo,Cr,f.SetBoldCommand,Bt,De,bi,wi,Ti,Ei,dl,ul,$o,Zo,In,f.SetItalicCommand,f.SetStrikeThroughCommand,f.SetFontFamilyCommand,f.SetFontSizeCommand,xi,Jo,Ni,qo,nt,Ft,Mn,er,tr,nr,f.SetUnderlineCommand,Ln,Pe,Dr,Or,Xi,Yi,$i,zi,ls].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initMenus(){[Wl,jl,zl,Yl,Xl,$l,Zl,rh,sh,ah,oh,mh,Sh,_h,fh,gh,ph,vh,dh,nc,oc,ic,rc,ch,sc,Gl,ac,lh,uh,hh,Ch,Ih,Jl,ql,ec,tc,Kl,Ql,El,yl,Ol,xl,Nl,Al,Dl,Pl,Ll,Hl,Ul,ih,Rh,bh,wh,Th,Eh,Vl,kl,Bl,Fl,yh,Oh,xh,Nh,Ah,Dh].forEach(i=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i)))})}_initShortcuts(){[Hh,Uh,Vh,kh,Bh,Fh,Wh,jh,zh,Yh,Xh,$h,Zh,Gh,Kh,Qh,Jh,qh,em,tm,nm,lm,dm,hm,mm,cm,um,im,om,rm,sm,am,...Tc(),Ec,yc,xc,Nc,Ac,Oc,Ph,Lh].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_initWorkbenchParts(){const i=this._uiController,t=this._injector;this.disposeWithMe(i.registerComponent(C.DesktopUIPart.HEADER,()=>K.connectInjector(eh,t))),this.disposeWithMe(i.registerComponent(C.DesktopUIPart.FOOTER,()=>K.connectInjector(qu,t))),this.disposeWithMe(i.registerComponent(C.DesktopUIPart.CONTENT,()=>K.connectInjector(th,t)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(l.UniverInstanceType.SHEET,i=>{this._injector.get(w.ITextSelectionRenderManager).focus()}))}};ei=fm([l.OnLifecycle(l.LifecycleStages.Ready,ei),ht(0,P.Inject(P.Injector)),ht(1,P.Inject(C.ComponentManager)),ht(2,C.ILayoutService),ht(3,l.ICommandService),ht(4,C.IShortcutService),ht(5,C.IMenuService),ht(6,C.IUIController)],ei);var gm=Object.defineProperty,pm=Object.getOwnPropertyDescriptor,vm=(i,t,e,n)=>{for(var o=n>1?void 0:n?pm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&gm(t,e,o),o},mt=(i,t)=>(e,n)=>t(e,n,i);let ti=class extends l.Disposable{constructor(t,e,n,o,r,s,a){super();I(this,"_calculateTimeout",-1);this._univerInstanceService=t,this._selectionManagerService=e,this._functionService=n,this._statusBarService=o,this._commandService=r,this._formulaDataModel=s,this._numfmtService=a,this._init()}_init(){this._registerSelectionListener()}_registerSelectionListener(){const t=l.debounce(e=>{var o;const n=(o=e[e.length-1])==null?void 0:o.primary;this._calculateSelection(e.map(r=>r.range),n)},100);this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoving$.subscribe(e=>{var n;((n=this._selectionManagerService.getCurrent())==null?void 0:n.pluginName)===f.NORMAL_SELECTION_PLUGIN_NAME&&e&&t(e)}))),this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(e=>{var n;((n=this._selectionManagerService.getCurrent())==null?void 0:n.pluginName)===f.NORMAL_SELECTION_PLUGIN_NAME&&e&&t(e)}))),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===f.SetRangeValuesMutation.id){const n=this._selectionManagerService.getSelections();n&&t(n)}}))}_calculateSelection(t,e){var c;const n=this._univerInstanceService.getCurrentUniverSheetInstance(),o=n.getUnitId(),r=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,rowData:u.rowData,columnData:u.columnData}}),t!=null&&t.length){const d=t.map(v=>new G.RangeReferenceObject(v,r,o));d.forEach(v=>{v.setUnitData({[o]:s}),a&&v.setArrayFormulaCellData(G.convertUnitDataToRuntime(a))});const u=this._statusBarService.getFunctions(),h=d.map(v=>v.toArrayValueObject(!1)),m=u.map(v=>{const M=this._functionService.getExecutor(v.func);if(!M)return;const R=M==null?void 0:M.calculate(...h),b=R==null?void 0:R.getValue();if(b)return{func:v.func,value:b}});if(m.every(v=>v===void 0))return;let S=null;if(e){const{actualRow:v,actualColumn:M}=e;S=(c=this._numfmtService.getValue(o,r,v,M))==null?void 0:c.pattern}const g={values:m.filter(v=>v!==void 0),pattern:S};this._statusBarService.setState(g)}else this._statusBarService.setState(null)}_isSingleCell(t){return t.startRow===t.endRow&&t.startColumn===t.endColumn}};ti=vm([l.OnLifecycle(l.LifecycleStages.Ready,ti),mt(0,l.IUniverInstanceService),mt(1,P.Inject(f.SelectionManagerService)),mt(2,G.IFunctionService),mt(3,Gi),mt(4,l.ICommandService),mt(5,P.Inject(G.FormulaDataModel)),mt(6,P.Inject(f.INumfmtService))],ti);var Cm=Object.defineProperty,Im=Object.getOwnPropertyDescriptor,Mm=(i,t,e,n)=>{for(var o=n>1?void 0:n?Im(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Cm(t,e,o),o},St=(i,t)=>(e,n)=>t(e,n,i);let ni=class extends l.Disposable{constructor(i,t,e,n,o,r,s){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=t,this._commandService=e,this._renderManagerService=n,this._selectionRenderService=o,this._selectionManagerService=r,this._scrollManagerService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._zoomEventBinding()}_zoomEventBinding(){var t;const i=(t=this._getSheetObject())==null?void 0:t.scene;i!=null&&(i.getViewport(F.VIEW_MAIN),this.disposeWithMe(l.toDisposable(i.onMouseWheelObserver.add((e,n)=>{if(!e.ctrlKey)return;const o=Math.abs(e.deltaX);let r=o<40?.2:o<80?.4:.2;r*=e.deltaY>0?-1:1,i.scaleX<1&&(r/=2);const s=this._currentUniverService.getCurrentUniverSheetInstance(),a=s.getActiveSheet(),c=a.getZoomRatio();let d=+Number.parseFloat(`${c+r}`).toFixed(1);d=d>=4?4:d<=.1?.1:d,this._commandService.executeCommand(Ln.id,{zoomRatio:Math.round(d*10)/10,unitId:s.getUnitId(),subUnitId:a.getSheetId()}),e.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=[Pe.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(i.includes(t.id)){const e=this._currentUniverService.getCurrentUniverSheetInstance(),n=e.getActiveSheet(),o=t.params,{unitId:r,subUnitId:s}=o;if(!(r===e.getUnitId()&&s===n.getSheetId()))return;const a=n.getConfig().zoomRatio||1;this._updateViewZoom(a)}}))}_updateViewZoom(i){const t=this._getSheetObject();t==null||t.scene.scale(i,i),t==null||t.spreadsheet.makeForceDirty()}_getSheetObject(){return Ie(this._currentUniverService,this._renderManagerService)}};ni=Mm([l.OnLifecycle(l.LifecycleStages.Rendered,ni),St(0,P.Inject(x.SheetSkeletonManagerService)),St(1,l.IUniverInstanceService),St(2,l.ICommandService),St(3,w.IRenderManagerService),St(4,ge),St(5,P.Inject(f.SelectionManagerService)),St(6,P.Inject(Xe))],ni);var Rm=Object.defineProperty,bm=Object.getOwnPropertyDescriptor,wm=(i,t,e,n)=>{for(var o=n>1?void 0:n?bm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Rm(t,e,o),o},nn=(i,t)=>(e,n)=>t(e,n,i);x.SheetCanvasView=class extends l.RxDisposable{constructor(e,n,o,r,s){super();I(this,"_scene");I(this,"_currentWorkbook");I(this,"_fps$",new V.BehaviorSubject(""));I(this,"fps$",this._fps$.asObservable());this._currentUniverService=e,this._commandService=n,this._renderManagerService=o,this._selectionRenderService=r,this._sheetSkeletonManagerService=s,this._initialize()}_initialize(){this._init()}dispose(){this._fps$.complete()}_init(){this._currentUniverService.currentSheet$.subscribe(e=>{this._create(e)}),this._currentUniverService.getAllUniverSheetsInstance().forEach(e=>{this._create(e)})}_create(e){if(e==null)return;const n=e.getUnitId();this._renderManagerService.has(n)||(this._currentWorkbook=e,this._addNewRender())}_addNewRender(){const e=this._currentWorkbook,n=e.getUnitId(),o=e.getContainer(),r=e.getParentRenderUnitId();if(o!=null&&r!=null)throw new Error("container or parentRenderUnitId can only exist one");const s=o==null&&r!=null;s?this._renderManagerService.createRenderWithParent(n,r):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 w.Layer(c,[],0),new w.Layer(c,[],2)),a!=null&&this._addComponent(a),e.getShouldRenderLoopImmediately()&&!s&&d.runRenderLoop(()=>{c.render(),this._fps$.next(Math.round(d.getFps()).toString())}),this._renderManagerService.setCurrent(n)}_addComponent(e){const n=this._scene,o=this._currentWorkbook,r=o.getActiveSheet(),s=o.getUnitId(),a=r.getSheetId();this._addViewport(r);const c=new w.Spreadsheet(fe.MAIN),d=new w.SpreadsheetRowHeader(fe.ROW),u=new w.SpreadsheetColumnHeader(fe.COLUMN),h=new w.Rect(fe.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});e.mainComponent=c,e.components.set(fe.MAIN,c),e.components.set(fe.ROW,d),e.components.set(fe.COLUMN,u),e.components.set(fe.LEFT_TOP,h),n.addObjects([c],Co),n.addObjects([d,u,h],et),n.enableLayerCache(Co,et),this._sheetSkeletonManagerService.setCurrent({sheetId:a,unitId:s})}_addViewport(e){const n=this._scene;if(n==null)return;const{rowHeader:o,columnHeader:r}=e.getConfig(),s=new w.Viewport(F.VIEW_MAIN,n,{left:o.width,top:r.height,bottom:0,right:0,isWheelPreventDefaultX:!0});return new w.Viewport(F.VIEW_ROW_TOP,n,{active:!1,isWheelPreventDefaultX:!0}),new w.Viewport(F.VIEW_ROW_BOTTOM,n,{left:0,top:r.height,bottom:0,width:o.width,isWheelPreventDefaultX:!0}),new w.Viewport(F.VIEW_COLUMN_LEFT,n,{active:!1,isWheelPreventDefaultX:!0}),new w.Viewport(F.VIEW_COLUMN_RIGHT,n,{left:o.width,top:0,height:r.height,right:0,isWheelPreventDefaultX:!0}),new w.Viewport(F.VIEW_LEFT_TOP,n,{left:0,top:0,width:o.width,height:r.height,isWheelPreventDefaultX:!0}),new w.Viewport(F.VIEW_MAIN_LEFT_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),new w.Viewport(F.VIEW_MAIN_LEFT,n,{isWheelPreventDefaultX:!0,active:!1}),new w.Viewport(F.VIEW_MAIN_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),this.disposeWithMe(l.toDisposable(n.onMouseWheelObserver.add((a,c)=>{if(a.ctrlKey)return;let d=0,u=0;const h=s.limitedScroll();if(a.inputIndex===w.PointerInput.MouseWheelX){const S=Math.abs(a.deltaX);a.deltaX>0?d=S:d=-S,this._commandService.executeCommand(Ft.id,{offsetX:d}),n.getParent().classType===w.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedX||c.stopPropagation():s.isWheelPreventDefaultX?a.preventDefault():h!=null&&h.isLimitedX||a.preventDefault()}if(a.inputIndex===w.PointerInput.MouseWheelY){let S=Math.abs(a.deltaY);a.shiftKey?(S*=3,a.deltaY>0?d=S:d=-S,this._commandService.executeCommand(Ft.id,{offsetX:d}),n.getParent().classType===w.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=S:u=-S,this._commandService.executeCommand(Ft.id,{offsetY:u}),n.getParent().classType===w.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedY||c.stopPropagation():s.isWheelPreventDefaultY?a.preventDefault():h!=null&&h.isLimitedY||a.preventDefault())}a.inputIndex,w.PointerInput.MouseWheelZ,this._scene.makeDirty(!0)}))),new w.ScrollBar(s),n.attachControl(),s}},x.SheetCanvasView=wm([l.OnLifecycle(l.LifecycleStages.Ready,x.SheetCanvasView),nn(0,l.IUniverInstanceService),nn(1,l.ICommandService),nn(2,w.IRenderManagerService),nn(3,ge),nn(4,P.Inject(x.SheetSkeletonManagerService))],x.SheetCanvasView);var Tm=Object.defineProperty,Em=Object.getOwnPropertyDescriptor,ym=(i,t,e,n)=>{for(var o=n>1?void 0:n?Em(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Tm(t,e,o),o},on=(i,t)=>(e,n)=>t(e,n,i);x.HoverManagerService=class{constructor(t,e,n,o,r){I(this,"_currentCell$",new V.Subject);I(this,"currentCell$",this._currentCell$.asObservable().pipe(V.distinctUntilChanged((t,e)=>{var n,o,r,s,a,c,d,u;return((n=t==null?void 0:t.location)==null?void 0:n.unitId)===((o=e==null?void 0:e.location)==null?void 0:o.unitId)&&((r=t==null?void 0:t.location)==null?void 0:r.subUnitId)===((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)&&((a=t==null?void 0:t.location)==null?void 0:a.row)===((c=e==null?void 0:e.location)==null?void 0:c.row)&&((d=t==null?void 0:t.location)==null?void 0:d.col)===((u=e==null?void 0:e.location)==null?void 0:u.col)})));I(this,"_lastPosition",null);this._univerInstanceService=t,this._scrollManagerService=e,this._sheetSkeletonManagerService=n,this._renderManagerService=o,this._selectionRenderService=r}_calcActiveCell(){if(!this._lastPosition)return;const{offsetX:t,offsetY:e}=this._lastPosition,n=this._univerInstanceService.getCurrentUniverSheetInstance(),o=n.getActiveSheet(),r=this._sheetSkeletonManagerService.getCurrent(),s=this._renderManagerService.getRenderById(n.getUnitId()),a=this._scrollManagerService.getCurrentScroll();if(!r||!a||!s)return;const{scene:c}=s,{skeleton:d,sheetId:u,unitId:h}=r,m=Sl(t,e,c,d);if(!m){this._currentCell$.next(null);return}const{row:S,col:_,mergeCell:g,actualCol:v,actualRow:M}=m,R={unitId:h,subUnitId:u,workbook:n,worksheet:o,row:M,col:v};let b;g?b=g:b={startRow:S,endRow:S,startColumn:_,endColumn:_};const E=c.getActiveViewportByCoord(w.Vector2.FromArray([t,e]));if(!E)return;const{scaleX:T,scaleY:y}=c.getAncestorScale(),O={x:E.actualScrollX,y:E.actualScrollY},N={startX:(d.getOffsetByPositionX(b.startColumn-1)-O.x)*T,endX:(d.getOffsetByPositionX(b.endColumn)-O.x)*T,startY:(d.getOffsetByPositionY(b.startRow-1)-O.y)*y,endY:(d.getOffsetByPositionY(b.endRow)-O.y)*y};this._currentCell$.next({location:R,position:N})}onMouseMove(t,e){this._lastPosition={offsetX:t,offsetY:e},this._calcActiveCell()}onScrollStart(){this._currentCell$.next(null)}onScrollEnd(){this._calcActiveCell()}},x.HoverManagerService=ym([on(0,l.IUniverInstanceService),on(1,P.Inject(Xe)),on(2,P.Inject(x.SheetSkeletonManagerService)),on(3,w.IRenderManagerService),on(4,ge)],x.HoverManagerService);var Om=Object.defineProperty,xm=Object.getOwnPropertyDescriptor,Nm=(i,t,e,n)=>{for(var o=n>1?void 0:n?xm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Om(t,e,o),o},to=(i,t)=>(e,n)=>t(e,n,i);x.HoverController=class extends l.Disposable{constructor(t,e,n){super(),this._renderManagerService=t,this._hoverManagerService=e,this._univerInstanceService=n,this._initPointerEvent()}_initScrollEvent(){}_initPointerEvent(){const t=this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId());if(!t)return;const{scene:e}=t,n=e.onPointerMoveObserver.add(o=>{this._hoverManagerService.onMouseMove(o.offsetX,o.offsetY)});this.disposeWithMe({dispose(){e.onPointerMoveObserver.remove(n)}})}},x.HoverController=Nm([l.OnLifecycle(l.LifecycleStages.Rendered,x.HoverController),to(0,w.IRenderManagerService),to(1,P.Inject(x.HoverManagerService)),to(2,l.IUniverInstanceService)],x.HoverController);const Ke={cellAlert:"univer-cell-alert",cellAlertTitle:"univer-cell-alert-title",cellAlertIcon:"univer-cell-alert-icon",cellAlertIconError:"univer-cell-alert-icon-error",cellAlertIconInfo:"univer-cell-alert-icon-info",cellAlertIconWarning:"univer-cell-alert-icon-warning",cellAlertContent:"univer-cell-alert-content"};function Am(){const i=K.useDependency(x.CellAlertManagerService),t=C.useObservable(i.currentAlert$,i.currentAlert),{type:e,title:n,message:o}=t||{},r={[sn.ERROR]:p.jsx(zr,{className:xe(Ke.cellAlertIcon,Ke.cellAlertIconError)}),[sn.INFO]:p.jsx(es,{className:xe(Ke.cellAlertIcon,Ke.cellAlertIconInfo)}),[sn.WARNING]:p.jsx(es,{className:xe(Ke.cellAlertIcon,Ke.cellAlertIconWarning)})};return p.jsxs("div",{className:Ke.cellAlert,children:[p.jsxs("div",{className:Ke.cellAlertTitle,children:[e?r[e]:null,n]}),p.jsx("div",{className:Ke.cellAlertContent,children:o})]})}const hs="univer.sheet.cell-alert";var Dm=Object.defineProperty,Pm=Object.getOwnPropertyDescriptor,Lm=(i,t,e,n)=>{for(var o=n>1?void 0:n?Pm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Dm(t,e,o),o},rn=(i,t)=>(e,n)=>t(e,n,i);x.SheetCanvasPopManagerService=class extends l.Disposable{constructor(t,e,n,o,r){super(),this._globalPopupManagerService=t,this._renderManagerService=e,this._univerInstanceService=n,this._sheetSkeletonManagerService=o,this._commandService=r}_calcCellPosition(t,e,n,o,r){const{scene:s,engine:a}=n,c=o.getCellByIndex(t,e),d=c.isMergedMainCell?c.mergeInfo:c,{scaleX:u,scaleY:h}=s.getAncestorScale(),m={x:r.actualScrollX,y:r.actualScrollY},S=a.getCanvasElement().getBoundingClientRect();return{left:(d.startX-m.x)*u,right:(d.endX-m.x)*u,top:(d.startY-m.y)*h+S.top,bottom:(d.endY-m.y)*h+S.top}}_createCellPositionObserver(t,e,n,o,r){const s=this._calcCellPosition(t,e,n,o,r),a=new V.BehaviorSubject(s),c=new l.DisposableCollection;return c.add(this._commandService.onCommandExecuted(d=>{if(d.id===f.SetWorksheetRowAutoHeightMutation.id&&d.params.rowsAutoHeightInfo.findIndex(h=>h.row===t)>-1){a.next(this._calcCellPosition(t,e,n,o,r));return}(f.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(d.id)>-1||d.id===nt.id||d.id===Pe.id)&&a.next(this._calcCellPosition(t,e,n,o,r))})),{position$:a,disposable:c,position:s}}_createObjectPositionObserver(t,e,n,o){const r=()=>{const{scene:d}=e,{left:u,top:h,width:m,height:S}=t,_={left:u,right:u+m,top:h,bottom:h+S},g=fl(_,d,n,o),v=e.engine.getCanvasElement().getBoundingClientRect();return{left:g.left,right:g.right,top:g.top+v.top,bottom:g.bottom+v.top}},s=r(),a=new V.BehaviorSubject(s),c=new l.DisposableCollection;return c.add(this._commandService.onCommandExecuted(d=>{(d.id===nt.id||d.id===Pe.id)&&a.next(r())})),{position:s,position$:a,disposable:c}}attachPopupToObject(t,e){const n=this._univerInstanceService.getCurrentUniverSheetInstance(),o=n.getActiveSheet(),r=n.getUnitId(),s=o.getSheetId(),a=this._sheetSkeletonManagerService.getOrCreateSkeleton({unitId:r,sheetId:s}),c=this._renderManagerService.getRenderById(r);if(!c||!a)return{dispose:()=>{}};const{position:d,position$:u,disposable:h}=this._createObjectPositionObserver(t,c,a,o),m=this._globalPopupManagerService.addPopup({...e,unitId:r,subUnitId:s,anchorRect:d,anchorRect$:u});return{dispose:()=>{this._globalPopupManagerService.removePopup(m),u.complete(),h.dispose()}}}attachPopupToCell(t,e,n,o){const r=this._univerInstanceService.getCurrentUniverSheetInstance(),s=r.getActiveSheet(),a=r.getUnitId(),c=s.getSheetId(),d=this._sheetSkeletonManagerService.getOrCreateSkeleton({unitId:a,sheetId:c}),u=this._renderManagerService.getRenderById(a);if(!u||!d)return{dispose:()=>{}};const h=o!=null?o:_l(t,e,u.scene,s);if(!h)return{dispose:()=>{}};const{position:m,position$:S,disposable:_}=this._createCellPositionObserver(t,e,u,d,h),g=this._globalPopupManagerService.addPopup({...n,unitId:a,subUnitId:c,anchorRect:m,anchorRect$:S}),v=()=>{this._globalPopupManagerService.removePopup(g),_.dispose(),S.complete()},M=this._commandService.onCommandExecuted(R=>{if(R.id===f.RemoveColMutation.id){const b=R.params;l.Rectangle.contains(b.range,{startColumn:e,endColumn:e,startRow:t,endRow:t})&&v()}if(R.id===f.RemoveRowMutation.id){const b=R.params;l.Rectangle.contains(b.range,{startColumn:e,endColumn:e,startRow:t,endRow:t})&&v()}});return{dispose:()=>{M.dispose(),v()}}}},x.SheetCanvasPopManagerService=Lm([rn(0,P.Inject(C.ICanvasPopupService)),rn(1,w.IRenderManagerService),rn(2,l.IUniverInstanceService),rn(3,P.Inject(x.SheetSkeletonManagerService)),rn(4,l.ICommandService)],x.SheetCanvasPopManagerService);var Hm=Object.defineProperty,Um=Object.getOwnPropertyDescriptor,Vm=(i,t,e,n)=>{for(var o=n>1?void 0:n?Um(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Hm(t,e,o),o},ms=(i,t)=>(e,n)=>t(e,n,i),sn=(i=>(i[i.INFO=0]="INFO",i[i.WARNING=1]="WARNING",i[i.ERROR=2]="ERROR",i))(sn||{});x.CellAlertManagerService=class{constructor(t,e){I(this,"_currentAlert$",new V.Subject);I(this,"_currentPopup");I(this,"_currentAlert",null);I(this,"currentAlert$",this._currentAlert$.asObservable());this._renderManagerService=t,this._canvasPopManagerService=e}get currentAlert(){return this._currentAlert}showAlert(t){this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null;const{location:e}=t,{row:n,col:o,unitId:r}=e;this._renderManagerService.getRenderById(r)&&(this._currentAlert=t,this._currentAlert$.next(t),this._currentPopup=this._canvasPopManagerService.attachPopupToCell(n,o,{componentKey:hs,direction:"horizontal",offset:[2,0]}))}clearAlert(){this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._currentAlert=null,this._currentAlert$.next(null)}},x.CellAlertManagerService=Vm([ms(0,w.IRenderManagerService),ms(1,P.Inject(x.SheetCanvasPopManagerService))],x.CellAlertManagerService);var km=Object.defineProperty,Bm=Object.getOwnPropertyDescriptor,Fm=(i,t,e,n)=>{for(var o=n>1?void 0:n?Bm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&km(t,e,o),o},Wm=(i,t)=>(e,n)=>t(e,n,i);let ii=class extends l.Disposable{constructor(i){super(),this._componentManager=i,this._initComponent()}_initComponent(){this._componentManager.register(hs,Am)}};ii=Fm([l.OnLifecycle(l.LifecycleStages.Starting,ii),Wm(0,P.Inject(C.ComponentManager))],ii);var jm=Object.defineProperty,zm=Object.getOwnPropertyDescriptor,Ym=(i,t,e,n)=>{for(var o=n>1?void 0:n?zm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&jm(t,e,o),o},no=(i,t)=>(e,n)=>t(e,n,i);x.UniverSheetsUIPlugin=(io=class extends l.Plugin{constructor(t,e,n,o){super(lo),this._injector=e,this._localeService=n,this._currentUniverService=o,this._localeService.load({zhCN:hr})}onStarting(t){[[x.SheetCanvasView],[Ht],[we,{useClass:x.EditorBridgeService}],[pt,{useClass:x.SheetClipboardService}],[Ot,{useClass:Yd}],[Rt,{useClass:Oi}],[Yt,{useClass:mr}],[wn,{useClass:cc}],[Wt,{useClass:x.AutoFillService}],[Xe],[x.SheetSkeletonManagerService],[ge,{useClass:x.SelectionRenderService}],[Gi,{useClass:Zu}],[Lt,{useClass:x.MarkSelectionService}],[x.HoverManagerService],[x.SheetCanvasPopManagerService],[x.CellAlertManagerService],[Tn],[En],[Hn],[Nn],[An],[Un],[Vn],[Bn],[Fn],[Wn],[zn],[Xn],[x.ScrollController],[$n],[yn],[On],[Zn],[ei],[Dn],[ni],[x.AutoFillController],[ti],[xn],[Yn],[x.HoverController],[ii],[x.CellCustomRenderController]].forEach(e=>t.add(e))}onReady(){this._markSheetAsFocused()}_markSheetAsFocused(){const t=this._currentUniverService;t.currentSheet$.pipe(vs.filter(e=>!!e)).subscribe(e=>{t.focusUniverInstance(e.getUnitId())})}},I(io,"type",l.PluginType.Sheet),io),x.UniverSheetsUIPlugin=Ym([no(1,P.Inject(P.Injector)),no(2,P.Inject(l.LocaleService)),no(3,l.IUniverInstanceService)],x.UniverSheetsUIPlugin),x.APPLY_TYPE=oe,x.AutoFillCommand=go,x.COPY_TYPE=at,x.CellAlertType=sn,x.CellEditorManagerService=mr,x.DATA_TYPE=me,x.ExpandSelectionCommand=Ae,x.IAutoFillService=Wt,x.ICellEditorManagerService=Yt,x.IEditorBridgeService=we,x.IFormulaEditorManagerService=wn,x.IMarkSelectionService=Lt,x.ISelectionRenderService=ge,x.ISheetClipboardService=pt,x.JumpOver=ke,x.MoveSelectionCommand=be,x.PASTE_SPECIAL_MENU_ID=Tt,x.PREDEFINED_HOOK_NAME=ve,x.ResetScrollCommand=za,x.SHEET_UI_PLUGIN_NAME=lo,x.SHEET_VIEW_KEY=fe,x.ScrollCommand=ct,x.ScrollToCellCommand=jo,x.SelectionShape=gn,x.SetCellEditVisibleArrowOperation=Bt,x.SetCellEditVisibleOperation=De,x.SetScrollOperation=nt,x.SetScrollRelativeCommand=Ft,x.SetZoomRatioOperation=Pe,x.SheetCopyCommand=Ao,x.SheetPasteCommand=vt,x.VIEWPORT_KEY=F,x.enUS=lc,x.getAutoFillRepeatRange=Ps,x.getCoordByCell=Ii,x.getCoordByOffset=Ct,x.getEditorObject=hn,x.getRepeatRange=_a,x.getSheetObject=Ie,x.getTransformCoord=Cn,x.mergeSetRangeValues=_i,x.whenFormulaEditorActivated=Hs,x.whenSheetEditorFocused=ie,x.zhCN=hr,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
|
|
17
|
+
*/var Ml=L,Rl=Symbol.for("react.element"),bl=Symbol.for("react.fragment"),wl=Object.prototype.hasOwnProperty,Tl=Ml.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,El={key:!0,ref:!0,__self:!0,__source:!0};function cr(i,t,e){var n,o={},r=null,s=null;e!==void 0&&(r=""+e),t.key!==void 0&&(r=""+t.key),t.ref!==void 0&&(s=t.ref);for(n in t)wl.call(t,n)&&!El.hasOwnProperty(n)&&(o[n]=t[n]);if(i&&i.defaultProps)for(n in t=i.defaultProps,t)o[n]===void 0&&(o[n]=t[n]);return{$$typeof:Rl,type:i,key:r,ref:s,props:o,_owner:Tl.current}}bn.Fragment=bl,bn.jsx=cr,bn.jsxs=cr,lr.exports=bn;var p=lr.exports;const Pi={sheetsUiContextMenuInput:"univer-sheets-ui-context-menu-input",sheetsUiContextMenuInputContainer:"univer-sheets-ui-context-menu-input-container",sheetsUiContextMenuInputNumber:"univer-sheets-ui-context-menu-input-number"},yl=i=>{const{prefix:t,suffix:e,value:n,onChange:o,min:r=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=i,a=Z.useDependency(l.LocaleService),[c,d]=L.useState(),u=m=>{var S;d(m==null?void 0:m.toString()),o((S=m==null?void 0:m.toString())!=null?S:"")};L.useEffect(()=>{d(n)},[n]);function h(m){m.key==="Backspace"&&m.stopPropagation()}return p.jsxs("div",{className:Pi.sheetsUiContextMenuInput,children:[a.t(t),p.jsx("span",{className:Pi.sheetsUiContextMenuInputContainer,onClick:m=>m.stopPropagation(),children:p.jsx(le.InputNumber,{className:Pi.sheetsUiContextMenuInputNumber,value:Number(c),precision:0,onKeyDown:h,onChange:u,min:r,max:s})}),a.t(e)]})};var he=(i=>(i.ROW_HEADER_CONTEXT_MENU="rowHeaderContextMenu",i.COL_HEADER_CONTEXT_MENU="colHeaderContextMenu",i.SHEET_BAR="sheetBar",i))(he||{});function Ol(i){const t=i.get(Rt);return{id:Ni.id,subId:er.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",positions:[C.MenuPosition.TOOLBAR_START],activated$:new k.Observable(e=>{let n=!1;const o=t.status$.subscribe(r=>{n=r!==Le.OFF,e.next(n)});return e.next(n),()=>{o.unsubscribe()}}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:f.getCurrentSheetDisabled$(i)}}function Al(i){const t=i.get(l.ICommandService),e=i.get(l.IUniverInstanceService),n=i.get(l.IContextService),o=i.get(f.SelectionManagerService);return{id:wi.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[C.MenuPosition.TOOLBAR_START],disabled$:f.getCurrentSheetDisabled$(i),activated$:new k.Observable(r=>{var u;const s=t.onCommandExecuted(h=>{var S,g;const m=h.id;if(m===f.SetRangeValuesMutation.id||m===f.SetSelectionsOperation.id||m===f.SetWorksheetActiveOperation.id){const _=(S=o.getLast())==null?void 0:S.primary,v=e.getCurrentUniverSheetInstance().getActiveSheet();let M=l.FontWeight.NORMAL;if(_!=null){const R=v.getRange(_.startRow,_.startColumn);M=R==null?void 0:R.getFontWeight()}r.next(M===l.FontWeight.BOLD)}if((m===te.SetTextSelectionsOperation.id||m===te.SetInlineFormatCommand.id)&&n.getContextValue(l.EDITOR_ACTIVATED)&&n.getContextValue(l.FOCUSING_SHEET)){const _=Yt(i);if(_==null)return;const v=(g=_.ts)==null?void 0:g.bl;r.next(v===l.BooleanNumber.TRUE)}}),a=(u=o.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d=l.FontWeight.NORMAL;if(a!=null){const h=c.getRange(a.startRow,a.startColumn);d=h==null?void 0:h.getFontWeight()}return r.next(d===l.FontWeight.BOLD),s.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function xl(i){const t=i.get(l.ICommandService),e=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService),o=i.get(l.IContextService);return{id:Ti.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[C.MenuPosition.TOOLBAR_START],disabled$:f.getCurrentSheetDisabled$(i),activated$:new k.Observable(r=>{var u;const s=t.onCommandExecuted(h=>{var S,g;const m=h.id;if(m===f.SetRangeValuesMutation.id||m===f.SetSelectionsOperation.id||m===f.SetWorksheetActiveOperation.id){const _=(S=n.getLast())==null?void 0:S.primary,v=e.getCurrentUniverSheetInstance().getActiveSheet();let M=l.FontItalic.NORMAL;if(_!=null){const R=v.getRange(_.startRow,_.startColumn);M=R==null?void 0:R.getFontStyle()}r.next(M===l.FontItalic.ITALIC)}if((m===te.SetTextSelectionsOperation.id||m===te.SetInlineFormatCommand.id)&&o.getContextValue(l.EDITOR_ACTIVATED)&&o.getContextValue(l.FOCUSING_SHEET)){const _=Yt(i);if(_==null)return;const v=(g=_.ts)==null?void 0:g.it;r.next(v===l.BooleanNumber.TRUE)}}),a=(u=n.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d=l.FontItalic.NORMAL;if(a!=null){const h=c.getRange(a.startRow,a.startColumn);d=h==null?void 0:h.getFontStyle()}return r.next(d===l.FontItalic.ITALIC),s.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function Nl(i){const t=i.get(l.ICommandService),e=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService),o=i.get(l.IContextService);return{id:Ei.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[C.MenuPosition.TOOLBAR_START],disabled$:f.getCurrentSheetDisabled$(i),activated$:new k.Observable(r=>{var u;const s=t.onCommandExecuted(h=>{var S,g;const m=h.id;if(m===f.SetRangeValuesMutation.id||m===f.SetSelectionsOperation.id||m===f.SetWorksheetActiveOperation.id){const _=(S=n.getLast())==null?void 0:S.primary,v=e.getCurrentUniverSheetInstance().getActiveSheet();let M;if(_!=null){const R=v.getRange(_.startRow,_.startColumn);M=R==null?void 0:R.getUnderline()}r.next(!!(M&&M.s))}if((m===te.SetTextSelectionsOperation.id||m===te.SetInlineFormatCommand.id)&&o.getContextValue(l.EDITOR_ACTIVATED)&&o.getContextValue(l.FOCUSING_SHEET)){const _=Yt(i);if(_==null)return;const v=(g=_.ts)==null?void 0:g.ul;r.next((v==null?void 0:v.s)===l.BooleanNumber.TRUE)}}),a=(u=n.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.getUnderline()}return r.next(!!(d&&d.s)),s.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function Dl(i){const t=i.get(l.ICommandService),e=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService),o=i.get(l.IContextService);return{id:yi.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[C.MenuPosition.TOOLBAR_START],disabled$:f.getCurrentSheetDisabled$(i),activated$:new k.Observable(r=>{var u;const s=t.onCommandExecuted(h=>{var S,g;const m=h.id;if(m===f.SetRangeValuesMutation.id||m===f.SetSelectionsOperation.id||m===f.SetWorksheetActiveOperation.id){const _=(S=n.getLast())==null?void 0:S.primary,v=e.getCurrentUniverSheetInstance().getActiveSheet();let M;if(_!=null){const R=v.getRange(_.startRow,_.startColumn);M=R==null?void 0:R.getStrikeThrough()}r.next(!!(M&&M.s))}if((m===te.SetTextSelectionsOperation.id||m===te.SetInlineFormatCommand.id)&&o.getContextValue(l.EDITOR_ACTIVATED)&&o.getContextValue(l.FOCUSING_SHEET)){const _=Yt(i);if(_==null)return;const v=(g=_.ts)==null?void 0:g.st;r.next((v==null?void 0:v.s)===l.BooleanNumber.TRUE)}}),a=(u=n.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.getStrikeThrough()}return r.next(!!(d&&d.s)),s.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function Pl(i){const t=i.get(l.ICommandService),e=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService);return{id:Ko.id,tooltip:"toolbar.font",group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.SELECTOR,label:rr,positions:[C.MenuPosition.TOOLBAR_START],selections:C.FONT_FAMILY_LIST.map(o=>({label:{name:sr,hoverable:!0},value:o.value})),disabled$:f.getCurrentSheetDisabled$(i),value$:new k.Observable(o=>{var u;const r=C.FONT_FAMILY_LIST[0].value,s=t.onCommandExecuted(h=>{var v;const m=h.id;if(m!==f.SetRangeValuesMutation.id&&m!==f.SetSelectionsOperation.id&&m!==f.SetWorksheetActiveOperation.id)return;const S=(v=n.getLast())==null?void 0:v.primary,g=e.getCurrentUniverSheetInstance().getActiveSheet();let _;if(S!=null){const M=g.getRange(S.startRow,S.startColumn);_=M==null?void 0:M.getFontFamily()}o.next(_!=null?_:r)}),a=(u=n.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.getFontFamily()}return o.next(d!=null?d:r),s.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function Ll(i){const t=i.get(l.ICommandService),e=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService),o=i.get(l.IContextService),r=f.getCurrentSheetDisabled$(i);return{id:Go.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:ar,props:{min:1,max:400,disabled$:r}},positions:[C.MenuPosition.TOOLBAR_START],selections:C.FONT_SIZE_LIST,disabled$:r,value$:new k.Observable(s=>{var m;const c=t.onCommandExecuted(S=>{var _,v;const g=S.id;if(g===f.SetRangeValuesMutation.id||g===f.SetSelectionsOperation.id||g===f.SetWorksheetActiveOperation.id){const M=(_=n.getLast())==null?void 0:_.primary,R=e.getCurrentUniverSheetInstance().getActiveSheet();let b;if(M!=null){const E=R.getRange(M.startRow,M.startColumn);b=E==null?void 0:E.getFontSize()}s.next(b!=null?b:11)}if((g===te.SetTextSelectionsOperation.id||g===te.SetInlineFormatCommand.id)&&o.getContextValue(l.EDITOR_ACTIVATED)&&o.getContextValue(l.FOCUSING_SHEET)){const M=Yt(i);if(M==null)return;const R=(v=M.ts)==null?void 0:v.fs;s.next(R!=null?R:11)}}),d=(m=n.getLast())==null?void 0:m.primary,u=e.getCurrentUniverSheetInstance().getActiveSheet();let h;if(d!=null){const S=u.getRange(d.startRow,d.startColumn);h=S==null?void 0:S.getFontSize()}return s.next(h!=null?h:11),c.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function Ul(i){return{id:f.ResetTextColorCommand.id,type:C.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:In.id,disabled$:f.getCurrentSheetDisabled$(i)}}function Hl(i){const t=i.get(l.ICommandService),e=i.get(l.ThemeService);return{id:In.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON_SELECTOR,positions:[C.MenuPosition.TOOLBAR_START],selections:[{label:{name:Rn,hoverable:!1}}],value$:new k.Observable(n=>{const o=e.getCurrentTheme().textColor,r=t.onCommandExecuted(s=>{if(s.id===In.id){const a=s.params.value;n.next(a!=null?a:o)}});return n.next(o),r.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:f.getCurrentSheetDisabled$(i)}}function Vl(i){return{id:f.ResetBackgroundColorCommand.id,type:C.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:f.SetBackgroundColorCommand.id,disabled$:f.getCurrentSheetDisabled$(i)}}function kl(i){const t=i.get(l.ICommandService),e=i.get(l.ThemeService);return{id:f.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON_SELECTOR,positions:[C.MenuPosition.TOOLBAR_START],icon:"PaintBucket",selections:[{label:{name:Rn,hoverable:!1}}],value$:new k.Observable(n=>{const o=e.getCurrentTheme().primaryColor,r=t.onCommandExecuted(s=>{if(s.id===f.SetBackgroundColorCommand.id){const a=s.params.value;n.next(a!=null?a:o)}});return n.next(o),r.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:f.getCurrentSheetDisabled$(i)}}const dr=[{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 Bl(i){const t=i.get(l.IUniverInstanceService),e=i.get(f.SelectionManagerService);return{id:f.SetHorizontalTextAlignCommand.id,icon:dr[0].icon,positions:[C.MenuPosition.TOOLBAR_START],tooltip:"toolbar.horizontalAlignMode.main",group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SELECTOR,selections:dr,value$:new k.Observable(n=>{var c;const o=i.get(l.ICommandService).onCommandExecuted(d=>{var g;const u=d.id;if(u!==f.SetHorizontalTextAlignCommand.id&&u!==f.SetSelectionsOperation.id&&u!==f.SetWorksheetActiveOperation.id)return;const h=(g=e.getLast())==null?void 0:g.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let S;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);S=_==null?void 0:_.getHorizontalAlignment()}n.next(S!=null?S:l.HorizontalAlign.LEFT)}),r=(c=e.getLast())==null?void 0:c.primary,s=t.getCurrentUniverSheetInstance().getActiveSheet();let a;if(r!=null){const d=s.getRange(r.startRow,r.startColumn);a=d==null?void 0:d.getHorizontalAlignment()}return n.next(a!=null?a:l.HorizontalAlign.LEFT),o.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:f.getCurrentSheetDisabled$(i)}}const ur=[{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 Fl(i){const t=i.get(l.IUniverInstanceService),e=i.get(f.SelectionManagerService);return{id:f.SetVerticalTextAlignCommand.id,icon:ur[0].icon,tooltip:"toolbar.verticalAlignMode.main",group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SELECTOR,positions:[C.MenuPosition.TOOLBAR_START],selections:ur,value$:new k.Observable(n=>{var c;const o=i.get(l.ICommandService).onCommandExecuted(d=>{var g;const u=d.id;if(u!==f.SetVerticalTextAlignCommand.id&&u!==f.SetSelectionsOperation.id&&u!==f.SetWorksheetActiveOperation.id)return;const h=(g=e.getLast())==null?void 0:g.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let S;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);S=_==null?void 0:_.getVerticalAlignment()}n.next(S!=null?S:l.VerticalAlign.TOP)}),r=(c=e.getLast())==null?void 0:c.primary,s=t.getCurrentUniverSheetInstance().getActiveSheet();let a;if(r!=null){const d=s.getRange(r.startRow,r.startColumn);a=d==null?void 0:d.getVerticalAlignment()}return n.next(a!=null?a:l.VerticalAlign.TOP),o.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:f.getCurrentSheetDisabled$(i)}}const hr=[{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 Wl(i){const t=i.get(f.SelectionManagerService),e=i.get(l.IUniverInstanceService);return{id:f.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:hr[0].icon,group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SELECTOR,positions:[C.MenuPosition.TOOLBAR_START],selections:hr,value$:new k.Observable(n=>{var c;const o=i.get(l.ICommandService).onCommandExecuted(d=>{var g;const u=d.id;if(u!==f.SetTextWrapCommand.id&&u!==f.SetSelectionsOperation.id&&u!==f.SetWorksheetActiveOperation.id)return;const h=(g=t.getLast())==null?void 0:g.primary,m=e.getCurrentUniverSheetInstance().getActiveSheet();let S;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);S=_==null?void 0:_.getWrapStrategy()}n.next(S!=null?S:l.WrapStrategy.OVERFLOW)}),r=(c=t.getLast())==null?void 0:c.primary,s=e.getCurrentUniverSheetInstance().getActiveSheet();let a;if(r!=null){const d=s.getRange(r.startRow,r.startColumn);a=d==null?void 0:d.getWrapStrategy()}return n.next(a!=null?a:l.WrapStrategy.OVERFLOW),o.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:f.getCurrentSheetDisabled$(i)}}const mr=[{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 jl(i){const t=i.get(f.SelectionManagerService),e=i.get(l.IUniverInstanceService);return{id:f.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:mr[0].icon,group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SELECTOR,selections:mr,positions:[C.MenuPosition.TOOLBAR_START],value$:new k.Observable(n=>{var c,d;const o=i.get(l.ICommandService).onCommandExecuted(u=>{var _,v;const h=u.id;if(h!==f.SetTextRotationCommand.id&&h!==f.SetSelectionsOperation.id&&h!==f.SetWorksheetActiveOperation.id)return;const m=(_=t.getLast())==null?void 0:_.primary,S=e.getCurrentUniverSheetInstance().getActiveSheet();let g;if(m!=null){const M=S.getRange(m.startRow,m.startColumn);g=M==null?void 0:M.getTextRotation()}(g==null?void 0:g.v)===l.BooleanNumber.TRUE?n.next("v"):n.next((v=g&&g.a)!=null?v:0)}),r=(c=t.getLast())==null?void 0:c.primary,s=e.getCurrentUniverSheetInstance().getActiveSheet();let a;if(r!=null){const u=s.getRange(r.startRow,r.startColumn);a=u==null?void 0:u.getTextRotation()}return(a==null?void 0:a.v)===l.BooleanNumber.TRUE?n.next("v"):n.next((d=a&&a.a)!=null?d:0),o.dispose}),hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:f.getCurrentSheetDisabled$(i)}}function wt(i){return new k.Observable(t=>t.next(!i.get(C.IClipboardInterfaceService).supportClipboard))}function zl(){return{id:C.CopyCommand.id,group:C.MenuGroup.CONTEXT_MENU_FORMAT,type:C.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",positions:[C.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function Yl(i){return{id:C.PasteCommand.id,group:C.MenuGroup.CONTEXT_MENU_FORMAT,type:C.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",disabled$:wt(i),positions:[C.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}const Tt="sheet.menu.paste-special";function Xl(i){return{id:Tt,group:C.MenuGroup.CONTEXT_MENU_FORMAT,type:C.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",disabled$:wt(i),positions:[C.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function $l(i){return{id:Lo.id,type:C.MenuItemType.BUTTON,title:"rightClick.pasteValue",positions:[Tt],disabled$:wt(i)}}function Zl(i){return{id:Uo.id,type:C.MenuItemType.BUTTON,title:"rightClick.pasteFormat",positions:[Tt],disabled$:wt(i)}}function Gl(i){return{id:Ho.id,type:C.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",positions:[Tt],disabled$:wt(i)}}function Kl(i){return{id:Vo.id,type:C.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",positions:[Tt],disabled$:wt(i)}}function Ql(){return{id:f.SetWorksheetRowIsAutoHeightCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"AutoHeight",title:"rightClick.fitContent"}}const zt="sheet.menu.sheet-frozen";function Jl(){return{id:zt,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:[C.MenuPosition.CONTEXT_MENU]}}const Li="sheet.header-menu.sheet-frozen";function ql(){return{id:Li,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:["rowHeaderContextMenu","colHeaderContextMenu"]}}function ec(){return{id:Mn.id,type:C.MenuItemType.BUTTON,positions:[zt,Li],title:"rightClick.freeze",icon:"FreezeToSelectedSingle"}}function tc(){return{id:nr.id,type:C.MenuItemType.BUTTON,positions:[zt],title:"rightClick.freezeRow",icon:"FreezeRowSingle"}}function nc(){return{id:ir.id,type:C.MenuItemType.BUTTON,positions:[zt],title:"rightClick.freezeCol",icon:"FreezeColumnSingle"}}function ic(){return{id:or.id,type:C.MenuItemType.BUTTON,positions:[zt,Li],title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle"}}function oc(){return{id:$o.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedRow"}}function rc(){return{id:Zo.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedColumn"}}function sc(i){const t=i.get(l.IUniverInstanceService),e=i.get(f.SelectionManagerService);function n(){var a;const r=t.getCurrentUniverSheetInstance().getActiveSheet(),s=(a=e.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(!r.getRowVisible(d))return!0;return!1}))}const o=i.get(l.ICommandService);return{id:f.SetSelectedRowsVisibleCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],title:"rightClick.showHideRow",hidden$:new k.Observable(r=>{const s=o.onCommandExecuted(a=>{(a.id===f.SetSelectionsOperation.id||a.id===f.SetRowHiddenMutation.id||a.id===f.SetRowVisibleMutation.id)&&r.next(!n())});return r.next(!n()),()=>s.dispose()})}}function ac(i){const t=i.get(l.IUniverInstanceService),e=i.get(f.SelectionManagerService);function n(){var a;const r=t.getCurrentUniverSheetInstance().getActiveSheet(),s=(a=e.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(!r.getColVisible(d))return!0;return!1})}const o=i.get(l.ICommandService);return{id:f.SetSelectedColsVisibleCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],title:"rightClick.showHideColumn",hidden$:new k.Observable(r=>{const s=o.onCommandExecuted(a=>{(a.id===f.SetSelectionsOperation.id||a.id===f.SetColHiddenMutation.id||a.id===f.SetColVisibleMutation.id)&&r.next(!n())});return r.next(!n()),()=>s.dispose()})}}function lc(i){const t=i.get(l.ICommandService),e=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService);return{id:f.SetRowHeightCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,icon:"AdjustHeight",positions:["rowHeaderContextMenu"],label:{name:Di,props:{prefix:"rightClick.rowHeight",suffix:"px",min:2,max:1e3}},value$:new k.Observable(o=>{function r(){var u;const a=(u=n.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;a!=null&&(d=c.getRowHeight(a.startRow)),o.next(d!=null?d:0)}const s=t.onCommandExecuted(a=>{const c=a.id;if(c===f.SetRangeValuesMutation.id||c===f.SetSelectionsOperation.id)return r()});return r(),s.dispose})}}function cc(i){const t=i.get(l.ICommandService),e=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService);return{id:f.SetColWidthCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,icon:"AdjustWidth",positions:["colHeaderContextMenu"],label:{name:Di,props:{prefix:"rightClick.columnWidth",suffix:"px",min:2,max:1e3}},value$:new k.Observable(o=>{function r(){var u;const a=(u=n.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d=0;a!=null&&(d=c.getColumnWidth(a.startColumn)),o.next(d)}const s=t.onCommandExecuted(a=>{const c=a.id;if(c===f.SetRangeValuesMutation.id||c===f.SetSelectionsOperation.id)return r()});return r(),s.dispose})}}function Yt(i){var c;const t=i.get(l.IUniverInstanceService),e=i.get(te.TextSelectionManagerService),n=t.getUniverDocInstance(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),o=e.getActiveRange();if(n==null||o==null)return;const r=(c=n.getBody())==null?void 0:c.textRuns;if(r==null)return;const{startOffset:s}=o;return r.find(({st:d,ed:u})=>s>=d&&s<=u)}const dc={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",conditionalFormatting:"Conditional formatting",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"},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"},shortCutNotify:{title:"Kindly paste using keyboard shortcuts.",useShortCutInstead:"Detected Excel content. Use keyboard shortcut to paste."}},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",definedName:{managerTitle:"Manager named",managerDescription:"Create a defined name by selecting cells or formulas, and entering the desired name into the text box.",addButton:"Add a defined name",featureTitle:"Defined names",ratioRange:"Range",ratioFormula:"Formula",confirm:"Confirm",cancel:"Cancel",scopeWorkbook:"Workbook",inputNamePlaceholder:"Please enter a name(No space allowed)",inputCommentPlaceholder:"Please enter a comment",inputRangePlaceholder:"Please input range(No space allowed)",inputFormulaPlaceholder:"Please input a formula(No space allowed)",nameEmpty:"Name cannot be empty",nameDuplicate:"Name already exists",formulaOrRefStringEmpty:"Formula or reference string cannot be empty",formulaOrRefStringInvalid:"Invalid formula or reference string",defaultName:"DefinedName",updateButton:"Update",deleteButton:"Delete",deleteConfirmText:"Are you sure you want to delete this defined name?",nameConflict:"The name conflicts with the function name",nameInvalid:"The name is invalid",nameSheetConflict:"The name conflicts with the sheet name"}},Sr={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:"更多函数",conditionalFormatting:"条件格式",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:"粘贴区域超出最大单元格数"},shortCutNotify:{title:"请使用快捷键粘贴",useShortCutInstead:"检测到 Excel 内容,请使用快捷键粘贴"}},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":"编辑表格",definedName:{managerTitle:"名称管理器",managerDescription:"通过选择单元格或公式,并在文本框中输入您想要的名称来创建一个定义名称。",addButton:"新建名称",featureTitle:"定义名称",ratioRange:"范围",ratioFormula:"公式",confirm:"确认",cancel:"取消",scopeWorkbook:"工作簿",inputNamePlaceholder:"请输入名称(必填)",inputCommentPlaceholder:"请输入备注",inputRangePlaceholder:"请输入范围(必填)",inputFormulaPlaceholder:"请输入公式(必填)",nameEmpty:"名称不能为空",nameDuplicate:"名称重复",formulaOrRefStringEmpty:"公式或引用字符串不能为空",formulaOrRefStringInvalid:"公式或引用字符串无效",defaultName:"DefinedName",updateButton:"修改",deleteButton:"删除",deleteConfirmText:"确定删除定义名称?",nameConflict:"与函数名称冲突",nameInvalid:"名称不包含空格或不允许的字符",nameSheetConflict:"名称与工作表名称冲突"}};class gr{constructor(){I(this,"_state",null);I(this,"_rect",null);I(this,"_state$",new k.BehaviorSubject(null));I(this,"state$",this._state$.asObservable());I(this,"_rect$",new k.BehaviorSubject(null));I(this,"rect$",this._rect$.asObservable());I(this,"_focus",!1);I(this,"_focus$",new k.BehaviorSubject(this._focus));I(this,"focus$",this._focus$.asObservable())}dispose(){this._state$.complete(),this._state=null,this._rect$.complete(),this._rect=null}setState(t){this._state=t,this._refresh(t)}getRect(){return this._rect}setRect(t){this._rect=t,this._rect$.next(t)}getState(){return this._state}setFocus(t=!1){this._focus=t,this._focus$.next(t)}_refresh(t){this._state$.next(t)}}const Xt=P.createIdentifier("univer.sheet-cell-editor-manager.service");class uc{constructor(){I(this,"_position",null);I(this,"_position$",new k.BehaviorSubject(null));I(this,"position$",this._position$.asObservable());I(this,"_focus",!1);I(this,"_focus$",new k.BehaviorSubject(this._focus));I(this,"focus$",this._focus$.asObservable());I(this,"_fxBtnClick$",new k.Subject);I(this,"fxBtnClick$",this._fxBtnClick$.asObservable());I(this,"_foldBtnStatus$",new k.Subject);I(this,"foldBtnStatus$",this._foldBtnStatus$.asObservable())}dispose(){this._position$.complete(),this._focus$.complete(),this._position=null,this._focus=!1}setPosition(t){this._position=t,this._refresh(t)}getPosition(){return this._position}setFocus(t=!1){this._focus=t,this._focus$.next(t)}handleFxBtnClick(t){this._fxBtnClick$.next(t)}handleFoldBtnClick(t){this._foldBtnStatus$.next(t)}_refresh(t){this._position$.next(t)}}const wn=P.createIdentifier("univer.sheet-formula-editor-manager.service");var hc=Object.defineProperty,mc=Object.getOwnPropertyDescriptor,Sc=(i,t,e,n)=>{for(var o=n>1?void 0:n?mc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&hc(t,e,o),o},_r=(i,t)=>(e,n)=>t(e,n,i);let Tn=class extends l.Disposable{constructor(t,e){super();I(this,"_previousSheetIndex",-1);this._commandService=t,this._univerInstanceService=e,this.disposeWithMe(this._commandService.beforeCommandExecuted(n=>{if(n.id===f.RemoveSheetMutation.id)return this._beforeAdjustActiveSheetOnRemoveSheet(n)})),this.disposeWithMe(this._commandService.onCommandExecuted((n,o)=>{if(n.id===f.RemoveSheetMutation.id)return this._adjustActiveSheetOnRemoveSheet(n);if(n.id===f.SetWorksheetHideMutation.id&&n.params.hidden)return this._adjustActiveSheetOnHideSheet(n);if(!(o!=null&&o.fromCollab)){if(n.id===f.InsertSheetMutation.id)return this._adjustActiveSheetOnInsertSheet(n);if(n.id===f.SetWorksheetHideMutation.id&&!n.params.hidden)return this._adjustActiveSheetOnShowSheet(n)}}))}_adjustActiveSheetOnHideSheet(t){const{unitId:e,subUnitId:n}=t.params,o=this._univerInstanceService.getUniverSheetInstance(e);if(!o||o.getActiveSheet().getSheetId()!==n)return;const s=o.getActiveSheetIndex(),a=fr(o,s);this._switchToNextSheet(e,a)}_beforeAdjustActiveSheetOnRemoveSheet(t){const{unitId:e,subUnitId:n}=t.params,o=this._univerInstanceService.getUniverSheetInstance(e);if(!o)return;const r=o.getSheetBySheetId(n);r&&(this._previousSheetIndex=o.getSheetIndex(r))}_adjustActiveSheetOnRemoveSheet(t){if(this._previousSheetIndex===-1)return;const{unitId:e}=t.params,n=this._univerInstanceService.getUniverSheetInstance(e);if(!n||n.getRawActiveSheet())return;const r=this._previousSheetIndex,s=r>=1?r-1:0,a=fr(n,s);this._switchToNextSheet(e,a)}_adjustActiveSheetOnInsertSheet(t){const{unitId:e,sheet:n}=t.params;this._switchToNextSheet(e,n.id)}_adjustActiveSheetOnShowSheet(t){const{unitId:e,subUnitId:n}=t.params;this._switchToNextSheet(e,n)}_switchToNextSheet(t,e){this._commandService.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:e})}};Tn=Sc([l.OnLifecycle(l.LifecycleStages.Ready,Tn),_r(0,l.ICommandService),_r(1,l.IUniverInstanceService)],Tn);function fr(i,t){const e=i.getSheetSize();for(let n=t;n>-1;n--){const o=i.getSheetByIndex(n);if(!o.getConfig().hidden)return o.getSheetId()}for(let n=t;n<e;n++){const o=i.getSheetByIndex(n);if(!o.getConfig().hidden)return o.getSheetId()}throw new Error("[ActiveWorksheetController]: could not find the next unhidden sheet! Collaboration error perhaps.")}var gc=Object.defineProperty,_c=Object.getOwnPropertyDescriptor,fc=(i,t,e,n)=>{for(var o=n>1?void 0:n?_c(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&gc(t,e,o),o},$t=(i,t)=>(e,n)=>t(e,n,i);let En=class{constructor(i,t,e,n,o){this._injector=i,this._sheetInterceptorService=t,this._selectionManagerService=e,this._univerInstanceService=n,this._sheetSkeletonManagerService=o,this._initialize()}_getUndoRedoParamsOfAutoHeight(i){const{_univerInstanceService:t,_sheetSkeletonManagerService:e,_injector:n}=this,{skeleton:o}=e.getCurrent(),r=o.calculateAutoHeightInRange(i),s=t.getCurrentUniverSheetInstance(),a=s.getUnitId(),d={subUnitId:s.getActiveSheet().getSheetId(),unitId:a,rowsAutoHeightInfo:r},u=f.SetWorksheetRowAutoHeightMutationFactory(n,d);return{undos:[{id:f.SetWorksheetRowAutoHeightMutation.id,params:u}],redos:[{id:f.SetWorksheetRowAutoHeightMutation.id,params:d}]}}_initialize(){const{_sheetInterceptorService:i,_selectionManagerService:t}=this;i.interceptCommand({getMutations:e=>e.id!==f.SetRangeValuesCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(e.params.range)}),i.interceptCommand({getMutations:e=>e.id!==f.SetWorksheetRowIsAutoHeightCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(e.params.ranges)}),i.interceptCommand({getMutations:e=>{var r;if(e.id!==f.SetStyleCommand.id)return{redos:[],undos:[]};if(!["ff","fs","tr","tb"].includes((r=e.params)==null?void 0:r.style.type))return{redos:[],undos:[]};const o=t.getSelectionRanges();return o!=null&&o.length?this._getUndoRedoParamsOfAutoHeight(o):{redos:[],undos:[]}}})}};En=fc([l.OnLifecycle(l.LifecycleStages.Ready,En),$t(0,P.Inject(P.Injector)),$t(1,P.Inject(f.SheetInterceptorService)),$t(2,P.Inject(f.SelectionManagerService)),$t(3,P.Inject(l.IUniverInstanceService)),$t(4,P.Inject(A.SheetSkeletonManagerService))],En);var pc=Object.defineProperty,vc=Object.getOwnPropertyDescriptor,Cc=(i,t,e,n)=>{for(var o=n>1?void 0:n?vc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&pc(t,e,o),o},Ue=(i,t)=>(e,n)=>t(e,n,i);let yn=class extends l.RxDisposable{constructor(i,t,e,n,o,r,s,a,c,d,u){var h;super(),this._injector=i,this._currentUniverSheet=t,this._commandService=e,this._contextService=n,this._configService=o,this._sheetClipboardService=r,this._clipboardInterfaceService=s,this._messageService=a,this._sheetSkeletonManagerService=c,this._localService=d,this._textSelectionRenderManager=u,this._init(),(h=this._textSelectionRenderManager)==null||h.onPaste$.pipe(k.takeUntil(this.dispose$)).subscribe(m=>{var v,M;if(!ie(this._contextService))return;m.event.preventDefault();const S=m.event,g=(v=S.clipboardData)==null?void 0:v.getData("text/html"),_=(M=S.clipboardData)==null?void 0:M.getData("text/plain");this._sheetClipboardService.legacyPaste(g,_)})}_init(){[Po,Aa,vt].forEach(t=>this.disposeWithMe(this._commandService.registerMultipleCommand(t))),[Lo,Uo,Ho,Vo].forEach(t=>this.disposeWithMe(this._commandService.registerCommand(t))),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initCopyingHooks())),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingHook()));const i=this._initSpecialPasteHooks().map(t=>this._sheetClipboardService.addClipboardHook(t));this.disposeWithMe({dispose:()=>i.forEach(t=>t.dispose())})}_initCopyingHooks(){const i=this;let t=null;return{id:ve.DEFAULT_COPY,isDefaultHook:!0,onBeforeCopy(e,n){t=i._getWorksheet(e,n)},onCopyCellContent(e,n){const o=t.getCell(e,n);return o?l.extractPureTextFromCell(o):""},onCopyCellStyle:(e,n,o,r)=>{const s={};(o||r)&&(s.rowspan=`${o||1}`,s.colspan=`${r||1}`);const c=t.getRange(e,n).getTextStyle();let d="";return c&&(d=l.handleStyleToString(c)),d&&(s.style=d),s},onCopyColumn(e){return{width:`${t.getColumnWidth(e)}`}},onCopyRow(e){return{style:`height: ${t.getRowHeight(e)}px;`}},onAfterCopy(){t=null}}}_initPastingHook(){const i=this;let t=null,e=null,n=null;return{id:ve.DEFAULT_PASTE,isDefaultHook:!0,onBeforePaste({unitId:o,subUnitId:r,range:s}){n=i._getWorksheet(o,r),t=o,e=r;const a=i._configService.getConfig(f.MAX_CELL_PER_SHEET_KEY),{endRow:c,endColumn:d}=s;return a&&c*d>a?(i._messageService.show({type:le.MessageType.Error,content:i._localService.t("clipboard.paste.exceedMaxCells")}),!1):!0},onPasteRows(o,r){const{range:s}=o,a=[],c=n.getMaxRows(),d=s.endRow-c,u=r.length-d;if(d>0){const S={};r.slice(u).forEach((_,v)=>{const{style:M,height:R}=_||{};if(M){const b=M.split(";");let E=l.DEFAULT_WORKSHEET_ROW_HEIGHT;b.find(T=>{T=T.toLowerCase();const y=C.textTrim(T.substr(0,T.indexOf(":"))),O=C.textTrim(T.substr(T.indexOf(":")+1));return y==="height"?(E=Number.parseFloat(O),!0):!1}),S[v]={h:E,hd:l.BooleanNumber.FALSE}}else R&&(S[v]={h:Number.parseFloat(R),hd:l.BooleanNumber.FALSE})});const g={unitId:t,subUnitId:e,range:{...s,startRow:c},rowInfo:S};a.push({id:f.InsertRowMutation.id,params:g})}const h={};r.slice(0,u).forEach((S,g)=>{const{style:_,height:v}=S;if(_){const M=_.split(";");let R=l.DEFAULT_WORKSHEET_ROW_HEIGHT;M.find(b=>{b=b.toLowerCase();const E=C.textTrim(b.substr(0,b.indexOf(":"))),T=C.textTrim(b.substr(b.indexOf(":")+1));return E==="height"?(R=Number.parseFloat(T),!0):!1}),h[g+s.startRow]=R}else v&&(h[g+s.startRow]=Number.parseFloat(v))});const m={unitId:t,subUnitId:e,ranges:[{...s,endRow:Math.min(s.endRow,c)}],rowHeight:h};return a.push({id:f.SetWorksheetRowHeightMutation.id,params:m}),{redos:a,undos:[]}},onPasteColumns(o,r,s){var g;const{range:a}=o,c=[],d=n.getMaxColumns(),u=a.endColumn-d,h=r.length-u,m=(g=i._configService.getConfig(l.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?g:l.DEFAULT_WORKSHEET_COLUMN_WIDTH;if(u>0){const _={unitId:t,subUnitId:e,range:{...a,startColumn:d},colInfo:r.slice(h).map(v=>({w:v.width?+v.width:m,hd:l.BooleanNumber.FALSE}))};c.push({id:f.InsertColMutation.id,params:_})}const S={unitId:t,subUnitId:e,ranges:[{...a,endRow:Math.min(a.endColumn,d)}],colWidth:r.slice(0,h).map(_=>_.width?+_.width:m)};return c.push({id:f.SetWorksheetColWidthMutation.id,params:S}),{redos:c,undos:[]}},onPastePlainText(o,r,s){return i._onPastePlainText(o,r,s)},onPasteCells(o,r,s,a){return i._onPasteCells(o,r,s,a)},onAfterPaste(o){n=null}}}_generateDocumentDataModelSnapshot(i){var s;const t=this._sheetSkeletonManagerService.getCurrent();if(t==null)return null;const{skeleton:e}=t,n=(s=e.getBlankCellDocumentModel())==null?void 0:s.documentModel,r={...n==null?void 0:n.getSnapshot(),...i};return n==null||n.reset(r),n==null?void 0:n.getSnapshot()}_onPastePlainText(i,t,e){const{range:n,unitId:o,subUnitId:r}=i;let s;if(/\r|\n/.test(t)){const c=Ao(t),d=this._generateDocumentDataModelSnapshot({body:c});s={[n.startRow]:{[n.startColumn]:{p:d}}}}else s={[n.startRow]:{[n.startColumn]:{v:t}}};const a={unitId:o,subUnitId:r,cellValue:s};return{redos:[{id:f.SetRangeValuesMutation.id,params:a}],undos:[{id:f.SetRangeValuesMutation.id,params:f.SetRangeValuesUndoMutationFactory(this._injector,a)}]}}_onPasteCells(i,t,e,n){const o={get:this._injector.get.bind(this._injector)};return ia(i,t,e,n,o)}_initSpecialPasteHooks(){const i={get:this._injector.get.bind(this._injector)},t=this,e={id:ve.SPECIAL_PASTE_VALUE,specialPasteInfo:{label:"specialPaste.value"},onPasteCells:(s,a,c,d)=>{const u=t._currentUniverSheet.getCurrentUniverSheetInstance();return u.getUnitId(),u.getActiveSheet().getSheetId(),Eo(a,c,i)}},n={id:ve.SPECIAL_PASTE_FORMAT,specialPasteInfo:{label:"specialPaste.format"},onPasteCells(s,a,c,d){const u=t._currentUniverSheet.getCurrentUniverSheetInstance();u.getUnitId(),u.getActiveSheet().getSheetId();const h=[],m=[],{undos:S,redos:g}=Oo(a,c,i);h.push(...g),m.push(...S);const{undos:_,redos:v}=ui(a,c,i);h.push(...v),m.push(..._);const{undos:M,redos:R}=yo(a,c,i);return h.push(...R),m.push(...M),{undos:m,redos:h}}},o={id:ve.SPECIAL_PASTE_COL_WIDTH,specialPasteInfo:{label:"specialPaste.colWidth"},onPasteCells(){return{undos:[],redos:[]}},onPasteColumns(s,a,c){var E;const d=t._currentUniverSheet.getCurrentUniverSheetInstance(),u=d.getUnitId(),h=d.getActiveSheet().getSheetId(),m=[],S=t._getWorksheet(u,h),{range:g}=s,_=S.getMaxColumns(),v=g.endColumn-_,M=a.length-v,R=(E=t._configService.getConfig(l.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?E:l.DEFAULT_WORKSHEET_COLUMN_WIDTH,b={unitId:u,subUnitId:h,ranges:[{...g,endRow:Math.min(g.endColumn,_)}],colWidth:a.slice(0,M).map(T=>T.width?+T.width:R)};return m.push({id:f.SetWorksheetColWidthMutation.id,params:b}),m.push({id:f.SetWorksheetColWidthMutation.id,params:b}),{redos:m,undos:[]}}},r={id:ve.SPECIAL_PASTE_BESIDES_BORDER,specialPasteInfo:{label:"specialPaste.besidesBorder"},onPasteCells(s,a,c,d){t._currentUniverSheet.getCurrentUniverSheetInstance();const u=[],h=[],{range:m,unitId:S,subUnitId:g}=a,{startColumn:_,startRow:v,endColumn:M,endRow:R}=m,b=new l.ObjectMatrix;c.forValue((x,N,V)=>{const D=V.s;typeof D=="object"&&b.setValue(x+v,N+_,{s:{...D,bd:void 0},v:V.v})});const E={unitId:S,subUnitId:g,cellValue:b.getData()};u.push({id:f.SetRangeValuesMutation.id,params:E});const T=f.SetRangeValuesUndoMutationFactory(i,E);h.push({id:f.SetRangeValuesMutation.id,params:T});const{undos:y,redos:O}=ui(a,c,i);return h.push(...y),u.push(...O),{redos:u,undos:h}}};return[e,n,o,r]}_getWorksheet(i,t){var n;const e=(n=this._currentUniverSheet.getUniverSheetInstance(i))==null?void 0:n.getSheetBySheetId(t);if(!e)throw new Error(`[SheetClipboardController]: cannot find a worksheet with unitId ${i} and subUnitId ${t}.`);return e}};yn=Cc([l.OnLifecycle(l.LifecycleStages.Steady,yn),Ue(0,P.Inject(P.Injector)),Ue(1,l.IUniverInstanceService),Ue(2,l.ICommandService),Ue(3,l.IContextService),Ue(4,l.IConfigService),Ue(5,pt),Ue(6,C.IClipboardInterfaceService),Ue(7,C.IMessageService),Ue(8,P.Inject(A.SheetSkeletonManagerService)),Ue(9,P.Inject(l.LocaleService)),Ue(10,P.Optional(w.ITextSelectionRenderManager))],yn);var Ic=Object.defineProperty,Mc=Object.getOwnPropertyDescriptor,Rc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Mc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Ic(t,e,o),o},Zt=(i,t)=>(e,n)=>t(e,n,i);let On=class extends l.Disposable{constructor(i,t,e,n,o){super(),this._currentUniverService=i,this._contextMenuService=t,this._renderManagerService=e,this._selectionManagerService=n,this._selectionRenderService=o,this._currentUniverService.currentSheet$.subscribe(r=>{if(r==null)throw new Error("workbook is null");this._addListeners()})}_addListeners(){const i=Ie(this._currentUniverService,this._renderManagerService);if(!i)return;const t=i.spreadsheet.onPointerDownObserver,e=t.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 g=a.offsetX,_=a.offsetY;switch(u){case l.RANGE_TYPE.ROW:return h.startY<=_&&h.endY>=_;case l.RANGE_TYPE.COLUMN:return h.startX<=g&&h.endX>=g;default:return h.startX<=g&&h.endX>=g&&h.startY<=_&&h.endY>=_}},S=g=>{this._contextMenuService.triggerContextMenu(a,g)};m()?u===l.RANGE_TYPE.COLUMN?S(he.COL_HEADER_CONTEXT_MENU):u===l.RANGE_TYPE.ROW?S(he.ROW_HEADER_CONTEXT_MENU):S(C.MenuPosition.CONTEXT_MENU):S(C.MenuPosition.CONTEXT_MENU)}});this.disposeWithMe(l.toDisposable(()=>t.remove(e)));const o=i.spreadsheetRowHeader.onPointerDownObserver.add(a=>{a.button===2&&this._contextMenuService.triggerContextMenu(a,he.ROW_HEADER_CONTEXT_MENU)});this.disposeWithMe(l.toDisposable(()=>t.remove(o)));const s=i.spreadsheetColumnHeader.onPointerDownObserver.add(a=>{a.button===2&&this._contextMenuService.triggerContextMenu(a,he.COL_HEADER_CONTEXT_MENU)});this.disposeWithMe(l.toDisposable(()=>t.remove(s)))}};On=Rc([l.OnLifecycle(l.LifecycleStages.Rendered,On),Zt(0,l.IUniverInstanceService),Zt(1,C.IContextMenuService),Zt(2,w.IRenderManagerService),Zt(3,P.Inject(f.SelectionManagerService)),Zt(4,fe)],On);var bc=Object.defineProperty,wc=Object.getOwnPropertyDescriptor,Tc=(i,t,e,n)=>{for(var o=n>1?void 0:n?wc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&bc(t,e,o),o},Ui=(i,t)=>(e,n)=>t(e,n,i);let An=class extends l.RxDisposable{constructor(i,t,e){super(),this._currentUniverService=i,this._renderManagerService=t,this._undoRedoService=e,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialNormalInput(),this._listenEditorBlur()}_listenEditorBlur(){this._currentUniverService.currentDoc$.pipe(k.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(t=>{const e=t.getConfig();i[t.getSheetId()]={cellData:new l.ObjectMatrix(e.cellData),rowCount:e.rowCount,columnCount:e.columnCount,rowData:e.rowData,columnData:e.columnData}})}_commandExecutedListener(){}_getDocObject(){return te.getDocObject(this._currentUniverService,this._renderManagerService)}};An=Tc([l.OnLifecycle(l.LifecycleStages.Rendered,An),Ui(0,l.IUniverInstanceService),Ui(1,w.IRenderManagerService),Ui(2,P.Inject(l.IUndoRedoService))],An);const pr=[C.KeyCode.ARROW_DOWN,C.KeyCode.ARROW_UP,C.KeyCode.ARROW_LEFT,C.KeyCode.ARROW_RIGHT],Ec=[C.KeyCode.ENTER,C.KeyCode.TAB,...pr];function yc(){const i=[];for(const t of pr)i.push({id:Ft.id,binding:t,preconditions:e=>_n(e),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:t,isShift:!1}}),i.push({id:Ft.id,binding:t|C.MetaKeys.SHIFT,preconditions:e=>_n(e),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:t,isShift:!0}});return i}const Oc={id:Ii.id,binding:C.KeyCode.F2,description:"shortcut.sheet.start-editing",group:"4_sheet-edit",preconditions:ie,staticParameters:{visible:!0,eventType:w.DeviceInputEventType.Keyboard,keycode:C.KeyCode.F2}},Ac={id:Te.id,binding:C.KeyCode.ENTER,description:"shortcut.sheet.toggle-editing",group:"4_sheet-edit",preconditions:i=>_n(i),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:C.KeyCode.ENTER}},xc={id:Te.id,binding:C.KeyCode.TAB,preconditions:i=>_n(i),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:C.KeyCode.TAB}},Nc={id:Te.id,binding:C.KeyCode.ESC,description:"shortcut.sheet.abort-editing",group:"4_sheet-edit",preconditions:i=>Co(i),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:C.KeyCode.ESC}},Dc={id:te.BreakLineCommand.id,description:"shortcut.sheet.break-line",group:"4_sheet-edit",preconditions:i=>Co(i),binding:C.KeyCode.ENTER|C.MetaKeys.ALT},Pc={id:te.DeleteLeftCommand.id,preconditions:i=>Hs(i)||Io(i),binding:C.KeyCode.BACKSPACE},Lc={id:Te.id,description:"shortcut.sheet.delete-and-start-editing",group:"4_sheet-edit",preconditions:i=>ie(i)&&!Io(i),binding:C.KeyCode.BACKSPACE,staticParameters:{visible:!0,eventType:w.DeviceInputEventType.Keyboard,keycode:C.KeyCode.BACKSPACE}};var Uc=Object.defineProperty,Hc=Object.getOwnPropertyDescriptor,Vc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Hc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Uc(t,e,o),o},Fe=(i,t)=>(e,n)=>t(e,n,i);function kc(i){const{textRuns:t=[],paragraphs:e=[]}=i;return t.some(n=>n.ts&&!l.Tools.isEmptyObject(n.ts))||e.some(n=>n.bullet)||e.length>=2}let xn=class extends l.Disposable{constructor(t,e,n,o,r,s,a,c,d,u){super();I(this,"_cursorChangeObservers");I(this,"_editorVisiblePrevious",!1);I(this,"_cursorChange",0);this._currentUniverService=t,this._renderManagerService=e,this._commandService=n,this._editorBridgeService=o,this._contextService=r,this._cellEditorManagerService=s,this._lexerTreeBuilder=a,this._undoRedoService=c,this._selectionManagerService=d,this._editorService=u,this._initialize(),this._commandExecutedListener()}dispose(){const t=this._getEditorObject();if(t==null)return;const{document:e}=t;e.onPointerDownObserver.remove(this._cursorChangeObservers),super.dispose()}_initialize(){this._initialExitInput(),this._cursorStateListener()}_initialExitInput(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(async t=>{const{visible:e,keycode:n,eventType:o}=t;if(e===this._editorVisiblePrevious)return;if(this._editorVisiblePrevious=e,e===!0){this._cursorChange=o===w.DeviceInputEventType.PointerDown?2:1;return}this._cursorChange=0;const r=this._selectionManagerService.getSelections(),s=this._selectionManagerService.getCurrent();if(s==null)return;const{unitId:a,sheetId:c,pluginName:d}=s;if(this._exitInput(t),n===C.KeyCode.ESC){r&&this._commandService.syncExecuteCommand(f.SetSelectionsOperation.id,{unitId:a,subUnitId:c,pluginName:d,selections:r});return}const u=this._editorBridgeService.getEditCellState();if(u==null)return;const{unitId:h,sheetId:m,row:S,column:g,documentLayoutObject:_}=u;if(this._editorBridgeService.getEditorDirty()===!1){this._moveCursor(n);return}const M=this._currentUniverService.getUniverSheetInstance(h),R=M==null?void 0:M.getSheetBySheetId(m);if(R==null)return;const b=Bc(R.getCellRaw(S,g)||{},_,this._lexerTreeBuilder);if(b==null){this._moveCursor(n);return}const E={subUnitId:m,unitId:h,workbook:M,worksheet:R,row:S,col:g};a===h&&m!==c&&this._editorBridgeService.isForceKeepVisible()&&this._commandService.executeCommand(f.SetWorksheetActivateCommand.id,{subUnitId:m,unitId:h}),this._selectionManagerService.refreshSelection();const T=this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT)(b,E),y=await this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT_ASYNC)(Promise.resolve(T),E);this._commandService.executeCommand(f.SetRangeValuesCommand.id,{subUnitId:m,unitId:h,range:{startRow:S,startColumn:g,endRow:S,endColumn:g},value:y}),this._moveCursor(n)}))}_exitInput(t){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:t.visible});const e=this._editorBridgeService.getCurrentEditorId();e==null||!this._editorService.isSheetEditor(e)||(this._undoRedoService.clearUndoRedo(e),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))}_moveCursor(t){if(t==null||!Ec.includes(t))return;let e=l.Direction.LEFT;switch(t){case C.KeyCode.ENTER:e=l.Direction.DOWN;break;case C.KeyCode.TAB:e=l.Direction.RIGHT;break;case C.KeyCode.ARROW_DOWN:e=l.Direction.DOWN;break;case C.KeyCode.ARROW_UP:e=l.Direction.UP;break;case C.KeyCode.ARROW_LEFT:e=l.Direction.LEFT;break;case C.KeyCode.ARROW_RIGHT:e=l.Direction.RIGHT;break}t===C.KeyCode.ENTER||t===C.KeyCode.TAB?this._commandService.executeCommand(lt.id,{keycode:t,direction:e}):this._commandService.executeCommand(be.id,{direction:e})}_cursorStateListener(){const t=this._getEditorObject();if(t==null)return;const{document:e}=t;this.disposeWithMe(l.toDisposable(e.onPointerDownObserver.add(()=>{this._cursorChange===1&&(this._cursorChange=2)})))}_commandExecutedListener(){const t=[Ft.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(t.includes(e.id)){const n=e.params,{keycode:o,isShift:r}=n;if(o!=null&&(this._cursorChange===2||this._contextService.getContextValue(l.FOCUSING_FORMULA_EDITOR))){this._moveInEditor(o,r);return}this._editorBridgeService.changeVisible(n)}e.id===Ii.id&&(this._cursorChange=2)}))}_moveInEditor(t,e){let n=l.Direction.LEFT;t===C.KeyCode.ARROW_DOWN?n=l.Direction.DOWN:t===C.KeyCode.ARROW_UP?n=l.Direction.UP:t===C.KeyCode.ARROW_RIGHT&&(n=l.Direction.RIGHT),e?this._commandService.executeCommand(te.MoveSelectionOperation.id,{direction:n}):this._commandService.executeCommand(te.MoveCursorOperation.id,{direction:n})}_getEditorObject(){return hn(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};xn=Vc([l.OnLifecycle(l.LifecycleStages.Rendered,xn),Fe(0,l.IUniverInstanceService),Fe(1,w.IRenderManagerService),Fe(2,l.ICommandService),Fe(3,we),Fe(4,l.IContextService),Fe(5,Xt),Fe(6,P.Inject(K.LexerTreeBuilder)),Fe(7,l.IUndoRedoService),Fe(8,P.Inject(f.SelectionManagerService)),Fe(9,C.IEditorService)],xn);function Bc(i,t,e){i=l.Tools.deepClone(i);const{documentModel:n}=t;if(n==null)return null;const o=n.getSnapshot(),{body:r}=o;if(r==null)return null;i.t=void 0;const s=r.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=e.checkIfAddBracket(c);for(let u=0;u<d;u++)c+=K.matchToken.CLOSE_BRACKET;i.f=c,i.v=null,i.p=null}else if(kc(r))r.dataStream===`\r
|
|
19
|
+
`?(i.v="",i.f=null,i.si=null,i.p=null):(i.p=o,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 Fc=Object.defineProperty,Wc=Object.getOwnPropertyDescriptor,jc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Wc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Fc(t,e,o),o},We=(i,t)=>(e,n)=>t(e,n,i);let Nn=class extends l.RxDisposable{constructor(t,e,n,o,r,s,a,c,d,u){super();I(this,"_loadedMap",new WeakSet);this._univerInstanceService=t,this._renderManagerService=e,this._editorBridgeService=n,this._commandService=o,this._contextService=r,this._formulaEditorManagerService=s,this._undoRedoService=a,this._docSkeletonManagerService=c,this._docViewModelManagerService=d,this._textSelectionManagerService=u,this._initialize()}_initialize(){this._syncFormulaEditorContent(),this._commandExecutedListener(),this._syncEditorSize(),this._listenFxBtnClick(),this._listenFoldBtnClick(),this._renderManagerService.currentRender$.pipe(k.takeUntil(this.dispose$)).subscribe(t=>{this._create(t)}),this._create(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._textSelectionManagerService.textSelection$.pipe(k.takeUntil(this.dispose$)).subscribe(t=>{if(t==null)return;const{unitId:e}=t;e!==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))})}_create(t){if(t!==l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)return;const e=this._renderManagerService.getRenderById(t);if(e==null)return;const{mainComponent:n}=e;n!=null&&(this._loadedMap.has(n)||(this._initialMain(t),this._loadedMap.add(n)))}_listenFxBtnClick(){this._formulaEditorManagerService.fxBtnClick$.pipe(k.takeUntil(this.dispose$)).subscribe(()=>{var e;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:w.DeviceInputEventType.PointerDown});const r=(e=n==null?void 0:n.getBody())==null?void 0:e.dataStream;if(r==null)return;let s=r.startsWith("=")?r:`=${r}`;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(te.CoverContentCommand.id,c),this._textSelectionManagerService.replaceTextRanges(a)}})}_listenFoldBtnClick(){this._formulaEditorManagerService.foldBtnStatus$.pipe(k.takeUntil(this.dispose$)).subscribe(()=>{this._textSelectionManagerService.refreshSelection()})}_initialMain(t){const e=this._renderManagerService.getRenderById(t);if(e==null)return;const{mainComponent:n}=e;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:w.DeviceInputEventType.Dblclick})})))}_syncEditorSize(){this._formulaEditorManagerService.position$.pipe(k.takeUntil(this.dispose$)).subscribe(t=>{if(t==null)return;const e=hn(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,this._renderManagerService),n=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(e==null||n==null)return;const{width:o,height:r}=t,{engine:s}=e;n.updateDocumentDataPageSize(o),this._autoScroll(),requestIdleCallback(()=>{s.resizeBySize(o,r)})})}_syncFormulaEditorContent(){this._editorBridgeService.currentEditCellState$.pipe(k.takeUntil(this.dispose$)).subscribe(t=>{t==null||this._editorBridgeService.isForceKeepVisible()||this._editorSyncHandler(t)}),this._editorBridgeService.visible$.pipe(k.takeUntil(this.dispose$)).subscribe(t=>{if(t==null||t.visible===!1||this._editorBridgeService.isForceKeepVisible())return;const e=this._editorBridgeService.getLatestEditCellState();e!=null&&this._editorSyncHandler(e)})}_editorSyncHandler(t){var s;const e=(s=t.documentLayoutObject.documentModel)==null?void 0:s.getBody();let n=e==null?void 0:e.dataStream,o=e==null?void 0:e.paragraphs,r=[];n==null||o==null||(t.isInArrayFormulaRange===!0&&this._editorBridgeService.isVisible().eventType===w.DeviceInputEventType.Dblclick?(n=`\r
|
|
20
|
+
`,o=[{startIndex:0}]):t.isInArrayFormulaRange===!0&&(r=(e==null?void 0:e.textRuns)||[]),this._syncContentAndRender(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,n,o,r),this._autoScroll())}_commandExecutedListener(){const t=[te.RichTextEditingMutation.id,C.SetEditorResizeOperation.id],e=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(o=>{var r,s;if(t.includes(o.id)){const a=o.params,{unitId:c}=a;if(e.includes(c)){const d=this._univerInstanceService.getUniverDocInstance(c),u=(r=d==null?void 0:d.getBody())==null?void 0:r.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=[f.SetRangeValuesMutation.id,f.MoveRangeMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(o=>{var r,s,a,c,d;if(n.includes(o.id)){const u=this._editorBridgeService.getLatestEditCellState();if(u==null)return;let h=!1;const{row:m,column:S}=u;if(o.id===f.SetRangeValuesMutation.id&&o.params?(s=(r=o.params.cellValue)==null?void 0:r[m])!=null&&s[S]&&(h=!0):o.id===f.MoveRangeMutation.id&&o.params&&(c=(a=o.params.to.value)==null?void 0:a[m])!=null&&c[S]&&(h=!0),h){const g=(d=u.documentLayoutObject.documentModel)==null?void 0:d.getBody();if(g==null)return;const{dataStream:_,paragraphs:v=[]}=g;this._syncContentAndRender(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,_,v),this._autoScroll()}}}))}_syncContentAndRender(t,e,n,o=[]){var h;const r=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=this._docSkeletonManagerService.getSkeletonByUnitId(t),a=this._univerInstanceService.getUniverDocInstance(t),c=this._docViewModelManagerService.getViewModel(t);if(a==null||c==null||s==null)return;a.getBody().dataStream=e,a.getBody().paragraphs=this._clearParagraph(n),t===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(a.getBody().textRuns=[]),o.length>0&&(a.getBody().textRuns=o),c.reset(a);const{skeleton:d}=s,u=this._renderManagerService.getRenderById(t);u!=null&&(d.calculate(),r.includes(t)&&((h=u.mainComponent)==null||h.makeDirty()))}_clearParagraph(t){const e=l.Tools.deepClone(t);for(const n of e)n.paragraphStyle&&(n.paragraphStyle.horizontalAlign=l.HorizontalAlign.UNSPECIFIED);return e}_autoScroll(){var g,_;const t=(g=this._docSkeletonManagerService.getSkeletonByUnitId(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))==null?void 0:g.skeleton,e=this._formulaEditorManagerService.getPosition(),n=this._renderManagerService.getRenderById(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),o=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(t==null||e==null||n==null||o==null)return;const{marginTop:r=0,marginBottom:s=0}=o.getSnapshot().documentStyle,{scene:a,mainComponent:c}=n;let{actualHeight:d}=t.getActualSize();d+=r+s;const{width:u,height:h}=e,m=a.getViewport(te.VIEWPORT_KEY.VIEW_MAIN);let S=m==null?void 0:m.getScrollBar();a.transformByState({width:u,height:d}),c==null||c.resize(u,d),d>h?S==null?m&&new w.ScrollBar(m,{enableHorizontal:!1,barSize:8}):m==null||m.resetSizeAndScrollBar():(S=null,m==null||m.scrollTo({x:0,y:0}),(_=m==null?void 0:m.getScrollBar())==null||_.dispose())}};Nn=jc([l.OnLifecycle(l.LifecycleStages.Steady,Nn),We(0,l.IUniverInstanceService),We(1,w.IRenderManagerService),We(2,we),We(3,l.ICommandService),We(4,l.IContextService),We(5,wn),We(6,l.IUndoRedoService),We(7,P.Inject(te.DocSkeletonManagerService)),We(8,P.Inject(te.DocViewModelManagerService)),We(9,P.Inject(te.TextSelectionManagerService))],Nn);const vr={sheetFooterBarHeight:"36",sheetContainer:"univer-sheet-container"};var zc=Object.defineProperty,Yc=Object.getOwnPropertyDescriptor,Xc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Yc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&zc(t,e,o),o},ye=(i,t)=>(e,n)=>t(e,n,i);const Cr=-1e3,Ir=5,$c=2;let Dn=class extends l.Disposable{constructor(t,e,n,o,r,s,a,c,d,u,h,m){super();I(this,"_editorVisiblePrevious",!1);this._docSkeletonManagerService=t,this._docViewModelManagerService=e,this._contextService=n,this._currentUniverService=o,this._renderManagerService=r,this._editorBridgeService=s,this._cellEditorManagerService=a,this._textSelectionRenderManager=c,this._textSelectionManagerService=d,this._commandService=u,this._localService=h,this._editorService=m,this._initialize(),this._commandExecutedListener()}dispose(){super.dispose()}_initialize(){this._initialEditFocusListener(),this._initialStartEdit(),this._initialKeyboardListener(),this._initialCursorSync(),this._listenEditorFocus()}_listenEditorFocus(){const t=this._getEditorObject();t!=null&&this.disposeWithMe(l.toDisposable(t.document.onPointerDownObserver.add(()=>{var e;if(this._editorBridgeService.isVisible()){const n=this._editorBridgeService.getEditCellState(),o=this._editorBridgeService.getCurrentEditorId();if(n==null||o==null||!this._editorService.isSheetEditor(o))return;const r=(e=this._docSkeletonManagerService.getSkeletonByUnitId(o))==null?void 0:e.skeleton;if(r==null)return;const{position:s,documentLayoutObject:a,canvasOffset:c,scaleX:d,scaleY:u}=n;this._fitTextSize(s,c,r,a,d,u)}})))}_initialCursorSync(){this.disposeWithMe(this._cellEditorManagerService.focus$.pipe(k.filter(t=>!!t)).subscribe(()=>{this._textSelectionRenderManager.sync()}))}_initialEditFocusListener(){this.disposeWithMe(this._editorBridgeService.currentEditCellState$.subscribe(t=>{if(t==null||this._editorBridgeService.isForceKeepVisible())return;const{position:e,documentLayoutObject:n,scaleX:o,editorUnitId:r}=t;if(this._getEditorObject()==null)return;const{startX:a,endX:c}=e,{textRotation:d,wrapStrategy:u,documentModel:h}=n,{vertexAngle:m}=w.convertTextRotation(d);h.updateDocumentId(r),u===l.WrapStrategy.WRAP&&m===0&&h.updateDocumentDataPageSize((c-a)/o),this._currentUniverService.changeDoc(r,h),this._contextService.setContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN,!0),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}]),this._textSelectionRenderManager.activate(Cr,Cr)}))}_fitTextSize(t,e,n,o,r=1,s=1){const{startX:a,startY:c,endX:d,endY:u}=t,h=o.documentModel;if(h==null)return;const{actualWidth:m,actualHeight:S}=this._predictingSize(t,e,n,o,r,s),{verticalAlign:g,paddingData:_,fill:v}=o;let M=d-a,R=u-c;if(M<m&&(M=m),R<S)R=S,h.updateDocumentDataMargin(_);else{let b=R-S||0;g===l.VerticalAlign.MIDDLE?b=(R-S)/2:g===l.VerticalAlign.TOP&&(b=_.t||0),b/=s,b=b<(_.t||0)?_.t||0:b,h.updateDocumentDataMargin({t:b})}n.calculate(),this._editAreaProcessing(M,R,t,e,v,r,s)}_predictingSize(t,e,n,o,r=1,s=1){const{startX:a,endX:c}=t,{textRotation:d,wrapStrategy:u}=o,h=o.documentModel,{vertexAngle:m}=w.convertTextRotation(d),S=document.body.clientWidth;if(u===l.WrapStrategy.WRAP&&m===0){const{actualWidth:v,actualHeight:M}=n.getActualSize();return{actualWidth:v*r,actualHeight:M*s}}h==null||h.updateDocumentDataPageSize((S-a-e.left)/r),n.calculate();const g=n.getActualSize();let _=c-a;return _<g.actualWidth*r+Ir*r&&(_=g.actualWidth*r+Ir*r),h==null||h.updateDocumentDataPageSize(_/r),h==null||h.updateDocumentRenderConfig({horizontalAlign:l.HorizontalAlign.UNSPECIFIED,cellValueType:void 0}),{actualWidth:_,actualHeight:g.actualHeight*s}}_editAreaProcessing(t,e,n,o,r,s=1,a=1){var T;const c=this._getEditorObject();if(c==null)return;let{startX:d,startY:u}=n;const{document:h,scene:m,engine:S}=c,g=m.getViewport(te.VIEWPORT_KEY.VIEW_MAIN),_=document.body.clientHeight-u-Number.parseFloat(vr.sheetFooterBarHeight)-o.top-$c*2,v=document.body.clientWidth-d-o.left;let M=e,R=g==null?void 0:g.getScrollBar();M>_?(M=_,R==null?g&&new w.ScrollBar(g,{enableHorizontal:!1,barSize:8}):g==null||g.resetSizeAndScrollBar()):(R=null,(T=g==null?void 0:g.getScrollBar())==null||T.dispose()),t+=(R==null?void 0:R.barSize)||0,t>v&&(t=v),d-=w.FIX_ONE_PIXEL_BLUR_OFFSET,u-=w.FIX_ONE_PIXEL_BLUR_OFFSET,this._addBackground(m,t/s,e/a,r);const{scaleX:b,scaleY:E}=m.getPrecisionScale();m.transformByState({width:t/s,height:e/a,scaleX:s,scaleY:a}),h.resize(t/s,e/a),requestIdleCallback(()=>{S.resizeBySize(w.fixLineWidthByScale(t,b),w.fixLineWidthByScale(M,E))}),this._cellEditorManagerService.setState({startX:d,startY:u,endX:t+d,endY:M+u,show:!0})}_addBackground(t,e,n,o){const r="_backgroundRectHelperColor_",s=t.getObject(r);s==null&&o==null||(s==null?t.addObjects([new w.Rect(r,{width:e,height:n,fill:o,evented:!1})],te.DOCS_COMPONENT_MAIN_LAYER_INDEX):o==null?s.dispose():(s.setProps({fill:o}),s.transformByState({width:e,height:n})))}_initialStartEdit(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{var T,y;const{visible:e,eventType:n,keycode:o}=t;if(e===this._editorVisiblePrevious)return;if(this._editorVisiblePrevious=e,e===!1){this._setOpenForCurrent(null,null);return}const r=this._editorBridgeService.getEditCellState();if(r==null)return;const{position:s,documentLayoutObject:a,canvasOffset:c,scaleX:d,scaleY:u,editorUnitId:h,unitId:m,sheetId:S,isInArrayFormulaRange:g=!1}=r,_=this._getEditorObject();if(_==null)return;this._setOpenForCurrent(m,S);const{document:v,scene:M}=_;this._contextService.setContextValue(l.EDITOR_ACTIVATED,!0);const{documentModel:R}=a,b=this._docSkeletonManagerService.getSkeletonByUnitId(h);if(b==null||R==null)return;const{skeleton:E}=b;if(this._fitTextSize(s,c,E,a,d,u),n===w.DeviceInputEventType.Keyboard||n===w.DeviceInputEventType.Dblclick&&g){const O=l.Tools.deepClone(R.snapshot),x=this._docViewModelManagerService.getViewModel(h);if(x==null)return;this._resetBodyStyle(O.body,!!g),R.reset(O),x.reset(R),v.makeDirty(),(o===C.KeyCode.BACKSPACE||n===w.DeviceInputEventType.Dblclick)&&(E.calculate(),this._editorBridgeService.changeEditorDirty(!0)),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}])}else if(n===w.DeviceInputEventType.Dblclick){const O=R.getBody().dataStream.length-2||0;(T=M.getViewport(te.VIEWPORT_KEY.VIEW_MAIN))==null||T.scrollTo({y:Number.POSITIVE_INFINITY}),this._textSelectionManagerService.replaceTextRanges([{startOffset:O,endOffset:O}])}(y=this._renderManagerService.getRenderById(m))==null||y.scene.resetCursor()}))}_resetBodyStyle(t,e=!1){t.dataStream=l.DEFAULT_EMPTY_DOCUMENT_VALUE,t.textRuns!=null&&(t.textRuns.length===1&&!e?(t.textRuns[0].st=0,t.textRuns[0].ed=1):t.textRuns=void 0),t.paragraphs!=null&&(t.paragraphs.length===1?t.paragraphs[0].startIndex=0:t.paragraphs=[{startIndex:0}]),t.sectionBreaks!=null&&(t.sectionBreaks=void 0),t.tables!=null&&(t.tables=void 0),t.customRanges!=null&&(t.customRanges=void 0),t.customBlocks!=null&&(t.customBlocks=void 0)}_initialKeyboardListener(){this.disposeWithMe(this._textSelectionRenderManager.onInputBefore$.subscribe(t=>{const e=this._contextService.getContextValue(l.FOCUSING_FORMULA_EDITOR),n=this._contextService.getContextValue(l.FOCUSING_SHEET),o=this._currentUniverService.getCurrentUniverDocInstance().getUnitId();n&&!e&&this._editorService.isSheetEditor(o)&&this._showEditorByKeyboard(t)}))}_showEditorByKeyboard(t){if(t==null)return;const e=t.event;this._commandService.executeCommand(Te.id,{visible:!0,eventType:w.DeviceInputEventType.Keyboard,keycode:e.which})}_commandExecutedListener(){const t=[te.RichTextEditingMutation.id,C.SetEditorResizeOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var n;if(t.includes(e.id)){const o=e.params,{unitId:r}=o;if(!this._editorService.isSheetEditor(r))return;const s=this._editorBridgeService.getCurrentEditorId();if(s==null)return;this._editorBridgeService.changeEditorDirty(!0);const a=(n=this._docSkeletonManagerService.getSkeletonByUnitId(s))==null?void 0:n.skeleton;if(a==null)return;const c=this._editorBridgeService.getEditCellState();if(c==null)return;const{position:d,documentLayoutObject:u,canvasOffset:h,scaleX:m,scaleY:S}=c;this._fitTextSize(d,h,a,u,m,S)}}))}_setOpenForCurrent(t,e){const n=this._editorService.getAllEditor();for(const[o,r]of n)r.isSheetEditor()&&(r.setOpenForSheetUnitId(t),r.setOpenForSheetSubUnitId(e))}_getEditorObject(){return hn(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};Dn=Xc([l.OnLifecycle(l.LifecycleStages.Rendered,Dn),ye(0,P.Inject(te.DocSkeletonManagerService)),ye(1,P.Inject(te.DocViewModelManagerService)),ye(2,l.IContextService),ye(3,l.IUniverInstanceService),ye(4,w.IRenderManagerService),ye(5,we),ye(6,Xt),ye(7,w.ITextSelectionRenderManager),ye(8,P.Inject(te.TextSelectionManagerService)),ye(9,l.ICommandService),ye(10,P.Inject(l.LocaleService)),ye(11,C.IEditorService)],Dn);const Pn={id:"sheet.command.change-zoom-ratio",type:l.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const{delta:e,reset:n}=t,o=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),r=o.getActiveSheet(),s=o.getUnitId(),a=r.getSheetId();let c=n?100:Math.round((r.getConfig().zoomRatio+e)*100);c=Math.max(ci[0],c),c=Math.min(ci[1],c);const d=c/100;return i.get(l.ICommandService).executeCommand(Pe.id,{unitId:s,subUnitId:a,zoomRatio:d})}},Ln={id:"sheet.command.set-zoom-ratio",type:l.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const{unitId:e,subUnitId:n,zoomRatio:o}=t;return i.get(l.ICommandService).executeCommand(Pe.id,{unitId:e,subUnitId:n,zoomRatio:o})}},Mr={id:"sheet.operation.set-activate-cell-edit",type:l.CommandType.OPERATION,handler:(i,t)=>(i.get(we).setEditCell(t),!0)};var Zc=Object.defineProperty,Gc=Object.getOwnPropertyDescriptor,Kc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Gc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Zc(t,e,o),o},He=(i,t)=>(e,n)=>t(e,n,i);let Un=class extends l.RxDisposable{constructor(i,t,e,n,o,r,s,a,c,d,u){super(),this._injector=i,this._sheetSkeletonManagerService=t,this._currentUniverService=e,this._commandService=n,this._renderManagerService=o,this._editorBridgeService=r,this._layoutService=s,this._editorService=a,this._contextService=c,this._selectionManagerService=d,this._rangeSelectorService=u,this._initialize(),this._commandExecutedListener()}dispose(){}_initialize(){this._initSelectionChangeListener(),this._initialEventListener(),this._initialChangeEditorListener(),this._initialRangeSelector()}_initSelectionChangeListener(){k.merge(this._selectionManagerService.selectionMoveEnd$,this._selectionManagerService.selectionMoveStart$).pipe(k.takeUntil(this.dispose$)).subscribe(i=>this._handleSelectionListener(i))}_handleSelectionListener(i){const t=this._selectionManagerService.getCurrent();if((t==null?void 0:t.pluginName)!==f.NORMAL_SELECTION_PLUGIN_NAME||this._editorBridgeService.isVisible().visible===!0)return;const e=this._injector.get(w.ITextSelectionRenderManager,P.Quantity.OPTIONAL);if(!this._layoutService.checkCanvasIsFocused()&&e&&!e.hasFocus())return;const n=this._sheetSkeletonManagerService.getCurrent();if(n==null||i==null||i.length===0||i[i.length-1]==null)return;const{primary:o}=i[i.length-1];if(o==null)return;const r=this._getSheetObject();if(r==null)return;const{unitId:s,sheetId:a}=n,{scene:c,engine:d}=r;this._commandService.executeCommand(Mr.id,{scene:c,engine:d,primary:o,unitId:s,sheetId:a})}_initialEventListener(){const i=this._getSheetObject();if(i==null)return;const{spreadsheet:t,spreadsheetColumnHeader:e,spreadsheetLeftTopPlaceholder:n,spreadsheetRowHeader:o}=i;t.onDblclickObserver.add(r=>{r.button!==2&&this._commandService.executeCommand(Te.id,{visible:!0,eventType:w.DeviceInputEventType.Dblclick})}),t.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),e.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),n.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),o.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this))}_initialChangeEditorListener(){this.disposeWithMe(this._currentUniverService.currentDoc$.subscribe(i=>{if(i==null)return;const t=i.getUnitId();this._editorService.isEditor(t)&&(this._editorService.isSheetEditor(t)?(this._contextService.setContextValue(l.FOCUSING_DOC,!1),this._contextService.setContextValue(l.FOCUSING_SHEET,!0)):(this._contextService.setContextValue(l.FOCUSING_SHEET,!1),this._contextService.setContextValue(l.FOCUSING_DOC,!0),this._hideEditor()))}))}_keepVisibleHideEditor(){this._editorBridgeService.isForceKeepVisible()||this._hideEditor()}_hideEditor(){this._editorBridgeService.isVisible().visible===!0&&(this._selectionManagerService.makeDirty(!1),this._commandService.executeCommand(Te.id,{visible:!1,eventType:w.DeviceInputEventType.PointerDown}),setTimeout(()=>{this._selectionManagerService.makeDirty(!0)},0))}_initialRangeSelector(){this.disposeWithMe(this._selectionManagerService.selectionMoving$.subscribe(this._rangeSelector.bind(this))),this.disposeWithMe(this._selectionManagerService.selectionMoveStart$.subscribe(this._rangeSelector.bind(this))),this.disposeWithMe(this._rangeSelectorService.openSelector$.subscribe(()=>{const i=this._selectionManagerService.getSelections(),{unitId:t,sheetId:e,sheetName:n}=this._getCurrentUnitIdAndSheetId(),o=i==null?void 0:i.map(r=>({range:r.range,unitId:t,sheetId:e,sheetName:n}));o&&this._rangeSelectorService.selectionChange(o)}))}_rangeSelector(i){if(!i)return;const{unitId:t,sheetId:e,sheetName:n}=this._getCurrentUnitIdAndSheetId(),o=i.map(r=>({range:r.range,unitId:t,sheetId:e,sheetName:n}));this._rangeSelectorService.selectionChange(o)}_getCurrentUnitIdAndSheetId(){const i=this._currentUniverService.getCurrentUniverSheetInstance(),t=i.getActiveSheet();return{unitId:i.getUnitId(),sheetId:t.getSheetId(),sheetName:t.getName()}}_getSheetObject(){return Ie(this._currentUniverService,this._renderManagerService)}_commandExecutedListener(){const i=f.COMMAND_LISTENER_SKELETON_CHANGE;this.disposeWithMe(this._commandService.onCommandExecuted((t,e)=>{e!=null&&e.fromCollab||(t.id===f.SetWorksheetActiveOperation.id?this._keepVisibleHideEditor():i.includes(t.id)&&this._hideEditor())})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{t.id===Ln.id&&this._editorBridgeService.refreshEditCellState()}))}};Un=Kc([l.OnLifecycle(l.LifecycleStages.Rendered,Un),He(0,P.Inject(P.Injector)),He(1,P.Inject(A.SheetSkeletonManagerService)),He(2,l.IUniverInstanceService),He(3,l.ICommandService),He(4,w.IRenderManagerService),He(5,we),He(6,C.ILayoutService),He(7,C.IEditorService),He(8,l.IContextService),He(9,P.Inject(f.SelectionManagerService)),He(10,C.IRangeSelectorService)],Un);var Qc=Object.defineProperty,Jc=Object.getOwnPropertyDescriptor,qc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Jc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Qc(t,e,o),o},Gt=(i,t)=>(e,n)=>t(e,n,i);let Hn=class extends l.Disposable{constructor(i,t,e,n,o){super(),this._commandService=i,this._formatPainterService=t,this._currentUniverService=e,this._renderManagerService=n,this._selectionRenderService=o,this._initialize()}_initialize(){this._commandExecutedListener(),this._bindFormatPainterStatus()}_bindFormatPainterStatus(){this._formatPainterService.status$.subscribe(i=>{const{scene:t}=this._getSheetObject()||{};t&&(i!==Le.OFF?t.setDefaultCursor(w.CURSOR_TYPE.CELL):t.setDefaultCursor(w.CURSOR_TYPE.DEFAULT))})}_commandExecutedListener(){this.disposeWithMe(l.toDisposable(this._selectionRenderService.selectionMoveEnd$.subscribe(i=>{if(this._formatPainterService.getStatus()!==Le.OFF){const{rangeWithCoord:t}=i[i.length-1];this._applyFormatPainter({startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}),this._formatPainterService.getStatus()===Le.ONCE&&this._commandService.executeCommand(Ni.id)}})))}async _applyFormatPainter(i){const{styles:t,merges:e}=this._formatPainterService.getSelectionFormat(),n=this._currentUniverService.getCurrentUniverSheetInstance().getUnitId(),o=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();if(!t)return;const{startRow:r,startColumn:s,endRow:a,endColumn:c}=t.getDataRange(),d=a-r+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((g,_)=>{g.forEach((v,M)=>{const R=_%d+r,b=M%u+s,E=t.getValue(R,b);E&&(h[_][M].s=E)})}),e.forEach(g=>{const _={startRow:g.startRow-r,startColumn:g.startColumn-s,endRow:g.endRow-r,endColumn:g.endColumn-s},v=Math.max(1,Math.floor((i.endRow-i.startRow+1)/d)),M=Math.max(1,Math.floor((i.endColumn-i.startColumn+1)/u));for(let R=0;R<v;R++)for(let b=0;b<M;b++)m.push({startRow:_.startRow+R*d+i.startRow,startColumn:_.startColumn+b*u+i.startColumn,endRow:_.endRow+R*d+i.startRow,endColumn:_.endColumn+b*u+i.startColumn})});const S={subUnitId:o,unitId:n,styleRange:i,styleValues:h,mergeRanges:m};await this._commandService.executeCommand(tr.id,S)}_getSheetObject(){return Ie(this._currentUniverService,this._renderManagerService)}};Hn=qc([l.OnLifecycle(l.LifecycleStages.Rendered,Hn),Gt(0,l.ICommandService),Gt(1,Rt),Gt(2,l.IUniverInstanceService),Gt(3,w.IRenderManagerService),Gt(4,fe)],Hn);var ed=Object.defineProperty,td=Object.getOwnPropertyDescriptor,nd=(i,t,e,n)=>{for(var o=n>1?void 0:n?td(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&ed(t,e,o),o},je=(i,t)=>(e,n)=>t(e,n,i);const id="__SpreadsheetFreezeRowMainName__",od="__SpreadsheetFreezeRowHeaderName__",rd="__SpreadsheetFreezeColumnMainName__",sd="__SpreadsheetFreezeColumnHeaderName__",Hi=4,ad=.01;let Vn=class extends l.Disposable{constructor(t,e,n,o,r,s,a,c,d,u){super();I(this,"_rowFreezeHeaderRect");I(this,"_rowFreezeMainRect");I(this,"_columnFreezeHeaderRect");I(this,"_columnFreezeMainRect");I(this,"_freezeDownObservers",[]);I(this,"_freezeMoveObservers",[]);I(this,"_freezeLeaveObservers",[]);I(this,"_moveObserver");I(this,"_upObserver");I(this,"_changeToRow",-1);I(this,"_changeToColumn",-1);I(this,"_changeToOffsetX",0);I(this,"_changeToOffsetY",0);I(this,"_activeViewport",null);I(this,"_freezeNormalHeaderColor","");I(this,"_freezeNormalMainColor","");I(this,"_freezeActiveColor","");I(this,"_freezeHoverColor","");I(this,"_lastFreeze");this._sheetSkeletonManagerService=t,this._currentUniverService=e,this._commandService=n,this._renderManagerService=o,this._selectionRenderService=r,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(t=0,e){var O;const n=e!=null?e:this._getFreeze();if(n==null)return;const o=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton;if(o==null)return;const{startRow:r,startColumn:s}=n,a=this._getPositionByIndex(r,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:S,startY:g}=a,{rowTotalHeight:_,columnTotalWidth:v,rowHeaderWidthAndMarginLeft:M,columnHeaderHeightAndMarginTop:R}=o,b=u>v+M?u:v+R,E=h>_+R?h:_+R;this._changeToRow=r,this._changeToColumn=s,this._changeToOffsetX=S,this._changeToOffsetY=g;const T=Math.max(m.scaleX,m.scaleY),y=Hi/(T<1?1:T);if(t===0){const x=y;this._rowFreezeHeaderRect=new w.Rect(od,{fill:this._freezeNormalHeaderColor,width:M,height:y,left:0,top:g-x,zIndex:3});let N=this._freezeNormalHeaderColor;(r===-1||r===0)&&(N=this._freezeNormalMainColor),this._rowFreezeMainRect=new w.Rect(id,{fill:N,width:b*2,height:y,left:M,top:g-x,zIndex:3}),m.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],et)}else{const x=y;this._columnFreezeHeaderRect=new w.Rect(sd,{fill:this._freezeNormalHeaderColor,width:y,height:R,left:S-x,top:0,zIndex:3});let N=this._freezeNormalHeaderColor;(s===-1||s===0)&&(N=this._freezeNormalMainColor),this._columnFreezeMainRect=new w.Rect(rd,{fill:N,width:y,height:E*2,left:S-x,top:R,zIndex:3}),m.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],et)}this._eventBinding(t)}_eventBinding(t=0){let e=this._rowFreezeHeaderRect,n=this._rowFreezeMainRect;t===1&&(e=this._columnFreezeHeaderRect,n=this._columnFreezeMainRect);const o=this._getSheetObject();if(o==null)return;const{scene:r}=o;this._freezeMoveObservers.push(e==null?void 0:e.onPointerEnterObserver.add(()=>{e==null||e.setProps({fill:this._freezeHoverColor,zIndex:4}),r.setCursor(w.CURSOR_TYPE.GRAB)})),this._freezeMoveObservers.push(n==null?void 0:n.onPointerEnterObserver.add(()=>{e==null||e.setProps({fill:this._freezeHoverColor,zIndex:4}),r.setCursor(w.CURSOR_TYPE.GRAB)})),this._freezeLeaveObservers.push(e==null?void 0:e.onPointerLeaveObserver.add(()=>{e==null||e.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),r.resetCursor()})),this._freezeLeaveObservers.push(n==null?void 0:n.onPointerLeaveObserver.add(()=>{e==null||e.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),r.resetCursor()})),this._freezeDownObservers.push(e==null?void 0:e.onPointerDownObserver.add(s=>{this._freezeDown(s,e,n,t)})),this._freezeDownObservers.push(n==null?void 0:n.onPointerDownObserver.add(s=>{this._freezeDown(s,e,n,t)}))}_getCurrentLastVisibleRow(){var h,m,S,g;const t=this._getSheetObject();if(t==null)return;const e=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(e==null)return;const n=t.scene,o=Math.max(n.scaleX,n.scaleY),r=this._scrollManagerService.getCurrentScroll(),s=(t.engine.height-e.columnHeaderHeight)/o,a=(m=r==null?void 0:r.sheetViewStartRow)!=null?m:0,c=a===0?-((S=r==null?void 0:r.offsetY)!=null?S:0):e.rowHeightAccumulation[a-1]-((g=r==null?void 0:r.offsetY)!=null?g:0);let d=0,u=!1;for(let _=a,v=e.rowHeightAccumulation.length;_<v;_++)if(e.rowHeightAccumulation[_]-c>s){d=_,u=!0;break}return u||(d=e.rowHeightAccumulation.length-1),d}_getActiveViewport(t){var n;const e=(n=this._getSheetObject())==null?void 0:n.scene.getViewports();return e&&e.find(o=>o.isHit(new w.Vector2(t.offsetX,t.offsetY)))||null}_freezeDown(t,e,n,o=0){var h;const r=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(r==null)return;const s=this._getSheetObject();if(s==null)return;const{scene:a}=s;a.setCursor(w.CURSOR_TYPE.GRABBING),a.disableEvent();const c=this._getCurrentLastVisibleRow(),d=c===void 0?Number.POSITIVE_INFINITY:r.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 b,E,T,y;const S=this._getActiveViewport(m),{startX:g,startY:_,row:v,column:M}=Ct(m.offsetX,m.offsetY,a,r,S||void 0);a.setCursor(w.CURSOR_TYPE.GRABBING);const R=Hi/Math.max(a.scaleX,a.scaleY);o===0?((b=e.transformByState({top:Math.min(_,d)-R/2}))==null||b.setProps({fill:this._freezeActiveColor}),(E=n.transformByState({top:Math.min(_,d)-R/2}))==null||E.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=c===void 0?v:Math.min(v,c),this._changeToOffsetY=Math.min(_,d),this._activeViewport=S):((T=e.transformByState({left:g-R/2}))==null||T.setProps({fill:this._freezeActiveColor}),(y=n.transformByState({left:g-R/2}))==null||y.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=M,this._changeToOffsetX=g,this._activeViewport=S)}),this._upObserver=a.onPointerUpObserver.add(()=>{var x,N;a.resetCursor(),a.enableEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:m,columnHeaderHeightAndMarginTop:S}=r;o===0&&(this._changeToRow===0||this._changeToRow===-1)||o===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(e.setProps({fill:this._freezeNormalHeaderColor}),n.setProps({fill:this._freezeNormalMainColor})):(e==null||e.setProps({fill:this._freezeNormalHeaderColor}),n==null||n.setProps({fill:this._freezeNormalHeaderColor}));const g=Hi/Math.max(a.scaleX,a.scaleY);o===0?(this._changeToRow===0||this._changeToRow===-1)&&(e.transformByState({top:S-g}),n.transformByState({top:S-g})):(this._changeToColumn===0||this._changeToColumn===-1)&&(e.transformByState({left:m-g}),n.transformByState({left:m-g}));const _=this._scrollManagerService.getCurrentScroll()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:v,sheetViewStartColumn:M}=_;if(M==null||v==null)return;const R=this._currentUniverService.getCurrentUniverSheetInstance(),b=R.getActiveSheet(),E=(x=b.getConfig())==null?void 0:x.freeze;let T=(E==null?void 0:E.xSplit)||0,y=(E==null?void 0:E.ySplit)||0;const O=(N=this._activeViewport)==null?void 0:N.viewPortKey;o===0&&(!O||O===F.VIEW_LEFT_TOP||O===F.VIEW_MAIN_LEFT_TOP||O===F.VIEW_MAIN_TOP||O===F.VIEW_ROW_TOP?y=this._changeToRow-(E.startRow-E.ySplit):y=this._changeToRow-v,y=y<0?0:y),o===1&&(!O||O===F.VIEW_LEFT_TOP||O===F.VIEW_MAIN_LEFT_TOP||O===F.VIEW_MAIN_LEFT||O===F.VIEW_COLUMN_LEFT?T=this._changeToColumn-(E.startColumn-E.xSplit):T=this._changeToColumn-M,T=T<0?0:T),this._commandService.executeCommand(f.SetFrozenCommand.id,{startRow:y===0?-1:this._changeToRow,startColumn:T===0?-1:this._changeToColumn,ySplit:y,xSplit:T,unitId:R.getUnitId(),subUnitId:b.getSheetId()})})}_getViewports(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t,n=e.getViewport(F.VIEW_COLUMN_LEFT),o=e.getViewport(F.VIEW_COLUMN_RIGHT),r=e.getViewport(F.VIEW_ROW_TOP),s=e.getViewport(F.VIEW_ROW_BOTTOM),a=e.getViewport(F.VIEW_LEFT_TOP),c=e.getViewport(F.VIEW_MAIN),d=e.getViewport(F.VIEW_MAIN_LEFT_TOP),u=e.getViewport(F.VIEW_MAIN_LEFT),h=e.getViewport(F.VIEW_MAIN_TOP);if(!(n==null||o==null||r==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:o,viewRowTop:r,viewRowBottom:s,viewLeftTop:a}}_bindViewportScroll(){const t=this._getViewports();if(!t)return;const{viewMain:e,viewRowBottom:n,viewColumnRight:o,viewMainLeft:r,viewMainTop:s}=t;this.disposeWithMe(e.onScrollAfterObserver.add(a=>{const{scrollX:c,scrollY:d,actualScrollX:u,actualScrollY:h}=a;n.isActive&&n.updateScroll({scrollY:d,actualScrollY:h}),o.isActive&&o.updateScroll({scrollX:c,actualScrollX:u}),r.isActive&&r.updateScroll({scrollY:d,actualScrollY:h}),s.isActive&&s.updateScroll({scrollX:c,actualScrollX:u})}))}_updateViewport(t=-1,e=-1,n=0,o=0,r=3){var O;const s=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.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:S,viewColumnLeft:g,viewColumnRight:_,viewRowTop:v,viewRowBottom:M,viewLeftTop:R}=d;_.resize({left:a,top:0,height:c,right:0}),M.resize({left:0,top:c,bottom:0,width:a}),R.resize({left:0,top:0,width:a,height:c});let b=!0,E=!0;h.enable(),(t===-1||t===0)&&(b=!1),(e===-1||e===0)&&(E=!1);const T=s.getNoMergeCellPositionByIndexWithNoHeader(t-n,e-o),y=s.getNoMergeCellPositionByIndexWithNoHeader(t,e);if(h.disable(),S.disable(),m.disable(),v.disable(),g.disable(),h.resetPadding(),S.resetPadding(),m.resetPadding(),v.resetPadding(),g.resetPadding(),b===!1&&E===!1)u.resize({left:a,top:c,bottom:0,right:0}),u.resetPadding();else if(b===!0&&E===!1){const x=y.startY-T.startY;u.resize({left:a,top:c+x,bottom:0,right:0}),u.setPadding({startY:T.startY,endY:y.startY,startX:0,endX:0}),r&2&&this._commandService.executeCommand(ct.id,{sheetViewStartRow:0,offsetY:0}),S.resize({left:a,top:c,height:x,right:0}),S.updateScroll({actualScrollY:T.startY,x:u.scrollX,actualScrollX:u.actualScrollX}),v.resize({left:0,top:c,width:a,height:x}),v.updateScroll({actualScrollY:T.startY}),M.resize({left:0,top:c+x,bottom:0,width:a}),S.enable(),v.enable()}else if(b===!1&&E===!0){const x=y.startX-T.startX;u.resize({left:a+x,top:c,bottom:0,right:0}),u.setPadding({startX:T.startX,endX:y.startX,startY:0,endY:0}),r&1&&this._commandService.executeCommand(ct.id,{sheetViewStartColumn:0,offsetX:0}),m.resize({left:a,top:c,width:x,bottom:0,right:0}),m.updateScroll({actualScrollX:T.startX,y:u.scrollY,actualScrollY:u.actualScrollY}),g.resize({left:a,top:0,width:x,height:c}),g.updateScroll({actualScrollX:T.startX}),_.resize({left:a+x,top:0,height:c,right:0}),m.enable(),g.enable()}else{const x=y.startX-T.startX,N=y.startY-T.startY;u.resize({left:a+x,top:c+N,bottom:0,right:0}),u.setPadding({startY:T.startY,endY:y.startY,startX:T.startX,endX:y.startX}),r&&this._commandService.executeCommand(ct.id,{...r&1?{sheetViewStartColumn:0,offsetX:0}:null,...r&2?{sheetViewStartRow:0,offsetY:0}:null}),m.resize({left:a,top:c+N,width:x,bottom:0}),m.updateScroll({actualScrollX:T.startX,y:u.scrollY,actualScrollY:u.actualScrollY}),S.resize({left:a+x,top:c,height:N,right:0}),S.updateScroll({actualScrollY:T.startY,x:u.scrollX,actualScrollX:u.actualScrollX}),h.resize({left:a,top:c,width:x,height:N}),h.updateScroll({actualScrollX:T.startX,actualScrollY:T.startY}),v.resize({left:0,top:c,width:a,height:N}),v.updateScroll({actualScrollY:T.startY}),M.resize({left:0,top:c+N,bottom:0,width:a}),g.resize({left:a,top:0,width:x,height:c}),g.updateScroll({actualScrollX:T.startX}),_.resize({left:a+x,top:0,height:c,right:0}),h.enable(),S.enable(),m.enable(),v.enable(),g.enable()}}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(t=>{[f.SetWorksheetActiveOperation.id,f.InsertRangeMoveDownCommand.id,f.InsertRangeMoveRightCommand.id].includes((t==null?void 0:t.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const n=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getConfig().freeze,{startRow:o=-1,startColumn:r=-1,ySplit:s=0,xSplit:a=0}=n;this._refreshFreeze(o,r,s,a,0)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(l.toDisposable(this._themeService.currentTheme$.subscribe(t=>{this._clearFreeze(),this._themeChange(t),this._refreshCurrent()})))}_themeChange(t){this._freezeNormalHeaderColor=t.grey400,this._freezeNormalMainColor=new l.ColorKit(t.grey400).setAlpha(ad).toRgbString(),this._freezeActiveColor=t.primaryColor,this._freezeHoverColor=t.grey500}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:t=>{const e={redos:[],undos:[]},n=this._getFreeze();if(!n)return e;const o=r=>{const s=this._currentUniverService.getCurrentUniverSheetInstance(),a=s.getUnitId(),d=s.getActiveSheet().getSheetId();this._refreshFreeze(r.startRow,r.startColumn,r.ySplit,r.xSplit,0);const u={...r,unitId:a,subUnitId:d,resetScroll:!1},h=f.SetFrozenMutationFactory(this._injector,u);return{undos:[{id:f.SetFrozenMutation.id,params:h}],redos:[{id:f.SetFrozenMutation.id,params:u}]}};if(t.id===f.InsertRowCommand.id){const s=t.params.range,a=s.endRow-s.startRow+1;if(s.startRow<=n.startRow){const c={...n,startRow:Math.max(1,n.startRow+a),ySplit:Math.max(1,n.ySplit+a)};return o(c)}}if(t.id===f.InsertColCommand.id){const s=t.params.range,a=s.endColumn-s.startColumn+1;if(s.startColumn<=n.startColumn){const c={...n,startColumn:Math.max(1,n.startColumn+a),xSplit:Math.max(1,n.xSplit+a)};return o(c)}}if(t.id===f.MoveColsCommand.id){const r=this._selectionManagerService.getSelections(),{fromRange:{startColumn:s},toRange:{startColumn:a}}=t.params,c=r==null?void 0:r.filter(v=>v.range.rangeType===l.RANGE_TYPE.COLUMN&&v.range.startColumn<=s&&s<=v.range.endColumn);if(!(c!=null&&c.length))return e;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 e;const h=d.endColumn-d.startColumn+1,m=Math.max(Math.min(n.startColumn,d.endColumn+1)-d.startColumn,0);let S,g;u.startColumn>=n.startColumn?(S=Math.max(n.startColumn-m,1),g=Math.max(n.xSplit-m,1)):(S=n.startColumn+h-m,g=n.xSplit+h-m);const _={...n,startColumn:S,xSplit:g};return o(_)}if(t.id===f.MoveRowsCommand.id){const r=this._selectionManagerService.getSelections(),{fromRange:{startRow:s},toRange:{startRow:a}}=t.params,c=r==null?void 0:r.filter(v=>v.range.rangeType===l.RANGE_TYPE.ROW&&v.range.startRow<=s&&s<=v.range.endRow);if(!(c!=null&&c.length))return e;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 e;const h=d.endRow-d.startRow+1,m=Math.max(Math.min(n.startRow,d.endRow+1)-d.startRow,0);let S,g;u.startRow>=n.startRow?(S=Math.max(n.startRow-m,1),g=Math.max(n.ySplit-m,1)):(S=n.startRow+h-m,g=n.ySplit+h-m);const _={...n,startRow:S,ySplit:g};return o(_)}if(t.id===f.RemoveColCommand.id||t.id===f.RemoveRowCommand.id){const r=t.params,s=r.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 o(c)}if(r.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 o(c)}}return e}}))}_commandExecutedListener(){const t=[f.SetFrozenMutation.id,Pe.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(t.includes(e.id)){const n=this._lastFreeze,o=this._currentUniverService.getCurrentUniverSheetInstance(),r=o.getActiveSheet(),s=e.params,{unitId:a,subUnitId:c}=s;if(!(a===o.getUnitId()&&c===r.getSheetId()))return;const d=r.getConfig().freeze;if(this._lastFreeze=d,d==null)return;let u=0;const{startRow:h=-1,startColumn:m=-1,ySplit:S=0,xSplit:g=0}=d;(!n||n.startRow!==h||n.ySplit!==S)&&(u|=2),(!n||n.startColumn!==m||n.xSplit!==g)&&(u|=1),s.resetScroll===!1&&(u=0),this._refreshFreeze(h,m,S,g,u)}else if(e.id===f.SetWorksheetRowHeightMutation.id){const n=this._getFreeze();e.params&&n&&e.params.ranges.some(o=>o.startRow<n.startRow)&&this._refreshCurrent()}else if(e.id===f.SetWorksheetColWidthMutation.id){const n=this._getFreeze();e.params&&n&&e.params.ranges.some(o=>o.startColumn<n.startColumn)&&this._refreshCurrent()}else if(e.id===f.SetWorksheetRowAutoHeightMutation.id){const n=e.params,o=this._getFreeze();if(o&&o.startRow>-1&&n.rowsAutoHeightInfo.some(r=>r.row<o.startRow)){const r=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{r.unsubscribe()})})}}else if(e.id===f.SetColHiddenMutation.id||e.id===f.SetColVisibleMutation.id){const n=e.params,o=this._getFreeze(),r=n.ranges;o&&o.startColumn>-1&&r.some(s=>s.startColumn<o.startColumn)&&this._refreshCurrent()}else if(e.id===f.SetRowHiddenMutation.id||e.id===f.SetRowVisibleMutation.id){const n=e.params,o=this._getFreeze(),r=n.ranges;o&&o.startRow>-1&&r.some(s=>s.startRow<o.startRow)&&this._refreshCurrent()}}))}_zoomRefresh(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;e.onTransformChangeObservable.add(n=>{n.type===w.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&this._refreshCurrent()})}_clearObserverEvent(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_clearFreeze(){var n,o,r,s;(n=this._rowFreezeHeaderRect)==null||n.dispose(),(o=this._rowFreezeMainRect)==null||o.dispose(),(r=this._columnFreezeHeaderRect)==null||r.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose();const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;[...this._freezeDownObservers,...this._freezeMoveObservers,...this._freezeLeaveObservers].forEach(a=>{e.onPointerDownObserver.remove(a),e.onPointerMoveObserver.remove(a),e.onPointerLeaveObserver.remove(a)}),e.onPointerEnterObserver.remove(this._moveObserver),e.onPointerMoveObserver.remove(this._upObserver)}_getPositionByIndex(t,e){var c;if(this._getSheetObject()==null)return;const o=(c=this._sheetSkeletonManagerService.getCurrent())==null?void 0:c.skeleton,r=o==null?void 0:o.getNoMergeCellPositionByIndex(t,e);if(o==null)return;if(r!=null&&(!isNaN(r.endX)||!isNaN(r.endY)))return r;const{rowHeaderWidthAndMarginLeft:s,columnHeaderHeightAndMarginTop:a}=o;return{startX:s,endX:s,startY:a,endY:a}}_getFreeze(){var e;const t=(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig();if(t!=null)return t.freeze}_getSheetObject(){return Ie(this._currentUniverService,this._renderManagerService)}_refreshFreeze(t,e,n,o,r){var a;const s={startRow:t,startColumn:e,ySplit:n,xSplit:o};this._clearFreeze(),this._createFreeze(0,s),this._createFreeze(1,s),this._updateViewport(t,e,n,o,r),(a=this._getSheetObject())==null||a.spreadsheet.makeForceDirty()}};Vn=nd([l.OnLifecycle(l.LifecycleStages.Rendered,Vn),je(0,P.Inject(A.SheetSkeletonManagerService)),je(1,l.IUniverInstanceService),je(2,l.ICommandService),je(3,w.IRenderManagerService),je(4,fe),je(5,P.Inject(f.SelectionManagerService)),je(6,P.Inject(Xe)),je(7,P.Inject(l.ThemeService)),je(8,P.Inject(f.SheetInterceptorService)),je(9,P.Inject(P.Injector))],Vn);var Vi=(i=>(i[i.NORMAL=0]="NORMAL",i[i.HIGHLIGHT=1]="HIGHLIGHT",i))(Vi||{});const ld="rgba(0, 0, 0, 0.15)",Ze="rgb(0, 0, 0)",kn="rgb(255, 255, 255, 1)";class cd extends w.Shape{constructor(e,n){super(e,n);I(this,"_size",12);I(this,"_iconRatio",.4);I(this,"_mode",0);this.setShapeProps(n)}setShapeProps(e){e!=null&&e.size&&(this._size=e.size),e!=null&&e.mode&&(this._mode=e.mode),this.transformByState({width:this._size,height:this._size})}_draw(e){this._mode===1&&w.Rect.drawWith(e,{width:this._size,height:this._size,radius:this._size,fill:ld});const n=this._size*.5*this._iconRatio,o=Math.PI/180*60,r=n*Math.sin(o),s=n*Math.cos(o);w.RegularPolygon.drawWith(e,{pointsGroup:[[{x:-r+this._size/2,y:-s+this._size/2},{x:r+this._size/2,y:-s+this._size/2},{x:this._size/2,y:n+this._size/2}]],fill:Ze})}}var dd=Object.defineProperty,ud=Object.getOwnPropertyDescriptor,hd=(i,t,e,n)=>{for(var o=n>1?void 0:n?ud(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&dd(t,e,o),o},Et=(i,t)=>(e,n)=>t(e,n,i);const md="__SpreadsheetHeaderMenuSHAPEControllerShape__",Sd="__SpreadsheetHeaderMenuMAINControllerShape__",gd="rgba(0, 0, 0, 0.1)";let Bn=class extends l.Disposable{constructor(t,e,n,o,r,s){super();I(this,"_hoverRect");I(this,"_hoverMenu");I(this,"_currentColumn",Number.POSITIVE_INFINITY);I(this,"_observers",[]);this._sheetSkeletonManagerService=t,this._currentUniverService=e,this._renderManagerService=n,this._contextMenuService=o,this._commandService=r,this._selectionManagerService=s,this._initialize()}dispose(){var o,r;(o=this._hoverRect)==null||o.dispose(),(r=this._hoverMenu)==null||r.dispose();const t=this._getSheetObject();if(t==null)return;const{spreadsheetRowHeader:e,spreadsheetColumnHeader:n}=t;this._observers.forEach(s=>{e.onPointerEnterObserver.remove(s),e.onPointerMoveObserver.remove(s),e.onPointerLeaveObserver.remove(s),n.onPointerEnterObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)})}_initialize(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;this._hoverRect=new w.Rect(md,{fill:gd,evented:!1}),this._hoverMenu=new cd(Sd,{zIndex:100,visible:!1}),e.addObjects([this._hoverRect,this._hoverMenu],et),this._initialHover(0),this._initialHover(1),this._initialHoverMenu()}_initialHover(t=0){const e=this._getSheetObject();if(e==null)return;const{spreadsheetColumnHeader:n,spreadsheetRowHeader:o}=e,r=t===0?o:n;this._observers.push(r==null?void 0:r.onPointerEnterObserver.add(()=>{var s;(s=this._hoverRect)==null||s.show()})),this._observers.push(r==null?void 0:r.onPointerMoveObserver.add(s=>{var v,M,R;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:S,endY:g,column:_}=Ct(s.offsetX,s.offsetY,c.scene,a);if(t===0)(M=this._hoverRect)==null||M.transformByState({width:d,height:g-m,left:0,top:m});else{if(this._currentColumn=_,(R=this._hoverRect)==null||R.transformByState({width:S-h,height:u,left:h,top:0}),this._hoverMenu==null)return;if(S-h<u*2){this._hoverMenu.hide();return}const b=u*.8;this._hoverMenu.transformByState({left:S-u,top:u/2-b/2}),this._hoverMenu.setShapeProps({size:b}),this._hoverMenu.show()}})),this._observers.push(r==null?void 0:r.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 t=this._getSheetObject();t!=null&&(this._hoverMenu.setProps({mode:Vi.HIGHLIGHT,visible:!0}),t.scene.setCursor(w.CURSOR_TYPE.POINTER))}),this._hoverMenu.onPointerLeaveObserver.add(()=>{if(this._hoverMenu==null)return;const t=this._getSheetObject();t!=null&&(this._hoverMenu.setProps({mode:Vi.NORMAL,visible:!1}),t.scene.resetCursor())}),this._hoverMenu.onPointerDownObserver.add(t=>{if(!this._getSheetObject())return;const n=this._currentColumn,o=this._selectionManagerService.getSelectionRanges();if(!!!(o!=null&&o.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(f.SetSelectionsOperation.id,s)}t.stopPropagation(),t.preventDefault(),this._contextMenuService.triggerContextMenu(t,he.COL_HEADER_CONTEXT_MENU)}))}_getSheetObject(){return Ie(this._currentUniverService,this._renderManagerService)}_getSelectionOnColumn(t){const e=this._currentUniverService.getCurrentUniverSheetInstance(),n=e.getActiveSheet();return{unitId:e.getUnitId(),subUnitId:n.getSheetId(),pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:{startRow:0,startColumn:t,endRow:n.getRowCount()-1,endColumn:t,rangeType:l.RANGE_TYPE.COLUMN},primary:{startRow:0,startColumn:t,endRow:0,endColumn:t,actualRow:0,actualColumn:t,isMerged:!1,isMergedMainCell:!1},style:null}]}}};Bn=hd([l.OnLifecycle(l.LifecycleStages.Rendered,Bn),Et(0,P.Inject(A.SheetSkeletonManagerService)),Et(1,l.IUniverInstanceService),Et(2,w.IRenderManagerService),Et(3,C.IContextMenuService),Et(4,l.ICommandService),Et(5,P.Inject(f.SelectionManagerService))],Bn);var _d=Object.defineProperty,fd=Object.getOwnPropertyDescriptor,pd=(i,t,e,n)=>{for(var o=n>1?void 0:n?fd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&_d(t,e,o),o},yt=(i,t)=>(e,n)=>t(e,n,i);const vd="__SpreadsheetHeaderMoveControllerBackground__",Cd="__SpreadsheetHeaderMoveControllerShapeLine__",Id="rgba(0, 0, 0, 0.1)",Md="rgb(119, 119, 119)",Rd=4;let Fn=class extends l.Disposable{constructor(t,e,n,o,r,s){super();I(this,"_startOffsetX",Number.NEGATIVE_INFINITY);I(this,"_startOffsetY",Number.NEGATIVE_INFINITY);I(this,"_moveHelperBackgroundShape");I(this,"_moveHelperLineShape");I(this,"_sheetObject");I(this,"_rowOrColumnDownObservers",[]);I(this,"_rowOrColumnMoveObservers",[]);I(this,"_rowOrColumnLeaveObservers",[]);I(this,"_moveObserver");I(this,"_upObserver");I(this,"_scrollTimer");I(this,"_changeFromColumn",-1);I(this,"_changeFromRow",-1);I(this,"_changeToColumn",-1);I(this,"_changeToRow",-1);this._sheetSkeletonManagerService=t,this._currentUniverService=e,this._renderManagerService=n,this._commandService=o,this._selectionRenderService=r,this._selectionManagerService=s,this._initialize()}dispose(){var r,s;(r=this._moveHelperBackgroundShape)==null||r.dispose(),(s=this._moveHelperLineShape)==null||s.dispose();const t=this._getSheetObject();if(t==null)return;const{spreadsheetRowHeader:e,spreadsheetColumnHeader:n,scene:o}=t;[...this._rowOrColumnDownObservers,...this._rowOrColumnMoveObservers,...this._rowOrColumnLeaveObservers].forEach(a=>{e.onPointerDownObserver.remove(a),n.onPointerDownObserver.remove(a)}),o.onPointerMoveObserver.remove(this._moveObserver),o.onPointerUpObserver.remove(this._upObserver),this._scrollTimer.dispose()}_initialize(){const t=this._getSheetObject();t!=null&&(this._sheetObject=t,this._initialRowOrColumn(0),this._initialRowOrColumn(1))}_initialRowOrColumn(t=0){const{spreadsheetColumnHeader:e,spreadsheetRowHeader:n,scene:o}=this._sheetObject,r=t===0?n:e;this._rowOrColumnMoveObservers.push(r==null?void 0:r.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}=Ct(s.offsetX,s.offsetY,o,a);if(this._checkInHeaderRange(t===0?c:d,t)===!1){o.resetCursor(),this._selectionRenderService.enableSelection();return}o.setCursor(w.CURSOR_TYPE.GRAB),this._selectionRenderService.disableSelection()})),this._rowOrColumnLeaveObservers.push(r==null?void 0:r.onPointerLeaveObserver.add(()=>{var s,a;(s=this._moveHelperBackgroundShape)==null||s.hide(),(a=this._moveHelperLineShape)==null||a.hide(),o.resetCursor(),this._selectionRenderService.enableSelection()})),this._rowOrColumnDownObservers.push(r==null?void 0:r.onPointerDownObserver.add(s=>{var T;const a=(T=this._sheetSkeletonManagerService.getCurrent())==null?void 0:T.skeleton;if(a==null)return;const{offsetX:c,offsetY:d}=s,u=o.getRelativeCoord(w.Vector2.FromArray([c,d])),{x:h,y:m}=u;this._startOffsetX=h,this._startOffsetY=m;const{row:S,column:g}=Ct(s.offsetX,s.offsetY,o,a);let _;t===0?(this._changeFromRow=S,_=w.ScrollTimerType.Y):(this._changeFromColumn=g,_=w.ScrollTimerType.X);const v=this._checkInHeaderRange(t===0?S:g,t);if(v===!1)return;const M=o.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),o.setCursor(w.CURSOR_TYPE.GRABBING),o.disableEvent();let R=!1,b;const E=()=>{if(R)return;b=w.ScrollTimer.create(o,_);const y=o.getViewport(F.VIEW_MAIN);b.startScroll(h,m,y),this._scrollTimer=b,R=!0};this._moveObserver=o.onPointerMoveObserver.add(y=>{E();const{offsetX:O,offsetY:x}=y,{x:N,y:V}=o.getRelativeCoord(w.Vector2.FromArray([O,x]));o.setCursor(w.CURSOR_TYPE.GRABBING),this._rowColumnMoving(N,V,v,M,t),b.scrolling(N,V,()=>{this._rowColumnMoving(N,V,v,M,t)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var O,x,N;this._disposeBackgroundAndLine(),o.resetCursor(),o.enableEvent(),this._clearObserverEvent(),(O=this._scrollTimer)==null||O.dispose();const y=this._selectionManagerService.getSelections();if(t===0){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const D=(x=((y==null?void 0:y.filter(H=>H.range.rangeType===l.RANGE_TYPE.ROW&&H.range.startRow<=this._changeFromRow&&this._changeFromRow<=H.range.endRow))||[])[0])==null?void 0:x.range;D&&this._commandService.executeCommand(f.MoveRowsCommand.id,{fromRange:D,toRange:{...D,startRow:this._changeToRow,endRow:this._changeToRow+D.endRow-D.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const D=(N=((y==null?void 0:y.filter(H=>H.range.rangeType===l.RANGE_TYPE.COLUMN&&H.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=H.range.endColumn))||[])[0])==null?void 0:N.range;D&&this._commandService.executeCommand(f.MoveColsCommand.id,{fromRange:D,toRange:{...D,startColumn:this._changeToColumn,endColumn:this._changeToColumn+D.endColumn-D.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})}))}_rowColumnMoving(t,e,n,o,r){var ee,ne,U,W,G,q,re;const{scene:s}=this._sheetObject,a=(ee=this._sheetSkeletonManagerService.getCurrent())==null?void 0:ee.skeleton;if(a==null)return;const{rowHeaderWidth:c,columnHeaderHeight:d,rowTotalHeight:u,columnTotalWidth:h}=a,m=s.getScrollXY(s.getViewport(F.VIEW_MAIN)),{scaleX:S,scaleY:g}=s.getAncestorScale(),_=a.getCellPositionByOffset(t,e,S,g,m),{row:v,column:M}=_,R=a.getNoMergeCellPositionByIndex(v,M),{startX:b,startY:E,endX:T,endY:y}=R,O=this._selectionRenderService.convertRangeDataToSelection(n.range);if(O==null)return;const x=Math.max(S,S),{startX:N,endX:V,startY:D,endY:H,startRow:B,startColumn:j,endRow:X,endColumn:z}=O;r===0?(ne=this._moveHelperBackgroundShape)==null||ne.transformByState({height:H-D,width:h+c,left:0,top:D+(e-this._startOffsetY)/x+m.y-o.y}):(U=this._moveHelperBackgroundShape)==null||U.transformByState({height:u+d,width:V-N,left:N+(t-this._startOffsetX)/x+m.x-o.x,top:0}),(W=this._moveHelperBackgroundShape)==null||W.show();const $=Rd/x;if(r===0){let se=0;if(v<=B)se=E-$/2,this._changeToRow=v;else if(v>X)se=y-$/2,this._changeToRow=v+1;else return;(G=this._moveHelperLineShape)==null||G.transformByState({height:$,width:h,left:c,top:se})}else{let se=0;if(M<=j)se=b-$/2,this._changeToColumn=M;else if(M>z)se=T-$/2,this._changeToColumn=M+1;else return;(q=this._moveHelperLineShape)==null||q.transformByState({height:u,width:$,left:se,top:d})}(re=this._moveHelperLineShape)==null||re.show()}_checkInHeaderRange(t,e=0){var a;const n=this._selectionManagerService.getSelections();if(((a=this._selectionManagerService.getCurrent())==null?void 0:a.pluginName)!==f.NORMAL_SELECTION_PLUGIN_NAME)return!1;const r=n==null?void 0:n.find(c=>{const d=c.range,{startRow:u,endRow:h,startColumn:m,endColumn:S,rangeType:g}=d;return e===1?t>=m&&t<=S&&l.RANGE_TYPE.COLUMN===g:t>=u&&t<=h&&l.RANGE_TYPE.ROW===g}),s=r==null?void 0:r.range;return r==null||s==null||s.rangeType===l.RANGE_TYPE.ALL||s.rangeType===l.RANGE_TYPE.NORMAL||s.rangeType===l.RANGE_TYPE.ROW&&e!==0||s.rangeType===l.RANGE_TYPE.COLUMN&&e!==1?!1:r}_clearObserverEvent(){const{scene:t}=this._sheetObject;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_newBackgroundAndLine(){const{scene:t}=this._sheetObject;this._moveHelperBackgroundShape=new w.Rect(vd,{fill:Id,evented:!1,zIndex:100}),this._moveHelperLineShape=new w.Rect(Cd,{fill:Md,evented:!1,zIndex:100}),t.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],et)}_disposeBackgroundAndLine(){var t,e;(t=this._moveHelperBackgroundShape)==null||t.dispose(),(e=this._moveHelperLineShape)==null||e.dispose()}_getSheetObject(){return Ie(this._currentUniverService,this._renderManagerService)}};Fn=pd([l.OnLifecycle(l.LifecycleStages.Rendered,Fn),yt(0,P.Inject(A.SheetSkeletonManagerService)),yt(1,l.IUniverInstanceService),yt(2,w.IRenderManagerService),yt(3,l.ICommandService),yt(4,fe),yt(5,P.Inject(f.SelectionManagerService))],Fn);var ki=(i=>(i[i.VERTICAL=0]="VERTICAL",i[i.HORIZONTAL=1]="HORIZONTAL",i))(ki||{});const bd="rgba(120, 120, 120, 0.01)",Bi="rgb(68, 71, 70)",Kt=12,Fi=4;class Rr extends w.Shape{constructor(e,n){super(e,n);I(this,"_size",Kt);I(this,"_color",Bi);I(this,"_mode",0);this.setShapeProps(n)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(e){let{width:n,height:o}=this,r=0,s=0;const a=this.getScene(),{scaleX:c,scaleY:d}=a.getAncestorScale(),u=Math.max(c,d),h=Kt/u,m=Fi/u;this.mode===0?(n=m,r=h-m):(o=m,s=h-m),w.Rect.drawWith(e,{width:this.width,height:this.height,left:0,top:0,fill:bd}),w.Rect.drawWith(e,{width:n,height:o,fill:Bi,radius:m}),e.save(),e.transform(1,0,0,1,r,s),w.Rect.drawWith(e,{width:n,height:o,fill:Bi,radius:m}),e.restore()}setShapeProps(e){return e!=null&&e.size&&(this._size=e.size),e!=null&&e.mode&&(this._mode=e.mode),e!=null&&e.color&&(this._color=e.color),this.mode===0?this.transformByState({width:Kt,height:this.size}):this.transformByState({width:this.size,height:Kt}),this}}var wd=Object.defineProperty,Td=Object.getOwnPropertyDescriptor,Ed=(i,t,e,n)=>{for(var o=n>1?void 0:n?Td(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&wd(t,e,o),o},Qt=(i,t)=>(e,n)=>t(e,n,i);const yd="__SpreadsheetHeaderResizeControllerShapeRow__",Od="__SpreadsheetHeaderResizeControllerShapeColumn__",br="__SpreadsheetHeaderResizeControllerShapeHelper__",wr="rgb(199, 199, 199)",Ad=2;let Wn=class extends l.Disposable{constructor(t,e,n,o,r){super();I(this,"_currentRow",0);I(this,"_currentColumn",0);I(this,"_rowResizeRect");I(this,"_columnResizeRect");I(this,"_observers",[]);I(this,"_moveObserver");I(this,"_upObserver");I(this,"_resizeHelperShape");I(this,"_startOffsetX",Number.POSITIVE_INFINITY);I(this,"_startOffsetY",Number.POSITIVE_INFINITY);this._sheetSkeletonManagerService=t,this._currentUniverService=e,this._commandService=n,this._renderManagerService=o,this._editorBridgeService=r,this._initialize()}dispose(){var o,r;(o=this._rowResizeRect)==null||o.dispose(),this._rowResizeRect=null,(r=this._columnResizeRect)==null||r.dispose(),this._columnResizeRect=null;const t=this._getSheetObject();if(t==null)return;const{spreadsheetRowHeader:e,spreadsheetColumnHeader:n}=t;this._observers.forEach(s=>{e.onPointerMoveObserver.remove(s),e.onPointerLeaveObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)}),this._observers=[]}_initialize(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;this._rowResizeRect=new Rr(yd,{visible:!1,mode:ki.HORIZONTAL,zIndex:100}),this._columnResizeRect=new Rr(Od,{visible:!1,mode:ki.VERTICAL,zIndex:100}),e.addObjects([this._rowResizeRect,this._columnResizeRect],et),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(t=0){const e=this._getSheetObject();if(e==null)return;const{spreadsheetRowHeader:n,spreadsheetColumnHeader:o,scene:r}=e,s=t===0?n:o;this._observers.push(s==null?void 0:s.onPointerMoveObserver.add((a,c)=>{var O;const d=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton;if(d==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:u,columnHeaderHeight:h}=d,{startX:m,startY:S,endX:g,endY:_,row:v,column:M}=Ct(a.offsetX,a.offsetY,r,d),R=Cn(a.offsetX,a.offsetY,r),{scaleX:b,scaleY:E}=r.getAncestorScale(),T=Math.max(b,E),y=Kt/T;if(t===0){let x=S-y/2;if(R.y<=S+y/2&&R.y>=S)this._currentRow=v-1;else if(R.y>=_-y/2&&R.y<=_)this._currentRow=v,x=_-y/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;const N=u/3;this._rowResizeRect.transformByState({left:u/2-N/2,top:x}),this._rowResizeRect.setShapeProps({size:N}),this._rowResizeRect.show()}else{let x=m-y/2;if(R.x<=m+y/2&&R.x>=m)this._currentColumn=M-1;else if(R.x>=g-y/2&&R.x<=g)this._currentColumn=M,x=g-y/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;const N=h*.7;this._columnResizeRect.transformByState({left:x,top:h/2-N/2}),this._columnResizeRect.setShapeProps({size:N}),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(t=0){const e=this._getSheetObject();if(e==null)return;const{scene:n}=e,o=t===0?this._rowResizeRect:this._columnResizeRect;if(o==null)return;const r=n.getEngine(),s=(r==null?void 0:r.width)||0,a=(r==null?void 0:r.height)||0;this.disposeWithMe(l.toDisposable(o.onPointerEnterObserver.add(()=>{o!=null&&(o.show(),n.setCursor(t===0?w.CURSOR_TYPE.ROW_RESIZE:w.CURSOR_TYPE.COLUMN_RESIZE))}))),this.disposeWithMe(l.toDisposable(o.onPointerLeaveObserver.add(()=>{o!=null&&(o.hide(),n.resetCursor())}))),this.disposeWithMe(l.toDisposable(o.onPointerDownObserver.add((c,d)=>{var ne,U,W,G,q,re,se;const u=(ne=this._sheetSkeletonManagerService.getCurrent())==null?void 0:ne.skeleton;if(u==null)return;const h=this._getSheetObject();if(h==null)return;const{scene:m}=h,S=m.getViewport(F.VIEW_MAIN),g=(((W=(U=S==null?void 0:S.getScrollBar())==null?void 0:U.horizonBarRect)==null?void 0:W.height)||0)+10,_=(((q=(G=S==null?void 0:S.getScrollBar())==null?void 0:G.verticalBarRect)==null?void 0:q.width)||0)+10,v=Cn(c.offsetX,c.offsetY,m),{scaleX:M,scaleY:R}=m.getAncestorScale();this._startOffsetX=v.x,this._startOffsetY=v.y;const b=u.getOffsetByPositionX(this._currentColumn),E=u.getOffsetByPositionY(this._currentRow),T=u.getNoMergeCellPositionByIndex(this._currentRow,this._currentColumn);let y=!1,O=0,x=0;const{columnTotalWidth:N,rowHeaderWidth:V,rowTotalHeight:D,columnHeaderHeight:H}=u,B=s>N+V?s:N+V,j=a>D+H?a:D+H,X=Math.max(M,R),z=Fi/X;t===0?this._resizeHelperShape=new w.Rect(br,{width:B,height:z,fill:wr,left:0,top:E-z/2}):this._resizeHelperShape=new w.Rect(br,{width:z,height:j,fill:wr,left:b-z/2,top:0});const $=((re=this._columnResizeRect)==null?void 0:re.left)||0,ee=((se=this._rowResizeRect)==null?void 0:se.top)||0;m.addObject(this._resizeHelperShape,et),m.disableEvent(),this._editorBridgeService.changeVisible({visible:!1,eventType:w.DeviceInputEventType.PointerDown}),this._moveObserver=m.onPointerMoveObserver.add(Y=>{var Je,Re,an,ln,cn,dn;const Q=m.getRelativeCoord(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),J=m.getScrollXYByRelativeCoords(Q,S),ae=Cn(Y.offsetX,Y.offsetY,m),{x:ce,y:pe}=ae,{scaleX:Qe,scaleY:Me}=m.getAncestorScale(),ge=Math.max(Qe,Me),de=Fi/ge;O=ce-this._startOffsetX-de/2,x=pe-this._startOffsetY-de/2,Math.abs(t===0?x:O)>=Ad&&(y=!0),t===0?(x>a-g+J.y-T.startY&&(x=a-g+J.y-T.startY),x<-(T.endY-T.startY)+2&&(x=-(T.endY-T.startY)+2),y&&((Je=this._resizeHelperShape)==null||Je.transformByState({top:E+x}),(Re=this._rowResizeRect)==null||Re.transformByState({top:ee+x+de/2}),(an=this._rowResizeRect)==null||an.show(),m.setCursor(w.CURSOR_TYPE.ROW_RESIZE))):(O>s-_+J.x-T.startX&&(O=s-_+J.x-T.startX),O<-(T.endX-T.startX)+2&&(O=-(T.endX-T.startX)+2),y&&((ln=this._resizeHelperShape)==null||ln.transformByState({left:b+O}),(cn=this._columnResizeRect)==null||cn.transformByState({left:$+O+de/2}),(dn=this._columnResizeRect)==null||dn.show(),m.setCursor(w.CURSOR_TYPE.COLUMN_RESIZE)))}),this._upObserver=m.onPointerUpObserver.add(Y=>{var ae,ce,pe;const Q=Ie(this._currentUniverService,this._renderManagerService);if(Q==null)return;this._clearObserverEvent(),(ae=this._resizeHelperShape)==null||ae.dispose(),this._resizeHelperShape=null;const{scene:J}=Q;J.enableEvent(),y&&(J.resetCursor(),(ce=this._rowResizeRect)==null||ce.hide(),(pe=this._columnResizeRect)==null||pe.hide(),t===0?this._commandService.executeCommand(f.DeltaRowHeightCommand.id,{deltaY:x,anchorRow:this._currentRow}):this._commandService.executeCommand(f.DeltaColumnWidthCommand.id,{deltaX:O,anchorCol:this._currentColumn}))})}))),this.disposeWithMe(l.toDisposable(o.onDblclickObserver.add(()=>{var c;if(t===0){const d=this._getSheetObject();if(d==null)return;const{scene:u}=d;u.resetCursor(),this._commandService.executeCommand(f.SetWorksheetRowIsAutoHeightCommand.id,{anchorRow:this._currentRow}),(c=this._rowResizeRect)==null||c.hide()}})))}_clearObserverEvent(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_getSheetObject(){return Ie(this._currentUniverService,this._renderManagerService)}};Wn=Ed([l.OnLifecycle(l.LifecycleStages.Rendered,Wn),Qt(0,P.Inject(A.SheetSkeletonManagerService)),Qt(1,l.IUniverInstanceService),Qt(2,l.ICommandService),Qt(3,w.IRenderManagerService),Qt(4,we)],Wn);var Wi=(i=>(i[i.ROW=0]="ROW",i[i.COLUMN=1]="COLUMN",i))(Wi||{});const Jt=12,xd=.4;class Tr extends w.Shape{constructor(e,n,o){super(e,n);I(this,"_size",Jt);I(this,"_iconRatio",xd);I(this,"_hovered",!0);I(this,"_hasPrevious",!0);I(this,"_hasNext",!0);I(this,"_unhideType");n&&this.setShapeProps(n),this.onPointerEnterObserver.add(()=>this.setShapeProps({hovered:!0})),this.onPointerLeaveObserver.add(()=>this.setShapeProps({hovered:!1})),this.onPointerDownObserver.add(()=>o==null?void 0:o())}setShapeProps(e){e.type!==void 0&&(this._unhideType=e.type),e.hovered!==void 0&&(this._hovered=e.hovered),e.hasPrevious!==void 0&&(this._hasPrevious=e.hasPrevious),e.hasNext!==void 0&&(this._hasNext=e.hasNext),this.transformByState({width:this._size*(this._unhideType===1?2:1),height:this._size*(this._unhideType===0?2:1)})}_draw(e){this._unhideType===0?this._drawOnRow(e):this._drawOnCol(e)}_drawOnRow(e){this._hovered&&(!this._hasNext||!this._hasPrevious?w.Rect.drawWith(e,{width:this._size,height:this._size,stroke:Ze,fill:kn}):w.Rect.drawWith(e,{width:this._size,height:2*this._size,stroke:Ze,fill:kn}));const n=this._size*.5*this._iconRatio,o=Math.PI/3,r=n*Math.cos(o),s=n*Math.sin(o);if(this._hasPrevious&&w.RegularPolygon.drawWith(e,{pointsGroup:[[{x:this._size/2,y:this._size/2-s},{x:this._size/2-s,y:this._size/2+r},{x:this._size/2+s,y:this._size/2+r}]],fill:Ze}),this._hasNext){const a=this._hasPrevious?3:1;w.RegularPolygon.drawWith(e,{pointsGroup:[[{x:this._size/2,y:this._size*a/2+s},{x:this._size/2-s,y:this._size*a/2-r},{x:this._size/2+s,y:this._size*a/2-r}]],fill:Ze})}}_drawOnCol(e){this._hovered&&(!this._hasNext||!this._hasPrevious?w.Rect.drawWith(e,{width:this._size,height:this._size,stroke:Ze,fill:kn}):w.Rect.drawWith(e,{width:2*this._size,height:this._size,stroke:Ze,fill:kn}));const n=this._size*.5*this._iconRatio,o=Math.PI/3,r=n*Math.cos(o),s=n*Math.sin(o);if(this._hasPrevious&&w.RegularPolygon.drawWith(e,{pointsGroup:[[{x:-r+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:Ze}),this._hasNext){const a=this._hasPrevious?3:1;w.RegularPolygon.drawWith(e,{pointsGroup:[[{x:r+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:Ze})}}}var Nd=Object.defineProperty,Dd=Object.getOwnPropertyDescriptor,Pd=(i,t,e,n)=>{for(var o=n>1?void 0:n?Dd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Nd(t,e,o),o},jn=(i,t)=>(e,n)=>t(e,n,i);const Er="__SpreadsheetHeaderUnhideSHAPEControllerShape__",Ld=[f.SetRowHiddenMutation.id,f.SetRowVisibleMutation.id,f.SetColHiddenMutation.id,f.SetColVisibleMutation.id];let zn=class extends l.RxDisposable{constructor(t,e,n,o){super();I(this,"_shapes",new Map);this._sheetSkeletonManagerService=t,this._cmdSrv=e,this._univerInstanceService=n,this._rendererManagerService=o,this._init()}dispose(){super.dispose()}_init(){this._getSheetObject()&&(this._sheetSkeletonManagerService.currentSkeleton$.pipe(k.takeUntil(this.dispose$),k.startWith(void 0),k.pairwise()).subscribe(([e,n])=>{if(n){const o=this._univerInstanceService.getUniverSheetInstance(n.unitId),r=o.getSheetBySheetId(n.sheetId);this._updateWorksheet(o,r,e==null?void 0:e.sheetId)}}),this.disposeWithMe(this._cmdSrv.onCommandExecuted(e=>{if(!Ld.includes(e.id)||!e.params||!e.params.unitId||!e.params.subUnitId)return;const n=this._univerInstanceService.getUniverSheetInstance(e.params.unitId),o=n==null?void 0:n.getSheetBySheetId(e.params.subUnitId);o&&this._updateWorksheet(n,o,o.getSheetId())})))}_initForWorksheet(t,e){var m;const n=(m=this._sheetSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(!n)return;const o=e.getHiddenRows(),r=e.getHiddenCols(),s=this._getSheetObject();if(!s)return;const{scene:a}=s,c=e.getRowCount(),d=o.map(S=>{const{startRow:g,endRow:_}=S,v=Mi(g,0,a,n),M=g!==0,R=_!==c-1;return new Tr(Er,{type:Wi.ROW,hovered:!1,hasPrevious:M,hasNext:R,top:v.startY-(M?Jt:0),left:v.startX-Jt},()=>this._cmdSrv.executeCommand(f.SetSpecificRowsVisibleCommand.id,{unitId:t.getUnitId(),subUnitId:e.getSheetId(),ranges:[S]}))}),u=e.getColumnCount(),h=r.map(S=>{const{startColumn:g,endColumn:_}=S,v=Mi(0,g,a,n),M=g!==0,R=_!==u-1;return new Tr(Er,{type:Wi.COLUMN,hovered:!1,hasPrevious:M,hasNext:R,left:v.startX-(M?Jt:0),top:20-Jt},()=>this._cmdSrv.executeCommand(f.SetSpecificColsVisibleCommand.id,{unitId:t.getUnitId(),subUnitId:e.getSheetId(),ranges:[S]}))});a.addObjects(h,Ro),a.addObjects(d,Ro),this._shapes.set(l.getWorksheetUID(t,e),{cols:h,rows:d})}_updateWorksheet(t,e,n){if(n){const o=this._shapes.get(`${t.getUnitId()}|${n}`);o==null||o.cols.forEach(r=>r.dispose()),o==null||o.rows.forEach(r=>r.dispose())}this._initForWorksheet(t,e)}_getSheetObject(){return Ie(this._univerInstanceService,this._rendererManagerService)}};zn=Pd([l.OnLifecycle(l.LifecycleStages.Rendered,zn),jn(0,P.Inject(A.SheetSkeletonManagerService)),jn(1,l.ICommandService),jn(2,l.IUniverInstanceService),jn(3,w.IRenderManagerService)],zn);var Ud=Object.defineProperty,Hd=Object.getOwnPropertyDescriptor,Vd=(i,t,e,n)=>{for(var o=n>1?void 0:n?Hd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Ud(t,e,o),o},ji=(i,t)=>(e,n)=>t(e,n,i);let Yn=class extends l.Disposable{constructor(i,t,e){super(),this._markSelectionService=i,this._commandService=t,this._sheetSkeletonManagerService=e,this._initListeners()}_initListeners(){this._addRemoveListener(),this._addRefreshListener()}_addRemoveListener(){const i=[Te.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{i.includes(t.id)?this._markSelectionService.removeAllShapes():this._markSelectionService.getShapeMap().forEach((n,o)=>{n.exits.includes(t.id)&&this._markSelectionService.removeShape(o)})}))}_addRefreshListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{i&&this._markSelectionService.refreshShapes()})))}};Yn=Vd([l.OnLifecycle(l.LifecycleStages.Steady,Yn),ji(0,P.Inject(Ut)),ji(1,l.ICommandService),ji(2,P.Inject(A.SheetSkeletonManagerService))],Yn);var kd=Object.defineProperty,Bd=Object.getOwnPropertyDescriptor,Fd=(i,t,e,n)=>{for(var o=n>1?void 0:n?Bd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&kd(t,e,o),o},zi=(i,t)=>(e,n)=>t(e,n,i);let Xn=class extends l.Disposable{constructor(t,e,n){super();I(this,"_initialize",()=>{const t=new l.DisposableCollection;this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(()=>{t.dispose();const e=this._selectionManagerService.getCurrent();if((e==null?void 0:e.pluginName)!==f.NORMAL_SELECTION_PLUGIN_NAME)return;this._selectionRenderService.getCurrentControls().forEach(o=>{t.add(l.toDisposable(o.selectionMoved$.subscribe(r=>{if(!r)return;const s=o.model.getRange(),a={startRow:s.startRow,startColumn:s.startColumn,endRow:s.endRow,endColumn:s.endColumn,rangeType:s.rangeType},c={startRow:r.startRow,startColumn:r.startColumn,endRow:r.endRow,endColumn:r.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(f.MoveRangeCommand.id,d)})))})})))});this._selectionRenderService=t,this._selectionManagerService=e,this._commandService=n,this._initialize()}};Xn=Fd([l.OnLifecycle(l.LifecycleStages.Steady,Xn),zi(0,P.Inject(fe)),zi(1,P.Inject(f.SelectionManagerService)),zi(2,P.Inject(l.ICommandService))],Xn);var Wd=Object.defineProperty,jd=Object.getOwnPropertyDescriptor,zd=(i,t,e,n)=>{for(var o=n>1?void 0:n?jd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Wd(t,e,o),o},it=(i,t)=>(e,n)=>t(e,n,i);let $n=class extends l.Disposable{constructor(i,t,e,n,o,r,s,a){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=t,this._commandService=e,this._renderManagerService=n,this._selectionRenderService=o,this._selectionManagerService=r,this._themeService=s,this._definedNamesService=a,this._initialize()}_initialize(){const i=this._currentUniverService.getCurrentUniverSheetInstance(),t=i.getActiveSheet(),e=this._getSheetObject();if(e==null)return;this._initViewMainListener(e),this._initRowHeader(e),this._initColumnHeader(e),this._initLeftTop(e),this._initSelectionChangeListener(),this._initThemeChangeListener(),this._initSkeletonChangeListener(),this._initCommandListener(),this._initUserActionSyncListener(),this._initDefinedNameListener();const n=i.getUnitId(),o=t.getSheetId();this._selectionManagerService.setCurrentSelection({pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,unitId:n,sheetId:o})}_initDefinedNameListener(){this.disposeWithMe(l.toDisposable(this._definedNamesService.focusRange$.subscribe(async i=>{if(i==null)return;const{unitId:t}=i;let{formulaOrRefString:e}=i;const n=this._currentUniverService.getCurrentUniverSheetInstance();if(t!==n.getUnitId())return;e.substring(0,1)===K.operatorToken.EQUALS&&(e=e.substring(1));const o=e.split(",");if(!o.every(c=>K.isReferenceString(c.trim())))return;let s=n.getActiveSheet();const a=[];for(let c=0;c<o.length;c++){const d=o[c].trim(),u=K.deserializeRangeWithSheet(d.trim());if(c===0){const m=n.getSheetBySheetName(u.sheetName);m&&s.getSheetId()!==m.getSheetId()&&(s=m,await this._commandService.executeCommand(f.SetWorksheetActivateCommand.id,{subUnitId:s.getSheetId(),unitId:t}))}if(s.getName()!==u.sheetName)continue;let h=null;if(c===o.length-1){const m=u.range,{startRow:S,startColumn:g,endRow:_,endColumn:v}=m;h=f.getPrimaryForRange({startRow:S,startColumn:g,endRow:_,endColumn:v},s)}a.push({range:u.range,style:f.getNormalSelectionStyle(this._themeService),primary:h})}this._selectionManagerService.replace(a),this._commandService.executeCommand(f.ScrollToCellOperation.id,a[0].range)})))}_getActiveViewport(i){const t=this._getSheetObject();return t==null?void 0:t.scene.getActiveViewportByCoord(w.Vector2.FromArray([i.offsetX,i.offsetY]))}_initViewMainListener(i){const{spreadsheet:t}=i;this.disposeWithMe(l.toDisposable(t==null?void 0:t.onPointerDownObserver.add((e,n)=>{this._selectionRenderService.enableDetectMergedCell(),this._selectionRenderService.eventTrigger(e,t.zIndex+1,l.RANGE_TYPE.NORMAL,this._getActiveViewport(e)),e.button!==2&&n.stopPropagation()})))}_initThemeChangeListener(){this.disposeWithMe(l.toDisposable(this._themeService.currentTheme$.subscribe(()=>{this._selectionRenderService.resetStyle();const i=this._selectionManagerService.getSelections(),t=this._selectionManagerService.getCurrent();i==null||(t==null?void 0:t.pluginName)!==f.NORMAL_SELECTION_PLUGIN_NAME||this._refreshSelection(i)})))}_refreshSelection(i){const t=i.map(e=>{const n=this._selectionRenderService.convertSelectionRangeToData(e);return n.style=f.getNormalSelectionStyle(this._themeService),n});this._selectionRenderService.updateControlForCurrentByRangeData(t)}_initRowHeader(i){const{spreadsheetRowHeader:t,spreadsheet:e}=i;this.disposeWithMe(l.toDisposable(t==null?void 0:t.onPointerDownObserver.add((n,o)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(n,((e==null?void 0:e.zIndex)||1)+1,l.RANGE_TYPE.ROW,this._getActiveViewport(n),w.ScrollTimerType.Y),n.button!==2&&o.stopPropagation()})))}_initColumnHeader(i){const{spreadsheetColumnHeader:t,spreadsheet:e}=i;this.disposeWithMe(l.toDisposable(t==null?void 0:t.onPointerDownObserver.add((n,o)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(n,((e==null?void 0:e.zIndex)||1)+1,l.RANGE_TYPE.COLUMN,this._getActiveViewport(n),w.ScrollTimerType.X),n.button!==2&&o.stopPropagation()})))}_initLeftTop(i){const{spreadsheetLeftTopPlaceholder:t}=i;this.disposeWithMe(l.toDisposable(t==null?void 0:t.onPointerDownObserver.add((e,n)=>{var a;const o=(a=this._sheetSkeletonManagerService.getCurrent())==null?void 0:a.skeleton;if(o==null)return;this._selectionRenderService.reset();const r=this._getAllRange(o),s=this._selectionRenderService.convertSelectionRangeToData(r);this._selectionRenderService.addControlToCurrentByRangeData(s),this._selectionRenderService.refreshSelectionMoveStart(),e.button!==2&&n.stopPropagation()})))}_initSelectionChangeListener(){this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(i=>{if(this._selectionRenderService.reset(),i!=null){for(const t of i){if(t==null)continue;const e=this._selectionRenderService.convertSelectionRangeToData(t);this._selectionRenderService.addControlToCurrentByRangeData(e)}this._syncDefinedNameRange(i)}}))),this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoving$.subscribe(i=>{i!=null&&this._syncDefinedNameRange(i)}))),this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveStart$.subscribe(i=>{i!=null&&this._syncDefinedNameRange(i)})))}_syncDefinedNameRange(i){if(i.length===0)return;const t=i[i.length-1],e=this._currentUniverService.getCurrentUniverSheetInstance(),n=e.getActiveSheet();this._definedNamesService.setCurrentRange({range:t.range,unitId:e.getUnitId(),sheetId:n.getSheetId()})}_initUserActionSyncListener(){this._selectionRenderService.selectionMoveStart$.subscribe(i=>{this._move(i,f.SelectionMoveType.MOVE_START)}),this._selectionRenderService.selectionMoving$.subscribe(i=>{this._move(i,f.SelectionMoveType.MOVING)}),this._selectionRenderService.selectionMoveEnd$.subscribe(i=>{this._move(i,f.SelectionMoveType.MOVE_END)})}_move(i,t){const e=this._currentUniverService.getCurrentUniverSheetInstance(),n=e.getUnitId(),o=e.getActiveSheet().getSheetId(),r=this._selectionManagerService.getCurrent();i==null||i.length===0||this._commandService.executeCommand(f.SetSelectionsOperation.id,{unitId:n,subUnitId:o,type:t,pluginName:(r==null?void 0:r.pluginName)||f.NORMAL_SELECTION_PLUGIN_NAME,selections:i.map(s=>f.convertSelectionDataToRange(s))})}_getSheetObject(){return Ie(this._currentUniverService,this._renderManagerService)}_initCommandListener(){const i=[Pe.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(i.includes(t.id)){const e=this._currentUniverService.getCurrentUniverSheetInstance(),n=e.getActiveSheet(),o=t.params,{unitId:r,subUnitId:s}=o;if(!(r===e.getUnitId()&&s===n.getSheetId()))return;this._selectionManagerService.refreshSelection()}}))}_initSkeletonChangeListener(){this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{unitId:t,sheetId:e,skeleton:n}=i,o=this._renderManagerService.getRenderById(t);if(o==null)return;const{scene:r}=o,s=r.getViewport(F.VIEW_MAIN);this._selectionRenderService.changeRuntime(n,r,s);const a=this._selectionManagerService.getCurrent(),c=(a==null?void 0:a.pluginName)||f.NORMAL_SELECTION_PLUGIN_NAME;if((a==null?void 0:a.unitId)===t&&a.sheetId===e){const d=this._selectionManagerService.getSelections();d!=null&&this._refreshSelection(d)}else this._selectionManagerService.setCurrentSelection({pluginName:c,unitId:t,sheetId:e});c===f.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 t=i.mergeData;return f.transformCellDataToSelectionData(0,0,t)||{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}}};$n=zd([l.OnLifecycle(l.LifecycleStages.Rendered,$n),it(0,P.Inject(A.SheetSkeletonManagerService)),it(1,l.IUniverInstanceService),it(2,l.ICommandService),it(3,w.IRenderManagerService),it(4,fe),it(5,P.Inject(f.SelectionManagerService)),it(6,P.Inject(l.ThemeService)),it(7,K.IDefinedNamesService)],$n);var Yd=Object.defineProperty,Xd=Object.getOwnPropertyDescriptor,$d=(i,t,e,n)=>{for(var o=n>1?void 0:n?Xd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Yd(t,e,o),o},qt=(i,t)=>(e,n)=>t(e,n,i);let Zn=class extends l.Disposable{constructor(i,t,e,n,o){super(),this._sheetSkeletonManagerService=i,this._contextService=t,this._currentUniverService=e,this._renderManagerService=n,this._commandService=o,this._init()}_init(){this._initialRenderRefresh(),this._initCommandListener(),this._initContextListener()}_initialRenderRefresh(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{skeleton:t,unitId:e,sheetId:n}=i,o=this._currentUniverService.getUniverSheetInstance(e),r=o==null?void 0:o.getSheetBySheetId(n);if(o==null||r==null)return;const s=this._renderManagerService.getRenderById(e);if(s==null)return;const{mainComponent:a,components:c}=s,d=a,u=c.get(_e.ROW),h=c.get(_e.COLUMN),m=c.get(_e.LEFT_TOP),{rowHeaderWidth:S,columnHeaderHeight:g}=t;d==null||d.updateSkeleton(t),u==null||u.updateSkeleton(t),h==null||h.updateSkeleton(t),m==null||m.transformByState({width:S,height:g})}))}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{var n,o;const t=this._currentUniverService.getCurrentUniverSheetInstance(),e=t.getUnitId();if(f.COMMAND_LISTENER_SKELETON_CHANGE.includes(i.id)){const r=t.getActiveSheet(),s=r.getSheetId(),a=i.params,{unitId:c,subUnitId:d}=a;if(!(c===t.getUnitId()&&d===r.getSheetId()))return;i.id!==f.SetWorksheetActiveOperation.id&&this._sheetSkeletonManagerService.makeDirty({unitId:c,sheetId:s,commandId:i.id},!0),this._sheetSkeletonManagerService.setCurrent({unitId:c,sheetId:s,commandId:i.id})}else f.COMMAND_LISTENER_VALUE_CHANGE.includes(i.id)&&this._sheetSkeletonManagerService.reCalculate();i.type===l.CommandType.MUTATION&&((o=(n=this._renderManagerService.getRenderById(e))==null?void 0:n.mainComponent)==null||o.makeDirty())}))}_initContextListener(){this._contextService.subscribeContextValue$(w.RENDER_RAW_FORMULA_KEY).pipe(k.distinctUntilChanged()).subscribe(()=>{this._renderManagerService.getRenderAll().forEach(i=>{i.mainComponent instanceof w.Spreadsheet&&i.mainComponent.makeForceDirty(!0)})})}};Zn=$d([l.OnLifecycle(l.LifecycleStages.Ready,Zn),qt(0,P.Inject(A.SheetSkeletonManagerService)),qt(1,l.IContextService),qt(2,l.IUniverInstanceService),qt(3,w.IRenderManagerService),qt(4,l.ICommandService)],Zn);const Ge={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(i,t)=>{const e=i.get(l.ICommandService),n=i.get(l.IUndoRedoService),o=i.get(l.IUniverInstanceService),r=i.get(C.IConfirmService),s=i.get(l.LocaleService),a=t.unitId,c=t.subUnitId,d=t.selections,u=f.getAddMergeMutationRangeByType(d,t.value),h=o.getUniverSheetInstance(a).getSheetBySheetId(c),m=[],S=[],g=Qo(h,u);if(g&&!await r.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:"merge.confirm.title"},cancelText:s.t("merge.confirm.cancel"),confirmText:s.t("merge.confirm.confirm")}))return!1;const _={unitId:a,subUnitId:c,ranges:u},v={unitId:a,subUnitId:c,ranges:u},M=f.RemoveMergeUndoMutationFactory(i,_),R=f.AddMergeUndoMutationFactory(i,v);if(M.ranges.length>0&&m.push({id:f.RemoveWorksheetMergeMutation.id,params:M}),m.push({id:f.AddWorksheetMergeMutation.id,params:v}),S.push({id:f.RemoveWorksheetMergeMutation.id,params:R}),M.ranges.length>0&&S.push({id:f.AddWorksheetMergeMutation.id,params:M}),g){const y=Jo(i,a,h,u);m.unshift(...y.redos),S.push(...y.undos)}const b=f.AddMergeRedoSelectionsOperationFactory(i,t,u);b&&m.push(b);const E=f.AddMergeUndoSelectionsOperationFactory(i,t);return E&&S.push(E),l.sequenceExecute(m,e).result?(n.pushUndoRedo({unitID:a,undoMutations:S,redoMutations:m}),!0):!1}},yr={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async i=>{const t=i.get(l.ICommandService),n=i.get(f.SelectionManagerService).getSelectionRanges(),o=vi(vn.MergeAll,n);if(!(o!=null&&o.length))return!1;const s=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!s)return!1;const a=s.getActiveSheet();if(!a)return!1;const c=s.getUnitId(),d=a.getSheetId();return t.executeCommand(Ge.id,{selections:o,unitId:c,subUnitId:d})}},Or={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async i=>{const t=i.get(l.ICommandService),n=i.get(f.SelectionManagerService).getSelectionRanges(),o=vi(vn.MergeVertical,n);if(!(o!=null&&o.length))return!1;const s=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!s)return!1;const a=s.getActiveSheet();if(!a)return!1;const c=s.getUnitId(),d=a.getSheetId();return t.executeCommand(Ge.id,{value:l.Dimension.COLUMNS,selections:o,unitId:c,subUnitId:d})}},Ar={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async i=>{const t=i.get(l.ICommandService),n=i.get(f.SelectionManagerService).getSelectionRanges(),o=vi(vn.MergeHorizontal,n);if(!(o!=null&&o.length))return!1;const s=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!s)return!1;const a=s.getActiveSheet();if(!a)return!1;const c=s.getUnitId(),d=a.getSheetId();return t.executeCommand(Ge.id,{value:l.Dimension.ROWS,selections:o,unitId:c,subUnitId:d})}},Yi={type:l.CommandType.COMMAND,id:"sheet.command.delete-range-move-left-confirm",handler:async i=>{const t=i.get(C.IConfirmService),e=i.get(l.ICommandService),n=i.get(l.LocaleService),o=i.get(f.SelectionManagerService),r=i.get(l.IUniverInstanceService),s=o.getSelections();if(!s)return!1;const c=r.getCurrentUniverSheetInstance().getActiveSheet();let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const g=l.Rectangle.getIntersects(S,d);return g?u(S)>u(g):!1})||await t.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")})?e.executeCommand(f.DeleteRangeMoveLeftCommand.id):!0}},Xi={type:l.CommandType.COMMAND,id:"sheet.command.delete-range-move-up-confirm",handler:async i=>{const t=i.get(C.IConfirmService),e=i.get(l.ICommandService),n=i.get(l.LocaleService),o=i.get(f.SelectionManagerService),r=i.get(l.IUniverInstanceService),s=o.getSelections();if(!s)return!1;const c=r.getCurrentUniverSheetInstance().getActiveSheet();let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getColumnCount()-1};const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const g=l.Rectangle.getIntersects(S,d);return g?u(S)>u(g):!1})||await t.confirm({id:Xi.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")})?e.executeCommand(f.DeleteRangeMoveUpCommand.id):!0}},$i={type:l.CommandType.COMMAND,id:"sheet.command.insert-range-move-down-confirm",handler:async i=>{const t=i.get(C.IConfirmService),e=i.get(l.ICommandService),n=i.get(l.LocaleService),o=i.get(f.SelectionManagerService),r=i.get(l.IUniverInstanceService),s=o.getSelections();if(!s)return!1;const c=r.getCurrentUniverSheetInstance().getActiveSheet();let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getColumnCount()-1};const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const g=l.Rectangle.getIntersects(S,d);return g?u(S)>u(g):!1})||await t.confirm({id:$i.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")})?e.executeCommand(f.InsertRangeMoveDownCommand.id):!0}},Zi={type:l.CommandType.COMMAND,id:"sheet.command.insert-range-move-right-confirm",handler:async i=>{const t=i.get(C.IConfirmService),e=i.get(l.ICommandService),n=i.get(l.LocaleService),o=i.get(f.SelectionManagerService),r=i.get(l.IUniverInstanceService),s=o.getSelections();if(!s)return!1;const c=r.getCurrentUniverSheetInstance().getActiveSheet();let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const g=l.Rectangle.getIntersects(S,d);return g?u(S)>u(g):!1})||await t.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")})?e.executeCommand(f.InsertRangeMoveRightCommand.id):!0}},xr={id:"sheet.command.refill",type:l.CommandType.COMMAND,handler:async(i,t)=>{const e=i.get(jt);return e.applyType=t.type,!0}},Nr={id:"sheet.command.remove-row-confirm",type:l.CommandType.COMMAND,handler:async(i,t)=>{var d;const e=i.get(f.SelectionManagerService);let n=t==null?void 0:t.range;if(n||(n=(d=e.getLast())==null?void 0:d.range),!n)return!1;const o=i.get(l.ICommandService),c=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance().getActiveSheet().getVisibleRows();if(Wo(c,[n])){const u=i.get(C.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 o.executeCommand(f.RemoveRowCommand.id,{range:n}),!0}},Dr={id:"sheet.command.remove-col-confirm",type:l.CommandType.COMMAND,handler:async(i,t)=>{var d;const e=i.get(f.SelectionManagerService);let n=t==null?void 0:t.range;if(n||(n=(d=e.getLast())==null?void 0:d.range),!n)return!1;const o=i.get(l.ICommandService),c=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance().getActiveSheet().getVisibleCols();if(jo(c,[n])){const u=i.get(C.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 o.executeCommand(f.RemoveColCommand.id,{range:n}),!0}},Pr={id:"sheet.command.remove-sheet-confirm",type:l.CommandType.COMMAND,handler:async(i,t)=>{const{subUnitId:e}=t,n=i.get(C.IConfirmService),o=i.get(l.ICommandService),r=i.get(l.LocaleService);return await n.confirm({id:"sheet.confirm.remove-sheet",title:{title:r.t("sheetConfig.deleteSheet")},children:{title:r.t("sheetConfig.deleteSheetContent")},cancelText:r.t("button.cancel"),confirmText:r.t("button.confirm")})?(await o.executeCommand(f.RemoveSheetCommand.id,{subUnitId:e}),!0):!1}},Ot=P.createIdentifier("univer.sheetbar-service");class Zd extends l.Disposable{constructor(){super();I(this,"renameId$");I(this,"removeId$");I(this,"scroll$");I(this,"scrollX$");I(this,"addSheet$");I(this,"_renameId$");I(this,"_removeId$");I(this,"_scroll$");I(this,"_scrollX$");I(this,"_addSheet$");I(this,"_currentHandler",null);this._renameId$=new k.Subject,this.renameId$=this._renameId$.asObservable(),this._removeId$=new k.Subject,this.removeId$=this._removeId$.asObservable(),this._scroll$=new k.Subject,this.scroll$=this._scroll$.asObservable(),this._scrollX$=new k.Subject,this.scrollX$=this._scrollX$.asObservable(),this._addSheet$=new k.Subject,this.addSheet$=this._addSheet$.asObservable()}setRenameId(e){this._renameId$.next(e)}setRemoveId(e){this._removeId$.next(e)}setScroll(e){this._scroll$.next(e)}setScrollX(e){this._scrollX$.next(e)}setAddSheet(e){this._addSheet$.next(e)}triggerSheetBarMenu(){var e;(e=this._currentHandler)==null||e.handleSheetBarMenu()}registerSheetBarMenuHandler(e){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=e,l.toDisposable(()=>{this._currentHandler=null})}}const Lr={id:"ui-sheet.command.show-menu-list",type:l.CommandType.OPERATION,handler:async i=>(i.get(Ot).triggerSheetBarMenu(),!0)},Ur={id:"sheet.operation.rename-sheet",type:l.CommandType.OPERATION,handler:async(i,t)=>{const e=i.get(Ot);return t&&e.setRenameId(t.subUnitId),!0}};var Oe=function(){return Oe=Object.assign||function(i){for(var t,e=1,n=arguments.length;e<n;e++){t=arguments[e];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(i[o]=t[o])}return i},Oe.apply(this,arguments)},Gd=function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(i);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(i,n[o])&&(e[n[o]]=i[n[o]]);return e},Ce=L.forwardRef(function(i,t){var e=i.icon,n=i.id,o=i.className,r=i.extend,s=Gd(i,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),c=L.useRef("_".concat(Jd()));return Hr(e,"".concat(n),{defIds:e.defIds,idSuffix:c.current},Oe({ref:t,className:a},s),r)});function Hr(i,t,e,n,o){return L.createElement(i.tag,Oe(Oe({key:t},Kd(i,e,o)),n),(Qd(i,e).children||[]).map(function(r,s){return Hr(r,"".concat(t,"-").concat(i.tag,"-").concat(s),e,void 0,o)}))}function Kd(i,t,e){var n=Oe({},i.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1);var o=t.defIds;return!o||o.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],a=r[1];typeof a=="string"&&(n[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Qd(i,t){var e,n=t.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((e=i.children)===null||e===void 0)&&e.length)?Oe(Oe({},i),{children:i.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?Oe(Oe({},o),{attrs:Oe(Oe({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):i}function Jd(){return Math.random().toString(36).substring(2,8)}Ce.displayName="UniverIcon";var qd={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"}}]},Vr=L.forwardRef(function(i,t){return L.createElement(Ce,Object.assign({},i,{id:"autofill",ref:t,icon:qd}))});Vr.displayName="Autofill";const eu=Vr;var tu={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"}}]},kr=L.forwardRef(function(i,t){return L.createElement(Ce,Object.assign({},i,{id:"check-mark-single",ref:t,icon:tu}))});kr.displayName="CheckMarkSingle";const en=kr;var nu={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"}}]},Br=L.forwardRef(function(i,t){return L.createElement(Ce,Object.assign({},i,{id:"close-single",ref:t,icon:nu}))});Br.displayName="CloseSingle";const iu=Br;var ou={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1213",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{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"}}]}]},Fr=L.forwardRef(function(i,t){return L.createElement(Ce,Object.assign({},i,{id:"convert-single",ref:t,icon:ou}))});Fr.displayName="ConvertSingle";const ru=Fr;var su={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6.78662 6.17993C7.12169 6.17993 7.39331 6.45156 7.39331 6.78662V10.7301C7.39331 11.0652 7.12169 11.3368 6.78662 11.3368 6.45156 11.3368 6.17993 11.0652 6.17993 10.7301V6.78662C6.17993 6.45156 6.45156 6.17993 6.78662 6.17993zM9.82007 6.78662C9.82007 6.45156 9.54844 6.17993 9.21338 6.17993 8.87831 6.17993 8.60669 6.45156 8.60669 6.78662V10.7301C8.60669 11.0652 8.87831 11.3368 9.21338 11.3368 9.54844 11.3368 9.82007 11.0652 9.82007 10.7301V6.78662z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.57094 1.32642C6.34938 1.32642 6.14544 1.44719 6.03894 1.64148L5.21395 3.14648H1.93311C1.59804 3.14648 1.32642 3.41811 1.32642 3.75317C1.32642 4.08824 1.59804 4.35986 1.93311 4.35986H2.84314V14.0669C2.84314 14.402 3.11476 14.6736 3.44983 14.6736H12.5502C12.8852 14.6736 13.1569 14.402 13.1569 14.0669V4.35986H14.0669C14.402 4.35986 14.6736 4.08824 14.6736 3.75317C14.6736 3.41811 14.402 3.14648 14.0669 3.14648H10.7895L9.98357 1.64602C9.87785 1.4492 9.67252 1.32642 9.44911 1.32642H6.57094ZM9.4122 3.14648L9.08632 2.53979H6.93024L6.59767 3.14648H9.4122ZM4.05652 4.35986V13.4602H11.9435V4.35986H4.05652Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Wr=L.forwardRef(function(i,t){return L.createElement(Ce,Object.assign({},i,{id:"delete-single",ref:t,icon:su}))});Wr.displayName="DeleteSingle";const au=Wr;var lu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_371_77",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_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"}}]}]},jr=L.forwardRef(function(i,t){return L.createElement(Ce,Object.assign({},i,{id:"dropdown-single",ref:t,icon:lu}))});jr.displayName="DropdownSingle";const zr=jr;var cu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M0 0H16V16H0z",opacity:.01}},{tag:"path",attrs:{fill:"currentColor",d:"M8.09973 1.50049C4.51022 1.50049 1.59973 4.41098 1.59973 8.00049C1.59973 11.59 4.51022 14.5005 8.09973 14.5005C11.6892 14.5005 14.5997 11.59 14.5997 8.00049C14.5997 4.41098 11.6892 1.50049 8.09973 1.50049ZM10.4995 10.4701L9.5419 10.4657L8.09971 8.74643L6.65897 10.4643L5.69993 10.4686C5.63609 10.4686 5.58386 10.4179 5.58386 10.3526C5.58386 10.325 5.59402 10.2989 5.61143 10.2771L7.49904 8.02824L5.61143 5.7808C5.59402 5.75904 5.58386 5.73292 5.58386 5.70536C5.58386 5.64152 5.63609 5.58929 5.69993 5.58929L6.65897 5.59364L8.09971 7.31295L9.54045 5.59509L10.498 5.59074C10.5619 5.59074 10.6141 5.64152 10.6141 5.70681C10.6141 5.73438 10.604 5.76049 10.5865 5.78225L8.70183 8.02969L10.588 10.2786C10.6054 10.3003 10.6156 10.3265 10.6156 10.354C10.6156 10.4179 10.5633 10.4701 10.4995 10.4701Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Yr=L.forwardRef(function(i,t){return L.createElement(Ce,Object.assign({},i,{id:"error-single",ref:t,icon:cu}))});Yr.displayName="ErrorSingle";const Xr=Yr;var du={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"}}]},$r=L.forwardRef(function(i,t){return L.createElement(Ce,Object.assign({},i,{id:"eyelash-single",ref:t,icon:du}))});$r.displayName="EyelashSingle";const uu=$r;var hu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_367_60",style:{maskType:"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"}}]}]},Zr=L.forwardRef(function(i,t){return L.createElement(Ce,Object.assign({},i,{id:"fx-single",ref:t,icon:hu}))});Zr.displayName="FxSingle";const mu=Zr;var Su={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_249",style:{maskType:"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"}}]}]},Gr=L.forwardRef(function(i,t){return L.createElement(Ce,Object.assign({},i,{id:"increase-single",ref:t,icon:Su}))});Gr.displayName="IncreaseSingle";const Kr=Gr;var gu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_556",style:{maskType:"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"}}]}]},Qr=L.forwardRef(function(i,t){return L.createElement(Ce,Object.assign({},i,{id:"more-down-single",ref:t,icon:gu}))});Qr.displayName="MoreDownSingle";const Gn=Qr;var _u={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"}}]},Jr=L.forwardRef(function(i,t){return L.createElement(Ce,Object.assign({},i,{id:"more-single",ref:t,icon:_u}))});Jr.displayName="MoreSingle";const qr=Jr;var fu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1204",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_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"}}]}]},es=L.forwardRef(function(i,t){return L.createElement(Ce,Object.assign({},i,{id:"paint-bucket",ref:t,icon:fu}))});es.displayName="PaintBucket";const pu=es;var vu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.40051 8.00049C1.40051 4.41098 4.311 1.50049 7.90051 1.50049C11.49 1.50049 14.4005 4.41098 14.4005 8.00049C14.4005 11.59 11.49 14.5005 7.90051 14.5005C4.311 14.5005 1.40051 11.59 1.40051 8.00049ZM7.31368 5.3379L7.56087 9.33424H8.24066L8.49816 5.3379L8.51876 4.12252H7.28278L7.31368 5.3379ZM7.07678 11.0646C7.07678 11.5693 7.44758 11.8783 7.90077 11.8783C8.35396 11.8783 8.72476 11.5693 8.72476 11.0646C8.72476 10.5805 8.35396 10.2612 7.90077 10.2612C7.44758 10.2612 7.07678 10.5805 7.07678 11.0646Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ts=L.forwardRef(function(i,t){return L.createElement(Ce,Object.assign({},i,{id:"warning-single",ref:t,icon:vu}))});ts.displayName="WarningSingle";const ns=ts,Cu=()=>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"})]}),Iu=()=>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"})]}),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:"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"})]}),Ru=()=>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"})]}),bu=()=>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"})}),wu=()=>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"})]}),Tu=()=>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"})]}),Eu=()=>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"})]}),yu=()=>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"})}),is=()=>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 os(i){const{type:t=l.BorderStyleTypes.THIN}=i;switch(t){case l.BorderStyleTypes.DASH_DOT:return p.jsx(Cu,{});case l.BorderStyleTypes.DASH_DOT_DOT:return p.jsx(Iu,{});case l.BorderStyleTypes.DASHED:return p.jsx(Mu,{});case l.BorderStyleTypes.HAIR:return p.jsx(Ru,{});case l.BorderStyleTypes.MEDIUM:return p.jsx(bu,{});case l.BorderStyleTypes.MEDIUM_DASH_DOT:return p.jsx(wu,{});case l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return p.jsx(Tu,{});case l.BorderStyleTypes.MEDIUM_DASHED:return p.jsx(Eu,{});case l.BorderStyleTypes.THICK:return p.jsx(yu,{});case l.BorderStyleTypes.THIN:return p.jsx(is,{});default:return p.jsx(is,{})}}const Ve={uiPluginSheetsBorderPanel:"univer-ui-plugin-sheets-border-panel",uiPluginSheetsBorderPanelPosition:"univer-ui-plugin-sheets-border-panel-position",uiPluginSheetsBorderPanelPositionItem:"univer-ui-plugin-sheets-border-panel-position-item",uiPluginSheetsBorderPanelPositionItemActive:"univer-ui-plugin-sheets-border-panel-position-item-active",uiPluginSheetsBorderPanelStyles:"univer-ui-plugin-sheets-border-panel-styles",uiPluginSheetsBorderPanelBoard:"univer-ui-plugin-sheets-border-panel-board",uiPluginSheetsBorderPanelButton:"univer-ui-plugin-sheets-border-panel-button",uiPluginSheetsBorderPanelMoreIcon:"univer-ui-plugin-sheets-border-panel-more-icon"},rs=`${bt}_BORDER_PANEL_COMPONENT`,ss=[{label:"borderLine.borderTop",icon:"UpBorder",value:"top"},{label:"borderLine.borderBottom",icon:"DownBorder",value:"bottom"},{label:"borderLine.borderLeft",icon:"LeftBorder",value:"left"},{label:"borderLine.borderRight",icon:"RightBorder",value:"right"},{label:"borderLine.borderNone",icon:"NoBorderSingle",value:"none"},{label:"borderLine.borderAll",icon:"AllBorderSingle",value:"all"},{label:"borderLine.borderOutside",icon:"OuterBorder",value:"outside"},{label:"borderLine.borderInside",icon:"InnerBorder",value:"inside"},{label:"borderLine.borderHorizontal",icon:"HorizontalBorder",value:"horizontal"},{label:"borderLine.borderVertical",icon:"VerticalBorder",value:"vertical"},{label:"borderLine.borderTlbr",icon:"BackSlashSingle",value:"tlbr"},{label:"borderLine.borderTlbcTlmr",icon:"LeftDoubleDiagonalSingle",value:"tlbc_tlmr"},{label:"borderLine.borderTlbrTlbcTlmr",icon:"LeftTridiagonalSingle",value:"tlbr_tlbc_tlmr"},{label:"borderLine.borderBlTr",icon:"SlashSingle",value:"bltr"},{label:"borderLine.borderMltrBctr",icon:"RightDoubleDiagonalSingle",value:"mltr_bctr"}],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 Au(i){var c;const t=Z.useDependency(C.ComponentManager),e=Z.useDependency(f.BorderStyleManagerService),{onChange:n,value:o}=i;function r(d,u){n==null||n({...o,[u]:d})}function s(d){const u=t.get(d);return u&&p.jsx(u,{extend:{colorChannel1:"rgb(var(--primary-color))"}})}function a(d){d.stopPropagation()}return p.jsxs("section",{className:Ve.uiPluginSheetsBorderPanel,children:[p.jsx("div",{className:Ve.uiPluginSheetsBorderPanelPosition,children:ss.map(d=>p.jsx("div",{className:e.getBorderInfo().type===d.value?`${Ve.uiPluginSheetsBorderPanelPositionItemActive} ${Ve.uiPluginSheetsBorderPanelPositionItem}`:Ve.uiPluginSheetsBorderPanelPositionItem,onClick:u=>{u.stopPropagation(),r(d.value,"type")},children:s(d.icon)},d.value))}),p.jsxs("div",{className:Ve.uiPluginSheetsBorderPanelStyles,children:[p.jsx("div",{children:p.jsx(le.Dropdown,{align:{offset:[0,18]},overlay:p.jsx("section",{className:Ve.uiPluginSheetsBorderPanelBoard,onClick:a,children:p.jsx(le.ColorPicker,{onChange:d=>r(d,"color")})}),children:p.jsxs("a",{className:Ve.uiPluginSheetsBorderPanelButton,onClick:a,children:[p.jsx(pu,{extend:{colorChannel1:(c=o.color)!=null?c:"rgb(var(--primary-color))"}}),p.jsx("span",{className:Ve.uiPluginSheetsBorderPanelMoreIcon,children:p.jsx(Gn,{})})]})})}),p.jsx("div",{children:p.jsx(le.Dropdown,{align:{offset:[0,18]},overlay:p.jsx("section",{onClick:a,children:p.jsx(le.Menu,{children:Ou.map(d=>p.jsx(le.MenuItem,{eventKey:d.value.toString(),onClick:()=>r(d.value,"style"),children:p.jsx(os,{type:d.value})},d.value))})}),children:p.jsxs("a",{className:Ve.uiPluginSheetsBorderPanelButton,onClick:a,children:[p.jsx(os,{type:l.BorderStyleTypes.THIN}),p.jsx("span",{className:Ve.uiPluginSheetsBorderPanelMoreIcon,children:p.jsx(Gn,{})})]})})})]})]})}const xu={countBar:"univer-count-bar"},Nu=[50,80,100,130,150,170,200,400];function Du(){const i=Z.useDependency(l.ICommandService),t=Z.useDependency(l.IUniverInstanceService),e=L.useCallback(()=>{const s=t.getCurrentUniverSheetInstance().getActiveSheet().getZoomRatio()*100||100;return Math.round(s)},[t]),[n,o]=L.useState(()=>e());L.useEffect(()=>i.onCommandExecuted(a=>{if(a.id===Pe.id||a.id===f.SetWorksheetActivateCommand.id){const c=e();o(c)}}).dispose,[i,e]);function r(s){o(s);const a=t.getCurrentUniverSheetInstance(),c=a==null?void 0:a.getActiveSheet();if(c==null)return;const d=s/100;i.executeCommand(Ln.id,{unitId:a.getUnitId(),subUnitId:c.getSheetId(),zoomRatio:d})}return p.jsx(le.Slider,{min:ci[0],value:n,shortcuts:Nu,onChange:r})}function Pu(i){return p.jsx("section",{className:xu.countBar,children:p.jsx(Du,{})})}const as={editorContainer:"univer-editor-container",editorInput:"univer-editor-input"},Kn=-1e3,ls={width:0,height:0,top:Kn,left:Kn},Lu=()=>{const[i,t]=L.useState({...ls}),e=Z.useDependency(Xt),n=Z.useDependency(C.IEditorService),o=Z.useDependency(l.IContextService),r=C.useObservable(()=>o.subscribeContextValue$(C.DISABLE_AUTO_FOCUS_KEY),!1,void 0,[o,C.DISABLE_AUTO_FOCUS_KEY]),s={id:l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:{dataStream:`${l.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{}};return L.useEffect(()=>{e.state$.subscribe(a=>{if(a==null)return;const{startX:c=Kn,startY:d=Kn,endX:u=0,endY:h=0,show:m=!1}=a;if(!m)t({...ls});else{t({width:u-c-w.FIX_ONE_PIXEL_BLUR_OFFSET,height:h-d-w.FIX_ONE_PIXEL_BLUR_OFFSET,left:c+w.FIX_ONE_PIXEL_BLUR_OFFSET,top:d+w.FIX_ONE_PIXEL_BLUR_OFFSET});const S=n.getEditor(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(S==null)return;const{left:g,top:_,width:v,height:M}=S.getBoundingClientRect();e.setRect({left:g,top:_,width:v,height:M})}})},[]),L.useEffect(()=>{r||e.setFocus(!0)},[r,i]),p.jsx("div",{className:as.editorContainer,style:{left:i.left,top:i.top,width:i.width,height:i.height},children:p.jsx(C.TextEditor,{id:l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,className:as.editorInput,snapshot:s,cancelDefaultResizeListener:!0,isSheetEditor:!0,isSingle:!1})})},ue={definedName:"univer-defined-name",definedNameDropDown:"univer-defined-name-drop-down",definedNameOverlay:"univer-defined-name-overlay",definedNameOverlayContainer:"univer-defined-name-overlay-container",definedNameOverlayItem:"univer-defined-name-overlay-item",definedNameOverlayItemName:"univer-defined-name-overlay-item-name",definedNameOverlayItemNameForSheet:"univer-defined-name-overlay-item-name-for-sheet",definedNameOverlayItemFormula:"univer-defined-name-overlay-item-formula",definedNameOverlayManager:"univer-defined-name-overlay-manager",definedNameOverlayManagerTitle:"univer-defined-name-overlay-manager-title",definedNameOverlayManagerContent:"univer-defined-name-overlay-manager-content",definedNameContainer:"univer-defined-name-container",definedNameContainerScroll:"univer-defined-name-container-scroll",definedNameContainerAddButton:"univer-defined-name-container-addButton",definedNameContainerAddButtonText:"univer-defined-name-container-addButton-text",definedNameContainerItem:"univer-defined-name-container-item",definedNameContainerItemName:"univer-defined-name-container-item-name",definedNameContainerItemNameForSheet:"univer-defined-name-container-item-name-for-sheet",definedNameContainerItemFormulaOrRefString:"univer-defined-name-container-item-formula-or-refString",definedNameContainerItemUpdate:"univer-defined-name-container-item-update",definedNameContainerItemDelete:"univer-defined-name-container-item-delete",definedNameContainerItemShow:"univer-defined-name-container-item-show",definedNameInput:"univer-defined-name-input",definedNameInputValidation:"univer-defined-name-input-validation"},cs="DefinedNameContainer",Gi="AllDefaultWorkbook",ds={id:"sidebar.operation.defined-name",type:l.CommandType.COMMAND,handler:async(i,t)=>{const e=i.get(C.ISidebarService),n=i.get(C.IEditorService),o=i.get(l.LocaleService),s=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();switch(t.value){case"open":n.setOperationSheetUnitId(s.getUnitId()),e.open({header:{title:o.t("definedName.featureTitle")},children:{label:cs},onClose:()=>{n.closeRangePrompt()},width:333});break;case"close":default:e.close();break}return!0}};function Uu(i){const t=Z.useDependency(l.ICommandService),e=Z.useDependency(l.LocaleService),n=Z.useDependency(K.IDefinedNamesService),s=Z.useDependency(l.IUniverInstanceService).getCurrentUniverSheetInstance().getUnitId(),a=()=>{const m=n.getDefinedNameMap(s);return m?Array.from(Object.values(m)):[]},[c,d]=L.useState(a());L.useEffect(()=>{const m=n.update$.subscribe(()=>{d(a())});return()=>{m.unsubscribe()}},[]);const u=()=>{t.executeCommand(ds.id,{value:"open"})},h=m=>{n.focusRange(s,m.id)};return p.jsxs("div",{className:ue.definedNameOverlay,children:[p.jsx("div",{className:ue.definedNameOverlayContainer,children:c.map((m,S)=>p.jsxs("div",{className:ue.definedNameOverlayItem,onClick:()=>{h(m)},children:[p.jsx("div",{className:ue.definedNameOverlayItemName,title:m.name,children:m.name}),p.jsx("div",{className:ue.definedNameOverlayItemFormula,title:m.formulaOrRefString,children:m.formulaOrRefString})]},S))}),p.jsxs("div",{className:ue.definedNameOverlayManager,onClick:u,children:[p.jsx("div",{className:ue.definedNameOverlayManagerTitle,children:e.t("definedName.managerTitle")}),p.jsx("div",{className:ue.definedNameOverlayManagerContent,children:e.t("definedName.managerDescription")})]})]})}function Hu(){const[i,t]=L.useState(""),e=Z.useDependency(K.IDefinedNamesService);return L.useEffect(()=>{const n=e.currentRange$.subscribe(()=>{t(e.getCurrentRangeForString())});return()=>{n.unsubscribe()}},[]),p.jsxs("div",{className:ue.definedName,children:[p.jsx(le.Input,{value:i,type:"text",size:"small",affixWrapperStyle:{border:"none",paddingLeft:"6px",paddingRight:"6px"}}),p.jsx(le.Dropdown,{overlay:p.jsx(Uu,{}),children:p.jsx("div",{className:ue.definedNameDropDown,children:p.jsx(Gn,{})})})]})}const Se={formulaBox:"univer-formula-box",nameRanges:"univer-name-ranges",formulaBar:"univer-formula-bar",formulaIcon:"univer-formula-icon",formulaIconWrapper:"univer-formula-icon-wrapper",iconContainer:"univer-icon-container",iconContainerSuccess:"univer-icon-container-success",formulaActive:"univer-formula-active",iconContainerError:"univer-icon-container-error",iconContainerFx:"univer-icon-container-fx",formulaInput:"univer-formula-input",formulaContent:"univer-formula-content",arrowContainer:"univer-arrow-container"};function Vu(){const[i,t]=L.useState(Se.formulaGrey),[e,n]=L.useState(0),o=Z.useDependency(wn),r=Z.useDependency(we),s={id:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:`${l.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},marginTop:5,marginBottom:5,marginRight:0,marginLeft:0,paragraphLineGapDefault:0,renderConfig:{horizontalAlign:l.HorizontalAlign.UNSPECIFIED,verticalAlign:l.VerticalAlign.TOP,centerAngle:0,vertexAngle:0,wrapStrategy:l.WrapStrategy.WRAP}}};L.useEffect(()=>{r.visible$.subscribe(m=>{t(m.visible?Se.formulaActive:Se.formulaGrey)})},[]);function a(m){if(m==null)return;const S=m.getBoundingClientRect();o.setPosition(S)}function c(){n(e===0?1:0),setTimeout(()=>{o.handleFoldBtnClick(e===1)},150)}function d(){r.isVisible().visible&&r.changeVisible({visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:C.KeyCode.ESC})}function u(){r.isVisible().visible&&r.changeVisible({visible:!1,eventType:w.DeviceInputEventType.PointerDown})}function h(){o.handleFxBtnClick(!0)}return p.jsxs("div",{className:Se.formulaBox,style:{height:e===0?"28px":"82px"},children:[p.jsx("div",{className:Se.nameRanges,children:p.jsx(Hu,{})}),p.jsxs("div",{className:Se.formulaBar,children:[p.jsx("div",{className:Se.formulaIcon,children:p.jsxs("div",{className:Se.formulaIconWrapper,children:[p.jsx("span",{className:xe(Se.iconContainer,Se.iconContainerError,i),onClick:d,children:p.jsx(iu,{})}),p.jsx("span",{className:xe(Se.iconContainer,Se.iconContainerSuccess,i),onClick:u,children:p.jsx(en,{})}),p.jsx("span",{className:xe(Se.iconContainer,Se.iconContainerFx),onClick:h,children:p.jsx(mu,{})})]})}),p.jsxs("div",{className:Se.formulaInput,children:[p.jsx(C.TextEditor,{id:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,isSheetEditor:!0,resizeCallBack:a,cancelDefaultResizeListener:!0,onContextMenu:m=>m.preventDefault(),className:Se.formulaContent,snapshot:s,isSingle:!1}),p.jsx("div",{className:Se.arrowContainer,onClick:c,children:e===0?p.jsx(zr,{}):p.jsx(zr,{style:{transform:"rotateZ(180deg)"}})})]})]})]})}const dt={operateContainer:"univer-operate-container",autoFillPopupMenu:"univer-auto-fill-popup-menu",autoFillPopupMenuItem:"univer-auto-fill-popup-menu-item",autoFillPopupMenuItemIcon:"univer-auto-fill-popup-menu-item-icon",autoFillPopupMenuItemTitle:"univer-auto-fill-popup-menu-item-title",autoFillPopupMenuItemHide:"univer-auto-fill-popup-menu-item-hide",btnContainer:"univer-btn-container",btnContainerExpand:"univer-btn-container-expand"},ku=()=>{const[,i]=L.useState({});return L.useCallback(()=>i(t=>!t),[])},Bu=()=>{var ne;const i=Z.useDependency(l.ICommandService),t=Z.useDependency(A.SheetSkeletonManagerService),e=Z.useDependency(l.IUniverInstanceService),n=Z.useDependency(w.IRenderManagerService),o=Z.useDependency(fe),r=Z.useDependency(jt),s=Z.useDependency(l.LocaleService),[a,c]=L.useState([]),[d,u]=L.useState(!1),[h,m]=L.useState({row:-1,col:-1}),[S,g]=L.useState(oe.SERIES),[_,v]=L.useState(!1),M=()=>{v(!0)},R=()=>{v(!1)},b=ku(),E=Ie(e,n);if(E==null)return null;const{scene:T}=E;if(L.useEffect(()=>{const U=[Te.id,gn.id,Pe.id,f.SetWorksheetActiveOperation.id,f.MoveRangeMutation.id];return i.onCommandExecuted(G=>{G.id===nt.id&&b(),U.includes(G.id)&&m({row:-1,col:-1})}).dispose},[b,i]),L.useEffect(()=>l.toDisposable(r.menu$.subscribe(W=>{c(W.map(G=>({...G,index:W.indexOf(G)})))})).dispose,[r]),L.useEffect(()=>l.toDisposable(r.showMenu$.subscribe(W=>{const{source:G,target:q}=r.autoFillLocation||{source:null,target:null};if(W&&G&&q){const re=l.Rectangle.union(G,q);m({row:re.endRow,col:re.endColumn})}})).dispose,[r]),L.useEffect(()=>l.toDisposable(r.applyType$.subscribe(W=>{g(W)})).dispose,[r]),L.useEffect(()=>{function U(){u(!1)}return document.addEventListener("wheel",U),()=>{document.removeEventListener("wheel",U)}},[d]),h.col<0||h.row<0)return null;const y=(ne=t.getCurrent())==null?void 0:ne.skeleton,O=o.getViewPort(),x=T==null?void 0:T.scaleX,N=T==null?void 0:T.scaleY,V=T==null?void 0:T.getScrollXY(O);if(!x||!T||!x||!N||!V)return null;const D=(y==null?void 0:y.getNoMergeCellPositionByIndex(h.row,h.col).endX)||0,H=(y==null?void 0:y.getNoMergeCellPositionByIndex(h.row,h.col).endY)||0,B=y==null?void 0:y.convertTransformToOffsetX(D,x,V),j=y==null?void 0:y.convertTransformToOffsetY(H,N,V);if(B==null||j==null)return null;const X=U=>{u(U)},z=U=>{i.executeCommand(xr.id,{type:U.value})},$=d||_,ee=a.filter(U=>!U.disable);return p.jsx("div",{onMouseEnter:M,onMouseLeave:R,style:{left:`${B+2}px`,top:`${j+2}px`,position:"absolute"},children:p.jsx(le.Dropdown,{placement:"bottomLeft",trigger:["click"],overlay:p.jsx("ul",{className:dt.autoFillPopupMenu,children:ee.map(U=>p.jsxs("li",{onClick:()=>z(U),className:dt.autoFillPopupMenuItem,children:[p.jsx("span",{className:dt.autoFillPopupMenuItemIcon,children:U.value===S&&p.jsx(en,{style:{color:"rgb(var(--green-700, #409f11))"}})}),p.jsx("span",{className:dt.autoFillPopupMenuItemTitle,children:s.t(U.label)})]},U.index))}),visible:d,onVisibleChange:X,children:p.jsxs("div",{className:xe(dt.btnContainer,{[dt.btnContainerExpand]:d}),children:[p.jsx(eu,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),$&&p.jsx(Gn,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},Fu=()=>p.jsx("div",{className:dt.operateContainer,children:p.jsx(Bu,{})}),Qn={sheetBar:"univer-sheet-bar",sheetBarOptions:"univer-sheet-bar-options",sheetBarOptionsDivider:"univer-sheet-bar-options-divider"},Wu={sheetBarBtn:"univer-sheet-bar-btn"};function Jn(i){const{children:t,className:e,style:n,disabled:o=!1,onClick:r,...s}=i,a=c=>{if(o){c.preventDefault();return}r&&r(c)};return p.jsx("button",{className:Wu.sheetBarBtn,style:n,disabled:o,onClick:a,...s,children:t})}const ot={sheetBarMenu:"univer-sheet-bar-menu",sheetBarMenuItem:"univer-sheet-bar-menu-item",sheetBarMenuItemIcon:"univer-sheet-bar-menu-item-icon",sheetBarMenuItemHide:"univer-sheet-bar-menu-item-hide",sheetBarMenuItemSelect:"univer-sheet-bar-menu-item-select",sheetBarMenuItemLabel:"univer-sheet-bar-menu-item-label"};function ju(i){const{style:t}=i,[e,n]=L.useState([]),[o,r]=L.useState(!1),s=Z.useDependency(l.IUniverInstanceService),a=Z.useDependency(l.ICommandService),c=Z.useDependency(Ot),d=s.getCurrentUniverSheetInstance(),u=_=>{const{sheetId:v}=_;v&&(_.hidden?a.executeCommand(f.SetWorksheetShowCommand.id,{value:v}):_.selected||a.executeCommand(f.SetWorksheetActivateCommand.id,{unitId:d.getUnitId(),subUnitId:v}),r(!1))};L.useEffect(()=>{m();const _=new l.DisposableCollection;return _.add(h()),_.add(c.registerSheetBarMenuHandler({handleSheetBarMenu:S})),()=>{_.dispose()}},[]);const h=()=>a.onCommandExecuted(_=>{switch(_.id){case f.SetWorksheetHideMutation.id:case f.RemoveSheetMutation.id:case f.SetWorksheetNameMutation.id:case f.InsertSheetMutation.id:case f.SetWorksheetOrderMutation.id:case f.SetWorksheetActiveOperation.id:m();break}}),m=()=>{const _=d.getSheets(),v=d.getActiveSheet(),M=_.map((R,b)=>({label:R.getName(),index:`${b}`,sheetId:R.getSheetId(),hidden:R.isSheetHidden()===l.BooleanNumber.TRUE,selected:v===R}));n(M)};function S(){r(!0)}const g=_=>{r(_)};return p.jsx(le.Dropdown,{placement:"topLeft",trigger:["click"],overlay:p.jsx("ul",{className:ot.sheetBarMenu,style:{...t},children:e.map(_=>p.jsxs("li",{onClick:()=>u(_),className:_.selected?`${ot.sheetBarMenuItem} ${ot.sheetBarMenuItemSelect}`:_.hidden?`${ot.sheetBarMenuItem} ${ot.sheetBarMenuItemHide}`:ot.sheetBarMenuItem,children:[p.jsx("span",{className:ot.sheetBarMenuItemIcon,children:_.selected?p.jsx(en,{}):_.hidden?p.jsx(uu,{}):p.jsx(en,{})}),p.jsx("span",{className:ot.sheetBarMenuItemLabel,children:_.label})]},_.index))}),visible:o,onVisibleChange:g,children:p.jsx(Jn,{children:p.jsx(ru,{})})})}const Ae={slideTabBarContainer:"univer-slide-tab-bar-container",slideTabBar:"univer-slide-tab-bar",slideTabItem:"univer-slide-tab-item",slideTabActive:"univer-slide-tab-active",slideTabSpan:"univer-slide-tab-span",slideTabSpanEdit:"univer-slide-tab-span-edit",slideTabItemDropdown:"univer-slide-tab-item-dropdown"};function zu(i){const{sheetId:t,label:e,color:n,selected:o}=i,[r,s]=L.useState(o),a=Z.useDependency(l.ThemeService);L.useEffect(()=>{s(o)},[o]);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":t,className:r?`${Ae.slideTabActive} ${Ae.slideTabItem}`:Ae.slideTabItem,style:{backgroundColor:!r&&n?n:"",color:!r&&n?c(n):"",boxShadow:r&&n?`0px 0px 8px rgba(0, 0, 0, 0.08), inset 0px -2px 0px 0px ${n}`:""},children:p.jsx("span",{className:Ae.slideTabSpan,children:e})},t)}const Yu={easeOutStrong(i,t,e,n){return-e*((i=i/n-1)*i*i*i-1)+t},backOut(i,t,e,n,o){return typeof o>"u"&&(o=.7),e*((i=i/n-1)*i*((o+1)*i+o)+1)+t}},Xu={loop:!1,begin:0,end:0,duration:300,delay:0,type:"easeOutStrong",receive(i){},success(i){},cancel(i){},complete(i){}};class $u{constructor(t){I(this,"_config");I(this,"_status",0);I(this,"_start",0);I(this,"_handle",0);I(this,"_delayHandle",null);this._config={...Xu,...t},this._config.loop&&(this._config.complete=()=>{},this._config.success=()=>{this.request()})}static success(...t){let e=0;return new Promise(n=>{for(let o=0;o<t.length;o++){const r=t[o],s=r._config,a=s.success;s.loop||(s.success=d=>{e++,a&&a.call(r,d),e===t.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 t=Date.now()-this._start;t=t>=this._config.duration?this._config.duration:t;const n=Yu[this._config.type](t,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(t===this._config.duration){this._config.success(n),this._config.complete(n);return}this._handle=requestAnimationFrame(()=>{this._fakeHandle()})}}class ut{constructor(t,e){I(this,"_slideTabItem");I(this,"_animate");I(this,"_midline",0);I(this,"_translateX");I(this,"_scrollbar");I(this,"_slideTabBar");I(this,"_editMode");I(this,"_placeholder");this._slideTabItem=t,this._animate=null,this._translateX=0,this._editMode=!1,this._slideTabBar=e,this._placeholder=null,this._scrollbar=e.getScrollbar(),this.update()}static midline(t){return t.getBoundingRect().x+t.getBoundingRect().width/2}static leftLine(t){return t.getBoundingRect().x}static rightLine(t){return t.getBoundingRect().x+t.getBoundingRect().width}static make(t,e){const n=[];return t.forEach(o=>n.push(new ut(o,e))),n}getSlideTabItem(){return this._slideTabItem}getEditor(){return this._slideTabItem.querySelector("span")}focus(){var t;(t=this.getEditor())==null||t.focus()}selectAll(){const t=this.getEditor();t&&At.keepSelectAll(t)}isEditMode(){return this._editMode}classList(){return this._slideTabItem.classList}translateX(t){return this._translateX=t,this._slideTabItem.style.transform=`translateX(${t}px)`,this.getTranslateXDirection()}setEditor(t){let e=!0;if(this._editMode===!1){const n=this._slideTabItem.querySelector("span"),o=d=>{if(!this.nameCheck()){if(this._editMode=!1,n&&(n.removeAttribute("contentEditable"),n.removeEventListener("blur",o),n.removeEventListener("compositionstart",s),n.removeEventListener("compositionend",a),n.removeEventListener("input",c),n.removeEventListener("keydown",r),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)}t&&t(d)}};let r=d=>{n&&(d.stopPropagation(),d.key==="Enter"&&n.blur())};const s=d=>{e=!1},a=d=>{e=!0},c=d=>{if(!n)return;const u=50;setTimeout(()=>{if(e){const h=n.innerText;h.length>u&&(n.innerText=h.substring(0,u),At.keepLastIndex(n))}},0)};n&&(n.setAttribute("contentEditable","true"),n.addEventListener("blur",o),n.addEventListener("compositionstart",s),n.addEventListener("compositionend",a),n.addEventListener("input",c),n.addEventListener("keydown",r),n.classList.add(this._slideTabBar.getConfig().slideTabBarSpanEditClassName),this._editMode=!0,At.keepSelectAll(n))}}nameCheck(){const t=this._slideTabItem.querySelector("span");if(!t)return!1;const e=t.innerText;return this._slideTabBar.getConfig().onNameCheckAlert(e)}animate(){return{translateX:t=>{this._translateX!==t&&(this._animate&&(this._animate.cancel(),this._animate=null),this._animate=new $u({begin:this._translateX,end:t,receive:e=>{this._slideTabItem.style.transform=`translateX(${e}px)`}}),this._translateX=t,this._animate.request())},cancel:()=>{this._animate&&(this._animate.cancel(),this._animate=null)}}}after(t){this._slideTabItem.after(t._slideTabItem||t)}update(){this._midline=ut.midline(this)}disableFixed(){if(this._placeholder){const t=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),t.removeChild(this._placeholder),this._placeholder=null}}enableFixed(){const t=document.createElement("div"),e=this.getBoundingRect(),n=getComputedStyle(this._slideTabItem),o=this._slideTabItem.querySelector("span");if(this._placeholder=t,this._placeholder.style.width=`${e.width}px`,this._placeholder.style.height=`${e.height}px`,this._placeholder.style.flexShrink="0",this._placeholder.style.margin=n.margin,this._slideTabItem.style.background=n.background,o){const r=getComputedStyle(o).padding;this._slideTabItem.style.padding=r}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=`${e.x-this.getScrollbar().getScrollX()}px`,this._slideTabItem.style.top=`${e.y}px`,this._slideTabItem.style.width=`${e.width}px`,this._slideTabItem.style.height=`${e.height}px`,this._slideTabItem.style.position="fixed",this._slideTabItem.after(t),document.body.appendChild(this._slideTabItem)}addEventListener(t,e,n){this._slideTabItem.addEventListener(t,e,n)}removeEventListener(t,e,n){this._slideTabItem.removeEventListener(t,e,n)}getScrollbar(){return this._scrollbar}getMidLine(){return this._midline}getBoundingRect(){const t=this._slideTabItem.getBoundingClientRect();return t.x+=this._scrollbar.getScrollX(),t}getWidth(){return this.getBoundingRect().width}getTranslateXDirection(){const t=ut.midline(this);return t>this._midline?1:t<this._midline?-1:0}equals(t){return t&&t._slideTabItem===this._slideTabItem}getId(){return this._slideTabItem.dataset.id||""}}class Zu{constructor(t){I(this,"_slideTabBar");I(this,"_scrollX");const e=t.primeval();this._scrollX=e.scrollLeft,this._slideTabBar=t}scrollX(t){const e=this._slideTabBar.primeval();e.scrollLeft=t,this._scrollX=e.scrollLeft}scrollRight(){const t=this._slideTabBar.primeval();t.scrollLeft=t.scrollWidth,this._scrollX=t.scrollLeft}getScrollX(){return this._scrollX}}const Dt=class Dt{constructor(t){I(this,"_activeTabItemIndex",0);I(this,"_slideTabBar");I(this,"_slideTabItems",[]);I(this,"_config");I(this,"_downActionX",0);I(this,"_moveActionX",0);I(this,"_compareIndex",0);I(this,"_activeTabItem",null);I(this,"_moveAction");I(this,"_upAction");I(this,"_downAction");I(this,"_wheelAction");I(this,"_scrollIncremental",0);I(this,"_compareDirection",0);I(this,"_autoScrollTime",null);I(this,"_slideScrollbar");I(this,"_longPressTimer",null);I(this,"_leftBoundingLine",0);I(this,"_rightBoundingLine",0);I(this,"_leftMoveX",0);I(this,"_rightMoveX",0);var s;if(t.slideTabBarContainer==null)throw new Error("not found slide-tab-bar root element");const e=t.slideTabBarContainer.querySelector(`.${(s=t.slideTabBarClassName)!=null?s:"slide-tab-bar"}`);if(e==null)throw new Error("not found slide-tab-bar");this._slideTabBar=e,this._slideScrollbar=new Zu(this),this._config=t,this._initConfig();let n=0,o=0,r=0;this._downAction=a=>{var y,O,x,N,V,D;if((y=this._activeTabItem)!=null&&y.isEditMode())return;const c=(x=(O=a.target)==null?void 0:O.closest(`.${t.slideTabBarItemClassName}`))==null?void 0:x.getAttribute("data-id"),d=this._slideTabItems.findIndex(H=>H.getId()===c);if(c==null||d===-1)return;if(this._activeTabItemIndex!==d){(N=this._activeTabItem)==null||N.removeEventListener("pointermove",this._moveAction),(V=this._activeTabItem)==null||V.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),(D=this._activeTabItem)==null||D.addEventListener("pointerup",this._upAction);const{x:h,width:m}=this._activeTabItem.getBoundingRect(),{x:S,width:g}=this.getBoundingRect(),_=this._slideScrollbar.getScrollX();if(this._leftBoundingLine=this._downActionX-(h-_),this._rightBoundingLine=h-_+m-this._downActionX,this._leftMoveX=h-S-_,this._rightMoveX=S+g-(h+m)+_,a.button===2||this._hasEditItem())return;const{pageX:v,pageY:M}=a,R=Date.now(),b=R-r<=Dt.DoubleClickDelay,E=Math.abs(v-n)<10,T=Math.abs(M-o)<10;b&&E&&T&&this._activeTabItem.setEditor(),n=v,o=M,r=R,this._longPressTimer=setTimeout(()=>{var H,B;(H=this._activeTabItem)==null||H.enableFixed(),this._startAutoScroll(),u&&(u.setPointerCapture(a.pointerId),u.style.cursor="move",(B=this._activeTabItem)==null||B.addEventListener("pointermove",this._moveAction))},Dt.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(t){let e=t.target;for(;e!=null&&e!==document.body;){if(e.getAttribute("data-slide-skip"))return!0;e=e.parentElement}return!1}static keepLastIndex(t){setTimeout(()=>{const e=window.getSelection();e&&(e.selectAllChildren(t),e.collapseToEnd())})}static keepSelectAll(t){setTimeout(()=>{const e=window.getSelection();if(!e)return;const n=document.createRange();n.selectNodeContents(t),e.removeAllRanges(),e.addRange(n)})}update(t){this._config.currentIndex=t,this._initConfig(),this.removeListener(),this.addListener()}primeval(){return this._slideTabBar}updateItems(){for(let t=0;t<this._slideTabItems.length;t++)this._slideTabItems[t].animate().cancel(),this._slideTabItems[t].translateX(0),this._slideTabItems[t].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 t=this._slideTabBar.parentElement;return t?this._slideTabBar.scrollWidth-t.clientWidth===this._slideTabBar.scrollLeft:!1}addListener(){this._slideTabBar.addEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(t=>{t.addEventListener("pointerdown",this._downAction)})}removeListener(){this._slideTabBar.removeEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(t=>{t.removeEventListener("pointerdown",this._downAction)})}setScroll(t){if(this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t),t>0){const e=this.calculateLeftScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}else if(t<0){const e=this.calculateRightScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}flipPage(t){if(t>0){const e=this.calculateLeftScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}else if(t<0){const e=this.calculateRightScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}calculateLeftScrollX(t){let e=0;const n=4;return this._slideTabItems.some(o=>{const r=this._slideTabBar.getBoundingClientRect(),s=r.left+r.width,a=o.getSlideTabItem().getBoundingClientRect(),c=a.left,d=a.width;return c<s&&c+d+n*2>s?(e=t?c-r.left-n:c+d-s+n,!0):!1}),e}calculateRightScrollX(t){let e=0;const n=4;return this._slideTabItems.some(o=>{const r=this._slideTabBar.getBoundingClientRect(),s=r.left,a=o.getSlideTabItem().getBoundingClientRect(),c=a.left,d=a.width;return c-n*2<s&&c+d>s?(e=t?c+d-r.left-r.width+n:c-s-n,!0):!1}),e}destroy(){this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=[],this._activeTabItem=null,this.removeListener()}_hasEditItem(){for(let t=0;t<this._slideTabItems.length;t++)if(this._slideTabItems[t].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(t){const e=this.getBoundingRect(),n=t.pageX-e.x;n<this._leftBoundingLine&&(this._scrollIncremental=-Math.min(Math.abs(n-this._leftBoundingLine)*.1,50))}_scrollRight(t){const e=this.getBoundingRect(),n=t.pageX-e.x;n>e.width-this._rightBoundingLine&&(this._scrollIncremental=Math.min(Math.abs(n-(e.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 t=0;t<this._slideTabItems.length;t++){const e=this._slideTabItems[t],n=this._slideTabItems[t+1];n&&e.after(n)}}_compareLeft(){if(this._activeTabItem&&this._activeTabItemIndex){const t=this._slideTabItems.findIndex(r=>r.equals(this._activeTabItem)),e=this._slideTabItems.length,n=[];for(let r=0;r<t&&!(r>=t);r++)n.push(this._slideTabItems[r]);for(let r=t+1;r<e;r++)this._slideTabItems[r].animate().translateX(0);let o=!0;for(let r=n.length-1;r>=0;r--){const s=n[r];ut.leftLine(this._activeTabItem)<s.getMidLine()?(s.animate().translateX(this._activeTabItem.getWidth()),this._compareIndex=r,o=!1):(s.animate().translateX(0),o&&(this._compareIndex=this._activeTabItemIndex))}}}_compareRight(){if(this._activeTabItem){const t=this._slideTabItems.findIndex(r=>r.equals(this._activeTabItem)),e=this._slideTabItems.length,n=[];for(let r=t+1;r<e;r++)n.push(this._slideTabItems[r]);for(let r=0;r<t;r++)this._slideTabItems[r].animate().translateX(0);let o=!0;for(let r=0;r<n.length;r++){const s=n[r];ut.rightLine(this._activeTabItem)>s.getMidLine()?(s.animate().translateX(-this._activeTabItem.getWidth()),this._compareIndex=t+r+1,o=!1):(s.animate().translateX(0),o&&(this._compareIndex=this._activeTabItemIndex))}}}_initConfig(){var e;const t=this._slideTabBar.querySelectorAll(`.${(e=this._config.slideTabBarItemClassName)!=null?e:"slide-tab-item"}`);this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=ut.make(t,this),this._activeTabItemIndex=this._config.currentIndex,this._activeTabItem=this._slideTabItems[this._activeTabItemIndex]}};I(Dt,"LongPressDelay",500),I(Dt,"DoubleClickDelay",300);let At=Dt;function Gu(){const[i,t]=L.useState([]),[e,n]=L.useState(""),[o,r]=L.useState(""),[s,a]=L.useState(!1),[c,d]=L.useState([0,0]),u=L.useRef({slideTabBar:null}),h=L.useRef(null),m=Z.useDependency(l.IUniverInstanceService),S=Z.useDependency(l.ICommandService),g=Z.useDependency(Ot),_=Z.useDependency(l.LocaleService),v=Z.useDependency(C.IConfirmService),M=Z.useDependency(fe),R=Z.useDependency(we);Z.useInjector();const b=m.getCurrentUniverSheetInstance();L.useEffect(()=>{D();const U=E(),W=V(),G=[H(),B(),j(),X()];return()=>{W.dispose(),U.destroy(),G.forEach(q=>q.unsubscribe())}},[]),L.useEffect(()=>{i.length>0&&N()},[i]);const E=()=>{const U=new At({slideTabBarClassName:Ae.slideTabBar,slideTabBarItemActiveClassName:Ae.slideTabActive,slideTabBarItemClassName:Ae.slideTabItem,slideTabBarSpanEditClassName:Ae.slideTabSpanEdit,slideTabBarItemAutoSort:!0,slideTabBarContainer:h.current,currentIndex:0,onChangeName:(W,G)=>{S.executeCommand(f.SetWorksheetNameCommand.id,{subUnitId:W,name:G})},onSlideEnd:(W,G)=>{S.executeCommand(f.SetWorksheetOrderCommand.id,{order:G})},onChangeTab:(W,G)=>{S.executeCommand(f.SetWorksheetActiveOperation.id,{subUnitId:G,unitId:b.getUnitId()}).then(()=>{W.button===2&&ne(!0)})},onScroll:W=>{g.setScroll(W)},onNameCheckAlert:W=>T(W)||y(W)});return u.current.slideTabBar=U,ee(U),U},T=U=>{if(U.trim()===""){const W="sheetNameEmptyAlert";return v.open({id:W,title:{title:_.t("sheetConfig.sheetNameErrorTitle")},children:{title:_.t("sheetConfig.sheetNameCannotIsEmptyError")},cancelText:_.t("button.cancel"),confirmText:_.t("button.confirm"),onClose(){O(),v.close(W)},onConfirm(){O(),v.close(W)}}),!0}return!1},y=U=>{const W=m.getCurrentUniverSheetInstance();if(W.getActiveSheet().getName()===U)return!1;const re=W.checkSheetName(U);if(re){const se="sheetNameRepeatAlert";v.open({id:se,title:{title:_.t("sheetConfig.sheetNameErrorTitle")},children:{title:_.t("sheetConfig.sheetNameAlreadyExistsError")},cancelText:_.t("button.cancel"),confirmText:_.t("button.confirm"),onClose(){v.close(se),O()},onConfirm(){v.close(se),O()}})}return re},O=()=>{M.endSelection(),setTimeout(()=>{var W;const U=(W=u.current.slideTabBar)==null?void 0:W.getActiveItem();U&&(U.focus(),U.selectAll())},0)},x=()=>{var U,W;(W=(U=u.current.slideTabBar)==null?void 0:U.getActiveItem())==null||W.setEditor()},N=()=>{var W;const U=i.findIndex(G=>G.selected);(W=u.current.slideTabBar)==null||W.update(U)},V=()=>S.onCommandExecuted(U=>{switch(U.id){case f.SetTabColorMutation.id:case f.SetWorksheetHideMutation.id:case f.RemoveSheetMutation.id:case f.SetWorksheetNameMutation.id:case f.InsertSheetMutation.id:case f.SetWorksheetOrderMutation.id:case f.SetWorksheetActiveOperation.id:D();break}}),D=()=>{const U=b.getActiveSheet().getSheetId();n(U);const W=b.getSheets(),G=b.getActiveSheet(),q=W.filter(re=>!re.isSheetHidden()).map((re,se)=>{var Y;return{sheetId:re.getSheetId(),label:re.getName(),index:se,selected:G===re,color:(Y=re.getTabColor())!=null?Y:void 0}});t(q)},H=()=>g.scroll$.subscribe(U=>{z(U)}),B=()=>g.scrollX$.subscribe(U=>{var W;(W=u.current.slideTabBar)==null||W.flipPage(U)}),j=()=>g.renameId$.subscribe(()=>{x()}),X=()=>g.addSheet$.subscribe(()=>{var U;(U=u.current.slideTabBar)==null||U.getScrollbar().scrollRight()}),z=U=>{const{leftEnd:W,rightEnd:G}=U;let q="";W&&G?q="":W&&!G?q="inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!W&&G?q="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!W&&!G&&(q="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2), inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)"),r(q)},$=U=>{g.setScroll({leftEnd:U.isLeftEnd(),rightEnd:U.isRightEnd()})},ee=U=>{var q;const W=(q=h.current)==null?void 0:q.querySelector(`.${Ae.slideTabBar}`);if(!W)return;new ResizeObserver(()=>{$(U)}).observe(W)},ne=U=>{var W,G,q,re,se;if(!R.isForceKeepVisible()){if(U){const{left:Y}=(G=(W=h.current)==null?void 0:W.getBoundingClientRect())!=null?G:{},{left:Q}=(se=(re=(q=u.current.slideTabBar)==null?void 0:q.getActiveItem())==null?void 0:re.getSlideTabItem().getBoundingClientRect())!=null?se:{};Y!==void 0&&Q!==void 0&&d([Q-Y,0])}a(U)}};return p.jsx(le.Dropdown,{className:Ae.slideTabItemDropdown,visible:s,align:{offset:c},trigger:["contextMenu"],overlay:p.jsx(C.Menu,{menuType:he.SHEET_BAR,onOptionSelect:U=>{const{label:W,value:G}=U;S.executeCommand(W,{value:G,subUnitId:e}),a(!1)}}),onVisibleChange:ne,children:p.jsx("div",{className:Ae.slideTabBarContainer,ref:h,children:p.jsx("div",{className:Ae.slideTabBar,style:{boxShadow:o},children:i.map(U=>L.createElement(zu,{...U,key:U.sheetId,selected:e===U.sheetId}))})})})}const us=100,Ku=()=>{const[i,t]=L.useState(!0),[e,n]=L.useState(!0),o=Z.useDependency(l.ICommandService),r=Z.useDependency(Ot);L.useEffect(()=>{const u=r.scroll$.subscribe(h=>{s(h)});return()=>{u.unsubscribe()}},[]);const s=u=>{const{leftEnd:h,rightEnd:m}=u;t(h),n(m)},a=()=>{o.executeCommand(f.InsertSheetCommand.id),setTimeout(()=>{r.setAddSheet(0)},0)},c=()=>{r.setScrollX(-us)},d=()=>{r.setScrollX(us)};return p.jsxs("div",{className:Qn.sheetBar,children:[p.jsxs("div",{className:Qn.sheetBarOptions,children:[p.jsx(Jn,{onClick:a,children:p.jsx(Kr,{})}),p.jsx(ju,{})]}),p.jsx(Gu,{}),(!i||!e)&&p.jsxs("div",{className:`${Qn.sheetBarOptions} ${Qn.sheetBarOptionsDivider}`,children:[p.jsx(Jn,{disabled:i,onClick:c,children:p.jsx(qr,{style:{transform:"rotateZ(180deg)"}})}),p.jsx(Jn,{disabled:e,onClick:d,children:p.jsx(qr,{})})]})]})};class Qu{constructor(){I(this,"_functions",[{func:K.FUNCTION_NAMES_STATISTICAL.MAX,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}},{func:K.FUNCTION_NAMES_STATISTICAL.MIN,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}},{func:K.FUNCTION_NAMES_MATH.SUM,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}},{func:K.FUNCTION_NAMES_STATISTICAL.COUNTA,filter:t=>{var e,n;return((n=(e=t.values.find(o=>o.func===K.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1}},{func:K.FUNCTION_NAMES_STATISTICAL.COUNT,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}},{func:K.FUNCTION_NAMES_STATISTICAL.AVERAGE,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}}]);I(this,"_state$",new k.BehaviorSubject(null));I(this,"state$",this._state$.asObservable())}dispose(){this._state$.complete()}setState(t){var n;const e={values:[],pattern:null};t==null||t.values.forEach(o=>{const r=this._functions.find(s=>s.func===o.func);r&&(r.filter===void 0||r.filter(t))&&e.values.push(o)}),e.pattern=(n=t==null?void 0:t.pattern)!=null?n:null,this._state$.next(e)}getState(){return this._state$.getValue()}getFunctions(){return this._functions}addFunctions(t){this._functions.push(...t)}}const Ki=P.createIdentifier("univer.sheet-status-bar.service"),xt={statusBar:"univer-status-bar",singleMode:"univer-single-mode",statusBarDiv:"univer-status-bar-div",statisticList:"univer-statistic-list",statisticListColumn:"univer-statistic-list-column",statisticItem:"univer-statistic-item",statisticPicker:"univer-statistic-picker",statisticPickerItem:"univer-statistic-picker-item",statisticMore:"univer-statistic-more"},Ju=[K.FUNCTION_NAMES_MATH.SUM,K.FUNCTION_NAMES_STATISTICAL.AVERAGE,K.FUNCTION_NAMES_STATISTICAL.MIN,K.FUNCTION_NAMES_STATISTICAL.MAX],Qi={[K.FUNCTION_NAMES_MATH.SUM]:"statusbar.sum",[K.FUNCTION_NAMES_STATISTICAL.AVERAGE]:"statusbar.average",[K.FUNCTION_NAMES_STATISTICAL.MIN]:"statusbar.min",[K.FUNCTION_NAMES_STATISTICAL.MAX]:"statusbar.max",[K.FUNCTION_NAMES_STATISTICAL.COUNT]:"statusbar.count",[K.FUNCTION_NAMES_STATISTICAL.COUNTA]:"statusbar.countA",[K.FUNCTION_NAMES_TEXT.CONCATENATE]:"concatenate"},Ji=i=>{const t=Z.useDependency(l.LocaleService),e=Z.useDependency(C.IMessageService),n=Z.useDependency(C.IClipboardInterfaceService),o=qu(i),r=async()=>{await n.writeText(i.value.toString()),e.show({type:le.MessageType.Success,content:t.t("statusbar.copied")})};return p.jsx(le.Tooltip,{title:t.t("statusbar.clickToCopy"),placement:"top",children:p.jsx("div",{className:xt.statisticItem,onClick:r,children:p.jsx("span",{children:`${t.t((Qi==null?void 0:Qi[i.name])||i.name)}: ${o}`})},i.name)})};function qu(i){const{pattern:t,value:e}=i;return typeof e!="number"?"Invalid input":e>=1e8?e.toExponential(2):t&&Ju.includes(i.name)?Ms.format(t,e):e.toLocaleString()}const hs=800,eh=3,th=()=>{const[i,t]=L.useState(window.innerWidth<hs),[e,n]=L.useState(!0),o=Z.useDependency(Ki),r=o.getFunctions().map((m,S)=>({name:m.func,value:0,show:!0,disable:!1,pattern:null})),[s,a]=L.useState(r),c=s.find(m=>m.show&&!m.disable),d=i&&c?[c]:s.filter(m=>m.show&&!m.disable);L.useEffect(()=>{const m=o.state$.subscribe(S=>{const g=S==null?void 0:S.values;if(!g||g.length===0)n(!1);else{n(!0);const _=s.map(v=>{var R;const M=g.find(b=>b.func===v.name);return M?(v.value=M.value,v.disable=!1):v.disable=!0,v.pattern=(R=S==null?void 0:S.pattern)!=null?R:null,v});a(_)}});return()=>{m.unsubscribe()}},[o]);const u=l.debounce(()=>{const m=window.innerWidth<hs;i!==m&&t(m)},100);L.useEffect(()=>(window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}),[i]);let h=null;if(d.length>eh){const m=[];d.forEach((S,g)=>{g%2===0&&m.push(d.slice(g,g+2))}),h=p.jsxs(p.Fragment,{children:[" ",m.map((S,g)=>p.jsxs("div",{className:xt.statisticListColumn,children:[(S==null?void 0:S[0])&&p.jsx(Ji,{...S==null?void 0:S[0]},S==null?void 0:S[0].name),(S==null?void 0:S[1])&&p.jsx(Ji,{...S==null?void 0:S[1]},S==null?void 0:S[1].name)]},`stat-col-${g}`))," "]})}else h=p.jsx(p.Fragment,{children:d.map(m=>p.jsx(Ji,{...m},m.name))});return e&&p.jsxs("div",{className:xe(xt.statusBar,{[xt.singleMode]:i}),children:[p.jsx("div",{className:xe(xt.statisticList),children:h}),p.jsx("div",{className:xt.statusBarDiv})]})};function nh(){return p.jsxs("section",{className:vr.sheetContainer,"data-range-selector":!0,children:[p.jsx(Ku,{}),p.jsx(th,{}),p.jsx(Pu,{})]})}function ih(){return p.jsx(Vu,{})}function oh(){return p.jsxs(p.Fragment,{children:[p.jsx(Lu,{}),p.jsx(Fu,{})]})}const qi={width:"100%"},ms=i=>{const{inputId:t,state:e=!1,type:n="range",confirm:o,cancel:r,name:s,formulaOrRefString:a,comment:c="",localSheetId:d=Gi,hidden:u=!1,id:h}=i,S=Z.useDependency(l.IUniverInstanceService).getCurrentUniverSheetInstance(),g=Z.useDependency(l.LocaleService),_=Z.useDependency(K.IDefinedNamesService),v=Z.useDependency(K.IFunctionService),M=Z.useDependency(K.LexerTreeBuilder);if(S==null)return;const R=S.getUnitId();S.getActiveSheet().getSheetId();const[b,E]=L.useState(s),[T,y]=L.useState(a),[O,x]=L.useState(c),[N,V]=L.useState(d),[D,H]=L.useState(""),[B,j]=L.useState(n),[X,z]=L.useState(!0),[$,ee]=L.useState(a),ne=[{label:g.t("definedName.scopeWorkbook"),value:Gi}];L.useEffect(()=>{z(!0),E(s),x(c),V(d);let Y=a;a.substring(0,1)===K.operatorToken.EQUALS?j("formula"):U(a)?(j("formula"),Y=K.operatorToken.EQUALS+a):j("range"),y(Y),ee(Y),H("")},[e]);const U=Y=>!Y.split(",").every(Q=>K.isReferenceString(Q.trim()));S.getSheetOrders().forEach(Y=>{const Q=S.getSheetBySheetId(Y);ne.push({label:(Q==null?void 0:Q.getName())||"",value:Y})});const W=Y=>Y.map(J=>{var ae;return K.serializeRangeToRefString({...J,sheetName:((ae=S.getSheetBySheetId(J.sheetId))==null?void 0:ae.getName())||""})}).join(","),G=Y=>{ee(W(Y))},q=Y=>{ee(Y||"")},re=()=>{if(b.length===0){H(g.t("definedName.nameEmpty"));return}if(_.getValueByName(R,b)!=null&&(h==null||h.length===0)){H(g.t("definedName.nameDuplicate"));return}if(!l.Tools.isValidParameter(b)||!l.Tools.isStartValidPosition(b)&&!w.hasCJKText(b.substring(0,1))){H(g.t("definedName.nameInvalid"));return}if(S.getSheetOrders().map(Q=>{var J;return((J=S.getSheetBySheetId(Q))==null?void 0:J.getName())||""}).includes(b)){H(g.t("definedName.nameSheetConflict"));return}if($.length===0){H(g.t("definedName.formulaOrRefStringEmpty"));return}if(!X){H(g.t("definedName.formulaOrRefStringInvalid"));return}if(v.hasExecutor(b.toUpperCase())){H(g.t("definedName.nameConflict"));return}o&&o({id:h||"",name:b,formulaOrRefString:M.convertRefersToAbsolute($,l.AbsoluteRefType.ALL,l.AbsoluteRefType.ALL),comment:O,localSheetId:N})},se=Y=>{const Q=Y;Q==="formula"&&T.substring(0,1)!==K.operatorToken.EQUALS?(ee(`${K.operatorToken.EQUALS}`),y(`${K.operatorToken.EQUALS}`)):T.substring(0,1)===K.operatorToken.EQUALS&&(ee(""),y("")),j(Q)};return p.jsxs("div",{className:ue.definedNameInput,style:{display:e?"block":"none"},children:[p.jsx("div",{children:p.jsx(le.Input,{placeholder:g.t("definedName.inputNamePlaceholder"),value:b,allowClear:!0,onChange:E,affixWrapperStyle:qi})}),p.jsx("div",{children:p.jsxs(le.RadioGroup,{value:B,onChange:se,children:[p.jsx(le.Radio,{value:"range",children:g.t("definedName.ratioRange")}),p.jsx(le.Radio,{value:"formula",children:g.t("definedName.ratioFormula")})]})}),p.jsx("div",{style:{display:B==="range"?"block":"none"},children:p.jsx(C.RangeSelector,{value:T,onValid:z,onChange:G,placeholder:g.t("definedName.inputRangePlaceholder"),id:l.createInternalEditorID(`${t}-rangeSelector`),width:"99%",openForSheetUnitId:R},`${t}-rangeSelector`)}),p.jsx("div",{style:{display:B==="range"?"none":"block"},children:p.jsx(C.TextEditor,{value:T,onValid:z,onChange:q,id:l.createInternalEditorID(`${t}-editor`),placeholder:g.t("definedName.inputFormulaPlaceholder"),openForSheetUnitId:R,onlyInputFormula:!0,style:{width:"99%"},canvasStyle:{fontSize:10}},`${t}-editor`)}),p.jsx("div",{children:p.jsx(le.Select,{style:qi,value:N,options:ne,onChange:V})}),p.jsx("div",{children:p.jsx(le.Input,{affixWrapperStyle:qi,placeholder:g.t("definedName.inputCommentPlaceholder"),value:O,onChange:x})}),p.jsxs("div",{style:{display:D.length===0?"none":"flex"},className:ue.definedNameInputValidation,children:[p.jsx("span",{children:D}),p.jsx(Xr,{})]}),p.jsxs("div",{children:[p.jsx(le.Button,{onClick:()=>{r&&r()},children:g.t("definedName.cancel")}),p.jsx(le.Button,{style:{marginLeft:15},type:"primary",onClick:re,children:g.t("definedName.confirm")})]})]})},rh=()=>{const i=Z.useDependency(l.ICommandService),e=Z.useDependency(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=Z.useDependency(l.LocaleService),o=Z.useDependency(K.IDefinedNamesService),r=Z.useDependency(f.SelectionManagerService);if(e==null)return;const s=e.getUnitId(),a=()=>{const D=o.getDefinedNameMap(s);return D?Array.from(Object.values(D)):[]},[c,d]=L.useState(!1),[u,h]=L.useState(a()),[m,S]=L.useState(null),[g,_]=L.useState();L.useEffect(()=>{const D=o.update$.subscribe(()=>{h(a())});return()=>{D.unsubscribe()}},[]);const v=D=>{const{name:H,formulaOrRefString:B,comment:j,localSheetId:X,hidden:z}=D;let $=D.id;if($==null||$.length===0)$=l.Tools.generateRandomId(10),i.executeCommand(f.InsertDefinedNameCommand.id,{id:$,unitId:s,name:H,formulaOrRefString:B,comment:j,localSheetId:X,hidden:z});else{const ee=o.getValueById(s,$),ne={id:$,unitId:s,name:H,formulaOrRefString:B,comment:j,localSheetId:X,hidden:z};i.executeCommand(f.SetDefinedNameCommand.id,{unitId:s,oldDefinedName:ee,newDefinedName:ne})}d(!1),S(null)},M=D=>{_(D)};function R(){_(null)}function b(D){const H=o.getValueById(s,D);i.executeCommand(f.RemoveDefinedNameCommand.id,{...H,unitId:s}),_(null)}const E=D=>{o.focusRange(s,D.id)},T=()=>{const D=u.length+1,H=n.t("definedName.defaultName")+D;if(o.getValueByName(s,H)==null)return H;let B=D+1;for(;;){const j=n.t("definedName.defaultName")+B;if(o.getValueByName(s,j)==null)return j;B++}},y=()=>{const D=e.getActiveSheet().getName(),H=r.getSelections();return H==null?"":H.map(j=>K.serializeRangeWithSheet(D,j.range)).join(",")},O=()=>{d(!1),S(null)},x=()=>{d(!0),S(null)},N=D=>{d(!1),S(D)},V=D=>{const H=e.getSheetBySheetId(D);return H==null?"":H.getName()};return p.jsx("div",{className:ue.definedNameContainer,children:p.jsxs("div",{className:ue.definedNameContainerScroll,children:[p.jsxs("div",{children:[p.jsxs("div",{onClick:x,className:ue.definedNameContainerAddButton,style:{display:c?"none":"flex"},children:[p.jsx(Kr,{}),p.jsx("span",{className:ue.definedNameContainerAddButtonText,children:n.t("definedName.addButton")})]}),p.jsx(ms,{confirm:v,cancel:O,state:c,inputId:"insertDefinedName",name:T(),formulaOrRefString:y()})]},"insertDefinedName"),u.map((D,H)=>p.jsxs("div",{children:[p.jsxs("div",{onClick:()=>{E(D)},className:ue.definedNameContainerItem,style:{display:D.id===m?"none":"flex"},children:[p.jsxs("div",{title:D.comment,children:[p.jsxs("div",{className:ue.definedNameContainerItemName,children:[D.name,p.jsx("span",{className:ue.definedNameContainerItemNameForSheet,children:D.localSheetId===Gi||D.localSheetId==null?"":V(D.localSheetId)})]}),p.jsx("div",{className:ue.definedNameContainerItemFormulaOrRefString,children:D.formulaOrRefString})]}),p.jsx(le.Tooltip,{title:n.t("definedName.updateButton"),placement:"top",style:{pointerEvents:"none"},children:p.jsx("div",{className:xe(ue.definedNameContainerItemUpdate,ue.definedNameContainerItemShow),onClick:()=>{N(D.id)},children:p.jsx(en,{})})}),p.jsx(le.Tooltip,{title:n.t("definedName.deleteButton"),placement:"top",style:{pointerEvents:"none"},children:p.jsx("div",{className:xe(ue.definedNameContainerItemDelete,ue.definedNameContainerItemShow),onClick:()=>{M(D.id)},children:p.jsx(au,{})})})]}),p.jsx(le.Confirm,{visible:g===D.id,onClose:R,onConfirm:()=>{b(D.id)},children:n.t("definedName.deleteConfirmText")}),p.jsx(ms,{confirm:v,cancel:O,state:D.id===m,id:D.id,inputId:D.id+H,name:D.name,formulaOrRefString:D.formulaOrRefString,comment:D.comment,localSheetId:D.localSheetId})]},H))]})})};function sh(i){const t=i.get(f.BorderStyleManagerService),e=f.getCurrentSheetDisabled$(i);return{id:f.SetBorderBasicCommand.id,icon:new k.Observable(n=>{const o="AllBorderSingle",r=i.get(f.BorderStyleManagerService),s=i.get(l.ICommandService).onCommandExecuted(a=>{var m;if(a.id!==f.SetBorderBasicCommand.id)return;const{type:d}=r.getBorderInfo(),u=ss.find(S=>S.value===d),h=(m=u==null?void 0:u.icon)!=null?m:o;n.next(h)});return n.next(o),s.dispose}),group:C.MenuGroup.TOOLBAR_FORMAT,tooltip:"toolbar.border.main",positions:[C.MenuPosition.TOOLBAR_START],type:C.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:rs,hoverable:!1},value$:t.borderInfo$}],value$:t.borderInfo$,hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:e}}const qn="sheet.menu.clear-selection";function ah(){return{id:qn,group:C.MenuGroup.CONTEXT_MENU_FORMAT,type:C.MenuItemType.SUBITEMS,icon:"ClearFormat",title:"rightClick.clearSelection",positions:[C.MenuPosition.CONTEXT_MENU,he.COL_HEADER_CONTEXT_MENU,he.ROW_HEADER_CONTEXT_MENU]}}function lh(){return{id:f.ClearSelectionContentCommand.id,type:C.MenuItemType.BUTTON,title:"rightClick.clearContent",positions:[qn]}}function ch(){return{id:f.ClearSelectionFormatCommand.id,type:C.MenuItemType.BUTTON,title:"rightClick.clearFormat",positions:[qn]}}function dh(){return{id:f.ClearSelectionAllCommand.id,type:C.MenuItemType.BUTTON,title:"rightClick.clearAll",positions:[qn]}}const tn="sheet.menu.delete";function uh(){return{id:tn,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.delete",icon:"Reduce",positions:[C.MenuPosition.CONTEXT_MENU]}}function hh(){return{id:Dr.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,icon:"DeleteColumn",positions:[tn,he.COL_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedColumn"}}function mh(){return{id:Nr.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,icon:"DeleteRow",positions:[tn,he.ROW_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedRow"}}function Sh(){return{id:Yi.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,title:"rightClick.moveLeft",icon:"DeleteCellShiftLeft",positions:[tn]}}function gh(){return{id:Xi.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,title:"rightClick.moveUp",icon:"DeleteCellShiftUp",positions:[tn]}}const eo="sheet.menu.col-insert";function _h(){return{id:eo,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[he.COL_HEADER_CONTEXT_MENU]}}const to="sheet.menu.row-insert";function fh(){return{id:to,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[he.ROW_HEADER_CONTEXT_MENU]}}const nn="sheet.menu.cell-insert";function ph(){return{id:nn,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[C.MenuPosition.CONTEXT_MENU]}}function vh(i){const t=i.get(f.SelectionManagerService);return{id:f.InsertRowBeforeCommand.id,type:C.MenuItemType.BUTTON,title:"rightClick.insertRowBefore",icon:"InsertRowAbove",positions:[to,nn],hidden$:new k.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function Ch(i){const t=i.get(f.SelectionManagerService);return{id:f.InsertRowAfterCommand.id,type:C.MenuItemType.BUTTON,positions:[to],title:"rightClick.insertRow",icon:"InsertRowBelow",hidden$:new k.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function Ih(i){const t=i.get(f.SelectionManagerService);return{id:f.InsertColBeforeCommand.id,type:C.MenuItemType.BUTTON,positions:[eo,nn],title:"rightClick.insertColumnBefore",icon:"LeftInsertColumn",hidden$:new k.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function Mh(i){const t=i.get(f.SelectionManagerService);return{id:f.InsertColAfterCommand.id,type:C.MenuItemType.BUTTON,positions:[eo],title:"rightClick.insertColumn",icon:"RightInsertColumn",hidden$:new k.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function Rh(){return{id:Zi.id,type:C.MenuItemType.BUTTON,title:"rightClick.moveRight",icon:"InsertCellShiftRight",positions:[nn]}}function bh(){return{id:$i.id,type:C.MenuItemType.BUTTON,title:"rightClick.moveDown",icon:"InsertCellDown",positions:[nn]}}function wh(i){return i.get(f.SelectionManagerService).selectionMoveEnd$.pipe(k.filter(e=>e!=null&&e.length>=2),k.map(e=>{if(!e)return!1;for(let n=0;n<e.length;n++)for(let o=n+1;o<e.length;o++)if(l.Rectangle.intersects(e[n].range,e[o].range))return!0;return!1}))}function Th(i){const t=f.getCurrentSheetDisabled$(i),e=wh(i);return{id:Ge.id,icon:"MergeAllSingle",tooltip:"toolbar.mergeCell.main",positions:[C.MenuPosition.TOOLBAR_START],group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SUBITEMS,hidden$:C.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:t.pipe(k.combineLatestWith(e),k.map(([n,o])=>n||o))}}function Eh(i){return{id:yr.id,type:C.MenuItemType.BUTTON,title:"merge.all",icon:"MergeAllSingle",positions:[Ge.id]}}function yh(i){return{id:Or.id,type:C.MenuItemType.BUTTON,title:"merge.vertical",icon:"VerticalIntegrationSingle",positions:[Ge.id]}}function Oh(i){return{id:Ar.id,type:C.MenuItemType.BUTTON,title:"merge.horizontal",icon:"HorizontalMergeSingle",positions:[Ge.id]}}function Ah(i){return{id:f.RemoveWorksheetMergeCommand.id,type:C.MenuItemType.BUTTON,title:"merge.cancel",icon:"CancelMergeSingle",positions:[Ge.id]}}function xh(i){const t=i.get(l.IUniverInstanceService),e=i.get(l.ICommandService);return{id:Pr.id,type:C.MenuItemType.BUTTON,positions:[he.SHEET_BAR],title:"sheetConfig.delete",disabled$:new k.Observable(n=>{const o=e.onCommandExecuted(r=>{const s=r.id;if(s===f.RemoveSheetMutation.id||s===f.InsertSheetMutation.id||s===f.SetWorksheetHideMutation.id){const a=t.getCurrentUniverSheetInstance().getWorksheets(),c=Array.from(a.values()).filter(d=>d.getConfig().hidden===l.BooleanNumber.FALSE);n.next(c.length===1)}});return n.next(!1),o.dispose})}}function Nh(){return{id:f.CopySheetCommand.id,type:C.MenuItemType.BUTTON,positions:[he.SHEET_BAR],title:"sheetConfig.copy"}}function Dh(){return{id:Ur.id,type:C.MenuItemType.BUTTON,positions:[he.SHEET_BAR],title:"sheetConfig.rename"}}function Ph(){return{id:f.SetTabColorCommand.id,title:"sheetConfig.changeColor",positions:[he.SHEET_BAR],type:C.MenuItemType.SELECTOR,selections:[{label:{name:Rn,hoverable:!1}}]}}function Lh(i){const t=i.get(l.IUniverInstanceService),e=i.get(l.ICommandService);return{id:f.SetWorksheetHideCommand.id,type:C.MenuItemType.BUTTON,positions:[he.SHEET_BAR],title:"sheetConfig.hide",disabled$:new k.Observable(n=>{const o=e.onCommandExecuted(r=>{const s=r.id;if(s===f.RemoveSheetMutation.id||s===f.InsertSheetMutation.id||s===f.SetWorksheetHideMutation.id){const a=t.getCurrentUniverSheetInstance().getWorksheets(),c=Array.from(a.values()).filter(d=>d.getConfig().hidden===l.BooleanNumber.FALSE);n.next(c.length===1)}});return n.next(!1),o.dispose})}}function Uh(i){const t=i.get(l.IUniverInstanceService),e=i.get(l.ICommandService);return{id:Lr.id,type:C.MenuItemType.BUTTON,positions:[he.SHEET_BAR],title:"sheetConfig.unhide",disabled$:new k.Observable(n=>{const o=e.onCommandExecuted(r=>{const s=r.id;if(s===f.RemoveSheetMutation.id||s===f.InsertSheetMutation.id||s===f.SetWorksheetHideMutation.id){const a=t.getCurrentUniverSheetInstance().getWorksheets(),c=Array.from(a.values());n.next(c.length===1)}});return n.next(!1),o.dispose})}}const Hh={id:f.SetRowHiddenCommand.id,preconditions:i=>ie(i),binding:C.KeyCode.Digit9|C.MetaKeys.CTRL_COMMAND},Vh={id:f.SetColHiddenCommand.id,preconditions:i=>ie(i),binding:C.KeyCode.Digit0|C.MetaKeys.CTRL_COMMAND|C.MetaKeys.SHIFT},kh={id:be.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_DOWN,priority:100,preconditions:ie,staticParameters:{direction:l.Direction.DOWN}},Bh={id:be.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_UP,priority:100,preconditions:ie,staticParameters:{direction:l.Direction.UP}},Fh={id:be.id,description:"shortcut.sheet.select-left-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_LEFT,priority:100,preconditions:vo,staticParameters:{direction:l.Direction.LEFT}},Wh={id:be.id,description:"shortcut.sheet.select-right-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_RIGHT,priority:100,preconditions:vo,staticParameters:{direction:l.Direction.RIGHT}},jh={id:lt.id,description:"shortcut.sheet.select-next-cell",group:"3_sheet-view",binding:C.KeyCode.TAB,priority:100,preconditions:ie,staticParameters:{direction:l.Direction.RIGHT,keycode:C.KeyCode.TAB}},zh={id:lt.id,description:"shortcut.sheet.select-previous-cell",group:"3_sheet-view",binding:C.KeyCode.TAB|C.MetaKeys.SHIFT,priority:100,preconditions:ie,staticParameters:{direction:l.Direction.LEFT,keycode:C.KeyCode.TAB}},Yh={id:lt.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:C.KeyCode.ENTER,priority:100,preconditions:ie,staticParameters:{direction:l.Direction.DOWN,keycode:C.KeyCode.ENTER}},Xh={id:lt.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:C.KeyCode.ENTER|C.MetaKeys.SHIFT,priority:100,preconditions:ie,staticParameters:{direction:l.Direction.UP,keycode:C.KeyCode.ENTER}},$h={id:be.id,description:"shortcut.sheet.select-below-value-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_DOWN|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:l.Direction.DOWN,jumpOver:ke.moveGap}},Zh={id:be.id,description:"shortcut.sheet.select-up-value-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_UP|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:l.Direction.UP,jumpOver:ke.moveGap}},Gh={id:be.id,description:"shortcut.sheet.select-left-value-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_LEFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:l.Direction.LEFT,jumpOver:ke.moveGap}},Kh={id:be.id,description:"shortcut.sheet.select-right-value-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_RIGHT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:l.Direction.RIGHT,jumpOver:ke.moveGap}},Qh={id:De.id,description:"shortcut.sheet.expand-selection-down",group:"3_sheet-view",binding:C.KeyCode.ARROW_DOWN|C.MetaKeys.SHIFT,preconditions:ie,staticParameters:{direction:l.Direction.DOWN}},Jh={id:De.id,description:"shortcut.sheet.expand-selection-up",group:"3_sheet-view",binding:C.KeyCode.ARROW_UP|C.MetaKeys.SHIFT,preconditions:ie,staticParameters:{direction:l.Direction.UP}},qh={id:De.id,description:"shortcut.sheet.expand-selection-left",group:"3_sheet-view",binding:C.KeyCode.ARROW_LEFT|C.MetaKeys.SHIFT,preconditions:ie,staticParameters:{direction:l.Direction.LEFT}},em={id:De.id,description:"shortcut.sheet.expand-selection-right",group:"3_sheet-view",binding:C.KeyCode.ARROW_RIGHT|C.MetaKeys.SHIFT,preconditions:ie,staticParameters:{direction:l.Direction.RIGHT}},tm={id:De.id,description:"shortcut.sheet.expand-selection-to-below-gap",group:"3_sheet-view",binding:C.KeyCode.ARROW_DOWN|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:l.Direction.DOWN,jumpOver:ke.moveGap}},nm={id:De.id,description:"shortcut.sheet.expand-selection-to-up-gap",group:"3_sheet-view",binding:C.KeyCode.ARROW_UP|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:l.Direction.UP,jumpOver:ke.moveGap}},im={id:De.id,description:"shortcut.sheet.expand-selection-to-left-gap",group:"3_sheet-view",binding:C.KeyCode.ARROW_LEFT|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:l.Direction.LEFT,jumpOver:ke.moveGap}},om={id:De.id,description:"shortcut.sheet.expand-selection-to-right-gap",group:"3_sheet-view",binding:C.KeyCode.ARROW_RIGHT|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:l.Direction.RIGHT,jumpOver:ke.moveGap}},rm={id:zo.id,description:"shortcut.sheet.select-all",group:"3_sheet-view",binding:C.KeyCode.A|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{expandToGapFirst:!0,loop:!0}},sm={id:wi.id,description:"shortcut.sheet.set-bold",group:"4_sheet-edit",preconditions:i=>ie(i),binding:C.KeyCode.B|C.MetaKeys.CTRL_COMMAND},am={id:Ti.id,description:"shortcut.sheet.set-italic",group:"4_sheet-edit",preconditions:i=>ie(i),binding:C.KeyCode.I|C.MetaKeys.CTRL_COMMAND},lm={id:Ei.id,description:"shortcut.sheet.set-underline",group:"4_sheet-edit",preconditions:i=>ie(i),binding:C.KeyCode.U|C.MetaKeys.CTRL_COMMAND},cm={id:yi.id,description:"shortcut.sheet.set-strike-through",group:"4_sheet-edit",preconditions:i=>ie(i),binding:C.KeyCode.X|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND},dm={id:f.ClearSelectionContentCommand.id,preconditions:i=>ie(i),binding:C.KeyCode.DELETE,mac:C.KeyCode.BACKSPACE},um={id:Pn.id,description:"shortcut.sheet.zoom-in",binding:C.KeyCode.EQUAL|C.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",preconditions:ie,priority:1,staticParameters:{delta:.2}},hm={id:l.NilCommand.id,binding:C.KeyCode.EQUAL|C.MetaKeys.CTRL_COMMAND},mm={id:Pn.id,description:"shortcut.sheet.zoom-out",binding:C.KeyCode.MINUS|C.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",preconditions:ie,priority:1,staticParameters:{delta:-.2}},Sm={id:l.NilCommand.id,binding:C.KeyCode.MINUS|C.MetaKeys.CTRL_COMMAND},gm={id:Pn.id,description:"shortcut.sheet.reset-zoom",binding:C.KeyCode.Digit0|C.MetaKeys.CTRL_COMMAND,preconditions:ie,group:"3_sheet-view",priority:1,staticParameters:{reset:!0}},_m={id:l.NilCommand.id,binding:C.KeyCode.Digit0|C.MetaKeys.CTRL_COMMAND};var fm=Object.defineProperty,pm=Object.getOwnPropertyDescriptor,vm=(i,t,e,n)=>{for(var o=n>1?void 0:n?pm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&fm(t,e,o),o},ht=(i,t)=>(e,n)=>t(e,n,i);let ei=class extends l.Disposable{constructor(i,t,e,n,o,r,s){super(),this._injector=i,this._componentManager=t,this._layoutService=e,this._commandService=n,this._shortcutService=o,this._menuService=r,this._uiController=s,this._init()}_init(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts(),this._initWorkbenchParts(),this._initFocusHandler()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Di,yl)),this.disposeWithMe(i.register(rs,Au)),this.disposeWithMe(i.register(Rn,le.ColorPicker)),this.disposeWithMe(i.register(rr,C.FontFamily)),this.disposeWithMe(i.register(sr,C.FontFamilyItem)),this.disposeWithMe(i.register(ar,C.FontSize)),this.disposeWithMe(i.register(cs,rh))}_initCommands(){[yr,Ge,Ar,Or,Pn,De,be,lt,Ur,Pr,Nr,Dr,$o,Zo,ct,Yo,zo,Mr,f.SetBoldCommand,Ft,Te,Ii,wi,Ti,Ei,yi,hl,ml,Go,Ko,In,f.SetItalicCommand,f.SetStrikeThroughCommand,f.SetFontFamilyCommand,f.SetFontSizeCommand,xi,er,Ni,tr,nt,Wt,Mn,nr,ir,or,f.SetUnderlineCommand,Ln,Pe,Lr,xr,$i,Xi,Zi,Yi,ds].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initMenus(){[zl,Yl,Xl,$l,Zl,Gl,Kl,lh,ch,dh,ah,_h,fh,ph,vh,Ch,Ih,Mh,mh,oc,sc,rc,ac,hh,lc,Ql,cc,uh,Sh,gh,Rh,bh,ec,tc,nc,ic,Jl,ql,Ol,Al,xl,Nl,Dl,Pl,Ll,Ul,Hl,Vl,kl,sh,Th,Eh,yh,Oh,Ah,Bl,Fl,Wl,jl,xh,Nh,Dh,Ph,Lh,Uh].forEach(i=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i)))})}_initShortcuts(){[kh,Bh,Fh,Wh,jh,zh,Yh,Xh,$h,Zh,Gh,Kh,Qh,Jh,qh,em,tm,nm,im,om,rm,um,mm,gm,_m,hm,Sm,sm,am,lm,cm,dm,...yc(),Ac,Oc,xc,Dc,Pc,Lc,Nc,Hh,Vh].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_initWorkbenchParts(){const i=this._uiController,t=this._injector;this.disposeWithMe(i.registerComponent(C.DesktopUIPart.HEADER,()=>Z.connectInjector(ih,t))),this.disposeWithMe(i.registerComponent(C.DesktopUIPart.FOOTER,()=>Z.connectInjector(nh,t))),this.disposeWithMe(i.registerComponent(C.DesktopUIPart.CONTENT,()=>Z.connectInjector(oh,t)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(l.UniverInstanceType.SHEET,i=>{this._injector.get(w.ITextSelectionRenderManager).focus()}))}};ei=vm([l.OnLifecycle(l.LifecycleStages.Ready,ei),ht(0,P.Inject(P.Injector)),ht(1,P.Inject(C.ComponentManager)),ht(2,C.ILayoutService),ht(3,l.ICommandService),ht(4,C.IShortcutService),ht(5,C.IMenuService),ht(6,C.IUIController)],ei);var Cm=Object.defineProperty,Im=Object.getOwnPropertyDescriptor,Mm=(i,t,e,n)=>{for(var o=n>1?void 0:n?Im(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Cm(t,e,o),o},mt=(i,t)=>(e,n)=>t(e,n,i);let ti=class extends l.Disposable{constructor(t,e,n,o,r,s,a){super();I(this,"_calculateTimeout",-1);this._univerInstanceService=t,this._selectionManagerService=e,this._functionService=n,this._statusBarService=o,this._commandService=r,this._formulaDataModel=s,this._numfmtService=a,this._init()}_init(){this._registerSelectionListener()}_registerSelectionListener(){const t=l.debounce(e=>{var o;const n=(o=e[e.length-1])==null?void 0:o.primary;this._calculateSelection(e.map(r=>r.range),n)},100);this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoving$.subscribe(e=>{var n;((n=this._selectionManagerService.getCurrent())==null?void 0:n.pluginName)===f.NORMAL_SELECTION_PLUGIN_NAME&&e&&t(e)}))),this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(e=>{var n;((n=this._selectionManagerService.getCurrent())==null?void 0:n.pluginName)===f.NORMAL_SELECTION_PLUGIN_NAME&&e&&t(e)}))),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===f.SetRangeValuesMutation.id){const n=this._selectionManagerService.getSelections();n&&t(n)}}))}_calculateSelection(t,e){var c;const n=this._univerInstanceService.getCurrentUniverSheetInstance(),o=n.getUnitId(),r=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,rowData:u.rowData,columnData:u.columnData}}),t!=null&&t.length){const d=t.map(v=>new K.RangeReferenceObject(v,r,o));d.forEach(v=>{v.setUnitData({[o]:s}),a&&v.setArrayFormulaCellData(K.convertUnitDataToRuntime(a))});const u=this._statusBarService.getFunctions(),h=d.map(v=>v.toArrayValueObject(!1)),m=u.map(v=>{const M=this._functionService.getExecutor(v.func);if(!M)return;const R=M==null?void 0:M.calculate(...h),b=R==null?void 0:R.getValue();if(b)return{func:v.func,value:b}});if(m.every(v=>v===void 0))return;let S=null;if(e){const{actualRow:v,actualColumn:M}=e;S=(c=this._numfmtService.getValue(o,r,v,M))==null?void 0:c.pattern}const _={values:m.filter(v=>v!==void 0),pattern:S};this._statusBarService.setState(_)}else this._statusBarService.setState(null)}_isSingleCell(t){return t.startRow===t.endRow&&t.startColumn===t.endColumn}};ti=Mm([l.OnLifecycle(l.LifecycleStages.Ready,ti),mt(0,l.IUniverInstanceService),mt(1,P.Inject(f.SelectionManagerService)),mt(2,K.IFunctionService),mt(3,Ki),mt(4,l.ICommandService),mt(5,P.Inject(K.FormulaDataModel)),mt(6,P.Inject(f.INumfmtService))],ti);var Rm=Object.defineProperty,bm=Object.getOwnPropertyDescriptor,wm=(i,t,e,n)=>{for(var o=n>1?void 0:n?bm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Rm(t,e,o),o},St=(i,t)=>(e,n)=>t(e,n,i);let ni=class extends l.Disposable{constructor(i,t,e,n,o,r,s){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=t,this._commandService=e,this._renderManagerService=n,this._selectionRenderService=o,this._selectionManagerService=r,this._scrollManagerService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._zoomEventBinding()}_zoomEventBinding(){var t;const i=(t=this._getSheetObject())==null?void 0:t.scene;i!=null&&(i.getViewport(F.VIEW_MAIN),this.disposeWithMe(l.toDisposable(i.onMouseWheelObserver.add((e,n)=>{if(!e.ctrlKey)return;const o=Math.abs(e.deltaX);let r=o<40?.2:o<80?.4:.2;r*=e.deltaY>0?-1:1,i.scaleX<1&&(r/=2);const s=this._currentUniverService.getCurrentUniverSheetInstance(),a=s.getActiveSheet(),c=a.getZoomRatio();let d=+Number.parseFloat(`${c+r}`).toFixed(1);d=d>=4?4:d<=.1?.1:d,this._commandService.executeCommand(Ln.id,{zoomRatio:Math.round(d*10)/10,unitId:s.getUnitId(),subUnitId:a.getSheetId()}),e.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=[Pe.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(i.includes(t.id)){const e=this._currentUniverService.getCurrentUniverSheetInstance(),n=e.getActiveSheet(),o=t.params,{unitId:r,subUnitId:s}=o;if(!(r===e.getUnitId()&&s===n.getSheetId()))return;const a=n.getConfig().zoomRatio||1;this._updateViewZoom(a)}}))}_updateViewZoom(i){const t=this._getSheetObject();t==null||t.scene.scale(i,i),t==null||t.spreadsheet.makeForceDirty()}_getSheetObject(){return Ie(this._currentUniverService,this._renderManagerService)}};ni=wm([l.OnLifecycle(l.LifecycleStages.Rendered,ni),St(0,P.Inject(A.SheetSkeletonManagerService)),St(1,l.IUniverInstanceService),St(2,l.ICommandService),St(3,w.IRenderManagerService),St(4,fe),St(5,P.Inject(f.SelectionManagerService)),St(6,P.Inject(Xe))],ni);var Tm=Object.defineProperty,Em=Object.getOwnPropertyDescriptor,ym=(i,t,e,n)=>{for(var o=n>1?void 0:n?Em(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Tm(t,e,o),o},on=(i,t)=>(e,n)=>t(e,n,i);A.SheetCanvasView=class extends l.RxDisposable{constructor(e,n,o,r,s){super();I(this,"_scene");I(this,"_currentWorkbook");I(this,"_fps$",new k.BehaviorSubject(""));I(this,"fps$",this._fps$.asObservable());this._currentUniverService=e,this._commandService=n,this._renderManagerService=o,this._selectionRenderService=r,this._sheetSkeletonManagerService=s,this._initialize()}_initialize(){this._init()}dispose(){this._fps$.complete()}_init(){this._currentUniverService.currentSheet$.subscribe(e=>{this._create(e)}),this._currentUniverService.getAllUniverSheetsInstance().forEach(e=>{this._create(e)})}_create(e){if(e==null)return;const n=e.getUnitId();this._renderManagerService.has(n)||(this._currentWorkbook=e,this._addNewRender())}_addNewRender(){const e=this._currentWorkbook,n=e.getUnitId(),o=e.getContainer(),r=e.getParentRenderUnitId();if(o!=null&&r!=null)throw new Error("container or parentRenderUnitId can only exist one");const s=o==null&&r!=null;s?this._renderManagerService.createRenderWithParent(n,r):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 w.Layer(c,[],0),new w.Layer(c,[],2)),a!=null&&this._addComponent(a),e.getShouldRenderLoopImmediately()&&!s&&d.runRenderLoop(()=>{c.render(),this._fps$.next(Math.round(d.getFps()).toString())}),this._renderManagerService.setCurrent(n)}_addComponent(e){const n=this._scene,o=this._currentWorkbook,r=o.getActiveSheet(),s=o.getUnitId(),a=r.getSheetId();this._addViewport(r);const c=new w.Spreadsheet(_e.MAIN),d=new w.SpreadsheetRowHeader(_e.ROW),u=new w.SpreadsheetColumnHeader(_e.COLUMN),h=new w.Rect(_e.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});e.mainComponent=c,e.components.set(_e.MAIN,c),e.components.set(_e.ROW,d),e.components.set(_e.COLUMN,u),e.components.set(_e.LEFT_TOP,h),n.addObjects([c],Mo),n.addObjects([d,u,h],et),n.enableLayerCache(Mo,et),this._sheetSkeletonManagerService.setCurrent({sheetId:a,unitId:s})}_addViewport(e){const n=this._scene;if(n==null)return;const{rowHeader:o,columnHeader:r}=e.getConfig(),s=new w.Viewport(F.VIEW_MAIN,n,{left:o.width,top:r.height,bottom:0,right:0,isWheelPreventDefaultX:!0});return new w.Viewport(F.VIEW_ROW_TOP,n,{active:!1,isWheelPreventDefaultX:!0}),new w.Viewport(F.VIEW_ROW_BOTTOM,n,{left:0,top:r.height,bottom:0,width:o.width,isWheelPreventDefaultX:!0}),new w.Viewport(F.VIEW_COLUMN_LEFT,n,{active:!1,isWheelPreventDefaultX:!0}),new w.Viewport(F.VIEW_COLUMN_RIGHT,n,{left:o.width,top:0,height:r.height,right:0,isWheelPreventDefaultX:!0}),new w.Viewport(F.VIEW_LEFT_TOP,n,{left:0,top:0,width:o.width,height:r.height,isWheelPreventDefaultX:!0}),new w.Viewport(F.VIEW_MAIN_LEFT_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),new w.Viewport(F.VIEW_MAIN_LEFT,n,{isWheelPreventDefaultX:!0,active:!1}),new w.Viewport(F.VIEW_MAIN_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),this.disposeWithMe(l.toDisposable(n.onMouseWheelObserver.add((a,c)=>{if(a.ctrlKey)return;let d=0,u=0;const h=s.limitedScroll();if(a.inputIndex===w.PointerInput.MouseWheelX){const S=Math.abs(a.deltaX);a.deltaX>0?d=S:d=-S,this._commandService.executeCommand(Wt.id,{offsetX:d}),n.getParent().classType===w.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedX||c.stopPropagation():s.isWheelPreventDefaultX?a.preventDefault():h!=null&&h.isLimitedX||a.preventDefault()}if(a.inputIndex===w.PointerInput.MouseWheelY){let S=Math.abs(a.deltaY);a.shiftKey?(S*=3,a.deltaY>0?d=S:d=-S,this._commandService.executeCommand(Wt.id,{offsetX:d}),n.getParent().classType===w.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=S:u=-S,this._commandService.executeCommand(Wt.id,{offsetY:u}),n.getParent().classType===w.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedY||c.stopPropagation():s.isWheelPreventDefaultY?a.preventDefault():h!=null&&h.isLimitedY||a.preventDefault())}a.inputIndex,w.PointerInput.MouseWheelZ,this._scene.makeDirty(!0)}))),new w.ScrollBar(s),n.attachControl(),s}},A.SheetCanvasView=ym([l.OnLifecycle(l.LifecycleStages.Ready,A.SheetCanvasView),on(0,l.IUniverInstanceService),on(1,l.ICommandService),on(2,w.IRenderManagerService),on(3,fe),on(4,P.Inject(A.SheetSkeletonManagerService))],A.SheetCanvasView);var Om=Object.defineProperty,Am=Object.getOwnPropertyDescriptor,xm=(i,t,e,n)=>{for(var o=n>1?void 0:n?Am(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Om(t,e,o),o},rn=(i,t)=>(e,n)=>t(e,n,i);A.HoverManagerService=class{constructor(t,e,n,o,r){I(this,"_currentCell$",new k.Subject);I(this,"currentCell$",this._currentCell$.asObservable().pipe(k.distinctUntilChanged((t,e)=>{var n,o,r,s,a,c,d,u;return((n=t==null?void 0:t.location)==null?void 0:n.unitId)===((o=e==null?void 0:e.location)==null?void 0:o.unitId)&&((r=t==null?void 0:t.location)==null?void 0:r.subUnitId)===((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)&&((a=t==null?void 0:t.location)==null?void 0:a.row)===((c=e==null?void 0:e.location)==null?void 0:c.row)&&((d=t==null?void 0:t.location)==null?void 0:d.col)===((u=e==null?void 0:e.location)==null?void 0:u.col)})));I(this,"_lastPosition",null);this._univerInstanceService=t,this._scrollManagerService=e,this._sheetSkeletonManagerService=n,this._renderManagerService=o,this._selectionRenderService=r}_calcActiveCell(){if(!this._lastPosition)return;const{offsetX:t,offsetY:e}=this._lastPosition,n=this._univerInstanceService.getCurrentUniverSheetInstance(),o=n.getActiveSheet(),r=this._sheetSkeletonManagerService.getCurrent(),s=this._renderManagerService.getRenderById(n.getUnitId()),a=this._scrollManagerService.getCurrentScroll();if(!r||!a||!s)return;const{scene:c}=s,{skeleton:d,sheetId:u,unitId:h}=r,m=_l(t,e,c,d);if(!m){this._currentCell$.next(null);return}const{row:S,col:g,mergeCell:_,actualCol:v,actualRow:M}=m,R={unitId:h,subUnitId:u,workbook:n,worksheet:o,row:M,col:v};let b;_?b=_:b={startRow:S,endRow:S,startColumn:g,endColumn:g};const E=c.getActiveViewportByCoord(w.Vector2.FromArray([t,e]));if(!E)return;const{scaleX:T,scaleY:y}=c.getAncestorScale(),O={x:E.actualScrollX,y:E.actualScrollY},x={startX:(d.getOffsetByPositionX(b.startColumn-1)-O.x)*T,endX:(d.getOffsetByPositionX(b.endColumn)-O.x)*T,startY:(d.getOffsetByPositionY(b.startRow-1)-O.y)*y,endY:(d.getOffsetByPositionY(b.endRow)-O.y)*y};this._currentCell$.next({location:R,position:x})}onMouseMove(t,e){this._lastPosition={offsetX:t,offsetY:e},this._calcActiveCell()}onScrollStart(){this._currentCell$.next(null)}onScrollEnd(){this._calcActiveCell()}},A.HoverManagerService=xm([rn(0,l.IUniverInstanceService),rn(1,P.Inject(Xe)),rn(2,P.Inject(A.SheetSkeletonManagerService)),rn(3,w.IRenderManagerService),rn(4,fe)],A.HoverManagerService);var Nm=Object.defineProperty,Dm=Object.getOwnPropertyDescriptor,Pm=(i,t,e,n)=>{for(var o=n>1?void 0:n?Dm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Nm(t,e,o),o},no=(i,t)=>(e,n)=>t(e,n,i);A.HoverController=class extends l.Disposable{constructor(t,e,n){super(),this._renderManagerService=t,this._hoverManagerService=e,this._univerInstanceService=n,this._initPointerEvent()}_initScrollEvent(){}_initPointerEvent(){const t=this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId());if(!t)return;const{scene:e}=t,n=e.onPointerMoveObserver.add(o=>{this._hoverManagerService.onMouseMove(o.offsetX,o.offsetY)});this.disposeWithMe({dispose(){e.onPointerMoveObserver.remove(n)}})}},A.HoverController=Pm([l.OnLifecycle(l.LifecycleStages.Rendered,A.HoverController),no(0,w.IRenderManagerService),no(1,P.Inject(A.HoverManagerService)),no(2,l.IUniverInstanceService)],A.HoverController);const Ke={cellAlert:"univer-cell-alert",cellAlertTitle:"univer-cell-alert-title",cellAlertIcon:"univer-cell-alert-icon",cellAlertIconError:"univer-cell-alert-icon-error",cellAlertIconInfo:"univer-cell-alert-icon-info",cellAlertIconWarning:"univer-cell-alert-icon-warning",cellAlertContent:"univer-cell-alert-content"};function Lm(){const i=Z.useDependency(A.CellAlertManagerService),t=C.useObservable(i.currentAlert$,i.currentAlert),{type:e,title:n,message:o}=t||{},r={[sn.ERROR]:p.jsx(Xr,{className:xe(Ke.cellAlertIcon,Ke.cellAlertIconError)}),[sn.INFO]:p.jsx(ns,{className:xe(Ke.cellAlertIcon,Ke.cellAlertIconInfo)}),[sn.WARNING]:p.jsx(ns,{className:xe(Ke.cellAlertIcon,Ke.cellAlertIconWarning)})};return p.jsxs("div",{className:Ke.cellAlert,children:[p.jsxs("div",{className:Ke.cellAlertTitle,children:[e?r[e]:null,n]}),p.jsx("div",{className:Ke.cellAlertContent,children:o})]})}const Ss="univer.sheet.cell-alert";var Um=Object.defineProperty,Hm=Object.getOwnPropertyDescriptor,Vm=(i,t,e,n)=>{for(var o=n>1?void 0:n?Hm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Um(t,e,o),o},Nt=(i,t)=>(e,n)=>t(e,n,i);A.SheetCanvasPopManagerService=class extends l.Disposable{constructor(t,e,n,o,r,s){super(),this._globalPopupManagerService=t,this._renderManagerService=e,this._univerInstanceService=n,this._sheetSkeletonManagerService=o,this._refRangeService=r,this._commandService=s}_calcCellPosition(t,e,n,o,r){const{scene:s,engine:a}=n,c=o.getCellByIndex(t,e),d=c.isMergedMainCell?c.mergeInfo:c,{scaleX:u,scaleY:h}=s.getAncestorScale(),m={x:r.actualScrollX,y:r.actualScrollY},S=a.getCanvasElement().getBoundingClientRect();return{left:(d.startX-m.x)*u,right:(d.endX-m.x)*u,top:(d.startY-m.y)*h+S.top,bottom:(d.endY-m.y)*h+S.top}}_createCellPositionObserver(t,e,n,o,r){let s=t,a=e;const c=this._calcCellPosition(s,a,n,o,r),d=new k.BehaviorSubject(c),u=()=>d.next(this._calcCellPosition(s,a,n,o,r)),h=new l.DisposableCollection;return h.add(this._commandService.onCommandExecuted(S=>{if(S.id===f.SetWorksheetRowAutoHeightMutation.id&&S.params.rowsAutoHeightInfo.findIndex(_=>_.row===s)>-1){u();return}(f.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(S.id)>-1||S.id===nt.id||S.id===Pe.id)&&u()})),{position$:d,disposable:h,position:c,updateRowCol:(S,g)=>{s=S,a=g,u()}}}_createObjectPositionObserver(t,e,n,o){const r=()=>{const{scene:d}=e,{left:u,top:h,width:m,height:S}=t,g={left:u,right:u+m,top:h,bottom:h+S},_=pl(g,d,n,o),v=e.engine.getCanvasElement().getBoundingClientRect();return{left:_.left,right:_.right,top:_.top+v.top,bottom:_.bottom+v.top}},s=r(),a=new k.BehaviorSubject(s),c=new l.DisposableCollection;return c.add(this._commandService.onCommandExecuted(d=>{(d.id===nt.id||d.id===Pe.id)&&a.next(r())})),{position:s,position$:a,disposable:c}}attachPopupToObject(t,e){const n=this._univerInstanceService.getCurrentUniverSheetInstance(),o=n.getActiveSheet(),r=n.getUnitId(),s=o.getSheetId(),a=this._sheetSkeletonManagerService.getOrCreateSkeleton({unitId:r,sheetId:s}),c=this._renderManagerService.getRenderById(r);if(!c||!a)return{dispose:()=>{}};const{position:d,position$:u,disposable:h}=this._createObjectPositionObserver(t,c,a,o),m=this._globalPopupManagerService.addPopup({...e,unitId:r,subUnitId:s,anchorRect:d,anchorRect$:u});return{dispose:()=>{this._globalPopupManagerService.removePopup(m),u.complete(),h.dispose()}}}attachPopupToCell(t,e,n,o){const r=this._univerInstanceService.getCurrentUniverSheetInstance(),s=r.getActiveSheet(),a=r.getUnitId(),c=s.getSheetId(),d=this._sheetSkeletonManagerService.getOrCreateSkeleton({unitId:a,sheetId:c}),u=this._renderManagerService.getRenderById(a);if(!u||!d)return null;const h=o!=null?o:fl(t,e,u.scene,s);if(!h)return null;const{position:m,position$:S,disposable:g,updateRowCol:_}=this._createCellPositionObserver(t,e,u,d,h),v=this._globalPopupManagerService.addPopup({...n,unitId:a,subUnitId:c,anchorRect:m,anchorRect$:S}),M=new l.DisposableCollection;M.add(g),M.add(l.toDisposable(()=>{this._globalPopupManagerService.removePopup(v),S.complete()}));const R={startRow:t,endRow:t,startColumn:e,endColumn:e};return M.add(this._refRangeService.watchRange(a,c,R,(b,E)=>{E?_(E.startRow,E.startColumn):M.dispose()})),M}},A.SheetCanvasPopManagerService=Vm([Nt(0,P.Inject(C.ICanvasPopupService)),Nt(1,w.IRenderManagerService),Nt(2,l.IUniverInstanceService),Nt(3,P.Inject(A.SheetSkeletonManagerService)),Nt(4,P.Inject(f.RefRangeService)),Nt(5,l.ICommandService)],A.SheetCanvasPopManagerService);var km=Object.defineProperty,Bm=Object.getOwnPropertyDescriptor,Fm=(i,t,e,n)=>{for(var o=n>1?void 0:n?Bm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&km(t,e,o),o},gs=(i,t)=>(e,n)=>t(e,n,i),sn=(i=>(i[i.INFO=0]="INFO",i[i.WARNING=1]="WARNING",i[i.ERROR=2]="ERROR",i))(sn||{});A.CellAlertManagerService=class{constructor(t,e){I(this,"_currentAlert$",new k.Subject);I(this,"_currentPopup");I(this,"_currentAlert",null);I(this,"currentAlert$",this._currentAlert$.asObservable());this._renderManagerService=t,this._canvasPopManagerService=e}get currentAlert(){return this._currentAlert}showAlert(t){this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null;const{location:e}=t,{row:n,col:o,unitId:r}=e;this._renderManagerService.getRenderById(r)&&(this._currentAlert=t,this._currentAlert$.next(t),this._currentPopup=this._canvasPopManagerService.attachPopupToCell(n,o,{componentKey:Ss,direction:"horizontal",offset:[2,0]}))}clearAlert(){this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._currentAlert=null,this._currentAlert$.next(null)}},A.CellAlertManagerService=Fm([gs(0,w.IRenderManagerService),gs(1,P.Inject(A.SheetCanvasPopManagerService))],A.CellAlertManagerService);var Wm=Object.defineProperty,jm=Object.getOwnPropertyDescriptor,zm=(i,t,e,n)=>{for(var o=n>1?void 0:n?jm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Wm(t,e,o),o},Ym=(i,t)=>(e,n)=>t(e,n,i);let ii=class extends l.Disposable{constructor(i){super(),this._componentManager=i,this._initComponent()}_initComponent(){this._componentManager.register(Ss,Lm)}};ii=zm([l.OnLifecycle(l.LifecycleStages.Starting,ii),Ym(0,P.Inject(C.ComponentManager))],ii);var Xm=Object.defineProperty,$m=Object.getOwnPropertyDescriptor,Zm=(i,t,e,n)=>{for(var o=n>1?void 0:n?$m(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Xm(t,e,o),o},io=(i,t)=>(e,n)=>t(e,n,i);A.UniverSheetsUIPlugin=(oo=class extends l.Plugin{constructor(t,e,n,o){super(co),this._injector=e,this._localeService=n,this._currentUniverService=o,this._localeService.load({zhCN:Sr})}onStarting(t){[[A.SheetCanvasView],[Ht],[we,{useClass:A.EditorBridgeService}],[pt,{useClass:A.SheetClipboardService}],[Ot,{useClass:Zd}],[Rt,{useClass:Ai}],[Xt,{useClass:gr}],[wn,{useClass:uc}],[jt,{useClass:A.AutoFillService}],[Xe],[A.SheetSkeletonManagerService],[fe,{useClass:A.SelectionRenderService}],[Ki,{useClass:Qu}],[Ut,{useClass:A.MarkSelectionService}],[A.HoverManagerService],[A.SheetCanvasPopManagerService],[A.CellAlertManagerService],[Tn],[En],[Un],[xn],[Nn],[Hn],[Vn],[Bn],[Fn],[Wn],[zn],[Xn],[A.ScrollController],[$n],[yn],[On],[Zn],[ei],[Dn],[ni],[A.AutoFillController],[ti],[An],[Yn],[A.HoverController],[ii],[A.CellCustomRenderController]].forEach(e=>t.add(e))}onReady(){this._markSheetAsFocused()}_markSheetAsFocused(){const t=this._currentUniverService;t.currentSheet$.pipe(Is.filter(e=>!!e)).subscribe(e=>{t.focusUniverInstance(e.getUnitId())})}},I(oo,"type",l.PluginType.Sheet),oo),A.UniverSheetsUIPlugin=Zm([io(1,P.Inject(P.Injector)),io(2,P.Inject(l.LocaleService)),io(3,l.IUniverInstanceService)],A.UniverSheetsUIPlugin),A.APPLY_TYPE=oe,A.AutoFillCommand=po,A.COPY_TYPE=at,A.CellAlertType=sn,A.CellEditorManagerService=gr,A.DATA_TYPE=me,A.ExpandSelectionCommand=De,A.IAutoFillService=jt,A.ICellEditorManagerService=Xt,A.IEditorBridgeService=we,A.IFormulaEditorManagerService=wn,A.IMarkSelectionService=Ut,A.ISelectionRenderService=fe,A.ISheetClipboardService=pt,A.JumpOver=ke,A.MoveSelectionCommand=be,A.PASTE_SPECIAL_MENU_ID=Tt,A.PREDEFINED_HOOK_NAME=ve,A.ResetScrollCommand=Xa,A.SHEET_UI_PLUGIN_NAME=co,A.SHEET_VIEW_KEY=_e,A.ScrollCommand=ct,A.ScrollToCellCommand=Yo,A.SelectionShape=fn,A.SetCellEditVisibleArrowOperation=Ft,A.SetCellEditVisibleOperation=Te,A.SetScrollOperation=nt,A.SetScrollRelativeCommand=Wt,A.SetZoomRatioOperation=Pe,A.SheetCopyCommand=Po,A.SheetPasteCommand=vt,A.VIEWPORT_KEY=F,A.enUS=dc,A.getAutoFillRepeatRange=Us,A.getCoordByCell=Mi,A.getCoordByOffset=Ct,A.getEditorObject=hn,A.getRepeatRange=fa,A.getSheetObject=Ie,A.getTransformCoord=Cn,A.mergeSetRangeValues=gi,A.whenFormulaEditorActivated=Vs,A.whenSheetEditorFocused=ie,A.zhCN=Sr,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|