@docx-editor.dev/core 2.3.1 → 2.4.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 (90) hide show
  1. package/dist/automation.cjs +1 -1
  2. package/dist/automation.d.cts +2 -2
  3. package/dist/automation.d.ts +2 -2
  4. package/dist/automation.js +1 -1
  5. package/dist/binding.cjs +1 -1
  6. package/dist/binding.d.cts +7 -7
  7. package/dist/binding.d.ts +7 -7
  8. package/dist/binding.js +1 -1
  9. package/dist/{chunk-G5D7EXZD.js → chunk-33F6TRXO.js} +1 -1
  10. package/dist/{chunk-LD4YWMBO.cjs → chunk-DQ5HGUWG.cjs} +7 -7
  11. package/dist/chunk-EQO762XH.cjs +10 -0
  12. package/dist/{chunk-XIKXGERI.js → chunk-F6WNPYOM.js} +1 -1
  13. package/dist/chunk-FL4GWK76.js +12 -0
  14. package/dist/chunk-GOEBQ26R.js +1 -0
  15. package/dist/{chunk-J6743NQP.cjs → chunk-GWG5IVVX.cjs} +5 -5
  16. package/dist/{chunk-G7Y6EPB2.cjs → chunk-IZIL6BAW.cjs} +5 -5
  17. package/dist/{chunk-AMLGAD5Q.js → chunk-LIJPSHRA.js} +5 -5
  18. package/dist/{chunk-UKI45YR7.cjs → chunk-MHDO6HLI.cjs} +1 -1
  19. package/dist/chunk-OHJQ7GPZ.cjs +1 -0
  20. package/dist/{chunk-LKWSYFJQ.js → chunk-SG7OH2EK.js} +1 -1
  21. package/dist/chunk-TCX3PVWR.js +10 -0
  22. package/dist/chunk-YMIMLEX4.cjs +1 -0
  23. package/dist/{chunk-TDYP32AL.cjs → chunk-YTYKNA6X.cjs} +1 -1
  24. package/dist/chunk-ZACHY6OS.js +1 -0
  25. package/dist/contracts/editor.cjs +1 -1
  26. package/dist/contracts/editor.d.cts +6 -6
  27. package/dist/contracts/editor.d.ts +6 -6
  28. package/dist/contracts/editor.js +1 -1
  29. package/dist/contracts/interaction.d.cts +6 -6
  30. package/dist/contracts/interaction.d.ts +6 -6
  31. package/dist/contracts/modules.d.cts +3 -3
  32. package/dist/contracts/modules.d.ts +3 -3
  33. package/dist/{custom-node-writes-ttKuYd0M.d.ts → custom-node-writes-BkMgMXxs.d.ts} +3 -3
  34. package/dist/{custom-node-writes-YqISlSRl.d.cts → custom-node-writes-C5YRoPcc.d.cts} +3 -3
  35. package/dist/{editor-BajbOumY.d.ts → editor-D1qHfzOt.d.ts} +12 -4
  36. package/dist/{editor-BXstgYTp.d.cts → editor-DYvC9CZs.d.cts} +12 -4
  37. package/dist/editor.cjs +1 -1
  38. package/dist/editor.d.cts +19 -19
  39. package/dist/editor.d.ts +19 -19
  40. package/dist/editor.js +1 -1
  41. package/dist/{image-resources-C_YnqPhn.d.ts → image-resources-BG9DLyW7.d.ts} +1 -1
  42. package/dist/{image-resources-DwpNnTg3.d.cts → image-resources-DXvPZvXD.d.cts} +1 -1
  43. package/dist/{index-D67PwDZQ.d.cts → index-Bb-QAg_f.d.cts} +11 -11
  44. package/dist/{index-DaJ8nU56.d.ts → index-DpY3WZuP.d.ts} +11 -11
  45. package/dist/index.cjs +1 -1
  46. package/dist/index.d.cts +13 -13
  47. package/dist/index.d.ts +13 -13
  48. package/dist/index.js +1 -1
  49. package/dist/layout.cjs +1 -1
  50. package/dist/layout.d.cts +14 -14
  51. package/dist/layout.d.ts +14 -14
  52. package/dist/layout.js +1 -1
  53. package/dist/output.cjs +1 -1
  54. package/dist/output.d.cts +4 -4
  55. package/dist/output.d.ts +4 -4
  56. package/dist/output.js +1 -1
  57. package/dist/{protocol-DAs0YOP3.d.cts → protocol-CD7slqvl.d.cts} +24 -4
  58. package/dist/{protocol-r6hje8Kf.d.ts → protocol-DsbfgBwA.d.ts} +24 -4
  59. package/dist/{review-reads-cgvJLJc2.d.ts → review-reads-CQmU9Lcl.d.ts} +1 -1
  60. package/dist/{review-reads-JBOmRH--.d.cts → review-reads-CxgN62yp.d.cts} +1 -1
  61. package/dist/{review-support-rsyGP5-9.d.cts → review-support-BJ-YjGmD.d.cts} +1 -1
  62. package/dist/{review-support-B9ykYpoZ.d.ts → review-support-DgXTIYBW.d.ts} +1 -1
  63. package/dist/{semantic-cell-selection-9vfCLkd4.d.cts → semantic-cell-selection--ezfezTe.d.cts} +2 -2
  64. package/dist/{semantic-cell-selection-bA5HTLkV.d.ts → semantic-cell-selection-DZtyMXkH.d.ts} +2 -2
  65. package/dist/{semantic-interaction-BG0jWJ0I.d.cts → semantic-interaction-2yxdv7q0.d.cts} +1 -1
  66. package/dist/{semantic-interaction-lHDX4yIt.d.ts → semantic-interaction-DrgbgKg6.d.ts} +1 -1
  67. package/dist/{semantic-paint-DdGGra4m.d.cts → semantic-paint-BYjE0Xbl.d.cts} +2 -2
  68. package/dist/{semantic-paint-BBNaqr1s.d.ts → semantic-paint-BedBxkyY.d.ts} +2 -2
  69. package/dist/{semantic-records-BC4bIKKL.d.ts → semantic-records-CR5hTqMK.d.ts} +2 -2
  70. package/dist/{semantic-records-DC6V1U3T.d.cts → semantic-records-DSD8WENa.d.cts} +2 -2
  71. package/dist/{shaped-measurer-ChSWkuAT.d.ts → shaped-measurer-BL8g4AcW.d.ts} +1 -1
  72. package/dist/{shaped-measurer-SIqZp-Ty.d.cts → shaped-measurer-CBOTJTV_.d.cts} +1 -1
  73. package/dist/store.cjs +1 -1
  74. package/dist/store.d.cts +30 -31
  75. package/dist/store.d.ts +30 -31
  76. package/dist/store.js +1 -1
  77. package/dist/{tree-op-types-DWLCllG7.d.ts → tree-op-types-8a6xyRCN.d.ts} +6 -1
  78. package/dist/{tree-op-types-UOXlRUqQ.d.cts → tree-op-types-EZXbR8bW.d.cts} +6 -1
  79. package/dist/{tree-session-ZpXtFxlP.d.cts → tree-session-DrMm8Cj2.d.cts} +5 -5
  80. package/dist/{tree-session-COduYhKr.d.ts → tree-session-SucW0znF.d.ts} +5 -5
  81. package/dist/{tree-store-BscFPB7x.d.ts → tree-store-BoM6eXaL.d.ts} +1 -1
  82. package/dist/{tree-store-B1lEkdXc.d.cts → tree-store-UYrGKF_Q.d.cts} +1 -1
  83. package/package.json +2 -2
  84. package/dist/chunk-2H6LCX4H.js +0 -10
  85. package/dist/chunk-5LFOW7UO.cjs +0 -1
  86. package/dist/chunk-GRGRIDHF.js +0 -1
  87. package/dist/chunk-JQSVJSR7.js +0 -12
  88. package/dist/chunk-MIUELYVA.cjs +0 -1
  89. package/dist/chunk-QONAJ66B.cjs +0 -10
  90. package/dist/chunk-YTRVI333.js +0 -1
@@ -1 +1 @@
1
- 'use strict';var chunk5LFOW7UO_cjs=require('./chunk-5LFOW7UO.cjs'),chunkQONAJ66B_cjs=require('./chunk-QONAJ66B.cjs');var I=Object.freeze({document:true,save:true,events:true,selection:false,scrolling:false,layout:false}),D=Object.freeze({kind:"body"});function L(a,r={}){let o=chunkQONAJ66B_cjs.xb(a,r.limits??{});if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let n=o.package.parts.get(o.package.mainDocumentPart);if(!n)return {ok:false,reason:"no-main-document-part",detail:o.package.mainDocumentPart};let e=new chunkQONAJ66B_cjs.Ff(o.package,chunkQONAJ66B_cjs.Qc(n));return {ok:true,host:chunk5LFOW7UO_cjs.g({port:M(e),capabilities:I})}}function j(a,r,o){let n=a.partFor(o);if(!n)return null;let e=chunkQONAJ66B_cjs.Sc(a.currentPackage(),r,n.name);return e?(a.replacePackageShell(e.pkg),e.relationshipId):null}function M(a){let r=true;return {revision:()=>a.packageRevision,currentPackage:()=>r?a.currentPackage():null,apply(o,n=D){if(!r)return {ok:false,reason:"disposed"};let e=o(i=>j(a,i,n));if(e===null)return {ok:false,reason:"unsupported-target"};let t=a.transact(n,i=>{for(let u of e)i.apply(u);});return t.ok?{ok:true,changed:t.change!==null}:{ok:false,reason:t.detail?`${t.reason}: ${t.detail}`:t.reason}},applyLifecycle(o){if(!r)return {ok:false,reason:"disposed"};let n=a.applyLifecycleOp(o);return n.ok?{ok:true,changed:n.change!==null}:{ok:false,reason:n.detail?`${n.reason}: ${n.detail}`:n.reason}},applyCommentWrites(o,n){if(!r)return {ok:false,reason:"disposed"};if(o.length===0)return {ok:true,changed:false};let e=a.resolveStory(n);if(!e.ok)return {ok:false,reason:e.reason};if(e.store.graftPackage(()=>a.currentPackage()),o.every(u=>u.kind==="delete")){let u=false,l=false,x=e.store.transact(T=>{T.applyPackage(d=>{let m=d;for(let s of o){if(s.kind!=="delete")continue;let A={storyPartName:e.store.part.name,...s.noteId===void 0?{}:{noteId:s.noteId}},p=s.parentCommentId===void 0?chunkQONAJ66B_cjs.Je(m,s.commentId,A):chunkQONAJ66B_cjs.Ke(m,s.commentId,s.parentCommentId,A);if(p===null)return u=true,d;l||=p!==m,m=p;}return m});});return u||!x.ok?{ok:false,reason:"comment-delete-refused"}:(l&&a.installPackageSnapshot(e.store.package),{ok:true,changed:l})}if(o.length!==1)return {ok:false,reason:"mixed-comment-writes"};let t=o[0],i=t.kind==="create"?chunkQONAJ66B_cjs.Kf(e.store,{anchor:t.anchor,author:t.author,text:t.text,...t.date===void 0?{}:{date:t.date}}):t.kind==="reply"?chunkQONAJ66B_cjs.Kf(e.store,{anchor:t.anchor,author:t.author,text:t.text,...t.date===void 0?{}:{date:t.date},replyToCommentId:t.parentCommentId}):t.kind==="resolve"?chunkQONAJ66B_cjs.Lf(e.store,t.commentId,t.resolved):null;return i===null?{ok:false,reason:"unsupported-comment-write"}:i.ok?(a.replacePackageShell(e.store.package),{ok:true,changed:true,..."commentId"in i?{commentId:i.commentId}:{}}):{ok:false,reason:i.reason}},applyCustomNodeWrite(o,n){if(!r)return {ok:false,reason:"disposed"};let e=a.resolveStory(n);if(!e.ok)return {ok:false,reason:e.reason};e.store.graftPackage(()=>a.currentPackage());let t=chunkQONAJ66B_cjs.Rf(e.store,o);return t.ok?(a.replacePackageShell(e.store.package),{ok:true,changed:t.change!==null}):{ok:false,reason:t.detail?`${t.reason}: ${t.detail}`:t.reason}},save:()=>r?chunkQONAJ66B_cjs.yb(a.currentPackage()):null,subscribe:o=>a.subscribe(()=>o()),dispose(){r=false;}}}Object.defineProperty(exports,"AUTOMATION_COMMAND_OPERATIONS",{enumerable:true,get:function(){return chunk5LFOW7UO_cjs.c}});Object.defineProperty(exports,"AUTOMATION_QUERY_OPERATIONS",{enumerable:true,get:function(){return chunk5LFOW7UO_cjs.b}});Object.defineProperty(exports,"AUTOMATION_SOLITARY_OPERATIONS",{enumerable:true,get:function(){return chunk5LFOW7UO_cjs.d}});Object.defineProperty(exports,"HEADER_FOOTER_VARIANTS",{enumerable:true,get:function(){return chunk5LFOW7UO_cjs.a}});Object.defineProperty(exports,"isAutomationCommand",{enumerable:true,get:function(){return chunk5LFOW7UO_cjs.f}});Object.defineProperty(exports,"isSolitaryAutomationCommand",{enumerable:true,get:function(){return chunk5LFOW7UO_cjs.e}});exports.SERVER_AUTOMATION_CAPABILITIES=I;exports.createServerAutomationHost=L;
1
+ 'use strict';var chunkYMIMLEX4_cjs=require('./chunk-YMIMLEX4.cjs'),chunkEQO762XH_cjs=require('./chunk-EQO762XH.cjs');var I=Object.freeze({document:true,save:true,events:true,selection:false,scrolling:false,layout:false}),D=Object.freeze({kind:"body"});function L(a,r={}){let o=chunkEQO762XH_cjs.xb(a,r.limits??{});if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let n=o.package.parts.get(o.package.mainDocumentPart);if(!n)return {ok:false,reason:"no-main-document-part",detail:o.package.mainDocumentPart};let e=new chunkEQO762XH_cjs.Ff(o.package,chunkEQO762XH_cjs.Qc(n));return {ok:true,host:chunkYMIMLEX4_cjs.g({port:M(e),capabilities:I})}}function j(a,r,o){let n=a.partFor(o);if(!n)return null;let e=chunkEQO762XH_cjs.Sc(a.currentPackage(),r,n.name);return e?(a.replacePackageShell(e.pkg),e.relationshipId):null}function M(a){let r=true;return {revision:()=>a.packageRevision,currentPackage:()=>r?a.currentPackage():null,apply(o,n=D){if(!r)return {ok:false,reason:"disposed"};let e=o(i=>j(a,i,n));if(e===null)return {ok:false,reason:"unsupported-target"};let t=a.transact(n,i=>{for(let u of e)i.apply(u);});return t.ok?{ok:true,changed:t.change!==null}:{ok:false,reason:t.detail?`${t.reason}: ${t.detail}`:t.reason}},applyLifecycle(o){if(!r)return {ok:false,reason:"disposed"};let n=a.applyLifecycleOp(o);return n.ok?{ok:true,changed:n.change!==null}:{ok:false,reason:n.detail?`${n.reason}: ${n.detail}`:n.reason}},applyCommentWrites(o,n){if(!r)return {ok:false,reason:"disposed"};if(o.length===0)return {ok:true,changed:false};let e=a.resolveStory(n);if(!e.ok)return {ok:false,reason:e.reason};if(e.store.graftPackage(()=>a.currentPackage()),o.every(u=>u.kind==="delete")){let u=false,l=false,x=e.store.transact(T=>{T.applyPackage(d=>{let m=d;for(let s of o){if(s.kind!=="delete")continue;let A={storyPartName:e.store.part.name,...s.noteId===void 0?{}:{noteId:s.noteId}},p=s.parentCommentId===void 0?chunkEQO762XH_cjs.Je(m,s.commentId,A):chunkEQO762XH_cjs.Ke(m,s.commentId,s.parentCommentId,A);if(p===null)return u=true,d;l||=p!==m,m=p;}return m});});return u||!x.ok?{ok:false,reason:"comment-delete-refused"}:(l&&a.installPackageSnapshot(e.store.package),{ok:true,changed:l})}if(o.length!==1)return {ok:false,reason:"mixed-comment-writes"};let t=o[0],i=t.kind==="create"?chunkEQO762XH_cjs.Kf(e.store,{anchor:t.anchor,author:t.author,text:t.text,...t.date===void 0?{}:{date:t.date}}):t.kind==="reply"?chunkEQO762XH_cjs.Kf(e.store,{anchor:t.anchor,author:t.author,text:t.text,...t.date===void 0?{}:{date:t.date},replyToCommentId:t.parentCommentId}):t.kind==="resolve"?chunkEQO762XH_cjs.Lf(e.store,t.commentId,t.resolved):null;return i===null?{ok:false,reason:"unsupported-comment-write"}:i.ok?(a.replacePackageShell(e.store.package),{ok:true,changed:true,..."commentId"in i?{commentId:i.commentId}:{}}):{ok:false,reason:i.reason}},applyCustomNodeWrite(o,n){if(!r)return {ok:false,reason:"disposed"};let e=a.resolveStory(n);if(!e.ok)return {ok:false,reason:e.reason};e.store.graftPackage(()=>a.currentPackage());let t=chunkEQO762XH_cjs.Rf(e.store,o);return t.ok?(a.replacePackageShell(e.store.package),{ok:true,changed:t.change!==null}):{ok:false,reason:t.detail?`${t.reason}: ${t.detail}`:t.reason}},save:()=>r?chunkEQO762XH_cjs.yb(a.currentPackage()):null,subscribe:o=>a.subscribe(()=>o()),dispose(){r=false;}}}Object.defineProperty(exports,"AUTOMATION_COMMAND_OPERATIONS",{enumerable:true,get:function(){return chunkYMIMLEX4_cjs.c}});Object.defineProperty(exports,"AUTOMATION_QUERY_OPERATIONS",{enumerable:true,get:function(){return chunkYMIMLEX4_cjs.b}});Object.defineProperty(exports,"AUTOMATION_SOLITARY_OPERATIONS",{enumerable:true,get:function(){return chunkYMIMLEX4_cjs.d}});Object.defineProperty(exports,"HEADER_FOOTER_VARIANTS",{enumerable:true,get:function(){return chunkYMIMLEX4_cjs.a}});Object.defineProperty(exports,"isAutomationCommand",{enumerable:true,get:function(){return chunkYMIMLEX4_cjs.f}});Object.defineProperty(exports,"isSolitaryAutomationCommand",{enumerable:true,get:function(){return chunkYMIMLEX4_cjs.e}});exports.SERVER_AUTOMATION_CAPABILITIES=I;exports.createServerAutomationHost=L;
@@ -1,5 +1,5 @@
1
- import { A as AutomationCapabilities, a as AutomationHost } from './protocol-DAs0YOP3.cjs';
2
- export { b as AUTOMATION_COMMAND_OPERATIONS, c as AUTOMATION_QUERY_OPERATIONS, d as AUTOMATION_SOLITARY_OPERATIONS, e as AutomationAlignment, f as AutomationBatchRequest, g as AutomationBatchResponse, h as AutomationChangeEvent, i as AutomationContentControlLock, j as AutomationContentControlRangeLocation, k as AutomationContentControlScope, l as AutomationContentControlSubtype, m as AutomationContentControlValue, n as AutomationError, o as AutomationErrorCode, p as AutomationFontRead, q as AutomationFontWrite, r as AutomationHandle, s as AutomationHandleRef, t as AutomationObjectKind, u as AutomationOperation, v as AutomationOperationKind, w as AutomationOperationResult, x as AutomationPageOrientation, y as AutomationPageSetupRead, z as AutomationPageSetupWrite, B as AutomationParagraphFormatRead, C as AutomationParagraphFormatWrite, D as AutomationParagraphRef, E as AutomationPoint, F as AutomationSaveResult, G as AutomationSearchOptions, H as AutomationSelectionMode, I as AutomationSpan, J as AutomationSpanRef, K as AutomationUnsubscribe, L as AutomationValue, M as isAutomationCommand, N as isSolitaryAutomationCommand } from './protocol-DAs0YOP3.cjs';
1
+ import { A as AutomationCapabilities, a as AutomationHost } from './protocol-CD7slqvl.cjs';
2
+ export { b as AUTOMATION_COMMAND_OPERATIONS, c as AUTOMATION_QUERY_OPERATIONS, d as AUTOMATION_SOLITARY_OPERATIONS, e as AutomationAlignment, f as AutomationBatchRequest, g as AutomationBatchResponse, h as AutomationChangeEvent, i as AutomationContentControlLock, j as AutomationContentControlRangeLocation, k as AutomationContentControlScope, l as AutomationContentControlSubtype, m as AutomationContentControlValue, n as AutomationError, o as AutomationErrorCode, p as AutomationFontRead, q as AutomationFontWrite, r as AutomationHandle, s as AutomationHandleRef, t as AutomationObjectKind, u as AutomationOperation, v as AutomationOperationKind, w as AutomationOperationResult, x as AutomationPageOrientation, y as AutomationPageSetupRead, z as AutomationPageSetupWrite, B as AutomationParagraphFormatRead, C as AutomationParagraphFormatWrite, D as AutomationParagraphRef, E as AutomationPoint, F as AutomationSaveResult, G as AutomationSearchOptions, H as AutomationSelectionMode, I as AutomationSpan, J as AutomationSpanRef, K as AutomationUnsubscribe, L as AutomationValue, M as isAutomationCommand, N as isSolitaryAutomationCommand } from './protocol-CD7slqvl.cjs';
3
3
  import { H as HeaderFooterVariant } from './hf-references-CgEOSw3i.cjs';
