@betteroffice/docx 0.4.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +108 -598
  3. package/dist/chunk-25WGDXBF.mjs +1 -0
  4. package/dist/chunk-2CCPNW44.mjs +1 -0
  5. package/dist/chunk-32A4I3T4.mjs +1 -0
  6. package/dist/chunk-4LO3PSLZ.mjs +2 -0
  7. package/dist/chunk-67MGRMP3.mjs +1 -0
  8. package/dist/chunk-6AUR4AA2.mjs +1 -0
  9. package/dist/chunk-6WT6HKAY.mjs +1 -0
  10. package/dist/chunk-77ZWGQZN.mjs +1 -0
  11. package/dist/chunk-7C3Y7LIH.mjs +1 -0
  12. package/dist/chunk-7WIUNGQW.mjs +1 -0
  13. package/dist/chunk-7WWFGMMF.mjs +1 -0
  14. package/dist/chunk-AK2NG7PT.mjs +1 -0
  15. package/dist/chunk-BR5BFOHF.mjs +1 -0
  16. package/dist/chunk-CDNWHQH2.mjs +1 -0
  17. package/dist/chunk-CRTTEHZN.mjs +1 -0
  18. package/dist/chunk-ETDMQ5GE.mjs +1 -0
  19. package/dist/{wasm-KSZTTO3B.mjs → chunk-GBOHQ3CJ.mjs} +1 -1
  20. package/dist/chunk-H7K4SJKK.mjs +1 -0
  21. package/dist/chunk-ICJH7QUY.mjs +1 -0
  22. package/dist/chunk-IHETKRDA.mjs +1 -0
  23. package/dist/chunk-ISBZLVIF.mjs +1 -0
  24. package/dist/chunk-JSYH6HNV.mjs +2 -0
  25. package/dist/chunk-KICHSQFN.mjs +1 -0
  26. package/dist/chunk-KXIGXLFA.mjs +5 -0
  27. package/dist/chunk-KXLTK7AT.mjs +57 -0
  28. package/dist/chunk-L3JRNJ34.mjs +1 -0
  29. package/dist/chunk-LKDHP22R.mjs +1 -0
  30. package/dist/chunk-LPOEM5WH.mjs +1 -0
  31. package/dist/chunk-M44BABH2.mjs +1 -0
  32. package/dist/chunk-MAYPJU23.mjs +1 -0
  33. package/dist/chunk-N5RE2S3U.mjs +2 -0
  34. package/dist/chunk-NLYHFVF5.mjs +1 -0
  35. package/dist/chunk-ONYCW7VV.mjs +4 -0
  36. package/dist/chunk-QGZ2AB3M.mjs +1 -0
  37. package/dist/chunk-QWHU7YIW.mjs +2 -0
  38. package/dist/{chunk-VH7P4734.mjs → chunk-QX2CDKPG.mjs} +1 -1
  39. package/dist/chunk-RGDE6YQB.mjs +1 -0
  40. package/dist/chunk-TE3AU2JK.mjs +1 -0
  41. package/dist/chunk-UDVEZ722.mjs +1 -0
  42. package/dist/chunk-UQSVFDRV.mjs +2 -0
  43. package/dist/chunk-VHOOSS4D.mjs +1 -0
  44. package/dist/chunk-WIDM4EMT.mjs +1 -0
  45. package/dist/chunk-YITJ4QAO.mjs +1 -0
  46. package/dist/collaboration/index.d.mts +111 -11
  47. package/dist/collaboration/index.mjs +1 -1
  48. package/dist/{content-DSb-6a9T.d.mts → content-DVT06V_6.d.mts} +24 -3
  49. package/dist/core.d.mts +9 -9
  50. package/dist/core.mjs +1 -1
  51. package/dist/displayListQueries-6XjS7B5e.d.mts +1473 -0
  52. package/dist/docx/index.d.mts +8 -7
  53. package/dist/docx/index.mjs +1 -2
  54. package/dist/docxWorker.mjs +1 -0
  55. package/dist/editor/index.d.mts +14 -12
  56. package/dist/editor/index.mjs +1 -1
  57. package/dist/{fontLoader-BNSs0E8K.d.mts → fontLoader-CBkmh4ps.d.mts} +1 -1
  58. package/dist/{formatting-gqLFeJ9X.d.mts → formatting-p5MneNuy.d.mts} +32 -1
  59. package/dist/generated/edit/docx_edit_bg.wasm +0 -0
  60. package/dist/generated/layout/docx_layout_bg.wasm +0 -0
  61. package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
  62. package/dist/generated/parse/docx_parse_bg.wasm +0 -0
  63. package/dist/index-C-KKULi5.d.mts +5596 -0
  64. package/dist/layout/index.d.mts +4 -4
  65. package/dist/layout/index.mjs +1 -1
  66. package/dist/layout/pagination/index.d.mts +4 -4
  67. package/dist/layout/render/index.d.mts +37 -53
  68. package/dist/layout/render/index.mjs +3 -1
  69. package/dist/{pagedExport-BmSlEhoP.d.mts → pagedExport-DDgA5O7E.d.mts} +92 -9
  70. package/dist/plugin-api/RenderedDomContext.d.mts +5 -7
  71. package/dist/plugin-api/index.d.mts +3 -3
  72. package/dist/plugin-api/resolveItemPositions.d.mts +3 -3
  73. package/dist/{rezip-Bxiq4Z_R.d.mts → rezip-CfwAYdV4.d.mts} +7 -1
  74. package/dist/styles/index.d.mts +3 -3
  75. package/dist/styles/index.mjs +1 -1
  76. package/dist/{styles-AryxLAhx.d.mts → styles-DZZz2oRy.d.mts} +2 -2
  77. package/dist/types/content.d.mts +2 -2
  78. package/dist/types/document.d.mts +6 -6
  79. package/dist/{types-Cz7S77Ut.d.mts → types-bvPg3KsF.d.mts} +16 -3
  80. package/dist/utils/comments.d.mts +2 -2
  81. package/dist/utils/findReplace.mjs +1 -2
  82. package/dist/utils/index.d.mts +5 -5
  83. package/dist/utils/index.mjs +1 -1
  84. package/dist/utils/listState.d.mts +2 -5
  85. package/dist/utils/stylePreview.d.mts +2 -2
  86. package/dist/utils/stylePreview.mjs +1 -1
  87. package/dist/wasm-edit.d.mts +233 -48
  88. package/dist/wasm-edit.mjs +1 -1
  89. package/dist/wasm-layout.d.mts +7 -1
  90. package/dist/wasm-layout.mjs +1 -1
  91. package/dist/wasm-opc.mjs +1 -1
  92. package/dist/wasm-parse.d.mts +7 -1
  93. package/dist/wasm-parse.mjs +1 -1
  94. package/dist/worker.d.mts +60 -0
  95. package/dist/worker.mjs +1 -0
  96. package/dist/yrs/docxWorker.d.mts +20 -0
  97. package/dist/yrs/docxWorker.mjs +3 -0
  98. package/dist/yrs/index.d.mts +12 -7
  99. package/dist/yrs/index.mjs +1 -1
  100. package/package.json +14 -4
  101. package/dist/chunk-3RPZ44TT.mjs +0 -1
  102. package/dist/chunk-47Q2FMFF.mjs +0 -1
  103. package/dist/chunk-5Z22FORG.mjs +0 -1
  104. package/dist/chunk-7ZV6P6NZ.mjs +0 -57
  105. package/dist/chunk-AXFMDV66.mjs +0 -1
  106. package/dist/chunk-EBYC3CX7.mjs +0 -1
  107. package/dist/chunk-FK7X7557.mjs +0 -1
  108. package/dist/chunk-GKWXOZZH.mjs +0 -1
  109. package/dist/chunk-LIOWZSE7.mjs +0 -1
  110. package/dist/chunk-ML6E23W2.mjs +0 -1
  111. package/dist/chunk-MLEMGJP7.mjs +0 -1
  112. package/dist/chunk-QBMNRD5V.mjs +0 -2
  113. package/dist/chunk-SHVHVJUB.mjs +0 -1
  114. package/dist/compareDocx-URPCPAQT.mjs +0 -1
  115. package/dist/computeLayout-ZTO6TBWX.mjs +0 -1
  116. package/dist/displayListQueries-BVBDVXoP.d.mts +0 -306
  117. package/dist/frameDelta-CLeO7K5z.d.mts +0 -807
  118. package/dist/index-DzZVJC8-.d.mts +0 -2467
  119. package/dist/parseWasm-BESKFFA3.mjs +0 -1
  120. package/dist/rustDisplayList-B7uPoItK.d.mts +0 -315
  121. package/dist/wasm-JPDPN2B2.mjs +0 -1
  122. package/dist/wasm-QI7MWC5D.mjs +0 -1
  123. package/dist/yrs/residentEngineWorker.d.mts +0 -2
  124. package/dist/yrs/residentEngineWorker.mjs +0 -1
