revise 2.0.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +195 -0
- package/README.md +4 -1
- package/assets/historyMaterializeWorker-B51R08XN.js +612 -0
- package/backend.d.ts +8 -2
- package/backend.js +3 -1
- package/chunks/AgentPageRenderer-CH8kSTJn.js +1 -0
- package/chunks/AgentPageRenderer-P23XVguo.js +1 -0
- package/chunks/AttachmentDocumentImporter-B1WOaa7d.js +1 -0
- package/chunks/AttachmentDocumentImporter-CT_PJp_e.js +1 -0
- package/chunks/BidiText-Swm5fl9J.js +160 -0
- package/chunks/ColorParserFull-BKH72fK8.js +446 -1
- package/chunks/DocumentMutator-btiDK57e.js +31 -0
- package/chunks/DocumentScrubber-CMPfm_HF.js +18 -0
- package/chunks/{DocumentScrubber-DrgzBlx4.js → DocumentScrubber-Cm2kH8op.js} +1 -1
- package/chunks/{DocumentScrubber-W0EfGmL-.js → DocumentScrubber-bJoKijol.js} +1 -1
- package/chunks/DocumentStylesheet-DreoD7sD.js +7 -0
- package/chunks/DocxConverter-BcVG-p5K.js +13 -0
- package/chunks/DocxConverter-D2bO5RE-.js +1125 -0
- package/chunks/DocxConverter-haCfRuWb.js +13 -0
- package/chunks/{DocxGraft-B6W7fbh4.js → DocxGraft-BRKh4mHQ.js} +1 -1
- package/chunks/DocxGraft-BxSQtl12.js +7 -0
- package/chunks/{DocxGraft-Cj7v78BO.js → DocxGraft-C9MBQCnf.js} +1 -1
- package/chunks/FileImporter-CszqRfVU.js +1 -0
- package/chunks/FileImporter-DObFoCCn.js +1 -0
- package/chunks/HorizontalRuleOrnaments-gmUZ3R7Q.js +3 -1
- package/chunks/HtmlConverter-DwXB4IDh.js +267 -0
- package/chunks/ListNumbering-Qlu6AuRZ.js +23 -1
- package/chunks/MarkdownConverter-CUC8GgsS.js +57 -0
- package/chunks/MathRenderer-DT6GyJXb.js +68 -0
- package/chunks/OdtConverter-7h9HHMpL.js +125 -0
- package/chunks/OdtConverter-Ct4qypJk.js +6 -0
- package/chunks/OdtConverter-DFl__sJc.js +6 -0
- package/chunks/OfficeImportShared-BY6FdZ8d.js +1 -0
- package/chunks/OfficeImportShared-BrZoDM0j.js +30 -0
- package/chunks/OfficeImportShared-Bvm-mOyj.js +1 -0
- package/chunks/ParagraphDiffAnalysis-DrmStvmz.js +36 -0
- package/chunks/PdfConverter-1wyvoT7X.js +21 -0
- package/chunks/PdfConverter-BAoEHILo.js +21 -0
- package/chunks/PdfConverter-CKEvFj11.js +448 -0
- package/chunks/{PdfImportService-Dj1-3L2B.js → PdfImportService-BhLPp5uG.js} +2 -2
- package/chunks/{PdfImportService-OE9G383I.js → PdfImportService-xbzrN__L.js} +2 -2
- package/chunks/RtfConverter-Bxn-enp8.js +15 -0
- package/chunks/RtfConverter-LZPzBDSr.js +15 -0
- package/chunks/RtfConverter-_bacXqr1.js +186 -0
- package/chunks/TableBorders-CwnF3jvH.js +30 -0
- package/chunks/TableGrid-DbroRucl.js +12 -0
- package/chunks/TextFileDecoder--rsVs3NR.js +9 -2
- package/chunks/{TxtConverter-BYazsp6P.js → TxtConverter-C7FOwHpH.js} +5 -2
- package/chunks/UnicodeUtils-CXtusU4g.js +10 -0
- package/chunks/XmlConverter-7oo8oeQB.js +2 -0
- package/chunks/XmlConverter-DGORHJcZ.js +96 -0
- package/chunks/XmlConverter-DeLHReK_.js +2 -0
- package/chunks/_commonjsHelpers-DaMA6jEr.js +2 -1
- package/chunks/_revise-sdk-lazy-harfbuzz-CDWdjF9f.js +1 -1
- package/chunks/_revise-sdk-lazy-harfbuzz-X8gnYTZL.js +1 -1
- package/chunks/ar-ComXvtmh.js +13 -0
- package/chunks/backend-DecaBz-I.js +490 -0
- package/chunks/base64-sSPOzq-u.js +198 -0
- package/chunks/browser-module-CFmqfGkE.js +1791 -3
- package/chunks/{browser-module-BbaxnHNK.js → browser-module-Dj5o3kuL.js} +1 -1
- package/chunks/{browser-module-D2ixluMg.js → browser-module-UuM_O36W.js} +1 -1
- package/chunks/bundle.min-DRpfgV69.js +779 -5
- package/chunks/capture-1btcWcPF.js +9 -0
- package/chunks/carrier-DQeng6yq.js +6 -0
- package/chunks/de-BkbpIKxx.js +13 -0
- package/chunks/es-CKkXujOF.js +13 -0
- package/chunks/fil-piIHMc8F.js +13 -0
- package/chunks/footnoteFlatten-DUQticYy.js +6 -0
- package/chunks/fr-DuA8qLje.js +13 -0
- package/chunks/graftExport-CYnStOdU.js +82 -0
- package/chunks/html2canvas.esm-CntiHiYW.js +994 -2
- package/chunks/index-2TBhRkX7.js +387 -0
- package/chunks/index-BWdRWxoH.js +1796 -13
- package/chunks/index-Bf14eTEW.js +1096 -0
- package/chunks/index-BwcX_r62.js +387 -0
- package/chunks/index.es-CI0QPo8w.js +780 -5
- package/chunks/{index.es-B97tjxvW.js → index.es-CI7cDExj.js} +1 -1
- package/chunks/{index.es-mTU7Sl3w.js → index.es-DHpGt6Y5.js} +1 -1
- package/chunks/ja-DgrSs555.js +13 -0
- package/chunks/{jspdf.es.min-Mykp4BZO.js → jspdf.es.min--GshOuIm.js} +1 -1
- package/chunks/jspdf.es.min-DU74zN8b.js +1747 -32
- package/chunks/{jspdf.es.min-DGiD4mlU.js → jspdf.es.min-DurJZ1zW.js} +1 -1
- package/chunks/jszip.min-CPW0h1Kx.js +476 -2
- package/chunks/katex-DWj8TvwO.js +1209 -8
- package/chunks/pdf-BLWDCiFF.js +1826 -10
- package/chunks/pseudoLocale-BoYTjmiK.js +1 -0
- package/chunks/pseudoLocale-DG2NnZmz.js +1 -0
- package/chunks/purify.es-BwLardii.js +107 -2
- package/chunks/serverDocumentSession-CJ1EH3Tp.js +15 -0
- package/chunks/signatures-Bwt_OGik.js +17 -0
- package/chunks/suggestionAuthorship-B-IuLQlE.js +1 -0
- package/chunks/tree-sitter-D6zWWUMP.js +1 -1
- package/chunks/web-tree-sitter-BXGZGnNj.js +2 -1
- package/chunks/zh-9OF3SWWO.js +13 -0
- package/full.js +1 -1
- package/index.d.ts +42 -15
- package/index.js +1 -1
- package/package.json +1 -1
- package/root.js +2 -2
- package/serverToolContract.d.ts +21 -3
- package/serverToolInputs.generated.d.ts +23 -2
- package/style.css +1 -1
- package/assets/historyMaterializeWorker-C4uxcZEh.js +0 -3
- package/chunks/AgentPageRenderer-BIf_Fza8.js +0 -1
- package/chunks/AgentPageRenderer-DT9sNxEn.js +0 -1
- package/chunks/AttachmentDocumentImporter-BUavYRxO.js +0 -1
- package/chunks/AttachmentDocumentImporter-DGwfDJSH.js +0 -1
- package/chunks/BidiText-D7LYTAUL.js +0 -1
- package/chunks/DocumentMutator-CjN7Kk-X.js +0 -31
- package/chunks/DocumentScrubber-C9ZZEcYW.js +0 -1
- package/chunks/DocumentStylesheet-byN5dtC6.js +0 -1
- package/chunks/DocxConverter-Be3uPNcD.js +0 -11
- package/chunks/DocxConverter-CGYMfz-j.js +0 -11
- package/chunks/DocxConverter-DabDLfsu.js +0 -11
- package/chunks/DocxGraft-Duvo2cpy.js +0 -1
- package/chunks/FileImporter-CjUX2S4s.js +0 -1
- package/chunks/FileImporter-DtkbI6rF.js +0 -1
- package/chunks/HtmlConverter-ikXImzTY.js +0 -61
- package/chunks/MarkdownConverter-CFrcLyO_.js +0 -17
- package/chunks/MathRenderer-B0Y1h1JU.js +0 -33
- package/chunks/OdtConverter-BFT_P8SI.js +0 -1
- package/chunks/OdtConverter-Cnda9T0q.js +0 -1
- package/chunks/OdtConverter-WdwwXKVM.js +0 -1
- package/chunks/PdfConverter-D7UM58vc.js +0 -21
- package/chunks/PdfConverter-TB-QPw29.js +0 -21
- package/chunks/PdfConverter-wVP63986.js +0 -21
- package/chunks/RtfConverter-D-oqPWNl.js +0 -14
- package/chunks/RtfConverter-D9zhE07-.js +0 -14
- package/chunks/RtfConverter-DZgwU-_R.js +0 -14
- package/chunks/TableBorders-BorZS8aZ.js +0 -1
- package/chunks/TableGrid-DVWaRZv0.js +0 -1
- package/chunks/ar-C8zx2RwP.js +0 -8
- package/chunks/backend-MFpDFVrD.js +0 -1
- package/chunks/base64-BNMNG-lN.js +0 -1
- package/chunks/capture-qC26xmfy.js +0 -1
- package/chunks/carrier-BWONvrA7.js +0 -1
- package/chunks/de-ByQFqecF.js +0 -8
- package/chunks/es-PHpJXv5S.js +0 -8
- package/chunks/footnoteFlatten-Bdnn_bz1.js +0 -1
- package/chunks/graftExport-CP3h2T88.js +0 -2
- package/chunks/index-CjeGoI2g.js +0 -351
- package/chunks/index-D7V8zn4w.js +0 -36
- package/chunks/index-DyOcu9mD.js +0 -351
- package/chunks/pseudoLocale-C90lXrPg.js +0 -1
- package/chunks/pseudoLocale-UA_TkGrH.js +0 -1
- package/chunks/serverDocumentSession-CRZSb5SO.js +0 -11
- package/chunks/signatures-CsL_TjvW.js +0 -1
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import{M as bt,N as ee,O as Ve,m as ze,P as xt,Q as Et,E as Xe,F as $e,R as Ue,g as be,y as _e,T as rt,U as Qe,V as Ze,W as me,X as qe,x as Je,Y as xe,Z as Ke,_ as ke,$ as je,A as ye,z as to}from"./index-Bf14eTEW.js";
|
|
2
|
+
import{ai as Me,bk as vt,bv as eo,Z as we,bu as oo,a as no,t as ao,r as ro,bg as so,bi as io,aa as lo,bn as co,bo as oe}from"./backend-DecaBz-I.js";import{L as go,v as uo,w as ho}from"./BidiText-Swm5fl9J.js";
|
|
3
|
+
import{b as po,c as fo}from"./TableGrid-DbroRucl.js";import{r as bo,t as mo}from"./TableBorders-CwnF3jvH.js";const Ye=48,xo=10;function Se(o,t,e,a,c){const u=(e.columnCount??1)>1?Math.max(1,e.pageWidth-
|
|
4
|
+
bt(e)-ee(e)):e.availableWidth,s=u/3,p=c??o.children,h=[0,1,2].map(Y=>{const f=p[Y];if(!f)return Ye;if(f.borders)return u;const b=Ve(f,t,e,a)+xo;return Math.max(Ye,Math.min(b,u))}),k=[s,s,s],H=h.map((Y,f)=>Math.
|
|
5
|
+
max(0,Y-k[f])),x=h.map((Y,f)=>Math.max(0,k[f]-Y)),m=H.reduce((Y,f)=>Y+f,0),v=x.reduce((Y,f)=>Y+f,0);if(m>0&&v>0){const Y=Math.min(m,v);for(let f=0;f<3;f++)H[f]>0?k[f]+=H[f]/m*Y:x[f]>0&&(k[f]-=x[f]/v*Y)}
|
|
6
|
+
const F=[0,1,2].map(Y=>{const f=p[Y];return!f||!f.children.some(b=>b.type==="text"&&b.text!=="")});for(let Y=0;Y<3;Y++){let f=h[Y]-k[Y];if(!(f<=0||F[Y]))for(let b=0;b<3&&f>0;b++){if(b===Y||!F[b])continue;
|
|
7
|
+
const R=Math.min(k[b],f);k[b]-=R,k[Y]+=R,f-=R}}return[k[0],k[1],k[2]]}function ne(o){if(o.type!=="paragraph")return{keepNext:!1,keepLines:!1,widowControl:!1};const t=o;return{keepNext:t.keepNext??!!t.
|
|
8
|
+
heading,keepLines:!!t.keepLines,widowControl:t.widowControl!==!1}}const ae=3;function ko(o,t){const e=[];let a=[];for(const c of o)a.push(c),c.type==="section-break"&&(e.push({blocks:a,rawSettings:c.layout}),
|
|
9
|
+
a=[]);return e.push({blocks:a,rawSettings:t}),e}function Ie(o,t,e){if(!e)return{...o};const a=we(t,e),{pageWidth:c,pageHeight:u}=no(a),s=a.columnCount,p=ao(a.columnGapTwips),h=Math.max(1,c-a.marginLeftPx-
|
|
10
|
+
a.marginRightPx);return{...o,pageWidth:c,pageHeight:u,pageMargin:a.marginLeftPx,pageMarginTop:a.marginTopPx,pageMarginRight:a.marginRightPx,pageMarginBottom:a.marginBottomPx,pageMarginLeft:a.marginLeftPx,
|
|
11
|
+
availableWidth:be(h,s,p),columnCount:s,columnGapPx:p,textStartY:a.marginTopPx,hyphenationEnabled:a.hyphenationEnabled,lineNumbering:a.lineNumbering}}const yo=32,Mo=co.paddingPx;function wo(o,t,e){const a=ze(),
|
|
12
|
+
c=(n,r)=>({doc:o,layout:n,textContext:t,registry:a,blocks:[],fragments:[],currentY:r,currentPage:1,totalHeight:r,pageStep:n.pageless?0:n.pageHeight+n.pageSpacing,nextBlockIndex:0,pageBreakListeners:[],
|
|
13
|
+
suppressTopSpacingForNextBlock:!1}),u=(n,r,g=!1)=>{const l=ko(n,o.pageLayout),i=l.map((X,tt)=>tt===l.length-1?Ie(r,o.pageLayout,o.pageLayout):Ie(r,o.pageLayout,X.rawSettings)),d=i.some(X=>(X.columnCount??
|
|
14
|
+
1)>1);if(l.length===1&&!d||r.pageless){const X=c(r,Et(r));return r.lineNumbering&&!r.pageless&&(X.lineNumberMarks=[]),X.trackLineExtents=g,Wt({state:X,blocks:n,x:bt(r),layoutForLevel:r,suppressTopSpacingForFirstBlock:!0}),
|
|
15
|
+
X.totalHeight=X.currentY,r.pageless||(X.sectionRuntime={runs:[{blocks:n,rawSettings:o.pageLayout}],layouts:[r],startPageIndexes:[0],sectionStartTops:[0]}),X}const M=[],I=[],w=c(i[0],0);w.blocks=[],w.fragments=
|
|
16
|
+
[],w.currentY=0,w.totalHeight=0,w.currentPage=1,w.trackLineExtents=g,i.some(X=>X.lineNumbering)&&(w.lineNumberMarks=[]);let P=-1,z=0,Z=null,S=0,Q=!1;const ht=()=>{Q||(Q=!0,console.warn("Column layout \
|
|
17
|
+
projection clamped a fragment outside its pagination window; a column may render overflowing content."))},G=X=>{const tt=X.blocks[X.blocks.length-1];return tt?.type==="section-break"?tt:void 0};return l.
|
|
18
|
+
forEach((X,tt)=>{const V=i[tt],Mt=tt>0?G(l[tt-1]):void 0,et=tt>0&&Mt?.breakType==="continuous",It=Xe(et,Z&&{width:Z.pageWidth,height:Z.pageHeight},{width:V.pageWidth,height:V.pageHeight}),C=It?P:P+1,ot=It?
|
|
19
|
+
z:Z?z+Z.pageHeight+Z.pageSpacing:0,wt=It?$e(S,Ue(V,0),ot,Et(V)):ot+Et(V);V.sectionStartY=ot,V.sectionFirstPageIndex=C,M.push(C),I.push(ot);const Ht=Math.max(1,Math.round(V.columnCount??1)),Ot=Math.max(
|
|
20
|
+
0,V.columnGapPx??eo),pt=be(V.pageWidth-bt(V)-ee(V),Ht,Ot),$t=Je(pt,Ot),Rt=V.pageHeight+V.pageSpacing,zt=Et(V),Yt=B=>{const $=new Map,nt=U=>{const O=Math.floor(U/Ht),L=U%Ht,at=C+O,ft=O===0?wt-ot:zt,Lt=xe(
|
|
21
|
+
V,at),At=V.pageHeight-xt(V)-Lt,Bt=B?.pageOffset===O?Math.min(At,ft+B.height):At;return{top:U*Rt+ft,bottom:U*Rt+Bt,full:B?.pageOffset!==O&&ft<=zt&&Lt<=0,pageIndex:O,columnIndex:L,actualContentTop:ot+O*
|
|
22
|
+
Rt+ft}},N=U=>{let O=$.get(U);return O||(O=nt(U),$.set(U,O)),O};return{at:N,indexForY:U=>{if(N(0).top>U+rt)return 0;let O=1;for(;N(O).top<=U+rt;)O*=2;let L=O>>1,at=L;for(;L<=O;){const ft=L+O>>1;N(ft).top<=
|
|
23
|
+
U+rt?(at=ft,L=ft+1):O=ft-1}return at}}},Ee=new Map,le=(B,$)=>{const nt={...V,sectionStartY:0,sectionFirstPageIndex:0,availableWidth:pt,columnCount:Ht,columnGapPx:Ot,flowWindows:B},N=c(nt,B.at(0).top);
|
|
24
|
+
N.nextBlockIndex=w.nextBlockIndex,N.trackLineExtents=g,N.boundsMemo=Ee,V.lineNumbering&&(N.lineNumberMarks=[]);const U=$?.resume;if(U){const{snapshot:L,from:at}=U;N.blocks=at.blocks.slice(0,L.blocksLen),
|
|
25
|
+
N.fragments=at.fragments.slice(0,L.fragmentsLen),N.currentY=L.currentY,N.currentPage=L.currentPage,N.totalHeight=L.totalHeight,N.nextBlockIndex=L.nextBlockIndex,N.suppressTopSpacingForNextBlock=L.suppressTopSpacingForNextBlock,
|
|
26
|
+
N.lastLineTail=L.lastLineTail,N.lineNumberMarks&&at.lineNumberMarks&&(N.lineNumberMarks=at.lineNumberMarks.slice(0,L.lineNumberMarksLen))}const O=$?.recordSnapshots;return Wt({state:N,blocks:U?X.blocks.
|
|
27
|
+
slice(U.snapshot.blockCount):X.blocks,x:bt(V),layoutForLevel:nt,suppressTopSpacingForFirstBlock:!U,onBlockLaidOut:O?L=>{O.push({blockCount:L+1,blocksLen:N.blocks.length,fragmentsLen:N.fragments.length,
|
|
28
|
+
currentY:N.currentY,currentPage:N.currentPage,totalHeight:N.totalHeight,nextBlockIndex:N.nextBlockIndex,suppressTopSpacingForNextBlock:N.suppressTopSpacingForNextBlock,lastLineTail:N.lastLineTail,lineNumberMarksLen:N.
|
|
29
|
+
lineNumberMarks?.length??0})}:void 0}),N.totalHeight=N.currentY,N},Kt=(B,$)=>B.indexForY(Math.max($.currentY-rt,B.at(0).top)),Oe=G(X)?.breakType==="continuous",ce=_e(Ht,Oe)&&X.blocks.length>0;let Ft=Yt();
|
|
30
|
+
const ge=[];let Tt=le(Ft,ce?{recordSnapshots:ge}:void 0),jt=Kt(Ft,Tt);if(ce){const B=Ft.at(jt).pageIndex,$=B*Ht,nt=Ft.at($),N=Math.max(1,nt.bottom-nt.top),U=Ft.at(Math.max(0,$-1)).top;let O;for(const Bt of ge)
|
|
31
|
+
if(Bt.currentY<U-rt)O=Bt;else break;const L=O?{resume:{snapshot:O,from:Tt}}:void 0;let at=1,ft=Math.ceil(N),Lt=Tt,At=Ft;for(let Bt=0;Bt<11&&at<=ft;Bt++){const Vt=Math.ceil((at+ft)/2),Qt=Yt({pageOffset:B,
|
|
32
|
+
height:Vt}),fe=le(Qt,L),Ge=Kt(Qt,fe);Qt.at(Ge).pageIndex<=B?(Lt=fe,At=Qt,ft=Vt-1):at=Vt+1}Tt=Lt,Ft=At,jt=Kt(Ft,Tt)}const Ut=B=>{const $=Ft.indexForY(B),nt=Ft.at($);return{windowIndex:$,window:nt,xOffset:nt.
|
|
33
|
+
columnIndex*$t,y:nt.actualContentTop+Math.max(0,B-nt.top),pageNumber:C+nt.pageIndex+1}},_t=[],ue=new Map;for(const B of Tt.fragments){const $=B.bounds.y,nt=$+B.bounds.height,N=B.lineExtents;let U=0,O=$,
|
|
34
|
+
L=!1;for(;O<nt-rt||!L;){const at=Ut(O),ft=Math.min(nt,at.window.bottom),Lt=Math.max(0,ft-O),At=ft>=nt-rt||Lt<=0;Lt<=0&&B.bounds.height>rt&&ht();let Bt;if(N)for(Bt=[];U<N.length&&(At||N[U].bottom<=ft+rt);)
|
|
35
|
+
Bt.push({charEnd:N[U].charEnd,bottom:at.y+(N[U].bottom-O)}),U+=1;const Vt=ue.get(B.blockIndex)??0;if(_t.push({...B,fragmentIndex:Vt,bounds:{...B.bounds,x:B.bounds.x+at.xOffset,y:at.y,height:Lt>0?Lt:B.
|
|
36
|
+
bounds.height},pageNumber:at.pageNumber,lineExtents:Bt&&Bt.length>0?Bt:void 0}),ue.set(B.blockIndex,Vt+1),L=!0,At)break;O=Ft.at(at.windowIndex+1).top}}const te=new Map;for(const B of _t){const $=te.get(
|
|
37
|
+
B.blockIndex)??[];$.push(B),te.set(B.blockIndex,$)}const Ae=Tt.blocks.map(B=>{const $=te.get(B.blockIndex)??[];if($.length===0){const L=Ut(B.bounds.y);return{...B,bounds:{...B.bounds,x:B.bounds.x+L.xOffset,
|
|
38
|
+
y:L.y},pageNumber:L.pageNumber}}const nt=Math.min(...$.map(L=>L.bounds.x)),N=Math.min(...$.map(L=>L.bounds.y)),U=Math.max(...$.map(L=>L.bounds.x+L.bounds.width)),O=Math.max(...$.map(L=>L.bounds.y+L.bounds.
|
|
39
|
+
height));return{...B,bounds:{...B.bounds,x:nt,y:N,width:U-nt,height:O-N},pageNumber:$[0].pageNumber}});if(w.blocks.push(...Ae),w.fragments.push(..._t),w.nextBlockIndex=Tt.nextBlockIndex,w.lineNumberMarks!==
|
|
40
|
+
void 0&&Tt.lineNumberMarks)for(const B of Tt.lineNumberMarks){const $=Ut(B.y);w.lineNumberMarks.push({...B,y:$.y,pageNumber:$.pageNumber})}const de=Ft.at(jt).pageIndex;P=C+de,z=ot+de*Rt,Z=V;const De=P+
|
|
41
|
+
1,he=_t.filter(B=>B.pageNumber===De).map(B=>B.bounds.y+B.bounds.height),pe=Ut(Tt.currentY);S=Math.max(pe.y,...he.length>0?he:[pe.y]),w.currentY=S,w.totalHeight=Math.max(w.totalHeight,S),w.currentPage=
|
|
42
|
+
Math.max(w.currentPage,P+1),w.layout=V,w.pageStep=Rt}),w.sectionRuntime={runs:l,layouts:i,startPageIndexes:M,sectionStartTops:I},w},s=(n,r)=>{const g=n.sectionRuntime;if(!g)return e;let l=g.startPageIndexes.
|
|
43
|
+
length-1;for(;l>0&&r<g.startPageIndexes[l];)l--;return g.layouts[l]},p=(n,r)=>{const g=n.sectionRuntime;if(!g)return r*(e.pageHeight+e.pageSpacing);let l=g.startPageIndexes.length-1;for(;l>0&&r<g.startPageIndexes[l];)
|
|
44
|
+
l--;const i=g.layouts[l],d=i.pageHeight+i.pageSpacing;return g.sectionStartTops[l]+(r-g.startPageIndexes[l])*d},h=(n,r)=>{const g=n.sectionRuntime;if(!g)return Math.max(0,Math.floor((r-e.textStartY)/(e.
|
|
45
|
+
pageHeight+e.pageSpacing)));let l=g.startPageIndexes.length-1;for(;l>0&&r<g.sectionStartTops[l];)l--;const i=g.layouts[l],d=i.pageHeight+i.pageSpacing;return g.startPageIndexes[l]+Math.max(0,Math.floor(
|
|
46
|
+
(r-g.sectionStartTops[l]-i.textStartY)/d))},k=(n,r)=>{const g=n.sectionRuntime;if(!g)return;const l=g.layouts.length,i=g.layouts.map((w,P)=>{const z=g.runs[P].rawSettings,Z=we(o.pageLayout,z);return{layout:w,
|
|
47
|
+
raw:z,resolved:Z,step:w.pageHeight+w.pageSpacing,marginTop:Et(w),marginRight:ee(w),marginBottom:xt(w),marginLeft:bt(w)}}),d=[];let M=0,I=0;for(let w=0;w<r;w++){for(;M<l-1&&w>=g.startPageIndexes[M+1];)
|
|
48
|
+
M++;const P=i[M];w===0||w===g.startPageIndexes[M]&&(M<l-1?P.raw?.pageNumberStart!==void 0:o.pageLayout?.pageNumberRestart===!0)?I=P.resolved.pageNumberStart:I+=1,d.push({pageIndex:w,sectionIndex:M,pageTop:g.
|
|
49
|
+
sectionStartTops[M]+(w-g.startPageIndexes[M])*P.step,pageWidth:P.layout.pageWidth,pageHeight:P.layout.pageHeight,marginTop:P.marginTop,marginRight:P.marginRight,marginBottom:P.marginBottom,marginLeft:P.
|
|
50
|
+
marginLeft,showPageNumbers:P.resolved.showPageNumbers,pageNumberPosition:P.resolved.pageNumberPosition,renderedPageNumber:I,pageNumberFormat:P.resolved.pageNumberFormat,lineNumbering:P.resolved.lineNumbering,
|
|
51
|
+
pleadingGrid:P.resolved.pleadingGrid,pageBorders:P.resolved.pageBorders,sectionFirstPage:w===g.startPageIndexes[M]})}return d},H=[...o.notes??[],...o.children.filter(n=>n.type==="footnote")],x=(o.chrome?.
|
|
52
|
+
length??0)>0;if(H.length===0&&!x){const n=u(o.children,e),r=Math.max(1,n.currentPage,Xt(n));return{blocks:n.blocks,fragments:n.fragments,totalHeight:n.totalHeight,pageCount:r,pageGeometries:k(n,r),...n.
|
|
53
|
+
lineNumberMarks!==void 0?{lineNumberMarks:n.lineNumberMarks}:{}}}const m=o.children.filter(n=>n.type!=="footnote"&&n.type!=="header-footer"),v=[],F=n=>{if(!n||typeof n!="object")return;if(Array.isArray(
|
|
54
|
+
n)){n.forEach(F);return}const r=n;r.type!=="footnote"&&(r.marks?.footnoteRef&&!v.includes(r.marks.footnoteRef)&&v.push(r.marks.footnoteRef),F(r.children))};F(m);const Y=[...v.map(n=>H.find(r=>r.id===n)).
|
|
55
|
+
filter(n=>!!n),...H.filter(n=>!v.includes(n.id))],f=Y.filter(n=>n.noteKind!=="endnote"),b=Y.filter(n=>n.noteKind==="endnote");f.forEach((n,r)=>{n.footnoteNumber=Me(r+1,"footnote")}),b.forEach((n,r)=>{
|
|
56
|
+
n.footnoteNumber=Me(r+1,"endnote")});const R=vt.separatorSpacePx,W=[],E=Math.max(vt.separatorWidthMinPx,e.availableWidth*vt.separatorWidthFraction),ut=(n,r,g,l)=>{const i=n.layout,d=c(Gt(i),g);d.nextBlockIndex=
|
|
57
|
+
n.nextBlockIndex,Wt({state:d,blocks:r,x:bt(i),layoutForLevel:Gt(i),suppressTopSpacingForFirstBlock:!0});for(const M of d.blocks)M.pageNumber=l,n.blocks.push(M);for(const M of d.fragments)M.pageNumber=
|
|
58
|
+
l,n.fragments.push(M);return n.nextBlockIndex=d.nextBlockIndex,d.currentY},q=(n,r,g,l,i,d)=>{const M=s(n,l),I=p(n,l),w=Et(M),P=xt(M),z=12,Z=g?I+Math.max(z/2+4,w/2):I+M.pageHeight-Math.max(z/2+4,P/2),S=bt(
|
|
59
|
+
M),Q=ro(o.pageLayout),ht=d?so(d.renderedPageNumber,d.pageNumberFormat):io(Q,l),G=Mt=>Mt.children.some(et=>et.type==="text"&&et.marks?.field)?{...Mt,children:Mt.children.map(et=>{if(et.type!=="text"||!et.
|
|
60
|
+
marks?.field)return et;const It=et.marks.field==="page"?ht:String(i);return{...et,text:It}})}:Mt,X=r.children.slice(0,3).map((Mt,et)=>{const It=G(Mt),C=lo[et];return C&&!It.align?{...It,align:C}:It}),
|
|
61
|
+
tt=Se(r,t,M,o,X),V=[0,tt[0],tt[0]+tt[1]];r.children.forEach((Mt,et)=>{if(et>2)return;const It=X[et],C=tt[et],ot=S+V[et],wt=c({...M,pageless:!0,availableWidth:C,columnCount:1},0);wt.nextBlockIndex=n.nextBlockIndex,
|
|
62
|
+
Wt({state:wt,blocks:[It],x:ot,layoutForLevel:{...M,pageless:!0,availableWidth:C,columnCount:1},suppressTopSpacingForFirstBlock:!0});const Ht=wt.currentY,Ot=Z-Ht/2;for(const pt of wt.blocks)pt.pageNumber=
|
|
63
|
+
l+1,pt.bounds={...pt.bounds,y:pt.bounds.y+Ot},n.blocks.push(pt);for(const pt of wt.fragments)pt.pageNumber=l+1,pt.isChrome=!0,pt.bounds={...pt.bounds,y:pt.bounds.y+Ot},n.fragments.push(pt);n.nextBlockIndex=
|
|
64
|
+
wt.nextBlockIndex})},K=(n,r,g)=>{if(e.pageless)return;const l=new Set;for(let i=0;i<r;i++)for(const d of[!0,!1]){const M=oo(o.chrome??[],d?"header":"footer",i+1,g?.[i]?.sectionIndex);M&&(q(n,M,d,i,r,g?.[i]),
|
|
65
|
+
l.add(M.id))}};if(e.pageless){const n=u(m,e),r=[];for(const g of[f,b]){if(g.length===0)continue;const l=n.currentY+R;W.push({x:bt(e),y:l,width:E}),n.currentY=l+10,Wt({state:n,blocks:g,x:bt(e),layoutForLevel:Gt(
|
|
66
|
+
e),suppressTopSpacingForFirstBlock:!0}),r.push({x:bt(e),y:l,width:e.availableWidth,height:Math.max(0,n.currentY-l)})}return n.totalHeight=n.currentY,{blocks:n.blocks,fragments:n.fragments,totalHeight:n.
|
|
67
|
+
totalHeight,pageCount:1,footnoteSeparators:W,footnoteAreas:r}}const it=new Map;(n=>{const r=(g,l,i)=>{if(!g||typeof g!="object")return;if(Array.isArray(g)){g.forEach(M=>r(M,l,i));return}const d=g;if(d.
|
|
68
|
+
marks?.footnoteRef&&!it.has(d.marks.footnoteRef)){const M=i?.value,I=l.type==="paragraph"&&M!==void 0?qe(l).toVisibleOffset(M):void 0;it.set(d.marks.footnoteRef,{blockId:l.id??"",charOffset:I})}d.type===
|
|
69
|
+
"text"&&i&&(i.value+=d.text?.length??0),r(d.children,l,i)};for(const g of n)r(g,g,g.type==="paragraph"?{value:0}:void 0)})(m);const Pt=n=>{const r=new Map,g=Math.max(0,n.currentPage-1);for(const l of f){
|
|
70
|
+
const i=it.get(l.id),d=i?n.fragments.filter(S=>S.blockId===i.blockId):[],M=i?.charOffset===void 0?d[0]:[...d].reverse().find(S=>S.charRange&&i.charOffset>=S.charRange.start&&i.charOffset<=S.charRange.
|
|
71
|
+
end),I=i?n.blocks.find(S=>S.blockId===i.blockId):void 0,w=M?.pageNumber??I?.pageNumber;if(w===void 0){r.set(l.id,{pageIndex:g});continue}const P=Math.max(0,w-1),z=M??I;let Z;if(z){const S=s(n,P),Q=p(n,
|
|
72
|
+
P)+S.pageHeight-xt(S),ht=M?.lineExtents&&i?.charOffset!==void 0?M.lineExtents.find(G=>G.charEnd>=i.charOffset)?.bottom:void 0;Z=Math.min(ht??z.bounds.y+z.bounds.height,Q)}r.set(l.id,{pageIndex:P,keepBottomY:Z})}
|
|
73
|
+
return r},yt=n=>Math.max(R,n.pageHeight-Et(n)-xt(n)),Nt=n=>{const r=[];for(const g of n.fragments){const l=g.bounds.y,i=l+g.bounds.height,d=h(n,l),M=h(n,Math.max(l,i-.01));for(let I=d;I<=M;I++){const w=s(
|
|
74
|
+
n,I),P=p(n,I)+w.pageHeight-xt(w);r[I]=Math.max(r[I]??0,Math.min(i,P))}}return r},st=(n,r)=>Math.max(0,yt(s(n,r))-R),J=(n,r,g)=>{const l=Nt(n),i=Math.max(n.currentPage,Xt(n)),d=Math.max(e.lineHeight,e.
|
|
75
|
+
fontSize*go.paragraph),M=S=>S.type==="paragraph"?uo(S):S.type==="list"?e.fontSize*ho(S):d,I=[],w=[];for(const S of n.fragments){const Q=h(n,S.bounds.y),ht=I[Q];ht!==void 0&&S.bounds.y>=ht||(I[Q]=S.bounds.
|
|
76
|
+
y,w[Q]=M(S.block))}const P=S=>Math.max(32,vt.minimumBodyLinesBeforeFootnotes*(w[S]??d)),z=new Map;for(const S of f){const Q=r.get(S.id),ht=g.get(S.id)??Q?.pageIndex??0;!Q||Q.keepBottomY===void 0||ht!==
|
|
77
|
+
Q.pageIndex||z.set(Q.pageIndex,Math.max(z.get(Q.pageIndex)??0,Q.keepBottomY))}const Z=[];for(let S=0;S<i;S++){const Q=s(n,S),ht=p(n,S),G=ht+Et(Q),X=ht+Q.pageHeight-xt(Q),tt=l[S];if(tt===void 0){Z[S]=st(
|
|
78
|
+
n,S);continue}const V=Math.max(z.get(S)??0,Math.min(tt,G+P(S)));Z[S]=Math.max(0,X-R-V-vt.bodyKeepSlackPx)}return Z},lt=(n,r)=>{const g=Math.max(n.currentPage,Xt(n)),l=[];for(let i=0;i<g;i++)l[i]=Math.
|
|
79
|
+
max(0,Math.min(st(n,i),(r[i]??0)-R));return l};let ct;const j=()=>{if(ct===void 0){const n=c(Gt(e),0);Wt({state:n,blocks:f,x:bt(e),layoutForLevel:Gt(e),suppressTopSpacingForFirstBlock:!0}),ct=Math.max(
|
|
80
|
+
n.currentY,0)}return ct},dt=(n,r,g,l)=>{const i=C=>C<g.length?Math.max(0,g[C]??0):st(n,C),d=C=>{const ot=s(n,C);return p(n,C)+ot.pageHeight-xt(ot)-i(C)},M=C=>{const ot=s(n,C);return p(n,C)+ot.pageHeight-
|
|
81
|
+
xt(ot)},I=Math.max(48,yt(e)/2),w=Math.max(n.currentPage,Xt(n),g.length)+Math.ceil(j()/I)+4,P=[];for(let C=0;C<w;C++)P.push({top:d(C),bottom:M(C),full:i(C)>=st(n,C)-.01,pageIndex:C});const z=Ze(P),Z=C=>({
|
|
82
|
+
...s(n,C),pageless:!1,lineHeight:1.25,paragraphSpacing:.25,blockSpacingPx:2,footnotePageInsets:void 0,pageContentTopOffsets:void 0,flowWindows:z}),S=C=>z.at(z.indexForY(C)).pageIndex,Q=f[0],ht=r.get(Q.
|
|
83
|
+
id)??0,G=c(Z(ht),d(ht));G.nextBlockIndex=l,G.currentPage=ht+1;const X=[],tt=new Map,V=new Set,Mt=new Map,et=new Map;for(const C of f){const ot=S(G.currentY),wt=Math.max(r.get(C.id)??0,ot),Ht=wt>ot,Ot=Ht||
|
|
84
|
+
G.blocks.length===0;Ht&&(G.currentY=d(wt),G.currentPage=Math.max(G.currentPage,wt+1)),G.layout=Z(wt),G.pageStep=me(G.layout);const pt=G.blocks.length;Wt({state:G,blocks:[C],x:bt(G.layout),layoutForLevel:G.
|
|
85
|
+
layout,suppressTopSpacingForFirstBlock:Ot});const $t=G.blocks[pt],Rt=$t?S($t.bounds.y):wt,zt=S(G.currentY-.01);et.set(C.id,Rt);for(let Yt=Rt;Yt<=zt;Yt++)tt.has(Yt)||tt.set(Yt,d(Yt)),Yt>Rt&&V.add(Yt),Mt.
|
|
86
|
+
set(Yt,Math.max(Mt.get(Yt)??0,Yt<zt?M(Yt):G.currentY))}for(const[C,ot]of Mt)X[C]=Math.max(0,ot-d(C));const It=Math.max(0,...Mt.keys());return{heights:X,windowTops:tt,continuationPages:V,startPageByNote:et,
|
|
87
|
+
blocks:G.blocks,fragments:G.fragments,endY:G.currentY,lastPageIndex:It,nextBlockIndex:G.nextBlockIndex}},Ct=(n,r)=>{const g=[];return r.heights.forEach((l,i)=>{if(!l||l<=0)return;const d=s(n,i);g[i]=Math.
|
|
88
|
+
min(R+l,yt(d))}),g},kt=(n,r)=>{const g=Math.max(n.length,r.length);for(let l=0;l<g;l++)if(Math.abs((n[l]??0)-(r[l]??0))>.25)return!1;return!0},A=new Map;let T=[],y=u(m,e,f.length>0),mt=y.currentY;const _=[];
|
|
89
|
+
if(f.length>0){for(let r=0;r<8;r++){const g=Pt(y);for(const[d,M]of g)A.set(d,Math.max(A.get(d)??0,M.pageIndex));const l=dt(y,A,J(y,g,A),0);for(const[d,M]of l.startPageByNote)A.set(d,Math.max(A.get(d)??
|
|
90
|
+
0,M));const i=Ct(y,l);if(kt(i,T))break;T=i,y=u(m,{...e,footnotePageInsets:T},!0)}mt=y.currentY;const n=dt(y,A,lt(y,T),y.nextBlockIndex);y.blocks.push(...n.blocks),y.fragments.push(...n.fragments),y.nextBlockIndex=
|
|
91
|
+
n.nextBlockIndex,y.currentY=Math.max(y.currentY,n.endY),y.totalHeight=Math.max(y.totalHeight,n.endY),y.currentPage=Math.max(y.currentPage,n.lastPageIndex+1);for(const[r,g]of[...n.windowTops].sort((l,i)=>l[0]-
|
|
92
|
+
i[0])){const l=s(y,r),i=g-8;W.push({pageIndex:r,x:bt(l),y:i,width:n.continuationPages.has(r)?l.availableWidth:Math.max(96,l.availableWidth*.3)}),_.push({pageIndex:r,x:bt(l),y:i,width:l.availableWidth,
|
|
93
|
+
height:p(y,r)+l.pageHeight-xt(l)-i})}}let D=Math.max(1,y.currentPage,Xt(y));if(b.length>0){const n=D-1,r=p(y,n)+e.pageHeight-xt(e),g=_.filter(S=>S.pageIndex===n).reduce((S,Q)=>Math.min(S,Q.y),Number.POSITIVE_INFINITY),
|
|
94
|
+
l=Math.min(r,g),i=mt+vt.inlineEndnoteGapPx,d=c(Gt(e),i+vt.separatorToContentPx);d.nextBlockIndex=y.nextBlockIndex,Wt({state:d,blocks:b,x:bt(e),layoutForLevel:Gt(e),suppressTopSpacingForFirstBlock:!0});
|
|
95
|
+
const M=d.currentY<=l,I=M?n:D,w=p(y,I)+e.textStartY,P=M?i:w+vt.newPageSeparatorOffsetPx;W.push({pageIndex:I,x:bt(e),y:P,width:E});const z=ut(y,b,P+vt.separatorToContentPx,I+1);_.push({pageIndex:I,x:bt(
|
|
96
|
+
e),y:P,width:e.availableWidth,height:Math.max(p(y,I)+e.pageHeight-xt(e),z)-P}),y.currentY=Math.max(y.currentY,z),y.totalHeight=Math.max(y.totalHeight,z);const Z=St(y,z)??D;D=Math.max(I+1,Z),y.currentPage=
|
|
97
|
+
Math.max(y.currentPage,D)}const gt=k(y,D);return K(y,D,gt),{blocks:y.blocks,fragments:y.fragments,totalHeight:y.totalHeight,pageCount:D,footnoteSeparators:W,footnoteAreas:_,pageGeometries:gt,...y.lineNumberMarks!==
|
|
98
|
+
void 0?{lineNumberMarks:y.lineNumberMarks}:{}}}function Wt(o){const{state:t,blocks:e,x:a,layoutForLevel:c,onFirstBlockLayout:u,suppressTopSpacingForFirstBlock:s=!1,onBlockLaidOut:p}=o;let h,k,H=!1;for(let x=0;x<
|
|
99
|
+
e.length;x++){const m=e[x],v=t.blocks.length,F=t.suppressTopSpacingForNextBlock,Y=s&&x===0||F;F&&(t.suppressTopSpacingForNextBlock=!1);const f=Be(c,{suppressTopSpacingForFirstChild:Y,...Qe(e,x)});Yo({
|
|
100
|
+
state:t,block:m,x:a,layout:f,followingBlocks:e.slice(x+1,x+4)});const b=t.blocks.length>v?t.blocks[t.blocks.length-1]:void 0;if(b){H||(H=!0,h=b.bounds.y,u?.(b));const R=b.bounds.y+b.bounds.height;k=k===
|
|
101
|
+
void 0?R:Math.max(k,R)}p?.(x)}return{firstBlockStartY:h,lastBlockEndY:k}}function Be(o,t){return o.suppressTopSpacingForFirstChild===!0===t.suppressTopSpacingForFirstChild&&o.siblingSpaceBeforePx===t.
|
|
102
|
+
siblingSpaceBeforePx&&o.siblingSpaceAfterPx===t.siblingSpaceAfterPx?o:{...o,...t}}function Yo(o){o.state.lastLineTail=So(o)}function So(o){const{block:t}=o;if(t.type==="container"){Fe({...o,block:t});
|
|
103
|
+
return}if(t.type==="footnote"){No({...o,block:t});return}if(t.type==="table"){Wo({...o,block:t});return}if(t.type==="table-cell"){re({...o,block:t});return}return t.type==="page-break"?vo({...o,block:t}):
|
|
104
|
+
t.type==="section-break"?Bo(o):qt(o)}const Io=4;function ve(o,t,e){const a=o.lastLineTail;return a?{x:a.x+Io,y:a.y,width:t.width,height:Math.max(Math.min(16,a.height),0)}:{x:t.x,y:o.currentY,width:t.width,
|
|
105
|
+
height:Math.max(Math.min(16,e),0)}}function Bo(o){const{state:t,block:e,x:a,layout:c}=o;if(c.pageless)return qt(o);const u=t.registry.getHandlerForBlock(e);if(!u)return qt(o);const s=t.nextBlockIndex++,
|
|
106
|
+
p=u.getBounds(e,a,t.currentY,t.textContext,c,t.doc),h=ve(t,p,Jt(t,t.currentY)-t.currentY),k=St(t,h.y);return t.blocks.push({block:e,blockIndex:s,blockId:e.id??"",bounds:h,pageNumber:k,pageBreakBefore:!1}),
|
|
107
|
+
t.fragments.push({block:e,blockIndex:s,blockId:e.id??"",fragmentIndex:0,bounds:h,pageNumber:k,data:{type:"section-break"}}),{x:h.x+h.width,y:h.y,height:Math.max(h.height,t.lastLineTail?.height??0)}}function vo(o){
|
|
108
|
+
const{state:t,block:e,x:a,layout:c}=o,u=t.registry.getHandlerForBlock(e);if(!u)return console.warn(`No handler for block type: ${e.type}`),t.lastLineTail;if(c.pageless)return qt(o);const s=t.nextBlockIndex++,
|
|
109
|
+
p=u.getBounds(e,a,t.currentY,t.textContext,c,t.doc),h=Ro(t,t.currentY),k=ve(t,p,h-t.currentY),H=St(t,k.y),x={block:e,blockIndex:s,blockId:e.id??"",bounds:k,pageNumber:H,pageBreakBefore:!1},m={block:e,
|
|
110
|
+
blockIndex:s,blockId:e.id??"",fragmentIndex:0,bounds:k,pageNumber:H,data:{type:"page-break"}};t.blocks.push(x),t.fragments.push(m),t.currentY=h,t.totalHeight=t.currentY,t.currentPage=Math.max(t.currentPage,
|
|
111
|
+
St(t,h)??t.currentPage),t.suppressTopSpacingForNextBlock=!0,ie(t,h)}function Zt(o,t,e){if(e<=0||o.layout.pageless||o.pageStep<=0)return!1;const a=o.layout.flowWindows;return(a&&a.length!==0?Le(t,e,a):
|
|
112
|
+
ke(t,e,o.layout)).pageChanged}function Pe(o){const t=Jt(o);t>o.currentY&&(o.currentY=t,ie(o,t))}function Po(o,t,e,a,c){if(!e||e.length===0)return 0;let u=0,s=t;for(let p=0;p<e.length&&p<ae;p++){const h=e[p];
|
|
113
|
+
if(!h||h.type!=="paragraph")break;const k=o.registry.getHandlerForBlock(h);if(!k)break;const H=Be(c,{suppressTopSpacingForFirstChild:!1,siblingSpaceBeforePx:to(s,h),siblingSpaceAfterPx:ye(h,e[p+1])}),
|
|
114
|
+
x=ye(s,h)??(s.type==="paragraph"&&Number.isFinite(s.spaceAfter)?Math.max(0,s.spaceAfter??0):0);s=h;const m=Ne(o,k,h,a,H),v=m.units??[];if(v.length===0)break;const F=x+(m.margins?.top??0),Y=ne(h);if(Y.
|
|
115
|
+
keepNext&&p<ae-1){u+=F+v.reduce((f,b)=>f+Math.max(b.height,0),0);continue}u+=F+Math.max(v[0].height,0),Y.widowControl&&v.length>=2&&(u+=Math.max(v[1].height,0));break}return u}function qt(o){const{state:t,
|
|
116
|
+
block:e,x:a,layout:c,followingBlocks:u}=o,s=t.registry.getHandlerForBlock(e);if(!s)return console.warn(`No handler for block type: ${e.type}`),t.lastLineTail;const p=t.nextBlockIndex++,h=Ne(t,s,e,a,c),
|
|
117
|
+
k=h.margins?.top??0,H=h.margins?.bottom??0;t.currentY+=k;const x=h.units.length>0?h.units:[];x.length===0&&console.warn(`Block handler for type ${e.type} returned no layout units; layout may be incorr\
|
|
118
|
+
ect.`);let m=!1;const v=ne(e);if(!c.pageless&&t.pageStep>0&&x.length>0){const A=x.reduce((y,mt)=>y+Math.max(mt.height,0),0);let T=0;v.keepLines?T=A:v.widowControl&&x.length>=2&&(T=Math.max(x[0].height,
|
|
119
|
+
0)+Math.max(x[1].height,0)),v.keepNext&&(T=Math.max(T,A+Po(t,e,u,a,c))),T>0&&Zt(t,t.currentY,T)&&!Zt(t,Jt(t),T)&&(Pe(t),m=!0)}let F=0,Y=0,f=t.currentY,b,R,W,E,ut,q,K,it=Number.POSITIVE_INFINITY,Pt=Number.
|
|
120
|
+
NEGATIVE_INFINITY,yt,Nt=0,st,J=m;const lt=[],ct=(A,T)=>{Y=A,f=T,b=void 0,R=void 0,W=void 0,E=void 0,ut=void 0,q=void 0,K=void 0},j=A=>{if(A<=Y){ct(A,t.currentY);return}const T=t.currentY-f;if(T<=0){ct(
|
|
121
|
+
A,t.currentY);return}const y=ut??h.x,mt=q!==void 0&&ut!==void 0?q-ut:h.width,_=Math.max(mt,h.width),D={x:y,y:f,width:_,height:T};let gt;!t.layout.pageless&&t.pageStep>0&&(gt=St(t,D.y));const n={block:e,
|
|
122
|
+
blockIndex:p,blockId:e.id??"",fragmentIndex:F,bounds:D,pageNumber:gt,unitRange:{start:Y,end:A}};b!==void 0&&R!==void 0&&R>=b&&(n.lineRange={start:b,end:R}),W!==void 0&&E!==void 0&&E>=W&&(n.charRange={
|
|
123
|
+
start:W,end:E}),K&&K.length>0&&(n.lineExtents=K),F===0&&(st=gt),lt.push(n),F+=1,yt=yt??D.y,Nt+=D.height,ct(A,t.currentY)};let dt;for(let A=0;A<x.length;A++){const T=x[A],y=Math.max(T.height,0),mt=T.x??
|
|
124
|
+
h.x,_=T.width,D=mt+_,gt=v.widowControl&&x.length>=3&&A===x.length-2&&!Zt(t,t.currentY,y)&&Zt(t,t.currentY+y,Math.max(x[A+1].height,0));gt&&Pe(t),(gt||Dt(t,y))&&(Y<A?j(A):F===0&&(J=!0),ct(A,t.currentY)),
|
|
125
|
+
b===void 0&&T.lineRange&&(b=T.lineRange.start),T.lineRange&&(R=T.lineRange.end),W===void 0&&T.charRange&&(W=T.charRange.start),T.charRange&&(E=T.charRange.end),t.trackLineExtents&&T.charRange&&(K??(K=
|
|
126
|
+
[])).push({charEnd:T.charRange.end,bottom:t.currentY+y}),ut=ut===void 0?mt:Math.min(ut,mt),q=q===void 0?D:Math.max(q,D),it=Math.min(it,mt),Pt=Math.max(Pt,D),t.lineNumberMarks!==void 0&&t.layout.lineNumbering&&
|
|
127
|
+
T.lineRange&&t.lineNumberMarks.push({y:t.currentY,height:y,...T.baselineOffset!==void 0?{baselineOffset:T.baselineOffset}:{},pageNumber:St(t,t.currentY)}),dt={unit:T,fallbackX:D,y:t.currentY,height:y},
|
|
128
|
+
t.currentY+=y}j(x.length);const Ct={x:Number.isFinite(it)?it:h.x,y:yt??t.currentY,width:Number.isFinite(it)&&Number.isFinite(Pt)?Math.max(Pt-it,h.width):h.width,height:Nt,margins:h.margins};t.blocks.push(
|
|
129
|
+
{block:e,blockIndex:p,blockId:e.id??"",bounds:Ct,pageNumber:t.layout.pageless?void 0:st,pageBreakBefore:J}),t.fragments.push(...lt),t.currentY+=H,t.totalHeight=t.currentY;const kt=dt;if(!(!s.isTextBased||
|
|
130
|
+
!kt))return{get x(){return kt.unit.textEndX??kt.fallbackX},y:kt.y,height:kt.height}}function Ne(o,t,e,a,c){const u=o.boundsMemo;if(!u)return t.getBounds(e,a,o.currentY,o.textContext,c,o.doc);const s=c.
|
|
131
|
+
suppressTopSpacingForFirstChild===!0,{siblingSpaceBeforePx:p,siblingSpaceAfterPx:h}=c;let k=u.get(e);const H=k?.find(m=>m.x===a&&m.availableWidth===c.availableWidth&&m.suppressTopSpacing===s&&m.siblingSpaceBeforePx===
|
|
132
|
+
p&&m.siblingSpaceAfterPx===h);if(H)return H.result;const x=t.getBounds(e,a,o.currentY,o.textContext,c,o.doc);return k||(k=[],u.set(e,k)),k.push({x:a,availableWidth:c.availableWidth,suppressTopSpacing:s,
|
|
133
|
+
siblingSpaceBeforePx:p,siblingSpaceAfterPx:h,result:x}),x}function Gt(o){return{...o,pageless:!0,lineHeight:1.25,paragraphSpacing:.25,blockSpacingPx:vt.blockSpacingPx}}function Fe(o){const{state:t,block:e,
|
|
134
|
+
x:a,layout:c,paddingOverride:u,fragmentType:s}=o,p=t.registry.getHandlerForBlock(e);if(!p){console.warn(`No handler for block type: ${e.type}`);return}const h=t.nextBlockIndex++,k=p.getBounds(e,a,t.currentY,
|
|
135
|
+
t.textContext,c,t.doc),H=k.margins?.top??0,x=k.margins?.bottom??0;t.currentY+=H;let m=t.currentY,v=!1;const F=Math.max(0,e.padding??Mo),Y=u?.top??F,f=u?.bottom??F,b=u?.left??F,R=u?.right??F,W=k.width??
|
|
136
|
+
c.availableWidth,E={block:e,blockIndex:h,blockId:e.id??"",bounds:{x:a,y:m,width:W,height:0,margins:k.margins},pageBreakBefore:!1},ut=t.blocks.length;t.blocks.push(E);const q=t.fragments.length,K=e.children.
|
|
137
|
+
length>0;let it=!K;const Pt=se(t,Ct=>{it||(m=Ct,E.bounds.y=Ct,v=!0)});Dt(t,1e-4)&&(m=t.currentY,E.bounds.y=m,v=!0),Dt(t,Y)&&(m=t.currentY,E.bounds.y=m,v=!0),t.currentY+=Y;const yt=a+b,Nt=Math.max(c.availableWidth-
|
|
138
|
+
b-R,yo),st=Math.abs(Nt-c.availableWidth)<.5?c:Re(c,Nt);let J={};try{J=Wt({state:t,blocks:e.children,x:yt,layoutForLevel:st,onFirstBlockLayout:()=>{it=!0},suppressTopSpacingForFirstBlock:!0})}finally{Pt()}
|
|
139
|
+
J.firstBlockStartY!==void 0&&J.firstBlockStartY-Y<m&&(m=J.firstBlockStartY-Y,E.bounds.y=m),Dt(t,f)&&(K||(m=t.currentY,E.bounds.y=m,v=!0)),t.currentY+=f;const lt=Math.max(t.currentY-m,Y+f);E.bounds={...E.
|
|
140
|
+
bounds,y:m,height:lt,width:W,margins:k.margins},E.pageBreakBefore=v,E.pageNumber=St(t,E.bounds.y);const ct={x:a,y:E.bounds.y,width:W,height:lt},j={block:e,blockIndex:h,blockId:e.id||"",fragmentIndex:0,
|
|
141
|
+
bounds:ct,pageNumber:E.pageNumber,data:{type:s??"container"}};if(t.fragments.splice(q,0,j),J.firstBlockStartY!==void 0){const Ct=Math.max(t.layout.lineHeight*4,64);if(J.firstBlockStartY-m>Ct+Y){const kt=J.
|
|
142
|
+
firstBlockStartY-Y;E.bounds.y=kt,E.bounds.height=Math.max(t.currentY-kt,Y+f),j.bounds={...j.bounds,...E.bounds}}}t.blocks[ut]=E;const dt=St(t,E.bounds.y);E.pageNumber=dt,j.pageNumber=dt,t.currentY+=x,
|
|
143
|
+
t.totalHeight=t.currentY}function No(o){Fe({...o,block:o.block,paddingOverride:{top:vt.verticalPaddingPx,bottom:vt.verticalPaddingPx,left:vt.gutterPx,right:0},fragmentType:"footnote"})}const Ce=oe.cellPaddingPx,
|
|
144
|
+
Fo=oe.borderColor,Co=oe.borderWidthPx;function Ho(o){if(o.flowWindows)return o.flowWindows;const t=me(o),e=o.sectionStartY??0,a=o.sectionFirstPageIndex??0;return{indexForY:c=>Math.max(0,Math.floor((c-
|
|
145
|
+
e-o.textStartY+rt)/t)),at:c=>{const u=je(o,a+c),s=xe(o,a+c),p=e+c*t;return{top:p+u,bottom:p+o.pageHeight-xt(o)-s,full:u<=Et(o)&&s<=0,pageIndex:a+c}}}}function He(o,t,e){if(o.layout.pageless||e<=0)return t+
|
|
146
|
+
e;const a=o.layout.flowWindows;let c=a.indexForY(t);for(;e>rt;){const u=a.at(c);t=Math.max(t,u.top);const s=Math.max(0,u.bottom-t);if(e<=s+rt)return t+e;if(e-=s,a.length!==void 0&&c+1>=a.length)return u.
|
|
147
|
+
bottom+e;t=a.at(++c).top}return t}function To(o,t,e){return We(o,t,e).reduce((a,c)=>a+c.height,0)}function Lo(o,t,e,a){const{blockIndex:c,fragmentIndex:u,params:s}=t,p=o.blocks[c].bounds.y,h=s.block.verticalAlign,
|
|
148
|
+
k=To(o,p,e)-(s.measuredHeight??0);if(a&&h&&h!=="top"&&k>rt){const v=b=>{const R={...o,blocks:[],fragments:[],currentY:p,nextBlockIndex:o.blocks[c].blockIndex,pageBreakListeners:[],lineNumberMarks:void 0,
|
|
149
|
+
lastLineTail:void 0,suppressTopSpacingForNextBlock:!1};return re({...s,state:R,rowHeight:void 0,contentOffset:b}),R};let F=k*(h==="middle"?.5:1),Y=v(F),f;if(Y.currentY<=e+rt)f=Y;else{let b=0;for(let R=0;R<
|
|
150
|
+
16&&F-b>.01;R++){const W=(b+F)/2;Y=v(W),Y.currentY<=e+rt?(f=Y,b=W):F=W}}f&&(o.blocks.splice(c,t.blockCount,...f.blocks),o.fragments.splice(u,t.fragmentCount,...f.fragments))}const H=o.blocks[c];H.bounds.
|
|
151
|
+
height=Math.max(0,e-p);const x=o.fragments[u],m=We(o,p,e);m.length&&o.fragments.splice(u,1,...m.map((v,F)=>({...x,fragmentIndex:F,bounds:{...x.bounds,y:v.y,height:v.height},pageNumber:St(o,v.y),data:F>
|
|
152
|
+
0?structuredClone(x.data):x.data})))}function Wo(o){const{state:t,block:e,x:a,layout:c}=o,u=t.registry.getHandlerForBlock(e);if(!u){console.warn(`No handler for block type: ${e.type}`);return}const s=t.
|
|
153
|
+
nextBlockIndex++,p=u.getBounds(e,a,t.currentY,t.textContext,c,t.doc),h=p.margins?.top??0,k=p.margins?.bottom??0;t.currentY+=h;let H=t.currentY,x=!1;const m=p.width,v=Number.isFinite(e.cellPadding)?Math.
|
|
154
|
+
max(0,Math.round(e.cellPadding)):Ce,F=e.borderColor??Fo,Y=Number.isFinite(e.borderWidth)?Math.max(0,Number(e.borderWidth)):Co,f=p.x,b={block:e,blockIndex:s,blockId:e.id??"",bounds:{x:f,y:H,width:m,height:0,
|
|
155
|
+
margins:p.margins},pageBreakBefore:!1},R=t.blocks.length;t.blocks.push(b);const W=t.fragments.length;let E=!(e.children.length>0);const ut=se(t,st=>{E||(H=st,b.bounds.y=st,x=!0)});Dt(t,1e-4)&&(H=t.currentY,
|
|
156
|
+
b.bounds.y=H,x=!0);const q=t.layout,K=Ho(q);q.pageless||(t.layout={...q,flowWindows:K});try{const st=p.units[0]?.data,J=st?.grid??po(e),lt=st?.geometry??fo(J,m,e.columnWidths,(_,D)=>{const gt={...c,availableWidth:D,
|
|
157
|
+
tableCellPadding:v};return t.registry.getHandlerForBlock(_)?.getBounds(_,0,0,t.textContext,gt,t.doc).units.reduce((n,r)=>n+r.height,0)??0}),ct=Array.from({length:J.rows},()=>[]);for(const _ of J.cells)
|
|
158
|
+
ct[_.row].push(_);const j=new Array(J.rows).fill(0),dt=new Array(J.rows).fill(0),Ct=q.pageless?1/0:q.pageHeight-q.textStartY-xt(q);let kt=e.hasHeader===!0&&J.rows>1&&!q.pageless&&!ct[0].some(_=>_.rowSpan>
|
|
159
|
+
1),A=[],T=0,y=0,mt=0;for(let _=0;_<J.rows;){let D=_+1,gt=0;for(let i=_;i<D;i++){gt+=lt.rowHeights[i];for(const d of ct[i])D=Math.max(D,d.row+d.rowSpan)}const n=gt>Ct-(_>0?y:0);n?Dt(t,1e-4):Dt(t,gt),E=
|
|
160
|
+
!0;const r=t.currentY,g=t.fragments.length,l=[];for(let i=_;i<D;i++){const d=t.currentY;let M=n?He(t,d,lt.rowHeights[i]):d+lt.rowHeights[i];for(const I of ct[i]){t.currentY=d;const w={state:t,block:I.
|
|
161
|
+
cell,x:f+lt.colLefts[I.col],layout:{...c,availableWidth:lt.cellWidth(I),tableCellPadding:v},measuredHeight:lt.measuredCellHeight(I),rowHeight:n?void 0:lt.cellHeight(I),cellEdgeInfo:{parentTableId:e.id??
|
|
162
|
+
"",tableDiffState:e.diffState,rowDiffState:e.children[i].diffState,isTopRow:i===0,isBottomRow:I.row+I.rowSpan===J.rows,isLeftCol:I.col===0,isRightCol:I.col+I.colSpan===J.cols,isHeaderCell:e.hasHeader===
|
|
163
|
+
!0&&i===0,tableBorderColor:F,tableBorderWidth:Y,tableBorders:e.borders,tableCellPadding:v,gridRow:I.row,gridCol:I.col,rowSpan:I.rowSpan,colSpan:I.colSpan}},P=t.blocks.length,z=t.fragments.length,Z=t.lineNumberMarks;
|
|
164
|
+
t.lineNumberMarks=void 0;try{re(w)}finally{t.lineNumberMarks=Z}const S=I.row+I.rowSpan-1;dt[S]=Math.max(dt[S],t.currentY),l.push({params:w,gc:I,blockIndex:P,fragmentIndex:z,blockCount:t.blocks.length-
|
|
165
|
+
P,fragmentCount:t.fragments.length-z})}M=Math.max(M,dt[i]),j[i]=M,t.currentY=M}for(let i=l.length-1;i>=0;i--){const d=l[i];Lo(t,d,j[d.gc.row+d.gc.rowSpan-1],n)}_===0&&kt&&(T=r,y=t.currentY-T,mt=K.indexForY(
|
|
166
|
+
T),kt=!n&&K.indexForY(t.currentY-rt)===mt&&y<Ct,kt?(A=t.fragments.slice(g),t.layout={...q,flowWindows:{length:K.length,indexForY:K.indexForY,at:i=>{const d=K.at(i);return i>mt?{...d,top:d.top+y}:d}}}):
|
|
167
|
+
y=0),_=D}if(kt&&A.length){const _=K.indexForY(t.currentY-rt);for(let D=mt+1;D<=_;D++){const gt=K.at(D).top-T;for(const n of A){const r={...n.bounds,y:n.bounds.y+gt};t.fragments.push({...n,bounds:r,repeatedHeader:!0,
|
|
168
|
+
pageNumber:St(t,r.y),lineExtents:n.lineExtents?.map(g=>({...g,bottom:g.bottom+gt})),data:{...structuredClone(n.data),repeatedHeader:!0}})}}}}finally{t.layout=q,ut()}const it=Math.max(t.currentY-H,0);b.
|
|
169
|
+
bounds={...b.bounds,y:H,height:it,width:m,margins:p.margins},b.pageBreakBefore=x,b.pageNumber=St(t,b.bounds.y);const Pt={x:f,y:b.bounds.y,width:m,height:it},yt={block:e,blockIndex:s,blockId:e.id||"",fragmentIndex:0,
|
|
170
|
+
bounds:Pt,pageNumber:b.pageNumber,data:{type:"table"}};t.fragments.splice(W,0,yt),t.blocks[R]=b;const Nt=St(t,b.bounds.y);b.pageNumber=Nt,yt.pageNumber=Nt,t.currentY+=k,t.totalHeight=t.currentY}function re(o){
|
|
171
|
+
const{state:t,block:e,x:a,layout:c,rowHeight:u,cellEdgeInfo:s}=o,p=t.registry.getHandlerForBlock(e);if(!p){console.warn(`No handler for block type: ${e.type}`);return}const h=t.nextBlockIndex++,k=o.measuredHeight??
|
|
172
|
+
p.getBounds(e,a,t.currentY,t.textContext,c,t.doc).units.reduce((j,dt)=>j+Math.max(dt.height,0),0),H=c.availableWidth,x=bo(s?.tableCellPadding??Ce,e.padding),m=Math.max(k,x.top+x.bottom),v=u!==void 0?Math.
|
|
173
|
+
max(u,0):m,F=Math.max(0,v-m),Y=e.verticalAlign??"top",f=o.contentOffset??(Y==="bottom"?F:Y==="middle"?F/2:0);let b=t.currentY,R=!1;const W={block:e,blockIndex:h,blockId:e.id??"",bounds:{x:a,y:b,width:H,
|
|
174
|
+
height:0},pageBreakBefore:!1},E=t.blocks.length;t.blocks.push(W);const ut=t.fragments.length;let q=!(e.children.length>0);const K=se(t,j=>{!q&&t.fragments.length===ut&&(b=j,W.bounds.y=j,R=!0)});f>0&&(t.
|
|
175
|
+
currentY=He(t,t.currentY,f)),Dt(t,x.top)&&(b=t.currentY,W.bounds.y=b,R=!0),t.currentY+=x.top;const it=a+x.left,Pt=mo(H,x),yt=Re(c,Pt);try{Wt({state:t,blocks:e.children,x:it,layoutForLevel:yt,onFirstBlockLayout:()=>{
|
|
176
|
+
q=!0},suppressTopSpacingForFirstBlock:!Ke(e.children[0])})}finally{K()}if(e.backgroundColor)for(let j=ut;j<t.fragments.length;j++){const dt=t.fragments[j];dt.backgroundFill===void 0&&(dt.backgroundFill=
|
|
177
|
+
e.backgroundColor)}t.currentY+=x.bottom;const Nt=Math.max(t.currentY-b,x.top+x.bottom),st=Math.max(u??0,Nt);W.bounds={...W.bounds,y:b,height:st,width:H},W.pageBreakBefore=R,W.pageNumber=St(t,W.bounds.
|
|
178
|
+
y);const J={x:a,y:W.bounds.y,width:H,height:st},lt={block:e,blockIndex:h,blockId:e.id||"",fragmentIndex:0,bounds:J,pageNumber:W.pageNumber,data:{type:"table-cell",...s&&{parentTableId:s.parentTableId,
|
|
179
|
+
tableDiffState:s.tableDiffState,rowDiffState:s.rowDiffState,isTopRow:s.isTopRow,isBottomRow:s.isBottomRow,isLeftCol:s.isLeftCol,isRightCol:s.isRightCol,isHeaderCell:s.isHeaderCell,tableBorderColor:s.tableBorderColor,
|
|
180
|
+
tableBorderWidth:s.tableBorderWidth,...s.tableBorders?{tableBorders:s.tableBorders}:{},tableCellPadding:s.tableCellPadding,gridRow:s.gridRow,gridCol:s.gridCol,rowSpan:s.rowSpan,colSpan:s.colSpan}}};t.
|
|
181
|
+
fragments.splice(ut,0,lt),t.blocks[E]=W;const ct=St(t,W.bounds.y);W.pageNumber=ct,lt.pageNumber=ct,u!==void 0&&(t.currentY=b+st),t.totalHeight=t.currentY}const Te=1e4;function Le(o,t,e){const a=e.indexForY(
|
|
182
|
+
o);if(o+t<=e.at(a).bottom)return{newY:o,pageChanged:!1};const c=e.length!==void 0?e.length-1:a+Te;for(let u=a+1;u<=c;u++){const s=e.at(u);if(s.full||s.top+t<=s.bottom||u===c)return u===c&&e.length===void 0&&
|
|
183
|
+
console.warn("Flow-window scan hit its defensive cap without finding a window that accepts the content; window geometry is broken."),{newY:s.top,pageChanged:!0}}return{newY:o,pageChanged:!1}}function Dt(o,t){
|
|
184
|
+
if(t<=0||o.layout.pageless)return!1;const e=o.layout.flowWindows,a=e&&e.length!==0?Le(o.currentY,t,e):ke(o.currentY,t,o.layout);return a.pageChanged?(o.currentY=a.newY,ie(o,a.newY),!0):!1}function We(o,t,e){
|
|
185
|
+
if(o.layout.pageless||o.pageStep<=0||e<=t)return e>t?[{y:t,height:e-t}]:[];const a=o.layout.flowWindows;if(a&&a.length!==0){const x=[];let m=t,v=a.indexForY(m);for(;m<e-rt;){const F=Math.min(e,a.at(v).
|
|
186
|
+
bottom);if(F>m&&x.push({y:m,height:F-m}),v+=1,a.length!==void 0&&v>=a.length){e>F&&x.push({y:F,height:e-F});break}m=Math.max(F,a.at(v).top)}return x}const{textStartY:c,pageHeight:u}=o.layout,s=o.layout.
|
|
187
|
+
sectionStartY??0,p=xt(o.layout),h=[];let k=t,H=Math.floor(Math.max(k-s-c,0)/o.pageStep);for(;k<e-rt;){const x=s+H*o.pageStep+u-p,m=Math.min(e,x);m>k&&h.push({y:k,height:m-k}),H+=1,k=Math.max(m,s+H*o.pageStep+
|
|
188
|
+
c)}return h}function Jt(o,t=o.currentY){if(o.layout.pageless||o.pageStep<=0)return t;const e=o.layout.flowWindows;if(e&&e.length!==0){const u=e.indexForY(t);return e.length!==void 0&&u+1>=e.length?t:e.
|
|
189
|
+
at(u+1).top}const a=o.layout.sectionStartY??0,c=Math.floor(Math.max(t-a-o.layout.textStartY,0)/o.pageStep);return a+(c+1)*o.pageStep+o.layout.textStartY}function Ro(o,t=o.currentY){const e=o.layout.flowWindows;
|
|
190
|
+
if(!e||e.length===0)return Jt(o,t);const a=e.indexForY(t),c=e.at(a).pageIndex,u=e.length!==void 0?e.length-1:a+Te;for(let s=a+1;s<=u;s++){const p=e.at(s);if(p.pageIndex>c)return p.top}return t}function St(o,t){
|
|
191
|
+
if(o.layout.pageless||o.pageStep<=0)return;const e=o.layout.flowWindows;if(e&&e.length!==0){const s=e.at(e.indexForY(t)).pageIndex+1;return o.currentPage=Math.max(o.currentPage,s),s}const a=o.layout.sectionStartY??
|
|
192
|
+
0,c=Math.floor(Math.max(t-a-o.layout.textStartY,0)/o.pageStep),u=(o.layout.sectionFirstPageIndex??0)+c+1;return o.currentPage=Math.max(o.currentPage,u),u}function Xt(o){if(o.layout.pageless||o.pageStep<=
|
|
193
|
+
0)return 1;const t=o.layout.sectionStartY??0,e=Math.max(o.totalHeight,o.currentY,t+o.layout.textStartY),a=Math.max(e-t-o.layout.textStartY-rt,0);return(o.layout.sectionFirstPageIndex??0)+Math.floor(a/
|
|
194
|
+
o.pageStep)+1}function Eo(o,t){const e=Math.max(1,o.pageHeight-o.textStartY-xt(o)),a=Math.max(o.textStartY,t.totalHeight),c=o.pageHeight+o.pageSpacing;let u;if(o.pageless||c<=0)u=(a-o.textStartY)/e;else{
|
|
195
|
+
const s=Math.max(1,t.pageCount),p=(t.pageGeometries?.[s-1]?.pageTop??(s-1)*c)+o.textStartY,h=Math.max(0,a-p),k=Math.max(.1,Math.min(1,h/e));u=s===1?k:s-1+k}return Math.round(Math.max(.1,u)*10)/10}function Re(o,t){
|
|
196
|
+
return{...o,availableWidth:t}}function se(o,t){return o.pageBreakListeners.push(t),()=>{const e=o.pageBreakListeners.lastIndexOf(t);e>=0&&o.pageBreakListeners.splice(e,1)}}function ie(o,t){if(o.pageBreakListeners.
|
|
197
|
+
length!==0)for(const e of o.pageBreakListeners)try{e(t)}catch(a){console.error("Error in page break listener",a)}}function Oo(o){if(typeof Buffer<"u")return Uint8Array.from(Buffer.from(o,"base64"));const t=atob(
|
|
198
|
+
o),e=new Uint8Array(t.length);for(let a=0;a<t.length;a++)e[a]=t.charCodeAt(a);return e}export{ae as K,Eo as a,Oo as b,wo as c,Se as d,ne as p};
|