chunk-S7YN35PX.js 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132
  1. import {
  2. At,
  3. Bt,
  4. I,
  5. O,
  6. Q,
  7. Tt,
  8. U,
  9. Wt,
  10. ae,
  11. jt,
  12. k,
  13. xt,
  14. ye
  15. } from "./chunk-4SXJQ6MB.js";
  16. import {
  17. F as F2
  18. } from "./chunk-Q35HEJKG.js";
  19. import {
  20. Ei
  21. } from "./chunk-U3EPM6JO.js";
  22. import {
  23. De as De2,
  24. Er,
  25. Hr,
  26. Sn,
  27. Ys,
  28. _s,
  29. el,
  30. gr,
  31. iE,
  32. ke,
  33. lf,
  34. me,
  35. oE,
  36. rt,
  37. sE,
  38. tE,
  39. tt,
  40. ue,
  41. vi,
  42. ws
  43. } from "./chunk-T4NNB5UY.js";
  44. import {
  45. Co,
  46. F,
  47. Hn,
  48. Io,
  49. Js,
  50. Ls,
  51. Me,
  52. N,
  53. Nn,
  54. Pe,
  55. So,
  56. Te,
  57. V,
  58. Xs,
  59. an,
  60. et,
  61. or,
  62. po,
  63. re as re2,
  64. wn
  65. } from "./chunk-BW43Z7N3.js";
  66. import {
  67. fn,
  68. fr,
  69. pc,
  70. pr,
  71. ys
  72. } from "./chunk-QRYBFJ3R.js";
  73. import {
  74. Gn as Gn2,
  75. Se,
  76. gs,
  77. is,
  78. kn,
  79. ko
  80. } from "./chunk-MIOQ566M.js";
  81. import {
  82. $e,
  83. Ae,
  84. Fa,
  85. He,
  86. I1,
  87. P1,
  88. it,
  89. l1,
  90. m1,
  91. n1,
  92. n3,
  93. o3,
  94. u3
  95. } from "./chunk-POAJ2YNP.js";
  96. import {
  97. Gf,
  98. HO,
  99. Po,
  100. QC,
  101. Xw,
  102. r_
  103. } from "./chunk-GBYP4PB2.js";
  104. import {
  105. m
  106. } from "./chunk-PZD7N4BC.js";
  107. import {
  108. Yx
  109. } from "./chunk-2MK3Q52E.js";
  110. import {
  111. BehaviorSubject,
  112. De,
  113. Fe,
  114. Gn,
  115. Hd,
  116. Il,
  117. Mi,
  118. Nt,
  119. OR,
  120. Observable,
  121. Ot,
  122. Pt,
  123. Ra,
  124. SC,
  125. SE,
  126. Subject,
  127. UE,
  128. Vn,
  129. Vr,
  130. W0,
  131. _n,
  132. aE,
  133. ar,
  134. combineLatest,
  135. debounceTime,
  136. distinctUntilChanged,
  137. en,
  138. filter,
  139. fs,
  140. kt,
  141. ln,
  142. map,
  143. ml,
  144. mn,
  145. nt,
  146. nu,
  147. of,
  148. ot,
  149. qt,
  150. re,
  151. st,
  152. su,
  153. switchMap,
  154. tr,
  155. z0
  156. } from "./chunk-23V3HWTR.js";
  157. import {
  158. require_react
  159. } from "./chunk-GNR2UJZM.js";
  160. import {
  161. __toESM
  162. } from "./chunk-2LSFTFF7.js";
  163. // node_modules/.pnpm/@univerjs+sheets-hyper-link-ui@0.5.5_@grpc+grpc-js@1.13.4_react-dom@18.3.1_react@18.3.1_rxjs@7.8.1_typescript@5.4.5/node_modules/@univerjs/sheets-hyper-link-ui/lib/es/index.js
  164. var import_react = __toESM(require_react());
  165. var rr = Object.defineProperty;
  166. var ir = (t, e, n) => e in t ? rr(t, e, { enumerable: true, configurable: true, writable: true, value: n }) : t[e] = n;
  167. var B = (t, e, n) => ir(t, typeof e != "symbol" ? e + "" : e, n);
  168. function Ke(t) {
  169. return re.isLegalUrl(t);
  170. }
  171. function vi2(t) {
  172. return /^[a-zA-Z]+:\/\//.test(t);
  173. }
  174. function Si(t) {
  175. return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t);
  176. }
  177. function Ci(t) {
  178. if (Ke(t)) {
  179. const e = vi2(t) ? t : Si(t) ? `mailto://${t}` : `http://${t}`;
  180. let n;
  181. try {
  182. n = new URL(e);
  183. } catch {
  184. return t;
  185. }
  186. return n.hostname === location.hostname && n.port === location.port && n.protocol === location.protocol && n.pathname === location.pathname && n.hash && !n.search ? n.hash : e;
  187. }
  188. return t;
  189. }
  190. var $n = "sheets-hyper-link-ui.config";
  191. var gn = {};
  192. var Ii = Object.defineProperty;
  193. var yi = Object.getOwnPropertyDescriptor;
  194. var Ei2 = (t, e, n, i) => {
  195. for (var r = i > 1 ? void 0 : i ? yi(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  196. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  197. return i && r && Ii(e, n, r), r;
  198. };
  199. var ve = (t, e) => (n, i) => e(n, i, t);
  200. function Ri(t, e) {
  201. const n = e.getMergeData(), i = e.getMaxColumns() - 1, r = e.getMaxRows() - 1;
  202. if (i < t.endColumn && (t.endColumn = i), r < t.endRow && (t.endRow = r), t.rangeType === De.COLUMN || De.ROW)
  203. return t;
  204. const o = [];
  205. return n.forEach((s) => {
  206. en.intersects(t, s) && o.push(s);
  207. }), en.realUnion(t, ...o);
  208. }
  209. var pe = class {
  210. constructor(t, e, n, i, r, o) {
  211. this._univerInstanceService = t, this._commandService = e, this._definedNamesService = n, this._messageService = i, this._localeService = r, this._configService = o;
  212. }
  213. navigate(t) {
  214. switch (t.type) {
  215. case U.URL:
  216. this.navigateToOtherWebsite(t.url);
  217. break;
  218. default:
  219. this._navigateToUniver(t.searchObj);
  220. }
  221. }
  222. _navigateToUniver(t) {
  223. const { gid: e, range: n, rangeid: i } = t, r = this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET);
  224. if (!r)
  225. return;
  226. const o = r.getUnitId();
  227. if (i) {
  228. const s = this._definedNamesService.getValueById(o, i);
  229. if (!s)
  230. return;
  231. const { formulaOrRefString: c } = s, l = this._definedNamesService.getWorksheetByRef(o, c);
  232. if (!l) {
  233. this._messageService.show({
  234. content: this._localeService.t("hyperLink.message.refError"),
  235. type: Xw.Error
  236. });
  237. return;
  238. }
  239. if (l.isSheetHidden()) {
  240. this._messageService.show({
  241. content: this._localeService.t("hyperLink.message.hiddenSheet"),
  242. type: Xw.Error
  243. });
  244. return;
  245. }
  246. this.navigateToDefineName(o, i);
  247. }
  248. if (e) {
  249. if (n) {
  250. const s = fn(n);
  251. SC(s.range) && n !== Q && this.navigateToRange(o, e, s.range);
  252. return;
  253. }
  254. this.navigateToSheetById(o, e);
  255. }
  256. }
  257. async navigateToRange(t, e, n, i) {
  258. const r = await this.navigateToSheetById(t, e);
  259. if (r) {
  260. const o = Ri(n, r);
  261. await this._commandService.executeCommand(
  262. re2.id,
  263. {
  264. unitId: t,
  265. subUnitId: e,
  266. selections: [{
  267. range: o,
  268. primary: null
  269. }]
  270. }
  271. ), await this._commandService.executeCommand(lf.id, {
  272. range: o,
  273. forceTop: i
  274. });
  275. }
  276. }
  277. async navigateToSheetById(t, e) {
  278. const n = this._univerInstanceService.getUnit(t, Fe.UNIVER_SHEET);
  279. if (!n)
  280. return false;
  281. const i = n.getActiveSheet();
  282. if (!i)
  283. return false;
  284. if (i.getSheetId() === e)
  285. return i;
  286. const r = n.getSheetBySheetId(e);
  287. return r ? n.getHiddenWorksheets().indexOf(e) > -1 ? (this._messageService.show({
  288. content: this._localeService.t("hyperLink.message.hiddenSheet"),
  289. type: Xw.Error
  290. }), false) : await this._commandService.executeCommand(an.id, { unitId: t, subUnitId: e }) ? r : false : (this._messageService.show({
  291. content: this._localeService.t("hyperLink.message.noSheet"),
  292. type: Xw.Error
  293. }), false);
  294. }
  295. async navigateToDefineName(t, e) {
  296. return this._definedNamesService.focusRange(t, e), true;
  297. }
  298. async navigateToOtherWebsite(t) {
  299. var n;
  300. const e = this._configService.getConfig($n);
  301. if ((n = e == null ? void 0 : e.urlHandler) != null && n.navigateToOtherWebsite)
  302. return e.urlHandler.navigateToOtherWebsite(t);
  303. window.open(t, "_blank", "noopener noreferrer");
  304. }
  305. };
  306. pe = Ei2([
  307. ve(0, _n),
  308. ve(1, Pt),
  309. ve(2, pr),
  310. ve(3, o3),
  311. ve(4, ot(Vr)),
  312. ve(5, SE)
  313. ], pe);
  314. var Ht = "SHEET_HYPER_LINK_UI_PLUGIN";
  315. var Li = Object.defineProperty;
  316. var Pi = Object.getOwnPropertyDescriptor;
  317. var bi = (t, e, n, i) => {
  318. for (var r = i > 1 ? void 0 : i ? Pi(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  319. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  320. return i && r && Li(e, n, r), r;
  321. };
  322. var Ve = (t, e) => (n, i) => e(n, i, t);
  323. var Ye = class extends nt {
  324. constructor(e, n, i, r) {
  325. super();
  326. B(this, "_plainTextFilter", /* @__PURE__ */ new Set());
  327. B(this, "_copyInfo");
  328. this._sheetClipboardService = e, this._hyperLinkModel = n, this._injector = i, this._resolverService = r, this._initCopyPaste(), this.disposeWithMe(() => {
  329. this._plainTextFilter.clear();
  330. });
  331. }
  332. registerPlainTextFilter(e) {
  333. this._plainTextFilter.add(e);
  334. }
  335. removePlainTextFilter(e) {
  336. this._plainTextFilter.delete(e);
  337. }
  338. /* If return false the process of paste text will be stop */
  339. _filterPlainText(e) {
  340. return Array.from(this._plainTextFilter).every((n) => n(e));
  341. }
  342. _initCopyPaste() {
  343. this._sheetClipboardService.addClipboardHook({
  344. id: Ht,
  345. onBeforeCopy: (e, n, i) => this._collect(e, n, i),
  346. onPasteCells: (e, n, i, r) => {
  347. const { copyType: o = gr.COPY, pasteType: s } = r, { range: c } = e || {}, { range: l, unitId: p, subUnitId: u } = n;
  348. return this._generateMutations(l, { copyType: o, pasteType: s, copyRange: c, unitId: p, subUnitId: u });
  349. },
  350. onPastePlainText: (e, n) => {
  351. const i = this._filterPlainText(n);
  352. if (Ke(n) && i) {
  353. const { range: r, unitId: o, subUnitId: s } = e, { ranges: [c], mapFunc: l } = _s([r]), p = [], u = [];
  354. return tr.foreach(c, (g, d) => {
  355. const { row: v, col: C } = l(g, d), _ = this._hyperLinkModel.getHyperLinkByLocation(o, s, v, C);
  356. _ && p.push({
  357. id: k.id,
  358. params: {
  359. unitId: o,
  360. subUnitId: s,
  361. id: _.id
  362. }
  363. }), _ && u.push({
  364. id: O.id,
  365. params: {
  366. unitId: o,
  367. subUnitId: s,
  368. link: _
  369. }
  370. });
  371. }), { redos: p, undos: u };
  372. }
  373. return { undos: [], redos: [] };
  374. },
  375. priority: 99
  376. });
  377. }
  378. _collect(e, n, i) {
  379. const r = new kt();
  380. this._copyInfo = {
  381. unitId: e,
  382. subUnitId: n,
  383. matrix: r
  384. };
  385. const o = this._injector.invoke((l) => Ys(i, l, e, n));
  386. if (!o)
  387. return;
  388. const { rows: s, cols: c } = o;
  389. s.forEach((l, p) => {
  390. c.forEach((u, g) => {
  391. var v;
  392. const d = this._hyperLinkModel.getHyperLinkByLocation(e, n, l, u);
  393. r.setValue(p, g, (v = d == null ? void 0 : d.id) != null ? v : "");
  394. });
  395. });
  396. }
  397. // eslint-disable-next-line max-lines-per-function
  398. _generateMutations(e, n) {
  399. if (!this._copyInfo)
  400. return { redos: [], undos: [] };
  401. if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !n.copyRange)
  402. return { redos: [], undos: [] };
  403. if ([
  404. rt.SPECIAL_PASTE_COL_WIDTH,
  405. rt.SPECIAL_PASTE_VALUE,
  406. rt.SPECIAL_PASTE_FORMAT,
  407. rt.SPECIAL_PASTE_FORMULA
  408. ].includes(n.pasteType))
  409. return { redos: [], undos: [] };
  410. const { unitId: r, subUnitId: o } = this._copyInfo, s = [], c = [], { ranges: [l, p], mapFunc: u } = _s([n.copyRange, e]);
  411. return sE(l, p, true).forEach(({ startRange: d }) => {
  412. var v;
  413. (v = this._copyInfo) == null || v.matrix.forValue((C, _, O2) => {
  414. const a = en.getPositionRange(
  415. {
  416. startRow: C,
  417. endRow: C,
  418. startColumn: _,
  419. endColumn: _
  420. },
  421. d
  422. ), b = this._hyperLinkModel.getHyperLink(r, o, O2), { row: M, col: k2 } = u(a.startRow, a.startColumn), L = this._hyperLinkModel.getHyperLinkByLocation(n.unitId, n.subUnitId, M, k2), j = re.generateRandomId();
  423. L && s.push({
  424. id: k.id,
  425. params: {
  426. unitId: n.unitId,
  427. subUnitId: n.subUnitId,
  428. id: L.id
  429. }
  430. }), b && (s.push({
  431. id: O.id,
  432. params: {
  433. unitId: n.unitId,
  434. subUnitId: n.subUnitId,
  435. link: {
  436. ...b,
  437. id: j,
  438. row: M,
  439. column: k2
  440. }
  441. }
  442. }), c.push({
  443. id: k.id,
  444. params: {
  445. unitId: n.unitId,
  446. subUnitId: n.subUnitId,
  447. id: j
  448. }
  449. })), L && c.push({
  450. id: O.id,
  451. params: {
  452. unitId: n.unitId,
  453. subUnitId: n.subUnitId,
  454. link: L
  455. }
  456. });
  457. });
  458. }), { redos: s, undos: c };
  459. }
  460. };
  461. Ye = bi([
  462. Ve(0, Sn),
  463. Ve(1, ot(I)),
  464. Ve(2, ot(Ot)),
  465. Ve(3, ot(pe))
  466. ], Ye);
  467. var m2 = ((t) => (t.EDITING = "editing", t.VIEWING = "viewing", t.ZEN_EDITOR = "zen_mode", t))(m2 || {});
  468. var Et = { exports: {} };
  469. var ke2 = {};
  470. var fn2;
  471. function wi() {
  472. if (fn2)
  473. return ke2;
  474. fn2 = 1;
  475. var t = import_react.default, 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: true, ref: true, __self: true, __source: true };
  476. function s(c, l, p) {
  477. var u, g = {}, d = null, v = null;
  478. p !== void 0 && (d = "" + p), l.key !== void 0 && (d = "" + l.key), l.ref !== void 0 && (v = l.ref);
  479. for (u in l)
  480. i.call(l, u) && !o.hasOwnProperty(u) && (g[u] = l[u]);
  481. if (c && c.defaultProps)
  482. for (u in l = c.defaultProps, l)
  483. g[u] === void 0 && (g[u] = l[u]);
  484. return { $$typeof: e, type: c, key: d, ref: v, props: g, _owner: r.current };
  485. }
  486. return ke2.Fragment = n, ke2.jsx = s, ke2.jsxs = s, ke2;
  487. }
  488. var mn2;
  489. function Oi() {
  490. return mn2 || (mn2 = 1, Et.exports = wi()), Et.exports;
  491. }
  492. var f = Oi();
  493. var jn = class extends nt {
  494. constructor() {
  495. super(...arguments);
  496. B(this, "_customHyperLinks", /* @__PURE__ */ new Map());
  497. }
  498. isBuiltInLinkType(n) {
  499. return n !== U.URL;
  500. }
  501. getOptions() {
  502. return Array.from(this._customHyperLinks.values()).map(({ option: n }) => n);
  503. }
  504. findCustomHyperLink(n) {
  505. return Array.from(this._customHyperLinks.values()).find((r) => r.match(n));
  506. }
  507. registerCustomHyperLink(n) {
  508. this._customHyperLinks.set(n.type, n);
  509. }
  510. getCustomHyperLink(n) {
  511. return this._customHyperLinks.get(n);
  512. }
  513. removeCustomHyperLink(n) {
  514. const { _customHyperLinks: i } = this;
  515. i.delete(n);
  516. }
  517. dispose() {
  518. super.dispose(), this._customHyperLinks.clear();
  519. }
  520. };
  521. var ki = "univer-cell-link-edit";
  522. var Ti = "univer-cell-link-edit-buttons";
  523. var _n2 = {
  524. cellLinkEdit: ki,
  525. cellLinkEditButtons: Ti
  526. };
  527. var ze = () => {
  528. var Ft;
  529. const [t, e] = (0, import_react.useState)(""), [n, i] = (0, import_react.useState)(false), [r, o] = (0, import_react.useState)(""), [s, c] = (0, import_react.useState)(true), [l, p] = (0, import_react.useState)(U.URL), [u, g] = (0, import_react.useState)(""), d = W0(Vr), v = W0(pr), C = W0(tt), _ = W0(_n), O2 = W0(K), a = z0(O2.currentEditing$), b = W0(ye), M = W0(pe), k2 = W0(Pt), L = W0(jn), j = (0, import_react.useMemo)(() => L.getOptions(), [L]), D = W0(u3), q = W0(Yx), Ee = W0(ws), je = W0(m), se = W0(fs), Re = W0(ml), Le = W0(m), Pe2 = (0, import_react.useRef)({}), oe = (0, import_react.useMemo)(() => {
  530. if (!L.isBuiltInLinkType(l))
  531. return L.getCustomHyperLink(l);
  532. }, [L, l]), [A, Jn] = (0, import_react.useState)(false), [be, gt] = (0, import_react.useState)(false), H = (0, import_react.useRef)(false), V2 = _.getCurrentUnitForType(Fe.UNIVER_SHEET), Xn = (V2 == null ? void 0 : V2.getActiveSheet().getSheetId()) || "", Q2 = (0, import_react.useCallback)((h) => {
  533. o(h.replaceAll(ln.CUSTOM_RANGE_START, "").replaceAll(ln.CUSTOM_RANGE_END, ""));
  534. }, [o]);
  535. (0, import_react.useEffect)(() => {
  536. var h, y, I2, P, N2, F3, Wt2, Zt, Gt, Kt, Yt, zt, qt2, Jt, Xt, Qt, en2;
  537. if ((a == null ? void 0 : a.row) !== void 0 && a.col !== void 0) {
  538. const { customRange: ae2, row: vt, col: St } = a;
  539. let { label: J } = a;
  540. typeof J == "number" && (J = `${J}`);
  541. let W;
  542. if (ae2)
  543. W = {
  544. id: (h = ae2 == null ? void 0 : ae2.rangeId) != null ? h : "",
  545. display: J != null ? J : "",
  546. payload: (I2 = (y = ae2 == null ? void 0 : ae2.properties) == null ? void 0 : y.url) != null ? I2 : "",
  547. row: vt,
  548. column: St
  549. };
  550. else if (a.type === m2.VIEWING) {
  551. const T = _.getUnit(a.unitId), te = T == null ? void 0 : T.getSheetBySheetId(a.subUnitId), U2 = te == null ? void 0 : te.getCellRaw(a.row, a.col), me2 = (F3 = (N2 = (P = U2 == null ? void 0 : U2.p) == null ? void 0 : P.body) == null ? void 0 : N2.customRanges) == null ? void 0 : F3.find((nn) => {
  552. var rn;
  553. return nn.rangeType === mn.HYPERLINK && ((rn = nn.properties) == null ? void 0 : rn.url);
  554. }), we = U2 == null ? void 0 : U2.v;
  555. U2 && (!st.transform.isEmptyDocument((Zt = (Wt2 = U2.p) == null ? void 0 : Wt2.body) == null ? void 0 : Zt.dataStream) || re.isDefine(we)) && c(false), W = {
  556. id: "",
  557. display: "",
  558. payload: (Kt = (Gt = me2 == null ? void 0 : me2.properties) == null ? void 0 : Gt.url) != null ? Kt : "",
  559. row: vt,
  560. column: St
  561. };
  562. } else {
  563. const T = _.getCurrentUnitForType(Fe.UNIVER_DOC), te = je.getActiveTextRange(), U2 = T == null ? void 0 : T.getBody(), me2 = te && U2 ? te : null, we = me2 && ((zt = st.customRange.getCustomRangesInterestsWithSelection(me2, (Yt = U2 == null ? void 0 : U2.customRanges) != null ? Yt : [])) == null ? void 0 : zt[0]);
  564. c(false), W = {
  565. id: "",
  566. display: J != null ? J : "",
  567. payload: (Jt = (qt2 = we == null ? void 0 : we.properties) == null ? void 0 : qt2.url) != null ? Jt : "",
  568. row: vt,
  569. column: St
  570. };
  571. }
  572. e(W.id);
  573. const tn = L.findCustomHyperLink(W);
  574. if (tn) {
  575. const T = tn.convert(W);
  576. p(T.type), g(T.payload), Q2(T.display);
  577. return;
  578. }
  579. Q2(W.display);
  580. const ee = b.parseHyperLink(W.payload);
  581. switch (p(ee.type === U.INVALID ? U.RANGE : ee.type), ee.type) {
  582. case U.URL: {
  583. g(ee.url), ee.url === W.display && (H.current = true);
  584. break;
  585. }
  586. case U.RANGE: {
  587. const T = ee.searchObj, te = T.gid && (en2 = (Qt = (Xt = _.getUnit(a.unitId)) == null ? void 0 : Xt.getSheetBySheetId(T.gid)) == null ? void 0 : Qt.getName()) != null ? en2 : "", U2 = pc(te, fn(T.range).range);
  588. g(U2), U2 === W.display && (H.current = true);
  589. break;
  590. }
  591. case U.SHEET: {
  592. const T = ee.searchObj;
  593. g(T.gid);
  594. break;
  595. }
  596. case U.DEFINE_NAME: {
  597. const T = ee.searchObj;
  598. g(T.rangeid);
  599. break;
  600. }
  601. default:
  602. g("");
  603. break;
  604. }
  605. }
  606. }, [a, M, L, je, _]), (0, import_react.useEffect)(() => {
  607. let h = null;
  608. if (a && !a.customRangeId && a.type === m2.VIEWING && re.isDefine(a.row) && re.isDefine(a.col)) {
  609. const y = _.getUnit(a.unitId, Fe.UNIVER_SHEET), I2 = y == null ? void 0 : y.getSheetBySheetId(a.subUnitId), P = I2 == null ? void 0 : I2.getMergedCell(a.row, a.col), N2 = new Nt(Re.getCurrentTheme().hyacinth500).toRgb();
  610. h = Ee.addShape(
  611. {
  612. range: P != null ? P : {
  613. startColumn: a.col,
  614. endColumn: a.col,
  615. startRow: a.row,
  616. endRow: a.row
  617. },
  618. style: {
  619. // hasAutoFill: false,
  620. fill: `rgb(${N2.r}, ${N2.g}, ${N2.b}, 0.12)`,
  621. strokeWidth: 1,
  622. stroke: "#FFBD37",
  623. widgets: {}
  624. },
  625. primary: null
  626. },
  627. [],
  628. -1
  629. );
  630. }
  631. return () => {
  632. h && Ee.removeShape(h);
  633. };
  634. }, [a, Ee, Re, _]), (0, import_react.useEffect)(() => {
  635. gt(l === U.RANGE);
  636. }, [l]), (0, import_react.useEffect)(() => {
  637. const h = (a == null ? void 0 : a.type) === m2.ZEN_EDITOR ? q.getRenderById(Hd) : q.getRenderById(C.getCurrentEditorId()), y = new Mi();
  638. if (h) {
  639. const I2 = h.with(Se);
  640. I2.setReserveRangesStatus(true), y.add(() => {
  641. I2.setReserveRangesStatus(false);
  642. });
  643. }
  644. return () => {
  645. C.disableForceKeepVisible(), y.dispose();
  646. };
  647. }, [a == null ? void 0 : a.type, C, q]), (0, import_react.useEffect)(() => (O2.setIsKeepVisible(be), () => {
  648. O2.setIsKeepVisible(false);
  649. }), [be, O2]), (0, import_react.useEffect)(() => () => {
  650. D.temporaryHidden && (D.show(), se.setContextValue(Gn, false));
  651. }, [se, D]), (0, import_react.useEffect)(() => {
  652. if (be)
  653. return C.enableForceKeepVisible(), () => {
  654. C.disableForceKeepVisible();
  655. };
  656. }, [be, C]);
  657. const Qn = [
  658. {
  659. label: d.t("hyperLink.form.link"),
  660. value: U.URL
  661. },
  662. {
  663. label: d.t("hyperLink.form.range"),
  664. value: U.RANGE
  665. },
  666. {
  667. label: d.t("hyperLink.form.worksheet"),
  668. value: U.SHEET
  669. },
  670. {
  671. label: d.t("hyperLink.form.definedName"),
  672. value: U.DEFINE_NAME
  673. },
  674. ...j
  675. ];
  676. if (!V2)
  677. return;
  678. const er = V2.getHiddenWorksheets(), ft = V2.getSheets().map((h) => ({ label: h.getName(), value: h.getSheetId() })).filter((h) => er.indexOf(h.value) === -1), mt = Object.values((Ft = v.getDefinedNameMap(V2.getUnitId())) != null ? Ft : {}).map((h) => ({
  679. label: h.name,
  680. value: h.id
  681. })), Vt = (h, y) => {
  682. if (h === U.URL)
  683. return Ci(y);
  684. if (h === U.RANGE) {
  685. const I2 = fn(y), P = V2.getSheetBySheetName(I2.sheetName);
  686. if (P)
  687. return `#gid=${P.getSheetId()}&range=${fr(I2.range)}`;
  688. }
  689. return `#${h}=${y}`;
  690. }, tr2 = n3((h) => {
  691. var N2;
  692. const I2 = h.split(",").map(fn)[0];
  693. if (!I2 || !SC(I2.range))
  694. return;
  695. I2.sheetName || (I2.sheetName = ((N2 = V2.getActiveSheet()) == null ? void 0 : N2.getName()) || "");
  696. const P = ys(I2);
  697. g(P), P && (H.current || !r) && (Q2(P), H.current = true);
  698. }), _t = async () => {
  699. if (s && !r || !u || l === U.URL && !Ke(u)) {
  700. Jn(true);
  701. return;
  702. }
  703. if (a)
  704. if (t) {
  705. const h = a.type === m2.ZEN_EDITOR || a.type === m2.EDITING ? jt.id : Bt.id;
  706. await k2.executeCommand(h, {
  707. id: t,
  708. unitId: a.unitId,
  709. subUnitId: a.subUnitId,
  710. payload: {
  711. display: s ? r : "",
  712. payload: Vt(l, u)
  713. },
  714. row: a.row,
  715. column: a.col,
  716. documentId: a.type === m2.ZEN_EDITOR ? Hd : C.getCurrentEditorId()
  717. });
  718. } else {
  719. const h = a.type === m2.ZEN_EDITOR || a.type === m2.EDITING ? Tt.id : xt.id;
  720. await k2.executeCommand(h, {
  721. unitId: a.unitId,
  722. subUnitId: a.subUnitId,
  723. link: {
  724. id: qt(),
  725. row: a.row,
  726. column: a.col,
  727. payload: Vt(l, u),
  728. display: s ? r : ""
  729. },
  730. documentId: a.type === m2.ZEN_EDITOR ? Hd : C.getCurrentEditorId()
  731. });
  732. }
  733. if ((a == null ? void 0 : a.type) === m2.VIEWING) {
  734. await k2.executeCommand(an.id, {
  735. unitId: a.unitId,
  736. subUnitId: a.subUnitId
  737. });
  738. const h = 1;
  739. await k2.executeCommand(lf.id, {
  740. range: {
  741. startRow: Math.max(a.row - h, 0),
  742. endRow: a.row + h,
  743. startColumn: Math.max(a.col - h, 0),
  744. endColumn: a.col + h
  745. }
  746. });
  747. }
  748. k2.executeCommand(Je.id);
  749. }, nr = (h) => {
  750. var I2;
  751. if (l !== U.RANGE)
  752. return;
  753. const y = (I2 = Pe2.current) == null ? void 0 : I2.handleOutClick;
  754. y && y(h, () => gt(false));
  755. };
  756. return a ? f.jsxs("div", { className: _n2.cellLinkEdit, style: { display: n ? "none" : "block" }, onClick: nr, children: [
  757. s ? f.jsx(
  758. HO,
  759. {
  760. label: d.t("hyperLink.form.label"),
  761. error: A && !r ? d.t("hyperLink.form.inputError") : "",
  762. children: f.jsx(
  763. QC,
  764. {
  765. value: r,
  766. onChange: (h) => {
  767. Q2(h), H.current = false;
  768. },
  769. placeholder: d.t("hyperLink.form.labelPlaceholder"),
  770. autoFocus: true,
  771. onKeyDown: (h) => {
  772. h.keyCode === I1.ENTER && _t();
  773. }
  774. }
  775. )
  776. }
  777. ) : null,
  778. f.jsx(HO, { label: d.t("hyperLink.form.type"), children: f.jsx(
  779. r_,
  780. {
  781. options: Qn,
  782. value: l,
  783. onChange: (h) => {
  784. p(h), g("");
  785. }
  786. }
  787. ) }),
  788. l === U.URL && f.jsx(
  789. HO,
  790. {
  791. error: A ? u ? Ke(u) ? "" : d.t("hyperLink.form.linkError") : d.t("hyperLink.form.inputError") : "",
  792. children: f.jsx(
  793. QC,
  794. {
  795. value: u,
  796. onChange: (h) => {
  797. g(h), h && (H.current || !r || r === u) && (Q2(h), H.current = true);
  798. },
  799. placeholder: d.t("hyperLink.form.linkPlaceholder"),
  800. autoFocus: true,
  801. onKeyDown: (h) => {
  802. h.keyCode === I1.ENTER && _t();
  803. }
  804. }
  805. )
  806. }
  807. ),
  808. l === U.RANGE && f.jsx(HO, { error: A && !u ? d.t("hyperLink.form.inputError") : "", children: f.jsx(
  809. Ei,
  810. {
  811. unitId: V2.getUnitId(),
  812. subUnitId: Xn,
  813. isOnlyOneRange: true,
  814. isSupportAcrossSheet: true,
  815. initValue: u,
  816. onChange: tr2,
  817. isFocus: be,
  818. onFocus: () => gt(true),
  819. actions: Pe2.current,
  820. onRangeSelectorDialogVisibleChange: async (h) => {
  821. var y, I2;
  822. if (h)
  823. a.type === m2.ZEN_EDITOR && (D.hide(), se.setContextValue(Gn, true)), a.type !== m2.VIEWING && C.enableForceKeepVisible(), i(true);
  824. else {
  825. if (await M.navigateToRange(a.unitId, a.subUnitId, { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col }, true), a.type === m2.ZEN_EDITOR) {
  826. await k2.executeCommand(re2.id, {
  827. unitId: a.unitId,
  828. subUnitId: a.subUnitId,
  829. selections: [{ range: { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col } }]
  830. }), D.show(), se.setContextValue(Gn, false);
  831. const P = (y = q.getRenderById(Hd)) == null ? void 0 : y.with(kn), N2 = (I2 = Le.getTextRanges({ unitId: Hd, subUnitId: Hd })) == null ? void 0 : I2[0];
  832. P && N2 && (P.scrollToRange(N2), Le.refreshSelection({ unitId: Hd, subUnitId: Hd }));
  833. }
  834. C.disableForceKeepVisible(), i(false);
  835. }
  836. }
  837. }
  838. ) }),
  839. l === U.SHEET && f.jsx(HO, { error: A && !u ? d.t("hyperLink.form.selectError") : "", children: f.jsx(
  840. r_,
  841. {
  842. options: ft,
  843. value: u,
  844. onChange: (h) => {
  845. var P, N2;
  846. g(h);
  847. const y = (P = ft.find((F3) => F3.value === h)) == null ? void 0 : P.label, I2 = (N2 = ft.find((F3) => F3.value === u)) == null ? void 0 : N2.label;
  848. y && (H.current || !r || r === I2) && (Q2(y), H.current = true);
  849. }
  850. }
  851. ) }),
  852. l === U.DEFINE_NAME && f.jsx(HO, { error: A && !u ? d.t("hyperLink.form.selectError") : "", children: f.jsx(
  853. r_,
  854. {
  855. options: mt,
  856. value: u,
  857. onChange: (h) => {
  858. var P, N2;
  859. g(h);
  860. const y = (P = mt.find((F3) => F3.value === h)) == null ? void 0 : P.label, I2 = (N2 = mt.find((F3) => F3.value === u)) == null ? void 0 : N2.label;
  861. y && (H.current || !r || r === I2) && (Q2(y), H.current = true);
  862. }
  863. }
  864. ) }),
  865. (oe == null ? void 0 : oe.Form) && f.jsx(
  866. oe.Form,
  867. {
  868. linkId: t,
  869. payload: u,
  870. display: r,
  871. showError: A,
  872. setByPayload: H,
  873. setDisplay: (h) => {
  874. Q2(h), H.current = true;
  875. },
  876. setPayload: g
  877. }
  878. ),
  879. f.jsxs("div", { className: _n2.cellLinkEditButtons, children: [
  880. f.jsx(
  881. Po,
  882. {
  883. onClick: () => {
  884. a && M.navigateToRange(a.unitId, a.subUnitId, { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col }, true), k2.executeCommand(Je.id);
  885. },
  886. children: d.t("hyperLink.form.cancel")
  887. }
  888. ),
  889. f.jsx(
  890. Po,
  891. {
  892. type: "primary",
  893. style: { marginLeft: 8 },
  894. onClick: async () => {
  895. _t();
  896. },
  897. children: d.t("hyperLink.form.ok")
  898. }
  899. )
  900. ] })
  901. ] }) : null;
  902. };
  903. ze.componentKey = "univer.sheet.cell-link-edit";
  904. var $ = function() {
  905. return $ = Object.assign || function(t) {
  906. for (var e, n = 1, i = arguments.length; n < i; n++) {
  907. e = arguments[n];
  908. for (var r in e)
  909. Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]);
  910. }
  911. return t;
  912. }, $.apply(this, arguments);
  913. };
  914. var xi = function(t, e) {
  915. var n = {};
  916. for (var i in t)
  917. Object.prototype.hasOwnProperty.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]);
  918. if (t != null && typeof Object.getOwnPropertySymbols == "function")
  919. for (var r = 0, i = Object.getOwnPropertySymbols(t); r < i.length; r++)
  920. e.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, i[r]) && (n[i[r]] = t[i[r]]);
  921. return n;
  922. };
  923. var fe = (0, import_react.forwardRef)(function(t, e) {
  924. 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 = (0, import_react.useRef)("_".concat(Ui()));
  925. return An(n, "".concat(i), { defIds: n.defIds, idSuffix: l.current }, $({ ref: e, className: c }, s), o);
  926. });
  927. function An(t, e, n, i, r) {
  928. return (0, import_react.createElement)(t.tag, $($({ key: e }, Ni(t, n, r)), i), (Mi2(t, n).children || []).map(function(o, s) {
  929. return An(o, "".concat(e, "-").concat(t.tag, "-").concat(s), n, void 0, r);
  930. }));
  931. }
  932. function Ni(t, e, n) {
  933. var i = $({}, t.attrs);
  934. n != null && n.colorChannel1 && i.fill === "colorChannel1" && (i.fill = n.colorChannel1);
  935. var r = e.defIds;
  936. 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) {
  937. var s = o[0], c = o[1];
  938. typeof c == "string" && (i[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
  939. })), i;
  940. }
  941. function Mi2(t, e) {
  942. var n, i = e.defIds;
  943. 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) {
  944. return typeof r.attrs.id == "string" && i && i.indexOf(r.attrs.id) > -1 ? $($({}, r), { attrs: $($({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
  945. }) }) : t;
  946. }
  947. function Ui() {
  948. return Math.random().toString(36).substring(2, 8);
  949. }
  950. fe.displayName = "UniverIcon";
  951. 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" } }] };
  952. var Ze = (0, import_react.forwardRef)(function(t, e) {
  953. return (0, import_react.createElement)(fe, Object.assign({}, t, {
  954. id: "all-border-single",
  955. ref: e,
  956. icon: Hi
  957. }));
  958. });
  959. Ze.displayName = "AllBorderSingle";
  960. 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" } }] };
  961. var Bn = (0, import_react.forwardRef)(function(t, e) {
  962. return (0, import_react.createElement)(fe, Object.assign({}, t, {
  963. id: "copy-single",
  964. ref: e,
  965. icon: Di
  966. }));
  967. });
  968. Bn.displayName = "CopySingle";
  969. 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" } }] };
  970. var Dt = (0, import_react.forwardRef)(function(t, e) {
  971. return (0, import_react.createElement)(fe, Object.assign({}, t, {
  972. id: "link-single",
  973. ref: e,
  974. icon: $i
  975. }));
  976. });
  977. Dt.displayName = "LinkSingle";
  978. 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" } }] };
  979. var Vn2 = (0, import_react.forwardRef)(function(t, e) {
  980. return (0, import_react.createElement)(fe, Object.assign({}, t, {
  981. id: "unlink-single",
  982. ref: e,
  983. icon: ji
  984. }));
  985. });
  986. Vn2.displayName = "UnlinkSingle";
  987. 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" } }] };
  988. var Fn = (0, import_react.forwardRef)(function(t, e) {
  989. return (0, import_react.createElement)(fe, Object.assign({}, t, {
  990. id: "write-single",
  991. ref: e,
  992. icon: Ai
  993. }));
  994. });
  995. Fn.displayName = "WriteSingle";
  996. 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" } }] };
  997. var Wn = (0, import_react.forwardRef)(function(t, e) {
  998. return (0, import_react.createElement)(fe, Object.assign({}, t, {
  999. id: "xlsx",
  1000. ref: e,
  1001. icon: Bi
  1002. }));
  1003. });
  1004. Wn.displayName = "Xlsx";
  1005. function Zn(t) {
  1006. var e, n, i = "";
  1007. if (typeof t == "string" || typeof t == "number")
  1008. i += t;
  1009. else if (typeof t == "object")
  1010. if (Array.isArray(t)) {
  1011. var r = t.length;
  1012. for (e = 0; e < r; e++)
  1013. t[e] && (n = Zn(t[e])) && (i && (i += " "), i += n);
  1014. } else
  1015. for (n in t)
  1016. t[n] && (i && (i += " "), i += n);
  1017. return i;
  1018. }
  1019. function vn() {
  1020. for (var t, e, n = 0, i = "", r = arguments.length; n < r; n++)
  1021. (t = arguments[n]) && (e = Zn(t)) && (i && (i += " "), i += e);
  1022. return i;
  1023. }
  1024. var Vi = "univer-cell-link";
  1025. var Fi = "univer-cell-link-type";
  1026. var Wi = "univer-cell-link-content";
  1027. var Zi = "univer-cell-link-content-error";
  1028. var Gi = "univer-cell-link-url";
  1029. var Ki = "univer-cell-link-operations";
  1030. var Yi = "univer-cell-link-operation";
  1031. var zi = "univer-cell-link-operation-error";
  1032. var Z = {
  1033. cellLink: Vi,
  1034. cellLinkType: Fi,
  1035. cellLinkContent: Wi,
  1036. cellLinkContentError: Zi,
  1037. cellLinkUrl: Gi,
  1038. cellLinkOperations: Ki,
  1039. cellLinkOperation: Yi,
  1040. cellLinkOperationError: zi
  1041. };
  1042. var qi = {
  1043. [U.URL]: f.jsx(Dt, {}),
  1044. [U.SHEET]: f.jsx(Wn, {}),
  1045. [U.RANGE]: f.jsx(Ze, {}),
  1046. [U.DEFINE_NAME]: f.jsx(Ze, {}),
  1047. [U.INVALID]: f.jsx(Ze, {})
  1048. };
  1049. var Sn2 = (t) => {
  1050. var M, k2;
  1051. const e = W0(K), n = W0(Pt), i = W0(o3), r = W0(Vr), o = W0(pe), s = W0(tt), c = W0(ye), l = W0(u3), { customRange: p, row: u, col: g, unitId: d, subUnitId: v, editPermission: C, copyPermission: _, type: O2 } = t;
  1052. if (!((M = p == null ? void 0 : p.properties) != null && M.url))
  1053. return null;
  1054. const a = c.parseHyperLink((k2 = p.properties.url) != null ? k2 : ""), b = a.type === U.INVALID;
  1055. return f.jsxs("div", { className: Z.cellLink, onClick: () => e.hideCurrentPopup(), children: [
  1056. f.jsxs(
  1057. "div",
  1058. {
  1059. className: vn(Z.cellLinkContent, { [Z.cellLinkContentError]: b }),
  1060. onClick: () => {
  1061. l.visible || b || o.navigate(a);
  1062. },
  1063. children: [
  1064. f.jsx("div", { className: Z.cellLinkType, children: qi[a.type] }),
  1065. f.jsx(Gf, { showIfEllipsis: true, title: a.name, asChild: true, children: f.jsx("span", { className: Z.cellLinkUrl, children: a.name }) })
  1066. ]
  1067. }
  1068. ),
  1069. f.jsxs("div", { className: Z.cellLinkOperations, children: [
  1070. _ && f.jsx(
  1071. "div",
  1072. {
  1073. className: vn(Z.cellLinkOperation, { [Z.cellLinkOperationError]: b }),
  1074. onClick: () => {
  1075. if (!b) {
  1076. if (a.type !== U.URL) {
  1077. const L = new URL(window.location.href);
  1078. L.hash = a.url.slice(1), navigator.clipboard.writeText(L.href);
  1079. } else
  1080. navigator.clipboard.writeText(a.url);
  1081. i.show({
  1082. content: r.t("hyperLink.message.coped"),
  1083. type: Xw.Info
  1084. });
  1085. }
  1086. },
  1087. children: f.jsx(Gf, { placement: "bottom", title: r.t("hyperLink.popup.copy"), children: f.jsx(Bn, {}) })
  1088. }
  1089. ),
  1090. C && f.jsxs(f.Fragment, { children: [
  1091. f.jsx(
  1092. "div",
  1093. {
  1094. className: Z.cellLinkOperation,
  1095. onClick: () => {
  1096. n.executeCommand(jt2.id, {
  1097. unitId: d,
  1098. subUnitId: v,
  1099. row: u,
  1100. col: g,
  1101. customRangeId: p.rangeId,
  1102. type: O2
  1103. });
  1104. },
  1105. children: f.jsx(Gf, { placement: "bottom", title: r.t("hyperLink.popup.edit"), children: f.jsx(Fn, {}) })
  1106. }
  1107. ),
  1108. f.jsx(
  1109. "div",
  1110. {
  1111. className: Z.cellLinkOperation,
  1112. onClick: () => {
  1113. const L = O2 === m2.EDITING || O2 === m2.ZEN_EDITOR ? Wt.id : At.id;
  1114. n.syncExecuteCommand(L, {
  1115. unitId: d,
  1116. subUnitId: v,
  1117. id: p.rangeId,
  1118. row: u,
  1119. column: g,
  1120. documentId: O2 === m2.ZEN_EDITOR ? Hd : s.getCurrentEditorId()
  1121. }) && e.hideCurrentPopup(void 0, true);
  1122. },
  1123. children: f.jsx(Gf, { placement: "bottom", title: r.t("hyperLink.popup.cancel"), children: f.jsx(Vn2, {}) })
  1124. }
  1125. )
  1126. ] })
  1127. ] })
  1128. ] });
  1129. };
  1130. var qe = () => {
  1131. var r, o;
  1132. const t = W0(K), [e, n] = (0, import_react.useState)(null), i = W0(_n);
  1133. if ((0, import_react.useEffect)(() => {
  1134. n(t.currentPopup);
  1135. const s = t.currentPopup$.subscribe((c) => {
  1136. n(c);
  1137. });
  1138. return () => {
  1139. s.unsubscribe();
  1140. };
  1141. }, [t.currentPopup, t.currentPopup$]), !e)
  1142. return null;
  1143. if (e.showAll) {
  1144. const s = i.getUnit(e.unitId, Fe.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;
  1145. return p != null && p.length ? f.jsx("div", { children: p.map((u) => f.jsx(Sn2, { ...e, customRange: u }, u.rangeId)) }) : null;
  1146. }
  1147. return f.jsx(Sn2, { ...e });
  1148. };
  1149. qe.componentKey = "univer.sheet.cell-link-popup";
  1150. var Ji = Object.defineProperty;
  1151. var Xi = Object.getOwnPropertyDescriptor;
  1152. var Qi = (t, e, n, i) => {
  1153. for (var r = i > 1 ? void 0 : i ? Xi(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  1154. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  1155. return i && r && Ji(e, n, r), r;
  1156. };
  1157. var ce = (t, e) => (n, i) => e(n, i, t);
  1158. var Cn = (t, e) => {
  1159. var n, i;
  1160. 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;
  1161. };
  1162. var K = class extends nt {
  1163. constructor(e, n, i, r, o, s, c) {
  1164. super();
  1165. B(this, "_currentPopup", null);
  1166. B(this, "_currentPopup$", new Subject());
  1167. B(this, "currentPopup$", this._currentPopup$.asObservable());
  1168. B(this, "_currentEditingPopup", null);
  1169. B(this, "_currentEditing$", new BehaviorSubject(null));
  1170. B(this, "currentEditing$", this._currentEditing$.asObservable());
  1171. B(this, "_isKeepVisible", false);
  1172. this._sheetCanvasPopManagerService = e, this._injector = n, this._univerInstanceService = i, this._editorBridgeService = r, this._textSelectionManagerService = o, this._docCanvasPopManagerService = s, this._zenZoneService = c, this.disposeWithMe(() => {
  1173. this.hideCurrentPopup(), this.endEditing(), this._currentEditing$.complete(), this._currentPopup$.complete();
  1174. });
  1175. }
  1176. get currentPopup() {
  1177. return this._currentPopup;
  1178. }
  1179. get currentEditing() {
  1180. return this._currentEditing$.getValue();
  1181. }
  1182. setIsKeepVisible(e) {
  1183. this._isKeepVisible = e;
  1184. }
  1185. getIsKeepVisible() {
  1186. return this._isKeepVisible;
  1187. }
  1188. showPopup(e) {
  1189. if (this._currentPopup && Cn(e, this._currentPopup) || (this.hideCurrentPopup(void 0, true), e.type !== m2.ZEN_EDITOR && this._zenZoneService.visible))
  1190. return;
  1191. const n = this._currentEditing$.getValue();
  1192. if (n && Cn(e, n))
  1193. return;
  1194. const { unitId: i, subUnitId: r, row: o, col: s, customRangeRect: c, customRange: l } = e;
  1195. let p;
  1196. const u = {
  1197. componentKey: qe.componentKey,
  1198. direction: "bottom",
  1199. onClickOutside: () => {
  1200. this.hideCurrentPopup();
  1201. },
  1202. onClick: () => {
  1203. this.hideCurrentPopup(e.type, true);
  1204. }
  1205. };
  1206. if (e.type === m2.EDITING) {
  1207. if (!l)
  1208. return;
  1209. p = c && this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
  1210. c,
  1211. u
  1212. );
  1213. } else if (e.type === m2.ZEN_EDITOR) {
  1214. if (!l)
  1215. return;
  1216. p = this._docCanvasPopManagerService.attachPopupToRange(
  1217. {
  1218. startOffset: l.startIndex,
  1219. endOffset: l.endIndex + 1,
  1220. collapsed: false
  1221. },
  1222. u,
  1223. Hd
  1224. );
  1225. } else if (e.showAll)
  1226. p = this._sheetCanvasPopManagerService.attachPopupToCell(e.row, e.col, u, i, r);
  1227. else {
  1228. if (!l)
  1229. return;
  1230. p = c && this._sheetCanvasPopManagerService.attachPopupByPosition(
  1231. c,
  1232. u,
  1233. e
  1234. );
  1235. }
  1236. p && (this._currentPopup = {
  1237. unitId: i,
  1238. subUnitId: r,
  1239. disposable: p,
  1240. row: o,
  1241. col: s,
  1242. editPermission: !!e.editPermission,
  1243. copyPermission: !!e.copyPermission,
  1244. customRange: l,
  1245. type: e.type,
  1246. showAll: e.showAll
  1247. }, this._currentPopup$.next(this._currentPopup));
  1248. }
  1249. hideCurrentPopup(e, n) {
  1250. var i, r;
  1251. 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));
  1252. }
  1253. _getEditingRange() {
  1254. var i, r, o;
  1255. const e = this._editorBridgeService.isVisible().visible, n = this._editorBridgeService.getEditCellState();
  1256. if (e && n) {
  1257. const s = this._textSelectionManagerService.getActiveTextRange(), c = (i = n.documentLayoutObject.documentModel) == null ? void 0 : i.getBody();
  1258. if (!c)
  1259. return null;
  1260. if (!s || s.collapsed)
  1261. return {
  1262. startOffset: 0,
  1263. endOffset: c.dataStream.length - 2,
  1264. collapsed: c.dataStream.length - 2 === 0,
  1265. label: st.transform.getPlainText(c.dataStream)
  1266. };
  1267. const l = st.customRange.getCustomRangesInterestsWithSelection(s, (o = (r = c.customRanges) == null ? void 0 : r.filter((g) => g.rangeType === mn.HYPERLINK)) != null ? o : []);
  1268. let p = s.startOffset, u = s.endOffset;
  1269. return l.forEach((g) => {
  1270. p = Math.min(p, g.startIndex), u = Math.max(u, g.endIndex + 1);
  1271. }), {
  1272. startOffset: p,
  1273. endOffset: u,
  1274. collapsed: p === u,
  1275. label: st.transform.getPlainText(c.dataStream.slice(p, u))
  1276. };
  1277. }
  1278. return null;
  1279. }
  1280. get _editPopup() {
  1281. return {
  1282. componentKey: ze.componentKey,
  1283. direction: "vertical",
  1284. onClickOutside: () => {
  1285. this.getIsKeepVisible() || this.endEditing();
  1286. },
  1287. onContextMenu: () => {
  1288. this.getIsKeepVisible() || this.endEditing();
  1289. },
  1290. hiddenType: "hide"
  1291. };
  1292. }
  1293. startAddEditing(e) {
  1294. var o, s, c, l, p;
  1295. const { unitId: n, subUnitId: i, type: r } = e;
  1296. if (r === m2.ZEN_EDITOR) {
  1297. const u = this._univerInstanceService.getUnit(Hd, Fe.UNIVER_DOC);
  1298. if (!u)
  1299. return;
  1300. const g = this._textSelectionManagerService.getActiveTextRange();
  1301. if (!g)
  1302. return;
  1303. this._currentEditingPopup = this._docCanvasPopManagerService.attachPopupToRange(
  1304. g,
  1305. this._editPopup,
  1306. Hd
  1307. );
  1308. const d = (o = u.getBody()) == null ? void 0 : o.dataStream.slice(g.startOffset, g.endOffset);
  1309. this._currentEditing$.next({
  1310. ...e,
  1311. label: d
  1312. });
  1313. } else if (r === m2.EDITING) {
  1314. const u = this._getEditingRange();
  1315. if (!u)
  1316. return;
  1317. this._textSelectionManagerService.replaceDocRanges([{ ...u }], { unitId: su, subUnitId: su });
  1318. const g = this._injector.get(Yx).getRenderById(su);
  1319. if (!g)
  1320. return;
  1321. const d = ko(u, g);
  1322. if (!(d != null && d.length))
  1323. return;
  1324. this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
  1325. d.pop(),
  1326. this._editPopup,
  1327. n,
  1328. i
  1329. ), this._currentEditing$.next({
  1330. ...e,
  1331. label: (s = u == null ? void 0 : u.label) != null ? s : ""
  1332. });
  1333. } else {
  1334. this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell(
  1335. e.row,
  1336. e.col,
  1337. this._editPopup,
  1338. n,
  1339. i
  1340. );
  1341. const u = this._univerInstanceService.getUnit(n, Fe.UNIVER_SHEET), g = u == null ? void 0 : u.getSheetBySheetId(i), d = g == null ? void 0 : g.getCellRaw(e.row, e.col);
  1342. this._currentEditing$.next({
  1343. ...e,
  1344. label: d != null && d.p ? st.transform.getPlainText((l = (c = d.p.body) == null ? void 0 : c.dataStream) != null ? l : "") : ((p = d == null ? void 0 : d.v) != null ? p : "").toString()
  1345. });
  1346. }
  1347. }
  1348. // eslint-disable-next-line complexity, max-lines-per-function
  1349. startEditing(e) {
  1350. var s, c, l, p, u, g;
  1351. (s = this._currentEditingPopup) == null || s.dispose(), this.hideCurrentPopup(void 0, true);
  1352. const { unitId: n, subUnitId: i } = e;
  1353. let r, o;
  1354. if (e.type === m2.ZEN_EDITOR) {
  1355. const d = this._univerInstanceService.getUnit(Hd, Fe.UNIVER_DOC);
  1356. 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)
  1357. return;
  1358. this._textSelectionManagerService.replaceTextRanges([
  1359. {
  1360. startOffset: r.startIndex,
  1361. endOffset: r.endIndex + 1
  1362. }
  1363. ]), this._currentEditingPopup = this._docCanvasPopManagerService.attachPopupToRange(
  1364. {
  1365. startOffset: r.startIndex,
  1366. endOffset: r.endIndex,
  1367. collapsed: false
  1368. },
  1369. this._editPopup,
  1370. Hd
  1371. );
  1372. } else if (e.type === m2.EDITING) {
  1373. const d = oE(this._injector, e.unitId, e.subUnitId, e.row, e.col, e.customRangeId);
  1374. if (!d || !((u = d.rects) != null && u.length))
  1375. return;
  1376. r = d.customRange, o = d.label, this._textSelectionManagerService.replaceTextRanges([
  1377. {
  1378. startOffset: r.startIndex,
  1379. endOffset: r.endIndex + 1
  1380. }
  1381. ]), this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
  1382. d.rects.pop(),
  1383. this._editPopup,
  1384. n,
  1385. i
  1386. );
  1387. } else {
  1388. const d = this._univerInstanceService.getUnit(n, Fe.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), O2 = _ == null ? void 0 : _.tr, a = iE(this._injector, e.unitId, e.subUnitId, e.row, e.col, e.customRangeId);
  1389. if (!a || !((g = a.rects) != null && g.length))
  1390. return;
  1391. r = a.customRange, o = a.label, O2 ? this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell(
  1392. e.row,
  1393. e.col,
  1394. this._editPopup,
  1395. n,
  1396. i
  1397. ) : this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupByPosition(
  1398. a.rects.pop(),
  1399. this._editPopup,
  1400. {
  1401. unitId: n,
  1402. subUnitId: i,
  1403. row: e.row,
  1404. col: e.col
  1405. }
  1406. );
  1407. }
  1408. this._currentEditing$.next({
  1409. ...e,
  1410. customRange: r,
  1411. label: o
  1412. });
  1413. }
  1414. endEditing(e) {
  1415. var i;
  1416. const n = this._currentEditing$.getValue();
  1417. n && (!e || e === n.type) && ((i = this._currentEditingPopup) == null || i.dispose(), this._currentEditing$.next(null));
  1418. }
  1419. };
  1420. K = Qi([
  1421. ce(0, ot(vi)),
  1422. ce(1, ot(Ot)),
  1423. ce(2, _n),
  1424. ce(3, tt),
  1425. ce(4, ot(m)),
  1426. ce(5, ot(is)),
  1427. ce(6, u3)
  1428. ], K);
  1429. var Me2 = ((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))(Me2 || {});
  1430. var es = /* @__PURE__ */ new Set([
  1431. Il.CHECKBOX,
  1432. Il.LIST,
  1433. Il.LIST_MULTIPLE
  1434. ]);
  1435. var $t = (t, e, n, i) => {
  1436. var c, l;
  1437. const r = e.getCell(n, i);
  1438. if (r != null && r.f || r != null && r.si)
  1439. return 1;
  1440. const o = t.has(F2) ? t.get(F2) : null, s = o == null ? void 0 : o.getRuleByLocation(e.getUnitId(), e.getSheetId(), n, i);
  1441. return s && es.has(s.type) ? true : (l = (c = r == null ? void 0 : r.p) == null ? void 0 : c.drawingsOrder) != null && l.length ? 2 : 0;
  1442. };
  1443. var ts = (t) => {
  1444. const e = t.get(_n).getCurrentUnitForType(Fe.UNIVER_SHEET);
  1445. if (!e)
  1446. return true;
  1447. const n = e.getActiveSheet(), i = t.get(F).getCurrentSelections();
  1448. if (!i.length)
  1449. return true;
  1450. const r = i[0].range.startRow, o = i[0].range.startColumn;
  1451. return $t(t, n, r, o) === 1;
  1452. };
  1453. var ns = (t) => {
  1454. const e = t.get(m), n = t.get(_n), i = e.getTextRanges();
  1455. if (!(i != null && i.length))
  1456. return true;
  1457. const r = n.getCurrentUnitForType(Fe.UNIVER_DOC);
  1458. return !!(!r || i.every((s) => s.collapsed) || !r.getSelfOrHeaderFooterModel(i[0].segmentId).getBody());
  1459. };
  1460. var jt2 = {
  1461. type: ar.OPERATION,
  1462. id: "sheet.operation.open-hyper-link-edit-panel",
  1463. handler(t, e) {
  1464. if (!e)
  1465. return false;
  1466. const n = t.get(K);
  1467. return e.customRangeId ? n.startEditing(e) : n.startAddEditing(e), true;
  1468. }
  1469. };
  1470. var Je = {
  1471. type: ar.OPERATION,
  1472. id: "sheet.operation.close-hyper-link-popup",
  1473. handler(t) {
  1474. return t.get(K).endEditing(), true;
  1475. }
  1476. };
  1477. var At2 = {
  1478. type: ar.OPERATION,
  1479. id: "sheet.operation.insert-hyper-link",
  1480. handler(t) {
  1481. var g;
  1482. const e = t.get(_n), n = N(e), i = t.get(tt);
  1483. if (!n)
  1484. return false;
  1485. const r = t.get(Pt), s = t.get(F).getCurrentLastSelection();
  1486. if (!s)
  1487. return false;
  1488. const c = s.range.startRow, l = s.range.startColumn, p = i.isVisible(), u = ((g = e.getFocusedUnit()) == null ? void 0 : g.getUnitId()) === Hd;
  1489. return r.executeCommand(jt2.id, {
  1490. unitId: n.unitId,
  1491. subUnitId: n.subUnitId,
  1492. row: c,
  1493. col: l,
  1494. type: u ? m2.ZEN_EDITOR : p.visible ? m2.EDITING : m2.VIEWING
  1495. });
  1496. }
  1497. };
  1498. var de = {
  1499. type: ar.OPERATION,
  1500. id: "sheet.operation.insert-hyper-link-toolbar",
  1501. handler(t) {
  1502. if (ts(t))
  1503. return false;
  1504. const e = t.get(Pt);
  1505. return t.get(K).currentEditing ? e.executeCommand(Je.id) : e.executeCommand(At2.id);
  1506. }
  1507. };
  1508. var Bt2 = (t, e = Hd) => {
  1509. var r;
  1510. const n = t.get(_n), i = (r = t.get(Yx).getRenderById(e)) == null ? void 0 : r.with(Se);
  1511. return i ? i.textSelectionInner$.pipe(map(() => {
  1512. const s = t.get(tt).getEditCellState();
  1513. if (!s)
  1514. return true;
  1515. const c = N(n, { unitId: s.unitId, subUnitId: s.sheetId });
  1516. return !(c != null && c.worksheet) || $t(t, c.worksheet, s.row, s.column) === 1 ? true : ns(t);
  1517. })) : of(true);
  1518. };
  1519. var Gn3 = (t) => {
  1520. const e = ue(t, { workbookTypes: [Me], worksheetTypes: [Te, wn, or], rangeTypes: [Pe] }, true), n = t.get(_n), i = t.get(F), r = t.has(tt) ? t.get(tt) : null, o = n.focused$.pipe(
  1521. filter((s) => !!s),
  1522. map((s) => n.getUnit(s, Fe.UNIVER_SHEET)),
  1523. filter((s) => !!s),
  1524. switchMap((s) => s.activeSheet$),
  1525. switchMap((s) => i.selectionMoveEnd$.pipe(map((c) => s && { selections: c, sheet: s }))),
  1526. map((s) => {
  1527. if (!s)
  1528. return Me2.DISABLED_BY_CELL;
  1529. const { selections: c, sheet: l } = s;
  1530. if (!c.length)
  1531. return Me2.DISABLED_BY_CELL;
  1532. const p = c[0].range.startRow, u = c[0].range.startColumn;
  1533. return $t(t, l, p, u);
  1534. }),
  1535. switchMap((s) => {
  1536. if (s === Me2.DISABLED_BY_CELL)
  1537. return of(true);
  1538. const c = (r ? r.visible$ : of(null)).pipe(map((p) => p != null && p.visible ? su : void 0)), l = t.get(fs).subscribeContextValue$(aE);
  1539. return combineLatest([c, l]).pipe(
  1540. switchMap(
  1541. ([p, u]) => p ? u ? of(true) : Bt2(t, p) : of(s === Me2.ALLOW_ON_EDITING)
  1542. )
  1543. );
  1544. })
  1545. );
  1546. return e.pipe(
  1547. distinctUntilChanged(),
  1548. switchMap((s) => o.pipe(map((c) => s || c)))
  1549. );
  1550. };
  1551. var Xe = {
  1552. commandId: At2.id,
  1553. type: $e.BUTTON,
  1554. title: "hyperLink.menu.add",
  1555. icon: "LinkSingle"
  1556. };
  1557. var Qe = (t) => `${t}-zen-editor`;
  1558. var rs = (t) => ({
  1559. ...Xe,
  1560. id: Xe.commandId,
  1561. hidden$: Fa(t, Fe.UNIVER_SHEET),
  1562. disabled$: Gn3(t)
  1563. // disabled$: getObservableWithExclusiveRange$(accessor, getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })),
  1564. });
  1565. var is2 = (t) => ({
  1566. ...Xe,
  1567. id: Qe(Xe.commandId),
  1568. hidden$: Fa(t, Fe.UNIVER_DOC, Hd),
  1569. disabled$: Bt2(t)
  1570. });
  1571. var et2 = {
  1572. tooltip: "hyperLink.form.addTitle",
  1573. commandId: de.id,
  1574. type: $e.BUTTON,
  1575. icon: "LinkSingle"
  1576. };
  1577. var ss = (t) => ({
  1578. ...et2,
  1579. id: et2.commandId,
  1580. hidden$: Fa(t, Fe.UNIVER_SHEET),
  1581. disabled$: Gn3(t)
  1582. });
  1583. var os = (t) => ({
  1584. ...et2,
  1585. id: Qe(et2.commandId),
  1586. hidden$: Fa(t, Fe.UNIVER_DOC, Hd),
  1587. disabled$: Bt2(t)
  1588. });
  1589. var Kn = {
  1590. id: de.id,
  1591. binding: I1.K | Ae.CTRL_COMMAND,
  1592. preconditions: De2
  1593. };
  1594. var as = Object.defineProperty;
  1595. var cs = Object.getOwnPropertyDescriptor;
  1596. var ls = (t, e, n, i) => {
  1597. for (var r = i > 1 ? void 0 : i ? cs(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  1598. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  1599. return i && r && as(e, n, r), r;
  1600. };
  1601. var In = (t, e) => (n, i) => e(n, i, t);
  1602. var tt2 = class extends nt {
  1603. constructor(t, e) {
  1604. super(), this._autoFillService = t, this._hyperLinkModel = e, this._initAutoFill();
  1605. }
  1606. // eslint-disable-next-line max-lines-per-function
  1607. _initAutoFill() {
  1608. const t = () => ({ redos: [], undos: [] }), e = (i, r) => {
  1609. const { source: o, target: s, unitId: c, subUnitId: l } = i, p = _s([o, s]), [u, g] = p.ranges, { mapFunc: d } = p, v = {
  1610. row: u.startRow,
  1611. col: u.startColumn
  1612. }, C = tE(u, g), _ = [], O2 = [];
  1613. return C.forEach((a) => {
  1614. const b = a.repeatStartCell, M = a.relativeRange, k2 = {
  1615. startRow: v.row,
  1616. startColumn: v.col,
  1617. endColumn: v.col,
  1618. endRow: v.row
  1619. }, L = {
  1620. startRow: b.row,
  1621. startColumn: b.col,
  1622. endColumn: b.col,
  1623. endRow: b.row
  1624. };
  1625. tr.foreach(M, (j, D) => {
  1626. const q = en.getPositionRange(
  1627. {
  1628. startRow: j,
  1629. startColumn: D,
  1630. endColumn: D,
  1631. endRow: j
  1632. },
  1633. k2
  1634. ), { row: Ee, col: je } = d(q.startRow, q.startColumn), se = this._hyperLinkModel.getHyperLinkByLocation(c, l, Ee, je), Re = en.getPositionRange(
  1635. {
  1636. startRow: j,
  1637. startColumn: D,
  1638. endColumn: D,
  1639. endRow: j
  1640. },
  1641. L
  1642. ), { row: Le, col: Pe2 } = d(Re.startRow, Re.startColumn), oe = re.generateRandomId(), A = this._hyperLinkModel.getHyperLinkByLocation(c, l, Le, Pe2);
  1643. A && _.push({
  1644. id: k.id,
  1645. params: {
  1646. unitId: c,
  1647. subUnitId: l,
  1648. id: A.id
  1649. }
  1650. }), (ke.COPY === r || ke.SERIES === r) && se && (_.push({
  1651. id: O.id,
  1652. params: {
  1653. unitId: c,
  1654. subUnitId: l,
  1655. link: {
  1656. ...se,
  1657. id: oe,
  1658. row: Le,
  1659. column: Pe2
  1660. }
  1661. }
  1662. }), O2.push({
  1663. id: k.id,
  1664. params: {
  1665. unitId: c,
  1666. subUnitId: l,
  1667. id: oe
  1668. }
  1669. })), A && O2.push({
  1670. id: O.id,
  1671. params: {
  1672. unitId: c,
  1673. subUnitId: l,
  1674. link: A
  1675. }
  1676. });
  1677. });
  1678. }), {
  1679. undos: O2,
  1680. redos: _
  1681. };
  1682. }, n = {
  1683. id: Ht,
  1684. onFillData: (i, r, o) => o === ke.COPY || o === ke.ONLY_FORMAT || o === ke.SERIES ? e(i, o) : t()
  1685. };
  1686. this.disposeWithMe(this._autoFillService.addHook(n));
  1687. }
  1688. };
  1689. tt2 = ls([
  1690. In(0, Hr),
  1691. In(1, ot(I))
  1692. ], tt2);
  1693. var us = Object.defineProperty;
  1694. var ds = Object.getOwnPropertyDescriptor;
  1695. var ps = (t, e, n, i) => {
  1696. for (var r = i > 1 ? void 0 : i ? ds(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  1697. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  1698. return i && r && us(e, n, r), r;
  1699. };
  1700. var Rt = (t, e) => (n, i) => e(n, i, t);
  1701. var nt2 = class extends nt {
  1702. constructor(t, e, n) {
  1703. super(), this._localeService = t, this._commandService = e, this._sheetPermissionCheckController = n, this._commandExecutedListener();
  1704. }
  1705. _commandExecutedListener() {
  1706. this.disposeWithMe(
  1707. this._commandService.beforeCommandExecuted((t) => {
  1708. t.id === Kn.id && (this._sheetPermissionCheckController.permissionCheckWithRanges({
  1709. workbookTypes: [Me],
  1710. rangeTypes: [Pe],
  1711. worksheetTypes: [Te, wn, or]
  1712. }) || this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.hyperLinkErr")));
  1713. })
  1714. );
  1715. }
  1716. };
  1717. nt2 = ps([
  1718. Rt(0, ot(Vr)),
  1719. Rt(1, Pt),
  1720. Rt(2, ot(Nn))
  1721. ], nt2);
  1722. var hs = Object.defineProperty;
  1723. var gs2 = Object.getOwnPropertyDescriptor;
  1724. var fs2 = (t, e, n, i) => {
  1725. for (var r = i > 1 ? void 0 : i ? gs2(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  1726. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  1727. return i && r && hs(e, n, r), r;
  1728. };
  1729. var G = (t, e) => (n, i) => e(n, i, t);
  1730. var rt2 = class extends nt {
  1731. constructor(t, e, n, i, r, o, s, c, l, p) {
  1732. 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();
  1733. }
  1734. _getLinkPermission(t) {
  1735. const { unitId: e, subUnitId: n, row: i, col: r } = t, o = this._univerInstanceService.getUnit(e, Fe.UNIVER_SHEET);
  1736. if (!(o == null ? void 0 : o.getSheetBySheetId(n)))
  1737. return {
  1738. viewPermission: false,
  1739. editPermission: false,
  1740. copyPermission: false
  1741. };
  1742. const c = this._sheetPermissionCheckController.permissionCheckWithRanges({
  1743. workbookTypes: [Js],
  1744. worksheetTypes: [Hn],
  1745. rangeTypes: [Io]
  1746. }, [{ startRow: i, startColumn: r, endRow: i, endColumn: r }]), l = this._sheetPermissionCheckController.permissionCheckWithRanges({
  1747. workbookTypes: [Me],
  1748. worksheetTypes: [Te, or],
  1749. rangeTypes: [Pe]
  1750. }, [{ startRow: i, startColumn: r, endRow: i, endColumn: r }]), p = this._permissionService.composePermission([new Ls(e).id, new Xs(e, n).id]).every((u) => u.value);
  1751. return {
  1752. viewPermission: c,
  1753. editPermission: l,
  1754. copyPermission: p
  1755. };
  1756. }
  1757. _initHoverListener() {
  1758. this.disposeWithMe(
  1759. // hover over not editing cell
  1760. this._hoverManagerService.currentRichText$.pipe(debounceTime(200)).subscribe((t) => {
  1761. var k2, L;
  1762. if (!t) {
  1763. this._sheetsHyperLinkPopupService.hideCurrentPopup();
  1764. return;
  1765. }
  1766. const { unitId: e, subUnitId: n, row: i, col: r } = t, o = this._renderManagerService.getRenderById(e);
  1767. if (!o)
  1768. return;
  1769. const s = this._univerInstanceService.getUnit(e, Fe.UNIVER_SHEET), c = s == null ? void 0 : s.getSheetBySheetId(n);
  1770. if (!c)
  1771. return;
  1772. if (!o.with(el).active) {
  1773. this._sheetsHyperLinkPopupService.hideCurrentPopup(m2.VIEWING);
  1774. return;
  1775. }
  1776. const p = (k2 = o == null ? void 0 : o.with(me).getWorksheetSkeleton(n)) == null ? void 0 : k2.skeleton, u = r, g = i;
  1777. let d = g, v = u;
  1778. p && p.overflowCache.forValue((j, D, q) => {
  1779. en.contains(q, { startColumn: u, endColumn: u, startRow: g, endRow: g }) && (d = j, v = D);
  1780. });
  1781. const { viewPermission: C, editPermission: _, copyPermission: O2 } = this._getLinkPermission(t);
  1782. if (!C) {
  1783. this._sheetsHyperLinkPopupService.hideCurrentPopup();
  1784. return;
  1785. }
  1786. const a = c.getCellStyleOnly(d, v), b = s.getStyles().getStyleByCell(a), M = (L = b == null ? void 0 : b.tr) == null ? void 0 : L.a;
  1787. if (!M && !t.customRange) {
  1788. this._sheetsHyperLinkPopupService.hideCurrentPopup();
  1789. return;
  1790. }
  1791. this._sheetsHyperLinkPopupService.showPopup({
  1792. row: d,
  1793. col: v,
  1794. editPermission: _,
  1795. copyPermission: O2,
  1796. customRange: t.customRange,
  1797. customRangeRect: t.rect,
  1798. type: m2.VIEWING,
  1799. unitId: e,
  1800. subUnitId: n,
  1801. showAll: !!M
  1802. });
  1803. })
  1804. );
  1805. }
  1806. _initHoverEditingListener() {
  1807. let t = null;
  1808. this.disposeWithMe(
  1809. this._editorBridgeService.currentEditCellState$.pipe(switchMap((e) => this._editorBridgeService.visible$.pipe(map((n) => ({ visible: n, state: e }))))).subscribe(({ visible: e, state: n }) => {
  1810. if (!n || n.editorUnitId !== su)
  1811. return;
  1812. if (!e.visible) {
  1813. t == null || t.unsubscribe(), this._sheetsHyperLinkPopupService.hideCurrentPopup(m2.EDITING), this._sheetsHyperLinkPopupService.endEditing(m2.EDITING);
  1814. return;
  1815. }
  1816. const { editorUnitId: i, unitId: r, sheetId: o, row: s, column: c } = n, l = this._renderManagerService.getRenderById(i);
  1817. if (!l)
  1818. return;
  1819. const { editPermission: p, viewPermission: u, copyPermission: g } = this._getLinkPermission({ unitId: r, subUnitId: o, row: s, col: c }), d = l.with(Gn2);
  1820. u && (t == null || t.unsubscribe(), t = d.hoverCustomRanges$.pipe(debounceTime(200)).subscribe((v) => {
  1821. var b, M;
  1822. const C = v.find((k2) => k2.range.rangeType === mn.HYPERLINK);
  1823. if (!C) {
  1824. this._sheetsHyperLinkPopupService.hideCurrentPopup();
  1825. return;
  1826. }
  1827. const _ = C.rects[C.rects.length - 1];
  1828. if (!((M = (b = this._renderManagerService.getRenderById(r)) == null ? void 0 : b.with(me).getWorksheetSkeleton(o)) == null ? void 0 : M.skeleton) || !_)
  1829. return;
  1830. const a = l.engine.getCanvasElement().getBoundingClientRect();
  1831. this._sheetsHyperLinkPopupService.showPopup({
  1832. unitId: r,
  1833. subUnitId: o,
  1834. row: s,
  1835. col: c,
  1836. customRange: C.range,
  1837. customRangeRect: {
  1838. left: _.left + a.left,
  1839. top: _.top + a.top,
  1840. bottom: _.bottom + a.top,
  1841. right: _.right + a.left
  1842. },
  1843. editPermission: p,
  1844. copyPermission: g,
  1845. type: m2.EDITING
  1846. });
  1847. }));
  1848. })
  1849. ), this.disposeWithMe(() => {
  1850. t == null || t.unsubscribe();
  1851. });
  1852. }
  1853. _initZenEditor() {
  1854. this.disposeWithMe(
  1855. this._zenZoneService.visible$.subscribe((t) => {
  1856. t ? (this._sheetsHyperLinkPopupService.hideCurrentPopup(m2.VIEWING), this._sheetsHyperLinkPopupService.hideCurrentPopup(m2.EDITING), this._sheetsHyperLinkPopupService.endEditing(m2.EDITING), this._sheetsHyperLinkPopupService.hideCurrentPopup(m2.VIEWING)) : (this._sheetsHyperLinkPopupService.hideCurrentPopup(m2.ZEN_EDITOR), this._sheetsHyperLinkPopupService.endEditing(m2.ZEN_EDITOR));
  1857. })
  1858. ), this.disposeWithMe(
  1859. this._univerInstanceService.focused$.pipe(
  1860. switchMap((t) => {
  1861. const e = t === Hd ? this._renderManagerService.getRenderById(t) : null;
  1862. return e ? e.with(Gn2).hoverCustomRanges$.pipe(debounceTime(200)) : new Observable((n) => {
  1863. n.next(null);
  1864. });
  1865. })
  1866. ).subscribe((t) => {
  1867. const e = t == null ? void 0 : t.find((i) => i.range.rangeType === mn.HYPERLINK), n = this._editorBridgeService.getEditCellState();
  1868. if (e && n) {
  1869. 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 });
  1870. l && this._sheetsHyperLinkPopupService.showPopup({
  1871. type: m2.ZEN_EDITOR,
  1872. unitId: i,
  1873. subUnitId: r,
  1874. row: o,
  1875. col: s,
  1876. customRange: e.range,
  1877. editPermission: c,
  1878. copyPermission: p
  1879. });
  1880. } else
  1881. this._sheetsHyperLinkPopupService.hideCurrentPopup(m2.ZEN_EDITOR);
  1882. })
  1883. );
  1884. }
  1885. _initTextSelectionListener() {
  1886. this.disposeWithMe(
  1887. this._textSelectionManagerService.textSelection$.subscribe((t) => {
  1888. t && t.unitId === su && this._sheetsHyperLinkPopupService.endEditing(m2.EDITING);
  1889. })
  1890. );
  1891. }
  1892. _initCommandListener() {
  1893. const t = [Co.id, po.id, So.id];
  1894. this.disposeWithMe(this._commandService.onCommandExecuted((e) => {
  1895. t.includes(e.id) && this._sheetsHyperLinkPopupService.hideCurrentPopup();
  1896. }));
  1897. }
  1898. };
  1899. rt2 = fs2([
  1900. G(0, ot(Er)),
  1901. G(1, ot(K)),
  1902. G(2, ot(Yx)),
  1903. G(3, ot(UE)),
  1904. G(4, ot(Nn)),
  1905. G(5, Pt),
  1906. G(6, tt),
  1907. G(7, ot(m)),
  1908. G(8, _n),
  1909. G(9, u3)
  1910. ], rt2);
  1911. var ms = Object.defineProperty;
  1912. var _s2 = Object.getOwnPropertyDescriptor;
  1913. var Yn = (t, e, n, i) => {
  1914. for (var r = i > 1 ? void 0 : i ? _s2(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  1915. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  1916. return i && r && ms(e, n, r), r;
  1917. };
  1918. var wt = (t, e) => (n, i) => e(n, i, t);
  1919. var Ot2 = class extends nt {
  1920. constructor(t, e) {
  1921. super(), this._context = t, this._hyperLinkModel = e, this._initSkeletonChange();
  1922. }
  1923. _initSkeletonChange() {
  1924. const t = () => {
  1925. var e;
  1926. (e = this._context.mainComponent) == null || e.makeForceDirty();
  1927. };
  1928. this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(debounceTime(16)).subscribe(() => {
  1929. t();
  1930. }));
  1931. }
  1932. };
  1933. Ot2 = Yn([
  1934. wt(1, ot(I))
  1935. ], Ot2);
  1936. var it2 = class extends nt {
  1937. constructor(t, e) {
  1938. super(), this._sheetInterceptorService = t, this._hyperLinkModel = e, this._initViewModelIntercept();
  1939. }
  1940. _initViewModelIntercept() {
  1941. this.disposeWithMe(
  1942. this._sheetInterceptorService.intercept(
  1943. et.CELL_CONTENT,
  1944. {
  1945. effect: Vn.Value,
  1946. priority: 100,
  1947. handler: (t, e, n) => {
  1948. const { row: i, col: r, unitId: o, subUnitId: s } = e, c = this._hyperLinkModel.getHyperLinkByLocation(o, s, i, r);
  1949. return n(c ? {
  1950. ...t,
  1951. linkUrl: c.payload,
  1952. linkId: c.id
  1953. } : t);
  1954. }
  1955. }
  1956. )
  1957. );
  1958. }
  1959. };
  1960. it2 = Yn([
  1961. wt(0, ot(V)),
  1962. wt(1, ot(I))
  1963. ], it2);
  1964. var vs = {
  1965. [l1.OTHERS]: {
  1966. [de.id]: {
  1967. order: 2,
  1968. menuItemFactory: ss
  1969. },
  1970. [Qe(de.id)]: {
  1971. order: 2,
  1972. menuItemFactory: os
  1973. }
  1974. },
  1975. [P1.MAIN_AREA]: {
  1976. [He.OTHERS]: {
  1977. order: 1,
  1978. [de.id]: {
  1979. order: 0,
  1980. menuItemFactory: rs
  1981. },
  1982. [Qe(de.id)]: {
  1983. order: 0,
  1984. menuItemFactory: is2
  1985. }
  1986. }
  1987. }
  1988. };
  1989. var Ss = Object.defineProperty;
  1990. var Cs = Object.getOwnPropertyDescriptor;
  1991. var Is = (t, e, n, i) => {
  1992. for (var r = i > 1 ? void 0 : i ? Cs(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  1993. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  1994. return i && r && Ss(e, n, r), r;
  1995. };
  1996. var Te2 = (t, e) => (n, i) => e(n, i, t);
  1997. var st2 = class extends nt {
  1998. constructor(t, e, n, i, r) {
  1999. super(), this._componentManager = t, this._commandService = e, this._menuManagerService = n, this._injector = i, this._shortcutService = r, this._initComponents(), this._initCommands(), this._initMenus(), this._initShortCut();
  2000. }
  2001. _initComponents() {
  2002. [
  2003. [qe, qe.componentKey],
  2004. [ze, ze.componentKey],
  2005. [Dt, "LinkSingle"]
  2006. ].forEach(([t, e]) => {
  2007. this._componentManager.register(e, t);
  2008. });
  2009. }
  2010. _initCommands() {
  2011. [
  2012. jt2,
  2013. Je,
  2014. At2,
  2015. de
  2016. ].forEach((t) => {
  2017. this._commandService.registerCommand(t);
  2018. });
  2019. }
  2020. _initMenus() {
  2021. this._menuManagerService.mergeMenu(vs);
  2022. }
  2023. _initShortCut() {
  2024. this._shortcutService.registerShortcut(Kn);
  2025. }
  2026. };
  2027. st2 = Is([
  2028. Te2(0, ot(n1)),
  2029. Te2(1, Pt),
  2030. Te2(2, m1),
  2031. Te2(3, ot(Ot)),
  2032. Te2(4, ot(it))
  2033. ], st2);
  2034. var ys2 = Object.defineProperty;
  2035. var Es = Object.getOwnPropertyDescriptor;
  2036. var Rs = (t, e, n, i) => {
  2037. for (var r = i > 1 ? void 0 : i ? Es(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  2038. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  2039. return i && r && ys2(e, n, r), r;
  2040. };
  2041. var yn = (t, e) => (n, i) => e(n, i, t);
  2042. var ot2 = class extends nt {
  2043. constructor(t, e) {
  2044. super(), this._parserService = t, this._resolverService = e, this._handleInitUrl();
  2045. }
  2046. _handleInitUrl() {
  2047. const t = location.hash;
  2048. if (t) {
  2049. const e = this._parserService.parseHyperLink(t);
  2050. this._resolverService.navigate(e);
  2051. }
  2052. }
  2053. };
  2054. ot2 = Rs([
  2055. yn(0, ot(ye)),
  2056. yn(1, ot(pe))
  2057. ], ot2);
  2058. var zn = Object.defineProperty;
  2059. var Ls2 = Object.getOwnPropertyDescriptor;
  2060. var Ps = (t, e, n) => e in t ? zn(t, e, { enumerable: true, configurable: true, writable: true, value: n }) : t[e] = n;
  2061. var bs = (t, e, n, i) => {
  2062. for (var r = i > 1 ? void 0 : i ? Ls2(e, n) : e, o = t.length - 1, s; o >= 0; o--)
  2063. (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
  2064. return i && r && zn(e, n, r), r;
  2065. };
  2066. var En = (t, e) => (n, i) => e(n, i, t);
  2067. var qn = (t, e, n) => Ps(t, typeof e != "symbol" ? e + "" : e, n);
  2068. var at = class extends Ra {
  2069. constructor(t = gn, e, n) {
  2070. super(), this._config = t, this._injector = e, this._configService = n;
  2071. const { menu: i, ...r } = nu(
  2072. {},
  2073. gn,
  2074. this._config
  2075. );
  2076. i && this._configService.setConfig("menu", i, { merge: true }), this._configService.setConfig($n, r);
  2077. }
  2078. onStarting() {
  2079. [
  2080. [pe],
  2081. [K],
  2082. [jn],
  2083. [it2],
  2084. [rt2],
  2085. [st2],
  2086. [tt2],
  2087. [Ye],
  2088. [nt2],
  2089. [ot2]
  2090. ].forEach((e) => this._injector.add(e)), this._injector.get(it2);
  2091. }
  2092. onReady() {
  2093. this._injector.get(Yx).registerRenderModule(Fe.UNIVER_SHEET, [Ot2]), this._injector.get(tt2), this._injector.get(Ye), this._injector.get(st2);
  2094. }
  2095. onRendered() {
  2096. this._injector.get(nt2), this._injector.get(ot2), this._injector.get(rt2);
  2097. }
  2098. };
  2099. qn(at, "pluginName", Ht);
  2100. qn(at, "type", Fe.UNIVER_SHEET);
  2101. at = bs([
  2102. OR(ae, gs),
  2103. En(1, ot(Ot)),
  2104. En(2, SE)
  2105. ], at);
  2106. export {
  2107. pe,
  2108. Ye,
  2109. jn,
  2110. K,
  2111. jt2 as jt,
  2112. Je,
  2113. At2 as At,
  2114. Kn,
  2115. at
  2116. };
  2117. /*! Bundled license information:
  2118. @univerjs/sheets-hyper-link-ui/lib/es/index.js:
  2119. (**
  2120. * @license React
  2121. * react-jsx-runtime.production.min.js
  2122. *
  2123. * Copyright (c) Facebook, Inc. and its affiliates.
  2124. *
  2125. * This source code is licensed under the MIT license found in the
  2126. * LICENSE file in the root directory of this source tree.
  2127. *)
  2128. */
  2129. //# sourceMappingURL=chunk-S7YN35PX.js.map