@docx-editor.dev/core 2.9.1 → 2.10.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 (94) hide show
  1. package/dist/automation.cjs +1 -1
  2. package/dist/automation.js +1 -1
  3. package/dist/binding.cjs +1 -1
  4. package/dist/binding.d.cts +74 -10
  5. package/dist/binding.d.ts +74 -10
  6. package/dist/binding.js +1 -1
  7. package/dist/chunk-27APDXY2.js +2 -0
  8. package/dist/chunk-35MI6K7M.cjs +10 -0
  9. package/dist/chunk-4XL7SOWQ.cjs +2 -0
  10. package/dist/chunk-6K6QQVAZ.cjs +18 -0
  11. package/dist/chunk-7ZJL5AEY.cjs +1 -0
  12. package/dist/chunk-C6LK2BYA.cjs +2 -0
  13. package/dist/chunk-HBEBUCRM.cjs +5 -0
  14. package/dist/chunk-LG5K46OM.js +2 -0
  15. package/dist/chunk-LWADHMVV.js +5 -0
  16. package/dist/chunk-N725IUO7.js +18 -0
  17. package/dist/chunk-N7DBENH4.js +10 -0
  18. package/dist/chunk-NVGFWMCO.js +1 -0
  19. package/dist/chunk-SYTWKJPJ.cjs +18 -0
  20. package/dist/chunk-YI6JXF7U.js +18 -0
  21. package/dist/contracts/document.d.cts +6 -1
  22. package/dist/contracts/document.d.ts +6 -1
  23. package/dist/contracts/editor.d.cts +6 -6
  24. package/dist/contracts/editor.d.ts +6 -6
  25. package/dist/contracts/interaction.d.cts +6 -6
  26. package/dist/contracts/interaction.d.ts +6 -6
  27. package/dist/contracts/modules.d.cts +3 -4
  28. package/dist/contracts/modules.d.ts +3 -4
  29. package/dist/{custom-node-writes-QyVZdTUA.d.ts → custom-node-writes-BvpWCnW8.d.ts} +52 -5
  30. package/dist/{custom-node-writes-7ERv0f_X.d.cts → custom-node-writes-Db8H6Z3n.d.cts} +52 -5
  31. package/dist/{editor-PUlv5Pp7.d.ts → editor-C0my6Uta.d.ts} +35 -14
  32. package/dist/{editor-CojjwMmF.d.cts → editor-CwzY2Hcg.d.cts} +35 -14
  33. package/dist/editor.cjs +1 -1
  34. package/dist/editor.css +66 -461
  35. package/dist/editor.d.cts +20 -20
  36. package/dist/editor.d.ts +20 -20
  37. package/dist/editor.js +1 -1
  38. package/dist/{index-oN-v8DQ5.d.ts → index-kID8Ymkp.d.ts} +126 -20
  39. package/dist/{index-DGPSeLI0.d.cts → index-nLFwo_17.d.cts} +126 -20
  40. package/dist/index.cjs +1 -1
  41. package/dist/index.d.cts +13 -13
  42. package/dist/index.d.ts +13 -13
  43. package/dist/index.js +1 -1
  44. package/dist/layout.cjs +1 -1
  45. package/dist/layout.d.cts +357 -310
  46. package/dist/layout.d.ts +357 -310
  47. package/dist/layout.js +1 -1
  48. package/dist/output.cjs +1 -1
  49. package/dist/output.d.cts +6 -6
  50. package/dist/output.d.ts +6 -6
  51. package/dist/output.js +1 -1
  52. package/dist/{review-items-DpsqTHio.d.cts → review-items-CwixiHNe.d.cts} +1 -1
  53. package/dist/{review-items-D5SPFtsO.d.ts → review-items-Dw-8a6Ie.d.ts} +1 -1
  54. package/dist/{review-reads-CP106AHp.d.cts → review-reads-BqkiJTeR.d.cts} +1 -1
  55. package/dist/{review-reads-B2Ji3fVU.d.ts → review-reads-C0u-IKEA.d.ts} +1 -1
  56. package/dist/{semantic-cell-selection-DJPjBWzf.d.cts → semantic-cell-selection-DT9x9WLf.d.cts} +2 -2
  57. package/dist/{semantic-cell-selection-BWhVAk5B.d.ts → semantic-cell-selection-Utrf0lz7.d.ts} +2 -2
  58. package/dist/{semantic-interaction-BjOcDB06.d.cts → semantic-interaction-B6hFRQLy.d.ts} +21 -2
  59. package/dist/{semantic-interaction-Cca1-X_a.d.ts → semantic-interaction-Z0xKQcB4.d.cts} +21 -2
  60. package/dist/{semantic-paint-CufpIQFw.d.ts → semantic-paint-CQEOC0Od.d.cts} +2 -2
  61. package/dist/{semantic-paint-Ur7pAINj.d.cts → semantic-paint-quke354p.d.ts} +2 -2
  62. package/dist/{semantic-records-C3Z76KeN.d.cts → semantic-records-CMakzQ1X.d.cts} +36 -4
  63. package/dist/{semantic-records-Cc1MJrhM.d.ts → semantic-records-Do3-i5oB.d.ts} +36 -4
  64. package/dist/{shaped-measurer-CwlTPDJO.d.ts → shaped-measurer-BxwTUluj.d.ts} +1 -1
  65. package/dist/{shaped-measurer-CYSK20E2.d.cts → shaped-measurer-DzRwWrL5.d.cts} +1 -1
  66. package/dist/store.cjs +1 -1
  67. package/dist/store.d.cts +250 -134
  68. package/dist/store.d.ts +250 -134
  69. package/dist/store.js +1 -1
  70. package/dist/tree-op-revision-attribution-CN06Xshv.d.cts +24 -0
  71. package/dist/tree-op-revision-attribution-CN06Xshv.d.ts +24 -0
  72. package/dist/{tree-op-types-XMVsJSpe.d.ts → tree-op-types-BuOfCrkp.d.ts} +280 -32
  73. package/dist/{tree-op-types-B0-sCtw-.d.cts → tree-op-types-DSJYmf5b.d.cts} +280 -32
  74. package/dist/{tree-session-D945D43B.d.cts → tree-session-contract-ByWx8eew.d.cts} +44 -104
  75. package/dist/{tree-session-DBJgmdmc.d.ts → tree-session-contract-C1dfE9hy.d.ts} +44 -104
  76. package/dist/{tree-store-ClA-qng4.d.ts → tree-store-ASBtz7UB.d.ts} +1 -1
  77. package/dist/{tree-store-C6vc8E_2.d.cts → tree-store-CWOUMGN8.d.cts} +1 -1
  78. package/package.json +2 -2
  79. package/dist/chunk-5VC5HGJA.js +0 -2
  80. package/dist/chunk-A2JIBG75.js +0 -1
  81. package/dist/chunk-DKMKH77K.cjs +0 -5
  82. package/dist/chunk-FWUI7EXG.cjs +0 -15
  83. package/dist/chunk-GZWMLQJO.js +0 -18
  84. package/dist/chunk-IEXDXWTA.cjs +0 -1
  85. package/dist/chunk-IMMAG4QP.cjs +0 -10
  86. package/dist/chunk-JTSNJQFO.js +0 -15
  87. package/dist/chunk-KBCC66CI.js +0 -5
  88. package/dist/chunk-LJ6BY6IU.cjs +0 -18
  89. package/dist/chunk-QDBAXFIK.js +0 -2
  90. package/dist/chunk-RD266XSK.cjs +0 -2
  91. package/dist/chunk-VUJGPCPU.js +0 -10
  92. package/dist/chunk-XMHWBL3K.cjs +0 -2
  93. package/dist/image-resources-DQOiwOuE.d.cts +0 -203
  94. package/dist/image-resources-eZqD_-vC.d.ts +0 -203
