@docx-editor.dev/core 2.5.0 → 2.6.1
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.
- package/THIRD_PARTY_NOTICES.md +39 -1
- package/dist/automation.cjs +1 -1
- package/dist/automation.d.cts +6 -6
- package/dist/automation.d.ts +6 -6
- package/dist/automation.js +1 -1
- package/dist/binding.cjs +1 -1
- package/dist/binding.d.cts +12 -12
- package/dist/binding.d.ts +12 -12
- package/dist/binding.js +1 -1
- package/dist/chunk-4GQXAXTZ.js +5 -0
- package/dist/chunk-DGUHCJPF.cjs +18 -0
- package/dist/{chunk-2GSRLGUI.cjs → chunk-DY3QVCWC.cjs} +6 -6
- package/dist/{chunk-45FL7KH4.js → chunk-E7BXJ4BF.js} +1 -1
- package/dist/chunk-F7Z6PWAZ.cjs +2 -0
- package/dist/chunk-JEMP5YI5.cjs +15 -0
- package/dist/{chunk-3FRSOOND.cjs → chunk-JZXK4DKV.cjs} +1 -1
- package/dist/chunk-NIGGABAA.js +15 -0
- package/dist/chunk-OPKOTVQQ.js +18 -0
- package/dist/{chunk-GOEBQ26R.js → chunk-PSZH2VXP.js} +1 -1
- package/dist/{chunk-LJIX4ZDF.js → chunk-R75OLPL6.js} +6 -6
- package/dist/{chunk-JDHTCMFA.cjs → chunk-SFMAIFEN.cjs} +1 -1
- package/dist/chunk-SKWYEZCO.cjs +5 -0
- package/dist/{chunk-YTZIGUXT.js → chunk-SMRD66T5.js} +1 -1
- package/dist/chunk-WAVN7MAT.js +2 -0
- package/dist/chunk-WU7PUTVA.js +2 -0
- package/dist/{chunk-OHJQ7GPZ.cjs → chunk-YMYCPY5Y.cjs} +1 -1
- package/dist/{content-control-walk-BeAFh6Xi.d.cts → content-control-walk-CbTqHq6O.d.cts} +1 -1
- package/dist/{content-control-walk-CQp8l6eS.d.ts → content-control-walk-D06GijR0.d.ts} +1 -1
- package/dist/contracts/editor.cjs +1 -1
- package/dist/contracts/editor.d.cts +10 -10
- package/dist/contracts/editor.d.ts +10 -10
- package/dist/contracts/editor.js +1 -1
- package/dist/contracts/interaction.d.cts +9 -9
- package/dist/contracts/interaction.d.ts +9 -9
- package/dist/contracts/modules.d.cts +5 -5
- package/dist/contracts/modules.d.ts +5 -5
- package/dist/contracts/types.d.cts +3 -1
- package/dist/contracts/types.d.ts +3 -1
- package/dist/{custom-node-writes-CIC_-wad.d.cts → custom-node-writes-D9G3GKQ7.d.cts} +7 -7
- package/dist/{custom-node-writes-2clI36T9.d.ts → custom-node-writes-tJw8U9MO.d.ts} +7 -7
- package/dist/dist-YFULGVS3.js +2 -0
- package/dist/{editor-CUul9IuY.d.cts → editor-BZEJL3vv.d.cts} +33 -19
- package/dist/{editor-DIwctMcU.d.ts → editor-D2zOJztO.d.ts} +33 -19
- package/dist/editor.cjs +1 -1
- package/dist/editor.css +375 -38
- package/dist/editor.d.cts +42 -26
- package/dist/editor.d.ts +42 -26
- package/dist/editor.js +1 -1
- package/dist/harfbuzz.wasm +0 -0
- package/dist/{hf-references-CAp1xTv6.d.ts → hf-references-BdjsQNE_.d.ts} +2 -2
- package/dist/{hf-references-BPET4tlK.d.cts → hf-references-CgEOSw3i.d.cts} +2 -2
- package/dist/{image-resources-CSlQmPIm.d.cts → image-resources-BaHz4QAd.d.cts} +10 -10
- package/dist/{image-resources-e13t-pgy.d.ts → image-resources-Cl5_cNi9.d.ts} +10 -10
- package/dist/{index-BUsYjxF5.d.ts → index-D8L8WrNF.d.ts} +111 -21
- package/dist/{index-8t44iXTY.d.cts → index-_xF7n_z0.d.cts} +111 -21
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +20 -20
- package/dist/index.d.ts +20 -20
- package/dist/index.js +1 -1
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.cts +71 -23
- package/dist/layout.d.ts +71 -23
- package/dist/layout.js +1 -1
- package/dist/node-module-shim-TTKTT66I.js +1 -0
- package/dist/{note-nodes-CZQXU6Fg.d.ts → note-nodes-BPSTVDMr.d.ts} +1 -1
- package/dist/{note-nodes-B2wWES2L.d.cts → note-nodes-C6DLxlvj.d.cts} +1 -1
- package/dist/{ooxml-package-Cmbe_M04.d.cts → ooxml-package-CR5us6ad.d.cts} +115 -115
- package/dist/{ooxml-package-BrxTmTsZ.d.ts → ooxml-package-D_CtywTW.d.ts} +115 -115
- package/dist/{ooxml-tree-CG0odFyi.d.cts → ooxml-tree-BU0e3DVi.d.cts} +1 -1
- package/dist/{ooxml-tree-CG0odFyi.d.ts → ooxml-tree-BU0e3DVi.d.ts} +1 -1
- package/dist/output.cjs +1 -1
- package/dist/output.d.cts +22 -8
- package/dist/output.d.ts +22 -8
- package/dist/output.js +1 -1
- package/dist/{protocol-B5oSt08P.d.cts → protocol-CD7slqvl.d.cts} +2 -2
- package/dist/{protocol-ooK7PAXz.d.ts → protocol-DsbfgBwA.d.ts} +2 -2
- package/dist/{note-properties-Dhqkro--.d.cts → review-reads-Dr0CpW6u.d.cts} +67 -67
- package/dist/{note-properties-BS66XmcC.d.ts → review-reads-HDvoQXK2.d.ts} +67 -67
- package/dist/{review-support-Bl9sN8cv.d.ts → review-support-D4ZBdUXa.d.ts} +2 -2
- package/dist/{review-support-CHuJxHmz.d.cts → review-support-T-riLz4Y.d.cts} +2 -2
- package/dist/{revision-projection-u4nT52xT.d.ts → revision-projection-UKqvPa4-.d.ts} +1 -1
- package/dist/{revision-projection-DRZMzoLD.d.cts → revision-projection-WzlQGBJx.d.cts} +1 -1
- package/dist/{semantic-cell-selection-Dc-_enhm.d.ts → semantic-cell-selection-B5vfPz4Q.d.ts} +4 -4
- package/dist/{semantic-cell-selection-CdNQ-a9-.d.cts → semantic-cell-selection-BTQFpN0S.d.cts} +4 -4
- package/dist/{semantic-interaction-DgaWs-5w.d.cts → semantic-interaction-CDNEU_Tx.d.cts} +1 -1
- package/dist/{semantic-interaction-CCVwyw2A.d.ts → semantic-interaction-lvpzZRpA.d.ts} +1 -1
- package/dist/{semantic-paint-6iIB4fhx.d.cts → semantic-paint-BBPL3u5w.d.ts} +111 -3
- package/dist/{semantic-paint-CKIbFkQ7.d.ts → semantic-paint-IjbL-4CT.d.cts} +111 -3
- package/dist/{semantic-records-B-qbrnp2.d.ts → semantic-records-CdQvpUj1.d.ts} +4 -4
- package/dist/{semantic-records-Dq8SlCY8.d.cts → semantic-records-DEOs3_tE.d.cts} +4 -4
- package/dist/{shaped-measurer-Dx4llNhK.d.cts → shaped-measurer-C2SJAjV0.d.cts} +1 -1
- package/dist/{shaped-measurer-BT4FqYe9.d.ts → shaped-measurer-l4o5ITJ0.d.ts} +1 -1
- package/dist/store.cjs +1 -1
- package/dist/store.d.cts +238 -238
- package/dist/store.d.ts +238 -238
- package/dist/store.js +1 -1
- package/dist/{tree-op-types-DOYNkKqD.d.cts → tree-op-types-CUCwPWjT.d.cts} +219 -219
- package/dist/{tree-op-types-CZw9QhWX.d.ts → tree-op-types-D0fTNBVW.d.ts} +219 -219
- package/dist/{tree-session-CF_EOhTW.d.ts → tree-session-CH1oA75f.d.ts} +61 -45
- package/dist/{tree-session-CtK3KgFU.d.cts → tree-session-b7bggR-S.d.cts} +61 -45
- package/dist/{tree-store-Jg-q7fyf.d.cts → tree-store-BqgeCa1Q.d.cts} +3 -3
- package/dist/{tree-store-9TaX-L0V.d.ts → tree-store-CIKASRHk.d.ts} +3 -3
- package/licenses/HarfBuzz-COPYING.txt +42 -0
- package/package.json +5 -3
- package/dist/chunk-2QIA75K3.js +0 -2
- package/dist/chunk-32NXPFYL.js +0 -5
- package/dist/chunk-3C533HSQ.cjs +0 -18
- package/dist/chunk-7GYF33B5.cjs +0 -2
- package/dist/chunk-H3DZP4LE.cjs +0 -5
- package/dist/chunk-L2GMLEHX.cjs +0 -14
- package/dist/chunk-QUZM6LWQ.js +0 -14
- package/dist/chunk-T252F4US.js +0 -18
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var chunk2GSRLGUI_cjs=require('./chunk-2GSRLGUI.cjs'),fflate=require('fflate');var Ft=["extension","capability","command","query","schema","dependencyKey","runtimePort","result","origin"],Lt=/^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+$/,Bt=/^@[a-z0-9.-]+\/[a-z0-9.-]+(?:#[a-z0-9]+(?:[/._-][a-z0-9]+)*)?$/;function ot(e){return Lt.test(e)||Bt.test(e)}function J(e,t){if(!ot(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 Ut=/^(\d+)\.(\d+)\.(\d+)$/;function S(e){let t=Ut.exec(e);if(!t)throw new Error(`invalid semantic version: ${JSON.stringify(e)}`);return {major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3])}}function q(e,t){return e.major!==t.major?e.major<t.major?-1:1:e.minor!==t.minor?e.minor<t.minor?-1:1:e.patch!==t.patch?e.patch<t.patch?-1:1:0}function Q(e,t){let n=S(e),r=t.trim();if(r==="*")return true;if(r.startsWith("^")){let o=S(r.slice(1));return q(n,o)<0?false:o.major>0?n.major===o.major:o.minor>0?n.major===0&&n.minor===o.minor:n.major===0&&n.minor===0}if(r.includes(" ")){let o=r.split(/\s+/);if(o.length!==2)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let s=true;for(let a of o){let i=a.startsWith(">=")?">=":a.startsWith("<")?"<":null;if(!i)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let d=S(a.slice(i.length)),l=q(n,d);i===">="?s=s&&l>=0:s=s&&l<0;}return s}return q(n,S(r))===0}var h=class extends Error{constructor(n,r,o=[]){super(r);this.code=n;this.responsible=o;this.name="RegistryError";}code;responsible},$e=(e,t)=>`${e}:${t}`;function Ht(e,t={}){let n=new Map;for(let l of e){if(J(l.id,"extension"),it(l.version,l.id),n.has(l.id))throw new h("duplicate-extension",`duplicate extension id ${l.id}`,[l.id]);n.set(l.id,l);for(let c of l.contributions)J(c.id,c.kind),it(c.version,`${l.id} \u2192 ${c.id}`),c.replaces&&Xt(c.replaces.targetRange,`${l.id} \u2192 replaces ${c.replaces.targetId}`);}for(let l of e){for(let c of l.dependencies??[])if(!n.has(c))throw new h("missing-dependency",`${l.id} requires missing extension ${c}`,[l.id,c]);for(let c of l.conflicts??[])if(n.has(c)){let p=[l.id,c].sort();throw new h("conflict",`extensions ${p[0]} and ${p[1]} conflict`,p)}}jt(n);let r=new Set(t.availablePorts??[]);for(let l of e)for(let c of l.contributions)c.kind==="runtimePort"&&r.add(c.id);for(let l of e)for(let c of l.requiredPorts??[])if(!r.has(c))throw new h("missing-port",`${l.id} requires unavailable port ${c}`,[l.id,c]);let o=new Map,s=new Map,a=new Map;for(let l of e)for(let c of l.contributions){let p=$e(c.kind,c.id);if(c.replaces){let u=$e(c.kind,c.replaces.targetId),m=a.get(u)??[];m.push({ext:l.id,c}),a.set(u,m);continue}if(s.has(p)){let u=[o.get(p),l.id].sort();throw new h("id-collision",`${c.kind} id ${c.id} registered by both ${u[0]} and ${u[1]}`,u)}s.set(p,c),o.set(p,l.id);}let i=new Map(s);for(let[l,c]of a){let p=s.get(l);if(!p){let f=c[0];throw new h("replacement-target-missing",`${f.ext} replaces missing target ${f.c.replaces.targetId}`,[f.ext,f.c.replaces.targetId])}let u=p.replaceable??{kind:"none"};for(let{ext:f,c:y}of c){if(!Q(p.version,y.replaces.targetRange))throw new h("replacement-version-mismatch",`${f} replaces ${y.replaces.targetId}@${p.version} outside range ${y.replaces.targetRange}`,[f,y.replaces.targetId]);if(u.kind==="none")throw new h("unauthorized-replacement",`${y.replaces.targetId} does not authorize replacement (attempted by ${f})`,[f,y.replaces.targetId])}let m=Vt(p,c);i.set(l,m);}return {extensions:n,contributions:i,get:(l,c)=>i.get($e(l,c))}}function Vt(e,t){let n=e.replaceable??{kind:"none"};if(t.length===1)return t[0].c;if(n.kind==="priority"){let o=[...t].sort((i,d)=>(d.c.replaces.priority??0)-(i.c.replaces.priority??0)),s=o[0].c.replaces.priority??0,a=o.filter(i=>(i.c.replaces.priority??0)===s);if(a.length>1){let i=a.map(d=>d.ext).sort();throw new h("ambiguous-replacement",`multiple replacers of ${e.id} share top priority ${s}: ${i.join(", ")}`,i)}return o[0].c}let r=t.map(o=>o.ext).sort();throw new h("ambiguous-replacement",`multiple replacers of ${e.id}: ${r.join(", ")}`,r)}function jt(e){let o=new Map,s=[],a=i=>{o.set(i,1),s.push(i);let d=[...e.get(i)?.dependencies??[]].sort();for(let l of d){let c=o.get(l)??0;if(c===1){let p=s.indexOf(l),u=[...s.slice(p),l];throw new h("dependency-cycle",`dependency cycle: ${u.join(" -> ")}`,u)}c===0&&a(l);}s.pop(),o.set(i,2);};for(let i of [...e.keys()].sort())(o.get(i)??0)===0&&a(i);}function it(e,t){try{S(e);}catch{throw new h("invalid-version",`invalid version ${JSON.stringify(e)} in ${t}`,[t])}}function Xt(e,t){try{Q("0.0.0",e);}catch{throw new h("invalid-version",`invalid version range ${JSON.stringify(e)} in ${t}`,[t])}}var v=class extends Error{constructor(t){super(t),this.name="BudgetError";}},B=class e{constructor(t,n){this.label=t;this.capacity=n;this.used=new chunk2GSRLGUI_cjs.H(`${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 v(`${this.label}: cannot release with ${this.children.size} child budget(s) outstanding`);if(this.activeReservations>0)throw new v(`${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 v(`${this.label}: ${t.length} cleanup error(s); first: ${String(t[0])}`)}assertLive(){if(this.disposed)throw new v(`${this.label}: budget already released`)}};var Z=class extends Error{constructor(n,r){super(r?`cancelled: ${r}`:"cancelled");this.derivedOnly=n;this.name="CancellationError";}derivedOnly},U=class{_cancelled=false;_phase="pre-publication";_reason;cancel(t){this._cancelled=true,t!==void 0&&(this._reason=t);}markPublished(){this._phase="post-publication";}get isCancelled(){return this._cancelled}get phase(){return this._phase}get isPublished(){return this._phase==="post-publication"}get derivedOnly(){return this._cancelled&&this._phase==="post-publication"}get token(){let t=this;return {get isCancelled(){return t._cancelled},get phase(){return t._phase},get derivedOnly(){return t.derivedOnly},checkpoint(){if(t._cancelled)throw new Z(t.derivedOnly,t._reason)}}}};var ee=class extends Error{constructor(n){super(`runtime port not available: ${n}`);this.portId=n;this.name="PortResolutionError";}portId},De=class{ports=new Map;provide(t,n){return this.ports.set(t,n),this}has(t){return this.ports.has(t)}resolve(t){if(!this.ports.has(t))throw new ee(t);return this.ports.get(t)}missing(t){return t.filter(n=>!this.ports.has(n))}availablePorts(){return [...this.ports.keys()]}clock(){return this.resolve(chunk2GSRLGUI_cjs.x.clock)}identity(){return this.resolve(chunk2GSRLGUI_cjs.x.identity)}},Me=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}},Fe=class{constructor(t="id"){this.prefix=t;}prefix;n=0;newId(){return this.n+=1,`${this.prefix}-${this.n}`}};function Kt(e){let t=chunk2GSRLGUI_cjs.C(e.limits),n=Object.freeze({...e.config??{}}),r=e.capacity??t.maxDecompressedBytes,o=e.id??"op",s={id:o,limits:t,config:n,ports:e.ports,budget:new B(`op:${o}`,r),cancellation:new U};return Object.freeze(s)}function Gt(e){e.budget.dispose();}var Be=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"}}),at=Object.keys(Be);function zt(e,t){return new chunk2GSRLGUI_cjs.H(`${Be[t].phase}:${t}`,e[t])}var Le=class{counter;current=0;peak=0;constructor(t){this.counter=new chunk2GSRLGUI_cjs.H("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 Wt(){for(let e of at){let t=chunk2GSRLGUI_cjs.B[e],n=chunk2GSRLGUI_cjs.A[e];if(!Number.isFinite(t)||t<=0)throw new Error(`default ${e} must be finite > 0`);if(!Number.isFinite(n)||n<=0)throw new Error(`ceiling ${e} must be finite > 0`);if(t>n)throw new Error(`default ${e} exceeds ceiling`)}}function H(e,t=new Set){let n=new WeakSet,r=o=>{if(o===null)return "null";let s=typeof o;if(s==="boolean")return o?"true":"false";if(s==="number"){let a=o;if(!Number.isFinite(a))throw new Error(`non-finite number is not comparable: ${a}`);return Object.is(a,-0)?"0":String(a)}if(s==="string")return JSON.stringify(o);if(s==="bigint")return `${o.toString()}n`;if(Array.isArray(o))return `[${o.map(r).join(",")}]`;if(s==="object"){let a=o;if(n.has(a))throw new Error("cannot canonicalize a cyclic structure");n.add(a);let d=Object.keys(a).filter(l=>!t.has(l)).sort().map(l=>`${JSON.stringify(l)}:${r(a[l])}`).join(",");return n.delete(a),`{${d}}`}throw new Error(`unsupported value type in comparator input: ${s}`)};return r(e)}function Ue(e,t){let n=H(e,t),r=0xcbf29ce484222325n,o=0x100000001b3n,s=0xffffffffffffffffn;for(let a=0;a<n.length;a++)r^=BigInt(n.charCodeAt(a)),r=r*o&s;return r.toString(16).padStart(16,"0")}var R="dev.docx-editor.core.comparator",He={authoredState:{id:`${R}.authored-state`,mode:"canonical-exact",ephemera:["revision","provenance","producedAt","commitId"],note:"canonical normalized authored records; ephemera excluded"},anchor:{id:`${R}.anchor`,mode:"exact",ephemera:[],note:"internal anchor identity/affinity compares exactly"},yjsStateVector:{id:`${R}.yjs-state-vector`,mode:"sync-optimization-only",ephemera:[],note:"exchange optimization only; never proves update or delete-set coverage"},shapedRun:{id:`${R}.shaped-run`,mode:"exact",ephemera:[],note:"glyph ids, clusters, and fixed-point advances compare exactly"},paginationFingerprint:{id:`${R}.pagination-fingerprint`,mode:"exact",ephemera:[],note:"page/column boundaries, break causes, fixed-point geometry compare exactly"},semanticTree:{id:`${R}.semantic-tree`,mode:"exact",ephemera:[],note:"reading order, roles, headings, alt text compare exactly"},hitTest:{id:`${R}.hit-test`,mode:"exact",ephemera:[],note:"resolved hit target and cluster affinity compare exactly"},pdfSemantics:{id:`${R}.pdf-semantics`,mode:"canonical-exact",ephemera:["objectNumber","producer","creationDate","modDate","subsetTag"],note:"canonical semantic PDF objects; container ephemera excluded"},rasterCheckpoint:{id:`${R}.raster-checkpoint`,mode:"tolerance",ephemera:[],note:"documented unavoidable raster comparison; explicit tolerance only"},benchmarkEvidence:{id:`${R}.benchmark-evidence`,mode:"sync-optimization-only",ephemera:[],note:"diagnostic evidence, not an equivalence basis"}};function Ve(e,t,n,r={}){let o=He[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:st(t,n,r.epsilon)}}case "exact":case "canonical-exact":{let s=o.mode==="canonical-exact"?new Set(o.ephemera):new Set,a=H(t,s),i=H(n,s);return a===i?{equal:true}:{equal:false,left:a,right:i}}}}function je(e,t){let n=He[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 Ue(t,r)}function st(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)=>st(r,t[o],n)):false}var ct=new Set([...chunk2GSRLGUI_cjs.u,...chunk2GSRLGUI_cjs.v]),lt=/^[0-9a-f]{16}$/,Yt=/^[0-9a-f]*$/;function Xe(e){let t=[],n=o=>t.push(o);e.formatVersion!==1&&n(`unsupported formatVersion ${e.formatVersion}`),e.documentId||n("documentId is required"),e.source.kind==="docx"&&!/^[0-9a-f]{64}$/.test(e.source.sha256)&&n("docx source requires a 64-hex sha256");let r=-1;e.steps.forEach((o,s)=>{let a=`step[${s}]`;ct.has(o.origin)||n(`${a}: unknown origin ${o.origin}`),(!Number.isInteger(o.baseRevision)||o.baseRevision<0)&&n(`${a}: baseRevision must be a non-negative integer`),o.baseRevision<r&&n(`${a}: baseRevision regressed below ${r}`);let i=o.expect;i.outcome==="applied"?(i.committedRevision===void 0?n(`${a}: applied step needs committedRevision`):i.committedRevision<=o.baseRevision?n(`${a}: committedRevision ${i.committedRevision} must exceed baseRevision ${o.baseRevision}`):r=i.committedRevision,i.modelChange&&Jt(i.modelChange,a,n)):(i.committedRevision!==void 0&&n(`${a}: ${i.outcome} step must not commit a revision`),i.authoredStateHash!==void 0&&n(`${a}: ${i.outcome} step must not change authored state`)),i.authoredStateHash!==void 0&&!lt.test(i.authoredStateHash)&&n(`${a}: authoredStateHash must be 16-hex`),i.outputHash!==void 0&&!lt.test(i.outputHash)&&n(`${a}: outputHash must be 16-hex`);});for(let o of [...e.snapshots??[],...e.updates??[]])o.documentId!==e.documentId&&n(`envelope documentId ${o.documentId} != ${e.documentId}`),Yt.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 Jt(e,t,n){ct.has(e.origin)||n(`${t}: modelChange origin ${e.origin} unknown`),e.toRevision<=e.fromRevision&&n(`${t}: modelChange revision must advance`);}function qt(e,t){let n=Xe(e);if(!n.valid)return {ok:false,mismatches:n.errors};let r=[];return t.init(e),e.steps.forEach((o,s)=>{let a=`step[${s}]`,i=t.applyStep(o),d=o.expect;if(i.outcome!==d.outcome){r.push(`${a}: outcome ${i.outcome} != expected ${d.outcome}`);return}if(d.outcome==="applied"&&(i.committedRevision!==d.committedRevision&&r.push(`${a}: revision ${i.committedRevision} != expected ${d.committedRevision}`),d.authoredStateHash!==void 0))if(i.authoredState===void 0)r.push(`${a}: store returned no authored state to hash`);else {Ve("authoredState",i.authoredState,i.authoredState).equal||r.push(`${a}: authored state is not self-consistent`);let c=dt(i.authoredState);c!==d.authoredStateHash&&r.push(`${a}: authoredStateHash ${c} != expected ${d.authoredStateHash}`);}}),{ok:r.length===0,mismatches:r}}function dt(e){return je("authoredState",e)}var Qt=new Map([["embedRegular","regular"],["embedBold","bold"],["embedItalic","italic"],["embedBoldItalic","boldItalic"]]),Zt=32;function mt(e,t){let n=t.replace(/[^0-9a-fA-F]/g,"");if(n.length!==32)return null;let r=new Uint8Array(16);for(let a=0;a<16;a+=1){let i=Number.parseInt(n.slice(a*2,a*2+2),16);if(Number.isNaN(i))return null;r[15-a]=i;}let o=new Uint8Array(e),s=Math.min(Zt,o.length);for(let a=0;a<s;a+=1)o[a]=o[a]^r[a%16];return o}var Ke=(e,t)=>{if(!(e.kind==="textValue"||!("attributes"in e))){for(let n of e.attributes??[])if(n.localName===t)return n.value}},pt=e=>e.kind==="textValue"?[]:e.children??[],ut=e=>e.kind==="textValue"||!("localName"in e)?"":e.localName;function en(e,t,n){for(let r of e.relationships.get(t)??[]){if(r.id!==n)continue;if(r.targetMode==="External")return null;let o=chunk2GSRLGUI_cjs.r(t,r.rawTarget);return o.ok?o.partName:null}return null}function tn(e,t,n={}){if(!t)return [];let r=n.maxFontBytes??16*1024*1024,o=n.maxFonts??64,s=[],a=new Map,i=d=>{if(!(s.length>=o)){if(ut(d)==="font"){let l=Ke(d,"name");if(l&&l.length<=128)for(let c of pt(d)){if(s.length>=o)return;let p=Qt.get(ut(c));if(!p)continue;let u=Ke(c,"id"),m=Ke(c,"fontKey");if(!u||!m)continue;let f=en(e,t.name,u);if(!f)continue;let y=e.partBytes.get(f);if(!y||y.length===0||y.length>r)continue;let g=a.get(f);if(g){s.push({family:l,style:p,bytes:g,partName:f});continue}let O=mt(y,m);O&&(a.set(f,O),s.push({family:l,style:p,bytes:O,partName:f}));}}for(let l of pt(d))i(l);}};return i(t.root),s}function ft(e){if(e.kind!=="textValue")for(let t of e.children){if(t.kind==="textValue")continue;if(t.kind==="hyperlink"){let r=chunk2GSRLGUI_cjs.Sa(t);if(r!==void 0&&r.length>0)return r}let n=ft(t);if(n!==void 0)return n}}function nn(e){let t="",n=false,r=o=>{if(!(n||o.kind==="textValue")){if(o.kind==="tab"||o.localName==="ptab"||o.localName==="tab"){n=true;return}if(o.kind==="text"||o.localName==="t"){for(let s of o.children)s.kind==="textValue"&&(t+=s.value);return}for(let s of o.children)r(s);}};return r(e),chunk2GSRLGUI_cjs.Hc(t)}function rn(e,t,n,r){let o=n.filter(d=>{if(r.has(d.blockId))return false;let l=d.level+1;return l>=t.instruction.outlineStart&&l<=t.instruction.outlineEnd}),s=new Set(o.map(d=>d.blockId)),a=chunk2GSRLGUI_cjs.Cc(e),i=new Map;for(let d of o){let l=chunk2GSRLGUI_cjs.Hc(d.text),c=i.get(l);c?c.push(d.blockId):i.set(l,[d.blockId]);}return t.resultParagraphIds.map(d=>{let l=chunk2GSRLGUI_cjs.Fa(e,d);if(!l||l.kind==="textValue")return null;let c=ft(l),p=c===void 0?void 0:a.get(c);if(p&&s.has(p.paragraphId)){let f=i.get(chunk2GSRLGUI_cjs.Hc(o.find(g=>g.blockId===p.paragraphId)?.text??"")),y=f?.indexOf(p.paragraphId)??-1;return f&&y>=0&&f.splice(y,1),p.paragraphId}let u=nn(l);if(u.length===0)return null;let m=i.get(u);return !m||m.length===0?null:m.shift()??null})}function C(e){return e.namespaceUri===chunk2GSRLGUI_cjs.ma?e.localName:`{${e.namespaceUri}}${e.localName}`}function I(e){let t=[];for(let n of e.attributes)t.push(n.namespaceUri===""||n.namespaceUri===chunk2GSRLGUI_cjs.ma?`${n.localName}=${n.value}`:`{${n.namespaceUri}}${n.localName}=${n.value}`);return t.sort(),t}function gt(e,t){let n=I(e),r=n.length>0?`${C(e)}(${n.join(",")})`:C(e);if(t>=chunk2GSRLGUI_cjs.ca)return r;let o=[];for(let s of e.children){if(s.kind==="textValue"){s.value!==""&&o.push(`#${s.value}`);continue}o.push(gt(s,t+1));}return o.sort(),o.length>0?`${r}[${o.join(",")}]`:r}function yt(e){if(!e)return [];let t=[];for(let n of e.children)n.namespaceUri===chunk2GSRLGUI_cjs.ma&&t.push(gt(n,1));return t.sort(),t}function Ge(e){if(e.kind==="textValue")return e.value;if(e.kind==="tab")return " ";if(e.kind==="hardBreak")return chunk2GSRLGUI_cjs._b(e);if(e.kind==="drawing")return chunk2GSRLGUI_cjs.mc();if(e.kind==="runProperties"||e.kind==="paragraphProperties"||e.kind==="generic")return "";if(e.kind==="hyperlink"||chunk2GSRLGUI_cjs.Lb(e)){let n="",r=e.kind==="hyperlink"?e.children:chunk2GSRLGUI_cjs.Nb(e)??[];for(let o of r)n+=Ge(o);return n}let t="";for(let n of e.children)t+=Ge(n);return t}function x(e,t){let n=new Map(e);for(let r of t.namespaceBindings)n.set(r.prefix,r.namespaceUri);return n}function V(e,t){try{return chunk2GSRLGUI_cjs.wa(e,t)}catch(n){if(n instanceof chunk2GSRLGUI_cjs.qa&&n.reason==="undeclared-prefix")return `generic-refusal:undeclared-prefix:{${e.namespaceUri}}${e.localName}`;throw n}}function ze(e,t,n=chunk2GSRLGUI_cjs.va){if(e.kind==="textValue")return;if(e.kind==="runProperties"||e.kind==="paragraphProperties"){let o=x(n,e),s=[];for(let a of e.children)a.namespaceUri!==chunk2GSRLGUI_cjs.ma&&s.push(V(a,o));s.sort(),t.push(...s);return}if(e.kind==="generic"){t.push(V(e,n));return}if(chunk2GSRLGUI_cjs.Lb(e)){t.push(chunk2GSRLGUI_cjs.xa(e));return}if(e.kind==="bookmarkStart"||e.kind==="bookmarkEnd"){t.push(chunk2GSRLGUI_cjs.wa(e,n));return}if(e.kind==="drawing"){t.push(ht(e));return}if(chunk2GSRLGUI_cjs.la(e.kind))return;let r=x(n,e);for(let o of e.children)ze(o,t,r);}function on(e){return `hyperlink(${e.attributes.map(n=>`${n.namespaceUri}|${n.localName}=${n.value}`).sort().join(",")})`}function an(e){for(let t of e.children)if(t.kind==="pictureBlipFill")for(let n of t.children){if(n.kind!=="pictureBlip")continue;let r=n.attributes.find(s=>s.localName==="embed"&&s.namespaceUri===chunk2GSRLGUI_cjs.pa)?.value,o=n.attributes.find(s=>s.localName==="link"&&s.namespaceUri===chunk2GSRLGUI_cjs.pa)?.value;if(r!==void 0)return `embed=${r}`;if(o!==void 0)return `link=${o}`}}function te(e,t,n){if(e.kind==="textValue")return `#${e.value}`;if(t>=chunk2GSRLGUI_cjs.ca)return C(e);let r=x(n,e);if(e.kind==="generic")return V(e,r);let o=I(e),s=o.length>0?`${C(e)}(${o.join(",")})`:C(e),a=[];for(let i of e.children)i.kind!=="textValue"&&a.push(te(i,t+1,r));return a.sort(),a.length>0?`${s}[${a.join(",")}]`:s}function sn(e,t,n){let r=x(n,e),o=[];for(let s of e.children)if(s.kind!=="textValue"){if(s.kind==="pictureBlipFill"){let a=s.children,i=a.find(l=>l.kind==="pictureBlip"),d=a.filter(l=>l.kind!=="pictureBlip").map(l=>te(l,t+1,r));if(d.sort(),i&&i.kind==="pictureBlip"){let l=I(i),c=l.length>0?`pictureBlip(${l.join(",")})`:"pictureBlip";o.push(d.length>0?`${c}[${d.join(",")}]`:c);}else for(let l of a)o.push(te(l,t+1,r));continue}o.push(te(s,t+1,r));}return o.sort(),o}function We(e,t,n){if(e.kind==="textValue")return `#${e.value}`;if(t>=chunk2GSRLGUI_cjs.ca)return C(e);let r=x(n,e);if(e.kind==="drawingDocPr"){let i=I(e);return i.length>0?`docPr(${i.join(",")})`:"docPr"}if(e.kind==="picture"){let i=an(e),d=sn(e,t+1,r),l=i===void 0?"picture":`picture(${i})`;return d.length>0?`${l}[${d.join(",")}]`:l}let o=I(e),s=o.length>0?`${C(e)}(${o.join(",")})`:C(e),a=[];for(let i of e.children){if(i.kind==="picture"){a.push(We(i,t+1,r));continue}if(i.kind==="generic"){a.push(V(i,r));continue}i.kind!=="textValue"&&a.push(We(i,t+1,r));}return a.length>0?`${s}[${a.join(",")}]`:s}function ht(e){let t=x(chunk2GSRLGUI_cjs.va,e),n=e.children.find(i=>i.kind==="inlineDrawing"||i.kind==="anchoredDrawing");if(!n||n.kind==="textValue")return `drawing(${I(e).join(",")})`;let r=x(t,n),o=I(n),s=o.length>0?`${n.kind}(${o.join(",")})`:n.kind,a=[];for(let i of n.children){if(i.kind==="generic"){a.push(V(i,r));continue}i.kind!=="textValue"&&a.push(We(i,1,r));}return a.length>0?`drawing[${s};${a.join(";")}]`:`drawing[${s}]`}function ln(e,t,n){let r=e.children.find(c=>c.kind==="paragraphProperties"),o=[],s="",a=[],i=x(chunk2GSRLGUI_cjs.va,e),d=(c,p)=>{if(c.kind==="run"){let u=x(p,c),m=c.children.find(f=>f.kind==="runProperties");o.push(yt(m)),s+=Ge(c);for(let f of c.children)ze(f,a,u);return}if(c.kind==="drawing"){a.push(ht(c));return}if(c.kind==="hyperlink"){a.push(on(c));let u=x(p,c);for(let m of c.children)d(m,u);return}if(c.kind==="contentControl"){a.push(chunk2GSRLGUI_cjs.xa({...c,children:c.children.filter(m=>m.kind!=="contentControlContent")}));let u=x(p,c);for(let m of c.children){if(m.kind!=="contentControlContent")continue;let f=x(u,m);for(let y of m.children)d(y,f);}return}ze(c,a,p);};for(let c of e.children)d(c,i);let l=chunk2GSRLGUI_cjs.Oc(e);return {ordinal:t,path:n,paraId:l===null?null:l.toUpperCase(),text:s,paragraphProperties:yt(r),runProperties:o,genericStructure:a}}function cn(e){if(e.localName==="hdr"||e.localName==="ftr"||e.kind==="body")return e;for(let t of e.children)if(t.kind!=="textValue"&&(t.kind==="body"||t.localName==="hdr"||t.localName==="ftr"))return t;return e}function xt(e,t,n,r,o,s){if(s>chunk2GSRLGUI_cjs.ca)return;let a=0;for(let i of e.children){if(i.kind==="textValue"){i.value.trim()!==""&&o.push(`${t}/#text ${i.value}`);continue}let d=t===""?String(a):`${t}/${a}`;if(a+=1,i.kind==="paragraph"){n.push(i),r.push(d),o.push(`${d} p`);continue}let l=I(i);o.push(l.length>0?`${d} ${C(i)}(${l.join(",")})`:`${d} ${C(i)}`),xt(i,d,n,r,o,s+1);}}function Nt(e){let t=cn(e.root),n=[],r=[],o=[];xt(t,"",n,r,o,0);let s=n.map((a,i)=>ln(a,i,r[i]));return {partName:e.name,paragraphs:s,structure:o}}function dn(e){let t=[];for(let n of e){let r=Nt(n);r&&t.push(r);}return {stories:t}}function pn(e,t){let n=[],r=(s,a,i)=>{n.push({path:s,before:JSON.stringify(a)??"undefined",after:JSON.stringify(i)??"undefined"});};e.stories.length!==t.stories.length&&r("stories.length",e.stories.length,t.stories.length);let o=Math.min(e.stories.length,t.stories.length);for(let s=0;s<o;s+=1){let a=e.stories[s],i=t.stories[s],d=p=>`${a.partName}${p}`;a.paragraphs.length!==i.paragraphs.length&&r(d(".paragraphs.length"),a.paragraphs.length,i.paragraphs.length);let l=Math.min(a.paragraphs.length,i.paragraphs.length);for(let p=0;p<l;p+=1){let u=a.paragraphs[p],m=i.paragraphs[p];u.text!==m.text&&r(d(`.p[${p}].text`),u.text,m.text),u.path!==m.path&&r(d(`.p[${p}].path`),u.path,m.path),u.paraId!==m.paraId&&r(d(`.p[${p}].paraId`),u.paraId,m.paraId),JSON.stringify(u.paragraphProperties)!==JSON.stringify(m.paragraphProperties)&&r(d(`.p[${p}].paragraphProperties`),u.paragraphProperties,m.paragraphProperties),JSON.stringify(u.runProperties)!==JSON.stringify(m.runProperties)&&r(d(`.p[${p}].runProperties`),u.runProperties,m.runProperties),JSON.stringify(u.genericStructure)!==JSON.stringify(m.genericStructure)&&r(d(`.p[${p}].genericStructure`),u.genericStructure,m.genericStructure);}a.structure.length!==i.structure.length&&r(d(".structure.length"),a.structure.length,i.structure.length);let c=Math.min(a.structure.length,i.structure.length);for(let p=0;p<c;p+=1)a.structure[p]!==i.structure[p]&&r(d(`.structure[${p}]`),a.structure[p],i.structure[p]);}return n}var j="http://schemas.openxmlformats.org/wordprocessingml/2006/main",fn="http://schemas.openxmlformats.org/package/2006/relationships",Ot="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",_="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",yn="application/vnd.openxmlformats-package.relationships+xml",gn="http://schemas.openxmlformats.org/package/2006/content-types",Rt="/[Content_Types].xml",E="/word/numbering.xml",Ct=[{text:"\uF0B7",font:"Symbol"},{text:"o",font:"Courier New"},{text:"\uF0A7",font:"Wingdings"}],bt=["decimal","lowerLetter","lowerRoman"],Ye=9;function St(e,t){let n=720*(t+1),r='<w:start w:val="1"/>';if(e==="bullet"){let a=Ct[t%Ct.length];return `<w:lvl w:ilvl="${t}">${r}<w:numFmt w:val="bullet"/><w:lvlText w:val="${a.text}"/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="${n}" w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="${a.font}" w:hAnsi="${a.font}" w:hint="default"/></w:rPr></w:lvl>`}let o=bt[t%bt.length],s=o==="lowerRoman";return `<w:lvl w:ilvl="${t}">${r}<w:numFmt w:val="${o}"/><w:lvlText w:val="%${t+1}."/><w:lvlJc w:val="${s?"right":"left"}"/><w:pPr><w:ind w:left="${n}" w:hanging="${s?180:360}"/></w:pPr></w:lvl>`}function hn(e,t){let n=Array.from({length:Ye},(r,o)=>St(e,o)).join("");return `<w:abstractNum w:abstractNumId="${t}"><w:multiLevelType w:val="${e==="bullet"?"hybridMultilevel":"multilevel"}"/>${n}</w:abstractNum>`}function xn(){let e=chunk2GSRLGUI_cjs.Ba(`<w:numbering xmlns:w="${j}"></w:numbering>`,{name:E,contentType:_});return e.ok?e.part:null}var b=(e,t)=>{let n=[];for(let r of e.children)r.kind==="textValue"||r.localName!==t||r.namespaceUri===j&&n.push(r);return n},N=(e,t)=>e.attributes.find(n=>n.localName===t)?.value;function vt(e,t){let n=chunk2GSRLGUI_cjs.Ba(`<w:numbering xmlns:w="${j}">${e}</w:numbering>`,{name:E,contentType:_});if(!n.ok)return null;let r=[];for(let o of n.part.root.children)o.kind!=="textValue"&&r.push(o);if(r.length!==t.length)return null;for(let o=0;o<t.length;o+=1){let s=r[o],a=t[o];if(s.namespaceUri!==j||s.localName!==a.localName||a.attribute&&N(s,a.attribute.localName)!==a.attribute.value)return null}return r}var Et=["numPicBullet","abstractNum","num","numIdMacAtCleanup"];function Pt(e,t,n){let r=t.indexOf(n);if(r===-1)return e.length;let o=0;return e.forEach((s,a)=>{if(s.kind==="textValue")return;let i=t.indexOf(s.localName);i!==-1&&i<=r&&(o=a+1);}),o}function It(e,t){let n=0;for(let r of e){let o=N(r,t);!o||!/^\d{1,9}$/.test(o)||(n=Math.max(n,Number(o)));}return n+1}function Nn(e,t){let n=e.parts.get(E),r=n??xn();if(!r)return null;let o=r.root,s=b(o,"abstractNum"),a=b(o,"num"),i=t==="bullet"?"bullet":"decimal";for(let O of a){let $=N(O,"numId"),qe=b(O,"abstractNumId")[0],Qe=qe?N(qe,"val"):void 0;if(!$||!Qe)continue;let Ze=s.find(X=>N(X,"abstractNumId")===Qe);if(!Ze)continue;let et=b(Ze,"lvl").find(X=>N(X,"ilvl")==="0"||N(X,"ilvl")===void 0),tt=et?b(et,"numFmt")[0]:void 0;if(tt&&N(tt,"val")===i)return {pkg:e,numId:$}}let d=It(s,"abstractNumId"),l=It(a,"numId"),c=vt(hn(t,d)+`<w:num w:numId="${l}"><w:abstractNumId w:val="${d}"/></w:num>`,[{localName:"abstractNum",attribute:{localName:"abstractNumId",value:String(d)}},{localName:"num",attribute:{localName:"numId",value:String(l)}}]);if(!c)return null;let p=chunk2GSRLGUI_cjs.Da(r),[u,m]=c.map(O=>ne(O,p));if(!u||!m)return null;let f=chunk2GSRLGUI_cjs.Ia(r,o.id,Pt(o.children,Et,"abstractNum"),[u]);if(!f.ok)return null;let y=chunk2GSRLGUI_cjs.Ia(f.part,o.id,Pt(f.part.root.children,Et,"num"),[m]);if(!y.ok)return null;let g=Object.freeze({...e,parts:new Map([...e.parts,[E,y.part]])});if(!n){let O=bn(g);if(!O)return null;let $=kn(O);if(!$)return null;g=$;}return {pkg:g,numId:String(l)}}var On=["nsid","multiLevelType","tmpl","name","styleLink","numStyleLink","lvl"];function Tt(e){let t=N(e,"ilvl");return t===void 0||!/^\d{1,9}$/.test(t)?null:Number(t)}function Rn(e,t){let n=0;return e.forEach((r,o)=>{if(r.kind!=="textValue"){if(r.localName==="lvl"&&r.namespaceUri===j){(Tt(r)??0)<t&&(n=o+1);return}On.includes(r.localName)&&(n=o+1);}}),n}function Cn(e,t,n,r){if(!Number.isInteger(n)||n<0||n>=Ye||t.length===0||t.length>64)return null;let o=e.parts.get(E);if(!o)return null;let s=o.root,a=b(s,"num").find(f=>N(f,"numId")===t),i=a?b(a,"abstractNumId")[0]:void 0,d=i?N(i,"val"):void 0;if(!d)return null;let l=b(s,"abstractNum").find(f=>N(f,"abstractNumId")===d);if(!l||b(l,"numStyleLink").length>0)return null;let c=b(l,"lvl");if(c.some(f=>Tt(f)===n))return e;if(c.length>=Ye)return null;let p=vt(St(r,n),[{localName:"lvl",attribute:{localName:"ilvl",value:String(n)}}]);if(!p)return null;let u=chunk2GSRLGUI_cjs.Da(o),m=chunk2GSRLGUI_cjs.Ia(o,l.id,Rn(l.children,n),[ne(p[0],u)]);return m.ok?Object.freeze({...e,parts:new Map([...e.parts,[E,m.part]])}):null}function ne(e,t){return e.kind==="textValue"?{...e,id:t()}:{...e,id:t(),children:e.children.map(n=>ne(n,t))}}function bn(e){let t=e.mainDocumentPart,n=En(t),r=e.parts.get(n),o=Pn(e),s=chunk2GSRLGUI_cjs.Ba(`<Relationships xmlns="${fn}"><Relationship Id="${o}" Type="${Ot}" Target="numbering.xml"/></Relationships>`,{name:n,contentType:yn});if(!s.ok)return null;let a=e.relationships.get(t)??[],i={ownerPart:t,id:o,type:Ot,rawTarget:"numbering.xml",targetMode:"Internal",order:a.reduce((u,m)=>Math.max(u,m.order),-1)+1},d=new Map([...e.relationships,[t,[...a,i]]]);if(!r)return Object.freeze({...e,parts:new Map([...e.parts,[n,s.part]]),relationships:d});let l=chunk2GSRLGUI_cjs.Da(r),c=s.part.root.children[0];if(!c)return null;let p=chunk2GSRLGUI_cjs.Ia(r,r.root.id,r.root.children.length,[ne(c,l)]);return p.ok?Object.freeze({...e,parts:new Map([...e.parts,[n,p.part]]),relationships:d}):null}function En(e){let t=e.lastIndexOf("/");return `${e.slice(0,t)}/_rels/${e.slice(t+1)}.rels`}function Pn(e){let t=0;for(let n of e.relationships.values())for(let r of n){let o=/^rId(\d{1,9})$/.exec(r.id);o&&(t=Math.max(t,Number(o[1])));}for(let n of e.externalTargets){let r=/^rId(\d{1,9})$/.exec(n.id);r&&(t=Math.max(t,Number(r[1])));}return `rId${t+1}`}var In=`<Override PartName="${E}" ContentType="${_}"/>`;function kn(e){let t=e.contentTypes.overrides.get(chunk2GSRLGUI_cjs.p(E));if(t===_)return e;if(t!==void 0)return null;let n=e.partBytes.get(Rt);if(!n)return null;let r=fflate.strFromU8(n),o=kt(r);if(!o)return null;let s=r.lastIndexOf(`</${o.rootName}>`);if(s===-1)return null;let a=r.slice(0,s)+In+r.slice(s),i=kt(a);if(!i||i.rootName!==o.rootName)return null;let d=[...o.children,wt("Override",{PartName:E,ContentType:_})];return i.children.length!==d.length||i.children.some((l,c)=>l!==d[c])?null:Object.freeze({...e,partBytes:new Map([...e.partBytes,[Rt,fflate.strToU8(a)]]),contentTypes:Object.freeze({defaults:e.contentTypes.defaults,overrides:new Map([...e.contentTypes.overrides,[chunk2GSRLGUI_cjs.p(E),_]])})})}function kt(e){let t=chunk2GSRLGUI_cjs.da(e);if(!t.ok)return null;let n=t.nodes.filter(i=>i.type==="element");if(n.length!==1)return null;let r=n[0],o=r.name.indexOf(":"),s=o===-1?"":r.name.slice(0,o);if(r.name.slice(o+1)!=="Types"||r.attributes[s?`xmlns:${s}`:"xmlns"]!==gn)return null;let a=[];for(let i of r.children)i.type==="element"&&a.push(wt(i.name,i.attributes));return {rootName:r.name,children:a}}function wt(e,t){let n=Object.entries(t).map(([r,o])=>`${r}=${o}`).sort();return [e,...n].join("")}function re(e){return e!=null&&e.kind!=="textValue"}function Je(e,t){for(let n of e.children)if(n.kind!=="textValue"&&n.namespaceUri===chunk2GSRLGUI_cjs.ma&&n.localName===t)return n;return null}function oe(e,t){for(let n of e.attributes)if(n.namespaceUri===chunk2GSRLGUI_cjs.ma&&n.localName===t)return n.value}function A(e,t){let n=Je(e,t);if(!n)return false;let r=oe(n,"val");return r===void 0?true:r!=="0"&&r!=="false"&&r!=="off"}var _t=Object.freeze({trackRevisions:false,restrictedToTrackedChanges:false,doNotTrackMoves:false,doNotTrackFormatting:false});function Sn(e){if(!re(e))return _t;let t=Je(e,"documentProtection"),n=t===null?void 0:oe(t,"enforcement"),r=n!==void 0&&n!=="0"&&n!=="false"&&n!=="off";return {trackRevisions:A(e,"trackRevisions"),restrictedToTrackedChanges:r&&t!==null&&oe(t,"edit")==="trackedChanges",doNotTrackMoves:A(e,"doNotTrackMoves"),doNotTrackFormatting:A(e,"doNotTrackFormatting")}}var At=Object.freeze({doNotShadeFormData:false});function vn(e){return re(e)?{doNotShadeFormData:A(e,"doNotShadeFormData")}:At}function Tn(e,t){let n=e.parts.get(t.storyPartName);if(!n)return {ok:false,reason:`no story part named ${t.storyPartName}`};let r=[];for(let d of chunk2GSRLGUI_cjs.te(n.root)){let l=chunk2GSRLGUI_cjs.re(d.node).tag;if(l===void 0||l.length===0)continue;let c=t.decide(l);c!=="keep"&&r.push({nodeId:d.node.id,policy:c});}let o=n,s=0,a=0;for(let{nodeId:d,policy:l}of r){let c=chunk2GSRLGUI_cjs.Ga(o,d);if(!c)continue;if(l==="remove"){let g=chunk2GSRLGUI_cjs.Ka(o,d,{deferValidation:true});if(!g.ok)return {ok:false,reason:`a node could not be removed: ${$t(g)}`};o=g.part,a+=1;continue}let p=c.children.find(g=>g.id===d);if(!p)continue;let u=chunk2GSRLGUI_cjs.pe(p),m=u?u.children:[],f=c.children.flatMap(g=>g.id===d?m:[g]),y=chunk2GSRLGUI_cjs.Ha(o,c.id,f,{deferValidation:true});if(!y.ok)return {ok:false,reason:`a node could not be unwrapped: ${$t(y)}`};o=y.part,s+=1;}let i=o===n?e:chunk2GSRLGUI_cjs.Ab(e,o);if(!i.parts.has(t.storyPartName))return {ok:false,reason:"the story went missing during the export"};for(let d of t.namespaces)for(let l of _n(i,t.storyPartName,d)){let c=chunk2GSRLGUI_cjs.if(i,l.itemId),p=chunk2GSRLGUI_cjs.cf(i,l.partName,c);if(p.pkg===i&&p.removed.length===0&&!wn(i,l.partName,c))return {ok:false,reason:`the payloads in ${d} could not be removed`};if(i=p.pkg,c.size>0)continue;let u=An(i,l);if(!u.ok)return {ok:false,reason:`the payload store for ${d} could not be removed`};i=u.pkg;}return {ok:true,pkg:i,unwrapped:s,removed:a}}function wn(e,t,n){return chunk2GSRLGUI_cjs._e(e,t).every(r=>n.has(r.id))}function $t(e){return e.issues.map(t=>t.code).join(", ")||"the edit was refused"}function _n(e,t,n){return chunk2GSRLGUI_cjs.We(e,t).filter(r=>r.namespaceUri===n)}function An(e,t){let n=chunk2GSRLGUI_cjs.Gb(e,t.partName);if(!n.ok)return {pkg:e,ok:false};let r=chunk2GSRLGUI_cjs.Gb(n.pkg,t.propsPartName);return r.ok?{pkg:r.pkg,ok:true}:{pkg:e,ok:false}}var ie="http://purl.org/dc/elements/1.1/",Dt="http://schemas.openxmlformats.org/package/2006/metadata/core-properties",Mt="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties";var sp=Object.freeze({});function k(e,t,n){if(e.kind!=="textValue")for(let r of e.children){if(r.kind==="textValue"||r.namespaceUri!==t||r.localName!==n)continue;let o=r.children.find(a=>a.kind==="textValue");if(!o||o.kind!=="textValue")return;let s=o.value.trim();return s.length===0?void 0:s.length>4096?s.slice(0,4096):s}}function lp(e,t){let n={};if(e&&e.kind!=="textValue"){let r=k(e,ie,"title");r!==void 0&&(n.title=r);let o=k(e,ie,"creator");o!==void 0&&(n.creator=o);let s=k(e,ie,"subject");s!==void 0&&(n.subject=s);let a=k(e,ie,"description");a!==void 0&&(n.description=a);let i=k(e,Dt,"keywords");i!==void 0&&(n.keywords=i);let d=k(e,Dt,"lastModifiedBy");d!==void 0&&(n.lastModifiedBy=d);}if(t&&t.kind!=="textValue"){let r=k(t,Mt,"Company");r!==void 0&&(n.company=r);let o=k(t,Mt,"Manager");o!==void 0&&(n.manager=o);}return n}
|
|
1
|
+
'use strict';var chunkDY3QVCWC_cjs=require('./chunk-DY3QVCWC.cjs'),fflate=require('fflate');var Ft=["extension","capability","command","query","schema","dependencyKey","runtimePort","result","origin"],Lt=/^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+$/,Bt=/^@[a-z0-9.-]+\/[a-z0-9.-]+(?:#[a-z0-9]+(?:[/._-][a-z0-9]+)*)?$/;function ot(e){return Lt.test(e)||Bt.test(e)}function J(e,t){if(!ot(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 Ut=/^(\d+)\.(\d+)\.(\d+)$/;function S(e){let t=Ut.exec(e);if(!t)throw new Error(`invalid semantic version: ${JSON.stringify(e)}`);return {major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3])}}function q(e,t){return e.major!==t.major?e.major<t.major?-1:1:e.minor!==t.minor?e.minor<t.minor?-1:1:e.patch!==t.patch?e.patch<t.patch?-1:1:0}function Q(e,t){let n=S(e),r=t.trim();if(r==="*")return true;if(r.startsWith("^")){let o=S(r.slice(1));return q(n,o)<0?false:o.major>0?n.major===o.major:o.minor>0?n.major===0&&n.minor===o.minor:n.major===0&&n.minor===0}if(r.includes(" ")){let o=r.split(/\s+/);if(o.length!==2)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let s=true;for(let a of o){let i=a.startsWith(">=")?">=":a.startsWith("<")?"<":null;if(!i)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let d=S(a.slice(i.length)),l=q(n,d);i===">="?s=s&&l>=0:s=s&&l<0;}return s}return q(n,S(r))===0}var h=class extends Error{constructor(n,r,o=[]){super(r);this.code=n;this.responsible=o;this.name="RegistryError";}code;responsible},$e=(e,t)=>`${e}:${t}`;function Ht(e,t={}){let n=new Map;for(let l of e){if(J(l.id,"extension"),it(l.version,l.id),n.has(l.id))throw new h("duplicate-extension",`duplicate extension id ${l.id}`,[l.id]);n.set(l.id,l);for(let c of l.contributions)J(c.id,c.kind),it(c.version,`${l.id} \u2192 ${c.id}`),c.replaces&&Xt(c.replaces.targetRange,`${l.id} \u2192 replaces ${c.replaces.targetId}`);}for(let l of e){for(let c of l.dependencies??[])if(!n.has(c))throw new h("missing-dependency",`${l.id} requires missing extension ${c}`,[l.id,c]);for(let c of l.conflicts??[])if(n.has(c)){let p=[l.id,c].sort();throw new h("conflict",`extensions ${p[0]} and ${p[1]} conflict`,p)}}jt(n);let r=new Set(t.availablePorts??[]);for(let l of e)for(let c of l.contributions)c.kind==="runtimePort"&&r.add(c.id);for(let l of e)for(let c of l.requiredPorts??[])if(!r.has(c))throw new h("missing-port",`${l.id} requires unavailable port ${c}`,[l.id,c]);let o=new Map,s=new Map,a=new Map;for(let l of e)for(let c of l.contributions){let p=$e(c.kind,c.id);if(c.replaces){let u=$e(c.kind,c.replaces.targetId),m=a.get(u)??[];m.push({ext:l.id,c}),a.set(u,m);continue}if(s.has(p)){let u=[o.get(p),l.id].sort();throw new h("id-collision",`${c.kind} id ${c.id} registered by both ${u[0]} and ${u[1]}`,u)}s.set(p,c),o.set(p,l.id);}let i=new Map(s);for(let[l,c]of a){let p=s.get(l);if(!p){let f=c[0];throw new h("replacement-target-missing",`${f.ext} replaces missing target ${f.c.replaces.targetId}`,[f.ext,f.c.replaces.targetId])}let u=p.replaceable??{kind:"none"};for(let{ext:f,c:y}of c){if(!Q(p.version,y.replaces.targetRange))throw new h("replacement-version-mismatch",`${f} replaces ${y.replaces.targetId}@${p.version} outside range ${y.replaces.targetRange}`,[f,y.replaces.targetId]);if(u.kind==="none")throw new h("unauthorized-replacement",`${y.replaces.targetId} does not authorize replacement (attempted by ${f})`,[f,y.replaces.targetId])}let m=Vt(p,c);i.set(l,m);}return {extensions:n,contributions:i,get:(l,c)=>i.get($e(l,c))}}function Vt(e,t){let n=e.replaceable??{kind:"none"};if(t.length===1)return t[0].c;if(n.kind==="priority"){let o=[...t].sort((i,d)=>(d.c.replaces.priority??0)-(i.c.replaces.priority??0)),s=o[0].c.replaces.priority??0,a=o.filter(i=>(i.c.replaces.priority??0)===s);if(a.length>1){let i=a.map(d=>d.ext).sort();throw new h("ambiguous-replacement",`multiple replacers of ${e.id} share top priority ${s}: ${i.join(", ")}`,i)}return o[0].c}let r=t.map(o=>o.ext).sort();throw new h("ambiguous-replacement",`multiple replacers of ${e.id}: ${r.join(", ")}`,r)}function jt(e){let o=new Map,s=[],a=i=>{o.set(i,1),s.push(i);let d=[...e.get(i)?.dependencies??[]].sort();for(let l of d){let c=o.get(l)??0;if(c===1){let p=s.indexOf(l),u=[...s.slice(p),l];throw new h("dependency-cycle",`dependency cycle: ${u.join(" -> ")}`,u)}c===0&&a(l);}s.pop(),o.set(i,2);};for(let i of [...e.keys()].sort())(o.get(i)??0)===0&&a(i);}function it(e,t){try{S(e);}catch{throw new h("invalid-version",`invalid version ${JSON.stringify(e)} in ${t}`,[t])}}function Xt(e,t){try{Q("0.0.0",e);}catch{throw new h("invalid-version",`invalid version range ${JSON.stringify(e)} in ${t}`,[t])}}var v=class extends Error{constructor(t){super(t),this.name="BudgetError";}},B=class e{constructor(t,n){this.label=t;this.capacity=n;this.used=new chunkDY3QVCWC_cjs.H(`${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 v(`${this.label}: cannot release with ${this.children.size} child budget(s) outstanding`);if(this.activeReservations>0)throw new v(`${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 v(`${this.label}: ${t.length} cleanup error(s); first: ${String(t[0])}`)}assertLive(){if(this.disposed)throw new v(`${this.label}: budget already released`)}};var Z=class extends Error{constructor(n,r){super(r?`cancelled: ${r}`:"cancelled");this.derivedOnly=n;this.name="CancellationError";}derivedOnly},U=class{_cancelled=false;_phase="pre-publication";_reason;cancel(t){this._cancelled=true,t!==void 0&&(this._reason=t);}markPublished(){this._phase="post-publication";}get isCancelled(){return this._cancelled}get phase(){return this._phase}get isPublished(){return this._phase==="post-publication"}get derivedOnly(){return this._cancelled&&this._phase==="post-publication"}get token(){let t=this;return {get isCancelled(){return t._cancelled},get phase(){return t._phase},get derivedOnly(){return t.derivedOnly},checkpoint(){if(t._cancelled)throw new Z(t.derivedOnly,t._reason)}}}};var ee=class extends Error{constructor(n){super(`runtime port not available: ${n}`);this.portId=n;this.name="PortResolutionError";}portId},De=class{ports=new Map;provide(t,n){return this.ports.set(t,n),this}has(t){return this.ports.has(t)}resolve(t){if(!this.ports.has(t))throw new ee(t);return this.ports.get(t)}missing(t){return t.filter(n=>!this.ports.has(n))}availablePorts(){return [...this.ports.keys()]}clock(){return this.resolve(chunkDY3QVCWC_cjs.x.clock)}identity(){return this.resolve(chunkDY3QVCWC_cjs.x.identity)}},Me=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}},Fe=class{constructor(t="id"){this.prefix=t;}prefix;n=0;newId(){return this.n+=1,`${this.prefix}-${this.n}`}};function Kt(e){let t=chunkDY3QVCWC_cjs.C(e.limits),n=Object.freeze({...e.config??{}}),r=e.capacity??t.maxDecompressedBytes,o=e.id??"op",s={id:o,limits:t,config:n,ports:e.ports,budget:new B(`op:${o}`,r),cancellation:new U};return Object.freeze(s)}function Gt(e){e.budget.dispose();}var Be=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"}}),at=Object.keys(Be);function zt(e,t){return new chunkDY3QVCWC_cjs.H(`${Be[t].phase}:${t}`,e[t])}var Le=class{counter;current=0;peak=0;constructor(t){this.counter=new chunkDY3QVCWC_cjs.H("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 Wt(){for(let e of at){let t=chunkDY3QVCWC_cjs.B[e],n=chunkDY3QVCWC_cjs.A[e];if(!Number.isFinite(t)||t<=0)throw new Error(`default ${e} must be finite > 0`);if(!Number.isFinite(n)||n<=0)throw new Error(`ceiling ${e} must be finite > 0`);if(t>n)throw new Error(`default ${e} exceeds ceiling`)}}function H(e,t=new Set){let n=new WeakSet,r=o=>{if(o===null)return "null";let s=typeof o;if(s==="boolean")return o?"true":"false";if(s==="number"){let a=o;if(!Number.isFinite(a))throw new Error(`non-finite number is not comparable: ${a}`);return Object.is(a,-0)?"0":String(a)}if(s==="string")return JSON.stringify(o);if(s==="bigint")return `${o.toString()}n`;if(Array.isArray(o))return `[${o.map(r).join(",")}]`;if(s==="object"){let a=o;if(n.has(a))throw new Error("cannot canonicalize a cyclic structure");n.add(a);let d=Object.keys(a).filter(l=>!t.has(l)).sort().map(l=>`${JSON.stringify(l)}:${r(a[l])}`).join(",");return n.delete(a),`{${d}}`}throw new Error(`unsupported value type in comparator input: ${s}`)};return r(e)}function Ue(e,t){let n=H(e,t),r=0xcbf29ce484222325n,o=0x100000001b3n,s=0xffffffffffffffffn;for(let a=0;a<n.length;a++)r^=BigInt(n.charCodeAt(a)),r=r*o&s;return r.toString(16).padStart(16,"0")}var R="dev.docx-editor.core.comparator",He={authoredState:{id:`${R}.authored-state`,mode:"canonical-exact",ephemera:["revision","provenance","producedAt","commitId"],note:"canonical normalized authored records; ephemera excluded"},anchor:{id:`${R}.anchor`,mode:"exact",ephemera:[],note:"internal anchor identity/affinity compares exactly"},yjsStateVector:{id:`${R}.yjs-state-vector`,mode:"sync-optimization-only",ephemera:[],note:"exchange optimization only; never proves update or delete-set coverage"},shapedRun:{id:`${R}.shaped-run`,mode:"exact",ephemera:[],note:"glyph ids, clusters, and fixed-point advances compare exactly"},paginationFingerprint:{id:`${R}.pagination-fingerprint`,mode:"exact",ephemera:[],note:"page/column boundaries, break causes, fixed-point geometry compare exactly"},semanticTree:{id:`${R}.semantic-tree`,mode:"exact",ephemera:[],note:"reading order, roles, headings, alt text compare exactly"},hitTest:{id:`${R}.hit-test`,mode:"exact",ephemera:[],note:"resolved hit target and cluster affinity compare exactly"},pdfSemantics:{id:`${R}.pdf-semantics`,mode:"canonical-exact",ephemera:["objectNumber","producer","creationDate","modDate","subsetTag"],note:"canonical semantic PDF objects; container ephemera excluded"},rasterCheckpoint:{id:`${R}.raster-checkpoint`,mode:"tolerance",ephemera:[],note:"documented unavoidable raster comparison; explicit tolerance only"},benchmarkEvidence:{id:`${R}.benchmark-evidence`,mode:"sync-optimization-only",ephemera:[],note:"diagnostic evidence, not an equivalence basis"}};function Ve(e,t,n,r={}){let o=He[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:st(t,n,r.epsilon)}}case "exact":case "canonical-exact":{let s=o.mode==="canonical-exact"?new Set(o.ephemera):new Set,a=H(t,s),i=H(n,s);return a===i?{equal:true}:{equal:false,left:a,right:i}}}}function je(e,t){let n=He[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 Ue(t,r)}function st(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)=>st(r,t[o],n)):false}var ct=new Set([...chunkDY3QVCWC_cjs.u,...chunkDY3QVCWC_cjs.v]),lt=/^[0-9a-f]{16}$/,Yt=/^[0-9a-f]*$/;function Xe(e){let t=[],n=o=>t.push(o);e.formatVersion!==1&&n(`unsupported formatVersion ${e.formatVersion}`),e.documentId||n("documentId is required"),e.source.kind==="docx"&&!/^[0-9a-f]{64}$/.test(e.source.sha256)&&n("docx source requires a 64-hex sha256");let r=-1;e.steps.forEach((o,s)=>{let a=`step[${s}]`;ct.has(o.origin)||n(`${a}: unknown origin ${o.origin}`),(!Number.isInteger(o.baseRevision)||o.baseRevision<0)&&n(`${a}: baseRevision must be a non-negative integer`),o.baseRevision<r&&n(`${a}: baseRevision regressed below ${r}`);let i=o.expect;i.outcome==="applied"?(i.committedRevision===void 0?n(`${a}: applied step needs committedRevision`):i.committedRevision<=o.baseRevision?n(`${a}: committedRevision ${i.committedRevision} must exceed baseRevision ${o.baseRevision}`):r=i.committedRevision,i.modelChange&&Jt(i.modelChange,a,n)):(i.committedRevision!==void 0&&n(`${a}: ${i.outcome} step must not commit a revision`),i.authoredStateHash!==void 0&&n(`${a}: ${i.outcome} step must not change authored state`)),i.authoredStateHash!==void 0&&!lt.test(i.authoredStateHash)&&n(`${a}: authoredStateHash must be 16-hex`),i.outputHash!==void 0&&!lt.test(i.outputHash)&&n(`${a}: outputHash must be 16-hex`);});for(let o of [...e.snapshots??[],...e.updates??[]])o.documentId!==e.documentId&&n(`envelope documentId ${o.documentId} != ${e.documentId}`),Yt.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 Jt(e,t,n){ct.has(e.origin)||n(`${t}: modelChange origin ${e.origin} unknown`),e.toRevision<=e.fromRevision&&n(`${t}: modelChange revision must advance`);}function qt(e,t){let n=Xe(e);if(!n.valid)return {ok:false,mismatches:n.errors};let r=[];return t.init(e),e.steps.forEach((o,s)=>{let a=`step[${s}]`,i=t.applyStep(o),d=o.expect;if(i.outcome!==d.outcome){r.push(`${a}: outcome ${i.outcome} != expected ${d.outcome}`);return}if(d.outcome==="applied"&&(i.committedRevision!==d.committedRevision&&r.push(`${a}: revision ${i.committedRevision} != expected ${d.committedRevision}`),d.authoredStateHash!==void 0))if(i.authoredState===void 0)r.push(`${a}: store returned no authored state to hash`);else {Ve("authoredState",i.authoredState,i.authoredState).equal||r.push(`${a}: authored state is not self-consistent`);let c=dt(i.authoredState);c!==d.authoredStateHash&&r.push(`${a}: authoredStateHash ${c} != expected ${d.authoredStateHash}`);}}),{ok:r.length===0,mismatches:r}}function dt(e){return je("authoredState",e)}var Qt=new Map([["embedRegular","regular"],["embedBold","bold"],["embedItalic","italic"],["embedBoldItalic","boldItalic"]]),Zt=32;function mt(e,t){let n=t.replace(/[^0-9a-fA-F]/g,"");if(n.length!==32)return null;let r=new Uint8Array(16);for(let a=0;a<16;a+=1){let i=Number.parseInt(n.slice(a*2,a*2+2),16);if(Number.isNaN(i))return null;r[15-a]=i;}let o=new Uint8Array(e),s=Math.min(Zt,o.length);for(let a=0;a<s;a+=1)o[a]=o[a]^r[a%16];return o}var Ke=(e,t)=>{if(!(e.kind==="textValue"||!("attributes"in e))){for(let n of e.attributes??[])if(n.localName===t)return n.value}},pt=e=>e.kind==="textValue"?[]:e.children??[],ut=e=>e.kind==="textValue"||!("localName"in e)?"":e.localName;function en(e,t,n){for(let r of e.relationships.get(t)??[]){if(r.id!==n)continue;if(r.targetMode==="External")return null;let o=chunkDY3QVCWC_cjs.r(t,r.rawTarget);return o.ok?o.partName:null}return null}function tn(e,t,n={}){if(!t)return [];let r=n.maxFontBytes??16*1024*1024,o=n.maxFonts??64,s=[],a=new Map,i=d=>{if(!(s.length>=o)){if(ut(d)==="font"){let l=Ke(d,"name");if(l&&l.length<=128)for(let c of pt(d)){if(s.length>=o)return;let p=Qt.get(ut(c));if(!p)continue;let u=Ke(c,"id"),m=Ke(c,"fontKey");if(!u||!m)continue;let f=en(e,t.name,u);if(!f)continue;let y=e.partBytes.get(f);if(!y||y.length===0||y.length>r)continue;let g=a.get(f);if(g){s.push({family:l,style:p,bytes:g,partName:f});continue}let O=mt(y,m);O&&(a.set(f,O),s.push({family:l,style:p,bytes:O,partName:f}));}}for(let l of pt(d))i(l);}};return i(t.root),s}function ft(e){if(e.kind!=="textValue")for(let t of e.children){if(t.kind==="textValue")continue;if(t.kind==="hyperlink"){let r=chunkDY3QVCWC_cjs.Sa(t);if(r!==void 0&&r.length>0)return r}let n=ft(t);if(n!==void 0)return n}}function nn(e){let t="",n=false,r=o=>{if(!(n||o.kind==="textValue")){if(o.kind==="tab"||o.localName==="ptab"||o.localName==="tab"){n=true;return}if(o.kind==="text"||o.localName==="t"){for(let s of o.children)s.kind==="textValue"&&(t+=s.value);return}for(let s of o.children)r(s);}};return r(e),chunkDY3QVCWC_cjs.Hc(t)}function rn(e,t,n,r){let o=n.filter(d=>{if(r.has(d.blockId))return false;let l=d.level+1;return l>=t.instruction.outlineStart&&l<=t.instruction.outlineEnd}),s=new Set(o.map(d=>d.blockId)),a=chunkDY3QVCWC_cjs.Cc(e),i=new Map;for(let d of o){let l=chunkDY3QVCWC_cjs.Hc(d.text),c=i.get(l);c?c.push(d.blockId):i.set(l,[d.blockId]);}return t.resultParagraphIds.map(d=>{let l=chunkDY3QVCWC_cjs.Fa(e,d);if(!l||l.kind==="textValue")return null;let c=ft(l),p=c===void 0?void 0:a.get(c);if(p&&s.has(p.paragraphId)){let f=i.get(chunkDY3QVCWC_cjs.Hc(o.find(g=>g.blockId===p.paragraphId)?.text??"")),y=f?.indexOf(p.paragraphId)??-1;return f&&y>=0&&f.splice(y,1),p.paragraphId}let u=nn(l);if(u.length===0)return null;let m=i.get(u);return !m||m.length===0?null:m.shift()??null})}function C(e){return e.namespaceUri===chunkDY3QVCWC_cjs.ma?e.localName:`{${e.namespaceUri}}${e.localName}`}function I(e){let t=[];for(let n of e.attributes)t.push(n.namespaceUri===""||n.namespaceUri===chunkDY3QVCWC_cjs.ma?`${n.localName}=${n.value}`:`{${n.namespaceUri}}${n.localName}=${n.value}`);return t.sort(),t}function gt(e,t){let n=I(e),r=n.length>0?`${C(e)}(${n.join(",")})`:C(e);if(t>=chunkDY3QVCWC_cjs.ca)return r;let o=[];for(let s of e.children){if(s.kind==="textValue"){s.value!==""&&o.push(`#${s.value}`);continue}o.push(gt(s,t+1));}return o.sort(),o.length>0?`${r}[${o.join(",")}]`:r}function yt(e){if(!e)return [];let t=[];for(let n of e.children)n.namespaceUri===chunkDY3QVCWC_cjs.ma&&t.push(gt(n,1));return t.sort(),t}function Ge(e){if(e.kind==="textValue")return e.value;if(e.kind==="tab")return " ";if(e.kind==="hardBreak")return chunkDY3QVCWC_cjs._b(e);if(e.kind==="drawing")return chunkDY3QVCWC_cjs.mc();if(e.kind==="runProperties"||e.kind==="paragraphProperties"||e.kind==="generic")return "";if(e.kind==="hyperlink"||chunkDY3QVCWC_cjs.Lb(e)){let n="",r=e.kind==="hyperlink"?e.children:chunkDY3QVCWC_cjs.Nb(e)??[];for(let o of r)n+=Ge(o);return n}let t="";for(let n of e.children)t+=Ge(n);return t}function x(e,t){let n=new Map(e);for(let r of t.namespaceBindings)n.set(r.prefix,r.namespaceUri);return n}function V(e,t){try{return chunkDY3QVCWC_cjs.wa(e,t)}catch(n){if(n instanceof chunkDY3QVCWC_cjs.qa&&n.reason==="undeclared-prefix")return `generic-refusal:undeclared-prefix:{${e.namespaceUri}}${e.localName}`;throw n}}function ze(e,t,n=chunkDY3QVCWC_cjs.va){if(e.kind==="textValue")return;if(e.kind==="runProperties"||e.kind==="paragraphProperties"){let o=x(n,e),s=[];for(let a of e.children)a.namespaceUri!==chunkDY3QVCWC_cjs.ma&&s.push(V(a,o));s.sort(),t.push(...s);return}if(e.kind==="generic"){t.push(V(e,n));return}if(chunkDY3QVCWC_cjs.Lb(e)){t.push(chunkDY3QVCWC_cjs.xa(e));return}if(e.kind==="bookmarkStart"||e.kind==="bookmarkEnd"){t.push(chunkDY3QVCWC_cjs.wa(e,n));return}if(e.kind==="drawing"){t.push(ht(e));return}if(chunkDY3QVCWC_cjs.la(e.kind))return;let r=x(n,e);for(let o of e.children)ze(o,t,r);}function on(e){return `hyperlink(${e.attributes.map(n=>`${n.namespaceUri}|${n.localName}=${n.value}`).sort().join(",")})`}function an(e){for(let t of e.children)if(t.kind==="pictureBlipFill")for(let n of t.children){if(n.kind!=="pictureBlip")continue;let r=n.attributes.find(s=>s.localName==="embed"&&s.namespaceUri===chunkDY3QVCWC_cjs.pa)?.value,o=n.attributes.find(s=>s.localName==="link"&&s.namespaceUri===chunkDY3QVCWC_cjs.pa)?.value;if(r!==void 0)return `embed=${r}`;if(o!==void 0)return `link=${o}`}}function te(e,t,n){if(e.kind==="textValue")return `#${e.value}`;if(t>=chunkDY3QVCWC_cjs.ca)return C(e);let r=x(n,e);if(e.kind==="generic")return V(e,r);let o=I(e),s=o.length>0?`${C(e)}(${o.join(",")})`:C(e),a=[];for(let i of e.children)i.kind!=="textValue"&&a.push(te(i,t+1,r));return a.sort(),a.length>0?`${s}[${a.join(",")}]`:s}function sn(e,t,n){let r=x(n,e),o=[];for(let s of e.children)if(s.kind!=="textValue"){if(s.kind==="pictureBlipFill"){let a=s.children,i=a.find(l=>l.kind==="pictureBlip"),d=a.filter(l=>l.kind!=="pictureBlip").map(l=>te(l,t+1,r));if(d.sort(),i&&i.kind==="pictureBlip"){let l=I(i),c=l.length>0?`pictureBlip(${l.join(",")})`:"pictureBlip";o.push(d.length>0?`${c}[${d.join(",")}]`:c);}else for(let l of a)o.push(te(l,t+1,r));continue}o.push(te(s,t+1,r));}return o.sort(),o}function We(e,t,n){if(e.kind==="textValue")return `#${e.value}`;if(t>=chunkDY3QVCWC_cjs.ca)return C(e);let r=x(n,e);if(e.kind==="drawingDocPr"){let i=I(e);return i.length>0?`docPr(${i.join(",")})`:"docPr"}if(e.kind==="picture"){let i=an(e),d=sn(e,t+1,r),l=i===void 0?"picture":`picture(${i})`;return d.length>0?`${l}[${d.join(",")}]`:l}let o=I(e),s=o.length>0?`${C(e)}(${o.join(",")})`:C(e),a=[];for(let i of e.children){if(i.kind==="picture"){a.push(We(i,t+1,r));continue}if(i.kind==="generic"){a.push(V(i,r));continue}i.kind!=="textValue"&&a.push(We(i,t+1,r));}return a.length>0?`${s}[${a.join(",")}]`:s}function ht(e){let t=x(chunkDY3QVCWC_cjs.va,e),n=e.children.find(i=>i.kind==="inlineDrawing"||i.kind==="anchoredDrawing");if(!n||n.kind==="textValue")return `drawing(${I(e).join(",")})`;let r=x(t,n),o=I(n),s=o.length>0?`${n.kind}(${o.join(",")})`:n.kind,a=[];for(let i of n.children){if(i.kind==="generic"){a.push(V(i,r));continue}i.kind!=="textValue"&&a.push(We(i,1,r));}return a.length>0?`drawing[${s};${a.join(";")}]`:`drawing[${s}]`}function ln(e,t,n){let r=e.children.find(c=>c.kind==="paragraphProperties"),o=[],s="",a=[],i=x(chunkDY3QVCWC_cjs.va,e),d=(c,p)=>{if(c.kind==="run"){let u=x(p,c),m=c.children.find(f=>f.kind==="runProperties");o.push(yt(m)),s+=Ge(c);for(let f of c.children)ze(f,a,u);return}if(c.kind==="drawing"){a.push(ht(c));return}if(c.kind==="hyperlink"){a.push(on(c));let u=x(p,c);for(let m of c.children)d(m,u);return}if(c.kind==="contentControl"){a.push(chunkDY3QVCWC_cjs.xa({...c,children:c.children.filter(m=>m.kind!=="contentControlContent")}));let u=x(p,c);for(let m of c.children){if(m.kind!=="contentControlContent")continue;let f=x(u,m);for(let y of m.children)d(y,f);}return}ze(c,a,p);};for(let c of e.children)d(c,i);let l=chunkDY3QVCWC_cjs.Oc(e);return {ordinal:t,path:n,paraId:l===null?null:l.toUpperCase(),text:s,paragraphProperties:yt(r),runProperties:o,genericStructure:a}}function cn(e){if(e.localName==="hdr"||e.localName==="ftr"||e.kind==="body")return e;for(let t of e.children)if(t.kind!=="textValue"&&(t.kind==="body"||t.localName==="hdr"||t.localName==="ftr"))return t;return e}function xt(e,t,n,r,o,s){if(s>chunkDY3QVCWC_cjs.ca)return;let a=0;for(let i of e.children){if(i.kind==="textValue"){i.value.trim()!==""&&o.push(`${t}/#text ${i.value}`);continue}let d=t===""?String(a):`${t}/${a}`;if(a+=1,i.kind==="paragraph"){n.push(i),r.push(d),o.push(`${d} p`);continue}let l=I(i);o.push(l.length>0?`${d} ${C(i)}(${l.join(",")})`:`${d} ${C(i)}`),xt(i,d,n,r,o,s+1);}}function Nt(e){let t=cn(e.root),n=[],r=[],o=[];xt(t,"",n,r,o,0);let s=n.map((a,i)=>ln(a,i,r[i]));return {partName:e.name,paragraphs:s,structure:o}}function dn(e){let t=[];for(let n of e){let r=Nt(n);r&&t.push(r);}return {stories:t}}function pn(e,t){let n=[],r=(s,a,i)=>{n.push({path:s,before:JSON.stringify(a)??"undefined",after:JSON.stringify(i)??"undefined"});};e.stories.length!==t.stories.length&&r("stories.length",e.stories.length,t.stories.length);let o=Math.min(e.stories.length,t.stories.length);for(let s=0;s<o;s+=1){let a=e.stories[s],i=t.stories[s],d=p=>`${a.partName}${p}`;a.paragraphs.length!==i.paragraphs.length&&r(d(".paragraphs.length"),a.paragraphs.length,i.paragraphs.length);let l=Math.min(a.paragraphs.length,i.paragraphs.length);for(let p=0;p<l;p+=1){let u=a.paragraphs[p],m=i.paragraphs[p];u.text!==m.text&&r(d(`.p[${p}].text`),u.text,m.text),u.path!==m.path&&r(d(`.p[${p}].path`),u.path,m.path),u.paraId!==m.paraId&&r(d(`.p[${p}].paraId`),u.paraId,m.paraId),JSON.stringify(u.paragraphProperties)!==JSON.stringify(m.paragraphProperties)&&r(d(`.p[${p}].paragraphProperties`),u.paragraphProperties,m.paragraphProperties),JSON.stringify(u.runProperties)!==JSON.stringify(m.runProperties)&&r(d(`.p[${p}].runProperties`),u.runProperties,m.runProperties),JSON.stringify(u.genericStructure)!==JSON.stringify(m.genericStructure)&&r(d(`.p[${p}].genericStructure`),u.genericStructure,m.genericStructure);}a.structure.length!==i.structure.length&&r(d(".structure.length"),a.structure.length,i.structure.length);let c=Math.min(a.structure.length,i.structure.length);for(let p=0;p<c;p+=1)a.structure[p]!==i.structure[p]&&r(d(`.structure[${p}]`),a.structure[p],i.structure[p]);}return n}var j="http://schemas.openxmlformats.org/wordprocessingml/2006/main",fn="http://schemas.openxmlformats.org/package/2006/relationships",Ot="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",_="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",yn="application/vnd.openxmlformats-package.relationships+xml",gn="http://schemas.openxmlformats.org/package/2006/content-types",Rt="/[Content_Types].xml",E="/word/numbering.xml",Ct=[{text:"\uF0B7",font:"Symbol"},{text:"o",font:"Courier New"},{text:"\uF0A7",font:"Wingdings"}],bt=["decimal","lowerLetter","lowerRoman"],Ye=9;function St(e,t){let n=720*(t+1),r='<w:start w:val="1"/>';if(e==="bullet"){let a=Ct[t%Ct.length];return `<w:lvl w:ilvl="${t}">${r}<w:numFmt w:val="bullet"/><w:lvlText w:val="${a.text}"/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="${n}" w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="${a.font}" w:hAnsi="${a.font}" w:hint="default"/></w:rPr></w:lvl>`}let o=bt[t%bt.length],s=o==="lowerRoman";return `<w:lvl w:ilvl="${t}">${r}<w:numFmt w:val="${o}"/><w:lvlText w:val="%${t+1}."/><w:lvlJc w:val="${s?"right":"left"}"/><w:pPr><w:ind w:left="${n}" w:hanging="${s?180:360}"/></w:pPr></w:lvl>`}function hn(e,t){let n=Array.from({length:Ye},(r,o)=>St(e,o)).join("");return `<w:abstractNum w:abstractNumId="${t}"><w:multiLevelType w:val="${e==="bullet"?"hybridMultilevel":"multilevel"}"/>${n}</w:abstractNum>`}function xn(){let e=chunkDY3QVCWC_cjs.Ba(`<w:numbering xmlns:w="${j}"></w:numbering>`,{name:E,contentType:_});return e.ok?e.part:null}var b=(e,t)=>{let n=[];for(let r of e.children)r.kind==="textValue"||r.localName!==t||r.namespaceUri===j&&n.push(r);return n},N=(e,t)=>e.attributes.find(n=>n.localName===t)?.value;function vt(e,t){let n=chunkDY3QVCWC_cjs.Ba(`<w:numbering xmlns:w="${j}">${e}</w:numbering>`,{name:E,contentType:_});if(!n.ok)return null;let r=[];for(let o of n.part.root.children)o.kind!=="textValue"&&r.push(o);if(r.length!==t.length)return null;for(let o=0;o<t.length;o+=1){let s=r[o],a=t[o];if(s.namespaceUri!==j||s.localName!==a.localName||a.attribute&&N(s,a.attribute.localName)!==a.attribute.value)return null}return r}var Et=["numPicBullet","abstractNum","num","numIdMacAtCleanup"];function Pt(e,t,n){let r=t.indexOf(n);if(r===-1)return e.length;let o=0;return e.forEach((s,a)=>{if(s.kind==="textValue")return;let i=t.indexOf(s.localName);i!==-1&&i<=r&&(o=a+1);}),o}function It(e,t){let n=0;for(let r of e){let o=N(r,t);!o||!/^\d{1,9}$/.test(o)||(n=Math.max(n,Number(o)));}return n+1}function Nn(e,t){let n=e.parts.get(E),r=n??xn();if(!r)return null;let o=r.root,s=b(o,"abstractNum"),a=b(o,"num"),i=t==="bullet"?"bullet":"decimal";for(let O of a){let $=N(O,"numId"),qe=b(O,"abstractNumId")[0],Qe=qe?N(qe,"val"):void 0;if(!$||!Qe)continue;let Ze=s.find(X=>N(X,"abstractNumId")===Qe);if(!Ze)continue;let et=b(Ze,"lvl").find(X=>N(X,"ilvl")==="0"||N(X,"ilvl")===void 0),tt=et?b(et,"numFmt")[0]:void 0;if(tt&&N(tt,"val")===i)return {pkg:e,numId:$}}let d=It(s,"abstractNumId"),l=It(a,"numId"),c=vt(hn(t,d)+`<w:num w:numId="${l}"><w:abstractNumId w:val="${d}"/></w:num>`,[{localName:"abstractNum",attribute:{localName:"abstractNumId",value:String(d)}},{localName:"num",attribute:{localName:"numId",value:String(l)}}]);if(!c)return null;let p=chunkDY3QVCWC_cjs.Da(r),[u,m]=c.map(O=>ne(O,p));if(!u||!m)return null;let f=chunkDY3QVCWC_cjs.Ia(r,o.id,Pt(o.children,Et,"abstractNum"),[u]);if(!f.ok)return null;let y=chunkDY3QVCWC_cjs.Ia(f.part,o.id,Pt(f.part.root.children,Et,"num"),[m]);if(!y.ok)return null;let g=Object.freeze({...e,parts:new Map([...e.parts,[E,y.part]])});if(!n){let O=bn(g);if(!O)return null;let $=kn(O);if(!$)return null;g=$;}return {pkg:g,numId:String(l)}}var On=["nsid","multiLevelType","tmpl","name","styleLink","numStyleLink","lvl"];function Tt(e){let t=N(e,"ilvl");return t===void 0||!/^\d{1,9}$/.test(t)?null:Number(t)}function Rn(e,t){let n=0;return e.forEach((r,o)=>{if(r.kind!=="textValue"){if(r.localName==="lvl"&&r.namespaceUri===j){(Tt(r)??0)<t&&(n=o+1);return}On.includes(r.localName)&&(n=o+1);}}),n}function Cn(e,t,n,r){if(!Number.isInteger(n)||n<0||n>=Ye||t.length===0||t.length>64)return null;let o=e.parts.get(E);if(!o)return null;let s=o.root,a=b(s,"num").find(f=>N(f,"numId")===t),i=a?b(a,"abstractNumId")[0]:void 0,d=i?N(i,"val"):void 0;if(!d)return null;let l=b(s,"abstractNum").find(f=>N(f,"abstractNumId")===d);if(!l||b(l,"numStyleLink").length>0)return null;let c=b(l,"lvl");if(c.some(f=>Tt(f)===n))return e;if(c.length>=Ye)return null;let p=vt(St(r,n),[{localName:"lvl",attribute:{localName:"ilvl",value:String(n)}}]);if(!p)return null;let u=chunkDY3QVCWC_cjs.Da(o),m=chunkDY3QVCWC_cjs.Ia(o,l.id,Rn(l.children,n),[ne(p[0],u)]);return m.ok?Object.freeze({...e,parts:new Map([...e.parts,[E,m.part]])}):null}function ne(e,t){return e.kind==="textValue"?{...e,id:t()}:{...e,id:t(),children:e.children.map(n=>ne(n,t))}}function bn(e){let t=e.mainDocumentPart,n=En(t),r=e.parts.get(n),o=Pn(e),s=chunkDY3QVCWC_cjs.Ba(`<Relationships xmlns="${fn}"><Relationship Id="${o}" Type="${Ot}" Target="numbering.xml"/></Relationships>`,{name:n,contentType:yn});if(!s.ok)return null;let a=e.relationships.get(t)??[],i={ownerPart:t,id:o,type:Ot,rawTarget:"numbering.xml",targetMode:"Internal",order:a.reduce((u,m)=>Math.max(u,m.order),-1)+1},d=new Map([...e.relationships,[t,[...a,i]]]);if(!r)return Object.freeze({...e,parts:new Map([...e.parts,[n,s.part]]),relationships:d});let l=chunkDY3QVCWC_cjs.Da(r),c=s.part.root.children[0];if(!c)return null;let p=chunkDY3QVCWC_cjs.Ia(r,r.root.id,r.root.children.length,[ne(c,l)]);return p.ok?Object.freeze({...e,parts:new Map([...e.parts,[n,p.part]]),relationships:d}):null}function En(e){let t=e.lastIndexOf("/");return `${e.slice(0,t)}/_rels/${e.slice(t+1)}.rels`}function Pn(e){let t=0;for(let n of e.relationships.values())for(let r of n){let o=/^rId(\d{1,9})$/.exec(r.id);o&&(t=Math.max(t,Number(o[1])));}for(let n of e.externalTargets){let r=/^rId(\d{1,9})$/.exec(n.id);r&&(t=Math.max(t,Number(r[1])));}return `rId${t+1}`}var In=`<Override PartName="${E}" ContentType="${_}"/>`;function kn(e){let t=e.contentTypes.overrides.get(chunkDY3QVCWC_cjs.p(E));if(t===_)return e;if(t!==void 0)return null;let n=e.partBytes.get(Rt);if(!n)return null;let r=fflate.strFromU8(n),o=kt(r);if(!o)return null;let s=r.lastIndexOf(`</${o.rootName}>`);if(s===-1)return null;let a=r.slice(0,s)+In+r.slice(s),i=kt(a);if(!i||i.rootName!==o.rootName)return null;let d=[...o.children,wt("Override",{PartName:E,ContentType:_})];return i.children.length!==d.length||i.children.some((l,c)=>l!==d[c])?null:Object.freeze({...e,partBytes:new Map([...e.partBytes,[Rt,fflate.strToU8(a)]]),contentTypes:Object.freeze({defaults:e.contentTypes.defaults,overrides:new Map([...e.contentTypes.overrides,[chunkDY3QVCWC_cjs.p(E),_]])})})}function kt(e){let t=chunkDY3QVCWC_cjs.da(e);if(!t.ok)return null;let n=t.nodes.filter(i=>i.type==="element");if(n.length!==1)return null;let r=n[0],o=r.name.indexOf(":"),s=o===-1?"":r.name.slice(0,o);if(r.name.slice(o+1)!=="Types"||r.attributes[s?`xmlns:${s}`:"xmlns"]!==gn)return null;let a=[];for(let i of r.children)i.type==="element"&&a.push(wt(i.name,i.attributes));return {rootName:r.name,children:a}}function wt(e,t){let n=Object.entries(t).map(([r,o])=>`${r}=${o}`).sort();return [e,...n].join("")}function re(e){return e!=null&&e.kind!=="textValue"}function Je(e,t){for(let n of e.children)if(n.kind!=="textValue"&&n.namespaceUri===chunkDY3QVCWC_cjs.ma&&n.localName===t)return n;return null}function oe(e,t){for(let n of e.attributes)if(n.namespaceUri===chunkDY3QVCWC_cjs.ma&&n.localName===t)return n.value}function A(e,t){let n=Je(e,t);if(!n)return false;let r=oe(n,"val");return r===void 0?true:r!=="0"&&r!=="false"&&r!=="off"}var _t=Object.freeze({trackRevisions:false,restrictedToTrackedChanges:false,doNotTrackMoves:false,doNotTrackFormatting:false});function Sn(e){if(!re(e))return _t;let t=Je(e,"documentProtection"),n=t===null?void 0:oe(t,"enforcement"),r=n!==void 0&&n!=="0"&&n!=="false"&&n!=="off";return {trackRevisions:A(e,"trackRevisions"),restrictedToTrackedChanges:r&&t!==null&&oe(t,"edit")==="trackedChanges",doNotTrackMoves:A(e,"doNotTrackMoves"),doNotTrackFormatting:A(e,"doNotTrackFormatting")}}var At=Object.freeze({doNotShadeFormData:false});function vn(e){return re(e)?{doNotShadeFormData:A(e,"doNotShadeFormData")}:At}function Tn(e,t){let n=e.parts.get(t.storyPartName);if(!n)return {ok:false,reason:`no story part named ${t.storyPartName}`};let r=[];for(let d of chunkDY3QVCWC_cjs.te(n.root)){let l=chunkDY3QVCWC_cjs.re(d.node).tag;if(l===void 0||l.length===0)continue;let c=t.decide(l);c!=="keep"&&r.push({nodeId:d.node.id,policy:c});}let o=n,s=0,a=0;for(let{nodeId:d,policy:l}of r){let c=chunkDY3QVCWC_cjs.Ga(o,d);if(!c)continue;if(l==="remove"){let g=chunkDY3QVCWC_cjs.Ka(o,d,{deferValidation:true});if(!g.ok)return {ok:false,reason:`a node could not be removed: ${$t(g)}`};o=g.part,a+=1;continue}let p=c.children.find(g=>g.id===d);if(!p)continue;let u=chunkDY3QVCWC_cjs.pe(p),m=u?u.children:[],f=c.children.flatMap(g=>g.id===d?m:[g]),y=chunkDY3QVCWC_cjs.Ha(o,c.id,f,{deferValidation:true});if(!y.ok)return {ok:false,reason:`a node could not be unwrapped: ${$t(y)}`};o=y.part,s+=1;}let i=o===n?e:chunkDY3QVCWC_cjs.Ab(e,o);if(!i.parts.has(t.storyPartName))return {ok:false,reason:"the story went missing during the export"};for(let d of t.namespaces)for(let l of _n(i,t.storyPartName,d)){let c=chunkDY3QVCWC_cjs.if(i,l.itemId),p=chunkDY3QVCWC_cjs.cf(i,l.partName,c);if(p.pkg===i&&p.removed.length===0&&!wn(i,l.partName,c))return {ok:false,reason:`the payloads in ${d} could not be removed`};if(i=p.pkg,c.size>0)continue;let u=An(i,l);if(!u.ok)return {ok:false,reason:`the payload store for ${d} could not be removed`};i=u.pkg;}return {ok:true,pkg:i,unwrapped:s,removed:a}}function wn(e,t,n){return chunkDY3QVCWC_cjs._e(e,t).every(r=>n.has(r.id))}function $t(e){return e.issues.map(t=>t.code).join(", ")||"the edit was refused"}function _n(e,t,n){return chunkDY3QVCWC_cjs.We(e,t).filter(r=>r.namespaceUri===n)}function An(e,t){let n=chunkDY3QVCWC_cjs.Gb(e,t.partName);if(!n.ok)return {pkg:e,ok:false};let r=chunkDY3QVCWC_cjs.Gb(n.pkg,t.propsPartName);return r.ok?{pkg:r.pkg,ok:true}:{pkg:e,ok:false}}var ie="http://purl.org/dc/elements/1.1/",Dt="http://schemas.openxmlformats.org/package/2006/metadata/core-properties",Mt="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties";var sp=Object.freeze({});function k(e,t,n){if(e.kind!=="textValue")for(let r of e.children){if(r.kind==="textValue"||r.namespaceUri!==t||r.localName!==n)continue;let o=r.children.find(a=>a.kind==="textValue");if(!o||o.kind!=="textValue")return;let s=o.value.trim();return s.length===0?void 0:s.length>4096?s.slice(0,4096):s}}function lp(e,t){let n={};if(e&&e.kind!=="textValue"){let r=k(e,ie,"title");r!==void 0&&(n.title=r);let o=k(e,ie,"creator");o!==void 0&&(n.creator=o);let s=k(e,ie,"subject");s!==void 0&&(n.subject=s);let a=k(e,ie,"description");a!==void 0&&(n.description=a);let i=k(e,Dt,"keywords");i!==void 0&&(n.keywords=i);let d=k(e,Dt,"lastModifiedBy");d!==void 0&&(n.lastModifiedBy=d);}if(t&&t.kind!=="textValue"){let r=k(t,Mt,"Company");r!==void 0&&(n.company=r);let o=k(t,Mt,"Manager");o!==void 0&&(n.manager=o);}return n}
|
|
2
2
|
exports.A=Ve;exports.B=je;exports.C=Xe;exports.D=qt;exports.E=dt;exports.F=mt;exports.G=tn;exports.H=rn;exports.I=Nt;exports.J=dn;exports.K=pn;exports.L=Nn;exports.M=Cn;exports.N=_t;exports.O=Sn;exports.P=At;exports.Q=vn;exports.R=sp;exports.S=lp;exports.T=Tn;exports.a=Ft;exports.b=ot;exports.c=J;exports.d=S;exports.e=q;exports.f=Q;exports.g=h;exports.h=Ht;exports.i=v;exports.j=B;exports.k=Z;exports.l=U;exports.m=ee;exports.n=De;exports.o=Me;exports.p=Fe;exports.q=Kt;exports.r=Gt;exports.s=Be;exports.t=at;exports.u=zt;exports.v=Le;exports.w=Wt;exports.x=H;exports.y=Ue;exports.z=He;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
'use strict';var chunkIJ4V3LGV_cjs=require('./chunk-IJ4V3LGV.cjs'),chunkSFMAIFEN_cjs=require('./chunk-SFMAIFEN.cjs'),chunkDY3QVCWC_cjs=require('./chunk-DY3QVCWC.cjs'),prosemirrorModel=require('prosemirror-model'),prosemirrorState=require('prosemirror-state'),prosemirrorView=require('prosemirror-view'),prosemirrorKeymap=require('prosemirror-keymap'),prosemirrorCommands=require('prosemirror-commands');function j(t){return t.attributes?.val}function H(t){let e=j(t);return e===void 0||!(e==="0"||e==="false"||e==="off")}var En=/^[0-9A-Fa-f]{6}$/,ke=/^\d{1,6}$/,Dn=/^-?\d{1,6}$/;function _e(t){return t===void 0||t==="auto"?null:En.test(t)?`#${t}`:null}var Cn={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"},Mn={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 wn(t){return !t||!/^[\w \-.+]{1,64}$/.test(t)?null:`"${t}"`}function Y(t,e=false){return t===void 0||!(e?Dn:ke).test(t)?null:`${Number(t)/20}pt`}function Wt(t){let e=[],n=[],o=null,s=null;for(let l of t)switch(l.localName){case "b":e.push(`font-weight:${H(l)?"bold":"normal"}`);break;case "i":e.push(`font-style:${H(l)?"italic":"normal"}`);break;case "u":{let r=j(l)??"single";if(r==="none"||!H(l))break;n.push("underline"),o=Cn[r]??"solid",s=_e(l.attributes?.color);break}case "strike":H(l)&&n.push("line-through");break;case "dstrike":H(l)&&n.push("line-through");break;case "caps":H(l)&&e.push("text-transform:uppercase");break;case "smallCaps":H(l)&&e.push("font-variant:small-caps");break;case "vertAlign":{let r=j(l);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=_e(j(l));r&&e.push(`color:${r}`);break}case "highlight":{let r=Mn[j(l)??""];r&&e.push(`background-color:${r}`);break}case "sz":{let r=j(l);r!==void 0&&ke.test(r)&&e.push(`font-size:${Number(r)/2}pt`);break}case "rFonts":{let r=wn(l.attributes?.ascii??l.attributes?.hAnsi);r&&e.push(`font-family:${r}`);break}case "spacing":{let r=Y(j(l),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}`),s&&e.push(`text-decoration-color:${s}`)),e.join(";")}var Fn={left:"left",start:"left",right:"right",end:"right",center:"center",both:"justify",distribute:"justify"};function Yt(t){let e=[];for(let n of t)switch(n.localName){case "jc":{let o=Fn[j(n)??""];o&&e.push(`text-align:${o}`);break}case "ind":{let o=Y(n.attributes?.left??n.attributes?.start,true),s=Y(n.attributes?.right??n.attributes?.end,true),l=Y(n.attributes?.firstLine),r=Y(n.attributes?.hanging);o&&e.push(`margin-left:${o}`),s&&e.push(`margin-right:${s}`),l?e.push(`text-indent:${l}`):r&&e.push(`text-indent:-${r}`);break}case "spacing":{let o=Y(n.attributes?.before),s=Y(n.attributes?.after);o&&e.push(`margin-top:${o}`),s&&e.push(`margin-bottom:${s}`);let l=n.attributes?.line,r=n.attributes?.lineRule;l!==void 0&&ke.test(l)&&r!=="exact"&&r!=="atLeast"?e.push(`line-height:${(Number(l)/240).toFixed(3)}`):l!==void 0&&ke.test(l)&&e.push(`line-height:${Number(l)/20}pt`);break}case "shd":{let o=_e(n.attributes?.fill);o&&e.push(`background-color:${o}`);break}case "pageBreakBefore":H(n)&&e.push("break-before:page");break;}return e.join(";")}var E=new prosemirrorModel.Schema({nodes:{doc:{content:"paragraph+"},paragraph:{content:"inline*",group:"block",attrs:{nodeId:{default:null},props:{default:[]}},toDOM:t=>{let e=Yt(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=Wt(e);return ["span",{"data-run-props":Ln(e),...n?{style:n}:{}},0]},parseDOM:[{tag:"span[data-run-props]",getAttrs:t=>{if(typeof t=="string")return false;let e=_n(t.getAttribute("data-run-props"));return e?{props:e}:false}}]}}});function Ln(t){return JSON.stringify(Array.isArray(t)?t:[])}function _n(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 s=o;if(typeof s.localName!="string"||s.attributes!==void 0&&(typeof s.attributes!="object"||s.attributes===null))return null;n.push(s.attributes===void 0?{localName:s.localName}:{localName:s.localName,attributes:s.attributes});}return n}catch{return null}}function Be(t){for(let e of t.marks)if(e.type.name==="runProps")return e.attrs.props??[];return []}function xe(t,e){return JSON.stringify(be(t))===JSON.stringify(be(e))}function be(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 He(t){if(!t||t.kind==="textValue")return [];let e=[];for(let n of t.children){if(n.kind==="textValue")continue;let o={};for(let s of n.attributes)o[s.localName]=s.value;e.push(Object.keys(o).length>0?{localName:n.localName,attributes:o}:{localName:n.localName});}return e}function Gt(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 K(t){if(t.kind==="textValue")return [];let e=[],n=o=>{if(o.kind!=="run")return;let s=o.children.find(r=>r.kind==="runProperties"),l=He(s);for(let r of o.children)if(r.kind!=="runProperties"){if(r.kind==="tab"){e.push({kind:"tab"});continue}if(r.kind==="hardBreak"){e.push(chunkDY3QVCWC_cjs.Zb(r)?{kind:"pageBreak"}:{kind:"hardBreak"});continue}if(r.kind==="text"){let p="";for(let m of r.children)m.kind==="textValue"&&(p+=m.value);p.length>0&&e.push({kind:"text",text:p,props:l});continue}e.push({kind:"unknown",nodeId:r.id,label:Gt(r)});}};return chunkDY3QVCWC_cjs.Sb(t.children,0,o=>{if(o.kind==="run"){n(o);return}e.push({kind:"unknown",nodeId:o.id,label:Gt(o)});}),e}function M(t){let e=[],n=o=>{if(o.kind!=="textValue"){if(o.kind==="body"){for(let s of o.children)s.kind==="paragraph"&&e.push(s);return}for(let s of o.children)n(s);}};return n(t.root),e}function $(t){let e=[];for(let n of chunkDY3QVCWC_cjs.De(t))n.root.kind!=="textValue"&&chunkDY3QVCWC_cjs.Ge(n.root.children,e,0);return e}function G(t){let e=M(t).map(n=>{let o=n.kind==="textValue"?void 0:n.children.find(l=>l.kind==="paragraphProperties"),s=K(n).map(l=>{switch(l.kind){case "text":return E.text(l.text,l.props.length>0?[E.marks.runProps.create({props:l.props})]:[]);case "tab":return E.node("tab");case "hardBreak":return E.node("hardBreak");case "pageBreak":return E.node("pageBreak");default:return E.node("unknownInline",{nodeId:l.nodeId,label:l.label})}});return E.node("paragraph",{nodeId:n.id,props:He(o)},s)});return E.node("doc",null,e.length>0?e:[E.node("paragraph")])}function V(t){let e=[];return t.forEach(n=>{if(n.isText&&n.text){e.push({kind:"text",text:n.text,props:Be(n)});return}n.type.name==="tab"?e.push({kind:"tab"}):n.type.name==="hardBreak"?e.push({kind:"hardBreak"}):n.type.name==="pageBreak"?e.push({kind:"pageBreak"}):n.type.name==="unknownInline"&&e.push({kind:"unknown",nodeId:String(n.attrs.nodeId??""),label:String(n.attrs.label??"")});}),e}function D(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+=chunkDY3QVCWC_cjs.Xb);return e}function Kt(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}`);return e}function Bn(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 s=t.length,l=e.length;for(;s>n&&l>n&&t[s-1]===e[l-1];)s-=1,l-=1;return {start:n,endBefore:s,endAfter:l}}function Xt(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]??[]);return e}function Hn(t,e,n,o,s){let l=[],r=Kt(e),p=Kt(n);if(JSON.stringify(r)!==JSON.stringify(p))return {ok:false,reason:"unknown-content-moved",detail:t};xe(o,s)||l.push({op:"setParagraphProperties",paragraphId:t,properties:be(s)});let m=D(e),f=D(n),h=Bn(m,f);if(h&&(h.endBefore>h.start&&l.push({op:"deleteText",paragraphId:t,start:h.start,end:h.endBefore}),h.endAfter>h.start)){let b=f.slice(h.start,h.endAfter),g=h.start,i="",y=()=>{i.length!==0&&(l.push({op:"insertText",paragraphId:t,offset:g,text:i}),g+=i.length,i="");};for(let x of b)x===" "?(y(),l.push({op:"insertTab",paragraphId:t,offset:g}),g+=1):x===`
|
|
3
|
+
`?(y(),l.push({op:"insertHardBreak",paragraphId:t,offset:g}),g+=1):x===chunkDY3QVCWC_cjs.Xb?(y(),l.push({op:"insertPageBreak",paragraphId:t,offset:g}),g+=1):i+=x;y();}if(!h){let b=Xt(e),g=Xt(n),i=0;for(;i<g.length;){if(xe(b[i]??[],g[i])){i+=1;continue}let y=i,x=g[i];for(;i<g.length&&xe(g[i],x)&&!xe(b[i]??[],g[i]);)i+=1;l.push({op:"setRunProperties",paragraphId:t,start:y,end:i,properties:be(x)});}}return {ok:true,ops:l}}function je(t,e){let n=M(t),o=[];if(e.forEach(l=>{l.type.name==="paragraph"&&o.push(l);}),o.length!==e.childCount)return {ok:false,reason:"unsupported-node"};let s=o.length-n.length;if(s===0){let l=[];for(let[r,p]of o.entries()){let m=n[r];if(p.attrs.nodeId!==m.id)return {ok:false,reason:"paragraph-reordered",detail:String(p.attrs.nodeId)};let f=Hn(m.id,K(m),V(p),He(m.kind==="textValue"?void 0:m.children.find(h=>h.kind==="paragraphProperties")),p.attrs.props??[]);if(!f.ok)return f;l.push(...f.ops);}return {ok:true,ops:l}}return s===1?jn(n,o):s===-1?$n(n,o):{ok:false,reason:"paragraph-count-unexplained",detail:String(s)}}function jn(t,e){for(let n=0;n<t.length;n+=1){let o=t[n],s=e[n],l=e[n+1];if(!s||!l||s.attrs.nodeId!==o.id)continue;let r=l.attrs.nodeId;if(r!==null&&r!==o.id)continue;let p=D(V(s));if(p+D(V(l))===D(K(o))&&Jt(t,e,n)&&Zt(t,e,n+1,n+2))return {ok:true,ops:[{op:"splitParagraph",paragraphId:o.id,offset:p.length}]}}return {ok:false,reason:"split-not-clean"}}function $n(t,e){for(let n=0;n+1<t.length;n+=1){let o=t[n],s=t[n+1],l=e[n];if(!l||l.attrs.nodeId!==o.id)continue;let r=D(K(o))+D(K(s));if(D(V(l))===r&&Jt(t,e,n)&&Zt(t,e,n+2,n+1))return {ok:true,ops:[{op:"joinParagraphs",firstId:o.id,secondId:s.id}]}}return {ok:false,reason:"join-not-clean"}}function Jt(t,e,n){for(let o=0;o<n;o+=1){let s=e[o],l=t[o];if(!s||s.attrs.nodeId!==l.id||D(V(s))!==D(K(l)))return false}return true}function Zt(t,e,n,o){for(let s=0;n+s<t.length;s+=1){let l=t[n+s],r=e[o+s];if(!r||r.attrs.nodeId!==l.id||D(V(r))!==D(K(l)))return false}return true}function zn(t,e){return chunkDY3QVCWC_cjs.Fa(t,e)!==null}function $e(t,e,n){if(!n||n.created.length>0||n.deleted.length>0||n.splitJoin.length>0)return G(e);let o=new Map;t.forEach(m=>{let f=m.attrs.nodeId;typeof f=="string"&&o.set(f,m);});let s=new Set(n.dirty),l=M(e);if(l.length!==t.childCount)return G(e);let r=G(e),p=[];for(let[m,f]of l.entries()){let h=o.get(f.id);p.push(h&&!s.has(f.id)?h:r.child(m));}return E.node("doc",null,p)}function Un(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 Vt(t,e,n){for(let s of e)if(s.ranges.length===0)return false;let o=new Set;for(let s of t)s.kind!=="revision"||s.ranges.length>0||qt(s,n)||o.add(chunkIJ4V3LGV_cjs.b(s));for(let s of e)if(o.has(chunkIJ4V3LGV_cjs.b(s)))return false;return true}function Qt(t,e,n,o){let s=e.get(n);if(s===void 0)return [...t];let l=[],r=null;for(let p of t){if(p.kind==="revision"&&qt(p,n)){r===null&&(r=l.length);continue}if(r===null){let m=Un(p,e);m!==null&&m>s&&(r=l.length);}l.push(p);}if(r===null&&(r=l.length),o.length>0){let p=o.length<2?[...o]:[...o].sort((m,f)=>chunkIJ4V3LGV_cjs.g(m,e)-chunkIJ4V3LGV_cjs.g(f,e));l.splice(r,0,...p);}return chunkDY3QVCWC_cjs.sg(l)}function qt(t,e){return t.ranges.length>0&&t.ranges.every(n=>n.start.paragraphId===e&&n.end.paragraphId===e)}function Wn(t,e){return t.range?t.range.start.paragraphId===e||t.range.end.paragraphId===e:false}function Yn(t,e){return t.revisionKind==="structural"&&t.ranges.some(n=>n.start.paragraphId===e||n.end.paragraphId===e)}function Gn(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 en(t,e,n,o,s,l,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!==s||e.commentsExtendedPart!==l)return null;let p=t.dirty[0],m=chunkDY3QVCWC_cjs.Fa(o,p);if(!m||m.kind!=="paragraph")return null;for(let f of n){if(f.kind==="comment"){if(Wn(f,p))return null;continue}if(f.kind==="custom"){if(f.range?.start.paragraphId===p)return null;continue}if(Yn(f,p)||Gn(f,p))return null}return p}var nn=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u,Kn=["ascii","hAnsi","cs","eastAsia"],Xn=["asciiTheme","hAnsiTheme","cstheme","eastAsiaTheme"],Jn=128,Zn=/[\u0000-\u001F\u007F-\u009F]/;function Q(t){return t.kind!=="textValue"}function X(t,e){return t.attributes.find(n=>n.localName===e)?.value}function rn(t,e){let n=new Map,o=r=>{if(!r||!nn.test(r))return;let p=r.toLowerCase();n.has(p)||n.set(p,r);},s=[...t].reverse();for(;s.length>0;){let r=s.pop();if(Q(r)){if(r.localName==="rFonts"){for(let p of Kn)o(X(r,p));if(e)for(let p of Xn){let m=X(r,p);m!==void 0&&(m.startsWith("major")?o(e.major):m.startsWith("minor")&&o(e.minor));}}for(let p=r.children.length-1;p>=0;p-=1)s.push(r.children[p]);}}let l=[...n.values()];return l.sort((r,p)=>r<p?-1:r>p?1:0),l}function on(t){let e=[...t];for(;e.length>0;){let n=e.pop();if(Q(n)){if(n.localName==="t"&&n.namespaceUri===chunkDY3QVCWC_cjs.ma){for(let o of n.children)if(!Q(o)&&o.value.length>0)return true;continue}for(let o of n.children)e.push(o);}}return false}var Vn=new Set(["paragraph","character","table","numbering"]),Qn=/^[0-9A-Fa-f]{6}$/,qn=16,tn=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 an(t){return t.children}function ze(t,e){for(let n of an(t))if(Q(n)&&n.localName===e)return n}function er(t){return tn.get(t.name.toLowerCase())??tn.get(t.styleId.toLowerCase())??Number.MAX_SAFE_INTEGER}function Ue(t){return t===void 0||t.length===0||t.length>Jn||Zn.test(t)?null:t}function ln(t,e){if(!t)return [];let n=new Map;for(let l of t.children){if(!Q(l)||l.localName!=="style")continue;let r=Ue(X(l,"styleId"));r!==null&&!n.has(r)&&n.set(r,l);}let o=l=>{let r=false,p=false,m=null,f=false,h=false,b=new Set,g=l;for(let x=0;x<qn&&g!==null&&!b.has(g);x+=1){b.add(g);let T=n.get(g);if(!T)break;let O=ze(T,"rPr");for(let I of O?an(O):[]){if(!Q(I))continue;let v=X(I,"val"),B=v!=="0"&&v!=="false"&&v!=="off";I.localName==="b"&&!f?(r=B,f=true):I.localName==="i"&&!h?(p=B,h=true):I.localName==="color"&&m===null&&v&&Qn.test(v)&&(m=v);}let S=ze(T,"basedOn");g=S?Ue(X(S,"val")):null;}let i=e?.(l),y=i?.fontFamily??null;return {fontFamily:y!==null&&nn.test(y)?y:null,fontSizePt:i?.fontSizeHalfPoints!=null&&i.fontSizeHalfPoints>0?i.fontSizeHalfPoints/2:null,bold:r,italic:p,color:m}},s=[];for(let[l,r]of n){let p=X(r,"type");if(p===void 0||!Vn.has(p))continue;let m=ze(r,"name"),f=Ue(m?X(m,"val"):void 0);s.push({styleId:l,name:f??l,type:p,preview:o(l)});}return s.map((l,r)=>({entry:l,index:r,rank:er(l)})).sort((l,r)=>l.rank-r.rank||l.index-r.index).map(l=>l.entry)}var tr=128,nr=/[\u0000-\u001F\u007F-\u009F]/,rr=/[\u0000-\u001F\u007F-\u009F]/g,or=200,ar=/^heading ([1-9])$/i;function We(t){return t.kind!=="textValue"}function le(t,e){for(let n of t.children)if(We(n)&&n.localName===e)return n}function ae(t,e){return t.attributes.find(n=>n.localName===e)?.value}function lr(t){let e=new Map;if(!t)return e;for(let n of t.children){if(!We(n)||n.localName!=="style"||ae(n,"type")!=="paragraph")continue;let o=ae(n,"styleId");if(o===void 0||o.length===0||o.length>tr||nr.test(o))continue;let s=le(n,"name"),l=s?ae(s,"val"):void 0,r=l!==void 0?ar.exec(l):null;if(r){e.set(o,Number(r[1])-1);continue}let p=le(n,"pPr"),m=p?le(p,"outlineLvl"):void 0,f=m?ae(m,"val"):void 0;f!==void 0&&/^[0-8]$/.test(f)&&e.set(o,Number(f));}return e}function Ye(t){let e=le(t,"pPr"),n=e?le(e,"pStyle"):void 0;return n?ae(n,"val"):void 0}function sn(t,e){let n=lr(e);if(n.size===0)return [];let o=[];for(let s of M(t)){if(!We(s))continue;let l=Ye(s);if(l===void 0)continue;let r=n.get(l);if(r===void 0)continue;let m=(chunkDY3QVCWC_cjs.Ff(t,s.id)??"").replace(rr," ").trim().slice(0,or);m.length!==0&&o.push({text:m,level:r,blockId:s.id});}return o}var Pe=48,sr=/[\u0000-\u001F\u007F-\u009F]/g;function un(t){return t.kind!=="textValue"}function Oe(t){if(t.kind==="textValue")return t.value.length;if(t.kind==="tab"||t.kind==="hardBreak")return 1;if(t.kind==="runProperties"||t.kind==="generic")return 0;if(t.kind==="hyperlink"||chunkDY3QVCWC_cjs.Lb(t)){let n=0,o=t.kind==="hyperlink"?t.children:chunkDY3QVCWC_cjs.Nb(t)??[];for(let s of o)n+=Oe(s);return n}let e=0;for(let n of t.children)e+=Oe(n);return e}function ir(t){let e=[],n=0;return un(t)&&chunkDY3QVCWC_cjs.Sb(t.children,0,o=>{if(o.kind==="run"){e.push(n),n+=Oe(o);return}n+=Oe(o);}),e}function ur(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];if(e>=o)return {index:n,offset:e-o}}return {index:0,offset:e}}function Ge(t,e){return t.replace(sr," ").slice(0,e)}function cn(t,e,n={}){let o={matches:[],truncated:false};if(!chunkDY3QVCWC_cjs.Bg(e))return o;let s=n.limit!==void 0&&Number.isInteger(n.limit)&&n.limit>0?Math.min(n.limit,2e3):2e3,l={...n.matchCase===void 0?{}:{matchCase:n.matchCase},...n.wholeWord===void 0?{}:{wholeWord:n.wholeWord}},r=[],p=0;for(let m of M(t)){if(!un(m))continue;let f=p;p+=1;let h=chunkDY3QVCWC_cjs.Ff(t,m.id)??"";if(h.length===0)continue;let b=chunkDY3QVCWC_cjs.Cg(h,e,s-r.length,l),g=null;for(let i of b.matches){let y=i.start+i.length;g??=ir(m);let x=ur(g,i.start);r.push({blockId:m.id,start:i.start,length:i.length,paragraphIndex:f,runIndex:x.index,runOffset:x.offset,text:Ge(h.slice(i.start,y),256),contextBefore:Ge(h.slice(Math.max(0,i.start-Pe),i.start),Pe),contextAfter:Ge(h.slice(y,y+Pe),Pe)});}if(b.truncated)return {matches:r,truncated:true}}return {matches:r,truncated:false}}var cr=["lt1","dk1","lt2","dk2","accent1","accent2","accent3","accent4","accent5","accent6"],dr=/^[0-9A-Fa-f]{6}$/,dn={windowText:"000000",window:"FFFFFF"};function mn(t){return t.kind!=="textValue"}function Se(t,e){return t.attributes.find(n=>n.localName===e)?.value}function fn(t,e){let n=[t];for(;n.length>0;){let o=n.pop();if(mn(o)){if(o.localName===e)return o;for(let s=o.children.length-1;s>=0;s-=1)n.push(o.children[s]);}}return null}function ve(t,e){for(let n of t.children)if(mn(n)&&(e===void 0||n.localName===e))return n;return null}function pr(t){let e=ve(t);if(!e)return null;let n;if(e.localName==="srgbClr")n=Se(e,"val");else if(e.localName==="sysClr"){let o=Se(e,"val")??"";n=Se(e,"lastClr")??(Object.prototype.hasOwnProperty.call(dn,o)?dn[o]:void 0);}return n===void 0||!dr.test(n)?null:n.toUpperCase()}var mr=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u;function pn(t,e){let n=ve(t,e),o=n?ve(n,"latin"):null,s=o?Se(o,"typeface"):void 0;return s!==void 0&&mr.test(s)?s:null}function se(t){if(!t)return {major:null,minor:null};let e=fn(t,"fontScheme");return e?{major:pn(e,"majorFont"),minor:pn(e,"minorFont")}:{major:null,minor:null}}function gn(t){if(!t)return [];let e=fn(t,"clrScheme");if(!e)return [];let n=[];for(let o of cr){let s=ve(e,o),l=s?pr(s):null;if(l===null)return [];n.push({slot:o,hex:l});}return n}var fr=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u;var gr=/[\u0000-\u001F\u007F-\u009F]/;function kn(t){return t.kind!=="textValue"}function J(t,e){for(let n of t.children)if(kn(n)&&n.localName===e)return n}function Z(t,e){return t.attributes.find(n=>n.localName===e)?.value}function yn(t){return t===void 0||t.length===0||t.length>128||gr.test(t)?null:t}function Re(t,e){return t==="minorAscii"||t==="minorHAnsi"?e.minor:t==="majorAscii"||t==="majorHAnsi"?e.major:null}function yr(t,e){let n=Re(Z(t,"asciiTheme"),e)??Re(Z(t,"hAnsiTheme"),e);if(n!==null)return n;let o=Z(t,"ascii")??Z(t,"hAnsi");return o===void 0?null:fr.test(o)?o:null}function hn(t,e){if(!t)return {fontFamily:null,fontSizeHalfPoints:null};let n=J(t,"rFonts"),o=J(t,"sz"),s=o?Z(o,"val"):void 0,l=s!==void 0&&/^\d{1,4}$/.test(s)?Number(s):null;return {fontFamily:n?yr(n,e):null,fontSizeHalfPoints:l!==null&&l>=2&&l<=3276?l:null}}function Ke(t,e){let n=new Map,o={fontFamily:null,fontSizeHalfPoints:null};if(t){let r=J(t,"docDefaults"),p=r?J(r,"rPrDefault"):void 0;o=hn(p?J(p,"rPr"):void 0,e);for(let m of t.children){if(!kn(m)||m.localName!=="style")continue;let f=yn(Z(m,"styleId"));if(f===null||n.has(f))continue;let h=J(m,"basedOn");n.set(f,{basedOn:yn(h?Z(h,"val"):void 0),own:hn(J(m,"rPr"),e)});}}let s=new Map,l=r=>{let p=r??"",m=s.get(p);if(m)return m;let f=null,h=null,b=new Set,g=r;for(let y=0;g!==null&&y<16&&!b.has(g);y+=1){b.add(g);let x=n.get(g);if(!x)break;f??=x.own.fontFamily,h??=x.own.fontSizeHalfPoints,g=x.basedOn;}let i={fontFamily:f??o.fontFamily,fontSizeHalfPoints:h??o.fontSizeHalfPoints};return s.set(p,i),i};return (r,p)=>{let m=l(r),f=p?.find(b=>b.localName==="rFonts"),h=f?Re(f.attributes?.asciiTheme,e)??Re(f.attributes?.hAnsiTheme,e):null;return h===null?m:{...m,fontFamily:h}}}function xn(t){let e=new Map,n=new Map,o=new Map;return $(t).forEach((s,l)=>{o.set(s.id,l);let r=chunkDY3QVCWC_cjs.Oc(s);if(r===null||!chunkDY3QVCWC_cjs.Nc(r))return;e.set(s.id,r);let p=r.toUpperCase();n.has(p)||n.set(p,s.id);}),Object.freeze({paraIdByNode:e,nodeByParaId:n,ordinalByNode:o})}var hr=Object.freeze([]);function kr(t,e={}){let n=chunkDY3QVCWC_cjs.yb(t);if(!n.ok)return {ok:false,reason:n.reason,...n.detail?{detail:n.detail}:{}};let o=n.package,s=o.parts.get(o.mainDocumentPart);if(!s)return {ok:false,reason:"no-main-document-tree",detail:o.mainDocumentPart};let l=chunkDY3QVCWC_cjs.Uc(s),r=new chunkDY3QVCWC_cjs.Kf(o,l),p=null,m=null,f=null,h=null;r.subscribe(a=>{h=a;});let b=()=>r.bodyStore(),g=()=>r.currentPackage(),i=Object.freeze({kind:"body"}),y=(a,u)=>{let c=r.currentPackage(),d=a.checkpoint();a.graftPackage(()=>r.currentPackage());let k=u();return k.ok&&(a.restoreHistoryStacks(d),r.replacePackageShell(a.package),r.adoptPackageUnit(c),r.publishStoryWrite(k.change)),k},x=()=>{if(!p||p.packageRevision!==r.packageRevision){let a=chunkDY3QVCWC_cjs.Ub(g());p={packageRevision:r.packageRevision,resolution:a,parts:chunkDY3QVCWC_cjs.Vb(g())};}return p},T="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",O="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",S=false,I=null,v=()=>{if(S)return I;S=true;let a=g(),u=(a.relationships.get(a.mainDocumentPart)??[]).find(d=>d.type===T),c;if(u){let d=chunkDY3QVCWC_cjs.O(u);d.mode==="Internal"&&d.target.ok&&(c=a.parts.get(d.target.partName));}return c??=a.parts.get("/word/styles.xml"),I=c?.root??null,I},B=false,z=null,ie=()=>{if(B)return z;B=true;let a=g(),u=(a.relationships.get(a.mainDocumentPart)??[]).find(d=>d.type===O),c;if(u){let d=chunkDY3QVCWC_cjs.O(u);d.mode==="Internal"&&d.target.ok&&(c=a.parts.get(d.target.partName));}return c??=a.parts.get("/word/numbering.xml"),z=c?.root??null,z},q="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",ue=-1,Te=null,Xe=()=>{if(ue===r.packageRevision)return Te;ue=r.packageRevision;let a=g(),u=(a.relationships.get(a.mainDocumentPart)??[]).find(d=>d.type===q),c;if(u){let d=chunkDY3QVCWC_cjs.O(u);d.mode==="Internal"&&d.target.ok&&(c=a.parts.get(d.target.partName));}return c??=a.parts.get("/word/settings.xml"),Te=c?.root??null,Te},Sn="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",vn="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",Je=(a,u)=>{let c=g(),d=(c.relationships.get("/")??[]).find(P=>P.type===a),k;if(d){let P=chunkDY3QVCWC_cjs.O(d);P.mode==="Internal"&&P.target.ok&&(k=c.parts.get(P.target.partName));}return k??c.parts.get(u)},Ze=-1,Ie=chunkSFMAIFEN_cjs.R,Rn=()=>{if(Ze===r.packageRevision)return Ie;Ze=r.packageRevision;let a=Je(Sn,"/docProps/core.xml"),u=Je(vn,"/docProps/app.xml");return Ie=chunkSFMAIFEN_cjs.S(a?.root??null,u?.root??null),Ie},Tn="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",Ve=false,Ne=null,ee=()=>{if(Ve)return Ne;Ve=true;let a=g(),u=(a.relationships.get(a.mainDocumentPart)??[]).find(d=>d.type===Tn),c;if(u){let d=chunkDY3QVCWC_cjs.O(u);d.mode==="Internal"&&d.target.ok&&(c=a.parts.get(d.target.partName));}return c??=a.parts.get("/word/theme/theme1.xml"),Ne=c?.root??null,Ne},In="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",ce=null,Nn=()=>{if(ce)return ce;let a=g(),u=(a.relationships.get(a.mainDocumentPart)??[]).find(d=>d.type===In),c;if(u){let d=chunkDY3QVCWC_cjs.O(u);d.mode==="Internal"&&d.target.ok&&(c=a.parts.get(d.target.partName));}return c??=a.parts.get("/word/fontTable.xml"),ce=Object.freeze(chunkSFMAIFEN_cjs.G(a,c)),ce},te=null,ne=null,Qe=null,qe=null,et=null,tt=()=>{let a=[b().part.root],u=v();u&&a.push(u);let c=new Set;for(let d of x().parts)for(let k of [...d.headers.values(),...d.footers.values()])c.has(k)||(c.add(k),a.push(k.root));return a},de=null,pe=null,re=null,oe=null,me=null,fe=null,Ee=()=>{let a=b();return (!me||me.revision!==a.revision)&&(me={revision:a.revision,index:xn(a.part)}),me.index};return {ok:true,session:{editable:$(b().part).length>0,paragraphIds:()=>$(b().part).map(a=>a.id),paragraphIdsIn(a=i){let u=r.partFor(a);return u?$(u).map(c=>c.id):[]},part:()=>b().part,partFor:a=>r.partFor(a),currentPackage:g,applyTreeOps(a,u,c,d=i){if(a.length===0)return {committed:false,rejected:false,opCount:0};let k=a.filter(R=>chunkDY3QVCWC_cjs.Yc(R)||chunkDY3QVCWC_cjs.ce(R)).length;if(k>0){if(k!==a.length||a.length!==1)return {committed:false,rejected:true,opCount:a.length,reason:"invalidArgs"};let R=r.applyLifecycleOp(a[0]);return R.ok?{committed:true,rejected:false,opCount:1}:{committed:false,rejected:true,opCount:1,reason:R.detail??R.reason}}let P=r.transact(d,R=>{u!==void 0&&R.selectionBefore(u),c!==void 0&&R.selectionAfter(c);for(let N of a)R.apply(N);});return P.ok?{committed:true,rejected:false,opCount:a.length}:{committed:false,rejected:true,opCount:a.length,reason:P.reason}},projectDoc:()=>G(b().part),reconcile:a=>$e(a,b().part,h),lastCommitWasStructural:()=>h!==null&&(h.created.length>0||h.deleted.length>0||h.splitJoin.length>0||h.impact==="global"),applyPmDoc(a){let u=b(),c=je(u.part,a);if(!c.ok)return {committed:false,rejected:true,opCount:0,reason:c.reason};if(c.ops.length===0)return {committed:false,rejected:false,opCount:0};let d=r.transact(i,k=>{for(let P of c.ops)k.apply(P);});return d.ok?{committed:true,rejected:false,opCount:c.ops.length}:{committed:false,rejected:true,opCount:c.ops.length,reason:d.reason}},bodyText:()=>xr(b().part),storyText(a){let u=r.partFor(a);return u?$(u).map(c=>chunkDY3QVCWC_cjs.Ff(u,c.id)??"").join(`
|
|
4
|
+
`):null},revision:()=>b().revision,revisionFor:a=>r.revisionFor(a),packageRevision:()=>r.packageRevision,canUndo:()=>r.canUndo,canRedo:()=>r.canRedo,undo:()=>{let a=r.selectionForUndo();return r.undo()===null?null:a},redo:()=>{let a=r.selectionForRedo();return r.redo()===null?null:a},beginComposition:(a=i)=>{r.beginComposition(a);},endComposition:()=>r.endComposition(),subscribe(a){return r.subscribe(a)},save(){return chunkDY3QVCWC_cjs.zb(g())},headerFooterParts:()=>{let a=x().parts;return a[a.length-1]??chunkDY3QVCWC_cjs.Wb(g())},headerFooterPartsBySection:()=>x().parts,headerFooterResolutionBySection:()=>x().resolution,documentFonts(){return te&&te.revision===r.packageRevision||(te={revision:r.packageRevision,fonts:rn(tt(),se(ee()))}),te.fonts},rendersText(){return ne&&ne.revision===r.packageRevision||(ne={revision:r.packageRevision,rendersText:on(tt())}),ne.rendersText},documentStyles(){de??=Ke(v(),se(ee()));let a=de;return Qe??=ln(v(),u=>a(u)),Qe},stylesRoot:()=>v(),documentThemeFonts(){return et??=se(ee()),et},numberingRoot:()=>ie(),settingsRoot:()=>Xe(),documentProperties:()=>Rn(),trackingSettings:()=>chunkSFMAIFEN_cjs.O(Xe()),documentThemeColors(){return qe??=gn(ee()),qe},effectiveRunDefaults(a,u){de??=Ke(v(),se(ee()));let c=b();if(!pe||pe.revision!==c.revision){let d=new Map;for(let k of $(c.part))k.kind!=="textValue"&&d.set(k.id,Ye(k)??null);pe={revision:c.revision,byId:d};}return de(pe.byId.get(a)??null,u)},documentOutline(){let a=b();return re&&re.revision===a.revision||(re={revision:a.revision,outline:sn(a.part,v())}),re.outline},findText(a,u){let c=b(),d=`${u?.matchCase===true?"c":""}${u?.wholeWord===true?"w":""}${u?.limit??""}\0${a}`;if(oe&&oe.revision===c.revision&&oe.key===d)return oe.result;let k=cn(c.part,a,u??{});return oe={revision:c.revision,key:d,result:k},k},embeddedFonts:Nn,paragraphAnchors:Ee,paraIdOf:a=>Ee().paraIdByNode.get(a)??null,nodeIdOf:a=>Ee().nodeByParaId.get(a.toUpperCase())??null,relationshipTarget:(a,u=i)=>{let c=g(),d=r.partFor(u);return d?chunkDY3QVCWC_cjs.Xc(c,d.name,a):null},bookmarks:()=>{let a=b();return (!fe||fe.revision!==a.revision)&&(fe={revision:a.revision,index:chunkDY3QVCWC_cjs.Cc(a.part)}),fe.index},ensureHyperlinkRelationship(a,u=i){let c=r.partFor(u);if(!c)return null;let d=g(),k=chunkDY3QVCWC_cjs.Wc(d,a,c.name);return k?(k.pkg!==d&&r.replacePackageShell(k.pkg),k.relationshipId):null},reviewItems(){let a=e.reviewModel;if(!a)return hr;let u=b(),c=`${r.packageRevision}:${u.revision}`;if(m&&m.revisionKey===c)return m.items;let d=g(),k=d.parts.get(chunkDY3QVCWC_cjs.Sf(d,u.part.name)),P=d.parts.get(chunkDY3QVCWC_cjs.Tf(d,u.part.name)),R=[],N=new Set;for(let A of x().parts)for(let L of [A.headers,A.footers])for(let _ of L.values())N.has(_)||(N.add(_),R.push(_));for(let A of ["footnote","endnote"]){let L=chunkDY3QVCWC_cjs.Yd(d,A);!L||N.has(L)||(N.add(L),R.push(L));}let w=m&&h?en(h,m,m.items,u.part,k,P,r.packageRevision):null,F,C;if(w&&m){let A=a.revisionItemsOfParagraph(u.part,w);Vt(m.items,A,w)?(F=Qt(m.items,m.paragraphOrder,w,A),C=m.paragraphOrder):(C=chunkDY3QVCWC_cjs.tg(u.part),F=a.collectReviewItems({storyPart:u.part,furnitureParts:R,commentsPart:k,commentsExtendedPart:P,customNodePayloads:chunkDY3QVCWC_cjs.Zf(g(),u.part.name)}));}else C=chunkDY3QVCWC_cjs.tg(u.part),F=a.collectReviewItems({storyPart:u.part,furnitureParts:R,commentsPart:k,commentsExtendedPart:P,customNodePayloads:chunkDY3QVCWC_cjs.Zf(g(),u.part.name)});return m={revisionKey:c,bodyRevision:u.revision,packageRevision:r.packageRevision,items:F,paragraphOrder:C,commentsPart:k,commentsExtendedPart:P},m.items},hasReviewContent(){let a=b();return (!f||f.revision!==a.revision)&&(f={revision:a.revision,present:chunkDY3QVCWC_cjs.kf(a.part).length>0||Pn(a.part.root)}),f.present},replyToComment(a,u,c,d,k,P=i){let R=P.kind==="body"?null:r.resolveStory(P),N=R?.ok?R.store:b(),w=r.currentPackage(),F=N.checkpoint();N.graftPackage(()=>r.currentPackage());let C=chunkDY3QVCWC_cjs.Pf(N,{anchor:{paragraphId:u.paragraphId,start:u.start,end:u.end,...u.endParagraphId===void 0?{}:{endParagraphId:u.endParagraphId}},author:d,text:c,...k===void 0?{}:{date:k},...a===null?{}:{replyToCommentId:a}});return C.ok?(N.restoreHistoryStacks(F),r.replacePackageShell(N.package),r.adoptPackageUnit(w),r.publishStoryWrite(C.change),C.commentId):null},setCommentResolved(a,u){let c=b(),d=r.currentPackage(),k=c.checkpoint();c.graftPackage(()=>r.currentPackage());let P=chunkDY3QVCWC_cjs.Qf(c,a,u);return P.ok?(P.changed&&(c.restoreHistoryStacks(k),r.replacePackageShell(c.package),r.adoptPackageUnit(d),r.publishStoryWrite(P.change)),true):false},deleteComment(a,u=i,c){return this.deleteComments([{commentId:a}],u,c)},deleteComments(a,u=i,c){if(a.length===0)return false;let d=u.kind==="body"?b().part:r.partFor(u);if(!d)return false;let k={storyPartName:d.name,...c===void 0?{}:{noteId:c}},P=b(),R=r.currentPackage(),N=P.checkpoint();P.graftPackage(()=>r.currentPackage());let w=false,F=false,C=P.transact(A=>{A.applyPackage(L=>{let _=L;for(let ge of a){let De=ge.parentCommentId===void 0?chunkDY3QVCWC_cjs.Oe(_,ge.commentId,k):chunkDY3QVCWC_cjs.Pe(_,ge.commentId,ge.parentCommentId,k);if(De===null)return w=true,L;F||=De!==_,_=De;}return _});});return w||!C.ok||!F?false:(P.restoreHistoryStacks(N),r.installPackageSnapshot(P.package),r.adoptPackageUnit(R),r.publishStoryWrite(C.change),true)},insertCustomNode(a,u=i){let c=u.kind==="body"?null:r.resolveStory(u),d=c?.ok?c.store:b();return y(d,()=>chunkDY3QVCWC_cjs.Wf(d,a,b().part.name))},removeCustomNode(a,u=i){let c=u.kind==="body"?null:r.resolveStory(u),d=c?.ok?c.store:b();return y(d,()=>chunkDY3QVCWC_cjs.Xf(d,a))},sweepCustomNodePayloads(a){let u=b(),c=chunkDY3QVCWC_cjs.Yf(r.currentPackage(),u.part.name,a);return c.ok?c.removed.length===0?{ok:true,removed:[]}:(r.replacePackageShell(c.pkg),{ok:true,removed:c.removed}):{ok:false,reason:c.reason}},ensureListDefinition(a){let u=chunkSFMAIFEN_cjs.L(g(),a);return u?(r.replacePackageShell(u.pkg),B=false,z=null,u.numId):null},ensureNumberingLevel(a,u,c){let d=g(),k=chunkSFMAIFEN_cjs.M(d,a,u,c);return k?(k!==d&&(r.replacePackageShell(k),B=false,z=null),true):false},insertImage(a,u){return r.insertImage(a,u)},replaceImage(a,u,c,d,k,P){return r.replaceImage(a,u,c,d,k,P)},deleteImage(a,u){return r.deleteImage(a,u)},applyImageProperties(a,u){return r.applyImageProperties(a,u)}}}}function xr(t){return M(t).map(e=>chunkDY3QVCWC_cjs.Ff(t,e.id)??"").join(`
|
|
5
|
+
`)}var bn=new WeakMap;function Pn(t,e=0){if(e>64)return false;let n=bn.get(t);if(n!==void 0)return n;let o=false;for(let s of t.children)if(s.kind!=="textValue"&&(s.kind==="commentRangeStart"||s.kind==="commentReference"||Pn(s,e+1))){o=true;break}return bn.set(t,o),o}var br=chunkDY3QVCWC_cjs.t.projection;function Cr(t,e,n){let o=t.filter(s=>s.localName!==e);return o.length!==t.length?o:[...o,n?{localName:e,attributes:n}:{localName:e}]}function Mr(t,e,n={}){let o=null,s=false,l=()=>n.onChange?.(r()),r=()=>({revision:e.revision(),canUndo:e.canUndo(),canRedo:e.canRedo(),lastRejection:o}),p=i=>{s=true;let y=f.state.tr.replaceWith(0,f.state.doc.content.size,i.content);y.setMeta("addToHistory",false),f.dispatch(y),s=false;},m=i=>()=>(i()&&(p(e.projectDoc()),l()),true),f=new prosemirrorView.EditorView(t,{state:prosemirrorState.EditorState.create({doc:e.projectDoc(),plugins:[prosemirrorKeymap.keymap({...prosemirrorCommands.baseKeymap,Home:prosemirrorCommands.selectTextblockStart,End:prosemirrorCommands.selectTextblockEnd,"Mod-z":m(()=>e.undo()!==null),"Mod-y":m(()=>e.redo()!==null),"Shift-Mod-z":m(()=>e.redo()!==null),"Mod-b":(i,y)=>g(i,y,"b"),"Mod-i":(i,y)=>g(i,y,"i"),"Mod-u":(i,y)=>g(i,y,"u",{val:"single"})})]}),editable:()=>e.editable,handleDOMEvents:{keydown:i=>(h(i),false),beforeinput:(i,y)=>{let x=y;if(i.composing)return false;h(i);let T=x.inputType;if(T==="insertText"&&x.data!=null){x.preventDefault();let{from:O,to:S}=i.state.selection;return i.dispatch(i.state.tr.insertText(x.data,O,S)),true}if(T==="deleteContentBackward"){x.preventDefault();let{from:O,empty:S}=i.state.selection;return S?O>0?i.dispatch(i.state.tr.delete(O-1,O)):prosemirrorCommands.joinBackward(i.state,i.dispatch):prosemirrorCommands.deleteSelection(i.state,i.dispatch),true}if(T==="deleteContentForward"){x.preventDefault();let{from:O,to:S,empty:I}=i.state.selection;return I?S<i.state.doc.content.size?i.dispatch(i.state.tr.delete(O,O+1)):prosemirrorCommands.joinForward(i.state,i.dispatch):prosemirrorCommands.deleteSelection(i.state,i.dispatch),true}return T==="insertParagraph"?(x.preventDefault(),prosemirrorCommands.splitBlock(i.state,i.dispatch),true):false},compositionstart:()=>(e.beginComposition(),false),compositionend:()=>(e.endComposition(),l(),false)},dispatchTransaction(i){let y=f.state.apply(i);if(s||!i.docChanged){f.updateState(y);return}let x=e.applyPmDoc(y.doc);if(x.rejected){o=String(x.reason??"rejected"),f.updateState(y),p(e.projectDoc()),l();return}o=null,f.updateState(x.committed&&e.lastCommitWasStructural()?b(y):y),l();}});function h(i){if(i.composing||s)return;let y=i.dom.ownerDocument.getSelection(),x=y?.anchorNode,T=y?.focusNode;if(!(!y||!x||!T)&&!(!i.dom.contains(x)||!i.dom.contains(T)))try{let O=i.posAtDOM(x,y.anchorOffset),S=i.posAtDOM(T,y.focusOffset),I=i.state.selection;if(I.anchor===O&&I.head===S)return;let v=prosemirrorState.TextSelection.create(i.state.doc,O,S);i.dispatch(i.state.tr.setSelection(v).setMeta("addToHistory",!1));}catch{}}function b(i){let y=e.paragraphIds(),x=i.tr,T=false,O=0;return i.doc.forEach((S,I)=>{let v=y[O];O+=1,!(S.type.name!=="paragraph"||v===void 0)&&S.attrs.nodeId!==v&&(x=x.setNodeMarkup(I,void 0,{...S.attrs,nodeId:v}),T=true);}),T?i.apply(x.setMeta("addToHistory",false)):i}function g(i,y,x,T){let O=E.marks.runProps;if(!y)return true;let{from:S,to:I,empty:v}=i.selection;if(v)return true;let z=i.doc.resolve(S).marks().find(ue=>ue.type===O)?.attrs.props??[],ie=Cr(z,x,T),q=i.tr;return q.removeMark(S,I,O),ie.length>0&&q.addMark(S,I,O.create({props:ie})),y(q),true}return {view:f,state:r,undo:()=>m(()=>e.undo()!==null)(),redo:()=>m(()=>e.redo()!==null)(),toggleRunProperty(i,y){g(f.state,f.dispatch.bind(f),i,y);},destroy:()=>f.destroy()}}exports.a=E;exports.b=Be;exports.c=M;exports.d=$;exports.e=G;exports.f=je;exports.g=zn;exports.h=$e;exports.i=Ye;exports.j=kr;exports.k=br;exports.l=Mr;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {u,v as v$1,H as H$1,x as x$1,C as C$1,B as B$1,A as A$1,Cc,Hc,Fa,Da,Ia,Ba,p,da,te as te$1,re as re$1,Ga,Ka,pe,Ha,Ab,if as _if,cf,_e,We as We$1,Gb,Sa,ca,Oc,ma,r,va,xa,_b,mc,Lb,Nb,wa,la,qa,pa}from'./chunk-LJIX4ZDF.js';import {strFromU8,strToU8}from'fflate';var Ft=["extension","capability","command","query","schema","dependencyKey","runtimePort","result","origin"],Lt=/^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+$/,Bt=/^@[a-z0-9.-]+\/[a-z0-9.-]+(?:#[a-z0-9]+(?:[/._-][a-z0-9]+)*)?$/;function ot(e){return Lt.test(e)||Bt.test(e)}function J(e,t){if(!ot(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 Ut=/^(\d+)\.(\d+)\.(\d+)$/;function S(e){let t=Ut.exec(e);if(!t)throw new Error(`invalid semantic version: ${JSON.stringify(e)}`);return {major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3])}}function q(e,t){return e.major!==t.major?e.major<t.major?-1:1:e.minor!==t.minor?e.minor<t.minor?-1:1:e.patch!==t.patch?e.patch<t.patch?-1:1:0}function Q(e,t){let n=S(e),r=t.trim();if(r==="*")return true;if(r.startsWith("^")){let o=S(r.slice(1));return q(n,o)<0?false:o.major>0?n.major===o.major:o.minor>0?n.major===0&&n.minor===o.minor:n.major===0&&n.minor===0}if(r.includes(" ")){let o=r.split(/\s+/);if(o.length!==2)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let s=true;for(let a of o){let i=a.startsWith(">=")?">=":a.startsWith("<")?"<":null;if(!i)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let d=S(a.slice(i.length)),l=q(n,d);i===">="?s=s&&l>=0:s=s&&l<0;}return s}return q(n,S(r))===0}var h=class extends Error{constructor(n,r,o=[]){super(r);this.code=n;this.responsible=o;this.name="RegistryError";}code;responsible},$e=(e,t)=>`${e}:${t}`;function Ht(e,t={}){let n=new Map;for(let l of e){if(J(l.id,"extension"),it(l.version,l.id),n.has(l.id))throw new h("duplicate-extension",`duplicate extension id ${l.id}`,[l.id]);n.set(l.id,l);for(let c of l.contributions)J(c.id,c.kind),it(c.version,`${l.id} \u2192 ${c.id}`),c.replaces&&Xt(c.replaces.targetRange,`${l.id} \u2192 replaces ${c.replaces.targetId}`);}for(let l of e){for(let c of l.dependencies??[])if(!n.has(c))throw new h("missing-dependency",`${l.id} requires missing extension ${c}`,[l.id,c]);for(let c of l.conflicts??[])if(n.has(c)){let p=[l.id,c].sort();throw new h("conflict",`extensions ${p[0]} and ${p[1]} conflict`,p)}}jt(n);let r=new Set(t.availablePorts??[]);for(let l of e)for(let c of l.contributions)c.kind==="runtimePort"&&r.add(c.id);for(let l of e)for(let c of l.requiredPorts??[])if(!r.has(c))throw new h("missing-port",`${l.id} requires unavailable port ${c}`,[l.id,c]);let o=new Map,s=new Map,a=new Map;for(let l of e)for(let c of l.contributions){let p=$e(c.kind,c.id);if(c.replaces){let u=$e(c.kind,c.replaces.targetId),m=a.get(u)??[];m.push({ext:l.id,c}),a.set(u,m);continue}if(s.has(p)){let u=[o.get(p),l.id].sort();throw new h("id-collision",`${c.kind} id ${c.id} registered by both ${u[0]} and ${u[1]}`,u)}s.set(p,c),o.set(p,l.id);}let i=new Map(s);for(let[l,c]of a){let p=s.get(l);if(!p){let f=c[0];throw new h("replacement-target-missing",`${f.ext} replaces missing target ${f.c.replaces.targetId}`,[f.ext,f.c.replaces.targetId])}let u=p.replaceable??{kind:"none"};for(let{ext:f,c:y}of c){if(!Q(p.version,y.replaces.targetRange))throw new h("replacement-version-mismatch",`${f} replaces ${y.replaces.targetId}@${p.version} outside range ${y.replaces.targetRange}`,[f,y.replaces.targetId]);if(u.kind==="none")throw new h("unauthorized-replacement",`${y.replaces.targetId} does not authorize replacement (attempted by ${f})`,[f,y.replaces.targetId])}let m=Vt(p,c);i.set(l,m);}return {extensions:n,contributions:i,get:(l,c)=>i.get($e(l,c))}}function Vt(e,t){let n=e.replaceable??{kind:"none"};if(t.length===1)return t[0].c;if(n.kind==="priority"){let o=[...t].sort((i,d)=>(d.c.replaces.priority??0)-(i.c.replaces.priority??0)),s=o[0].c.replaces.priority??0,a=o.filter(i=>(i.c.replaces.priority??0)===s);if(a.length>1){let i=a.map(d=>d.ext).sort();throw new h("ambiguous-replacement",`multiple replacers of ${e.id} share top priority ${s}: ${i.join(", ")}`,i)}return o[0].c}let r=t.map(o=>o.ext).sort();throw new h("ambiguous-replacement",`multiple replacers of ${e.id}: ${r.join(", ")}`,r)}function jt(e){let o=new Map,s=[],a=i=>{o.set(i,1),s.push(i);let d=[...e.get(i)?.dependencies??[]].sort();for(let l of d){let c=o.get(l)??0;if(c===1){let p=s.indexOf(l),u=[...s.slice(p),l];throw new h("dependency-cycle",`dependency cycle: ${u.join(" -> ")}`,u)}c===0&&a(l);}s.pop(),o.set(i,2);};for(let i of [...e.keys()].sort())(o.get(i)??0)===0&&a(i);}function it(e,t){try{S(e);}catch{throw new h("invalid-version",`invalid version ${JSON.stringify(e)} in ${t}`,[t])}}function Xt(e,t){try{Q("0.0.0",e);}catch{throw new h("invalid-version",`invalid version range ${JSON.stringify(e)} in ${t}`,[t])}}var v=class extends Error{constructor(t){super(t),this.name="BudgetError";}},B=class e{constructor(t,n){this.label=t;this.capacity=n;this.used=new H$1(`${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 v(`${this.label}: cannot release with ${this.children.size} child budget(s) outstanding`);if(this.activeReservations>0)throw new v(`${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 v(`${this.label}: ${t.length} cleanup error(s); first: ${String(t[0])}`)}assertLive(){if(this.disposed)throw new v(`${this.label}: budget already released`)}};var Z=class extends Error{constructor(n,r){super(r?`cancelled: ${r}`:"cancelled");this.derivedOnly=n;this.name="CancellationError";}derivedOnly},U=class{_cancelled=false;_phase="pre-publication";_reason;cancel(t){this._cancelled=true,t!==void 0&&(this._reason=t);}markPublished(){this._phase="post-publication";}get isCancelled(){return this._cancelled}get phase(){return this._phase}get isPublished(){return this._phase==="post-publication"}get derivedOnly(){return this._cancelled&&this._phase==="post-publication"}get token(){let t=this;return {get isCancelled(){return t._cancelled},get phase(){return t._phase},get derivedOnly(){return t.derivedOnly},checkpoint(){if(t._cancelled)throw new Z(t.derivedOnly,t._reason)}}}};var ee=class extends Error{constructor(n){super(`runtime port not available: ${n}`);this.portId=n;this.name="PortResolutionError";}portId},De=class{ports=new Map;provide(t,n){return this.ports.set(t,n),this}has(t){return this.ports.has(t)}resolve(t){if(!this.ports.has(t))throw new ee(t);return this.ports.get(t)}missing(t){return t.filter(n=>!this.ports.has(n))}availablePorts(){return [...this.ports.keys()]}clock(){return this.resolve(x$1.clock)}identity(){return this.resolve(x$1.identity)}},Me=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}},Fe=class{constructor(t="id"){this.prefix=t;}prefix;n=0;newId(){return this.n+=1,`${this.prefix}-${this.n}`}};function Kt(e){let t=C$1(e.limits),n=Object.freeze({...e.config??{}}),r=e.capacity??t.maxDecompressedBytes,o=e.id??"op",s={id:o,limits:t,config:n,ports:e.ports,budget:new B(`op:${o}`,r),cancellation:new U};return Object.freeze(s)}function Gt(e){e.budget.dispose();}var Be=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"}}),at=Object.keys(Be);function zt(e,t){return new H$1(`${Be[t].phase}:${t}`,e[t])}var Le=class{counter;current=0;peak=0;constructor(t){this.counter=new H$1("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 Wt(){for(let e of at){let t=B$1[e],n=A$1[e];if(!Number.isFinite(t)||t<=0)throw new Error(`default ${e} must be finite > 0`);if(!Number.isFinite(n)||n<=0)throw new Error(`ceiling ${e} must be finite > 0`);if(t>n)throw new Error(`default ${e} exceeds ceiling`)}}function H(e,t=new Set){let n=new WeakSet,r=o=>{if(o===null)return "null";let s=typeof o;if(s==="boolean")return o?"true":"false";if(s==="number"){let a=o;if(!Number.isFinite(a))throw new Error(`non-finite number is not comparable: ${a}`);return Object.is(a,-0)?"0":String(a)}if(s==="string")return JSON.stringify(o);if(s==="bigint")return `${o.toString()}n`;if(Array.isArray(o))return `[${o.map(r).join(",")}]`;if(s==="object"){let a=o;if(n.has(a))throw new Error("cannot canonicalize a cyclic structure");n.add(a);let d=Object.keys(a).filter(l=>!t.has(l)).sort().map(l=>`${JSON.stringify(l)}:${r(a[l])}`).join(",");return n.delete(a),`{${d}}`}throw new Error(`unsupported value type in comparator input: ${s}`)};return r(e)}function Ue(e,t){let n=H(e,t),r=0xcbf29ce484222325n,o=0x100000001b3n,s=0xffffffffffffffffn;for(let a=0;a<n.length;a++)r^=BigInt(n.charCodeAt(a)),r=r*o&s;return r.toString(16).padStart(16,"0")}var R="dev.docx-editor.core.comparator",He={authoredState:{id:`${R}.authored-state`,mode:"canonical-exact",ephemera:["revision","provenance","producedAt","commitId"],note:"canonical normalized authored records; ephemera excluded"},anchor:{id:`${R}.anchor`,mode:"exact",ephemera:[],note:"internal anchor identity/affinity compares exactly"},yjsStateVector:{id:`${R}.yjs-state-vector`,mode:"sync-optimization-only",ephemera:[],note:"exchange optimization only; never proves update or delete-set coverage"},shapedRun:{id:`${R}.shaped-run`,mode:"exact",ephemera:[],note:"glyph ids, clusters, and fixed-point advances compare exactly"},paginationFingerprint:{id:`${R}.pagination-fingerprint`,mode:"exact",ephemera:[],note:"page/column boundaries, break causes, fixed-point geometry compare exactly"},semanticTree:{id:`${R}.semantic-tree`,mode:"exact",ephemera:[],note:"reading order, roles, headings, alt text compare exactly"},hitTest:{id:`${R}.hit-test`,mode:"exact",ephemera:[],note:"resolved hit target and cluster affinity compare exactly"},pdfSemantics:{id:`${R}.pdf-semantics`,mode:"canonical-exact",ephemera:["objectNumber","producer","creationDate","modDate","subsetTag"],note:"canonical semantic PDF objects; container ephemera excluded"},rasterCheckpoint:{id:`${R}.raster-checkpoint`,mode:"tolerance",ephemera:[],note:"documented unavoidable raster comparison; explicit tolerance only"},benchmarkEvidence:{id:`${R}.benchmark-evidence`,mode:"sync-optimization-only",ephemera:[],note:"diagnostic evidence, not an equivalence basis"}};function Ve(e,t,n,r={}){let o=He[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:st(t,n,r.epsilon)}}case "exact":case "canonical-exact":{let s=o.mode==="canonical-exact"?new Set(o.ephemera):new Set,a=H(t,s),i=H(n,s);return a===i?{equal:true}:{equal:false,left:a,right:i}}}}function je(e,t){let n=He[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 Ue(t,r)}function st(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)=>st(r,t[o],n)):false}var ct=new Set([...u,...v$1]),lt=/^[0-9a-f]{16}$/,Yt=/^[0-9a-f]*$/;function Xe(e){let t=[],n=o=>t.push(o);e.formatVersion!==1&&n(`unsupported formatVersion ${e.formatVersion}`),e.documentId||n("documentId is required"),e.source.kind==="docx"&&!/^[0-9a-f]{64}$/.test(e.source.sha256)&&n("docx source requires a 64-hex sha256");let r=-1;e.steps.forEach((o,s)=>{let a=`step[${s}]`;ct.has(o.origin)||n(`${a}: unknown origin ${o.origin}`),(!Number.isInteger(o.baseRevision)||o.baseRevision<0)&&n(`${a}: baseRevision must be a non-negative integer`),o.baseRevision<r&&n(`${a}: baseRevision regressed below ${r}`);let i=o.expect;i.outcome==="applied"?(i.committedRevision===void 0?n(`${a}: applied step needs committedRevision`):i.committedRevision<=o.baseRevision?n(`${a}: committedRevision ${i.committedRevision} must exceed baseRevision ${o.baseRevision}`):r=i.committedRevision,i.modelChange&&Jt(i.modelChange,a,n)):(i.committedRevision!==void 0&&n(`${a}: ${i.outcome} step must not commit a revision`),i.authoredStateHash!==void 0&&n(`${a}: ${i.outcome} step must not change authored state`)),i.authoredStateHash!==void 0&&!lt.test(i.authoredStateHash)&&n(`${a}: authoredStateHash must be 16-hex`),i.outputHash!==void 0&&!lt.test(i.outputHash)&&n(`${a}: outputHash must be 16-hex`);});for(let o of [...e.snapshots??[],...e.updates??[]])o.documentId!==e.documentId&&n(`envelope documentId ${o.documentId} != ${e.documentId}`),Yt.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 Jt(e,t,n){ct.has(e.origin)||n(`${t}: modelChange origin ${e.origin} unknown`),e.toRevision<=e.fromRevision&&n(`${t}: modelChange revision must advance`);}function qt(e,t){let n=Xe(e);if(!n.valid)return {ok:false,mismatches:n.errors};let r=[];return t.init(e),e.steps.forEach((o,s)=>{let a=`step[${s}]`,i=t.applyStep(o),d=o.expect;if(i.outcome!==d.outcome){r.push(`${a}: outcome ${i.outcome} != expected ${d.outcome}`);return}if(d.outcome==="applied"&&(i.committedRevision!==d.committedRevision&&r.push(`${a}: revision ${i.committedRevision} != expected ${d.committedRevision}`),d.authoredStateHash!==void 0))if(i.authoredState===void 0)r.push(`${a}: store returned no authored state to hash`);else {Ve("authoredState",i.authoredState,i.authoredState).equal||r.push(`${a}: authored state is not self-consistent`);let c=dt(i.authoredState);c!==d.authoredStateHash&&r.push(`${a}: authoredStateHash ${c} != expected ${d.authoredStateHash}`);}}),{ok:r.length===0,mismatches:r}}function dt(e){return je("authoredState",e)}var Qt=new Map([["embedRegular","regular"],["embedBold","bold"],["embedItalic","italic"],["embedBoldItalic","boldItalic"]]),Zt=32;function mt(e,t){let n=t.replace(/[^0-9a-fA-F]/g,"");if(n.length!==32)return null;let r=new Uint8Array(16);for(let a=0;a<16;a+=1){let i=Number.parseInt(n.slice(a*2,a*2+2),16);if(Number.isNaN(i))return null;r[15-a]=i;}let o=new Uint8Array(e),s=Math.min(Zt,o.length);for(let a=0;a<s;a+=1)o[a]=o[a]^r[a%16];return o}var Ke=(e,t)=>{if(!(e.kind==="textValue"||!("attributes"in e))){for(let n of e.attributes??[])if(n.localName===t)return n.value}},pt=e=>e.kind==="textValue"?[]:e.children??[],ut=e=>e.kind==="textValue"||!("localName"in e)?"":e.localName;function en(e,t,n){for(let r$1 of e.relationships.get(t)??[]){if(r$1.id!==n)continue;if(r$1.targetMode==="External")return null;let o=r(t,r$1.rawTarget);return o.ok?o.partName:null}return null}function tn(e,t,n={}){if(!t)return [];let r=n.maxFontBytes??16*1024*1024,o=n.maxFonts??64,s=[],a=new Map,i=d=>{if(!(s.length>=o)){if(ut(d)==="font"){let l=Ke(d,"name");if(l&&l.length<=128)for(let c of pt(d)){if(s.length>=o)return;let p=Qt.get(ut(c));if(!p)continue;let u=Ke(c,"id"),m=Ke(c,"fontKey");if(!u||!m)continue;let f=en(e,t.name,u);if(!f)continue;let y=e.partBytes.get(f);if(!y||y.length===0||y.length>r)continue;let g=a.get(f);if(g){s.push({family:l,style:p,bytes:g,partName:f});continue}let O=mt(y,m);O&&(a.set(f,O),s.push({family:l,style:p,bytes:O,partName:f}));}}for(let l of pt(d))i(l);}};return i(t.root),s}function ft(e){if(e.kind!=="textValue")for(let t of e.children){if(t.kind==="textValue")continue;if(t.kind==="hyperlink"){let r=Sa(t);if(r!==void 0&&r.length>0)return r}let n=ft(t);if(n!==void 0)return n}}function nn(e){let t="",n=false,r=o=>{if(!(n||o.kind==="textValue")){if(o.kind==="tab"||o.localName==="ptab"||o.localName==="tab"){n=true;return}if(o.kind==="text"||o.localName==="t"){for(let s of o.children)s.kind==="textValue"&&(t+=s.value);return}for(let s of o.children)r(s);}};return r(e),Hc(t)}function rn(e,t,n,r){let o=n.filter(d=>{if(r.has(d.blockId))return false;let l=d.level+1;return l>=t.instruction.outlineStart&&l<=t.instruction.outlineEnd}),s=new Set(o.map(d=>d.blockId)),a=Cc(e),i=new Map;for(let d of o){let l=Hc(d.text),c=i.get(l);c?c.push(d.blockId):i.set(l,[d.blockId]);}return t.resultParagraphIds.map(d=>{let l=Fa(e,d);if(!l||l.kind==="textValue")return null;let c=ft(l),p=c===void 0?void 0:a.get(c);if(p&&s.has(p.paragraphId)){let f=i.get(Hc(o.find(g=>g.blockId===p.paragraphId)?.text??"")),y=f?.indexOf(p.paragraphId)??-1;return f&&y>=0&&f.splice(y,1),p.paragraphId}let u=nn(l);if(u.length===0)return null;let m=i.get(u);return !m||m.length===0?null:m.shift()??null})}function C(e){return e.namespaceUri===ma?e.localName:`{${e.namespaceUri}}${e.localName}`}function I(e){let t=[];for(let n of e.attributes)t.push(n.namespaceUri===""||n.namespaceUri===ma?`${n.localName}=${n.value}`:`{${n.namespaceUri}}${n.localName}=${n.value}`);return t.sort(),t}function gt(e,t){let n=I(e),r=n.length>0?`${C(e)}(${n.join(",")})`:C(e);if(t>=ca)return r;let o=[];for(let s of e.children){if(s.kind==="textValue"){s.value!==""&&o.push(`#${s.value}`);continue}o.push(gt(s,t+1));}return o.sort(),o.length>0?`${r}[${o.join(",")}]`:r}function yt(e){if(!e)return [];let t=[];for(let n of e.children)n.namespaceUri===ma&&t.push(gt(n,1));return t.sort(),t}function Ge(e){if(e.kind==="textValue")return e.value;if(e.kind==="tab")return " ";if(e.kind==="hardBreak")return _b(e);if(e.kind==="drawing")return mc();if(e.kind==="runProperties"||e.kind==="paragraphProperties"||e.kind==="generic")return "";if(e.kind==="hyperlink"||Lb(e)){let n="",r=e.kind==="hyperlink"?e.children:Nb(e)??[];for(let o of r)n+=Ge(o);return n}let t="";for(let n of e.children)t+=Ge(n);return t}function x(e,t){let n=new Map(e);for(let r of t.namespaceBindings)n.set(r.prefix,r.namespaceUri);return n}function V(e,t){try{return wa(e,t)}catch(n){if(n instanceof qa&&n.reason==="undeclared-prefix")return `generic-refusal:undeclared-prefix:{${e.namespaceUri}}${e.localName}`;throw n}}function ze(e,t,n=va){if(e.kind==="textValue")return;if(e.kind==="runProperties"||e.kind==="paragraphProperties"){let o=x(n,e),s=[];for(let a of e.children)a.namespaceUri!==ma&&s.push(V(a,o));s.sort(),t.push(...s);return}if(e.kind==="generic"){t.push(V(e,n));return}if(Lb(e)){t.push(xa(e));return}if(e.kind==="bookmarkStart"||e.kind==="bookmarkEnd"){t.push(wa(e,n));return}if(e.kind==="drawing"){t.push(ht(e));return}if(la(e.kind))return;let r=x(n,e);for(let o of e.children)ze(o,t,r);}function on(e){return `hyperlink(${e.attributes.map(n=>`${n.namespaceUri}|${n.localName}=${n.value}`).sort().join(",")})`}function an(e){for(let t of e.children)if(t.kind==="pictureBlipFill")for(let n of t.children){if(n.kind!=="pictureBlip")continue;let r=n.attributes.find(s=>s.localName==="embed"&&s.namespaceUri===pa)?.value,o=n.attributes.find(s=>s.localName==="link"&&s.namespaceUri===pa)?.value;if(r!==void 0)return `embed=${r}`;if(o!==void 0)return `link=${o}`}}function te(e,t,n){if(e.kind==="textValue")return `#${e.value}`;if(t>=ca)return C(e);let r=x(n,e);if(e.kind==="generic")return V(e,r);let o=I(e),s=o.length>0?`${C(e)}(${o.join(",")})`:C(e),a=[];for(let i of e.children)i.kind!=="textValue"&&a.push(te(i,t+1,r));return a.sort(),a.length>0?`${s}[${a.join(",")}]`:s}function sn(e,t,n){let r=x(n,e),o=[];for(let s of e.children)if(s.kind!=="textValue"){if(s.kind==="pictureBlipFill"){let a=s.children,i=a.find(l=>l.kind==="pictureBlip"),d=a.filter(l=>l.kind!=="pictureBlip").map(l=>te(l,t+1,r));if(d.sort(),i&&i.kind==="pictureBlip"){let l=I(i),c=l.length>0?`pictureBlip(${l.join(",")})`:"pictureBlip";o.push(d.length>0?`${c}[${d.join(",")}]`:c);}else for(let l of a)o.push(te(l,t+1,r));continue}o.push(te(s,t+1,r));}return o.sort(),o}function We(e,t,n){if(e.kind==="textValue")return `#${e.value}`;if(t>=ca)return C(e);let r=x(n,e);if(e.kind==="drawingDocPr"){let i=I(e);return i.length>0?`docPr(${i.join(",")})`:"docPr"}if(e.kind==="picture"){let i=an(e),d=sn(e,t+1,r),l=i===void 0?"picture":`picture(${i})`;return d.length>0?`${l}[${d.join(",")}]`:l}let o=I(e),s=o.length>0?`${C(e)}(${o.join(",")})`:C(e),a=[];for(let i of e.children){if(i.kind==="picture"){a.push(We(i,t+1,r));continue}if(i.kind==="generic"){a.push(V(i,r));continue}i.kind!=="textValue"&&a.push(We(i,t+1,r));}return a.length>0?`${s}[${a.join(",")}]`:s}function ht(e){let t=x(va,e),n=e.children.find(i=>i.kind==="inlineDrawing"||i.kind==="anchoredDrawing");if(!n||n.kind==="textValue")return `drawing(${I(e).join(",")})`;let r=x(t,n),o=I(n),s=o.length>0?`${n.kind}(${o.join(",")})`:n.kind,a=[];for(let i of n.children){if(i.kind==="generic"){a.push(V(i,r));continue}i.kind!=="textValue"&&a.push(We(i,1,r));}return a.length>0?`drawing[${s};${a.join(";")}]`:`drawing[${s}]`}function ln(e,t,n){let r=e.children.find(c=>c.kind==="paragraphProperties"),o=[],s="",a=[],i=x(va,e),d=(c,p)=>{if(c.kind==="run"){let u=x(p,c),m=c.children.find(f=>f.kind==="runProperties");o.push(yt(m)),s+=Ge(c);for(let f of c.children)ze(f,a,u);return}if(c.kind==="drawing"){a.push(ht(c));return}if(c.kind==="hyperlink"){a.push(on(c));let u=x(p,c);for(let m of c.children)d(m,u);return}if(c.kind==="contentControl"){a.push(xa({...c,children:c.children.filter(m=>m.kind!=="contentControlContent")}));let u=x(p,c);for(let m of c.children){if(m.kind!=="contentControlContent")continue;let f=x(u,m);for(let y of m.children)d(y,f);}return}ze(c,a,p);};for(let c of e.children)d(c,i);let l=Oc(e);return {ordinal:t,path:n,paraId:l===null?null:l.toUpperCase(),text:s,paragraphProperties:yt(r),runProperties:o,genericStructure:a}}function cn(e){if(e.localName==="hdr"||e.localName==="ftr"||e.kind==="body")return e;for(let t of e.children)if(t.kind!=="textValue"&&(t.kind==="body"||t.localName==="hdr"||t.localName==="ftr"))return t;return e}function xt(e,t,n,r,o,s){if(s>ca)return;let a=0;for(let i of e.children){if(i.kind==="textValue"){i.value.trim()!==""&&o.push(`${t}/#text ${i.value}`);continue}let d=t===""?String(a):`${t}/${a}`;if(a+=1,i.kind==="paragraph"){n.push(i),r.push(d),o.push(`${d} p`);continue}let l=I(i);o.push(l.length>0?`${d} ${C(i)}(${l.join(",")})`:`${d} ${C(i)}`),xt(i,d,n,r,o,s+1);}}function Nt(e){let t=cn(e.root),n=[],r=[],o=[];xt(t,"",n,r,o,0);let s=n.map((a,i)=>ln(a,i,r[i]));return {partName:e.name,paragraphs:s,structure:o}}function dn(e){let t=[];for(let n of e){let r=Nt(n);r&&t.push(r);}return {stories:t}}function pn(e,t){let n=[],r=(s,a,i)=>{n.push({path:s,before:JSON.stringify(a)??"undefined",after:JSON.stringify(i)??"undefined"});};e.stories.length!==t.stories.length&&r("stories.length",e.stories.length,t.stories.length);let o=Math.min(e.stories.length,t.stories.length);for(let s=0;s<o;s+=1){let a=e.stories[s],i=t.stories[s],d=p=>`${a.partName}${p}`;a.paragraphs.length!==i.paragraphs.length&&r(d(".paragraphs.length"),a.paragraphs.length,i.paragraphs.length);let l=Math.min(a.paragraphs.length,i.paragraphs.length);for(let p=0;p<l;p+=1){let u=a.paragraphs[p],m=i.paragraphs[p];u.text!==m.text&&r(d(`.p[${p}].text`),u.text,m.text),u.path!==m.path&&r(d(`.p[${p}].path`),u.path,m.path),u.paraId!==m.paraId&&r(d(`.p[${p}].paraId`),u.paraId,m.paraId),JSON.stringify(u.paragraphProperties)!==JSON.stringify(m.paragraphProperties)&&r(d(`.p[${p}].paragraphProperties`),u.paragraphProperties,m.paragraphProperties),JSON.stringify(u.runProperties)!==JSON.stringify(m.runProperties)&&r(d(`.p[${p}].runProperties`),u.runProperties,m.runProperties),JSON.stringify(u.genericStructure)!==JSON.stringify(m.genericStructure)&&r(d(`.p[${p}].genericStructure`),u.genericStructure,m.genericStructure);}a.structure.length!==i.structure.length&&r(d(".structure.length"),a.structure.length,i.structure.length);let c=Math.min(a.structure.length,i.structure.length);for(let p=0;p<c;p+=1)a.structure[p]!==i.structure[p]&&r(d(`.structure[${p}]`),a.structure[p],i.structure[p]);}return n}var j="http://schemas.openxmlformats.org/wordprocessingml/2006/main",fn="http://schemas.openxmlformats.org/package/2006/relationships",Ot="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",_="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",yn="application/vnd.openxmlformats-package.relationships+xml",gn="http://schemas.openxmlformats.org/package/2006/content-types",Rt="/[Content_Types].xml",E="/word/numbering.xml",Ct=[{text:"\uF0B7",font:"Symbol"},{text:"o",font:"Courier New"},{text:"\uF0A7",font:"Wingdings"}],bt=["decimal","lowerLetter","lowerRoman"],Ye=9;function St(e,t){let n=720*(t+1),r='<w:start w:val="1"/>';if(e==="bullet"){let a=Ct[t%Ct.length];return `<w:lvl w:ilvl="${t}">${r}<w:numFmt w:val="bullet"/><w:lvlText w:val="${a.text}"/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="${n}" w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="${a.font}" w:hAnsi="${a.font}" w:hint="default"/></w:rPr></w:lvl>`}let o=bt[t%bt.length],s=o==="lowerRoman";return `<w:lvl w:ilvl="${t}">${r}<w:numFmt w:val="${o}"/><w:lvlText w:val="%${t+1}."/><w:lvlJc w:val="${s?"right":"left"}"/><w:pPr><w:ind w:left="${n}" w:hanging="${s?180:360}"/></w:pPr></w:lvl>`}function hn(e,t){let n=Array.from({length:Ye},(r,o)=>St(e,o)).join("");return `<w:abstractNum w:abstractNumId="${t}"><w:multiLevelType w:val="${e==="bullet"?"hybridMultilevel":"multilevel"}"/>${n}</w:abstractNum>`}function xn(){let e=Ba(`<w:numbering xmlns:w="${j}"></w:numbering>`,{name:E,contentType:_});return e.ok?e.part:null}var b=(e,t)=>{let n=[];for(let r of e.children)r.kind==="textValue"||r.localName!==t||r.namespaceUri===j&&n.push(r);return n},N=(e,t)=>e.attributes.find(n=>n.localName===t)?.value;function vt(e,t){let n=Ba(`<w:numbering xmlns:w="${j}">${e}</w:numbering>`,{name:E,contentType:_});if(!n.ok)return null;let r=[];for(let o of n.part.root.children)o.kind!=="textValue"&&r.push(o);if(r.length!==t.length)return null;for(let o=0;o<t.length;o+=1){let s=r[o],a=t[o];if(s.namespaceUri!==j||s.localName!==a.localName||a.attribute&&N(s,a.attribute.localName)!==a.attribute.value)return null}return r}var Et=["numPicBullet","abstractNum","num","numIdMacAtCleanup"];function Pt(e,t,n){let r=t.indexOf(n);if(r===-1)return e.length;let o=0;return e.forEach((s,a)=>{if(s.kind==="textValue")return;let i=t.indexOf(s.localName);i!==-1&&i<=r&&(o=a+1);}),o}function It(e,t){let n=0;for(let r of e){let o=N(r,t);!o||!/^\d{1,9}$/.test(o)||(n=Math.max(n,Number(o)));}return n+1}function Nn(e,t){let n=e.parts.get(E),r=n??xn();if(!r)return null;let o=r.root,s=b(o,"abstractNum"),a=b(o,"num"),i=t==="bullet"?"bullet":"decimal";for(let O of a){let $=N(O,"numId"),qe=b(O,"abstractNumId")[0],Qe=qe?N(qe,"val"):void 0;if(!$||!Qe)continue;let Ze=s.find(X=>N(X,"abstractNumId")===Qe);if(!Ze)continue;let et=b(Ze,"lvl").find(X=>N(X,"ilvl")==="0"||N(X,"ilvl")===void 0),tt=et?b(et,"numFmt")[0]:void 0;if(tt&&N(tt,"val")===i)return {pkg:e,numId:$}}let d=It(s,"abstractNumId"),l=It(a,"numId"),c=vt(hn(t,d)+`<w:num w:numId="${l}"><w:abstractNumId w:val="${d}"/></w:num>`,[{localName:"abstractNum",attribute:{localName:"abstractNumId",value:String(d)}},{localName:"num",attribute:{localName:"numId",value:String(l)}}]);if(!c)return null;let p=Da(r),[u,m]=c.map(O=>ne(O,p));if(!u||!m)return null;let f=Ia(r,o.id,Pt(o.children,Et,"abstractNum"),[u]);if(!f.ok)return null;let y=Ia(f.part,o.id,Pt(f.part.root.children,Et,"num"),[m]);if(!y.ok)return null;let g=Object.freeze({...e,parts:new Map([...e.parts,[E,y.part]])});if(!n){let O=bn(g);if(!O)return null;let $=kn(O);if(!$)return null;g=$;}return {pkg:g,numId:String(l)}}var On=["nsid","multiLevelType","tmpl","name","styleLink","numStyleLink","lvl"];function Tt(e){let t=N(e,"ilvl");return t===void 0||!/^\d{1,9}$/.test(t)?null:Number(t)}function Rn(e,t){let n=0;return e.forEach((r,o)=>{if(r.kind!=="textValue"){if(r.localName==="lvl"&&r.namespaceUri===j){(Tt(r)??0)<t&&(n=o+1);return}On.includes(r.localName)&&(n=o+1);}}),n}function Cn(e,t,n,r){if(!Number.isInteger(n)||n<0||n>=Ye||t.length===0||t.length>64)return null;let o=e.parts.get(E);if(!o)return null;let s=o.root,a=b(s,"num").find(f=>N(f,"numId")===t),i=a?b(a,"abstractNumId")[0]:void 0,d=i?N(i,"val"):void 0;if(!d)return null;let l=b(s,"abstractNum").find(f=>N(f,"abstractNumId")===d);if(!l||b(l,"numStyleLink").length>0)return null;let c=b(l,"lvl");if(c.some(f=>Tt(f)===n))return e;if(c.length>=Ye)return null;let p=vt(St(r,n),[{localName:"lvl",attribute:{localName:"ilvl",value:String(n)}}]);if(!p)return null;let u=Da(o),m=Ia(o,l.id,Rn(l.children,n),[ne(p[0],u)]);return m.ok?Object.freeze({...e,parts:new Map([...e.parts,[E,m.part]])}):null}function ne(e,t){return e.kind==="textValue"?{...e,id:t()}:{...e,id:t(),children:e.children.map(n=>ne(n,t))}}function bn(e){let t=e.mainDocumentPart,n=En(t),r=e.parts.get(n),o=Pn(e),s=Ba(`<Relationships xmlns="${fn}"><Relationship Id="${o}" Type="${Ot}" Target="numbering.xml"/></Relationships>`,{name:n,contentType:yn});if(!s.ok)return null;let a=e.relationships.get(t)??[],i={ownerPart:t,id:o,type:Ot,rawTarget:"numbering.xml",targetMode:"Internal",order:a.reduce((u,m)=>Math.max(u,m.order),-1)+1},d=new Map([...e.relationships,[t,[...a,i]]]);if(!r)return Object.freeze({...e,parts:new Map([...e.parts,[n,s.part]]),relationships:d});let l=Da(r),c=s.part.root.children[0];if(!c)return null;let p=Ia(r,r.root.id,r.root.children.length,[ne(c,l)]);return p.ok?Object.freeze({...e,parts:new Map([...e.parts,[n,p.part]]),relationships:d}):null}function En(e){let t=e.lastIndexOf("/");return `${e.slice(0,t)}/_rels/${e.slice(t+1)}.rels`}function Pn(e){let t=0;for(let n of e.relationships.values())for(let r of n){let o=/^rId(\d{1,9})$/.exec(r.id);o&&(t=Math.max(t,Number(o[1])));}for(let n of e.externalTargets){let r=/^rId(\d{1,9})$/.exec(n.id);r&&(t=Math.max(t,Number(r[1])));}return `rId${t+1}`}var In=`<Override PartName="${E}" ContentType="${_}"/>`;function kn(e){let t=e.contentTypes.overrides.get(p(E));if(t===_)return e;if(t!==void 0)return null;let n=e.partBytes.get(Rt);if(!n)return null;let r=strFromU8(n),o=kt(r);if(!o)return null;let s=r.lastIndexOf(`</${o.rootName}>`);if(s===-1)return null;let a=r.slice(0,s)+In+r.slice(s),i=kt(a);if(!i||i.rootName!==o.rootName)return null;let d=[...o.children,wt("Override",{PartName:E,ContentType:_})];return i.children.length!==d.length||i.children.some((l,c)=>l!==d[c])?null:Object.freeze({...e,partBytes:new Map([...e.partBytes,[Rt,strToU8(a)]]),contentTypes:Object.freeze({defaults:e.contentTypes.defaults,overrides:new Map([...e.contentTypes.overrides,[p(E),_]])})})}function kt(e){let t=da(e);if(!t.ok)return null;let n=t.nodes.filter(i=>i.type==="element");if(n.length!==1)return null;let r=n[0],o=r.name.indexOf(":"),s=o===-1?"":r.name.slice(0,o);if(r.name.slice(o+1)!=="Types"||r.attributes[s?`xmlns:${s}`:"xmlns"]!==gn)return null;let a=[];for(let i of r.children)i.type==="element"&&a.push(wt(i.name,i.attributes));return {rootName:r.name,children:a}}function wt(e,t){let n=Object.entries(t).map(([r,o])=>`${r}=${o}`).sort();return [e,...n].join("")}function re(e){return e!=null&&e.kind!=="textValue"}function Je(e,t){for(let n of e.children)if(n.kind!=="textValue"&&n.namespaceUri===ma&&n.localName===t)return n;return null}function oe(e,t){for(let n of e.attributes)if(n.namespaceUri===ma&&n.localName===t)return n.value}function A(e,t){let n=Je(e,t);if(!n)return false;let r=oe(n,"val");return r===void 0?true:r!=="0"&&r!=="false"&&r!=="off"}var _t=Object.freeze({trackRevisions:false,restrictedToTrackedChanges:false,doNotTrackMoves:false,doNotTrackFormatting:false});function Sn(e){if(!re(e))return _t;let t=Je(e,"documentProtection"),n=t===null?void 0:oe(t,"enforcement"),r=n!==void 0&&n!=="0"&&n!=="false"&&n!=="off";return {trackRevisions:A(e,"trackRevisions"),restrictedToTrackedChanges:r&&t!==null&&oe(t,"edit")==="trackedChanges",doNotTrackMoves:A(e,"doNotTrackMoves"),doNotTrackFormatting:A(e,"doNotTrackFormatting")}}var At=Object.freeze({doNotShadeFormData:false});function vn(e){return re(e)?{doNotShadeFormData:A(e,"doNotShadeFormData")}:At}function Tn(e,t){let n=e.parts.get(t.storyPartName);if(!n)return {ok:false,reason:`no story part named ${t.storyPartName}`};let r=[];for(let d of te$1(n.root)){let l=re$1(d.node).tag;if(l===void 0||l.length===0)continue;let c=t.decide(l);c!=="keep"&&r.push({nodeId:d.node.id,policy:c});}let o=n,s=0,a=0;for(let{nodeId:d,policy:l}of r){let c=Ga(o,d);if(!c)continue;if(l==="remove"){let g=Ka(o,d,{deferValidation:true});if(!g.ok)return {ok:false,reason:`a node could not be removed: ${$t(g)}`};o=g.part,a+=1;continue}let p=c.children.find(g=>g.id===d);if(!p)continue;let u=pe(p),m=u?u.children:[],f=c.children.flatMap(g=>g.id===d?m:[g]),y=Ha(o,c.id,f,{deferValidation:true});if(!y.ok)return {ok:false,reason:`a node could not be unwrapped: ${$t(y)}`};o=y.part,s+=1;}let i=o===n?e:Ab(e,o);if(!i.parts.has(t.storyPartName))return {ok:false,reason:"the story went missing during the export"};for(let d of t.namespaces)for(let l of _n(i,t.storyPartName,d)){let c=_if(i,l.itemId),p=cf(i,l.partName,c);if(p.pkg===i&&p.removed.length===0&&!wn(i,l.partName,c))return {ok:false,reason:`the payloads in ${d} could not be removed`};if(i=p.pkg,c.size>0)continue;let u=An(i,l);if(!u.ok)return {ok:false,reason:`the payload store for ${d} could not be removed`};i=u.pkg;}return {ok:true,pkg:i,unwrapped:s,removed:a}}function wn(e,t,n){return _e(e,t).every(r=>n.has(r.id))}function $t(e){return e.issues.map(t=>t.code).join(", ")||"the edit was refused"}function _n(e,t,n){return We$1(e,t).filter(r=>r.namespaceUri===n)}function An(e,t){let n=Gb(e,t.partName);if(!n.ok)return {pkg:e,ok:false};let r=Gb(n.pkg,t.propsPartName);return r.ok?{pkg:r.pkg,ok:true}:{pkg:e,ok:false}}var ie="http://purl.org/dc/elements/1.1/",Dt="http://schemas.openxmlformats.org/package/2006/metadata/core-properties",Mt="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties";var sp=Object.freeze({});function k(e,t,n){if(e.kind!=="textValue")for(let r of e.children){if(r.kind==="textValue"||r.namespaceUri!==t||r.localName!==n)continue;let o=r.children.find(a=>a.kind==="textValue");if(!o||o.kind!=="textValue")return;let s=o.value.trim();return s.length===0?void 0:s.length>4096?s.slice(0,4096):s}}function lp(e,t){let n={};if(e&&e.kind!=="textValue"){let r=k(e,ie,"title");r!==void 0&&(n.title=r);let o=k(e,ie,"creator");o!==void 0&&(n.creator=o);let s=k(e,ie,"subject");s!==void 0&&(n.subject=s);let a=k(e,ie,"description");a!==void 0&&(n.description=a);let i=k(e,Dt,"keywords");i!==void 0&&(n.keywords=i);let d=k(e,Dt,"lastModifiedBy");d!==void 0&&(n.lastModifiedBy=d);}if(t&&t.kind!=="textValue"){let r=k(t,Mt,"Company");r!==void 0&&(n.company=r);let o=k(t,Mt,"Manager");o!==void 0&&(n.manager=o);}return n}
|
|
1
|
+
import {u,v as v$1,H as H$1,x as x$1,C as C$1,B as B$1,A as A$1,Cc,Hc,Fa,Da,Ia,Ba,p,da,te as te$1,re as re$1,Ga,Ka,pe,Ha,Ab,if as _if,cf,_e,We as We$1,Gb,Sa,ca,Oc,ma,r,va,xa,_b,mc,Lb,Nb,wa,la,qa,pa}from'./chunk-R75OLPL6.js';import {strFromU8,strToU8}from'fflate';var Ft=["extension","capability","command","query","schema","dependencyKey","runtimePort","result","origin"],Lt=/^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+$/,Bt=/^@[a-z0-9.-]+\/[a-z0-9.-]+(?:#[a-z0-9]+(?:[/._-][a-z0-9]+)*)?$/;function ot(e){return Lt.test(e)||Bt.test(e)}function J(e,t){if(!ot(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 Ut=/^(\d+)\.(\d+)\.(\d+)$/;function S(e){let t=Ut.exec(e);if(!t)throw new Error(`invalid semantic version: ${JSON.stringify(e)}`);return {major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3])}}function q(e,t){return e.major!==t.major?e.major<t.major?-1:1:e.minor!==t.minor?e.minor<t.minor?-1:1:e.patch!==t.patch?e.patch<t.patch?-1:1:0}function Q(e,t){let n=S(e),r=t.trim();if(r==="*")return true;if(r.startsWith("^")){let o=S(r.slice(1));return q(n,o)<0?false:o.major>0?n.major===o.major:o.minor>0?n.major===0&&n.minor===o.minor:n.major===0&&n.minor===0}if(r.includes(" ")){let o=r.split(/\s+/);if(o.length!==2)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let s=true;for(let a of o){let i=a.startsWith(">=")?">=":a.startsWith("<")?"<":null;if(!i)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let d=S(a.slice(i.length)),l=q(n,d);i===">="?s=s&&l>=0:s=s&&l<0;}return s}return q(n,S(r))===0}var h=class extends Error{constructor(n,r,o=[]){super(r);this.code=n;this.responsible=o;this.name="RegistryError";}code;responsible},$e=(e,t)=>`${e}:${t}`;function Ht(e,t={}){let n=new Map;for(let l of e){if(J(l.id,"extension"),it(l.version,l.id),n.has(l.id))throw new h("duplicate-extension",`duplicate extension id ${l.id}`,[l.id]);n.set(l.id,l);for(let c of l.contributions)J(c.id,c.kind),it(c.version,`${l.id} \u2192 ${c.id}`),c.replaces&&Xt(c.replaces.targetRange,`${l.id} \u2192 replaces ${c.replaces.targetId}`);}for(let l of e){for(let c of l.dependencies??[])if(!n.has(c))throw new h("missing-dependency",`${l.id} requires missing extension ${c}`,[l.id,c]);for(let c of l.conflicts??[])if(n.has(c)){let p=[l.id,c].sort();throw new h("conflict",`extensions ${p[0]} and ${p[1]} conflict`,p)}}jt(n);let r=new Set(t.availablePorts??[]);for(let l of e)for(let c of l.contributions)c.kind==="runtimePort"&&r.add(c.id);for(let l of e)for(let c of l.requiredPorts??[])if(!r.has(c))throw new h("missing-port",`${l.id} requires unavailable port ${c}`,[l.id,c]);let o=new Map,s=new Map,a=new Map;for(let l of e)for(let c of l.contributions){let p=$e(c.kind,c.id);if(c.replaces){let u=$e(c.kind,c.replaces.targetId),m=a.get(u)??[];m.push({ext:l.id,c}),a.set(u,m);continue}if(s.has(p)){let u=[o.get(p),l.id].sort();throw new h("id-collision",`${c.kind} id ${c.id} registered by both ${u[0]} and ${u[1]}`,u)}s.set(p,c),o.set(p,l.id);}let i=new Map(s);for(let[l,c]of a){let p=s.get(l);if(!p){let f=c[0];throw new h("replacement-target-missing",`${f.ext} replaces missing target ${f.c.replaces.targetId}`,[f.ext,f.c.replaces.targetId])}let u=p.replaceable??{kind:"none"};for(let{ext:f,c:y}of c){if(!Q(p.version,y.replaces.targetRange))throw new h("replacement-version-mismatch",`${f} replaces ${y.replaces.targetId}@${p.version} outside range ${y.replaces.targetRange}`,[f,y.replaces.targetId]);if(u.kind==="none")throw new h("unauthorized-replacement",`${y.replaces.targetId} does not authorize replacement (attempted by ${f})`,[f,y.replaces.targetId])}let m=Vt(p,c);i.set(l,m);}return {extensions:n,contributions:i,get:(l,c)=>i.get($e(l,c))}}function Vt(e,t){let n=e.replaceable??{kind:"none"};if(t.length===1)return t[0].c;if(n.kind==="priority"){let o=[...t].sort((i,d)=>(d.c.replaces.priority??0)-(i.c.replaces.priority??0)),s=o[0].c.replaces.priority??0,a=o.filter(i=>(i.c.replaces.priority??0)===s);if(a.length>1){let i=a.map(d=>d.ext).sort();throw new h("ambiguous-replacement",`multiple replacers of ${e.id} share top priority ${s}: ${i.join(", ")}`,i)}return o[0].c}let r=t.map(o=>o.ext).sort();throw new h("ambiguous-replacement",`multiple replacers of ${e.id}: ${r.join(", ")}`,r)}function jt(e){let o=new Map,s=[],a=i=>{o.set(i,1),s.push(i);let d=[...e.get(i)?.dependencies??[]].sort();for(let l of d){let c=o.get(l)??0;if(c===1){let p=s.indexOf(l),u=[...s.slice(p),l];throw new h("dependency-cycle",`dependency cycle: ${u.join(" -> ")}`,u)}c===0&&a(l);}s.pop(),o.set(i,2);};for(let i of [...e.keys()].sort())(o.get(i)??0)===0&&a(i);}function it(e,t){try{S(e);}catch{throw new h("invalid-version",`invalid version ${JSON.stringify(e)} in ${t}`,[t])}}function Xt(e,t){try{Q("0.0.0",e);}catch{throw new h("invalid-version",`invalid version range ${JSON.stringify(e)} in ${t}`,[t])}}var v=class extends Error{constructor(t){super(t),this.name="BudgetError";}},B=class e{constructor(t,n){this.label=t;this.capacity=n;this.used=new H$1(`${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 v(`${this.label}: cannot release with ${this.children.size} child budget(s) outstanding`);if(this.activeReservations>0)throw new v(`${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 v(`${this.label}: ${t.length} cleanup error(s); first: ${String(t[0])}`)}assertLive(){if(this.disposed)throw new v(`${this.label}: budget already released`)}};var Z=class extends Error{constructor(n,r){super(r?`cancelled: ${r}`:"cancelled");this.derivedOnly=n;this.name="CancellationError";}derivedOnly},U=class{_cancelled=false;_phase="pre-publication";_reason;cancel(t){this._cancelled=true,t!==void 0&&(this._reason=t);}markPublished(){this._phase="post-publication";}get isCancelled(){return this._cancelled}get phase(){return this._phase}get isPublished(){return this._phase==="post-publication"}get derivedOnly(){return this._cancelled&&this._phase==="post-publication"}get token(){let t=this;return {get isCancelled(){return t._cancelled},get phase(){return t._phase},get derivedOnly(){return t.derivedOnly},checkpoint(){if(t._cancelled)throw new Z(t.derivedOnly,t._reason)}}}};var ee=class extends Error{constructor(n){super(`runtime port not available: ${n}`);this.portId=n;this.name="PortResolutionError";}portId},De=class{ports=new Map;provide(t,n){return this.ports.set(t,n),this}has(t){return this.ports.has(t)}resolve(t){if(!this.ports.has(t))throw new ee(t);return this.ports.get(t)}missing(t){return t.filter(n=>!this.ports.has(n))}availablePorts(){return [...this.ports.keys()]}clock(){return this.resolve(x$1.clock)}identity(){return this.resolve(x$1.identity)}},Me=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}},Fe=class{constructor(t="id"){this.prefix=t;}prefix;n=0;newId(){return this.n+=1,`${this.prefix}-${this.n}`}};function Kt(e){let t=C$1(e.limits),n=Object.freeze({...e.config??{}}),r=e.capacity??t.maxDecompressedBytes,o=e.id??"op",s={id:o,limits:t,config:n,ports:e.ports,budget:new B(`op:${o}`,r),cancellation:new U};return Object.freeze(s)}function Gt(e){e.budget.dispose();}var Be=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"}}),at=Object.keys(Be);function zt(e,t){return new H$1(`${Be[t].phase}:${t}`,e[t])}var Le=class{counter;current=0;peak=0;constructor(t){this.counter=new H$1("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 Wt(){for(let e of at){let t=B$1[e],n=A$1[e];if(!Number.isFinite(t)||t<=0)throw new Error(`default ${e} must be finite > 0`);if(!Number.isFinite(n)||n<=0)throw new Error(`ceiling ${e} must be finite > 0`);if(t>n)throw new Error(`default ${e} exceeds ceiling`)}}function H(e,t=new Set){let n=new WeakSet,r=o=>{if(o===null)return "null";let s=typeof o;if(s==="boolean")return o?"true":"false";if(s==="number"){let a=o;if(!Number.isFinite(a))throw new Error(`non-finite number is not comparable: ${a}`);return Object.is(a,-0)?"0":String(a)}if(s==="string")return JSON.stringify(o);if(s==="bigint")return `${o.toString()}n`;if(Array.isArray(o))return `[${o.map(r).join(",")}]`;if(s==="object"){let a=o;if(n.has(a))throw new Error("cannot canonicalize a cyclic structure");n.add(a);let d=Object.keys(a).filter(l=>!t.has(l)).sort().map(l=>`${JSON.stringify(l)}:${r(a[l])}`).join(",");return n.delete(a),`{${d}}`}throw new Error(`unsupported value type in comparator input: ${s}`)};return r(e)}function Ue(e,t){let n=H(e,t),r=0xcbf29ce484222325n,o=0x100000001b3n,s=0xffffffffffffffffn;for(let a=0;a<n.length;a++)r^=BigInt(n.charCodeAt(a)),r=r*o&s;return r.toString(16).padStart(16,"0")}var R="dev.docx-editor.core.comparator",He={authoredState:{id:`${R}.authored-state`,mode:"canonical-exact",ephemera:["revision","provenance","producedAt","commitId"],note:"canonical normalized authored records; ephemera excluded"},anchor:{id:`${R}.anchor`,mode:"exact",ephemera:[],note:"internal anchor identity/affinity compares exactly"},yjsStateVector:{id:`${R}.yjs-state-vector`,mode:"sync-optimization-only",ephemera:[],note:"exchange optimization only; never proves update or delete-set coverage"},shapedRun:{id:`${R}.shaped-run`,mode:"exact",ephemera:[],note:"glyph ids, clusters, and fixed-point advances compare exactly"},paginationFingerprint:{id:`${R}.pagination-fingerprint`,mode:"exact",ephemera:[],note:"page/column boundaries, break causes, fixed-point geometry compare exactly"},semanticTree:{id:`${R}.semantic-tree`,mode:"exact",ephemera:[],note:"reading order, roles, headings, alt text compare exactly"},hitTest:{id:`${R}.hit-test`,mode:"exact",ephemera:[],note:"resolved hit target and cluster affinity compare exactly"},pdfSemantics:{id:`${R}.pdf-semantics`,mode:"canonical-exact",ephemera:["objectNumber","producer","creationDate","modDate","subsetTag"],note:"canonical semantic PDF objects; container ephemera excluded"},rasterCheckpoint:{id:`${R}.raster-checkpoint`,mode:"tolerance",ephemera:[],note:"documented unavoidable raster comparison; explicit tolerance only"},benchmarkEvidence:{id:`${R}.benchmark-evidence`,mode:"sync-optimization-only",ephemera:[],note:"diagnostic evidence, not an equivalence basis"}};function Ve(e,t,n,r={}){let o=He[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:st(t,n,r.epsilon)}}case "exact":case "canonical-exact":{let s=o.mode==="canonical-exact"?new Set(o.ephemera):new Set,a=H(t,s),i=H(n,s);return a===i?{equal:true}:{equal:false,left:a,right:i}}}}function je(e,t){let n=He[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 Ue(t,r)}function st(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)=>st(r,t[o],n)):false}var ct=new Set([...u,...v$1]),lt=/^[0-9a-f]{16}$/,Yt=/^[0-9a-f]*$/;function Xe(e){let t=[],n=o=>t.push(o);e.formatVersion!==1&&n(`unsupported formatVersion ${e.formatVersion}`),e.documentId||n("documentId is required"),e.source.kind==="docx"&&!/^[0-9a-f]{64}$/.test(e.source.sha256)&&n("docx source requires a 64-hex sha256");let r=-1;e.steps.forEach((o,s)=>{let a=`step[${s}]`;ct.has(o.origin)||n(`${a}: unknown origin ${o.origin}`),(!Number.isInteger(o.baseRevision)||o.baseRevision<0)&&n(`${a}: baseRevision must be a non-negative integer`),o.baseRevision<r&&n(`${a}: baseRevision regressed below ${r}`);let i=o.expect;i.outcome==="applied"?(i.committedRevision===void 0?n(`${a}: applied step needs committedRevision`):i.committedRevision<=o.baseRevision?n(`${a}: committedRevision ${i.committedRevision} must exceed baseRevision ${o.baseRevision}`):r=i.committedRevision,i.modelChange&&Jt(i.modelChange,a,n)):(i.committedRevision!==void 0&&n(`${a}: ${i.outcome} step must not commit a revision`),i.authoredStateHash!==void 0&&n(`${a}: ${i.outcome} step must not change authored state`)),i.authoredStateHash!==void 0&&!lt.test(i.authoredStateHash)&&n(`${a}: authoredStateHash must be 16-hex`),i.outputHash!==void 0&&!lt.test(i.outputHash)&&n(`${a}: outputHash must be 16-hex`);});for(let o of [...e.snapshots??[],...e.updates??[]])o.documentId!==e.documentId&&n(`envelope documentId ${o.documentId} != ${e.documentId}`),Yt.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 Jt(e,t,n){ct.has(e.origin)||n(`${t}: modelChange origin ${e.origin} unknown`),e.toRevision<=e.fromRevision&&n(`${t}: modelChange revision must advance`);}function qt(e,t){let n=Xe(e);if(!n.valid)return {ok:false,mismatches:n.errors};let r=[];return t.init(e),e.steps.forEach((o,s)=>{let a=`step[${s}]`,i=t.applyStep(o),d=o.expect;if(i.outcome!==d.outcome){r.push(`${a}: outcome ${i.outcome} != expected ${d.outcome}`);return}if(d.outcome==="applied"&&(i.committedRevision!==d.committedRevision&&r.push(`${a}: revision ${i.committedRevision} != expected ${d.committedRevision}`),d.authoredStateHash!==void 0))if(i.authoredState===void 0)r.push(`${a}: store returned no authored state to hash`);else {Ve("authoredState",i.authoredState,i.authoredState).equal||r.push(`${a}: authored state is not self-consistent`);let c=dt(i.authoredState);c!==d.authoredStateHash&&r.push(`${a}: authoredStateHash ${c} != expected ${d.authoredStateHash}`);}}),{ok:r.length===0,mismatches:r}}function dt(e){return je("authoredState",e)}var Qt=new Map([["embedRegular","regular"],["embedBold","bold"],["embedItalic","italic"],["embedBoldItalic","boldItalic"]]),Zt=32;function mt(e,t){let n=t.replace(/[^0-9a-fA-F]/g,"");if(n.length!==32)return null;let r=new Uint8Array(16);for(let a=0;a<16;a+=1){let i=Number.parseInt(n.slice(a*2,a*2+2),16);if(Number.isNaN(i))return null;r[15-a]=i;}let o=new Uint8Array(e),s=Math.min(Zt,o.length);for(let a=0;a<s;a+=1)o[a]=o[a]^r[a%16];return o}var Ke=(e,t)=>{if(!(e.kind==="textValue"||!("attributes"in e))){for(let n of e.attributes??[])if(n.localName===t)return n.value}},pt=e=>e.kind==="textValue"?[]:e.children??[],ut=e=>e.kind==="textValue"||!("localName"in e)?"":e.localName;function en(e,t,n){for(let r$1 of e.relationships.get(t)??[]){if(r$1.id!==n)continue;if(r$1.targetMode==="External")return null;let o=r(t,r$1.rawTarget);return o.ok?o.partName:null}return null}function tn(e,t,n={}){if(!t)return [];let r=n.maxFontBytes??16*1024*1024,o=n.maxFonts??64,s=[],a=new Map,i=d=>{if(!(s.length>=o)){if(ut(d)==="font"){let l=Ke(d,"name");if(l&&l.length<=128)for(let c of pt(d)){if(s.length>=o)return;let p=Qt.get(ut(c));if(!p)continue;let u=Ke(c,"id"),m=Ke(c,"fontKey");if(!u||!m)continue;let f=en(e,t.name,u);if(!f)continue;let y=e.partBytes.get(f);if(!y||y.length===0||y.length>r)continue;let g=a.get(f);if(g){s.push({family:l,style:p,bytes:g,partName:f});continue}let O=mt(y,m);O&&(a.set(f,O),s.push({family:l,style:p,bytes:O,partName:f}));}}for(let l of pt(d))i(l);}};return i(t.root),s}function ft(e){if(e.kind!=="textValue")for(let t of e.children){if(t.kind==="textValue")continue;if(t.kind==="hyperlink"){let r=Sa(t);if(r!==void 0&&r.length>0)return r}let n=ft(t);if(n!==void 0)return n}}function nn(e){let t="",n=false,r=o=>{if(!(n||o.kind==="textValue")){if(o.kind==="tab"||o.localName==="ptab"||o.localName==="tab"){n=true;return}if(o.kind==="text"||o.localName==="t"){for(let s of o.children)s.kind==="textValue"&&(t+=s.value);return}for(let s of o.children)r(s);}};return r(e),Hc(t)}function rn(e,t,n,r){let o=n.filter(d=>{if(r.has(d.blockId))return false;let l=d.level+1;return l>=t.instruction.outlineStart&&l<=t.instruction.outlineEnd}),s=new Set(o.map(d=>d.blockId)),a=Cc(e),i=new Map;for(let d of o){let l=Hc(d.text),c=i.get(l);c?c.push(d.blockId):i.set(l,[d.blockId]);}return t.resultParagraphIds.map(d=>{let l=Fa(e,d);if(!l||l.kind==="textValue")return null;let c=ft(l),p=c===void 0?void 0:a.get(c);if(p&&s.has(p.paragraphId)){let f=i.get(Hc(o.find(g=>g.blockId===p.paragraphId)?.text??"")),y=f?.indexOf(p.paragraphId)??-1;return f&&y>=0&&f.splice(y,1),p.paragraphId}let u=nn(l);if(u.length===0)return null;let m=i.get(u);return !m||m.length===0?null:m.shift()??null})}function C(e){return e.namespaceUri===ma?e.localName:`{${e.namespaceUri}}${e.localName}`}function I(e){let t=[];for(let n of e.attributes)t.push(n.namespaceUri===""||n.namespaceUri===ma?`${n.localName}=${n.value}`:`{${n.namespaceUri}}${n.localName}=${n.value}`);return t.sort(),t}function gt(e,t){let n=I(e),r=n.length>0?`${C(e)}(${n.join(",")})`:C(e);if(t>=ca)return r;let o=[];for(let s of e.children){if(s.kind==="textValue"){s.value!==""&&o.push(`#${s.value}`);continue}o.push(gt(s,t+1));}return o.sort(),o.length>0?`${r}[${o.join(",")}]`:r}function yt(e){if(!e)return [];let t=[];for(let n of e.children)n.namespaceUri===ma&&t.push(gt(n,1));return t.sort(),t}function Ge(e){if(e.kind==="textValue")return e.value;if(e.kind==="tab")return " ";if(e.kind==="hardBreak")return _b(e);if(e.kind==="drawing")return mc();if(e.kind==="runProperties"||e.kind==="paragraphProperties"||e.kind==="generic")return "";if(e.kind==="hyperlink"||Lb(e)){let n="",r=e.kind==="hyperlink"?e.children:Nb(e)??[];for(let o of r)n+=Ge(o);return n}let t="";for(let n of e.children)t+=Ge(n);return t}function x(e,t){let n=new Map(e);for(let r of t.namespaceBindings)n.set(r.prefix,r.namespaceUri);return n}function V(e,t){try{return wa(e,t)}catch(n){if(n instanceof qa&&n.reason==="undeclared-prefix")return `generic-refusal:undeclared-prefix:{${e.namespaceUri}}${e.localName}`;throw n}}function ze(e,t,n=va){if(e.kind==="textValue")return;if(e.kind==="runProperties"||e.kind==="paragraphProperties"){let o=x(n,e),s=[];for(let a of e.children)a.namespaceUri!==ma&&s.push(V(a,o));s.sort(),t.push(...s);return}if(e.kind==="generic"){t.push(V(e,n));return}if(Lb(e)){t.push(xa(e));return}if(e.kind==="bookmarkStart"||e.kind==="bookmarkEnd"){t.push(wa(e,n));return}if(e.kind==="drawing"){t.push(ht(e));return}if(la(e.kind))return;let r=x(n,e);for(let o of e.children)ze(o,t,r);}function on(e){return `hyperlink(${e.attributes.map(n=>`${n.namespaceUri}|${n.localName}=${n.value}`).sort().join(",")})`}function an(e){for(let t of e.children)if(t.kind==="pictureBlipFill")for(let n of t.children){if(n.kind!=="pictureBlip")continue;let r=n.attributes.find(s=>s.localName==="embed"&&s.namespaceUri===pa)?.value,o=n.attributes.find(s=>s.localName==="link"&&s.namespaceUri===pa)?.value;if(r!==void 0)return `embed=${r}`;if(o!==void 0)return `link=${o}`}}function te(e,t,n){if(e.kind==="textValue")return `#${e.value}`;if(t>=ca)return C(e);let r=x(n,e);if(e.kind==="generic")return V(e,r);let o=I(e),s=o.length>0?`${C(e)}(${o.join(",")})`:C(e),a=[];for(let i of e.children)i.kind!=="textValue"&&a.push(te(i,t+1,r));return a.sort(),a.length>0?`${s}[${a.join(",")}]`:s}function sn(e,t,n){let r=x(n,e),o=[];for(let s of e.children)if(s.kind!=="textValue"){if(s.kind==="pictureBlipFill"){let a=s.children,i=a.find(l=>l.kind==="pictureBlip"),d=a.filter(l=>l.kind!=="pictureBlip").map(l=>te(l,t+1,r));if(d.sort(),i&&i.kind==="pictureBlip"){let l=I(i),c=l.length>0?`pictureBlip(${l.join(",")})`:"pictureBlip";o.push(d.length>0?`${c}[${d.join(",")}]`:c);}else for(let l of a)o.push(te(l,t+1,r));continue}o.push(te(s,t+1,r));}return o.sort(),o}function We(e,t,n){if(e.kind==="textValue")return `#${e.value}`;if(t>=ca)return C(e);let r=x(n,e);if(e.kind==="drawingDocPr"){let i=I(e);return i.length>0?`docPr(${i.join(",")})`:"docPr"}if(e.kind==="picture"){let i=an(e),d=sn(e,t+1,r),l=i===void 0?"picture":`picture(${i})`;return d.length>0?`${l}[${d.join(",")}]`:l}let o=I(e),s=o.length>0?`${C(e)}(${o.join(",")})`:C(e),a=[];for(let i of e.children){if(i.kind==="picture"){a.push(We(i,t+1,r));continue}if(i.kind==="generic"){a.push(V(i,r));continue}i.kind!=="textValue"&&a.push(We(i,t+1,r));}return a.length>0?`${s}[${a.join(",")}]`:s}function ht(e){let t=x(va,e),n=e.children.find(i=>i.kind==="inlineDrawing"||i.kind==="anchoredDrawing");if(!n||n.kind==="textValue")return `drawing(${I(e).join(",")})`;let r=x(t,n),o=I(n),s=o.length>0?`${n.kind}(${o.join(",")})`:n.kind,a=[];for(let i of n.children){if(i.kind==="generic"){a.push(V(i,r));continue}i.kind!=="textValue"&&a.push(We(i,1,r));}return a.length>0?`drawing[${s};${a.join(";")}]`:`drawing[${s}]`}function ln(e,t,n){let r=e.children.find(c=>c.kind==="paragraphProperties"),o=[],s="",a=[],i=x(va,e),d=(c,p)=>{if(c.kind==="run"){let u=x(p,c),m=c.children.find(f=>f.kind==="runProperties");o.push(yt(m)),s+=Ge(c);for(let f of c.children)ze(f,a,u);return}if(c.kind==="drawing"){a.push(ht(c));return}if(c.kind==="hyperlink"){a.push(on(c));let u=x(p,c);for(let m of c.children)d(m,u);return}if(c.kind==="contentControl"){a.push(xa({...c,children:c.children.filter(m=>m.kind!=="contentControlContent")}));let u=x(p,c);for(let m of c.children){if(m.kind!=="contentControlContent")continue;let f=x(u,m);for(let y of m.children)d(y,f);}return}ze(c,a,p);};for(let c of e.children)d(c,i);let l=Oc(e);return {ordinal:t,path:n,paraId:l===null?null:l.toUpperCase(),text:s,paragraphProperties:yt(r),runProperties:o,genericStructure:a}}function cn(e){if(e.localName==="hdr"||e.localName==="ftr"||e.kind==="body")return e;for(let t of e.children)if(t.kind!=="textValue"&&(t.kind==="body"||t.localName==="hdr"||t.localName==="ftr"))return t;return e}function xt(e,t,n,r,o,s){if(s>ca)return;let a=0;for(let i of e.children){if(i.kind==="textValue"){i.value.trim()!==""&&o.push(`${t}/#text ${i.value}`);continue}let d=t===""?String(a):`${t}/${a}`;if(a+=1,i.kind==="paragraph"){n.push(i),r.push(d),o.push(`${d} p`);continue}let l=I(i);o.push(l.length>0?`${d} ${C(i)}(${l.join(",")})`:`${d} ${C(i)}`),xt(i,d,n,r,o,s+1);}}function Nt(e){let t=cn(e.root),n=[],r=[],o=[];xt(t,"",n,r,o,0);let s=n.map((a,i)=>ln(a,i,r[i]));return {partName:e.name,paragraphs:s,structure:o}}function dn(e){let t=[];for(let n of e){let r=Nt(n);r&&t.push(r);}return {stories:t}}function pn(e,t){let n=[],r=(s,a,i)=>{n.push({path:s,before:JSON.stringify(a)??"undefined",after:JSON.stringify(i)??"undefined"});};e.stories.length!==t.stories.length&&r("stories.length",e.stories.length,t.stories.length);let o=Math.min(e.stories.length,t.stories.length);for(let s=0;s<o;s+=1){let a=e.stories[s],i=t.stories[s],d=p=>`${a.partName}${p}`;a.paragraphs.length!==i.paragraphs.length&&r(d(".paragraphs.length"),a.paragraphs.length,i.paragraphs.length);let l=Math.min(a.paragraphs.length,i.paragraphs.length);for(let p=0;p<l;p+=1){let u=a.paragraphs[p],m=i.paragraphs[p];u.text!==m.text&&r(d(`.p[${p}].text`),u.text,m.text),u.path!==m.path&&r(d(`.p[${p}].path`),u.path,m.path),u.paraId!==m.paraId&&r(d(`.p[${p}].paraId`),u.paraId,m.paraId),JSON.stringify(u.paragraphProperties)!==JSON.stringify(m.paragraphProperties)&&r(d(`.p[${p}].paragraphProperties`),u.paragraphProperties,m.paragraphProperties),JSON.stringify(u.runProperties)!==JSON.stringify(m.runProperties)&&r(d(`.p[${p}].runProperties`),u.runProperties,m.runProperties),JSON.stringify(u.genericStructure)!==JSON.stringify(m.genericStructure)&&r(d(`.p[${p}].genericStructure`),u.genericStructure,m.genericStructure);}a.structure.length!==i.structure.length&&r(d(".structure.length"),a.structure.length,i.structure.length);let c=Math.min(a.structure.length,i.structure.length);for(let p=0;p<c;p+=1)a.structure[p]!==i.structure[p]&&r(d(`.structure[${p}]`),a.structure[p],i.structure[p]);}return n}var j="http://schemas.openxmlformats.org/wordprocessingml/2006/main",fn="http://schemas.openxmlformats.org/package/2006/relationships",Ot="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",_="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",yn="application/vnd.openxmlformats-package.relationships+xml",gn="http://schemas.openxmlformats.org/package/2006/content-types",Rt="/[Content_Types].xml",E="/word/numbering.xml",Ct=[{text:"\uF0B7",font:"Symbol"},{text:"o",font:"Courier New"},{text:"\uF0A7",font:"Wingdings"}],bt=["decimal","lowerLetter","lowerRoman"],Ye=9;function St(e,t){let n=720*(t+1),r='<w:start w:val="1"/>';if(e==="bullet"){let a=Ct[t%Ct.length];return `<w:lvl w:ilvl="${t}">${r}<w:numFmt w:val="bullet"/><w:lvlText w:val="${a.text}"/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="${n}" w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="${a.font}" w:hAnsi="${a.font}" w:hint="default"/></w:rPr></w:lvl>`}let o=bt[t%bt.length],s=o==="lowerRoman";return `<w:lvl w:ilvl="${t}">${r}<w:numFmt w:val="${o}"/><w:lvlText w:val="%${t+1}."/><w:lvlJc w:val="${s?"right":"left"}"/><w:pPr><w:ind w:left="${n}" w:hanging="${s?180:360}"/></w:pPr></w:lvl>`}function hn(e,t){let n=Array.from({length:Ye},(r,o)=>St(e,o)).join("");return `<w:abstractNum w:abstractNumId="${t}"><w:multiLevelType w:val="${e==="bullet"?"hybridMultilevel":"multilevel"}"/>${n}</w:abstractNum>`}function xn(){let e=Ba(`<w:numbering xmlns:w="${j}"></w:numbering>`,{name:E,contentType:_});return e.ok?e.part:null}var b=(e,t)=>{let n=[];for(let r of e.children)r.kind==="textValue"||r.localName!==t||r.namespaceUri===j&&n.push(r);return n},N=(e,t)=>e.attributes.find(n=>n.localName===t)?.value;function vt(e,t){let n=Ba(`<w:numbering xmlns:w="${j}">${e}</w:numbering>`,{name:E,contentType:_});if(!n.ok)return null;let r=[];for(let o of n.part.root.children)o.kind!=="textValue"&&r.push(o);if(r.length!==t.length)return null;for(let o=0;o<t.length;o+=1){let s=r[o],a=t[o];if(s.namespaceUri!==j||s.localName!==a.localName||a.attribute&&N(s,a.attribute.localName)!==a.attribute.value)return null}return r}var Et=["numPicBullet","abstractNum","num","numIdMacAtCleanup"];function Pt(e,t,n){let r=t.indexOf(n);if(r===-1)return e.length;let o=0;return e.forEach((s,a)=>{if(s.kind==="textValue")return;let i=t.indexOf(s.localName);i!==-1&&i<=r&&(o=a+1);}),o}function It(e,t){let n=0;for(let r of e){let o=N(r,t);!o||!/^\d{1,9}$/.test(o)||(n=Math.max(n,Number(o)));}return n+1}function Nn(e,t){let n=e.parts.get(E),r=n??xn();if(!r)return null;let o=r.root,s=b(o,"abstractNum"),a=b(o,"num"),i=t==="bullet"?"bullet":"decimal";for(let O of a){let $=N(O,"numId"),qe=b(O,"abstractNumId")[0],Qe=qe?N(qe,"val"):void 0;if(!$||!Qe)continue;let Ze=s.find(X=>N(X,"abstractNumId")===Qe);if(!Ze)continue;let et=b(Ze,"lvl").find(X=>N(X,"ilvl")==="0"||N(X,"ilvl")===void 0),tt=et?b(et,"numFmt")[0]:void 0;if(tt&&N(tt,"val")===i)return {pkg:e,numId:$}}let d=It(s,"abstractNumId"),l=It(a,"numId"),c=vt(hn(t,d)+`<w:num w:numId="${l}"><w:abstractNumId w:val="${d}"/></w:num>`,[{localName:"abstractNum",attribute:{localName:"abstractNumId",value:String(d)}},{localName:"num",attribute:{localName:"numId",value:String(l)}}]);if(!c)return null;let p=Da(r),[u,m]=c.map(O=>ne(O,p));if(!u||!m)return null;let f=Ia(r,o.id,Pt(o.children,Et,"abstractNum"),[u]);if(!f.ok)return null;let y=Ia(f.part,o.id,Pt(f.part.root.children,Et,"num"),[m]);if(!y.ok)return null;let g=Object.freeze({...e,parts:new Map([...e.parts,[E,y.part]])});if(!n){let O=bn(g);if(!O)return null;let $=kn(O);if(!$)return null;g=$;}return {pkg:g,numId:String(l)}}var On=["nsid","multiLevelType","tmpl","name","styleLink","numStyleLink","lvl"];function Tt(e){let t=N(e,"ilvl");return t===void 0||!/^\d{1,9}$/.test(t)?null:Number(t)}function Rn(e,t){let n=0;return e.forEach((r,o)=>{if(r.kind!=="textValue"){if(r.localName==="lvl"&&r.namespaceUri===j){(Tt(r)??0)<t&&(n=o+1);return}On.includes(r.localName)&&(n=o+1);}}),n}function Cn(e,t,n,r){if(!Number.isInteger(n)||n<0||n>=Ye||t.length===0||t.length>64)return null;let o=e.parts.get(E);if(!o)return null;let s=o.root,a=b(s,"num").find(f=>N(f,"numId")===t),i=a?b(a,"abstractNumId")[0]:void 0,d=i?N(i,"val"):void 0;if(!d)return null;let l=b(s,"abstractNum").find(f=>N(f,"abstractNumId")===d);if(!l||b(l,"numStyleLink").length>0)return null;let c=b(l,"lvl");if(c.some(f=>Tt(f)===n))return e;if(c.length>=Ye)return null;let p=vt(St(r,n),[{localName:"lvl",attribute:{localName:"ilvl",value:String(n)}}]);if(!p)return null;let u=Da(o),m=Ia(o,l.id,Rn(l.children,n),[ne(p[0],u)]);return m.ok?Object.freeze({...e,parts:new Map([...e.parts,[E,m.part]])}):null}function ne(e,t){return e.kind==="textValue"?{...e,id:t()}:{...e,id:t(),children:e.children.map(n=>ne(n,t))}}function bn(e){let t=e.mainDocumentPart,n=En(t),r=e.parts.get(n),o=Pn(e),s=Ba(`<Relationships xmlns="${fn}"><Relationship Id="${o}" Type="${Ot}" Target="numbering.xml"/></Relationships>`,{name:n,contentType:yn});if(!s.ok)return null;let a=e.relationships.get(t)??[],i={ownerPart:t,id:o,type:Ot,rawTarget:"numbering.xml",targetMode:"Internal",order:a.reduce((u,m)=>Math.max(u,m.order),-1)+1},d=new Map([...e.relationships,[t,[...a,i]]]);if(!r)return Object.freeze({...e,parts:new Map([...e.parts,[n,s.part]]),relationships:d});let l=Da(r),c=s.part.root.children[0];if(!c)return null;let p=Ia(r,r.root.id,r.root.children.length,[ne(c,l)]);return p.ok?Object.freeze({...e,parts:new Map([...e.parts,[n,p.part]]),relationships:d}):null}function En(e){let t=e.lastIndexOf("/");return `${e.slice(0,t)}/_rels/${e.slice(t+1)}.rels`}function Pn(e){let t=0;for(let n of e.relationships.values())for(let r of n){let o=/^rId(\d{1,9})$/.exec(r.id);o&&(t=Math.max(t,Number(o[1])));}for(let n of e.externalTargets){let r=/^rId(\d{1,9})$/.exec(n.id);r&&(t=Math.max(t,Number(r[1])));}return `rId${t+1}`}var In=`<Override PartName="${E}" ContentType="${_}"/>`;function kn(e){let t=e.contentTypes.overrides.get(p(E));if(t===_)return e;if(t!==void 0)return null;let n=e.partBytes.get(Rt);if(!n)return null;let r=strFromU8(n),o=kt(r);if(!o)return null;let s=r.lastIndexOf(`</${o.rootName}>`);if(s===-1)return null;let a=r.slice(0,s)+In+r.slice(s),i=kt(a);if(!i||i.rootName!==o.rootName)return null;let d=[...o.children,wt("Override",{PartName:E,ContentType:_})];return i.children.length!==d.length||i.children.some((l,c)=>l!==d[c])?null:Object.freeze({...e,partBytes:new Map([...e.partBytes,[Rt,strToU8(a)]]),contentTypes:Object.freeze({defaults:e.contentTypes.defaults,overrides:new Map([...e.contentTypes.overrides,[p(E),_]])})})}function kt(e){let t=da(e);if(!t.ok)return null;let n=t.nodes.filter(i=>i.type==="element");if(n.length!==1)return null;let r=n[0],o=r.name.indexOf(":"),s=o===-1?"":r.name.slice(0,o);if(r.name.slice(o+1)!=="Types"||r.attributes[s?`xmlns:${s}`:"xmlns"]!==gn)return null;let a=[];for(let i of r.children)i.type==="element"&&a.push(wt(i.name,i.attributes));return {rootName:r.name,children:a}}function wt(e,t){let n=Object.entries(t).map(([r,o])=>`${r}=${o}`).sort();return [e,...n].join("")}function re(e){return e!=null&&e.kind!=="textValue"}function Je(e,t){for(let n of e.children)if(n.kind!=="textValue"&&n.namespaceUri===ma&&n.localName===t)return n;return null}function oe(e,t){for(let n of e.attributes)if(n.namespaceUri===ma&&n.localName===t)return n.value}function A(e,t){let n=Je(e,t);if(!n)return false;let r=oe(n,"val");return r===void 0?true:r!=="0"&&r!=="false"&&r!=="off"}var _t=Object.freeze({trackRevisions:false,restrictedToTrackedChanges:false,doNotTrackMoves:false,doNotTrackFormatting:false});function Sn(e){if(!re(e))return _t;let t=Je(e,"documentProtection"),n=t===null?void 0:oe(t,"enforcement"),r=n!==void 0&&n!=="0"&&n!=="false"&&n!=="off";return {trackRevisions:A(e,"trackRevisions"),restrictedToTrackedChanges:r&&t!==null&&oe(t,"edit")==="trackedChanges",doNotTrackMoves:A(e,"doNotTrackMoves"),doNotTrackFormatting:A(e,"doNotTrackFormatting")}}var At=Object.freeze({doNotShadeFormData:false});function vn(e){return re(e)?{doNotShadeFormData:A(e,"doNotShadeFormData")}:At}function Tn(e,t){let n=e.parts.get(t.storyPartName);if(!n)return {ok:false,reason:`no story part named ${t.storyPartName}`};let r=[];for(let d of te$1(n.root)){let l=re$1(d.node).tag;if(l===void 0||l.length===0)continue;let c=t.decide(l);c!=="keep"&&r.push({nodeId:d.node.id,policy:c});}let o=n,s=0,a=0;for(let{nodeId:d,policy:l}of r){let c=Ga(o,d);if(!c)continue;if(l==="remove"){let g=Ka(o,d,{deferValidation:true});if(!g.ok)return {ok:false,reason:`a node could not be removed: ${$t(g)}`};o=g.part,a+=1;continue}let p=c.children.find(g=>g.id===d);if(!p)continue;let u=pe(p),m=u?u.children:[],f=c.children.flatMap(g=>g.id===d?m:[g]),y=Ha(o,c.id,f,{deferValidation:true});if(!y.ok)return {ok:false,reason:`a node could not be unwrapped: ${$t(y)}`};o=y.part,s+=1;}let i=o===n?e:Ab(e,o);if(!i.parts.has(t.storyPartName))return {ok:false,reason:"the story went missing during the export"};for(let d of t.namespaces)for(let l of _n(i,t.storyPartName,d)){let c=_if(i,l.itemId),p=cf(i,l.partName,c);if(p.pkg===i&&p.removed.length===0&&!wn(i,l.partName,c))return {ok:false,reason:`the payloads in ${d} could not be removed`};if(i=p.pkg,c.size>0)continue;let u=An(i,l);if(!u.ok)return {ok:false,reason:`the payload store for ${d} could not be removed`};i=u.pkg;}return {ok:true,pkg:i,unwrapped:s,removed:a}}function wn(e,t,n){return _e(e,t).every(r=>n.has(r.id))}function $t(e){return e.issues.map(t=>t.code).join(", ")||"the edit was refused"}function _n(e,t,n){return We$1(e,t).filter(r=>r.namespaceUri===n)}function An(e,t){let n=Gb(e,t.partName);if(!n.ok)return {pkg:e,ok:false};let r=Gb(n.pkg,t.propsPartName);return r.ok?{pkg:r.pkg,ok:true}:{pkg:e,ok:false}}var ie="http://purl.org/dc/elements/1.1/",Dt="http://schemas.openxmlformats.org/package/2006/metadata/core-properties",Mt="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties";var sp=Object.freeze({});function k(e,t,n){if(e.kind!=="textValue")for(let r of e.children){if(r.kind==="textValue"||r.namespaceUri!==t||r.localName!==n)continue;let o=r.children.find(a=>a.kind==="textValue");if(!o||o.kind!=="textValue")return;let s=o.value.trim();return s.length===0?void 0:s.length>4096?s.slice(0,4096):s}}function lp(e,t){let n={};if(e&&e.kind!=="textValue"){let r=k(e,ie,"title");r!==void 0&&(n.title=r);let o=k(e,ie,"creator");o!==void 0&&(n.creator=o);let s=k(e,ie,"subject");s!==void 0&&(n.subject=s);let a=k(e,ie,"description");a!==void 0&&(n.description=a);let i=k(e,Dt,"keywords");i!==void 0&&(n.keywords=i);let d=k(e,Dt,"lastModifiedBy");d!==void 0&&(n.lastModifiedBy=d);}if(t&&t.kind!=="textValue"){let r=k(t,Mt,"Company");r!==void 0&&(n.company=r);let o=k(t,Mt,"Manager");o!==void 0&&(n.manager=o);}return n}
|
|
2
2
|
export{Ve as A,je as B,Xe as C,qt as D,dt as E,mt as F,tn as G,rn as H,Nt as I,dn as J,pn as K,Nn as L,Cn as M,_t as N,Sn as O,At as P,vn as Q,sp as R,lp as S,Tn as T,Ft as a,ot as b,J as c,S as d,q as e,Q as f,h as g,Ht as h,v as i,B as j,Z as k,U as l,ee as m,De as n,Me as o,Fe as p,Kt as q,Gt as r,Be as s,at as t,zt as u,Le as v,Wt as w,H as x,Ue as y,He as z};
|