@univerjs/sheets-formula 0.1.0-alpha.1 → 0.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +178 -0
- package/lib/cjs/index.js +11 -4215
- package/lib/es/index.js +4346 -0
- package/lib/index.css +1 -214
- package/lib/types/commands/commands/formula-clipboard.command.d.ts +18 -0
- package/lib/types/commands/commands/insert-function.command.d.ts +15 -1
- package/lib/types/commands/operations/__tests__/create-command-test-bed.d.ts +15 -1
- package/lib/types/commands/operations/__tests__/insert-function.operation.spec.d.ts +15 -1
- package/lib/types/commands/operations/editor-formula.operation.d.ts +15 -1
- package/lib/types/commands/operations/help-function.operation.d.ts +15 -1
- package/lib/types/commands/operations/insert-function.operation.d.ts +15 -1
- package/lib/types/commands/operations/more-functions.operation.d.ts +15 -1
- package/lib/types/commands/operations/reference-absolute.operation.d.ts +15 -1
- package/lib/types/commands/operations/search-function.operation.d.ts +15 -1
- package/lib/types/common/plugin-name.d.ts +15 -1
- package/lib/types/common/prompt.d.ts +15 -1
- package/lib/types/common/selection.d.ts +15 -1
- package/lib/types/controllers/__tests__/create-command-test-bed.d.ts +15 -1
- package/lib/types/controllers/__tests__/formula-auto-fill.controller.spec.d.ts +15 -1
- package/lib/types/controllers/__tests__/formula-clipboard.controller.spec.d.ts +16 -0
- package/lib/types/controllers/__tests__/update-formula.controller.spec.d.ts +16 -0
- package/lib/types/controllers/__tests__/utils.spec.d.ts +16 -0
- package/lib/types/controllers/active-dirty.controller.d.ts +40 -0
- package/lib/types/controllers/array-formula-display.controller.d.ts +27 -0
- package/lib/types/controllers/formula-auto-fill.controller.d.ts +18 -4
- package/lib/types/controllers/formula-clipboard.controller.d.ts +41 -0
- package/lib/types/controllers/formula-editor-show.controller.d.ts +35 -0
- package/lib/types/controllers/formula-input.controller.d.ts +18 -4
- package/lib/types/controllers/formula-ui.controller.d.ts +15 -1
- package/lib/types/controllers/menu.d.ts +16 -1
- package/lib/types/controllers/prompt.controller.d.ts +18 -4
- package/lib/types/controllers/shortcuts/prompt.shortcut.d.ts +15 -1
- package/lib/types/controllers/trigger-calculation.controller.d.ts +32 -0
- package/lib/types/controllers/update-formula.controller.d.ts +75 -0
- package/lib/types/controllers/utils.d.ts +26 -0
- package/lib/types/formula-ui-plugin.d.ts +16 -2
- package/lib/types/index.d.ts +17 -2
- package/lib/types/locale/en-US.d.ts +18 -1
- package/lib/types/locale/function-list/array/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/array/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/compatibility/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/compatibility/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/cube/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/cube/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/database/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/database/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/date/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/date/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/engineering/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/engineering/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/financial/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/financial/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/information/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/information/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/logical/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/logical/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/lookup/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/lookup/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/math/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/math/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/statistical/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/statistical/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/text/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/text/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/univer/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/univer/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/web/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/web/zh-CN.d.ts +15 -1
- package/lib/types/locale/index.d.ts +15 -1
- package/lib/types/locale/zh-CN.d.ts +18 -1
- package/lib/types/services/active-dirty-manager.service.d.ts +48 -0
- package/lib/types/services/description.service.d.ts +21 -7
- package/lib/types/services/formula-input.service.d.ts +15 -4
- package/lib/types/services/function-list/array.d.ts +15 -1
- package/lib/types/services/function-list/compatibility.d.ts +15 -1
- package/lib/types/services/function-list/cube.d.ts +15 -1
- package/lib/types/services/function-list/database.d.ts +15 -1
- package/lib/types/services/function-list/date.d.ts +15 -1
- package/lib/types/services/function-list/engineering.d.ts +15 -1
- package/lib/types/services/function-list/financial.d.ts +15 -1
- package/lib/types/services/function-list/function-list.d.ts +15 -1
- package/lib/types/services/function-list/information.d.ts +15 -1
- package/lib/types/services/function-list/logical.d.ts +15 -1
- package/lib/types/services/function-list/lookup.d.ts +15 -1
- package/lib/types/services/function-list/math.d.ts +15 -1
- package/lib/types/services/function-list/statistical.d.ts +15 -1
- package/lib/types/services/function-list/text.d.ts +15 -1
- package/lib/types/services/function-list/univer.d.ts +15 -1
- package/lib/types/services/function-list/web.d.ts +15 -1
- package/lib/types/services/prompt.service.d.ts +15 -1
- package/lib/types/services/utils.d.ts +15 -1
- package/lib/types/views/FormulaPromptContainer.d.ts +15 -1
- package/lib/types/views/more-functions/MoreFunctions.d.ts +15 -1
- package/lib/types/views/more-functions/function-help/FunctionHelp.d.ts +15 -1
- package/lib/types/views/more-functions/function-params/FunctionParams.d.ts +15 -1
- package/lib/types/views/more-functions/input-params/InputParams.d.ts +15 -1
- package/lib/types/views/more-functions/interface.d.ts +15 -1
- package/lib/types/views/more-functions/select-function/SelectFunction.d.ts +15 -1
- package/lib/types/views/prompt/error-function/error-function.d.ts +15 -1
- package/lib/types/views/prompt/help-function/HelpFunction.d.ts +15 -1
- package/lib/types/views/prompt/search-function/SearchFunction.d.ts +15 -1
- package/lib/umd/index.js +11 -0
- package/package.json +42 -31
- package/LICENSE +0 -21
- package/lib/cjs/locale/en-US.js +0 -223
- package/lib/cjs/locale/zh-CN.js +0 -223
- package/lib/esm/index.js +0 -4205
- package/lib/esm/locale/en-US.js +0 -200
- package/lib/esm/locale/zh-CN.js +0 -200
- package/lib/types/commands/commands/insert-function.command.d.ts.map +0 -1
- package/lib/types/commands/operations/__tests__/create-command-test-bed.d.ts.map +0 -1
- package/lib/types/commands/operations/__tests__/insert-function.operation.spec.d.ts.map +0 -1
- package/lib/types/commands/operations/editor-formula.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/help-function.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/insert-function.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/more-functions.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/reference-absolute.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/search-function.operation.d.ts.map +0 -1
- package/lib/types/common/plugin-name.d.ts.map +0 -1
- package/lib/types/common/prompt.d.ts.map +0 -1
- package/lib/types/common/selection.d.ts.map +0 -1
- package/lib/types/controllers/__tests__/create-command-test-bed.d.ts.map +0 -1
- package/lib/types/controllers/__tests__/formula-auto-fill.controller.spec.d.ts.map +0 -1
- package/lib/types/controllers/formula-auto-fill.controller.d.ts.map +0 -1
- package/lib/types/controllers/formula-input.controller.d.ts.map +0 -1
- package/lib/types/controllers/formula-ui.controller.d.ts.map +0 -1
- package/lib/types/controllers/menu.d.ts.map +0 -1
- package/lib/types/controllers/prompt.controller.d.ts.map +0 -1
- package/lib/types/controllers/shortcuts/prompt.shortcut.d.ts.map +0 -1
- package/lib/types/formula-ui-plugin.d.ts.map +0 -1
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/locale/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/array/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/array/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/compatibility/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/compatibility/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/cube/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/cube/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/database/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/database/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/date/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/date/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/engineering/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/engineering/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/financial/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/financial/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/information/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/information/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/logical/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/logical/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/lookup/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/lookup/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/math/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/math/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/statistical/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/statistical/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/text/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/text/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/univer/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/univer/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/web/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/web/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/index.d.ts.map +0 -1
- package/lib/types/locale/zh-CN.d.ts.map +0 -1
- package/lib/types/services/description.service.d.ts.map +0 -1
- package/lib/types/services/formula-input.service.d.ts.map +0 -1
- package/lib/types/services/function-list/array.d.ts.map +0 -1
- package/lib/types/services/function-list/compatibility.d.ts.map +0 -1
- package/lib/types/services/function-list/cube.d.ts.map +0 -1
- package/lib/types/services/function-list/database.d.ts.map +0 -1
- package/lib/types/services/function-list/date.d.ts.map +0 -1
- package/lib/types/services/function-list/engineering.d.ts.map +0 -1
- package/lib/types/services/function-list/financial.d.ts.map +0 -1
- package/lib/types/services/function-list/function-list.d.ts.map +0 -1
- package/lib/types/services/function-list/information.d.ts.map +0 -1
- package/lib/types/services/function-list/logical.d.ts.map +0 -1
- package/lib/types/services/function-list/lookup.d.ts.map +0 -1
- package/lib/types/services/function-list/math.d.ts.map +0 -1
- package/lib/types/services/function-list/statistical.d.ts.map +0 -1
- package/lib/types/services/function-list/text.d.ts.map +0 -1
- package/lib/types/services/function-list/univer.d.ts.map +0 -1
- package/lib/types/services/function-list/web.d.ts.map +0 -1
- package/lib/types/services/prompt.service.d.ts.map +0 -1
- package/lib/types/services/utils.d.ts.map +0 -1
- package/lib/types/views/FormulaPromptContainer.d.ts.map +0 -1
- package/lib/types/views/more-functions/MoreFunctions.d.ts.map +0 -1
- package/lib/types/views/more-functions/function-help/FunctionHelp.d.ts.map +0 -1
- package/lib/types/views/more-functions/function-params/FunctionParams.d.ts.map +0 -1
- package/lib/types/views/more-functions/input-params/InputParams.d.ts.map +0 -1
- package/lib/types/views/more-functions/interface.d.ts.map +0 -1
- package/lib/types/views/more-functions/select-function/SelectFunction.d.ts.map +0 -1
- package/lib/types/views/prompt/error-function/error-function.d.ts.map +0 -1
- package/lib/types/views/prompt/help-function/HelpFunction.d.ts.map +0 -1
- package/lib/types/views/prompt/search-function/SearchFunction.d.ts.map +0 -1
package/lib/umd/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
(function(j,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("@ctrl/tinycolor"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("rxjs"),require("@wendellhu/redi/react-bindings"),require("react"),require("@univerjs/design"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/engine-formula","@univerjs/sheets","@univerjs/sheets-ui","@ctrl/tinycolor","@univerjs/engine-render","@univerjs/ui","rxjs","@wendellhu/redi/react-bindings","react","@univerjs/design","@univerjs/docs"],s):(j=typeof globalThis<"u"?globalThis:j||self,s(j.UniverSheetsFormula={},j.UniverCore,j["@wendellhu/redi"],j.UniverEngineFormula,j.UniverSheets,j.UniverSheetsUi,j.tinycolor,j.UniverEngineRender,j.UniverUi,j.rxjs,j["@wendellhu/redi/react-bindings"],j.React,j.UniverDesign,j.UniverDocs))})(this,function(j,s,T,y,h,D,Be,V,O,G,k,w,Y,ce){"use strict";var Sr=Object.defineProperty;var _r=(j,s,T)=>s in j?Sr(j,s,{enumerable:!0,configurable:!0,writable:!0,value:T}):j[s]=T;var x=(j,s,T)=>(_r(j,typeof s!="symbol"?s+"":s,T),T);var ke;const Ve="formula-ui";class mt extends s.Disposable{constructor(){super(...arguments);x(this,"_dirtyConversionMap",new Map)}dispose(){this._dirtyConversionMap.clear()}remove(t){this._dirtyConversionMap.delete(t)}get(t){return this._dirtyConversionMap.get(t)}has(t){return this._dirtyConversionMap.has(t)}register(t,n){this._dirtyConversionMap.set(t,n)}getDirtyConversionMap(){return this._dirtyConversionMap}}const Ne=T.createIdentifier("univer.formula.active-dirty-manager.service");var dt=Object.defineProperty,ft=Object.getOwnPropertyDescriptor,ht=(i,e,t,n)=>{for(var r=n>1?void 0:n?ft(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&dt(e,t,r),r},Te=(i,e)=>(t,n)=>e(t,n,i);let ue=class extends s.Disposable{constructor(i,e,t){super(),this._activeDirtyManagerService=i,this._currentUniverService=e,this._formulaDataModel=t,this._initialize()}_initialize(){this._initialConversion()}_initialConversion(){this._activeDirtyManagerService.register(h.SetRangeValuesMutation.id,{commandId:h.SetRangeValuesMutation.id,getDirtyData:i=>{const e=i.params;return e.trigger===h.SetStyleCommand.id?{}:{dirtyRanges:this._getSetRangeValuesMutationDirtyRange(e)}}}),this._activeDirtyManagerService.register(h.MoveRangeMutation.id,{commandId:h.MoveRangeMutation.id,getDirtyData:i=>{const e=i.params;return{dirtyRanges:this._getMoveRangeMutationDirtyRange(e)}}}),this._activeDirtyManagerService.register(h.MoveRowsMutation.id,{commandId:h.MoveRowsMutation.id,getDirtyData:i=>{const e=i.params;return{dirtyRanges:this._getMoveRowsMutationDirtyRange(e)}}}),this._activeDirtyManagerService.register(h.MoveColsMutation.id,{commandId:h.MoveColsMutation.id,getDirtyData:i=>{const e=i.params;return{dirtyRanges:this._getMoveRowsMutationDirtyRange(e)}}}),this._activeDirtyManagerService.register(h.DeleteRangeMutation.id,{commandId:h.DeleteRangeMutation.id,getDirtyData:i=>{const e=i.params;return{dirtyRanges:this._getDeleteRangeMutationDirtyRange(e)}}}),this._activeDirtyManagerService.register(h.InsertRangeMutation.id,{commandId:h.InsertRangeMutation.id,getDirtyData:i=>{const e=i.params;return{dirtyRanges:this._getDeleteRangeMutationDirtyRange(e)}}}),this._activeDirtyManagerService.register(h.RemoveRowMutation.id,{commandId:h.RemoveRowMutation.id,getDirtyData:i=>{const e=i.params;return{dirtyRanges:this._getRemoveRowOrColumnMutation(e,!0)}}}),this._activeDirtyManagerService.register(h.RemoveColMutation.id,{commandId:h.RemoveColMutation.id,getDirtyData:i=>{const e=i.params;return{dirtyRanges:this._getRemoveRowOrColumnMutation(e,!1)}}}),this._activeDirtyManagerService.register(h.RemoveSheetMutation.id,{commandId:h.RemoveSheetMutation.id,getDirtyData:i=>{const e=i.params;return{dirtyNameMap:this._getRemoveSheetMutation(e)}}}),this._activeDirtyManagerService.register(h.InsertSheetMutation.id,{commandId:h.InsertSheetMutation.id,getDirtyData:i=>{const e=i.params;return{dirtyNameMap:this._getInsertSheetMutation(e)}}})}_getSetRangeValuesMutationDirtyRange(i){const{worksheetId:e,workbookId:t,cellValue:n}=i,r=[];return n==null||(r.push(...this._getDirtyRangesByCellValue(t,e,n)),r.push(...this._getDirtyRangesForArrayFormula(t,e,n))),r}_getMoveRangeMutationDirtyRange(i){const{worksheetId:e,workbookId:t,from:n,to:r}=i,o=[];return o.push(...this._getDirtyRangesByCellValue(t,e,n)),o.push(...this._getDirtyRangesByCellValue(t,e,r)),o.push(...this._getDirtyRangesForArrayFormula(t,e,r)),o}_getMoveRowsMutationDirtyRange(i){const{worksheetId:e,workbookId:t,sourceRange:n,targetRange:r}=i,o=[],a=this._rangeToMatrix(n).getData(),l=this._rangeToMatrix(r).getData();return o.push(...this._getDirtyRangesByCellValue(t,e,a)),o.push(...this._getDirtyRangesByCellValue(t,e,l)),o.push(...this._getDirtyRangesForArrayFormula(t,e,l)),o}_getDeleteRangeMutationDirtyRange(i){const{worksheetId:e,workbookId:t,ranges:n,shiftDimension:r}=i,o=[],a=this._currentUniverService.getUniverSheetInstance(t),l=a==null?void 0:a.getSheetBySheetId(e),c=(l==null?void 0:l.getLastRowWithContent())||0,u=(l==null?void 0:l.getLastColumnWithContent())||0,f=new s.ObjectMatrix;for(const d of n){let g=null;const{startRow:_,startColumn:I,endRow:m,endColumn:v}=d;r===s.Dimension.ROWS?g=this._rangeToMatrix({startRow:_,startColumn:I,endRow:c,endColumn:v}):r===s.Dimension.COLUMNS&&(g=this._rangeToMatrix({startRow:_,startColumn:I,endRow:m,endColumn:u})),g!=null&&f.merge(g)}const p=f.getData();return o.push(...this._getDirtyRangesByCellValue(t,e,p)),o.push(...this._getDirtyRangesForArrayFormula(t,e,p)),o}_getRemoveRowOrColumnMutation(i,e=!0){const{worksheetId:t,workbookId:n,ranges:r}=i,o=[],a=this._currentUniverService.getUniverSheetInstance(n),l=a==null?void 0:a.getSheetBySheetId(t),c=(l==null?void 0:l.getRowCount())||0,u=(l==null?void 0:l.getColumnCount())||0,f=new s.ObjectMatrix;for(const d of r){let g=null;const{startRow:_,endRow:I,startColumn:m,endColumn:v}=d;e===!0?g=this._rangeToMatrix({startRow:_,startColumn:0,endRow:I,endColumn:u-1}):g=this._rangeToMatrix({startRow:0,startColumn:m,endRow:c,endColumn:v}),g!=null&&f.merge(g)}const p=f.getData();return o.push(...this._getDirtyRangesByCellValue(n,t,p)),o.push(...this._getDirtyRangesForArrayFormula(n,t,p)),o}_getRemoveSheetMutation(i,e){const t={},{worksheetId:n,workbookId:r}=i;return t[r]==null&&(t[r]={}),t[r][n]=e,t}_getInsertSheetMutation(i,e){const t={},{sheet:n,workbookId:r}=i;return t[r]==null&&(t[r]={}),t[r][n.id]=e,t}_rangeToMatrix(i){const e=new s.ObjectMatrix,{startRow:t,startColumn:n,endRow:r,endColumn:o}=i;for(let a=t;a<=r;a++)for(let l=n;l<=o;l++)e.setValue(a,l,{});return e}_getDirtyRangesByCellValue(i,e,t){const n=[];return t==null||new s.ObjectMatrix(t).getDiscreteRanges().forEach(a=>{n.push({unitId:i,sheetId:e,range:a})}),n}_getDirtyRangesForArrayFormula(i,e,t){var a,l;const n=[];if(t==null)return n;const r=new s.ObjectMatrix(t),o=this._formulaDataModel.getArrayFormulaRange();if((a=o==null?void 0:o[i])!=null&&a[e]){const c=new s.ObjectMatrix((l=o==null?void 0:o[i])==null?void 0:l[e]);r.forValue((u,f)=>{c.forValue((p,d,g)=>{const{startRow:_,startColumn:I,endRow:m,endColumn:v}=g;u>=_&&u<=m&&f>=I&&f<=v&&n.push({unitId:i,sheetId:e,range:{startRow:_,startColumn:I,endRow:_,endColumn:I}})})})}return n}};ue=ht([s.OnLifecycle(s.LifecycleStages.Ready,ue),Te(0,Ne),Te(1,s.IUniverInstanceService),Te(2,T.Inject(y.FormulaDataModel))],ue);var pt=Object.defineProperty,gt=Object.getOwnPropertyDescriptor,St=(i,e,t,n)=>{for(var r=n>1?void 0:n?gt(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&pt(e,t,r),r},Fe=(i,e)=>(t,n)=>e(t,n,i);let me=class extends s.Disposable{constructor(i,e,t){super(),this._commandService=i,this._sheetInterceptorService=e,this._formulaDataModel=t,this._initialize()}_initialize(){this._commandExecutedListener(),this._initInterceptorCellContent()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id!==y.SetArrayFormulaDataMutation.id)return;const e=i.params;if(e==null)return;const{arrayFormulaRange:t,arrayFormulaCellData:n}=e;this._formulaDataModel.setArrayFormulaRange(t),this._formulaDataModel.setArrayFormulaCellData(n)}))}_initInterceptorCellContent(){this.disposeWithMe(this._sheetInterceptorService.intercept(h.INTERCEPTOR_POINT.CELL_CONTENT,{priority:100,handler:(i,e,t)=>{var p,d,g,_,I,m;const{workbookId:n,worksheetId:r,row:o,col:a}=e,l=this._formulaDataModel.getArrayFormulaCellData(),c=this._formulaDataModel.getArrayFormulaRange(),u=(g=(d=(p=l==null?void 0:l[n])==null?void 0:p[r])==null?void 0:d[o])==null?void 0:g[a],f=(m=(I=(_=c==null?void 0:c[n])==null?void 0:_[r])==null?void 0:I[o])==null?void 0:m[a];return u==null||f!=null&&f.startRow===o&&f.startColumn===a?t(i):t({...i,...u})}}))}};me=St([s.OnLifecycle(s.LifecycleStages.Ready,me),Fe(0,s.ICommandService),Fe(1,T.Inject(h.SheetInterceptorService)),Fe(2,T.Inject(y.FormulaDataModel))],me);var _t=Object.defineProperty,vt=Object.getOwnPropertyDescriptor,Rt=(i,e,t,n)=>{for(var r=n>1?void 0:n?vt(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&_t(e,t,r),r},$e=(i,e)=>(t,n)=>e(t,n,i);let de=class extends s.Disposable{constructor(i,e){super(),this._autoFillService=i,this._lexerTreeBuilder=e,this._initialize()}_initialize(){this._registerAutoFill()}_registerAutoFill(){const i={type:D.DATA_TYPE.FORMULA,priority:1001,match:e=>s.isFormulaString(e==null?void 0:e.f)||s.isFormulaId(e==null?void 0:e.si),isContinue:(e,t)=>e.type===D.DATA_TYPE.FORMULA,applyFunctions:{[D.APPLY_TYPE.COPY]:(e,t,n,r)=>{const{data:o,index:a}=e;return this._fillCopyFormula(o,t,n,a,r)}}};this._autoFillService.registerRule(i)}_fillCopyFormula(i,e,t,n,r){var c,u;const o=Ct(r),a=[],l=new Map;for(let f=1;f<=e;f++){const p=(f-1)%i.length,d=s.Tools.deepClone(i[p]);if(d){const g=((c=i[p])==null?void 0:c.f)||"",_=((u=i[p])==null?void 0:u.si)||"",I=s.isFormulaString(g);if(s.isFormulaId(_))d.si=_,d.f=null,d.v=null,d.p=null,t===s.Direction.DOWN||t===s.Direction.RIGHT?a.push(d):a.unshift(d);else if(I){let v=l.get(p);if(v)d.si=v,d.f=null,d.v=null,d.p=null;else{v=s.Tools.generateRandomId(6),l.set(p,v);const{offsetX:S,offsetY:C}=It(o,t),E=this._lexerTreeBuilder.moveFormulaRefOffset(g,S,C);d.si=v,d.f=E,d.v=null,d.p=null}t===s.Direction.DOWN||t===s.Direction.RIGHT?a.push(d):a.unshift(d)}}}return a}};de=Rt([s.OnLifecycle(s.LifecycleStages.Ready,de),$e(0,D.IAutoFillService),$e(1,T.Inject(y.LexerTreeBuilder))],de);function It(i,e){let t=0,n=0;switch(e){case s.Direction.UP:n=-i;break;case s.Direction.RIGHT:t=i;break;case s.Direction.DOWN:n=i;break;case s.Direction.LEFT:t=-i;break}return{offsetX:t,offsetY:n}}function Ct(i){let e=0;for(const t in i)i[t].forEach(n=>{e+=n.data.length});return e}const He="special-paste-formula",We={id:"sheet.command.paste-formula",type:s.CommandType.COMMAND,handler:async i=>i.get(s.ICommandService).executeCommand(D.SheetPasteCommand.id,{value:He})};var yt=Object.defineProperty,Mt=Object.getOwnPropertyDescriptor,bt=(i,e,t,n)=>{for(var r=n>1?void 0:n?Mt(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&yt(e,t,r),r},fe=(i,e)=>(t,n)=>e(t,n,i);const Nt="default-paste-formula";let he=class extends s.Disposable{constructor(i,e,t,n){super(),this._currentUniverSheet=i,this._lexerTreeBuilder=e,this._sheetClipboardService=t,this._injector=n,this._initialize()}_initialize(){this._registerClipboardHook()}_registerClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._pasteFormulaHook())),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._pasteWithFormulaHook()))}_pasteFormulaHook(){return{hookName:He,specialPasteInfo:{label:"specialPaste.formula"},onPasteCells:(e,t,n,r)=>{const o=this._currentUniverSheet.getCurrentUniverSheetInstance(),a=o.getUnitId(),l=o.getActiveSheet().getSheetId();return this._injector.invoke(c=>qe(a,l,e,t,c,r,this._lexerTreeBuilder,!0))}}}_pasteWithFormulaHook(){return{hookName:Nt,onPasteCells:(e,t,n,r)=>{const o=this._currentUniverSheet.getCurrentUniverSheetInstance(),a=o.getUnitId(),l=o.getActiveSheet().getSheetId();return this._injector.invoke(c=>qe(a,l,e,t,c,r,this._lexerTreeBuilder))}}}};he=bt([s.OnLifecycle(s.LifecycleStages.Ready,he),fe(0,s.IUniverInstanceService),fe(1,T.Inject(y.LexerTreeBuilder)),fe(2,D.ISheetClipboardService),fe(3,T.Inject(T.Injector))],he);function qe(i,e,t,n,r,o,a,l=!1){const c=[],u=[],{startColumn:f,startRow:p}=t,d=new s.ObjectMatrix,g=new Map;let _=0,I=0,m=0,v=0;if(o){const{copyType:E,copyRange:N}=o;E===D.COPY_TYPE.COPY&&N&&(m=N.startRow,v=N.startColumn,_=N.endRow-m+1,I=N.endColumn-v+1)}n.forValue((E,N,M)=>{const b=M.f||"",L={};if(l&&(L.v=M.v),s.isFormulaString(b)&&_&&I){const U=E%_,F=N%I,P=`${U}_${F}`;let A=g.get(P);if(A)L.si=A,L.f=null,L.v=null,L.p=null;else{A=s.Tools.generateRandomId(6),g.set(P,A);const q=N+f-(v+F),$=E+p-(m+U),J=a.moveFormulaRefOffset(b,q,$);L.si=A,L.f=J,L.v=null,L.p=null}}d.setValue(E+p,N+f,L)});const S={workbookId:i,worksheetId:e,cellValue:d.getData()};c.push({id:h.SetRangeValuesMutation.id,params:S});const C=h.SetRangeValuesUndoMutationFactory(r,S);return u.push({id:h.SetRangeValuesMutation.id,params:C}),{undos:u,redos:c}}var Tt=Object.defineProperty,Ft=Object.getOwnPropertyDescriptor,wt=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ft(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&Tt(e,t,r),r},z=(i,e)=>(t,n)=>e(t,n,i);let pe=class extends s.Disposable{constructor(e,t,n,r,o,a,l,c){super();x(this,"_previousShape");this._editorBridgeService=e,this._formulaDataModel=t,this._lexerTreeBuilder=n,this._themeService=r,this._renderManagerService=o,this._selectionRenderService=a,this._sheetSkeletonManagerService=l,this._commandService=c,this._initInterceptorEditorStart(),this._commandExecutedListener()}_initInterceptorEditorStart(){this.disposeWithMe(s.toDisposable(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{handler:(e,t,n)=>{var g,_,I,m;const{row:r,col:o,workbookId:a,worksheetId:l}=t,c=this._formulaDataModel.getArrayFormulaRange(),u=this._formulaDataModel.getArrayFormulaCellData();if(this._removeArrayFormulaRangeShape(),e==null)return n(e);let f=null;const p=this._formulaDataModel.getFormulaDataItem(r,o,l,a);if(p!=null){const{f:v,si:S,x:C=0,y:E=0}=p;if(S!=null&&(C>0||E>0)){let N="";if(v.length>0)N=v;else{const b=this._formulaDataModel.getFormulaItemBySId(S,l,a);if(b==null||b.f.length===0)return n(e);N=b.f}f={f:this._lexerTreeBuilder.moveFormulaRefOffset(N,C,E)}}}if(e.v!=null&&e.v!==""&&((I=(_=(g=u[a])==null?void 0:g[l])==null?void 0:_[r])==null?void 0:I[o])==null)return f||n(e);const d=(m=c==null?void 0:c[a])==null?void 0:m[l];return d!=null&&new s.ObjectMatrix(d).forValue((v,S,C)=>{if(C==null)return!0;const{startRow:E,startColumn:N,endRow:M,endColumn:b}=C;if(v===r&&S===o)return this._createArrayFormulaRangeShape(C,a),!1;if(r>=E&&r<=M&&o>=N&&o<=b){const L=this._formulaDataModel.getFormulaDataItem(v,S,l,a);return L==null||L.f==null?!0:(f==null&&(f={f:L.f,isInArrayFormulaRange:!0}),this._createArrayFormulaRangeShape(C,a),!1)}}),f||n(e)}})))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{e.id===y.SetFormulaCalculationResultMutation.id&&this._removeArrayFormulaRangeShape()}))}_createArrayFormulaRangeShape(e,t){var g;const n=this._themeService.getCurrentTheme(),r=new Be.TinyColor(n.colorWhite).setAlpha(0).toString(),o={strokeWidth:1,stroke:n.hyacinth700,fill:r,widgets:{},hasAutoFill:!1,hasRowHeader:!1,hasColumnHeader:!1},{scene:a}=this._renderManagerService.getRenderById(t)||{},{rangeWithCoord:l,primaryWithCoord:c}=this._selectionRenderService.convertSelectionRangeToData({range:e,primary:null,style:o}),u=(g=this._sheetSkeletonManagerService.getCurrent())==null?void 0:g.skeleton;if(!a||!u)return;const{rowHeaderWidth:f,columnHeaderHeight:p}=u,d=new D.SelectionShape(a,100,!1,this._themeService);d.update(l,f,p,o,c),this._previousShape=d}_removeArrayFormulaRangeShape(){this._previousShape!=null&&(this._previousShape.dispose(),this._previousShape=null)}};pe=wt([s.OnLifecycle(s.LifecycleStages.Rendered,pe),z(0,T.Inject(D.IEditorBridgeService)),z(1,T.Inject(y.FormulaDataModel)),z(2,T.Inject(y.LexerTreeBuilder)),z(3,T.Inject(s.ThemeService)),z(4,V.IRenderManagerService),z(5,D.ISelectionRenderService),z(6,T.Inject(D.SheetSkeletonManagerService)),z(7,s.ICommandService)],pe);const we={id:"formula-ui.operation.change-ref-to-absolute",type:s.CommandType.OPERATION,handler:async i=>!0};class Et{constructor(){x(this,"_sequenceNodes",[]);x(this,"_isSelectionMoving",!1);x(this,"_isLockedOnSelectionChangeRefString",!1);x(this,"_isLockedOnSelectionInsertRefString",!1);x(this,"_syncToEditor$",new G.Subject);x(this,"syncToEditor$",this._syncToEditor$.asObservable());x(this,"_changeRef$",new G.Subject);x(this,"changeRef$",this._changeRef$.asObservable());x(this,"_inputFormula$",new G.Subject);x(this,"inputFormula$",this._inputFormula$.asObservable())}dispose(){this._sequenceNodes=[]}inputFormula(e){this._inputFormula$.next(e)}syncToEditor(e){this._syncToEditor$.next({sequences:this.getSequenceNodes(),textSelectionOffset:e})}getSequenceNodes(){return[...this._sequenceNodes]}setSequenceNodes(e){this._sequenceNodes=e}clearSequenceNodes(){this._sequenceNodes=[]}getCurrentSequenceNode(e){return this._sequenceNodes[this.getCurrentSequenceNodeIndex(e)]}getCurrentSequenceNodeByIndex(e){return this._sequenceNodes[e]}getCurrentSequenceNodeIndex(e){let t=0;for(let n=0,r=this._sequenceNodes.length;n<r;n++){const o=this._sequenceNodes[n];if(typeof o=="string")t++;else{const{endIndex:a}=o;t=a}if(e<=t)return n}return this._sequenceNodes.length}updateSequenceRef(e,t){const n=this._sequenceNodes[e];if(typeof n=="string"||n.nodeType!==y.sequenceNodeType.REFERENCE)return;const r=t.length-n.token.length,o={...n};o.token=t,o.endIndex+=r,this._sequenceNodes[e]=o;for(let a=e+1,l=this._sequenceNodes.length;a<l;a++){const c=this._sequenceNodes[a];if(typeof c=="string")continue;const u={...c};u.startIndex+=r,u.endIndex+=r,this._sequenceNodes[a]=u}this._changeRef$.next(!0)}insertSequenceRef(e,t){const n=t.length,r=this.getCurrentSequenceNodeIndex(e);this._sequenceNodes.splice(r,0,{token:t,startIndex:e,endIndex:e+n-1,nodeType:y.sequenceNodeType.REFERENCE});for(let o=r+1,a=this._sequenceNodes.length;o<a;o++){const l=this._sequenceNodes[o];if(typeof l=="string")continue;const c={...l};c.startIndex+=n,c.endIndex+=n,this._sequenceNodes[o]=c}this._changeRef$.next(!0)}insertSequenceString(e,t){const n=this.getCurrentSequenceNodeIndex(e),r=t.split("");this._sequenceNodes.splice(n,0,...r);const o=r.length;for(let a=n+o,l=this._sequenceNodes.length;a<l;a++){const c=this._sequenceNodes[a];if(typeof c=="string")continue;const u={...c};u.startIndex+=o,u.endIndex+=o,this._sequenceNodes[a]=u}this._changeRef$.next(!0)}enableSelectionMoving(){this._isSelectionMoving=!0}disableSelectionMoving(){this._isSelectionMoving=!1}isSelectionMoving(){return this._isSelectionMoving}enableLockedSelectionChange(){this._isLockedOnSelectionChangeRefString=!0}disableLockedSelectionChange(){this._isLockedOnSelectionChangeRefString=!1}isLockedSelectionChange(){return this._isLockedOnSelectionChangeRefString}enableLockedSelectionInsert(){this._isLockedOnSelectionInsertRefString=!0}disableLockedSelectionInsert(){this._isLockedOnSelectionInsertRefString=!1}isLockedSelectionInsert(){return this._isLockedOnSelectionInsertRefString}}const oe=T.createIdentifier("formula-ui.input-service");var xt=Object.defineProperty,Ot=Object.getOwnPropertyDescriptor,Dt=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ot(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&xt(e,t,r),r},te=(i,e)=>(t,n)=>e(t,n,i);let ge=class extends s.Disposable{constructor(e,t,n,r,o,a){super();x(this,"_userCursorMove",!1);this._commandService=e,this._textSelectionRenderManager=t,this._editorBridgeService=n,this._lexerTreeBuilder=r,this._renderManagerService=o,this._formulaInputService=a,this._initialize()}_initialize(){this._commandExecutedListener(),this._initialEditorInputChange(),this._userMouseListener(),this._inputFormulaListener()}_initialEditorInputChange(){this.disposeWithMe(s.toDisposable(this._textSelectionRenderManager.onInputBefore$.subscribe(e=>{const t=e==null?void 0:e.event;t!=null&&t.which!==O.KeyCode.F4&&(this._userCursorMove=!1)})))}_userMouseListener(){const e=this._getEditorObject();if(e==null)return;const{document:t}=e;this.disposeWithMe(s.toDisposable(t.onPointerDownObserver.add(()=>{this._userCursorMove=!0})))}_inputFormulaListener(){this.disposeWithMe(s.toDisposable(this._formulaInputService.inputFormula$.subscribe(e=>{this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:V.DeviceInputEventType.Dblclick});const n=this._lexerTreeBuilder.sequenceNodesBuilder(e)||[];this._formulaInputService.setSequenceNodes(n),this._formulaInputService.syncToEditor(e.length-1)})))}_changeRefString(){const e=this._textSelectionRenderManager.getActiveRange();if(e==null)return;const{startOffset:t}=e,n=t-2,r=this._formulaInputService.getCurrentSequenceNodeIndex(n),o=this._formulaInputService.getCurrentSequenceNodeByIndex(r);if(o==null||typeof o=="string"||o.nodeType!==y.sequenceNodeType.REFERENCE)return;const a=o.token.split("!");let l=o.token;a.length>1&&(l=a[a.length-1]);let c="";for(let p=0,d=a.length;p<d-1;p++)c+=a[p];let u=l;if(l.indexOf(y.matchToken.COLON)>-1)if(!this._userCursorMove)u=this._changeRangeRef(l);else{const p=l.split(y.matchToken.COLON),d=p[0],g=p[1];n-o.startIndex<=d.length?u=this._changeSingleRef(d)+y.matchToken.COLON+g:u=d+y.matchToken.COLON+this._changeSingleRef(g)}else u=this._changeSingleRef(l);u=c+u;const f=u.length-o.token.length;this._formulaInputService.updateSequenceRef(r,u),this._formulaInputService.syncToEditor(n+f+1)}_changeRangeRef(e){const t=s.deserializeRangeWithSheet(e).range;let n="";return t.startAbsoluteRefType===s.AbsoluteRefType.NONE||t.startAbsoluteRefType==null?(t.startAbsoluteRefType=s.AbsoluteRefType.ALL,t.endAbsoluteRefType=s.AbsoluteRefType.ALL):(t.startAbsoluteRefType=s.AbsoluteRefType.NONE,t.endAbsoluteRefType=s.AbsoluteRefType.NONE),n=s.serializeRange(t),n}_changeSingleRef(e){const t=s.deserializeRangeWithSheet(e).range,n=t.startAbsoluteRefType;let r="";return n===s.AbsoluteRefType.NONE||n==null?(t.startAbsoluteRefType=s.AbsoluteRefType.ALL,t.endAbsoluteRefType=s.AbsoluteRefType.ALL):n===s.AbsoluteRefType.ALL?(t.startAbsoluteRefType=s.AbsoluteRefType.ROW,t.endAbsoluteRefType=s.AbsoluteRefType.ROW):n===s.AbsoluteRefType.ROW?(t.startAbsoluteRefType=s.AbsoluteRefType.COLUMN,t.endAbsoluteRefType=s.AbsoluteRefType.COLUMN):(t.startAbsoluteRefType=s.AbsoluteRefType.NONE,t.endAbsoluteRefType=s.AbsoluteRefType.NONE),r=s.serializeRange(t),r}_commandExecutedListener(){const e=[we.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{e.includes(t.id)&&this._changeRefString()}))}_getEditorObject(){return D.getEditorObject(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};ge=Dt([s.OnLifecycle(s.LifecycleStages.Steady,ge),te(0,s.ICommandService),te(1,V.ITextSelectionRenderManager),te(2,T.Inject(D.IEditorBridgeService)),te(3,T.Inject(y.LexerTreeBuilder)),te(4,V.IRenderManagerService),te(5,oe)],ge);const Ke={id:"formula-ui.command.insert-function",type:s.CommandType.COMMAND,handler:async(i,e)=>{const{list:t}=e,n=i.get(s.ICommandService),r=new s.ObjectMatrix;t.forEach(a=>{const{range:l,primary:c,formula:u}=a,{row:f,column:p}=c,d=s.Tools.generateRandomId(6);r.setValue(f,p,{f:u,si:d});const{startRow:g,startColumn:_,endRow:I,endColumn:m}=l;for(let v=g;v<=I;v++)for(let S=_;S<=m;S++)(v!==f||S!==p)&&r.setValue(v,S,{si:d})});const o={value:r.getData()};return n.executeCommand(h.SetRangeValuesCommand.id,o)}},ne={id:"formula-ui.operation.select-editor-formula",type:s.CommandType.OPERATION,handler:(i,e)=>!0},X=T.createIdentifier("formula-ui.prompt-service");class Lt{constructor(){x(this,"_search$",new G.Subject);x(this,"_help$",new G.Subject);x(this,"_navigate$",new G.Subject);x(this,"_accept$",new G.Subject);x(this,"_acceptFormulaName$",new G.Subject);x(this,"search$",this._search$.asObservable());x(this,"help$",this._help$.asObservable());x(this,"navigate$",this._navigate$.asObservable());x(this,"accept$",this._accept$.asObservable());x(this,"acceptFormulaName$",this._acceptFormulaName$.asObservable());x(this,"_searching",!1);x(this,"_helping",!1);x(this,"_isInsertRefString",!1)}dispose(){this._search$.complete(),this._help$.complete(),this._navigate$.complete(),this._accept$.complete(),this._acceptFormulaName$.complete()}search(e){this._searching=e.visible,this._search$.next(e)}isSearching(){return this._searching}help(e){this._helping=e.visible,this._help$.next(e)}isHelping(){return this._helping}navigate(e){this._navigate$.next(e)}accept(e){this._accept$.next(e)}acceptFormulaName(e){this._acceptFormulaName$.next(e)}}const Ee={id:"formula-ui.operation.help-function",type:s.CommandType.OPERATION,handler:async(i,e)=>(i.get(X).help(e),!0)},xe={id:"formula-ui.operation.insert-function",type:s.CommandType.OPERATION,handler:async(i,e)=>{const t=i.get(h.SelectionManagerService),n=i.get(oe),r=t.getSelections();if(!r||!r.length)return!1;const o=i.get(s.IUniverInstanceService).getCurrentUniverSheetInstance(),a=o.getActiveSheet(),l=o.getUnitId(),c=a.getSheetId(),u=a.getCellMatrix(),{value:f}=e,p=i.get(s.ICommandService),d=[];let g=null,_=0,I=0;if(r.some(m=>{const{range:v,primary:S}=m,C=(S==null?void 0:S.actualRow)??v.startRow,E=(S==null?void 0:S.actualColumn)??v.startColumn,N=At(u,C,E);if(!N)return g=v,_=C,I=E,!0;const M=s.serializeRange(N),b=`=${f}(${M})`;return d.push({range:v,primary:{row:C,column:E},formula:b}),!1}),g){const m=h.getCellAtRowCol(_,I,a),v={range:s.Rectangle.clone(g),primary:{startRow:m.startRow,startColumn:m.startColumn,endRow:m.endRow,endColumn:m.endColumn,actualRow:_,actualColumn:I,isMerged:m.isMerged,isMergedMainCell:m.startRow===_&&m.startColumn===I}},S={unitId:l,sheetId:c,pluginName:h.NORMAL_SELECTION_PLUGIN_NAME,selections:[v]};await p.executeCommand(h.SetSelectionsOperation.id,S),setTimeout(()=>{n.inputFormula(`=${f}(`)},0)}return d.length===0?!1:p.executeCommand(Ke.id,{list:d})}};function At(i,e,t){const n=Pt(i,e,t);if(n!==e)return{startRow:n,endRow:e-1,startColumn:t,endColumn:t};const r=jt(i,e,t);return r!==t?{startRow:e,endRow:e,startColumn:r,endColumn:t-1}:null}function Pt(i,e,t){let n=!1;if(e===0)return e;for(let r=e-1;r>=0;r--){const o=i.getValue(r,t);if(Se(o)&&!n){if(r===0)return 0;n=!0}else{if(n&&!Se(o))return r+1;if(n&&r===0)return 0}}return e}function jt(i,e,t){let n=!1;if(t===0)return t;for(let r=t-1;r>=0;r--){const o=i.getValue(e,r);if(Se(o)&&!n){if(r===0)return 0;n=!0}else{if(n&&!Se(o))return r+1;if(n&&r===0)return 0}}return t}function Se(i){return i&&(s.Tools.isStringNumber(i.v)||s.getCellValueType(i)===s.CellValueType.NUMBER)}const Ge=`${Ve}_MORE_FUNCTIONS_COMPONENT`,ze={id:"formula-ui.operation.more-functions",type:s.CommandType.OPERATION,handler:async i=>(i.get(O.ISidebarService).open({header:{title:"formula.insert.tooltip"},children:{label:Ge}}),!0)},Oe={id:"formula-ui.operation.search-function",type:s.CommandType.OPERATION,handler:async(i,e)=>(i.get(X).search(e),!0)};var Ye={exports:{}},_e={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Ut=w,kt=Symbol.for("react.element"),Bt=Symbol.for("react.fragment"),Vt=Object.prototype.hasOwnProperty,$t=Ut.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ht={key:!0,ref:!0,__self:!0,__source:!0};function Xe(i,e,t){var n,r={},o=null,a=null;t!==void 0&&(o=""+t),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(a=e.ref);for(n in e)Vt.call(e,n)&&!Ht.hasOwnProperty(n)&&(r[n]=e[n]);if(i&&i.defaultProps)for(n in e=i.defaultProps,e)r[n]===void 0&&(r[n]=e[n]);return{$$typeof:kt,type:i,key:o,ref:a,props:r,_owner:$t.current}}_e.Fragment=Bt,_e.jsx=Xe,_e.jsxs=Xe,Ye.exports=_e;var R=Ye.exports;const Wt={formulaErrorFunction:"univer-formula-error-function"};function qt(){const[i,e]=w.useState(!1),[t,n]=w.useState({left:0,top:0}),r=k.useDependency(X),o=k.useDependency(D.ICellEditorManagerService);return w.useEffect(()=>{const a=r.help$.subscribe(l=>{const c=o.getState();if(!c)return;const{visible:u}=l;if(!u){e(u);return}const{endX:f=0,startY:p=0}=c;n({left:f,top:p}),e(u)});return()=>{a==null||a.unsubscribe()}},[]),i?R.jsx("div",{className:Wt.formulaErrorFunction,style:{left:t.left,top:t.top}}):null}var W=function(){return W=Object.assign||function(i){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},W.apply(this,arguments)},Kt=function(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(t[n[r]]=i[n[r]]);return t},ae=w.forwardRef(function(i,e){var t=i.icon,n=i.id,r=i.className,o=i.extend,a=Kt(i,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),c=w.useRef("_".concat(Yt()));return Ze(t,"".concat(n),{defIds:t.defIds,idSuffix:c.current},W({ref:e,className:l},a),o)});function Ze(i,e,t,n,r){return w.createElement(i.tag,W(W({key:e},Gt(i,t,r)),n),(zt(i,t).children||[]).map(function(o,a){return Ze(o,"".concat(e,"-").concat(i.tag,"-").concat(a),t,void 0,r)}))}function Gt(i,e,t){var n=W({},i.attrs);t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1);var r=e.defIds;return!r||r.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(o){var a=o[0],l=o[1];typeof l=="string"&&(n[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function zt(i,e){var t,n=e.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?W(W({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?W(W({},r),{attrs:W(W({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function Yt(){return Math.random().toString(36).substring(2,8)}ae.displayName="UniverIcon";var Xt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.6152 4.52067C14.8732 4.77869 14.8732 5.19703 14.6152 5.45505L6.61862 13.4514C6.46241 13.6077 6.20915 13.6077 6.05294 13.4514L1.73512 9.13354C1.4771 8.87551 1.4771 8.45718 1.73513 8.19915C1.99315 7.94113 2.41149 7.94114 2.66951 8.19916L6.19436 11.7241C6.27247 11.8022 6.3991 11.8022 6.47721 11.7241L13.6808 4.52067C13.9388 4.26264 14.3571 4.26264 14.6152 4.52067Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Qe=w.forwardRef(function(i,e){return w.createElement(ae,Object.assign({},i,{id:"check-mark-single",ref:e,icon:Xt}))});Qe.displayName="CheckMarkSingle";const Zt=Qe;var Qt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.48712 4.59907C5.23328 4.34523 4.82172 4.34523 4.56788 4.59907C4.31404 4.85291 4.31404 5.26447 4.56788 5.51831L7.9973 8.94773L4.56773 12.3773C4.31389 12.6311 4.31389 13.0427 4.56773 13.2965C4.82157 13.5504 5.23313 13.5504 5.48697 13.2965L8.91654 9.86697L12.3461 13.2965C12.5999 13.5503 13.0114 13.5503 13.2653 13.2965C13.5191 13.0426 13.5191 12.6311 13.2653 12.3772L9.83577 8.94773L13.2651 5.51836C13.519 5.26452 13.519 4.85296 13.2651 4.59912C13.0113 4.34528 12.5997 4.34528 12.3459 4.59912L8.91654 8.02849L5.48712 4.59907Z"}}]},Je=w.forwardRef(function(i,e){return w.createElement(ae,Object.assign({},i,{id:"close-single",ref:e,icon:Qt}))});Je.displayName="CloseSingle";const Jt=Je;var en={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_891",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0.51 0.5H16.51V16.5H0.51z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_102_891)"},children:[{tag:"path",attrs:{d:"M9.30291 5.78907C9.30291 6.22898 8.94629 6.5856 8.50637 6.5856 8.06646 6.5856 7.70984 6.22898 7.70984 5.78907 7.70984 5.34916 8.06646 4.99254 8.50637 4.99254 8.94629 4.99254 9.30291 5.34916 9.30291 5.78907zM9.1436 8.17867C9.1436 7.82674 8.8583 7.54144 8.50637 7.54144 8.15444 7.54144 7.86915 7.82674 7.86915 8.17867V12.002C7.86915 12.354 8.15444 12.6392 8.50637 12.6392 8.8583 12.6392 9.1436 12.354 9.1436 12.002V8.17867z"}},{tag:"path",attrs:{d:"M1.49689 8.49728C1.49689 4.62605 4.63514 1.48779 8.50637 1.48779C12.3776 1.48779 15.5159 4.62605 15.5159 8.49728C15.5159 12.3685 12.3776 15.5068 8.50637 15.5068C4.63514 15.5068 1.49689 12.3685 1.49689 8.49728ZM8.50637 2.76224C5.339 2.76224 2.77134 5.32991 2.77134 8.49728C2.77134 11.6646 5.339 14.2323 8.50637 14.2323C11.6737 14.2323 14.2414 11.6646 14.2414 8.49728C14.2414 5.32991 11.6737 2.76224 8.50637 2.76224Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},et=w.forwardRef(function(i,e){return w.createElement(ae,Object.assign({},i,{id:"details-single",ref:e,icon:en}))});et.displayName="DetailsSingle";const tn=et;var nn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.52628 3.57095C5.81918 3.26411 6.29405 3.26411 6.58695 3.57095L11.0869 8.28525C11.3798 8.59209 11.3798 9.08958 11.0869 9.39642L6.51623 14.04C6.22334 14.3468 5.74846 14.3468 5.45557 14.04C5.16268 13.7331 5.16268 13.2357 5.45557 12.9288L9.35939 8.979C9.43544 8.90205 9.43652 8.77857 9.36182 8.70031L5.52628 4.68212C5.23339 4.37528 5.23339 3.87779 5.52628 3.57095Z",fillRule:"evenodd",clipRule:"evenodd"}}]},tt=w.forwardRef(function(i,e){return w.createElement(ae,Object.assign({},i,{id:"more-single",ref:e,icon:nn}))});tt.displayName="MoreSingle";const rn=tt,H={formulaHelpFunction:"univer-formula-help-function",formulaHelpFunctionTitle:"univer-formula-help-function-title",formulaHelpFunctionTitleIcons:"univer-formula-help-function-title-icons",formulaHelpFunctionTitleIcon:"univer-formula-help-function-title-icon",formulaHelpFunctionContent:"univer-formula-help-function-content",formulaHelpFunctionContentInner:"univer-formula-help-function-content-inner",formulaHelpFunctionContentParams:"univer-formula-help-function-content-params",formulaHelpFunctionContentParamsTitle:"univer-formula-help-function-content-params-title",formulaHelpFunctionContentParamsDetail:"univer-formula-help-function-content-params-detail",formulaHelpFunctionActive:"univer-formula-help-function-active",formulaHelpDecorator:"univer-formula-help-decorator"};function on(){const[i,e]=w.useState(!1),[t,n]=w.useState(!0),[r,o]=w.useState(!0),[a,l]=w.useState(0),[c,u]=w.useState([0,0]),[f,p]=w.useState({left:0,top:0}),[d,g]=w.useState(null),_=k.useDependency(X),I=k.useDependency(D.ICellEditorManagerService),m=k.useDependency(s.LocaleService),v=k.useDependency(D.IFormulaEditorManagerService),S=k.useDependency(s.IContextService),C=m.t("formula.prompt.required"),E=m.t("formula.prompt.optional");w.useEffect(()=>{const M=_.help$.subscribe(b=>{const{visible:L,paramIndex:U,functionInfo:F}=b;if(!L){e(L);return}const A=S.getContextValue(s.FOCUSING_FORMULA_EDITOR)?v.getPosition():I.getRect();if(A==null)return;const{left:q,top:$,height:J}=A,ie={functionName:F.functionName,functionType:F.functionType,description:m.t(F.description),abstract:m.t(F.abstract),functionParameter:F.functionParameter.map(ee=>({name:m.t(ee.name),detail:m.t(ee.detail),example:ee.example,require:ee.require,repeat:ee.repeat}))};u([q,$+J]),l(U),g(ie),p({left:q,top:$}),e(L)});return()=>{M==null||M.unsubscribe()}},[]);function N(M){l(M)}return R.jsx(R.Fragment,{children:r?R.jsx(Y.Popup,{visible:i,offset:c,children:d?R.jsxs("div",{className:H.formulaHelpFunction,children:[R.jsxs("div",{className:H.formulaHelpFunctionTitle,children:[R.jsx(an,{prefix:d.functionName,value:d.functionParameter,active:a,onClick:N}),R.jsxs("div",{className:H.formulaHelpFunctionTitleIcons,children:[R.jsx("div",{className:H.formulaHelpFunctionTitleIcon,style:{transform:t?"rotateZ(-90deg)":"rotateZ(90deg)"},onClick:()=>n(!t),children:R.jsx(rn,{})}),R.jsx("div",{className:H.formulaHelpFunctionTitleIcon,onClick:()=>o(!r),children:R.jsx(Jt,{})})]})]}),R.jsx("div",{className:H.formulaHelpFunctionContent,style:{height:t?"unset":0,padding:t?"revert-layer":0},children:R.jsxs("div",{className:H.formulaHelpFunctionContentInner,children:[R.jsx(De,{title:m.t("formula.prompt.helpExample"),value:`${d.functionName}(${d.functionParameter.map(M=>M.example).join(",")})`}),R.jsx(De,{title:m.t("formula.prompt.helpAbstract"),value:d.description}),d&&d.functionParameter&&d.functionParameter.map((M,b)=>R.jsx(De,{className:a===b?H.formulaHelpFunctionActive:"",title:M.name,value:`${M.require?C:E} ${M.detail}`},b))]})})]}):R.jsx(R.Fragment,{})}):i?R.jsx("div",{className:H.formulaHelpDecorator,onClick:()=>o(!r),style:{left:f.left-24,top:f.top},children:R.jsx(tn,{})}):R.jsx(R.Fragment,{})})}const De=i=>R.jsxs("div",{className:H.formulaHelpFunctionContentParams,children:[R.jsx("div",{className:`${H.formulaHelpFunctionContentParamsTitle} ${i.className}`,children:i.title}),R.jsx("div",{className:H.formulaHelpFunctionContentParamsDetail,children:i.value})]}),an=i=>{const{prefix:e,value:t,active:n,onClick:r}=i;return R.jsxs("div",{children:[R.jsxs("span",{children:[e,"("]}),t&&t.map((o,a)=>R.jsxs("span",{children:[R.jsx("span",{className:n===a?H.formulaHelpFunctionActive:"",onClick:()=>r(a),children:o.repeat?`[${o.name},...]`:o.name}),a===t.length-1?"":","]},a)),")"]})},Z={formulaSearchFunction:"univer-formula-search-function",formulaSearchFunctionItem:"univer-formula-search-function-item",formulaSearchFunctionItemName:"univer-formula-search-function-item-name",formulaSearchFunctionItemNameLight:"univer-formula-search-function-item-name-light",formulaSearchFunctionItemDesc:"univer-formula-search-function-item-desc",formulaSearchFunctionItemActive:"univer-formula-search-function-item-active"};function sn(){const[i,e]=w.useState(!1),[t,n]=w.useState(0),[r,o]=w.useState([0,0]),[a,l]=w.useState([]),[c,u]=w.useState(""),f=k.useDependency(X),p=k.useDependency(D.ICellEditorManagerService),d=k.useDependency(D.IFormulaEditorManagerService),g=k.useDependency(s.IContextService);w.useEffect(()=>{let m=[],v=0;const S=f.search$.subscribe(N=>{const{visible:M,searchText:b,searchList:L}=N;if(!M){e(M);return}const F=g.getContextValue(s.FOCUSING_FORMULA_EDITOR)?d.getPosition():p.getRect();if(F==null)return;const{left:P,top:A,height:q}=F;u(b),l(L),m=L,o([P,A+q]),e(M),n(0),v=0}),C=f.navigate$.subscribe(N=>{const{direction:M}=N;if(M===s.Direction.UP){let b=v-1;b=b<0?m.length-1:b,n(b),v=b}else if(M===s.Direction.DOWN){let b=v+1;b=b>=m.length?0:b,n(b),v=b}}),E=f.accept$.subscribe(N=>{const M=m[v].name;f.acceptFormulaName(M)});return()=>{S==null||S.unsubscribe(),C==null||C.unsubscribe(),E==null||E.unsubscribe()}},[]);function _(m){n(m)}function I(){n(-1)}return R.jsx(Y.Popup,{visible:i,offset:r,children:R.jsx("ul",{className:Z.formulaSearchFunction,children:a.map((m,v)=>R.jsxs("li",{className:t===v?`${Z.formulaSearchFunctionItem} ${Z.formulaSearchFunctionItemActive}`:Z.formulaSearchFunctionItem,onMouseEnter:()=>_(v),onMouseLeave:I,onClick:()=>f.acceptFormulaName(m.name),children:[R.jsxs("span",{className:Z.formulaSearchFunctionItemName,children:[R.jsx("span",{className:Z.formulaSearchFunctionItemNameLight,children:c}),R.jsx("span",{children:m.name.slice(c.length)})]}),R.jsx("span",{className:Z.formulaSearchFunctionItemDesc,children:m.desc})]},v))})})}function ln(){return R.jsxs(R.Fragment,{children:[R.jsx(sn,{}),R.jsx(on,{}),R.jsx(qt,{})]})}const nt={formulaMoreFunctions:"univer-formula-more-functions",formulaMoreFunctionsOperation:"univer-formula-more-functions-operation"};function rt(i){const{prefix:e,value:t}=i;return R.jsxs("div",{children:[R.jsxs("span",{children:[e,"("]}),t&&t.map((n,r)=>R.jsxs("span",{children:[R.jsx("span",{children:n.repeat?`[${n.name},...]`:n.name}),r===t.length-1?"":","]},r)),")"]})}const Le={formulaFunctionParams:"univer-formula-function-params",formulaFunctionParamsTitle:"univer-formula-function-params-title",formulaFunctionParamsDetail:"univer-formula-function-params-detail"};function se(i){const{className:e,value:t,title:n}=i;return R.jsxs("div",{className:Le.formulaFunctionParams,children:[R.jsx("div",{className:`${Le.formulaFunctionParamsTitle} ${e}`,children:n}),R.jsx("div",{className:Le.formulaFunctionParamsDetail,children:t})]})}const le={formulaInputParamsList:"univer-formula-input-params-list",formulaInputParamsListItemName:"univer-formula-input-params-list-item-name",formulaInputParamsListItemSelector:"univer-formula-input-params-list-item-selector"};function cn(i){const{functionInfo:e,onChange:t}=i;if(!e)return null;const[n,r]=w.useState([]),[o,a]=w.useState(e.functionParameter),[l,c]=w.useState(-1);function u(p,d){const g=[...n];g[d]=p,r(g),t(g)}function f(p){if(p===o.length-1&&o[p].repeat){const d=[...o];d.push(o[p]),a(d)}c(p)}return R.jsxs("div",{className:le.formulaInputParams,children:[R.jsx("div",{className:le.formulaInputParamsList,children:o.map((p,d)=>R.jsxs("div",{children:[R.jsx("div",{className:le.formulaInputParamsListItemName,children:p.name}),R.jsx("div",{className:le.formulaInputParamsListItemSelector,children:R.jsx(D.RangeSelector,{onChange:g=>u(g,d),onActive:()=>f(d)})})]},d))}),R.jsx("div",{className:le.formulaInputParamsInfo,children:R.jsx(se,{title:l===-1?R.jsx(rt,{prefix:e.functionName,value:o}):o[l].name,value:l===-1?e.description:o[l].detail})})]})}const un=[],mn=[],dn=[],fn=[],hn=[],pn=[],gn=[],Sn=[],_n=[],vn=[],Rn=[{functionName:y.FUNCTION_NAMES_MATH.SUM,aliasFunctionName:"formula.functionList.SUM.aliasFunctionName",functionType:y.FunctionType.Math,description:"formula.functionList.SUM.description",abstract:"formula.functionList.SUM.abstract",functionParameter:[{name:"formula.functionList.SUM.functionParameter.number1.name",detail:"formula.functionList.SUM.functionParameter.number1.detail",example:"A1:A20",require:1,repeat:0},{name:"formula.functionList.SUM.functionParameter.number2.name",detail:"formula.functionList.SUM.functionParameter.number2.detail",example:"B2:B10",require:0,repeat:1}]},{functionName:y.FUNCTION_NAMES_MATH.SUMIF,aliasFunctionName:"formula.functionList.SUMIF.aliasFunctionName",functionType:y.FunctionType.Math,description:"formula.functionList.SUMIF.description",abstract:"formula.functionList.SUMIF.abstract",functionParameter:[{name:"formula.functionList.SUMIF.functionParameter.range.name",detail:"formula.functionList.SUMIF.functionParameter.range.detail",example:"A1:A20",require:1,repeat:0},{name:"formula.functionList.SUMIF.functionParameter.criteria.name",detail:"formula.functionList.SUMIF.functionParameter.criteria.detail",example:">5",require:1,repeat:0},{name:"formula.functionList.SUMIF.functionParameter.sum_range.name",detail:"formula.functionList.SUMIF.functionParameter.sum_range.detail",example:"B1:B20",require:0,repeat:0}]}],In=[{functionName:y.FUNCTION_NAMES_STATISTICAL.AVERAGE,aliasFunctionName:"formula.functionList.AVERAGE.aliasFunctionName",functionType:y.FunctionType.Statistical,description:"formula.functionList.AVERAGE.description",abstract:"formula.functionList.AVERAGE.abstract",functionParameter:[{name:"formula.functionList.AVERAGE.functionParameter.number1.name",detail:"formula.functionList.AVERAGE.functionParameter.number1.detail",example:"A1:A20",require:1,repeat:0},{name:"formula.functionList.AVERAGE.functionParameter.number2.name",detail:"formula.functionList.AVERAGE.functionParameter.number2.detail",example:"B2:B10",require:0,repeat:1}]},{functionName:y.FUNCTION_NAMES_STATISTICAL.MAX,aliasFunctionName:"formula.functionList.MAX.aliasFunctionName",functionType:y.FunctionType.Statistical,description:"formula.functionList.MAX.description",abstract:"formula.functionList.MAX.abstract",functionParameter:[{name:"formula.functionList.MAX.functionParameter.number1.name",detail:"formula.functionList.MAX.functionParameter.number1.detail",example:"A1:A20",require:1,repeat:0},{name:"formula.functionList.MAX.functionParameter.number2.name",detail:"formula.functionList.MAX.functionParameter.number2.detail",example:"B2:B10",require:0,repeat:1}]},{functionName:y.FUNCTION_NAMES_STATISTICAL.COUNT,aliasFunctionName:"formula.functionList.COUNT.aliasFunctionName",functionType:y.FunctionType.Statistical,description:"formula.functionList.COUNT.description",abstract:"formula.functionList.COUNT.abstract",functionParameter:[{name:"formula.functionList.COUNT.functionParameter.value1.name",detail:"formula.functionList.COUNT.functionParameter.value1.detail",example:"A1:A20",require:1,repeat:0},{name:"formula.functionList.COUNT.functionParameter.value2.name",detail:"formula.functionList.COUNT.functionParameter.value2.detail",example:"B2:B10",require:0,repeat:1}]},{functionName:y.FUNCTION_NAMES_STATISTICAL.MIN,aliasFunctionName:"formula.functionList.MIN.aliasFunctionName",functionType:y.FunctionType.Statistical,description:"formula.functionList.MIN.description",abstract:"formula.functionList.MIN.abstract",functionParameter:[{name:"formula.functionList.MIN.functionParameter.number1.name",detail:"formula.functionList.MIN.functionParameter.number1.detail",example:"A1:A20",require:1,repeat:0},{name:"formula.functionList.MIN.functionParameter.number2.name",detail:"formula.functionList.MIN.functionParameter.number2.detail",example:"B2:B10",require:0,repeat:1}]}],Cn=[],yn=[],Mn=[],bn=[...gn,...hn,...Rn,...In,...vn,...fn,...Cn,..._n,...Sn,...pn,...dn,...mn,...Mn,...un,...yn];function Nn(i,e){return Object.keys(i).filter(t=>isNaN(Number(t))).map(t=>({label:e.t(`formula.functionType.${t.toLocaleLowerCase()}`),value:`${i[t]}`}))}function Tn(i,e){let t="";return i.aliasFunctionName?(t=e.t(i.aliasFunctionName),t===i.aliasFunctionName&&(t=i.functionName)):t=i.functionName,t}var Fn=Object.defineProperty,wn=Object.getOwnPropertyDescriptor,En=(i,e,t,n)=>{for(var r=n>1?void 0:n?wn(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&Fn(e,t,r),r},it=(i,e)=>(t,n)=>e(t,n,i);const Ae=T.createIdentifier("formula-ui.description-service");let Pe=class{constructor(i,e,t){this._description=i,this._functionService=e,this._localeService=t,this._initialize(),this._registerDescription()}dispose(){this._localeService.localeChanged$.complete()}getDescriptions(){return this._functionService.getDescriptions()}hasFunction(i){return this._functionService.getDescriptions().get(i.toLocaleUpperCase())!==void 0}getFunctionInfo(i){return this._functionService.getDescriptions().get(i.toLocaleUpperCase())}getSearchListByName(i){const e=[],t=this._functionService.getDescriptions();return i=i.toLocaleUpperCase(),t.forEach(n=>{const{functionName:r,abstract:o}=n;r.indexOf(i)>-1&&e.push({name:r,desc:o})}),e}getSearchListByType(i){const e=[];return this._functionService.getDescriptions().forEach(n=>{const{functionName:r,functionType:o,abstract:a}=n;(o===i||i===-1)&&e.push({name:r,desc:a})}),e}_initialize(){this._localeService.localeChanged$.subscribe(()=>{this._registerDescription()})}_registerDescription(){const i=this._localeService,t=bn.concat(this._description||[]).map(n=>({functionName:Tn(n,i),functionType:n.functionType,description:i.t(n.description),abstract:i.t(n.abstract),functionParameter:n.functionParameter.map(r=>({name:i.t(r.name),detail:i.t(r.detail),example:r.example,require:r.require,repeat:r.repeat}))}));this._functionService.registerDescriptions(...t)}};Pe=En([it(1,y.IFunctionService),it(2,T.Inject(s.LocaleService))],Pe);const K={formulaSelectFunctionSelect:"univer-formula-select-function-select",formulaSelectFunctionResult:"univer-formula-select-function-result",formulaSelectFunctionResultItem:"univer-formula-select-function-result-item",formulaSelectFunctionResultItemNameLight:"univer-formula-select-function-result-item-name-light",formulaSelectFunctionResultItemSelected:"univer-formula-select-function-result-item-selected",formulaSelectFunctionResultItemActive:"univer-formula-select-function-result-item-active",formulaSelectFunctionContent:"univer-formula-select-function-content"};function xn(i){const{onChange:e}=i,t="-1",[n,r]=w.useState(""),[o,a]=w.useState([]),[l,c]=w.useState(0),[u,f]=w.useState(t),[p,d]=w.useState(0),[g,_]=w.useState(null),I=k.useDependency(Ae),m=k.useDependency(s.LocaleService),v=Nn(y.FunctionType,m);v.unshift({label:m.t("formula.moreFunctions.allFunctions"),value:t});const S=m.t("formula.prompt.required"),C=m.t("formula.prompt.optional");w.useEffect(()=>{M(t)},[]),w.useEffect(()=>{N(0)},[o]);const E=P=>{const A=new RegExp(`(${n.toLocaleUpperCase()})`);return P.split(A).filter(Boolean).map(($,J)=>$.match(A)?R.jsx("span",{className:K.formulaSelectFunctionResultItemNameLight,children:$},J):$)},N=P=>{if(o.length===0){_(null);return}d(P);const A=I.getFunctionInfo(o[P].name);if(!A){_(null);return}_(A),e(A)};function M(P){f(P);const A=I.getSearchListByType(+P);a(A)}function b(P){r(P);const A=I.getSearchListByName(P);a(A)}function L(P){if(P.stopPropagation(),P.key==="ArrowDown"){const A=l+1;c(A===o.length?0:A)}else if(P.key==="ArrowUp"){const A=l-1;c(A===-1?o.length-1:A)}else P.key==="Enter"&&N(l)}const U=P=>{c(P)},F=()=>{c(-1)};return R.jsxs("div",{children:[R.jsxs("div",{className:K.formulaSelectFunctionSelect,children:[R.jsx(Y.Select,{value:u,options:v,onChange:M}),R.jsx(Y.Input,{placeholder:m.t("formula.moreFunctions.searchFunctionPlaceholder"),onKeyDown:L,value:n,onChange:b,size:"large",allowClear:!0})]}),R.jsx("ul",{className:K.formulaSelectFunctionResult,onKeyDown:L,tabIndex:-1,children:o.map(({name:P},A)=>R.jsxs("li",{className:l===A?`${K.formulaSelectFunctionResultItem} ${K.formulaSelectFunctionResultItemActive}`:K.formulaSelectFunctionResultItem,onMouseEnter:()=>U(A),onMouseLeave:F,onClick:()=>N(A),children:[p===A&&R.jsx(Zt,{className:K.formulaSelectFunctionResultItemSelected}),R.jsx("span",{className:K.formulaSelectFunctionResultItemName,children:E(P)})]},A))}),g&&R.jsxs("div",{className:K.formulaSelectFunctionContent,children:[R.jsx(se,{title:g.functionName,value:g.description}),R.jsx(se,{title:m.t("formula.moreFunctions.syntax"),value:R.jsx(rt,{prefix:g.functionName,value:g.functionParameter})}),R.jsx(se,{title:m.t("formula.prompt.helpExample"),value:`${g.functionName}(${g.functionParameter.map(P=>P.example).join(",")})`}),g.functionParameter&&g.functionParameter.map((P,A)=>R.jsx(se,{title:P.name,value:`${P.require?S:C} ${P.detail}`},A))]})]})}function On(){const[i,e]=w.useState(!0),[t,n]=w.useState(!1),[r,o]=w.useState([]),[a,l]=w.useState(null),c=k.useDependency(s.LocaleService);k.useDependency(O.ISidebarService);const u=k.useDependency(oe);function f(){e(!i),n(!t)}function p(){u.inputFormula(`=${a==null?void 0:a.functionName}(`)}return R.jsxs("div",{className:nt.formulaMoreFunctions,children:[i&&R.jsx(xn,{onChange:l}),t&&R.jsx(cn,{functionInfo:a,onChange:o}),R.jsxs("div",{className:nt.formulaMoreFunctionsOperation,children:[t&&R.jsx(Y.Button,{type:"primary",onClick:f,children:c.t("formula.moreFunctions.next")}),t&&R.jsx(Y.Button,{onClick:f,children:c.t("formula.moreFunctions.prev")}),i&&R.jsx(Y.Button,{type:"primary",onClick:p,children:c.t("formula.moreFunctions.confirm")})]})]})}function Dn(i){return{id:xe.id,icon:"FunctionSingle",tooltip:"formula.insert.tooltip",group:O.MenuGroup.TOOLBAR_FORMULAS_INSERT,type:O.MenuItemType.SELECTOR,positions:[O.MenuPosition.TOOLBAR_START],selections:[{label:"SUM",value:"SUM",icon:"SumSingle"},{label:"AVERAGE",value:"AVERAGE",icon:"AvgSingle"},{label:"COUNT",value:"COUNT",icon:"CntSingle"},{label:"MAX",value:"MAX",icon:"MaxSingle"},{label:"MIN",value:"MIN",icon:"MinSingle"}]}}function Ln(i){return{id:ze.id,title:"formula.insert.more",positions:xe.id,type:O.MenuItemType.BUTTON}}function An(i){return{id:We.id,type:O.MenuItemType.BUTTON,title:"formula.operation.pasteFormula",positions:[D.PASTE_SPECIAL_MENU_ID]}}const ot="meta_key_ctrl_And_Shift",ve=[O.KeyCode.ARROW_DOWN,O.KeyCode.ARROW_UP,O.KeyCode.ARROW_LEFT,O.KeyCode.ARROW_RIGHT],Pn=[...ve,O.KeyCode.ENTER,O.KeyCode.TAB];function jn(){const i=[];for(const e of Pn)i.push({id:ne.id,binding:e,preconditions:t=>D.whenEditorInputFormulaActivated(t),staticParameters:{eventType:V.DeviceInputEventType.Keyboard,keycode:e}});return i}function Un(){const i=[];for(const e of ve)i.push({id:ne.id,binding:e|O.MetaKeys.SHIFT,preconditions:t=>D.whenEditorInputFormulaActivated(t),staticParameters:{eventType:V.DeviceInputEventType.Keyboard,keycode:e,metaKey:O.MetaKeys.SHIFT}});return i}function kn(){const i=[];for(const e of ve)i.push({id:ne.id,binding:e|O.MetaKeys.CTRL_COMMAND,preconditions:t=>D.whenEditorInputFormulaActivated(t),staticParameters:{eventType:V.DeviceInputEventType.Keyboard,keycode:e,metaKey:O.MetaKeys.CTRL_COMMAND}});return i}function Bn(){const i=[];for(const e of ve)i.push({id:ne.id,binding:e|O.MetaKeys.SHIFT|O.MetaKeys.CTRL_COMMAND,preconditions:t=>D.whenEditorInputFormulaActivated(t),staticParameters:{eventType:V.DeviceInputEventType.Keyboard,keycode:e,metaKey:ot}});return i}const Vn={id:we.id,binding:O.KeyCode.F4,preconditions:i=>D.whenEditorInputFormulaActivated(i)};var $n=Object.defineProperty,Hn=Object.getOwnPropertyDescriptor,Wn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Hn(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&$n(e,t,r),r},re=(i,e)=>(t,n)=>e(t,n,i);let Re=class extends s.Disposable{constructor(i,e,t,n,r,o){super(),this._injector=i,this._menuService=e,this._commandService=t,this._shortcutService=n,this._uiController=r,this._componentManager=o,this._initialize()}_initialize(){this._registerCommands(),this._registerMenus(),this._registerShortcuts(),this._registerComponents()}_registerMenus(){[Dn,Ln,An].forEach(i=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i)))})}_registerCommands(){[Ke,We,xe,ze,Oe,Ee,ne,we].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_registerShortcuts(){[...jn(),...Un(),...kn(),...Bn(),Vn].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_registerComponents(){this.disposeWithMe(this._uiController.registerContentComponent(()=>k.connectInjector(ln,this._injector))),this._componentManager.register(Ge,On)}};Re=Wn([s.OnLifecycle(s.LifecycleStages.Ready,Re),re(0,T.Inject(T.Injector)),re(1,O.IMenuService),re(2,s.ICommandService),re(3,O.IShortcutService),re(4,O.IUIController),re(5,T.Inject(O.ComponentManager))],Re);const at="formula_reference_selection_plugin_name";function je(i,e,t){const n=i.getCurrentTheme(),r=new Be.TinyColor(e).setAlpha(.05).toString();return{id:t,strokeWidth:2,stroke:e,fill:r,widgets:{tl:!0,tc:!0,tr:!0,ml:!0,mr:!0,bl:!0,bc:!0,br:!0},widgetSize:6,widgetStrokeWidth:1,widgetStroke:n.colorWhite,hasAutoFill:!1,hasRowHeader:!1,hasColumnHeader:!1}}var qn=Object.defineProperty,Kn=Object.getOwnPropertyDescriptor,Gn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Kn(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&qn(e,t,r),r},B=(i,e)=>(t,n)=>e(t,n,i);let Ie=class extends s.Disposable{constructor(e,t,n,r,o,a,l,c,u,f,p,d,g,_,I,m,v){super();x(this,"_formulaRefColors",[]);x(this,"_previousSequenceNodes");x(this,"_previousRangesCount",0);x(this,"_previousInsertRefStringIndex");x(this,"_currentInsertRefStringIndex",-1);x(this,"_currentUnitId");x(this,"_currentSheetId");x(this,"_arrowMoveActionState",0);x(this,"_isSelectionMovingRefSelections",[]);x(this,"_stringColor","");x(this,"_numberColor","");x(this,"_insertSelections",[]);x(this,"_inputPanelState",0);this._commandService=e,this._localeService=t,this._contextService=n,this._textSelectionRenderManager=r,this._editorBridgeService=o,this._formulaPromptService=a,this._lexerTreeBuilder=l,this._renderManagerService=c,this._themeService=u,this._selectionManagerService=f,this._sheetSkeletonManagerService=p,this._currentUniverService=d,this._selectionRenderService=g,this._descriptionService=_,this._textSelectionManagerService=I,this._formulaInputService=m,this._docViewModelManagerService=v,this._initialize()}dispose(){this._formulaRefColors=[],this._resetTemp()}_resetTemp(){this._previousSequenceNodes=null,this._previousInsertRefStringIndex=null,this._currentUnitId=null,this._currentSheetId=null,this._isSelectionMovingRefSelections=[],this._previousRangesCount=0,this._currentInsertRefStringIndex=-1}_initialize(){this._initialCursorSync(),this._initAcceptFormula(),this._initialFormulaTheme(),this._initialRefSelectionUpdateEvent(),this._initialRefSelectionInsertEvent(),this._initialExitEditor(),this._initialEditorInputChange(),this._commandExecutedListener(),this._cursorStateListener(),this._syncEditorListener()}_initialFormulaTheme(){const e=this._themeService.getCurrentTheme();this._formulaRefColors=[e.loopColor1,e.loopColor2,e.loopColor3,e.loopColor4,e.loopColor5,e.loopColor6,e.loopColor7,e.loopColor8,e.loopColor9,e.loopColor10,e.loopColor11,e.loopColor12],this._numberColor=e.hyacinth700,this._stringColor=e.verdancy800}_initialCursorSync(){this.disposeWithMe(s.toDisposable(this._textSelectionRenderManager.textSelection$.subscribe(()=>{if(this._editorBridgeService.isVisible().visible===!1||this._formulaInputService.isSelectionMoving())return;const e=this._getCurrentBody(),t=(e==null?void 0:e.dataStream)||"";this._contextSwitch(t),this._changeKeepVisibleHideState(),this._switchSelectionPlugin(),!this._formulaInputService.isLockedSelectionChange()&&(this._highlightFormula(),this._changeFunctionPanelState())})))}_initialEditorInputChange(){this.disposeWithMe(s.toDisposable(this._textSelectionRenderManager.onInputBefore$.subscribe(e=>{this._previousSequenceNodes=null,this._previousInsertRefStringIndex=null,this._selectionRenderService.enableSkipRemainLast();const t=e==null?void 0:e.event;t!=null&&([O.KeyCode.ARROW_DOWN,O.KeyCode.ARROW_UP,O.KeyCode.ARROW_LEFT,O.KeyCode.ARROW_RIGHT].includes(t.which)?this._inputPanelState=2:(this._arrowMoveActionState!==1&&(this._arrowMoveActionState=2),this._inputPanelState=1))})))}_initialExitEditor(){this.disposeWithMe(s.toDisposable(this._editorBridgeService.afterVisible$.subscribe(e=>{if(e.visible===!0){const{unitId:n,sheetId:r}=this._getCurrentUnitIdAndSheetId();this._currentUnitId==null&&(this._currentUnitId=n),this._currentSheetId==null&&(this._currentSheetId=r);return}const t=this._selectionManagerService.getCurrent();if((t==null?void 0:t.pluginName)===h.NORMAL_SELECTION_PLUGIN_NAME){this._disableForceKeepVisible();return}this._selectionManagerService.clear(),this._selectionManagerService.changePlugin(h.NORMAL_SELECTION_PLUGIN_NAME),this._updateEditorModel(`\r
|
|
10
|
+
`,[]),this._contextService.setContextValue(s.FOCUSING_EDITOR_INPUT_FORMULA,!1),this._disableForceKeepVisible(),this._selectionRenderService.resetStyle(),this._resetTemp(),this._hideFunctionPanel()})))}_initialRefSelectionUpdateEvent(){const e=new s.DisposableCollection;this.disposeWithMe(s.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(()=>{e.dispose();const t=this._selectionManagerService.getCurrent();if(this._formulaInputService.disableSelectionMoving(),(t==null?void 0:t.pluginName)!==at)return;this._updateRefSelectionStyle(this._isSelectionMovingRefSelections),this._selectionRenderService.getCurrentControls().forEach(r=>{r.disableHelperSelection(),e.add(s.toDisposable(r.selectionMoving$.subscribe(o=>{this._changeControlSelection(o,r)}))),e.add(s.toDisposable(r.selectionScaling$.subscribe(o=>{this._changeControlSelection(o,r)}))),e.add(s.toDisposable(r.selectionMoved$.subscribe(()=>{this._formulaInputService.disableLockedSelectionChange()}))),e.add(s.toDisposable(r.selectionScaled$.subscribe(()=>{this._formulaInputService.disableLockedSelectionChange()})))})})))}_syncEditorListener(){this.disposeWithMe(s.toDisposable(this._formulaInputService.syncToEditor$.subscribe(e=>{const{sequences:t,textSelectionOffset:n}=e;this._syncToEditor(t,n)})))}_selectionChanging(e,t=!1){if(e.length===0||!this._formulaInputService.isLockedSelectionInsert()||(this._formulaInputService.enableSelectionMoving(),this._inertControlSelection(e),t===!1))return;const n=e[e.length-1];this._inertControlSelectionReplace(n)}_initialRefSelectionInsertEvent(){this.disposeWithMe(s.toDisposable(this._selectionRenderService.selectionMoving$.subscribe(e=>{this._selectionChanging(e.map(t=>h.convertSelectionDataToRange(t)))}))),this.disposeWithMe(s.toDisposable(this._selectionRenderService.selectionMoveStart$.subscribe(e=>{this._selectionChanging(e.map(t=>h.convertSelectionDataToRange(t)),!0)})))}_initAcceptFormula(){this.disposeWithMe(s.toDisposable(this._formulaPromptService.acceptFormulaName$.subscribe(e=>{const t=this._textSelectionRenderManager.getActiveRange();if(t==null){this._hideFunctionPanel();return}const{startOffset:n}=t,r=this._formulaInputService.getSequenceNodes(),o=this._formulaInputService.getCurrentSequenceNodeIndex(n-2),a=r[o];if(a==null||typeof a=="string"){this._hideFunctionPanel();return}const l=e.length-a.token.length,c={...a};c.token=e,c.endIndex+=l,r[o]=c,r.splice(o+1,0,y.matchToken.OPEN_BRACKET);const u=e.length+1;for(let f=o+2,p=r.length;f<p;f++){const d=r[f];if(typeof d=="string")continue;const g={...d};g.startIndex+=u,g.endIndex+=u,r[f]=g}this._syncToEditor(r,c.endIndex+2)})))}_changeFunctionPanelState(){const e=this._textSelectionRenderManager.getActiveRange();if(e==null){this._hideFunctionPanel();return}const{startOffset:t}=e,n=this._formulaInputService.getCurrentSequenceNode(t-2);if(n==null){this._hideFunctionPanel();return}if(typeof n!="string"&&n.nodeType===y.sequenceNodeType.FUNCTION){const u=n.token.toUpperCase();if(this._inputPanelState===1){const f=this._descriptionService.getSearchListByName(u);if(this._hideFunctionPanel(),f==null||f.length===0)return;this._commandService.executeCommand(Oe.id,{visible:!0,searchText:u,searchList:f})}else this._descriptionService.hasFunction(u)&&this._changeHelpFunctionPanelState(u,-1);return}const r=this._getCurrentBody(),o=(r==null?void 0:r.dataStream)||"",a=this._lexerTreeBuilder.getFunctionAndParameter(o,t-1);if(a==null){this._hideFunctionPanel();return}const{functionName:l,paramIndex:c}=a;this._changeHelpFunctionPanelState(l.toUpperCase(),c)}_changeHelpFunctionPanelState(e,t){const n=this._descriptionService.getFunctionInfo(e);this._hideFunctionPanel(),n!=null&&this._commandService.executeCommand(Ee.id,{visible:!0,paramIndex:t,functionInfo:n})}_hideFunctionPanel(){this._commandService.executeCommand(Oe.id,{visible:!1,searchText:""}),this._commandService.executeCommand(Ee.id,{visible:!1,paramIndex:-1})}_changeKeepVisibleHideState(){if(this._getContextState()===!1){this._disableForceKeepVisible();return}const e=this._getCurrentChar();if(e==null){this._disableForceKeepVisible();return}this._matchRefDrawToken(e)?(this._editorBridgeService.enableForceKeepVisible(),this._formulaInputService.enableLockedSelectionInsert(),this._selectionRenderService.enableRemainLast(),this._arrowMoveActionState!==1&&(this._arrowMoveActionState=2)):this._disableForceKeepVisible()}_matchRefDrawToken(e){return y.isFormulaLexerToken(e)&&e!==y.matchToken.CLOSE_BRACES&&e!==y.matchToken.CLOSE_BRACKET&&e!==y.matchToken.SINGLE_QUOTATION&&e!==y.matchToken.DOUBLE_QUOTATION||e===" "}_getCurrentChar(){const e=this._textSelectionRenderManager.getActiveRange();if(e==null)return;const{startOffset:t}=e,n=this._getCurrentBody();return n==null||t==null?void 0:n.dataStream[t-1]}_disableForceKeepVisible(){this._editorBridgeService.disableForceKeepVisible(),this._formulaInputService.disableLockedSelectionInsert(),this._currentInsertRefStringIndex=-1,this._selectionRenderService.disableRemainLast(),this._arrowMoveActionState===2&&(this._arrowMoveActionState=4)}_getCurrentBody(){var n;const e=this._editorBridgeService.getCurrentEditorId();if(e==null)return;const t=this._currentUniverService.getUniverDocInstance(e);return(n=t==null?void 0:t.snapshot)==null?void 0:n.body}_getFormulaAndCellEditorBody(){return[s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY].map(t=>{const n=this._currentUniverService.getUniverDocInstance(t);return n==null?void 0:n.getBody()})}_contextSwitch(e){if(s.isFormulaString(e)){this._contextService.setContextValue(s.FOCUSING_EDITOR_INPUT_FORMULA,!0);const t=this._lexerTreeBuilder.sequenceNodesBuilder(e.replace(/\r/g,"").replace(/\n/g,""))||[];this._formulaInputService.setSequenceNodes(t);const n=this._textSelectionRenderManager.getActiveRange();if(n==null)return;const{startOffset:r}=n;this._currentInsertRefStringIndex=r-1}else this._contextService.setContextValue(s.FOCUSING_EDITOR_INPUT_FORMULA,!1),this._formulaInputService.disableLockedSelectionChange(),this._formulaInputService.disableLockedSelectionInsert(),this._formulaInputService.clearSequenceNodes(),this._hideFunctionPanel()}_getContextState(){return this._contextService.getContextValue(s.FOCUSING_EDITOR_INPUT_FORMULA)}_switchSelectionPlugin(){if(this._getContextState()===!0){this._selectionManagerService.changePluginNoRefresh(at);const e=h.getNormalSelectionStyle(this._themeService);e.strokeDash=8,e.hasAutoFill=!1,e.hasRowHeader=!1,e.hasColumnHeader=!1,this._selectionRenderService.setStyle(e)}else this._selectionManagerService.changePluginNoRefresh(h.NORMAL_SELECTION_PLUGIN_NAME),this._selectionRenderService.resetStyle()}_highlightFormula(){if(this._getContextState()===!1)return;const e=this._formulaInputService.getSequenceNodes(),t=this._getFormulaAndCellEditorBody().filter(n=>!!n);if(this._selectionManagerService.clear(),e==null||e.length===0)t.forEach(n=>n.textRuns=[]);else{const{textRuns:n,refSelections:r}=this._buildTextRuns(e);t.forEach(o=>o.textRuns=n),this._refreshSelectionForReference(r)}this._refreshFormulaAndCellEditor()}_buildTextRuns(e){const t=[],n=[];let r=0;for(let o=0,a=e.length;o<a;o++){const l=e[o];if(typeof l=="string")continue;const{startIndex:c,endIndex:u,nodeType:f,token:p}=l;let d="";if(f===y.sequenceNodeType.REFERENCE){const g=r%this._formulaRefColors.length;d=this._formulaRefColors[g],n.push({refIndex:o,themeColor:d,token:p}),r++}else f===y.sequenceNodeType.NUMBER?d=this._numberColor:f===y.sequenceNodeType.STRING?d=this._stringColor:f===y.sequenceNodeType.ARRAY&&(d=this._stringColor);d&&d.length>0&&t.push({st:c+1,ed:u+2,ts:{cl:{rgb:d}}})}return{textRuns:t,refSelections:n}}_refreshSelectionForReference(e){var c;const{unitId:t,sheetId:n}=this._getCurrentUnitIdAndSheetId(),r=[],o=this._currentUniverService.getUniverSheetInstance(t);if((o==null?void 0:o.getSheetBySheetId(n))==null)return;let l=null;for(let u=0,f=e.length;u<f;u++){const p=e[u],{themeColor:d,token:g,refIndex:_}=p,I=s.deserializeRangeWithSheet(g),{unitId:m,sheetName:v,range:S}=I;if(m!=null&&m.length>0&&t!==m)continue;const C=this._getSheetIdByName(t,v.trim());if(v.length!==0&&C!==n)continue;const E=(c=this._insertSelections.find(N=>{const{startRow:M,startColumn:b,endRow:L,endColumn:U}=N.range;return M===S.startRow&&b===S.startColumn&&L===S.endRow&&U===S.endColumn||M===S.startRow&&b===S.startColumn&&S.startRow===S.endRow&&S.startColumn===S.endColumn}))==null?void 0:c.primary;if(E!=null){const{isMerged:N,isMergedMainCell:M,startRow:b,endRow:L,startColumn:U,endColumn:F}=E;(N||M)&&b===S.startRow&&U===S.startColumn&&S.startRow===S.endRow&&S.startColumn===S.endColumn&&(S.endRow=L,S.endColumn=F),l={range:S,primary:E,style:je(this._themeService,d,_.toString())};continue}r.push({range:S,primary:E,style:je(this._themeService,d,_.toString())})}l&&r.push(l),r.length!==0&&this._selectionManagerService.add(r)}_getSheetIdByName(e,t){var r;const n=this._currentUniverService.getUniverSheetInstance(e);return(r=n==null?void 0:n.getSheetBySheetName(y.normalizeSheetName(t)))==null?void 0:r.getSheetId()}_getSheetNameById(e,t){var o;const n=this._currentUniverService.getUniverSheetInstance(e);let r=((o=n==null?void 0:n.getSheetBySheetId(t))==null?void 0:o.getName())||"";return r.length>0&&y.includeFormulaLexerToken(r)&&(r=`'${r}'`),r}_getCurrentUnitIdAndSheetId(){const e=this._sheetSkeletonManagerService.getCurrent();if(e==null){const o=this._currentUniverService.getCurrentUniverSheetInstance(),a=o.getActiveSheet();return{unitId:o.getUnitId(),sheetId:a.getSheetId()}}const{unitId:t,sheetId:n,skeleton:r}=e;return{unitId:t,sheetId:n,skeleton:r}}_getRefString(e){const{unitId:t,sheetId:n}=this._getCurrentUnitIdAndSheetId();let r="",o="";t===this._currentUnitId?r="":r=t,n===this._currentSheetId?o="":o=this._getSheetNameById(t,n);const{range:a,primary:l}=e;let{startRow:c,endRow:u,startColumn:f,endColumn:p}=a;if(l){const{isMerged:d,isMergedMainCell:g,startRow:_,endRow:I,startColumn:m,endColumn:v}=l;(d||g)&&_===c&&m===f&&I===u&&v===p&&(c=_,f=m,u=_,p=m)}return s.serializeRangeToRefString({sheetName:o,unitId:r,range:{startRow:c,endRow:u,startColumn:f,endColumn:p}})}async _syncToEditor(e,t,n=!0){const r=y.generateStringWithSequence(e),{textRuns:o,refSelections:a}=this._buildTextRuns(e);this._isSelectionMovingRefSelections=a;const l=this._textSelectionManagerService.getLast();if(l==null)return;const{collapsed:c,style:u}=l;this._currentInsertRefStringIndex=t,await this._fitEditorSize(),n?this._commandService.executeCommand(ce.ReplaceContentCommand.id,{unitId:this._editorBridgeService.getCurrentEditorId(),body:{dataStream:`=${r}`,textRuns:o},textRanges:[{startOffset:t+1,endOffset:t+1,collapsed:c,style:u}],segmentId:null}):(this._updateEditorModel(`=${r}\r
|
|
11
|
+
`,o),this._textSelectionManagerService.replaceTextRanges([{startOffset:t+1,endOffset:t+1,collapsed:c,style:u}]))}async _fitEditorSize(){const e=this._editorBridgeService.getCurrentEditorId();e!=null&&await this._commandService.syncExecuteCommand(D.SetEditorResizeOperation.id,{unitId:e})}_updateEditorModel(e,t){const n=this._editorBridgeService.getCurrentEditorId();if(n==null)return;const r=this._currentUniverService.getUniverDocInstance(n),o=this._docViewModelManagerService.getViewModel(n);if(o==null||r==null)return;const a=r==null?void 0:r.getSnapshot();if(a==null)return;const l={dataStream:e,textRuns:t};a.body=l,o.reset(r)}_inertControlSelectionReplace(e){this._previousSequenceNodes==null&&(this._previousSequenceNodes=this._formulaInputService.getSequenceNodes()),this._previousInsertRefStringIndex==null&&(this._previousInsertRefStringIndex=this._currentInsertRefStringIndex);const t=s.Tools.deepClone(this._previousSequenceNodes);if(t==null)return;const n=this._getRefString(e);this._formulaInputService.setSequenceNodes(t),this._formulaInputService.insertSequenceRef(this._previousInsertRefStringIndex,n),this._syncToEditor(t,this._previousInsertRefStringIndex+n.length);const r=this._selectionRenderService.getSelectionDataWithStyle();this._insertSelections=[],r.forEach(o=>{const a=h.convertSelectionDataToRange(o);this._insertSelections.push(a)})}_inertControlSelection(e){const t=e[e.length-1];if((e.length===this._previousRangesCount||this._previousRangesCount===0)&&this._previousSequenceNodes!=null)this._inertControlSelectionReplace(t);else{let n=this._formulaInputService.getSequenceNodes();if(n==null)return;const r=this._getCurrentChar();if(r==null)return;this._previousInsertRefStringIndex=this._currentInsertRefStringIndex,this._matchRefDrawToken(r)||(this._formulaInputService.insertSequenceString(this._currentInsertRefStringIndex,y.matchToken.COMMA),n=this._formulaInputService.getSequenceNodes(),this._previousInsertRefStringIndex+=1),this._previousSequenceNodes=s.Tools.deepClone(n);const o=this._getRefString(t);this._formulaInputService.setSequenceNodes(n),this._formulaInputService.insertSequenceRef(this._previousInsertRefStringIndex,o),this._selectionRenderService.disableSkipRemainLast()}this._arrowMoveActionState=2,this._previousRangesCount=e.length}_updateRefSelectionStyle(e){const t=this._selectionRenderService.getCurrentControls(),{unitId:n,sheetId:r}=this._getCurrentUnitIdAndSheetId();for(let o=0,a=e.length;o<a;o++){const l=e[o],{refIndex:c,themeColor:u,token:f}=l,p=s.deserializeRangeWithSheet(f),{unitId:d,sheetName:g,range:_}=p;if(d!=null&&d.length>0&&n!==d)continue;const I=this._getSheetIdByName(n,g.trim());if(I!=null&&I!==r)continue;const m=t.find(S=>{const{startRow:C,startColumn:E,endRow:N,endColumn:M}=S.getRange();return C===_.startRow&&E===_.startColumn&&N===_.endRow&&M===_.endColumn||C===_.startRow&&E===_.startColumn&&_.startRow===_.endRow&&_.startColumn===_.endColumn});if(m==null)continue;const v=je(this._themeService,u,c.toString());m.updateStyle(v)}}_changeControlSelection(e,t){var m;if(!e)return;const{unitId:n,sheetId:r,skeleton:o}=this._getCurrentUnitIdAndSheetId();this._formulaInputService.enableLockedSelectionChange();const a=(m=t.selectionStyle)==null?void 0:m.id;if(a==null||!s.Tools.isStringNumber(a))return;let{startRow:l,endRow:c,startColumn:u,endColumn:f}=e;const p=V.getCellInfoInMergeData(l,u,o==null?void 0:o.mergeData);if(p){const{isMerged:v,isMergedMainCell:S,startRow:C,endRow:E,startColumn:N,endColumn:M}=p;(v||S)&&C===l&&N===u&&E===c&&M===f&&(l=C,u=N,c=C,f=N)}const d=this._getRefString({range:{startRow:l,endRow:c,startColumn:u,endColumn:f},primary:p,style:null}),g=Number(a);this._formulaInputService.updateSequenceRef(g,d);const _=this._formulaInputService.getSequenceNodes(),I=_[g];typeof I!="string"&&(this._syncToEditor(_,I.endIndex+1),t.update(e))}_refreshFormulaAndCellEditor(){var t;const e=[s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY];for(const n of e){const r=D.getEditorObject(n,this._renderManagerService),o=r==null?void 0:r.document;o!=null&&((t=o.getSkeleton())==null||t.calculate(),o.makeDirty())}}_cursorStateListener(){const e=this._getEditorObject();if(e==null)return;const{document:t}=e;this.disposeWithMe(s.toDisposable(t.onPointerDownObserver.add(()=>{this._arrowMoveActionState=1,this._inputPanelState=3})))}_commandExecutedListener(){const e=[ne.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=t.params,{keycode:r,metaKey:o}=n;if(r===O.KeyCode.ENTER){if(this._formulaPromptService.isSearching()){this._formulaPromptService.accept(!0);return}this._editorBridgeService.changeVisible({visible:!1,eventType:V.DeviceInputEventType.Keyboard,keycode:r}),this._commandService.executeCommand(D.MoveSelectionCommand.id,{direction:s.Direction.DOWN});return}if(r===O.KeyCode.TAB){if(this._formulaPromptService.isSearching()){this._formulaPromptService.accept(!0);return}this._editorBridgeService.changeVisible({visible:!1,eventType:V.DeviceInputEventType.Keyboard,keycode:r}),this._commandService.executeCommand(D.MoveSelectionCommand.id,{direction:s.Direction.RIGHT});return}if(this._formulaPromptService.isSearching()){if(r===O.KeyCode.ARROW_DOWN){this._formulaPromptService.navigate({direction:s.Direction.DOWN});return}if(r===O.KeyCode.ARROW_UP){this._formulaPromptService.navigate({direction:s.Direction.UP});return}}if(this._arrowMoveActionState===1){this._moveInEditor(r);return}if(this._arrowMoveActionState===4){this._editorBridgeService.changeVisible({visible:!1,eventType:V.DeviceInputEventType.Keyboard,keycode:r});return}if(this._arrowMoveActionState===2&&(this._arrowMoveActionState=3),(this._selectionManagerService.getSelectionRanges()||[]).length===0){const f=this._selectionManagerService.getLastByPlugin(h.NORMAL_SELECTION_PLUGIN_NAME);if(f!=null){const p=s.Tools.deepClone(f);this._selectionManagerService.add([p])}}let l=s.Direction.DOWN;r===O.KeyCode.ARROW_DOWN?l=s.Direction.DOWN:r===O.KeyCode.ARROW_UP?l=s.Direction.UP:r===O.KeyCode.ARROW_LEFT?l=s.Direction.LEFT:r===O.KeyCode.ARROW_RIGHT&&(l=s.Direction.RIGHT),o===O.MetaKeys.CTRL_COMMAND?this._commandService.executeCommand(D.MoveSelectionCommand.id,{direction:l,jumpOver:D.JumpOver.moveGap}):o===O.MetaKeys.SHIFT?this._commandService.executeCommand(D.ExpandSelectionCommand.id,{direction:l}):o===ot?this._commandService.executeCommand(D.ExpandSelectionCommand.id,{direction:l,jumpOver:D.JumpOver.moveGap}):this._commandService.executeCommand(D.MoveSelectionCommand.id,{direction:l});const c=this._selectionManagerService.getSelections()||[],u=c[c.length-1];this._inertControlSelectionReplace(u)}}))}_moveInEditor(e){if(e==null)return;let t=s.Direction.LEFT;e===O.KeyCode.ARROW_DOWN?t=s.Direction.DOWN:e===O.KeyCode.ARROW_UP?t=s.Direction.UP:e===O.KeyCode.ARROW_RIGHT&&(t=s.Direction.RIGHT),this._commandService.executeCommand(ce.MoveCursorOperation.id,{direction:t})}_getEditorObject(){return D.getEditorObject(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};Ie=Gn([s.OnLifecycle(s.LifecycleStages.Steady,Ie),B(0,s.ICommandService),B(1,T.Inject(s.LocaleService)),B(2,s.IContextService),B(3,V.ITextSelectionRenderManager),B(4,T.Inject(D.IEditorBridgeService)),B(5,T.Inject(X)),B(6,T.Inject(y.LexerTreeBuilder)),B(7,V.IRenderManagerService),B(8,T.Inject(s.ThemeService)),B(9,T.Inject(h.SelectionManagerService)),B(10,T.Inject(D.SheetSkeletonManagerService)),B(11,s.IUniverInstanceService),B(12,T.Inject(D.ISelectionRenderService)),B(13,T.Inject(Ae)),B(14,T.Inject(ce.TextSelectionManagerService)),B(15,oe),B(16,T.Inject(ce.DocViewModelManagerService))],Ie);var zn=Object.defineProperty,Yn=Object.getOwnPropertyDescriptor,Xn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Yn(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&zn(e,t,r),r},st=(i,e)=>(t,n)=>e(t,n,i);let Ce=class extends s.Disposable{constructor(e,t){super();x(this,"_waitingCommandQueue",[]);x(this,"_setTimeoutKey",-1);x(this,"_startExecutionTime",0);this._commandService=e,this._activeDirtyManagerService=t,this._initialize()}_initialize(){this._commandExecutedListener(),this._initialExecuteFormulaProcessListener(),this._initialExecuteFormula()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted((e,t)=>{if(this._activeDirtyManagerService.get(e.id)){if(e.id===h.SetRangeValuesMutation.id){const n=e.params;if(t&&t.local===!0||n.trigger===h.SetStyleCommand.id)return}this._waitingCommandQueue.push(e),clearTimeout(this._setTimeoutKey),this._setTimeoutKey=setTimeout(()=>{this._commandService.executeCommand(y.SetFormulaCalculationStartMutation.id,{...this._generateDirty(this._waitingCommandQueue)},{local:!0}),this._startExecutionTime=performance.now()},100)}}))}_generateDirty(e){const t=[],n={},r={};for(const o of e){const a=this._activeDirtyManagerService.get(o.id);if(a==null)continue;const l=a.getDirtyData(o),{dirtyRanges:c,dirtyNameMap:u,dirtyUnitFeatureMap:f}=l;c!=null&&t.push(...c),u!=null&&this._mergeDirtyNameMap(n,u),f!=null&&this._mergeDirtyUnitFeatureMap(r,f)}return{dirtyRanges:t,dirtyNameMap:n,dirtyUnitFeatureMap:r}}_mergeDirtyNameMap(e,t){Object.keys(t).forEach(n=>{e[n]==null&&(e[n]={}),Object.keys(t[n]).forEach(r=>{e[n][r]=t[n][r]})})}_mergeDirtyUnitFeatureMap(e,t){Object.keys(t).forEach(n=>{e[n]==null&&(e[n]={}),Object.keys(t[n]).forEach(r=>{e[n][r]==null&&(e[n][r]={}),Object.keys(t[n][r]).forEach(o=>{e[n][r][o]=t[n][r][o]})})})}_initialExecuteFormulaProcessListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==y.SetFormulaCalculationNotificationMutation.id)return;const t=e.params;if(t.stageInfo!=null){const{totalFormulasToCalculate:n,completedFormulasCount:r,totalArrayFormulasToCalculate:o,completedArrayFormulasCount:a,stage:l}=t.stageInfo;o>0?console.log(`Stage ${l} Array formula.There are ${o} functions to be executed, ${a} complete.`):console.log(`Stage ${l} .There are ${n} functions to be executed, ${r} complete.`)}else{const n=t.functionsExecutedState;let r="";switch(n){case y.FormulaExecutedStateType.NOT_EXECUTED:r="No tasks are being executed anymore";break;case y.FormulaExecutedStateType.STOP_EXECUTION:r="The execution of the formula has been stopped";break;case y.FormulaExecutedStateType.SUCCESS:r=`Formula calculation succeeded, Total time consumed: ${performance.now()-this._startExecutionTime} ms`;break;case y.FormulaExecutedStateType.INITIAL:r="Waiting for calculation";break}console.log(`execution result${r}`)}}))}_initialExecuteFormula(){this._commandService.executeCommand(y.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{local:!0})}};Ce=Xn([s.OnLifecycle(s.LifecycleStages.Ready,Ce),st(0,s.ICommandService),st(1,Ne)],Ce);function ye(i,e,t,n,r){const{id:o}=e;if(lt(i,t,n))return i;const a=new s.ObjectMatrix(i[t][n]);switch(o){case h.MoveRangeCommand.id:Zn(a,e);break;case h.MoveRowsCommand.id:Qn(a,e,r);break;case h.MoveColsCommand.id:Jn(a,e,r);break;case h.InsertRowCommand.id:er(a,e);break;case h.InsertColCommand.id:tr(a,e);break;case h.InsertRangeMoveRightCommand.id:nr(a,e);break;case h.InsertRangeMoveDownCommand.id:rr(a,e);break;case h.RemoveRowCommand.id:ir(a,e);break;case h.RemoveColCommand.id:or(a,e);break;case h.DeleteRangeMoveUpCommand.id:ar(a,e);break;case h.DeleteRangeMoveLeftCommand.id:sr(a,e);break}return i}function Zn(i,e){const{params:t}=e;if(!t)return;const{fromRange:n,toRange:r}=t,{startRow:o,endRow:a,startColumn:l,endColumn:c}=n,{startRow:u,endRow:f,startColumn:p,endColumn:d}=r,g=new s.ObjectMatrix;for(let _=o;_<=a;_++)for(let I=l;I<=c;I++){const m=i.getValue(_,I);g.setValue(_-o,I-l,m),i.setValue(_,I,null)}for(let _=u;_<=f;_++)for(let I=p;I<=d;I++){const m=g.getValue(_-u,I-p);i.setValue(_,I,m)}}function Qn(i,e,t){const{params:n}=e;if(!n)return;const{fromRow:r,toRow:o}=n,a=t==null?void 0:t.filter(f=>f.range.rangeType===s.RANGE_TYPE.ROW&&f.range.startRow<=r&&r<=f.range.endRow);if((a==null?void 0:a.length)!==1)return;const l=a[0].range,c=l.startRow,u=l.endRow-l.startRow+1;i.moveRows(c,u,o)}function Jn(i,e,t){const{params:n}=e;if(!n)return;const{fromCol:r,toCol:o}=n,a=t==null?void 0:t.filter(f=>f.range.rangeType===s.RANGE_TYPE.COLUMN&&f.range.startColumn<=r&&r<=f.range.endColumn);if((a==null?void 0:a.length)!==1)return;const l=a[0].range,c=l.startColumn,u=l.endColumn-l.startColumn+1;i.moveColumns(c,u,o)}function er(i,e){const{params:t}=e;if(!t)return;const{range:n}=t,r=i.getLength()-1,o=i.getRange().endColumn;h.handleInsertRangeMutation(i,[n],r,o,s.Dimension.ROWS)}function tr(i,e){const{params:t}=e;if(!t)return;const{range:n}=t,r=i.getLength()-1,o=i.getRange().endColumn;h.handleInsertRangeMutation(i,[n],r,o,s.Dimension.COLUMNS)}function nr(i,e){const{params:t}=e;if(!t)return;const{ranges:n}=t,r=i.getLength()-1,o=i.getRange().endColumn;h.handleInsertRangeMutation(i,n,r,o,s.Dimension.COLUMNS)}function rr(i,e){const{params:t}=e;if(!t)return;const{ranges:n}=t,r=i.getLength()-1,o=i.getRange().endColumn;h.handleInsertRangeMutation(i,n,r,o,s.Dimension.ROWS)}function ir(i,e){const{params:t}=e;if(!t)return;const{ranges:n}=t,r=i.getLength()-1,o=i.getRange().endColumn;h.handleDeleteRangeMutation(i,n,r,o,s.Dimension.ROWS)}function or(i,e){const{params:t}=e;if(!t)return;const{ranges:n}=t,r=i.getLength()-1,o=i.getRange().endColumn;h.handleDeleteRangeMutation(i,n,r,o,s.Dimension.COLUMNS)}function ar(i,e){const{params:t}=e;if(!t)return;const{ranges:n}=t,r=i.getLength()-1,o=i.getRange().endColumn;h.handleDeleteRangeMutation(i,n,r,o,s.Dimension.ROWS)}function sr(i,e){const{params:t}=e;if(!t)return;const{ranges:n}=t,r=i.getLength()-1,o=i.getRange().endColumn;h.handleDeleteRangeMutation(i,n,r,o,s.Dimension.COLUMNS)}function lr(i,e,t){if(lt(i,e,t))return i;const n=new s.ObjectMatrix(i[e][t]);return n.forValue((r,o,a)=>{const{startRow:l,startColumn:c,endRow:u,endColumn:f}=a;if(r===l&&o===c)return;const p=u-l,d=f-c,g={startRow:r,startColumn:o,endRow:r+p,endColumn:o+d};n.setValue(r,o,g)}),i}function lt(i,e,t){return i==null||i[e]==null||i[e][t]==null}var cr=Object.defineProperty,ur=Object.getOwnPropertyDescriptor,mr=(i,e,t,n)=>{for(var r=n>1?void 0:n?ur(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&cr(e,t,r),r},Q=(i,e)=>(t,n)=>e(t,n,i);let Me=class extends s.Disposable{constructor(i,e,t,n,r,o,a){super(),this._currentUniverService=i,this._commandService=e,this._lexerTreeBuilder=t,this._formulaDataModel=n,this._sheetInterceptorService=r,this._selectionManagerService=o,this._injector=a,this._initialize()}_initialize(){this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>this._getUpdateFormula(i)})),this.disposeWithMe(this._commandService.onCommandExecuted((i,e)=>{const{id:t,params:n}=i;if(n)switch(t){case h.SetRangeValuesMutation.id:this._handleSetRangeValuesMutation(n,e);break;case h.RemoveSheetMutation.id:this._handleRemoveSheetMutation(n);break;case h.InsertSheetMutation.id:this._handleInsertSheetMutation(n);break}}))}_handleSetRangeValuesMutation(i,e){const{worksheetId:t,workbookId:n,cellValue:r}=i;e&&e.local===!0||r==null||(this._formulaDataModel.updateFormulaData(n,t,r),this._commandService.executeCommand(y.SetFormulaDataMutation.id,{formulaData:this._formulaDataModel.getFormulaData()},{local:!0}))}_handleRemoveSheetMutation(i){const{worksheetId:e,workbookId:t}=i,n=this._formulaDataModel.getFormulaData();delete n[t][e];const r=this._formulaDataModel.getArrayFormulaRange();delete r[t][e];const o=this._formulaDataModel.getArrayFormulaCellData();delete o[t][e],this._commandService.executeCommand(y.SetFormulaDataMutation.id,{formulaData:n}),this._commandService.executeCommand(y.SetArrayFormulaDataMutation.id,{arrayFormulaRange:r,arrayFormulaCellData:o})}_handleInsertSheetMutation(i){const{sheet:e,workbookId:t}=i,n=this._formulaDataModel.getFormulaData(),{id:r,cellData:o}=e,a=new s.ObjectMatrix(o);y.initSheetFormulaData(n,t,r,a),this._commandService.executeCommand(y.SetFormulaDataMutation.id,{formulaData:n})}_getUpdateFormula(i){const{id:e}=i;let t=null;switch(e){case h.MoveRangeCommand.id:t=this._handleMoveRange(i);break;case h.MoveRowsCommand.id:t=this._handleMoveRows(i);break;case h.MoveColsCommand.id:t=this._handleMoveCols(i);break;case h.InsertRowCommand.id:t=this._handleInsertRow(i);break;case h.InsertColCommand.id:t=this._handleInsertCol(i);break;case h.InsertRangeMoveRightCommand.id:t=this._handleInsertRangeMoveRight(i);break;case h.InsertRangeMoveDownCommand.id:t=this._handleInsertRangeMoveDown(i);break;case h.RemoveRowCommand.id:t=this._handleRemoveRow(i);break;case h.RemoveColCommand.id:t=this._handleRemoveCol(i);break;case h.DeleteRangeMoveUpCommand.id:t=this._handleDeleteRangeMoveUp(i);break;case h.DeleteRangeMoveLeftCommand.id:t=this._handleDeleteRangeMoveLeft(i);break;case h.SetWorksheetNameCommand.id:t=this._handleSetWorksheetName(i);break}if(t){const{unitSheetNameMap:n}=this._formulaDataModel.getCalculateData();let r=this._formulaDataModel.getFormulaData();const o=this._getFormulaReferenceMoveInfo(r,n,t),a=this._currentUniverService.getCurrentUniverSheetInstance(),l=a.getUnitId(),c=a.getActiveSheet().getSheetId(),u=this._selectionManagerService.getSelections(),f=this._formulaDataModel.getArrayFormulaRange(),p=this._formulaDataModel.getArrayFormulaCellData();let d=ye(f,i,l,c,u);d=lr(d,l,c);const g=ye(p,i,l,c,u);this._commandService.executeCommand(y.SetArrayFormulaDataMutation.id,{arrayFormulaRange:d,arrayFormulaCellData:g},{local:!0}),r=ye(r,i,l,c,u);const _=ye(o,i,l,c,u);return this._commandService.executeCommand(y.SetFormulaDataMutation.id,{formulaData:this._formulaDataModel.getFormulaData()}),this._getUpdateFormulaMutations(r,_)}return{undos:[],redos:[]}}_handleMoveRange(i){const{params:e}=i;if(!e)return null;const{fromRange:t,toRange:n}=e;if(!t||!n)return null;const{unitId:r,sheetId:o}=this._getCurrentSheetInfo();return{type:0,from:t,to:n,unitId:r,sheetId:o}}_handleMoveRows(i){const{params:e}=i;if(!e)return null;const{fromRow:t,toRow:n}=e,r=this._currentUniverService.getCurrentUniverSheetInstance(),o=r.getUnitId(),a=r.getActiveSheet(),l=a.getSheetId(),c={startRow:t,startColumn:0,endRow:t,endColumn:a.getColumnCount()-1,rangeType:s.RANGE_TYPE.ROW},u={startRow:n,startColumn:0,endRow:n,endColumn:a.getColumnCount()-1,rangeType:s.RANGE_TYPE.ROW};return{type:0,from:c,to:u,unitId:o,sheetId:l}}_handleMoveCols(i){const{params:e}=i;if(!e)return null;const{fromCol:t,toCol:n}=e,r=this._currentUniverService.getCurrentUniverSheetInstance(),o=r.getUnitId(),a=r.getActiveSheet(),l=a.getSheetId(),c={startRow:0,startColumn:t,endRow:a.getRowCount()-1,endColumn:t,rangeType:s.RANGE_TYPE.COLUMN},u={startRow:0,startColumn:n,endRow:a.getRowCount()-1,endColumn:n,rangeType:s.RANGE_TYPE.COLUMN};return{type:0,from:c,to:u,unitId:o,sheetId:l}}_handleInsertRow(i){const{params:e}=i;if(!e)return null;const{range:t,workbookId:n,worksheetId:r}=e;return{type:1,ranges:[t],unitId:n,sheetId:r}}_handleInsertCol(i){const{params:e}=i;if(!e)return null;const{range:t,workbookId:n,worksheetId:r}=e;return{type:2,ranges:[t],unitId:n,sheetId:r}}_handleInsertRangeMoveRight(i){const{params:e}=i;if(!e)return null;const{ranges:t}=e,{unitId:n,sheetId:r}=this._getCurrentSheetInfo();return{type:8,ranges:t,unitId:n,sheetId:r}}_handleInsertRangeMoveDown(i){const{params:e}=i;if(!e)return null;const{ranges:t}=e,{unitId:n,sheetId:r}=this._getCurrentSheetInfo();return{type:7,ranges:t,unitId:n,sheetId:r}}_handleRemoveRow(i){const{params:e}=i;if(!e)return null;const{ranges:t}=e,{unitId:n,sheetId:r}=this._getCurrentSheetInfo();return{type:3,ranges:t,unitId:n,sheetId:r}}_handleRemoveCol(i){const{params:e}=i;if(!e)return null;const{ranges:t}=e,{unitId:n,sheetId:r}=this._getCurrentSheetInfo();return{type:4,ranges:t,unitId:n,sheetId:r}}_handleDeleteRangeMoveUp(i){const{params:e}=i;if(!e)return null;const{ranges:t}=e,{unitId:n,sheetId:r}=this._getCurrentSheetInfo();return{type:6,ranges:t,unitId:n,sheetId:r}}_handleDeleteRangeMoveLeft(i){const{params:e}=i;if(!e)return null;const{ranges:t}=e,{unitId:n,sheetId:r}=this._getCurrentSheetInfo();return{type:5,ranges:t,unitId:n,sheetId:r}}_handleSetWorksheetName(i){const{params:e}=i;if(!e)return null;const{workbookId:t,worksheetId:n,name:r}=e,{unitId:o,sheetId:a}=this._getCurrentSheetInfo();return{type:9,unitId:t||o,sheetId:n||a,sheetName:r}}_getUpdateFormulaMutations(i,e){const t=[],n=[],r={get:this._injector.get.bind(this._injector)},o=Object.keys(e);for(const a of o){const l=e[a],c=Object.keys(l);for(const u of c){const f=new s.ObjectMatrix(i[a][u]),p=new s.ObjectMatrix(l[u]),d=new s.ObjectMatrix;p.forValue((m,v,S)=>{var N,M;const C=(S==null?void 0:S.f)||"",E=((M=(N=f.getRow(m))==null?void 0:N.get(v))==null?void 0:M.f)||"";s.isFormulaString(C)&&(s.isFormulaString(E)&&C!==E?d.setValue(m,v,{f:C}):d.setValue(m,v,{f:C,si:null}))});const g=d.getData();if(s.Tools.isEmptyObject(g))continue;const _={worksheetId:u,workbookId:a,cellValue:g};t.push({id:h.SetRangeValuesMutation.id,params:_});const I=h.SetRangeValuesUndoMutationFactory(r,_);n.push({id:h.SetRangeValuesMutation.id,params:I})}}return{redos:t,undos:n}}_getFormulaReferenceMoveInfo(i,e,t){const n=Object.keys(i),r={};for(const o of n){const a=i[o],l=Object.keys(a);r[o]==null&&(r[o]={});for(const c of l){const u=new s.ObjectMatrix(a[c]),f=new s.ObjectMatrix;u.forValue((p,d,g)=>{var M;if(!g)return!0;const{f:_,x:I,y:m,si:v}=g,S=this._lexerTreeBuilder.sequenceNodesBuilder(_);if(S==null)return!0;let C=!1;const E=[];for(let b=0,L=S.length;b<L;b++){const U=S[b];if(typeof U=="string"||U.nodeType!==y.sequenceNodeType.REFERENCE)continue;const{token:F}=U,P=s.deserializeRangeWithSheet(F),{range:A,sheetName:q,unitId:$}=P,J=$==null||$.length===0?o:$,ie=(M=e==null?void 0:e[J])==null?void 0:M[q],ee={range:A,sheetId:ie,unitId:$,sheetName:q,refOffsetX:I||0,refOffsetY:m||0};let be=null;if(t.type===9){const{unitId:Fi,sheetId:gr,sheetName:ut}=t;if(ut==null||ie==null||ie.length===0||gr!==ie)continue;be=s.serializeRangeToRefString({range:A,sheetName:ut,unitId:$})}else be=this._getNewRangeByMoveParam(ee,t,o,c);be!=null&&(S[b]={...U,token:be},C=!0,E.push(b))}if(!C)return!0;const N=this._updateRefOffset(S,E,I,m);f.setValue(p,d,{f:`=${y.generateStringWithSequence(N)}`,x:I,y:m,si:v})}),r[o][c]=f.getData()}}return r}_getNewRangeByMoveParam(i,e,t,n){const{type:r,unitId:o,sheetId:a,ranges:l,from:c,to:u}=e,{range:f,sheetId:p,unitId:d,sheetName:g,refOffsetX:_,refOffsetY:I}=i;if(!this._checkIsSameUnitAndSheet(o,a,t,n,d,p))return;const m=s.Rectangle.moveOffset(f,_,I);let v=null;if(r===0){if(c==null||u==null)return;const S=this._checkMoveEdge(m,c),C=s.Rectangle.getIntersects(m,c);if(C==null)return;const E=h.handleMoveRange({id:h.EffectRefRangId.MoveRangeCommandId,params:{toRange:u,fromRange:c}},C),N=h.runRefRangeMutations(E,C);if(N==null)return;v=this._getMoveNewRange(S,N,c,u,m,C)}if(l!=null){if(r===1){const S=h.handleInsertRow({id:h.EffectRefRangId.InsertRowCommandId,params:{range:l[0],workbookId:"",worksheetId:"",direction:s.Direction.DOWN}},m),C=h.runRefRangeMutations(S,m);if(C==null)return;v={...m,...C}}else if(r===2){const S=h.handleInsertCol({id:h.EffectRefRangId.InsertColCommandId,params:{range:l[0],workbookId:"",worksheetId:"",direction:s.Direction.RIGHT}},m),C=h.runRefRangeMutations(S,m);if(C==null)return;v={...m,...C}}else if(r===3){const S=h.handleIRemoveRow({id:h.EffectRefRangId.RemoveRowCommandId,params:{ranges:l}},m),C=h.runRefRangeMutations(S,m);if(C==null)return;v={...m,...C}}else if(r===4){const S=h.handleIRemoveCol({id:h.EffectRefRangId.RemoveColCommandId,params:{ranges:l}},m),C=h.runRefRangeMutations(S,m);if(C==null)return;v={...m,...C}}else if(r===5){const S=h.handleDeleteRangeMoveLeft({id:h.EffectRefRangId.DeleteRangeMoveLeftCommandId,params:{ranges:l}},m),C=h.runRefRangeMutations(S,m);if(C==null)return;v={...m,...C}}else if(r===6){const S=h.handleDeleteRangeMoveUp({id:h.EffectRefRangId.DeleteRangeMoveUpCommandId,params:{ranges:l}},m),C=h.runRefRangeMutations(S,m);if(C==null)return;v={...m,...C}}else if(r===7){const S=h.handleInsertRangeMoveDown({id:h.EffectRefRangId.InsertRangeMoveDownCommandId,params:{ranges:l}},m),C=h.runRefRangeMutations(S,m);if(C==null)return;v={...m,...C}}else if(r===8){const S=h.handleInsertRangeMoveRight({id:h.EffectRefRangId.InsertRangeMoveRightCommandId,params:{ranges:l}},m),C=h.runRefRangeMutations(S,m);if(C==null)return;v={...m,...C}}}if(v!=null)return s.serializeRangeToRefString({range:v,sheetName:g,unitId:d})}_checkIsSameUnitAndSheet(i,e,t,n,r,o){if((r==null||r.length===0)&&(o==null||o.length===0)){if(i===t&&e===n)return!0}else if((i===r||r==null||r.length===0)&&e===o)return!0;return!1}_updateRefOffset(i,e,t=0,n=0){const r=[];for(let o=0,a=i.length;o<a;o++){const l=i[o];if(typeof l=="string"||l.nodeType!==y.sequenceNodeType.REFERENCE||e.includes(o)){r.push(l);continue}const{token:c}=l,u=s.deserializeRangeWithSheet(c),{range:f,sheetName:p,unitId:d}=u,g=s.Rectangle.moveOffset(f,t,n);r.push({...l,token:s.serializeRangeToRefString({range:g,unitId:d,sheetName:p})})}return r}_checkMoveEdge(i,e){const{startRow:t,startColumn:n,endRow:r,endColumn:o}=i,{startRow:a,startColumn:l,endRow:c,endColumn:u}=e;if(t>=a&&r<=c&&n>=l&&o<=u)return 4;if(n>=l&&o<=u&&t>=a&&t<=c&&r>c)return 0;if(n>=l&&o<=u&&r>=a&&r<=c&&t<a)return 1;if(t>=a&&r<=c&&n>=l&&n<=u&&o>u)return 2;if(t>=a&&r<=c&&o>=l&&o<=u&&n<l)return 3}_getMoveNewRange(i,e,t,n,r,o){const{startRow:a,endRow:l,startColumn:c,endColumn:u}=e,{startRow:f,startColumn:p,endRow:d,endColumn:g}=t,{startRow:_,startColumn:I,endRow:m,endColumn:v}=n,{startRow:S,endRow:C,startColumn:E,endColumn:N}=o,{startRow:M,endRow:b,startColumn:L,endColumn:U}=r,F={...r};if(i===0)if(c===L&&u===U)if(a<M)F.startRow=a;else if(l<b)F.startRow=a;else if(l>=b&&_<=b)F.startRow=d+1,F.endRow=l;else return;else return;else if(i===1)if(c===L&&u===U)if(l>b)F.endRow=l;else if(a>M)F.endRow=l;else if(a<=M&&m>=M)F.endRow=f+1,F.startRow=a;else return;else return;else if(i===2)if(a===M&&l===b)if(c<L)F.startColumn=c;else if(u<U)F.startColumn=c;else if(u>=U&&I<=U)F.startColumn=g+1,F.endColumn=u;else return;else return;else if(i===3)if(a===M&&l===b)if(u>U)F.endColumn=u;else if(c>L)F.endColumn=u;else if(c<=L&&v>=L)F.endColumn=p+1,F.startColumn=c;else return;else return;else(i===4||(I<=N+1&&v>=U||I<=L&&v>=E-1)&&_<=M&&m>=b||(_<=C+1&&m>=b||_<=M&&m>=S-1)&&I<=L&&v>=U)&&(F.startRow=a,F.startColumn=c,F.endRow=l,F.endColumn=u);return F}_getInsertNewRange(){}_getCurrentSheetInfo(){const i=this._currentUniverService.getCurrentUniverSheetInstance(),e=i.getUnitId(),t=i.getActiveSheet().getSheetId();return{unitId:e,sheetId:t}}};Me=mr([s.OnLifecycle(s.LifecycleStages.Ready,Me),Q(0,s.IUniverInstanceService),Q(1,s.ICommandService),Q(2,T.Inject(y.LexerTreeBuilder)),Q(3,T.Inject(y.FormulaDataModel)),Q(4,T.Inject(h.SheetInterceptorService)),Q(5,T.Inject(h.SelectionManagerService)),Q(6,T.Inject(T.Injector))],Me);const dr={formula:{insert:{tooltip:"Functions",sum:"SUM",average:"AVERAGE",count:"COUNT",max:"MAX",min:"MIN",more:"More Functions..."},functionList:{...{},...{},...{SUM:{description:"You can add individual values, cell references or ranges or a mix of all three.",abstract:"Adds its arguments",functionParameter:{number1:{name:"number1",detail:"The first number you want to add. The number can be like 4, a cell reference like B6, or a cell range like B2:B8."},number2:{name:"number2",detail:"This is the second number you want to add. You can specify up to 255 numbers in this way."}}},SUMIF:{description:"Sum the values in a range that meet criteria that you specify.",abstract:"Adds the cells specified by a given criteria",functionParameter:{range:{name:"range",detail:"The range of cells that you want evaluated by criteria."},criteria:{name:"criteria",detail:"The criteria in the form of a number, expression, a cell reference, text, or a function that defines which cells will be added. Wildcard characters can be included - a question mark (?) to match any single character, an asterisk (*) to match any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) preceding the character."},sum_range:{name:"sum_range",detail:"The actual cells to add, if you want to add cells other than those specified in the range argument. If the sum_range argument is omitted, Excel adds the cells that are specified in the range argument (the same cells to which the criteria is applied)."}}}},...{AVERAGE:{description:"Returns the average (arithmetic mean) of the arguments.",abstract:"Returns the average of its arguments",functionParameter:{number1:{name:"number1",detail:"The first number, cell reference, or range for which you want the average."},number2:{name:"number2",detail:"Additional numbers, cell references or ranges for which you want the average, up to a maximum of 255."}}},COUNT:{description:"Counts the number of cells that contain numbers, and counts numbers within the list of arguments.",abstract:"Counts how many numbers are in the list of arguments",functionParameter:{value1:{name:"value1",detail:"The first item, cell reference, or range within which you want to count numbers."},value2:{name:"value2",detail:"Up to 255 additional items, cell references, or ranges within which you want to count numbers."}}},MAX:{description:"Returns the largest value in a set of values.",abstract:"Returns the maximum value in a list of arguments",functionParameter:{number1:{name:"number1",detail:"The first number, cell reference, or range to calculate the maximum value from."},number2:{name:"number2",detail:"Additional numbers, cell references or ranges to calculate the maximum value from, up to a maximum of 255."}}},MIN:{description:"Returns the smallest number in a set of values.",abstract:"Returns the minimum value in a list of arguments",functionParameter:{number1:{name:"number1",detail:"The first number, cell reference, or range to calculate the minimum value from."},number2:{name:"number2",detail:"Additional numbers, cell references or ranges to calculate the minimum value from, up to a maximum of 255."}}}},...{},...{},...{},...{},...{},...{},...{},...{},...{},...{},...{}},prompt:{helpExample:"EXAMPLE",helpAbstract:"ABOUT",required:"Required.",optional:"Optional."},functionType:{financial:"Financial",date:"Date & Time",math:"Math & Trig",statistical:"Statistical",lookup:"Lookup & Reference",database:"Database",text:"Text",logical:"Logical",information:"Information",engineering:"Engineering",cube:"Cube",compatibility:"Compatibility",web:"Web",array:"Array",univer:"Univer"},moreFunctions:{confirm:"Confirm",prev:"Previous",next:"Next",searchFunctionPlaceholder:"Search function",allFunctions:"All Functions",syntax:"SYNTAX"},operation:{pasteFormula:"Paste Formula"}}},ct={formula:{insert:{tooltip:"函数",sum:"求和",average:"平均值",count:"计数",max:"最大值",min:"最小值",more:"更多函数..."},functionList:{...{},...{},...{SUM:{description:"将单个值、单元格引用或是区域相加,或者将三者的组合相加。",abstract:"求参数的和",functionParameter:{number1:{name:"数值1",detail:"要相加的第一个数字。 该数字可以是 4 之类的数字,B6 之类的单元格引用或 B2:B8 之类的单元格范围。"},number2:{name:"数值2",detail:"这是要相加的第二个数字。 可以按照这种方式最多指定 255 个数字。"}}},SUMIF:{description:"对范围中符合指定条件的值求和。",abstract:"按给定条件对指定单元格求和",functionParameter:{range:{name:"范围",detail:"要根据条件进行检测的范围。"},criteria:{name:"条件",detail:"以数字、表达式、单元格引用、文本或函数的形式来定义将添加哪些单元格。可包括的通配符字符 - 问号(?)以匹配任意单个字符,星号(*)以匹配任意字符序列。 如果要查找实际的问号或星号,请在该字符前键入波形符(~)。"},sum_range:{name:"求和范围",detail:"要添加的实际单元格,如果要添加在范围参数指定以外的其他单元格。 如果省略sum_range参数,Excel就会添加范围参数中指定的单元格(与应用标准的单元格相同)。"}}}},...{AVERAGE:{description:"返回参数的平均值(算术平均值)。",abstract:"返回参数平均值",functionParameter:{number1:{name:"数值1",detail:"要计算平均值的第一个数字、单元格引用或单元格区域。"},number2:{name:"数值2",detail:"要计算平均值的其他数字、单元格引用或单元格区域,最多可包含 255 个。"}}},COUNT:{description:"计算包含数字的单元格个数以及参数列表中数字的个数。",abstract:"计算参数列表中数字的个数",functionParameter:{value1:{name:"值1",detail:"要计算其中数字的个数的第一项、单元格引用或区域。"},value2:{name:"值2",detail:"要计算其中数字的个数的其他项、单元格引用或区域,最多可包含 255 个。"}}},MAX:{description:"返回一组值中的最大值。",abstract:"返回参数列表中的最大值",functionParameter:{number1:{name:"数值1",detail:"要计算最大值的第一个数字、单元格引用或单元格区域。"},number2:{name:"数值2",detail:"要计算最大值的其他数字、单元格引用或单元格区域,最多可包含 255 个。"}}},MIN:{description:"返回一组值中的最小值。",abstract:"返回参数列表中的最小值",functionParameter:{number1:{name:"数值1",detail:"要计算最小值的第一个数字、单元格引用或单元格区域。"},number2:{name:"数值2",detail:"要计算最小值的其他数字、单元格引用或单元格区域,最多可包含 255 个。"}}}},...{},...{},...{},...{},...{},...{},...{},...{},...{},...{},...{}},prompt:{helpExample:"示例",helpAbstract:"简介",required:"必需。",optional:"可选。"},functionType:{financial:"财务",date:"日期与时间",math:"数学与三角函数",statistical:"统计",lookup:"查找与引用",database:"数据库",text:"文本",logical:"逻辑",information:"信息",engineering:"工程",cube:"多维数据集",compatibility:"兼容性",web:"Web",array:"数组",univer:"Univer"},moreFunctions:{confirm:"应用",prev:"上一步",next:"下一步",searchFunctionPlaceholder:"搜索函数",allFunctions:"全部函数",syntax:"语法"},operation:{pasteFormula:"仅粘贴公式"}}};var fr=Object.defineProperty,hr=Object.getOwnPropertyDescriptor,pr=(i,e,t,n)=>{for(var r=n>1?void 0:n?hr(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&fr(e,t,r),r},Ue=(i,e)=>(t,n)=>e(t,n,i);j.UniverSheetsFormulaPlugin=(ke=class extends s.Plugin{constructor(e,t,n,r){super(Ve),this._config=e,this._injector=t,this._localeService=n,this._currentUniverService=r}initialize(){this._localeService.load({zhCN:ct}),[[X,{useClass:Lt}],[oe,{useClass:Et}],[Ae,{useFactory:()=>{var t;return this._injector.createInstance(Pe,((t=this._config)==null?void 0:t.description)||[])}}],[Ne,{useClass:mt}],[Re],[Ie],[ge],[de],[he],[me],[Ce],[Me],[pe],[ue]].forEach(t=>this._injector.add(t))}onReady(){this.initialize()}},x(ke,"type",s.PluginType.Sheet),ke),j.UniverSheetsFormulaPlugin=pr([Ue(1,T.Inject(T.Injector)),Ue(2,T.Inject(s.LocaleService)),Ue(3,s.IUniverInstanceService)],j.UniverSheetsFormulaPlugin),j.enUS=dr,j.zhCN=ct,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-formula",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
4
|
"author": "DreamNum <developer@univer.ai>",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
7
|
-
"module": "./lib/
|
|
7
|
+
"module": "./lib/es/index.js",
|
|
8
8
|
"types": "./lib/types/index.d.ts",
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"import": "./lib/
|
|
14
|
+
"import": "./lib/es/index.js",
|
|
15
15
|
"require": "./lib/cjs/index.js",
|
|
16
16
|
"types": "./lib/types/index.d.ts"
|
|
17
17
|
},
|
|
18
18
|
"./*": {
|
|
19
|
-
"import": "./lib/
|
|
19
|
+
"import": "./lib/es/*",
|
|
20
20
|
"require": "./lib/cjs/*",
|
|
21
21
|
"types": "./lib/types/index.d.ts"
|
|
22
22
|
},
|
|
23
|
-
"./
|
|
24
|
-
"import": "./lib/esm/locale/*.js",
|
|
25
|
-
"require": "./lib/cjs/locale/*.js",
|
|
26
|
-
"types": "./lib/types/index.d.ts"
|
|
27
|
-
}
|
|
23
|
+
"./lib/*": "./lib/*"
|
|
28
24
|
},
|
|
29
25
|
"directories": {
|
|
30
26
|
"lib": "lib"
|
|
@@ -32,37 +28,52 @@
|
|
|
32
28
|
"files": [
|
|
33
29
|
"lib"
|
|
34
30
|
],
|
|
31
|
+
"sideEffects": [
|
|
32
|
+
"**/*.css"
|
|
33
|
+
],
|
|
35
34
|
"private": false,
|
|
36
35
|
"dependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@univerjs/icons": "^0.1.14",
|
|
39
|
-
"@wendellhu/redi": "^0.12.11",
|
|
40
|
-
"rxjs": "^7.8.1",
|
|
41
|
-
"@univerjs/docs": "0.1.0-alpha.1",
|
|
42
|
-
"@univerjs/engine-render": "0.1.0-alpha.1",
|
|
43
|
-
"@univerjs/engine-formula": "0.1.0-alpha.1",
|
|
44
|
-
"@univerjs/formula": "0.1.0-alpha.1",
|
|
45
|
-
"@univerjs/sheets": "0.1.0-alpha.1",
|
|
46
|
-
"@univerjs/ui": "0.1.0-alpha.1",
|
|
47
|
-
"@univerjs/core": "0.1.0-alpha.1",
|
|
48
|
-
"@univerjs/design": "0.1.0-alpha.1",
|
|
49
|
-
"@univerjs/sheets-ui": "0.1.0-alpha.1"
|
|
36
|
+
"@univerjs/icons": "^0.1.18"
|
|
50
37
|
},
|
|
51
38
|
"devDependencies": {
|
|
52
|
-
"@
|
|
53
|
-
"@
|
|
54
|
-
"
|
|
39
|
+
"@ctrl/tinycolor": "^4.0.2",
|
|
40
|
+
"@types/react": "^18.2.42",
|
|
41
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
42
|
+
"@vitest/coverage-istanbul": "^1.0.2",
|
|
43
|
+
"@wendellhu/redi": "^0.12.12",
|
|
55
44
|
"happy-dom": "^12.10.3",
|
|
56
45
|
"less": "^4.2.0",
|
|
57
46
|
"react": "^18.2.0",
|
|
58
|
-
"
|
|
59
|
-
"typescript": "^5.3.
|
|
60
|
-
"
|
|
47
|
+
"rxjs": "^7.8.1",
|
|
48
|
+
"typescript": "^5.3.3",
|
|
49
|
+
"vite": "^5.0.7",
|
|
50
|
+
"vite-plugin-dts": "^3.6.4",
|
|
51
|
+
"vite-plugin-externals": "^0.6.2",
|
|
52
|
+
"vitest": "^1.0.2",
|
|
53
|
+
"@univerjs/design": "0.1.0-alpha.2",
|
|
54
|
+
"@univerjs/docs": "0.1.0-alpha.2",
|
|
55
|
+
"@univerjs/core": "0.1.0-alpha.2",
|
|
56
|
+
"@univerjs/engine-render": "0.1.0-alpha.2",
|
|
57
|
+
"@univerjs/sheets": "0.1.0-alpha.2",
|
|
58
|
+
"@univerjs/sheets-ui": "0.1.0-alpha.2",
|
|
59
|
+
"@univerjs/engine-formula": "0.1.0-alpha.2",
|
|
60
|
+
"@univerjs/ui": "0.1.0-alpha.2"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"
|
|
63
|
+
"@ctrl/tinycolor": ">=4.0.0",
|
|
64
|
+
"@wendellhu/redi": ">=0.12.12",
|
|
65
|
+
"react": ">=16.9.0",
|
|
66
|
+
"rxjs": ">=7.0.0",
|
|
67
|
+
"@univerjs/core": "0.1.0-alpha.2",
|
|
68
|
+
"@univerjs/docs": "0.1.0-alpha.2",
|
|
69
|
+
"@univerjs/design": "0.1.0-alpha.2",
|
|
70
|
+
"@univerjs/engine-render": "0.1.0-alpha.2",
|
|
71
|
+
"@univerjs/engine-formula": "0.1.0-alpha.2",
|
|
72
|
+
"@univerjs/sheets": "0.1.0-alpha.2",
|
|
73
|
+
"@univerjs/sheets-ui": "0.1.0-alpha.2",
|
|
74
|
+
"@univerjs/ui": "0.1.0-alpha.2"
|
|
64
75
|
},
|
|
65
76
|
"scripts": {
|
|
66
|
-
"
|
|
77
|
+
"build": "tsc && vite build"
|
|
67
78
|
}
|
|
68
79
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020-present, DreamNum
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
package/lib/cjs/locale/en-US.js
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/locale/en-US.ts
|
|
21
|
-
var en_US_exports = {};
|
|
22
|
-
__export(en_US_exports, {
|
|
23
|
-
default: () => en_US_default16
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(en_US_exports);
|
|
26
|
-
|
|
27
|
-
// src/locale/function-list/array/en-US.ts
|
|
28
|
-
var en_US_default = {};
|
|
29
|
-
|
|
30
|
-
// src/locale/function-list/compatibility/en-US.ts
|
|
31
|
-
var en_US_default2 = {};
|
|
32
|
-
|
|
33
|
-
// src/locale/function-list/cube/en-US.ts
|
|
34
|
-
var en_US_default3 = {};
|
|
35
|
-
|
|
36
|
-
// src/locale/function-list/database/en-US.ts
|
|
37
|
-
var en_US_default4 = {};
|
|
38
|
-
|
|
39
|
-
// src/locale/function-list/date/en-US.ts
|
|
40
|
-
var en_US_default5 = {};
|
|
41
|
-
|
|
42
|
-
// src/locale/function-list/engineering/en-US.ts
|
|
43
|
-
var en_US_default6 = {};
|
|
44
|
-
|
|
45
|
-
// src/locale/function-list/financial/en-US.ts
|
|
46
|
-
var en_US_default7 = {};
|
|
47
|
-
|
|
48
|
-
// src/locale/function-list/information/en-US.ts
|
|
49
|
-
var en_US_default8 = {};
|
|
50
|
-
|
|
51
|
-
// src/locale/function-list/logical/en-US.ts
|
|
52
|
-
var en_US_default9 = {};
|
|
53
|
-
|
|
54
|
-
// src/locale/function-list/lookup/en-US.ts
|
|
55
|
-
var en_US_default10 = {};
|
|
56
|
-
|
|
57
|
-
// src/locale/function-list/math/en-US.ts
|
|
58
|
-
var en_US_default11 = {
|
|
59
|
-
SUM: {
|
|
60
|
-
description: "You can add individual values, cell references or ranges or a mix of all three.",
|
|
61
|
-
abstract: "Adds its arguments",
|
|
62
|
-
functionParameter: {
|
|
63
|
-
number1: {
|
|
64
|
-
name: "number1",
|
|
65
|
-
detail: "The first number you want to add. The number can be like 4, a cell reference like B6, or a cell range like B2:B8."
|
|
66
|
-
},
|
|
67
|
-
number2: {
|
|
68
|
-
name: "number2",
|
|
69
|
-
detail: "This is the second number you want to add. You can specify up to 255 numbers in this way."
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
SUMIF: {
|
|
74
|
-
description: "Sum the values in a range that meet criteria that you specify.",
|
|
75
|
-
abstract: "Adds the cells specified by a given criteria",
|
|
76
|
-
functionParameter: {
|
|
77
|
-
range: {
|
|
78
|
-
name: "range",
|
|
79
|
-
detail: "The range of cells that you want evaluated by criteria."
|
|
80
|
-
},
|
|
81
|
-
criteria: {
|
|
82
|
-
name: "criteria",
|
|
83
|
-
detail: "The criteria in the form of a number, expression, a cell reference, text, or a function that defines which cells will be added. Wildcard characters can be included - a question mark (?) to match any single character, an asterisk (*) to match any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) preceding the character."
|
|
84
|
-
},
|
|
85
|
-
sum_range: {
|
|
86
|
-
name: "sum_range",
|
|
87
|
-
detail: "The actual cells to add, if you want to add cells other than those specified in the range argument. If the sum_range argument is omitted, Excel adds the cells that are specified in the range argument (the same cells to which the criteria is applied)."
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// src/locale/function-list/statistical/en-US.ts
|
|
94
|
-
var en_US_default12 = {
|
|
95
|
-
AVERAGE: {
|
|
96
|
-
description: "Returns the average (arithmetic mean) of the arguments.",
|
|
97
|
-
abstract: "Returns the average of its arguments",
|
|
98
|
-
functionParameter: {
|
|
99
|
-
number1: {
|
|
100
|
-
name: "number1",
|
|
101
|
-
detail: "The first number, cell reference, or range for which you want the average."
|
|
102
|
-
},
|
|
103
|
-
number2: {
|
|
104
|
-
name: "number2",
|
|
105
|
-
detail: "Additional numbers, cell references or ranges for which you want the average, up to a maximum of 255."
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
COUNT: {
|
|
110
|
-
description: "Counts the number of cells that contain numbers, and counts numbers within the list of arguments.",
|
|
111
|
-
abstract: "Counts how many numbers are in the list of arguments",
|
|
112
|
-
functionParameter: {
|
|
113
|
-
value1: {
|
|
114
|
-
name: "value1",
|
|
115
|
-
detail: "The first item, cell reference, or range within which you want to count numbers."
|
|
116
|
-
},
|
|
117
|
-
value2: {
|
|
118
|
-
name: "value2",
|
|
119
|
-
detail: "Up to 255 additional items, cell references, or ranges within which you want to count numbers."
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
MAX: {
|
|
124
|
-
description: "Returns the largest value in a set of values.",
|
|
125
|
-
abstract: "Returns the maximum value in a list of arguments",
|
|
126
|
-
functionParameter: {
|
|
127
|
-
number1: {
|
|
128
|
-
name: "number1",
|
|
129
|
-
detail: "The first number, cell reference, or range to calculate the maximum value from."
|
|
130
|
-
},
|
|
131
|
-
number2: {
|
|
132
|
-
name: "number2",
|
|
133
|
-
detail: "Additional numbers, cell references or ranges to calculate the maximum value from, up to a maximum of 255."
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
MIN: {
|
|
138
|
-
description: "Returns the smallest number in a set of values.",
|
|
139
|
-
abstract: "Returns the minimum value in a list of arguments",
|
|
140
|
-
functionParameter: {
|
|
141
|
-
number1: {
|
|
142
|
-
name: "number1",
|
|
143
|
-
detail: "The first number, cell reference, or range to calculate the minimum value from."
|
|
144
|
-
},
|
|
145
|
-
number2: {
|
|
146
|
-
name: "number2",
|
|
147
|
-
detail: "Additional numbers, cell references or ranges to calculate the minimum value from, up to a maximum of 255."
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
// src/locale/function-list/text/en-US.ts
|
|
154
|
-
var en_US_default13 = {};
|
|
155
|
-
|
|
156
|
-
// src/locale/function-list/univer/en-US.ts
|
|
157
|
-
var en_US_default14 = {};
|
|
158
|
-
|
|
159
|
-
// src/locale/function-list/web/en-US.ts
|
|
160
|
-
var en_US_default15 = {};
|
|
161
|
-
|
|
162
|
-
// src/locale/en-US.ts
|
|
163
|
-
var en_US_default16 = {
|
|
164
|
-
formula: {
|
|
165
|
-
insert: {
|
|
166
|
-
tooltip: "Functions",
|
|
167
|
-
sum: "SUM",
|
|
168
|
-
average: "AVERAGE",
|
|
169
|
-
count: "COUNT",
|
|
170
|
-
max: "MAX",
|
|
171
|
-
min: "MIN",
|
|
172
|
-
more: "More Functions..."
|
|
173
|
-
},
|
|
174
|
-
functionList: {
|
|
175
|
-
...en_US_default7,
|
|
176
|
-
...en_US_default5,
|
|
177
|
-
...en_US_default11,
|
|
178
|
-
...en_US_default12,
|
|
179
|
-
...en_US_default10,
|
|
180
|
-
...en_US_default4,
|
|
181
|
-
...en_US_default13,
|
|
182
|
-
...en_US_default9,
|
|
183
|
-
...en_US_default8,
|
|
184
|
-
...en_US_default6,
|
|
185
|
-
...en_US_default3,
|
|
186
|
-
...en_US_default2,
|
|
187
|
-
...en_US_default15,
|
|
188
|
-
...en_US_default,
|
|
189
|
-
...en_US_default14
|
|
190
|
-
},
|
|
191
|
-
prompt: {
|
|
192
|
-
helpExample: "EXAMPLE",
|
|
193
|
-
helpAbstract: "ABOUT",
|
|
194
|
-
required: "Required.",
|
|
195
|
-
optional: "Optional."
|
|
196
|
-
},
|
|
197
|
-
functionType: {
|
|
198
|
-
financial: "Financial",
|
|
199
|
-
date: "Date & Time",
|
|
200
|
-
math: "Math & Trig",
|
|
201
|
-
statistical: "Statistical",
|
|
202
|
-
lookup: "Lookup & Reference",
|
|
203
|
-
database: "Database",
|
|
204
|
-
text: "Text",
|
|
205
|
-
logical: "Logical",
|
|
206
|
-
information: "Information",
|
|
207
|
-
engineering: "Engineering",
|
|
208
|
-
cube: "Cube",
|
|
209
|
-
compatibility: "Compatibility",
|
|
210
|
-
web: "Web",
|
|
211
|
-
array: "Array",
|
|
212
|
-
univer: "Univer"
|
|
213
|
-
},
|
|
214
|
-
moreFunctions: {
|
|
215
|
-
confirm: "Confirm",
|
|
216
|
-
prev: "Previous",
|
|
217
|
-
next: "Next",
|
|
218
|
-
searchFunctionPlaceholder: "Search function",
|
|
219
|
-
allFunctions: "All Functions",
|
|
220
|
-
syntax: "SYNTAX"
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
};
|