index.js 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889
  1. var rr = Object.defineProperty;
  2. var ir = (t, e, n) => e in t ? rr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
  3. var B = (t, e, n) => ir(t, typeof e != "symbol" ? e + "" : e, n);
  4. import { Tools as Ce, Inject as R, LocaleService as ct, UniverInstanceType as w, isValidRange as Rn, IUniverInstanceService as Y, ICommandService as ie, IConfigService as Ln, RANGE_TYPE as sn, Rectangle as ye, Injector as lt, Disposable as z, Range as Pn, ObjectMatrix as sr, useDependency as E, IContextService as bn, ThemeService as or, DataStreamTreeTokenType as on, CustomRangeType as Ge, BuildTextUtils as Se, ColorKit as ar, DOCS_ZEN_EDITOR_UNIT_ID_KEY as x, DisposableCollection as cr, FOCUSING_SHEET as Ct, generateRandomId as lr, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as Ie, DataValidationType as It, CommandType as ut, FOCUSING_FX_BAR_EDITOR as ur, IPermissionService as dr, InterceptorEffectEnum as pr, DependentOn as hr, Plugin as gr, merge as fr } from "@univerjs/core";
  5. import { SheetHyperLinkType as S, ERROR_RANGE as mr, HyperLinkModel as dt, RemoveHyperLinkMutation as Ue, AddHyperLinkMutation as He, SheetsHyperLinkParserService as kt, UpdateRichHyperLinkCommand as _r, UpdateHyperLinkCommand as vr, AddRichHyperLinkCommand as Sr, AddHyperLinkCommand as Cr, CancelRichHyperLinkCommand as Ir, CancelHyperLinkCommand as yr, UniverSheetsHyperLinkPlugin as Er } from "@univerjs/sheets-hyper-link";
  6. import { ScrollToRangeOperation as wn, COPY_TYPE as Rr, virtualizeDiscreteRanges as Lt, rangeToDiscreteRange as Lr, PREDEFINED_HOOK_NAME as Ae, getRepeatRange as Pr, ISheetClipboardService as br, IEditorBridgeService as re, IMarkSelectionService as wr, SheetCanvasPopManagerService as Or, getEditingCustomRangePosition as kr, getCustomRangePosition as Tr, whenSheetEditorFocused as xr, getCurrentRangeDisable$ as Nr, IAutoFillService as Mr, APPLY_TYPE as Oe, getAutoFillRepeatRange as Ur, HoverManagerService as Hr, HoverRenderController as Dr, SheetSkeletonManagerService as an } from "@univerjs/sheets-ui";
  7. import { MessageType as xe, FormLayout as _e, Input as cn, Select as yt, Button as ln, Tooltip as Be } from "@univerjs/design";
  8. import { deserializeRangeWithSheet as Fe, IDefinedNamesService as On, serializeRangeWithSheet as $r, serializeRangeToRefString as jr, serializeRange as Ar } from "@univerjs/engine-formula";
  9. import { SetSelectionsOperation as kn, SetWorksheetActiveOperation as Tn, SheetsSelectionsService as Tt, getSheetCommandTarget as xn, WorkbookEditablePermission as xt, WorksheetEditPermission as Nt, WorksheetSetCellValuePermission as Nn, WorksheetInsertHyperlinkPermission as Mt, RangeProtectionPermissionEditPoint as Ut, SheetPermissionCheckController as Mn, WorkbookViewPermission as Br, WorksheetViewPermission as Vr, RangeProtectionPermissionViewPoint as Fr, WorkbookCopyPermission as Wr, WorksheetCopyPermission as Zr, ClearSelectionContentCommand as Gr, ClearSelectionAllCommand as Kr, ClearSelectionFormatCommand as Yr, SheetInterceptorService as zr, INTERCEPTOR_POINT as qr } from "@univerjs/sheets";
  10. import { IMessageService as Un, useObservable as Jr, IZenZoneService as pt, useEvent as Xr, KeyCode as Pt, MenuItemType as Hn, MetaKeys as Qr, getMenuHiddenObservable as ht, RibbonStartGroup as ei, ContextMenuPosition as ti, ContextMenuGroup as ni, ComponentManager as ri, IShortcutService as ii, IMenuManagerService as si } from "@univerjs/ui";
  11. import { DocSelectionRenderService as Dn, DocBackScrollRenderController as oi, DocCanvasPopManagerService as ai, calcDocRangePositions as ci, DocEventManagerService as un, UniverDocsUIPlugin as li } from "@univerjs/docs-ui";
  12. import { IRenderManagerService as $e } from "@univerjs/engine-render";
  13. import { Subject as ui, BehaviorSubject as di, of as Ne, map as le, filter as dn, switchMap as ue, combineLatest as pi, distinctUntilChanged as hi, debounceTime as We, Observable as gi } from "rxjs";
  14. import { DocSelectionManagerService as De } from "@univerjs/docs";
  15. import fi, { useState as X, useMemo as pn, useRef as bt, useCallback as mi, useEffect as ne, forwardRef as he, createElement as ge } from "react";
  16. import { RangeSelector as _i } from "@univerjs/sheets-formula-ui";
  17. import { SheetDataValidationModel as hn } from "@univerjs/sheets-data-validation";
  18. function Ke(t) {
  19. return Ce.isLegalUrl(t);
  20. }
  21. function vi(t) {
  22. return /^[a-zA-Z]+:\/\//.test(t);
  23. }
  24. function Si(t) {
  25. return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t);
  26. }
  27. function Ci(t) {
  28. if (Ke(t)) {
  29. const e = vi(t) ? t : Si(t) ? `mailto://${t}` : `http://${t}`;
  30. let n;
  31. try {
  32. n = new URL(e);
  33. } catch {
  34. return t;
  35. }
  36. return n.hostname === location.hostname && n.port === location.port && n.protocol === location.protocol && n.pathname === location.pathname && n.hash && !n.search ? n.hash : e;
  37. }
  38. return t;
  39. }
  40. const $n = "sheets-hyper-link-ui.config", gn = {};
  41. var Ii = Object.defineProperty, yi = Object.getOwnPropertyDescriptor, Ei = (t, e, n, i) => {
  42. for (var r = i > 1 ? void 0 : i ? yi(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  43. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  44. return i && r && Ii(e, n, r), r;
  45. }, ve = (t, e) => (n, i) => e(n, i, t);
  46. function Ri(t, e) {
  47. const n = e.getMergeData(), i = e.getMaxColumns() - 1, r = e.getMaxRows() - 1;
  48. if (i < t.endColumn && (t.endColumn = i), r < t.endRow && (t.endRow = r), t.rangeType === sn.COLUMN || sn.ROW)
  49. return t;
  50. const o = [];
  51. return n.forEach((s) => {
  52. ye.intersects(t, s) && o.push(s);
  53. }), ye.realUnion(t, ...o);
  54. }
  55. let pe = class {
  56. constructor(t, e, n, i, r, o) {
  57. this._univerInstanceService = t, this._commandService = e, this._definedNamesService = n, this._messageService = i, this._localeService = r, this._configService = o;
  58. }
  59. navigate(t) {
  60. switch (t.type) {
  61. case S.URL:
  62. this.navigateToOtherWebsite(t.url);
  63. break;
  64. default:
  65. this._navigateToUniver(t.searchObj);
  66. }
  67. }
  68. _navigateToUniver(t) {
  69. const { gid: e, range: n, rangeid: i } = t, r = this._univerInstanceService.getCurrentUnitForType(w.UNIVER_SHEET);
  70. if (!r)
  71. return;
  72. const o = r.getUnitId();
  73. if (i) {
  74. const s = this._definedNamesService.getValueById(o, i);
  75. if (!s)
  76. return;
  77. const { formulaOrRefString: c } = s, l = this._definedNamesService.getWorksheetByRef(o, c);
  78. if (!l) {
  79. this._messageService.show({
  80. content: this._localeService.t("hyperLink.message.refError"),
  81. type: xe.Error
  82. });
  83. return;
  84. }
  85. if (l.isSheetHidden()) {
  86. this._messageService.show({
  87. content: this._localeService.t("hyperLink.message.hiddenSheet"),
  88. type: xe.Error
  89. });
  90. return;
  91. }
  92. this.navigateToDefineName(o, i);
  93. }
  94. if (e) {
  95. if (n) {
  96. const s = Fe(n);
  97. Rn(s.range) && n !== mr && this.navigateToRange(o, e, s.range);
  98. return;
  99. }
  100. this.navigateToSheetById(o, e);
  101. }
  102. }
  103. async navigateToRange(t, e, n, i) {
  104. const r = await this.navigateToSheetById(t, e);
  105. if (r) {
  106. const o = Ri(n, r);
  107. await this._commandService.executeCommand(
  108. kn.id,
  109. {
  110. unitId: t,
  111. subUnitId: e,
  112. selections: [{
  113. range: o,
  114. primary: null
  115. }]
  116. }
  117. ), await this._commandService.executeCommand(wn.id, {
  118. range: o,
  119. forceTop: i
  120. });
  121. }
  122. }
  123. async navigateToSheetById(t, e) {
  124. const n = this._univerInstanceService.getUnit(t, w.UNIVER_SHEET);
  125. if (!n)
  126. return !1;
  127. const i = n.getActiveSheet();
  128. if (!i)
  129. return !1;
  130. if (i.getSheetId() === e)
  131. return i;
  132. const r = n.getSheetBySheetId(e);
  133. return r ? n.getHiddenWorksheets().indexOf(e) > -1 ? (this._messageService.show({
  134. content: this._localeService.t("hyperLink.message.hiddenSheet"),
  135. type: xe.Error
  136. }), !1) : await this._commandService.executeCommand(Tn.id, { unitId: t, subUnitId: e }) ? r : !1 : (this._messageService.show({
  137. content: this._localeService.t("hyperLink.message.noSheet"),
  138. type: xe.Error
  139. }), !1);
  140. }
  141. async navigateToDefineName(t, e) {
  142. return this._definedNamesService.focusRange(t, e), !0;
  143. }
  144. async navigateToOtherWebsite(t) {
  145. var n;
  146. const e = this._configService.getConfig($n);
  147. if ((n = e == null ? void 0 : e.urlHandler) != null && n.navigateToOtherWebsite)
  148. return e.urlHandler.navigateToOtherWebsite(t);
  149. window.open(t, "_blank", "noopener noreferrer");
  150. }
  151. };
  152. pe = Ei([
  153. ve(0, Y),
  154. ve(1, ie),
  155. ve(2, On),
  156. ve(3, Un),
  157. ve(4, R(ct)),
  158. ve(5, Ln)
  159. ], pe);
  160. const Ht = "SHEET_HYPER_LINK_UI_PLUGIN";
  161. var Li = Object.defineProperty, Pi = Object.getOwnPropertyDescriptor, bi = (t, e, n, i) => {
  162. for (var r = i > 1 ? void 0 : i ? Pi(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  163. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  164. return i && r && Li(e, n, r), r;
  165. }, Ve = (t, e) => (n, i) => e(n, i, t);
  166. let Ye = class extends z {
  167. constructor(e, n, i, r) {
  168. super();
  169. B(this, "_plainTextFilter", /* @__PURE__ */ new Set());
  170. B(this, "_copyInfo");
  171. this._sheetClipboardService = e, this._hyperLinkModel = n, this._injector = i, this._resolverService = r, this._initCopyPaste(), this.disposeWithMe(() => {
  172. this._plainTextFilter.clear();
  173. });
  174. }
  175. registerPlainTextFilter(e) {
  176. this._plainTextFilter.add(e);
  177. }
  178. removePlainTextFilter(e) {
  179. this._plainTextFilter.delete(e);
  180. }
  181. /* If return false the process of paste text will be stop */
  182. _filterPlainText(e) {
  183. return Array.from(this._plainTextFilter).every((n) => n(e));
  184. }
  185. _initCopyPaste() {
  186. this._sheetClipboardService.addClipboardHook({
  187. id: Ht,
  188. onBeforeCopy: (e, n, i) => this._collect(e, n, i),
  189. onPasteCells: (e, n, i, r) => {
  190. const { copyType: o = Rr.COPY, pasteType: s } = r, { range: c } = e || {}, { range: l, unitId: p, subUnitId: u } = n;
  191. return this._generateMutations(l, { copyType: o, pasteType: s, copyRange: c, unitId: p, subUnitId: u });
  192. },
  193. onPastePlainText: (e, n) => {
  194. const i = this._filterPlainText(n);
  195. if (Ke(n) && i) {
  196. const { range: r, unitId: o, subUnitId: s } = e, { ranges: [c], mapFunc: l } = Lt([r]), p = [], u = [];
  197. return Pn.foreach(c, (g, d) => {
  198. const { row: v, col: C } = l(g, d), _ = this._hyperLinkModel.getHyperLinkByLocation(o, s, v, C);
  199. _ && p.push({
  200. id: Ue.id,
  201. params: {
  202. unitId: o,
  203. subUnitId: s,
  204. id: _.id
  205. }
  206. }), _ && u.push({
  207. id: He.id,
  208. params: {
  209. unitId: o,
  210. subUnitId: s,
  211. link: _
  212. }
  213. });
  214. }), { redos: p, undos: u };
  215. }
  216. return { undos: [], redos: [] };
  217. },
  218. priority: 99
  219. });
  220. }
  221. _collect(e, n, i) {
  222. const r = new sr();
  223. this._copyInfo = {
  224. unitId: e,
  225. subUnitId: n,
  226. matrix: r
  227. };
  228. const o = this._injector.invoke((l) => Lr(i, l, e, n));
  229. if (!o)
  230. return;
  231. const { rows: s, cols: c } = o;
  232. s.forEach((l, p) => {
  233. c.forEach((u, g) => {
  234. var v;
  235. const d = this._hyperLinkModel.getHyperLinkByLocation(e, n, l, u);
  236. r.setValue(p, g, (v = d == null ? void 0 : d.id) != null ? v : "");
  237. });
  238. });
  239. }
  240. // eslint-disable-next-line max-lines-per-function
  241. _generateMutations(e, n) {
  242. if (!this._copyInfo)
  243. return { redos: [], undos: [] };
  244. if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !n.copyRange)
  245. return { redos: [], undos: [] };
  246. if ([
  247. Ae.SPECIAL_PASTE_COL_WIDTH,
  248. Ae.SPECIAL_PASTE_VALUE,
  249. Ae.SPECIAL_PASTE_FORMAT,
  250. Ae.SPECIAL_PASTE_FORMULA
  251. ].includes(n.pasteType))
  252. return { redos: [], undos: [] };
  253. const { unitId: r, subUnitId: o } = this._copyInfo, s = [], c = [], { ranges: [l, p], mapFunc: u } = Lt([n.copyRange, e]);
  254. return Pr(l, p, !0).forEach(({ startRange: d }) => {
  255. var v;
  256. (v = this._copyInfo) == null || v.matrix.forValue((C, _, O) => {
  257. const a = ye.getPositionRange(
  258. {
  259. startRow: C,
  260. endRow: C,
  261. startColumn: _,
  262. endColumn: _
  263. },
  264. d
  265. ), b = this._hyperLinkModel.getHyperLink(r, o, O), { row: M, col: k } = u(a.startRow, a.startColumn), L = this._hyperLinkModel.getHyperLinkByLocation(n.unitId, n.subUnitId, M, k), j = Ce.generateRandomId();
  266. L && s.push({
  267. id: Ue.id,
  268. params: {
  269. unitId: n.unitId,
  270. subUnitId: n.subUnitId,
  271. id: L.id
  272. }
  273. }), b && (s.push({
  274. id: He.id,
  275. params: {
  276. unitId: n.unitId,
  277. subUnitId: n.subUnitId,
  278. link: {
  279. ...b,
  280. id: j,
  281. row: M,
  282. column: k
  283. }
  284. }
  285. }), c.push({
  286. id: Ue.id,
  287. params: {
  288. unitId: n.unitId,
  289. subUnitId: n.subUnitId,
  290. id: j
  291. }
  292. })), L && c.push({
  293. id: He.id,
  294. params: {
  295. unitId: n.unitId,
  296. subUnitId: n.subUnitId,
  297. link: L
  298. }
  299. });
  300. });
  301. }), { redos: s, undos: c };
  302. }
  303. };
  304. Ye = bi([
  305. Ve(0, br),
  306. Ve(1, R(dt)),
  307. Ve(2, R(lt)),
  308. Ve(3, R(pe))
  309. ], Ye);
  310. var m = /* @__PURE__ */ ((t) => (t.EDITING = "editing", t.VIEWING = "viewing", t.ZEN_EDITOR = "zen_mode", t))(m || {}), Et = { exports: {} }, ke = {};
  311. /**
  312. * @license React
  313. * react-jsx-runtime.production.min.js
  314. *
  315. * Copyright (c) Facebook, Inc. and its affiliates.
  316. *
  317. * This source code is licensed under the MIT license found in the
  318. * LICENSE file in the root directory of this source tree.
  319. */
  320. var fn;
  321. function wi() {
  322. if (fn) return ke;
  323. fn = 1;
  324. var t = fi, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, r = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, o = { key: !0, ref: !0, __self: !0, __source: !0 };
  325. function s(c, l, p) {
  326. var u, g = {}, d = null, v = null;
  327. p !== void 0 && (d = "" + p), l.key !== void 0 && (d = "" + l.key), l.ref !== void 0 && (v = l.ref);
  328. for (u in l) i.call(l, u) && !o.hasOwnProperty(u) && (g[u] = l[u]);
  329. if (c && c.defaultProps) for (u in l = c.defaultProps, l) g[u] === void 0 && (g[u] = l[u]);
  330. return { $$typeof: e, type: c, key: d, ref: v, props: g, _owner: r.current };
  331. }
  332. return ke.Fragment = n, ke.jsx = s, ke.jsxs = s, ke;
  333. }
  334. var mn;
  335. function Oi() {
  336. return mn || (mn = 1, Et.exports = wi()), Et.exports;
  337. }
  338. var f = Oi();
  339. class jn extends z {
  340. constructor() {
  341. super(...arguments);
  342. B(this, "_customHyperLinks", /* @__PURE__ */ new Map());
  343. }
  344. isBuiltInLinkType(n) {
  345. return n !== S.URL;
  346. }
  347. getOptions() {
  348. return Array.from(this._customHyperLinks.values()).map(({ option: n }) => n);
  349. }
  350. findCustomHyperLink(n) {
  351. return Array.from(this._customHyperLinks.values()).find((r) => r.match(n));
  352. }
  353. registerCustomHyperLink(n) {
  354. this._customHyperLinks.set(n.type, n);
  355. }
  356. getCustomHyperLink(n) {
  357. return this._customHyperLinks.get(n);
  358. }
  359. removeCustomHyperLink(n) {
  360. const { _customHyperLinks: i } = this;
  361. i.delete(n);
  362. }
  363. dispose() {
  364. super.dispose(), this._customHyperLinks.clear();
  365. }
  366. }
  367. const ki = "univer-cell-link-edit", Ti = "univer-cell-link-edit-buttons", _n = {
  368. cellLinkEdit: ki,
  369. cellLinkEditButtons: Ti
  370. }, ze = () => {
  371. var Ft;
  372. const [t, e] = X(""), [n, i] = X(!1), [r, o] = X(""), [s, c] = X(!0), [l, p] = X(S.URL), [u, g] = X(""), d = E(ct), v = E(On), C = E(re), _ = E(Y), O = E(K), a = Jr(O.currentEditing$), b = E(kt), M = E(pe), k = E(ie), L = E(jn), j = pn(() => L.getOptions(), [L]), D = E(pt), q = E($e), Ee = E(wr), je = E(De), se = E(bn), Re = E(or), Le = E(De), Pe = bt({}), oe = pn(() => {
  373. if (!L.isBuiltInLinkType(l))
  374. return L.getCustomHyperLink(l);
  375. }, [L, l]), [A, Jn] = X(!1), [be, gt] = X(!1), H = bt(!1), V = _.getCurrentUnitForType(w.UNIVER_SHEET), Xn = (V == null ? void 0 : V.getActiveSheet().getSheetId()) || "", Q = mi((h) => {
  376. o(h.replaceAll(on.CUSTOM_RANGE_START, "").replaceAll(on.CUSTOM_RANGE_END, ""));
  377. }, [o]);
  378. ne(() => {
  379. var h, y, I, P, N, F, Wt, Zt, Gt, Kt, Yt, zt, qt, Jt, Xt, Qt, en;
  380. if ((a == null ? void 0 : a.row) !== void 0 && a.col !== void 0) {
  381. const { customRange: ae, row: vt, col: St } = a;
  382. let { label: J } = a;
  383. typeof J == "number" && (J = `${J}`);
  384. let W;
  385. if (ae)
  386. W = {
  387. id: (h = ae == null ? void 0 : ae.rangeId) != null ? h : "",
  388. display: J != null ? J : "",
  389. payload: (I = (y = ae == null ? void 0 : ae.properties) == null ? void 0 : y.url) != null ? I : "",
  390. row: vt,
  391. column: St
  392. };
  393. else if (a.type === m.VIEWING) {
  394. const T = _.getUnit(a.unitId), te = T == null ? void 0 : T.getSheetBySheetId(a.subUnitId), U = te == null ? void 0 : te.getCellRaw(a.row, a.col), me = (F = (N = (P = U == null ? void 0 : U.p) == null ? void 0 : P.body) == null ? void 0 : N.customRanges) == null ? void 0 : F.find((nn) => {
  395. var rn;
  396. return nn.rangeType === Ge.HYPERLINK && ((rn = nn.properties) == null ? void 0 : rn.url);
  397. }), we = U == null ? void 0 : U.v;
  398. U && (!Se.transform.isEmptyDocument((Zt = (Wt = U.p) == null ? void 0 : Wt.body) == null ? void 0 : Zt.dataStream) || Ce.isDefine(we)) && c(!1), W = {
  399. id: "",
  400. display: "",
  401. payload: (Kt = (Gt = me == null ? void 0 : me.properties) == null ? void 0 : Gt.url) != null ? Kt : "",
  402. row: vt,
  403. column: St
  404. };
  405. } else {
  406. const T = _.getCurrentUnitForType(w.UNIVER_DOC), te = je.getActiveTextRange(), U = T == null ? void 0 : T.getBody(), me = te && U ? te : null, we = me && ((zt = Se.customRange.getCustomRangesInterestsWithSelection(me, (Yt = U == null ? void 0 : U.customRanges) != null ? Yt : [])) == null ? void 0 : zt[0]);
  407. c(!1), W = {
  408. id: "",
  409. display: J != null ? J : "",
  410. payload: (Jt = (qt = we == null ? void 0 : we.properties) == null ? void 0 : qt.url) != null ? Jt : "",
  411. row: vt,
  412. column: St
  413. };
  414. }
  415. e(W.id);
  416. const tn = L.findCustomHyperLink(W);
  417. if (tn) {
  418. const T = tn.convert(W);
  419. p(T.type), g(T.payload), Q(T.display);
  420. return;
  421. }
  422. Q(W.display);
  423. const ee = b.parseHyperLink(W.payload);
  424. switch (p(ee.type === S.INVALID ? S.RANGE : ee.type), ee.type) {
  425. case S.URL: {
  426. g(ee.url), ee.url === W.display && (H.current = !0);
  427. break;
  428. }
  429. case S.RANGE: {
  430. const T = ee.searchObj, te = T.gid && (en = (Qt = (Xt = _.getUnit(a.unitId)) == null ? void 0 : Xt.getSheetBySheetId(T.gid)) == null ? void 0 : Qt.getName()) != null ? en : "", U = $r(te, Fe(T.range).range);
  431. g(U), U === W.display && (H.current = !0);
  432. break;
  433. }
  434. case S.SHEET: {
  435. const T = ee.searchObj;
  436. g(T.gid);
  437. break;
  438. }
  439. case S.DEFINE_NAME: {
  440. const T = ee.searchObj;
  441. g(T.rangeid);
  442. break;
  443. }
  444. default:
  445. g("");
  446. break;
  447. }
  448. }
  449. }, [a, M, L, je, _]), ne(() => {
  450. let h = null;
  451. if (a && !a.customRangeId && a.type === m.VIEWING && Ce.isDefine(a.row) && Ce.isDefine(a.col)) {
  452. const y = _.getUnit(a.unitId, w.UNIVER_SHEET), I = y == null ? void 0 : y.getSheetBySheetId(a.subUnitId), P = I == null ? void 0 : I.getMergedCell(a.row, a.col), N = new ar(Re.getCurrentTheme().hyacinth500).toRgb();
  453. h = Ee.addShape(
  454. {
  455. range: P != null ? P : {
  456. startColumn: a.col,
  457. endColumn: a.col,
  458. startRow: a.row,
  459. endRow: a.row
  460. },
  461. style: {
  462. // hasAutoFill: false,
  463. fill: `rgb(${N.r}, ${N.g}, ${N.b}, 0.12)`,
  464. strokeWidth: 1,
  465. stroke: "#FFBD37",
  466. widgets: {}
  467. },
  468. primary: null
  469. },
  470. [],
  471. -1
  472. );
  473. }
  474. return () => {
  475. h && Ee.removeShape(h);
  476. };
  477. }, [a, Ee, Re, _]), ne(() => {
  478. gt(l === S.RANGE);
  479. }, [l]), ne(() => {
  480. const h = (a == null ? void 0 : a.type) === m.ZEN_EDITOR ? q.getRenderById(x) : q.getRenderById(C.getCurrentEditorId()), y = new cr();
  481. if (h) {
  482. const I = h.with(Dn);
  483. I.setReserveRangesStatus(!0), y.add(() => {
  484. I.setReserveRangesStatus(!1);
  485. });
  486. }
  487. return () => {
  488. C.disableForceKeepVisible(), y.dispose();
  489. };
  490. }, [a == null ? void 0 : a.type, C, q]), ne(() => (O.setIsKeepVisible(be), () => {
  491. O.setIsKeepVisible(!1);
  492. }), [be, O]), ne(() => () => {
  493. D.temporaryHidden && (D.show(), se.setContextValue(Ct, !1));
  494. }, [se, D]), ne(() => {
  495. if (be)
  496. return C.enableForceKeepVisible(), () => {
  497. C.disableForceKeepVisible();
  498. };
  499. }, [be, C]);
  500. const Qn = [
  501. {
  502. label: d.t("hyperLink.form.link"),
  503. value: S.URL
  504. },
  505. {
  506. label: d.t("hyperLink.form.range"),
  507. value: S.RANGE
  508. },
  509. {
  510. label: d.t("hyperLink.form.worksheet"),
  511. value: S.SHEET
  512. },
  513. {
  514. label: d.t("hyperLink.form.definedName"),
  515. value: S.DEFINE_NAME
  516. },
  517. ...j
  518. ];
  519. if (!V)
  520. return;
  521. const er = V.getHiddenWorksheets(), ft = V.getSheets().map((h) => ({ label: h.getName(), value: h.getSheetId() })).filter((h) => er.indexOf(h.value) === -1), mt = Object.values((Ft = v.getDefinedNameMap(V.getUnitId())) != null ? Ft : {}).map((h) => ({
  522. label: h.name,
  523. value: h.id
  524. })), Vt = (h, y) => {
  525. if (h === S.URL)
  526. return Ci(y);
  527. if (h === S.RANGE) {
  528. const I = Fe(y), P = V.getSheetBySheetName(I.sheetName);
  529. if (P)
  530. return `#gid=${P.getSheetId()}&range=${Ar(I.range)}`;
  531. }
  532. return `#${h}=${y}`;
  533. }, tr = Xr((h) => {
  534. var N;
  535. const I = h.split(",").map(Fe)[0];
  536. if (!I || !Rn(I.range))
  537. return;
  538. I.sheetName || (I.sheetName = ((N = V.getActiveSheet()) == null ? void 0 : N.getName()) || "");
  539. const P = jr(I);
  540. g(P), P && (H.current || !r) && (Q(P), H.current = !0);
  541. }), _t = async () => {
  542. if (s && !r || !u || l === S.URL && !Ke(u)) {
  543. Jn(!0);
  544. return;
  545. }
  546. if (a)
  547. if (t) {
  548. const h = a.type === m.ZEN_EDITOR || a.type === m.EDITING ? _r.id : vr.id;
  549. await k.executeCommand(h, {
  550. id: t,
  551. unitId: a.unitId,
  552. subUnitId: a.subUnitId,
  553. payload: {
  554. display: s ? r : "",
  555. payload: Vt(l, u)
  556. },
  557. row: a.row,
  558. column: a.col,
  559. documentId: a.type === m.ZEN_EDITOR ? x : C.getCurrentEditorId()
  560. });
  561. } else {
  562. const h = a.type === m.ZEN_EDITOR || a.type === m.EDITING ? Sr.id : Cr.id;
  563. await k.executeCommand(h, {
  564. unitId: a.unitId,
  565. subUnitId: a.subUnitId,
  566. link: {
  567. id: lr(),
  568. row: a.row,
  569. column: a.col,
  570. payload: Vt(l, u),
  571. display: s ? r : ""
  572. },
  573. documentId: a.type === m.ZEN_EDITOR ? x : C.getCurrentEditorId()
  574. });
  575. }
  576. if ((a == null ? void 0 : a.type) === m.VIEWING) {
  577. await k.executeCommand(Tn.id, {
  578. unitId: a.unitId,
  579. subUnitId: a.subUnitId
  580. });
  581. const h = 1;
  582. await k.executeCommand(wn.id, {
  583. range: {
  584. startRow: Math.max(a.row - h, 0),
  585. endRow: a.row + h,
  586. startColumn: Math.max(a.col - h, 0),
  587. endColumn: a.col + h
  588. }
  589. });
  590. }
  591. k.executeCommand(Je.id);
  592. }, nr = (h) => {
  593. var I;
  594. if (l !== S.RANGE)
  595. return;
  596. const y = (I = Pe.current) == null ? void 0 : I.handleOutClick;
  597. y && y(h, () => gt(!1));
  598. };
  599. return a ? /* @__PURE__ */ f.jsxs("div", { className: _n.cellLinkEdit, style: { display: n ? "none" : "block" }, onClick: nr, children: [
  600. s ? /* @__PURE__ */ f.jsx(
  601. _e,
  602. {
  603. label: d.t("hyperLink.form.label"),
  604. error: A && !r ? d.t("hyperLink.form.inputError") : "",
  605. children: /* @__PURE__ */ f.jsx(
  606. cn,
  607. {
  608. value: r,
  609. onChange: (h) => {
  610. Q(h), H.current = !1;
  611. },
  612. placeholder: d.t("hyperLink.form.labelPlaceholder"),
  613. autoFocus: !0,
  614. onKeyDown: (h) => {
  615. h.keyCode === Pt.ENTER && _t();
  616. }
  617. }
  618. )
  619. }
  620. ) : null,
  621. /* @__PURE__ */ f.jsx(_e, { label: d.t("hyperLink.form.type"), children: /* @__PURE__ */ f.jsx(
  622. yt,
  623. {
  624. options: Qn,
  625. value: l,
  626. onChange: (h) => {
  627. p(h), g("");
  628. }
  629. }
  630. ) }),
  631. l === S.URL && /* @__PURE__ */ f.jsx(
  632. _e,
  633. {
  634. error: A ? u ? Ke(u) ? "" : d.t("hyperLink.form.linkError") : d.t("hyperLink.form.inputError") : "",
  635. children: /* @__PURE__ */ f.jsx(
  636. cn,
  637. {
  638. value: u,
  639. onChange: (h) => {
  640. g(h), h && (H.current || !r || r === u) && (Q(h), H.current = !0);
  641. },
  642. placeholder: d.t("hyperLink.form.linkPlaceholder"),
  643. autoFocus: !0,
  644. onKeyDown: (h) => {
  645. h.keyCode === Pt.ENTER && _t();
  646. }
  647. }
  648. )
  649. }
  650. ),
  651. l === S.RANGE && /* @__PURE__ */ f.jsx(_e, { error: A && !u ? d.t("hyperLink.form.inputError") : "", children: /* @__PURE__ */ f.jsx(
  652. _i,
  653. {
  654. unitId: V.getUnitId(),
  655. subUnitId: Xn,
  656. isOnlyOneRange: !0,
  657. isSupportAcrossSheet: !0,
  658. initValue: u,
  659. onChange: tr,
  660. isFocus: be,
  661. onFocus: () => gt(!0),
  662. actions: Pe.current,
  663. onRangeSelectorDialogVisibleChange: async (h) => {
  664. var y, I;
  665. if (h)
  666. a.type === m.ZEN_EDITOR && (D.hide(), se.setContextValue(Ct, !0)), a.type !== m.VIEWING && C.enableForceKeepVisible(), i(!0);
  667. else {
  668. if (await M.navigateToRange(a.unitId, a.subUnitId, { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col }, !0), a.type === m.ZEN_EDITOR) {
  669. await k.executeCommand(kn.id, {
  670. unitId: a.unitId,
  671. subUnitId: a.subUnitId,
  672. selections: [{ range: { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col } }]
  673. }), D.show(), se.setContextValue(Ct, !1);
  674. const P = (y = q.getRenderById(x)) == null ? void 0 : y.with(oi), N = (I = Le.getTextRanges({ unitId: x, subUnitId: x })) == null ? void 0 : I[0];
  675. P && N && (P.scrollToRange(N), Le.refreshSelection({ unitId: x, subUnitId: x }));
  676. }
  677. C.disableForceKeepVisible(), i(!1);
  678. }
  679. }
  680. }
  681. ) }),
  682. l === S.SHEET && /* @__PURE__ */ f.jsx(_e, { error: A && !u ? d.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ f.jsx(
  683. yt,
  684. {
  685. options: ft,
  686. value: u,
  687. onChange: (h) => {
  688. var P, N;
  689. g(h);
  690. const y = (P = ft.find((F) => F.value === h)) == null ? void 0 : P.label, I = (N = ft.find((F) => F.value === u)) == null ? void 0 : N.label;
  691. y && (H.current || !r || r === I) && (Q(y), H.current = !0);
  692. }
  693. }
  694. ) }),
  695. l === S.DEFINE_NAME && /* @__PURE__ */ f.jsx(_e, { error: A && !u ? d.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ f.jsx(
  696. yt,
  697. {
  698. options: mt,
  699. value: u,
  700. onChange: (h) => {
  701. var P, N;
  702. g(h);
  703. const y = (P = mt.find((F) => F.value === h)) == null ? void 0 : P.label, I = (N = mt.find((F) => F.value === u)) == null ? void 0 : N.label;
  704. y && (H.current || !r || r === I) && (Q(y), H.current = !0);
  705. }
  706. }
  707. ) }),
  708. (oe == null ? void 0 : oe.Form) && /* @__PURE__ */ f.jsx(
  709. oe.Form,
  710. {
  711. linkId: t,
  712. payload: u,
  713. display: r,
  714. showError: A,
  715. setByPayload: H,
  716. setDisplay: (h) => {
  717. Q(h), H.current = !0;
  718. },
  719. setPayload: g
  720. }
  721. ),
  722. /* @__PURE__ */ f.jsxs("div", { className: _n.cellLinkEditButtons, children: [
  723. /* @__PURE__ */ f.jsx(
  724. ln,
  725. {
  726. onClick: () => {
  727. a && M.navigateToRange(a.unitId, a.subUnitId, { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col }, !0), k.executeCommand(Je.id);
  728. },
  729. children: d.t("hyperLink.form.cancel")
  730. }
  731. ),
  732. /* @__PURE__ */ f.jsx(
  733. ln,
  734. {
  735. type: "primary",
  736. style: { marginLeft: 8 },
  737. onClick: async () => {
  738. _t();
  739. },
  740. children: d.t("hyperLink.form.ok")
  741. }
  742. )
  743. ] })
  744. ] }) : null;
  745. };
  746. ze.componentKey = "univer.sheet.cell-link-edit";
  747. var $ = function() {
  748. return $ = Object.assign || function(t) {
  749. for (var e, n = 1, i = arguments.length; n < i; n++) {
  750. e = arguments[n];
  751. for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]);
  752. }
  753. return t;
  754. }, $.apply(this, arguments);
  755. }, xi = function(t, e) {
  756. var n = {};
  757. for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]);
  758. if (t != null && typeof Object.getOwnPropertySymbols == "function")
  759. for (var r = 0, i = Object.getOwnPropertySymbols(t); r < i.length; r++)
  760. e.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, i[r]) && (n[i[r]] = t[i[r]]);
  761. return n;
  762. }, fe = he(function(t, e) {
  763. var n = t.icon, i = t.id, r = t.className, o = t.extend, s = xi(t, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(i, " ").concat(r || "").trim(), l = bt("_".concat(Ui()));
  764. return An(n, "".concat(i), { defIds: n.defIds, idSuffix: l.current }, $({ ref: e, className: c }, s), o);
  765. });
  766. function An(t, e, n, i, r) {
  767. return ge(t.tag, $($({ key: e }, Ni(t, n, r)), i), (Mi(t, n).children || []).map(function(o, s) {
  768. return An(o, "".concat(e, "-").concat(t.tag, "-").concat(s), n, void 0, r);
  769. }));
  770. }
  771. function Ni(t, e, n) {
  772. var i = $({}, t.attrs);
  773. n != null && n.colorChannel1 && i.fill === "colorChannel1" && (i.fill = n.colorChannel1);
  774. var r = e.defIds;
  775. return !r || r.length === 0 || (t.tag === "use" && i["xlink:href"] && (i["xlink:href"] = i["xlink:href"] + e.idSuffix), Object.entries(i).forEach(function(o) {
  776. var s = o[0], c = o[1];
  777. typeof c == "string" && (i[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
  778. })), i;
  779. }
  780. function Mi(t, e) {
  781. var n, i = e.defIds;
  782. return !i || i.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ? $($({}, t), { children: t.children.map(function(r) {
  783. return typeof r.attrs.id == "string" && i && i.indexOf(r.attrs.id) > -1 ? $($({}, r), { attrs: $($({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
  784. }) }) : t;
  785. }
  786. function Ui() {
  787. return Math.random().toString(36).substring(2, 8);
  788. }
  789. fe.displayName = "UniverIcon";
  790. var Hi = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Ze = he(function(t, e) {
  791. return ge(fe, Object.assign({}, t, {
  792. id: "all-border-single",
  793. ref: e,
  794. icon: Hi
  795. }));
  796. });
  797. Ze.displayName = "AllBorderSingle";
  798. var Di = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Bn = he(function(t, e) {
  799. return ge(fe, Object.assign({}, t, {
  800. id: "copy-single",
  801. ref: e,
  802. icon: Di
  803. }));
  804. });
  805. Bn.displayName = "CopySingle";
  806. var $i = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z" } }] }, Dt = he(function(t, e) {
  807. return ge(fe, Object.assign({}, t, {
  808. id: "link-single",
  809. ref: e,
  810. icon: $i
  811. }));
  812. });
  813. Dt.displayName = "LinkSingle";
  814. var ji = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z" } }] }, Vn = he(function(t, e) {
  815. return ge(fe, Object.assign({}, t, {
  816. id: "unlink-single",
  817. ref: e,
  818. icon: ji
  819. }));
  820. });
  821. Vn.displayName = "UnlinkSingle";
  822. var Ai = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z" } }] }, Fn = he(function(t, e) {
  823. return ge(fe, Object.assign({}, t, {
  824. id: "write-single",
  825. ref: e,
  826. icon: Ai
  827. }));
  828. });
  829. Fn.displayName = "WriteSingle";
  830. var Bi = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "#35BD4B", d: "M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z" } }, { tag: "path", attrs: { fill: "#32A846", d: "M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z" } }, { tag: "path", attrs: { fill: "#fff", d: "M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Wn = he(function(t, e) {
  831. return ge(fe, Object.assign({}, t, {
  832. id: "xlsx",
  833. ref: e,
  834. icon: Bi
  835. }));
  836. });
  837. Wn.displayName = "Xlsx";
  838. function Zn(t) {
  839. var e, n, i = "";
  840. if (typeof t == "string" || typeof t == "number") i += t;
  841. else if (typeof t == "object") if (Array.isArray(t)) {
  842. var r = t.length;
  843. for (e = 0; e < r; e++) t[e] && (n = Zn(t[e])) && (i && (i += " "), i += n);
  844. } else for (n in t) t[n] && (i && (i += " "), i += n);
  845. return i;
  846. }
  847. function vn() {
  848. for (var t, e, n = 0, i = "", r = arguments.length; n < r; n++) (t = arguments[n]) && (e = Zn(t)) && (i && (i += " "), i += e);
  849. return i;
  850. }
  851. const Vi = "univer-cell-link", Fi = "univer-cell-link-type", Wi = "univer-cell-link-content", Zi = "univer-cell-link-content-error", Gi = "univer-cell-link-url", Ki = "univer-cell-link-operations", Yi = "univer-cell-link-operation", zi = "univer-cell-link-operation-error", Z = {
  852. cellLink: Vi,
  853. cellLinkType: Fi,
  854. cellLinkContent: Wi,
  855. cellLinkContentError: Zi,
  856. cellLinkUrl: Gi,
  857. cellLinkOperations: Ki,
  858. cellLinkOperation: Yi,
  859. cellLinkOperationError: zi
  860. }, qi = {
  861. [S.URL]: /* @__PURE__ */ f.jsx(Dt, {}),
  862. [S.SHEET]: /* @__PURE__ */ f.jsx(Wn, {}),
  863. [S.RANGE]: /* @__PURE__ */ f.jsx(Ze, {}),
  864. [S.DEFINE_NAME]: /* @__PURE__ */ f.jsx(Ze, {}),
  865. [S.INVALID]: /* @__PURE__ */ f.jsx(Ze, {})
  866. }, Sn = (t) => {
  867. var M, k;
  868. const e = E(K), n = E(ie), i = E(Un), r = E(ct), o = E(pe), s = E(re), c = E(kt), l = E(pt), { customRange: p, row: u, col: g, unitId: d, subUnitId: v, editPermission: C, copyPermission: _, type: O } = t;
  869. if (!((M = p == null ? void 0 : p.properties) != null && M.url))
  870. return null;
  871. const a = c.parseHyperLink((k = p.properties.url) != null ? k : ""), b = a.type === S.INVALID;
  872. return /* @__PURE__ */ f.jsxs("div", { className: Z.cellLink, onClick: () => e.hideCurrentPopup(), children: [
  873. /* @__PURE__ */ f.jsxs(
  874. "div",
  875. {
  876. className: vn(Z.cellLinkContent, { [Z.cellLinkContentError]: b }),
  877. onClick: () => {
  878. l.visible || b || o.navigate(a);
  879. },
  880. children: [
  881. /* @__PURE__ */ f.jsx("div", { className: Z.cellLinkType, children: qi[a.type] }),
  882. /* @__PURE__ */ f.jsx(Be, { showIfEllipsis: !0, title: a.name, asChild: !0, children: /* @__PURE__ */ f.jsx("span", { className: Z.cellLinkUrl, children: a.name }) })
  883. ]
  884. }
  885. ),
  886. /* @__PURE__ */ f.jsxs("div", { className: Z.cellLinkOperations, children: [
  887. _ && /* @__PURE__ */ f.jsx(
  888. "div",
  889. {
  890. className: vn(Z.cellLinkOperation, { [Z.cellLinkOperationError]: b }),
  891. onClick: () => {
  892. if (!b) {
  893. if (a.type !== S.URL) {
  894. const L = new URL(window.location.href);
  895. L.hash = a.url.slice(1), navigator.clipboard.writeText(L.href);
  896. } else
  897. navigator.clipboard.writeText(a.url);
  898. i.show({
  899. content: r.t("hyperLink.message.coped"),
  900. type: xe.Info
  901. });
  902. }
  903. },
  904. children: /* @__PURE__ */ f.jsx(Be, { placement: "bottom", title: r.t("hyperLink.popup.copy"), children: /* @__PURE__ */ f.jsx(Bn, {}) })
  905. }
  906. ),
  907. C && /* @__PURE__ */ f.jsxs(f.Fragment, { children: [
  908. /* @__PURE__ */ f.jsx(
  909. "div",
  910. {
  911. className: Z.cellLinkOperation,
  912. onClick: () => {
  913. n.executeCommand(jt.id, {
  914. unitId: d,
  915. subUnitId: v,
  916. row: u,
  917. col: g,
  918. customRangeId: p.rangeId,
  919. type: O
  920. });
  921. },
  922. children: /* @__PURE__ */ f.jsx(Be, { placement: "bottom", title: r.t("hyperLink.popup.edit"), children: /* @__PURE__ */ f.jsx(Fn, {}) })
  923. }
  924. ),
  925. /* @__PURE__ */ f.jsx(
  926. "div",
  927. {
  928. className: Z.cellLinkOperation,
  929. onClick: () => {
  930. const L = O === m.EDITING || O === m.ZEN_EDITOR ? Ir.id : yr.id;
  931. n.syncExecuteCommand(L, {
  932. unitId: d,
  933. subUnitId: v,
  934. id: p.rangeId,
  935. row: u,
  936. column: g,
  937. documentId: O === m.ZEN_EDITOR ? x : s.getCurrentEditorId()
  938. }) && e.hideCurrentPopup(void 0, !0);
  939. },
  940. children: /* @__PURE__ */ f.jsx(Be, { placement: "bottom", title: r.t("hyperLink.popup.cancel"), children: /* @__PURE__ */ f.jsx(Vn, {}) })
  941. }
  942. )
  943. ] })
  944. ] })
  945. ] });
  946. }, qe = () => {
  947. var r, o;
  948. const t = E(K), [e, n] = X(null), i = E(Y);
  949. if (ne(() => {
  950. n(t.currentPopup);
  951. const s = t.currentPopup$.subscribe((c) => {
  952. n(c);
  953. });
  954. return () => {
  955. s.unsubscribe();
  956. };
  957. }, [t.currentPopup, t.currentPopup$]), !e)
  958. return null;
  959. if (e.showAll) {
  960. const s = i.getUnit(e.unitId, w.UNIVER_SHEET), c = s == null ? void 0 : s.getSheetBySheetId(e.subUnitId), l = c == null ? void 0 : c.getCell(e.row, e.col), p = (o = (r = l == null ? void 0 : l.p) == null ? void 0 : r.body) == null ? void 0 : o.customRanges;
  961. return p != null && p.length ? /* @__PURE__ */ f.jsx("div", { children: p.map((u) => /* @__PURE__ */ f.jsx(Sn, { ...e, customRange: u }, u.rangeId)) }) : null;
  962. }
  963. return /* @__PURE__ */ f.jsx(Sn, { ...e });
  964. };
  965. qe.componentKey = "univer.sheet.cell-link-popup";
  966. var Ji = Object.defineProperty, Xi = Object.getOwnPropertyDescriptor, Qi = (t, e, n, i) => {
  967. for (var r = i > 1 ? void 0 : i ? Xi(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  968. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  969. return i && r && Ji(e, n, r), r;
  970. }, ce = (t, e) => (n, i) => e(n, i, t);
  971. const Cn = (t, e) => {
  972. var n, i;
  973. return t.unitId === e.unitId && t.subUnitId === e.subUnitId && t.row === e.row && t.col === e.col && ((n = t.customRange) == null ? void 0 : n.rangeId) === ((i = e.customRange) == null ? void 0 : i.rangeId) && t.type === e.type;
  974. };
  975. let K = class extends z {
  976. constructor(e, n, i, r, o, s, c) {
  977. super();
  978. B(this, "_currentPopup", null);
  979. B(this, "_currentPopup$", new ui());
  980. B(this, "currentPopup$", this._currentPopup$.asObservable());
  981. B(this, "_currentEditingPopup", null);
  982. B(this, "_currentEditing$", new di(null));
  983. B(this, "currentEditing$", this._currentEditing$.asObservable());
  984. B(this, "_isKeepVisible", !1);
  985. this._sheetCanvasPopManagerService = e, this._injector = n, this._univerInstanceService = i, this._editorBridgeService = r, this._textSelectionManagerService = o, this._docCanvasPopManagerService = s, this._zenZoneService = c, this.disposeWithMe(() => {
  986. this.hideCurrentPopup(), this.endEditing(), this._currentEditing$.complete(), this._currentPopup$.complete();
  987. });
  988. }
  989. get currentPopup() {
  990. return this._currentPopup;
  991. }
  992. get currentEditing() {
  993. return this._currentEditing$.getValue();
  994. }
  995. setIsKeepVisible(e) {
  996. this._isKeepVisible = e;
  997. }
  998. getIsKeepVisible() {
  999. return this._isKeepVisible;
  1000. }
  1001. showPopup(e) {
  1002. if (this._currentPopup && Cn(e, this._currentPopup) || (this.hideCurrentPopup(void 0, !0), e.type !== m.ZEN_EDITOR && this._zenZoneService.visible))
  1003. return;
  1004. const n = this._currentEditing$.getValue();
  1005. if (n && Cn(e, n))
  1006. return;
  1007. const { unitId: i, subUnitId: r, row: o, col: s, customRangeRect: c, customRange: l } = e;
  1008. let p;
  1009. const u = {
  1010. componentKey: qe.componentKey,
  1011. direction: "bottom",
  1012. onClickOutside: () => {
  1013. this.hideCurrentPopup();
  1014. },
  1015. onClick: () => {
  1016. this.hideCurrentPopup(e.type, !0);
  1017. }
  1018. };
  1019. if (e.type === m.EDITING) {
  1020. if (!l)
  1021. return;
  1022. p = c && this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
  1023. c,
  1024. u
  1025. );
  1026. } else if (e.type === m.ZEN_EDITOR) {
  1027. if (!l)
  1028. return;
  1029. p = this._docCanvasPopManagerService.attachPopupToRange(
  1030. {
  1031. startOffset: l.startIndex,
  1032. endOffset: l.endIndex + 1,
  1033. collapsed: !1
  1034. },
  1035. u,
  1036. x
  1037. );
  1038. } else if (e.showAll)
  1039. p = this._sheetCanvasPopManagerService.attachPopupToCell(e.row, e.col, u, i, r);
  1040. else {
  1041. if (!l)
  1042. return;
  1043. p = c && this._sheetCanvasPopManagerService.attachPopupByPosition(
  1044. c,
  1045. u,
  1046. e
  1047. );
  1048. }
  1049. p && (this._currentPopup = {
  1050. unitId: i,
  1051. subUnitId: r,
  1052. disposable: p,
  1053. row: o,
  1054. col: s,
  1055. editPermission: !!e.editPermission,
  1056. copyPermission: !!e.copyPermission,
  1057. customRange: l,
  1058. type: e.type,
  1059. showAll: e.showAll
  1060. }, this._currentPopup$.next(this._currentPopup));
  1061. }
  1062. hideCurrentPopup(e, n) {
  1063. var i, r;
  1064. this._currentPopup && ((!e || e === this._currentPopup.type) && this._currentPopup.disposable.canDispose() || n) && ((r = (i = this._currentPopup) == null ? void 0 : i.disposable) == null || r.dispose(), this._currentPopup = null, this._currentPopup$.next(null));
  1065. }
  1066. _getEditingRange() {
  1067. var i, r, o;
  1068. const e = this._editorBridgeService.isVisible().visible, n = this._editorBridgeService.getEditCellState();
  1069. if (e && n) {
  1070. const s = this._textSelectionManagerService.getActiveTextRange(), c = (i = n.documentLayoutObject.documentModel) == null ? void 0 : i.getBody();
  1071. if (!c)
  1072. return null;
  1073. if (!s || s.collapsed)
  1074. return {
  1075. startOffset: 0,
  1076. endOffset: c.dataStream.length - 2,
  1077. collapsed: c.dataStream.length - 2 === 0,
  1078. label: Se.transform.getPlainText(c.dataStream)
  1079. };
  1080. const l = Se.customRange.getCustomRangesInterestsWithSelection(s, (o = (r = c.customRanges) == null ? void 0 : r.filter((g) => g.rangeType === Ge.HYPERLINK)) != null ? o : []);
  1081. let p = s.startOffset, u = s.endOffset;
  1082. return l.forEach((g) => {
  1083. p = Math.min(p, g.startIndex), u = Math.max(u, g.endIndex + 1);
  1084. }), {
  1085. startOffset: p,
  1086. endOffset: u,
  1087. collapsed: p === u,
  1088. label: Se.transform.getPlainText(c.dataStream.slice(p, u))
  1089. };
  1090. }
  1091. return null;
  1092. }
  1093. get _editPopup() {
  1094. return {
  1095. componentKey: ze.componentKey,
  1096. direction: "vertical",
  1097. onClickOutside: () => {
  1098. this.getIsKeepVisible() || this.endEditing();
  1099. },
  1100. onContextMenu: () => {
  1101. this.getIsKeepVisible() || this.endEditing();
  1102. },
  1103. hiddenType: "hide"
  1104. };
  1105. }
  1106. startAddEditing(e) {
  1107. var o, s, c, l, p;
  1108. const { unitId: n, subUnitId: i, type: r } = e;
  1109. if (r === m.ZEN_EDITOR) {
  1110. const u = this._univerInstanceService.getUnit(x, w.UNIVER_DOC);
  1111. if (!u)
  1112. return;
  1113. const g = this._textSelectionManagerService.getActiveTextRange();
  1114. if (!g)
  1115. return;
  1116. this._currentEditingPopup = this._docCanvasPopManagerService.attachPopupToRange(
  1117. g,
  1118. this._editPopup,
  1119. x
  1120. );
  1121. const d = (o = u.getBody()) == null ? void 0 : o.dataStream.slice(g.startOffset, g.endOffset);
  1122. this._currentEditing$.next({
  1123. ...e,
  1124. label: d
  1125. });
  1126. } else if (r === m.EDITING) {
  1127. const u = this._getEditingRange();
  1128. if (!u)
  1129. return;
  1130. this._textSelectionManagerService.replaceDocRanges([{ ...u }], { unitId: Ie, subUnitId: Ie });
  1131. const g = this._injector.get($e).getRenderById(Ie);
  1132. if (!g)
  1133. return;
  1134. const d = ci(u, g);
  1135. if (!(d != null && d.length))
  1136. return;
  1137. this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
  1138. d.pop(),
  1139. this._editPopup,
  1140. n,
  1141. i
  1142. ), this._currentEditing$.next({
  1143. ...e,
  1144. label: (s = u == null ? void 0 : u.label) != null ? s : ""
  1145. });
  1146. } else {
  1147. this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell(
  1148. e.row,
  1149. e.col,
  1150. this._editPopup,
  1151. n,
  1152. i
  1153. );
  1154. const u = this._univerInstanceService.getUnit(n, w.UNIVER_SHEET), g = u == null ? void 0 : u.getSheetBySheetId(i), d = g == null ? void 0 : g.getCellRaw(e.row, e.col);
  1155. this._currentEditing$.next({
  1156. ...e,
  1157. label: d != null && d.p ? Se.transform.getPlainText((l = (c = d.p.body) == null ? void 0 : c.dataStream) != null ? l : "") : ((p = d == null ? void 0 : d.v) != null ? p : "").toString()
  1158. });
  1159. }
  1160. }
  1161. // eslint-disable-next-line complexity, max-lines-per-function
  1162. startEditing(e) {
  1163. var s, c, l, p, u, g;
  1164. (s = this._currentEditingPopup) == null || s.dispose(), this.hideCurrentPopup(void 0, !0);
  1165. const { unitId: n, subUnitId: i } = e;
  1166. let r, o;
  1167. if (e.type === m.ZEN_EDITOR) {
  1168. const d = this._univerInstanceService.getUnit(x, w.UNIVER_DOC);
  1169. if (r = (l = (c = d == null ? void 0 : d.getBody()) == null ? void 0 : c.customRanges) == null ? void 0 : l.find((v) => v.rangeId === e.customRangeId), o = r ? (p = d == null ? void 0 : d.getBody()) == null ? void 0 : p.dataStream.slice(r.startIndex, r.endIndex + 1) : "", !r || !o)
  1170. return;
  1171. this._textSelectionManagerService.replaceTextRanges([
  1172. {
  1173. startOffset: r.startIndex,
  1174. endOffset: r.endIndex + 1
  1175. }
  1176. ]), this._currentEditingPopup = this._docCanvasPopManagerService.attachPopupToRange(
  1177. {
  1178. startOffset: r.startIndex,
  1179. endOffset: r.endIndex,
  1180. collapsed: !1
  1181. },
  1182. this._editPopup,
  1183. x
  1184. );
  1185. } else if (e.type === m.EDITING) {
  1186. const d = kr(this._injector, e.unitId, e.subUnitId, e.row, e.col, e.customRangeId);
  1187. if (!d || !((u = d.rects) != null && u.length))
  1188. return;
  1189. r = d.customRange, o = d.label, this._textSelectionManagerService.replaceTextRanges([
  1190. {
  1191. startOffset: r.startIndex,
  1192. endOffset: r.endIndex + 1
  1193. }
  1194. ]), this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
  1195. d.rects.pop(),
  1196. this._editPopup,
  1197. n,
  1198. i
  1199. );
  1200. } else {
  1201. const d = this._univerInstanceService.getUnit(n, w.UNIVER_SHEET), v = d == null ? void 0 : d.getSheetBySheetId(i), C = v == null ? void 0 : v.getCellRaw(e.row, e.col), _ = d == null ? void 0 : d.getStyles().getStyleByCell(C), O = _ == null ? void 0 : _.tr, a = Tr(this._injector, e.unitId, e.subUnitId, e.row, e.col, e.customRangeId);
  1202. if (!a || !((g = a.rects) != null && g.length))
  1203. return;
  1204. r = a.customRange, o = a.label, O ? this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell(
  1205. e.row,
  1206. e.col,
  1207. this._editPopup,
  1208. n,
  1209. i
  1210. ) : this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupByPosition(
  1211. a.rects.pop(),
  1212. this._editPopup,
  1213. {
  1214. unitId: n,
  1215. subUnitId: i,
  1216. row: e.row,
  1217. col: e.col
  1218. }
  1219. );
  1220. }
  1221. this._currentEditing$.next({
  1222. ...e,
  1223. customRange: r,
  1224. label: o
  1225. });
  1226. }
  1227. endEditing(e) {
  1228. var i;
  1229. const n = this._currentEditing$.getValue();
  1230. n && (!e || e === n.type) && ((i = this._currentEditingPopup) == null || i.dispose(), this._currentEditing$.next(null));
  1231. }
  1232. };
  1233. K = Qi([
  1234. ce(0, R(Or)),
  1235. ce(1, R(lt)),
  1236. ce(2, Y),
  1237. ce(3, re),
  1238. ce(4, R(De)),
  1239. ce(5, R(ai)),
  1240. ce(6, pt)
  1241. ], K);
  1242. var Me = /* @__PURE__ */ ((t) => (t[t.ALLOWED = 0] = "ALLOWED", t[t.DISABLED_BY_CELL = 1] = "DISABLED_BY_CELL", t[t.ALLOW_ON_EDITING = 2] = "ALLOW_ON_EDITING", t))(Me || {});
  1243. const es = /* @__PURE__ */ new Set([
  1244. It.CHECKBOX,
  1245. It.LIST,
  1246. It.LIST_MULTIPLE
  1247. ]), $t = (t, e, n, i) => {
  1248. var c, l;
  1249. const r = e.getCell(n, i);
  1250. if (r != null && r.f || r != null && r.si)
  1251. return 1;
  1252. const o = t.has(hn) ? t.get(hn) : null, s = o == null ? void 0 : o.getRuleByLocation(e.getUnitId(), e.getSheetId(), n, i);
  1253. return s && es.has(s.type) ? !0 : (l = (c = r == null ? void 0 : r.p) == null ? void 0 : c.drawingsOrder) != null && l.length ? 2 : 0;
  1254. }, ts = (t) => {
  1255. const e = t.get(Y).getCurrentUnitForType(w.UNIVER_SHEET);
  1256. if (!e)
  1257. return !0;
  1258. const n = e.getActiveSheet(), i = t.get(Tt).getCurrentSelections();
  1259. if (!i.length)
  1260. return !0;
  1261. const r = i[0].range.startRow, o = i[0].range.startColumn;
  1262. return $t(t, n, r, o) === 1;
  1263. }, ns = (t) => {
  1264. const e = t.get(De), n = t.get(Y), i = e.getTextRanges();
  1265. if (!(i != null && i.length))
  1266. return !0;
  1267. const r = n.getCurrentUnitForType(w.UNIVER_DOC);
  1268. return !!(!r || i.every((s) => s.collapsed) || !r.getSelfOrHeaderFooterModel(i[0].segmentId).getBody());
  1269. }, jt = {
  1270. type: ut.OPERATION,
  1271. id: "sheet.operation.open-hyper-link-edit-panel",
  1272. handler(t, e) {
  1273. if (!e)
  1274. return !1;
  1275. const n = t.get(K);
  1276. return e.customRangeId ? n.startEditing(e) : n.startAddEditing(e), !0;
  1277. }
  1278. }, Je = {
  1279. type: ut.OPERATION,
  1280. id: "sheet.operation.close-hyper-link-popup",
  1281. handler(t) {
  1282. return t.get(K).endEditing(), !0;
  1283. }
  1284. }, At = {
  1285. type: ut.OPERATION,
  1286. id: "sheet.operation.insert-hyper-link",
  1287. handler(t) {
  1288. var g;
  1289. const e = t.get(Y), n = xn(e), i = t.get(re);
  1290. if (!n)
  1291. return !1;
  1292. const r = t.get(ie), s = t.get(Tt).getCurrentLastSelection();
  1293. if (!s)
  1294. return !1;
  1295. const c = s.range.startRow, l = s.range.startColumn, p = i.isVisible(), u = ((g = e.getFocusedUnit()) == null ? void 0 : g.getUnitId()) === x;
  1296. return r.executeCommand(jt.id, {
  1297. unitId: n.unitId,
  1298. subUnitId: n.subUnitId,
  1299. row: c,
  1300. col: l,
  1301. type: u ? m.ZEN_EDITOR : p.visible ? m.EDITING : m.VIEWING
  1302. });
  1303. }
  1304. }, de = {
  1305. type: ut.OPERATION,
  1306. id: "sheet.operation.insert-hyper-link-toolbar",
  1307. handler(t) {
  1308. if (ts(t))
  1309. return !1;
  1310. const e = t.get(ie);
  1311. return t.get(K).currentEditing ? e.executeCommand(Je.id) : e.executeCommand(At.id);
  1312. }
  1313. }, Bt = (t, e = x) => {
  1314. var r;
  1315. const n = t.get(Y), i = (r = t.get($e).getRenderById(e)) == null ? void 0 : r.with(Dn);
  1316. return i ? i.textSelectionInner$.pipe(le(() => {
  1317. const s = t.get(re).getEditCellState();
  1318. if (!s)
  1319. return !0;
  1320. const c = xn(n, { unitId: s.unitId, subUnitId: s.sheetId });
  1321. return !(c != null && c.worksheet) || $t(t, c.worksheet, s.row, s.column) === 1 ? !0 : ns(t);
  1322. })) : Ne(!0);
  1323. }, Gn = (t) => {
  1324. const e = Nr(t, { workbookTypes: [xt], worksheetTypes: [Nt, Nn, Mt], rangeTypes: [Ut] }, !0), n = t.get(Y), i = t.get(Tt), r = t.has(re) ? t.get(re) : null, o = n.focused$.pipe(
  1325. dn((s) => !!s),
  1326. le((s) => n.getUnit(s, w.UNIVER_SHEET)),
  1327. dn((s) => !!s),
  1328. ue((s) => s.activeSheet$),
  1329. ue((s) => i.selectionMoveEnd$.pipe(le((c) => s && { selections: c, sheet: s }))),
  1330. le((s) => {
  1331. if (!s)
  1332. return Me.DISABLED_BY_CELL;
  1333. const { selections: c, sheet: l } = s;
  1334. if (!c.length)
  1335. return Me.DISABLED_BY_CELL;
  1336. const p = c[0].range.startRow, u = c[0].range.startColumn;
  1337. return $t(t, l, p, u);
  1338. }),
  1339. ue((s) => {
  1340. if (s === Me.DISABLED_BY_CELL)
  1341. return Ne(!0);
  1342. const c = (r ? r.visible$ : Ne(null)).pipe(le((p) => p != null && p.visible ? Ie : void 0)), l = t.get(bn).subscribeContextValue$(ur);
  1343. return pi([c, l]).pipe(
  1344. ue(
  1345. ([p, u]) => p ? u ? Ne(!0) : Bt(t, p) : Ne(s === Me.ALLOW_ON_EDITING)
  1346. )
  1347. );
  1348. })
  1349. );
  1350. return e.pipe(
  1351. hi(),
  1352. ue((s) => o.pipe(le((c) => s || c)))
  1353. );
  1354. }, Xe = {
  1355. commandId: At.id,
  1356. type: Hn.BUTTON,
  1357. title: "hyperLink.menu.add",
  1358. icon: "LinkSingle"
  1359. }, Qe = (t) => `${t}-zen-editor`, rs = (t) => ({
  1360. ...Xe,
  1361. id: Xe.commandId,
  1362. hidden$: ht(t, w.UNIVER_SHEET),
  1363. disabled$: Gn(t)
  1364. // disabled$: getObservableWithExclusiveRange$(accessor, getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })),
  1365. }), is = (t) => ({
  1366. ...Xe,
  1367. id: Qe(Xe.commandId),
  1368. hidden$: ht(t, w.UNIVER_DOC, x),
  1369. disabled$: Bt(t)
  1370. }), et = {
  1371. tooltip: "hyperLink.form.addTitle",
  1372. commandId: de.id,
  1373. type: Hn.BUTTON,
  1374. icon: "LinkSingle"
  1375. }, ss = (t) => ({
  1376. ...et,
  1377. id: et.commandId,
  1378. hidden$: ht(t, w.UNIVER_SHEET),
  1379. disabled$: Gn(t)
  1380. }), os = (t) => ({
  1381. ...et,
  1382. id: Qe(et.commandId),
  1383. hidden$: ht(t, w.UNIVER_DOC, x),
  1384. disabled$: Bt(t)
  1385. }), Kn = {
  1386. id: de.id,
  1387. binding: Pt.K | Qr.CTRL_COMMAND,
  1388. preconditions: xr
  1389. };
  1390. var as = Object.defineProperty, cs = Object.getOwnPropertyDescriptor, ls = (t, e, n, i) => {
  1391. for (var r = i > 1 ? void 0 : i ? cs(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  1392. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  1393. return i && r && as(e, n, r), r;
  1394. }, In = (t, e) => (n, i) => e(n, i, t);
  1395. let tt = class extends z {
  1396. constructor(t, e) {
  1397. super(), this._autoFillService = t, this._hyperLinkModel = e, this._initAutoFill();
  1398. }
  1399. // eslint-disable-next-line max-lines-per-function
  1400. _initAutoFill() {
  1401. const t = () => ({ redos: [], undos: [] }), e = (i, r) => {
  1402. const { source: o, target: s, unitId: c, subUnitId: l } = i, p = Lt([o, s]), [u, g] = p.ranges, { mapFunc: d } = p, v = {
  1403. row: u.startRow,
  1404. col: u.startColumn
  1405. }, C = Ur(u, g), _ = [], O = [];
  1406. return C.forEach((a) => {
  1407. const b = a.repeatStartCell, M = a.relativeRange, k = {
  1408. startRow: v.row,
  1409. startColumn: v.col,
  1410. endColumn: v.col,
  1411. endRow: v.row
  1412. }, L = {
  1413. startRow: b.row,
  1414. startColumn: b.col,
  1415. endColumn: b.col,
  1416. endRow: b.row
  1417. };
  1418. Pn.foreach(M, (j, D) => {
  1419. const q = ye.getPositionRange(
  1420. {
  1421. startRow: j,
  1422. startColumn: D,
  1423. endColumn: D,
  1424. endRow: j
  1425. },
  1426. k
  1427. ), { row: Ee, col: je } = d(q.startRow, q.startColumn), se = this._hyperLinkModel.getHyperLinkByLocation(c, l, Ee, je), Re = ye.getPositionRange(
  1428. {
  1429. startRow: j,
  1430. startColumn: D,
  1431. endColumn: D,
  1432. endRow: j
  1433. },
  1434. L
  1435. ), { row: Le, col: Pe } = d(Re.startRow, Re.startColumn), oe = Ce.generateRandomId(), A = this._hyperLinkModel.getHyperLinkByLocation(c, l, Le, Pe);
  1436. A && _.push({
  1437. id: Ue.id,
  1438. params: {
  1439. unitId: c,
  1440. subUnitId: l,
  1441. id: A.id
  1442. }
  1443. }), (Oe.COPY === r || Oe.SERIES === r) && se && (_.push({
  1444. id: He.id,
  1445. params: {
  1446. unitId: c,
  1447. subUnitId: l,
  1448. link: {
  1449. ...se,
  1450. id: oe,
  1451. row: Le,
  1452. column: Pe
  1453. }
  1454. }
  1455. }), O.push({
  1456. id: Ue.id,
  1457. params: {
  1458. unitId: c,
  1459. subUnitId: l,
  1460. id: oe
  1461. }
  1462. })), A && O.push({
  1463. id: He.id,
  1464. params: {
  1465. unitId: c,
  1466. subUnitId: l,
  1467. link: A
  1468. }
  1469. });
  1470. });
  1471. }), {
  1472. undos: O,
  1473. redos: _
  1474. };
  1475. }, n = {
  1476. id: Ht,
  1477. onFillData: (i, r, o) => o === Oe.COPY || o === Oe.ONLY_FORMAT || o === Oe.SERIES ? e(i, o) : t()
  1478. };
  1479. this.disposeWithMe(this._autoFillService.addHook(n));
  1480. }
  1481. };
  1482. tt = ls([
  1483. In(0, Mr),
  1484. In(1, R(dt))
  1485. ], tt);
  1486. var us = Object.defineProperty, ds = Object.getOwnPropertyDescriptor, ps = (t, e, n, i) => {
  1487. for (var r = i > 1 ? void 0 : i ? ds(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  1488. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  1489. return i && r && us(e, n, r), r;
  1490. }, Rt = (t, e) => (n, i) => e(n, i, t);
  1491. let nt = class extends z {
  1492. constructor(t, e, n) {
  1493. super(), this._localeService = t, this._commandService = e, this._sheetPermissionCheckController = n, this._commandExecutedListener();
  1494. }
  1495. _commandExecutedListener() {
  1496. this.disposeWithMe(
  1497. this._commandService.beforeCommandExecuted((t) => {
  1498. t.id === Kn.id && (this._sheetPermissionCheckController.permissionCheckWithRanges({
  1499. workbookTypes: [xt],
  1500. rangeTypes: [Ut],
  1501. worksheetTypes: [Nt, Nn, Mt]
  1502. }) || this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.hyperLinkErr")));
  1503. })
  1504. );
  1505. }
  1506. };
  1507. nt = ps([
  1508. Rt(0, R(ct)),
  1509. Rt(1, ie),
  1510. Rt(2, R(Mn))
  1511. ], nt);
  1512. var hs = Object.defineProperty, gs = Object.getOwnPropertyDescriptor, fs = (t, e, n, i) => {
  1513. for (var r = i > 1 ? void 0 : i ? gs(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  1514. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  1515. return i && r && hs(e, n, r), r;
  1516. }, G = (t, e) => (n, i) => e(n, i, t);
  1517. let rt = class extends z {
  1518. constructor(t, e, n, i, r, o, s, c, l, p) {
  1519. super(), this._hoverManagerService = t, this._sheetsHyperLinkPopupService = e, this._renderManagerService = n, this._permissionService = i, this._sheetPermissionCheckController = r, this._commandService = o, this._editorBridgeService = s, this._textSelectionManagerService = c, this._univerInstanceService = l, this._zenZoneService = p, this._initHoverListener(), this._initCommandListener(), this._initHoverEditingListener(), this._initTextSelectionListener(), this._initZenEditor();
  1520. }
  1521. _getLinkPermission(t) {
  1522. const { unitId: e, subUnitId: n, row: i, col: r } = t, o = this._univerInstanceService.getUnit(e, w.UNIVER_SHEET);
  1523. if (!(o == null ? void 0 : o.getSheetBySheetId(n)))
  1524. return {
  1525. viewPermission: !1,
  1526. editPermission: !1,
  1527. copyPermission: !1
  1528. };
  1529. const c = this._sheetPermissionCheckController.permissionCheckWithRanges({
  1530. workbookTypes: [Br],
  1531. worksheetTypes: [Vr],
  1532. rangeTypes: [Fr]
  1533. }, [{ startRow: i, startColumn: r, endRow: i, endColumn: r }]), l = this._sheetPermissionCheckController.permissionCheckWithRanges({
  1534. workbookTypes: [xt],
  1535. worksheetTypes: [Nt, Mt],
  1536. rangeTypes: [Ut]
  1537. }, [{ startRow: i, startColumn: r, endRow: i, endColumn: r }]), p = this._permissionService.composePermission([new Wr(e).id, new Zr(e, n).id]).every((u) => u.value);
  1538. return {
  1539. viewPermission: c,
  1540. editPermission: l,
  1541. copyPermission: p
  1542. };
  1543. }
  1544. _initHoverListener() {
  1545. this.disposeWithMe(
  1546. // hover over not editing cell
  1547. this._hoverManagerService.currentRichText$.pipe(We(200)).subscribe((t) => {
  1548. var k, L;
  1549. if (!t) {
  1550. this._sheetsHyperLinkPopupService.hideCurrentPopup();
  1551. return;
  1552. }
  1553. const { unitId: e, subUnitId: n, row: i, col: r } = t, o = this._renderManagerService.getRenderById(e);
  1554. if (!o)
  1555. return;
  1556. const s = this._univerInstanceService.getUnit(e, w.UNIVER_SHEET), c = s == null ? void 0 : s.getSheetBySheetId(n);
  1557. if (!c)
  1558. return;
  1559. if (!o.with(Dr).active) {
  1560. this._sheetsHyperLinkPopupService.hideCurrentPopup(m.VIEWING);
  1561. return;
  1562. }
  1563. const p = (k = o == null ? void 0 : o.with(an).getWorksheetSkeleton(n)) == null ? void 0 : k.skeleton, u = r, g = i;
  1564. let d = g, v = u;
  1565. p && p.overflowCache.forValue((j, D, q) => {
  1566. ye.contains(q, { startColumn: u, endColumn: u, startRow: g, endRow: g }) && (d = j, v = D);
  1567. });
  1568. const { viewPermission: C, editPermission: _, copyPermission: O } = this._getLinkPermission(t);
  1569. if (!C) {
  1570. this._sheetsHyperLinkPopupService.hideCurrentPopup();
  1571. return;
  1572. }
  1573. const a = c.getCellStyleOnly(d, v), b = s.getStyles().getStyleByCell(a), M = (L = b == null ? void 0 : b.tr) == null ? void 0 : L.a;
  1574. if (!M && !t.customRange) {
  1575. this._sheetsHyperLinkPopupService.hideCurrentPopup();
  1576. return;
  1577. }
  1578. this._sheetsHyperLinkPopupService.showPopup({
  1579. row: d,
  1580. col: v,
  1581. editPermission: _,
  1582. copyPermission: O,
  1583. customRange: t.customRange,
  1584. customRangeRect: t.rect,
  1585. type: m.VIEWING,
  1586. unitId: e,
  1587. subUnitId: n,
  1588. showAll: !!M
  1589. });
  1590. })
  1591. );
  1592. }
  1593. _initHoverEditingListener() {
  1594. let t = null;
  1595. this.disposeWithMe(
  1596. this._editorBridgeService.currentEditCellState$.pipe(ue((e) => this._editorBridgeService.visible$.pipe(le((n) => ({ visible: n, state: e }))))).subscribe(({ visible: e, state: n }) => {
  1597. if (!n || n.editorUnitId !== Ie)
  1598. return;
  1599. if (!e.visible) {
  1600. t == null || t.unsubscribe(), this._sheetsHyperLinkPopupService.hideCurrentPopup(m.EDITING), this._sheetsHyperLinkPopupService.endEditing(m.EDITING);
  1601. return;
  1602. }
  1603. const { editorUnitId: i, unitId: r, sheetId: o, row: s, column: c } = n, l = this._renderManagerService.getRenderById(i);
  1604. if (!l)
  1605. return;
  1606. const { editPermission: p, viewPermission: u, copyPermission: g } = this._getLinkPermission({ unitId: r, subUnitId: o, row: s, col: c }), d = l.with(un);
  1607. u && (t == null || t.unsubscribe(), t = d.hoverCustomRanges$.pipe(We(200)).subscribe((v) => {
  1608. var b, M;
  1609. const C = v.find((k) => k.range.rangeType === Ge.HYPERLINK);
  1610. if (!C) {
  1611. this._sheetsHyperLinkPopupService.hideCurrentPopup();
  1612. return;
  1613. }
  1614. const _ = C.rects[C.rects.length - 1];
  1615. if (!((M = (b = this._renderManagerService.getRenderById(r)) == null ? void 0 : b.with(an).getWorksheetSkeleton(o)) == null ? void 0 : M.skeleton) || !_)
  1616. return;
  1617. const a = l.engine.getCanvasElement().getBoundingClientRect();
  1618. this._sheetsHyperLinkPopupService.showPopup({
  1619. unitId: r,
  1620. subUnitId: o,
  1621. row: s,
  1622. col: c,
  1623. customRange: C.range,
  1624. customRangeRect: {
  1625. left: _.left + a.left,
  1626. top: _.top + a.top,
  1627. bottom: _.bottom + a.top,
  1628. right: _.right + a.left
  1629. },
  1630. editPermission: p,
  1631. copyPermission: g,
  1632. type: m.EDITING
  1633. });
  1634. }));
  1635. })
  1636. ), this.disposeWithMe(() => {
  1637. t == null || t.unsubscribe();
  1638. });
  1639. }
  1640. _initZenEditor() {
  1641. this.disposeWithMe(
  1642. this._zenZoneService.visible$.subscribe((t) => {
  1643. t ? (this._sheetsHyperLinkPopupService.hideCurrentPopup(m.VIEWING), this._sheetsHyperLinkPopupService.hideCurrentPopup(m.EDITING), this._sheetsHyperLinkPopupService.endEditing(m.EDITING), this._sheetsHyperLinkPopupService.hideCurrentPopup(m.VIEWING)) : (this._sheetsHyperLinkPopupService.hideCurrentPopup(m.ZEN_EDITOR), this._sheetsHyperLinkPopupService.endEditing(m.ZEN_EDITOR));
  1644. })
  1645. ), this.disposeWithMe(
  1646. this._univerInstanceService.focused$.pipe(
  1647. ue((t) => {
  1648. const e = t === x ? this._renderManagerService.getRenderById(t) : null;
  1649. return e ? e.with(un).hoverCustomRanges$.pipe(We(200)) : new gi((n) => {
  1650. n.next(null);
  1651. });
  1652. })
  1653. ).subscribe((t) => {
  1654. const e = t == null ? void 0 : t.find((i) => i.range.rangeType === Ge.HYPERLINK), n = this._editorBridgeService.getEditCellState();
  1655. if (e && n) {
  1656. const { unitId: i, sheetId: r, row: o, column: s } = n, { editPermission: c, viewPermission: l, copyPermission: p } = this._getLinkPermission({ unitId: i, subUnitId: r, row: o, col: s });
  1657. l && this._sheetsHyperLinkPopupService.showPopup({
  1658. type: m.ZEN_EDITOR,
  1659. unitId: i,
  1660. subUnitId: r,
  1661. row: o,
  1662. col: s,
  1663. customRange: e.range,
  1664. editPermission: c,
  1665. copyPermission: p
  1666. });
  1667. } else
  1668. this._sheetsHyperLinkPopupService.hideCurrentPopup(m.ZEN_EDITOR);
  1669. })
  1670. );
  1671. }
  1672. _initTextSelectionListener() {
  1673. this.disposeWithMe(
  1674. this._textSelectionManagerService.textSelection$.subscribe((t) => {
  1675. t && t.unitId === Ie && this._sheetsHyperLinkPopupService.endEditing(m.EDITING);
  1676. })
  1677. );
  1678. }
  1679. _initCommandListener() {
  1680. const t = [Gr.id, Kr.id, Yr.id];
  1681. this.disposeWithMe(this._commandService.onCommandExecuted((e) => {
  1682. t.includes(e.id) && this._sheetsHyperLinkPopupService.hideCurrentPopup();
  1683. }));
  1684. }
  1685. };
  1686. rt = fs([
  1687. G(0, R(Hr)),
  1688. G(1, R(K)),
  1689. G(2, R($e)),
  1690. G(3, R(dr)),
  1691. G(4, R(Mn)),
  1692. G(5, ie),
  1693. G(6, re),
  1694. G(7, R(De)),
  1695. G(8, Y),
  1696. G(9, pt)
  1697. ], rt);
  1698. var ms = Object.defineProperty, _s = Object.getOwnPropertyDescriptor, Yn = (t, e, n, i) => {
  1699. for (var r = i > 1 ? void 0 : i ? _s(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  1700. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  1701. return i && r && ms(e, n, r), r;
  1702. }, wt = (t, e) => (n, i) => e(n, i, t);
  1703. let Ot = class extends z {
  1704. constructor(t, e) {
  1705. super(), this._context = t, this._hyperLinkModel = e, this._initSkeletonChange();
  1706. }
  1707. _initSkeletonChange() {
  1708. const t = () => {
  1709. var e;
  1710. (e = this._context.mainComponent) == null || e.makeForceDirty();
  1711. };
  1712. this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(We(16)).subscribe(() => {
  1713. t();
  1714. }));
  1715. }
  1716. };
  1717. Ot = Yn([
  1718. wt(1, R(dt))
  1719. ], Ot);
  1720. let it = class extends z {
  1721. constructor(t, e) {
  1722. super(), this._sheetInterceptorService = t, this._hyperLinkModel = e, this._initViewModelIntercept();
  1723. }
  1724. _initViewModelIntercept() {
  1725. this.disposeWithMe(
  1726. this._sheetInterceptorService.intercept(
  1727. qr.CELL_CONTENT,
  1728. {
  1729. effect: pr.Value,
  1730. priority: 100,
  1731. handler: (t, e, n) => {
  1732. const { row: i, col: r, unitId: o, subUnitId: s } = e, c = this._hyperLinkModel.getHyperLinkByLocation(o, s, i, r);
  1733. return n(c ? {
  1734. ...t,
  1735. linkUrl: c.payload,
  1736. linkId: c.id
  1737. } : t);
  1738. }
  1739. }
  1740. )
  1741. );
  1742. }
  1743. };
  1744. it = Yn([
  1745. wt(0, R(zr)),
  1746. wt(1, R(dt))
  1747. ], it);
  1748. const vs = {
  1749. [ei.OTHERS]: {
  1750. [de.id]: {
  1751. order: 2,
  1752. menuItemFactory: ss
  1753. },
  1754. [Qe(de.id)]: {
  1755. order: 2,
  1756. menuItemFactory: os
  1757. }
  1758. },
  1759. [ti.MAIN_AREA]: {
  1760. [ni.OTHERS]: {
  1761. order: 1,
  1762. [de.id]: {
  1763. order: 0,
  1764. menuItemFactory: rs
  1765. },
  1766. [Qe(de.id)]: {
  1767. order: 0,
  1768. menuItemFactory: is
  1769. }
  1770. }
  1771. }
  1772. };
  1773. var Ss = Object.defineProperty, Cs = Object.getOwnPropertyDescriptor, Is = (t, e, n, i) => {
  1774. for (var r = i > 1 ? void 0 : i ? Cs(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  1775. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  1776. return i && r && Ss(e, n, r), r;
  1777. }, Te = (t, e) => (n, i) => e(n, i, t);
  1778. let st = class extends z {
  1779. constructor(t, e, n, i, r) {
  1780. super(), this._componentManager = t, this._commandService = e, this._menuManagerService = n, this._injector = i, this._shortcutService = r, this._initComponents(), this._initCommands(), this._initMenus(), this._initShortCut();
  1781. }
  1782. _initComponents() {
  1783. [
  1784. [qe, qe.componentKey],
  1785. [ze, ze.componentKey],
  1786. [Dt, "LinkSingle"]
  1787. ].forEach(([t, e]) => {
  1788. this._componentManager.register(e, t);
  1789. });
  1790. }
  1791. _initCommands() {
  1792. [
  1793. jt,
  1794. Je,
  1795. At,
  1796. de
  1797. ].forEach((t) => {
  1798. this._commandService.registerCommand(t);
  1799. });
  1800. }
  1801. _initMenus() {
  1802. this._menuManagerService.mergeMenu(vs);
  1803. }
  1804. _initShortCut() {
  1805. this._shortcutService.registerShortcut(Kn);
  1806. }
  1807. };
  1808. st = Is([
  1809. Te(0, R(ri)),
  1810. Te(1, ie),
  1811. Te(2, si),
  1812. Te(3, R(lt)),
  1813. Te(4, R(ii))
  1814. ], st);
  1815. var ys = Object.defineProperty, Es = Object.getOwnPropertyDescriptor, Rs = (t, e, n, i) => {
  1816. for (var r = i > 1 ? void 0 : i ? Es(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  1817. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  1818. return i && r && ys(e, n, r), r;
  1819. }, yn = (t, e) => (n, i) => e(n, i, t);
  1820. let ot = class extends z {
  1821. constructor(t, e) {
  1822. super(), this._parserService = t, this._resolverService = e, this._handleInitUrl();
  1823. }
  1824. _handleInitUrl() {
  1825. const t = location.hash;
  1826. if (t) {
  1827. const e = this._parserService.parseHyperLink(t);
  1828. this._resolverService.navigate(e);
  1829. }
  1830. }
  1831. };
  1832. ot = Rs([
  1833. yn(0, R(kt)),
  1834. yn(1, R(pe))
  1835. ], ot);
  1836. var zn = Object.defineProperty, Ls = Object.getOwnPropertyDescriptor, Ps = (t, e, n) => e in t ? zn(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, bs = (t, e, n, i) => {
  1837. for (var r = i > 1 ? void 0 : i ? Ls(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  1838. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  1839. return i && r && zn(e, n, r), r;
  1840. }, En = (t, e) => (n, i) => e(n, i, t), qn = (t, e, n) => Ps(t, typeof e != "symbol" ? e + "" : e, n);
  1841. let at = class extends gr {
  1842. constructor(t = gn, e, n) {
  1843. super(), this._config = t, this._injector = e, this._configService = n;
  1844. const { menu: i, ...r } = fr(
  1845. {},
  1846. gn,
  1847. this._config
  1848. );
  1849. i && this._configService.setConfig("menu", i, { merge: !0 }), this._configService.setConfig($n, r);
  1850. }
  1851. onStarting() {
  1852. [
  1853. [pe],
  1854. [K],
  1855. [jn],
  1856. [it],
  1857. [rt],
  1858. [st],
  1859. [tt],
  1860. [Ye],
  1861. [nt],
  1862. [ot]
  1863. ].forEach((e) => this._injector.add(e)), this._injector.get(it);
  1864. }
  1865. onReady() {
  1866. this._injector.get($e).registerRenderModule(w.UNIVER_SHEET, [Ot]), this._injector.get(tt), this._injector.get(Ye), this._injector.get(st);
  1867. }
  1868. onRendered() {
  1869. this._injector.get(nt), this._injector.get(ot), this._injector.get(rt);
  1870. }
  1871. };
  1872. qn(at, "pluginName", Ht);
  1873. qn(at, "type", w.UNIVER_SHEET);
  1874. at = bs([
  1875. hr(Er, li),
  1876. En(1, R(lt)),
  1877. En(2, Ln)
  1878. ], at);
  1879. export {
  1880. Je as CloseHyperLinkPopupOperation,
  1881. At as InsertHyperLinkOperation,
  1882. Kn as InsertLinkShortcut,
  1883. jt as OpenHyperLinkEditPanelOperation,
  1884. Ye as SheetsHyperLinkCopyPasteController,
  1885. K as SheetsHyperLinkPopupService,
  1886. pe as SheetsHyperLinkResolverService,
  1887. jn as SheetsHyperLinkSidePanelService,
  1888. at as UniverSheetsHyperLinkUIPlugin
  1889. };