@eigenpal/docx-js-editor 0.0.28 → 0.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ClipboardManager-BzgQ-SOi.d.cts → ClipboardManager-t936d0KD.d.mts} +1 -1
- package/dist/{DocumentAgent-B9FUoSVS.d.cts → DocumentAgent-BqA9EJ3F.d.mts} +1 -1
- package/dist/FindReplaceDialog-AQFR4OCT.js +1 -1
- package/dist/FindReplaceDialog-N4J5OB7O.mjs +1 -0
- package/dist/FootnotePropertiesDialog-UFUIHLDW.mjs +1 -0
- package/dist/FootnotePropertiesDialog-YYIZU5U6.js +1 -1
- package/dist/HyperlinkDialog-HGZ2S37Z.js +1 -1
- package/dist/HyperlinkDialog-YQSQFHOP.mjs +1 -0
- package/dist/ImagePositionDialog-DQ4JWS4F.js +1 -1
- package/dist/ImagePositionDialog-HT6J2SHV.mjs +1 -0
- package/dist/ImagePropertiesDialog-3VK2S2AF.mjs +1 -0
- package/dist/ImagePropertiesDialog-GJMGLM6G.js +1 -1
- package/dist/PageSetupDialog-3QCVUNDL.mjs +1 -0
- package/dist/PageSetupDialog-ZZTFPZKJ.js +1 -1
- package/dist/TablePropertiesDialog-FI5E3RCB.mjs +1 -0
- package/dist/TablePropertiesDialog-STZOGHJB.js +1 -1
- package/dist/chunk-2KHL5RSD.js +3 -3
- package/dist/chunk-4VUZBV2S.js +1 -1
- package/dist/chunk-6WPRCJ5A.mjs +1 -0
- package/dist/chunk-7HZRJTOL.mjs +4 -0
- package/dist/chunk-AARNCPWR.js +1 -1
- package/dist/chunk-AZRYS2WF.mjs +2 -0
- package/dist/chunk-BUEMG4NW.js +1 -1
- package/dist/chunk-CQRI4YUS.mjs +26 -0
- package/dist/chunk-CTYOM6BE.js +2 -2
- package/dist/{chunk-PRBTINOW.js → chunk-DLVLK5FT.mjs} +2 -2
- package/dist/chunk-FVUGBRDD.js +1 -1
- package/dist/chunk-G72SXG7G.js +258 -0
- package/dist/chunk-H5NTJZO4.js +1 -1
- package/dist/chunk-I6LFWQFR.mjs +59 -0
- package/dist/chunk-IFPN3NT3.js +3 -3
- package/dist/chunk-IRO7KGGC.js +59 -0
- package/dist/chunk-KCUPCJFL.mjs +111 -0
- package/dist/chunk-LYBG4YI7.mjs +1 -0
- package/dist/chunk-M5F4SK3W.mjs +1 -0
- package/dist/chunk-MRWJ3GNH.js +9 -0
- package/dist/chunk-MVCTPHRR.mjs +258 -0
- package/dist/chunk-PB7VMDDP.js +24 -0
- package/dist/chunk-PJVI53AH.js +2 -2
- package/dist/chunk-QAZ4233N.mjs +1 -0
- package/dist/{chunk-OJ7NJK46.cjs → chunk-QQ63M65M.js} +1 -1
- package/dist/chunk-QTSXJRP6.mjs +1 -0
- package/dist/chunk-QVPR2W5S.js +1 -1
- package/dist/chunk-SE5EN2QL.js +1 -1
- package/dist/chunk-TAUMSKRE.mjs +1 -0
- package/dist/{chunk-JO2CKU4O.js → chunk-TDEHAPMZ.mjs} +1 -1
- package/dist/chunk-VHWEKJ35.js +10 -0
- package/dist/chunk-VR6PT4IZ.js +26 -0
- package/dist/chunk-W53SI3XW.mjs +1 -0
- package/dist/chunk-WOHFANC5.mjs +3 -0
- package/dist/chunk-XGL3EGKF.js +7 -7
- package/dist/chunk-XWBCP563.mjs +2 -0
- package/dist/{chunk-TOGKKPIW.js → chunk-YGTSQZRK.mjs} +1 -1
- package/dist/chunk-Z35FA4M4.mjs +10 -0
- package/dist/{clipboard-Cm7udEnb.d.cts → clipboard-BkM7Zvgs.d.mts} +1 -1
- package/dist/{colorResolver-Bu7uJqpw.d.cts → colorResolver-BwI_Uxp3.d.mts} +2 -2
- package/dist/{core-plugins-reexport.d.cts → core-plugins-reexport.d.mts} +4 -4
- package/dist/core-plugins-reexport.js +1 -1
- package/dist/core-plugins-reexport.mjs +1 -0
- package/dist/{core-reexport.d.cts → core-reexport.d.mts} +11 -11
- package/dist/core-reexport.js +1 -1
- package/dist/core-reexport.mjs +1 -0
- package/dist/executor-L2MVKMXO.js +1 -1
- package/dist/executor-XKBCCVNY.mjs +1 -0
- package/dist/{fontLoader-X8ocGzeD.d.cts → fontLoader-DicgJidU.d.mts} +1 -1
- package/dist/{headless-reexport.d.cts → headless-reexport.d.mts} +7 -7
- package/dist/headless-reexport.js +2 -2
- package/dist/headless-reexport.mjs +4 -0
- package/dist/{index.d.cts → index.d.mts} +14 -14
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -6
- package/dist/index.mjs +155 -0
- package/dist/lib-BCT2DRYI.mjs +1 -0
- package/dist/lib-U35UU4OU.js +1 -1
- package/dist/{mcp-reexport.d.cts → mcp-reexport.d.mts} +2 -2
- package/dist/mcp-reexport.js +9 -9
- package/dist/mcp-reexport.mjs +16 -0
- package/dist/processTemplate-5ZST2Q5L.js +1 -0
- package/dist/{processTemplate-CGIQEJ26.js → processTemplate-LRHXOWMZ.mjs} +1 -1
- package/dist/{react-BgZObIoP.d.ts → react-By80Gfi-.d.ts} +4 -0
- package/dist/{react-D9JDP3cV.d.cts → react-C-pJU0Y4.d.mts} +8 -4
- package/dist/{react.d.cts → react.d.mts} +5 -5
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/react.mjs +1 -0
- package/dist/{registry-Bxb5ZI1z.d.cts → registry-DyIMyB-0.d.mts} +1 -1
- package/dist/selectionRects-6TRAXB7D.js +1 -0
- package/dist/selectionRects-IS7ZAS3A.mjs +1 -0
- package/dist/{types-D03hsi5t.d.cts → types-B3LkfO0u.d.mts} +1 -1
- package/dist/{ui.d.cts → ui.d.mts} +3 -3
- package/dist/ui.js +1 -1
- package/dist/ui.mjs +1 -0
- package/dist/{variableDetector-iGl52A6q.d.cts → variableDetector-CIqTek7A.d.mts} +1 -1
- package/package.json +17 -18
- package/dist/FindReplaceDialog-J3DI3U5I.cjs +0 -1
- package/dist/FootnotePropertiesDialog-DO5DCAW6.cjs +0 -1
- package/dist/HyperlinkDialog-PEPS3C2G.cjs +0 -1
- package/dist/ImagePositionDialog-UYXYHSP4.cjs +0 -1
- package/dist/ImagePropertiesDialog-V6SVKINO.cjs +0 -1
- package/dist/PageSetupDialog-RLMYJ3BA.cjs +0 -1
- package/dist/TablePropertiesDialog-A36OXG3A.cjs +0 -1
- package/dist/chunk-2FYTKTQL.cjs +0 -111
- package/dist/chunk-2VHQ7YOQ.cjs +0 -1
- package/dist/chunk-3YHC2RAO.js +0 -258
- package/dist/chunk-63YB7DGI.js +0 -59
- package/dist/chunk-7OCUAFPO.cjs +0 -258
- package/dist/chunk-HE3SUXOQ.cjs +0 -4
- package/dist/chunk-HRUPO723.js +0 -10
- package/dist/chunk-IA4LPH2A.cjs +0 -1
- package/dist/chunk-JMR5HNJP.cjs +0 -10
- package/dist/chunk-KR32M3S4.cjs +0 -1
- package/dist/chunk-MSV5LTHM.cjs +0 -9
- package/dist/chunk-NLYEW36R.js +0 -26
- package/dist/chunk-NVAQQYBJ.cjs +0 -1
- package/dist/chunk-P7ZF45KZ.cjs +0 -1
- package/dist/chunk-PCJ5ACUV.cjs +0 -1
- package/dist/chunk-PVV7DV3L.cjs +0 -59
- package/dist/chunk-QDNL7NWN.cjs +0 -3
- package/dist/chunk-VPDOOMUJ.cjs +0 -26
- package/dist/chunk-VTAS7VZ6.cjs +0 -2
- package/dist/chunk-XKBIFFAS.cjs +0 -24
- package/dist/chunk-XS2AQFMF.cjs +0 -2
- package/dist/chunk-YS7FDEZ4.cjs +0 -1
- package/dist/core-plugins-reexport.cjs +0 -1
- package/dist/core-reexport.cjs +0 -1
- package/dist/executor-JGWZ7S6Z.cjs +0 -1
- package/dist/headless-reexport.cjs +0 -4
- package/dist/index.cjs +0 -155
- package/dist/lib-SPXD4LFI.cjs +0 -1
- package/dist/mcp-reexport.cjs +0 -16
- package/dist/processTemplate-FOYV6BC5.cjs +0 -1
- package/dist/react.cjs +0 -1
- package/dist/selectionRects-BMXJJCPJ.cjs +0 -1
- package/dist/selectionRects-TWK7CAC3.js +0 -1
- package/dist/ui.cjs +0 -1
- /package/dist/{agentApi-BVHzyk2l.d.cts → agentApi-BVHzyk2l.d.mts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {b as b$1}from'./chunk-W53SI3XW.mjs';function v(s,t){let a=b$1.getCommandHandler(t.type);if(a)return a(s,t);switch(t.type){case "insertText":return R(s,t);case "replaceText":return E(s,t);case "deleteText":return B(s,t);case "formatText":return S(s,t);case "formatParagraph":return V(s,t);case "applyStyle":return $(s,t);case "insertTable":return H(s,t);case "insertImage":return A(s,t);case "insertHyperlink":return F(s,t);case "removeHyperlink":return j(s,t);case "insertParagraphBreak":return T(s,t);case "mergeParagraphs":return N(s,t);case "splitParagraph":return M(s,t);case "setVariable":return O(s,t);case "applyVariables":return _(s,t);default:let r=t;throw new Error(`Unknown command type: ${r.type}`)}}function z(s,t){return t.reduce((a,r)=>v(a,r),s)}function h(s){return JSON.parse(JSON.stringify(s))}function g(s,t){let a=0;for(let r=0;r<s.content.length;r++)if(s.content[r].type==="paragraph"){if(a===t)return r;a++;}return -1}function I(s){let t="";for(let a of s.content)if(a.type==="run")for(let r of a.content)r.type==="text"&&(t+=r.text);else if(a.type==="hyperlink"){for(let r of a.children)if(r.type==="run")for(let e of r.content)e.type==="text"&&(t+=e.text);}return t}function b(s,t){return {type:"run",formatting:t,content:[{type:"text",text:s}]}}function C(s,t,a,r){let e=[],o=0,p=false;for(let n of s.content)if(n.type==="run"){let c=n.content.filter(l=>l.type==="text").map(l=>l.text).join(""),i=o,u=o+c.length;if(!p&&t>=i&&t<=u){let l=t-i;l>0&&e.push({...n,content:[{type:"text",text:c.slice(0,l)}]}),e.push(b(a,r||n.formatting)),l<c.length&&e.push({...n,content:[{type:"text",text:c.slice(l)}]}),p=true;}else e.push(n);o=u;}else e.push(n);return p||e.push(b(a,r)),e}function y(s,t,a){let r=[],e=0;for(let o of s.content)if(o.type==="run"){let p=o.content.filter(i=>i.type==="text").map(i=>i.text).join(""),n=e,c=e+p.length;if(c<=t||n>=a)r.push(o);else {let i="";n<t&&(i+=p.slice(0,t-n)),c>a&&(i+=p.slice(a-n)),i.length>0&&r.push({...o,content:[{type:"text",text:i}]});}e=c;}else r.push(o);return r}function D(s,t,a,r){let e=[],o=0;for(let p of s.content)if(p.type==="run"){let n=p.content.filter(u=>u.type==="text").map(u=>u.text).join(""),c=o,i=o+n.length;if(i<=t||c>=a)e.push(p);else if(c>=t&&i<=a)e.push({...p,formatting:{...p.formatting,...r}});else {let u=Math.max(t,c),l=Math.min(a,i);c<u&&e.push({...p,content:[{type:"text",text:n.slice(0,u-c)}]}),e.push({...p,formatting:{...p.formatting,...r},content:[{type:"text",text:n.slice(u-c,l-c)}]}),i>l&&e.push({...p,content:[{type:"text",text:n.slice(l-c)}]});}o=i;}else e.push(p);return e}function R(s,t){let a=h(s),r=a.package.document,e=g(r,t.position.paragraphIndex);if(e===-1)throw new Error(`Paragraph index ${t.position.paragraphIndex} not found`);let o=r.content[e];return o.content=C(o,t.position.offset,t.text,t.formatting),a}function E(s,t){let a=h(s),r=a.package.document,{start:e,end:o}=t.range;if(e.paragraphIndex===o.paragraphIndex){let p=g(r,e.paragraphIndex);if(p===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let n=r.content[p];n.content=y(n,e.offset,o.offset),n.content=C(n,e.offset,t.text,t.formatting);}else {let p=g(r,e.paragraphIndex),n=r.content[p],c=I(n);n.content=y(n,e.offset,c.length),n.content=C(n,e.offset,t.text,t.formatting);let i=[];for(let u=e.paragraphIndex+1;u<=o.paragraphIndex;u++)i.push(g(r,u));for(let u=i.length-1;u>=0;u--)i[u]!==-1&&r.content.splice(i[u],1);}return a}function B(s,t){let a=h(s),r=a.package.document,{start:e,end:o}=t.range;if(e.paragraphIndex===o.paragraphIndex){let p=g(r,e.paragraphIndex);if(p===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let n=r.content[p];n.content=y(n,e.offset,o.offset);}else {let p=g(r,e.paragraphIndex),n=r.content[p],c=I(n);n.content=y(n,e.offset,c.length);let i=g(r,o.paragraphIndex),u=r.content[i];u.content=y(u,0,o.offset),n.content.push(...u.content);let l=[];for(let f=e.paragraphIndex+1;f<=o.paragraphIndex;f++)l.push(g(r,f));for(let f=l.length-1;f>=0;f--)l[f]!==-1&&r.content.splice(l[f],1);}return a}function S(s,t){let a=h(s),r=a.package.document,{start:e,end:o}=t.range;if(e.paragraphIndex===o.paragraphIndex){let p=g(r,e.paragraphIndex);if(p===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let n=r.content[p];n.content=D(n,e.offset,o.offset,t.formatting);}else for(let p=e.paragraphIndex;p<=o.paragraphIndex;p++){let n=g(r,p);if(n===-1)continue;let c=r.content[n],i=I(c),u=0,l=i.length;p===e.paragraphIndex&&(u=e.offset),p===o.paragraphIndex&&(l=o.offset),c.content=D(c,u,l,t.formatting);}return a}function V(s,t){let a=h(s),r=a.package.document,e=g(r,t.paragraphIndex);if(e===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let o=r.content[e];if(o.formatting={...o.formatting,...t.formatting},"numPr"in t.formatting){let p=t.formatting.numPr;if(p&&p.numId!==void 0&&p.numId!==0){let n=p.ilvl??0,c=p.numId===1,i=c?"\u2022":"1.";if(a.package.numbering){let u=a.package.numbering.nums.find(l=>l.numId===p.numId);if(u){let l=a.package.numbering.abstractNums.find(f=>f.abstractNumId===u.abstractNumId);if(l){let f=l.levels.find(x=>x.ilvl===n);f&&(i=f.lvlText||i);}}}o.listRendering={level:n,numId:p.numId,marker:i,isBullet:c};}else delete o.listRendering;}return a}function $(s,t){let a=h(s),r=a.package.document,e=g(r,t.paragraphIndex);if(e===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let o=r.content[e];return o.formatting={...o.formatting,styleId:t.styleId},a}function H(s,t){let a=h(s),r=a.package.document,e=[];for(let n=0;n<t.rows;n++){let c=[];for(let i=0;i<t.columns;i++){let u=t.data?.[n]?.[i]||"";c.push({type:"tableCell",content:[{type:"paragraph",content:u?[b(u)]:[]}]});}e.push({type:"tableRow",formatting:n===0&&t.hasHeader?{header:true}:void 0,cells:c});}let o={type:"table",rows:e},p=g(r,t.position.paragraphIndex);return p===-1?r.content.push(o):r.content.splice(p+1,0,o),a}function A(s,t){let a=h(s),r=a.package.document,e=g(r,t.position.paragraphIndex);if(e===-1)throw new Error(`Paragraph index ${t.position.paragraphIndex} not found`);let o=r.content[e],n={type:"run",content:[{type:"drawing",image:{type:"image",rId:`rId_img_${Date.now()}`,src:t.src,alt:t.alt,size:{width:(t.width||100)*914400,height:(t.height||100)*914400},wrap:{type:"inline"}}}]},c=C(o,t.position.offset,"",void 0),i=false,u=0;for(let l=0;l<c.length;l++){let f=c[l];if(f.type==="run"){let x=f.content.filter(d=>d.type==="text").map(d=>d.text).join("");if(u+=x.length,!i&&u>=t.position.offset){c.splice(l+1,0,n),i=true;break}}}return i||c.push(n),o.content=c,a}function F(s,t){let a=h(s),r=a.package.document,{start:e,end:o}=t.range;if(e.paragraphIndex!==o.paragraphIndex)throw new Error("Hyperlinks cannot span multiple paragraphs");let p=g(r,e.paragraphIndex);if(p===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let n=r.content[p],c=I(n),i=t.displayText||c.slice(e.offset,o.offset);n.content=y(n,e.offset,o.offset);let u={type:"hyperlink",href:t.url,tooltip:t.tooltip,children:[b(i)]},l=false,f=0,x=[];for(let d of n.content)if(d.type==="run"){let P=d.content.filter(m=>m.type==="text").map(m=>m.text).join(""),w=f+P.length;if(!l&&f<=e.offset&&e.offset<=w){let m=e.offset-f;m>0&&x.push({...d,content:[{type:"text",text:P.slice(0,m)}]}),x.push(u),m<P.length&&x.push({...d,content:[{type:"text",text:P.slice(m)}]}),l=true;}else x.push(d);f=w;}else x.push(d);return l||x.push(u),n.content=x,a}function j(s,t){let a=h(s),r=a.package.document,{start:e}=t.range,o=g(r,e.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let p=r.content[o],n=[];for(let c of p.content)if(c.type==="hyperlink")for(let i of c.children)i.type==="run"&&n.push(i);else n.push(c);return p.content=n,a}function T(s,t){let a=h(s),r=a.package.document,e=g(r,t.position.paragraphIndex);if(e===-1)throw new Error(`Paragraph index ${t.position.paragraphIndex} not found`);let o=r.content[e],p=I(o),n=y({...o,content:[...o.content]},t.position.offset,p.length),c=y({...o,content:[...o.content]},0,t.position.offset);o.content=n;let i={type:"paragraph",formatting:o.formatting,content:c};return r.content.splice(e+1,0,i),a}function N(s,t){let a=h(s),r=a.package.document,e=g(r,t.paragraphIndex);if(e===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let o=r.content[e],p=[];for(let n=1;n<=t.count;n++){let c=g(r,t.paragraphIndex+n);if(c!==-1){let i=r.content[c];o.content.push(...i.content),p.push(c);}}for(let n=p.length-1;n>=0;n--)r.content.splice(p[n],1);return a}function M(s,t){return T(s,{position:t.position})}function O(s,t){let a=h(s);return a.templateVariables||(a.templateVariables=[]),a.templateVariables.includes(t.name)||a.templateVariables.push(t.name),a}function _(s,t){let a=h(s),r=a.package.document;function e(n){for(let c of n.content)if(c.type==="text")for(let[i,u]of Object.entries(t.values)){let l=new RegExp(`\\{${i}\\}`,"g");c.text=c.text.replace(l,u);}}function o(n){for(let c of n.content)if(c.type==="run")e(c);else if(c.type==="hyperlink")for(let i of c.children)i.type==="run"&&e(i);}function p(n){if(n.type==="paragraph")o(n);else if(n.type==="table")for(let c of n.rows)for(let i of c.cells)for(let u of i.content)p(u);}for(let n of r.content)p(n);return a}export{v as a,z as b};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';var chunkVHWEKJ35_js=require('./chunk-VHWEKJ35.js'),chunkIRO7KGGC_js=require('./chunk-IRO7KGGC.js'),chunkAARNCPWR_js=require('./chunk-AARNCPWR.js'),chunkVR6PT4IZ_js=require('./chunk-VR6PT4IZ.js'),chunkH5NTJZO4_js=require('./chunk-H5NTJZO4.js');function G(r,t){let e=et(t),n=new RegExp(`<w:p[\\s][^>]*w14:paraId="${e}"`,"g"),a=[],o;for(;(o=n.exec(r))!==null;)a.push(o.index);if(a.length===0||a.length>1)return null;let s=a[0],i=s,c=0;for(;i<r.length;){let l=r.indexOf("<",i);if(l===-1)break;if(r.startsWith("<w:p",l)){let u=r[l+4];if(u===">"||u===" "||u==="/"){let g=r.indexOf(">",l);if(g===-1)break;if(r[g-1]==="/"){if(c===0)return {start:s,end:g+1};i=g+1;}else c++,i=g+1;}else i=l+1;}else if(r.startsWith("</w:p>",l)){if(c--,c===0)return {start:s,end:l+6};i=l+6;}else i=l+1;}return null}function Q(r,t){let e=G(r,t);return e?r.substring(e.start,e.end):null}function q(r){let t=0,e=/<w:p[\s>]/g,n;for(;(n=e.exec(r))!==null;){let a=n.index,o=r[a+4];(o===">"||o===" ")&&t++;}return t}function X(r){let t=new Map,e=/w14:paraId="([^"]+)"/g,n;for(;(n=e.exec(r))!==null;){let a=n[1];t.set(a,(t.get(a)||0)+1);}return t}function tt(r,t,e){if(e.size===0)return {safe:true};let n=X(r),a=X(t);for(let i of e){let c=n.get(i)||0;if(c===0)return {safe:false,reason:`paraId-not-found-in-original: ${i}`};if(c>1)return {safe:false,reason:`duplicate-paraId-in-original: ${i}`}}for(let i of e){let c=a.get(i)||0;if(c===0)return {safe:false,reason:`paraId-not-found-in-serialized: ${i}`};if(c>1)return {safe:false,reason:`duplicate-paraId-in-serialized: ${i}`}}let o=q(r),s=q(t);return o!==s?{safe:false,reason:`paragraph-count-mismatch: original=${o}, serialized=${s}`}:{safe:true}}function Z(r,t,e){if(e.size===0)return r;if(!tt(r,t,e).safe)return null;let a=[];for(let s of e){let i=G(r,s);if(!i)return null;let c=Q(t,s);if(!c)return null;a.push({start:i.start,end:i.end,newXml:c});}a.sort((s,i)=>i.start-s.start);let o=r;for(let{start:s,end:i,newXml:c}of a)o=o.substring(0,s)+c+o.substring(i);return o}function et(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function J(r){for(let t of r)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="run"){for(let n of e.content)if(n.type==="drawing"&&n.image?.src?.startsWith("data:")&&!n.image?.rId)return true}else if(e.type==="hyperlink"&&e.href&&!e.rId&&!e.anchor)return true}else if(t.type==="table"){for(let e of t.rows)for(let n of e.cells)if(J(n.content))return true}return false}async function Y(r,t,e){let{changedParaIds:n,structuralChange:a,hasUntrackedChanges:o}=e;if(a||o||!t)return null;let s=r.package.document.content;if(J(s))return null;let i=r.package.document.comments,c=i&&i.length>0,l=chunkIRO7KGGC_js.j(r);try{let g=await(await import('./lib-U35UU4OU.js')).default.loadAsync(t),f=new Map;if(n.size>0){let p=g.file("word/document.xml");if(!p)return null;let m=await p.async("text"),b=chunkIRO7KGGC_js.c(r),d=Z(m,b,n);if(!d)return null;f.set("word/document.xml",d);}if(c){f.set("word/comments.xml",chunkIRO7KGGC_js.d(i));let p=g.file("[Content_Types].xml");if(p){let d=await p.async("text");d.includes("/word/comments.xml")||f.set("[Content_Types].xml",d.replace("</Types>",`<Override PartName="/word/comments.xml" ContentType="${chunkIRO7KGGC_js.g}"/></Types>`));}let m="word/_rels/document.xml.rels",b=g.file(m);if(b){let d=await b.async("text");if(!d.includes("comments.xml")){let x=chunkIRO7KGGC_js.e(d);f.set(m,d.replace("</Relationships>",`<Relationship Id="rId${x+1}" Type="${chunkVR6PT4IZ_js.a.comments}" Target="comments.xml"/></Relationships>`));}}}for(let[p,m]of l)f.set(p,m);let y=g.file("docProps/core.xml");if(y){let p=await y.async("text");f.set("docProps/core.xml",chunkIRO7KGGC_js.k(p,{updateModifiedDate:!0}));}return await chunkIRO7KGGC_js.i(g,f)}catch{return null}}function nt(){return [{styleId:"Normal",type:"paragraph",name:"Normal",default:true,qFormat:true,uiPriority:0,rPr:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:276}},{styleId:"Title",type:"paragraph",name:"Title",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:10,rPr:{fontSize:52,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:240}},{styleId:"Subtitle",type:"paragraph",name:"Subtitle",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:11,rPr:{fontSize:30,color:{rgb:"666666"},fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:240}},{styleId:"Heading1",type:"paragraph",name:"Heading 1",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:40,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:400,spaceAfter:120,lineSpacing:240}},{styleId:"Heading2",type:"paragraph",name:"Heading 2",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:32,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:360,spaceAfter:80,lineSpacing:240}},{styleId:"Heading3",type:"paragraph",name:"Heading 3",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:28,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:320,spaceAfter:80,lineSpacing:240}},{styleId:"Heading4",type:"paragraph",name:"Heading 4",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:24,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:280,spaceAfter:80,lineSpacing:240}}]}function rt(){return {pageWidth:12240,pageHeight:15840,orientation:"portrait",marginTop:1440,marginBottom:1440,marginLeft:1440,marginRight:1440,headerDistance:720,footerDistance:720,gutter:0,columnCount:1,columnSpace:720,equalWidth:true,sectionStart:"nextPage",verticalAlign:"top"}}function at(r={}){let t=rt();r.pageWidth!==void 0&&(t.pageWidth=r.pageWidth),r.pageHeight!==void 0&&(t.pageHeight=r.pageHeight),r.orientation!==void 0&&(t.orientation=r.orientation),r.marginTop!==void 0&&(t.marginTop=r.marginTop),r.marginBottom!==void 0&&(t.marginBottom=r.marginBottom),r.marginLeft!==void 0&&(t.marginLeft=r.marginLeft),r.marginRight!==void 0&&(t.marginRight=r.marginRight);let e={type:"text",text:r.initialText||""};return {package:{document:{content:[{type:"paragraph",content:[{type:"run",content:r.initialText?[e]:[],formatting:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}}}],formatting:{lineSpacing:276}}],finalSectionProperties:t},styles:{docDefaults:{rPr:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:276}},styles:nt()}},templateVariables:[],warnings:[]}}function Wt(r,t={}){return at({...t,initialText:r})}var T=class r{constructor(t){chunkH5NTJZO4_js.d(this,"_document");chunkH5NTJZO4_js.d(this,"_pendingVariables");t instanceof ArrayBuffer||ArrayBuffer.isView(t)?this._document={package:{document:{content:[]}},originalBuffer:t instanceof ArrayBuffer?t:t.buffer}:this._document=t,this._pendingVariables={};}static async fromBuffer(t){let e=await chunkVR6PT4IZ_js.n(t);return new r(e)}static fromDocument(t){return new r(t)}getDocument(){return this._document}getText(){let t=this._document.package.document;return this._getBodyText(t)}getFormattedText(){let t=[],e=this._document.package.document;for(let n of e.content)n.type==="paragraph"&&this._extractParagraphSegments(n,t);return t}getVariables(){return chunkVHWEKJ35_js.a(this._document)}getStyles(){let t=this._document.package.styles;if(!t?.styles)return [];let e=[];for(let[n,a]of Object.entries(t.styles))if(typeof a=="object"&&a!==null){let o=a;e.push({id:n,name:o.name||n,type:o.type==="numbering"?"paragraph":o.type||"paragraph",builtIn:o.default});}return e}getPageCount(){let t=this.getWordCount();return Math.max(1,Math.ceil(t/500))}getWordCount(){return this.getText().split(/\s+/).filter(n=>n.length>0).length}getCharacterCount(t=true){let e=this.getText();return t?e.length:e.replace(/\s/g,"").length}getParagraphCount(){return this._document.package.document.content.filter(t=>t.type==="paragraph").length}getTableCount(){return this._document.package.document.content.filter(t=>t.type==="table").length}getAgentContext(t=100){let e=this._document.package.document,n=e.content.filter(s=>s.type==="paragraph"),a=n.map((s,i)=>{let c=this._getParagraphText(s),l=s.formatting?.styleId;return {index:i,preview:c.slice(0,t),style:l,isHeading:l?.toLowerCase().includes("heading")||false,headingLevel:this._parseHeadingLevel(l),isListItem:!!s.listRendering,isEmpty:c.trim().length===0}}),o=(e.sections||[]).map((s,i)=>({index:i,paragraphCount:s.content?.length||0,pageSize:s.properties?.pageWidth&&s.properties?.pageHeight?{width:s.properties.pageWidth,height:s.properties.pageHeight}:void 0,isLandscape:s.properties?.orientation==="landscape",hasHeader:!!s.properties?.headerReferences?.length,hasFooter:!!s.properties?.footerReferences?.length}));return {paragraphCount:n.length,wordCount:this.getWordCount(),characterCount:this.getCharacterCount(),variables:this.getVariables(),variableCount:this.getVariables().length,availableStyles:this.getStyles(),outline:a,sections:o,hasTables:this.getTableCount()>0,hasImages:this._hasImages(),hasHyperlinks:this._hasHyperlinks()}}insertText(t,e,n={}){let a={type:"insertText",position:t,text:e,formatting:n.formatting};return this._executeCommand(a)}replaceRange(t,e,n={}){let a={type:"replaceText",range:t,text:e,formatting:n.formatting};return this._executeCommand(a)}deleteRange(t){let e={type:"deleteText",range:t};return this._executeCommand(e)}applyFormatting(t,e){let n={type:"formatText",range:t,formatting:e};return this._executeCommand(n)}applyStyle(t,e){let n={type:"applyStyle",paragraphIndex:t,styleId:e};return this._executeCommand(n)}applyParagraphFormatting(t,e){let n={type:"formatParagraph",paragraphIndex:t,formatting:e};return this._executeCommand(n)}insertTable(t,e,n,a={}){let o={type:"insertTable",position:t,rows:e,columns:n,data:a.data,hasHeader:a.hasHeader};return this._executeCommand(o)}insertImage(t,e,n={}){let a={type:"insertImage",position:t,src:e,width:n.width,height:n.height,alt:n.alt};return this._executeCommand(a)}insertHyperlink(t,e,n={}){let a={type:"insertHyperlink",range:t,url:e,displayText:n.displayText,tooltip:n.tooltip};return this._executeCommand(a)}removeHyperlink(t){let e={type:"removeHyperlink",range:t};return this._executeCommand(e)}insertParagraphBreak(t){let e={type:"insertParagraphBreak",position:t};return this._executeCommand(e)}mergeParagraphs(t,e){let n={type:"mergeParagraphs",paragraphIndex:t,count:e};return this._executeCommand(n)}setVariable(t,e){return this._pendingVariables[t]=e,this}setVariables(t){for(let[e,n]of Object.entries(t))this._pendingVariables[e]=n;return this}getPendingVariables(){return {...this._pendingVariables}}clearPendingVariables(){return this._pendingVariables={},this}async applyVariables(t){let e={...this._pendingVariables,...t};if(Object.keys(e).length===0)return this;let n=this._document.originalBuffer;if(!n)throw new Error("Cannot apply variables: no original buffer for processing");let{processTemplate:a}=await import('./processTemplate-5ZST2Q5L.js'),o=a(n,e),s=await chunkVR6PT4IZ_js.n(o),i=new r(s);return i._pendingVariables={},i}async toBuffer(t){if(this._document.originalBuffer){if(t?.selective){let n=await Y(this._document,this._document.originalBuffer,t.selective);if(n)return this._document.originalBuffer=n,n}let e=await chunkIRO7KGGC_js.f(this._document);return this._document.originalBuffer=e,e}return chunkIRO7KGGC_js.l(this._document)}async toBlob(t="application/vnd.openxmlformats-officedocument.wordprocessingml.document"){let e=await this.toBuffer();return new Blob([e],{type:t})}executeCommands(t){return new r(chunkAARNCPWR_js.b(this._document,t))}_executeCommand(t){let e=new r(chunkAARNCPWR_js.a(this._document,t));return e._pendingVariables={...this._pendingVariables},e}_getBodyText(t){let e=[];for(let n of t.content)n.type==="paragraph"?e.push(this._getParagraphText(n)):n.type==="table"&&e.push(this._getTableText(n));return e.join(`
|
|
2
|
+
`)}_getParagraphText(t){let e=[];for(let n of t.content)n.type==="run"?e.push(this._getRunText(n)):n.type==="hyperlink"&&e.push(this._getHyperlinkText(n));return e.join("")}_getRunText(t){return t.content.filter(e=>e.type==="text").map(e=>e.text).join("")}_getHyperlinkText(t){let e=[];for(let n of t.children)n.type==="run"&&e.push(this._getRunText(n));return e.join("")}_getTableText(t){let e=[];for(let n of t.rows)for(let a of n.cells)for(let o of a.content)o.type==="paragraph"&&e.push(this._getParagraphText(o));return e.join(" ")}_extractParagraphSegments(t,e){for(let n of t.content)if(n.type==="run"){let a=this._getRunText(n);a&&e.push({text:a,formatting:n.formatting});}else if(n.type==="hyperlink"){let a=n.href||"";for(let o of n.children)if(o.type==="run"){let s=this._getRunText(o);s&&e.push({text:s,formatting:o.formatting,isHyperlink:true,hyperlinkUrl:a});}}}_parseHeadingLevel(t){if(!t)return;let e=t.match(/heading\s*(\d)/i);if(e)return parseInt(e[1],10)}_hasImages(){let t=this._document.package.document;for(let e of t.content)if(e.type==="paragraph"){for(let n of e.content)if(n.type==="run"){for(let a of n.content)if(a.type==="drawing")return true}}return false}_hasHyperlinks(){let t=this._document.package.document;for(let e of t.content)if(e.type==="paragraph"){for(let n of e.content)if(n.type==="hyperlink")return true}return false}};async function Gt(r){return T.fromBuffer(r)}function Zt(r){return T.fromDocument(r)}function ot(r,t={}){let{outlineMaxChars:e=100,maxOutlineParagraphs:n=50}=t,a=r.package.document,o=a.content.filter(m=>m.type==="paragraph"),s=it(o,e,n),i=chunkVHWEKJ35_js.a(r),c=st(r),l=ct(a),u=lt(a),g=pt(a),f=a.content.some(m=>m.type==="table"),y=ft(a),p=mt(a);return {paragraphCount:o.length,wordCount:u,characterCount:g,variables:i,variableCount:i.length,availableStyles:c,outline:s,sections:l,hasTables:f,hasImages:y,hasHyperlinks:p}}function Qt(r,t,e={}){let{contextChars:n=200,includeSuggestions:a=true}=e,s=r.package.document.content.filter(x=>x.type==="paragraph"),i=s[t.start.paragraphIndex];if(!i)throw new Error(`Paragraph not found at index ${t.start.paragraphIndex}`);let c=h(i),l="";if(t.start.paragraphIndex===t.end.paragraphIndex)l=c.slice(t.start.offset,t.end.offset);else {let x=[];for(let C=t.start.paragraphIndex;C<=t.end.paragraphIndex;C++){let H=s[C];if(!H)continue;let w=h(H);C===t.start.paragraphIndex?x.push(w.slice(t.start.offset)):C===t.end.paragraphIndex?x.push(w.slice(0,t.end.offset)):x.push(w);}l=x.join(`
|
|
3
|
+
`);}let u=yt(s,t.start.paragraphIndex,t.start.offset,n),g=xt(s,t.end.paragraphIndex,t.end.offset,n),f=bt(i,t.start.offset),y=i.formatting||{},p={index:t.start.paragraphIndex,fullText:c,style:i.formatting?.styleId,wordCount:F(c)},m=false,b=Pt(i,t.start.offset),d=a?Ct(l):[];return {selectedText:l,range:t,formatting:f,paragraphFormatting:y,textBefore:u,textAfter:g,paragraph:p,inTable:m,inHyperlink:b,suggestedActions:d}}function K(r){let t=ot(r,{outlineMaxChars:50,maxOutlineParagraphs:10}),e=[`Document with ${t.paragraphCount} paragraphs, ${t.wordCount} words.`];t.hasTables&&e.push("Contains tables."),t.hasImages&&e.push("Contains images."),t.hasHyperlinks&&e.push("Contains hyperlinks."),t.variableCount>0&&e.push(`Has ${t.variableCount} template variables: ${t.variables.join(", ")}`);let n=t.outline.filter(a=>a.isHeading);if(n.length>0){e.push(`
|
|
4
|
+
Headings:`);for(let a of n.slice(0,5)){let o=a.headingLevel||1;e.push(`${" ".repeat(o-1)}- ${a.preview}`);}n.length>5&&e.push(` ... and ${n.length-5} more headings`);}return e.join(" ")}function it(r,t,e){let n=[];for(let a=0;a<Math.min(r.length,e);a++){let o=r[a],s=h(o),i=o.formatting?.styleId;n.push({index:a,preview:s.slice(0,t),style:i,isHeading:dt(i),headingLevel:ht(i),isListItem:!!o.listRendering,isEmpty:s.trim().length===0});}return n}function st(r){let t=r.package.styles;if(!t?.styles)return [];let e=[];for(let[n,a]of Object.entries(t.styles))if(typeof a=="object"&&a!==null){let o=a;e.push({id:n,name:o.name||n,type:o.type==="numbering"?"paragraph":o.type||"paragraph",builtIn:o.default});}return e}function ct(r){return r.sections?r.sections.map((t,e)=>({index:e,paragraphCount:t.content?.length||0,pageSize:t.properties?.pageWidth&&t.properties?.pageHeight?{width:t.properties.pageWidth,height:t.properties.pageHeight}:void 0,isLandscape:t.properties?.orientation==="landscape",hasHeader:!!t.properties?.headerReferences?.length,hasFooter:!!t.properties?.footerReferences?.length})):[]}function lt(r){let t=0;for(let e of r.content)if(e.type==="paragraph"){let n=h(e);t+=F(n);}else e.type==="table"&&(t+=ut(e));return t}function F(r){return r.split(/\s+/).filter(e=>e.length>0).length}function pt(r){let t=0;for(let e of r.content)if(e.type==="paragraph"){let n=h(e);t+=n.length;}else e.type==="table"&&(t+=gt(e));return t}function ut(r){let t=0;for(let e of r.rows)for(let n of e.cells)for(let a of n.content)if(a.type==="paragraph"){let o=h(a);t+=F(o);}return t}function gt(r){let t=0;for(let e of r.rows)for(let n of e.cells)for(let a of n.content)if(a.type==="paragraph"){let o=h(a);t+=o.length;}return t}function h(r){let t=[];for(let e of r.content)e.type==="run"?t.push(k(e)):e.type==="hyperlink"&&t.push(v(e));return t.join("")}function k(r){return r.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function v(r){let t=[];for(let e of r.children)e.type==="run"&&t.push(k(e));return t.join("")}function ft(r){for(let t of r.content)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="run"){for(let n of e.content)if(n.type==="drawing")return true}}return false}function mt(r){for(let t of r.content)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="hyperlink")return true}return false}function dt(r){return r?r.toLowerCase().includes("heading"):false}function ht(r){if(!r)return;let t=r.match(/heading\s*(\d)/i);if(t)return parseInt(t[1],10)}function yt(r,t,e,n){let a=[],o=0,s=r[t];if(s){let l=h(s).slice(0,e);a.unshift(l),o+=l.length;}for(let c=t-1;c>=0&&o<n;c--){let l=r[c];if(!l)continue;let u=h(l);a.unshift(u),o+=u.length;}let i=a.join(`
|
|
5
|
+
`);return i.length>n?"..."+i.slice(-n):i}function xt(r,t,e,n){let a=[],o=0,s=r[t];if(s){let l=h(s).slice(e);a.push(l),o+=l.length;}for(let c=t+1;c<r.length&&o<n;c++){let l=r[c];if(!l)continue;let u=h(l);a.push(u),o+=u.length;}let i=a.join(`
|
|
6
|
+
`);return i.length>n?i.slice(0,n)+"...":i}function bt(r,t){let e=0;for(let n of r.content)if(n.type==="run"){let a=k(n),o=e,s=e+a.length;if(t>=o&&t<s)return n.formatting||{};e=s;}else if(n.type==="hyperlink"){let a=v(n),o=e,s=e+a.length;if(t>=o&&t<s){for(let i of n.children)if(i.type==="run")return i.formatting||{}}e=s;}return {}}function Pt(r,t){let e=0;for(let n of r.content)if(n.type==="run"){let a=k(n);e+=a.length;}else if(n.type==="hyperlink"){let a=v(n),o=e,s=e+a.length;if(t>=o&&t<s)return true;e=s;}return false}function Ct(r,t,e){let n=[];return r.length>0&&(n.push({id:"rewrite",label:"Rewrite",description:"Rewrite this text",priority:10},{id:"summarize",label:"Summarize",description:"Summarize this text",priority:9}),r.length>200&&n.push({id:"summarize",label:"Summarize",description:"Create a shorter version",priority:8}),r.length<50&&r.split(/\s+/).length<10&&n.push({id:"expand",label:"Expand",description:"Add more details",priority:8}),n.push({id:"fixGrammar",label:"Fix Grammar",description:"Fix grammar and spelling",priority:7}),n.push({id:"translate",label:"Translate",description:"Translate to another language",priority:6}),n.push({id:"makeFormal",label:"Make Formal",description:"Use formal tone",priority:5},{id:"makeCasual",label:"Make Casual",description:"Use casual tone",priority:4})),n.sort((a,o)=>(o.priority||0)-(a.priority||0)),n}function St(r,t,e={}){let{contextCharsBefore:n=200,contextCharsAfter:a=200,includeSuggestions:o=true}=e,s=r.package.document,i=s.content.filter(x=>x.type==="paragraph");if(t.start.paragraphIndex>=i.length)throw new Error(`Invalid start paragraph index: ${t.start.paragraphIndex}`);let c=i[t.start.paragraphIndex],l=At(i,t),u=Tt(i,t.start,n),g=kt(i,t.end,a),f=It(c,t.start.offset),y=c.formatting||{},p={index:t.start.paragraphIndex,fullText:P(c),style:c.formatting?.styleId,wordCount:R(P(c))},m=Dt(s,t.start),b=_t(c,t.start.offset),d=o?Ft(l):[];return {selectedText:l,range:t,formatting:f,paragraphFormatting:y,textBefore:u,textAfter:g,paragraph:p,inTable:m,inHyperlink:b,suggestedActions:d}}function ne(r,t,e={}){let n=St(r,t,e),{includeDocumentSummary:a=true}=e,s=r.package.document.content.filter(p=>p.type==="paragraph"),i=R(n.selectedText),c=n.selectedText.length,l=t.start.paragraphIndex!==t.end.paragraphIndex,u=[];for(let p=t.start.paragraphIndex;p<=t.end.paragraphIndex;p++)u.push(p);let g=vt(s,t),f=a?K(r):void 0,y=Rt(n.selectedText);return {...n,documentSummary:f,wordCount:i,characterCount:c,isMultiParagraph:l,paragraphIndices:u,detectedLanguage:y,contentType:g}}function re(r,t){let n=r.package.document.content.filter(i=>i.type==="paragraph"),a=[];for(let i=t.start.paragraphIndex;i<=t.end.paragraphIndex;i++){let c=n[i];if(!c)continue;let l=i===t.start.paragraphIndex?t.start.offset:0,u=i===t.end.paragraphIndex?t.end.offset:1/0;wt(c,l,u,a);}let o=a.length<=1||a.every(i=>Ht(i,a[0]));return {predominant:a.length>0?a[0]:{},isConsistent:o,allFormatting:a}}function At(r,t){if(t.start.paragraphIndex===t.end.paragraphIndex){let n=r[t.start.paragraphIndex];return n?P(n).slice(t.start.offset,t.end.offset):""}let e=[];for(let n=t.start.paragraphIndex;n<=t.end.paragraphIndex;n++){let a=r[n];if(!a)continue;let o=P(a);n===t.start.paragraphIndex?e.push(o.slice(t.start.offset)):n===t.end.paragraphIndex?e.push(o.slice(0,t.end.offset)):e.push(o);}return e.join(`
|
|
7
|
+
`)}function Tt(r,t,e){let n=[],a=0,o=r[t.paragraphIndex];if(o){let c=P(o).slice(0,t.offset);n.unshift(c),a+=c.length;}for(let i=t.paragraphIndex-1;i>=0&&a<e;i--){let c=r[i];if(!c)continue;let l=P(c);n.unshift(l),a+=l.length;}let s=n.join(`
|
|
8
|
+
`);return s.length>e?"..."+s.slice(-e):s}function kt(r,t,e){let n=[],a=0,o=r[t.paragraphIndex];if(o){let c=P(o).slice(t.offset);n.push(c),a+=c.length;}for(let i=t.paragraphIndex+1;i<r.length&&a<e;i++){let c=r[i];if(!c)continue;let l=P(c);n.push(l),a+=l.length;}let s=n.join(`
|
|
9
|
+
`);return s.length>e?s.slice(0,e)+"...":s}function It(r,t){let e=0;for(let n of r.content)if(n.type==="run"){let a=S(n),o=e+a.length;if(t>=e&&t<o)return n.formatting||{};e=o;}else if(n.type==="hyperlink"){let a=I(n),o=e+a.length;if(t>=e&&t<o){for(let s of n.children)if(s.type==="run")return s.formatting||{}}e=o;}return {}}function wt(r,t,e,n){let a=0;for(let o of r.content)if(o.type==="run"){let s=S(o),i=a,c=a+s.length;c>t&&i<e&&o.formatting&&n.push({...o.formatting}),a=c;}else if(o.type==="hyperlink"){let s=I(o),i=a,c=a+s.length;if(c>t&&i<e)for(let l of o.children)l.type==="run"&&l.formatting&&n.push({...l.formatting});a=c;}}function Dt(r,t){return false}function _t(r,t){let e=0;for(let n of r.content)if(n.type==="run"){let a=S(n);e+=a.length;}else if(n.type==="hyperlink"){let a=I(n),o=e,s=e+a.length;if(t>=o&&t<s)return true;e=s;}return false}function Ft(r,t,e){let n=[];if(!r||r.trim().length===0)return n;n.push({id:"askAI",label:"Ask AI",description:"Ask AI about this text",priority:11},{id:"rewrite",label:"Rewrite",description:"Rewrite this text differently",priority:10});let a=R(r);return a>50&&n.push({id:"summarize",label:"Summarize",description:"Create a shorter version",priority:9}),a<20&&n.push({id:"expand",label:"Expand",description:"Add more details",priority:9}),n.push({id:"fixGrammar",label:"Fix Grammar",description:"Fix grammar and spelling",priority:7},{id:"translate",label:"Translate",description:"Translate to another language",priority:6},{id:"explain",label:"Explain",description:"Explain what this means",priority:5}),n.push({id:"makeFormal",label:"Make Formal",description:"Use formal tone",priority:4},{id:"makeCasual",label:"Make Casual",description:"Use casual tone",priority:3}),n.sort((o,s)=>(s.priority||0)-(o.priority||0)),n}function vt(r,t){let e=new Set;for(let n=t.start.paragraphIndex;n<=t.end.paragraphIndex;n++){let a=r[n];a&&(a.listRendering?e.add("list"):a.formatting?.styleId?.toLowerCase().includes("heading")?e.add("heading"):e.add("prose"));}return e.size>1?"mixed":e.has("list")?"list":e.has("heading")?"heading":"prose"}function Rt(r){return /[а-яА-ЯёЁ]/.test(r)?"ru":/[一-龯]/.test(r)?"zh":/[ひらがなカタカナ]/.test(r)||/[\u3040-\u309F\u30A0-\u30FF]/.test(r)?"ja":/[가-힣]/.test(r)?"ko":/[àâäéèêëïîôùûüç]/i.test(r)?"fr":/[äöüß]/i.test(r)?"de":/[áéíóúñ]/i.test(r)?"es":"en"}function P(r){let t=[];for(let e of r.content)e.type==="run"?t.push(S(e)):e.type==="hyperlink"&&t.push(I(e));return t.join("")}function S(r){return r.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function I(r){let t=[];for(let e of r.children)e.type==="run"&&t.push(S(e));return t.join("")}function R(r){return r.split(/\s+/).filter(t=>t.length>0).length}function Ht(r,t){let e=Object.keys(r),n=Object.keys(t);return e.length!==n.length?false:e.every(a=>{let o=r[a],s=t[a];return o===s})}exports.a=tt;exports.b=Z;exports.c=Y;exports.d=at;exports.e=Wt;exports.f=T;exports.g=Gt;exports.h=Zt;exports.i=ot;exports.j=Qt;exports.k=K;exports.l=St;exports.m=ne;exports.n=re;
|