import { At, Bt, I, O, Q, Tt, U, Wt, ae, jt, k, xt, ye } from "./chunk-4SXJQ6MB.js"; import { F as F2 } from "./chunk-Q35HEJKG.js"; import { Ei } from "./chunk-U3EPM6JO.js"; import { De as De2, Er, Hr, Sn, Ys, _s, el, gr, iE, ke, lf, me, oE, rt, sE, tE, tt, ue, vi, ws } from "./chunk-T4NNB5UY.js"; import { Co, F, Hn, Io, Js, Ls, Me, N, Nn, Pe, So, Te, V, Xs, an, et, or, po, re as re2, wn } from "./chunk-BW43Z7N3.js"; import { fn, fr, pc, pr, ys } from "./chunk-QRYBFJ3R.js"; import { Gn as Gn2, Se, gs, is, kn, ko } from "./chunk-MIOQ566M.js"; import { $e, Ae, Fa, He, I1, P1, it, l1, m1, n1, n3, o3, u3 } from "./chunk-POAJ2YNP.js"; import { Gf, HO, Po, QC, Xw, r_ } from "./chunk-GBYP4PB2.js"; import { m } from "./chunk-PZD7N4BC.js"; import { Yx } from "./chunk-2MK3Q52E.js"; import { BehaviorSubject, De, Fe, Gn, Hd, Il, Mi, Nt, OR, Observable, Ot, Pt, Ra, SC, SE, Subject, UE, Vn, Vr, W0, _n, aE, ar, combineLatest, debounceTime, distinctUntilChanged, en, filter, fs, kt, ln, map, ml, mn, nt, nu, of, ot, qt, re, st, su, switchMap, tr, z0 } from "./chunk-23V3HWTR.js"; import { require_react } from "./chunk-GNR2UJZM.js"; import { __toESM } from "./chunk-2LSFTFF7.js"; // 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 var import_react = __toESM(require_react()); var rr = Object.defineProperty; var ir = (t, e, n) => e in t ? rr(t, e, { enumerable: true, configurable: true, writable: true, value: n }) : t[e] = n; var B = (t, e, n) => ir(t, typeof e != "symbol" ? e + "" : e, n); function Ke(t) { return re.isLegalUrl(t); } function vi2(t) { return /^[a-zA-Z]+:\/\//.test(t); } function Si(t) { return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t); } function Ci(t) { if (Ke(t)) { const e = vi2(t) ? t : Si(t) ? `mailto://${t}` : `http://${t}`; let n; try { n = new URL(e); } catch { return t; } return n.hostname === location.hostname && n.port === location.port && n.protocol === location.protocol && n.pathname === location.pathname && n.hash && !n.search ? n.hash : e; } return t; } var $n = "sheets-hyper-link-ui.config"; var gn = {}; var Ii = Object.defineProperty; var yi = Object.getOwnPropertyDescriptor; var Ei2 = (t, e, n, i) => { for (var r = i > 1 ? void 0 : i ? yi(e, n) : e, o = t.length - 1, s; o >= 0; o--) (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r); return i && r && Ii(e, n, r), r; }; var ve = (t, e) => (n, i) => e(n, i, t); function Ri(t, e) { const n = e.getMergeData(), i = e.getMaxColumns() - 1, r = e.getMaxRows() - 1; if (i < t.endColumn && (t.endColumn = i), r < t.endRow && (t.endRow = r), t.rangeType === De.COLUMN || De.ROW) return t; const o = []; return n.forEach((s) => { en.intersects(t, s) && o.push(s); }), en.realUnion(t, ...o); } var pe = class { constructor(t, e, n, i, r, o) { this._univerInstanceService = t, this._commandService = e, this._definedNamesService = n, this._messageService = i, this._localeService = r, this._configService = o; } navigate(t) { switch (t.type) { case U.URL: this.navigateToOtherWebsite(t.url); break; default: this._navigateToUniver(t.searchObj); } } _navigateToUniver(t) { const { gid: e, range: n, rangeid: i } = t, r = this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET); if (!r) return; const o = r.getUnitId(); if (i) { const s = this._definedNamesService.getValueById(o, i); if (!s) return; const { formulaOrRefString: c } = s, l = this._definedNamesService.getWorksheetByRef(o, c); if (!l) { this._messageService.show({ content: this._localeService.t("hyperLink.message.refError"), type: Xw.Error }); return; } if (l.isSheetHidden()) { this._messageService.show({ content: this._localeService.t("hyperLink.message.hiddenSheet"), type: Xw.Error }); return; } this.navigateToDefineName(o, i); } if (e) { if (n) { const s = fn(n); SC(s.range) && n !== Q && this.navigateToRange(o, e, s.range); return; } this.navigateToSheetById(o, e); } } async navigateToRange(t, e, n, i) { const r = await this.navigateToSheetById(t, e); if (r) { const o = Ri(n, r); await this._commandService.executeCommand( re2.id, { unitId: t, subUnitId: e, selections: [{ range: o, primary: null }] } ), await this._commandService.executeCommand(lf.id, { range: o, forceTop: i }); } } async navigateToSheetById(t, e) { const n = this._univerInstanceService.getUnit(t, Fe.UNIVER_SHEET); if (!n) return false; const i = n.getActiveSheet(); if (!i) return false; if (i.getSheetId() === e) return i; const r = n.getSheetBySheetId(e); return r ? n.getHiddenWorksheets().indexOf(e) > -1 ? (this._messageService.show({ content: this._localeService.t("hyperLink.message.hiddenSheet"), type: Xw.Error }), false) : await this._commandService.executeCommand(an.id, { unitId: t, subUnitId: e }) ? r : false : (this._messageService.show({ content: this._localeService.t("hyperLink.message.noSheet"), type: Xw.Error }), false); } async navigateToDefineName(t, e) { return this._definedNamesService.focusRange(t, e), true; } async navigateToOtherWebsite(t) { var n; const e = this._configService.getConfig($n); if ((n = e == null ? void 0 : e.urlHandler) != null && n.navigateToOtherWebsite) return e.urlHandler.navigateToOtherWebsite(t); window.open(t, "_blank", "noopener noreferrer"); } }; pe = Ei2([ ve(0, _n), ve(1, Pt), ve(2, pr), ve(3, o3), ve(4, ot(Vr)), ve(5, SE) ], pe); var Ht = "SHEET_HYPER_LINK_UI_PLUGIN"; var Li = Object.defineProperty; var Pi = Object.getOwnPropertyDescriptor; var bi = (t, e, n, i) => { for (var r = i > 1 ? void 0 : i ? Pi(e, n) : e, o = t.length - 1, s; o >= 0; o--) (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r); return i && r && Li(e, n, r), r; }; var Ve = (t, e) => (n, i) => e(n, i, t); var Ye = class extends nt { constructor(e, n, i, r) { super(); B(this, "_plainTextFilter", /* @__PURE__ */ new Set()); B(this, "_copyInfo"); this._sheetClipboardService = e, this._hyperLinkModel = n, this._injector = i, this._resolverService = r, this._initCopyPaste(), this.disposeWithMe(() => { this._plainTextFilter.clear(); }); } registerPlainTextFilter(e) { this._plainTextFilter.add(e); } removePlainTextFilter(e) { this._plainTextFilter.delete(e); } /* If return false the process of paste text will be stop */ _filterPlainText(e) { return Array.from(this._plainTextFilter).every((n) => n(e)); } _initCopyPaste() { this._sheetClipboardService.addClipboardHook({ id: Ht, onBeforeCopy: (e, n, i) => this._collect(e, n, i), onPasteCells: (e, n, i, r) => { const { copyType: o = gr.COPY, pasteType: s } = r, { range: c } = e || {}, { range: l, unitId: p, subUnitId: u } = n; return this._generateMutations(l, { copyType: o, pasteType: s, copyRange: c, unitId: p, subUnitId: u }); }, onPastePlainText: (e, n) => { const i = this._filterPlainText(n); if (Ke(n) && i) { const { range: r, unitId: o, subUnitId: s } = e, { ranges: [c], mapFunc: l } = _s([r]), p = [], u = []; return tr.foreach(c, (g, d) => { const { row: v, col: C } = l(g, d), _ = this._hyperLinkModel.getHyperLinkByLocation(o, s, v, C); _ && p.push({ id: k.id, params: { unitId: o, subUnitId: s, id: _.id } }), _ && u.push({ id: O.id, params: { unitId: o, subUnitId: s, link: _ } }); }), { redos: p, undos: u }; } return { undos: [], redos: [] }; }, priority: 99 }); } _collect(e, n, i) { const r = new kt(); this._copyInfo = { unitId: e, subUnitId: n, matrix: r }; const o = this._injector.invoke((l) => Ys(i, l, e, n)); if (!o) return; const { rows: s, cols: c } = o; s.forEach((l, p) => { c.forEach((u, g) => { var v; const d = this._hyperLinkModel.getHyperLinkByLocation(e, n, l, u); r.setValue(p, g, (v = d == null ? void 0 : d.id) != null ? v : ""); }); }); } // eslint-disable-next-line max-lines-per-function _generateMutations(e, n) { if (!this._copyInfo) return { redos: [], undos: [] }; if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !n.copyRange) return { redos: [], undos: [] }; if ([ rt.SPECIAL_PASTE_COL_WIDTH, rt.SPECIAL_PASTE_VALUE, rt.SPECIAL_PASTE_FORMAT, rt.SPECIAL_PASTE_FORMULA ].includes(n.pasteType)) return { redos: [], undos: [] }; const { unitId: r, subUnitId: o } = this._copyInfo, s = [], c = [], { ranges: [l, p], mapFunc: u } = _s([n.copyRange, e]); return sE(l, p, true).forEach(({ startRange: d }) => { var v; (v = this._copyInfo) == null || v.matrix.forValue((C, _, O2) => { const a = en.getPositionRange( { startRow: C, endRow: C, startColumn: _, endColumn: _ }, d ), 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(); L && s.push({ id: k.id, params: { unitId: n.unitId, subUnitId: n.subUnitId, id: L.id } }), b && (s.push({ id: O.id, params: { unitId: n.unitId, subUnitId: n.subUnitId, link: { ...b, id: j, row: M, column: k2 } } }), c.push({ id: k.id, params: { unitId: n.unitId, subUnitId: n.subUnitId, id: j } })), L && c.push({ id: O.id, params: { unitId: n.unitId, subUnitId: n.subUnitId, link: L } }); }); }), { redos: s, undos: c }; } }; Ye = bi([ Ve(0, Sn), Ve(1, ot(I)), Ve(2, ot(Ot)), Ve(3, ot(pe)) ], Ye); var m2 = ((t) => (t.EDITING = "editing", t.VIEWING = "viewing", t.ZEN_EDITOR = "zen_mode", t))(m2 || {}); var Et = { exports: {} }; var ke2 = {}; var fn2; function wi() { if (fn2) return ke2; fn2 = 1; 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 }; function s(c, l, p) { var u, g = {}, d = null, v = null; p !== void 0 && (d = "" + p), l.key !== void 0 && (d = "" + l.key), l.ref !== void 0 && (v = l.ref); for (u in l) i.call(l, u) && !o.hasOwnProperty(u) && (g[u] = l[u]); if (c && c.defaultProps) for (u in l = c.defaultProps, l) g[u] === void 0 && (g[u] = l[u]); return { $$typeof: e, type: c, key: d, ref: v, props: g, _owner: r.current }; } return ke2.Fragment = n, ke2.jsx = s, ke2.jsxs = s, ke2; } var mn2; function Oi() { return mn2 || (mn2 = 1, Et.exports = wi()), Et.exports; } var f = Oi(); var jn = class extends nt { constructor() { super(...arguments); B(this, "_customHyperLinks", /* @__PURE__ */ new Map()); } isBuiltInLinkType(n) { return n !== U.URL; } getOptions() { return Array.from(this._customHyperLinks.values()).map(({ option: n }) => n); } findCustomHyperLink(n) { return Array.from(this._customHyperLinks.values()).find((r) => r.match(n)); } registerCustomHyperLink(n) { this._customHyperLinks.set(n.type, n); } getCustomHyperLink(n) { return this._customHyperLinks.get(n); } removeCustomHyperLink(n) { const { _customHyperLinks: i } = this; i.delete(n); } dispose() { super.dispose(), this._customHyperLinks.clear(); } }; var ki = "univer-cell-link-edit"; var Ti = "univer-cell-link-edit-buttons"; var _n2 = { cellLinkEdit: ki, cellLinkEditButtons: Ti }; var ze = () => { var Ft; 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)(() => { if (!L.isBuiltInLinkType(l)) return L.getCustomHyperLink(l); }, [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) => { o(h.replaceAll(ln.CUSTOM_RANGE_START, "").replaceAll(ln.CUSTOM_RANGE_END, "")); }, [o]); (0, import_react.useEffect)(() => { var h, y, I2, P, N2, F3, Wt2, Zt, Gt, Kt, Yt, zt, qt2, Jt, Xt, Qt, en2; if ((a == null ? void 0 : a.row) !== void 0 && a.col !== void 0) { const { customRange: ae2, row: vt, col: St } = a; let { label: J } = a; typeof J == "number" && (J = `${J}`); let W; if (ae2) W = { id: (h = ae2 == null ? void 0 : ae2.rangeId) != null ? h : "", display: J != null ? J : "", payload: (I2 = (y = ae2 == null ? void 0 : ae2.properties) == null ? void 0 : y.url) != null ? I2 : "", row: vt, column: St }; else if (a.type === m2.VIEWING) { 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) => { var rn; return nn.rangeType === mn.HYPERLINK && ((rn = nn.properties) == null ? void 0 : rn.url); }), we = U2 == null ? void 0 : U2.v; U2 && (!st.transform.isEmptyDocument((Zt = (Wt2 = U2.p) == null ? void 0 : Wt2.body) == null ? void 0 : Zt.dataStream) || re.isDefine(we)) && c(false), W = { id: "", display: "", payload: (Kt = (Gt = me2 == null ? void 0 : me2.properties) == null ? void 0 : Gt.url) != null ? Kt : "", row: vt, column: St }; } else { 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]); c(false), W = { id: "", display: J != null ? J : "", payload: (Jt = (qt2 = we == null ? void 0 : we.properties) == null ? void 0 : qt2.url) != null ? Jt : "", row: vt, column: St }; } e(W.id); const tn = L.findCustomHyperLink(W); if (tn) { const T = tn.convert(W); p(T.type), g(T.payload), Q2(T.display); return; } Q2(W.display); const ee = b.parseHyperLink(W.payload); switch (p(ee.type === U.INVALID ? U.RANGE : ee.type), ee.type) { case U.URL: { g(ee.url), ee.url === W.display && (H.current = true); break; } case U.RANGE: { 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); g(U2), U2 === W.display && (H.current = true); break; } case U.SHEET: { const T = ee.searchObj; g(T.gid); break; } case U.DEFINE_NAME: { const T = ee.searchObj; g(T.rangeid); break; } default: g(""); break; } } }, [a, M, L, je, _]), (0, import_react.useEffect)(() => { let h = null; if (a && !a.customRangeId && a.type === m2.VIEWING && re.isDefine(a.row) && re.isDefine(a.col)) { 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(); h = Ee.addShape( { range: P != null ? P : { startColumn: a.col, endColumn: a.col, startRow: a.row, endRow: a.row }, style: { // hasAutoFill: false, fill: `rgb(${N2.r}, ${N2.g}, ${N2.b}, 0.12)`, strokeWidth: 1, stroke: "#FFBD37", widgets: {} }, primary: null }, [], -1 ); } return () => { h && Ee.removeShape(h); }; }, [a, Ee, Re, _]), (0, import_react.useEffect)(() => { gt(l === U.RANGE); }, [l]), (0, import_react.useEffect)(() => { const h = (a == null ? void 0 : a.type) === m2.ZEN_EDITOR ? q.getRenderById(Hd) : q.getRenderById(C.getCurrentEditorId()), y = new Mi(); if (h) { const I2 = h.with(Se); I2.setReserveRangesStatus(true), y.add(() => { I2.setReserveRangesStatus(false); }); } return () => { C.disableForceKeepVisible(), y.dispose(); }; }, [a == null ? void 0 : a.type, C, q]), (0, import_react.useEffect)(() => (O2.setIsKeepVisible(be), () => { O2.setIsKeepVisible(false); }), [be, O2]), (0, import_react.useEffect)(() => () => { D.temporaryHidden && (D.show(), se.setContextValue(Gn, false)); }, [se, D]), (0, import_react.useEffect)(() => { if (be) return C.enableForceKeepVisible(), () => { C.disableForceKeepVisible(); }; }, [be, C]); const Qn = [ { label: d.t("hyperLink.form.link"), value: U.URL }, { label: d.t("hyperLink.form.range"), value: U.RANGE }, { label: d.t("hyperLink.form.worksheet"), value: U.SHEET }, { label: d.t("hyperLink.form.definedName"), value: U.DEFINE_NAME }, ...j ]; if (!V2) return; 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) => ({ label: h.name, value: h.id })), Vt = (h, y) => { if (h === U.URL) return Ci(y); if (h === U.RANGE) { const I2 = fn(y), P = V2.getSheetBySheetName(I2.sheetName); if (P) return `#gid=${P.getSheetId()}&range=${fr(I2.range)}`; } return `#${h}=${y}`; }, tr2 = n3((h) => { var N2; const I2 = h.split(",").map(fn)[0]; if (!I2 || !SC(I2.range)) return; I2.sheetName || (I2.sheetName = ((N2 = V2.getActiveSheet()) == null ? void 0 : N2.getName()) || ""); const P = ys(I2); g(P), P && (H.current || !r) && (Q2(P), H.current = true); }), _t = async () => { if (s && !r || !u || l === U.URL && !Ke(u)) { Jn(true); return; } if (a) if (t) { const h = a.type === m2.ZEN_EDITOR || a.type === m2.EDITING ? jt.id : Bt.id; await k2.executeCommand(h, { id: t, unitId: a.unitId, subUnitId: a.subUnitId, payload: { display: s ? r : "", payload: Vt(l, u) }, row: a.row, column: a.col, documentId: a.type === m2.ZEN_EDITOR ? Hd : C.getCurrentEditorId() }); } else { const h = a.type === m2.ZEN_EDITOR || a.type === m2.EDITING ? Tt.id : xt.id; await k2.executeCommand(h, { unitId: a.unitId, subUnitId: a.subUnitId, link: { id: qt(), row: a.row, column: a.col, payload: Vt(l, u), display: s ? r : "" }, documentId: a.type === m2.ZEN_EDITOR ? Hd : C.getCurrentEditorId() }); } if ((a == null ? void 0 : a.type) === m2.VIEWING) { await k2.executeCommand(an.id, { unitId: a.unitId, subUnitId: a.subUnitId }); const h = 1; await k2.executeCommand(lf.id, { range: { startRow: Math.max(a.row - h, 0), endRow: a.row + h, startColumn: Math.max(a.col - h, 0), endColumn: a.col + h } }); } k2.executeCommand(Je.id); }, nr = (h) => { var I2; if (l !== U.RANGE) return; const y = (I2 = Pe2.current) == null ? void 0 : I2.handleOutClick; y && y(h, () => gt(false)); }; return a ? f.jsxs("div", { className: _n2.cellLinkEdit, style: { display: n ? "none" : "block" }, onClick: nr, children: [ s ? f.jsx( HO, { label: d.t("hyperLink.form.label"), error: A && !r ? d.t("hyperLink.form.inputError") : "", children: f.jsx( QC, { value: r, onChange: (h) => { Q2(h), H.current = false; }, placeholder: d.t("hyperLink.form.labelPlaceholder"), autoFocus: true, onKeyDown: (h) => { h.keyCode === I1.ENTER && _t(); } } ) } ) : null, f.jsx(HO, { label: d.t("hyperLink.form.type"), children: f.jsx( r_, { options: Qn, value: l, onChange: (h) => { p(h), g(""); } } ) }), l === U.URL && f.jsx( HO, { error: A ? u ? Ke(u) ? "" : d.t("hyperLink.form.linkError") : d.t("hyperLink.form.inputError") : "", children: f.jsx( QC, { value: u, onChange: (h) => { g(h), h && (H.current || !r || r === u) && (Q2(h), H.current = true); }, placeholder: d.t("hyperLink.form.linkPlaceholder"), autoFocus: true, onKeyDown: (h) => { h.keyCode === I1.ENTER && _t(); } } ) } ), l === U.RANGE && f.jsx(HO, { error: A && !u ? d.t("hyperLink.form.inputError") : "", children: f.jsx( Ei, { unitId: V2.getUnitId(), subUnitId: Xn, isOnlyOneRange: true, isSupportAcrossSheet: true, initValue: u, onChange: tr2, isFocus: be, onFocus: () => gt(true), actions: Pe2.current, onRangeSelectorDialogVisibleChange: async (h) => { var y, I2; if (h) a.type === m2.ZEN_EDITOR && (D.hide(), se.setContextValue(Gn, true)), a.type !== m2.VIEWING && C.enableForceKeepVisible(), i(true); else { 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) { await k2.executeCommand(re2.id, { unitId: a.unitId, subUnitId: a.subUnitId, selections: [{ range: { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col } }] }), D.show(), se.setContextValue(Gn, false); 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]; P && N2 && (P.scrollToRange(N2), Le.refreshSelection({ unitId: Hd, subUnitId: Hd })); } C.disableForceKeepVisible(), i(false); } } } ) }), l === U.SHEET && f.jsx(HO, { error: A && !u ? d.t("hyperLink.form.selectError") : "", children: f.jsx( r_, { options: ft, value: u, onChange: (h) => { var P, N2; g(h); 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; y && (H.current || !r || r === I2) && (Q2(y), H.current = true); } } ) }), l === U.DEFINE_NAME && f.jsx(HO, { error: A && !u ? d.t("hyperLink.form.selectError") : "", children: f.jsx( r_, { options: mt, value: u, onChange: (h) => { var P, N2; g(h); 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; y && (H.current || !r || r === I2) && (Q2(y), H.current = true); } } ) }), (oe == null ? void 0 : oe.Form) && f.jsx( oe.Form, { linkId: t, payload: u, display: r, showError: A, setByPayload: H, setDisplay: (h) => { Q2(h), H.current = true; }, setPayload: g } ), f.jsxs("div", { className: _n2.cellLinkEditButtons, children: [ f.jsx( Po, { onClick: () => { a && M.navigateToRange(a.unitId, a.subUnitId, { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col }, true), k2.executeCommand(Je.id); }, children: d.t("hyperLink.form.cancel") } ), f.jsx( Po, { type: "primary", style: { marginLeft: 8 }, onClick: async () => { _t(); }, children: d.t("hyperLink.form.ok") } ) ] }) ] }) : null; }; ze.componentKey = "univer.sheet.cell-link-edit"; var $ = function() { return $ = Object.assign || function(t) { for (var e, n = 1, i = arguments.length; n < i; n++) { e = arguments[n]; for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]); } return t; }, $.apply(this, arguments); }; var xi = function(t, e) { var n = {}; for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]); if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var r = 0, i = Object.getOwnPropertySymbols(t); r < i.length; r++) e.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, i[r]) && (n[i[r]] = t[i[r]]); return n; }; var fe = (0, import_react.forwardRef)(function(t, e) { 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())); return An(n, "".concat(i), { defIds: n.defIds, idSuffix: l.current }, $({ ref: e, className: c }, s), o); }); function An(t, e, n, i, r) { return (0, import_react.createElement)(t.tag, $($({ key: e }, Ni(t, n, r)), i), (Mi2(t, n).children || []).map(function(o, s) { return An(o, "".concat(e, "-").concat(t.tag, "-").concat(s), n, void 0, r); })); } function Ni(t, e, n) { var i = $({}, t.attrs); n != null && n.colorChannel1 && i.fill === "colorChannel1" && (i.fill = n.colorChannel1); var r = e.defIds; 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) { var s = o[0], c = o[1]; typeof c == "string" && (i[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")"))); })), i; } function Mi2(t, e) { var n, i = e.defIds; 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) { return typeof r.attrs.id == "string" && i && i.indexOf(r.attrs.id) > -1 ? $($({}, r), { attrs: $($({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r; }) }) : t; } function Ui() { return Math.random().toString(36).substring(2, 8); } fe.displayName = "UniverIcon"; 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" } }] }; var Ze = (0, import_react.forwardRef)(function(t, e) { return (0, import_react.createElement)(fe, Object.assign({}, t, { id: "all-border-single", ref: e, icon: Hi })); }); Ze.displayName = "AllBorderSingle"; 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" } }] }; var Bn = (0, import_react.forwardRef)(function(t, e) { return (0, import_react.createElement)(fe, Object.assign({}, t, { id: "copy-single", ref: e, icon: Di })); }); Bn.displayName = "CopySingle"; 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" } }] }; var Dt = (0, import_react.forwardRef)(function(t, e) { return (0, import_react.createElement)(fe, Object.assign({}, t, { id: "link-single", ref: e, icon: $i })); }); Dt.displayName = "LinkSingle"; 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" } }] }; var Vn2 = (0, import_react.forwardRef)(function(t, e) { return (0, import_react.createElement)(fe, Object.assign({}, t, { id: "unlink-single", ref: e, icon: ji })); }); Vn2.displayName = "UnlinkSingle"; 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" } }] }; var Fn = (0, import_react.forwardRef)(function(t, e) { return (0, import_react.createElement)(fe, Object.assign({}, t, { id: "write-single", ref: e, icon: Ai })); }); Fn.displayName = "WriteSingle"; 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" } }] }; var Wn = (0, import_react.forwardRef)(function(t, e) { return (0, import_react.createElement)(fe, Object.assign({}, t, { id: "xlsx", ref: e, icon: Bi })); }); Wn.displayName = "Xlsx"; function Zn(t) { var e, n, i = ""; if (typeof t == "string" || typeof t == "number") i += t; else if (typeof t == "object") if (Array.isArray(t)) { var r = t.length; for (e = 0; e < r; e++) t[e] && (n = Zn(t[e])) && (i && (i += " "), i += n); } else for (n in t) t[n] && (i && (i += " "), i += n); return i; } function vn() { for (var t, e, n = 0, i = "", r = arguments.length; n < r; n++) (t = arguments[n]) && (e = Zn(t)) && (i && (i += " "), i += e); return i; } var Vi = "univer-cell-link"; var Fi = "univer-cell-link-type"; var Wi = "univer-cell-link-content"; var Zi = "univer-cell-link-content-error"; var Gi = "univer-cell-link-url"; var Ki = "univer-cell-link-operations"; var Yi = "univer-cell-link-operation"; var zi = "univer-cell-link-operation-error"; var Z = { cellLink: Vi, cellLinkType: Fi, cellLinkContent: Wi, cellLinkContentError: Zi, cellLinkUrl: Gi, cellLinkOperations: Ki, cellLinkOperation: Yi, cellLinkOperationError: zi }; var qi = { [U.URL]: f.jsx(Dt, {}), [U.SHEET]: f.jsx(Wn, {}), [U.RANGE]: f.jsx(Ze, {}), [U.DEFINE_NAME]: f.jsx(Ze, {}), [U.INVALID]: f.jsx(Ze, {}) }; var Sn2 = (t) => { var M, k2; 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; if (!((M = p == null ? void 0 : p.properties) != null && M.url)) return null; const a = c.parseHyperLink((k2 = p.properties.url) != null ? k2 : ""), b = a.type === U.INVALID; return f.jsxs("div", { className: Z.cellLink, onClick: () => e.hideCurrentPopup(), children: [ f.jsxs( "div", { className: vn(Z.cellLinkContent, { [Z.cellLinkContentError]: b }), onClick: () => { l.visible || b || o.navigate(a); }, children: [ f.jsx("div", { className: Z.cellLinkType, children: qi[a.type] }), f.jsx(Gf, { showIfEllipsis: true, title: a.name, asChild: true, children: f.jsx("span", { className: Z.cellLinkUrl, children: a.name }) }) ] } ), f.jsxs("div", { className: Z.cellLinkOperations, children: [ _ && f.jsx( "div", { className: vn(Z.cellLinkOperation, { [Z.cellLinkOperationError]: b }), onClick: () => { if (!b) { if (a.type !== U.URL) { const L = new URL(window.location.href); L.hash = a.url.slice(1), navigator.clipboard.writeText(L.href); } else navigator.clipboard.writeText(a.url); i.show({ content: r.t("hyperLink.message.coped"), type: Xw.Info }); } }, children: f.jsx(Gf, { placement: "bottom", title: r.t("hyperLink.popup.copy"), children: f.jsx(Bn, {}) }) } ), C && f.jsxs(f.Fragment, { children: [ f.jsx( "div", { className: Z.cellLinkOperation, onClick: () => { n.executeCommand(jt2.id, { unitId: d, subUnitId: v, row: u, col: g, customRangeId: p.rangeId, type: O2 }); }, children: f.jsx(Gf, { placement: "bottom", title: r.t("hyperLink.popup.edit"), children: f.jsx(Fn, {}) }) } ), f.jsx( "div", { className: Z.cellLinkOperation, onClick: () => { const L = O2 === m2.EDITING || O2 === m2.ZEN_EDITOR ? Wt.id : At.id; n.syncExecuteCommand(L, { unitId: d, subUnitId: v, id: p.rangeId, row: u, column: g, documentId: O2 === m2.ZEN_EDITOR ? Hd : s.getCurrentEditorId() }) && e.hideCurrentPopup(void 0, true); }, children: f.jsx(Gf, { placement: "bottom", title: r.t("hyperLink.popup.cancel"), children: f.jsx(Vn2, {}) }) } ) ] }) ] }) ] }); }; var qe = () => { var r, o; const t = W0(K), [e, n] = (0, import_react.useState)(null), i = W0(_n); if ((0, import_react.useEffect)(() => { n(t.currentPopup); const s = t.currentPopup$.subscribe((c) => { n(c); }); return () => { s.unsubscribe(); }; }, [t.currentPopup, t.currentPopup$]), !e) return null; if (e.showAll) { 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; return p != null && p.length ? f.jsx("div", { children: p.map((u) => f.jsx(Sn2, { ...e, customRange: u }, u.rangeId)) }) : null; } return f.jsx(Sn2, { ...e }); }; qe.componentKey = "univer.sheet.cell-link-popup"; var Ji = Object.defineProperty; var Xi = Object.getOwnPropertyDescriptor; var Qi = (t, e, n, i) => { for (var r = i > 1 ? void 0 : i ? Xi(e, n) : e, o = t.length - 1, s; o >= 0; o--) (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r); return i && r && Ji(e, n, r), r; }; var ce = (t, e) => (n, i) => e(n, i, t); var Cn = (t, e) => { var n, i; 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; }; var K = class extends nt { constructor(e, n, i, r, o, s, c) { super(); B(this, "_currentPopup", null); B(this, "_currentPopup$", new Subject()); B(this, "currentPopup$", this._currentPopup$.asObservable()); B(this, "_currentEditingPopup", null); B(this, "_currentEditing$", new BehaviorSubject(null)); B(this, "currentEditing$", this._currentEditing$.asObservable()); B(this, "_isKeepVisible", false); this._sheetCanvasPopManagerService = e, this._injector = n, this._univerInstanceService = i, this._editorBridgeService = r, this._textSelectionManagerService = o, this._docCanvasPopManagerService = s, this._zenZoneService = c, this.disposeWithMe(() => { this.hideCurrentPopup(), this.endEditing(), this._currentEditing$.complete(), this._currentPopup$.complete(); }); } get currentPopup() { return this._currentPopup; } get currentEditing() { return this._currentEditing$.getValue(); } setIsKeepVisible(e) { this._isKeepVisible = e; } getIsKeepVisible() { return this._isKeepVisible; } showPopup(e) { if (this._currentPopup && Cn(e, this._currentPopup) || (this.hideCurrentPopup(void 0, true), e.type !== m2.ZEN_EDITOR && this._zenZoneService.visible)) return; const n = this._currentEditing$.getValue(); if (n && Cn(e, n)) return; const { unitId: i, subUnitId: r, row: o, col: s, customRangeRect: c, customRange: l } = e; let p; const u = { componentKey: qe.componentKey, direction: "bottom", onClickOutside: () => { this.hideCurrentPopup(); }, onClick: () => { this.hideCurrentPopup(e.type, true); } }; if (e.type === m2.EDITING) { if (!l) return; p = c && this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition( c, u ); } else if (e.type === m2.ZEN_EDITOR) { if (!l) return; p = this._docCanvasPopManagerService.attachPopupToRange( { startOffset: l.startIndex, endOffset: l.endIndex + 1, collapsed: false }, u, Hd ); } else if (e.showAll) p = this._sheetCanvasPopManagerService.attachPopupToCell(e.row, e.col, u, i, r); else { if (!l) return; p = c && this._sheetCanvasPopManagerService.attachPopupByPosition( c, u, e ); } p && (this._currentPopup = { unitId: i, subUnitId: r, disposable: p, row: o, col: s, editPermission: !!e.editPermission, copyPermission: !!e.copyPermission, customRange: l, type: e.type, showAll: e.showAll }, this._currentPopup$.next(this._currentPopup)); } hideCurrentPopup(e, n) { var i, r; 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)); } _getEditingRange() { var i, r, o; const e = this._editorBridgeService.isVisible().visible, n = this._editorBridgeService.getEditCellState(); if (e && n) { const s = this._textSelectionManagerService.getActiveTextRange(), c = (i = n.documentLayoutObject.documentModel) == null ? void 0 : i.getBody(); if (!c) return null; if (!s || s.collapsed) return { startOffset: 0, endOffset: c.dataStream.length - 2, collapsed: c.dataStream.length - 2 === 0, label: st.transform.getPlainText(c.dataStream) }; const l = st.customRange.getCustomRangesInterestsWithSelection(s, (o = (r = c.customRanges) == null ? void 0 : r.filter((g) => g.rangeType === mn.HYPERLINK)) != null ? o : []); let p = s.startOffset, u = s.endOffset; return l.forEach((g) => { p = Math.min(p, g.startIndex), u = Math.max(u, g.endIndex + 1); }), { startOffset: p, endOffset: u, collapsed: p === u, label: st.transform.getPlainText(c.dataStream.slice(p, u)) }; } return null; } get _editPopup() { return { componentKey: ze.componentKey, direction: "vertical", onClickOutside: () => { this.getIsKeepVisible() || this.endEditing(); }, onContextMenu: () => { this.getIsKeepVisible() || this.endEditing(); }, hiddenType: "hide" }; } startAddEditing(e) { var o, s, c, l, p; const { unitId: n, subUnitId: i, type: r } = e; if (r === m2.ZEN_EDITOR) { const u = this._univerInstanceService.getUnit(Hd, Fe.UNIVER_DOC); if (!u) return; const g = this._textSelectionManagerService.getActiveTextRange(); if (!g) return; this._currentEditingPopup = this._docCanvasPopManagerService.attachPopupToRange( g, this._editPopup, Hd ); const d = (o = u.getBody()) == null ? void 0 : o.dataStream.slice(g.startOffset, g.endOffset); this._currentEditing$.next({ ...e, label: d }); } else if (r === m2.EDITING) { const u = this._getEditingRange(); if (!u) return; this._textSelectionManagerService.replaceDocRanges([{ ...u }], { unitId: su, subUnitId: su }); const g = this._injector.get(Yx).getRenderById(su); if (!g) return; const d = ko(u, g); if (!(d != null && d.length)) return; this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition( d.pop(), this._editPopup, n, i ), this._currentEditing$.next({ ...e, label: (s = u == null ? void 0 : u.label) != null ? s : "" }); } else { this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell( e.row, e.col, this._editPopup, n, i ); 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); this._currentEditing$.next({ ...e, 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() }); } } // eslint-disable-next-line complexity, max-lines-per-function startEditing(e) { var s, c, l, p, u, g; (s = this._currentEditingPopup) == null || s.dispose(), this.hideCurrentPopup(void 0, true); const { unitId: n, subUnitId: i } = e; let r, o; if (e.type === m2.ZEN_EDITOR) { const d = this._univerInstanceService.getUnit(Hd, Fe.UNIVER_DOC); 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) return; this._textSelectionManagerService.replaceTextRanges([ { startOffset: r.startIndex, endOffset: r.endIndex + 1 } ]), this._currentEditingPopup = this._docCanvasPopManagerService.attachPopupToRange( { startOffset: r.startIndex, endOffset: r.endIndex, collapsed: false }, this._editPopup, Hd ); } else if (e.type === m2.EDITING) { const d = oE(this._injector, e.unitId, e.subUnitId, e.row, e.col, e.customRangeId); if (!d || !((u = d.rects) != null && u.length)) return; r = d.customRange, o = d.label, this._textSelectionManagerService.replaceTextRanges([ { startOffset: r.startIndex, endOffset: r.endIndex + 1 } ]), this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition( d.rects.pop(), this._editPopup, n, i ); } else { 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); if (!a || !((g = a.rects) != null && g.length)) return; r = a.customRange, o = a.label, O2 ? this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell( e.row, e.col, this._editPopup, n, i ) : this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupByPosition( a.rects.pop(), this._editPopup, { unitId: n, subUnitId: i, row: e.row, col: e.col } ); } this._currentEditing$.next({ ...e, customRange: r, label: o }); } endEditing(e) { var i; const n = this._currentEditing$.getValue(); n && (!e || e === n.type) && ((i = this._currentEditingPopup) == null || i.dispose(), this._currentEditing$.next(null)); } }; K = Qi([ ce(0, ot(vi)), ce(1, ot(Ot)), ce(2, _n), ce(3, tt), ce(4, ot(m)), ce(5, ot(is)), ce(6, u3) ], K); 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 || {}); var es = /* @__PURE__ */ new Set([ Il.CHECKBOX, Il.LIST, Il.LIST_MULTIPLE ]); var $t = (t, e, n, i) => { var c, l; const r = e.getCell(n, i); if (r != null && r.f || r != null && r.si) return 1; const o = t.has(F2) ? t.get(F2) : null, s = o == null ? void 0 : o.getRuleByLocation(e.getUnitId(), e.getSheetId(), n, i); 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; }; var ts = (t) => { const e = t.get(_n).getCurrentUnitForType(Fe.UNIVER_SHEET); if (!e) return true; const n = e.getActiveSheet(), i = t.get(F).getCurrentSelections(); if (!i.length) return true; const r = i[0].range.startRow, o = i[0].range.startColumn; return $t(t, n, r, o) === 1; }; var ns = (t) => { const e = t.get(m), n = t.get(_n), i = e.getTextRanges(); if (!(i != null && i.length)) return true; const r = n.getCurrentUnitForType(Fe.UNIVER_DOC); return !!(!r || i.every((s) => s.collapsed) || !r.getSelfOrHeaderFooterModel(i[0].segmentId).getBody()); }; var jt2 = { type: ar.OPERATION, id: "sheet.operation.open-hyper-link-edit-panel", handler(t, e) { if (!e) return false; const n = t.get(K); return e.customRangeId ? n.startEditing(e) : n.startAddEditing(e), true; } }; var Je = { type: ar.OPERATION, id: "sheet.operation.close-hyper-link-popup", handler(t) { return t.get(K).endEditing(), true; } }; var At2 = { type: ar.OPERATION, id: "sheet.operation.insert-hyper-link", handler(t) { var g; const e = t.get(_n), n = N(e), i = t.get(tt); if (!n) return false; const r = t.get(Pt), s = t.get(F).getCurrentLastSelection(); if (!s) return false; const c = s.range.startRow, l = s.range.startColumn, p = i.isVisible(), u = ((g = e.getFocusedUnit()) == null ? void 0 : g.getUnitId()) === Hd; return r.executeCommand(jt2.id, { unitId: n.unitId, subUnitId: n.subUnitId, row: c, col: l, type: u ? m2.ZEN_EDITOR : p.visible ? m2.EDITING : m2.VIEWING }); } }; var de = { type: ar.OPERATION, id: "sheet.operation.insert-hyper-link-toolbar", handler(t) { if (ts(t)) return false; const e = t.get(Pt); return t.get(K).currentEditing ? e.executeCommand(Je.id) : e.executeCommand(At2.id); } }; var Bt2 = (t, e = Hd) => { var r; const n = t.get(_n), i = (r = t.get(Yx).getRenderById(e)) == null ? void 0 : r.with(Se); return i ? i.textSelectionInner$.pipe(map(() => { const s = t.get(tt).getEditCellState(); if (!s) return true; const c = N(n, { unitId: s.unitId, subUnitId: s.sheetId }); return !(c != null && c.worksheet) || $t(t, c.worksheet, s.row, s.column) === 1 ? true : ns(t); })) : of(true); }; var Gn3 = (t) => { 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( filter((s) => !!s), map((s) => n.getUnit(s, Fe.UNIVER_SHEET)), filter((s) => !!s), switchMap((s) => s.activeSheet$), switchMap((s) => i.selectionMoveEnd$.pipe(map((c) => s && { selections: c, sheet: s }))), map((s) => { if (!s) return Me2.DISABLED_BY_CELL; const { selections: c, sheet: l } = s; if (!c.length) return Me2.DISABLED_BY_CELL; const p = c[0].range.startRow, u = c[0].range.startColumn; return $t(t, l, p, u); }), switchMap((s) => { if (s === Me2.DISABLED_BY_CELL) return of(true); const c = (r ? r.visible$ : of(null)).pipe(map((p) => p != null && p.visible ? su : void 0)), l = t.get(fs).subscribeContextValue$(aE); return combineLatest([c, l]).pipe( switchMap( ([p, u]) => p ? u ? of(true) : Bt2(t, p) : of(s === Me2.ALLOW_ON_EDITING) ) ); }) ); return e.pipe( distinctUntilChanged(), switchMap((s) => o.pipe(map((c) => s || c))) ); }; var Xe = { commandId: At2.id, type: $e.BUTTON, title: "hyperLink.menu.add", icon: "LinkSingle" }; var Qe = (t) => `${t}-zen-editor`; var rs = (t) => ({ ...Xe, id: Xe.commandId, hidden$: Fa(t, Fe.UNIVER_SHEET), disabled$: Gn3(t) // disabled$: getObservableWithExclusiveRange$(accessor, getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })), }); var is2 = (t) => ({ ...Xe, id: Qe(Xe.commandId), hidden$: Fa(t, Fe.UNIVER_DOC, Hd), disabled$: Bt2(t) }); var et2 = { tooltip: "hyperLink.form.addTitle", commandId: de.id, type: $e.BUTTON, icon: "LinkSingle" }; var ss = (t) => ({ ...et2, id: et2.commandId, hidden$: Fa(t, Fe.UNIVER_SHEET), disabled$: Gn3(t) }); var os = (t) => ({ ...et2, id: Qe(et2.commandId), hidden$: Fa(t, Fe.UNIVER_DOC, Hd), disabled$: Bt2(t) }); var Kn = { id: de.id, binding: I1.K | Ae.CTRL_COMMAND, preconditions: De2 }; var as = Object.defineProperty; var cs = Object.getOwnPropertyDescriptor; var ls = (t, e, n, i) => { for (var r = i > 1 ? void 0 : i ? cs(e, n) : e, o = t.length - 1, s; o >= 0; o--) (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r); return i && r && as(e, n, r), r; }; var In = (t, e) => (n, i) => e(n, i, t); var tt2 = class extends nt { constructor(t, e) { super(), this._autoFillService = t, this._hyperLinkModel = e, this._initAutoFill(); } // eslint-disable-next-line max-lines-per-function _initAutoFill() { const t = () => ({ redos: [], undos: [] }), e = (i, r) => { const { source: o, target: s, unitId: c, subUnitId: l } = i, p = _s([o, s]), [u, g] = p.ranges, { mapFunc: d } = p, v = { row: u.startRow, col: u.startColumn }, C = tE(u, g), _ = [], O2 = []; return C.forEach((a) => { const b = a.repeatStartCell, M = a.relativeRange, k2 = { startRow: v.row, startColumn: v.col, endColumn: v.col, endRow: v.row }, L = { startRow: b.row, startColumn: b.col, endColumn: b.col, endRow: b.row }; tr.foreach(M, (j, D) => { const q = en.getPositionRange( { startRow: j, startColumn: D, endColumn: D, endRow: j }, k2 ), { row: Ee, col: je } = d(q.startRow, q.startColumn), se = this._hyperLinkModel.getHyperLinkByLocation(c, l, Ee, je), Re = en.getPositionRange( { startRow: j, startColumn: D, endColumn: D, endRow: j }, L ), { row: Le, col: Pe2 } = d(Re.startRow, Re.startColumn), oe = re.generateRandomId(), A = this._hyperLinkModel.getHyperLinkByLocation(c, l, Le, Pe2); A && _.push({ id: k.id, params: { unitId: c, subUnitId: l, id: A.id } }), (ke.COPY === r || ke.SERIES === r) && se && (_.push({ id: O.id, params: { unitId: c, subUnitId: l, link: { ...se, id: oe, row: Le, column: Pe2 } } }), O2.push({ id: k.id, params: { unitId: c, subUnitId: l, id: oe } })), A && O2.push({ id: O.id, params: { unitId: c, subUnitId: l, link: A } }); }); }), { undos: O2, redos: _ }; }, n = { id: Ht, onFillData: (i, r, o) => o === ke.COPY || o === ke.ONLY_FORMAT || o === ke.SERIES ? e(i, o) : t() }; this.disposeWithMe(this._autoFillService.addHook(n)); } }; tt2 = ls([ In(0, Hr), In(1, ot(I)) ], tt2); var us = Object.defineProperty; var ds = Object.getOwnPropertyDescriptor; var ps = (t, e, n, i) => { for (var r = i > 1 ? void 0 : i ? ds(e, n) : e, o = t.length - 1, s; o >= 0; o--) (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r); return i && r && us(e, n, r), r; }; var Rt = (t, e) => (n, i) => e(n, i, t); var nt2 = class extends nt { constructor(t, e, n) { super(), this._localeService = t, this._commandService = e, this._sheetPermissionCheckController = n, this._commandExecutedListener(); } _commandExecutedListener() { this.disposeWithMe( this._commandService.beforeCommandExecuted((t) => { t.id === Kn.id && (this._sheetPermissionCheckController.permissionCheckWithRanges({ workbookTypes: [Me], rangeTypes: [Pe], worksheetTypes: [Te, wn, or] }) || this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.hyperLinkErr"))); }) ); } }; nt2 = ps([ Rt(0, ot(Vr)), Rt(1, Pt), Rt(2, ot(Nn)) ], nt2); var hs = Object.defineProperty; var gs2 = Object.getOwnPropertyDescriptor; var fs2 = (t, e, n, i) => { for (var r = i > 1 ? void 0 : i ? gs2(e, n) : e, o = t.length - 1, s; o >= 0; o--) (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r); return i && r && hs(e, n, r), r; }; var G = (t, e) => (n, i) => e(n, i, t); var rt2 = class extends nt { constructor(t, e, n, i, r, o, s, c, l, p) { 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(); } _getLinkPermission(t) { const { unitId: e, subUnitId: n, row: i, col: r } = t, o = this._univerInstanceService.getUnit(e, Fe.UNIVER_SHEET); if (!(o == null ? void 0 : o.getSheetBySheetId(n))) return { viewPermission: false, editPermission: false, copyPermission: false }; const c = this._sheetPermissionCheckController.permissionCheckWithRanges({ workbookTypes: [Js], worksheetTypes: [Hn], rangeTypes: [Io] }, [{ startRow: i, startColumn: r, endRow: i, endColumn: r }]), l = this._sheetPermissionCheckController.permissionCheckWithRanges({ workbookTypes: [Me], worksheetTypes: [Te, or], rangeTypes: [Pe] }, [{ 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); return { viewPermission: c, editPermission: l, copyPermission: p }; } _initHoverListener() { this.disposeWithMe( // hover over not editing cell this._hoverManagerService.currentRichText$.pipe(debounceTime(200)).subscribe((t) => { var k2, L; if (!t) { this._sheetsHyperLinkPopupService.hideCurrentPopup(); return; } const { unitId: e, subUnitId: n, row: i, col: r } = t, o = this._renderManagerService.getRenderById(e); if (!o) return; const s = this._univerInstanceService.getUnit(e, Fe.UNIVER_SHEET), c = s == null ? void 0 : s.getSheetBySheetId(n); if (!c) return; if (!o.with(el).active) { this._sheetsHyperLinkPopupService.hideCurrentPopup(m2.VIEWING); return; } const p = (k2 = o == null ? void 0 : o.with(me).getWorksheetSkeleton(n)) == null ? void 0 : k2.skeleton, u = r, g = i; let d = g, v = u; p && p.overflowCache.forValue((j, D, q) => { en.contains(q, { startColumn: u, endColumn: u, startRow: g, endRow: g }) && (d = j, v = D); }); const { viewPermission: C, editPermission: _, copyPermission: O2 } = this._getLinkPermission(t); if (!C) { this._sheetsHyperLinkPopupService.hideCurrentPopup(); return; } const a = c.getCellStyleOnly(d, v), b = s.getStyles().getStyleByCell(a), M = (L = b == null ? void 0 : b.tr) == null ? void 0 : L.a; if (!M && !t.customRange) { this._sheetsHyperLinkPopupService.hideCurrentPopup(); return; } this._sheetsHyperLinkPopupService.showPopup({ row: d, col: v, editPermission: _, copyPermission: O2, customRange: t.customRange, customRangeRect: t.rect, type: m2.VIEWING, unitId: e, subUnitId: n, showAll: !!M }); }) ); } _initHoverEditingListener() { let t = null; this.disposeWithMe( this._editorBridgeService.currentEditCellState$.pipe(switchMap((e) => this._editorBridgeService.visible$.pipe(map((n) => ({ visible: n, state: e }))))).subscribe(({ visible: e, state: n }) => { if (!n || n.editorUnitId !== su) return; if (!e.visible) { t == null || t.unsubscribe(), this._sheetsHyperLinkPopupService.hideCurrentPopup(m2.EDITING), this._sheetsHyperLinkPopupService.endEditing(m2.EDITING); return; } const { editorUnitId: i, unitId: r, sheetId: o, row: s, column: c } = n, l = this._renderManagerService.getRenderById(i); if (!l) return; const { editPermission: p, viewPermission: u, copyPermission: g } = this._getLinkPermission({ unitId: r, subUnitId: o, row: s, col: c }), d = l.with(Gn2); u && (t == null || t.unsubscribe(), t = d.hoverCustomRanges$.pipe(debounceTime(200)).subscribe((v) => { var b, M; const C = v.find((k2) => k2.range.rangeType === mn.HYPERLINK); if (!C) { this._sheetsHyperLinkPopupService.hideCurrentPopup(); return; } const _ = C.rects[C.rects.length - 1]; if (!((M = (b = this._renderManagerService.getRenderById(r)) == null ? void 0 : b.with(me).getWorksheetSkeleton(o)) == null ? void 0 : M.skeleton) || !_) return; const a = l.engine.getCanvasElement().getBoundingClientRect(); this._sheetsHyperLinkPopupService.showPopup({ unitId: r, subUnitId: o, row: s, col: c, customRange: C.range, customRangeRect: { left: _.left + a.left, top: _.top + a.top, bottom: _.bottom + a.top, right: _.right + a.left }, editPermission: p, copyPermission: g, type: m2.EDITING }); })); }) ), this.disposeWithMe(() => { t == null || t.unsubscribe(); }); } _initZenEditor() { this.disposeWithMe( this._zenZoneService.visible$.subscribe((t) => { 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)); }) ), this.disposeWithMe( this._univerInstanceService.focused$.pipe( switchMap((t) => { const e = t === Hd ? this._renderManagerService.getRenderById(t) : null; return e ? e.with(Gn2).hoverCustomRanges$.pipe(debounceTime(200)) : new Observable((n) => { n.next(null); }); }) ).subscribe((t) => { const e = t == null ? void 0 : t.find((i) => i.range.rangeType === mn.HYPERLINK), n = this._editorBridgeService.getEditCellState(); if (e && n) { 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 }); l && this._sheetsHyperLinkPopupService.showPopup({ type: m2.ZEN_EDITOR, unitId: i, subUnitId: r, row: o, col: s, customRange: e.range, editPermission: c, copyPermission: p }); } else this._sheetsHyperLinkPopupService.hideCurrentPopup(m2.ZEN_EDITOR); }) ); } _initTextSelectionListener() { this.disposeWithMe( this._textSelectionManagerService.textSelection$.subscribe((t) => { t && t.unitId === su && this._sheetsHyperLinkPopupService.endEditing(m2.EDITING); }) ); } _initCommandListener() { const t = [Co.id, po.id, So.id]; this.disposeWithMe(this._commandService.onCommandExecuted((e) => { t.includes(e.id) && this._sheetsHyperLinkPopupService.hideCurrentPopup(); })); } }; rt2 = fs2([ G(0, ot(Er)), G(1, ot(K)), G(2, ot(Yx)), G(3, ot(UE)), G(4, ot(Nn)), G(5, Pt), G(6, tt), G(7, ot(m)), G(8, _n), G(9, u3) ], rt2); var ms = Object.defineProperty; var _s2 = Object.getOwnPropertyDescriptor; var Yn = (t, e, n, i) => { for (var r = i > 1 ? void 0 : i ? _s2(e, n) : e, o = t.length - 1, s; o >= 0; o--) (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r); return i && r && ms(e, n, r), r; }; var wt = (t, e) => (n, i) => e(n, i, t); var Ot2 = class extends nt { constructor(t, e) { super(), this._context = t, this._hyperLinkModel = e, this._initSkeletonChange(); } _initSkeletonChange() { const t = () => { var e; (e = this._context.mainComponent) == null || e.makeForceDirty(); }; this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(debounceTime(16)).subscribe(() => { t(); })); } }; Ot2 = Yn([ wt(1, ot(I)) ], Ot2); var it2 = class extends nt { constructor(t, e) { super(), this._sheetInterceptorService = t, this._hyperLinkModel = e, this._initViewModelIntercept(); } _initViewModelIntercept() { this.disposeWithMe( this._sheetInterceptorService.intercept( et.CELL_CONTENT, { effect: Vn.Value, priority: 100, handler: (t, e, n) => { const { row: i, col: r, unitId: o, subUnitId: s } = e, c = this._hyperLinkModel.getHyperLinkByLocation(o, s, i, r); return n(c ? { ...t, linkUrl: c.payload, linkId: c.id } : t); } } ) ); } }; it2 = Yn([ wt(0, ot(V)), wt(1, ot(I)) ], it2); var vs = { [l1.OTHERS]: { [de.id]: { order: 2, menuItemFactory: ss }, [Qe(de.id)]: { order: 2, menuItemFactory: os } }, [P1.MAIN_AREA]: { [He.OTHERS]: { order: 1, [de.id]: { order: 0, menuItemFactory: rs }, [Qe(de.id)]: { order: 0, menuItemFactory: is2 } } } }; var Ss = Object.defineProperty; var Cs = Object.getOwnPropertyDescriptor; var Is = (t, e, n, i) => { for (var r = i > 1 ? void 0 : i ? Cs(e, n) : e, o = t.length - 1, s; o >= 0; o--) (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r); return i && r && Ss(e, n, r), r; }; var Te2 = (t, e) => (n, i) => e(n, i, t); var st2 = class extends nt { constructor(t, e, n, i, r) { super(), this._componentManager = t, this._commandService = e, this._menuManagerService = n, this._injector = i, this._shortcutService = r, this._initComponents(), this._initCommands(), this._initMenus(), this._initShortCut(); } _initComponents() { [ [qe, qe.componentKey], [ze, ze.componentKey], [Dt, "LinkSingle"] ].forEach(([t, e]) => { this._componentManager.register(e, t); }); } _initCommands() { [ jt2, Je, At2, de ].forEach((t) => { this._commandService.registerCommand(t); }); } _initMenus() { this._menuManagerService.mergeMenu(vs); } _initShortCut() { this._shortcutService.registerShortcut(Kn); } }; st2 = Is([ Te2(0, ot(n1)), Te2(1, Pt), Te2(2, m1), Te2(3, ot(Ot)), Te2(4, ot(it)) ], st2); var ys2 = Object.defineProperty; var Es = Object.getOwnPropertyDescriptor; var Rs = (t, e, n, i) => { for (var r = i > 1 ? void 0 : i ? Es(e, n) : e, o = t.length - 1, s; o >= 0; o--) (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r); return i && r && ys2(e, n, r), r; }; var yn = (t, e) => (n, i) => e(n, i, t); var ot2 = class extends nt { constructor(t, e) { super(), this._parserService = t, this._resolverService = e, this._handleInitUrl(); } _handleInitUrl() { const t = location.hash; if (t) { const e = this._parserService.parseHyperLink(t); this._resolverService.navigate(e); } } }; ot2 = Rs([ yn(0, ot(ye)), yn(1, ot(pe)) ], ot2); var zn = Object.defineProperty; var Ls2 = Object.getOwnPropertyDescriptor; var Ps = (t, e, n) => e in t ? zn(t, e, { enumerable: true, configurable: true, writable: true, value: n }) : t[e] = n; var bs = (t, e, n, i) => { for (var r = i > 1 ? void 0 : i ? Ls2(e, n) : e, o = t.length - 1, s; o >= 0; o--) (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r); return i && r && zn(e, n, r), r; }; var En = (t, e) => (n, i) => e(n, i, t); var qn = (t, e, n) => Ps(t, typeof e != "symbol" ? e + "" : e, n); var at = class extends Ra { constructor(t = gn, e, n) { super(), this._config = t, this._injector = e, this._configService = n; const { menu: i, ...r } = nu( {}, gn, this._config ); i && this._configService.setConfig("menu", i, { merge: true }), this._configService.setConfig($n, r); } onStarting() { [ [pe], [K], [jn], [it2], [rt2], [st2], [tt2], [Ye], [nt2], [ot2] ].forEach((e) => this._injector.add(e)), this._injector.get(it2); } onReady() { this._injector.get(Yx).registerRenderModule(Fe.UNIVER_SHEET, [Ot2]), this._injector.get(tt2), this._injector.get(Ye), this._injector.get(st2); } onRendered() { this._injector.get(nt2), this._injector.get(ot2), this._injector.get(rt2); } }; qn(at, "pluginName", Ht); qn(at, "type", Fe.UNIVER_SHEET); at = bs([ OR(ae, gs), En(1, ot(Ot)), En(2, SE) ], at); export { pe, Ye, jn, K, jt2 as jt, Je, At2 as At, Kn, at }; /*! Bundled license information: @univerjs/sheets-hyper-link-ui/lib/es/index.js: (** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. *) */ //# sourceMappingURL=chunk-S7YN35PX.js.map