@@ -0,0 +1 @@
1
+ import {f as f$1,g,e,q,m as m$1,n,u as u$1,w,o,t,b as b$1,v as v$1,j as j$1,k as k$1,r,s,c as c$1,d,a,h,i}from'./chunk-VHOOSS4D.mjs';import {a as a$1,f as f$2}from'./chunk-LPOEM5WH.mjs';import {b}from'./chunk-TTRUPDAB.mjs';var u=class extends Error{constructor(t,r,s){super(r);b(this,"code");b(this,"cause");this.name="CollaborationError",this.code=t,this.cause=s;}};var J=new WeakMap;function j(n){return J.get(n)}var K=new WeakMap;function Te(n,e){K.set(n,e);}function Z(n){return K.get(n)}function x(n){return ()=>{throw new Error(`${n} is not available on a worker-hosted replica; use async.${n}() or open the editor with legacySyncApi for synchronous replica access`)}}function Fe(n){let e={clientId:n.clientId,encodeStateVector:()=>n.encodeStateVector(),encodeStateAsUpdate:r=>n.encodeStateAsUpdate(r),...n.encodeStateAsUpdateChunks&&{encodeStateAsUpdateChunks:(r,s)=>n.encodeStateAsUpdateChunks(r,s)},applyUpdate:r=>n.applyUpdate(r.slice()),...n.applyUpdateChunks&&{applyUpdateChunks:r=>n.applyUpdateChunks(r.map(s=>s.slice()))},onUpdate:r=>n.onUpdate(r)},t={clientId:n.clientId,async:e,encodeStateVector:x("encodeStateVector"),encodeStateAsUpdate:x("encodeStateAsUpdate"),...e.encodeStateAsUpdateChunks&&{encodeStateAsUpdateChunks:x("encodeStateAsUpdateChunks")},applyUpdate:e.applyUpdate,onUpdate:e.onUpdate};return J.set(t,n),t}function ae(n){return n instanceof Error&&n.message?n.message:typeof n=="string"&&n?n:"Unknown error"}var oe=["backpressure","protocol","replica","transport"],B=64,ce=250;function le(n){if(n[0]!==0||n[1]!==2)return false;let e=0;for(let t=2,r=0;t<Math.min(n.byteLength,7);t++,r+=7)if(e+=(n[t]&127)*2**r,n[t]<128)return t+1+e===n.byteLength;return false}var U=class{constructor(e,t,r){b(this,"transport",t);b(this,"options",r);b(this,"endpoint");b(this,"statusListeners",new Map);b(this,"errorListeners",new Map);b(this,"peerListeners",new Map);b(this,"nextListenerId",0);b(this,"connectionStatus","disconnected");b(this,"isSynced",false);b(this,"peerList",[]);b(this,"seq",0);b(this,"floor",0);b(this,"sendFloor",0);b(this,"inboundBytes",0);b(this,"flushingFrames",false);b(this,"queue",[]);b(this,"posting",false);b(this,"flushQueued",false);b(this,"heldTimer",null);b(this,"urgent",false);b(this,"unsubscribeTransport",null);b(this,"subscription",0);b(this,"wantsConnection",false);b(this,"connectAttempt",0);b(this,"leaveFrame",null);b(this,"pendingFrames",[]);b(this,"queuedBytes",0);b(this,"isDestroyed",false);b(this,"closed",false);this.endpoint=e.open(s=>this.receive(s),s=>this.lose(s)),this.enqueue({op:"create",seq:++this.seq,options:r.worker});}get status(){return this.connectionStatus}get synced(){return this.isSynced}get pendingBytes(){return this.queuedBytes}get peers(){return this.peerList}setCursor(e,t){this.isDestroyed||this.enqueue({op:"cursor",seq:++this.seq,cursor:e,broadcast:t});}onPeers(e){if(this.isDestroyed)return ()=>{};let t=this.nextListenerId++;return this.peerListeners.set(t,e),e(this.peers),()=>this.peerListeners.delete(t)}onStatus(e){if(this.isDestroyed)return ()=>{};let t=this.nextListenerId++;return this.statusListeners.set(t,e),()=>this.statusListeners.delete(t)}onError(e){if(this.isDestroyed)return ()=>{};let t=this.nextListenerId++;return this.errorListeners.set(t,e),()=>this.errorListeners.delete(t)}connect(){if(this.isDestroyed||this.connectionStatus==="connected"||this.connectionStatus==="connecting")return;if(this.closed){this.report(this.options.makeError("replica","Collaboration replica is retired"));return}this.wantsConnection=true,this.floor=++this.seq,this.enqueue({op:"connect",seq:this.floor});let e=++this.connectAttempt;if(this.setStatus("connecting",false),!(!this.wantsConnection||this.isDestroyed||e!==this.connectAttempt)){if(!this.unsubscribeTransport){let t=++this.subscription,r;try{if(r=this.transport.onEvent(s=>this.forward(t,s)),typeof r!="function")throw new TypeError("Transport event subscription must return a function")}catch(s){this.subscription+=1,this.fail(this.transportError("Failed to subscribe to transport events",s));return}if(!this.wantsConnection||this.isDestroyed||e!==this.connectAttempt||t!==this.subscription){try{r();}catch(s){this.isDestroyed||this.report(this.transportError("Failed to unsubscribe from stale transport events",s));}return}this.unsubscribeTransport=r;}try{let t=this.transport.connect();t&&t.catch(r=>{!this.isDestroyed&&this.wantsConnection&&this.connectAttempt===e&&this.fail(this.transportError("Transport connect failed",r));});}catch(t){this.fail(this.transportError("Transport connect failed",t));}}}disconnect(){if(this.isDestroyed)return;if(this.closed){this.setStatus("disconnected",false);return}if(!(this.wantsConnection||this.unsubscribeTransport!==null||this.connectionStatus!=="disconnected"))return;this.sendLeave(),this.floor=++this.seq,this.enqueue({op:"disconnect",seq:this.floor});let t=this.release(true);this.setStatus("disconnected",false);for(let r of t)this.report(r);}destroy(){if(this.isDestroyed)return;let e=!this.closed&&(this.wantsConnection||this.unsubscribeTransport!==null||this.connectionStatus==="connecting"||this.connectionStatus==="connected");e&&this.sendLeave(),this.floor=++this.seq,this.enqueue({op:"destroy",seq:this.floor});let t=this.closed?[]:this.release(e);this.isDestroyed=true,this.setStatus("destroyed",false);for(let r of t)this.report(r);this.statusListeners.clear(),this.errorListeners.clear(),this.peerListeners.clear();}transportError(e,t){return this.options.normalize("transport",e,t)}release(e){this.wantsConnection=false,this.connectAttempt+=1,this.leaveFrame=null,this.clearQueue(),this.clearPeers();let t=[],r=this.unsubscribeTransport;if(this.unsubscribeTransport=null,this.subscription+=1,r)try{r();}catch(s){t.push(this.transportError("Failed to unsubscribe from transport events",s));}if(!e)return t;try{let s=this.transport.disconnect();s&&s.catch(a=>{this.isDestroyed||this.report(this.transportError("Transport disconnect failed",a));});}catch(s){t.push(this.transportError("Transport disconnect failed",s));}return t}fail(e){if(this.isDestroyed||!this.wantsConnection)return;let t=e.code;this.floor=++this.seq,this.enqueue({op:"fail",seq:this.floor,error:{code:typeof t=="string"&&oe.includes(t)?t:"transport",message:e.message}});let r=this.release(true);this.setStatus("disconnected",false),this.report(e);for(let s of r)this.report(s);}sendLeave(){let e=this.leaveFrame;if(this.leaveFrame=null,!(!e||!this.options.hasUser||!this.unsubscribeTransport||this.connectionStatus!=="connected"))try{this.transport.send(e);}catch(t){this.report(this.transportError("Failed to send awareness leave",t));}}enqueue(e,t=false){this.closed||(this.queue.push(e),this.schedule(t));}schedule(e){if(e||(this.urgent=true),!(this.posting||this.flushQueued)){if(e){this.heldTimer??(this.heldTimer=setTimeout(()=>{this.heldTimer=null,this.flush();},ce));return}this.flushQueued=true,queueMicrotask(()=>{this.flushQueued=false,this.flush();});}}flush(){if(this.posting||this.closed||this.queue.length===0)return;this.heldTimer!==null&&(clearTimeout(this.heldTimer),this.heldTimer=null);let e=this.queue;this.queue=[],this.urgent=false,this.posting=true;let t=e.some(a=>a.op==="destroy"),r=e.reduce((a,o)=>o.op==="event"&&o.event.type==="message"?a+o.event.data.byteLength+B:a,0),s;try{s=this.endpoint.post(e,a$1(e));}catch(a){s=Promise.reject(a);}s.then(()=>{this.posting=false,this.inboundBytes-=r,t?this.close():this.urgent?this.flush():this.queue.length>0&&this.schedule(true);},a=>{this.posting=false,this.inboundBytes-=r,this.lose(ae(a));});}forward(e,t){if(!(this.closed||this.isDestroyed||e!==this.subscription))switch(t.type){case "message":if(this.inboundBytes===0?t.data.byteLength>this.options.maxPendingBytes:t.data.byteLength+B>this.options.maxPendingBytes-this.inboundBytes){this.fail(this.options.makeError("backpressure","Pending replica data exceeds the byte limit"));return}this.inboundBytes+=t.data.byteLength+B,this.enqueue({op:"event",seq:++this.seq,event:{type:"message",data:t.data.slice().buffer}},!this.isSynced&&le(t.data)&&this.inboundBytes<=this.options.maxPendingBytes/2);return;case "open":case "close":this.clearQueue(),t.type==="close"&&(this.connectAttempt+=1,this.leaveFrame=null),this.sendFloor=++this.seq,this.enqueue({op:"event",seq:this.sendFloor,event:t.type==="open"?{type:"open"}:{type:"close",...t.reason!==void 0&&{reason:t.reason}}}),t.type==="close"&&(this.clearPeers(),this.setStatus("disconnected",false));return;case "drain":this.flushPending();return;case "error":this.fail(this.transportError("Transport error",t.error));return;default:this.fail(this.options.makeError("transport","Unknown transport event"));}}receive(e){for(let t of e){if(this.closed||this.isDestroyed)return;if(t.do==="lost"){this.lose("Collaboration replica is retired");return}if(!(t.through<this.floor))switch(t.do){case "unsubscribe":{let r=this.release(false);for(let s of r)this.report(s);break}case "disconnect":{this.wantsConnection=false;let r=this.release(true);for(let s of r)this.report(s);break}case "send":t.through>=this.sendFloor&&this.send(new Uint8Array(t.data));break;case "leave":t.through>=this.sendFloor&&(this.leaveFrame=t.data?new Uint8Array(t.data):null);break;case "status":t.through>=this.sendFloor&&this.setStatus(t.status,t.synced);break;case "peers":{if(t.through<this.sendFloor||t.peers.length===0&&this.peerList.length===0)break;let r=this.options.rebasePeer,s=t.timeOrigin-f$2();this.peerList=r?t.peers.map(a=>r(a,s)):t.peers,this.emitPeers();break}case "error":this.report(this.options.makeError(t.error.code,t.error.message));break}}}send(e){if(!this.unsubscribeTransport)return;if(this.pendingFrames.length>0){this.queueFrame(e);return}let t=this.sendFloor,r;try{r=this.transport.send(e.slice());}catch(s){this.fail(this.transportError("Transport send failed",s));return}if(typeof r!="boolean"){this.fail(this.options.makeError("transport","Transport send must return a boolean"));return}!r&&this.unsubscribeTransport!==null&&t===this.sendFloor&&this.queueFrame(e);}queueFrame(e){if(e.byteLength>this.options.maxPendingBytes-this.queuedBytes){this.fail(this.options.makeError("backpressure",`Pending collaboration data exceeds ${this.options.maxPendingBytes} bytes`));return}this.pendingFrames.push(e),this.queuedBytes+=e.byteLength;}flushPending(){if(!this.flushingFrames){this.flushingFrames=true;try{for(;this.unsubscribeTransport&&this.pendingFrames.length>0;){let e=this.pendingFrames[0],t;try{t=this.transport.send(e.slice());}catch(r){this.fail(this.transportError("Transport send failed",r));return}if(typeof t!="boolean"){this.fail(this.options.makeError("transport","Transport send must return a boolean"));return}if(!t||this.pendingFrames[0]!==e)return;this.pendingFrames.shift(),this.queuedBytes-=e.byteLength;}}finally{this.flushingFrames=false;}}}clearQueue(){this.pendingFrames.length=0,this.queuedBytes=0;}lose(e){if(this.closed||(this.close(),this.isDestroyed))return;this.sendLeave();let t=this.release(this.wantsConnection||this.connectionStatus!=="disconnected");setTimeout(()=>{if(!this.isDestroyed){this.setStatus("disconnected",false),this.report(this.options.makeError("replica",e));for(let r of t)this.report(r);}},0);}close(){this.closed||(this.closed=true,this.queue=[],this.heldTimer!==null&&(clearTimeout(this.heldTimer),this.heldTimer=null),this.endpoint.close());}clearPeers(){this.peerList.length!==0&&(this.peerList=[],this.emitPeers());}setStatus(e,t){if(!(this.connectionStatus===e&&this.isSynced===t)){this.connectionStatus=e,t&&!this.isSynced&&this.queue.length>0&&this.schedule(false),this.isSynced=t;for(let[r,s]of [...this.statusListeners])if(this.statusListeners.get(r)===s)try{s({status:e,synced:t});}catch{}}}emitPeers(){let e=this.peers;for(let[t,r]of [...this.peerListeners])if(this.peerListeners.get(t)===r)try{r(e);}catch{}}report(e){for(let[t,r]of [...this.errorListeners])if(this.errorListeners.get(t)===r)try{r(e);}catch{}}};var pe=16*1024*1024,ue=64*1024*1024,de=64,ye=80,fe=2e4,me=45e3,be=5e3,f=0;function v(n,e,t,r){if(!Number.isSafeInteger(e)||e<(t?0:1)||e>r)throw new RangeError(`${n} must be ${t?"a non-negative":"a positive"} integer no greater than ${r}`);return e}function ee(n,e){if(!Array.isArray(n)||n.length===0||!n.every(t=>t instanceof Uint8Array&&t.byteLength>0))throw new TypeError(`${e} must return a non-empty array of non-empty Uint8Array`);return n}function ve(n){return n instanceof Error&&n.message?n.message:typeof n=="string"&&n?n:"Unknown error"}function c(n,e,t){return t instanceof u?t:new u(n,`${e}: ${ve(t)}`,t)}function m(n,e){if(!(n instanceof Uint8Array))throw new TypeError(`${e} must return a Uint8Array`);return n.slice()}function C(){return globalThis.performance?.now?.()??Date.now()}function k(n){n.unref?.();}function Ce(n,e){if(!n)return null;if(!Number.isSafeInteger(e)||e<0)throw new RangeError("clientId must be a non-negative safe integer for awareness");if(typeof n.name!="string"||n.name.trim().length===0)throw new TypeError("user.name must be a non-empty string");return {name:n.name.trim().slice(0,1024),color:a(e,n.color)}}function ge(n){if(n===null)return null;if(typeof n.story!="string"||!n.story||!(n.anchor instanceof Uint8Array)||!(n.head instanceof Uint8Array))throw new TypeError("cursor requires a story and Uint8Array anchor/head");return {story:n.story,anchor:n.anchor.slice(),head:n.head.slice()}}function Ae(n){return n.story.length<=1024&&n.anchor.byteLength<=1024&&n.head.byteLength<=1024}function we(n){if(typeof n!="object"||n===null)return null;let e=n;return !Number.isSafeInteger(e.clientId)||(e.clientId??-1)<0||typeof e.story!="string"||typeof e.paraId!="string"||!Number.isSafeInteger(e.endOffset)||(e.endOffset??-1)<0?null:{clientId:e.clientId,story:e.story,paraId:e.paraId,endOffset:e.endOffset}}function Se(n){return n.type==="sync-step-1"||n.type==="sync-step-2"||n.type==="update"}function te(n,e,t){return e.length===0?n.applyUpdate(t):n.applyUpdateChunks([...e,t])}var se=new WeakMap,ne=new WeakMap;function Ne(n){return ne.get(n)()}function Ve(n){return se.get(n)()}var re=class{constructor(e,t,r={}){b(this,"replica");b(this,"piped");b(this,"asyncReplica");b(this,"replicaTail",Promise.resolve());b(this,"replicaBytes",0);b(this,"openEpoch",0);b(this,"transport");b(this,"maxFrameBytes");b(this,"maxMessagesPerFrame");b(this,"maxPendingBytes");b(this,"syncChunkBytes");b(this,"maxSyncBytes");b(this,"syncHeld",null);b(this,"syncHeldBytes",0);b(this,"syncJoinPending",false);b(this,"syncRequestOwed",false);b(this,"updateBatch",null);b(this,"localUser");b(this,"statusListeners",new Map);b(this,"errorListeners",new Map);b(this,"peerListeners",new Map);b(this,"pendingFrames",[]);b(this,"awarenessRecords",new Map);b(this,"awarenessGenerations",new Map);b(this,"awarenessGeneration",0);b(this,"awarenessFloor",0);b(this,"arrivalsInFlight",new Map);b(this,"unsubscribeReplica");b(this,"unsubscribeTransport",()=>{});b(this,"hasTransportSubscription",false);b(this,"connectionStatus","disconnected");b(this,"isSynced",false);b(this,"wantsConnection",false);b(this,"isOpen",false);b(this,"isDestroyed",false);b(this,"epoch",0);b(this,"connectAttempt",0);b(this,"nextListenerId",0);b(this,"queuedBytes",0);b(this,"isFlushing",false);b(this,"arrivalInfers",true);b(this,"localClock",Math.max(Date.now(),f));b(this,"reportedClockExhaustion",false);b(this,"localCursor",null);b(this,"lastAwarenessSentAt",Number.NEGATIVE_INFINITY);b(this,"cursorBroadcastTimer",null);b(this,"heartbeatTimer",null);b(this,"expiryTimer",null);this.replica=e,this.asyncReplica=j(e),this.transport=t,this.maxFrameBytes=v("maxFrameBytes",r.maxFrameBytes??f$1,false,h),this.maxMessagesPerFrame=v("maxMessagesPerFrame",r.maxMessagesPerFrame??g,false,Number.MAX_SAFE_INTEGER),this.maxPendingBytes=v("maxPendingBytes",r.maxPendingBytes??pe,true,i),this.syncChunkBytes=r.syncChunkBytes===void 0?void 0:v("syncChunkBytes",r.syncChunkBytes,false,this.maxFrameBytes),this.maxSyncBytes=v("maxSyncBytes",r.maxSyncBytes??ue,false,i),this.localUser=Ce(r.user,e.clientId),se.set(this,()=>this.beginArrival()),ne.set(this,()=>this.leaveFrame());let s=Z(e);if(s){this.unsubscribeReplica=()=>{},this.piped=new U(s,t,{worker:{maxFrameBytes:this.maxFrameBytes,maxMessagesPerFrame:this.maxMessagesPerFrame,maxSyncBytes:this.maxSyncBytes,...this.syncChunkBytes!==void 0&&{syncChunkBytes:this.syncChunkBytes},...r.user&&{user:{name:r.user.name,...r.user.color!==void 0&&{color:r.user.color}}}},maxPendingBytes:this.maxPendingBytes,hasUser:this.localUser!==null,rebasePeer:(a,o)=>({...a,lastSeenAt:a.lastSeenAt+o,cursorMovedAt:a.cursorMovedAt===0?0:a.cursorMovedAt+o}),makeError:(a,o,l)=>new u(a,o,l),normalize:c});return}try{this.unsubscribeReplica=e.onUpdate((a,o)=>{o==="local"&&this.forwardLocalUpdate(a);});}catch(a){throw c("replica","Failed to observe replica updates",a)}}get status(){return this.piped?this.piped.status:this.connectionStatus}get synced(){return this.piped?this.piped.synced:this.isSynced}get pendingBytes(){return this.piped?this.piped.pendingBytes:this.queuedBytes}get peers(){return this.piped?this.piped.peers:e(this.awarenessRecords)}setCursor(e,t=true){if(this.isDestroyed||!this.localUser)return;let r=ge(e);if(this.piped){this.piped.setCursor(r,t);return}if(this.localCursor=!r||Ae(r)?r:null,r&&!this.localCursor&&this.report(new u("protocol",`Presence cursor exceeds ${1024} story characters or ${1024} position bytes; cursor dropped`)),!t){this.clearCursorBroadcastTimer();return}this.scheduleCursorBroadcast();}onPeers(e){if(this.isDestroyed)return ()=>{};if(typeof e!="function")throw new TypeError("peer listener must be a function");if(this.piped)return this.piped.onPeers(e);let t=this.nextListenerId++;return this.peerListeners.set(t,e),e(this.peers),()=>this.peerListeners.delete(t)}connect(){if(this.piped){this.piped.connect();return}if(this.isDestroyed||this.isOpen||this.connectionStatus==="connecting")return;this.wantsConnection=true;let e=this.hasTransportSubscription?this.epoch:++this.epoch,t=++this.connectAttempt;if(this.setStatus("connecting",false),!!this.isCurrent(e)){if(!this.hasTransportSubscription){let r;try{if(r=this.transport.onEvent(s=>this.handleTransportEvent(e,s)),typeof r!="function")throw new TypeError("Transport event subscription must return a function")}catch(s){this.failConnection(e,c("transport","Failed to subscribe to transport events",s));return}if(!this.isCurrent(e)){try{r();}catch(s){this.isDestroyed||this.report(c("transport","Failed to unsubscribe from stale transport events",s));}return}this.unsubscribeTransport=r,this.hasTransportSubscription=true;}try{let r=this.transport.connect();r&&r.catch(s=>{this.isCurrent(e)&&this.connectAttempt===t&&this.failConnection(e,c("transport","Transport connect failed",s));});}catch(r){this.failConnection(e,c("transport","Transport connect failed",r));}}}disconnect(){if(this.isDestroyed)return;if(this.piped){this.piped.disconnect();return}if(!(this.wantsConnection||this.isOpen||this.hasTransportSubscription||this.connectionStatus!=="disconnected"))return;this.resetReplicaQueue(),this.sendLeaveBestEffort(),this.stopPresence(),this.wantsConnection=false,this.isOpen=false,this.epoch+=1,this.connectAttempt+=1;let t=this.takeTransportSubscription();this.clearPending();let r=this.cleanupTransport(t,true);this.setStatus("disconnected",false);for(let s of r)this.report(s);}destroy(){if(this.isDestroyed)return;if(this.piped){this.isDestroyed=true,this.piped.destroy();return}let e=this.wantsConnection||this.isOpen||this.hasTransportSubscription||this.connectionStatus==="connecting"||this.connectionStatus==="connected";this.resetReplicaQueue(),this.sendLeaveBestEffort(),this.stopPresence(),this.isDestroyed=true,this.wantsConnection=false,this.isOpen=false,this.epoch+=1,this.connectAttempt+=1;let t=this.takeTransportSubscription();this.clearPending();let r=this.cleanupTransport(t,e);this.setStatus("destroyed",false);for(let s of r)this.report(s);try{this.unsubscribeReplica();}catch(s){this.report(c("replica","Failed to unsubscribe from replica updates",s));}this.unsubscribeReplica=()=>{},this.statusListeners.clear(),this.errorListeners.clear(),this.peerListeners.clear();}onStatus(e){if(this.isDestroyed)return ()=>{};if(typeof e!="function")throw new TypeError("status listener must be a function");if(this.piped)return this.piped.onStatus(e);let t=this.nextListenerId++;return this.statusListeners.set(t,e),()=>this.statusListeners.delete(t)}onError(e){if(this.isDestroyed)return ()=>{};if(typeof e!="function")throw new TypeError("error listener must be a function");if(this.piped)return this.piped.onError(e);let t=this.nextListenerId++;return this.errorListeners.set(t,e),()=>this.errorListeners.delete(t)}isCurrent(e){return !this.isDestroyed&&this.wantsConnection&&e===this.epoch}failConnection(e,t){if(!this.isCurrent(e))return;this.resetReplicaQueue(),this.stopPresence(),this.wantsConnection=false,this.isOpen=false,this.epoch+=1,this.connectAttempt+=1;let r=this.takeTransportSubscription();this.clearPending();let s=this.cleanupTransport(r,true);this.setStatus("disconnected",false),this.report(t);for(let a of s)this.report(a);}takeTransportSubscription(){let e=this.unsubscribeTransport;return this.unsubscribeTransport=()=>{},this.hasTransportSubscription=false,e}cleanupTransport(e,t){let r=[];try{e();}catch(s){r.push(c("transport","Failed to unsubscribe from transport events",s));}if(!t)return r;try{let s=this.transport.disconnect();s&&s.catch(a=>{this.isDestroyed||this.report(c("transport","Transport disconnect failed",a));});}catch(s){r.push(c("transport","Transport disconnect failed",s));}return r}handleTransportEvent(e,t){if(this.isCurrent(e))switch(t.type){case "open":this.handleOpen(e);break;case "message":this.isOpen&&this.handleMessage(e,t.data);break;case "close":this.resetReplicaQueue(),this.isOpen=false,this.connectAttempt+=1,this.stopPresence(),this.clearPending(),this.setStatus("disconnected",false);break;case "error":this.failConnection(e,c("transport","Transport error",t.error));break;case "drain":this.isOpen&&this.flushPending();break;default:this.failConnection(e,new u("transport","Unknown transport event"));}}handleOpen(e){if(this.isOpen)return;let t=++this.openEpoch;if(this.replicaTail=Promise.resolve(),this.replicaBytes=0,this.updateBatch=null,this.syncHeld=typeof(this.asyncReplica??this.replica).applyUpdateChunks=="function"?[]:null,this.syncHeldBytes=0,this.syncJoinPending=false,this.syncRequestOwed=false,this.isOpen=true,this.clearPending(),this.setStatus("connected",false),!this.isCurrent(e)||!this.isOpen)return;if(this.asyncReplica){Promise.resolve().then(()=>{if(this.isCurrentOpen(e,t))return this.asyncReplica.encodeStateVector()}).then(a=>{this.isCurrentOpen(e,t)&&this.sendHandshake(e,m(a,"encodeStateVector"),t);}).catch(a=>{this.isCurrentOpen(e,t)&&this.failConnection(e,c("replica","Failed to encode replica state vector",a));});return}let r;try{r=m(this.replica.encodeStateVector(),"encodeStateVector");}catch(s){this.failConnection(e,c("replica","Failed to encode replica state vector",s));return}this.sendHandshake(e,r,t);}sendHandshake(e,t,r){if(this.isCurrentOpen(e,r)){try{this.sendFrame(q(m$1(t,{open:!0,chunked:this.syncHeld!==null}),this.maxFrameBytes));}catch(s){this.failConnection(e,c("protocol","Failed to encode collaboration handshake",s));return}if(n(t)&&this.isCurrentOpen(e,r)&&this.sendFullUpdate(e,r),!(!this.localUser||!this.isCurrentOpen(e,r))){try{this.sendFrame(u$1(this.maxFrameBytes));}catch(s){this.report(c("protocol","Failed to encode awareness query",s));}this.isCurrentOpen(e,r)&&(this.broadcastLocalAwareness(),this.isCurrentOpen(e,r)&&this.startPresence());}}}sendFullUpdate(e,t){let r=o=>{if(this.isCurrentOpen(e,t))try{this.sendFrame(s(o,this.maxFrameBytes));}catch(l){this.failConnection(e,c("protocol","Failed to encode collaboration handshake",l));}},s$1=o=>{this.isCurrentOpen(e,t)&&this.failConnection(e,c("replica","Failed to encode replica update",o));};if(this.asyncReplica){this.asyncReplica.encodeStateAsUpdate().then(o=>m(o,"encodeStateAsUpdate")).then(r,s$1);return}let a;try{a=m(this.replica.encodeStateAsUpdate(),"encodeStateAsUpdate");}catch(o){s$1(o);return}r(a);}handleMessage(e,t$1,r){let s=this.openEpoch,a;try{a=r??w(t$1,this.maxFrameBytes,this.maxMessagesPerFrame);}catch(o){this.failConnection(e,c("protocol","Invalid collaboration frame",o));return}if(this.asyncReplica&&!r){let o$1={connection:s,bytes:t$1.byteLength,remaining:0},l=false;for(let h of a){if(!this.isCurrentOpen(e,s))return;if(h.type==="update"&&this.syncHeld){if(!this.holdSyncUpdate(e,h.update))return}else if(Se(h)){if(!l){if(o$1.bytes>this.maxPendingBytes-this.replicaBytes){this.failConnection(e,new u("backpressure","Pending replica data exceeds the byte limit"));return}this.replicaBytes+=o$1.bytes,l=true;}o$1.remaining+=1,h.type==="sync-step-2"&&this.syncHeld&&(this.syncJoinPending=true);let d=h.type==="sync-step-2"?this.takeSyncHeld():[],p=h.type==="sync-step-1"&&this.defersSyncRequest()&&o(h.stateVector).open;p&&(this.syncRequestOwed=true),h.type==="update"&&this.asyncReplica.applyUpdateChunks?this.enqueueRemoteUpdate(e,o$1,h.update):this.enqueueReplicaMessages(e,o$1,[h],d,p);}else this.handleMessage(e,new Uint8Array,[h]);}return}for(let o of a){if(!this.isCurrent(e)||!this.isOpen)return;switch(o.type){case "sync-step-1":this.respondToSyncStep1(e,s,o.stateVector);break;case "sync-step-2":if(this.applySyncStep2(e,o.update)&&this.isCurrent(e)){if(this.setStatus("connected",true),this.localUser)try{this.sendFrame(u$1(this.maxFrameBytes));}catch(l){this.report(c("protocol","Failed to query awareness after sync",l));}this.sendOwedSyncRequest(e,s);}break;case "update":this.syncHeld?this.holdSyncUpdate(e,o.update):this.applyRemoteUpdate(e,o.update,true);break;case "awareness":{let l=[];try{let h=b$1(this.awarenessRecords,v$1(o.update,{trackedClientIds:this.awarenessRecords.keys(),localClientId:this.replica.clientId,onDiscard:d=>l.push(d)}),this.replica.clientId,C());this.setAwarenessRecords(h.records),h.peersChanged&&this.emitPeers();}catch(h){this.report(c("protocol","Failed to apply awareness update",h));}for(let h of l)this.report(c("protocol","Discarded over-limit awareness data",h));break}case "auth":this.failConnection(e,new u("protocol",o.reason?`Authentication denied: ${o.reason}`:"Authentication denied"));return;case "query-awareness":try{this.localUser?this.broadcastLocalAwareness():this.sendFrame(t([],this.maxFrameBytes));}catch(l){this.report(c("protocol","Failed to encode awareness response",l));}break}}}isCurrentOpen(e,t){return this.isCurrent(e)&&this.isOpen&&t===this.openEpoch}resetReplicaQueue(){this.openEpoch+=1,this.replicaTail=Promise.resolve(),this.replicaBytes=0,this.updateBatch=null,this.syncHeld=null,this.syncHeldBytes=0,this.syncJoinPending=false,this.syncRequestOwed=false,this.arrivalsInFlight.clear(),this.awarenessGenerations.clear();}enqueueReplicaMessages(e,t,r,s=[],a=false){let o$1=t.connection;if(!this.isCurrentOpen(e,o$1))return;this.updateBatch=null;let l=this.awarenessGeneration;this.arrivalsInFlight.set(l,(this.arrivalsInFlight.get(l)??0)+1);let h=this.replicaTail.then(async()=>{for(let d of r){if(!this.isCurrentOpen(e,o$1))return;try{if(d.type==="sync-step-1"){let p=this.asyncReplica,y=o(d.stateVector),ie=this.chunksAnswer(y.chunked,p)?ee(await p.encodeStateAsUpdateChunks(y.stateVector.slice(),this.syncChunkLimit()),"encodeStateAsUpdateChunks"):[m(await p.encodeStateAsUpdate(y.stateVector.slice()),"encodeStateAsUpdate")];if(!this.isCurrentOpen(e,o$1))return;this.sendSyncAnswer(e,ie,()=>this.isCurrentOpen(e,o$1)),y.open&&!a&&this.isCurrentOpen(e,o$1)&&await this.sendWorkerSyncRequest(e,o$1);}else if(d.type==="sync-step-2"||d.type==="update"){let p=d.type==="sync-step-2"?await te(this.asyncReplica,s,d.update):await this.asyncReplica.applyUpdate(d.update);if(!this.isCurrentOpen(e,o$1))return;if(d.type==="sync-step-2"){if(this.syncJoinPending=!1,this.setStatus("connected",!0),!this.isCurrentOpen(e,o$1))return;if(this.localUser)try{this.sendFrame(u$1(this.maxFrameBytes));}catch(y){this.report(c("protocol","Failed to query awareness after sync",y));}this.syncRequestOwed&&(this.syncRequestOwed=!1,await this.sendWorkerSyncRequest(e,o$1));}else this.applyTypingInference(p,l);}}catch(p){this.isCurrentOpen(e,o$1)&&this.failConnection(e,c("replica",d.type==="sync-step-1"?"Failed to encode replica update":"Failed to apply remote update",p));return}}}).finally(()=>{t.remaining-=r.length,o$1===this.openEpoch&&(t.remaining===0&&(this.replicaBytes-=t.bytes),this.settleArrival(l));});this.replicaTail=h.catch(()=>{});}enqueueRemoteUpdate(e,t,r){let s=t.connection;if(!this.isCurrentOpen(e,s))return;let a=this.awarenessGeneration;this.arrivalsInFlight.set(a,(this.arrivalsInFlight.get(a)??0)+1);let o={update:r,frame:t,arrival:a},l=this.updateBatch;if(l?.connection===s&&l.bytes+r.byteLength<=this.maxSyncBytes){l.entries.push(o),l.bytes+=r.byteLength;return}let h={connection:s,bytes:r.byteLength,entries:[o]};this.updateBatch=h;let d=this.replicaTail.then(async()=>{if(this.updateBatch===h&&(this.updateBatch=null),!this.isCurrentOpen(e,s))return;let p=this.asyncReplica;try{if(h.entries.length===1){let y=await p.applyUpdate(r);this.isCurrentOpen(e,s)&&this.applyTypingInference(y,a);}else await p.applyUpdateChunks(h.entries.map(y=>y.update));}catch(y){this.isCurrentOpen(e,s)&&this.failConnection(e,c("replica","Failed to apply remote update",y));}}).finally(()=>{for(let p of h.entries)p.frame.remaining-=1,s===this.openEpoch&&(p.frame.remaining===0&&(this.replicaBytes-=p.frame.bytes),this.settleArrival(p.arrival));});this.replicaTail=d.catch(()=>{});}respondToSyncStep1(e,t,r){let s=o(r),a;try{a=this.chunksAnswer(s.chunked,this.replica)?ee(this.replica.encodeStateAsUpdateChunks(s.stateVector.slice(),this.syncChunkLimit()),"encodeStateAsUpdateChunks"):[m(this.replica.encodeStateAsUpdate(s.stateVector.slice()),"encodeStateAsUpdate")];}catch(o){this.failConnection(e,c("replica","Failed to encode replica update",o));return}this.sendSyncAnswer(e,a,()=>this.isCurrentOpen(e,t)),!(!s.open||!this.isCurrentOpen(e,t))&&(this.defersSyncRequest()?this.syncRequestOwed=true:this.sendSyncRequest(e));}defersSyncRequest(){return this.syncHeld!==null&&this.syncChunkBytes!==void 0}sendOwedSyncRequest(e,t){!this.syncRequestOwed||!this.isCurrentOpen(e,t)||(this.syncRequestOwed=false,this.sendSyncRequest(e));}async sendWorkerSyncRequest(e,t){let r=m(await this.asyncReplica.encodeStateVector(),"encodeStateVector");this.isCurrentOpen(e,t)&&this.sendFrame(q(this.syncRequestVector(r),this.maxFrameBytes));}syncRequestVector(e){return this.syncHeld||this.syncJoinPending?m$1(e,{chunked:true}):e}sendSyncRequest(e){let t;try{t=m(this.replica.encodeStateVector(),"encodeStateVector");}catch(r){this.failConnection(e,c("replica","Failed to encode replica state vector",r));return}try{this.sendFrame(q(this.syncRequestVector(t),this.maxFrameBytes));}catch(r){this.failConnection(e,c("protocol","Failed to encode collaboration handshake",r));}}chunksAnswer(e,t){return this.syncChunkBytes!==void 0&&typeof t.encodeStateAsUpdateChunks=="function"&&e}syncChunkLimit(){return Math.max(1,Math.min(this.syncChunkBytes,j$1(this.maxFrameBytes)))}sendSyncAnswer(e,t,r$1){if(t.some(s=>k$1(s.byteLength)>this.maxFrameBytes)){this.failConnection(e,new u("protocol",`Failed to encode SyncStep2: Frame exceeds ${this.maxFrameBytes} bytes`));return}for(let s$1=0;s$1<t.length;s$1++){if(!r$1())return;let a;try{a=s$1===t.length-1?r(t[s$1],this.maxFrameBytes):s(t[s$1],this.maxFrameBytes);}catch(o){this.failConnection(e,c("protocol","Failed to encode SyncStep2",o));return}this.sendFrame(a);}}holdSyncUpdate(e,t){let r=t.byteLength+de;return r>this.maxSyncBytes-this.syncHeldBytes?(this.failConnection(e,new u("backpressure",`Initial sync exceeds ${this.maxSyncBytes} bytes`)),false):(this.syncHeld.push(t),this.syncHeldBytes+=r,true)}takeSyncHeld(){let e=this.syncHeld??[];return this.syncHeld=null,this.syncHeldBytes=0,e}applySyncStep2(e,t){let r=this.takeSyncHeld();this.arrivalInfers=false;try{return te(this.replica,r,t.slice()),!0}catch(s){return this.failConnection(e,c("replica","Failed to apply remote update",s)),false}finally{this.arrivalInfers=true;}}applyRemoteUpdate(e,t,r){this.arrivalInfers=r;try{let s=this.replica.applyUpdate(t.slice());return r&&this.applyTypingInference(s),!0}catch(s){return this.failConnection(e,c("replica","Failed to apply remote update",s)),false}finally{this.arrivalInfers=true;}}beginArrival(){let e=this.arrivalInfers,t=this.epoch,r=this.openEpoch,s=this.awarenessGeneration;this.arrivalsInFlight.set(s,(this.arrivalsInFlight.get(s)??0)+1);let a=false,o=l=>{a||(a=true,r===this.openEpoch&&(this.isCurrentOpen(t,r)&&l(),r===this.openEpoch&&this.settleArrival(s)));};return {settle:l=>o(()=>{e&&this.applyTypingInference(l,s);}),fail:l=>o(()=>this.failConnection(t,c("replica","Failed to apply remote update",l)))}}settleArrival(e){let t=this.arrivalsInFlight.get(e)-1;if(t>0?this.arrivalsInFlight.set(e,t):this.arrivalsInFlight.delete(e),this.arrivalsInFlight.size===0){this.awarenessGenerations.clear();return}let[r]=this.arrivalsInFlight.keys();for(let[s,a]of this.awarenessGenerations)a<=r&&this.awarenessGenerations.delete(s);}setAwarenessRecords(e){if(this.arrivalsInFlight.size>0&&e!==this.awarenessRecords){for(let[t,r]of e)r.clock!==this.awarenessRecords.get(t)?.clock&&this.awarenessGenerations.set(t,++this.awarenessGeneration);for(let t of this.awarenessRecords.keys())e.has(t)||this.awarenessGenerations.set(t,++this.awarenessGeneration);this.awarenessGenerations.size>1024&&(this.awarenessGenerations.clear(),this.awarenessFloor=this.awarenessGeneration);}this.awarenessRecords=e;}applyTypingInference(e,t){let r=we(e);if(!r||t!==void 0&&(t<this.awarenessFloor||(this.awarenessGenerations.get(r.clientId)??0)>t))return;let s=c$1(this.awarenessRecords,r,this.replica.clientId,C());this.awarenessRecords=s.records,s.peersChanged&&this.emitPeers();}forwardLocalUpdate(e){if(this.isDestroyed||!this.isOpen||!this.wantsConnection)return;let t=this.epoch,r;try{r=m(e,"Replica update");}catch(s){this.failConnection(t,c("replica","Invalid replica update",s));return}try{this.sendFrame(s(r,this.maxFrameBytes));}catch(s){this.failConnection(t,c("protocol","Failed to encode update",s));}}nextAwarenessClock(){if(Math.max(this.localClock,f+1)>=Number.MAX_SAFE_INTEGER)throw new RangeError("Awareness clock exceeds Number.MAX_SAFE_INTEGER");return this.localClock=Math.max(this.localClock+1,f+2),f=Math.max(f,this.localClock),this.localClock}encodeLocalAwareness(e,t$1,r){return t([{clientId:this.replica.clientId,clock:t$1,state:{user:e,cursor:r}}],this.maxFrameBytes)}broadcastLocalAwareness(){if(!this.localUser||!this.isOpen||this.isDestroyed||!this.wantsConnection)return;if(this.clearCursorBroadcastTimer(),Math.max(this.localClock,f+1)>=Number.MAX_SAFE_INTEGER){this.reportedClockExhaustion||(this.reportedClockExhaustion=true,this.report(new u("protocol","Awareness clock exceeds Number.MAX_SAFE_INTEGER")));return}let e=this.localUser,t=this.nextAwarenessClock(),r;try{r=this.encodeLocalAwareness(e,t,this.localCursor);}catch(s){let a=this.localCursor;if(this.localCursor=null,!a){this.report(c("protocol","Failed to encode local awareness",s));return}try{r=this.encodeLocalAwareness(e,t,null);}catch(o){this.report(c("protocol","Failed to encode local awareness",o));return}this.report(c("protocol","Dropped an unencodable presence cursor",s));}this.sendFrame(r),this.lastAwarenessSentAt=C();}scheduleCursorBroadcast(){if(!this.localUser||!this.isOpen||this.isDestroyed||!this.wantsConnection)return;let e=ye-(C()-this.lastAwarenessSentAt);if(e<=0){this.broadcastLocalAwareness();return}this.cursorBroadcastTimer||(this.cursorBroadcastTimer=setTimeout(()=>{this.cursorBroadcastTimer=null,!(!this.isOpen||this.isDestroyed||!this.wantsConnection)&&this.broadcastLocalAwareness();},e),k(this.cursorBroadcastTimer));}clearCursorBroadcastTimer(){this.cursorBroadcastTimer&&clearTimeout(this.cursorBroadcastTimer),this.cursorBroadcastTimer=null;}startPresence(){!this.localUser||!this.isOpen||this.isDestroyed||!this.wantsConnection||this.heartbeatTimer||this.expiryTimer||(this.heartbeatTimer=setInterval(()=>{this.broadcastLocalAwareness();},fe),this.expiryTimer=setInterval(()=>{let e=d(this.awarenessRecords,C(),me);this.setAwarenessRecords(e.records),e.peersChanged&&this.emitPeers();},be),k(this.heartbeatTimer),k(this.expiryTimer));}stopPresence(){this.clearCursorBroadcastTimer(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.expiryTimer&&clearInterval(this.expiryTimer),this.heartbeatTimer=null,this.expiryTimer=null;let e$1=e(this.awarenessRecords).length>0;this.setAwarenessRecords(new Map),this.awarenessGenerations.clear(),e$1&&this.emitPeers();}leaveFrame(){if(!this.localUser||!this.isOpen||this.isDestroyed||!this.wantsConnection||this.localClock>=Number.MAX_SAFE_INTEGER)return null;try{let e=this.localClock+1;return f=Math.max(f,e),{clock:e,frame:t([{clientId:this.replica.clientId,clock:e,state:null}],this.maxFrameBytes)}}catch{return null}}sendLeaveBestEffort(){if(!(!this.localUser||!this.isOpen||this.isDestroyed||!this.wantsConnection)){this.clearCursorBroadcastTimer();try{if(this.localClock>=Number.MAX_SAFE_INTEGER)throw new RangeError("Awareness clock exceeds Number.MAX_SAFE_INTEGER");let e=this.localClock+1;f=Math.max(f,e);let t$1=t([{clientId:this.replica.clientId,clock:e,state:null}],this.maxFrameBytes);this.transport.send(t$1.slice());}catch(e){this.report(c("transport","Failed to send awareness leave",e));}}}emitPeers(){let e=this.peers;for(let[t,r]of [...this.peerListeners])if(this.peerListeners.get(t)===r)try{r(e);}catch{}}sendFrame(e){if(!this.isOpen||this.isDestroyed||!this.wantsConnection)return;let t=this.epoch;if(this.pendingFrames.length>0){this.queueFrame(t,e);return}let r;try{r=this.transport.send(e.slice());}catch(s){this.failConnection(t,c("transport","Transport send failed",s));return}if(typeof r!="boolean"){this.failConnection(t,new u("transport","Transport send must return a boolean"));return}!r&&this.isCurrent(t)&&this.isOpen&&this.queueFrame(t,e);}queueFrame(e,t){if(t.byteLength>this.maxPendingBytes-this.queuedBytes){this.failConnection(e,new u("backpressure",`Pending collaboration data exceeds ${this.maxPendingBytes} bytes`));return}let r=t.slice();this.pendingFrames.push(r),this.queuedBytes+=r.byteLength;}flushPending(){if(!this.isFlushing){this.isFlushing=true;try{for(;this.isOpen&&!this.isDestroyed&&this.pendingFrames.length>0;){let e=this.epoch,t=this.pendingFrames[0],r;try{r=this.transport.send(t.slice());}catch(s){this.failConnection(e,c("transport","Transport send failed",s));return}if(typeof r!="boolean"){this.failConnection(e,new u("transport","Transport send must return a boolean"));return}if(!r||!this.isOpen||this.pendingFrames[0]!==t)return;this.pendingFrames.shift(),this.queuedBytes-=t.byteLength;}}finally{this.isFlushing=false;}}}clearPending(){this.pendingFrames.length=0,this.queuedBytes=0;}setStatus(e,t){if(this.connectionStatus===e&&this.isSynced===t)return;this.connectionStatus=e,this.isSynced=t;let r={status:e,synced:t};for(let[s,a]of [...this.statusListeners])if(this.statusListeners.get(s)===a)try{a(r);}catch{}}report(e){for(let[t,r]of [...this.errorListeners])if(this.errorListeners.get(t)===r)try{r(e);}catch{}}};export{u as a,Te as b,Fe as c,Ne as d,Ve as e,re as f};
@@ -0,0 +1 @@
1
+ var m=0;function S(){globalThis.__betterofficeEngineProgress?.();}function I(){m+=1,m%256===0&&S();}var k=new WeakMap;function F(o,t){k.set(o,t);}function T(o){return k.get(o)}function M(o,t){let i=T(o);return i!==void 0&&t.has(i)}var p=new Set(["commentRangeStart","commentRangeEnd","commentReference"]),A=new Set([...p,"bookmarkStart","bookmarkEnd","moveFromRangeStart","moveFromRangeEnd","moveToRangeStart","moveToRangeEnd"]),E=/\bw:id\s*=\s*["'](\d+)["']/g,R=new WeakSet,b=false;function O(o,t){return t&&R.add(o),b=true,o}function N(o,t){if(!b)return t();let i=[],f=0,g=new Set,a=(e,u=true)=>{typeof e!="number"||!Number.isInteger(e)||e<0||e>=2147483648||(g.add(e),u&&e>f&&(f=e));},c=(e,u,l)=>{if(typeof e=="string"){if(e.includes("w:id"))for(let[,r]of e.matchAll(E))a(Number(r));return}if(e===null||typeof e!="object"||ArrayBuffer.isView(e))return;if(R.has(e)){i.push({holder:u,key:l,info:e});return}if(Array.isArray(e)){e.forEach((r,w)=>c(r,e,w));return}let n=e;if(typeof n.author=="string"){let r=Array.isArray(n.content);a(n.id,!r),a(n.revisionId,!r);}else typeof n.type=="string"&&A.has(n.type)&&a(n.id,!p.has(n.type));for(let r of Object.keys(n))c(n[r],n,r);};if(c(o,{},""),i.length===0)return t();let s=f,d=new Map;for(let{info:e}of i)if(!d.has(e.id)){do if(s=s+1<2147483648?s+1:1,s===f)throw new RangeError("no Word revision ids left in range");while(g.has(s));d.set(e.id,s);}for(let e of i)e.holder[e.key]={...e.info,id:d.get(e.info.id)};try{return t()}finally{for(let e of i)e.holder[e.key]=e.info;}}export{S as a,I as b,F as c,T as d,M as e,O as f,N as g};
@@ -0,0 +1,2 @@
1
+ function F(){return {matchCase:false,matchWholeWord:false,useRegex:false}}function g(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function p(t,e){if(!t)return null;try{let n;e.useRegex?n=t:n=g(t),e.matchWholeWord&&(n=`\\b${n}\\b`);let r=e.matchCase?"g":"gi";return new RegExp(n,r)}catch{return null}}function l(t,e,n){if(!t||!e)return [];let r=[],o=e;n.matchCase||(o=e.toLowerCase());let c=h=>h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i;n.matchWholeWord?i=`\\b${c(o)}\\b`:i=c(o);let a=n.matchCase?"g":"gi",s=new RegExp(i,a),f;for(;(f=s.exec(t))!==null;)r.push({start:f.index,end:f.index+f[0].length}),f[0].length===0&&s.lastIndex++;return r}function y(t,e,n,r){let o=p(e,r);return o?t.replace(o,n):t}function C(t,e,n,r,o=0){let c=l(t,e,r),i=c.find(s=>s.start>=o)||c[0];return i?{content:t.substring(0,i.start)+n+t.substring(i.end),replaced:true,matchStart:i.start,matchEnd:i.start+n.length}:{content:t,replaced:false,matchStart:-1,matchEnd:-1}}function M(t){return t?t.totalCount===0?"No results":t.totalCount===1?"1 match":`${t.currentIndex+1} of ${t.totalCount} matches`:""}function O(t){return !t||t.trim()===""}function R(){return {currentMatchColor:"#FFFF00",otherMatchColor:"#FFFFAA"}}function u(t){if(!t||!t.content)return "";let e="";for(let n of t.content)n.type==="text"?e+=n.text||"":n.type==="tab"?e+=" ":n.type==="break"&&n.breakType==="textWrapping"&&(e+=`
2
+ `);return e}function d(t){if(!t||!t.content)return "";let e="";for(let n of t.content)if(n.type==="run")e+=u(n);else if(n.type==="hyperlink")for(let r of n.children||[])r.type==="run"&&(e+=u(r));return e}function E(t,e,n){if(!t||!e)return [];let r=[],o=t.package?.document||t.package?.document;if(!o||!o.content)return r;let c=0;for(let i of o.content)if(i.type==="paragraph"){let a=x(i,e,n,c);r.push(...a),c++;}else if(i.type==="table")for(let a of i.rows||[])for(let s of a.cells||[])for(let f of s.content||[])f.type;return r}function x(t,e,n,r){let o=[],c=d(t);if(!c)return o;let i=l(c,e,n);for(let a of i){let s=m(t,a.start);o.push({paragraphIndex:r,contentIndex:s.contentIndex,startOffset:s.offsetInContent,endOffset:s.offsetInContent+(a.end-a.start),text:c.substring(a.start,a.end)});}return o}function m(t,e){if(!t||!t.content)return {contentIndex:0,runIndex:0,offsetInContent:e};let n=0,r=0;for(let o of t.content){let c="";if(o.type==="run")c=u(o);else if(o.type==="hyperlink")for(let a of o.children||[])a.type==="run"&&(c+=u(a));let i=c.length;if(n+i>e)return {contentIndex:r,runIndex:r,offsetInContent:e-n};n+=i,r++;}return {contentIndex:Math.max(0,t.content.length-1),runIndex:Math.max(0,t.content.length-1),offsetInContent:0}}function w(t,e){if(!t||!e)return;let n=t.querySelector(`[data-paragraph-index="${e.paragraphIndex}"]`);n&&n.scrollIntoView({behavior:"smooth",block:"center"});}export{F as a,g as b,p as c,l as d,y as e,C as f,M as g,O as h,R as i,E as j,x as k,w as l};
@@ -0,0 +1 @@
1
+ import'./chunk-HPZFJGGM.mjs';export{a as preloadOpcWasm,c as rezipContainer,b as unzipContainer}from'./chunk-7WIUNGQW.mjs';import'./chunk-HGKSOBXK.mjs';import'./chunk-TTRUPDAB.mjs';
@@ -0,0 +1,4 @@
1
+ import {m}from'./chunk-BR5BFOHF.mjs';import {j,g,h,f}from'./chunk-KXIGXLFA.mjs';import {d}from'./chunk-N5RE2S3U.mjs';import {c,d as d$1,a}from'./chunk-ETDMQ5GE.mjs';import {e,g as g$1}from'./chunk-IHETKRDA.mjs';import {b}from'./chunk-TTRUPDAB.mjs';function nr(e,r,t){if(!r)return [];let n=t?.caseSensitive??false,o=n?r:r.toLowerCase(),i=t?.limit??20,a=[];for(let s of e.storyIds().filter(c=>c==="body"||c.startsWith("body:")))for(let c of e.paragraphs(s)){if(a.length>=i)return a;let p=n?c.text:c.text.toLowerCase(),l=p.indexOf(o);l<0||p.indexOf(o,l+1)>=0||a.push({paraId:c.paraId,match:c.text.slice(l,l+r.length),before:c.text.slice(Math.max(0,l-40),l),after:c.text.slice(l+r.length,l+r.length+40)});}return a}function ir(e,r,t,n){let o=[],i=e.paragraphs("body");for(let a=0;a<i.length;a+=1){let s=i[a];if(s.text)for(let c of d(s.text,t,n)){let p={story:"body",paraId:s.paraId,offset:c.start},l={story:"body",paraId:s.paraId,offset:c.end},u=r(p),b=r(l);u==null||b==null||u>=b||o.push({paragraphIndex:a,contentIndex:0,startOffset:c.start,endOffset:c.end,text:s.text.slice(c.start,c.end),displayFrom:u,displayTo:b,yrsRange:{story:"body",start:{paraId:s.paraId,offset:c.start},end:{paraId:s.paraId,offset:c.end}}});}}return o}function K(e,r){let t=0,n=r.map(o=>{let i={paraId:o.paraId,length:Math.max(0,Math.trunc(o.length)),displayStart:t};return t+=i.length+2,i});return {story:e,paragraphs:n}}function B(e,r){let t=e.paragraphs.find(n=>n.paraId===r.paraId);return !t||r.story!==e.story?e.paragraphs[0]?.displayStart??0:t.displayStart+1+Math.min(Math.max(0,r.offset),t.length)}function pr(e,r){if(e.paragraphs.length===0)return null;let t=Math.max(0,Math.trunc(r)),n=e.paragraphs[0];for(let o of e.paragraphs){if(o.displayStart>t)break;n=o;}return {story:e.story,paraId:n.paraId,offset:Math.min(Math.max(0,t-(n.displayStart+1)),n.length)}}function ur(e,r,t){return B(e,r)-B(e,t)}function hr(e,r,t){let n=e.paragraphSpans(r.story),o=n.findIndex(s=>s.paraId===r.paraId);if(o<0)return null;let i=r.offset;if(t==="forward"&&i===n[o].length&&(o+=1,i=0,o===n.length))return null;let a=0;for(let s of e.paragraphSegments(r.story,[o])[0]??[]){let c=s.kind==="text"?s.text.length:1;if(s.kind==="embed"&&s.embedKind==="table"&&(t==="backward"&&i===a+c||i===a)){if(t==="forward"||!Array.isArray(s.payload.rows))return r;let p=j(s.payload).anchors.at(-1),l=p&&e.paragraphSpans(p.story).at(-1);return p&&l?{story:p.story,paraId:l.paraId,offset:l.length}:r}if(a+=c,a>i)break}return null}var xr=2;function Le(e){return e?.paragraphs.some(r=>r.inlines?.some(t=>"image"in t))??false}var Oe=1e4,Ee=1e3,ce=1e6,ue=8,de=64*1024*1024,Ne=/^data:image\/[a-z0-9.+-]+;base64,[a-z0-9+/]+={0,2}$/iu,ze=new Set(["rId","_kind","id","embedId","docPrId","drawingId"]);function fe(e){return Object.fromEntries(Object.entries(e).filter(([r])=>!ze.has(r)))}function U(e){return S(e)&&N(e)&&!Object.hasOwn(e,"_kind")&&typeof e.src=="string"&&e.src.length<=de&&Ne.test(e.src)&&["widthEmu","heightEmu"].every(r=>e[r]===void 0||typeof e[r]=="number"&&Number.isFinite(e[r])&&e[r]>0)}var pe=/[\n\r\u000B\u2028\u2029]/u;function S(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;let r=Object.getPrototypeOf(e);return r===Object.prototype||r===null}function N(e,r=0){return r>32?false:e===null||typeof e=="string"||typeof e=="boolean"?true:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.every(t=>N(t,r+1)):S(e)&&Object.values(e).every(t=>N(t,r+1))}function L(e){return e===void 0||S(e)&&N(e)}function Ge(e){let r={cells:Oe,text:ce,media:de},t=(s,c)=>typeof s!="string"||!c&&s===""||pe.test(s)?false:(r.text-=s.length,r.text>=0),n=(s,c)=>{let p=s[c];return p==null?1:typeof p!="number"||!Number.isInteger(p)||p<1||p>1e3?null:p},o=s=>{if(s===void 0)return true;if(!S(s)||!N(s))return false;let c=d=>d==null||typeof d=="boolean";if(!c(s.bold)||!c(s.italic))return false;let p=s.underline;if(p!=null&&typeof p!="boolean"&&!(S(p)&&(p.style===void 0||typeof p.style=="string")&&(p.color===void 0||typeof p.color=="string")))return false;let l=s.strike;if(l!=null&&typeof l!="boolean"&&!(S(l)&&(l.double===void 0||typeof l.double=="boolean")))return false;let u=s.color;if(u!=null){if(!S(u))return false;let d=typeof u.rgb=="string",y=typeof u.themeColor=="string";if(d===y||u.rgb!==void 0&&!d||u.themeColor!==void 0&&!y)return false}if(s.highlight!==void 0&&s.highlight!==null&&typeof s.highlight!="string")return false;let b=s.fontSize;if(b!=null&&(typeof b!="number"||!Number.isFinite(b)||b<=0))return false;let h=s.fontFamily;if(h!=null&&!(S(h)&&typeof h.ascii=="string"&&(h.hAnsi===void 0||typeof h.hAnsi=="string")))return false;let f=s.other;return !(f!==void 0&&!(S(f)&&!("ins"in f)&&!("del"in f)&&!("hyperlink"in f)))},i=(s,c)=>{if(!S(s)||!L(s.attributes))return false;switch(s.kind){case "text":return t(s.text,false)&&o(s.format);case "tab":case "break":return L(s.payload);case "pilcrow":return L(s.properties);case "table":return a(s.table,c+1);default:return false}},a=(s,c)=>{if(c>ue||!S(s)||!L(s.tblPr)||s.tblPr===void 0||!Array.isArray(s.grid)||!s.grid.every(f=>typeof f=="number"&&Number.isFinite(f)&&f>0)||!Array.isArray(s.rows)||s.rows.length===0||s.rows.length>1e3||!s.rows.every(f=>S(f)&&f.trPr!==void 0&&L(f.trPr)&&Array.isArray(f.cells)&&f.cells.length<=1e3&&f.cells.every(d=>{if(!S(d)||d.tcPr===void 0||!L(d.tcPr))return false;let y=d.tcPr;if(n(y,"rowspan")===null||n(y,"colspan")===null||d.shading!==void 0&&(typeof d.shading!="string"||!/^[0-9a-f]{6}$/iu.test(d.shading))||--r.cells<0||!Array.isArray(d.content)||d.content.length===0)return false;let g=d.content.at(-1);return S(g)&&g.kind==="pilcrow"&&d.content.every(w=>i(w,c))})))return false;let l=s.rows,u=l.map(()=>[]),b=0,h=0;for(let f=0;f<l.length;f+=1){let d=0;for(let y of l[f].cells){for(;u[f][d];)d+=1;let g=n(y.tcPr,"rowspan"),w=n(y.tcPr,"colspan");if(f+g>l.length||d+w>1e3)return false;for(let R=f;R<f+g;R+=1)for(let m=d;m<d+w;m+=1){if(u[R][m])return false;u[R][m]=true;}h+=1,d+=w,b=Math.max(b,d);}}if(h===0||s.grid.length>0&&s.grid.length!==b)return false;for(let f=0;f<l.length;f+=1)if(l[f].cells.length===0){for(let d=0;d<b;d+=1)if(!u[f][d])return false}return true};return !S(e)||!Array.isArray(e.paragraphs)||e.paragraphs.length===0||e.paragraphs.length>Ee?false:e.paragraphs.every(s=>{if(!S(s)||!t(s.text,true)||!(s.tables===void 0||Array.isArray(s.tables)&&s.tables.every(p=>a(p,1))))return false;if(s.inlines===void 0)return true;if(!Array.isArray(s.inlines)||s.inlines.length>ce)return false;let c="";for(let p of s.inlines){if(!S(p)||Object.keys(p).length!==1)return false;if("text"in p){if(typeof p.text!="string"||p.text===""||pe.test(p.text))return false;c+=p.text;}else if("image"in p){if(!U(p.image)||(r.media-=p.image.src.length,r.media<0))return false}else return false}return c===s.text})}function O(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function Ve(e){let r=O(e);return r&&Object.keys(r).length>0?{...r}:void 0}function ge(e){let r=O(e);return !r||!Array.isArray(r.rows)?null:{...O(r.tblPr)?{tblPr:r.tblPr}:{},...Array.isArray(r.grid)?{grid:r.grid}:{},rows:r.rows}}function Be(e){if(!e||!Array.isArray(e.rows)||e.rows.length===0)throw new Error("Table payload holds no rows");return e.rows}function Ke(e,r,t){let n=[];for(let o of e.storySegments(r))if(o.kind==="text"){if(o.text===""||o.attributes?.del!=null)continue;n.push({kind:"text",text:o.text,...Object.keys(o.attributes).length>0?{attributes:{...o.attributes}}:{}});}else if(o.kind==="pilcrow")n.push({kind:"pilcrow",...Object.keys(o.properties).length>0?{properties:{...o.properties}}:{},...Object.keys(o.attributes).length>0?{attributes:{...o.attributes}}:{}});else if(o.embedKind==="tab"||o.embedKind==="break")n.push({kind:o.embedKind,...Object.keys(o.payload).length>0?{payload:{...o.payload}}:{},...Object.keys(o.attributes).length>0?{attributes:{...o.attributes}}:{}});else if(o.embedKind==="table")n.push({kind:"table",table:_(e,o.payload,void 0,t),...Object.keys(o.attributes).length>0?{attributes:{...o.attributes}}:{}});else for(let i of _e(e,o,t))n.push(i);return n}function _e(e,r,t){let n=[],o=f(e,r.embedKind,r.payload);t&&!me(e,r.embedKind,r.payload,o)&&t();let i=o.split(`
2
+ `),a=Object.keys(r.attributes).length>0?{...r.attributes}:void 0;return i.forEach((s,c)=>{c>0&&n.push({kind:"pilcrow"}),s!==""&&n.push({kind:"text",text:s,...a?{attributes:{...a}}:{}});}),n}function he(e,r,t,n=0){if(n>ue)return false;let o=(i,a)=>{switch(i){case "tab":case "break":case "pilcrow":return true;case "sdt":case "blockSdt":{let s=O(a);return s!==null&&he(e,i,s,n+1)}default:return false}};return r==="blockSdt"?typeof t.story=="string"&&e.storySegments(t.story).every(i=>i.kind==="text"||i.kind==="pilcrow"||o(i.embedKind,i.payload)):Array.isArray(t.content)&&t.content.every(i=>S(i)&&(i.kind==="text"?typeof i.text=="string":o(i.kind,i.payload)))}function me(e,r,t,n){switch(r){case "bookmark":case "bookmarkStart":case "bookmarkEnd":case "commentAnchor":case "commentReference":case "commentRangeStart":case "commentRangeEnd":case "rangeMarker":case "rangeStart":case "rangeEnd":case "permStart":case "permEnd":case "moveFromRangeStart":case "moveFromRangeEnd":case "moveToRangeStart":case "moveToRangeEnd":return true;case "field":return t.modelKind==="commentReference"||n!=="";case "sdt":case "blockSdt":return n!==""&&he(e,r,t);case "math":return n!=="";case "shape":case "chart":case "opaqueDrawing":case "horizontalRule":case "noteRef":case "pageBreak":case "columnBreak":case "opaque":return false;default:return false}}function $e(e){let r=typeof e.backgroundColor=="string"?e.backgroundColor.replace(/^#+/,""):null;return r&&/^[0-9a-f]{6}$/iu.test(r)?r:void 0}function _(e,r,t,n){let o=Be(r),i={rows:o},{anchors:a,columns:s}=j(i),c=o.length,p={top:0,bottom:c-1,left:0,right:Math.max(s-1,0)},l=(m,x)=>Math.min(Math.max(m,0),Math.max(x,0)),u=t?{top:l(Math.min(t.top,t.bottom),c-1),bottom:l(Math.max(t.top,t.bottom),c-1),left:l(Math.min(t.left,t.right),s-1),right:l(Math.max(t.left,t.right),s-1)}:{...p};for(;;){let m=`${u.top}:${u.bottom}:${u.left}:${u.right}`;for(let x of a)x.row<=u.bottom&&x.row+x.rowspan-1>=u.top&&x.column<=u.right&&x.column+x.colspan-1>=u.left&&(u={top:Math.min(u.top,x.row),bottom:Math.max(u.bottom,x.row+x.rowspan-1),left:Math.min(u.left,x.column),right:Math.max(u.right,x.column+x.colspan-1)});if(`${u.top}:${u.bottom}:${u.left}:${u.right}`===m)break}let{top:b,bottom:h,left:f,right:d}=u,y=new Map;for(let m of a)if(m.row>=b&&m.row+m.rowspan-1<=h&&m.column>=f&&m.column+m.colspan-1<=d){let x=y.get(m.row)??[];x.push(m),y.set(m.row,x);}if(y.size===0)throw new Error("Table selection holds no cells");let g=[];for(let m=b;m<=h;m+=1){let x=(y.get(m)??[]).sort((A,I)=>A.column-I.column);g.push({trPr:Ve(o[m]?.trPr)??{},cells:x.map(A=>{let I=o[A.row]?.cells?.find(Y=>Y?.story===A.story),G={...O(I?.tcPr)??{}},C=$e(G);return C!==void 0&&delete G.backgroundColor,{tcPr:{...G,rowspan:A.rowspan,colspan:A.colspan},content:Ke(e,A.story,n),...C!==void 0?{shading:C}:{}}})});}let w=Array.isArray(r.grid)&&r.grid.every(m=>typeof m=="number"&&Number.isFinite(m)&&m>0)?r.grid.slice(f,d+1):[],R={...O(r.tblPr)??{}};return (f>0||d<s-1)&&R.widthType==="dxa"&&typeof R.width=="number"&&w.length>0&&(R.width=w.reduce((m,x)=>m+x,0)),{tblPr:R,grid:w,rows:g}}function wr(e,r,t){let n=e.tablePayload(r.story,r.tableIndex);if(!n)throw new Error(`Table ${r.tableIndex} was not found in story ${r.story}`);let o=ge(n);if(!o)throw new Error(`Table ${r.tableIndex} in story ${r.story} holds no rows`);return _(e,o,t)}function kr(e,r){if("cells"in r){let{anchor:d,head:y}=r.cells,g$1=ge(e.tablePayload(d.story,d.tableIndex)),w={top:Math.min(d.row,y.row),bottom:Math.max(d.row,y.row),left:Math.min(d.column,y.column),right:Math.max(d.column,y.column)};return {text:g$1?g(e,g$1,w).join(`
3
+ `):"",fragment:g$1?{paragraphs:[{tables:[_(e,g$1,w)],text:""}]}:null}}let t=Math.min(r.from,r.to),n=Math.max(r.from,r.to),o=h(e,r.story,t,n),i=[],a={tables:[],text:"",inlines:[]},s=false,c=false,p=false,l=()=>{i.push({...a.tables.length>0?{tables:a.tables}:{},text:a.text,...a.inlines.some(d=>"image"in d)?{inlines:a.inlines}:{}}),a={tables:[],text:"",inlines:[]};},u=d=>{d!==""&&(a.text+=d,a.inlines.push({text:d}));},b=d=>{let y=d.split(`
4
+ `);u(y[0]??"");for(let g of y.slice(1))c=true,l(),u(g);},h$1=0;for(let d of e.storySegments(r.story)){let y=h$1;if(h$1+=d.kind==="text"?d.text.length:1,!(h$1<=t||y>=n))if(d.kind==="text")u(d.text.slice(Math.max(t,y)-y,Math.min(n,h$1)-y));else if(d.kind==="pilcrow")c=true,l();else if(d.embedKind==="table")a.inlines.length>0&&l(),a.tables.push(_(e,d.payload,void 0,()=>{p=true;})),s=true;else if(d.embedKind==="image"){let g=fe(d.payload),w=g.src;if(g.src=typeof w=="string"&&w.startsWith("media:")?e.mediaDataUrl?.(w):w,!U(g))throw new Error("Picture clipboard media is unavailable or invalid");a.inlines.push({image:g}),s=true;}else if(d.embedKind==="tab")u(" ");else if(d.embedKind==="break")c=true,l();else {let g=f(e,d.embedKind,d.payload);me(e,d.embedKind,d.payload,g)||(p=true),b(g);}}(c||a.tables.length>0||a.inlines.length>0)&&l();let f$1=s?{paragraphs:i}:null;if(f$1&&Le(f$1)){if(p)throw new Error("Picture selection contains unsupported clipboard objects");if(!Ge(f$1))throw new Error("Clipboard fragment exceeds the supported size or shape")}return {text:o,fragment:f$1}}function Rr(e,r,t,n){for(let i of t.paragraphs){for(let a of i.tables??[])e.validateTableFragment(a);for(let a of i.inlines??[])if("image"in a&&!U(a.image))throw new Error("Invalid clipboard picture")}let o={story:r.story,paraId:r.start.paraId,offset:r.start.offset};if(r.start.paraId!==r.end.paraId||r.start.offset!==r.end.offset){let i=e.deleteRange(r,n);if(!i.range)throw new Error("Delete receipt lacks range");o={story:i.range.story,paraId:i.range.start.paraId,offset:i.range.start.offset};}return t.paragraphs.forEach((i,a)=>{if(a>0){let s=e.splitParagraph(o,n);o={story:o.story,paraId:s.secondParaId,offset:0};}for(let s of i.tables??[])o=e.insertTableFragment(o,s,n).after;for(let s of i.inlines??(i.text===""?[]:[{text:i.text}])){let c="image"in s?e.insertImage(o,fe(s.image),n):e.insertText(o,s.text,n);if(!c.range)throw new Error("Clipboard insertion receipt lacks range");o={story:c.range.story,...c.range.end};}}),o}function Tr(e,r,t){if(e.version()!==t)return null;let n=c(e),o=e.listRevisions(),i=d$1(o,n);return {comments:r.map(a=>{try{return {id:a,anchors:e.resolveComment(a).map(s=>({start:n.storyOffsetToDisplayPoint(s.story,s.start),end:n.storyOffsetToDisplayPoint(s.story,s.end)}))}}catch{return {id:a,anchors:[]}}}),revisions:o.map(a$1=>({key:`revision-${a(a$1.revisionId)}`,start:n.locToDisplayPoint({story:a$1.story,...a$1.range.start})})),trackedChanges:{entries:i.entries,commentToRevision:[...i.commentToRevision]}}}function vr(e,r,t,n){let o=c(e),i=new Map;for(let l of e.listRevisions()){if(n.has(l.revisionId)||i.has(l.revisionId))continue;let u=o.locToDisplayPoint({story:l.story,...l.range.start});u&&!u.hfRid&&i.set(l.revisionId,u.position);}let a=[...i].sort((l,u)=>l[1]-u[1]);if(!a.length)return null;let s=r?[r.anchor,r.focus].map(l=>o.locToDisplayPoint(l)):[],c$1=s.length&&s.every(l=>l&&!l.hfRid)?s.map(l=>l.position):null;return {revisionId:(t==="next"?a.find(([,l])=>l>(c$1?Math.max(...c$1):-1))??a[0]:[...a].reverse().find(([,l])=>l<(c$1?Math.min(...c$1):-1))??a.at(-1))[0]}}function Yr(e,r){if(e.version()!==r)return null;let t=new Map(e.headings("body").map(a=>[a.paraId,a.heading.outlineLevel])),n=[];if(t.size===0)return n;let o=c(e),i=[];for(let a of e.storySegments("body")){if(a.kind==="text"){i.push(a.text);continue}if(a.kind!=="pilcrow")continue;let s=t.get(a.paraId),c=s==null?"":i.join("").trim();if(i.length=0,s==null||!c)continue;let p=o.locToDisplayPoint({story:"body",paraId:a.paraId,offset:0})?.position;p!=null&&n.push({story:"body",paraId:a.paraId,text:c,level:s,position:p});}return n}function Fr(e,r,t,n){let o=t*n;return {x:e.x*o,y:e.y*o,width:Math.max(1,r.width*t),height:e.height*o}}function Cr(e,r){if(!Number.isSafeInteger(e.frameEpoch)||e.frameEpoch!==r.frameEpoch)return null;let t=e.caretRect;return t?!Number.isInteger(t.pageIndex)||t.pageIndex<0||!Number.isFinite(t.x)||!Number.isFinite(t.y)||!Number.isFinite(t.height)||t.height<0||!/^[1-9]\d*$/u.test(t.pageId)?null:r.pages[t.pageIndex]?.pageId.toString()===t.pageId?e:null:e}function ye(e){if(!Array.isArray(e.content))return 2;let r=2;for(let t of e.content){if(!t||typeof t!="object"||Array.isArray(t))continue;let n=t;n.kind==="text"?r+=typeof n.text=="string"?n.text.length:0:n.kind!=="sdt"?r+=1:r+=n.payload&&typeof n.payload=="object"&&!Array.isArray(n.payload)?ye(n.payload):2;}return r}function xe(e,r){let t=0;for(let[n,o]of r??[]){if(n>=e)break;t+=o-1;}return e+t}function Xe(e,r){let t=0;for(let[n,o]of r){let i=n+t;if(e<=i)break;if(e<i+o)return e-i<i+o-e?n:n+1;t+=o-1;}return e-t}function we(e){let r=new Map(Object.entries(e).map(([t,n])=>{let o=new Map;for(let i of n.paragraphs)o.has(i.paraId)||o.set(i.paraId,i);return [t,{contentStart:n.contentStart,paragraphs:o}]}));return {positionForLoc:t=>{let n=r.get(t.story),o=n?.paragraphs.get(t.paraId);return !n||!o?null:n.contentStart+o.displayStart+1+Math.min(xe(Math.max(0,t.offset-o.leading),o.controls),o.length)}}}function ke(e,r,t){return e.hasStory(r)?new J(e,r,t):null}function Nr(e$1,r,t){let n="body";if(typeof e$1!="number")switch(e$1.region){case "header":case "footer":if(!e$1.rId)return null;n=e(t,e$1.rId);break;case "footnote":case "endnote":if(e$1.noteId===void 0)return null;n=`${e$1.region==="footnote"?"fn":"en"}:${e$1.noteId}`;break}let o=typeof e$1=="number"?e$1:e$1.position,i=r(n);return !i||!Number.isFinite(o)||o<0||o>i.size?null:i.targetAt(o)}var J=class{constructor(r,t,n){b(this,"rootStory",t);b(this,"stories",new Map);b(this,"nodes",new Map);b(this,"tables",[]);b(this,"blockBoundaries",new Map);b(this,"source");b(this,"paragraphsById",new Map);this.source=n??{segments:o=>r.storySegments(o)},this.buildStory(t,0,0);}get size(){return this.stories.get(this.rootStory)?.size??0}nodeAt(r){return this.nodes.get(r)??null}allTables(){return this.tables}tableAtPosition(r){let t=null;for(let n of this.tables)r<n.start||r>n.start+n.nodeSize||(!t||n.nodeSize<t.nodeSize)&&(t=n);return t}tableAtStart(r){return this.tables.find(t=>t.start===r)??null}tableStartForLoc(r){return this.stories.get(r.story)?.tables.find(t=>t.tableIndex===r.tableIndex)?.start??null}cellPosition(r,t,n){let o=this.tableAtStart(r);return o?o.cells.find(a=>a.row<=t&&t<a.row+a.rowspan&&a.column<=n&&n<a.column+a.colspan)?.start??null:null}targetAt(r){let t=this.stories.get(this.rootStory)??null;for(let n of this.stories.values())r>=n.contentStart&&r<=n.contentStart+n.size&&(!t||n.depth>t.depth)&&(t=n);return {story:t?.story??this.rootStory,displayPosition:t?this.inputPositionAt(t,r):0,...t?.cell?{cell:t.cell}:{}}}positionForLoc(r){let t=this.stories.get(r.story),n=t?this.paragraphIndex(t).get(r.paraId):void 0;return !t||!n?null:t.contentStart+n.displayStart+1+Math.min(xe(Math.max(0,r.offset-n.leading),n.controls),n.length)}blockBoundaryAt(r){return this.blockBoundaries.get(r)??null}setBlockBoundary(r,t){this.blockBoundaries.has(r)||this.blockBoundaries.set(r,t);}paragraphIndex(r){let t=this.paragraphsById.get(r);if(!t){t=new Map;for(let n of r.paragraphs)t.has(n.paraId)||t.set(n.paraId,n);this.paragraphsById.set(r,t);}return t}bookmarkPosition(r){for(let t of this.stories.values())for(let n of t.paragraphs){let i=this.nodes.get(t.contentStart+n.displayStart)?.attrs.bookmarks;if(Array.isArray(i)&&i.some(a=>a!=null&&typeof a=="object"&&String(a.name??"")===r))return t.contentStart+n.displayStart}return null}buildStory(r,t,n,o){let i=this.stories.get(r);if(i)return i;let a={story:r,contentStart:t,size:0,depth:n,cell:o,paragraphs:[],tables:[]};this.stories.set(r,a);let s=this.source.segments(r),c=0,p=0,l=0,u=[],b=0,h=0,f=0,d=0,y=[];for(let g of s){if(g.kind==="text"){p+=g.text.length,l+=g.text.length;continue}if(g.kind==="pilcrow"){let m=p+2,x=t+h,A={kind:"paragraph",start:x,nodeSize:m,attrs:{...g.properties,paraId:g.paraId},story:r};this.nodes.set(x,A);for(let I of y)this.setBlockBoundary(I.start,{story:r,paraId:g.paraId,offset:I.offset}),this.setBlockBoundary(I.start+I.size,{story:r,paraId:g.paraId,offset:I.offset+1});y=[],a.paragraphs.push({paraId:g.paraId,displayStart:h,inputStart:f,length:p,leading:b,controls:u}),f+=l+2+b,c=h+m,h=c,p=0,l=0,u=[],b=0;continue}if(g.embedKind==="table"){let m=this.buildTable(g,r,d,t+c,n);a.tables.push(m),this.tables.push(m),this.nodes.set(m.start,m),y.push({start:m.start,size:m.nodeSize,offset:b}),d+=1,c+=m.nodeSize,h=c,b+=1;continue}if(g.embedKind==="blockSdt"){let m=String(g.payload.story??`${r}:sdt0`),x=t+c,A=this.buildStory(m,x+1,n+1,o),I={kind:"blockSdt",start:x,nodeSize:A.size+2,attrs:g.payload,story:r};this.nodes.set(x,I),y.push({start:x,size:I.nodeSize,offset:b}),c+=I.nodeSize,h=c,b+=1;continue}if((g.embedKind==="pageBreak"||g.embedKind==="columnBreak")&&p===0){let m={kind:g.embedKind,start:t+c,nodeSize:1,attrs:g.payload,story:r};this.nodes.set(m.start,m),y.push({start:m.start,size:m.nodeSize,offset:b}),c+=1,h=c,b+=1;continue}let w=t+h+1+p,R=g.embedKind==="sdt"?ye(g.payload):1;this.nodes.set(w,{kind:g.embedKind,start:w,nodeSize:R,attrs:{...g.payload,...g.attributes},story:r}),g.embedKind==="sdt"&&u.push([l,R]),p+=R,l+=1;}return a.size=Math.max(c,h+(p>0?p+2:0)),a}inputPositionAt(r,t){let n=Math.max(0,t-r.contentStart),o=r.paragraphs[0];for(let a of r.paragraphs){if(a.displayStart>n)break;o=a;}if(!o)return 0;let i=Math.min(Math.max(0,n-o.displayStart),o.length+1);return o.inputStart+o.leading+(i===0?0:1+Xe(i-1,o.controls))}buildTable(r,t,n,o,i){let a=Array.isArray(r.payload.rows)?r.payload.rows:[],s=Array.from({length:a.length},()=>[]),c=[],p=0;return a.forEach((l,u)=>{let b=o+1+p,h=Array.isArray(l.cells)?l.cells:[],f=0,d=0;h.forEach((y,g)=>{for(;s[u]?.[d];)d+=1;let w=He(y.tcPr),R=be(w.rowspan),m=be(w.colspan),x=String(y.story??`${t}:t${n}:r${u}c${g}`),A=b+1+f,I={story:t,tableIndex:n,row:u,column:d},C=this.buildStory(x,A+1,i+1,I).size+2;c.push({row:u,column:d,rowspan:R,colspan:m,story:x,start:A,contentStart:A+1,nodeSize:C,attrs:w});for(let Y=u;Y<u+R;Y+=1){s[Y]??(s[Y]=[]);for(let H=d;H<d+m;H+=1)s[Y][H]=true;}f+=C,d+=m;}),p+=f+2;}),{kind:"table",start:o,nodeSize:p+2,attrs:r.payload,story:t,tableIndex:n,widthsTwips:Array.isArray(r.payload.grid)?r.payload.grid.filter(l=>typeof l=="number"):[],rowCount:a.length,cells:c}}};function He(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function be(e){return typeof e=="number"&&Number.isInteger(e)&&e>0?e:1}function Re(e,r,t,n="body",o){let i=o?o(t.story):e.hasStory(t.story)?K(t.story,e.paragraphSpans(t.story)):null;if(!i)return null;let a=t.story==="body"||t.story.startsWith("body:")?"body":n;return r(a)?.positionForLoc(t)??(t.story===a?B(i,t):null)}var Se=new WeakMap;function E(e,r){let t=Se.get(e);return t?.version!==r&&(t={version:r,spans:new Map,segments:new Map,views:new Map,anchors:new Map},Se.set(e,t)),t}function M(e,r,t){if(e.has(r))return e.get(r);let n=t();return e.set(r,n),n}function Ie(e,r){let t=E(e,r);return t.revisions??(t.revisions=e.listRevisions())}function Te(e,r,t){return M(E(e,r).segments,t,()=>e.storySegments(t))}function k(e,r){return {ok:false,failure:{code:e,message:r}}}function q(e){return e==="body"||e.startsWith("body:")}function z(e){return q(e)?"body":/^hf:[^:]+/.exec(e)?.[0]??null}var We=new Set(["table","blockSdt","pageBreak","columnBreak"]);function Ue(e,r){let t=[],n=0,o=0,i=[],a=true,s=0;for(let c of e){if(c.kind==="pilcrow"){t.push({index:t.length,paraId:c.paraId,inlineStart:s,rawLength:n,viewLength:o,spans:i}),s=0,n=0,o=0,i=[],a=true;continue}if(a&&c.kind==="embed"&&We.has(c.embedKind)){n+=1,s=n;continue}a=false;let p=c.kind==="text"?c.text.length:1;!(c.attributes[r==="accepted"?"del":"ins"]!=null)&&p>0&&(i.push({raw:n,view:o,length:p}),o+=p),n+=p;}return t}function ve(e,r){let t=new Map;for(let n of Ue(e,r))t.set(n.paraId,t.has(n.paraId)?null:n);return {byId:t}}function Q(e,r,t,n){let o=M(E(e,r).views,t,()=>new Map);return M(o,n,()=>ve(Te(e,r,t),n))}function Ye(e,r,t,n){return Q(e,r,t,"accepted").byId.get(n)?.inlineStart??0}function Z(e,r){let t=c=>{let p=e.byId.get(c);return p===null?k("ambiguous-target","The paragraph cannot be resolved uniquely"):p??k("missing-target","The paragraph no longer exists")},n=t(r.start.paraId);if("ok"in n)return n;let o=t(r.end.paraId);if("ok"in o)return o;if(!Number.isInteger(r.start.offset)||!Number.isInteger(r.end.offset)||r.start.offset<0||r.end.offset<0||r.start.offset>n.viewLength||r.end.offset>o.viewLength||n.index>o.index||n===o&&r.start.offset>r.end.offset)return k("missing-target","The range is outside the paragraph text");let i=(c,p,l)=>{let u=c.spans.find(b=>l?p>=b.view&&p<b.view+b.length:p>b.view&&p<=b.view+b.length);return u?u.raw+p-u.view:l?c.rawLength:c.inlineStart},a=i(n,r.start.offset,true),s=n===o&&r.start.offset===r.end.offset;return {ok:true,range:{start:{story:r.story,paraId:n.paraId,offset:a},end:{story:r.story,paraId:o.paraId,offset:s?a:i(o,r.end.offset,false)}}}}function Hr(e,r){return Z(ve(e,r.view),r)}function Pe(e,r,t){let n=E(e,t),o=M(n.anchors,JSON.stringify(r),()=>e.resolveParagraphAnchor(r));if(o.status==="missing")return k("missing-target","The paragraph no longer exists");if(o.status==="ambiguous")return k("ambiguous-target","The paragraph cannot be resolved uniquely");if(o.status==="unsupported"||o.anchor.kind!=="session"||z(o.anchor.story)===null)return k("unsupported","The paragraph has no display position");let{story:i,paraId:a}=o.anchor,s=M(n.spans,i,()=>e.paragraphSpans(i)).filter(c=>c.paraId===a);return s.length>1?k("ambiguous-target","The paragraph cannot be resolved uniquely"):s.length?{ok:true,loc:{story:i,paraId:a,offset:0},length:s[0].length}:k("missing-target","The paragraph no longer exists")}function Je(e,r,t,n){let o=t?m(t):void 0;return qe(e,r,o,n)}function qe(e,r,t,n){return t?(n??Ie(e,r)).filter(({revisionId:o,kind:i})=>i==="deletion"&&t[o]==="accepted"||i==="insertion"&&t[o]==="rejected").map(({story:o,range:i})=>({start:{story:o,...i.start},end:{story:o,...i.end}})):[]}function $(e,r,t,n=null,o){if(r.kind==="range"){if(r.version!==t)return k("stale-version","The document changed after that version");if(z(r.range.story)===null)return k("unsupported","The range has no display position");if(!e.hasStory(r.range.story))return k("missing-target","The story no longer exists");let f=Z(Q(e,t,r.range.story,r.range.view),r.range);return f.ok?{ok:true,ranges:[f.range],paragraph:{...f.range.start,offset:0}}:f}if(r.kind==="proposal"||r.kind==="revision"){let f=r.kind==="proposal"?n?.proposals.find(g=>g.id===r.id):null;if(r.kind==="proposal"&&!f)return k("unknown-proposal","The proposal is not registered in this document");let d=(o??Ie(e,t)).filter(g=>r.kind==="revision"?g.revisionId===r.revisionId:f.revisionIds.includes(g.revisionId));if(r.kind==="revision"&&!d.length)return k("missing-target","The revision no longer exists");let y=d.map(({story:g,range:w})=>({start:{story:g,...w.start},end:{story:g,...w.end}}));if(y.some(({start:g})=>f?!q(g.story):z(g.story)===null))return k("unsupported","The revision has no display position");if(f){let g=Pe(e,f.paragraph,t);return g.ok&&!q(g.loc.story)?k("unsupported","The paragraph has no display position"):g.ok?{ok:true,ranges:y,paragraph:g.loc}:g}return {ok:true,ranges:y,paragraph:{...y[0].start,offset:0}}}let i=Pe(e,r.paragraph,t);if(!i.ok)return i;if(r.kind==="paragraph")return {ok:true,ranges:[{start:i.loc,end:{...i.loc,offset:i.length}}],paragraph:i.loc};if(!r.text)return k("missing-target","The search text is empty");let a=r.occurrence??"first";if(a!=="first"&&a!=="all"&&(!Number.isInteger(a)||a<1))return k("missing-target","The occurrence must be first, all, or a positive integer");let{story:s,paraId:c}=i.loc,p=e.findText({text:r.text,within:{kind:"paragraph",story:s,paraId:c},view:"accepted",limit:1e4});if(!p.ok){let{code:f,message:d}=p.failure;return k(f==="stale-version"||f==="missing-target"||f==="ambiguous-target"?f:"unsupported",d)}let l=[];for(let{range:f}of [...p.matches].sort((d,y)=>d.range.start.offset-y.range.start.offset))f.start.offset>=(l.at(-1)?.end.offset??0)&&l.push(f);let u=a==="all"?l:l.slice(a==="first"?0:a-1,a==="first"?1:a);if(p.truncated&&(a==="all"||!u.length))return k("unsupported","The search returned too many matches");if(!u.length)return k("missing-target",`The requested search occurrence (${a}) is unavailable`);let b=Q(e,t,s,"accepted"),h=[];for(let f of u){let d=Z(b,f);if(!d.ok)return d;h.push(d.range);}return {ok:true,ranges:h,paragraph:i.loc}}var Ae=new WeakMap;function De(e){let r=Ae.get(e);return r===void 0&&(r=JSON.stringify(e.proposals.map(({id:t,revisionIds:n,paragraph:o})=>[t,n,o])),Ae.set(e,r)),r}function Me(e,r,t="body"){let n=new Map,o=new Map,i=l=>M(n,l,()=>{if(!e.hasStory(l))return null;let u=e.positionOutline?.(l);return u?we(u):ke(e,l,{segments:b=>Te(e,r,b)})}),a=l=>M(o,l,()=>e.hasStory(l)?K(l,M(E(e,r).spans,l,()=>e.paragraphSpans(l))):null),s=l=>z(l.story)===t?Re(e,i,l,t,a):null,c=l=>{let u=s(l.start),b=s(l.end);return u===null||b===null?null:{from:u,to:b}};return {positionFor:s,display:c,displayTarget:l=>{if(!l.ok)return l;let u=[];for(let b of l.ranges){let h=c(b);if(!h)return k("unsupported","The target has no display position");u.push(h);}return u.sort((b,h)=>b.from-h.from||b.to-h.to),{ok:true,ranges:u,paragraph:s(l.paragraph)}}}}function Wr(e,r,t=true){let n=e.version(),o;if(e.proposalRevisions){let c=[...new Set(r.proposals.flatMap(({revisionIds:u})=>u))].sort(),p=JSON.stringify(c),l=E(e,n);l.proposalRevisions?.ids!==p&&(l.proposalRevisions={ids:p,revisions:c.length>0?e.proposalRevisions(c):[]}),o=l.proposalRevisions.revisions;}let{display:i,displayTarget:a}=Me(e,n),s=Object.fromEntries(r.proposals.map(({id:c})=>[c,a($(e,{kind:"proposal",id:c},n,r,o))]));return {version:n,previewVersion:r.previewVersion,proposals:De(r),targets:s,navigationTargets:t?Object.fromEntries(r.proposals.map(({id:c,paragraph:p})=>[c,Ze(e,p.story,p.paraId)])):void 0,hidden:Je(e,n,r,o).map(i).filter(c=>c!==null)}}function Ur(e,r,t=()=>[]){let n=e.version(),o=Qe(e,n,t);return r.map(i=>{try{return o($(e,i,n))}catch(a){if(a instanceof WebAssembly.RuntimeError)throw a;return k("unsupported",a instanceof Error?a.message:String(a))}})}function Qe(e,r,t=()=>[]){let n=new Map;return o=>{if(!o.ok)return o;let i=z(o.paragraph.story)??"body",a=n.get(i);a||n.set(i,a={mapping:Me(e,r,i)});let s=a.mapping.displayTarget(o);if(!s.ok||i==="body")return s;let{display:c}=a.mapping;a.hidden??(a.hidden=t().map(c).filter(l=>l!==null));let p=e.headerFooterAliases?g$1(e.headerFooterAliases(),i.slice(3)):void 0;return {...s,root:i,hidden:a.hidden,...p?{rIds:p}:{}}}}function Jr(e,r,t,n){if(!e?.navigationTargets||e.version!==r.version||e.previewVersion!==r.previewVersion||e.proposals!==De(r))return null;let o=r.proposals.find(({paragraph:i})=>i.story===t&&i.paraId===n);return o&&Object.hasOwn(e.navigationTargets,o.id)?e.navigationTargets[o.id]:null}function Ze(e,r,t){if(typeof r!="string"||typeof t!="string"||!e.hasStory(r))return "missing-target";let n=e.paragraphIdCount(r,t);if(n===0)return "missing-target";if(n>1)return "ambiguous-target";let o={story:r,paraId:t,offset:0},i=c(e).locToDisplayPoint(o);return !i||i.hfRid?"unsupported":{loc:o,position:i.position}}function et(e,r){let t=new Set(e.sets.map(({owner:n})=>n));return Object.fromEntries(Object.entries(r??{}).filter(([,n])=>t.has(n.owner)))}var er=1e5,F=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),P=e=>typeof e=="string",je=e=>Number.isInteger(e)&&e>=0,X=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=er;function Fe(e){if(!F(e))return false;switch(e.kind){case "session":return P(e.sessionId)&&P(e.story)&&P(e.paraId);case "source":return P(e.packageSha256)&&P(e.partUri)&&je(e.paragraphOrdinal);case "persisted":return F(e.story)&&P(e.story.partUri)&&P(e.story.kind)&&P(e.paraId);default:return false}}var Ce=e=>F(e)&&P(e.paraId)&&je(e.offset);function ee(e,r,t){if(!F(e))return false;switch(e.kind){case "paragraph":return r&&Fe(e.paragraph);case "range":return P(e.version)&&F(e.range)&&P(e.range.story)&&Ce(e.range.start)&&Ce(e.range.end)&&(e.range.view==="accepted"||e.range.view==="original");case "search":return Fe(e.paragraph)&&P(e.text)&&e.text.length>0&&(e.occurrence===void 0||e.occurrence==="first"||!t&&e.occurrence==="all"||Number.isInteger(e.occurrence)&&e.occurrence>=1);default:return false}}function rr(e){if(!F(e)||!P(e.id)||!e.id)return false;switch(e.kind){case "inline":return ee(e.anchor,false,true)&&X(e.width)&&X(e.height)&&(e.hideAnchor===void 0||typeof e.hideAnchor=="boolean");case "block":return ee(e.anchor,true,true)&&(e.side==="before"||e.side==="after")&&X(e.height)&&(e.width===void 0||X(e.width));case "hide":return ee(e.anchor,true,false);default:return false}}function rt(e){if(!F(e)||!P(e.version)||!Array.isArray(e.sets)||e.key!==void 0&&!P(e.key))return false;let r=new Set;return e.sets.every(t=>{if(!F(t)||!P(t.owner)||!t.owner||r.has(t.owner)||t.version!==void 0&&(!P(t.version)||!t.version)||!Array.isArray(t.items))return false;r.add(t.owner);let n=new Set;return t.items.every(o=>!rr(o)||n.has(o.id)?false:(n.add(o.id),true))})}function tr(e,r,t){let{story:n}=r.start;if(r.start.paraId===r.end.paraId)return [{story:n,paraId:r.start.paraId,start:r.start.offset,end:r.end.offset+(t?1:0)}];let{spans:o,positions:i}=e(n),a=i.get(r.start.paraId)??-1,s=i.get(r.end.paraId)??-1;return a<0||s<a?[]:o.slice(a,s+1).map((c,p,l)=>({story:n,paraId:c.paraId,start:p===0?r.start.offset:0,end:p===l.length-1?r.end.offset+(t?1:0):c.length+1}))}function tt(e,r,t=r.version,n=null){let o=new Map,i=l=>{let u=o.get(l);if(!u){let b=e.paragraphSpans(l),h=new Map;b.forEach((f,d)=>{h.has(f.paraId)||h.set(f.paraId,d);}),u={spans:b,positions:h},o.set(l,u);}return u},a=new Map,s={resolveParagraphAnchor:l=>e.resolveParagraphAnchor(l),hasStory:l=>e.hasStory(l),findText:(...l)=>e.findText(...l),listRevisions:()=>e.listRevisions(),paragraphSpans:l=>i(l).spans,storySegments:l=>{let u=a.get(l);return u||(u=e.storySegments(l),a.set(l,u)),u}},c={},p=new Map;for(let[l,u]of Object.entries(n??{})){let b=p.get(u.owner);b||p.set(u.owner,b=[]),b.push([l,u]);}for(let{owner:l,version:u,items:b}of r.sets){if(u!==void 0&&u!==r.version){for(let[h,f]of p.get(l)??[])c[h]=f;continue}for(let h of b){let f=h.anchor.kind==="range"?{...h.anchor,version:h.anchor.version===r.version?t:""}:h.anchor,d=$(s,f,t);if(!d.ok||!d.ranges.length)continue;let y=h.anchor.kind==="paragraph",g=(h.kind==="inline"?d.ranges.slice(0,1):d.ranges).flatMap(m=>tr(i,m,y)).map(m=>{let x=Ye(s,t,m.story,m.paraId);return {...m,start:Math.max(0,m.start-x),end:m.end-x}}),w=g[0];if(!w)continue;let R=m=>JSON.stringify(m?[l,h.id,m]:[l,h.id]);if(h.kind==="block"){c[R(0)]={owner:l,id:h.id,story:w.story,paraId:w.paraId,start:0,end:0,kind:"block",side:h.side,height:h.height,...h.width===void 0?{}:{width:h.width}};continue}h.kind==="inline"&&(c[R(0)]={owner:l,id:h.id,...w,end:h.hideAnchor?w.end:w.start,kind:"inline",width:h.width,height:h.height,...h.hideAnchor?{hide:true}:{}},!h.hideAnchor)||g.forEach((m,x)=>{(h.kind==="hide"||x>0)&&(c[R(x)]={owner:l,id:h.id,...m,kind:"hide"});});}}return c}export{z as A,Ye as B,Hr as C,Je as D,qe as E,$ as F,De as G,Wr as H,Ur as I,Qe as J,Jr as K,Ze as L,et as M,rt as N,tt as O,nr as a,ir as b,K as c,B as d,pr as e,ur as f,hr as g,xr as h,Le as i,Ge as j,ge as k,wr as l,kr as m,Rr as n,Tr as o,vr as p,Yr as q,Fr as r,Cr as s,we as t,ke as u,Nr as v,J as w,Re as x,k as y,q as z};
@@ -0,0 +1 @@
1
+ import {d as d$1,e,k}from'./chunk-YITJ4QAO.mjs';function B(n){return n.length>=4&&(n[0]===73&&n[1]===73&&n[2]===42&&n[3]===0||n[0]===77&&n[1]===77&&n[2]===0&&n[3]===42)}function R(n,e,t,r){if(!B(n)||n.byteLength>33554432)return {bytes:n,mimeType:e,dataUrl:t};try{let o=r(n);return {bytes:o,mimeType:"image/png",dataUrl:`data:image/png;base64,${N(o)}`}}catch{return {bytes:n,mimeType:e,dataUrl:t}}}function N(n){let e="";for(let t=0;t<n.length;t+=32768)e+=String.fromCharCode(...n.subarray(t,t+32768));return btoa(e)}var U=new Set(["__proto__","constructor","prototype"]);function Z(n,e){return O(d$1(new Uint8Array(n),JSON.stringify(e)),n)}function O(n,e){return C(JSON.parse(n),e)}function C(n,e){h(n,"wire");let t=c(n,"wire");if(p(t,["wireVersion","document","embeddedFontParts","fontTableRelationshipsXml","canonicalBase64","canonicalSha256"],"wire",["fontTableRelationshipsXml","canonicalBase64","canonicalSha256"]),t.wireVersion!==1)throw new TypeError("wire.wireVersion must be 1");let r=X(t.document,e),o=I(t.embeddedFontParts);if((t.canonicalBase64!==void 0||t.canonicalSha256!==void 0)&&(t.canonicalBase64===void 0||t.canonicalSha256===void 0))throw new TypeError("wire canonical fields must be present together");let i=t.canonicalSha256===void 0?void 0:d(t.canonicalSha256,"wire.canonicalSha256");if(i!==void 0&&!/^[0-9a-f]{64}$/.test(i))throw new TypeError("wire.canonicalSha256 is invalid");return {wireVersion:1,document:r,embeddedFonts:o,...t.fontTableRelationshipsXml===void 0?{}:{fontTableRelationshipsXml:d(t.fontTableRelationshipsXml,"wire.fontTableRelationshipsXml")},...t.canonicalBase64===void 0?{}:{rustCanonicalBytes:b(d(t.canonicalBase64,"wire.canonicalBase64")),rustCanonicalSha256:i}}}function X(n,e){let t=c(n,"wire.document");p(t,["package","templateVariables","warnings"],"wire.document",["templateVariables","warnings"]);let o={package:_(t.package),originalBuffer:e};return t.warnings!==void 0&&(o.warnings=J(t.warnings,"wire.document.warnings")),o}function _(n){let e=c(n,"wire.document.package");p(e,["document","styles","theme","numbering","settings","fontTable","headerEntries","footerEntries","footnotes","endnotes","footnoteSeparators","endnoteSeparators","relationshipEntries","mediaEntries","chartEntries"],"wire.document.package",["styles","headerEntries","footerEntries","footnotes","endnotes","footnoteSeparators","endnoteSeparators"]);let o={document:V(e.document),theme:c(e.theme,"wire.document.package.theme"),numbering:c(e.numbering,"wire.document.package.numbering"),settings:c(e.settings,"wire.document.package.settings"),fontTable:c(e.fontTable,"wire.document.package.fontTable"),relationships:x(e.relationshipEntries,"wire.document.package.relationshipEntries"),media:j(e.mediaEntries),charts:g(e.chartEntries,"wire.document.package.chartEntries",(a,i)=>c(a,i))};e.styles!==void 0&&(o.styles=c(e.styles,"wire.document.package.styles"));for(let[a,i]of [["headerEntries","headers"],["footerEntries","footers"]]){let s=e[a];s!==void 0&&(o[i]=g(s,`wire.document.package.${a}`,(f,u)=>c(f,u)));}return e.footnotes!==void 0&&(o.footnotes=m(e.footnotes,"wire.document.package.footnotes")),e.endnotes!==void 0&&(o.endnotes=m(e.endnotes,"wire.document.package.endnotes")),e.footnoteSeparators!==void 0&&(o.footnoteSeparators=m(e.footnoteSeparators,"wire.document.package.footnoteSeparators")),e.endnoteSeparators!==void 0&&(o.endnoteSeparators=m(e.endnoteSeparators,"wire.document.package.endnoteSeparators")),o}function V(n){let e="wire.document.package.document",t=c(n,e);if(p(t,["content","sections","finalSectionProperties","customRootBindings","comments"],e,["sections","finalSectionProperties","customRootBindings","comments"]),!Array.isArray(t.content))throw new TypeError(`${e}.content must be an array`);t.content.forEach((o,a)=>c(o,`${e}.content[${a}]`));let r={content:t.content};if(t.sections!==void 0){if(!Array.isArray(t.sections))throw new TypeError(`${e}.sections must be an array`);r.sections=t.sections.map((o,a)=>{let i=`${e}.sections[${a}]`,s=c(o,i);p(s,["id","properties","contentStart","contentEnd"],i,["id"]);let f=P(s.contentStart,`${i}.contentStart`),u=P(s.contentEnd,`${i}.contentEnd`);if(f>u||u>r.content.length)throw new TypeError(`${i} has an invalid content range`);return {...s.id===void 0?{}:{id:d(s.id,`${i}.id`)},properties:c(s.properties,`${i}.properties`),content:r.content.slice(f,u)}});}return t.finalSectionProperties!==void 0&&(r.finalSectionProperties=c(t.finalSectionProperties,`${e}.finalSectionProperties`)),t.customRootBindings!==void 0&&(r.customRootBindings=m(t.customRootBindings,`${e}.customRootBindings`)),t.comments!==void 0&&(r.comments=m(t.comments,`${e}.comments`)),r}function x(n,e){return g(n,e,(t,r,o)=>W(t,r,o))}function j(n){let e="wire.document.package.mediaEntries";if(!Array.isArray(n))throw new TypeError(`${e} must be an array`);let t=new Map,r=new Map;for(let o=0;o<n.length;o+=1){let a=`${e}[${o}]`,i=n[o];if(!Array.isArray(i)||i.length!==2)throw new TypeError(`${a} must be a key/value pair`);let s=d(i[0],`${a}[0]`);if(t.has(s))throw new TypeError(`${e} contains duplicate key ${JSON.stringify(s)}`);let f=`${a}[1]`,u=c(i[1],f);p(u,["path","filename","mimeType","base64","dataUrl"],f,["filename"]);let l=d(u.path,`${f}.path`),y=r.get(l);if(!y){let D=b(d(u.base64,`${f}.base64`)),w=R(D,d(u.mimeType,`${f}.mimeType`),d(u.dataUrl,`${f}.dataUrl`),k),k$1={path:l,...u.filename===void 0?{}:{filename:d(u.filename,`${f}.filename`)},mimeType:w.mimeType,data:M(w.bytes),dataUrl:w.dataUrl};y=k$1,r.set(l,k$1);}t.set(s,y);}return t}function I(n){let e="wire.embeddedFontParts";if(!Array.isArray(n))throw new TypeError(`${e} must be an array`);let t=new Map;return n.forEach((r,o)=>{let a=`${e}[${o}]`,i=c(r,a);p(i,["path","base64"],a);let s=d(i.path,`${a}.path`);if(t.has(s))throw new TypeError(`${e} contains duplicate key ${JSON.stringify(s)}`);t.set(s,M(b(d(i.base64,`${a}.base64`))));}),t}function g(n,e,t){if(!Array.isArray(n))throw new TypeError(`${e} must be an array`);let r=new Map;return n.forEach((o,a)=>{let i=`${e}[${a}]`;if(!Array.isArray(o)||o.length!==2)throw new TypeError(`${i} must be a key/value pair`);let s=d(o[0],`${i}[0]`);if(r.has(s))throw new TypeError(`${e} contains duplicate key ${JSON.stringify(s)}`);r.set(s,t(o[1],`${i}[1]`,s));}),r}function J(n,e){if(!Array.isArray(n))throw new TypeError(`${e} must be an array`);return n.map((t,r)=>d(t,`${e}[${r}]`))}function m(n,e){if(!Array.isArray(n))throw new TypeError(`${e} must be an array`);return n.forEach((t,r)=>c(t,`${e}[${r}]`)),n}function M(n){return Uint8Array.from(n).buffer}function P(n,e){let t=H(n,e);if(!Number.isSafeInteger(t)||t<0)throw new TypeError(`${e} must be a non-negative safe integer`);return t}function v(n,e$1="word/_rels/document.xml.rels"){let t=JSON.parse(e(new TextEncoder().encode(n),e$1));h(t,"relationshipPart");let r=c(t,"relationshipPart");return p(r,["path","relationships","canonicalBase64","canonicalSha256"],"relationshipPart"),d(r.path,"relationshipPart.path"),x(r.relationships,"relationshipPart.relationships")}function W(n,e,t){let r=c(n,e);p(r,["id","type","target","targetMode"],e,["targetMode"]);let o=d(r.id,`${e}.id`);if(o!==t)throw new TypeError(`${e}.id does not match its map key`);let a={id:o,type:d(r.type,`${e}.type`),target:d(r.target,`${e}.target`)};if(r.targetMode!==void 0){if(r.targetMode!=="External"&&r.targetMode!=="Internal")throw new TypeError(`${e}.targetMode is invalid`);a.targetMode=r.targetMode;}return a}function h(n,e,t=new WeakSet){if(!(n===null||typeof n!="object")){if(t.has(n))throw new TypeError(`${e} contains a cycle`);t.add(n);try{for(let r of Object.keys(n)){if(U.has(r))throw new TypeError(`${e} contains forbidden key ${r}`);h(n[r],`${e}.${r}`,t);}}finally{t.delete(n);}}}function c(n,e){if(n===null||typeof n!="object"||Array.isArray(n))throw new TypeError(`${e} must be an object`);return n}function p(n,e,t,r=[]){let o=new Set(e);for(let i of Object.keys(n))if(!o.has(i))throw new TypeError(`${t} contains unknown key ${i}`);let a=new Set(r);for(let i of e)if(!a.has(i)&&!Object.prototype.hasOwnProperty.call(n,i))throw new TypeError(`${t} is missing ${i}`)}function d(n,e){if(typeof n!="string")throw new TypeError(`${e} must be a string`);return n}function H(n,e){if(typeof n!="number"||!Number.isFinite(n))throw new TypeError(`${e} must be a finite number`);return n}function b(n){let e;try{e=atob(n);}catch{throw new TypeError("wire canonicalBase64 is invalid")}let t=new Uint8Array(e.length);for(let r=0;r<e.length;r+=1)t[r]=e.charCodeAt(r);return t}export{Z as a,O as b,C as c,v as d};
@@ -0,0 +1,2 @@
1
+ var t={image:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",hyperlink:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",header:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",footer:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",footnotes:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",endnotes:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes",styles:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",numbering:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",fontTable:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",theme:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",settings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",webSettings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings",oleObject:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject",chart:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",diagramData:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData",officeDocument:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",coreProperties:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",extendedProperties:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",customProperties:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties",customXml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml",comments:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",commentsExtended:"http://schemas.microsoft.com/office/2011/relationships/commentsExtended",commentsIds:"http://schemas.microsoft.com/office/2016/09/relationships/commentsIds",commentsExtensible:"http://schemas.microsoft.com/office/2018/08/relationships/commentsExtensible"};
2
+ export{t as a};
@@ -1,4 +1,4 @@
1
- import {d}from'./chunk-EBYC3CX7.mjs';import {a as a$1,b as b$1}from'./chunk-AXFMDV66.mjs';import {a as a$2}from'./chunk-GKWXOZZH.mjs';import {a,c}from'./chunk-DLXIZBB6.mjs';async function In(e){if(e instanceof ArrayBuffer)return e;if(e instanceof Uint8Array){let n=new ArrayBuffer(e.byteLength);return new Uint8Array(n).set(e),n}if(e instanceof Blob)return e.arrayBuffer();throw new TypeError(`Unsupported DocxInput type: ${typeof e}`)}function ye(e){let n=e.replace(/[^0-9a-fA-F]/g,"");if(n.length!==32)return null;let t=new Uint8Array(16);for(let i=0;i<16;i++){let r=Number.parseInt(n.slice(i*2,i*2+2),16);if(Number.isNaN(r))return null;t[i]=r;}let o=new Uint8Array(16);for(let i=0;i<16;i++)o[i]=t[15-i];return o}function be(e){return e?ye(e)!==null:false}function we(e,n){let t=ye(n);if(!t)throw new Error(`Invalid embedded-font key: "${n}"`);let o=new Uint8Array(e.slice(0)),i=Math.min(32,o.length);for(let r=0;r<i;r++)o[r]^=t[r%16];return o.buffer}var je={calibri:{googleFont:"Carlito",category:"sans-serif",fallbackStack:["Calibri","Carlito","Arial","Helvetica","sans-serif"],singleLineRatio:1.2207},cambria:{googleFont:"Caladea",category:"serif",fallbackStack:["Cambria","Caladea","Georgia","serif"],singleLineRatio:1.2676},arial:{googleFont:"Arimo",category:"sans-serif",fallbackStack:["Arial","Arimo","Helvetica","sans-serif"],singleLineRatio:1.1172},"times new roman":{googleFont:"Tinos",category:"serif",fallbackStack:["Times New Roman","Tinos","Times","serif"],singleLineRatio:1.1074},"courier new":{googleFont:"Cousine",category:"monospace",fallbackStack:["Courier New","Cousine","Courier","monospace"],singleLineRatio:1.1328},georgia:{googleFont:"Tinos",category:"serif",fallbackStack:["Georgia","Tinos","Times New Roman","serif"],singleLineRatio:1.1362},verdana:{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Verdana","Open Sans","Arial","sans-serif"],singleLineRatio:1.2153},tahoma:{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Tahoma","Open Sans","Arial","sans-serif"],singleLineRatio:1.2075},"trebuchet ms":{googleFont:"Fira Sans",category:"sans-serif",fallbackStack:["Trebuchet MS","Fira Sans","Arial","sans-serif"],singleLineRatio:1.1431},"comic sans ms":{googleFont:"Comic Neue",category:"cursive",fallbackStack:["Comic Sans MS","Comic Neue","cursive"],singleLineRatio:1.3936},impact:{googleFont:"Anton",category:"sans-serif",fallbackStack:["Impact","Anton","Arial Black","sans-serif"],singleLineRatio:1.2197},"palatino linotype":{googleFont:"EB Garamond",category:"serif",fallbackStack:["Palatino Linotype","EB Garamond","Palatino","Georgia","serif"],singleLineRatio:1.0259},"book antiqua":{googleFont:"EB Garamond",category:"serif",fallbackStack:["Book Antiqua","EB Garamond","Palatino","Georgia","serif"],singleLineRatio:1.0259},garamond:{googleFont:"EB Garamond",category:"serif",fallbackStack:["Garamond","EB Garamond","Georgia","serif"],singleLineRatio:1.068},"century gothic":{googleFont:"Questrial",category:"sans-serif",fallbackStack:["Century Gothic","Questrial","Arial","sans-serif"],singleLineRatio:1.1611},"lucida sans":{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Lucida Sans","Open Sans","Arial","sans-serif"],singleLineRatio:1.1655},"lucida console":{googleFont:"Cousine",category:"monospace",fallbackStack:["Lucida Console","Cousine","Courier New","monospace"],singleLineRatio:1.1387},consolas:{googleFont:"Inconsolata",category:"monospace",fallbackStack:["Consolas","Inconsolata","Cousine","Courier New","monospace"],singleLineRatio:1.1626},"ms mincho":{googleFont:"Noto Serif JP",category:"serif",fallbackStack:["MS Mincho","Noto Serif JP","serif"],singleLineRatio:1.15},"\uFF4D\uFF53 \u660E\u671D":{googleFont:"Noto Serif JP",category:"serif",fallbackStack:["MS Mincho","\uFF2D\uFF33 \u660E\u671D","Noto Serif JP","serif"],singleLineRatio:1.15},"\uFF4D\uFF53 \uFF50\u660E\u671D":{googleFont:"Noto Serif JP",category:"serif",fallbackStack:["MS PMincho","\uFF2D\uFF33 \uFF30\u660E\u671D","Noto Serif JP","serif"],singleLineRatio:1.15},"ms gothic":{googleFont:"Noto Sans JP",category:"sans-serif",fallbackStack:["MS Gothic","Noto Sans JP","sans-serif"],singleLineRatio:1.15},"\uFF4D\uFF53 \u30B4\u30B7\u30C3\u30AF":{googleFont:"Noto Sans JP",category:"sans-serif",fallbackStack:["MS Gothic","\uFF2D\uFF33 \u30B4\u30B7\u30C3\u30AF","Noto Sans JP","sans-serif"],singleLineRatio:1.15},"\uFF4D\uFF53 \uFF50\u30B4\u30B7\u30C3\u30AF":{googleFont:"Noto Sans JP",category:"sans-serif",fallbackStack:["MS PGothic","\uFF2D\uFF33 \uFF30\u30B4\u30B7\u30C3\u30AF","Noto Sans JP","sans-serif"],singleLineRatio:1.15},simhei:{googleFont:"Noto Sans SC",category:"sans-serif",fallbackStack:["SimHei","Noto Sans SC","sans-serif"],singleLineRatio:1.15},simsun:{googleFont:"Noto Serif SC",category:"serif",fallbackStack:["SimSun","Noto Serif SC","serif"],singleLineRatio:1.15},"malgun gothic":{googleFont:"Noto Sans KR",category:"sans-serif",fallbackStack:["Malgun Gothic","Noto Sans KR","sans-serif"],singleLineRatio:1.15},\u5B8B\u4F53:{googleFont:"Noto Serif SC",category:"serif",fallbackStack:["SimSun","\u5B8B\u4F53","Noto Serif SC","serif"],singleLineRatio:1.15},\u9ED1\u4F53:{googleFont:"Noto Sans SC",category:"sans-serif",fallbackStack:["SimHei","\u9ED1\u4F53","Noto Sans SC","sans-serif"],singleLineRatio:1.15},\u5FAE\u8F6F\u96C5\u9ED1:{googleFont:"Noto Sans SC",category:"sans-serif",fallbackStack:["Microsoft YaHei","\u5FAE\u8F6F\u96C5\u9ED1","Noto Sans SC","sans-serif"],singleLineRatio:1.15},\u7B49\u7EBF:{googleFont:"Noto Sans SC",category:"sans-serif",fallbackStack:["DengXian","\u7B49\u7EBF","Noto Sans SC","sans-serif"],singleLineRatio:1.15},\u4EFF\u5B8B:{googleFont:"Noto Serif SC",category:"serif",fallbackStack:["FangSong","\u4EFF\u5B8B","Noto Serif SC","serif"],singleLineRatio:1.15},\u6977\u4F53:{googleFont:"Noto Serif SC",category:"serif",fallbackStack:["KaiTi","\u6977\u4F53","Noto Serif SC","serif"],singleLineRatio:1.15},\u65B0\u7D30\u660E\u9AD4:{googleFont:"Noto Serif TC",category:"serif",fallbackStack:["PMingLiU","\u65B0\u7D30\u660E\u9AD4","Noto Serif TC","serif"],singleLineRatio:1.15},\u7D30\u660E\u9AD4:{googleFont:"Noto Serif TC",category:"serif",fallbackStack:["MingLiU","\u7D30\u660E\u9AD4","Noto Serif TC","serif"],singleLineRatio:1.15},\u5FAE\u8EDF\u6B63\u9ED1\u9AD4:{googleFont:"Noto Sans TC",category:"sans-serif",fallbackStack:["Microsoft JhengHei","\u5FAE\u8EDF\u6B63\u9ED1\u9AD4","Noto Sans TC","sans-serif"],singleLineRatio:1.15},\u6A19\u6977\u9AD4:{googleFont:"Noto Serif TC",category:"serif",fallbackStack:["DFKai-SB","\u6A19\u6977\u9AD4","Noto Serif TC","serif"],singleLineRatio:1.15},"\uB9D1\uC740 \uACE0\uB515":{googleFont:"Noto Sans KR",category:"sans-serif",fallbackStack:["Malgun Gothic","\uB9D1\uC740 \uACE0\uB515","Noto Sans KR","sans-serif"],singleLineRatio:1.15},\uAD74\uB9BC:{googleFont:"Noto Sans KR",category:"sans-serif",fallbackStack:["Gulim","\uAD74\uB9BC","Noto Sans KR","sans-serif"],singleLineRatio:1.15},\uB3CB\uC6C0:{googleFont:"Noto Sans KR",category:"sans-serif",fallbackStack:["Dotum","\uB3CB\uC6C0","Noto Sans KR","sans-serif"],singleLineRatio:1.15},\uBC14\uD0D5:{googleFont:"Noto Serif KR",category:"serif",fallbackStack:["Batang","\uBC14\uD0D5","Noto Serif KR","serif"],singleLineRatio:1.15},\uAD81\uC11C:{googleFont:"Noto Serif KR",category:"serif",fallbackStack:["Gungsuh","\uAD81\uC11C","Noto Serif KR","serif"],singleLineRatio:1.15}},Je={"sans-serif":"Arial, Helvetica, sans-serif",serif:"Times New Roman, Times, serif",monospace:"Courier New, Courier, monospace",cursive:"cursive",fantasy:"fantasy","system-ui":"system-ui, sans-serif"};function Ye(e){let n=e.toLowerCase();return n.includes("mono")||n.includes("courier")||n.includes("consolas")||n.includes("console")||n.includes("code")||n.includes("terminal")?"monospace":n.includes("times")||n.includes("georgia")||n.includes("garamond")||n.includes("palatino")||n.includes("baskerville")||n.includes("bodoni")||n.includes("cambria")||n.includes("mincho")||n.includes("\u660E\u671D")||n.includes("\u660E\u9AD4")||n.includes("\u5B8B")||n.includes("ming")||n.includes("song")||n.includes("serif")?"serif":n.includes("script")||n.includes("cursive")||n.includes("comic")||n.includes("brush")||n.includes("hand")?"cursive":"sans-serif"}var Ve={"microsoft yahei":"\u5FAE\u8F6F\u96C5\u9ED1",dengxian:"\u7B49\u7EBF",fangsong:"\u4EFF\u5B8B",kaiti:"\u6977\u4F53",pmingliu:"\u65B0\u7D30\u660E\u9AD4",mingliu:"\u7D30\u660E\u9AD4","microsoft jhenghei":"\u5FAE\u8EDF\u6B63\u9ED1\u9AD4","dfkai-sb":"\u6A19\u6977\u9AD4",gulim:"\uAD74\uB9BC",dotum:"\uB3CB\uC6C0",batang:"\uBC14\uD0D5",gungsuh:"\uAD81\uC11C",meiryo:"ms gothic",\u30E1\u30A4\u30EA\u30AA:"ms gothic","yu gothic":"ms gothic",\u6E38\u30B4\u30B7\u30C3\u30AF:"ms gothic","yu mincho":"ms mincho",\u6E38\u660E\u671D:"ms mincho"};function Le(e){let n=e.trim().toLowerCase(),t=je[Ve[n]??n];if(t)return {googleFont:t.googleFont,cssFallback:t.fallbackStack.map(he).join(", "),originalFont:e,hasGoogleEquivalent:true,singleLineRatio:t.singleLineRatio};let o=Ye(e),i=Je[o];return {googleFont:null,cssFallback:`${he(e)}, ${i}`,originalFont:e,hasGoogleEquivalent:false,singleLineRatio:1.15}}var Xe={"\n":"\\a ","\r":"\\d ","\f":"\\c "};function Qe(e){return e.replace(/["\\]/g,"\\$&").replace(/[\n\r\f]/g,n=>Xe[n])}function he(e){return ["serif","sans-serif","monospace","cursive","fantasy","system-ui"].includes(e.toLowerCase())?e:/[\s,'"()]/.test(e)?`"${Qe(e)}"`:e}var g=new Set,L=new Map,W=new Set,S=new Map,Z=new Set,ee=new Set,_e=new Set([null]),z={scope:null},Ee=new Set,C=new Set;function P(e){!e.disposed&&(e.loadCallbacks.size>0||e.errorCallbacks.size>0)?C.add(e):C.delete(e);}function G(e){return e.has(null)?C:[...e].filter(n=>n!==null&&C.has(n))}var V=new Map,ne=new Map;function te(e,n,t){let o=e.get(n);return o||(o=new Set,e.set(n,o)),o.add(t),o}var y=false,D=true,j=new Set,O=new Set,oe=new Map,Ze=5*6e4;function ke(e){let n=oe.get(e);return n===void 0?false:Date.now()-n<Ze?true:(oe.delete(e),false)}function b(e,n,t=_e){let o=e instanceof Error?e.message:String(e),i=new Error(`[font] ${n}: ${o}`,{cause:e}),r=[...ee];for(let s of G(t))r.push(...s.errorCallbacks);if(r.length>0)for(let s of r)try{s(i);}catch(a){console.error("Font error subscriber threw:",a);}else console.warn(i.message);}function ve(e,n="normal",t="normal"){return `${e.trim()}|${n}|${t}`}var en=[[false,false],[true,false],[false,true],[true,true]],Re=5e3,nn=500,B=new Map,x=new Map,Pe=new Set,re=new Set,X=new Set,ie=0,N=[],M=null;function Ne(){if(M!==null&&(clearTimeout(M),M=null),N.length===0)return;let e=N;N=[],document.fonts.dispatchEvent(typeof FontFaceSetLoadEvent=="function"?new FontFaceSetLoadEvent("loadingdone",{fontfaces:e}):new Event("loadingdone"));}function tn(){ie-=1,N.length!==0&&(ie===0?Ne():M??(M=setTimeout(Ne,nn)));}function Be(e,n,t,o){return e.resolveFamily?e.resolveFamily(n,t,o):!t&&!o?e.resolve(n,false,false):void 0}function on(e,n,t,o,i,r){let s=ve(n,o?700:400,i?"italic":"normal"),a=B.get(s);if(a)return x.get(s)?.add(r),a;let c=Be(e,t,o,i);if(!c)return;ie+=1;let d=new Set([r]);x.set(s,d);let l=(async()=>{let f;try{f=new FontFace(n,await c(),{weight:o?"700":"400",style:i?"italic":"normal"});let u=f.status==="loaded";return document.fonts.add(f),await f.load(),u&&N.push(f),!0}catch(u){return f&&document.fonts.delete(f),b(u,`failed to register bundled "${n}"`,new Set([...d].flatMap(m=>[...m]))),false}finally{x.get(s)===d&&x.delete(s),tn();}})();return B.set(s,l),l.then(f=>{!f&&B.get(s)===l&&B.delete(s);}),l}function rn(e,n,t,o,i,r){if(typeof FontFace>"u"||document.fonts===void 0)return Promise.resolve("none");let s=t||o?(t??[400,700]).flatMap(l=>(o??["normal","italic"]).map(f=>[l>=600,f==="italic"])):en,a=s.map(()=>"pending"),c$1=false,d=()=>c$1&&a.every(l=>l==="unsupported")?"absent":a.includes("registered")?c$1&&a.every(l=>l==="registered"||l==="unsupported")?"complete":"partial":"none";return new Promise(l=>{let f=false,u=()=>{f||(f=true,clearTimeout(m),l(d()));},m=setTimeout(u,i);(async()=>{let w=await c();if(!w)return;c$1=true;let p=n.find(h=>s.some(([J,v])=>Be(w,h,J,v)))??e;await Promise.all(s.map(async([h,J],v)=>{let de=on(w,e,p,h,J,r);if(!de){a[v]="unsupported";return}Pe.add(e),a[v]=await de?"registered":"failed";}));})().catch(()=>{}).finally(u);})}function se(e,n){return j.has(e)||Pe.has(e)?false:O.has(e)?true:mn(e)?(O.add(e),queueMicrotask(()=>T([e],n)),true):false}function sn(e){let n=`${e.toLowerCase()}|`,t=[],o=[];for(let[i,r]of S)if(i.toLowerCase().startsWith(n)){t.push(r);let s=F.get(i)?.requesters??ne.get(i);s&&o.push(s);}return {promises:t,requesters:o}}function an(e,n,t){W.add(e),g.add(n),T([n],t);}function ln(e,n=[400,700],t=["normal","italic"]){let o=encodeURIComponent(e),i=[];for(let s of t){let a=s==="italic"?1:0;for(let c of n)i.push(`${a},${c}`);}i.sort();let r=i.join(";");return `https://fonts.googleapis.com/css2?family=${o}:ital,wght@${r}&display=swap`}function cn(e,n){return U(e,n,void 0,void 0,null)}async function U(e,n,t,o,i){if(typeof document>"u")return false;let r=e.trim();if(g.has(r))return true;let s=L.get(r);if(s){if(te(V,r,i),!t)return s;let u=o??Date.now()+Re;return s.then(m=>m||!X.has(r)?m:U(e,n,t,u,i))}if(!n&&se(r,new Set([i])))return true;let a$1=sn(r),c=a();if(!D&&!c&&a$1.promises.length===0)return false;let d=ln(r,n?.weights,n?.styles);if(!c&&a$1.promises.length===0&&ke(d))return false;let l=te(V,r,i),f=(async()=>{y=true;try{if(a$1.promises.length>0){if(await Promise.all(a$1.promises),g.has(r))return un([r],l,a$1.requesters),!0;if(!n&&se(r,l))return !0}if(c){let p=await rn(r,t?[r,t.trim()]:[r],n?.weights,n?.styles,o===void 0?Re:Math.max(0,o-Date.now()),l);return p==="absent"?X.add(r):X.delete(r),p==="none"||p==="absent"?!1:(p==="complete"?(re.delete(r),q(r)):re.add(r),T([r],l),!0)}if(!D||ke(d))return !1;let u=document.createElement("link");u.rel="stylesheet",u.href=d;let m=!1;return await new Promise(p=>{let h=setTimeout(()=>p(!1),5e3);u.onload=()=>{clearTimeout(h),p(!0);},u.onerror=()=>{clearTimeout(h),m=!0,p(!1);},document.head.appendChild(u);})?(await le(r,3e3),q(r),T([r],l),!0):(u.onload=null,u.onerror=null,u.remove(),m&&oe.set(d,Date.now()),!1)}catch(u){return b(u,`failed to load "${r}"`,l),false}finally{L.delete(r),V.delete(r),L.size===0&&S.size===0&&(y=false);}})();return L.set(r,f),f}async function fn(e,n){let t=e.filter(o=>!g.has(o.trim()));t.length!==0&&await Promise.all(t.map(o=>cn(o,n)));}function Ae(e){let n=e.trim();return g.has(n)||O.has(n)}function On(e){D=e;}function Un(){return D}function $n(){return y}function qn(){return Array.from(new Set([...g,...O]))}function Kn(e){return Z.add(e),()=>{Z.delete(e);}}function T(e,n=_e){let t=[...Z];for(let o of G(n))t.push(...o.loadCallbacks);for(let o of t)try{o(e);}catch(i){b(i,"load callback threw",n);}}function un(e,n,t){let o=new Set;for(let i of t)for(let r of G(i))o.add(r);for(let i of G(n))if(!o.has(i))for(let r of [...i.loadCallbacks])try{r(e);}catch(s){b(s,"load callback threw",new Set([i]));}}function Hn(e){return ee.add(e),()=>{ee.delete(e);}}async function le(e,n){if("fonts"in document)try{let t=`400 16px "${e}"`;return await Promise.race([document.fonts.load(t),new Promise(o=>setTimeout(o,n))]),document.fonts.check(t)}catch{}return await new Promise(t=>setTimeout(t,100)),true}var R,Ce=new Map,dn="abcdefghijklmnopqrstuvwxyz0123456789";function gn(){return R===void 0&&(R=document.createElement("canvas").getContext("2d"),R&&(R.textBaseline="top")),R}function mn(e,n="sans-serif"){if(typeof document>"u")return false;let t=gn();if(!t)return false;let o=r=>(t.font=r,t.measureText(dn).width),i=r=>{let s=Ce.get(r);return s===void 0&&(s=o(`72px ${r}`),Ce.set(r,s)),o(`72px "${e}", ${r}`)!==s};return i(n)||i(n==="sans-serif"?"serif":"sans-serif")}var pn={"<":"\\3c ",">":"\\3e ","\n":"\\a ","\r":"\\d ","\f":"\\c "},xe=e=>e.replace(/["\\]/g,"\\$&").replace(/[<>\n\r\f]/g,n=>pn[n]);async function Wn(e,n,t){if(typeof document>"u")return false;let o={family:e,data:n,weight:t?.weight,style:t?.style},i=e.trim();return Oe(o,z,De(i,[o]))}var F=new Map,I=new Map,A=new Map,Sn=256,_=new Set,$=new Map;function q(e){g.add(e),_.delete(e),$.delete(e);}function Te(e,n){g.has(n)||_.add(n),g.add(n),e.families.has(n)||(e.families.add(n),A.set(n,(A.get(n)??0)+1));}function K(e){return new Uint8Array(e.data)}function ae(e){let n=2166136261;for(let t=0;t<e.length;t+=1)n=Math.imul(n^e[t],16777619);return `${(n>>>0).toString(16).padStart(8,"0")}${e.length.toString(16)}`}function Me(e,n){if(e.length!==n.length)return false;for(let t=0;t<e.length;t+=1)if(e[t]!==n[t])return false;return true}function Fn(e){let n=String(e??"normal").trim().toLowerCase();if(n==="normal")return "400";if(n==="bold")return "700";let t=Number(n);return n!==""&&Number.isFinite(t)?String(t):n}function Ge(e,n,t){return `${e.trim().toLowerCase()}|${Fn(n)}|${t}`}function yn(e,n){let t=`${e}|${ae(n)}`;for(let o=0;;o+=1){let i=o===0?t:`${t}~${o}`,r=F.get(i);if(!r||Me(r.bytes,n))return i}}function Ie(e,n,t){let o=Ge(e,n.weight,n.style??"normal"),i=K(n);for(let r of I.get(o)??[])if(!Me(r.bytes,i)&&[...r.owners].some(s=>!t.has(s)))return true;return false}function De(e,n,t=Ee){if(!n.some(i=>Ie(e,i,t)))return e;let o=`${e}#${ae(new TextEncoder().encode(n.map(i=>ae(K(i))).join()))}`;for(let i=0;;i+=1){let r=i===0?o:`${o}~${i}`;if(!n.some(s=>Ie(r,s,Ee)))return r}}function Oe(e,n,t){let o=e.family.trim(),i=e.style??"normal",r=Ge(t,e.weight,i),s=yn(r,K(e)),a=t.toLowerCase()===o.toLowerCase();j.add(o);let c=F.get(s);if(c)return c.owners.add(n),c.settled||c.requesters.add(n.scope),a?c.promise.then(u=>(u&&F.get(s)===c&&Te(c,o),u)):c.promise;let d=K(e).slice(),l={key:s,cssSlot:r,cssFamily:t,families:new Set,requesters:new Set([n.scope]),settled:false,bytes:d,owners:new Set([n]),promise:Promise.resolve(false),style:null,url:null};F.set(s,l);let f=I.get(r);return f||(f=new Set,I.set(r,f)),f.add(l),l.promise=(async()=>{y=true;try{return l.url=URL.createObjectURL(new Blob([d],{type:"font/ttf"})),l.style=document.createElement("style"),l.style.textContent=`
1
+ import {d}from'./chunk-QGZ2AB3M.mjs';import {a as a$2}from'./chunk-YITJ4QAO.mjs';import {a as a$1,b as b$1}from'./chunk-7WIUNGQW.mjs';import {a,c}from'./chunk-DLXIZBB6.mjs';async function In(e){if(e instanceof ArrayBuffer)return e;if(e instanceof Uint8Array){let n=new ArrayBuffer(e.byteLength);return new Uint8Array(n).set(e),n}if(e instanceof Blob)return e.arrayBuffer();throw new TypeError(`Unsupported DocxInput type: ${typeof e}`)}function ye(e){let n=e.replace(/[^0-9a-fA-F]/g,"");if(n.length!==32)return null;let t=new Uint8Array(16);for(let i=0;i<16;i++){let r=Number.parseInt(n.slice(i*2,i*2+2),16);if(Number.isNaN(r))return null;t[i]=r;}let o=new Uint8Array(16);for(let i=0;i<16;i++)o[i]=t[15-i];return o}function be(e){return e?ye(e)!==null:false}function we(e,n){let t=ye(n);if(!t)throw new Error(`Invalid embedded-font key: "${n}"`);let o=new Uint8Array(e.slice(0)),i=Math.min(32,o.length);for(let r=0;r<i;r++)o[r]^=t[r%16];return o.buffer}var je={calibri:{googleFont:"Carlito",category:"sans-serif",fallbackStack:["Calibri","Carlito","Arial","Helvetica","sans-serif"],singleLineRatio:1.2207},cambria:{googleFont:"Caladea",category:"serif",fallbackStack:["Cambria","Caladea","Georgia","serif"],singleLineRatio:1.2676},arial:{googleFont:"Arimo",category:"sans-serif",fallbackStack:["Arial","Arimo","Helvetica","sans-serif"],singleLineRatio:1.1172},"times new roman":{googleFont:"Tinos",category:"serif",fallbackStack:["Times New Roman","Tinos","Times","serif"],singleLineRatio:1.1074},"courier new":{googleFont:"Cousine",category:"monospace",fallbackStack:["Courier New","Cousine","Courier","monospace"],singleLineRatio:1.1328},georgia:{googleFont:"Tinos",category:"serif",fallbackStack:["Georgia","Tinos","Times New Roman","serif"],singleLineRatio:1.1362},verdana:{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Verdana","Open Sans","Arial","sans-serif"],singleLineRatio:1.2153},tahoma:{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Tahoma","Open Sans","Arial","sans-serif"],singleLineRatio:1.2075},"trebuchet ms":{googleFont:"Fira Sans",category:"sans-serif",fallbackStack:["Trebuchet MS","Fira Sans","Arial","sans-serif"],singleLineRatio:1.1431},"comic sans ms":{googleFont:"Comic Neue",category:"cursive",fallbackStack:["Comic Sans MS","Comic Neue","cursive"],singleLineRatio:1.3936},impact:{googleFont:"Anton",category:"sans-serif",fallbackStack:["Impact","Anton","Arial Black","sans-serif"],singleLineRatio:1.2197},"palatino linotype":{googleFont:"EB Garamond",category:"serif",fallbackStack:["Palatino Linotype","EB Garamond","Palatino","Georgia","serif"],singleLineRatio:1.0259},"book antiqua":{googleFont:"EB Garamond",category:"serif",fallbackStack:["Book Antiqua","EB Garamond","Palatino","Georgia","serif"],singleLineRatio:1.0259},garamond:{googleFont:"EB Garamond",category:"serif",fallbackStack:["Garamond","EB Garamond","Georgia","serif"],singleLineRatio:1.068},"century gothic":{googleFont:"Questrial",category:"sans-serif",fallbackStack:["Century Gothic","Questrial","Arial","sans-serif"],singleLineRatio:1.1611},"lucida sans":{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Lucida Sans","Open Sans","Arial","sans-serif"],singleLineRatio:1.1655},"lucida console":{googleFont:"Cousine",category:"monospace",fallbackStack:["Lucida Console","Cousine","Courier New","monospace"],singleLineRatio:1.1387},consolas:{googleFont:"Inconsolata",category:"monospace",fallbackStack:["Consolas","Inconsolata","Cousine","Courier New","monospace"],singleLineRatio:1.1626},"ms mincho":{googleFont:"Noto Serif JP",category:"serif",fallbackStack:["MS Mincho","Noto Serif JP","serif"],singleLineRatio:1.15},"\uFF4D\uFF53 \u660E\u671D":{googleFont:"Noto Serif JP",category:"serif",fallbackStack:["MS Mincho","\uFF2D\uFF33 \u660E\u671D","Noto Serif JP","serif"],singleLineRatio:1.15},"\uFF4D\uFF53 \uFF50\u660E\u671D":{googleFont:"Noto Serif JP",category:"serif",fallbackStack:["MS PMincho","\uFF2D\uFF33 \uFF30\u660E\u671D","Noto Serif JP","serif"],singleLineRatio:1.15},"ms gothic":{googleFont:"Noto Sans JP",category:"sans-serif",fallbackStack:["MS Gothic","Noto Sans JP","sans-serif"],singleLineRatio:1.15},"\uFF4D\uFF53 \u30B4\u30B7\u30C3\u30AF":{googleFont:"Noto Sans JP",category:"sans-serif",fallbackStack:["MS Gothic","\uFF2D\uFF33 \u30B4\u30B7\u30C3\u30AF","Noto Sans JP","sans-serif"],singleLineRatio:1.15},"\uFF4D\uFF53 \uFF50\u30B4\u30B7\u30C3\u30AF":{googleFont:"Noto Sans JP",category:"sans-serif",fallbackStack:["MS PGothic","\uFF2D\uFF33 \uFF30\u30B4\u30B7\u30C3\u30AF","Noto Sans JP","sans-serif"],singleLineRatio:1.15},simhei:{googleFont:"Noto Sans SC",category:"sans-serif",fallbackStack:["SimHei","Noto Sans SC","sans-serif"],singleLineRatio:1.15},simsun:{googleFont:"Noto Serif SC",category:"serif",fallbackStack:["SimSun","Noto Serif SC","serif"],singleLineRatio:1.15},"malgun gothic":{googleFont:"Noto Sans KR",category:"sans-serif",fallbackStack:["Malgun Gothic","Noto Sans KR","sans-serif"],singleLineRatio:1.15},\u5B8B\u4F53:{googleFont:"Noto Serif SC",category:"serif",fallbackStack:["SimSun","\u5B8B\u4F53","Noto Serif SC","serif"],singleLineRatio:1.15},\u9ED1\u4F53:{googleFont:"Noto Sans SC",category:"sans-serif",fallbackStack:["SimHei","\u9ED1\u4F53","Noto Sans SC","sans-serif"],singleLineRatio:1.15},\u5FAE\u8F6F\u96C5\u9ED1:{googleFont:"Noto Sans SC",category:"sans-serif",fallbackStack:["Microsoft YaHei","\u5FAE\u8F6F\u96C5\u9ED1","Noto Sans SC","sans-serif"],singleLineRatio:1.15},\u7B49\u7EBF:{googleFont:"Noto Sans SC",category:"sans-serif",fallbackStack:["DengXian","\u7B49\u7EBF","Noto Sans SC","sans-serif"],singleLineRatio:1.15},\u4EFF\u5B8B:{googleFont:"Noto Serif SC",category:"serif",fallbackStack:["FangSong","\u4EFF\u5B8B","Noto Serif SC","serif"],singleLineRatio:1.15},\u6977\u4F53:{googleFont:"Noto Serif SC",category:"serif",fallbackStack:["KaiTi","\u6977\u4F53","Noto Serif SC","serif"],singleLineRatio:1.15},\u65B0\u7D30\u660E\u9AD4:{googleFont:"Noto Serif TC",category:"serif",fallbackStack:["PMingLiU","\u65B0\u7D30\u660E\u9AD4","Noto Serif TC","serif"],singleLineRatio:1.15},\u7D30\u660E\u9AD4:{googleFont:"Noto Serif TC",category:"serif",fallbackStack:["MingLiU","\u7D30\u660E\u9AD4","Noto Serif TC","serif"],singleLineRatio:1.15},\u5FAE\u8EDF\u6B63\u9ED1\u9AD4:{googleFont:"Noto Sans TC",category:"sans-serif",fallbackStack:["Microsoft JhengHei","\u5FAE\u8EDF\u6B63\u9ED1\u9AD4","Noto Sans TC","sans-serif"],singleLineRatio:1.15},\u6A19\u6977\u9AD4:{googleFont:"Noto Serif TC",category:"serif",fallbackStack:["DFKai-SB","\u6A19\u6977\u9AD4","Noto Serif TC","serif"],singleLineRatio:1.15},"\uB9D1\uC740 \uACE0\uB515":{googleFont:"Noto Sans KR",category:"sans-serif",fallbackStack:["Malgun Gothic","\uB9D1\uC740 \uACE0\uB515","Noto Sans KR","sans-serif"],singleLineRatio:1.15},\uAD74\uB9BC:{googleFont:"Noto Sans KR",category:"sans-serif",fallbackStack:["Gulim","\uAD74\uB9BC","Noto Sans KR","sans-serif"],singleLineRatio:1.15},\uB3CB\uC6C0:{googleFont:"Noto Sans KR",category:"sans-serif",fallbackStack:["Dotum","\uB3CB\uC6C0","Noto Sans KR","sans-serif"],singleLineRatio:1.15},\uBC14\uD0D5:{googleFont:"Noto Serif KR",category:"serif",fallbackStack:["Batang","\uBC14\uD0D5","Noto Serif KR","serif"],singleLineRatio:1.15},\uAD81\uC11C:{googleFont:"Noto Serif KR",category:"serif",fallbackStack:["Gungsuh","\uAD81\uC11C","Noto Serif KR","serif"],singleLineRatio:1.15}},Je={"sans-serif":"Arial, Helvetica, sans-serif",serif:"Times New Roman, Times, serif",monospace:"Courier New, Courier, monospace",cursive:"cursive",fantasy:"fantasy","system-ui":"system-ui, sans-serif"};function Ye(e){let n=e.toLowerCase();return n.includes("mono")||n.includes("courier")||n.includes("consolas")||n.includes("console")||n.includes("code")||n.includes("terminal")?"monospace":n.includes("times")||n.includes("georgia")||n.includes("garamond")||n.includes("palatino")||n.includes("baskerville")||n.includes("bodoni")||n.includes("cambria")||n.includes("mincho")||n.includes("\u660E\u671D")||n.includes("\u660E\u9AD4")||n.includes("\u5B8B")||n.includes("ming")||n.includes("song")||n.includes("serif")?"serif":n.includes("script")||n.includes("cursive")||n.includes("comic")||n.includes("brush")||n.includes("hand")?"cursive":"sans-serif"}var Ve={"microsoft yahei":"\u5FAE\u8F6F\u96C5\u9ED1",dengxian:"\u7B49\u7EBF",fangsong:"\u4EFF\u5B8B",kaiti:"\u6977\u4F53",pmingliu:"\u65B0\u7D30\u660E\u9AD4",mingliu:"\u7D30\u660E\u9AD4","microsoft jhenghei":"\u5FAE\u8EDF\u6B63\u9ED1\u9AD4","dfkai-sb":"\u6A19\u6977\u9AD4",gulim:"\uAD74\uB9BC",dotum:"\uB3CB\uC6C0",batang:"\uBC14\uD0D5",gungsuh:"\uAD81\uC11C",meiryo:"ms gothic",\u30E1\u30A4\u30EA\u30AA:"ms gothic","yu gothic":"ms gothic",\u6E38\u30B4\u30B7\u30C3\u30AF:"ms gothic","yu mincho":"ms mincho",\u6E38\u660E\u671D:"ms mincho"};function Le(e){let n=e.trim().toLowerCase(),t=je[Ve[n]??n];if(t)return {googleFont:t.googleFont,cssFallback:t.fallbackStack.map(he).join(", "),originalFont:e,hasGoogleEquivalent:true,singleLineRatio:t.singleLineRatio};let o=Ye(e),i=Je[o];return {googleFont:null,cssFallback:`${he(e)}, ${i}`,originalFont:e,hasGoogleEquivalent:false,singleLineRatio:1.15}}var Xe={"\n":"\\a ","\r":"\\d ","\f":"\\c "};function Qe(e){return e.replace(/["\\]/g,"\\$&").replace(/[\n\r\f]/g,n=>Xe[n])}function he(e){return ["serif","sans-serif","monospace","cursive","fantasy","system-ui"].includes(e.toLowerCase())?e:/[\s,'"()]/.test(e)?`"${Qe(e)}"`:e}var g=new Set,L=new Map,W=new Set,S=new Map,Z=new Set,ee=new Set,_e=new Set([null]),z={scope:null},Ee=new Set,C=new Set;function P(e){!e.disposed&&(e.loadCallbacks.size>0||e.errorCallbacks.size>0)?C.add(e):C.delete(e);}function G(e){return e.has(null)?C:[...e].filter(n=>n!==null&&C.has(n))}var V=new Map,ne=new Map;function te(e,n,t){let o=e.get(n);return o||(o=new Set,e.set(n,o)),o.add(t),o}var y=false,D=true,j=new Set,O=new Set,oe=new Map,Ze=5*6e4;function ke(e){let n=oe.get(e);return n===void 0?false:Date.now()-n<Ze?true:(oe.delete(e),false)}function b(e,n,t=_e){let o=e instanceof Error?e.message:String(e),i=new Error(`[font] ${n}: ${o}`,{cause:e}),r=[...ee];for(let s of G(t))r.push(...s.errorCallbacks);if(r.length>0)for(let s of r)try{s(i);}catch(a){console.error("Font error subscriber threw:",a);}else console.warn(i.message);}function ve(e,n="normal",t="normal"){return `${e.trim()}|${n}|${t}`}var en=[[false,false],[true,false],[false,true],[true,true]],Re=5e3,nn=500,B=new Map,x=new Map,Pe=new Set,re=new Set,X=new Set,ie=0,N=[],M=null;function Ne(){if(M!==null&&(clearTimeout(M),M=null),N.length===0)return;let e=N;N=[],document.fonts.dispatchEvent(typeof FontFaceSetLoadEvent=="function"?new FontFaceSetLoadEvent("loadingdone",{fontfaces:e}):new Event("loadingdone"));}function tn(){ie-=1,N.length!==0&&(ie===0?Ne():M??(M=setTimeout(Ne,nn)));}function Be(e,n,t,o){return e.resolveFamily?e.resolveFamily(n,t,o):!t&&!o?e.resolve(n,false,false):void 0}function on(e,n,t,o,i,r){let s=ve(n,o?700:400,i?"italic":"normal"),a=B.get(s);if(a)return x.get(s)?.add(r),a;let c=Be(e,t,o,i);if(!c)return;ie+=1;let d=new Set([r]);x.set(s,d);let l=(async()=>{let f;try{f=new FontFace(n,await c(),{weight:o?"700":"400",style:i?"italic":"normal"});let u=f.status==="loaded";return document.fonts.add(f),await f.load(),u&&N.push(f),!0}catch(u){return f&&document.fonts.delete(f),b(u,`failed to register bundled "${n}"`,new Set([...d].flatMap(m=>[...m]))),false}finally{x.get(s)===d&&x.delete(s),tn();}})();return B.set(s,l),l.then(f=>{!f&&B.get(s)===l&&B.delete(s);}),l}function rn(e,n,t,o,i,r){if(typeof FontFace>"u"||document.fonts===void 0)return Promise.resolve("none");let s=t||o?(t??[400,700]).flatMap(l=>(o??["normal","italic"]).map(f=>[l>=600,f==="italic"])):en,a=s.map(()=>"pending"),c$1=false,d=()=>c$1&&a.every(l=>l==="unsupported")?"absent":a.includes("registered")?c$1&&a.every(l=>l==="registered"||l==="unsupported")?"complete":"partial":"none";return new Promise(l=>{let f=false,u=()=>{f||(f=true,clearTimeout(m),l(d()));},m=setTimeout(u,i);(async()=>{let w=await c();if(!w)return;c$1=true;let p=n.find(h=>s.some(([J,v])=>Be(w,h,J,v)))??e;await Promise.all(s.map(async([h,J],v)=>{let de=on(w,e,p,h,J,r);if(!de){a[v]="unsupported";return}Pe.add(e),a[v]=await de?"registered":"failed";}));})().catch(()=>{}).finally(u);})}function se(e,n){return j.has(e)||Pe.has(e)?false:O.has(e)?true:mn(e)?(O.add(e),queueMicrotask(()=>T([e],n)),true):false}function sn(e){let n=`${e.toLowerCase()}|`,t=[],o=[];for(let[i,r]of S)if(i.toLowerCase().startsWith(n)){t.push(r);let s=F.get(i)?.requesters??ne.get(i);s&&o.push(s);}return {promises:t,requesters:o}}function an(e,n,t){W.add(e),g.add(n),T([n],t);}function ln(e,n=[400,700],t=["normal","italic"]){let o=encodeURIComponent(e),i=[];for(let s of t){let a=s==="italic"?1:0;for(let c of n)i.push(`${a},${c}`);}i.sort();let r=i.join(";");return `https://fonts.googleapis.com/css2?family=${o}:ital,wght@${r}&display=swap`}function cn(e,n){return U(e,n,void 0,void 0,null)}async function U(e,n,t,o,i){if(typeof document>"u")return false;let r=e.trim();if(g.has(r))return true;let s=L.get(r);if(s){if(te(V,r,i),!t)return s;let u=o??Date.now()+Re;return s.then(m=>m||!X.has(r)?m:U(e,n,t,u,i))}if(!n&&se(r,new Set([i])))return true;let a$1=sn(r),c=a();if(!D&&!c&&a$1.promises.length===0)return false;let d=ln(r,n?.weights,n?.styles);if(!c&&a$1.promises.length===0&&ke(d))return false;let l=te(V,r,i),f=(async()=>{y=true;try{if(a$1.promises.length>0){if(await Promise.all(a$1.promises),g.has(r))return un([r],l,a$1.requesters),!0;if(!n&&se(r,l))return !0}if(c){let p=await rn(r,t?[r,t.trim()]:[r],n?.weights,n?.styles,o===void 0?Re:Math.max(0,o-Date.now()),l);return p==="absent"?X.add(r):X.delete(r),p==="none"||p==="absent"?!1:(p==="complete"?(re.delete(r),q(r)):re.add(r),T([r],l),!0)}if(!D||ke(d))return !1;let u=document.createElement("link");u.rel="stylesheet",u.href=d;let m=!1;return await new Promise(p=>{let h=setTimeout(()=>p(!1),5e3);u.onload=()=>{clearTimeout(h),p(!0);},u.onerror=()=>{clearTimeout(h),m=!0,p(!1);},document.head.appendChild(u);})?(await le(r,3e3),q(r),T([r],l),!0):(u.onload=null,u.onerror=null,u.remove(),m&&oe.set(d,Date.now()),!1)}catch(u){return b(u,`failed to load "${r}"`,l),false}finally{L.delete(r),V.delete(r),L.size===0&&S.size===0&&(y=false);}})();return L.set(r,f),f}async function fn(e,n){let t=e.filter(o=>!g.has(o.trim()));t.length!==0&&await Promise.all(t.map(o=>cn(o,n)));}function Ae(e){let n=e.trim();return g.has(n)||O.has(n)}function On(e){D=e;}function Un(){return D}function $n(){return y}function qn(){return Array.from(new Set([...g,...O]))}function Kn(e){return Z.add(e),()=>{Z.delete(e);}}function T(e,n=_e){let t=[...Z];for(let o of G(n))t.push(...o.loadCallbacks);for(let o of t)try{o(e);}catch(i){b(i,"load callback threw",n);}}function un(e,n,t){let o=new Set;for(let i of t)for(let r of G(i))o.add(r);for(let i of G(n))if(!o.has(i))for(let r of [...i.loadCallbacks])try{r(e);}catch(s){b(s,"load callback threw",new Set([i]));}}function Hn(e){return ee.add(e),()=>{ee.delete(e);}}async function le(e,n){if("fonts"in document)try{let t=`400 16px "${e}"`;return await Promise.race([document.fonts.load(t),new Promise(o=>setTimeout(o,n))]),document.fonts.check(t)}catch{}return await new Promise(t=>setTimeout(t,100)),true}var R,Ce=new Map,dn="abcdefghijklmnopqrstuvwxyz0123456789";function gn(){return R===void 0&&(R=document.createElement("canvas").getContext("2d"),R&&(R.textBaseline="top")),R}function mn(e,n="sans-serif"){if(typeof document>"u")return false;let t=gn();if(!t)return false;let o=r=>(t.font=r,t.measureText(dn).width),i=r=>{let s=Ce.get(r);return s===void 0&&(s=o(`72px ${r}`),Ce.set(r,s)),o(`72px "${e}", ${r}`)!==s};return i(n)||i(n==="sans-serif"?"serif":"sans-serif")}var pn={"<":"\\3c ",">":"\\3e ","\n":"\\a ","\r":"\\d ","\f":"\\c "},xe=e=>e.replace(/["\\]/g,"\\$&").replace(/[<>\n\r\f]/g,n=>pn[n]);async function Wn(e,n,t){if(typeof document>"u")return false;let o={family:e,data:n,weight:t?.weight,style:t?.style},i=e.trim();return Oe(o,z,De(i,[o]))}var F=new Map,I=new Map,A=new Map,Sn=256,_=new Set,$=new Map;function q(e){g.add(e),_.delete(e),$.delete(e);}function Te(e,n){g.has(n)||_.add(n),g.add(n),e.families.has(n)||(e.families.add(n),A.set(n,(A.get(n)??0)+1));}function K(e){return new Uint8Array(e.data)}function ae(e){let n=2166136261;for(let t=0;t<e.length;t+=1)n=Math.imul(n^e[t],16777619);return `${(n>>>0).toString(16).padStart(8,"0")}${e.length.toString(16)}`}function Me(e,n){if(e.length!==n.length)return false;for(let t=0;t<e.length;t+=1)if(e[t]!==n[t])return false;return true}function Fn(e){let n=String(e??"normal").trim().toLowerCase();if(n==="normal")return "400";if(n==="bold")return "700";let t=Number(n);return n!==""&&Number.isFinite(t)?String(t):n}function Ge(e,n,t){return `${e.trim().toLowerCase()}|${Fn(n)}|${t}`}function yn(e,n){let t=`${e}|${ae(n)}`;for(let o=0;;o+=1){let i=o===0?t:`${t}~${o}`,r=F.get(i);if(!r||Me(r.bytes,n))return i}}function Ie(e,n,t){let o=Ge(e,n.weight,n.style??"normal"),i=K(n);for(let r of I.get(o)??[])if(!Me(r.bytes,i)&&[...r.owners].some(s=>!t.has(s)))return true;return false}function De(e,n,t=Ee){if(!n.some(i=>Ie(e,i,t)))return e;let o=`${e}#${ae(new TextEncoder().encode(n.map(i=>ae(K(i))).join()))}`;for(let i=0;;i+=1){let r=i===0?o:`${o}~${i}`;if(!n.some(s=>Ie(r,s,Ee)))return r}}function Oe(e,n,t){let o=e.family.trim(),i=e.style??"normal",r=Ge(t,e.weight,i),s=yn(r,K(e)),a=t.toLowerCase()===o.toLowerCase();j.add(o);let c=F.get(s);if(c)return c.owners.add(n),c.settled||c.requesters.add(n.scope),a?c.promise.then(u=>(u&&F.get(s)===c&&Te(c,o),u)):c.promise;let d=K(e).slice(),l={key:s,cssSlot:r,cssFamily:t,families:new Set,requesters:new Set([n.scope]),settled:false,bytes:d,owners:new Set([n]),promise:Promise.resolve(false),style:null,url:null};F.set(s,l);let f=I.get(r);return f||(f=new Set,I.set(r,f)),f.add(l),l.promise=(async()=>{y=true;try{return l.url=URL.createObjectURL(new Blob([d],{type:"font/ttf"})),l.style=document.createElement("style"),l.style.textContent=`
2
2
  @font-face {
3
3
  font-family: "${xe(t)}";
4
4
  src: url(${l.url}) format('truetype');
@@ -0,0 +1 @@
1
+ import {k as k$1,i,g as g$1}from'./chunk-6WT6HKAY.mjs';import {a}from'./chunk-LPOEM5WH.mjs';import {b as b$2}from'./chunk-CRTTEHZN.mjs';import {b as b$1}from'./chunk-TTRUPDAB.mjs';var I=2,L=new Set(["commandInit","edit","requestFullFrame","commandUpdate","commandViewport","bootstrap","sync","layoutJson","buildFrame","releasePages","applyInput","applyDelete","proposal","documentRead"]),E=6e4;function M(){return new Worker(new URL("./docxWorker.mjs",import.meta.url),{type:"module",name:"betteroffice-docx-worker"})}var x=class{constructor(e=M()){b$1(this,"worker",e);b$1(this,"pending",new Map);b$1(this,"watchdog",null);b$1(this,"nextId",1);b$1(this,"terminalError",null);b$1(this,"commandSession",false);b$1(this,"commandGenerationValue",0);b$1(this,"commandInitialGenerations",new WeakMap);b$1(this,"commandReplacementPending",false);b$1(this,"ready",false);b$1(this,"revision",0);b$1(this,"documentSequence",0);b$1(this,"remoteVector",null);b$1(this,"appliedFontsRevision",null);b$1(this,"bootstrapped",false);b$1(this,"openedHeapLimit",null);b$1(this,"bootstraps",0);b$1(this,"fontRead",null);b$1(this,"lastSnapshotId",0);b$1(this,"lastFailedFontsSnapshotId",0);b$1(this,"keepSurfaces",false);b$1(this,"bootstrapWaiters",[]);b$1(this,"lastMemory",null);b$1(this,"answeredFrameEpoch",0);b$1(this,"retainBuiltPages",false);b$1(this,"failureListener",null);b$1(this,"frameListeners",new Set);b$1(this,"pipeListeners",new Set);b$1(this,"collabListeners",new Set);b$1(this,"commandIdentity",null);this.worker.onmessage=r=>{let t=r.data;if(t.ok&&t.commandFrame){let a=t.commandFrame,m=this.commandIdentity;if(this.terminalError||this.commandReplacementPending||!m||a.session!==m.session||a.incarnation!==m.incarnation||a.epoch!==m.epoch){k$1(a.frame);let f=this.pending.get(t.id);f&&(this.pending.delete(t.id),f.reject(new i("disposed","Worker command frame was superseded"))),this.pending.size>0?this.armWatchdog():this.disarmWatchdog();return}if(!g$1({...m,version:0,throughSeq:0,outcomes:[],frame:a.frame})){k$1(a.frame),this.fail(new i("message","Malformed worker command frame"));return}}t.memory&&(this.lastMemory=t.memory);let n=t.collabUpdates,i$1=t.ok?t.commandInitial??this.commandIdentity:this.commandIdentity;if(n&&!this.terminalError&&!this.commandReplacementPending&&(n.session===void 0||i$1&&n.session===i$1.session&&n.incarnation===i$1.incarnation&&n.epoch===i$1.epoch)){let a={updates:n.updates.map(m=>new Uint8Array(m)),inferences:n.inferences,clock:n.clock};for(let m of [...this.collabListeners])try{m(a);}catch{}if(n.pipe)for(let m of [...this.pipeListeners])try{m(n.pipe);}catch{}}if(t.ok&&t.caret&&(this.answeredFrameEpoch=Math.max(this.answeredFrameEpoch,t.caret.frameEpoch)),t.ok&&t.id>=this.lastSnapshotId){let a=t.proposal?.stateVector??t.stateVector;a&&(this.remoteVector=new Uint8Array(a));}if(!t.ok&&t.terminal){this.fail(this.commandSession?new i(t.failureCode??(t.outOfMemory?"out-of-memory":"trap"),t.error):t.outOfMemory?new R(t.error,t.memory??[]):new g(t.error));return}if(this.pending.size>0&&this.armWatchdog(),t.ok&&t.commandFrame){let a=t.commandFrame;this.frameListeners.size===0&&k$1(a.frame),this.answeredFrameEpoch=Math.max(this.answeredFrameEpoch,a.frame.revision),this.revision=a.frame.payload.layoutRevision;for(let m of [...this.frameListeners])try{m(a.frame);}catch{}}let d=this.pending.get(t.id);if(!d){t.ok&&(k$1(t.commandInitial?.frame),k$1(t.commandAck?.frame));return}this.pending.delete(t.id),this.pending.size===0&&this.disarmWatchdog(),t.ok?d.resolve(t):((d.type==="bootstrap"||d.type==="sync")&&(this.appliedFontsRevision=null,this.lastFailedFontsSnapshotId=this.nextId-1),d.reject(t.commandError?t.failureCode?new i(t.failureCode,t.commandError.message):Object.assign(new Error(t.commandError.message),t.commandError):t.code==="save-unavailable"?new W(t.error):t.code==="cut-kept"?new A(t.error):V(t.error,t.residentUnavailable)));},this.worker.onerror=r=>{this.fail(new l(`Document worker failed: ${r.message}`));},this.worker.onmessageerror=()=>{let r="Document worker returned an unreadable message";this.fail(this.commandSession?new i("message",r):new l(r));};}isReady(){return this.ready}get commandGeneration(){return this.commandGenerationValue}get commandFailure(){return this.terminalError??void 0}commandInitialGeneration(e){return this.commandInitialGenerations.get(e)}async commandInit(e){this.commandSession=true;let r=this.commandGeneration,t=await this.request({type:"commandInit",request:e},e.hostImages?.map(({image:i})=>i));if(r!==this.commandGeneration)throw k$1(t.commandInitial?.frame),new i("disposed","Worker command initialization was superseded");let n=t.commandInitial;if(!n||!g$1(n)||n.selection===void 0||n.editState===void 0||!n.frame)throw k$1(n?.frame),new i("message","Worker command initialization omitted its state or frame");return this.commandInitialGenerations.set(n,r),this.commandIdentity={session:n.session,incarnation:n.incarnation,epoch:n.epoch},this.ready=true,this.revision=n.frame.payload.layoutRevision,this.answeredFrameEpoch=Math.max(this.answeredFrameEpoch,n.frame.revision),n}async edit(e){let r=[],t=i=>{let d=i.slice(0);return r.push(d),d};e.kind==="applyRemoteUpdate"&&e.payload&&typeof e.payload=="object"&&"update"in e.payload&&e.payload.update instanceof ArrayBuffer?e={...e,payload:{...e.payload,update:t(e.payload.update)}}:e.kind==="applyRemoteUpdateChunks"&&e.payload&&typeof e.payload=="object"&&"updates"in e.payload&&Array.isArray(e.payload.updates)&&e.payload.updates.every(i=>i instanceof ArrayBuffer)?e={...e,payload:{...e.payload,updates:e.payload.updates.map(t)}}:e.kind==="collabPipe"&&e.payload&&typeof e.payload=="object"&&"ops"in e.payload&&Array.isArray(e.payload.ops)&&r.push(...a(e.payload.ops));let n=await this.request({type:"edit",command:e},r);return this.commandAck(n)}async checkpoint(){let e=await this.request({type:"checkpoint"});if(!e.checkpoint||!(e.checkpoint.state instanceof Uint8Array))throw new i("message","Worker command checkpoint omitted its state");return e.checkpoint}async requestFullFrame(){return this.commandAck(await this.request({type:"requestFullFrame"}))}async provideHostImages(e){let r=this.commandIdentity;if(!r)throw new i("disposed","Resident command session is not initialized");await this.request({type:"buildPages",pages:[],expectedFrameEpoch:this.answeredFrameEpoch,paintCaret:false,hostImages:e,hostImagesFor:{...r}},e.map(({image:t})=>t));}async requestViewport(e){await this.request({type:"commandViewport",request:e});}onFrame(e){return this.frameListeners.add(e),()=>{this.frameListeners.delete(e);}}onCollabPipe(e){return this.pipeListeners.add(e),()=>{this.pipeListeners.delete(e);}}onCollabUpdates(e){return this.collabListeners.add(e),()=>{this.collabListeners.delete(e);}}async applyRemoteUpdate(e){let r=e.slice();await this.request({type:"commandUpdate",update:r},[r.buffer]);}commandAck(e){let r=e.commandAck?.frame;if(!e.commandAck||!g$1(e.commandAck))throw k$1(r),new i("message","Worker command response omitted its acknowledgement");return e.commandAck.frame&&(this.answeredFrameEpoch=Math.max(this.answeredFrameEpoch,e.commandAck.frame.revision),this.revision=e.commandAck.frame.payload.layoutRevision),e.commandAck}hasFailed(){return this.terminalError!==null}memory(){return this.lastMemory}layoutRevision(){return this.revision}stateSequence(){return this.documentSequence}answeredFrame(){return this.answeredFrameEpoch}setRetainBuiltPages(e){this.retainBuiltPages=e;}onFailure(e){this.failureListener=e;}frameRequestPending(e=true){for(let{type:r}of this.pending.values())if(L.has(r)&&(e||r!=="documentRead"))return true;return false}remoteStateVector(){return this.remoteVector}syncedFontsRevision(){return this.appliedFontsRevision}bootstrapSent(){return this.bootstrapped}whenBootstrapSent(){return this.bootstrapped?Promise.resolve():new Promise(e=>this.bootstrapWaiters.push(e))}rebootstrap(){this.commandSession&&this.fenceCommands(),this.documentSequence+=1,this.bootstrapped=false,this.remoteVector=null,this.appliedFontsRevision=null,this.lastSnapshotId=this.nextId,this.revision=0,this.keepSurfaces=true,this.openedHeapLimit=null;}async open(e,r={}){if(this.openedHeapLimit||this.bootstrapped)throw new l("Document worker already holds a document");let t={bytes:r.heapLimitBytes};this.openedHeapLimit=t;let n;try{let i=new Uint8Array(e);n=await this.request({type:"open",bytes:i.buffer,...r.digest!==void 0?{digest:r.digest}:{},...r.generation!==void 0?{generation:r.generation}:{},...r.heapLimitBytes!==void 0?{heapLimitBytes:r.heapLimitBytes}:{}},[i.buffer]);}catch(i){throw this.openedHeapLimit===t&&(this.openedHeapLimit=null),i}if(n.hostJson===void 0||!n.stateVector)throw new l("Document worker omitted the opened document");return {hostJson:n.hostJson,stateVector:new Uint8Array(n.stateVector)}}async openPreview(e,r,t={}){if(this.openedHeapLimit||this.bootstrapped)throw new l("Document worker already holds a document");let n={bytes:t.heapLimitBytes};this.openedHeapLimit=n;let i;try{let d=new Uint8Array(e);i=await this.request({type:"open",bytes:d.buffer,previewBlocks:r,...t.paragraphBudget!==void 0?{previewParagraphBudget:t.paragraphBudget}:{},...t.heapLimitBytes!==void 0?{heapLimitBytes:t.heapLimitBytes}:{}},[d.buffer]);}catch(d){throw this.openedHeapLimit===n&&(this.openedHeapLimit=null),d}if(i.previewRefused)return this.openedHeapLimit===n&&(this.openedHeapLimit=null),null;if(i.hostJson===void 0||!i.stateVector)throw new l("Document worker omitted the opened preview");return {hostJson:i.hostJson,stateVector:new Uint8Array(i.stateVector)}}fontRequirements(e){let r=this.fontRead;if(r&&r.layoutInput===e&&r.id===this.nextId-1)return r.reply;let t=this.request({type:"fontRequirements",layoutInput:e}).then(d=>{if(d.requirementsJson===void 0)throw new l("Document worker omitted the font requirements");return d.requirementsJson}),n={layoutInput:e,id:this.nextId-1,reply:t};this.fontRead=n;let i=()=>{this.fontRead===n&&(this.fontRead=null);};return t.then(i,i),t}async layoutJson(e){let r=await this.request({type:"layoutJson",layoutRevision:e});if(r.layoutJsonStatus==="stale")return {status:"stale"};if(r.layoutJsonStatus!=="ok"||r.layoutJson===void 0)throw new l("Document worker omitted its retained layout");return {status:"ok",layoutJson:r.layoutJson}}async proposal(e){if(!this.bootstrapped&&!this.commandSession)throw new l("Document worker has not laid out its document");let r=await this.request({type:"proposal",operation:e});if(!r.proposal)throw new l("Document worker omitted the proposal result");let{peerDiff:t,...n}=r.proposal;return {...n,updates:r.proposal.updates.map(i=>new Uint8Array(i)),...t===void 0?{}:{peerDiff:new Uint8Array(t)},stateVector:new Uint8Array(r.proposal.stateVector)}}async documentRead(e){let r=await this.request({type:"documentRead",read:e});if(!r.read)throw new l("Document worker omitted the document read");return r.read}async documentReadAt(e,r){let t=await this.request({type:"documentRead",read:e,expectVersion:r});if(t.superseded)return {status:"superseded"};if(!t.read)throw new l("Document worker omitted the document read");let{version:n,value:i}=t.read;return {status:"ok",version:n,value:i}}async handOver(e){let r=await this.request({type:"encodeState",...e?{peerMetadata:e}:{}});if(!r.state||r.version===void 0||!r.proposals)throw new l("Document worker omitted its document handoff");return {state:new Uint8Array(r.state),version:r.version,proposals:r.proposals,...e?{metadata:r.peerMetadata===void 0?void 0:new Uint8Array(r.peerMetadata),metadataReason:r.peerMetadata===void 0?r.peerMetadataReason??"missing-capability: Worker omitted peer metadata":void 0}:{}}}async encodeState(){let e=await this.request({type:"encodeState"});if(!e.state)throw new l("Document worker omitted its state");return new Uint8Array(e.state)}async encodeVersionedState(e){let r=await this.request({type:"encodeState",...e?{peerMetadata:e}:{}});if(!r.state)throw new l("Document worker omitted its state");return {state:new Uint8Array(r.state),version:r.version,...e?{metadata:r.peerMetadata===void 0?void 0:new Uint8Array(r.peerMetadata),metadataReason:r.peerMetadata===void 0?r.peerMetadataReason??"missing-capability: Worker omitted peer metadata":void 0}:{}}}async save(e){let r=await this.request({type:"save",comments:e.comments,...e.commentsSource===void 0?{}:{commentsSource:e.commentsSource},...e.host===void 0?{}:{host:e.host},...e.stateVector===void 0?{}:{stateVector:e.stateVector.slice()},...e.stories===void 0?{}:{stories:[...e.stories]}});if(!(r.saved instanceof ArrayBuffer)||!Array.isArray(r.updates)||typeof r.version!="string")throw new l("Document worker omitted the saved document");return {bytes:r.saved,updates:r.updates.map(t=>new Uint8Array(t)),version:r.version}}async revisionCount(){let e=await this.request({type:"revisionCount"});if(typeof e.revisionCount!="number"||!Number.isInteger(e.revisionCount)||e.revisionCount<0)throw new l("Document worker omitted a valid revision count");return e.revisionCount}async warm(){let e=this.request({type:"warm",hostModule:true}),r=t=>{if(!this.terminalError)try{this.worker.postMessage({type:"editModule",module:t});}catch{try{this.worker.postMessage({type:"editModule",module:null});}catch{}}};b$2().then(r,()=>r(null)),await e;}async bootstrap(e,r,t={}){if(t.opened&&!this.openedHeapLimit)throw new l("Document worker has no opened document");if(t.opened&&t.heapLimitBytes!==void 0&&t.heapLimitBytes!==this.openedHeapLimit?.bytes)throw new l("Document worker opened its document under another heap limit");let n=e.fontsRevision,i$1=this.commandSession&&!t.opened;i$1&&this.fenceCommands(),this.bootstrapped=true;for(let u of this.bootstrapWaiters.splice(0))u();let d=this.keepSurfaces;this.keepSurfaces=false;let a=++this.bootstraps,m=this.commandGeneration,f=this.request({type:"bootstrap",snapshot:e,extras:r,expectedFrameEpoch:t.frameEpoch??0,...t.layoutExtras!==void 0?{layoutExtras:t.layoutExtras}:{},...t.layoutReply?{layoutReply:t.layoutReply}:{},...t.headersFootersEpoch!==void 0?{headersFootersEpoch:t.headersFootersEpoch}:{},...t.displayWindow?{displayWindow:t.displayWindow,...this.retainBuiltPages?{retainBuiltPages:true}:{}}:{},...t.provisionalPages!==void 0?{provisionalPages:t.provisionalPages}:{},...d?{keepSurfaces:true}:{},...t.opened?{opened:true}:{},...t.heapLimitBytes!==void 0?{heapLimitBytes:t.heapLimitBytes}:{}},C(e));this.recordSent(t.stateVector,n);let w;try{w=await f;}catch(u){throw t.opened&&!this.openedHeapLimit&&a===this.bootstraps&&(this.bootstrapped=false,this.remoteVector=null,this.appliedFontsRevision=null),u}let P=y(w);if(i$1){if(a!==this.bootstraps)throw k$1(w.commandInitial?.frame),new i("disposed","Worker command replacement was superseded");let u=w.commandInitial;if(!u||!g$1(u)||u.selection===void 0||u.editState===void 0||!u.frame||u.frame.baseRevision!==void 0)throw k$1(u?.frame),new i("message","Worker replacement omitted its initial command state");P.commandInitial=u,this.commandInitialGenerations.set(u,m),this.commandIdentity={session:u.session,incarnation:u.incarnation,epoch:u.epoch},this.commandReplacementPending=false;}return this.recordSync(w,n),this.ready=true,this.revision=P.layoutRevision,P}async sync(e,r,t,n=false,i={}){let d=e.fontsRevision,a=this.request({type:"sync",snapshot:e,extras:r,expectedFrameEpoch:t,paintCaret:n,...i.layoutExtras!==void 0?{layoutExtras:i.layoutExtras}:{},...i.layoutReply?{layoutReply:i.layoutReply}:{},...i.headersFootersEpoch!==void 0?{headersFootersEpoch:i.headersFootersEpoch}:{},...i.provisionalPages!==void 0?{provisionalPages:i.provisionalPages}:{},...i.displayWindow?{displayWindow:i.displayWindow,...this.retainBuiltPages?{retainBuiltPages:true}:{}}:{}},C(e));this.recordSent(i.stateVector,d);let m=await a,f=y(m);return this.recordSync(m,d),this.ready=true,this.revision=f.layoutRevision,f}async completeLayout(e,r=false,t){let n=await this.request({type:"completeLayout",expectedFrameEpoch:e,paintCaret:r,...t?{sliceBlocks:t}:{}});return n.frame?y(n):null}async buildFrame(e,r,t=false,n){return y(await this.request({type:"buildFrame",extras:e,expectedFrameEpoch:r,paintCaret:t,...n?{displayWindow:n,...this.retainBuiltPages?{retainBuiltPages:true}:{}}:{}}))}async buildPages(e,r,t=false,n=false){let i=await this.request({type:"buildPages",pages:e,expectedFrameEpoch:r,paintCaret:t,...n?{background:true}:{}});return n&&i.pageBuildSuperseded?null:y(i)}async releasePages(e,r,t=false){let n=await this.request({type:"releasePages",pages:e,expectedFrameEpoch:r,paintCaret:t});return n.superseded?{superseded:true}:y(n)}async applyInput(e,r,t,n=false,i=false,d){if(!this.ready)return {applied:false};try{return {applied:!0,...y(await this.request({type:"applyInput",text:e,selection:r,expectedFrameEpoch:t,profile:n,paintCaret:i,...d?{displayWindow:d,...this.retainBuiltPages?{retainBuiltPages:!0}:{}}:{}}))}}catch(a){if(S(a))return {applied:false};throw a}}async applyDelete(e,r,t,n=false,i=false,d=1,a){if(!this.ready)return {applied:false};try{return {applied:!0,...y(await this.request({type:"applyDelete",direction:e,count:d,selection:r,expectedFrameEpoch:t,profile:n,paintCaret:i,...a?{displayWindow:a,...this.retainBuiltPages?{retainBuiltPages:!0}:{}}:{}}))}}catch(m){if(S(m))return {applied:false};throw m}}eraseCaret(){if(this.terminalError)return;let r={id:this.nextId++,type:"eraseCaret"};this.worker.postMessage(r);}invalidate(e,r){if(this.terminalError)return;this.documentSequence+=1,this.ready=false;let t=e.slice(),i={id:this.nextId++,type:"applyUpdate",update:t,selection:r};this.worker.postMessage(i,[t.buffer]);}async syncUpdate(e,r){let t=e.slice(),n=r.slice(),i=await this.request({type:"syncUpdate",update:t,stateVector:n},[t.buffer,n.buffer]);if(typeof i.version!="string"||!(i.stateVector instanceof ArrayBuffer)||i.repair!==null&&!(i.repair instanceof ArrayBuffer))throw new l("Document worker omitted the update acknowledgment");return {version:i.version,stateVector:new Uint8Array(i.stateVector),repair:i.repair===null?null:new Uint8Array(i.repair)}}async attachCanvases(e,r,t,n,i){let d=e.map(a=>a.canvas);await this.request({type:"attachCanvases",pages:e,activePageIds:r,devicePixelRatio:t,zoom:n,caretStyle:i},d);}destroy(){if(this.terminalError)return;let r={id:this.nextId++,type:"destroy"};this.worker.postMessage(r),this.fail(Object.assign(new l("Document worker was destroyed"),{code:"disposed"}),false);}request(e,r=[]){if(this.terminalError)return Promise.reject(this.terminalError);if(this.commandReplacementPending&&(e.type==="edit"||e.type==="checkpoint"||e.type==="requestFullFrame"||e.type==="commandUpdate"||e.type==="buildPages"||e.type==="commandViewport"))return Promise.reject(new i("disposed","Worker command document is being replaced"));(e.type==="open"||(e.type==="bootstrap"||e.type==="sync")&&!e.snapshot.workerAuthoritative&&e.snapshot.state.byteLength>I&&(e.type!=="bootstrap"||!e.opened)||e.type==="applyInput"||e.type==="applyDelete"||e.type==="proposal"&&e.operation.kind!=="snapshot")&&(this.documentSequence+=1);let t=this.nextId++;return new Promise((n,i)=>{this.pending.size===0&&this.armWatchdog(),this.pending.set(t,{type:e.type,resolve:n,reject:i}),this.worker.postMessage({...e,id:t},r);})}fenceCommands(){this.commandReplacementPending=true,this.commandGenerationValue+=1,this.commandIdentity=null;let e=new i("disposed","Worker command document was replaced"),r=this.failureListener;this.failureListener=null;for(let[t,n]of this.pending)n.type!=="edit"&&n.type!=="checkpoint"&&n.type!=="requestFullFrame"&&n.type!=="commandUpdate"&&n.type!=="buildPages"&&n.type!=="commandViewport"||(this.pending.delete(t),n.reject(e));this.pending.size===0&&this.disarmWatchdog(),r?.(e);}recordSent(e,r){this.terminalError||(this.lastSnapshotId=this.nextId-1,e&&(this.remoteVector=e.slice()),this.appliedFontsRevision=r);}armWatchdog(){this.disarmWatchdog(),this.watchdog=setTimeout(()=>{this.watchdog=null;let r=`Document worker did not answer ${this.pending.values().next().value?.type??"a request"} within ${E}ms`;this.fail(this.commandSession?new i("silence",r):new l(r));},E);}disarmWatchdog(){this.watchdog!==null&&(clearTimeout(this.watchdog),this.watchdog=null);}recordSync(e,r){e.id>=this.lastSnapshotId&&e.id>this.lastFailedFontsSnapshotId&&(this.appliedFontsRevision=r);}fail(e,r=true){let t=this.terminalError===null;this.terminalError=e,this.ready=false,this.disarmWatchdog(),this.worker.terminate();for(let n of this.pending.values())n.reject(e);this.pending.clear(),this.frameListeners.clear(),this.collabListeners.clear(),this.pipeListeners.clear();for(let n of this.bootstrapWaiters.splice(0))n();r&&t&&this.failureListener?.(e);}},g=class extends Error{},l=class extends Error{},W=class extends l{},A=class extends Error{},R=class extends g{constructor(r,t){super(r);b$1(this,"memory",t);}};function S(o){return o instanceof g&&!(o instanceof R)}function V(o,e=false){return e?new g(o):new Error(o)}function C(o){return [o.state.buffer,...o.fonts.flatMap(e=>e instanceof Uint8Array?[e.buffer]:[])]}function y(o){if(!o.frame)throw new l("Document worker response omitted its FrameDelta");if(!o.caret)throw new l("Document worker response omitted its caret snapshot");if(o.selection===void 0)throw new l("Document worker response omitted its selection");return {frame:new Uint8Array(o.frame),...o.pageFrames?{pageFrames:o.pageFrames.map(e=>new Uint8Array(e))}:{},updates:(o.updates??[]).map(e=>new Uint8Array(e)),engineMs:o.engineMs??0,workerTotalMs:o.workerTotalMs??0,engineProfile:o.engineProfile,caret:o.caret,selection:o.selection,selectionCursor:o.selectionCursor??null,caretPainted:o.caretPainted??false,replayMs:o.replayMs??0,replayedPages:o.replayedPages??0,layoutRevision:o.layoutRevision??0,...o.documentVersion===void 0?{}:{documentVersion:o.documentVersion},...o.documentPreview===void 0?{}:{documentPreview:o.documentPreview},...o.documentAsOpened===void 0?{}:{documentAsOpened:o.documentAsOpened},deletedUnits:o.deletedUnits??0,...o.layoutJson!==void 0?{layoutJson:o.layoutJson}:{},...o.layoutMeta!==void 0?{layoutMeta:o.layoutMeta}:{},...o.layoutProvisional?{layoutProvisional:true}:{}}}function U(){return typeof Worker<"u"}var c=null;function b(o){o.idleTimer!==null&&clearTimeout(o.idleTimer),o.releaseTimer!==null&&clearTimeout(o.releaseTimer),o.idleTimer=null,o.releaseTimer=null;}function k(o){c===o&&(c=null,b(o),o.client.destroy());}function j(){if(!U())return Promise.resolve();c&&(c.factory!==Worker||c.client.hasFailed())&&k(c),c||(c={client:new x,factory:Worker,ready:null,owners:0,idleTimer:null,releaseTimer:null});let o=c;return o.ready||(o.ready=o.client.warm().catch(e=>{throw o.client.hasFailed()?k(o):o.ready=null,e})),b(o),o.owners===0&&(o.idleTimer=setTimeout(()=>k(o),E)),o.ready}function G(){let o=c;if(!o)return ()=>{};b(o),o.owners+=1;let e=false;return ()=>{e||(e=true,o.owners-=1,o.owners===0&&c===o&&(o.releaseTimer=setTimeout(()=>k(o),0)));}}function z(){let o=c;return o?!U()||o.factory!==Worker||o.client.hasFailed()?(k(o),null):(c=null,b(o),o.client):null}export{x as a,l as b,W as c,A as d,R as e,U as f,j as g,G as h,z as i};
@@ -0,0 +1 @@
1
+ import {b as b$1}from'./chunk-TTRUPDAB.mjs';function j(t,n){let o=c=>{let{content:f,...m}=c;return m},r=c=>[...c??[]].map(([f,m])=>[f,o(m)]),s=c=>(c??[]).map(f=>{let{verbatimXml:m,sourceOrdinal:u,...e}=o(f);return e}),{package:i}=t,a={finalSectionProperties:i.document.finalSectionProperties,sections:i.document.sections?.map(o),headers:r(i.headers),footers:r(i.footers),footnotes:s(i.footnotes),endnotes:s(i.endnotes),relationships:[...i.relationships??[]]},p=n??i.document.comments??[];return {metadata:h(a),comments:h(p),commentIds:p.map(c=>c.id)}}function M(t){return {footnotes:h(t.package.footnoteSeparators??[]),endnotes:h(t.package.endnoteSeparators??[])}}function h(t){return JSON.stringify(t,(n,o)=>o instanceof Map?[...o]:o)}function w(t,n){return Array.isArray(t)&&t.every(o=>o?.type==="paragraph")?t:typeof t=="string"?[{type:"paragraph",formatting:{},content:[{type:"run",formatting:{},content:[{type:"text",text:t}]}]}]:n}function R(t,n){let o=new Set(t),r=new Set(t.map(String)),s=new Map(n.filter(a=>r.has(a.id)).map(a=>[a.id,Number(a.id)])),i=Math.max(0,...o)+1;for(let a of n){if(s.has(a.id))continue;let p=/^\d+$/u.test(a.id)?Number(a.id):Number.NaN;if(!Number.isSafeInteger(p)||o.has(p)){for(;o.has(i);)i+=1;p=i;}o.add(p),s.set(a.id,p);}return s}function O(t,n,o=false,r=false){let s=t.propertyDocument().package.document.comments??[],i=t.listComments();for(let e of i){let d=/^\d+$/u.test(e.id)?Number(e.id):Number.NaN;Number.isSafeInteger(d)&&n.set(e.id,d);}if(!r){let e=1;for(let d of [...s.map(l=>l.id),...n.values()])e=Math.max(e,d+1);for(let d of i)n.has(d.id)||(n.set(d.id,e),e++);}let a=r?R(s.map(e=>e.id),i):n,p=Object.fromEntries(i.map(e=>[e.id,a.get(e.id)])),c=new Map(i.map(e=>[a.get(e.id),e])),f=e=>e.parentId===null?void 0:a.get(e.parentId)??(/^\d+$/u.test(e.parentId)?Number(e.parentId):void 0),m=s.flatMap(e=>{let d=c.get(e.id);if(!d)return n.has(String(e.id))?[]:[e];let l=f(d),S=o?d.done:d.done||(e.done??false);return [{...e,...d.author?{author:d.author}:{},...d.date?{date:d.date}:{},...d.body==null?{}:{content:w(d.body,e.content)},...S===(e.done??false)?{}:{done:S,...e.status===void 0?{}:{status:S?"resolved":"active"}},...l===void 0?{}:{parentId:l}}]}),u=new Set(s.map(e=>e.id));for(let e of i){let d=a.get(e.id);u.has(d)||m.push({id:d,author:e.author,date:e.date||void 0,content:w(e.body,[]),done:e.done,parentId:f(e)});}return {comments:m,ids:p,sessionIds:new Map(i.map(e=>[a.get(e.id),e.id]))}}var y=t=>({status:"refused",reason:t});function T(t,n,o){let r=t.geometryReader.storyIds().flatMap(m=>t.geometryReader.paragraphSpans(m).filter(u=>u.paraId===n).map(u=>({story:m,paragraph:u})));if(r.length!==1)return y(r.length?"ambiguous-target":"missing-target");if(o==="")return y("invalid-step");let{story:s,paragraph:i}=r[0],a={story:s,paraId:n,offset:0};if(o===void 0)return {story:s,start:a,end:{...a,offset:i.length}};let p=t.selectionText({story:s,start:a,end:a}).after,c=p.indexOf(o);if(c<0)return y("missing-target");if(p.indexOf(o,c+1)>=0)return y("ambiguous-target");let f=m=>{let u=0,e=i.length;for(;u<e;){let d=Math.floor((u+e)/2),l={...a,offset:d};t.selectionText({story:s,start:l,end:l}).before.length<m?u=d+1:e=d;}return u};return {story:s,start:{...a,offset:f(c+1)-1},end:{...a,offset:f(c+o.length)}}}function I(t){return ["hf:","fn:","en:"].some(n=>t.startsWith(n))?t.split(":",2).join(":"):"body"}var v=class{constructor(){b$1(this,"stories",new Map);b$1(this,"nextMark",0);}add(n){this.stories.set(n,++this.nextMark);}projectionOptions(){return this.stories.size>0?{storyIds:new Set([...this.stories.keys()].map(I))}:void 0}capture(){let n=new Map(this.stories);return {stories:[...n.keys()],clear:()=>{for(let[o,r]of n)this.stories.get(o)===r&&this.stories.delete(o);}}}clear(){this.stories.clear();}},b=class{constructor(){b$1(this,"projection",new v);b$1(this,"workerSave",new v);b$1(this,"projections",0);b$1(this,"savedAtProjection",0);b$1(this,"adoptingWorkerSaveUpdates",0);}add(n){this.adoptingWorkerSaveUpdates>0||(this.projection.add(n),this.workerSave.add(n));}adoptWorkerSaveUpdates(n){this.adoptingWorkerSaveUpdates++;try{n();}finally{this.adoptingWorkerSaveUpdates--;}}projected(){this.projection.clear(),this.projections++;}captureWorkerSave(){let n=this.workerSave.capture(),o=this.projections;return {stories:o!==this.savedAtProjection&&this.projection.projectionOptions()===void 0?[]:n.stories,clear:()=>{n.clear(),this.savedAtProjection=o;}}}clear(){this.projection.clear(),this.workerSave.clear(),this.savedAtProjection=this.projections;}};function W(t){let n=Promise.resolve();return o=>{let r=n.then(async()=>{let s=t.captureWorkerSave(),i=await o(s.stories);return s.clear(),i});return n=r.catch(()=>{}),r}}function A(t,n,o){return new Set([...n.snapshot.proposals.filter(r=>r.changed&&!t.has(r.id)).map(r=>r.paragraph.story),...o])}function C(t,n){if(Array.isArray(t))for(let o of t)C(o,n);else if(t&&typeof t=="object"){let o=t;for(let[r,s]of Object.entries(o))r==="src"&&typeof s=="string"?o[r]=n(s)??s:C(s,n);}}function U(t,n){if(!t.includes('"media:'))return t;let o=JSON.parse(t),r=o.envelope?.document?.package?.document?.comments;return r===void 0?t:(C(r,n),JSON.stringify(o))}export{C as a,U as b,j as c,M as d,R as e,O as f,T as g,I as h,v as i,b as j,W as k,A as l};
@@ -0,0 +1 @@
1
+ var n={Title:26,Subtitle:18,Heading1:24,Heading2:18,Heading3:16,Heading4:14,Heading5:13,Heading6:13,Normal:14},l=new Set(["Title","Heading1","Heading2","Heading3"]),a={Subtitle:"666666"},d="#4a6c8c";function g(t){let e=n[t.styleId],o={fontSize:e?`${e}px`:`${Math.min(Math.max(t.fontSize?t.fontSize/2:11,11),20)}px`,lineHeight:"1.3"};(t.bold??l.has(t.styleId))&&(o.fontWeight="bold"),t.italic&&(o.fontStyle="italic");let i=t.color??a[t.styleId];return i?o.color=`#${i}`:t.styleId.startsWith("Heading")&&(o.color=d),o}function S(t){return !t||t.length===0?[]:t.filter(e=>e.type==="paragraph").filter(e=>e.qFormat?true:!(e.hidden||e.semiHidden)).map(e=>({styleId:e.styleId,name:e.name||e.styleId,priority:e.uiPriority??99,fontSize:e.rPr?.fontSize,bold:e.rPr?.bold,italic:e.rPr?.italic,color:e.rPr?.color?.rgb})).sort((e,r)=>e.priority-r.priority)}export{n as a,l as b,a as c,d,g as e,S as f};
@@ -0,0 +1,2 @@
1
+ import {a as a$4}from'./chunk-QWHU7YIW.mjs';import {a as a$2,g,e}from'./chunk-MAYPJU23.mjs';import {a as a$1,c as c$1,b,j as j$1}from'./chunk-YITJ4QAO.mjs';import {a as a$3}from'./chunk-UBUTIWXN.mjs';import {c,a,b as b$1}from'./chunk-7WIUNGQW.mjs';var V=new TextEncoder,j=new TextDecoder("utf-8",{ignoreBOM:true});function ee(e){return typeof e=="string"?V.encode(e):e instanceof Uint8Array?e:new Uint8Array(e)}function R(e){return e?j.decode(e):void 0}function re(e){let r=c(Object.fromEntries(e)),t=new ArrayBuffer(r.byteLength);return new Uint8Array(t).set(r),t}function x(e){return e.startsWith("/")?e.slice(1):`word/${e}`}function M(e$1){let r=[{relsPath:"word/_rels/document.xml.rels",blocks:e$1.package.document.content}],t=c=>(c??[]).flatMap(i=>i.content),n=[...t(e$1.package.footnoteSeparators),...t(e$1.package.footnotes)];n.length>0&&r.push({relsPath:"word/_rels/footnotes.xml.rels",blocks:n});let o=[...t(e$1.package.endnoteSeparators),...t(e$1.package.endnotes)];o.length>0&&r.push({relsPath:"word/_rels/endnotes.xml.rels",blocks:o});let s=e$1.package.relationships;if(!s)return r;let l=(c,i)=>{if(c)for(let[f,u]of c.entries()){if(e(u,c))continue;let p=s.get(f);if(!p||p.type!==i||!p.target)continue;let g=x(p.target).replace(/^word\//,"");r.push({relsPath:`word/_rels/${g}.rels`,blocks:u.content});}};return l(e$1.package.headers,a$4.header),l(e$1.package.footers,a$4.footer),r}function U(e$1){return e$1?[...e$1].filter(([,r])=>!e(r,e$1)):[]}async function z(e){let r=await crypto.subtle.digest("SHA-256",Uint8Array.from(e).buffer);return Array.from(new Uint8Array(r),t=>t.toString(16).padStart(2,"0")).join("")}async function de(e,r,t={},n,o,s,l=false){await Promise.all([a(),a$1()]);for(let a of s?.splicedParts??[])if(a.changed.length&&c$1()!==b)throw new Error(`DOCX_MINIMAL_PATCH [INVALID_PLAN] ${a.part} p#?: paragraphPatchWriterVersion must report PARAGRAPH_PATCH_WRITER_VERSION=1`);let c=o??{seed:await z(new Uint8Array(r)),now:new Date().toISOString()};q(c);let i=e.package,f={determinism:c,document:i.document,headerEntries:U(i.headers),footerEntries:U(i.footers),footnotes:i.footnotes??[],endnotes:i.endnotes??[],footnoteSeparators:i.footnoteSeparators??[],endnoteSeparators:i.endnoteSeparators??[],relationshipEntries:[...i.relationships?.entries()??[]],...i.numbering===void 0?{}:{numbering:i.numbering},options:{updateModifiedDate:t.updateModifiedDate??true,...t.modifiedBy===void 0?{}:{modifiedBy:t.modifiedBy}},...n===void 0?{}:{selective:{changedParaIds:[...n.changedParaIds],...n.sourceParagraphs===void 0?{}:{sourceParagraphs:n.sourceParagraphs}}},...s===void 0?{}:{paragraphIds:s}};a$2(),T(f,"save"),a$2();let u=g(f,()=>JSON.stringify(f));a$2();let{bytes:p,warnings:m}=j$1(u,new Uint8Array(r));a$2();let g$1=J(p);return !n&&!l&&X(e,r,g$1),{buffer:g$1,determinism:c,warnings:[...e.warnings??[],...m]}}function X(e,r,t){let n=b$1(new Uint8Array(r)),o=b$1(new Uint8Array(t));for(let c of M(e)){let i=R(n[c.relsPath])??"",f=R(o[c.relsPath])??"",u=new Set(P(i).map(a=>d(a,"Id"))),p=P(f).filter(a=>d(a,"Type")?.endsWith("/image")).map(a=>d(a,"Id")).filter(a=>!!a&&!u.has(a)),m=F(c.blocks);if(m.length>p.length)throw new Error(`Rust save image mutation mismatch in ${c.relsPath}: ${m.length} model images, ${p.length} relationships`);m.forEach((a,h)=>{a.rId=p[h];});let g=P(f).filter(a=>d(a,"Type")?.endsWith("/hyperlink")&&d(a,"TargetMode")==="External");for(let a of E(c.blocks)){if(!a.href){$(f,a.rId)||(a.rId=void 0);continue}let h=g.find(k=>Y(d(k,"Target")??"")===a.href),y=h&&d(h,"Id");y&&(a.rId=y);}}let s=e.package.headers,l=e.package.relationships;if(!(!s||!l))for(let[c,i]of s){let f=i.watermark;if(!f||f.kind!=="picture")continue;let u=l.get(c);if(!u?.target)continue;let m=`word/_rels/${x(u.target).replace(/^word\//,"")}.rels`,g=R(o[m])??"";if($(g,f.relId))continue;let a=f.mediaPath?.split("/").pop(),h=P(g).find(k=>{if(!d(k,"Type")?.endsWith("/image"))return false;let O=d(k,"Target")?.split("/").pop();return a?O===a:true}),y=h&&d(h,"Id");y&&(f.relId=y);}}function F(e){let r=[],t=n=>{for(let o of n.content)o.type==="drawing"&&o.image.src?.startsWith("data:")&&!o.image.rId&&r.push(o.image);};for(let n of e)if(n.type==="paragraph")for(let o of n.content)if(o.type==="run")t(o);else if(o.type==="insertion"||o.type==="deletion"||o.type==="moveFrom"||o.type==="moveTo")for(let s of o.content)s.type==="run"?t(s):a$3(s,l=>{l.type==="run"&&t(l);},false,true);else a$3(o,s=>{s.type==="run"&&t(s);});else if(n.type==="table")for(let o of n.rows)for(let s of o.cells)r.push(...F(s.content));return r}function E(e){let r=[];for(let t of e)if(t.type==="paragraph")for(let n of t.content)n.type==="hyperlink"&&(n.href||n.rId)&&!n.anchor&&r.push(n),n.type!=="run"&&a$3(n,o=>{o.type==="hyperlink"&&(o.href||o.rId)&&!o.anchor&&r.push(o);});else if(t.type==="table")for(let n of t.rows)for(let o of n.cells)r.push(...E(o.content));else t.type==="blockSdt"&&r.push(...E(t.content));return r}function P(e){return [...e.matchAll(/<Relationship\b[^>]*\/?>/g)].map(r=>r[0])}function d(e,r){return e.match(new RegExp(`\\b${r}="([^"]*)"`))?.[1]}function $(e,r){if(r)return P(e).find(t=>d(t,"Id")===r)}function Y(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&#(\d+);/g,(r,t)=>String.fromCodePoint(Number(t))).replace(/&#x([0-9A-Fa-f]+);/g,(r,t)=>String.fromCodePoint(parseInt(t,16))).replace(/&amp;/g,"&")}function q(e){if(!/^[0-9a-f]{64}$/i.test(e.seed))throw new TypeError("Rust save determinism seed must be a SHA-256 hex digest");if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(e.now))throw new TypeError("Rust save clock must be a UTC ISO-8601 millisecond timestamp")}var G=new Set(["__proto__","constructor","prototype"]);function T(e,r,t=new WeakSet){if(!(e===null||typeof e!="object")){if(t.has(e))throw new TypeError(`${r} contains a cycle`);if(t.add(e),Array.isArray(e))e.forEach((n,o)=>T(n,`${r}[${o}]`,t));else for(let n of Object.keys(e)){if(G.has(n))throw new TypeError(`${r} contains forbidden key ${n}`);T(e[n],`${r}.${n}`,t);}t.delete(e);}}function J(e){let r=new ArrayBuffer(e.byteLength);return new Uint8Array(r).set(e),r}
2
+ export{ee as a,re as b,de as c};
@@ -0,0 +1 @@
1
+ import {b}from'./chunk-TTRUPDAB.mjs';var C=["#0B57D0","#B3261E","#137333","#7B1FA2","#A142F4","#A04B00","#006A6A","#455A64"],G=/^#[0-9a-fA-F]{3}(?:[0-9a-fA-F]{3})?$/;function M(e,t){if(typeof t=="string"&&G.test(t))return t;let r=Number.isSafeInteger(e)&&e>=0?e%C.length:0;return C[r]}function I(e,t){return e.byteLength===t.byteLength&&e.every((r,n)=>r===t[n])}function W(e,t){return e===t||!!(e&&t&&e.story===t.story&&I(e.anchor,t.anchor)&&I(e.head,t.head))}function q(e,t){return e?.clientId===t.clientId&&e.story===t.story&&e.paraId===t.paraId&&e.endOffset===t.endOffset}function x(e){return e?{story:e.story,anchor:e.anchor.slice(),head:e.head.slice()}:null}function j(e){return e?{user:{...e.user},cursor:x(e.cursor)}:null}function oe(e,t,r,n){let s=e,a=false;for(let o of t){if(o.clientId===r)continue;let c=s.get(o.clientId);if(!c&&s.size>=1024)continue;if(c&&o.clock<=c.clock){o.clock===c.clock&&n>c.lastSeenAt&&(s===e&&(s=new Map(e)),s.set(o.clientId,{...c,lastSeenAt:n}));continue}s===e&&(s=new Map(e));let d=o.state?.cursor!=null&&(c?.inferredCursor!=null||c?.state==null||!W(c.state.cursor,o.state.cursor));s.set(o.clientId,{clientId:o.clientId,clock:o.clock,state:j(o.state),lastSeenAt:n,cursorMovedAt:d?n:c?.cursorMovedAt??0,inferredCursor:null}),a=true;}return {records:s,peersChanged:a}}function ae(e,t,r,n){if(t.clientId===r)return {records:e,peersChanged:false};let s=e.get(t.clientId);if(!s&&e.size>=1024)return {records:e,peersChanged:false};let a=new Map(e);return a.set(t.clientId,{clientId:t.clientId,clock:s?.clock??-1,state:s?.state??null,lastSeenAt:s?.lastSeenAt??n,cursorMovedAt:q(s?.inferredCursor??null,t)?s?.cursorMovedAt??n:n,inferredCursor:{...t}}),{records:a,peersChanged:s?.state!=null}}function ce(e,t,r){let n=e,s=false;for(let[a,o]of e)t-o.lastSeenAt<r||(n===e&&(n=new Map(e)),n.delete(a),o.state&&(s=true));return {records:n,peersChanged:s}}function ie(e){let t=[];for(let r of e.values()){if(!r.state)continue;let n={clientId:r.clientId,clock:r.clock,user:{...r.state.user},cursor:x(r.state.cursor)};t.push({...n,lastSeenAt:r.lastSeenAt,cursorMovedAt:r.cursorMovedAt,inferredCursor:r.inferredCursor?{...r.inferredCursor}:null});}return t.sort((r,n)=>r.clientId-n.clientId),t}var p=16777216,H=4096,K=64*1024*1024,pe=K+6,Ee=256*1024*1024,V=0,O=1,z=2,X=3,F=0,B=1,D=2,J=0,Q=Number.MAX_SAFE_INTEGER,Z=10,i=class extends Error{constructor(t){super(t),this.name="ProtocolError";}},A=class extends i{},h=class{constructor(t){b(this,"bytes",t);b(this,"offset",0);}get done(){return this.offset===this.bytes.byteLength}readVarUint(){let t=0,r=1,n=0;for(;;){if(this.offset>=this.bytes.byteLength)throw new i("Truncated varUint");let s=this.bytes[this.offset++],a=s&127;if(a>Math.floor((Q-t)/r))throw new i("varUint exceeds Number.MAX_SAFE_INTEGER");if(t+=a*r,n+=1,(s&128)===0){if(n>1&&a===0)throw new i("Non-canonical varUint");return t}if(n>=8)throw new i("varUint exceeds Number.MAX_SAFE_INTEGER");r*=128;}}readVarUint8Array(){let t=this.readVarUint(),r=this.bytes.byteLength-this.offset;if(t>r)throw new i("Truncated varUint8Array");let n=this.bytes.slice(this.offset,this.offset+t);return this.offset+=t,n}skipVarUint8Array(){let t=this.readVarUint(),r=this.bytes.byteLength-this.offset;if(t>r)throw new i("Truncated varUint8Array");this.offset+=t;}readVarString(){let t=this.readVarUint8Array();try{return new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch(r){throw new i(`Invalid UTF-8 string${r instanceof Error?`: ${r.message}`:""}`)}}};function u(e){if(!Number.isSafeInteger(e)||e<0)throw new i("varUint value must be a non-negative safe integer");let t=[],r=e;for(;r>=128;)t.push(r%128|128),r=Math.floor(r/128);return t.push(r),Uint8Array.from(t)}function f(e,t){let r=0;for(let a of e)if(r+=a.byteLength,r>t)throw new i(`Frame exceeds ${t} bytes`);let n=new Uint8Array(r),s=0;for(let a of e)n.set(a,s),s+=a.byteLength;return n}function ee(e){let t=new TextEncoder().encode(e);return f([u(t.byteLength),t],Number.MAX_SAFE_INTEGER)}function R(e,t,r){return f([u(V),u(e),u(t.byteLength),t],r)}function be(e){return e-2-u(e).byteLength}function we(e){return 2+u(e).byteLength+e}var U=Number.MAX_SAFE_INTEGER,E=Number.MAX_SAFE_INTEGER-1;function he(e){if(e>=E)throw new RangeError("clientId must be below Number.MAX_SAFE_INTEGER - 1");return e}function S(e){let t=0,r=()=>{let o=0n;for(let c=0;c<Z&&t<e.byteLength;c+=1){let d=e[t++];if(o|=BigInt(d&127)<<BigInt(7*c),d<128)return o}},n=r();if(n===void 0)return;let s=t,a=[];for(let o=n;o>0n;o-=1n){let c=t,d=r(),l=r();if(d===void 0||l===void 0)return;a.push({client:d,clock:l,start:c,end:t});}return t===e.byteLength?{header:s,entries:a}:void 0}function Se(e,{open:t=false,chunked:r=false}){let n=S(e);if(!n)return e;let s=[...t?[E]:[],...r?[U]:[]].filter(a=>!n.entries.some(o=>o.client===BigInt(a)));return s.length?f([u(n.entries.length+s.length),e.subarray(n.header),...s.flatMap(a=>[u(a),u(0)])],Number.MAX_SAFE_INTEGER):e}function _e(e){return S(e)?.entries.some(t=>t.client===BigInt(E)&&t.clock!==0n)??false}function me(e){let t=S(e),r=(o,c)=>o.client===BigInt(c)&&o.clock===0n,n=t?.entries.some(o=>r(o,E))??false,s=t?.entries.some(o=>r(o,U))??false;if(!t||!n&&!s)return {stateVector:e,open:n,chunked:s};let a=t.entries.filter(o=>!r(o,E)&&!r(o,U));return {stateVector:f([u(a.length),...a.map(({start:o,end:c})=>e.subarray(o,c))],Number.MAX_SAFE_INTEGER),open:n,chunked:s}}function Ue(e,t){return Number(S(e)?.entries.find(r=>r.client===BigInt(t))?.clock??0n)}function Re(e,t=p){return R(F,e,t)}function ge(e,t=p){return R(B,e,t)}function Ce(e,t=p){return R(D,e,t)}function te(e){return e.state===null?"null":JSON.stringify({user:e.state.user,cursor:e.state.cursor?{story:e.state.cursor.story,anchor:[...e.state.cursor.anchor],head:[...e.state.cursor.head]}:null})}function re(e){let t=[u(e.length)];for(let r of e)t.push(u(r.clientId),u(r.clock),ee(te(r)));return f(t,Number.MAX_SAFE_INTEGER)}function Ie(e,t=p){let r=re(e);return f([u(O),u(r.byteLength),r],t)}function Te(e=p){return f([u(X)],e)}function P(e,t){if(!Array.isArray(e))throw new i(`${t} must be a byte array`);if(e.length>1024)throw new A(`${t} exceeds ${1024} bytes`);if(e.some(r=>!Number.isInteger(r)||r<0||r>255))throw new i(`${t} must be a byte array`);return Uint8Array.from(e)}function ne(e,t){let r;try{r=JSON.parse(e);}catch{throw new i("Invalid awareness JSON")}if(r===null)return null;if(typeof r!="object"||Array.isArray(r))throw new i("Awareness state must be an object or null");let n=r,s=n.user;if(typeof s!="object"||s===null||Array.isArray(s))throw new i("Awareness user must be an object");let a=s;if(typeof a.name!="string")throw new i("Awareness user requires a string name");if(a.name.length>1024)throw new A(`Awareness user name exceeds ${1024} characters`);let o={name:a.name,color:M(t,a.color)},c=n.cursor;if(c==null)return {user:o,cursor:null};if(typeof c!="object"||Array.isArray(c))throw new i("Awareness cursor must be an object or null");let d=c;if(typeof d.story!="string")throw new i("Awareness cursor requires a string story");if(d.story.length>1024)throw new A(`Awareness cursor story exceeds ${1024} characters`);return {user:o,cursor:{story:d.story,anchor:P(d.anchor,"Awareness cursor anchor"),head:P(d.head,"Awareness cursor head")}}}function Ne(e,t={}){let r=new h(e),n=r.readVarUint();if(n>e.byteLength)throw new i("Invalid awareness entry count");let s=new Set(t.trackedClientIds);t.localClientId!==void 0&&s.delete(t.localClientId);let a=new Set,o=l=>{a.has(l.message)||(a.add(l.message),t.onDiscard?.(l));};n>1024&&o(new A(`Awareness update exceeds ${1024} entries`));let c=[],d=Math.min(n,1024);for(let l=0;l<d;l+=1){let y=r.readVarUint(),Y=r.readVarUint();if(!(y===t.localClientId||s.has(y))&&s.size>=1024){r.skipVarUint8Array(),o(new A(`Awareness peer limit of ${1024} reached`));continue}let $=r.readVarString(),g;try{g=ne($,y);}catch(_){if(!(_ instanceof A))throw _;o(_);continue}c.push({clientId:y,clock:Y,state:g}),y!==t.localClientId&&s.add(y);}if(n<=1024&&!r.done)throw new i("Trailing awareness data");return c}function Me(e,t=p,r=H){if(!(e instanceof Uint8Array))throw new i("Frame must be a Uint8Array");if(e.byteLength===0)throw new i("Frame is empty");if(e.byteLength>t)throw new i(`Frame exceeds ${t} bytes`);if(!Number.isSafeInteger(r)||r<1)throw new i("Message limit must be a positive integer");let n=new h(e),s=[];for(;!n.done;){if(s.length>=r)throw new i(`Frame exceeds ${r} messages`);let a=n.readVarUint();switch(a){case V:{let o=n.readVarUint(),c=n.readVarUint8Array();if(o===F)s.push({type:"sync-step-1",stateVector:c});else if(o===B)s.push({type:"sync-step-2",update:c});else if(o===D)s.push({type:"update",update:c});else throw new i(`Unknown sync message type ${o}`);break}case O:s.push({type:"awareness",update:n.readVarUint8Array()});break;case z:{let o=n.readVarUint();if(o!==J)throw new i(`Unknown auth message type ${o}`);s.push({type:"auth",reason:n.readVarString()});break}case X:s.push({type:"query-awareness"});break;default:throw new i(`Unknown top-level message type ${a}`)}}return s}export{M as a,oe as b,ae as c,ce as d,ie as e,p as f,H as g,pe as h,Ee as i,be as j,we as k,he as l,Se as m,_e as n,me as o,Ue as p,Re as q,ge as r,Ce as s,Ie as t,Te as u,Ne as v,Me as w};
@@ -0,0 +1 @@
1
+ import {c as c$1}from'./chunk-HGKSOBXK.mjs';import {a}from'./chunk-TTRUPDAB.mjs';var k={};a(k,{build_display_list_json:()=>A,clear_measure_fonts:()=>W,close_display_list:()=>z,default:()=>U,hit_test_json:()=>Y,hit_test_regions_by_handle:()=>K,hit_test_regions_json:()=>D,initSync:()=>P,install_panic_hook:()=>Q,layout_document_json:()=>M,measure_paragraph_json:()=>B,open_display_list:()=>Z,outline_glyph_json:()=>I,range_rects_by_handle:()=>ee,range_rects_json:()=>H,range_rects_on_pages_by_handle:()=>ne,range_rects_on_pages_json:()=>te,range_rects_region_by_handle:()=>re,range_rects_region_json:()=>oe,register_measure_font:()=>S,register_substitute_measure_font:()=>J,update_display_list:()=>se,vertical_move_by_handle:()=>ie,vertical_move_json:()=>ae});function A(e){let n,t;try{let _=p(e,o.__wbindgen_malloc,o.__wbindgen_realloc),a=f,i=o.build_display_list_json(_,a);var r=i[0],s=i[1];if(i[3])throw r=0,s=0,g(i[2]);return n=r,t=s,b(r,s)}finally{o.__wbindgen_free(n,t,1);}}function W(){let e=o.clear_measure_fonts();if(e[1])throw g(e[0])}function z(e){o.close_display_list(e);}function Y(e,n,t,r){let s,_;try{let l=p(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=f,d=o.hit_test_json(l,u,n,t,r);var a=d[0],i=d[1];if(d[3])throw a=0,i=0,g(d[2]);return s=a,_=i,b(a,i)}finally{o.__wbindgen_free(s,_,1);}}function K(e,n,t,r){let s,_;try{let l=o.hit_test_regions_by_handle(e,n,t,r);var a=l[0],i=l[1];if(l[3])throw a=0,i=0,g(l[2]);return s=a,_=i,b(a,i)}finally{o.__wbindgen_free(s,_,1);}}function D(e,n,t,r){let s,_;try{let l=p(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=f,d=o.hit_test_regions_json(l,u,n,t,r);var a=d[0],i=d[1];if(d[3])throw a=0,i=0,g(d[2]);return s=a,_=i,b(a,i)}finally{o.__wbindgen_free(s,_,1);}}function Q(){o.install_panic_hook();}function M(e){let n,t;try{let _=p(e,o.__wbindgen_malloc,o.__wbindgen_realloc),a=f,i=o.layout_document_json(_,a);var r=i[0],s=i[1];if(i[3])throw r=0,s=0,g(i[2]);return n=r,t=s,b(r,s)}finally{o.__wbindgen_free(n,t,1);}}function B(e){let n,t;try{let _=p(e,o.__wbindgen_malloc,o.__wbindgen_realloc),a=f,i=o.measure_paragraph_json(_,a);var r=i[0],s=i[1];if(i[3])throw r=0,s=0,g(i[2]);return n=r,t=s,b(r,s)}finally{o.__wbindgen_free(n,t,1);}}function Z(e){let n=p(e,o.__wbindgen_malloc,o.__wbindgen_realloc),t=f,r=o.open_display_list(n,t);if(r[2])throw g(r[1]);return r[0]>>>0}function I(e,n){let t,r;try{let a=o.outline_glyph_json(e,n);var s=a[0],_=a[1];if(a[3])throw s=0,_=0,g(a[2]);return t=s,r=_,b(s,_)}finally{o.__wbindgen_free(t,r,1);}}function ee(e,n,t){let r,s;try{let i=o.range_rects_by_handle(e,n,t);var _=i[0],a=i[1];if(i[3])throw _=0,a=0,g(i[2]);return r=_,s=a,b(_,a)}finally{o.__wbindgen_free(r,s,1);}}function H(e,n,t){let r,s;try{let i=p(e,o.__wbindgen_malloc,o.__wbindgen_realloc),l=f,u=o.range_rects_json(i,l,n,t);var _=u[0],a=u[1];if(u[3])throw _=0,a=0,g(u[2]);return r=_,s=a,b(_,a)}finally{o.__wbindgen_free(r,s,1);}}function ne(e,n,t,r,s){let _,a;try{let u=o.range_rects_on_pages_by_handle(e,n,t,r,s);var i=u[0],l=u[1];if(u[3])throw i=0,l=0,g(u[2]);return _=i,a=l,b(i,l)}finally{o.__wbindgen_free(_,a,1);}}function te(e,n,t,r,s){let _,a;try{let u=p(e,o.__wbindgen_malloc,o.__wbindgen_realloc),d=f,w=o.range_rects_on_pages_json(u,d,n,t,r,s);var i=w[0],l=w[1];if(w[3])throw i=0,l=0,g(w[2]);return _=i,a=l,b(i,l)}finally{o.__wbindgen_free(_,a,1);}}function re(e,n,t,r,s){let _,a;try{let u=p(n,o.__wbindgen_malloc,o.__wbindgen_realloc),d=f,w=p(t,o.__wbindgen_malloc,o.__wbindgen_realloc),m=f,h=o.range_rects_region_by_handle(e,u,d,w,m,r,s);var i=h[0],l=h[1];if(h[3])throw i=0,l=0,g(h[2]);return _=i,a=l,b(i,l)}finally{o.__wbindgen_free(_,a,1);}}function oe(e,n,t,r,s){let _,a;try{let u=p(e,o.__wbindgen_malloc,o.__wbindgen_realloc),d=f,w=p(n,o.__wbindgen_malloc,o.__wbindgen_realloc),m=f,h=p(t,o.__wbindgen_malloc,o.__wbindgen_realloc),V=f,j=o.range_rects_region_json(u,d,w,m,h,V,r,s);var i=j[0],l=j[1];if(j[3])throw i=0,l=0,g(j[2]);return _=i,a=l,b(i,l)}finally{o.__wbindgen_free(_,a,1);}}function S(e){let n=_e(e,o.__wbindgen_malloc),t=f,r=o.register_measure_font(n,t);if(r[2])throw g(r[1]);return r[0]>>>0}function J(e,n){let t=p(n,o.__wbindgen_malloc,o.__wbindgen_realloc),r=f,s=o.register_substitute_measure_font(e,t,r);if(s[2])throw g(s[1]);return s[0]>>>0}function se(e,n){let t=p(n,o.__wbindgen_malloc,o.__wbindgen_realloc),r=f,s=o.update_display_list(e,t,r);if(s[1])throw g(s[0])}function ie(e,n,t,r){let s,_;try{let l=p(t,o.__wbindgen_malloc,o.__wbindgen_realloc),u=f,d=o.vertical_move_by_handle(e,n,l,u,r);var a=d[0],i=d[1];if(d[3])throw a=0,i=0,g(d[2]);return s=a,_=i,b(a,i)}finally{o.__wbindgen_free(s,_,1);}}function ae(e,n,t,r){let s,_;try{let l=p(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=f,d=p(t,o.__wbindgen_malloc,o.__wbindgen_realloc),w=f,m=o.vertical_move_json(l,u,n,d,w,r);var a=m[0],i=m[1];if(m[3])throw a=0,i=0,g(m[2]);return s=a,_=i,b(a,i)}finally{o.__wbindgen_free(s,_,1);}}function G(){return {__proto__:null,"./docx_layout_bg.js":{__proto__:null,__wbg___wbindgen_is_function_1f9d30630b8b1d3d:function(n){return typeof n=="function"},__wbg___wbindgen_is_undefined_8865fb403f8fe9d8:function(n){return n===void 0},__wbg___wbindgen_throw_41e9ee4f547fc59a:function(n,t){throw new Error(b(n,t))},__wbg_call_6137034ef55c9d0f:function(){return F(function(n,t){return n.call(t)},arguments)},__wbg_error_6f2529748b0b6312:function(n,t){console.error(b(n,t));},__wbg_get_31af05bd4842a84f:function(){return F(function(n,t){return Reflect.get(n,t)},arguments)},__wbg_static_accessor_GLOBAL_266715b9d96ba635:function(){let n=typeof global>"u"?null:global;return L(n)?0:x(n)},__wbg_static_accessor_GLOBAL_THIS_10fb7dc1ae063179:function(){let n=typeof globalThis>"u"?null:globalThis;return L(n)?0:x(n)},__wbg_static_accessor_SELF_0b583911f537483a:function(){let n=typeof self>"u"?null:self;return L(n)?0:x(n)},__wbg_static_accessor_WINDOW_d7f903d1508cbdc4:function(){let n=typeof window>"u"?null:window;return L(n)?0:x(n)},__wbindgen_generic_0000000000000001:function(n,t){return b(n,t)},__wbindgen_init_externref_table:function(){let n=o.__wbindgen_externrefs,t=n.grow(4);n.set(0,void 0),n.set(t+0,void 0),n.set(t+1,null),n.set(t+2,true),n.set(t+3,false);}}}}function x(e){let n=o.__externref_table_alloc();return o.__wbindgen_externrefs.set(n,e),n}function b(e,n){return ce(e>>>0,n)}var v=null;function R(){return (v===null||v.byteLength===0)&&(v=new Uint8Array(o.memory.buffer)),v}function F(e,n){try{return e.apply(this,n)}catch(t){let r=x(t);o.__wbindgen_exn_store(r);}}function L(e){return e==null}function _e(e,n){let t=n(e.length*1,1)>>>0;return R().set(e,t/1),f=e.length,t}function p(e,n,t){if(t===void 0){let i=E.encode(e),l=n(i.length,1)>>>0;return R().subarray(l,l+i.length).set(i),f=i.length,l}let r=e.length,s=n(r,1)>>>0,_=R(),a=0;for(;a<r;a++){let i=e.charCodeAt(a);if(i>127)break;_[s+a]=i;}if(a!==r){a!==0&&(e=e.slice(a)),s=t(s,r,r=a+e.length*3,1)>>>0;let i=R().subarray(s+a,s+r),l=E.encodeInto(e,i);a+=l.written,s=t(s,r,a,1)>>>0;}return f=a,s}function g(e){let n=o.__wbindgen_externrefs.get(e);return o.__externref_table_dealloc(e),n}var O=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true});O.decode();var le=2146435072,T=0;function ce(e,n){return T+=n,T>=le&&(O=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}),O.decode(),T=n),O.decode(R().subarray(e,e+n))}var E=new TextEncoder;"encodeInto"in E||(E.encodeInto=function(e,n){let t=E.encode(e);return n.set(t),{read:e.length,written:t.length}});var f=0,o;function C(e,n){return o=e.exports,v=null,o.__wbindgen_start(),o}async function fe(e,n){if(typeof Response=="function"&&e instanceof Response){if(!e.ok)throw new Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,n)}catch(s){if(t(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",s);else throw s}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,n)}else {let r=await WebAssembly.instantiate(e,n);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}function t(r){switch(r){case "basic":case "cors":case "default":return true}return false}}function P(e){if(o!==void 0)return o;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module:e}=e:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let n=G();e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e));let t=new WebAssembly.Instance(e,n);return C(t)}async function U(e){if(o!==void 0)return o;if(e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),e===void 0)throw new Error("docx-layout requires an explicit module or URL");let n=G();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:t,module:r}=await fe(await e,n);return C(t)}var c=c$1({label:"docx-layout",preloadName:"preloadLayoutWasm",assetUrl:()=>new URL("./generated/layout/docx_layout_bg.wasm",import.meta.url),initAsync:U,initSync:P});function we(e){return c.preload(e)}function me(e,n,t,r){return c.ensure(),D(e,n,t,r)}function he(e,n,t){return c.ensure(),H(e,n,t)}function xe(e,n,t,r,s){c.ensure();let _=y("range_rects_on_pages_json");if(!_)throw new Error("range_rects_on_pages_json is not available in the embedded layout wasm");return _(e,n,t,r,s)}function y(e){let n=k[e];return typeof n=="function"?n:void 0}function ve(){return c.ensure(),y("open_display_list")!==void 0}function Re(){return c.ensure(),y("range_rects_on_pages_json")!==void 0&&y("range_rects_on_pages_by_handle")!==void 0}function Ee(){return c.ensure(),y("range_rects_region_json")!==void 0}function je(e){c.ensure();let n=y("open_display_list");if(!n)throw new Error("open_display_list is not available in the embedded layout wasm yet");return n(e)}function Le(e){c.ensure(),y("close_display_list")?.(e);}function Oe(e,n){c.ensure();let t=y("update_display_list");if(!t)throw new Error("update_display_list is not available in the embedded layout wasm yet");t(e,n);}function Te(){return c.ensure(),y("update_display_list")!==void 0}function Ae(e,n,t,r){c.ensure();let s=y("hit_test_regions_by_handle");if(!s)throw new Error("hit_test_regions_by_handle is not available in the embedded layout wasm yet");return s(e,n,t,r)}function We(e,n,t,r){c.ensure();let s=y("vertical_move_json");if(!s)throw new Error("vertical_move_json is not available in the embedded layout wasm");return s(e,n,t,r)}function De(e,n,t,r){c.ensure();let s=y("vertical_move_by_handle");if(!s)throw new Error("vertical_move_by_handle is not available in the embedded layout wasm");return s(e,n,t,r)}function Me(e,n,t){c.ensure();let r=y("range_rects_by_handle");if(!r)throw new Error("range_rects_by_handle is not available in the embedded layout wasm yet");return r(e,n,t)}function Be(e,n,t,r,s){c.ensure();let _=y("range_rects_on_pages_by_handle");if(!_)throw new Error("range_rects_on_pages_by_handle is not available in the embedded layout wasm");return _(e,n,t,r,s)}function Ie(e,n,t,r,s){c.ensure();let _=y("range_rects_region_json");if(!_)throw new Error("range_rects_region_json is not available in the embedded layout wasm yet");return _(e,n,t,r,s)}function He(e,n,t,r,s){c.ensure();let _=y("range_rects_region_by_handle");if(!_)throw new Error("range_rects_region_by_handle is not available in the embedded layout wasm yet");return _(e,n,t,r,s)}function Se(e){return c.ensure(),A(e)}function Je(e){return c.ensure(),M(e)}function Pe(e){return c.ensure(),S(e)}function Ue(e,n){return c.ensure(),J(e,n)}function ke(){c.ensure(),W();}function qe(e){return c.ensure(),B(e)}function ge(){let e=I;return typeof e=="function"?e:void 0}function Fe(e,n){c.ensure();let t=ge();if(!t)throw new Error("outline_glyph_json is not available in the embedded layout wasm yet");return t(e,n)}export{we as a,me as b,he as c,xe as d,ve as e,Re as f,Ee as g,je as h,Le as i,Oe as j,Te as k,Ae as l,We as m,De as n,Me as o,Be as p,Ie as q,He as r,Se as s,Je as t,Pe as u,Ue as v,ke as w,qe as x,Fe as y};
@@ -0,0 +1 @@
1
+ import {c}from'./chunk-HGKSOBXK.mjs';function E(e){let n=h(e,s.__wbindgen_malloc),t=_,r=s.decodeTiffPng(n,t);if(r[3])throw u(r[2]);var i=T(r[0],r[1]).slice();return s.__wbindgen_free(r[0],r[1]*1,1),i}function U(){return s.paragraphPatchWriterVersion()>>>0}function I(e,n){let t,r;try{let o=h(e,s.__wbindgen_malloc),a=_,f=g(n,s.__wbindgen_malloc,s.__wbindgen_realloc),W=_,d=s.parse_docx_s9(o,a,f,W);var i=d[0],c=d[1];if(d[3])throw i=0,c=0,u(d[2]);return t=i,r=c,w(i,c)}finally{s.__wbindgen_free(t,r,1);}}function O(e,n){let t,r;try{let o=h(e,s.__wbindgen_malloc),a=_,f=g(n,s.__wbindgen_malloc,s.__wbindgen_realloc),W=_,d=s.parse_relationships_xml(o,a,f,W);var i=d[0],c=d[1];if(d[3])throw i=0,c=0,u(d[2]);return t=i,r=c,w(i,c)}finally{s.__wbindgen_free(t,r,1);}}function P(e){let n,t;try{let c=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),o=_,a=s.serialize_docx_s10(c,o);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,u(a[2]);return n=r,t=i,w(r,i)}finally{s.__wbindgen_free(n,t,1);}}function L(e){let n,t;try{let c=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),o=_,a=s.serialize_docx_s11(c,o);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,u(a[2]);return n=r,t=i,w(r,i)}finally{s.__wbindgen_free(n,t,1);}}function D(e){let n,t;try{let c=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),o=_,a=s.serialize_docx_s12(c,o);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,u(a[2]);return n=r,t=i,w(r,i)}finally{s.__wbindgen_free(n,t,1);}}function z(e,n){let t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=_,i=h(n,s.__wbindgen_malloc),c=_,o=s.write_docx_s13_wasm(t,r,i,c);if(o[3])throw u(o[2]);var a=T(o[0],o[1]).slice();return s.__wbindgen_free(o[0],o[1]*1,1),a}function M(e,n){let t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=_,i=h(n,s.__wbindgen_malloc),c=_,o=s.write_docx_s13_wasm_with_warnings(t,r,i,c);if(o[3])throw u(o[2]);var a=T(o[0],o[1]).slice();return s.__wbindgen_free(o[0],o[1]*1,1),a}function B(){return {__proto__:null,"./docx_parse_bg.js":{__proto__:null,__wbg___wbindgen_is_function_1f9d30630b8b1d3d:function(n){return typeof n=="function"},__wbg___wbindgen_is_undefined_8865fb403f8fe9d8:function(n){return n===void 0},__wbg___wbindgen_throw_41e9ee4f547fc59a:function(n,t){throw new Error(w(n,t))},__wbg_call_6137034ef55c9d0f:function(){return R(function(n,t){return n.call(t)},arguments)},__wbg_get_31af05bd4842a84f:function(){return R(function(n,t){return Reflect.get(n,t)},arguments)},__wbg_static_accessor_GLOBAL_266715b9d96ba635:function(){let n=typeof global>"u"?null:global;return m(n)?0:p(n)},__wbg_static_accessor_GLOBAL_THIS_10fb7dc1ae063179:function(){let n=typeof globalThis>"u"?null:globalThis;return m(n)?0:p(n)},__wbg_static_accessor_SELF_0b583911f537483a:function(){let n=typeof self>"u"?null:self;return m(n)?0:p(n)},__wbg_static_accessor_WINDOW_d7f903d1508cbdc4:function(){let n=typeof window>"u"?null:window;return m(n)?0:p(n)},__wbindgen_generic_0000000000000001:function(n,t){return w(n,t)},__wbindgen_init_externref_table:function(){let n=s.__wbindgen_externrefs,t=n.grow(4);n.set(0,void 0),n.set(t+0,void 0),n.set(t+1,null),n.set(t+2,true),n.set(t+3,false);}}}}function p(e){let n=s.__externref_table_alloc();return s.__wbindgen_externrefs.set(n,e),n}function T(e,n){return e=e>>>0,b().subarray(e/1,e/1+n)}function w(e,n){return G(e>>>0,n)}var y=null;function b(){return (y===null||y.byteLength===0)&&(y=new Uint8Array(s.memory.buffer)),y}function R(e,n){try{return e.apply(this,n)}catch(t){let r=p(t);s.__wbindgen_exn_store(r);}}function m(e){return e==null}function h(e,n){let t=n(e.length*1,1)>>>0;return b().set(e,t/1),_=e.length,t}function g(e,n,t){if(t===void 0){let a=x.encode(e),f=n(a.length,1)>>>0;return b().subarray(f,f+a.length).set(a),_=a.length,f}let r=e.length,i=n(r,1)>>>0,c=b(),o=0;for(;o<r;o++){let a=e.charCodeAt(o);if(a>127)break;c[i+o]=a;}if(o!==r){o!==0&&(e=e.slice(o)),i=t(i,r,r=o+e.length*3,1)>>>0;let a=b().subarray(i+o,i+r),f=x.encodeInto(e,a);o+=f.written,i=t(i,r,o,1)>>>0;}return _=o,i}function u(e){let n=s.__wbindgen_externrefs.get(e);return s.__externref_table_dealloc(e),n}var v=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true});v.decode();var q=2146435072,A=0;function G(e,n){return A+=n,A>=q&&(v=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}),v.decode(),A=n),v.decode(b().subarray(e,e+n))}var x=new TextEncoder;"encodeInto"in x||(x.encodeInto=function(e,n){let t=x.encode(e);return n.set(t),{read:e.length,written:t.length}});var _=0,s;function N(e,n){return s=e.exports,y=null,s.__wbindgen_start(),s}async function X(e,n){if(typeof Response=="function"&&e instanceof Response){if(!e.ok)throw new Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,n)}catch(i){if(t(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",i);else throw i}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,n)}else {let r=await WebAssembly.instantiate(e,n);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}function t(r){switch(r){case "basic":case "cors":case "default":return true}return false}}function V(e){if(s!==void 0)return s;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module:e}=e:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let n=B();e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e));let t=new WebAssembly.Instance(e,n);return N(t)}async function j(e){if(s!==void 0)return s;if(e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),e===void 0)throw new Error("docx-parse requires an explicit module or URL");let n=B();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:t,module:r}=await X(await e,n);return N(t)}var l=c({label:"docx-parse",preloadName:"preloadParseWasm",assetUrl:()=>new URL("./generated/parse/docx_parse_bg.wasm",import.meta.url),initAsync:j,initSync:V}),F=false;function Z(e){return l.preload(e).then(()=>{F=true;})}var ee=1;function ne(){let e=U;if(typeof e=="function")return F?e():null}function te(e,n){return l.ensure(),I(e,n)}function re(e,n){return l.ensure(),O(e,n)}function se(e){return l.ensure(),P(e)}function ie(e){return l.ensure(),L(e)}function oe(e){return l.ensure(),D(e)}function ae(e,n){return l.ensure(),z(e,n)}function ce(e,n){l.ensure();let t=M(e,n);if(t.byteLength<8)throw new Error("Rust save response is truncated");let r=Number(new DataView(t.buffer,t.byteOffset,t.byteLength).getBigUint64(0,true));if(!Number.isSafeInteger(r)||8+r>t.byteLength)throw new Error("Rust save response carries a corrupt warnings frame");let i=JSON.parse(new TextDecoder().decode(t.subarray(8,8+r)));if(!Array.isArray(i)||!i.every(c=>typeof c=="string"))throw new Error("Rust save response carries malformed warnings");return {bytes:t.subarray(8+r),warnings:i}}function _e(e){l.ensure();try{return E(e)}catch(n){throw n instanceof Error?n:new Error(typeof n=="string"?n:String(n))}}export{Z as a,ee as b,ne as c,te as d,re as e,se as f,ie as g,oe as h,ae as i,ce as j,_e as k};