@eigenpal/docx-editor-agents 0.5.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/LICENSE +204 -672
  2. package/README.md +74 -42
  3. package/dist/agent-types-C8RvQB7n.d.mts +36 -0
  4. package/dist/agent-types-C8RvQB7n.d.ts +36 -0
  5. package/dist/ai-sdk/react.d.mts +29 -39
  6. package/dist/ai-sdk/react.d.ts +29 -39
  7. package/dist/ai-sdk/react.js +1 -1
  8. package/dist/ai-sdk/react.mjs +1 -1
  9. package/dist/ai-sdk/server.d.mts +42 -4
  10. package/dist/ai-sdk/server.d.ts +42 -4
  11. package/dist/ai-sdk/vue.d.ts +32 -0
  12. package/dist/ai-sdk/vue.js +1 -0
  13. package/dist/ai-sdk/vue.mjs +31 -0
  14. package/dist/bridge.d.mts +18 -1
  15. package/dist/bridge.d.ts +18 -1
  16. package/dist/bridge.js +1 -1
  17. package/dist/bridge.mjs +1 -1
  18. package/dist/chunk-3EQVOH4S.js +2 -0
  19. package/dist/chunk-7JG2PH72.js +71 -0
  20. package/dist/chunk-D3TF6WTP.mjs +71 -0
  21. package/dist/chunk-HWYEQX5Y.mjs +1 -0
  22. package/dist/chunk-NISW2GF6.js +1 -0
  23. package/dist/chunk-Q5KDGSCS.js +1 -0
  24. package/dist/{chunk-LVRKZUG4.js → chunk-RYHTROV6.js} +3 -3
  25. package/dist/{chunk-CPJV53R6.mjs → chunk-ULRDFDHR.mjs} +1 -1
  26. package/dist/chunk-X4YGLGUM.mjs +1 -0
  27. package/dist/chunk-XWXSTZIE.mjs +2 -0
  28. package/dist/docx-editor-agents.css +1 -0
  29. package/dist/executor-QBMOTUCJ.js +1 -0
  30. package/dist/executor-RSQI3VOF.mjs +1 -0
  31. package/dist/{headless-JRF2KBID.mjs → headless-Q72PHJUD.mjs} +1 -1
  32. package/dist/headless-U2SAKM5E.js +1 -0
  33. package/dist/index.d.mts +32 -2
  34. package/dist/index.d.ts +32 -2
  35. package/dist/index.js +1 -1
  36. package/dist/index.mjs +1 -1
  37. package/dist/mcp.d.mts +20 -1
  38. package/dist/mcp.d.ts +20 -1
  39. package/dist/react.d.mts +175 -3
  40. package/dist/react.d.ts +175 -3
  41. package/dist/react.js +9 -1
  42. package/dist/react.mjs +9 -1
  43. package/dist/{server-DH5eszkm.d.mts → server-B7RHNVSu.d.mts} +970 -753
  44. package/dist/{server-DH5eszkm.d.ts → server-B7RHNVSu.d.ts} +970 -753
  45. package/dist/server.d.mts +34 -1
  46. package/dist/server.d.ts +34 -1
  47. package/dist/server.js +1 -1
  48. package/dist/server.mjs +1 -1
  49. package/dist/vue/components/AIContextMenu.d.ts +33 -0
  50. package/dist/vue/components/AIResponsePreview.d.ts +40 -0
  51. package/dist/vue/components/AgentChatLog.d.ts +37 -0
  52. package/dist/vue/components/AgentComposer.d.ts +30 -0
  53. package/dist/vue/components/AgentPanel.d.ts +49 -0
  54. package/dist/vue/components/AgentSuggestionChip.d.ts +10 -0
  55. package/dist/vue/components/AgentTimeline.d.ts +19 -0
  56. package/dist/vue/composables/useAgentBridge.d.ts +19 -0
  57. package/dist/vue/types.d.ts +5 -0
  58. package/dist/vue.d.ts +72 -0
  59. package/dist/vue.js +21 -0
  60. package/dist/vue.mjs +1857 -0
  61. package/package.json +52 -9
  62. package/dist/chunk-6NWAUIGY.js +0 -1
  63. package/dist/chunk-A6ANAWKH.js +0 -1
  64. package/dist/chunk-BDHS4WRJ.mjs +0 -1
  65. package/dist/chunk-G46D3GDJ.js +0 -71
  66. package/dist/chunk-N2TKFYHU.js +0 -2
  67. package/dist/chunk-QALBLABE.mjs +0 -2
  68. package/dist/chunk-U7BWZ7DG.mjs +0 -1
  69. package/dist/chunk-XZHZXQO5.mjs +0 -71
  70. package/dist/executor-OYRPTNBR.mjs +0 -1
  71. package/dist/executor-SJAFSXKL.js +0 -1
  72. package/dist/headless-FE3K7ABO.js +0 -1