4
4
  import { N as NoteKind } from './note-nodes-C6DLxlvj.cjs';
5
5
  import { a as OoxmlPackageLimits, b as OoxmlPackageRejection } from './ooxml-package-CR5us6ad.cjs';
@@ -1,5 +1,5 @@
1
- import { A as AutomationCapabilities, a as AutomationHost } from './protocol-r6hje8Kf.js';
2
- export { b as AUTOMATION_COMMAND_OPERATIONS, c as AUTOMATION_QUERY_OPERATIONS, d as AUTOMATION_SOLITARY_OPERATIONS, e as AutomationAlignment, f as AutomationBatchRequest, g as AutomationBatchResponse, h as AutomationChangeEvent, i as AutomationContentControlLock, j as AutomationContentControlRangeLocation, k as AutomationContentControlScope, l as AutomationContentControlSubtype, m as AutomationContentControlValue, n as AutomationError, o as AutomationErrorCode, p as AutomationFontRead, q as AutomationFontWrite, r as AutomationHandle, s as AutomationHandleRef, t as AutomationObjectKind, u as AutomationOperation, v as AutomationOperationKind, w as AutomationOperationResult, x as AutomationPageOrientation, y as AutomationPageSetupRead, z as AutomationPageSetupWrite, B as AutomationParagraphFormatRead, C as AutomationParagraphFormatWrite, D as AutomationParagraphRef, E as AutomationPoint, F as AutomationSaveResult, G as AutomationSearchOptions, H as AutomationSelectionMode, I as AutomationSpan, J as AutomationSpanRef, K as AutomationUnsubscribe, L as AutomationValue, M as isAutomationCommand, N as isSolitaryAutomationCommand } from './protocol-r6hje8Kf.js';
1
+ import { A as AutomationCapabilities, a as AutomationHost } from './protocol-DsbfgBwA.js';
2
+ export { b as AUTOMATION_COMMAND_OPERATIONS, c as AUTOMATION_QUERY_OPERATIONS, d as AUTOMATION_SOLITARY_OPERATIONS, e as AutomationAlignment, f as AutomationBatchRequest, g as AutomationBatchResponse, h as AutomationChangeEvent, i as AutomationContentControlLock, j as AutomationContentControlRangeLocation, k as AutomationContentControlScope, l as AutomationContentControlSubtype, m as AutomationContentControlValue, n as AutomationError, o as AutomationErrorCode, p as AutomationFontRead, q as AutomationFontWrite, r as AutomationHandle, s as AutomationHandleRef, t as AutomationObjectKind, u as AutomationOperation, v as AutomationOperationKind, w as AutomationOperationResult, x as AutomationPageOrientation, y as AutomationPageSetupRead, z as AutomationPageSetupWrite, B as AutomationParagraphFormatRead, C as AutomationParagraphFormatWrite, D as AutomationParagraphRef, E as AutomationPoint, F as AutomationSaveResult, G as AutomationSearchOptions, H as AutomationSelectionMode, I as AutomationSpan, J as AutomationSpanRef, K as AutomationUnsubscribe, L as AutomationValue, M as isAutomationCommand, N as isSolitaryAutomationCommand } from './protocol-DsbfgBwA.js';
3
3
  import { H as HeaderFooterVariant } from './hf-references-BdjsQNE_.js';
4
4
  import { N as NoteKind } from './note-nodes-BPSTVDMr.js';
5
5
  import { a as OoxmlPackageLimits, b as OoxmlPackageRejection } from './ooxml-package-D_CtywTW.js';
@@ -1 +1 @@
1
- import {g}from'./chunk-YTRVI333.js';export{c as AUTOMATION_COMMAND_OPERATIONS,b as AUTOMATION_QUERY_OPERATIONS,d as AUTOMATION_SOLITARY_OPERATIONS,a as HEADER_FOOTER_VARIANTS,f as isAutomationCommand,e as isSolitaryAutomationCommand}from'./chunk-YTRVI333.js';import {xb,Ff,Qc,yb,Rf,Je,Ke,Kf,Lf,Sc}from'./chunk-2H6LCX4H.js';var I=Object.freeze({document:true,save:true,events:true,selection:false,scrolling:false,layout:false}),D=Object.freeze({kind:"body"});function L(a,r={}){let o=xb(a,r.limits??{});if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let n=o.package.parts.get(o.package.mainDocumentPart);if(!n)return {ok:false,reason:"no-main-document-part",detail:o.package.mainDocumentPart};let e=new Ff(o.package,Qc(n));return {ok:true,host:g({port:M(e),capabilities:I})}}function j(a,r,o){let n=a.partFor(o);if(!n)return null;let e=Sc(a.currentPackage(),r,n.name);return e?(a.replacePackageShell(e.pkg),e.relationshipId):null}function M(a){let r=true;return {revision:()=>a.packageRevision,currentPackage:()=>r?a.currentPackage():null,apply(o,n=D){if(!r)return {ok:false,reason:"disposed"};let e=o(i=>j(a,i,n));if(e===null)return {ok:false,reason:"unsupported-target"};let t=a.transact(n,i=>{for(let u of e)i.apply(u);});return t.ok?{ok:true,changed:t.change!==null}:{ok:false,reason:t.detail?`${t.reason}: ${t.detail}`:t.reason}},applyLifecycle(o){if(!r)return {ok:false,reason:"disposed"};let n=a.applyLifecycleOp(o);return n.ok?{ok:true,changed:n.change!==null}:{ok:false,reason:n.detail?`${n.reason}: ${n.detail}`:n.reason}},applyCommentWrites(o,n){if(!r)return {ok:false,reason:"disposed"};if(o.length===0)return {ok:true,changed:false};let e=a.resolveStory(n);if(!e.ok)return {ok:false,reason:e.reason};if(e.store.graftPackage(()=>a.currentPackage()),o.every(u=>u.kind==="delete")){let u=false,l=false,x=e.store.transact(T=>{T.applyPackage(d=>{let m=d;for(let s of o){if(s.kind!=="delete")continue;let A={storyPartName:e.store.part.name,...s.noteId===void 0?{}:{noteId:s.noteId}},p=s.parentCommentId===void 0?Je(m,s.commentId,A):Ke(m,s.commentId,s.parentCommentId,A);if(p===null)return u=true,d;l||=p!==m,m=p;}return m});});return u||!x.ok?{ok:false,reason:"comment-delete-refused"}:(l&&a.installPackageSnapshot(e.store.package),{ok:true,changed:l})}if(o.length!==1)return {ok:false,reason:"mixed-comment-writes"};let t=o[0],i=t.kind==="create"?Kf(e.store,{anchor:t.anchor,author:t.author,text:t.text,...t.date===void 0?{}:{date:t.date}}):t.kind==="reply"?Kf(e.store,{anchor:t.anchor,author:t.author,text:t.text,...t.date===void 0?{}:{date:t.date},replyToCommentId:t.parentCommentId}):t.kind==="resolve"?Lf(e.store,t.commentId,t.resolved):null;return i===null?{ok:false,reason:"unsupported-comment-write"}:i.ok?(a.replacePackageShell(e.store.package),{ok:true,changed:true,..."commentId"in i?{commentId:i.commentId}:{}}):{ok:false,reason:i.reason}},applyCustomNodeWrite(o,n){if(!r)return {ok:false,reason:"disposed"};let e=a.resolveStory(n);if(!e.ok)return {ok:false,reason:e.reason};e.store.graftPackage(()=>a.currentPackage());let t=Rf(e.store,o);return t.ok?(a.replacePackageShell(e.store.package),{ok:true,changed:t.change!==null}):{ok:false,reason:t.detail?`${t.reason}: ${t.detail}`:t.reason}},save:()=>r?yb(a.currentPackage()):null,subscribe:o=>a.subscribe(()=>o()),dispose(){r=false;}}}export{I as SERVER_AUTOMATION_CAPABILITIES,L as createServerAutomationHost};
1
+ import {g}from'./chunk-ZACHY6OS.js';export{c as AUTOMATION_COMMAND_OPERATIONS,b as AUTOMATION_QUERY_OPERATIONS,d as AUTOMATION_SOLITARY_OPERATIONS,a as HEADER_FOOTER_VARIANTS,f as isAutomationCommand,e as isSolitaryAutomationCommand}from'./chunk-ZACHY6OS.js';import {xb,Ff,Qc,yb,Rf,Je,Ke,Kf,Lf,Sc}from'./chunk-TCX3PVWR.js';var I=Object.freeze({document:true,save:true,events:true,selection:false,scrolling:false,layout:false}),D=Object.freeze({kind:"body"});function L(a,r={}){let o=xb(a,r.limits??{});if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let n=o.package.parts.get(o.package.mainDocumentPart);if(!n)return {ok:false,reason:"no-main-document-part",detail:o.package.mainDocumentPart};let e=new Ff(o.package,Qc(n));return {ok:true,host:g({port:M(e),capabilities:I})}}function j(a,r,o){let n=a.partFor(o);if(!n)return null;let e=Sc(a.currentPackage(),r,n.name);return e?(a.replacePackageShell(e.pkg),e.relationshipId):null}function M(a){let r=true;return {revision:()=>a.packageRevision,currentPackage:()=>r?a.currentPackage():null,apply(o,n=D){if(!r)return {ok:false,reason:"disposed"};let e=o(i=>j(a,i,n));if(e===null)return {ok:false,reason:"unsupported-target"};let t=a.transact(n,i=>{for(let u of e)i.apply(u);});return t.ok?{ok:true,changed:t.change!==null}:{ok:false,reason:t.detail?`${t.reason}: ${t.detail}`:t.reason}},applyLifecycle(o){if(!r)return {ok:false,reason:"disposed"};let n=a.applyLifecycleOp(o);return n.ok?{ok:true,changed:n.change!==null}:{ok:false,reason:n.detail?`${n.reason}: ${n.detail}`:n.reason}},applyCommentWrites(o,n){if(!r)return {ok:false,reason:"disposed"};if(o.length===0)return {ok:true,changed:false};let e=a.resolveStory(n);if(!e.ok)return {ok:false,reason:e.reason};if(e.store.graftPackage(()=>a.currentPackage()),o.every(u=>u.kind==="delete")){let u=false,l=false,x=e.store.transact(T=>{T.applyPackage(d=>{let m=d;for(let s of o){if(s.kind!=="delete")continue;let A={storyPartName:e.store.part.name,...s.noteId===void 0?{}:{noteId:s.noteId}},p=s.parentCommentId===void 0?Je(m,s.commentId,A):Ke(m,s.commentId,s.parentCommentId,A);if(p===null)return u=true,d;l||=p!==m,m=p;}return m});});return u||!x.ok?{ok:false,reason:"comment-delete-refused"}:(l&&a.installPackageSnapshot(e.store.package),{ok:true,changed:l})}if(o.length!==1)return {ok:false,reason:"mixed-comment-writes"};let t=o[0],i=t.kind==="create"?Kf(e.store,{anchor:t.anchor,author:t.author,text:t.text,...t.date===void 0?{}:{date:t.date}}):t.kind==="reply"?Kf(e.store,{anchor:t.anchor,author:t.author,text:t.text,...t.date===void 0?{}:{date:t.date},replyToCommentId:t.parentCommentId}):t.kind==="resolve"?Lf(e.store,t.commentId,t.resolved):null;return i===null?{ok:false,reason:"unsupported-comment-write"}:i.ok?(a.replacePackageShell(e.store.package),{ok:true,changed:true,..."commentId"in i?{commentId:i.commentId}:{}}):{ok:false,reason:i.reason}},applyCustomNodeWrite(o,n){if(!r)return {ok:false,reason:"disposed"};let e=a.resolveStory(n);if(!e.ok)return {ok:false,reason:e.reason};e.store.graftPackage(()=>a.currentPackage());let t=Rf(e.store,o);return t.ok?(a.replacePackageShell(e.store.package),{ok:true,changed:t.change!==null}):{ok:false,reason:t.detail?`${t.reason}: ${t.detail}`:t.reason}},save:()=>r?yb(a.currentPackage()):null,subscribe:o=>a.subscribe(()=>o()),dispose(){r=false;}}}export{I as SERVER_AUTOMATION_CAPABILITIES,L as createServerAutomationHost};
package/dist/binding.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var chunkJ6743NQP_cjs=require('./chunk-J6743NQP.cjs');require('./chunk-BS554B6D.cjs'),require('./chunk-UKI45YR7.cjs'),require('./chunk-QONAJ66B.cjs');Object.defineProperty(exports,"PROJECTION_ORIGIN",{enumerable:true,get:function(){return chunkJ6743NQP_cjs.k}});Object.defineProperty(exports,"bodyParagraphs",{enumerable:true,get:function(){return chunkJ6743NQP_cjs.c}});Object.defineProperty(exports,"docToTreeOps",{enumerable:true,get:function(){return chunkJ6743NQP_cjs.f}});Object.defineProperty(exports,"mountTreeSurface",{enumerable:true,get:function(){return chunkJ6743NQP_cjs.l}});Object.defineProperty(exports,"openTreeSession",{enumerable:true,get:function(){return chunkJ6743NQP_cjs.j}});Object.defineProperty(exports,"partHasNode",{enumerable:true,get:function(){return chunkJ6743NQP_cjs.g}});Object.defineProperty(exports,"reconcileDoc",{enumerable:true,get:function(){return chunkJ6743NQP_cjs.h}});Object.defineProperty(exports,"runPropsOf",{enumerable:true,get:function(){return chunkJ6743NQP_cjs.b}});Object.defineProperty(exports,"treeSchema",{enumerable:true,get:function(){return chunkJ6743NQP_cjs.a}});Object.defineProperty(exports,"treeToDoc",{enumerable:true,get:function(){return chunkJ6743NQP_cjs.e}});
1
+ 'use strict';var chunkGWG5IVVX_cjs=require('./chunk-GWG5IVVX.cjs');require('./chunk-BS554B6D.cjs'),require('./chunk-MHDO6HLI.cjs'),require('./chunk-EQO762XH.cjs');Object.defineProperty(exports,"PROJECTION_ORIGIN",{enumerable:true,get:function(){return chunkGWG5IVVX_cjs.k}});Object.defineProperty(exports,"bodyParagraphs",{enumerable:true,get:function(){return chunkGWG5IVVX_cjs.c}});Object.defineProperty(exports,"docToTreeOps",{enumerable:true,get:function(){return chunkGWG5IVVX_cjs.f}});Object.defineProperty(exports,"mountTreeSurface",{enumerable:true,get:function(){return chunkGWG5IVVX_cjs.l}});Object.defineProperty(exports,"openTreeSession",{enumerable:true,get:function(){return chunkGWG5IVVX_cjs.j}});Object.defineProperty(exports,"partHasNode",{enumerable:true,get:function(){return chunkGWG5IVVX_cjs.g}});Object.defineProperty(exports,"reconcileDoc",{enumerable:true,get:function(){return chunkGWG5IVVX_cjs.h}});Object.defineProperty(exports,"runPropsOf",{enumerable:true,get:function(){return chunkGWG5IVVX_cjs.b}});Object.defineProperty(exports,"treeSchema",{enumerable:true,get:function(){return chunkGWG5IVVX_cjs.a}});Object.defineProperty(exports,"treeToDoc",{enumerable:true,get:function(){return chunkGWG5IVVX_cjs.e}});
@@ -1,17 +1,17 @@
1
1
  import { Node, Schema } from 'prosemirror-model';
