@reviseio/engine 0.0.0-stage → 3.0.1
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 +21 -0
- package/FONT-LICENSE-HAN-EXT-B.txt +91 -0
- package/FONT-LICENSE-KATEX.txt +95 -0
- package/FONT-LICENSE-LIBERATION.txt +102 -0
- package/FONT-LICENSE-NOTO-MULTILINGUAL.txt +93 -0
- package/FONT-LICENSE-NOTO-SANS-SC.txt +93 -0
- package/FONT-LICENSE-NOTO.txt +94 -0
- package/FONT-LICENSE-SOURCE-CODE-PRO.txt +94 -0
- package/FONT-LICENSE-SOURCE-SERIF-4.txt +93 -0
- package/LICENSE +141 -0
- package/README.md +11 -2
- package/THIRD-PARTY-NOTICES.md +3376 -0
- package/assets/historyMaterializeWorker-Kl0syEbc.js +618 -0
- package/chunks/AgentHtmlConverter-CnnB8-WI.js +379 -0
- package/chunks/AgentPageRenderViews-BTLjPZJQ.js +2 -0
- package/chunks/AgentPageRenderer-DLgUGrGy.js +180 -0
- package/chunks/BidiText-Bkp4Y90s.js +160 -0
- package/chunks/BlockDiff-B6-aJxHo.js +42 -0
- package/chunks/CanvasRenderer-C1Vegx9Y.js +110 -0
- package/chunks/ColorParserFull-BKH72fK8.js +446 -0
- package/chunks/DocumentCompare-C8295s35.js +6 -0
- package/chunks/DocumentLayout-CsU5MR-3.js +12 -0
- package/chunks/DocumentLayoutEngine-C62pyGVf.js +218 -0
- package/chunks/DocumentMutator-Bat_oLBQ.js +13 -0
- package/chunks/DocumentScrubber-BZQn_z92.js +21 -0
- package/chunks/DocumentSession-BDcazSEv.js +1 -0
- package/chunks/DocumentStylesheet-CEEt18sr.js +7 -0
- package/chunks/DocxConverter-BC31uYIL.js +1236 -0
- package/chunks/DocxGraft-L10HXM3U.js +8 -0
- package/chunks/HorizontalRuleOrnaments-gmUZ3R7Q.js +3 -0
- package/chunks/HtmlConverter-C5ihhZ6G.js +267 -0
- package/chunks/ListNumbering-Qlu6AuRZ.js +23 -0
- package/chunks/MarkdownConverter-DofaSeC4.js +57 -0
- package/chunks/MathRenderer-Bz9WEVvF.js +68 -0
- package/chunks/OdtConverter-c1fTWoAt.js +125 -0
- package/chunks/OfficeImportShared-CrOpHpJ-.js +30 -0
- package/chunks/PageNumeralFonts-BWzI061X.js +5 -0
- package/chunks/ParagraphDiffAnalysis-DrmStvmz.js +36 -0
- package/chunks/PdfConverter-DX7fsRH5.js +457 -0
- package/chunks/RtfConverter-hbJ2529G.js +186 -0
- package/chunks/TableBorders-DVhdvo6f.js +32 -0
- package/chunks/TableGrid-DbroRucl.js +12 -0
- package/chunks/TextDecoding-IPbuUqcC.js +2 -0
- package/chunks/TextFileDecoder-BZBBejlR.js +10 -0
- package/chunks/TxtConverter-YHv5FXWb.js +14 -0
- package/chunks/Typography-B4gndEdB.js +28 -0
- package/chunks/UnicodeUtils-CXtusU4g.js +10 -0
- package/chunks/XmlConverter-BRRluy9k.js +55 -0
- package/chunks/_commonjsHelpers-DaMA6jEr.js +2 -0
- package/chunks/_revise-sdk-lazy-harfbuzz-CDWdjF9f.js +1 -0
- package/chunks/base64-Di1bxoXD.js +1 -0
- package/chunks/browser-module-CFmqfGkE.js +1791 -0
- package/chunks/bundle.min-DRpfgV69.js +782 -0
- package/chunks/capture-i_dPkQIS.js +11 -0
- package/chunks/carrier-pYM9xf6x.js +6 -0
- package/chunks/chromeImageLayout-BiQ3Iz1-.js +18 -0
- package/chunks/engine-LMUnxdm2.js +520 -0
- package/chunks/footnoteFlatten-EE85Hjre.js +6 -0
- package/chunks/graftExport-G-dG7Vcc.js +104 -0
- package/chunks/html2canvas.esm-CntiHiYW.js +997 -0
- package/chunks/index-BLb10wQt.js +1002 -0
- package/chunks/index-BWdRWxoH.js +1807 -0
- package/chunks/index.es-CI0QPo8w.js +780 -0
- package/chunks/jspdf.es.min-DU74zN8b.js +1792 -0
- package/chunks/jszip.min-CPW0h1Kx.js +476 -0
- package/chunks/katex-DWj8TvwO.js +1462 -0
- package/chunks/pdf-BLWDCiFF.js +1828 -0
- package/chunks/purify.es-BwLardii.js +107 -0
- package/chunks/serverDocumentSession-DGDU5Lh3.js +1011 -0
- package/chunks/signatures-DTNDS2PH.js +21 -0
- package/chunks/suggestionAuthorship-B-IuLQlE.js +1 -0
- package/chunks/web-tree-sitter-BXGZGnNj.js +2 -0
- package/chunks/xmlScan-DXjt2cTS.js +8 -0
- package/engine.d.ts +179 -0
- package/engine.js +3 -0
- package/package.json +64 -4
- package/serverToolContract.d.ts +420 -0
- package/serverToolInputs.generated.d.ts +264 -0
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import{bk as ne,bl as Pt,bm as Ht,bn as Nt,r as Gt,bo as Rt,R as zt,e as Ut,t as re,bp as se,bq as le,br as ce,bs as he,ae as Kt,bt as tt,af as jt,b0 as ge,aR as de,bu as Yt,bv as fe,bw as vt,bx as It,
|
|
2
|
+
by as dt,bz as me,bA as Pe,bB as pe,p as ue,a_ as Ft,h as Te,a8 as xe,ab as ye,a4 as Bt}from"./engine-LMUnxdm2.js";import{b as _e,s as be,o as Fe,p as Se,n as Le}from"./ListNumbering-Qlu6AuRZ.js";import{
|
|
3
|
+
e as $t,f as Vt,d as we,c as Oe,s as Ce,h as Me,i as ke,j as Ne,D as St,k as Re,l as ve,m as Ie,w as qt,n as Jt,o as Be,p as Zt,q as Qt,r as Ee,S as te}from"./index-BLb10wQt.js";import{m as De,p as Xe,
|
|
4
|
+
c as Ae,r as We,o as He,b as Ge,q as ze}from"./TableBorders-DVhdvo6f.js";import{b as Ue,n as Ke}from"./TableGrid-DbroRucl.js";import{i as je,l as Ye,s as $e,d as Ve}from"./HorizontalRuleOrnaments-gmUZ3R7Q.js";
|
|
5
|
+
import{c as qe,p as Et,K as ee,e as Je}from"./DocumentLayoutEngine-C62pyGVf.js";import{a as Ze}from"./chromeImageLayout-BiQ3Iz1-.js";import{l as Dt}from"./UnicodeUtils-CXtusU4g.js";import{createStandardLayout as Qe}from"./DocumentLayout-CsU5MR-3.js";
|
|
6
|
+
import{g as ta}from"./PageNumeralFonts-BWzI061X.js";import{l as Xt,a as ea,b as aa,g as ia,f as oa,i as na}from"./BidiText-Bkp4Y90s.js";import{r as Lt,o as ra,e as sa,d as la,b as ca}from"./MathRenderer-Bz9WEVvF.js";
|
|
7
|
+
import{L as ha,F as yt,l as wt,e as ae,g as ie,d as ga,f as da}from"./Typography-B4gndEdB.js";import{b as oe}from"./base64-Di1bxoXD.js";const kt=new Map;ra(()=>kt.clear());function fa(it){const t=String.
|
|
8
|
+
fromCharCode(...it.subarray(0,4));return it[0]===0&&it[1]===1&&it[2]===0&&it[3]===0||t==="true"||t==="OTTO"}function ma(it){let t="";for(let e=0;e<it.length;e+=32768)t+=String.fromCharCode(...it.subarray(
|
|
9
|
+
e,e+32768));return btoa(t)}async function Pa(it){try{const t=await fetch(Lt(`fonts/${encodeURIComponent(it)}`),{credentials:"omit"});if(!t.ok)return null;const e=new Uint8Array(await t.arrayBuffer());
|
|
10
|
+
return fa(e)?ma(e):null}catch{return null}}async function pa(it){let t=kt.get(it);return t||(t=Pa(it),kt.set(it,t),t.then(e=>{e===null&&kt.delete(it)})),t}const J=it=>({normal:it,bold:it}),ua={japanese:{
|
|
11
|
+
family:"NotoSansJP",probeCodePoint:12354,charRegex:/[\p{Script=Hiragana}\p{Script=Katakana}]/u,files:J("NotoSansJP-Regular.ttf")},korean:{family:"NotoSansKR",probeCodePoint:54620,charRegex:/\p{Script=Hangul}/u,
|
|
12
|
+
files:J("NotoSansKR-Regular.ttf")},devanagari:{family:"NotoSansDevanagari",probeCodePoint:2309,charRegex:/\p{Script=Devanagari}/u,files:J("NotoSansDevanagari-Regular.ttf"),shape:!0},bengali:{family:"N\
|
|
13
|
+
otoSansBengali",probeCodePoint:2437,charRegex:/\p{Script=Bengali}/u,files:J("NotoSansBengali-Regular.ttf"),shape:!0},gurmukhi:{family:"NotoSansGurmukhi",probeCodePoint:2565,charRegex:/\p{Script=Gurmukhi}/u,
|
|
14
|
+
files:J("NotoSansGurmukhi-Regular.ttf"),shape:!0},gujarati:{family:"NotoSansGujarati",probeCodePoint:2693,charRegex:/\p{Script=Gujarati}/u,files:J("NotoSansGujarati-Regular.ttf"),shape:!0},oriya:{family:"\
|
|
15
|
+
NotoSansOriya",probeCodePoint:2821,charRegex:/\p{Script=Oriya}/u,files:J("NotoSansOriya-Regular.ttf"),shape:!0},tamil:{family:"NotoSansTamil",probeCodePoint:2949,charRegex:/\p{Script=Tamil}/u,files:J(
|
|
16
|
+
"NotoSansTamil-Regular.ttf"),shape:!0},telugu:{family:"NotoSansTelugu",probeCodePoint:3077,charRegex:/\p{Script=Telugu}/u,files:J("NotoSansTelugu-Regular.ttf"),shape:!0},kannada:{family:"NotoSansKanna\
|
|
17
|
+
da",probeCodePoint:3205,charRegex:/\p{Script=Kannada}/u,files:J("NotoSansKannada-Regular.ttf"),shape:!0},malayalam:{family:"NotoSansMalayalam",probeCodePoint:3333,charRegex:/\p{Script=Malayalam}/u,files:J(
|
|
18
|
+
"NotoSansMalayalam-Regular.ttf"),shape:!0},sinhala:{family:"NotoSansSinhala",probeCodePoint:3461,charRegex:/\p{Script=Sinhala}/u,files:J("NotoSansSinhala-Regular.ttf"),shape:!0},thai:{family:"NotoSans\
|
|
19
|
+
Thai",probeCodePoint:3585,charRegex:/\p{Script=Thai}/u,files:J("NotoSansThai-Regular.ttf"),shape:!0},lao:{family:"NotoSansLao",probeCodePoint:3713,charRegex:/\p{Script=Lao}/u,files:J("NotoSansLao-Regu\
|
|
20
|
+
lar.ttf"),shape:!0},khmer:{family:"NotoSansKhmer",probeCodePoint:6016,charRegex:/\p{Script=Khmer}/u,files:J("NotoSansKhmer-Regular.ttf"),shape:!0},myanmar:{family:"NotoSansMyanmar",probeCodePoint:4096,
|
|
21
|
+
charRegex:/\p{Script=Myanmar}/u,files:J("NotoSansMyanmar-Regular.ttf"),shape:!0},tibetan:{family:"NotoSerifTibetan",probeCodePoint:3904,charRegex:/\p{Script=Tibetan}/u,files:J("NotoSerifTibetan-Regula\
|
|
22
|
+
r.ttf"),shape:!0},ethiopic:{family:"NotoSansEthiopic",probeCodePoint:4608,charRegex:/\p{Script=Ethiopic}/u,files:J("NotoSansEthiopic-Regular.ttf")},armenian:{family:"NotoSansArmenian",probeCodePoint:1329,
|
|
23
|
+
charRegex:/\p{Script=Armenian}/u,files:J("NotoSansArmenian-Regular.ttf")},georgian:{family:"NotoSansGeorgian",probeCodePoint:4304,charRegex:/\p{Script=Georgian}/u,files:J("NotoSansGeorgian-Regular.ttf")},
|
|
24
|
+
syriac:{family:"NotoSansSyriac",probeCodePoint:1808,charRegex:/\p{Script=Syriac}/u,files:J("NotoSansSyriac-Regular.ttf"),shape:!0},thaana:{family:"NotoSansThaana",probeCodePoint:1920,charRegex:/\p{Script=Thaana}/u,
|
|
25
|
+
files:J("NotoSansThaana-Regular.ttf"),shape:!0},arabic:{family:"NotoNaskhArabic",probeCodePoint:1575,charRegex:/[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/,files:{normal:"Noto\
|
|
26
|
+
NaskhArabic-Regular.ttf",bold:"NotoNaskhArabic-Bold.ttf"}},hebrew:{family:"NotoSansHebrew",probeCodePoint:1488,charRegex:/[\u0590-\u05FF\uFB1D-\uFB4F]/,files:{normal:"NotoSansHebrew-Regular.ttf",bold:"\
|
|
27
|
+
NotoSansHebrew-Bold.ttf"}},cjkExtensionB:{family:"HanExtBSubset",probeCodePoint:131079,charRegex:/[\u{20000}-\u{207FF}]/u,files:J("HanExtBSubset-Regular.ttf"),shape:!0},han:{family:"NotoSansSC",probeCodePoint:20013,
|
|
28
|
+
charRegex:/[\p{Script=Han}\p{Script=Bopomofo}\u3000-\u303F\uFE30-\uFE4F\uFF00-\uFFEF]/u,files:J("NotoSansSC-Regular.ttf")},emoji:{family:"NotoEmoji",probeCodePoint:128512,charRegex:/[\p{Extended_Pictographic}\p{Regional_Indicator}]/u,
|
|
29
|
+
files:J("NotoEmoji-Regular.ttf"),shape:!0},arrows:{family:"NotoSansSymbols",probeCodePoint:8592,charRegex:/[\u2190-\u21FF]/u,files:J("NotoSansSymbols-Regular.ttf")},symbols:{family:"NotoSansSymbols2",
|
|
30
|
+
probeCodePoint:9728,charRegex:/[\u2300-\u23FF\u2460-\u24FF\u25A0-\u27BF\u2B00-\u2BFF\u{1F000}-\u{1F2FF}]/u,files:J("NotoSansSymbols2-Regular.ttf"),shape:!0}},v=class st{static async ensureAllLatexRendered(t){
|
|
31
|
+
const e=[],a=new Set,i=(o,l)=>{const n=`${l}:${o}`;!a.has(n)&&o.trim()&&(a.add(n),e.push({content:o,displayMode:l}))},r=o=>{if(!o||typeof o!="object")return;if(Array.isArray(o)){o.forEach(r);return}const l=o;
|
|
32
|
+
l.type==="math"&&l.content?i(l.content,l.displayMode!=="inline"):l.type==="text"&&l.marks?.latex&&l.text&&i(l.text,!1),r(l.children)};r(t.children),r(t.chrome),r(t.notes),await Promise.all(e.map(o=>sa(
|
|
33
|
+
o.content,o.displayMode)))}static getLatexSvgFromCache(t,e){return la(t,e)}static async svgToPng(t,e,a,i=3){return new Promise(r=>{const o=new Image,l="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(
|
|
34
|
+
t);o.onload=()=>{try{const n=document.createElement("canvas");n.width=e*i,n.height=a*i;const h=n.getContext("2d");if(!h){r(null);return}h.scale(i,i),h.drawImage(o,0,0,e,a),r(n.toDataURL("image/png"))}catch(n){
|
|
35
|
+
console.error("Failed to convert SVG to PNG:",n),r(null)}},o.onerror=()=>{r(null)},o.src=l})}static async loadFontFile(t,e=!0){const a=Lt(`fonts/${t}`),i=this.fontFileData.get(a);if(i!==void 0)return i;
|
|
36
|
+
const r=await pa(t);let o=r??null;try{if(r===void 0){const l=await fetch(Lt(`fonts/${t}`));if(l.ok){const n=await l.arrayBuffer();Ht(new Uint8Array(n))==="ttf"&&(o=this.arrayBufferToBase64(n))}}}catch{}
|
|
37
|
+
return o||(o=await this.readFontFromDisk(t)),!o&&e&&console.warn(`Failed to load font ${t}; PDF export used a fallback font. Embedded editors: if revise.io is unreachable, mirror the fonts and call se\
|
|
38
|
+
tAssetBaseUrl().`),this.fontFileData.set(a,o),o}static async readFontFromDisk(t){try{const{readFile:e}=await import("fs/promises"),{join:a}=await import("path"),i=[a(process.cwd(),"public","fonts",t),
|
|
39
|
+
a(process.cwd(),"frontend","public","fonts",t),a(process.cwd(),"..","frontend","public","fonts",t),a(process.cwd(),"..","..","frontend","public","fonts",t)];for(const r of i)try{return(await e(r)).toString(
|
|
40
|
+
"base64")}catch{}}catch{}return null}static async loadSourceCodePro(t){const e=await this.loadFontFile("SourceCodePro-Regular.ttf",!1);return e?(t.addFileToVFS("SourceCodePro-Regular.ttf",e),t.addFont(
|
|
41
|
+
"SourceCodePro-Regular.ttf","SourceCodePro","normal"),!0):!1}static async loadKaTeXMain(t){const e=[{file:"KaTeX_Main-Regular.ttf",style:"normal"},{file:"KaTeX_Main-Bold.ttf",style:"bold"},{file:"KaTe\
|
|
42
|
+
X_Main-Italic.ttf",style:"italic"},{file:"KaTeX_Main-BoldItalic.ttf",style:"bolditalic"}],a=await Promise.all(e.map(async i=>{const r=await this.loadFontFile(i.file);return r?{...i,base64:r}:null}));for(const i of a)
|
|
43
|
+
i&&(t.addFileToVFS(i.file,i.base64),t.addFont(i.file,"KaTeX_Main",i.style));return a[0]!==null}static async embedBundledGenreFonts(t,e,a){this.bundledGenreFamilies.clear();const i=new Set,r=o=>{const l=this.
|
|
44
|
+
mapFontFamilyToStandard(o);this.BUNDLED_GENRE_FONTS[l]&&i.add(l)};r(a);for(const o of Nt(e))r(o.value);for(const o of i){const l=this.BUNDLED_GENRE_FONTS[o],n=await Promise.all(Object.entries(l.files).
|
|
45
|
+
map(async([h,s])=>({style:h,file:s,base64:await this.loadFontFile(s)})));if(!n.some(h=>!h.base64)){for(const{style:h,file:s,base64:g}of n)t.addFileToVFS(s,g),t.addFont(s,l.family,h);this.bundledGenreFamilies.
|
|
46
|
+
set(o,l.family)}}}static documentFallbackScripts(t){const e=new Set,a=Object.keys(this.SCRIPT_FALLBACK_FONTS),i=r=>{if(e.size===a.length||!r||typeof r!="object")return;if(Array.isArray(r)){r.forEach(i);
|
|
47
|
+
return}const o=r;if(typeof o.text=="string"&&o.text)for(const l of a)!e.has(l)&&this.SCRIPT_FALLBACK_FONTS[l].charRegex.test(o.text)&&e.add(l);i(o.children)};return i(t.children),i(t.chrome),i(t.notes),
|
|
48
|
+
e}static splitDocumentFallbackRuns(t,e){const a=Object.entries(this.SCRIPT_FALLBACK_FONTS),i=s=>{const g=a.filter(([,P])=>P.charRegex.test(s)).map(([P])=>P);if(g.length>1&&e){const P=s.codePointAt(0)??
|
|
49
|
+
0,c=g.find(f=>e(f,P));if(c)return c}return g[0]},r=/[\p{Letter}\p{Number}]/u,o=this.SCRIPT_FALLBACK_FONTS.japanese.charRegex,l=this.SCRIPT_FALLBACK_FONTS.korean.charRegex,n=s=>{const g=s.text??"";if(!g)
|
|
50
|
+
return[{...s}];const P=[];let c="",f=null;for(const d of g.split(/(\s+)/)){const T=o.test(d)?"japanese":l.test(d)?"korean":null;for(const m of d){let x=i(m);if(x==="han"&&T&&(x=T),!x&&r.test(m)&&(x="b\
|
|
51
|
+
ase"),!x){f?f.text+=m:c+=m;continue}!f||f.key!==x?(f&&P.push(f),f={key:x,text:c+m},c=""):f.text+=m}}return f?(f.text+=c,P.push(f)):P.push({key:"base",text:c}),P.map(d=>{if(d.key==="base")return{...s,text:d.
|
|
52
|
+
text};const T=this.SCRIPT_FALLBACK_FONTS[d.key];return{...s,text:d.text,marks:{...s.marks,fontFamily:T.family}}})},h=s=>Array.isArray(s)?s.flatMap(g=>g&&typeof g=="object"&&g.type==="text"?n(g):[h(g)]):
|
|
53
|
+
!s||typeof s!="object"?s:Object.fromEntries(Object.entries(s).map(([g,P])=>[g,h(P)]));return h(t)}static async loadFallbackCoverage(t){const e=Object.entries(this.SCRIPT_FALLBACK_FONTS),a=new Set,i=new Set,
|
|
54
|
+
r=l=>{if(!l||typeof l!="object")return;if(Array.isArray(l)){l.forEach(r);return}const n=l;if(typeof n.text=="string")for(const h of n.text){if(i.has(h)||h.charCodeAt(0)<128)continue;i.add(h);const s=e.
|
|
55
|
+
filter(([,g])=>g.charRegex.test(h));s.length>1&&s.forEach(([g])=>a.add(g))}r(n.children)};r(t.children),r(t.chrome),r(t.notes);const o=new Map;for(const l of a){const n=this.SCRIPT_FALLBACK_FONTS[l].files.
|
|
56
|
+
normal;let h=this.fallbackCharsetCache.get(n);if(h===void 0){h=null;const s=await this.loadFontFile(n,!1);if(s)try{const g=(await import("./browser-module-CFmqfGkE.js")).create(oe(s));h=new Set(g.characterSet??
|
|
57
|
+
[])}catch{h=null}this.fallbackCharsetCache.set(n,h)}h&&o.set(l,h)}return(l,n)=>{const h=o.get(l);return h?h.has(n):!0}}static async embedScriptFallbackFonts(t,e){this.scriptFallbackFamilies.clear(),this.
|
|
58
|
+
shapingFonts.clear();for(const a of this.documentFallbackScripts(e)){const i=await this.registerScriptFallbackFace(t,a);i&&this.scriptFallbackFamilies.set(a,i)}}static async registerScriptFallbackFace(t,e){
|
|
59
|
+
const a=this.SCRIPT_FALLBACK_FONTS[e];if(!a)return null;const i=await this.loadFontFile(a.files.normal);if(!i)return null;const r=await this.loadFontFile(a.files.bold,!1);t.addFileToVFS(a.files.normal,
|
|
60
|
+
i),r&&a.files.bold!==a.files.normal&&t.addFileToVFS(a.files.bold,r);const o=r?a.files.bold:a.files.normal;if(t.addFont(a.files.normal,a.family,"normal"),t.addFont(o,a.family,"bold"),t.addFont(a.files.
|
|
61
|
+
normal,a.family,"italic"),t.addFont(o,a.family,"bolditalic"),a.shape&&!this.shapingFonts.has(a.family))try{const[l,n]=await Promise.all([import("./browser-module-CFmqfGkE.js"),import("./_revise-sdk-lazy-harfbuzz-CDWdjF9f.js")]),
|
|
62
|
+
h=n,s=h.loadHarfBuzz?await h.loadHarfBuzz():n,g=oe(i),P=l.create(g),c=new s.Blob(g),f=new s.Face(c),d=new s.Font(f);this.shapingFonts.set(a.family,{unitsPerEm:f.upem,notdefPathCommands:P.getGlyph(0).path.
|
|
63
|
+
commands,layout:T=>{const m=new s.Buffer;m.addText(T),m.guessSegmentProperties(),s.shape(d,m);const x=m.getGlyphInfosAndPositions(),F=x.map(y=>({xAdvance:y.xAdvance??0,yAdvance:y.yAdvance??0,xOffset:y.
|
|
64
|
+
xOffset??0,yOffset:y.yOffset??0}));return{glyphs:x.map(y=>P.getGlyph(y.codepoint)),positions:F,advanceWidth:F.reduce((y,E)=>y+E.xAdvance,0)}}})}catch(l){console.warn(`Failed to initialize PDF shaping \
|
|
65
|
+
for ${a.family}:`,l)}return a.family}static fontCoversCodePoint(t,e,a){const i=`${e}:${a}`;let r=this.scriptFontCoverageCache.get(i);if(r===void 0){let o;try{o=t.getFont(e,"normal")}catch{o=void 0}r=!!o?.
|
|
66
|
+
metadata?.cmap?.unicode?.codeMap?.[a],this.scriptFontCoverageCache.set(i,r)}return r}static fontCoversMatchedChars(t,e,a,i){let r=!1;for(const o of a)if(i.test(o)&&(r=!0,!this.fontCoversCodePoint(t,e,
|
|
67
|
+
o.codePointAt(0)??0)))return!1;return r}static scriptFallbackFor(t,e,a){if(!e||this.scriptFallbackFamilies.size===0)return null;let i=null;for(const[r,o]of Object.entries(this.SCRIPT_FALLBACK_FONTS)){
|
|
68
|
+
const l=this.scriptFallbackFamilies.get(r);if(l&&o.charRegex.test(e)&&!this.fontCoversCodePoint(t,a,o.probeCodePoint)&&!this.fontCoversMatchedChars(t,a,e,o.charRegex)){if(this.fontCoversMatchedChars(t,
|
|
69
|
+
l,e,o.charRegex))return l;i??(i=l)}}return i}static async registerDocumentFonts(t,e,a){await this.embedLocalFonts(t,e),await this.embedBundledGenreFonts(t,e,a),await this.embedScriptFallbackFonts(t,e);
|
|
70
|
+
const i=this.documentUsesSourceCodePro(e)?await this.loadSourceCodePro(t):!1;return this.inlineCodeFontFamily=i?"SourceCodePro":"courier",this.documentUsesKaTeXMain(e)&&await this.loadKaTeXMain(t),{hasSourceCodePro:i}}static async registerCurrentPdfFonts(t,e){
|
|
71
|
+
for(const[a,i]of this.bundledGenreFamilies){const r=this.BUNDLED_GENRE_FONTS[a];if(!r||r.family!==i)continue;const o=await Promise.all(Object.entries(r.files).map(async([l,n])=>({style:l,file:n,base64:await this.
|
|
72
|
+
loadFontFile(n)})));for(const{style:l,file:n,base64:h}of o)h&&(t.addFileToVFS(n,h),t.addFont(n,i,l))}for(const a of this.scriptFallbackFamilies.keys())await this.registerScriptFallbackFace(t,a);e&&await this.
|
|
73
|
+
loadSourceCodePro(t)}static documentUsesKaTeXMain(t){return Nt(t).some(e=>{const a=e.family.toLowerCase();return a.includes("katex")||a.includes("computer modern")||a.includes("computermodern")})}static documentUsesSourceCodePro(t){
|
|
74
|
+
const e=[...t.children];for(;e.length>0;){const a=e.pop();if(!a||typeof a!="object")continue;const i=a;if(i.type==="code"||i.type==="text"&&typeof i.marks=="object"&&i.marks!==null&&i.marks.code===!0)
|
|
75
|
+
return!0;Array.isArray(i.children)&&e.push(...i.children)}return!1}static createCanvasTextContext(){if(typeof document>"u")return null;const t=document.createElement("canvas").getContext("2d");if(!t)return null;
|
|
76
|
+
let e=null;return{measureText:a=>({width:$t(a,e,i=>t.measureText(i).width)}),setFont:a=>{t.font=a,e=null},setMarkAdjustments:a=>{e=a}}}static resolveIndentStepPx(t){return this.resolvePdfLayoutMetrics(
|
|
77
|
+
t).indentStepPx}static getDefaultPdfLayoutMetrics(){const t=Gt(void 0),e=Math.max(1,this.PAGE_WIDTH-this.MARGIN_LEFT-this.MARGIN_RIGHT);return{orientation:"portrait",pageWidthPt:this.PAGE_WIDTH,pageHeightPt:this.
|
|
78
|
+
PAGE_HEIGHT,marginTopPt:this.MARGIN_TOP,marginRightPt:this.MARGIN_RIGHT,marginBottomPt:this.MARGIN_BOTTOM,marginLeftPt:this.MARGIN_LEFT,contentWidthPt:e,fullContentWidthPt:e,pageMarginLeftPt:this.MARGIN_LEFT,
|
|
79
|
+
columnCount:1,columnGapPt:Rt(t.columnGapTwips),columnStridePt:Vt(e,Rt(t.columnGapTwips)),blockSpacingPt:t.blockSpacingPx*this.PX_TO_PT,indentStepPx:t.indentStepPx,showPageNumbers:t.showPageNumbers,pageBorders:t.
|
|
80
|
+
pageBorders,pageNumberPosition:t.pageNumberPosition,pageNumberStart:t.pageNumberStart,pageNumberFormat:t.pageNumberFormat,hyphenationEnabled:t.hyphenationEnabled,lineNumbering:t.lineNumbering,pleadingGrid:t.
|
|
81
|
+
pleadingGrid}}static resolvePdfLayoutMetrics(t){return this.resolvePdfMetricsFromSettings(t?.pageLayout,t?.pageLayout,!1)}static resolvePdfMetricsFromSettings(t,e,a=!1){const i=zt(e,t),r=t,{pageWidth:o,
|
|
82
|
+
pageHeight:l}=Ut(i),n=o*this.PX_TO_PT,h=l*this.PX_TO_PT,s=i.marginTopPx*this.PX_TO_PT,g=i.marginRightPx*this.PX_TO_PT,P=i.marginBottomPx*this.PX_TO_PT,c=i.marginLeftPx*this.PX_TO_PT,f=Math.max(1,n-c-g),
|
|
83
|
+
d=Math.max(1,i.columnCount),T=Rt(i.columnGapTwips),m=we(f,d,T);return{orientation:i.orientation,pageWidthPt:n,pageHeightPt:h,marginTopPt:s,marginRightPt:g,marginBottomPt:P,marginLeftPt:c,contentWidthPt:m,
|
|
84
|
+
fullContentWidthPt:f,pageMarginLeftPt:c,columnCount:d,columnGapPt:T,columnStridePt:Vt(m,T),...d>1?{columnFlow:{index:0,topPt:s,pageOffset:0}}:{},blockSpacingPt:i.blockSpacingPx*this.PX_TO_PT,indentStepPx:i.
|
|
85
|
+
indentStepPx,showPageNumbers:i.showPageNumbers,pageBorders:i.pageBorders,pageNumberPosition:i.pageNumberPosition,pageNumberStart:i.pageNumberStart,pageNumberStartExplicit:a&&r?.pageNumberStart!==void 0,
|
|
86
|
+
pageNumberFormat:i.pageNumberFormat,hyphenationEnabled:i.hyphenationEnabled,lineNumbering:i.lineNumbering,pleadingGrid:i.pleadingGrid}}static physicalPageMetrics(t){return{...t,marginLeftPt:t.pageMarginLeftPt,
|
|
87
|
+
contentWidthPt:t.fullContentWidthPt,columnFlow:void 0,reservedInsetForPage:void 0}}static computeEngineLayout(t){if(typeof document>"u")return null;const e=document.createElement("canvas").getContext(
|
|
88
|
+
"2d");if(!e)return null;const a=Gt(t.pageLayout),i=Ut(a),r=Qe({pageWidth:i.pageWidth,pageHeight:i.pageHeight,pageMargin:a.marginLeftPx,pageMarginTop:a.marginTopPx,pageMarginRight:a.marginRightPx,pageMarginBottom:a.
|
|
89
|
+
marginBottomPx,pageMarginLeft:a.marginLeftPx,availableWidth:Math.max(1,i.pageWidth-a.marginLeftPx-a.marginRightPx),textStartY:a.marginTopPx,indentStepPx:a.indentStepPx,blockSpacingPx:a.blockSpacingPx,
|
|
90
|
+
hyphenationEnabled:a.hyphenationEnabled,lineNumbering:a.lineNumbering,columnCount:a.columnCount,columnGapPx:re(a.columnGapTwips),pageless:!1});try{return qe(t,Oe(e),r)}catch{return null}}static computeColumnBalanceTargets(t,e){
|
|
91
|
+
const a=new Map,i=e.filter(g=>g.type==="section-break"),r=new Set;if(i.forEach((g,P)=>{const c=zt(t.pageLayout,g.layout);Ce(Math.max(1,c.columnCount),g.breakType==="continuous")&&r.add(P)}),r.size===0)
|
|
92
|
+
return a;const o=this.computeEngineLayout(t);if(!o?.pageGeometries||o.pageGeometries.length===0)return a;const l=new Map(o.pageGeometries.map(g=>[g.pageIndex+1,g.pageTop])),n=(g,P)=>{if(!g||typeof g!=
|
|
93
|
+
"object")return;if(Array.isArray(g)){g.forEach(f=>n(f,P));return}const c=g;typeof c.id=="string"&&c.id&&P.add(c.id),n(c.children,P)},h=new Map;let s=0;for(const g of e){if(g.type==="section-break"){s+=
|
|
94
|
+
1;continue}let P=h.get(s);P||(P=new Set,h.set(s,P)),n(g,P)}for(const g of r){const P=h.get(g);if(!P||P.size===0)continue;const c=o.fragments.filter(x=>!x.isChrome&&typeof x.pageNumber=="number"&&P.has(
|
|
95
|
+
x.blockId));if(c.length===0)continue;let f=Number.POSITIVE_INFINITY,d=0;for(const x of c)f=Math.min(f,x.pageNumber),d=Math.max(d,x.pageNumber);const T=l.get(d);if(T===void 0)continue;let m=0;for(const x of c)
|
|
96
|
+
x.pageNumber===d&&(m=Math.max(m,x.bounds.y+x.bounds.height-T));m<=0||a.set(g,{pageOffset:d-f,bottomPt:m*this.PX_TO_PT+this.COLUMN_BALANCE_SLACK_PT})}return a}static advancePdfColumnOrPage(t,e){const a=e.
|
|
97
|
+
columnFlow;return!a||e.columnCount<=1?(t.addPage(),!0):a.index<e.columnCount-1?(a.index+=1,e.marginLeftPt=e.pageMarginLeftPt+a.index*e.columnStridePt,!1):(a.index=0,e.marginLeftPt=e.pageMarginLeftPt,t.
|
|
98
|
+
addPage([e.pageWidthPt,e.pageHeightPt],e.orientation),a.topPt=e.marginTopPt,a.pageOffset+=1,!0)}static advancePdfFlowRegion(t,e){const a=this.advancePdfColumnOrPage(t,e);return{x:e.marginLeftPt,y:a?e.
|
|
99
|
+
marginTopPt:e.columnFlow?.topPt??e.marginTopPt}}static declaredSpacingPx(t,e){const a=t?.[e];return typeof a=="number"&&Number.isFinite(a)?Math.max(0,a):void 0}static pdfSpaceBeforePt(t,e,a){const i=Me(
|
|
100
|
+
a,t)??st.declaredSpacingPx(t,"spaceBefore");return i!==void 0?i*st.PX_TO_PT:e.blockSpacingPt}static pdfSpaceAfterPt(t,e){const a=ke(t,e)??st.declaredSpacingPx(t,"spaceAfter");return a!==void 0?a*st.PX_TO_PT:
|
|
101
|
+
0}static syncPdfColumnOffset(t){const e=t.columnFlow;!e||t.columnCount<=1||(t.marginLeftPt=t.pageMarginLeftPt+e.index*t.columnStridePt)}static getPdfReservedInsetPt(t,e){return e.reservedInsetForPage?.
|
|
102
|
+
get(this.getPdfCurrentPage(t))??0}static getPdfWritableBottomPt(t,e){return e.pageHeightPt-e.marginBottomPt-this.getPdfReservedInsetPt(t,e)}static getPdfFlowBottom(t,e){const a=this.getPdfWritableBottomPt(
|
|
103
|
+
t,e),i=e.columnFlow;return!i?.balance||e.columnCount<=1||i.pageOffset!==i.balance.pageOffset?a:Math.min(a,i.balance.bottomPt)}static getPdfPageCount(t){return typeof t.getNumberOfPages=="function"?t.getNumberOfPages():
|
|
104
|
+
typeof t.internal?.getNumberOfPages=="function"?t.internal.getNumberOfPages():1}static getPdfCurrentPage(t){return t.getCurrentPageInfo?.().pageNumber??this.getPdfPageCount(t)}static createPdfPageNumbering(t,e,a){
|
|
105
|
+
const i=[...e?.keys()??[]].sort((n,h)=>n-h),r=n=>{let h=t;for(const s of i){if(s>n)break;h=e.get(s)}return h},o=[],l=n=>{const h=Math.max(1,Math.floor(n));for(let s=o.length+1;s<=h;s++){const g=r(s);o.
|
|
106
|
+
push(s===1||a?.has(s)&&g.pageNumberStartExplicit?g.pageNumberStart:o[s-2]+1)}return o[h-1]};return{metricsForPage:r,numberForPage:l,labelForPage:n=>se(l(n),r(n).pageNumberFormat)}}static async renderHeaderFooterChrome(t,e,a,i,r,o){
|
|
107
|
+
const l=this.getPdfPageCount(t),n=f=>{if(!r)return a;let d=a,T=0;for(const[m,x]of r)m<=f&&m>T&&(d=x,T=m);return d},h=f=>{if(!o)return 0;let d=0,T=0;for(const[m,x]of o)m<=f&&m>T&&(d=x,T=m);return d},s=f=>{
|
|
108
|
+
if(!o)return 1;let d=1;for(const[T]of o)T<=f&&T>d&&(d=T);return d},g=this.createPdfPageNumbering(a,r,o).labelForPage,P=(f,d)=>{if(e.chrome&&e.chrome.length>0)return Te(e.chrome,f,d,h(d));const T=f==="\
|
|
109
|
+
header"?e.headers:e.footers;if(!T)return;const m=d===s(d)&&T.first?"first":d%2===0&&T.even?"even":"default",x=T[m];if(x)return xe(f,m,ye(x),i)},c=async(f,d,T)=>{const m=n(T),x=f.children.slice(0,3).map(
|
|
110
|
+
(k,I)=>{const p=Bt[I];return{...k,...p&&!k.align?{align:p}:{},children:k.children.map(u=>u.type!=="text"||!u.marks?.field?u:u.marks.field==="page"?{...u,text:g(T)}:{...u,text:String(l)})}});for(;x.length<
|
|
111
|
+
3;){const k=x.length;x.push({type:"paragraph",id:`${f.id}-pdf-column-${k}`,children:[{type:"text",text:""}],...Bt[k]?{align:Bt[k]}:{}})}const F=this.createLayoutForWrapping(m.contentWidthPt,m.indentStepPx,
|
|
112
|
+
m),y=this.createCanvasTextContext(),E=y?Je(f,y,F,e,x).map(k=>k*this.PX_TO_PT):[m.contentWidthPt/3,m.contentWidthPt/3,m.contentWidthPt/3],R=d?Math.max(10*this.PX_TO_PT,m.marginTopPt/2):m.pageHeightPt-Math.
|
|
113
|
+
max(10*this.PX_TO_PT,m.marginBottomPt/2);let B=m.marginLeftPt;for(let k=0;k<3;k++){const I=x[k],p=E[k],u=this.measureParagraphLineAdvances(I,p,m.indentStepPx,m).reduce((C,D)=>C+D,0),S=R-u/2,w={...m,marginTopPt:S,
|
|
114
|
+
marginLeftPt:B,marginRightPt:Math.max(0,m.pageWidthPt-B-p),contentWidthPt:Math.max(1,p)};await this.renderParagraph(t,I,S,p,i,1e9,m.indentStepPx,w),B+=p}};for(let f=0;f<l;f++){const d=f+1;t.setPage(d);
|
|
115
|
+
const T=P("header",d),m=P("footer",d);T&&await c(T,!0,d),m&&await c(m,!1,d),await this.drawChromeImages(t,e,n(d),d,h(d))}this.renderPageNumbers(t,a,i,n,g,(f,d)=>!!P(d,f));for(let f=1;f<=l;f++){const d=n(
|
|
116
|
+
f),T=le(d.pageBorders,d.pageWidthPt,d.pageHeightPt,{top:d.marginTopPt,right:d.marginRightPt,bottom:d.marginBottomPt,left:d.pageMarginLeftPt},f===s(f));if(!T.length)continue;t.setPage(f);const m=t.internal?.
|
|
117
|
+
pages?.[f],x=m?.length??0;t.saveGraphicsState(),t.setLineCap?.("square");for(const F of T){t.setDrawColor(F.color),t.setLineWidth(F.style==="double"?F.widthPt/3:F.widthPt),t.setLineDashPattern(F.style===
|
|
118
|
+
"dotted"?[F.widthPt,F.widthPt*2]:F.style==="dashed"?[F.widthPt*4,F.widthPt*2]:[],0);for(const y of F.style==="double"?[-F.widthPt/3,F.widthPt/3]:[0]){const E=F.x1===F.x2?y:0,R=F.y1===F.y2?y:0;t.line(F.
|
|
119
|
+
x1+E,F.y1+R,F.x2+E,F.y2+R)}}t.restoreGraphicsState(),d.pageBorders?.zOrder==="back"&&m&&m.unshift(...m.splice(x))}}static async drawChromeImages(t,e,a,i,r){if(!e.chromeImages?.length)return;const o=Ze(
|
|
120
|
+
{chrome:e.chrome??[],records:e.chromeImages,pageNumber:i,isFirstPage:i===1,sectionIndex:r,pageWidth:a.pageWidthPt,pageHeight:a.pageHeightPt,marginTop:a.marginTopPt,marginBottom:a.marginBottomPt,marginLeft:a.
|
|
121
|
+
pageMarginLeftPt,marginRight:Math.max(0,a.pageWidthPt-a.pageMarginLeftPt-a.fullContentWidthPt),unit:this.PX_TO_PT});for(const l of o){const n=await this.resolveImageDataCached(t,l.src);if(n)try{t.addImage(
|
|
122
|
+
n.data,n.format,l.x,l.y,l.width,l.height)}catch(h){console.error("Failed to add header/footer image to PDF",h)}}}static drawWatermarkOnPage(t,e,a,i){t.setFont("helvetica","normal");const r=De(e,a/this.
|
|
123
|
+
PX_TO_PT,i/this.PX_TO_PT,(x,F)=>{t.setFontSize(F*this.PX_TO_PT);const y=t.getTextWidth(x);return typeof y=="number"?y/this.PX_TO_PT:0})*this.PX_TO_PT;t.setFontSize(r);const o=t.getTextWidth(e.text),l=this.
|
|
124
|
+
hexToRgb(e.color);t.setTextColor(l.r,l.g,l.b);const n=typeof t.saveGraphicsState=="function"&&typeof t.setGState=="function"&&typeof t.GState=="function";n&&(t.saveGraphicsState(),t.setGState(new t.GState(
|
|
125
|
+
{opacity:e.opacity})));const h=e.diagonal?Math.atan2(i,a):0,s=Math.cos(h),g=Math.sin(h),P=a/2,c=i/2,f=o/2,d=-.35*r,T=P-(f*s+d*g),m=c-(-f*g+d*s);t.text(e.text,T,m,{...h!==0?{angle:h*180/Math.PI}:{}}),n&&
|
|
126
|
+
t.restoreGraphicsState()}static installWatermarkUnderpaint(t,e){const a=()=>{const r=t.internal?.pageSize,o=typeof r?.getWidth=="function"?r.getWidth():r?.width,l=typeof r?.getHeight=="function"?r.getHeight():
|
|
127
|
+
r?.height;!o||!l||this.drawWatermarkOnPage(t,e,o,l)},i=t.addPage.bind(t);t.addPage=(...r)=>{const o=i(...r);return a(),o},a()}static renderBodyLineNumbers(t,e,a,i,r){const o=s=>{let g,P=0;for(const[c,
|
|
128
|
+
f]of a)c<=s&&c>P&&(g=f,P=c);return g??this.resolvePdfLayoutMetrics(i)},l=this.getPdfPageCount(t),n=l;let h=!1;for(let s=1;s<=l;s++){const g=o(s),P=g.pleadingGrid;P&&(t.setPage(s),h=!0,this.renderPleadingGrid(
|
|
129
|
+
t,P,g,r?.get(s)??P.fontFamily));const c=g.lineNumbering;if(!c||e.length===0)continue;let f=c.start;if(c.restart==="continuous")for(const T of e)T.pageNumber<s&&f++;t.setPage(s),h=!0,t.setFont(this.mapFontFamily(
|
|
130
|
+
r?.get(s)),"normal"),t.setFontSize(10*this.PX_TO_PT),t.setTextColor(115,115,115);const d=g.marginLeftPt-(c.distancePx??12)*this.PX_TO_PT;for(const T of e){if(T.pageNumber!==s)continue;const m=f++;if(m%
|
|
131
|
+
c.countBy!==0)continue;const x=T.baselineOffset??Math.min(T.height,12);t.text(String(m),d,T.y+x,{align:"right",baseline:"alphabetic"})}}h&&t.setPage(n)}static renderPleadingGrid(t,e,a,i){t.setFont(this.
|
|
132
|
+
mapFontFamily(i??"Times New Roman"),"normal");const r=(e.fontSizePx??16)*this.PX_TO_PT;t.setFontSize(r),t.setTextColor(0,0,0);const o=e.firstBaselinePx!==void 0?e.firstBaselinePx*this.PX_TO_PT:a.marginTopPt+
|
|
133
|
+
r,l=(a.pageMarginLeftPt??a.marginLeftPt)-(e.distancePx??14)*this.PX_TO_PT;for(let n=0;n<e.rows;n++)t.text(String(n+1),l,o+n*e.pitchPx*this.PX_TO_PT,{align:"right",baseline:"alphabetic"})}static lineBaselineOffsetPt(t,e){
|
|
134
|
+
let a=0;for(const i of t){if(i.latexImage||i.marks?.latex)continue;const r=i.marks?.fontSize?i.marks.fontSize*this.PX_TO_PT:e;r>a&&(a=r)}return a||e}static renderPageNumbers(t,e,a,i,r,o){const l=this.
|
|
135
|
+
getPdfPageCount(t),n=12,h=n/2+6;t.setFont(this.mapFontFamily(a),"normal"),t.setFontSize(n),t.setTextColor(0,0,0);for(let s=0;s<l;s++){const g=i?.(s+1)??e;if(!g.showPageNumbers)continue;const P=s+1,c=g.
|
|
136
|
+
pageNumberPosition.startsWith("top");if(o?.(P,c?"header":"footer"))continue;const f=g.pageNumberPosition.endsWith("right"),d=f?g.pageWidthPt-g.marginRightPt:g.marginLeftPt,T=c?Math.max(h,g.marginTopPt/
|
|
137
|
+
2):g.pageHeightPt-Math.max(h,g.marginBottomPt/2);t.setPage(P),t.text(r?.(P)??ce({pageNumberStart:e.pageNumberStart,pageNumberFormat:e.pageNumberFormat??"decimal"},s),d,T,{align:f?"right":"left"})}}static getParagraphLineIndentPt(t,e,a){
|
|
138
|
+
return he(t,e,a)*this.PX_TO_PT}static createLayoutForWrapping(t,e,a=this.getDefaultPdfLayoutMetrics()){const i=t/this.PX_TO_PT;return{pageWidth:a.pageWidthPt/this.PX_TO_PT,pageHeight:a.pageHeightPt/this.
|
|
139
|
+
PX_TO_PT,pageMargin:a.marginLeftPt/this.PX_TO_PT,pageMarginTop:a.marginTopPt/this.PX_TO_PT,pageMarginRight:a.marginRightPt/this.PX_TO_PT,pageMarginBottom:a.marginBottomPt/this.PX_TO_PT,pageMarginLeft:a.
|
|
140
|
+
marginLeftPt/this.PX_TO_PT,pageSpacing:0,paragraphSpacing:0,availableWidth:i,textStartY:a.marginTopPt/this.PX_TO_PT,fontSize:16,fontFamily:this.DEFAULT_BODY_FONT,lineHeight:16*1.4,indentStepPx:e,pageless:!1,
|
|
141
|
+
hyphenationEnabled:a.hyphenationEnabled}}static buildNumberedNoteEntries(t){const e=new Map,a=s=>{if(!s||typeof s!="object")return;if(Array.isArray(s)){s.forEach(a);return}const g=s;g.type!=="footnote"&&
|
|
142
|
+
(g.marks?.footnoteRef&&!e.has(g.marks.footnoteRef)&&e.set(g.marks.footnoteRef,g.text??""),a(g.children))};a(t.children.filter(s=>s.type!=="footnote"));const i=[...t.notes??[],...t.children.filter(s=>s.
|
|
143
|
+
type==="footnote")],r={footnote:0,endnote:0},o=new Map,l=new Map;for(const s of i)l.set(s.id,s.noteKind==="endnote"?"endnote":"footnote");for(const[s]of e){const g=l.get(s)??"footnote";r[g]+=1,o.set(s,
|
|
144
|
+
Kt(r[g],g))}const n=i.map(s=>{const g=l.get(s.id)??"footnote",P=o.get(s.id)||Kt(r[g]+=1,g);return{footnoteId:s.id,number:P,kind:g,blocks:s.children}}),h=s=>{const g=[...o.keys()],P=g.indexOf(s.footnoteId);
|
|
145
|
+
return P===-1?g.length:P};return n.sort((s,g)=>h(s)-h(g))}static async renderNoteEntry(t,e,a,i,r,o,l,n,h){n&&this.drawNoteNumeral(t,e.number,i.marginLeftPt,a,r);const s=tt.verticalPaddingPx*st.PX_TO_PT,
|
|
146
|
+
g=tt.gutterPx*st.PX_TO_PT,P=a+s,c={...i,marginTopPt:i.marginTopPt+s,marginLeftPt:i.marginLeftPt+g,contentWidthPt:Math.max(1,i.contentWidthPt-g),blockSpacingPt:tt.blockSpacingPx*st.PX_TO_PT};if(h){const f=c.
|
|
147
|
+
marginTopPt;Object.defineProperty(c,"marginTopPt",{get:()=>h.get(this.getPdfCurrentPage(t))??f})}return(await this.renderBodyBlocks(t,e.blocks,c,o,l,r,void 0,void 0,void 0,P)).finalY+s}static drawNoteNumeral(t,e,a,i,r){
|
|
148
|
+
t.setFont(this.mapFontFamily(r),"normal"),t.setFontSize(jt*this.PX_TO_PT),t.setTextColor(0,0,0),t.text(e,a+1.5,i+(6+jt)*st.PX_TO_PT)}static mapFootnoteRefBlocks(t){const e=new Map,a=(i,r)=>{if(!i||typeof i!=
|
|
149
|
+
"object")return;if(Array.isArray(i)){i.forEach(l=>a(l,r));return}const o=i;o.marks?.footnoteRef&&!e.has(o.marks.footnoteRef)&&e.set(o.marks.footnoteRef,r),a(o.children,r)};for(const i of t)a(i,i.id??"");
|
|
150
|
+
return e}static async renderBodyBlocks(t,e,a,i,r,o,l,n,h,s,g){const P=new Map,c=new Map([[1,0]]),f=[],d=[],T=_e(e);let m=s??a.marginTopPt,x=a.contentWidthPt,F=a.indentStepPx,y=!0;const E=new Map([[1,this.
|
|
151
|
+
physicalPageMetrics(a)]]),R=()=>t.getCurrentPageInfo?.()?.pageNumber??t.getNumberOfPages();let B=0;const k=I=>{if(B=I,!g)return;const p=a.columnFlow;!p||a.columnCount<=1||(p.index=0,p.topPt=m,p.pageOffset=
|
|
152
|
+
0,p.balance=g.balanceBySection.get(I),a.marginLeftPt=a.pageMarginLeftPt)};k(0);for(let I=0;I<e.length;I++){this.syncPdfColumnOffset(a);const p=e[I],u=this.getPdfFlowBottom(t,a);if(p.type==="page-break"){
|
|
153
|
+
!y&&a.blockSpacingPt>0&&(m+=a.blockSpacingPt),p.id&&P.set(p.id,R()),t.addPage([a.pageWidthPt,a.pageHeightPt],a.orientation),a.columnFlow&&(a.columnFlow.index=0,a.columnFlow.topPt=a.marginTopPt,a.columnFlow.
|
|
154
|
+
pageOffset+=1,a.marginLeftPt=a.pageMarginLeftPt),m=a.marginTopPt,y=!0;continue}if(p.type==="docx-raw"){const M=St.heightPx*.75,N=a.pageWidthPt-a.marginLeftPt-a.marginRightPt,G=Ne(p,N/.75)*.75;!y&&a.blockSpacingPt>
|
|
155
|
+
0&&(m+=a.blockSpacingPt),m+M>u&&(m=this.advancePdfFlowRegion(t,a).y),p.id&&P.set(p.id,R());const H=a.marginLeftPt;t.setDrawColor(107,114,128),t.setFillColor(243,244,246),t.setLineWidth(.75),t.roundedRect(
|
|
156
|
+
H,m,G,M,St.cornerRadiusPx*.75,St.cornerRadiusPx*.75,"FD"),t.setFont("courier","normal"),t.setFontSize(St.fontPx*.75),t.setTextColor(107,114,128),t.text(Re(p),H+St.paddingXPx*.75,m+M/2,{baseline:"middl\
|
|
157
|
+
e"}),t.setTextColor(0,0,0),m+=M,y=!1;continue}if(p.type==="section-break"){p.id&&P.set(p.id,R());const M=l?.get(p.id),N=M?n?.(M)??M:void 0;if(N){const H=ve(p.breakType==="continuous",{width:a.pageWidthPt,
|
|
158
|
+
height:a.pageHeightPt},{width:N.pageWidthPt,height:N.pageHeightPt});a=N,x=N.contentWidthPt,F=N.indentStepPx,H?(m=Ie(m,a.blockSpacingPt,0,a.marginTopPt),m>this.getPdfWritableBottomPt(t,a)&&(t.addPage([
|
|
159
|
+
a.pageWidthPt,a.pageHeightPt],a.orientation),m=a.marginTopPt)):(t.addPage([N.pageWidthPt,N.pageHeightPt],N.orientation),m=a.marginTopPt),E.set(R(),this.physicalPageMetrics(N))}else t.addPage(),m=a.marginTopPt;
|
|
160
|
+
const G=h?.get(p.id);G!==void 0&&c.set(R(),G),k(B+1),y=!0;continue}if(p.type==="toc"){const M=a.blockSpacingPt;!y&&M>0&&(m+=M),y=!1,p.id&&P.set(p.id,R());const N=ge({children:e.map(b=>b.type==="paragr\
|
|
161
|
+
aph"?this.paragraphForPdfOutput(b):b)},de(p)),G=(p.fontSize??16)*this.PX_TO_PT,H=G*1.4,j=Yt.paddingYPx*this.PX_TO_PT;t.setFont(this.mapFontFamily(p.fontFamily??o),"normal"),t.setFontSize(G);const _=this.
|
|
162
|
+
hexToRgb(p.color??"#000000");t.setTextColor(_.r,_.g,_.b),m+=j,N.length===0&&(m+H>u&&(m=this.advancePdfFlowRegion(t,a).y),m+=H);for(const b of N)m+H>u&&(m=this.advancePdfFlowRegion(t,a).y),d.push({pdfPage:R(),
|
|
163
|
+
headingBlockId:b.blockId,block:p,entry:b,baseline:m+G,left:a.marginLeftPt,width:a.contentWidthPt,fontName:this.mapFontFamily(p.fontFamily??o),fontSizePt:G}),m+=H;m+=j;continue}const S=I>0?e[I-1]:void 0,
|
|
164
|
+
w=st.pdfSpaceBeforePt(p,a,S)+st.pdfSpaceAfterPt(S,p);if(!y&&w>0?m+=w:y&&I===0&&a.keepFirstBlockDeclaredSpaceBefore&&(m+=(st.declaredSpacingPx(p,"spaceBefore")??0)*st.PX_TO_PT),y=!1,p.id&&p.type!=="par\
|
|
165
|
+
agraph"&&P.set(p.id,R()),p.type==="container"){const M=await this.renderContainerBlock(t,p,m,x,o,i,r,a);m=M.nextY;for(const[N,G]of M.blockStartPages)P.set(N,G);f.push(...M.lineMarks);continue}if(p.type===
|
|
166
|
+
"placeholder"){m=this.advancePlaceholderBlock(t,p,m,a);continue}if(p.type==="image"){const M=await this.renderImageBlock(t,p,m,x,a);M&&(m=M.nextY);continue}if(p.type==="math"){const M=p;m=(await this.
|
|
167
|
+
renderMathBlock(t,M,m,x,u,a)).nextY;continue}if(p.type==="list"){m=await this.renderListBlock(t,p,m,x,o,a,T.get(p.id),f);continue}if(p.type==="table"){m=await this.renderTableBlock(t,p,m,x,o,i,r,a);continue}
|
|
168
|
+
if(p.type==="code"){m=await this.renderCodeBlock(t,p,m,x,u,a.marginLeftPt,i,r,a,f);continue}if(p.type!=="paragraph")continue;const C=p,{required:D,firstLineAdvance:V}=this.getRequiredParagraphStartHeight(
|
|
169
|
+
e,I,x,F,a);D>0&&m+D>u&&a.marginTopPt+D<=u&&m!==a.marginTopPt&&(m=this.advancePdfFlowRegion(t,a).y),m+V>u&&m!==a.marginTopPt&&(m=this.advancePdfFlowRegion(t,a).y),C.id&&P.set(C.id,R()),m=await this.renderParagraph(
|
|
170
|
+
t,C,m,x,o,u,F,a,f)}if(d.length>0){const I=R(),p=this.createPdfPageNumbering(E.get(1)??a,E,c).labelForPage;for(const u of d){t.setPage(u.pdfPage),t.setFont(u.fontName,"normal"),t.setFontSize(u.fontSizePt);
|
|
171
|
+
const S=this.hexToRgb(u.block.color??"#000000");t.setTextColor(S.r,S.g,S.b);const w=P.get(u.headingBlockId),C=w!==void 0?p(w):"",D=fe(u.block,u.entry,u.left,u.width,C,V=>t.getTextWidth(V),this.PX_TO_PT);
|
|
172
|
+
D.text&&t.text(D.text,D.textX,u.baseline,{align:D.align,...D.rtl?{isInputVisual:!1,isOutputVisual:!0,isInputRtl:!0,isOutputRtl:!1}:{}}),C&&D.leaderEnd-D.leaderStart>Yt.minimumLeaderWidthPx*this.PX_TO_PT&&
|
|
173
|
+
(t.setDrawColor(150),typeof t.setLineDashPattern=="function"&&t.setLineDashPattern([.8,2.2],0),t.line(D.leaderStart,u.baseline,D.leaderEnd,u.baseline),typeof t.setLineDashPattern=="function"&&t.setLineDashPattern(
|
|
174
|
+
[],0),t.setDrawColor(0,0,0)),C&&t.text(C,D.numberX,u.baseline)}t.setPage(I)}return{blockStartPages:P,pageMetrics:E,pageSections:c,lineMarks:f,finalY:m}}static async renderContainerBlock(t,e,a,i,r,o,l,n){
|
|
175
|
+
const h=Math.max(0,e.padding??vt.paddingPx)*this.PX_TO_PT,s=this.getPdfFlowBottom(t,n);a+h>s&&a!==n.marginTopPt&&(a=this.advancePdfFlowRegion(t,n).y);const g=()=>t.getCurrentPageInfo?.()?.pageNumber??
|
|
176
|
+
t.getNumberOfPages(),P=g(),c=n.columnFlow?.index??0,f=n.columnFlow?.topPt??n.marginTopPt,d={...n,keepFirstBlockDeclaredSpaceBefore:void 0,marginTopPt:n.marginTopPt+h,marginRightPt:n.marginRightPt+h,marginBottomPt:n.
|
|
177
|
+
marginBottomPt+h,marginLeftPt:n.marginLeftPt+h,contentWidthPt:Math.max(1,i-h*2),pageMarginLeftPt:n.pageMarginLeftPt+h},T=await this.renderBodyBlocks(t,e.children,d,o,l,r,void 0,void 0,void 0,a+h);let m=T.
|
|
178
|
+
finalY+h;this.syncPdfColumnOffset(n),m>s&&T.finalY!==d.marginTopPt&&(m=this.advancePdfFlowRegion(t,n).y+h);const x=g(),F=n.columnFlow?.index??0,y=x,E=this.hexToRgb(e.borderColor??vt.borderColor);t.setDrawColor(
|
|
179
|
+
E.r,E.g,E.b),t.setLineWidth(vt.borderWidthPx*this.PX_TO_PT);let R=P,B=c;for(;R<x||R===x&&B<=F;){t.setPage(R);const k=R===P&&B===c,I=R===x&&B===F,p=k?a:R===P?f:n.marginTopPt,u=I?m:s;u>p&&t.rect(n.pageMarginLeftPt+
|
|
180
|
+
B*n.columnStridePt,p,i,u-p,"S"),B+=1,B>=n.columnCount&&(B=0,R+=1)}return t.setPage(y),{nextY:m,blockStartPages:T.blockStartPages,lineMarks:T.lineMarks}}static advancePlaceholderBlock(t,e,a,i){const r=Math.
|
|
181
|
+
max(0,e.height||100)*this.PX_TO_PT,o=this.getPdfFlowBottom(t,i);return a+r>o&&a!==i.marginTopPt&&(a=this.advancePdfFlowRegion(t,i).y),a+r}static async toBlob(t,e,a){class i extends this{}return i.bundledGenreFamilies=
|
|
182
|
+
new Map,i.scriptFallbackFamilies=new Map,i.shapingFonts=new Map,i.embeddedFamilyNames=new Map,i.inlineCodeFontFamily="courier",i.renderDocument(t,e,a)}static async renderDocument(t,e,a){t=this.splitDocumentFallbackRuns(
|
|
183
|
+
t,await this.loadFallbackCoverage(t));const i=a||{...Xt,background:wt.codeBackground,text:wt.codeText};await this.ensureAllLatexRendered(t);const r=this.resolvePdfLayoutMetrics(t),o=t.children.filter(
|
|
184
|
+
S=>S.type==="section-break"),l=new Map,n=new Map,h=t.pageLayout?.pageNumberRestart===!0?{...r,pageNumberStartExplicit:!0}:r;o.forEach((S,w)=>{const C=o[w+1];l.set(S.id,C?.layout?this.resolvePdfMetricsFromSettings(
|
|
185
|
+
C.layout,t.pageLayout,!0):C?r:h),n.set(S.id,w+1)});const s=o[0]?.layout?this.resolvePdfMetricsFromSettings(o[0].layout,t.pageLayout,!1):r,g=await import("./jspdf.es.min-DU74zN8b.js").then(S=>S.j),P=g.
|
|
186
|
+
jsPDF??g.default,c=new P({orientation:s.orientation,unit:"pt",format:[s.pageWidthPt,s.pageHeightPt]}),f=this.DEFAULT_BODY_FONT,{hasSourceCodePro:d}=await this.registerDocumentFonts(c,t,f);e&&c.setProperties(
|
|
187
|
+
{title:e});const T=Xe(t.watermark);T&&this.installWatermarkUnderpaint(c,T);const m=[...t.children.filter(S=>S.type==="footnote"),...t.notes??[]],x=t.children.filter(S=>S.type!=="footnote"&&S.type!=="h\
|
|
188
|
+
eader-footer"),F={balanceBySection:this.computeColumnBalanceTargets(t,x)},y=m.length>0?this.buildNumberedNoteEntries(t):[],E=y.filter(S=>S.kind==="footnote"),R=y.filter(S=>S.kind==="endnote");let B=new Map(
|
|
189
|
+
[[1,s]]),k=new Map([[1,0]]),I=s.marginTopPt,p=[],u=new Map;if(E.length===0){const S=await this.renderBodyBlocks(c,x,s,i,d,f,l,void 0,n,void 0,F);B=S.pageMetrics,k=S.pageSections,p=S.lineMarks,I=S.finalY}else{
|
|
190
|
+
const S=E,w=tt.separatorSpacePx*this.PX_TO_PT,C=this.mapFootnoteRefBlocks(x),D=new P({orientation:s.orientation,unit:"pt",format:[s.pageWidthPt,s.pageHeightPt]});await this.registerDocumentFonts(D,t,f);
|
|
191
|
+
const V=await this.renderBodyBlocks(D,x,s,i,d,f,l,void 0,void 0,void 0,F),M=L=>{let A=s,U=0;for(const[z,Y]of V.pageMetrics)z<=L&&z>U&&(A=Y,U=z);return A},N=new Map,G=D.getNumberOfPages();for(const L of S){
|
|
192
|
+
const A=C.get(L.footnoteId),U=(A?V.blockStartPages.get(A):void 0)??G,z=N.get(U)??[];z.push(L),N.set(U,z)}const H=new P({orientation:r.orientation,unit:"pt",format:[r.pageWidthPt,1e4]});await this.registerDocumentFonts(
|
|
193
|
+
H,t,f);const j=new Map;for(const[L,A]of N){const U=M(L);for(const z of A){const Y={...U,pageHeightPt:1e4,marginTopPt:0,marginBottomPt:0},q=await this.renderNoteEntry(H,z,0,Y,f,i,d,!1);j.set(z.footnoteId,
|
|
194
|
+
Math.max(0,q))}}const _=new Map;for(const[L,A]of N){const U=M(L),z=w+A.reduce((Q,rt)=>Q+(j.get(rt.footnoteId)??0),0),Y=U.pageHeightPt-U.marginTopPt-U.marginBottomPt,q=V.lineMarks.filter(Q=>Q.pageNumber===
|
|
195
|
+
L).sort((Q,rt)=>Q.y-rt.y).slice(0,tt.minimumBodyLinesBeforeFootnotes),Z=this.getParagraphLineHeight({type:"paragraph",id:"__pdf_measure__",children:[]}),ot=(q.length>0?Math.max(0,Math.max(...q.map(Q=>Q.
|
|
196
|
+
y+Q.height))-U.marginTopPt):Z*tt.minimumBodyLinesBeforeFootnotes)+tt.bodyKeepSlackPx*this.PX_TO_PT;_.set(L,Math.min(z,Math.max(0,Y-ot)))}u=_;const b=L=>({...L,reservedInsetForPage:_}),X=b(s),O=await this.
|
|
197
|
+
renderBodyBlocks(c,x,X,i,d,f,l,b,n,void 0,F);B=O.pageMetrics,k=O.pageSections,p=O.lineMarks,I=O.finalY;const K=new Map;for(const L of O.lineMarks)K.set(L.pageNumber,Math.max(K.get(L.pageNumber)??0,L.y+
|
|
198
|
+
L.height+tt.separatorSpacePx*this.PX_TO_PT+tt.verticalPaddingPx*this.PX_TO_PT));const W=c.getNumberOfPages();for(const[L,A]of[...N.entries()].sort((U,z)=>U[0]-z[0])){const U=Math.min(L,W);c.setPage(U);
|
|
199
|
+
const z=M(L),Y=_.get(L)??0,q=z.pageHeightPt-z.marginBottomPt-Y+w;c.setDrawColor(120),c.setLineWidth(.75),c.line(z.marginLeftPt,q-7,z.marginLeftPt+Math.max(tt.separatorWidthMinPx*this.PX_TO_PT,z.contentWidthPt*
|
|
200
|
+
tt.separatorWidthFraction),q-7);let Z=q;for(let ot=0;ot<A.length;ot++){ot>0&&(Z+=tt.blockSpacingPx*this.PX_TO_PT);const Q=this.getPdfCurrentPage(c),rt=c.addPage.bind(c),lt=[];c.addPage=(...ct)=>{const et=this.
|
|
201
|
+
getPdfCurrentPage(c)+1;return et<=W?c.setPage(et):rt(...ct),lt.push(this.getPdfCurrentPage(c)),c};try{Z=await this.renderNoteEntry(c,A[ot],Z,z,f,i,d,!0,K)}finally{c.addPage=rt}for(const ct of lt){c.setPage(
|
|
202
|
+
ct),c.setDrawColor(120),c.setLineWidth(.75);const et=(K.get(ct)??z.marginTopPt)-tt.verticalPaddingPx*this.PX_TO_PT*2;c.line(z.marginLeftPt,et,z.marginLeftPt+z.contentWidthPt,et)}c.setPage(lt[lt.length-
|
|
203
|
+
1]??Q)}}c.setPage(this.getPdfPageCount(c))}if(R.length>0){const S=new P({orientation:r.orientation,unit:"pt",format:[r.pageWidthPt,1e4]});await this.registerDocumentFonts(S,t,f);let w=tt.separatorToContentPx*
|
|
204
|
+
this.PX_TO_PT;for(let H=0;H<R.length;H++){H>0&&(w+=tt.blockSpacingPx*this.PX_TO_PT);const j={...r,pageHeightPt:1e4,marginTopPt:0,marginBottomPt:0};w+=await this.renderNoteEntry(S,R[H],0,j,f,i,d,!1)}const C=this.
|
|
205
|
+
getPdfPageCount(c);let D=s,V=0;for(const[H,j]of B)H<=C&&H>=V&&(D=j,V=H);const M=I+tt.inlineEndnoteGapPx*this.PX_TO_PT,N=M+w<=D.pageHeightPt-D.marginBottomPt-(u.get(C)??0);let G;N?(c.setPage(C),G=M):(c.
|
|
206
|
+
addPage(),G=D.marginTopPt+tt.newPageSeparatorOffsetPx*this.PX_TO_PT),c.setDrawColor(120),c.setLineWidth(.75),c.line(D.marginLeftPt,G,D.marginLeftPt+Math.max(tt.separatorWidthMinPx*this.PX_TO_PT,D.contentWidthPt*
|
|
207
|
+
tt.separatorWidthFraction),G),G+=tt.separatorToContentPx*this.PX_TO_PT;for(let H=0;H<R.length;H++)H>0&&(G+=tt.blockSpacingPx*this.PX_TO_PT),G=await this.renderNoteEntry(c,R[H],G,D,f,i,d,!0)}return await this.
|
|
208
|
+
renderHeaderFooterChrome(c,t,r,f,B,k),this.renderBodyLineNumbers(c,p,B,t,[...B.values()].some(S=>S.lineNumbering||S.pleadingGrid)?ta(this.computeEngineLayout(t),this.DEFAULT_BODY_FONT):void 0),c.output(
|
|
209
|
+
"blob")}static measureLineAdvancePt(t,e,a,i){let r=0,o=0;for(const h of t)h.latexImage?o=Math.max(o,h.latexImage.contentHeight*this.PX_TO_PT):r=Math.max(r,h.marks?.fontSize?h.marks.fontSize*this.PX_TO_PT:
|
|
210
|
+
e);r===0&&(r=e);const l=i??(a?this.LINE_HEIGHT_MULTIPLIERS.heading:this.LINE_HEIGHT_MULTIPLIERS.paragraph),n=r*l;return o>n*1.25?o:n}static parseParagraphDecoration(t){const e=t.shading&&t.shading!=="\
|
|
211
|
+
transparent"?t.shading:void 0;if(!e&&!t.borders)return null;let a;if(t.borders)try{a=JSON.parse(t.borders)}catch{a=void 0}return!e&&!a?null:{...e?{shading:e}:{},...a?{edges:a}:{}}}static drawParagraphDecorationSlice(t,e,a,i,r,o,l,n){
|
|
212
|
+
if(e.shading){const d=this.hexToRgb(e.shading);t.setFillColor(d.r,d.g,d.b),t.rect(a,i,r,o+(n?0:.5),"F")}const h=e.edges;if(!h)return;const s=(d,T,m,x,F)=>{const y=h[d];if(!y||y.style==="none")return;const E=Math.
|
|
213
|
+
max(.4,(y.width??1)*this.PX_TO_PT),R=m===F,B=this.hexToRgb(y.color??"#000000");if(t.setDrawColor(B.r,B.g,B.b),t.setLineWidth(E),R&&je(y.style)){const p=Ye(T,x,this.PX_TO_PT);for(const u of p.lines)t.line(
|
|
214
|
+
u.from,m,u.to,m);t.setFillColor(B.r,B.g,B.b);for(const u of p.ornaments)if(y.style==="stars")for(const S of $e(u.cx,m,u.radius))t.line(S.x1,S.y1,S.x2,S.y2);else{const S=Ve(u.cx,m,u.radius);t.lines([[S[1].
|
|
215
|
+
x-S[0].x,S[1].y-S[0].y],[S[2].x-S[1].x,S[2].y-S[1].y],[S[3].x-S[2].x,S[3].y-S[2].y]],S[0].x,S[0].y,[1,1],"F",!0)}return}const k=typeof t.setLineDashPattern=="function";k&&(y.style==="dashed"?t.setLineDashPattern(
|
|
216
|
+
[4.5,2.25],0):y.style==="dotted"?t.setLineDashPattern([1.5,1.5],0):t.setLineDashPattern([],0));const I=p=>{t.line(T+(R?0:p),m+(R?p:0),x+(R?0:p),F+(R?p:0))};y.style==="double"?(I(-E),I(E)):I(0),k&&t.setLineDashPattern(
|
|
217
|
+
[],0)},g=n?0:.5,P=d=>Math.max(0,h[d]?.space??0)*this.PX_TO_PT,c=a-P("left"),f=a+r+P("right");if(s("left",c,i,c,i+o+g),s("right",f,i,f,i+o+g),l){const d=i-P("top");s("top",a,d,a+r,d)}if(n){const d=i+o+
|
|
218
|
+
P("bottom");s("bottom",a,d,a+r,d)}}static measureParagraphLineAdvances(t,e,a,i){const r=this.createCanvasTextContext();if(!r)return[this.getParagraphLineHeight(t)];const o=this.createLayoutForWrapping(
|
|
219
|
+
e,a,i),l=qt(this.paragraphForPdfOutput(t),r,o);if(l.length===0)return[this.getEmptyParagraphLineHeight(t)];const n=this.getParagraphFontSize(t),h=this.getLineSpacingMultiplier(t);return l.map(s=>this.
|
|
220
|
+
measureLineAdvancePt(s.segments.map(g=>({marks:g.marks})),n,!!t.heading,h))}static paragraphForPdfOutput(t){const e=t.children.filter(a=>a.type!=="text"||!a.marks?.hidden||!!a.marks.footnoteRef);return e.
|
|
221
|
+
length===t.children.length?t:{...t,children:e}}static getParagraphDirection(t){let e="";for(const a of t.children)e+=a.text??"";return ea(t.direction,e)}static getEffectiveParagraphAlignment(t,e){return t.
|
|
222
|
+
align||(e==="rtl"?"right":"left")}static getRequiredParagraphStartHeight(t,e,a,i,r){const o=t[e];if(!o||o.type!=="paragraph")return{required:0,firstLineAdvance:0};const l=Et(o),n=this.measureParagraphLineAdvances(
|
|
223
|
+
o,a,i,r),h=this.paragraphForPdfOutput(o).children.every(c=>c.type==="text"&&c.text==="")||n.length===0?this.getEmptyParagraphLineHeight(o):n[0],s=c=>c.reduce((f,d)=>f+Math.max(0,d),0);let g=0;if(l.keepLines?
|
|
224
|
+
g=s(n):l.widowControl&&n.length>=2&&(g=n[0]+n[1]),!l.keepNext)return{required:g,firstLineAdvance:h};let P=0;for(let c=0;c<ee;c++){const f=t[e+c+1];if(!f||f.type!=="paragraph")break;const d=this.measureParagraphLineAdvances(
|
|
225
|
+
f,a,i,r);if(d.length===0)break;const T=t[e+c];P+=st.pdfSpaceBeforePt(f,r,T)+st.pdfSpaceAfterPt(T,f);const m=Et(f);if(m.keepNext&&c<ee-1){P+=s(d);continue}P+=d[0],m.widowControl&&d.length>=2&&(P+=d[1]);
|
|
226
|
+
break}return{required:Math.max(g,s(n)+P),firstLineAdvance:h}}static async renderParagraph(t,e,a,i,r,o,l=this.resolveIndentStepPx(),n=this.getDefaultPdfLayoutMetrics(),h){let s=a;const g=this.paragraphForPdfOutput(
|
|
227
|
+
e),P=this.getParagraphFontSize(e),c=this.getParagraphLineHeight(e),f=this.getLineSpacingMultiplier(e);let d=Number.isFinite(o)&&o>0?o:this.getPdfFlowBottom(t,n),T=n.marginLeftPt;const m=()=>{const k=this.
|
|
228
|
+
advancePdfFlowRegion(t,n);s=k.y,T=k.x,d=this.getPdfFlowBottom(t,n)},x=(k=c)=>{if(s+k>d){if(s===n.marginTopPt)return;m()}},F=()=>t.getCurrentPageInfo?.()?.pageNumber??t.getNumberOfPages(),y=this.getParagraphDirection(
|
|
229
|
+
g),E=this.getEffectiveParagraphAlignment(e,y),R=this.parseParagraphDecoration(e);if(g.children.length===0||g.children.length===1&&g.children[0].type==="text"&&g.children[0].text===""){const k=this.getEmptyParagraphLineHeight(
|
|
230
|
+
e);return R&&(x(k),this.drawParagraphDecorationSlice(t,R,T,s,i,k,!0,!0)),s+k}const B=this.createCanvasTextContext();if(B){const k=this.createLayoutForWrapping(i,l,n),I=qt(g,B,k),p=await this.prepareLatexImages(
|
|
231
|
+
g,P),u=I.map(w=>w.segments.map(C=>C.marks?.latex?{text:C.text,marks:C.marks,latexImage:p.get(C.text)}:{text:C.text,marks:C.marks,font:C.marks?.fontFamily})),S=Et(e);for(let w=0;w<I.length;w++){const C=I[w],
|
|
232
|
+
D=u[w];if(D.length>0){const V=this.getParagraphLineIndentPt(e,w,l),M=Math.max(1,i-V),N=this.measureLineAdvancePt(D,P,!!e.heading,f),G=u[w+1];if(S.widowControl&&I.length>=3&&w===I.length-2&&G&&s+N<=d){
|
|
233
|
+
const j=this.measureLineAdvancePt(G,P,!!e.heading,f);s+N+j>d&&s!==n.marginTopPt&&m()}x(N);const H=y==="rtl"?T:T+V;R&&this.drawParagraphDecorationSlice(t,R,T,s,i,N,w===0,w===I.length-1),h?.push({pageNumber:F(),
|
|
234
|
+
y:s,height:N,baselineOffset:this.lineBaselineOffsetPt(D,P)}),s=this.renderLine(t,D,s,H,M,E,P,r,!!e.heading,f,w===I.length-1,{direction:y,...C.tabLayout?{tabLayoutPx:C.tabLayout.segments,...C.tabLayout.
|
|
235
|
+
rtl?{tabRtl:!0,tabWidthPx:C.tabLayout.width}:{}}:{},...C.hyphenTrailing?{hyphenTrailing:!0}:{}})}}return s}return this.renderParagraphWithJsPDFWrapping(t,g,a,i,r,o,l,n)}static async prepareLatexImages(t,e){
|
|
236
|
+
const a=new Map;for(const i of t.children)if(i.type==="text"&&i.marks?.latex){const r=await this.renderLatexToImage(i.text,!1,e);r&&a.set(i.text,r)}return a}static async renderParagraphWithJsPDFWrapping(t,e,a,i,r,o,l=this.
|
|
237
|
+
resolveIndentStepPx(),n=this.getDefaultPdfLayoutMetrics()){let h=a;const s=this.getParagraphFontSize(e),g=this.getParagraphLineHeight(e),P=this.getLineSpacingMultiplier(e);let c=Number.isFinite(o)&&o>
|
|
238
|
+
0?o:this.getPdfFlowBottom(t,n),f=n.marginLeftPt;const d=()=>{if(h+g>c){if(h===n.marginTopPt)return;const k=this.advancePdfFlowRegion(t,n);h=k.y,f=k.x,c=this.getPdfFlowBottom(t,n)}},T=this.getParagraphDirection(
|
|
239
|
+
e),m=this.getEffectiveParagraphAlignment(e,T),x=await this.processTextNodesWithLatex(e.children,s);if(x.length===0)return h+this.getEmptyParagraphLineHeight(e);let F=[],y=0,E=0;const R=()=>Math.max(1,
|
|
240
|
+
i-this.getParagraphLineIndentPt(e,E,l)),B=(k=!1)=>{if(F.length===0)return;d();const I=this.getParagraphLineIndentPt(e,E,l);h=this.renderLine(t,F,h,T==="rtl"?f:f+I,Math.max(1,i-I),m,s,r,!!e.heading,P,k,
|
|
241
|
+
{direction:T}),F=[],y=0,E+=1};if(x.length===1&&x[0].text==="")return a+this.getEmptyParagraphLineHeight(e);for(const k of x){if(k.latexImage){const p=k.latexImage.contentWidth*this.PX_TO_PT;y+p>R()&&F.
|
|
242
|
+
length>0&&B(),F.push({text:k.text,marks:k.marks,font:k.font||k.marks?.fontFamily,latexImage:k.latexImage}),y+=p;continue}this.setRunFont(t,k,r),t.setFontSize(this.getRunEffectiveFontSizePt(k.marks,s));
|
|
243
|
+
const I=k.text.split(`
|
|
244
|
+
`);for(let p=0;p<I.length;p++){const u=I[p];p>0&&F.length>0&&B();const S=u.split(/(\s+)/);for(const w of S){const C=this.measureRunDisplayWidthPt(t,w,k.marks);y+C>R()&&F.length>0&&B(),(w.trim()||F.length>
|
|
245
|
+
0)&&(F.push({text:w,marks:k.marks,font:k.font||k.marks?.fontFamily}),y+=C)}}}return F.length>0&&B(!0),h}static getLineSpacingMultiplier(t){return ae(t)}static async renderListBlock(t,e,a,i,r,o=this.getDefaultPdfLayoutMetrics(),l,n){
|
|
246
|
+
if(!e.children.length)return a;let h=a;const s=this.getPdfFlowBottom(t,o),g=l??be(e),P={...g.counters};let c;if(e.variant==="ordered"&&e.numberingFormat)try{t.setFont(this.mapFontFamily(r),"normal"),t.
|
|
247
|
+
setFontSize(this.FONT_SIZES.normal);let f=0;for(const T of Fe(e,g))f=Math.max(f,t.getTextWidth(T)/this.PX_TO_PT);const d=this.ORDERED_LIST_INDENT_PT/this.PX_TO_PT;c=Math.min(Math.max(d,Math.ceil(f)+10),
|
|
248
|
+
240)*this.PX_TO_PT}catch{c=void 0}for(let f=0;f<e.children.length;f++){const d=e.children[f],T=this.getListIndentLevel(d);let m;e.variant==="ordered"?m={type:"ordered",label:this.computeOrderedMarkerLabel(
|
|
249
|
+
P,T,g.start,Se(e.numberingFormat))}:e.variant==="todo"?m={type:"todo",checked:!!d.checked}:m={type:"bullet",indentLevel:T},h=await this.renderListItem(t,d,e,m,h,i,s,r,o,n,c)}return h}static async renderListItem(t,e,a,i,r,o,l,n,h=this.
|
|
250
|
+
getDefaultPdfLayoutMetrics(),s,g){let P=r+Math.max(0,e.spaceBefore??0)*this.PX_TO_PT;const c=this.getListIndentLevel(e)*this.SUBLIST_INDENT_PT,f=n,d=this.FONT_SIZES.normal,T=this.mapFontFamily(f);t.setFont(
|
|
251
|
+
T,"normal"),t.setFontSize(d);const m=g??this.getListIndentPt(a.variant);let x=h.marginLeftPt,F=x+c+m,y=l;const E=()=>{const b=this.advancePdfFlowRegion(t,h);P=b.y,x=b.x,F=x+c+m,y=this.getPdfFlowBottom(
|
|
252
|
+
t,h)};let R=o-c-m;(!Number.isFinite(R)||R<=0)&&(R=Math.max(o*.3,o*.1));let B="";for(const b of e.children)B+=b.text??"";const k=aa(B)??"ltr",I=k==="rtl",p=()=>I?x:F,u=()=>I?x+R:F,S=e.lineSpacing??a.lineSpacing??
|
|
253
|
+
this.LINE_HEIGHT_MULTIPLIERS.paragraph,w=d*S,C=await this.processTextNodesWithLatex(e.children,d);let D=C.length>0?C:[{text:""}];a.variant==="todo"&&e.checked&&(D=D.map(b=>b.latexImage?b:{...b,marks:{
|
|
254
|
+
...b.marks,strikethrough:!0,color:wt.todoCheckedText}}));const V=new Set(Object.values(this.SCRIPT_FALLBACK_FONTS).map(b=>b.family)),M=[...C].reverse().find(b=>!b.latexImage&&!b.marks?.latex&&b.text.length>
|
|
255
|
+
0&&!V.has(b.marks?.fontFamily??""))?.marks;let N=[],G=0,H=!1;const j=()=>{H||(P+w>y&&P!==h.marginTopPt&&E(),this.drawListMarker(t,i,u(),P,w,d,f,n,I,M),H=!0)},_=()=>{N.length!==0&&(P+w>y&&P!==h.marginTopPt&&
|
|
256
|
+
E(),j(),s?.push({pageNumber:t.getCurrentPageInfo?.().pageNumber??t.getNumberOfPages(),y:P,height:this.measureLineAdvancePt(N,d,!1,S),baselineOffset:this.lineBaselineOffsetPt(N,d)}),P=this.renderLine(t,
|
|
257
|
+
N,P,p(),R,I?"right":"left",d,f,!1,S,!0,{direction:k}),N=[],G=0)};for(const b of D){if(b.latexImage){const O=b.latexImage.contentWidth*this.PX_TO_PT;G+O>R&&N.length>0&&_(),N.push({text:b.text,marks:b.marks,
|
|
258
|
+
font:b.font,latexImage:b.latexImage}),G+=O;continue}this.setRunFont(t,b,f||n),t.setFontSize(this.getRunEffectiveFontSizePt(b.marks,d));const X=b.text.split(`
|
|
259
|
+
`);for(let O=0;O<X.length;O++){const K=X[O];O>0&&(N.length>0?_():(j(),P+=w));const W=K.split(/(\s+)/);for(const L of W){const A=this.measureRunDisplayWidthPt(t,L,b.marks);G+A>R&&N.length>0&&_(),(L.trim()||
|
|
260
|
+
N.length>0)&&(N.push({text:L,marks:b.marks,font:b.font}),G+=A)}}}return N.length>0&&_(),H||(j(),P+=w),P+Math.max(0,e.spaceAfter??0)*this.PX_TO_PT}static drawListMarker(t,e,a,i,r,o,l,n,h,s){t.setDrawColor(
|
|
261
|
+
0,0,0);const g=(f,d=0)=>h?2*a-f-d:f,P=a-this.BULLET_MARKER_WIDTH_PT,c=i+r/2;switch(e.type){case"bullet":{const f=g(P+this.BULLET_CENTER_OFFSET_PT),d=this.BULLET_RADIUS_PT;if(e.indentLevel<=0)t.circle(
|
|
262
|
+
f,c,d,"F");else if(e.indentLevel===1)t.circle(f,c,d,"S");else{const T=this.BULLET_SQUARE_HALF_PT*2,m=g(P+this.BULLET_SQUARE_INSET_PT,T),x=c-this.BULLET_SQUARE_HALF_PT+this.BULLET_SQUARE_VERTICAL_ADJUST_PT;
|
|
263
|
+
t.rect(m,x,T,T,"S")}break}case"todo":{const f=this.TODO_CHECKBOX_SIZE_PT,d=g(P-this.TODO_CHECKBOX_OFFSET_PT,f),T=c-f/2;t.setLineWidth(.8),typeof t.roundedRect=="function"?t.roundedRect(d,T,f,f,this.TODO_CHECKBOX_RADIUS_PT,
|
|
264
|
+
this.TODO_CHECKBOX_RADIUS_PT,"S"):t.rect(d,T,f,f,"S"),e.checked&&(t.setLineWidth(1.2),t.line(d+f*.15,T+f*.55,d+f*.4,T+f*.75),t.line(d+f*.4,T+f*.75,d+f*.85,T+f*.25));break}case"ordered":{const f=e.label,
|
|
265
|
+
d=s?{fontFamily:s.fontFamily,fontSize:s.fontSize,bold:s.bold,italic:s.italic,code:s.code,superscript:s.superscript,subscript:s.subscript}:void 0;this.setRunFont(t,{text:f,marks:d},l||n);const T=this.getRunEffectiveFontSizePt(
|
|
266
|
+
d,o);t.setFontSize(T);const m=t.getTextWidth(f),x=h?a+this.ORDERED_LABEL_GAP_PT:a-this.ORDERED_LABEL_GAP_PT-m;t.text(f,x,i+T);break}}t.setLineWidth(.5),t.setTextColor(0,0,0)}static async renderTableBlock(t,e,a,i,r,o=Xt,l=!1,n=this.
|
|
267
|
+
getDefaultPdfLayoutMetrics()){if(!e.children||e.children.length===0)return a;const h=this.getPdfFlowBottom(t,n);let s=a;const g=e.borderWidth??It.borderWidthPx,P=e.borderColor??It.borderColor,c=this.hexToRgb(
|
|
268
|
+
P),f=Number.isFinite(e.cellPadding)?Math.max(0,Math.round(e.cellPadding)):It.cellPaddingPx,d=f*this.PX_TO_PT,T=Ae(e.borders),m=Ue(e),x=m.cols,F=Math.min(e.tableWidth?e.tableWidth*this.PX_TO_PT:i,i),y=e.
|
|
269
|
+
align==="center"?(i-F)/2:e.align==="right"?i-F:0;let E=n.marginLeftPt+y;const R=Ke(e.columnWidths??[],x).map(_=>_/100*F),B=[0];for(let _=0;_<x;_++)B.push(B[_]+R[_]);const k=_=>B[Math.min(_.col+_.colSpan,
|
|
270
|
+
x)]-B[_.col],I=new Map;for(const _ of m.cells){const b=We(f,_.cell.padding),X={top:b.top*this.PX_TO_PT,right:b.right*this.PX_TO_PT,bottom:b.bottom*this.PX_TO_PT,left:b.left*this.PX_TO_PT},O=k(_)-X.left-
|
|
271
|
+
X.right,K=this.extractCellBlocks(_.cell);let W=this.FONT_SIZES.normal*this.LINE_HEIGHT_MULTIPLIERS.paragraph;if(K.length>0){const A=await import("./jspdf.es.min-DU74zN8b.js").then(q=>q.j),U=A.jsPDF??A.
|
|
272
|
+
default,z=new U({orientation:"portrait",unit:"pt",format:[Math.max(72,O),this.UNBOUNDED_CELL_FLOW_BOTTOM_PT]});await this.registerCurrentPdfFonts(z,l);const Y={...n,keepFirstBlockDeclaredSpaceBefore:!0,
|
|
273
|
+
pageWidthPt:Math.max(72,O),pageHeightPt:this.UNBOUNDED_CELL_FLOW_BOTTOM_PT,marginTopPt:0,marginRightPt:0,marginBottomPt:0,marginLeftPt:0,contentWidthPt:Math.max(1,O)};W=(await this.renderBodyBlocks(z,
|
|
274
|
+
K,Y,o,l,r,void 0,void 0,void 0,0)).finalY}const L=X.top+W+X.bottom;I.set(_.cell.id,{blocks:K,width:O,flowHeight:W,contentHeight:L,pad:X})}const p=e.children.map((_,b)=>{let X=0;for(const O of _.children){
|
|
275
|
+
const K=m.byId.get(O.id);K&&K.rowSpan>1||(X=Math.max(X,I.get(O.id)?.contentHeight??0))}return X}),u=m.cells.filter(_=>_.rowSpan>1).sort((_,b)=>_.rowSpan-b.rowSpan);for(const _ of u){const b=I.get(_.cell.
|
|
276
|
+
id);if(!b)continue;let X=0;for(let O=_.row;O<_.row+_.rowSpan;O++)X+=p[O];b.contentHeight>X&&(p[_.row+_.rowSpan-1]+=b.contentHeight-X)}const S=_=>{let b=0;for(let X=_.row;X<_.row+_.rowSpan;X++)b+=p[X];
|
|
277
|
+
return b},w=[],C=()=>{if(w.length===0)return;const _=this.getPdfCurrentPage(t);for(const{page:b,draw:X}of w)t.setPage(b),X();w.length=0,t.setPage(_)},D=(_,b,X,O,K,W,L)=>{const A=_.backgroundColor?this.
|
|
278
|
+
hexToRgb(_.backgroundColor):L?{r:249,g:250,b:251}:{r:255,g:255,b:255};(_.backgroundColor||L)&&(t.setFillColor(A.r,A.g,A.b),t.rect(X,K,O,W,"F"));const U=this.getPdfCurrentPage(t),z=Ge(_.borders);if(T||
|
|
279
|
+
z){const Y=ze({tableBorders:T,cellBorders:z,flags:{isTopRow:(b?.row??0)===0,isBottomRow:b?b.row+b.rowSpan===m.rows:!1,isLeftCol:(b?.col??0)===0,isRightCol:b?b.col+b.colSpan===m.cols:!1},fallback:{style:"\
|
|
280
|
+
single",width:g,color:P}}),q=X+O,Z=K+W;w.push({page:U,draw:()=>{this.drawPdfBorderEdge(t,Y.top,X,K,q,K),this.drawPdfBorderEdge(t,Y.bottom,X,Z,q,Z),this.drawPdfBorderEdge(t,Y.left,X,K,X,Z),this.drawPdfBorderEdge(
|
|
281
|
+
t,Y.right,q,K,q,Z)}})}else g>0&&w.push({page:U,draw:()=>{t.setDrawColor(c.r,c.g,c.b),t.setLineWidth(g*this.PX_TO_PT),t.rect(X,K,O,W,"S")}})},V=async(_,b,X,O)=>{const K=!!e.hasHeader&&b===0,W=p[b],L=this.
|
|
282
|
+
getPdfCurrentPage(t);for(const A of _.children){t.setPage(L);const U=m.byId.get(A.id),z=E+(U?B[U.col]:0),Y=U?k(U):F/x,q=O||!U?W:S(U);D(A,U,z,Y,X,q,K);const Z=I.get(A.id),ot=Z?.blocks??this.extractCellBlocks(
|
|
283
|
+
A),Q=Z?.pad.left??d,rt=Z?.pad.right??d,lt=Z?.pad.top??d,ct=Z?.pad.bottom??d,et=Z?.width??Y-Q-rt,nt=Z?.flowHeight??this.FONT_SIZES.normal*this.LINE_HEIGHT_MULTIPLIERS.paragraph,ft=Math.max(0,q-lt-ct-nt),
|
|
284
|
+
pt=A.verticalAlign==="bottom"?ft:A.verticalAlign==="middle"?ft/2:0,Ot=X+lt+pt;if(ot.length>0){const Ct={...n,keepFirstBlockDeclaredSpaceBefore:!0,columnCount:1,columnFlow:void 0,marginTopPt:Ot,marginRightPt:Math.
|
|
285
|
+
max(0,n.pageWidthPt-(z+Q+et)),marginBottomPt:n.pageHeightPt-this.UNBOUNDED_CELL_FLOW_BOTTOM_PT,marginLeftPt:z+Q,pageMarginLeftPt:z+Q,contentWidthPt:Math.max(1,et),fullContentWidthPt:Math.max(1,et),columnStridePt:Math.
|
|
286
|
+
max(1,et)};await this.renderBodyBlocks(t,ot,Ct,o,l,r,void 0,void 0,void 0,Ot)}}t.setPage(L)},M=(_,b)=>_.idx!==b.idx?_.idx>b.idx?_:b:_.y>=b.y?_:b,N=async(_,b,X,O,K,W)=>{const L=I.get(b.id),A=L?.blocks??
|
|
287
|
+
this.extractCellBlocks(b),U=L?.pad.left??d,z=L?.pad.bottom??d,Y=X?k(X):F/x,q=L?.width??Y-U-(L?.pad.right??d),Z=X?B[X.col]:0;let ot=O.idx;if(A.length===0){const nt=L?.flowHeight??this.FONT_SIZES.normal*
|
|
288
|
+
this.LINE_HEIGHT_MULTIPLIERS.paragraph;return{idx:ot,y:Math.min(W,O.y+nt+z)}}const Q=(nt,ft)=>{const pt=nt.left+Z+U;ft.marginTopPt=nt.top,ft.marginLeftPt=pt,ft.pageMarginLeftPt=pt,ft.marginRightPt=Math.
|
|
289
|
+
max(0,n.pageWidthPt-(pt+q))},rt={...n,keepFirstBlockDeclaredSpaceBefore:!0,columnCount:1,columnFlow:void 0,marginBottomPt:n.pageHeightPt-W,reservedInsetForPage:void 0,contentWidthPt:Math.max(1,q),fullContentWidthPt:Math.
|
|
290
|
+
max(1,q),columnStridePt:Math.max(1,q)},lt=K(ot);Q(lt,rt),_.setPage(lt.page);const ct=_.addPage;_.addPage=()=>{ot+=1;const nt=K(ot);return Q(nt,rt),_.setPage(nt.page),_};let et=O.y;try{et=(await this.renderBodyBlocks(
|
|
291
|
+
_,A,rt,o,l,r,void 0,void 0,void 0,O.y)).finalY}finally{_.addPage=ct}return{idx:ot,y:Math.min(W,et+z)}},G=async(_,b,X)=>{const O=h,K=H&&_>0?p[0]:0,W=n.marginTopPt+K,L=await import("./jspdf.es.min-DU74zN8b.js").
|
|
292
|
+
then($=>$.j),A=L.jsPDF??L.default,U=new A({orientation:n.orientation,unit:"pt",format:[n.pageWidthPt,n.pageHeightPt]});await this.registerCurrentPdfFonts(U,l);const z=U.addPage.bind(U),Y=[{page:1,top:n.
|
|
293
|
+
marginTopPt,left:E}],q=$=>{for(;Y.length<=$;)z(),Y.push({page:Y.length+1,top:W,left:E});return Y[$]},Z=($,at)=>{let{idx:ut,y:ht}=$,gt=at;for(;;){const mt=Math.max(0,O-ht);if(gt<=mt+.01)return{idx:ut,y:ht+
|
|
294
|
+
gt};gt-=mt,ut+=1,ht=W}},ot=[],Q=[],rt=new Map,lt=[];let ct={idx:0,y:X};for(let $=_;$<b;$++){const at=ct;ot[$-_]=at;for(const gt of e.children[$].children){const mt=m.byId.get(gt.id),xt=I.get(gt.id)?.pad.
|
|
295
|
+
top??d,Mt=at.y+xt>O+.01?{idx:at.idx+1,y:W+xt}:{idx:at.idx,y:at.y+xt};rt.set(gt.id,Mt);const Tt=await N(U,gt,mt,Mt,q,O),_t=Math.min(b-1,$+(mt?.rowSpan??1)-1),bt=lt[_t-_];lt[_t-_]=bt?M(bt,Tt):Tt}const ut=Z(
|
|
296
|
+
at,p[$]),ht=lt[$-_];ct=ht?M(ut,ht):ut,Q[$-_]=ct}let et=ct.idx;for(const $ of rt.values())et=Math.max(et,$.idx);et=Math.max(et,Y.length-1);const nt=[{page:this.getPdfCurrentPage(t),top:n.marginTopPt,left:E}],
|
|
297
|
+
ft=t.addPage,pt=()=>{const $=this.advancePdfFlowRegion(t,n);return E=$.x+y,{page:this.getPdfCurrentPage(t),top:$.y+K,left:E}};for(let $=1;$<=et;$++){const at=pt();nt.push(at),K>0&&await V(e.children[0],
|
|
298
|
+
0,at.top-K,!0)}const Ot=$=>{for(;nt.length<=$;){const at=t.addPage;t.addPage=ft;try{nt.push(pt())}finally{t.addPage=at}}return nt[$]};for(let $=_;$<b;$++){const at=!!e.hasHeader&&$===0;for(const ut of e.
|
|
299
|
+
children[$].children){const ht=m.byId.get(ut.id),gt=Math.min(b-1,$+(ht?.rowSpan??1)-1),mt=ot[$-_],xt=Q[gt-_],Mt=ht?k(ht):F/x;for(let Tt=mt.idx;Tt<=xt.idx;Tt++){const _t=nt[Tt],bt=Tt===mt.idx?mt.y:_t.top,
|
|
300
|
+
Wt=Tt===xt.idx?xt.y:O;Wt-bt<=.01||(t.setPage(_t.page),D(ut,ht,_t.left+(ht?B[ht.col]:0),Mt,bt,Wt-bt,at))}}}for(let $=_;$<b;$++)for(const at of e.children[$].children)await N(t,at,m.byId.get(at.id),rt.get(
|
|
301
|
+
at.id),Ot,O);const Ct=Q[Q.length-1],At=nt[Math.min(Ct.idx,nt.length-1)];return t.setPage(At.page),E=At.left,Ct.y},H=e.hasHeader===!0&&e.children.length>1&&!m.cells.some(_=>_.row===0&&_.rowSpan>1),j=e.
|
|
302
|
+
children.map(()=>[]);for(const _ of m.cells)j[_.row]?.push(_);for(let _=0;_<e.children.length;){let b=_+1,X=0;for(let L=_;L<b;L++){X+=p[L];for(const A of j[L])b=Math.min(e.children.length,Math.max(b,A.
|
|
303
|
+
row+A.rowSpan))}const O=H&&_>0?p[0]:0,K=h-n.marginTopPt-O,W=X>K;if((W?s>=h-.01:s+X>h)&&s!==n.marginTopPt){const L=this.advancePdfFlowRegion(t,n);s=L.y,E=L.x+y,H&&_>0&&(await V(e.children[0],0,s,!0),s+=
|
|
304
|
+
p[0])}if(W)s=await G(_,b,s);else for(let L=_;L<b;L++)await V(e.children[L],L,s,!1),s+=p[L];_=b}return C(),s}static async renderCodeBlock(t,e,a,i,r,o=this.MARGIN_LEFT,l=Xt,n=!1,h=this.getDefaultPdfLayoutMetrics(),s){
|
|
305
|
+
const g=o-h.marginLeftPt;let P=o;const c=e.language||"",f=ia(c);if(f&&e.renderDiagram!==!1&&f)return this.renderDiagramCodeBlock(t,e,a,i,r,P,f,l,n,h);const d=n?"SourceCodePro":"courier",T=e.content||"",
|
|
306
|
+
m=c?await oa(T,c,l):null,x=dt.fontSizePx*this.PX_TO_PT,F=x*dt.lineHeightMultiplier,y=dt.paddingPx*this.PX_TO_PT,E=dt.borderRadiusPx*this.PX_TO_PT,R=this.hexToRgb(l.background),B=this.hexToRgb(l.default);
|
|
307
|
+
t.setFont(d,"normal"),t.setFontSize(x);const k=Math.max(1,i-y*2),I=Jt(T,M=>t.getTextWidth(M),k),p=[];let u=0;for(const M of m??[])p.push({start:u,end:u+M.text.length,color:M.color}),u+=M.text.length;const S=M=>{
|
|
308
|
+
if(p.length===0)return[{text:M.text,color:l.default}];const N=[];for(const G of p){const H=Math.max(M.startCharOffset,G.start),j=Math.min(M.endCharOffset,G.end);j<=H||N.push({text:T.slice(H,j),color:G.
|
|
309
|
+
color})}return N.length>0?N:[{text:M.text,color:l.default}]};let w=a,C=0,D=r;const V=()=>{const M=this.advancePdfFlowRegion(t,h);w=M.y,P=M.x+g,D=this.getPdfFlowBottom(t,h)};for(;C<I.length;){const M=C===
|
|
310
|
+
0,N=M?y:0,G=N+F+(I.length===C+1?y:0);w+G>D&&w!==h.marginTopPt&&V();let H=C,j=N;for(;H<I.length;){const b=H===I.length-1,X=j+F+(b?y:0);if(w+X>D&&H>C)break;j+=F,H+=1}const _=H===I.length;_&&(j+=y),t.setFillColor(
|
|
311
|
+
R.r,R.g,R.b),M&&_?this.drawRoundedRect(t,P,w,i,j,E):t.rect(P,w,i,j,"F"),t.setFont(d,"normal"),t.setFontSize(x);for(let b=C;b<H;b++){const X=b===0,O=b===I.length-1,K=w+N+(b-C)*F;s?.push({pageNumber:t.getCurrentPageInfo?.().
|
|
312
|
+
pageNumber??t.getNumberOfPages(),y:K-(X?y:0),height:F+(X?y:0)+(O?y:0)});let W=P+y;const L=w+N+(b-C)*F+x;for(const A of S(I[b])){const U=A.color?this.hexToRgb(A.color):B;t.setTextColor(U.r,U.g,U.b),A.text&&
|
|
313
|
+
t.text(A.text,W,L),W+=t.getTextWidth(A.text)}}w+=j,C=H,_||V()}return w}static async renderDiagramCodeBlock(t,e,a,i,r,o,l,n,h,s){const g=o-s.marginLeftPt;let P=o;const c=dt.paddingPx*this.PX_TO_PT,f=dt.
|
|
314
|
+
diagramSourceGapPx*this.PX_TO_PT,d=ie(),T=Math.max(120,Math.round((i-c*2)/this.PX_TO_PT)),m=await na({protocol:l,source:e.content||"",theme:d,maxWidth:T}),x=Math.max(1,m.width*this.PX_TO_PT),F=Math.max(
|
|
315
|
+
dt.diagramMinHeightPx,m.height)*this.PX_TO_PT,y=F+c*2,E=e.showDiagramSource!==!1,R=h?"SourceCodePro":"courier",B=dt.fontSizePx*this.PX_TO_PT;t.setFont(R,"normal"),t.setFontSize(B);const k=Jt(e.content||
|
|
316
|
+
"",N=>t.getTextWidth(N),Math.max(1,i-c*2)),I=c*2+k.length*B*dt.lineHeightMultiplier,p=(E?I+f:0)+y;let u=a;if(u+p>r&&u!==s.marginTopPt){const N=this.advancePdfFlowRegion(t,s);u=N.y,P=N.x+g}E&&(u=await this.
|
|
317
|
+
renderCodeBlock(t,{...e,renderDiagram:!1},u,i,r,P,n,h,s),u+=f);const S=this.hexToRgb(d.codeBorder||"#e0e0e0"),w=dt.borderRadiusPx*this.PX_TO_PT;t.setDrawColor(S.r,S.g,S.b),t.setLineWidth(this.BLOCK_BORDER_WIDTH_PT),
|
|
318
|
+
this.drawRoundedRect(t,P,u,i,y,w,"S");const C=Math.min(i-c*2,x),D=Math.min(y-c*2,F),V=P+(i-C)/2,M=u+(y-D)/2;if(m.svg){const N=await this.svgToPng(m.svg,Math.max(1,Math.round(m.width)),Math.max(1,Math.
|
|
319
|
+
round(m.height)),2);if(N)return t.addImage(N,"PNG",V,M,C,D),u+y}return t.setTextColor(220,38,38),t.setFont("helvetica","normal"),t.setFontSize(10),t.text("Diagram unavailable",P+c,u+c+10),u+y}static renderCellParagraph(t,e,a,i,r,o,l=!1){
|
|
320
|
+
const n=this.getParagraphFontSize(e),h=this.getParagraphDirection(e),s=this.getEffectiveParagraphAlignment(e,h),g=this.getLineSpacingMultiplier(e),P=this.processTextNodes(e.children);let c=i,f=[],d=0;
|
|
321
|
+
const T=m=>{f.length!==0&&(l?c+=this.measureLineAdvancePt(f,n,!!e.heading,g):c=this.renderLine(t,f,c,a,r,s,n,o,!!e.heading,g,m,{direction:h}),f=[],d=0)};for(const m of P){this.setRunFont(t,m,o),t.setFontSize(
|
|
322
|
+
this.getRunEffectiveFontSizePt(m.marks,n));const x=m.text.split(`
|
|
323
|
+
`);for(let F=0;F<x.length;F++){F>0&&T(!1);const y=x[F].split(/(\s+)/);for(const E of y){const R=this.measureRunDisplayWidthPt(t,E,m.marks);d+R>r&&f.length>0&&T(!1),(E.trim()||f.length>0)&&(f.push({text:E,
|
|
324
|
+
marks:m.marks,font:m.marks?.fontFamily}),d+=R)}}}return T(!0),c===i&&(c+=this.getEmptyParagraphLineHeight(e)),c}static extractCellBlocks(t){return t.children}static drawRoundedRect(t,e,a,i,r,o,l="F"){
|
|
325
|
+
const n=Math.min(o,i/2,r/2);t.roundedRect(e,a,i,r,n,n,l)}static getListIndentPt(t){switch(t){case"todo":return this.TODO_LIST_INDENT_PT;case"ordered":return this.ORDERED_LIST_INDENT_PT;case"unordered":default:
|
|
326
|
+
return this.UNORDERED_LIST_INDENT_PT}}static getListIndentLevel(t){const e=t.indentLevel??0;if(!Number.isFinite(e))return 0;const a=Math.floor(e);return Math.max(0,Math.min(a,this.MAX_LIST_INDENT_LEVEL))}static computeOrderedMarkerLabel(t,e,a,i){
|
|
327
|
+
return Le(t,a,e,i)}static getRunLetterSpacingPt(t){return(typeof t?.letterSpacing=="number"&&Number.isFinite(t.letterSpacing)?t.letterSpacing:0)*this.PX_TO_PT}static getRunEffectiveFontSizePt(t,e){const a=t?.
|
|
328
|
+
fontSize?t.fontSize*this.PX_TO_PT:e;return t?.superscript||t?.subscript?Math.round(a/this.PX_TO_PT*.7)*this.PX_TO_PT:a}static setRunFont(t,e,a){if(e.marks?.code){t.setFont(this.inlineCodeFontFamily,"n\
|
|
329
|
+
ormal");return}const i=this.mapFontFamily(e.font||e.marks?.fontFamily||a),r=this.resolveFontStyle(e.marks),o=this.scriptFallbackFor(t,e.text,i);if(o){t.setFont(o,r==="bold"||r==="bolditalic"?"bold":"n\
|
|
330
|
+
ormal");return}t.setFont(i,r)}static measureRunDisplayWidthPt(t,e,a){const i=o=>{const l=t.getFont?.()?.fontName,n=l?this.shapingFonts.get(l):void 0;return n?n.layout(o).advanceWidth*t.getFontSize()/n.
|
|
331
|
+
unitsPerEm:t.getTextWidth(o)},r=Be(a);return r?$t(e,{...r,letterSpacingPx:this.getRunLetterSpacingPt(a)},i):i(e)}static drawShapedText(t,e,a,i,r,o,l){const n=t.getFont?.()?.fontName,h=n?this.shapingFonts.
|
|
332
|
+
get(n):void 0;if(!h)return null;const s=h.layout(e);Array.from(e).every(d=>(d.codePointAt(0)??0)<=65535)&&t.text(e,a,i,{renderingMode:"invisible"}),t.setFillColor(l.r,l.g,l.b);const g=r/h.unitsPerEm;let P=0,
|
|
333
|
+
c=0,f=0;for(let d=0;d<s.glyphs.length;d++){const T=s.glyphs[d],m=s.positions[d],x=[];let F=0,y=0;const E=B=>a+f+(P+m.xOffset+B)*g,R=B=>i-(c+m.yOffset+B)*g;for(const B of T.path.commands)if(B.command===
|
|
334
|
+
"moveTo")[F,y]=B.args,x.push({op:"m",c:[E(F),R(y)]});else if(B.command==="lineTo")[F,y]=B.args,x.push({op:"l",c:[E(F),R(y)]});else if(B.command==="bezierCurveTo"){const[k,I,p,u,S,w]=B.args;x.push({op:"\
|
|
335
|
+
c",c:[E(k),R(I),E(p),R(u),E(S),R(w)]}),F=S,y=w}else if(B.command==="quadraticCurveTo"){const[k,I,p,u]=B.args,S=F+(k-F)*2/3,w=y+(I-y)*2/3,C=p+(k-p)*2/3,D=u+(I-u)*2/3;x.push({op:"c",c:[E(S),R(w),E(C),R(
|
|
336
|
+
D),E(p),R(u)]}),F=p,y=u}else B.command==="closePath"&&x.push({op:"h",c:[]});x.length>0&&(t.path(x),t.fill()),P+=m.xAdvance,c+=m.yAdvance,f+=o*Math.max(1,T.codePoints?.length??1)}return s.advanceWidth*
|
|
337
|
+
r/h.unitsPerEm+o*[...e].length}static renderLine(t,e,a,i,r,o,l,n,h,s,g=!0,P){e=e.filter(p=>!p.marks?.hidden||!!p.marks.footnoteRef);let c=P?.tabLayoutPx;const f=p=>p.marks?.fontSize?p.marks.fontSize*this.
|
|
338
|
+
PX_TO_PT:l,d=P?.direction??"ltr";if(!c&&e.length>0&&!e.some(p=>p.latexImage||p.marks?.latex)){const p=e,u={segments:p.map(w=>({text:w.text}))},S=Zt(u,d);if(S){const w=(D,V)=>{let M=0,N=0;for(const G of p){
|
|
339
|
+
const H=Math.max(D,N),j=Math.min(V,N+G.text.length);if(H<j){const _=G.text.slice(H-N,j-N);this.setRunFont(t,{...G,text:_},n),t.setFontSize(this.getRunEffectiveFontSizePt(G.marks,l)),M+=this.measureRunDisplayWidthPt(
|
|
340
|
+
t,_,G.marks)}N+=G.text.length}return M},C=p.map(D=>D.text).join("");e=Qt(u,S,w,o==="justify"&&!g).map(D=>({...p[D.segmentIndex],text:C.slice(D.start,D.end),rtl:D.rtl}))}}if(P?.tabRtl&&c&&c.length>0){const p=e,
|
|
341
|
+
u=c,S=[],w=[];let C=0;for(;C<p.length;){const D=p[C];if(D.text===" "){S.push(D),w.push(u[C]??{startX:0,endX:0}),C++;continue}const V=C;let M=Number.NEGATIVE_INFINITY;for(;C<p.length&&p[C].text!==" ";){
|
|
342
|
+
const O=u[C];O&&(M=Math.max(M,O.endX)),C++}const N=p.slice(V,C),G=N.map(O=>O.text).join("");if(!G)continue;Number.isFinite(M)||(M=0);const H={segments:N.map(O=>({text:O.text}))},j=Zt(H,"rtl");if(!j){for(let O=V;O<
|
|
343
|
+
C;O++)S.push(p[O]),w.push(u[O]??{startX:0,endX:0});continue}const _=Qt(H,j,(O,K)=>{let W=0,L=0;for(const A of N){const U=Math.max(O,L),z=Math.min(K,L+A.text.length);if(U<z){const Y=A.text.slice(U-L,z-
|
|
344
|
+
L);this.setRunFont(t,{...A,text:Y},n),t.setFontSize(this.getRunEffectiveFontSizePt(A.marks,l)),W+=this.measureRunDisplayWidthPt(t,Y,A.marks)}L+=A.text.length}return W}),b=_.reduce((O,K)=>O+K.width,0),
|
|
345
|
+
X=M*this.PX_TO_PT-b;for(const O of _)S.push({...N[O.segmentIndex],text:G.slice(O.start,O.end),rtl:O.rtl}),w.push({startX:(X+O.x)/this.PX_TO_PT,endX:(X+O.x+O.width)/this.PX_TO_PT})}e=S,c=w}let T=0,m=0;
|
|
346
|
+
for(const p of e)if(p.latexImage){const u=p.latexImage.contentHeight*this.PX_TO_PT;u>m&&(m=u)}else{const u=f(p);u>T&&(T=u)}T===0&&(T=l);const x=a+T;let F=0;if(c&&c.length>0)F=P?.tabRtl?(P.tabWidthPx??
|
|
347
|
+
Math.max(...c.map(p=>p.endX)))*this.PX_TO_PT:c[c.length-1].endX*this.PX_TO_PT;else for(const p of e)p.latexImage?F+=p.latexImage.contentWidth*this.PX_TO_PT:(this.setRunFont(t,p,n),t.setFontSize(this.getRunEffectiveFontSizePt(
|
|
348
|
+
p.marks,l)),F+=this.measureRunDisplayWidthPt(t,p.text,p.marks));let y=i;o==="center"?y=i+(r-F)/2:(o==="right"||o==="justify"&&d==="rtl"&&(g||c))&&(y=i+r-F),P?.tabRtl&&c&&(y=i);let E=0;if(o==="justify"&&
|
|
349
|
+
!g&&!c){let p=0;for(const u of e)u.latexImage||u.marks?.latex||(p+=(u.text.match(/ /g)||[]).length);p>0&&(E=Math.max(0,(r-F)/p))}const R=y;for(let p=0;p<e.length;p++){const u=e[p],S=c?.[p];if(S&&(y=R+
|
|
350
|
+
S.startX*this.PX_TO_PT,u.text===" ")){if(S.leader){const W=this.getRunEffectiveFontSizePt(u.marks,l),L=u.marks?.color?this.hexToRgb(u.marks.color):{r:0,g:0,b:0};this.renderTabLeaderPdf(t,R+S.startX*this.
|
|
351
|
+
PX_TO_PT,R+S.endX*this.PX_TO_PT,x,S.leader,W,L)}y=R+S.endX*this.PX_TO_PT;continue}if(u.latexImage){const W=u.latexImage.width*this.PX_TO_PT,L=u.latexImage.height*this.PX_TO_PT,A=u.latexImage.contentWidth*
|
|
352
|
+
this.PX_TO_PT,U=u.latexImage.contentHeight*this.PX_TO_PT,z=(W-A)/2,Y=y-z,q=x-U*.7-z;try{t.addImage(u.latexImage.dataUrl,"PNG",Y,q,W,L)}catch(Z){console.error("Failed to add inline latex image to PDF:",
|
|
353
|
+
Z)}y+=A;continue}this.setRunFont(t,u,n);const w=f(u),C=this.getRunEffectiveFontSizePt(u.marks,l),D=C/this.PX_TO_PT;t.setFontSize(C);const V=!!u.marks?.link;let M={r:0,g:0,b:0};V?M={r:37,g:99,b:235}:u.
|
|
354
|
+
marks?.color?M=this.hexToRgb(u.marks.color):u.marks?.code&&(M=this.hexToRgb(wt.codeText)),t.setTextColor(M.r,M.g,M.b);const N=!!(u.marks?.smallCaps&&!u.marks?.allCaps),G=this.getRunLetterSpacingPt(u.marks),
|
|
355
|
+
H=u.rtl?{isInputVisual:!1,isOutputVisual:!0,isInputRtl:!0,isOutputRtl:!1}:void 0,j=G!==0||H?{...G!==0?{charSpace:G}:{},...H}:void 0,_=this.measureRunDisplayWidthPt(t,u.text,u.marks),b=E>0?(u.text.match(
|
|
356
|
+
/ /g)||[]).length:0,X=_+b*E;if(u.marks?.backgroundColor){const W=ga(u.marks.backgroundColor)??u.marks.backgroundColor,L=this.hexToRgb(W);t.setFillColor(L.r,L.g,L.b),t.rect(y,x-w*.8,X,w*1.1,"F"),t.setTextColor(
|
|
357
|
+
M.r,M.g,M.b)}else if(u.marks?.code){const W=this.hexToRgb(wt.codeBackground);t.setFillColor(W.r,W.g,W.b),this.drawRoundedRect(t,y-2*this.PX_TO_PT,x-w*.93,X+4*this.PX_TO_PT,w+4*this.PX_TO_PT,3*this.PX_TO_PT),
|
|
358
|
+
t.setTextColor(M.r,M.g,M.b)}let O=x;u.marks?.superscript?O=x-w*.4:u.marks?.subscript&&(O=x+w*.15),(u.marks?.underline||V)&&!u.marks?.code&&(V?t.setDrawColor(37,99,235):t.setDrawColor(0,0,0),t.setLineWidth(
|
|
359
|
+
.5),t.line(y,O+2,y+X,O+2));const K=(W,L)=>{const A=u.marks?.allCaps?Dt(W,u.marks.lang):W,U=this.drawShapedText(t,A,L,O,C,G,M);if(U!==null)return U;if(N){let z=L;for(const Y of Ee(W,u.marks?.lang)){const q=Y.
|
|
360
|
+
lower?t.getTextWidth(Dt(Y.text,u.marks?.lang))*te:t.getTextWidth(Y.text);Y.lower?(t.setFontSize(C*te),t.text(Dt(Y.text,u.marks?.lang),z,O,j),t.setFontSize(C)):t.text(Y.text,z,O,j),z+=q+G*Y.text.length}
|
|
361
|
+
return z-L}return t.text(A,L,O,j),this.measureRunDisplayWidthPt(t,W,u.marks)};if(E>0){let W=y;for(const L of u.text.split(/( +)/))L&&(W+=K(L,W),L[0]===" "&&(W+=E*L.length))}else K(u.text,y);if(u.marks?.
|
|
362
|
+
strikethrough||u.marks?.doubleStrikethrough){t.setDrawColor(M.r,M.g,M.b),t.setLineWidth(Math.max(1,Math.round(D*.04))*this.PX_TO_PT);const W=L=>{const A=L-C*.3;t.line(y,A,y+X,A)};u.marks?.doubleStrikethrough?
|
|
363
|
+
(W(O+C*.09),W(O-C*.09)):W(O)}if(V&&u.marks?.link){const W=x-w*.8,L=w*1.1;t.link(y,W,X,L,{url:u.marks.link})}y+=X}if(P?.hyphenTrailing){const p=e[e.length-1];if(p&&!p.marks?.latex){this.setRunFont(t,p,
|
|
364
|
+
n),t.setFontSize(this.getRunEffectiveFontSizePt(p.marks,l));const u=p.marks?.color?this.hexToRgb(p.marks.color):{r:0,g:0,b:0};t.setTextColor(u.r,u.g,u.b),t.text("-",y,x)}}const B=s??(h?this.LINE_HEIGHT_MULTIPLIERS.
|
|
365
|
+
heading:this.LINE_HEIGHT_MULTIPLIERS.paragraph),k=T*B,I=m>k*1.25?m:k;return a+I}static renderTabLeaderPdf(t,e,a,i,r,o,l){const n=Math.max(1.5,o*.12),h=e+n,s=a-n;if(s-h<1)return;if(t.setFillColor(l.r,l.
|
|
366
|
+
g,l.b),r==="underscore"){const P=i+Math.max(1,o*.08),c=Math.max(.75,o*.055);t.rect(h,P,s-h,c,"F");return}const g=Math.max(2.25,o*.33);if(r==="dot"){const P=Math.max(.45,o*.045),c=i-P;for(let f=Math.ceil(
|
|
367
|
+
h/g)*g;f<=s;f+=g)t.circle(f,c,P,"F")}else{const P=Math.max(1.5,o*.18),c=i-o*.28,f=Math.max(.75,o*.055);for(let d=Math.ceil(h/g)*g;d+P<=s;d+=g)t.rect(d,c,P,f,"F")}}static processTextNodes(t){const e=[];
|
|
368
|
+
for(const a of t)if(a.type==="text"){const i=a;if(i.marks?.hidden&&!i.marks.footnoteRef)continue;e.push({text:i.text,marks:i.marks,font:i.marks?.fontFamily})}return e}static async processTextNodesWithLatex(t,e){
|
|
369
|
+
const a=[];for(let o=0;o<t.length;o++){const l=t[o];if(l.type==="text"){const n=l;if(n.marks?.hidden&&!n.marks.footnoteRef)continue;n.marks?.latex?a.push({index:o,node:n,latexPromise:this.renderLatexToImage(
|
|
370
|
+
n.text,!1,e)}):a.push({index:o,node:n})}}const i=await Promise.all(a.map(o=>o.latexPromise||Promise.resolve(null))),r=[];for(let o=0;o<a.length;o++){const{node:l}=a[o],n=i[o];r.push({text:l.text,marks:l.
|
|
371
|
+
marks,font:l.marks?.fontFamily,latexImage:n||void 0})}return r}static getParagraphFontSize(t){return da(t)*this.PX_TO_PT}static getParagraphLineHeight(t){return this.getParagraphFontSize(t)*ae(t)}static getEmptyParagraphLineHeight(t){
|
|
372
|
+
return this.measureLineAdvancePt(this.paragraphForPdfOutput(t).children.map(e=>({marks:e.type==="text"?e.marks:void 0})),this.getParagraphFontSize(t),!!t.heading,this.getLineSpacingMultiplier(t))}static async embedLocalFonts(t,e){
|
|
373
|
+
if(this.embeddedFamilyNames.clear(),typeof window>"u")return;const a=new Set(["sans-serif","sans","serif","monospace","system-ui","system ui","ui-sans-serif","ui-serif","ui-monospace"]),i=Nt(e).map(o=>o.
|
|
374
|
+
family).filter(o=>{const l=o.toLowerCase();return!a.has(l)&&this.FONT_MAP[l]!=="KaTeX_Main"});if(i.length===0)return;let r;for(const o of i){const l=o.toLowerCase();let n=this.localFontFiles.get(l);if(n===
|
|
375
|
+
void 0){if(r===void 0&&(r=await me().catch(()=>null)),!r)return;try{n=await this.buildLocalFontFiles(o,r)}catch{n=null}this.localFontFiles.set(l,n)}if(n)try{for(const h of n)t.addFileToVFS(h.vfsName,h.
|
|
376
|
+
base64),t.addFont(h.vfsName,o,h.style);this.embeddedFamilyNames.set(l,o)}catch(h){console.warn(`Failed to embed font "${o}" in PDF:`,h),this.localFontFiles.set(l,null)}}}static async buildLocalFontFiles(t,e){
|
|
377
|
+
const a=t.toLowerCase(),i=e.filter(c=>c.family?.trim().toLowerCase()===a&&c.blob);if(i.length===0)return null;const r=i.map(c=>({entry:c,...Pe(c.style),specificity:(c.style??"").length})),o=(c,f)=>r.filter(
|
|
378
|
+
d=>d.bold===c&&d.italic===f).sort((d,T)=>d.specificity-T.specificity)[0]?.entry,l=o(!1,!1)??r[0].entry,n=[{style:"normal",entry:l},{style:"bold",entry:o(!0,!1)??l},{style:"italic",entry:o(!1,!0)??l},{
|
|
379
|
+
style:"bolditalic",entry:o(!0,!0)??o(!0,!1)??l}],h=new Map;for(const{entry:c}of n){if(h.has(c))continue;const f=await(await c.blob()).arrayBuffer(),d=Ht(new Uint8Array(f));h.set(c,d==="ttf"?this.arrayBufferToBase64(
|
|
380
|
+
f):null)}if(!h.get(l))return null;const s=a.replace(/[^a-z0-9]+/g,"-"),g=new Map;let P=0;return n.map(({style:c,entry:f})=>{const d=h.get(f)?f:l;let T=g.get(d);return T||(T=`${s}-${P++}.ttf`,g.set(d,T)),
|
|
381
|
+
{vfsName:T,base64:h.get(d),style:c}})}static mapFontFamily(t){const e=this.mapFontFamilyToStandard(t);return this.bundledGenreFamilies.get(e)??(e==="SourceSerif4"?"times":e)}static mapFontFamilyToStandard(t){
|
|
382
|
+
if(!t)return"helvetica";const e=new Set(["helvetica","times","courier"]),a=t.split(",").map(r=>r.trim().replace(/^['"]|['"]$/g,"")).filter(r=>r.length>0);a.length===0&&a.push(t);for(const r of a){const o=r.
|
|
383
|
+
toLowerCase(),l=this.embeddedFamilyNames.get(o);if(l)return l;if(e.has(o))return o;const n=this.FONT_MAP[o];if(n)return n}const i=pe(a[0]);return i==="serif"?"times":i==="monospace"?"courier":"helveti\
|
|
384
|
+
ca"}static resolveFontStyle(t){const e=!!t?.bold,a=!!t?.italic;return e&&a?"bolditalic":e?"bold":a?"italic":"normal"}static drawPdfBorderEdge(t,e,a,i,r,o){if(e.style==="none"||e.width<=0)return;const l=this.
|
|
385
|
+
hexToRgb(e.color);t.setDrawColor(l.r,l.g,l.b);const n=He(e).map(h=>h*this.PX_TO_PT);if(n.length>0&&typeof t.setLineDashPattern=="function"&&t.setLineDashPattern(n,0),e.style==="double"){const h=Math.max(
|
|
386
|
+
e.width/3,.5)*this.PX_TO_PT,s=e.width*2/3/2*this.PX_TO_PT;t.setLineWidth(h);const g=i===o,P=g?0:s,c=g?s:0;t.line(a-P,i-c,r-P,o-c),t.line(a+P,i+c,r+P,o+c)}else t.setLineWidth(e.width*this.PX_TO_PT),t.line(
|
|
387
|
+
a,i,r,o);n.length>0&&typeof t.setLineDashPattern=="function"&&t.setLineDashPattern([],0)}static hexToRgb(t){return ue(t)??{r:0,g:0,b:0}}static async renderImageBlock(t,e,a,i,r=this.getDefaultPdfLayoutMetrics()){
|
|
388
|
+
if(!e.src)return{nextY:a};const o=this.getPdfFlowBottom(t,r);let l=Math.max(e.width||1,1)*this.PX_TO_PT,n=Math.max(e.height||1,1)*this.PX_TO_PT;if(l>i){const c=i/l;l=i,n*=c}(n<=0||!Number.isFinite(n))&&
|
|
389
|
+
(n=72);let h=r.marginLeftPt;if(a+n>o&&a!==r.marginTopPt){const c=this.advancePdfFlowRegion(t,r);a=c.y,h=c.x}const s=e.align||"left";let g=h;if(s==="center"?g=h+(i-l)/2:s==="right"&&(g=h+i-l),e.originalFormat)
|
|
390
|
+
return t.setFillColor(243,244,246),t.setDrawColor(209,213,219),t.setLineWidth(.75),t.rect(g,a,l,n,"FD"),t.setFont(this.mapFontFamily(void 0),"normal"),t.setFontSize(14*this.PX_TO_PT),t.setTextColor(107,
|
|
391
|
+
114,128),t.text(`${e.originalFormat.toUpperCase()} image`,g+l/2,a+n/2,{align:"center",baseline:"middle"}),{nextY:a+n};const P=await this.resolveImageDataCached(t,e.src);if(!P)return{nextY:a+n};try{t.addImage(
|
|
392
|
+
P.data,P.format,g,a,l,n)}catch(c){return console.error("Failed to add image to PDF",c),{nextY:a+n}}return{nextY:a+n}}static resolveImageDataCached(t,e){let a=this.imageDataCache.get(t);a||(a=new Map,this.
|
|
393
|
+
imageDataCache.set(t,a));let i=a.get(e);return i||(i=this.resolveImageData(e),a.set(e,i)),i}static async resolveImageData(t){if(/^data:image\/svg\+xml[;,]/i.test(t))return this.rasterizeSvgImage(t);const e=t.
|
|
394
|
+
match(/^data:image\/([a-zA-Z0-9+.-]+);base64,/);if(e){const l=this.normalizeImageFormat(e[1]);return{data:t,format:l}}const a=await this.fetchImageAsBlob(t);if(!a)return null;const{blob:i,format:r}=a,
|
|
395
|
+
o=await this.blobToDataUrl(i,r);return r==="SVG+XML"?this.rasterizeSvgImage(o):{data:o,format:r}}static async rasterizeSvgImage(t){const e=this.decodeSvgDataUrl(t);if(!e)return null;const a=this.svgIntrinsicSize(
|
|
396
|
+
e),i=2;if(typeof process<"u"&&process.versions?.node&&(typeof navigator>"u"||/jsdom|node/i.test(navigator.userAgent??"")))try{const o=await import(["can","vas"].join("")),l=await o.loadImage(Buffer.from(
|
|
397
|
+
e,"utf8")),n=o.createCanvas(Math.max(1,Math.round(a.width*i)),Math.max(1,Math.round(a.height*i)));return n.getContext("2d").drawImage(l,0,0,n.width,n.height),{data:n.toDataURL("image/png"),format:"PNG"}}catch(o){
|
|
398
|
+
return console.error("Failed to rasterize SVG image for PDF export",o),null}const r=await Promise.race([this.svgToPng(e,a.width,a.height,i),new Promise(o=>setTimeout(()=>o(null),5e3))]);return r?{data:r,
|
|
399
|
+
format:"PNG"}:null}static decodeSvgDataUrl(t){const e=t.indexOf(",");if(e<0)return null;const a=t.slice(0,e),i=t.slice(e+1);try{if(/;base64$/i.test(a)){const r=globalThis?.Buffer;if(r)return r.from(i,
|
|
400
|
+
"base64").toString();const o=atob(i),l=Uint8Array.from(o,n=>n.charCodeAt(0));return new TextDecoder().decode(l)}return decodeURIComponent(i)}catch{return null}}static svgIntrinsicSize(t){const e=/<svg\b[^>]*>/i.
|
|
401
|
+
exec(t)?.[0]??"",a=n=>{const h=new RegExp(`\\s${n}="([\\d.]+)(px)?"`,"i").exec(e),s=h?Number(h[1]):NaN;return Number.isFinite(s)&&s>0?s:void 0},i=/\sviewBox="([^"]+)"/i.exec(e)?.[1]?.trim().split(/[\s,]+/).
|
|
402
|
+
map(Number),r=i&&i.length===4&&i[2]>0?i[2]:void 0,o=i&&i.length===4&&i[3]>0?i[3]:void 0,l=n=>Math.min(4e3,Math.max(1,n));return{width:l(a("width")??r??300),height:l(a("height")??o??150)}}static async fetchImageAsBlob(t){
|
|
403
|
+
try{const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch image: ${e.status}`);const a=await e.blob(),i=this.extractImageFormat(a.type);return{blob:a,format:i}}catch(e){return console.error(
|
|
404
|
+
"Failed to load image for PDF export",e),null}}static async blobToDataUrl(t,e){const a=await t.arrayBuffer(),i=this.arrayBufferToBase64(a);return`data:${this.formatToMime(e)};base64,${i}`}static arrayBufferToBase64(t){
|
|
405
|
+
const e=globalThis?.Buffer;if(e)return e.from(t).toString("base64");let a="";const i=new Uint8Array(t),r=32768;for(let o=0;o<i.length;o+=r){const l=i.subarray(o,o+r);a+=String.fromCharCode.apply(null,
|
|
406
|
+
Array.from(l))}return btoa(a)}static formatToMime(t){const e=t.toLowerCase();return e==="jpeg"||e==="jpg"?"image/jpeg":e==="png"?"image/png":e==="webp"?"image/webp":`image/${e}`}static extractImageFormat(t){
|
|
407
|
+
if(!t)return"PNG";const e=t.match(/^image\/([a-zA-Z0-9+.-]+)/);return e?this.normalizeImageFormat(e[1]):"PNG"}static normalizeImageFormat(t){const e=t.toLowerCase();return e==="jpg"||e==="jpeg"?"JPEG":
|
|
408
|
+
e==="png"?"PNG":e==="webp"?"WEBP":e.toUpperCase()}static async renderMathBlock(t,e,a,i,r,o=this.getDefaultPdfLayoutMetrics()){if(!e.content||e.content.trim()==="")return{nextY:a};const l=e.displayMode!==
|
|
409
|
+
"inline",n=await this.renderLatexToImage(e.content,l);if(!n)return{nextY:a+20};let h=n.width*this.PX_TO_PT,s=n.height*this.PX_TO_PT;const g=i-this.MATH_BLOCK_PADDING*2;if(h>g){const x=g/h;h=g,s*=x}const P=Math.
|
|
410
|
+
max(this.MATH_BLOCK_MIN_HEIGHT,s)+this.MATH_BLOCK_PADDING*2;let c=o.marginLeftPt;if(a+P>r&&a!==o.marginTopPt){const x=this.advancePdfFlowRegion(t,o);a=x.y,c=x.x}const f=this.hexToRgb(ie().codeBorder||
|
|
411
|
+
"#e0e0e0");t.setDrawColor(f.r,f.g,f.b),t.setLineWidth(this.BLOCK_BORDER_WIDTH_PT),typeof t.roundedRect=="function"?t.roundedRect(c,a,i,P,this.MATH_BLOCK_BORDER_RADIUS,this.MATH_BLOCK_BORDER_RADIUS,"S"):
|
|
412
|
+
t.rect(c,a,i,P,"S");const d=e.align||"center";let T=c+this.MATH_BLOCK_PADDING;d==="center"?T=c+(i-h)/2:d==="right"&&(T=c+i-h-this.MATH_BLOCK_PADDING);const m=a+(P-s)/2;try{t.addImage(n.dataUrl,"PNG",T,
|
|
413
|
+
m,h,s)}catch(x){console.error("Failed to add math image to PDF:",x)}return{nextY:a+P}}static async getHtml2Canvas(){return this.html2canvasModule?this.html2canvasModule:this.html2canvasLoading?this.html2canvasLoading:
|
|
414
|
+
(this.html2canvasLoading=import("./html2canvas.esm-CntiHiYW.js").then(t=>(this.html2canvasModule=t.default,t.default)),this.html2canvasLoading)}static async renderLatexToImage(t,e,a=12){const i=this.getLatexSvgFromCache(
|
|
415
|
+
t,e);if(i){const r=await this.svgToPng(i.svg,i.width,i.height,3);if(r){const o=e?1:this.INLINE_MATH_SCALE;return{dataUrl:r,width:i.width*o,height:i.height*o,contentWidth:i.contentWidth*o,contentHeight:i.
|
|
416
|
+
contentHeight*o}}}try{const r=await this.getHtml2Canvas(),o=this.preprocessLaTeX(t),l=(await ca()).renderToString(o,{displayMode:e,throwOnError:!1,errorColor:"#ef4444",trust:!1,strict:!1});this.ensureKaTeXStyles();
|
|
417
|
+
const n=a/this.PX_TO_PT,h=e?20:n*this.INLINE_MATH_SCALE,s=4,g=document.createElement("div");g.style.cssText=`
|
|
418
|
+
position: fixed;
|
|
419
|
+
top: -9999px;
|
|
420
|
+
left: -9999px;
|
|
421
|
+
font-size: ${h}px;
|
|
422
|
+
line-height: 1.2;
|
|
423
|
+
background: transparent;
|
|
424
|
+
padding: ${s}px;
|
|
425
|
+
z-index: -9999;
|
|
426
|
+
`,g.innerHTML=l,document.body.appendChild(g),document.fonts?.ready&&await document.fonts.ready;const P=4,c=await r(g,{backgroundColor:null,scale:P,logging:!1,useCORS:!0,allowTaint:!1});document.
|
|
427
|
+
body.removeChild(g);const f=c.toDataURL("image/png"),d=c.width/P,T=c.height/P,m=d-s*2,x=T-s*2;return{dataUrl:f,width:d,height:T,contentWidth:m,contentHeight:x}}catch(r){return console.error("Failed to\
|
|
428
|
+
render LaTeX for PDF:",r),null}}static preprocessLaTeX(t){if(!t.includes(`
|
|
429
|
+
`)||["align","aligned","gather","gathered","split","cases","matrix","pmatrix","bmatrix","array"].some(a=>t.includes(`\\begin{${a}}`)||t.includes(`\\begin{${a}*}`)))return t;const e=t.split(`
|
|
430
|
+
`).map(a=>a.trim()).filter(a=>a.length>0);return e.length<=1?t:`\\begin{gathered}
|
|
431
|
+
${e.join(` \\\\
|
|
432
|
+
`)}
|
|
433
|
+
\\end{gathered}`}static ensureKaTeXStyles(){if(this.katexStylesLoaded)return;if(document.querySelector('link[href*="katex"]')){this.katexStylesLoaded=!0;return}const t=document.createElement("link");t.
|
|
434
|
+
rel="stylesheet",t.href=Lt("katex.min.css"),document.head.appendChild(t),this.katexStylesLoaded=!0}static async parseFile(t){const e=await import("./pdf-BLWDCiFF.js");e.GlobalWorkerOptions.workerSrc=Lt(
|
|
435
|
+
"pdfjs/worker.js");const a=await t.arrayBuffer();try{const i=await e.getDocument(a).promise;let r="";for(let h=1;h<=i.numPages;h++){const s=(await(await i.getPage(h)).getTextContent()).items.map(g=>g.
|
|
436
|
+
str).join(" ");r+=s+`
|
|
437
|
+
|
|
438
|
+
`}const o=r.trim().split(`
|
|
439
|
+
`),l=[];let n=[];for(let h=0;h<o.length;h++){const s=o[h].trim();if(s===""){if(n.length>0){const g=n.join(" ").trim();g&&l.push(Ft([{type:"text",text:g}])),n=[]}}else{const g=s.length<60,P=s===s.toUpperCase()&&
|
|
440
|
+
/[A-Z]/.test(s),c=/[.!?]$/.test(s),f=h+1<o.length&&o[h+1].trim()==="";if(g&&(P||f&&!c)){if(n.length>0){const d=n.join(" ").trim();d&&l.push(Ft([{type:"text",text:d}])),n=[]}l.push(Ft([{type:"text",text:s}]))}else
|
|
441
|
+
n.push(s)}}if(n.length>0){const h=n.join(" ").trim();h&&l.push(Ft([{type:"text",text:h}]))}return l.length===0&&l.push(Ft()),{type:"doc",children:l}}catch(i){throw console.error("Failed to parse PDF:",
|
|
442
|
+
i),new Error(`Failed to parse PDF: ${i instanceof Error?i.message:"Unknown error"}`)}}};v.PAGE_WIDTH=612,v.PAGE_HEIGHT=792,v.MARGIN_LEFT=72,v.MARGIN_RIGHT=72,v.MARGIN_TOP=72,v.MARGIN_BOTTOM=72,v.PX_TO_PT=
|
|
443
|
+
ne,v.UNBOUNDED_CELL_FLOW_BOTTOM_PT=1e4,v.DEFAULT_BODY_FONT="Arial, sans-serif",v.LINE_HEIGHT_MULTIPLIERS=ha,v.FONT_SIZES={h1:yt.h1*v.PX_TO_PT,h2:yt.h2*v.PX_TO_PT,h3:yt.h3*v.PX_TO_PT,h4:yt.h4*v.PX_TO_PT,
|
|
444
|
+
h5:yt.h5*v.PX_TO_PT,h6:yt.h6*v.PX_TO_PT,normal:yt.paragraph*v.PX_TO_PT},v.FONT_MAP={arial:"helvetica",helvetica:"helvetica","helvetica neue":"helvetica","times new roman":"times",georgia:"times","sour\
|
|
445
|
+
ce serif 4":"SourceSerif4",times:"times",courier:"courier","courier new":"courier",monospace:"courier",verdana:"helvetica",tahoma:"helvetica",inter:"helvetica","system-ui":"helvetica","system ui":"hel\
|
|
446
|
+
vetica","ui-sans-serif":"helvetica","ui-serif":"times","ui-monospace":"courier","sans-serif":"helvetica",sans:"helvetica",serif:"times",katex_main:"KaTeX_Main",computermodern:"KaTeX_Main","computer mo\
|
|
447
|
+
dern":"KaTeX_Main"},v.TODO_LIST_INDENT_PT=Pt.variantIndentPx.todo*v.PX_TO_PT,v.ORDERED_LIST_INDENT_PT=Pt.variantIndentPx.ordered*v.PX_TO_PT,v.UNORDERED_LIST_INDENT_PT=Pt.variantIndentPx.unordered*v.PX_TO_PT,
|
|
448
|
+
v.SUBLIST_INDENT_PT=Pt.sublistIndentPx*v.PX_TO_PT,v.BULLET_MARKER_WIDTH_PT=Pt.markerWidthPx*v.PX_TO_PT,v.BULLET_CENTER_OFFSET_PT=8*v.PX_TO_PT,v.BULLET_RADIUS_PT=2.5*v.PX_TO_PT,v.BULLET_SQUARE_INSET_PT=
|
|
449
|
+
5*v.PX_TO_PT,v.BULLET_SQUARE_HALF_PT=5*v.PX_TO_PT,v.BULLET_SQUARE_VERTICAL_ADJUST_PT=1*v.PX_TO_PT,v.ORDERED_LABEL_GAP_PT=6*v.PX_TO_PT,v.TODO_CHECKBOX_SIZE_PT=Pt.todoCheckboxSizePx*v.PX_TO_PT,v.TODO_CHECKBOX_RADIUS_PT=
|
|
450
|
+
Pt.todoCheckboxRadiusPx*v.PX_TO_PT,v.TODO_CHECKBOX_OFFSET_PT=Pt.todoCheckboxOffsetPx*v.PX_TO_PT,v.MAX_LIST_INDENT_LEVEL=Pt.maxIndentLevel,v.MATH_BLOCK_PADDING=16*v.PX_TO_PT,v.MATH_BLOCK_MIN_HEIGHT=40*
|
|
451
|
+
v.PX_TO_PT,v.MATH_BLOCK_BORDER_RADIUS=4*v.PX_TO_PT,v.BLOCK_BORDER_WIDTH_PT=1*v.PX_TO_PT,v.INLINE_MATH_SCALE=.85,v.BUNDLED_GENRE_FONTS={SourceSerif4:{family:"SourceSerif4",files:{normal:"SourceSerif4-R\
|
|
452
|
+
egular.ttf",bold:"SourceSerif4-Bold.ttf",italic:"SourceSerif4-It.ttf",bolditalic:"SourceSerif4-BoldIt.ttf"}},helvetica:{family:"LiberationSans",files:{normal:"LiberationSans-Regular.ttf",bold:"Liberat\
|
|
453
|
+
ionSans-Bold.ttf",italic:"LiberationSans-Italic.ttf",bolditalic:"LiberationSans-BoldItalic.ttf"}},times:{family:"LiberationSerif",files:{normal:"LiberationSerif-Regular.ttf",bold:"LiberationSerif-Bold\
|
|
454
|
+
.ttf",italic:"LiberationSerif-Italic.ttf",bolditalic:"LiberationSerif-BoldItalic.ttf"}},courier:{family:"LiberationMono",files:{normal:"LiberationMono-Regular.ttf",bold:"LiberationMono-Bold.ttf",italic:"\
|
|
455
|
+
LiberationMono-Italic.ttf",bolditalic:"LiberationMono-BoldItalic.ttf"}}},v.bundledGenreFamilies=new Map,v.SCRIPT_FALLBACK_FONTS=ua,v.scriptFallbackFamilies=new Map,v.scriptFontCoverageCache=new Map,v.
|
|
456
|
+
fallbackCharsetCache=new Map,v.shapingFonts=new Map,v.inlineCodeFontFamily="courier",v.fontFileData=new Map,v.localFontFiles=new Map,v.embeddedFamilyNames=new Map,v.COLUMN_BALANCE_SLACK_PT=1.5,v.imageDataCache=
|
|
457
|
+
new WeakMap,v.html2canvasModule=null,v.html2canvasLoading=null,v.katexStylesLoaded=!1;let Ta=v;export{Ta as PdfConverter};
|