@@ -1,2 +0,0 @@
1
- 'use strict';var chunkIMMAG4QP_cjs=require('./chunk-IMMAG4QP.cjs'),fflate=require('fflate');var Ft=["extension","capability","command","query","schema","dependencyKey","runtimePort","result","origin"],Bt=/^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+$/,Ut=/^@[a-z0-9.-]+\/[a-z0-9.-]+(?:#[a-z0-9]+(?:[/._-][a-z0-9]+)*)?$/;function it(e){return Bt.test(e)||Ut.test(e)}function J(e,t){if(!it(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 Ht=/^(\d+)\.(\d+)\.(\d+)$/;function S(e){let t=Ht.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 q(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=S(e),r=t.trim();if(r==="*")return true;if(r.startsWith("^")){let o=S(r.slice(1));return q(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=S(a.slice(i.length)),l=q(n,d);i===">="?s=s&&l>=0:s=s&&l<0;}return s}return q(n,S(r))===0}var h=class extends Error{constructor(n,r,o=[]){super(r);this.code=n;this.responsible=o;this.name="RegistryError";}code;responsible},Me=(e,t)=>`${e}:${t}`;function Vt(e,t={}){let n=new Map;for(let l of e){if(J(l.id,"extension"),at(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)J(c.id,c.kind),at(c.version,`${l.id} \u2192 ${c.id}`),c.replaces&&Kt(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)}}Xt(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=Me(c.kind,c.id);if(c.replaces){let u=Me(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=jt(p,c);i.set(l,m);}return {extensions:n,contributions:i,get:(l,c)=>i.get(Me(l,c))}}function jt(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 Xt(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 at(e,t){try{S(e);}catch{throw new h("invalid-version",`invalid version ${JSON.stringify(e)} in ${t}`,[t])}}function Kt(e,t){try{Q("0.0.0",e);}catch{throw new h("invalid-version",`invalid version range ${JSON.stringify(e)} in ${t}`,[t])}}var T=class extends Error{constructor(t){super(t),this.name="BudgetError";}},U=class e{constructor(t,n){this.label=t;this.capacity=n;this.used=new chunkIMMAG4QP_cjs.p(`${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 T(`${this.label}: cannot release with ${this.children.size} child budget(s) outstanding`);if(this.activeReservations>0)throw new T(`${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 T(`${this.label}: ${t.length} cleanup error(s); first: ${String(t[0])}`)}assertLive(){if(this.disposed)throw new T(`${this.label}: budget already released`)}};var Z=class extends Error{constructor(n,r){super(r?`cancelled: ${r}`:"cancelled");this.derivedOnly=n;this.name="CancellationError";}derivedOnly},H=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 Z(t.derivedOnly,t._reason)}}}};var ee=class extends Error{constructor(n){super(`runtime port not available: ${n}`);this.portId=n;this.name="PortResolutionError";}portId},Le=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 ee(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(chunkIMMAG4QP_cjs.f.clock)}identity(){return this.resolve(chunkIMMAG4QP_cjs.f.identity)}},Fe=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}},Be=class{constructor(t="id"){this.prefix=t;}prefix;n=0;newId(){return this.n+=1,`${this.prefix}-${this.n}`}};function Gt(e){let t=chunkIMMAG4QP_cjs.k(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 U(`op:${o}`,r),cancellation:new H};return Object.freeze(s)}function zt(e){e.budget.dispose();}var He=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"}}),st=Object.keys(He);function Wt(e,t){return new chunkIMMAG4QP_cjs.p(`${He[t].phase}:${t}`,e[t])}var Ue=class{counter;current=0;peak=0;constructor(t){this.counter=new chunkIMMAG4QP_cjs.p("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 Yt(){for(let e of st){let t=chunkIMMAG4QP_cjs.j[e],n=chunkIMMAG4QP_cjs.i[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 V(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 Ve(e,t){let n=V(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",je={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 Xe(e,t,n,r={}){let o=je[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:lt(t,n,r.epsilon)}}case "exact":case "canonical-exact":{let s=o.mode==="canonical-exact"?new Set(o.ephemera):new Set,a=V(t,s),i=V(n,s);return a===i?{equal:true}:{equal:false,left:a,right:i}}}}function Ke(e,t){let n=je[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 Ve(t,r)}function lt(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)=>lt(r,t[o],n)):false}var dt=new Set([...chunkIMMAG4QP_cjs.c,...chunkIMMAG4QP_cjs.d]),ct=/^[0-9a-f]{16}$/,Jt=/^[0-9a-f]*$/;function Ge(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}]`;dt.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&&qt(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&&!ct.test(i.authoredStateHash)&&n(`${a}: authoredStateHash must be 16-hex`),i.outputHash!==void 0&&!ct.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}`),Jt.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 qt(e,t,n){dt.has(e.origin)||n(`${t}: modelChange origin ${e.origin} unknown`),e.toRevision<=e.fromRevision&&n(`${t}: modelChange revision must advance`);}function Qt(e,t){let n=Ge(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 {Xe("authoredState",i.authoredState,i.authoredState).equal||r.push(`${a}: authored state is not self-consistent`);let c=pt(i.authoredState);c!==d.authoredStateHash&&r.push(`${a}: authoredStateHash ${c} != expected ${d.authoredStateHash}`);}}),{ok:r.length===0,mismatches:r}}function pt(e){return Ke("authoredState",e)}var Zt=new Map([["embedRegular","regular"],["embedBold","bold"],["embedItalic","italic"],["embedBoldItalic","boldItalic"]]),en=32;function ft(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(en,o.length);for(let a=0;a<s;a+=1)o[a]=o[a]^r[a%16];return o}var ze=(e,t)=>{if(!(e.kind==="textValue"||!("attributes"in e))){for(let n of e.attributes??[])if(n.localName===t)return n.value}},ut=e=>e.kind==="textValue"?[]:e.children??[],mt=e=>e.kind==="textValue"||!("localName"in e)?"":e.localName;function tn(e,t,n){for(let r of e.relationships.get(t)??[]){if(r.id!==n)continue;if(r.targetMode==="External")return null;let o=chunkIMMAG4QP_cjs.w(t,r.rawTarget);return o.ok?o.partName:null}return null}function nn(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(mt(d)==="font"){let l=ze(d,"name");if(l&&l.length<=128)for(let c of ut(d)){if(s.length>=o)return;let p=Zt.get(mt(c));if(!p)continue;let u=ze(c,"id"),m=ze(c,"fontKey");if(!u||!m)continue;let f=tn(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 v=ft(y,m);v&&(a.set(f,v),s.push({family:l,style:p,bytes:v,partName:f}));}}for(let l of ut(d))i(l);}};return i(t.root),s}function yt(e){if(e.kind!=="textValue")for(let t of e.children){if(t.kind==="textValue")continue;if(t.kind==="hyperlink"){let r=chunkIMMAG4QP_cjs.Ia(t);if(r!==void 0&&r.length>0)return r}let n=yt(t);if(n!==void 0)return n}}function rn(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),chunkIMMAG4QP_cjs.Jc(t)}function on(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=chunkIMMAG4QP_cjs.zc(e),i=new Map;for(let d of o){let l=chunkIMMAG4QP_cjs.Jc(d.text),c=i.get(l);c?c.push(d.blockId):i.set(l,[d.blockId]);}return t.resultParagraphIds.map(d=>{let l=chunkIMMAG4QP_cjs.va(e,d);if(!l||l.kind==="textValue")return null;let c=yt(l),p=c===void 0?void 0:a.get(c);if(p&&s.has(p.paragraphId)){let f=i.get(chunkIMMAG4QP_cjs.Jc(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=rn(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===chunkIMMAG4QP_cjs.ca?e.localName:`{${e.namespaceUri}}${e.localName}`}function I(e){let t=[];for(let n of e.attributes)t.push(n.namespaceUri===""||n.namespaceUri===chunkIMMAG4QP_cjs.ca?`${n.localName}=${n.value}`:`{${n.namespaceUri}}${n.localName}=${n.value}`);return t.sort(),t}function ht(e,t){let n=I(e),r=n.length>0?`${C(e)}(${n.join(",")})`:C(e);if(t>=chunkIMMAG4QP_cjs.U)return r;let o=[];for(let s of e.children){if(s.kind==="textValue"){s.value!==""&&o.push(`#${s.value}`);continue}o.push(ht(s,t+1));}return o.sort(),o.length>0?`${r}[${o.join(",")}]`:r}function gt(e){if(!e)return [];let t=[];for(let n of e.children)n.namespaceUri===chunkIMMAG4QP_cjs.ca&&t.push(ht(n,1));return t.sort(),t}function We(e){if(e.kind==="textValue")return e.value;if(e.kind==="tab")return " ";if(e.kind==="hardBreak")return chunkIMMAG4QP_cjs.Xb(e);if(e.kind==="drawing")return chunkIMMAG4QP_cjs.jc();if(e.kind==="runProperties"||e.kind==="paragraphProperties"||e.kind==="generic")return "";if(e.kind==="hyperlink"||chunkIMMAG4QP_cjs.Hb(e)){let n="",r=e.kind==="hyperlink"?e.children:chunkIMMAG4QP_cjs.Jb(e)??[];for(let o of r)n+=We(o);return n}let t="";for(let n of e.children)t+=We(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 j(e,t){try{return chunkIMMAG4QP_cjs.ma(e,t)}catch(n){if(n instanceof chunkIMMAG4QP_cjs.ga&&n.reason==="undeclared-prefix")return `generic-refusal:undeclared-prefix:{${e.namespaceUri}}${e.localName}`;throw n}}function Ye(e,t,n=chunkIMMAG4QP_cjs.la){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!==chunkIMMAG4QP_cjs.ca&&s.push(j(a,o));s.sort(),t.push(...s);return}if(e.kind==="generic"){t.push(j(e,n));return}if(chunkIMMAG4QP_cjs.Hb(e)){t.push(chunkIMMAG4QP_cjs.na(e));return}if(e.kind==="bookmarkStart"||e.kind==="bookmarkEnd"){t.push(chunkIMMAG4QP_cjs.ma(e,n));return}if(e.kind==="drawing"){t.push(xt(e));return}if(chunkIMMAG4QP_cjs.ba(e.kind))return;let r=x(n,e);for(let o of e.children)Ye(o,t,r);}function an(e){return `hyperlink(${e.attributes.map(n=>`${n.namespaceUri}|${n.localName}=${n.value}`).sort().join(",")})`}function sn(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===chunkIMMAG4QP_cjs.fa)?.value,o=n.attributes.find(s=>s.localName==="link"&&s.namespaceUri===chunkIMMAG4QP_cjs.fa)?.value;if(r!==void 0)return `embed=${r}`;if(o!==void 0)return `link=${o}`}}function te(e,t,n){if(e.kind==="textValue")return `#${e.value}`;if(t>=chunkIMMAG4QP_cjs.U)return C(e);let r=x(n,e);if(e.kind==="generic")return j(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(te(i,t+1,r));return a.sort(),a.length>0?`${s}[${a.join(",")}]`:s}function ln(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=>te(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(te(l,t+1,r));continue}o.push(te(s,t+1,r));}return o.sort(),o}function Je(e,t,n){if(e.kind==="textValue")return `#${e.value}`;if(t>=chunkIMMAG4QP_cjs.U)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=sn(e),d=ln(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(Je(i,t+1,r));continue}if(i.kind==="generic"){a.push(j(i,r));continue}i.kind!=="textValue"&&a.push(Je(i,t+1,r));}return a.length>0?`${s}[${a.join(",")}]`:s}function xt(e){let t=x(chunkIMMAG4QP_cjs.la,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(j(i,r));continue}i.kind!=="textValue"&&a.push(Je(i,1,r));}return a.length>0?`drawing[${s};${a.join(";")}]`:`drawing[${s}]`}function cn(e,t,n){let r=e.children.find(c=>c.kind==="paragraphProperties"),o=[],s="",a=[],i=x(chunkIMMAG4QP_cjs.la,e),d=(c,p)=>{if(c.kind==="run"){let u=x(p,c),m=c.children.find(f=>f.kind==="runProperties");o.push(gt(m)),s+=We(c);for(let f of c.children)Ye(f,a,u);return}if(c.kind==="drawing"){a.push(xt(c));return}if(c.kind==="hyperlink"){a.push(an(c));let u=x(p,c);for(let m of c.children)d(m,u);return}if(c.kind==="contentControl"){a.push(chunkIMMAG4QP_cjs.na({...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}Ye(c,a,p);};for(let c of e.children)d(c,i);let l=chunkIMMAG4QP_cjs.Qc(e);return {ordinal:t,path:n,paraId:l===null?null:l.toUpperCase(),text:s,paragraphProperties:gt(r),runProperties:o,genericStructure:a}}function dn(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 Nt(e,t,n,r,o,s){if(s>chunkIMMAG4QP_cjs.U)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)}`),Nt(i,d,n,r,o,s+1);}}function Ot(e){let t=dn(e.root),n=[],r=[],o=[];Nt(t,"",n,r,o,0);let s=n.map((a,i)=>cn(a,i,r[i]));return {partName:e.name,paragraphs:s,structure:o}}function pn(e){let t=[];for(let n of e){let r=Ot(n);r&&t.push(r);}return {stories:t}}function un(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 X="http://schemas.openxmlformats.org/wordprocessingml/2006/main",yn="http://schemas.openxmlformats.org/package/2006/relationships",Rt="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",A="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",gn="application/vnd.openxmlformats-package.relationships+xml",hn="http://schemas.openxmlformats.org/package/2006/content-types",Ct="/[Content_Types].xml",b="/word/numbering.xml",bt=[{text:"\uF0B7",font:"Symbol"},{text:"o",font:"Courier New"},{text:"\uF0A7",font:"Wingdings"}],Et=["decimal","lowerLetter","lowerRoman"],qe=9;function Tt(e,t){let n=720*(t+1),r='<w:start w:val="1"/>';if(e==="bullet"){let a=bt[t%bt.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=Et[t%Et.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 xn(e,t){let n=Array.from({length:qe},(r,o)=>Tt(e,o)).join("");return `<w:abstractNum w:abstractNumId="${t}"><w:multiLevelType w:val="${e==="bullet"?"hybridMultilevel":"multilevel"}"/>${n}</w:abstractNum>`}function Nn(){let e=chunkIMMAG4QP_cjs.ra(`<w:numbering xmlns:w="${X}"></w:numbering>`,{name:b,contentType:A});return e.ok?e.part:null}var P=(e,t)=>{let n=[];for(let r of e.children)r.kind==="textValue"||r.localName!==t||r.namespaceUri===X&&n.push(r);return n},N=(e,t)=>e.attributes.find(n=>n.localName===t)?.value;function vt(e,t){let n=chunkIMMAG4QP_cjs.ra(`<w:numbering xmlns:w="${X}">${e}</w:numbering>`,{name:b,contentType:A});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!==X||s.localName!==a.localName||a.attribute&&N(s,a.attribute.localName)!==a.attribute.value)return null}return r}var Pt=["numPicBullet","abstractNum","num","numIdMacAtCleanup"];function It(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 kt(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 On(e,t){let n=e.parts.get(b),r=n??Nn();if(!r)return null;let o=r.root,s=P(o,"abstractNum"),a=P(o,"num"),i=t==="bullet"?"bullet":"decimal",d=s.find(O=>{let D=N(O,"abstractNumId");if(!D||!/^\d{1,9}$/.test(D))return false;let et=P(O,"lvl").find(nt=>N(nt,"ilvl")==="0"||N(nt,"ilvl")===void 0),tt=et?P(et,"numFmt")[0]:void 0;return tt!==void 0&&N(tt,"val")===i}),c=(d?Number(N(d,"abstractNumId")):null)??kt(s,"abstractNumId"),p=kt(a,"numId"),u=d===void 0,m=vt((u?xn(t,c):"")+`<w:num w:numId="${p}"><w:abstractNumId w:val="${c}"/></w:num>`,u?[{localName:"abstractNum",attribute:{localName:"abstractNumId",value:String(c)}},{localName:"num",attribute:{localName:"numId",value:String(p)}}]:[{localName:"num",attribute:{localName:"numId",value:String(p)}}]);if(!m)return null;let f=chunkIMMAG4QP_cjs.ta(r),y=m.map(O=>ne(O,f)),g=u?y[0]:void 0,v=y[u?1:0];if(u&&!g||!v)return null;let ae=r;if(g){let O=chunkIMMAG4QP_cjs.ya(r,o.id,It(o.children,Pt,"abstractNum"),[g]);if(!O.ok)return null;ae=O.part;}let Ze=chunkIMMAG4QP_cjs.ya(ae,o.id,It(ae.root.children,Pt,"num"),[v]);if(!Ze.ok)return null;let se=Object.freeze({...e,parts:new Map([...e.parts,[b,Ze.part]])});if(!n){let O=En(se);if(!O)return null;let D=Sn(O);if(!D)return null;se=D;}return {pkg:se,numId:String(p)}}var Rn=["nsid","multiLevelType","tmpl","name","styleLink","numStyleLink","lvl"];function wt(e){let t=N(e,"ilvl");return t===void 0||!/^\d{1,9}$/.test(t)?null:Number(t)}function Cn(e,t){let n=0;return e.forEach((r,o)=>{if(r.kind!=="textValue"){if(r.localName==="lvl"&&r.namespaceUri===X){(wt(r)??0)<t&&(n=o+1);return}Rn.includes(r.localName)&&(n=o+1);}}),n}function bn(e,t,n,r){if(!Number.isInteger(n)||n<0||n>=qe||t.length===0||t.length>64)return null;let o=e.parts.get(b);if(!o)return null;let s=o.root,a=P(s,"num").find(f=>N(f,"numId")===t),i=a?P(a,"abstractNumId")[0]:void 0,d=i?N(i,"val"):void 0;if(!d)return null;let l=P(s,"abstractNum").find(f=>N(f,"abstractNumId")===d);if(!l||P(l,"numStyleLink").length>0)return null;let c=P(l,"lvl");if(c.some(f=>wt(f)===n))return e;if(c.length>=qe)return null;let p=vt(Tt(r,n),[{localName:"lvl",attribute:{localName:"ilvl",value:String(n)}}]);if(!p)return null;let u=chunkIMMAG4QP_cjs.ta(o),m=chunkIMMAG4QP_cjs.ya(o,l.id,Cn(l.children,n),[ne(p[0],u)]);return m.ok?Object.freeze({...e,parts:new Map([...e.parts,[b,m.part]])}):null}function ne(e,t){return e.kind==="textValue"?{...e,id:t()}:{...e,id:t(),children:e.children.map(n=>ne(n,t))}}function En(e){let t=e.mainDocumentPart,n=Pn(t),r=e.parts.get(n),o=In(e),s=chunkIMMAG4QP_cjs.ra(`<Relationships xmlns="${yn}"><Relationship Id="${o}" Type="${Rt}" Target="numbering.xml"/></Relationships>`,{name:n,contentType:gn});if(!s.ok)return null;let a=e.relationships.get(t)??[],i={ownerPart:t,id:o,type:Rt,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=chunkIMMAG4QP_cjs.ta(r),c=s.part.root.children[0];if(!c)return null;let p=chunkIMMAG4QP_cjs.ya(r,r.root.id,r.root.children.length,[ne(c,l)]);return p.ok?Object.freeze({...e,parts:new Map([...e.parts,[n,p.part]]),relationships:d}):null}function Pn(e){let t=e.lastIndexOf("/");return `${e.slice(0,t)}/_rels/${e.slice(t+1)}.rels`}function In(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 kn=`<Override PartName="${b}" ContentType="${A}"/>`;function Sn(e){let t=e.contentTypes.overrides.get(chunkIMMAG4QP_cjs.u(b));if(t===A)return e;if(t!==void 0)return null;let n=e.partBytes.get(Ct);if(!n)return null;let r=fflate.strFromU8(n),o=St(r);if(!o)return null;let s=r.lastIndexOf(`</${o.rootName}>`);if(s===-1)return null;let a=r.slice(0,s)+kn+r.slice(s),i=St(a);if(!i||i.rootName!==o.rootName)return null;let d=[...o.children,_t("Override",{PartName:b,ContentType:A})];return i.children.length!==d.length||i.children.some((l,c)=>l!==d[c])?null:Object.freeze({...e,partBytes:new Map([...e.partBytes,[Ct,fflate.strToU8(a)]]),contentTypes:Object.freeze({defaults:e.contentTypes.defaults,overrides:new Map([...e.contentTypes.overrides,[chunkIMMAG4QP_cjs.u(b),A]])})})}function St(e){let t=chunkIMMAG4QP_cjs.V(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"]!==hn)return null;let a=[];for(let i of r.children)i.type==="element"&&a.push(_t(i.name,i.attributes));return {rootName:r.name,children:a}}function _t(e,t){let n=Object.entries(t).map(([r,o])=>`${r}=${o}`).sort();return [e,...n].join("")}function re(e){return e!=null&&e.kind!=="textValue"}function Qe(e,t){for(let n of e.children)if(n.kind!=="textValue"&&n.namespaceUri===chunkIMMAG4QP_cjs.ca&&n.localName===t)return n;return null}function oe(e,t){for(let n of e.attributes)if(n.namespaceUri===chunkIMMAG4QP_cjs.ca&&n.localName===t)return n.value}function $(e,t){let n=Qe(e,t);if(!n)return false;let r=oe(n,"val");return r===void 0?true:r!=="0"&&r!=="false"&&r!=="off"}var At=Object.freeze({trackRevisions:false,restrictedToTrackedChanges:false,doNotTrackMoves:false,doNotTrackFormatting:false});function Tn(e){if(!re(e))return At;let t=Qe(e,"documentProtection"),n=t===null?void 0:oe(t,"enforcement"),r=n!==void 0&&n!=="0"&&n!=="false"&&n!=="off";return {trackRevisions:$(e,"trackRevisions"),restrictedToTrackedChanges:r&&t!==null&&oe(t,"edit")==="trackedChanges",doNotTrackMoves:$(e,"doNotTrackMoves"),doNotTrackFormatting:$(e,"doNotTrackFormatting")}}var $t=Object.freeze({doNotShadeFormData:false});function vn(e){return re(e)?{doNotShadeFormData:$(e,"doNotShadeFormData")}:$t}function wn(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 chunkIMMAG4QP_cjs.ve(n.root)){let l=chunkIMMAG4QP_cjs.te(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=chunkIMMAG4QP_cjs.wa(o,d);if(!c)continue;if(l==="remove"){let g=chunkIMMAG4QP_cjs.Aa(o,d,{deferValidation:true});if(!g.ok)return {ok:false,reason:`a node could not be removed: ${Dt(g)}`};o=g.part,a+=1;continue}let p=c.children.find(g=>g.id===d);if(!p)continue;let u=chunkIMMAG4QP_cjs.re(p),m=u?u.children:[],f=c.children.flatMap(g=>g.id===d?m:[g]),y=chunkIMMAG4QP_cjs.xa(o,c.id,f,{deferValidation:true});if(!y.ok)return {ok:false,reason:`a node could not be unwrapped: ${Dt(y)}`};o=y.part,s+=1;}let i=o===n?e:chunkIMMAG4QP_cjs.qb(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 An(i,t.storyPartName,d)){let c=chunkIMMAG4QP_cjs.lf(i,l.itemId),p=chunkIMMAG4QP_cjs.ff(i,l.partName,c);if(p.pkg===i&&p.removed.length===0&&!_n(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=$n(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 _n(e,t,n){return chunkIMMAG4QP_cjs.bf(e,t).every(r=>n.has(r.id))}function Dt(e){return e.issues.map(t=>t.code).join(", ")||"the edit was refused"}function An(e,t,n){return chunkIMMAG4QP_cjs.Ze(e,t).filter(r=>r.namespaceUri===n)}function $n(e,t){let n=chunkIMMAG4QP_cjs.wb(e,t.partName);if(!n.ok)return {pkg:e,ok:false};let r=chunkIMMAG4QP_cjs.wb(n.pkg,t.propsPartName);return r.ok?{pkg:r.pkg,ok:true}:{pkg:e,ok:false}}var ie="http://purl.org/dc/elements/1.1/",Mt="http://schemas.openxmlformats.org/package/2006/metadata/core-properties",Lt="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties";var Ip=Object.freeze({});function k(e,t,n){if(e.kind!=="textValue")for(let r of e.children){if(r.kind==="textValue"||r.namespaceUri!==t||r.localName!==n)continue;let o=r.children.find(a=>a.kind==="textValue");if(!o||o.kind!=="textValue")return;let s=o.value.trim();return s.length===0?void 0:s.length>4096?s.slice(0,4096):s}}function kp(e,t){let n={};if(e&&e.kind!=="textValue"){let r=k(e,ie,"title");r!==void 0&&(n.title=r);let o=k(e,ie,"creator");o!==void 0&&(n.creator=o);let s=k(e,ie,"subject");s!==void 0&&(n.subject=s);let a=k(e,ie,"description");a!==void 0&&(n.description=a);let i=k(e,Mt,"keywords");i!==void 0&&(n.keywords=i);let d=k(e,Mt,"lastModifiedBy");d!==void 0&&(n.lastModifiedBy=d);}if(t&&t.kind!=="textValue"){let r=k(t,Lt,"Company");r!==void 0&&(n.company=r);let o=k(t,Lt,"Manager");o!==void 0&&(n.manager=o);}return n}
2
- exports.A=Xe;exports.B=Ke;exports.C=Ge;exports.D=Qt;exports.E=pt;exports.F=ft;exports.G=nn;exports.H=on;exports.I=Ot;exports.J=pn;exports.K=un;exports.L=On;exports.M=bn;exports.N=At;exports.O=Tn;exports.P=$t;exports.Q=vn;exports.R=Ip;exports.S=kp;exports.T=wn;exports.a=Ft;exports.b=it;exports.c=J;exports.d=S;exports.e=q;exports.f=Q;exports.g=h;exports.h=Vt;exports.i=T;exports.j=U;exports.k=Z;exports.l=H;exports.m=ee;exports.n=Le;exports.o=Fe;exports.p=Be;exports.q=Gt;exports.r=zt;exports.s=He;exports.t=st;exports.u=Wt;exports.v=Ue;exports.w=Yt;exports.x=V;exports.y=Ve;exports.z=je;
@@ -1,203 +0,0 @@
1
- import { D as DrawingProjection } from './tree-op-types-B0-sCtw-.cjs';
2
- import { c as OoxmlPackage } from './ooxml-package-CdEy9ufK.cjs';
3
-
4
- /**
5
- * The engine's trust-boundary caps: recursion depth, element counts, and the rest.
6
- *
7
- * A caller may LOWER any of these but never raise or disable one — an override of `Infinity`,
8
- * zero, a negative or `NaN` clamps into `(0, ceiling]` rather than turning the limit off. These
9
- * are security ceilings, not performance budgets.
10
- */
11
- interface ResourceLimits {
12
- /** Max nested-structure recursion (tables/shapes/SDT/groups). */
13
- readonly maxRecursionDepth: number;
14
- /** Max total parsed element count. */
15
- readonly maxElementCount: number;
16
- /** Max package part count. */
17
- readonly maxPartCount: number;
18
- /** Max total decompressed bytes (zip-bomb guard). */
19
- readonly maxDecompressedBytes: number;
20
- /** Max total compressed input bytes. */
21
- readonly maxCompressedBytes: number;
22
- /** Max decompressed:compressed ratio per entry. */
23
- readonly maxCompressionRatio: number;
24
- /** In-memory chunk budget for streaming/spooling. */
25
- readonly maxChunkBytes: number;
26
- /** Max pagination passes before non-convergence is declared. */
27
- readonly maxPaginationPasses: number;
28
- /** Max queued items in any bounded work queue. */
29
- readonly maxQueueDepth: number;
30
- }
31
- /** Non-disableable hard ceilings: no resolved limit may exceed these. */
32
- declare const HARD_CEILINGS: ResourceLimits;
33
- /** Finite defaults, all <= their hard ceiling. */
34
- declare const DEFAULT_LIMITS: ResourceLimits;
35
- /**
36
- * Resolve caller overrides into a frozen, always-finite limit set. Each value is
37
- * `min(override>0 ? override : default, ceiling)`. Infinity/0/negative/NaN can
38
- * never disable a limit — the hard ceiling always wins.
39
- */
40
- declare function resolveLimits(overrides?: Partial<ResourceLimits>): ResourceLimits;
41
- /** Bounded image decode limits (typed-drawings-and-images task 4). */
42
- /** Trust-boundary caps specific to image decoding and embedding. */
43
- interface ImageResourceLimits {
44
- readonly maxEncodedBytes: number;
45
- readonly maxDecodedBytes: number;
46
- readonly maxPixels: number;
47
- readonly maxDimension: number;
48
- readonly maxPolygonPoints: number;
49
- readonly maxExternalRedirects: number;
50
- }
51
- /** Image caps nothing can raise past. A caller's override clamps into these. */
52
- declare const IMAGE_RESOURCE_HARD_CEILINGS: ImageResourceLimits;
53
- /** The image caps in force when a host configures none. Conservative and finite. */
54
- declare const DEFAULT_IMAGE_RESOURCE_LIMITS: ImageResourceLimits;
55
- /** Resolve caller overrides into frozen image limits; hard ceilings cannot be raised. */
56
- declare function resolveImageResourceLimits(overrides?: Partial<ImageResourceLimits>): ImageResourceLimits;
57
-
58
- /** Opaque handle — bytes are reachable only through {@link mintValidatedImageBytes}. */
59
- interface ValidatedImageBytesHandle {
60
- readonly registryId: number;
61
- readonly resourceKey: string;
62
- readonly contentId: string;
63
- readonly generation: number;
64
- }
65
-
66
- /**
67
- * Raster media the decode port measures and any authoring path may write.
68
- *
69
- * BMP and WebP are here for the same reason the other three are: an `<img>` decodes them
70
- * natively, so they need a signature and a structural header and nothing else. BMP is what
71
- * older documents carry; WebP is what current Word writes.
72
- */
73
- type SupportedImageMime = 'image/png' | 'image/jpeg' | 'image/gif' | 'image/bmp' | 'image/webp';
74
- /**
75
- * Vector media painted straight from validated bytes. An `<img>` renders SVG in the
76
- * browser's secure static mode — no script, no external subresource loads — so there is
77
- * no decode step and no raster buffer sized by a file-supplied number.
78
- */
79
- type VectorImageMime = 'image/svg+xml';
80
- /** Every mime the painter can hand to an `<img>`. */
81
- type RenderableImageMime = SupportedImageMime | VectorImageMime;
82
- /**
83
- * Media kept in the package byte-for-byte that the painter cannot hand to an `<img>`.
84
- * A decode port may rasterize it; without one it paints as a labelled placeholder.
85
- */
86
- type PreservedImageMime = 'image/tiff' | 'image/x-emf' | 'image/x-wmf';
87
- /**
88
- * What is known about one embedded image: validated, refused, or still decoding.
89
- *
90
- * Content type is a CLAIM. Signature sniffing, structural header validation and the decode port
91
- * are authoritative, and bytes that fail them never enter public state.
92
- */
93
- type ImageResourceState = {
94
- readonly kind: 'ready';
95
- readonly partName: string;
96
- readonly contentId: string;
97
- readonly resourceKey: string;
98
- readonly validatedHandle: ValidatedImageBytesHandle;
99
- readonly mime: RenderableImageMime;
100
- readonly pixelWidth: number;
101
- readonly pixelHeight: number;
102
- readonly dpiX: number;
103
- readonly dpiY: number;
104
- } | {
105
- readonly kind: 'unrenderable';
106
- readonly partName: string | null;
107
- readonly mime: RenderableImageMime | PreservedImageMime | 'unknown';
108
- readonly reason: 'unsupported-format' | 'non-picture-graphic' | 'signature-mismatch' | 'decode-failed' | 'resource-limit';
109
- } | {
110
- readonly kind: 'external';
111
- readonly relationshipId: string;
112
- readonly sinkSafe: boolean;
113
- } | {
114
- readonly kind: 'missing';
115
- readonly relationshipId: string;
116
- } | {
117
- readonly kind: 'pending';
118
- readonly resourceKey: string;
119
- };
120
- /**
121
- * The injected image decoder.
122
- *
123
- * A port rather than a direct `Image`/`createImageBitmap` call, so a worker or server runtime
124
- * supplies its own and the engine never reaches for a browser global.
125
- */
126
- interface ImageDecodePort {
127
- decode(bytes: Uint8Array, mime: SupportedImageMime, limits: ImageResourceLimits): Promise<Readonly<{
128
- pixelWidth: number;
129
- pixelHeight: number;
130
- dpiX: number;
131
- dpiY: number;
132
- }>>;
133
- /**
134
- * Optional conversion of media an `<img>` cannot render (EMF/WMF metafiles, TIFF) into a
135
- * renderable raster. The returned bytes are untrusted and re-enter the full raster
136
- * validation path (sniff, header, pixel caps, decode) before they can become a ready
137
- * resource. A null return declines the format and keeps the labelled placeholder; so does
138
- * a throw, as `decode-failed`.
139
- */
140
- convertPreserved?(bytes: Uint8Array, mime: PreservedImageMime, limits: ImageResourceLimits): Promise<Readonly<{
141
- bytes: Uint8Array;
142
- mime: SupportedImageMime;
143
- }> | null>;
144
- }
145
- /** Resolves a relationship id to a validated image resource, or reports why it could not. */
146
- interface ImageResourceLookup {
147
- readonly resolveEmbedded: (ownerPartName: string, relationshipId: string) => Promise<ImageResourceState>;
148
- readonly resolveLinked: (ownerPartName: string, relationshipId: string) => ImageResourceState;
149
- readonly resolveForProjection: (projection: DrawingProjection) => Promise<ImageResourceState>;
150
- readonly liveReferenceCount: (partName: string) => number;
151
- readonly dispose: () => void;
152
- }
153
- /** Maximum prefix inspected for SVG root detection (exported for bounded-scan tests). */
154
- declare const MAX_SVG_SNIFF_BYTES = 512;
155
- /** A raster header that passed structural validation: its real MIME type and pixel extent. */
156
- interface ValidatedRasterHeader {
157
- readonly pixelWidth: number;
158
- readonly pixelHeight: number;
159
- }
160
- /** Bounded scan for an `<svg` document root (optional `<?xml` prolog only). */
161
- declare function hasBoundedSvgRoot(bytes: Uint8Array): boolean;
162
- /** Signature sniffing — authoritative over declared content type. */
163
- declare function sniffImageMime(bytes: Uint8Array): RenderableImageMime | PreservedImageMime | 'unknown';
164
- /** Structural PNG IHDR validation before decode. */
165
- declare function validatePngHeader(bytes: Uint8Array): ValidatedRasterHeader | null;
166
- /** Structural GIF logical screen descriptor validation before decode. */
167
- declare function validateGifHeader(bytes: Uint8Array): ValidatedRasterHeader | null;
168
- /** Bounded JPEG marker scan through the first supported SOF marker. */
169
- declare function validateJpegHeader(bytes: Uint8Array): ValidatedRasterHeader | null;
170
- /**
171
- * Intrinsic size of an SVG, resolved the way a browser sizes one: absolute `width`/`height`
172
- * first, then `viewBox` for the missing axis or ratio, then the CSS 300x150 default.
173
- *
174
- * This is metadata for insert and reset-to-natural-size only. Layout uses the authored
175
- * `wp:extent` and the browser rasterizes into that box, so nothing here sizes an allocation
176
- * and an out-of-range value is clamped rather than refused.
177
- */
178
- declare function resolveSvgIntrinsicSize(bytes: Uint8Array, limits: ImageResourceLimits): ValidatedRasterHeader | null;
179
- /**
180
- * Validate a raster image's header structurally and report its real MIME type and extent.
181
- *
182
- * Content type is a CLAIM; this is what makes it a fact. A file declaring `image/png` over JPEG
183
- * bytes is caught here rather than at decode.
184
- */
185
- declare function validateRasterHeader(bytes: Uint8Array, mime: SupportedImageMime): ValidatedRasterHeader | null;
186
- /** Package-wide live drawing references to a media part name. */
187
- declare function liveDrawingReferenceCount(pkg: OoxmlPackage, partName: string): number;
188
- /** How the image cache decodes, and what it will spend doing so. */
189
- interface CreateImageResourceCacheOptions {
190
- readonly limits?: Partial<ImageResourceLimits>;
191
- readonly decodePort: ImageDecodePort;
192
- }
193
- /**
194
- * Derived cache for one immutable package snapshot. Registry identity is
195
- * `(package snapshot, decodePort object, normalized limits)` — the first caller
196
- * never imposes its decoder or limits on later callers with different options.
197
- */
198
- declare function imageResourceLookupFor(pkg: OoxmlPackage, options: CreateImageResourceCacheOptions): ImageResourceLookup;
199
- /** @deprecated Prefer {@link imageResourceLookupFor} — registry binds cache to package identity. */
200
- /** Build the per-document image cache. Validated bytes only; refusals are remembered too. */
201
- declare function createImageResourceCache(initialPkg: OoxmlPackage, options: CreateImageResourceCacheOptions): ImageResourceLookup;
202
-
203
- export { type CreateImageResourceCacheOptions as C, DEFAULT_IMAGE_RESOURCE_LIMITS as D, HARD_CEILINGS as H, type ImageResourceState as I, MAX_SVG_SNIFF_BYTES as M, type PreservedImageMime as P, type RenderableImageMime as R, type SupportedImageMime as S, type ValidatedImageBytesHandle as V, type VectorImageMime as a, type ImageDecodePort as b, type ImageResourceLimits as c, resolveSvgIntrinsicSize as d, type ResourceLimits as e, DEFAULT_LIMITS as f, IMAGE_RESOURCE_HARD_CEILINGS as g, type ImageResourceLookup as h, type ValidatedRasterHeader as i, createImageResourceCache as j, hasBoundedSvgRoot as k, imageResourceLookupFor as l, liveDrawingReferenceCount as m, resolveLimits as n, validateGifHeader as o, validateJpegHeader as p, validatePngHeader as q, resolveImageResourceLimits as r, sniffImageMime as s, validateRasterHeader as v };
@@ -1,203 +0,0 @@
1
- import { D as DrawingProjection } from './tree-op-types-XMVsJSpe.js';
2
- import { c as OoxmlPackage } from './ooxml-package-CdEy9ufK.js';
3
-
4
- /**
5
- * The engine's trust-boundary caps: recursion depth, element counts, and the rest.
6
- *
7
- * A caller may LOWER any of these but never raise or disable one — an override of `Infinity`,
8
- * zero, a negative or `NaN` clamps into `(0, ceiling]` rather than turning the limit off. These
9
- * are security ceilings, not performance budgets.
10
- */
11
- interface ResourceLimits {
12
- /** Max nested-structure recursion (tables/shapes/SDT/groups). */
13
- readonly maxRecursionDepth: number;
14
- /** Max total parsed element count. */
15
- readonly maxElementCount: number;
16
- /** Max package part count. */
17
- readonly maxPartCount: number;
18
- /** Max total decompressed bytes (zip-bomb guard). */
19
- readonly maxDecompressedBytes: number;
20
- /** Max total compressed input bytes. */
21
- readonly maxCompressedBytes: number;
22
- /** Max decompressed:compressed ratio per entry. */
23
- readonly maxCompressionRatio: number;
24
- /** In-memory chunk budget for streaming/spooling. */
25
- readonly maxChunkBytes: number;
26
- /** Max pagination passes before non-convergence is declared. */
27
- readonly maxPaginationPasses: number;
28
- /** Max queued items in any bounded work queue. */
29
- readonly maxQueueDepth: number;
30
- }
31
- /** Non-disableable hard ceilings: no resolved limit may exceed these. */
32
- declare const HARD_CEILINGS: ResourceLimits;
33
- /** Finite defaults, all <= their hard ceiling. */
34
- declare const DEFAULT_LIMITS: ResourceLimits;
35
- /**
36
- * Resolve caller overrides into a frozen, always-finite limit set. Each value is
37
- * `min(override>0 ? override : default, ceiling)`. Infinity/0/negative/NaN can
38
- * never disable a limit — the hard ceiling always wins.
39
- */
40
- declare function resolveLimits(overrides?: Partial<ResourceLimits>): ResourceLimits;
41
- /** Bounded image decode limits (typed-drawings-and-images task 4). */
42
- /** Trust-boundary caps specific to image decoding and embedding. */
43
- interface ImageResourceLimits {
44
- readonly maxEncodedBytes: number;
45
- readonly maxDecodedBytes: number;
46
- readonly maxPixels: number;
47
- readonly maxDimension: number;
48
- readonly maxPolygonPoints: number;
49
- readonly maxExternalRedirects: number;
50
- }
51
- /** Image caps nothing can raise past. A caller's override clamps into these. */
52
- declare const IMAGE_RESOURCE_HARD_CEILINGS: ImageResourceLimits;
53
- /** The image caps in force when a host configures none. Conservative and finite. */
54
- declare const DEFAULT_IMAGE_RESOURCE_LIMITS: ImageResourceLimits;
55
- /** Resolve caller overrides into frozen image limits; hard ceilings cannot be raised. */
56
- declare function resolveImageResourceLimits(overrides?: Partial<ImageResourceLimits>): ImageResourceLimits;
57
-
58
- /** Opaque handle — bytes are reachable only through {@link mintValidatedImageBytes}. */
59
- interface ValidatedImageBytesHandle {
60
- readonly registryId: number;
61
- readonly resourceKey: string;
62
- readonly contentId: string;
63
- readonly generation: number;
64
- }
65
-
66
- /**
67
- * Raster media the decode port measures and any authoring path may write.
68
- *
69
- * BMP and WebP are here for the same reason the other three are: an `<img>` decodes them
70
- * natively, so they need a signature and a structural header and nothing else. BMP is what
71
- * older documents carry; WebP is what current Word writes.
72
- */
73
- type SupportedImageMime = 'image/png' | 'image/jpeg' | 'image/gif' | 'image/bmp' | 'image/webp';
74
- /**
75
- * Vector media painted straight from validated bytes. An `<img>` renders SVG in the
76
- * browser's secure static mode — no script, no external subresource loads — so there is
77
- * no decode step and no raster buffer sized by a file-supplied number.
78
- */
79
- type VectorImageMime = 'image/svg+xml';
80
- /** Every mime the painter can hand to an `<img>`. */
81
- type RenderableImageMime = SupportedImageMime | VectorImageMime;
82
- /**
83
- * Media kept in the package byte-for-byte that the painter cannot hand to an `<img>`.
84
- * A decode port may rasterize it; without one it paints as a labelled placeholder.
85
- */
86
- type PreservedImageMime = 'image/tiff' | 'image/x-emf' | 'image/x-wmf';
87
- /**
88
- * What is known about one embedded image: validated, refused, or still decoding.
89
- *
90
- * Content type is a CLAIM. Signature sniffing, structural header validation and the decode port
91
- * are authoritative, and bytes that fail them never enter public state.
92
- */
93
- type ImageResourceState = {
94
- readonly kind: 'ready';
95
- readonly partName: string;
96
- readonly contentId: string;
97
- readonly resourceKey: string;
98
- readonly validatedHandle: ValidatedImageBytesHandle;
99
- readonly mime: RenderableImageMime;
100
- readonly pixelWidth: number;
101
- readonly pixelHeight: number;
102
- readonly dpiX: number;
103
- readonly dpiY: number;
104
- } | {
105
- readonly kind: 'unrenderable';
106
- readonly partName: string | null;
107
- readonly mime: RenderableImageMime | PreservedImageMime | 'unknown';
108
- readonly reason: 'unsupported-format' | 'non-picture-graphic' | 'signature-mismatch' | 'decode-failed' | 'resource-limit';
109
- } | {
110
- readonly kind: 'external';
111
- readonly relationshipId: string;
112
- readonly sinkSafe: boolean;
113
- } | {
114
- readonly kind: 'missing';
115
- readonly relationshipId: string;
116
- } | {
117
- readonly kind: 'pending';
118
- readonly resourceKey: string;
119
- };
120
- /**
121
- * The injected image decoder.
122
- *
123
- * A port rather than a direct `Image`/`createImageBitmap` call, so a worker or server runtime
124
- * supplies its own and the engine never reaches for a browser global.
125
- */
126
- interface ImageDecodePort {
127
- decode(bytes: Uint8Array, mime: SupportedImageMime, limits: ImageResourceLimits): Promise<Readonly<{
128
- pixelWidth: number;
129
- pixelHeight: number;
130
- dpiX: number;
131
- dpiY: number;
132
- }>>;
133
- /**
134
- * Optional conversion of media an `<img>` cannot render (EMF/WMF metafiles, TIFF) into a
135
- * renderable raster. The returned bytes are untrusted and re-enter the full raster
136
- * validation path (sniff, header, pixel caps, decode) before they can become a ready
137
- * resource. A null return declines the format and keeps the labelled placeholder; so does
138
- * a throw, as `decode-failed`.
139
- */
140
- convertPreserved?(bytes: Uint8Array, mime: PreservedImageMime, limits: ImageResourceLimits): Promise<Readonly<{
141
- bytes: Uint8Array;
142
- mime: SupportedImageMime;
143
- }> | null>;
144
- }
145
- /** Resolves a relationship id to a validated image resource, or reports why it could not. */
146
- interface ImageResourceLookup {
147
- readonly resolveEmbedded: (ownerPartName: string, relationshipId: string) => Promise<ImageResourceState>;
148
- readonly resolveLinked: (ownerPartName: string, relationshipId: string) => ImageResourceState;
149
- readonly resolveForProjection: (projection: DrawingProjection) => Promise<ImageResourceState>;
150
- readonly liveReferenceCount: (partName: string) => number;
151
- readonly dispose: () => void;
152
- }
153
- /** Maximum prefix inspected for SVG root detection (exported for bounded-scan tests). */
154
- declare const MAX_SVG_SNIFF_BYTES = 512;
155
- /** A raster header that passed structural validation: its real MIME type and pixel extent. */
156
- interface ValidatedRasterHeader {
157
- readonly pixelWidth: number;
158
- readonly pixelHeight: number;
159
- }
160
- /** Bounded scan for an `<svg` document root (optional `<?xml` prolog only). */
161
- declare function hasBoundedSvgRoot(bytes: Uint8Array): boolean;
162
- /** Signature sniffing — authoritative over declared content type. */
163
- declare function sniffImageMime(bytes: Uint8Array): RenderableImageMime | PreservedImageMime | 'unknown';
164
- /** Structural PNG IHDR validation before decode. */
165
- declare function validatePngHeader(bytes: Uint8Array): ValidatedRasterHeader | null;
166
- /** Structural GIF logical screen descriptor validation before decode. */
167
- declare function validateGifHeader(bytes: Uint8Array): ValidatedRasterHeader | null;
168
- /** Bounded JPEG marker scan through the first supported SOF marker. */
169
- declare function validateJpegHeader(bytes: Uint8Array): ValidatedRasterHeader | null;
170
- /**
171
- * Intrinsic size of an SVG, resolved the way a browser sizes one: absolute `width`/`height`
172
- * first, then `viewBox` for the missing axis or ratio, then the CSS 300x150 default.
173
- *
174
- * This is metadata for insert and reset-to-natural-size only. Layout uses the authored
175
- * `wp:extent` and the browser rasterizes into that box, so nothing here sizes an allocation
176
- * and an out-of-range value is clamped rather than refused.
177
- */
178
- declare function resolveSvgIntrinsicSize(bytes: Uint8Array, limits: ImageResourceLimits): ValidatedRasterHeader | null;
179
- /**
180
- * Validate a raster image's header structurally and report its real MIME type and extent.
181
- *
182
- * Content type is a CLAIM; this is what makes it a fact. A file declaring `image/png` over JPEG
183
- * bytes is caught here rather than at decode.
184
- */
185
- declare function validateRasterHeader(bytes: Uint8Array, mime: SupportedImageMime): ValidatedRasterHeader | null;
186
- /** Package-wide live drawing references to a media part name. */
187
- declare function liveDrawingReferenceCount(pkg: OoxmlPackage, partName: string): number;
188
- /** How the image cache decodes, and what it will spend doing so. */
189
- interface CreateImageResourceCacheOptions {
190
- readonly limits?: Partial<ImageResourceLimits>;
191
- readonly decodePort: ImageDecodePort;
192
- }
193
- /**
194
- * Derived cache for one immutable package snapshot. Registry identity is
195
- * `(package snapshot, decodePort object, normalized limits)` — the first caller
196
- * never imposes its decoder or limits on later callers with different options.
197
- */
198
- declare function imageResourceLookupFor(pkg: OoxmlPackage, options: CreateImageResourceCacheOptions): ImageResourceLookup;
199
- /** @deprecated Prefer {@link imageResourceLookupFor} — registry binds cache to package identity. */
200
- /** Build the per-document image cache. Validated bytes only; refusals are remembered too. */
201
- declare function createImageResourceCache(initialPkg: OoxmlPackage, options: CreateImageResourceCacheOptions): ImageResourceLookup;
202
-
203
- export { type CreateImageResourceCacheOptions as C, DEFAULT_IMAGE_RESOURCE_LIMITS as D, HARD_CEILINGS as H, type ImageResourceState as I, MAX_SVG_SNIFF_BYTES as M, type PreservedImageMime as P, type RenderableImageMime as R, type SupportedImageMime as S, type ValidatedImageBytesHandle as V, type VectorImageMime as a, type ImageDecodePort as b, type ImageResourceLimits as c, resolveSvgIntrinsicSize as d, type ResourceLimits as e, DEFAULT_LIMITS as f, IMAGE_RESOURCE_HARD_CEILINGS as g, type ImageResourceLookup as h, type ValidatedRasterHeader as i, createImageResourceCache as j, hasBoundedSvgRoot as k, imageResourceLookupFor as l, liveDrawingReferenceCount as m, resolveLimits as n, validateGifHeader as o, validateJpegHeader as p, validatePngHeader as q, resolveImageResourceLimits as r, sniffImageMime as s, validateRasterHeader as v };