2
- import { O as OoxmlProperty } from './tree-op-types-UOXlRUqQ.cjs';
3
- import { T as TreeDocxSession } from './tree-session-ZpXtFxlP.cjs';
4
- export { D as DocumentStyleEntry, M as MapResult, O as OpenTreeSessionResult, P as PROJECTION_ORIGIN, a as TreeApplyResult, b as TreeBindingRejection, c as TreeSessionRejection, d as bodyParagraphs, e as docToTreeOps, o as openTreeSession, p as partHasNode, r as reconcileDoc, t as treeToDoc } from './tree-session-ZpXtFxlP.cjs';
5
- export { S as StoryScope, a as StoryTargetRejection } from './custom-node-writes-YqISlSRl.cjs';
2
+ import { O as OoxmlProperty } from './tree-op-types-EZXbR8bW.cjs';
3
+ import { T as TreeDocxSession } from './tree-session-DrMm8Cj2.cjs';
4
+ export { D as DocumentStyleEntry, M as MapResult, O as OpenTreeSessionResult, P as PROJECTION_ORIGIN, a as TreeApplyResult, b as TreeBindingRejection, c as TreeSessionRejection, d as bodyParagraphs, e as docToTreeOps, o as openTreeSession, p as partHasNode, r as reconcileDoc, t as treeToDoc } from './tree-session-DrMm8Cj2.cjs';
5
+ export { S as StoryScope, a as StoryTargetRejection } from './custom-node-writes-C5YRoPcc.cjs';
6
6
  import { EditorView } from 'prosemirror-view';
7
7
  import './ooxml-tree-BU0e3DVi.cjs';
8
- import './image-resources-DwpNnTg3.cjs';
8
+ import './image-resources-DXvPZvXD.cjs';
9
9
  import './ooxml-package-CR5us6ad.cjs';
10
- import './review-support-rsyGP5-9.cjs';
10
+ import './review-support-BJ-YjGmD.cjs';
11
11
  import './contracts/modules.cjs';
12
12
  import './revision-projection-72ZApe-g.cjs';
13
13
  import './hf-references-CgEOSw3i.cjs';
14
- import './tree-store-B1lEkdXc.cjs';
14
+ import './tree-store-UYrGKF_Q.cjs';
15
15
  import './note-nodes-C6DLxlvj.cjs';
16
16
 
17
17
  /** Attributes carried by a projected paragraph. */
package/dist/binding.d.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  import { Node, Schema } from 'prosemirror-model';
2
- import { O as OoxmlProperty } from './tree-op-types-DWLCllG7.js';
3
- import { T as TreeDocxSession } from './tree-session-COduYhKr.js';
4
- export { D as DocumentStyleEntry, M as MapResult, O as OpenTreeSessionResult, P as PROJECTION_ORIGIN, a as TreeApplyResult, b as TreeBindingRejection, c as TreeSessionRejection, d as bodyParagraphs, e as docToTreeOps, o as openTreeSession, p as partHasNode, r as reconcileDoc, t as treeToDoc } from './tree-session-COduYhKr.js';
5
- export { S as StoryScope, a as StoryTargetRejection } from './custom-node-writes-ttKuYd0M.js';
2
+ import { O as OoxmlProperty } from './tree-op-types-8a6xyRCN.js';
3
+ import { T as TreeDocxSession } from './tree-session-SucW0znF.js';
4
+ export { D as DocumentStyleEntry, M as MapResult, O as OpenTreeSessionResult, P as PROJECTION_ORIGIN, a as TreeApplyResult, b as TreeBindingRejection, c as TreeSessionRejection, d as bodyParagraphs, e as docToTreeOps, o as openTreeSession, p as partHasNode, r as reconcileDoc, t as treeToDoc } from './tree-session-SucW0znF.js';
5
+ export { S as StoryScope, a as StoryTargetRejection } from './custom-node-writes-BkMgMXxs.js';
6
6
  import { EditorView } from 'prosemirror-view';
7
7
  import './ooxml-tree-BU0e3DVi.js';
8
- import './image-resources-C_YnqPhn.js';
8
+ import './image-resources-BG9DLyW7.js';
9
9
  import './ooxml-package-D_CtywTW.js';
10
- import './review-support-B9ykYpoZ.js';
10
+ import './review-support-DgXTIYBW.js';
11
11
  import './contracts/modules.js';
12
12
  import './revision-projection-DHAkcD_L.js';
13
13
  import './hf-references-BdjsQNE_.js';
14
- import './tree-store-BscFPB7x.js';
14
+ import './tree-store-BoM6eXaL.js';
15
15
  import './note-nodes-BPSTVDMr.js';
16
16
 
17
17
  /** Attributes carried by a projected paragraph. */
