@univerjs/sheets-hyper-link 0.4.2 → 0.5.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -1,507 +1,1209 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { Disposable, ObjectMatrix, UniverInstanceType, IUniverInstanceService, CommandType, Inject, ICommandService, sequenceExecuteAsync, isValidRange, toDisposable, IResourceManagerService, DependentOn, Injector, Plugin, IConfigService } from "@univerjs/core";
6
- import { Subject } from "rxjs";
7
- import { RefRangeService, SheetsSelectionsService, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests, handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests, UniverSheetsPlugin } from "@univerjs/sheets";
8
- import { deserializeRangeWithSheet, serializeRange } from "@univerjs/engine-formula";
9
- var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
10
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
11
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
12
- return kind && result && __defProp$4(target, key, result), result;
13
- }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a;
14
- let HyperLinkModel = (_a = class extends Disposable {
15
- constructor(_univerInstanceService) {
1
+ var xe = Object.defineProperty;
2
+ var Te = (s, e, t) => e in s ? xe(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var C = (s, e, t) => Te(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { Disposable as V, ObjectMatrix as J, UniverInstanceType as R, IUniverInstanceService as E, CommandType as L, Inject as I, ICommandService as b, sequenceExecuteAsync as ye, isValidRange as ve, toDisposable as Ae, CustomRangeType as N, DisposableCollection as We, Range as Be, Tools as ie, BuildTextUtils as X, generateRandomId as ae, TextX as oe, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as je, IUndoRedoService as Se, CellValueType as Re, sequenceExecute as Fe, getBodySlice as be, IResourceManagerService as Ke, LocaleService as Ge, DependentOn as Ye, Injector as ze, Plugin as Je, registerDependencies as Xe, touchDependencies as qe, IConfigService as Ze } from "@univerjs/core";
5
+ import { Subject as Qe } from "rxjs";
6
+ import { RefRangeService as Pe, SheetsSelectionsService as Ne, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as et, handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests as tt, SheetInterceptorService as de, RemoveSheetCommand as nt, SetRangeValuesMutation as H, SetRangeValuesCommand as rt, ClearSelectionContentCommand as st, ClearSelectionAllCommand as it, ClearSelectionFormatCommand as at, getSheetCommandTarget as ce, AFTER_CELL_EDIT as ot, SetRangeValuesUndoMutationFactory as Ie, UniverSheetsPlugin as dt } from "@univerjs/sheets";
7
+ import { deserializeRangeWithSheet as Me, serializeRange as B, serializeRangeWithSheet as ct, IDefinedNamesService as lt } from "@univerjs/engine-formula";
8
+ import { addCustomRangeBySelectionFactory as ut, deleteCustomRangeFactory as pt, replaceSelectionFactory as Oe } from "@univerjs/docs";
9
+ var ht = Object.defineProperty, gt = Object.getOwnPropertyDescriptor, ft = (s, e, t, n) => {
10
+ for (var r = n > 1 ? void 0 : n ? gt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
11
+ (a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
12
+ return n && r && ht(e, t, r), r;
13
+ }, _t = (s, e) => (t, n) => e(t, n, s);
14
+ let v = class extends V {
15
+ constructor(e) {
16
16
  super();
17
- __publicField(this, "_linkUpdate$", new Subject());
18
- __publicField(this, "linkUpdate$", this._linkUpdate$.asObservable());
19
- __publicField(this, "_linkMap", /* @__PURE__ */ new Map());
20
- __publicField(this, "_linkPositionMap", /* @__PURE__ */ new Map());
21
- this._univerInstanceService = _univerInstanceService, this.disposeWithMe({
22
- dispose: /* @__PURE__ */ __name(() => {
17
+ C(this, "_linkUpdate$", new Qe());
18
+ C(this, "linkUpdate$", this._linkUpdate$.asObservable());
19
+ C(this, "_linkMap", /* @__PURE__ */ new Map());
20
+ C(this, "_linkPositionMap", /* @__PURE__ */ new Map());
21
+ this._univerInstanceService = e, this.disposeWithMe({
22
+ dispose: () => {
23
23
  this._linkUpdate$.complete();
24
- }, "dispose")
24
+ }
25
25
  });
26
26
  }
27
- _ensureMap(unitId, subUnitId) {
28
- let unitMap = this._linkMap.get(unitId);
29
- unitMap || (unitMap = /* @__PURE__ */ new Map(), this._linkMap.set(unitId, unitMap));
30
- let matrix = unitMap.get(subUnitId);
31
- matrix || (matrix = new ObjectMatrix(), unitMap.set(subUnitId, matrix));
32
- let positionUnitMap = this._linkPositionMap.get(unitId);
33
- positionUnitMap || (positionUnitMap = /* @__PURE__ */ new Map(), this._linkPositionMap.set(unitId, positionUnitMap));
34
- let positionSubUnitMap = positionUnitMap.get(subUnitId);
35
- return positionSubUnitMap || (positionSubUnitMap = /* @__PURE__ */ new Map(), positionUnitMap.set(subUnitId, positionSubUnitMap)), {
36
- matrix,
37
- positionMap: positionSubUnitMap
27
+ _ensureMap(e, t) {
28
+ let n = this._linkMap.get(e);
29
+ n || (n = /* @__PURE__ */ new Map(), this._linkMap.set(e, n));
30
+ let r = n.get(t);
31
+ r || (r = new J(), n.set(t, r));
32
+ let i = this._linkPositionMap.get(e);
33
+ i || (i = /* @__PURE__ */ new Map(), this._linkPositionMap.set(e, i));
34
+ let a = i.get(t);
35
+ return a || (a = /* @__PURE__ */ new Map(), i.set(t, a)), {
36
+ matrix: r,
37
+ positionMap: a
38
38
  };
39
39
  }
40
- addHyperLink(unitId, subUnitId, link) {
41
- const { matrix, positionMap } = this._ensureMap(unitId, subUnitId);
42
- return matrix.setValue(link.row, link.column, link), positionMap.set(link.id, { row: link.row, column: link.column, link }), this._linkUpdate$.next({
43
- unitId,
44
- subUnitId,
45
- payload: link,
40
+ addHyperLink(e, t, n) {
41
+ const { matrix: r, positionMap: i } = this._ensureMap(e, t);
42
+ return r.setValue(n.row, n.column, n), i.set(n.id, { row: n.row, column: n.column, link: n }), this._linkUpdate$.next({
43
+ unitId: e,
44
+ subUnitId: t,
45
+ payload: n,
46
46
  type: "add"
47
47
  }), !0;
48
48
  }
49
- updateHyperLink(unitId, subUnitId, id, payload, silent = !1) {
50
- const { matrix, positionMap } = this._ensureMap(unitId, subUnitId), position = positionMap.get(id);
51
- if (!position)
49
+ updateHyperLink(e, t, n, r, i = !1) {
50
+ const { matrix: a, positionMap: o } = this._ensureMap(e, t), c = o.get(n);
51
+ if (!c)
52
52
  return !0;
53
- const link = matrix.getValue(position.row, position.column);
54
- return link && (Object.assign(link, payload), this._linkUpdate$.next({
55
- unitId,
56
- subUnitId,
53
+ const d = a.getValue(c.row, c.column);
54
+ return d && (Object.assign(d, r), this._linkUpdate$.next({
55
+ unitId: e,
56
+ subUnitId: t,
57
57
  payload: {
58
- display: link.display,
59
- payload: link.payload
58
+ display: d.display,
59
+ payload: d.payload
60
60
  },
61
- id,
61
+ id: n,
62
62
  type: "update",
63
- silent
63
+ silent: i
64
64
  })), !0;
65
65
  }
66
- updateHyperLinkRef(unitId, subUnitId, id, payload, silent = !1) {
67
- const { matrix, positionMap } = this._ensureMap(unitId, subUnitId), position = positionMap.get(id);
68
- if (!position)
66
+ updateHyperLinkRef(e, t, n, r, i = !1) {
67
+ const { matrix: a, positionMap: o } = this._ensureMap(e, t), c = o.get(n);
68
+ if (!c)
69
69
  return !0;
70
- let link = matrix.getValue(position.row, position.column);
71
- return !link || link.id !== id ? link = position.link : matrix.realDeleteValue(position.row, position.column), Object.assign(link, payload), positionMap.set(id, { ...payload, link }), matrix.setValue(payload.row, payload.column, link), this._linkUpdate$.next({
72
- unitId,
73
- subUnitId,
74
- payload,
75
- id,
70
+ let d = a.getValue(c.row, c.column);
71
+ return !d || d.id !== n ? d = c.link : a.realDeleteValue(c.row, c.column), Object.assign(d, r), o.set(n, { ...r, link: d }), a.setValue(r.row, r.column, d), this._linkUpdate$.next({
72
+ unitId: e,
73
+ subUnitId: t,
74
+ payload: r,
75
+ id: n,
76
76
  type: "updateRef",
77
- silent
77
+ silent: i
78
78
  }), !0;
79
79
  }
80
- removeHyperLink(unitId, subUnitId, id) {
81
- const { matrix, positionMap } = this._ensureMap(unitId, subUnitId), position = positionMap.get(id);
82
- if (!position)
80
+ removeHyperLink(e, t, n) {
81
+ const { matrix: r, positionMap: i } = this._ensureMap(e, t), a = i.get(n);
82
+ if (!a)
83
83
  return !1;
84
- positionMap.delete(id);
85
- const link = matrix.getValue(position.row, position.column);
86
- return link && link.id === id && matrix.realDeleteValue(position.row, position.column), this._linkUpdate$.next({
87
- unitId,
88
- subUnitId,
89
- payload: position.link,
84
+ i.delete(n);
85
+ const o = r.getValue(a.row, a.column);
86
+ return o && o.id === n && r.realDeleteValue(a.row, a.column), this._linkUpdate$.next({
87
+ unitId: e,
88
+ subUnitId: t,
89
+ payload: a.link,
90
90
  type: "remove"
91
91
  }), !0;
92
92
  }
93
- getHyperLink(unitId, subUnitId, id) {
94
- const { matrix, positionMap } = this._ensureMap(unitId, subUnitId), position = positionMap.get(id);
95
- if (position)
96
- return matrix.getValue(position.row, position.column);
93
+ getHyperLink(e, t, n) {
94
+ const { matrix: r, positionMap: i } = this._ensureMap(e, t), a = i.get(n);
95
+ if (a)
96
+ return r.getValue(a.row, a.column);
97
97
  }
98
- getHyperLinkByLocation(unitId, subUnitId, row, column) {
99
- const { matrix } = this._ensureMap(unitId, subUnitId);
100
- return matrix.getValue(row, column);
98
+ getHyperLinkByLocation(e, t, n, r) {
99
+ const { matrix: i } = this._ensureMap(e, t);
100
+ return i.getValue(n, r);
101
101
  }
102
- getHyperLinkByLocationSync(unitId, subUnitId, row, column) {
103
- var _a6, _b, _c, _d, _e;
104
- const { matrix } = this._ensureMap(unitId, subUnitId), workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET), cell = (_a6 = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId)) == null ? void 0 : _a6.getCellRaw(row, column), cellValueStr = ((_e = (_d = cell == null ? void 0 : cell.v) != null ? _d : (_c = (_b = cell == null ? void 0 : cell.p) == null ? void 0 : _b.body) == null ? void 0 : _c.dataStream.slice(0, -2)) != null ? _e : "").toString(), link = matrix.getValue(row, column);
105
- if (link)
102
+ getHyperLinkByLocationSync(e, t, n, r) {
103
+ var l, p, h, g, u;
104
+ const { matrix: i } = this._ensureMap(e, t), a = this._univerInstanceService.getUnit(e, R.UNIVER_SHEET), o = (l = a == null ? void 0 : a.getSheetBySheetId(t)) == null ? void 0 : l.getCellRaw(n, r), c = ((u = (g = o == null ? void 0 : o.v) != null ? g : (h = (p = o == null ? void 0 : o.p) == null ? void 0 : p.body) == null ? void 0 : h.dataStream.slice(0, -2)) != null ? u : "").toString(), d = i.getValue(n, r);
105
+ if (d)
106
106
  return {
107
- ...link,
108
- display: cellValueStr
107
+ ...d,
108
+ display: c
109
109
  };
110
110
  }
111
- getSubUnit(unitId, subUnitId) {
112
- const { matrix } = this._ensureMap(unitId, subUnitId), links = [];
113
- return matrix.forValue((row, col, value) => {
114
- value && links.push(value);
115
- }), links;
111
+ getSubUnit(e, t) {
112
+ const { matrix: n } = this._ensureMap(e, t), r = [];
113
+ return n.forValue((i, a, o) => {
114
+ o && r.push(o);
115
+ }), r;
116
116
  }
117
- getUnit(unitId) {
118
- const unitMap = this._linkMap.get(unitId);
119
- return unitMap ? Array.from(unitMap.keys()).map((subUnitId) => {
120
- const links = this.getSubUnit(unitId, subUnitId);
117
+ getUnit(e) {
118
+ const t = this._linkMap.get(e);
119
+ return t ? Array.from(t.keys()).map((n) => {
120
+ const r = this.getSubUnit(e, n);
121
121
  return {
122
- unitId,
123
- subUnitId,
124
- links
122
+ unitId: e,
123
+ subUnitId: n,
124
+ links: r
125
125
  };
126
126
  }) : [];
127
127
  }
128
- deleteUnit(unitId) {
129
- const links = this.getUnit(unitId);
130
- this._linkMap.delete(unitId), this._linkPositionMap.delete(unitId), this._linkUpdate$.next({
128
+ deleteUnit(e) {
129
+ const t = this.getUnit(e);
130
+ this._linkMap.delete(e), this._linkPositionMap.delete(e), this._linkUpdate$.next({
131
131
  type: "unload",
132
- unitId,
133
- unitLinks: links
132
+ unitId: e,
133
+ unitLinks: t
134
134
  });
135
135
  }
136
136
  getAll() {
137
- return Array.from(this._linkMap.keys()).map((unitId) => this.getUnit(unitId));
138
- }
139
- }, __name(_a, "HyperLinkModel"), _a);
140
- HyperLinkModel = __decorateClass$4([
141
- __decorateParam$4(0, IUniverInstanceService)
142
- ], HyperLinkModel);
143
- var SheetHyperLinkType = /* @__PURE__ */ ((SheetHyperLinkType2) => (SheetHyperLinkType2.SHEET = "gid", SheetHyperLinkType2.RANGE = "range", SheetHyperLinkType2.DEFINE_NAME = "rangeid", SheetHyperLinkType2.INVALID = "invalid", SheetHyperLinkType2.URL = "url", SheetHyperLinkType2))(SheetHyperLinkType || {});
144
- const PLUGIN_CONFIG_KEY = "sheets-hyper-link.config", defaultPluginConfig = {}, AddHyperLinkMutation = {
145
- type: CommandType.MUTATION,
137
+ return Array.from(this._linkMap.keys()).map((t) => this.getUnit(t));
138
+ }
139
+ };
140
+ v = ft([
141
+ _t(0, E)
142
+ ], v);
143
+ var U = /* @__PURE__ */ ((s) => (s.SHEET = "gid", s.RANGE = "range", s.DEFINE_NAME = "rangeid", s.INVALID = "invalid", s.URL = "url", s))(U || {});
144
+ const mt = "sheets-hyper-link.config", yt = {}, O = {
145
+ type: L.MUTATION,
146
146
  id: "sheets.mutation.add-hyper-link",
147
- handler(accessor, params) {
148
- if (!params)
147
+ handler(s, e) {
148
+ if (!e)
149
149
  return !1;
150
- const model = accessor.get(HyperLinkModel), { unitId, subUnitId, link } = params;
151
- return model.addHyperLink(unitId, subUnitId, link);
150
+ const t = s.get(v), { unitId: n, subUnitId: r, link: i } = e;
151
+ return t.addHyperLink(n, r, i);
152
152
  }
153
- }, RemoveHyperLinkMutation = {
154
- type: CommandType.MUTATION,
153
+ }, k = {
154
+ type: L.MUTATION,
155
155
  id: "sheets.mutation.remove-hyper-link",
156
- handler(accessor, params) {
157
- if (!params)
156
+ handler(s, e) {
157
+ if (!e)
158
158
  return !1;
159
- const model = accessor.get(HyperLinkModel), { unitId, subUnitId, id } = params;
160
- return model.removeHyperLink(unitId, subUnitId, id);
159
+ const t = s.get(v), { unitId: n, subUnitId: r, id: i } = e;
160
+ return t.removeHyperLink(n, r, i);
161
161
  }
162
- }, UpdateHyperLinkMutation = {
163
- type: CommandType.MUTATION,
162
+ }, fe = {
163
+ type: L.MUTATION,
164
164
  id: "sheets.mutation.update-hyper-link",
165
- handler(accessor, params) {
166
- if (!params)
165
+ handler(s, e) {
166
+ if (!e)
167
167
  return !1;
168
- const model = accessor.get(HyperLinkModel), { unitId, subUnitId, payload, id } = params;
169
- return model.updateHyperLink(unitId, subUnitId, id, payload, !1);
168
+ const t = s.get(v), { unitId: n, subUnitId: r, payload: i, id: a } = e;
169
+ return t.updateHyperLink(n, r, a, i, !1);
170
170
  }
171
- }, UpdateHyperLinkRefMutation = {
172
- type: CommandType.MUTATION,
171
+ }, _e = {
172
+ type: L.MUTATION,
173
173
  id: "sheets.mutation.update-hyper-link-ref",
174
- handler(accessor, params) {
175
- if (!params)
174
+ handler(s, e) {
175
+ if (!e)
176
176
  return !1;
177
- const model = accessor.get(HyperLinkModel), { unitId, subUnitId, id, row, column, silent } = params;
178
- return model.updateHyperLinkRef(unitId, subUnitId, id, { row, column }, silent);
179
- }
180
- }, SHEET_HYPER_LINK_PLUGIN = "SHEET_HYPER_LINK_PLUGIN", ERROR_RANGE = "err";
181
- var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
182
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
183
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
184
- return kind && result && __defProp$3(target, key, result), result;
185
- }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a2;
186
- let SheetsHyperLinkRefRangeController = (_a2 = class extends Disposable {
187
- constructor(_refRangeService, _hyperLinkModel, _selectionManagerService, _commandService) {
177
+ const t = s.get(v), { unitId: n, subUnitId: r, id: i, row: a, column: o, silent: c } = e;
178
+ return t.updateHyperLinkRef(n, r, i, { row: a, column: o }, c);
179
+ }
180
+ }, ke = "SHEET_HYPER_LINK_PLUGIN", q = "err";
181
+ var vt = Object.defineProperty, St = Object.getOwnPropertyDescriptor, Rt = (s, e, t, n) => {
182
+ for (var r = n > 1 ? void 0 : n ? St(e, t) : e, i = s.length - 1, a; i >= 0; i--)
183
+ (a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
184
+ return n && r && vt(e, t, r), r;
185
+ }, Y = (s, e) => (t, n) => e(t, n, s);
186
+ let Z = class extends V {
187
+ constructor(e, t, n, r) {
188
188
  super();
189
- __publicField(this, "_disposableMap", /* @__PURE__ */ new Map());
190
- __publicField(this, "_watchDisposableMap", /* @__PURE__ */ new Map());
191
- __publicField(this, "_rangeDisableMap", /* @__PURE__ */ new Map());
192
- __publicField(this, "_rangeWatcherMap", /* @__PURE__ */ new Map());
193
- __publicField(this, "_handlePositionChange", /* @__PURE__ */ __name((unitId, subUnitId, link, resultRange, silent) => {
194
- const oldRange = {
195
- startColumn: link.column,
196
- endColumn: link.column,
197
- startRow: link.row,
198
- endRow: link.row
189
+ C(this, "_disposableMap", /* @__PURE__ */ new Map());
190
+ C(this, "_watchDisposableMap", /* @__PURE__ */ new Map());
191
+ C(this, "_rangeDisableMap", /* @__PURE__ */ new Map());
192
+ C(this, "_rangeWatcherMap", /* @__PURE__ */ new Map());
193
+ C(this, "_handlePositionChange", (e, t, n, r, i) => {
194
+ const a = {
195
+ startColumn: n.column,
196
+ endColumn: n.column,
197
+ startRow: n.row,
198
+ endRow: n.row
199
199
  };
200
- return resultRange ? {
200
+ return r ? {
201
201
  redos: [{
202
- id: UpdateHyperLinkRefMutation.id,
202
+ id: _e.id,
203
203
  params: {
204
- unitId,
205
- subUnitId,
206
- id: link.id,
207
- row: resultRange.startRow,
208
- column: resultRange.startColumn,
209
- silent
204
+ unitId: e,
205
+ subUnitId: t,
206
+ id: n.id,
207
+ row: r.startRow,
208
+ column: r.startColumn,
209
+ silent: i
210
210
  }
211
211
  }],
212
212
  undos: [{
213
- id: UpdateHyperLinkRefMutation.id,
213
+ id: _e.id,
214
214
  params: {
215
- unitId,
216
- subUnitId,
217
- id: link.id,
218
- row: oldRange.startRow,
219
- column: oldRange.startColumn,
220
- silent
215
+ unitId: e,
216
+ subUnitId: t,
217
+ id: n.id,
218
+ row: a.startRow,
219
+ column: a.startColumn,
220
+ silent: i
221
221
  }
222
222
  }]
223
223
  } : {
224
224
  redos: [{
225
- id: RemoveHyperLinkMutation.id,
225
+ id: k.id,
226
226
  params: {
227
- unitId,
228
- subUnitId,
229
- id: link.id
227
+ unitId: e,
228
+ subUnitId: t,
229
+ id: n.id
230
230
  }
231
231
  }],
232
232
  undos: [{
233
- id: AddHyperLinkMutation.id,
233
+ id: O.id,
234
234
  params: {
235
- unitId,
236
- subUnitId,
237
- link
235
+ unitId: e,
236
+ subUnitId: t,
237
+ link: n
238
238
  }
239
239
  }]
240
240
  };
241
- }, "_handlePositionChange"));
242
- this._refRangeService = _refRangeService, this._hyperLinkModel = _hyperLinkModel, this._selectionManagerService = _selectionManagerService, this._commandService = _commandService, this._initData(), this._initRefRange();
243
- }
244
- _registerPosition(unitId, subUnitId, link) {
245
- const id = link.id, oldRange = {
246
- startColumn: link.column,
247
- endColumn: link.column,
248
- startRow: link.row,
249
- endRow: link.row
250
- }, handleRefRangeChange = /* @__PURE__ */ __name((commandInfo) => {
251
- const resultRanges = handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(oldRange, commandInfo, { selectionManagerService: this._selectionManagerService }), resultRange = Array.isArray(resultRanges) ? resultRanges[0] : resultRanges;
252
- return resultRange && resultRange.startColumn === oldRange.startColumn && resultRange.startRow === oldRange.startRow ? {
241
+ });
242
+ this._refRangeService = e, this._hyperLinkModel = t, this._selectionManagerService = n, this._commandService = r, this._initData(), this._initRefRange();
243
+ }
244
+ _registerPosition(e, t, n) {
245
+ const r = n.id, i = {
246
+ startColumn: n.column,
247
+ endColumn: n.column,
248
+ startRow: n.row,
249
+ endRow: n.row
250
+ }, a = (o) => {
251
+ const c = et(i, o, { selectionManagerService: this._selectionManagerService }), d = Array.isArray(c) ? c[0] : c;
252
+ return d && d.startColumn === i.startColumn && d.startRow === i.startRow ? {
253
253
  undos: [],
254
254
  redos: []
255
- } : this._handlePositionChange(unitId, subUnitId, link, resultRange, !1);
256
- }, "handleRefRangeChange");
257
- this._disposableMap.set(id, this._refRangeService.registerRefRange(oldRange, handleRefRangeChange, unitId, subUnitId));
258
- }
259
- _watchPosition(unitId, subUnitId, link) {
260
- const id = link.id, oldRange = {
261
- startColumn: link.column,
262
- endColumn: link.column,
263
- startRow: link.row,
264
- endRow: link.row
255
+ } : this._handlePositionChange(e, t, n, d, !1);
256
+ };
257
+ this._disposableMap.set(r, this._refRangeService.registerRefRange(i, a, e, t));
258
+ }
259
+ _watchPosition(e, t, n) {
260
+ const r = n.id, i = {
261
+ startColumn: n.column,
262
+ endColumn: n.column,
263
+ startRow: n.row,
264
+ endRow: n.row
265
265
  };
266
266
  this._watchDisposableMap.set(
267
- id,
268
- this._refRangeService.watchRange(unitId, subUnitId, oldRange, (before, after) => {
269
- const { redos } = this._handlePositionChange(unitId, subUnitId, link, after, !0);
270
- sequenceExecuteAsync(redos, this._commandService, { onlyLocal: !0 });
267
+ r,
268
+ this._refRangeService.watchRange(e, t, i, (a, o) => {
269
+ const { redos: c } = this._handlePositionChange(e, t, n, o, !0);
270
+ ye(c, this._commandService, { onlyLocal: !0 });
271
271
  }, !0)
272
272
  );
273
273
  }
274
- _unregisterPosition(id) {
275
- const disposable = this._disposableMap.get(id);
276
- disposable == null || disposable.dispose(), this._disposableMap.delete(id);
277
- }
278
- _unwatchPosition(id) {
279
- const disposable = this._watchDisposableMap.get(id);
280
- disposable == null || disposable.dispose(), this._watchDisposableMap.delete(id);
281
- }
282
- _registerRange(unitId, id, payload, silent = !1) {
283
- var _a6, _b, _c;
284
- if (payload.startsWith("#")) {
285
- const search = new URLSearchParams(payload.slice(1)), searchObj = {
286
- gid: (_a6 = search.get("gid")) != null ? _a6 : "",
287
- range: (_b = search.get("range")) != null ? _b : "",
288
- rangeid: (_c = search.get("rangeid")) != null ? _c : ""
274
+ _unregisterPosition(e) {
275
+ const t = this._disposableMap.get(e);
276
+ t == null || t.dispose(), this._disposableMap.delete(e);
277
+ }
278
+ _unwatchPosition(e) {
279
+ const t = this._watchDisposableMap.get(e);
280
+ t == null || t.dispose(), this._watchDisposableMap.delete(e);
281
+ }
282
+ _registerRange(e, t, n, r = !1) {
283
+ var i, a, o;
284
+ if (n.startsWith("#")) {
285
+ const c = new URLSearchParams(n.slice(1)), d = {
286
+ gid: (i = c.get("gid")) != null ? i : "",
287
+ range: (a = c.get("range")) != null ? a : "",
288
+ rangeid: (o = c.get("rangeid")) != null ? o : ""
289
289
  };
290
- if (searchObj.range && searchObj.gid) {
291
- const subUnitId = searchObj.gid, range = deserializeRangeWithSheet(searchObj.range).range;
292
- if (isValidRange(range) && searchObj.range !== ERROR_RANGE) {
293
- const handleRangeChange = /* @__PURE__ */ __name((commandInfo) => {
294
- const resultRange = handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(range, commandInfo, { selectionManagerService: this._selectionManagerService });
295
- return resultRange && serializeRange(resultRange) === serializeRange(range) ? {
290
+ if (d.range && d.gid) {
291
+ const l = d.gid, p = Me(d.range).range;
292
+ if (ve(p) && d.range !== q) {
293
+ const h = (g) => {
294
+ const u = tt(p, g, { selectionManagerService: this._selectionManagerService });
295
+ return u && B(u) === B(p) ? {
296
296
  redos: [],
297
297
  undos: []
298
298
  } : {
299
299
  redos: [{
300
- id: UpdateHyperLinkMutation.id,
300
+ id: fe.id,
301
301
  params: {
302
- unitId,
303
- subUnitId,
304
- id,
302
+ unitId: e,
303
+ subUnitId: l,
304
+ id: t,
305
305
  payload: {
306
- payload: `#gid=${subUnitId}&range=${resultRange ? serializeRange(resultRange) : "err"}`
306
+ payload: `#gid=${l}&range=${u ? B(u) : "err"}`
307
307
  }
308
308
  }
309
309
  }],
310
310
  undos: [{
311
- id: UpdateHyperLinkMutation.id,
311
+ id: fe.id,
312
312
  params: {
313
- unitId,
314
- subUnitId,
315
- id,
313
+ unitId: e,
314
+ subUnitId: l,
315
+ id: t,
316
316
  payload: {
317
- payload
317
+ payload: n
318
318
  }
319
319
  }
320
320
  }]
321
321
  };
322
- }, "handleRangeChange");
323
- this._rangeDisableMap.set(id, this._refRangeService.registerRefRange(range, handleRangeChange, unitId, subUnitId)), silent || this._rangeWatcherMap.set(id, this._refRangeService.watchRange(unitId, subUnitId, range, (before, after) => {
324
- this._hyperLinkModel.updateHyperLink(unitId, subUnitId, id, {
325
- payload: `#gid=${subUnitId}&range=${after ? serializeRange(after) : "err"}`
322
+ };
323
+ this._rangeDisableMap.set(t, this._refRangeService.registerRefRange(p, h, e, l)), r || this._rangeWatcherMap.set(t, this._refRangeService.watchRange(e, l, p, (g, u) => {
324
+ this._hyperLinkModel.updateHyperLink(e, l, t, {
325
+ payload: `#gid=${l}&range=${u ? B(u) : "err"}`
326
326
  }, !0);
327
327
  }, !0));
328
328
  }
329
329
  }
330
330
  }
331
331
  }
332
- _unregisterRange(id) {
333
- const disposable = this._rangeDisableMap.get(id);
334
- disposable == null || disposable.dispose(), this._rangeDisableMap.delete(id);
332
+ _unregisterRange(e) {
333
+ const t = this._rangeDisableMap.get(e);
334
+ t == null || t.dispose(), this._rangeDisableMap.delete(e);
335
335
  }
336
- _unwatchRange(id) {
337
- const disposable = this._rangeWatcherMap.get(id);
338
- disposable == null || disposable.dispose(), this._rangeWatcherMap.delete(id);
336
+ _unwatchRange(e) {
337
+ const t = this._rangeWatcherMap.get(e);
338
+ t == null || t.dispose(), this._rangeWatcherMap.delete(e);
339
339
  }
340
340
  _initData() {
341
- this._hyperLinkModel.getAll().forEach((unitData) => {
342
- unitData.forEach((subUnitData) => {
343
- const { unitId, subUnitId, links } = subUnitData;
344
- links.forEach((link) => {
345
- this._registerPosition(unitId, subUnitId, link), this._watchPosition(unitId, subUnitId, link), this._registerRange(unitId, link.id, link.payload);
341
+ this._hyperLinkModel.getAll().forEach((t) => {
342
+ t.forEach((n) => {
343
+ const { unitId: r, subUnitId: i, links: a } = n;
344
+ a.forEach((o) => {
345
+ this._registerPosition(r, i, o), this._watchPosition(r, i, o), this._registerRange(r, o.id, o.payload);
346
346
  });
347
347
  });
348
348
  });
349
349
  }
350
350
  _initRefRange() {
351
351
  this.disposeWithMe(
352
- this._hyperLinkModel.linkUpdate$.subscribe((option) => {
353
- switch (option.type) {
352
+ this._hyperLinkModel.linkUpdate$.subscribe((e) => {
353
+ switch (e.type) {
354
354
  case "add": {
355
- this._registerPosition(option.unitId, option.subUnitId, option.payload), this._watchPosition(option.unitId, option.subUnitId, option.payload), this._registerRange(option.unitId, option.payload.id, option.payload.payload);
355
+ this._registerPosition(e.unitId, e.subUnitId, e.payload), this._watchPosition(e.unitId, e.subUnitId, e.payload), this._registerRange(e.unitId, e.payload.id, e.payload.payload);
356
356
  break;
357
357
  }
358
358
  case "remove": {
359
- this._unregisterPosition(option.payload.id), this._unwatchPosition(option.payload.id), this._unregisterRange(option.payload.id), this._unwatchRange(option.payload.id);
359
+ this._unregisterPosition(e.payload.id), this._unwatchPosition(e.payload.id), this._unregisterRange(e.payload.id), this._unwatchRange(e.payload.id);
360
360
  break;
361
361
  }
362
362
  case "updateRef": {
363
- const { unitId, subUnitId, id, silent } = option, link = this._hyperLinkModel.getHyperLink(unitId, subUnitId, id);
364
- if (!link)
363
+ const { unitId: t, subUnitId: n, id: r, silent: i } = e, a = this._hyperLinkModel.getHyperLink(t, n, r);
364
+ if (!a)
365
365
  return;
366
- this._unregisterPosition(id), this._registerPosition(unitId, subUnitId, link), silent || (this._unwatchPosition(id), this._watchPosition(unitId, subUnitId, link));
366
+ this._unregisterPosition(r), this._registerPosition(t, n, a), i || (this._unwatchPosition(r), this._watchPosition(t, n, a));
367
367
  break;
368
368
  }
369
369
  case "unload": {
370
- const { unitLinks } = option;
371
- unitLinks.forEach((subUnitData) => {
372
- const { links } = subUnitData;
373
- links.forEach((link) => {
374
- this._unregisterPosition(link.id), this._unwatchPosition(link.id), this._unregisterRange(link.id), this._unwatchRange(link.id);
370
+ const { unitLinks: t } = e;
371
+ t.forEach((n) => {
372
+ const { links: r } = n;
373
+ r.forEach((i) => {
374
+ this._unregisterPosition(i.id), this._unwatchPosition(i.id), this._unregisterRange(i.id), this._unwatchRange(i.id);
375
375
  });
376
376
  });
377
377
  break;
378
378
  }
379
379
  case "update": {
380
- option.silent || this._unwatchRange(option.id), this._unregisterRange(option.id), this._registerRange(option.unitId, option.id, option.payload.payload, option.silent);
380
+ e.silent || this._unwatchRange(e.id), this._unregisterRange(e.id), this._registerRange(e.unitId, e.id, e.payload.payload, e.silent);
381
381
  break;
382
382
  }
383
383
  }
384
384
  })
385
- ), this.disposeWithMe(toDisposable(() => {
386
- this._disposableMap.forEach((item) => {
387
- item.dispose();
385
+ ), this.disposeWithMe(Ae(() => {
386
+ this._disposableMap.forEach((e) => {
387
+ e.dispose();
388
388
  }), this._disposableMap.clear();
389
389
  }));
390
390
  }
391
- }, __name(_a2, "SheetsHyperLinkRefRangeController"), _a2);
392
- SheetsHyperLinkRefRangeController = __decorateClass$3([
393
- __decorateParam$3(0, Inject(RefRangeService)),
394
- __decorateParam$3(1, Inject(HyperLinkModel)),
395
- __decorateParam$3(2, Inject(SheetsSelectionsService)),
396
- __decorateParam$3(3, ICommandService)
397
- ], SheetsHyperLinkRefRangeController);
398
- var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
399
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
400
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
401
- return kind && result && __defProp$2(target, key, result), result;
402
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a3;
403
- let SheetsHyperLinkController = (_a3 = class extends Disposable {
404
- constructor(_commandService) {
405
- super(), this._commandService = _commandService, this._registerCommands();
391
+ };
392
+ Z = Rt([
393
+ Y(0, I(Pe)),
394
+ Y(1, I(v)),
395
+ Y(2, I(Ne)),
396
+ Y(3, b)
397
+ ], Z);
398
+ var It = Object.defineProperty, Mt = Object.getOwnPropertyDescriptor, Ct = (s, e, t, n) => {
399
+ for (var r = n > 1 ? void 0 : n ? Mt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
400
+ (a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
401
+ return n && r && It(e, t, r), r;
402
+ }, pe = (s, e) => (t, n) => e(t, n, s);
403
+ let Q = class extends V {
404
+ constructor(s, e, t) {
405
+ super(), this._sheetInterceptorService = s, this._univerInstanceService = e, this._hyperLinkModel = t, this._initSheetChange();
406
+ }
407
+ _initSheetChange() {
408
+ this.disposeWithMe(
409
+ this._sheetInterceptorService.interceptCommand({
410
+ getMutations: (s) => {
411
+ var e;
412
+ if (s.id === nt.id) {
413
+ const t = s.params, n = t.unitId ? this._univerInstanceService.getUnit(t.unitId) : this._univerInstanceService.getCurrentUnitForType(R.UNIVER_SHEET);
414
+ if (!n)
415
+ return { redos: [], undos: [] };
416
+ const r = n.getUnitId(), i = t.subUnitId || ((e = n.getActiveSheet()) == null ? void 0 : e.getSheetId());
417
+ if (!i)
418
+ return { redos: [], undos: [] };
419
+ const a = this._hyperLinkModel.getSubUnit(r, i), o = a.map((d) => ({
420
+ id: k.id,
421
+ params: {
422
+ unitId: r,
423
+ subUnitId: i,
424
+ id: d.id
425
+ }
426
+ })), c = a.map((d) => ({
427
+ id: O.id,
428
+ params: {
429
+ unitId: r,
430
+ subUnitId: i,
431
+ link: d
432
+ }
433
+ }));
434
+ return { redos: o, undos: c };
435
+ }
436
+ return { redos: [], undos: [] };
437
+ }
438
+ })
439
+ );
440
+ }
441
+ };
442
+ Q = Ct([
443
+ pe(0, I(de)),
444
+ pe(1, E),
445
+ pe(2, I(v))
446
+ ], Q);
447
+ var wt = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, Lt = (s, e, t, n) => {
448
+ for (var r = n > 1 ? void 0 : n ? Et(e, t) : e, i = s.length - 1, a; i >= 0; i--)
449
+ (a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
450
+ return n && r && wt(e, t, r), r;
451
+ }, he = (s, e) => (t, n) => e(t, n, s);
452
+ let ee = class extends V {
453
+ constructor(e, t, n) {
454
+ super();
455
+ C(this, "_refRangeMap", /* @__PURE__ */ new Map());
456
+ this._commandService = e, this._univerInstanceService = t, this._refRangeService = n, this._initWorkbookLoad(), this._initWorkbookUnload(), this._initSetRangesListener();
457
+ }
458
+ _enusreMap(e, t) {
459
+ let n = this._refRangeMap.get(e);
460
+ n || (n = /* @__PURE__ */ new Map(), this._refRangeMap.set(e, n));
461
+ let r = n.get(t);
462
+ return r || (r = new J(), n.set(t, r)), r;
463
+ }
464
+ _isLegalRangeUrl(e, t) {
465
+ var r, i, a;
466
+ const n = this._univerInstanceService.getUnit(e, R.UNIVER_SHEET);
467
+ if (!n)
468
+ return null;
469
+ if (t && t.startsWith("#")) {
470
+ const o = new URLSearchParams(t.slice(1)), c = {
471
+ gid: (r = o.get("gid")) != null ? r : "",
472
+ range: (i = o.get("range")) != null ? i : "",
473
+ rangeid: (a = o.get("rangeid")) != null ? a : ""
474
+ };
475
+ if (c.range && c.gid) {
476
+ const d = c.gid, l = n.getSheetBySheetId(d);
477
+ if (!l)
478
+ return null;
479
+ const p = Me(c.range).range;
480
+ if (ve(p, l) && c.range !== q)
481
+ return p;
482
+ }
483
+ }
484
+ return null;
485
+ }
486
+ _registerRange(e, t, n, r, i) {
487
+ var o, c, d, l;
488
+ const a = this._enusreMap(e, t);
489
+ if ((c = (o = i.body) == null ? void 0 : o.customRanges) != null && c.some((p) => {
490
+ var h;
491
+ return p.rangeType === N.HYPERLINK && this._isLegalRangeUrl(e, (h = p.properties) == null ? void 0 : h.url);
492
+ })) {
493
+ const p = new We();
494
+ let h = !1;
495
+ (l = (d = i.body) == null ? void 0 : d.customRanges) == null || l.forEach((g) => {
496
+ var u;
497
+ if (g.rangeType === N.HYPERLINK) {
498
+ const f = (u = g.properties) == null ? void 0 : u.url, S = this._isLegalRangeUrl(e, f);
499
+ S && (h = !0, p.add(this._refRangeService.watchRange(e, t, S, (_, M) => {
500
+ g.properties.url = `#gid=${t}&range=${M ? B(M) : q}`;
501
+ })));
502
+ }
503
+ }), h && a.setValue(n, r, p);
504
+ }
505
+ }
506
+ _initWorkbookLoad() {
507
+ const e = (t) => {
508
+ const n = t.getUnitId();
509
+ t.getSheets().forEach((r) => {
510
+ const i = r.getSheetId(), a = this._enusreMap(n, i);
511
+ r.getCellMatrix().forValue((o, c, d) => {
512
+ const l = a.getValue(o, c);
513
+ l && l.dispose(), d && d.p && this._registerRange(n, i, o, c, d.p);
514
+ });
515
+ });
516
+ };
517
+ this._univerInstanceService.getAllUnitsForType(R.UNIVER_SHEET).forEach((t) => {
518
+ e(t);
519
+ }), this.disposeWithMe(
520
+ this._univerInstanceService.unitAdded$.subscribe((t) => {
521
+ t.type === R.UNIVER_SHEET && e(t);
522
+ })
523
+ );
524
+ }
525
+ _initWorkbookUnload() {
526
+ this._univerInstanceService.unitDisposed$.subscribe((e) => {
527
+ if (e.type === R.UNIVER_SHEET) {
528
+ const t = e, n = t.getUnitId();
529
+ t.getSheets().forEach((r) => {
530
+ const i = r.getSheetId();
531
+ this._enusreMap(n, i).forValue((o, c, d) => {
532
+ d && d.dispose();
533
+ });
534
+ }), this._refRangeMap.delete(n);
535
+ }
536
+ });
537
+ }
538
+ _initSetRangesListener() {
539
+ this.disposeWithMe(
540
+ this._commandService.onCommandExecuted((e) => {
541
+ if (e.id === H.id) {
542
+ const t = e.params, { unitId: n, subUnitId: r, cellValue: i } = t, a = this._enusreMap(n, r);
543
+ i && new J(i).forValue((o, c, d) => {
544
+ const l = a.getValue(o, c);
545
+ l && l.dispose(), d && d.p && this._registerRange(n, r, o, c, d.p);
546
+ });
547
+ }
548
+ })
549
+ );
550
+ }
551
+ };
552
+ ee = Lt([
553
+ he(0, b),
554
+ he(1, E),
555
+ he(2, I(Pe))
556
+ ], ee);
557
+ var Ut = Object.defineProperty, bt = Object.getOwnPropertyDescriptor, Pt = (s, e, t, n) => {
558
+ for (var r = n > 1 ? void 0 : n ? bt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
559
+ (a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
560
+ return n && r && Ut(e, t, r), r;
561
+ }, z = (s, e) => (t, n) => e(t, n, s);
562
+ let te = class extends V {
563
+ constructor(s, e, t, n) {
564
+ super(), this._sheetInterceptorService = s, this._hyperLinkModel = e, this._selectionManagerService = t, this._univerInstanceService = n, this._initCommandInterceptor(), this._initAfterEditor();
565
+ }
566
+ _initCommandInterceptor() {
567
+ this._initSetRangeValuesCommandInterceptor(), this._initClearSelectionCommandInterceptor();
568
+ }
569
+ _initSetRangeValuesCommandInterceptor() {
570
+ this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
571
+ getMutations: (s) => {
572
+ if (s.id === rt.id) {
573
+ const e = s.params, { unitId: t, subUnitId: n } = e, r = [], i = [];
574
+ return e.cellValue && new J(e.cellValue).forValue((a, o) => {
575
+ const c = this._hyperLinkModel.getHyperLinkByLocation(t, n, a, o);
576
+ c && (r.push({
577
+ id: k.id,
578
+ params: {
579
+ unitId: t,
580
+ subUnitId: n,
581
+ id: c.id
582
+ }
583
+ }), i.push({
584
+ id: O.id,
585
+ params: {
586
+ unitId: t,
587
+ subUnitId: n,
588
+ link: c
589
+ }
590
+ }));
591
+ }), {
592
+ undos: i,
593
+ redos: r
594
+ };
595
+ }
596
+ return {
597
+ redos: [],
598
+ undos: []
599
+ };
600
+ }
601
+ }));
602
+ }
603
+ _initClearSelectionCommandInterceptor() {
604
+ this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
605
+ getMutations: (s) => {
606
+ if (s.id === st.id || s.id === it.id || s.id === at.id) {
607
+ const e = [], t = [], n = this._selectionManagerService.getCurrentLastSelection(), r = ce(this._univerInstanceService);
608
+ if (n && r) {
609
+ const { unitId: i, subUnitId: a } = r;
610
+ Be.foreach(n.range, (o, c) => {
611
+ const d = this._hyperLinkModel.getHyperLinkByLocation(i, a, o, c);
612
+ d && (e.push({
613
+ id: k.id,
614
+ params: {
615
+ unitId: i,
616
+ subUnitId: a,
617
+ id: d.id
618
+ }
619
+ }), t.push({
620
+ id: O.id,
621
+ params: {
622
+ unitId: i,
623
+ subUnitId: a,
624
+ link: d
625
+ }
626
+ }));
627
+ });
628
+ }
629
+ return {
630
+ redos: e,
631
+ undos: t
632
+ };
633
+ }
634
+ return {
635
+ redos: [],
636
+ undos: []
637
+ };
638
+ }
639
+ }));
640
+ }
641
+ _initAfterEditor() {
642
+ this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(ot, {
643
+ handler: (s, e, t) => {
644
+ if (!s || s.p)
645
+ return t(s);
646
+ if (typeof s.v == "string" && ie.isLegalUrl(s.v) && s.v[s.v.length - 1] !== " ") {
647
+ const { unitId: n, subUnitId: r } = e, i = this._univerInstanceService.getUnit(n, R.UNIVER_SHEET), a = i == null ? void 0 : i.getSheetBySheetId(r);
648
+ if (!a)
649
+ return t(s);
650
+ const o = a.getBlankCellDocumentModel(s);
651
+ if (!o.documentModel)
652
+ return t(s);
653
+ const c = X.selection.replace({
654
+ selection: {
655
+ startOffset: 0,
656
+ endOffset: s.v.length,
657
+ collapsed: !1
658
+ },
659
+ body: {
660
+ dataStream: `${s.v}`,
661
+ customRanges: [{
662
+ startIndex: 0,
663
+ endIndex: s.v.length - 1,
664
+ rangeId: ae(),
665
+ rangeType: N.HYPERLINK,
666
+ properties: {
667
+ url: s.v
668
+ }
669
+ }]
670
+ },
671
+ doc: o.documentModel
672
+ });
673
+ if (!c)
674
+ return t(s);
675
+ const d = o.documentModel.getBody();
676
+ return oe.apply(d, c.serialize()), t({
677
+ ...s,
678
+ p: {
679
+ id: je,
680
+ body: d,
681
+ documentStyle: {
682
+ pageSize: {
683
+ width: 1 / 0,
684
+ height: 1 / 0
685
+ }
686
+ }
687
+ }
688
+ });
689
+ }
690
+ return t(s);
691
+ }
692
+ }));
693
+ }
694
+ };
695
+ te = Pt([
696
+ z(0, I(de)),
697
+ z(1, I(v)),
698
+ z(2, I(Ne)),
699
+ z(3, E)
700
+ ], te);
701
+ const Nt = {
702
+ type: L.COMMAND,
703
+ id: "sheets.command.add-hyper-link",
704
+ // eslint-disable-next-line max-lines-per-function
705
+ async handler(s, e) {
706
+ if (!e) return !1;
707
+ const t = s.get(b), n = s.get(Se), r = s.get(E), i = s.get(v), a = s.get(de), o = ce(r, e);
708
+ if (!o) return !1;
709
+ const { unitId: c, subUnitId: d, workbook: l, worksheet: p } = o, { link: h } = e, { payload: g, display: u, row: f, column: S, id: _ } = h, M = p.getCell(f, S), m = p.getBlankCellDocumentModel(M), w = m.documentModel.getSnapshot(), y = ie.deepClone(w.body);
710
+ if (!y) return !1;
711
+ let P;
712
+ if (u ? P = X.selection.replace({
713
+ selection: {
714
+ startOffset: 0,
715
+ endOffset: y.dataStream.length - 2,
716
+ collapsed: !0
717
+ },
718
+ body: {
719
+ dataStream: `${u}`,
720
+ customRanges: [{
721
+ startIndex: 0,
722
+ endIndex: u.length - 1,
723
+ rangeType: N.HYPERLINK,
724
+ rangeId: _,
725
+ properties: {
726
+ url: g
727
+ // refId: id,
728
+ }
729
+ }]
730
+ },
731
+ doc: m.documentModel
732
+ }) : P = X.customRange.add({
733
+ body: y,
734
+ range: { startOffset: 0, endOffset: y.dataStream.length - 2, collapsed: !1 },
735
+ rangeId: _,
736
+ rangeType: N.HYPERLINK,
737
+ properties: {
738
+ url: g,
739
+ refId: _
740
+ }
741
+ }), !P) return !1;
742
+ const j = oe.apply(y, P.serialize()), D = {
743
+ p: {
744
+ ...w,
745
+ body: j
746
+ },
747
+ t: Re.STRING
748
+ }, x = await a.onWriteCell(l, p, f, S, D), T = {
749
+ unitId: c,
750
+ subUnitId: d,
751
+ cellValue: {
752
+ [h.row]: {
753
+ [h.column]: x
754
+ }
755
+ }
756
+ }, le = {
757
+ id: H.id,
758
+ params: T
759
+ }, K = Ie(s, T), ue = {
760
+ id: H.id,
761
+ params: K
762
+ }, F = [le], A = [ue], W = i.getHyperLinkByLocation(c, d, f, S);
763
+ return W && (F.push({
764
+ id: k.id,
765
+ params: {
766
+ unitId: c,
767
+ subUnitId: d,
768
+ id: W.id
769
+ }
770
+ }), A.push({
771
+ id: O.id,
772
+ params: {
773
+ unitId: c,
774
+ subUnitId: d,
775
+ link: W
776
+ }
777
+ })), await ye(F, t) ? (n.pushUndoRedo({
778
+ redoMutations: F,
779
+ undoMutations: A,
780
+ unitID: c
781
+ }), !0) : !1;
782
+ }
783
+ }, Ot = {
784
+ id: "sheets.command.add-rich-hyper-link",
785
+ type: L.COMMAND,
786
+ handler: async (s, e) => {
787
+ if (!e)
788
+ return !1;
789
+ const { documentId: t, link: n } = e, r = s.get(b), i = ae(), { payload: a } = n, o = ut(s, {
790
+ unitId: t,
791
+ rangeId: i,
792
+ rangeType: N.HYPERLINK,
793
+ properties: {
794
+ url: a,
795
+ refId: i
796
+ }
797
+ });
798
+ return o ? r.syncExecuteCommand(o.id, o.params) : !1;
799
+ }
800
+ }, kt = {
801
+ type: L.COMMAND,
802
+ id: "sheets.command.cancel-hyper-link",
803
+ // eslint-disable-next-line max-lines-per-function
804
+ handler(s, e) {
805
+ var D, x;
806
+ if (!e) return !1;
807
+ const t = s.get(b), n = s.get(Se), r = s.get(E), i = s.get(v), a = ce(r, e);
808
+ if (!a) return !1;
809
+ const { row: o, column: c, id: d } = e, { unitId: l, subUnitId: p, worksheet: h } = a, g = h.getCell(o, c);
810
+ if (!g) return !1;
811
+ const u = h.getCellDocumentModelWithFormula(g);
812
+ if (!(u != null && u.documentModel)) return !1;
813
+ const f = ie.deepClone(u.documentModel.getSnapshot());
814
+ if (!((x = (D = f.body) == null ? void 0 : D.customRanges) == null ? void 0 : x.find((T) => T.rangeId === d))) return !1;
815
+ const _ = X.customRange.delete(s, { documentDataModel: u.documentModel, rangeId: d });
816
+ if (!_) return !1;
817
+ const M = oe.apply(f.body, _.serialize()), m = [], w = [], y = {
818
+ unitId: l,
819
+ subUnitId: p,
820
+ cellValue: {
821
+ [o]: {
822
+ [c]: {
823
+ p: {
824
+ ...f,
825
+ body: M
826
+ },
827
+ t: Re.STRING
828
+ }
829
+ }
830
+ }
831
+ };
832
+ m.push({
833
+ id: H.id,
834
+ params: y
835
+ });
836
+ const P = Ie(s, y);
837
+ w.push({
838
+ id: H.id,
839
+ params: P
840
+ });
841
+ const j = i.getHyperLinkByLocation(l, p, o, c);
842
+ return j && (m.push({
843
+ id: k.id,
844
+ params: {
845
+ unitId: l,
846
+ subUnitId: p,
847
+ id: d
848
+ }
849
+ }), w.push({
850
+ id: O.id,
851
+ params: {
852
+ unitId: l,
853
+ subUnitId: p,
854
+ link: {
855
+ ...j
856
+ }
857
+ }
858
+ })), Fe(m, t).result ? (n.pushUndoRedo({
859
+ redoMutations: m,
860
+ undoMutations: w,
861
+ unitID: l
862
+ }), !0) : !1;
863
+ }
864
+ }, Dt = {
865
+ type: L.COMMAND,
866
+ id: "sheets.command.cancel-rich-hyper-link",
867
+ handler(s, e) {
868
+ var l, p;
869
+ if (!e)
870
+ return !1;
871
+ const { id: t, documentId: n } = e, r = s.get(b), a = s.get(E).getUnit(n, R.UNIVER_DOC), o = (p = (l = a == null ? void 0 : a.getBody()) == null ? void 0 : l.customRanges) == null ? void 0 : p.find((h) => h.rangeId === t);
872
+ let c = null;
873
+ o && o.endIndex === a.getBody().dataStream.length - 3 && (c = {
874
+ dataStream: " "
875
+ });
876
+ const d = pt(s, { unitId: n, rangeId: t, insert: c });
877
+ return d ? r.syncExecuteCommand(d.id, d.params) : !1;
878
+ }
879
+ }, Ht = {
880
+ type: L.COMMAND,
881
+ id: "sheets.command.update-hyper-link",
882
+ // eslint-disable-next-line max-lines-per-function
883
+ async handler(s, e) {
884
+ var Ce, we, Ee;
885
+ if (!e) return !1;
886
+ const t = s.get(b), n = s.get(Se), r = s.get(E), i = s.get(v), a = s.get(de), o = ce(r, {
887
+ unitId: e.unitId,
888
+ subUnitId: e.subUnitId
889
+ });
890
+ if (!o) return !1;
891
+ const { payload: c, row: d, column: l, id: p } = e, { workbook: h, worksheet: g, unitId: u, subUnitId: f } = o, { payload: S, display: _ = "" } = c, M = g.getCell(d, l);
892
+ if (!M) return !1;
893
+ const m = g.getCellDocumentModelWithFormula(M);
894
+ if (!(m != null && m.documentModel)) return !1;
895
+ const w = m.documentModel.getSnapshot(), y = (we = (Ce = w.body) == null ? void 0 : Ce.customRanges) == null ? void 0 : we.find(($e) => $e.rangeId === p);
896
+ if (!y) return !1;
897
+ const P = ae(), $ = (Ee = be(m.documentModel.getBody(), y.startIndex, y.endIndex + 1).textRuns) == null ? void 0 : Ee[0];
898
+ $ && ($.ed = _.length + 1);
899
+ const D = Oe(s, {
900
+ unitId: u,
901
+ body: {
902
+ dataStream: `${_}`,
903
+ customRanges: [{
904
+ rangeId: P,
905
+ rangeType: N.HYPERLINK,
906
+ startIndex: 0,
907
+ endIndex: _.length - 1,
908
+ properties: {
909
+ url: S
910
+ }
911
+ }],
912
+ textRuns: $ ? [$] : void 0
913
+ },
914
+ selection: {
915
+ startOffset: y.startIndex,
916
+ endOffset: y.endIndex + 1,
917
+ collapsed: !1
918
+ },
919
+ doc: m.documentModel
920
+ });
921
+ if (!D)
922
+ return !1;
923
+ const x = oe.apply(ie.deepClone(w.body), D.textX.serialize()), T = {
924
+ p: {
925
+ ...w,
926
+ body: x
927
+ },
928
+ t: Re.STRING
929
+ }, le = await a.onWriteCell(h, g, d, l, T), K = {
930
+ id: H.id,
931
+ params: {
932
+ unitId: u,
933
+ subUnitId: f,
934
+ cellValue: {
935
+ [d]: {
936
+ [l]: le
937
+ }
938
+ }
939
+ }
940
+ }, ue = Ie(s, K.params), F = {
941
+ id: H.id,
942
+ params: ue
943
+ }, A = [K], W = [F], G = i.getHyperLinkByLocation(u, f, d, l);
944
+ return G && (A.push({
945
+ id: k.id,
946
+ params: {
947
+ unitId: u,
948
+ subUnitId: f,
949
+ id: G.id
950
+ }
951
+ }), W.push({
952
+ id: O.id,
953
+ params: {
954
+ unitId: u,
955
+ subUnitId: f,
956
+ link: G
957
+ }
958
+ })), await ye(A, t) ? (n.pushUndoRedo({
959
+ redoMutations: A,
960
+ undoMutations: W,
961
+ unitID: u
962
+ }), !0) : !1;
963
+ }
964
+ }, Vt = {
965
+ type: L.COMMAND,
966
+ id: "sheets.command.update-rich-hyper-link",
967
+ handler: (s, e) => {
968
+ var u, f, S, _;
969
+ if (!e)
970
+ return !1;
971
+ const { documentId: t, payload: n, id: r } = e, i = s.get(E), a = s.get(b), o = i.getUnit(t, R.UNIVER_DOC);
972
+ if (!o)
973
+ return !1;
974
+ const c = (f = (u = o.getBody()) == null ? void 0 : u.customRanges) == null ? void 0 : f.find((M) => M.rangeId === r);
975
+ if (!c)
976
+ return !1;
977
+ const d = (S = e.payload.display) != null ? S : "", l = ae(), h = (_ = be(o.getBody(), c.startIndex, c.endIndex + 1).textRuns) == null ? void 0 : _[0];
978
+ h && (h.ed = d.length + 1);
979
+ const g = Oe(s, {
980
+ unitId: t,
981
+ body: {
982
+ dataStream: `${d}`,
983
+ customRanges: [{
984
+ rangeId: l,
985
+ rangeType: N.HYPERLINK,
986
+ startIndex: 0,
987
+ endIndex: d.length - 1,
988
+ properties: {
989
+ url: n.payload
990
+ }
991
+ }],
992
+ textRuns: h ? [h] : void 0
993
+ },
994
+ selection: {
995
+ startOffset: c.startIndex,
996
+ endOffset: c.endIndex + 1,
997
+ collapsed: !1
998
+ },
999
+ doc: o
1000
+ });
1001
+ return g ? a.syncExecuteCommand(g.id, g.params) : !1;
1002
+ }
1003
+ };
1004
+ var $t = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, Tt = (s, e, t, n) => {
1005
+ for (var r = n > 1 ? void 0 : n ? xt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
1006
+ (a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
1007
+ return n && r && $t(e, t, r), r;
1008
+ }, At = (s, e) => (t, n) => e(t, n, s);
1009
+ let ne = class extends V {
1010
+ constructor(s) {
1011
+ super(), this._commandService = s, this._registerCommands();
406
1012
  }
407
1013
  _registerCommands() {
408
1014
  [
409
- AddHyperLinkMutation,
410
- UpdateHyperLinkMutation,
411
- RemoveHyperLinkMutation,
412
- UpdateHyperLinkRefMutation
413
- ].forEach((command) => {
414
- this._commandService.registerCommand(command);
1015
+ Nt,
1016
+ Ht,
1017
+ kt,
1018
+ Vt,
1019
+ Dt,
1020
+ Ot,
1021
+ O,
1022
+ fe,
1023
+ k,
1024
+ _e
1025
+ ].forEach((s) => {
1026
+ this._commandService.registerCommand(s);
415
1027
  });
416
1028
  }
417
- }, __name(_a3, "SheetsHyperLinkController"), _a3);
418
- SheetsHyperLinkController = __decorateClass$2([
419
- __decorateParam$2(0, ICommandService)
420
- ], SheetsHyperLinkController);
421
- var _ = /* @__PURE__ */ ((E) => (E[E.UNIVER_UNKNOWN = 0] = "UNIVER_UNKNOWN", E[E.UNIVER_DOC = 1] = "UNIVER_DOC", E[E.UNIVER_SHEET = 2] = "UNIVER_SHEET", E[E.UNIVER_SLIDE = 3] = "UNIVER_SLIDE", E[E.UNIVER_PROJECT = 4] = "UNIVER_PROJECT", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(_ || {}), __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
422
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
423
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
424
- return kind && result && __defProp$1(target, key, result), result;
425
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a4;
426
- let SheetsHyperLinkResourceController = (_a4 = class extends Disposable {
427
- constructor(_resourceManagerService, _hyperLinkModel) {
428
- super(), this._resourceManagerService = _resourceManagerService, this._hyperLinkModel = _hyperLinkModel, this._initSnapshot();
1029
+ };
1030
+ ne = Tt([
1031
+ At(0, b)
1032
+ ], ne);
1033
+ var De = /* @__PURE__ */ ((s) => (s[s.UNIVER_UNKNOWN = 0] = "UNIVER_UNKNOWN", s[s.UNIVER_DOC = 1] = "UNIVER_DOC", s[s.UNIVER_SHEET = 2] = "UNIVER_SHEET", s[s.UNIVER_SLIDE = 3] = "UNIVER_SLIDE", s[s.UNIVER_PROJECT = 4] = "UNIVER_PROJECT", s[s.UNRECOGNIZED = -1] = "UNRECOGNIZED", s))(De || {}), Wt = Object.defineProperty, Bt = Object.getOwnPropertyDescriptor, jt = (s, e, t, n) => {
1034
+ for (var r = n > 1 ? void 0 : n ? Bt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
1035
+ (a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
1036
+ return n && r && Wt(e, t, r), r;
1037
+ }, Le = (s, e) => (t, n) => e(t, n, s);
1038
+ let re = class extends V {
1039
+ constructor(s, e) {
1040
+ super(), this._resourceManagerService = s, this._hyperLinkModel = e, this._initSnapshot();
429
1041
  }
430
1042
  _initSnapshot() {
431
- const toJson = /* @__PURE__ */ __name((unitID) => {
432
- const map = this._hyperLinkModel.getUnit(unitID), resultMap = {};
433
- return map ? (map.forEach((info) => {
434
- resultMap[info.subUnitId] = info.links.map(({ display, ...link }) => link);
435
- }), JSON.stringify(resultMap)) : "";
436
- }, "toJson"), parseJson = /* @__PURE__ */ __name((json) => {
437
- if (!json)
1043
+ const s = (t) => {
1044
+ const n = this._hyperLinkModel.getUnit(t), r = {};
1045
+ return n ? (n.forEach((i) => {
1046
+ r[i.subUnitId] = i.links.map(({ display: a, ...o }) => o);
1047
+ }), JSON.stringify(r)) : "";
1048
+ }, e = (t) => {
1049
+ if (!t)
438
1050
  return {};
439
1051
  try {
440
- return JSON.parse(json);
1052
+ return JSON.parse(t);
441
1053
  } catch {
442
1054
  return {};
443
1055
  }
444
- }, "parseJson");
1056
+ };
445
1057
  this.disposeWithMe(
446
1058
  this._resourceManagerService.registerPluginResource({
447
- pluginName: SHEET_HYPER_LINK_PLUGIN,
448
- businesses: [_.UNIVER_SHEET],
449
- toJson: /* @__PURE__ */ __name((unitID) => toJson(unitID), "toJson"),
450
- parseJson: /* @__PURE__ */ __name((json) => parseJson(json), "parseJson"),
451
- onUnLoad: /* @__PURE__ */ __name((unitID) => {
452
- this._hyperLinkModel.deleteUnit(unitID);
453
- }, "onUnLoad"),
454
- onLoad: /* @__PURE__ */ __name(async (unitID, value) => {
455
- Object.keys(value).forEach((subunitId) => {
456
- value[subunitId].forEach((link) => {
457
- this._hyperLinkModel.addHyperLink(unitID, subunitId, link);
1059
+ pluginName: ke,
1060
+ businesses: [De.UNIVER_SHEET],
1061
+ toJson: (t) => s(t),
1062
+ parseJson: (t) => e(t),
1063
+ onUnLoad: (t) => {
1064
+ this._hyperLinkModel.deleteUnit(t);
1065
+ },
1066
+ onLoad: async (t, n) => {
1067
+ Object.keys(n).forEach((r) => {
1068
+ n[r].forEach((a) => {
1069
+ this._hyperLinkModel.addHyperLink(t, r, a);
458
1070
  });
459
1071
  });
460
- }, "onLoad")
1072
+ }
461
1073
  })
462
1074
  );
463
1075
  }
464
- }, __name(_a4, "SheetsHyperLinkResourceController"), _a4);
465
- SheetsHyperLinkResourceController = __decorateClass$1([
466
- __decorateParam$1(0, IResourceManagerService),
467
- __decorateParam$1(1, Inject(HyperLinkModel))
468
- ], SheetsHyperLinkResourceController);
469
- var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
470
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
471
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
472
- return kind && result && __defProp2(target, key, result), result;
473
- }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField"), _a5;
474
- let UniverSheetsHyperLinkPlugin = (_a5 = class extends Plugin {
475
- constructor(_config = defaultPluginConfig, _injector, _configService) {
476
- super(), this._config = _config, this._injector = _injector, this._configService = _configService;
477
- const { ...rest } = this._config;
478
- this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
1076
+ };
1077
+ re = jt([
1078
+ Le(0, Ke),
1079
+ Le(1, I(v))
1080
+ ], re);
1081
+ var Ft = Object.defineProperty, Kt = Object.getOwnPropertyDescriptor, Gt = (s, e, t, n) => {
1082
+ for (var r = n > 1 ? void 0 : n ? Kt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
1083
+ (a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
1084
+ return n && r && Ft(e, t, r), r;
1085
+ }, ge = (s, e) => (t, n) => e(t, n, s);
1086
+ let me = class {
1087
+ constructor(s, e, t) {
1088
+ this._univerInstanceService = s, this._localeService = e, this._definedNamesService = t;
1089
+ }
1090
+ buildHyperLink(s, e, t) {
1091
+ return `#${U.SHEET}=${e}${t ? `&${typeof t == "string" ? U.DEFINE_NAME : U.RANGE}=${typeof t == "string" ? t : B(t)}` : ""}`;
1092
+ }
1093
+ parseHyperLink(s) {
1094
+ var e, t, n, r;
1095
+ if (s.startsWith("#")) {
1096
+ const i = new URLSearchParams(s.slice(1)), a = {
1097
+ gid: (e = i.get("gid")) != null ? e : "",
1098
+ range: (t = i.get("range")) != null ? t : "",
1099
+ rangeid: (n = i.get("rangeid")) != null ? n : "",
1100
+ unitid: (r = i.get("unitid")) != null ? r : ""
1101
+ }, o = this._getURLName(a);
1102
+ return {
1103
+ type: o.type,
1104
+ name: o.name,
1105
+ url: s,
1106
+ searchObj: a
1107
+ };
1108
+ } else
1109
+ return {
1110
+ type: U.URL,
1111
+ name: s,
1112
+ url: s,
1113
+ searchObj: null
1114
+ };
1115
+ }
1116
+ _getURLName(s) {
1117
+ var d;
1118
+ const { gid: e, range: t, rangeid: n, unitid: r } = s, i = r ? this._univerInstanceService.getUnit(r, R.UNIVER_SHEET) : this._univerInstanceService.getCurrentUnitForType(R.UNIVER_SHEET), a = {
1119
+ type: U.INVALID,
1120
+ name: this._localeService.t("hyperLink.message.refError")
1121
+ };
1122
+ if (!i)
1123
+ return a;
1124
+ const o = e ? i.getSheetBySheetId(e) : i.getActiveSheet(), c = (d = o == null ? void 0 : o.getName()) != null ? d : "";
1125
+ if (t) {
1126
+ if (!o) return a;
1127
+ const l = Me(t).range;
1128
+ return ve(l, o) && t !== q ? {
1129
+ type: U.RANGE,
1130
+ name: ct(c, l)
1131
+ } : a;
1132
+ }
1133
+ if (n) {
1134
+ const l = this._definedNamesService.getValueById(i.getUnitId(), n);
1135
+ return l ? {
1136
+ type: U.DEFINE_NAME,
1137
+ name: l.formulaOrRefString
1138
+ } : a;
1139
+ }
1140
+ if (e) {
1141
+ const l = i.getSheetBySheetId(e);
1142
+ return l ? {
1143
+ type: U.SHEET,
1144
+ name: l.getName()
1145
+ } : a;
1146
+ }
1147
+ return a;
1148
+ }
1149
+ };
1150
+ me = Gt([
1151
+ ge(0, E),
1152
+ ge(1, I(Ge)),
1153
+ ge(2, lt)
1154
+ ], me);
1155
+ var He = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, zt = (s, e, t) => e in s ? He(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, Jt = (s, e, t, n) => {
1156
+ for (var r = n > 1 ? void 0 : n ? Yt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
1157
+ (a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
1158
+ return n && r && He(e, t, r), r;
1159
+ }, Ue = (s, e) => (t, n) => e(t, n, s), Ve = (s, e, t) => zt(s, typeof e != "symbol" ? e + "" : e, t);
1160
+ let se = class extends Je {
1161
+ constructor(s = yt, e, t) {
1162
+ super(), this._config = s, this._injector = e, this._configService = t;
1163
+ const { ...n } = this._config;
1164
+ this._configService.setConfig(mt, n);
479
1165
  }
480
1166
  onStarting() {
481
- [
482
- [SheetsHyperLinkResourceController],
483
- [SheetsHyperLinkController],
484
- [SheetsHyperLinkRefRangeController],
485
- [HyperLinkModel]
486
- ].forEach((dep) => {
487
- this._injector.add(dep);
488
- }), this._injector.get(SheetsHyperLinkRefRangeController), this._injector.get(SheetsHyperLinkResourceController), this._injector.get(SheetsHyperLinkController);
489
- }
490
- }, __name(_a5, "UniverSheetsHyperLinkPlugin"), _a5);
491
- __publicField2(UniverSheetsHyperLinkPlugin, "pluginName", SHEET_HYPER_LINK_PLUGIN);
492
- __publicField2(UniverSheetsHyperLinkPlugin, "type", UniverInstanceType.UNIVER_SHEET);
493
- UniverSheetsHyperLinkPlugin = __decorateClass([
494
- DependentOn(UniverSheetsPlugin),
495
- __decorateParam(1, Inject(Injector)),
496
- __decorateParam(2, IConfigService)
497
- ], UniverSheetsHyperLinkPlugin);
1167
+ Xe(this._injector, [
1168
+ [v],
1169
+ [me],
1170
+ [re],
1171
+ [ne],
1172
+ [Z],
1173
+ [te],
1174
+ [Q],
1175
+ [ee]
1176
+ ]), qe(this._injector, [
1177
+ [Z],
1178
+ [re],
1179
+ [ne],
1180
+ [te],
1181
+ [Q],
1182
+ [ee]
1183
+ ]);
1184
+ }
1185
+ };
1186
+ Ve(se, "pluginName", ke);
1187
+ Ve(se, "type", R.UNIVER_SHEET);
1188
+ se = Jt([
1189
+ Ye(dt),
1190
+ Ue(1, I(ze)),
1191
+ Ue(2, Ze)
1192
+ ], se);
498
1193
  export {
499
- AddHyperLinkMutation,
500
- ERROR_RANGE,
501
- HyperLinkModel,
502
- RemoveHyperLinkMutation,
503
- SheetHyperLinkType,
504
- UniverSheetsHyperLinkPlugin,
505
- UpdateHyperLinkMutation,
506
- UpdateHyperLinkRefMutation
1194
+ Nt as AddHyperLinkCommand,
1195
+ O as AddHyperLinkMutation,
1196
+ Ot as AddRichHyperLinkCommand,
1197
+ kt as CancelHyperLinkCommand,
1198
+ Dt as CancelRichHyperLinkCommand,
1199
+ q as ERROR_RANGE,
1200
+ v as HyperLinkModel,
1201
+ k as RemoveHyperLinkMutation,
1202
+ U as SheetHyperLinkType,
1203
+ me as SheetsHyperLinkParserService,
1204
+ se as UniverSheetsHyperLinkPlugin,
1205
+ Ht as UpdateHyperLinkCommand,
1206
+ fe as UpdateHyperLinkMutation,
1207
+ _e as UpdateHyperLinkRefMutation,
1208
+ Vt as UpdateRichHyperLinkCommand
507
1209
  };