@docx-editor.dev/core 2.16.0 → 2.16.2

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.ts +6 -6
  3. package/dist/automation.js +1 -1
  4. package/dist/binding.cjs +1 -1
  5. package/dist/binding.d.ts +10 -10
  6. package/dist/binding.js +1 -1
  7. package/dist/chunk-4RDCLCLB.js +2 -0
  8. package/dist/chunk-7QG5FJ4X.js +1 -0
  9. package/dist/chunk-BML3CNUT.js +2 -0
  10. package/dist/chunk-FRRMJK2G.js +5 -0
  11. package/dist/{chunk-FAD7DH6Q.cjs → chunk-G5GLQ4SX.cjs} +1 -1
  12. package/dist/chunk-JP253KIZ.cjs +2 -0
  13. package/dist/chunk-JROG4U3Z.cjs +21 -0
  14. package/dist/{chunk-DYPT6YDY.js → chunk-MBXGQN6J.js} +1 -1
  15. package/dist/{chunk-QVJO5FUR.js → chunk-MDMM3XVQ.js} +6 -6
  16. package/dist/{chunk-4MIFIUEV.cjs → chunk-NO7U62I2.cjs} +1 -1
  17. package/dist/{chunk-WGHVIB6B.cjs → chunk-NPZX5O23.cjs} +1 -1
  18. package/dist/chunk-OISZDVXT.cjs +5 -0
  19. package/dist/{chunk-YRTRPSSA.cjs → chunk-PRNYSOQL.cjs} +1 -1
  20. package/dist/chunk-QQP2SGAT.js +20 -0
  21. package/dist/chunk-RXPOTTQQ.js +21 -0
  22. package/dist/chunk-T7JERNXT.cjs +2 -0
  23. package/dist/{chunk-TDHR2QLH.cjs → chunk-TDMGSCCL.cjs} +1 -1
  24. package/dist/{chunk-BPSGGVP5.cjs → chunk-UIB2MDE3.cjs} +1 -1
  25. package/dist/{chunk-I4ENGOOZ.js → chunk-UXAWPVH6.js} +1 -1
  26. package/dist/{chunk-AEIAYDCG.js → chunk-VYQTZIYH.js} +1 -1
  27. package/dist/chunk-W7GY2IJC.js +2 -0
  28. package/dist/chunk-XC7YDJBL.cjs +20 -0
  29. package/dist/{chunk-YKDRBDI2.js → chunk-XXLS6O6B.js} +1 -1
  30. package/dist/{chunk-GHNTGVKG.cjs → chunk-ZFBNCHRP.cjs} +6 -6
  31. package/dist/collaboration/replication.cjs +1 -1
  32. package/dist/collaboration/replication.d.ts +4 -4
  33. package/dist/collaboration/replication.js +1 -1
  34. package/dist/collaboration.d.ts +4 -4
  35. package/dist/contracts/editor.d.ts +7 -7
  36. package/dist/contracts/modules.d.ts +8 -8
  37. package/dist/{custom-node-writes-4WOL8JB_.d.ts → custom-node-writes-ClTkWM7s.d.ts} +2 -2
  38. package/dist/{editor-PDx0fqSo.d.ts → editor-BlerWPyk.d.ts} +21 -3
  39. package/dist/editor.cjs +1 -1
  40. package/dist/editor.css +1 -1
  41. package/dist/editor.d.ts +26 -26
  42. package/dist/editor.js +1 -1
  43. package/dist/export.cjs +1 -1
  44. package/dist/export.d.ts +11 -11
  45. package/dist/export.js +1 -1
  46. package/dist/{font-resolver-CdqOugwZ.d.ts → font-resolver-DtADJcLL.d.ts} +1 -1
  47. package/dist/{headless-document-view-C9ONlGtf.d.ts → headless-document-view-BDSeMGoK.d.ts} +2 -2
  48. package/dist/{hf-references-BZVHctVD.d.ts → hf-references-kSSFMq9X.d.ts} +1 -1
  49. package/dist/{index-BVb4a6O3.d.ts → index-D51bUVBE.d.ts} +96 -15
  50. package/dist/index.cjs +1 -1
  51. package/dist/index.d.ts +18 -18
  52. package/dist/index.js +1 -1
  53. package/dist/{layout-shaping-D_U5z-Qh.d.ts → layout-shaping-rTElghj2.d.ts} +1 -1
  54. package/dist/layout.cjs +1 -1
  55. package/dist/layout.d.ts +21 -19
  56. package/dist/layout.js +1 -1
  57. package/dist/{note-properties-BosjbkGC.d.ts → note-properties-D5_fXW9K.d.ts} +1 -1
  58. package/dist/{omml-equation-oLlbPpVy.d.ts → omml-equation-C9AJfWy5.d.ts} +1 -1
  59. package/dist/output.cjs +1 -1
  60. package/dist/output.d.ts +6 -6
  61. package/dist/output.js +1 -1
  62. package/dist/{protocol-CUsqt13U.d.ts → protocol-K-Djpjjw.d.ts} +2 -2
  63. package/dist/{review-items-kC-YI70C.d.ts → review-items-CiliAz8H.d.ts} +11 -1
  64. package/dist/review-paragraph-order-BlSnyg9a.d.ts +79 -0
  65. package/dist/{revision-projection-CN_DiOl_.d.ts → revision-projection-JiDclAFU.d.ts} +1 -1
  66. package/dist/{semantic-cell-selection-BMrXDniV.d.ts → semantic-cell-selection-C-VsxNee.d.ts} +4 -4
  67. package/dist/{semantic-interaction-NGeYzYCN.d.ts → semantic-interaction-2vPh96Ey.d.ts} +1 -1
  68. package/dist/{semantic-paint-CM8F-8pH.d.ts → semantic-paint-BEjYcsPK.d.ts} +4 -2
  69. package/dist/{semantic-records-BreR44Ki.d.ts → semantic-records-Bc-MGXbM.d.ts} +9 -3
  70. package/dist/store.cjs +1 -1
  71. package/dist/store.d.ts +99 -15
  72. package/dist/store.js +1 -1
  73. package/dist/{tree-op-types-C5rZzoAz.d.ts → tree-op-types-C71G7rIv.d.ts} +6 -2
  74. package/dist/{tree-package-fragment-DDQHk8sv.d.ts → tree-package-fragment-DRJkmfTW.d.ts} +3 -3
  75. package/dist/{tree-session-contract-dKgbKH9A.d.ts → tree-session-contract-Cp5W25RC.d.ts} +7 -7
  76. package/dist/{tree-store-DU192chS.d.ts → tree-store-BRfhZceK.d.ts} +1 -1
  77. package/package.json +2 -2
  78. package/dist/chunk-66DTF4TD.cjs +0 -2
  79. package/dist/chunk-67U2OZS7.cjs +0 -2
  80. package/dist/chunk-6EGMDUL7.js +0 -21
  81. package/dist/chunk-ABXCIZVW.js +0 -2
  82. package/dist/chunk-CMV2MTDE.js +0 -5
  83. package/dist/chunk-EWV5JMJY.cjs +0 -21
  84. package/dist/chunk-GQVKCK33.js +0 -2
  85. package/dist/chunk-IZHDCQUC.js +0 -20
  86. package/dist/chunk-KEXMDQ2Z.js +0 -1
  87. package/dist/chunk-KQEUFAAG.cjs +0 -20
  88. package/dist/chunk-SIUUTE5M.js +0 -2
  89. package/dist/chunk-XKQTITOJ.cjs +0 -5
  90. package/dist/review-reads-DdvADsmp.d.ts +0 -161
