@univerjs/sheets-numfmt-ui 0.6.7 → 0.6.9-experimental.20250403-d914ddc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js ADDED
@@ -0,0 +1,1100 @@
1
+ var dt = Object.defineProperty;
2
+ var ht = (e, t, r) => t in e ? dt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var J = (e, t, r) => ht(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { Inject as S, LocaleService as M, IConfigService as Le, Disposable as oe, isRealNum as ft, CommandType as He, ILocalStorageService as Ae, numfmt as Q, ThemeService as pt, IUniverInstanceService as Se, ICommandService as ye, UniverInstanceType as T, CellValueType as x, toDisposable as ge, DisposableCollection as vt, InterceptorEffectEnum as Oe, Range as je, Injector as Be, Optional as gt, fromCallback as _t, DependentOn as St, Plugin as yt, merge as bt, registerDependencies as Ct, touchDependencies as It } from "@univerjs/core";
5
+ import { IRenderManagerService as We } from "@univerjs/engine-render";
6
+ import { SHEETS_NUMFMT_PLUGIN_CONFIG_KEY as Nt, currencySymbols as Ue, getDecimalFromPattern as te, getCurrencyType as V, setPatternDecimal as O, getCurrencyFormatOptions as ue, isPatternEqualWithoutDecimal as ce, CURRENCYFORMAT as Et, DATEFMTLISG as Tt, NUMBERFORMAT as Mt, getDateFormatOptions as Ve, getNumberFormatOptions as Ge, isPatternHasDecimal as Pt, SheetsNumfmtCellContentController as Ke, getPatternPreviewIgnoreGeneral as wt, getPatternType as ne, SetNumfmtCommand as Ze, SetPercentCommand as ze, SubtractDecimalCommand as Ye, AddDecimalCommand as Xe, SetCurrencyCommand as qe, MenuCurrencyService as Rt, countryCurrencyMap as $, getPatternPreview as Ot, UniverSheetsNumfmtPlugin as Ut } from "@univerjs/sheets-numfmt";
7
+ import { HoverManagerService as Dt, CellAlertManagerService as Ft, CellAlertType as kt, SheetSkeletonManagerService as $t, IEditorBridgeService as xt, deriveStateFromActiveSheet$ as Lt, getCurrentRangeDisable$ as G, UniverSheetsUIPlugin as Ht } from "@univerjs/sheets-ui";
8
+ import { FormulaDataModel as At } from "@univerjs/engine-formula";
9
+ import { isTextFormat as Je, isDefaultFormat as jt, DEFAULT_TEXT_FORMAT_EXCEL as Bt } from "@univerjs/engine-numfmt";
10
+ import { INumfmtService as be, SheetInterceptorService as Qe, SheetsSelectionsService as Ce, INTERCEPTOR_POINT as Wt, RemoveNumfmtMutation as Ie, SetNumfmtMutation as Ne, BEFORE_CELL_EDIT as Vt, AFTER_CELL_EDIT as Gt, SetRangeValuesCommand as Kt, transformCellsToRange as Zt, factorySetNumfmtUndoMutation as zt, factoryRemoveNumfmtUndoMutation as Yt, RangeProtectionPermissionEditPoint as K, WorksheetSetCellStylePermission as Z, WorksheetEditPermission as z, WorkbookEditablePermission as Y } from "@univerjs/sheets";
11
+ import { IZenZoneService as Xt, useDependency as C, ComponentManager as et, ISidebarService as qt, getMenuHiddenObservable as X, MenuItemType as q, ILayoutService as Jt, RibbonStartGroup as Qt, IMenuManagerService as en } from "@univerjs/ui";
12
+ import { debounceTime as tn, merge as tt, Observable as A, combineLatest as nn, filter as rn } from "rxjs";
13
+ import { map as sn, switchMap as on, tap as cn, debounceTime as an } from "rxjs/operators";
14
+ import { jsxs as b, jsx as u } from "react/jsx-runtime";
15
+ import { createContext as ln, useState as I, useEffect as ae, useRef as Ee, useContext as nt, useMemo as U, forwardRef as rt, createElement as Te } from "react";
16
+ import { InputNumber as Me, Select as Pe, SelectList as we, Input as mn, Button as De, Separator as un } from "@univerjs/design";
17
+ const Fe = {};
18
+ var dn = Object.getOwnPropertyDescriptor, hn = (e, t, r, n) => {
19
+ for (var i = n > 1 ? void 0 : n ? dn(t, r) : t, s = e.length - 1, o; s >= 0; s--)
20
+ (o = e[s]) && (i = o(i) || i);
21
+ return i;
22
+ }, D = (e, t) => (r, n) => t(r, n, e);
23
+ const de = "SHEET_NUMFMT_ALERT";
24
+ let _e = class extends oe {
25
+ constructor(e, t, r, n, i, s, o, a) {
26
+ super(), this._context = e, this._hoverManagerService = t, this._cellAlertManagerService = r, this._localeService = n, this._formulaDataModel = i, this._zenZoneService = s, this._numfmtService = o, this._configService = a, this._init();
27
+ }
28
+ _init() {
29
+ this._initCellAlertPopup(), this._initZenService();
30
+ }
31
+ _initCellAlertPopup() {
32
+ this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(tn(100)).subscribe((e) => {
33
+ var t, r;
34
+ if (e) {
35
+ const n = e.location, i = this._context.unit, s = i.getActiveSheet();
36
+ if (!s) return;
37
+ const o = n.unitId, a = n.subUnitId;
38
+ let c;
39
+ const m = s.getCell(n.row, n.col);
40
+ if (m != null && m.s) {
41
+ const d = i.getStyles().get(m.s);
42
+ d != null && d.n && (c = d.n);
43
+ }
44
+ if (c || (c = this._numfmtService.getValue(o, a, n.row, n.col)), !c) {
45
+ this._hideAlert();
46
+ return;
47
+ }
48
+ if (Je(c.pattern) && (m != null && m.v) && ft(m.v)) {
49
+ if ((t = this._configService.getConfig(Nt)) != null && t.disableTextFormatAlert)
50
+ return;
51
+ const d = this._cellAlertManagerService.currentAlert.get(de), l = (r = d == null ? void 0 : d.alert) == null ? void 0 : r.location;
52
+ if (l && l.row === n.row && l.col === n.col && l.subUnitId === n.subUnitId && l.unitId === n.unitId)
53
+ return;
54
+ this._cellAlertManagerService.showAlert({
55
+ type: kt.WARNING,
56
+ title: this._localeService.t("info.error"),
57
+ message: this._localeService.t("info.forceStringInfo"),
58
+ location: n,
59
+ width: 200,
60
+ height: 74,
61
+ key: de
62
+ });
63
+ return;
64
+ }
65
+ }
66
+ this._hideAlert();
67
+ }));
68
+ }
69
+ _initZenService() {
70
+ this.disposeWithMe(this._zenZoneService.visible$.subscribe((e) => {
71
+ e && this._hideAlert();
72
+ }));
73
+ }
74
+ _hideAlert() {
75
+ this._cellAlertManagerService.removeAlert(de);
76
+ }
77
+ };
78
+ _e = hn([
79
+ D(1, S(Dt)),
80
+ D(2, S(Ft)),
81
+ D(3, S(M)),
82
+ D(4, S(At)),
83
+ D(5, Xt),
84
+ D(6, S(be)),
85
+ D(7, Le)
86
+ ], _e);
87
+ const he = {
88
+ id: "sheet.operation.close.numfmt.panel",
89
+ type: He.OPERATION,
90
+ handler: () => (
91
+ // do nothing, just notify panel is closed
92
+ !0
93
+ )
94
+ }, j = {
95
+ id: "sheet.operation.open.numfmt.panel",
96
+ type: He.OPERATION,
97
+ handler: (e) => (e.get(W).openPanel(), !0)
98
+ };
99
+ var fn = Object.getOwnPropertyDescriptor, pn = (e, t, r, n) => {
100
+ for (var i = n > 1 ? void 0 : n ? fn(t, r) : t, s = e.length - 1, o; s >= 0; s--)
101
+ (o = e[s]) && (i = o(i) || i);
102
+ return i;
103
+ }, vn = (e, t) => (r, n) => t(r, n, e);
104
+ const Re = ln([]);
105
+ let B = class {
106
+ constructor(e) {
107
+ this._localStorageService = e;
108
+ }
109
+ _getKey(e) {
110
+ return `userHabitController_${e}`;
111
+ }
112
+ async addHabit(e, t) {
113
+ const r = this._getKey(e);
114
+ return this._localStorageService.getItem(r).then((n) => {
115
+ n || this._localStorageService.setItem(r, t);
116
+ });
117
+ }
118
+ markHabit(e, t) {
119
+ const r = this._getKey(e);
120
+ this._localStorageService.getItem(r).then((n) => {
121
+ if (n) {
122
+ const i = n.findIndex((s) => s === t);
123
+ i > -1 && n.splice(i, 1), n.unshift(t), this._localStorageService.setItem(r, n);
124
+ }
125
+ });
126
+ }
127
+ async getHabit(e, t) {
128
+ const r = this._getKey(e), n = await this._localStorageService.getItem(r);
129
+ if (t && n) {
130
+ const i = n.map((s, o, a) => {
131
+ const c = a.length;
132
+ return {
133
+ value: s,
134
+ priority: c - o
135
+ };
136
+ });
137
+ return t.sort((s, o) => {
138
+ var m, d;
139
+ const a = ((m = i.find((l) => l.value === s)) == null ? void 0 : m.priority) || -1;
140
+ return (((d = i.find((l) => l.value === o)) == null ? void 0 : d.priority) || -1) - a;
141
+ });
142
+ }
143
+ return n || [];
144
+ }
145
+ deleteHabit(e) {
146
+ this._localStorageService.removeItem(e);
147
+ }
148
+ };
149
+ B = pn([
150
+ vn(0, S(Ae))
151
+ ], B);
152
+ const ke = "numfmtCurrency", gn = (e) => {
153
+ const t = C(B), [r, n] = I(Ue);
154
+ return ae(() => {
155
+ t.addHabit("numfmtCurrency", []).then(() => {
156
+ t.getHabit(ke, [...Ue]).then((s) => {
157
+ n(s), e && e(s);
158
+ });
159
+ });
160
+ }, []), { userHabitCurrency: r, mark: (s) => {
161
+ t.markHabit(ke, s);
162
+ } };
163
+ }, _n = () => {
164
+ const e = Ee([]), [t, r] = I({});
165
+ return ae(() => {
166
+ e.current.forEach((i) => {
167
+ i();
168
+ }), e.current = [];
169
+ }, [t]), (i) => {
170
+ e.current.push(i), r({});
171
+ };
172
+ }, Sn = (e) => !!V(e) && e.startsWith("_("), yn = (e) => {
173
+ const { defaultPattern: t, action: r, onChange: n } = e, [i, s] = I(() => te(t || "", 2)), o = nt(Re), [a, c] = I(() => V(t) || o[0]), m = U(() => o.map((v) => ({ label: v, value: v })), []), l = C(M).t;
174
+ r.current = () => O(`_("${a}"* #,##0${i > 0 ? ".0" : ""}_)`, i);
175
+ const h = (v) => {
176
+ c(v), n(O(`_("${v}"* #,##0${i > 0 ? ".0" : ""}_)`, i));
177
+ }, p = (v) => {
178
+ const f = v || 0;
179
+ s(f), n(O(`_("${a}"* #,##0${f > 0 ? ".0" : ""}_)`, f));
180
+ };
181
+ return /* @__PURE__ */ b("div", { children: [
182
+ /* @__PURE__ */ b("div", { className: "m-t-16 options", children: [
183
+ /* @__PURE__ */ b("div", { className: "option", children: [
184
+ /* @__PURE__ */ u("div", { className: "label", children: l("sheet.numfmt.decimalLength") }),
185
+ /* @__PURE__ */ u("div", { className: "m-t-8 w-120", children: /* @__PURE__ */ u(Me, { value: i, max: 20, min: 0, onChange: p }) })
186
+ ] }),
187
+ /* @__PURE__ */ b("div", { className: "option", children: [
188
+ /* @__PURE__ */ u("div", { className: "label", children: l("sheet.numfmt.currencyType") }),
189
+ /* @__PURE__ */ u("div", { className: "m-t-8 w-140", children: /* @__PURE__ */ u(Pe, { onChange: h, options: m, value: a }) })
190
+ ] })
191
+ ] }),
192
+ /* @__PURE__ */ u("div", { className: "describe m-t-14", children: l("sheet.numfmt.accountingDes") })
193
+ ] });
194
+ }, bn = (e) => !!V(e) && !e.startsWith("_("), Cn = (e) => {
195
+ const r = C(M).t, n = nt(Re), [i, s] = I(() => V(e.defaultPattern) || n[0]), [o, a] = I(() => te(e.defaultPattern || "", 2)), [c, m] = I(() => {
196
+ var g;
197
+ const f = ue(i);
198
+ return ((g = f.find((N) => ce(N.value, e.defaultPattern))) == null ? void 0 : g.value) || f[0].value;
199
+ }), d = U(() => ue(i), [i]), l = U(() => n.map((f) => ({ label: f, value: f })), [n]);
200
+ e.action.current = () => O(c, o);
201
+ const h = (f) => {
202
+ if (f === void 0)
203
+ return;
204
+ s(f);
205
+ const y = ue(f)[0].value;
206
+ m(y), e.onChange(O(y, o));
207
+ }, p = (f) => {
208
+ f !== void 0 && (m(f), e.onChange(O(f, o)));
209
+ }, v = (f) => {
210
+ a(f || 0), e.onChange(O(c, f || 0));
211
+ };
212
+ return /* @__PURE__ */ b("div", { children: [
213
+ /* @__PURE__ */ b("div", { className: "m-t-16 options", children: [
214
+ /* @__PURE__ */ b("div", { className: "option", children: [
215
+ /* @__PURE__ */ u("div", { className: "label", children: r("sheet.numfmt.decimalLength") }),
216
+ /* @__PURE__ */ u("div", { className: "m-t-8 w-120", children: /* @__PURE__ */ u(Me, { value: o, max: 20, min: 0, onChange: v }) })
217
+ ] }),
218
+ /* @__PURE__ */ b("div", { className: "option", children: [
219
+ /* @__PURE__ */ u("div", { className: "label", children: r("sheet.numfmt.currencyType") }),
220
+ /* @__PURE__ */ u("div", { className: "m-t-8 w-140", children: /* @__PURE__ */ u(Pe, { onChange: h, options: l, value: i }) })
221
+ ] })
222
+ ] }),
223
+ /* @__PURE__ */ u("div", { className: "m-t-16 label", children: r("sheet.numfmt.negType") }),
224
+ /* @__PURE__ */ u("div", { className: "m-t-8", children: /* @__PURE__ */ u(we, { onChange: p, options: d, value: c }) }),
225
+ /* @__PURE__ */ u("div", { className: "describe m-t-14", children: r("sheet.numfmt.currencyDes") })
226
+ ] });
227
+ };
228
+ var E = function() {
229
+ return E = Object.assign || function(e) {
230
+ for (var t, r = 1, n = arguments.length; r < n; r++) {
231
+ t = arguments[r];
232
+ for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
233
+ }
234
+ return e;
235
+ }, E.apply(this, arguments);
236
+ }, In = function(e, t) {
237
+ var r = {};
238
+ for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
239
+ if (e != null && typeof Object.getOwnPropertySymbols == "function")
240
+ for (var i = 0, n = Object.getOwnPropertySymbols(e); i < n.length; i++)
241
+ t.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[i]) && (r[n[i]] = e[n[i]]);
242
+ return r;
243
+ }, it = rt(function(e, t) {
244
+ var r = e.icon, n = e.id, i = e.className, s = e.extend, o = In(e, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(n, " ").concat(i || "").trim(), c = Ee("_".concat(Tn()));
245
+ return st(r, "".concat(n), { defIds: r.defIds, idSuffix: c.current }, E({ ref: t, className: a }, o), s);
246
+ });
247
+ function st(e, t, r, n, i) {
248
+ return Te(e.tag, E(E({ key: t }, Nn(e, r, i)), n), (En(e, r).children || []).map(function(s, o) {
249
+ return st(s, "".concat(t, "-").concat(e.tag, "-").concat(o), r, void 0, i);
250
+ }));
251
+ }
252
+ function Nn(e, t, r) {
253
+ var n = E({}, e.attrs);
254
+ r != null && r.colorChannel1 && n.fill === "colorChannel1" && (n.fill = r.colorChannel1), e.tag === "mask" && n.id && (n.id = n.id + t.idSuffix), Object.entries(n).forEach(function(s) {
255
+ var o = s[0], a = s[1];
256
+ o === "mask" && typeof a == "string" && (n[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
257
+ });
258
+ var i = t.defIds;
259
+ return !i || i.length === 0 || (e.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + t.idSuffix), Object.entries(n).forEach(function(s) {
260
+ var o = s[0], a = s[1];
261
+ typeof a == "string" && (n[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
262
+ })), n;
263
+ }
264
+ function En(e, t) {
265
+ var r, n = t.defIds;
266
+ return !n || n.length === 0 ? e : e.tag === "defs" && (!((r = e.children) === null || r === void 0) && r.length) ? E(E({}, e), { children: e.children.map(function(i) {
267
+ return typeof i.attrs.id == "string" && n && n.indexOf(i.attrs.id) > -1 ? E(E({}, i), { attrs: E(E({}, i.attrs), { id: i.attrs.id + t.idSuffix }) }) : i;
268
+ }) }) : e;
269
+ }
270
+ function Tn() {
271
+ return Math.random().toString(36).substring(2, 8);
272
+ }
273
+ it.displayName = "UniverIcon";
274
+ var Mn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, ot = rt(function(e, t) {
275
+ return Te(it, Object.assign({}, e, {
276
+ id: "check-mark-single",
277
+ ref: t,
278
+ icon: Mn
279
+ }));
280
+ });
281
+ ot.displayName = "CheckMarkSingle";
282
+ const Pn = "univer-custom-format-title", wn = "univer-custom-format-input", Rn = "univer-custom-format-history-list", On = "univer-custom-format-history-list-item", Un = "univer-custom-format-history-list-item-icon-wrap", Dn = "univer-custom-format-des", F = {
283
+ customFormatTitle: Pn,
284
+ customFormatInput: wn,
285
+ customFormatHistoryList: Rn,
286
+ customFormatHistoryListItem: On,
287
+ customFormatHistoryListItemIconWrap: Un,
288
+ customFormatDes: Dn
289
+ }, fe = "customFormat", pe = "numfmt_custom_pattern";
290
+ function Fn(e) {
291
+ const { defaultPattern: t, action: r, onChange: n } = e, i = C(B), s = C(Ae), o = C(M), [a, c] = I(t);
292
+ r.current = () => (i.markHabit(fe, a), s.getItem(pe).then((p = []) => {
293
+ const v = [.../* @__PURE__ */ new Set([a, ...p || []])].splice(0, 10).filter((f) => !!f);
294
+ s.setItem(pe, v);
295
+ }), a);
296
+ const [m, d] = I([]);
297
+ ae(() => {
298
+ s.getItem(pe).then((p) => {
299
+ const v = [
300
+ ...Et.map((f) => f.suffix("$")),
301
+ ...Tt.map((f) => f.suffix),
302
+ ...Mt.map((f) => f.suffix)
303
+ ];
304
+ v.push(...p || []), i.addHabit(fe, []).finally(() => {
305
+ i.getHabit(fe, v).then((f) => {
306
+ d([...new Set(f)]);
307
+ });
308
+ });
309
+ });
310
+ }, []);
311
+ const l = (p) => {
312
+ c(p), n(p);
313
+ }, h = () => {
314
+ n(a);
315
+ };
316
+ return /* @__PURE__ */ b("div", { className: F.customFormat, children: [
317
+ /* @__PURE__ */ u("div", { className: F.customFormatTitle, children: o.t("sheet.numfmt.customFormat") }),
318
+ /* @__PURE__ */ u(mn, { placeholder: o.t("sheet.numfmt.customFormat"), onBlur: h, value: a, onChange: c, className: F.customFormatInput }),
319
+ /* @__PURE__ */ u("div", { className: F.customFormatHistoryList, children: m.map((p) => /* @__PURE__ */ b("div", { onClick: () => l(p), className: F.customFormatHistoryListItem, children: [
320
+ /* @__PURE__ */ u("div", { className: F.customFormatHistoryListItemIconWrap, children: a === p && /* @__PURE__ */ u(ot, {}) }),
321
+ /* @__PURE__ */ u("div", { children: p })
322
+ ] }, p)) }),
323
+ /* @__PURE__ */ u("div", { className: F.customFormatDes, children: o.t("sheet.numfmt.customFormatDes") })
324
+ ] });
325
+ }
326
+ const kn = (e) => {
327
+ const t = Q.getInfo(e);
328
+ return Ve().map((r) => r.value).includes(e) || ["date", "datetime", "time"].includes(t.type);
329
+ }, $n = (e) => {
330
+ const t = U(Ve, []), n = C(M).t, [i, s] = I(() => {
331
+ if (e.defaultPattern) {
332
+ const a = t.find((c) => c.value === e.defaultPattern);
333
+ if (a)
334
+ return a.value;
335
+ }
336
+ return t[0].value;
337
+ });
338
+ e.action.current = () => i;
339
+ const o = (a) => {
340
+ a !== void 0 && (s(a), e.onChange(a));
341
+ };
342
+ return /* @__PURE__ */ b("div", { children: [
343
+ /* @__PURE__ */ u("div", { className: "m-t-16 label", children: n("sheet.numfmt.dateType") }),
344
+ /* @__PURE__ */ u("div", { className: "m-t-8", children: /* @__PURE__ */ u(we, { value: i, options: t, onChange: o }) }),
345
+ /* @__PURE__ */ u("div", { className: "describe m-t-14", children: n("sheet.numfmt.dateDes") })
346
+ ] });
347
+ }, xn = (e) => !e, Ln = (e) => {
348
+ const r = C(M).t;
349
+ return e.action.current = () => "", /* @__PURE__ */ u("div", { children: /* @__PURE__ */ u("div", { className: "describe m-t-14", children: r("sheet.numfmt.generalDes") }) });
350
+ }, Hn = (e) => Ge().some((t) => ce(t.value, e)), An = (e) => {
351
+ const t = C(M), r = U(Ge, []), [n, i] = I(() => te(e.defaultPattern || "", 0)), [s, o] = I(() => {
352
+ const l = r.find((h) => ce(h.value, e.defaultPattern || ""));
353
+ return (l == null ? void 0 : l.value) || r[0].value;
354
+ }), a = U(() => O(s, Number(n || 0)), [s, n]), c = U(() => !Pt(s), [s]), m = (l) => {
355
+ i(l || 0), e.onChange(O(s, Number(l || 0)));
356
+ }, d = (l) => {
357
+ l !== void 0 && (i(te(l, 0)), o(l), e.onChange(l));
358
+ };
359
+ return e.action.current = () => a, /* @__PURE__ */ b("div", { children: [
360
+ /* @__PURE__ */ u("div", { className: "m-t-16 label", children: t.t("sheet.numfmt.decimalLength") }),
361
+ /* @__PURE__ */ u("div", { className: "m-t-8", children: /* @__PURE__ */ u(
362
+ Me,
363
+ {
364
+ disabled: c,
365
+ value: n,
366
+ max: 20,
367
+ min: 0,
368
+ onChange: m
369
+ }
370
+ ) }),
371
+ /* @__PURE__ */ b("div", { className: "m-t-16 label", children: [
372
+ " ",
373
+ t.t("sheet.numfmt.negType")
374
+ ] }),
375
+ /* @__PURE__ */ u("div", { className: "m-t-8", children: /* @__PURE__ */ u(we, { onChange: d, options: r, value: s }) }),
376
+ /* @__PURE__ */ u("div", { className: "describe m-t-14", children: t.t("sheet.numfmt.thousandthPercentileDes") })
377
+ ] });
378
+ }, jn = (e) => {
379
+ const { defaultValue: t, defaultPattern: r, row: n, col: i } = e.value, s = C(M), o = Ee(() => ""), a = s.t, c = _n(), m = U(
380
+ () => [
381
+ { label: "sheet.numfmt.general", component: Ln },
382
+ { label: "sheet.numfmt.accounting", component: yn },
383
+ { label: "sheet.numfmt.currency", component: Cn },
384
+ { label: "sheet.numfmt.date", component: $n },
385
+ { label: "sheet.numfmt.thousandthPercentile", component: An },
386
+ { label: "sheet.numfmt.customFormat", component: Fn }
387
+ ].map((_) => ({ ..._, label: a(_.label) })),
388
+ []
389
+ ), [d, l] = I(g), [h, p] = I(() => `${n}_${i}`), { mark: v, userHabitCurrency: f } = gn(() => p(`${n}_${i}_userCurrency'`)), y = U(() => {
390
+ var _;
391
+ return (_ = m.find((k) => k.label === d)) == null ? void 0 : _.component;
392
+ }, [d]);
393
+ function g() {
394
+ return [xn, Sn, bn, kn, Hn].reduce((k, mt, ut) => k || (mt(r) ? m[ut].label : ""), "") || m[0].label;
395
+ }
396
+ const N = m.map((_) => ({
397
+ label: _.label,
398
+ value: _.label
399
+ })), w = (_) => {
400
+ l(_), c(() => e.onChange({ type: "change", value: o.current() || "" }));
401
+ }, R = (_) => {
402
+ e.onChange({ type: "change", value: _ });
403
+ }, le = () => {
404
+ const _ = o.current() || "", k = V(_);
405
+ k && v(k), e.onChange({ type: "confirm", value: _ });
406
+ }, L = () => {
407
+ e.onChange({ type: "cancel", value: "" });
408
+ }, me = {
409
+ onChange: R,
410
+ defaultValue: t,
411
+ defaultPattern: r,
412
+ action: o
413
+ };
414
+ return ae(() => {
415
+ l(g()), p(`${n}_${i}`);
416
+ }, [n, i]), /* @__PURE__ */ b("div", { className: "numfmt-panel p-b-20", children: [
417
+ /* @__PURE__ */ b("div", { children: [
418
+ /* @__PURE__ */ u("div", { className: "label m-t-14", children: a("sheet.numfmt.numfmtType") }),
419
+ /* @__PURE__ */ u("div", { className: "m-t-8", children: /* @__PURE__ */ u(Pe, { onChange: w, options: N, value: d, style: { width: "100%" } }) }),
420
+ /* @__PURE__ */ u("div", { children: y && /* @__PURE__ */ u(Re.Provider, { value: f, children: /* @__PURE__ */ Te(y, { ...me, key: h }) }) })
421
+ ] }),
422
+ /* @__PURE__ */ b("div", { className: "btn-list m-t-14 m-b-20", children: [
423
+ /* @__PURE__ */ u(De, { size: "small", onClick: L, className: "m-r-12", children: a("sheet.numfmt.cancel") }),
424
+ /* @__PURE__ */ u(De, { type: "primary", size: "small", onClick: le, children: a("sheet.numfmt.confirm") })
425
+ ] })
426
+ ] });
427
+ };
428
+ var Bn = Object.getOwnPropertyDescriptor, Wn = (e, t, r, n) => {
429
+ for (var i = n > 1 ? void 0 : n ? Bn(t, r) : t, s = e.length - 1, o; s >= 0; s--)
430
+ (o = e[s]) && (i = o(i) || i);
431
+ return i;
432
+ }, P = (e, t) => (r, n) => t(r, n, e);
433
+ const $e = "SHEET_NUMFMT_PANEL";
434
+ let W = class extends oe {
435
+ constructor(t, r, n, i, s, o, a, c, m, d, l) {
436
+ super();
437
+ /**
438
+ * If _previewPattern is null ,the realTimeRenderingInterceptor will skip and if it is '',realTimeRenderingInterceptor will clear numfmt.
439
+ * @private
440
+ * @type {(string | null)}
441
+ * @memberof NumfmtController
442
+ */
443
+ J(this, "_previewPattern", "");
444
+ J(this, "_sidebarDisposable", null);
445
+ this._sheetInterceptorService = t, this._themeService = r, this._univerInstanceService = n, this._commandService = i, this._selectionManagerService = s, this._renderManagerService = o, this._numfmtService = a, this._componentManager = c, this._sidebarService = m, this._localeService = d, this._sheetsNumfmtCellContentController = l, this._initRealTimeRenderingInterceptor(), this._initPanel(), this._initCommands(), this._initCloseListener(), this._commandExecutedListener(), this._initNumfmtLocalChange();
446
+ }
447
+ _initNumfmtLocalChange() {
448
+ this.disposeWithMe(tt(this._sheetsNumfmtCellContentController.local$, this._localeService.currentLocale$).subscribe(() => {
449
+ this._forceUpdate();
450
+ }));
451
+ }
452
+ openPanel() {
453
+ var y;
454
+ const t = this._sidebarService, r = this._selectionManagerService, n = this._commandService, i = this._univerInstanceService, s = this._numfmtService, o = this._localeService, c = (((y = r.getCurrentSelections()) == null ? void 0 : y.map((g) => g.range)) || [])[0];
455
+ if (!c)
456
+ return !1;
457
+ const m = i.getCurrentUnitForType(T.UNIVER_SHEET), d = m.getActiveSheet();
458
+ if (!d)
459
+ return !1;
460
+ const l = d.getCellRaw(c.startRow, c.startColumn), h = s.getValue(
461
+ m.getUnitId(),
462
+ d.getSheetId(),
463
+ c.startRow,
464
+ c.startColumn
465
+ );
466
+ let p = "";
467
+ h && (p = h.pattern);
468
+ const v = (l == null ? void 0 : l.t) === x.NUMBER ? l.v : 12345678, f = {
469
+ onChange: (g) => {
470
+ var N;
471
+ if (g.type === "change")
472
+ this._previewPattern = g.value, this._forceUpdate();
473
+ else if (g.type === "confirm") {
474
+ const w = ((N = r.getCurrentSelections()) == null ? void 0 : N.map((L) => L.range)) || [], R = { values: [] }, le = ne(g.value);
475
+ w.forEach((L) => {
476
+ je.foreach(L, (me, _) => {
477
+ R.values.push({
478
+ row: me,
479
+ col: _,
480
+ pattern: g.value,
481
+ type: le
482
+ });
483
+ });
484
+ }), n.executeCommand(Ze.id, R), t.close();
485
+ } else g.type === "cancel" && t.close();
486
+ },
487
+ value: { defaultPattern: p, defaultValue: v, row: c.startRow, col: c.startColumn }
488
+ };
489
+ return this._sidebarDisposable = t.open({
490
+ header: { title: o.t("sheet.numfmt.title") },
491
+ children: {
492
+ label: $e,
493
+ ...f
494
+ // need passthrough to react props.
495
+ },
496
+ onClose: () => {
497
+ this._forceUpdate(), n.executeCommand(he.id);
498
+ }
499
+ }), !0;
500
+ }
501
+ _forceUpdate(t) {
502
+ var n;
503
+ const r = this._renderManagerService.getRenderById(
504
+ t != null ? t : this._univerInstanceService.getCurrentUnitForType(T.UNIVER_SHEET).getUnitId()
505
+ );
506
+ r == null || r.with($t).reCalculate(), (n = r == null ? void 0 : r.mainComponent) == null || n.makeDirty();
507
+ }
508
+ _initCommands() {
509
+ [
510
+ j,
511
+ he
512
+ ].forEach((t) => {
513
+ this.disposeWithMe(this._commandService.registerCommand(t));
514
+ });
515
+ }
516
+ _initPanel() {
517
+ this._componentManager.register($e, jn);
518
+ }
519
+ // eslint-disable-next-line max-lines-per-function
520
+ _initRealTimeRenderingInterceptor() {
521
+ const t = new A((n) => {
522
+ this._commandService.onCommandExecuted((i) => {
523
+ i.id === j.id && n.next(!0), i.id === he.id && n.next(!1);
524
+ });
525
+ }), r = nn([
526
+ t,
527
+ this._selectionManagerService.selectionMoveEnd$.pipe(
528
+ sn((n) => n ? n.map((i) => i.range) : [])
529
+ )
530
+ ]);
531
+ this.disposeWithMe(
532
+ ge(
533
+ r.pipe(
534
+ on(
535
+ ([n, i]) => new A((s) => {
536
+ const o = new vt();
537
+ return n && i.length && s.next({ selectionRanges: i, disposableCollection: o }), () => {
538
+ o.dispose();
539
+ };
540
+ })
541
+ ),
542
+ cn(() => {
543
+ this._previewPattern = null;
544
+ })
545
+ ).subscribe(({ disposableCollection: n, selectionRanges: i }) => {
546
+ var o, a;
547
+ const s = this._univerInstanceService.getCurrentUnitForType(T.UNIVER_SHEET);
548
+ this.openPanel(), n.add(
549
+ this._sheetInterceptorService.intercept(Wt.CELL_CONTENT, {
550
+ priority: 99,
551
+ effect: Oe.Value | Oe.Style,
552
+ handler: (c, m, d) => {
553
+ const { row: l, col: h } = m, p = d(c) || {};
554
+ if (i.find(
555
+ (v) => v.startColumn <= h && v.endColumn >= h && v.startRow <= l && v.endRow >= l
556
+ )) {
557
+ const v = m.worksheet.getCellRaw(l, h), f = v == null ? void 0 : v.v, y = v == null ? void 0 : v.t;
558
+ if (f == null || y !== x.NUMBER || this._previewPattern === null)
559
+ return p;
560
+ const g = wt(this._previewPattern, f, this._sheetsNumfmtCellContentController.local);
561
+ if (g.color) {
562
+ const w = this._themeService.getCurrentTheme()[`${g.color}500`];
563
+ return {
564
+ ...p,
565
+ v: g.result,
566
+ t: x.STRING,
567
+ s: { cl: { rgb: w } }
568
+ };
569
+ }
570
+ return {
571
+ ...p,
572
+ v: g.result,
573
+ t: x.STRING
574
+ };
575
+ }
576
+ return p;
577
+ }
578
+ })
579
+ ), (a = (o = this._renderManagerService.getRenderById(s.getUnitId())) == null ? void 0 : o.mainComponent) == null || a.makeDirty();
580
+ })
581
+ )
582
+ );
583
+ }
584
+ _commandExecutedListener() {
585
+ const t = [Ie.id, Ne.id];
586
+ this.disposeWithMe(
587
+ new A((r) => {
588
+ const n = this._commandService.onCommandExecuted((i) => {
589
+ if (t.includes(i.id)) {
590
+ const s = i.params;
591
+ r.next(s.unitId);
592
+ }
593
+ });
594
+ return () => n.dispose();
595
+ }).pipe(an(16)).subscribe((r) => this._forceUpdate(r))
596
+ );
597
+ }
598
+ _initCloseListener() {
599
+ this._univerInstanceService.getCurrentTypeOfUnit$(T.UNIVER_SHEET).subscribe((t) => {
600
+ var r;
601
+ t || ((r = this._sidebarDisposable) == null || r.dispose(), this._sidebarDisposable = null);
602
+ });
603
+ }
604
+ };
605
+ W = Wn([
606
+ P(0, S(Qe)),
607
+ P(1, S(pt)),
608
+ P(2, Se),
609
+ P(3, ye),
610
+ P(4, S(Ce)),
611
+ P(5, We),
612
+ P(6, be),
613
+ P(7, S(et)),
614
+ P(8, qt),
615
+ P(9, S(M)),
616
+ P(10, S(Ke))
617
+ ], W);
618
+ var Vn = Object.getOwnPropertyDescriptor, Gn = (e, t, r, n) => {
619
+ for (var i = n > 1 ? void 0 : n ? Vn(t, r) : t, s = e.length - 1, o; s >= 0; s--)
620
+ (o = e[s]) && (i = o(i) || i);
621
+ return i;
622
+ }, H = (e, t) => (r, n) => t(r, n, e);
623
+ const Kn = () => {
624
+ let e = [];
625
+ return {
626
+ add: (i, s, o, a, c) => e.push({ unitId: i, subUnitId: s, row: o, col: a, value: c }),
627
+ getEffects: () => e,
628
+ clean: () => {
629
+ e = [];
630
+ }
631
+ };
632
+ };
633
+ let re = class extends oe {
634
+ constructor(t, r, n, i, s) {
635
+ super();
636
+ // collect effect mutations when edit end and push this to commands stack in next commands progress
637
+ J(this, "_collectEffectMutation", Kn());
638
+ this._sheetInterceptorService = t, this._numfmtService = r, this._univerInstanceService = n, this._injector = i, this._editorBridgeService = s, this._initInterceptorEditorStart(), this._initInterceptorEditorEnd(), this._initInterceptorCommands();
639
+ }
640
+ _initInterceptorEditorStart() {
641
+ this._editorBridgeService && this.disposeWithMe(
642
+ ge(
643
+ this._sheetInterceptorService.writeCellInterceptor.intercept(Vt, {
644
+ handler: (t, r, n) => {
645
+ const i = r.row, s = r.col, o = this._numfmtService.getValue(
646
+ r.unitId,
647
+ r.subUnitId,
648
+ i,
649
+ s
650
+ );
651
+ if (o)
652
+ switch (ne(o.pattern)) {
653
+ case "scientific":
654
+ case "currency":
655
+ case "grouped":
656
+ case "number": {
657
+ const c = r.worksheet.getCellRaw(i, s);
658
+ return n && n(c);
659
+ }
660
+ case "percent":
661
+ case "date":
662
+ case "time":
663
+ case "datetime":
664
+ default:
665
+ return n && n(t);
666
+ }
667
+ return n(t);
668
+ }
669
+ })
670
+ )
671
+ );
672
+ }
673
+ /**
674
+ * Process the values after edit
675
+ * @private
676
+ * @memberof NumfmtService
677
+ */
678
+ _initInterceptorEditorEnd() {
679
+ this.disposeWithMe(
680
+ ge(
681
+ this._sheetInterceptorService.writeCellInterceptor.intercept(Gt, {
682
+ // eslint-disable-next-line complexity
683
+ handler: (t, r, n) => {
684
+ var d, l, h, p;
685
+ this._collectEffectMutation.clean();
686
+ const i = this._numfmtService.getValue(
687
+ r.unitId,
688
+ r.subUnitId,
689
+ r.row,
690
+ r.col
691
+ ), s = (d = i && ne(i.pattern)) != null ? d : "", o = () => {
692
+ i && this._collectEffectMutation.add(
693
+ r.unitId,
694
+ r.subUnitId,
695
+ r.row,
696
+ r.col,
697
+ null
698
+ );
699
+ };
700
+ if (!(t != null && t.v) && !(t != null && t.p) || Je(i == null ? void 0 : i.pattern) || t.t === x.FORCE_STRING)
701
+ return n(t);
702
+ const a = (l = t.p) == null ? void 0 : l.body, c = (p = (h = t == null ? void 0 : t.p) == null ? void 0 : h.body) != null && p.dataStream ? t.p.body.dataStream.replace(/\r\n$/, "") : String(t.v), m = Q.parseDate(c) || Q.parseTime(c) || Q.parseNumber(c);
703
+ if (a)
704
+ if (zn(a)) {
705
+ const { dataStream: v } = a, f = v.replace(/\r\n$/, ""), y = Number(f);
706
+ if (Number.isNaN(y) && !m)
707
+ return n(t);
708
+ } else
709
+ return n(t);
710
+ if (m) {
711
+ m.z && this._collectEffectMutation.add(
712
+ r.unitId,
713
+ r.subUnitId,
714
+ r.row,
715
+ r.col,
716
+ {
717
+ pattern: m.z
718
+ }
719
+ );
720
+ const v = Number(m.v);
721
+ return n({ ...t, p: void 0, v, t: x.NUMBER });
722
+ } else (["date", "time", "datetime", "percent"].includes(s) || !Zn(c)) && o();
723
+ return n(t);
724
+ }
725
+ })
726
+ )
727
+ );
728
+ }
729
+ _initInterceptorCommands() {
730
+ const t = this;
731
+ this.disposeWithMe(
732
+ this._sheetInterceptorService.interceptCommand({
733
+ getMutations(r) {
734
+ var n;
735
+ switch (r.id) {
736
+ case Kt.id: {
737
+ const i = t._univerInstanceService.getCurrentUnitForType(T.UNIVER_SHEET), s = i.getUnitId(), o = (n = i.getActiveSheet()) == null ? void 0 : n.getSheetId();
738
+ if (!o)
739
+ return {
740
+ redos: [],
741
+ undos: []
742
+ };
743
+ const a = t._collectEffectMutation.getEffects();
744
+ if (t._collectEffectMutation.clean(), !a.length)
745
+ return {
746
+ redos: [],
747
+ undos: []
748
+ };
749
+ const c = a.filter((h) => {
750
+ var p;
751
+ return !!((p = h.value) != null && p.pattern);
752
+ }).map((h) => ({
753
+ row: h.row,
754
+ col: h.col,
755
+ pattern: h.value.pattern
756
+ })), m = a.filter((h) => {
757
+ var p;
758
+ return !((p = h.value) != null && p.pattern);
759
+ }).map((h) => ({
760
+ startRow: h.row,
761
+ endColumn: h.col,
762
+ startColumn: h.col,
763
+ endRow: h.row
764
+ })), d = [], l = [];
765
+ if (c.length) {
766
+ const h = {
767
+ id: Ne.id,
768
+ params: Zt(s, o, c)
769
+ };
770
+ d.push(h), l.push(...zt(t._injector, h.params));
771
+ }
772
+ if (m.length) {
773
+ const h = {
774
+ id: Ie.id,
775
+ params: {
776
+ unitId: s,
777
+ subUnitId: o,
778
+ ranges: m
779
+ }
780
+ };
781
+ d.push(h), l.push(...Yt(t._injector, h.params));
782
+ }
783
+ return {
784
+ redos: d,
785
+ undos: l.reverse()
786
+ };
787
+ }
788
+ }
789
+ return {
790
+ redos: [],
791
+ undos: []
792
+ };
793
+ }
794
+ })
795
+ );
796
+ }
797
+ };
798
+ re = Gn([
799
+ H(0, S(Qe)),
800
+ H(1, S(be)),
801
+ H(2, S(Se)),
802
+ H(3, S(Be)),
803
+ H(4, gt(xt))
804
+ ], re);
805
+ function Zn(e) {
806
+ return /^-?\d+(\.\d+)?$/.test(e);
807
+ }
808
+ function zn(e) {
809
+ const { textRuns: t = [], paragraphs: r = [], customRanges: n, customBlocks: i = [] } = e, s = ["va"];
810
+ return !(t.some((o) => !!(o.ts && Object.keys(o.ts).some((c) => s.includes(c)))) || r.some((o) => o.bullet) || r.length >= 2 || n != null && n.length || i.length > 0);
811
+ }
812
+ const ee = [
813
+ {
814
+ label: "sheet.numfmt.general",
815
+ pattern: null
816
+ },
817
+ {
818
+ label: "sheet.numfmt.text",
819
+ pattern: Bt
820
+ },
821
+ "|",
822
+ {
823
+ label: "sheet.numfmt.number",
824
+ pattern: "0"
825
+ },
826
+ {
827
+ label: "sheet.numfmt.percent",
828
+ pattern: "0.00%"
829
+ },
830
+ {
831
+ label: "sheet.numfmt.scientific",
832
+ pattern: "0.00E+00"
833
+ },
834
+ "|",
835
+ {
836
+ label: "sheet.numfmt.accounting",
837
+ pattern: '"¥" #,##0.00_);[Red]("¥"#,##0.00)'
838
+ },
839
+ {
840
+ label: "sheet.numfmt.financialValue",
841
+ pattern: "#,##0.00;[Red]#,##0.00"
842
+ },
843
+ {
844
+ label: "sheet.numfmt.currency",
845
+ pattern: '"¥"#,##0.00_);[Red]("¥"#,##0.00)'
846
+ },
847
+ {
848
+ label: "sheet.numfmt.roundingCurrency",
849
+ pattern: '"¥"#,##0;[Red]"¥"#,##0'
850
+ },
851
+ "|",
852
+ {
853
+ label: "sheet.numfmt.date",
854
+ pattern: "yyyy-mm-dd;@"
855
+ },
856
+ {
857
+ label: "sheet.numfmt.time",
858
+ pattern: 'am/pm h":"mm":"ss'
859
+ },
860
+ {
861
+ label: "sheet.numfmt.dateTime",
862
+ pattern: "yyyy-m-d am/pm h:mm"
863
+ },
864
+ {
865
+ label: "sheet.numfmt.timeDuration",
866
+ pattern: "h:mm:ss"
867
+ },
868
+ "|",
869
+ {
870
+ label: "sheet.numfmt.moreFmt",
871
+ pattern: ""
872
+ }
873
+ ], Yn = (e) => ({
874
+ icon: new A((t) => {
875
+ const r = e.get(Rt);
876
+ function n(s) {
877
+ return {
878
+ [$.US]: "DollarSingle",
879
+ [$.RU]: "RoubleSingle",
880
+ [$.CN]: "RmbSingle",
881
+ [$.AT]: "EuroSingle"
882
+ }[s] || "DollarSingle";
883
+ }
884
+ const i = $[r.getCurrencySymbol()] || "$";
885
+ return t.next(n(i)), r.currencySymbol$.subscribe((s) => {
886
+ const o = $[s] || "$";
887
+ t.next(n(o));
888
+ });
889
+ }),
890
+ id: qe.id,
891
+ title: "sheet.numfmt.currency",
892
+ tooltip: "sheet.numfmt.currency",
893
+ type: q.BUTTON,
894
+ hidden$: X(e, T.UNIVER_SHEET),
895
+ disabled$: G(e, { workbookTypes: [Y], worksheetTypes: [z, Z], rangeTypes: [K] })
896
+ }), Xn = (e) => ({
897
+ icon: "AddDigitsSingle",
898
+ id: Xe.id,
899
+ title: "sheet.numfmt.addDecimal",
900
+ tooltip: "sheet.numfmt.addDecimal",
901
+ type: q.BUTTON,
902
+ hidden$: X(e, T.UNIVER_SHEET),
903
+ disabled$: G(e, { workbookTypes: [Y], worksheetTypes: [z, Z], rangeTypes: [K] })
904
+ }), qn = (e) => ({
905
+ icon: "ReduceDigitsSingle",
906
+ id: Ye.id,
907
+ title: "sheet.numfmt.subtractDecimal",
908
+ tooltip: "sheet.numfmt.subtractDecimal",
909
+ type: q.BUTTON,
910
+ hidden$: X(e, T.UNIVER_SHEET),
911
+ disabled$: G(e, { workbookTypes: [Y], worksheetTypes: [z, Z], rangeTypes: [K] })
912
+ }), Jn = (e) => ({
913
+ icon: "PercentSingle",
914
+ id: ze.id,
915
+ title: "sheet.numfmt.percent",
916
+ tooltip: "sheet.numfmt.percent",
917
+ type: q.BUTTON,
918
+ hidden$: X(e, T.UNIVER_SHEET),
919
+ disabled$: G(e, { workbookTypes: [Y], worksheetTypes: [z, Z], rangeTypes: [K] })
920
+ }), Qn = (e) => {
921
+ const t = e.get(Se), r = e.get(ye), n = e.get(M), i = e.get(Ce), s = [Ie.id, Ne.id], o = Lt(
922
+ t,
923
+ "",
924
+ ({ workbook: a, worksheet: c }) => new A(
925
+ (m) => tt(
926
+ i.selectionMoveEnd$,
927
+ _t(r.onCommandExecuted.bind(r)).pipe(
928
+ rn(([d]) => s.includes(d.id))
929
+ )
930
+ ).subscribe(() => {
931
+ var l, h;
932
+ const d = i.getCurrentSelections();
933
+ if (d && d[0]) {
934
+ const p = d[0].range, v = p.startRow, f = p.startColumn, y = (h = a.getStyles().get((l = c.getCell(v, f)) == null ? void 0 : l.s)) == null ? void 0 : h.n, g = y == null ? void 0 : y.pattern;
935
+ let N = n.t("sheet.numfmt.general");
936
+ if (jt(g)) {
937
+ m.next(N);
938
+ return;
939
+ }
940
+ if (g) {
941
+ const w = ee.filter((R) => typeof R == "object" && R.pattern).find(
942
+ (R) => ce(g, R.pattern)
943
+ );
944
+ w && typeof w == "object" && w.pattern ? N = n.t(w.label) : N = n.t("sheet.numfmt.moreFmt");
945
+ }
946
+ m.next(N);
947
+ }
948
+ })
949
+ )
950
+ );
951
+ return {
952
+ label: ct,
953
+ id: j.id,
954
+ tooltip: "sheet.numfmt.title",
955
+ type: q.SELECTOR,
956
+ slot: !0,
957
+ selections: [
958
+ {
959
+ label: {
960
+ name: at,
961
+ hoverable: !1,
962
+ selectable: !1
963
+ }
964
+ }
965
+ ],
966
+ value$: o,
967
+ hidden$: X(e, T.UNIVER_SHEET),
968
+ disabled$: G(e, { workbookTypes: [Y], worksheetTypes: [Z, z], rangeTypes: [K] })
969
+ };
970
+ }, ct = "sheet.numfmt.moreNumfmtType", at = "sheet.numfmt.moreNumfmtType.options", er = (e) => {
971
+ const { value: t } = e, r = C(M), n = t != null ? t : r.t("sheet.numfmt.general");
972
+ return /* @__PURE__ */ u("span", { className: "univer-text-sm", children: n });
973
+ }, tr = () => {
974
+ const e = C(ye), t = C(M), r = C(Jt), n = C(Ke), i = C(Ce), s = (c) => {
975
+ const m = i.getCurrentLastSelection();
976
+ if (!m)
977
+ return;
978
+ const d = m.range, l = [];
979
+ je.foreach(d, (h, p) => {
980
+ c ? l.push({ row: h, col: p, pattern: c, type: ne(c) }) : l.push({ row: h, col: p });
981
+ }), e.executeCommand(Ze.id, { values: l }), r.focus();
982
+ }, o = (c) => {
983
+ if (c === 0)
984
+ s(null);
985
+ else if (c === ee.length - 1)
986
+ e.executeCommand(j.id), r.focus();
987
+ else {
988
+ const m = ee[c];
989
+ m.pattern && s(m.pattern);
990
+ }
991
+ }, a = 1220;
992
+ return /* @__PURE__ */ u("div", { className: "univer-grid univer-gap-1 univer-p-1.5", children: ee.map((c, m) => c === "|" ? /* @__PURE__ */ u(un, {}, m) : /* @__PURE__ */ b(
993
+ "div",
994
+ {
995
+ className: `
996
+ univer-flex univer-h-7 univer-items-center univer-justify-between univer-gap-6 univer-rounded
997
+ univer-px-2 univer-text-[13px]
998
+ hover:univer-bg-gray-100
999
+ `,
1000
+ onClick: () => {
1001
+ o(m);
1002
+ },
1003
+ children: [
1004
+ /* @__PURE__ */ u("span", { children: t.t(c.label) }),
1005
+ /* @__PURE__ */ u("span", { className: "univer-text-xs univer-text-gray-500", children: c.pattern ? Ot(c.pattern || "", a, n.local).result.trim() : "" })
1006
+ ]
1007
+ },
1008
+ m
1009
+ )) });
1010
+ }, nr = {
1011
+ [Qt.FORMULAS_INSERT]: {
1012
+ [qe.id]: {
1013
+ order: 4,
1014
+ menuItemFactory: Yn
1015
+ },
1016
+ [Xe.id]: {
1017
+ order: 5,
1018
+ menuItemFactory: Xn
1019
+ },
1020
+ [Ye.id]: {
1021
+ order: 6,
1022
+ menuItemFactory: qn
1023
+ },
1024
+ [ze.id]: {
1025
+ order: 7,
1026
+ menuItemFactory: Jn
1027
+ },
1028
+ [j.id]: {
1029
+ order: 8,
1030
+ menuItemFactory: Qn
1031
+ }
1032
+ }
1033
+ };
1034
+ var rr = Object.getOwnPropertyDescriptor, ir = (e, t, r, n) => {
1035
+ for (var i = n > 1 ? void 0 : n ? rr(t, r) : t, s = e.length - 1, o; s >= 0; s--)
1036
+ (o = e[s]) && (i = o(i) || i);
1037
+ return i;
1038
+ }, xe = (e, t) => (r, n) => t(r, n, e);
1039
+ let ie = class extends oe {
1040
+ constructor(e, t) {
1041
+ super(), this._componentManager = e, this._menuManagerService = t, this._initMenu();
1042
+ }
1043
+ _initMenu() {
1044
+ this._menuManagerService.mergeMenu(nr), this.disposeWithMe(this._componentManager.register(ct, er)), this.disposeWithMe(this._componentManager.register(at, tr));
1045
+ }
1046
+ };
1047
+ ie = ir([
1048
+ xe(0, S(et)),
1049
+ xe(1, en)
1050
+ ], ie);
1051
+ var sr = Object.defineProperty, or = Object.getOwnPropertyDescriptor, cr = (e, t, r) => t in e ? sr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, ar = (e, t, r, n) => {
1052
+ for (var i = n > 1 ? void 0 : n ? or(t, r) : t, s = e.length - 1, o; s >= 0; s--)
1053
+ (o = e[s]) && (i = o(i) || i);
1054
+ return i;
1055
+ }, ve = (e, t) => (r, n) => t(r, n, e), lt = (e, t, r) => cr(e, typeof t != "symbol" ? t + "" : t, r);
1056
+ const lr = "SHEET_NUMFMT_UI_PLUGIN";
1057
+ let se = class extends yt {
1058
+ constructor(e = Fe, t, r, n) {
1059
+ super(), this._config = e, this._injector = t, this._configService = r, this._renderManagerService = n;
1060
+ const { menu: i, ...s } = bt(
1061
+ {},
1062
+ Fe,
1063
+ this._config
1064
+ );
1065
+ i && this._configService.setConfig("menu", i, { merge: !0 }), this._configService.setConfig("sheets-numfmt-ui.config", s);
1066
+ }
1067
+ onStarting() {
1068
+ Ct(this._injector, [
1069
+ [W],
1070
+ [re],
1071
+ [B],
1072
+ [ie]
1073
+ ]);
1074
+ }
1075
+ onRendered() {
1076
+ this._registerRenderModules(), It(this._injector, [
1077
+ [W],
1078
+ [re],
1079
+ [ie]
1080
+ ]);
1081
+ }
1082
+ _registerRenderModules() {
1083
+ [
1084
+ [_e]
1085
+ ].forEach((t) => {
1086
+ this.disposeWithMe(this._renderManagerService.registerRenderModule(T.UNIVER_SHEET, t));
1087
+ });
1088
+ }
1089
+ };
1090
+ lt(se, "pluginName", lr);
1091
+ lt(se, "type", T.UNIVER_SHEET);
1092
+ se = ar([
1093
+ St(Ht, Ut),
1094
+ ve(1, S(Be)),
1095
+ ve(2, Le),
1096
+ ve(3, We)
1097
+ ], se);
1098
+ export {
1099
+ se as UniverSheetsNumfmtUIPlugin
1100
+ };