@@ -0,0 +1 @@
1
+ import {d,e,k as k$1,l,b,i,h,c,j,g as g$1,a}from'./chunk-ULRDFDHR.mjs';import {w as w$1}from'./chunk-D3TF6WTP.mjs';function g(o,e){let{paragraphIndex:t,author:n="AI",text:s,search:a}=e,r=b(o,t),i$1=(o.comments??[]).map(m=>m.id),p=i$1.length>0?Math.max(...i$1)+1:1,c={id:p,author:n,date:new Date().toISOString(),content:[{type:"paragraph",content:[{type:"run",content:[{type:"text",text:s}]}],formatting:{}}]};if(o.comments||(o.comments=[]),o.comments.push(c),a){let m=i(r,a,t);r.content.splice(m.endRunIndex+1,0,{type:"commentRangeEnd",id:p}),r.content.splice(m.startRunIndex,0,{type:"commentRangeStart",id:p});}else r.content.unshift({type:"commentRangeStart",id:p}),r.content.push({type:"commentRangeEnd",id:p});return p}function y(o,e,t){let n=o.comments??[];if(!n.find(p=>p.id===e))throw new h(e);let a=n.map(p=>p.id),r=Math.max(...a)+1,i={id:r,author:t.author??"AI",date:new Date().toISOString(),parentId:e,content:[{type:"paragraph",content:[{type:"run",content:[{type:"text",text:t.text}]}],formatting:{}}]};return n.push(i),r}function E(o,e){let t=o.comments??[],n=t.find(r=>r.id===e);if(!n)throw new h(e);let s=n.parentId!==void 0,a=new Set([e]);if(!s)for(let r of t)r.parentId===e&&a.add(r.id);o.comments=t.filter(r=>!a.has(r.id)),!s&&c(o,r=>{for(let i=r.content.length-1;i>=0;i--){let p=r.content[i];(p.type==="commentRangeStart"||p.type==="commentRangeEnd")&&p.id===e&&r.content.splice(i,1);}});}function C(o,e){if(!W(o,e,"accept"))throw new g$1(e)}function I(o,e){if(!W(o,e,"reject"))throw new g$1(e)}function k(o){return M(o,"accept")}function F(o){return M(o,"reject")}function M(o,e){let t=0;return c(o,n=>{for(let s=n.content.length-1;s>=0;s--){let a$1=n.content[s];a(a$1)&&(G(n,s,a$1,e),t++);}}),t}function W(o,e,t){let n=false;return c(o,s=>{for(let a$1=s.content.length-1;a$1>=0;a$1--){let r=s.content[a$1];a(r)&&r.info.id===e&&(G(s,a$1,r,t),n=true);}if(n)return false}),n}function G(o,e,t,n){if(t.type==="insertion"&&n==="accept"||t.type==="deletion"&&n==="reject"||t.type==="moveTo"&&n==="accept"||t.type==="moveFrom"&&n==="reject"){let a=t.content;o.content.splice(e,1,...a);}else o.content.splice(e,1);}function x(o,e){let{paragraphIndex:t,search:n,author:s="AI",replaceWith:a}=e,r=b(o,t),{startIndex:i,endIndex:p}=j(r,n,t),c=new Date().toISOString(),m=w(o),h=r.content.slice(i,p+1),R={type:"deletion",info:{id:m,author:s,date:c},content:h},v={type:"insertion",info:{id:m+1,author:s,date:c},content:[{type:"run",content:[{type:"text",text:a}]}]};r.content.splice(i,p-i+1,R,v);}function H(o,e){let{paragraphIndex:t,author:n="AI",insertText:s,position:a="after",search:r}=e,i=b(o,t),p=new Date().toISOString(),m={type:"insertion",info:{id:w(o),author:n,date:p},content:[{type:"run",content:[{type:"text",text:s}]}]};if(r){let{startIndex:h,endIndex:R}=j(i,r,t),v=a==="after"?R+1:h;i.content.splice(v,0,m);}else a==="before"?i.content.unshift(m):i.content.push(m);}function L(o,e){let{paragraphIndex:t,search:n,author:s="AI"}=e,a=b(o,t),{startIndex:r,endIndex:i}=j(a,n,t),p=new Date().toISOString(),c=w(o),m=a.content.slice(r,i+1),h={type:"deletion",info:{id:c,author:s,date:p},content:m};a.content.splice(r,i-r+1,h);}var S=new WeakMap;function w(o){let e=S.get(o);e===void 0&&(e=0,c(o,n=>{for(let s of n.content)a(s)&&(e=Math.max(e,s.info.id));}));let t=e+1;return S.set(o,t+1),t}function N(o,e,t="AI"){let n=[],s=0,a=0,r=0,i=0,p=0;for(let c of e.accept??[])try{C(o,c),s++;}catch(m){n.push({operation:"accept",id:c,error:m.message});}for(let c of e.reject??[])try{I(o,c),a++;}catch(m){n.push({operation:"reject",id:c,error:m.message});}for(let c of e.comments??[])try{g(o,{...c,author:c.author??t}),r++;}catch(m){n.push({operation:"comment",search:c.search,error:m.message});}for(let c of e.replies??[])try{y(o,c.commentId,{author:c.author??t,text:c.text}),i++;}catch(m){n.push({operation:"reply",id:c.commentId,error:m.message});}for(let c of e.proposals??[])try{x(o,{...c,author:c.author??t}),p++;}catch(m){n.push({operation:"proposal",search:c.search,error:m.message});}return {accepted:s,rejected:a,commentsAdded:r,repliesAdded:i,proposalsAdded:p,errors:n}}var U=class o{constructor(e,t="AI",n){let s=n??e.originalBuffer,{originalBuffer:a,...r}=e;this.doc=structuredClone(r),s&&(this.doc.originalBuffer=s),this.author=t;}static async fromBuffer(e,t="AI"){let n=await w$1(e,{preloadFonts:false});return new o(n,t,e)}get body(){return this.doc.package.document}resolveAuthor(e){return e??this.author}getContent(e){return d(this.body,e)}getContentAsText(e$1){return e(d(this.body,e$1))}getChanges(e){return k$1(this.body,e)}getComments(e){return l(this.body,e)}addComment(e,t){let n=typeof e=="number"?{paragraphIndex:e,text:t,author:this.author}:{...e,author:this.resolveAuthor(e.author)};return g(this.body,n)}replyTo(e,t){let n=typeof t=="string"?{text:t,author:this.author}:{...t,author:this.resolveAuthor(t.author)};return y(this.body,e,n)}removeComment(e){E(this.body,e);}replace(e,t,n){let s=typeof e=="number"?{paragraphIndex:e,search:t,replaceWith:n,author:this.author}:{...e,author:this.resolveAuthor(e.author)};x(this.body,s);}proposeReplacement(e){this.replace(e);}proposeInsertion(e){H(this.body,{...e,author:this.resolveAuthor(e.author)});}proposeDeletion(e){L(this.body,{...e,author:this.resolveAuthor(e.author)});}acceptChange(e){C(this.body,e);}rejectChange(e){I(this.body,e);}acceptAll(){return k(this.body)}rejectAll(){return F(this.body)}applyReview(e){return N(this.body,e,this.author)}toDocument(){return this.doc}async toBuffer(){if(!this.doc.originalBuffer)throw new Error("Cannot create buffer: no original DOCX buffer was provided. Use DocxReviewer.fromBuffer() or pass originalBuffer to the constructor.");let{repackDocx:e}=await import('./headless-Q72PHJUD.mjs');return e(this.doc)}};export{U as a};
@@ -0,0 +1 @@
1
+ 'use strict';var D=class{constructor(){this.plugins=new Map;this.commandHandlers=new Map;this.eventListeners=new Set;this.initialized=new Set;}register(e,r){let n=[];if(!e.id)return {success:false,error:"Plugin must have an id"};if(this.plugins.has(e.id))return {success:false,error:`Plugin '${e.id}' is already registered`};if(e.dependencies){for(let t of e.dependencies)if(!this.plugins.has(t))return {success:false,error:`Plugin '${e.id}' requires '${t}' which is not registered`}}if(e.commandHandlers)for(let[t,s]of Object.entries(e.commandHandlers)){if(this.commandHandlers.has(t)){let i=this.commandHandlers.get(t);n.push(`Command '${t}' from '${e.id}' overrides handler from '${i.pluginId}'`);}this.commandHandlers.set(t,{pluginId:e.id,handler:s});}if(this.plugins.set(e.id,e),e.initialize&&!this.initialized.has(e.id))try{let t=e.initialize();t instanceof Promise?t.then(()=>{this.initialized.add(e.id);}).catch(s=>{this.emit({type:"error",pluginId:e.id,error:s});}):this.initialized.add(e.id);}catch(t){this.emit({type:"error",pluginId:e.id,error:t});}return r?.debug&&console.log(`[PluginRegistry] Registered plugin: ${e.id}`),this.emit({type:"registered",plugin:e}),{success:true,plugin:e,warnings:n.length>0?n:void 0}}unregister(e){let r=this.plugins.get(e);if(!r)return false;for(let[n,t]of this.plugins)if(t.dependencies?.includes(e))return console.warn(`Cannot unregister '${e}': '${n}' depends on it`),false;for(let[n,{pluginId:t}]of this.commandHandlers)t===e&&this.commandHandlers.delete(n);if(r.destroy)try{let n=r.destroy();n instanceof Promise&&n.catch(t=>{this.emit({type:"error",pluginId:e,error:t});});}catch(n){this.emit({type:"error",pluginId:e,error:n});}return this.plugins.delete(e),this.initialized.delete(e),this.emit({type:"unregistered",pluginId:e}),true}get(e){return this.plugins.get(e)}getAll(){return Array.from(this.plugins.values())}has(e){return this.plugins.has(e)}get size(){return this.plugins.size}getCommandHandler(e){return this.commandHandlers.get(e)?.handler}getCommandTypes(){return Array.from(this.commandHandlers.keys())}hasCommandHandler(e){return this.commandHandlers.has(e)}getMcpTools(){let e=[];for(let r of this.plugins.values())r.mcpTools&&e.push(...r.mcpTools);return e}getMcpToolsForPlugin(e){return this.plugins.get(e)?.mcpTools||[]}getMcpTool(e){for(let r of this.plugins.values())if(r.mcpTools){let n=r.mcpTools.find(t=>t.name===e);if(n)return n}}addEventListener(e){this.eventListeners.add(e);}removeEventListener(e){this.eventListeners.delete(e);}emit(e){for(let r of this.eventListeners)try{r(e);}catch(n){console.error("[PluginRegistry] Event listener error:",n);}}clear(){for(let e of this.plugins.values())if(e.destroy)try{e.destroy();}catch{}this.plugins.clear(),this.commandHandlers.clear(),this.initialized.clear();}getDebugInfo(){return {plugins:Array.from(this.plugins.keys()),commandTypes:Array.from(this.commandHandlers.keys()),mcpTools:this.getMcpTools().map(e=>e.name),initialized:Array.from(this.initialized)}}},C=new D;function U(o,e){return o.map(r=>C.register(r,e))}function W(o){return e=>C.register(e,o)}function h(o){return JSON.parse(JSON.stringify(o))}function g(o,e){let r=0;for(let n=0;n<o.content.length;n++)if(o.content[n].type==="paragraph"){if(r===e)return n;r++;}return -1}function y(o){let e="";for(let r of o.content)if(r.type==="run")for(let n of r.content)n.type==="text"&&(e+=n.text);else if(r.type==="hyperlink"){for(let n of r.children)if(n.type==="run")for(let t of n.content)t.type==="text"&&(e+=t.text);}return e}function T(o,e){return {type:"run",formatting:e,content:[{type:"text",text:o}]}}function I(o,e,r,n){let t=[],s=0,i=false;for(let a of o.content)if(a.type==="run"){let p=a.content.filter(l=>l.type==="text").map(l=>l.text).join(""),c=s,u=s+p.length;if(!i&&e>=c&&e<=u){let l=e-c;l>0&&t.push({...a,content:[{type:"text",text:p.slice(0,l)}]}),t.push(T(r,n||a.formatting)),l<p.length&&t.push({...a,content:[{type:"text",text:p.slice(l)}]}),i=true;}else t.push(a);s=u;}else t.push(a);return i||t.push(T(r,n)),t}function d(o,e,r){let n=[],t=0;for(let s of o.content)if(s.type==="run"){let i=s.content.filter(c=>c.type==="text").map(c=>c.text).join(""),a=t,p=t+i.length;if(p<=e||a>=r)n.push(s);else {let c="";a<e&&(c+=i.slice(0,e-a)),p>r&&(c+=i.slice(r-a)),c.length>0&&n.push({...s,content:[{type:"text",text:c}]});}t=p;}else n.push(s);return n}function w(o,e,r,n){let t=[],s=0;for(let i of o.content)if(i.type==="run"){let a=i.content.filter(u=>u.type==="text").map(u=>u.text).join(""),p=s,c=s+a.length;if(c<=e||p>=r)t.push(i);else if(p>=e&&c<=r)t.push({...i,formatting:{...i.formatting,...n}});else {let u=Math.max(e,p),l=Math.min(r,c);p<u&&t.push({...i,content:[{type:"text",text:a.slice(0,u-p)}]}),t.push({...i,formatting:{...i.formatting,...n},content:[{type:"text",text:a.slice(u-p,l-p)}]}),c>l&&t.push({...i,content:[{type:"text",text:a.slice(l-p)}]});}s=c;}else t.push(i);return t}function R(o,e){let r=h(o),n=r.package.document,t=g(n,e.position.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.position.paragraphIndex} not found`);let s=n.content[t];return s.content=I(s,e.position.offset,e.text,e.formatting),r}function _(o,e){let r=h(o),n=r.package.document,{start:t,end:s}=e.range;if(t.paragraphIndex===s.paragraphIndex){let i=g(n,t.paragraphIndex);if(i===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let a=n.content[i];a.content=d(a,t.offset,s.offset),a.content=I(a,t.offset,e.text,e.formatting);}else {let i=g(n,t.paragraphIndex),a=n.content[i],p=y(a);a.content=d(a,t.offset,p.length),a.content=I(a,t.offset,e.text,e.formatting);let c=[];for(let u=t.paragraphIndex+1;u<=s.paragraphIndex;u++)c.push(g(n,u));for(let u=c.length-1;u>=0;u--)c[u]!==-1&&n.content.splice(c[u],1);}return r}function v(o,e){let r=h(o),n=r.package.document,{start:t,end:s}=e.range;if(t.paragraphIndex===s.paragraphIndex){let i=g(n,t.paragraphIndex);if(i===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let a=n.content[i];a.content=d(a,t.offset,s.offset);}else {let i=g(n,t.paragraphIndex),a=n.content[i],p=y(a);a.content=d(a,t.offset,p.length);let c=g(n,s.paragraphIndex),u=n.content[c];u.content=d(u,0,s.offset),a.content.push(...u.content);let l=[];for(let f=t.paragraphIndex+1;f<=s.paragraphIndex;f++)l.push(g(n,f));for(let f=l.length-1;f>=0;f--)l[f]!==-1&&n.content.splice(l[f],1);}return r}function S(o,e){let r=h(o),n=r.package.document,{start:t,end:s}=e.range;if(t.paragraphIndex===s.paragraphIndex){let i=g(n,t.paragraphIndex);if(i===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let a=n.content[i];a.content=w(a,t.offset,s.offset,e.formatting);}else for(let i=t.paragraphIndex;i<=s.paragraphIndex;i++){let a=g(n,i);if(a===-1)continue;let p=n.content[a],c=y(p),u=0,l=c.length;i===t.paragraphIndex&&(u=t.offset),i===s.paragraphIndex&&(l=s.offset),p.content=w(p,u,l,e.formatting);}return r}function N(o,e){let r=h(o),n=r.package.document,t=g(n,e.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let s=n.content[t];if(s.formatting={...s.formatting,...e.formatting},"numPr"in e.formatting){let i=e.formatting.numPr;if(i&&i.numId!==void 0&&i.numId!==0){let a=i.ilvl??0,p=i.numId===1,c=p?"\u2022":"1.";if(r.package.numbering){let u=r.package.numbering.nums.find(l=>l.numId===i.numId);if(u){let l=r.package.numbering.abstractNums.find(f=>f.abstractNumId===u.abstractNumId);if(l){let f=l.levels.find(m=>m.ilvl===a);f&&(c=f.lvlText||c);}}}s.listRendering={level:a,numId:i.numId,marker:c,isBullet:p};}else delete s.listRendering;}return r}function A(o,e){let r=h(o),n=r.package.document,t=g(n,e.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let s=n.content[t];return s.formatting={...s.formatting,styleId:e.styleId},r}function Q(o){return o/1440*96}function Y(o){return o/96*1440}function Z(o){return o==null||isNaN(o)?0:Math.round(o*96/914400)}function E(o){return Math.round(o/96*914400)}function ee(o){return Math.round(o/914400*1440)}function te(o){return Math.round(o/1440*914400)}function ne(o){return o/72*96}function re(o){return o/144*96}function X(o,e=2){let r=Math.pow(10,e);return Math.round(o*r)/r}function oe(o){return `${X(o)}px`}function M(o,e){let r=h(o),n=r.package.document,t=[];for(let a=0;a<e.rows;a++){let p=[];for(let c=0;c<e.columns;c++){let u=e.data?.[a]?.[c]||"";p.push({type:"tableCell",content:[{type:"paragraph",content:u?[T(u)]:[]}]});}t.push({type:"tableRow",formatting:a===0&&e.hasHeader?{header:true}:void 0,cells:p});}let s={type:"table",rows:t},i=g(n,e.position.paragraphIndex);return i===-1?n.content.push(s):n.content.splice(i+1,0,s),r}function $(o,e){let r=h(o),n=r.package.document,t=g(n,e.position.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.position.paragraphIndex} not found`);let s=n.content[t],a={type:"run",content:[{type:"drawing",image:{type:"image",rId:`rId_img_${Date.now()}`,src:e.src,alt:e.alt,size:{width:E(e.width||100),height:E(e.height||100)},wrap:{type:"inline"}}}]},p=I(s,e.position.offset,"",void 0),c=false,u=0;for(let l=0;l<p.length;l++){let f=p[l];if(f.type==="run"){let m=f.content.filter(x=>x.type==="text").map(x=>x.text).join("");if(u+=m.length,!c&&u>=e.position.offset){p.splice(l+1,0,a),c=true;break}}}return c||p.push(a),s.content=p,r}function B(o,e){let r=h(o),n=r.package.document,{start:t,end:s}=e.range;if(t.paragraphIndex!==s.paragraphIndex)throw new Error("Hyperlinks cannot span multiple paragraphs");let i=g(n,t.paragraphIndex);if(i===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let a=n.content[i],p=y(a),c=e.displayText||p.slice(t.offset,s.offset);a.content=d(a,t.offset,s.offset);let u={type:"hyperlink",href:e.url,tooltip:e.tooltip,children:[T(c)]},l=false,f=0,m=[];for(let x of a.content)if(x.type==="run"){let b=x.content.filter(P=>P.type==="text").map(P=>P.text).join(""),H=f+b.length;if(!l&&f<=t.offset&&t.offset<=H){let P=t.offset-f;P>0&&m.push({...x,content:[{type:"text",text:b.slice(0,P)}]}),m.push(u),P<b.length&&m.push({...x,content:[{type:"text",text:b.slice(P)}]}),l=true;}else m.push(x);f=H;}else m.push(x);return l||m.push(u),a.content=m,r}function F(o,e){let r=h(o),n=r.package.document,{start:t}=e.range,s=g(n,t.paragraphIndex);if(s===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let i=n.content[s],a=[];for(let p of i.content)if(p.type==="hyperlink")for(let c of p.children)c.type==="run"&&a.push(c);else a.push(p);return i.content=a,r}function k(o,e){let r=h(o),n=r.package.document,t=g(n,e.position.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.position.paragraphIndex} not found`);let s=n.content[t],i=y(s),a=d({content:[...s.content]},e.position.offset,i.length),p=d({content:[...s.content]},0,e.position.offset);s.content=a;let c={type:"paragraph",formatting:s.formatting,content:p};return n.content.splice(t+1,0,c),r}function L(o,e){let r=h(o),n=r.package.document,t=g(n,e.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let s=n.content[t],i=[];for(let a=1;a<=e.count;a++){let p=g(n,e.paragraphIndex+a);if(p!==-1){let c=n.content[p];s.content.push(...c.content),i.push(p);}}for(let a=i.length-1;a>=0;a--)n.content.splice(i[a],1);return r}function V(o,e){return k(o,{position:e.position})}function z(o,e){let r=h(o);return r.templateVariables||(r.templateVariables=[]),r.templateVariables.includes(e.name)||r.templateVariables.push(e.name),r}function O(o,e){let r=h(o),n=r.package.document;function t(a){for(let p of a.content)if(p.type==="text")for(let[c,u]of Object.entries(e.values)){let l=new RegExp(`\\{${c}\\}`,"g");p.text=p.text.replace(l,u);}}function s(a){for(let p of a.content)if(p.type==="run")t(p);else if(p.type==="hyperlink")for(let c of p.children)c.type==="run"&&t(c);}function i(a){if(a.type==="paragraph")s(a);else if(a.type==="table")for(let p of a.rows)for(let c of p.cells)for(let u of c.content)i(u);}for(let a of n.content)i(a);return r}function j(o,e){let r=C.getCommandHandler(e.type);if(r)return r(o,e);switch(e.type){case "insertText":return R(o,e);case "replaceText":return _(o,e);case "deleteText":return v(o,e);case "formatText":return S(o,e);case "formatParagraph":return N(o,e);case "applyStyle":return A(o,e);case "insertTable":return M(o,e);case "insertImage":return $(o,e);case "insertHyperlink":return B(o,e);case "removeHyperlink":return F(o,e);case "insertParagraphBreak":return k(o,e);case "mergeParagraphs":return L(o,e);case "splitParagraph":return V(o,e);case "setVariable":return z(o,e);case "applyVariables":return O(o,e);default:{let n=e;throw new Error(`Unknown command type: ${n.type}`)}}}function Pe(o,e){return e.reduce((r,n)=>j(r,n),o)}exports.a=D;exports.b=C;exports.c=U;exports.d=W;exports.e=Q;exports.f=Y;exports.g=Z;exports.h=E;exports.i=ee;exports.j=te;exports.k=ne;exports.l=re;exports.m=oe;exports.n=j;exports.o=Pe;
@@ -0,0 +1 @@
1
+ 'use strict';var chunkRYHTROV6_js=require('./chunk-RYHTROV6.js'),chunk7JG2PH72_js=require('./chunk-7JG2PH72.js');function g(o,e){let{paragraphIndex:t,author:n="AI",text:s,search:a}=e,r=chunkRYHTROV6_js.b(o,t),i=(o.comments??[]).map(m=>m.id),p=i.length>0?Math.max(...i)+1:1,c={id:p,author:n,date:new Date().toISOString(),content:[{type:"paragraph",content:[{type:"run",content:[{type:"text",text:s}]}],formatting:{}}]};if(o.comments||(o.comments=[]),o.comments.push(c),a){let m=chunkRYHTROV6_js.i(r,a,t);r.content.splice(m.endRunIndex+1,0,{type:"commentRangeEnd",id:p}),r.content.splice(m.startRunIndex,0,{type:"commentRangeStart",id:p});}else r.content.unshift({type:"commentRangeStart",id:p}),r.content.push({type:"commentRangeEnd",id:p});return p}function y(o,e,t){let n=o.comments??[];if(!n.find(p=>p.id===e))throw new chunkRYHTROV6_js.h(e);let a=n.map(p=>p.id),r=Math.max(...a)+1,i={id:r,author:t.author??"AI",date:new Date().toISOString(),parentId:e,content:[{type:"paragraph",content:[{type:"run",content:[{type:"text",text:t.text}]}],formatting:{}}]};return n.push(i),r}function E(o,e){let t=o.comments??[],n=t.find(r=>r.id===e);if(!n)throw new chunkRYHTROV6_js.h(e);let s=n.parentId!==void 0,a=new Set([e]);if(!s)for(let r of t)r.parentId===e&&a.add(r.id);o.comments=t.filter(r=>!a.has(r.id)),!s&&chunkRYHTROV6_js.c(o,r=>{for(let i=r.content.length-1;i>=0;i--){let p=r.content[i];(p.type==="commentRangeStart"||p.type==="commentRangeEnd")&&p.id===e&&r.content.splice(i,1);}});}function C(o,e){if(!W(o,e,"accept"))throw new chunkRYHTROV6_js.g(e)}function I(o,e){if(!W(o,e,"reject"))throw new chunkRYHTROV6_js.g(e)}function k(o){return M(o,"accept")}function F(o){return M(o,"reject")}function M(o,e){let t=0;return chunkRYHTROV6_js.c(o,n=>{for(let s=n.content.length-1;s>=0;s--){let a=n.content[s];chunkRYHTROV6_js.a(a)&&(G(n,s,a,e),t++);}}),t}function W(o,e,t){let n=false;return chunkRYHTROV6_js.c(o,s=>{for(let a=s.content.length-1;a>=0;a--){let r=s.content[a];chunkRYHTROV6_js.a(r)&&r.info.id===e&&(G(s,a,r,t),n=true);}if(n)return false}),n}function G(o,e,t,n){if(t.type==="insertion"&&n==="accept"||t.type==="deletion"&&n==="reject"||t.type==="moveTo"&&n==="accept"||t.type==="moveFrom"&&n==="reject"){let a=t.content;o.content.splice(e,1,...a);}else o.content.splice(e,1);}function x(o,e){let{paragraphIndex:t,search:n,author:s="AI",replaceWith:a}=e,r=chunkRYHTROV6_js.b(o,t),{startIndex:i,endIndex:p}=chunkRYHTROV6_js.j(r,n,t),c=new Date().toISOString(),m=w(o),h=r.content.slice(i,p+1),R={type:"deletion",info:{id:m,author:s,date:c},content:h},v={type:"insertion",info:{id:m+1,author:s,date:c},content:[{type:"run",content:[{type:"text",text:a}]}]};r.content.splice(i,p-i+1,R,v);}function H(o,e){let{paragraphIndex:t,author:n="AI",insertText:s,position:a="after",search:r}=e,i=chunkRYHTROV6_js.b(o,t),p=new Date().toISOString(),m={type:"insertion",info:{id:w(o),author:n,date:p},content:[{type:"run",content:[{type:"text",text:s}]}]};if(r){let{startIndex:h,endIndex:R}=chunkRYHTROV6_js.j(i,r,t),v=a==="after"?R+1:h;i.content.splice(v,0,m);}else a==="before"?i.content.unshift(m):i.content.push(m);}function L(o,e){let{paragraphIndex:t,search:n,author:s="AI"}=e,a=chunkRYHTROV6_js.b(o,t),{startIndex:r,endIndex:i}=chunkRYHTROV6_js.j(a,n,t),p=new Date().toISOString(),c=w(o),m=a.content.slice(r,i+1),h={type:"deletion",info:{id:c,author:s,date:p},content:m};a.content.splice(r,i-r+1,h);}var S=new WeakMap;function w(o){let e=S.get(o);e===void 0&&(e=0,chunkRYHTROV6_js.c(o,n=>{for(let s of n.content)chunkRYHTROV6_js.a(s)&&(e=Math.max(e,s.info.id));}));let t=e+1;return S.set(o,t+1),t}function N(o,e,t="AI"){let n=[],s=0,a=0,r=0,i=0,p=0;for(let c of e.accept??[])try{C(o,c),s++;}catch(m){n.push({operation:"accept",id:c,error:m.message});}for(let c of e.reject??[])try{I(o,c),a++;}catch(m){n.push({operation:"reject",id:c,error:m.message});}for(let c of e.comments??[])try{g(o,{...c,author:c.author??t}),r++;}catch(m){n.push({operation:"comment",search:c.search,error:m.message});}for(let c of e.replies??[])try{y(o,c.commentId,{author:c.author??t,text:c.text}),i++;}catch(m){n.push({operation:"reply",id:c.commentId,error:m.message});}for(let c of e.proposals??[])try{x(o,{...c,author:c.author??t}),p++;}catch(m){n.push({operation:"proposal",search:c.search,error:m.message});}return {accepted:s,rejected:a,commentsAdded:r,repliesAdded:i,proposalsAdded:p,errors:n}}var U=class o{constructor(e,t="AI",n){let s=n??e.originalBuffer,{originalBuffer:a,...r}=e;this.doc=structuredClone(r),s&&(this.doc.originalBuffer=s),this.author=t;}static async fromBuffer(e,t="AI"){let n=await chunk7JG2PH72_js.w(e,{preloadFonts:false});return new o(n,t,e)}get body(){return this.doc.package.document}resolveAuthor(e){return e??this.author}getContent(e){return chunkRYHTROV6_js.d(this.body,e)}getContentAsText(e){return chunkRYHTROV6_js.e(chunkRYHTROV6_js.d(this.body,e))}getChanges(e){return chunkRYHTROV6_js.k(this.body,e)}getComments(e){return chunkRYHTROV6_js.l(this.body,e)}addComment(e,t){let n=typeof e=="number"?{paragraphIndex:e,text:t,author:this.author}:{...e,author:this.resolveAuthor(e.author)};return g(this.body,n)}replyTo(e,t){let n=typeof t=="string"?{text:t,author:this.author}:{...t,author:this.resolveAuthor(t.author)};return y(this.body,e,n)}removeComment(e){E(this.body,e);}replace(e,t,n){let s=typeof e=="number"?{paragraphIndex:e,search:t,replaceWith:n,author:this.author}:{...e,author:this.resolveAuthor(e.author)};x(this.body,s);}proposeReplacement(e){this.replace(e);}proposeInsertion(e){H(this.body,{...e,author:this.resolveAuthor(e.author)});}proposeDeletion(e){L(this.body,{...e,author:this.resolveAuthor(e.author)});}acceptChange(e){C(this.body,e);}rejectChange(e){I(this.body,e);}acceptAll(){return k(this.body)}rejectAll(){return F(this.body)}applyReview(e){return N(this.body,e,this.author)}toDocument(){return this.doc}async toBuffer(){if(!this.doc.originalBuffer)throw new Error("Cannot create buffer: no original DOCX buffer was provided. Use DocxReviewer.fromBuffer() or pass originalBuffer to the constructor.");let{repackDocx:e}=await import('./headless-U2SAKM5E.js');return e(this.doc)}};exports.a=U;
@@ -1,5 +1,5 @@
1
- 'use strict';var chunkG46D3GDJ_js=require('./chunk-G46D3GDJ.js');function h(s){return s.type==="insertion"||s.type==="deletion"||s.type==="moveFrom"||s.type==="moveTo"}function x(s){let n=[];for(let o of s)o.type==="run"?n.push(chunkG46D3GDJ_js.H(o)):o.type==="hyperlink"&&n.push(chunkG46D3GDJ_js.I(o));return n.join("")}function K(s,n){let o=0;for(let t of s.content)if(t.type==="paragraph"){if(o===n)return t;o++;}else if(t.type==="table"){for(let r of t.rows)for(let e of r.cells)for(let a of e.content)if(a.type==="paragraph"){if(o===n)return a;o++;}}else o++;throw new Error(`Paragraph index ${n} out of bounds (max: ${o-1})`)}function R(s,n){let o=0;for(let t of s.content)if(t.type==="paragraph"){if(n(t,o)===false)return;o++;}else if(t.type==="table"){for(let r of t.rows)for(let e of r.cells)for(let a of e.content)if(a.type==="paragraph"){if(n(a,o)===false)return;o++;}}else o++;}function V(s,n={}){let{fromIndex:o,toIndex:t,includeTrackedChanges:r=true,includeCommentAnchors:e=true}=n,a=[],i=0;for(let c of s.content)if(c.type==="paragraph")w(i,o,t)&&a.push(L(c,i,r,e)),i++;else if(c.type==="table"){w(i,o,t)&&a.push(H(c,i,r,e));for(let l of c.rows)for(let u of l.cells)for(let p of u.content)p.type==="paragraph"&&i++;}else i++;return a}function w(s,n,o){return (n===void 0||s>=n)&&(o===void 0||s<=o)}function L(s,n,o,t){let r=B(s,o,t),e=s.formatting?.styleId,a=s.paraId;return chunkG46D3GDJ_js.U(e)?{type:"heading",index:n,paraId:a,level:chunkG46D3GDJ_js.V(e)??1,text:r}:s.listRendering?{type:"list-item",index:n,paraId:a,text:r,listLevel:s.listRendering.level??0,listType:s.listRendering.isBullet?"bullet":"number"}:{type:"paragraph",index:n,paraId:a,text:r}}function H(s,n,o,t){let r=[],e=[];for(let a of s.rows){let i=[],c=[];for(let l of a.cells){let u=[],p;for(let g of l.content)g.type==="paragraph"&&(p===void 0&&(p=g.paraId),u.push(B(g,o,t)));i.push(u.join(`
1
+ 'use strict';var chunk7JG2PH72_js=require('./chunk-7JG2PH72.js');function h(s){return s.type==="insertion"||s.type==="deletion"||s.type==="moveFrom"||s.type==="moveTo"}function x(s){let n=[];for(let o of s)o.type==="run"?n.push(chunk7JG2PH72_js.H(o)):o.type==="hyperlink"&&n.push(chunk7JG2PH72_js.I(o));return n.join("")}function K(s,n){let o=0;for(let t of s.content)if(t.type==="paragraph"){if(o===n)return t;o++;}else if(t.type==="table"){for(let r of t.rows)for(let e of r.cells)for(let a of e.content)if(a.type==="paragraph"){if(o===n)return a;o++;}}else o++;throw new Error(`Paragraph index ${n} out of bounds (max: ${o-1})`)}function R(s,n){let o=0;for(let t of s.content)if(t.type==="paragraph"){if(n(t,o)===false)return;o++;}else if(t.type==="table"){for(let r of t.rows)for(let e of r.cells)for(let a of e.content)if(a.type==="paragraph"){if(n(a,o)===false)return;o++;}}else o++;}function V(s,n={}){let{fromIndex:o,toIndex:t,includeTrackedChanges:r=true,includeCommentAnchors:e=true}=n,a=[],i=0;for(let c of s.content)if(c.type==="paragraph")w(i,o,t)&&a.push(L(c,i,r,e)),i++;else if(c.type==="table"){w(i,o,t)&&a.push(H(c,i,r,e));for(let l of c.rows)for(let u of l.cells)for(let p of u.content)p.type==="paragraph"&&i++;}else i++;return a}function w(s,n,o){return (n===void 0||s>=n)&&(o===void 0||s<=o)}function L(s,n,o,t){let r=B(s,o,t),e=s.formatting?.styleId,a=s.paraId;return chunk7JG2PH72_js.U(e)?{type:"heading",index:n,paraId:a,level:chunk7JG2PH72_js.V(e)??1,text:r}:s.listRendering?{type:"list-item",index:n,paraId:a,text:r,listLevel:s.listRendering.level??0,listType:s.listRendering.isBullet?"bullet":"number"}:{type:"paragraph",index:n,paraId:a,text:r}}function H(s,n,o,t){let r=[],e=[];for(let a of s.rows){let i=[],c=[];for(let l of a.cells){let u=[],p;for(let g of l.content)g.type==="paragraph"&&(p===void 0&&(p=g.paraId),u.push(B(g,o,t)));i.push(u.join(`
2
2
  `)),c.push(p);}r.push(i),e.push(c);}return {type:"table",index:n,rows:r,cellParaIds:e}}function Y(s){let n=[],o=t=>t.paraId?t.paraId:String(t.index);for(let t of s)switch(t.type){case "heading":n.push(`[${o(t)}] (h${t.level}) ${t.text}`);break;case "paragraph":n.push(`[${o(t)}] ${t.text}`);break;case "list-item":{let r=" ".repeat(t.listLevel),e=t.listType==="bullet"?"\u2022":"-";n.push(`[${o(t)}] ${r}${e} ${t.text}`);break}case "table":{let r=t.index;for(let e=0;e<t.rows.length;e++)for(let a=0;a<t.rows[e].length;a++){let c=t.rows[e][a].split(`
3
3
  `),l=t.cellParaIds?.[e]?.[a];for(let u=0;u<c.length;u++){let p=u===0&&l?l:String(r);n.push(`[${p}] (table, row ${e+1}, col ${a+1}) ${c[u]}`),r++;}}break}}return n.join(`
4
- `)}function B(s,n,o){let t=[],r=new Set;for(let e of s.content){if(e.type==="commentRangeStart"&&o){r.add(e.id),t.push(`[comment:${e.id}]`);continue}if(e.type==="commentRangeEnd"&&o){r.has(e.id)&&(r.delete(e.id),t.push("[/comment]"));continue}if(e.type==="run")t.push(chunkG46D3GDJ_js.H(e));else if(e.type==="hyperlink")t.push(chunkG46D3GDJ_js.I(e));else if(h(e)){let a=x(e.content);e.type==="insertion"||e.type==="moveTo"?n&&t.push(`[+${a}+]{by:${e.info.author}}`):n?t.push(`[-${a}-]{by:${e.info.author}}`):t.push(a);}}return t.join("")}var y=class extends Error{constructor(n,o){let t=o!==void 0?` in paragraph ${o}`:" in document";super(`Text not found${t}: "${n}"`),this.name="TextNotFoundError";}},M=class extends Error{constructor(n){super(`Tracked change not found: id=${n}`),this.name="ChangeNotFoundError";}},F=class extends Error{constructor(n){super(`Comment not found: id=${n}`),this.name="CommentNotFoundError";}};function E(s){let n=[],o=0;for(let t=0;t<s.content.length;t++){let r=s.content[t];if(r.type==="run"){let e=chunkG46D3GDJ_js.H(r);n.push({contentIndex:t,run:r,text:e,startPos:o}),o+=e.length;}else if(r.type==="hyperlink")for(let e=0;e<r.children.length;e++){let a=r.children[e];if(a.type==="run"){let i=chunkG46D3GDJ_js.H(a);n.push({contentIndex:t,run:a,text:i,startPos:o}),o+=i.length;}}else if(h(r)){if(r.type==="insertion"||r.type==="moveTo")continue;for(let e=0;e<r.content.length;e++){let a=r.content[e];if(a.type==="run"){let i=chunkG46D3GDJ_js.H(a);n.push({contentIndex:t,run:a,text:i,startPos:o}),o+=i.length;}else if(a.type==="hyperlink"){for(let i of a.children)if(i.type==="run"){let c=chunkG46D3GDJ_js.H(i);n.push({contentIndex:t,run:i,text:c,startPos:o}),o+=c.length;}}}}}return n}function k(s){return E(s).map(n=>n.text).join("")}function G(s,n,o){let t=E(s),r=t.map(u=>u.text).join(""),e=W(r,n);if(!e)throw new y(n,o);let a=-1,i=0;for(let u=0;u<t.length;u++)if(e.start<t[u].startPos+t[u].text.length){a=u,i=e.start-t[u].startPos;break}let c=-1,l=0;for(let u=t.length-1;u>=0;u--)if(e.end>t[u].startPos){c=u,l=e.end-t[u].startPos;break}if(a===-1||c===-1)throw new y(n,o);return {startRunIndex:t[a].contentIndex,startOffset:i,endRunIndex:t[c].contentIndex,endOffset:l}}function te(s,n,o){let t=G(s,n,o),{startRunIndex:r,endRunIndex:e}=t,{startOffset:a,endOffset:i}=t,c=s.content[e];if(c.type==="run"){let u=chunkG46D3GDJ_js.H(c);if(i<u.length){let p=D(u.slice(i),c);$(c,u.slice(0,i)),s.content.splice(e+1,0,p);}}let l=s.content[r];if(l.type==="run"&&a>0){let u=chunkG46D3GDJ_js.H(l),p=D(u.slice(0,a),l);$(l,u.slice(a)),s.content.splice(r,0,p),r++,e++;}return {startIndex:r,endIndex:e}}function D(s,n){return {type:"run",content:[{type:"text",text:s}],formatting:n.formatting?{...n.formatting}:void 0}}function $(s,n){let o=s.content.find(t=>t.type==="text");o&&(o.text=n);}function O(s){let n=[],o=[],t=true;for(let r=0;r<s.length;r++){let e=s[r];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"){n.push(".",".","."),o.push(r,r,r),t=false;continue}if(/\s/.test(e)||e==="\xA0"){t||(n.push(" "),o.push(r),t=true);continue}n.push(e.toLowerCase()),o.push(r),t=false;}}return n.length>0&&n[n.length-1]===" "&&(n.pop(),o.pop()),{text:n.join(""),posMap:o}}function S(s,n,o,t){let r=s.posMap[n],e=s.posMap[n+o-1]+1;for(;e<t.length&&"\u200B\u200C\u200D\uFEFF\xAD".includes(t[e]);)e++;return {start:r,end:e}}function W(s,n){if(!n||!s)return null;let o=s.indexOf(n);if(o!==-1)return {start:o,end:o+n.length};let t=O(s),r=O(n);if(!r.text)return null;let e=t.text.indexOf(r.text);if(e!==-1)return S(t,e,r.text.length,s);let a=r.text.split(" ");if(a.length>=3)for(let i=1;i<=Math.min(2,a.length-2);i++){let c=a.slice(0,-i).join(" "),l=t.text.indexOf(c);if(l!==-1)return S(t,l,c.length,s)}return null}function se(s,n){let o=new Map;return R(s,(r,e)=>{let a=null;for(let i of r.content)if(h(i)){a===null&&(a=k(r));let c=x(i.content),l=i.info.id,u=o.get(l);u&&u.paragraphIndex===e?u.text+=c:o.set(l,{id:l,type:i.type,author:i.info.author,date:i.info.date??null,text:c,context:a,paragraphIndex:e});}}),Array.from(o.values()).filter(r=>!(n?.author&&r.author!==n.author||n?.type&&r.type!==n.type))}function ae(s,n){let o=s.comments??[];if(o.length===0)return [];let t=z(s),r=[],e=new Map;for(let i of o)if(i.parentId!==void 0){let c=e.get(i.parentId)??[];c.push(i),e.set(i.parentId,c);}else r.push(i);return r.map(i=>{let c=t.get(i.id),l=(e.get(i.id)??[]).map(u=>({id:u.id,author:u.author,date:u.date??null,text:A(u)}));return {id:i.id,author:i.author,date:i.date??null,text:A(i),anchoredText:c?.text??"",paragraphIndex:c?.paragraphIndex??-1,replies:l,done:i.done??false}}).filter(i=>!(n?.author&&i.author!==n.author||n?.done!==void 0&&i.done!==n.done))}function A(s){return s.content.map(n=>k(n)).join(`
5
- `)}function z(s){let n=new Map,o=new Map;return R(s,(t,r)=>{for(let e of t.content)if(e.type==="commentRangeStart")o.set(e.id,{paragraphIndex:r,parts:[]});else if(e.type==="commentRangeEnd"){let a=o.get(e.id);a&&(n.set(e.id,{text:a.parts.join(""),paragraphIndex:a.paragraphIndex}),o.delete(e.id));}else if(e.type==="run"){let a=chunkG46D3GDJ_js.H(e);for(let i of o.values())i.parts.push(a);}else if(e.type==="hyperlink"){let a=e.children.filter(i=>i.type==="run").map(chunkG46D3GDJ_js.H).join("");for(let i of o.values())i.parts.push(a);}else if(h(e)){if(e.type==="insertion"||e.type==="moveTo")continue;let a=x(e.content);for(let i of o.values())i.parts.push(a);}}),n}function N(s){let n=s.toDocument().package?.document;if(!n)return new Map;let o=new Map,t=0;for(let r of n.content)if(r.type==="paragraph"){let e=r.paraId;e&&o.set(e,t),t++;}else if(r.type==="table")for(let e of r.rows)for(let a of e.cells)for(let i of a.content)i.type==="paragraph"&&t++;else t++;return o}function X(s){let n=[],o=t=>{for(let r of t.content)r.type==="text"&&n.push(r.text??"");};for(let t of s.content)if(t.type==="run")o(t);else if(t.type==="hyperlink")for(let r of t.children)r.type==="run"&&o(r);else if(t.type==="deletion"||t.type==="moveFrom"){for(let r of t.content)if(r.type==="run")o(r);else if(r.type==="hyperlink")for(let e of r.children)e.type==="run"&&o(e);}return n.join("")}function ce(s){let n=new Set,o=null;function t(){return o===null&&(o=N(s)),o}function r(){if(n.size===0)return;let e=s.getComments(),a=s.getChanges(),i={commentCount:e.length,changeCount:a.length,comments:e,changes:a};for(let c of n)try{c(i);}catch(l){console.error("reviewerBridge content listener threw:",l);}}return {getContentAsText(e){return s.getContentAsText(e)},getContent(e){return s.getContent(e)},getComments(e){return s.getComments(e)},getChanges(e){return s.getChanges(e)},findText(e,a){if(!e)return [];let i=a?.caseSensitive??false,c=a?.limit??20,l=i?e:e.toLowerCase(),u=s.toDocument().package?.document;if(!u)return [];let p=[],g=40;for(let P of u.content){if(p.length>=c)break;if(P.type!=="paragraph")continue;let C=P;if(!C.paraId)continue;let m=X(C),v=i?m:m.toLowerCase(),d=v.indexOf(l);if(d===-1||v.indexOf(l,d+1)!==-1)continue;let j=m.slice(d,d+e.length);p.push({paraId:C.paraId,match:j,before:m.slice(Math.max(0,d-g),d),after:m.slice(d+e.length,d+e.length+g)});}return p},getSelection(){return null},addComment(e){let a=t().get(e.paraId);if(a===void 0)return null;try{let i=s.addComment({paragraphIndex:a,text:e.text,author:e.author,search:e.search});return r(),i}catch{return null}},replyTo(e,a){try{let i=s.replyTo(e,a);return r(),i}catch{return null}},resolveComment(e){let i=s.toDocument().package?.document?.comments?.find(c=>c.id===e);i&&(i.done=true,r());},proposeChange(e){let a=t().get(e.paraId);if(a===void 0)return false;let i=e.search==="",c=e.replaceWith==="";if(i&&c)return false;try{return i?s.proposeInsertion({paragraphIndex:a,insertText:e.replaceWith,author:e.author}):c?s.proposeDeletion({paragraphIndex:a,search:e.search,author:e.author}):s.replace({paragraphIndex:a,search:e.search,replaceWith:e.replaceWith,author:e.author}),r(),true}catch{return false}},scrollTo(e){return t().has(e)},applyFormatting(){return false},setParagraphStyle(){return false},getPage(){return null},getPages(){return []},getTotalPages(){return 0},getCurrentPage(){return 0},onContentChange(e){return n.add(e),()=>{n.delete(e);}},onSelectionChange(){return ()=>{}}}}exports.a=h;exports.b=K;exports.c=R;exports.d=V;exports.e=Y;exports.f=y;exports.g=M;exports.h=F;exports.i=G;exports.j=te;exports.k=se;exports.l=ae;exports.m=ce;
4
+ `)}function B(s,n,o){let t=[],r=new Set;for(let e of s.content){if(e.type==="commentRangeStart"&&o){r.add(e.id),t.push(`[comment:${e.id}]`);continue}if(e.type==="commentRangeEnd"&&o){r.has(e.id)&&(r.delete(e.id),t.push("[/comment]"));continue}if(e.type==="run")t.push(chunk7JG2PH72_js.H(e));else if(e.type==="hyperlink")t.push(chunk7JG2PH72_js.I(e));else if(h(e)){let a=x(e.content);e.type==="insertion"||e.type==="moveTo"?n&&t.push(`[+${a}+]{by:${e.info.author}}`):n?t.push(`[-${a}-]{by:${e.info.author}}`):t.push(a);}}return t.join("")}var y=class extends Error{constructor(n,o){let t=o!==void 0?` in paragraph ${o}`:" in document";super(`Text not found${t}: "${n}"`),this.name="TextNotFoundError";}},M=class extends Error{constructor(n){super(`Tracked change not found: id=${n}`),this.name="ChangeNotFoundError";}},F=class extends Error{constructor(n){super(`Comment not found: id=${n}`),this.name="CommentNotFoundError";}};function E(s){let n=[],o=0;for(let t=0;t<s.content.length;t++){let r=s.content[t];if(r.type==="run"){let e=chunk7JG2PH72_js.H(r);n.push({contentIndex:t,run:r,text:e,startPos:o}),o+=e.length;}else if(r.type==="hyperlink")for(let e=0;e<r.children.length;e++){let a=r.children[e];if(a.type==="run"){let i=chunk7JG2PH72_js.H(a);n.push({contentIndex:t,run:a,text:i,startPos:o}),o+=i.length;}}else if(h(r)){if(r.type==="insertion"||r.type==="moveTo")continue;for(let e=0;e<r.content.length;e++){let a=r.content[e];if(a.type==="run"){let i=chunk7JG2PH72_js.H(a);n.push({contentIndex:t,run:a,text:i,startPos:o}),o+=i.length;}else if(a.type==="hyperlink"){for(let i of a.children)if(i.type==="run"){let c=chunk7JG2PH72_js.H(i);n.push({contentIndex:t,run:i,text:c,startPos:o}),o+=c.length;}}}}}return n}function k(s){return E(s).map(n=>n.text).join("")}function G(s,n,o){let t=E(s),r=t.map(u=>u.text).join(""),e=W(r,n);if(!e)throw new y(n,o);let a=-1,i=0;for(let u=0;u<t.length;u++)if(e.start<t[u].startPos+t[u].text.length){a=u,i=e.start-t[u].startPos;break}let c=-1,l=0;for(let u=t.length-1;u>=0;u--)if(e.end>t[u].startPos){c=u,l=e.end-t[u].startPos;break}if(a===-1||c===-1)throw new y(n,o);return {startRunIndex:t[a].contentIndex,startOffset:i,endRunIndex:t[c].contentIndex,endOffset:l}}function te(s,n,o){let t=G(s,n,o),{startRunIndex:r,endRunIndex:e}=t,{startOffset:a,endOffset:i}=t,c=s.content[e];if(c.type==="run"){let u=chunk7JG2PH72_js.H(c);if(i<u.length){let p=D(u.slice(i),c);$(c,u.slice(0,i)),s.content.splice(e+1,0,p);}}let l=s.content[r];if(l.type==="run"&&a>0){let u=chunk7JG2PH72_js.H(l),p=D(u.slice(0,a),l);$(l,u.slice(a)),s.content.splice(r,0,p),r++,e++;}return {startIndex:r,endIndex:e}}function D(s,n){return {type:"run",content:[{type:"text",text:s}],formatting:n.formatting?{...n.formatting}:void 0}}function $(s,n){let o=s.content.find(t=>t.type==="text");o&&(o.text=n);}function O(s){let n=[],o=[],t=true;for(let r=0;r<s.length;r++){let e=s[r];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"){n.push(".",".","."),o.push(r,r,r),t=false;continue}if(/\s/.test(e)||e==="\xA0"){t||(n.push(" "),o.push(r),t=true);continue}n.push(e.toLowerCase()),o.push(r),t=false;}}return n.length>0&&n[n.length-1]===" "&&(n.pop(),o.pop()),{text:n.join(""),posMap:o}}function S(s,n,o,t){let r=s.posMap[n],e=s.posMap[n+o-1]+1;for(;e<t.length&&"\u200B\u200C\u200D\uFEFF\xAD".includes(t[e]);)e++;return {start:r,end:e}}function W(s,n){if(!n||!s)return null;let o=s.indexOf(n);if(o!==-1)return {start:o,end:o+n.length};let t=O(s),r=O(n);if(!r.text)return null;let e=t.text.indexOf(r.text);if(e!==-1)return S(t,e,r.text.length,s);let a=r.text.split(" ");if(a.length>=3)for(let i=1;i<=Math.min(2,a.length-2);i++){let c=a.slice(0,-i).join(" "),l=t.text.indexOf(c);if(l!==-1)return S(t,l,c.length,s)}return null}function se(s,n){let o=new Map;return R(s,(r,e)=>{let a=null;for(let i of r.content)if(h(i)){a===null&&(a=k(r));let c=x(i.content),l=i.info.id,u=o.get(l);u&&u.paragraphIndex===e?u.text+=c:o.set(l,{id:l,type:i.type,author:i.info.author,date:i.info.date??null,text:c,context:a,paragraphIndex:e});}}),Array.from(o.values()).filter(r=>!(n?.author&&r.author!==n.author||n?.type&&r.type!==n.type))}function ae(s,n){let o=s.comments??[];if(o.length===0)return [];let t=z(s),r=[],e=new Map;for(let i of o)if(i.parentId!==void 0){let c=e.get(i.parentId)??[];c.push(i),e.set(i.parentId,c);}else r.push(i);return r.map(i=>{let c=t.get(i.id),l=(e.get(i.id)??[]).map(u=>({id:u.id,author:u.author,date:u.date??null,text:A(u)}));return {id:i.id,author:i.author,date:i.date??null,text:A(i),anchoredText:c?.text??"",paragraphIndex:c?.paragraphIndex??-1,replies:l,done:i.done??false}}).filter(i=>!(n?.author&&i.author!==n.author||n?.done!==void 0&&i.done!==n.done))}function A(s){return s.content.map(n=>k(n)).join(`
5
+ `)}function z(s){let n=new Map,o=new Map;return R(s,(t,r)=>{for(let e of t.content)if(e.type==="commentRangeStart")o.set(e.id,{paragraphIndex:r,parts:[]});else if(e.type==="commentRangeEnd"){let a=o.get(e.id);a&&(n.set(e.id,{text:a.parts.join(""),paragraphIndex:a.paragraphIndex}),o.delete(e.id));}else if(e.type==="run"){let a=chunk7JG2PH72_js.H(e);for(let i of o.values())i.parts.push(a);}else if(e.type==="hyperlink"){let a=e.children.filter(i=>i.type==="run").map(chunk7JG2PH72_js.H).join("");for(let i of o.values())i.parts.push(a);}else if(h(e)){if(e.type==="insertion"||e.type==="moveTo")continue;let a=x(e.content);for(let i of o.values())i.parts.push(a);}}),n}function N(s){let n=s.toDocument().package?.document;if(!n)return new Map;let o=new Map,t=0;for(let r of n.content)if(r.type==="paragraph"){let e=r.paraId;e&&o.set(e,t),t++;}else if(r.type==="table")for(let e of r.rows)for(let a of e.cells)for(let i of a.content)i.type==="paragraph"&&t++;else t++;return o}function X(s){let n=[],o=t=>{for(let r of t.content)r.type==="text"&&n.push(r.text??"");};for(let t of s.content)if(t.type==="run")o(t);else if(t.type==="hyperlink")for(let r of t.children)r.type==="run"&&o(r);else if(t.type==="deletion"||t.type==="moveFrom"){for(let r of t.content)if(r.type==="run")o(r);else if(r.type==="hyperlink")for(let e of r.children)e.type==="run"&&o(e);}return n.join("")}function ce(s){let n=new Set,o=null;function t(){return o===null&&(o=N(s)),o}function r(){if(n.size===0)return;let e=s.getComments(),a=s.getChanges(),i={commentCount:e.length,changeCount:a.length,comments:e,changes:a};for(let c of n)try{c(i);}catch(l){console.error("reviewerBridge content listener threw:",l);}}return {getContentAsText(e){return s.getContentAsText(e)},getContent(e){return s.getContent(e)},getComments(e){return s.getComments(e)},getChanges(e){return s.getChanges(e)},findText(e,a){if(!e)return [];let i=a?.caseSensitive??false,c=a?.limit??20,l=i?e:e.toLowerCase(),u=s.toDocument().package?.document;if(!u)return [];let p=[],g=40;for(let P of u.content){if(p.length>=c)break;if(P.type!=="paragraph")continue;let C=P;if(!C.paraId)continue;let m=X(C),v=i?m:m.toLowerCase(),d=v.indexOf(l);if(d===-1||v.indexOf(l,d+1)!==-1)continue;let j=m.slice(d,d+e.length);p.push({paraId:C.paraId,match:j,before:m.slice(Math.max(0,d-g),d),after:m.slice(d+e.length,d+e.length+g)});}return p},getSelection(){return null},addComment(e){let a=t().get(e.paraId);if(a===void 0)return null;try{let i=s.addComment({paragraphIndex:a,text:e.text,author:e.author,search:e.search});return r(),i}catch{return null}},replyTo(e,a){try{let i=s.replyTo(e,a);return r(),i}catch{return null}},resolveComment(e){let i=s.toDocument().package?.document?.comments?.find(c=>c.id===e);i&&(i.done=true,r());},proposeChange(e){let a=t().get(e.paraId);if(a===void 0)return false;let i=e.search==="",c=e.replaceWith==="";if(i&&c)return false;try{return i?s.proposeInsertion({paragraphIndex:a,insertText:e.replaceWith,author:e.author}):c?s.proposeDeletion({paragraphIndex:a,search:e.search,author:e.author}):s.replace({paragraphIndex:a,search:e.search,replaceWith:e.replaceWith,author:e.author}),r(),true}catch{return false}},scrollTo(e){return t().has(e)},applyFormatting(){return false},setParagraphStyle(){return false},getPage(){return null},getPages(){return []},getTotalPages(){return 0},getCurrentPage(){return 0},onContentChange(e){return n.add(e),()=>{n.delete(e);}},onSelectionChange(){return ()=>{}}}}exports.a=h;exports.b=K;exports.c=R;exports.d=V;exports.e=Y;exports.f=y;exports.g=M;exports.h=F;exports.i=G;exports.j=te;exports.k=se;exports.l=ae;exports.m=ce;
@@ -1,4 +1,4 @@
1
- import {U,V as V$1,H as H$1,I}from'./chunk-XZHZXQO5.mjs';function h(s){return s.type==="insertion"||s.type==="deletion"||s.type==="moveFrom"||s.type==="moveTo"}function x(s){let n=[];for(let o of s)o.type==="run"?n.push(H$1(o)):o.type==="hyperlink"&&n.push(I(o));return n.join("")}function K(s,n){let o=0;for(let t of s.content)if(t.type==="paragraph"){if(o===n)return t;o++;}else if(t.type==="table"){for(let r of t.rows)for(let e of r.cells)for(let a of e.content)if(a.type==="paragraph"){if(o===n)return a;o++;}}else o++;throw new Error(`Paragraph index ${n} out of bounds (max: ${o-1})`)}function R(s,n){let o=0;for(let t of s.content)if(t.type==="paragraph"){if(n(t,o)===false)return;o++;}else if(t.type==="table"){for(let r of t.rows)for(let e of r.cells)for(let a of e.content)if(a.type==="paragraph"){if(n(a,o)===false)return;o++;}}else o++;}function V(s,n={}){let{fromIndex:o,toIndex:t,includeTrackedChanges:r=true,includeCommentAnchors:e=true}=n,a=[],i=0;for(let c of s.content)if(c.type==="paragraph")w(i,o,t)&&a.push(L(c,i,r,e)),i++;else if(c.type==="table"){w(i,o,t)&&a.push(H(c,i,r,e));for(let l of c.rows)for(let u of l.cells)for(let p of u.content)p.type==="paragraph"&&i++;}else i++;return a}function w(s,n,o){return (n===void 0||s>=n)&&(o===void 0||s<=o)}function L(s,n,o,t){let r=B(s,o,t),e=s.formatting?.styleId,a=s.paraId;return U(e)?{type:"heading",index:n,paraId:a,level:V$1(e)??1,text:r}:s.listRendering?{type:"list-item",index:n,paraId:a,text:r,listLevel:s.listRendering.level??0,listType:s.listRendering.isBullet?"bullet":"number"}:{type:"paragraph",index:n,paraId:a,text:r}}function H(s,n,o,t){let r=[],e=[];for(let a of s.rows){let i=[],c=[];for(let l of a.cells){let u=[],p;for(let g of l.content)g.type==="paragraph"&&(p===void 0&&(p=g.paraId),u.push(B(g,o,t)));i.push(u.join(`
1
+ import {U,V as V$1,H as H$1,I}from'./chunk-D3TF6WTP.mjs';function h(s){return s.type==="insertion"||s.type==="deletion"||s.type==="moveFrom"||s.type==="moveTo"}function x(s){let n=[];for(let o of s)o.type==="run"?n.push(H$1(o)):o.type==="hyperlink"&&n.push(I(o));return n.join("")}function K(s,n){let o=0;for(let t of s.content)if(t.type==="paragraph"){if(o===n)return t;o++;}else if(t.type==="table"){for(let r of t.rows)for(let e of r.cells)for(let a of e.content)if(a.type==="paragraph"){if(o===n)return a;o++;}}else o++;throw new Error(`Paragraph index ${n} out of bounds (max: ${o-1})`)}function R(s,n){let o=0;for(let t of s.content)if(t.type==="paragraph"){if(n(t,o)===false)return;o++;}else if(t.type==="table"){for(let r of t.rows)for(let e of r.cells)for(let a of e.content)if(a.type==="paragraph"){if(n(a,o)===false)return;o++;}}else o++;}function V(s,n={}){let{fromIndex:o,toIndex:t,includeTrackedChanges:r=true,includeCommentAnchors:e=true}=n,a=[],i=0;for(let c of s.content)if(c.type==="paragraph")w(i,o,t)&&a.push(L(c,i,r,e)),i++;else if(c.type==="table"){w(i,o,t)&&a.push(H(c,i,r,e));for(let l of c.rows)for(let u of l.cells)for(let p of u.content)p.type==="paragraph"&&i++;}else i++;return a}function w(s,n,o){return (n===void 0||s>=n)&&(o===void 0||s<=o)}function L(s,n,o,t){let r=B(s,o,t),e=s.formatting?.styleId,a=s.paraId;return U(e)?{type:"heading",index:n,paraId:a,level:V$1(e)??1,text:r}:s.listRendering?{type:"list-item",index:n,paraId:a,text:r,listLevel:s.listRendering.level??0,listType:s.listRendering.isBullet?"bullet":"number"}:{type:"paragraph",index:n,paraId:a,text:r}}function H(s,n,o,t){let r=[],e=[];for(let a of s.rows){let i=[],c=[];for(let l of a.cells){let u=[],p;for(let g of l.content)g.type==="paragraph"&&(p===void 0&&(p=g.paraId),u.push(B(g,o,t)));i.push(u.join(`
2
2
  `)),c.push(p);}r.push(i),e.push(c);}return {type:"table",index:n,rows:r,cellParaIds:e}}function Y(s){let n=[],o=t=>t.paraId?t.paraId:String(t.index);for(let t of s)switch(t.type){case "heading":n.push(`[${o(t)}] (h${t.level}) ${t.text}`);break;case "paragraph":n.push(`[${o(t)}] ${t.text}`);break;case "list-item":{let r=" ".repeat(t.listLevel),e=t.listType==="bullet"?"\u2022":"-";n.push(`[${o(t)}] ${r}${e} ${t.text}`);break}case "table":{let r=t.index;for(let e=0;e<t.rows.length;e++)for(let a=0;a<t.rows[e].length;a++){let c=t.rows[e][a].split(`
3
3
  `),l=t.cellParaIds?.[e]?.[a];for(let u=0;u<c.length;u++){let p=u===0&&l?l:String(r);n.push(`[${p}] (table, row ${e+1}, col ${a+1}) ${c[u]}`),r++;}}break}}return n.join(`
4
4
  `)}function B(s,n,o){let t=[],r=new Set;for(let e of s.content){if(e.type==="commentRangeStart"&&o){r.add(e.id),t.push(`[comment:${e.id}]`);continue}if(e.type==="commentRangeEnd"&&o){r.has(e.id)&&(r.delete(e.id),t.push("[/comment]"));continue}if(e.type==="run")t.push(H$1(e));else if(e.type==="hyperlink")t.push(I(e));else if(h(e)){let a=x(e.content);e.type==="insertion"||e.type==="moveTo"?n&&t.push(`[+${a}+]{by:${e.info.author}}`):n?t.push(`[-${a}-]{by:${e.info.author}}`):t.push(a);}}return t.join("")}var y=class extends Error{constructor(n,o){let t=o!==void 0?` in paragraph ${o}`:" in document";super(`Text not found${t}: "${n}"`),this.name="TextNotFoundError";}},M=class extends Error{constructor(n){super(`Tracked change not found: id=${n}`),this.name="ChangeNotFoundError";}},F=class extends Error{constructor(n){super(`Comment not found: id=${n}`),this.name="CommentNotFoundError";}};function E(s){let n=[],o=0;for(let t=0;t<s.content.length;t++){let r=s.content[t];if(r.type==="run"){let e=H$1(r);n.push({contentIndex:t,run:r,text:e,startPos:o}),o+=e.length;}else if(r.type==="hyperlink")for(let e=0;e<r.children.length;e++){let a=r.children[e];if(a.type==="run"){let i=H$1(a);n.push({contentIndex:t,run:a,text:i,startPos:o}),o+=i.length;}}else if(h(r)){if(r.type==="insertion"||r.type==="moveTo")continue;for(let e=0;e<r.content.length;e++){let a=r.content[e];if(a.type==="run"){let i=H$1(a);n.push({contentIndex:t,run:a,text:i,startPos:o}),o+=i.length;}else if(a.type==="hyperlink"){for(let i of a.children)if(i.type==="run"){let c=H$1(i);n.push({contentIndex:t,run:i,text:c,startPos:o}),o+=c.length;}}}}}return n}function k(s){return E(s).map(n=>n.text).join("")}function G(s,n,o){let t=E(s),r=t.map(u=>u.text).join(""),e=W(r,n);if(!e)throw new y(n,o);let a=-1,i=0;for(let u=0;u<t.length;u++)if(e.start<t[u].startPos+t[u].text.length){a=u,i=e.start-t[u].startPos;break}let c=-1,l=0;for(let u=t.length-1;u>=0;u--)if(e.end>t[u].startPos){c=u,l=e.end-t[u].startPos;break}if(a===-1||c===-1)throw new y(n,o);return {startRunIndex:t[a].contentIndex,startOffset:i,endRunIndex:t[c].contentIndex,endOffset:l}}function te(s,n,o){let t=G(s,n,o),{startRunIndex:r,endRunIndex:e}=t,{startOffset:a,endOffset:i}=t,c=s.content[e];if(c.type==="run"){let u=H$1(c);if(i<u.length){let p=D(u.slice(i),c);$(c,u.slice(0,i)),s.content.splice(e+1,0,p);}}let l=s.content[r];if(l.type==="run"&&a>0){let u=H$1(l),p=D(u.slice(0,a),l);$(l,u.slice(a)),s.content.splice(r,0,p),r++,e++;}return {startIndex:r,endIndex:e}}function D(s,n){return {type:"run",content:[{type:"text",text:s}],formatting:n.formatting?{...n.formatting}:void 0}}function $(s,n){let o=s.content.find(t=>t.type==="text");o&&(o.text=n);}function O(s){let n=[],o=[],t=true;for(let r=0;r<s.length;r++){let e=s[r];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"){n.push(".",".","."),o.push(r,r,r),t=false;continue}if(/\s/.test(e)||e==="\xA0"){t||(n.push(" "),o.push(r),t=true);continue}n.push(e.toLowerCase()),o.push(r),t=false;}}return n.length>0&&n[n.length-1]===" "&&(n.pop(),o.pop()),{text:n.join(""),posMap:o}}function S(s,n,o,t){let r=s.posMap[n],e=s.posMap[n+o-1]+1;for(;e<t.length&&"\u200B\u200C\u200D\uFEFF\xAD".includes(t[e]);)e++;return {start:r,end:e}}function W(s,n){if(!n||!s)return null;let o=s.indexOf(n);if(o!==-1)return {start:o,end:o+n.length};let t=O(s),r=O(n);if(!r.text)return null;let e=t.text.indexOf(r.text);if(e!==-1)return S(t,e,r.text.length,s);let a=r.text.split(" ");if(a.length>=3)for(let i=1;i<=Math.min(2,a.length-2);i++){let c=a.slice(0,-i).join(" "),l=t.text.indexOf(c);if(l!==-1)return S(t,l,c.length,s)}return null}function se(s,n){let o=new Map;return R(s,(r,e)=>{let a=null;for(let i of r.content)if(h(i)){a===null&&(a=k(r));let c=x(i.content),l=i.info.id,u=o.get(l);u&&u.paragraphIndex===e?u.text+=c:o.set(l,{id:l,type:i.type,author:i.info.author,date:i.info.date??null,text:c,context:a,paragraphIndex:e});}}),Array.from(o.values()).filter(r=>!(n?.author&&r.author!==n.author||n?.type&&r.type!==n.type))}function ae(s,n){let o=s.comments??[];if(o.length===0)return [];let t=z(s),r=[],e=new Map;for(let i of o)if(i.parentId!==void 0){let c=e.get(i.parentId)??[];c.push(i),e.set(i.parentId,c);}else r.push(i);return r.map(i=>{let c=t.get(i.id),l=(e.get(i.id)??[]).map(u=>({id:u.id,author:u.author,date:u.date??null,text:A(u)}));return {id:i.id,author:i.author,date:i.date??null,text:A(i),anchoredText:c?.text??"",paragraphIndex:c?.paragraphIndex??-1,replies:l,done:i.done??false}}).filter(i=>!(n?.author&&i.author!==n.author||n?.done!==void 0&&i.done!==n.done))}function A(s){return s.content.map(n=>k(n)).join(`
@@ -0,0 +1 @@
1
+ var D=class{constructor(){this.plugins=new Map;this.commandHandlers=new Map;this.eventListeners=new Set;this.initialized=new Set;}register(e,r){let n=[];if(!e.id)return {success:false,error:"Plugin must have an id"};if(this.plugins.has(e.id))return {success:false,error:`Plugin '${e.id}' is already registered`};if(e.dependencies){for(let t of e.dependencies)if(!this.plugins.has(t))return {success:false,error:`Plugin '${e.id}' requires '${t}' which is not registered`}}if(e.commandHandlers)for(let[t,s]of Object.entries(e.commandHandlers)){if(this.commandHandlers.has(t)){let i=this.commandHandlers.get(t);n.push(`Command '${t}' from '${e.id}' overrides handler from '${i.pluginId}'`);}this.commandHandlers.set(t,{pluginId:e.id,handler:s});}if(this.plugins.set(e.id,e),e.initialize&&!this.initialized.has(e.id))try{let t=e.initialize();t instanceof Promise?t.then(()=>{this.initialized.add(e.id);}).catch(s=>{this.emit({type:"error",pluginId:e.id,error:s});}):this.initialized.add(e.id);}catch(t){this.emit({type:"error",pluginId:e.id,error:t});}return r?.debug&&console.log(`[PluginRegistry] Registered plugin: ${e.id}`),this.emit({type:"registered",plugin:e}),{success:true,plugin:e,warnings:n.length>0?n:void 0}}unregister(e){let r=this.plugins.get(e);if(!r)return false;for(let[n,t]of this.plugins)if(t.dependencies?.includes(e))return console.warn(`Cannot unregister '${e}': '${n}' depends on it`),false;for(let[n,{pluginId:t}]of this.commandHandlers)t===e&&this.commandHandlers.delete(n);if(r.destroy)try{let n=r.destroy();n instanceof Promise&&n.catch(t=>{this.emit({type:"error",pluginId:e,error:t});});}catch(n){this.emit({type:"error",pluginId:e,error:n});}return this.plugins.delete(e),this.initialized.delete(e),this.emit({type:"unregistered",pluginId:e}),true}get(e){return this.plugins.get(e)}getAll(){return Array.from(this.plugins.values())}has(e){return this.plugins.has(e)}get size(){return this.plugins.size}getCommandHandler(e){return this.commandHandlers.get(e)?.handler}getCommandTypes(){return Array.from(this.commandHandlers.keys())}hasCommandHandler(e){return this.commandHandlers.has(e)}getMcpTools(){let e=[];for(let r of this.plugins.values())r.mcpTools&&e.push(...r.mcpTools);return e}getMcpToolsForPlugin(e){return this.plugins.get(e)?.mcpTools||[]}getMcpTool(e){for(let r of this.plugins.values())if(r.mcpTools){let n=r.mcpTools.find(t=>t.name===e);if(n)return n}}addEventListener(e){this.eventListeners.add(e);}removeEventListener(e){this.eventListeners.delete(e);}emit(e){for(let r of this.eventListeners)try{r(e);}catch(n){console.error("[PluginRegistry] Event listener error:",n);}}clear(){for(let e of this.plugins.values())if(e.destroy)try{e.destroy();}catch{}this.plugins.clear(),this.commandHandlers.clear(),this.initialized.clear();}getDebugInfo(){return {plugins:Array.from(this.plugins.keys()),commandTypes:Array.from(this.commandHandlers.keys()),mcpTools:this.getMcpTools().map(e=>e.name),initialized:Array.from(this.initialized)}}},C=new D;function U(o,e){return o.map(r=>C.register(r,e))}function W(o){return e=>C.register(e,o)}function h(o){return JSON.parse(JSON.stringify(o))}function g(o,e){let r=0;for(let n=0;n<o.content.length;n++)if(o.content[n].type==="paragraph"){if(r===e)return n;r++;}return -1}function y(o){let e="";for(let r of o.content)if(r.type==="run")for(let n of r.content)n.type==="text"&&(e+=n.text);else if(r.type==="hyperlink"){for(let n of r.children)if(n.type==="run")for(let t of n.content)t.type==="text"&&(e+=t.text);}return e}function T(o,e){return {type:"run",formatting:e,content:[{type:"text",text:o}]}}function I(o,e,r,n){let t=[],s=0,i=false;for(let a of o.content)if(a.type==="run"){let p=a.content.filter(l=>l.type==="text").map(l=>l.text).join(""),c=s,u=s+p.length;if(!i&&e>=c&&e<=u){let l=e-c;l>0&&t.push({...a,content:[{type:"text",text:p.slice(0,l)}]}),t.push(T(r,n||a.formatting)),l<p.length&&t.push({...a,content:[{type:"text",text:p.slice(l)}]}),i=true;}else t.push(a);s=u;}else t.push(a);return i||t.push(T(r,n)),t}function d(o,e,r){let n=[],t=0;for(let s of o.content)if(s.type==="run"){let i=s.content.filter(c=>c.type==="text").map(c=>c.text).join(""),a=t,p=t+i.length;if(p<=e||a>=r)n.push(s);else {let c="";a<e&&(c+=i.slice(0,e-a)),p>r&&(c+=i.slice(r-a)),c.length>0&&n.push({...s,content:[{type:"text",text:c}]});}t=p;}else n.push(s);return n}function w(o,e,r,n){let t=[],s=0;for(let i of o.content)if(i.type==="run"){let a=i.content.filter(u=>u.type==="text").map(u=>u.text).join(""),p=s,c=s+a.length;if(c<=e||p>=r)t.push(i);else if(p>=e&&c<=r)t.push({...i,formatting:{...i.formatting,...n}});else {let u=Math.max(e,p),l=Math.min(r,c);p<u&&t.push({...i,content:[{type:"text",text:a.slice(0,u-p)}]}),t.push({...i,formatting:{...i.formatting,...n},content:[{type:"text",text:a.slice(u-p,l-p)}]}),c>l&&t.push({...i,content:[{type:"text",text:a.slice(l-p)}]});}s=c;}else t.push(i);return t}function R(o,e){let r=h(o),n=r.package.document,t=g(n,e.position.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.position.paragraphIndex} not found`);let s=n.content[t];return s.content=I(s,e.position.offset,e.text,e.formatting),r}function _(o,e){let r=h(o),n=r.package.document,{start:t,end:s}=e.range;if(t.paragraphIndex===s.paragraphIndex){let i=g(n,t.paragraphIndex);if(i===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let a=n.content[i];a.content=d(a,t.offset,s.offset),a.content=I(a,t.offset,e.text,e.formatting);}else {let i=g(n,t.paragraphIndex),a=n.content[i],p=y(a);a.content=d(a,t.offset,p.length),a.content=I(a,t.offset,e.text,e.formatting);let c=[];for(let u=t.paragraphIndex+1;u<=s.paragraphIndex;u++)c.push(g(n,u));for(let u=c.length-1;u>=0;u--)c[u]!==-1&&n.content.splice(c[u],1);}return r}function v(o,e){let r=h(o),n=r.package.document,{start:t,end:s}=e.range;if(t.paragraphIndex===s.paragraphIndex){let i=g(n,t.paragraphIndex);if(i===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let a=n.content[i];a.content=d(a,t.offset,s.offset);}else {let i=g(n,t.paragraphIndex),a=n.content[i],p=y(a);a.content=d(a,t.offset,p.length);let c=g(n,s.paragraphIndex),u=n.content[c];u.content=d(u,0,s.offset),a.content.push(...u.content);let l=[];for(let f=t.paragraphIndex+1;f<=s.paragraphIndex;f++)l.push(g(n,f));for(let f=l.length-1;f>=0;f--)l[f]!==-1&&n.content.splice(l[f],1);}return r}function S(o,e){let r=h(o),n=r.package.document,{start:t,end:s}=e.range;if(t.paragraphIndex===s.paragraphIndex){let i=g(n,t.paragraphIndex);if(i===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let a=n.content[i];a.content=w(a,t.offset,s.offset,e.formatting);}else for(let i=t.paragraphIndex;i<=s.paragraphIndex;i++){let a=g(n,i);if(a===-1)continue;let p=n.content[a],c=y(p),u=0,l=c.length;i===t.paragraphIndex&&(u=t.offset),i===s.paragraphIndex&&(l=s.offset),p.content=w(p,u,l,e.formatting);}return r}function N(o,e){let r=h(o),n=r.package.document,t=g(n,e.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let s=n.content[t];if(s.formatting={...s.formatting,...e.formatting},"numPr"in e.formatting){let i=e.formatting.numPr;if(i&&i.numId!==void 0&&i.numId!==0){let a=i.ilvl??0,p=i.numId===1,c=p?"\u2022":"1.";if(r.package.numbering){let u=r.package.numbering.nums.find(l=>l.numId===i.numId);if(u){let l=r.package.numbering.abstractNums.find(f=>f.abstractNumId===u.abstractNumId);if(l){let f=l.levels.find(m=>m.ilvl===a);f&&(c=f.lvlText||c);}}}s.listRendering={level:a,numId:i.numId,marker:c,isBullet:p};}else delete s.listRendering;}return r}function A(o,e){let r=h(o),n=r.package.document,t=g(n,e.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let s=n.content[t];return s.formatting={...s.formatting,styleId:e.styleId},r}function Q(o){return o/1440*96}function Y(o){return o/96*1440}function Z(o){return o==null||isNaN(o)?0:Math.round(o*96/914400)}function E(o){return Math.round(o/96*914400)}function ee(o){return Math.round(o/914400*1440)}function te(o){return Math.round(o/1440*914400)}function ne(o){return o/72*96}function re(o){return o/144*96}function X(o,e=2){let r=Math.pow(10,e);return Math.round(o*r)/r}function oe(o){return `${X(o)}px`}function M(o,e){let r=h(o),n=r.package.document,t=[];for(let a=0;a<e.rows;a++){let p=[];for(let c=0;c<e.columns;c++){let u=e.data?.[a]?.[c]||"";p.push({type:"tableCell",content:[{type:"paragraph",content:u?[T(u)]:[]}]});}t.push({type:"tableRow",formatting:a===0&&e.hasHeader?{header:true}:void 0,cells:p});}let s={type:"table",rows:t},i=g(n,e.position.paragraphIndex);return i===-1?n.content.push(s):n.content.splice(i+1,0,s),r}function $(o,e){let r=h(o),n=r.package.document,t=g(n,e.position.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.position.paragraphIndex} not found`);let s=n.content[t],a={type:"run",content:[{type:"drawing",image:{type:"image",rId:`rId_img_${Date.now()}`,src:e.src,alt:e.alt,size:{width:E(e.width||100),height:E(e.height||100)},wrap:{type:"inline"}}}]},p=I(s,e.position.offset,"",void 0),c=false,u=0;for(let l=0;l<p.length;l++){let f=p[l];if(f.type==="run"){let m=f.content.filter(x=>x.type==="text").map(x=>x.text).join("");if(u+=m.length,!c&&u>=e.position.offset){p.splice(l+1,0,a),c=true;break}}}return c||p.push(a),s.content=p,r}function B(o,e){let r=h(o),n=r.package.document,{start:t,end:s}=e.range;if(t.paragraphIndex!==s.paragraphIndex)throw new Error("Hyperlinks cannot span multiple paragraphs");let i=g(n,t.paragraphIndex);if(i===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let a=n.content[i],p=y(a),c=e.displayText||p.slice(t.offset,s.offset);a.content=d(a,t.offset,s.offset);let u={type:"hyperlink",href:e.url,tooltip:e.tooltip,children:[T(c)]},l=false,f=0,m=[];for(let x of a.content)if(x.type==="run"){let b=x.content.filter(P=>P.type==="text").map(P=>P.text).join(""),H=f+b.length;if(!l&&f<=t.offset&&t.offset<=H){let P=t.offset-f;P>0&&m.push({...x,content:[{type:"text",text:b.slice(0,P)}]}),m.push(u),P<b.length&&m.push({...x,content:[{type:"text",text:b.slice(P)}]}),l=true;}else m.push(x);f=H;}else m.push(x);return l||m.push(u),a.content=m,r}function F(o,e){let r=h(o),n=r.package.document,{start:t}=e.range,s=g(n,t.paragraphIndex);if(s===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let i=n.content[s],a=[];for(let p of i.content)if(p.type==="hyperlink")for(let c of p.children)c.type==="run"&&a.push(c);else a.push(p);return i.content=a,r}function k(o,e){let r=h(o),n=r.package.document,t=g(n,e.position.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.position.paragraphIndex} not found`);let s=n.content[t],i=y(s),a=d({content:[...s.content]},e.position.offset,i.length),p=d({content:[...s.content]},0,e.position.offset);s.content=a;let c={type:"paragraph",formatting:s.formatting,content:p};return n.content.splice(t+1,0,c),r}function L(o,e){let r=h(o),n=r.package.document,t=g(n,e.paragraphIndex);if(t===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let s=n.content[t],i=[];for(let a=1;a<=e.count;a++){let p=g(n,e.paragraphIndex+a);if(p!==-1){let c=n.content[p];s.content.push(...c.content),i.push(p);}}for(let a=i.length-1;a>=0;a--)n.content.splice(i[a],1);return r}function V(o,e){return k(o,{position:e.position})}function z(o,e){let r=h(o);return r.templateVariables||(r.templateVariables=[]),r.templateVariables.includes(e.name)||r.templateVariables.push(e.name),r}function O(o,e){let r=h(o),n=r.package.document;function t(a){for(let p of a.content)if(p.type==="text")for(let[c,u]of Object.entries(e.values)){let l=new RegExp(`\\{${c}\\}`,"g");p.text=p.text.replace(l,u);}}function s(a){for(let p of a.content)if(p.type==="run")t(p);else if(p.type==="hyperlink")for(let c of p.children)c.type==="run"&&t(c);}function i(a){if(a.type==="paragraph")s(a);else if(a.type==="table")for(let p of a.rows)for(let c of p.cells)for(let u of c.content)i(u);}for(let a of n.content)i(a);return r}function j(o,e){let r=C.getCommandHandler(e.type);if(r)return r(o,e);switch(e.type){case "insertText":return R(o,e);case "replaceText":return _(o,e);case "deleteText":return v(o,e);case "formatText":return S(o,e);case "formatParagraph":return N(o,e);case "applyStyle":return A(o,e);case "insertTable":return M(o,e);case "insertImage":return $(o,e);case "insertHyperlink":return B(o,e);case "removeHyperlink":return F(o,e);case "insertParagraphBreak":return k(o,e);case "mergeParagraphs":return L(o,e);case "splitParagraph":return V(o,e);case "setVariable":return z(o,e);case "applyVariables":return O(o,e);default:{let n=e;throw new Error(`Unknown command type: ${n.type}`)}}}function Pe(o,e){return e.reduce((r,n)=>j(r,n),o)}export{D as a,C as b,U as c,W as d,Q as e,Y as f,Z as g,E as h,ee as i,te as j,ne as k,re as l,oe as m,j as n,Pe as o};
@@ -0,0 +1,2 @@
1
+ import {l,k,d,e}from'./chunk-ULRDFDHR.mjs';function y(n){return !n||n.length===0?"":n.map(i=>{let s=i;return s?.content?s.content.map(e=>e.content?.map(t=>t.text||"").join("")||"").join(""):""}).join(`
2
+ `)}function u(n){let i=n.getEditorRef();if(i){let e=i.getDocument();if(e?.package?.document)return e.package.document}return n.getDocument()?.package?.document??null}function T(n,i="AI"){function s(e){return e??i}return {getContentAsText(e$1){let t=u(n);return t?e(d(t,e$1)):""},getContent(e){let t=u(n);return t?d(t,e):[]},getComments(e){let t=u(n);if(!t)return [];let r=l(t,e);if(r.length>0)return r;let l$1=n.getComments();if(l$1.length===0)return [];let a=new Map,g=[];for(let o of l$1)if(o.parentId){let c=a.get(o.parentId);c?c.push(o):a.set(o.parentId,[o]);}else g.push(o);let m=[];for(let o of g){if(e?.author&&o.author!==e.author||e?.done!==void 0&&(o.done??false)!==e.done)continue;let c=a.get(o.id)??[];m.push({id:o.id,author:o.author,date:o.date??null,text:y(o.content),anchoredText:"",paragraphIndex:-1,replies:c.map(p=>({id:p.id,author:p.author,date:p.date??null,text:y(p.content)})),done:o.done??false});}return m},getChanges(e){let t=u(n);return t?k(t,e):[]},findText(e,t){return n.findInDocument(e,t)},getSelection(){return n.getSelectionInfo()},addComment(e){return n.addComment({paraId:e.paraId,text:e.text,author:s(e.author),search:e.search})},replyTo(e,t){return n.replyToComment(e,t.text,s(t.author))},resolveComment(e){n.resolveComment(e);},proposeChange(e){return n.proposeChange({paraId:e.paraId,search:e.search,replaceWith:e.replaceWith,author:s(e.author)})},applyFormatting(e){return n.applyFormatting({paraId:e.paraId,search:e.search,marks:e.marks})},setParagraphStyle(e){return n.setParagraphStyle({paraId:e.paraId,styleId:e.styleId})},getPage(e){return n.getPageContent(e)},getPages(e){let t=n.getTotalPages(),r=Math.max(1,Math.min(e.from,t)),l=Math.max(r,Math.min(e.to,t)),a=[];for(let g=r;g<=l;g++){let m=n.getPageContent(g);m&&a.push(m);}return a},getTotalPages(){return n.getTotalPages()},getCurrentPage(){return n.getCurrentPage()},scrollTo(e){return n.scrollToParaId(e)},onContentChange(e){return n.onContentChange(()=>{let t=u(n),r=t?l(t):[],l$1=t?k(t):[];try{e({commentCount:r.length,changeCount:l$1.length,comments:r,changes:l$1});}catch(a){console.error("onContentChange listener threw:",a);}})},onSelectionChange(e){return n.onSelectionChange(()=>{try{e(n.getSelectionInfo());}catch(t){console.error("onSelectionChange listener threw:",t);}})}}}export{T as a};
@@ -0,0 +1 @@
1
+ .ai-ctx-backdrop[data-v-c30da7a7]{position:fixed;inset:0;z-index:499}.ai-ctx-menu[data-v-c30da7a7]{background:#fff;border:1px solid #d1d5db;border-radius:8px;box-shadow:0 4px 16px #00000024;min-width:200px;padding:4px 0}.ai-ctx-menu__header[data-v-c30da7a7]{padding:6px 14px;font-size:11px;font-weight:600;color:#6b7280;text-transform:uppercase;letter-spacing:.04em}.ai-ctx-menu__item[data-v-c30da7a7]{display:flex;align-items:center;gap:10px;width:100%;padding:7px 14px;border:none;background:transparent;cursor:pointer;font-size:13px;color:#1f2937;text-align:left}.ai-ctx-menu__item[data-v-c30da7a7]:hover{background:#f3f4f6}.ai-ctx-menu__icon[data-v-c30da7a7]{font-size:14px;width:18px;text-align:center}.ai-ctx-menu__label[data-v-c30da7a7]{flex:1}.ai-ctx-menu__divider[data-v-c30da7a7]{height:1px;background:#e5e7eb;margin:4px 10px}.ai-ctx-menu__custom[data-v-c30da7a7]{padding:6px 10px}.ai-ctx-menu__input[data-v-c30da7a7]{width:100%;padding:6px 8px;border:1px solid #d1d5db;border-radius:4px;font-size:12px;outline:none}.ai-ctx-menu__input[data-v-c30da7a7]:focus{border-color:#3b82f6}.ai-preview[data-v-1226b741]{background:#fff;border:1px solid #d1d5db;border-radius:8px;box-shadow:0 4px 16px #0000001f;width:420px;max-width:90vw;overflow:hidden}.ai-preview__header[data-v-1226b741]{display:flex;align-items:center;justify-content:space-between;padding:10px 14px;background:#f0f4ff;border-bottom:1px solid #d0daf0}.ai-preview__title[data-v-1226b741]{font-size:13px;font-weight:600;color:#1557b0}.ai-preview__close[data-v-1226b741]{border:none;background:transparent;cursor:pointer;font-size:14px;color:#6b7280}.ai-preview__loading[data-v-1226b741]{display:flex;align-items:center;gap:10px;padding:24px 14px;color:#6b7280;font-size:13px}.ai-preview__spinner[data-v-1226b741]{width:16px;height:16px;border:2px solid #e5e7eb;border-top-color:#3b82f6;border-radius:50%;animation:spin-1226b741 .8s linear infinite}@keyframes spin-1226b741{to{transform:rotate(360deg)}}.ai-preview__error[data-v-1226b741]{padding:16px 14px;color:#dc2626;font-size:13px;display:flex;align-items:center;gap:8px}.ai-preview__retry[data-v-1226b741]{padding:4px 10px;border:1px solid #d1d5db;border-radius:3px;background:#fff;cursor:pointer;font-size:12px}.ai-preview__content[data-v-1226b741]{padding:12px 14px}.ai-preview__diff-label[data-v-1226b741]{font-size:11px;font-weight:600;color:#6b7280;margin-bottom:4px;text-transform:uppercase}.ai-preview__diff-text[data-v-1226b741]{font-size:13px;line-height:1.5;padding:8px 10px;border-radius:4px;margin-bottom:10px}.ai-preview__diff-text--old[data-v-1226b741]{background:#fef2f2;color:#991b1b}.ai-preview__diff-text--new[data-v-1226b741]{background:#f0fdf4;color:#166534}.ai-preview__result[data-v-1226b741]{font-size:13px;line-height:1.5;color:#1f2937}.ai-preview__textarea[data-v-1226b741]{width:100%;padding:8px;border:1px solid #d1d5db;border-radius:4px;font-size:13px;font-family:inherit;resize:vertical;margin-top:8px;outline:none}.ai-preview__textarea[data-v-1226b741]:focus{border-color:#3b82f6}.ai-preview__footer[data-v-1226b741]{display:flex;justify-content:flex-end;gap:6px;padding:10px 14px;border-top:1px solid #e5e7eb}.ai-preview__btn[data-v-1226b741]{padding:5px 14px;border:1px solid #d1d5db;border-radius:4px;background:#fff;cursor:pointer;font-size:12px;font-weight:500}.ai-preview__btn[data-v-1226b741]:hover{background:#f3f4f6}.ai-preview__btn--primary[data-v-1226b741]{background:#1a73e8;color:#fff;border-color:#1a73e8}.ai-preview__btn--primary[data-v-1226b741]:hover{background:#1557b0}
@@ -0,0 +1 @@
1
+ 'use strict';var chunkNISW2GF6_js=require('./chunk-NISW2GF6.js');Object.defineProperty(exports,"executeCommand",{enumerable:true,get:function(){return chunkNISW2GF6_js.n}});Object.defineProperty(exports,"executeCommands",{enumerable:true,get:function(){return chunkNISW2GF6_js.o}});
@@ -0,0 +1 @@
1
+ export{n as executeCommand,o as executeCommands}from'./chunk-X4YGLGUM.mjs';
@@ -1 +1 @@
1
- export{wa as DEFAULT_AI_ACTIONS,x as DocumentAgent,ya as VERSION,i as attemptSelectiveSave,na as blendColors,E as buildExtendedSelectionContext,h as buildPatchedDocumentXml,D as buildSelectionContext,B as buildSelectionContextFromContext,oa as colorsEqual,ta as comparePositions,M as countCharacters,L as countWords,y as createAgent,z as createAgentFromDocument,qa as createCollapsedRange,xa as createCommand,ba as createDocumentWithText,f as createDocx,aa as createEmptyDocument,ra as createRange,ka as createRgbColor,ja as createThemeColor,la as darkenColor,j as detectVariables,k as detectVariablesDetailed,l as detectVariablesInBody,m as detectVariablesInParagraph,v as documentHasVariables,n as extractVariablesFromText,r as formatVariable,va as getActionDescription,ua as getActionLabel,A as getAgentContext,$ as getBlockIndexForParagraph,O as getBodyCharacterCount,K as getBodyText,N as getBodyWordCount,ha as getContrastingColor,C as getDocumentSummary,R as getFormattingAtPosition,T as getHyperlinkAtPosition,I as getHyperlinkText,_ as getParagraphAtIndex,G as getParagraphText,Z as getParagraphs,H as getRunText,F as getSelectionFormattingSummary,J as getTableText,Q as getTextAfter,P as getTextBefore,X as hasHyperlinks,W as hasImages,Y as hasTables,o as hasTemplateVariables,fa as isBlack,U as isHeadingStyle,S as isPositionInHyperlink,sa as isPositionInRange,p as isValidVariableName,ga as isWhite,pa as isZodSchema,ma as lightenColor,ia as parseColorString,w as parseDocx,V as parseHeadingLevel,s as parseVariable,u as removeVariables,d as repackDocx,t as replaceVariables,ca as resolveColor,da as resolveHighlightColor,ea as resolveShadingColor,q as sanitizeVariableName,b as serializeDocumentBody,c as serializeDocx,a as serializeSectionProperties,e as updateMultipleFiles,g as validatePatchSafety}from'./chunk-XZHZXQO5.mjs';export{j as createTemplateProcessor,g as getMissingVariables,e as getTemplateTags,h as previewTemplate,a as processTemplate,i as processTemplateAdvanced,c as processTemplateAsBlob,b as processTemplateDetailed,f as validateTemplate}from'./chunk-UILTIEBD.mjs';export{a as PluginRegistry,d as createPluginRegistrar,g as emuToPixels,i as emuToTwips,n as executeCommand,o as executeCommands,m as formatPx,l as halfPointsToPixels,h as pixelsToEmu,f as pixelsToTwips,b as pluginRegistry,k as pointsToPixels,c as registerPlugins,j as twipsToEmu,e as twipsToPixels}from'./chunk-U7BWZ7DG.mjs';
1
+ export{wa as DEFAULT_AI_ACTIONS,x as DocumentAgent,ya as VERSION,i as attemptSelectiveSave,na as blendColors,E as buildExtendedSelectionContext,h as buildPatchedDocumentXml,D as buildSelectionContext,B as buildSelectionContextFromContext,oa as colorsEqual,ta as comparePositions,M as countCharacters,L as countWords,y as createAgent,z as createAgentFromDocument,qa as createCollapsedRange,xa as createCommand,ba as createDocumentWithText,f as createDocx,aa as createEmptyDocument,ra as createRange,ka as createRgbColor,ja as createThemeColor,la as darkenColor,j as detectVariables,k as detectVariablesDetailed,l as detectVariablesInBody,m as detectVariablesInParagraph,v as documentHasVariables,n as extractVariablesFromText,r as formatVariable,va as getActionDescription,ua as getActionLabel,A as getAgentContext,$ as getBlockIndexForParagraph,O as getBodyCharacterCount,K as getBodyText,N as getBodyWordCount,ha as getContrastingColor,C as getDocumentSummary,R as getFormattingAtPosition,T as getHyperlinkAtPosition,I as getHyperlinkText,_ as getParagraphAtIndex,G as getParagraphText,Z as getParagraphs,H as getRunText,F as getSelectionFormattingSummary,J as getTableText,Q as getTextAfter,P as getTextBefore,X as hasHyperlinks,W as hasImages,Y as hasTables,o as hasTemplateVariables,fa as isBlack,U as isHeadingStyle,S as isPositionInHyperlink,sa as isPositionInRange,p as isValidVariableName,ga as isWhite,pa as isZodSchema,ma as lightenColor,ia as parseColorString,w as parseDocx,V as parseHeadingLevel,s as parseVariable,u as removeVariables,d as repackDocx,t as replaceVariables,ca as resolveColor,da as resolveHighlightColor,ea as resolveShadingColor,q as sanitizeVariableName,b as serializeDocumentBody,c as serializeDocx,a as serializeSectionProperties,e as updateMultipleFiles,g as validatePatchSafety}from'./chunk-D3TF6WTP.mjs';export{j as createTemplateProcessor,g as getMissingVariables,e as getTemplateTags,h as previewTemplate,a as processTemplate,i as processTemplateAdvanced,c as processTemplateAsBlob,b as processTemplateDetailed,f as validateTemplate}from'./chunk-UILTIEBD.mjs';export{a as PluginRegistry,d as createPluginRegistrar,g as emuToPixels,i as emuToTwips,n as executeCommand,o as executeCommands,m as formatPx,l as halfPointsToPixels,h as pixelsToEmu,f as pixelsToTwips,b as pluginRegistry,k as pointsToPixels,c as registerPlugins,j as twipsToEmu,e as twipsToPixels}from'./chunk-X4YGLGUM.mjs';
@@ -0,0 +1 @@
1
+ 'use strict';var chunk7JG2PH72_js=require('./chunk-7JG2PH72.js'),chunk4QRVKNI4_js=require('./chunk-4QRVKNI4.js'),chunkNISW2GF6_js=require('./chunk-NISW2GF6.js');Object.defineProperty(exports,"DEFAULT_AI_ACTIONS",{enumerable:true,get:function(){return chunk7JG2PH72_js.wa}});Object.defineProperty(exports,"DocumentAgent",{enumerable:true,get:function(){return chunk7JG2PH72_js.x}});Object.defineProperty(exports,"VERSION",{enumerable:true,get:function(){return chunk7JG2PH72_js.ya}});Object.defineProperty(exports,"attemptSelectiveSave",{enumerable:true,get:function(){return chunk7JG2PH72_js.i}});Object.defineProperty(exports,"blendColors",{enumerable:true,get:function(){return chunk7JG2PH72_js.na}});Object.defineProperty(exports,"buildExtendedSelectionContext",{enumerable:true,get:function(){return chunk7JG2PH72_js.E}});Object.defineProperty(exports,"buildPatchedDocumentXml",{enumerable:true,get:function(){return chunk7JG2PH72_js.h}});Object.defineProperty(exports,"buildSelectionContext",{enumerable:true,get:function(){return chunk7JG2PH72_js.D}});Object.defineProperty(exports,"buildSelectionContextFromContext",{enumerable:true,get:function(){return chunk7JG2PH72_js.B}});Object.defineProperty(exports,"colorsEqual",{enumerable:true,get:function(){return chunk7JG2PH72_js.oa}});Object.defineProperty(exports,"comparePositions",{enumerable:true,get:function(){return chunk7JG2PH72_js.ta}});Object.defineProperty(exports,"countCharacters",{enumerable:true,get:function(){return chunk7JG2PH72_js.M}});Object.defineProperty(exports,"countWords",{enumerable:true,get:function(){return chunk7JG2PH72_js.L}});Object.defineProperty(exports,"createAgent",{enumerable:true,get:function(){return chunk7JG2PH72_js.y}});Object.defineProperty(exports,"createAgentFromDocument",{enumerable:true,get:function(){return chunk7JG2PH72_js.z}});Object.defineProperty(exports,"createCollapsedRange",{enumerable:true,get:function(){return chunk7JG2PH72_js.qa}});Object.defineProperty(exports,"createCommand",{enumerable:true,get:function(){return chunk7JG2PH72_js.xa}});Object.defineProperty(exports,"createDocumentWithText",{enumerable:true,get:function(){return chunk7JG2PH72_js.ba}});Object.defineProperty(exports,"createDocx",{enumerable:true,get:function(){return chunk7JG2PH72_js.f}});Object.defineProperty(exports,"createEmptyDocument",{enumerable:true,get:function(){return chunk7JG2PH72_js.aa}});Object.defineProperty(exports,"createRange",{enumerable:true,get:function(){return chunk7JG2PH72_js.ra}});Object.defineProperty(exports,"createRgbColor",{enumerable:true,get:function(){return chunk7JG2PH72_js.ka}});Object.defineProperty(exports,"createThemeColor",{enumerable:true,get:function(){return chunk7JG2PH72_js.ja}});Object.defineProperty(exports,"darkenColor",{enumerable:true,get:function(){return chunk7JG2PH72_js.la}});Object.defineProperty(exports,"detectVariables",{enumerable:true,get:function(){return chunk7JG2PH72_js.j}});Object.defineProperty(exports,"detectVariablesDetailed",{enumerable:true,get:function(){return chunk7JG2PH72_js.k}});Object.defineProperty(exports,"detectVariablesInBody",{enumerable:true,get:function(){return chunk7JG2PH72_js.l}});Object.defineProperty(exports,"detectVariablesInParagraph",{enumerable:true,get:function(){return chunk7JG2PH72_js.m}});Object.defineProperty(exports,"documentHasVariables",{enumerable:true,get:function(){return chunk7JG2PH72_js.v}});Object.defineProperty(exports,"extractVariablesFromText",{enumerable:true,get:function(){return chunk7JG2PH72_js.n}});Object.defineProperty(exports,"formatVariable",{enumerable:true,get:function(){return chunk7JG2PH72_js.r}});Object.defineProperty(exports,"getActionDescription",{enumerable:true,get:function(){return chunk7JG2PH72_js.va}});Object.defineProperty(exports,"getActionLabel",{enumerable:true,get:function(){return chunk7JG2PH72_js.ua}});Object.defineProperty(exports,"getAgentContext",{enumerable:true,get:function(){return chunk7JG2PH72_js.A}});Object.defineProperty(exports,"getBlockIndexForParagraph",{enumerable:true,get:function(){return chunk7JG2PH72_js.$}});Object.defineProperty(exports,"getBodyCharacterCount",{enumerable:true,get:function(){return chunk7JG2PH72_js.O}});Object.defineProperty(exports,"getBodyText",{enumerable:true,get:function(){return chunk7JG2PH72_js.K}});Object.defineProperty(exports,"getBodyWordCount",{enumerable:true,get:function(){return chunk7JG2PH72_js.N}});Object.defineProperty(exports,"getContrastingColor",{enumerable:true,get:function(){return chunk7JG2PH72_js.ha}});Object.defineProperty(exports,"getDocumentSummary",{enumerable:true,get:function(){return chunk7JG2PH72_js.C}});Object.defineProperty(exports,"getFormattingAtPosition",{enumerable:true,get:function(){return chunk7JG2PH72_js.R}});Object.defineProperty(exports,"getHyperlinkAtPosition",{enumerable:true,get:function(){return chunk7JG2PH72_js.T}});Object.defineProperty(exports,"getHyperlinkText",{enumerable:true,get:function(){return chunk7JG2PH72_js.I}});Object.defineProperty(exports,"getParagraphAtIndex",{enumerable:true,get:function(){return chunk7JG2PH72_js._}});Object.defineProperty(exports,"getParagraphText",{enumerable:true,get:function(){return chunk7JG2PH72_js.G}});Object.defineProperty(exports,"getParagraphs",{enumerable:true,get:function(){return chunk7JG2PH72_js.Z}});Object.defineProperty(exports,"getRunText",{enumerable:true,get:function(){return chunk7JG2PH72_js.H}});Object.defineProperty(exports,"getSelectionFormattingSummary",{enumerable:true,get:function(){return chunk7JG2PH72_js.F}});Object.defineProperty(exports,"getTableText",{enumerable:true,get:function(){return chunk7JG2PH72_js.J}});Object.defineProperty(exports,"getTextAfter",{enumerable:true,get:function(){return chunk7JG2PH72_js.Q}});Object.defineProperty(exports,"getTextBefore",{enumerable:true,get:function(){return chunk7JG2PH72_js.P}});Object.defineProperty(exports,"hasHyperlinks",{enumerable:true,get:function(){return chunk7JG2PH72_js.X}});Object.defineProperty(exports,"hasImages",{enumerable:true,get:function(){return chunk7JG2PH72_js.W}});Object.defineProperty(exports,"hasTables",{enumerable:true,get:function(){return chunk7JG2PH72_js.Y}});Object.defineProperty(exports,"hasTemplateVariables",{enumerable:true,get:function(){return chunk7JG2PH72_js.o}});Object.defineProperty(exports,"isBlack",{enumerable:true,get:function(){return chunk7JG2PH72_js.fa}});Object.defineProperty(exports,"isHeadingStyle",{enumerable:true,get:function(){return chunk7JG2PH72_js.U}});Object.defineProperty(exports,"isPositionInHyperlink",{enumerable:true,get:function(){return chunk7JG2PH72_js.S}});Object.defineProperty(exports,"isPositionInRange",{enumerable:true,get:function(){return chunk7JG2PH72_js.sa}});Object.defineProperty(exports,"isValidVariableName",{enumerable:true,get:function(){return chunk7JG2PH72_js.p}});Object.defineProperty(exports,"isWhite",{enumerable:true,get:function(){return chunk7JG2PH72_js.ga}});Object.defineProperty(exports,"isZodSchema",{enumerable:true,get:function(){return chunk7JG2PH72_js.pa}});Object.defineProperty(exports,"lightenColor",{enumerable:true,get:function(){return chunk7JG2PH72_js.ma}});Object.defineProperty(exports,"parseColorString",{enumerable:true,get:function(){return chunk7JG2PH72_js.ia}});Object.defineProperty(exports,"parseDocx",{enumerable:true,get:function(){return chunk7JG2PH72_js.w}});Object.defineProperty(exports,"parseHeadingLevel",{enumerable:true,get:function(){return chunk7JG2PH72_js.V}});Object.defineProperty(exports,"parseVariable",{enumerable:true,get:function(){return chunk7JG2PH72_js.s}});Object.defineProperty(exports,"removeVariables",{enumerable:true,get:function(){return chunk7JG2PH72_js.u}});Object.defineProperty(exports,"repackDocx",{enumerable:true,get:function(){return chunk7JG2PH72_js.d}});Object.defineProperty(exports,"replaceVariables",{enumerable:true,get:function(){return chunk7JG2PH72_js.t}});Object.defineProperty(exports,"resolveColor",{enumerable:true,get:function(){return chunk7JG2PH72_js.ca}});Object.defineProperty(exports,"resolveHighlightColor",{enumerable:true,get:function(){return chunk7JG2PH72_js.da}});Object.defineProperty(exports,"resolveShadingColor",{enumerable:true,get:function(){return chunk7JG2PH72_js.ea}});Object.defineProperty(exports,"sanitizeVariableName",{enumerable:true,get:function(){return chunk7JG2PH72_js.q}});Object.defineProperty(exports,"serializeDocumentBody",{enumerable:true,get:function(){return chunk7JG2PH72_js.b}});Object.defineProperty(exports,"serializeDocx",{enumerable:true,get:function(){return chunk7JG2PH72_js.c}});Object.defineProperty(exports,"serializeSectionProperties",{enumerable:true,get:function(){return chunk7JG2PH72_js.a}});Object.defineProperty(exports,"updateMultipleFiles",{enumerable:true,get:function(){return chunk7JG2PH72_js.e}});Object.defineProperty(exports,"validatePatchSafety",{enumerable:true,get:function(){return chunk7JG2PH72_js.g}});Object.defineProperty(exports,"createTemplateProcessor",{enumerable:true,get:function(){return chunk4QRVKNI4_js.j}});Object.defineProperty(exports,"getMissingVariables",{enumerable:true,get:function(){return chunk4QRVKNI4_js.g}});Object.defineProperty(exports,"getTemplateTags",{enumerable:true,get:function(){return chunk4QRVKNI4_js.e}});Object.defineProperty(exports,"previewTemplate",{enumerable:true,get:function(){return chunk4QRVKNI4_js.h}});Object.defineProperty(exports,"processTemplate",{enumerable:true,get:function(){return chunk4QRVKNI4_js.a}});Object.defineProperty(exports,"processTemplateAdvanced",{enumerable:true,get:function(){return chunk4QRVKNI4_js.i}});Object.defineProperty(exports,"processTemplateAsBlob",{enumerable:true,get:function(){return chunk4QRVKNI4_js.c}});Object.defineProperty(exports,"processTemplateDetailed",{enumerable:true,get:function(){return chunk4QRVKNI4_js.b}});Object.defineProperty(exports,"validateTemplate",{enumerable:true,get:function(){return chunk4QRVKNI4_js.f}});Object.defineProperty(exports,"PluginRegistry",{enumerable:true,get:function(){return chunkNISW2GF6_js.a}});Object.defineProperty(exports,"createPluginRegistrar",{enumerable:true,get:function(){return chunkNISW2GF6_js.d}});Object.defineProperty(exports,"emuToPixels",{enumerable:true,get:function(){return chunkNISW2GF6_js.g}});Object.defineProperty(exports,"emuToTwips",{enumerable:true,get:function(){return chunkNISW2GF6_js.i}});Object.defineProperty(exports,"executeCommand",{enumerable:true,get:function(){return chunkNISW2GF6_js.n}});Object.defineProperty(exports,"executeCommands",{enumerable:true,get:function(){return chunkNISW2GF6_js.o}});Object.defineProperty(exports,"formatPx",{enumerable:true,get:function(){return chunkNISW2GF6_js.m}});Object.defineProperty(exports,"halfPointsToPixels",{enumerable:true,get:function(){return chunkNISW2GF6_js.l}});Object.defineProperty(exports,"pixelsToEmu",{enumerable:true,get:function(){return chunkNISW2GF6_js.h}});Object.defineProperty(exports,"pixelsToTwips",{enumerable:true,get:function(){return chunkNISW2GF6_js.f}});Object.defineProperty(exports,"pluginRegistry",{enumerable:true,get:function(){return chunkNISW2GF6_js.b}});Object.defineProperty(exports,"pointsToPixels",{enumerable:true,get:function(){return chunkNISW2GF6_js.k}});Object.defineProperty(exports,"registerPlugins",{enumerable:true,get:function(){return chunkNISW2GF6_js.c}});Object.defineProperty(exports,"twipsToEmu",{enumerable:true,get:function(){return chunkNISW2GF6_js.j}});Object.defineProperty(exports,"twipsToPixels",{enumerable:true,get:function(){return chunkNISW2GF6_js.e}});
package/dist/index.d.mts CHANGED
@@ -1,5 +1,35 @@
1
- import { G as GetContentOptions, C as ContentBlock, e as CommentFilter, R as ReviewComment, f as ChangeFilter, h as ReviewChange, F as FoundMatch, S as SelectionInfo, i as AddCommentByParaIdOptions, j as ReplyOptions, P as ProposeChangeOptions, k as ApplyFormattingOptions, l as SetParagraphStyleOptions, m as PageContent, n as ContentChangeEvent, o as SelectionChangeEvent } from './server-DH5eszkm.mjs';
2
- export { A as AgentToolDefinition, a as AgentToolResult, B as BatchError, p as BatchResult, q as BatchReviewOptions, D as DocxReviewer, r as agentTools, s as createReviewerBridge, t as executeToolCall, g as getToolSchemas } from './server-DH5eszkm.mjs';
1
+ /**
2
+ * @eigenpal/docx-editor-agents
3
+ *
4
+ * Word-like API for AI document review.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const reviewer = await DocxReviewer.fromBuffer(buffer, 'AI Reviewer');
9
+ *
10
+ * // Read
11
+ * const text = reviewer.getContentAsText();
12
+ *
13
+ * // Comment on a paragraph
14
+ * reviewer.addComment(5, 'Liability cap seems too low.');
15
+ *
16
+ * // Replace text (creates tracked change)
17
+ * reviewer.replace(5, '$50k', '$500k');
18
+ *
19
+ * // Or batch from LLM JSON response
20
+ * reviewer.applyReview({
21
+ * comments: [{ paragraphIndex: 5, text: 'Too low.' }],
22
+ * proposals: [{ paragraphIndex: 5, search: '$50k', replaceWith: '$500k' }],
23
+ * });
24
+ *
25
+ * const output = await reviewer.toBuffer();
26
+ * ```
27
+ *
28
+ * @packageDocumentation
29
+ * @public
30
+ */
31
+ import { G as GetContentOptions, C as ContentBlock, a as CommentFilter, R as ReviewComment, b as ChangeFilter, c as ReviewChange, F as FoundMatch, S as SelectionInfo, A as AddCommentByParaIdOptions, d as ReplyOptions, P as ProposeChangeOptions, e as ApplyFormattingOptions, f as SetParagraphStyleOptions, g as PageContent, h as ContentChangeEvent, i as SelectionChangeEvent } from './server-B7RHNVSu.mjs';
32
+ export { j as AgentToolDefinition, k as AgentToolResult, B as BatchError, l as BatchResult, m as BatchReviewOptions, D as DocxReviewer, n as agentTools, o as createReviewerBridge, p as executeToolCall, q as getToolSchemas } from './server-B7RHNVSu.mjs';
3
33
 
4
34
  /**
5
35
  * Error classes for @eigenpal/docx-editor-agents
package/dist/index.d.ts CHANGED
@@ -1,5 +1,35 @@
1
- import { G as GetContentOptions, C as ContentBlock, e as CommentFilter, R as ReviewComment, f as ChangeFilter, h as ReviewChange, F as FoundMatch, S as SelectionInfo, i as AddCommentByParaIdOptions, j as ReplyOptions, P as ProposeChangeOptions, k as ApplyFormattingOptions, l as SetParagraphStyleOptions, m as PageContent, n as ContentChangeEvent, o as SelectionChangeEvent } from './server-DH5eszkm.js';
2
- export { A as AgentToolDefinition, a as AgentToolResult, B as BatchError, p as BatchResult, q as BatchReviewOptions, D as DocxReviewer, r as agentTools, s as createReviewerBridge, t as executeToolCall, g as getToolSchemas } from './server-DH5eszkm.js';
1
+ /**
2
+ * @eigenpal/docx-editor-agents
3
+ *
4
+ * Word-like API for AI document review.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const reviewer = await DocxReviewer.fromBuffer(buffer, 'AI Reviewer');
9
+ *
10
+ * // Read
11
+ * const text = reviewer.getContentAsText();
12
+ *
13
+ * // Comment on a paragraph
14
+ * reviewer.addComment(5, 'Liability cap seems too low.');
15
+ *
16
+ * // Replace text (creates tracked change)
17
+ * reviewer.replace(5, '$50k', '$500k');
18
+ *
19
+ * // Or batch from LLM JSON response
20
+ * reviewer.applyReview({
21
+ * comments: [{ paragraphIndex: 5, text: 'Too low.' }],
22
+ * proposals: [{ paragraphIndex: 5, search: '$50k', replaceWith: '$500k' }],
23
+ * });
24
+ *
25
+ * const output = await reviewer.toBuffer();
26
+ * ```
27
+ *
28
+ * @packageDocumentation
29
+ * @public
30
+ */
31
+ import { G as GetContentOptions, C as ContentBlock, a as CommentFilter, R as ReviewComment, b as ChangeFilter, c as ReviewChange, F as FoundMatch, S as SelectionInfo, A as AddCommentByParaIdOptions, d as ReplyOptions, P as ProposeChangeOptions, e as ApplyFormattingOptions, f as SetParagraphStyleOptions, g as PageContent, h as ContentChangeEvent, i as SelectionChangeEvent } from './server-B7RHNVSu.js';
32
+ export { j as AgentToolDefinition, k as AgentToolResult, B as BatchError, l as BatchResult, m as BatchReviewOptions, D as DocxReviewer, n as agentTools, o as createReviewerBridge, p as executeToolCall, q as getToolSchemas } from './server-B7RHNVSu.js';
3
33
 
4
34
  /**
5
35
  * Error classes for @eigenpal/docx-editor-agents
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- 'use strict';var chunkA6ANAWKH_js=require('./chunk-A6ANAWKH.js'),chunkLVRKZUG4_js=require('./chunk-LVRKZUG4.js'),chunkRI5S75JY_js=require('./chunk-RI5S75JY.js');Object.defineProperty(exports,"DocxReviewer",{enumerable:true,get:function(){return chunkA6ANAWKH_js.a}});Object.defineProperty(exports,"ChangeNotFoundError",{enumerable:true,get:function(){return chunkLVRKZUG4_js.g}});Object.defineProperty(exports,"CommentNotFoundError",{enumerable:true,get:function(){return chunkLVRKZUG4_js.h}});Object.defineProperty(exports,"TextNotFoundError",{enumerable:true,get:function(){return chunkLVRKZUG4_js.f}});Object.defineProperty(exports,"createReviewerBridge",{enumerable:true,get:function(){return chunkLVRKZUG4_js.m}});Object.defineProperty(exports,"agentTools",{enumerable:true,get:function(){return chunkRI5S75JY_js.a}});Object.defineProperty(exports,"executeToolCall",{enumerable:true,get:function(){return chunkRI5S75JY_js.b}});Object.defineProperty(exports,"getToolSchemas",{enumerable:true,get:function(){return chunkRI5S75JY_js.d}});
1
+ 'use strict';var chunkQ5KDGSCS_js=require('./chunk-Q5KDGSCS.js'),chunkRYHTROV6_js=require('./chunk-RYHTROV6.js'),chunkRI5S75JY_js=require('./chunk-RI5S75JY.js');Object.defineProperty(exports,"DocxReviewer",{enumerable:true,get:function(){return chunkQ5KDGSCS_js.a}});Object.defineProperty(exports,"ChangeNotFoundError",{enumerable:true,get:function(){return chunkRYHTROV6_js.g}});Object.defineProperty(exports,"CommentNotFoundError",{enumerable:true,get:function(){return chunkRYHTROV6_js.h}});Object.defineProperty(exports,"TextNotFoundError",{enumerable:true,get:function(){return chunkRYHTROV6_js.f}});Object.defineProperty(exports,"createReviewerBridge",{enumerable:true,get:function(){return chunkRYHTROV6_js.m}});Object.defineProperty(exports,"agentTools",{enumerable:true,get:function(){return chunkRI5S75JY_js.a}});Object.defineProperty(exports,"executeToolCall",{enumerable:true,get:function(){return chunkRI5S75JY_js.b}});Object.defineProperty(exports,"getToolSchemas",{enumerable:true,get:function(){return chunkRI5S75JY_js.d}});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export{a as DocxReviewer}from'./chunk-BDHS4WRJ.mjs';export{g as ChangeNotFoundError,h as CommentNotFoundError,f as TextNotFoundError,m as createReviewerBridge}from'./chunk-CPJV53R6.mjs';export{a as agentTools,b as executeToolCall,d as getToolSchemas}from'./chunk-24MVJKCP.mjs';
1
+ export{a as DocxReviewer}from'./chunk-HWYEQX5Y.mjs';export{g as ChangeNotFoundError,h as CommentNotFoundError,f as TextNotFoundError,m as createReviewerBridge}from'./chunk-ULRDFDHR.mjs';export{a as agentTools,b as executeToolCall,d as getToolSchemas}from'./chunk-24MVJKCP.mjs';
package/dist/mcp.d.mts CHANGED
@@ -1,4 +1,23 @@
1
- import { v as EditorBridge } from './server-DH5eszkm.mjs';
1
+ /**
2
+ * @eigenpal/docx-editor-agents/mcp
3
+ *
4
+ * Model Context Protocol (MCP) server for the docx editor agent bridge.
5
+ *
6
+ * Two transports, same core:
7
+ * - `stdio`: classic MCP transport. Use `runStdioServer(bridge)` from a
8
+ * Node subprocess that Claude Desktop, Cursor, or any MCP-aware client
9
+ * will spawn. Newline-delimited JSON-RPC.
10
+ * - `direct`: call `new McpServer(bridge).handle(message)` if you have
11
+ * your own transport (WebSocket, `postMessage`, HTTP long-poll, etc.).
12
+ *
13
+ * The server is transport-agnostic and zero-dep. The stdio module reaches
14
+ * for `process.stdin` / `process.stdout` only when you call
15
+ * `runStdioServer` without explicit streams.
16
+ *
17
+ * @packageDocumentation
18
+ * @public
19
+ */
20
+ import { E as EditorBridge } from './server-B7RHNVSu.mjs';
2
21
 
3
22
  /**
4
23
  * MCP wire protocol (subset) — JSON-RPC 2.0 framing + the message types we
package/dist/mcp.d.ts CHANGED
@@ -1,4 +1,23 @@
1
- import { v as EditorBridge } from './server-DH5eszkm.js';
1
+ /**
2
+ * @eigenpal/docx-editor-agents/mcp
3
+ *
4
+ * Model Context Protocol (MCP) server for the docx editor agent bridge.
5
+ *
6
+ * Two transports, same core:
7
+ * - `stdio`: classic MCP transport. Use `runStdioServer(bridge)` from a
8
+ * Node subprocess that Claude Desktop, Cursor, or any MCP-aware client
9
+ * will spawn. Newline-delimited JSON-RPC.
10
+ * - `direct`: call `new McpServer(bridge).handle(message)` if you have
11
+ * your own transport (WebSocket, `postMessage`, HTTP long-poll, etc.).
12
+ *
13
+ * The server is transport-agnostic and zero-dep. The stdio module reaches
14
+ * for `process.stdin` / `process.stdout` only when you call
15
+ * `runStdioServer` without explicit streams.
16
+ *
17
+ * @packageDocumentation
18
+ * @public
19
+ */
20
+ import { E as EditorBridge } from './server-B7RHNVSu.js';
2
21
 
3
22
  /**
4
23
  * MCP wire protocol (subset) — JSON-RPC 2.0 framing + the message types we
package/dist/react.d.mts CHANGED
@@ -1,5 +1,59 @@
1
- import { E as EditorRefLike, A as AgentToolDefinition, g as getToolSchemas, a as AgentToolResult, b as AgentContextSnapshot } from './server-DH5eszkm.mjs';
2
- export { U as UseAgentChatOptions, c as UseAgentChatReturn, d as getToolDisplayName, u as useAgentChat } from './server-DH5eszkm.mjs';
1
+ /**
2
+ * @eigenpal/docx-editor-agents/react
3
+ *
4
+ * React entry. Hooks, components, and types that need React as a peer
5
+ * dependency. Pair with `/server` (or `/ai-sdk/server`) for the API route
6
+ * that drives the LLM.
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * import { useDocxAgentTools } from '@eigenpal/docx-editor-agents/react';
11
+ *
12
+ * const { tools, executeToolCall, getContext } = useDocxAgentTools({
13
+ * editorRef,
14
+ * author: 'Assistant',
15
+ * });
16
+ * ```
17
+ *
18
+ * @packageDocumentation
19
+ * @public
20
+ */
21
+ import { r as EditorRefLike, k as AgentToolResult, q as getToolSchemas, j as AgentToolDefinition, s as AgentContextSnapshot } from './server-B7RHNVSu.mjs';
22
+ export { t as getToolDisplayName } from './server-B7RHNVSu.mjs';
23
+ import * as react_jsx_runtime from 'react/jsx-runtime';
24
+ import { ReactNode, CSSProperties } from 'react';
25
+ import { A as AgentMessage, a as AgentToolCall } from './agent-types-C8RvQB7n.mjs';
26
+
27
+ /**
28
+ * useAgentChat — React hook that wires agent tools to a live DocxEditor.
29
+ *
30
+ * @example
31
+ * ```tsx
32
+ * import { useAgentChat } from '@eigenpal/docx-editor-agents/react';
33
+ *
34
+ * const { executeToolCall, toolSchemas } = useAgentChat({ editorRef, author: 'Assistant' });
35
+ *
36
+ * // Pass toolSchemas to your AI provider, execute tool calls on the client
37
+ * const result = executeToolCall('add_comment', { paragraphIndex: 3, text: 'Fix this.' });
38
+ * ```
39
+ */
40
+
41
+ interface UseAgentChatOptions {
42
+ /** Reference to the DocxEditor (must match EditorRefLike interface). */
43
+ editorRef: React.RefObject<EditorRefLike | null>;
44
+ /** Default author name for comments and changes. Default: 'AI' */
45
+ author?: string;
46
+ }
47
+ interface UseAgentChatReturn {
48
+ /** Execute a tool call through the bridge. */
49
+ executeToolCall: (toolName: string, input: Record<string, unknown>) => AgentToolResult;
50
+ /** Tool schemas in OpenAI function calling format. Pass to your AI provider. */
51
+ toolSchemas: ReturnType<typeof getToolSchemas>;
52
+ }
53
+ /**
54
+ * Hook that creates an EditorBridge and provides tool execution.
55
+ */
56
+ declare function useAgentChat(options: UseAgentChatOptions): UseAgentChatReturn;
3
57
 
4
58
  /**
5
59
  * useDocxAgentTools — wires the toolkit to a live DocxEditor for BYO chat
@@ -75,4 +129,122 @@ interface UseDocxAgentToolsReturn {
75
129
  }
76
130
  declare function useDocxAgentTools(options: UseDocxAgentToolsOptions): UseDocxAgentToolsReturn;
77
131
 
78
- export { AgentContextSnapshot, AgentToolDefinition, AgentToolResult, EditorRefLike, type UseDocxAgentToolsOptions, type UseDocxAgentToolsReturn, useDocxAgentTools };
132
+ interface AgentPanelProps {
133
+ /** Header title. Defaults to `'Assistant'`. Pass a localised string for i18n. */
134
+ title?: string;
135
+ /** Header icon node. Defaults to a sparkle SVG. */
136
+ icon?: ReactNode;
137
+ /** Close button aria-label. Defaults to `'Close panel'`. */
138
+ closeLabel?: string;
139
+ /** Resize handle aria-label. Defaults to `'Resize agent panel'`. */
140
+ resizeHandleLabel?: string;
141
+ /** Controlled width in pixels. Omit for uncontrolled (internal state + localStorage). */
142
+ width?: number;
143
+ /** Default width when uncontrolled. */
144
+ defaultWidth?: number;
145
+ /** Min drag width. */
146
+ minWidth?: number;
147
+ /** Max drag width. */
148
+ maxWidth?: number;
149
+ /** Width change callback (drag end and intermediate). */
150
+ onWidthChange?: (w: number) => void;
151
+ /** Header close button click. Omit to hide the close button. */
152
+ onClose?: () => void;
153
+ /** Panel content. Render whatever you want — a chat, tabs, settings, anything. */
154
+ children: ReactNode;
155
+ /** Optional class on the outer wrapper. */
156
+ className?: string;
157
+ /**
158
+ * When `true`, the panel collapses to zero width with an ease-out
159
+ * transition (the children are still mounted so chat state survives
160
+ * close/reopen). The DocxEditor wrapper passes this when the user
161
+ * toggles the panel — kept off by default for standalone usage.
162
+ */
163
+ closed?: boolean;
164
+ }
165
+ declare function AgentPanel({ title, icon, closeLabel, resizeHandleLabel, width: controlledWidth, defaultWidth, minWidth, maxWidth, onWidthChange, onClose, children, className, closed, }: AgentPanelProps): react_jsx_runtime.JSX.Element;
166
+
167
+ interface AgentChatLogProps {
168
+ messages: AgentMessage[];
169
+ /** Render thinking dots at the bottom of the list. */
170
+ loading?: boolean;
171
+ /** Render an error bubble after the last message. */
172
+ error?: string | null;
173
+ /** Shown when there are no messages and not loading. */
174
+ emptyState?: ReactNode;
175
+ /** "Assistant is thinking" aria-label. Default English. */
176
+ thinkingLabel?: string;
177
+ /** "Working… N steps" — pass for i18n. Default English. */
178
+ workingLabel?: (count: number) => string;
179
+ /** "N steps" — pass for i18n. Default English. */
180
+ summaryLabel?: (count: number) => string;
181
+ /** "+ N earlier steps" — pass for i18n. Default English. */
182
+ earlierLabel?: (count: number) => string;
183
+ /** Auto-scroll to bottom on new messages / loading toggles. Default: true. */
184
+ autoScroll?: boolean;
185
+ /**
186
+ * Map a tool name to a friendly label for the per-message timeline.
187
+ * Pass `getToolDisplayName` from `@eigenpal/docx-editor-agents/react` to
188
+ * use the toolkit's registry-aware labels (e.g. "Adding comment").
189
+ */
190
+ humanizeToolName?: (name: string) => string;
191
+ /** Cap the tool-call timeline to this many recent rows. Default 3. */
192
+ maxVisibleCalls?: number;
193
+ className?: string;
194
+ style?: CSSProperties;
195
+ }
196
+ interface AgentTimelineProps {
197
+ /** Tool calls in chronological order. */
198
+ toolCalls: AgentToolCall[];
199
+ /**
200
+ * Whether the parent assistant turn is still streaming. While true, the
201
+ * timeline is forced expanded and shows a spinner; on false it
202
+ * auto-collapses to an "N steps" summary unless the user expanded it.
203
+ */
204
+ streaming?: boolean;
205
+ /**
206
+ * Cap the number of rendered call rows — older entries collapse into a
207
+ * "+N earlier steps" header. Default 3.
208
+ */
209
+ maxVisibleCalls?: number;
210
+ /**
211
+ * Map a tool name to a friendly label. Defaults to a sentence-case
212
+ * conversion of the snake_case name. Pass `getToolDisplayName` from
213
+ * `@eigenpal/docx-editor-agents/react` to use the toolkit's registry.
214
+ */
215
+ humanizeName?: (name: string) => string;
216
+ /** "Working… N steps" — pass for i18n. Default English. */
217
+ workingLabel?: (count: number) => string;
218
+ /** "N steps" — pass for i18n. Default English. */
219
+ summaryLabel?: (count: number) => string;
220
+ /** "+ N earlier steps" — pass for i18n. Default English. */
221
+ earlierLabel?: (count: number) => string;
222
+ }
223
+ /**
224
+ * Collapsible timeline of an assistant turn's tool calls. Lives above the
225
+ * assistant text bubble. Auto-collapses when the turn finishes; click the
226
+ * summary row to re-expand.
227
+ */
228
+ declare function AgentTimeline({ toolCalls, streaming, maxVisibleCalls, humanizeName, workingLabel, summaryLabel, earlierLabel, }: AgentTimelineProps): react_jsx_runtime.JSX.Element | null;
229
+ declare function AgentChatLog({ messages, loading, error, emptyState, autoScroll, humanizeToolName, maxVisibleCalls, className, style, thinkingLabel, workingLabel, summaryLabel, earlierLabel, }: AgentChatLogProps): react_jsx_runtime.JSX.Element;
230
+ interface AgentComposerProps {
231
+ value: string;
232
+ onChange: (next: string) => void;
233
+ onSubmit: () => void;
234
+ disabled?: boolean;
235
+ placeholder?: string;
236
+ /** Send-button aria-label. Default `'Send'`. */
237
+ sendLabel?: string;
238
+ /** Small text under the input — typically a scope reminder. */
239
+ footnote?: ReactNode;
240
+ className?: string;
241
+ }
242
+ declare function AgentComposer({ value, onChange, onSubmit, disabled, placeholder, sendLabel, footnote, className, }: AgentComposerProps): react_jsx_runtime.JSX.Element;
243
+ interface AgentSuggestionChipProps {
244
+ label: string;
245
+ onClick: () => void;
246
+ disabled?: boolean;
247
+ }
248
+ declare function AgentSuggestionChip({ label, onClick, disabled }: AgentSuggestionChipProps): react_jsx_runtime.JSX.Element;
249
+
250
+ export { AgentChatLog, type AgentChatLogProps, AgentComposer, type AgentComposerProps, AgentContextSnapshot, AgentMessage, AgentPanel, type AgentPanelProps, AgentSuggestionChip, type AgentSuggestionChipProps, AgentTimeline, type AgentTimelineProps, AgentToolCall, AgentToolDefinition, AgentToolResult, EditorRefLike, type UseAgentChatOptions, type UseAgentChatReturn, type UseDocxAgentToolsOptions, type UseDocxAgentToolsReturn, useAgentChat, useDocxAgentTools };