ooxml-core 1.10.0 → 1.12.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 (205) 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 +3504 -2888
  5. package/dist/automation/index.mjs +3504 -2888
  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/embedded.cjs +1 -1
  24. package/dist/docx/embedded.mjs +1 -1
  25. package/dist/docx/index.cjs +1 -1
  26. package/dist/docx/index.mjs +1 -1
  27. package/dist/docx/layout/adapt-table.d.ts.map +1 -1
  28. package/dist/docx/layout/flow-table.d.ts.map +1 -1
  29. package/dist/docx/layout/index.cjs +266 -61
  30. package/dist/docx/layout/index.d.ts +1 -0
  31. package/dist/docx/layout/index.d.ts.map +1 -1
  32. package/dist/docx/layout/index.mjs +266 -62
  33. package/dist/docx/layout/input.d.ts +5 -0
  34. package/dist/docx/layout/input.d.ts.map +1 -1
  35. package/dist/docx/layout/layout-session.d.ts +10 -0
  36. package/dist/docx/layout/layout-session.d.ts.map +1 -0
  37. package/dist/docx/layout/nested-fragment-edges.d.ts +9 -0
  38. package/dist/docx/layout/nested-fragment-edges.d.ts.map +1 -0
  39. package/dist/docx/layout/paragraph-cache.d.ts +8 -0
  40. package/dist/docx/layout/paragraph-cache.d.ts.map +1 -0
  41. package/dist/docx/layout/paragraph-layout.d.ts.map +1 -1
  42. package/dist/docx/layout/paragraph-tokens.d.ts +1 -1
  43. package/dist/docx/layout/paragraph-tokens.d.ts.map +1 -1
  44. package/dist/docx/layout/result.d.ts +7 -0
  45. package/dist/docx/layout/result.d.ts.map +1 -1
  46. package/dist/docx/layout/table-border-layout.d.ts +1 -1
  47. package/dist/docx/layout/table-border-layout.d.ts.map +1 -1
  48. package/dist/docx/layout/table-cell-layout.d.ts +1 -1
  49. package/dist/docx/layout/table-cell-layout.d.ts.map +1 -1
  50. package/dist/docx/layout/table-frames.d.ts.map +1 -1
  51. package/dist/docx/layout/table-layout.d.ts +1 -1
  52. package/dist/docx/layout/table-layout.d.ts.map +1 -1
  53. package/dist/docx/layout/table-paragraph-keeps.d.ts +14 -0
  54. package/dist/docx/layout/table-paragraph-keeps.d.ts.map +1 -0
  55. package/dist/docx/load/index.cjs +1 -1
  56. package/dist/docx/load/index.mjs +1 -1
  57. package/dist/docx/ui/index.cjs +83 -6
  58. package/dist/docx/ui/index.mjs +83 -7
  59. package/dist/docx/ui/ribbon-action-ids.d.ts +1 -1
  60. package/dist/docx/ui/ribbon-action-ids.d.ts.map +1 -1
  61. package/dist/docx/ui/word-count.d.ts +3 -0
  62. package/dist/docx/ui/word-count.d.ts.map +1 -1
  63. package/dist/geometry/element-transform.d.ts +90 -0
  64. package/dist/geometry/element-transform.d.ts.map +1 -0
  65. package/dist/geometry/index.cjs +90 -0
  66. package/dist/geometry/index.d.ts +1 -0
  67. package/dist/geometry/index.d.ts.map +1 -1
  68. package/dist/geometry/index.mjs +83 -1
  69. package/dist/index.cjs +90 -0
  70. package/dist/index.mjs +90 -0
  71. package/dist/pptx/automation/index.cjs +266 -114
  72. package/dist/pptx/automation/index.d.ts +5 -4
  73. package/dist/pptx/automation/index.d.ts.map +1 -1
  74. package/dist/pptx/automation/index.mjs +5 -5
  75. package/dist/pptx/chunks/{text-operations-BqHmLaLA.d.ts → elements-DD3UGOMd.d.ts} +17 -3262
  76. package/dist/pptx/chunks/elements-DD3UGOMd.d.ts.map +1 -0
  77. package/dist/pptx/chunks/{index-DUCGeZh7.d.ts → index-BZrFyNtU.d.ts} +53 -5
  78. package/dist/pptx/chunks/index-BZrFyNtU.d.ts.map +1 -0
  79. package/dist/pptx/chunks/{index-Cuxtr76Y.d.ts → index-DdX02BSm.d.ts} +5 -3
  80. package/dist/pptx/chunks/index-DdX02BSm.d.ts.map +1 -0
  81. package/dist/pptx/chunks/smart-art-ENMMEbmW.d.ts +1512 -0
  82. package/dist/pptx/chunks/smart-art-ENMMEbmW.d.ts.map +1 -0
  83. package/dist/pptx/chunks/text-D49FKllA.d.ts +1473 -0
  84. package/dist/pptx/chunks/text-D49FKllA.d.ts.map +1 -0
  85. package/dist/pptx/chunks/text-operations-CyMTMfID.d.ts +3261 -0
  86. package/dist/pptx/chunks/text-operations-CyMTMfID.d.ts.map +1 -0
  87. package/dist/pptx/cli/index.cjs +266 -114
  88. package/dist/pptx/cli/index.d.ts +1 -1
  89. package/dist/pptx/cli/index.mjs +4 -4
  90. package/dist/pptx/converter/index.d.ts +1 -1
  91. package/dist/pptx/converter/index.mjs +2 -2
  92. package/dist/pptx/editor/render/find-replace.cjs +17 -16
  93. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  94. package/dist/pptx/editor/render/find-replace.mjs +2 -1
  95. package/dist/pptx/editor/render/font-family-update.cjs +14 -0
  96. package/dist/pptx/editor/render/font-family-update.d.ts +17 -0
  97. package/dist/pptx/editor/render/font-family-update.d.ts.map +1 -0
  98. package/dist/pptx/editor/render/font-family-update.mjs +1 -0
  99. package/dist/pptx/editor/render/paragraph-geometry-overrides.cjs +14 -0
  100. package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts +17 -0
  101. package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts.map +1 -0
  102. package/dist/pptx/editor/render/paragraph-geometry-overrides.mjs +12 -0
  103. package/dist/pptx/editor/render/slide-operations.cjs +9 -8
  104. package/dist/pptx/editor/render/slide-operations.mjs +3 -2
  105. package/dist/pptx/editor/render/table-data-grid-ops.cjs +1 -1
  106. package/dist/pptx/editor/render/table-data-grid-ops.mjs +1 -1
  107. package/dist/pptx/editor/render/text-content-style.cjs +18 -0
  108. package/dist/pptx/editor/render/text-content-style.d.ts +9 -0
  109. package/dist/pptx/editor/render/text-content-style.d.ts.map +1 -0
  110. package/dist/pptx/editor/render/text-content-style.mjs +5 -0
  111. package/dist/pptx/editor/render/text-runs-style-patch.cjs +17 -0
  112. package/dist/pptx/editor/render/text-runs-style-patch.d.ts +7 -0
  113. package/dist/pptx/editor/render/text-runs-style-patch.d.ts.map +1 -0
  114. package/dist/pptx/editor/render/text-runs-style-patch.mjs +15 -0
  115. package/dist/pptx/editor/render/text-style-scope.cjs +173 -0
  116. package/dist/pptx/editor/render/text-style-scope.d.ts +76 -0
  117. package/dist/pptx/editor/render/text-style-scope.d.ts.map +1 -0
  118. package/dist/pptx/editor/render/text-style-scope.mjs +164 -0
  119. package/dist/pptx/editor/render/theme-editor-model.cjs +1 -1
  120. package/dist/pptx/editor/render/theme-editor-model.mjs +1 -1
  121. package/dist/pptx/editor/render/update-text-segment-style.cjs +11 -0
  122. package/dist/pptx/editor/render/update-text-segment-style.d.ts +14 -0
  123. package/dist/pptx/editor/render/update-text-segment-style.d.ts.map +1 -0
  124. package/dist/pptx/editor/render/update-text-segment-style.mjs +2 -0
  125. package/dist/pptx/index.cjs +329 -114
  126. package/dist/pptx/index.d.ts +7 -5
  127. package/dist/pptx/index.mjs +5 -5
  128. package/dist/pptx/smartart-layouts/index.d.ts +1 -1
  129. package/dist/teams/index.cjs +112 -16
  130. package/dist/teams/index.mjs +112 -16
  131. package/dist/visio/edit-commands.d.ts +3 -3
  132. package/dist/visio/edit-commands.d.ts.map +1 -1
  133. package/dist/visio/edit-formatting-scope.d.ts.map +1 -1
  134. package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
  135. package/dist/visio/edit-text-field-commands.d.ts +15 -0
  136. package/dist/visio/edit-text-field-commands.d.ts.map +1 -1
  137. package/dist/visio/edit-text-field.d.ts +2 -2
  138. package/dist/visio/edit-text-field.d.ts.map +1 -1
  139. package/dist/visio/edit.d.ts +1 -1
  140. package/dist/visio/edit.d.ts.map +1 -1
  141. package/dist/visio/index.cjs +696 -249
  142. package/dist/visio/index.d.ts +2 -1
  143. package/dist/visio/index.d.ts.map +1 -1
  144. package/dist/visio/index.mjs +695 -250
  145. package/dist/visio/model.d.ts +18 -0
  146. package/dist/visio/model.d.ts.map +1 -1
  147. package/dist/visio/paper-sizes.d.ts +5 -0
  148. package/dist/visio/paper-sizes.d.ts.map +1 -1
  149. package/dist/visio/parser.d.ts.map +1 -1
  150. package/dist/visio/print-count.d.ts +20 -0
  151. package/dist/visio/print-count.d.ts.map +1 -0
  152. package/dist/visio/print-settings.d.ts +14 -0
  153. package/dist/visio/print-settings.d.ts.map +1 -0
  154. package/dist/visio/shapes.d.ts.map +1 -1
  155. package/dist/visio/style.d.ts +1 -1
  156. package/dist/visio/style.d.ts.map +1 -1
  157. package/dist/visio/text-field-display.d.ts +3 -0
  158. package/dist/visio/text-field-display.d.ts.map +1 -1
  159. package/dist/visio/text-field-editability.d.ts +6 -0
  160. package/dist/visio/text-field-editability.d.ts.map +1 -0
  161. package/dist/visio/text-field-independent.d.ts +4 -0
  162. package/dist/visio/text-field-independent.d.ts.map +1 -0
  163. package/dist/visio/text-field-source.d.ts +6 -0
  164. package/dist/visio/text-field-source.d.ts.map +1 -0
  165. package/dist/visio/ui/edit-commands.d.ts.map +1 -1
  166. package/dist/visio/ui/index.cjs +588 -215
  167. package/dist/visio/ui/index.mjs +588 -215
  168. package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
  169. package/dist/xlsx/edit/pivots.d.ts.map +1 -1
  170. package/dist/xlsx/index.cjs +773 -514
  171. package/dist/xlsx/index.mjs +772 -515
  172. package/dist/xlsx/load/index.cjs +541 -292
  173. package/dist/xlsx/load/index.mjs +541 -292
  174. package/dist/xlsx/model-pivots.d.ts +8 -0
  175. package/dist/xlsx/model-pivots.d.ts.map +1 -1
  176. package/dist/xlsx/pivot/admission.d.ts.map +1 -1
  177. package/dist/xlsx/pivot/aggregate.d.ts.map +1 -1
  178. package/dist/xlsx/pivot/data.d.ts +2 -2
  179. package/dist/xlsx/pivot/data.d.ts.map +1 -1
  180. package/dist/xlsx/pivot/index.d.ts +2 -0
  181. package/dist/xlsx/pivot/index.d.ts.map +1 -1
  182. package/dist/xlsx/pivot/measures.d.ts +1 -1
  183. package/dist/xlsx/pivot/measures.d.ts.map +1 -1
  184. package/dist/xlsx/pivot/page-filter-admission.d.ts +5 -0
  185. package/dist/xlsx/pivot/page-filter-admission.d.ts.map +1 -0
  186. package/dist/xlsx/pivot/page-filter.d.ts +11 -0
  187. package/dist/xlsx/pivot/page-filter.d.ts.map +1 -0
  188. package/dist/xlsx/pivot/read.d.ts.map +1 -1
  189. package/dist/xlsx/pivot/table-xml.d.ts.map +1 -1
  190. package/dist/xlsx/pivot/values-axis.d.ts +4 -1
  191. package/dist/xlsx/pivot/values-axis.d.ts.map +1 -1
  192. package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
  193. package/dist/xlsx/ui/commands/i18n/pivots.d.ts.map +1 -1
  194. package/dist/xlsx/ui/index.cjs +95 -12
  195. package/dist/xlsx/ui/index.mjs +95 -12
  196. package/dist/xlsx/ui/ribbon/parts.d.ts +1 -0
  197. package/dist/xlsx/ui/ribbon/parts.d.ts.map +1 -1
  198. package/package.json +2 -2
  199. package/dist/PptxHandler-5UURGJEV.mjs +0 -2
  200. package/dist/PptxHandler-U5XB2HUE.cjs +0 -11
  201. package/dist/pptx/chunks/index-Cuxtr76Y.d.ts.map +0 -1
  202. package/dist/pptx/chunks/index-DUCGeZh7.d.ts.map +0 -1
  203. package/dist/pptx/chunks/smart-art-D-sXa_Nb.d.ts +0 -2980
  204. package/dist/pptx/chunks/smart-art-D-sXa_Nb.d.ts.map +0 -1
  205. 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: {
@@ -11599,6 +11692,177 @@ function readVisioPageSetup(cells4) {
11599
11692
  return Object.keys(result).length ? result : void 0;
11600
11693
  }
11601
11694
 
11695
+ // visio/print-settings.ts
11696
+ var NAMES = [
11697
+ "PaperKind",
11698
+ "PrintPageOrientation",
11699
+ "PageLeftMargin",
11700
+ "PageRightMargin",
11701
+ "PageTopMargin",
11702
+ "PageBottomMargin",
11703
+ "ScaleX",
11704
+ "ScaleY",
11705
+ "OnPage",
11706
+ "PagesX",
11707
+ "PagesY",
11708
+ "CenterX",
11709
+ "CenterY"
11710
+ ];
11711
+ var BOOLEAN = /* @__PURE__ */ new Set(["OnPage", "CenterX", "CenterY"]);
11712
+ var LENGTH = /* @__PURE__ */ new Set(["PageLeftMargin", "PageRightMargin", "PageTopMargin", "PageBottomMargin"]);
11713
+ var CANONICAL = new Map(
11714
+ [...NAMES, "PageWidth", "PageHeight", "PageScale", "DrawingScale"].map((name3) => [
11715
+ name3.toLowerCase(),
11716
+ name3
11717
+ ])
11718
+ );
11719
+ function indexCells2(sheet) {
11720
+ const cells4 = /* @__PURE__ */ new Map();
11721
+ let duplicate = false;
11722
+ for (const node2 of children2(sheet, "Cell")) {
11723
+ const name3 = attribute2(node2, "N") ?? "", canonical2 = CANONICAL.get(name3.toLowerCase());
11724
+ if (!canonical2) continue;
11725
+ if (canonical2 !== name3) duplicate = true;
11726
+ const values = cells4.get(canonical2) ?? [];
11727
+ if (values.length < 2) values.push(node2);
11728
+ cells4.set(canonical2, values);
11729
+ if (values.length > 1) duplicate = true;
11730
+ }
11731
+ return { cells: cells4, duplicate };
11732
+ }
11733
+ function createVisioPrintSettingsReader(documentSheets, rootStyles) {
11734
+ const indexes = { document: indexCells2(documentSheets[0]), root: indexCells2(rootStyles[0]) };
11735
+ return (pageSheets) => readVisioPrintCountSettings(pageSheets, documentSheets, rootStyles, indexes);
11736
+ }
11737
+ function readVisioPrintCountSettings(pageSheets, documentSheets, rootStyles, indexes) {
11738
+ let refusal;
11739
+ const refuse3 = (reason) => {
11740
+ refusal ??= reason;
11741
+ };
11742
+ if (pageSheets.length !== 1) refuse3("ambiguous-page-sheet");
11743
+ if (documentSheets.length > 1) refuse3("ambiguous-document-sheet");
11744
+ if (!documentSheets.length) refuse3("missing-setting");
11745
+ if (rootStyles.length > 1) refuse3("duplicate-setting");
11746
+ const root2 = rootStyles[0];
11747
+ if (!root2 || attribute2(root2, "ID") !== "0" || attribute2(root2, "NameU") !== "No Style")
11748
+ refuse3("unsupported-print-style");
11749
+ for (const sheet of [...pageSheets, ...documentSheets])
11750
+ for (const name3 of ["LineStyle", "FillStyle", "TextStyle"])
11751
+ if (attribute2(sheet, name3) !== "0") refuse3("unsupported-print-style");
11752
+ for (const name3 of ["LineStyle", "FillStyle", "TextStyle"])
11753
+ if (attribute2(root2, name3) !== void 0) refuse3("unsupported-print-style");
11754
+ const localIndex = indexCells2(pageSheets[0]), rootIndex = indexes?.root ?? indexCells2(root2);
11755
+ const documentIndex = indexes?.document ?? indexCells2(documentSheets[0]);
11756
+ if (localIndex.duplicate || rootIndex.duplicate || documentIndex.duplicate)
11757
+ refuse3("duplicate-setting");
11758
+ const local = localIndex.cells, inherited = rootIndex.cells;
11759
+ const read = (node2, name3, origin) => {
11760
+ const invalid4 = () => {
11761
+ refuse3(origin === "local" ? "invalid-local-setting" : "invalid-document-setting");
11762
+ return void 0;
11763
+ };
11764
+ if (node2.hasAttribute("E")) return invalid4();
11765
+ let raw = (attribute2(node2, "V") ?? "").trim();
11766
+ if (!raw || raw.length > 128) return invalid4();
11767
+ if (BOOLEAN.has(name3)) {
11768
+ if (!["0", "1", "false", "true"].includes(raw)) return invalid4();
11769
+ raw = raw === "true" ? "1" : raw === "false" ? "0" : raw;
11770
+ }
11771
+ try {
11772
+ const value = visioFormulaCachedValue(raw, attribute2(node2, "U"));
11773
+ const length = LENGTH.has(name3) || /^(PageWidth|PageHeight|PageScale|DrawingScale)$/.test(name3);
11774
+ if (!["scalar", ...length ? ["length"] : []].includes(value.unit) || Math.abs(value.value) > 1e9)
11775
+ return invalid4();
11776
+ const formula = attribute2(node2, "F");
11777
+ if (formula !== void 0) {
11778
+ const source = formula.trim();
11779
+ if (/^(true|false)$/i.test(source)) {
11780
+ if ((source.toLowerCase() === "true" ? 1 : 0) !== value.value) return invalid4();
11781
+ } else {
11782
+ if (!source || source === "Inh") return invalid4();
11783
+ const limits = { maxLength: 512, maxNodes: 64, maxDepth: 16, maxSteps: 128 };
11784
+ const analysis = analyzeVisioFormula(source, limits);
11785
+ if (analysis.dynamic || analysis.guarded || analysis.references.length || analysis.unsupportedFunctions.length) {
11786
+ refuse3("dynamic-setting");
11787
+ return void 0;
11788
+ }
11789
+ const evaluated = evaluateVisioFormula(
11790
+ source,
11791
+ () => {
11792
+ throw new Error("Unexpected reference");
11793
+ },
11794
+ limits
11795
+ );
11796
+ if (evaluated.value !== value.value || !["scalar", ...length ? ["length"] : []].includes(evaluated.unit))
11797
+ return invalid4();
11798
+ }
11799
+ }
11800
+ return value.value;
11801
+ } catch {
11802
+ return invalid4();
11803
+ }
11804
+ };
11805
+ const values = /* @__PURE__ */ new Map();
11806
+ for (const name3 of NAMES) {
11807
+ const nodes = local.get(name3) ?? inherited.get(name3);
11808
+ if (!nodes?.length) continue;
11809
+ if (nodes.length !== 1) continue;
11810
+ const value = read(nodes[0], name3, local.has(name3) ? "local" : "document");
11811
+ if (value !== void 0) values.set(name3, value);
11812
+ }
11813
+ for (const name3 of ["PageWidth", "PageHeight", "PageScale", "DrawingScale"]) {
11814
+ const nodes = local.get(name3);
11815
+ if (!nodes || nodes.length !== 1 || !(read(nodes[0], name3, "local") > 0))
11816
+ refuse3("unusable-drawing-scale");
11817
+ }
11818
+ const setup = {};
11819
+ const paper = values.get("PaperKind");
11820
+ if (paper !== void 0 && Number.isSafeInteger(paper) && paper >= 0 && paper <= 65535)
11821
+ setup.paperKind = paper;
11822
+ else if (paper !== void 0)
11823
+ refuse3(local.has("PaperKind") ? "invalid-local-setting" : "invalid-document-setting");
11824
+ const orientation = values.get("PrintPageOrientation");
11825
+ if (orientation === 0 || orientation === 1 || orientation === 2)
11826
+ setup.printPageOrientation = orientation;
11827
+ else if (orientation !== void 0)
11828
+ refuse3(
11829
+ local.has("PrintPageOrientation") ? "invalid-local-setting" : "invalid-document-setting"
11830
+ );
11831
+ const margins = ["Left", "Right", "Top", "Bottom"].map((side2) => values.get(`Page${side2}Margin`));
11832
+ if (margins.every((n) => n !== void 0 && n >= 0 && n <= 1e3))
11833
+ setup.margins = {
11834
+ left: margins[0],
11835
+ right: margins[1],
11836
+ top: margins[2],
11837
+ bottom: margins[3]
11838
+ };
11839
+ else if (margins.some((n) => n !== void 0 && (n < 0 || n > 1e3)))
11840
+ refuse3("unusable-print-area");
11841
+ for (const [name3, key2] of [
11842
+ ["ScaleX", "printZoom"],
11843
+ ["ScaleY", "printZoomY"],
11844
+ ["PagesX", "printPagesAcross"],
11845
+ ["PagesY", "printPagesDown"]
11846
+ ]) {
11847
+ const value = values.get(name3);
11848
+ if (value !== void 0) {
11849
+ if ((name3 === "PagesX" || name3 === "PagesY") && (!Number.isSafeInteger(value) || value < 1))
11850
+ refuse3(local.has(name3) ? "invalid-local-setting" : "invalid-document-setting");
11851
+ else setup[key2] = value;
11852
+ }
11853
+ }
11854
+ for (const [name3, key2] of [
11855
+ ["OnPage", "printFitToPages"],
11856
+ ["CenterX", "printCenterX"],
11857
+ ["CenterY", "printCenterY"]
11858
+ ]) {
11859
+ const value = values.get(name3);
11860
+ if (value !== void 0) setup[key2] = value === 1;
11861
+ }
11862
+ if (refusal) setup.printCountRefusal = refusal;
11863
+ return setup;
11864
+ }
11865
+
11602
11866
  // visio/page-layout.ts
11603
11867
  var VISIO_GRID_DENSITIES = Object.freeze([0, 2, 4, 8]);
11604
11868
  var VISIO_RULER_DENSITIES = Object.freeze([8, 16, 32]);
@@ -11622,7 +11886,7 @@ var VISIO_PAGE_LAYOUT_DEFAULTS = Object.freeze({
11622
11886
  rulerOriginX: 0,
11623
11887
  rulerOriginY: 0
11624
11888
  });
11625
- var NAMES = {
11889
+ var NAMES2 = {
11626
11890
  lineJumpCode: "LineJumpCode",
11627
11891
  lineJumpStyle: "LineJumpStyle",
11628
11892
  lineJumpDirectionX: "PageLineJumpDirX",
@@ -11645,8 +11909,8 @@ var NAMES = {
11645
11909
  var NUMBER4 = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i;
11646
11910
  function readVisioPageLayout(cells4) {
11647
11911
  const result = {};
11648
- for (const key2 of Object.keys(NAMES)) {
11649
- const cell = cells4.get(NAMES[key2]);
11912
+ for (const key2 of Object.keys(NAMES2)) {
11913
+ const cell = cells4.get(NAMES2[key2]);
11650
11914
  const raw = cell?.value?.trim();
11651
11915
  if (!cell || cell.error !== void 0 || cell.formula === "Inh" || !raw || raw.length > 64)
11652
11916
  continue;
@@ -12322,6 +12586,11 @@ async function parseVsdx(input, options = {}) {
12322
12586
  });
12323
12587
  const rootStyle = styles.get("0");
12324
12588
  if (rootStyle?.attributes.get("NameU") === "No Style") resources.rootSheet = rootStyle.sheet;
12589
+ const printStyleGroups = children2(documentRoot, "StyleSheets");
12590
+ const readPrintSettings = createVisioPrintSettingsReader(
12591
+ children2(documentRoot, "DocumentSheet"),
12592
+ printStyleGroups.length === 1 ? children2(printStyleGroups[0], "StyleSheet").filter((node2) => attribute2(node2, "ID") === "0") : []
12593
+ );
12325
12594
  const masters = /* @__PURE__ */ new Map();
12326
12595
  const masterRecords = [];
12327
12596
  const mastersPart = await related(pkg, documentPart2, "masters", false);
@@ -12485,7 +12754,17 @@ async function parseVsdx(input, options = {}) {
12485
12754
  const value = number(sheet.cells, name3, Number.NaN, localReport);
12486
12755
  if (Number.isSafeInteger(value) && value >= 0 && value <= 255) pageModes[key2] = value;
12487
12756
  }
12488
- const pageSetup = readVisioPageSetup(sheet.cells);
12757
+ const { paperKind, printPageOrientation, margins, printZoom, ...countMetadata } = readPrintSettings(children2(page, "PageSheet"));
12758
+ const pageSetup = {
12759
+ ...readVisioPageSetup(sheet.cells),
12760
+ ...countMetadata,
12761
+ printCountSettings: {
12762
+ ...paperKind === void 0 ? {} : { paperKind },
12763
+ ...printPageOrientation === void 0 ? {} : { printPageOrientation },
12764
+ ...margins === void 0 ? {} : { margins },
12765
+ ...printZoom === void 0 ? {} : { printZoom }
12766
+ }
12767
+ };
12489
12768
  const layout = readVisioPageLayout(sheet.cells);
12490
12769
  for (const connection of connectors)
12491
12770
  if (!seen.has(connection.fromShapeId) || !seen.has(connection.toShapeId))
@@ -12561,6 +12840,128 @@ function getVisioPageLayers(document, pageId2) {
12561
12840
  return result.reverse();
12562
12841
  }
12563
12842
 
12843
+ // visio/paper-sizes.ts
12844
+ var mm = (value) => value / 25.4;
12845
+ var size = (id3, label, width, height, paperKind) => Object.freeze({ id: id3, label, width, height, ...paperKind === void 0 ? {} : { paperKind } });
12846
+ var VISIO_PAPER_SIZES = Object.freeze([
12847
+ size("letter", "Letter", 8.5, 11, 1),
12848
+ size("tabloid", "Tabloid", 11, 17, 3),
12849
+ size("legal", "Legal", 8.5, 14, 5),
12850
+ size("statement", "Statement", 5.5, 8.5, 6),
12851
+ size("executive", "Executive", 7.25, 10.5, 7),
12852
+ size("a3", "A3", mm(297), mm(420), 8),
12853
+ size("a4", "A4", mm(210), mm(297), 9),
12854
+ size("a5", "A5", mm(148), mm(210), 11),
12855
+ size("b4", "B4 (JIS)", mm(257), mm(364), 12),
12856
+ size("b5", "B5 (JIS)", mm(182), mm(257), 13),
12857
+ size("ansi-c", "ANSI C", 17, 22, 24),
12858
+ size("ansi-d", "ANSI D", 22, 34, 25),
12859
+ size("ansi-e", "ANSI E", 34, 44, 26),
12860
+ size("arch-c", "ARCH C", 18, 24),
12861
+ size("arch-d", "ARCH D", 24, 36)
12862
+ ]);
12863
+ function visioPaperSize(paperKind) {
12864
+ return VISIO_PAPER_SIZES.find((item) => item.paperKind === paperKind);
12865
+ }
12866
+ function visioOrientedPaperSize(paper, landscape) {
12867
+ const short = Math.min(paper.width, paper.height), long = Math.max(paper.width, paper.height);
12868
+ return { width: landscape ? long : short, height: landscape ? short : long };
12869
+ }
12870
+ function visioPrintTile(page, paper = page.pageSetup?.paperKind === void 0 ? void 0 : visioPaperSize(page.pageSetup.paperKind)) {
12871
+ if (!paper) return void 0;
12872
+ const setup = page.pageSetup;
12873
+ const landscape = setup?.printPageOrientation === 2 || setup?.printPageOrientation !== 1 && page.width > page.height;
12874
+ const oriented = visioOrientedPaperSize(paper, landscape);
12875
+ const margins = setup?.margins ?? { left: 0, right: 0, top: 0, bottom: 0 };
12876
+ const zoom = setup?.printZoom ?? 1;
12877
+ const width = (oriented.width - margins.left - margins.right) / zoom;
12878
+ const height = (oriented.height - margins.top - margins.bottom) / zoom;
12879
+ return width > 0.01 && height > 0.01 ? { width, height } : void 0;
12880
+ }
12881
+
12882
+ // visio/print-count.ts
12883
+ var VISIO_PRINT_COUNT_LIMITS = Object.freeze({ maxAxis: 200, maxTotal: 4096 });
12884
+ var REFUSALS = /* @__PURE__ */ new Set([
12885
+ "missing-setting",
12886
+ "invalid-local-setting",
12887
+ "invalid-document-setting",
12888
+ "ambiguous-document-sheet",
12889
+ "ambiguous-page-sheet",
12890
+ "duplicate-setting",
12891
+ "dynamic-setting",
12892
+ "fit-mode",
12893
+ "unequal-scale",
12894
+ "unknown-paper",
12895
+ "printer-orientation",
12896
+ "centering-unmeasured",
12897
+ "unusable-drawing-scale",
12898
+ "unusable-print-area",
12899
+ "count-budget",
12900
+ "boundary-precision",
12901
+ "unsupported-print-style"
12902
+ ]);
12903
+ function visioPrintTileCount(page) {
12904
+ const unsupported2 = (reason) => ({
12905
+ kind: "unsupported",
12906
+ reason
12907
+ });
12908
+ const setup = page.pageSetup && { ...page.pageSetup, ...page.pageSetup.printCountSettings };
12909
+ if (setup?.printCountRefusal !== void 0)
12910
+ return unsupported2(
12911
+ REFUSALS.has(setup.printCountRefusal) ? setup.printCountRefusal : "invalid-local-setting"
12912
+ );
12913
+ if (!setup || [
12914
+ setup.paperKind,
12915
+ setup.printPageOrientation,
12916
+ setup.printZoom,
12917
+ setup.printZoomY,
12918
+ setup.printFitToPages,
12919
+ setup.printCenterX,
12920
+ setup.printCenterY
12921
+ ].some((value) => value === void 0) || !setup.margins)
12922
+ return unsupported2("missing-setting");
12923
+ if (typeof setup.printFitToPages !== "boolean" || typeof setup.printCenterX !== "boolean" || typeof setup.printCenterY !== "boolean")
12924
+ return unsupported2("invalid-local-setting");
12925
+ if (setup.printFitToPages) return unsupported2("fit-mode");
12926
+ if ([setup.printPagesAcross, setup.printPagesDown].some(
12927
+ (value) => value !== void 0 && (!Number.isSafeInteger(value) || value < 1)
12928
+ ))
12929
+ return unsupported2("invalid-local-setting");
12930
+ if (setup.printCenterX || setup.printCenterY) return unsupported2("centering-unmeasured");
12931
+ const zoom = setup.printZoom;
12932
+ if (!Number.isFinite(zoom) || zoom <= 0 || zoom > 100 || !Number.isFinite(setup.printZoomY) || zoom !== setup.printZoomY)
12933
+ return unsupported2("unequal-scale");
12934
+ if (setup.printPageOrientation !== 1 && setup.printPageOrientation !== 2)
12935
+ return unsupported2("printer-orientation");
12936
+ if (setup.paperKind !== 1 && setup.paperKind !== 9) return unsupported2("unknown-paper");
12937
+ const paper = visioPaperSize(setup.paperKind);
12938
+ const oriented = visioOrientedPaperSize(paper, setup.printPageOrientation === 2);
12939
+ if (![page.width, page.height].every((n) => Number.isFinite(n) && n > 0))
12940
+ return unsupported2("unusable-drawing-scale");
12941
+ if (![setup.margins.left, setup.margins.right, setup.margins.top, setup.margins.bottom].every(
12942
+ (n) => Number.isFinite(n) && n >= 0
12943
+ ))
12944
+ return unsupported2("unusable-print-area");
12945
+ const tile = visioPrintTile({ ...page, pageSetup: setup }, paper);
12946
+ if (!tile) return unsupported2("unusable-print-area");
12947
+ const axis = (extent2, full, usable) => {
12948
+ const scaled = extent2 * zoom, ratio = (scaled - full) / usable;
12949
+ if (!Number.isFinite(ratio)) return "count-budget";
12950
+ const gap = Math.abs(ratio - Math.round(ratio));
12951
+ const uncertainty = 8 * Number.EPSILON * (Math.max(Math.abs(scaled), full) / usable + Math.abs(ratio));
12952
+ if (Math.round(ratio) >= 0 && gap > 0 && gap <= uncertainty) return "boundary-precision";
12953
+ return Math.max(1, Math.ceil(ratio) + 1);
12954
+ };
12955
+ const columns = axis(page.width, oriented.width, tile.width * zoom);
12956
+ const rows = axis(page.height, oriented.height, tile.height * zoom);
12957
+ if (typeof columns !== "number") return unsupported2(columns);
12958
+ if (typeof rows !== "number") return unsupported2(rows);
12959
+ const total = columns * rows;
12960
+ if (![columns, rows, total].every(Number.isSafeInteger) || columns > VISIO_PRINT_COUNT_LIMITS.maxAxis || rows > VISIO_PRINT_COUNT_LIMITS.maxAxis || total > VISIO_PRINT_COUNT_LIMITS.maxTotal)
12961
+ return unsupported2("count-budget");
12962
+ return { kind: "supported", profile: "explicit-nonfit-count", columns, rows, total };
12963
+ }
12964
+
12564
12965
  // ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/ole2-parser-types.js
12565
12966
  var OLE_MAGIC = new Uint8Array([208, 207, 17, 224, 161, 177, 26, 225]);
12566
12967
  var ENDOFCHAIN = 4294967294;
@@ -22051,6 +22452,7 @@ async function assertFormattingDependencies(pkg, pagePaths, roots, pageId2, shap
22051
22452
  continue;
22052
22453
  const source = executableCellFormula(attribute2(node2, "F"));
22053
22454
  if (!source || inertDoubleClickFormula(attribute2(node2, "N") ?? "", source)) continue;
22455
+ if (independentTextFieldFormula(node2, source)) continue;
22054
22456
  if (attribute2(node2, "V") === "Themed" && isThemeLookupFormula(source)) continue;
22055
22457
  if (isConnectedGlueCell(node2, source)) continue;
22056
22458
  const owner = node2.parentNode;
@@ -26961,9 +27363,23 @@ async function insertVisioTextField(pkg, pagePaths, roots, document, edit, check
26961
27363
  effectiveFormattingRows(shape, document, "Paragraph")
26962
27364
  );
26963
27365
  const rows = formattingRows(shape, "Field");
26964
- const point2 = insertionPoint(text5, edit.offset);
26965
- if (edit.offset !== void 0 && point2.logical !== edit.expectedText)
27366
+ const updating = edit.type === "update-text-field";
27367
+ if (updating) assertEditableFieldShape(shape);
27368
+ const point2 = insertionPoint(text5, updating ? void 0 : edit.offset);
27369
+ if ((updating || edit.offset !== void 0) && point2.logical !== edit.expectedText)
26966
27370
  fail("EDIT_STALE_TEXT", "The shape text changed since the field position was chosen.");
27371
+ const existing = updating ? rows.get(edit.fieldIndex) : void 0;
27372
+ const markers = updating ? children2(text5, "fld").filter((field3) => attribute2(field3, "IX") === edit.fieldIndex) : [];
27373
+ if (updating) {
27374
+ if (!existing || markers.length !== 1)
27375
+ fail(
27376
+ "UNSUPPORTED_TEXT_FIELD",
27377
+ "Existing fields require one live local row and unique text marker."
27378
+ );
27379
+ if (markers[0].textContent !== edit.expectedCached || textFieldSourceKey(readCells(existing)) !== edit.expectedSourceKey)
27380
+ fail("EDIT_STALE_TEXT", "The field source changed since it was selected.");
27381
+ assertEditableFieldRow(existing);
27382
+ }
26967
27383
  const context = { ...await pageContext(pkg, edit.pageId), resolve: shapeResolver(shape) };
26968
27384
  let value;
26969
27385
  try {
@@ -26976,9 +27392,19 @@ async function insertVisioTextField(pkg, pagePaths, roots, document, edit, check
26976
27392
  "UNSUPPORTED_TEXT_FIELD",
26977
27393
  `This editor cannot evaluate the field formula. Supported: ${VISIO_FIELD_FUNCTIONS.join(", ")}, PAGENUMBER, PAGECOUNT and numeric formulas on this shape.`
26978
27394
  );
26979
- const display = formatVisioFieldValue(value, edit.format ?? "");
27395
+ const format4 = edit.format ?? "";
27396
+ const display = formatVisioFieldValue(value, format4);
26980
27397
  if (display === void 0)
26981
27398
  fail("UNSUPPORTED_TEXT_FIELD", "The field format does not suit the field value.");
27399
+ const prepared = valueCell(value);
27400
+ if (existing && markers[0].textContent === display) {
27401
+ const same5 = (name3, v, u, f) => {
27402
+ const cell2 = children2(existing, "Cell").find((cell3) => attribute2(cell3, "N") === name3);
27403
+ return attribute2(cell2, "V") === v && attribute2(cell2, "U") === u && attribute2(cell2, "F") === f;
27404
+ };
27405
+ if (same5("Value", prepared.v, prepared.u, edit.formula) && same5("Format", format4, "STR", `"${format4.replaceAll('"', '""')}"`) && same5("Type", String(prepared.type), void 0, void 0))
27406
+ return false;
27407
+ }
26982
27408
  if (texts[0])
26983
27409
  await assertFormattingDependencies(
26984
27410
  pkg,
@@ -26986,32 +27412,49 @@ async function insertVisioTextField(pkg, pagePaths, roots, document, edit, check
26986
27412
  roots,
26987
27413
  edit.pageId,
26988
27414
  shape,
26989
- /* @__PURE__ */ new Map([["TheText", text5]]),
27415
+ new Map([
27416
+ ["TheText", text5],
27417
+ ...existing ? ["Value", "Format", "Type"].flatMap((name3) => {
27418
+ const cell2 = children2(existing, "Cell").find((cell3) => attribute2(cell3, "N") === name3);
27419
+ return [
27420
+ [`Field.${updating ? edit.fieldIndex : ""}.${name3}`, cell2],
27421
+ [`Fields.${name3}`, cell2]
27422
+ ];
27423
+ }) : []
27424
+ ]),
26990
27425
  check
26991
27426
  );
26992
27427
  check();
26993
- const index = String(rows.size ? Math.max(...[...rows.keys()].map(Number)) + 1 : 0);
27428
+ const index = updating ? edit.fieldIndex : String(rows.size ? Math.max(...[...rows.keys()].map(Number)) + 1 : 0);
26994
27429
  let section3 = children2(shape, "Section").find((node2) => attribute2(node2, "N") === "Field");
26995
27430
  if (!section3) {
26996
27431
  section3 = owner.createElementNS(ns, "Section");
26997
27432
  section3.setAttribute("N", "Field");
26998
27433
  shape.insertBefore(section3, texts[0] ?? null);
26999
27434
  }
27000
- const row2 = owner.createElementNS(ns, "Row");
27001
- row2.setAttribute("IX", index);
27435
+ const row2 = existing ?? owner.createElementNS(ns, "Row");
27436
+ if (!existing) row2.setAttribute("IX", index);
27002
27437
  const cell = (name3, v, extra = {}) => {
27003
- const node2 = owner.createElementNS(ns, "Cell");
27438
+ const node2 = children2(row2, "Cell").find((cell2) => attribute2(cell2, "N") === name3) ?? owner.createElementNS(ns, "Cell");
27004
27439
  node2.setAttribute("N", name3);
27005
27440
  node2.setAttribute("V", v);
27441
+ if (updating) {
27442
+ node2.removeAttribute("U");
27443
+ node2.removeAttribute("F");
27444
+ }
27006
27445
  for (const [key2, item] of Object.entries(extra)) node2.setAttribute(key2, item);
27007
- row2.appendChild(node2);
27446
+ if (!node2.parentNode) row2.appendChild(node2);
27008
27447
  };
27009
- const stored = valueCell(value);
27448
+ const stored = prepared;
27010
27449
  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('"', '""')}"` });
27450
+ if (format4 || updating)
27451
+ cell("Format", format4, { U: "STR", F: `"${format4.replaceAll('"', '""')}"` });
27013
27452
  cell("Type", String(stored.type));
27014
- section3.appendChild(row2);
27453
+ if (!row2.parentNode) section3.appendChild(row2);
27454
+ if (updating) {
27455
+ markers[0].textContent = display;
27456
+ return true;
27457
+ }
27015
27458
  const field2 = owner.createElementNS(ns, "fld");
27016
27459
  field2.setAttribute("IX", index);
27017
27460
  field2.appendChild(owner.createTextNode(display));
@@ -28713,41 +29156,6 @@ async function editVsdxMasterInstance(pkg, parts, pages, edit, limits, maxOutput
28713
29156
  return { bytes, changedParts: [...dirty.keys()], diagnostics: [] };
28714
29157
  }
28715
29158
 
28716
- // visio/paper-sizes.ts
28717
- var mm = (value) => value / 25.4;
28718
- var size = (id3, label, width, height, paperKind) => Object.freeze({ id: id3, label, width, height, ...paperKind === void 0 ? {} : { paperKind } });
28719
- var VISIO_PAPER_SIZES = Object.freeze([
28720
- size("letter", "Letter", 8.5, 11, 1),
28721
- size("tabloid", "Tabloid", 11, 17, 3),
28722
- size("legal", "Legal", 8.5, 14, 5),
28723
- size("statement", "Statement", 5.5, 8.5, 6),
28724
- size("executive", "Executive", 7.25, 10.5, 7),
28725
- size("a3", "A3", mm(297), mm(420), 8),
28726
- size("a4", "A4", mm(210), mm(297), 9),
28727
- size("a5", "A5", mm(148), mm(210), 11),
28728
- size("b4", "B4 (JIS)", mm(257), mm(364), 12),
28729
- size("b5", "B5 (JIS)", mm(182), mm(257), 13),
28730
- size("ansi-c", "ANSI C", 17, 22, 24),
28731
- size("ansi-d", "ANSI D", 22, 34, 25),
28732
- size("ansi-e", "ANSI E", 34, 44, 26),
28733
- size("arch-c", "ARCH C", 18, 24),
28734
- size("arch-d", "ARCH D", 24, 36)
28735
- ]);
28736
- function visioPaperSize(paperKind) {
28737
- return VISIO_PAPER_SIZES.find((item) => item.paperKind === paperKind);
28738
- }
28739
- function visioPrintTile(page, paper = page.pageSetup?.paperKind === void 0 ? void 0 : visioPaperSize(page.pageSetup.paperKind)) {
28740
- if (!paper) return void 0;
28741
- const setup = page.pageSetup;
28742
- const landscape = setup?.printPageOrientation === 2 || setup?.printPageOrientation !== 1 && page.width > page.height;
28743
- const short = Math.min(paper.width, paper.height), long = Math.max(paper.width, paper.height);
28744
- const margins = setup?.margins ?? { left: 0, right: 0, top: 0, bottom: 0 };
28745
- const zoom = setup?.printZoom ?? 1;
28746
- const width = ((landscape ? long : short) - margins.left - margins.right) / zoom;
28747
- const height = ((landscape ? short : long) - margins.top - margins.bottom) / zoom;
28748
- return width > 0.01 && height > 0.01 ? { width, height } : void 0;
28749
- }
28750
-
28751
29159
  // visio/edit-page-auto-size.ts
28752
29160
  var GROWING = /* @__PURE__ */ new Set([
28753
29161
  "create-rectangle",
@@ -29409,6 +29817,35 @@ function snapshotGuideEdit(edit) {
29409
29817
  }
29410
29818
 
29411
29819
  // visio/edit-text-field-commands.ts
29820
+ function snapshotTextFieldUpdate(edit) {
29821
+ const insert = snapshotTextFieldInsert({
29822
+ pageId: edit.pageId,
29823
+ shapeId: edit.shapeId,
29824
+ formula: edit.formula,
29825
+ ...edit.format === void 0 ? {} : { format: edit.format }
29826
+ });
29827
+ if (analyzeVisioFormula(parseVisioFormula(insert.formula)).references.some(
29828
+ (ref) => /^fields?\./i.test(ref.cell)
29829
+ ))
29830
+ fail("UNSUPPORTED_TEXT_FIELD", "Existing field formulas cannot reference Field rows.");
29831
+ if (typeof edit.fieldIndex !== "string" || !/^(0|[1-9]\d{0,9})$/.test(edit.fieldIndex) || Number(edit.fieldIndex) > 4294967295)
29832
+ fail("INVALID_EDIT", "An existing field needs a canonical row index.");
29833
+ if ([edit.expectedText, edit.expectedCached, edit.expectedSourceKey].some(
29834
+ (value) => typeof value !== "string" || value.length > 1e6
29835
+ ) || !edit.expectedSourceKey)
29836
+ fail("INVALID_EDIT", "An existing field needs its source text and row identity.");
29837
+ return {
29838
+ type: "update-text-field",
29839
+ pageId: insert.pageId,
29840
+ shapeId: insert.shapeId,
29841
+ fieldIndex: edit.fieldIndex,
29842
+ formula: insert.formula,
29843
+ format: insert.format,
29844
+ expectedText: edit.expectedText,
29845
+ expectedCached: edit.expectedCached,
29846
+ expectedSourceKey: edit.expectedSourceKey
29847
+ };
29848
+ }
29412
29849
  function snapshotTextFieldInsert(edit) {
29413
29850
  const { pageId: pageId2, shapeId: shapeId2 } = edit;
29414
29851
  if ([pageId2, shapeId2].some((id3) => typeof id3 !== "string" || !id3 || id3.length > 256))
@@ -30162,6 +30599,14 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
30162
30599
  return { ...target2, type: edit.type, text: text5(edit.text) };
30163
30600
  if (edit.type === "replace-text-ranges") return snapshotTextRanges(edit, text5);
30164
30601
  if (edit.type === "insert-text-field") return snapshotTextFieldInsert(edit);
30602
+ if (edit.type === "update-text-field") {
30603
+ const update = snapshotTextFieldUpdate(edit);
30604
+ update.formula = text5(update.formula);
30605
+ update.expectedText = text5(update.expectedText);
30606
+ update.expectedCached = text5(update.expectedCached);
30607
+ update.expectedSourceKey = text5(update.expectedSourceKey);
30608
+ return update;
30609
+ }
30165
30610
  if (isVisioFormatEdit(edit)) return snapshotFormatting(edit);
30166
30611
  if (edit.type === "reorder-shape") {
30167
30612
  if (!["front", "back", "forward", "backward"].includes(edit.order))
@@ -35589,7 +36034,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
35589
36034
  const dirty = /* @__PURE__ */ new Map();
35590
36035
  const roots = /* @__PURE__ */ new Map();
35591
36036
  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)
36037
+ (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
36038
  );
35594
36039
  let document;
35595
36040
  let masterMovePins = emptyMasterMoveProof();
@@ -35597,7 +36042,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
35597
36042
  let instanceDeletes = /* @__PURE__ */ new Set();
35598
36043
  let groupMembers = /* @__PURE__ */ new Map();
35599
36044
  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)
36045
+ (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
36046
  )) {
35602
36047
  for (const [pageId2, path2] of pages) {
35603
36048
  const sourceRoot = await visioXml(pkg, path2, "PageContents");
@@ -35708,7 +36153,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
35708
36153
  textChanged = true;
35709
36154
  await noteTextSize(command2, root2);
35710
36155
  }
35711
- } else if (command2.type === "insert-text-field") {
36156
+ } else if (command2.type === "insert-text-field" || command2.type === "update-text-field") {
35712
36157
  if (await insertVisioTextField(pkg, new Set(pages.values()), roots, document, command2, check)) {
35713
36158
  dirty.set(path, root2);
35714
36159
  textChanged = true;
@@ -36223,4 +36668,4 @@ function checkVisioAlternativeText(document) {
36223
36668
  return issues;
36224
36669
  }
36225
36670
 
36226
- export { VISIO_ARROW_SHAPES, VISIO_BACKGROUND_STYLES, VISIO_BASIC_SHAPES, VISIO_BASIC_STENCIL, VISIO_BORDER_STYLES, VISIO_BUILT_IN_STENCILS, VISIO_BUILT_IN_THEMES, VISIO_BUILT_IN_THEME_IDS, VISIO_CALLOUT_STYLES, VISIO_CLIPBOARD_MAGIC, VISIO_CLIPBOARD_MAX_CHARS, VISIO_COMMENT_AUTHOR_LIMIT, VISIO_COMMENT_LIMIT, VISIO_COMMENT_TEXT_LIMIT, VISIO_CONNECTOR_ROUTES, VISIO_CONTAINER_HEADING, VISIO_CONTAINER_MARGIN, VISIO_CONTAINER_STYLES, VISIO_DATA_LIMITS, VISIO_EMF_ADMISSION_LIMITS, VISIO_FIELD_FORMATS, VISIO_FIELD_FUNCTIONS, VISIO_FLOWCHART_SHAPES, VISIO_FOREIGN_VECTOR_LIMITS, VISIO_GLOW_SIZES, VISIO_GLOW_TRANSPARENCY, VISIO_GLUE, VISIO_GRID_DENSITIES, VISIO_LAYER_NAME_LIMIT, VISIO_LINE_JUMP_LIMITS, VISIO_LINE_JUMP_WIDTH, VISIO_MANAGED_BACKGROUND, VISIO_METADATA_TEXT_LIMIT, VISIO_PAGE_LAYOUT_DEFAULTS, VISIO_PATH_SEGMENT_LIMIT, VISIO_PICTURE_MAX_BYTES, VISIO_QUICK_STYLE_COLORS, VISIO_QUICK_STYLE_VARIANT_COLORS, VISIO_RASTER_IMAGE_LIMITS, VISIO_REFLECTION_PRESETS, VISIO_RULER_DENSITIES, VISIO_SCALE_UNITS, VISIO_SHADOW_PRESETS, VISIO_SHAPE_DATA_TYPES, VISIO_SNAP, VISIO_SNAP_GLUE_DEFAULTS, VISIO_SOFT_EDGE_SIZES, VISIO_STENCILS, VISIO_STENCIL_FILES, VISIO_TEXT_CASES, VISIO_TEXT_POSITIONS, VISIO_THEME_COLOR_SLOTS, VISIO_UNTHEMED_COLORS, VISIO_VISIBILITY_LIMITS, VisioForeignVectorError, VisioFormulaError, VisioImageError, VisioPackageError, analyzeVisioFormula, canonicalShapeDataValue, captureVisioClipboard, checkVisioAlternativeText, convertVisioMetafile, createVsdx, deserializeVisioClipboard, designTextMeasurer, editVsdx, evaluateVisioFormula, evaluateVisioTextField, formatVisioFieldValue, getVisioPageLayers, inspectVisioEmfAdmission, inspectVisioRasterImage, isVisioBasicShape, isVisioBuiltInThemeId, isVisioChangeShapeTarget, isVisioDiagramPartEdit, isVisioLayerName, isVisioOutlineShape, isVisioQuickStyleColor, isVisioShadowPreset, isVisioStencilShape, isVisioThemeColorRef, layoutVisioFilledArrowLine, loadVisio, parseLegacyVsd, parseVisioFormula, parseVisioThemeColorFormula, parseVsdx, resolveVisioPageVisibility, resolveVisioThemeColor, sanitizeVisioForeignVectorTree, serializeVisioClipboard, setVisioTextMeasurer, trimVisioArrowLine, validateVisioForeignVector, visioBackgroundShapes, visioBasicShapeOutline, visioBorderShapes, visioBuiltInMaster, visioBuiltInStencil, visioBuiltInTheme, visioCircleThrough, visioCurvedRoute, visioDecorationName, visioFallbackQuickStyle, visioFilledArrow, visioFitFreeform, visioFitPencil, visioFontAssumed, visioFormulaCachedValue, visioLineJumpPaths, visioLinkedRowNames, visioOpenArrowExtent, visioOpenArrowPath, visioOrthogonalRoute, visioOutlineShape, visioPageLayout, visioPageThemeColors, visioPathBounds, visioPathSamples, visioQuarterArc, visioShade, visioShadowPresetGeometry, visioShapeDataRowName, visioShapeStructure, visioSimplifyPath, visioSnapGlue, visioStencilMaster, visioStencilShapeOutline, visioTextExtents, visioThemeColorFormula, visioThemeVariantColors, visioThemeXml };
36671
+ export { VISIO_ARROW_SHAPES, VISIO_BACKGROUND_STYLES, VISIO_BASIC_SHAPES, VISIO_BASIC_STENCIL, VISIO_BORDER_STYLES, VISIO_BUILT_IN_STENCILS, VISIO_BUILT_IN_THEMES, VISIO_BUILT_IN_THEME_IDS, VISIO_CALLOUT_STYLES, VISIO_CLIPBOARD_MAGIC, VISIO_CLIPBOARD_MAX_CHARS, VISIO_COMMENT_AUTHOR_LIMIT, VISIO_COMMENT_LIMIT, VISIO_COMMENT_TEXT_LIMIT, VISIO_CONNECTOR_ROUTES, VISIO_CONTAINER_HEADING, VISIO_CONTAINER_MARGIN, VISIO_CONTAINER_STYLES, VISIO_DATA_LIMITS, VISIO_EMF_ADMISSION_LIMITS, VISIO_FIELD_FORMATS, VISIO_FIELD_FUNCTIONS, VISIO_FLOWCHART_SHAPES, VISIO_FOREIGN_VECTOR_LIMITS, VISIO_GLOW_SIZES, VISIO_GLOW_TRANSPARENCY, VISIO_GLUE, VISIO_GRID_DENSITIES, VISIO_LAYER_NAME_LIMIT, VISIO_LINE_JUMP_LIMITS, VISIO_LINE_JUMP_WIDTH, VISIO_MANAGED_BACKGROUND, VISIO_METADATA_TEXT_LIMIT, VISIO_PAGE_LAYOUT_DEFAULTS, VISIO_PATH_SEGMENT_LIMIT, VISIO_PICTURE_MAX_BYTES, VISIO_PRINT_COUNT_LIMITS, VISIO_QUICK_STYLE_COLORS, VISIO_QUICK_STYLE_VARIANT_COLORS, VISIO_RASTER_IMAGE_LIMITS, VISIO_REFLECTION_PRESETS, VISIO_RULER_DENSITIES, VISIO_SCALE_UNITS, VISIO_SHADOW_PRESETS, VISIO_SHAPE_DATA_TYPES, VISIO_SNAP, VISIO_SNAP_GLUE_DEFAULTS, VISIO_SOFT_EDGE_SIZES, VISIO_STENCILS, VISIO_STENCIL_FILES, VISIO_TEXT_CASES, VISIO_TEXT_POSITIONS, VISIO_THEME_COLOR_SLOTS, VISIO_UNTHEMED_COLORS, VISIO_VISIBILITY_LIMITS, VisioForeignVectorError, VisioFormulaError, VisioImageError, VisioPackageError, analyzeVisioFormula, canonicalShapeDataValue, captureVisioClipboard, checkVisioAlternativeText, convertVisioMetafile, createVsdx, deserializeVisioClipboard, designTextMeasurer, editVsdx, evaluateVisioFormula, evaluateVisioTextField, formatVisioFieldValue, getVisioPageLayers, inspectVisioEmfAdmission, inspectVisioRasterImage, isVisioBasicShape, isVisioBuiltInThemeId, isVisioChangeShapeTarget, isVisioDiagramPartEdit, isVisioLayerName, isVisioOutlineShape, isVisioQuickStyleColor, isVisioShadowPreset, isVisioStencilShape, isVisioThemeColorRef, layoutVisioFilledArrowLine, loadVisio, parseLegacyVsd, parseVisioFormula, parseVisioThemeColorFormula, parseVsdx, resolveVisioPageVisibility, resolveVisioThemeColor, sanitizeVisioForeignVectorTree, serializeVisioClipboard, setVisioTextMeasurer, trimVisioArrowLine, validateVisioForeignVector, visioBackgroundShapes, visioBasicShapeOutline, visioBorderShapes, visioBuiltInMaster, visioBuiltInStencil, visioBuiltInTheme, visioCircleThrough, visioCurvedRoute, visioDecorationName, visioFallbackQuickStyle, visioFilledArrow, visioFitFreeform, visioFitPencil, visioFontAssumed, visioFormulaCachedValue, visioLineJumpPaths, visioLinkedRowNames, visioOpenArrowExtent, visioOpenArrowPath, visioOrthogonalRoute, visioOutlineShape, visioPageLayout, visioPageThemeColors, visioPathBounds, visioPathSamples, visioPrintTileCount, visioQuarterArc, visioShade, visioShadowPresetGeometry, visioShapeDataRowName, visioShapeStructure, visioSimplifyPath, visioSnapGlue, visioStencilMaster, visioStencilShapeOutline, visioTextExtents, visioThemeColorFormula, visioThemeVariantColors, visioThemeXml };