ooxml-core 1.10.0 → 1.11.0

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.
Files changed (162) hide show
  1. package/dist/PptxHandler-DNZHAHUY.cjs +12 -0
  2. package/dist/PptxHandler-E44KDHMQ.mjs +3 -0
  3. package/dist/{PptxHandler-ADEFY476.mjs → PptxHandler-NROFYT2N.mjs} +2 -2
  4. package/dist/automation/index.cjs +3293 -2867
  5. package/dist/automation/index.mjs +3293 -2867
  6. package/dist/{chunk-3N6XMMTT.cjs → chunk-2UVH6RHI.cjs} +1138 -996
  7. package/dist/{chunk-ZOUGMAZG.mjs → chunk-7DSZI7S6.mjs} +1 -1
  8. package/dist/{chunk-S6DOCMQC.cjs → chunk-7QZGRB3T.cjs} +0 -10
  9. package/dist/chunk-ANZ4Q6I3.cjs +21 -0
  10. package/dist/{chunk-5NVJN4E6.mjs → chunk-EC2W2MDY.mjs} +1 -1
  11. package/dist/chunk-EGTRL3QJ.mjs +19 -0
  12. package/dist/chunk-GXHKNSZX.mjs +9 -0
  13. package/dist/{chunk-CCHYFCPD.mjs → chunk-HCXUI5UC.mjs} +296 -103
  14. package/dist/chunk-HDQXPSHY.cjs +17 -0
  15. package/dist/chunk-KTYBFGEY.mjs +14 -0
  16. package/dist/chunk-QOO36KG4.cjs +42 -0
  17. package/dist/chunk-R2KZXD6U.mjs +39 -0
  18. package/dist/{chunk-A6P7G3UK.mjs → chunk-U2DF3EGK.mjs} +1 -1
  19. package/dist/{chunk-R6KSBNKX.mjs → chunk-UAY26XOI.mjs} +1 -9
  20. package/dist/{chunk-WUE5ZHU3.mjs → chunk-W5ARCUJB.mjs} +3 -3
  21. package/dist/chunk-XZPZHXV4.cjs +12 -0
  22. package/dist/{chunk-ZE53K7DH.mjs → chunk-YB5SRNFS.mjs} +244 -102
  23. package/dist/docx/layout/flow-table.d.ts.map +1 -1
  24. package/dist/docx/layout/index.cjs +125 -56
  25. package/dist/docx/layout/index.mjs +125 -56
  26. package/dist/docx/layout/nested-fragment-edges.d.ts +9 -0
  27. package/dist/docx/layout/nested-fragment-edges.d.ts.map +1 -0
  28. package/dist/docx/layout/result.d.ts +7 -0
  29. package/dist/docx/layout/result.d.ts.map +1 -1
  30. package/dist/docx/layout/table-border-layout.d.ts +1 -1
  31. package/dist/docx/layout/table-border-layout.d.ts.map +1 -1
  32. package/dist/docx/layout/table-cell-layout.d.ts +1 -1
  33. package/dist/docx/layout/table-cell-layout.d.ts.map +1 -1
  34. package/dist/docx/layout/table-frames.d.ts.map +1 -1
  35. package/dist/docx/layout/table-layout.d.ts +1 -1
  36. package/dist/docx/layout/table-layout.d.ts.map +1 -1
  37. package/dist/pptx/automation/index.cjs +266 -114
  38. package/dist/pptx/automation/index.d.ts +5 -4
  39. package/dist/pptx/automation/index.d.ts.map +1 -1
  40. package/dist/pptx/automation/index.mjs +5 -5
  41. package/dist/pptx/chunks/{text-operations-BqHmLaLA.d.ts → elements-DD3UGOMd.d.ts} +17 -3262
  42. package/dist/pptx/chunks/elements-DD3UGOMd.d.ts.map +1 -0
  43. package/dist/pptx/chunks/{index-DUCGeZh7.d.ts → index-BZrFyNtU.d.ts} +53 -5
  44. package/dist/pptx/chunks/index-BZrFyNtU.d.ts.map +1 -0
  45. package/dist/pptx/chunks/{index-Cuxtr76Y.d.ts → index-DdX02BSm.d.ts} +5 -3
  46. package/dist/pptx/chunks/index-DdX02BSm.d.ts.map +1 -0
  47. package/dist/pptx/chunks/smart-art-ENMMEbmW.d.ts +1512 -0
  48. package/dist/pptx/chunks/smart-art-ENMMEbmW.d.ts.map +1 -0
  49. package/dist/pptx/chunks/text-D49FKllA.d.ts +1473 -0
  50. package/dist/pptx/chunks/text-D49FKllA.d.ts.map +1 -0
  51. package/dist/pptx/chunks/text-operations-CyMTMfID.d.ts +3261 -0
  52. package/dist/pptx/chunks/text-operations-CyMTMfID.d.ts.map +1 -0
  53. package/dist/pptx/cli/index.cjs +266 -114
  54. package/dist/pptx/cli/index.d.ts +1 -1
  55. package/dist/pptx/cli/index.mjs +4 -4
  56. package/dist/pptx/converter/index.d.ts +1 -1
  57. package/dist/pptx/converter/index.mjs +2 -2
  58. package/dist/pptx/editor/render/find-replace.cjs +17 -16
  59. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  60. package/dist/pptx/editor/render/find-replace.mjs +2 -1
  61. package/dist/pptx/editor/render/font-family-update.cjs +14 -0
  62. package/dist/pptx/editor/render/font-family-update.d.ts +17 -0
  63. package/dist/pptx/editor/render/font-family-update.d.ts.map +1 -0
  64. package/dist/pptx/editor/render/font-family-update.mjs +1 -0
  65. package/dist/pptx/editor/render/paragraph-geometry-overrides.cjs +14 -0
  66. package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts +17 -0
  67. package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts.map +1 -0
  68. package/dist/pptx/editor/render/paragraph-geometry-overrides.mjs +12 -0
  69. package/dist/pptx/editor/render/slide-operations.cjs +9 -8
  70. package/dist/pptx/editor/render/slide-operations.mjs +3 -2
  71. package/dist/pptx/editor/render/table-data-grid-ops.cjs +1 -1
  72. package/dist/pptx/editor/render/table-data-grid-ops.mjs +1 -1
  73. package/dist/pptx/editor/render/text-content-style.cjs +18 -0
  74. package/dist/pptx/editor/render/text-content-style.d.ts +9 -0
  75. package/dist/pptx/editor/render/text-content-style.d.ts.map +1 -0
  76. package/dist/pptx/editor/render/text-content-style.mjs +5 -0
  77. package/dist/pptx/editor/render/text-runs-style-patch.cjs +17 -0
  78. package/dist/pptx/editor/render/text-runs-style-patch.d.ts +7 -0
  79. package/dist/pptx/editor/render/text-runs-style-patch.d.ts.map +1 -0
  80. package/dist/pptx/editor/render/text-runs-style-patch.mjs +15 -0
  81. package/dist/pptx/editor/render/text-style-scope.cjs +173 -0
  82. package/dist/pptx/editor/render/text-style-scope.d.ts +76 -0
  83. package/dist/pptx/editor/render/text-style-scope.d.ts.map +1 -0
  84. package/dist/pptx/editor/render/text-style-scope.mjs +164 -0
  85. package/dist/pptx/editor/render/theme-editor-model.cjs +1 -1
  86. package/dist/pptx/editor/render/theme-editor-model.mjs +1 -1
  87. package/dist/pptx/editor/render/update-text-segment-style.cjs +11 -0
  88. package/dist/pptx/editor/render/update-text-segment-style.d.ts +14 -0
  89. package/dist/pptx/editor/render/update-text-segment-style.d.ts.map +1 -0
  90. package/dist/pptx/editor/render/update-text-segment-style.mjs +2 -0
  91. package/dist/pptx/index.cjs +329 -114
  92. package/dist/pptx/index.d.ts +7 -5
  93. package/dist/pptx/index.mjs +5 -5
  94. package/dist/pptx/smartart-layouts/index.d.ts +1 -1
  95. package/dist/teams/index.cjs +112 -16
  96. package/dist/teams/index.mjs +112 -16
  97. package/dist/visio/edit-commands.d.ts +3 -3
  98. package/dist/visio/edit-commands.d.ts.map +1 -1
  99. package/dist/visio/edit-formatting-scope.d.ts.map +1 -1
  100. package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
  101. package/dist/visio/edit-text-field-commands.d.ts +15 -0
  102. package/dist/visio/edit-text-field-commands.d.ts.map +1 -1
  103. package/dist/visio/edit-text-field.d.ts +2 -2
  104. package/dist/visio/edit-text-field.d.ts.map +1 -1
  105. package/dist/visio/edit.d.ts +1 -1
  106. package/dist/visio/edit.d.ts.map +1 -1
  107. package/dist/visio/index.cjs +382 -210
  108. package/dist/visio/index.d.ts +1 -1
  109. package/dist/visio/index.d.ts.map +1 -1
  110. package/dist/visio/index.mjs +382 -210
  111. package/dist/visio/model.d.ts +6 -0
  112. package/dist/visio/model.d.ts.map +1 -1
  113. package/dist/visio/shapes.d.ts.map +1 -1
  114. package/dist/visio/style.d.ts +1 -1
  115. package/dist/visio/style.d.ts.map +1 -1
  116. package/dist/visio/text-field-display.d.ts +3 -0
  117. package/dist/visio/text-field-display.d.ts.map +1 -1
  118. package/dist/visio/text-field-editability.d.ts +6 -0
  119. package/dist/visio/text-field-editability.d.ts.map +1 -0
  120. package/dist/visio/text-field-independent.d.ts +4 -0
  121. package/dist/visio/text-field-independent.d.ts.map +1 -0
  122. package/dist/visio/text-field-source.d.ts +6 -0
  123. package/dist/visio/text-field-source.d.ts.map +1 -0
  124. package/dist/visio/ui/edit-commands.d.ts.map +1 -1
  125. package/dist/visio/ui/index.cjs +394 -211
  126. package/dist/visio/ui/index.mjs +394 -211
  127. package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
  128. package/dist/xlsx/edit/pivots.d.ts.map +1 -1
  129. package/dist/xlsx/index.cjs +773 -514
  130. package/dist/xlsx/index.mjs +772 -515
  131. package/dist/xlsx/load/index.cjs +541 -292
  132. package/dist/xlsx/load/index.mjs +541 -292
  133. package/dist/xlsx/model-pivots.d.ts +8 -0
  134. package/dist/xlsx/model-pivots.d.ts.map +1 -1
  135. package/dist/xlsx/pivot/admission.d.ts.map +1 -1
  136. package/dist/xlsx/pivot/aggregate.d.ts.map +1 -1
  137. package/dist/xlsx/pivot/data.d.ts +2 -2
  138. package/dist/xlsx/pivot/data.d.ts.map +1 -1
  139. package/dist/xlsx/pivot/index.d.ts +2 -0
  140. package/dist/xlsx/pivot/index.d.ts.map +1 -1
  141. package/dist/xlsx/pivot/measures.d.ts +1 -1
  142. package/dist/xlsx/pivot/measures.d.ts.map +1 -1
  143. package/dist/xlsx/pivot/page-filter-admission.d.ts +5 -0
  144. package/dist/xlsx/pivot/page-filter-admission.d.ts.map +1 -0
  145. package/dist/xlsx/pivot/page-filter.d.ts +11 -0
  146. package/dist/xlsx/pivot/page-filter.d.ts.map +1 -0
  147. package/dist/xlsx/pivot/read.d.ts.map +1 -1
  148. package/dist/xlsx/pivot/table-xml.d.ts.map +1 -1
  149. package/dist/xlsx/pivot/values-axis.d.ts +4 -1
  150. package/dist/xlsx/pivot/values-axis.d.ts.map +1 -1
  151. package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
  152. package/dist/xlsx/ui/commands/i18n/pivots.d.ts.map +1 -1
  153. package/dist/xlsx/ui/index.cjs +95 -12
  154. package/dist/xlsx/ui/index.mjs +95 -12
  155. package/package.json +2 -2
  156. package/dist/PptxHandler-5UURGJEV.mjs +0 -2
  157. package/dist/PptxHandler-U5XB2HUE.cjs +0 -11
  158. package/dist/pptx/chunks/index-Cuxtr76Y.d.ts.map +0 -1
  159. package/dist/pptx/chunks/index-DUCGeZh7.d.ts.map +0 -1
  160. package/dist/pptx/chunks/smart-art-D-sXa_Nb.d.ts +0 -2980
  161. package/dist/pptx/chunks/smart-art-D-sXa_Nb.d.ts.map +0 -1
  162. package/dist/pptx/chunks/text-operations-BqHmLaLA.d.ts.map +0 -1
