@eigenpal/docx-editor-agents 0.5.0 → 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
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@eigenpal/docx-editor-agents",
3
- "version": "0.5.0",
4
- "description": "Agent-friendly API for DOCX document review read, comment, propose changes, accept/reject tracked changes",
3
+ "version": "1.0.0",
4
+ "description": "Agent SDK and chat UI for the DOCX editorframework-agnostic bridge, MCP server, AI SDK adapters, plus React UI (and Vue UI in 1.x)",
5
+ "sideEffects": [
6
+ "*.css"
7
+ ],
5
8
  "main": "./dist/index.js",
6
9
  "module": "./dist/index.mjs",
7
10
  "types": "./dist/index.d.ts",
@@ -26,6 +29,11 @@
26
29
  "import": "./dist/react.mjs",
27
30
  "require": "./dist/react.js"
28
31
  },
32
+ "./vue": {
33
+ "types": "./dist/vue.d.ts",
34
+ "import": "./dist/vue.mjs",
35
+ "require": "./dist/vue.js"
36
+ },
29
37
  "./mcp": {
30
38
  "types": "./dist/mcp.d.ts",
31
39
  "import": "./dist/mcp.mjs",
@@ -40,6 +48,11 @@
40
48
  "types": "./dist/ai-sdk/react.d.ts",
41
49
  "import": "./dist/ai-sdk/react.mjs",
42
50
  "require": "./dist/ai-sdk/react.js"
51
+ },
52
+ "./ai-sdk/vue": {
53
+ "types": "./dist/ai-sdk/vue.d.ts",
54
+ "import": "./dist/ai-sdk/vue.mjs",
55
+ "require": "./dist/ai-sdk/vue.js"
43
56
  }
44
57
  },
45
58
  "typesVersions": {
@@ -53,6 +66,9 @@
53
66
  "react": [
54
67
  "./dist/react.d.ts"
55
68
  ],
69
+ "vue": [
70
+ "./dist/vue.d.ts"
71
+ ],
56
72
  "mcp": [
57
73
  "./dist/mcp.d.ts"
58
74
  ],
@@ -61,27 +77,50 @@
61
77
  ],
62
78
  "ai-sdk/react": [
63
79
  "./dist/ai-sdk/react.d.ts"
80
+ ],
81
+ "ai-sdk/vue": [
82
+ "./dist/ai-sdk/vue.d.ts"
64
83
  ]
65
84
  }
66
85
  },
67
86
  "peerDependencies": {
68
- "ai": "^5.0.0 || ^6.0.0"
87
+ "@ai-sdk/vue": "^2.0.0",
88
+ "ai": "^5.0.0 || ^6.0.0",
89
+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
90
+ "vue": "^3.0.0"
69
91
  },
70
92
  "peerDependenciesMeta": {
93
+ "@ai-sdk/vue": {
94
+ "optional": true
95
+ },
71
96
  "ai": {
72
97
  "optional": true
98
+ },
99
+ "react": {
100
+ "optional": true
101
+ },
102
+ "vue": {
103
+ "optional": true
73
104
  }
74
105
  },
75
106
  "devDependencies": {
76
- "ai": "^6.0.169"
107
+ "@microsoft/api-extractor": "^7.50.0",
108
+ "@vitejs/plugin-vue": "^5.2.4",
109
+ "ai": "^6.0.169",
110
+ "vite": "^7.0.0",
111
+ "vite-plugin-dts": "^5.0.0",
112
+ "vue": "^3.4.0",
113
+ "vue-tsc": "^2.0.0"
77
114
  },
78
115
  "files": [
79
116
  "dist",
80
117
  "LICENSE"
81
118
  ],
82
119
  "scripts": {
83
- "build": "tsup",
84
- "typecheck": "tsc --noEmit"
120
+ "build": "tsup && vite build && node ../../scripts/inject-package-doc.mjs --package @eigenpal/docx-editor-agents",
121
+ "typecheck": "vue-tsc --noEmit",
122
+ "api:extract": "node ../../scripts/api-extractor.mjs --package @eigenpal/docx-editor-agents --local",
123
+ "api:check": "node ../../scripts/api-extractor.mjs --package @eigenpal/docx-editor-agents"
85
124
  },
