@univerjs/preset-docs-drawing 1.0.0-alpha.3 → 1.0.0-alpha.4

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/es/index.js CHANGED
@@ -4,6 +4,7 @@ import { UniverDocsDrawingPlugin } from "@univerjs/docs-drawing";
4
4
  import { UniverDocsDrawingUIPlugin } from "@univerjs/docs-drawing-ui";
5
5
  import { UniverDrawingPlugin } from "@univerjs/drawing";
6
6
  import { UniverDrawingUIPlugin } from "@univerjs/drawing-ui";
7
+ import "@univerjs/docs-drawing/facade";
7
8
 
8
9
  export * from "@univerjs/docs-drawing"
9
10
 
@@ -905,7 +906,7 @@ function composeStyles(...styles) {
905
906
  //#endregion
906
907
  //#region ../../../packages/core/package.json
907
908
  var name = "@univerjs/core";
908
- var version = "1.0.0-alpha.3";
909
+ var version = "1.0.0-alpha.4";
909
910
 
910
911
  //#endregion
911
912
  //#region ../../../packages/core/src/common/array.ts
@@ -6141,7 +6142,7 @@ const THEME_COLORS = { ["Office"]: {
6141
6142
  } };
6142
6143
 
6143
6144
  //#endregion
6144
- //#region ../../../node_modules/.pnpm/numfmt@3.2.6/node_modules/numfmt/lib/constants.js
6145
+ //#region ../../../packages/core/src/shared/numfmt/constants.ts
6145
6146
  const TOKEN_GENERAL = "general";
6146
6147
  const TOKEN_HASH = "hash";
6147
6148
  const TOKEN_ZERO = "zero";
@@ -6204,11 +6205,26 @@ const currencySymbols$1 = [
6204
6205
  "₾",
6205
6206
  "₿"
6206
6207
  ];
6207
- const reCurrencySymbols = new RegExp("[" + currencySymbols$1.join("") + "]");
6208
+ const reCurrencySymbols = new RegExp(`[${currencySymbols$1.join("")}]`);
6208
6209
 
6209
6210
  //#endregion
6210
- //#region ../../../node_modules/.pnpm/numfmt@3.2.6/node_modules/numfmt/lib/codeToLocale.js
6211
- var codeToLocale_default = Object.freeze({
6211
+ //#region ../../../packages/core/src/shared/numfmt/code-to-locale.ts
6212
+ /**
6213
+ * Copyright 2023-present DreamNum Co., Ltd.
6214
+ *
6215
+ * Licensed under the Apache License, Version 2.0 (the "License");
6216
+ * you may not use this file except in compliance with the License.
6217
+ * You may obtain a copy of the License at
6218
+ *
6219
+ * http://www.apache.org/licenses/LICENSE-2.0
6220
+ *
6221
+ * Unless required by applicable law or agreed to in writing, software
6222
+ * distributed under the License is distributed on an "AS IS" BASIS,
6223
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6224
+ * See the License for the specific language governing permissions and
6225
+ * limitations under the License.
6226
+ */
6227
+ const codeToLocale = Object.freeze({
6212
6228
  1078: "af",
6213
6229
  1052: "sq",
6214
6230
  1118: "am",
@@ -6398,34 +6414,17 @@ var codeToLocale_default = Object.freeze({
6398
6414
  });
6399
6415
 
6400
6416
  //#endregion
6401
- //#region ../../../node_modules/.pnpm/numfmt@3.2.6/node_modules/numfmt/lib/locale.js
6417
+ //#region ../../../packages/core/src/shared/numfmt/locale.ts
6402
6418
  const re_locale = /^([a-z\d]+)(?:[_-]([a-z\d]+))?(?:\.([a-z\d]+))?(?:@([a-z\d]+))?$/i;
6403
6419
  const locales = {};
6404
6420
  /**
6405
6421
  * Split a semicolon delimited string and replace instances of characters
6406
6422
  * @ignore
6407
6423
  * @param {string} str Semicolon delimited string
6408
- * @param {string} [tilde=''] String to be inserted on every instance of ~
6424
+ * @param {string} [tilde] String to be inserted on every instance of ~
6409
6425
  * @returns {string[]} Array of strings
6410
6426
  */
6411
6427
  const _ = (str, tilde = "") => str.replace(/~/g, tilde).split(";");
6412
- /**
6413
- * Generate mmm and ddd properties as needed for locales. Many of them
6414
- * are straightforward abreviations of mmmm and dddd so we can save some
6415
- * bytes by auto-generating them.
6416
- *
6417
- * Both rule parameters use the same system. If shortform prop is missing:
6418
- *
6419
- * - 0 - use long form array unchanged
6420
- * - 1...9 - shorten to N many characters
6421
- * - 11...19 - shorten to 1...9 characters and add periods
6422
- *
6423
- * @ignore
6424
- * @param {object} o Locale object
6425
- * @param {number} [ml=0] Month list rule
6426
- * @param {number} [dl=0] Day list rule
6427
- * @returns {object} The same input object, but with ddd and mmm filled in.
6428
- */
6429
6428
  const xm = (o, ml = 0, dl = 0) => {
6430
6429
  if (!o.mmm) o.mmm = ml < 1 ? o.mmmm.concat() : o.mmmm.map((d) => {
6431
6430
  const s = d.slice(0, ml % 10);
@@ -6499,20 +6498,20 @@ function parseLocale(locale) {
6499
6498
  const lm = re_locale.exec(locale);
6500
6499
  if (!lm) throw new SyntaxError(`Malformed locale: ${locale}`);
6501
6500
  return {
6502
- lang: lm[1] + (lm[2] ? "_" + lm[2] : ""),
6501
+ lang: lm[1] + (lm[2] ? `_${lm[2]}` : ""),
6503
6502
  language: lm[1],
6504
6503
  territory: lm[2] || ""
6505
6504
  };
6506
6505
  }
6507
- function resolveLocale(l4e) {
6508
- if (typeof l4e === "number") return codeToLocale_default[l4e & 65535] || null;
6509
- const wincode = parseInt(l4e, 16);
6510
- if (isFinite(wincode) && codeToLocale_default[wincode & 65535]) return codeToLocale_default[wincode & 65535] || null;
6511
- if (re_locale.test(l4e)) return l4e;
6506
+ function resolveLocale(locale) {
6507
+ if (typeof locale === "number") return codeToLocale[locale & 65535] || null;
6508
+ const wincode = Number.parseInt(locale, 16);
6509
+ if (Number.isFinite(wincode) && codeToLocale[wincode & 65535]) return codeToLocale[wincode & 65535] || null;
6510
+ if (re_locale.test(locale)) return locale;
6512
6511
  return null;
6513
6512
  }
6514
- function createLocale(data) {
6515
- return Object.assign({}, baseLocaleData, data);
6513
+ function createLocale(settings) {
6514
+ return Object.assign({}, baseLocaleData, settings);
6516
6515
  }
6517
6516
  /**
6518
6517
  * Register locale data for a language so for use when formatting.
@@ -6520,48 +6519,48 @@ function createLocale(data) {
6520
6519
  * Any partial set of properties may be returned to have the defaults used where properties are missing.
6521
6520
  *
6522
6521
  * @see {LocaleData}
6523
- * @param {object} localeSettings - A collection of settings for a locale.
6524
- * @param {string} [localeSettings.group="\u00a0"]
6522
+ * @param {object} settings - A collection of settings for a locale.
6523
+ * @param {string} [settings.group]
6525
6524
  * Symbol used as a grouping separator (`1,000,000` uses `,`)
6526
- * @param {string} [localeSettings.decimal="."]
6525
+ * @param {string} [settings.decimal]
6527
6526
  * Symbol used to separate integers from fractions (usually `.`)
6528
- * @param {string} [localeSettings.positive="+"]
6527
+ * @param {string} [settings.positive]
6529
6528
  * Symbol used to indicate positive numbers (usually `+`)
6530
- * @param {string} [localeSettings.negative="-"]
6529
+ * @param {string} [settings.negative]
6531
6530
  * Symbol used to indicate positive numbers (usually `-`)
6532
- * @param {string} [localeSettings.percent="%"]
6531
+ * @param {string} [settings.percent]
6533
6532
  * Symbol used to indicate a percentage (usually `%`)
6534
- * @param {string} [localeSettings.exponent="E"]
6533
+ * @param {string} [settings.exponent]
6535
6534
  * Symbol used to indicate an exponent (usually `E`)
6536
- * @param {string} [localeSettings.nan="NaN"]
6535
+ * @param {string} [settings.nan]
6537
6536
  * Symbol used to indicate NaN values (`NaN`)
6538
- * @param {string} [localeSettings.infinity="∞"]
6537
+ * @param {string} [settings.infinity]
6539
6538
  * Symbol used to indicate infinite values (`∞`)
6540
- * @param {Array<string>} [localeSettings.ampm=["AM","PM"]]
6539
+ * @param {Array<string>} [settings.ampm]
6541
6540
  * How AM and PM should be presented.
6542
- * @param {Array<string>} [localeSettings.mmmm6=["Muharram", "Safar", "Rabiʻ I", "Rabiʻ II", "Jumada I", "Jumada II", "Rajab", "Shaʻban", "Ramadan", "Shawwal", "Dhuʻl-Qiʻdah", "Dhuʻl-Hijjah"]]
6541
+ * @param {Array<string>} [settings.mmmm6]
6543
6542
  * Long month names for the Islamic calendar (e.g. `Rajab`)
6544
- * @param {Array<string>} [localeSettings.mmm6=["Muh.", "Saf.", "Rab. I", "Rab. II", "Jum. I", "Jum. II", "Raj.", "Sha.", "Ram.", "Shaw.", "Dhuʻl-Q.", "Dhuʻl-H."]]
6543
+ * @param {Array<string>} [settings.mmm6]
6545
6544
  * Short month names for the Islamic calendar (e.g. `Raj.`)
6546
- * @param {Array<string>} [localeSettings.mmmm=["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]]
6545
+ * @param {Array<string>} [settings.mmmm]
6547
6546
  * Long month names for the Gregorian calendar (e.g. `November`)
6548
- * @param {Array<string>} [localeSettings.mmm=["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]]
6547
+ * @param {Array<string>} [settings.mmm]
6549
6548
  * Short month names for the Gregorian calendar (e.g. `Nov`)
6550
- * @param {Array<string>} [localeSettings.dddd=["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]]
6549
+ * @param {Array<string>} [settings.dddd]
6551
6550
  * Long day names (e.g. `Wednesday`)
6552
- * @param {Array<string>} [localeSettings.ddd=["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]]
6551
+ * @param {Array<string>} [settings.ddd]
6553
6552
  * Shortened day names (e.g. `Wed`)
6554
- * @param {Array<string>} [localeSettings.bool=["TRUE", "FALSE"]]
6553
+ * @param {Array<string>} [settings.bool]
6555
6554
  * How TRUE and FALSE should be presented.
6556
- * @param {boolean} [localeSettings.preferMDY=false]
6555
+ * @param {boolean} [settings.preferMDY]
6557
6556
  * Is the prefered date format month first (12/31/2025) or day first (31/12/2025)
6558
- * @param {string} l4e - A string BCP 47 tag of the locale.
6557
+ * @param {string | LocaleToken} locale - A string BCP 47 tag or parsed locale token.
6559
6558
  * @returns {LocaleData} - A full collection of settings for a locale
6560
6559
  */
6561
- function addLocale(localeSettings, l4e) {
6562
- const c = typeof l4e === "object" ? l4e : parseLocale(l4e);
6563
- locales[c.lang] = createLocale(localeSettings);
6564
- if (c.language !== c.lang && !locales[c.language]) locales[c.language] = createLocale(localeSettings);
6560
+ function addLocale(settings, locale) {
6561
+ const c = typeof locale === "object" ? locale : parseLocale(locale);
6562
+ locales[c.lang] = createLocale(settings);
6563
+ if (c.language !== c.lang && !locales[c.language]) locales[c.language] = createLocale(settings);
6565
6564
  return locales[c.lang];
6566
6565
  }
6567
6566
  const defaultLocale = createLocale({
@@ -7078,131 +7077,62 @@ addLocale({
7078
7077
  }, "hi");
7079
7078
 
7080
7079
  //#endregion
7081
- //#region ../../../node_modules/.pnpm/numfmt@3.2.6/node_modules/numfmt/lib/parseValue.js
7082
- /**
7083
- * @typedef {object} ParseData
7084
- * @property {number | boolean} v - the value
7085
- * @property {string} [z] - number format pattern
7086
- */
7087
- const okDateFormats = [
7088
- "!d-m-y",
7089
- "!d-m-Y",
7090
- "!j-m-y",
7091
- "!j-m-Y",
7092
- "!d-n-y",
7093
- "!d-n-Y",
7094
- "!j-n-y",
7095
- "!j-n-Y",
7096
- "?m-d-y",
7097
- "?m-d-Y",
7098
- "?m-j-y",
7099
- "?m-j-Y",
7100
- "?n-d-y",
7101
- "?n-d-Y",
7102
- "?n-j-y",
7103
- "?n-j-Y",
7104
- "d-M-y",
7105
- "d-M-Y",
7106
- "j-M-y",
7107
- "j-M-Y",
7108
- "M-d-y",
7109
- "M-d-Y",
7110
- "M-j-y",
7111
- "M-j-Y",
7112
- "d-F-y",
7113
- "d-F-Y",
7114
- "F-d-y",
7115
- "F-d-Y",
7116
- "F-j-y",
7117
- "F-j-Y",
7118
- "j-F-y",
7119
- "j-F-Y",
7120
- "y-F-d",
7121
- "y-F-j",
7122
- "y-M-d",
7123
- "y-M-j",
7124
- "Y-F-d",
7125
- "Y-F-j",
7126
- "Y-M-d",
7127
- "Y-m-d",
7128
- "Y-M-j",
7129
- "Y-m-j",
7130
- "Y-n-d",
7131
- "Y-n-j",
7132
- "j-F",
7133
- "j-M",
7134
- "d-F",
7135
- "d-M",
7136
- "n-d",
7137
- "n-j",
7138
- "n-Y",
7139
- "m-d",
7140
- "m-j",
7141
- "m-Y",
7142
- "M-Y",
7143
- "M-y",
7144
- "F-y",
7145
- "F-Y",
7146
- "Y-M",
7147
- "Y-n",
7148
- "Y-m",
7149
- "Y-F",
7150
- "Y-M"
7151
- ];
7152
- const dateTrieDM = {};
7153
- const dateTrieMD = {};
7154
- function packDate(f, node, allowType = 1) {
7155
- if (f) {
7156
- const char = f[0];
7157
- const next = f.slice(1);
7158
- if (char === "!") packDate(next, node, 4);
7159
- else if (char === "?") packDate(next, node, 2);
7160
- else {
7161
- node[char] = node[char] || {};
7162
- packDate(next, node[char], allowType);
7163
- }
7164
- } else node.$ = allowType;
7080
+ //#region ../../../packages/core/src/shared/numfmt/parse-format-section.ts
7081
+ function getNumberPattern(part, prefix) {
7082
+ switch (prefix) {
7083
+ case "int": return part.int_pattern;
7084
+ case "frac": return part.frac_pattern;
7085
+ case "man": return part.man_pattern;
7086
+ case "den": return part.den_pattern;
7087
+ case "num": return part.num_pattern;
7088
+ }
7165
7089
  }
7166
- function addFormatToTrie(fmt, trie) {
7167
- packDate(fmt, trie);
7168
- packDate(fmt + " x", trie);
7169
- packDate(fmt + " l", trie);
7170
- packDate(fmt + " l x", trie);
7171
- packDate("l " + fmt, trie);
7172
- packDate("l " + fmt + " x", trie);
7173
- packDate(fmt + " D", trie);
7174
- packDate(fmt + " D x", trie);
7175
- packDate("D " + fmt, trie);
7176
- packDate("D " + fmt + " x", trie);
7177
- }
7178
- okDateFormats.forEach((fmt) => {
7179
- if (!fmt.startsWith("?")) addFormatToTrie(fmt, dateTrieDM);
7180
- if (!fmt.startsWith("!")) addFormatToTrie(fmt, dateTrieMD);
7181
- });
7182
- const currentYear = (/* @__PURE__ */ new Date()).getUTCFullYear();
7183
-
7184
- //#endregion
7185
- //#region ../../../node_modules/.pnpm/numfmt@3.2.6/node_modules/numfmt/lib/parseFormatSection.js
7186
7090
  function minMaxPad(str, part, prefix) {
7187
- part[prefix + "_max"] = str.length;
7188
- part[prefix + "_min"] = str.replace(/#/g, "").length;
7091
+ const max = str.length;
7092
+ const min = str.replace(/#/g, "").length;
7093
+ switch (prefix) {
7094
+ case "int":
7095
+ part.int_max = max;
7096
+ part.int_min = min;
7097
+ break;
7098
+ case "frac":
7099
+ part.frac_max = max;
7100
+ part.frac_min = min;
7101
+ break;
7102
+ case "man":
7103
+ part.man_max = max;
7104
+ part.man_min = min;
7105
+ break;
7106
+ case "den":
7107
+ part.den_max = max;
7108
+ part.den_min = min;
7109
+ break;
7110
+ case "num":
7111
+ part.num_max = max;
7112
+ part.num_min = min;
7113
+ break;
7114
+ }
7189
7115
  return part;
7190
7116
  }
7191
- function add(s, tokens) {
7192
- if (typeof s === "string") tokens.push({
7117
+ function add(token, tokens) {
7118
+ if (typeof token === "string") tokens.push({
7193
7119
  type: "string",
7194
- value: s
7120
+ value: token
7195
7121
  });
7196
- else tokens.push(s);
7122
+ else tokens.push(token);
7197
7123
  }
7198
7124
  function isNumOp(token, activePattern) {
7199
7125
  const type = token === null || token === void 0 ? void 0 : token.type;
7200
7126
  return type === "hash" || type === "zero" || type === "qmark" || type === "digit" && activePattern === "den";
7201
7127
  }
7128
+ function assertNumberChunk(token) {
7129
+ if (token === null) throw new TypeError("Cannot read properties of null (reading 'num')");
7130
+ }
7202
7131
  function parseFormatSection(inputTokens) {
7203
7132
  const outputTokens = [];
7204
7133
  const part = {
7205
7134
  scale: 1,
7135
+ scaleExponent: 0,
7206
7136
  percent: false,
7207
7137
  text: false,
7208
7138
  date: 0,
@@ -7216,7 +7146,24 @@ function parseFormatSection(inputTokens) {
7216
7146
  man_pattern: [],
7217
7147
  den_pattern: [],
7218
7148
  num_pattern: [],
7219
- tokens: outputTokens
7149
+ tokens: outputTokens,
7150
+ tokensUsed: 0,
7151
+ pattern: "",
7152
+ int_max: 0,
7153
+ int_min: 0,
7154
+ frac_max: 0,
7155
+ frac_min: 0,
7156
+ man_max: 0,
7157
+ man_min: 0,
7158
+ num_max: 0,
7159
+ num_min: 0,
7160
+ den_max: 0,
7161
+ den_min: 0,
7162
+ int_p: "",
7163
+ man_p: "",
7164
+ num_p: "",
7165
+ den_p: "",
7166
+ integer: false
7220
7167
  };
7221
7168
  let currentPattern = "int";
7222
7169
  let lastNumberChunk = null;
@@ -7236,12 +7183,13 @@ function parseFormatSection(inputTokens) {
7236
7183
  part.general = true;
7237
7184
  add(token, outputTokens);
7238
7185
  } else if (isNumOp(token, currentPattern)) {
7239
- const pt = part[currentPattern + "_pattern"];
7186
+ const pattern = getNumberPattern(part, currentPattern);
7240
7187
  if (isNumOp(last, currentPattern) || (last === null || last === void 0 ? void 0 : last.type) === "group") {
7241
- pt.push((pt.pop() || "") + token.value);
7188
+ pattern.push((pattern.pop() || "") + token.value);
7189
+ assertNumberChunk(lastNumberChunk);
7242
7190
  lastNumberChunk.num += token.value;
7243
7191
  } else {
7244
- pt.push(token.value);
7192
+ pattern.push(token.value);
7245
7193
  lastNumberChunk = {
7246
7194
  type: currentPattern,
7247
7195
  num: token.value
@@ -7254,17 +7202,22 @@ function parseFormatSection(inputTokens) {
7254
7202
  } else if (type === "digit") add(token.value, outputTokens);
7255
7203
  else if (type === "slash") {
7256
7204
  haveSlash = true;
7257
- if (part[currentPattern + "_pattern"].length) {
7205
+ const pattern = getNumberPattern(part, currentPattern);
7206
+ if (pattern.length) {
7258
7207
  if (!lastNumberChunk) throw new SyntaxError("Format pattern is missing a numerator");
7259
7208
  part.fractions = true;
7260
- part.num_pattern.push(part[currentPattern + "_pattern"].pop());
7209
+ const numerator = pattern.pop();
7210
+ if (numerator === void 0) throw new SyntaxError("Format pattern is missing a numerator");
7211
+ part.num_pattern.push(numerator);
7261
7212
  lastNumberChunk.type = "num";
7262
7213
  currentPattern = "den";
7263
7214
  add({ type: "div" }, outputTokens);
7264
7215
  } else add(token.value, outputTokens);
7265
7216
  } else if (type === "comma") add(",", outputTokens);
7266
- else if (type === "scale") part.scale = .001 ** token.raw.length;
7267
- else if (type === "group") {
7217
+ else if (type === "scale") {
7218
+ part.scale = .001 ** token.raw.length;
7219
+ part.scaleExponent = -3 * token.raw.length;
7220
+ } else if (type === "group") {
7268
7221
  if (currentPattern === "int") part.grouping = true;
7269
7222
  if (currentPattern === "den") throw new SyntaxError("Cannot group denominator digits");
7270
7223
  } else if (type === "space") add(token, outputTokens);
@@ -7299,17 +7252,17 @@ function parseFormatSection(inputTokens) {
7299
7252
  add(bit, outputTokens);
7300
7253
  } else if (part.date && type === "point" && ((_inputTokens = inputTokens[index + 1]) === null || _inputTokens === void 0 ? void 0 : _inputTokens.type) === "zero") {
7301
7254
  var _inputTokens2, _inputTokens3;
7302
- let dec = 1;
7255
+ let decimals = 1;
7303
7256
  index++;
7304
7257
  let raw = "0";
7305
7258
  if (((_inputTokens2 = inputTokens[index + 1]) === null || _inputTokens2 === void 0 ? void 0 : _inputTokens2.type) === "zero") {
7306
7259
  raw += "0";
7307
- dec = 2;
7260
+ decimals = 2;
7308
7261
  index++;
7309
7262
  }
7310
7263
  if (((_inputTokens3 = inputTokens[index + 1]) === null || _inputTokens3 === void 0 ? void 0 : _inputTokens3.type) === "zero") {
7311
7264
  raw += "0";
7312
- dec = 3;
7265
+ decimals = 3;
7313
7266
  index++;
7314
7267
  }
7315
7268
  patternSource += raw;
@@ -7318,14 +7271,14 @@ function parseFormatSection(inputTokens) {
7318
7271
  128,
7319
7272
  256,
7320
7273
  512
7321
- ][dec];
7274
+ ][decimals];
7322
7275
  part.date = part.date | size;
7323
7276
  part.date_eval = true;
7324
- part.sec_decimals = Math.max(part.sec_decimals, dec);
7277
+ part.sec_decimals = Math.max(part.sec_decimals, decimals);
7325
7278
  add({
7326
7279
  type: "subsec",
7327
7280
  size,
7328
- decimals: dec,
7281
+ decimals,
7329
7282
  date: 1
7330
7283
  }, outputTokens);
7331
7284
  } else if (type === "calendar") {
@@ -7376,9 +7329,9 @@ function parseFormatSection(inputTokens) {
7376
7329
  bit.size = 4;
7377
7330
  bit.type = "monthname";
7378
7331
  }
7379
- const last_date_chunk = dateChunks[dateChunks.length - 1];
7380
- if (!bit.type && last_date_chunk && !last_date_chunk.used && last_date_chunk.size & (16 | 64)) {
7381
- last_date_chunk.used = true;
7332
+ const lastDateChunk = dateChunks[dateChunks.length - 1];
7333
+ if (!bit.type && lastDateChunk && !lastDateChunk.used && lastDateChunk.size & (16 | 64)) {
7334
+ lastDateChunk.used = true;
7382
7335
  bit.size = 32;
7383
7336
  bit.type = "min";
7384
7337
  bit.pad = /mm/.test(value);
@@ -7393,12 +7346,12 @@ function parseFormatSection(inputTokens) {
7393
7346
  bit.size = 64;
7394
7347
  bit.type = "sec";
7395
7348
  bit.pad = /ss/.test(value);
7396
- const last_date_chunk = dateChunks[dateChunks.length - 1];
7397
- if (last_date_chunk && last_date_chunk.size & 32) bit.used = true;
7398
- else if (last_date_chunk === null || last_date_chunk === void 0 ? void 0 : last_date_chunk.indeterminate) {
7399
- delete last_date_chunk.indeterminate;
7400
- last_date_chunk.size = 32;
7401
- last_date_chunk.type = "min";
7349
+ const lastDateChunk = dateChunks[dateChunks.length - 1];
7350
+ if (lastDateChunk && lastDateChunk.size & 32) bit.used = true;
7351
+ else if (lastDateChunk === null || lastDateChunk === void 0 ? void 0 : lastDateChunk.indeterminate) {
7352
+ delete lastDateChunk.indeterminate;
7353
+ lastDateChunk.size = 32;
7354
+ lastDateChunk.type = "min";
7402
7355
  bit.used = true;
7403
7356
  }
7404
7357
  } else if (startsWith === "g") {}
@@ -7413,26 +7366,28 @@ function parseFormatSection(inputTokens) {
7413
7366
  token.short = token.value === "A/P";
7414
7367
  add(token, outputTokens);
7415
7368
  } else if (type === "string" || type === "escaped" || type === "char") add(token.value, outputTokens);
7416
- else if (type === "condition") part.condition = [token.value[0], parseFloat(token.value[1])];
7369
+ else if (type === "condition") part.condition = [token.value[0], Number.parseFloat(token.value[1])];
7417
7370
  else if (type === "locale") {
7418
7371
  const bits = token.value.split("-");
7419
7372
  const code = bits.length < 2 ? "" : bits.slice(1).join("-");
7420
7373
  const currency = bits[0];
7421
7374
  if (currency) add(currency, outputTokens);
7422
- const l4e = resolveLocale(code);
7423
- if (l4e) part.locale = l4e;
7424
- const wincode = parseInt(code, 16);
7425
- if (isFinite(wincode) && wincode & 16711680) {
7426
- if ((wincode >> 16 & 255) === 6) part.date_system = 6;
7375
+ const locale = resolveLocale(code);
7376
+ if (locale) part.locale = locale;
7377
+ const windowsCode = Number.parseInt(code, 16);
7378
+ if (Number.isFinite(windowsCode) && windowsCode & 16711680) {
7379
+ if ((windowsCode >> 16 & 255) === 6) part.date_system = 6;
7427
7380
  }
7428
7381
  haveLocale = true;
7429
7382
  } else if (type === "color") {
7430
- let cm;
7431
- let v = token.value.toLowerCase();
7432
- if (cm = /^color\s*(\d+)$/i.exec(v)) v = parseInt(cm[1], 10);
7433
- part.color = v;
7383
+ const normalizedColor = token.value.toLowerCase();
7384
+ let color = normalizedColor;
7385
+ const colorMatch = /^color\s*(\d+)$/i.exec(normalizedColor);
7386
+ if (colorMatch) color = Number.parseInt(colorMatch[1], 10);
7387
+ part.color = color;
7434
7388
  } else if (type === "percent") {
7435
7389
  part.scale = 100;
7390
+ part.scaleExponent = 2;
7436
7391
  part.percent = true;
7437
7392
  add("%", outputTokens);
7438
7393
  } else if (type === "point") {
@@ -7449,8 +7404,7 @@ function parseFormatSection(inputTokens) {
7449
7404
  type: "exp",
7450
7405
  plus: part.exp_plus
7451
7406
  }, outputTokens);
7452
- } else if (type === "skip") add(token, outputTokens);
7453
- else if (type === "fill") add(token, outputTokens);
7407
+ } else if (type === "skip" || type === "fill") add(token, outputTokens);
7454
7408
  else if (type === "dbnum" || type === "natnum") {} else if (type === "error") throw new SyntaxError(`Illegal character: ${patternSource}`);
7455
7409
  else throw new SyntaxError(`Unknown token ${type} in ${patternSource}`);
7456
7410
  last = token;
@@ -7464,34 +7418,34 @@ function parseFormatSection(inputTokens) {
7464
7418
  const fracPattern = part.frac_pattern.join("");
7465
7419
  minMaxPad(intPattern, part, "int");
7466
7420
  let min = 0;
7467
- for (let i = 0; i < intPattern.length; i++) {
7468
- const ch = intPattern[intPattern.length - 1 - i];
7469
- if (/^[0-9?]/.test(ch)) min = i + 1;
7421
+ for (let patternIndex = 0; patternIndex < intPattern.length; patternIndex++) {
7422
+ const character = intPattern[intPattern.length - 1 - patternIndex];
7423
+ if (/^[0-9?]/.test(character)) min = patternIndex + 1;
7470
7424
  }
7471
7425
  part.int_min = min;
7472
7426
  minMaxPad(fracPattern, part, "frac");
7473
7427
  minMaxPad(manPattern, part, "man");
7474
- let num_pat = part.num_pattern.join("");
7475
- let den_pat = part.den_pattern[0] || "";
7476
- if (den_pat.includes("?") || num_pat.includes("?")) {
7477
- den_pat = den_pat.replace(/\d/g, "?");
7478
- den_pat = den_pat.replace(/#$/g, "?");
7479
- minMaxPad(num_pat, part, "num");
7480
- minMaxPad(den_pat, part, "den");
7481
- num_pat = num_pat.replace(/#$/g, "?");
7428
+ let numeratorPattern = part.num_pattern.join("");
7429
+ let denominatorPattern = part.den_pattern[0] || "";
7430
+ if (denominatorPattern.includes("?") || numeratorPattern.includes("?")) {
7431
+ denominatorPattern = denominatorPattern.replace(/\d/g, "?");
7432
+ denominatorPattern = denominatorPattern.replace(/#$/g, "?");
7433
+ minMaxPad(numeratorPattern, part, "num");
7434
+ minMaxPad(denominatorPattern, part, "den");
7435
+ numeratorPattern = numeratorPattern.replace(/#$/g, "?");
7482
7436
  } else {
7483
- minMaxPad(num_pat, part, "num");
7484
- minMaxPad(den_pat, part, "den");
7437
+ minMaxPad(numeratorPattern, part, "num");
7438
+ minMaxPad(denominatorPattern, part, "den");
7485
7439
  }
7486
7440
  part.int_p = intPattern;
7487
7441
  part.man_p = manPattern;
7488
- part.num_p = num_pat;
7489
- part.den_p = den_pat;
7490
- if (part.den_pattern.length) part.denominator = parseInt(part.den_pattern.join("").replace(/\D/g, ""), 10);
7442
+ part.num_p = numeratorPattern;
7443
+ part.den_p = denominatorPattern;
7444
+ if (part.den_pattern.length) part.denominator = Number.parseInt(part.den_pattern.join("").replace(/\D/g, ""), 10);
7491
7445
  part.integer = !!intPattern.length;
7492
7446
  if (!part.integer && !part.exponential && fracPattern.length) {
7493
- const pointIdx = part.tokens.findIndex((d) => d.type === "point");
7494
- part.tokens.splice(pointIdx, 0, {
7447
+ const pointIndex = part.tokens.findIndex((token) => token.type === "point");
7448
+ part.tokens.splice(pointIndex, 0, {
7495
7449
  type: "int",
7496
7450
  value: "#"
7497
7451
  });
@@ -7499,71 +7453,136 @@ function parseFormatSection(inputTokens) {
7499
7453
  part.int_pattern = ["#"];
7500
7454
  part.int_p = "#";
7501
7455
  }
7502
- if (part.fractions) for (let i = 0; i < outputTokens.length - 1; i++) {
7503
- const tok = outputTokens[i];
7504
- if (tok.type !== "string" && tok.type !== "space") continue;
7505
- const nextType = outputTokens[i + 1].type;
7506
- if (nextType === "num") tok.rule = "num+int";
7507
- else if (nextType === "div") tok.rule = "num";
7508
- else if (nextType === "den") tok.rule = "den";
7509
- }
7510
- if (part.grouping) {
7511
- if (part.int_pattern.length > 1) part.grouping = false;
7456
+ if (part.fractions) for (let tokenIndex = 0; tokenIndex < outputTokens.length - 1; tokenIndex++) {
7457
+ const token = outputTokens[tokenIndex];
7458
+ if (token.type !== "string" && token.type !== "space") continue;
7459
+ const nextType = outputTokens[tokenIndex + 1].type;
7460
+ if (nextType === "num") token.rule = "num+int";
7461
+ else if (nextType === "div") token.rule = "num";
7462
+ else if (nextType === "den") token.rule = "den";
7512
7463
  }
7464
+ if (part.grouping && part.int_pattern.length > 1) part.grouping = false;
7513
7465
  return part;
7514
7466
  }
7515
7467
 
7516
7468
  //#endregion
7517
- //#region ../../../node_modules/.pnpm/numfmt@3.2.6/node_modules/numfmt/lib/formatNumber.js
7518
- const default_text = parseFormatSection([{
7469
+ //#region ../../../packages/core/src/shared/numfmt/format-number.ts
7470
+ const defaultText = parseFormatSection([{
7519
7471
  type: TOKEN_TEXT,
7520
7472
  value: "@",
7521
7473
  raw: "@"
7522
7474
  }]);
7523
7475
 
7524
7476
  //#endregion
7525
- //#region ../../../node_modules/.pnpm/numfmt@3.2.6/node_modules/numfmt/lib/index.js
7526
- /**
7527
- * A dictionary of the types used to identify token variants.
7528
- *
7529
- * @readonly
7530
- * @constant {Object<string>} tokenTypes
7531
- * @property {string} AMPM - AM/PM operator (`AM/PM`, `A/P`)
7532
- * @property {string} BREAK - Semicolon operator indicating a break between format sections (`;`)
7533
- * @property {string} CALENDAR - Calendar modifier (`B2`)
7534
- * @property {string} CHAR - Single non-operator character (`m`)
7535
- * @property {string} COLOR - Color modifier (`[Black]`, `[color 5]`)
7536
- * @property {string} COMMA - Plain non-operator comma (`,`)
7537
- * @property {string} CONDITION - Condition modifier for a section (`[>=10]`)
7538
- * @property {string} DATETIME - Date-time operator (`mmmm`, `YY`)
7539
- * @property {string} DBNUM - Number display modifier (`[DBNum23]`)
7540
- * @property {string} DIGIT - A digit between 1 and 9 (`3`)
7541
- * @property {string} DURATION - Time duration (`[ss]`)
7542
- * @property {string} ERROR - Unidentifiable or illegal character (`Ň`)
7543
- * @property {string} ESCAPED - Escaped character (`\E`)
7544
- * @property {string} EXP - Exponent operator (`E+`)
7545
- * @property {string} FILL - Fill with char operator and operand (`*_`)
7546
- * @property {string} GENERAL - General format operator (`General`)
7547
- * @property {string} GROUP - Number grouping operator (`,`)
7548
- * @property {string} HASH - Hash operator (digit if available) (`#`)
7549
- * @property {string} LOCALE - Locale modifier (`[$-1E020404]`)
7550
- * @property {string} MINUS - Minus sign (`-`)
7551
- * @property {string} MODIFIER - An unidentified modifier (`[Schwarz]`)
7552
- * @property {string} NATNUM - Number display modifier (`[NatNum3]`)
7553
- * @property {string} PAREN - Parenthesis character (`)`)
7554
- * @property {string} PERCENT - Percent operator (`%`)
7555
- * @property {string} PLUS - Plus sign (`+`)
7556
- * @property {string} POINT - Decimal point operator (`.`)
7557
- * @property {string} QMARK - Question mark operator (digit or space if not available) (`?`)
7558
- * @property {string} SCALE - Scaling operator (`,`)
7559
- * @property {string} SKIP - Skip with char operator and operand (`*_`)
7560
- * @property {string} SLASH - Slash operator (`/`)
7561
- * @property {string} SPACE - Space (` `)
7562
- * @property {string} STRING - Quoted string (`"days"`)
7563
- * @property {string} TEXT - Text output operator (`@`)
7564
- * @property {string} ZERO - Zero operator (digit or zero if not available) (`0`)
7565
- * @see tokenize
7566
- */
7477
+ //#region ../../../packages/core/src/shared/numfmt/serial-date.ts
7478
+ const dateUTC = Date.UTC;
7479
+
7480
+ //#endregion
7481
+ //#region ../../../packages/core/src/shared/numfmt/parse-value.ts
7482
+ const okDateFormats = [
7483
+ "!d-m-y",
7484
+ "!d-m-Y",
7485
+ "!j-m-y",
7486
+ "!j-m-Y",
7487
+ "!d-n-y",
7488
+ "!d-n-Y",
7489
+ "!j-n-y",
7490
+ "!j-n-Y",
7491
+ "?m-d-y",
7492
+ "?m-d-Y",
7493
+ "?m-j-y",
7494
+ "?m-j-Y",
7495
+ "?n-d-y",
7496
+ "?n-d-Y",
7497
+ "?n-j-y",
7498
+ "?n-j-Y",
7499
+ "d-M-y",
7500
+ "d-M-Y",
7501
+ "j-M-y",
7502
+ "j-M-Y",
7503
+ "M-d-y",
7504
+ "M-d-Y",
7505
+ "M-j-y",
7506
+ "M-j-Y",
7507
+ "d-F-y",
7508
+ "d-F-Y",
7509
+ "F-d-y",
7510
+ "F-d-Y",
7511
+ "F-j-y",
7512
+ "F-j-Y",
7513
+ "j-F-y",
7514
+ "j-F-Y",
7515
+ "y-F-d",
7516
+ "y-F-j",
7517
+ "y-M-d",
7518
+ "y-M-j",
7519
+ "Y-F-d",
7520
+ "Y-F-j",
7521
+ "Y-M-d",
7522
+ "Y-m-d",
7523
+ "Y-M-j",
7524
+ "Y-m-j",
7525
+ "Y-n-d",
7526
+ "Y-n-j",
7527
+ "j-F",
7528
+ "j-M",
7529
+ "d-F",
7530
+ "d-M",
7531
+ "n-d",
7532
+ "n-j",
7533
+ "n-Y",
7534
+ "m-d",
7535
+ "m-j",
7536
+ "m-Y",
7537
+ "M-Y",
7538
+ "M-y",
7539
+ "F-y",
7540
+ "F-Y",
7541
+ "Y-M",
7542
+ "Y-n",
7543
+ "Y-m",
7544
+ "Y-F",
7545
+ "Y-M"
7546
+ ];
7547
+ const dateTrieDM = {};
7548
+ const dateTrieMD = {};
7549
+ function packDate(format, node, allowType = 1) {
7550
+ if (format) {
7551
+ const char = format[0];
7552
+ const next = format.slice(1);
7553
+ if (char === "!") packDate(next, node, 4);
7554
+ else if (char === "?") packDate(next, node, 2);
7555
+ else {
7556
+ let branch = node[char];
7557
+ if (typeof branch !== "object") {
7558
+ branch = {};
7559
+ node[char] = branch;
7560
+ }
7561
+ packDate(next, branch, allowType);
7562
+ }
7563
+ } else node.$ = allowType;
7564
+ }
7565
+ function addFormatToTrie(format, trie) {
7566
+ packDate(format, trie);
7567
+ packDate(`${format} x`, trie);
7568
+ packDate(`${format} l`, trie);
7569
+ packDate(`${format} l x`, trie);
7570
+ packDate(`l ${format}`, trie);
7571
+ packDate(`l ${format} x`, trie);
7572
+ packDate(`${format} D`, trie);
7573
+ packDate(`${format} D x`, trie);
7574
+ packDate(`D ${format}`, trie);
7575
+ packDate(`D ${format} x`, trie);
7576
+ }
7577
+ okDateFormats.forEach((format) => {
7578
+ if (!format.startsWith("?")) addFormatToTrie(format, dateTrieDM);
7579
+ if (!format.startsWith("!")) addFormatToTrie(format, dateTrieMD);
7580
+ });
7581
+ const currentYear = (/* @__PURE__ */ new Date()).getUTCFullYear();
7582
+
7583
+ //#endregion
7584
+ //#region ../../../packages/core/src/shared/numfmt/api.ts
7585
+ /** A dictionary of the types used to identify token variants. */
7567
7586
  const tokenTypes = Object.freeze({
7568
7587
  AMPM: TOKEN_AMPM,
7569
7588
  BREAK: TOKEN_BREAK,
@@ -7915,7 +7934,7 @@ const regexp = {
7915
7934
  };
7916
7935
 
7917
7936
  //#endregion
7918
- //#region ../../../packages/core/src/shared/numfmt.ts
7937
+ //#region ../../../packages/core/src/shared/numfmt/utils.ts
7919
7938
  const currencySymbols = [
7920
7939
  "Rp",
7921
7940
  "zł",
@@ -9317,6 +9336,7 @@ const STYLE_KEYS = defineExactKeys()([
9317
9336
  "cl",
9318
9337
  "va",
9319
9338
  "n",
9339
+ "stf",
9320
9340
  "tr",
9321
9341
  "td",
9322
9342
  "ht",
@@ -18067,6 +18087,10 @@ _defineProperty(BuildTextUtils, "paragraph", {
18067
18087
  });
18068
18088
  _defineProperty(BuildTextUtils, "drawing", { add: addDrawing });
18069
18089
 
18090
+ //#endregion
18091
+ //#region ../../../packages/core/src/docs/data-model/rich-text-builder.ts
18092
+ const NON_EDITABLE_RICH_TEXT_TOKENS = new Set(Object.values(DataStreamTreeTokenType).filter((token) => token !== "" && token !== " "));
18093
+
18070
18094
  //#endregion
18071
18095
  //#region ../../../packages/core/src/services/resource-manager/type.ts
18072
18096
  const IResourceManagerService = createIdentifier("core.resource-manager.service");