@eigenpal/docx-editor-core 1.6.0 → 1.6.2
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/agent/index.d.mts +3 -3
- package/dist/agent/index.d.ts +3 -3
- package/dist/agent/index.js +1 -1
- package/dist/agent/index.mjs +1 -1
- package/dist/chunk-25775MLP.mjs +2 -0
- package/dist/chunk-2AEZLDY4.js +1 -0
- package/dist/chunk-2EFI3BAN.js +59 -0
- package/dist/{chunk-2ZTKTE7P.js → chunk-2EKWMNCY.js} +1 -1
- package/dist/chunk-3QQLHMB6.mjs +4 -0
- package/dist/{chunk-2KUOYHXX.js → chunk-455DUC37.js} +1 -1
- package/dist/chunk-4EATD3FP.js +2 -0
- package/dist/chunk-4VLKSJRK.mjs +1 -0
- package/dist/{chunk-7UMOUKSF.js → chunk-5CLYWBNI.js} +1 -1
- package/dist/chunk-5TLT5TUD.js +1 -0
- package/dist/{chunk-CWPIXUU2.js → chunk-5ZAMEYCA.js} +1 -1
- package/dist/{chunk-YMXWLXVF.mjs → chunk-6BAIXYUY.mjs} +1 -1
- package/dist/chunk-6UCWVS7Y.mjs +1 -0
- package/dist/chunk-7E2TOWBX.mjs +1 -0
- package/dist/{chunk-KSW6W2EK.mjs → chunk-7LPUPZAO.mjs} +2 -2
- package/dist/{chunk-XTPT4TNP.mjs → chunk-AC6JHCPC.mjs} +1 -1
- package/dist/chunk-B3SVS2AF.js +1 -0
- package/dist/{chunk-CDGV7CLS.js → chunk-BA4OW45H.js} +1 -1
- package/dist/chunk-BMP2OSXE.js +1 -0
- package/dist/{chunk-WEQA5PPW.mjs → chunk-CF4SIWV2.mjs} +1 -1
- package/dist/{chunk-GFM6PERG.js → chunk-CMZXBKDH.js} +1 -1
- package/dist/chunk-CRQO6WI3.mjs +2 -0
- package/dist/chunk-DPMR7U7D.js +2 -0
- package/dist/{chunk-QZPVZY6S.mjs → chunk-EEEED6FG.mjs} +1 -1
- package/dist/chunk-IJ2PPHRN.mjs +1 -0
- package/dist/chunk-IUYHWUBF.mjs +1 -0
- package/dist/chunk-LMGFGJTJ.mjs +1 -0
- package/dist/chunk-LZTEPSU2.js +4 -0
- package/dist/chunk-NJBEJTIO.mjs +2 -0
- package/dist/chunk-O5L4BZCZ.mjs +1 -0
- package/dist/chunk-OBRTIXHC.mjs +59 -0
- package/dist/chunk-OSTMAXZZ.mjs +1 -0
- package/dist/chunk-OTXLG6KM.js +1 -0
- package/dist/chunk-PGWY6UFK.js +1 -0
- package/dist/{chunk-6AGU57TL.mjs → chunk-QCPISGPW.mjs} +1 -1
- package/dist/chunk-QI6JDDGO.js +1 -0
- package/dist/chunk-R5DGXEWJ.js +2 -0
- package/dist/{chunk-NY36MZ55.mjs → chunk-RT5AAIEK.mjs} +1 -1
- package/dist/{chunk-RGHRXIIZ.js → chunk-SSL74NAS.js} +3 -3
- package/dist/chunk-T5G3IWCO.mjs +1 -0
- package/dist/{chunk-WQJWT4RB.mjs → chunk-U55TPVTA.mjs} +1 -1
- package/dist/{chunk-5JULVEYK.mjs → chunk-V4DLVFYG.mjs} +1 -1
- package/dist/{chunk-BBJMUBTD.mjs → chunk-VMBCUUZM.mjs} +1 -1
- package/dist/chunk-WA4IJOGH.js +1 -0
- package/dist/{chunk-EJ2JAYRI.js → chunk-XCTYXYEU.js} +1 -1
- package/dist/{chunk-T3UP6LF5.js → chunk-XLY5A37T.js} +1 -1
- package/dist/{chunk-F44XU6G5.js → chunk-XRJFWDCV.js} +1 -1
- package/dist/{chunk-DX5XU6JN.js → chunk-YUHOVME2.js} +1 -1
- package/dist/chunk-ZCYUN3EC.js +1 -0
- package/dist/{chunk-E7UN3PVC.mjs → chunk-ZW3VG4TK.mjs} +1 -1
- package/dist/{content-CbBCrsr0.d.mts → content-BEFz1zcs.d.mts} +1 -1
- package/dist/{content-BebvPfXc.d.ts → content-DNcMlHU0.d.ts} +1 -1
- package/dist/{contentControlValues-Com1GnZS.d.ts → contentControlValues-2pV4M4kG.d.ts} +1 -1
- package/dist/{contentControlValues-DVJyudKU.d.mts → contentControlValues-CKWIIkkr.d.mts} +1 -1
- package/dist/core-plugins.d.mts +1 -1
- package/dist/core-plugins.d.ts +1 -1
- package/dist/core-plugins.js +1 -1
- package/dist/core-plugins.mjs +1 -1
- package/dist/core.d.mts +6 -6
- package/dist/core.d.ts +6 -6
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/docx/index.d.mts +1 -1
- package/dist/docx/index.d.ts +1 -1
- package/dist/docx/index.js +1 -1
- package/dist/docx/index.mjs +1 -1
- package/dist/docx/parser.d.mts +1 -1
- package/dist/docx/parser.d.ts +1 -1
- package/dist/docx/parser.js +1 -1
- package/dist/docx/parser.mjs +1 -1
- package/dist/docx/rezip.d.mts +3 -3
- package/dist/docx/rezip.d.ts +3 -3
- package/dist/docx/rezip.js +1 -1
- package/dist/docx/rezip.mjs +1 -1
- package/dist/docx/serializer/index.d.mts +2 -2
- package/dist/docx/serializer/index.d.ts +2 -2
- package/dist/docx/serializer/index.js +1 -1
- package/dist/docx/serializer/index.mjs +1 -1
- package/dist/editor/index.d.mts +1 -1
- package/dist/editor/index.d.ts +1 -1
- package/dist/editor/index.js +1 -1
- package/dist/editor/index.mjs +1 -1
- package/dist/executor-LAWUSXNG.mjs +1 -0
- package/dist/executor-SJOHUTMY.js +1 -0
- package/dist/{fontLoader-D9SBYuZZ.d.ts → fontLoader-CH12AtFF.d.ts} +1 -1
- package/dist/{fontLoader-B4uFKpAy.d.mts → fontLoader-D3X2Qgb_.d.mts} +1 -1
- package/dist/{headerFooterLayout-CtVsfqxQ.d.ts → headerFooterLayout-BdGTU0IA.d.ts} +31 -16
- package/dist/{headerFooterLayout-D2LZLkDC.d.mts → headerFooterLayout-D5-u-IsD.d.mts} +31 -16
- package/dist/headless.d.mts +4 -4
- package/dist/headless.d.ts +4 -4
- package/dist/headless.js +1 -1
- package/dist/headless.mjs +1 -1
- package/dist/layout-bridge/index.d.mts +2 -2
- package/dist/layout-bridge/index.d.ts +2 -2
- package/dist/layout-bridge/index.js +1 -1
- package/dist/layout-bridge/index.mjs +1 -1
- package/dist/layout-bridge/measuring/index.d.mts +1 -1
- package/dist/layout-bridge/measuring/index.d.ts +1 -1
- package/dist/layout-bridge/measuring/index.js +1 -1
- package/dist/layout-bridge/measuring/index.mjs +1 -1
- package/dist/layout-bridge/tableInsertHover.js +1 -1
- package/dist/layout-bridge/tableInsertHover.mjs +1 -1
- package/dist/layout-bridge/toFlowBlocks.d.mts +1 -1
- package/dist/layout-bridge/toFlowBlocks.d.ts +1 -1
- package/dist/layout-bridge/toFlowBlocks.js +1 -1
- package/dist/layout-bridge/toFlowBlocks.mjs +1 -1
- package/dist/layout-engine/index.d.mts +1 -1
- package/dist/layout-engine/index.d.ts +1 -1
- package/dist/layout-engine/index.js +1 -1
- package/dist/layout-engine/index.mjs +1 -1
- package/dist/layout-engine/types.d.mts +1 -1
- package/dist/layout-engine/types.d.ts +1 -1
- package/dist/layout-painter/index.d.mts +2 -2
- package/dist/layout-painter/index.d.ts +2 -2
- package/dist/layout-painter/index.js +1 -1
- package/dist/layout-painter/index.mjs +1 -1
- package/dist/layout-painter/renderPage.d.mts +2 -2
- package/dist/layout-painter/renderPage.d.ts +2 -2
- package/dist/layout-painter/renderPage.js +1 -1
- package/dist/layout-painter/renderPage.mjs +1 -1
- package/dist/managers/AutoSaveManager.d.mts +1 -1
- package/dist/managers/AutoSaveManager.d.ts +1 -1
- package/dist/managers/TableSelectionManager.d.mts +1 -1
- package/dist/managers/TableSelectionManager.d.ts +1 -1
- package/dist/managers/types.d.mts +1 -1
- package/dist/managers/types.d.ts +1 -1
- package/dist/mcp-cli.mjs +23 -23
- package/dist/mcp.d.mts +1 -1
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +8 -8
- package/dist/mcp.mjs +1 -1
- package/dist/{nodes-BvO8GGD4.d.mts → nodes-5w_QaI3g.d.mts} +13 -1
- package/dist/{nodes-Bd6tTkp0.d.ts → nodes-qQdZtu3Z.d.ts} +13 -1
- package/dist/prosemirror/applyFormatting.js +1 -1
- package/dist/prosemirror/applyFormatting.mjs +1 -1
- package/dist/prosemirror/commands/formatting.js +1 -1
- package/dist/prosemirror/commands/formatting.mjs +1 -1
- package/dist/prosemirror/commands/index.js +1 -1
- package/dist/prosemirror/commands/index.mjs +1 -1
- package/dist/prosemirror/commands/paragraph.js +1 -1
- package/dist/prosemirror/commands/paragraph.mjs +1 -1
- package/dist/prosemirror/commentIdAllocator.d.mts +1 -1
- package/dist/prosemirror/commentIdAllocator.d.ts +1 -1
- package/dist/prosemirror/commentOps.d.mts +1 -1
- package/dist/prosemirror/commentOps.d.ts +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.d.mts +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.mjs +1 -1
- package/dist/prosemirror/conversion/index.d.mts +1 -1
- package/dist/prosemirror/conversion/index.d.ts +1 -1
- package/dist/prosemirror/conversion/index.js +1 -1
- package/dist/prosemirror/conversion/index.mjs +1 -1
- package/dist/prosemirror/extensions/index.js +1 -1
- package/dist/prosemirror/extensions/index.mjs +1 -1
- package/dist/prosemirror/index.d.mts +3 -3
- package/dist/prosemirror/index.d.ts +3 -3
- package/dist/prosemirror/index.js +2 -2
- package/dist/prosemirror/index.mjs +2 -2
- package/dist/prosemirror/plugins/index.d.mts +1 -1
- package/dist/prosemirror/plugins/index.d.ts +1 -1
- package/dist/prosemirror/queries.d.mts +1 -1
- package/dist/prosemirror/queries.d.ts +1 -1
- package/dist/prosemirror/schema/index.d.mts +2 -2
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/index.js +1 -1
- package/dist/prosemirror/schema/index.mjs +1 -1
- package/dist/prosemirror/utils/extractTrackedChanges.d.mts +1 -1
- package/dist/prosemirror/utils/extractTrackedChanges.d.ts +1 -1
- package/dist/{sectionPropertiesSerializer-CzgskSoA.d.ts → sectionPropertiesSerializer-BJSNK-Wl.d.ts} +1 -1
- package/dist/{sectionPropertiesSerializer-D3yI82iZ.d.mts → sectionPropertiesSerializer-DI3OIQ1j.d.mts} +1 -1
- package/dist/types/content.d.mts +1 -1
- package/dist/types/content.d.ts +1 -1
- package/dist/types/document.d.mts +2 -2
- package/dist/types/document.d.ts +2 -2
- package/dist/utils/comments.d.mts +1 -1
- package/dist/utils/comments.d.ts +1 -1
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/{variableDetector-D2-xDa2O.d.mts → variableDetector-7xBsshP0.d.mts} +1 -1
- package/dist/{variableDetector-d-PpDlNV.d.ts → variableDetector-Bv5Tm0D-.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-2KPOGFFR.js +0 -1
- package/dist/chunk-2LVK7EF5.mjs +0 -2
- package/dist/chunk-34DJT72K.js +0 -1
- package/dist/chunk-4JPHW7ZI.js +0 -2
- package/dist/chunk-4QJEMD23.mjs +0 -4
- package/dist/chunk-4QSFBX26.mjs +0 -1
- package/dist/chunk-4SZAFWLV.mjs +0 -1
- package/dist/chunk-6KYOT4E7.js +0 -4
- package/dist/chunk-77X765ZO.js +0 -1
- package/dist/chunk-AXVWVIIN.js +0 -1
- package/dist/chunk-B6FA4MJ5.mjs +0 -1
- package/dist/chunk-BKP5QMTS.js +0 -1
- package/dist/chunk-C2BAPYGJ.js +0 -1
- package/dist/chunk-C57BOE7B.mjs +0 -2
- package/dist/chunk-F24WZXN4.mjs +0 -59
- package/dist/chunk-FETIBXTH.js +0 -1
- package/dist/chunk-IM56AITE.mjs +0 -1
- package/dist/chunk-JQUIUKRO.js +0 -59
- package/dist/chunk-KK673XRZ.mjs +0 -1
- package/dist/chunk-LE67NTCN.mjs +0 -1
- package/dist/chunk-M65C4SQJ.mjs +0 -2
- package/dist/chunk-NO6PIL32.mjs +0 -1
- package/dist/chunk-NTYJIOUE.js +0 -2
- package/dist/chunk-V3NE7Q22.js +0 -2
- package/dist/chunk-WCB25ESG.mjs +0 -1
- package/dist/chunk-WWG6PUWU.js +0 -1
- package/dist/executor-FHL5D4CB.js +0 -1
- package/dist/executor-FL6XGVP3.mjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {c,a as a$1,b as b$1}from'./chunk-FCJWLEKT.mjs';import {a as a$2,b}from'./chunk-7E5VBRDL.mjs';import {p}from'./chunk-3QQLHMB6.mjs';import {a,b as b$2,o}from'./chunk-67LVRQIR.mjs';import {j as j$1,k,l}from'./chunk-KNY7SXPJ.mjs';import {f}from'./chunk-VJFIAFZ5.mjs';function B(e,s){let r={};for(let t of e)switch(t.type.name){case "bold":r.bold=true;break;case "italic":r.italic=true;break;case "underline":{let n=t.attrs;if(n.style||n.color){let i=n.color?a(n.color,s):void 0;r.underline={style:n.style,color:i};}else r.underline=true;break}case "strike":r.strike=true;break;case "textColor":{let n=t.attrs;(n.themeColor||n.rgb)&&(r.color=a({rgb:n.rgb,themeColor:n.themeColor,themeTint:n.themeTint,themeShade:n.themeShade},s));break}case "highlight":r.highlight=o(t.attrs.color);break;case "fontSize":{let n=t.attrs;r.fontSize=n.size/2;break}case "fontFamily":{let n=t.attrs;r.fontFamily=n.ascii||n.hAnsi;break}case "characterSpacing":{let n=t.attrs;n.spacing!=null&&n.spacing!==0&&(r.letterSpacing=a$1(n.spacing)),n.position!=null&&n.position!==0&&(r.positionPx=k(n.position)),n.scale!=null&&n.scale!==100&&(r.horizontalScale=n.scale),n.kerning!=null&&n.kerning>0&&(r.kerningMinPt=l(n.kerning));break}case "allCaps":r.allCaps=true;break;case "smallCaps":r.smallCaps=true;break;case "emboss":r.emboss=true;break;case "imprint":r.imprint=true;break;case "textShadow":r.textShadow=true;break;case "textOutline":r.textOutline=true;break;case "hidden":r.hidden=true;break;case "rtl":r.rtl=true;break;case "textEffect":{let n=t.attrs.effect;(n==="blinkBackground"||n==="lights"||n==="antsBlack"||n==="antsRed"||n==="shimmer"||n==="sparkle")&&(r.textEffect=n);break}case "emphasisMark":{let n=t.attrs.type;n==="dot"||n==="comma"||n==="circle"||n==="underDot"?r.emphasisMark=n:r.emphasisMark="dot";break}case "superscript":r.superscript=true;break;case "subscript":r.subscript=true;break;case "hyperlink":{let n=t.attrs;r.hyperlink={href:n.href,tooltip:n.tooltip};break}case "footnoteRef":{let n=t.attrs,i=typeof n.id=="string"?parseInt(n.id,10):n.id;n.noteType==="endnote"?r.endnoteRefId=i:r.footnoteRefId=i,r.superscript=true;break}case "comment":{let n=t.attrs.commentId;n&&(r.commentIds||(r.commentIds=[]),r.commentIds.push(n));break}case "insertion":r.isInsertion=true,r.changeAuthor=t.attrs.author,r.changeDate=t.attrs.date,r.changeRevisionId=t.attrs.revisionId;break;case "deletion":r.isDeletion=true,r.changeAuthor=t.attrs.author,r.changeDate=t.attrs.date,r.changeRevisionId=t.attrs.revisionId;break}return r}function G(e){let s=e.defaultTextFormatting;if(!s)return {};let r={};if(s.fontFamily){let t=s.fontFamily.ascii||s.fontFamily.hAnsi;t&&(r.fontFamily=t);}return s.fontSize!=null&&(r.fontSize=s.fontSize/2),r}function D(e){e.hyperlink&&(e.hyperlink={...e.hyperlink,noDefaultStyle:true},delete e.color,delete e.underline);}function $(e){return e==="contentLocked"||e==="sdtContentLocked"}function Y(e,s){let r=e.attrs;if(r.sdtType==="checkbox"&&!($(r.lock)||r.dataBinding!=null))return {kind:"checkbox",groupId:`sdt@${s}`,pos:s,tag:r.tag!=null?String(r.tag):void 0,alias:r.alias!=null?String(r.alias):void 0,checked:typeof r.checked=="boolean"?r.checked:void 0}}function N(e,s,r){let t=[],n=s+1,i=r.theme,l=G(e.attrs),b=e.attrs.styleId,d=typeof b=="string"&&/^TOC\d*$/i.test(b);function f(u,m,p){if(u.isText&&u.text){let a=B(u.marks,i);d&&D(a);let o={kind:"text",text:u.text,...l,...a,pmStart:m,pmEnd:m+u.nodeSize,inlineSdtWidget:p};t.push(o);}else if(u.type.name==="hardBreak")t.push({kind:"lineBreak",pmStart:m,pmEnd:m+u.nodeSize});else if(u.type.name==="tab"){let a=B(u.marks,i),o={kind:"tab",...l,...a,pmStart:m,pmEnd:m+u.nodeSize};t.push(o);}else if(u.type.name==="image"){let a=u.attrs,o=b$1(a.width||100,a.height||100,r.pageContentHeight),c=B(u.marks,i),h={kind:"image",src:a.src,width:o.width,height:o.height,alt:a.alt,transform:a.transform,wrapType:a.wrapType,displayMode:a.displayMode,cssFloat:a.cssFloat,distTop:a.distTop,distBottom:a.distBottom,distLeft:a.distLeft,distRight:a.distRight,position:a.position,cropTop:a.cropTop,cropRight:a.cropRight,cropBottom:a.cropBottom,cropLeft:a.cropLeft,opacity:a.opacity,isInsertion:c.isInsertion,isDeletion:c.isDeletion,changeAuthor:c.changeAuthor,changeDate:c.changeDate,changeRevisionId:c.changeRevisionId,pmStart:m,pmEnd:m+u.nodeSize};t.push(h);}else if(u.type.name==="field"){let a=u.attrs.fieldType,o=a==="PAGE"?"PAGE":a==="NUMPAGES"?"NUMPAGES":a==="DATE"?"DATE":a==="TIME"?"TIME":"OTHER",c=B(u.marks,i);d&&D(c),t.push({kind:"field",fieldType:o,fallback:u.attrs.displayText||"",...l,...c,pmStart:m,pmEnd:m+u.nodeSize});}else if(u.type.name==="math"){let a=u.attrs.plainText||"[equation]";t.push({kind:"text",text:a,italic:true,fontFamily:"Cambria Math",pmStart:m,pmEnd:m+u.nodeSize});}else if(u.type.name==="sdt"){let a=Y(u,m)??p,o=m+1;u.forEach((c,h)=>{f(c,o+h,a);});}}return e.forEach((u,m)=>{f(u,n+m);}),t}function j(e){return Math.max(1,Math.round(e/8*1.333))}var Z={single:"solid",double:"double",dotted:"dotted",dashed:"dashed",thick:"solid",dashSmallGap:"dashed",dotDash:"dashed",dotDotDash:"dotted",triple:"double",wave:"solid",doubleWave:"double",threeDEmboss:"ridge",threeDEngrave:"groove",outset:"outset",inset:"inset"};function w(e,s){if(!e||!e.style||e.style==="none"||e.style==="nil")return;let r={style:Z[e.style]||"solid",width:j(e.size??0),color:e.color?a(e.color,s):"#000000"};return e.space!==void 0&&(r.space=j$1(e.space)),r}function O(e,s){let r=e.borders;if(!r)return;let t={},n=["top","bottom","left","right"];for(let i of n){let l=r[i],b=l?w(l,s):void 0;t[i]=b??{width:0,style:"none"};}return Object.keys(t).length>0?t:void 0}function V(e,s){let r=[];for(let t=0;t<=s;t+=1){let n=e[t]??0;if(n<=0)break;r.push(n);}return r.length===0?"1.":`${r.join(".")}.`}var q=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];function W(e,s){if(e<=0)return "";let r=e,t="";for(let[n,i]of q)for(;r>=n;)t+=i,r-=n;return s?t:t.toLowerCase()}function H(e,s){if(e<=0)return "";let r=e,t="";for(;r>0;){let n=(r-1)%26;t=String.fromCharCode(65+n)+t,r=Math.floor((r-1)/26);}return s?t:t.toLowerCase()}function K(e,s){if(e<=0)return "";switch(s){case "upperRoman":return W(e,true);case "lowerRoman":return W(e,false);case "upperLetter":return H(e,true);case "lowerLetter":return H(e,false);case "decimalZero":return f(e,2);case "decimalZero3":return f(e,3);case "decimalZero4":return f(e,4);case "decimalZero5":return f(e,5);case "none":return "";default:return String(e)}}function X(e,s,r){return e.replace(/%(\d)([.):\]])?/g,(t,n,i="")=>{let l=parseInt(n,10)-1;if(l<0)return "";let b=s[l]??0,d=r?.[l]??"decimal",f=K(b,d);return f?f+i:""})}function _(e,s,r){let t=e.numPr;if(!t)return null;let n=t.numId;if(n==null||n===0)return null;if(e.listIsBullet)return p(e.listMarker||"");let i=t.ilvl??0;if((e.listLevelNumFmts?.[i]??e.listNumFmt)==="none")return e.listMarker?e.listMarker:null;let b=e.listAbstractNumId??n,d=s.get(b)??new Array(9).fill(0),f=`${n}:${i}`;r.has(f)||(r.add(f),e.listStartOverride!=null&&(d[i]=e.listStartOverride-1)),d[i]=(d[i]??0)+1;for(let u=i+1;u<d.length;u+=1)d[u]=0;return s.set(b,d),e.listMarker&&e.listMarker.includes("%")?X(e.listMarker,d,e.listLevelNumFmts??void 0):e.listMarker?e.listMarker:V(d,i)}var J="Calibri",Q=11;function A(e,s,r,t,n){let i={};if(e.alignment){let o=e.alignment;o==="both"||o==="distribute"?i.alignment="justify":o==="left"?i.alignment="left":o==="center"?i.alignment="center":o==="right"&&(i.alignment="right");}let l=e._originalFormatting?.beforeAutospacing,b=e._originalFormatting?.afterAutospacing;(l||b||e.spaceBefore!=null||e.spaceAfter!=null||e.lineSpacing!=null)&&(i.spacing={},l?i.spacing.before=14:e.spaceBefore!=null&&(i.spacing.before=a$1(e.spaceBefore)),b?i.spacing.after=14:e.spaceAfter!=null&&(i.spacing.after=a$1(e.spaceAfter)),e.lineSpacing!=null&&(e.lineSpacingRule==="exact"||e.lineSpacingRule==="atLeast"?(i.spacing.line=a$1(e.lineSpacing),i.spacing.lineUnit="px",i.spacing.lineRule=e.lineSpacingRule):(i.spacing.line=e.lineSpacing/240,i.spacing.lineUnit="multiplier",i.spacing.lineRule="auto"))),e.spacingExplicit&&(i.spacingExplicit=e.spacingExplicit);let d=e.indentLeft,f=e.indentFirstLine,u=e.hangingIndent;if(e.numPr?.numId&&d==null&&(d=((e.numPr.ilvl??0)+1)*720,f==null&&(f=-360,u=true)),(d!=null||e.indentRight!=null||f!=null)&&(i.indent={},d!=null&&(i.indent.left=a$1(d)),e.indentRight!=null&&(i.indent.right=a$1(e.indentRight)),f!=null&&(u?i.indent.hanging=Math.abs(a$1(f)):i.indent.firstLine=a$1(f))),e.styleId&&(i.styleId=e.styleId),e.borders){let o=e.borders;i.borders={};let c=h=>h?w(h,s):void 0;o.top&&(i.borders.top=c(o.top)),o.bottom&&(i.borders.bottom=c(o.bottom)),o.left&&(i.borders.left=c(o.left)),o.right&&(i.borders.right=c(o.right)),o.between&&(i.borders.between=c(o.between)),o.bar&&(i.borders.bar=c(o.bar)),!i.borders.top&&!i.borders.bottom&&!i.borders.left&&!i.borders.right&&!i.borders.between&&!i.borders.bar&&delete i.borders;}let m=b$2(e.shading?.fill,s);m&&(i.shading=`#${m}`),e.tabs&&e.tabs.length>0&&(i.tabs=e.tabs.map(o=>({val:ee(o.alignment),pos:o.position,leader:o.leader}))),e.pageBreakBefore&&(i.pageBreakBefore=true),e.keepNext&&(i.keepNext=true),e.keepLines&&(i.keepLines=true),e.contextualSpacing&&(i.contextualSpacing=true),e.bidi&&(i.bidi=true),e.styleId&&(i.styleId=e.styleId),e.numPr&&(i.numPr={numId:e.numPr.numId,ilvl:e.numPr.ilvl});let p=r&&t?_(e,r,t):null;p!=null?i.listMarker=p:e.listMarker&&(i.listMarker=e.listMarker),e.listIsBullet!=null&&(i.listIsBullet=e.listIsBullet),e.listMarkerHidden&&(i.listMarkerHidden=true),e.listMarkerFontFamily&&(i.listMarkerFontFamily=e.listMarkerFontFamily),e.listMarkerFontSize&&(i.listMarkerFontSize=e.listMarkerFontSize),e.listMarkerSuffix&&(i.listMarkerSuffix=e.listMarkerSuffix),n!==void 0&&(i.defaultTabStopTwips=n);let a=e.defaultTextFormatting;if(a&&(a.fontSize!=null&&(i.defaultFontSize=a.fontSize/2),a.fontFamily&&(i.defaultFontFamily=a.fontFamily.ascii||a.fontFamily.hAnsi)),e.pPrIns&&(i.pPrIns=e.pPrIns),e.pPrDel&&(i.pPrDel=e.pPrDel),e.numPr){let o=e.pPrChange,c=Array.isArray(o)&&o.some(h=>!h?.previousFormatting?.numPr);e.pPrDel?i.listMarkerRevision="del":(e.pPrIns||c)&&(i.listMarkerRevision="ins");}return i}function ee(e){switch(e){case "left":return "start";case "right":return "end";case "center":return "center";case "decimal":return "decimal";case "bar":return "bar";case "clear":return "clear";case "num":return "start";default:return "start"}}function M(e,s,r){let t=e.attrs,n=N(e,s,r),i=A(t,r.theme,r.listCounters,r.listSeenNumIds,r.defaultTabStopTwips);return {kind:"paragraph",id:c(),runs:n,attrs:i,pmStart:s,pmEnd:s+e.nodeSize}}function te(e,s,r,t){let n=[],i=s+1;e.forEach(o=>{o.type.name==="paragraph"?n.push(M(o,i,r)):o.type.name==="table"&&n.push(U(o,i,r)),i+=o.nodeSize;});let l=e.attrs,b=l.width,d=l.widthType,f=b&&(!d||d==="dxa"||d==="auto")?a$1(b):void 0,u=l.margins,m=(o,c)=>{if(o!=null){let h=a$1(o);if(h>0)return h}if(c!=null){let h=a$1(c);if(h>=0)return h}return 0},p={top:m(u?.top,t?.top),right:m(u?.right,t?.right),bottom:m(u?.bottom,t?.bottom),left:m(u?.left,t?.left)},a=l.cellMarker;return {id:c(),blocks:n,colSpan:l.colspan,rowSpan:l.rowspan,width:f,widthValue:b,widthType:d,verticalAlign:l.verticalAlign,background:l.backgroundColor?`#${l.backgroundColor}`:void 0,borders:O(l,r.theme),padding:p,noWrap:l.noWrap||void 0,trackedMarker:a??void 0}}function ne(e,s,r,t){let n=[],i=s+1;e.forEach(d=>{(d.type.name==="tableCell"||d.type.name==="tableHeader")&&n.push(te(d,i,r,t)),i+=d.nodeSize;});let l=e.attrs,b=l._originalFormatting;return {id:c(),cells:n,height:l.height?a$1(l.height):void 0,heightRule:l.heightRule??void 0,isHeader:l.isHeader,cantSplit:b?.cantSplit||void 0,trackedIns:l.trIns??void 0,trackedDel:l.trDel??void 0}}function U(e,s,r){let t=[],n=s+1,i=e.attrs.cellMargins;e.forEach(c=>{c.type.name==="tableRow"&&t.push(ne(c,n,r,i)),n+=c.nodeSize;});let b=e.attrs.columnWidths?.map(a$1),d=e.attrs.width,f=e.attrs.widthType;if(!b&&t.length>0){let h=t[0].cells.map(k=>k.width);h.every(k=>k!==void 0&&k>0)&&(b=h);}let u=e.attrs.justification,m=e.attrs._originalFormatting,p=m?.indent?.value&&m.indent.type==="dxa"?a$1(m.indent.value):void 0,a=e.attrs.floating,o=a?{horzAnchor:a.horzAnchor,vertAnchor:a.vertAnchor,tblpX:a.tblpX!==void 0?a$1(a.tblpX):void 0,tblpXSpec:a.tblpXSpec,tblpY:a.tblpY!==void 0?a$1(a.tblpY):void 0,tblpYSpec:a.tblpYSpec,topFromText:a.topFromText!==void 0?a$1(a.topFromText):void 0,bottomFromText:a.bottomFromText!==void 0?a$1(a.bottomFromText):void 0,leftFromText:a.leftFromText!==void 0?a$1(a.leftFromText):void 0,rightFromText:a.rightFromText!==void 0?a$1(a.rightFromText):void 0}:void 0;return {kind:"table",id:c(),rows:t,columnWidths:b,width:d,widthType:f,justification:u,indent:p,floating:o,pmStart:s,pmEnd:s+e.nodeSize}}function re(e,s,r){let t=e.attrs,n=t.wrapType,i=n==="behind"||n==="inFront",l=b$1(t.width||100,t.height||100,r);return {kind:"image",id:c(),src:t.src,width:l.width,height:l.height,alt:t.alt,transform:t.transform,anchor:i?{isAnchored:true,offsetH:t.distLeft,offsetV:t.distTop,behindDoc:n==="behind"}:void 0,hlinkHref:t.hlinkHref,pmStart:s,pmEnd:s+e.nodeSize}}function ie(e,s,r){let t=e.attrs,n=[];return e.forEach((i,l)=>{if(i.type.name==="paragraph"){let b=M(i,s+1+l,r);n.push(b);}}),{kind:"textBox",id:c(),width:t.width??b,height:t.height??void 0,fillColor:t.fillColor,outlineWidth:t.outlineWidth,outlineColor:t.outlineColor,outlineStyle:t.outlineStyle,margins:{top:t.marginTop??a$2.top,bottom:t.marginBottom??a$2.bottom,left:t.marginLeft??a$2.left,right:t.marginRight??a$2.right},content:n,displayMode:t.displayMode,cssFloat:t.cssFloat,wrapType:t.wrapType,wrapText:t.wrapText,anchorTarget:t.anchorTarget,position:t.position,distTop:t.distTop,distBottom:t.distBottom,distLeft:t.distLeft,distRight:t.distRight,pmStart:s,pmEnd:s+e.nodeSize}}function xe(e,s={}){let r=e.attrs?.defaultTabStopTwips,t={...s,defaultFont:s.defaultFont??J,defaultSize:s.defaultSize??Q,defaultTabStopTwips:s.defaultTabStopTwips??r},n=[],i=0,l={top:1440,bottom:1440,left:1440,right:1440};t.listCounters||(t.listCounters=new Map),t.listSeenNumIds||(t.listSeenNumIds=new Set);let b=(d,f,u)=>{if(d.type.name==="blockSdt"){let p=d.attrs,a={id:`sdt@${f}`,sdtType:typeof p.sdtType=="string"?p.sdtType:"richText",tag:p.tag!=null?String(p.tag):void 0,alias:p.alias!=null?String(p.alias):void 0,lock:p.lock!=null?String(p.lock):void 0,checked:typeof p.checked=="boolean"?p.checked:void 0,bound:p.dataBinding!=null?true:void 0,repeatingItem:/<w15:repeatingSectionItem[\s/>]/.test(String(p.rawPropertiesXml??""))?true:void 0},o=[...u,a];d.forEach((c,h)=>{b(c,f+1+h,o);});return}let m=n.length;switch(d.type.name){case "paragraph":{let p=M(d,f,t),a=d.attrs;n.push(p);let o=a._sectionProperties;if(o||a.sectionBreakType){let c$1={kind:"sectionBreak",id:c(),type:o?.sectionStart??a.sectionBreakType};if(o){if((o.pageWidth!==void 0||o.pageHeight!==void 0)&&(c$1.pageSize={w:a$1(o.pageWidth??12240),h:a$1(o.pageHeight??15840)}),o.marginTop!==void 0||o.marginBottom!==void 0||o.marginLeft!==void 0||o.marginRight!==void 0){let k={top:o.marginTop??l.top,bottom:o.marginBottom??l.bottom,left:o.marginLeft??l.left,right:o.marginRight??l.right};c$1.margins={top:a$1(k.top),bottom:a$1(k.bottom),left:a$1(k.left),right:a$1(k.right)},l=k;}let h=o.columnCount??1;if(h>1){let k={count:h,gap:a$1(o.columnSpace??720),equalWidth:o.equalWidth??true,separator:o.separator};c$1.columns=k;}}n.push(c$1);}}break;case "table":n.push(U(d,f,t));break;case "image":n.push(re(d,f,t.pageContentHeight));break;case "textBox":n.push(ie(d,f,t));break;case "horizontalRule":case "pageBreak":{let p={kind:"pageBreak",id:c(),pmStart:f,pmEnd:f+d.nodeSize};n.push(p);break}}if(u.length>0)for(let p=m;p<n.length;p++)n[p].sdtGroups=u;};return e.forEach((d,f)=>{b(d,i+f,[]);}),n}export{w as a,X as b,xe as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function i(t,r){if(r<=0)return [];let n=Math.floor(t/r),e=t-n*r;return Array.from({length:r},()=>{let a=n+(e>0?1:0);return e=Math.max(0,e-1),Math.max(1,a)})}export{i as a};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {b}from'./chunk-ARHPXIBJ.mjs';import {b as b$1,f}from'./chunk-CGJ6S3AH.mjs';import {a}from'./chunk-
|
|
1
|
+
import {b}from'./chunk-ARHPXIBJ.mjs';import {b as b$1,f}from'./chunk-CGJ6S3AH.mjs';import {a}from'./chunk-CRQO6WI3.mjs';function M(o){return typeof o=="object"&&o!==null&&("_def"in o||"parse"in o||"safeParse"in o)}function v(o,i){let s=i,{position:n,variableName:t}=s,e=JSON.parse(JSON.stringify(o)),a=e.package.document.content.filter(m=>m.type==="paragraph");if(n.paragraphIndex>=a.length)throw new Error(`Paragraph index ${n.paragraphIndex} out of bounds`);let l=a[n.paragraphIndex],p=`{${t}}`;return C(l,n.offset,p),e.templateVariables||(e.templateVariables=[]),e.templateVariables.includes(t)||e.templateVariables.push(t),e}function w(o,i){let s=i,{range:n,variableName:t}=s,e=JSON.parse(JSON.stringify(o)),a=e.package.document.content.filter(m=>m.type==="paragraph");if(n.start.paragraphIndex!==n.end.paragraphIndex)throw new Error("Template variable replacement cannot span multiple paragraphs");if(n.start.paragraphIndex>=a.length)throw new Error(`Paragraph index ${n.start.paragraphIndex} out of bounds`);let l=a[n.start.paragraphIndex];I(l,n.start.offset,n.end.offset);let p=`{${t}}`;return C(l,n.start.offset,p),e.templateVariables||(e.templateVariables=[]),e.templateVariables.includes(t)||e.templateVariables.push(t),e}function C(o,i,s){let n=0,t=false;for(let e=0;e<o.content.length;e++){let r=o.content[e];if(r.type==="run"){let a=g(r),l=n,p=n+a.length;if(!t&&i>=l&&i<=p){let m=i-l,f=a.slice(0,m),x=a.slice(m),d=[];for(let c=0;c<e;c++)d.push(o.content[c]);f&&d.push({type:"run",formatting:r.formatting,content:[{type:"text",text:f}]}),d.push({type:"run",formatting:r.formatting,content:[{type:"text",text:s}]}),x&&d.push({type:"run",formatting:r.formatting,content:[{type:"text",text:x}]});for(let c=e+1;c<o.content.length;c++)d.push(o.content[c]);o.content=d,t=true;break}n=p;}else if(r.type==="hyperlink")for(let a of r.children)a.type==="run"&&(n+=g(a).length);}t||o.content.push({type:"run",content:[{type:"text",text:s}]});}function I(o,i,s){let n=[],t=0;for(let e of o.content)if(e.type==="run"){let r=g(e),a=t,l=t+r.length;if(l<=i||a>=s)n.push(e);else {let p="";a<i&&(p+=r.slice(0,i-a)),l>s&&(p+=r.slice(s-a)),p.length>0&&n.push({type:"run",formatting:e.formatting,content:[{type:"text",text:p}]});}t=l;}else n.push(e);o.content=n;}function g(o){return o.content.filter(i=>i.type==="text").map(i=>i.text).join("")}var u={type:"string",description:"Document ID from a previous docx_load call"},D={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)"},offset:{type:"number",description:"Character offset within the paragraph"}},required:["paragraphIndex","offset"]},V={name:"docx_get_variables",description:`List all template variables ({name} format) found in the document.
|
|
2
2
|
Returns variable names without braces, along with their locations (body, headers, footers, etc.).
|
|
3
3
|
Use this to discover what data fields a template document expects.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(o,i)=>{let{documentId:s}=o,n=i.session.documents.get(s);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};try{let t=b(n.document);return {content:[{type:"text",text:JSON.stringify({variables:t.variables,count:t.variables.length,totalOccurrences:t.totalOccurrences,byLocation:t.byLocation},null,2)}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to detect variables: ${t.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low",examples:[{description:"Get all variables from a loaded document",input:{documentId:"doc_123"},output:'{"variables": ["customer_name", "invoice_date"], "count": 2}'}]}},R={name:"docx_insert_variable",description:`Insert a template variable placeholder ({name}) at a specific position in the document.
|
|
4
4
|
The variable can later be substituted with actual values using docx_apply_template.
|
|
5
|
-
Variable names should follow the pattern: letters, numbers, underscores, starting with a letter.`,inputSchema:{type:"object",properties:{documentId:u,position:D,variableName:{type:"string",description:'Variable name without braces (e.g., "customer_name"). Will be inserted as {customer_name}',pattern:"^[a-zA-Z_][a-zA-Z0-9_]*$"}},required:["documentId","position","variableName"]},handler:async(o,i)=>{let{documentId:s,position:n,variableName:t}=o,e=i.session.documents.get(s);if(!e)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};if(!/^[a-zA-Z_][a-zA-Z0-9_\-.]*$/.test(t))return {isError:true,content:[{type:"text",text:`Invalid variable name: ${t}. Must start with letter/underscore and contain only alphanumeric, underscore, hyphen, or dot.`}]};try{let{executeCommand:r}=await import('./executor-
|
|
5
|
+
Variable names should follow the pattern: letters, numbers, underscores, starting with a letter.`,inputSchema:{type:"object",properties:{documentId:u,position:D,variableName:{type:"string",description:'Variable name without braces (e.g., "customer_name"). Will be inserted as {customer_name}',pattern:"^[a-zA-Z_][a-zA-Z0-9_]*$"}},required:["documentId","position","variableName"]},handler:async(o,i)=>{let{documentId:s,position:n,variableName:t}=o,e=i.session.documents.get(s);if(!e)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};if(!/^[a-zA-Z_][a-zA-Z0-9_\-.]*$/.test(t))return {isError:true,content:[{type:"text",text:`Invalid variable name: ${t}. Must start with letter/underscore and contain only alphanumeric, underscore, hyphen, or dot.`}]};try{let{executeCommand:r}=await import('./executor-LAWUSXNG.mjs'),a=r(e.document,{type:"insertText",position:n,text:`{${t}}`});return e.document=a,e.lastModified=Date.now(),a.templateVariables||(a.templateVariables=[]),a.templateVariables.includes(t)||a.templateVariables.push(t),{content:[{type:"text",text:JSON.stringify({success:!0,variable:t,insertedAs:`{${t}}`,position:n})}]}}catch(r){return {isError:true,content:[{type:"text",text:`Failed to insert variable: ${r.message}`}]}}},annotations:{category:"template",readOnly:false,complexity:"low",examples:[{description:"Insert customer name variable at start of first paragraph",input:{documentId:"doc_123",position:{paragraphIndex:0,offset:0},variableName:"customer_name"}}]}},S={name:"docx_apply_template",description:`Substitute template variables with actual values in the document.
|
|
6
6
|
Replaces all {variable} placeholders with the corresponding values provided.
|
|
7
7
|
Preserves all formatting (fonts, styles, colors, tables).
|
|
8
8
|
Use docx_get_variables first to discover what variables exist in the document.`,inputSchema:{type:"object",properties:{documentId:u,variables:{type:"object",description:'Map of variable names to values (e.g., {"customer_name": "John Doe", "date": "2024-01-15"})',additionalProperties:{type:"string"}},keepUnmatchedVariables:{type:"boolean",description:"If true, keep {variable} placeholders for variables not in the map. If false, replace with empty string. Default: true",default:true}},required:["documentId","variables"]},handler:async(o,i)=>{let{documentId:s,variables:n,keepUnmatchedVariables:t=true}=o,e=i.session.documents.get(s);if(!e)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};if(!e.buffer)return {isError:true,content:[{type:"text",text:"Cannot apply template: document was not loaded from a DOCX buffer"}]};try{let r=b$1(e.buffer,n,{nullGetter:t?"keep":"empty"}),a$1=await a(r.buffer);return e.document=a$1,e.buffer=r.buffer,e.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedVariables:r.replacedVariables,unreplacedVariables:r.unreplacedVariables,warnings:r.warnings})}]}}catch(r){return {isError:true,content:[{type:"text",text:`Failed to apply template: ${r.message}`}]}}},annotations:{category:"template",readOnly:false,complexity:"medium",examples:[{description:"Fill in customer and date values",input:{documentId:"doc_123",variables:{customer_name:"Jane Smith",invoice_date:"2024-02-15",amount:"$1,234.56"}}}]}},k={name:"docx_validate_template",description:`Validate that a document is a valid docxtemplater template.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {c}from'./chunk-
|
|
1
|
+
import {c}from'./chunk-EEEED6FG.mjs';import {a as a$2}from'./chunk-ARHPXIBJ.mjs';import {b,a as a$3}from'./chunk-IUYHWUBF.mjs';import {i,t}from'./chunk-OBRTIXHC.mjs';import {a as a$1}from'./chunk-CRQO6WI3.mjs';import {a}from'./chunk-QYUPLKLP.mjs';var P=class o{constructor(t){a(this,"_document");a(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 a$1(t);return new o(e)}static fromDocument(t){return new o(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 a$2(this._document)}getStyles(){let t=this._document.package.styles;if(!t?.styles)return [];let e=[];for(let[n,r]of Object.entries(t.styles))if(typeof r=="object"&&r!==null){let a=r;e.push({id:n,name:a.name||n,type:a.type==="numbering"?"paragraph":a.type||"paragraph",builtIn:a.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(i=>i.type==="paragraph"),r=n.map((i,s)=>{let c=this._getParagraphText(i),p=i.formatting?.styleId;return {index:s,preview:c.slice(0,t),style:p,isHeading:p?.toLowerCase().includes("heading")||false,headingLevel:this._parseHeadingLevel(p),isListItem:!!i.listRendering,isEmpty:c.trim().length===0}}),a=(e.sections||[]).map((i,s)=>({index:s,paragraphCount:i.content?.length||0,pageSize:i.properties?.pageWidth&&i.properties?.pageHeight?{width:i.properties.pageWidth,height:i.properties.pageHeight}:void 0,isLandscape:i.properties?.orientation==="landscape",hasHeader:!!i.properties?.headerReferences?.length,hasFooter:!!i.properties?.footerReferences?.length}));return {paragraphCount:n.length,wordCount:this.getWordCount(),characterCount:this.getCharacterCount(),variables:this.getVariables(),variableCount:this.getVariables().length,availableStyles:this.getStyles(),outline:r,sections:a,hasTables:this.getTableCount()>0,hasImages:this._hasImages(),hasHyperlinks:this._hasHyperlinks()}}insertText(t,e,n={}){let r={type:"insertText",position:t,text:e,formatting:n.formatting};return this._executeCommand(r)}replaceRange(t,e,n={}){let r={type:"replaceText",range:t,text:e,formatting:n.formatting};return this._executeCommand(r)}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,r={}){let a={type:"insertTable",position:t,rows:e,columns:n,data:r.data,hasHeader:r.hasHeader};return this._executeCommand(a)}insertImage(t,e,n={}){let r={type:"insertImage",position:t,src:e,width:n.width,height:n.height,alt:n.alt};return this._executeCommand(r)}insertHyperlink(t,e,n={}){let r={type:"insertHyperlink",range:t,url:e,displayText:n.displayText,tooltip:n.tooltip};return this._executeCommand(r)}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:r}=await import('./processTemplate-GPFDLQMX.mjs'),a=r(n,e),i=await a$1(a),s=new o(i);return s._pendingVariables={},s}async toBuffer(t$1){if(this._document.originalBuffer){if(t$1?.selective){let n=await c(this._document,this._document.originalBuffer,t$1.selective);if(n)return this._document.originalBuffer=n,n}let e=await i(this._document);return this._document.originalBuffer=e,e}return t(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 o(b(this._document,t))}_executeCommand(t){let e=new o(a$3(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
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 r of n.cells)for(let a of r.content)a.type==="paragraph"&&e.push(this._getParagraphText(a));return e.join(" ")}_extractParagraphSegments(t,e){for(let n of t.content)if(n.type==="run"){let r=this._getRunText(n);r&&e.push({text:r,formatting:n.formatting});}else if(n.type==="hyperlink"){let r=n.href||"";for(let a of n.children)if(a.type==="run"){let i=this._getRunText(a);i&&e.push({text:i,formatting:a.formatting,isHyperlink:true,hyperlinkUrl:r});}}}_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 r of n.content)if(r.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 Ct(o){return P.fromBuffer(o)}function kt(o){return P.fromDocument(o)}function M(o,t={}){let{outlineMaxChars:e=100,maxOutlineParagraphs:n=50}=t,r=o.package.document,a=r.content.filter(y=>y.type==="paragraph"),i=z(a,e,n),s=a$2(o),c=W(o),p=$(r),u=U(r),d=G(r),f=r.content.some(y=>y.type==="table"),x=K(r),l=N(r);return {paragraphCount:a.length,wordCount:u,characterCount:d,variables:s,variableCount:s.length,availableStyles:c,outline:i,sections:p,hasTables:f,hasImages:x,hasHyperlinks:l}}function At(o,t,e={}){let{contextChars:n=200,includeSuggestions:r=true}=e,i=o.package.document.content.filter(m=>m.type==="paragraph"),s=i[t.start.paragraphIndex];if(!s)throw new Error(`Paragraph not found at index ${t.start.paragraphIndex}`);let c=g(s),p="";if(t.start.paragraphIndex===t.end.paragraphIndex)p=c.slice(t.start.offset,t.end.offset);else {let m=[];for(let b=t.start.paragraphIndex;b<=t.end.paragraphIndex;b++){let H=i[b];if(!H)continue;let _=g(H);b===t.start.paragraphIndex?m.push(_.slice(t.start.offset)):b===t.end.paragraphIndex?m.push(_.slice(0,t.end.offset)):m.push(_);}p=m.join(`
|
|
3
3
|
`);}let u=Y(i,t.start.paragraphIndex,t.start.offset,n),d=Z(i,t.end.paragraphIndex,t.end.offset,n),f=tt(s,t.start.offset),x=s.formatting||{},l={index:t.start.paragraphIndex,fullText:c,style:s.formatting?.styleId,wordCount:v(c)},y=false,A=et(s,t.start.offset),S=r?nt(p):[];return {selectedText:p,range:t,formatting:f,paragraphFormatting:x,textBefore:u,textAfter:d,paragraph:l,inTable:y,inHyperlink:A,suggestedActions:S}}function L(o){let t=M(o,{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(r=>r.isHeading);if(n.length>0){e.push(`
|
|
4
4
|
Headings:`);for(let r of n.slice(0,5)){let a=r.headingLevel||1;e.push(`${" ".repeat(a-1)}- ${r.preview}`);}n.length>5&&e.push(` ... and ${n.length-5} more headings`);}return e.join(" ")}function z(o,t,e){let n=[];for(let r=0;r<Math.min(o.length,e);r++){let a=o[r],i=g(a),s=a.formatting?.styleId;n.push({index:r,preview:i.slice(0,t),style:s,isHeading:Q(s),headingLevel:X(s),isListItem:!!a.listRendering,isEmpty:i.trim().length===0});}return n}function W(o){let t=o.package.styles;if(!t?.styles)return [];let e=[];for(let[n,r]of Object.entries(t.styles))if(typeof r=="object"&&r!==null){let a=r;e.push({id:n,name:a.name||n,type:a.type==="numbering"?"paragraph":a.type||"paragraph",builtIn:a.default});}return e}function $(o){return o.sections?o.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 U(o){let t=0;for(let e of o.content)if(e.type==="paragraph"){let n=g(e);t+=v(n);}else e.type==="table"&&(t+=q(e));return t}function v(o){return o.split(/\s+/).filter(e=>e.length>0).length}function G(o){let t=0;for(let e of o.content)if(e.type==="paragraph"){let n=g(e);t+=n.length;}else e.type==="table"&&(t+=J(e));return t}function q(o){let t=0;for(let e of o.rows)for(let n of e.cells)for(let r of n.content)if(r.type==="paragraph"){let a=g(r);t+=v(a);}return t}function J(o){let t=0;for(let e of o.rows)for(let n of e.cells)for(let r of n.content)if(r.type==="paragraph"){let a=g(r);t+=a.length;}return t}function g(o){let t=[];for(let e of o.content)e.type==="run"?t.push(T(e)):e.type==="hyperlink"&&t.push(F(e));return t.join("")}function T(o){return o.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function F(o){let t=[];for(let e of o.children)e.type==="run"&&t.push(T(e));return t.join("")}function K(o){for(let t of o.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 N(o){for(let t of o.content)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="hyperlink")return true}return false}function Q(o){return o?o.toLowerCase().includes("heading"):false}function X(o){if(!o)return;let t=o.match(/heading\s*(\d)/i);if(t)return parseInt(t[1],10)}function Y(o,t,e,n){let r=[],a=0,i=o[t];if(i){let p=g(i).slice(0,e);r.unshift(p),a+=p.length;}for(let c=t-1;c>=0&&a<n;c--){let p=o[c];if(!p)continue;let u=g(p);r.unshift(u),a+=u.length;}let s=r.join(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';function e(){return Math.floor(Math.random()*2147483647).toString(16).toUpperCase().padStart(8,"0")}var t=/^[0-9A-Fa-f]{8}$/;function r(n){return !n||!t.test(n)?false:parseInt(n,16)<2147483647}function f(n){if(n!=null)return r(n)?n:e()}exports.a=e;exports.b=r;exports.c=f;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkZCYUN3EC_js=require('./chunk-ZCYUN3EC.js'),chunkILPNMG7Q_js=require('./chunk-ILPNMG7Q.js');function y(e){return chunkILPNMG7Q_js.g(e,chunkZCYUN3EC_js.b)}var t=chunkZCYUN3EC_js.a.getCommands(),F=t.toggleBold(),f=t.toggleItalic(),S=t.toggleUnderline(),H=t.toggleStrike(),T=t.toggleSuperscript(),h=t.toggleSubscript();function M(e){return t.setTextColor(e)}var A=t.clearTextColor();function v(e){return t.setHighlight(e)}var z=t.clearHighlight();function U(e){return t.setFontSize(e)}var b=t.clearFontSize();function B(e){return t.setFontFamily(e)}var I=t.clearFontFamily();function R(e,o){return t.setUnderlineStyle(e,o)}function _(e,o){return t.setHyperlink(e,o)}var j=t.removeHyperlink();function q(e,o,i){return t.insertHyperlink(e,o,i)}exports.a=y;exports.b=F;exports.c=f;exports.d=S;exports.e=H;exports.f=T;exports.g=h;exports.h=M;exports.i=A;exports.j=v;exports.k=z;exports.l=U;exports.m=b;exports.n=B;exports.o=I;exports.p=R;exports.q=_;exports.r=j;exports.s=q;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkPGWY6UFK_js=require('./chunk-PGWY6UFK.js'),chunkRQVHKDXK_js=require('./chunk-RQVHKDXK.js'),chunkBJSG6TEG_js=require('./chunk-BJSG6TEG.js');function K(t){return t.attrs.href||""}function z(t){return chunkPGWY6UFK_js.c(t,chunkPGWY6UFK_js.a)}function T(t){let e={};for(let n of t)switch(n.type.name){case "bold":e.bold=true,e.boldCs=true;break;case "italic":e.italic=true,e.italicCs=true;break;case "underline":{let i=n.attrs;e.underline={style:i.style||"single",color:i.color};break}case "strike":n.attrs.double?e.doubleStrike=true:e.strike=true;break;case "textColor":{let i=n.attrs;e.color={rgb:i.rgb,themeColor:i.themeColor,themeTint:i.themeTint,themeShade:i.themeShade};break}case "highlight":e.highlight=n.attrs.color;break;case "fontSize":e.fontSize=n.attrs.size,e.fontSizeCs=n.attrs.size;break;case "fontFamily":{let i=n.attrs;e.fontFamily={ascii:i.ascii,hAnsi:i.hAnsi,eastAsia:i.eastAsia||void 0,cs:i.cs||i.ascii||void 0,asciiTheme:i.asciiTheme,hAnsiTheme:i.hAnsiTheme||void 0,eastAsiaTheme:i.eastAsiaTheme||void 0,csTheme:i.csTheme||void 0};break}case "superscript":e.vertAlign="superscript";break;case "subscript":e.vertAlign="subscript";break;case "allCaps":e.allCaps=true;break;case "smallCaps":e.smallCaps=true;break;case "characterSpacing":{n.attrs.spacing!=null&&(e.spacing=n.attrs.spacing),n.attrs.position!=null&&(e.position=n.attrs.position),n.attrs.scale!=null&&(e.scale=n.attrs.scale),n.attrs.kerning!=null&&(e.kerning=n.attrs.kerning);break}case "emboss":e.emboss=true;break;case "imprint":e.imprint=true;break;case "textShadow":e.shadow=true;break;case "emphasisMark":e.emphasisMark=n.attrs.type||"dot";break;case "textOutline":e.outline=true;break;case "hidden":e.hidden=true;break;case "rtl":e.rtl=true;break;case "textEffect":e.effect=n.attrs.effect||"blinkBackground";break;case "runStyle":n.attrs.styleId&&(e.styleId=n.attrs.styleId);break}return e}function V(t){let e=t.attrs.href;return e?.startsWith("#")?{type:"hyperlink",anchor:e.substring(1),tooltip:t.attrs.tooltip||void 0,children:[]}:{type:"hyperlink",href:e,tooltip:t.attrs.tooltip||void 0,rId:t.attrs.rId||void 0,children:[]}}function M(t,e){let n=e.marks.filter(i=>i.type.name!=="hyperlink");e.isText&&e.text?t.children.push(w(e.text,n)):e.type.name==="tab"?t.children.push(S()):e.type.name==="hardBreak"&&t.children.push(v());}function w(t,e){let n=T(e),i={type:"text",text:t};return {type:"run",formatting:Object.keys(n).length>0?n:void 0,content:[i]}}function U(t,e){let n=t.content[t.content.length-1];n&&n.type==="text"?n.text+=e:t.content.push({type:"text",text:e});}function v(){return {type:"run",content:[{type:"break",breakType:"textWrapping"}]}}function S(){return {type:"run",content:[{type:"tab"}]}}function $(t,e){let n=t.attrs,i=e&&e.length>0?T(e):void 0,r=n.displayText||"";if(!r)switch(n.fieldType){case "PAGE":r="1";break;case "NUMPAGES":r="1";break;default:r=" ";break}let o={type:"run",content:[{type:"text",text:r}],...i&&Object.keys(i).length>0?{formatting:i}:{}};return n.fieldKind==="complex"?{type:"complexField",instruction:n.instruction,fieldType:n.fieldType,fieldCode:[],fieldResult:[o],fldLock:n.fldLock||void 0,dirty:n.dirty||void 0}:{type:"simpleField",instruction:n.instruction,fieldType:n.fieldType,content:[o],fldLock:n.fldLock||void 0,dirty:n.dirty||void 0}}function J(t){let e=t.attrs;return {type:"mathEquation",display:e.display||"inline",ommlXml:e.ommlXml,plainText:e.plainText||void 0}}function I(t){let e=t.attrs,i={type:e.wrapType||"inline"};e.distTop!==void 0&&(i.distT=chunkBJSG6TEG_js.g(e.distTop)),e.distBottom!==void 0&&(i.distB=chunkBJSG6TEG_js.g(e.distBottom)),e.distLeft!==void 0&&(i.distL=chunkBJSG6TEG_js.g(e.distLeft)),e.distRight!==void 0&&(i.distR=chunkBJSG6TEG_js.g(e.distRight)),e.wrapText&&(i.wrapText=e.wrapText);let r={type:"image",rId:e.rId||"",src:e.src,alt:e.alt||void 0,title:e.title||void 0,size:{width:chunkBJSG6TEG_js.g(e.width||0),height:chunkBJSG6TEG_js.g(e.height||0)},wrap:i};if(e.transform){let a=e.transform,l={},d=a.match(/rotate\(([-\d.]+)deg\)/);d&&(l.rotation=parseFloat(d[1])),a.includes("scaleX(-1)")&&(l.flipH=true),a.includes("scaleY(-1)")&&(l.flipV=true),(l.rotation||l.flipH||l.flipV)&&(r.transform=l);}if(e.position?.horizontal&&e.position?.vertical){let a=e.position;r.position={horizontal:{relativeTo:a.horizontal.relativeTo||"column",alignment:a.horizontal.align,posOffset:a.horizontal.posOffset},vertical:{relativeTo:a.vertical.relativeTo||"paragraph",alignment:a.vertical.align,posOffset:a.vertical.posOffset}};}if(e.borderWidth&&e.borderWidth>0){let a={solid:"solid",dotted:"dot",dashed:"dash",double:"solid",groove:"solid",ridge:"solid",inset:"solid",outset:"solid"};r.outline={width:chunkBJSG6TEG_js.g(e.borderWidth),color:e.borderColor?{rgb:e.borderColor.replace("#","")}:void 0,style:e.borderStyle&&a[e.borderStyle]||"solid"};}if(e.hlinkHref&&(r.hlinkHref=e.hlinkHref),e.cropTop!==void 0||e.cropRight!==void 0||e.cropBottom!==void 0||e.cropLeft!==void 0){let a={};e.cropTop!==void 0&&e.cropTop!==null&&(a.top=e.cropTop),e.cropRight!==void 0&&e.cropRight!==null&&(a.right=e.cropRight),e.cropBottom!==void 0&&e.cropBottom!==null&&(a.bottom=e.cropBottom),e.cropLeft!==void 0&&e.cropLeft!==null&&(a.left=e.cropLeft),Object.keys(a).length>0&&(r.crop=a);}if(e.opacity!==void 0&&e.opacity!==null&&e.opacity<1&&(r.opacity=e.opacity),e.layoutInCell!==void 0&&e.layoutInCell!==null&&(r.layoutInCell=e.layoutInCell),e.allowOverlap!==void 0&&e.allowOverlap!==null&&(r.allowOverlap=e.allowOverlap),e.effectExtentTop||e.effectExtentBottom||e.effectExtentLeft||e.effectExtentRight){let a={};e.effectExtentTop&&(a.top=chunkBJSG6TEG_js.g(e.effectExtentTop)),e.effectExtentBottom&&(a.bottom=chunkBJSG6TEG_js.g(e.effectExtentBottom)),e.effectExtentLeft&&(a.left=chunkBJSG6TEG_js.g(e.effectExtentLeft)),e.effectExtentRight&&(a.right=chunkBJSG6TEG_js.g(e.effectExtentRight)),Object.keys(a).length>0&&(r.padding=a);}return {type:"run",content:[{type:"drawing",image:r}]}}function B(t){let e=t.attrs,n={type:"shape",shapeType:e.shapeType||"rect",id:e.shapeId||void 0,size:{width:e.width?chunkBJSG6TEG_js.g(e.width):0,height:e.height?chunkBJSG6TEG_js.g(e.height):0}};if(e.fillType==="gradient"&&e.gradientStops)try{let r=JSON.parse(e.gradientStops);n.fill={type:"gradient",gradient:{type:e.gradientType||"linear",angle:e.gradientAngle||void 0,stops:r.map(o=>({position:o.position,color:{rgb:o.color.replace("#","")}}))}};}catch{n.fill={type:"solid",color:{rgb:(e.fillColor||"000000").replace("#","")}};}else e.fillColor?n.fill={type:e.fillType||"solid",color:{rgb:e.fillColor.replace("#","")}}:e.fillType==="none"&&(n.fill={type:"none"});if(e.outlineWidth&&e.outlineWidth>0){let r={solid:"solid",dotted:"dot",dashed:"dash"};n.outline={width:chunkBJSG6TEG_js.g(e.outlineWidth),color:e.outlineColor?{rgb:e.outlineColor.replace("#","")}:void 0,style:e.outlineStyle&&r[e.outlineStyle]||"solid"};}return {type:"run",content:[{type:"shape",shape:n}]}}function x(t){let e=t.attrs,n=Q(G(t),t);n=re(n,t);let i=e.bookmarks;if(i&&i.length>0){let o=i.map(l=>({type:"bookmarkStart",id:l.id,name:l.name})),a=i.map(l=>({type:"bookmarkEnd",id:l.id}));n=[...o,...n,...a];}let r={type:"paragraph",paraId:e.paraId||void 0,textId:e.textId||void 0,formatting:se(e),content:n};return e.renderedPageBreakBefore&&(r.renderedPageBreakBefore=true),e.pPrIns&&(r.pPrIns={id:e.pPrIns.revisionId,author:e.pPrIns.author,...e.pPrIns.date?{date:e.pPrIns.date}:{}}),e.pPrDel&&(r.pPrDel={id:e.pPrDel.revisionId,author:e.pPrDel.author,...e.pPrDel.date?{date:e.pPrDel.date}:{}}),e.pPrChange&&e.pPrChange.length>0&&(r.propertyChanges=e.pPrChange),e._sectionProperties?r.sectionProperties=e._sectionProperties:e.sectionBreakType&&(r.sectionProperties={sectionStart:e.sectionBreakType}),r}function Q(t,e){let n=e.attrs._originalRunBoundaries;if(!n||n.length===0||!t.every(a=>a.type==="run"))return t;let i=t;if(!i.every(Z))return t;let r=i.map(F).join(""),o=n.map(a=>a.text).join("");return r!==o||!ee(e,n)?t:te(i,n)??t}function Z(t){return t.content.every(e=>e.type==="text")}function F(t){return t.content.map(e=>e.type==="text"?e.text:"").join("")}function ee(t,e){let n=0,i=0,r=true;if(t.forEach(o=>{if(!r)return;if(!o.isText){r=false;return}let a=chunkPGWY6UFK_js.c(o.marks,chunkPGWY6UFK_js.b),l=o.text??"",d=0;for(;d<l.length;){for(;n<e.length&&e[n].text.length===0;)n++;let s=e[n];if(!s||a!==(s.marksKey??"")){r=false;return}let u=s.text.length-i,c=l.length-d,p=Math.min(u,c),m=l.slice(d,d+p),g=s.text.slice(i,i+p);if(m!==g){r=false;return}d+=p,i+=p,i===s.text.length&&(n++,i=0);}}),!r)return false;for(;n<e.length&&e[n].text.length===0;)n++;return n===e.length&&i===0}function te(t,e){let n=[],i={runIndex:0,runOffset:0};for(let r of e){if(r.text.length===0){n.push(ne(r));continue}let o=ie(t,i,r.text.length);if(!o)return null;r.propertyChanges&&r.propertyChanges.length>0&&(o.propertyChanges=r.propertyChanges),n.push(o);}for(;i.runIndex<t.length;){if(F(t[i.runIndex]).length-i.runOffset>0)return null;i.runIndex++,i.runOffset=0;}return n}function ne(t){let e={type:"run",content:[]};return t.formatting&&Object.keys(t.formatting).length>0&&(e.formatting=t.formatting),t.propertyChanges&&t.propertyChanges.length>0&&(e.propertyChanges=t.propertyChanges),e}function ie(t,e,n){let i=n,r="",o,a;for(;i>0;){let d=t[e.runIndex];if(!d)return null;let s=F(d),u=s.length-e.runOffset;if(u<=0){e.runIndex++,e.runOffset=0;continue}let c=JSON.stringify(d.formatting??null);if(a==null)o=d.formatting,a=c;else if(a!==c)return null;let p=Math.min(i,u);r+=s.slice(e.runOffset,e.runOffset+p),e.runOffset+=p,i-=p,e.runOffset===s.length&&(e.runIndex++,e.runOffset=0);}let l={type:"run",content:[{type:"text",text:r}]};return o&&Object.keys(o).length>0&&(l.formatting=o),l}function re(t,e){let n=new Set;if(e.forEach(a=>{for(let l of a.marks)l.type.name==="comment"&&n.add(l.attrs.commentId);}),n.size===0)return t;let i=[],r=new Set,o={index:0};for(e.forEach(a=>{let l=new Set;for(let d of a.marks)d.type.name==="comment"&&l.add(d.attrs.commentId);for(let d of [...r])l.has(d)||(i.push({type:"commentRangeEnd",id:d}),r.delete(d));for(let d of l)r.has(d)||(i.push({type:"commentRangeStart",id:d}),r.add(d));oe(i,t,o,a);});o.index<t.length;)i.push(t[o.index]),o.index++;for(let a of r)i.push({type:"commentRangeEnd",id:a});return i}function oe(t,e,n,i){if(!i.isText){ae(t,e,n);return}let r=(i.text??"").length;for(;r>0&&n.index<e.length;){let o=e[n.index];t.push(o),n.index++,r-=q(o);}}function ae(t,e,n){n.index>=e.length||(t.push(e[n.index]),n.index++);}function q(t){switch(t.type){case "run":return le(t);case "hyperlink":return k(t.children);case "simpleField":return k(t.content);case "complexField":return k(t.fieldResult);case "inlineSdt":return k(t.content);case "insertion":case "deletion":case "moveFrom":case "moveTo":return k(t.content);case "mathEquation":return t.plainText?.length??0;default:return 0}}function k(t){return t.reduce((e,n)=>e+q(n),0)}function le(t){return t.content.reduce((e,n)=>{switch(n.type){case "text":case "instrText":return e+n.text.length;case "symbol":return e+n.char.length;case "tab":case "softHyphen":case "noBreakHyphen":return e+1;default:return e}},0)}function X(t){return t.numPrFromStyle!=null&&t.numPr!=null&&JSON.stringify(t.numPr)===JSON.stringify(t.numPrFromStyle)}function se(t){if(t._originalFormatting){let n=t._originalFormatting,i={...n};return t.alignment!==(n.alignment||void 0)&&(i.alignment=t.alignment||void 0),X(t)?(delete i.numPr,delete i.numPrFromStyle):t.numPr!==n.numPr&&JSON.stringify(t.numPr)!==JSON.stringify(n.numPr)&&(i.numPr=t.numPr||void 0,delete i.numPrFromStyle),t.styleId!==(n.styleId||void 0)&&(i.styleId=t.styleId||void 0),t.pageBreakBefore!==(n.pageBreakBefore||void 0)&&(i.pageBreakBefore=t.pageBreakBefore||void 0),t.bidi!==(n.bidi||void 0)&&(i.bidi=t.bidi||void 0),i}if(t.alignment||t.spaceBefore||t.spaceAfter||t.lineSpacing||t.indentLeft||t.indentRight||t.indentFirstLine||t.numPr||t.styleId||t.borders||t.shading||t.tabs||t.outlineLevel!=null||t.contextualSpacing||t.pageBreakBefore||t.bidi)return {alignment:t.alignment||void 0,spaceBefore:t.spaceBefore||void 0,spaceAfter:t.spaceAfter||void 0,lineSpacing:t.lineSpacing||void 0,lineSpacingRule:t.lineSpacingRule||void 0,indentLeft:t.indentLeft||void 0,indentRight:t.indentRight||void 0,indentFirstLine:t.indentFirstLine||void 0,hangingIndent:t.hangingIndent||void 0,numPr:X(t)?void 0:t.numPr||void 0,styleId:t.styleId||void 0,borders:t.borders||void 0,shading:t.shading||void 0,tabs:t.tabs||void 0,outlineLevel:t.outlineLevel??void 0,contextualSpacing:t.contextualSpacing||void 0,pageBreakBefore:t.pageBreakBefore||void 0,bidi:t.bidi||void 0}}function G(t){let e=[],n=null,i=null,r=null;return t.forEach(o=>{let a=o.marks.find(u=>u.type.name==="footnoteRef");if(a){n&&(e.push(n),n=null,i=null),r&&(e.push(r),r=null);let c={type:a.attrs.noteType==="endnote"?"endnoteRef":"footnoteRef",id:parseInt(a.attrs.id,10)||0};e.push({type:"run",content:[c]});return}let l=o.marks.find(u=>u.type.name==="insertion"),d=o.marks.find(u=>u.type.name==="deletion");if(l||d){n&&(e.push(n),n=null,i=null),r&&(e.push(r),r=null);let u=l||d,c;if(o.type.name==="image")c=I(o);else if(o.type.name==="shape")c=B(o);else {let g=o.marks.filter(y=>y.type.name!=="insertion"&&y.type.name!=="deletion"),h=T(g);c={type:"run",content:o.isText&&o.text?[{type:"text",text:o.text}]:[],...Object.keys(h).length>0?{formatting:h}:{}};}let p={id:u.attrs.revisionId,author:u.attrs.author||"Unknown",date:u.attrs.date||void 0},m=u.attrs.isMovePair===true;l?m?e.push({type:"moveTo",info:p,content:[c]}):e.push({type:"insertion",info:p,content:[c]}):m?e.push({type:"moveFrom",info:p,content:[c]}):e.push({type:"deletion",info:p,content:[c]});return}let s=o.marks.find(u=>u.type.name==="hyperlink");if(s){let u=K(s),c=r?.href||(r?.anchor?`#${r.anchor}`:"");r&&c===u?M(r,o):(n&&(e.push(n),n=null,i=null),r&&e.push(r),r=V(s),M(r,o));return}if(r&&(e.push(r),r=null),o.isText){let u=z(o.marks);n&&i===u?U(n,o.text||""):(n&&e.push(n),n=w(o.text||"",o.marks),i=u);}else o.type.name==="hardBreak"?(n&&(e.push(n),n=null,i=null),e.push(v())):o.type.name==="image"?(n&&(e.push(n),n=null,i=null),e.push(I(o))):o.type.name==="shape"?(n&&(e.push(n),n=null,i=null),e.push(B(o))):o.type.name==="tab"?(n&&(e.push(n),n=null,i=null),e.push(S())):o.type.name==="field"?(n&&(e.push(n),n=null,i=null),e.push($(o,o.marks))):o.type.name==="sdt"?(n&&(e.push(n),n=null,i=null),e.push(de(o))):o.type.name==="math"&&(n&&(e.push(n),n=null,i=null),e.push(J(o)));}),n&&e.push(n),r&&e.push(r),e}function de(t){let e=chunkPGWY6UFK_js.e(t.attrs),i=G(t).filter(r=>r.type==="run"||r.type==="hyperlink"||r.type==="simpleField"||r.type==="complexField"||r.type==="inlineSdt"||r.type==="mathEquation");return {type:"inlineSdt",properties:e,content:i}}function ue(t){for(let e of t)for(let n of e.cells){let i=n.formatting?.borders;if(i){let r=i.top||i.left||i.right||i.bottom||i.insideH||i.insideV;return r?{top:i.top??r,bottom:i.bottom??r,left:i.left??r,right:i.right??r,insideH:i.insideH??i.bottom??r,insideV:i.insideV??i.right??r}:void 0}}}function pe(t){let e=[],n=[],i=0;for(let r=0;r<t.childCount;r++){let o=t.child(r),a=0;o.forEach(l=>{if(l.type.name!=="tableCell"&&l.type.name!=="tableHeader")return;for(;e[r]?.[a];)a++;let d=l.attrs.rowspan||1,s=l.attrs.colspan||1;n.push({row:r,col:a,rowspan:d,colspan:s,cell:he(l)});for(let u=r;u<r+d;u++){let c=e[u]??[];e[u]=c;for(let p=a;p<a+s;p++)c[p]=true;}a+=s,i=Math.max(i,a);});}return {anchors:n,totalCols:i}}function ce(t){let e=new Map;t.forEach((i,r)=>{let o=0;for(let a of i.cells){let l=o;if(o+=a.formatting?.gridSpan??1,a.formatting?.vMerge){let d=e.get(l)??[];d.push({rowIndex:r,cell:a}),e.set(l,d);}}});let n=i=>{i.formatting&&(delete i.formatting.vMerge,Object.keys(i.formatting).length===0&&(i.formatting=void 0));};for(let i of e.values()){let r=null,o=0,a=-1,l=()=>{r&&o<2&&n(r),r=null,o=0;};for(let{rowIndex:d,cell:s}of i){let u=s.formatting?.vMerge;u==="restart"?(l(),r=s,o=1,a=d):u==="continue"&&(r&&d===a+1?(o++,a=d):(l(),n(s)));}l();}}function A(t){let e=t.attrs,{anchors:n,totalCols:i}=pe(t),r=new Map,o=new Map;for(let s of n){r.set(`${s.row}-${s.col}`,s);for(let u=s.row;u<s.row+s.rowspan;u++)for(let c=s.col;c<s.col+s.colspan;c++)o.set(`${u}-${c}`,s);}let a=[];for(let s=0;s<t.childCount;s++){let u=t.child(s),c=[];for(let g=0;g<i;){let h=r.get(`${s}-${g}`);if(h){let b={...h.cell.formatting??{}};h.colspan>1?b.gridSpan=h.colspan:delete b.gridSpan,h.rowspan>1?b.vMerge="restart":b.vMerge!=="restart"&&b.vMerge!=="continue"&&delete b.vMerge,c.push({...h.cell,formatting:Object.keys(b).length?b:void 0}),g+=h.colspan;continue}let y=o.get(`${s}-${g}`);if(!y){g++;continue}let C={...y.cell.formatting??{}};y.colspan>1?C.gridSpan=y.colspan:delete C.gridSpan,C.vMerge="continue",c.push({...y.cell,content:[],formatting:C}),g+=y.colspan;}let p=u.attrs,m={type:"tableRow",formatting:ge(p),cells:c};p.trIns?m.structuralChange={type:"tableRowInsertion",info:{id:p.trIns.revisionId,author:p.trIns.author,...p.trIns.date?{date:p.trIns.date}:{}}}:p.trDel&&(m.structuralChange={type:"tableRowDeletion",info:{id:p.trDel.revisionId,author:p.trDel.author,...p.trDel.date?{date:p.trDel.date}:{}}}),p.trPrChange&&p.trPrChange.length>0&&(m.propertyChanges=p.trPrChange),a.push(m);}ce(a);let l=fe(e)||void 0;if(!l?.borders){let s=ue(a);if(s)if(l)l.borders=s;else return {type:"table",columnWidths:e.columnWidths||void 0,formatting:{borders:s},rows:a}}let d={type:"table",columnWidths:e.columnWidths||void 0,formatting:l,rows:a};return e.tblPrChange&&e.tblPrChange.length>0&&(d.propertyChanges=e.tblPrChange),d}function fe(t){if(t._originalFormatting){let r=t._originalFormatting,o={...r};t.styleId!==(r.styleId||void 0)&&(o.styleId=t.styleId||void 0),t.justification!==(r.justification||void 0)&&(o.justification=t.justification||void 0),t.floating!==(r.floating||void 0)&&(o.floating=t.floating||void 0),t.tableLayout!==(r.layout||void 0)&&(o.layout=t.tableLayout||void 0),t.look!==(r.look||void 0)&&(o.look=t.look||void 0);let a=r.width?.value,l=r.width?.type;return (t.width!==a||t.widthType!==l)&&(t.width!=null||t.widthType?o.width={value:t.width??0,type:t.widthType||"dxa"}:o.width=void 0),t.cellMargins&&(o.cellMargins={top:t.cellMargins.top!=null?{value:t.cellMargins.top,type:"dxa"}:void 0,bottom:t.cellMargins.bottom!=null?{value:t.cellMargins.bottom,type:"dxa"}:void 0,left:t.cellMargins.left!=null?{value:t.cellMargins.left,type:"dxa"}:void 0,right:t.cellMargins.right!=null?{value:t.cellMargins.right,type:"dxa"}:void 0}),o}if(!(t.styleId||t.width!=null||t.widthType||t.justification||t.tableLayout||t.floating||t.cellMargins||t.look))return;let n=t.cellMargins?{top:t.cellMargins.top!=null?{value:t.cellMargins.top,type:"dxa"}:void 0,bottom:t.cellMargins.bottom!=null?{value:t.cellMargins.bottom,type:"dxa"}:void 0,left:t.cellMargins.left!=null?{value:t.cellMargins.left,type:"dxa"}:void 0,right:t.cellMargins.right!=null?{value:t.cellMargins.right,type:"dxa"}:void 0}:void 0,i;return (t.width!=null||t.widthType)&&(i={value:t.width??0,type:t.widthType||"dxa"}),{styleId:t.styleId||void 0,width:i,justification:t.justification||void 0,layout:t.tableLayout||void 0,floating:t.floating||void 0,cellMargins:n,look:t.look||void 0}}function ge(t){if(t._originalFormatting){let n=t._originalFormatting,i={...n};return t.height!==(n.height?.value||void 0)&&(i.height=t.height?{value:t.height,type:"dxa"}:void 0),t.heightRule!==(n.heightRule||void 0)&&(i.heightRule=t.heightRule||void 0),t.isHeader!==(n.header||void 0)&&(i.header=t.isHeader||void 0),i}if(t.height||t.isHeader)return {height:t.height?{value:t.height,type:"dxa"}:void 0,heightRule:t.heightRule||void 0,header:t.isHeader||void 0}}function he(t){let e=t.attrs,n=[];t.forEach(r=>{r.type.name==="paragraph"?n.push(x(r)):r.type.name==="table"&&n.push(A(r));});let i={type:"tableCell",formatting:me(e),content:n};if(e.cellMarker){let r=e.cellMarker,o={id:r.info.revisionId,author:r.info.author,...r.info.date?{date:r.info.date}:{}};r.kind==="ins"?i.structuralChange={type:"tableCellInsertion",info:o}:r.kind==="del"?i.structuralChange={type:"tableCellDeletion",info:o}:i.structuralChange={type:"tableCellMerge",info:o,...r.vMerge?{vMerge:r.vMerge}:{},...r.vMergeOrig?{vMergeOrig:r.vMergeOrig}:{}};}return e.tcPrChange&&e.tcPrChange.length>0&&(i.propertyChanges=e.tcPrChange),i}function me(t){if(t._originalFormatting){let i=t._originalFormatting,r={...i};if(t.colspan>1&&(r.gridSpan=t.colspan),t.width!=null&&(r.width={value:t.width,type:t.widthType||"dxa"}),t.verticalAlign!==(i.verticalAlign||void 0)&&(r.verticalAlign=t.verticalAlign||void 0),t.backgroundColor?t._originalResolvedFill===t.backgroundColor&&i.shading?r.shading=i.shading:r.shading={fill:{rgb:t.backgroundColor}}:i.shading&&(r.shading=void 0),t.borders&&(r.borders=t.borders),t.margins){let o=t.margins,a={};o.top!=null&&(a.top={value:o.top,type:"dxa"}),o.bottom!=null&&(a.bottom={value:o.bottom,type:"dxa"}),o.left!=null&&(a.left={value:o.left,type:"dxa"}),o.right!=null&&(a.right={value:o.right,type:"dxa"}),r.margins=a;}return t.textDirection!==(i.textDirection||void 0)&&(r.textDirection=t.textDirection||void 0),r}if(!(t.colspan>1||t.rowspan>1||t.width!=null||t.verticalAlign||t.backgroundColor||t.borders||t.margins||t.textDirection))return;let n;if(t.margins){let i=t.margins;n={},i.top!=null&&(n.top={value:i.top,type:"dxa"}),i.bottom!=null&&(n.bottom={value:i.bottom,type:"dxa"}),i.left!=null&&(n.left={value:i.left,type:"dxa"}),i.right!=null&&(n.right={value:i.right,type:"dxa"});}return {gridSpan:t.colspan>1?t.colspan:void 0,width:t.width!=null?{value:t.width,type:t.widthType||"dxa"}:void 0,verticalAlign:t.verticalAlign||void 0,textDirection:t.textDirection||void 0,shading:t.backgroundColor?{fill:{rgb:t.backgroundColor}}:void 0,borders:t.borders,margins:n}}function O(t){let e=t.attrs,n=[];t.forEach(l=>{l.type.name==="paragraph"&&n.push(x(l));});let i={type:"shape",shapeType:"rect",id:e.textBoxId||void 0,size:{width:e.width?chunkBJSG6TEG_js.g(e.width):0,height:e.height?chunkBJSG6TEG_js.g(e.height):0},textBody:{content:n.length>0?n:[{type:"paragraph",content:[]}],margins:{top:e.marginTop!=null?chunkBJSG6TEG_js.g(e.marginTop):void 0,bottom:e.marginBottom!=null?chunkBJSG6TEG_js.g(e.marginBottom):void 0,left:e.marginLeft!=null?chunkBJSG6TEG_js.g(e.marginLeft):void 0,right:e.marginRight!=null?chunkBJSG6TEG_js.g(e.marginRight):void 0}}},r=chunkPGWY6UFK_js.i(e);r&&(i.position=r);let o=chunkPGWY6UFK_js.j(e);if(o&&(i.wrap=o),e.fillColor&&(i.fill={type:"solid",color:{rgb:e.fillColor.replace("#","")}}),e.outlineWidth&&e.outlineWidth>0){let l={solid:"solid",dotted:"dot",dashed:"dash"};i.outline={width:chunkBJSG6TEG_js.g(e.outlineWidth),color:e.outlineColor?{rgb:e.outlineColor.replace("#","")}:void 0,style:e.outlineStyle&&l[e.outlineStyle]||"solid"};}return {type:"run",content:[{type:"shape",shape:i}]}}function Y(t){return {type:"paragraph",content:[O(t)]}}function ye(t,e){let i={content:N(t),finalSectionProperties:e?.package.document.finalSectionProperties,sections:e?.package.document.sections,comments:e?.package.document.comments},r=e?{...e,package:{...e.package,document:i}}:{package:{document:i}},o=t.attrs.watermark??null,a=chunkRQVHKDXK_js.a(r)??null;return o!==a?chunkRQVHKDXK_js.b(r,o):r}function N(t){let e=[],n=[],i=()=>{for(let r of n)e.push({type:"paragraph",content:[r]});n=[];};return t.forEach(r=>{if(r.type.name==="paragraph"){let o=x(r);n.length>0&&(o.content=[...n,...o.content],n=[]),e.push(o);}else if(r.type.name==="table")i(),e.push(A(r));else if(r.type.name==="blockSdt")i(),e.push(be(r));else if(r.type.name==="textBox"){let o=r.attrs;chunkPGWY6UFK_js.h(o)?n.push(O(r)):(i(),e.push(Y(r)));}else r.type.name==="pageBreak"&&(i(),e.push(xe()));}),i(),e}function be(t){return {type:"blockSdt",properties:chunkPGWY6UFK_js.e(t.attrs),content:N(t)}}function xe(){return {type:"paragraph",content:[{type:"run",content:[{type:"break",breakType:"page"}]}]}}function Ke(t,e){return ye(e,t)}function ze(t){return N(t)}exports.a=ye;exports.b=Ke;exports.c=ze;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {e,b,c,a as a$1}from'./chunk-KQTB5Y7P.mjs';import {a}from'./chunk-NO6PIL32.mjs';import {i,g}from'./chunk-MJ6XZFVD.mjs';import {TextSelection}from'prosemirror-state';function _(e){let{$from:t}=e.selection,n=null,r=null,s=null,a=-1,o=-1;for(let i=t.depth;i>0;i--){let c=t.node(i);if(c.type.name==="tableCell"||c.type.name==="tableHeader"){s=c;let l=t.node(i-1);if(l?.type.name==="tableRow"){let b=0;l.forEach((h,y,S)=>{if(o===-1){if(S===t.index(i-1)){o=b;return}b+=h.attrs.colspan||1;}});}}else if(c.type.name==="tableRow")t.node(i-1)?.type.name==="table"&&(a=t.index(i-1));else if(c.type.name==="table"){n=c,r=t.before(i);break}}return !n||r==null||!s||a<0||o<0?null:{table:n,tablePos:r,cell:s,row:a,col:o,rowspan:s.attrs.rowspan||1,colspan:s.attrs.colspan||1}}function H(e){let t=[],n=[],r=0;for(let s=0;s<e.childCount;s++){let a=e.child(s),o=0;a.forEach(i=>{for(;t[s]?.[o];)o++;let c=i.attrs.rowspan||1,l=i.attrs.colspan||1;n.push({data:i,row:s,col:o,rowspan:c,colspan:l});for(let b=s;b<s+c;b++){let h=t[b]??[];t[b]=h;for(let y=o;y<o+l;y++)h[y]=true;}o+=l,r=Math.max(r,o);});}return {anchors:n,totalCols:r}}function j(e,t,n,r,s){let a={...e.attrs},o=s.reduce((l,b)=>l+b,0),i=a$1(s,t,n),c=n!==(e.attrs.colspan||1)||r!==(e.attrs.rowspan||1);return a.colspan=n,a.rowspan=r,a.colwidth=null,o>0&&(a.width=Math.round(i/o*5e3),a.widthType="pct"),c&&(a._originalFormatting=null),a}function Y(e,t,n,r){let s=t+1;for(let a=0;a<e.childCount;a++){let o=e.child(a),i=s+1,c=0;for(let l=0;l<o.childCount;l++){let b=o.child(l);if(a===n&&c===r)return i;c+=b.attrs.colspan||1,i+=b.nodeSize;}s+=o.nodeSize;}return null}function q(e,t){let n=e.attrs.width??9360;return Array.isArray(e.attrs.columnWidths)&&e.attrs.columnWidths.length>0?[...e.attrs.columnWidths]:Array.from({length:t},()=>Math.floor(n/Math.max(t,1)))}function Q(e$1){let t=_(e$1);return t?{...e(t.rowspan,t.colspan),capturedCellRow:t.row,capturedCellCol:t.col}:null}function Z(e,t,n,r,s,a){if(n<1||r<1)return false;let o=_(e);if(!o||!t)return false;let i=o;if(s!=null&&a!=null&&(s!==o.row||a!==o.col)){let{anchors:p}=H(o.table),g=p.find(T=>T.row===s&&T.col===a);if(!g)return false;i={...o,cell:g.data,row:g.row,col:g.col,rowspan:g.rowspan,colspan:g.colspan};}if(n<i.rowspan||r<i.colspan||n===1&&r===1)return false;let{anchors:c$1,totalCols:l}=H(i.table),b$1=q(i.table,l),h=b(b$1,i.col,i.colspan,r),y=c$1.find(p=>p.row===i.row&&p.col===i.col);if(!y)return false;let S=c(c$1,y,n,r,i.table.childCount,p=>{if(p)return y.data;let g=y.data.type.schema.nodes.paragraph.create(),T=j(y.data,0,1,1,h);return y.data.type.create(T,g)}),x=i.row+i.rowspan,w=Array.from({length:S.newRowCount},(p,g)=>g<x?{...i.table.child(g)?.attrs??{}}:g<i.row+n?{...i.table.child(x-1)?.attrs??{}}:{...i.table.child(g-S.deltaRows)?.attrs??{}}),k=Array.from({length:S.newRowCount},()=>[]);S.anchors.sort((p,g)=>p.row===g.row?p.col-g.col:p.row-g.row).forEach(p=>{let g=j(p.data,p.col,p.colspan,p.rowspan,h);k[p.row].push(p.data.type.create(g,p.data.content));});let u=k.map((p,g)=>i.table.type.schema.nodes.tableRow.create(w[g],p)),d=i.table.type.create({...i.table.attrs,columnWidths:h},u),f=e.tr.replaceWith(i.tablePos,i.tablePos+i.table.nodeSize,d),C=f.doc.nodeAt(i.tablePos);if(C){let p=Y(C,i.tablePos,i.row,i.col);p!=null&&(f=f.setSelection(TextSelection.near(f.doc.resolve(p+1))));}return t(f.scrollIntoView()),true}var m=a.getCommands();function re(e,t){return m.insertTable(e,t)}function ne(e,t){return m.addRowAbove()(e,t)}function oe(e,t){return m.addRowBelow()(e,t)}function ae(e,t){return m.deleteRow()(e,t)}function ie(e,t){return m.addColumnLeft()(e,t)}function se(e,t){return m.addColumnRight()(e,t)}function le(e,t){return m.deleteColumn()(e,t)}function ce(e,t){return m.deleteTable()(e,t)}function de(e,t){return m.selectTable()(e,t)}function ue(e,t){return m.selectRow()(e,t)}function pe(e,t){return m.selectColumn()(e,t)}function me(e,t){return m.mergeCells()(e,t)}function fe(e,t){return m.splitCell()(e,t)}function ge(e,t,n){return m.setCellBorder(e,t,n)}function be(e,t){return m.setTableBorders(e,t)}function he(e,t){return m.removeTableBorders()(e,t)}function ye(e,t,n){return m.setAllTableBorders(n)(e,t)}function Ce(e,t,n){return m.setOutsideTableBorders(n)(e,t)}function Te(e,t,n){return m.setInsideTableBorders(n)(e,t)}function Se(e){return m.setCellVerticalAlign(e)}function ke(e){return m.setCellMargins(e)}function ve(e){return m.setCellTextDirection(e)}function xe(){return m.toggleNoWrap()}function we(e,t){return m.setRowHeight(e,t)}function Ie(){return m.toggleHeaderRow()}function Pe(){return m.distributeColumns()}function Ae(){return m.autoFitContents()}function Ee(e){return m.setTableProperties(e)}function Me(e){return m.applyTableStyle(e)}function Re(e){return m.setCellFillColor(e)}function Ne(e){return m.setTableBorderColor(e)}function Be(e){return m.setTableBorderWidth(e)}var Fe=a.getCommands();function O(e,t,n,r){if(!t)return true;let s=e.tr.insert(r,n),a=i(e),o=e.schema.marks.insertion;return a&&o&&s.addMark(r,r+n.nodeSize,o.create({revisionId:a.revisionId,author:a.author,date:a.date})),t(s.scrollIntoView()),true}var V=612;function We(e,t,n){let r=n?.maxWidth??V,s=new FileReader;s.onload=()=>{let a=s.result,o=new Image;o.onload=()=>{let i=o.naturalWidth,c=o.naturalHeight;i>r&&(c=Math.round(c*(r/i)),i=r);let l=e.state.schema.nodes.image.create({src:a,alt:t.name,width:i,height:c,rId:`rId_img_${Date.now()}_${Math.round(Math.random()*1e9)}`,wrapType:"inline",displayMode:"inline"});O(e.state,e.dispatch,l,e.state.selection.from),e.focus(),n?.onInserted?.();},o.onerror=()=>n?.onError?.(new Error("Failed to decode image")),o.src=a;},s.onerror=()=>n?.onError?.(s.error),s.readAsDataURL(t);}function De(e,t,n){return Fe.setImageWrapType(e,t,n)}function Le(e){return (t,n)=>{let{from:r,to:s,empty:a}=t.selection;if(a)return false;let o=t.schema.marks.comment;if(!o)return false;if(n){let i=t.tr.addMark(r,s,o.create({commentId:e}));n(i);}return true}}function ze(e){return (t,n)=>{let r=t.schema.marks.comment;if(!r)return false;if(n){let s=t.tr;t.doc.descendants((a,o)=>{if(a.isText)for(let i of a.marks)i.type===r&&i.attrs.commentId===e&&s.removeMark(o,o+a.nodeSize,i);}),s.steps.length>0&&n(s);}return true}}function $(e,t,n){return (r,s)=>{let a=r.schema.marks.insertion,o=r.schema.marks.deletion;if(!a&&!o)return false;let i=n==="accept"?a:o,c=n==="accept"?o:a;if(s){let l=r.tr,b=[];r.doc.nodesBetween(e,t,(h,y)=>{if(!h.isInline)return;let S=y+h.nodeSize,x=Math.max(e,y),w=Math.min(t,S);c&&h.marks.some(k=>k.type===c)&&b.push({from:x,to:w}),i&&h.marks.some(k=>k.type===i)&&l.removeMark(x,w,i);});for(let h of b.reverse())l.delete(h.from,h.to);l.steps.length>0&&s(l);}return true}}function He(e,t){return $(e,t,"accept")}function je(e,t){return $(e,t,"reject")}function U(e){let t=new Set,n=[],r=o=>{typeof o=="number"&&!t.has(o)&&(t.add(o),n.push(o));},s=e.schema.marks.insertion,a=e.schema.marks.deletion;return e.doc.descendants(o=>{if(o.type.name==="paragraph"){r(o.attrs.pPrIns?.revisionId),r(o.attrs.pPrDel?.revisionId);let i=o.attrs.pPrChange;if(Array.isArray(i))for(let c of i)r(c.info.id);}if(o.type.name==="tableRow"){r(o.attrs.trIns?.revisionId),r(o.attrs.trDel?.revisionId);let i=o.attrs.trPrChange;if(Array.isArray(i))for(let c of i)r(c.info.id);}if(o.type.name==="tableCell"||o.type.name==="tableHeader"){let i=o.attrs.cellMarker;r(i?.info?.revisionId);let c=o.attrs.tcPrChange;if(Array.isArray(c))for(let l of c)r(l.info.id);}if(o.type.name==="table"){let i=o.attrs.tblPrChange;if(Array.isArray(i))for(let c of i)r(c.info.id);}if(o.isInline)for(let i of o.marks)(s&&i.type===s||a&&i.type===a)&&r(i.attrs.revisionId);}),n}function _e(){return (e,t)=>{let n=U(e);if(n.length===0)return false;if(!t)return true;let r=e,s=a=>{t(a),r=r.apply(a);};for(let a of n)M(a,"accept")(r,s);return true}}function Oe(){return (e,t)=>{let n=U(e);if(n.length===0)return false;if(!t)return true;let r=e,s=a=>{t(a),r=r.apply(a);};for(let a of n)M(a,"reject")(r,s);return true}}function G(e,t){let n=e.schema.marks.insertion,r=e.schema.marks.deletion;if(!n&&!r)return null;let s=null;return e.doc.descendants((a,o)=>{if(s)return false;if(a.isInline&&!(o+a.nodeSize<=t)){for(let i of a.marks)if(i.type===n||i.type===r)return s={from:Math.max(o,t),to:o+a.nodeSize,type:i.type===n?"insertion":"deletion"},false}}),!s&&t>0?G(e,0):s}function Ve(e,t){let n=[];return e.doc.descendants((r,s)=>{if(r.type.name!=="paragraph")return;let a=r.attrs.pPrIns,o=r.attrs.pPrDel;a&&a.revisionId===t&&n.push({pos:s,node:r,kind:"pPrIns"}),o&&o.revisionId===t&&n.push({pos:s,node:r,kind:"pPrDel"});}),n}function $e(e,t){let n=[];return e.doc.descendants((r,s)=>{if(r.type.name!=="paragraph")return;let a=r.attrs.pPrChange;Array.isArray(a)&&a.forEach((o,i)=>{!o?.info||typeof o.info.id!="number"||o.info.id===t&&n.push({pos:s,node:r,entryIndex:i,prior:o.previousFormatting,current:o.currentFormatting});});}),n}function Ue(e,t){let n=[],r=e.schema.marks.insertion,s=e.schema.marks.deletion;return e.doc.descendants((a,o)=>{if(a.isInline){for(let i of a.marks)if((r&&i.type===r||s&&i.type===s)&&i.attrs.revisionId===t){let c=i.type===r?"insertion":"deletion",l=n[n.length-1];l&&l.markName===c&&l.to===o?l.to=o+a.nodeSize:n.push({from:o,to:o+a.nodeSize,markName:c});}}}),n}function Ge(e,t,n){let r=e.doc.nodeAt(t);if(!r)return;let s=t+r.nodeSize,a=e.doc.nodeAt(s);!a||a.type.name!=="paragraph"||(e.setNodeMarkup(t,void 0,{...a.attrs,pPrIns:null,pPrDel:null}),e.join(s));}function N(e,t,n){let r=e.doc.nodeAt(t);if(!r)return;let s={...r.attrs};s[n]=null,e.setNodeMarkup(t,void 0,s);}function Xe(e,t,n){let r=e.doc.nodeAt(t);if(!r)return;let s=r.attrs.pPrChange;if(!Array.isArray(s)||n<0||n>=s.length)return;let a=s.slice();a.splice(n,1),e.setNodeMarkup(t,void 0,{...r.attrs,pPrChange:a.length>0?a:null});}function Je(e,t,n){let r={...e},s=["alignment","spaceBefore","spaceAfter","lineSpacing","lineSpacingRule","beforeAutospacing","afterAutospacing","spacingExplicit","indentLeft","indentRight","indentFirstLine","hangingIndent","styleId","borders","shading","tabs","pageBreakBefore","keepNext","keepLines","contextualSpacing","bidi","outlineLevel","numPr"];for(let a of s)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=t[a]??null);return n?.numPr&&!Object.prototype.hasOwnProperty.call(t,"numPr")&&(r.numPr=null),r.numPr==null&&(r.listIsBullet=null,r.listNumFmt=null,r.listMarker=null),r}function Ke(e,t){let n=[];return e.doc.descendants((r,s)=>{if(r.type.name!=="tableRow")return;let a=r.attrs.trIns,o=r.attrs.trDel;a&&a.revisionId===t&&n.push({pos:s,node:r,kind:"trIns"}),o&&o.revisionId===t&&n.push({pos:s,node:r,kind:"trDel"});}),n}function Ye(e,t){let n=[];return e.doc.descendants((r,s)=>{if(r.type.name!=="tableCell"&&r.type.name!=="tableHeader")return;let a=r.attrs.cellMarker;a?.info?.revisionId===t&&n.push({pos:s,node:r,cellKind:a.kind});}),n}function M(e,t){return (n,r)=>{let s=Ve(n,e),a=Ue(n,e),o=$e(n,e),i=Ke(n,e),c=Ye(n,e);if(s.length===0&&a.length===0&&o.length===0&&i.length===0&&c.length===0)return false;if(!r)return true;let l=n.tr;l.setMeta(g,true);let b=n.schema.marks.insertion,h=n.schema.marks.deletion,y=[...a].sort((u,d)=>d.from-u.from);for(let u of y){let d=u.markName==="insertion";if(t==="accept"&&!d||t==="reject"&&d)l.delete(u.from,u.to);else {let C=d?b:h;C&&l.removeMark(u.from,u.to,C);}}let S=[...s].sort((u,d)=>d.pos-u.pos);for(let u of S){let d=l.mapping.map(u.pos),f=l.doc.nodeAt(d);if(!f||f.type.name!=="paragraph")continue;let C=u.kind==="pPrIns"&&f.attrs.pPrIns?.revisionId===e,p=u.kind==="pPrDel"&&f.attrs.pPrDel?.revisionId===e;if(!C&&!p)continue;if(t==="reject"&&u.kind==="pPrIns"||t==="accept"&&u.kind==="pPrDel"){let T=d+f.nodeSize,R=l.doc.nodeAt(T);!R||R.type.name!=="paragraph"?N(l,d,u.kind):(N(l,d,u.kind),Ge(l,d));}else N(l,d,u.kind);}let x=[...o].sort((u,d)=>d.pos-u.pos);for(let u of x){let d=l.mapping.map(u.pos),f=l.doc.nodeAt(d);if(!f||f.type.name!=="paragraph")continue;let C=f.attrs.pPrChange;if(!Array.isArray(C))continue;let p=C.findIndex(g=>g.info.id===e);if(!(p<0))if(t==="reject"&&u.prior){let g=Je(f.attrs,u.prior,u.current),T=C.slice();T.splice(p,1),l.setNodeMarkup(d,void 0,{...g,pPrChange:T.length>0?T:null});}else Xe(l,d,p);}let w=[...c].sort((u,d)=>d.pos-u.pos);for(let u of w){let d=l.mapping.map(u.pos),f=l.doc.nodeAt(d);if(!f||f.type.name!=="tableCell"&&f.type.name!=="tableHeader")continue;let C=f.attrs.cellMarker;!C||C.info.revisionId!==e||l.setNodeMarkup(d,void 0,{...f.attrs,cellMarker:null});}let k=[...i].sort((u,d)=>d.pos-u.pos);for(let u of k){let d=l.mapping.map(u.pos),f=l.doc.nodeAt(d);if(!f||f.type.name!=="tableRow")continue;let C=f.attrs.trIns,p=f.attrs.trDel,g=C?.revisionId===e,T=p?.revisionId===e;if(!g&&!T)continue;if(t==="reject"&&g||t==="accept"&&T){let v=l.doc.resolve(d+1),I=v.node(v.depth-1),P=v.before(v.depth-1);if(I?.type.name==="table"&&I.childCount>1)l.delete(d,d+f.nodeSize);else if(I?.type.name==="table")if(l.doc.resolve(P).parent.childCount===1){let J=l.doc.type.schema.nodes.paragraph;l.replaceWith(P,P+I.nodeSize,J.create());}else l.delete(P,P+I.nodeSize);else {let A={...f.attrs};g&&(A.trIns=null),T&&(A.trDel=null),l.setNodeMarkup(d,void 0,A);}}else {let v={...f.attrs};g&&(v.trIns=null),T&&(v.trDel=null),l.setNodeMarkup(d,void 0,v);}}return l.steps.length===0?false:(r(l),true)}}function qe(e){return M(e,"accept")}function Qe(e){return M(e,"reject")}function X(e,t){let n=e.schema.marks.insertion,r=e.schema.marks.deletion;if(!n&&!r)return null;let s=null;return e.doc.descendants((a,o)=>{if(a.isInline){if(o>=t)return false;for(let i of a.marks)(i.type===n||i.type===r)&&(s={from:o,to:o+a.nodeSize,type:i.type===n?"insertion":"deletion"});}}),!s&&t<e.doc.content.size?X(e,e.doc.content.size):s}function Ze(e){return e.doc.attrs.watermark??null}function et(e){return (t,n)=>(n&&n(t.tr.setDocAttribute("watermark",e)),true)}export{Ie as A,Pe as B,Ae as C,Ee as D,Me as E,Re as F,Ne as G,Be as H,O as I,V as J,We as K,De as L,Le as M,ze as N,He as O,je as P,_e as Q,Oe as R,G as S,qe as T,Qe as U,X as V,Ze as W,et as X,Q as a,Z as b,re as c,ne as d,oe as e,ae as f,ie as g,se as h,le as i,ce as j,de as k,ue as l,pe as m,me as n,fe as o,ge as p,be as q,he as r,ye as s,Ce as t,Te as u,Se as v,ke as w,ve as x,xe as y,we as z};
|
|
1
|
+
import {e,b,c,a as a$1}from'./chunk-KQTB5Y7P.mjs';import {a}from'./chunk-LMGFGJTJ.mjs';import {i,g}from'./chunk-MJ6XZFVD.mjs';import {TextSelection}from'prosemirror-state';function _(e){let{$from:t}=e.selection,n=null,r=null,s=null,a=-1,o=-1;for(let i=t.depth;i>0;i--){let c=t.node(i);if(c.type.name==="tableCell"||c.type.name==="tableHeader"){s=c;let l=t.node(i-1);if(l?.type.name==="tableRow"){let b=0;l.forEach((h,y,S)=>{if(o===-1){if(S===t.index(i-1)){o=b;return}b+=h.attrs.colspan||1;}});}}else if(c.type.name==="tableRow")t.node(i-1)?.type.name==="table"&&(a=t.index(i-1));else if(c.type.name==="table"){n=c,r=t.before(i);break}}return !n||r==null||!s||a<0||o<0?null:{table:n,tablePos:r,cell:s,row:a,col:o,rowspan:s.attrs.rowspan||1,colspan:s.attrs.colspan||1}}function H(e){let t=[],n=[],r=0;for(let s=0;s<e.childCount;s++){let a=e.child(s),o=0;a.forEach(i=>{for(;t[s]?.[o];)o++;let c=i.attrs.rowspan||1,l=i.attrs.colspan||1;n.push({data:i,row:s,col:o,rowspan:c,colspan:l});for(let b=s;b<s+c;b++){let h=t[b]??[];t[b]=h;for(let y=o;y<o+l;y++)h[y]=true;}o+=l,r=Math.max(r,o);});}return {anchors:n,totalCols:r}}function j(e,t,n,r,s){let a={...e.attrs},o=s.reduce((l,b)=>l+b,0),i=a$1(s,t,n),c=n!==(e.attrs.colspan||1)||r!==(e.attrs.rowspan||1);return a.colspan=n,a.rowspan=r,a.colwidth=null,o>0&&(a.width=Math.round(i/o*5e3),a.widthType="pct"),c&&(a._originalFormatting=null),a}function Y(e,t,n,r){let s=t+1;for(let a=0;a<e.childCount;a++){let o=e.child(a),i=s+1,c=0;for(let l=0;l<o.childCount;l++){let b=o.child(l);if(a===n&&c===r)return i;c+=b.attrs.colspan||1,i+=b.nodeSize;}s+=o.nodeSize;}return null}function q(e,t){let n=e.attrs.width??9360;return Array.isArray(e.attrs.columnWidths)&&e.attrs.columnWidths.length>0?[...e.attrs.columnWidths]:Array.from({length:t},()=>Math.floor(n/Math.max(t,1)))}function Q(e$1){let t=_(e$1);return t?{...e(t.rowspan,t.colspan),capturedCellRow:t.row,capturedCellCol:t.col}:null}function Z(e,t,n,r,s,a){if(n<1||r<1)return false;let o=_(e);if(!o||!t)return false;let i=o;if(s!=null&&a!=null&&(s!==o.row||a!==o.col)){let{anchors:p}=H(o.table),g=p.find(T=>T.row===s&&T.col===a);if(!g)return false;i={...o,cell:g.data,row:g.row,col:g.col,rowspan:g.rowspan,colspan:g.colspan};}if(n<i.rowspan||r<i.colspan||n===1&&r===1)return false;let{anchors:c$1,totalCols:l}=H(i.table),b$1=q(i.table,l),h=b(b$1,i.col,i.colspan,r),y=c$1.find(p=>p.row===i.row&&p.col===i.col);if(!y)return false;let S=c(c$1,y,n,r,i.table.childCount,p=>{if(p)return y.data;let g=y.data.type.schema.nodes.paragraph.create(),T=j(y.data,0,1,1,h);return y.data.type.create(T,g)}),x=i.row+i.rowspan,w=Array.from({length:S.newRowCount},(p,g)=>g<x?{...i.table.child(g)?.attrs??{}}:g<i.row+n?{...i.table.child(x-1)?.attrs??{}}:{...i.table.child(g-S.deltaRows)?.attrs??{}}),k=Array.from({length:S.newRowCount},()=>[]);S.anchors.sort((p,g)=>p.row===g.row?p.col-g.col:p.row-g.row).forEach(p=>{let g=j(p.data,p.col,p.colspan,p.rowspan,h);k[p.row].push(p.data.type.create(g,p.data.content));});let u=k.map((p,g)=>i.table.type.schema.nodes.tableRow.create(w[g],p)),d=i.table.type.create({...i.table.attrs,columnWidths:h},u),f=e.tr.replaceWith(i.tablePos,i.tablePos+i.table.nodeSize,d),C=f.doc.nodeAt(i.tablePos);if(C){let p=Y(C,i.tablePos,i.row,i.col);p!=null&&(f=f.setSelection(TextSelection.near(f.doc.resolve(p+1))));}return t(f.scrollIntoView()),true}var m=a.getCommands();function re(e,t){return m.insertTable(e,t)}function ne(e,t){return m.addRowAbove()(e,t)}function oe(e,t){return m.addRowBelow()(e,t)}function ae(e,t){return m.deleteRow()(e,t)}function ie(e,t){return m.addColumnLeft()(e,t)}function se(e,t){return m.addColumnRight()(e,t)}function le(e,t){return m.deleteColumn()(e,t)}function ce(e,t){return m.deleteTable()(e,t)}function de(e,t){return m.selectTable()(e,t)}function ue(e,t){return m.selectRow()(e,t)}function pe(e,t){return m.selectColumn()(e,t)}function me(e,t){return m.mergeCells()(e,t)}function fe(e,t){return m.splitCell()(e,t)}function ge(e,t,n){return m.setCellBorder(e,t,n)}function be(e,t){return m.setTableBorders(e,t)}function he(e,t){return m.removeTableBorders()(e,t)}function ye(e,t,n){return m.setAllTableBorders(n)(e,t)}function Ce(e,t,n){return m.setOutsideTableBorders(n)(e,t)}function Te(e,t,n){return m.setInsideTableBorders(n)(e,t)}function Se(e){return m.setCellVerticalAlign(e)}function ke(e){return m.setCellMargins(e)}function ve(e){return m.setCellTextDirection(e)}function xe(){return m.toggleNoWrap()}function we(e,t){return m.setRowHeight(e,t)}function Ie(){return m.toggleHeaderRow()}function Pe(){return m.distributeColumns()}function Ae(){return m.autoFitContents()}function Ee(e){return m.setTableProperties(e)}function Me(e){return m.applyTableStyle(e)}function Re(e){return m.setCellFillColor(e)}function Ne(e){return m.setTableBorderColor(e)}function Be(e){return m.setTableBorderWidth(e)}var Fe=a.getCommands();function O(e,t,n,r){if(!t)return true;let s=e.tr.insert(r,n),a=i(e),o=e.schema.marks.insertion;return a&&o&&s.addMark(r,r+n.nodeSize,o.create({revisionId:a.revisionId,author:a.author,date:a.date})),t(s.scrollIntoView()),true}var V=612;function We(e,t,n){let r=n?.maxWidth??V,s=new FileReader;s.onload=()=>{let a=s.result,o=new Image;o.onload=()=>{let i=o.naturalWidth,c=o.naturalHeight;i>r&&(c=Math.round(c*(r/i)),i=r);let l=e.state.schema.nodes.image.create({src:a,alt:t.name,width:i,height:c,rId:`rId_img_${Date.now()}_${Math.round(Math.random()*1e9)}`,wrapType:"inline",displayMode:"inline"});O(e.state,e.dispatch,l,e.state.selection.from),e.focus(),n?.onInserted?.();},o.onerror=()=>n?.onError?.(new Error("Failed to decode image")),o.src=a;},s.onerror=()=>n?.onError?.(s.error),s.readAsDataURL(t);}function De(e,t,n){return Fe.setImageWrapType(e,t,n)}function Le(e){return (t,n)=>{let{from:r,to:s,empty:a}=t.selection;if(a)return false;let o=t.schema.marks.comment;if(!o)return false;if(n){let i=t.tr.addMark(r,s,o.create({commentId:e}));n(i);}return true}}function ze(e){return (t,n)=>{let r=t.schema.marks.comment;if(!r)return false;if(n){let s=t.tr;t.doc.descendants((a,o)=>{if(a.isText)for(let i of a.marks)i.type===r&&i.attrs.commentId===e&&s.removeMark(o,o+a.nodeSize,i);}),s.steps.length>0&&n(s);}return true}}function $(e,t,n){return (r,s)=>{let a=r.schema.marks.insertion,o=r.schema.marks.deletion;if(!a&&!o)return false;let i=n==="accept"?a:o,c=n==="accept"?o:a;if(s){let l=r.tr,b=[];r.doc.nodesBetween(e,t,(h,y)=>{if(!h.isInline)return;let S=y+h.nodeSize,x=Math.max(e,y),w=Math.min(t,S);c&&h.marks.some(k=>k.type===c)&&b.push({from:x,to:w}),i&&h.marks.some(k=>k.type===i)&&l.removeMark(x,w,i);});for(let h of b.reverse())l.delete(h.from,h.to);l.steps.length>0&&s(l);}return true}}function He(e,t){return $(e,t,"accept")}function je(e,t){return $(e,t,"reject")}function U(e){let t=new Set,n=[],r=o=>{typeof o=="number"&&!t.has(o)&&(t.add(o),n.push(o));},s=e.schema.marks.insertion,a=e.schema.marks.deletion;return e.doc.descendants(o=>{if(o.type.name==="paragraph"){r(o.attrs.pPrIns?.revisionId),r(o.attrs.pPrDel?.revisionId);let i=o.attrs.pPrChange;if(Array.isArray(i))for(let c of i)r(c.info.id);}if(o.type.name==="tableRow"){r(o.attrs.trIns?.revisionId),r(o.attrs.trDel?.revisionId);let i=o.attrs.trPrChange;if(Array.isArray(i))for(let c of i)r(c.info.id);}if(o.type.name==="tableCell"||o.type.name==="tableHeader"){let i=o.attrs.cellMarker;r(i?.info?.revisionId);let c=o.attrs.tcPrChange;if(Array.isArray(c))for(let l of c)r(l.info.id);}if(o.type.name==="table"){let i=o.attrs.tblPrChange;if(Array.isArray(i))for(let c of i)r(c.info.id);}if(o.isInline)for(let i of o.marks)(s&&i.type===s||a&&i.type===a)&&r(i.attrs.revisionId);}),n}function _e(){return (e,t)=>{let n=U(e);if(n.length===0)return false;if(!t)return true;let r=e,s=a=>{t(a),r=r.apply(a);};for(let a of n)M(a,"accept")(r,s);return true}}function Oe(){return (e,t)=>{let n=U(e);if(n.length===0)return false;if(!t)return true;let r=e,s=a=>{t(a),r=r.apply(a);};for(let a of n)M(a,"reject")(r,s);return true}}function G(e,t){let n=e.schema.marks.insertion,r=e.schema.marks.deletion;if(!n&&!r)return null;let s=null;return e.doc.descendants((a,o)=>{if(s)return false;if(a.isInline&&!(o+a.nodeSize<=t)){for(let i of a.marks)if(i.type===n||i.type===r)return s={from:Math.max(o,t),to:o+a.nodeSize,type:i.type===n?"insertion":"deletion"},false}}),!s&&t>0?G(e,0):s}function Ve(e,t){let n=[];return e.doc.descendants((r,s)=>{if(r.type.name!=="paragraph")return;let a=r.attrs.pPrIns,o=r.attrs.pPrDel;a&&a.revisionId===t&&n.push({pos:s,node:r,kind:"pPrIns"}),o&&o.revisionId===t&&n.push({pos:s,node:r,kind:"pPrDel"});}),n}function $e(e,t){let n=[];return e.doc.descendants((r,s)=>{if(r.type.name!=="paragraph")return;let a=r.attrs.pPrChange;Array.isArray(a)&&a.forEach((o,i)=>{!o?.info||typeof o.info.id!="number"||o.info.id===t&&n.push({pos:s,node:r,entryIndex:i,prior:o.previousFormatting,current:o.currentFormatting});});}),n}function Ue(e,t){let n=[],r=e.schema.marks.insertion,s=e.schema.marks.deletion;return e.doc.descendants((a,o)=>{if(a.isInline){for(let i of a.marks)if((r&&i.type===r||s&&i.type===s)&&i.attrs.revisionId===t){let c=i.type===r?"insertion":"deletion",l=n[n.length-1];l&&l.markName===c&&l.to===o?l.to=o+a.nodeSize:n.push({from:o,to:o+a.nodeSize,markName:c});}}}),n}function Ge(e,t,n){let r=e.doc.nodeAt(t);if(!r)return;let s=t+r.nodeSize,a=e.doc.nodeAt(s);!a||a.type.name!=="paragraph"||(e.setNodeMarkup(t,void 0,{...a.attrs,pPrIns:null,pPrDel:null}),e.join(s));}function N(e,t,n){let r=e.doc.nodeAt(t);if(!r)return;let s={...r.attrs};s[n]=null,e.setNodeMarkup(t,void 0,s);}function Xe(e,t,n){let r=e.doc.nodeAt(t);if(!r)return;let s=r.attrs.pPrChange;if(!Array.isArray(s)||n<0||n>=s.length)return;let a=s.slice();a.splice(n,1),e.setNodeMarkup(t,void 0,{...r.attrs,pPrChange:a.length>0?a:null});}function Je(e,t,n){let r={...e},s=["alignment","spaceBefore","spaceAfter","lineSpacing","lineSpacingRule","beforeAutospacing","afterAutospacing","spacingExplicit","indentLeft","indentRight","indentFirstLine","hangingIndent","styleId","borders","shading","tabs","pageBreakBefore","keepNext","keepLines","contextualSpacing","bidi","outlineLevel","numPr"];for(let a of s)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=t[a]??null);return n?.numPr&&!Object.prototype.hasOwnProperty.call(t,"numPr")&&(r.numPr=null),r.numPr==null&&(r.listIsBullet=null,r.listNumFmt=null,r.listMarker=null),r}function Ke(e,t){let n=[];return e.doc.descendants((r,s)=>{if(r.type.name!=="tableRow")return;let a=r.attrs.trIns,o=r.attrs.trDel;a&&a.revisionId===t&&n.push({pos:s,node:r,kind:"trIns"}),o&&o.revisionId===t&&n.push({pos:s,node:r,kind:"trDel"});}),n}function Ye(e,t){let n=[];return e.doc.descendants((r,s)=>{if(r.type.name!=="tableCell"&&r.type.name!=="tableHeader")return;let a=r.attrs.cellMarker;a?.info?.revisionId===t&&n.push({pos:s,node:r,cellKind:a.kind});}),n}function M(e,t){return (n,r)=>{let s=Ve(n,e),a=Ue(n,e),o=$e(n,e),i=Ke(n,e),c=Ye(n,e);if(s.length===0&&a.length===0&&o.length===0&&i.length===0&&c.length===0)return false;if(!r)return true;let l=n.tr;l.setMeta(g,true);let b=n.schema.marks.insertion,h=n.schema.marks.deletion,y=[...a].sort((u,d)=>d.from-u.from);for(let u of y){let d=u.markName==="insertion";if(t==="accept"&&!d||t==="reject"&&d)l.delete(u.from,u.to);else {let C=d?b:h;C&&l.removeMark(u.from,u.to,C);}}let S=[...s].sort((u,d)=>d.pos-u.pos);for(let u of S){let d=l.mapping.map(u.pos),f=l.doc.nodeAt(d);if(!f||f.type.name!=="paragraph")continue;let C=u.kind==="pPrIns"&&f.attrs.pPrIns?.revisionId===e,p=u.kind==="pPrDel"&&f.attrs.pPrDel?.revisionId===e;if(!C&&!p)continue;if(t==="reject"&&u.kind==="pPrIns"||t==="accept"&&u.kind==="pPrDel"){let T=d+f.nodeSize,R=l.doc.nodeAt(T);!R||R.type.name!=="paragraph"?N(l,d,u.kind):(N(l,d,u.kind),Ge(l,d));}else N(l,d,u.kind);}let x=[...o].sort((u,d)=>d.pos-u.pos);for(let u of x){let d=l.mapping.map(u.pos),f=l.doc.nodeAt(d);if(!f||f.type.name!=="paragraph")continue;let C=f.attrs.pPrChange;if(!Array.isArray(C))continue;let p=C.findIndex(g=>g.info.id===e);if(!(p<0))if(t==="reject"&&u.prior){let g=Je(f.attrs,u.prior,u.current),T=C.slice();T.splice(p,1),l.setNodeMarkup(d,void 0,{...g,pPrChange:T.length>0?T:null});}else Xe(l,d,p);}let w=[...c].sort((u,d)=>d.pos-u.pos);for(let u of w){let d=l.mapping.map(u.pos),f=l.doc.nodeAt(d);if(!f||f.type.name!=="tableCell"&&f.type.name!=="tableHeader")continue;let C=f.attrs.cellMarker;!C||C.info.revisionId!==e||l.setNodeMarkup(d,void 0,{...f.attrs,cellMarker:null});}let k=[...i].sort((u,d)=>d.pos-u.pos);for(let u of k){let d=l.mapping.map(u.pos),f=l.doc.nodeAt(d);if(!f||f.type.name!=="tableRow")continue;let C=f.attrs.trIns,p=f.attrs.trDel,g=C?.revisionId===e,T=p?.revisionId===e;if(!g&&!T)continue;if(t==="reject"&&g||t==="accept"&&T){let v=l.doc.resolve(d+1),I=v.node(v.depth-1),P=v.before(v.depth-1);if(I?.type.name==="table"&&I.childCount>1)l.delete(d,d+f.nodeSize);else if(I?.type.name==="table")if(l.doc.resolve(P).parent.childCount===1){let J=l.doc.type.schema.nodes.paragraph;l.replaceWith(P,P+I.nodeSize,J.create());}else l.delete(P,P+I.nodeSize);else {let A={...f.attrs};g&&(A.trIns=null),T&&(A.trDel=null),l.setNodeMarkup(d,void 0,A);}}else {let v={...f.attrs};g&&(v.trIns=null),T&&(v.trDel=null),l.setNodeMarkup(d,void 0,v);}}return l.steps.length===0?false:(r(l),true)}}function qe(e){return M(e,"accept")}function Qe(e){return M(e,"reject")}function X(e,t){let n=e.schema.marks.insertion,r=e.schema.marks.deletion;if(!n&&!r)return null;let s=null;return e.doc.descendants((a,o)=>{if(a.isInline){if(o>=t)return false;for(let i of a.marks)(i.type===n||i.type===r)&&(s={from:o,to:o+a.nodeSize,type:i.type===n?"insertion":"deletion"});}}),!s&&t<e.doc.content.size?X(e,e.doc.content.size):s}function Ze(e){return e.doc.attrs.watermark??null}function et(e){return (t,n)=>(n&&n(t.tr.setDocAttribute("watermark",e)),true)}export{Ie as A,Pe as B,Ae as C,Ee as D,Me as E,Re as F,Ne as G,Be as H,O as I,V as J,We as K,De as L,Le as M,ze as N,He as O,je as P,_e as Q,Oe as R,G as S,qe as T,Qe as U,X as V,Ze as W,et as X,Q as a,Z as b,re as c,ne as d,oe as e,ae as f,ie as g,se as h,le as i,ce as j,de as k,ue as l,pe as m,me as n,fe as o,ge as p,be as q,he as r,ye as s,Ce as t,Te as u,Se as v,ke as w,ve as x,xe as y,we as z};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunk2EFI3BAN_js=require('./chunk-2EFI3BAN.js'),chunk4EATD3FP_js=require('./chunk-4EATD3FP.js'),chunkZ3LGMBJC_js=require('./chunk-Z3LGMBJC.js');function Z(e,s){let r=G(s),t=new RegExp(`<w:p[\\s][^>]*w14:paraId="${r}"`,"g"),o=[],i;for(;(i=t.exec(e))!==null;)o.push(i.index);if(o.length===0||o.length>1)return null;let l=o[0],n=l,a=0;for(;n<e.length;){let m=e.indexOf("<",n);if(m===-1)break;if(e.startsWith("<w:p",m)){let y=e[m+4];if(y===">"||y===" "||y==="/"){let f=e.indexOf(">",m);if(f===-1)break;if(e[f-1]==="/"){if(a===0)return {start:l,end:f+1};n=f+1;}else a++,n=f+1;}else n=m+1;}else if(e.startsWith("</w:p>",m)){if(a--,a===0)return {start:l,end:m+6};n=m+6;}else n=m+1;}return null}function j(e,s){let r=Z(e,s);return r?e.substring(r.start,r.end):null}function H(e){let s=0,r=/<w:p[\s>]/g,t;for(;(t=r.exec(e))!==null;){let o=t.index,i=e[o+4];(i===">"||i===" ")&&s++;}return s}function W(e){let s=new Map,r=/w14:paraId="([^"]+)"/g,t;for(;(t=r.exec(e))!==null;){let o=t[1];s.set(o,(s.get(o)||0)+1);}return s}function q(e,s,r){if(r.size===0)return {safe:true};let t=W(e),o=W(s);for(let n of r){let a=t.get(n)||0;if(a===0)return {safe:false,reason:`paraId-not-found-in-original: ${n}`};if(a>1)return {safe:false,reason:`duplicate-paraId-in-original: ${n}`}}for(let n of r){let a=o.get(n)||0;if(a===0)return {safe:false,reason:`paraId-not-found-in-serialized: ${n}`};if(a>1)return {safe:false,reason:`duplicate-paraId-in-serialized: ${n}`}}let i=H(e),l=H(s);return i!==l?{safe:false,reason:`paragraph-count-mismatch: original=${i}, serialized=${l}`}:{safe:true}}function J(e,s,r){if(r.size===0)return e;if(!q(e,s,r).safe)return null;let o=[];for(let l of r){let n=Z(e,l);if(!n)return null;let a=j(s,l);if(!a)return null;o.push({start:n.start,end:n.end,newXml:a});}o.sort((l,n)=>n.start-l.start);let i=e;for(let{start:l,end:n,newXml:a}of o)i=i.substring(0,l)+a+i.substring(n);return i}function G(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function L(e){let s=r=>r.content.some(t=>t.type==="drawing"&&t.image?.src?.startsWith("data:")&&!t.image?.rId);for(let r of e)if(r.type==="paragraph")for(let t of r.content)if(t.type==="run"){if(s(t))return true}else {if(t.type==="hyperlink"&&t.href&&!t.rId&&!t.anchor)return true;if(t.type==="insertion"||t.type==="deletion"||t.type==="moveFrom"||t.type==="moveTo"){for(let o of t.content)if(o.type==="run"&&s(o))return true}}else if(r.type==="table"){for(let t of r.rows)for(let o of t.cells)if(L(o.content))return true}return false}async function oe(e,s,r){let{changedParaIds:t,structuralChange:o,hasUntrackedChanges:i}=r;if(o||i||!s)return null;let l=e.package.document.content;if(L(l))return null;let n=e.package.document.comments,a=n&&n.length>0,m=chunk2EFI3BAN_js.g(e);try{let f=await(await import('jszip')).default.loadAsync(s),u=new Map,I=e.package.relationships;if(I)for(let c of I.values()){if(!c.target||c.type!==chunkZ3LGMBJC_js.a.header&&c.type!==chunkZ3LGMBJC_js.a.footer)continue;let d=chunk2EFI3BAN_js.a(c.target).replace(/^\//,"");if(!f.file(d))return null}if(t.size>0){let c=f.file("word/document.xml");if(!c)return null;let d=await c.async("text"),w=chunk4EATD3FP_js.h(e),x=J(d,w,t);if(!x)return null;u.set("word/document.xml",x);}if(a){let{xml:c,paraInfos:d}=chunk4EATD3FP_js.j(n);u.set("word/comments.xml",c);let w=chunk4EATD3FP_js.l(d);w&&u.set("word/commentsExtended.xml",w);let x=chunk4EATD3FP_js.m(d);x&&u.set("word/commentsIds.xml",x);let S=chunk4EATD3FP_js.n(d,n);S&&u.set("word/commentsExtensible.xml",S);let N=f.file("[Content_Types].xml");if(N){let p=u.get("[Content_Types].xml")??await N.async("text"),h=!1,C=[["/word/comments.xml",chunk2EFI3BAN_js.c],["/word/commentsExtended.xml",chunk2EFI3BAN_js.d],["/word/commentsIds.xml",chunk2EFI3BAN_js.e],["/word/commentsExtensible.xml",chunk2EFI3BAN_js.f]];for(let[E,b]of C)p.includes(E)||(p=p.replace("</Types>",`<Override PartName="${E}" ContentType="${b}"/></Types>`),h=!0);h&&u.set("[Content_Types].xml",p);}let T="word/_rels/document.xml.rels",O=f.file(T);if(O){let p=u.get(T)??await O.async("text"),h=!1,C=[["comments.xml",chunkZ3LGMBJC_js.a.comments],["commentsExtended.xml",chunkZ3LGMBJC_js.a.commentsExtended],["commentsIds.xml",chunkZ3LGMBJC_js.a.commentsIds],["commentsExtensible.xml",chunkZ3LGMBJC_js.a.commentsExtensible]];for(let[E,b]of C)if(!p.includes(E)){let V=chunk2EFI3BAN_js.b(p);p=p.replace("</Relationships>",`<Relationship Id="rId${V+1}" Type="${b}" Target="${E}"/></Relationships>`),h=!0;}h&&u.set(T,p);}}for(let[c,d]of m)u.set(c,d);let P=f.file("docProps/core.xml");if(P){let c=await P.async("text");u.set("docProps/core.xml",chunk2EFI3BAN_js.q(c,{updateModifiedDate:!0}));}return await chunk2EFI3BAN_js.n(f,u)}catch{return null}}
|
|
2
2
|
exports.a=q;exports.b=J;exports.c=oe;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a,r,s,t,u as u$1,A,z,q as q$2,B,D,O as O$1,N,C,b as b$3}from'./chunk-3QQLHMB6.mjs';import {b as b$1}from'./chunk-MOCGHQ4A.mjs';import {u,q as q$1}from'./chunk-CDBKFBC2.mjs';import {b,a as a$2}from'./chunk-W77JXDEV.mjs';import {a as a$4,b as b$4}from'./chunk-4VLKSJRK.mjs';import {b as b$2}from'./chunk-DI6CRWSW.mjs';import {a as a$1}from'./chunk-VJFIAFZ5.mjs';import {c,f,e,l,j as j$1,a as a$3,i,m}from'./chunk-3ANZ3252.mjs';import We from'jszip';async function K(t){let n=await We.loadAsync(t),e={documentXml:null,stylesXml:null,themeXml:null,numberingXml:null,fontTableXml:null,settingsXml:null,webSettingsXml:null,headers:new Map,footers:new Map,footnotesXml:null,endnotesXml:null,commentsXml:null,commentsExtensibleXml:null,commentsExtendedXml:null,documentRels:null,packageRels:null,contentTypesXml:null,corePropsXml:null,appPropsXml:null,customPropsXml:null,media:new Map,fonts:new Map,allXml:new Map,originalZip:n,originalBuffer:t};for(let[o,i]of Object.entries(n.files)){if(i.dir)continue;let r=o.toLowerCase();if(r.endsWith(".xml")||r.endsWith(".rels")){let a=await i.async("text");if(e.allXml.set(o,a),r==="word/document.xml")e.documentXml=a;else if(r==="word/styles.xml")e.stylesXml=a;else if(r==="word/theme/theme1.xml")e.themeXml=a;else if(r==="word/numbering.xml")e.numberingXml=a;else if(r==="word/fonttable.xml")e.fontTableXml=a;else if(r==="word/settings.xml")e.settingsXml=a;else if(r==="word/websettings.xml")e.webSettingsXml=a;else if(r==="word/footnotes.xml")e.footnotesXml=a;else if(r==="word/endnotes.xml")e.endnotesXml=a;else if(r==="word/comments.xml")e.commentsXml=a;else if(r==="word/commentsextensible.xml")e.commentsExtensibleXml=a;else if(r==="word/commentsextended.xml")e.commentsExtendedXml=a;else if(r==="word/_rels/document.xml.rels")e.documentRels=a;else if(r==="_rels/.rels")e.packageRels=a;else if(r==="[content_types].xml")e.contentTypesXml=a;else if(r==="docprops/core.xml")e.corePropsXml=a;else if(r==="docprops/app.xml")e.appPropsXml=a;else if(r==="docprops/custom.xml")e.customPropsXml=a;else if(r.match(/^word\/header\d+\.xml$/)){let c=o.split("/").pop()||o;e.headers.set(c,a);}else if(r.match(/^word\/footer\d+\.xml$/)){let c=o.split("/").pop()||o;e.footers.set(c,a);}}else if(r.startsWith("word/media/")){let a=await i.async("arraybuffer");e.media.set(o,a);}else if(r.startsWith("word/fonts/")){let a=await i.async("arraybuffer");e.fonts.set(o,a);}}return e}function Ae(t){switch(t.toLowerCase().split(".").pop()){case "png":return "image/png";case "jpg":case "jpeg":return "image/jpeg";case "gif":return "image/gif";case "bmp":return "image/bmp";case "tif":case "tiff":return "image/tiff";case "wmf":return "image/x-wmf";case "emf":return "image/x-emf";case "svg":return "image/svg+xml";case "webp":return "image/webp";default:return "application/octet-stream"}}function ee(t,n,e,o){let i={};return t&&t!=="auto"?i.rgb=t:t==="auto"&&(i.auto=true),n&&(i.themeColor=n),e&&(i.themeTint=e),o&&(i.themeShade=o),i}function Z(t){if(!t)return;let n={},e=j$1(t,"w","color");e&&e!=="auto"&&(n.color={rgb:e});let o=j$1(t,"w","fill");o&&o!=="auto"&&(n.fill={rgb:o});let i=j$1(t,"w","themeFill");i&&(n.fill=n.fill||{},n.fill.themeColor=i);let r=j$1(t,"w","themeFillTint");r&&n.fill&&(n.fill.themeTint=r);let a=j$1(t,"w","themeFillShade");a&&n.fill&&(n.fill.themeShade=a);let c=j$1(t,"w","val");return c&&(n.pattern=c),Object.keys(n).length>0?n:void 0}function q(t,n){if(!t)return;let e$1={},o=e(t,"w","b");o&&(e$1.bold=m(o));let i=e(t,"w","bCs");i&&(e$1.boldCs=m(i));let r=e(t,"w","i");r&&(e$1.italic=m(r));let a=e(t,"w","iCs");a&&(e$1.italicCs=m(a));let c=e(t,"w","u");if(c){let p=j$1(c,"w","val");if(p){e$1.underline={style:p};let T=j$1(c,"w","color"),I=j$1(c,"w","themeColor");(T||I)&&(e$1.underline.color=ee(T,I,j$1(c,"w","themeTint"),j$1(c,"w","themeShade")));}}let g=e(t,"w","strike");g&&(e$1.strike=m(g));let d=e(t,"w","dstrike");d&&(e$1.doubleStrike=m(d));let h=e(t,"w","vertAlign");if(h){let p=j$1(h,"w","val");(p==="superscript"||p==="subscript"||p==="baseline")&&(e$1.vertAlign=p);}let y=e(t,"w","smallCaps");y&&(e$1.smallCaps=m(y));let u=e(t,"w","caps");u&&(e$1.allCaps=m(u));let S=e(t,"w","vanish");S&&(e$1.hidden=m(S));let f=e(t,"w","color");f&&(e$1.color=ee(j$1(f,"w","val"),j$1(f,"w","themeColor"),j$1(f,"w","themeTint"),j$1(f,"w","themeShade")));let b=e(t,"w","highlight");if(b){let p=j$1(b,"w","val");p&&(e$1.highlight=p);}let C=e(t,"w","shd");C&&(e$1.shading=Z(C));let D=e(t,"w","sz");if(D){let p=l(D,"w","val");p!==void 0&&(e$1.fontSize=p);}let B=e(t,"w","szCs");if(B){let p=l(B,"w","val");p!==void 0&&(e$1.fontSizeCs=p);}let v=e(t,"w","rFonts");if(v){e$1.fontFamily={ascii:j$1(v,"w","ascii")??void 0,hAnsi:j$1(v,"w","hAnsi")??void 0,eastAsia:j$1(v,"w","eastAsia")??void 0,cs:j$1(v,"w","cs")??void 0};let p=j$1(v,"w","asciiTheme");p&&(e$1.fontFamily.asciiTheme=p,n&&!e$1.fontFamily.ascii&&(e$1.fontFamily.ascii=b$3(n,p)));let T=j$1(v,"w","hAnsiTheme");T&&(e$1.fontFamily.hAnsiTheme=T,n&&!e$1.fontFamily.hAnsi&&(e$1.fontFamily.hAnsi=b$3(n,T)));let I=j$1(v,"w","eastAsiaTheme");I&&(e$1.fontFamily.eastAsiaTheme=I,n&&!e$1.fontFamily.eastAsia&&(e$1.fontFamily.eastAsia=b$3(n,I)));let W=j$1(v,"w","cstheme");W&&(e$1.fontFamily.csTheme=W,n&&!e$1.fontFamily.cs&&(e$1.fontFamily.cs=b$3(n,W)));}let X=e(t,"w","spacing");if(X){let p=l(X,"w","val");p!==void 0&&(e$1.spacing=p);}let m$1=e(t,"w","position");if(m$1){let p=l(m$1,"w","val");p!==void 0&&(e$1.position=p);}let x=e(t,"w","w");if(x){let p=l(x,"w","val");p!==void 0&&(e$1.scale=p);}let F=e(t,"w","kern");if(F){let p=l(F,"w","val");p!==void 0&&(e$1.kerning=p);}let k=e(t,"w","effect");if(k){let p=j$1(k,"w","val");p&&(e$1.effect=p);}let A=e(t,"w","em");if(A){let p=j$1(A,"w","val");p&&(e$1.emphasisMark=p);}let M=e(t,"w","emboss");M&&(e$1.emboss=m(M));let R=e(t,"w","imprint");R&&(e$1.imprint=m(R));let H=e(t,"w","outline");H&&(e$1.outline=m(H));let U=e(t,"w","shadow");U&&(e$1.shadow=m(U));let N=e(t,"w","rtl");N&&(e$1.rtl=m(N));let V=e(t,"w","cs");V&&(e$1.cs=m(V));let z=e(t,"w","rStyle");if(z){let p=j$1(z,"w","val");p&&(e$1.styleId=p);}return Object.keys(e$1).length>0?e$1:void 0}function E(t){if(!t)return;let n=j$1(t,"w","val");if(!n)return;let e={style:n},o=j$1(t,"w","color"),i=j$1(t,"w","themeColor");(o||i)&&(e.color=ee(o,i,j$1(t,"w","themeTint"),j$1(t,"w","themeShade")));let r=l(t,"w","sz");r!==void 0&&(e.size=r);let a=l(t,"w","space");a!==void 0&&(e.space=a);let c=j$1(t,"w","shadow");c&&(e.shadow=c==="1"||c==="true");let g=j$1(t,"w","frame");return g&&(e.frame=g==="1"||g==="true"),e}function $e(t){if(!t)return;let n=f(t,"w","tab");if(n.length===0)return;let e=[];for(let o of n){let i=l(o,"w","pos"),r=j$1(o,"w","val");if(i!==void 0&&r){let a={position:i,alignment:r},c=j$1(o,"w","leader");c&&(a.leader=c),e.push(a);}}return e.length>0?e:void 0}function te(t,n){if(!t)return;let e$1={},o=e(t,"w","jc");if(o){let m=j$1(o,"w","val");m&&(e$1.alignment=m);}let i=e(t,"w","bidi");i&&(e$1.bidi=m(i));let r=e(t,"w","spacing");if(r){let m=l(r,"w","before");m!==void 0&&(e$1.spaceBefore=m);let x=l(r,"w","after");x!==void 0&&(e$1.spaceAfter=x);let F=l(r,"w","line");F!==void 0&&(e$1.lineSpacing=F);let k=j$1(r,"w","lineRule");k&&(e$1.lineSpacingRule=k);let A=j$1(r,"w","beforeAutospacing");A&&(e$1.beforeAutospacing=A==="1"||A==="true");let M=j$1(r,"w","afterAutospacing");M&&(e$1.afterAutospacing=M==="1"||M==="true");}let a=e(t,"w","ind");if(a){let m=l(a,"w","left");m!==void 0&&(e$1.indentLeft=m);let x=l(a,"w","right");x!==void 0&&(e$1.indentRight=x);let F=l(a,"w","firstLine");F!==void 0&&(e$1.indentFirstLine=F);let k=l(a,"w","hanging");k!==void 0&&(e$1.indentFirstLine=-k,e$1.hangingIndent=true);}let c=e(t,"w","pBdr");if(c){let m={},x=E(e(c,"w","top"));x&&(m.top=x);let F=E(e(c,"w","bottom"));F&&(m.bottom=F);let k=E(e(c,"w","left"));k&&(m.left=k);let A=E(e(c,"w","right"));A&&(m.right=A);let M=E(e(c,"w","between"));M&&(m.between=M);let R=E(e(c,"w","bar"));R&&(m.bar=R),Object.keys(m).length>0&&(e$1.borders=m);}let g=e(t,"w","shd");g&&(e$1.shading=Z(g));let d=e(t,"w","tabs");d&&(e$1.tabs=$e(d));let h=e(t,"w","keepNext");h&&(e$1.keepNext=m(h));let y=e(t,"w","keepLines");y&&(e$1.keepLines=m(y));let u=e(t,"w","widowControl");u&&(e$1.widowControl=m(u));let S=e(t,"w","pageBreakBefore");S&&(e$1.pageBreakBefore=m(S));let f=e(t,"w","contextualSpacing");f&&(e$1.contextualSpacing=m(f));let b=e(t,"w","numPr");if(b){let m=e(b,"w","numId"),x=e(b,"w","ilvl");if(m||x){if(e$1.numPr={},m){let F=l(m,"w","val");F!==void 0&&(e$1.numPr.numId=F);}if(x){let F=l(x,"w","val");F!==void 0&&(e$1.numPr.ilvl=F);}}}let C=e(t,"w","outlineLvl");if(C){let m=l(C,"w","val");m!==void 0&&(e$1.outlineLevel=m);}let D=e(t,"w","pStyle");if(D){let m=j$1(D,"w","val");m&&(e$1.styleId=m);}let B=e(t,"w","suppressLineNumbers");B&&(e$1.suppressLineNumbers=m(B));let v=e(t,"w","suppressAutoHyphens");v&&(e$1.suppressAutoHyphens=m(v));let X=e(t,"w","rPr");return X&&(e$1.runProperties=q(X,n)),Object.keys(e$1).length>0?e$1:void 0}function j(t){if(!t)return;let n=l(t,"w","w"),e=j$1(t,"w","type");if(n!==void 0&&e)return {value:n,type:e}}function Ie(t){if(!t)return;let n={},e$1=E(e(t,"w","top"));e$1&&(n.top=e$1);let o=E(e(t,"w","bottom"));o&&(n.bottom=o);let i=E(e(t,"w","left"));i&&(n.left=i);let r=E(e(t,"w","right"));r&&(n.right=r);let a=E(e(t,"w","insideH"));a&&(n.insideH=a);let c=E(e(t,"w","insideV"));return c&&(n.insideV=c),Object.keys(n).length>0?n:void 0}function Re(t){if(!t)return;let n={},e$1=j(e(t,"w","top"));e$1&&(n.top=e$1);let o=j(e(t,"w","bottom"));o&&(n.bottom=o);let i=j(e(t,"w","left"));i&&(n.left=i);let r=j(e(t,"w","right"));return r&&(n.right=r),Object.keys(n).length>0?n:void 0}function _e(t){if(!t)return;let n={},e=j$1(t,"w","val");if(e){let d=parseInt(e,16);isNaN(d)||(n.firstRow=(d&32)!==0,n.lastRow=(d&64)!==0,n.firstColumn=(d&128)!==0,n.lastColumn=(d&256)!==0,n.noHBand=(d&512)!==0,n.noVBand=(d&1024)!==0);}let o=j$1(t,"w","firstColumn");o&&(n.firstColumn=o==="1");let i=j$1(t,"w","firstRow");i&&(n.firstRow=i==="1");let r=j$1(t,"w","lastColumn");r&&(n.lastColumn=r==="1");let a=j$1(t,"w","lastRow");a&&(n.lastRow=a==="1");let c=j$1(t,"w","noHBand");c&&(n.noHBand=c==="1");let g=j$1(t,"w","noVBand");return g&&(n.noVBand=g==="1"),Object.keys(n).length>0?n:void 0}function ue(t,n){if(!t)return;let e$1={},o=e(t,"w","tblW");o&&(e$1.width=j(o));let i=e(t,"w","jc");if(i){let f=j$1(i,"w","val");(f==="left"||f==="center"||f==="right")&&(e$1.justification=f);}let r=e(t,"w","tblCellSpacing");r&&(e$1.cellSpacing=j(r));let a=e(t,"w","tblInd");a&&(e$1.indent=j(a));let c=e(t,"w","tblBorders");c&&(e$1.borders=Ie(c));let g=e(t,"w","tblCellMar");g&&(e$1.cellMargins=Re(g));let d=e(t,"w","tblLayout");if(d){let f=j$1(d,"w","type");(f==="fixed"||f==="autofit")&&(e$1.layout=f);}let h=e(t,"w","tblStyle");if(h){let f=j$1(h,"w","val");f&&(e$1.styleId=f);}let y=e(t,"w","tblLook");y&&(e$1.look=_e(y));let u=e(t,"w","shd");u&&(e$1.shading=Z(u));let S=e(t,"w","bidiVisual");return S&&(e$1.bidi=m(S)),Object.keys(e$1).length>0?e$1:void 0}function de(t){if(!t)return;let n={},e$1=e(t,"w","trHeight");if(e$1){n.height=j(e$1);let c=j$1(e$1,"w","hRule");c&&(n.heightRule=c);}let o=e(t,"w","tblHeader");o&&(n.header=m(o));let i=e(t,"w","cantSplit");i&&(n.cantSplit=m(i));let r=e(t,"w","jc");if(r){let c=j$1(r,"w","val");(c==="left"||c==="center"||c==="right")&&(n.justification=c);}let a=e(t,"w","hidden");return a&&(n.hidden=m(a)),Object.keys(n).length>0?n:void 0}function pe(t,n){if(!t)return;let e$1={},o=e(t,"w","tcW");o&&(e$1.width=j(o));let i=e(t,"w","tcBorders");i&&(e$1.borders=Ie(i));let r=e(t,"w","tcMar");r&&(e$1.margins=Re(r));let a=e(t,"w","shd");a&&(e$1.shading=Z(a));let c=e(t,"w","vAlign");if(c){let f=j$1(c,"w","val");(f==="top"||f==="center"||f==="bottom")&&(e$1.verticalAlign=f);}let g=e(t,"w","textDirection");if(g){let f=j$1(g,"w","val");f&&(e$1.textDirection=f);}let d=e(t,"w","gridSpan");if(d){let f=l(d,"w","val");f!==void 0&&(e$1.gridSpan=f);}let h=e(t,"w","vMerge");if(h){let f=j$1(h,"w","val");e$1.vMerge=f==="restart"?"restart":"continue";}let y=e(t,"w","tcFitText");y&&(e$1.fitText=m(y));let u=e(t,"w","noWrap");u&&(e$1.noWrap=m(u));let S=e(t,"w","hideMark");return S&&(e$1.hideMark=m(S)),Object.keys(e$1).length>0?e$1:void 0}function Ze(t,n){let e$1={styleId:j$1(t,"w","styleId")??"",type:j$1(t,"w","type")??"paragraph"},o=j$1(t,"w","default");o&&(e$1.default=o==="1"||o==="true");let i=e(t,"w","name");i&&(e$1.name=j$1(i,"w","val")??void 0);let r=e(t,"w","basedOn");r&&(e$1.basedOn=j$1(r,"w","val")??void 0);let a=e(t,"w","next");a&&(e$1.next=j$1(a,"w","val")??void 0);let c=e(t,"w","link");c&&(e$1.link=j$1(c,"w","val")??void 0);let g=e(t,"w","uiPriority");if(g){let X=l(g,"w","val");X!==void 0&&(e$1.uiPriority=X);}let d=e(t,"w","hidden");d&&(e$1.hidden=m(d));let h=e(t,"w","semiHidden");h&&(e$1.semiHidden=m(h));let y=e(t,"w","unhideWhenUsed");y&&(e$1.unhideWhenUsed=m(y));let u=e(t,"w","qFormat");u&&(e$1.qFormat=m(u));let S=e(t,"w","personal");S&&(e$1.personal=m(S));let f$1=e(t,"w","pPr");f$1&&(e$1.pPr=te(f$1,n));let b=e(t,"w","rPr");b&&(e$1.rPr=q(b,n));let C=e(t,"w","tblPr");C&&(e$1.tblPr=ue(C));let D=e(t,"w","trPr");D&&(e$1.trPr=de(D));let B=e(t,"w","tcPr");B&&(e$1.tcPr=pe(B));let v=f(t,"w","tblStylePr");if(v.length>0){e$1.tblStylePr=[];for(let X of v){let m=j$1(X,"w","type");if(m){let x={type:m},F=e(X,"w","pPr");F&&(x.pPr=te(F,n));let k=e(X,"w","rPr");k&&(x.rPr=q(k,n));let A=e(X,"w","tblPr");A&&(x.tblPr=ue(A));let M=e(X,"w","trPr");M&&(x.trPr=de(M));let R=e(X,"w","tcPr");R&&(x.tcPr=pe(R)),e$1.tblStylePr.push(x);}}}return e$1}function qe(t,n){if(!t)return;let e$1={},o=e(t,"w","rPrDefault");if(o){let r=e(o,"w","rPr");r&&(e$1.rPr=q(r,n));}let i=e(t,"w","pPrDefault");if(i){let r=e(i,"w","pPr");r&&(e$1.pPr=te(r,n));}return e$1.rPr||e$1.pPr?e$1:void 0}function Je(t,n){if(!n)return t;if(!t)return n?{...n}:void 0;let e={...t};for(let o of Object.keys(n)){let i=n[o];if(i!==void 0)if(o==="runProperties")e.runProperties=b$2(e.runProperties,n.runProperties);else if(o==="borders"||o==="numPr"||o==="frame"){let r=e[o],a=i;e[o]={...r||{},...a||{}};}else o==="tabs"&&Array.isArray(i)?e.tabs=[...i]:e[o]=i;}return e}function Ee(t,n,e,o=new Set){if(o.has(t.styleId)||(o.add(t.styleId),!t.basedOn))return t;let i=n.get(t.basedOn);if(!i)return t;let r=Ee(i,n,e,o),a={...t,pPr:Je(r.pPr,t.pPr),rPr:b$2(r.rPr,t.rPr)};return t.type==="table"&&((r.tblPr||t.tblPr)&&(a.tblPr={...r.tblPr||{},...t.tblPr||{}}),(r.trPr||t.trPr)&&(a.trPr={...r.trPr||{},...t.trPr||{}}),(r.tcPr||t.tcPr)&&(a.tcPr={...r.tcPr||{},...t.tcPr||{}})),a}function me(t,n){let e=new Map;try{let o=c(t);if(!o)return e;let i=f(o,"w","style");for(let r of i){let a=Ze(r,n);a.styleId&&e.set(a.styleId,a);}for(let[r,a]of e){let c=Ee(a,e,n);e.set(r,c);}}catch(o){console.warn("Failed to parse styles:",o);}return e}function Ne(t,n){let e$1={styles:[]};try{let o=c(t);if(!o)return e$1;let i=e(o,"w","docDefaults");e$1.docDefaults=qe(i,n);let r=e(o,"w","latentStyles");r&&(e$1.latentStyles={defLockedState:j$1(r,"w","defLockedState")==="1",defUIPriority:l(r,"w","defUIPriority"),defSemiHidden:j$1(r,"w","defSemiHidden")==="1",defUnhideWhenUsed:j$1(r,"w","defUnhideWhenUsed")==="1",defQFormat:j$1(r,"w","defQFormat")==="1",count:l(r,"w","count")});let a=me(t,n);e$1.styles=Array.from(a.values());}catch(o){console.warn("Failed to parse style definitions:",o);}return e$1}var He=/\{([a-zA-Z_][a-zA-Z0-9_\-\.]*)\}/g;function Ve(t){let n=[],e;for(He.lastIndex=0;(e=He.exec(t))!==null;){let o=e[1].trim();o&&!n.includes(o)&&n.push(o);}return n}function ne(t){let n=[];for(let e of t)if(e.type==="paragraph"){let o=N(e),i=Ve(o);for(let r of i)n.includes(r)||n.push(r);}else if(e.type==="table"){let o=je(e);for(let i of o)n.includes(i)||n.push(i);}return n}function je(t){let n=[];for(let e of t.rows)for(let o of e.cells)for(let i of o.content)if(i.type==="paragraph"){let r=N(i),a=Ve(r);for(let c of a)n.includes(c)||n.push(c);}else if(i.type==="table"){let r=je(i);for(let a of r)n.includes(a)||n.push(a);}return n}function Qe(t,n){let e=[],o=[];for(let i of t)o.push(i),i.type==="paragraph"&&i.sectionProperties&&(e.push({properties:i.sectionProperties,content:o}),o=[]);return (o.length>0||e.length===0)&&e.push({properties:n??C(),content:o}),e}function oe(t,n=null,e$1=null,o=null,i=null,r=null){let a={content:[]};if(!t)return a;let c=a$3(t);if(!c)return a;let g=(c.elements??[]).find(u=>u.type==="element"&&(u.name==="w:document"||u.name?.endsWith(":document")));if(!g)return a;let d=e(g,"w","body");if(!d)return a;a.content=q$2(d,n,e$1,o,i,r);let h=e(d,"w","sectPr");h&&(a.finalSectionProperties=B(h,i));let y=Qe(a.content,a.finalSectionProperties);return a.sections=D(y),a.finalSectionProperties&&a.sections.length>0&&(a.finalSectionProperties=a.sections[a.sections.length-1].properties),a}function Ge(t){let n=new Map,e$1=a$3(t);if(!e$1)return n;let o=e(e$1,"w16cex","commentsExtensible")??e$1;for(let i$1 of i(o)){if((i$1.name?.replace(/^.*:/,"")??"")!=="comment")continue;let a=j$1(i$1,"w16cex","paraId")??j$1(i$1,"w15","paraId")??i$1.attributes?.["w16cex:paraId"]??i$1.attributes?.["w15:paraId"],c=j$1(i$1,"w16cex","dateUtc")??j$1(i$1,"w15","dateUtc")??i$1.attributes?.["w16cex:dateUtc"]??i$1.attributes?.["w15:dateUtc"];a&&c&&n.set(String(a).toUpperCase(),String(c));}return n}function Ye(t){let n=new Map,e$1=new Map,o=a$3(t);if(!o)return {parentByParaId:n,doneByParaId:e$1};let i$1=e(o,"w15","commentsEx")??o;for(let r of i(i$1)){if((r.name?.replace(/^.*:/,"")??"")!=="commentEx")continue;let c=j$1(r,"w15","paraId")??r.attributes?.["w15:paraId"],g=j$1(r,"w15","paraIdParent")??r.attributes?.["w15:paraIdParent"],d=j$1(r,"w15","done")??r.attributes?.["w15:done"];if(c){let h=String(c).toUpperCase();g&&n.set(h,String(g).toUpperCase()),d==="1"&&e$1.set(h,true);}}return {parentByParaId:n,doneByParaId:e$1}}function Le(t,n,e$1,o,i$1,r,a){if(!t)return [];let c=a$3(t);if(!c)return [];let g=r?Ge(r):new Map,d=a?Ye(a):null,h=e(c,"w","comments")??c,y=i(h),u=[],S=[];for(let f of y){if((f.name?.replace(/^.*:/,"")??"")!=="comment")continue;let C=parseInt(j$1(f,"w","id")??"0",10),D=j$1(f,"w","author")??"Unknown",B=j$1(f,"w","initials"),v=B!=null?String(B):void 0,X=j$1(f,"w","date"),m=X!=null?String(X):void 0,x=j$1(f,"w14","paraId")??f.attributes?.["w14:paraId"]??j$1(f,"w","paraId"),k=(x?g.get(String(x).toUpperCase()):void 0)??m,A=j$1(f,"w","done")??f.attributes?.["w:done"],M=A==="1"||A==="true"?true:void 0,R=j$1(f,"w16cid","parentId")??j$1(f,"w","parentId")??f.attributes?.["w16cid:parentId"]??f.attributes?.["w:parentId"],H=R!=null?parseInt(String(R),10):void 0,U=[],N="";for(let V of i(f))if((V.name?.replace(/^.*:/,"")??"")==="p"){let p=O$1(V,n,e$1,null,o,i$1);U.push(p);let T=j$1(V,"w14","paraId")??V.attributes?.["w14:paraId"];T&&(N=String(T).toUpperCase());}M==null&&d&&N&&d.doneByParaId.get(N)&&(M=true),S.push(N),u.push({id:C,author:D,initials:v,date:k,content:U,...M!=null?{done:M}:{},...H!=null&&!isNaN(H)?{parentId:H}:{}});}if(d&&d.parentByParaId.size>0){let f=new Map;for(let b=0;b<u.length;b++){let C=S[b];C&&f.set(C,u[b].id);}for(let b=0;b<u.length;b++){if(u[b].parentId!=null)continue;let C=S[b];if(!C)continue;let D=d.parentByParaId.get(C);if(!D)continue;let B=f.get(D);B!=null&&(u[b]={...u[b],parentId:B});}}return u}function L(t,n){if(t)for(let e of t)if(e.type==="paragraph")e.content=e.content.filter(o=>o.type!=="commentRangeStart"&&o.type!=="commentRangeEnd"||n.has(o.id));else if(e.type==="table")for(let o of e.rows)for(let i of o.cells)L(i.content,n);else e.type==="blockSdt"&&L(e.content,n);}function Oe(t){let n=t.package,e=new Set((n.document.comments??[]).map(o=>o.id));L(n.document.content,e);for(let o of n.headers?.values()??[])L(o.content,e);for(let o of n.footers?.values()??[])L(o.content,e);for(let o of n.footnotes??[])L(o.content,e);for(let o of n.endnotes??[])L(o.content,e);for(let o of n.footnoteSeparators??[])L(o.content,e);for(let o of n.endnoteSeparators??[])L(o.content,e);}function Ke(t){let n=a$4();for(;t.has(n)||!b$4(n);)n=a$4();return n}function et(t,n){t.paraId!=null&&(n.has(t.paraId)&&(t.paraId=Ke(n)),n.add(t.paraId));}function O(t,n){if(t)for(let e of t)if(e.type==="paragraph")et(e,n);else if(e.type==="table")for(let o of e.rows)for(let i of o.cells)O(i.content,n);else e.type==="blockSdt"&&O(e.content,n);}function Ue(t){let n=t.package,e=new Set;O(n.document.content,e);for(let o of n.headers?.values()??[])O(o.content,e);for(let o of n.footers?.values()??[])O(o.content,e);for(let o of n.footnotes??[])O(o.content,e);for(let o of n.endnotes??[])O(o.content,e);for(let o of n.footnoteSeparators??[])O(o.content,e);for(let o of n.endnoteSeparators??[])O(o.content,e);}async function ze(t,n={}){let e=t instanceof ArrayBuffer?t:await u(t),{onProgress:o=()=>{},preloadFonts:i=true,parseHeadersFooters:r=true,parseNotes:a$2=true,detectVariables:c=true}=n,g=[];try{let u=function(T,I){let W=performance.now(),se=I(),$=performance.now()-W;return y.push({stage:T,ms:$}),$>1e3&&console.warn(`[parseDocx] ${T} took ${Math.round($)}ms`),se};var d=u;let h=performance.now(),y=[];async function S(T,I){let W=performance.now(),se=await I(),$=performance.now()-W;return y.push({stage:T,ms:$}),$>1e3&&console.warn(`[parseDocx] ${T} took ${Math.round($)}ms`),se}o("Extracting DOCX...",0);let f=await S("unzip",()=>K(e));o("Extracted DOCX",10),o("Parsing relationships...",10);let b$2=u("relationships",()=>f.documentRels?b(f.documentRels):new Map);o("Parsed relationships",15),o("Parsing theme...",15);let C=u("theme",()=>a(f.themeXml));o("Parsed theme",20),o("Parsing styles...",20);let D=null,B;u("styles",()=>{f.stylesXml&&(D=me(f.stylesXml,C),B=Ne(f.stylesXml,C));}),o("Parsed styles",30),o("Parsing numbering...",30);let v=u("numbering",()=>a$1(f.numberingXml)),X=u("settings",()=>b$1(f.settingsXml));o("Parsed numbering",35),o("Processing media files...",35);let m=u("media",()=>tt(f,b$2));o("Processed media",40),o("Parsing document body...",40);let x={content:[]};u("documentBody",()=>{f.documentXml?x=oe(f.documentXml,D,C,v,b$2,m):g.push("No document.xml found in DOCX");}),o("Parsed document body",55);let F,k;if(r){o("Parsing headers/footers...",55);let T=u("headersFooters",()=>nt(f,D,C,v,b$2,m));F=T.headers,k=T.footers,o("Parsed headers/footers",65);}else o("Skipping headers/footers",65);let A,M,R,H;if(a$2){o("Parsing footnotes/endnotes...",65);let T=u("footnotesEndnotes",()=>ot(f,D,C,v,b$2,m));A=T.footnotes,M=T.endnotes,R=T.footnoteSeparators,H=T.endnoteSeparators,o("Parsed footnotes/endnotes",75);}else o("Skipping footnotes/endnotes",75);o("Parsing comments...",75);let U=u("comments",()=>Le(f.commentsXml,D,C,b$2,m,f.commentsExtensibleXml,f.commentsExtendedXml));U.length>0&&(x.comments=U);let N;c?(o("Detecting template variables...",75),N=u("variables",()=>ne(x.content)),o("Detected variables",80)):o("Skipping variable detection",80),i?(o("Loading fonts...",80),await S("fonts",()=>rt(C,B,x)),o("Loaded fonts",95)):o("Skipping font loading",95),o("Assembling document...",95);let z={package:{document:x,styles:B,theme:C,numbering:v.definitions,settings:X,headers:F,footers:k,footnotes:A,endnotes:M,footnoteSeparators:R,endnoteSeparators:H,relationships:b$2,media:m},originalBuffer:e,templateVariables:N,warnings:g.length>0?g:void 0};Oe(z),Ue(z);let p=performance.now()-h;if(p>2e3){let T=y.filter(I=>I.ms>100).map(I=>`${I.stage}: ${Math.round(I.ms)}ms`).join(", ");console.warn(`[parseDocx] Total: ${Math.round(p)}ms`+(T?` (${T})`:""));}return o("Complete",100),z}catch(h){let y=h instanceof Error?h.message:String(h);throw console.error("[parseDocx] Failed to parse DOCX:",y,h),new Error(`Failed to parse DOCX: ${y}`)}}function tt(t,n){let e=new Map;for(let[o,i]of t.media.entries()){let r=o.split("/").pop()||o,a=Ae(o),c=new Uint8Array(i),g="";for(let S=0;S<c.length;S++)g+=String.fromCharCode(c[S]);let d=btoa(g),h=`data:${a};base64,${d}`,y={path:o,filename:r,mimeType:a,data:i,dataUrl:h};e.set(o,y);let u=o.replace(/^word\//,"");u!==o&&e.set(u,y);}return e}function re(t,n){let e=n.toLowerCase();for(let[o,i]of t.entries())if(o.toLowerCase()===e)return i}function nt(t,n,e,o,i,r$1){let a=new Map,c=new Map;for(let[g,d]of i.entries())if(d.type===a$2.header&&d.target){let h=d.target.split("/").pop()||d.target,y=re(t.headers,h);if(y){let u=`word/_rels/${h}.rels`,S=re(t.allXml,u),f=S?b(S):i,b$1=r(y,"default",n,e,o,f,r$1);a.set(g,b$1);}}else if(d.type===a$2.footer&&d.target){let h=d.target.split("/").pop()||d.target,y=re(t.footers,h);if(y){let u=`word/_rels/${h}.rels`,S=re(t.allXml,u),f=S?b(S):i,b$1=s(y,"default",n,e,o,f,r$1);c.set(g,b$1);}}return {headers:a,footers:c}}function ot(t$1,n,e,o,i,r){let a=t(t$1.footnotesXml,n,e,o,i,r),c=u$1(t$1.endnotesXml,n,e,o,i,r);return {footnotes:a.getNormalFootnotes(),endnotes:c.getNormalEndnotes(),footnoteSeparators:a.footnotes.filter(z),endnoteSeparators:c.endnotes.filter(A)}}async function rt(t,n,e){let o=new Set;if(t?.fontScheme){let{majorFont:i,minorFont:r}=t.fontScheme;i?.latin&&o.add(i.latin),r?.latin&&o.add(r.latin);}if(n?.docDefaults?.rPr?.fontFamily?.ascii&&o.add(n.docDefaults.rPr.fontFamily.ascii),n?.styles)for(let i of n.styles)i.rPr?.fontFamily?.ascii&&o.add(i.rPr.fontFamily.ascii),i.rPr?.fontFamily?.hAnsi&&o.add(i.rPr.fontFamily.hAnsi);if(e.content){for(let i of e.content)if(i.type==="paragraph")for(let r of i.content)r.type==="run"&&r.formatting?.fontFamily&&(r.formatting.fontFamily.ascii&&o.add(r.formatting.fontFamily.ascii),r.formatting.fontFamily.hAnsi&&o.add(r.formatting.fontFamily.hAnsi));}if(o.size>0)try{await q$1(Array.from(o));}catch(i){console.warn("Failed to load some fonts:",i);}}async function qt(t){return ze(t,{preloadFonts:false,parseHeadersFooters:false,parseNotes:false,detectVariables:true})}async function Jt(t,n){return ze(t,{onProgress:n,preloadFonts:true,parseHeadersFooters:true,parseNotes:true,detectVariables:true})}async function Qt(t){let n=await K(t);if(!n.documentXml)return [];let e=oe(n.documentXml);return ne(e.content)}async function Gt(t){let n=await K(t),e=n.documentXml?ne(oe(n.documentXml).content):[];return {hasDocument:n.documentXml!==null,hasStyles:n.stylesXml!==null,hasTheme:n.themeXml!==null,hasNumbering:n.numberingXml!==null,headerCount:n.headers.size,footerCount:n.footers.size,mediaCount:n.media.size,variableCount:e.length}}
|
|
2
|
+
export{ze as a,qt as b,Jt as c,Qt as d,Gt as e};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkLZTEPSU2_js=require('./chunk-LZTEPSU2.js'),chunkFIGLFSNR_js=require('./chunk-FIGLFSNR.js'),chunkQVRMX2AC_js=require('./chunk-QVRMX2AC.js'),chunkZ3LGMBJC_js=require('./chunk-Z3LGMBJC.js'),chunkB3SVS2AF_js=require('./chunk-B3SVS2AF.js'),chunkGSKMHXHG_js=require('./chunk-GSKMHXHG.js'),chunkH57LNDBH_js=require('./chunk-H57LNDBH.js'),chunk3R7QHNI5_js=require('./chunk-3R7QHNI5.js'),We=require('jszip');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var We__default=/*#__PURE__*/_interopDefault(We);async function K(t){let n=await We__default.default.loadAsync(t),e={documentXml:null,stylesXml:null,themeXml:null,numberingXml:null,fontTableXml:null,settingsXml:null,webSettingsXml:null,headers:new Map,footers:new Map,footnotesXml:null,endnotesXml:null,commentsXml:null,commentsExtensibleXml:null,commentsExtendedXml:null,documentRels:null,packageRels:null,contentTypesXml:null,corePropsXml:null,appPropsXml:null,customPropsXml:null,media:new Map,fonts:new Map,allXml:new Map,originalZip:n,originalBuffer:t};for(let[o,i]of Object.entries(n.files)){if(i.dir)continue;let r=o.toLowerCase();if(r.endsWith(".xml")||r.endsWith(".rels")){let a=await i.async("text");if(e.allXml.set(o,a),r==="word/document.xml")e.documentXml=a;else if(r==="word/styles.xml")e.stylesXml=a;else if(r==="word/theme/theme1.xml")e.themeXml=a;else if(r==="word/numbering.xml")e.numberingXml=a;else if(r==="word/fonttable.xml")e.fontTableXml=a;else if(r==="word/settings.xml")e.settingsXml=a;else if(r==="word/websettings.xml")e.webSettingsXml=a;else if(r==="word/footnotes.xml")e.footnotesXml=a;else if(r==="word/endnotes.xml")e.endnotesXml=a;else if(r==="word/comments.xml")e.commentsXml=a;else if(r==="word/commentsextensible.xml")e.commentsExtensibleXml=a;else if(r==="word/commentsextended.xml")e.commentsExtendedXml=a;else if(r==="word/_rels/document.xml.rels")e.documentRels=a;else if(r==="_rels/.rels")e.packageRels=a;else if(r==="[content_types].xml")e.contentTypesXml=a;else if(r==="docprops/core.xml")e.corePropsXml=a;else if(r==="docprops/app.xml")e.appPropsXml=a;else if(r==="docprops/custom.xml")e.customPropsXml=a;else if(r.match(/^word\/header\d+\.xml$/)){let c=o.split("/").pop()||o;e.headers.set(c,a);}else if(r.match(/^word\/footer\d+\.xml$/)){let c=o.split("/").pop()||o;e.footers.set(c,a);}}else if(r.startsWith("word/media/")){let a=await i.async("arraybuffer");e.media.set(o,a);}else if(r.startsWith("word/fonts/")){let a=await i.async("arraybuffer");e.fonts.set(o,a);}}return e}function Ae(t){switch(t.toLowerCase().split(".").pop()){case "png":return "image/png";case "jpg":case "jpeg":return "image/jpeg";case "gif":return "image/gif";case "bmp":return "image/bmp";case "tif":case "tiff":return "image/tiff";case "wmf":return "image/x-wmf";case "emf":return "image/x-emf";case "svg":return "image/svg+xml";case "webp":return "image/webp";default:return "application/octet-stream"}}function ee(t,n,e,o){let i={};return t&&t!=="auto"?i.rgb=t:t==="auto"&&(i.auto=true),n&&(i.themeColor=n),e&&(i.themeTint=e),o&&(i.themeShade=o),i}function Z(t){if(!t)return;let n={},e=chunk3R7QHNI5_js.j(t,"w","color");e&&e!=="auto"&&(n.color={rgb:e});let o=chunk3R7QHNI5_js.j(t,"w","fill");o&&o!=="auto"&&(n.fill={rgb:o});let i=chunk3R7QHNI5_js.j(t,"w","themeFill");i&&(n.fill=n.fill||{},n.fill.themeColor=i);let r=chunk3R7QHNI5_js.j(t,"w","themeFillTint");r&&n.fill&&(n.fill.themeTint=r);let a=chunk3R7QHNI5_js.j(t,"w","themeFillShade");a&&n.fill&&(n.fill.themeShade=a);let c=chunk3R7QHNI5_js.j(t,"w","val");return c&&(n.pattern=c),Object.keys(n).length>0?n:void 0}function q(t,n){if(!t)return;let e={},o=chunk3R7QHNI5_js.e(t,"w","b");o&&(e.bold=chunk3R7QHNI5_js.m(o));let i=chunk3R7QHNI5_js.e(t,"w","bCs");i&&(e.boldCs=chunk3R7QHNI5_js.m(i));let r=chunk3R7QHNI5_js.e(t,"w","i");r&&(e.italic=chunk3R7QHNI5_js.m(r));let a=chunk3R7QHNI5_js.e(t,"w","iCs");a&&(e.italicCs=chunk3R7QHNI5_js.m(a));let c=chunk3R7QHNI5_js.e(t,"w","u");if(c){let p=chunk3R7QHNI5_js.j(c,"w","val");if(p){e.underline={style:p};let T=chunk3R7QHNI5_js.j(c,"w","color"),I=chunk3R7QHNI5_js.j(c,"w","themeColor");(T||I)&&(e.underline.color=ee(T,I,chunk3R7QHNI5_js.j(c,"w","themeTint"),chunk3R7QHNI5_js.j(c,"w","themeShade")));}}let g=chunk3R7QHNI5_js.e(t,"w","strike");g&&(e.strike=chunk3R7QHNI5_js.m(g));let d=chunk3R7QHNI5_js.e(t,"w","dstrike");d&&(e.doubleStrike=chunk3R7QHNI5_js.m(d));let h=chunk3R7QHNI5_js.e(t,"w","vertAlign");if(h){let p=chunk3R7QHNI5_js.j(h,"w","val");(p==="superscript"||p==="subscript"||p==="baseline")&&(e.vertAlign=p);}let y=chunk3R7QHNI5_js.e(t,"w","smallCaps");y&&(e.smallCaps=chunk3R7QHNI5_js.m(y));let u=chunk3R7QHNI5_js.e(t,"w","caps");u&&(e.allCaps=chunk3R7QHNI5_js.m(u));let S=chunk3R7QHNI5_js.e(t,"w","vanish");S&&(e.hidden=chunk3R7QHNI5_js.m(S));let f=chunk3R7QHNI5_js.e(t,"w","color");f&&(e.color=ee(chunk3R7QHNI5_js.j(f,"w","val"),chunk3R7QHNI5_js.j(f,"w","themeColor"),chunk3R7QHNI5_js.j(f,"w","themeTint"),chunk3R7QHNI5_js.j(f,"w","themeShade")));let b=chunk3R7QHNI5_js.e(t,"w","highlight");if(b){let p=chunk3R7QHNI5_js.j(b,"w","val");p&&(e.highlight=p);}let C=chunk3R7QHNI5_js.e(t,"w","shd");C&&(e.shading=Z(C));let D=chunk3R7QHNI5_js.e(t,"w","sz");if(D){let p=chunk3R7QHNI5_js.l(D,"w","val");p!==void 0&&(e.fontSize=p);}let B=chunk3R7QHNI5_js.e(t,"w","szCs");if(B){let p=chunk3R7QHNI5_js.l(B,"w","val");p!==void 0&&(e.fontSizeCs=p);}let v=chunk3R7QHNI5_js.e(t,"w","rFonts");if(v){e.fontFamily={ascii:chunk3R7QHNI5_js.j(v,"w","ascii")??void 0,hAnsi:chunk3R7QHNI5_js.j(v,"w","hAnsi")??void 0,eastAsia:chunk3R7QHNI5_js.j(v,"w","eastAsia")??void 0,cs:chunk3R7QHNI5_js.j(v,"w","cs")??void 0};let p=chunk3R7QHNI5_js.j(v,"w","asciiTheme");p&&(e.fontFamily.asciiTheme=p,n&&!e.fontFamily.ascii&&(e.fontFamily.ascii=chunkLZTEPSU2_js.b(n,p)));let T=chunk3R7QHNI5_js.j(v,"w","hAnsiTheme");T&&(e.fontFamily.hAnsiTheme=T,n&&!e.fontFamily.hAnsi&&(e.fontFamily.hAnsi=chunkLZTEPSU2_js.b(n,T)));let I=chunk3R7QHNI5_js.j(v,"w","eastAsiaTheme");I&&(e.fontFamily.eastAsiaTheme=I,n&&!e.fontFamily.eastAsia&&(e.fontFamily.eastAsia=chunkLZTEPSU2_js.b(n,I)));let W=chunk3R7QHNI5_js.j(v,"w","cstheme");W&&(e.fontFamily.csTheme=W,n&&!e.fontFamily.cs&&(e.fontFamily.cs=chunkLZTEPSU2_js.b(n,W)));}let X=chunk3R7QHNI5_js.e(t,"w","spacing");if(X){let p=chunk3R7QHNI5_js.l(X,"w","val");p!==void 0&&(e.spacing=p);}let m=chunk3R7QHNI5_js.e(t,"w","position");if(m){let p=chunk3R7QHNI5_js.l(m,"w","val");p!==void 0&&(e.position=p);}let x=chunk3R7QHNI5_js.e(t,"w","w");if(x){let p=chunk3R7QHNI5_js.l(x,"w","val");p!==void 0&&(e.scale=p);}let F=chunk3R7QHNI5_js.e(t,"w","kern");if(F){let p=chunk3R7QHNI5_js.l(F,"w","val");p!==void 0&&(e.kerning=p);}let k=chunk3R7QHNI5_js.e(t,"w","effect");if(k){let p=chunk3R7QHNI5_js.j(k,"w","val");p&&(e.effect=p);}let A=chunk3R7QHNI5_js.e(t,"w","em");if(A){let p=chunk3R7QHNI5_js.j(A,"w","val");p&&(e.emphasisMark=p);}let M=chunk3R7QHNI5_js.e(t,"w","emboss");M&&(e.emboss=chunk3R7QHNI5_js.m(M));let R=chunk3R7QHNI5_js.e(t,"w","imprint");R&&(e.imprint=chunk3R7QHNI5_js.m(R));let H=chunk3R7QHNI5_js.e(t,"w","outline");H&&(e.outline=chunk3R7QHNI5_js.m(H));let U=chunk3R7QHNI5_js.e(t,"w","shadow");U&&(e.shadow=chunk3R7QHNI5_js.m(U));let N=chunk3R7QHNI5_js.e(t,"w","rtl");N&&(e.rtl=chunk3R7QHNI5_js.m(N));let V=chunk3R7QHNI5_js.e(t,"w","cs");V&&(e.cs=chunk3R7QHNI5_js.m(V));let z=chunk3R7QHNI5_js.e(t,"w","rStyle");if(z){let p=chunk3R7QHNI5_js.j(z,"w","val");p&&(e.styleId=p);}return Object.keys(e).length>0?e:void 0}function E(t){if(!t)return;let n=chunk3R7QHNI5_js.j(t,"w","val");if(!n)return;let e={style:n},o=chunk3R7QHNI5_js.j(t,"w","color"),i=chunk3R7QHNI5_js.j(t,"w","themeColor");(o||i)&&(e.color=ee(o,i,chunk3R7QHNI5_js.j(t,"w","themeTint"),chunk3R7QHNI5_js.j(t,"w","themeShade")));let r=chunk3R7QHNI5_js.l(t,"w","sz");r!==void 0&&(e.size=r);let a=chunk3R7QHNI5_js.l(t,"w","space");a!==void 0&&(e.space=a);let c=chunk3R7QHNI5_js.j(t,"w","shadow");c&&(e.shadow=c==="1"||c==="true");let g=chunk3R7QHNI5_js.j(t,"w","frame");return g&&(e.frame=g==="1"||g==="true"),e}function $e(t){if(!t)return;let n=chunk3R7QHNI5_js.f(t,"w","tab");if(n.length===0)return;let e=[];for(let o of n){let i=chunk3R7QHNI5_js.l(o,"w","pos"),r=chunk3R7QHNI5_js.j(o,"w","val");if(i!==void 0&&r){let a={position:i,alignment:r},c=chunk3R7QHNI5_js.j(o,"w","leader");c&&(a.leader=c),e.push(a);}}return e.length>0?e:void 0}function te(t,n){if(!t)return;let e={},o=chunk3R7QHNI5_js.e(t,"w","jc");if(o){let m=chunk3R7QHNI5_js.j(o,"w","val");m&&(e.alignment=m);}let i=chunk3R7QHNI5_js.e(t,"w","bidi");i&&(e.bidi=chunk3R7QHNI5_js.m(i));let r=chunk3R7QHNI5_js.e(t,"w","spacing");if(r){let m=chunk3R7QHNI5_js.l(r,"w","before");m!==void 0&&(e.spaceBefore=m);let x=chunk3R7QHNI5_js.l(r,"w","after");x!==void 0&&(e.spaceAfter=x);let F=chunk3R7QHNI5_js.l(r,"w","line");F!==void 0&&(e.lineSpacing=F);let k=chunk3R7QHNI5_js.j(r,"w","lineRule");k&&(e.lineSpacingRule=k);let A=chunk3R7QHNI5_js.j(r,"w","beforeAutospacing");A&&(e.beforeAutospacing=A==="1"||A==="true");let M=chunk3R7QHNI5_js.j(r,"w","afterAutospacing");M&&(e.afterAutospacing=M==="1"||M==="true");}let a=chunk3R7QHNI5_js.e(t,"w","ind");if(a){let m=chunk3R7QHNI5_js.l(a,"w","left");m!==void 0&&(e.indentLeft=m);let x=chunk3R7QHNI5_js.l(a,"w","right");x!==void 0&&(e.indentRight=x);let F=chunk3R7QHNI5_js.l(a,"w","firstLine");F!==void 0&&(e.indentFirstLine=F);let k=chunk3R7QHNI5_js.l(a,"w","hanging");k!==void 0&&(e.indentFirstLine=-k,e.hangingIndent=true);}let c=chunk3R7QHNI5_js.e(t,"w","pBdr");if(c){let m={},x=E(chunk3R7QHNI5_js.e(c,"w","top"));x&&(m.top=x);let F=E(chunk3R7QHNI5_js.e(c,"w","bottom"));F&&(m.bottom=F);let k=E(chunk3R7QHNI5_js.e(c,"w","left"));k&&(m.left=k);let A=E(chunk3R7QHNI5_js.e(c,"w","right"));A&&(m.right=A);let M=E(chunk3R7QHNI5_js.e(c,"w","between"));M&&(m.between=M);let R=E(chunk3R7QHNI5_js.e(c,"w","bar"));R&&(m.bar=R),Object.keys(m).length>0&&(e.borders=m);}let g=chunk3R7QHNI5_js.e(t,"w","shd");g&&(e.shading=Z(g));let d=chunk3R7QHNI5_js.e(t,"w","tabs");d&&(e.tabs=$e(d));let h=chunk3R7QHNI5_js.e(t,"w","keepNext");h&&(e.keepNext=chunk3R7QHNI5_js.m(h));let y=chunk3R7QHNI5_js.e(t,"w","keepLines");y&&(e.keepLines=chunk3R7QHNI5_js.m(y));let u=chunk3R7QHNI5_js.e(t,"w","widowControl");u&&(e.widowControl=chunk3R7QHNI5_js.m(u));let S=chunk3R7QHNI5_js.e(t,"w","pageBreakBefore");S&&(e.pageBreakBefore=chunk3R7QHNI5_js.m(S));let f=chunk3R7QHNI5_js.e(t,"w","contextualSpacing");f&&(e.contextualSpacing=chunk3R7QHNI5_js.m(f));let b=chunk3R7QHNI5_js.e(t,"w","numPr");if(b){let m=chunk3R7QHNI5_js.e(b,"w","numId"),x=chunk3R7QHNI5_js.e(b,"w","ilvl");if(m||x){if(e.numPr={},m){let F=chunk3R7QHNI5_js.l(m,"w","val");F!==void 0&&(e.numPr.numId=F);}if(x){let F=chunk3R7QHNI5_js.l(x,"w","val");F!==void 0&&(e.numPr.ilvl=F);}}}let C=chunk3R7QHNI5_js.e(t,"w","outlineLvl");if(C){let m=chunk3R7QHNI5_js.l(C,"w","val");m!==void 0&&(e.outlineLevel=m);}let D=chunk3R7QHNI5_js.e(t,"w","pStyle");if(D){let m=chunk3R7QHNI5_js.j(D,"w","val");m&&(e.styleId=m);}let B=chunk3R7QHNI5_js.e(t,"w","suppressLineNumbers");B&&(e.suppressLineNumbers=chunk3R7QHNI5_js.m(B));let v=chunk3R7QHNI5_js.e(t,"w","suppressAutoHyphens");v&&(e.suppressAutoHyphens=chunk3R7QHNI5_js.m(v));let X=chunk3R7QHNI5_js.e(t,"w","rPr");return X&&(e.runProperties=q(X,n)),Object.keys(e).length>0?e:void 0}function j(t){if(!t)return;let n=chunk3R7QHNI5_js.l(t,"w","w"),e=chunk3R7QHNI5_js.j(t,"w","type");if(n!==void 0&&e)return {value:n,type:e}}function Ie(t){if(!t)return;let n={},e=E(chunk3R7QHNI5_js.e(t,"w","top"));e&&(n.top=e);let o=E(chunk3R7QHNI5_js.e(t,"w","bottom"));o&&(n.bottom=o);let i=E(chunk3R7QHNI5_js.e(t,"w","left"));i&&(n.left=i);let r=E(chunk3R7QHNI5_js.e(t,"w","right"));r&&(n.right=r);let a=E(chunk3R7QHNI5_js.e(t,"w","insideH"));a&&(n.insideH=a);let c=E(chunk3R7QHNI5_js.e(t,"w","insideV"));return c&&(n.insideV=c),Object.keys(n).length>0?n:void 0}function Re(t){if(!t)return;let n={},e=j(chunk3R7QHNI5_js.e(t,"w","top"));e&&(n.top=e);let o=j(chunk3R7QHNI5_js.e(t,"w","bottom"));o&&(n.bottom=o);let i=j(chunk3R7QHNI5_js.e(t,"w","left"));i&&(n.left=i);let r=j(chunk3R7QHNI5_js.e(t,"w","right"));return r&&(n.right=r),Object.keys(n).length>0?n:void 0}function _e(t){if(!t)return;let n={},e=chunk3R7QHNI5_js.j(t,"w","val");if(e){let d=parseInt(e,16);isNaN(d)||(n.firstRow=(d&32)!==0,n.lastRow=(d&64)!==0,n.firstColumn=(d&128)!==0,n.lastColumn=(d&256)!==0,n.noHBand=(d&512)!==0,n.noVBand=(d&1024)!==0);}let o=chunk3R7QHNI5_js.j(t,"w","firstColumn");o&&(n.firstColumn=o==="1");let i=chunk3R7QHNI5_js.j(t,"w","firstRow");i&&(n.firstRow=i==="1");let r=chunk3R7QHNI5_js.j(t,"w","lastColumn");r&&(n.lastColumn=r==="1");let a=chunk3R7QHNI5_js.j(t,"w","lastRow");a&&(n.lastRow=a==="1");let c=chunk3R7QHNI5_js.j(t,"w","noHBand");c&&(n.noHBand=c==="1");let g=chunk3R7QHNI5_js.j(t,"w","noVBand");return g&&(n.noVBand=g==="1"),Object.keys(n).length>0?n:void 0}function ue(t,n){if(!t)return;let e={},o=chunk3R7QHNI5_js.e(t,"w","tblW");o&&(e.width=j(o));let i=chunk3R7QHNI5_js.e(t,"w","jc");if(i){let f=chunk3R7QHNI5_js.j(i,"w","val");(f==="left"||f==="center"||f==="right")&&(e.justification=f);}let r=chunk3R7QHNI5_js.e(t,"w","tblCellSpacing");r&&(e.cellSpacing=j(r));let a=chunk3R7QHNI5_js.e(t,"w","tblInd");a&&(e.indent=j(a));let c=chunk3R7QHNI5_js.e(t,"w","tblBorders");c&&(e.borders=Ie(c));let g=chunk3R7QHNI5_js.e(t,"w","tblCellMar");g&&(e.cellMargins=Re(g));let d=chunk3R7QHNI5_js.e(t,"w","tblLayout");if(d){let f=chunk3R7QHNI5_js.j(d,"w","type");(f==="fixed"||f==="autofit")&&(e.layout=f);}let h=chunk3R7QHNI5_js.e(t,"w","tblStyle");if(h){let f=chunk3R7QHNI5_js.j(h,"w","val");f&&(e.styleId=f);}let y=chunk3R7QHNI5_js.e(t,"w","tblLook");y&&(e.look=_e(y));let u=chunk3R7QHNI5_js.e(t,"w","shd");u&&(e.shading=Z(u));let S=chunk3R7QHNI5_js.e(t,"w","bidiVisual");return S&&(e.bidi=chunk3R7QHNI5_js.m(S)),Object.keys(e).length>0?e:void 0}function de(t){if(!t)return;let n={},e=chunk3R7QHNI5_js.e(t,"w","trHeight");if(e){n.height=j(e);let c=chunk3R7QHNI5_js.j(e,"w","hRule");c&&(n.heightRule=c);}let o=chunk3R7QHNI5_js.e(t,"w","tblHeader");o&&(n.header=chunk3R7QHNI5_js.m(o));let i=chunk3R7QHNI5_js.e(t,"w","cantSplit");i&&(n.cantSplit=chunk3R7QHNI5_js.m(i));let r=chunk3R7QHNI5_js.e(t,"w","jc");if(r){let c=chunk3R7QHNI5_js.j(r,"w","val");(c==="left"||c==="center"||c==="right")&&(n.justification=c);}let a=chunk3R7QHNI5_js.e(t,"w","hidden");return a&&(n.hidden=chunk3R7QHNI5_js.m(a)),Object.keys(n).length>0?n:void 0}function pe(t,n){if(!t)return;let e={},o=chunk3R7QHNI5_js.e(t,"w","tcW");o&&(e.width=j(o));let i=chunk3R7QHNI5_js.e(t,"w","tcBorders");i&&(e.borders=Ie(i));let r=chunk3R7QHNI5_js.e(t,"w","tcMar");r&&(e.margins=Re(r));let a=chunk3R7QHNI5_js.e(t,"w","shd");a&&(e.shading=Z(a));let c=chunk3R7QHNI5_js.e(t,"w","vAlign");if(c){let f=chunk3R7QHNI5_js.j(c,"w","val");(f==="top"||f==="center"||f==="bottom")&&(e.verticalAlign=f);}let g=chunk3R7QHNI5_js.e(t,"w","textDirection");if(g){let f=chunk3R7QHNI5_js.j(g,"w","val");f&&(e.textDirection=f);}let d=chunk3R7QHNI5_js.e(t,"w","gridSpan");if(d){let f=chunk3R7QHNI5_js.l(d,"w","val");f!==void 0&&(e.gridSpan=f);}let h=chunk3R7QHNI5_js.e(t,"w","vMerge");if(h){let f=chunk3R7QHNI5_js.j(h,"w","val");e.vMerge=f==="restart"?"restart":"continue";}let y=chunk3R7QHNI5_js.e(t,"w","tcFitText");y&&(e.fitText=chunk3R7QHNI5_js.m(y));let u=chunk3R7QHNI5_js.e(t,"w","noWrap");u&&(e.noWrap=chunk3R7QHNI5_js.m(u));let S=chunk3R7QHNI5_js.e(t,"w","hideMark");return S&&(e.hideMark=chunk3R7QHNI5_js.m(S)),Object.keys(e).length>0?e:void 0}function Ze(t,n){let e={styleId:chunk3R7QHNI5_js.j(t,"w","styleId")??"",type:chunk3R7QHNI5_js.j(t,"w","type")??"paragraph"},o=chunk3R7QHNI5_js.j(t,"w","default");o&&(e.default=o==="1"||o==="true");let i=chunk3R7QHNI5_js.e(t,"w","name");i&&(e.name=chunk3R7QHNI5_js.j(i,"w","val")??void 0);let r=chunk3R7QHNI5_js.e(t,"w","basedOn");r&&(e.basedOn=chunk3R7QHNI5_js.j(r,"w","val")??void 0);let a=chunk3R7QHNI5_js.e(t,"w","next");a&&(e.next=chunk3R7QHNI5_js.j(a,"w","val")??void 0);let c=chunk3R7QHNI5_js.e(t,"w","link");c&&(e.link=chunk3R7QHNI5_js.j(c,"w","val")??void 0);let g=chunk3R7QHNI5_js.e(t,"w","uiPriority");if(g){let X=chunk3R7QHNI5_js.l(g,"w","val");X!==void 0&&(e.uiPriority=X);}let d=chunk3R7QHNI5_js.e(t,"w","hidden");d&&(e.hidden=chunk3R7QHNI5_js.m(d));let h=chunk3R7QHNI5_js.e(t,"w","semiHidden");h&&(e.semiHidden=chunk3R7QHNI5_js.m(h));let y=chunk3R7QHNI5_js.e(t,"w","unhideWhenUsed");y&&(e.unhideWhenUsed=chunk3R7QHNI5_js.m(y));let u=chunk3R7QHNI5_js.e(t,"w","qFormat");u&&(e.qFormat=chunk3R7QHNI5_js.m(u));let S=chunk3R7QHNI5_js.e(t,"w","personal");S&&(e.personal=chunk3R7QHNI5_js.m(S));let f=chunk3R7QHNI5_js.e(t,"w","pPr");f&&(e.pPr=te(f,n));let b=chunk3R7QHNI5_js.e(t,"w","rPr");b&&(e.rPr=q(b,n));let C=chunk3R7QHNI5_js.e(t,"w","tblPr");C&&(e.tblPr=ue(C));let D=chunk3R7QHNI5_js.e(t,"w","trPr");D&&(e.trPr=de(D));let B=chunk3R7QHNI5_js.e(t,"w","tcPr");B&&(e.tcPr=pe(B));let v=chunk3R7QHNI5_js.f(t,"w","tblStylePr");if(v.length>0){e.tblStylePr=[];for(let X of v){let m=chunk3R7QHNI5_js.j(X,"w","type");if(m){let x={type:m},F=chunk3R7QHNI5_js.e(X,"w","pPr");F&&(x.pPr=te(F,n));let k=chunk3R7QHNI5_js.e(X,"w","rPr");k&&(x.rPr=q(k,n));let A=chunk3R7QHNI5_js.e(X,"w","tblPr");A&&(x.tblPr=ue(A));let M=chunk3R7QHNI5_js.e(X,"w","trPr");M&&(x.trPr=de(M));let R=chunk3R7QHNI5_js.e(X,"w","tcPr");R&&(x.tcPr=pe(R)),e.tblStylePr.push(x);}}}return e}function qe(t,n){if(!t)return;let e={},o=chunk3R7QHNI5_js.e(t,"w","rPrDefault");if(o){let r=chunk3R7QHNI5_js.e(o,"w","rPr");r&&(e.rPr=q(r,n));}let i=chunk3R7QHNI5_js.e(t,"w","pPrDefault");if(i){let r=chunk3R7QHNI5_js.e(i,"w","pPr");r&&(e.pPr=te(r,n));}return e.rPr||e.pPr?e:void 0}function Je(t,n){if(!n)return t;if(!t)return n?{...n}:void 0;let e={...t};for(let o of Object.keys(n)){let i=n[o];if(i!==void 0)if(o==="runProperties")e.runProperties=chunkGSKMHXHG_js.b(e.runProperties,n.runProperties);else if(o==="borders"||o==="numPr"||o==="frame"){let r=e[o],a=i;e[o]={...r||{},...a||{}};}else o==="tabs"&&Array.isArray(i)?e.tabs=[...i]:e[o]=i;}return e}function Ee(t,n,e,o=new Set){if(o.has(t.styleId)||(o.add(t.styleId),!t.basedOn))return t;let i=n.get(t.basedOn);if(!i)return t;let r=Ee(i,n,e,o),a={...t,pPr:Je(r.pPr,t.pPr),rPr:chunkGSKMHXHG_js.b(r.rPr,t.rPr)};return t.type==="table"&&((r.tblPr||t.tblPr)&&(a.tblPr={...r.tblPr||{},...t.tblPr||{}}),(r.trPr||t.trPr)&&(a.trPr={...r.trPr||{},...t.trPr||{}}),(r.tcPr||t.tcPr)&&(a.tcPr={...r.tcPr||{},...t.tcPr||{}})),a}function me(t,n){let e=new Map;try{let o=chunk3R7QHNI5_js.c(t);if(!o)return e;let i=chunk3R7QHNI5_js.f(o,"w","style");for(let r of i){let a=Ze(r,n);a.styleId&&e.set(a.styleId,a);}for(let[r,a]of e){let c=Ee(a,e,n);e.set(r,c);}}catch(o){console.warn("Failed to parse styles:",o);}return e}function Ne(t,n){let e={styles:[]};try{let o=chunk3R7QHNI5_js.c(t);if(!o)return e;let i=chunk3R7QHNI5_js.e(o,"w","docDefaults");e.docDefaults=qe(i,n);let r=chunk3R7QHNI5_js.e(o,"w","latentStyles");r&&(e.latentStyles={defLockedState:chunk3R7QHNI5_js.j(r,"w","defLockedState")==="1",defUIPriority:chunk3R7QHNI5_js.l(r,"w","defUIPriority"),defSemiHidden:chunk3R7QHNI5_js.j(r,"w","defSemiHidden")==="1",defUnhideWhenUsed:chunk3R7QHNI5_js.j(r,"w","defUnhideWhenUsed")==="1",defQFormat:chunk3R7QHNI5_js.j(r,"w","defQFormat")==="1",count:chunk3R7QHNI5_js.l(r,"w","count")});let a=me(t,n);e.styles=Array.from(a.values());}catch(o){console.warn("Failed to parse style definitions:",o);}return e}var He=/\{([a-zA-Z_][a-zA-Z0-9_\-\.]*)\}/g;function Ve(t){let n=[],e;for(He.lastIndex=0;(e=He.exec(t))!==null;){let o=e[1].trim();o&&!n.includes(o)&&n.push(o);}return n}function ne(t){let n=[];for(let e of t)if(e.type==="paragraph"){let o=chunkLZTEPSU2_js.N(e),i=Ve(o);for(let r of i)n.includes(r)||n.push(r);}else if(e.type==="table"){let o=je(e);for(let i of o)n.includes(i)||n.push(i);}return n}function je(t){let n=[];for(let e of t.rows)for(let o of e.cells)for(let i of o.content)if(i.type==="paragraph"){let r=chunkLZTEPSU2_js.N(i),a=Ve(r);for(let c of a)n.includes(c)||n.push(c);}else if(i.type==="table"){let r=je(i);for(let a of r)n.includes(a)||n.push(a);}return n}function Qe(t,n){let e=[],o=[];for(let i of t)o.push(i),i.type==="paragraph"&&i.sectionProperties&&(e.push({properties:i.sectionProperties,content:o}),o=[]);return (o.length>0||e.length===0)&&e.push({properties:n??chunkLZTEPSU2_js.C(),content:o}),e}function oe(t,n=null,e=null,o=null,i=null,r=null){let a={content:[]};if(!t)return a;let c=chunk3R7QHNI5_js.a(t);if(!c)return a;let g=(c.elements??[]).find(u=>u.type==="element"&&(u.name==="w:document"||u.name?.endsWith(":document")));if(!g)return a;let d=chunk3R7QHNI5_js.e(g,"w","body");if(!d)return a;a.content=chunkLZTEPSU2_js.q(d,n,e,o,i,r);let h=chunk3R7QHNI5_js.e(d,"w","sectPr");h&&(a.finalSectionProperties=chunkLZTEPSU2_js.B(h,i));let y=Qe(a.content,a.finalSectionProperties);return a.sections=chunkLZTEPSU2_js.D(y),a.finalSectionProperties&&a.sections.length>0&&(a.finalSectionProperties=a.sections[a.sections.length-1].properties),a}function Ge(t){let n=new Map,e=chunk3R7QHNI5_js.a(t);if(!e)return n;let o=chunk3R7QHNI5_js.e(e,"w16cex","commentsExtensible")??e;for(let i of chunk3R7QHNI5_js.i(o)){if((i.name?.replace(/^.*:/,"")??"")!=="comment")continue;let a=chunk3R7QHNI5_js.j(i,"w16cex","paraId")??chunk3R7QHNI5_js.j(i,"w15","paraId")??i.attributes?.["w16cex:paraId"]??i.attributes?.["w15:paraId"],c=chunk3R7QHNI5_js.j(i,"w16cex","dateUtc")??chunk3R7QHNI5_js.j(i,"w15","dateUtc")??i.attributes?.["w16cex:dateUtc"]??i.attributes?.["w15:dateUtc"];a&&c&&n.set(String(a).toUpperCase(),String(c));}return n}function Ye(t){let n=new Map,e=new Map,o=chunk3R7QHNI5_js.a(t);if(!o)return {parentByParaId:n,doneByParaId:e};let i=chunk3R7QHNI5_js.e(o,"w15","commentsEx")??o;for(let r of chunk3R7QHNI5_js.i(i)){if((r.name?.replace(/^.*:/,"")??"")!=="commentEx")continue;let c=chunk3R7QHNI5_js.j(r,"w15","paraId")??r.attributes?.["w15:paraId"],g=chunk3R7QHNI5_js.j(r,"w15","paraIdParent")??r.attributes?.["w15:paraIdParent"],d=chunk3R7QHNI5_js.j(r,"w15","done")??r.attributes?.["w15:done"];if(c){let h=String(c).toUpperCase();g&&n.set(h,String(g).toUpperCase()),d==="1"&&e.set(h,true);}}return {parentByParaId:n,doneByParaId:e}}function Le(t,n,e,o,i,r,a){if(!t)return [];let c=chunk3R7QHNI5_js.a(t);if(!c)return [];let g=r?Ge(r):new Map,d=a?Ye(a):null,h=chunk3R7QHNI5_js.e(c,"w","comments")??c,y=chunk3R7QHNI5_js.i(h),u=[],S=[];for(let f of y){if((f.name?.replace(/^.*:/,"")??"")!=="comment")continue;let C=parseInt(chunk3R7QHNI5_js.j(f,"w","id")??"0",10),D=chunk3R7QHNI5_js.j(f,"w","author")??"Unknown",B=chunk3R7QHNI5_js.j(f,"w","initials"),v=B!=null?String(B):void 0,X=chunk3R7QHNI5_js.j(f,"w","date"),m=X!=null?String(X):void 0,x=chunk3R7QHNI5_js.j(f,"w14","paraId")??f.attributes?.["w14:paraId"]??chunk3R7QHNI5_js.j(f,"w","paraId"),k=(x?g.get(String(x).toUpperCase()):void 0)??m,A=chunk3R7QHNI5_js.j(f,"w","done")??f.attributes?.["w:done"],M=A==="1"||A==="true"?true:void 0,R=chunk3R7QHNI5_js.j(f,"w16cid","parentId")??chunk3R7QHNI5_js.j(f,"w","parentId")??f.attributes?.["w16cid:parentId"]??f.attributes?.["w:parentId"],H=R!=null?parseInt(String(R),10):void 0,U=[],N="";for(let V of chunk3R7QHNI5_js.i(f))if((V.name?.replace(/^.*:/,"")??"")==="p"){let p=chunkLZTEPSU2_js.O(V,n,e,null,o,i);U.push(p);let T=chunk3R7QHNI5_js.j(V,"w14","paraId")??V.attributes?.["w14:paraId"];T&&(N=String(T).toUpperCase());}M==null&&d&&N&&d.doneByParaId.get(N)&&(M=true),S.push(N),u.push({id:C,author:D,initials:v,date:k,content:U,...M!=null?{done:M}:{},...H!=null&&!isNaN(H)?{parentId:H}:{}});}if(d&&d.parentByParaId.size>0){let f=new Map;for(let b=0;b<u.length;b++){let C=S[b];C&&f.set(C,u[b].id);}for(let b=0;b<u.length;b++){if(u[b].parentId!=null)continue;let C=S[b];if(!C)continue;let D=d.parentByParaId.get(C);if(!D)continue;let B=f.get(D);B!=null&&(u[b]={...u[b],parentId:B});}}return u}function L(t,n){if(t)for(let e of t)if(e.type==="paragraph")e.content=e.content.filter(o=>o.type!=="commentRangeStart"&&o.type!=="commentRangeEnd"||n.has(o.id));else if(e.type==="table")for(let o of e.rows)for(let i of o.cells)L(i.content,n);else e.type==="blockSdt"&&L(e.content,n);}function Oe(t){let n=t.package,e=new Set((n.document.comments??[]).map(o=>o.id));L(n.document.content,e);for(let o of n.headers?.values()??[])L(o.content,e);for(let o of n.footers?.values()??[])L(o.content,e);for(let o of n.footnotes??[])L(o.content,e);for(let o of n.endnotes??[])L(o.content,e);for(let o of n.footnoteSeparators??[])L(o.content,e);for(let o of n.endnoteSeparators??[])L(o.content,e);}function Ke(t){let n=chunkB3SVS2AF_js.a();for(;t.has(n)||!chunkB3SVS2AF_js.b(n);)n=chunkB3SVS2AF_js.a();return n}function et(t,n){t.paraId!=null&&(n.has(t.paraId)&&(t.paraId=Ke(n)),n.add(t.paraId));}function O(t,n){if(t)for(let e of t)if(e.type==="paragraph")et(e,n);else if(e.type==="table")for(let o of e.rows)for(let i of o.cells)O(i.content,n);else e.type==="blockSdt"&&O(e.content,n);}function Ue(t){let n=t.package,e=new Set;O(n.document.content,e);for(let o of n.headers?.values()??[])O(o.content,e);for(let o of n.footers?.values()??[])O(o.content,e);for(let o of n.footnotes??[])O(o.content,e);for(let o of n.endnotes??[])O(o.content,e);for(let o of n.footnoteSeparators??[])O(o.content,e);for(let o of n.endnoteSeparators??[])O(o.content,e);}async function ze(t,n={}){let e=t instanceof ArrayBuffer?t:await chunkQVRMX2AC_js.u(t),{onProgress:o=()=>{},preloadFonts:i=true,parseHeadersFooters:r=true,parseNotes:a=true,detectVariables:c=true}=n,g=[];try{let u=function(T,I){let W=performance.now(),se=I(),$=performance.now()-W;return y.push({stage:T,ms:$}),$>1e3&&console.warn(`[parseDocx] ${T} took ${Math.round($)}ms`),se};var d=u;let h=performance.now(),y=[];async function S(T,I){let W=performance.now(),se=await I(),$=performance.now()-W;return y.push({stage:T,ms:$}),$>1e3&&console.warn(`[parseDocx] ${T} took ${Math.round($)}ms`),se}o("Extracting DOCX...",0);let f=await S("unzip",()=>K(e));o("Extracted DOCX",10),o("Parsing relationships...",10);let b=u("relationships",()=>f.documentRels?chunkZ3LGMBJC_js.b(f.documentRels):new Map);o("Parsed relationships",15),o("Parsing theme...",15);let C=u("theme",()=>chunkLZTEPSU2_js.a(f.themeXml));o("Parsed theme",20),o("Parsing styles...",20);let D=null,B;u("styles",()=>{f.stylesXml&&(D=me(f.stylesXml,C),B=Ne(f.stylesXml,C));}),o("Parsed styles",30),o("Parsing numbering...",30);let v=u("numbering",()=>chunkH57LNDBH_js.a(f.numberingXml)),X=u("settings",()=>chunkFIGLFSNR_js.b(f.settingsXml));o("Parsed numbering",35),o("Processing media files...",35);let m=u("media",()=>tt(f,b));o("Processed media",40),o("Parsing document body...",40);let x={content:[]};u("documentBody",()=>{f.documentXml?x=oe(f.documentXml,D,C,v,b,m):g.push("No document.xml found in DOCX");}),o("Parsed document body",55);let F,k;if(r){o("Parsing headers/footers...",55);let T=u("headersFooters",()=>nt(f,D,C,v,b,m));F=T.headers,k=T.footers,o("Parsed headers/footers",65);}else o("Skipping headers/footers",65);let A,M,R,H;if(a){o("Parsing footnotes/endnotes...",65);let T=u("footnotesEndnotes",()=>ot(f,D,C,v,b,m));A=T.footnotes,M=T.endnotes,R=T.footnoteSeparators,H=T.endnoteSeparators,o("Parsed footnotes/endnotes",75);}else o("Skipping footnotes/endnotes",75);o("Parsing comments...",75);let U=u("comments",()=>Le(f.commentsXml,D,C,b,m,f.commentsExtensibleXml,f.commentsExtendedXml));U.length>0&&(x.comments=U);let N;c?(o("Detecting template variables...",75),N=u("variables",()=>ne(x.content)),o("Detected variables",80)):o("Skipping variable detection",80),i?(o("Loading fonts...",80),await S("fonts",()=>rt(C,B,x)),o("Loaded fonts",95)):o("Skipping font loading",95),o("Assembling document...",95);let z={package:{document:x,styles:B,theme:C,numbering:v.definitions,settings:X,headers:F,footers:k,footnotes:A,endnotes:M,footnoteSeparators:R,endnoteSeparators:H,relationships:b,media:m},originalBuffer:e,templateVariables:N,warnings:g.length>0?g:void 0};Oe(z),Ue(z);let p=performance.now()-h;if(p>2e3){let T=y.filter(I=>I.ms>100).map(I=>`${I.stage}: ${Math.round(I.ms)}ms`).join(", ");console.warn(`[parseDocx] Total: ${Math.round(p)}ms`+(T?` (${T})`:""));}return o("Complete",100),z}catch(h){let y=h instanceof Error?h.message:String(h);throw console.error("[parseDocx] Failed to parse DOCX:",y,h),new Error(`Failed to parse DOCX: ${y}`)}}function tt(t,n){let e=new Map;for(let[o,i]of t.media.entries()){let r=o.split("/").pop()||o,a=Ae(o),c=new Uint8Array(i),g="";for(let S=0;S<c.length;S++)g+=String.fromCharCode(c[S]);let d=btoa(g),h=`data:${a};base64,${d}`,y={path:o,filename:r,mimeType:a,data:i,dataUrl:h};e.set(o,y);let u=o.replace(/^word\//,"");u!==o&&e.set(u,y);}return e}function re(t,n){let e=n.toLowerCase();for(let[o,i]of t.entries())if(o.toLowerCase()===e)return i}function nt(t,n,e,o,i,r){let a=new Map,c=new Map;for(let[g,d]of i.entries())if(d.type===chunkZ3LGMBJC_js.a.header&&d.target){let h=d.target.split("/").pop()||d.target,y=re(t.headers,h);if(y){let u=`word/_rels/${h}.rels`,S=re(t.allXml,u),f=S?chunkZ3LGMBJC_js.b(S):i,b=chunkLZTEPSU2_js.r(y,"default",n,e,o,f,r);a.set(g,b);}}else if(d.type===chunkZ3LGMBJC_js.a.footer&&d.target){let h=d.target.split("/").pop()||d.target,y=re(t.footers,h);if(y){let u=`word/_rels/${h}.rels`,S=re(t.allXml,u),f=S?chunkZ3LGMBJC_js.b(S):i,b=chunkLZTEPSU2_js.s(y,"default",n,e,o,f,r);c.set(g,b);}}return {headers:a,footers:c}}function ot(t,n,e,o,i,r){let a=chunkLZTEPSU2_js.t(t.footnotesXml,n,e,o,i,r),c=chunkLZTEPSU2_js.u(t.endnotesXml,n,e,o,i,r);return {footnotes:a.getNormalFootnotes(),endnotes:c.getNormalEndnotes(),footnoteSeparators:a.footnotes.filter(chunkLZTEPSU2_js.z),endnoteSeparators:c.endnotes.filter(chunkLZTEPSU2_js.A)}}async function rt(t,n,e){let o=new Set;if(t?.fontScheme){let{majorFont:i,minorFont:r}=t.fontScheme;i?.latin&&o.add(i.latin),r?.latin&&o.add(r.latin);}if(n?.docDefaults?.rPr?.fontFamily?.ascii&&o.add(n.docDefaults.rPr.fontFamily.ascii),n?.styles)for(let i of n.styles)i.rPr?.fontFamily?.ascii&&o.add(i.rPr.fontFamily.ascii),i.rPr?.fontFamily?.hAnsi&&o.add(i.rPr.fontFamily.hAnsi);if(e.content){for(let i of e.content)if(i.type==="paragraph")for(let r of i.content)r.type==="run"&&r.formatting?.fontFamily&&(r.formatting.fontFamily.ascii&&o.add(r.formatting.fontFamily.ascii),r.formatting.fontFamily.hAnsi&&o.add(r.formatting.fontFamily.hAnsi));}if(o.size>0)try{await chunkQVRMX2AC_js.q(Array.from(o));}catch(i){console.warn("Failed to load some fonts:",i);}}async function qt(t){return ze(t,{preloadFonts:false,parseHeadersFooters:false,parseNotes:false,detectVariables:true})}async function Jt(t,n){return ze(t,{onProgress:n,preloadFonts:true,parseHeadersFooters:true,parseNotes:true,detectVariables:true})}async function Qt(t){let n=await K(t);if(!n.documentXml)return [];let e=oe(n.documentXml);return ne(e.content)}async function Gt(t){let n=await K(t),e=n.documentXml?ne(oe(n.documentXml).content):[];return {hasDocument:n.documentXml!==null,hasStyles:n.stylesXml!==null,hasTheme:n.themeXml!==null,hasNumbering:n.numberingXml!==null,headerCount:n.headers.size,footerCount:n.footers.size,mediaCount:n.media.size,variableCount:e.length}}
|
|
2
|
+
exports.a=ze;exports.b=qt;exports.c=Jt;exports.d=Qt;exports.e=Gt;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {g,a as a$1,c,d,e,f,b,q as q$1,n as n$1}from'./chunk-
|
|
1
|
+
import {g,a as a$1,c,d,e,f,b,q as q$1,n as n$1}from'./chunk-OBRTIXHC.mjs';import {h,j as j$1,l,m,n}from'./chunk-25775MLP.mjs';import {a}from'./chunk-W77JXDEV.mjs';function Z(e,s){let r=G(s),t=new RegExp(`<w:p[\\s][^>]*w14:paraId="${r}"`,"g"),o=[],i;for(;(i=t.exec(e))!==null;)o.push(i.index);if(o.length===0||o.length>1)return null;let l=o[0],n=l,a=0;for(;n<e.length;){let m=e.indexOf("<",n);if(m===-1)break;if(e.startsWith("<w:p",m)){let y=e[m+4];if(y===">"||y===" "||y==="/"){let f=e.indexOf(">",m);if(f===-1)break;if(e[f-1]==="/"){if(a===0)return {start:l,end:f+1};n=f+1;}else a++,n=f+1;}else n=m+1;}else if(e.startsWith("</w:p>",m)){if(a--,a===0)return {start:l,end:m+6};n=m+6;}else n=m+1;}return null}function j(e,s){let r=Z(e,s);return r?e.substring(r.start,r.end):null}function H(e){let s=0,r=/<w:p[\s>]/g,t;for(;(t=r.exec(e))!==null;){let o=t.index,i=e[o+4];(i===">"||i===" ")&&s++;}return s}function W(e){let s=new Map,r=/w14:paraId="([^"]+)"/g,t;for(;(t=r.exec(e))!==null;){let o=t[1];s.set(o,(s.get(o)||0)+1);}return s}function q(e,s,r){if(r.size===0)return {safe:true};let t=W(e),o=W(s);for(let n of r){let a=t.get(n)||0;if(a===0)return {safe:false,reason:`paraId-not-found-in-original: ${n}`};if(a>1)return {safe:false,reason:`duplicate-paraId-in-original: ${n}`}}for(let n of r){let a=o.get(n)||0;if(a===0)return {safe:false,reason:`paraId-not-found-in-serialized: ${n}`};if(a>1)return {safe:false,reason:`duplicate-paraId-in-serialized: ${n}`}}let i=H(e),l=H(s);return i!==l?{safe:false,reason:`paragraph-count-mismatch: original=${i}, serialized=${l}`}:{safe:true}}function J(e,s,r){if(r.size===0)return e;if(!q(e,s,r).safe)return null;let o=[];for(let l of r){let n=Z(e,l);if(!n)return null;let a=j(s,l);if(!a)return null;o.push({start:n.start,end:n.end,newXml:a});}o.sort((l,n)=>n.start-l.start);let i=e;for(let{start:l,end:n,newXml:a}of o)i=i.substring(0,l)+a+i.substring(n);return i}function G(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function L(e){let s=r=>r.content.some(t=>t.type==="drawing"&&t.image?.src?.startsWith("data:")&&!t.image?.rId);for(let r of e)if(r.type==="paragraph")for(let t of r.content)if(t.type==="run"){if(s(t))return true}else {if(t.type==="hyperlink"&&t.href&&!t.rId&&!t.anchor)return true;if(t.type==="insertion"||t.type==="deletion"||t.type==="moveFrom"||t.type==="moveTo"){for(let o of t.content)if(o.type==="run"&&s(o))return true}}else if(r.type==="table"){for(let t of r.rows)for(let o of t.cells)if(L(o.content))return true}return false}async function oe(e$1,s,r){let{changedParaIds:t,structuralChange:o,hasUntrackedChanges:i}=r;if(o||i||!s)return null;let l$1=e$1.package.document.content;if(L(l$1))return null;let n$2=e$1.package.document.comments,a$2=n$2&&n$2.length>0,m$1=g(e$1);try{let f$1=await(await import('jszip')).default.loadAsync(s),u=new Map,I=e$1.package.relationships;if(I)for(let c of I.values()){if(!c.target||c.type!==a.header&&c.type!==a.footer)continue;let d=a$1(c.target).replace(/^\//,"");if(!f$1.file(d))return null}if(t.size>0){let c=f$1.file("word/document.xml");if(!c)return null;let d=await c.async("text"),w=h(e$1),x=J(d,w,t);if(!x)return null;u.set("word/document.xml",x);}if(a$2){let{xml:c$1,paraInfos:d$1}=j$1(n$2);u.set("word/comments.xml",c$1);let w=l(d$1);w&&u.set("word/commentsExtended.xml",w);let x=m(d$1);x&&u.set("word/commentsIds.xml",x);let S=n(d$1,n$2);S&&u.set("word/commentsExtensible.xml",S);let N=f$1.file("[Content_Types].xml");if(N){let p=u.get("[Content_Types].xml")??await N.async("text"),h=!1,C=[["/word/comments.xml",c],["/word/commentsExtended.xml",d],["/word/commentsIds.xml",e],["/word/commentsExtensible.xml",f]];for(let[E,b]of C)p.includes(E)||(p=p.replace("</Types>",`<Override PartName="${E}" ContentType="${b}"/></Types>`),h=!0);h&&u.set("[Content_Types].xml",p);}let T="word/_rels/document.xml.rels",O=f$1.file(T);if(O){let p=u.get(T)??await O.async("text"),h=!1,C=[["comments.xml",a.comments],["commentsExtended.xml",a.commentsExtended],["commentsIds.xml",a.commentsIds],["commentsExtensible.xml",a.commentsExtensible]];for(let[E,b$1]of C)if(!p.includes(E)){let V=b(p);p=p.replace("</Relationships>",`<Relationship Id="rId${V+1}" Type="${b$1}" Target="${E}"/></Relationships>`),h=!0;}h&&u.set(T,p);}}for(let[c,d]of m$1)u.set(c,d);let P=f$1.file("docProps/core.xml");if(P){let c=await P.async("text");u.set("docProps/core.xml",q$1(c,{updateModifiedDate:!0}));}return await n$1(f$1,u)}catch{return null}}
|
|
2
2
|
export{q as a,J as b,oe as c};
|