@eigenpal/docx-editor-agents 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +0,0 @@
1
- import {U as U$1,V as V$1,H as H$1,I as I$1,ca}from'./chunk-QPFWFH5W.mjs';import {m}from'./chunk-XDZHYYU6.mjs';function h(o){return o.type==="insertion"||o.type==="deletion"||o.type==="moveFrom"||o.type==="moveTo"}function x(o){let t=[];for(let r of o)r.type==="run"?t.push(H$1(r)):r.type==="hyperlink"&&t.push(I$1(r));return t.join("")}function I(o,t){let r=0;for(let n of o.content)if(n.type==="paragraph"){if(r===t)return n;r++;}else if(n.type==="table"){for(let i of n.rows)for(let e of i.cells)for(let a of e.content)if(a.type==="paragraph"){if(r===t)return a;r++;}}else r++;throw new Error(`Paragraph index ${t} out of bounds (max: ${r-1})`)}function P(o,t){let r=0;for(let n of o.content)if(n.type==="paragraph"){if(t(n,r)===false)return;r++;}else if(n.type==="table"){for(let i of n.rows)for(let e of i.cells)for(let a of e.content)if(a.type==="paragraph"){if(t(a,r)===false)return;r++;}}else r++;}function ce(o,t={}){let{fromIndex:r,toIndex:n,includeTrackedChanges:i=true,includeCommentAnchors:e=true}=t,a=[],s=0;for(let u of o.content)if(u.type==="paragraph")E(s,r,n)&&a.push(J(u,s,i,e)),s++;else if(u.type==="table"){E(s,r,n)&&a.push(K(u,s,i,e));for(let l of u.rows)for(let c of l.cells)for(let f of c.content)f.type==="paragraph"&&s++;}else s++;return a}function E(o,t,r){return (t===void 0||o>=t)&&(r===void 0||o<=r)}function J(o,t,r,n){let i=O(o,r,n),e=o.formatting?.styleId,a=o.paraId;return U$1(e)?{type:"heading",index:t,paraId:a,level:V$1(e)??1,text:i}:o.listRendering?{type:"list-item",index:t,paraId:a,text:i,listLevel:o.listRendering.level??0,listType:o.listRendering.isBullet?"bullet":"number"}:{type:"paragraph",index:t,paraId:a,text:i}}function K(o,t,r,n){let i=[],e=[];for(let a of o.rows){let s=[],u=[];for(let l of a.cells){let c=[],f;for(let g of l.content)g.type==="paragraph"&&(f===void 0&&(f=g.paraId),c.push(O(g,r,n)));s.push(c.join(`
2
- `)),u.push(f);}i.push(s),e.push(u);}return {type:"table",index:t,rows:i,cellParaIds:e}}function le(o){let t=[],r=n=>n.paraId?n.paraId:String(n.index);for(let n of o)switch(n.type){case "heading":t.push(`[${r(n)}] (h${n.level}) ${n.text}`);break;case "paragraph":t.push(`[${r(n)}] ${n.text}`);break;case "list-item":{let i=" ".repeat(n.listLevel),e=n.listType==="bullet"?"\u2022":"-";t.push(`[${r(n)}] ${i}${e} ${n.text}`);break}case "table":{let i=n.index;for(let e=0;e<n.rows.length;e++)for(let a=0;a<n.rows[e].length;a++){let u=n.rows[e][a].split(`
3
- `),l=n.cellParaIds?.[e]?.[a];for(let c=0;c<u.length;c++){let f=c===0&&l?l:String(i);t.push(`[${f}] (table, row ${e+1}, col ${a+1}) ${u[c]}`),i++;}}break}}return t.join(`
4
- `)}function O(o,t,r){let n=[],i=new Set;for(let e of o.content){if(e.type==="commentRangeStart"&&r){i.add(e.id),n.push(`[comment:${e.id}]`);continue}if(e.type==="commentRangeEnd"&&r){i.has(e.id)&&(i.delete(e.id),n.push("[/comment]"));continue}if(e.type==="run")n.push(H$1(e));else if(e.type==="hyperlink")n.push(I$1(e));else if(h(e)){let a=x(e.content);e.type==="insertion"||e.type==="moveTo"?t&&n.push(`[+${a}+]{by:${e.info.author}}`):t?n.push(`[-${a}-]{by:${e.info.author}}`):n.push(a);}}return n.join("")}var y=class extends Error{constructor(t,r){let n=r!==void 0?` in paragraph ${r}`:" in document";super(`Text not found${n}: "${t}"`),this.name="TextNotFoundError";}},A=class extends Error{constructor(t){super(`Tracked change not found: id=${t}`),this.name="ChangeNotFoundError";}},L=class extends Error{constructor(t){super(`Comment not found: id=${t}`),this.name="CommentNotFoundError";}};function W(o){let t=[],r=0;for(let n=0;n<o.content.length;n++){let i=o.content[n];if(i.type==="run"){let e=H$1(i);t.push({contentIndex:n,run:i,text:e,startPos:r}),r+=e.length;}else if(i.type==="hyperlink")for(let e=0;e<i.children.length;e++){let a=i.children[e];if(a.type==="run"){let s=H$1(a);t.push({contentIndex:n,run:a,text:s,startPos:r}),r+=s.length;}}else if(h(i)){if(i.type==="insertion"||i.type==="moveTo")continue;for(let e=0;e<i.content.length;e++){let a=i.content[e];if(a.type==="run"){let s=H$1(a);t.push({contentIndex:n,run:a,text:s,startPos:r}),r+=s.length;}else if(a.type==="hyperlink"){for(let s of a.children)if(s.type==="run"){let u=H$1(s);t.push({contentIndex:n,run:s,text:u,startPos:r}),r+=u.length;}}}}}return t}function v(o){return W(o).map(t=>t.text).join("")}function Q(o,t,r){let n=W(o),i=n.map(c=>c.text).join(""),e=V(i,t);if(!e)throw new y(t,r);let a=-1,s=0;for(let c=0;c<n.length;c++)if(e.start<n[c].startPos+n[c].text.length){a=c,s=e.start-n[c].startPos;break}let u=-1,l=0;for(let c=n.length-1;c>=0;c--)if(e.end>n[c].startPos){u=c,l=e.end-n[c].startPos;break}if(a===-1||u===-1)throw new y(t,r);return {startRunIndex:n[a].contentIndex,startOffset:s,endRunIndex:n[u].contentIndex,endOffset:l}}function ge(o,t,r){let n=Q(o,t,r),{startRunIndex:i,endRunIndex:e}=n,{startOffset:a,endOffset:s}=n,u=o.content[e];if(u.type==="run"){let c=H$1(u);if(s<c.length){let f=j(c.slice(s),u);H(u,c.slice(0,s)),o.content.splice(e+1,0,f);}}let l=o.content[i];if(l.type==="run"&&a>0){let c=H$1(l),f=j(c.slice(0,a),l);H(l,c.slice(a)),o.content.splice(i,0,f),i++,e++;}return {startIndex:i,endIndex:e}}function j(o,t){return {type:"run",content:[{type:"text",text:o}],formatting:t.formatting?{...t.formatting}:void 0}}function H(o,t){let r=o.content.find(n=>n.type==="text");r&&(r.text=t);}function z(o){let t=[],r=[],n=true;for(let i=0;i<o.length;i++){let e=o[i];if(!"\u200B\u200C\u200D\uFEFF\xAD".includes(e)){if("\u201C\u201D\u201E\u201F".includes(e)&&(e='"'),"\u2018\u2019\u201A\u201B".includes(e)&&(e="'"),"\u2013\u2014\u2012\u2015".includes(e)&&(e="-"),e==="\u2026"){t.push(".",".","."),r.push(i,i,i),n=false;continue}if(/\s/.test(e)||e==="\xA0"){n||(t.push(" "),r.push(i),n=true);continue}t.push(e.toLowerCase()),r.push(i),n=false;}}return t.length>0&&t[t.length-1]===" "&&(t.pop(),r.pop()),{text:t.join(""),posMap:r}}function N(o,t,r,n){let i=o.posMap[t],e=o.posMap[t+r-1]+1;for(;e<n.length&&"\u200B\u200C\u200D\uFEFF\xAD".includes(n[e]);)e++;return {start:i,end:e}}function V(o,t){if(!t||!o)return null;let r=o.indexOf(t);if(r!==-1)return {start:r,end:r+t.length};let n=z(o),i=z(t);if(!i.text)return null;let e=n.text.indexOf(i.text);if(e!==-1)return N(n,e,i.text.length,o);let a=i.text.split(" ");if(a.length>=3)for(let s=1;s<=Math.min(2,a.length-2);s++){let u=a.slice(0,-s).join(" "),l=n.text.indexOf(u);if(l!==-1)return N(n,l,u.length,o)}return null}function be(o,t){let r=new Map;return P(o,(i,e)=>{let a=null;for(let s of i.content)if(h(s)){a===null&&(a=v(i));let u=x(s.content),l=s.info.id,c=r.get(l);c&&c.paragraphIndex===e?c.text+=u:r.set(l,{id:l,type:s.type,author:s.info.author,date:s.info.date??null,text:u,context:a,paragraphIndex:e});}}),Array.from(r.values()).filter(i=>!(t?.author&&i.author!==t.author||t?.type&&i.type!==t.type))}function Ce(o,t){let r=o.comments??[];if(r.length===0)return [];let n=Y(o),i=[],e=new Map;for(let s of r)if(s.parentId!==void 0){let u=e.get(s.parentId)??[];u.push(s),e.set(s.parentId,u);}else i.push(s);return i.map(s=>{let u=n.get(s.id),l=(e.get(s.id)??[]).map(c=>({id:c.id,author:c.author,date:c.date??null,text:G(c)}));return {id:s.id,author:s.author,date:s.date??null,text:G(s),anchoredText:u?.text??"",paragraphIndex:u?.paragraphIndex??-1,replies:l,done:s.done??false}}).filter(s=>!(t?.author&&s.author!==t.author||t?.done!==void 0&&s.done!==t.done))}function G(o){return o.content.map(t=>v(t)).join(`
5
- `)}function Y(o){let t=new Map,r=new Map;return P(o,(n,i)=>{for(let e of n.content)if(e.type==="commentRangeStart")r.set(e.id,{paragraphIndex:i,parts:[]});else if(e.type==="commentRangeEnd"){let a=r.get(e.id);a&&(t.set(e.id,{text:a.parts.join(""),paragraphIndex:a.paragraphIndex}),r.delete(e.id));}else if(e.type==="run"){let a=H$1(e);for(let s of r.values())s.parts.push(a);}else if(e.type==="hyperlink"){let a=e.children.filter(s=>s.type==="run").map(H$1).join("");for(let s of r.values())s.parts.push(a);}else if(h(e)){if(e.type==="insertion"||e.type==="moveTo")continue;let a=x(e.content);for(let s of r.values())s.parts.push(a);}}),t}function Z(o){let t=o.toDocument().package?.document;if(!t)return new Map;let r=new Map,n=0;for(let i of t.content)if(i.type==="paragraph"){let e=i.paraId;e&&r.set(e,n),n++;}else if(i.type==="table")for(let e of i.rows)for(let a of e.cells)for(let s of a.content)s.type==="paragraph"&&n++;else n++;return r}function _(o){let t=[],r=n=>{for(let i of n.content)i.type==="text"&&t.push(i.text??"");};for(let n of o.content)if(n.type==="run")r(n);else if(n.type==="hyperlink")for(let i of n.children)i.type==="run"&&r(i);else if(n.type==="deletion"||n.type==="moveFrom"){for(let i of n.content)if(i.type==="run")r(i);else if(i.type==="hyperlink")for(let e of i.children)e.type==="run"&&r(e);}return t.join("")}function F(o,t){let n={type:"run",content:[{type:"text",text:t,preserveSpace:/^\s|\s$/.test(t)}]};return o.formatting&&(n.formatting={...o.formatting}),o.propertyChanges&&(n.propertyChanges=[...o.propertyChanges]),n}function q(o){return o.content.map(t=>t.type==="text"?t.text:"").join("")}function k(o,t,r,n,i){let e=q(o);if(!e)return;let a=i.value,s=a+e.length;n.push({run:o,parent:t,index:r,text:e,start:a,end:s}),i.value=s;}function U(o,t,r){o.children.forEach((n,i)=>{n.type==="run"&&k(n,o.children,i,t,r);});}function M(o,t){let r=[],n={value:0};return o.content.forEach((i,e)=>{i.type==="run"?k(i,o.content,e,r,n):i.type==="hyperlink"?U(i,r,n):(i.type==="deletion"||i.type==="moveFrom"||t&&(i.type==="insertion"||i.type==="moveTo"))&&i.content.forEach((a,s)=>{a.type==="run"?k(a,i.content,s,r,n):a.type==="hyperlink"&&U(a,r,n);});}),r}function ee(o,t){let r={...o??{}};t.bold!==void 0&&(r.bold=t.bold||void 0),t.italic!==void 0&&(r.italic=t.italic||void 0),t.underline!==void 0&&(t.underline?r.underline={style:typeof t.underline=="object"&&t.underline.style?t.underline.style:"single"}:delete r.underline),t.strike!==void 0&&(r.strike=t.strike||void 0),t.color!==void 0&&(t.color&&(t.color.rgb||t.color.themeColor)?r.color={rgb:t.color.rgb,themeColor:t.color.themeColor}:delete r.color),t.highlight!==void 0&&(t.highlight?r.highlight=ca(t.highlight)||t.highlight:delete r.highlight),t.fontSize!==void 0&&(t.fontSize>0?r.fontSize=m(t.fontSize):delete r.fontSize),t.fontFamily!==void 0&&(t.fontFamily&&(t.fontFamily.ascii||t.fontFamily.hAnsi)?r.fontFamily={ascii:t.fontFamily.ascii,hAnsi:t.fontFamily.hAnsi??t.fontFamily.ascii}:delete r.fontFamily);for(let n of Object.keys(r))r[n]===void 0&&delete r[n];return Object.keys(r).length>0?r:void 0}function w(o,t){o.formatting=ee(o.formatting,t);}function te(o,t,r,n){let i=o.run.content.every(s=>s.type==="text");if(t<=0&&r>=o.text.length||!i){w(o.run,n);return}let e=[];t>0&&e.push(F(o.run,o.text.slice(0,t)));let a=F(o.run,o.text.slice(t,r));w(a,n),e.push(a),r<o.text.length&&e.push(F(o.run,o.text.slice(r))),o.parent.splice(o.index,1,...e);}function ne(o,t,r,n){let e=M(o,false).filter(a=>a.start<r&&a.end>t);if(e.length===0)return true;for(let a=e.length-1;a>=0;a--){let s=e[a];te(s,Math.max(0,t-s.start),Math.min(s.text.length,r-s.start),n);}return true}function re(o,t){let r=M(o,true);for(let n of r)w(n.run,t);return true}function oe(o,t){if(!t)return null;let n=M(o,false).map(e=>e.text).join(""),i=n.indexOf(t);return i===-1||n.indexOf(t,i+1)!==-1?null:{from:i,to:i+t.length}}function ie(o,t){return o?!!o.styles?.some(r=>r.styleId===t&&r.type==="paragraph"):true}function Pe(o){let t=new Set,r=null;function n(){return r===null&&(r=Z(o)),r}function i(){if(t.size===0)return;let e=o.getComments(),a=o.getChanges(),s={commentCount:e.length,changeCount:a.length,comments:e,changes:a};for(let u of t)try{u(s);}catch(l){console.error("reviewerBridge content listener threw:",l);}}return {getContentAsText(e){return o.getContentAsText(e)},getContent(e){return o.getContent(e)},getComments(e){return o.getComments(e)},getChanges(e){return o.getChanges(e)},findText(e,a){if(!e)return [];let s=a?.caseSensitive??false,u=a?.limit??20,l=s?e:e.toLowerCase(),c=o.toDocument().package?.document;if(!c)return [];let f=[],g=40;for(let B of c.content){if(f.length>=u)break;if(B.type!=="paragraph")continue;let C=B;if(!C.paraId)continue;let m=_(C),S=s?m:m.toLowerCase(),d=S.indexOf(l);if(d===-1||S.indexOf(l,d+1)!==-1)continue;let X=m.slice(d,d+e.length);f.push({paraId:C.paraId,match:X,before:m.slice(Math.max(0,d-g),d),after:m.slice(d+e.length,d+e.length+g)});}return f},getSelection(){return null},addComment(e){let a=n().get(e.paraId);if(a===void 0)return null;try{let s=o.addComment({paragraphIndex:a,text:e.text,author:e.author,search:e.search});return i(),s}catch{return null}},replyTo(e,a){try{let s=o.replyTo(e,a);return i(),s}catch{return null}},resolveComment(e){let s=o.toDocument().package?.document?.comments?.find(u=>u.id===e);s&&(s.done=true,i());},proposeChange(e){let a=n().get(e.paraId);if(a===void 0)return false;let s=e.search==="",u=e.replaceWith==="";if(s&&u)return false;try{return s?o.proposeInsertion({paragraphIndex:a,insertText:e.replaceWith,author:e.author}):u?o.proposeDeletion({paragraphIndex:a,search:e.search,author:e.author}):o.replace({paragraphIndex:a,search:e.search,replaceWith:e.replaceWith,author:e.author}),i(),true}catch{return false}},scrollTo(e){return n().has(e)},applyFormatting(e){let a=n().get(e.paraId);if(a===void 0)return false;let s=o.toDocument().package?.document;if(!s)return false;try{let u=s?I(s,a):null;if(!u)return false;if(e.search){let l=oe(u,e.search);if(!l)return false;ne(u,l.from,l.to,e.marks);}else re(u,e.marks);return i(),true}catch{return false}},setParagraphStyle(e){let a=n().get(e.paraId);if(a===void 0)return false;let s=o.toDocument(),u=s.package?.document;if(!u||!ie(s.package?.styles,e.styleId))return false;try{let l=I(u,a);return l.formatting={...l.formatting??{},styleId:e.styleId},i(),true}catch{return false}},getPage(){return null},getPages(){return []},getTotalPages(){return 0},getCurrentPage(){return 0},onContentChange(e){return t.add(e),()=>{t.delete(e);}},onSelectionChange(){return ()=>{}}}}export{h as a,I as b,P as c,ce as d,le as e,y as f,A as g,L as h,Q as i,ge as j,be as k,Ce as l,Pe as m};
@@ -1,5 +0,0 @@
1
- 'use strict';var chunkYNUYVVTY_js=require('./chunk-YNUYVVTY.js'),chunkEPRXZTIE_js=require('./chunk-EPRXZTIE.js');function h(o){return o.type==="insertion"||o.type==="deletion"||o.type==="moveFrom"||o.type==="moveTo"}function x(o){let t=[];for(let r of o)r.type==="run"?t.push(chunkYNUYVVTY_js.H(r)):r.type==="hyperlink"&&t.push(chunkYNUYVVTY_js.I(r));return t.join("")}function I(o,t){let r=0;for(let n of o.content)if(n.type==="paragraph"){if(r===t)return n;r++;}else if(n.type==="table"){for(let i of n.rows)for(let e of i.cells)for(let a of e.content)if(a.type==="paragraph"){if(r===t)return a;r++;}}else r++;throw new Error(`Paragraph index ${t} out of bounds (max: ${r-1})`)}function P(o,t){let r=0;for(let n of o.content)if(n.type==="paragraph"){if(t(n,r)===false)return;r++;}else if(n.type==="table"){for(let i of n.rows)for(let e of i.cells)for(let a of e.content)if(a.type==="paragraph"){if(t(a,r)===false)return;r++;}}else r++;}function ce(o,t={}){let{fromIndex:r,toIndex:n,includeTrackedChanges:i=true,includeCommentAnchors:e=true}=t,a=[],s=0;for(let u of o.content)if(u.type==="paragraph")E(s,r,n)&&a.push(J(u,s,i,e)),s++;else if(u.type==="table"){E(s,r,n)&&a.push(K(u,s,i,e));for(let l of u.rows)for(let c of l.cells)for(let f of c.content)f.type==="paragraph"&&s++;}else s++;return a}function E(o,t,r){return (t===void 0||o>=t)&&(r===void 0||o<=r)}function J(o,t,r,n){let i=O(o,r,n),e=o.formatting?.styleId,a=o.paraId;return chunkYNUYVVTY_js.U(e)?{type:"heading",index:t,paraId:a,level:chunkYNUYVVTY_js.V(e)??1,text:i}:o.listRendering?{type:"list-item",index:t,paraId:a,text:i,listLevel:o.listRendering.level??0,listType:o.listRendering.isBullet?"bullet":"number"}:{type:"paragraph",index:t,paraId:a,text:i}}function K(o,t,r,n){let i=[],e=[];for(let a of o.rows){let s=[],u=[];for(let l of a.cells){let c=[],f;for(let g of l.content)g.type==="paragraph"&&(f===void 0&&(f=g.paraId),c.push(O(g,r,n)));s.push(c.join(`
2
- `)),u.push(f);}i.push(s),e.push(u);}return {type:"table",index:t,rows:i,cellParaIds:e}}function le(o){let t=[],r=n=>n.paraId?n.paraId:String(n.index);for(let n of o)switch(n.type){case "heading":t.push(`[${r(n)}] (h${n.level}) ${n.text}`);break;case "paragraph":t.push(`[${r(n)}] ${n.text}`);break;case "list-item":{let i=" ".repeat(n.listLevel),e=n.listType==="bullet"?"\u2022":"-";t.push(`[${r(n)}] ${i}${e} ${n.text}`);break}case "table":{let i=n.index;for(let e=0;e<n.rows.length;e++)for(let a=0;a<n.rows[e].length;a++){let u=n.rows[e][a].split(`
3
- `),l=n.cellParaIds?.[e]?.[a];for(let c=0;c<u.length;c++){let f=c===0&&l?l:String(i);t.push(`[${f}] (table, row ${e+1}, col ${a+1}) ${u[c]}`),i++;}}break}}return t.join(`
4
- `)}function O(o,t,r){let n=[],i=new Set;for(let e of o.content){if(e.type==="commentRangeStart"&&r){i.add(e.id),n.push(`[comment:${e.id}]`);continue}if(e.type==="commentRangeEnd"&&r){i.has(e.id)&&(i.delete(e.id),n.push("[/comment]"));continue}if(e.type==="run")n.push(chunkYNUYVVTY_js.H(e));else if(e.type==="hyperlink")n.push(chunkYNUYVVTY_js.I(e));else if(h(e)){let a=x(e.content);e.type==="insertion"||e.type==="moveTo"?t&&n.push(`[+${a}+]{by:${e.info.author}}`):t?n.push(`[-${a}-]{by:${e.info.author}}`):n.push(a);}}return n.join("")}var y=class extends Error{constructor(t,r){let n=r!==void 0?` in paragraph ${r}`:" in document";super(`Text not found${n}: "${t}"`),this.name="TextNotFoundError";}},A=class extends Error{constructor(t){super(`Tracked change not found: id=${t}`),this.name="ChangeNotFoundError";}},L=class extends Error{constructor(t){super(`Comment not found: id=${t}`),this.name="CommentNotFoundError";}};function W(o){let t=[],r=0;for(let n=0;n<o.content.length;n++){let i=o.content[n];if(i.type==="run"){let e=chunkYNUYVVTY_js.H(i);t.push({contentIndex:n,run:i,text:e,startPos:r}),r+=e.length;}else if(i.type==="hyperlink")for(let e=0;e<i.children.length;e++){let a=i.children[e];if(a.type==="run"){let s=chunkYNUYVVTY_js.H(a);t.push({contentIndex:n,run:a,text:s,startPos:r}),r+=s.length;}}else if(h(i)){if(i.type==="insertion"||i.type==="moveTo")continue;for(let e=0;e<i.content.length;e++){let a=i.content[e];if(a.type==="run"){let s=chunkYNUYVVTY_js.H(a);t.push({contentIndex:n,run:a,text:s,startPos:r}),r+=s.length;}else if(a.type==="hyperlink"){for(let s of a.children)if(s.type==="run"){let u=chunkYNUYVVTY_js.H(s);t.push({contentIndex:n,run:s,text:u,startPos:r}),r+=u.length;}}}}}return t}function v(o){return W(o).map(t=>t.text).join("")}function Q(o,t,r){let n=W(o),i=n.map(c=>c.text).join(""),e=V(i,t);if(!e)throw new y(t,r);let a=-1,s=0;for(let c=0;c<n.length;c++)if(e.start<n[c].startPos+n[c].text.length){a=c,s=e.start-n[c].startPos;break}let u=-1,l=0;for(let c=n.length-1;c>=0;c--)if(e.end>n[c].startPos){u=c,l=e.end-n[c].startPos;break}if(a===-1||u===-1)throw new y(t,r);return {startRunIndex:n[a].contentIndex,startOffset:s,endRunIndex:n[u].contentIndex,endOffset:l}}function ge(o,t,r){let n=Q(o,t,r),{startRunIndex:i,endRunIndex:e}=n,{startOffset:a,endOffset:s}=n,u=o.content[e];if(u.type==="run"){let c=chunkYNUYVVTY_js.H(u);if(s<c.length){let f=j(c.slice(s),u);H(u,c.slice(0,s)),o.content.splice(e+1,0,f);}}let l=o.content[i];if(l.type==="run"&&a>0){let c=chunkYNUYVVTY_js.H(l),f=j(c.slice(0,a),l);H(l,c.slice(a)),o.content.splice(i,0,f),i++,e++;}return {startIndex:i,endIndex:e}}function j(o,t){return {type:"run",content:[{type:"text",text:o}],formatting:t.formatting?{...t.formatting}:void 0}}function H(o,t){let r=o.content.find(n=>n.type==="text");r&&(r.text=t);}function z(o){let t=[],r=[],n=true;for(let i=0;i<o.length;i++){let e=o[i];if(!"\u200B\u200C\u200D\uFEFF\xAD".includes(e)){if("\u201C\u201D\u201E\u201F".includes(e)&&(e='"'),"\u2018\u2019\u201A\u201B".includes(e)&&(e="'"),"\u2013\u2014\u2012\u2015".includes(e)&&(e="-"),e==="\u2026"){t.push(".",".","."),r.push(i,i,i),n=false;continue}if(/\s/.test(e)||e==="\xA0"){n||(t.push(" "),r.push(i),n=true);continue}t.push(e.toLowerCase()),r.push(i),n=false;}}return t.length>0&&t[t.length-1]===" "&&(t.pop(),r.pop()),{text:t.join(""),posMap:r}}function N(o,t,r,n){let i=o.posMap[t],e=o.posMap[t+r-1]+1;for(;e<n.length&&"\u200B\u200C\u200D\uFEFF\xAD".includes(n[e]);)e++;return {start:i,end:e}}function V(o,t){if(!t||!o)return null;let r=o.indexOf(t);if(r!==-1)return {start:r,end:r+t.length};let n=z(o),i=z(t);if(!i.text)return null;let e=n.text.indexOf(i.text);if(e!==-1)return N(n,e,i.text.length,o);let a=i.text.split(" ");if(a.length>=3)for(let s=1;s<=Math.min(2,a.length-2);s++){let u=a.slice(0,-s).join(" "),l=n.text.indexOf(u);if(l!==-1)return N(n,l,u.length,o)}return null}function be(o,t){let r=new Map;return P(o,(i,e)=>{let a=null;for(let s of i.content)if(h(s)){a===null&&(a=v(i));let u=x(s.content),l=s.info.id,c=r.get(l);c&&c.paragraphIndex===e?c.text+=u:r.set(l,{id:l,type:s.type,author:s.info.author,date:s.info.date??null,text:u,context:a,paragraphIndex:e});}}),Array.from(r.values()).filter(i=>!(t?.author&&i.author!==t.author||t?.type&&i.type!==t.type))}function Ce(o,t){let r=o.comments??[];if(r.length===0)return [];let n=Y(o),i=[],e=new Map;for(let s of r)if(s.parentId!==void 0){let u=e.get(s.parentId)??[];u.push(s),e.set(s.parentId,u);}else i.push(s);return i.map(s=>{let u=n.get(s.id),l=(e.get(s.id)??[]).map(c=>({id:c.id,author:c.author,date:c.date??null,text:G(c)}));return {id:s.id,author:s.author,date:s.date??null,text:G(s),anchoredText:u?.text??"",paragraphIndex:u?.paragraphIndex??-1,replies:l,done:s.done??false}}).filter(s=>!(t?.author&&s.author!==t.author||t?.done!==void 0&&s.done!==t.done))}function G(o){return o.content.map(t=>v(t)).join(`
5
- `)}function Y(o){let t=new Map,r=new Map;return P(o,(n,i)=>{for(let e of n.content)if(e.type==="commentRangeStart")r.set(e.id,{paragraphIndex:i,parts:[]});else if(e.type==="commentRangeEnd"){let a=r.get(e.id);a&&(t.set(e.id,{text:a.parts.join(""),paragraphIndex:a.paragraphIndex}),r.delete(e.id));}else if(e.type==="run"){let a=chunkYNUYVVTY_js.H(e);for(let s of r.values())s.parts.push(a);}else if(e.type==="hyperlink"){let a=e.children.filter(s=>s.type==="run").map(chunkYNUYVVTY_js.H).join("");for(let s of r.values())s.parts.push(a);}else if(h(e)){if(e.type==="insertion"||e.type==="moveTo")continue;let a=x(e.content);for(let s of r.values())s.parts.push(a);}}),t}function Z(o){let t=o.toDocument().package?.document;if(!t)return new Map;let r=new Map,n=0;for(let i of t.content)if(i.type==="paragraph"){let e=i.paraId;e&&r.set(e,n),n++;}else if(i.type==="table")for(let e of i.rows)for(let a of e.cells)for(let s of a.content)s.type==="paragraph"&&n++;else n++;return r}function _(o){let t=[],r=n=>{for(let i of n.content)i.type==="text"&&t.push(i.text??"");};for(let n of o.content)if(n.type==="run")r(n);else if(n.type==="hyperlink")for(let i of n.children)i.type==="run"&&r(i);else if(n.type==="deletion"||n.type==="moveFrom"){for(let i of n.content)if(i.type==="run")r(i);else if(i.type==="hyperlink")for(let e of i.children)e.type==="run"&&r(e);}return t.join("")}function F(o,t){let n={type:"run",content:[{type:"text",text:t,preserveSpace:/^\s|\s$/.test(t)}]};return o.formatting&&(n.formatting={...o.formatting}),o.propertyChanges&&(n.propertyChanges=[...o.propertyChanges]),n}function q(o){return o.content.map(t=>t.type==="text"?t.text:"").join("")}function k(o,t,r,n,i){let e=q(o);if(!e)return;let a=i.value,s=a+e.length;n.push({run:o,parent:t,index:r,text:e,start:a,end:s}),i.value=s;}function U(o,t,r){o.children.forEach((n,i)=>{n.type==="run"&&k(n,o.children,i,t,r);});}function M(o,t){let r=[],n={value:0};return o.content.forEach((i,e)=>{i.type==="run"?k(i,o.content,e,r,n):i.type==="hyperlink"?U(i,r,n):(i.type==="deletion"||i.type==="moveFrom"||t&&(i.type==="insertion"||i.type==="moveTo"))&&i.content.forEach((a,s)=>{a.type==="run"?k(a,i.content,s,r,n):a.type==="hyperlink"&&U(a,r,n);});}),r}function ee(o,t){let r={...o??{}};t.bold!==void 0&&(r.bold=t.bold||void 0),t.italic!==void 0&&(r.italic=t.italic||void 0),t.underline!==void 0&&(t.underline?r.underline={style:typeof t.underline=="object"&&t.underline.style?t.underline.style:"single"}:delete r.underline),t.strike!==void 0&&(r.strike=t.strike||void 0),t.color!==void 0&&(t.color&&(t.color.rgb||t.color.themeColor)?r.color={rgb:t.color.rgb,themeColor:t.color.themeColor}:delete r.color),t.highlight!==void 0&&(t.highlight?r.highlight=chunkYNUYVVTY_js.ca(t.highlight)||t.highlight:delete r.highlight),t.fontSize!==void 0&&(t.fontSize>0?r.fontSize=chunkEPRXZTIE_js.m(t.fontSize):delete r.fontSize),t.fontFamily!==void 0&&(t.fontFamily&&(t.fontFamily.ascii||t.fontFamily.hAnsi)?r.fontFamily={ascii:t.fontFamily.ascii,hAnsi:t.fontFamily.hAnsi??t.fontFamily.ascii}:delete r.fontFamily);for(let n of Object.keys(r))r[n]===void 0&&delete r[n];return Object.keys(r).length>0?r:void 0}function w(o,t){o.formatting=ee(o.formatting,t);}function te(o,t,r,n){let i=o.run.content.every(s=>s.type==="text");if(t<=0&&r>=o.text.length||!i){w(o.run,n);return}let e=[];t>0&&e.push(F(o.run,o.text.slice(0,t)));let a=F(o.run,o.text.slice(t,r));w(a,n),e.push(a),r<o.text.length&&e.push(F(o.run,o.text.slice(r))),o.parent.splice(o.index,1,...e);}function ne(o,t,r,n){let e=M(o,false).filter(a=>a.start<r&&a.end>t);if(e.length===0)return true;for(let a=e.length-1;a>=0;a--){let s=e[a];te(s,Math.max(0,t-s.start),Math.min(s.text.length,r-s.start),n);}return true}function re(o,t){let r=M(o,true);for(let n of r)w(n.run,t);return true}function oe(o,t){if(!t)return null;let n=M(o,false).map(e=>e.text).join(""),i=n.indexOf(t);return i===-1||n.indexOf(t,i+1)!==-1?null:{from:i,to:i+t.length}}function ie(o,t){return o?!!o.styles?.some(r=>r.styleId===t&&r.type==="paragraph"):true}function Pe(o){let t=new Set,r=null;function n(){return r===null&&(r=Z(o)),r}function i(){if(t.size===0)return;let e=o.getComments(),a=o.getChanges(),s={commentCount:e.length,changeCount:a.length,comments:e,changes:a};for(let u of t)try{u(s);}catch(l){console.error("reviewerBridge content listener threw:",l);}}return {getContentAsText(e){return o.getContentAsText(e)},getContent(e){return o.getContent(e)},getComments(e){return o.getComments(e)},getChanges(e){return o.getChanges(e)},findText(e,a){if(!e)return [];let s=a?.caseSensitive??false,u=a?.limit??20,l=s?e:e.toLowerCase(),c=o.toDocument().package?.document;if(!c)return [];let f=[],g=40;for(let B of c.content){if(f.length>=u)break;if(B.type!=="paragraph")continue;let C=B;if(!C.paraId)continue;let m=_(C),S=s?m:m.toLowerCase(),d=S.indexOf(l);if(d===-1||S.indexOf(l,d+1)!==-1)continue;let X=m.slice(d,d+e.length);f.push({paraId:C.paraId,match:X,before:m.slice(Math.max(0,d-g),d),after:m.slice(d+e.length,d+e.length+g)});}return f},getSelection(){return null},addComment(e){let a=n().get(e.paraId);if(a===void 0)return null;try{let s=o.addComment({paragraphIndex:a,text:e.text,author:e.author,search:e.search});return i(),s}catch{return null}},replyTo(e,a){try{let s=o.replyTo(e,a);return i(),s}catch{return null}},resolveComment(e){let s=o.toDocument().package?.document?.comments?.find(u=>u.id===e);s&&(s.done=true,i());},proposeChange(e){let a=n().get(e.paraId);if(a===void 0)return false;let s=e.search==="",u=e.replaceWith==="";if(s&&u)return false;try{return s?o.proposeInsertion({paragraphIndex:a,insertText:e.replaceWith,author:e.author}):u?o.proposeDeletion({paragraphIndex:a,search:e.search,author:e.author}):o.replace({paragraphIndex:a,search:e.search,replaceWith:e.replaceWith,author:e.author}),i(),true}catch{return false}},scrollTo(e){return n().has(e)},applyFormatting(e){let a=n().get(e.paraId);if(a===void 0)return false;let s=o.toDocument().package?.document;if(!s)return false;try{let u=s?I(s,a):null;if(!u)return false;if(e.search){let l=oe(u,e.search);if(!l)return false;ne(u,l.from,l.to,e.marks);}else re(u,e.marks);return i(),true}catch{return false}},setParagraphStyle(e){let a=n().get(e.paraId);if(a===void 0)return false;let s=o.toDocument(),u=s.package?.document;if(!u||!ie(s.package?.styles,e.styleId))return false;try{let l=I(u,a);return l.formatting={...l.formatting??{},styleId:e.styleId},i(),true}catch{return false}},getPage(){return null},getPages(){return []},getTotalPages(){return 0},getCurrentPage(){return 0},onContentChange(e){return t.add(e),()=>{t.delete(e);}},onSelectionChange(){return ()=>{}}}}exports.a=h;exports.b=I;exports.c=P;exports.d=ce;exports.e=le;exports.f=y;exports.g=A;exports.h=L;exports.i=Q;exports.j=ge;exports.k=be;exports.l=Ce;exports.m=Pe;