@univerjs/sheets-ui
Version:
UniverSheet normal ui-plugin-sheets
872 lines • 1.1 MB
JavaScript
var nv = Object.defineProperty;
var rv = (n, e, t) => e in n ? nv(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
var _ = (n, e, t) => rv(n, typeof e != "symbol" ? e + "" : e, t);
import { DOCS_VIEW_KEY as iv, SetInlineFormatBoldCommand as ov, SetInlineFormatItalicCommand as sv, SetInlineFormatUnderlineCommand as lv, SetInlineFormatStrikethroughCommand as av, SetInlineFormatSubscriptCommand as cv, SetInlineFormatSuperscriptCommand as dv, SetInlineFormatFontSizeCommand as fd, SetInlineFormatFontFamilyCommand as uv, SetInlineFormatTextColorCommand as dg, IEditorService as Bi, getCanvasOffsetByEngine as Hu, VIEWPORT_KEY as Zs, DOCS_COMPONENT_MAIN_LAYER_INDEX as hv, DocSelectionRenderService as Zn, BreakLineCommand as gv, DeleteLeftCommand as ug, DeleteRightCommand as mv, ReplaceSnapshotCommand as hg, MoveSelectionOperation as fv, MoveCursorOperation as pv, CoverContentCommand as vv, NodePositionConvertToCursor as gg, getLineBounding as mg, DOC_VERTICAL_PADDING as Sv, SetInlineFormatCommand as Ko, IMEInputCommand as Cv, InsertCommand as wv, convertBodyToHtml as bv } from "@univerjs/docs-ui";
import { CommandType as $, createInterceptorKey as On, ColorKit as an, RANGE_TYPE as j, convertCellToRange as Gs, UniverInstanceType as H, IUniverInstanceService as W, Quantity as Hc, Disposable as ae, toDisposable as Fe, Tools as ye, createIdentifier as jt, InterceptorManager as Fi, ThemeService as Pt, Inject as D, Injector as Rt, IConfigService as xt, generateRandomId as En, ObjectMatrix as Ze, Direction as U, isFormulaString as pd, isFormulaId as _v, CellValueType as yt, numfmt as vr, ICommandService as B, IUndoRedoService as qt, Rectangle as le, sequenceExecute as Ql, FOCUSING_SHEET as Nt, FOCUSING_UNIVER_EDITOR as xr, EDITOR_ACTIVATED as qe, FOCUSING_COMMON_DRAWINGS as Kl, FOCUSING_FX_BAR_EDITOR as Ht, FOCUSING_EDITOR_INPUT_FORMULA as qs, FOCUSING_EDITOR_STANDALONE as Jl, cloneValue as Ds, LRUMap as Rv, BaselineOffset as Vu, BooleanNumber as et, DataStreamTreeTokenType as Iv, getNumfmtParseValueFilter as Ui, skipParseTagNames as yv, CustomRangeType as vd, DEFAULT_WORKSHEET_ROW_HEIGHT as Vc, ILogService as $l, LocaleService as Pe, ErrorService as Mv, CellModeEnum as Ev, cloneCellDataWithSpanAndDisplay as Tv, getEmptyCell as no, isNotNullOrUndefined as Pv, extractPureTextFromCell as fg, IConfirmService as un, getReverseDirection as pg, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as xe, IContextService as He, DEFAULT_STYLES as Or, Workbook as xv, Optional as Sd, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as Oe, RxDisposable as An, DisposableCollection as ht, IPermissionService as ot, fromEventSubject as Qs, sortRules as Ov, AbsoluteRefType as Ks, debounce as Js, nameCharacterCheck as Av, throttle as Hv, VerticalAlign as nn, HorizontalAlign as It, WrapStrategy as hr, LocaleType as Nu, FOCUSING_EDITOR_BUT_HIDDEN as Nc, DEFAULT_EMPTY_DOCUMENT_VALUE as vg, isTextFormat as Jo, PresetListType as Vv, UserManagerService as Bt, FontWeight as _s, FontItalic as Rs, composeStyles as Nv, FOCUSING_COMMENT_EDITOR as kv, get as Ua, BorderStyleTypes as Te, NilCommand as Cd, splitIntoGrid as Dv, UndoCommandId as Lv, willLoseNumericPrecision as Wv, cloneCellData as kc, cloneCellDataMatrix as ea, Range as Ls, cellToRange as Bv, handleStyleToString as ku, DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY as Du, DEFAULT_WORKSHEET_COLUMN_WIDTH as Lu, DocumentFlavor as Fv, isRealNum as Sg, InterceptorEffectEnum as Uv, IAuthzIoService as ta, isValidRange as zv, dayjs as Is, BuildTextUtils as Xv, DependentOn as Cg, Plugin as wg, merge as bg, registerDependencies as $s, mergeOverrideWithDependencies as _g, touchDependencies as oi, set as jv } from "@univerjs/core";
import { SELECTION_CONTROL_BORDER_BUFFER_WIDTH as el, SELECTION_CONTROL_BORDER_BUFFER_COLOR as ys, convertPrimaryWithCoordToPrimary as Yv, SELECTIONS_ENABLED as Jr, REF_SELECTIONS_ENABLED as Io, SheetSkeletonService as Zv, SheetsSelectionsService as J, SheetInterceptorService as Hn, MarkDirtyRowAutoHeightMutation as Rg, CancelMarkDirtyRowAutoHeightMutation as Ig, getSheetCommandTarget as We, SetWorksheetRowAutoHeightMutationFactory as yg, SetWorksheetRowAutoHeightMutation as Qn, rangeToDiscreteRange as vo, SetSelectionsOperation as _e, SetRangeValuesMutation as be, generateNullCellValue as Gv, SetRangeValuesUndoMutationFactory as cn, SetWorksheetActiveOperation as st, getPrimaryForRange as yo, DeleteRangeMoveLeftCommand as Wu, DeleteRangeMoveUpCommand as Bu, alignToMergedCellsBorders as _n, SetRowHiddenCommand as Mg, SetColHiddenCommand as Eg, SetBoldCommand as wd, SetItalicCommand as bd, SetUnderlineCommand as _d, SetStrikeThroughCommand as Rd, SetFontSizeCommand as $o, SetFontFamilyCommand as Id, SetTextColorCommand as Tg, InsertRangeMoveDownCommand as Dc, InsertRangeMoveRightCommand as Lc, EditStateEnum as $t, ViewStateEnum as vi, UnitObject as Dt, WorksheetProtectionRuleModel as ft, DeleteWorksheetProtectionCommand as tl, RangeProtectionRuleModel as tt, DeleteRangeProtectionMutation as Fu, AddRangeProtectionMutation as qv, RemoveRowCommand as Pg, RemoveColCommand as xg, SHEETS_PLUGIN_CONFIG_KEY as Qv, defaultLargeSheetOperationConfig as Kv, countCells as Jv, RemoveSheetCommand as $v, SetFrozenMutationFactory as Og, SetFrozenMutation as gr, getSelectionsService as Sr, SelectionMoveType as Vt, getCellAtRowCol as Ws, expandToContinuousRange as eS, ScrollToCellOperation as yd, SetWorksheetColWidthMutation as en, BEFORE_CELL_EDIT as tS, AddWorksheetProtectionCommand as Ag, SetRangeValuesCommand as na, MoveRangeMutation as Kn, RemoveRowMutation as es, RemoveColMutation as ts, InsertRowMutation as ns, InsertColMutation as rs, MoveRowsMutation as ra, MoveColsMutation as ia, SetWorksheetRowHeightMutation as Mo, RemoveSheetMutation as Ar, RemoveMergeUndoMutationFactory as Md, RemoveWorksheetMergeMutation as Rn, AddWorksheetMergeMutation as In, getAddMergeMutationRangeByType as Ed, AddMergeUndoMutationFactory as Td, WorkbookEditablePermission as K, WorksheetEditPermission as te, UnitAction as Eo, SetWorksheetShowCommand as oa, RangeProtectionCache as is, WorksheetViewPermission as Hg, SetWorksheetOrderMutation as Pd, InsertSheetMutation as zi, SetWorksheetNameMutation as xd, SetWorksheetHideMutation as Xi, SetWorksheetActivateCommand as Od, WorkbookManageCollaboratorPermission as Vg, WorkbookRenameSheetPermission as Ng, SetWorksheetOrderCommand as nS, SetWorksheetNameCommand as rS, SetTabColorMutation as iS, WorkbookCreateSheetPermission as kg, InsertSheetCommand as oS, ClearSelectionFormatCommand as So, COMMAND_LISTENER_SKELETON_CHANGE as Ad, adjustRangeOnMutation as sS, RangeProtectionPermissionEditPoint as oe, IExclusiveRangeService as lS, BorderStyleManagerService as Wc, WorksheetSetCellStylePermission as je, SetBorderBasicCommand as Bc, ClearSelectionAllCommand as go, WorksheetSetCellValuePermission as Zt, ClearSelectionContentCommand as mr, WorkbookDeleteRowPermission as aS, WorksheetDeleteRowPermission as cS, WorkbookDeleteColumnPermission as dS, WorksheetDeleteColumnPermission as uS, CancelFrozenCommand as Bs, ToggleGridlinesCommand as Dg, ToggleGridlinesMutation as hS, WorkbookInsertRowPermission as sa, WorksheetInsertRowPermission as la, InsertMultiRowsAfterCommand as Lg, InsertMultiRowsAboveCommand as Wg, WorkbookInsertColumnPermission as aa, WorksheetInsertColumnPermission as ca, InsertMultiColsRightCommand as Bg, InsertMultiColsLeftCommand as Fg, InsertColBeforeCommand as Ug, InsertRowBeforeCommand as zg, SetWorksheetRowIsAutoHeightCommand as Hd, WorksheetSetRowStylePermission as Hr, SetRowHeightCommand as Xg, SetRowHiddenMutation as jg, SetRowVisibleMutation as Yg, SetSelectedRowsVisibleCommand as Zg, WorksheetSetColumnStylePermission as Vr, RangeProtectionPermissionViewPoint as nl, WorkbookCopyPermission as $r, WorksheetCopyPermission as To, SetColWidthCommand as Gg, SetColHiddenMutation as qg, SetColVisibleMutation as Qg, SetSelectedColsVisibleCommand as Kg, SetTextRotationCommand as Fc, SetTextWrapCommand as Uc, SetVerticalTextAlignCommand as zc, SetHorizontalTextAlignCommand as Xc, ResetBackgroundColorCommand as Jg, SetBackgroundColorCommand as rl, SetWorksheetRowIsAutoHeightMutation as gS, MergeCellController as mS, MERGE_CELL_INTERCEPTOR_CHECK as fS, RemoveWorksheetMergeCommand as $g, AddWorksheetMergeHorizontalCommand as em, AddWorksheetMergeVerticalCommand as tm, AddWorksheetMergeAllCommand as nm, AddWorksheetMergeCommand as Vd, WorkbookCreateProtectPermission as da, WorksheetDeleteProtectionPermission as rm, WorksheetManageCollaboratorPermission as pS, SetWorksheetHideCommand as im, SetTabColorCommand as om, CopySheetCommand as sm, WorkbookDeleteSheetPermission as vS, WorkbookHideSheetPermission as lm, ResetTextColorCommand as SS, SheetPermissionCheckController as Nd, SetFrozenCommand as CS, InsertRowCommand as wS, InsertColCommand as bS, MoveColsCommand as am, MoveRowsCommand as cm, DeltaRowHeightCommand as _S, DeltaColumnWidthCommand as RS, COMMAND_LISTENER_VALUE_CHANGE as IS, RefRangeService as yS, IRefSelectionsService as kd, SCOPE_WORKBOOK_VALUE_DEFINED_NAME as jc, InsertDefinedNameCommand as MS, SetDefinedNameCommand as ES, RemoveDefinedNameCommand as TS, INumfmtService as PS, ToggleCellCheckboxCommand as xS, MoveRangeCommand as dm, MAX_CELL_PER_SHEET_KEY as OS, INTERCEPTOR_POINT as AS, getClearContentMutationParamsForRanges as HS, SheetPermissionInitController as VS, SetProtectionCommand as NS, AddRangeProtectionCommand as kS, setEndForRange as DS, baseProtectionActions as LS, DeleteRangeProtectionCommand as WS, WorksheetProtectionPointModel as BS, SetWorksheetPermissionPointsCommand as FS, getAllWorksheetPermissionPoint as US, SetSpecificRowsVisibleCommand as zS, SetSpecificColsVisibleCommand as XS, convertSelectionDataToRange as um, UniverSheetsPlugin as hm, RefSelectionsService as gm } from "@univerjs/sheets";
import { IRenderManagerService as fe, withCurrentTypeOfRenderer as Dd, SHEET_VIEWPORT_KEY as z, CURSOR_TYPE as Ie, Vector2 as De, Rect as ve, ScrollTimer as si, ScrollTimerType as bt, DashedRect as jS, Group as za, TRANSFORM_CHANGE_OBSERVABLE_TYPE as Yc, cancelRequestFrame as YS, requestNewFrame as ZS, FIX_ONE_PIXEL_BLUR_OFFSET as GS, Layer as qS, SpreadsheetSkeleton as QS, ptToPixel as Uu, RENDER_CLASS_TYPE as KS, DeviceInputEventType as Xe, convertTransformToOffsetX as ei, convertTransformToOffsetY as ti, convertTextRotation as Ld, RENDER_RAW_FORMULA_KEY as JS, Spreadsheet as mm, getCurrentTypeOfRenderer as os, ScrollBar as Wd, fixLineWidthByScale as zu, Shape as Bd, SHEET_EXTENSION_PREFIX as Xu, SpreadsheetRowHeader as $S, SpreadsheetColumnHeader as eC, Viewport as gn, hasCJKText as tC, DEFAULT_PADDING_DATA as nC, SheetExtension as fm, RegularPolygon as mo, precisionTo as jn } from "@univerjs/engine-render";
import { BehaviorSubject as Me, Subject as Ae, switchMap as at, map as Ne, of as Se, merge as Ct, startWith as At, takeUntil as Si, distinctUntilChanged as rn, throttleTime as il, EMPTY as ju, filter as ji, combineLatest as nt, Observable as Be, combineLatestWith as tr, shareReplay as Yu, Subscription as Gn, withLatestFrom as rC } from "rxjs";
import { handleStringToStyle as iC, textTrim as Zu, IClipboardInterfaceService as ua, INotificationService as oC, IPlatformService as sC, PLAIN_TEXT_CLIPBOARD_MIME_TYPE as Gu, HTML_CLIPBOARD_MIME_TYPE as qu, imageMimeTypeSet as lC, FILE__BMP_CLIPBOARD_MIME_TYPE as aC, FILE__WEBP_CLIPBOARD_MIME_TYPE as cC, FILE__JPEG_CLIPBOARD_MIME_TYPE as dC, FILE_PNG_CLIPBOARD_MIME_TYPE as uC, CopyCommand as hC, CutCommand as pm, PasteCommand as gC, SheetPasteShortKeyCommandName as mC, ISidebarService as Yi, KeyCode as Y, IDialogService as ss, useDependency as k, useObservable as dt, ComponentManager as kt, DISABLE_AUTO_FOCUS_KEY as Qu, useEvent as Ku, useSidebarClick as vm, MetaKeys as pe, useComponentsOfPart as fC, ComponentContainer as pC, useConfigValue as ha, UI_PLUGIN_CONFIG_KEY as ga, UIMenu as vC, ContextMenuPosition as _t, Slider as SC, IMessageService as Sm, IMenuManagerService as Fd, ToolbarItem as CC, ILayoutService as Ud, getMenuHiddenObservable as se, MenuItemType as Q, FONT_SIZE_LIST as wC, FONT_SIZE_COMPONENT as bC, IContextMenuService as ma, COLOR_PICKER_COMPONENT as zd, FONT_FAMILY_ITEM_COMPONENT as _C, FONT_FAMILY_COMPONENT as RC, ContextMenuGroup as $e, RibbonPosition as IC, RibbonStartGroup as Ms, ICanvasPopupService as yC, IShortcutService as fa, IUIPartsService as Xd, BuiltInUIPart as li, connectInjector as ai, IZenZoneService as Cm, UniverMobileUIPlugin as MC } from "@univerjs/ui";
import { DocSelectionManagerService as jd, DocSkeletonManagerService as qn, RichTextEditingMutation as Po, SetTextSelectionsOperation as ls } from "@univerjs/docs";
import { useRef as yn, createElement as lt, forwardRef as ut, useState as ne, useMemo as St, useEffect as we, useCallback as Tn, useLayoutEffect as EC } from "react";
import { IDefinedNamesService as as, LexerTreeBuilder as Yd, serializeRangeWithSheet as Zd, isReferenceStringWithEffectiveColumn as wm, deserializeRangeWithSheet as Gd, FUNCTION_NAMES_STATISTICAL as ze, FUNCTION_NAMES_MATH as pa, FUNCTION_NAMES_TEXT as TC, sequenceNodeType as Xa, matchToken as bm, IFunctionService as _m, SetFormulaCalculationNotificationMutation as PC, ISuperTableService as xC, operatorToken as Kr, isReferenceStrings as Rm, FormulaDataModel as OC, NullValueObject as Ju, serializeRange as Im } from "@univerjs/engine-formula";
import { jsx as b, jsxs as q, Fragment as Zi } from "react/jsx-runtime";
import { DropdownMenu as qd, clsx as Ee, borderClassName as Gi, borderBottomClassName as Qd, scrollbarClassName as va, borderRightClassName as Kd, Dropdown as Zc, Button as Xt, DropdownLegacy as AC, Tooltip as Xn, MessageType as ym, InputNumber as HC, Separator as VC, ColorPicker as Mm, Input as ol, RadioGroup as Gc, Radio as ni, Select as Em, Confirm as NC, FormLayout as sl, Avatar as Jd, Switch as kC, borderTopClassName as ll, CascaderList as DC, TimeInput as LC, Calendar as WC } from "@univerjs/design";
import { startWith as ja, shareReplay as $u, switchMap as Mn, map as dn, debounceTime as Sa, filter as Tm } from "rxjs/operators";
import { ITelemetryService as BC } from "@univerjs/telemetry";
function $d(n, e) {
if (n == null)
return;
const t = e.getRenderById(n);
if (t == null)
return;
const { mainComponent: r, scene: i, engine: o, components: s } = t, l = r, a = s.get(iv.BACKGROUND);
return {
document: l,
docBackground: a,
scene: i,
engine: o
};
}
const qc = [10, 400], Pm = "RANGE_SELECTOR_COMPONENT_KEY", eu = "EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY";
var Ge = /* @__PURE__ */ ((n) => (n.MAIN = "__SpreadsheetRender__", n.ROW = "__SpreadsheetRowHeader__", n.COLUMN = "__SpreadsheetColumnHeader__", n.LEFT_TOP = "__SpreadsheetLeftTopPlaceholder__", n))(Ge || {});
const eh = 0, al = 1, Jn = 10, FC = 11, th = 12, Ca = {
id: "sheet.command.set-row-header-width",
type: $.COMMAND,
handler: async (n, e) => {
if (!e)
return !1;
const t = n.get(fe);
if (!t)
return !1;
const { unitId: r, subUnitId: i, size: o } = e, s = t.getRenderById(r);
if (s) {
t.getRenderById(r).with(ge).setRowHeaderSize(s, i, o);
const { components: a } = s, c = a.get(Ge.ROW);
c && c.setCustomHeader({ headerStyle: { size: o } }, i);
}
return !0;
}
}, wa = {
id: "sheet.command.set-col-header-height",
type: $.COMMAND,
handler: async (n, e) => {
if (!e)
return !1;
const t = n.get(fe);
if (!t)
return !1;
const { unitId: r, subUnitId: i, size: o } = e, s = t.getRenderById(r);
if (s) {
t.getRenderById(r).with(ge).setColumnHeaderSize(s, i, o);
const { components: a } = s, c = a.get(Ge.COLUMN);
c && c.setCustomHeader({ headerStyle: { size: o } }, i);
}
return !0;
}
}, Qc = On("rangeMovePermissionCheck"), Kc = On("rangeFillPermissionCheck");
var xm = /* @__PURE__ */ ((n) => (n[n.FORMULA_EDITOR_SHOW = 100] = "FORMULA_EDITOR_SHOW", n[n.MARK_SELECTION = 1e4] = "MARK_SELECTION", n))(xm || {});
function $n(n) {
const e = n.getColorFromTheme("primary.600"), t = n.getColorFromTheme("white"), r = new an(e).setAlpha(0.07).toRgbString();
return {
strokeWidth: 1,
stroke: e,
fill: r,
// widgets: { tl: true, tc: true, tr: true, ml: true, mr: true, bl: true, bc: true, br: true },
widgets: {},
widgetSize: 6,
widgetStrokeWidth: 1,
widgetStroke: t,
autofillSize: 6,
autofillStrokeWidth: 1,
autofillStroke: t,
rowHeaderFill: r,
rowHeaderStroke: e,
rowHeaderStrokeWidth: 1,
columnHeaderFill: r,
columnHeaderStroke: e,
columnHeaderStrokeWidth: 1,
expandCornerSize: 40
};
}
class UC {
constructor() {
_(this, "_startColumn", -1);
_(this, "_startRow", -1);
_(this, "_endColumn", -1);
_(this, "_endRow", -1);
_(this, "_startX", 0);
_(this, "_startY", 0);
_(this, "_endX", 0);
_(this, "_endY", 0);
/**
* The highlight cell of a selection. aka: current cell
*/
_(this, "_primary");
_(this, "_rangeType", j.NORMAL);
}
get startColumn() {
return this._startColumn;
}
get startRow() {
return this._startRow;
}
get endColumn() {
return this._endColumn;
}
get endRow() {
return this._endRow;
}
get startX() {
return this._startX;
}
get startY() {
return this._startY;
}
get endX() {
return this._endX;
}
get endY() {
return this._endY;
}
get currentCell() {
return this._primary;
}
get rangeType() {
return this._rangeType;
}
/**
* @deprecated, Duplicate with `Rectangle`
*/
isEqual(e) {
const { startColumn: t, startRow: r, endColumn: i, endRow: o } = this, {
startColumn: s,
startRow: l,
endColumn: a,
endRow: c
} = e;
return t === s && r === l && i === a && o === c;
}
highlightToSelection() {
if (this._primary)
return Gs(this._primary);
}
getRange() {
return {
startColumn: this._startColumn,
startRow: this._startRow,
endColumn: this._endColumn,
endRow: this._endRow,
startX: this._startX,
startY: this._startY,
endX: this._endX,
endY: this._endY,
rangeType: this.rangeType
};
}
getCell() {
return this._primary;
}
getRangeType() {
return this._rangeType;
}
setRangeType(e) {
this._rangeType = e;
}
getValue() {
return {
rangeWithCoord: this.getRange(),
primaryWithCoord: this._primary
};
}
setValue(e, t) {
const {
startColumn: r,
startRow: i,
endColumn: o,
endRow: s,
startX: l,
startY: a,
endX: c,
endY: d,
rangeType: u
} = e;
this._startColumn = r, this._startRow = i, this._endColumn = o, this._endRow = s, this._startX = l, this._startY = a, this._endX = c, this._endY = d, u !== void 0 && (this._rangeType = u), t !== void 0 && this.setCurrentCell(t);
}
/**
* Set primary cell.
* @TODO lumixraku there are 3 concepts for same thing, primary and current and highlight
* highlight is best. primary sometimes means the actual cell(actual means ignore merge)
* @param currentCell
*/
setCurrentCell(e) {
this._primary = e;
}
clearCurrentCell() {
this._primary = null;
}
}
function xo(n, e) {
const { startRow: t, startColumn: r, endRow: i, endColumn: o, rangeType: s } = e, l = i < t ? i : t, a = i < t ? t : i, c = o < r ? o : r, d = o < r ? r : o, u = n.getNoMergeCellWithCoordByIndex(l, c), h = n.getNoMergeCellWithCoordByIndex(a, d);
return {
startRow: t,
startColumn: r,
endRow: i,
endColumn: o,
rangeType: s,
startY: (u == null ? void 0 : u.startY) || 0,
endY: (h == null ? void 0 : h.endY) || 0,
startX: (u == null ? void 0 : u.startX) || 0,
endX: (h == null ? void 0 : h.endX) || 0
};
}
function Wt(n, e) {
const { range: t, primary: r, style: i } = n, o = xo(e, t), s = r && cl(e, r);
return {
rangeWithCoord: o,
primaryWithCoord: s,
style: i
};
}
function cl(n, e) {
const { actualRow: t, actualColumn: r, isMerged: i, isMergedMainCell: o, startRow: s, startColumn: l, endRow: a, endColumn: c } = e, d = n.getNoMergeCellWithCoordByIndex(t, r), u = n.getNoMergeCellWithCoordByIndex(s, l), h = n.getNoMergeCellWithCoordByIndex(a, c);
return {
actualRow: t,
actualColumn: r,
isMerged: i,
isMergedMainCell: o,
startX: d.startX,
startY: d.startY,
endX: d.endX,
endY: d.endY,
mergeInfo: {
startRow: s,
startColumn: l,
endRow: a,
endColumn: c,
startY: (u == null ? void 0 : u.startY) || 0,
endY: (h == null ? void 0 : h.endY) || 0,
startX: (u == null ? void 0 : u.startX) || 0,
endX: (h == null ? void 0 : h.endX) || 0
}
};
}
const nh = "__SpreadsheetHelperSelectionTempRect", zC = 35;
class XC {
constructor(e, t) {
_(this, "_startOffsetX", 0);
_(this, "_startOffsetY", 0);
_(this, "_relativeSelectionPositionRow", 0);
_(this, "_relativeSelectionPositionColumn", 0);
_(this, "_relativeSelectionRowLength", 0);
_(this, "_relativeSelectionColumnLength", 0);
_(this, "_scenePointerMoveSub");
_(this, "_scenePointerUpSub");
_(this, "_disabled", !1);
/**
* The shadow selection under cursor when move whole selection control(for moving normal selection)
*/
_(this, "_helperSelection");
_(this, "_scrollTimer");
_(this, "_activeViewport");
_(this, "_targetSelection", {
startY: 0,
endY: 0,
startX: 0,
endX: 0,
startRow: -1,
endRow: -1,
startColumn: -1,
endColumn: -1
});
_(this, "_isInMergeState", !1);
_(this, "_fillControlColors", []);
_(this, "_skeleton");
_(this, "_scene");
_(this, "_themeService");
_(this, "_injector");
_(this, "_selectionHooks");
this._control = e, this._skeleton = t.skeleton, this._scene = t.scene, this._themeService = t.themeService, this._injector = t.injector, this._selectionHooks = t.selectionHooks, this._initialControl(), this._initialWidget(), this._initialAutoFill(), this._control.dispose$.subscribe(() => {
this.dispose();
});
}
get isHelperSelection() {
return this._control.isHelperSelection;
}
dispose() {
var e, t;
(e = this._scrollTimer) == null || e.dispose(), this._fillControlColors = [], this._clearObserverEvent(), (t = this._helperSelection) == null || t.dispose();
}
setDisabled(e) {
this._disabled = e;
}
_getFreeze() {
var t, r;
return (r = (t = Dd(
H.UNIVER_SHEET,
ge,
this._injector.get(W),
this._injector.get(fe)
)) == null ? void 0 : t.getCurrentParam()) == null ? void 0 : r.skeleton.getWorksheetConfig().freeze;
}
_isSelectionInViewport(e, t) {
const r = this._getFreeze() || {
startRow: -1,
startColumn: -1
};
switch (t.viewportKey) {
case z.VIEW_MAIN:
return e.endRow >= r.startRow && e.endColumn >= r.startColumn;
case z.VIEW_MAIN_TOP:
case z.VIEW_COLUMN_RIGHT:
return e.endColumn >= r.startColumn && e.startRow < r.startRow;
case z.VIEW_MAIN_LEFT:
case z.VIEW_ROW_BOTTOM:
return e.endRow >= r.startRow && e.startColumn < r.startColumn;
case z.VIEW_MAIN_LEFT_TOP:
case z.VIEW_COLUMN_LEFT:
case z.VIEW_ROW_TOP:
case z.VIEW_LEFT_TOP:
return e.startRow < r.startRow && e.startColumn < r.startColumn;
}
}
_clearObserverEvent() {
var e, t;
(e = this._scenePointerMoveSub) == null || e.unsubscribe(), (t = this._scenePointerUpSub) == null || t.unsubscribe(), this._scenePointerMoveSub = null, this._scenePointerUpSub = null;
}
_initialControl() {
const { leftControl: e, rightControl: t, topControl: r, bottomControl: i } = this._control;
[e, t, r, i].forEach((o) => {
o.onPointerEnter$.subscribeEvent(() => {
var l;
((l = this._injector.get(gt, Hc.OPTIONAL)) == null ? void 0 : l.interceptor.fetchThroughInterceptors(Qc)(!1, null)) !== !1 && o.setCursor(Ie.MOVE);
}), o.onPointerLeave$.subscribeEvent(() => {
o.resetCursor();
}), o.onPointerDown$.subscribeEvent(this._controlPointerDownHandler.bind(this));
});
}
/**
* Move the whole selection control after cursor turn into move state.
* NOT same as widgetMoving, that's for 8 control points.
* @param moveOffsetX
* @param moveOffsetY
*/
_controlMoving(e, t) {
var E;
const r = this._scene, i = r.getScrollXYInfoByViewport(De.FromArray([e, t])), { scaleX: o, scaleY: s } = r.getAncestorScale(), l = this._skeleton.getCellIndexByOffset(
e,
t,
o,
s,
i
), { row: a, column: c } = l, d = this._skeleton.getRowCount() - 1, u = this._skeleton.getColumnCount() - 1;
let h = Math.max(0, a + this._relativeSelectionPositionRow), m = h + this._relativeSelectionRowLength;
m > d && (m = d, m - h < this._relativeSelectionRowLength && (h = m - this._relativeSelectionRowLength));
let g = Math.max(0, c + this._relativeSelectionPositionColumn), f = g + this._relativeSelectionColumnLength;
f > u && (f = u, f - g < this._relativeSelectionColumnLength && (g = f - this._relativeSelectionColumnLength));
const p = this._skeleton.worksheet.getCellInfoInMergeData(h, g), S = Wt({
range: { startRow: h, endRow: m, startColumn: g, endColumn: f },
primary: p,
style: null
}, this._skeleton), C = this._skeleton.getNoMergeCellWithCoordByIndex(h, g), w = this._skeleton.getNoMergeCellWithCoordByIndex(m, f), R = (C == null ? void 0 : C.startY) || 0, I = (w == null ? void 0 : w.endY) || 0, y = (C == null ? void 0 : C.startX) || 0, M = (w == null ? void 0 : w.endX) || 0;
(E = this._helperSelection) == null || E.transformByState({
left: y,
top: R,
width: M - y,
height: I - R
}), this._targetSelection = { ...S.rangeWithCoord }, this._control.selectionMoving$.next(S.rangeWithCoord);
}
/**
* Drag move whole selectionControl when cursor turns to crosshair. Not for dragging 8 control points.
* @param evt
*/
_controlPointerDownHandler(e) {
const { offsetX: t, offsetY: r } = e, i = this._scene, o = i.getCoordRelativeToViewport(De.FromArray([t, r])), { x: s, y: l } = o, a = i.getScrollXYInfoByViewport(o), { scaleX: c, scaleY: d } = i.getAncestorScale(), u = this._skeleton.getCellIndexByOffset(
s,
l,
c,
d,
a
);
this._startOffsetX = s, this._startOffsetY = l;
const { row: h, column: m } = u, {
startRow: g,
startColumn: f,
endRow: p,
endColumn: v
} = this._control.model;
let S = 0, C = 0;
h < g ? S -= 1 : h > p && (S += 1), m < f ? C -= 1 : m > v && (C += 1), this._relativeSelectionPositionRow = g - h + S, this._relativeSelectionPositionColumn = f - m + C, this._relativeSelectionRowLength = p - g, this._relativeSelectionColumnLength = v - f;
const w = this._control.currentStyle, R = this._getScale();
this.isHelperSelection && (this._helperSelection = new ve(nh, {
stroke: w.stroke,
strokeWidth: w.strokeWidth / R
}), i.addObject(this._helperSelection));
const I = i.getViewport(z.VIEW_MAIN), y = si.create(i);
this._scrollTimer = y, y.startScroll(s, l, I), i.disableObjectsEvent(), this._scenePointerMoveSub = i.onPointerMove$.subscribeEvent((M) => {
var A;
if (this._disabled)
return;
const { offsetX: E, offsetY: P } = M;
if (((A = this._injector.get(gt, Hc.OPTIONAL)) == null ? void 0 : A.interceptor.fetchThroughInterceptors(Qc)(!1, null)) === !1)
return;
const { x, y: O } = i.getCoordRelativeToViewport(
De.FromArray([E, P])
);
this._controlMoving(x, O), i.setCursor(Ie.MOVE), y.scrolling(x, O, () => {
this._controlMoving(x, O);
});
}), this._scenePointerUpSub = i.onPointerUp$.subscribeEvent(() => {
var E, P, T, x;
(E = this._helperSelection) == null || E.dispose();
const M = this._scene;
M.resetCursor(), this._clearObserverEvent(), M.enableObjectsEvent(), (P = this._scrollTimer) == null || P.dispose(), this._control.selectionMoveEnd$.next(this._targetSelection), (x = (T = this._selectionHooks).selectionMoveEnd) == null || x.call(T);
});
}
_initialWidget() {
const {
topLeftWidget: e,
topCenterWidget: t,
topRightWidget: r,
middleLeftWidget: i,
middleRightWidget: o,
bottomLeftWidget: s,
bottomCenterWidget: l,
bottomRightWidget: a
} = this._control, c = [
Ie.NORTH_WEST_RESIZE,
Ie.NORTH_RESIZE,
Ie.NORTH_EAST_RESIZE,
Ie.WEST_RESIZE,
Ie.EAST_RESIZE,
Ie.SOUTH_WEST_RESIZE,
Ie.SOUTH_RESIZE,
Ie.SOUTH_EAST_RESIZE
];
[
e,
t,
r,
i,
o,
s,
l,
a
].forEach((d, u) => {
d.onPointerEnter$.subscribeEvent(() => {
d.setCursor(c[u]);
}), d.onPointerLeave$.subscribeEvent(() => {
d.resetCursor();
}), d.onPointerDown$.subscribeEvent((h) => {
this._widgetPointerDownEvent(h, c[u]);
});
});
}
/**
* Pointer down Events for 8 control point.
* @param evt
* @param cursor
*/
_widgetPointerDownEvent(e, t) {
const r = this._scene, { offsetX: i, offsetY: o } = e, s = r.getCoordRelativeToViewport(De.FromArray([i, o])), { x: l, y: a } = s;
this._startOffsetX = i, this._startOffsetY = o;
const {
startRow: c,
startColumn: d,
endRow: u,
endColumn: h
} = this._control.model, m = Math.min(c, u), g = Math.min(d, h), f = Math.max(c, u), p = Math.max(d, h);
this._relativeSelectionPositionRow = m, this._relativeSelectionPositionColumn = g, this._relativeSelectionRowLength = f - m, this._relativeSelectionColumnLength = p - g, t === Ie.NORTH_WEST_RESIZE ? (this._relativeSelectionPositionRow = f, this._relativeSelectionPositionColumn = p) : t === Ie.NORTH_RESIZE ? this._relativeSelectionPositionRow = f : t === Ie.NORTH_EAST_RESIZE ? this._relativeSelectionPositionRow = f : t === Ie.WEST_RESIZE ? this._relativeSelectionPositionColumn = p : t === Ie.SOUTH_WEST_RESIZE ? this._relativeSelectionPositionColumn = p : t === Ie.SOUTH_RESIZE && (this._relativeSelectionPositionRow = m);
const v = si.create(r), S = r.getViewport(z.VIEW_MAIN);
v.startScroll(l, a, S), this._scrollTimer = v, r.disableObjectsEvent(), this._scenePointerMoveSub = r.onPointerMove$.subscribeEvent((C) => {
const { offsetX: w, offsetY: R } = C, { x: I, y } = r.getCoordRelativeToViewport(
De.FromArray([w, R])
);
this._widgetMoving(I, y, t), r.setCursor(t), v.scrolling(I, y, () => {
this._widgetMoving(I, y, t);
});
}), this._scenePointerUpSub = r.onPointerUp$.subscribeEvent(() => {
var w, R, I;
const C = this._scene;
C.resetCursor(), this._clearObserverEvent(), C.enableObjectsEvent(), (w = this._scrollTimer) == null || w.dispose(), this._control.selectionScaled$.next(this._targetSelection), (I = (R = this._selectionHooks).selectionMoveEnd) == null || I.call(R);
});
}
/**
* Pointer move Events for 8 control point.
* @param moveOffsetX
* @param moveOffsetY
* @param cursor
*/
_widgetMoving(e, t, r) {
const i = this._scene, o = i.getScrollXYInfoByViewport(De.FromArray([this._startOffsetX, this._startOffsetY])), { scaleX: s, scaleY: l } = i.getAncestorScale(), a = this._skeleton.getCellIndexByOffset(
e,
t,
s,
l,
o
), { row: c, column: d } = a;
let u = this._relativeSelectionPositionRow, h = this._relativeSelectionPositionColumn, m = c, g = d;
r === Ie.NORTH_WEST_RESIZE ? (u = c, h = d, m = this._relativeSelectionPositionRow, g = this._relativeSelectionPositionColumn) : r === Ie.NORTH_RESIZE ? (u = c, h = this._relativeSelectionPositionColumn, m = this._relativeSelectionPositionRow, g = this._relativeSelectionPositionColumn + this._relativeSelectionColumnLength) : r === Ie.NORTH_EAST_RESIZE ? (u = c, h = this._relativeSelectionPositionColumn, m = this._relativeSelectionPositionRow, g = d) : r === Ie.WEST_RESIZE ? (u = this._relativeSelectionPositionRow, h = d, m = this._relativeSelectionPositionRow + this._relativeSelectionRowLength, g = this._relativeSelectionPositionColumn) : r === Ie.EAST_RESIZE ? m = this._relativeSelectionPositionRow + this._relativeSelectionRowLength : r === Ie.SOUTH_WEST_RESIZE ? (u = this._relativeSelectionPositionRow, h = d, m = c, g = this._relativeSelectionPositionColumn) : r === Ie.SOUTH_RESIZE && (u = this._relativeSelectionPositionRow, h = this._relativeSelectionPositionColumn, m = c, g = this._relativeSelectionPositionColumn + this._relativeSelectionColumnLength);
const f = this._swapPositions(u, h, m, g), p = this._skeleton.getCellWithMergeInfoByIndex(u, h), S = Wt({ range: f, primary: p, style: null }, this._skeleton);
this._targetSelection = { ...S.rangeWithCoord }, this._control.updateRangeBySelectionWithCoord(S), this._control.selectionScaling$.next(this._targetSelection);
}
_initialAutoFill() {
const { fillControl: e } = this._control;
e.onPointerEnter$.subscribeEvent((t) => {
this._injector.get(gt).interceptor.fetchThroughInterceptors(Kc)(!1, { x: t.offsetX, y: t.offsetY, skeleton: this._skeleton, scene: this._scene }) && e.setCursor(Ie.CROSSHAIR);
}), e.onPointerLeave$.subscribeEvent(() => {
e.resetCursor();
}), e.onPointerDown$.subscribeEvent(this._autoFillForPointerdown.bind(this));
}
// eslint-disable-next-line complexity
_autoFillMoving(e, t) {
var P, T, x;
const r = this._scene, i = r.getViewportScrollXY(this._activeViewport), { scaleX: o, scaleY: s } = r.getAncestorScale(), l = this._skeleton.getCellIndexByOffset(
e,
t,
o,
s,
i
), { row: a, column: c } = l, d = r.getCoordRelativeToViewport(De.FromArray([e, t])), u = this._skeleton.getRowCount() - 1, h = this._skeleton.getColumnCount() - 1;
let m = this._relativeSelectionPositionRow, g = this._relativeSelectionPositionColumn, f = this._relativeSelectionPositionRow + this._relativeSelectionRowLength, p = this._relativeSelectionPositionColumn + this._relativeSelectionColumnLength, v = !1, S = !0;
if ((c < g || c > p) && a >= m && a <= f) {
const O = this._fillRuler(
c,
g,
p,
this._relativeSelectionColumnLength,
h
);
g = O.startRowOrColumn, p = O.endRowOrColumn, v = O.isLighten, S = !1;
} else if ((a < m || a > f) && c >= g && c <= p) {
const O = this._fillRuler(a, m, f, this._relativeSelectionRowLength, u);
m = O.startRowOrColumn, f = O.endRowOrColumn, v = O.isLighten;
} else if (Math.abs(this._startOffsetX - d.x - i.x) / 2 > Math.abs(this._startOffsetY - d.y - i.y)) {
const O = this._fillRuler(
c,
g,
p,
this._relativeSelectionColumnLength,
h
);
g = O.startRowOrColumn, p = O.endRowOrColumn, v = O.isLighten, S = !1;
} else {
const O = this._fillRuler(a, m, f, this._relativeSelectionRowLength, u);
m = O.startRowOrColumn, f = O.endRowOrColumn, v = O.isLighten;
}
const C = this._skeleton.getNoMergeCellWithCoordByIndex(m, g), w = this._skeleton.getNoMergeCellWithCoordByIndex(f, p), R = (C == null ? void 0 : C.startY) || 0, I = (w == null ? void 0 : w.endY) || 0, y = (C == null ? void 0 : C.startX) || 0, M = (w == null ? void 0 : w.endX) || 0;
v ? this._controlHandler((O, A) => {
const V = new an(this._fillControlColors[A]).lighten(zC).toRgbString();
O.setProps({
fill: V
});
}) : this._controlHandler((O, A) => {
O.setProps({
fill: this._fillControlColors[A]
});
});
const E = el / this._getScale();
m === f && S === !0 || g === p && S === !1 ? (P = this._helperSelection) == null || P.hide() : ((T = this._helperSelection) == null || T.transformByState({
left: y - E / 2,
top: R - E / 2,
width: M - y,
height: I - R
}), (x = this._helperSelection) == null || x.show()), this._targetSelection = {
startY: R,
endY: I,
startX: y,
endX: M,
startRow: m,
endRow: f,
startColumn: g,
endColumn: p
}, this._control.selectionFilling$.next(this._targetSelection);
}
// eslint-disable-next-line max-lines-per-function
_autoFillForPointerdown(e) {
const { offsetX: t, offsetY: r } = e, i = this._scene, o = i.getCoordRelativeToViewport(De.FromArray([t, r])), { x: s, y: l } = o;
this._startOffsetX = s, this._startOffsetY = l;
const {
startRow: a,
startColumn: c,
endRow: d,
endColumn: u
} = this._control.model;
this._isInMergeState = this._hasMergeInRange(a, c, d, u), this._relativeSelectionPositionRow = a, this._relativeSelectionPositionColumn = c, this._relativeSelectionRowLength = d - a, this._relativeSelectionColumnLength = u - c;
const h = this._control.currentStyle;
let m = h == null ? void 0 : h.stroke, g = h == null ? void 0 : h.strokeWidth;
const f = $n(this._themeService);
m == null && (m = f.stroke), g == null && (g = f.strokeWidth);
const p = this._getScale();
g /= p;
const v = el / p, S = new an(m).darken(2).toRgbString();
this.isHelperSelection && (this._helperSelection = new ve(nh, {
stroke: S,
strokeWidth: g + v / 2
}), i.addObject(this._helperSelection)), this._activeViewport = i.getActiveViewportByCoord(De.FromArray([t, r]));
const C = i.getViewport(z.VIEW_MAIN), w = si.create(
i,
this._activeViewport.viewportKey === z.VIEW_MAIN ? bt.ALL : bt.NONE
);
w.startScroll(s, l, C), this._scrollTimer = w, i.disableObjectsEvent(), this._controlHandler((R) => {
this._fillControlColors.push(R.fill);
}), this._scenePointerMoveSub = i.onPointerMove$.subscribeEvent((R) => {
var O;
const { offsetX: I, offsetY: y } = R, M = i.getActiveViewportByCoord(De.FromArray([I, y]));
if (!this._injector.get(gt).interceptor.fetchThroughInterceptors(Kc)(!1, { x: e.offsetX, y: e.offsetY, skeleton: this._skeleton, scene: this._scene }))
return;
const { x: P, y: T } = i.getCoordRelativeToViewport(
De.FromArray([I, y])
);
this._autoFillMoving(P, T), i.setCursor(Ie.CROSSHAIR);
const x = this._targetSelection;
if (C && M && ((O = this._activeViewport) == null ? void 0 : O.viewportKey) !== (M == null ? void 0 : M.viewportKey)) {
let A;
x.startRow !== a ? (w.scrollTimerType = bt.Y, A = {
...x,
endRow: x.startRow
}) : x.endRow !== d ? (w.scrollTimerType = bt.Y, A = {
...x,
startRow: x.endRow
}) : x.startColumn !== c ? (w.scrollTimerType = bt.X, A = {
...x,
endColumn: x.startColumn
}) : (w.scrollTimerType = bt.X, A = {
...x,
startColumn: x.endColumn
}), this._isSelectionInViewport(A, M) && (this._viewportMainScrollBarNeedResetPosition(w.scrollTimerType, this._activeViewport.viewportKey, M.viewportKey) && C.scrollToBarPos({
x: w.scrollTimerType === bt.X ? 0 : void 0,
y: w.scrollTimerType === bt.Y ? 0 : void 0
}), this._activeViewport = M);
}
w.scrolling(P, T, () => {
this._autoFillMoving(P, T);
});
}), this._scenePointerUpSub = i.onPointerUp$.subscribeEvent(() => {
var I, y;
(I = this._helperSelection) == null || I.dispose();
const R = this._scene;
R.resetCursor(), this._clearObserverEvent(), R.enableObjectsEvent(), (y = this._scrollTimer) == null || y.dispose(), this._control.refreshSelectionFilled(this._targetSelection), this._isInMergeState = !1, this._controlHandler((M, E) => {
M.setProps({
fill: this._fillControlColors[E]
});
}), this._fillControlColors = [];
});
}
_viewportMainScrollBarNeedResetPosition(e, t, r) {
return e === bt.X && (t === z.VIEW_MAIN_LEFT || t === z.VIEW_MAIN_LEFT_TOP) && (r === z.VIEW_MAIN || r === z.VIEW_MAIN_TOP) || e === bt.Y && (t === z.VIEW_MAIN_TOP || t === z.VIEW_MAIN_LEFT_TOP) && (r === z.VIEW_MAIN || r === z.VIEW_MAIN_LEFT);
}
_hasMergeInRange(e, t, r, i) {
return this._skeleton.worksheet.getMergedCellRange(e, t, r, i).length > 0;
}
/**
* Make sure startRow < endRow and startColumn < endColumn
*
* @param startRow
* @param startColumn
* @param endRow
* @param endColumn
* @returns {IRange} range
*/
_swapPositions(e, t, r, i) {
const o = Math.min(e, r), s = Math.min(t, i), l = Math.max(e, r), a = Math.max(t, i);
return {
startRow: o,
startColumn: s,
endRow: l,
endColumn: a
};
}
_controlHandler(e) {
const {
leftControl: t,
rightControl: r,
topControl: i,
bottomControl: o,
backgroundControlTop: s,
backgroundControlMiddleLeft: l,
backgroundControlMiddleRight: a,
backgroundControlBottom: c,
fillControl: d
} = this._control, u = [
t,
r,
i,
o,
s,
l,
a,
c,
d
];
for (let h = 0, m = u.length; h < m; h++) {
const g = u[h];
e(g, h);
}
}
_fillRuler(e, t, r, i, o) {
let s = !1;
if (e < t)
if (this._isInMergeState && e < t) {
const l = t - e, a = i + 1, c = Math.ceil(l / a);
let d = t - c * a;
d < 0 && (d = t - (c - 1) * a), t = d;
} else
t = e;
else if (e >= t && e <= r)
s = !0, this._isInMergeState || (r = e);
else if (this._isInMergeState && e > r) {
const l = e - r, a = i + 1, c = Math.ceil(l / a);
let d = r + c * a;
d > o && (d = r + (c - 1) * a), r = d;
} else
r = e;
return {
rowOrColumn: e,
startRowOrColumn: t,
endRowOrColumn: r,
isLighten: s
};
}
_getScale() {
const { scaleX: e, scaleY: t } = this._scene.getAncestorScale();
return Math.max(e, t);
}
}
var Jc = /* @__PURE__ */ ((n) => (n.Selection = "__SpreadsheetSelectionShape__", n.top = "__SpreadsheetSelectionTopControl__", n.bottom = "__SpreadsheetSelectionBottomControl__", n.left = "__SpreadsheetSelectionShapeLeftControl__", n.right = "__SpreadsheetSelectionShapeRightControl__", n.backgroundTop = "__SpreadsheetSelectionBackgroundControlTop__", n.backgroundMiddleLeft = "__SpreadsheetSelectionBackgroundControlMiddleLeft__", n.backgroundMiddleRight = "__SpreadsheetSelectionBackgroundControlMiddleRight__", n.backgroundBottom = "__SpreadsheetSelectionBackgroundControlBottom__", n.fill = "__SpreadsheetSelectionFillControl__", n.fillTopLeft = "__SpreadsheetSelectionFillControlTopLeft__", n.fillBottomRight = "__SpreadsheetSelectionFillControlBottomRight__", n.fillTopLeftInner = "__SpreadsheetSelectionFillControlTopLeftInner__", n.fillBottomRightInner = "__SpreadsheetSelectionFillControlBottomRightInner__", n.lineMain = "__SpreadsheetDragLineMainControl__", n.lineContent = "__SpreadsheetDragLineContentControl__", n.line = "__SpreadsheetDragLineControl__", n.dash = "__SpreadsheetDragDashControl__", n.rowHeaderBackground = "__SpreadSheetSelectionRowHeaderBackground__", n.rowHeaderBorder = "__SpreadSheetSelectionRowHeaderBorder__", n.rowHeaderGroup = "__SpreadSheetSelectionRowHeaderGroup__", n.columnHeaderBackground = "__SpreadSheetSelectionColumnHeaderBackground__", n.columnHeaderBorder = "__SpreadSheetSelectionColumnHeaderBorder__", n.columnHeaderGroup = "__SpreadSheetSelectionColumnHeaderGroup__", n.topLeftWidget = "__SpreadSheetSelectionTopLeftWidget__", n.topCenterWidget = "__SpreadSheetSelectionTopCenterWidget__", n.topRightWidget = "__SpreadSheetSelectionTopRightWidget__", n.middleLeftWidget = "__SpreadSheetSelectionMiddleLeftWidget__", n.middleRightWidget = "__SpreadSheetSelectionMiddleRightWidget__", n.bottomLeftWidget = "__SpreadSheetSelectionBottomLeftWidget__", n.bottomCenterWidget = "__SpreadSheetSelectionBottomCenterWidget__", n.bottomRightWidget = "__SpreadSheetSelectionBottomRightWidget__", n))(Jc || {});
const rh = 0.3;
class tu extends ae {
constructor(t, r, i, o) {
var s, l, a, c;
super();
_(this, "_isHelperSelection", !0);
/**
* For ref selections, there is no auto fill.
*/
_(this, "_enableAutoFill", !0);
/**
* Only normal selections with primary cell has auto fill.
* This works for multiple normal selections. Only last selection has primary cell and auto fill.
*/
_(this, "_showAutoFill", !1);
/**
* If rowHeader & col Header would be highlighted with selection.
*/
_(this, "_highlightHeader", !0);
_(this, "_selectionRenderModel");
_(this, "_leftBorder");
_(this, "_rightBorder");
_(this, "_topBorder");
_(this, "_bottomBorder");
_(this, "_backgroundControlTop");
_(this, "_backgroundControlBottom");
_(this, "_backgroundControlMiddleLeft");
_(this, "_backgroundControlMiddleRight");
_(this, "_autoFillControl");
_(this, "_selectionShapeGroup");
_(this, "_rowHeaderBackground");
_(this, "_rowHeaderBorder");
_(this, "_rowHeaderGroup");
_(this, "_columnHeaderBackground");
_(this, "_columnHeaderBorder");
_(this, "_columnHeaderGroup");
_(this, "_dashedRect");
// for ref selection
_(this, "_topLeftWidget");
_(this, "_topCenterWidget");
_(this, "_topRightWidget");
_(this, "_middleLeftWidget");
_(this, "_middleRightWidget");
_(this, "_bottomLeftWidget");
_(this, "_bottomCenterWidget");
_(this, "_bottomRightWidget");
// why three style prop? what's diff between _selectionStyle & _currentStyle?
// protected _selectionStyle: Nullable<ISelectionStyle>;
_(this, "_defaultStyle");
_(this, "_currentStyle");
_(this, "_rowHeaderWidth", 0);
_(this, "_columnHeaderHeight", 0);
_(this, "_widgetRects", []);
_(this, "_controlExtension");
_(this, "_dispose$", new Me(this));
_(this, "dispose$", this._dispose$.asObservable());
/**
* eventSource: selectionShapeExtension selectionMoving$.next,
* Observer: prompt.controller
*/
_(this, "selectionMoving$", new Ae());
_(this, "selectionMoveEnd$", new Ae());
_(this, "selectionScaling$", new Ae());
_(this, "selectionScaled$", new Ae());
_(this, "selectionFilling$", new Ae());
_(this, "_selectionFilled$", new Ae());
_(this, "selectionFilled$", this._selectionFilled$.asObservable());
_(this, "_antLineOffset", 0);
_(this, "_antRequestNewFrame", -1);
this._scene = t, this._zIndex = r, this._themeService = i, this._enableAutoFill = (s = o == null ? void 0 : o.enableAutoFill) != null ? s : !0, this._highlightHeader = (l = o == null ? void 0 : o.highlightHeader) != null ? l : !0, this._rowHeaderWidth = (a = o == null ? void 0 : o.rowHeaderWidth) != null ? a : 0, this._columnHeaderHeight = (c = o == null ? void 0 : o.columnHeaderHeight) != null ? c : 0, this._initializeSheetBody(), this._initialHeader();
}
_initializeSheetBody() {
this._defaultStyle = $n(this._themeService), this._currentStyle = $n(this._themeService), this._selectionRenderModel = new UC();
const t = this._zIndex;
this._leftBorder = new ve("__SpreadsheetSelectionShapeLeftControl__" + t, {
zIndex: t
}), this._rightBorder = new ve("__SpreadsheetSelectionShapeRightControl__" + t, {
zIndex: t
}), this._topBorder = new ve("__SpreadsheetSelectionTopControl__" + t, {
zIndex: t
}), this._bottomBorder = new ve("__SpreadsheetSelectionBottomControl__" + t, {
zIndex: t
}), this._backgroundControlTop = new ve("__SpreadsheetSelectionBackgroundControlTop__" + t, {
zIndex: t - 1,
evented: !1
}), this._backgroundControlBottom = new ve("__SpreadsheetSelectionBackgroundControlBottom__" + t, {
zIndex: t - 1,
evented: !1
}), this._backgroundControlMiddleLeft = new ve("__SpreadsheetSelectionBackgroundControlMiddleLeft__" + t, {
zIndex: t - 1,
evented: !1
}), this._backgroundControlMiddleRight = new ve("__SpreadsheetSelectionBackgroundControlMiddleRight__" + t, {
zIndex: t - 1,
evented: !1
}), this._autoFillControl = new ve("__SpreadsheetSelectionFillControl__" + t, {
zIndex: t + 1
}), this._autoFillControl.hide(), this._dashedRect = new jS("__SpreadsheetDragDashControl__" + t, {
zIndex: t + 2,
evented: !1,
stroke: "#fff"
});
const r = [
this._autoFillControl,
this._leftBorder,
this._rightBorder,
this._topBorder,
this._bottomBorder,
this._backgroundControlTop,
this._backgroundControlMiddleLeft,
this._backgroundControlMiddleRight,
this._backgroundControlBottom,
this._dashedRect
];
this._widgetRects = this._initialWidget(), this._selectionShapeGroup = new za("__SpreadsheetSelectionShape__" + t, ...r, ...this._widgetRects), this._selectionShapeGroup.hide(), this._selectionShapeGroup.evented = !1, this._selectionShapeGroup.zIndex = t;
const i = this.getScene();
i.addObject(this._selectionShapeGroup, al), this.disposeWithMe(
Fe(
i.onTransformChange$.subscribeEvent((o) => {
o.type === Yc.scale && (this._updateLayoutOfSelectionControl(this._currentStyle), this._updateControlCoord());
})
)
);
}
_initialHeader() {
const t = this._zIndex;
this._rowHeaderBackground = new ve("__SpreadSheetSelectionRowHeaderBackground__" + t, {
zIndex: t - 1,
evented: !1
}), this._rowHeaderBorder = new ve("__SpreadSheetSelectionRowHeaderBorder__" + t, {
zIndex: t - 1,
evented: !1
}), this._rowHeaderGroup = new za(
"__SpreadSheetSelectionRowHeaderGroup__" + t,
this._rowHeaderBackground,
this._rowHeaderBorder
), this._rowHeaderGroup.hide(), this._rowHeaderGroup.evented = !1, this._rowHeaderGroup.zIndex = t, this._columnHeaderBackground = n