86
125
  "dependencies": {
87
126
  "docxtemplater": "^3.50.0",
@@ -99,13 +138,17 @@
99
138
  "legal",
100
139
  "contract"
101
140
  ],
102
- "author": "EigenPal",
103
- "license": "AGPL-3.0-or-later",
141
+ "author": {
142
+ "name": "Jedr Blaszyk",
143
+ "email": "jedr@eigenpal.com",
144
+ "url": "https://github.com/jedrazb"
145
+ },
146
+ "license": "Apache-2.0",
104
147
  "homepage": "https://docx-editor.dev/",
105
148
  "repository": {
106
149
  "type": "git",
107
150
  "url": "https://github.com/eigenpal/docx-editor.git",
108
- "directory": "packages/agent-use"
151
+ "directory": "packages/agents"
109
152
  },
110
153
  "publishConfig": {
111
154
  "access": "public"
@@ -1 +0,0 @@
1
- 'use strict';var w=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)}}},b=new w;function U(o,e){return o.map(r=>b.register(r,e))}function W(o){return e=>b.register(e,o)}function J(o){return o/1440*96}function q(o){return o/96*1440}function K(o){return o==null||isNaN(o)?0:Math.round(o*96/914400)}function E(o){return Math.round(o/96*914400)}function Q(o){return Math.round(o/914400*1440)}function Y(o){return Math.round(o/1440*914400)}function Z(o){return o/72*96}function ee(o){return o/144*96}function R(o,e=2){let r=Math.pow(10,e);return Math.round(o*r)/r}function te(o){return `${R(o)}px`}function _(o,e){let r=b.getCommandHandler(e.type);if(r)return r(o,e);switch(e.type){case "insertText":return v(o,e);case "replaceText":return S(o,e);case "deleteText":return N(o,e);case "formatText":return M(o,e);case "formatParagraph":return $(o,e);case "applyStyle":return A(o,e);case "insertTable":return L(o,e);case "insertImage":return B(o,e);case "insertHyperlink":return F(o,e);case "removeHyperlink":return V(o,e);case "insertParagraphBreak":return H(o,e);case "mergeParagraphs":return z(o,e);case "splitParagraph":return O(o,e);case "setVariable":return X(o,e);case "applyVariables":return j(o,e);default:let n=e;throw new Error(`Unknown command type: ${n.type}`)}}function ae(o,e){return e.reduce((r,n)=>_(r,n),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 I(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 C(o,e,r,n){let t=[],s=0,i=false;for(let a of o.content)if(a.type==="run"){let c=a.content.filter(l=>l.type==="text").map(l=>l.text).join(""),p=s,u=s+c.length;if(!i&&e>=p&&e<=u){let l=e-p;l>0&&t.push({...a,content:[{type:"text",text:c.slice(0,l)}]}),t.push(T(r,n||a.formatting)),l<c.length&&t.push({...a,content:[{type:"text",text:c.slice(l)}]}),i=true;}else t.push(a);s=u;}else t.push(a);return i||t.push(T(r,n)),t}function P(o,e,r){let n=[],t=0;for(let s of o.content)if(s.type==="run"){let i=s.content.filter(p=>p.type==="text").map(p=>p.text).join(""),a=t,c=t+i.length;if(c<=e||a>=r)n.push(s);else {let p="";a<e&&(p+=i.slice(0,e-a)),c>r&&(p+=i.slice(r-a)),p.length>0&&n.push({...s,content:[{type:"text",text:p}]});}t=c;}else n.push(s);return n}function k(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(""),c=s,p=s+a.length;if(p<=e||c>=r)t.push(i);else if(c>=e&&p<=r)t.push({...i,formatting:{...i.formatting,...n}});else {let u=Math.max(e,c),l=Math.min(r,p);c<u&&t.push({...i,content:[{type:"text",text:a.slice(0,u-c)}]}),t.push({...i,formatting:{...i.formatting,...n},content:[{type:"text",text:a.slice(u-c,l-c)}]}),p>l&&t.push({...i,content:[{type:"text",text:a.slice(l-c)}]});}s=p;}else t.push(i);return t}function v(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=C(s,e.position.offset,e.text,e.formatting),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=P(a,t.offset,s.offset),a.content=C(a,t.offset,e.text,e.formatting);}else {let i=g(n,t.paragraphIndex),a=n.content[i],c=I(a);a.content=P(a,t.offset,c.length),a.content=C(a,t.offset,e.text,e.formatting);let p=[];for(let u=t.paragraphIndex+1;u<=s.paragraphIndex;u++)p.push(g(n,u));for(let u=p.length-1;u>=0;u--)p[u]!==-1&&n.content.splice(p[u],1);}return r}function N(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=P(a,t.offset,s.offset);}else {let i=g(n,t.paragraphIndex),a=n.content[i],c=I(a);a.content=P(a,t.offset,c.length);let p=g(n,s.paragraphIndex),u=n.content[p];u.content=P(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 M(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=k(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 c=n.content[a],p=I(c),u=0,l=p.length;i===t.paragraphIndex&&(u=t.offset),i===s.paragraphIndex&&(l=s.offset),c.content=k(c,u,l,e.formatting);}return r}function $(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,c=i.numId===1,p=c?"\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(d=>d.ilvl===a);f&&(p=f.lvlText||p);}}}s.listRendering={level:a,numId:i.numId,marker:p,isBullet:c};}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 L(o,e){let r=h(o),n=r.package.document,t=[];for(let a=0;a<e.rows;a++){let c=[];for(let p=0;p<e.columns;p++){let u=e.data?.[a]?.[p]||"";c.push({type:"tableCell",content:[{type:"paragraph",content:u?[T(u)]:[]}]});}t.push({type:"tableRow",formatting:a===0&&e.hasHeader?{header:true}:void 0,cells:c});}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 B(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"}}}]},c=C(s,e.position.offset,"",void 0),p=false,u=0;for(let l=0;l<c.length;l++){let f=c[l];if(f.type==="run"){let d=f.content.filter(m=>m.type==="text").map(m=>m.text).join("");if(u+=d.length,!p&&u>=e.position.offset){c.splice(l+1,0,a),p=true;break}}}return p||c.push(a),s.content=c,r}function F(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],c=I(a),p=e.displayText||c.slice(t.offset,s.offset);a.content=P(a,t.offset,s.offset);let u={type:"hyperlink",href:e.url,tooltip:e.tooltip,children:[T(p)]},l=false,f=0,d=[];for(let m of a.content)if(m.type==="run"){let y=m.content.filter(x=>x.type==="text").map(x=>x.text).join(""),D=f+y.length;if(!l&&f<=t.offset&&t.offset<=D){let x=t.offset-f;x>0&&d.push({...m,content:[{type:"text",text:y.slice(0,x)}]}),d.push(u),x<y.length&&d.push({...m,content:[{type:"text",text:y.slice(x)}]}),l=true;}else d.push(m);f=D;}else d.push(m);return l||d.push(u),a.content=d,r}function V(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 c of i.content)if(c.type==="hyperlink")for(let p of c.children)p.type==="run"&&a.push(p);else a.push(c);return i.content=a,r}function H(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=I(s),a=P({content:[...s.content]},e.position.offset,i.length),c=P({content:[...s.content]},0,e.position.offset);s.content=a;let p={type:"paragraph",formatting:s.formatting,content:c};return n.content.splice(t+1,0,p),r}function z(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 c=g(n,e.paragraphIndex+a);if(c!==-1){let p=n.content[c];s.content.push(...p.content),i.push(c);}}for(let a=i.length-1;a>=0;a--)n.content.splice(i[a],1);return r}function O(o,e){return H(o,{position:e.position})}function X(o,e){let r=h(o);return r.templateVariables||(r.templateVariables=[]),r.templateVariables.includes(e.name)||r.templateVariables.push(e.name),r}function j(o,e){let r=h(o),n=r.package.document;function t(a){for(let c of a.content)if(c.type==="text")for(let[p,u]of Object.entries(e.values)){let l=new RegExp(`\\{${p}\\}`,"g");c.text=c.text.replace(l,u);}}function s(a){for(let c of a.content)if(c.type==="run")t(c);else if(c.type==="hyperlink")for(let p of c.children)p.type==="run"&&t(p);}function i(a){if(a.type==="paragraph")s(a);else if(a.type==="table")for(let c of a.rows)for(let p of c.cells)for(let u of p.content)i(u);}for(let a of n.content)i(a);return r}exports.a=w;exports.b=b;exports.c=U;exports.d=W;exports.e=J;exports.f=q;exports.g=K;exports.h=E;exports.i=Q;exports.j=Y;exports.k=Z;exports.l=ee;exports.m=te;exports.n=_;exports.o=ae;
@@ -1 +0,0 @@
1
- 'use strict';var chunkLVRKZUG4_js=require('./chunk-LVRKZUG4.js'),chunkG46D3GDJ_js=require('./chunk-G46D3GDJ.js');function g(o,e){let{paragraphIndex:t,author:n="AI",text:s,search:a}=e,r=chunkLVRKZUG4_js.b(o,t),p=(o.comments??[]).map(m=>m.id),i=p.length>0?Math.max(...p)+1:1,c={id:i,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=chunkLVRKZUG4_js.i(r,a,t);r.content.splice(m.endRunIndex+1,0,{type:"commentRangeEnd",id:i}),r.content.splice(m.startRunIndex,0,{type:"commentRangeStart",id:i});}else r.content.unshift({type:"commentRangeStart",id:i}),r.content.push({type:"commentRangeEnd",id:i});return i}function y(o,e,t){let n=o.comments??[];if(!n.find(i=>i.id===e))throw new chunkLVRKZUG4_js.h(e);let a=n.map(i=>i.id),r=Math.max(...a)+1,p={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(p),r}function E(o,e){let t=o.comments??[],n=t.find(r=>r.id===e);if(!n)throw new chunkLVRKZUG4_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&&chunkLVRKZUG4_js.c(o,r=>{for(let p=r.content.length-1;p>=0;p--){let i=r.content[p];(i.type==="commentRangeStart"||i.type==="commentRangeEnd")&&i.id===e&&r.content.splice(p,1);}});}function C(o,e){if(!W(o,e,"accept"))throw new chunkLVRKZUG4_js.g(e)}function I(o,e){if(!W(o,e,"reject"))throw new chunkLVRKZUG4_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 chunkLVRKZUG4_js.c(o,n=>{for(let s=n.content.length-1;s>=0;s--){let a=n.content[s];chunkLVRKZUG4_js.a(a)&&(G(n,s,a,e),t++);}}),t}function W(o,e,t){let n=false;return chunkLVRKZUG4_js.c(o,s=>{for(let a=s.content.length-1;a>=0;a--){let r=s.content[a];chunkLVRKZUG4_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=chunkLVRKZUG4_js.b(o,t),{startIndex:p,endIndex:i}=chunkLVRKZUG4_js.j(r,n,t),c=new Date().toISOString(),m=w(o),d=r.content.slice(p,i+1),R={type:"deletion",info:{id:m,author:s,date:c},content:d},v={type:"insertion",info:{id:m+1,author:s,date:c},content:[{type:"run",content:[{type:"text",text:a}]}]};r.content.splice(p,i-p+1,R,v);}function H(o,e){let{paragraphIndex:t,author:n="AI",insertText:s,position:a="after",search:r}=e,p=chunkLVRKZUG4_js.b(o,t),i=new Date().toISOString(),m={type:"insertion",info:{id:w(o),author:n,date:i},content:[{type:"run",content:[{type:"text",text:s}]}]};if(r){let{startIndex:d,endIndex:R}=chunkLVRKZUG4_js.j(p,r,t),v=a==="after"?R+1:d;p.content.splice(v,0,m);}else a==="before"?p.content.unshift(m):p.content.push(m);}function L(o,e){let{paragraphIndex:t,search:n,author:s="AI"}=e,a=chunkLVRKZUG4_js.b(o,t),{startIndex:r,endIndex:p}=chunkLVRKZUG4_js.j(a,n,t),i=new Date().toISOString(),c=w(o),m=a.content.slice(r,p+1),d={type:"deletion",info:{id:c,author:s,date:i},content:m};a.content.splice(r,p-r+1,d);}var S=new WeakMap;function w(o){let e=S.get(o);e===void 0&&(e=0,chunkLVRKZUG4_js.c(o,n=>{for(let s of n.content)chunkLVRKZUG4_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,p=0,i=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}),p++;}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}),i++;}catch(m){n.push({operation:"proposal",search:c.search,error:m.message});}return {accepted:s,rejected:a,commentsAdded:r,repliesAdded:p,proposalsAdded:i,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 chunkG46D3GDJ_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 chunkLVRKZUG4_js.d(this.body,e)}getContentAsText(e){return chunkLVRKZUG4_js.e(chunkLVRKZUG4_js.d(this.body,e))}getChanges(e){return chunkLVRKZUG4_js.k(this.body,e)}getComments(e){return chunkLVRKZUG4_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-FE3K7ABO.js');return e(this.doc)}};exports.a=U;
@@ -1 +0,0 @@
1
- import {d,e,k as k$1,l,b,i,h,c,j,g as g$1,a}from'./chunk-CPJV53R6.mjs';import {w as w$1}from'./chunk-XZHZXQO5.mjs';function g(o,e){let{paragraphIndex:t,author:n="AI",text:s,search:a}=e,r=b(o,t),p=(o.comments??[]).map(m=>m.id),i$1=p.length>0?Math.max(...p)+1:1,c={id:i$1,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:i$1}),r.content.splice(m.startRunIndex,0,{type:"commentRangeStart",id:i$1});}else r.content.unshift({type:"commentRangeStart",id:i$1}),r.content.push({type:"commentRangeEnd",id:i$1});return i$1}function y(o,e,t){let n=o.comments??[];if(!n.find(i=>i.id===e))throw new h(e);let a=n.map(i=>i.id),r=Math.max(...a)+1,p={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(p),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 p=r.content.length-1;p>=0;p--){let i=r.content[p];(i.type==="commentRangeStart"||i.type==="commentRangeEnd")&&i.id===e&&r.content.splice(p,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:p,endIndex:i}=j(r,n,t),c=new Date().toISOString(),m=w(o),d=r.content.slice(p,i+1),R={type:"deletion",info:{id:m,author:s,date:c},content:d},v={type:"insertion",info:{id:m+1,author:s,date:c},content:[{type:"run",content:[{type:"text",text:a}]}]};r.content.splice(p,i-p+1,R,v);}function H(o,e){let{paragraphIndex:t,author:n="AI",insertText:s,position:a="after",search:r}=e,p=b(o,t),i=new Date().toISOString(),m={type:"insertion",info:{id:w(o),author:n,date:i},content:[{type:"run",content:[{type:"text",text:s}]}]};if(r){let{startIndex:d,endIndex:R}=j(p,r,t),v=a==="after"?R+1:d;p.content.splice(v,0,m);}else a==="before"?p.content.unshift(m):p.content.push(m);}function L(o,e){let{paragraphIndex:t,search:n,author:s="AI"}=e,a=b(o,t),{startIndex:r,endIndex:p}=j(a,n,t),i=new Date().toISOString(),c=w(o),m=a.content.slice(r,p+1),d={type:"deletion",info:{id:c,author:s,date:i},content:m};a.content.splice(r,p-r+1,d);}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,p=0,i=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}),p++;}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}),i++;}catch(m){n.push({operation:"proposal",search:c.search,error:m.message});}return {accepted:s,rejected:a,commentsAdded:r,repliesAdded:p,proposalsAdded:i,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-JRF2KBID.mjs');return e(this.doc)}};export{U as a};