package/dist/binding.js CHANGED
@@ -1 +1 @@
1
- export{k as PROJECTION_ORIGIN,c as bodyParagraphs,f as docToTreeOps,l as mountTreeSurface,j as openTreeSession,g as partHasNode,h as reconcileDoc,b as runPropsOf,a as treeSchema,e as treeToDoc}from'./chunk-AMLGAD5Q.js';import'./chunk-4WWEDTTE.js';import'./chunk-G5D7EXZD.js';import'./chunk-2H6LCX4H.js';
1
+ export{k as PROJECTION_ORIGIN,c as bodyParagraphs,f as docToTreeOps,l as mountTreeSurface,j as openTreeSession,g as partHasNode,h as reconcileDoc,b as runPropsOf,a as treeSchema,e as treeToDoc}from'./chunk-LIJPSHRA.js';import'./chunk-4WWEDTTE.js';import'./chunk-33F6TRXO.js';import'./chunk-TCX3PVWR.js';
@@ -1,2 +1,2 @@
1
- import {t,u,G,w as w$1,B as B$1,A,z,yc,Dc,Ea,Ca,Ha,Aa,o,ca,pe,ne as ne$1,Fa,Ja,le,Ga,zb,df,Ze,Ve as Ve$1,Re,Fb,Ra,ba,Kc,la,q as q$1,ua,wa,Zb,kc,Kb,Mb,va,ka,pa,oa}from'./chunk-2H6LCX4H.js';import {strFromU8,strToU8}from'fflate';var $t=["extension","capability","command","query","schema","dependencyKey","runtimePort","result","origin"],At=/^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+$/,Dt=/^@[a-z0-9.-]+\/[a-z0-9.-]+(?:#[a-z0-9]+(?:[/._-][a-z0-9]+)*)?$/;function nt(e){return At.test(e)||Dt.test(e)}function Y(e,t){if(!nt(e))throw new Error(`invalid ${t??"registry"} id ${JSON.stringify(e)}: must be reverse-domain (dev.docx-editor.core.x) or package-owned (@scope/pkg#kind/name)`)}var Ft=/^(\d+)\.(\d+)\.(\d+)$/;function k(e){let t=Ft.exec(e);if(!t)throw new Error(`invalid semantic version: ${JSON.stringify(e)}`);return {major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3])}}function J(e,t){return e.major!==t.major?e.major<t.major?-1:1:e.minor!==t.minor?e.minor<t.minor?-1:1:e.patch!==t.patch?e.patch<t.patch?-1:1:0}function q(e,t){let n=k(e),r=t.trim();if(r==="*")return true;if(r.startsWith("^")){let o=k(r.slice(1));return J(n,o)<0?false:o.major>0?n.major===o.major:o.minor>0?n.major===0&&n.minor===o.minor:n.major===0&&n.minor===0}if(r.includes(" ")){let o=r.split(/\s+/);if(o.length!==2)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let s=true;for(let a of o){let i=a.startsWith(">=")?">=":a.startsWith("<")?"<":null;if(!i)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let d=k(a.slice(i.length)),l=J(n,d);i===">="?s=s&&l>=0:s=s&&l<0;}return s}return J(n,k(r))===0}var h=class extends Error{constructor(n,r,o=[]){super(r);this.code=n;this.responsible=o;this.name="RegistryError";}code;responsible},_e=(e,t)=>`${e}:${t}`;function Lt(e,t={}){let n=new Map;for(let l of e){if(Y(l.id,"extension"),rt(l.version,l.id),n.has(l.id))throw new h("duplicate-extension",`duplicate extension id ${l.id}`,[l.id]);n.set(l.id,l);for(let c of l.contributions)Y(c.id,c.kind),rt(c.version,`${l.id} \u2192 ${c.id}`),c.replaces&&Ht(c.replaces.targetRange,`${l.id} \u2192 replaces ${c.replaces.targetId}`);}for(let l of e){for(let c of l.dependencies??[])if(!n.has(c))throw new h("missing-dependency",`${l.id} requires missing extension ${c}`,[l.id,c]);for(let c of l.conflicts??[])if(n.has(c)){let p=[l.id,c].sort();throw new h("conflict",`extensions ${p[0]} and ${p[1]} conflict`,p)}}Bt(n);let r=new Set(t.availablePorts??[]);for(let l of e)for(let c of l.contributions)c.kind==="runtimePort"&&r.add(c.id);for(let l of e)for(let c of l.requiredPorts??[])if(!r.has(c))throw new h("missing-port",`${l.id} requires unavailable port ${c}`,[l.id,c]);let o=new Map,s=new Map,a=new Map;for(let l of e)for(let c of l.contributions){let p=_e(c.kind,c.id);if(c.replaces){let u=_e(c.kind,c.replaces.targetId),m=a.get(u)??[];m.push({ext:l.id,c}),a.set(u,m);continue}if(s.has(p)){let u=[o.get(p),l.id].sort();throw new h("id-collision",`${c.kind} id ${c.id} registered by both ${u[0]} and ${u[1]}`,u)}s.set(p,c),o.set(p,l.id);}let i=new Map(s);for(let[l,c]of a){let p=s.get(l);if(!p){let f=c[0];throw new h("replacement-target-missing",`${f.ext} replaces missing target ${f.c.replaces.targetId}`,[f.ext,f.c.replaces.targetId])}let u=p.replaceable??{kind:"none"};for(let{ext:f,c:y}of c){if(!q(p.version,y.replaces.targetRange))throw new h("replacement-version-mismatch",`${f} replaces ${y.replaces.targetId}@${p.version} outside range ${y.replaces.targetRange}`,[f,y.replaces.targetId]);if(u.kind==="none")throw new h("unauthorized-replacement",`${y.replaces.targetId} does not authorize replacement (attempted by ${f})`,[f,y.replaces.targetId])}let m=Mt(p,c);i.set(l,m);}return {extensions:n,contributions:i,get:(l,c)=>i.get(_e(l,c))}}function Mt(e,t){let n=e.replaceable??{kind:"none"};if(t.length===1)return t[0].c;if(n.kind==="priority"){let o=[...t].sort((i,d)=>(d.c.replaces.priority??0)-(i.c.replaces.priority??0)),s=o[0].c.replaces.priority??0,a=o.filter(i=>(i.c.replaces.priority??0)===s);if(a.length>1){let i=a.map(d=>d.ext).sort();throw new h("ambiguous-replacement",`multiple replacers of ${e.id} share top priority ${s}: ${i.join(", ")}`,i)}return o[0].c}let r=t.map(o=>o.ext).sort();throw new h("ambiguous-replacement",`multiple replacers of ${e.id}: ${r.join(", ")}`,r)}function Bt(e){let o=new Map,s=[],a=i=>{o.set(i,1),s.push(i);let d=[...e.get(i)?.dependencies??[]].sort();for(let l of d){let c=o.get(l)??0;if(c===1){let p=s.indexOf(l),u=[...s.slice(p),l];throw new h("dependency-cycle",`dependency cycle: ${u.join(" -> ")}`,u)}c===0&&a(l);}s.pop(),o.set(i,2);};for(let i of [...e.keys()].sort())(o.get(i)??0)===0&&a(i);}function rt(e,t){try{k(e);}catch{throw new h("invalid-version",`invalid version ${JSON.stringify(e)} in ${t}`,[t])}}function Ht(e,t){try{q("0.0.0",e);}catch{throw new h("invalid-version",`invalid version range ${JSON.stringify(e)} in ${t}`,[t])}}var S=class extends Error{constructor(t){super(t),this.name="BudgetError";}},M=class e{constructor(t,n){this.label=t;this.capacity=n;this.used=new G(`${t}.budget`,n);}label;capacity;used;children=new Set;activeReservations=0;cleanups=[];disposed=false;carveAmount=0;parent;get inUse(){return this.used.current}get available(){return this.used.remaining}get isDisposed(){return this.disposed}reserve(t){this.assertLive(),this.used.add(t),this.activeReservations+=1;let n=false,r=this;return {amount:t,get released(){return n},release(){n||(n=true,r.used.release(t),r.activeReservations-=1);}}}child(t,n){this.assertLive(),this.used.add(n);let r=new e(t,n);return r.parent=this,r.carveAmount=n,this.children.add(r),r}onRelease(t){this.assertLive(),this.cleanups.push(t);}dispose(){if(this.disposed)return;if(this.children.size>0)throw new S(`${this.label}: cannot release with ${this.children.size} child budget(s) outstanding`);if(this.activeReservations>0)throw new S(`${this.label}: cannot release with ${this.activeReservations} reservation(s) outstanding`);let t=[];for(let n=this.cleanups.length-1;n>=0;n--)try{this.cleanups[n]();}catch(r){t.push(r);}if(this.disposed=true,this.parent&&(this.parent.children.delete(this),this.parent.used.release(this.carveAmount),this.parent=void 0),t.length>0)throw new S(`${this.label}: ${t.length} cleanup error(s); first: ${String(t[0])}`)}assertLive(){if(this.disposed)throw new S(`${this.label}: budget already released`)}};var Q=class extends Error{constructor(n,r){super(r?`cancelled: ${r}`:"cancelled");this.derivedOnly=n;this.name="CancellationError";}derivedOnly},B=class{_cancelled=false;_phase="pre-publication";_reason;cancel(t){this._cancelled=true,t!==void 0&&(this._reason=t);}markPublished(){this._phase="post-publication";}get isCancelled(){return this._cancelled}get phase(){return this._phase}get isPublished(){return this._phase==="post-publication"}get derivedOnly(){return this._cancelled&&this._phase==="post-publication"}get token(){let t=this;return {get isCancelled(){return t._cancelled},get phase(){return t._phase},get derivedOnly(){return t.derivedOnly},checkpoint(){if(t._cancelled)throw new Q(t.derivedOnly,t._reason)}}}};var Z=class extends Error{constructor(n){super(`runtime port not available: ${n}`);this.portId=n;this.name="PortResolutionError";}portId},$e=class{ports=new Map;provide(t,n){return this.ports.set(t,n),this}has(t){return this.ports.has(t)}resolve(t){if(!this.ports.has(t))throw new Z(t);return this.ports.get(t)}missing(t){return t.filter(n=>!this.ports.has(n))}availablePorts(){return [...this.ports.keys()]}clock(){return this.resolve(w$1.clock)}identity(){return this.resolve(w$1.identity)}},Ae=class{constructor(t=0,n=1){this.step=n;this.t=t;}step;t;now(){let t=this.t;return this.t+=this.step,t}},De=class{constructor(t="id"){this.prefix=t;}prefix;n=0;newId(){return this.n+=1,`${this.prefix}-${this.n}`}};function Ut(e){let t=B$1(e.limits),n=Object.freeze({...e.config??{}}),r=e.capacity??t.maxDecompressedBytes,o=e.id??"op",s={id:o,limits:t,config:n,ports:e.ports,budget:new M(`op:${o}`,r),cancellation:new B};return Object.freeze(s)}function Vt(e){e.budget.dispose();}var Le=Object.freeze({maxRecursionDepth:{unit:"depth",phase:"xml-parse"},maxElementCount:{unit:"count",phase:"xml-parse"},maxPartCount:{unit:"count",phase:"package-read"},maxDecompressedBytes:{unit:"bytes",phase:"package-read"},maxCompressedBytes:{unit:"bytes",phase:"package-read"},maxCompressionRatio:{unit:"ratio",phase:"package-read"},maxChunkBytes:{unit:"bytes",phase:"package-read"},maxPaginationPasses:{unit:"passes",phase:"layout"},maxQueueDepth:{unit:"count",phase:"output"}}),ot=Object.keys(Le);function Xt(e,t){return new G(`${Le[t].phase}:${t}`,e[t])}var Fe=class{counter;current=0;peak=0;constructor(t){this.counter=new G("memory",t);}allocate(t){this.counter.add(t),this.current+=t,this.current>this.peak&&(this.peak=this.current);}free(t){this.counter.release(t),this.current=Math.max(0,this.current-t);}get currentBytes(){return this.current}get peakBytes(){return this.peak}reset(){this.counter.release(this.current),this.current=0;}};function jt(){for(let e of ot){let t=A[e],n=z[e];if(!Number.isFinite(t)||t<=0)throw new Error(`default ${e} must be finite > 0`);if(!Number.isFinite(n)||n<=0)throw new Error(`ceiling ${e} must be finite > 0`);if(t>n)throw new Error(`default ${e} exceeds ceiling`)}}function H(e,t=new Set){let n=new WeakSet,r=o=>{if(o===null)return "null";let s=typeof o;if(s==="boolean")return o?"true":"false";if(s==="number"){let a=o;if(!Number.isFinite(a))throw new Error(`non-finite number is not comparable: ${a}`);return Object.is(a,-0)?"0":String(a)}if(s==="string")return JSON.stringify(o);if(s==="bigint")return `${o.toString()}n`;if(Array.isArray(o))return `[${o.map(r).join(",")}]`;if(s==="object"){let a=o;if(n.has(a))throw new Error("cannot canonicalize a cyclic structure");n.add(a);let d=Object.keys(a).filter(l=>!t.has(l)).sort().map(l=>`${JSON.stringify(l)}:${r(a[l])}`).join(",");return n.delete(a),`{${d}}`}throw new Error(`unsupported value type in comparator input: ${s}`)};return r(e)}function Me(e,t){let n=H(e,t),r=0xcbf29ce484222325n,o=0x100000001b3n,s=0xffffffffffffffffn;for(let a=0;a<n.length;a++)r^=BigInt(n.charCodeAt(a)),r=r*o&s;return r.toString(16).padStart(16,"0")}var R="dev.docx-editor.core.comparator",Be={authoredState:{id:`${R}.authored-state`,mode:"canonical-exact",ephemera:["revision","provenance","producedAt","commitId"],note:"canonical normalized authored records; ephemera excluded"},anchor:{id:`${R}.anchor`,mode:"exact",ephemera:[],note:"internal anchor identity/affinity compares exactly"},yjsStateVector:{id:`${R}.yjs-state-vector`,mode:"sync-optimization-only",ephemera:[],note:"exchange optimization only; never proves update or delete-set coverage"},shapedRun:{id:`${R}.shaped-run`,mode:"exact",ephemera:[],note:"glyph ids, clusters, and fixed-point advances compare exactly"},paginationFingerprint:{id:`${R}.pagination-fingerprint`,mode:"exact",ephemera:[],note:"page/column boundaries, break causes, fixed-point geometry compare exactly"},semanticTree:{id:`${R}.semantic-tree`,mode:"exact",ephemera:[],note:"reading order, roles, headings, alt text compare exactly"},hitTest:{id:`${R}.hit-test`,mode:"exact",ephemera:[],note:"resolved hit target and cluster affinity compare exactly"},pdfSemantics:{id:`${R}.pdf-semantics`,mode:"canonical-exact",ephemera:["objectNumber","producer","creationDate","modDate","subsetTag"],note:"canonical semantic PDF objects; container ephemera excluded"},rasterCheckpoint:{id:`${R}.raster-checkpoint`,mode:"tolerance",ephemera:[],note:"documented unavoidable raster comparison; explicit tolerance only"},benchmarkEvidence:{id:`${R}.benchmark-evidence`,mode:"sync-optimization-only",ephemera:[],note:"diagnostic evidence, not an equivalence basis"}};function He(e,t,n,r={}){let o=Be[e];switch(o.mode){case "sync-optimization-only":throw new Error(`${o.id} is not an equivalence basis (${o.note})`);case "tolerance":{if(r.epsilon===void 0)throw new Error(`${o.id} requires an explicit epsilon`);return {equal:it(t,n,r.epsilon)}}case "exact":case "canonical-exact":{let s=o.mode==="canonical-exact"?new Set(o.ephemera):new Set,a=H(t,s),i=H(n,s);return a===i?{equal:true}:{equal:false,left:a,right:i}}}}function Ue(e,t){let n=Be[e];if(n.mode==="tolerance"||n.mode==="sync-optimization-only")throw new Error(`${n.id} has no canonical fingerprint (${n.mode})`);let r=n.mode==="canonical-exact"?new Set(n.ephemera):void 0;return Me(t,r)}function it(e,t,n){return typeof e=="number"&&typeof t=="number"?Number.isFinite(e)&&Number.isFinite(t)&&Math.abs(e-t)<=n:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((r,o)=>it(r,t[o],n)):false}var st=new Set([...t,...u]),at=/^[0-9a-f]{16}$/,Kt=/^[0-9a-f]*$/;function Ve(e){let t=[],n=o=>t.push(o);e.formatVersion!==1&&n(`unsupported formatVersion ${e.formatVersion}`),e.documentId||n("documentId is required"),e.source.kind==="docx"&&!/^[0-9a-f]{64}$/.test(e.source.sha256)&&n("docx source requires a 64-hex sha256");let r=-1;e.steps.forEach((o,s)=>{let a=`step[${s}]`;st.has(o.origin)||n(`${a}: unknown origin ${o.origin}`),(!Number.isInteger(o.baseRevision)||o.baseRevision<0)&&n(`${a}: baseRevision must be a non-negative integer`),o.baseRevision<r&&n(`${a}: baseRevision regressed below ${r}`);let i=o.expect;i.outcome==="applied"?(i.committedRevision===void 0?n(`${a}: applied step needs committedRevision`):i.committedRevision<=o.baseRevision?n(`${a}: committedRevision ${i.committedRevision} must exceed baseRevision ${o.baseRevision}`):r=i.committedRevision,i.modelChange&&Gt(i.modelChange,a,n)):(i.committedRevision!==void 0&&n(`${a}: ${i.outcome} step must not commit a revision`),i.authoredStateHash!==void 0&&n(`${a}: ${i.outcome} step must not change authored state`)),i.authoredStateHash!==void 0&&!at.test(i.authoredStateHash)&&n(`${a}: authoredStateHash must be 16-hex`),i.outputHash!==void 0&&!at.test(i.outputHash)&&n(`${a}: outputHash must be 16-hex`);});for(let o of [...e.snapshots??[],...e.updates??[]])o.documentId!==e.documentId&&n(`envelope documentId ${o.documentId} != ${e.documentId}`),Kt.test(o.bytesHex)||n("envelope bytesHex must be hex"),o.bytesHex.length!==o.byteLength*2&&n(`envelope byteLength ${o.byteLength} disagrees with ${o.bytesHex.length/2} decoded bytes`);return {valid:t.length===0,errors:t}}function Gt(e,t,n){st.has(e.origin)||n(`${t}: modelChange origin ${e.origin} unknown`),e.toRevision<=e.fromRevision&&n(`${t}: modelChange revision must advance`);}function zt(e,t){let n=Ve(e);if(!n.valid)return {ok:false,mismatches:n.errors};let r=[];return t.init(e),e.steps.forEach((o,s)=>{let a=`step[${s}]`,i=t.applyStep(o),d=o.expect;if(i.outcome!==d.outcome){r.push(`${a}: outcome ${i.outcome} != expected ${d.outcome}`);return}if(d.outcome==="applied"&&(i.committedRevision!==d.committedRevision&&r.push(`${a}: revision ${i.committedRevision} != expected ${d.committedRevision}`),d.authoredStateHash!==void 0))if(i.authoredState===void 0)r.push(`${a}: store returned no authored state to hash`);else {He("authoredState",i.authoredState,i.authoredState).equal||r.push(`${a}: authored state is not self-consistent`);let c=lt(i.authoredState);c!==d.authoredStateHash&&r.push(`${a}: authoredStateHash ${c} != expected ${d.authoredStateHash}`);}}),{ok:r.length===0,mismatches:r}}function lt(e){return Ue("authoredState",e)}var Wt=new Map([["embedRegular","regular"],["embedBold","bold"],["embedItalic","italic"],["embedBoldItalic","boldItalic"]]),Yt=32;function pt(e,t){let n=t.replace(/[^0-9a-fA-F]/g,"");if(n.length!==32)return null;let r=new Uint8Array(16);for(let a=0;a<16;a+=1){let i=Number.parseInt(n.slice(a*2,a*2+2),16);if(Number.isNaN(i))return null;r[15-a]=i;}let o=new Uint8Array(e),s=Math.min(Yt,o.length);for(let a=0;a<s;a+=1)o[a]=o[a]^r[a%16];return o}var Xe=(e,t)=>{if(!(e.kind==="textValue"||!("attributes"in e))){for(let n of e.attributes??[])if(n.localName===t)return n.value}},ct=e=>e.kind==="textValue"?[]:e.children??[],dt=e=>e.kind==="textValue"||!("localName"in e)?"":e.localName;function Jt(e,t,n){for(let r of e.relationships.get(t)??[]){if(r.id!==n)continue;if(r.targetMode==="External")return null;let o=q$1(t,r.rawTarget);return o.ok?o.partName:null}return null}function qt(e,t,n={}){if(!t)return [];let r=n.maxFontBytes??16*1024*1024,o=n.maxFonts??64,s=[],a=new Map,i=d=>{if(!(s.length>=o)){if(dt(d)==="font"){let l=Xe(d,"name");if(l&&l.length<=128)for(let c of ct(d)){if(s.length>=o)return;let p=Wt.get(dt(c));if(!p)continue;let u=Xe(c,"id"),m=Xe(c,"fontKey");if(!u||!m)continue;let f=Jt(e,t.name,u);if(!f)continue;let y=e.partBytes.get(f);if(!y||y.length===0||y.length>r)continue;let g=a.get(f);if(g){s.push({family:l,style:p,bytes:g,partName:f});continue}let O=pt(y,m);O&&(a.set(f,O),s.push({family:l,style:p,bytes:O,partName:f}));}}for(let l of ct(d))i(l);}};return i(t.root),s}function ut(e){if(e.kind!=="textValue")for(let t of e.children){if(t.kind==="textValue")continue;if(t.kind==="hyperlink"){let r=Ra(t);if(r!==void 0&&r.length>0)return r}let n=ut(t);if(n!==void 0)return n}}function Qt(e){let t="",n=false,r=o=>{if(!(n||o.kind==="textValue")){if(o.kind==="tab"||o.localName==="ptab"||o.localName==="tab"){n=true;return}if(o.kind==="text"||o.localName==="t"){for(let s of o.children)s.kind==="textValue"&&(t+=s.value);return}for(let s of o.children)r(s);}};return r(e),Dc(t)}function Zt(e,t,n,r){let o=n.filter(d=>{if(r.has(d.blockId))return false;let l=d.level+1;return l>=t.instruction.outlineStart&&l<=t.instruction.outlineEnd}),s=new Set(o.map(d=>d.blockId)),a=yc(e),i=new Map;for(let d of o){let l=Dc(d.text),c=i.get(l);c?c.push(d.blockId):i.set(l,[d.blockId]);}return t.resultParagraphIds.map(d=>{let l=Ea(e,d);if(!l||l.kind==="textValue")return null;let c=ut(l),p=c===void 0?void 0:a.get(c);if(p&&s.has(p.paragraphId)){let f=i.get(Dc(o.find(g=>g.blockId===p.paragraphId)?.text??"")),y=f?.indexOf(p.paragraphId)??-1;return f&&y>=0&&f.splice(y,1),p.paragraphId}let u=Qt(l);if(u.length===0)return null;let m=i.get(u);return !m||m.length===0?null:m.shift()??null})}function C(e){return e.namespaceUri===la?e.localName:`{${e.namespaceUri}}${e.localName}`}function I(e){let t=[];for(let n of e.attributes)t.push(n.namespaceUri===""||n.namespaceUri===la?`${n.localName}=${n.value}`:`{${n.namespaceUri}}${n.localName}=${n.value}`);return t.sort(),t}function ft(e,t){let n=I(e),r=n.length>0?`${C(e)}(${n.join(",")})`:C(e);if(t>=ba)return r;let o=[];for(let s of e.children){if(s.kind==="textValue"){s.value!==""&&o.push(`#${s.value}`);continue}o.push(ft(s,t+1));}return o.sort(),o.length>0?`${r}[${o.join(",")}]`:r}function mt(e){if(!e)return [];let t=[];for(let n of e.children)n.namespaceUri===la&&t.push(ft(n,1));return t.sort(),t}function je(e){if(e.kind==="textValue")return e.value;if(e.kind==="tab")return " ";if(e.kind==="hardBreak")return Zb(e);if(e.kind==="drawing")return kc();if(e.kind==="runProperties"||e.kind==="paragraphProperties"||e.kind==="generic")return "";if(e.kind==="hyperlink"||Kb(e)){let n="",r=e.kind==="hyperlink"?e.children:Mb(e)??[];for(let o of r)n+=je(o);return n}let t="";for(let n of e.children)t+=je(n);return t}function x(e,t){let n=new Map(e);for(let r of t.namespaceBindings)n.set(r.prefix,r.namespaceUri);return n}function U(e,t){try{return va(e,t)}catch(n){if(n instanceof pa&&n.reason==="undeclared-prefix")return `generic-refusal:undeclared-prefix:{${e.namespaceUri}}${e.localName}`;throw n}}function Ke(e,t,n=ua){if(e.kind==="textValue")return;if(e.kind==="runProperties"||e.kind==="paragraphProperties"){let o=x(n,e),s=[];for(let a of e.children)a.namespaceUri!==la&&s.push(U(a,o));s.sort(),t.push(...s);return}if(e.kind==="generic"){t.push(U(e,n));return}if(Kb(e)){t.push(wa(e));return}if(e.kind==="bookmarkStart"||e.kind==="bookmarkEnd"){t.push(va(e,n));return}if(e.kind==="drawing"){t.push(yt(e));return}if(ka(e.kind))return;let r=x(n,e);for(let o of e.children)Ke(o,t,r);}function en(e){return `hyperlink(${e.attributes.map(n=>`${n.namespaceUri}|${n.localName}=${n.value}`).sort().join(",")})`}function tn(e){for(let t of e.children)if(t.kind==="pictureBlipFill")for(let n of t.children){if(n.kind!=="pictureBlip")continue;let r=n.attributes.find(s=>s.localName==="embed"&&s.namespaceUri===oa)?.value,o=n.attributes.find(s=>s.localName==="link"&&s.namespaceUri===oa)?.value;if(r!==void 0)return `embed=${r}`;if(o!==void 0)return `link=${o}`}}function ee(e,t,n){if(e.kind==="textValue")return `#${e.value}`;if(t>=ba)return C(e);let r=x(n,e);if(e.kind==="generic")return U(e,r);let o=I(e),s=o.length>0?`${C(e)}(${o.join(",")})`:C(e),a=[];for(let i of e.children)i.kind!=="textValue"&&a.push(ee(i,t+1,r));return a.sort(),a.length>0?`${s}[${a.join(",")}]`:s}function nn(e,t,n){let r=x(n,e),o=[];for(let s of e.children)if(s.kind!=="textValue"){if(s.kind==="pictureBlipFill"){let a=s.children,i=a.find(l=>l.kind==="pictureBlip"),d=a.filter(l=>l.kind!=="pictureBlip").map(l=>ee(l,t+1,r));if(d.sort(),i&&i.kind==="pictureBlip"){let l=I(i),c=l.length>0?`pictureBlip(${l.join(",")})`:"pictureBlip";o.push(d.length>0?`${c}[${d.join(",")}]`:c);}else for(let l of a)o.push(ee(l,t+1,r));continue}o.push(ee(s,t+1,r));}return o.sort(),o}function Ge(e,t,n){if(e.kind==="textValue")return `#${e.value}`;if(t>=ba)return C(e);let r=x(n,e);if(e.kind==="drawingDocPr"){let i=I(e);return i.length>0?`docPr(${i.join(",")})`:"docPr"}if(e.kind==="picture"){let i=tn(e),d=nn(e,t+1,r),l=i===void 0?"picture":`picture(${i})`;return d.length>0?`${l}[${d.join(",")}]`:l}let o=I(e),s=o.length>0?`${C(e)}(${o.join(",")})`:C(e),a=[];for(let i of e.children){if(i.kind==="picture"){a.push(Ge(i,t+1,r));continue}if(i.kind==="generic"){a.push(U(i,r));continue}i.kind!=="textValue"&&a.push(Ge(i,t+1,r));}return a.length>0?`${s}[${a.join(",")}]`:s}function yt(e){let t=x(ua,e),n=e.children.find(i=>i.kind==="inlineDrawing"||i.kind==="anchoredDrawing");if(!n||n.kind==="textValue")return `drawing(${I(e).join(",")})`;let r=x(t,n),o=I(n),s=o.length>0?`${n.kind}(${o.join(",")})`:n.kind,a=[];for(let i of n.children){if(i.kind==="generic"){a.push(U(i,r));continue}i.kind!=="textValue"&&a.push(Ge(i,1,r));}return a.length>0?`drawing[${s};${a.join(";")}]`:`drawing[${s}]`}function rn(e,t,n){let r=e.children.find(c=>c.kind==="paragraphProperties"),o=[],s="",a=[],i=x(ua,e),d=(c,p)=>{if(c.kind==="run"){let u=x(p,c),m=c.children.find(f=>f.kind==="runProperties");o.push(mt(m)),s+=je(c);for(let f of c.children)Ke(f,a,u);return}if(c.kind==="drawing"){a.push(yt(c));return}if(c.kind==="hyperlink"){a.push(en(c));let u=x(p,c);for(let m of c.children)d(m,u);return}if(c.kind==="contentControl"){a.push(wa({...c,children:c.children.filter(m=>m.kind!=="contentControlContent")}));let u=x(p,c);for(let m of c.children){if(m.kind!=="contentControlContent")continue;let f=x(u,m);for(let y of m.children)d(y,f);}return}Ke(c,a,p);};for(let c of e.children)d(c,i);let l=Kc(e);return {ordinal:t,path:n,paraId:l===null?null:l.toUpperCase(),text:s,paragraphProperties:mt(r),runProperties:o,genericStructure:a}}function on(e){if(e.localName==="hdr"||e.localName==="ftr"||e.kind==="body")return e;for(let t of e.children)if(t.kind!=="textValue"&&(t.kind==="body"||t.localName==="hdr"||t.localName==="ftr"))return t;return e}function gt(e,t,n,r,o,s){if(s>ba)return;let a=0;for(let i of e.children){if(i.kind==="textValue"){i.value.trim()!==""&&o.push(`${t}/#text ${i.value}`);continue}let d=t===""?String(a):`${t}/${a}`;if(a+=1,i.kind==="paragraph"){n.push(i),r.push(d),o.push(`${d} p`);continue}let l=I(i);o.push(l.length>0?`${d} ${C(i)}(${l.join(",")})`:`${d} ${C(i)}`),gt(i,d,n,r,o,s+1);}}function ht(e){let t=on(e.root),n=[],r=[],o=[];gt(t,"",n,r,o,0);let s=n.map((a,i)=>rn(a,i,r[i]));return {partName:e.name,paragraphs:s,structure:o}}function an(e){let t=[];for(let n of e){let r=ht(n);r&&t.push(r);}return {stories:t}}function sn(e,t){let n=[],r=(s,a,i)=>{n.push({path:s,before:JSON.stringify(a)??"undefined",after:JSON.stringify(i)??"undefined"});};e.stories.length!==t.stories.length&&r("stories.length",e.stories.length,t.stories.length);let o=Math.min(e.stories.length,t.stories.length);for(let s=0;s<o;s+=1){let a=e.stories[s],i=t.stories[s],d=p=>`${a.partName}${p}`;a.paragraphs.length!==i.paragraphs.length&&r(d(".paragraphs.length"),a.paragraphs.length,i.paragraphs.length);let l=Math.min(a.paragraphs.length,i.paragraphs.length);for(let p=0;p<l;p+=1){let u=a.paragraphs[p],m=i.paragraphs[p];u.text!==m.text&&r(d(`.p[${p}].text`),u.text,m.text),u.path!==m.path&&r(d(`.p[${p}].path`),u.path,m.path),u.paraId!==m.paraId&&r(d(`.p[${p}].paraId`),u.paraId,m.paraId),JSON.stringify(u.paragraphProperties)!==JSON.stringify(m.paragraphProperties)&&r(d(`.p[${p}].paragraphProperties`),u.paragraphProperties,m.paragraphProperties),JSON.stringify(u.runProperties)!==JSON.stringify(m.runProperties)&&r(d(`.p[${p}].runProperties`),u.runProperties,m.runProperties),JSON.stringify(u.genericStructure)!==JSON.stringify(m.genericStructure)&&r(d(`.p[${p}].genericStructure`),u.genericStructure,m.genericStructure);}a.structure.length!==i.structure.length&&r(d(".structure.length"),a.structure.length,i.structure.length);let c=Math.min(a.structure.length,i.structure.length);for(let p=0;p<c;p+=1)a.structure[p]!==i.structure[p]&&r(d(`.structure[${p}]`),a.structure[p],i.structure[p]);}return n}var V="http://schemas.openxmlformats.org/wordprocessingml/2006/main",dn="http://schemas.openxmlformats.org/package/2006/relationships",xt="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",w="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",pn="application/vnd.openxmlformats-package.relationships+xml",un="http://schemas.openxmlformats.org/package/2006/content-types",Nt="/[Content_Types].xml",E="/word/numbering.xml",Ot=[{text:"\uF0B7",font:"Symbol"},{text:"o",font:"Courier New"},{text:"\uF0A7",font:"Wingdings"}],Rt=["decimal","lowerLetter","lowerRoman"],ze=9;function It(e,t){let n=720*(t+1),r='<w:start w:val="1"/>';if(e==="bullet"){let a=Ot[t%Ot.length];return `<w:lvl w:ilvl="${t}">${r}<w:numFmt w:val="bullet"/><w:lvlText w:val="${a.text}"/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="${n}" w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="${a.font}" w:hAnsi="${a.font}" w:hint="default"/></w:rPr></w:lvl>`}let o=Rt[t%Rt.length],s=o==="lowerRoman";return `<w:lvl w:ilvl="${t}">${r}<w:numFmt w:val="${o}"/><w:lvlText w:val="%${t+1}."/><w:lvlJc w:val="${s?"right":"left"}"/><w:pPr><w:ind w:left="${n}" w:hanging="${s?180:360}"/></w:pPr></w:lvl>`}function mn(e,t){let n=Array.from({length:ze},(r,o)=>It(e,o)).join("");return `<w:abstractNum w:abstractNumId="${t}"><w:multiLevelType w:val="${e==="bullet"?"hybridMultilevel":"multilevel"}"/>${n}</w:abstractNum>`}function fn(){let e=Aa(`<w:numbering xmlns:w="${V}"></w:numbering>`,{name:E,contentType:w});return e.ok?e.part:null}var b=(e,t)=>{let n=[];for(let r of e.children)r.kind==="textValue"||r.localName!==t||r.namespaceUri===V&&n.push(r);return n},N=(e,t)=>e.attributes.find(n=>n.localName===t)?.value;function kt(e,t){let n=Aa(`<w:numbering xmlns:w="${V}">${e}</w:numbering>`,{name:E,contentType:w});if(!n.ok)return null;let r=[];for(let o of n.part.root.children)o.kind!=="textValue"&&r.push(o);if(r.length!==t.length)return null;for(let o=0;o<t.length;o+=1){let s=r[o],a=t[o];if(s.namespaceUri!==V||s.localName!==a.localName||a.attribute&&N(s,a.attribute.localName)!==a.attribute.value)return null}return r}var Ct=["numPicBullet","abstractNum","num","numIdMacAtCleanup"];function bt(e,t,n){let r=t.indexOf(n);if(r===-1)return e.length;let o=0;return e.forEach((s,a)=>{if(s.kind==="textValue")return;let i=t.indexOf(s.localName);i!==-1&&i<=r&&(o=a+1);}),o}function Et(e,t){let n=0;for(let r of e){let o=N(r,t);!o||!/^\d{1,9}$/.test(o)||(n=Math.max(n,Number(o)));}return n+1}function yn(e,t){let n=e.parts.get(E),r=n??fn();if(!r)return null;let o=r.root,s=b(o,"abstractNum"),a=b(o,"num"),i=t==="bullet"?"bullet":"decimal";for(let O of a){let $=N(O,"numId"),Ye=b(O,"abstractNumId")[0],Je=Ye?N(Ye,"val"):void 0;if(!$||!Je)continue;let qe=s.find(X=>N(X,"abstractNumId")===Je);if(!qe)continue;let Qe=b(qe,"lvl").find(X=>N(X,"ilvl")==="0"||N(X,"ilvl")===void 0),Ze=Qe?b(Qe,"numFmt")[0]:void 0;if(Ze&&N(Ze,"val")===i)return {pkg:e,numId:$}}let d=Et(s,"abstractNumId"),l=Et(a,"numId"),c=kt(mn(t,d)+`<w:num w:numId="${l}"><w:abstractNumId w:val="${d}"/></w:num>`,[{localName:"abstractNum",attribute:{localName:"abstractNumId",value:String(d)}},{localName:"num",attribute:{localName:"numId",value:String(l)}}]);if(!c)return null;let p=Ca(r),[u,m]=c.map(O=>te(O,p));if(!u||!m)return null;let f=Ha(r,o.id,bt(o.children,Ct,"abstractNum"),[u]);if(!f.ok)return null;let y=Ha(f.part,o.id,bt(f.part.root.children,Ct,"num"),[m]);if(!y.ok)return null;let g=Object.freeze({...e,parts:new Map([...e.parts,[E,y.part]])});if(!n){let O=Nn(g);if(!O)return null;let $=bn(O);if(!$)return null;g=$;}return {pkg:g,numId:String(l)}}var gn=["nsid","multiLevelType","tmpl","name","styleLink","numStyleLink","lvl"];function St(e){let t=N(e,"ilvl");return t===void 0||!/^\d{1,9}$/.test(t)?null:Number(t)}function hn(e,t){let n=0;return e.forEach((r,o)=>{if(r.kind!=="textValue"){if(r.localName==="lvl"&&r.namespaceUri===V){(St(r)??0)<t&&(n=o+1);return}gn.includes(r.localName)&&(n=o+1);}}),n}function xn(e,t,n,r){if(!Number.isInteger(n)||n<0||n>=ze||t.length===0||t.length>64)return null;let o=e.parts.get(E);if(!o)return null;let s=o.root,a=b(s,"num").find(f=>N(f,"numId")===t),i=a?b(a,"abstractNumId")[0]:void 0,d=i?N(i,"val"):void 0;if(!d)return null;let l=b(s,"abstractNum").find(f=>N(f,"abstractNumId")===d);if(!l||b(l,"numStyleLink").length>0)return null;let c=b(l,"lvl");if(c.some(f=>St(f)===n))return e;if(c.length>=ze)return null;let p=kt(It(r,n),[{localName:"lvl",attribute:{localName:"ilvl",value:String(n)}}]);if(!p)return null;let u=Ca(o),m=Ha(o,l.id,hn(l.children,n),[te(p[0],u)]);return m.ok?Object.freeze({...e,parts:new Map([...e.parts,[E,m.part]])}):null}function te(e,t){return e.kind==="textValue"?{...e,id:t()}:{...e,id:t(),children:e.children.map(n=>te(n,t))}}function Nn(e){let t=e.mainDocumentPart,n=On(t),r=e.parts.get(n),o=Rn(e),s=Aa(`<Relationships xmlns="${dn}"><Relationship Id="${o}" Type="${xt}" Target="numbering.xml"/></Relationships>`,{name:n,contentType:pn});if(!s.ok)return null;let a=e.relationships.get(t)??[],i={ownerPart:t,id:o,type:xt,rawTarget:"numbering.xml",targetMode:"Internal",order:a.reduce((u,m)=>Math.max(u,m.order),-1)+1},d=new Map([...e.relationships,[t,[...a,i]]]);if(!r)return Object.freeze({...e,parts:new Map([...e.parts,[n,s.part]]),relationships:d});let l=Ca(r),c=s.part.root.children[0];if(!c)return null;let p=Ha(r,r.root.id,r.root.children.length,[te(c,l)]);return p.ok?Object.freeze({...e,parts:new Map([...e.parts,[n,p.part]]),relationships:d}):null}function On(e){let t=e.lastIndexOf("/");return `${e.slice(0,t)}/_rels/${e.slice(t+1)}.rels`}function Rn(e){let t=0;for(let n of e.relationships.values())for(let r of n){let o=/^rId(\d{1,9})$/.exec(r.id);o&&(t=Math.max(t,Number(o[1])));}for(let n of e.externalTargets){let r=/^rId(\d{1,9})$/.exec(n.id);r&&(t=Math.max(t,Number(r[1])));}return `rId${t+1}`}var Cn=`<Override PartName="${E}" ContentType="${w}"/>`;function bn(e){let t=e.contentTypes.overrides.get(o(E));if(t===w)return e;if(t!==void 0)return null;let n=e.partBytes.get(Nt);if(!n)return null;let r=strFromU8(n),o$1=Pt(r);if(!o$1)return null;let s=r.lastIndexOf(`</${o$1.rootName}>`);if(s===-1)return null;let a=r.slice(0,s)+Cn+r.slice(s),i=Pt(a);if(!i||i.rootName!==o$1.rootName)return null;let d=[...o$1.children,vt("Override",{PartName:E,ContentType:w})];return i.children.length!==d.length||i.children.some((l,c)=>l!==d[c])?null:Object.freeze({...e,partBytes:new Map([...e.partBytes,[Nt,strToU8(a)]]),contentTypes:Object.freeze({defaults:e.contentTypes.defaults,overrides:new Map([...e.contentTypes.overrides,[o(E),w]])})})}function Pt(e){let t=ca(e);if(!t.ok)return null;let n=t.nodes.filter(i=>i.type==="element");if(n.length!==1)return null;let r=n[0],o=r.name.indexOf(":"),s=o===-1?"":r.name.slice(0,o);if(r.name.slice(o+1)!=="Types"||r.attributes[s?`xmlns:${s}`:"xmlns"]!==un)return null;let a=[];for(let i of r.children)i.type==="element"&&a.push(vt(i.name,i.attributes));return {rootName:r.name,children:a}}function vt(e,t){let n=Object.entries(t).map(([r,o])=>`${r}=${o}`).sort();return [e,...n].join("")}function ne(e){return e!=null&&e.kind!=="textValue"}function We(e,t){for(let n of e.children)if(n.kind!=="textValue"&&n.namespaceUri===la&&n.localName===t)return n;return null}function re(e,t){for(let n of e.attributes)if(n.namespaceUri===la&&n.localName===t)return n.value}function _(e,t){let n=We(e,t);if(!n)return false;let r=re(n,"val");return r===void 0?true:r!=="0"&&r!=="false"&&r!=="off"}var Tt=Object.freeze({trackRevisions:false,restrictedToTrackedChanges:false,doNotTrackMoves:false,doNotTrackFormatting:false});function En(e){if(!ne(e))return Tt;let t=We(e,"documentProtection"),n=t===null?void 0:re(t,"enforcement"),r=n!==void 0&&n!=="0"&&n!=="false"&&n!=="off";return {trackRevisions:_(e,"trackRevisions"),restrictedToTrackedChanges:r&&t!==null&&re(t,"edit")==="trackedChanges",doNotTrackMoves:_(e,"doNotTrackMoves"),doNotTrackFormatting:_(e,"doNotTrackFormatting")}}var wt=Object.freeze({doNotShadeFormData:false});function Pn(e){return ne(e)?{doNotShadeFormData:_(e,"doNotShadeFormData")}:wt}function In(e,t){let n=e.parts.get(t.storyPartName);if(!n)return {ok:false,reason:`no story part named ${t.storyPartName}`};let r=[];for(let d of pe(n.root)){let l=ne$1(d.node).tag;if(l===void 0||l.length===0)continue;let c=t.decide(l);c!=="keep"&&r.push({nodeId:d.node.id,policy:c});}let o=n,s=0,a=0;for(let{nodeId:d,policy:l}of r){let c=Fa(o,d);if(!c)continue;if(l==="remove"){let g=Ja(o,d,{deferValidation:true});if(!g.ok)return {ok:false,reason:`a node could not be removed: ${_t(g)}`};o=g.part,a+=1;continue}let p=c.children.find(g=>g.id===d);if(!p)continue;let u=le(p),m=u?u.children:[],f=c.children.flatMap(g=>g.id===d?m:[g]),y=Ga(o,c.id,f,{deferValidation:true});if(!y.ok)return {ok:false,reason:`a node could not be unwrapped: ${_t(y)}`};o=y.part,s+=1;}let i=o===n?e:zb(e,o);if(!i.parts.has(t.storyPartName))return {ok:false,reason:"the story went missing during the export"};for(let d of t.namespaces)for(let l of Sn(i,t.storyPartName,d)){let c=df(i,l.itemId),p=Ze(i,l.partName,c);if(p.pkg===i&&p.removed.length===0&&!kn(i,l.partName,c))return {ok:false,reason:`the payloads in ${d} could not be removed`};if(i=p.pkg,c.size>0)continue;let u=vn(i,l);if(!u.ok)return {ok:false,reason:`the payload store for ${d} could not be removed`};i=u.pkg;}return {ok:true,pkg:i,unwrapped:s,removed:a}}function kn(e,t,n){return Ve$1(e,t).every(r=>n.has(r.id))}function _t(e){return e.issues.map(t=>t.code).join(", ")||"the edit was refused"}function Sn(e,t,n){return Re(e,t).filter(r=>r.namespaceUri===n)}function vn(e,t){let n=Fb(e,t.partName);if(!n.ok)return {pkg:e,ok:false};let r=Fb(n.pkg,t.propsPartName);return r.ok?{pkg:r.pkg,ok:true}:{pkg:e,ok:false}}
1
+ import {t,u,G,w as w$1,B as B$1,A,z,yc,Dc,Ea,Ca,Ha,Aa,o,ca,pe,ne as ne$1,Fa,Ja,le,Ga,zb,df,Ze,Ve as Ve$1,Re,Fb,Ra,ba,Kc,la,q as q$1,ua,wa,Zb,kc,Kb,Mb,va,ka,pa,oa}from'./chunk-TCX3PVWR.js';import {strFromU8,strToU8}from'fflate';var $t=["extension","capability","command","query","schema","dependencyKey","runtimePort","result","origin"],At=/^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+$/,Dt=/^@[a-z0-9.-]+\/[a-z0-9.-]+(?:#[a-z0-9]+(?:[/._-][a-z0-9]+)*)?$/;function nt(e){return At.test(e)||Dt.test(e)}function Y(e,t){if(!nt(e))throw new Error(`invalid ${t??"registry"} id ${JSON.stringify(e)}: must be reverse-domain (dev.docx-editor.core.x) or package-owned (@scope/pkg#kind/name)`)}var Ft=/^(\d+)\.(\d+)\.(\d+)$/;function k(e){let t=Ft.exec(e);if(!t)throw new Error(`invalid semantic version: ${JSON.stringify(e)}`);return {major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3])}}function J(e,t){return e.major!==t.major?e.major<t.major?-1:1:e.minor!==t.minor?e.minor<t.minor?-1:1:e.patch!==t.patch?e.patch<t.patch?-1:1:0}function q(e,t){let n=k(e),r=t.trim();if(r==="*")return true;if(r.startsWith("^")){let o=k(r.slice(1));return J(n,o)<0?false:o.major>0?n.major===o.major:o.minor>0?n.major===0&&n.minor===o.minor:n.major===0&&n.minor===0}if(r.includes(" ")){let o=r.split(/\s+/);if(o.length!==2)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let s=true;for(let a of o){let i=a.startsWith(">=")?">=":a.startsWith("<")?"<":null;if(!i)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let d=k(a.slice(i.length)),l=J(n,d);i===">="?s=s&&l>=0:s=s&&l<0;}return s}return J(n,k(r))===0}var h=class extends Error{constructor(n,r,o=[]){super(r);this.code=n;this.responsible=o;this.name="RegistryError";}code;responsible},_e=(e,t)=>`${e}:${t}`;function Lt(e,t={}){let n=new Map;for(let l of e){if(Y(l.id,"extension"),rt(l.version,l.id),n.has(l.id))throw new h("duplicate-extension",`duplicate extension id ${l.id}`,[l.id]);n.set(l.id,l);for(let c of l.contributions)Y(c.id,c.kind),rt(c.version,`${l.id} \u2192 ${c.id}`),c.replaces&&Ht(c.replaces.targetRange,`${l.id} \u2192 replaces ${c.replaces.targetId}`);}for(let l of e){for(let c of l.dependencies??[])if(!n.has(c))throw new h("missing-dependency",`${l.id} requires missing extension ${c}`,[l.id,c]);for(let c of l.conflicts??[])if(n.has(c)){let p=[l.id,c].sort();throw new h("conflict",`extensions ${p[0]} and ${p[1]} conflict`,p)}}Bt(n);let r=new Set(t.availablePorts??[]);for(let l of e)for(let c of l.contributions)c.kind==="runtimePort"&&r.add(c.id);for(let l of e)for(let c of l.requiredPorts??[])if(!r.has(c))throw new h("missing-port",`${l.id} requires unavailable port ${c}`,[l.id,c]);let o=new Map,s=new Map,a=new Map;for(let l of e)for(let c of l.contributions){let p=_e(c.kind,c.id);if(c.replaces){let u=_e(c.kind,c.replaces.targetId),m=a.get(u)??[];m.push({ext:l.id,c}),a.set(u,m);continue}if(s.has(p)){let u=[o.get(p),l.id].sort();throw new h("id-collision",`${c.kind} id ${c.id} registered by both ${u[0]} and ${u[1]}`,u)}s.set(p,c),o.set(p,l.id);}let i=new Map(s);for(let[l,c]of a){let p=s.get(l);if(!p){let f=c[0];throw new h("replacement-target-missing",`${f.ext} replaces missing target ${f.c.replaces.targetId}`,[f.ext,f.c.replaces.targetId])}let u=p.replaceable??{kind:"none"};for(let{ext:f,c:y}of c){if(!q(p.version,y.replaces.targetRange))throw new h("replacement-version-mismatch",`${f} replaces ${y.replaces.targetId}@${p.version} outside range ${y.replaces.targetRange}`,[f,y.replaces.targetId]);if(u.kind==="none")throw new h("unauthorized-replacement",`${y.replaces.targetId} does not authorize replacement (attempted by ${f})`,[f,y.replaces.targetId])}let m=Mt(p,c);i.set(l,m);}return {extensions:n,contributions:i,get:(l,c)=>i.get(_e(l,c))}}function Mt(e,t){let n=e.replaceable??{kind:"none"};if(t.length===1)return t[0].c;if(n.kind==="priority"){let o=[...t].sort((i,d)=>(d.c.replaces.priority??0)-(i.c.replaces.priority??0)),s=o[0].c.replaces.priority??0,a=o.filter(i=>(i.c.replaces.priority??0)===s);if(a.length>1){let i=a.map(d=>d.ext).sort();throw new h("ambiguous-replacement",`multiple replacers of ${e.id} share top priority ${s}: ${i.join(", ")}`,i)}return o[0].c}let r=t.map(o=>o.ext).sort();throw new h("ambiguous-replacement",`multiple replacers of ${e.id}: ${r.join(", ")}`,r)}function Bt(e){let o=new Map,s=[],a=i=>{o.set(i,1),s.push(i);let d=[...e.get(i)?.dependencies??[]].sort();for(let l of d){let c=o.get(l)??0;if(c===1){let p=s.indexOf(l),u=[...s.slice(p),l];throw new h("dependency-cycle",`dependency cycle: ${u.join(" -> ")}`,u)}c===0&&a(l);}s.pop(),o.set(i,2);};for(let i of [...e.keys()].sort())(o.get(i)??0)===0&&a(i);}function rt(e,t){try{k(e);}catch{throw new h("invalid-version",`invalid version ${JSON.stringify(e)} in ${t}`,[t])}}function Ht(e,t){try{q("0.0.0",e);}catch{throw new h("invalid-version",`invalid version range ${JSON.stringify(e)} in ${t}`,[t])}}var S=class extends Error{constructor(t){super(t),this.name="BudgetError";}},M=class e{constructor(t,n){this.label=t;this.capacity=n;this.used=new G(`${t}.budget`,n);}label;capacity;used;children=new Set;activeReservations=0;cleanups=[];disposed=false;carveAmount=0;parent;get inUse(){return this.used.current}get available(){return this.used.remaining}get isDisposed(){return this.disposed}reserve(t){this.assertLive(),this.used.add(t),this.activeReservations+=1;let n=false,r=this;return {amount:t,get released(){return n},release(){n||(n=true,r.used.release(t),r.activeReservations-=1);}}}child(t,n){this.assertLive(),this.used.add(n);let r=new e(t,n);return r.parent=this,r.carveAmount=n,this.children.add(r),r}onRelease(t){this.assertLive(),this.cleanups.push(t);}dispose(){if(this.disposed)return;if(this.children.size>0)throw new S(`${this.label}: cannot release with ${this.children.size} child budget(s) outstanding`);if(this.activeReservations>0)throw new S(`${this.label}: cannot release with ${this.activeReservations} reservation(s) outstanding`);let t=[];for(let n=this.cleanups.length-1;n>=0;n--)try{this.cleanups[n]();}catch(r){t.push(r);}if(this.disposed=true,this.parent&&(this.parent.children.delete(this),this.parent.used.release(this.carveAmount),this.parent=void 0),t.length>0)throw new S(`${this.label}: ${t.length} cleanup error(s); first: ${String(t[0])}`)}assertLive(){if(this.disposed)throw new S(`${this.label}: budget already released`)}};var Q=class extends Error{constructor(n,r){super(r?`cancelled: ${r}`:"cancelled");this.derivedOnly=n;this.name="CancellationError";}derivedOnly},B=class{_cancelled=false;_phase="pre-publication";_reason;cancel(t){this._cancelled=true,t!==void 0&&(this._reason=t);}markPublished(){this._phase="post-publication";}get isCancelled(){return this._cancelled}get phase(){return this._phase}get isPublished(){return this._phase==="post-publication"}get derivedOnly(){return this._cancelled&&this._phase==="post-publication"}get token(){let t=this;return {get isCancelled(){return t._cancelled},get phase(){return t._phase},get derivedOnly(){return t.derivedOnly},checkpoint(){if(t._cancelled)throw new Q(t.derivedOnly,t._reason)}}}};var Z=class extends Error{constructor(n){super(`runtime port not available: ${n}`);this.portId=n;this.name="PortResolutionError";}portId},$e=class{ports=new Map;provide(t,n){return this.ports.set(t,n),this}has(t){return this.ports.has(t)}resolve(t){if(!this.ports.has(t))throw new Z(t);return this.ports.get(t)}missing(t){return t.filter(n=>!this.ports.has(n))}availablePorts(){return [...this.ports.keys()]}clock(){return this.resolve(w$1.clock)}identity(){return this.resolve(w$1.identity)}},Ae=class{constructor(t=0,n=1){this.step=n;this.t=t;}step;t;now(){let t=this.t;return this.t+=this.step,t}},De=class{constructor(t="id"){this.prefix=t;}prefix;n=0;newId(){return this.n+=1,`${this.prefix}-${this.n}`}};function Ut(e){let t=B$1(e.limits),n=Object.freeze({...e.config??{}}),r=e.capacity??t.maxDecompressedBytes,o=e.id??"op",s={id:o,limits:t,config:n,ports:e.ports,budget:new M(`op:${o}`,r),cancellation:new B};return Object.freeze(s)}function Vt(e){e.budget.dispose();}var Le=Object.freeze({maxRecursionDepth:{unit:"depth",phase:"xml-parse"},maxElementCount:{unit:"count",phase:"xml-parse"},maxPartCount:{unit:"count",phase:"package-read"},maxDecompressedBytes:{unit:"bytes",phase:"package-read"},maxCompressedBytes:{unit:"bytes",phase:"package-read"},maxCompressionRatio:{unit:"ratio",phase:"package-read"},maxChunkBytes:{unit:"bytes",phase:"package-read"},maxPaginationPasses:{unit:"passes",phase:"layout"},maxQueueDepth:{unit:"count",phase:"output"}}),ot=Object.keys(Le);function Xt(e,t){return new G(`${Le[t].phase}:${t}`,e[t])}var Fe=class{counter;current=0;peak=0;constructor(t){this.counter=new G("memory",t);}allocate(t){this.counter.add(t),this.current+=t,this.current>this.peak&&(this.peak=this.current);}free(t){this.counter.release(t),this.current=Math.max(0,this.current-t);}get currentBytes(){return this.current}get peakBytes(){return this.peak}reset(){this.counter.release(this.current),this.current=0;}};function jt(){for(let e of ot){let t=A[e],n=z[e];if(!Number.isFinite(t)||t<=0)throw new Error(`default ${e} must be finite > 0`);if(!Number.isFinite(n)||n<=0)throw new Error(`ceiling ${e} must be finite > 0`);if(t>n)throw new Error(`default ${e} exceeds ceiling`)}}function H(e,t=new Set){let n=new WeakSet,r=o=>{if(o===null)return "null";let s=typeof o;if(s==="boolean")return o?"true":"false";if(s==="number"){let a=o;if(!Number.isFinite(a))throw new Error(`non-finite number is not comparable: ${a}`);return Object.is(a,-0)?"0":String(a)}if(s==="string")return JSON.stringify(o);if(s==="bigint")return `${o.toString()}n`;if(Array.isArray(o))return `[${o.map(r).join(",")}]`;if(s==="object"){let a=o;if(n.has(a))throw new Error("cannot canonicalize a cyclic structure");n.add(a);let d=Object.keys(a).filter(l=>!t.has(l)).sort().map(l=>`${JSON.stringify(l)}:${r(a[l])}`).join(",");return n.delete(a),`{${d}}`}throw new Error(`unsupported value type in comparator input: ${s}`)};return r(e)}function Me(e,t){let n=H(e,t),r=0xcbf29ce484222325n,o=0x100000001b3n,s=0xffffffffffffffffn;for(let a=0;a<n.length;a++)r^=BigInt(n.charCodeAt(a)),r=r*o&s;return r.toString(16).padStart(16,"0")}var R="dev.docx-editor.core.comparator",Be={authoredState:{id:`${R}.authored-state`,mode:"canonical-exact",ephemera:["revision","provenance","producedAt","commitId"],note:"canonical normalized authored records; ephemera excluded"},anchor:{id:`${R}.anchor`,mode:"exact",ephemera:[],note:"internal anchor identity/affinity compares exactly"},yjsStateVector:{id:`${R}.yjs-state-vector`,mode:"sync-optimization-only",ephemera:[],note:"exchange optimization only; never proves update or delete-set coverage"},shapedRun:{id:`${R}.shaped-run`,mode:"exact",ephemera:[],note:"glyph ids, clusters, and fixed-point advances compare exactly"},paginationFingerprint:{id:`${R}.pagination-fingerprint`,mode:"exact",ephemera:[],note:"page/column boundaries, break causes, fixed-point geometry compare exactly"},semanticTree:{id:`${R}.semantic-tree`,mode:"exact",ephemera:[],note:"reading order, roles, headings, alt text compare exactly"},hitTest:{id:`${R}.hit-test`,mode:"exact",ephemera:[],note:"resolved hit target and cluster affinity compare exactly"},pdfSemantics:{id:`${R}.pdf-semantics`,mode:"canonical-exact",ephemera:["objectNumber","producer","creationDate","modDate","subsetTag"],note:"canonical semantic PDF objects; container ephemera excluded"},rasterCheckpoint:{id:`${R}.raster-checkpoint`,mode:"tolerance",ephemera:[],note:"documented unavoidable raster comparison; explicit tolerance only"},benchmarkEvidence:{id:`${R}.benchmark-evidence`,mode:"sync-optimization-only",ephemera:[],note:"diagnostic evidence, not an equivalence basis"}};function He(e,t,n,r={}){let o=Be[e];switch(o.mode){case "sync-optimization-only":throw new Error(`${o.id} is not an equivalence basis (${o.note})`);case "tolerance":{if(r.epsilon===void 0)throw new Error(`${o.id} requires an explicit epsilon`);return {equal:it(t,n,r.epsilon)}}case "exact":case "canonical-exact":{let s=o.mode==="canonical-exact"?new Set(o.ephemera):new Set,a=H(t,s),i=H(n,s);return a===i?{equal:true}:{equal:false,left:a,right:i}}}}function Ue(e,t){let n=Be[e];if(n.mode==="tolerance"||n.mode==="sync-optimization-only")throw new Error(`${n.id} has no canonical fingerprint (${n.mode})`);let r=n.mode==="canonical-exact"?new Set(n.ephemera):void 0;return Me(t,r)}function it(e,t,n){return typeof e=="number"&&typeof t=="number"?Number.isFinite(e)&&Number.isFinite(t)&&Math.abs(e-t)<=n:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((r,o)=>it(r,t[o],n)):false}var st=new Set([...t,...u]),at=/^[0-9a-f]{16}$/,Kt=/^[0-9a-f]*$/;function Ve(e){let t=[],n=o=>t.push(o);e.formatVersion!==1&&n(`unsupported formatVersion ${e.formatVersion}`),e.documentId||n("documentId is required"),e.source.kind==="docx"&&!/^[0-9a-f]{64}$/.test(e.source.sha256)&&n("docx source requires a 64-hex sha256");let r=-1;e.steps.forEach((o,s)=>{let a=`step[${s}]`;st.has(o.origin)||n(`${a}: unknown origin ${o.origin}`),(!Number.isInteger(o.baseRevision)||o.baseRevision<0)&&n(`${a}: baseRevision must be a non-negative integer`),o.baseRevision<r&&n(`${a}: baseRevision regressed below ${r}`);let i=o.expect;i.outcome==="applied"?(i.committedRevision===void 0?n(`${a}: applied step needs committedRevision`):i.committedRevision<=o.baseRevision?n(`${a}: committedRevision ${i.committedRevision} must exceed baseRevision ${o.baseRevision}`):r=i.committedRevision,i.modelChange&&Gt(i.modelChange,a,n)):(i.committedRevision!==void 0&&n(`${a}: ${i.outcome} step must not commit a revision`),i.authoredStateHash!==void 0&&n(`${a}: ${i.outcome} step must not change authored state`)),i.authoredStateHash!==void 0&&!at.test(i.authoredStateHash)&&n(`${a}: authoredStateHash must be 16-hex`),i.outputHash!==void 0&&!at.test(i.outputHash)&&n(`${a}: outputHash must be 16-hex`);});for(let o of [...e.snapshots??[],...e.updates??[]])o.documentId!==e.documentId&&n(`envelope documentId ${o.documentId} != ${e.documentId}`),Kt.test(o.bytesHex)||n("envelope bytesHex must be hex"),o.bytesHex.length!==o.byteLength*2&&n(`envelope byteLength ${o.byteLength} disagrees with ${o.bytesHex.length/2} decoded bytes`);return {valid:t.length===0,errors:t}}function Gt(e,t,n){st.has(e.origin)||n(`${t}: modelChange origin ${e.origin} unknown`),e.toRevision<=e.fromRevision&&n(`${t}: modelChange revision must advance`);}function zt(e,t){let n=Ve(e);if(!n.valid)return {ok:false,mismatches:n.errors};let r=[];return t.init(e),e.steps.forEach((o,s)=>{let a=`step[${s}]`,i=t.applyStep(o),d=o.expect;if(i.outcome!==d.outcome){r.push(`${a}: outcome ${i.outcome} != expected ${d.outcome}`);return}if(d.outcome==="applied"&&(i.committedRevision!==d.committedRevision&&r.push(`${a}: revision ${i.committedRevision} != expected ${d.committedRevision}`),d.authoredStateHash!==void 0))if(i.authoredState===void 0)r.push(`${a}: store returned no authored state to hash`);else {He("authoredState",i.authoredState,i.authoredState).equal||r.push(`${a}: authored state is not self-consistent`);let c=lt(i.authoredState);c!==d.authoredStateHash&&r.push(`${a}: authoredStateHash ${c} != expected ${d.authoredStateHash}`);}}),{ok:r.length===0,mismatches:r}}function lt(e){return Ue("authoredState",e)}var Wt=new Map([["embedRegular","regular"],["embedBold","bold"],["embedItalic","italic"],["embedBoldItalic","boldItalic"]]),Yt=32;function pt(e,t){let n=t.replace(/[^0-9a-fA-F]/g,"");if(n.length!==32)return null;let r=new Uint8Array(16);for(let a=0;a<16;a+=1){let i=Number.parseInt(n.slice(a*2,a*2+2),16);if(Number.isNaN(i))return null;r[15-a]=i;}let o=new Uint8Array(e),s=Math.min(Yt,o.length);for(let a=0;a<s;a+=1)o[a]=o[a]^r[a%16];return o}var Xe=(e,t)=>{if(!(e.kind==="textValue"||!("attributes"in e))){for(let n of e.attributes??[])if(n.localName===t)return n.value}},ct=e=>e.kind==="textValue"?[]:e.children??[],dt=e=>e.kind==="textValue"||!("localName"in e)?"":e.localName;function Jt(e,t,n){for(let r of e.relationships.get(t)??[]){if(r.id!==n)continue;if(r.targetMode==="External")return null;let o=q$1(t,r.rawTarget);return o.ok?o.partName:null}return null}function qt(e,t,n={}){if(!t)return [];let r=n.maxFontBytes??16*1024*1024,o=n.maxFonts??64,s=[],a=new Map,i=d=>{if(!(s.length>=o)){if(dt(d)==="font"){let l=Xe(d,"name");if(l&&l.length<=128)for(let c of ct(d)){if(s.length>=o)return;let p=Wt.get(dt(c));if(!p)continue;let u=Xe(c,"id"),m=Xe(c,"fontKey");if(!u||!m)continue;let f=Jt(e,t.name,u);if(!f)continue;let y=e.partBytes.get(f);if(!y||y.length===0||y.length>r)continue;let g=a.get(f);if(g){s.push({family:l,style:p,bytes:g,partName:f});continue}let O=pt(y,m);O&&(a.set(f,O),s.push({family:l,style:p,bytes:O,partName:f}));}}for(let l of ct(d))i(l);}};return i(t.root),s}function ut(e){if(e.kind!=="textValue")for(let t of e.children){if(t.kind==="textValue")continue;if(t.kind==="hyperlink"){let r=Ra(t);if(r!==void 0&&r.length>0)return r}let n=ut(t);if(n!==void 0)return n}}function Qt(e){let t="",n=false,r=o=>{if(!(n||o.kind==="textValue")){if(o.kind==="tab"||o.localName==="ptab"||o.localName==="tab"){n=true;return}if(o.kind==="text"||o.localName==="t"){for(let s of o.children)s.kind==="textValue"&&(t+=s.value);return}for(let s of o.children)r(s);}};return r(e),Dc(t)}function Zt(e,t,n,r){let o=n.filter(d=>{if(r.has(d.blockId))return false;let l=d.level+1;return l>=t.instruction.outlineStart&&l<=t.instruction.outlineEnd}),s=new Set(o.map(d=>d.blockId)),a=yc(e),i=new Map;for(let d of o){let l=Dc(d.text),c=i.get(l);c?c.push(d.blockId):i.set(l,[d.blockId]);}return t.resultParagraphIds.map(d=>{let l=Ea(e,d);if(!l||l.kind==="textValue")return null;let c=ut(l),p=c===void 0?void 0:a.get(c);if(p&&s.has(p.paragraphId)){let f=i.get(Dc(o.find(g=>g.blockId===p.paragraphId)?.text??"")),y=f?.indexOf(p.paragraphId)??-1;return f&&y>=0&&f.splice(y,1),p.paragraphId}let u=Qt(l);if(u.length===0)return null;let m=i.get(u);return !m||m.length===0?null:m.shift()??null})}function C(e){return e.namespaceUri===la?e.localName:`{${e.namespaceUri}}${e.localName}`}function I(e){let t=[];for(let n of e.attributes)t.push(n.namespaceUri===""||n.namespaceUri===la?`${n.localName}=${n.value}`:`{${n.namespaceUri}}${n.localName}=${n.value}`);return t.sort(),t}function ft(e,t){let n=I(e),r=n.length>0?`${C(e)}(${n.join(",")})`:C(e);if(t>=ba)return r;let o=[];for(let s of e.children){if(s.kind==="textValue"){s.value!==""&&o.push(`#${s.value}`);continue}o.push(ft(s,t+1));}return o.sort(),o.length>0?`${r}[${o.join(",")}]`:r}function mt(e){if(!e)return [];let t=[];for(let n of e.children)n.namespaceUri===la&&t.push(ft(n,1));return t.sort(),t}function je(e){if(e.kind==="textValue")return e.value;if(e.kind==="tab")return " ";if(e.kind==="hardBreak")return Zb(e);if(e.kind==="drawing")return kc();if(e.kind==="runProperties"||e.kind==="paragraphProperties"||e.kind==="generic")return "";if(e.kind==="hyperlink"||Kb(e)){let n="",r=e.kind==="hyperlink"?e.children:Mb(e)??[];for(let o of r)n+=je(o);return n}let t="";for(let n of e.children)t+=je(n);return t}function x(e,t){let n=new Map(e);for(let r of t.namespaceBindings)n.set(r.prefix,r.namespaceUri);return n}function U(e,t){try{return va(e,t)}catch(n){if(n instanceof pa&&n.reason==="undeclared-prefix")return `generic-refusal:undeclared-prefix:{${e.namespaceUri}}${e.localName}`;throw n}}function Ke(e,t,n=ua){if(e.kind==="textValue")return;if(e.kind==="runProperties"||e.kind==="paragraphProperties"){let o=x(n,e),s=[];for(let a of e.children)a.namespaceUri!==la&&s.push(U(a,o));s.sort(),t.push(...s);return}if(e.kind==="generic"){t.push(U(e,n));return}if(Kb(e)){t.push(wa(e));return}if(e.kind==="bookmarkStart"||e.kind==="bookmarkEnd"){t.push(va(e,n));return}if(e.kind==="drawing"){t.push(yt(e));return}if(ka(e.kind))return;let r=x(n,e);for(let o of e.children)Ke(o,t,r);}function en(e){return `hyperlink(${e.attributes.map(n=>`${n.namespaceUri}|${n.localName}=${n.value}`).sort().join(",")})`}function tn(e){for(let t of e.children)if(t.kind==="pictureBlipFill")for(let n of t.children){if(n.kind!=="pictureBlip")continue;let r=n.attributes.find(s=>s.localName==="embed"&&s.namespaceUri===oa)?.value,o=n.attributes.find(s=>s.localName==="link"&&s.namespaceUri===oa)?.value;if(r!==void 0)return `embed=${r}`;if(o!==void 0)return `link=${o}`}}function ee(e,t,n){if(e.kind==="textValue")return `#${e.value}`;if(t>=ba)return C(e);let r=x(n,e);if(e.kind==="generic")return U(e,r);let o=I(e),s=o.length>0?`${C(e)}(${o.join(",")})`:C(e),a=[];for(let i of e.children)i.kind!=="textValue"&&a.push(ee(i,t+1,r));return a.sort(),a.length>0?`${s}[${a.join(",")}]`:s}function nn(e,t,n){let r=x(n,e),o=[];for(let s of e.children)if(s.kind!=="textValue"){if(s.kind==="pictureBlipFill"){let a=s.children,i=a.find(l=>l.kind==="pictureBlip"),d=a.filter(l=>l.kind!=="pictureBlip").map(l=>ee(l,t+1,r));if(d.sort(),i&&i.kind==="pictureBlip"){let l=I(i),c=l.length>0?`pictureBlip(${l.join(",")})`:"pictureBlip";o.push(d.length>0?`${c}[${d.join(",")}]`:c);}else for(let l of a)o.push(ee(l,t+1,r));continue}o.push(ee(s,t+1,r));}return o.sort(),o}function Ge(e,t,n){if(e.kind==="textValue")return `#${e.value}`;if(t>=ba)return C(e);let r=x(n,e);if(e.kind==="drawingDocPr"){let i=I(e);return i.length>0?`docPr(${i.join(",")})`:"docPr"}if(e.kind==="picture"){let i=tn(e),d=nn(e,t+1,r),l=i===void 0?"picture":`picture(${i})`;return d.length>0?`${l}[${d.join(",")}]`:l}let o=I(e),s=o.length>0?`${C(e)}(${o.join(",")})`:C(e),a=[];for(let i of e.children){if(i.kind==="picture"){a.push(Ge(i,t+1,r));continue}if(i.kind==="generic"){a.push(U(i,r));continue}i.kind!=="textValue"&&a.push(Ge(i,t+1,r));}return a.length>0?`${s}[${a.join(",")}]`:s}function yt(e){let t=x(ua,e),n=e.children.find(i=>i.kind==="inlineDrawing"||i.kind==="anchoredDrawing");if(!n||n.kind==="textValue")return `drawing(${I(e).join(",")})`;let r=x(t,n),o=I(n),s=o.length>0?`${n.kind}(${o.join(",")})`:n.kind,a=[];for(let i of n.children){if(i.kind==="generic"){a.push(U(i,r));continue}i.kind!=="textValue"&&a.push(Ge(i,1,r));}return a.length>0?`drawing[${s};${a.join(";")}]`:`drawing[${s}]`}function rn(e,t,n){let r=e.children.find(c=>c.kind==="paragraphProperties"),o=[],s="",a=[],i=x(ua,e),d=(c,p)=>{if(c.kind==="run"){let u=x(p,c),m=c.children.find(f=>f.kind==="runProperties");o.push(mt(m)),s+=je(c);for(let f of c.children)Ke(f,a,u);return}if(c.kind==="drawing"){a.push(yt(c));return}if(c.kind==="hyperlink"){a.push(en(c));let u=x(p,c);for(let m of c.children)d(m,u);return}if(c.kind==="contentControl"){a.push(wa({...c,children:c.children.filter(m=>m.kind!=="contentControlContent")}));let u=x(p,c);for(let m of c.children){if(m.kind!=="contentControlContent")continue;let f=x(u,m);for(let y of m.children)d(y,f);}return}Ke(c,a,p);};for(let c of e.children)d(c,i);let l=Kc(e);return {ordinal:t,path:n,paraId:l===null?null:l.toUpperCase(),text:s,paragraphProperties:mt(r),runProperties:o,genericStructure:a}}function on(e){if(e.localName==="hdr"||e.localName==="ftr"||e.kind==="body")return e;for(let t of e.children)if(t.kind!=="textValue"&&(t.kind==="body"||t.localName==="hdr"||t.localName==="ftr"))return t;return e}function gt(e,t,n,r,o,s){if(s>ba)return;let a=0;for(let i of e.children){if(i.kind==="textValue"){i.value.trim()!==""&&o.push(`${t}/#text ${i.value}`);continue}let d=t===""?String(a):`${t}/${a}`;if(a+=1,i.kind==="paragraph"){n.push(i),r.push(d),o.push(`${d} p`);continue}let l=I(i);o.push(l.length>0?`${d} ${C(i)}(${l.join(",")})`:`${d} ${C(i)}`),gt(i,d,n,r,o,s+1);}}function ht(e){let t=on(e.root),n=[],r=[],o=[];gt(t,"",n,r,o,0);let s=n.map((a,i)=>rn(a,i,r[i]));return {partName:e.name,paragraphs:s,structure:o}}function an(e){let t=[];for(let n of e){let r=ht(n);r&&t.push(r);}return {stories:t}}function sn(e,t){let n=[],r=(s,a,i)=>{n.push({path:s,before:JSON.stringify(a)??"undefined",after:JSON.stringify(i)??"undefined"});};e.stories.length!==t.stories.length&&r("stories.length",e.stories.length,t.stories.length);let o=Math.min(e.stories.length,t.stories.length);for(let s=0;s<o;s+=1){let a=e.stories[s],i=t.stories[s],d=p=>`${a.partName}${p}`;a.paragraphs.length!==i.paragraphs.length&&r(d(".paragraphs.length"),a.paragraphs.length,i.paragraphs.length);let l=Math.min(a.paragraphs.length,i.paragraphs.length);for(let p=0;p<l;p+=1){let u=a.paragraphs[p],m=i.paragraphs[p];u.text!==m.text&&r(d(`.p[${p}].text`),u.text,m.text),u.path!==m.path&&r(d(`.p[${p}].path`),u.path,m.path),u.paraId!==m.paraId&&r(d(`.p[${p}].paraId`),u.paraId,m.paraId),JSON.stringify(u.paragraphProperties)!==JSON.stringify(m.paragraphProperties)&&r(d(`.p[${p}].paragraphProperties`),u.paragraphProperties,m.paragraphProperties),JSON.stringify(u.runProperties)!==JSON.stringify(m.runProperties)&&r(d(`.p[${p}].runProperties`),u.runProperties,m.runProperties),JSON.stringify(u.genericStructure)!==JSON.stringify(m.genericStructure)&&r(d(`.p[${p}].genericStructure`),u.genericStructure,m.genericStructure);}a.structure.length!==i.structure.length&&r(d(".structure.length"),a.structure.length,i.structure.length);let c=Math.min(a.structure.length,i.structure.length);for(let p=0;p<c;p+=1)a.structure[p]!==i.structure[p]&&r(d(`.structure[${p}]`),a.structure[p],i.structure[p]);}return n}var V="http://schemas.openxmlformats.org/wordprocessingml/2006/main",dn="http://schemas.openxmlformats.org/package/2006/relationships",xt="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",w="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",pn="application/vnd.openxmlformats-package.relationships+xml",un="http://schemas.openxmlformats.org/package/2006/content-types",Nt="/[Content_Types].xml",E="/word/numbering.xml",Ot=[{text:"\uF0B7",font:"Symbol"},{text:"o",font:"Courier New"},{text:"\uF0A7",font:"Wingdings"}],Rt=["decimal","lowerLetter","lowerRoman"],ze=9;function It(e,t){let n=720*(t+1),r='<w:start w:val="1"/>';if(e==="bullet"){let a=Ot[t%Ot.length];return `<w:lvl w:ilvl="${t}">${r}<w:numFmt w:val="bullet"/><w:lvlText w:val="${a.text}"/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="${n}" w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="${a.font}" w:hAnsi="${a.font}" w:hint="default"/></w:rPr></w:lvl>`}let o=Rt[t%Rt.length],s=o==="lowerRoman";return `<w:lvl w:ilvl="${t}">${r}<w:numFmt w:val="${o}"/><w:lvlText w:val="%${t+1}."/><w:lvlJc w:val="${s?"right":"left"}"/><w:pPr><w:ind w:left="${n}" w:hanging="${s?180:360}"/></w:pPr></w:lvl>`}function mn(e,t){let n=Array.from({length:ze},(r,o)=>It(e,o)).join("");return `<w:abstractNum w:abstractNumId="${t}"><w:multiLevelType w:val="${e==="bullet"?"hybridMultilevel":"multilevel"}"/>${n}</w:abstractNum>`}function fn(){let e=Aa(`<w:numbering xmlns:w="${V}"></w:numbering>`,{name:E,contentType:w});return e.ok?e.part:null}var b=(e,t)=>{let n=[];for(let r of e.children)r.kind==="textValue"||r.localName!==t||r.namespaceUri===V&&n.push(r);return n},N=(e,t)=>e.attributes.find(n=>n.localName===t)?.value;function kt(e,t){let n=Aa(`<w:numbering xmlns:w="${V}">${e}</w:numbering>`,{name:E,contentType:w});if(!n.ok)return null;let r=[];for(let o of n.part.root.children)o.kind!=="textValue"&&r.push(o);if(r.length!==t.length)return null;for(let o=0;o<t.length;o+=1){let s=r[o],a=t[o];if(s.namespaceUri!==V||s.localName!==a.localName||a.attribute&&N(s,a.attribute.localName)!==a.attribute.value)return null}return r}var Ct=["numPicBullet","abstractNum","num","numIdMacAtCleanup"];function bt(e,t,n){let r=t.indexOf(n);if(r===-1)return e.length;let o=0;return e.forEach((s,a)=>{if(s.kind==="textValue")return;let i=t.indexOf(s.localName);i!==-1&&i<=r&&(o=a+1);}),o}function Et(e,t){let n=0;for(let r of e){let o=N(r,t);!o||!/^\d{1,9}$/.test(o)||(n=Math.max(n,Number(o)));}return n+1}function yn(e,t){let n=e.parts.get(E),r=n??fn();if(!r)return null;let o=r.root,s=b(o,"abstractNum"),a=b(o,"num"),i=t==="bullet"?"bullet":"decimal";for(let O of a){let $=N(O,"numId"),Ye=b(O,"abstractNumId")[0],Je=Ye?N(Ye,"val"):void 0;if(!$||!Je)continue;let qe=s.find(X=>N(X,"abstractNumId")===Je);if(!qe)continue;let Qe=b(qe,"lvl").find(X=>N(X,"ilvl")==="0"||N(X,"ilvl")===void 0),Ze=Qe?b(Qe,"numFmt")[0]:void 0;if(Ze&&N(Ze,"val")===i)return {pkg:e,numId:$}}let d=Et(s,"abstractNumId"),l=Et(a,"numId"),c=kt(mn(t,d)+`<w:num w:numId="${l}"><w:abstractNumId w:val="${d}"/></w:num>`,[{localName:"abstractNum",attribute:{localName:"abstractNumId",value:String(d)}},{localName:"num",attribute:{localName:"numId",value:String(l)}}]);if(!c)return null;let p=Ca(r),[u,m]=c.map(O=>te(O,p));if(!u||!m)return null;let f=Ha(r,o.id,bt(o.children,Ct,"abstractNum"),[u]);if(!f.ok)return null;let y=Ha(f.part,o.id,bt(f.part.root.children,Ct,"num"),[m]);if(!y.ok)return null;let g=Object.freeze({...e,parts:new Map([...e.parts,[E,y.part]])});if(!n){let O=Nn(g);if(!O)return null;let $=bn(O);if(!$)return null;g=$;}return {pkg:g,numId:String(l)}}var gn=["nsid","multiLevelType","tmpl","name","styleLink","numStyleLink","lvl"];function St(e){let t=N(e,"ilvl");return t===void 0||!/^\d{1,9}$/.test(t)?null:Number(t)}function hn(e,t){let n=0;return e.forEach((r,o)=>{if(r.kind!=="textValue"){if(r.localName==="lvl"&&r.namespaceUri===V){(St(r)??0)<t&&(n=o+1);return}gn.includes(r.localName)&&(n=o+1);}}),n}function xn(e,t,n,r){if(!Number.isInteger(n)||n<0||n>=ze||t.length===0||t.length>64)return null;let o=e.parts.get(E);if(!o)return null;let s=o.root,a=b(s,"num").find(f=>N(f,"numId")===t),i=a?b(a,"abstractNumId")[0]:void 0,d=i?N(i,"val"):void 0;if(!d)return null;let l=b(s,"abstractNum").find(f=>N(f,"abstractNumId")===d);if(!l||b(l,"numStyleLink").length>0)return null;let c=b(l,"lvl");if(c.some(f=>St(f)===n))return e;if(c.length>=ze)return null;let p=kt(It(r,n),[{localName:"lvl",attribute:{localName:"ilvl",value:String(n)}}]);if(!p)return null;let u=Ca(o),m=Ha(o,l.id,hn(l.children,n),[te(p[0],u)]);return m.ok?Object.freeze({...e,parts:new Map([...e.parts,[E,m.part]])}):null}function te(e,t){return e.kind==="textValue"?{...e,id:t()}:{...e,id:t(),children:e.children.map(n=>te(n,t))}}function Nn(e){let t=e.mainDocumentPart,n=On(t),r=e.parts.get(n),o=Rn(e),s=Aa(`<Relationships xmlns="${dn}"><Relationship Id="${o}" Type="${xt}" Target="numbering.xml"/></Relationships>`,{name:n,contentType:pn});if(!s.ok)return null;let a=e.relationships.get(t)??[],i={ownerPart:t,id:o,type:xt,rawTarget:"numbering.xml",targetMode:"Internal",order:a.reduce((u,m)=>Math.max(u,m.order),-1)+1},d=new Map([...e.relationships,[t,[...a,i]]]);if(!r)return Object.freeze({...e,parts:new Map([...e.parts,[n,s.part]]),relationships:d});let l=Ca(r),c=s.part.root.children[0];if(!c)return null;let p=Ha(r,r.root.id,r.root.children.length,[te(c,l)]);return p.ok?Object.freeze({...e,parts:new Map([...e.parts,[n,p.part]]),relationships:d}):null}function On(e){let t=e.lastIndexOf("/");return `${e.slice(0,t)}/_rels/${e.slice(t+1)}.rels`}function Rn(e){let t=0;for(let n of e.relationships.values())for(let r of n){let o=/^rId(\d{1,9})$/.exec(r.id);o&&(t=Math.max(t,Number(o[1])));}for(let n of e.externalTargets){let r=/^rId(\d{1,9})$/.exec(n.id);r&&(t=Math.max(t,Number(r[1])));}return `rId${t+1}`}var Cn=`<Override PartName="${E}" ContentType="${w}"/>`;function bn(e){let t=e.contentTypes.overrides.get(o(E));if(t===w)return e;if(t!==void 0)return null;let n=e.partBytes.get(Nt);if(!n)return null;let r=strFromU8(n),o$1=Pt(r);if(!o$1)return null;let s=r.lastIndexOf(`</${o$1.rootName}>`);if(s===-1)return null;let a=r.slice(0,s)+Cn+r.slice(s),i=Pt(a);if(!i||i.rootName!==o$1.rootName)return null;let d=[...o$1.children,vt("Override",{PartName:E,ContentType:w})];return i.children.length!==d.length||i.children.some((l,c)=>l!==d[c])?null:Object.freeze({...e,partBytes:new Map([...e.partBytes,[Nt,strToU8(a)]]),contentTypes:Object.freeze({defaults:e.contentTypes.defaults,overrides:new Map([...e.contentTypes.overrides,[o(E),w]])})})}function Pt(e){let t=ca(e);if(!t.ok)return null;let n=t.nodes.filter(i=>i.type==="element");if(n.length!==1)return null;let r=n[0],o=r.name.indexOf(":"),s=o===-1?"":r.name.slice(0,o);if(r.name.slice(o+1)!=="Types"||r.attributes[s?`xmlns:${s}`:"xmlns"]!==un)return null;let a=[];for(let i of r.children)i.type==="element"&&a.push(vt(i.name,i.attributes));return {rootName:r.name,children:a}}function vt(e,t){let n=Object.entries(t).map(([r,o])=>`${r}=${o}`).sort();return [e,...n].join("")}function ne(e){return e!=null&&e.kind!=="textValue"}function We(e,t){for(let n of e.children)if(n.kind!=="textValue"&&n.namespaceUri===la&&n.localName===t)return n;return null}function re(e,t){for(let n of e.attributes)if(n.namespaceUri===la&&n.localName===t)return n.value}function _(e,t){let n=We(e,t);if(!n)return false;let r=re(n,"val");return r===void 0?true:r!=="0"&&r!=="false"&&r!=="off"}var Tt=Object.freeze({trackRevisions:false,restrictedToTrackedChanges:false,doNotTrackMoves:false,doNotTrackFormatting:false});function En(e){if(!ne(e))return Tt;let t=We(e,"documentProtection"),n=t===null?void 0:re(t,"enforcement"),r=n!==void 0&&n!=="0"&&n!=="false"&&n!=="off";return {trackRevisions:_(e,"trackRevisions"),restrictedToTrackedChanges:r&&t!==null&&re(t,"edit")==="trackedChanges",doNotTrackMoves:_(e,"doNotTrackMoves"),doNotTrackFormatting:_(e,"doNotTrackFormatting")}}var wt=Object.freeze({doNotShadeFormData:false});function Pn(e){return ne(e)?{doNotShadeFormData:_(e,"doNotShadeFormData")}:wt}function In(e,t){let n=e.parts.get(t.storyPartName);if(!n)return {ok:false,reason:`no story part named ${t.storyPartName}`};let r=[];for(let d of pe(n.root)){let l=ne$1(d.node).tag;if(l===void 0||l.length===0)continue;let c=t.decide(l);c!=="keep"&&r.push({nodeId:d.node.id,policy:c});}let o=n,s=0,a=0;for(let{nodeId:d,policy:l}of r){let c=Fa(o,d);if(!c)continue;if(l==="remove"){let g=Ja(o,d,{deferValidation:true});if(!g.ok)return {ok:false,reason:`a node could not be removed: ${_t(g)}`};o=g.part,a+=1;continue}let p=c.children.find(g=>g.id===d);if(!p)continue;let u=le(p),m=u?u.children:[],f=c.children.flatMap(g=>g.id===d?m:[g]),y=Ga(o,c.id,f,{deferValidation:true});if(!y.ok)return {ok:false,reason:`a node could not be unwrapped: ${_t(y)}`};o=y.part,s+=1;}let i=o===n?e:zb(e,o);if(!i.parts.has(t.storyPartName))return {ok:false,reason:"the story went missing during the export"};for(let d of t.namespaces)for(let l of Sn(i,t.storyPartName,d)){let c=df(i,l.itemId),p=Ze(i,l.partName,c);if(p.pkg===i&&p.removed.length===0&&!kn(i,l.partName,c))return {ok:false,reason:`the payloads in ${d} could not be removed`};if(i=p.pkg,c.size>0)continue;let u=vn(i,l);if(!u.ok)return {ok:false,reason:`the payload store for ${d} could not be removed`};i=u.pkg;}return {ok:true,pkg:i,unwrapped:s,removed:a}}function kn(e,t,n){return Ve$1(e,t).every(r=>n.has(r.id))}function _t(e){return e.issues.map(t=>t.code).join(", ")||"the edit was refused"}function Sn(e,t,n){return Re(e,t).filter(r=>r.namespaceUri===n)}function vn(e,t){let n=Fb(e,t.partName);if(!n.ok)return {pkg:e,ok:false};let r=Fb(n.pkg,t.propsPartName);return r.ok?{pkg:r.pkg,ok:true}:{pkg:e,ok:false}}
2
2
  export{He as A,Ue as B,Ve as C,zt as D,lt as E,pt as F,qt as G,Zt as H,ht as I,an as J,sn as K,yn as L,xn as M,Tt as N,En as O,wt as P,Pn as Q,In as R,$t as a,nt as b,Y as c,k as d,J as e,q as f,h as g,Lt as h,S as i,M as j,Q as k,B as l,Z as m,$e as n,Ae as o,De as p,Ut as q,Vt as r,Le as s,ot as t,Xt as u,Fe as v,jt as w,H as x,Me as y,Be as z};