@docx-editor.dev/core 2.30.0 → 2.31.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.
- package/dist/automation.cjs +1 -1
- package/dist/automation.d.ts +16 -25
- package/dist/automation.js +1 -1
- package/dist/binding.cjs +1 -1
- package/dist/binding.d.ts +15 -16
- package/dist/binding.js +1 -1
- package/dist/bookmark-names-DDuAra_V.d.ts +37 -0
- package/dist/{chrome-print-BM3Js-6X.d.ts → chrome-print-BWvaVEhD.d.ts} +318 -33
- package/dist/chunk-243W4WW2.cjs +2 -0
- package/dist/{chunk-RJCQGJR7.js → chunk-2E2RPEKX.js} +1 -1
- package/dist/chunk-4S24UOPG.js +30 -0
- package/dist/chunk-5JPIEN54.cjs +3 -0
- package/dist/{chunk-KJRTNY2Q.cjs → chunk-5SO5QDMV.cjs} +1 -1
- package/dist/{chunk-WF7JZ755.cjs → chunk-6IDOVU6L.cjs} +1 -1
- package/dist/chunk-DBOOTED4.cjs +30 -0
- package/dist/chunk-EOTAXOJY.cjs +5 -0
- package/dist/chunk-FDAKJ2SJ.cjs +30 -0
- package/dist/chunk-FNNOJNGY.js +3 -0
- package/dist/chunk-FT33HRZP.js +5 -0
- package/dist/{chunk-HYASLE2G.cjs → chunk-HC6YNKUI.cjs} +1 -1
- package/dist/chunk-HZ66UCIS.js +2 -0
- package/dist/{chunk-5RRAZMBU.cjs → chunk-IBRBNT37.cjs} +1 -1
- package/dist/chunk-IVIN7X43.js +30 -0
- package/dist/chunk-LZY6B6IV.js +4 -0
- package/dist/chunk-MOYYRVFV.cjs +2 -0
- package/dist/{chunk-YZGUBCHP.js → chunk-N6B3BXCL.js} +1 -1
- package/dist/chunk-Q5K2GGNG.js +2 -0
- package/dist/chunk-R2XINWVE.js +7 -0
- package/dist/chunk-SUEXVBPR.js +1 -0
- package/dist/chunk-T2QQHG5C.js +18 -0
- package/dist/{chunk-T32MGBJS.js → chunk-VWIJKH4A.js} +1 -1
- package/dist/chunk-WO4V6PNS.cjs +18 -0
- package/dist/chunk-XMJKFURD.cjs +4 -0
- package/dist/{chunk-FLBEJC6X.cjs → chunk-XSTGE3NI.cjs} +1 -1
- package/dist/chunk-YQWMI6J5.cjs +7 -0
- package/dist/{chunk-WPDD2Y32.js → chunk-ZCJS7D7S.js} +1 -1
- package/dist/collaboration/replication.cjs +1 -1
- package/dist/collaboration/replication.d.ts +4 -5
- package/dist/collaboration/replication.js +1 -1
- package/dist/collaboration.d.ts +3 -4
- package/dist/contracts/document.d.ts +3 -3
- package/dist/contracts/editor.d.ts +8 -9
- package/dist/contracts/interaction.d.ts +2 -2
- package/dist/contracts/modules.d.ts +12 -13
- package/dist/contracts/types.d.ts +2 -2
- package/dist/{custom-node-writes-0v0Kgw1T.d.ts → custom-node-writes-TeUvMP13.d.ts} +2 -2
- package/dist/{diagnostic-context-CcAO4q1s.d.ts → diagnostic-context-DJ0P1uZE.d.ts} +3 -2
- package/dist/{diagnostic-hints-2Bke6H_w.d.ts → diagnostic-hints-C9JlLz1L.d.ts} +1 -1
- package/dist/{document-protection-8eyMWIJ0.d.ts → document-protection-C8x3P2J6.d.ts} +1 -1
- package/dist/{editor-DaEJd2so.d.ts → editor-B2ShlO23.d.ts} +292 -50
- package/dist/{editor-scope-7o9xweiJ.d.ts → editor-scope-C7ke1KJG.d.ts} +57 -4
- package/dist/editor.cjs +1 -1
- package/dist/editor.css +5 -3
- package/dist/editor.d.ts +602 -31
- package/dist/editor.js +1 -1
- package/dist/export.cjs +2 -2
- package/dist/export.d.ts +13 -14
- package/dist/export.js +2 -2
- package/dist/{font-resolver-CL9BVKZo.d.ts → font-resolver-CWh40DYp.d.ts} +1 -1
- package/dist/{headless-document-view-DZQN8Bnx.d.ts → headless-document-view-qOpaCF82.d.ts} +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +22 -23
- package/dist/index.js +1 -1
- package/dist/{layout-shaping-cEnVrhWg.d.ts → layout-shaping-CWS3j0Xr.d.ts} +1 -1
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.ts +87 -22
- package/dist/layout.js +1 -1
- package/dist/{note-properties-9FH8zAeG.d.ts → note-properties-QsKh24sM.d.ts} +1 -1
- package/dist/{omml-equation-DP2WpUbK.d.ts → omml-equation-BsLAa2lX.d.ts} +27 -9
- package/dist/output.cjs +1 -1
- package/dist/output.d.ts +20 -10
- package/dist/output.js +1 -1
- package/dist/{protocol-CZ1uUlPO.d.ts → protocol-COZJUKUY.d.ts} +94 -2
- package/dist/{review-paragraph-order-CqVelc5A.d.ts → review-paragraph-order-C_QbCKcH.d.ts} +1 -1
- package/dist/{semantic-cell-selection-Dr9yxFZt.d.ts → semantic-cell-selection-Cub9FDa8.d.ts} +2 -2
- package/dist/{semantic-interaction-Dc3pf3hr.d.ts → semantic-interaction-dApRIYpt.d.ts} +1 -1
- package/dist/{semantic-paint-Bz3FBAoH.d.ts → semantic-paint-DLzA8sjP.d.ts} +3 -3
- package/dist/{semantic-record-queries-Bx0pl6kL.d.ts → semantic-record-queries-3yp9o11g.d.ts} +1 -1
- package/dist/{semantic-records-CjcF26ZL.d.ts → semantic-records-B-akgRch.d.ts} +130 -87
- package/dist/store.cjs +1 -1
- package/dist/store.d.ts +48 -22
- package/dist/store.js +1 -1
- package/dist/{tree-package-store-DKhdEVym.d.ts → tree-package-store-B8l8DX3Z.d.ts} +675 -645
- package/dist/{tree-session-contract-CwnTEVLF.d.ts → tree-session-contract-DeLRqohz.d.ts} +26 -13
- package/dist/{types-barrel-CA0xB8kH.d.ts → types-barrel-CkF2JbU4.d.ts} +1146 -745
- package/package.json +2 -2
- package/dist/chunk-2PV5L5NJ.js +0 -5
- package/dist/chunk-5OTS2EJ7.js +0 -7
- package/dist/chunk-5P4223J4.cjs +0 -27
- package/dist/chunk-5SPITS5F.js +0 -18
- package/dist/chunk-7ATNKARV.js +0 -2
- package/dist/chunk-BGCUTKWE.cjs +0 -5
- package/dist/chunk-EBCXSH2W.js +0 -3
- package/dist/chunk-ERECKTIR.cjs +0 -2
- package/dist/chunk-JC47NRJC.cjs +0 -3
- package/dist/chunk-NKPUH3QJ.js +0 -1
- package/dist/chunk-PF5NJWS3.js +0 -2
- package/dist/chunk-PWTRJSES.cjs +0 -18
- package/dist/chunk-QFKGI242.cjs +0 -30
- package/dist/chunk-RPPV4S6T.cjs +0 -4
- package/dist/chunk-UM26GH5B.js +0 -30
- package/dist/chunk-VRCZBFLH.js +0 -27
- package/dist/chunk-WK5X2MMA.cjs +0 -7
- package/dist/chunk-YBMWBXST.cjs +0 -2
- package/dist/chunk-ZOS2PM4A.js +0 -4
- package/dist/image-resources-Bipz8toD.d.ts +0 -211
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use strict';var chunkHC6YNKUI_cjs=require('./chunk-HC6YNKUI.cjs'),chunkDBOOTED4_cjs=require('./chunk-DBOOTED4.cjs'),chunk5SO5QDMV_cjs=require('./chunk-5SO5QDMV.cjs'),chunk243W4WW2_cjs=require('./chunk-243W4WW2.cjs'),chunk6IDOVU6L_cjs=require('./chunk-6IDOVU6L.cjs'),chunkWO4V6PNS_cjs=require('./chunk-WO4V6PNS.cjs');var yt=Object.freeze(["default","first","even"]);function Vo(e){return e.kind==="body"||e.kind==="header"||e.kind==="footer"}var Se=Object.freeze({kind:"body"});function z(e){switch(e.kind){case "body":return "body";case "note":return `note:${e.noteKind}:${String(e.noteId)}`;case "textbox":return `textbox:${z(e.owner)}:${String(e.shapeId)}`;default:return `${e.kind}:${String(e.sectionIndex)}:${e.variant}`}}function Uo(e){if(typeof e!="object"||e===null)return false;let t=e;return t.kind==="body"?true:t.kind==="textbox"?Uo(t.owner)&&Vo(t.owner)&&Number.isInteger(t.shapeId)&&t.shapeId>=0:t.kind==="note"?(t.noteKind==="footnote"||t.noteKind==="endnote")&&Number.isInteger(t.noteId):t.kind!=="header"&&t.kind!=="footer"?false:Number.isInteger(t.sectionIndex)&&t.sectionIndex>=0&&yt.includes(t.variant)}function Ue(e){return e.kind==="note"||e.kind==="textbox"}var ki=["getTables","getTable","getTableRows","getTableCells","getTableCell","getTableCellProperties","getTableCellBody","getFields","getField","getInlinePictures","getInlinePicture","getShapes","getShape","getShapeBody","getChangeTrackingMode","getDocument","getDocumentProperty","getBody","getParagraphs","getRange","getSpanParagraphs","getText","getSpanText","getParagraphId","search","getFont","getParagraphFormat","getStyle","getSections","getPageSetup","getFurniture","getNotes","getNoteBody","getNoteText","getNoteKind","getLists","getListId","getListById","getListParagraphs","getParagraphList","getListLevel","getHyperlink","getBookmarks","getBookmarkName","getBookmarkRange","getBookmarkNames","getBookmarkRangeByName","getComments","getCommentReplies","getCommentId","getCommentAuthor","getCommentDate","getCommentText","getCommentRange","getCommentResolved","getRevisions","getRevisionType","getRevisionAuthor","getRevisionDate","getRevisionRange","getReviewItemRange","getContentControls","getContentControlById","getContentControlsByTag","getContentControlsByTitle","getContentControlTag","getContentControlTitle","getContentControlFileId","getContentControlSubtype","getContentControlLock","getContentControlIsBound","getContentControlPlaceholderShown","getContentControlTemporary","getContentControlText","getContentControlParagraphs","getContentControlRange"],Wo=["removeDocumentInformation","setDocumentProperties","insertTableRows","insertTable","updateTable","updateTableCell","setInlinePicture","deleteInlinePicture","insertField","setFieldCode","deleteField","updateFieldResult","insertInlinePicture","insertBreak","setChangeTrackingMode","proposeInsertion","proposeDeletion","proposeReplacement","insertText","replaceSpan","replaceStoryBlocks","insertParagraph","splitParagraph","deleteParagraph","selectSpan","selectBookmark","insertBookmark","deleteBookmark","setFont","setParagraphFormat","setStyle","setPageSetup","deleteNote","setListLevel","startNewList","attachToList","detachFromList","setListLevelFormat","insertListParagraph","setHyperlink","insertComment","setCommentResolved","replyToComment","deleteComment","acceptRevision","rejectRevision","resolveRevisionBatch","setRevisionAuthorBatch","acceptAllRevisions","rejectAllRevisions","setContentControlValue","setContentControlProperties","deleteContentControl","insertContentControlText","insertContentControl","insertCustomNode"],$o=["removeDocumentInformation","insertTableRows","resolveRevisionBatch","setRevisionAuthorBatch","insertTable","insertInlinePicture","insertBreak","startNewList","deleteNote","insertComment","setCommentResolved","replyToComment","insertCustomNode"],vd=new Set($o);function rn(e){return vd.has(e.op)&&!(e.op==="insertBreak"&&e.breakType==="Line")||e.op==="updateTable"&&["addRows","addColumns","deleteRows","deleteColumns","delete"].includes(e.mutation.kind)}var Ad=new Set(Wo);function et(e){return Ad.has(e.op)}var Rd="http://schemas.openxmlformats.org/drawingml/2006/picture",Od="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",Pd="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",Id=4096,Sd=65536;function wd(e){return e&&e.kind!=="textValue"?e:null}function Gn(e,t,n){return e.kind!=="textValue"&&e.namespaceUri===t&&e.localName===n}function kt(e,t,n){return wd(e.children.find(o=>Gn(o,t,n)))}function Cd(e){let t=e.children.find(m=>m.kind==="anchoredDrawing"||m.kind==="inlineDrawing"||Gn(m,chunkWO4V6PNS_cjs.sa,"anchor")||Gn(m,chunkWO4V6PNS_cjs.sa,"inline"));if(!t||t.kind==="textValue")return null;let n=kt(t,chunkWO4V6PNS_cjs.sa,"docPr"),o=n?chunkWO4V6PNS_cjs.ka(n.attributes,"id"):void 0;if(!n||o===void 0||!/^\d{1,10}$/.test(o)||Number(o)>4294967295)return "malformed";let r=chunkWO4V6PNS_cjs.ka(n.attributes,"name")??"",a=kt(t,chunkWO4V6PNS_cjs.ra,"graphic"),i=a?kt(a,chunkWO4V6PNS_cjs.ra,"graphicData"):null,s=i?chunkWO4V6PNS_cjs.ka(i.attributes,"uri"):void 0,d="Unsupported",u=null;if(i&&s===chunkWO4V6PNS_cjs.ia){let m=kt(i,chunkWO4V6PNS_cjs.ia,"wsp"),p=m?kt(m,chunkWO4V6PNS_cjs.ia,"txbx"):null;u=p?kt(p,chunkWO4V6PNS_cjs.la,"txbxContent"):null;let h=m?kt(m,chunkWO4V6PNS_cjs.ia,"cNvSpPr"):null,f=h?chunkWO4V6PNS_cjs.ka(h.attributes,"txBox"):void 0;d=m?f==="1"||f==="true"?"TextBox":"GeometricShape":"Unsupported";}else s===Rd?d="Picture":s===Od?d="Group":s===Pd&&(d="Canvas");return {read:{id:Number(o),name:r,type:d},root:u}}function Xn(e,t){let n=[],o=new Set;for(let r of t){if(r.kind==="textValue")continue;let a=chunkWO4V6PNS_cjs.ud(chunkWO4V6PNS_cjs.uj(e,r),r),i=[];for(let d=r.children.length-1;d>=0;d-=1)i.push({node:r.children[d],scope:a});let s=0;for(;i.length>0;){if(++s>Sd)return {ok:false,reason:"truncated"};let{node:d,scope:u}=i.pop();if(d.kind==="textValue"||d.kind==="paragraph")continue;let m=chunkWO4V6PNS_cjs.ud(u,d),p=chunkWO4V6PNS_cjs.td(d),h=d.kind==="drawing"||Gn(d,chunkWO4V6PNS_cjs.la,"drawing")?d:p?chunkWO4V6PNS_cjs.Nd(d,m).drawing:null;if(!(p&&!h)){if(h){let f=Cd(h);if(f==="malformed")return {ok:false,reason:"malformed"};if(f){if(o.has(f.read.id))return {ok:false,reason:"duplicates"};if(n.length>=Id)return {ok:false,reason:"truncated"};o.add(f.read.id),n.push({...f.read,hostParagraphId:r.id,textboxRoot:f.root,alternate:p?d:null});}continue}for(let f=d.children.length-1;f>=0;f-=1)i.push({node:d.children[f],scope:m});}}}return {ok:true,shapes:Object.freeze(n)}}var Td=63360;function tt(e){return Math.round(chunkWO4V6PNS_cjs.ld(chunkWO4V6PNS_cjs.jd(e))*100)/100}function Nd(e,t){if(typeof e!="number"||!Number.isFinite(e))return null;let n=chunkWO4V6PNS_cjs.md(chunkWO4V6PNS_cjs.kd(e));return n>Td||n<0||n===0&&!t?null:n}var Ed=[["pageWidth","pageWidthTwips",false],["pageHeight","pageHeightTwips",false],["topMargin","marginTopTwips",true],["rightMargin","marginRightTwips",true],["bottomMargin","marginBottomTwips",true],["leftMargin","marginLeftTwips",true]];function bi(e){if(typeof e!="object"||e===null)return {ok:false,reason:"that is not a page setup",detail:"not-an-object"};let t=e,n={},o=0;for(let[a,i,s]of Ed){let d=t[a];if(d===void 0)continue;let u=Nd(d,s);if(u===null)return {ok:false,reason:`that is not a value for ${a}`,detail:String(d)};n[i]=u,o+=1;}let r=t.orientation;if(r!==void 0){if(r!=="portrait"&&r!=="landscape")return {ok:false,reason:"that is not an orientation",detail:String(r)};n.orientation=r,o+=1;}return o===0?{ok:false,reason:"that page setup names nothing to write",detail:"empty"}:{ok:true,value:n}}function Dd(e){let t=chunkWO4V6PNS_cjs.al(e),n=t.widthTwips>t.heightTwips?"landscape":"portrait";return Object.freeze({pageWidth:tt(t.widthTwips),pageHeight:tt(t.heightTwips),orientation:n,topMargin:tt(t.topTwips),rightMargin:tt(t.rightTwips),bottomMargin:tt(t.bottomTwips),leftMargin:tt(t.leftTwips),headerDistance:tt(t.headerTwips),footerDistance:tt(t.footerTwips),gutter:tt(t.gutterTwips)})}function Ld(e,t){if(!t)return null;let n=null,o=(r,a,i)=>{if(n!==null||r.kind==="textValue"||i>64)return;let s=r.kind==="paragraph"?r.id:a;if(r.id===t.id){n=s;return}for(let d of r.children)o(d,s,i+1);};return o(e.root,null,0),n}function xi(e,t,n){let o=chunkWO4V6PNS_cjs.ff(t.root);return Object.freeze(o.map((r,a)=>{let i=n[a];return Object.freeze({index:a,markParagraphId:Ld(t,r),pageSetup:Dd(r),titlePage:i?.titlePage??false,evenAndOddHeaders:i?.evenAndOddHeaders??false})}))}var vi=new WeakMap,Md=0;function Bd(e){if(!e)return;let t=vi.get(e);return t||(t={...e,cacheKey:`formatting-${++Md}`},vi.set(e,t)),t}function Yn(e){let t=new WeakMap;return (n,o,r,a)=>{let i=Bd(a),s=chunkWO4V6PNS_cjs.Ua(n,o.id),d;for(;s&&s.kind!=="table";){if(s.localName==="txbxContent")return;s.kind==="tableCell"&&(d=s.id),s=chunkWO4V6PNS_cjs.Ua(n,s.id);}if(!s||!d)return;let u=s,m=u.kind==="table"?u.children.find(h=>h.localName==="tblPr")??u:u,p=t.get(m);if(!p||p.table!==u||p.mode!==r||p.filter!==i){let h=new Map,f=chunkDBOOTED4_cjs.Xd(s,1,0,e,r,i);for(let k of f?.rows??[])for(let x of k.cells)h.set(x.id,x.styleFormatting);p={table:u,mode:r,filter:i,cells:h},t.set(m,p);}return p.cells.get(d)}}var Ht={},Ai=new WeakMap;function Hd(e,t){let n=e&&e.kind!=="textValue"?e.children.filter(r=>r.kind==="textValue"||r.localName!=="pStyle"):[];return {...e??{kind:"generic",id:"",localName:"pPr",attributes:[]},children:[{kind:"generic",id:"",namespaceUri:chunkWO4V6PNS_cjs.la,localName:"pStyle",prefix:"w",attributes:[{namespaceUri:chunkWO4V6PNS_cjs.la,localName:"val",prefix:"w",value:t}],children:[]},...n]}}function Fd(e){let t=chunkDBOOTED4_cjs.kd(e.styles,void 0,e.settings),n=Yn(t),o=chunkDBOOTED4_cjs.zc(chunkDBOOTED4_cjs.nc(e.numbering),t);return (r,a,i,s)=>{let d=chunkWO4V6PNS_cjs.Lh(a,"paragraphProperties","pPr"),u=s===void 0?d:Hd(d,s),m=chunkDBOOTED4_cjs.yc(chunkDBOOTED4_cjs.ld(t,u).paragraphPropertyNodes),p=m?chunkDBOOTED4_cjs.oc(o,m.numId,m.ilvl):null,h=chunkDBOOTED4_cjs.md(t,u,n(r,a,i),p?chunkDBOOTED4_cjs.rb(p.level):void 0);return chunkDBOOTED4_cjs.vd(h.inheritedParagraphProperties)}}function Ri(e,t,n,o,r){let a=Ai.get(e.styles??Ht);a||Ai.set(e.styles??Ht,a=new WeakMap);let i=a.get(e.settings??Ht);i||a.set(e.settings??Ht,i=new WeakMap);let s=i.get(e.numbering??Ht);return s||i.set(e.numbering??Ht,s=Fd(e)),s(t,n,o,r)}var jd=255,_d="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering";function Vd(e){let t=(e.relationships.get(e.mainDocumentPart)??[]).find(o=>o.type===_d),n;if(t){let o=chunkWO4V6PNS_cjs.J(t);o.mode==="Internal"&&o.target.ok&&(n=e.parts.get(o.target.partName));}return n??=e.parts.get("/word/numbering.xml"),n?.root??null}function Oi(e){let t=chunkWO4V6PNS_cjs.bd(e),n={styles:t?.root??null,settings:chunkWO4V6PNS_cjs.ah(e)?.root??null,numbering:Vd(e)},o=(s,d,u)=>Ri(n,s,d,"proposed",u);if(!t)return Object.freeze({nameOf:()=>null,idOf:()=>null,defaultId:null,present:false,inheritsRtl:o});let r=new Map,a=new Map,i=null;for(let s of chunkWO4V6PNS_cjs.ad(t).values())if(s.type==="paragraph"){if(r.set(s.styleId,s.name),s.name!==null){let d=s.name.trim().toLowerCase();a.has(d)||a.set(d,s.styleId);}s.isDefault&&i===null&&(i=s.styleId);}return Object.freeze({nameOf:s=>r.get(s)??null,idOf:s=>a.get(s.trim().toLowerCase())??null,defaultId:i,present:true,inheritsRtl:o})}function Jn(e,t,n){let o=chunkWO4V6PNS_cjs.Ta(e,t);if(!o||o.kind!=="paragraph")return null;let r=Ud(chunkWO4V6PNS_cjs.hg(chunkWO4V6PNS_cjs.fg(o),"pStyle"));return r!==null?n.nameOf(r):n.defaultId===null?null:n.nameOf(n.defaultId)}function Ud(e){if(!e)return null;for(let t of e.attributes)if(t.localName==="val")return t.value;return null}function Qn(e,t){if(typeof e!="string"||e.trim().length===0)return {ok:false,detail:"style: not a name"};if(e.length>jd)return {ok:false,detail:"style: name too long"};if(!chunkWO4V6PNS_cjs.T(e))return {ok:false,detail:"style: not valid XML text"};if(!t.present)return {ok:false,detail:"style: this document defines no styles"};let n=t.idOf(e);return n===null?{ok:false,detail:"style: this document defines no paragraph style with that name"}:{ok:true,styleId:n}}function Pi(e,t,n){return t>=n?null:{text:e.text.slice(t-e.rawStart,n-e.rawStart),rawStart:t,rawEnd:n,...e.symbol?{symbol:true}:{},...e.symbol&&e.symbolDisplays?{symbolDisplays:e.symbolDisplays}:{}}}function Wd(e,t){let n=[],o=0;for(let r of e){for(;o<t.length&&t[o].end<=r.rawStart;)o+=1;let a=r.rawEnd-r.rawStart;if(r.text.length!==a||r.resultRuns||r.symbolOffsets){let d=t[o];(!d||d.start>=r.rawEnd)&&n.push(r);continue}let i=r.rawStart;for(;o<t.length;){let d=t[o];if(d.end<=i){o+=1;continue}if(d.start>=r.rawEnd)break;let u=Pi(r,i,Math.min(d.start,r.rawEnd));if(u&&n.push(u),i=Math.max(i,d.end),d.end<=r.rawEnd&&(o+=1),i>=r.rawEnd)break}let s=Pi(r,i,r.rawEnd);s&&n.push(s);}return n}function Ko(e,t){return t.map(n=>{if(!n.text.includes(`
|
|
2
|
+
`))return n;let r=n.text.length===n.rawEnd-n.rawStart&&!n.resultRuns?n.text.replaceAll(`
|
|
3
|
+
`,(a,i)=>e[n.rawStart+i]):n.text.replaceAll(`
|
|
4
|
+
`,chunkWO4V6PNS_cjs.th);return {...n,text:r}})}function Zn(e,t,n){let o=chunkWO4V6PNS_cjs.kj(e,t);if(n==="model")return chunk5SO5QDMV_cjs.b(o);let r=chunk5SO5QDMV_cjs.c(e,t,n);if(n==="allMarkup")return chunk5SO5QDMV_cjs.a(Ko(o,r));let a=$d(e);if(a.length===0)return chunk5SO5QDMV_cjs.a(Ko(o,r));let i=Wd(r,a);return chunk5SO5QDMV_cjs.a(Ko(o,i))}function $d(e){let t=chunkWO4V6PNS_cjs.mg(e),n=[],o=(a,i)=>{if(!(i>64||a.kind==="textValue")){if(a.kind==="revisionInsert"||a.kind==="revisionMoveTo"){let s=t.spanOf(a);s&&s.end>s.start&&n.push({start:s.start,end:s.end});return}for(let s of a.children)o(s,i+1);}};o(e,0),n.sort((a,i)=>a.start-i.start||i.end-a.end);let r=[];for(let a of n){let i=r[r.length-1];i&&a.start<=i.end?i.end=Math.max(i.end,a.end):r.push({...a});}return r}var zo="\r",Kd=Object.freeze({nameOf:()=>null,idOf:()=>null,defaultId:null,present:false,inheritsRtl:()=>false}),zd=Object.freeze([]),Gd=Object.freeze([]),Ii=Object.freeze([]),Si=Object.freeze({ok:true,shapes:[]}),Xd=Object.freeze({package:null,body:null,story:()=>null,storyOf:()=>null,sections:()=>Gd,furniture:()=>Ii,noteIds:()=>({ok:true,ids:wi}),shapes:()=>Si,styles:()=>Kd});function Yd(e){return e.kind==="textValue"?zd:Object.freeze(e.children.filter(t=>t.kind!=="textValue").map(t=>{let n=[];chunkWO4V6PNS_cjs.Sc([t],n,0);let o=t.kind==="paragraph"?"paragraph":t.kind==="table"?"table":"other",r=t.kind==="paragraph"&&chunkWO4V6PNS_cjs.hg(chunkWO4V6PNS_cjs.fg(t),"sectPr")!==void 0;return Object.freeze({id:t.id,kind:o,paragraphIds:Object.freeze(n.map(a=>a.id)),removable:o!=="other"&&!r})}))}function an(e,t,n,o,r){let a=chunkWO4V6PNS_cjs.Rc(o),i=Object.freeze(a.map(f=>f.id)),s=new Map,d=new Map;a.forEach((f,k)=>{s.set(f.id,k),d.set(f.id,f);});let u=new Map,m=f=>{if(!s.has(f))return null;let k=u.get(f);if(k!==void 0)return k;let x=chunkWO4V6PNS_cjs.hj(t,f)??"";return u.set(f,x),x},p=new Map,h=(f,k="allMarkup")=>{let x=d.get(f);if(!x||x.kind!=="paragraph")return null;let O=`${f}:${k}`,I=p.get(O);if(I)return I;let R=Zn(x,m(f)??"",k);return p.set(O,R),R};return {story:e,part:t,root:o,scope:n,paragraphIds:i,blocks:Yd(o),has:f=>s.has(f),indexOf:f=>s.get(f)??-1,paragraph(f){let k=d.get(f);return k?{nodeId:f,paraId:chunkWO4V6PNS_cjs.wb(k),text:h(f)?.text??""}:null},node:f=>d.get(f)??null,rawText:m,paragraphText:(f,k)=>h(f,k)?.text??null,projectedText:h,text:f=>i.map(k=>h(k,f)?.text??"").join(zo),styles:r}}function qn(e,t){let n=an(e.story,e.part,e.scope,t,e.styles);return {...n,indexOf:o=>n.has(o)?e.indexOf(o):-1}}function dt(e){let t=e.parts.get(e.mainDocumentPart);if(!t)return Xd;let n,o=()=>n??=Oi(e),r,a=()=>r??=chunkWO4V6PNS_cjs.hf(e),i,s=new Map,d=new Map,u=new Map,m=R=>{let N=z(R),E=u.get(N);if(E)return E;let D=x(R),B=D?D.paragraphIds.flatMap(F=>{let Y=D.node(F);return Y?[Y]:[]}):[],S=D?Xn(D.part,B):Si;return u.set(N,S),S},p=R=>{let N=d.get(R);if(N)return N;let E=chunkWO4V6PNS_cjs.lh(e,R);if(!E){let V={ok:true,ids:wi};return d.set(R,V),V}let D=[],B=new Set,S=new Set,F=0,Y=false;for(let V of E.root.children){if(chunkWO4V6PNS_cjs.xc(V)!==R)continue;if(F+=1,V.kind!=="note"){Y=true;continue}if(!chunkWO4V6PNS_cjs.Ac(V))continue;let J=chunkWO4V6PNS_cjs.yc(V);if(J===null){Y=true;continue}B.has(J)?S.add(J):(B.add(J),D.push(J));}let $=F>chunkWO4V6PNS_cjs.Hc?{ok:false,reason:"truncated"}:Y?{ok:false,reason:"malformed"}:S.size>0?{ok:false,reason:"duplicates",duplicateIds:Object.freeze([...S])}:{ok:true,ids:Object.freeze(D)};return d.set(R,$),$},h=R=>{let N=a()[R.sectionIndex];return N?(R.kind==="header"?N.headers:N.footers).get(R.variant)??null:null},f=R=>{if(R.kind==="body"){let E=chunkWO4V6PNS_cjs.Qc(t);return E?an(R,t,{kind:"body"},E,o):null}if(R.kind==="note"){let E=p(R.noteKind);if(!E.ok||!E.ids.includes(R.noteId))return null;let D=chunkWO4V6PNS_cjs.lh(e,R.noteKind);if(!D)return null;let B=chunkWO4V6PNS_cjs.Lc(D.root,R.noteId);return !B||!chunkWO4V6PNS_cjs.Ac(B)?null:an(R,D,{kind:"notesPart",noteKind:R.noteKind},B,o)}if(R.kind==="textbox"){let E=k(R.owner),D=m(R.owner);if(!E||!D.ok)return null;let B=D.shapes.find(S=>S.id===R.shapeId);return B?.textboxRoot?an(R,E.part,E.scope,B.textboxRoot,o):null}let N=h(R);return N?an(R,N.part,{kind:"headerFooter",rId:N.rId},N.part.root,o):null},k=R=>x(R),x=R=>{let N=z(R);if(s.has(N))return s.get(N)??null;let E=f(R);return s.set(N,E),E},O=(R,N)=>{let E=m(R);if(!E.ok)return null;for(let D of E.shapes){if(!D.textboxRoot)continue;let B={kind:"textbox",owner:R,shapeId:D.id};if(x(B)?.has(N))return B}return null};return {package:e,get body(){return x(Se)},story:x,storyOf:R=>{if(x(Se)?.has(R))return Se;let E=[{kind:"body"}];for(let[D]of a().entries())for(let B of ["header","footer"])for(let S of yt){let F={kind:B,sectionIndex:D,variant:S};if(x(F)){if(x(F).has(R))return F;E.push(F);}}for(let D of ["footnote","endnote"]){let B=p(D);if(B.ok)for(let S of B.ids){let F={kind:"note",noteKind:D,noteId:S};if(x(F)?.has(R))return F}}for(let D of E){let B=O(D,R);if(B)return B}return null},sections:()=>i??=xi(e,t,a()),furniture(R){let N=a()[R];if(!N)return Ii;let E=[];for(let D of ["header","footer"]){let B=D==="header"?N.headers:N.footers;for(let S of yt){let F=B.get(S);F&&E.push(Object.freeze({kind:D,variant:S,declared:!F.inherited}));}}return Object.freeze(E)},noteIds:p,shapes:m,styles:o}}var wi=Object.freeze([]);function Ci(e){let t=[];for(let n of e.pages){let o=n.pageFieldSource?.pageNumber??n.index+1,r=chunkDBOOTED4_cjs.gc(o,n.pageFieldSource?.format),a=i=>{for(let s of i)if(s.kind==="paragraph")for(let d of s.lines)t.push({...d.range,pageNumber:o,pageNumberText:r});else for(let d of s.rows)for(let u of d.cells)a(u.blocks);};a(n.fragments),n.header&&a(n.header.fragments),n.footer&&a(n.footer.fragments);for(let i of n.footnotes?.notes??[])a(i.fragments);for(let i of n.endnotes?.notes??[])a(i.fragments);}return {pageCount:e.pages.length,ranges:t}}function Ti(e,t,n,o){if(!e||!Number.isInteger(e.pageCount)||e.pageCount<1)return null;let r=chunkWO4V6PNS_cjs.Ta(t,n);if(!r||r.kind!=="paragraph")return null;let a=chunkWO4V6PNS_cjs.kg(r).find(s=>s.node.id===o);if(!a)return null;let i=e.ranges.find(s=>s.paragraphId===n&&s.start<=a.start&&s.end>a.start);return !i||!Number.isInteger(i.pageNumber)||i.pageNumber<1?null:{pageNumber:i.pageNumber,pageNumberText:i.pageNumberText,pageCount:e.pageCount}}function Jd(e){return async t=>{let n=chunkHC6YNKUI_cjs.e(t,{measurer:e.measurer,producer:e.producer,displayMode:"proposed"});if(!n.ok)throw new Error("field pagination could not open the document");try{return Ci(await n.session.layout())}finally{n.session.dispose();}}}function Ni(e,t,n){let o=(r,a)=>({state:n,step:{ok:false,error:{code:"unsupported-capability",message:r,detail:a}}});return e.op==="getChangeTrackingMode"||e.op==="setChangeTrackingMode"?t?e.op==="getChangeTrackingMode"?{state:n,step:{ok:true,kind:"query",value:{kind:"text",text:n.mode}}}:e.mode!=="Off"&&e.mode!=="TrackMineOnly"?o("TrackAll requires shared tracking enforcement for every peer and is not supported","change-tracking-mode-unsupported"):e.mode==="TrackMineOnly"&&(typeof e.author!="string"||!e.author.trim()||!chunkWO4V6PNS_cjs.T(e.author))?o("TrackMineOnly requires a non-empty XML-safe runtime author","change-tracking-author-required"):{state:{mode:e.mode,...e.mode==="TrackMineOnly"?{author:e.author.trim()}:{}},step:{ok:true,kind:"query",value:{kind:"applied"}}}:o("this host does not support runtime-local change tracking","change-tracking-unsupported-host"):n.mode==="Off"||Go(e)?null:o(`${e.op} does not support TrackMineOnly; no permanent edit was applied`,"change-tracking-operation-unsupported")}function Go(e){return !et(e)||e.op==="setChangeTrackingMode"||e.op==="insertText"?true:e.op==="insertBreak"?e.breakType==="Line"&&!(e.location==="Replace"&&"body"in e.span):e.op==="insertTable"||e.op==="insertTableRows"||e.op==="updateTable"||e.op==="updateTableCell"||e.op==="replaceSpan"&&!("body"in e.span)||e.op==="deleteParagraph"?true:["insertContentControl","setContentControlProperties","startNewList","setListLevelFormat","attachToList","detachFromList","setListLevel","insertParagraph","setFont","setStyle","setParagraphFormat","proposeInsertion","proposeDeletion","proposeReplacement","insertComment","replyToComment","deleteComment","setCommentResolved","acceptRevision","rejectRevision","resolveRevisionBatch","setRevisionAuthorBatch","acceptAllRevisions","rejectAllRevisions","selectSpan","selectBookmark","insertBookmark","deleteBookmark"].includes(e.op)}function Ei(e,t,n){if(!n||!["setFont","setStyle","setParagraphFormat","insertParagraph","attachToList","detachFromList","setListLevel"].includes(e.op)||!t.ok||t.kind!=="command")return t;let o={author:n,date:new Date().toISOString()};return {...t,ops:t.ops.map(r=>{if(r.op==="insertText")return {...r,revision:o};if(r.op==="splitParagraph")return {op:"splitParagraphMany",paragraphId:r.paragraphId,offsets:[r.offset],revision:o};if(r.op==="setRunProperties"||r.op==="setParagraphProperties"||r.op==="setParagraphMarkProperties"||r.op==="setListNumbering"||r.op==="setListLevel")return {...r,revision:o};throw new Error("Formatting plan contains an operation without property revision support")})}}function Qd(){let e=globalThis.crypto,t=e?.getRandomValues;if(typeof t!="function")throw new Error("automation: no secure random source. globalThis.crypto.getRandomValues is required to scope document handles to one host.");let n=t.call(e,new Uint8Array(16)),o="";for(let r of n)o+=r.toString(16).padStart(2,"0");return o}function Zd(e){return typeof e=="object"&&e!==null&&"kind"in e&&"ref"in e}function Di(){let e=new Map,t=new Map,n=new Map,o=new Map,r=Qd(),a=null,i=(d,u)=>{let m=(o.get(d)??0)+1;o.set(d,m);let p=`${d}:${r}:${String(m)}`;return e.set(p,u),Object.freeze({kind:d,ref:p})},s=(d,u,m)=>{let p=`${d}\0${u}`,h=n.get(p);if(h)return Object.freeze({kind:d,ref:h});let f=i(d,m);return n.set(p,f.ref),f};return {document(){return a??=i("document",{kind:"document"}),a},body(d,u){return s("body",`${z(d)}:${u??""}`,{kind:"body",story:d,...u?{rootNodeId:u}:{}})},table(d,u){return s("table",`${z(u)}:${d}`,{kind:"table",nodeId:d,story:u})},tableRow(d,u){return s("tableRow",`${z(u)}:${d}`,{kind:"tableRow",nodeId:d,story:u})},tableCell(d,u){return s("tableCell",`${z(u)}:${d}`,{kind:"tableCell",nodeId:d,story:u})},field(d,u,m){return s("field",`${z(m)}:${u}`,{kind:"field",paragraphId:d,fieldNodeId:u,story:m})},inlinePicture(d,u){return s("inlinePicture",`${z(u)}:${d}`,{kind:"inlinePicture",drawingNodeId:d,story:u})},shape(d,u){return s("shape",`${z(u)}:${String(d)}`,{kind:"shape",shapeId:d,owner:u})},paragraph(d,u){let m=t.get(d);if(m)return Object.freeze({kind:"paragraph",ref:m});let p=i("paragraph",{kind:"paragraph",paragraphId:d,story:u});return t.set(d,p.ref),p},section(d){return s("section",String(d),{kind:"section",index:d})},note(d,u){return s("note",`${d}:${String(u)}`,{kind:"note",noteKind:d,noteId:u})},comment(d,u){return s("comment",`${z(u)}\0${d}`,{kind:"comment",commentId:d,story:u})},revision(d,u){return s("revision",`${z(u)}\0${d}`,{kind:"revision",revisionId:d,story:u})},bookmark(d,u){return s("bookmark",`${z(u)}\0${d}`,{kind:"bookmark",name:d,story:u})},list(d,u){return s("list",`${z(u)}\0${d}`,{kind:"list",numId:d,story:u})},contentControl(d,u){return s("contentControl",`${z(u)}\0${d}`,{kind:"contentControl",nodeId:d,story:u})},retargetRevisions(d,u){let m=h=>`revision\0${z(d)}\0${h}`,p=u.flatMap(({from:h,to:f})=>{let k=h===f?void 0:n.get(m(h));return k?[{ref:k,from:h,to:f}]:[]});for(let{from:h}of p)n.delete(m(h));for(let{ref:h,to:f}of p)n.has(m(f))||(n.set(m(f),h),e.set(h,{kind:"revision",revisionId:f,story:d}));},retarget(d,u){let m=t.get(d);if(!m||d===u)return;let p=e.get(m);!p||p.kind!=="paragraph"||(t.delete(d),e.set(m,{kind:"paragraph",paragraphId:u,story:p.story}),t.has(u)||t.set(u,m));},resolve(d,u){if(!Zd(d)||d.kind!==u||typeof d.ref!="string")return null;let m=e.get(d.ref);return !m||m.kind!==u?null:m}}}var We="target-removed";function Me(e,t){return {ok:false,code:e,detail:t}}function Be(e){return {ok:true,value:e}}function le(e,t,n,o){let r=n.resolve(e,t);if(!r||r.kind!=="body"&&r.kind!=="paragraph")return Me("invalid-handle",`not-a-${t}-handle`);let a=o.story(r.story);if(!a)return Me("invalid-handle",`no-such-story:${z(r.story)}`);if(r.kind==="body"&&r.rootNodeId){let i=chunkWO4V6PNS_cjs.Ta(a.part,r.rootNodeId);return !i||i.kind!=="tableCell"?Me("invalid-handle","cell-not-in-story"):Be(qn(a,i))}return Be(a)}function pe(e,t,n){let o=t.resolve(e,"paragraph");if(!o||o.kind!=="paragraph")return Me("invalid-handle","not-a-paragraph-handle");let r=n.story(o.story);if(!r)return Me("invalid-handle",`no-such-story:${z(o.story)}`);let a=r.indexOf(o.paragraphId);return a<0?Me("invalid-handle","paragraph-not-in-body"):Be({story:o.story,paragraphId:o.paragraphId,index:a,offset:0})}function qd(e,t,n){let o=pe(e.paragraph,t,n);if(!o.ok)return o;let a=(n.story(o.value.story)?.rawText(o.value.paragraphId)??"").length,{offset:i}=e;return !Number.isInteger(i)||i<0||i>a?Me("invalid-offset",`offset ${String(i)} outside 0..${String(a)}`):Be({...o.value,offset:i})}function Ft(e,t,n){if("paragraph"in e){if(!("at"in e))return qd(e,t,n);let s=pe(e.paragraph,t,n);if(!s.ok||e.at==="start")return s;let u=(n.story(s.value.story)?.rawText(s.value.paragraphId)??"").length;return Be({...s.value,offset:u})}let o=le(e.body,"body",t,n);if(!o.ok)return o;let r=o.value.paragraphIds;if(r.length===0)return Me("invalid-offset","empty-story");if(e.at==="start")return Be({story:o.value.story,paragraphId:r[0],index:o.value.indexOf(r[0]),offset:0});let a=r.length-1,i=r[a];return Be({story:o.value.story,paragraphId:i,index:o.value.indexOf(i),offset:(o.value.rawText(i)??"").length})}function eu(e,t){return e.index<t.index||e.index===t.index&&e.offset<=t.offset}function tu(e){let t=e.paragraphIds;if(t.length===0)return null;let n=t.length-1,o=t[n];return {start:{story:e.story,paragraphId:t[0],index:e.indexOf(t[0]),offset:0},end:{story:e.story,paragraphId:o,index:e.indexOf(o),offset:(e.rawText(o)??"").length}}}function G(e,t,n){if("body"in e){let a=le(e.body,"body",t,n);return a.ok?Be(tu(a.value)):a}if("paragraph"in e){let a=pe(e.paragraph,t,n);if(!a.ok)return a;let s=(n.story(a.value.story)?.rawText(a.value.paragraphId)??"").length;return Be({start:a.value,end:{...a.value,offset:s}})}let o=Ft(e.start,t,n);if(!o.ok)return o;let r=Ft(e.end,t,n);return r.ok?z(o.value.story)!==z(r.value.story)?Me("invalid-handle","span-crosses-stories"):eu(o.value,r.value)?Be({start:o.value,end:r.value}):Me("invalid-offset","span-start-after-end"):r}function Z(e,t,n){if("body"in e)return le(e.body,"body",t,n);if("paragraph"in e)return le(e.paragraph,"paragraph",t,n);let o=e.start;return "paragraph"in o?le(o.paragraph,"paragraph",t,n):le(o.body,"body",t,n)}function eo(e,t,n){if("paragraph"in e)return pe(e.paragraph,t,n);let o=le(e.body,"body",t,n);if(!o.ok)return o;let r=o.value.paragraphIds;if(r.length===0)return Me("invalid-offset","empty-story");let a=e.at==="first"?0:r.length-1;return Be({story:o.value.story,paragraphId:r[a],index:a,offset:0})}function Re(e,t){if(!e)return [];let n=t.paragraphIds,o=n[e.start.index]===e.start.paragraphId?e.start.index:n.indexOf(e.start.paragraphId),r=n[e.end.index]===e.end.paragraphId?e.end.index:n.indexOf(e.end.paragraphId);return o<0||r<o?[]:n.slice(o,r+1)}function bt(e,t){if(!e)return [];let n=Re(e,t),o=n.length-1;return n.map((r,a)=>{let i=(t.rawText(r)??"").length,s=a===0?e.start.offset:0,d=a===o?e.end.offset:i;return {paragraphId:r,start:s,end:d,whole:s===0&&d===i}})}function Li(e,t,n,o="allMarkup"){if(!e)return "";let r=Re(e,t);return r.length===1?t.projectedText(e.start.paragraphId,o)?.sliceRaw(e.start.offset,e.end.offset)??"":r.map((a,i)=>{let s=t.projectedText(a,o);if(!s)return "";let d=(t.rawText(a)??"").length;return i===0?s.sliceRaw(e.start.offset,d):i===r.length-1?s.sliceRaw(0,e.end.offset):s.text}).join(n)}function we(e,t){return {start:{paragraph:t.paragraph(e.start.paragraphId,e.start.story),offset:e.start.offset},end:{paragraph:t.paragraph(e.end.paragraphId,e.end.story),offset:e.end.offset}}}var nu=new Set(["TextBox","GeometricShape","Picture","Group","Canvas","Unsupported"]),$e=(e,t,n)=>({ok:false,error:{code:e,message:t,...n===void 0?{}:{detail:n}}}),Xo=e=>({ok:true,kind:"query",value:e});function ou(e,t,n){let o=t.resolve(e,"shape");if(!o||o.kind!=="shape")return $e("invalid-handle","that handle does not name a shape","shape");let r=n.shapes(o.owner);if(!r.ok)return $e("ambiguous-document","shape identities in that story are not completely and unambiguously enumerable",r.reason);let a=r.shapes.find(i=>i.id===o.shapeId);return a?{owner:o.owner,shape:a}:$e("invalid-handle","that shape is not in this document",z(o.owner))}function Mi(e,t,n){if(e.op==="getShapes"){let a=e.types;if(a!==void 0&&(!Array.isArray(a)||a.some(m=>!nu.has(m))))return $e("unsupported-content","unknown shape type","types");if(!("body"in e.span)&&!("paragraph"in e.span))return $e("unsupported-content","shapes are listed for a body or a paragraph only");let i=G(e.span,t,n),s=Z(e.span,t,n);if(!i.ok||!s.ok)return $e("invalid-handle","that range no longer exists",i.ok?s.ok?void 0:s.detail:i.detail);let d=n.shapes(s.value.story);if(!d.ok)return $e("ambiguous-document","shape identities in that story are not completely and unambiguously enumerable",d.reason);let u=new Set(i.value?Re(i.value,s.value):[]);return Xo({kind:"handles",handles:d.shapes.filter(m=>u.has(m.hostParagraphId)&&(!a||a.includes(m.type))).map(m=>t.shape(m.id,s.value.story))})}let o=ou(e.shape,t,n);if("ok"in o)return o;if(e.op==="getShape"){let{id:a,name:i,type:s}=o.shape;return Xo({kind:"shape",shape:{id:a,name:i,type:s}})}if(!o.shape.textboxRoot)return $e("unsupported-content","that shape holds no text story of its own",o.shape.type);if(!Vo(o.owner))return $e("unsupported-content","text boxes are reachable in the body, headers and footers only",z(o.owner));let r={kind:"textbox",owner:o.owner,shapeId:o.shape.id};return n.story(r)?Xo({kind:"handle",handle:t.body(r)}):$e("invalid-handle","that text box is not in this document",z(r))}var ru=256,Bi=1e4;function Yo(e,t){if(e.kind!=="textValue"){for(let n of e.attributes)if(n.namespaceUri===chunkWO4V6PNS_cjs.la&&n.localName===t)return n.value}}function au(e){return e.startsWith("_")}function xt(e,t={}){let n=new Map,o=[],r=new Set;for(let a of e.paragraphIds){let i=e.node(a);if(i?.kind!=="paragraph")continue;let s=chunkWO4V6PNS_cjs.mg(i),d=u=>{if(u.kind!=="textValue"){if(u.kind==="bookmarkStart"){if(o.length>=Bi||n.size>=Bi)return;let m=Yo(u,"id"),p=Yo(u,"name");if(m===void 0||p===void 0||p.length===0||p.length>ru||au(p)&&!t.includeHidden||r.has(p)||n.has(m))return;let h=s.spanOf(u)?.start??0;n.set(m,{name:p,start:{paragraphId:a,offset:h}});return}if(u.kind==="bookmarkEnd"){let m=Yo(u,"id");if(m===void 0)return;let p=n.get(m);if(!p)return;n.delete(m),r.add(p.name);let h=s.spanOf(u)?.start??0;o.push(Object.freeze({name:p.name,start:p.start,end:{paragraphId:a,offset:h}}));return}for(let m of u.children)d(m);}};for(let u of i.children)d(u);}return Object.freeze(o)}function to(e,t){return xt(e).find(n=>n.name===t)??null}function Hi(e,t){let n=e.node(t);if(n?.kind!=="paragraph")return Object.freeze([]);let o=chunkWO4V6PNS_cjs.mg(n),r=[],a=(i,s)=>{if(!(i.kind==="textValue"||s>32)){if(chunkWO4V6PNS_cjs.Ad(i)){let d=o.spanOf(i);d&&r.push(Object.freeze({id:i.id,paragraphId:t,start:d.start,end:d.end}));return}for(let d of i.children)a(d,s+1);}};for(let i of n.children)a(i,0);return Object.freeze(r)}function Fi(e,t,n){let o=chunkWO4V6PNS_cjs.Dd(n,r=>chunkWO4V6PNS_cjs.Qg(e,t,r));if(o.kind==="external")return o.href;if(o.kind==="internal"){let r=chunkWO4V6PNS_cjs.Bd(n);return r===void 0||r.length===0?null:`#${r}`}return null}var no=Object.freeze({kind:"applied"}),me=(e,t,n)=>({ok:false,error:n===void 0?{code:e,message:t}:{code:e,message:t,detail:n}}),vt=e=>({ok:true,kind:"query",value:e});function Vi(e){let t=[],n=new Set,o=r=>{let a=e.story(r);!a||n.has(z(r))||(n.add(z(r)),t.push(a));};o(Se),e.sections().forEach((r,a)=>{for(let i of ["header","footer"])for(let s of yt)e.furniture(a).some(u=>u.kind===i&&u.variant===s&&u.declared)&&o({kind:i,sectionIndex:a,variant:s});});for(let r of ["footnote","endnote"]){let a=e.noteIds(r);if(a.ok)for(let i of a.ids)o({kind:"note",noteKind:r,noteId:i});}return t}function ji(e,t){let n=chunkWO4V6PNS_cjs.Ig(t);for(let o of Vi(e)){let r=xt(o,{includeHidden:true}).find(a=>chunkWO4V6PNS_cjs.Ig(a.name)===n);if(r)return {story:o,bookmark:r}}return null}var sn=(e,t)=>e[0]<t[0]||e[0]===t[0]&&e[1]<t[1],jt=(e,t)=>e[0]===t[0]&&e[1]===t[1],_i=(e,t)=>sn(e,t)||jt(e,t);function iu(e,t,n){let o=jt(e.start,e.end),r=jt(t.start,t.end),a;return o?a=r?jt(t.start,e.start):_i(t.start,e.start)&&sn(e.start,t.end):r?a=_i(e.start,t.start)&&sn(t.start,e.end):a=sn(t.start,e.end)&&sn(e.start,t.end),a||!n?a:jt(t.end,e.start)||jt(t.start,e.end)}function Ui(e,t,n){return (o,r)=>{let a=e(o);return t(a)??[...new Set(r)].reduce((i,s)=>i??n(a,s),null)}}function Wi(e,t,n,o){if(o||!e.ok||e.kind!=="command"||e.relate)return e;let r=chunkWO4V6PNS_cjs.fj(t.part,n.start,n.end,t.paragraphIds);return r.length===0?e:{...e,ops:[...r,...e.ops]}}function $i(e,t,n){let o=t.resolve(e,"bookmark");if(!o||o.kind!=="bookmark")return me("invalid-handle","that handle does not name a bookmark","bookmark");let r=n.story(o.story);if(!r)return me("invalid-handle","that story is not in this document");let a=to(r,o.name);if(!a)return me("invalid-handle","this document no longer declares that bookmark",We);let i=s=>({story:r.story,paragraphId:s.paragraphId,index:r.indexOf(s.paragraphId),offset:s.offset});return {reads:r,range:{start:i(a.start),end:i(a.end)}}}function Ki(e,t,n,{admit:o,pinned:r}){if(e.op==="getBookmarkName"){let u=t.resolve(e.bookmark,"bookmark");return !u||u.kind!=="bookmark"?me("invalid-handle","that handle does not name a bookmark","bookmark"):vt({kind:"text",text:u.name})}if(e.op==="getBookmarks"){let u=G(e.scope,t,n);if(!u.ok)return me(u.code,"that span is not a place",u.detail);let m=Z(e.scope,t,n);if(!m.ok)return me(m.code,"that span is not a place",m.detail);let p=u.value,h=p===null?null:new Set(Re(p,m.value)),f=xt(m.value).filter(k=>{if(!h||p===null||!h.has(k.start.paragraphId)&&!h.has(k.end.paragraphId))return false;let x=k.start.paragraphId===p.end.paragraphId&&k.start.offset>p.end.offset,O=k.end.paragraphId===p.start.paragraphId&&k.end.offset<p.start.offset;return !x&&!O});return vt({kind:"handles",handles:f.map(k=>t.bookmark(k.name,m.value.story))})}if(e.op==="getBookmarkNames"){let u=G(e.scope,t,n);if(!u.ok)return me(u.code,"that range is not a place",u.detail);let m=Z(e.scope,t,n);if(!m.ok)return me(m.code,"that range is not a place",m.detail);let p=u.value;if(!p)return vt({kind:"texts",texts:[]});let h=(x,O)=>[m.value.indexOf(x),O],f={start:h(p.start.paragraphId,p.start.offset),end:h(p.end.paragraphId,p.end.offset)},k=xt(m.value,{includeHidden:e.includeHidden}).filter(x=>iu(f,{start:h(x.start.paragraphId,x.start.offset),end:h(x.end.paragraphId,x.end.offset)},e.includeAdjacent)).map(x=>x.name);return vt({kind:"texts",texts:Object.freeze(k)})}if(e.op==="getBookmarkRangeByName"){if(!t.resolve(e.document,"document"))return me("invalid-handle","that handle does not name a document","document");if(typeof e.name!="string")return me("unsupported-content","a bookmark name is a string");let u=ji(n,e.name);if(!u)return vt({kind:"spans",spans:[]});let m=p=>({story:u.story.story,paragraphId:p.paragraphId,index:u.story.indexOf(p.paragraphId),offset:p.offset});return vt({kind:"spans",spans:[we({start:m(u.bookmark.start),end:m(u.bookmark.end)},t)]})}if(e.op==="insertBookmark"){if(typeof e.name!="string"||chunkWO4V6PNS_cjs.Gg(e.name)!==null)return me("unsupported-content","a bookmark name starts with a letter or an underscore, holds only letters, digits and underscores, and has at most 40 characters","invalid-bookmark-name");let u=G(e.span,t,n);if(!u.ok)return me(u.code,"that range is not a place",u.detail);let m=Z(e.span,t,n);if(!m.ok)return me(m.code,"that range is not a place",m.detail);let p=u.value;if(!p)return me("invalid-offset","this story holds no paragraph to bookmark");let h=chunkWO4V6PNS_cjs.Ig(e.name),f=new Set(Vi(n).filter(O=>O.part.name!==m.value.part.name&&xt(O,{includeHidden:true}).some(I=>chunkWO4V6PNS_cjs.Ig(I.name)===h)).map(O=>O.part.name)),k=o(m.value,[p.start.paragraphId,p.end.paragraphId]);return k||{ok:true,kind:"command",ops:[{op:"insertBookmark",name:e.name,start:{paragraphId:p.start.paragraphId,offset:p.start.offset},end:{paragraphId:p.end.paragraphId,offset:p.end.offset}}],story:m.value.story,...f.size>0?{packageEdits:[O=>{let I=O;for(let R of f)I=chunkWO4V6PNS_cjs.ej(I,R,e.name);return I}]}:{},answer:()=>no}}let a=e.target,i;if("bookmark"in a){let u=t.resolve(a.bookmark,"bookmark");if(!u||u.kind!=="bookmark")return me("invalid-handle","that handle does not name a bookmark","bookmark");let m=n.story(u.story),p=m?xt(m,{includeHidden:true}).find(h=>h.name===u.name):void 0;if(!m||!p)return me("invalid-handle","this document no longer declares that bookmark",u.name);i={story:m,bookmark:p};}else {if(!t.resolve(a.document,"document"))return me("invalid-handle","that handle does not name a document","document");if(typeof a.name!="string")return me("unsupported-content","a bookmark name is a string");i=ji(n,a.name);}if(!i)return vt(no);let s=r();if(s===null||z(s)!==z(i.story.story)){let u=i.story.part.name,m=i.bookmark.name;return {ok:true,kind:"command",ops:[],story:s??i.story.story,packageEdits:[p=>chunkWO4V6PNS_cjs.ej(p,u,m)],answer:()=>no}}let d=o(i.story,[i.bookmark.start.paragraphId,i.bookmark.end.paragraphId]);return d||{ok:true,kind:"command",ops:[{op:"deleteBookmark",name:i.bookmark.name}],story:i.story.story,answer:()=>no}}var Jo="http://schemas.openxmlformats.org/package/2006/relationships",zi="http://schemas.openxmlformats.org/officeDocument/2006/relationships",su=[{type:"application/vnd.openxmlformats-package.core-properties+xml",namespace:"http://schemas.openxmlformats.org/package/2006/metadata/core-properties",root:"coreProperties",relationship:`${Jo}/metadata/core-properties`},{type:"application/vnd.openxmlformats-officedocument.extended-properties+xml",namespace:"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",root:"Properties",relationship:`${zi}/extended-properties`},{type:"application/vnd.openxmlformats-officedocument.custom-properties+xml",namespace:"http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",root:"Properties",relationship:`${zi}/custom-properties`}];function Qo(e){let t=new Map;for(let o of su){let r=[...new Set([...e.parts.keys(),...e.partBytes.keys()])].filter(d=>chunkWO4V6PNS_cjs.Le(e,d)===o.type);if(r.length>1)return null;let a=(e.relationships.get("/")??[]).filter(d=>d.type===o.relationship);if(a.length>1)return null;let i=a[0];if(i){if(i.targetMode!=="Internal")return null;let d=chunkWO4V6PNS_cjs.B("/",i.rawTarget);if(!d.ok||r.length!==1||chunkWO4V6PNS_cjs.z(d.partName)!==chunkWO4V6PNS_cjs.z(r[0]))return null}if(r.length===0)continue;let s=e.parts.get(r[0]);if(!s||s.root.namespaceUri!==o.namespace||s.root.localName!==o.root||(e.relationships.get(s.name)?.length??0)>0||e.parts.has(chunkWO4V6PNS_cjs.Me(s.name))||e.partBytes.has(chunkWO4V6PNS_cjs.Me(s.name)))return null;t.set(chunkWO4V6PNS_cjs.z(s.name),{part:s,relationship:o.relationship});}if(t.size===0)return e;if(!chunkWO4V6PNS_cjs.Xd(e,new Set(t.keys())))return null;for(let[o,r]of e.relationships)for(let a of r){if(a.targetMode==="External")continue;let i=chunkWO4V6PNS_cjs.B(o,a.rawTarget),s=i.ok&&t.get(chunkWO4V6PNS_cjs.z(i.partName));if(!s)continue;if(o!=="/"||a.type!==s.relationship)return null;let d=e.parts.get(chunkWO4V6PNS_cjs.Me(o));if(!d||d.root.namespaceUri!==Jo||d.root.localName!=="Relationships")return null;let u=d.root.children.filter(p=>p.kind!=="textValue"&&p.attributes.some(h=>h.namespaceUri===""&&h.localName==="Id"&&h.value===a.id));if(u.length!==1)return null;let m=u[0];if(m.kind==="textValue"||m.namespaceUri!==Jo||m.localName!=="Relationship"||m.attributes.some(p=>p.namespaceUri!==""||!["Id","Type","Target","TargetMode"].includes(p.localName))||m.children.some(p=>p.kind!=="textValue"||!chunkWO4V6PNS_cjs.Wd(p.value)))return null}let n=e;for(let{part:o}of t.values()){let r=chunkWO4V6PNS_cjs.Pe(n,o.name);if(!r.ok||r.pkg.contentTypes.overrides.has(chunkWO4V6PNS_cjs.z(o.name)))return null;n=r.pkg;}return n}var _t="http://schemas.openxmlformats.org/package/2006/metadata/core-properties",oo="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",ln="http://purl.org/dc/elements/1.1/",Zo="application/vnd.openxmlformats-package.core-properties+xml",qo={author:[ln,"creator"],title:[ln,"title"],subject:[ln,"subject"],comments:[ln,"description"],keywords:[_t,"keywords"],category:[_t,"category"]},Gi={...qo,lastAuthor:[_t,"lastModifiedBy"]},Xi=Object.keys(Gi);function ro(e){let t=(e.relationships.get("/")??[]).find(o=>o.type===oo);if(!t||t.targetMode!=="Internal")return null;let n=chunkWO4V6PNS_cjs.B("/",t.rawTarget);return n.ok?e.parts.get(n.partName)??null:null}function Yi(e,t){let n=ro(e),[o,r]=Gi[t],a=n?.root.children.find(i=>i.kind!=="textValue"&&i.namespaceUri===o&&i.localName===r);return a&&a.kind!=="textValue"?a.children.map(i=>i.kind==="textValue"?i.value:"").join(""):""}function er(e){if(!e||typeof e!="object"||Array.isArray(e))return false;let t=Object.entries(e);return t.length>0&&t.every(([n,o])=>Object.hasOwn(qo,n)&&typeof o=="string"&&o.length<=4096&&chunkWO4V6PNS_cjs.T(o))}function tr(e,t){if(!er(t)||(e.relationships.get("/")??[]).filter(s=>s.type===oo).length>1)return null;let n=ro(e);if(n&&(n.contentType!==Zo||n.root.namespaceUri!==_t||n.root.localName!=="coreProperties")||!n&&(e.relationships.get("/")??[]).some(s=>s.type===oo))return null;let o=n?.name??"/docProps/core.xml";if(!n&&(e.parts.has(o)||e.partBytes.has(o)))return null;let r=chunkWO4V6PNS_cjs.Ia(`<cp:coreProperties xmlns:cp="${_t}" xmlns:dc="${ln}">${Object.entries(t).map(([s,d])=>{let[u,m]=qo[s],p=u===_t?"cp":"dc";return `<${p}:${m}>${chunkWO4V6PNS_cjs.R(d)}</${p}:${m}>`}).join("")}</cp:coreProperties>`,{name:o,contentType:Zo});if(!r.ok)return null;if(n){let s=n,d=chunkWO4V6PNS_cjs.Ra(n),u=m=>m.kind==="textValue"?{...m,id:d()}:{...m,id:d(),children:m.children.map(u)};for(let m of r.part.root.children){if(m.kind==="textValue")continue;let p=s.root.children.filter(k=>k.kind!=="textValue"&&k.namespaceUri===m.namespaceUri&&k.localName===m.localName);if(p.length>1)return null;let h=p[0],f;if(h&&h.kind!=="textValue"){if(h.children.some(I=>I.kind!=="textValue"))return null;let k=h.children.length===1&&h.children[0]?.kind==="textValue"?h.children[0]:null,x=m.children.find(I=>I.kind==="textValue"),O=k&&x?.kind==="textValue"?[{...k,value:x.value}]:m.children.map(u);f=chunkWO4V6PNS_cjs.Za(s,h.id,{...h,children:O});}else {let k=Array.from(s.root.children);k.push(u(m)),f=chunkWO4V6PNS_cjs.Xa(s,s.root.id,k);}if(!f.ok)return null;s=f.part;}return chunkWO4V6PNS_cjs.Ie(e,s)}let a=chunkWO4V6PNS_cjs.Se(e,o,r.part.root,Zo);if(!a.parts.has(o))return null;let i=chunkWO4V6PNS_cjs.Re(a,"/",oo,o.slice(1));return i.ok?i.pkg:null}function Ji(e,t,n,o=true){let r=s=>({ok:false,error:{code:"unsupported-content",message:s}});if(!t.package)return r("document unavailable");if(e.op==="getDocumentProperty")return Xi.includes(e.name)?{ok:true,kind:"query",value:{kind:"text",text:Yi(t.package,e.name)}}:r("unsupported document property");if(e.op==="removeDocumentInformation"){if(e.removeDocInfoType!=="DocumentProperties"||!o)return {ok:false,error:{code:"unsupported-capability",message:"Only direct DocumentProperties removal outside collaboration is supported."}};if(!Qo(t.package))return {ok:false,error:{code:"unsupported-capability",message:"Document property parts have unsupported structure or dependencies."}};let s=n();return s||{ok:true,kind:"command",story:Se,ops:[],packageEdits:[d=>{let u=Qo(d);if(!u)throw new chunkWO4V6PNS_cjs.cj("document property parts changed");return u}],answer:()=>({kind:"applied"})}}if(!er(e.values))return r("invalid document property values");if(!o&&!ro(t.package))return {ok:false,error:{code:"unsupported-capability",message:"Create document properties before joining collaboration; concurrent core-part creation cannot merge safely."}};let a={...e.values};if(!tr(t.package,a))return {ok:false,error:{code:"unsupported-capability",message:"the core properties part cannot be updated safely"}};let i=n();return i||{ok:true,kind:"command",story:Se,ops:[],packageEdits:[s=>{let d=tr(s,a);if(!d)throw new chunkWO4V6PNS_cjs.cj("document properties package changed");return d}],answer:()=>({kind:"applied"})}}function Qi(e,t){let n=[],o=new Set,r=a=>{if(a.kind!=="textValue"){if(a.namespaceUri===chunkWO4V6PNS_cjs.la&&a.localName===`${t}Reference`){let i=chunkWO4V6PNS_cjs.yc(a)??Number.NaN;o.has(i)||(n.push(i),o.add(i));}for(let i of a.children)r(i);}};return r(e),n}var Zi={},qi=new WeakMap;function es(e,t=null,n="all-markup",o){let r=e??Zi,a=qi.get(r);a||qi.set(r,a=new WeakMap);let i=t??Zi,s=a.get(i);s||a.set(i,s=lu(e,t));let d=s;return (u,m,p,h,f=n,k=o)=>d(u,m,p,h,f,k)}function lu(e,t){let n=chunkDBOOTED4_cjs.kd(e,void 0,t),o=Yn(n),r=new WeakMap;return (a,i,s,d,u="all-markup",m)=>{let p=o(d,a,u,m),h=r.get(a);if(!h||h.cellStyle!==p){let I=chunkDBOOTED4_cjs.ld(n,chunkWO4V6PNS_cjs.Lh(a,"paragraphProperties","pPr"),p);h={cellStyle:p,inherited:I},r.set(a,h);}let{inherited:f}=h,k=s?f.markRunProperties:chunkDBOOTED4_cjs.od(f.runProperties,chunkDBOOTED4_cjs.mb(i),n),x=false,O=false;for(let I of k){if(I.localName!=="rtl"&&I.localName!=="cs")continue;let R=I.attributes?.val,N=R===void 0||["1","true","on"].includes(R);I.localName==="rtl"?x=N:O=N;}return x||O}}function ts(e,t=()=>null,n=()=>"all-markup",o=()=>{}){return {runPropertyEdits(...r){return chunkWO4V6PNS_cjs._h(r[0],r[1],r[2],r[3],r[4],r[5],r[6],es(e(),t(),n(),o()))},mergedParagraphMarkProperties(...r){return chunkWO4V6PNS_cjs.Vh(r[0],r[1],r[2],es(e(),t(),n(),o()))}}}var nt=chunkWO4V6PNS_cjs.th,ut=/[\r\n\f\u2028\u2029]/;function Vt(e,t,n){return n.length?[{op:"insertText",paragraphId:e,offset:t,text:n}]:[]}function nr(e){return e.replaceAll(nt,`
|
|
5
|
+
`)}var du={ok:false,error:{code:"unsupported-content",message:"a single-line control cannot hold a line break",detail:"line-break-in-single-line-control"}};function uu(e,t){return t.includes(nt)&&!chunkWO4V6PNS_cjs.uh(chunkWO4V6PNS_cjs.Zb(e))?du:null}function ct(e,t,n,o,r=nt){if(!r.includes(nt))return null;let a=chunkWO4V6PNS_cjs.Ta(e,t);if(!chunkWO4V6PNS_cjs.jg(a))return null;let i=chunkWO4V6PNS_cjs.Pk(e,a,n,o);return i?uu(i,r):null}function ao(e){return e.replaceAll(`
|
|
6
|
+
`,nt)}function ns(e,t){let n=e.rawText(t)??"",o=e.node(t);return o?.kind==="paragraph"?chunkWO4V6PNS_cjs.kj(o,n):n}function cu(e){return e?.kind!=="paragraph"?false:e.children.every(t=>t.namespaceUri!==chunkWO4V6PNS_cjs.la?false:t.localName==="pPr"?true:t.kind==="run"&&t.children.every(n=>n.namespaceUri===chunkWO4V6PNS_cjs.la&&(n.localName==="rPr"||n.localName==="t"&&n.children.every(o=>o.kind==="textValue"))))}function or(e,t,n){return cu(chunkWO4V6PNS_cjs.Ta(e,t))&&chunkWO4V6PNS_cjs.Nk(e,t,n)===null}function os(e,t,n,o){let r=chunkWO4V6PNS_cjs.Nk(e,t,n);if(!r)return null;let a=n===r.offset?chunkWO4V6PNS_cjs.yl(e,{op:"insertText",paragraphId:t,offset:n,text:o}):null;return a?.ok&&chunkWO4V6PNS_cjs.hj(a.part,t)?.slice(n,n+o.length)===nr(o)?null:{ok:false,error:{code:"unsupported-capability",message:"insert at the placeholder start or replace the complete prompt",detail:"placeholder-insertion-offset"}}}function pu(e,t,n){return e.start===e.end?t<e.start&&e.start<n:t===n?e.start<t&&t<e.end:Math.max(e.start,t)<Math.min(e.end,n)}var io=class{#e=new Map;has(t){return this.#e.has(t)}append(t,n,o,r,a=false){let i=this.#e.get(t)??[];if(i.some(p=>pu(p,n,o)))return null;let s=n,d=o;for(let p of i){let h=p.length-(p.end-p.start);p.end<=n&&!(a&&p.start===n&&p.end===n)&&(s+=h),(p.end<o||p.end===o&&p.start!==p.end)&&(d+=h);}n===o&&(d=s);let u=r-(o-n);for(let p of i)o<=p.start&&!(n===o&&p.start===p.end&&n===p.start&&!a)&&(p.result.start+=u,p.result.end+=u);let m={start:s,end:s+r};return i.push({start:n,end:o,length:r,result:m}),this.#e.set(t,i),{start:s,end:d,result:m}}};function rs(e,t,n,o,r=false){let a=t.start.paragraphId,i=e.append(a,t.start.offset,t.end.offset,n.length,r);return i?{ok:true,kind:"command",ops:as(a,i.start,i.end,n),story:t.start.story,answer:()=>({kind:"span",span:we({start:{...t.start,offset:i.result.start},end:{...t.start,offset:i.result.end}},o)})}:{ok:false,error:{code:"conflicting-operations",message:"text edits overlap in the batch snapshot",detail:a}}}function as(e,t,n,o){let r=[];return o.length&&r.push({op:"insertText",paragraphId:e,offset:t,text:o,...n>t?{bias:"right"}:{}}),n>t&&r.push({op:"deleteText",paragraphId:e,start:t+o.length,end:n+o.length}),r}function is(e,t,n,o){let r=t.start.paragraphId,a=chunkWO4V6PNS_cjs.hj(e,r),i=chunkWO4V6PNS_cjs.Nk(e,r,t.start.offset),s=i&&n.length?[{op:"insertText",paragraphId:r,offset:t.start.offset,text:n,bias:"right"}]:as(r,t.start.offset,t.end.offset,n),d=e;for(let m of s){let p=chunkWO4V6PNS_cjs.yl(d,m);if(!p.ok)return {ok:false,error:{code:"unsupported-content",message:"that replacement cannot preserve the targeted text safely",detail:p.reason}};d=p.part;}let u=chunkWO4V6PNS_cjs.hj(d,r);return a===null||u!==a.slice(0,t.start.offset)+nr(n)+a.slice(t.end.offset)?{ok:false,error:{code:i?"unsupported-capability":"unsupported-content",message:i?"replace the complete placeholder prompt to avoid consuming unrelated text":"that replacement changes the expected text positions",detail:r}}:{ok:true,kind:"command",ops:s,story:t.start.story,answer:()=>({kind:"span",span:we({start:t.start,end:{...t.start,offset:t.start.offset+n.length}},o)})}}function ls(e,t,n){let o=ns(e,t);return {text:o,occurrences:mu(o,n)}}var ss=/\s/;function mu(e,t){let n=[],o=0;for(;o<e.length;){let r=null;for(let a of t){let i=ao(a),s=e.indexOf(i,o);s<0||(!r||s<r.start||s===r.start&&i.length>r.length)&&(r={start:s,length:i.length});}if(!r)break;n.push(r),o=r.start+r.length;}return n}function ds(e,t,n){let o=t[n]?.markParagraphId??null;if(o!==null)return o;let r=e.paragraphIds,a=r[r.length-1];return a===void 0||new Set(t.map(s=>s.markParagraphId).filter(s=>s!==null)).has(a)?null:a}function us(e,t){for(let n of [e.start,e.end]){let o=t.rawText(n.paragraphId);if(o===null||n.offset>o.length)return false}return true}function cs(e,t,n){let o=t,r=n;for(;o<r&&ss.test(e[o]);)o+=1;for(;r>o&&ss.test(e[r-1]);)r-=1;return [o,r]}function Ut(e){let t=e.kind==="contentControl"?chunkWO4V6PNS_cjs.Xb(e):e;return t?chunkWO4V6PNS_cjs.$b(t).map(n=>n.node):[]}var ps=new Set(["unlocked","sdtLocked","contentLocked","sdtContentLocked"]),ms=new Set(["whole","content","start","end","before","after"]),fs=new Set(["richText","plainText","dropDownList","comboBox","date"]),fu=4096;function gs(e,t,n){let{type:o}=e;return ["richText","plainText","comboBox","untyped"].includes(o)?typeof t!="string"?{code:"unsupported-content",message:"text is required",detail:"text"}:t.includes(chunkWO4V6PNS_cjs.th)&&!chunkWO4V6PNS_cjs.uh(e)?{code:"unsupported-content",message:"a single-line control cannot hold a line break",detail:"line-break-in-single-line-control"}:n!=="replace"&&n!=="start"&&n!=="end"?{code:"unsupported-content",message:"that is not a place to insert at",detail:String(n)}:null:{code:"unsupported-capability",message:"this control requires a typed value rather than a text insertion",detail:o}}function hs(e){let t=(r,a)=>({ok:false,code:"unsupported-content",message:r,detail:a});if(typeof e!="object"||e===null||!("kind"in e))return t("a control value states its kind","value");let n=e,o=n.kind;if(o==="text"||o==="listItem"){let r=o==="text"?n.text:n.value;return typeof r!="string"?t("that value is not a string",String(o)):r.length>fu?t("that value is too long",String(r.length)):{ok:true,value:o==="text"?{kind:"text",text:r}:{kind:"listItem",value:r}}}if(o==="checkbox"){let r=n.checked;return typeof r!="boolean"?t("a checkbox is checked or not","checked"):{ok:true,value:{kind:"checkbox",checked:r}}}if(o==="date"){let r=n.iso;return typeof r!="string"?t("a date is an ISO-8601 string","iso"):r.length>64?t("that is not a date",String(r.length)):{ok:true,value:{kind:"date",iso:r}}}return t("that is not a value any control accepts",String(o))}function ys(e,t,n){let o=e.indexOf(n),r=[];return t.ranges.forEach((a,i)=>{let s=e.indexOf(a.start.paragraphId),d=e.indexOf(a.end.paragraphId);if(s<0||d<0||o<s||o>d)return;let u=t.revisionKind==="delete"||t.revisionKind==="moveFrom"||t.revisionKind==="replace"&&i<(t.replacedRangeCount??1/0);r.push({start:o===s?a.start.offset:0,end:o===d?a.end.offset:1/0,struck:u});}),r}function gu(e,t,n,o,r){let a=t.flatMap(s=>ys(e,s,n).filter(d=>d.struck)).sort((s,d)=>s.start-d.start),i=o;for(let s of a){if(s.start>i)break;if(i=Math.max(i,s.end),i>=r)return false}return i<r}function ks(e,t,n,o,r,a,i={}){let s=ys(e,n,o),d=i.insertsAt,u=p=>s.some(h=>h.start<p&&p<=h.end);return i.collaborative&&(s.some(p=>r<p.end&&a>p.start)||a>r&&u(r)||d!==void 0&&u(d))?"collaborative-insertion":n.revisionKind==="insert"||!s.some(p=>p.struck&&r<=p.end&&a>=p.start)||r===a||i.strikesMark||gu(e,t,o,r,a)?null:"deleted-text-only"}function rr(e,t,n,o,r){let a=chunkWO4V6PNS_cjs.Ta(e.part,t);if(!a||a.kind!=="paragraph")return o;let{past:i,landing:s}=chunkWO4V6PNS_cjs.Ch(a,n??{start:o,end:o},o,r.author,r.date);return n&&n.end>n.start?s:i}function bs(e,t,n,o){let r=chunkWO4V6PNS_cjs.Ta(e.part,t);if(!r||r.kind!=="paragraph")return false;let a=chunkWO4V6PNS_cjs.mg(r),i=false,s=r.children;for(let d=0;d<64;d++){let u=s.find(p=>{if(p.kind==="textValue"||p.kind==="run")return false;let h=a.spanOf(p);return h!==null&&h.start<n&&n<h.end});if(!u||u.kind==="textValue"||!(chunkWO4V6PNS_cjs.ya(u)&&u.kind!=="revisionDelete"&&u.kind!=="revisionMoveFrom"||u.kind==="contentControl"||u.kind==="contentControlContent"))return false;if(i&&u.kind!=="contentControlContent")return true;u.kind==="revisionInsert"&&(chunkWO4V6PNS_cjs.zh([u])??o)!==o&&(i=true),s=u.children;}return false}function dn(e,t,n){return {code:e,message:t,detail:n}}function xs(e,t=false){if(typeof e.author!="string"||!e.author.trim()||!chunkWO4V6PNS_cjs.T(e.author))return dn("unsupported-content","proposals need a non-empty XML-safe author","author");let n=e.op==="proposeInsertion";return !(e.op==="proposeDeletion")&&(typeof e.text!="string"||!t&&!e.text.length||ut.test(e.text)||!chunkWO4V6PNS_cjs.vh(e.text))?dn("unsupported-content","proposals need non-empty inline XML-safe text","text"):n&&e.where!=="Before"&&e.where!=="After"?dn("unsupported-content","insertion needs Before or After","where"):null}function Wt(e,t,n,o,r,a=false,i,s){let d=chunkWO4V6PNS_cjs.yk(e.part),u=new Set;if(d.some(f=>f.revisionKind==="structural"))for(let f=chunkWO4V6PNS_cjs.Ua(e.part,t);f!==null&&(u.add(f.id),f.id!==e.root.id);f=chunkWO4V6PNS_cjs.Ua(e.part,f.id));let m=null,p=d.find(f=>{if(r&&f.author===r&&(["insert","paragraphMark","format"].includes(f.revisionKind)||a&&["delete","replace"].includes(f.revisionKind)))return false;if(s!==void 0&&f.author!==s.author&&["insert","delete","replace"].includes(f.revisionKind))return m=ks(e,d,f,t,n,o,s),m!==null;if(f.revisionKind==="structural"){let x=chunkWO4V6PNS_cjs.Lj(f),O=0;for(let I of x){let R=chunkWO4V6PNS_cjs.Ua(e.part,I),N=R&&chunkWO4V6PNS_cjs.Ua(e.part,R.id),E=N?.kind==="tableRow"?"trPr":N?.kind==="tableCell"?"tcPr":null;if(!(!N||!E||chunkWO4V6PNS_cjs.hg(N,E)?.id!==R?.id)){if(u.has(N.id))return true;O+=1;}}if(x.length>0&&O===x.length)return false}let k=i!==void 0&&f.author===i;return f.ranges.some(x=>{let O=e.indexOf(x.start.paragraphId),I=e.indexOf(x.end.paragraphId),R=e.indexOf(t);if(O<0||I<0||R<O||R>I)return false;let N=R===O?x.start.offset:0,E=R===I?x.end.offset:1/0;return n<E&&o>N?true:n>E||o<N?false:!k||n!==E?true:!(f.revisionKind==="insert"||f.revisionKind==="replace"||f.revisionKind==="paragraphMark"&&f.markDirection==="insert")})});if(!p)return null;if(!s)return dn("unsupported-revision","proposal touches or overlaps a pending revision","span");let h=m??(p.author===s.author?"own-pending":"foreign-revision");return dn("unsupported-revision",hu[h],yu[h])}var hu={"deleted-text-only":"a tracked deletion or replacement needs live text, not only deleted text","collaborative-insertion":"in a collaboration session, the API refuses strikes over another author's pending insertion or deletion, and edits that start inside or right after one","foreign-revision":"the edit touches another author's pending paragraph mark, formatting, move, or structure","own-pending":"the edit would merge with or cover the author's own pending change"},yu={"deleted-text-only":"edit.tracked-deleted-text-only","collaborative-insertion":"edit.tracked-foreign-revision-unsupported","foreign-revision":"edit.tracked-foreign-revision-unsupported","own-pending":"edit.tracked-own-pending-change"};function vs(e,t,n,o,r,a){let i=!!o,s=(k,x,O)=>({ok:false,error:{code:k,message:x,...O?{detail:O}:{}}});if(i&&r===false)return s("unsupported-capability","tracked content-control creation is unsupported in collaboration");let d=G(e.span,t,n);if(!d.ok)return s(d.code,"that span is not a place",d.detail);if(!d.value)return s("invalid-offset","that story holds nothing to wrap","empty-story");let u=Z(e.span,t,n),m=u.ok?u.value:null;if(!m)return s("invalid-handle","that story is not in this document");let p=d.value;if(p.start.paragraphId!==p.end.paragraphId)return s("unsupported-content","wrapping several paragraphs in one control is not supported here","multi-paragraph");if(!fs.has(e.subtype))return s("unsupported-content","that control type cannot be inserted",e.subtype);if(i){if(!chunkWO4V6PNS_cjs.Ok(m.part,p.start.paragraphId,p.start.offset,p.end.offset))return s("unsupported-capability","tracked controls require a nonempty ordinary text range without existing review markup");let k=Wt(m,p.start.paragraphId,p.start.offset,p.end.offset);if(k)return {ok:false,error:k}}let h=new Set(Ut(m.root).map(k=>k.id)),f=a(m,p.start.paragraphId);return f||{ok:true,kind:"command",story:m.story,ops:[{op:"insertContentControl",paragraphId:p.start.paragraphId,start:p.start.offset,end:p.end.offset,type:e.subtype,...i?{revision:{author:o,date:new Date().toISOString()}}:{},...e.tag===void 0?{}:{tag:e.tag},...e.title===void 0?{}:{alias:e.title}}],answer:k=>{if(!e.returnHandle)return {kind:"applied"};let O=k.story(m.story)?.node(p.start.paragraphId),I=O?Ut(O).filter(R=>!h.has(R.id)):[];if(I.length!==1)throw new Error("content control insertion did not create a control");return {kind:"handle",handle:t.contentControl(I[0].id,m.story)}}}}function As(e,t,n){let o=chunkWO4V6PNS_cjs.Ta(e,t);if(!o||o.kind!=="contentControl")return false;let r=i=>i.kind==="textValue"||!i.kind.startsWith("revision")&&!i.localName.endsWith("Change")&&i.children.every(r);if(!r(o))return false;let a=chunkWO4V6PNS_cjs.Ua(e,t);return a?.kind==="revisionInsert"&&a.attributes.some(i=>i.namespaceUri===chunkWO4V6PNS_cjs.la&&i.localName==="author"&&i.value===n)}function Rs(e){if(e.length>128)return null;let t=e.trim(),n=new Set,o=[];for(;t;){let r=/^\\([ohzu])(?:\s+"([1-9])-([1-9])")?(?=\s|$)/.exec(t);if(!r)return null;let[,a,i,s]=r;if(n.has(a)||(a==="o"?!i||Number(i)>Number(s):i))return null;n.add(a),o.push(r[0]),t=t.slice(r[0].length).trimStart();}return ["TOC",...o].join(" ")}function so(e,t){let n=chunkWO4V6PNS_cjs.Ta(e,t);if(!n||n.kind!=="paragraph")return [];let o=chunkWO4V6PNS_cjs.kg(n);return chunkWO4V6PNS_cjs.rl(n).flatMap(r=>{let a=o.find(s=>s.node.id===r.fieldNodeId),i=chunkWO4V6PNS_cjs.Ta(e,r.fieldNodeId);return a?[{paragraphId:t,fieldNodeId:r.fieldNodeId,code:r.instruction,start:a.start,end:a.end,rewritable:r.rewritable,locked:!!i&&chunkWO4V6PNS_cjs.Bf(i,"fldLock")===true}]:[]})}function Os(e){let t=chunkWO4V6PNS_cjs.S(e),n=chunkWO4V6PNS_cjs.Ia(`<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body><w:p><w:fldSimple w:instr="${t}"><w:r><w:t/></w:r></w:fldSimple></w:p></w:body></w:document>`,{name:"/word/document.xml",contentType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"});if(!n.ok)throw new Error("could not build a field");let o=n.part.root.children.find(a=>a.kind==="body"),r=o&&chunkWO4V6PNS_cjs.Rc(o)[0];if(!r||r.kind!=="paragraph")throw new Error("could not build a field paragraph");return r}var ye=(e,t="unsupported-content",n)=>({ok:false,error:{code:t,message:e,...n===void 0?{}:{detail:n}}});function Ps(e,t,n,o,r){if(e.op==="getFields"||e.op==="insertField"){let m=G(e.span,t,n),p=Z(e.span,t,n);if(!m.ok||!p.ok)return ye("that field range no longer exists","invalid-handle",m.ok?p.ok?void 0:p.detail:m.detail);let h=p.value;if(e.op==="getFields")return {ok:true,kind:"query",value:{kind:"handles",handles:bt(m.value,h).flatMap(D=>so(h.part,D.paragraphId).filter(B=>B.start>=D.start&&B.end<=D.end)).map(D=>t.field(D.paragraphId,D.fieldNodeId,h.story))}};if(!m.value)return ye("insert a paragraph before inserting a field");if(e.removeFormatting!==void 0&&e.removeFormatting!==false)return ye("removeFormatting is not supported");if(e.text!==void 0&&typeof e.text!="string")return ye("field text must be a string");if(e.fieldType!==void 0&&typeof e.fieldType!="string")return ye("field type must be a string");let f=e.fieldType??"Empty",k=null;if(f==="Page"||f==="NumPages"){if(e.text!==void 0&&e.text.trim()!=="")return ye("field switches are not supported");k=f==="Page"?"PAGE":"NUMPAGES";}else f==="TOC"?k=Rs(e.text??""):f==="Empty"&&(k=chunkWO4V6PNS_cjs.ul(e.text??""));if(!k)return ye("only PAGE, NUMPAGES, and TOC with supported switches can be inserted");let{start:x,end:O}=m.value;if(!["Before","After","Start","End","Replace"].includes(e.location))return ye("unsupported field insert location");if(e.location==="Replace"&&x.paragraphId!==O.paragraphId)return ye("field replacement requires one paragraph");let I=e.location==="After"||e.location==="End"?O:x,R=o(h,I.paragraphId);if(R)return R;let N=[];return e.location==="Replace"&&O.offset>x.offset&&N.push({op:"deleteText",paragraphId:x.paragraphId,start:x.offset,end:O.offset}),N.push({op:"insertFragment",paragraphId:I.paragraphId,offset:I.offset,blocks:[Os(k)],lastMarkCovered:false}),{ok:true,kind:"command",story:h.story,ops:N,answer:E=>{let D=E.story(h.story)?.part,B=D&&so(D,I.paragraphId).find(S=>S.start===I.offset);if(!B)throw new Error("inserted field was not committed");return {kind:"handle",handle:t.field(I.paragraphId,B.fieldNodeId,h.story)}}}}let a=t.resolve(e.field,"field");if(!a||a.kind!=="field")return ye("that is not a field handle","invalid-handle");let i=n.story(a.story),s=i&&so(i.part,a.paragraphId).find(m=>m.fieldNodeId===a.fieldNodeId);if(!i||!i.has(a.paragraphId)||!s)return ye("that field no longer exists","invalid-handle",We);if(e.op==="getField")return {ok:true,kind:"query",value:{kind:"field",field:{code:s.code}}};if(s.locked||chunkWO4V6PNS_cjs.ag(i.part,a.fieldNodeId).content||chunkWO4V6PNS_cjs.dg(i.part,a.fieldNodeId))return ye("field is protected");let d=o(i,a.paragraphId,e.op==="updateFieldResult");if(d)return d;let u=[];if(e.op==="deleteField")u.push({op:"deleteText",paragraphId:a.paragraphId,start:s.start,end:s.end});else if(e.op==="setFieldCode"){if(!chunkWO4V6PNS_cjs.ul(s.code)||!chunkWO4V6PNS_cjs.ul(e.code))return ye("only PAGE and NUMPAGES code writes are supported");u.push({op:"setFieldCode",paragraphId:a.paragraphId,fieldNodeId:a.fieldNodeId,code:e.code});}else {let m=chunkWO4V6PNS_cjs.ul(s.code);if(!m||!s.rewritable)return ye("this field result cannot be evaluated","unsupported-capability");let p=r?.(i.story,a.paragraphId,a.fieldNodeId);if(!p||!Number.isInteger(p.pageNumber)||p.pageNumber<1||!Number.isInteger(p.pageCount)||p.pageCount<1)return ye("field update requires actual semantic pagination","unsupported-capability");let h=m==="PAGE"?p.pageNumberText??String(p.pageNumber):String(p.pageCount);u.push({op:"refreshFieldResults",updates:[{paragraphId:a.paragraphId,fieldNodeId:a.fieldNodeId,text:h}]});}return {ok:true,kind:"command",story:i.story,ops:u,answer:()=>({kind:"applied"})}}var fe=(e,t)=>({ok:false,error:{code:e,message:t,detail:t}}),At=e=>({ok:true,kind:"query",value:e}),ku=new Set(["insertTableRows","getTables","getTable","getTableRows","getTableCells","getTableCell","getTableCellProperties","getTableCellBody","updateTable","updateTableCell","insertTable"]);function un(e){let t=new Set,n=[e];for(;n.length;){let o=n.pop();o.kind==="paragraph"&&t.add(o.id),o.kind!=="textValue"&&n.push(...o.children);}return t}function Is(e,t){let n=un(e);return [...un(t)].filter(o=>!n.has(o)).length}function bu(e,t){let n=[{node:e}];for(;n.length;){let{node:o,table:r}=n.pop();if(o.id===t)return r;if(o.kind==="textValue")continue;let a=o.kind==="table"?o:r;for(let i of o.children)n.push({node:i,table:a});}}function Ss(e){let t=e.package&&chunkWO4V6PNS_cjs.bd(e.package);return t?[...chunkWO4V6PNS_cjs.ad(t).values()].filter(n=>n.type==="table"):[]}function ws(e,t){if(!ku.has(e.op))return null;let{handles:n,reads:o}=t;if(e.op==="getTables"||e.op==="insertTable"){let p=e.op==="getTables"?e.scope:e.span,h=Z(p,n,o);if(!h.ok)return fe(h.code,h.detail);let f=G(p,n,o);if(!f.ok)return fe(f.code,f.detail);let k=h.value;if(e.op==="getTables"){let N=f.value,E=chunkWO4V6PNS_cjs.pj(k.root).filter(D=>{if("body"in p)return true;if(!N)return false;let B=[...un(D)].sort((Y,$)=>k.indexOf(Y)-k.indexOf($)),S=B[0],F=B[B.length-1];return !S||!F?false:k.indexOf(S)>=N.start.index&&k.indexOf(F)<=N.end.index});return At({kind:"handles",handles:E.map(D=>n.table(D.id,k.story))})}if(!f.value)return fe("invalid-offset","empty-table-insertion-range");if(!["Before","After"].includes(e.location))return fe("unsupported-content","table-insertion-location");let x=e.location==="Before"?f.value.start:f.value.end,O=chunkWO4V6PNS_cjs.tj(k,x.paragraphId,x.offset,e.rowCount,e.columnCount,e.values,t.trackingAuthor?{author:t.trackingAuthor,date:new Date().toISOString()}:void 0);if(!O.ok)return fe("unsupported-content",O.reason);let I=t.admitWrite(k,Is(k.part.root,O.resultPart.root),[x.paragraphId]);if(I)return I;let R=new Set(chunkWO4V6PNS_cjs.pj(k.root).map(N=>N.id));return {ok:true,kind:"command",story:k.story,ops:[{op:"authorTable",action:{kind:"insert",paragraphId:x.paragraphId,offset:x.offset,rowCount:e.rowCount,columnCount:e.columnCount,...e.values?{values:e.values}:{}},...t.trackingAuthor?{revision:{author:t.trackingAuthor,date:new Date().toISOString()}}:{}}],answer:N=>{let E=N.story(k.story),D=E&&chunkWO4V6PNS_cjs.pj(E.root).find(B=>!R.has(B.id));return D?{kind:"handle",handle:n.table(D.id,k.story)}:{kind:"applied"}}}}let r=e.op==="getTableCells"||e.op==="insertTableRows"?"tableRow":"cell"in e?"tableCell":"table",a=e.op==="getTableCells"||e.op==="insertTableRows"?e.row:"cell"in e?e.cell:"table"in e?e.table:{kind:"document",ref:""},i=n.resolve(a,r);if(!i||!("nodeId"in i)||!("story"in i))return fe("invalid-handle","unknown-table-object");let s=o.story(i.story);if(!s)return fe("invalid-handle","missing-table-story");let d=chunkWO4V6PNS_cjs.Ta(s.part,i.nodeId);if(!d||d.kind!==r)return fe("invalid-handle","deleted-table-object");let u=r==="table"?d:bu(s.root,i.nodeId);if(!u)return fe("invalid-handle","missing-parent-table");let m=chunkWO4V6PNS_cjs.qj(s,u.id);if(!m)return fe("unsupported-content","unsupported-table-topology");switch(e.op){case "getTable":return At({kind:"table",table:{values:m.values,headerRowCount:m.headerRowCount,rowCount:m.rowIds.length,columnCount:m.columnCount,style:Ss(o).find(p=>p.styleId===m.styleId)?.name??""}});case "getTableRows":return At({kind:"handles",handles:m.rowIds.map(p=>n.tableRow(p,s.story))});case "getTableCells":{let p=m.rowIds.indexOf(i.nodeId);return At({kind:"handles",handles:(m.cellIds[p]??[]).map(h=>n.tableCell(h,s.story))})}case "getTableCell":{if(!Number.isInteger(e.rowIndex)||!Number.isInteger(e.cellIndex))return fe("invalid-offset","invalid-cell-index");let p=m.cellIds[e.rowIndex]?.[e.cellIndex];return p?At({kind:"handle",handle:n.tableCell(p,s.story)}):fe("invalid-handle","cell-not-found")}case "getTableCellBody":return At({kind:"handle",handle:n.body(s.story,i.nodeId)});case "getTableCellProperties":{let p=chunkWO4V6PNS_cjs.rj(s,u.id,i.nodeId);return p?At({kind:"tableCell",cell:{value:p.value,columnWidth:p.columnWidth,shadingColor:p.shadingColor,verticalAlignment:p.verticalAlignment}}):fe("invalid-handle","cell-not-found")}case "insertTableRows":case "updateTable":case "updateTableCell":{let p=e.op==="insertTableRows"?{kind:"insertRows",rowId:i.nodeId,location:e.location,count:e.count,...e.values?{values:e.values}:{}}:e.op==="updateTable"?e.mutation:{...e.properties,kind:"cell",cellId:i.nodeId};if(p.kind==="properties"&&p.styleId!==void 0){let O=p.styleId;if(typeof O!="string"||O.trim().length===0)return fe("unsupported-content","invalid-table-style-name");let I=Ss(o).find(R=>R.name?.trim().toLowerCase()===O.trim().toLowerCase());if(!I)return fe("unsupported-content","table-style-not-defined");p={...p,styleId:I.styleId};}let h=t.trackingAuthor?{author:t.trackingAuthor,date:new Date().toISOString()}:void 0;if(h&&t.trackedRangeReplacement===false&&(p.kind==="values"||p.kind==="cell"&&p.value!==void 0))return fe("unsupported-capability","tracked table value replacement is unsupported in collaboration");let f=chunkWO4V6PNS_cjs.sj(s,u.id,p,h);if(!f.ok)return fe(f.reason==="unsupported-revision"?"unsupported-revision":f.reason==="tracked-table-deletion-unsupported"||f.reason==="unsupported-tracked-table-operation"?"unsupported-capability":"unsupported-content",f.reason);let k=t.admitWrite(s,Is(s.part.root,f.resultPart.root),p.kind==="values"?[...un(u)]:p.kind==="cell"&&p.value!==void 0?[...un(d)]:[]);if(k)return k;let x=new Set(m.rowIds);return {ok:true,kind:"command",story:s.story,ops:[{op:"authorTable",action:{kind:"existing",tableId:u.id,mutation:p},...h?{revision:h}:{}}],answer:O=>{if(p.kind!=="addRows"&&p.kind!=="insertRows")return {kind:"applied"};let I=O.story(s.story);return {kind:"handles",handles:((I&&chunkWO4V6PNS_cjs.qj(I,u.id))?.rowIds??[]).filter(N=>!x.has(N)).map(N=>n.tableRow(N,s.story))}}}}default:return fe("unsupported-content","unknown-table-operation")}}var lo=e=>({ok:false,error:{code:"unsupported-content",message:e}});function ar(e){if(!(typeof e!="object"||e===null)){if("body"in e)return e.body;if("start"in e&&"end"in e)return ar(e.start)??ar(e.end)}}function xu(e){if(e.op==="getText")return e.target;if("body"in e)return e.body;let t=e;for(let n of ["span","scope","at","anchor","paragraph"]){let o=ar(t[n]);if(o)return o}}function Cs(e,t){let n=chunkWO4V6PNS_cjs.Wg(e,{op:"createHeaderFooter",sectionIndex:t.sectionIndex,kind:t.kind,variant:t.variant,...t.variant==="first"?{titlePage:true}:{},...t.variant==="even"?{evenAndOddHeaders:true}:{}});return n.ok&&n.createdPartName?n:null}function vu(e,t){let n=Cs(e,t),o=n&&n.package.parts.get(n.createdPartName);if(!n||!o)return null;let r={...o.root,children:[]};return dt(chunkWO4V6PNS_cjs.Ie(n.package,{...o,root:r}))}function Ts(e,t,n){let o=xu(e);if(!o)return null;let r=t.handles.resolve(o,"body");if(!r||r.kind!=="body"||r.story.kind!=="header"&&r.story.kind!=="footer")return null;let a=r.story,i=t.reads.package;if(!i||t.reads.story(a))return null;if(!t.reads.sections()[a.sectionIndex])return lo("that section no longer exists");if(e.op!=="insertText"&&e.op!=="replaceSpan"&&e.op!=="insertParagraph"){let u=vu(i,a);if(!u)return lo("cannot read this header or footer");let m=n(u).plan(e);return !m.ok||m.kind==="query"?m:m.kind!=="command"||m.ops.length||m.lifecycle||m.packageEdits?.length||m.relate?lo("this header or footer does not exist yet; write text to create it"):{ok:true,kind:"query",value:m.answer(u)}}let s=u=>{let m=Cs(u,a);if(!m)return null;let p=dt(m.package),h=n(p),f=h.plan(e);if(!f.ok||f.kind!=="command"||f.relate||f.lifecycle||f.packageEdits?.length)return null;let k=m.package.parts.get(m.createdPartName);if(!k)return null;for(let O of f.ops){let I=chunkWO4V6PNS_cjs.yl(k,O);if(!I.ok)return null;k=I.part;}let x=chunkWO4V6PNS_cjs.Ie(m.package,k);return h.settle(dt(x)).ok?{pkg:x,planner:h,step:f}:null},d=s(i);return d?{ok:true,kind:"command",story:{kind:"body"},ops:[],solitary:true,packageEdits:[u=>{let m=s(u);if(!m)throw new chunkWO4V6PNS_cjs.cj("header/footer creation changed during transaction");return d=m,m.pkg}],answer:u=>d.step.answer(u)}:lo("cannot create this header or footer with that content")}var Au=20*1024*1024;function Ru(e){if(typeof e!="string"||e.length===0||e.length>Math.ceil(Au/3)*4||e.length%4!==0)return null;let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=e.endsWith("==")?2:e.endsWith("=")?1:0,o=new Uint8Array(e.length/4*3-n),r=0;for(let a=0;a<e.length;a+=4){let i=a+4===e.length,s=i?4-n:4,d=[0,0,0,0];for(let m=0;m<s;m++){let p=t.indexOf(e[a+m]);if(p<0)return null;d[m]=p;}if(i&&(n===2&&(d[1]&15)!==0||n===1&&(d[2]&3)!==0))return null;let u=d[0]<<18|d[1]<<12|d[2]<<6|d[3];r<o.length&&(o[r++]=u>>>16),r<o.length&&(o[r++]=u>>>8),r<o.length&&(o[r++]=u);}return o}function Ns(e,t,n,o,r){let a=Ru(r);if(!a)return {ok:false,detail:"picture: invalid or oversized base64 (20 MiB maximum)"};let i=chunkWO4V6PNS_cjs.fe(a);if(i!=="image/png"&&i!=="image/jpeg")return {ok:false,detail:"picture: only PNG and JPEG are supported"};if(!Ou(a,i))return {ok:false,detail:"picture: truncated raster container"};let s=chunkWO4V6PNS_cjs.ke(a,i);if(!s||s.pixelWidth*s.pixelHeight>4e7)return {ok:false,detail:"picture: invalid or oversized raster dimensions"};let d=s.pixelWidth*72/(s.dpiX??96),u=s.pixelHeight*72/(s.dpiY??96),m=chunkWO4V6PNS_cjs.ye(d),p=chunkWO4V6PNS_cjs.ye(u);if(m===null||p===null)return {ok:false,detail:"picture: invalid physical dimensions"};let h=chunkWO4V6PNS_cjs.ve(e,t,{bytes:a,mime:i});if(!h.ok)return {ok:false,detail:`picture: ${h.reason}`};let f=chunkWO4V6PNS_cjs.ze({docPrId:h.docPrId,lockAspectRatio:true,relationshipId:h.relationshipId,extentEmu:{cx:m,cy:p}});return {ok:true,docPrId:h.docPrId,ops:[{op:"insertDrawing",paragraphId:n,offset:o,drawing:f}],packageEdits:[k=>{let x=chunkWO4V6PNS_cjs.ve(k,t,{bytes:a,mime:i});if(!x.ok||x.relationshipId!==h.relationshipId||x.docPrId!==h.docPrId||x.partName!==h.partName)throw new chunkWO4V6PNS_cjs.cj("picture allocation changed during the batch");return x.pkg}]}}function Es(e,t){return chunkWO4V6PNS_cjs.Qd(e).find(n=>n.drawingNodeId===t&&n.kind==="inline"&&n.picture!==null)??null}function Ds(e){return {width:e.extentEmu.cx/chunkWO4V6PNS_cjs.xe,height:e.extentEmu.cy/chunkWO4V6PNS_cjs.xe,lockAspectRatio:e.locks.changeAspect,altTextDescription:e.description}}function Ls(e,t){let n=new Set(chunkWO4V6PNS_cjs.Qd(e).filter(r=>r.kind==="inline"&&r.picture!==null).map(r=>r.drawingNodeId)),o=[];for(let r of t){let a=chunkWO4V6PNS_cjs.Ta(e,r.paragraphId);if(!(!a||a.kind!=="paragraph"))for(let i of chunkWO4V6PNS_cjs.kg(a))i.start>=r.start&&i.end<=r.end&&n.has(i.node.id)&&o.push(i.node.id);}return o}function Ms(e,t){let n=[],o=e.drawingNodeId;if(t.lockAspectRatio!==void 0&&typeof t.lockAspectRatio!="boolean")return {ok:false,detail:"lockAspectRatio: not a boolean"};let r=t.lockAspectRatio??e.locks.changeAspect;if(t.lockAspectRatio===false&&n.push({op:"setDrawingLocks",drawingNodeId:o,locks:{changeAspect:false}}),t.width!==void 0||t.height!==void 0){let a=t.width??e.extentEmu.cx/chunkWO4V6PNS_cjs.xe,i=t.height??e.extentEmu.cy/chunkWO4V6PNS_cjs.xe;if(r){let u=e.extentEmu.cx/e.extentEmu.cy;if(t.width!==void 0&&t.height!==void 0&&Math.abs(a/i-u)>1e-6)return {ok:false,detail:"picture: width and height disagree with the locked aspect ratio"};t.width!==void 0&&t.height===void 0&&(i=a/u),t.height!==void 0&&t.width===void 0&&(a=i*u);}let s=chunkWO4V6PNS_cjs.ye(a),d=chunkWO4V6PNS_cjs.ye(i);if(s===null||d===null)return {ok:false,detail:"picture: dimensions must be finite positive points"};n.push({op:"resizeDrawing",drawingNodeId:o,extentEmu:{cx:s,cy:d}});}if(t.lockAspectRatio===true&&n.push({op:"setDrawingLocks",drawingNodeId:o,locks:{changeAspect:true}}),t.altTextDescription!==void 0){if(typeof t.altTextDescription!="string"||t.altTextDescription.length>32767||!chunkWO4V6PNS_cjs.T(t.altTextDescription))return {ok:false,detail:"altTextDescription: invalid XML text or length"};n.push({op:"setDrawingMetadata",drawingNodeId:o,title:e.title,description:t.altTextDescription});}return n.length?{ok:true,ops:n}:{ok:false,detail:"picture: no properties requested"}}function Ou(e,t){if(t==="image/jpeg")return e.length>=4&&e[e.length-2]===255&&e[e.length-1]===217;let n=new DataView(e.buffer,e.byteOffset,e.byteLength),o=8,r=false;for(;o+12<=e.length;){let a=n.getUint32(o);if(a>e.length-o-12)return false;let i=String.fromCharCode(e[o+4],e[o+5],e[o+6],e[o+7]);if(i==="IDAT"&&a>0&&(r=true),o+=a+12,i==="IEND")return r&&a===0&&o===e.length}return false}var He=(e,t="unsupported-content",n)=>({ok:false,error:{code:t,message:e,...n===void 0?{}:{detail:n}}});function Bs(e,t,n,o){if(e.op==="getInlinePictures"||e.op==="insertInlinePicture"){let m=G(e.span,t,n),p=Z(e.span,t,n);if(!m.ok||!p.ok)return He("that picture range no longer exists","invalid-handle",m.ok?p.ok?void 0:p.detail:m.detail);let h=p.value;if(e.op==="getInlinePictures")return {ok:true,kind:"query",value:{kind:"handles",handles:Ls(h.part,bt(m.value,h)).map(E=>t.inlinePicture(E,h.story))}};if(!m.value||!n.package)return He("insert a paragraph before inserting a picture");let{start:f,end:k}=m.value;if(!["Before","After","Start","End","Replace"].includes(e.location))return He("unsupported picture insert location");if(e.location==="Replace"&&f.paragraphId!==k.paragraphId)return He("picture replacement requires a single paragraph");let x=e.location==="After"||e.location==="End"?k:f;if(chunkWO4V6PNS_cjs.ag(h.part,x.paragraphId).content||chunkWO4V6PNS_cjs.dg(h.part,x.paragraphId))return He("picture insertion is inside protected content");let O=chunkWO4V6PNS_cjs.Ta(h.part,x.paragraphId);if(O?.kind==="paragraph"){for(let E of chunkWO4V6PNS_cjs.kg(O))if((e.location==="Replace"?E.start<k.offset&&E.end>f.offset:E.start<x.offset&&E.end>x.offset)&&(chunkWO4V6PNS_cjs.ag(h.part,E.node.id).content||chunkWO4V6PNS_cjs.dg(h.part,E.node.id)))return He("picture insertion touches protected content")}let I=o(h,x.paragraphId);if(I)return I;let R=Ns(n.package,h.part.name,x.paragraphId,x.offset,e.base64);if(!R.ok)return He(R.detail);let N=[];return e.location==="Replace"&&k.offset>f.offset&&N.push({op:"deleteText",paragraphId:f.paragraphId,start:f.offset,end:k.offset}),N.push(...R.ops),{ok:true,kind:"command",story:h.story,ops:N,packageEdits:R.packageEdits,answer:E=>{let D=E.story(h.story)?.part,B=D&&chunkWO4V6PNS_cjs.Qd(D).find(S=>S.docPrId===R.docPrId&&S.kind==="inline");if(!B)throw new Error("inserted picture was not committed");return {kind:"handle",handle:t.inlinePicture(B.drawingNodeId,h.story)}}}}let r=t.resolve(e.picture,"inlinePicture");if(!r||r.kind!=="inlinePicture")return He("that is not a picture handle","invalid-handle");let a=n.story(r.story),i=a&&Es(a.part,r.drawingNodeId);if(!a||!i)return He("that inline picture no longer exists","invalid-handle",We);if(e.op==="getInlinePicture")return {ok:true,kind:"query",value:{kind:"inlinePicture",picture:Ds(i)}};let s=chunkWO4V6PNS_cjs.Ta(a.part,r.drawingNodeId);for(;s&&s.kind!=="paragraph";)s=chunkWO4V6PNS_cjs.ig(a.part,s.id);if(!s||!a.has(s.id))return He("picture is outside this story","invalid-handle");let d=o(a,s.id);if(d)return d;let u=e.op==="deleteInlinePicture"?{ok:true,ops:[{op:"deleteDrawing",drawingNodeId:r.drawingNodeId}]}:Ms(i,e.properties);return u.ok?{ok:true,kind:"command",story:a.story,ops:u.ops,answer:()=>({kind:"applied"})}:He(u.detail)}var Hs=["insert","delete"];function Pu(e,t,n){let o=new Map;t.forEach((d,u)=>{for(let m of chunkWO4V6PNS_cjs.Lj(d))o.set(m,u);});let r=t.map((d,u)=>u),a=d=>{for(;r[d]!==d;)r[d]=r[r[d]],d=r[d];return d};for(let[d,u]of o)for(let m=chunkWO4V6PNS_cjs.Ua(e,d);m;m=chunkWO4V6PNS_cjs.Ua(e,m.id)){let p=o.get(m.id);p!==void 0&&(r[a(p)]=a(u));}let i=t.findIndex(d=>chunkWO4V6PNS_cjs.Mj(d)===n);if(i<0)return [];let s=a(i);return t.filter((d,u)=>a(u)===s)}function Fs(e,t,n){if(!Hs.includes(t.revisionKind))return [];let o=Ue(e.story)?e.root:void 0,r=o&&o.kind!=="textValue"?{...e.part,root:o}:e.part,a=Pu(e.part,chunkWO4V6PNS_cjs.yk(r),chunkWO4V6PNS_cjs.Mj(t));if(a.length<2||a.some(m=>!Hs.includes(m.revisionKind)))return [];let i=a.map(chunkWO4V6PNS_cjs.Mj);if(chunk243W4WW2_cjs.va(e.part,n,i,o).result.skipped.length)return [];let s=new Set(chunkWO4V6PNS_cjs.Lj(t)),d=n==="accept"?"acceptRevision":"rejectRevision",u=new Map;for(let m of chunkWO4V6PNS_cjs.rk(e.part)){if(!s.has(m.node.id))continue;let p=O=>m.node.attributes.find(I=>I.namespaceUri===chunkWO4V6PNS_cjs.la&&I.localName===O)?.value,h=t.addresses.find(O=>O.id===p("id")&&O.author===(p("author")??"")&&(O.date??"")===(p("date")??""));if(!h)return [];let f=m.node.localName,k=JSON.stringify([h,f]),x=u.get(k);x?x.siteNodeIds.push(m.node.id):u.set(k,{revision:h,localName:f,siteNodeIds:[m.node.id]});}return [...u.values()].map(m=>({op:d,...m}))}var Vs=256,Iu=1<<22,js=new WeakMap,Su={story:new Map,copy:new Set};function wu(e){return e.kind!=="textValue"&&e.namespaceUri===chunkWO4V6PNS_cjs.la&&e.localName==="txbxContent"}function Cu(e){let t=e.children.find(r=>r.kind!=="textValue"&&r.namespaceUri===chunkWO4V6PNS_cjs.oa&&r.localName==="Fallback");if(!t||t.kind==="textValue")return null;let n=null,o=[{node:t,depth:0}];for(;o.length>0;){let{node:r,depth:a}=o.pop();if(!(r.kind==="textValue"||a>Vs)){if(wu(r)){if(n)return null;n=r;continue}for(let i of r.children)o.push({node:i,depth:a+1});}}return n}function _s(e,t,n,o,r){let a=[{node:e,depth:0}];for(;a.length>0;){let{node:i,depth:s}=a.pop();if(--o.left<0||s>Vs)return false;if(i.kind!=="textValue"){n.set(i.id,t),r?.add(i.id);for(let d of i.children)a.push({node:d,depth:s+1});}}return true}function cn(e){let t=js.get(e.root);if(t)return t;let n={left:Iu},o=Xn(e,chunkWO4V6PNS_cjs.Rc(chunkWO4V6PNS_cjs.Qc(e)??e.root)),r=new Map,a=new Set,i=o.ok;for(let d of o.ok?o.shapes:[]){if(!i)break;let u=d.textboxRoot;if(!u)continue;i=_s(u,u.id,r,n);let m=d.alternate?Cu(d.alternate):null;i&&m&&(i=_s(m,u.id,r,n,a));}let s=!i||r.size===0?Su:{story:r,copy:a};return js.set(e.root,s),s}function Us(e,t,n,o){return t.length===0?n===null&&o():n===null?t.every(r=>!e.story.has(r))&&o():t.every(r=>e.story.get(r)===n)&&t.some(r=>!e.copy.has(r))}var Tu={insert:"Insert",delete:"Delete",replace:"Replace",moveFrom:"MovedFrom",moveTo:"MovedTo",format:"Property",paragraphMark:"ParagraphProperty"};function Ws(e,t){return t.length===0?!Ue(e.story):t.every(n=>e.has(n.start.paragraphId))}function Nu(e,t){if(e.story.kind==="note")return Ws(e,t.ranges);let n=cn(e.part),o=e.story.kind==="textbox"&&e.root.kind!=="textValue"?e.root.id:null;return Us(n,chunkWO4V6PNS_cjs.Lj(t),o,()=>Ws(e,t.ranges))}function pt(e){return Object.freeze(chunkWO4V6PNS_cjs.yk(e.part).filter(t=>Nu(e,t)))}function pn(e){let t=[];for(let n of pt(e)){if(n.readOnly)continue;let o=n.structuralChanges?.length===1?n.structuralChanges[0]:void 0,r=n.revisionKind==="structural"?o==="rowInsert"?"Insert":o==="rowDelete"?"Delete":void 0:Tu[n.revisionKind];r!==void 0&&t.push(Object.freeze({id:n.id,type:r,author:n.author,date:n.date??"",item:n}));}return Object.freeze(t)}function Eu(e,t){let n=e;for(let o=0;n!==void 0&&o<=64;o+=1){if(n.parentId===void 0)return n.range!==null;n=t.get(n.parentId);}return false}var Du=Object.freeze({items:Object.freeze([]),roots:Object.freeze([]),byId:()=>null,textOf:()=>""});function $s(e,t){let n=e.parts.get(chunk243W4WW2_cjs.aa(e,t.part.name));if(!n)return Du;let o=e.parts.get(chunk243W4WW2_cjs.ba(e,t.part.name)),r=chunkWO4V6PNS_cjs.ji(n),a=o?chunkWO4V6PNS_cjs.ki(o):new Map,i=chunkWO4V6PNS_cjs.hi(t.part).filter(p=>t.has(p.start.paragraphId)),s=chunkWO4V6PNS_cjs.zk(r,i,a),d=new Map(s.map(p=>[p.id,p])),u=s.filter(p=>Eu(p,d)),m=new Map(u.map(p=>[p.id,p]));return Object.freeze({items:Object.freeze(u),roots:Object.freeze(u.filter(p=>p.parentId===void 0)),byId:p=>m.get(p)??null,textOf:p=>{let h=m.get(p);return h?chunkWO4V6PNS_cjs.ek(h.comment):""}})}var Lu=64,Ks=Object.freeze({kind:"applied"});function Ee(e,t,n){return {ok:false,error:Object.freeze(n===void 0?{code:e,message:t}:{code:e,message:t,detail:n})}}function uo(e){return {ok:true,kind:"query",value:e}}function Xs(){return {decided:new Map,whole:false}}function ir(e,t,n,o,r){let a=r(e);if(a)return a;if(o.whole)return Ee("conflicting-operations","an earlier decision resolved the whole story");let i=t.filter(k=>o.decided.get(chunkWO4V6PNS_cjs.Mj(k))!=="removed"),s=Bu(e,i.filter(k=>{let x=o.decided.get(chunkWO4V6PNS_cjs.Mj(k));return Mu(k,n)&&(x===void 0||x===n)})),d=[];for(let k of i){let x=chunkWO4V6PNS_cjs.Mj(k),O=o.decided.get(x);if(!s.has(x)){if(O===void 0)d.push(k);else if(O!==n)return Ee("conflicting-operations","an earlier decision took the contrary action")}}let u=k=>{for(let x of k)o.decided.set(x,n);for(let x of s)o.decided.set(x,"removed");};if(d.length===0)return u([]),{ok:true,kind:"command",story:e.story,ops:[],answer:()=>Ks};let m=d.map(chunkWO4V6PNS_cjs.Mj),p=chunk243W4WW2_cjs.va(e.part,n,m,Ue(e.story)?e.root:void 0),h=p.ops,f=p.result.skipped;if(f.length>0){let k=f.every(x=>x.reason==="incomplete-group")?Hu(e,d,n):null;if(!k)return Ee("unsupported-revision","a tracked change in that decision cannot be resolved",f[0]?.reason);h=k,u(m);}else u([...m,...p.result.resolved.map(k=>k.key)]);return {ok:true,kind:"command",story:e.story,ops:h,answer:()=>Ks}}function Mu(e,t){return t==="reject"?e.revisionKind==="insert":e.revisionKind==="delete"}function Bu(e,t){let n=new Set;for(let r of t)for(let a of chunkWO4V6PNS_cjs.Lj(r))n.add(a);if(n.size===0)return new Set;let o=r=>{for(let a=chunkWO4V6PNS_cjs.Ua(e.part,r);a;a=chunkWO4V6PNS_cjs.Ua(e.part,a.id))if(n.has(a.id))return true;return false};return new Set(pt(e).filter(r=>{let a=chunkWO4V6PNS_cjs.Lj(r);return a.length>0&&a.every(o)}).map(chunkWO4V6PNS_cjs.Mj))}function Hu(e,t,n){let o=[];for(let r of t){let a=Fs(e,r,n);if(a.length===0)return null;for(let i of a)o.push(i);}return o}function Ke(e,t){return e.index===t.index?e.offset-t.offset:e.index-t.index}function Fu(e,t,n){let o=e.indexOf(n.start.paragraphId),r=e.indexOf(n.end.paragraphId);if(o<0||r<0)return false;let a={index:o,offset:n.start.offset},i={index:r,offset:n.end.offset},s={index:e.indexOf(t.start.paragraphId),offset:t.start.offset},d={index:e.indexOf(t.end.paragraphId),offset:t.end.offset};return Ke(s,d)===0?Ke(a,d)<=0&&Ke(i,s)>=0:Ke(a,i)===0?Ke(a,s)>=0&&Ke(a,d)<0:Ke(a,d)<0&&Ke(i,s)>0}function Ys(e,t){return t===null?[]:pt(e).filter(n=>n.ranges.some(o=>Fu(e,t,o)))}function zs(e,t,n){let o=new Set(t.map(r=>r.id));return {kind:"handles",handles:pn(e).filter(r=>o.has(r.id)).map(r=>n.revision(r.id,e.story))}}function Js(e){let t=new Map,n=r=>{r&&!t.has(r.part.name)&&t.set(r.part.name,r.part);};n(e.body);let o=e.sections().length;for(let r=0;r<o;r+=1)for(let a of e.furniture(r))a.declared&&n(e.story({kind:a.kind,sectionIndex:r,variant:a.variant}));for(let r of ["footnote","endnote"]){let a=e.noteIds(r),i=a.ok?a.ids[0]:void 0;i!==void 0&&n(e.story({kind:"note",noteKind:r,noteId:i}));}return [...t.values()]}function Qs(e,t){if(t===void 0)return null;let n=e.storyOf(t);return n?e.story(n):null}function sr(e,t){let n=chunkWO4V6PNS_cjs.Qj(t);if(!n||n.kind!=="revision"&&n.kind!=="replacement")return null;let o=n.kind==="replacement"?n.halves:"";for(let r of Js(e)){let a=chunkWO4V6PNS_cjs.yk(r),i=null;if(n.kind==="revision"){let u=a.find(m=>m.id===n.id);u&&(i=[u]);}else for(let u of a){if(!o.startsWith(`${u.id}+`))continue;let m=o.slice(u.id.length+1),p=a.find(h=>h.id===m);if(p&&chunkWO4V6PNS_cjs.Pj(u,p)){i=[u,p];break}}if(!i)continue;let s=Qs(e,i[0].ranges[0]?.start.paragraphId);if(!s)return null;let d=new Set(pt(s).map(u=>u.id));return i.every(u=>d.has(u.id))?{reads:s,items:i}:null}return null}function ju(e,t){let n=e.package,o=e.body;if(!n||!o)return null;let r=n.parts.get(chunk243W4WW2_cjs.aa(n,o.part.name));if(!r)return null;let a=n.parts.get(chunk243W4WW2_cjs.ba(n,o.part.name)),i=a?chunkWO4V6PNS_cjs.ki(a):new Map,s=[];for(let p of Js(e))for(let h of chunkWO4V6PNS_cjs.hi(p))s.push(h);let d=chunkWO4V6PNS_cjs.zk(chunkWO4V6PNS_cjs.ji(r),s,i),u=new Map(d.map(p=>[p.id,p])),m=u.get(t);for(let p=0;m&&p<=Lu;p+=1){if(m.range){if(m.orphaned)return null;let h=Qs(e,m.range.start.paragraphId);return h&&h.has(m.range.end.paragraphId)?{reads:h,range:m.range}:null}m=m.parentId===void 0?void 0:u.get(m.parentId);}return null}function Gs(e,t,n){let o=null,r=null;for(let i of t)for(let s of [i.start,i.end]){let d=e.rawText(s.paragraphId);if(d===null)return null;let u={paragraphId:s.paragraphId,index:e.indexOf(s.paragraphId),offset:Math.min(s.offset,d.length)};(!o||Ke(u,o)<0)&&(o=u),(!r||Ke(u,r)>0)&&(r=u);}if(!o||!r)return null;let a=e.story;return we({start:{...o,story:a},end:{...r,story:a}},n)}function lr(e){return typeof e=="string"&&e.length>0?null:Ee("unsupported-content","a review item key is nonempty text")}function Zs(e,t,n){let o=lr(e);if(o)return o;if(n.package===null)return Ee("document-unavailable","this host holds no document");let r=chunkWO4V6PNS_cjs.Qj(e),a=null;if(r?.kind==="comment"){let i=ju(n,r.id);a=i?Gs(i.reads,[i.range],t):null;}else {let i=sr(n,e),s=i?.items.flatMap(d=>d.ranges)??[];a=i&&s.length>0?Gs(i.reads,s,t):null;}return uo({kind:"spans",spans:a?[a]:[]})}function qs(e,t,n){if("body"in e){let a=le(e.body,"body",t,n);if(!a.ok)return Ee(a.code,"that handle does not name a body",a.detail);let i=a.value;return uo({kind:"handles",handles:pn(i).map(s=>t.revision(s.id,i.story))})}if("key"in e){let a=lr(e.key);if(a)return a;let i=sr(n,e.key);return uo(i?zs(i.reads,i.items,t):{kind:"handles",handles:[]})}let o=G(e.scope,t,n);if(!o.ok)return Ee(o.code,"that span is not a place",o.detail);let r=Z(e.scope,t,n);return r.ok?uo(zs(r.value,Ys(r.value,o.value),t)):Ee(r.code,"that span names no story",r.detail)}function el(e,t,n,o,r){let a=e.op==="acceptAllRevisions"?"accept":"reject",i;if("key"in e){let s=lr(e.key);if(s)return s;let d=sr(n,e.key);if(!d)return Ee("invalid-handle","that review item is not in this document");i=d;}else {let s=e.scope,d=G(s,t,n);if(!d.ok)return Ee(d.code,"that span is not a place",d.detail);let u=Z(s,t,n);if(!u.ok)return Ee(u.code,"that span names no story",u.detail);i={reads:u.value,items:Ys(u.value,d.value)};}return i.items.some(s=>s.readOnly)?Ee("unsupported-revision","a tracked change in that decision is read-only"):ir(i.reads,i.items,a,r,o)}function tl(e,t,n,o){let r=h=>({ok:false,error:{code:"unsupported-content",message:h}});if(e.breakType!=="Page"&&e.breakType!=="SectionNext")return r("only Line, Page, and SectionNext breaks are supported");if(!["Before","After","Start","End","Replace"].includes(e.location))return r("invalid break insertion location");let a=G(e.span,t,n);if(!a.ok)return {ok:false,error:{code:a.code,message:a.detail}};let i=a.value;if(!i)return r("empty story has no break position");let s=e.location==="After"||e.location==="End"?i.end:i.start,d=n.story(s.story);if(!d)return r("missing story");if(e.location==="Replace"&&i.start.paragraphId!==i.end.paragraphId)return r("break replacement must remain in one paragraph");let u=e.breakType==="SectionNext";if(u&&(d.story.kind!=="body"||chunkWO4V6PNS_cjs.Zk(d.part,s.paragraphId)))return r("section breaks require a body paragraph outside a table");let m=o(d,s.paragraphId,u?1:0);if(m)return m;let p=[];return e.location==="Replace"&&i.end.offset>i.start.offset&&p.push({op:"deleteText",paragraphId:s.paragraphId,start:i.start.offset,end:i.end.offset}),u?p.push({op:"splitParagraph",paragraphId:s.paragraphId,offset:s.offset},{op:"setSectionMark",paragraphId:s.paragraphId,breakType:"nextPage"}):p.push({op:"insertPageBreak",paragraphId:s.paragraphId,offset:s.offset}),{ok:true,kind:"command",story:d.story,ops:p,answer:()=>({kind:"applied"})}}function nl(e,t){if(e.op!=="insertBreak"||e.breakType!=="Line")return null;let{span:n,location:o}=e,r=s=>"body"in n?{body:n.body,at:s}:"paragraph"in n?{paragraph:n.paragraph,at:s}:s==="start"?n.start:n.end,a=o==="Replace"?{op:"replaceSpan",span:n,text:nt}:o==="Before"||o==="Start"?{op:"insertText",at:r("start"),text:nt}:o==="After"||o==="End"?{op:"insertText",at:r("end"),text:nt}:null;if(!a)return {ok:false,error:{code:"unsupported-content",message:"invalid break insertion location"}};let i=t(a);return i.ok&&i.kind==="command"?{...i,answer:()=>({kind:"applied"})}:i}var ze=(e,t)=>e.children.find(n=>n.kind!=="textValue"&&n.namespaceUri===chunkWO4V6PNS_cjs.la&&n.localName===t),Fe=(e,t)=>e.attributes.find(n=>n.namespaceUri===chunkWO4V6PNS_cjs.la&&n.localName===t)?.value,co=e=>e.replaceAll("&","&").replaceAll('"',""").replaceAll("<","<").replaceAll(">",">"),dr=e=>typeof e=="string"&&e.length<=255&&!/[\x00-\x08\x0b\x0c\x0e-\x1f\uFFFE\uFFFF]/.test(e),ol={None:"none",Arabic:"decimal",UpperRoman:"upperRoman",LowerRoman:"lowerRoman",UpperLetter:"upperLetter",LowerLetter:"lowerLetter"},rl={Solid:["\uF0B7","Symbol"],Hollow:["o","Courier New"],Square:["\uF0A7","Wingdings"],Diamonds:["\uF076","Wingdings"],Arrow:["\uF0D8","Wingdings"],Checkmark:["\uF0FC","Wingdings"]};function ur(e){let t=chunkWO4V6PNS_cjs.Dg(e,"bullet");if(!t)return null;let n=t.pkg;for(let o=0;o<=8;o+=1)if(!mn(n,t.numId,o)){let r=po(n,t.numId,o,{bullet:o%3===0?"Solid":o%3===1?"Hollow":"Square"});if(!r)return null;n=r;}return {pkg:n,numId:t.numId}}function mn(e,t,n){let o=e.parts.get("/word/numbering.xml")?.root;if(!o)return false;let r=o.children,a=r.find(u=>u.kind!=="textValue"&&u.namespaceUri===chunkWO4V6PNS_cjs.la&&u.localName==="num"&&Fe(u,"numId")===t);if(!a)return false;let i=a.children.find(u=>u.kind!=="textValue"&&u.namespaceUri===chunkWO4V6PNS_cjs.la&&u.localName==="lvlOverride"&&Fe(u,"ilvl")===String(n));if(i&&ze(i,"lvl"))return true;let s=ze(a,"abstractNumId"),d=s&&r.find(u=>u.kind!=="textValue"&&u.namespaceUri===chunkWO4V6PNS_cjs.la&&u.localName==="abstractNum"&&Fe(u,"abstractNumId")===Fe(s,"val"));return !!d&&!ze(d,"numStyleLink")&&d.children.some(u=>u.kind!=="textValue"&&u.namespaceUri===chunkWO4V6PNS_cjs.la&&u.localName==="lvl"&&Fe(u,"ilvl")===String(n))}function cr(e,t){if(!Number.isInteger(e)||e<0||e>8||!t||typeof t!="object")return false;if(t.bullet!==void 0){if(t.numbering!==void 0)return false;if(t.bullet==="Custom"){if(!Number.isInteger(t.charCode)||t.charCode<1||t.charCode>65535||t.charCode>=55296&&t.charCode<=57343||!dr(String.fromCharCode(t.charCode)))return false}else if(!Object.hasOwn(rl,t.bullet))return false;if(t.fontName!==void 0&&(!dr(t.fontName)||!t.fontName.trim()))return false}if(t.numbering!==void 0&&!Object.hasOwn(ol,t.numbering)||t.formatString!==void 0&&(!Array.isArray(t.formatString)||t.formatString.length>32||t.formatString.some(o=>typeof o=="number"?!Number.isInteger(o)||o<0||o>e:!dr(o)||/%[1-9]/.test(o)))||t.startingNumber!==void 0&&(!Number.isInteger(t.startingNumber)||t.startingNumber<0||t.startingNumber>2147483647))return false;for(let o of [t.textIndent,t.bulletNumberPictureIndent])if(o!==void 0&&(!Number.isFinite(o)||Math.abs(o)>1584))return false;let n=["bullet","charCode","fontName","numbering","formatString","startingNumber","textIndent","bulletNumberPictureIndent"];return Object.keys(t).some(o=>!n.includes(o))||t.bullet===void 0&&(t.charCode!==void 0||t.fontName!==void 0)||t.numbering===void 0&&t.formatString!==void 0?false:Object.keys(t).length>0}function po(e,t,n,o){if(!cr(n,o))return null;let r=e.parts.get("/word/numbering.xml");if(!r)return null;let a=r.root.children.find(S=>S.kind!=="textValue"&&S.namespaceUri===chunkWO4V6PNS_cjs.la&&S.localName==="num"&&Fe(S,"numId")===t),i=a&&ze(a,"abstractNumId");if(!a||!i)return null;let s=r.root.children.find(S=>S.kind!=="textValue"&&S.namespaceUri===chunkWO4V6PNS_cjs.la&&S.localName==="abstractNum"&&Fe(S,"abstractNumId")===Fe(i,"val"));if(!s||ze(s,"numStyleLink"))return null;let d=a.children.find(S=>S.kind!=="textValue"&&S.namespaceUri===chunkWO4V6PNS_cjs.la&&S.localName==="lvlOverride"&&Fe(S,"ilvl")===String(n)),u=(d&&ze(d,"lvl"))??s.children.find(S=>S.kind!=="textValue"&&S.namespaceUri===chunkWO4V6PNS_cjs.la&&S.localName==="lvl"&&Fe(S,"ilvl")===String(n));if(u&&ze(u,"lvlPicBulletId"))return null;let m=chunkWO4V6PNS_cjs.Ra(r),p=S=>S.kind==="textValue"?{...S,id:m()}:{...S,id:m(),children:S.children.map(p)},h=S=>{let F=chunkWO4V6PNS_cjs.Ia(`<w:numbering xmlns:w="${chunkWO4V6PNS_cjs.la}">${S}</w:numbering>`,{name:r.name,contentType:r.contentType}),Y=F.ok?F.part.root.children[0]:void 0;return Y&&Y.kind!=="textValue"?p(Y):null};if(u??=h(`<w:lvl w:ilvl="${n}"><w:start w:val="1"/><w:numFmt w:val="decimal"/><w:lvlText w:val="%${n+1}."/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="${720*(n+1)}" w:hanging="360"/></w:pPr></w:lvl>`)??void 0,!u)return null;let f=[...u.children],k=["start","numFmt","lvlRestart","pStyle","isLgl","suff","lvlText","lvlPicBulletId","legacy","lvlJc","pPr","rPr"],x=(S,F)=>{let Y=h(F);if(!Y)return false;let $=f.findIndex(V=>V.kind!=="textValue"&&V.namespaceUri===chunkWO4V6PNS_cjs.la&&V.localName===S);if($>=0){let V=f[$];f.splice($,1,{...V,attributes:[...V.attributes.filter(J=>!Y.attributes.some(se=>se.namespaceUri===J.namespaceUri&&se.localName===J.localName)),...Y.attributes]});}else {let V=f.findIndex(J=>J.kind!=="textValue"&&J.namespaceUri===chunkWO4V6PNS_cjs.la&&k.indexOf(J.localName)>k.indexOf(S));f.splice(V<0?f.length:V,0,Y);}return true};if(o.startingNumber!==void 0&&!x("start",`<w:start w:val="${o.startingNumber}"/>`))return null;if(o.numbering!==void 0){let S=o.formatString?.map(F=>typeof F=="number"?`%${F+1}`:F).join("")??(o.numbering==="None"?"":`%${n+1}.`);if(!x("numFmt",`<w:numFmt w:val="${ol[o.numbering]}"/>`)||!x("lvlText",`<w:lvlText w:val="${co(S)}"/>`))return null}if(o.numbering!==void 0&&(f=f.map(S=>S.kind!=="textValue"&&S.namespaceUri===chunkWO4V6PNS_cjs.la&&S.localName==="rPr"?{...S,children:S.children.filter(F=>F.kind==="textValue"||F.namespaceUri!==chunkWO4V6PNS_cjs.la||F.localName!=="rFonts")}:S)),o.bullet!==void 0){let[S,F]=o.bullet==="Custom"?[String.fromCharCode(o.charCode),o.fontName??"Symbol"]:rl[o.bullet];if(!x("numFmt",'<w:numFmt w:val="bullet"/>')||!x("lvlText",`<w:lvlText w:val="${co(S)}"/>`))return null;let Y=ze(u,"rPr"),$=h(`<w:rFonts w:ascii="${co(F)}" w:hAnsi="${co(F)}"/>`);if(!$)return null;let V=Y?.children.filter(K=>K.kind==="textValue"||K.namespaceUri!==chunkWO4V6PNS_cjs.la||K.localName!=="rFonts")??[],J=Y?{...Y,children:[$,...V]}:h("<w:rPr/>");if(!J)return null;let se=f.findIndex(K=>K.kind!=="textValue"&&K.namespaceUri===chunkWO4V6PNS_cjs.la&&K.localName==="rPr");se<0?f.push({...J,children:[$,...V]}):f[se]={...J,children:[$,...V]};}if(o.textIndent!==void 0||o.bulletNumberPictureIndent!==void 0){let S=ze(u,"pPr"),F=S&&ze(S,"ind"),Y=F?.attributes.filter(L=>L.namespaceUri!==chunkWO4V6PNS_cjs.la||!["left","start","firstLine","hanging"].includes(L.localName))??[],$=o.textIndent===void 0?String(chunkWO4V6PNS_cjs.nd(Fe(F??u,"left"))??0):String(Math.round(o.textIndent*20)),V=o.bulletNumberPictureIndent,J=V===void 0?F?.attributes.filter(L=>L.namespaceUri===chunkWO4V6PNS_cjs.la&&["firstLine","hanging"].includes(L.localName))??[]:[],se=h(`<w:ind w:left="${$}"${V===void 0?"":` w:${V<0?"hanging":"firstLine"}="${Math.abs(Math.round(V*20))}"`}/>`);if(!se)return null;let K={...se,attributes:[...Y,...J,...se.attributes]},ke=S?.children.filter(L=>L.kind==="textValue"||L.namespaceUri!==chunkWO4V6PNS_cjs.la||L.localName!=="ind")??[],ce=S??h("<w:pPr/>");if(!ce)return null;let be=F?S.children.indexOf(F):-1,he=[...ke],xe=["contextualSpacing","mirrorIndents","suppressOverlap","jc","textDirection","textAlignment","textboxTightWrap","outlineLvl","divId","cnfStyle","rPr","sectPr","pPrChange"],ve=he.findIndex(L=>L.kind!=="textValue"&&L.namespaceUri===chunkWO4V6PNS_cjs.la&&xe.includes(L.localName));he.splice(be>=0?be:ve>=0?ve:he.length,0,K);let Xe={...ce,children:he},Ye=f.findIndex(L=>L.kind!=="textValue"&&L.namespaceUri===chunkWO4V6PNS_cjs.la&&L.localName==="pPr");if(Ye>=0)f[Ye]=Xe;else {let L=f.findIndex(q=>q.kind!=="textValue"&&q.localName==="rPr"&&q.namespaceUri===chunkWO4V6PNS_cjs.la);f.splice(L<0?f.length:L,0,Xe);}}let O=p({...u,children:f}),I=d?.children.filter(S=>S.kind==="textValue"||S.namespaceUri!==chunkWO4V6PNS_cjs.la||S.localName!=="lvl"&&(o.startingNumber===void 0||S.localName!=="startOverride"))??[],R=d??h(`<w:lvlOverride w:ilvl="${n}"/>`);if(!R)return null;let N={...R,children:[...I,O]},E=[...a.children],D=d?E.indexOf(d):-1;D>=0?E[D]=N:E.push(N);let B=chunkWO4V6PNS_cjs.Za(r,a.id,{...a,children:E});return B.ok?chunkWO4V6PNS_cjs.Ie(e,B.part):null}function Rt(e,t){return e&&"children"in e?e.children.find(n=>n.kind!=="textValue"&&n.namespaceUri===chunkWO4V6PNS_cjs.la&&n.localName===t):void 0}function pr(e,t){return e&&"attributes"in e?e.attributes.find(n=>n.namespaceUri===chunkWO4V6PNS_cjs.la&&n.localName===t)?.value:void 0}function al(e,t,n,o){return t.length>0&&t.every(r=>{let a=Rt(chunkWO4V6PNS_cjs.Ta(e.part,r)??void 0,"pPr");if(pr(Rt(Rt(a,"rPr"),"ins"),"author")===o)return true;let i=Rt(a,"pPrChange"),s=Rt(i,"pPr");return pr(i,"author")===o&&pr(Rt(Rt(s,"numPr"),"numId"),"val")!==n})}var $t=8;function il(e){if(!e||e.kind==="textValue")return null;for(let t of e.attributes)if(t.namespaceUri===chunkWO4V6PNS_cjs.la&&t.localName==="val")return t.value;return null}function mo(e){let t=chunkWO4V6PNS_cjs.hg(chunkWO4V6PNS_cjs.fg(e),"numPr");if(!t)return null;let n=il(chunkWO4V6PNS_cjs.hg(t,"numId"));if(n===null||!/^\d{1,10}$/.test(n)||n==="0")return null;let o=il(chunkWO4V6PNS_cjs.hg(t,"ilvl")),r=o===null?0:Number(o);return !Number.isInteger(r)||r<0||r>$t?null:{numId:n,level:r}}function Ot(e){let t=new Map;for(let n of e.paragraphIds){let o=e.node(n);if(!o)continue;let r=mo(o);if(!r)continue;let a=t.get(r.numId);a?a.push(n):t.set(r.numId,[n]);}return Object.freeze([...t].map(([n,o])=>Object.freeze({numId:n,paragraphIds:Object.freeze(o)})))}function fn(e,t){let n=e.node(t);return n?mo(n):null}var Oe=e=>({ok:false,error:{code:"unsupported-content",message:e}});function _u(e,t){if(e.root.namespaceUri!==chunkWO4V6PNS_cjs.la||e.root.localName!=="styles")return false;let n=[e.root];for(;n.length;){let o=n.pop();if(o.kind!=="textValue"){if(o.namespaceUri===chunkWO4V6PNS_cjs.la&&o.localName==="numId"&&o.attributes.some(r=>r.namespaceUri===chunkWO4V6PNS_cjs.la&&r.localName==="val"&&r.value===t))return true;for(let r of o.children)n.push(r);}}return false}function sl(e,t,n,o,r){let a=n.package;if(!a)return Oe("no document");if(e.op==="setListLevelFormat"){let f=t.resolve(e.list,"list");if(!f||f.kind!=="list")return Oe("that is not a list");let k=n.story(f.story),x=k&&Ot(k).find(O=>O.numId===f.numId);if(!k||!x)return Oe("that list no longer exists");if(r&&!al(k,x.paragraphIds,f.numId,r))return {ok:false,error:{code:"unsupported-capability",message:"Only a newly proposed list definition can change while tracking"}};if(!cr(e.level,e.format))return Oe("invalid list level format");for(let O of a.parts.values()){if(_u(O,f.numId))return Oe("list is referenced by a style");for(let I of chunkWO4V6PNS_cjs.Oc(O))for(let R of chunkWO4V6PNS_cjs.Rc(I.root))if(mo(R)?.numId===f.numId&&!k.has(R.id))return Oe("list is shared across stories")}for(let O of x.paragraphIds){if(chunkWO4V6PNS_cjs.ag(k.part,O).content||chunkWO4V6PNS_cjs.dg(k.part,O))return Oe("list contains protected content");let I=o(k,O,{numId:f.numId,level:e.level});if(I)return I}return po(a,f.numId,e.level,e.format)?{ok:true,kind:"command",story:k.story,ops:[],packageEdits:[O=>{let I=po(O,f.numId,e.level,e.format);if(!I)throw new chunkWO4V6PNS_cjs.cj("list definition changed during transaction");return I}],answer:()=>({kind:"applied"})}:Oe("cannot format this list")}let i=pe(e.paragraph,t,n);if(!i.ok)return {ok:false,error:{code:i.code,message:i.detail}};let s=n.story(i.value.story);if(!s)return Oe("missing story");let d=o(s,i.value.paragraphId);if(d)return d;let u=null,m=0,p=[];if(e.op==="startNewList"){let f=ur(a);if(!f)return Oe("cannot create numbering definition");let k=i.value.paragraphId;if(!chunkWO4V6PNS_cjs.yl(s.part,{op:"setListNumbering",paragraphId:k,numId:f.numId,level:0}).ok)return Oe("cannot number this paragraph");let O=f.numId;return {ok:true,kind:"command",story:s.story,ops:[],packageEdits:[I=>{let R=ur(I),N=R?.pkg.parts.get(s.part.name);if(!R||!N)throw new chunkWO4V6PNS_cjs.cj("cannot create numbering definition");let E=chunkWO4V6PNS_cjs.yl(N,{op:"setListNumbering",paragraphId:k,numId:R.numId,level:0,...r?{revision:{author:r,date:new Date().toISOString()}}:{}});if(!E.ok)throw new chunkWO4V6PNS_cjs.cj(E.detail??"cannot number this paragraph",E.reason);return O=R.numId,chunkWO4V6PNS_cjs.Ie(R.pkg,E.part)}],answer:()=>({kind:"handle",handle:t.list(O,s.story)})}}else if(e.op==="attachToList"){if(!Number.isSafeInteger(e.listId)||e.listId<=0||!Number.isInteger(e.level)||e.level<0||e.level>8)return Oe("invalid list identity or level");if(u=String(e.listId),m=e.level,!mn(a,u,m))return Oe("list level is not defined; configure that level first");if(!Ot(s).some(f=>f.numId===u))return Oe("that list does not exist in this story")}let h=u;return {ok:true,kind:"command",story:s.story,ops:[{op:"setListNumbering",paragraphId:i.value.paragraphId,numId:e.op==="detachFromList"?"0":u,level:m}],packageEdits:p,answer:()=>h===null?{kind:"applied"}:{kind:"handle",handle:t.list(h,s.story)}}}var mr=Object.freeze({None:"none",Single:"single",Word:"words",Double:"double",Thick:"thick",Dotted:"dotted",DottedHeavy:"dottedHeavy",DashLine:"dash",DashLineHeavy:"dashedHeavy",DashLineLong:"dashLong",DashLineLongHeavy:"dashLongHeavy",DotDashLine:"dotDash",DotDashLineHeavy:"dashDotHeavy",TwoDotDashLine:"dotDotDash",TwoDotDashLineHeavy:"dashDotDotHeavy",Wave:"wave",WaveHeavy:"wavyHeavy",WaveDouble:"wavyDouble"}),ll=[["Yellow","yellow","#FFFF00"],["Lime","green","#00FF00"],["Turquoise","cyan","#00FFFF"],["Pink","magenta","#FF00FF"],["Blue","blue","#0000FF"],["Red","red","#FF0000"],["DarkBlue","darkBlue","#000080"],["Teal","darkCyan","#008080"],["Green","darkGreen","#008000"],["Purple","darkMagenta","#800080"],["DarkRed","darkRed","#800000"],["Olive","darkYellow","#808000"],["Gray","darkGray","#808080"],["LightGray","lightGray","#C0C0C0"],["Black","black","#000000"],["White","white","#FFFFFF"]];function dl(e){return Object.entries(mr).find(([,t])=>t===e)?.[0]??null}function ul(e){return ll.find(([,t])=>t===e)?.[2]??null}function cl(e){let t=[];if(e.underline!==void 0){let n=typeof e.underline=="string"&&Object.hasOwn(mr,e.underline)?mr[e.underline]:void 0;if(!n)return {ok:false,detail:"underline: unsupported underline style"};t.push({localName:"u",attributes:{val:n}});}if(e.strikeThrough!==void 0){if(typeof e.strikeThrough!="boolean")return {ok:false,detail:"strikeThrough: not a boolean"};t.push({localName:"strike",attributes:{val:e.strikeThrough?"1":"0"}});}for(let n of ["subscript","superscript"])if(e[n]!==void 0&&typeof e[n]!="boolean")return {ok:false,detail:`${n}: not a boolean`};if(e.subscript===true&&e.superscript===true)return {ok:false,detail:"subscript and superscript are mutually exclusive"};if(e.highlightColor!==void 0){let n=e.highlightColor,o=typeof n=="string"?ll.find(([r,,a])=>r.toLowerCase()===n.toLowerCase()||a===n.toUpperCase()):void 0;if(n!==null&&!o)return {ok:false,detail:"highlightColor: use an exact Word palette color or null to clear"};t.push({localName:"highlight",attributes:{val:o?.[1]??"none"}});}return {ok:true,value:t}}var Vu=31680,Uu=1999,Wu=Object.freeze({bold:null,italic:null,underline:null,strikeThrough:null,highlightColor:null,subscript:null,superscript:null,name:null,size:null,color:null});function ge(e,t){if(!e)return null;for(let n of e.attributes)if(n.localName===t)return n.value;return null}function go(e){if(!e)return null;let t=ge(e,"val");if(t===null)return true;let n=t.trim().toLowerCase();return !(n==="0"||n==="false"||n==="off"||n==="none")}function $u(e){if(e===null)return null;let t=e.trim();return /^[0-9a-fA-F]{6}$/.test(t)?`#${t.toUpperCase()}`:null}function Ku(e){if(e===null)return null;let t=Number(e.trim());return !Number.isFinite(t)||t<=0?null:t/2}function Pt(e){let t=chunkWO4V6PNS_cjs.nd(e??void 0);return t===null?null:chunkWO4V6PNS_cjs.ld(chunkWO4V6PNS_cjs.jd(t))}function Ge(e){if(e.length===0)return null;let t=e[0];if(t===null)return null;for(let n of e)if(n!==t)return null;return t}function fl(e,t,n=chunkWO4V6PNS_cjs.Dh){let o=[];for(let r of t)for(let a of chunkWO4V6PNS_cjs.ai(e,r.paragraphId,r.start,r.end,n))o.push(chunkWO4V6PNS_cjs.gg(a));return o.length===0?Wu:{bold:Ge(o.map(r=>go(chunkWO4V6PNS_cjs.hg(r,"b")))),italic:Ge(o.map(r=>go(chunkWO4V6PNS_cjs.hg(r,"i")))),underline:Ge(o.map(r=>dl(ge(chunkWO4V6PNS_cjs.hg(r,"u"),"val")))),strikeThrough:Ge(o.map(r=>go(chunkWO4V6PNS_cjs.hg(r,"strike")))),highlightColor:Ge(o.map(r=>ul(ge(chunkWO4V6PNS_cjs.hg(r,"highlight"),"val")))),subscript:Ge(o.map(r=>ml(r,"subscript"))),superscript:Ge(o.map(r=>ml(r,"superscript"))),name:Ge(o.map(r=>{let a=chunkWO4V6PNS_cjs.hg(r,"rFonts"),i=ge(a,"ascii");return i===null||i.length===0?null:i})),size:Ge(o.map(r=>Ku(ge(chunkWO4V6PNS_cjs.hg(r,"sz"),"val")))),color:Ge(o.map(r=>$u(ge(chunkWO4V6PNS_cjs.hg(r,"color"),"val"))))}}var zu=Object.freeze({left:"Left",start:"Left",center:"Centered",right:"Right",end:"Right",both:"Justified",distribute:"Justified"}),Gu=Object.freeze({Left:"left",Centered:"center",Right:"right",Justified:"both"});function gl(e){let t=null;for(let n of e?.children??[]){if(n.kind==="textValue"||n.localName!=="bidi")continue;let o=ge(n,"val");t=o===null||["1","true","on"].includes(o);}return t}function Xu(e){let t=ge(chunkWO4V6PNS_cjs.hg(e,"jc"),"val");return t===null?"Unknown":zu[t.trim().toLowerCase()]??"Unknown"}function hl(e,t,n){let o=chunkWO4V6PNS_cjs.Ta(e,t);if(!o||o.kind!=="paragraph")return null;let r=chunkWO4V6PNS_cjs.fg(o),a=chunkWO4V6PNS_cjs.hg(r,"spacing"),i=chunkWO4V6PNS_cjs.hg(r,"ind");return {alignment:Xu(r),style:Jn(e,t,n),firstLineIndent:Yu(i),leftIndent:Pt(ge(i,"left")??ge(i,"start")),rightIndent:Pt(ge(i,"right")??ge(i,"end")),lineSpacing:Pt(ge(a,"line")),spaceBefore:Pt(ge(a,"before")),spaceAfter:Pt(ge(a,"after")),widowControl:go(chunkWO4V6PNS_cjs.hg(r,"widowControl")),readingOrder:gl(r)??n.inheritsRtl(e,o)?"RightToLeft":"LeftToRight"}}function Yu(e){let t=Pt(ge(e,"hanging"));if(t!==null&&t>0)return -t;let n=Pt(ge(e,"firstLine"));return n!==null?n:t===null?null:-t}function fo(e,t){if(typeof e!="number"||!Number.isFinite(e))return {ok:false,detail:`${t}: not a measurement`};let n=chunkWO4V6PNS_cjs.md(chunkWO4V6PNS_cjs.kd(e));return Math.abs(n)>Vu?{ok:false,detail:`${t}: out of range`}:{ok:true,value:n}}function yl(e){let t=cl(e);if(!t.ok)return t;let n=t.value;if(e.bold!==void 0){if(typeof e.bold!="boolean")return {ok:false,detail:"bold: not a boolean"};n.push({localName:"b",...e.bold?{}:{attributes:{val:"0"}}});}if(e.italic!==void 0){if(typeof e.italic!="boolean")return {ok:false,detail:"italic: not a boolean"};n.push({localName:"i",...e.italic?{}:{attributes:{val:"0"}}});}if(e.name!==void 0){let o=e.name;if(typeof o!="string"||o.length===0||o.length>128)return {ok:false,detail:"name: not a font name"};if(!chunkWO4V6PNS_cjs.T(o))return {ok:false,detail:"name: not valid XML text"};n.push({localName:"rFonts",attributes:{ascii:o,hAnsi:o}});}if(e.size!==void 0){let o=e.size;if(typeof o!="number"||!Number.isFinite(o)||o<=0)return {ok:false,detail:"size: not a positive number of points"};let r=Math.round(o*2);if(r<1||r>Uu)return {ok:false,detail:"size: out of range"};n.push({localName:"sz",attributes:{val:String(r)}}),n.push({localName:"szCs",attributes:{val:String(r)}});}if(e.color!==void 0){let o=e.color;if(typeof o!="string"||!/^#[0-9a-fA-F]{6}$/.test(o.trim()))return {ok:false,detail:"color: not a #RRGGBB triplet"};n.push({localName:"color",attributes:{val:o.trim().slice(1).toUpperCase()}});}return n.length===0&&e.subscript===void 0&&e.superscript===void 0?{ok:false,detail:"no formatting was asked for"}:{ok:true,value:n}}function kl(e,t,n,o){let r=chunkWO4V6PNS_cjs.Ta(e,t);if(!r||r.kind!=="paragraph")return {ok:false,detail:"not a paragraph"};let a=chunkWO4V6PNS_cjs.fg(r),i=[],s;if(n.style!==void 0){let R=Qn(n.style,o);if(!R.ok)return {ok:false,detail:R.detail};s=R.styleId,i.push({localName:"pStyle",attributes:{val:R.styleId}});}if(n.alignment!==void 0){let R=Gu[n.alignment];if(R===void 0)return {ok:false,detail:`alignment: ${String(n.alignment)}`};i.push({localName:"jc",attributes:{val:R}});}let d=chunkWO4V6PNS_cjs.hg(a,"ind"),u=pl(d),m=false;if(n.firstLineIndent!==void 0){let R=fo(n.firstLineIndent,"firstLineIndent");if(!R.ok)return R;delete u.firstLine,delete u.hanging,R.value<0?u.hanging=String(-R.value):u.firstLine=String(R.value),m=true;}for(let[R,N,E]of [["leftIndent","left","start"],["rightIndent","right","end"]]){let D=n[R];if(D===void 0)continue;let B=fo(D,R);if(!B.ok)return B;delete u[E],u[N]=String(B.value),m=true;}m&&i.push({localName:"ind",attributes:u});let p=chunkWO4V6PNS_cjs.hg(a,"spacing"),h=pl(p),f=false;for(let[R,N]of [["spaceBefore","before"],["spaceAfter","after"]]){let E=n[R];if(E===void 0)continue;let D=fo(E,R);if(!D.ok)return D;if(D.value<0)return {ok:false,detail:`${R}: out of range`};h[N]=String(D.value),f=true;}if(n.lineSpacing!==void 0){let R=fo(n.lineSpacing,"lineSpacing");if(!R.ok)return R;if(R.value<=0)return {ok:false,detail:"lineSpacing: out of range"};h.line=String(R.value),h.lineRule??="auto",f=true;}if(f&&i.push({localName:"spacing",attributes:h}),n.widowControl!==void 0){if(typeof n.widowControl!="boolean")return {ok:false,detail:"widowControl: not a boolean"};i.push({localName:"widowControl",...n.widowControl?{}:{attributes:{val:"0"}}});}let k=false;if(n.readingOrder!==void 0){if(n.readingOrder!=="RightToLeft"&&n.readingOrder!=="LeftToRight")return {ok:false,detail:`readingOrder: ${String(n.readingOrder)}`};let R=n.readingOrder==="RightToLeft",N=gl(a),E=o.inheritsRtl(e,r,s);(N??E)!==R&&(E===R?k=true:i.push({localName:"bidi",...R?{}:{attributes:{val:"0"}}}));}if(i.length===0&&!k&&n.readingOrder===void 0)return {ok:false,detail:"no formatting was asked for"};let x=chunkWO4V6PNS_cjs.Nh(e,t),O=chunkWO4V6PNS_cjs.Ph(x,i),I=k?O.filter(R=>R.localName!=="bidi"):O;return {ok:true,value:I,unchanged:Ju(x,I)}}function Ju(e,t){if(e.length!==t.length)return false;let n=r=>JSON.stringify([r.localName,Object.entries(r.attributes??{}).sort(([a],[i])=>a<i?-1:a>i?1:0)]),o=new Set(e.map(n));return t.every(r=>o.has(n(r)))}function pl(e){let t=Object.create(null);if(!e)return t;for(let n of e.attributes)t[n.localName]=n.value;return t}function fr(e,t){if(t.subscript===void 0&&t.superscript===void 0)return [...e];let n=e.find(r=>r.localName==="vertAlign")?.attributes?.val,o=t.subscript===true?"subscript":t.superscript===true?"superscript":n==="subscript"&&t.subscript===false||n==="superscript"&&t.superscript===false?"baseline":n??"baseline";return chunkWO4V6PNS_cjs.Ph(e,[{localName:"vertAlign",attributes:{val:o}}])}function ml(e,t){let n=ge(chunkWO4V6PNS_cjs.hg(e,"vertAlign"),"val");return n===null?null:n===t}function bl(){let e=false,t=false,n=false,o=false;return {conflict(r){let a=et(r),i=rn(r),s=r.op==="deleteComment",d=r.op==="updateFieldResult";return a&&(d&&e&&!o||o&&!d)?{message:"field result updates require a batch without other edits; sync document edits before updating fields",detail:r.op}:i&&e||t&&a?{message:"that command commits on its own and cannot share a batch",detail:r.op}:s&&e&&!n||n&&a&&!s?{message:"comment deletions may share a batch only with other comment deletions",detail:r.op}:null},note(r){et(r)&&(e=true,rn(r)&&(t=true),r.op==="deleteComment"&&(n=true),r.op==="updateFieldResult"&&(o=true));},get hasCommands(){return e}}}function xl(e,t,n,o,r){let a=Math.min(r?.limit??2e3,2e3),i=[],s=Re(t,e),d=s.length-1;for(let[u,m]of s.entries()){if(a<=0)break;let p=e.projectedText(m,r?.projection??"allMarkup");if(!p)continue;let h=p.findOccurrences(ao(o),a,{matchCase:r?.matchCase===true,wholeWord:r?.matchWholeWord===true,...u===0&&t?{from:p.projectedOffset(t.start.offset)}:{},...u===d&&t?{to:p.projectedOffset(t.end.offset)}:{}});for(let f of h.matches){if(u===0&&t&&f.rawStart<t.start.offset||u===d&&t&&f.rawEnd>t.end.offset)continue;let k=n.paragraph(m,e.story);i.push({start:{paragraph:k,offset:f.rawStart},end:{paragraph:k,offset:f.rawEnd}}),a-=1;}}return {ok:true,spans:i}}var Qu=64,vl=new WeakMap;function gr(e,t){if(e.kind==="textValue")return -1;let n=vl.get(e);if(!n){let o=new Map;e.children.forEach((r,a)=>{o.has(r.id)||o.set(r.id,a);}),n=o,vl.set(e,n);}return n.get(t)??-1}var Zu=new Set(["drawing","pict","object","AlternateContent","txbxContent"]),ho=(e,t)=>({code:"unsupported-capability",message:e,detail:t});function Al(e,t){let n=chunkWO4V6PNS_cjs.Ta(e,t);if(!n||n.kind!=="paragraph")return null;if(chunkWO4V6PNS_cjs.hg(chunkWO4V6PNS_cjs.fg(n),"sectPr"))return ho("a tracked deletion cannot remove a section break","section-mark");let o=false,r=0,a=false,i=false,s=(d,u)=>{if(!(d.kind==="textValue"||i)){if(u>Qu){i=true;return}if(!(chunkWO4V6PNS_cjs.ja(d.kind)||Zu.has(d.localName))){if(d.kind==="contentControl"&&(o=true),d.kind==="fldChar"){let m=chunkWO4V6PNS_cjs.rf(d);m==="begin"?r+=1:m==="end"&&(r===0?a=true:r-=1);}for(let m of d.children)s(m,u+1);}}};for(let d of n.children)s(d,0);return i?ho("the paragraph nests content too deeply to check","depth"):o?ho("a tracked paragraph deletion cannot remove an inline content control","control"):a||r>0?ho("a field crosses this paragraph mark","cross-paragraph-field"):null}function Rl(e,t){let n=chunkWO4V6PNS_cjs.Ua(e,t);if(!n)return null;let o=gr(n,t);if(o<0)return null;for(let r=o+1;r<n.children.length;r+=1){let a=n.children[r];if(a.kind==="paragraph")return a;if(!chunkWO4V6PNS_cjs.gk(a))return null}return null}function Ol(e,t){if(t.length<2)return true;let n=chunkWO4V6PNS_cjs.Ua(e,t[0]);if(!n)return false;let o=n.children,r=gr(n,t[0]);if(r<0)return false;for(let a=1;a<t.length;a+=1){let i=r+1;for(;i<o.length&&o[i].kind!=="paragraph"&&chunkWO4V6PNS_cjs.gk(o[i]);)i+=1;if(o[i]?.id!==t[a])return false;r=i;}return true}function Pl(e,t,n){let o=chunkWO4V6PNS_cjs.Ua(e,t);if(!o)return false;let r=gr(o,t);for(let a=r-1;a>=0;a-=1){let i=o.children[a];if(i.kind==="paragraph")return chunkWO4V6PNS_cjs.wl(i,"del")?.author===n;if(!chunkWO4V6PNS_cjs.gk(i))return false}return false}function Sl(e,t,n,o){if(e.op==="insertText")return {op:"proposeInsertion",span:{start:e.at,end:e.at},text:e.text,where:"Before",author:t};if(e.op==="replaceSpan")return {op:"proposeReplacement",span:e.span,text:e.text,author:t};if(e.op!=="deleteParagraph")return e;let r=pe(e.paragraph,n,o);if(!r.ok)return {ok:false,error:{code:r.code,message:"that handle does not name a paragraph",detail:r.detail}};let{story:a,paragraphId:i,index:s}=r.value,d=o.story(a),u=d?.paragraphIds[s+1];return !d||u===void 0||Rl(d.part,i)?.id!==u?{ok:false,error:{code:"unsupported-capability",message:"a tracked paragraph deletion needs a next paragraph in the same container",detail:"paragraph"}}:{op:"proposeDeletion",span:{start:{paragraph:e.paragraph,offset:0},end:{paragraph:n.paragraph(u,a),offset:0}},author:t}}function Il(e,t,n){return Pl(e,t,n.trim())?{ok:false,error:{code:"unsupported-revision",message:"a deletion beside the author's pending deletion would review as one decision",detail:"span"}}:null}function wl(e,t,n,o,r,a=true,i=false){let s=($,V,J)=>({ok:false,error:{code:$,message:V,...J===void 0?{}:{detail:J}}}),d=$=>we($,n),u=$=>({ok:true,kind:"query",value:$}),m=xs(e,t);if(m)return {ok:false,error:m};let p=e.op==="proposeInsertion",h=e.op==="proposeDeletion",f=G(e.span,n,o);if(!f.ok)return s(f.code,"that span is not a place",f.detail);let k=f.value;if(k&&t&&!p&&k.start.paragraphId!==k.end.paragraphId){if(!a&&!h&&e.text!=="")return s("unsupported-capability","tracked paragraph-range replacement is unsupported in collaboration","span");let $=Z(e.span,n,o);if(!$.ok)return s($.code,"that story is not a place",$.detail);let V=$.value,J=V.indexOf(k.start.paragraphId),se=V.indexOf(k.end.paragraphId),K=V.paragraphIds.slice(J,se+1);if(!Ol(V.part,K))return s("unsupported-content","tracked ranges require adjacent sibling paragraphs","span");if(k.start.offset===0){let L=Il(V.part,K[0],e.author);if(L)return L}let ke={author:e.author.trim(),date:new Date().toISOString()},ce=[],be=[];for(let L=0;L<K.length;L++){let q=K[L],Ae=L===0?k.start.offset:0,oe=L===K.length-1?k.end.offset:(V.rawText(q)??"").length,Ce=Wt(V,q,Ae,oe,void 0,false,void 0,oe>Ae?{author:ke.author,strikesMark:L<K.length-1,collaborative:i}:void 0)??(L<K.length-1?Al(V.part,q):null);if(Ce)return {ok:false,error:Ce};let Je=oe>Ae||L<K.length-1?r(V,q):null;if(Je)return Je;oe>Ae&&ce.push({op:"deleteText",paragraphId:q,start:Ae,end:oe,revision:ke}),L<K.length-1&&be.push({op:"setParagraphMarkRevision",paragraphId:q,kind:"del",revision:ke});}ce.push(...be);let he=(V.rawText(K[0])??"").length,xe=h?"":e.text,ve=ct(V.part,K[0],k.start.offset,he,xe);if(ve)return ve;xe&&ce.push({op:"insertText",paragraphId:K[0],offset:he,text:xe,revision:ke});let Xe=xe?rr(V,K[0],{start:k.start.offset,end:he},he,ke):he,Ye={...k.start,offset:Xe};return {ok:true,kind:"command",ops:ce,story:V.story,answer:()=>({kind:"span",span:d({start:Ye,end:{...Ye,offset:Ye.offset+xe.length}})})}}if(!k||k.start.paragraphId!==k.end.paragraphId)return s("unsupported-content","proposals require a single paragraph range","span");if(!t&&!p&&k.start.offset===k.end.offset)return s("unsupported-content","deletion and replacement need a non-empty range","span");let x=Z(e.span,n,o);if(!x.ok)return s(x.code,"that story is not a place",x.detail);let O=k.start.paragraphId,I=p&&e.where==="After"?k.end.offset:k.start.offset,R=p?I:k.end.offset;if(t&&!p&&R>I&&I===0){let $=Il(x.value.part,O,e.author);if($)return $}if(t&&!h&&I===R&&e.text==="")return u({kind:"span",span:d({start:k.start,end:k.start})});let N=Wt(x.value,O,I,R,t&&p?e.author.trim():void 0,p&&I===(x.value.rawText(O)??"").length,t&&!p&&R>I?e.author.trim():void 0,t?{author:e.author.trim(),collaborative:i,...!h&&e.text.length>0?{insertsAt:p?I:R}:{}}:void 0);if(N)return {ok:false,error:N};if(!h){let $=ct(x.value.part,O,I,R,e.text);if($)return $}let E={author:e.author.trim(),date:new Date().toISOString()},D=p?I:R,B=t&&!h&&e.text.length>0,S=B?rr(x.value,O,p?null:{start:I,end:R},D,E):D;if(B&&bs(x.value,O,S,E.author))return s("unsupported-revision","the new text would land inside a container within another author's pending insertion","edit.tracked-foreign-revision-unsupported");let F=r(x.value,O);if(F)return F;let Y=[];return !p&&R>I&&Y.push({op:"deleteText",paragraphId:O,start:I,end:R,revision:E}),!h&&e.text.length>0&&Y.push({op:"insertText",paragraphId:O,offset:p?I:R,text:e.text,revision:E}),{ok:true,kind:"command",ops:Y,story:x.value.story,answer:()=>{if(!t)return {kind:"applied"};let $={...k.start,offset:S};return {kind:"span",span:d({start:$,end:{...$,offset:$.offset+(h?0:e.text.length)}})}}}}function Cl(e,t,n){return Wt(e,t,0,(e.rawText(t)??"").length,n,true)}var Tl=5e4;function yo(e,t,n){if("body"in e){let o=le(e.body,"body",t,n);return o.ok?{ok:true,reads:o.value}:{ok:false,code:o.code,message:"that handle does not name a body",detail:o.detail}}return t.resolve(e.document,"document")?n.body?{ok:true,reads:n.body}:{ok:false,code:"document-unavailable",message:"this host holds no document"}:{ok:false,code:"invalid-handle",message:"that handle does not name a document",detail:"document"}}function qu(e,t){if(t.root.kind!=="textValue"&&chunkWO4V6PNS_cjs.rk({...t.part,root:t.root}).length===0)return [];let n=e.op,o=cn(t.part),r=()=>chunkWO4V6PNS_cjs.rk(t.part).map(d=>d.node.id),a=d=>{let u=[];for(let m=0;m<d.length;m+=Tl)u.push({op:n,siteNodeIds:d.slice(m,m+Tl)});return u};if(t.story.kind==="textbox"){let d=t.root.id,u=o.copy.size?r().filter(m=>o.copy.has(m)&&o.story.get(m)===d):[];return [{op:n,scopeRootId:d},...a(u)]}if(Ue(t.story))return [{op:n,scopeRootId:t.root.id}];if(o.story.size===0)return [{op:n}];let i=r(),s=i.filter(d=>!o.story.has(d));return s.length===i.length?[{op:n}]:a(s)}function Nl(e,t,n){let o=yo({op:"acceptAllRevisions",body:e.body},t,n);if(!o.ok)return o;if(e.revisions!==void 0&&!Array.isArray(e.revisions))return {ok:false,code:"unsupported-content",message:"invalid revision batch"};let r=e.revisions===void 0?void 0:[];r===void 0&&!Ue(o.reads.story)&&cn(o.reads.part).story.size>0&&(r=pt(o.reads).map(chunkWO4V6PNS_cjs.Mj));for(let i of e.revisions??[]){let s=t.resolve(i,"revision");if(!s||s.kind!=="revision"||z(s.story)!==z(o.reads.story))return {ok:false,code:"invalid-handle",message:"revision does not belong to this story"};r.push(`revision-${s.revisionId}`);}let a=Ue(o.reads.story)?o.reads.root:void 0;return {ok:true,reads:o.reads,keys:r,scopeRoot:a}}function ec(e,t,n){let o=Nl(e,t,n);if(!o.ok)return o;if(!["accept","reject"].includes(e.action))return {ok:false,code:"unsupported-content",message:"invalid revision batch"};let r=chunk243W4WW2_cjs.va(o.reads.part,e.action,o.keys,o.scopeRoot);return {ok:true,reads:o.reads,...r}}function tc(e,t,n){let o={author:e.author,...e.date===void 0?{}:{date:e.date}};if(typeof e.author!="string"||e.date!==void 0&&typeof e.date!="string"||chunkWO4V6PNS_cjs.Dk(o)||e.authors!==void 0&&(e.revisions!==void 0||!Array.isArray(e.authors)||e.authors.some(i=>typeof i!="string")))return {ok:false,code:"unsupported-content",message:"author must be nonblank text, date an xsd:dateTime, and authors a list without revisions"};let r=Nl(e,t,n);if(!r.ok)return r;let a=chunkWO4V6PNS_cjs.Ek(r.reads.part,o,r.keys,r.scopeRoot,e.authors);return {ok:true,reads:r.reads,...a}}function nc(e,t,n,o){let r=yo({op:"acceptAllRevisions",body:e},n,o);if(!r.ok)throw new Error("resolved story disappeared");let a=pt(r.reads).length;return {kind:"revisionBatch",result:{...t,remaining:a}}}function El(e,t,n,o,r){if("scope"in e||"key"in e)return el(e,t,n,o,r);if(e.op==="setRevisionAuthorBatch"){let s=tc(e,t,n);if(!s.ok)return {ok:false,error:{code:s.code,message:s.message}};let d=o(s.reads);return d||{ok:true,kind:"command",story:s.reads.story,ops:s.ops,answer:u=>{let m=yo({op:"acceptAllRevisions",body:e.body},t,u);if(!m.ok)throw new Error("reattributed story disappeared");let p=s.finish(m.reads.part),h="revision-";return t.retargetRevisions(s.reads.story,p.updated.flatMap(({previousKey:f,key:k})=>f.startsWith(h)&&k.startsWith(h)?[{from:f.slice(h.length),to:k.slice(h.length)}]:[])),{kind:"revisionAuthors",result:p}}}}if(e.op==="resolveRevisionBatch"){let s=ec(e,t,n);if(!s.ok)return {ok:false,error:{code:s.code,message:s.message}};let d=o(s.reads);return d||{ok:true,kind:"command",story:s.reads.story,ops:s.ops,answer:u=>nc(e.body,s.result,t,u)}}let a=yo(e,t,n);if(!a.ok)return {ok:false,error:{code:a.code,message:a.message,detail:a.detail}};let i=o(a.reads);return i||(r.whole||r.decided.size>0?{ok:false,error:{code:"conflicting-operations",message:"an earlier decision in this batch resolved changes"}}:(r.whole=true,{ok:true,kind:"command",story:a.reads.story,ops:qu(e,a.reads),answer:()=>({kind:"applied"})}))}var oc=/[\r\n\u2028\u2029]/u,Ml=Object.freeze({kind:"applied"});function It(e,t,n){return {ok:false,error:Object.freeze(n===void 0?{code:e,message:t}:{code:e,message:t,detail:n})}}function hr(e,t){return It("unsupported-content",e==="author"?"a comment records who wrote it":e==="date"?"a comment date must be a valid ISO-8601 instant":t==="reply"?"a reply says something":"a comment says something",e)}function yr(e){return chunk243W4WW2_cjs.U(e.author)?hr("author",e.kind):chunk243W4WW2_cjs.V(e.text)?hr("text",e.kind):typeof e.text=="string"&&oc.test(e.text)?It("unsupported-content",e.kind==="reply"?"a reply is one paragraph in this slice":"a comment is one paragraph in this slice","text"):chunk243W4WW2_cjs.X(e.date)?hr("date",e.kind):null}var Dl=()=>`${new Date().toISOString().slice(0,19)}Z`;function kr(e){if(e===void 0)return Dl();let t=chunk243W4WW2_cjs.W(e);return t.ok?t.value:Dl()}function Ll(e,t){let n=chunkWO4V6PNS_cjs.Ta(e.part,t);for(;n;){if(n.kind==="tableCell"||n.kind!=="textValue"&&n.namespaceUri===chunkWO4V6PNS_cjs.la&&n.localName==="tc")return n.id;n=chunkWO4V6PNS_cjs.Ua(e.part,n.id);}return null}function Bl(e,t,n,o){let r=yr({author:e.author,text:e.text,date:e.date,kind:"comment"});if(r)return r;let a=G(e.span,t,n);if(!a.ok)return It(a.code,"that span is not a place",a.detail);if(a.value===null)return It("invalid-handle","an empty story has no comment anchor");let i=Z(e.span,t,n);if(!i.ok)return It(i.code,"that span is not a place",i.detail);if(i.value.story.kind==="textbox")return It("unsupported-content","a comment cannot be anchored in a text box");let s=a.value;if(Ll(i.value,s.start.paragraphId)!==Ll(i.value,s.end.paragraphId))return It("unsupported-content","a comment range cannot cross a table-cell boundary");let d=o(i.value);if(d)return d;let u=kr(e.date);return {ok:true,kind:"commentWrite",write:{kind:"create",anchor:{paragraphId:s.start.paragraphId,start:s.start.offset,end:s.end.offset,...s.end.paragraphId===s.start.paragraphId?{}:{endParagraphId:s.end.paragraphId}},text:e.text,author:e.author,date:u},story:i.value.story,answer:(p,h)=>h===void 0?Ml:{kind:"handle",handle:t.comment(h,i.value.story)}}}function Hl(e,t,n){let o=n(t);if(o)return o;let r=t.story;return {ok:true,kind:"commentWrite",write:{kind:"delete",commentId:e.id,...e.parentId===void 0?{}:{parentCommentId:e.parentId},...r.kind==="note"?{noteId:r.noteId}:{}},story:r,answer:()=>Ml}}var rc=1e4;function Fl(e,t){let n=[],o=t.kind==="contentControl"?chunkWO4V6PNS_cjs.Xb(t):t;if(!o)return n;for(let r of chunkWO4V6PNS_cjs.$b(o))if(!(r.ancestors.length>0)){if(n.length>=rc)break;n.push(Wl(e,r.node));}return n}function jl(e,t){for(let n of chunkWO4V6PNS_cjs.$b(e.root))if(n.node.id===t)return Wl(e,n.node);return null}function _l(e,t){for(let n of chunkWO4V6PNS_cjs.$b(e.root))if(n.node.id===t)return n.node;return null}function Vl(e,t){for(let n of e.paragraphIds){let o=e.node(n);if(!(!o||o.kind!=="paragraph")&&chunkWO4V6PNS_cjs.$b(o).some(r=>r.node.id===t))return o}return null}function ko(e,t){let n=$l(t);if(n.length>0){let a=n[0],i=n[n.length-1],s=e.rawText(i);return s===null||!e.has(a)?null:{start:{paragraphId:a,offset:0},end:{paragraphId:i,offset:s.length}}}let o=Vl(e,t.id);if(!o)return null;let r=chunkWO4V6PNS_cjs.mg(o).spanOf(t);return r?{start:{paragraphId:o.id,offset:r.start},end:{paragraphId:o.id,offset:r.end}}:null}function ac(e,t,n){let o=Vl(e,t.id),r=chunkWO4V6PNS_cjs.Xb(t);if(!o||!r)return null;let a={...o,children:r.children},i=chunkWO4V6PNS_cjs.ij(a);return Zn(a,i,n).text}function Ul(e,t,n="allMarkup"){if(n==="allMarkup")return chunkWO4V6PNS_cjs.bc(t,chunkWO4V6PNS_cjs.th);let o=ac(e,t,n);if(o!==null)return o;let r=ko(e,t);if(!r)return "";let a=e.indexOf(r.start.paragraphId),i=e.indexOf(r.end.paragraphId);if(a<0||i<a)return "";let s=[];for(let d=a;d<=i;d+=1){let u=e.paragraphIds[d],m=e.projectedText(u,n),p=e.rawText(u);if(!m||p===null)return "";s.push(m.sliceRaw(d===a?r.start.offset:0,d===i?r.end.offset:p.length));}return s.join("\r")}function Wl(e,t){return {nodeId:t.id,properties:chunkWO4V6PNS_cjs.Zb(t),lock:chunkWO4V6PNS_cjs.Gk(e.part,t.id),paragraphIds:$l(t)}}function $l(e){let t=chunkWO4V6PNS_cjs.Xb(e);if(!t)return [];let n=[];return chunkWO4V6PNS_cjs.Sc(t.children,n,0),n.map(o=>o.id)}var ic=new Set(["unlocked","sdtLocked","contentLocked","sdtContentLocked"]),sc=4096,Kl=64;function zl(e){if(e===void 0)return {ok:true,value:null};if(typeof e!="object"||e===null)return {ok:false,field:"payload"};let t=e;for(let n of ["namespaceUri","rootLocalName","nodeId"]){let o=t[n];if(typeof o!="string"||o.length===0||o.length>sc)return {ok:false,field:n}}return typeof t.label!="string"||t.label.length>chunk243W4WW2_cjs.ga?{ok:false,field:"label"}:typeof t.data!="string"||t.data.length===0||t.data.length>chunk243W4WW2_cjs.fa?{ok:false,field:"data"}:{ok:true,value:{namespaceUri:t.namespaceUri,rootLocalName:t.rootLocalName,nodeId:t.nodeId,label:t.label,data:t.data}}}function Gl(e){let t=e.at!==void 0,n=e.span!==void 0;return t===n?{message:"a custom node goes at a position or over a span, not both",detail:t?"at+span":"no-place"}:typeof e.tag!="string"||e.tag.length===0?{message:"a custom node carries its identity in its tag",detail:"tag"}:e.tag.length>Kl?{message:`w:tag caps at ${String(Kl)} characters; a longer payload belongs in the store`,detail:"tag"}:typeof e.text!="string"||e.text.length===0?{message:"a custom node shows some text",detail:"text"}:e.lock!==void 0&&!ic.has(e.lock)?{message:"that is not a lock",detail:String(e.lock)}:null}function Xl(e,t,n,o){return {paragraphId:t.paragraphId,offset:t.offset,...n.offset>t.offset?{replaceUntil:n.offset}:{},tag:e.tag,text:e.text,...e.title===void 0?{}:{alias:e.title},...e.lock===void 0||e.lock==="unlocked"?{}:{lock:e.lock},...o===null?{}:{payload:o}}}function Yl(e,t,n){if(e.span){let r=G(e.span,t,n);return r.ok?r.value?r.value.start.paragraphId!==r.value.end.paragraphId?{code:"unsupported-content",message:"a custom node wraps text inside one paragraph",detail:"multi-paragraph"}:{range:r.value}:{code:"invalid-offset",message:"that story holds nothing to wrap",detail:"empty-story"}:{code:r.code,message:"that span is not a place",detail:r.detail}}let o=Ft(e.at,t,n);return o.ok?{range:{start:o.value,end:o.value}}:{code:o.code,message:"that is not a place",detail:o.detail}}var lc=16,dc=64;function uc(e,t,n){return Object.freeze(n===void 0?{code:e,message:t}:{code:e,message:t,detail:n})}function b(e,t,n){return {ok:false,error:uc(e,t,n)}}var gn=e=>b("invalid-handle",e,We),de=Object.freeze({kind:"applied"});function _(e){return {ok:true,kind:"query",value:e}}function br(e){let{runPropertyEdits:t,mergedParagraphMarkProperties:n}=ts(()=>e.reads.package?chunkWO4V6PNS_cjs.bd(e.reads.package)?.root??null:null,()=>e.reads.package?chunkWO4V6PNS_cjs.ah(e.reads.package)?.root??null:null,()=>e.displayMode??"proposed"),{handles:o,capabilities:r}=e,a=e.reads,i=new Map,s=new Map,d=c=>{let y=`${z(c.story)}:${c.root.id}`,A=i.get(y);if(A)return A;let P=new Map,w=c.paragraphIds.map(l=>{let g={id:l};return P.set(l,g),g}),M={externalCreatedCount:0,reads:c,order:w,slotById:P,created:[],restructured:new Set,touched:new Set,textEdits:new io,formatted:new Set,selected:new Set,retargets:[]};return i.set(y,M),M},u=[],m=bl(),p=false,h=null,f=c=>h===null?(h=c,null):h===c?null:b("conflicting-operations","one batch writes into one story",`${z(h.reads.story)} then ${z(c.reads.story)}`),k=c=>f(d(c)),x=k,O=Xs(),I=c=>{let y=a.package;return y===null?null:$s(y,c)},R=c=>{let y=o.resolve(c,"comment");if(!y||y.kind!=="comment")return {ok:false,planned:b("invalid-handle","that handle does not name a comment","comment")};let A=a.story(y.story);if(!A)return {ok:false,planned:b("invalid-handle","that story is not in this document")};let w=I(A)?.byId(y.commentId)??null;return w?{ok:true,reads:A,item:w}:{ok:false,planned:gn("this document no longer holds that comment")}},N=c=>{let y=o.resolve(c,"revision");if(!y||y.kind!=="revision")return {ok:false,planned:b("invalid-handle","that handle does not name a tracked change","revision")};let A=a.story(y.story);if(!A)return {ok:false,planned:b("invalid-handle","that story is not in this document")};let P=pn(A).find(w=>w.id===y.revisionId)??null;return P?{ok:true,reads:A,item:P}:{ok:false,planned:gn("this document no longer holds that tracked change")}},E=(c,y)=>{let A=c.rawText(y.start.paragraphId),P=c.rawText(y.end.paragraphId);if(A===null||P===null)return null;let w={story:c.story,paragraphId:y.start.paragraphId,index:c.indexOf(y.start.paragraphId),offset:Math.min(y.start.offset,A.length)},M={story:c.story,paragraphId:y.end.paragraphId,index:c.indexOf(y.end.paragraphId),offset:Math.min(y.end.offset,P.length)};return V({start:w,end:M})},D=(c,y)=>c.order.indexOf(y),B=(c,y)=>c.selected.has(y)?b("conflicting-operations","this batch selects a paragraph it also edits",y):null,S=(c,y)=>{let A=B(c,y);return A||(c.restructured.has(y)||c.touched.has(y)?b("conflicting-operations","another operation in this batch already changes that paragraph",y):(c.restructured.add(y),c.touched.add(y),null))},F=(c,y)=>{let A=B(c,y);return A||(c.restructured.has(y)||c.textEdits.has(y)?b("conflicting-operations","another operation in this batch restructures that paragraph",y):(c.touched.add(y),null))},Y=(c,y,A)=>{let P=`${A}:${y}`;if(c.formatted.has(P))return b("conflicting-operations","another operation in this batch already writes that formatting",y);let w=F(c,y);return w||(c.formatted.add(P),null)},$=(c,y)=>{let A={id:null};return c.order.splice(y,0,A),c.created.push(A),A},V=c=>we(c,o),J=c=>c===null?null:a.story(c.start.story),se=c=>c===void 0||c==="allMarkup"||c==="original"||c==="model",K=(c,y,A,P)=>{if(!se(P?.projection))return b("unsupported-content","unknown text projection","projection");if(P?.matchWildcards===true)return b("unsupported-capability","wildcard search is not implemented","matchWildcards");if(P?.ignorePunct===true)return b("unsupported-capability","ignoring punctuation is not implemented","ignorePunct");if(P?.ignoreSpace===true)return b("unsupported-capability","ignoring whitespace is not implemented","ignoreSpace");if(!chunk243W4WW2_cjs.sa(A))return b("unsupported-content","that is not a query this host will scan for","text");let w=P?.limit;if(w!==void 0&&(!Number.isInteger(w)||w<0))return b("invalid-offset","limit must be a non-negative integer",String(w));let M=xl(c,y,o,A,P);return M.ok?_({kind:"spans",spans:M.spans}):b("invalid-offset","projection mapping failed",M.paragraphId)},ke=(c,y,A,P=false)=>{let w=y.start.paragraphId,M=c.textEdits.has(w)?B(c,w):c.touched.has(w)?b("conflicting-operations","text edits cannot share a paragraph with other edits",w):F(c,w);return M||rs(c.textEdits,y,A,o,P)},ce=(c,y,A,P=false)=>{if(typeof A!="string"||ut.test(A))return b("unsupported-content","insertText needs text without paragraph marks","text");let w=ct(c.reads.part,y.paragraphId,y.offset,y.offset,A);if(w)return w;let M=f(c);if(M)return M;let l=e.replacementLanding?.(y.paragraphId,y.offset,y.offset)!=null,g=!l&&os(c.reads.part,y.paragraphId,y.offset,A);if(g)return g;if(!l&&or(c.reads.part,y.paragraphId,y.offset))return ke(c,{start:y,end:y},A,P);let v=S(c,y.paragraphId);return v||{ok:true,kind:"command",ops:Vt(y.paragraphId,y.offset,A),story:c.reads.story,answer:()=>({kind:"span",span:V({start:y,end:{...y,offset:y.offset+A.length}})})}},be=(c,y,A)=>{let P=c.reads;if(typeof A!="string")return b("unsupported-content","replaceSpan needs text","text");if(ut.test(A))return b("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let w=Re(y,P),M=y.start.paragraphId,l=[],g=w.length===1?y.end.offset:y.start.offset,v=ct(P.part,M,y.start.offset,g,A);if(v)return v;let C=f(c);if(C)return C;let T=w.length===1?y.end.offset:(P.rawText(M)??"").length,j=e.replacementLanding?.(M,y.start.offset,T);if(w.length===1&&j==null&&or(P.part,M,y.start.offset))return ke(c,y,A);if(w.length===1){let ae=S(c,M);if(ae)return ae;if(j==null)return is(P.part,y,A,o);y.end.offset>y.start.offset&&l.push({op:"deleteText",paragraphId:M,start:y.start.offset,end:y.end.offset});}else {for(let ne of w){let re=S(c,ne);if(re)return re}let ae=y.end.paragraphId,U=(P.rawText(M)??"").length;y.start.offset<U&&l.push({op:"deleteText",paragraphId:M,start:y.start.offset,end:U}),y.end.offset>0&&l.push({op:"deleteText",paragraphId:ae,start:0,end:y.end.offset});for(let ne of w.slice(1,-1))l.push({op:"deleteBlock",blockId:ne});l.push({op:"joinParagraphs",firstId:M,secondId:ae});for(let ne of w.slice(1)){let re=c.slotById.get(ne);re&&c.order.splice(D(c,re),1);}}let W=j??y.start.offset;l.push(...Vt(M,W,A));let te={...y.start,paragraphId:M,offset:W},Q=()=>({kind:"span",span:V({start:te,end:{...te,offset:te.offset+A.length}})});return {ok:true,kind:"command",ops:l,story:c.reads.story,answer:Q}},he=(c,y)=>{let A=c.reads;if(typeof y!="string")return b("unsupported-content","replaceSpan needs text","text");if(ut.test(y))return b("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let P=A.blocks,w=P.filter(U=>U.removable),M=P.filter(U=>!U.removable).flatMap(U=>U.paragraphIds),l=M.length===0?w.find(U=>U.kind==="paragraph"):void 0;if(!l&&M.length===0)return b("invalid-offset","that story holds no paragraph this host can write into","no-top-level-paragraph");let g=f(c);if(g)return g;for(let U of A.paragraphIds){let ne=S(c,U);if(ne)return ne}let v=[],C=(l?[l.id]:[...M]).sort((U,ne)=>A.indexOf(U)-A.indexOf(ne)),T=C[0],j=(A.rawText(T)??"").length;for(let U of C){let ne=(A.rawText(U)??"").length;ne>0&&v.push({op:"deleteText",paragraphId:U,start:0,end:ne});}for(let U of w)U.id!==l?.id&&v.push({op:"deleteBlock",blockId:U.id});let W=e.replacementLanding?.(T,0,j)??0,te=ct(A.part,T,0,j,y);if(te)return te;v.push(...Vt(T,W,y));for(let U of w)if(U.id!==l?.id)for(let ne of U.paragraphIds){let re=c.slotById.get(ne);re&&c.order.splice(D(c,re),1);}let Q={story:A.story,paragraphId:T,index:A.indexOf(T),offset:W},ae=()=>({kind:"span",span:V({start:Q,end:{...Q,offset:W+y.length}})});return {ok:true,kind:"command",ops:v,story:A.story,answer:ae}},xe=(c,y)=>{if(!Array.isArray(y)||y.length<1||y.length>1e4||y.some(P=>typeof P!="string"||ut.test(P))||!chunkWO4V6PNS_cjs.wh(y))return b("unsupported-content","replaceStoryBlocks needs 1-10000 valid XML text strings without paragraph marks","paragraphs");let A=f(c);if(A)return A;for(let P of c.reads.paragraphIds){let w=S(c,P);if(w)return w}c.order.splice(0,c.order.length);for(let P=0;P<y.length;P+=1)$(c,P);return {ok:true,kind:"command",ops:[{op:"replaceStoryBlocks",storyRootId:c.reads.root.id,paragraphs:y}],story:c.reads.story,answer:()=>de}},ve=(c,y,A,P)=>{let w=c.reads;if(typeof P!="string")return b("unsupported-content","insertParagraph needs text","text");if(ut.test(P))return b("unsupported-content","a paragraph mark inside a paragraph\u2019s text is not written by this host","paragraph-mark-in-text");let M=f(c);if(M)return M;let l=S(c,y.paragraphId);if(l)return l;let g=c.slotById.get(y.paragraphId);if(!g)return b("invalid-handle","that paragraph is not in the body");let v=(w.rawText(y.paragraphId)??"").length,C=A==="after"?v:0,T=ct(w.part,y.paragraphId,C,C,P);if(T)return T;let j=[];A==="after"?(j.push(...Vt(y.paragraphId,v,P)),j.push({op:"splitParagraph",paragraphId:y.paragraphId,offset:v})):(j.push(...Vt(y.paragraphId,0,P)),j.push({op:"splitParagraph",paragraphId:y.paragraphId,offset:P.length}));let W=$(c,D(c,g)+1);A==="before"&&c.retargets.push({from:y.paragraphId,slot:W});let te=()=>{let Q=A==="after"?W.id:y.paragraphId;return Q===null?de:{kind:"handle",handle:o.paragraph(Q,w.story)}};return {ok:true,kind:"command",ops:j,story:w.story,answer:te}},Xe=(c,y,A,P,w)=>{let M=c.reads;if(!Array.isArray(A)||A.length===0)return b("unsupported-content","split needs at least one delimiter","delimiters");if(A.length>lc)return b("unsupported-content","too many delimiters",String(A.length));for(let U of A){if(typeof U!="string"||U.length===0)return b("unsupported-content","a delimiter must be a non-empty string","delimiters");if(U.length>dc)return b("unsupported-content","that delimiter is too long","delimiters")}let l=f(c);if(l)return l;let g=S(c,y.paragraphId);if(g)return g;let v=c.slotById.get(y.paragraphId);if(!v)return b("invalid-handle","that paragraph is not in the body");let{text:C,occurrences:T}=ls(M,y.paragraphId,A),j=[],W=[],te=[];if(T.length===0)te.push(C);else if(P){for(let re of [...T].reverse())j.push({op:"deleteText",paragraphId:y.paragraphId,start:re.start,end:re.start+re.length});let U=0,ne=0;for(let re of T){let Oo=re.start-U;W.push(Oo),te.push(C.slice(ne,re.start)),ne=re.start+re.length,U+=re.length;}te.push(C.slice(ne));}else {let U=0;for(let ne of T){let re=ne.start+ne.length;W.push(re),te.push(C.slice(U,re)),U=re;}te.push(C.slice(U));}W.length>0&&j.push({op:"splitParagraphMany",paragraphId:y.paragraphId,offsets:W});let Q=[v];for(let U=0;U<W.length;U+=1)Q.push($(c,D(c,v)+1+U));let ae=U=>{let ne=U.story(M.story),re=[];return Q.forEach((Oo,kd)=>{let Po=Oo.id;if(Po===null)return;let Io=ne?.rawText(Po)??te[kd]??"",[bd,xd]=w?cs(Io,0,Io.length):[0,Io.length],Tr=o.paragraph(Po,M.story);re.push({start:{paragraph:Tr,offset:bd},end:{paragraph:Tr,offset:xd}});}),{kind:"spans",spans:re}};return {ok:true,kind:"command",ops:j,story:M.story,answer:ae}},Ye=(c,y)=>{let A=f(c);if(A)return A;let P=S(c,y.paragraphId);if(P)return P;let w=c.slotById.get(y.paragraphId);return w&&c.order.splice(D(c,w),1),{ok:true,kind:"command",ops:[{op:"deleteBlock",blockId:y.paragraphId}],story:c.reads.story,answer:()=>de}},L=(c,y,A)=>{let P=c.reads,w=P.part,M=f(c);if(M)return M;let l=yl(A??{});if(!l.ok)return b("unsupported-content","that is not formatting this host writes",l.detail);let g=[];for(let v of bt(y,P)){if(v.end<=v.start&&!v.whole)continue;let C=Y(c,v.paragraphId,"runs");if(C)return C;for(let T of t(w,v.paragraphId,v.start,v.end,l.value.filter(j=>j.localName!=="vertAlign"),e.displayMode))g.push({op:"setRunProperties",paragraphId:v.paragraphId,start:T.start,end:T.end,properties:fr(T.properties,A),...T.targetRunIds?{targetRunIds:T.targetRunIds}:{}});v.whole&&g.push({op:"setParagraphMarkProperties",paragraphId:v.paragraphId,properties:fr(n(w,v.paragraphId,l.value.filter(T=>T.localName!=="vertAlign")),A)});}return g.length===0?b("invalid-offset","that range covers no characters to format","collapsed-range"):{ok:true,kind:"command",ops:g,story:P.story,answer:()=>de}},q=(c,y,A)=>{let P=c.reads,w=P.part,M=f(c);if(M)return M;let l=Qn(A,P.styles());if(!l.ok)return b("unsupported-content","that is not a style this document has",l.detail);let g={localName:"pStyle",attributes:{val:l.styleId}},v=[];for(let C of Re(y,P)){let T=Y(c,C,"paragraph");if(T)return T;v.push({op:"setParagraphProperties",paragraphId:C,properties:chunkWO4V6PNS_cjs.Ph(chunkWO4V6PNS_cjs.Nh(w,C),g)});}return v.length===0?b("invalid-offset","that story holds no paragraph to style","empty-story"):{ok:true,kind:"command",ops:v,story:P.story,answer:()=>de}},Ae=(c,y,A)=>{let P=c.reads,w=P.part,M=f(c);if(M)return M;let l=kl(w,y.paragraphId,A??{},P.styles());if(!l.ok)return b("unsupported-content","that is not paragraph formatting this host writes",l.detail);let g=Y(c,y.paragraphId,"paragraph");return g||{ok:true,kind:"command",ops:l.unchanged?[]:[{op:"setParagraphProperties",paragraphId:y.paragraphId,properties:l.value}],story:P.story,answer:()=>de}},oe=(c,y)=>{let A=a.body;if(!A)return b("document-unavailable","this host holds no document right now");let P=a.sections();if(!P[c])return b("invalid-handle","that section is not in this document");let M=bi(y);if(!M.ok)return b("unsupported-content",M.reason,M.detail);let l=ds(A,P,c);if(l===null)return b("unsupported-content","that section holds no paragraph to address it by","no-anchor");let g=d(A),v=f(g);return v||{ok:true,kind:"command",ops:[{op:"setSectionProperties",...M.value,anchorParagraphId:l}],story:Se,answer:()=>de}},Ce=(c,y)=>({ok:true,kind:"command",ops:[{op:"deleteNote",noteKind:c,noteId:y}],story:Se,lifecycle:true,answer:()=>de}),Ct=c=>{let y=o.resolve(c,"list");if(!y||y.kind!=="list")return b("invalid-handle","that handle does not name a list","list");let A=a.story(y.story);if(!A)return b("invalid-handle","that story is not in this document");let P=Ot(A).find(w=>w.numId===y.numId);return P?{ok:true,plan:d(A),list:P}:gn("this story numbers nothing with that list")},Je=c=>{if(typeof c!="object"||c===null)return b("invalid-handle","that is not a scope a control lives in","scope");let y=c;if("body"in c){let A=le(y.body,"body",o,a);return A.ok?{reads:A.value,node:A.value.root}:b(A.code,"that handle does not name a body",A.detail)}if("contentControl"in c){let A=_e(y.contentControl);return "control"in A?{reads:A.reads,node:A.node}:A}return b("invalid-handle","that is not a scope a control lives in","scope")},_e=c=>{let y=o.resolve(c,"contentControl");if(!y||y.kind!=="contentControl")return b("invalid-handle","that handle does not name a content control","contentControl");let A=a.story(y.story);if(!A)return b("invalid-handle","that story is not in this document");let P=jl(A,y.nodeId),w=_l(A,y.nodeId);return !P||!w?gn("this document no longer holds that content control"):{reads:A,control:P,node:w}},gd=(c,y,A)=>{if(!Number.isInteger(A)||A<0||A>$t)return b("invalid-offset",`a list level is 0 to ${String($t)}`,String(A));let P=fn(c.reads,y);if(!P)return b("unsupported-content","that paragraph is not in a list",y);if(!a.package||!mn(a.package,P.numId,A))return b("unsupported-content","list level is not defined; configure that level first",y);let w=f(c);if(w)return w;let M=Y(c,y,"paragraph");return M||{ok:true,kind:"command",ops:[{op:"setListLevel",paragraphId:y,level:A}],story:c.reads.story,answer:()=>de}},hd=(c,y,A,P)=>{if(A!=="start"&&A!=="end")return b("unknown-operation","a list takes an item at its start or its end",String(A));let w=c.reads,M=A==="start"?y.paragraphIds[0]:y.paragraphIds[y.paragraphIds.length-1];if(M===void 0)return b("invalid-handle","that list holds no paragraph");let l={story:w.story,paragraphId:M,index:w.indexOf(M)};return ve(c,l,A==="start"?"before":"after",P)},Ir=(c,y)=>{if(y.start.paragraphId!==y.end.paragraphId)return null;for(let A of Hi(c,y.start.paragraphId))if(A.start<=y.start.offset&&A.end>=y.end.offset)return A;return null},yd=(c,y,A)=>{if(typeof A!="string")return b("unsupported-content","a hyperlink target is a string","target");let P=c.reads,w=Ir(P,y),M=y.start.paragraphId===y.end.paragraphId&&y.start.offset===y.end.offset,l=w&&(y.start.offset!==w.start||y.end.offset!==w.end),g=l?{range:{start:y.start.offset,end:y.end.offset}}:{};if(l){let Q=P.node(w.paragraphId),ae=Q?.kind==="paragraph"?Q.children.find(U=>U.id===w.id):void 0;if(M||!ae||!chunkWO4V6PNS_cjs.gj(ae)||Q?.kind!=="paragraph"||!Q.children.some(U=>U.id===w.id))return b("unsupported-capability","partial hyperlink edits require ordinary text in a paragraph")}if(A.length===0){if(!w)return b("unsupported-content","that text is not a link","no-link");let Q=f(c);if(Q)return Q;let ae=F(c,w.paragraphId);return ae||{ok:true,kind:"command",ops:[{op:"removeHyperlink",linkId:w.id,...g}],story:P.story,answer:()=>de}}let v={},C=null;if(A.startsWith("#")){let Q=A.slice(1);if(Q.length===0||!to(P,Q))return b("unsupported-content","this document declares no such bookmark",A);v={anchor:Q};}else {if(chunkWO4V6PNS_cjs.Og(A)===null)return b("unsupported-content","this engine will not author that target","target");C=A;}let T=f(c);if(T)return T;let j=Q=>C===null?{ok:true,kind:"command",ops:[Q(v)],story:P.story,answer:()=>de}:{ok:true,kind:"command",ops:[],relate:{url:C,ops:ae=>[Q({relationshipId:ae})]},story:P.story,answer:()=>de};if(w){let Q=F(c,w.paragraphId);return Q||j(ae=>({op:"setHyperlinkTarget",linkId:w.id,...g,...ae}))}if(M)return b("unsupported-content","a link with no text has nothing to click","collapsed");if(y.start.paragraphId!==y.end.paragraphId)return b("unsupported-content","a link lives inside one paragraph","crosses-paragraph-mark");let W=F(c,y.start.paragraphId);if(W)return W;let te=P.styles().idOf("hyperlink");return j(Q=>({op:"insertHyperlink",paragraphId:y.start.paragraphId,start:y.start.offset,end:y.end.offset,...Q,...te===null?{}:{styleId:te}}))},Sr=(c,y,A)=>{let P=c.reads;if(!r.selection||!e.select)return b("unsupported-capability","this host has no reader to move","selection");if(A!=="select"&&A!=="start"&&A!=="end")return b("unknown-operation","that is not a selection mode",String(A));let w=e.selectRefusal?.(P.story,y.start.paragraphId);if(w)return b("unsupported-capability",w,"selection");let M=Re(y,P);for(let l of M)if(c.touched.has(l))return b("conflicting-operations","this batch edits a paragraph the selection covers",l);for(let l of M)c.selected.add(l);return u.push({range:y,mode:A}),{ok:true,kind:"query",value:de}},wr=c=>$i(c,o,a),Cr=(c,y)=>{let A=nl(c,l=>Cr(l,y));if(A)return A;let P=Ts(c,e,l=>br({...e,reads:l}));if(P)return y&&P.ok&&P.kind==="command"?b("unsupported-content","header/footer creation cannot be tracked"):P;let w=ws(c,{trackingAuthor:y,trackedRangeReplacement:e.trackedRangeReplacement,handles:o,reads:a,admitWrite:(l,g,v)=>{let C=d(l),T=f(C);if(T)return T;for(let j of v){let W=S(C,j);if(W)return W}return C.externalCreatedCount+=g,null}});if(w)return w;let M=y!==void 0;if(M){let l=Sl(c,y,o,a);if("ok"in l)return l;c=l;}switch(c.op){case "getFields":case "getField":case "setFieldCode":case "deleteField":case "updateFieldResult":case "insertField":return Ps(c,o,a,(l,g,v)=>{let C=d(l);return f(C)??(v?null:S(C,g))},e.fieldPageContext);case "getShapes":case "getShape":case "getShapeBody":return Mi(c,o,a);case "getInlinePictures":case "getInlinePicture":case "setInlinePicture":case "deleteInlinePicture":case "insertInlinePicture":return Bs(c,o,a,(l,g)=>{let v=d(l);return f(v)??S(v,g)});case "getBookmarks":case "getBookmarkName":case "getBookmarkNames":case "getBookmarkRangeByName":case "insertBookmark":case "deleteBookmark":return Ki(c,o,a,{admit:Ui(d,f,S),pinned:()=>h?.reads.story??null});case "insertBreak":return tl(c,o,a,(l,g,v)=>{let C=d(l),T=f(C)??S(C,g);return T||(C.externalCreatedCount+=v),T});case "startNewList":case "attachToList":case "detachFromList":case "setListLevelFormat":return sl(c,o,a,(l,g,v)=>{let C=d(l);return f(C)??Y(C,g,v?`list:${v.numId}:${v.level}`:"paragraph")},y);case "removeDocumentInformation":case "getDocumentProperty":case "setDocumentProperties":return Ji(c,a,()=>f(d(a.body)),!e.collaborative);case "getDocument":return _({kind:"handle",handle:o.document()});case "getBody":return o.resolve(c.document,"document")?a.body?_({kind:"handle",handle:o.body(Se)}):b("document-unavailable","this host holds no document right now"):b("invalid-handle","that handle does not name a document","document");case "getParagraphs":{let l=le(c.body,"body",o,a);return l.ok?_({kind:"handles",handles:l.value.paragraphIds.map(g=>o.paragraph(g,l.value.story))}):b(l.code,"that handle does not name a body",l.detail)}case "getRange":{let l=G(c.span,o,a);if(!l.ok)return b(l.code,"that span is not a place",l.detail);if(!l.value)return b("invalid-offset","empty story");if(!["Whole","Content","Start","End"].includes(c.location))return b("unsupported-content","unsupported range location");let g=l.value,v=c.location==="Start"?{start:g.start,end:g.start}:c.location==="End"?{start:g.end,end:g.end}:g;return _({kind:"span",span:we(v,o)})}case "getSpanParagraphs":{let l=G(c.span,o,a);if(!l.ok)return b(l.code,"that span is not a place",l.detail);let g=Z(c.span,o,a);return g.ok?_({kind:"handles",handles:Re(l.value,g.value).map(v=>o.paragraph(v,g.value.story))}):b(g.code,"that span is not a place",g.detail)}case "getText":{if(!se(c.projection))return b("unsupported-content","unknown text projection","projection");if(o.resolve(c.target,"body")){let C=le(c.target,"body",o,a);return C.ok?_({kind:"text",text:C.value.text(c.projection??"allMarkup")}):b(C.code,"that handle does not name a body",C.detail)}let g=pe(c.target,o,a);if(!g.ok)return b(g.code,"that handle does not name a body or a paragraph",g.detail);let v=a.story(g.value.story);return _({kind:"text",text:v?.paragraphText(g.value.paragraphId,c.projection??"allMarkup")??""})}case "getSpanText":{if(!se(c.projection))return b("unsupported-content","unknown text projection","projection");let l=G(c.span,o,a);if(!l.ok)return b(l.code,"that span is not a place",l.detail);let g=Z(c.span,o,a);return g.ok?_({kind:"text",text:Li(l.value,g.value,zo,c.projection??"allMarkup")}):b(g.code,"that span is not a place",g.detail)}case "getParagraphId":{let l=pe(c.paragraph,o,a);if(!l.ok)return b(l.code,"that handle does not name a paragraph",l.detail);let v=a.story(l.value.story)?.paragraph(l.value.paragraphId);return _({kind:"text",text:v?.paraId??""})}case "search":{let l=G(c.scope,o,a);if(!l.ok)return b(l.code,"that is not a scope to search",l.detail);let g=Z(c.scope,o,a);return g.ok?K(g.value,l.value,c.text,c.options):b(g.code,"that is not a scope to search",g.detail)}case "proposeInsertion":case "proposeDeletion":case "proposeReplacement":return wl(c,M,o,a,(l,g)=>{let v=d(l);return f(v)??S(v,g)},e.trackedRangeReplacement!==false,e.collaborative===true);case "insertText":{let l=Ft(c.at,o,a);if(!l.ok)return b(l.code,"that is not a place to insert at",l.detail);let g=a.story(l.value.story);return g?ce(d(g),l.value,c.text,"at"in c.at&&c.at.at==="start"):b("invalid-handle","that story is not in this document")}case "replaceSpan":{if("body"in c.span){let v=le(c.span.body,"body",o,a);return v.ok?he(d(v.value),c.text):b(v.code,"that handle does not name a body",v.detail)}let l=G(c.span,o,a);if(!l.ok)return b(l.code,"that span is not a place",l.detail);if(!l.value)return b("invalid-offset","that story holds no paragraph to write into","empty-story");let g=J(l.value);return g?Wi(be(d(g),l.value,c.text),g,l.value,e.replacementLanding?.(l.value.start.paragraphId,0,0)!=null):b("invalid-handle","that story is not in this document")}case "replaceStoryBlocks":{let l=le(c.body,"body",o,a);return l.ok?xe(d(l.value),c.paragraphs):b(l.code,"that handle does not name a body",l.detail)}case "insertParagraph":{let l=eo(c.anchor,o,a);if(!l.ok)return b(l.code,"that is not a paragraph to insert beside",l.detail);if(c.where!=="before"&&c.where!=="after")return b("unknown-operation","that is not a place to insert",String(c.where));let g=a.story(l.value.story);if(!g)return b("invalid-handle","that story is not in this document");let v=M&&Cl(g,l.value.paragraphId,y);return v?{ok:false,error:v}:ve(d(g),l.value,c.where,c.text)}case "splitParagraph":{let l=pe(c.paragraph,o,a);if(!l.ok)return b(l.code,"that handle does not name a paragraph",l.detail);let g=a.story(l.value.story);return g?Xe(d(g),l.value,c.delimiters,c.trimDelimiters===true,c.trimSpacing===true):b("invalid-handle","that story is not in this document")}case "getFont":{let l=G(c.span,o,a);if(!l.ok)return b(l.code,"that span is not a place",l.detail);let g=Z(c.span,o,a);if(!g.ok)return b(g.code,"that span is not a place",g.detail);let v=bt(l.value,g.value);return _({kind:"font",font:fl(g.value.part,v,e.displayMode)})}case "setFont":{let l=G(c.span,o,a);if(!l.ok)return b(l.code,"that span is not a place",l.detail);if(!l.value)return b("invalid-offset","that story holds no paragraph to format","empty-story");let g=J(l.value);return g?L(d(g),l.value,c.font):b("invalid-handle","that story is not in this document")}case "getStyle":{let l=G(c.span,o,a);if(!l.ok)return b(l.code,"that span is not a place",l.detail);let g=Z(c.span,o,a);if(!g.ok)return b(g.code,"that span is not a place",g.detail);let v=g.value.part,C=g.value.styles(),T=Re(l.value,g.value).map(W=>Jn(v,W,C)),j=T.length>0&&T.every(W=>W!==null&&W===T[0])?T[0]:null;return _({kind:"style",name:j})}case "setStyle":{let l=G(c.span,o,a);if(!l.ok)return b(l.code,"that span is not a place",l.detail);if(!l.value)return b("invalid-offset","that story holds no paragraph to style","empty-story");let g=J(l.value);return g?q(d(g),l.value,c.name):b("invalid-handle","that story is not in this document")}case "getParagraphFormat":{let l=eo(c.paragraph,o,a);if(!l.ok)return b(l.code,"that is not a paragraph",l.detail);let g=a.story(l.value.story);if(!g)return b("document-unavailable","this host holds no document right now");let v=hl(g.part,l.value.paragraphId,g.styles());return v?_({kind:"paragraphFormat",format:v}):b("invalid-handle","that handle does not name a paragraph")}case "setParagraphFormat":{let l=eo(c.paragraph,o,a);if(!l.ok)return b(l.code,"that is not a paragraph",l.detail);let g=a.story(l.value.story);return g?Ae(d(g),l.value,c.format):b("invalid-handle","that story is not in this document")}case "deleteParagraph":{let l=pe(c.paragraph,o,a);if(!l.ok)return b(l.code,"that handle does not name a paragraph",l.detail);let g=a.story(l.value.story);return g?Ye(d(g),l.value):b("invalid-handle","that story is not in this document")}case "getSections":return o.resolve(c.document,"document")?_({kind:"handles",handles:a.sections().map(l=>o.section(l.index))}):b("invalid-handle","that handle does not name a document","document");case "getPageSetup":{let l=o.resolve(c.section,"section");if(!l||l.kind!=="section")return b("invalid-handle","that handle does not name a section","section");let g=a.sections()[l.index];return g?_({kind:"pageSetup",setup:g.pageSetup}):b("invalid-handle","that section is not in this document")}case "setPageSetup":{let l=o.resolve(c.section,"section");return !l||l.kind!=="section"?b("invalid-handle","that handle does not name a section","section"):oe(l.index,c.setup)}case "getFurniture":{let l=o.resolve(c.section,"section");if(!l||l.kind!=="section")return b("invalid-handle","that handle does not name a section","section");if(c.kind!=="header"&&c.kind!=="footer")return b("unknown-operation","that is not furniture",String(c.kind));let g={kind:c.kind,sectionIndex:l.index,variant:c.variant};return Uo(g)?a.sections()[l.index]?_({kind:"handle",handle:o.body(g)}):gn("that section no longer exists"):b("unknown-operation","that is not a furniture variant",String(c.variant))}case "getNotes":{if(!o.resolve(c.document,"document"))return b("invalid-handle","that handle does not name a document","document");if(c.noteKind!=="footnote"&&c.noteKind!=="endnote")return b("unknown-operation","that is not a kind of note",String(c.noteKind));let l=c.noteKind,g=a.noteIds(l);if(!g.ok)return b("ambiguous-document",`${l} identities are not completely and unambiguously enumerable`,g.reason==="duplicates"?g.duplicateIds.join(","):g.reason);let v=g.ids;if(c.scope){let C=le(c.scope,"body",o,a);if(!C.ok)return b(C.code,"that handle does not name a body",C.detail);let T=Qi(C.value.root,l),j=new Set(g.ids);if(T.some(W=>!j.has(W)))return b("ambiguous-document","a note reference has no matching note");v=T;}return _({kind:"handles",handles:v.map(C=>o.note(l,C))})}case "getNoteBody":case "getNoteText":{let l=o.resolve(c.note,"note");if(!l||l.kind!=="note")return b("invalid-handle","that handle does not name a note","note");let g=l,v=a.story(g);return v?c.op==="getNoteText"?_({kind:"text",text:v.text(c.projection)}):_({kind:"handle",handle:o.body(g)}):b("invalid-handle","that note is not in this document",z(g))}case "getNoteKind":{let l=o.resolve(c.note,"note");return !l||l.kind!=="note"?b("invalid-handle","that handle does not name a note","note"):_({kind:"text",text:l.noteKind})}case "deleteNote":{let l=o.resolve(c.note,"note");if(!l||l.kind!=="note")return b("invalid-handle","that handle does not name a note","note");let g=a.noteIds(l.noteKind);return g.ok?g.ids.includes(l.noteId)?Ce(l.noteKind,l.noteId):b("invalid-handle","that note is not in this document"):b("ambiguous-document",`${l.noteKind} identities are not completely and unambiguously enumerable`,g.reason==="duplicates"?g.duplicateIds.join(","):g.reason)}case "getLists":{let l=le(c.body,"body",o,a);return l.ok?_({kind:"handles",handles:Ot(l.value).map(g=>o.list(g.numId,l.value.story))}):b(l.code,"that handle does not name a body",l.detail)}case "getListId":{let l=Ct(c.list);return "list"in l?_({kind:"number",value:Number(l.list.numId)}):l}case "getListById":{let l=le(c.body,"body",o,a);if(!l.ok)return b(l.code,"that handle does not name a body",l.detail);if(!Number.isInteger(c.id)||c.id<=0)return b("unsupported-content","a list is numbered from one",String(c.id));let g=String(c.id),v=Ot(l.value).find(C=>C.numId===g);return v?_({kind:"handle",handle:o.list(v.numId,l.value.story)}):b("invalid-handle","no list in that story carries that number",g)}case "getListParagraphs":{let l=Ct(c.list);if(!("list"in l))return l;let g=c.level;if(g!==void 0&&(!Number.isInteger(g)||g<0||g>$t))return b("invalid-offset",`a list level is 0 to ${String($t)}`,String(g));let v=l.plan.reads,C=g===void 0?l.list.paragraphIds:l.list.paragraphIds.filter(T=>fn(v,T)?.level===g);return _({kind:"handles",handles:C.map(T=>o.paragraph(T,v.story))})}case "getParagraphList":{let l=pe(c.paragraph,o,a);if(!l.ok)return b(l.code,"that handle does not name a paragraph",l.detail);let g=a.story(l.value.story);if(!g)return b("invalid-handle","that story is not in this document");let v=fn(g,l.value.paragraphId);return v?_({kind:"handle",handle:o.list(v.numId,g.story)}):b("unsupported-content","that paragraph is not in a list",l.value.paragraphId)}case "getListLevel":{let l=pe(c.paragraph,o,a);if(!l.ok)return b(l.code,"that handle does not name a paragraph",l.detail);let g=a.story(l.value.story);if(!g)return b("invalid-handle","that story is not in this document");let v=fn(g,l.value.paragraphId);return v?_({kind:"number",value:v.level}):b("unsupported-content","that paragraph is not in a list",l.value.paragraphId)}case "setListLevel":{let l=pe(c.paragraph,o,a);if(!l.ok)return b(l.code,"that handle does not name a paragraph",l.detail);let g=a.story(l.value.story);return g?gd(d(g),l.value.paragraphId,c.level):b("invalid-handle","that story is not in this document")}case "insertListParagraph":{let l=Ct(c.list);return "list"in l?hd(l.plan,l.list,c.where,c.text):l}case "getHyperlink":{let l=G(c.span,o,a);if(!l.ok)return b(l.code,"that span is not a place",l.detail);let g=Z(c.span,o,a);if(!g.ok)return b(g.code,"that span is not a place",g.detail);let v=a.package;if(!v||!l.value)return _({kind:"text",text:""});let C=Ir(g.value,l.value);if(!C)return _({kind:"text",text:""});let T=chunkWO4V6PNS_cjs.Ta(g.value.part,C.id),j=T?Fi(v,g.value.part.name,T):null;return _({kind:"text",text:j??""})}case "setHyperlink":{let l=G(c.span,o,a);if(!l.ok)return b(l.code,"that span is not a place",l.detail);if(!l.value)return b("invalid-offset","that story holds no text to link","empty-story");let g=J(l.value);return g?yd(d(g),l.value,c.target):b("invalid-handle","that story is not in this document")}case "getBookmarkRange":{let l=wr(c.bookmark);return "reads"in l?_({kind:"span",span:V(l.range)}):l}case "getComments":{let l=G(c.scope,o,a);if(!l.ok)return b(l.code,"that scope is not a place",l.detail);let g=Z(c.scope,o,a);if(!g.ok)return b(g.code,"that scope names no story",g.detail);let v=g.value,C=I(v);if(!C)return b("document-unavailable","this host holds no document");let T=l.value,j=C.roots.filter(W=>{if(!T)return true;let te=W.range;if(!te)return false;let Q=v.indexOf(te.start.paragraphId),ae=v.indexOf(te.end.paragraphId),U=v.indexOf(T.start.paragraphId),ne=v.indexOf(T.end.paragraphId);return ae<U||Q>ne?false:ae===U&&Q===U&&ne===U?te.end.offset>T.start.offset&&te.start.offset<T.end.offset:true});return _({kind:"handles",handles:j.map(W=>o.comment(W.id,v.story))})}case "getCommentReplies":{let l=R(c.comment);return l.ok?_({kind:"handles",handles:l.item.replyIds.map(g=>o.comment(g,l.reads.story))}):l.planned}case "getCommentId":{let l=R(c.comment);return l.ok?_({kind:"text",text:l.item.id}):l.planned}case "getCommentAuthor":{let l=R(c.comment);return l.ok?_({kind:"text",text:l.item.comment.author}):l.planned}case "getCommentDate":{let l=R(c.comment);return l.ok?_({kind:"text",text:l.item.comment.date??""}):l.planned}case "getCommentText":{let l=R(c.comment);if(!l.ok)return l.planned;let g=I(l.reads);return _({kind:"text",text:g?.textOf(l.item.id)??""})}case "getCommentRange":{let l=R(c.comment);if(!l.ok)return l.planned;let g=l.item.range;if(!g||l.item.orphaned)return b("invalid-handle","that comment has no range in this document");let v=E(l.reads,g);return v?_({kind:"span",span:v}):b("invalid-handle","that comment\u2019s range is no longer in the story")}case "getCommentResolved":{let l=R(c.comment);return l.ok?_({kind:"flag",value:l.item.resolved}):l.planned}case "insertComment":return Bl(c,o,a,k);case "setCommentResolved":{let l=R(c.comment);if(!l.ok)return l.planned;if(typeof c.resolved!="boolean")return b("unsupported-content","resolved is a yes or a no",String(c.resolved));let g=f(d(l.reads));return g||{ok:true,kind:"commentWrite",write:{kind:"resolve",commentId:l.item.id,resolved:c.resolved},story:l.reads.story,answer:()=>de}}case "replyToComment":{let l=R(c.comment);if(!l.ok)return l.planned;let g=yr({author:c.author,text:c.text,date:c.date,kind:"reply"});if(g)return g;let v=l.item.range;if(!v||l.item.orphaned)return b("invalid-handle","that comment has no range to reply over");let C=f(d(l.reads));if(C)return C;let T=l.reads.story,j=kr(c.date);return {ok:true,kind:"commentWrite",write:{kind:"reply",parentCommentId:l.item.id,anchor:{paragraphId:v.start.paragraphId,start:v.start.offset,end:v.end.offset,...v.end.paragraphId===v.start.paragraphId?{}:{endParagraphId:v.end.paragraphId}},text:c.text,author:c.author,date:j},story:l.reads.story,answer:(W,te)=>te===void 0?de:{kind:"handle",handle:o.comment(te,T)}}}case "deleteComment":{let l=R(c.comment);return l.ok?Hl(l.item,l.reads,g=>f(d(g))):l.planned}case "getRevisions":return qs(c,o,a);case "getReviewItemRange":return Zs(c.key,o,a);case "getRevisionType":{let l=N(c.revision);return l.ok?_({kind:"text",text:l.item.type}):l.planned}case "getRevisionAuthor":{let l=N(c.revision);return l.ok?_({kind:"text",text:l.item.author}):l.planned}case "getRevisionDate":{let l=N(c.revision);return l.ok?_({kind:"text",text:l.item.date}):l.planned}case "getRevisionRange":{let l=N(c.revision);if(!l.ok)return l.planned;let[g]=l.item.item.ranges;if(!g)return b("invalid-handle","that change covers no characters");let v=E(l.reads,g);return v?_({kind:"span",span:v}):b("invalid-handle","that change\u2019s range is no longer in the story")}case "acceptRevision":case "rejectRevision":{let l=N(c.revision);if(!l.ok)return l.planned;let g=c.op==="acceptRevision"?"accept":"reject";return ir(l.reads,[l.item.item],g,O,x)}case "resolveRevisionBatch":case "setRevisionAuthorBatch":case "acceptAllRevisions":case "rejectAllRevisions":return El(c,o,a,x,O);case "selectSpan":{let l=G(c.span,o,a);if(!l.ok)return b(l.code,"that span is not a place",l.detail);if(!l.value)return b("invalid-offset","that story holds no paragraph to select","empty-story");let g=J(l.value);return g?Sr(d(g),l.value,c.mode):b("invalid-handle","that story is not in this document")}case "selectBookmark":{let l=wr(c.bookmark);return "reads"in l?Sr(d(l.reads),l.range,c.mode):l}case "getContentControls":{let l=Je(c.scope);return "reads"in l?_({kind:"handles",handles:Fl(l.reads,l.node).map(g=>o.contentControl(g.nodeId,l.reads.story))}):l}case "getContentControlById":{let l=Je(c.scope);if(!("reads"in l))return l;if(!Number.isInteger(c.id))return b("unsupported-content","a control id is a whole number",String(c.id));let g=Ut(l.node).find(v=>chunkWO4V6PNS_cjs.Zb(v).id===c.id);return g?_({kind:"handle",handle:o.contentControl(g.id,l.reads.story)}):b("invalid-handle","no control in that scope carries that id",String(c.id))}case "getContentControlsByTag":case "getContentControlsByTitle":{let l=Je(c.scope);if(!("reads"in l))return l;let g=c.op==="getContentControlsByTag"?c.tag:c.title;if(typeof g!="string"||g.length===0)return b("unsupported-content","a tag or title to match is required",c.op);let v=Ut(l.node).filter(C=>{let T=chunkWO4V6PNS_cjs.Zb(C);return c.op==="getContentControlsByTag"?T.tag===g:T.alias===g});return _({kind:"handles",handles:v.map(C=>o.contentControl(C.id,l.reads.story))})}case "getContentControlTag":case "getContentControlTitle":case "getContentControlFileId":case "getContentControlSubtype":case "getContentControlLock":{let l=_e(c.contentControl);if(!("control"in l))return l;let g=l.control.properties;if(c.op==="getContentControlLock")return _({kind:"text",text:l.control.lock});if(c.op==="getContentControlSubtype")return _({kind:"text",text:g.type});if(c.op==="getContentControlFileId")return _({kind:"text",text:g.id===void 0?"":String(g.id)});let v=c.op==="getContentControlTag"?g.tag:g.alias;return _({kind:"text",text:v??""})}case "getContentControlIsBound":case "getContentControlPlaceholderShown":case "getContentControlTemporary":{let l=_e(c.contentControl);if(!("control"in l))return l;let g=c.op==="getContentControlIsBound"?l.control.properties.dataBinding!==void 0:c.op==="getContentControlPlaceholderShown"?l.control.properties.showingPlaceholder:l.control.properties.temporary;return _({kind:"flag",value:g})}case "getContentControlText":{let l=_e(c.contentControl);return "control"in l?_({kind:"text",text:Ul(l.reads,l.node,c.projection)}):l}case "getContentControlParagraphs":{let l=_e(c.contentControl);return "control"in l?_({kind:"handles",handles:l.control.paragraphIds.map(g=>o.paragraph(g,l.reads.story))}):l}case "getContentControlRange":{let l=_e(c.contentControl);if(!("control"in l))return l;let g=c.location??"whole";if(!ms.has(g))return b("unsupported-content","that is not a place in a control",g);let v=ko(l.reads,l.node);if(!v)return b("unsupported-content","that control holds nothing addressable","empty");let C=g==="start"||g==="before"?v.start:v.end,T=g!=="whole"&&g!=="content",j=W=>({story:l.reads.story,paragraphId:W.paragraphId,index:l.reads.indexOf(W.paragraphId),offset:W.offset});return _({kind:"span",span:we(T?{start:j(C),end:j(C)}:{start:j(v.start),end:j(v.end)},o)})}case "setContentControlValue":{let l=_e(c.contentControl);if(!("control"in l))return l;let g=hs(c.value);if(!g.ok)return b(g.code,g.message,g.detail);let v=d(l.reads),C=f(v);return C||{ok:true,kind:"command",story:l.reads.story,ops:[{op:"setContentControlValue",controlId:l.control.nodeId,value:g.value}],answer:()=>de}}case "setContentControlProperties":{let l=_e(c.contentControl);if(!("control"in l))return l;if(M&&(!As(l.reads.part,l.control.nodeId,y)||c.lock!==void 0||c.cannotEdit!==void 0||c.cannotDelete!==void 0))return b("unsupported-capability","tracked control metadata requires an own pending insertion; locks require direct edits");if(c.tag===void 0&&c.title===void 0&&c.lock===void 0&&c.cannotEdit===void 0&&c.cannotDelete===void 0)return b("unsupported-content","nothing to write","no-properties");if(c.lock!==void 0&&!ps.has(c.lock))return b("unsupported-content","that is not a lock this schema declares",c.lock);for(let T of [c.cannotEdit,c.cannotDelete])if(T!==void 0&&typeof T!="boolean")return b("unsupported-content","lock flags must be boolean");let g=d(l.reads),v=c.lock;if(c.cannotEdit!==void 0||c.cannotDelete!==void 0){let T=v??s.get(g)?.get(l.control.nodeId)??l.control.properties.lock,j=c.cannotEdit??(T==="contentLocked"||T==="sdtContentLocked"),W=c.cannotDelete??(T==="sdtLocked"||T==="sdtContentLocked");v=j?W?"sdtContentLocked":"contentLocked":W?"sdtLocked":"unlocked";}let C=f(g);if(C)return C;if(v!==void 0){let T=s.get(g)??new Map;T.set(l.control.nodeId,v),s.set(g,T);}return {ok:true,kind:"command",story:l.reads.story,ops:[{op:"setContentControlProperties",controlId:l.control.nodeId,...c.tag===void 0?{}:{tag:c.tag},...c.title===void 0?{}:{alias:c.title},...v===void 0?{}:{lock:v}}],answer:()=>de}}case "insertContentControlText":{let l=_e(c.contentControl);if(!("control"in l))return l;let g=gs(l.control.properties,c.text,c.at);if(g)return {ok:false,error:g};let v=d(l.reads),C=f(v);if(C)return C;let T=ko(l.reads,l.node);if(!T)return b("unsupported-content","that control holds nothing addressable","empty");let j=c.at==="end"?T.end:T.start,W=()=>({kind:"span",span:V({start:{story:l.reads.story,paragraphId:j.paragraphId,index:l.reads.indexOf(j.paragraphId),offset:j.offset},end:{story:l.reads.story,paragraphId:j.paragraphId,index:l.reads.indexOf(j.paragraphId),offset:j.offset+c.text.length}})});return c.at==="replace"?{ok:true,kind:"command",story:l.reads.story,ops:[{op:"setContentControlValue",controlId:l.control.nodeId,value:{kind:"text",text:c.text}}],answer:W}:{ok:true,kind:"command",story:l.reads.story,ops:c.text.length===0?[]:[{op:"insertText",paragraphId:j.paragraphId,offset:j.offset,text:c.text,inside:l.node.id}],answer:W}}case "deleteContentControl":{let l=_e(c.contentControl);if(!("control"in l))return l;if(typeof c.keepContent!="boolean")return b("unsupported-content","keepContent is required","keepContent");let g=d(l.reads),v=f(g);if(v)return v;if(!c.keepContent)for(let C of l.control.paragraphIds){let T=F(g,C);if(T)return T}return {ok:true,kind:"command",story:l.reads.story,ops:[{op:"removeContentControl",controlId:l.control.nodeId,keepContent:c.keepContent}],answer:()=>de}}case "insertContentControl":return vs(c,o,a,y,e.trackedRangeReplacement,(l,g)=>{let v=d(l);return f(v)??S(v,g)});case "insertCustomNode":{let l=Gl(c);if(l)return b("unsupported-content",l.message,l.detail);let g=zl(c.payload);if(!g.ok)return b("unsupported-content","that payload cannot be written",g.field);let v=Yl(c,o,a);if("code"in v)return b(v.code,v.message,v.detail);let{start:C,end:T}=v.range,j=J(v.range);if(!j)return b("invalid-handle","that story is not in this document");let W=f(d(j));return W||{ok:true,kind:"customNodeWrite",story:j.story,write:Xl(c,C,T,g.value),answer:()=>de}}default:return b("unknown-operation","this host does not implement that operation",String(c.op))}};return {plan(c,y){if(p&&et(c))return b("conflicting-operations","header/footer creation must commit alone");let A=m.conflict(c);if(A)return b("conflicting-operations",A.message,A.detail);let P=Cr(c,y);if(P.ok&&P.kind==="command"&&P.solitary){if(m.hasCommands)return b("conflicting-operations","header/footer creation must commit alone");p=true;}return P.ok&&P.kind!=="query"&&m.note(c),P},get hasCommands(){return m.hasCommands},get writeScope(){return h?.reads.scope??null},settle(c){let y=h;if(y){let A=c.story(y.reads.story),P=A&&chunkWO4V6PNS_cjs.Ta(A.part,y.reads.root.id),w=A&&P&&P.id!==A.root.id?qn(A,P):A;if(!w)return {ok:false,detail:`the story this batch wrote is gone: ${z(y.reads.story)}`};let M=new Set(y.reads.paragraphIds),l=w.paragraphIds.filter(v=>!M.has(v));if(l.length!==y.created.length+y.externalCreatedCount)return {ok:false,detail:`planned ${String(y.created.length+y.externalCreatedCount)} new paragraphs, the transaction made ${String(l.length)}`};y.order.filter(v=>v.id===null).forEach((v,C)=>{v.id=l[C]??null;});for(let v of y.retargets)v.slot.id&&o.retarget(v.from,v.slot.id);}for(let[A,P]of u.entries()){let w=c.story(P.range.start.story);if(!(!w||!us(P.range,w))&&e.select?.(P.range,P.mode)===false)return {ok:false,detail:"the host could not place the selection",selection:A}}return {ok:true}}}}var cc=4e6,pc=16e6,Jl=12;function Kt(e){if(e===null||typeof e!="object")return false;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function zt(e){return "paragraph"in e&&typeof e.offset=="number"}function Ql(e=cc,t=pc){let n=new Map,o=[],r=0,a=0,i=(s,d)=>s.length+d.text.length;return {record(s,d,u){let m=n.get(d),p=m?.at(-1);if(m&&(n.delete(d),n.set(d,m)),p&&p.text===u){s>p.to&&(p.to=s);return}let h={from:s,to:s,text:u};if(a+=i(d,h),!m||!p)n.set(d,[h]);else for(m.push(h),a-=i(d,p),o.push({key:d,record:p}),r+=p.text.length;r>e&&o.length>0;){let f=o.shift();r-=f.record.text.length;let k=n.get(f.key);k?.[0]===f.record&&k.shift();}for(;a>t&&n.size>1;){let[f,k]=n.entries().next().value;n.delete(f);let x=k.at(-1);x&&(a-=i(f,x));}},clear(){n.clear(),o.length=0,r=0,a=0;},size(){return n.size},at(s,d){let u=n.get(d);if(u)for(let m=u.length-1;m>=0;m-=1){let p=u[m];if(p.from<=s)return s<=p.to?p.text:void 0}}}}function St(e,t,n){let o=pe(e.paragraph,t,n);if(!o.ok)return null;let r=n.story(o.value.story),a=r?.rawText(o.value.paragraphId);return a==null||!r?null:{id:o.value.paragraphId,text:a,story:r}}var Zl=e=>`next\0${e}`,ql=(e,t)=>`between\0${e}\0${t}`;function ed(e,t,n,o){let r=St(e,n,o),a=St(t,n,o);if(!r||!a||r.id===a.id||r.story!==a.story)return null;let i=r.story.indexOf(r.id),s=r.story.indexOf(a.id);if(i<0||s<=i)return null;let d=r.story.paragraphIds.slice(i+1,s);return {key:ql(r.id,a.id),ids:d,texts:d.map(u=>r.story.rawText(u)??"")}}function hn(e,t,n,o,r,a=0){if(a>Jl)return e;if(Array.isArray(e)){let u=false,m=e.map(p=>{let h=hn(p,t,n,o,r,a+1);return h!==p&&(u=true),h});return u?Object.freeze(m):e}if(!Kt(e))return e;let{start:i,end:s}=e;if(Kt(i)&&zt(i)&&Kt(s)&&zt(s)){let u=ed(i,s,o,r);u&&(n.record(t,u.key,u.ids.join("\0")),u.ids.forEach((m,p)=>n.record(t,m,u.texts[p])));}if(zt(e)){let u=St(e,o,r);if(!u)return e;n.record(t,u.id,u.text);let m=u.story.indexOf(u.id);return n.record(t,Zl(u.id),u.story.paragraphIds[m+1]??""),Object.freeze({...e,readAt:t})}let d=null;for(let[u,m]of Object.entries(e)){let p=hn(m,t,n,o,r,a+1);p!==m&&(d??={...e},d[u]=p);}return d?Object.freeze(d):e}function bo(e,t,n=0){if(n>Jl)return;if(Array.isArray(e)){for(let a of e)bo(a,t,n+1);return}if(!Kt(e))return;if(zt(e)){e.readAt!==void 0&&t.push({endpoint:e});return}let{start:o,end:r}=e;if(Kt(o)&&zt(o)&&Kt(r)&&zt(r)){o.readAt!==void 0&&t.push({endpoint:o,end:r}),r.readAt!==void 0&&t.push({endpoint:r});for(let[a,i]of Object.entries(e))a!=="start"&&a!=="end"&&bo(i,t,n+1);return}for(let a of Object.values(e))bo(a,t,n+1);}function td(e,t,n,o,r){let a=[];bo(e,a);for(let{endpoint:i,end:s}of a){if(i.readAt===t)continue;if(typeof i.readAt!="number"||!Number.isSafeInteger(i.readAt))return "invalid-read-revision";if(i.readAt>t)return `read-at ${String(i.readAt)} was never read: the document is at revision ${String(t)}`;let d=St(i,o,r);if(!d)continue;let u=n.at(i.readAt,d.id);if(u===void 0)return `read-at ${String(i.readAt)} is no longer checkable`;let m=d.text,p=i.offset;if(!Number.isInteger(p)||p<0||p>u.length)continue;let h=s!==void 0&&St(s,o,r)?.id!==d.id;if(h?u!==m:m.length<p||u.slice(0,p)!==m.slice(0,p))return h?`the paragraph a span starts in changed since revision ${String(i.readAt)}`:`text before offset ${String(p)} changed since revision ${String(i.readAt)}`;if(h){let f=mc(i,s,i.readAt,n,o,r);if(f)return f}}return null}function mc(e,t,n,o,r,a){let i=St(e,r,a),s=St(t,r,a);if(!i||!s)return null;let d=ed(e,t,r,a),u=ql(i.id,s.id),m=o.at(n,u)??(o.at(n,Zl(i.id))===s.id?"":void 0);if(m===void 0)return `the paragraphs a span covers are no longer checkable at revision ${String(n)}`;if(!d||d.ids.join("\0")!==m)return `a paragraph was inserted or removed inside a span since revision ${String(n)}`;for(let[p,h]of d.ids.entries())if(o.at(n,h)!==d.texts[p])return `a paragraph inside a span changed since revision ${String(n)}`;return null}var fc=Object.freeze({status:"skipped"});function ue(e,t,n){return Object.freeze(n===void 0?{code:e,message:t}:{code:e,message:t,detail:n})}function gc(e){if(e==="review-module-required"||e==="automation-structural-tracking-unsupported")return ue("unsupported-capability","this edit requires a supported review mode",e);if(e==="unsupported-revision:foreign-insertion")return ue("unsupported-revision","the new text would land inside a container within another author's pending insertion",e);let t=e==="unsupported-revision"||e.startsWith("unsupported-revision:");return ue(t?"unsupported-revision":"transaction-refused",t?"that story contains a tracked change this engine cannot resolve":"the document store refused the transaction",e)}function Pe(e,t,n,o){return {ok:false,results:e.map((r,a)=>a===t?{status:"error",error:n}:fc),revision:o,changed:false}}function hc(e,t){let n=-1,o=e.findIndex(r=>(r.op==="selectSpan"||r.op==="selectBookmark")&&++n===t);return o<0?0:o}function nd(e){let{port:t}=e,n=Object.freeze({...e.capabilities}),o=Di(),r=new Set,a=false,i={mode:"Off"},s=0,d=null,u=null,m=Ql(),p=n.events?t.subscribe(()=>{if(a)return;let x=Object.freeze({revision:t.revision()});if(s>0)d=x;else for(let O of [...r])O(x);}):()=>{},h=x=>{if(u&&u.pkg===x)return u.value;let O=dt(x);return u={pkg:x,value:O},O},f=x=>{let O=Array.isArray(x?.operations)?x.operations:[],I=t.revision();if(a)return Pe(O,0,ue("disposed","this host was disposed"),I);if(!n.document)return Pe(O,0,ue("unsupported-capability","this host has no document","document"),I);let R=t.currentPackage();if(!R)return Pe(O,0,ue("document-unavailable","this host holds no document right now"),I);if(x.expectedRevision!==void 0&&x.expectedRevision!==I)return Pe(O,0,ue("stale-revision","the document moved since that revision",`expected ${String(x.expectedRevision)}, at ${I}`),I);let N=h(R);for(let L=0;L<O.length;L+=1){let q=td(O[L],I,m,o,N);if(q)return Pe(O,L,q==="invalid-read-revision"?ue("invalid-offset","an endpoint carries an invalid readAt",q):ue("stale-revision","that range was read before its text changed",q),I)}let E=t.allocationActor?.(),D=br({handles:o,reads:N,capabilities:n,collaborative:t.collaborative?.()??false,trackedRangeReplacement:t.trackedRangeReplacement?.()??true,...t.revisionDisplayMode?{displayMode:t.revisionDisplayMode()}:{},...t.replacementLanding?{replacementLanding:t.replacementLanding.bind(t)}:{},...t.fieldPageContext?{fieldPageContext:t.fieldPageContext.bind(t)}:{},...t.select?{select:t.select.bind(t)}:{},...t.selectRefusal?{selectRefusal:t.selectRefusal.bind(t)}:{}}),B=[],S=[],F=null,Y=[],$=[],V=null,J,se=null,K=-1,ke=false,ce=i;for(let L=0;L<O.length;L+=1){let q=O[L];if(t.suggesting?.()&&q.op!=="replaceSpan"&&(!Go(q)||!ce.author&&["insertContentControl","setContentControlProperties","startNewList","setListLevelFormat","insertTable","insertTableRows","updateTable","updateTableCell"].includes(q.op)))return Pe(O,L,ue("unsupported-capability","this operation has no supported tracked form in suggesting mode"),I);let Ae=Ni(q,t.localChangeTracking===true,ce),oe=Ae?.step??Ei(q,chunkWO4V6PNS_cjs.Hb(E,()=>D.plan(q,ce.author)),ce.author);if(Ae&&(ce=Ae.state),!oe.ok)return Pe(O,L,oe.error,I);if(B.push(oe),oe.kind==="command")if(ce.author&&(oe.packageEdits?.length||q.op==="setContentControlProperties")&&(ke=true),q.op==="setRevisionAuthorBatch"&&(ke=true),oe.packageEdits&&Y.push(...oe.packageEdits),K<0&&(K=L),oe.lifecycle)F=oe.ops[0]??null;else if(oe.relate){let Ce=oe.relate;S.push(Ct=>{let Je=Ct(Ce.url);return Je===null?null:Ce.ops(Je)});}else {let{ops:Ce}=oe;S.push(()=>Ce);}else oe.kind==="commentWrite"?(K<0&&(K=L),$.push(oe.write),V=D.writeScope??{kind:"body"}):oe.kind==="customNodeWrite"&&(K<0&&(K=L),se={write:oe.write,scope:D.writeScope??{kind:"body"}});}let be=false;if($.length>0){let L=t.applyCommentWrites($,V??{kind:"body"});if(!L.ok)return Pe(O,K<0?0:K,ue("transaction-refused","the document store refused the comment write",L.reason),I);be=L.changed,J=L.commentId;}if(se){let L=t.applyCustomNodeWrite(se.write,se.scope);if(!L.ok)return Pe(O,K<0?0:K,ue("transaction-refused","the document store refused the custom-node write",L.reason),I);be=L.changed;}if(F){let L=t.applyLifecycle(F);if(!L.ok)return Pe(O,K<0?0:K,ue("transaction-refused","the document store refused the transaction",L.reason),I);be=L.changed;}if(S.length>0){let L=t.apply(q=>{let Ae=[];for(let oe of S){let Ce=oe(q);if(Ce===null)return null;Ae.push(...Ce);}return Ae},D.writeScope??{kind:"body"},Y,ke);if(!L.ok)return Pe(O,K<0?0:K,gc(L.reason),I);be=L.changed;}let he=t.currentPackage();if(!he)return Pe(O,0,ue("document-unavailable","this host holds no document right now"),I);let xe=h(he),ve=D.settle(xe);if(!ve.ok&&ve.selection!==void 0)return i=ce,{...Pe(O,hc(O,ve.selection),ue("unsupported-capability","the host could not place the selection","selection"),t.revision()),changed:be};if(!ve.ok)return Pe(O,K<0?0:K,ue("transaction-refused","the transaction did not produce the document the batch planned",ve.detail),t.revision());i=ce;let Xe=t.revision();return {ok:true,results:B.map(L=>({status:"ok",value:L.kind==="query"?hn(L.value,I,m,o,N):hn(L.kind==="customNodeWrite"?L.answer(xe):L.answer(xe,J),Xe,m,o,xe)})),revision:Xe,changed:be}};return {capabilities:n,revision:()=>t.revision(),execute:x=>{s+=1;try{return f(x)}finally{if(s-=1,s===0&&d){let O=d;d=null;for(let I of [...r])I(O);}}},...t.prepare?{prepare:t.prepare.bind(t)}:{},save(){if(a)return {ok:false,error:ue("disposed","this host was disposed")};if(!n.save)return {ok:false,error:ue("unsupported-capability","this host cannot save","save")};let x=t.save();return x?{ok:true,bytes:x}:{ok:false,error:ue("document-unavailable","this host holds no document right now")}},subscribe(x){return a||!n.events?()=>{}:(r.add(x),()=>{r.delete(x);})},dispose(){a||(a=true,r.clear(),p(),t.dispose(),u=null,m.clear());}}}var rd=Object.freeze({document:true,save:true,events:true,selection:false,scrolling:false,layout:false}),od=Object.freeze({kind:"body"});function yc(e,t={}){let n=chunkWO4V6PNS_cjs.Ee(e,t.limits??{});if(!n.ok)return {ok:false,reason:n.reason,...n.limit===void 0?{}:{limit:n.limit},...n.detail?{detail:n.detail}:{}};let o=n.package.parts.get(n.package.mainDocumentPart);if(!o)return {ok:false,reason:"no-main-document-part",detail:n.package.mainDocumentPart};let r=new chunk243W4WW2_cjs.T(n.package,chunk243W4WW2_cjs.ua(n.package,chunkWO4V6PNS_cjs.Eb(o)),t.contentLockPolicy?{contentLockPolicy:t.contentLockPolicy}:{}),a=t.collaborationModel?.session,i=()=>{},s=bc(r,a,()=>i());if(t.pagination){let u,m=-1,p=t.pagination;s.prepare=async h=>{if(!h.operations.some(x=>x.op==="updateFieldResult"))return;u=void 0;let f=r.packageRevision,k=await p(chunk243W4WW2_cjs.Da(r));r.packageRevision===f&&(u=k,m=f);},s.fieldPageContext=(h,f,k)=>{if(r.packageRevision!==m)return null;let x=dt(r.currentPackage()).story(h);return x?Ti(u,x.part,f,k):null};}let d=nd({port:s,capabilities:rd});return a&&(i=a.attach(chunk6IDOVU6L_cjs.b(r,{documentId:a.documentId}))),{ok:true,host:d}}function kc(e,t,n){let o=e.partFor(n);return o?chunkWO4V6PNS_cjs.Na(e,()=>{let r=chunkWO4V6PNS_cjs.Pg(e.currentPackage(),t,o.name);return r?(e.replacePackageShell(r.pkg),r.relationshipId):null},r=>r!==null):null}function bc(e,t,n=()=>{}){let o=true,r=0,a=()=>t?(r+=1,{origin:t.identity.role==="agent"?chunkWO4V6PNS_cjs.g.mutationAgent:chunkWO4V6PNS_cjs.g.mutationHuman,actorId:t.identity.actorId,operationId:`${t.identity.actorId}:${t.sessionId}:automation:${r}`,recordsHistory:false}):{},i=s=>(t?.flushPendingJournals(),s);return {localChangeTracking:true,collaborative:()=>!!t,allocationActor:()=>t?.identity.actorId,revision:()=>e.packageRevision,currentPackage:()=>o?e.currentPackage():null,apply(s,d=od,u=[]){if(!o)return {ok:false,reason:"disposed"};let m=s(k=>chunkWO4V6PNS_cjs.Hb(t?.identity.actorId,()=>kc(e,k,d)));if(m===null)return {ok:false,reason:"unsupported-target"};let p=t?.gateOperations(m,d);if(p)return {ok:false,reason:p};let h=t?e.partFor(d)?.name:void 0,f=e.transact(d,k=>{for(let x of u)k.applyPackage(x);for(let x of m)k.apply(x);h&&k.applyPackage(x=>chunk6IDOVU6L_cjs.a(x,h,m));},a());return f.ok?i({ok:true,changed:f.change!==null}):{ok:false,reason:f.detail?`${f.reason}: ${f.detail}`:f.reason}},applyLifecycle(s){if(!o)return {ok:false,reason:"disposed"};let d=t?.gateOperations([s],od);if(d)return {ok:false,reason:d};let u=chunkWO4V6PNS_cjs.Hb(t?.identity.actorId,()=>e.applyLifecycleOp(s));return u.ok?i({ok:true,changed:u.change!==null}):{ok:false,reason:u.detail?`${u.reason}: ${u.detail}`:u.reason}},applyCommentWrites(s,d){if(!o)return {ok:false,reason:"disposed"};if(s.length===0)return {ok:true,changed:false};let u=t?.gateOperations([],d);if(u)return {ok:false,reason:u};let m=e.resolveStory(d);if(!m.ok)return {ok:false,reason:m.reason};if(m.store.graftPackage(()=>e.currentPackage()),s.every(f=>f.kind==="delete")){let f=s.find(x=>x.kind==="delete"),k=chunkWO4V6PNS_cjs.Hb(t?.identity.actorId,()=>chunk243W4WW2_cjs.ea(e,s.flatMap(x=>x.kind==="delete"?[{commentId:x.commentId,...x.parentCommentId===void 0?{}:{parentCommentId:x.parentCommentId}}]:[]),d,f?.kind==="delete"?f.noteId:void 0));return k?i({ok:true,changed:k}):{ok:false,reason:"comment-delete-refused"}}if(s.length!==1)return {ok:false,reason:"mixed-comment-writes"};let p=s[0];if(p.kind==="create"||p.kind==="reply"){let f=chunkWO4V6PNS_cjs.Hb(t?.identity.actorId,()=>chunk243W4WW2_cjs.ca(e,{anchor:p.anchor,author:p.author,text:p.text,...p.date===void 0?{}:{date:p.date},...p.kind==="reply"?{replyToCommentId:p.parentCommentId}:{}},d));return f.ok?i({ok:true,changed:true,..."commentId"in f?{commentId:f.commentId}:{}}):{ok:false,reason:f.reason}}if(p.kind!=="resolve")return {ok:false,reason:"unsupported-comment-write"};let h=chunkWO4V6PNS_cjs.Hb(t?.identity.actorId,()=>chunk243W4WW2_cjs.da(e,p.commentId,p.resolved));return h.ok?i({ok:true,changed:true}):{ok:false,reason:h.reason}},applyCustomNodeWrite(s,d){if(!o)return {ok:false,reason:"disposed"};let u=t?.gateOperations([],d);if(u)return {ok:false,reason:u};let m=e.resolveStory(d);if(!m.ok)return {ok:false,reason:m.reason};let p=chunkWO4V6PNS_cjs.Hb(t?.identity.actorId,()=>chunk243W4WW2_cjs.ma(e,s,d));return p.ok?i({ok:true,changed:p.change!==null}):{ok:false,reason:p.detail?`${p.reason}: ${p.detail}`:p.reason}},save:()=>o?chunkWO4V6PNS_cjs.Ge(e.currentPackage()):null,subscribe:s=>e.subscribe(()=>s()),dispose(){n(),o=false;}}}var ad="https://docx-editor.dev/docs/2.x/guides/diagnostics";function xc(e){return e.replace(".","-")}var Or={"open.unsupported-source":"The editor was given something that is not DOCX bytes. Pass a Uint8Array or an ArrayBuffer of a .docx file, or 'blank'.","open.zip-corrupt":"The file is not a valid ZIP archive, or a compressed entry is damaged. Ask for a fresh copy of the file.","open.zip-invalid-entry-name":'The archive contains an entry with an unsafe path, such as ".." or a leading "/". The editor refuses it for safety.',"open.zip-entry-limit":"The archive has more entries than the open limit allows. For a trusted file, the server API accepts a higher limit: limits.zip.maxEntries in createServer.","open.zip-size-limit":"The archive expands to more than the total size limit. For a trusted file, the server API accepts a higher limit: limits.zip.maxTotalBytes in createServer.","open.zip-ratio-limit":"The file expands to many times its compressed size, which is how a decompression bomb looks. For a trusted file, the server API accepts a higher limit: limits.zip.maxRatio in createServer.","open.xml-malformed":"An XML part of the document is not well formed. Opening and saving the file in a desktop editor usually repairs it.","open.xml-dtd-forbidden":"An XML part declares a DTD or an entity. The editor refuses these to block XML entity attacks.","open.xml-part-size-limit":"One XML part is larger than the per-part size limit. For a trusted file, the server API accepts a higher limit: limits.xml.maxBytes in createServer.","open.xml-depth-limit":"An XML part nests deeper than the depth limit, often through deeply nested tables. This limit is fixed; flatten the nesting to open the file.","open.xml-element-limit":"An XML part has more elements than the element limit. For a trusted file, the server API accepts a higher limit: limits.xml.maxElements in createServer.","open.invalid-limits":"The limits passed to createServer are not valid numbers. Check the limits option.","open.content-types-invalid":"The file has no valid [Content_Types].xml part, so it is not a usable Office package. Save it again as .docx.","open.missing-main-document":"The package has no main document part. The file may be a different Office format, such as .xlsx or .pptx, renamed to .docx.","open.relationships-invalid":"A relationship in the package is invalid or duplicated. Opening and saving the file in a desktop editor usually repairs it.","open.relationship-limit":"The package has more relationships than the open limit allows. For a trusted file, the server API accepts a higher limit: limits.maxRelationships in createServer.","open.part-limit":"The package has more XML parts than the open limit allows. For a trusted file, the server API accepts a higher limit: limits.maxXmlParts in createServer.","open.failed":"The document could not be opened for a reason without a specific code. Report it with the engine version.","save.no-document":"save() ran before a document was loaded, or after it failed to open. Wait for the open to finish, and check the document.open event for a refusal.","save.document-changed":"A new document was loaded while save() waited for a pending edit. Save again after the new document opens.","save.failed":"save() threw. The errorName and stage fields name the class of the error; its message is never reported. Report it with the editor version.","edit.read-only":"The document is open for viewing or is protected as read-only, so edits are refused. Change the editing mode, or remove the protection.","edit.protected-content":"The edit touches content that document protection or a locked content control does not allow you to change.","edit.suggesting-needs-author":"Suggesting (tracking changes) needs an author to attribute each change to. Pass the author option or call setAuthor.","edit.review-module-required":"This operation needs the review module. Register reviewModule() from @docx-editor.dev/pro in modules.","edit.tracked-drawing-delete-unsupported":"This operation cannot record a drawing deletion as a tracked change, so nothing was deleted. Leave the drawing and report it, or ask a person to delete it in the editor, which records the deletion as a tracked change.","edit.tracked-structure-unsupported":"This structural edit cannot be recorded as a tracked change. Edit the text inside the structure instead, or ask a person to make the change with tracking off.","edit.tracked-operation-unsupported":"This editing API operation cannot be recorded as a tracked change, so nothing was applied. Use text edits such as range.insertText or range.delete, which tracking records. Never switch tracking off to make the edit succeed.","edit.tracking-mode-unsupported":"TrackAll needs every collaborator to enforce tracking, which this runtime cannot guarantee. Use TrackMineOnly instead.","edit.tracking-author-required":"TrackMineOnly needs an author for each tracked change. Pass the author option to createServer or createBrowser. The author set on the editor does not apply to an editing API batch.","edit.tracking-unsupported-host":"This automation host does not support change tracking. The runtimes from createServer and from a mounted editor both support TrackMineOnly.","edit.revision-unsupported":"The edit, accept, or reject touches a tracked change of a kind the editor cannot change yet. Edit around it, and leave that change for a person to review.","edit.tracking-required":"Document protection allows edits only as tracked changes. Switch to suggesting mode, or set document.changeTrackingMode to TrackMineOnly in an editing API batch, then edit again.","edit.tracked-image-replace-unsupported":"Replacing a picture cannot be recorded as a tracked change, so the picture did not change. Insert the new picture as a tracked insertion, or ask a person to replace it with tracking off.","edit.tracked-deleted-text-only":"The tracked deletion or replacement covers only text that is already deleted, so nothing was applied. Include live text in the range, or insert next to the deleted text instead.","edit.tracked-foreign-revision-unsupported":"The tracked edit touches another author's pending change in a way this editor cannot record: their paragraph mark, formatting, move, or structural change, a link or content control inside their insertion, or, in a collaboration session, strikes over another author's pending insertion or deletion, and edits that start inside or right after one. Nothing was applied. Edit outside that change, or leave it for a person to review first.","edit.tracked-own-pending-change":"The tracked edit covers or borders your own pending change and would merge with that decision, so nothing was applied. Edit outside your pending change, or reject it and edit again.","edit.picture-selected":"A picture is selected, so the new picture has no place to go and nothing was inserted. Place the caret in text next to the picture, then insert again.","edit.cross-structure-join":"The edit would join paragraphs that live in different containers, such as two table cells. Edit each container separately.","edit.indivisible-content":"The edit would split content that must stay whole, such as an equation or a field. Select the whole item instead.","edit.field-structure":"The edit would break the structure of a field. Edit the field result as a whole, or remove the whole field.","edit.section-mark":"The edit would remove a section break that holds page layout settings. Remove the section break on its own.","edit.table-structure-unsupported":"The table edit is not supported for this table shape, for example a table with merged cells. Change the merge first.","edit.table-insert-refused":"A table cannot be inserted at the selection, for example inside a field or a locked content control. Move the caret first.","edit.table-of-contents-refused":"The table of contents could not be inserted or updated at this place. Check that the selection is in the main document body.","edit.unsupported-content":"The edit touches content the editor shows but cannot change yet. The content is kept as it is.","edit.operation-unsupported":"This editing API operation or option is not supported by this runtime or host. Check the compatibility notes for the member you called.","edit.unsupported-story":"This part of the document, such as a header, a footer or a note, does not support this edit.","edit.unmapped-change":"The browser changed the page in a way the editor could not express as a document edit, so the change was undone.","edit.stale-target":"The operation addresses content that no longer exists, usually after a remote or undone change. Read the document again and retry.","edit.invalid-argument":"The command arguments are not valid for this target. Check the command type and its fields.","edit.resource-limit":"The edit would exceed a size or nesting limit. Split the change into smaller edits.","edit.refresh-in-progress":"An external document refresh is in progress. Retry the edit after the refresh completes.","edit.preview-active":"A preview is open over the document, so the editor refuses writes and a second preview. Commit or discard the open preview, then retry.","edit.preview-unsupported":"A preview cannot show this operation, so nothing was shown. Write it with run() after the preview, or leave it out of the preview.","edit.preview-composing":"An input method composition is in progress, so no preview began. Retry after the composition ends.","edit.preview-diverged":"The document answered a replayed read differently from the preview, so the commit wrote nothing. Read the document again and build a new preview.","edit.collaboration-not-ready":"The collaboration session is not ready to replicate edits, so this one was refused. Wait for the ready status, then retry; a destroyed session needs a rejoin.","edit.collaboration-text-limit":"One edit inserted more text than a collaboration session accepts at once. Insert the text in smaller parts.","edit.internal-invariant":"The editor refused an edit to protect the document structure. This is an engine defect: report the code with the engine version.","edit.refused":"The edit was refused for a reason without a specific code. Read snapshot().lastRejection for the local message.","review.revision-unsupported":"A tracked change of this kind cannot be accepted or rejected yet. It was left in the document.","review.incomplete-group":"The tracked change is part of a group that was not fully selected. Select the whole group, or resolve it from the review pane.","review.retained-structure":"Resolving the tracked change would remove structure that other content still needs, so it was left in place.","review.stale-revision":"The tracked change no longer exists, usually because it was resolved already. Read the review items again.","font.shaper-unavailable":"The text shaper did not load, so text is measured with fallback metrics. Check that your bundler serves the HarfBuzz WebAssembly file.","font.load-failed":"A font face could not be loaded. The editor uses a substitute. Check the font source URL and its CORS headers.","font.missing":"A font the document asks for is not available. The editor uses a substitute. Add the face to the fonts option.","font.integrity-mismatch":"A font face does not match its declared hash or metadata, so the editor refused it and used a substitute.","font.malformed":"A font file is not a valid font, so the editor refused it and used a substitute. Check the file the font source points at.","font.size-limit":"A font file is larger than the font byte budget, so the editor used a substitute. Subset the font, or serve a smaller face.","history.split":"An edit started a new undo step inside a gesture you meant as one. Wrap the gesture in beginHistoryGroup and end it when the gesture ends.","history.possible-ungrouped-gesture":"Several commands ran in quick succession without a history group, so undo may take them back one at a time. Use beginHistoryGroup for one user gesture.","history.possible-fragmented-gesture":"One gesture was split across several history groups, so undo may need several steps. Keep one history group open for the whole gesture.","custom-node.payload-invalid":"A custom node payload in the document does not match the node schema, so the node opened without its data. Check the schema version that wrote the file.","custom-node.payload-missing":"A custom node points at a payload the document does not contain, often after a partial export or a manual edit. The node opened without its data.","font.unsupported-face":"A font face uses a format or face index the editor does not support. The editor uses a substitute.","performance.slow-interaction":"More than one key press or click in 20 took over 200 ms to reach the screen. Compare the layout and paint timings in this event: slow layout follows document size, slow paint follows the pages on screen."},xr="The collaboration session could not take work: it was not attached, not ready yet, or already destroyed. Wait for the ready status, or rejoin when the session was destroyed.",xo="The collaboration factory rejected a value before joining. Fix the document id, session id, or identity that the host passed.",vo="Joining the room did not complete. Check that the provider is connected and the room id is right, then rejoin.",yn="The document cannot seed a collaboration room. Open the file on its own to find the problem, or seed the room from another copy.",vr="This client and the room use different collaboration formats. Save local work, then upgrade the client or migrate the room.",Ar="The room is unusable. Save a copy, then create a new room from saved document bytes.",wt="A remote update could not be applied yet. Edits pause and the session heals when a later update arrives. No action is needed unless it persists.",ot="Shared state reached a resource limit. A refused local edit is taken back automatically; a room over a limit must be recreated from a saved copy.",Ao="A value in the shared state is malformed or points at something that does not exist. A refused local edit is taken back automatically; a room that holds such a value must be recreated from a saved copy.",id="The room server refused the saved room. Check the server storage, then rejoin.",je="This collaboration code is no longer emitted. Upgrade the packages on every client and server.",vc={"collab.collaboration-session-destroyed":xr,"collab.collaboration-session-not-attached":xr,"collab.collaboration-session-not-ready":xr,"collab.collaboration-text-limit":"One edit inserted more text than a collaboration session accepts at once. Insert the text in smaller parts.","collab.experimental-collaboration-body-text-only":"This session replicates only body text, and the edit touched another part of the document. Make that change outside collaboration.","collab.invalid-document-id":xo,"collab.invalid-identity":xo,"collab.invalid-identity-color":xo,"collab.invalid-session-id":xo,"collab.already-initialized":vo,"collab.document-id-mismatch":vo,"collab.initialization-aborted":vo,"collab.not-initialized":vo,"collab.baseline-too-large":yn,"collab.blob-read":yn,"collab.invalid-baseline":yn,"collab.missing-local-blob":yn,"collab.no-main-document-part":yn,"collab.collaboration-format-mismatch":vr,"collab.protocol-version-mismatch":vr,"collab.schema-version-mismatch":vr,"collab.blob-digest-mismatch":Ar,"collab.concurrent-seed":Ar,"collab.port-already-attached":Ar,"collab.duplicate-paragraph-id":wt,"collab.invalid-relationships":wt,"collab.materialize-dropped-content":wt,"collab.missing-blob":wt,"collab.missing-root":wt,"collab.remote-apply-failed":wt,"collab.unknown-paragraph-id":wt,"collab.blob-store-full":ot,"collab.blob-too-large":ot,"collab.invalid-blob-descriptor":Ao,"collab.invalid-bound":Ao,"collab.invalid-logical-id":Ao,"collab.invalid-string":"A shared value is not valid XML text, so the session refused it. A peer sent malformed state; save a copy and recreate the room.","collab.prototype-key":"A shared state key would reach object internals, so the session refused it. A peer sent malformed state; save a copy and recreate the room.","collab.text-too-long":ot,"collab.too-many-attributes":ot,"collab.too-many-children":ot,"collab.too-many-nodes":ot,"collab.too-many-parts":ot,"collab.too-many-relationships":ot,"collab.tree-too-deep":ot,"collab.unknown-logical-id":Ao,"collab.unsafe-part-name":"A shared package part has an unsafe name, so the session refused it. A peer sent malformed state; save a copy and recreate the room.","collab.invalid-saved-room":id,"collab.saved-room-unavailable":id,"collab.baseline-digest-mismatch":je,"collab.experimental-collaboration-existing-paragraphs-only":je,"collab.experimental-collaboration-text-only":je,"collab.experimental-collaboration-untracked-text-only":je,"collab.immutable-baseline-changed":je,"collab.immutable-metadata-changed":je,"collab.invalid-shared-metadata":je,"collab.local-mirror-failed":je,"collab.paragraph-set-mismatch":je,"collab.shared-schema-invalid":je,"collab.unsupported-root-key":je,"collab.initialization-timeout":"Joining the room timed out. Check that the collaboration server is reachable, then rejoin.","collab.authentication-failed":"The collaboration server refused the credential. Refresh the token, then rejoin. Reconnecting with the same token fails again.","collab.room-generation-changed":"The server compacted the room while this client was away. Save a copy if it holds unsent changes, then rejoin.","collab.transport":"The collaboration transport failed. Check the network and the server, then rejoin.","collab.transport-disconnected":"The connection to the collaboration server dropped. The session reconnects on its own; edits continue offline when offline editing is on."},Rr={...Or,...vc};function Ac(e){return {hint:Rr[e]??Or["edit.refused"],docs:Object.hasOwn(Rr,e)?`${ad}#${xc(e)}`:ad}}function sd(e){return e.startsWith("edit.")&&Object.hasOwn(Or,e)}function Rc(){return Object.keys(Rr)}var Oc=1,dd={unsupported:"open.unsupported-source","inflate-error":"open.zip-corrupt","bad-name":"open.zip-invalid-entry-name","too-many-entries":"open.zip-entry-limit","parse-error":"open.xml-malformed","missing-root":"open.xml-malformed","multiple-roots":"open.xml-malformed","invalid-name":"open.xml-malformed","invalid-namespace":"open.xml-malformed","undeclared-prefix":"open.xml-malformed","duplicate-expanded-attribute":"open.xml-malformed","dtd-forbidden":"open.xml-dtd-forbidden","entity-forbidden":"open.xml-dtd-forbidden","too-deep":"open.xml-depth-limit","too-many-elements":"open.xml-element-limit","invalid-limits":"open.invalid-limits","no-content-types":"open.content-types-invalid","bad-content-types":"open.content-types-invalid","no-main-document":"open.missing-main-document","no-main-document-tree":"open.missing-main-document","bad-relationship-target":"open.relationships-invalid","duplicate-relationship-id":"open.relationships-invalid","too-many-relationships":"open.relationship-limit","too-many-xml-parts":"open.part-limit"};function Pc(e,t){return e==="too-large"?t==="zip.maxRatio"?"open.zip-ratio-limit":t==="zip.maxTotalBytes"?"open.zip-size-limit":"open.xml-part-size-limit":Ro(dd,e)??"open.failed"}var Pr={locked:"edit.protected-content",bound:"edit.protected-content","drawing-locked":"edit.protected-content","not-adjacent-siblings":"edit.cross-structure-join","indivisible-content":"edit.indivisible-content","field-structure":"edit.field-structure","field-result-unsupported":"edit.field-structure","carries-section-mark":"edit.section-mark","table-has-merge":"edit.table-structure-unsupported","row-hides-cell":"edit.table-structure-unsupported","unknown-grid-column":"edit.table-structure-unsupported","cross-cell-drawing":"edit.table-structure-unsupported",trackedDrawingDeletionUnsupported:"edit.tracked-drawing-delete-unsupported",packageTransactionRequired:"edit.tracked-structure-unsupported","automation-structural-tracking-unsupported":"edit.tracked-structure-unsupported","unsupported-revision":"edit.revision-unsupported","unsupported-revision:foreign-insertion":"edit.tracked-foreign-revision-unsupported","unknown-revision":"edit.stale-target","resource-limit":"edit.resource-limit","fragment-too-deep":"edit.resource-limit","fragment-resource-budget":"edit.resource-limit","fragment-invalid-block":"edit.unsupported-content",unsupported:"edit.unsupported-content","unsupported-property":"edit.unsupported-content","not-a-picture-drawing":"edit.unsupported-content","unknown-op":"edit.invalid-argument","invalid-range":"edit.invalid-argument","offset-out-of-range":"edit.invalid-argument","splits-surrogate-pair":"edit.invalid-argument","invalid-text":"edit.invalid-argument","invalid-property-value":"edit.invalid-argument","invalid-drawing-value":"edit.invalid-argument","not-a-list-paragraph":"edit.invalid-argument",typeMismatch:"edit.invalid-argument",invalidArgs:"edit.invalid-argument","unknown-paragraph":"edit.stale-target",[We]:"edit.stale-target","paragraph-not-in-body":"edit.stale-target","no-such-story":"edit.stale-target","cell-not-in-story":"edit.stale-target","deleted-table-object":"edit.stale-target","missing-parent-table":"edit.stale-target","missing-table-story":"edit.stale-target","not-a-paragraph":"edit.stale-target","unknown-block":"edit.stale-target","not-a-block":"edit.stale-target","block-required":"edit.stale-target","unknown-part":"edit.stale-target","unknown-content-control":"edit.stale-target","not-a-content-control":"edit.stale-target","unknown-control":"edit.stale-target","unknown-table":"edit.stale-target","unknown-row":"edit.stale-target","unknown-drawing":"edit.stale-target","not-a-drawing":"edit.stale-target","tree-invariant":"edit.internal-invariant","package-invariant":"edit.internal-invariant","package-changed":"edit.internal-invariant","duplicate-property-container":"edit.internal-invariant","unknown-scope":"edit.unsupported-story","dangling-relationship":"edit.unsupported-story","wrong-relationship-type":"edit.unsupported-story","external-relationship":"edit.unsupported-story","missing-part":"edit.unsupported-story","bad-relationship-target":"edit.unsupported-story","not-a-story-part":"edit.unsupported-story","too-many-story-stores":"edit.resource-limit","unsupported-story":"edit.unsupported-story","experimental-collaboration-body-text-only":"edit.unsupported-story","review-module-required":"edit.review-module-required","no-document":"edit.stale-target","table-insert-refused":"edit.table-insert-refused","table-of-contents-refused":"edit.table-of-contents-refused","refresh-in-progress":"edit.refresh-in-progress","preview-active":"edit.preview-active","preview-operation-unsupported":"edit.preview-unsupported","preview-composition-active":"edit.preview-composing","collaboration-session-not-ready":"edit.collaboration-not-ready","collaboration-session-not-attached":"edit.collaboration-not-ready","collaboration-session-destroyed":"edit.collaboration-not-ready","collaboration-text-limit":"edit.collaboration-text-limit","change-tracking-unsupported-host":"edit.tracking-unsupported-host","change-tracking-mode-unsupported":"edit.tracking-mode-unsupported","change-tracking-author-required":"edit.tracking-author-required","change-tracking-operation-unsupported":"edit.tracked-operation-unsupported"};function Ic(e){let t=Ro(Pr,e);if(t)return t;let n=e.indexOf(":"),o=n<0?e:e.slice(0,n);return sd(o)?o:Ro(Pr,o)??null}var ud={"unsupported-revision":"review.revision-unsupported","incomplete-group":"review.incomplete-group","retained-structure":"review.retained-structure","unknown-revision":"review.stale-revision"};function Sc(e){return Ro(ud,e)??null}function cd(){return [...Object.keys(dd),"too-large",...Object.keys(Pr),...Object.keys(ud)]}var Ie=1024,wc=[[64*Ie,"0-64KiB"],[128*Ie,"64-128KiB"],[256*Ie,"128-256KiB"],[512*Ie,"256-512KiB"],[1024*Ie,"512KiB-1MiB"],[2*1024*Ie,"1-2MiB"],[4*1024*Ie,"2-4MiB"],[8*1024*Ie,"4-8MiB"],[16*1024*Ie,"8-16MiB"],[32*1024*Ie,"16-32MiB"],[64*1024*Ie,"32-64MiB"],[128*1024*Ie,"64-128MiB"],[256*1024*Ie,"128-256MiB"],[512*1024*Ie,"256-512MiB"]];function Cc(e){for(let[t,n]of wc)if(e<t)return n;return "512MiB+"}function Tc(e){return e<=0?"0":e===1?"1":e<10?"2-9":e<100?"10-99":e<1e3?"100-999":"1000+"}var ld=0;function Nc(){let e=globalThis.crypto;if(e?.randomUUID)return `e_${e.randomUUID()}`;if(e?.getRandomValues){let t=e.getRandomValues(new Uint8Array(16));return `e_${Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}`}return ld+=1,`e_${Date.now().toString(36)}_${ld.toString(36)}`}function Ec(e,t=()=>Date.now()){let n=Nc();return {editorSessionId:n,deliver(o){let r=Object.freeze({...o,schemaVersion:Oc,editorSessionId:n,time:t()});for(let a of e())try{let i=a(r);i&&typeof i.then=="function"&&i.then(void 0,()=>{});}catch{}}}}function Ro(e,t){return Object.hasOwn(e,t)?e[t]:void 0}var Dc=["paragraph-count-unexplained","paragraph-reordered","unknown-paragraph-id","unknown-content-moved","unsupported-node","split-not-clean","join-not-clean"],Lc={unaddressed:true,"misplaced-marker":true,"nested-marker":true,"unsupported-structure":true,"unsupported-move":true,"unrecorded-properties":true,"read-only":true,"no-sites":true},md="exception",pd;function fd(){return pd??=new Set([...cd().filter(e=>!e.includes(":")),...Dc,...Object.keys(Lc),md]),pd}function Mc(){return [...fd()]}function Bc(e){if(!e)return;let t=e.indexOf(":"),n=t<0?e:e.slice(0,t);return fd().has(n)?n:void 0}function Hc(){return md}var Fc=new Set(["Error","TypeError","RangeError","ReferenceError","SyntaxError"]);function jc(e){let t=e instanceof Error?e.name:void 0;return t&&Fc.has(t)?t:"other"}var _c=[[/^\[content_types\]\.xml$/,"content-types"],[/\.rels$/,"relationships"],[/^customxml\//,"custom-xml"],[/^docprops\//,"document-properties"],[/\/media\//,"media"],[/\/embeddings\//,"embedding"],[/\/glossary\//,"glossary"],[/(?:^|\/)theme\/[^/]*\.xml$/,"theme"],[/(?:^|\/)header\d*\.xml$/,"header"],[/(?:^|\/)footer\d*\.xml$/,"footer"],[/(?:^|\/)footnotes\.xml$/,"footnotes"],[/(?:^|\/)endnotes\.xml$/,"endnotes"],[/(?:^|\/)comments[a-z]*\.xml$/,"comments"],[/(?:^|\/)people\.xml$/,"people"],[/(?:^|\/)styles(?:witheffects)?\.xml$/,"styles"],[/(?:^|\/)numbering\.xml$/,"numbering"],[/(?:^|\/)websettings\.xml$/,"web-settings"],[/(?:^|\/)settings\.xml$/,"settings"],[/(?:^|\/)fonttable\.xml$/,"font-table"],[/(?:^|\/)document\d*\.xml$/,"main-document"]],Vc=512;function Uc(e){if(!e)return;let t=[": "," -> "].reduce((o,r)=>{let a=e.indexOf(r);return a>=0&&a<o?a:o},e.length);if(t>Vc)return "other";let n=e.slice(0,t).replace(/^\/+/,"").toLowerCase().replace(/(\.(?:xml|rels))\/[^/]*$/,"$1");for(let[o,r]of _c)if(o.test(n))return r;return "other"}var Wc={insert:true,delete:true,replace:true,moveFrom:true,moveTo:true,format:true,paragraphMark:true,structural:true};function rb(e){return e&&Object.hasOwn(Wc,e)?e:void 0}var $c=new Set(["rPrChange","pPrChange","sectPrChange","tblPrChange","tblPrExChange","tblGridChange","trPrChange","tcPrChange","numberingChange"]);function ab(e){if(e)return $c.has(e)?e:"other"}
|
|
7
|
+
exports.A=Hc;exports.B=jc;exports.C=Uc;exports.D=rb;exports.E=ab;exports.a=es;exports.b=ts;exports.c=yt;exports.d=ki;exports.e=Wo;exports.f=$o;exports.g=rn;exports.h=et;exports.i=dt;exports.j=Ci;exports.k=Ti;exports.l=Jd;exports.m=nd;exports.n=rd;exports.o=yc;exports.p=bc;exports.q=Ac;exports.r=Rc;exports.s=Pc;exports.t=Ic;exports.u=Sc;exports.v=Cc;exports.w=Tc;exports.x=Ec;exports.y=Mc;exports.z=Bc;
|