import { Nu, me } from "./chunk-T4NNB5UY.js"; import { Aa, F, Xa } from "./chunk-BW43Z7N3.js"; import { $e, Fa, He, P1, m1, n1 } from "./chunk-POAJ2YNP.js"; import { A1, Yx, q3 } from "./chunk-2MK3Q52E.js"; import { BehaviorSubject, De, Fe, Nt, Ot, Pt, Ra, SE, W0, ar, combineLatest, en, fs, map, merge, nt, nu, ot, startWith, tap, z0 } from "./chunk-23V3HWTR.js"; import { require_react } from "./chunk-GNR2UJZM.js"; import { __toESM } from "./chunk-2LSFTFF7.js"; // node_modules/.pnpm/@univerjs+sheets-crosshair-highlight@0.5.5_@grpc+grpc-js@1.13.4_react-dom@18.3.1_react@18.3.1_gzzch6qfsqbrjibr7uqhl3ehqe/node_modules/@univerjs/sheets-crosshair-highlight/lib/es/index.js var import_react = __toESM(require_react()); var re = Object.defineProperty; var ne = (n, e, t) => e in n ? re(n, e, { enumerable: true, configurable: true, writable: true, value: t }) : n[e] = t; var h = (n, e, t) => ne(n, typeof e != "symbol" ? e + "" : e, t); var Pe = "sheets-crosshair-highlight.config"; var A = {}; var g = function() { return g = Object.assign || function(n) { for (var e, t = 1, r = arguments.length; t < r; t++) { e = arguments[t]; for (var s in e) Object.prototype.hasOwnProperty.call(e, s) && (n[s] = e[s]); } return n; }, g.apply(this, arguments); }; var Te = function(n, e) { var t = {}; for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && e.indexOf(r) < 0 && (t[r] = n[r]); if (n != null && typeof Object.getOwnPropertySymbols == "function") for (var s = 0, r = Object.getOwnPropertySymbols(n); s < r.length; s++) e.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[s]) && (t[r[s]] = n[r[s]]); return t; }; var F2 = (0, import_react.forwardRef)(function(n, e) { var t = n.icon, r = n.id, s = n.className, i = n.extend, o = Te(n, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(r, " ").concat(s || "").trim(), c = (0, import_react.useRef)("_".concat(Ve())); return W(t, "".concat(r), { defIds: t.defIds, idSuffix: c.current }, g({ ref: e, className: a }, o), i); }); function W(n, e, t, r, s) { return (0, import_react.createElement)(n.tag, g(g({ key: e }, Ne(n, t, s)), r), (je(n, t).children || []).map(function(i, o) { return W(i, "".concat(e, "-").concat(n.tag, "-").concat(o), t, void 0, s); })); } function Ne(n, e, t) { var r = g({}, n.attrs); t != null && t.colorChannel1 && r.fill === "colorChannel1" && (r.fill = t.colorChannel1); var s = e.defIds; return !s || s.length === 0 || (n.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(i) { var o = i[0], a = i[1]; typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")"))); })), r; } function je(n, e) { var t, r = e.defIds; return !r || r.length === 0 ? n : n.tag === "defs" && (!((t = n.children) === null || t === void 0) && t.length) ? g(g({}, n), { children: n.children.map(function(s) { return typeof s.attrs.id == "string" && r && r.indexOf(s.attrs.id) > -1 ? g(g({}, s), { attrs: g(g({}, s.attrs), { id: s.attrs.id + e.idSuffix }) }) : s; }) }) : n; } function Ve() { return Math.random().toString(36).substring(2, 8); } F2.displayName = "UniverIcon"; var Le = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "#E5E5E5", d: "M1.6499 3.65002C1.6499 2.54545 2.54533 1.65002 3.6499 1.65002H12.3499C13.4545 1.65002 14.3499 2.54545 14.3499 3.65002V12.35C14.3499 13.4546 13.4545 14.35 12.3499 14.35H3.6499C2.54533 14.35 1.6499 13.4546 1.6499 12.35V3.65002Z" } }, { tag: "path", attrs: { fill: "#fff", d: "M9.9998 1.65002H5.9998V6H1.6499V10H5.9998V14.35H9.9998V10H14.3499V6H9.9998V1.65002Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.6498 1.05005C2.21386 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V3.65005C14.9498 2.21411 13.7857 1.05005 12.3498 1.05005H3.6498ZM5.4002 2.25005H3.6498C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V5.40002H5.4002V2.25005ZM2.2498 10.6V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H5.4002V10.6H2.2498ZM6.60019 13.75H9.4002V9.40002H13.7498V6.60002H9.4002V2.25005H6.60019V6.60002H2.25029V9.40002H6.60019V13.75ZM10.6002 2.25005V5.40002H13.7498V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H10.6002ZM13.7498 10.6H10.6002V13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.6Z", fillRule: "evenodd", clipRule: "evenodd" } }] }; var Y = (0, import_react.forwardRef)(function(n, e) { return (0, import_react.createElement)(F2, Object.assign({}, n, { id: "cross-highlighting-single", ref: e, icon: Le })); }); Y.displayName = "CrossHighlightingSingle"; var q = [ "rgba(158, 109, 227, 0.3)", "rgba(254, 75, 75, 0.3)", "rgba(255, 140, 81, 0.3)", "rgba(164, 220, 22, 0.3)", "rgba(45, 174, 255, 0.3)", "rgba(58, 96, 247, 0.3)", "rgba(242, 72, 166, 0.3)", "rgba(153, 153, 153, 0.3)", "rgba(158, 109, 227, 0.15)", "rgba(254, 75, 75, 0.15)", "rgba(255, 140, 81, 0.15)", "rgba(164, 220, 22, 0.15)", "rgba(45, 174, 255, 0.15)", "rgba(58, 96, 247, 0.15)", "rgba(242, 72, 166, 0.15)", "rgba(153, 153, 153, 0.15)" ]; var S = class extends nt { constructor() { super(...arguments); h(this, "_enabled$", new BehaviorSubject(false)); h(this, "enabled$", this._enabled$.asObservable()); h(this, "_color$", new BehaviorSubject(q[0])); h(this, "color$", this._color$.asObservable()); } get enabled() { return this._enabled$.getValue(); } get color() { return this._color$.getValue(); } dispose() { this._enabled$.complete(); } setEnabled(t) { this._enabled$.next(t); } setColor(t) { this._color$.next(t); } }; var M = { id: "sheet.operation.toggle-crosshair-highlight", type: ar.OPERATION, handler(n) { const e = n.get(S), t = e.enabled; return e.setEnabled(!t), true; } }; var J = { id: "sheet.operation.set-crosshair-highlight-color", type: ar.OPERATION, handler(n, { value: e }) { const t = n.get(S); return t.enabled || t.setEnabled(true), t.setColor(e), true; } }; var Ae = { id: "sheet.operation.enable-crosshair-highlight", type: ar.OPERATION, handler(n) { const e = n.get(S); return e.enabled ? false : (e.setEnabled(true), true); } }; var Ge = { id: "sheet.operation.disable-crosshair-highlight", type: ar.OPERATION, handler(n) { const e = n.get(S); return e.enabled ? (e.setEnabled(false), true) : false; } }; var I = { exports: {} }; var m = {}; var G; function Ue() { if (G) return m; G = 1; var n = import_react.default, e = Symbol.for("react.element"), t = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, s = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: true, ref: true, __self: true, __source: true }; function o(a, c, f) { var l, d = {}, _ = null, u = null; f !== void 0 && (_ = "" + f), c.key !== void 0 && (_ = "" + c.key), c.ref !== void 0 && (u = c.ref); for (l in c) r.call(c, l) && !i.hasOwnProperty(l) && (d[l] = c[l]); if (a && a.defaultProps) for (l in c = a.defaultProps, c) d[l] === void 0 && (d[l] = c[l]); return { $$typeof: e, type: a, key: _, ref: u, props: d, _owner: s.current }; } return m.Fragment = t, m.jsx = o, m.jsxs = o, m; } var U; function De2() { return U || (U = 1, I.exports = Ue()), I.exports; } var D = De2(); function X(n) { var e, t, r = ""; if (typeof n == "string" || typeof n == "number") r += n; else if (typeof n == "object") if (Array.isArray(n)) { var s = n.length; for (e = 0; e < s; e++) n[e] && (t = X(n[e])) && (r && (r += " "), r += t); } else for (t in n) n[t] && (r && (r += " "), r += t); return r; } function ke() { for (var n, e, t = 0, r = "", s = arguments.length; t < s; t++) (n = arguments[t]) && (e = X(n)) && (r && (r += " "), r += e); return r; } var Ze = "univer-crosshair-highlight-overlay"; var Be = "univer-crosshair-highlight-item"; var Fe2 = "univer-crosshair-highlight-item-selected"; var y = { crosshairHighlightOverlay: Ze, crosshairHighlightItem: Be, crosshairHighlightItemSelected: Fe2 }; function We(n) { const { onChange: e } = n, t = W0(S), r = z0(t.color$), s = (0, import_react.useCallback)((i) => { e == null || e(i); }, [e]); return D.jsx("div", { className: y.crosshairHighlightOverlay, children: q.map((i) => D.jsx( "div", { className: ke(y.crosshairHighlightItem, { [y.crosshairHighlightItemSelected]: i === r }), style: { backgroundColor: i }, onClick: () => s(i) }, i )) }); } var K = "CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT"; function Ye(n) { const e = n.get(S); return { id: M.id, tooltip: "crosshair.button.tooltip", type: $e.BUTTON_SELECTOR, icon: "CrossHighlightingSingle", selections: [ { label: { name: K, hoverable: false } } ], selectionsCommandId: J.id, activated$: e.enabled$, hidden$: Fa(n, Fe.UNIVER_SHEET) }; } var qe = { [P1.FOOTER_MENU]: { [He.OTHERS]: { [M.id]: { order: 0, menuItemFactory: Ye } } } }; var Je = Object.defineProperty; var Xe = Object.getOwnPropertyDescriptor; var Ke = (n, e, t, r) => { for (var s = r > 1 ? void 0 : r ? Xe(e, t) : e, i = n.length - 1, o; i >= 0; i--) (o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s); return r && s && Je(e, t, s), s; }; var E = (n, e) => (t, r) => e(t, r, n); var b = class extends nt { constructor(n, e, t) { super(), this._componentMgr = n, this._menuManagerService = e, this._cmdSrv = t, this._initCommands(), this._initMenus(), this._initComponents(); } _initCommands() { [ M, J, Ae, Ge ].forEach((n) => this._cmdSrv.registerCommand(n)); } _initMenus() { this._menuManagerService.mergeMenu(qe); } _initComponents() { this._componentMgr.register(K, We), this._componentMgr.register("CrossHighlightingSingle", Y); } }; b = Ke([ E(0, ot(n1)), E(1, m1), E(2, Pt) ], b); var ze = 1; var Qe = class { constructor() { h(this, "_selectedRanges", []); h(this, "_ranges", []); } addRange(e) { if (e.rangeType === De.COLUMN || e.rangeType === De.ROW || e.rangeType === De.ALL) return; const t = this._getIntersects(e), r = this._getSplitRanges(e, t); r.length > 0 && this._ranges.push(...r); } setSelectedRanges(e) { this._selectedRanges = e; } _getSplitRanges(e, t) { let r = [e]; for (const s of t.concat(this._selectedRanges)) { const i = []; for (const o of r) { const a = en.subtract(o, s); a && a.length > 0 && i.push(...a); } r = i; } return r.filter((s) => s.startRow <= s.endRow && s.startColumn <= s.endColumn); } _getIntersects(e) { const t = []; for (const r of this._ranges) { const s = en.getIntersects(r, e); s && t.push(s); } return t; } getRanges() { return this._ranges; } reset() { this._ranges = [], this._selectedRanges = []; } }; var et = class extends q3 { constructor(t, r) { super(t, r); h(this, "_color"); r && this.setShapeProps(r); } setShapeProps(t) { typeof t.color < "u" && (this._color = t.color), this.transformByState({ width: t.width, height: t.height }); } _draw(t) { const r = `rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${this._color.a})`; A1.drawWith(t, { width: this.width, height: this.height, fill: r, stroke: void 0, strokeWidth: 0, evented: false }); } }; var tt = Object.defineProperty; var rt = Object.getOwnPropertyDescriptor; var nt2 = (n, e, t, r) => { for (var s = r > 1 ? void 0 : r ? rt(e, t) : e, i = n.length - 1, o; i >= 0; i--) (o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s); return r && s && tt(e, t, s), s; }; var C = (n, e) => (t, r) => e(t, r, n); var H = class extends nt { constructor(e, t, r, s, i, o) { super(); h(this, "_shapes", []); h(this, "_rangeCollection", new Qe()); h(this, "_color", "rgba(255,0,0,0.5)"); this._context = e, this._sheetSkeletonManagerService = t, this._sheetsSelectionsService = r, this._sheetsCrosshairHighlightService = s, this._contextService = i, this._refSelectionsService = o, this._initRenderListener(); } _transformSelection(e, t) { if (!e) return; const r = t.getRowCount(), s = t.getColumnCount(), i = []; for (const o of e) { const { startRow: a, endRow: c, startColumn: f, endColumn: l } = o.range; c - a + 1 === r || l - f + 1 === s || i.push(o.range); } this._rangeCollection.setSelectedRanges(i); for (const o of i) this.addSelection(o, t); } _initRenderListener() { const e = this._context.unit; this.disposeWithMe(combineLatest([ this._contextService.subscribeContextValue$(Aa).pipe(startWith(false)), this._sheetSkeletonManagerService.currentSkeleton$, this._sheetsCrosshairHighlightService.enabled$, this._sheetsCrosshairHighlightService.color$.pipe(tap((t) => this._color = t)), merge( this._sheetsSelectionsService.selectionMoveStart$, this._sheetsSelectionsService.selectionMoving$, this._sheetsSelectionsService.selectionMoveEnd$, this._sheetsSelectionsService.selectionSet$, e.activeSheet$.pipe(map(() => this._sheetsSelectionsService.getCurrentSelections())) ), merge( this._refSelectionsService.selectionMoveStart$, this._refSelectionsService.selectionMoving$, this._refSelectionsService.selectionMoveEnd$, this._sheetsSelectionsService.selectionSet$, e.activeSheet$.pipe(map(() => this._refSelectionsService.getCurrentSelections())) ) ]).subscribe(([t, r, s, i, o, a]) => { if (this._clear(), !s) return; const c = t ? a : o; this._rangeCollection.reset(), this._transformSelection(c, e.getActiveSheet()), this.render(this._rangeCollection.getRanges()); })); } addSelection(e, t) { if (e.rangeType === De.COLUMN || e.rangeType === De.ROW || e.rangeType === De.ALL) return; const r = t.getRowCount(), s = t.getColumnCount(), { startRow: i, endRow: o, startColumn: a, endColumn: c } = e, f = { startRow: i, endRow: o, startColumn: 0, endColumn: a - 1 }, l = { startRow: i, endRow: o, startColumn: c + 1, endColumn: s }, d = { startRow: 0, endRow: i - 1, startColumn: a, endColumn: c }, _ = { startRow: o + 1, endRow: r, startColumn: a, endColumn: c }; for (const u of [f, l, d, _]) u.startRow <= u.endRow && u.startColumn <= u.endColumn && this._rangeCollection.addRange(u); } _clear() { this._shapes.forEach((e) => { e.dispose(); }), this._shapes = []; } _addShapes(e, t, r, s) { const { startRow: i, endRow: o, startColumn: a, endColumn: c } = e, f = Nu(i, a, r, s), l = Nu(o, c, r, s), { startX: d, startY: _ } = f, { endX: u, endY: z } = l, Q = u - d, ee = z - _, te = { left: d, top: _, color: new Nt(this._color).toRgb(), width: Q, height: ee, zIndex: ze, evented: false }, P = new et(`crosshair-${t}`, te); this._shapes.push(P), r.addObject(P); } render(e) { const t = this._sheetSkeletonManagerService.getCurrentSkeleton(); if (!t) return; const { scene: r } = this._context; this._clear(); for (let s = 0; s < e.length; s++) { const i = e[s]; this._addShapes(i, s, r, t); } r.makeDirty(true); } async dispose() { super.dispose(); } }; H = nt2([ C(1, ot(me)), C(2, ot(F)), C(3, ot(S)), C(4, ot(fs)), C(5, Xa) ], H); var st = Object.defineProperty; var it = Object.getOwnPropertyDescriptor; var ot2 = (n, e, t, r) => { for (var s = r > 1 ? void 0 : r ? it(e, t) : e, i = n.length - 1, o; i >= 0; i--) (o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s); return r && s && st(e, t, s), s; }; var w = (n, e) => (t, r) => e(t, r, n); var R; var k = (R = class extends Ra { constructor(n = A, e, t, r) { super(), this._config = n, this._injector = e, this._renderManagerService = t, this._configService = r; const { ...s } = nu( {}, A, this._config ); this._configService.setConfig(Pe, s); } onStarting() { [ [S], [b] ].forEach((n) => this._injector.add(n)); } onReady() { [ [H] ].forEach((n) => this._injector.add(n)), this._injector.get(b), this._renderManagerService.registerRenderModule(Fe.UNIVER_SHEET, [H]); } }, h(R, "pluginName", "SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"), h(R, "type", Fe.UNIVER_SHEET), R); k = ot2([ w(1, ot(Ot)), w(2, Yx), w(3, SE) ], k); export { q, S, M, J, Ae, Ge, k }; /*! Bundled license information: @univerjs/sheets-crosshair-highlight/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-75UPVUU3.js.map