@@ -3450,6 +3450,208 @@ function takeDeferredTextSizes(root2) {
3450
3450
  return shapes;
3451
3451
  }
3452
3452
 
3453
+ // visio/text-fields.ts
3454
+ var PROPERTY_FUNCTIONS = {
3455
+ TITLE: "title",
3456
+ SUBJECT: "subject",
3457
+ CREATOR: "creator",
3458
+ KEYWORDS: "keywords",
3459
+ DESCRIPTION: "description",
3460
+ CATEGORY: "category",
3461
+ COMPANY: "company",
3462
+ MANAGER: "manager"
3463
+ };
3464
+ var DATE_FUNCTIONS = {
3465
+ NOW: void 0,
3466
+ DOCCREATION: "created",
3467
+ DOCLASTSAVE: "modified",
3468
+ DOCLASTEDIT: "modified",
3469
+ DOCLASTPRINT: "lastPrinted"
3470
+ };
3471
+ var VISIO_FIELD_FUNCTIONS = [
3472
+ ...Object.keys(PROPERTY_FUNCTIONS),
3473
+ ...Object.keys(DATE_FUNCTIONS),
3474
+ "PAGENAME"
3475
+ ];
3476
+ function visioWallClock(date2) {
3477
+ return new Date(
3478
+ Date.UTC(
3479
+ date2.getFullYear(),
3480
+ date2.getMonth(),
3481
+ date2.getDate(),
3482
+ date2.getHours(),
3483
+ date2.getMinutes(),
3484
+ date2.getSeconds()
3485
+ )
3486
+ );
3487
+ }
3488
+ var EPOCH = Date.UTC(1899, 11, 30);
3489
+ var visioSerialDate = (serial) => Number.isFinite(serial) && Math.abs(serial) < 3e6 ? new Date(EPOCH + Math.round(serial * 864e5)) : void 0;
3490
+ function evaluateVisioTextField(formula, context) {
3491
+ let ast;
3492
+ try {
3493
+ ast = parseVisioFormula(formula, { maxLength: 4096 });
3494
+ } catch {
3495
+ return void 0;
3496
+ }
3497
+ if (ast.kind === "call") {
3498
+ const name3 = ast.name;
3499
+ if (Object.hasOwn(PROPERTY_FUNCTIONS, name3) && !ast.args.length) {
3500
+ const value = context.properties?.[PROPERTY_FUNCTIONS[name3]];
3501
+ return value === void 0 ? void 0 : { kind: "string", text: value };
3502
+ }
3503
+ if (Object.hasOwn(DATE_FUNCTIONS, name3) && !ast.args.length) {
3504
+ if (name3 === "NOW") return context.now ? { kind: "date", date: context.now } : void 0;
3505
+ const stamp = context.properties?.[DATE_FUNCTIONS[name3]];
3506
+ const time = stamp ? Date.parse(stamp) : Number.NaN;
3507
+ return Number.isFinite(time) ? { kind: "date", date: visioWallClock(new Date(time)) } : void 0;
3508
+ }
3509
+ if (name3 === "PAGENAME" && ast.args.length <= 1)
3510
+ return context.pageName === void 0 ? void 0 : { kind: "string", text: context.pageName };
3511
+ }
3512
+ try {
3513
+ const result = evaluateVisioFormula(
3514
+ ast,
3515
+ context.resolve ?? (() => {
3516
+ throw new Error("No cell context");
3517
+ }),
3518
+ {
3519
+ ...context.pageNumber === void 0 ? {} : { pageNumber: context.pageNumber },
3520
+ ...context.pageCount === void 0 ? {} : { pageCount: context.pageCount }
3521
+ }
3522
+ );
3523
+ return { kind: "number", value: result.value, unit: result.unit };
3524
+ } catch {
3525
+ return void 0;
3526
+ }
3527
+ }
3528
+ var MONTHS = [
3529
+ "January",
3530
+ "February",
3531
+ "March",
3532
+ "April",
3533
+ "May",
3534
+ "June",
3535
+ "July",
3536
+ "August",
3537
+ "September",
3538
+ "October",
3539
+ "November",
3540
+ "December"
3541
+ ];
3542
+ var DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
3543
+ var pad = (value, length = 2) => String(value).padStart(length, "0");
3544
+ function dateToken(date2, token) {
3545
+ const hours = date2.getUTCHours();
3546
+ switch (token) {
3547
+ case "yyyy":
3548
+ return pad(date2.getUTCFullYear(), 4);
3549
+ case "yy":
3550
+ return pad(date2.getUTCFullYear() % 100);
3551
+ case "MMMM":
3552
+ return MONTHS[date2.getUTCMonth()];
3553
+ case "MMM":
3554
+ return MONTHS[date2.getUTCMonth()].slice(0, 3);
3555
+ case "MM":
3556
+ return pad(date2.getUTCMonth() + 1);
3557
+ case "M":
3558
+ return String(date2.getUTCMonth() + 1);
3559
+ case "dddd":
3560
+ return DAYS[date2.getUTCDay()];
3561
+ case "ddd":
3562
+ return DAYS[date2.getUTCDay()].slice(0, 3);
3563
+ case "dd":
3564
+ return pad(date2.getUTCDate());
3565
+ case "d":
3566
+ return String(date2.getUTCDate());
3567
+ case "HH":
3568
+ return pad(hours);
3569
+ case "H":
3570
+ return String(hours);
3571
+ case "hh":
3572
+ return pad(hours % 12 || 12);
3573
+ case "h":
3574
+ return String(hours % 12 || 12);
3575
+ case "mm":
3576
+ return pad(date2.getUTCMinutes());
3577
+ case "ss":
3578
+ return pad(date2.getUTCSeconds());
3579
+ case "tt":
3580
+ return hours < 12 ? "AM" : "PM";
3581
+ default:
3582
+ return void 0;
3583
+ }
3584
+ }
3585
+ function formatDate(date2, picture) {
3586
+ return picture.replace(
3587
+ /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|tt|"[^"]*"/g,
3588
+ (token) => {
3589
+ if (token.startsWith('"')) return token.slice(1, -1);
3590
+ return dateToken(date2, token) ?? token;
3591
+ }
3592
+ );
3593
+ }
3594
+ function formatNumber(value, picture) {
3595
+ const match = /^(#,##)?0(?:\.(0+|#+))?$/.exec(picture);
3596
+ if (!match) return void 0;
3597
+ const decimals = match[2]?.length ?? 0;
3598
+ const optional = match[2]?.startsWith("#") ?? false;
3599
+ const [coefficient, exponent = "0"] = Math.abs(value).toString().split("e");
3600
+ const shifted = Number(coefficient + "e" + (Number(exponent) + decimals));
3601
+ const rounded = Math.floor(shifted + 0.5) / 10 ** decimals;
3602
+ let text5 = (Math.sign(value) * rounded).toFixed(decimals);
3603
+ if (optional && text5.includes(".")) text5 = text5.replace(/\.?0+$/, "");
3604
+ if (match[1]) {
3605
+ const [whole, fraction] = text5.split(".");
3606
+ text5 = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (fraction ? `.${fraction}` : "");
3607
+ }
3608
+ return text5 === "-0" ? "0" : text5;
3609
+ }
3610
+ var VISIO_FIELD_FORMATS = {
3611
+ shortDate: "{{M/d/yyyy}}",
3612
+ isoDate: "{{yyyy-MM-dd}}",
3613
+ longDate: "{{dddd, MMMM d, yyyy}}",
3614
+ time: "{{h:mm tt}}",
3615
+ dateTime: "{{M/d/yyyy h:mm tt}}",
3616
+ text: "@",
3617
+ integer: "0",
3618
+ decimal: "0.00",
3619
+ decimalUnits: "0.00 u",
3620
+ integerUnits: "0 u"
3621
+ };
3622
+ function formatVisioFieldValue(value, format4 = "") {
3623
+ const picture = format4.trim();
3624
+ if (value.kind === "string") return picture === "" || picture === "@" ? value.text : void 0;
3625
+ if (value.kind === "date") {
3626
+ const date2 = /^\{\{(.+)\}\}$/.exec(picture)?.[1] ?? (picture ? void 0 : "M/d/yyyy");
3627
+ return date2 === void 0 ? void 0 : formatDate(value.date, date2);
3628
+ }
3629
+ const units2 = / u$/.test(picture);
3630
+ const body = picture.replace(/ u$/, "");
3631
+ let number5 = value.value, suffix = "";
3632
+ if (value.unit === "angle") {
3633
+ number5 = number5 * 180 / Math.PI;
3634
+ suffix = " deg.";
3635
+ } else if (value.unit === "length") suffix = " in.";
3636
+ else if (value.unit !== "scalar") return void 0;
3637
+ const text5 = body === "" || body === "@" ? String(Number(number5.toFixed(4))) : formatNumber(Number(number5.toFixed(10)), body);
3638
+ if (text5 === void 0) return void 0;
3639
+ return units2 || body === "" ? `${text5}${suffix}` : text5;
3640
+ }
3641
+
3642
+ // visio/text-field-independent.ts
3643
+ function independentTextFieldFormula(cell, formula) {
3644
+ const row2 = cell.parentNode, section3 = row2?.parentNode;
3645
+ if (cell.localName !== "Cell" || row2?.localName !== "Row" || section3?.localName !== "Section" || attribute2(section3, "N") !== "Field" || row2.hasAttribute("Del") || section3.hasAttribute("Del") || row2.hasAttribute("N") || row2.hasAttribute("T") || !/^(0|[1-9]\d*)$/.test(attribute2(row2, "IX") ?? "0") || (attribute2(section3, "IX") ?? "0") !== "0" || cell.hasAttribute("E"))
3646
+ return false;
3647
+ if (attribute2(cell, "N") === "Format")
3648
+ return /^\s*FIELDPICTURE\(\s*(2|37|204)\s*\)\s*$/i.test(formula);
3649
+ if (attribute2(cell, "N") !== "Value") return false;
3650
+ if (/^\s*DATE\(\s*\d{1,4}\s*,\s*\d{1,2}\s*,\s*\d{1,2}\s*\)\s*$/i.test(formula)) return true;
3651
+ const direct = /^\s*([A-Z]+)\(\s*\)\s*$/i.exec(formula)?.[1]?.toUpperCase();
3652
+ return direct !== void 0 && VISIO_FIELD_FUNCTIONS.includes(direct);
3653
+ }
3654
+
3453
3655
  // visio/edit-connector-glue.ts
3454
3656
  var VISIO_WALK_GLUE = "_WALKGLUE(BegTrigger,EndTrigger,WalkPreference)";
3455
3657
  var walkGlue = /^\s*_WALKGLUE\((?:BegTrigger,EndTrigger|EndTrigger,BegTrigger),WalkPreference\)\s*$/i;
@@ -3559,7 +3761,7 @@ function indexCells(roots, options) {
3559
3761
  unit: cellUnit(cell, relative)
3560
3762
  };
3561
3763
  const source = attribute2(node2, "F");
3562
- if (executableCellFormula(source) && !inertDoubleClickFormula(cell, source) && !(glue2 && isNativeGlueCell(cell, source)) && // A trigger only counts events of the sheet it names; an unglued connector keeps one
3764
+ if (executableCellFormula(source) && !independentTextFieldFormula(node2, source) && !inertDoubleClickFormula(cell, source) && !(glue2 && isNativeGlueCell(cell, source)) && // A trigger only counts events of the sheet it names; an unglued connector keeps one
3563
3765
  // (Visio's freshly dropped connector names its own sheet).
3564
3766
  !(/^(BegTrigger|EndTrigger)$/.test(cell) && isNativeGlueCell(cell, source))) {
3565
3767
  try {
@@ -6776,6 +6978,77 @@ async function prepareImages(shapes, pkg, sourcePart, report, options, converter
6776
6978
  }
6777
6979
  }
6778
6980
 
6981
+ // visio/text-field-source.ts
6982
+ var proofs = /* @__PURE__ */ new WeakMap();
6983
+ function textFieldSourceKey(cells4) {
6984
+ if (proofs.has(cells4)) return proofs.get(cells4);
6985
+ if (cells4.size > 64) {
6986
+ proofs.set(cells4, void 0);
6987
+ return void 0;
6988
+ }
6989
+ const key2 = JSON.stringify(
6990
+ [...cells4].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([name3, cell]) => [
6991
+ name3,
6992
+ cell.value ?? null,
6993
+ cell.formula ?? null,
6994
+ cell.unit ?? null,
6995
+ cell.error ?? null
6996
+ ])
6997
+ );
6998
+ const bounded6 = key2.length <= 2048 ? key2 : void 0;
6999
+ proofs.set(cells4, bounded6);
7000
+ return bounded6;
7001
+ }
7002
+
7003
+ // visio/text-field-editability.ts
7004
+ function assertEditableFieldRow(existing) {
7005
+ for (const name3 of ["Calendar", "ObjectKind"]) {
7006
+ const cell = children2(existing, "Cell").find((cell2) => attribute2(cell2, "N") === name3);
7007
+ if (cell && (attribute2(cell, "V") !== "0" || cell.hasAttribute("F") || cell.hasAttribute("E")))
7008
+ fail(
7009
+ "UNSUPPORTED_TEXT_FIELD",
7010
+ "Nonstandard field calendar or object profiles cannot be edited."
7011
+ );
7012
+ }
7013
+ for (const cell of children2(existing, "Cell")) {
7014
+ const name3 = attribute2(cell, "N") ?? "";
7015
+ if (/^(value|format|type|calendar|objectkind)$/i.test(name3) && !["Value", "Format", "Type", "Calendar", "ObjectKind"].includes(name3))
7016
+ fail("UNSUPPORTED_TEXT_FIELD", "Noncanonical field cell names cannot be edited.");
7017
+ if (["Value", "Format", "Type"].includes(attribute2(cell, "N") ?? "") && (cell.hasAttribute("E") || /^\s*(Inh|GUARD\s*\()/i.test(attribute2(cell, "F") ?? "")))
7018
+ fail("UNSUPPORTED_TEXT_FIELD", "Protected or inherited field cells cannot be edited.");
7019
+ }
7020
+ }
7021
+ function assertEditableFieldShape(shape) {
7022
+ if (shape.localName !== "Shape" || shape.parentNode?.parentNode?.localName !== "PageContents" || shape.hasAttribute("Master") || shape.hasAttribute("MasterShape") || attribute2(shape, "Type") === "Group" || ["Shapes", "ForeignData", "Rel"].some((name3) => children2(shape, name3).length))
7023
+ fail("UNSUPPORTED_TEXT_FIELD", "Existing field edits require a top-level plain local shape.");
7024
+ }
7025
+ function editableTextFieldIndices(text5, allowed) {
7026
+ const result = /* @__PURE__ */ new Set();
7027
+ if (!allowed || !text5) return result;
7028
+ const shape = text5.parentNode;
7029
+ try {
7030
+ assertEditableFieldShape(shape);
7031
+ assertFormattingText(shape);
7032
+ const rows = formattingRows(shape, "Field");
7033
+ const markers = children2(text5, "fld");
7034
+ const counts = /* @__PURE__ */ new Map();
7035
+ for (const marker2 of markers) {
7036
+ const index = attribute2(marker2, "IX");
7037
+ counts.set(index, (counts.get(index) ?? 0) + 1);
7038
+ }
7039
+ for (const [index, row2] of rows) {
7040
+ if (counts.get(index) !== 1 || textFieldSourceKey(readCells(row2)) === void 0) continue;
7041
+ try {
7042
+ assertEditableFieldRow(row2);
7043
+ result.add(index);
7044
+ } catch {
7045
+ }
7046
+ }
7047
+ } catch {
7048
+ }
7049
+ return result;
7050
+ }
7051
+
6779
7052
  // geometry/svg-path-curves.ts
6780
7053
  function sampleCubic(p0, p1, p2, p3, segments, out) {
6781
7054
  for (let i = 1; i <= segments; i++) {
@@ -8875,195 +9148,6 @@ function visioFieldCase(text5, upper) {
8875
9148
  }).join("");
8876
9149
  }
8877
9150
 
8878
- // visio/text-fields.ts
8879
- var PROPERTY_FUNCTIONS = {
8880
- TITLE: "title",
8881
- SUBJECT: "subject",
8882
- CREATOR: "creator",
8883
- KEYWORDS: "keywords",
8884
- DESCRIPTION: "description",
8885
- CATEGORY: "category",
8886
- COMPANY: "company",
8887
- MANAGER: "manager"
8888
- };
8889
- var DATE_FUNCTIONS = {
8890
- NOW: void 0,
8891
- DOCCREATION: "created",
8892
- DOCLASTSAVE: "modified",
8893
- DOCLASTEDIT: "modified",
8894
- DOCLASTPRINT: "lastPrinted"
8895
- };
8896
- var VISIO_FIELD_FUNCTIONS = [
8897
- ...Object.keys(PROPERTY_FUNCTIONS),
8898
- ...Object.keys(DATE_FUNCTIONS),
8899
- "PAGENAME"
8900
- ];
8901
- function visioWallClock(date2) {
8902
- return new Date(
8903
- Date.UTC(
8904
- date2.getFullYear(),
8905
- date2.getMonth(),
8906
- date2.getDate(),
8907
- date2.getHours(),
8908
- date2.getMinutes(),
8909
- date2.getSeconds()
8910
- )
8911
- );
8912
- }
8913
- var EPOCH = Date.UTC(1899, 11, 30);
8914
- var visioSerialDate = (serial) => Number.isFinite(serial) && Math.abs(serial) < 3e6 ? new Date(EPOCH + Math.round(serial * 864e5)) : void 0;
8915
- function evaluateVisioTextField(formula, context) {
8916
- let ast;
8917
- try {
8918
- ast = parseVisioFormula(formula, { maxLength: 4096 });
8919
- } catch {
8920
- return void 0;
8921
- }
8922
- if (ast.kind === "call") {
8923
- const name3 = ast.name;
8924
- if (Object.hasOwn(PROPERTY_FUNCTIONS, name3) && !ast.args.length) {
8925
- const value = context.properties?.[PROPERTY_FUNCTIONS[name3]];
8926
- return value === void 0 ? void 0 : { kind: "string", text: value };
8927
- }
8928
- if (Object.hasOwn(DATE_FUNCTIONS, name3) && !ast.args.length) {
8929
- if (name3 === "NOW") return context.now ? { kind: "date", date: context.now } : void 0;
8930
- const stamp = context.properties?.[DATE_FUNCTIONS[name3]];
8931
- const time = stamp ? Date.parse(stamp) : Number.NaN;
8932
- return Number.isFinite(time) ? { kind: "date", date: visioWallClock(new Date(time)) } : void 0;
8933
- }
8934
- if (name3 === "PAGENAME" && ast.args.length <= 1)
8935
- return context.pageName === void 0 ? void 0 : { kind: "string", text: context.pageName };
8936
- }
8937
- try {
8938
- const result = evaluateVisioFormula(
8939
- ast,
8940
- context.resolve ?? (() => {
8941
- throw new Error("No cell context");
8942
- }),
8943
- {
8944
- ...context.pageNumber === void 0 ? {} : { pageNumber: context.pageNumber },
8945
- ...context.pageCount === void 0 ? {} : { pageCount: context.pageCount }
8946
- }
8947
- );
8948
- return { kind: "number", value: result.value, unit: result.unit };
8949
- } catch {
8950
- return void 0;
8951
- }
8952
- }
8953
- var MONTHS = [
8954
- "January",
8955
- "February",
8956
- "March",
8957
- "April",
8958
- "May",
8959
- "June",
8960
- "July",
8961
- "August",
8962
- "September",
8963
- "October",
8964
- "November",
8965
- "December"
8966
- ];
8967
- var DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
8968
- var pad = (value, length = 2) => String(value).padStart(length, "0");
8969
- function dateToken(date2, token) {
8970
- const hours = date2.getUTCHours();
8971
- switch (token) {
8972
- case "yyyy":
8973
- return pad(date2.getUTCFullYear(), 4);
8974
- case "yy":
8975
- return pad(date2.getUTCFullYear() % 100);
8976
- case "MMMM":
8977
- return MONTHS[date2.getUTCMonth()];
8978
- case "MMM":
8979
- return MONTHS[date2.getUTCMonth()].slice(0, 3);
8980
- case "MM":
8981
- return pad(date2.getUTCMonth() + 1);
8982
- case "M":
8983
- return String(date2.getUTCMonth() + 1);
8984
- case "dddd":
8985
- return DAYS[date2.getUTCDay()];
8986
- case "ddd":
8987
- return DAYS[date2.getUTCDay()].slice(0, 3);
8988
- case "dd":
8989
- return pad(date2.getUTCDate());
8990
- case "d":
8991
- return String(date2.getUTCDate());
8992
- case "HH":
8993
- return pad(hours);
8994
- case "H":
8995
- return String(hours);
8996
- case "hh":
8997
- return pad(hours % 12 || 12);
8998
- case "h":
8999
- return String(hours % 12 || 12);
9000
- case "mm":
9001
- return pad(date2.getUTCMinutes());
9002
- case "ss":
9003
- return pad(date2.getUTCSeconds());
9004
- case "tt":
9005
- return hours < 12 ? "AM" : "PM";
9006
- default:
9007
- return void 0;
9008
- }
9009
- }
9010
- function formatDate(date2, picture) {
9011
- return picture.replace(
9012
- /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|tt|"[^"]*"/g,
9013
- (token) => {
9014
- if (token.startsWith('"')) return token.slice(1, -1);
9015
- return dateToken(date2, token) ?? token;
9016
- }
9017
- );
9018
- }
9019
- function formatNumber(value, picture) {
9020
- const match = /^(#,##)?0(?:\.(0+|#+))?$/.exec(picture);
9021
- if (!match) return void 0;
9022
- const decimals = match[2]?.length ?? 0;
9023
- const optional = match[2]?.startsWith("#") ?? false;
9024
- const [coefficient, exponent = "0"] = Math.abs(value).toString().split("e");
9025
- const shifted = Number(coefficient + "e" + (Number(exponent) + decimals));
9026
- const rounded = Math.floor(shifted + 0.5) / 10 ** decimals;
9027
- let text5 = (Math.sign(value) * rounded).toFixed(decimals);
9028
- if (optional && text5.includes(".")) text5 = text5.replace(/\.?0+$/, "");
9029
- if (match[1]) {
9030
- const [whole, fraction] = text5.split(".");
9031
- text5 = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (fraction ? `.${fraction}` : "");
9032
- }
9033
- return text5 === "-0" ? "0" : text5;
9034
- }
9035
- var VISIO_FIELD_FORMATS = {
9036
- shortDate: "{{M/d/yyyy}}",
9037
- isoDate: "{{yyyy-MM-dd}}",
9038
- longDate: "{{dddd, MMMM d, yyyy}}",
9039
- time: "{{h:mm tt}}",
9040
- dateTime: "{{M/d/yyyy h:mm tt}}",
9041
- text: "@",
9042
- integer: "0",
9043
- decimal: "0.00",
9044
- decimalUnits: "0.00 u",
9045
- integerUnits: "0 u"
9046
- };
9047
- function formatVisioFieldValue(value, format4 = "") {
9048
- const picture = format4.trim();
9049
- if (value.kind === "string") return picture === "" || picture === "@" ? value.text : void 0;
9050
- if (value.kind === "date") {
9051
- const date2 = /^\{\{(.+)\}\}$/.exec(picture)?.[1] ?? (picture ? void 0 : "M/d/yyyy");
9052
- return date2 === void 0 ? void 0 : formatDate(value.date, date2);
9053
- }
9054
- const units2 = / u$/.test(picture);
9055
- const body = picture.replace(/ u$/, "");
9056
- let number5 = value.value, suffix = "";
9057
- if (value.unit === "angle") {
9058
- number5 = number5 * 180 / Math.PI;
9059
- suffix = " deg.";
9060
- } else if (value.unit === "length") suffix = " in.";
9061
- else if (value.unit !== "scalar") return void 0;
9062
- const text5 = body === "" || body === "@" ? String(Number(number5.toFixed(4))) : formatNumber(Number(number5.toFixed(10)), body);
9063
- if (text5 === void 0) return void 0;
9064
- return units2 || body === "" ? `${text5}${suffix}` : text5;
9065
- }
9066
-
9067
9151
  // visio/text-field-fraction.ts
9068
9152
  function fractionalFieldNumber(value, maxDenominator) {
9069
9153
  if (!Number.isFinite(value) || Math.abs(value) > 1e15) return void 0;
@@ -9220,7 +9304,12 @@ function textFieldDisplay(element2, sheet, context) {
9220
9304
  const row2 = sectionRows(sheet, "Field").find((candidate) => candidate.index === index);
9221
9305
  const value = row2?.cells.get("Value"), format4 = row2?.cells.get("Format");
9222
9306
  const formula = value?.formula && value.formula !== "Inh" ? value.formula : void 0;
9223
- const result = { cached: cached5, ...formula ? { formula } : {} };
9307
+ const sourceKey = row2 ? textFieldSourceKey(row2.cells) : void 0;
9308
+ const result = {
9309
+ cached: cached5,
9310
+ ...formula ? { formula } : {},
9311
+ ...sourceKey !== void 0 ? { index, format: format4?.value ?? "", sourceKey } : {}
9312
+ };
9224
9313
  if (!row2 || !context) return { text: cached5, ...result };
9225
9314
  const picture = format4?.value ?? "";
9226
9315
  const evaluated = formula ? evaluateVisioTextField(formula, context) : void 0;
@@ -10094,7 +10183,8 @@ function runStyle(cells4, resources, report, themeCells) {
10094
10183
  ...characterExtras(cells4, report)
10095
10184
  };
10096
10185
  }
10097
- function shapeText(sheet, node2, width, height, resources, report, consume, consumeParagraph) {
10186
+ function shapeText(sheet, node2, width, height, resources, report, consume, consumeParagraph, allowFieldEditing = false) {
10187
+ const editableFields = editableTextFieldIndices(node2, allowFieldEditing);
10098
10188
  const cells4 = sheet.cells;
10099
10189
  const characters = new Map(sectionRows(sheet, "Character").map((row2) => [row2.index, row2.cells]));
10100
10190
  const defaultCells = characters.get("0") ?? /* @__PURE__ */ new Map();
@@ -10129,7 +10219,9 @@ function shapeText(sheet, node2, width, height, resources, report, consume, cons
10129
10219
  start: textOffset,
10130
10220
  end: textOffset + field2.text.length,
10131
10221
  cached: field2.cached,
10132
- ...field2.formula ? { formula: field2.formula } : {}
10222
+ ...field2.index !== void 0 && editableFields.has(field2.index) ? { editable: true } : {},
10223
+ ...field2.formula ? { formula: field2.formula } : {},
10224
+ ...field2.index === void 0 ? {} : { index: field2.index, format: field2.format, sourceKey: field2.sourceKey }
10133
10225
  });
10134
10226
  append(field2.text);
10135
10227
  } else if (element2.localName !== "pp" && element2.localName !== "tp") {
@@ -11408,7 +11500,8 @@ function normalizeShapes(raw, context, depth = 0, masterStack = []) {
11408
11500
  context.resources,
11409
11501
  report,
11410
11502
  context.consumeText,
11411
- context.consumeParagraph
11503
+ context.consumeParagraph,
11504
+ depth === 0 && masterId === void 0 && !sheet.cells.get("LockTextEdit")?.error && !sheet.cells.get("LockTextEdit")?.formula && number(sheet.cells, "LockTextEdit", 0, report) === 0
11412
11505
  ),
11413
11506
  hidden: membership.hidden || type === "Guide" || number(sheet.cells, "NoShow", 0, report) !== 0,
11414
11507
  visibility: {
@@ -22051,6 +22144,7 @@ async function assertFormattingDependencies(pkg, pagePaths, roots, pageId2, shap
22051
22144
  continue;
22052
22145
  const source = executableCellFormula(attribute2(node2, "F"));
22053
22146
  if (!source || inertDoubleClickFormula(attribute2(node2, "N") ?? "", source)) continue;
22147
+ if (independentTextFieldFormula(node2, source)) continue;
22054
22148
  if (attribute2(node2, "V") === "Themed" && isThemeLookupFormula(source)) continue;
22055
22149
  if (isConnectedGlueCell(node2, source)) continue;
22056
22150
  const owner = node2.parentNode;
@@ -26961,9 +27055,23 @@ async function insertVisioTextField(pkg, pagePaths, roots, document, edit, check
26961
27055
  effectiveFormattingRows(shape, document, "Paragraph")
26962
27056
  );
26963
27057
  const rows = formattingRows(shape, "Field");
26964
- const point2 = insertionPoint(text5, edit.offset);
26965
- if (edit.offset !== void 0 && point2.logical !== edit.expectedText)
27058
+ const updating = edit.type === "update-text-field";
27059
+ if (updating) assertEditableFieldShape(shape);
27060
+ const point2 = insertionPoint(text5, updating ? void 0 : edit.offset);
27061
+ if ((updating || edit.offset !== void 0) && point2.logical !== edit.expectedText)
26966
27062
  fail("EDIT_STALE_TEXT", "The shape text changed since the field position was chosen.");
27063
+ const existing = updating ? rows.get(edit.fieldIndex) : void 0;
27064
+ const markers = updating ? children2(text5, "fld").filter((field3) => attribute2(field3, "IX") === edit.fieldIndex) : [];
27065
+ if (updating) {
27066
+ if (!existing || markers.length !== 1)
27067
+ fail(
27068
+ "UNSUPPORTED_TEXT_FIELD",
27069
+ "Existing fields require one live local row and unique text marker."
27070
+ );
27071
+ if (markers[0].textContent !== edit.expectedCached || textFieldSourceKey(readCells(existing)) !== edit.expectedSourceKey)
27072
+ fail("EDIT_STALE_TEXT", "The field source changed since it was selected.");
27073
+ assertEditableFieldRow(existing);
27074
+ }
26967
27075
  const context = { ...await pageContext(pkg, edit.pageId), resolve: shapeResolver(shape) };
26968
27076
  let value;
26969
27077
  try {
@@ -26976,9 +27084,19 @@ async function insertVisioTextField(pkg, pagePaths, roots, document, edit, check
26976
27084
  "UNSUPPORTED_TEXT_FIELD",
26977
27085
  `This editor cannot evaluate the field formula. Supported: ${VISIO_FIELD_FUNCTIONS.join(", ")}, PAGENUMBER, PAGECOUNT and numeric formulas on this shape.`
26978
27086
  );
26979
- const display = formatVisioFieldValue(value, edit.format ?? "");
27087
+ const format4 = edit.format ?? "";
27088
+ const display = formatVisioFieldValue(value, format4);
26980
27089
  if (display === void 0)
26981
27090
  fail("UNSUPPORTED_TEXT_FIELD", "The field format does not suit the field value.");
27091
+ const prepared = valueCell(value);
27092
+ if (existing && markers[0].textContent === display) {
27093
+ const same5 = (name3, v, u, f) => {
27094
+ const cell2 = children2(existing, "Cell").find((cell3) => attribute2(cell3, "N") === name3);
27095
+ return attribute2(cell2, "V") === v && attribute2(cell2, "U") === u && attribute2(cell2, "F") === f;
27096
+ };
27097
+ if (same5("Value", prepared.v, prepared.u, edit.formula) && same5("Format", format4, "STR", `"${format4.replaceAll('"', '""')}"`) && same5("Type", String(prepared.type), void 0, void 0))
27098
+ return false;
27099
+ }
26982
27100
  if (texts[0])
26983
27101
  await assertFormattingDependencies(
26984
27102
  pkg,
@@ -26986,32 +27104,49 @@ async function insertVisioTextField(pkg, pagePaths, roots, document, edit, check
26986
27104
  roots,
26987
27105
  edit.pageId,
26988
27106
  shape,
26989
- /* @__PURE__ */ new Map([["TheText", text5]]),
27107
+ new Map([
27108
+ ["TheText", text5],
27109
+ ...existing ? ["Value", "Format", "Type"].flatMap((name3) => {
27110
+ const cell2 = children2(existing, "Cell").find((cell3) => attribute2(cell3, "N") === name3);
27111
+ return [
27112
+ [`Field.${updating ? edit.fieldIndex : ""}.${name3}`, cell2],
27113
+ [`Fields.${name3}`, cell2]
27114
+ ];
27115
+ }) : []
27116
+ ]),
26990
27117
  check
26991
27118
  );
26992
27119
  check();
26993
- const index = String(rows.size ? Math.max(...[...rows.keys()].map(Number)) + 1 : 0);
27120
+ const index = updating ? edit.fieldIndex : String(rows.size ? Math.max(...[...rows.keys()].map(Number)) + 1 : 0);
26994
27121
  let section3 = children2(shape, "Section").find((node2) => attribute2(node2, "N") === "Field");
26995
27122
  if (!section3) {
26996
27123
  section3 = owner.createElementNS(ns, "Section");
26997
27124
  section3.setAttribute("N", "Field");
26998
27125
  shape.insertBefore(section3, texts[0] ?? null);
26999
27126
  }
27000
- const row2 = owner.createElementNS(ns, "Row");
27001
- row2.setAttribute("IX", index);
27127
+ const row2 = existing ?? owner.createElementNS(ns, "Row");
27128
+ if (!existing) row2.setAttribute("IX", index);
27002
27129
  const cell = (name3, v, extra = {}) => {
27003
- const node2 = owner.createElementNS(ns, "Cell");
27130
+ const node2 = children2(row2, "Cell").find((cell2) => attribute2(cell2, "N") === name3) ?? owner.createElementNS(ns, "Cell");
27004
27131
  node2.setAttribute("N", name3);
27005
27132
  node2.setAttribute("V", v);
27133
+ if (updating) {
27134
+ node2.removeAttribute("U");
27135
+ node2.removeAttribute("F");
27136
+ }
27006
27137
  for (const [key2, item] of Object.entries(extra)) node2.setAttribute(key2, item);
27007
- row2.appendChild(node2);
27138
+ if (!node2.parentNode) row2.appendChild(node2);
27008
27139
  };
27009
- const stored = valueCell(value);
27140
+ const stored = prepared;
27010
27141
  cell("Value", stored.v, { ...stored.u ? { U: stored.u } : {}, F: edit.formula });
27011
- if (edit.format)
27012
- cell("Format", edit.format, { U: "STR", F: `"${edit.format.replaceAll('"', '""')}"` });
27142
+ if (format4 || updating)
27143
+ cell("Format", format4, { U: "STR", F: `"${format4.replaceAll('"', '""')}"` });
27013
27144
  cell("Type", String(stored.type));
27014
- section3.appendChild(row2);
27145
+ if (!row2.parentNode) section3.appendChild(row2);
27146
+ if (updating) {
27147
+ markers[0].textContent = display;
27148
+ return true;
27149
+ }
27015
27150
  const field2 = owner.createElementNS(ns, "fld");
27016
27151
  field2.setAttribute("IX", index);
27017
27152
  field2.appendChild(owner.createTextNode(display));
@@ -29409,6 +29544,35 @@ function snapshotGuideEdit(edit) {
29409
29544
  }
29410
29545
 
29411
29546
  // visio/edit-text-field-commands.ts
29547
+ function snapshotTextFieldUpdate(edit) {
29548
+ const insert = snapshotTextFieldInsert({
29549
+ pageId: edit.pageId,
29550
+ shapeId: edit.shapeId,
29551
+ formula: edit.formula,
29552
+ ...edit.format === void 0 ? {} : { format: edit.format }
29553
+ });
29554
+ if (analyzeVisioFormula(parseVisioFormula(insert.formula)).references.some(
29555
+ (ref) => /^fields?\./i.test(ref.cell)
29556
+ ))
29557
+ fail("UNSUPPORTED_TEXT_FIELD", "Existing field formulas cannot reference Field rows.");
29558
+ if (typeof edit.fieldIndex !== "string" || !/^(0|[1-9]\d{0,9})$/.test(edit.fieldIndex) || Number(edit.fieldIndex) > 4294967295)
29559
+ fail("INVALID_EDIT", "An existing field needs a canonical row index.");
29560
+ if ([edit.expectedText, edit.expectedCached, edit.expectedSourceKey].some(
29561
+ (value) => typeof value !== "string" || value.length > 1e6
29562
+ ) || !edit.expectedSourceKey)
29563
+ fail("INVALID_EDIT", "An existing field needs its source text and row identity.");
29564
+ return {
29565
+ type: "update-text-field",
29566
+ pageId: insert.pageId,
29567
+ shapeId: insert.shapeId,
29568
+ fieldIndex: edit.fieldIndex,
29569
+ formula: insert.formula,
29570
+ format: insert.format,
29571
+ expectedText: edit.expectedText,
29572
+ expectedCached: edit.expectedCached,
29573
+ expectedSourceKey: edit.expectedSourceKey
29574
+ };
29575
+ }
29412
29576
  function snapshotTextFieldInsert(edit) {
29413
29577
  const { pageId: pageId2, shapeId: shapeId2 } = edit;
29414
29578
  if ([pageId2, shapeId2].some((id3) => typeof id3 !== "string" || !id3 || id3.length > 256))
@@ -30162,6 +30326,14 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
30162
30326
  return { ...target2, type: edit.type, text: text5(edit.text) };
30163
30327
  if (edit.type === "replace-text-ranges") return snapshotTextRanges(edit, text5);
30164
30328
  if (edit.type === "insert-text-field") return snapshotTextFieldInsert(edit);
30329
+ if (edit.type === "update-text-field") {
30330
+ const update = snapshotTextFieldUpdate(edit);
30331
+ update.formula = text5(update.formula);
30332
+ update.expectedText = text5(update.expectedText);
30333
+ update.expectedCached = text5(update.expectedCached);
30334
+ update.expectedSourceKey = text5(update.expectedSourceKey);
30335
+ return update;
30336
+ }
30165
30337
  if (isVisioFormatEdit(edit)) return snapshotFormatting(edit);
30166
30338
  if (edit.type === "reorder-shape") {
30167
30339
  if (!["front", "back", "forward", "backward"].includes(edit.order))
@@ -35589,7 +35761,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
35589
35761
  const dirty = /* @__PURE__ */ new Map();
35590
35762
  const roots = /* @__PURE__ */ new Map();
35591
35763
  const geometryCommands = commands.filter(
35592
- (command2) => command2.type !== "replace-plain-text" && command2.type !== "replace-text-ranges" && command2.type !== "insert-text-field" && command2.type !== "reorder-shape" && command2.type !== "duplicate-shapes" && command2.type !== "paste-shapes" && command2.type !== "change-shape" && command2.type !== "insert-picture" && command2.type !== "set-page-theme" && !isVisioMetadataEdit(command2) && command2.type !== "set-shape-data" && !isVisioGroupEdit(command2) && !isVisioDiagramPartEdit(command2) && !isVisioGuideEdit(command2) && !isVisioFormatEdit(command2)
35764
+ (command2) => command2.type !== "replace-plain-text" && command2.type !== "replace-text-ranges" && command2.type !== "insert-text-field" && command2.type !== "update-text-field" && command2.type !== "reorder-shape" && command2.type !== "duplicate-shapes" && command2.type !== "paste-shapes" && command2.type !== "change-shape" && command2.type !== "insert-picture" && command2.type !== "set-page-theme" && !isVisioMetadataEdit(command2) && command2.type !== "set-shape-data" && !isVisioGroupEdit(command2) && !isVisioDiagramPartEdit(command2) && !isVisioGuideEdit(command2) && !isVisioFormatEdit(command2)
35593
35765
  );
35594
35766
  let document;
35595
35767
  let masterMovePins = emptyMasterMoveProof();
@@ -35597,7 +35769,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
35597
35769
  let instanceDeletes = /* @__PURE__ */ new Set();
35598
35770
  let groupMembers = /* @__PURE__ */ new Map();
35599
35771
  if (geometryCommands.length || commands.some(
35600
- (command2) => command2.type === "replace-plain-text" || command2.type === "replace-text-ranges" || command2.type === "insert-text-field" || isVisioFormatEdit(command2) || isVisioMetadataEdit(command2) || command2.type === "set-shape-data" || command2.type === "reorder-shape" || command2.type === "duplicate-shapes" || command2.type === "paste-shapes" || command2.type === "change-shape" || isVisioGroupEdit(command2) || isVisioDiagramPartEdit(command2) || isVisioGuideEdit(command2)
35772
+ (command2) => command2.type === "replace-plain-text" || command2.type === "replace-text-ranges" || command2.type === "insert-text-field" || command2.type === "update-text-field" || isVisioFormatEdit(command2) || isVisioMetadataEdit(command2) || command2.type === "set-shape-data" || command2.type === "reorder-shape" || command2.type === "duplicate-shapes" || command2.type === "paste-shapes" || command2.type === "change-shape" || isVisioGroupEdit(command2) || isVisioDiagramPartEdit(command2) || isVisioGuideEdit(command2)
35601
35773
  )) {
35602
35774
  for (const [pageId2, path2] of pages) {
35603
35775
  const sourceRoot = await visioXml(pkg, path2, "PageContents");
@@ -35708,7 +35880,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
35708
35880
  textChanged = true;
35709
35881
  await noteTextSize(command2, root2);
35710
35882
  }
35711
- } else if (command2.type === "insert-text-field") {
35883
+ } else if (command2.type === "insert-text-field" || command2.type === "update-text-field") {
35712
35884
  if (await insertVisioTextField(pkg, new Set(pages.values()), roots, document, command2, check)) {
35713
35885
  dirty.set(path, root2);
35714
35886
  textChanged = true;