@univerjs/sheets-ui
Version:
UniverSheet normal ui-plugin-sheets
875 lines • 1.08 MB
JavaScript
var Dp = Object.defineProperty;
var Lp = (r, e, t) => e in r ? Dp(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
var b = (r, e, t) => Lp(r, typeof e != "symbol" ? e + "" : e, t);
import { DOCS_VIEW_KEY as Wp, SetInlineFormatBoldCommand as Bp, SetInlineFormatItalicCommand as Fp, SetInlineFormatUnderlineCommand as Up, SetInlineFormatStrikethroughCommand as Xp, SetInlineFormatSubscriptCommand as zp, SetInlineFormatSuperscriptCommand as jp, SetInlineFormatFontSizeCommand as Yp, SetInlineFormatFontFamilyCommand as Zp, SetInlineFormatTextColorCommand as Wh, IEditorService as Ni, getCanvasOffsetByEngine as hu, VIEWPORT_KEY as ks, DOCS_COMPONENT_MAIN_LAYER_INDEX as Gp, DocSelectionRenderService as Kn, BreakLineCommand as qp, DeleteLeftCommand as Bh, DeleteRightCommand as Qp, ReplaceSnapshotCommand as Fh, MoveSelectionOperation as Kp, MoveCursorOperation as Jp, CoverContentCommand as $p, NodePositionConvertToCursor as Uh, getLineBounding as Xh, DOC_VERTICAL_PADDING as ev, SetInlineFormatCommand as Bo, IMEInputCommand as tv, InsertCommand as nv, convertBodyToHtml as rv } from "@univerjs/docs-ui";
import { CommandType as K, createInterceptorKey as Nn, ColorKit as fn, RANGE_TYPE as z, convertCellToRange as Ns, UniverInstanceType as O, IUniverInstanceService as N, Quantity as wc, Disposable as se, toDisposable as We, Tools as ue, createIdentifier as Yt, InterceptorManager as Di, ThemeService as At, Inject as k, Injector as Rt, IConfigService as Lt, generateRandomId as On, ObjectMatrix as Ge, Direction as U, isFormulaString as rd, isFormulaId as iv, CellValueType as Mt, numfmt as pn, ICommandService as L, IUndoRedoService as Zt, Rectangle as le, sequenceExecute as Fo, FOCUSING_SHEET as Ht, FOCUSING_UNIVER_EDITOR as Or, EDITOR_ACTIVATED as Je, FOCUSING_COMMON_DRAWINGS as kl, FOCUSING_FX_BAR_EDITOR as xt, FOCUSING_EDITOR_INPUT_FORMULA as Ds, FOCUSING_EDITOR_STANDALONE as Nl, LRUMap as ov, BaselineOffset as gu, BooleanNumber as Ke, DataStreamTreeTokenType as sv, skipParseTagNames as lv, CustomRangeType as id, DEFAULT_WORKSHEET_ROW_HEIGHT as _c, ILogService as Dl, LocaleService as Pe, ErrorService as av, CellModeEnum as zh, isNotNullOrUndefined as cv, extractPureTextFromCell as jh, getReverseDirection as Yh, IContextService as De, Workbook as dv, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as ke, Optional as od, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as Oe, RxDisposable as Dn, DisposableCollection as ht, IPermissionService as rt, fromEventSubject as Ls, sortRules as uv, nameCharacterCheck as hv, throttle as gv, debounce as bc, VerticalAlign as cn, HorizontalAlign as It, WrapStrategy as fr, LocaleType as mu, FOCUSING_EDITOR_BUT_HIDDEN as Rc, DEFAULT_EMPTY_DOCUMENT_VALUE as Zh, isTextFormat as Ll, PresetListType as mv, UserManagerService as Wt, DEFAULT_STYLES as sd, FontWeight as hs, FontItalic as gs, composeStyles as fv, Dimension as Gh, get as Oa, BorderStyleTypes as Ve, AbsoluteRefType as fu, NilCommand as ld, splitIntoGrid as pv, UndoCommandId as vv, willLoseNumericPrecision as Sv, Range as Es, cellToRange as Cv, handleStyleToString as pu, DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY as vu, DEFAULT_WORKSHEET_COLUMN_WIDTH as Su, DocumentFlavor as wv, isRealNum as qh, InterceptorEffectEnum as _v, IAuthzIoService as Wl, isValidRange as bv, dayjs as ms, BuildTextUtils as Rv, DependentOn as Qh, Plugin as Kh, merge as Jh, registerDependencies as Ws, mergeOverrideWithDependencies as $h, touchDependencies as ei, set as Iv } from "@univerjs/core";
import { SELECTION_CONTROL_BORDER_BUFFER_WIDTH as Bs, SELECTION_CONTROL_BORDER_BUFFER_COLOR as fs, SELECTIONS_ENABLED as Gr, REF_SELECTIONS_ENABLED as Co, SheetSkeletonService as yv, SheetsSelectionsService as $, SheetInterceptorService as Sn, MarkDirtyRowAutoHeightMutation as eg, CancelMarkDirtyRowAutoHeightMutation as tg, getSheetCommandTarget as Ue, SetWorksheetRowAutoHeightMutationFactory as ng, SetWorksheetRowAutoHeightMutation as tr, rangeToDiscreteRange as ho, SetSelectionsOperation as Te, SetRangeValuesMutation as be, generateNullCellValue as Mv, SetRangeValuesUndoMutationFactory as $t, SetWorksheetActiveOperation as nt, getPrimaryForRange as rg, DeleteRangeMoveLeftCommand as Cu, DeleteRangeMoveUpCommand as wu, alignToMergedCellsBorders as Tn, SetRowHiddenCommand as ig, SetColHiddenCommand as og, SetBoldCommand as ad, SetItalicCommand as cd, SetUnderlineCommand as dd, SetStrikeThroughCommand as ud, SetFontSizeCommand as hd, SetFontFamilyCommand as gd, SetTextColorCommand as sg, InsertRangeMoveDownCommand as Ic, InsertRangeMoveRightCommand as yc, EditStateEnum as sn, ViewStateEnum as ui, UnitObject as kt, WorksheetProtectionRuleModel as ft, DeleteWorksheetProtectionCommand as Fs, RangeProtectionRuleModel as $e, DeleteRangeProtectionMutation as _u, AddRangeProtectionMutation as Ev, RemoveRowCommand as lg, RemoveColCommand as ag, RemoveSheetCommand as Tv, SetFrozenMutationFactory as cg, SetFrozenMutation as pr, getSelectionsService as Uo, SelectionMoveType as Xt, getCellAtRowCol as Ts, expandToContinuousRange as Pv, ScrollToCellOperation as md, SetWorksheetColWidthMutation as ln, BEFORE_CELL_EDIT as xv, AddWorksheetProtectionCommand as dg, SetRangeValuesCommand as Bl, MoveRangeMutation as nr, RemoveRowMutation as Xo, RemoveColMutation as zo, InsertRowMutation as jo, InsertColMutation as Yo, MoveRowsMutation as Fl, MoveColsMutation as Ul, SetWorksheetRowHeightMutation as wo, RemoveSheetMutation as An, RemoveMergeUndoMutationFactory as Xl, RemoveWorksheetMergeMutation as Qt, AddWorksheetMergeMutation as Kt, getAddMergeMutationRangeByType as zl, AddMergeUndoMutationFactory as jl, WorkbookEditablePermission as Q, WorksheetEditPermission as te, UnitAction as _o, SetWorksheetShowCommand as fd, RangeProtectionCache as Zo, WorksheetViewPermission as ug, SetWorksheetOrderMutation as pd, InsertSheetMutation as Ar, SetWorksheetNameMutation as vd, SetWorksheetHideMutation as rr, SetWorksheetActivateCommand as Sd, WorkbookManageCollaboratorPermission as hg, WorkbookRenameSheetPermission as gg, SetWorksheetOrderCommand as Ov, SetWorksheetNameCommand as Av, SetTabColorMutation as Hv, WorkbookCreateSheetPermission as mg, InsertSheetCommand as Vv, ClearSelectionFormatCommand as go, COMMAND_LISTENER_SKELETON_CHANGE as Us, adjustRangeOnMutation as kv, RangeProtectionPermissionEditPoint as ie, IExclusiveRangeService as Nv, BorderStyleManagerService as Mc, WorksheetSetCellStylePermission as Ze, SetBorderBasicCommand as Ec, ClearSelectionAllCommand as so, WorksheetSetCellValuePermission as qt, ClearSelectionContentCommand as vr, WorkbookDeleteRowPermission as Dv, WorksheetDeleteRowPermission as Lv, WorkbookDeleteColumnPermission as Wv, WorksheetDeleteColumnPermission as Bv, ToggleGridlinesCommand as fg, ToggleGridlinesMutation as Fv, InsertMultiRowsAfterCommand as pg, WorkbookInsertRowPermission as Yl, WorksheetInsertRowPermission as Zl, InsertMultiRowsAboveCommand as vg, InsertMultiColsRightCommand as Sg, WorkbookInsertColumnPermission as Gl, WorksheetInsertColumnPermission as ql, InsertMultiColsLeftCommand as Cg, InsertColBeforeCommand as wg, InsertRowBeforeCommand as _g, CancelFrozenCommand as Ps, SetWorksheetRowIsAutoHeightCommand as Cd, WorksheetSetRowStylePermission as Hr, SetRowHeightCommand as bg, SetRowHiddenMutation as Rg, SetRowVisibleMutation as Ig, SetSelectedRowsVisibleCommand as yg, WorksheetSetColumnStylePermission as Vr, SetColWidthCommand as Mg, SetColHiddenMutation as Eg, SetColVisibleMutation as Tg, SetSelectedColsVisibleCommand as Pg, SetTextRotationCommand as Tc, SetTextWrapCommand as Pc, SetVerticalTextAlignCommand as xc, SetHorizontalTextAlignCommand as Oc, ResetBackgroundColorCommand as xg, SetBackgroundColorCommand as Xs, WorksheetCopyPermission as zs, RangeProtectionPermissionViewPoint as Ac, WorkbookCopyPermission as lo, SetWorksheetRowIsAutoHeightMutation as Uv, AddMergeRedoSelectionsOperationFactory as Xv, AddMergeUndoSelectionsOperationFactory as zv, MergeCellController as jv, MERGE_CELL_INTERCEPTOR_CHECK as Yv, RemoveWorksheetMergeCommand as Og, WorkbookCreateProtectPermission as Ql, WorksheetDeleteProtectionPermission as Ag, WorksheetManageCollaboratorPermission as Zv, SetWorksheetHideCommand as Hg, SetTabColorCommand as Vg, CopySheetCommand as kg, WorkbookDeleteSheetPermission as Gv, WorkbookHideSheetPermission as Ng, AddWorksheetMergeCommand as qv, AddWorksheetMergeHorizontalCommand as Qv, AddWorksheetMergeVerticalCommand as Kv, AddWorksheetMergeAllCommand as Jv, ResetTextColorCommand as $v, SheetPermissionCheckController as wd, SetFrozenCommand as eS, InsertRowCommand as tS, InsertColCommand as nS, MoveColsCommand as Dg, MoveRowsCommand as Lg, DeltaRowHeightCommand as rS, DeltaColumnWidthCommand as iS, COMMAND_LISTENER_VALUE_CHANGE as oS, RefRangeService as sS, IRefSelectionsService as _d, SCOPE_WORKBOOK_VALUE_DEFINED_NAME as Hc, InsertDefinedNameCommand as lS, SetDefinedNameCommand as aS, RemoveDefinedNameCommand as cS, INumfmtService as dS, ToggleCellCheckboxCommand as uS, MoveRangeCommand as Wg, MAX_CELL_PER_SHEET_KEY as hS, INTERCEPTOR_POINT as gS, SheetPermissionInitController as mS, SetProtectionCommand as fS, AddRangeProtectionCommand as pS, setEndForRange as vS, baseProtectionActions as SS, DeleteRangeProtectionCommand as CS, WorksheetProtectionPointModel as wS, SetWorksheetPermissionPointsCommand as _S, getAllWorksheetPermissionPoint as bS, SetSpecificRowsVisibleCommand as RS, SetSpecificColsVisibleCommand as IS, convertSelectionDataToRange as Bg, UniverSheetsPlugin as Fg, RefSelectionsService as Ug } from "@univerjs/sheets";
import { IRenderManagerService as Ce, withCurrentTypeOfRenderer as bd, SHEET_VIEWPORT_KEY as F, CURSOR_TYPE as ye, Vector2 as Ne, Rect as we, ScrollTimer as ti, ScrollTimerType as _t, DashedRect as yS, Group as Aa, TRANSFORM_CHANGE_OBSERVABLE_TYPE as Vc, cancelRequestFrame as MS, requestNewFrame as ES, FIX_ONE_PIXEL_BLUR_OFFSET as TS, Layer as PS, SpreadsheetSkeleton as xS, ptToPixel as bu, RENDER_CLASS_TYPE as OS, DeviceInputEventType as ze, convertTransformToOffsetX as qr, convertTransformToOffsetY as Qr, convertTextRotation as Rd, RENDER_RAW_FORMULA_KEY as AS, Spreadsheet as Xg, getCurrentTypeOfRenderer as Go, ScrollBar as Id, fixLineWidthByScale as Ru, Shape as yd, SHEET_EXTENSION_PREFIX as Iu, SpreadsheetRowHeader as HS, SpreadsheetColumnHeader as VS, Viewport as wn, hasCJKText as kS, DEFAULT_PADDING_DATA as NS, SheetExtension as zg, RegularPolygon as ao, precisionTo as qn } from "@univerjs/engine-render";
import { BehaviorSubject as Me, Subject as Ae, switchMap as lt, map as Be, of as Ie, merge as St, startWith as Pt, takeUntil as hi, distinctUntilChanged as dn, throttleTime as js, EMPTY as yu, filter as qo, combineLatest as at, Observable as je, combineLatestWith as sr, shareReplay as Mu, Subscription as Jn, withLatestFrom as DS } from "rxjs";
import { DEFAULT_BACKGROUND_COLOR_RGB as LS, DEFAULT_BACKGROUND_COLOR_RGBA as WS, handleStringToStyle as BS, textTrim as Eu, IClipboardInterfaceService as Kl, INotificationService as FS, IPlatformService as US, PLAIN_TEXT_CLIPBOARD_MIME_TYPE as Tu, HTML_CLIPBOARD_MIME_TYPE as Pu, imageMimeTypeSet as XS, FILE__BMP_CLIPBOARD_MIME_TYPE as zS, FILE__WEBP_CLIPBOARD_MIME_TYPE as jS, FILE__JPEG_CLIPBOARD_MIME_TYPE as YS, FILE_PNG_CLIPBOARD_MIME_TYPE as ZS, CopyCommand as GS, CutCommand as qS, PasteCommand as QS, SheetPasteShortKeyCommandName as KS, IConfirmService as tn, ISidebarService as Li, KeyCode as Z, IDialogService as Qo, useDependency as D, useObservable as ut, ComponentManager as Vt, DISABLE_AUTO_FOCUS_KEY as xu, useEvent as Ou, useSidebarClick as jg, MetaKeys as Se, useComponentsOfPart as JS, ComponentContainer as $S, useConfigValue as Jl, UI_PLUGIN_CONFIG_KEY as $l, UIMenu as eC, ContextMenuPosition as bt, Slider as tC, IMessageService as Yg, IMenuManagerService as Md, ToolbarItem as nC, ILayoutService as Ed, getMenuHiddenObservable as de, MenuItemType as J, IContextMenuService as Td, COLOR_PICKER_COMPONENT as Pd, FONT_SIZE_LIST as rC, FONT_SIZE_COMPONENT as iC, FONT_FAMILY_LIST as oC, FONT_FAMILY_COMPONENT as sC, FONT_FAMILY_ITEM_COMPONENT as lC, ContextMenuGroup as Qe, RibbonPosition as aC, RibbonStartGroup as ps, ICanvasPopupService as cC, IShortcutService as ea, IUIPartsService as xd, BuiltInUIPart as ni, connectInjector as ri, IZenZoneService as Zg, RectPopup as dC, UniverMobileUIPlugin as uC } from "@univerjs/ui";
import { forwardRef as ct, useRef as Pn, createElement as st, useState as re, useMemo as Ct, useEffect as Ee, useCallback as Hn, useLayoutEffect as hC } from "react";
import { DocSkeletonManagerService as $n, DocSelectionManagerService as Od, RichTextEditingMutation as bo, SetTextSelectionsOperation as Ko } from "@univerjs/docs";
import { IDefinedNamesService as Jo, FUNCTION_NAMES_STATISTICAL as Xe, FUNCTION_NAMES_MATH as ta, FUNCTION_NAMES_TEXT as gC, sequenceNodeType as Ha, matchToken as Gg, LexerTreeBuilder as qg, IFunctionService as Qg, SetFormulaCalculationNotificationMutation as mC, operatorToken as Zr, isReferenceStrings as Kg, isReferenceStringWithEffectiveColumn as fC, serializeRangeWithSheet as Jg, deserializeRangeWithSheet as $g, NullValueObject as Au, serializeRange as em } from "@univerjs/engine-formula";
import { jsx as _, jsxs as q, Fragment as Cr } from "react/jsx-runtime";
import { DropdownMenu as Ad, clsx as xe, borderClassName as Wi, borderBottomClassName as Hd, scrollbarClassName as na, borderRightClassName as Vd, Dropdown as kc, Button as jt, DropdownLegacy as pC, Tooltip as Gn, MessageType as tm, InputNumber as vC, Separator as SC, ColorPicker as nm, Input as Ys, RadioGroup as Nc, Radio as Kr, Select as rm, Confirm as CC, FormLayout as Zs, Avatar as kd, Switch as wC, CascaderList as _C, TimeInput as bC, Calendar as RC, borderTopClassName as im } from "@univerjs/design";
import { startWith as Va, shareReplay as Hu, switchMap as xn, map as vn, debounceTime as ra, filter as om } from "rxjs/operators";
import { ITelemetryService as IC } from "@univerjs/telemetry";
function Nd(r, e) {
if (r == null)
return;
const t = e.getRenderById(r);
if (t == null)
return;
const { mainComponent: n, scene: i, engine: o, components: s } = t, l = n, a = s.get(Wp.BACKGROUND);
return {
document: l,
docBackground: a,
scene: i,
engine: o
};
}
const Dc = [10, 400], sm = "RANGE_SELECTOR_COMPONENT_KEY", Dd = "EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY";
var Ye = /* @__PURE__ */ ((r) => (r.MAIN = "__SpreadsheetRender__", r.ROW = "__SpreadsheetRowHeader__", r.COLUMN = "__SpreadsheetColumnHeader__", r.LEFT_TOP = "__SpreadsheetLeftTopPlaceholder__", r))(Ye || {});
const Vu = 0, Gs = 1, ir = 10, yC = 11, ku = 12, ia = {
id: "sheet.command.set-row-header-width",
type: K.COMMAND,
handler: async (r, e) => {
if (!e)
return !1;
const t = r.get(Ce);
if (!t)
return !1;
const { unitId: n, subUnitId: i, size: o } = e, s = t.getRenderById(n);
if (s) {
t.getRenderById(n).with(he).setRowHeaderSize(s, i, o);
const { components: a } = s, c = a.get(Ye.ROW);
c && c.setCustomHeader({ headerStyle: { size: o } }, i);
}
return !0;
}
}, oa = {
id: "sheet.command.set-col-header-height",
type: K.COMMAND,
handler: async (r, e) => {
if (!e)
return !1;
const t = r.get(Ce);
if (!t)
return !1;
const { unitId: n, subUnitId: i, size: o } = e, s = t.getRenderById(n);
if (s) {
t.getRenderById(n).with(he).setColumnHeaderSize(s, i, o);
const { components: a } = s, c = a.get(Ye.COLUMN);
c && c.setCustomHeader({ headerStyle: { size: o } }, i);
}
return !0;
}
}, Lc = Nn("rangeMovePermissionCheck"), Wc = Nn("rangeFillPermissionCheck");
var lm = /* @__PURE__ */ ((r) => (r[r.FORMULA_EDITOR_SHOW = 100] = "FORMULA_EDITOR_SHOW", r[r.MARK_SELECTION = 1e4] = "MARK_SELECTION", r))(lm || {});
function wr(r) {
const e = r.getColorFromTheme("primary.600"), t = r.getColorFromTheme("white"), n = new fn(e).setAlpha(0.07).toRgbString();
return {
strokeWidth: 1,
stroke: e,
fill: n,
// 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: n,
rowHeaderStroke: e,
rowHeaderStrokeWidth: 1,
columnHeaderFill: n,
columnHeaderStroke: e,
columnHeaderStrokeWidth: 1,
expandCornerSize: 40
};
}
class MC {
constructor() {
b(this, "_startColumn", -1);
b(this, "_startRow", -1);
b(this, "_endColumn", -1);
b(this, "_endRow", -1);
b(this, "_startX", 0);
b(this, "_startY", 0);
b(this, "_endX", 0);
b(this, "_endY", 0);
/**
* The highlight cell of a selection. aka: current cell
*/
b(this, "_primary");
b(this, "_rangeType", z.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: n, endColumn: i, endRow: o } = this, {
startColumn: s,
startRow: l,
endColumn: a,
endRow: c
} = e;
return t === s && n === l && i === a && o === c;
}
highlightToSelection() {
if (this._primary)
return Ns(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: n,
startRow: i,
endColumn: o,
endRow: s,
startX: l,
startY: a,
endX: c,
endY: d,
rangeType: u
} = e;
this._startColumn = n, 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 Ro(r, e) {
const { startRow: t, startColumn: n, endRow: i, endColumn: o, rangeType: s } = e, l = i < t ? i : t, a = i < t ? t : i, c = o < n ? o : n, d = o < n ? n : o, u = r.getNoMergeCellWithCoordByIndex(l, c), h = r.getNoMergeCellWithCoordByIndex(a, d);
return {
startRow: t,
startColumn: n,
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 Dt(r, e) {
const { range: t, primary: n, style: i } = r, o = Ro(e, t), s = n && qs(e, n);
return {
rangeWithCoord: o,
primaryWithCoord: s,
style: i
};
}
function qs(r, e) {
const { actualRow: t, actualColumn: n, isMerged: i, isMergedMainCell: o, startRow: s, startColumn: l, endRow: a, endColumn: c } = e, d = r.getNoMergeCellWithCoordByIndex(t, n), u = r.getNoMergeCellWithCoordByIndex(s, l), h = r.getNoMergeCellWithCoordByIndex(a, c);
return {
actualRow: t,
actualColumn: n,
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 Nu = "__SpreadsheetHelperSelectionTempRect", EC = 35;
class TC {
constructor(e, t) {
b(this, "_startOffsetX", 0);
b(this, "_startOffsetY", 0);
b(this, "_relativeSelectionPositionRow", 0);
b(this, "_relativeSelectionPositionColumn", 0);
b(this, "_relativeSelectionRowLength", 0);
b(this, "_relativeSelectionColumnLength", 0);
b(this, "_scenePointerMoveSub");
b(this, "_scenePointerUpSub");
b(this, "_disabled", !1);
/**
* The shadow selection under cursor when move whole selection control(for moving normal selection)
*/
b(this, "_helperSelection");
b(this, "_scrollTimer");
b(this, "_activeViewport");
b(this, "_targetSelection", {
startY: 0,
endY: 0,
startX: 0,
endX: 0,
startRow: -1,
endRow: -1,
startColumn: -1,
endColumn: -1
});
b(this, "_isInMergeState", !1);
b(this, "_fillControlColors", []);
b(this, "_skeleton");
b(this, "_scene");
b(this, "_themeService");
b(this, "_injector");
b(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, n;
return (n = (t = bd(
O.UNIVER_SHEET,
he,
this._injector.get(N),
this._injector.get(Ce)
)) == null ? void 0 : t.getCurrentParam()) == null ? void 0 : n.skeleton.getWorksheetConfig().freeze;
}
_isSelectionInViewport(e, t) {
const n = this._getFreeze() || {
startRow: -1,
startColumn: -1
};
switch (t.viewportKey) {
case F.VIEW_MAIN:
return e.endRow >= n.startRow && e.endColumn >= n.startColumn;
case F.VIEW_MAIN_TOP:
case F.VIEW_COLUMN_RIGHT:
return e.endColumn >= n.startColumn && e.startRow < n.startRow;
case F.VIEW_MAIN_LEFT:
case F.VIEW_ROW_BOTTOM:
return e.endRow >= n.startRow && e.startColumn < n.startColumn;
case F.VIEW_MAIN_LEFT_TOP:
case F.VIEW_COLUMN_LEFT:
case F.VIEW_ROW_TOP:
case F.VIEW_LEFT_TOP:
return e.startRow < n.startRow && e.startColumn < n.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: n, bottomControl: i } = this._control;
[e, t, n, i].forEach((o) => {
o.onPointerEnter$.subscribeEvent(() => {
var l;
((l = this._injector.get(gt, wc.OPTIONAL)) == null ? void 0 : l.interceptor.fetchThroughInterceptors(Lc)(!1, null)) !== !1 && o.setCursor(ye.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 M;
const n = this._scene, i = n.getScrollXYInfoByViewport(Ne.FromArray([e, t])), { scaleX: o, scaleY: s } = n.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), g = h + this._relativeSelectionRowLength;
g > d && (g = d, g - h < this._relativeSelectionRowLength && (h = g - this._relativeSelectionRowLength));
let m = Math.max(0, c + this._relativeSelectionPositionColumn), f = m + this._relativeSelectionColumnLength;
f > u && (f = u, f - m < this._relativeSelectionColumnLength && (m = f - this._relativeSelectionColumnLength));
const v = this._skeleton.worksheet.getCellInfoInMergeData(h, m), C = Dt({
range: { startRow: h, endRow: g, startColumn: m, endColumn: f },
primary: v,
style: null
}, this._skeleton), w = this._skeleton.getNoMergeCellWithCoordByIndex(h, m), S = this._skeleton.getNoMergeCellWithCoordByIndex(g, f), I = (w == null ? void 0 : w.startY) || 0, R = (S == null ? void 0 : S.endY) || 0, y = (w == null ? void 0 : w.startX) || 0, E = (S == null ? void 0 : S.endX) || 0;
(M = this._helperSelection) == null || M.transformByState({
left: y,
top: I,
width: E - y,
height: R - I
}), this._targetSelection = { ...C.rangeWithCoord }, this._control.selectionMoving$.next(C.rangeWithCoord);
}
/**
* Drag move whole selectionControl when cursor turns to crosshair. Not for dragging 8 control points.
* @param evt
*/
_controlPointerDownHandler(e) {
const { offsetX: t, offsetY: n } = e, i = this._scene, o = i.getCoordRelativeToViewport(Ne.FromArray([t, n])), { 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: g } = u, {
startRow: m,
startColumn: f,
endRow: v,
endColumn: p
} = this._control.model;
let C = 0, w = 0;
h < m ? C -= 1 : h > v && (C += 1), g < f ? w -= 1 : g > p && (w += 1), this._relativeSelectionPositionRow = m - h + C, this._relativeSelectionPositionColumn = f - g + w, this._relativeSelectionRowLength = v - m, this._relativeSelectionColumnLength = p - f;
const S = this._control.currentStyle, I = this._getScale();
this.isHelperSelection && (this._helperSelection = new we(Nu, {
stroke: S.stroke,
strokeWidth: S.strokeWidth / I
}), i.addObject(this._helperSelection));
const R = i.getViewport(F.VIEW_MAIN), y = ti.create(i);
this._scrollTimer = y, y.startScroll(s, l, R), i.disableObjectsEvent(), this._scenePointerMoveSub = i.onPointerMove$.subscribeEvent((E) => {
var x;
if (this._disabled)
return;
const { offsetX: M, offsetY: T } = E;
if (((x = this._injector.get(gt, wc.OPTIONAL)) == null ? void 0 : x.interceptor.fetchThroughInterceptors(Lc)(!1, null)) === !1)
return;
const { x: A, y: H } = i.getCoordRelativeToViewport(
Ne.FromArray([M, T])
);
this._controlMoving(A, H), i.setCursor(ye.MOVE), y.scrolling(A, H, () => {
this._controlMoving(A, H);
});
}), this._scenePointerUpSub = i.onPointerUp$.subscribeEvent(() => {
var M, T, P, A;
(M = this._helperSelection) == null || M.dispose();
const E = this._scene;
E.resetCursor(), this._clearObserverEvent(), E.enableObjectsEvent(), (T = this._scrollTimer) == null || T.dispose(), this._control.selectionMoveEnd$.next(this._targetSelection), (A = (P = this._selectionHooks).selectionMoveEnd) == null || A.call(P);
});
}
_initialWidget() {
const {
topLeftWidget: e,
topCenterWidget: t,
topRightWidget: n,
middleLeftWidget: i,
middleRightWidget: o,
bottomLeftWidget: s,
bottomCenterWidget: l,
bottomRightWidget: a
} = this._control, c = [
ye.NORTH_WEST_RESIZE,
ye.NORTH_RESIZE,
ye.NORTH_EAST_RESIZE,
ye.WEST_RESIZE,
ye.EAST_RESIZE,
ye.SOUTH_WEST_RESIZE,
ye.SOUTH_RESIZE,
ye.SOUTH_EAST_RESIZE
];
[
e,
t,
n,
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 n = this._scene, { offsetX: i, offsetY: o } = e, s = n.getCoordRelativeToViewport(Ne.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, g = Math.min(c, u), m = Math.min(d, h), f = Math.max(c, u), v = Math.max(d, h);
this._relativeSelectionPositionRow = g, this._relativeSelectionPositionColumn = m, this._relativeSelectionRowLength = f - g, this._relativeSelectionColumnLength = v - m, t === ye.NORTH_WEST_RESIZE ? (this._relativeSelectionPositionRow = f, this._relativeSelectionPositionColumn = v) : t === ye.NORTH_RESIZE ? this._relativeSelectionPositionRow = f : t === ye.NORTH_EAST_RESIZE ? this._relativeSelectionPositionRow = f : t === ye.WEST_RESIZE ? this._relativeSelectionPositionColumn = v : t === ye.SOUTH_WEST_RESIZE ? this._relativeSelectionPositionColumn = v : t === ye.SOUTH_RESIZE && (this._relativeSelectionPositionRow = g);
const p = ti.create(n), C = n.getViewport(F.VIEW_MAIN);
p.startScroll(l, a, C), this._scrollTimer = p, n.disableObjectsEvent(), this._scenePointerMoveSub = n.onPointerMove$.subscribeEvent((w) => {
const { offsetX: S, offsetY: I } = w, { x: R, y } = n.getCoordRelativeToViewport(
Ne.FromArray([S, I])
);
this._widgetMoving(R, y, t), n.setCursor(t), p.scrolling(R, y, () => {
this._widgetMoving(R, y, t);
});
}), this._scenePointerUpSub = n.onPointerUp$.subscribeEvent(() => {
var S, I, R;
const w = this._scene;
w.resetCursor(), this._clearObserverEvent(), w.enableObjectsEvent(), (S = this._scrollTimer) == null || S.dispose(), this._control.selectionScaled$.next(this._targetSelection), (R = (I = this._selectionHooks).selectionMoveEnd) == null || R.call(I);
});
}
/**
* Pointer move Events for 8 control point.
* @param moveOffsetX
* @param moveOffsetY
* @param cursor
*/
_widgetMoving(e, t, n) {
const i = this._scene, o = i.getScrollXYInfoByViewport(Ne.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, g = c, m = d;
n === ye.NORTH_WEST_RESIZE ? (u = c, h = d, g = this._relativeSelectionPositionRow, m = this._relativeSelectionPositionColumn) : n === ye.NORTH_RESIZE ? (u = c, h = this._relativeSelectionPositionColumn, g = this._relativeSelectionPositionRow, m = this._relativeSelectionPositionColumn + this._relativeSelectionColumnLength) : n === ye.NORTH_EAST_RESIZE ? (u = c, h = this._relativeSelectionPositionColumn, g = this._relativeSelectionPositionRow, m = d) : n === ye.WEST_RESIZE ? (u = this._relativeSelectionPositionRow, h = d, g = this._relativeSelectionPositionRow + this._relativeSelectionRowLength, m = this._relativeSelectionPositionColumn) : n === ye.EAST_RESIZE ? g = this._relativeSelectionPositionRow + this._relativeSelectionRowLength : n === ye.SOUTH_WEST_RESIZE ? (u = this._relativeSelectionPositionRow, h = d, g = c, m = this._relativeSelectionPositionColumn) : n === ye.SOUTH_RESIZE && (u = this._relativeSelectionPositionRow, h = this._relativeSelectionPositionColumn, g = c, m = this._relativeSelectionPositionColumn + this._relativeSelectionColumnLength);
const f = this._swapPositions(u, h, g, m), v = this._skeleton.getCellWithMergeInfoByIndex(u, h), C = Dt({ range: f, primary: v, style: null }, this._skeleton);
this._targetSelection = { ...C.rangeWithCoord }, this._control.updateRangeBySelectionWithCoord(C), this._control.selectionScaling$.next(this._targetSelection);
}
_initialAutoFill() {
const { fillControl: e } = this._control;
e.onPointerEnter$.subscribeEvent((t) => {
this._injector.get(gt).interceptor.fetchThroughInterceptors(Wc)(!1, { x: t.offsetX, y: t.offsetY, skeleton: this._skeleton, scene: this._scene }) && e.setCursor(ye.CROSSHAIR);
}), e.onPointerLeave$.subscribeEvent(() => {
e.resetCursor();
}), e.onPointerDown$.subscribeEvent(this._autoFillForPointerdown.bind(this));
}
// eslint-disable-next-line complexity
_autoFillMoving(e, t) {
var T, P, A;
const n = this._scene, i = n.getViewportScrollXY(this._activeViewport), { scaleX: o, scaleY: s } = n.getAncestorScale(), l = this._skeleton.getCellIndexByOffset(
e,
t,
o,
s,
i
), { row: a, column: c } = l, d = n.getCoordRelativeToViewport(Ne.FromArray([e, t])), u = this._skeleton.getRowCount() - 1, h = this._skeleton.getColumnCount() - 1;
let g = this._relativeSelectionPositionRow, m = this._relativeSelectionPositionColumn, f = this._relativeSelectionPositionRow + this._relativeSelectionRowLength, v = this._relativeSelectionPositionColumn + this._relativeSelectionColumnLength, p = !1, C = !0;
if ((c < m || c > v) && a >= g && a <= f) {
const H = this._fillRuler(
c,
m,
v,
this._relativeSelectionColumnLength,
h
);
m = H.startRowOrColumn, v = H.endRowOrColumn, p = H.isLighten, C = !1;
} else if ((a < g || a > f) && c >= m && c <= v) {
const H = this._fillRuler(a, g, f, this._relativeSelectionRowLength, u);
g = H.startRowOrColumn, f = H.endRowOrColumn, p = H.isLighten;
} else if (Math.abs(this._startOffsetX - d.x - i.x) / 2 > Math.abs(this._startOffsetY - d.y - i.y)) {
const H = this._fillRuler(
c,
m,
v,
this._relativeSelectionColumnLength,
h
);
m = H.startRowOrColumn, v = H.endRowOrColumn, p = H.isLighten, C = !1;
} else {
const H = this._fillRuler(a, g, f, this._relativeSelectionRowLength, u);
g = H.startRowOrColumn, f = H.endRowOrColumn, p = H.isLighten;
}
const w = this._skeleton.getNoMergeCellWithCoordByIndex(g, m), S = this._skeleton.getNoMergeCellWithCoordByIndex(f, v), I = (w == null ? void 0 : w.startY) || 0, R = (S == null ? void 0 : S.endY) || 0, y = (w == null ? void 0 : w.startX) || 0, E = (S == null ? void 0 : S.endX) || 0;
p ? this._controlHandler((H, x) => {
const V = new fn(this._fillControlColors[x]).lighten(EC).toRgbString();
H.setProps({
fill: V
});
}) : this._controlHandler((H, x) => {
H.setProps({
fill: this._fillControlColors[x]
});
});
const M = Bs / this._getScale();
g === f && C === !0 || m === v && C === !1 ? (T = this._helperSelection) == null || T.hide() : ((P = this._helperSelection) == null || P.transformByState({
left: y - M / 2,
top: I - M / 2,
width: E - y,
height: R - I
}), (A = this._helperSelection) == null || A.show()), this._targetSelection = {
startY: I,
endY: R,
startX: y,
endX: E,
startRow: g,
endRow: f,
startColumn: m,
endColumn: v
}, this._control.selectionFilling$.next(this._targetSelection);
}
// eslint-disable-next-line max-lines-per-function
_autoFillForPointerdown(e) {
const { offsetX: t, offsetY: n } = e, i = this._scene, o = i.getCoordRelativeToViewport(Ne.FromArray([t, n])), { 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 g = h == null ? void 0 : h.stroke, m = h == null ? void 0 : h.strokeWidth;
const f = wr(this._themeService);
g == null && (g = f.stroke), m == null && (m = f.strokeWidth);
const v = this._getScale();
m /= v;
const p = Bs / v, C = new fn(g).darken(2).toRgbString();
this.isHelperSelection && (this._helperSelection = new we(Nu, {
stroke: C,
strokeWidth: m + p / 2
}), i.addObject(this._helperSelection)), this._activeViewport = i.getActiveViewportByCoord(Ne.FromArray([t, n]));
const w = i.getViewport(F.VIEW_MAIN), S = ti.create(
i,
this._activeViewport.viewportKey === F.VIEW_MAIN ? _t.ALL : _t.NONE
);
S.startScroll(s, l, w), this._scrollTimer = S, i.disableObjectsEvent(), this._controlHandler((I) => {
this._fillControlColors.push(I.fill);
}), this._scenePointerMoveSub = i.onPointerMove$.subscribeEvent((I) => {
var H;
const { offsetX: R, offsetY: y } = I, E = i.getActiveViewportByCoord(Ne.FromArray([R, y]));
if (!this._injector.get(gt).interceptor.fetchThroughInterceptors(Wc)(!1, { x: e.offsetX, y: e.offsetY, skeleton: this._skeleton, scene: this._scene }))
return;
const { x: T, y: P } = i.getCoordRelativeToViewport(
Ne.FromArray([R, y])
);
this._autoFillMoving(T, P), i.setCursor(ye.CROSSHAIR);
const A = this._targetSelection;
if (w && E && ((H = this._activeViewport) == null ? void 0 : H.viewportKey) !== (E == null ? void 0 : E.viewportKey)) {
let x;
A.startRow !== a ? (S.scrollTimerType = _t.Y, x = {
...A,
endRow: A.startRow
}) : A.endRow !== d ? (S.scrollTimerType = _t.Y, x = {
...A,
startRow: A.endRow
}) : A.startColumn !== c ? (S.scrollTimerType = _t.X, x = {
...A,
endColumn: A.startColumn
}) : (S.scrollTimerType = _t.X, x = {
...A,
startColumn: A.endColumn
}), this._isSelectionInViewport(x, E) && (this._viewportMainScrollBarNeedResetPosition(S.scrollTimerType, this._activeViewport.viewportKey, E.viewportKey) && w.scrollToBarPos({
x: S.scrollTimerType === _t.X ? 0 : void 0,
y: S.scrollTimerType === _t.Y ? 0 : void 0
}), this._activeViewport = E);
}
S.scrolling(T, P, () => {
this._autoFillMoving(T, P);
});
}), this._scenePointerUpSub = i.onPointerUp$.subscribeEvent(() => {
var R, y;
(R = this._helperSelection) == null || R.dispose();
const I = this._scene;
I.resetCursor(), this._clearObserverEvent(), I.enableObjectsEvent(), (y = this._scrollTimer) == null || y.dispose(), this._control.refreshSelectionFilled(this._targetSelection), this._isInMergeState = !1, this._controlHandler((E, M) => {
E.setProps({
fill: this._fillControlColors[M]
});
}), this._fillControlColors = [];
});
}
_viewportMainScrollBarNeedResetPosition(e, t, n) {
return e === _t.X && (t === F.VIEW_MAIN_LEFT || t === F.VIEW_MAIN_LEFT_TOP) && (n === F.VIEW_MAIN || n === F.VIEW_MAIN_TOP) || e === _t.Y && (t === F.VIEW_MAIN_TOP || t === F.VIEW_MAIN_LEFT_TOP) && (n === F.VIEW_MAIN || n === F.VIEW_MAIN_LEFT);
}
_hasMergeInRange(e, t, n, i) {
return this._skeleton.worksheet.getMergedCellRange(e, t, n, i).length > 0;
}
/**
* Make sure startRow < endRow and startColumn < endColumn
*
* @param startRow
* @param startColumn
* @param endRow
* @param endColumn
* @returns {IRange} range
*/
_swapPositions(e, t, n, i) {
const o = Math.min(e, n), s = Math.min(t, i), l = Math.max(e, n), a = Math.max(t, i);
return {
startRow: o,
startColumn: s,
endRow: l,
endColumn: a
};
}
_controlHandler(e) {
const {
leftControl: t,
rightControl: n,
topControl: i,
bottomControl: o,
backgroundControlTop: s,
backgroundControlMiddleLeft: l,
backgroundControlMiddleRight: a,
backgroundControlBottom: c,
fillControl: d
} = this._control, u = [
t,
n,
i,
o,
s,
l,
a,
c,
d
];
for (let h = 0, g = u.length; h < g; h++) {
const m = u[h];
e(m, h);
}
}
_fillRuler(e, t, n, 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 <= n)
s = !0, this._isInMergeState || (n = e);
else if (this._isInMergeState && e > n) {
const l = e - n, a = i + 1, c = Math.ceil(l / a);
let d = n + c * a;
d > o && (d = n + (c - 1) * a), n = d;
} else
n = e;
return {
rowOrColumn: e,
startRowOrColumn: t,
endRowOrColumn: n,
isLighten: s
};
}
_getScale() {
const { scaleX: e, scaleY: t } = this._scene.getAncestorScale();
return Math.max(e, t);
}
}
var Bc = /* @__PURE__ */ ((r) => (r.Selection = "__SpreadsheetSelectionShape__", r.top = "__SpreadsheetSelectionTopControl__", r.bottom = "__SpreadsheetSelectionBottomControl__", r.left = "__SpreadsheetSelectionShapeLeftControl__", r.right = "__SpreadsheetSelectionShapeRightControl__", r.backgroundTop = "__SpreadsheetSelectionBackgroundControlTop__", r.backgroundMiddleLeft = "__SpreadsheetSelectionBackgroundControlMiddleLeft__", r.backgroundMiddleRight = "__SpreadsheetSelectionBackgroundControlMiddleRight__", r.backgroundBottom = "__SpreadsheetSelectionBackgroundControlBottom__", r.fill = "__SpreadsheetSelectionFillControl__", r.fillTopLeft = "__SpreadsheetSelectionFillControlTopLeft__", r.fillBottomRight = "__SpreadsheetSelectionFillControlBottomRight__", r.fillTopLeftInner = "__SpreadsheetSelectionFillControlTopLeftInner__", r.fillBottomRightInner = "__SpreadsheetSelectionFillControlBottomRightInner__", r.lineMain = "__SpreadsheetDragLineMainControl__", r.lineContent = "__SpreadsheetDragLineContentControl__", r.line = "__SpreadsheetDragLineControl__", r.dash = "__SpreadsheetDragDashControl__", r.rowHeaderBackground = "__SpreadSheetSelectionRowHeaderBackground__", r.rowHeaderBorder = "__SpreadSheetSelectionRowHeaderBorder__", r.rowHeaderGroup = "__SpreadSheetSelectionRowHeaderGroup__", r.columnHeaderBackground = "__SpreadSheetSelectionColumnHeaderBackground__", r.columnHeaderBorder = "__SpreadSheetSelectionColumnHeaderBorder__", r.columnHeaderGroup = "__SpreadSheetSelectionColumnHeaderGroup__", r.topLeftWidget = "__SpreadSheetSelectionTopLeftWidget__", r.topCenterWidget = "__SpreadSheetSelectionTopCenterWidget__", r.topRightWidget = "__SpreadSheetSelectionTopRightWidget__", r.middleLeftWidget = "__SpreadSheetSelectionMiddleLeftWidget__", r.middleRightWidget = "__SpreadSheetSelectionMiddleRightWidget__", r.bottomLeftWidget = "__SpreadSheetSelectionBottomLeftWidget__", r.bottomCenterWidget = "__SpreadSheetSelectionBottomCenterWidget__", r.bottomRightWidget = "__SpreadSheetSelectionBottomRightWidget__", r))(Bc || {});
const Du = 0.3;
class Ld extends se {
constructor(t, n, i, o) {
var s, l, a, c;
super();
b(this, "_isHelperSelection", !0);
/**
* For ref selections, there is no auto fill.
*/
b(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.
*/
b(this, "_showAutoFill", !1);
/**
* If rowHeader & col Header would be highlighted with selection.
*/
b(this, "_highlightHeader", !0);
b(this, "_selectionRenderModel");
b(this, "_leftBorder");
b(this, "_rightBorder");
b(this, "_topBorder");
b(this, "_bottomBorder");
b(this, "_backgroundControlTop");
b(this, "_backgroundControlBottom");
b(this, "_backgroundControlMiddleLeft");
b(this, "_backgroundControlMiddleRight");
b(this, "_autoFillControl");
b(this, "_selectionShapeGroup");
b(this, "_rowHeaderBackground");
b(this, "_rowHeaderBorder");
b(this, "_rowHeaderGroup");
b(this, "_columnHeaderBackground");
b(this, "_columnHeaderBorder");
b(this, "_columnHeaderGroup");
b(this, "_dashedRect");
// for ref selection
b(this, "_topLeftWidget");
b(this, "_topCenterWidget");
b(this, "_topRightWidget");
b(this, "_middleLeftWidget");
b(this, "_middleRightWidget");
b(this, "_bottomLeftWidget");
b(this, "_bottomCenterWidget");
b(this, "_bottomRightWidget");
// why three style prop? what's diff between _selectionStyle & _currentStyle?
// protected _selectionStyle: Nullable<ISelectionStyle>;
b(this, "_defaultStyle");
b(this, "_currentStyle");
b(this, "_rowHeaderWidth", 0);
b(this, "_columnHeaderHeight", 0);
b(this, "_widgetRects", []);
b(this, "_controlExtension");
b(this, "_dispose$", new Me(this));
b(this, "dispose$", this._dispose$.asObservable());
/**
* eventSource: selectionShapeExtension selectionMoving$.next,
* Observer: prompt.controller
*/
b(this, "selectionMoving$", new Ae());
b(this, "selectionMoveEnd$", new Ae());
b(this, "selectionScaling$", new Ae());
b(this, "selectionScaled$", new Ae());
b(this, "selectionFilling$", new Ae());
b(this, "_selectionFilled$", new Ae());
b(this, "selectionFilled$", this._selectionFilled$.asObservable());
b(this, "_antLineOffset", 0);
b(this, "_antRequestNewFrame", -1);
this._scene = t, this._zIndex = n, 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 = wr(this._themeService), this._currentStyle = wr(this._themeService), this._selectionRenderModel = new MC();
const t = this._zIndex;
this._leftBorder = new we("__SpreadsheetSelectionShapeLeftControl__" + t, {
zIndex: t
}), this._rightBorder = new we("__SpreadsheetSelectionShapeRightControl__" + t, {
zIndex: t
}), this._topBorder = new we("__SpreadsheetSelectionTopControl__" + t, {
zIndex: t
}), this._bottomBorder = new we("__SpreadsheetSelectionBottomControl__" + t, {
zIndex: t
}), this._backgroundControlTop = new we("__SpreadsheetSelectionBackgroundControlTop__" + t, {
zIndex: t - 1,
evented: !1
}), this._backgroundControlBottom = new we("__SpreadsheetSelectionBackgroundControlBottom__" + t, {
zIndex: t - 1,
evented: !1
}), this._backgroundControlMiddleLeft = new we("__SpreadsheetSelectionBackgroundControlMiddleLeft__" + t, {
zIndex: t - 1,
evented: !1
}), this._backgroundControlMiddleRight = new we("__SpreadsheetSelectionBackgroundControlMiddleRight__" + t, {
zIndex: t - 1,
evented: !1
}), this._autoFillControl = new we("__SpreadsheetSelectionFillControl__" + t, {
zIndex: t + 1
}), this._autoFillControl.hide(), this._dashedRect = new yS("__SpreadsheetDragDashControl__" + t, {
zIndex: t + 2,
evented: !1,
stroke: "#fff"
});
const n = [
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 Aa("__SpreadsheetSelectionShape__" + t, ...n, ...this._widgetRects), this._selectionShapeGroup.hide(), this._selectionShapeGroup.evented = !1, this._selectionShapeGroup.zIndex = t;
const i = this.getScene();
i.addObject(this._selectionShapeGroup, Gs), this.disposeWithMe(
We(
i.onTransformChange$.subscribeEvent((o) => {
o.type === Vc.scale && (this._updateLayoutOfSelectionControl(this._currentStyle), this._updateControlCoord());
})
)
);
}
_initialHeader() {
const t = this._zIndex;
this._rowHeaderBackground = new we("__SpreadSheetSelectionRowHeaderBackground__" + t, {
zIndex: t - 1,
evented: !1
}), this._rowHeaderBorder = new we("__SpreadSheetSelectionRowHeaderBorder__" + t, {
zIndex: t - 1,
evented: !1
}), this._rowHeaderGroup = new Aa(
"__SpreadSheetSelectionRowHeaderGroup__" + t,
this._rowHeaderBackground,
this._rowHeaderBorder
), this._rowHeaderGroup.hide(), this._rowHeaderGroup.evented = !1, this._rowHeaderGroup.zIndex = t, this._columnHeaderBackground = new we("__SpreadSheetSelectionColumnHeaderBackground__" + t, {
zIndex: t - 1,
evented: !1
}), this._columnHeaderBorder = new we("__SpreadSheetSelectionColumnHeaderBorder__" +