@@ -0,0 +1,2 @@
1
+ import {q as q$1,p as p$1,m,r,n,t,s,l,u,v,o,x,d as d$1,y,e,A as A$1,k as k$2,f as f$1,G as G$1,w as w$1,z,a,b,g,c as c$1,h,i as i$1,j as j$2}from'./chunk-W7GY2IJC.js';import {c,d,p,f,k as k$1,j as j$1,i,Qe as Qe$1,Ph,Jf,De as De$1,da,gc,Oa,hc,N,x as x$1,Ra,cc,Kb,pf,Nd,Od,xg,wg,w,qa,E as E$1}from'./chunk-MDMM3XVQ.js';var On=["extension","capability","command","query","schema","dependencyKey","runtimePort","result","origin"],En=/^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+$/,bn=/^@[a-z0-9.-]+\/[a-z0-9.-]+(?:#[a-z0-9]+(?:[/._-][a-z0-9]+)*)?$/;function Xt(e){return En.test(e)||bn.test(e)}function oe(e,t){if(!Xt(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 vn=/^(\d+)\.(\d+)\.(\d+)$/;function A(e){let t=vn.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 ie(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 ae(e,t){let n=A(e),r=t.trim();if(r==="*")return true;if(r.startsWith("^")){let o=A(r.slice(1));return ie(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 l=true;for(let i of o){let s=i.startsWith(">=")?">=":i.startsWith("<")?"<":null;if(!s)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let d=A(i.slice(s.length)),c=ie(n,d);s===">="?l=l&&c>=0:l=l&&c<0;}return l}return ie(n,A(r))===0}var E=class extends Error{constructor(n,r,o=[]){super(r);this.code=n;this.responsible=o;this.name="RegistryError";}code;responsible},De=(e,t)=>`${e}:${t}`;function wn(e,t={}){let n=new Map;for(let c of e){if(oe(c.id,"extension"),Qt(c.version,c.id),n.has(c.id))throw new E("duplicate-extension",`duplicate extension id ${c.id}`,[c.id]);n.set(c.id,c);for(let p of c.contributions)oe(p.id,p.kind),Qt(p.version,`${c.id} \u2192 ${p.id}`),p.replaces&&Cn(p.replaces.targetRange,`${c.id} \u2192 replaces ${p.replaces.targetId}`);}for(let c of e){for(let p of c.dependencies??[])if(!n.has(p))throw new E("missing-dependency",`${c.id} requires missing extension ${p}`,[c.id,p]);for(let p of c.conflicts??[])if(n.has(p)){let g=[c.id,p].sort();throw new E("conflict",`extensions ${g[0]} and ${g[1]} conflict`,g)}}Sn(n);let r=new Set(t.availablePorts??[]);for(let c of e)for(let p of c.contributions)p.kind==="runtimePort"&&r.add(p.id);for(let c of e)for(let p of c.requiredPorts??[])if(!r.has(p))throw new E("missing-port",`${c.id} requires unavailable port ${p}`,[c.id,p]);let o=new Map,l=new Map,i=new Map;for(let c of e)for(let p of c.contributions){let g=De(p.kind,p.id);if(p.replaces){let f=De(p.kind,p.replaces.targetId),R=i.get(f)??[];R.push({ext:c.id,c:p}),i.set(f,R);continue}if(l.has(g)){let f=[o.get(g),c.id].sort();throw new E("id-collision",`${p.kind} id ${p.id} registered by both ${f[0]} and ${f[1]}`,f)}l.set(g,p),o.set(g,c.id);}let s=new Map(l);for(let[c,p]of i){let g=l.get(c);if(!g){let O=p[0];throw new E("replacement-target-missing",`${O.ext} replaces missing target ${O.c.replaces.targetId}`,[O.ext,O.c.replaces.targetId])}let f=g.replaceable??{kind:"none"};for(let{ext:O,c:b}of p){if(!ae(g.version,b.replaces.targetRange))throw new E("replacement-version-mismatch",`${O} replaces ${b.replaces.targetId}@${g.version} outside range ${b.replaces.targetRange}`,[O,b.replaces.targetId]);if(f.kind==="none")throw new E("unauthorized-replacement",`${b.replaces.targetId} does not authorize replacement (attempted by ${O})`,[O,b.replaces.targetId])}let R=kn(g,p);s.set(c,R);}return {extensions:n,contributions:s,get:(c,p)=>s.get(De(c,p))}}function kn(e,t){let n=e.replaceable??{kind:"none"};if(t.length===1)return t[0].c;if(n.kind==="priority"){let o=[...t].sort((s,d)=>(d.c.replaces.priority??0)-(s.c.replaces.priority??0)),l=o[0].c.replaces.priority??0,i=o.filter(s=>(s.c.replaces.priority??0)===l);if(i.length>1){let s=i.map(d=>d.ext).sort();throw new E("ambiguous-replacement",`multiple replacers of ${e.id} share top priority ${l}: ${s.join(", ")}`,s)}return o[0].c}let r=t.map(o=>o.ext).sort();throw new E("ambiguous-replacement",`multiple replacers of ${e.id}: ${r.join(", ")}`,r)}function Sn(e){let o=new Map,l=[],i=s=>{o.set(s,1),l.push(s);let d=[...e.get(s)?.dependencies??[]].sort();for(let c of d){let p=o.get(c)??0;if(p===1){let g=l.indexOf(c),f=[...l.slice(g),c];throw new E("dependency-cycle",`dependency cycle: ${f.join(" -> ")}`,f)}p===0&&i(c);}l.pop(),o.set(s,2);};for(let s of [...e.keys()].sort())(o.get(s)??0)===0&&i(s);}function Qt(e,t){try{A(e);}catch{throw new E("invalid-version",`invalid version ${JSON.stringify(e)} in ${t}`,[t])}}function Cn(e,t){try{ae("0.0.0",e);}catch{throw new E("invalid-version",`invalid version range ${JSON.stringify(e)} in ${t}`,[t])}}var F=class extends Error{constructor(t){super(t),this.name="BudgetError";}},K=class e{constructor(t,n){this.label=t;this.capacity=n;this.used=new 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 F(`${this.label}: cannot release with ${this.children.size} child budget(s) outstanding`);if(this.activeReservations>0)throw new F(`${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 F(`${this.label}: ${t.length} cleanup error(s); first: ${String(t[0])}`)}assertLive(){if(this.disposed)throw new F(`${this.label}: budget already released`)}};var se=class extends Error{constructor(n,r){super(r?`cancelled: ${r}`:"cancelled");this.derivedOnly=n;this.name="CancellationError";}derivedOnly},G=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 se(t.derivedOnly,t._reason)}}}};var le=class extends Error{constructor(n){super(`runtime port not available: ${n}`);this.portId=n;this.name="PortResolutionError";}portId},Me=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 le(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(f.clock)}identity(){return this.resolve(f.identity)}},Le=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}},je=class{constructor(t="id"){this.prefix=t;}prefix;n=0;newId(){return this.n+=1,`${this.prefix}-${this.n}`}};function Pn(e){let t=k$1(e.limits),n=Object.freeze({...e.config??{}}),r=e.capacity??t.maxDecompressedBytes,o=e.id??"op",l={id:o,limits:t,config:n,ports:e.ports,budget:new K(`op:${o}`,r),cancellation:new G};return Object.freeze(l)}function In(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"}}),Zt=Object.keys(He);function Tn(e,t){return new p(`${He[t].phase}:${t}`,e[t])}var Be=class{counter;current=0;peak=0;constructor(t){this.counter=new 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 Nn(){for(let e of Zt){let t=j$1[e],n=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 q(e,t=new Set){let n=new WeakSet,r=o=>{if(o===null)return "null";let l=typeof o;if(l==="boolean")return o?"true":"false";if(l==="number"){let i=o;if(!Number.isFinite(i))throw new Error(`non-finite number is not comparable: ${i}`);return Object.is(i,-0)?"0":String(i)}if(l==="string")return JSON.stringify(o);if(l==="bigint")return `${o.toString()}n`;if(Array.isArray(o))return `[${o.map(r).join(",")}]`;if(l==="object"){let i=o;if(n.has(i))throw new Error("cannot canonicalize a cyclic structure");n.add(i);let d=Object.keys(i).filter(c=>!t.has(c)).sort().map(c=>`${JSON.stringify(c)}:${r(i[c])}`).join(",");return n.delete(i),`{${d}}`}throw new Error(`unsupported value type in comparator input: ${l}`)};return r(e)}function Ve(e,t){let n=q(e,t),r=0xcbf29ce484222325n,o=0x100000001b3n,l=0xffffffffffffffffn;for(let i=0;i<n.length;i++)r^=BigInt(n.charCodeAt(i)),r=r*o&l;return r.toString(16).padStart(16,"0")}var k="dev.docx-editor.core.comparator",ze={authoredState:{id:`${k}.authored-state`,mode:"canonical-exact",ephemera:["revision","provenance","producedAt","commitId"],note:"canonical normalized authored records; ephemera excluded"},anchor:{id:`${k}.anchor`,mode:"exact",ephemera:[],note:"internal anchor identity/affinity compares exactly"},yjsStateVector:{id:`${k}.yjs-state-vector`,mode:"sync-optimization-only",ephemera:[],note:"exchange optimization only; never proves update or delete-set coverage"},shapedRun:{id:`${k}.shaped-run`,mode:"exact",ephemera:[],note:"glyph ids, clusters, and fixed-point advances compare exactly"},paginationFingerprint:{id:`${k}.pagination-fingerprint`,mode:"exact",ephemera:[],note:"page/column boundaries, break causes, fixed-point geometry compare exactly"},semanticTree:{id:`${k}.semantic-tree`,mode:"exact",ephemera:[],note:"reading order, roles, headings, alt text compare exactly"},hitTest:{id:`${k}.hit-test`,mode:"exact",ephemera:[],note:"resolved hit target and cluster affinity compare exactly"},pdfSemantics:{id:`${k}.pdf-semantics`,mode:"canonical-exact",ephemera:["objectNumber","producer","creationDate","modDate","subsetTag"],note:"canonical semantic PDF objects; container ephemera excluded"},rasterCheckpoint:{id:`${k}.raster-checkpoint`,mode:"tolerance",ephemera:[],note:"documented unavoidable raster comparison; explicit tolerance only"},benchmarkEvidence:{id:`${k}.benchmark-evidence`,mode:"sync-optimization-only",ephemera:[],note:"diagnostic evidence, not an equivalence basis"}};function Ue(e,t,n,r={}){let o=ze[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:en(t,n,r.epsilon)}}case "exact":case "canonical-exact":{let l=o.mode==="canonical-exact"?new Set(o.ephemera):new Set,i=q(t,l),s=q(n,l);return i===s?{equal:true}:{equal:false,left:i,right:s}}}}function We(e,t){let n=ze[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 en(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)=>en(r,t[o],n)):false}var nn=new Set([...c,...d]),tn=/^[0-9a-f]{16}$/,An=/^[0-9a-f]*$/;function Ke(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,l)=>{let i=`step[${l}]`;nn.has(o.origin)||n(`${i}: unknown origin ${o.origin}`),(!Number.isInteger(o.baseRevision)||o.baseRevision<0)&&n(`${i}: baseRevision must be a non-negative integer`),o.baseRevision<r&&n(`${i}: baseRevision regressed below ${r}`);let s=o.expect;s.outcome==="applied"?(s.committedRevision===void 0?n(`${i}: applied step needs committedRevision`):s.committedRevision<=o.baseRevision?n(`${i}: committedRevision ${s.committedRevision} must exceed baseRevision ${o.baseRevision}`):r=s.committedRevision,s.modelChange&&Fn(s.modelChange,i,n)):(s.committedRevision!==void 0&&n(`${i}: ${s.outcome} step must not commit a revision`),s.authoredStateHash!==void 0&&n(`${i}: ${s.outcome} step must not change authored state`)),s.authoredStateHash!==void 0&&!tn.test(s.authoredStateHash)&&n(`${i}: authoredStateHash must be 16-hex`),s.outputHash!==void 0&&!tn.test(s.outputHash)&&n(`${i}: outputHash must be 16-hex`);});for(let o of [...e.snapshots??[],...e.updates??[]])o.documentId!==e.documentId&&n(`envelope documentId ${o.documentId} != ${e.documentId}`),An.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 Fn(e,t,n){nn.has(e.origin)||n(`${t}: modelChange origin ${e.origin} unknown`),e.toRevision<=e.fromRevision&&n(`${t}: modelChange revision must advance`);}function $n(e,t){let n=Ke(e);if(!n.valid)return {ok:false,mismatches:n.errors};let r=[];return t.init(e),e.steps.forEach((o,l)=>{let i=`step[${l}]`,s=t.applyStep(o),d=o.expect;if(s.outcome!==d.outcome){r.push(`${i}: outcome ${s.outcome} != expected ${d.outcome}`);return}if(d.outcome==="applied"&&(s.committedRevision!==d.committedRevision&&r.push(`${i}: revision ${s.committedRevision} != expected ${d.committedRevision}`),d.authoredStateHash!==void 0))if(s.authoredState===void 0)r.push(`${i}: store returned no authored state to hash`);else {Ue("authoredState",s.authoredState,s.authoredState).equal||r.push(`${i}: authored state is not self-consistent`);let p=rn(s.authoredState);p!==d.authoredStateHash&&r.push(`${i}: authoredStateHash ${p} != expected ${d.authoredStateHash}`);}}),{ok:r.length===0,mismatches:r}}function rn(e){return We("authoredState",e)}function ce(e,t){return {...e,children:t}}function de(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===da}function Y(e,t=[]){if(e.kind==="textValue")return t;e.kind==="paragraph"&&t.push(e.id);for(let n of e.children)Y(n,t);return t}function on(e,t){if(e.kind==="textValue")return null;if(e.kind==="paragraph"&&e.id===t)return e;for(let n of e.children){let r=on(n,t);if(r)return r}return null}function _n(e){let t=(n,r)=>{if(n.kind==="textValue")return n;if(r&&de(n,"vMerge")){if(De$1(n,"val")==="restart")return n;let l=[...n.attributes.filter(i=>!(i.localName==="val"&&i.namespaceUri===da)),{kind:"wmlVal",namespaceUri:da,localName:"val",prefix:"w",value:"restart"}];return {...n,attributes:l}}if(n.kind==="paragraph"||n.kind==="table")return n;let o=r||de(n,"tc");return ce(n,n.children.map(l=>t(l,o)))};return ce(e,e.children.map(n=>t(n,false)))}function an(e,t){if(!(e.kind==="textValue"||e.kind==="table")){if(de(e,"tr")){t.push(e);return}for(let n of e.children)an(n,t);}}function sn(e,t,n){if(e.kind==="textValue"||e.kind==="table")return {node:e,hadRows:false,keptRows:false};if(de(e,"tr")){if(!t.has(e))return {node:null,hadRows:true,keptRows:false};let i=n.value?_n(e):e;return n.value=false,{node:i,hadRows:true,keptRows:true}}let r=false,o=false,l=[];for(let i of e.children){let s=sn(i,t,n);r||=s.hadRows,o||=s.keptRows,s.node!==null&&l.push(s.node);}return r?{node:o?ce(e,l):null,hadRows:true,keptRows:o}:{node:e,hadRows:false,keptRows:false}}function ln(e,t,n){let r=[];for(let d of e.children)an(d,r);let o=new Set(Y(e).filter(d=>t.inRange.has(d)));if(o.size===0)return;let l=r.filter(d=>{let c=Y(d);return c.length>0&&c.every(p=>t.covered.has(p))}),i=new Set(l.flatMap(d=>Y(d)));if(l.length>0&&o.size===i.size&&[...o].every(d=>i.has(d))){let d={value:true},c=new Set(l),p=[];for(let g of e.children){let f=sn(g,c,d);f.node!==null&&p.push(f.node);}n.push(ce(e,p));return}for(let d of Y(e)){if(!t.inRange.has(d))continue;let c=on(e,d);c&&n.push(c);}}var Dn="http://schemas.openxmlformats.org/package/2006/content-types",Mn=5e4;function I(e){return e.kind!=="textValue"}function cn(e,t=[]){if(e.kind==="textValue")return t;e.kind==="paragraph"&&t.push(e.id);for(let n of e.children)cn(n,t);return t}function Ge(e,t){if(e.kind==="textValue")return null;if(e.kind==="paragraph"&&e.id===t)return e;for(let n of e.children){let r=Ge(n,t);if(r)return r}return null}function P(e,t){return {...e,children:t}}function Ln(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===da}function jn(e){if(e.root.kind==="document"){let t=e.root.children.find(n=>n.kind==="body");return t&&I(t)?t:null}return I(e.root)?e.root:null}function Bn(e,t){return cn(e).some(n=>t.has(n))}function qe(e,t,n){for(let r of e)if(I(r)){if(r.kind==="paragraph"){t.inRange.has(r.id)&&n.push(r);continue}if(t.fullBlocks.has(r.id)){n.push(r);continue}if(r.kind==="table"){ln(r,t,n);continue}if(r.kind==="contentControl"){let o=r.children.find(l=>l.kind==="contentControlContent");o&&I(o)&&qe(o.children,t,n);continue}Bn(r,t.inRange)&&qe(r.children,t,n);}}var Hn=new Set(["commentRangeStart","commentRangeEnd"]);function Vn(e){return e.kind==="run"&&e.children.some(t=>t.kind==="commentReference")}function Ye(e){if(e.kind==="textValue")return e;if(Hn.has(e.localName)&&e.namespaceUri===da||Vn(e)||Ln(e,"sectPr"))return null;let t=false,n=[];for(let r of e.children){let o=Ye(r);if(o===null){t=true;continue}o!==r&&(t=true),n.push(o);}return t?P(e,n):e}function zn(e){let t=[],n=d=>{if(d.kind!=="textValue"){if(d.kind==="run"){for(let c of d.children)if(c.kind==="fldChar"){let p=De$1(c,"fldCharType");t.push({nodeId:c.id,type:p==="separate"||p==="end"?p:"begin"});}else c.kind==="instrText"&&t.push({nodeId:c.id,type:"instr"});return}for(let c of d.children)n(c);}};for(let d of e)n(d);if(t.length===0)return e;let r=new Set,o=[],l=null,i=[];for(let d of t){if(d.type==="begin"){o.push({beginId:d.nodeId,separateId:null,instrIds:[]});continue}if(d.type==="separate"){let p=o[o.length-1];p?p.separateId=d.nodeId:l=d.nodeId;continue}if(d.type==="instr"){let p=o[o.length-1];p?p.instrIds.push(d.nodeId):l===null&&i.push(d.nodeId);continue}if(!o.pop()){r.add(d.nodeId),l!==null&&r.add(l);for(let p of i)r.add(p);l=null,i=[];}}for(let d of o){r.add(d.beginId),d.separateId!==null&&r.add(d.separateId);for(let c of d.instrIds)r.add(c);}l!==null&&r.add(l);for(let d of i)r.add(d);if(r.size===0)return e;let s=d=>{if(d.kind==="textValue")return d;if(r.has(d.id))return null;let c=[],p=false;for(let g of d.children){let f=s(g);if(f===null){p=true;continue}f!==g&&(p=true),c.push(f);}return p?P(d,c):d};return e.map(d=>s(d)).filter(d=>d!==null)}function Je(e){if(e.kind==="textValue")return e.value.length;let t=0;for(let n of e.children)t+=Je(n);return t}function Un(e,t){let n=[];for(let r of e.children){if(r.kind!=="contentControl"){n.push(r);continue}let o=t.get(r.id),l=Je(r);if(o===void 0||l>=o){n.push(r);continue}if(l===0)continue;let i=r.children.find(s=>s.kind==="contentControlContent");i&&I(i)?n.push(...i.children):n.push(r);}return P(e,n)}function Wn(e){let t=new Set,n=new Set,r=i=>{if(i.kind!=="textValue"){if(i.kind==="bookmarkStart"){let s=De$1(i,"id");s!==void 0&&t.add(s);}if(i.kind==="bookmarkEnd"){let s=De$1(i,"id");s!==void 0&&n.add(s);}for(let s of i.children)r(s);}};for(let i of e)r(i);let o=new Set([...t].filter(i=>n.has(i)));if(o.size===t.size&&o.size===n.size)return e;let l=i=>{if(i.kind==="textValue")return i;if(i.kind==="bookmarkStart"||i.kind==="bookmarkEnd"){let c=De$1(i,"id");return c!==void 0&&o.has(c)?i:null}let s=[],d=false;for(let c of i.children){let p=l(c);if(p===null){d=true;continue}p!==c&&(d=true),s.push(p);}return d?P(i,s):i};return e.map(i=>l(i)??i)}function Kn(e$1,t$1,n$1){let r$1=e$1.parts.get(t$1.partName);if(!r$1)return {ok:false,reason:"unknown-part"};if(t$1.paragraphIds.length===0)return {ok:false,reason:"empty-range"};let o$1=t$1.paragraphIds[0],l$1=t$1.paragraphIds[t$1.paragraphIds.length-1],i=new Map;for(let a of [o$1,l$1]){let m=Ge(r$1.root,a);if(!m)return {ok:false,reason:"empty-range"};for(let u of m.children)u.kind==="contentControl"&&i.set(u.id,Je(u));}let s$1=r$1,d=Ge(s$1.root,l$1);if(!d)return {ok:false,reason:"empty-range"};let c=Qe$1(d);if(t$1.endOffset<c){let a=Ph(s$1,{op:"deleteText",paragraphId:l$1,start:t$1.endOffset,end:c},{deferValidation:true});if(!a.ok)return {ok:false,reason:"trim-refused"};s$1=a.part;}if(t$1.startOffset>0){let a=Ph(s$1,{op:"deleteText",paragraphId:o$1,start:0,end:t$1.startOffset},{deferValidation:true});if(!a.ok)return {ok:false,reason:"trim-refused"};s$1=a.part;}let p=jn(s$1);if(!p)return {ok:false,reason:"unknown-part"};let g$1={inRange:new Set(t$1.paragraphIds),covered:new Set(t$1.coveredParagraphIds),fullBlocks:new Set(t$1.fullyCoveredBlockIds)},f=[];if(qe(p.children,g$1,f),f.length===0)return {ok:false,reason:"empty-range"};if(f.length>Mn)return {ok:false,reason:"resource-limit"};let R=f.map(a=>Ye(a)).filter(a=>a!==null).map(a=>a.kind!=="paragraph"||a.id!==o$1&&a.id!==l$1?a:Un(a,i));R=[...zn(R)],R=[...Wn(R)];let O=Jf(e$1,"footnote"),b$1=Jf(e$1,"endnote"),Ze=(a,m)=>I(a)&&a.namespaceUri===da&&a.localName===m,et=q$1(R,(a,m)=>{let u=a==="footnote"?O:b$1;if(!u||!I(u.root))return null;for(let y of u.root.children){if(!Ze(y,a))continue;let h=De$1(y,"id");if(h!==void 0&&p$1(h)===m)return y}return null}),tt=et.footnote,nt=et.endnote;tt.size===0&&(O=null),nt.size===0&&(b$1=null);let rt=(a,m,u)=>{if(!a||!I(a.root))return [];let y=[];for(let h of a.root.children){if(!Ze(h,m))continue;let x=De$1(h,"id"),z=De$1(h,"type");if(z==="separator"||z==="continuationSeparator"){y.push(h);continue}if(x!==void 0&&u.has(p$1(x))){let Oe=Ye(h);Oe&&I(Oe)&&y.push(Oe);}}return y},ot=rt(O,"footnote",tt),it=rt(b$1,"endnote",nt),mn=[...ot,...it],at=[...R,...mn],$=new Set;m(at,$);let B=r(e$1,e$1.mainDocumentPart),_=new Set;n(at,_);let me=[],S=t(e$1,e$1.mainDocumentPart,_);for(;;){let a=$.size,m$1=_.size;me=s(B,$),n(me,_),S=t(e$1,e$1.mainDocumentPart,_);let u=[...S.nums,...S.abstracts];m(u,$);for(let y of u)l(y,h=>{if(h.kind!=="textValue"&&(h.localName==="styleLink"||h.localName==="numStyleLink")&&h.namespaceUri===da){let x=De$1(h,"val");x&&$.add(x);}});if($.size===a&&_.size===m$1)break}let D=u(e$1,e$1.mainDocumentPart),st=me.map(a=>v(a,D)),ue=B.docDefaults?v(B.docDefaults,D):null;R=R.map(a=>v(a,D));let fe=ot.map(a=>v(a,D)),ye=it.map(a=>v(a,D)),lt=new Set;o(R,lt);let ct=gc(e$1,r$1.name).filter(a=>lt.has(a.id)),dt=new Map,pt=0,mt=a=>{let m=new Set;for(let u of a){if(u.targetMode==="External")continue;let y=w(u.ownerPart,u.rawTarget);if(!y.ok){m.add(u.id);continue}if((hc(e$1,y.partName)??"").toLowerCase().startsWith("image/")&&n$1?.omitMedia!==true){let x=e$1.partBytes.get(y.partName)??e$1.partBytes.get(y.partName.replace(/^\//,""));x?(dt.set(y.partName,x),pt+=x.byteLength):m.add(u.id);continue}m.add(u.id);}return m},he=mt(ct),ge=(a,m)=>{if(a.kind==="textValue")return a;if(a.kind==="drawing"||a.namespaceUri===da&&a.localName==="pict"){let h=new Set;o([a],h);for(let x of h)if(m.has(x))return null;return a}let u=[],y=false;for(let h of a.children){let x=ge(h,m);if(x===null){y=true;continue}x!==h&&(y=true),u.push(x);}return y?P(a,u):a};he.size>0&&(R=R.map(a=>ge(a,he)).filter(a=>a!==null));let un=ct.filter(a=>!he.has(a.id)),ut=(a,m)=>{if(!a)return [];let u=new Set;o(m,u);let y=gc(e$1,a.name).filter(x=>u.has(x.id)),h=mt(y);if(h.size>0)for(let x=0;x<m.length;x+=1){let z=ge(m[x],h);z!==null&&(m[x]=z);}return y.filter(x=>!h.has(x.id))},fn=ut(O,fe),yn=ut(b$1,ye),C=new Map,xe=[],ft=new Map,H=(a,m,u)=>{let y=w$1(a,m,u);C.set(a.slice(1),Oa(qa(y))),xe.push([a,m]),ft.set(a,y);},Re=(a,m)=>a.map(u=>{if(u.targetMode==="External")return {...u,ownerPart:m};let y=w(u.ownerPart,u.rawTarget);return {...u,ownerPart:m,rawTarget:y.ok?y.partName:u.rawTarget}}),V=Re(un,"/word/document.xml"),J=Re(fn,"/word/footnotes.xml"),X=Re(yn,"/word/endnotes.xml"),yt=new Set(V.map(a=>a.id)),ht=9001,Q=(a,m)=>{let u=z(yt,ht);ht+=1,yt.add(u),V.push({ownerPart:"/word/document.xml",id:u,type:a,rawTarget:m,targetMode:"Internal",order:V.length});},hn=x(s$1,R);if(H("/word/document.xml",a,hn),B.part&&(st.length>0||ue)){let a=P(B.part.root,[...ue?[ue]:[],...st]);H("/word/styles.xml",b,a),Q(g,"styles.xml");}if(S.part&&(S.nums.length>0||S.abstracts.length>0)){let a=P(S.part.root,[...S.abstracts.map(m=>v(m,D)),...S.nums]);H("/word/numbering.xml",c$1,a),Q(h,"numbering.xml");}O&&fe.length>0&&(H("/word/footnotes.xml",d$1,P(O.root,fe)),Q(i$1,"footnotes.xml"),J.length>0&&C.set("word/_rels/footnotes.xml.rels",Oa(y(J)))),b$1&&ye.length>0&&(H("/word/endnotes.xml",e,P(b$1.root,ye)),Q(j$2,"endnotes.xml"),X.length>0&&C.set("word/_rels/endnotes.xml.rels",Oa(y(X))));let Z=new Map;for(let[a,m]of dt){C.set(a.slice(1),m);let u=A$1(a);u&&!Z.has(u)&&Z.set(u,hc(e$1,a)??"application/octet-stream");}let gt={ownerPart:"/",id:"rId1",type:k$2,rawTarget:"word/document.xml",targetMode:"Internal",order:0};C.set("word/_rels/document.xml.rels",Oa(y(V))),C.set("_rels/.rels",Oa(y([gt])));let gn=[`<Default Extension="rels" ContentType="${f$1}"/>`,'<Default Extension="xml" ContentType="application/xml"/>',...[...Z].map(([a,m])=>`<Default Extension="${N(a)}" ContentType="${N(m)}"/>`)].join(""),xn=xe.map(([a,m])=>`<Override PartName="${N(a)}" ContentType="${N(m)}"/>`).join("");C.set("[Content_Types].xml",Oa(`<Types xmlns="${Dn}">${gn}${xn}</Types>`));let M=new Map;M.set("/",[gt]),M.set("/word/document.xml",V),J.length>0&&M.set("/word/footnotes.xml",J),X.length>0&&M.set("/word/endnotes.xml",X);let xt=[];for(let a of M.values())for(let m of a)m.targetMode==="External"&&xt.push({ownerPart:m.ownerPart,id:m.id,type:m.type,rawTarget:m.rawTarget,sinkSafe:x$1(m.rawTarget).ok});let ee=new Map;ee.set("rels",f$1),ee.set("xml","application/xml");for(let[a,m]of Z)ee.set(a,m);let Rn={defaults:ee,overrides:new Map(xe)},Rt=new Map;for(let[a,m]of C)Rt.set(a.startsWith("/")?a:`/${a}`,m);return {ok:true,bytes:Ra(C),package:Object.freeze({parts:ft,partBytes:Rt,relationships:M,externalTargets:xt,contentTypes:Rn,mainDocumentPart:"/word/document.xml"}),lastMarkCovered:t$1.lastMarkCovered,blockCount:R.length,mediaBytes:pt}}function pn(e){return e.kind!=="textValue"}function dn(e,t){for(let n of e.children)if(pn(n)&&n.localName===t)return n;return null}function Gn(e,t){let n=[e];for(;n.length>0;){let r=n.pop();if(pn(r)){if(r.localName===t)return r;for(let o=r.children.length-1;o>=0;o-=1)n.push(r.children[o]);}}return null}var qn=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u;function pe(e,t,n){let r=dn(e,t),l=(r?dn(r,n):null)?.attributes.find(i=>i.localName==="typeface")?.value;return l!==void 0&&qn.test(l)?l:null}function Xe(e){let t=e?Gn(e,"fontScheme"):null;return t?{major:pe(t,"majorFont","latin"),minor:pe(t,"minorFont","latin"),majorEastAsia:pe(t,"majorFont","ea"),minorEastAsia:pe(t,"minorFont","ea")}:{major:null,minor:null,majorEastAsia:null,minorEastAsia:null}}var Yn=new Map([["minorAscii",e=>e.minor],["minorHAnsi",e=>e.minor],["majorAscii",e=>e.major],["majorHAnsi",e=>e.major],["minorEastAsia",e=>e.minorEastAsia??null],["majorEastAsia",e=>e.majorEastAsia??null]]);function ua(e,t){return e===void 0?null:Yn.get(e)?.(t)??null}var j=Object.freeze({styles:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",numbering:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",settings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",theme:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",coreProperties:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",extendedProperties:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"});function Qe(e,t,n,r){let o=(e.relationships.get(t)??[]).find(l=>l.type===n);if(o){let l=E$1(o);if(l.mode==="Internal"&&l.target.ok){let i=e.parts.get(l.target.partName);if(i)return i}}return e.parts.get(r)}function va(e){let t=cc(e);if(!t.ok)return {ok:false,reason:t.reason,...t.detail?{detail:t.detail}:{}};let n=t.package.parts.get(t.package.mainDocumentPart);if(!n)return {ok:false,reason:"no-main-document-tree",detail:t.package.mainDocumentPart};let r=new G$1(t.package,Kb(n)),o=()=>r.currentPackage(),l=()=>r.bodyStore().part,i=(f,R)=>Qe(o(),o().mainDocumentPart,f,R)?.root??null,s=Object.freeze(Xe(null)),d=null,c=wg,p=null;return {ok:true,view:Object.freeze({part:l,currentPackage:o,packageRevision:()=>r.packageRevision,stylesRoot:()=>i(j.styles,"/word/styles.xml"),numberingRoot:()=>i(j.numbering,"/word/numbering.xml"),settingsRoot:()=>i(j.settings,"/word/settings.xml"),documentThemeFonts(){let f=o();return d!==f&&(s=Object.freeze(Xe(i(j.theme,"/word/theme/theme1.xml"))),d=f),s},documentProperties(){let f=o();if(p!==f){let R=Qe(f,"/",j.coreProperties,"/docProps/core.xml"),O=Qe(f,"/",j.extendedProperties,"/docProps/app.xml");c=xg(R?.root??null,O?.root??null),p=f;}return c},headerFooterPartsBySection:()=>Od(o()),headerFooterResolutionBySection:()=>Nd(o()),relationshipTarget:f=>pf(o(),l().name,f)})}}
2
+ export{Ve as A,ze as B,Ue as C,We as D,Ke as E,$n as F,rn as G,Kn as H,va as I,Xe as a,ua as b,On as c,Xt as d,oe as e,A as f,ie as g,ae as h,E as i,wn as j,F as k,K as l,se as m,G as n,le as o,Me as p,Le as q,je as r,Pn as s,In as t,He as u,Zt as v,Tn as w,Be as x,Nn as y,q as z};
@@ -0,0 +1,5 @@
1
+ import {c,e,b as b$2}from'./chunk-VYQTZIYH.js';import {a as a$2}from'./chunk-VP7SDFCM.js';import {a,b as b$3}from'./chunk-BML3CNUT.js';import {d}from'./chunk-UXAWPVH6.js';import {G,Y as Y$1,aa,$ as $$1,T,S,R,P,Q,Ga as Ga$1,Z,Ra,xa,Aa,Ma}from'./chunk-W7GY2IJC.js';import {b as b$1,a as a$1}from'./chunk-XXLS6O6B.js';import {hg,b,wd,Ga,cc,Kb,Ba,mf,lf,mh,of,Te,pf,Kf,Jf,tg,Pd,dc,Qh,Nd,Md,E,wg,xg,Rd,Ad,Sd,Xd,zd,ab,da,rf,_f,Mb,Ha,la,na,ka,ma,Qf,Cd,Ed,Eb,Db,yg,Ne,de,Jd,yd,Kd,sd,gd,id,Yc,Ud,hb,Sa}from'./chunk-MDMM3XVQ.js';import {Schema}from'prosemirror-model';import {EditorState,TextSelection}from'prosemirror-state';import {EditorView}from'prosemirror-view';import {keymap}from'prosemirror-keymap';import {joinBackward,deleteSelection,joinForward,splitBlock,selectTextblockEnd,selectTextblockStart,baseKeymap}from'prosemirror-commands';function z(t){return t.attributes?.val}function $(t){let e=z(t);return e===void 0||!(e==="0"||e==="false"||e==="off")}var ho=/^[0-9A-Fa-f]{6}$/,ke=/^\d{1,6}$/,xo=/^-?\d{1,6}$/;function ze(t){return t===void 0||t==="auto"?null:ho.test(t)?`#${t}`:null}var ko={single:"solid",words:"solid",thick:"solid",double:"double",dotted:"dotted",dottedHeavy:"dotted",dash:"dashed",dashedHeavy:"dashed",dashLong:"dashed",dashLongHeavy:"dashed",dotDash:"dashed",dashDotHeavy:"dashed",dotDotDash:"dashed",dashDotDotHeavy:"dashed",wave:"wavy",wavyHeavy:"wavy",wavyDouble:"wavy"},Oo={black:"#000000",blue:"#0000ff",cyan:"#00ffff",darkBlue:"#000080",darkCyan:"#008080",darkGray:"#808080",darkGreen:"#008000",darkMagenta:"#800080",darkRed:"#800000",darkYellow:"#808000",green:"#00ff00",lightGray:"#c0c0c0",magenta:"#ff00ff",red:"#ff0000",yellow:"#ffff00",white:"#ffffff"};function Po(t){return !t||!/^[\w \-.+]{1,64}$/.test(t)?null:`"${t}"`}function W(t,e=false){return t===void 0||!(e?xo:ke).test(t)?null:`${Number(t)/20}pt`}function Sn(t){let e=[],n=[],o=null,a=null;for(let s of t)switch(s.localName){case "b":e.push(`font-weight:${$(s)?"bold":"normal"}`);break;case "i":e.push(`font-style:${$(s)?"italic":"normal"}`);break;case "u":{let r=z(s)??"single";if(r==="none"||!$(s))break;n.push("underline"),o=ko[r]??"solid",a=ze(s.attributes?.color);break}case "strike":$(s)&&n.push("line-through");break;case "dstrike":$(s)&&n.push("line-through");break;case "caps":$(s)&&e.push("text-transform:uppercase");break;case "smallCaps":$(s)&&e.push("font-variant:small-caps");break;case "vertAlign":{let r=z(s);r==="superscript"?e.push("vertical-align:super","font-size:0.75em"):r==="subscript"&&e.push("vertical-align:sub","font-size:0.75em");break}case "color":{let r=ze(z(s));r&&e.push(`color:${r}`);break}case "highlight":{let r=Oo[z(s)??""];r&&e.push(`background-color:${r}`);break}case "sz":{let r=z(s);r!==void 0&&ke.test(r)&&e.push(`font-size:${Number(r)/2}pt`);break}case "rFonts":{let r=Po(s.attributes?.ascii??s.attributes?.hAnsi);r&&e.push(`font-family:${r}`);break}case "spacing":{let r=W(z(s),true);r&&e.push(`letter-spacing:${r}`);break}}return n.length>0&&(e.push(`text-decoration-line:${[...new Set(n)].join(" ")}`),o&&e.push(`text-decoration-style:${o}`),a&&e.push(`text-decoration-color:${a}`)),e.join(";")}var So={left:"left",start:"left",right:"right",end:"right",center:"center",both:"justify",distribute:"justify"};function bn(t){let e=[];for(let n of t)switch(n.localName){case "jc":{let o=So[z(n)??""];o&&e.push(`text-align:${o}`);break}case "ind":{let o=W(n.attributes?.left??n.attributes?.start,true),a=W(n.attributes?.right??n.attributes?.end,true),s=W(n.attributes?.firstLine),r=W(n.attributes?.hanging);o&&e.push(`margin-left:${o}`),a&&e.push(`margin-right:${a}`),s?e.push(`text-indent:${s}`):r&&e.push(`text-indent:-${r}`);break}case "spacing":{let o=W(n.attributes?.before),a=W(n.attributes?.after);o&&e.push(`margin-top:${o}`),a&&e.push(`margin-bottom:${a}`);let s=n.attributes?.line,r=n.attributes?.lineRule;s!==void 0&&ke.test(s)&&r!=="exact"&&r!=="atLeast"?e.push(`line-height:${(Number(s)/240).toFixed(3)}`):s!==void 0&&ke.test(s)&&e.push(`line-height:${Number(s)/20}pt`);break}case "shd":{let o=ze(n.attributes?.fill);o&&e.push(`background-color:${o}`);break}case "pageBreakBefore":$(n)&&e.push("break-before:page");break;}return e.join(";")}var I=new Schema({nodes:{doc:{content:"paragraph+"},paragraph:{content:"inline*",group:"block",attrs:{nodeId:{default:null},props:{default:[]}},toDOM:t=>{let e=bn(t.attrs.props??[]);return ["p",{"data-node-id":String(t.attrs.nodeId??""),...e?{style:e}:{}},0]},parseDOM:[{tag:"p",getAttrs:t=>typeof t=="string"?null:{nodeId:t.getAttribute("data-node-id")||null,props:[]}}]},text:{group:"inline"},tab:{inline:true,group:"inline",atom:true,selectable:false,toDOM:()=>["span",{"data-token":"tab",class:"docx-tab"},"\u2192"],parseDOM:[{tag:'span[data-token="tab"]'}]},hardBreak:{inline:true,group:"inline",atom:true,selectable:false,toDOM:()=>["br"],parseDOM:[{tag:"br"}]},pageBreak:{inline:true,group:"inline",atom:true,selectable:false,toDOM:()=>["span",{"data-token":"page-break",class:"docx-page-break"}],parseDOM:[{tag:'span[data-token="page-break"]'}]},unknownInline:{inline:true,group:"inline",atom:true,selectable:false,draggable:false,attrs:{nodeId:{default:null},label:{default:""}},toDOM:t=>["span",{"data-token":"unknown","data-node-id":String(t.attrs.nodeId??""),contenteditable:"false",class:"docx-unknown-inline",title:String(t.attrs.label||"Content this editor cannot edit yet. It is preserved.")}],parseDOM:[{tag:'span[data-token="unknown"]',getAttrs:t=>typeof t=="string"?false:{nodeId:t.getAttribute("data-node-id")||null,label:""}}]}},marks:{runProps:{attrs:{props:{default:[]}},excludes:"runProps",toDOM:t=>{let e=t.attrs.props??[],n=Sn(e);return ["span",{"data-run-props":Ro(e),...n?{style:n}:{}},0]},parseDOM:[{tag:"span[data-run-props]",getAttrs:t=>{if(typeof t=="string")return false;let e=vo(t.getAttribute("data-run-props"));return e?{props:e}:false}}]}}});function Ro(t){return JSON.stringify(Array.isArray(t)?t:[])}function vo(t){if(!t)return null;try{let e=JSON.parse(t);if(!Array.isArray(e))return null;let n=[];for(let o of e){if(typeof o!="object"||o===null)return null;let a=o;if(typeof a.localName!="string"||a.attributes!==void 0&&(typeof a.attributes!="object"||a.attributes===null))return null;n.push(a.attributes===void 0?{localName:a.localName}:{localName:a.localName,attributes:a.attributes});}return n}catch{return null}}function We(t){for(let e of t.marks)if(e.type.name==="runProps")return e.attrs.props??[];return []}function Oe(t,e){return JSON.stringify(Pe(t))===JSON.stringify(Pe(e))}function Pe(t){return [...t].map(e=>({localName:e.localName,attributes:Object.fromEntries(Object.entries(e.attributes??{}).sort(([n],[o])=>n<o?-1:1))})).sort((e,n)=>e.localName<n.localName?-1:1)}function Je(t){if(!t||t.kind==="textValue")return [];let e=[];for(let n of t.children){if(n.kind==="textValue"||n.localName==="rPrChange"||n.localName==="pPrChange")continue;let o={};for(let a of n.attributes)o[a.localName]=a.value;e.push(Object.keys(o).length>0?{localName:n.localName,attributes:o}:{localName:n.localName});}return e}function Rn(t){return t.kind==="textValue"?"":`${{drawing:"Picture",pict:"Picture",object:"Embedded object",fldSimple:"Field",hyperlink:"Hyperlink",sdt:"Content control",tbl:"Table"}[t.localName]??t.localName} \u2014 preserved, not editable yet`}function A(t){if(t.kind==="textValue")return [];let e=[],n=s=>{if(s.kind!=="run")return;let r=s.children.find(c=>c.kind==="runProperties"),d=Je(r);for(let c of s.children)if(c.kind!=="runProperties"){if(c.kind==="tab"){e.push({kind:"tab"});continue}if(c.kind==="hardBreak"){e.push(Ud(c)?{kind:"pageBreak"}:{kind:"hardBreak"});continue}if(c.kind==="text"){let f="";for(let m of c.children)m.kind==="textValue"&&(f+=m.value);f.length>0&&e.push({kind:"text",text:f,props:d});continue}e.push({kind:"unknown",nodeId:c.id,label:Rn(c),modelLength:c.kind==="drawing"||hb(c)||Sa(c)?1:0});}},o=s=>{if(s.kind==="run"){n(s);return}e.push({kind:"unknown",nodeId:s.id,label:Rn(s),modelLength:0});},a=(s,r)=>{for(let d of s)if(!(d.kind==="textValue"||d.kind==="paragraphProperties")&&!(r>=la)){if(na(d)&&!ka(d.kind)&&r<la){a(d.children.filter(c=>!Qf(d,c)),ma(d,r));continue}if(Cd(d)){let c=Ed(d);c&&a(c,ma(d,r));continue}o(d);}};return a(t.children,0),e}function ee(t){let e=[],n=o=>{if(o.kind!=="textValue"){if(o.kind==="body"){for(let a of o.children)a.kind==="paragraph"&&e.push(a);return}for(let a of o.children)n(a);}};return n(t.root),e}var vn=hg(16),Tn=new WeakMap;function To(t,e){let n=Tn.get(t);if(!n){let o=[];Ad([t],o,0),n=Object.freeze(o),Tn.set(t,n);}for(let o of n)e.push(o);}function F(t){let e=vn.get(t);if(e)return e;let n=[];for(let o of wd(t))if(o.root.kind!=="textValue")for(let a of o.root.children)To(a,n);return vn.set(t,n),n}function J(t){let e=ee(t).map(n=>{let o=n.kind==="textValue"?void 0:n.children.find(s=>s.kind==="paragraphProperties"),a=A(n).map(s=>{switch(s.kind){case "text":return I.text(s.text,s.props.length>0?[I.marks.runProps.create({props:s.props})]:[]);case "tab":return I.node("tab");case "hardBreak":return I.node("hardBreak");case "pageBreak":return I.node("pageBreak");default:return I.node("unknownInline",{nodeId:s.nodeId,label:s.label})}});return I.node("paragraph",{nodeId:n.id,props:Je(o)},a)});return I.node("doc",null,e.length>0?e:[I.node("paragraph")])}function No(t,e){let n=[];return t.forEach(o=>{if(o.isText&&o.text){n.push({kind:"text",text:o.text,props:We(o)});return}o.type.name==="tab"?n.push({kind:"tab"}):o.type.name==="hardBreak"?n.push({kind:"hardBreak"}):o.type.name==="pageBreak"?n.push({kind:"pageBreak"}):o.type.name==="unknownInline"&&n.push({kind:"unknown",nodeId:String(o.attrs.nodeId??""),label:String(o.attrs.label??""),modelLength:e.has(String(o.attrs.nodeId??""))?1:0});}),n}function w(t){let e="";for(let n of t)n.kind==="text"?e+=n.text:n.kind==="tab"?e+=" ":n.kind==="hardBreak"?e+=`
2
+ `:n.kind==="pageBreak"?e+=Sd:n.modelLength===1&&(e+=Xd);return e}function L(t){let e=[],n=0;for(let o of t)o.kind==="text"?n+=o.text.length:o.kind==="tab"||o.kind==="hardBreak"||o.kind==="pageBreak"?n+=1:(e.push(`${o.nodeId}@${n}`),n+=o.modelLength);return e}function Io(t,e){if(t===e)return null;let n=0,o=Math.min(t.length,e.length);for(;n<o&&t[n]===e[n];)n+=1;let a=t.length,s=e.length;for(;a>n&&s>n&&t[a-1]===e[s-1];)a-=1,s-=1;return {start:n,endBefore:a,endAfter:s}}function Nn(t){let e=[];for(let n of t)if(n.kind==="text")for(let o=0;o<n.text.length;o+=1)e.push(n.props);else n.kind==="tab"||n.kind==="hardBreak"||n.kind==="pageBreak"?e.push(e[e.length-1]??[]):n.kind==="unknown"&&n.modelLength===1&&e.push([]);return e}function Eo(t,e,n,o,a){let s=[],r=w(e),d=w(n),c=Io(r,d),f=[],m=0,k=false;for(let h of e){if(h.kind!=="unknown"){m+=h.kind==="text"?h.text.length:1;continue}let u=m;h.modelLength===1&&c&&(c.start<m+1&&c.endBefore>m&&(k=true),c.endBefore<=m&&(u+=c.endAfter-c.endBefore)),f.push(`${h.nodeId}@${u}`),m+=h.modelLength;}if(k||JSON.stringify(f)!==JSON.stringify(L(n)))return {ok:false,reason:"unknown-content-moved",detail:t};if(Oe(o,a)||s.push({op:"setParagraphProperties",paragraphId:t,properties:Pe(a)}),c&&(c.endBefore>c.start&&s.push({op:"deleteText",paragraphId:t,start:c.start,end:c.endBefore}),c.endAfter>c.start)){let h=d.slice(c.start,c.endAfter),u=c.start,y="",O=()=>{y.length!==0&&(s.push({op:"insertText",paragraphId:t,offset:u,text:y}),u+=y.length,y="");};for(let R of h)R===" "?(O(),s.push({op:"insertTab",paragraphId:t,offset:u}),u+=1):R===`
3
+ `?(O(),s.push({op:"insertHardBreak",paragraphId:t,offset:u}),u+=1):R===Sd?(O(),s.push({op:"insertPageBreak",paragraphId:t,offset:u}),u+=1):y+=R;O();}if(!c){let h=Nn(e),u=Nn(n),y=0;for(;y<u.length;){if(Oe(h[y]??[],u[y])){y+=1;continue}let O=y,R=u[y];for(;y<u.length&&Oe(u[y],R)&&!Oe(h[y]??[],u[y]);)y+=1;s.push({op:"setRunProperties",paragraphId:t,start:O,end:y,properties:Pe(R)});}}return {ok:true,ops:s}}function Ye(t,e){let n=ee(t),o=new Set;for(let d of n)for(let c of A(d))c.kind==="unknown"&&c.modelLength===1&&o.add(c.nodeId);let a=d=>No(d,o),s=[];if(e.forEach(d=>{d.type.name==="paragraph"&&s.push(d);}),s.length!==e.childCount)return {ok:false,reason:"unsupported-node"};let r=s.length-n.length;if(r===0){let d=[];for(let[c,f]of s.entries()){let m=n[c];if(f.attrs.nodeId!==m.id)return {ok:false,reason:"paragraph-reordered",detail:String(f.attrs.nodeId)};let k=Eo(m.id,A(m),a(f),Je(m.kind==="textValue"?void 0:m.children.find(h=>h.kind==="paragraphProperties")),f.attrs.props??[]);if(!k.ok)return k;d.push(...k.ops);}return {ok:true,ops:d}}return r===1?Mo(n,s,a):r===-1?Co(n,s,a):{ok:false,reason:"paragraph-count-unexplained",detail:String(r)}}function Mo(t,e,n){for(let o=0;o<t.length;o+=1){let a=t[o],s=e[o],r=e[o+1];if(!s||!r||s.attrs.nodeId!==a.id)continue;let d=r.attrs.nodeId;if(d!==null&&d!==a.id)continue;let c=n(s),f=n(r),m=A(a),k=w(c);if(k+w(f)===w(m)&&JSON.stringify(L([...c,...f]))===JSON.stringify(L(m))&&In(t,e,o,n)&&En(t,e,o+1,o+2,n))return {ok:true,ops:[{op:"splitParagraph",paragraphId:a.id,offset:k.length}]}}return {ok:false,reason:"split-not-clean"}}function Co(t,e,n){for(let o=0;o+1<t.length;o+=1){let a=t[o],s=t[o+1],r=e[o];if(!r||r.attrs.nodeId!==a.id)continue;let d=[...A(a),...A(s)],c=n(r);if(w(c)===w(d)&&JSON.stringify(L(c))===JSON.stringify(L(d))&&In(t,e,o,n)&&En(t,e,o+2,o+1,n))return {ok:true,ops:[{op:"joinParagraphs",firstId:a.id,secondId:s.id}]}}return {ok:false,reason:"join-not-clean"}}function In(t,e,n,o){for(let a=0;a<n;a+=1){let s=e[a],r=t[a];if(!s||s.attrs.nodeId!==r.id||w(o(s))!==w(A(r))||JSON.stringify(L(o(s)))!==JSON.stringify(L(A(r))))return false}return true}function En(t,e,n,o,a){for(let s=0;n+s<t.length;s+=1){let r=t[n+s],d=e[o+s];if(!d||d.attrs.nodeId!==r.id||w(a(d))!==w(A(r))||JSON.stringify(L(a(d)))!==JSON.stringify(L(A(r))))return false}return true}function wo(t,e){return Ga(t,e)!==null}function Ue(t,e,n){if(!n||n.created.length>0||n.deleted.length>0||n.splitJoin.length>0)return J(e);let o=new Map;t.forEach(c=>{let f=c.attrs.nodeId;typeof f=="string"&&o.set(f,c);});let a=new Set(n.dirty),s=ee(e);if(s.length!==t.childCount)return J(e);let r=J(e),d=[];for(let[c,f]of s.entries()){let m=o.get(f.id);d.push(m&&!a.has(f.id)?m:r.child(c));}return I.node("doc",null,d)}function Cn(t){return F(t).map(e=>Qh(t,e.id)??"").join(`
4
+ `)}var Do=64,Mn=new WeakMap;function Ge(t,e=0){if(e>Do)return false;let n=Mn.get(t);if(n!==void 0)return n;let o=false;for(let a of t.children)if(a.kind!=="textValue"&&(a.kind==="commentRangeStart"||a.kind==="commentReference"||Ge(a,e+1))){o=true;break}return Mn.set(t,o),o}function Ao(t,e){let n=t.kind==="revision"?t.ranges[0]??null:t.range;if(!n)return null;let o=e.get(n.start.paragraphId);return o===void 0?null:o}function wn(t,e,n){for(let a of e)if(a.ranges.length===0)return false;let o=new Set;for(let a of t)a.kind!=="revision"||a.ranges.length>0||An(a,n)||o.add(xa(a));for(let a of e)if(o.has(xa(a)))return false;return true}function Dn(t,e,n,o){let a=e.get(n);if(a===void 0)return [...t];let s=[],r=null;for(let d of t){if(d.kind==="revision"&&An(d,n)){r===null&&(r=s.length);continue}if(r===null){let c=Ao(d,e);c!==null&&c>a&&(r=s.length);}s.push(d);}if(r===null&&(r=s.length),o.length>0){let d=o.length<2?[...o]:[...o].sort((c,f)=>Aa(c,e)-Aa(f,e));s.splice(r,0,...d);}return Ma(s)}function An(t,e){return t.ranges.length>0&&t.ranges.every(n=>n.start.paragraphId===e&&n.end.paragraphId===e)}function Fo(t,e){return t.range?t.range.start.paragraphId===e||t.range.end.paragraphId===e:false}function Lo(t,e){return t.revisionKind==="structural"&&t.ranges.some(n=>n.start.paragraphId===e||n.end.paragraphId===e)}function Bo(t,e){return t.ranges.length===0||!t.ranges.some(o=>o.start.paragraphId===e||o.end.paragraphId===e)?false:!t.ranges.every(o=>o.start.paragraphId===e&&o.end.paragraphId===e)}function Fn(t,e,n,o,a,s,r){if(t.fromRevision!==e.bodyRevision||r!==e.packageRevision+1||t.story!==void 0&&t.story.kind!=="body"||t.impact!=="text-local"||t.dirty.length!==1||t.created.length>0||t.deleted.length>0||t.splitJoin.length>0||e.commentsPart!==a||e.commentsExtendedPart!==s)return null;let d=t.dirty[0],c=Ga(o,d);if(!c||c.kind!=="paragraph")return null;let f=Ha(o,d);if(f){let m=f.children.findIndex(h=>h.id===d),k=f.children[m-1];if(k?.kind==="paragraph"&&mh({...o,root:k}).some(h=>h.paragraphMark))return null}for(let m of n){if(m.kind==="comment"){if(Fo(m,d))return null;continue}if(m.kind==="custom"){if(m.range?.start.paragraphId===d)return null;continue}if(Lo(m,d)||Bo(m,d))return null}return d}var _n=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u,_o=["ascii","hAnsi","cs","eastAsia"],jo=["asciiTheme","hAnsiTheme","cstheme","eastAsiaTheme"],Ho=128,$o=/[\u0000-\u001F\u007F-\u009F]/;function D(t){return t.kind!=="textValue"}function Y(t,e){return t.attributes.find(n=>n.localName===e)?.value}function jn(t,e){let n=new Map;for(let a of t)for(let s of a.children)if(D(s))for(let[r,d]of zn(s,e))n.has(r)||n.set(r,d);let o=[...n.values()];return o.sort((a,s)=>a<s?-1:a>s?1:0),o}var Ke=new WeakMap,Hn=16,$n=32;function zn(t,e,n=0){let o=e?.major??null,a=e?.minor??null,s=e?.majorEastAsia??null,r=e?.minorEastAsia??null,d=Ke.get(t);if(d&&d.major===o&&d.minor===a&&d.majorEastAsia===s&&d.minorEastAsia===r)return d.byFold;if(t.children.length>=Hn&&n<$n&&t.localName!=="rFonts"){let k=new Map;for(let h of t.children)if(D(h))for(let[u,y]of zn(h,e,n+1))k.has(u)||k.set(u,y);return Ke.set(t,{major:o,minor:a,majorEastAsia:s,minorEastAsia:r,byFold:k}),k}let c=new Map,f=k=>{if(!k||!_n.test(k))return;let h=k.toLowerCase();c.has(h)||c.set(h,k);},m=[t];for(;m.length>0;){let k=m.pop();if(D(k)){if(k.localName==="rFonts"){for(let h of _o)f(Y(k,h));if(e)for(let h of jo)f(b$3(Y(k,h),e));}for(let h=k.children.length-1;h>=0;h-=1)m.push(k.children[h]);}}return Ke.set(t,{major:o,minor:a,majorEastAsia:s,minorEastAsia:r,byFold:c}),c}function Wn(t){let e=new Map;for(let o of t)for(let a of o.children)if(D(a))for(let[s,r]of Jn(a))e.has(s)||e.set(s,r);let n=[...e.values()];return n.sort((o,a)=>o<a?-1:o>a?1:0),n}var Ln=new WeakMap,zo=new Map;function Jn(t,e=0){let n=Ln.get(t);if(n)return n;let o=r=>{let d=r.size===0?zo:r;return Ln.set(t,d),d},a=new Map;if(t.children.length>=Hn&&e<$n&&t.localName!=="sym"){for(let r of t.children)if(D(r))for(let[d,c]of Jn(r,e+1))a.has(d)||a.set(d,c);return o(a)}let s=[t];for(;s.length>0;){let r=s.pop();if(D(r)){if(r.localName==="sym"&&r.namespaceUri===da){let d=r.attributes.find(f=>f.localName==="font"&&(f.namespaceUri===da||f.namespaceUri===""))?.value,c=b$2(d);c!==null&&!a.has(c.toLowerCase())&&a.set(c.toLowerCase(),c);}for(let d=r.children.length-1;d>=0;d-=1)s.push(r.children[d]);}}return o(a)}function Yn(t){let e=[...t];for(;e.length>0;){let n=e.pop();if(D(n)){if(n.localName==="t"&&n.namespaceUri===da){for(let o of n.children)if(!D(o)&&o.value.length>0)return true;continue}for(let o of n.children)e.push(o);}}return false}var Wo=new Set(["paragraph","character","table","numbering"]),Jo=/^[0-9A-Fa-f]{6}$/,Yo=16,Bn=new Map([["normal",0],["title",1],["subtitle",2],["heading 1",11],["heading 2",12],["heading 3",13],["heading 4",14],["heading 5",15],["heading 6",16],["heading 7",17],["heading 8",18],["heading 9",19]]);function Un(t){return t.children}function Xe(t,e){for(let n of Un(t))if(D(n)&&n.localName===e)return n}function Uo(t){return Bn.get(t.name.toLowerCase())??Bn.get(t.styleId.toLowerCase())??Number.MAX_SAFE_INTEGER}function Ve(t){return t===void 0||t.length===0||t.length>Ho||$o.test(t)?null:t}function Gn(t,e){if(!t)return [];let n=new Map;for(let s of t.children){if(!D(s)||s.localName!=="style")continue;let r=Ve(Y(s,"styleId"));r!==null&&!n.has(r)&&n.set(r,s);}let o=s=>{let r=false,d=false,c=null,f=false,m=false,k=new Set,h=s;for(let O=0;O<Yo&&h!==null&&!k.has(h);O+=1){k.add(h);let R=n.get(h);if(!R)break;let b=Xe(R,"rPr");for(let T of b?Un(b):[]){if(!D(T))continue;let v=Y(T,"val"),E=v!=="0"&&v!=="false"&&v!=="off";T.localName==="b"&&!f?(r=E,f=true):T.localName==="i"&&!m?(d=E,m=true):T.localName==="color"&&c===null&&v&&Jo.test(v)&&(c=v);}let S=Xe(R,"basedOn");h=S?Ve(Y(S,"val")):null;}let u=e?.(s),y=u?.fontFamily??null;return {fontFamily:y!==null&&_n.test(y)?y:null,fontSizePt:u?.fontSizeHalfPoints!=null&&u.fontSizeHalfPoints>0?u.fontSizeHalfPoints/2:null,bold:r,italic:d,color:c}},a=[];for(let[s,r]of n){let d=Y(r,"type");if(d===void 0||!Wo.has(d))continue;let c=Xe(r,"name"),f=Ve(c?Y(c,"val"):void 0);a.push({styleId:s,name:f??s,type:d,preview:o(s)});}return a.map((s,r)=>({entry:s,index:r,rank:Uo(s)})).sort((s,r)=>s.rank-r.rank||s.index-r.index).map(s=>s.entry)}var Go=128,Ko=/[\u0000-\u001F\u007F-\u009F]/,Xo=/[\u0000-\u001F\u007F-\u009F]/g,Vo=200;function Ze(t){return t.kind!=="textValue"}function Kn(t,e){for(let n of t.children)if(Ze(n)&&n.localName===e)return n}function Qe(t,e){return t.attributes.find(n=>n.localName===e)?.value}function Qo(t){let e=new Map;if(!t)return e;for(let n of t.children){if(!Ze(n)||n.localName!=="style"||Qe(n,"type")!=="paragraph")continue;let o=Qe(n,"styleId");if(o===void 0||o.length===0||o.length>Go||Ko.test(o))continue;let a=a$2(n);a!==null&&e.set(o,a);}return e}function qe(t){let e=Kn(t,"pPr"),n=e?Kn(e,"pStyle"):void 0;return n?Qe(n,"val"):void 0}function Xn(t,e){let n=Qo(e);if(n.size===0)return [];let o=[];for(let a of ee(t)){if(!Ze(a))continue;let s=qe(a);if(s===void 0)continue;let r=n.get(s);if(r===void 0)continue;let c=(Qh(t,a.id)??"").replace(Xo," ").trim().slice(0,Vo);c.length!==0&&o.push({text:c,level:r,blockId:a.id});}return o}function Zo(t,e,n){let o=new Map,a=n(t);for(let s of a){let r=o.get(s.hostParagraphId);r?r.push(s):o.set(s.hostParagraphId,[s]);}return o}function qo(t,e,n){let o=[];for(let a of zd(t.root)){let s=e.get(a.id);if(s)for(let r of s)o.push(r);}return o}function Vn(t,e,n=yg){let o=[],a=new Map;for(let s of t){if(o.push(s),s.scope?.kind==="note")continue;let r=a.get(s.part);r||(r=Zo(s.part,e,n),a.set(s.part,r));for(let d of qo(s,r)){let c=s.scope;o.push({part:s.part,root:d.root,scope:{kind:"frame",id:d.root.id,drawingNodeId:d.drawingNodeId,hostParagraphId:d.hostParagraphId,...c?.kind==="headerFooter"?{owner:c}:{}}});}}return o}var Se=48,er=/[\u0000-\u001F\u007F-\u009F]/g;function tr(t){let e=[],n=Ne(t),o=new Map;for(let a of n.segments)de(a.node)&&o.set(a.node.id,a.formatRunIds??[]);return Jd(t.children,0,a=>{if(a.kind==="run"){e.push({id:a.id,start:n.spanOf(a)?.start??0});return}if(de(a))for(let s of o.get(a.id)??[]){let r=n.spanOf(s);r&&e.push({id:s,start:r.start});}},{descendRevisions:true}),e}function nr(t){let e=yd(t);return e?[{part:t,root:e}]:[]}function or(t,e){let n=[];for(let o of ["header","footer"])for(let a of t){let s=o==="header"?a.headers:a.footers;for(let[r,d]of s){if(!Kd(a,r)||e.has(d.part))continue;e.add(d.part);let c=wd(d.part).find(f=>f.kind===o);c&&n.push({part:d.part,root:c.root,scope:{kind:"headerFooter",rId:d.rId}});}}return n}function Qn(t,e,n){if(!t)return [];let o=[];for(let a of sd(t.root)){let s=gd(a);!id(a)||s===null||!n.has(s)||o.push({part:t,root:a,scope:{kind:"note",id:Yc(e,s)}});}return o}function rr(t,e){let n=nr(t);if(e){let o=new Set;for(let a of or(e.headerFooterBySection,o))n.push(a);for(let a of Qn(e.footnotes,"footnote",e.referencedNoteIds.footnote))n.push(a);for(let a of Qn(e.endnotes,"endnote",e.referencedNoteIds.endnote))n.push(a);}return Vn(n)}function Zn(t,e){if(t.length===0)return {index:0,offset:e};for(let n=t.length-1;n>=0;n-=1){let o=t[n].start;if(e>=o)return {index:n,offset:e-o}}return {index:0,offset:e}}function ar(t,e,n){let o=t.findIndex(a=>a.id===e);return o<0?null:{index:o,offset:n}}function et(t,e){return t.replace(er," ").slice(0,e)}function qn(t,e,n={},o){let a={matches:[],truncated:false};if(!Ra(e))return a;let s=n.limit!==void 0&&Number.isInteger(n.limit)&&n.limit>0?Math.min(n.limit,2e3):2e3,r={...n.matchCase===void 0?{}:{matchCase:n.matchCase},...n.wholeWord===void 0?{}:{wholeWord:n.wholeWord}},d$1=[],c=n.stories==="body"?void 0:o;for(let f of rr(t,c)){let m=0;for(let k of zd(f.root)){if(k.kind!=="paragraph")continue;let h=m;m+=1;let u=Qh(f.part,k.id)??"",y=d(k,u);if(y.text.length===0)continue;let O=s-d$1.length,R=y.findOccurrences(e,Math.max(O,1),r);if(O===0&&R.matches.length>0)return {matches:d$1,truncated:true};let b=null;for(let S of R.matches){let T=S.start+S.length;b??=tr(k);let v=y.resultRunAddressAt(S.start),E=v?ar(b,v.runId,v.offset)??Zn(b,S.rawStart):Zn(b,S.rawStart);d$1.push({blockId:k.id,start:S.rawStart,length:S.rawEnd-S.rawStart,paragraphIndex:h,runIndex:E.index,runOffset:E.offset,...f.scope?{scope:f.scope}:{},text:et(y.text.slice(S.start,T),256),contextBefore:et(y.text.slice(Math.max(0,S.start-Se),S.start),Se),contextAfter:et(y.text.slice(T,T+Se),Se)});}if(R.truncated)return {matches:d$1,truncated:true}}}return {matches:d$1,truncated:false}}var sr=["lt1","dk1","lt2","dk2","accent1","accent2","accent3","accent4","accent5","accent6"];function te(t){return a(t)}function eo(t){let e=ab(t),n=[];for(let o of sr){let a=e.get(o);if(!a)return [];n.push({slot:o,hex:a});}return n}var to=new WeakMap;function nt(t){let e=to.get(t);if(e!==void 0)return e;let n=Eb(t),o=n===null||!Db(n)?null:n;return to.set(t,o),o}var tt=class{#e;#t;constructor(e,n){this.#e=e,this.#t=n;}get size(){return this.#e.size}get(e){if(this.#e.has(e))return this.#t.find(n=>e.startsWith(`${n.name}#`))}has(e){return this.get(e)!==void 0}*entries(){for(let e of this.#e.keys()){let n=this.get(e);n&&(yield [e,n]);}}keys(){return this.#e.keys()}*values(){for(let[,e]of this.entries())yield e;}[Symbol.iterator](){return this.entries()}forEach(e,n){for(let[o,a]of this.entries())e.call(n,a,o,this);}};function no(t,e){return Object.freeze({...t,partByNode:new tt(t.ordinalByNode,e)})}function oo(t){let e=new Map,n=new Map,o=new Map,a=new Set,s=new Map,r=new Map,d=0;for(let c of t)for(let f of F(c)){o.set(f.id,d),s.set(f.id,c),d+=1;let m=nt(f);if(m===null)continue;e.set(f.id,m);let k=m.toUpperCase(),h=r.get(k);h?(h.push(f.id),a.add(k)):(r.set(k,[f.id]),n.set(k,f.id));}return Object.freeze({paraIdByNode:e,nodeByParaId:n,ordinalByNode:o,ambiguousParaIds:a,partByNode:s,claimantsByParaId:r})}function ro(t,e){let n=t.indexOf("#");if(n<=0)return null;let o=t.slice(0,n),a=e.body.name===o?e.body:void 0;a??=e.openStories.find(d=>d.name===o);let s=a?void 0:e.otherStories.find(d=>d.name===o);if(a??=s?e.normalize(s):void 0,!a)return null;let r=Ga(a,t);return r?.kind==="paragraph"?nt(r):null}var ao={committed:false,rejected:false,opCount:0};function U(t,e){return e===void 0?{committed:false,rejected:true,opCount:t}:{committed:false,rejected:true,opCount:t,reason:e}}function so(t,e,n={}){let o=e.filter(f=>f.ops.length>0),a=o.reduce((f,m)=>f+m.ops.length,0);if(a===0)return ao;if(o.some(f=>f.ops.some(rf))||o.some(f=>f.ops.some(_f)))return U(a,"invalidArgs");let[s,...r]=o,d=[];for(let f of r){let m=t.partFor(f.scope);if(!m)return U(a,"unknown-part");d.push({partName:m.name,ops:f.ops});}let c=t.transact(s.scope,f=>{for(let m of s.ops)f.apply(m);for(let m of d)for(let k of m.ops)f.applyTo(m.partName,k);},n);return c.ok?{committed:true,rejected:false,opCount:a}:U(a,c.reason)}function io(t,e,n,o,a,s){if(e.length===0)return ao;let r=e.filter(f=>rf(f)||_f(f)).length;if(r>0){if(r!==e.length||e.length!==1)return U(e.length,"invalidArgs");let f=Mb(s.actorId,()=>t.applyLifecycleOp(e[0]));return f.ok?{committed:true,rejected:false,opCount:1}:U(1,f.detail??f.reason)}let d=s.recordsHistory===false&&s.actorId&&s.operationId?t.partFor(a)?.name:void 0,c=t.transact(a,f=>{n!==void 0&&f.selectionBefore(n),o!==void 0&&f.selectionAfter(o);for(let m of e)f.apply(m);d&&f.applyPackage(m=>a$1(m,d,e));},s);return c.ok?{committed:true,rejected:false,opCount:e.length}:U(e.length,c.reason)}var ir=Object.freeze([]);function lr(t,e$1={}){let n=cc(t);if(!n.ok)return {ok:false,reason:n.reason,...n.detail?{detail:n.detail}:{}};let o=n.package,a=o.parts.get(o.mainDocumentPart);if(!a)return {ok:false,reason:"no-main-document-tree",detail:o.mainDocumentPart};let s=Kb(a),r=new G(o,s),d=null,c$1=null,f=null,m=null,k=null;r.subscribe(i=>{m=i,k=r.currentPackage();});let h=()=>r.bodyStore(),u=()=>r.currentPackage(),y=Object.freeze({kind:"body"}),O=(i,l)=>{let p=l?.find(x=>x.type==="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings");if(!p)return;let g=E(p);return g.mode==="Internal"&&g.target.ok?i.parts.get(g.target.partName):void 0},R$1=(i,l,p)=>{if(i.mainRelationships!==p||i.settingsPart!==O(l,p))return false;for(let g of i.resolution)for(let x of [g.headers,g.footers])for(let P of x.values())if(l.parts.get(P.partName)!==P.part)return false;return true},b=()=>{let i=u(),l=i.relationships.get(i.mainDocumentPart);if(d&&m&&k===i&&R$1(d,i,l)&&d.packageRevision===m.fromRevision&&r.packageRevision===m.toRevision&&m.story?.kind==="body"&&m.impact==="text-local"&&m.created.length===0&&m.deleted.length===0&&m.splitJoin.length===0&&(d={...d,packageRevision:r.packageRevision,pkg:i,mainRelationships:l,settingsPart:O(i,l)}),!d||d.packageRevision!==r.packageRevision||d.pkg!==i){let p=Nd(i);d={packageRevision:r.packageRevision,pkg:i,mainRelationships:l,settingsPart:O(i,l),resolution:p,parts:Md(p)};}return d},S$1="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",T$1="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",v=null,E$1=()=>{let i=u(),l=(i.relationships.get(i.mainDocumentPart)??[]).find(x=>x.type===S$1),p;if(l){let x=E(l);x.mode==="Internal"&&x.target.ok&&(p=i.parts.get(x.target.partName));}p??=i.parts.get("/word/styles.xml");let g=p?.root??null;return g!==v&&(v=g,ue=null,V=null),v},G$1=null,B=null,ne=()=>{let i=u();if(G$1===i)return B;G$1=i;let l=(i.relationships.get(i.mainDocumentPart)??[]).find(g=>g.type===T$1),p;if(l){let g=E(l);g.mode==="Internal"&&g.target.ok&&(p=i.parts.get(g.target.partName));}return p??=i.parts.get("/word/numbering.xml"),B=p?.root??null,B},be="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",ot=null,Re=null,rt=()=>{let i=u();if(ot===i)return Re;ot=i;let l=(i.relationships.get(i.mainDocumentPart)??[]).find(g=>g.type===be),p;if(l){let g=E(l);g.mode==="Internal"&&g.target.ok&&(p=i.parts.get(g.target.partName));}return p??=i.parts.get("/word/settings.xml"),Re=p?.root??null,Re},co="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",uo="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",at=(i,l)=>{let p=u(),g=(p.relationships.get("/")??[]).find(P=>P.type===i),x;if(g){let P=E(g);P.mode==="Internal"&&P.target.ok&&(x=p.parts.get(P.target.partName));}return x??p.parts.get(l)},st=null,ve=wg,po=()=>{let i=u();if(st===i)return ve;st=i;let l=at(co,"/docProps/core.xml"),p=at(uo,"/docProps/app.xml");return ve=xg(l?.root??null,p?.root??null),ve},fo="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",it=null,de=null,K=()=>{let i=u();if(it===i)return de;it=i;let l=(i.relationships.get(i.mainDocumentPart)??[]).find(x=>x.type===fo),p;if(l){let x=E(l);x.mode==="Internal"&&x.target.ok&&(p=i.parts.get(x.target.partName));}p??=i.parts.get("/word/theme/theme1.xml");let g=p?.root??null;return g!==de&&(de=g,Ne=null,Te$1=null,ue=null,V=null),de},mo="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",ce=null,go=()=>{if(ce)return ce;let i=u(),l=(i.relationships.get(i.mainDocumentPart)??[]).find(g=>g.type===mo),p;if(l){let g=E(l);g.mode==="Internal"&&g.target.ok&&(p=i.parts.get(g.target.partName));}return p??=i.parts.get("/word/fontTable.xml"),ce=Object.freeze(Rd(i,p)),ce},oe=null,X=null,re=null,ae=null,ue=null,Te$1=null,Ne=null,lt=()=>{let i=[h().part.root],l=new Set;for(let p of _())l.has(p)||(l.add(p),i.push(p.root));return i},Ie=()=>{let i=lt(),l=E$1();return l&&i.splice(1,0,l),i},V=null,pe=null,se=null,ie=null,Q$1=null,dt=new WeakMap,fe=null,ct=i=>{let l=dt.get(i);if(l)return l;let p=Kb(i);return dt.set(i,p),p},ut=()=>{let i=r.packageRevision,l=r.openStoryToken();if(!Q$1||Q$1.revision!==i||Q$1.openStories!==l){let p=r.openStoryParts(),g=new Set(p.map(M=>M.name)),x=_().filter(M=>!g.has(M.name)).map(ct),P=[h().part,...p,...x],N=Q$1,C=N!==null&&m!==null&&N.openStories===l&&N.revision===m.fromRevision&&i===m.toRevision&&m.impact==="text-local"&&m.created.length===0&&m.deleted.length===0&&m.splitJoin.length===0&&N.parts.length===P.length&&N.parts.every((M,Z)=>M.name===P[Z]?.name);Q$1={revision:i,openStories:l,parts:P,index:C&&N?no(N.index,P):oo(P)};}return Q$1.index},pt=()=>{let i=h().part.name,l=new Map;for(let p of [h().part,..._()])for(let[g,x]of Z(u(),p.name,i))l.set(g,x);return l},yo=()=>[h().part,..._()],_=()=>{let i=[],l=new Set;for(let g of b().parts)for(let x of [g.headers,g.footers])for(let P of x.values())l.has(P)||(l.add(P),i.push(P));let p=u();for(let g of ["footnote","endnote"]){let x=Jf(p,g);!x||l.has(x)||(l.add(x),i.push(x));}return i};return {ok:true,session:{editable:F(h().part).length>0,paragraphIds:()=>F(h().part).map(i=>i.id),paragraphIdsIn(i=y){let l=r.partFor(i);return l?F(l).map(p=>p.id):[]},part:()=>h().part,partFor:i=>r.partFor(i),currentPackage:u,collaborationPort:i=>b$1(r,{documentId:i}),applyTreeOps(i,l,p,g=y,x={}){return io(r,i,l,p,g,x)},applyTreeOpsAtomic(i,l={}){return so(r,i,l)},projectDoc:()=>J(h().part),reconcile:i=>Ue(i,h().part,m),lastCommitWasStructural:()=>m!==null&&(m.created.length>0||m.deleted.length>0||m.splitJoin.length>0||m.impact==="global"),applyPmDoc(i){let l=h(),p=Ye(l.part,i);if(!p.ok)return {committed:false,rejected:true,opCount:0,reason:p.reason};if(p.ops.length===0)return {committed:false,rejected:false,opCount:0};let g=r.transact(y,x=>{for(let P of p.ops)x.apply(P);});return g.ok?{committed:true,rejected:false,opCount:p.ops.length}:{committed:false,rejected:true,opCount:p.ops.length,reason:g.reason}},storyParts:yo,bodyText:()=>Cn(h().part),storyText(i){let l=r.partFor(i);return l?F(l).map(p=>Qh(l,p.id)??"").join(`
5
+ `):null},revision:()=>h().revision,revisionFor:i=>r.revisionFor(i),packageRevision:()=>r.packageRevision,canUndo:()=>r.canUndo,canRedo:()=>r.canRedo,undo:()=>{let i=r.selectionForUndo();return r.undo()===null?null:i},redo:()=>{let i=r.selectionForRedo();return r.redo()===null?null:i},beginComposition:(i=y)=>{r.beginComposition(i);},endComposition:()=>r.endComposition(),subscribe(i){return r.subscribe(i)},save(){return dc(u())},headerFooterParts:()=>{let i=b().parts;return i[i.length-1]??Pd(u())},headerFooterPartsBySection:()=>b().parts,headerFooterResolutionBySection:()=>b().resolution,documentFonts(){return oe&&oe.revision===r.packageRevision||(oe={revision:r.packageRevision,fonts:jn(Ie(),te(K()))}),oe.fonts},symbolFontFamilies(){return re&&re.revision===r.packageRevision||(re={revision:r.packageRevision,fonts:Wn(Ie())}),re.fonts},renderedFontFamilies(){let i=E$1();return X&&X.revision===r.packageRevision&&X.styles===i||(X={revision:r.packageRevision,styles:i,families:e(lt(),i,te(K()))}),X.families},rendersText(){return ae&&ae.revision===r.packageRevision||(ae={revision:r.packageRevision,rendersText:Yn(Ie())}),ae.rendersText},documentStyles(){let i=E$1(),l=K();V??=c(i,te(l));let p=V;return ue??=Gn(i,g=>p(g)),ue},stylesRoot:()=>E$1(),documentThemeFonts(){let i=K();return Ne??=te(i),Ne},numberingRoot:()=>ne(),settingsRoot:()=>rt(),documentProperties:()=>po(),trackingSettings:()=>tg(rt()),documentThemeColors(){let i=K();return Te$1??=eo(i),Te$1},effectiveRunDefaults(i,l){let p=E$1(),g=K();V??=c(p,te(g));let x=h();if(!pe||pe.revision!==x.revision){let P=new Map;for(let N of F(x.part))N.kind!=="textValue"&&P.set(N.id,qe(N)??null);pe={revision:x.revision,byId:P};}return V(pe.byId.get(i)??null,l)},documentOutline(){let i=h();return se&&se.revision===i.revision||(se={revision:i.revision,outline:Xn(i.part,E$1())}),se.outline},findText(i,l){let p=h(),g=r.packageRevision,x=`${l?.matchCase===true?"c":""}${l?.wholeWord===true?"w":""}${l?.limit??""}:${l?.stories??"all"}\0${i}`;if(ie&&ie.revision===g&&ie.key===x)return ie.result;let P=u(),N={footnote:new Set,endnote:new Set};for(let M of Kf(p.part))N[M.noteKind].add(M.noteId);let C=qn(p.part,i,l??{},{headerFooterBySection:b().resolution,footnotes:Jf(P,"footnote")??null,endnotes:Jf(P,"endnote")??null,referencedNoteIds:N});return ie={revision:g,key:x,result:C},C},embeddedFonts:go,paragraphAnchors:ut,paraIdOf:i=>ro(i,{body:h().part,openStories:r.openStoryParts(),otherStories:_(),normalize:ct}),nodeIdOf:i=>ut().nodeByParaId.get(i.toUpperCase())??null,relationshipTarget:(i,l=y)=>{let p=u(),g=r.partFor(l);return g?pf(p,g.name,i):null},bookmarks:()=>{let i=r.packageRevision;if(!fe||fe.revision!==i){let l=new Map(Te(h().part));for(let p of _())for(let[g,x]of Te(p))l.has(g)||l.set(g,x);fe={revision:i,index:l};}return fe.index},ensureHyperlinkRelationship(i,l=y){let p=r.partFor(l);return p?Ba(r,()=>{let g=u(),x=of(g,i,p.name);return x?(x.pkg!==g&&r.replacePackageShell(x.pkg),x.relationshipId):null},g=>g!==null):null},reviewItems(){let i=e$1.reviewModel;if(!i)return ir;let l=h(),p=`${r.packageRevision}:${l.revision}`;if(c$1&&c$1.revisionKey===p)return c$1.items;let g=u(),x=g.parts.get(P(g,l.part.name)),P$1=g.parts.get(Q(g,l.part.name)),N=_(),C=c$1&&m?Fn(m,c$1,c$1.items,l.part,x,P$1,r.packageRevision):null,M,Z;if(C&&c$1){let ft=i.revisionItemsOfParagraph(l.part,C);wn(c$1.items,ft,C)?(M=Dn(c$1.items,c$1.paragraphOrder,C,ft),Z=c$1.paragraphOrder):(Z=Ga$1(l.part),M=i.collectReviewItems({storyPart:l.part,furnitureParts:N,commentsPart:x,commentsExtendedPart:P$1,customNodePayloads:pt()}));}else Z=Ga$1(l.part),M=i.collectReviewItems({storyPart:l.part,furnitureParts:N,commentsPart:x,commentsExtendedPart:P$1,customNodePayloads:pt()});return c$1={revisionKey:p,bodyRevision:l.revision,packageRevision:r.packageRevision,items:M,paragraphOrder:Z,commentsPart:x,commentsExtendedPart:P$1},c$1.items},hasReviewContent(){let i=r.packageRevision;if(!f||f.revision!==i){let l=[h().part,..._()];f={revision:i,present:l.some(p=>mh(p).length>0||Ge(p.root))};}return f.present},replyToComment(i,l,p,g,x,P=y,N){let C=R(r,{anchor:{paragraphId:l.paragraphId,start:l.start,end:l.end,...l.endParagraphId===void 0?{}:{endParagraphId:l.endParagraphId}},author:g,text:p,...x===void 0?{}:{date:x},...i===null?{}:{replyToCommentId:i},...N===void 0?{}:{actorId:N}},P);return C.ok?C.commentId:null},setCommentResolved(i,l){return S(r,i,l).ok},deleteComment(i,l=y,p){return this.deleteComments([{commentId:i}],l,p)},deleteComments(i,l=y,p){return T(r,i,l,p)},insertCustomNode(i,l=y){return $$1(r,i,l)},removeCustomNode(i,l=y){return aa(r,i,l)},sweepCustomNodePayloads(i){return Ba(r,()=>{let l=h(),p=Y$1(r.currentPackage(),l.part.name,i);return p.ok?p.removed.length===0?{ok:true,removed:[]}:(r.replacePackageShell(p.pkg),{ok:true,removed:p.removed}):{ok:false,reason:p.reason}},l=>l.ok&&l.removed.length>0)},ensureListDefinition(i){return Ba(r,()=>{let l=lf(u(),i);return l?(r.replacePackageShell(l.pkg),G$1=null,B=null,l.numId):null},l=>l!==null)},ensureNumberingLevel(i,l,p){return Ba(r,()=>{let g=u(),x=mf(g,i,l,p);return x?x!==g?(r.replacePackageShell(x),G$1=null,B=null,{ok:true,changed:true}):{ok:true,changed:false}:{ok:false,changed:false}},g=>g.changed).ok},insertImage(i,l){return r.insertImage(i,l)},replaceImage(i,l,p,g,x,P){return r.replaceImage(i,l,p,g,x,P)},deleteImage(i,l){return r.deleteImage(i,l)},deleteImageTracked(i,l,p){return r.deleteImageTracked(i,l,p)},applyImageProperties(i,l){return r.applyImageProperties(i,l)},applyFragmentPaste(i,l){return r.applyFragmentPaste(i,l)}}}}var dr=b.projection;function Or(t,e,n){let o=t.filter(a=>a.localName!==e);return o.length!==t.length?o:[...o,n?{localName:e,attributes:n}:{localName:e}]}function Pr(t,e,n={}){let o=null,a=false,s=()=>n.onChange?.(r()),r=()=>({revision:e.revision(),canUndo:e.canUndo(),canRedo:e.canRedo(),lastRejection:o}),d=u=>{a=true;let y=f.state.tr.replaceWith(0,f.state.doc.content.size,u.content);y.setMeta("addToHistory",false),f.dispatch(y),a=false;},c=u=>()=>(u()&&(d(e.projectDoc()),s()),true),f=new EditorView(t,{state:EditorState.create({doc:e.projectDoc(),plugins:[keymap({...baseKeymap,Home:selectTextblockStart,End:selectTextblockEnd,"Mod-z":c(()=>e.undo()!==null),"Mod-y":c(()=>e.redo()!==null),"Shift-Mod-z":c(()=>e.redo()!==null),"Mod-b":(u,y)=>h(u,y,"b"),"Mod-i":(u,y)=>h(u,y,"i"),"Mod-u":(u,y)=>h(u,y,"u",{val:"single"})})]}),editable:()=>e.editable,handleDOMEvents:{keydown:u=>(m(u),false),beforeinput:(u,y)=>{let O=y;if(u.composing)return false;m(u);let R=O.inputType;if(R==="insertText"&&O.data!=null){O.preventDefault();let{from:b,to:S}=u.state.selection;return u.dispatch(u.state.tr.insertText(O.data,b,S)),true}if(R==="deleteContentBackward"){O.preventDefault();let{from:b,empty:S}=u.state.selection;return S?b>0?u.dispatch(u.state.tr.delete(b-1,b)):joinBackward(u.state,u.dispatch):deleteSelection(u.state,u.dispatch),true}if(R==="deleteContentForward"){O.preventDefault();let{from:b,to:S,empty:T}=u.state.selection;return T?S<u.state.doc.content.size?u.dispatch(u.state.tr.delete(b,b+1)):joinForward(u.state,u.dispatch):deleteSelection(u.state,u.dispatch),true}return R==="insertParagraph"?(O.preventDefault(),splitBlock(u.state,u.dispatch),true):false},compositionstart:()=>(e.beginComposition(),false),compositionend:()=>(e.endComposition(),s(),false)},dispatchTransaction(u){let y=f.state.apply(u);if(a||!u.docChanged){f.updateState(y);return}let O=e.applyPmDoc(y.doc);if(O.rejected){o=String(O.reason??"rejected"),f.updateState(y),d(e.projectDoc()),s();return}o=null,f.updateState(O.committed&&e.lastCommitWasStructural()?k(y):y),s();}});function m(u){if(u.composing||a)return;let y=u.dom.ownerDocument.getSelection(),O=y?.anchorNode,R=y?.focusNode;if(!(!y||!O||!R)&&!(!u.dom.contains(O)||!u.dom.contains(R)))try{let b=u.posAtDOM(O,y.anchorOffset),S=u.posAtDOM(R,y.focusOffset),T=u.state.selection;if(T.anchor===b&&T.head===S)return;let v=TextSelection.create(u.state.doc,b,S);u.dispatch(u.state.tr.setSelection(v).setMeta("addToHistory",!1));}catch{}}function k(u){let y=e.paragraphIds(),O=u.tr,R=false,b=0;return u.doc.forEach((S,T)=>{let v=y[b];b+=1,!(S.type.name!=="paragraph"||v===void 0)&&S.attrs.nodeId!==v&&(O=O.setNodeMarkup(T,void 0,{...S.attrs,nodeId:v}),R=true);}),R?u.apply(O.setMeta("addToHistory",false)):u}function h(u,y,O,R){let b=I.marks.runProps;if(!y)return true;let{from:S,to:T,empty:v}=u.selection;if(v)return true;let G=u.doc.resolve(S).marks().find(be=>be.type===b)?.attrs.props??[],B=Or(G,O,R),ne=u.tr;return ne.removeMark(S,T,b),B.length>0&&ne.addMark(S,T,b.create({props:B})),y(ne),true}return {view:f,state:r,undo:()=>c(()=>e.undo()!==null)(),redo:()=>c(()=>e.redo()!==null)(),toggleRunProperty(u,y){h(f.state,f.dispatch.bind(f),u,y);},destroy:()=>f.destroy()}}export{I as a,We as b,ee as c,F as d,J as e,Ye as f,wo as g,Ue as h,qe as i,lr as j,dr as k,Pr as l};
@@ -1 +1 @@
1
- 'use strict';var chunkEWV5JMJY_cjs=require('./chunk-EWV5JMJY.cjs'),chunkYRTRPSSA_cjs=require('./chunk-YRTRPSSA.cjs'),chunkGHNTGVKG_cjs=require('./chunk-GHNTGVKG.cjs');function je(e){let n=e&&"failures"in e?e.failures:void 0;return e==null||(e.sources?.length??0)===0&&(e.substitutions?.length??0)===0&&(n===void 0||Array.isArray(n)&&n.length===0)?void 0:e}var Be=64,Fe=Object.freeze({family:"Calibri",sizeHalfPoints:22});function he(e,...n){let o=[e,...n],i=[],t=new Set;for(let u of o)for(let d of u.sources??[]){let c=chunkEWV5JMJY_cjs.g(d.request);t.has(c)||(t.add(c),i.push(d));}let r=[],a=new Set;for(let u of o)for(let d of u.substitutions??[]){let c=chunkEWV5JMJY_cjs.g(d.from);t.has(c)||a.has(c)||(a.add(c),r.push(d));}return Object.freeze({epoch:e.epoch??0,maxFontBytes:e.maxFontBytes??chunkEWV5JMJY_cjs.a,sources:Object.freeze(i),...r.length>0?{substitutions:Object.freeze(r)}:{},defaultFont:e.defaultFont??Fe,...e.language!==void 0?{language:e.language}:{}})}var Re=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u;function be(e){let n=e?.defaultFont?.family;return n!==void 0&&Re.test(n)?n:Fe.family}var ke="docx-editor.dev/font-resolver",Oe=Symbol.for("docx-editor.dev/font-resolver");function Ve(e){let n={value:true,enumerable:false,configurable:true};try{Object.defineProperty(e,Oe,n),Object.defineProperty(e,ke,n);}catch(o){throw new TypeError("defineFontResolver cannot mark a frozen or sealed function; mark it before freezing, or wrap it in a fresh function and mark that.",{cause:o})}return e}function Ye(e){return typeof e=="function"&&e[Oe]===true}var U=e=>`${e.family.trim().toLowerCase()} ${e.weight} ${e.style}`;function ve(e,n,o){let i=new Map(e.map(t=>[U(t),t]));for(let[t,r]of n)i.set(t,r);for(let t of o)i.has(U(t.to))&&i.set(U(t.from),t.from);return [...i.values()]}async function He(e,n,o={}){return xe(e,n,o)}async function $e(e,n,o={}){return xe(e,n,o)}async function xe(e,n,o){let i=e.map(Ce),t,r=[],a=new Map,u=new Set,d=0,c=[],w=new Set,y=[],h=n.resolvedFaces??[],O=n.defaultFamily;for(let k=0;k<e.length;k+=1){Se(n.signal);let F=e[k],B=ve(h,a,c),v;try{let b=i[k],p;if(b){let s=await we(b,n.signal);if(!s.ok)throw s.cause;p=s.value;}else if(typeof F=="function"){let s=await we(Promise.resolve(F(Pe(n,O,B,d))).then(f=>({ok:!0,value:f}),f=>({ok:!1,cause:f})),n.signal);if(!s.ok)throw s.cause;p=s.value;}else p=F;if(p==null)continue;if(typeof p=="function"){X(o,F,k,new TypeError("A font origin answered with a function; pass the resolver itself rather than a function returning one"));continue}let S="failures"in p?p.failures:void 0,C=[];if(Array.isArray(S)){let s=Math.min(S.length,chunkEWV5JMJY_cjs.b);for(let f=0;f<s;f++)C.push(S[f]);S.length>s&&C.push(new Error("Additional font-origin failures were omitted"));}else S!==void 0&&C.push(S);let T=Te(p,u,d,w,t?"maxFontBytes"in t&&t.maxFontBytes!==void 0?t.maxFontBytes:chunkEWV5JMJY_cjs.a:void 0,o.reserveOwnedBytes,o.instrumentation);v=T;for(let s of new Set([...T.dropped,...C]))X(o,F,k,s);let E=T.fragment;y.push(...C);let j=(E.sources??[]).map(s=>(chunkEWV5JMJY_cjs.g(s.request),[U(s.request),s.request])),q=[...E.substitutions??[]];!t&&"defaultFont"in E&&(O=be(E)),t||(t=E);let l=new Set(T.sourceKeys);if(l.size>0){c=c.filter(s=>!l.has(chunkEWV5JMJY_cjs.g(s.from)));for(let s of l)w.delete(s);}r.push(...E.sources??[]);for(let s of T.sourceKeys)u.add(s);d+=T.ownedBytes;for(let[s,f]of j)a.set(s,f);for(let s of q)c.push(s),w.add(chunkEWV5JMJY_cjs.g(s.from));}catch(b){if(v?.releaseOwnedBytes?.(),n.signal?.aborted)throw n.signal.reason??b;if(b instanceof V)throw b.cause;X(o,F,k,b);continue}}if(!t)return;let{epoch:N,...x}=he({...t,sources:r,substitutions:c});return y.length===0?x:{...x,failures:Object.freeze(y)}}var V=class extends Error{constructor(o){super("Unable to reserve owned font bytes");this.cause=o;this.name="FontOwnershipReservationError";}cause},Y=class extends RangeError{};async function we(e,n){if(!n)return e;Se(n);let o,i=new Promise((r,a)=>{o=a;}),t=()=>o?.(n.reason);n.addEventListener("abort",t,{once:true});try{return await Promise.race([e,i])}finally{n.removeEventListener("abort",t);}}function Ce(e){if(e===null||typeof e!="object")return;let n;try{n=e.then;}catch(o){return Promise.resolve({ok:false,cause:o})}if(typeof n=="function")return Promise.resolve(e).then(o=>({ok:true,value:o}),o=>({ok:false,cause:o}))}function Te(e,n,o,i,t,r,a){let u=e.sources??[],d=e.substitutions??[],c="maxFontBytes"in e?e.maxFontBytes:void 0,w="defaultFont"in e?e.defaultFont:void 0,y="epoch"in e?e.epoch:void 0,h="language"in e?e.language:void 0;if(!Array.isArray(u)||!Array.isArray(d))throw new TypeError("Font origin sources and substitutions must be arrays");let O=u.length,N=d.length;if(O>chunkEWV5JMJY_cjs.b)throw new RangeError(`Font source count must not exceed ${chunkEWV5JMJY_cjs.b}`);if(N>chunkEWV5JMJY_cjs.b)throw new RangeError(`Font substitution count must not exceed ${chunkEWV5JMJY_cjs.b}`);let x=c??chunkEWV5JMJY_cjs.a;if(!Number.isSafeInteger(x)||x<=0||x>chunkEWV5JMJY_cjs.a)throw new RangeError(`Font byte ceiling must be a positive safe integer no greater than ${chunkEWV5JMJY_cjs.a}`);let k=t??x,F=0,B=[],v=new Set,b=[],p=[];for(let l=0;l<O;l+=1){let s=u[l];try{let f=W(s.request),L=s.availability,_=s.faceIndex,g=s.hash,P=s.id,M=chunkEWV5JMJY_cjs.g(f);if(L!==void 0&&L!=="available"&&L!=="forbidden")throw new TypeError("Font source availability must be available or forbidden");if(!Number.isSafeInteger(_)||_<0)throw new RangeError("Font face index must be a non-negative safe integer");if(typeof g!="string"||g.length===0)throw new TypeError("Font source hash must be a non-empty string");let z;if(L!=="forbidden"){if(typeof P!="string"||P.length===0)throw new TypeError("Font source id must be a non-empty string");z=s.bytes;let H=chunkEWV5JMJY_cjs.e(z);if(H>k)throw new RangeError("Font source exceeds the effective base byte ceiling");if(n.has(M)||v.has(M))continue;if(o+F+H>chunkEWV5JMJY_cjs.c)throw new RangeError(`Font sources exceed the aggregate byte ceiling of ${chunkEWV5JMJY_cjs.c}`);F+=H;}else z=new Uint8Array(0);if(n.has(M)||v.has(M))continue;if(n.size+v.size>=chunkEWV5JMJY_cjs.b)throw new Y(`Font source count must not exceed ${chunkEWV5JMJY_cjs.b}`);v.add(M),B.push(M),b.push(Object.freeze({request:f,id:P,bytes:z,hash:g,faceIndex:_,...L?{availability:L}:{}}));}catch(f){if(f instanceof Y)throw f;p.push(f);}}let S=new Set,C=[];for(let l=0;l<N;l+=1){let s=d[l];try{let f=W(s.from),L=W(s.to);chunkEWV5JMJY_cjs.g(f),chunkEWV5JMJY_cjs.g(L);let _=s.lineMetrics,g=_?Object.freeze({heightEm:_.heightEm,baselineEm:_.baselineEm}):void 0;if(g&&(!Number.isFinite(g.heightEm)||!Number.isFinite(g.baselineEm)||g.heightEm<=0||g.heightEm>4||g.baselineEm<0||g.baselineEm>g.heightEm))throw new RangeError("Font substitution line metrics must fit within a bounded em box");let P=chunkEWV5JMJY_cjs.g(f);if(n.has(P)||v.has(P)||i.has(P)||S.has(P))continue;S.add(P),C.push(Object.freeze({from:f,to:L,...g?{lineMetrics:g}:{}}));}catch(f){p.push(f);}}if((O>0||N>0)&&b.length===0&&C.length===0&&p.length>0)throw p[0];let T=i.size;for(let l of v)i.has(l)&&(T-=1);if(T+S.size>chunkEWV5JMJY_cjs.b)throw new RangeError(`Font substitution count must not exceed ${chunkEWV5JMJY_cjs.b}`);let E;if(w!==void 0){let l=w.family,s=w.sizeHalfPoints;if(chunkEWV5JMJY_cjs.g({family:l,weight:400,style:"normal"}),!Number.isSafeInteger(s)||s<=0)throw new RangeError("Default font size must be a positive safe integer in half-points");E=Object.freeze({family:l,sizeHalfPoints:s});}if(y!==void 0&&(!Number.isSafeInteger(y)||y<0))throw new RangeError("Font configuration epoch must be a non-negative safe integer");if(h!==void 0&&typeof h!="string")throw new TypeError("Font shaping language must be a string");let j;if(F>0&&r)try{j=r(F);}catch(l){throw new V(l)}let q;try{q=b.map(l=>chunkEWV5JMJY_cjs.f(l,a));}catch(l){throw j?.(),l}return {fragment:Object.freeze({sources:Object.freeze(q),substitutions:Object.freeze(C),...y!==void 0?{epoch:y}:{},...c!==void 0?{maxFontBytes:c}:{},...E?{defaultFont:E}:{},...h!==void 0?{language:h}:{}}),sourceKeys:Object.freeze(B),ownedBytes:F,dropped:Object.freeze(p),releaseOwnedBytes:j}}function Le(e){return !Number.isSafeInteger(e)||e<=0?0:e>chunkEWV5JMJY_cjs.c?chunkEWV5JMJY_cjs.c:e}function Pe(e,n,o,i){let{committedSourceBytes:t,...r}=e,a=Le(i);return {...r,defaultFamily:n,...o.length>0?{resolvedFaces:o}:{},...a>0?{committedSourceBytes:a}:{}}}function W(e){return Object.freeze({family:e.family,weight:e.weight,style:e.style})}function Se(e){if(e?.aborted)throw e.reason??new DOMException("Font resolution was aborted","AbortError")}function X(e,n,o,i){let t;try{typeof n=="function"&&n.name.length>0&&(t=n.name);}catch{}let r=Object.freeze({originIndex:o,...t!==void 0?{originName:t}:{},cause:i});if(e.onOriginFailure)try{let u=e.onOriginFailure(r);Promise.resolve(u).catch(d=>{console.warn("[fonts] font-origin diagnostic callback failed",d);});return}catch(u){console.warn("[fonts] font-origin diagnostic callback failed",u);}let a="";try{i instanceof Error&&i.message.length>0&&(a=`: ${i.message}`);}catch{}console.warn(`[fonts] a font origin failed and was skipped${a}`,i);}function Ze(e){let n=e.defaultTabStopPt?.(),o=e.view.part().name,i={view:e.view,measurer:e.measurer,producer:e.producer,cache:e.cache,styleCascade:e.styleCascade,numberingIndex:e.numberingIndex,defaultTabStopPt:n,compatibilityMode:e.compatibilityMode?.(),inlineDrawingLayoutForPart:e.inlineDrawingLayoutForPart,drawingTokenForParagraphForPart:e.drawingTokenForParagraphForPart,drawingLayoutEpochForPart:e.drawingLayoutEpochForPart,linkProjectors:e.linkProjectors,projectFieldLink:e.projectFieldLink,displayMode:e.displayMode,revisionAuthorFilter:e.revisionAuthorFilter},t=chunkEWV5JMJY_cjs.$d(i),r={view:e.view,revision:e.revision,measurer:e.measurer,cache:e.cache,session:e.session,producer:e.producer,styleCascade:e.styleCascade,numberingIndex:e.numberingIndex,defaultTabStopPt:n,furniture:e.furniture,compatibilityMode:e.compatibilityMode,linkProjectors:e.linkProjectors,projectFieldLink:e.projectFieldLink,inlineDrawingLayout:e.inlineDrawingLayout,drawingTokenForParagraph:e.drawingTokenForParagraph,drawingLayoutEpoch:e.drawingLayoutEpoch,displayMode:e.displayMode,revisionAuthorFilter:e.revisionAuthorFilter},a={measurer:r.measurer,cache:r.cache,session:r.session,producer:r.producer,styleCascade:r.styleCascade?.(),defaultTabStopPt:r.defaultTabStopPt,compatibilityMode:r.compatibilityMode?.(),numberingIndex:r.numberingIndex?.(),sectionFurniture:r.furniture.sectionFurniture(),furniture:r.furniture.furniture(),projectLink:r.linkProjectors.projectLink,projectFieldLink:r.projectFieldLink,documentProperties:r.view.documentProperties(),inlineDrawingLayout:r.inlineDrawingLayout,drawingTokenForParagraph:r.drawingTokenForParagraph,drawingLayoutEpoch:r.drawingLayoutEpoch,projectionTokenForParagraph:u=>r.linkProjectors.tokenForParagraphForPart(o,u),projectionTokenForTable:u=>r.linkProjectors.tokenForTableForPart(o,u),projectionEpoch:r.linkProjectors.epochForPart(o),notes:t,displayMode:r.displayMode,revisionAuthorFilter:r.revisionAuthorFilter};return chunkEWV5JMJY_cjs.Ge(r.view.part(),r.revision,a)}function G(e,n){return e.attributes.find(o=>o.localName===n)?.value}function cn(e){let n=new Map,o=i=>{let t=chunkYRTRPSSA_cjs.a(i??void 0);t!==null&&!n.has(t.toLowerCase())&&n.set(t.toLowerCase(),t);};for(let i of e){let t=[i];for(;t.length;){let r=t.pop();if(r.namespaceUri===chunkGHNTGVKG_cjs.da&&(r.localName==="fldSimple"&&o(chunkEWV5JMJY_cjs.cd(G(r,"instr")??"")?.font),r.localName==="p"))for(let a of Ie(r))o(a);for(let a=r.children.length-1;a>=0;a--){let u=r.children[a];u.kind!=="textValue"&&t.push(u);}}}return [...n.values()]}function Ie(e){let n=[],o=chunkEWV5JMJY_cjs.Wa(),i=[];for(let t=e.children.length-1;t>=0;t-=1){let r=e.children[t];r.kind!=="textValue"&&i.push({node:r,containerDepth:0});}for(;i.length>0;){let{node:t,containerDepth:r}=i.pop();if(r>=chunkGHNTGVKG_cjs.la||t.namespaceUri===chunkGHNTGVKG_cjs.da&&t.localName==="p")continue;if(t.namespaceUri===chunkGHNTGVKG_cjs.da&&t.localName==="fldChar"){let u=G(t,"fldCharType");u==="begin"?chunkEWV5JMJY_cjs.Za(o):u==="separate"?(o.nesting===1&&Ee(o,n),chunkEWV5JMJY_cjs.$a(o)):u==="end"&&(o.nesting===1&&Ee(o,n),chunkEWV5JMJY_cjs.ab(o));continue}if(t.namespaceUri===chunkGHNTGVKG_cjs.da&&(t.localName==="instrText"||t.localName==="delInstrText")){chunkEWV5JMJY_cjs._a(o,Ne(t),t.localName==="delInstrText");continue}if(t.namespaceUri===chunkGHNTGVKG_cjs.da&&t.localName==="fldSimple"){let u=chunkEWV5JMJY_cjs.cd(G(t,"instr")??"");u?.font&&n.push(u.font);}let a=chunkGHNTGVKG_cjs.ma(t,r);for(let u=t.children.length-1;u>=0;u-=1){let d=t.children[u];d.kind!=="textValue"&&i.push({node:d,containerDepth:a});}}return chunkEWV5JMJY_cjs.Xa(o),n}function Ee(e,n){let o=chunkEWV5JMJY_cjs.Ya(e);if(o.overflow)return;let i=chunkEWV5JMJY_cjs.cd(o.instruction);i?.font&&n.push(i.font);}function Ne(e){let n="",o=[...e.children].reverse();for(;o.length>0&&n.length<=256;){let i=o.pop();if(i.kind==="textValue")n+=i.value;else for(let t=i.children.length-1;t>=0;t-=1)o.push(i.children[t]);}return n}function ln(e,n,o,i){if(!n)return [];let t=chunkEWV5JMJY_cjs.jd(n),r=chunkEWV5JMJY_cjs.Cc(o,i),a=new Map;for(let u of e)for(let d of Ae(u)){let c=chunkGHNTGVKG_cjs.Gd(d.children),w=y=>{if(y)for(let h of y.values())for(let O of [h.markerStyle.fontFamily,h.markerStyle.fontFamilyEastAsia]){let N=chunkYRTRPSSA_cjs.a(O??void 0);if(N===null)continue;let x=N.toLowerCase();a.has(x)||a.set(x,N);}};w(chunkEWV5JMJY_cjs.Mc(c,t,r));for(let y of c){let h=chunkEWV5JMJY_cjs.Yd(y);for(let O of h.contents)w(chunkEWV5JMJY_cjs.Xd(O,t,r));}}return [...a.values()].sort((u,d)=>u.localeCompare(d))}function Ae(e){if(e.localName==="document"){for(let n of e.children)if(n.kind!=="textValue"&&n.localName==="body")return [n];return []}if(e.localName==="footnotes"||e.localName==="endnotes"){let n=[];for(let o of e.children)o.kind!=="textValue"&&(o.localName==="footnote"||o.localName==="endnote")&&n.push(o);return n}return [e]}var _e={regular:{weight:400,style:"normal"},bold:{weight:700,style:"normal"},italic:{weight:400,style:"italic"},boldItalic:{weight:700,style:"italic"}};function yn(e,n){let o=[],i=[],t=0;for(let r of e){let a=r.bytes.byteLength;if(!Number.isSafeInteger(a)||a>n||a>chunkEWV5JMJY_cjs.a||a>chunkEWV5JMJY_cjs.c-t){i.push(r);continue}t+=a,o.push(r);}return {sources:o,dropped:i}}function pn(e,n,o){let i=n.reduce((r,a)=>r+a.bytes.byteLength,0),t=new Set(n.filter(r=>r.request.family.trim().length>0).map(r=>chunkEWV5JMJY_cjs.g(r.request)));return Me(e,{maxFontBytes:o,aggregateBudget:Math.max(0,chunkEWV5JMJY_cjs.c-i),shadowedRequests:t})}function Me(e,n){let o=[],i=[],t=n.aggregateBudget,r=new Set;for(let a of e){let u=_e[a.style],d=Object.freeze({family:a.family,weight:u.weight,style:u.style});if(a.family.trim().length===0){i.push({request:d,partName:a.partName,reason:"malformed"});continue}let c=chunkEWV5JMJY_cjs.g(d);if(!(n.shadowedRequests?.has(c)||r.has(c))){if(r.add(c),a.bytes.byteLength>n.maxFontBytes||a.bytes.byteLength>t){i.push({request:d,partName:a.partName,reason:"overLimit"});continue}t-=a.bytes.byteLength,o.push({request:d,id:`embedded:${a.partName}#${a.style}`,bytes:a.bytes,hash:chunkGHNTGVKG_cjs.a(a.bytes),faceIndex:0});}}return {sources:o,dropped:i}}exports.a=je;exports.b=Be;exports.c=Fe;exports.d=he;exports.e=be;exports.f=ke;exports.g=Oe;exports.h=Ve;exports.i=Ye;exports.j=He;exports.k=$e;exports.l=Ze;exports.m=yn;exports.n=pn;exports.o=Me;exports.p=cn;exports.q=Ie;exports.r=ln;
1
+ 'use strict';var chunkJROG4U3Z_cjs=require('./chunk-JROG4U3Z.cjs'),chunkPRNYSOQL_cjs=require('./chunk-PRNYSOQL.cjs'),chunkZFBNCHRP_cjs=require('./chunk-ZFBNCHRP.cjs');function je(e){let n=e&&"failures"in e?e.failures:void 0;return e==null||(e.sources?.length??0)===0&&(e.substitutions?.length??0)===0&&(n===void 0||Array.isArray(n)&&n.length===0)?void 0:e}var Be=64,Fe=Object.freeze({family:"Calibri",sizeHalfPoints:22});function he(e,...n){let o=[e,...n],i=[],t=new Set;for(let u of o)for(let d of u.sources??[]){let c=chunkJROG4U3Z_cjs.g(d.request);t.has(c)||(t.add(c),i.push(d));}let r=[],a=new Set;for(let u of o)for(let d of u.substitutions??[]){let c=chunkJROG4U3Z_cjs.g(d.from);t.has(c)||a.has(c)||(a.add(c),r.push(d));}return Object.freeze({epoch:e.epoch??0,maxFontBytes:e.maxFontBytes??chunkJROG4U3Z_cjs.a,sources:Object.freeze(i),...r.length>0?{substitutions:Object.freeze(r)}:{},defaultFont:e.defaultFont??Fe,...e.language!==void 0?{language:e.language}:{}})}var Re=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u;function be(e){let n=e?.defaultFont?.family;return n!==void 0&&Re.test(n)?n:Fe.family}var ke="docx-editor.dev/font-resolver",Oe=Symbol.for("docx-editor.dev/font-resolver");function Ve(e){let n={value:true,enumerable:false,configurable:true};try{Object.defineProperty(e,Oe,n),Object.defineProperty(e,ke,n);}catch(o){throw new TypeError("defineFontResolver cannot mark a frozen or sealed function; mark it before freezing, or wrap it in a fresh function and mark that.",{cause:o})}return e}function Ye(e){return typeof e=="function"&&e[Oe]===true}var U=e=>`${e.family.trim().toLowerCase()} ${e.weight} ${e.style}`;function ve(e,n,o){let i=new Map(e.map(t=>[U(t),t]));for(let[t,r]of n)i.set(t,r);for(let t of o)i.has(U(t.to))&&i.set(U(t.from),t.from);return [...i.values()]}async function He(e,n,o={}){return xe(e,n,o)}async function $e(e,n,o={}){return xe(e,n,o)}async function xe(e,n,o){let i=e.map(Ce),t,r=[],a=new Map,u=new Set,d=0,c=[],w=new Set,y=[],h=n.resolvedFaces??[],O=n.defaultFamily;for(let k=0;k<e.length;k+=1){Se(n.signal);let F=e[k],B=ve(h,a,c),v;try{let b=i[k],p;if(b){let s=await we(b,n.signal);if(!s.ok)throw s.cause;p=s.value;}else if(typeof F=="function"){let s=await we(Promise.resolve(F(Pe(n,O,B,d))).then(f=>({ok:!0,value:f}),f=>({ok:!1,cause:f})),n.signal);if(!s.ok)throw s.cause;p=s.value;}else p=F;if(p==null)continue;if(typeof p=="function"){X(o,F,k,new TypeError("A font origin answered with a function; pass the resolver itself rather than a function returning one"));continue}let S="failures"in p?p.failures:void 0,C=[];if(Array.isArray(S)){let s=Math.min(S.length,chunkJROG4U3Z_cjs.b);for(let f=0;f<s;f++)C.push(S[f]);S.length>s&&C.push(new Error("Additional font-origin failures were omitted"));}else S!==void 0&&C.push(S);let T=Te(p,u,d,w,t?"maxFontBytes"in t&&t.maxFontBytes!==void 0?t.maxFontBytes:chunkJROG4U3Z_cjs.a:void 0,o.reserveOwnedBytes,o.instrumentation);v=T;for(let s of new Set([...T.dropped,...C]))X(o,F,k,s);let E=T.fragment;y.push(...C);let j=(E.sources??[]).map(s=>(chunkJROG4U3Z_cjs.g(s.request),[U(s.request),s.request])),q=[...E.substitutions??[]];!t&&"defaultFont"in E&&(O=be(E)),t||(t=E);let l=new Set(T.sourceKeys);if(l.size>0){c=c.filter(s=>!l.has(chunkJROG4U3Z_cjs.g(s.from)));for(let s of l)w.delete(s);}r.push(...E.sources??[]);for(let s of T.sourceKeys)u.add(s);d+=T.ownedBytes;for(let[s,f]of j)a.set(s,f);for(let s of q)c.push(s),w.add(chunkJROG4U3Z_cjs.g(s.from));}catch(b){if(v?.releaseOwnedBytes?.(),n.signal?.aborted)throw n.signal.reason??b;if(b instanceof V)throw b.cause;X(o,F,k,b);continue}}if(!t)return;let{epoch:N,...x}=he({...t,sources:r,substitutions:c});return y.length===0?x:{...x,failures:Object.freeze(y)}}var V=class extends Error{constructor(o){super("Unable to reserve owned font bytes");this.cause=o;this.name="FontOwnershipReservationError";}cause},Y=class extends RangeError{};async function we(e,n){if(!n)return e;Se(n);let o,i=new Promise((r,a)=>{o=a;}),t=()=>o?.(n.reason);n.addEventListener("abort",t,{once:true});try{return await Promise.race([e,i])}finally{n.removeEventListener("abort",t);}}function Ce(e){if(e===null||typeof e!="object")return;let n;try{n=e.then;}catch(o){return Promise.resolve({ok:false,cause:o})}if(typeof n=="function")return Promise.resolve(e).then(o=>({ok:true,value:o}),o=>({ok:false,cause:o}))}function Te(e,n,o,i,t,r,a){let u=e.sources??[],d=e.substitutions??[],c="maxFontBytes"in e?e.maxFontBytes:void 0,w="defaultFont"in e?e.defaultFont:void 0,y="epoch"in e?e.epoch:void 0,h="language"in e?e.language:void 0;if(!Array.isArray(u)||!Array.isArray(d))throw new TypeError("Font origin sources and substitutions must be arrays");let O=u.length,N=d.length;if(O>chunkJROG4U3Z_cjs.b)throw new RangeError(`Font source count must not exceed ${chunkJROG4U3Z_cjs.b}`);if(N>chunkJROG4U3Z_cjs.b)throw new RangeError(`Font substitution count must not exceed ${chunkJROG4U3Z_cjs.b}`);let x=c??chunkJROG4U3Z_cjs.a;if(!Number.isSafeInteger(x)||x<=0||x>chunkJROG4U3Z_cjs.a)throw new RangeError(`Font byte ceiling must be a positive safe integer no greater than ${chunkJROG4U3Z_cjs.a}`);let k=t??x,F=0,B=[],v=new Set,b=[],p=[];for(let l=0;l<O;l+=1){let s=u[l];try{let f=W(s.request),L=s.availability,_=s.faceIndex,g=s.hash,P=s.id,M=chunkJROG4U3Z_cjs.g(f);if(L!==void 0&&L!=="available"&&L!=="forbidden")throw new TypeError("Font source availability must be available or forbidden");if(!Number.isSafeInteger(_)||_<0)throw new RangeError("Font face index must be a non-negative safe integer");if(typeof g!="string"||g.length===0)throw new TypeError("Font source hash must be a non-empty string");let z;if(L!=="forbidden"){if(typeof P!="string"||P.length===0)throw new TypeError("Font source id must be a non-empty string");z=s.bytes;let H=chunkJROG4U3Z_cjs.e(z);if(H>k)throw new RangeError("Font source exceeds the effective base byte ceiling");if(n.has(M)||v.has(M))continue;if(o+F+H>chunkJROG4U3Z_cjs.c)throw new RangeError(`Font sources exceed the aggregate byte ceiling of ${chunkJROG4U3Z_cjs.c}`);F+=H;}else z=new Uint8Array(0);if(n.has(M)||v.has(M))continue;if(n.size+v.size>=chunkJROG4U3Z_cjs.b)throw new Y(`Font source count must not exceed ${chunkJROG4U3Z_cjs.b}`);v.add(M),B.push(M),b.push(Object.freeze({request:f,id:P,bytes:z,hash:g,faceIndex:_,...L?{availability:L}:{}}));}catch(f){if(f instanceof Y)throw f;p.push(f);}}let S=new Set,C=[];for(let l=0;l<N;l+=1){let s=d[l];try{let f=W(s.from),L=W(s.to);chunkJROG4U3Z_cjs.g(f),chunkJROG4U3Z_cjs.g(L);let _=s.lineMetrics,g=_?Object.freeze({heightEm:_.heightEm,baselineEm:_.baselineEm}):void 0;if(g&&(!Number.isFinite(g.heightEm)||!Number.isFinite(g.baselineEm)||g.heightEm<=0||g.heightEm>4||g.baselineEm<0||g.baselineEm>g.heightEm))throw new RangeError("Font substitution line metrics must fit within a bounded em box");let P=chunkJROG4U3Z_cjs.g(f);if(n.has(P)||v.has(P)||i.has(P)||S.has(P))continue;S.add(P),C.push(Object.freeze({from:f,to:L,...g?{lineMetrics:g}:{}}));}catch(f){p.push(f);}}if((O>0||N>0)&&b.length===0&&C.length===0&&p.length>0)throw p[0];let T=i.size;for(let l of v)i.has(l)&&(T-=1);if(T+S.size>chunkJROG4U3Z_cjs.b)throw new RangeError(`Font substitution count must not exceed ${chunkJROG4U3Z_cjs.b}`);let E;if(w!==void 0){let l=w.family,s=w.sizeHalfPoints;if(chunkJROG4U3Z_cjs.g({family:l,weight:400,style:"normal"}),!Number.isSafeInteger(s)||s<=0)throw new RangeError("Default font size must be a positive safe integer in half-points");E=Object.freeze({family:l,sizeHalfPoints:s});}if(y!==void 0&&(!Number.isSafeInteger(y)||y<0))throw new RangeError("Font configuration epoch must be a non-negative safe integer");if(h!==void 0&&typeof h!="string")throw new TypeError("Font shaping language must be a string");let j;if(F>0&&r)try{j=r(F);}catch(l){throw new V(l)}let q;try{q=b.map(l=>chunkJROG4U3Z_cjs.f(l,a));}catch(l){throw j?.(),l}return {fragment:Object.freeze({sources:Object.freeze(q),substitutions:Object.freeze(C),...y!==void 0?{epoch:y}:{},...c!==void 0?{maxFontBytes:c}:{},...E?{defaultFont:E}:{},...h!==void 0?{language:h}:{}}),sourceKeys:Object.freeze(B),ownedBytes:F,dropped:Object.freeze(p),releaseOwnedBytes:j}}function Le(e){return !Number.isSafeInteger(e)||e<=0?0:e>chunkJROG4U3Z_cjs.c?chunkJROG4U3Z_cjs.c:e}function Pe(e,n,o,i){let{committedSourceBytes:t,...r}=e,a=Le(i);return {...r,defaultFamily:n,...o.length>0?{resolvedFaces:o}:{},...a>0?{committedSourceBytes:a}:{}}}function W(e){return Object.freeze({family:e.family,weight:e.weight,style:e.style})}function Se(e){if(e?.aborted)throw e.reason??new DOMException("Font resolution was aborted","AbortError")}function X(e,n,o,i){let t;try{typeof n=="function"&&n.name.length>0&&(t=n.name);}catch{}let r=Object.freeze({originIndex:o,...t!==void 0?{originName:t}:{},cause:i});if(e.onOriginFailure)try{let u=e.onOriginFailure(r);Promise.resolve(u).catch(d=>{console.warn("[fonts] font-origin diagnostic callback failed",d);});return}catch(u){console.warn("[fonts] font-origin diagnostic callback failed",u);}let a="";try{i instanceof Error&&i.message.length>0&&(a=`: ${i.message}`);}catch{}console.warn(`[fonts] a font origin failed and was skipped${a}`,i);}function Ze(e){let n=e.defaultTabStopPt?.(),o=e.view.part().name,i={view:e.view,measurer:e.measurer,producer:e.producer,cache:e.cache,styleCascade:e.styleCascade,numberingIndex:e.numberingIndex,defaultTabStopPt:n,compatibilityMode:e.compatibilityMode?.(),inlineDrawingLayoutForPart:e.inlineDrawingLayoutForPart,drawingTokenForParagraphForPart:e.drawingTokenForParagraphForPart,drawingLayoutEpochForPart:e.drawingLayoutEpochForPart,linkProjectors:e.linkProjectors,projectFieldLink:e.projectFieldLink,displayMode:e.displayMode,revisionAuthorFilter:e.revisionAuthorFilter},t=chunkJROG4U3Z_cjs.$d(i),r={view:e.view,revision:e.revision,measurer:e.measurer,cache:e.cache,session:e.session,producer:e.producer,styleCascade:e.styleCascade,numberingIndex:e.numberingIndex,defaultTabStopPt:n,furniture:e.furniture,compatibilityMode:e.compatibilityMode,linkProjectors:e.linkProjectors,projectFieldLink:e.projectFieldLink,inlineDrawingLayout:e.inlineDrawingLayout,drawingTokenForParagraph:e.drawingTokenForParagraph,drawingLayoutEpoch:e.drawingLayoutEpoch,displayMode:e.displayMode,revisionAuthorFilter:e.revisionAuthorFilter},a={measurer:r.measurer,cache:r.cache,session:r.session,producer:r.producer,styleCascade:r.styleCascade?.(),defaultTabStopPt:r.defaultTabStopPt,compatibilityMode:r.compatibilityMode?.(),numberingIndex:r.numberingIndex?.(),sectionFurniture:r.furniture.sectionFurniture(),furniture:r.furniture.furniture(),projectLink:r.linkProjectors.projectLink,projectFieldLink:r.projectFieldLink,documentProperties:r.view.documentProperties(),inlineDrawingLayout:r.inlineDrawingLayout,drawingTokenForParagraph:r.drawingTokenForParagraph,drawingLayoutEpoch:r.drawingLayoutEpoch,projectionTokenForParagraph:u=>r.linkProjectors.tokenForParagraphForPart(o,u),projectionTokenForTable:u=>r.linkProjectors.tokenForTableForPart(o,u),projectionEpoch:r.linkProjectors.epochForPart(o),notes:t,displayMode:r.displayMode,revisionAuthorFilter:r.revisionAuthorFilter};return chunkJROG4U3Z_cjs.Ge(r.view.part(),r.revision,a)}function G(e,n){return e.attributes.find(o=>o.localName===n)?.value}function cn(e){let n=new Map,o=i=>{let t=chunkPRNYSOQL_cjs.a(i??void 0);t!==null&&!n.has(t.toLowerCase())&&n.set(t.toLowerCase(),t);};for(let i of e){let t=[i];for(;t.length;){let r=t.pop();if(r.namespaceUri===chunkZFBNCHRP_cjs.da&&(r.localName==="fldSimple"&&o(chunkJROG4U3Z_cjs.cd(G(r,"instr")??"")?.font),r.localName==="p"))for(let a of Ie(r))o(a);for(let a=r.children.length-1;a>=0;a--){let u=r.children[a];u.kind!=="textValue"&&t.push(u);}}}return [...n.values()]}function Ie(e){let n=[],o=chunkJROG4U3Z_cjs.Wa(),i=[];for(let t=e.children.length-1;t>=0;t-=1){let r=e.children[t];r.kind!=="textValue"&&i.push({node:r,containerDepth:0});}for(;i.length>0;){let{node:t,containerDepth:r}=i.pop();if(r>=chunkZFBNCHRP_cjs.la||t.namespaceUri===chunkZFBNCHRP_cjs.da&&t.localName==="p")continue;if(t.namespaceUri===chunkZFBNCHRP_cjs.da&&t.localName==="fldChar"){let u=G(t,"fldCharType");u==="begin"?chunkJROG4U3Z_cjs.Za(o):u==="separate"?(o.nesting===1&&Ee(o,n),chunkJROG4U3Z_cjs.$a(o)):u==="end"&&(o.nesting===1&&Ee(o,n),chunkJROG4U3Z_cjs.ab(o));continue}if(t.namespaceUri===chunkZFBNCHRP_cjs.da&&(t.localName==="instrText"||t.localName==="delInstrText")){chunkJROG4U3Z_cjs._a(o,Ne(t),t.localName==="delInstrText");continue}if(t.namespaceUri===chunkZFBNCHRP_cjs.da&&t.localName==="fldSimple"){let u=chunkJROG4U3Z_cjs.cd(G(t,"instr")??"");u?.font&&n.push(u.font);}let a=chunkZFBNCHRP_cjs.ma(t,r);for(let u=t.children.length-1;u>=0;u-=1){let d=t.children[u];d.kind!=="textValue"&&i.push({node:d,containerDepth:a});}}return chunkJROG4U3Z_cjs.Xa(o),n}function Ee(e,n){let o=chunkJROG4U3Z_cjs.Ya(e);if(o.overflow)return;let i=chunkJROG4U3Z_cjs.cd(o.instruction);i?.font&&n.push(i.font);}function Ne(e){let n="",o=[...e.children].reverse();for(;o.length>0&&n.length<=256;){let i=o.pop();if(i.kind==="textValue")n+=i.value;else for(let t=i.children.length-1;t>=0;t-=1)o.push(i.children[t]);}return n}function ln(e,n,o,i){if(!n)return [];let t=chunkJROG4U3Z_cjs.jd(n),r=chunkJROG4U3Z_cjs.Cc(o,i),a=new Map;for(let u of e)for(let d of Ae(u)){let c=chunkZFBNCHRP_cjs.Gd(d.children),w=y=>{if(y)for(let h of y.values())for(let O of [h.markerStyle.fontFamily,h.markerStyle.fontFamilyEastAsia]){let N=chunkPRNYSOQL_cjs.a(O??void 0);if(N===null)continue;let x=N.toLowerCase();a.has(x)||a.set(x,N);}};w(chunkJROG4U3Z_cjs.Mc(c,t,r));for(let y of c){let h=chunkJROG4U3Z_cjs.Yd(y);for(let O of h.contents)w(chunkJROG4U3Z_cjs.Xd(O,t,r));}}return [...a.values()].sort((u,d)=>u.localeCompare(d))}function Ae(e){if(e.localName==="document"){for(let n of e.children)if(n.kind!=="textValue"&&n.localName==="body")return [n];return []}if(e.localName==="footnotes"||e.localName==="endnotes"){let n=[];for(let o of e.children)o.kind!=="textValue"&&(o.localName==="footnote"||o.localName==="endnote")&&n.push(o);return n}return [e]}var _e={regular:{weight:400,style:"normal"},bold:{weight:700,style:"normal"},italic:{weight:400,style:"italic"},boldItalic:{weight:700,style:"italic"}};function yn(e,n){let o=[],i=[],t=0;for(let r of e){let a=r.bytes.byteLength;if(!Number.isSafeInteger(a)||a>n||a>chunkJROG4U3Z_cjs.a||a>chunkJROG4U3Z_cjs.c-t){i.push(r);continue}t+=a,o.push(r);}return {sources:o,dropped:i}}function pn(e,n,o){let i=n.reduce((r,a)=>r+a.bytes.byteLength,0),t=new Set(n.filter(r=>r.request.family.trim().length>0).map(r=>chunkJROG4U3Z_cjs.g(r.request)));return Me(e,{maxFontBytes:o,aggregateBudget:Math.max(0,chunkJROG4U3Z_cjs.c-i),shadowedRequests:t})}function Me(e,n){let o=[],i=[],t=n.aggregateBudget,r=new Set;for(let a of e){let u=_e[a.style],d=Object.freeze({family:a.family,weight:u.weight,style:u.style});if(a.family.trim().length===0){i.push({request:d,partName:a.partName,reason:"malformed"});continue}let c=chunkJROG4U3Z_cjs.g(d);if(!(n.shadowedRequests?.has(c)||r.has(c))){if(r.add(c),a.bytes.byteLength>n.maxFontBytes||a.bytes.byteLength>t){i.push({request:d,partName:a.partName,reason:"overLimit"});continue}t-=a.bytes.byteLength,o.push({request:d,id:`embedded:${a.partName}#${a.style}`,bytes:a.bytes,hash:chunkZFBNCHRP_cjs.a(a.bytes),faceIndex:0});}}return {sources:o,dropped:i}}exports.a=je;exports.b=Be;exports.c=Fe;exports.d=he;exports.e=be;exports.f=ke;exports.g=Oe;exports.h=Ve;exports.i=Ye;exports.j=He;exports.k=$e;exports.l=Ze;exports.m=yn;exports.n=pn;exports.o=Me;exports.p=cn;exports.q=Ie;exports.r=ln;