@reviseio/engine 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/assets/{historyMaterializeWorker-Kl0syEbc.js → historyMaterializeWorker-BMHTnStL.js} +131 -130
- package/chunks/{AgentHtmlConverter-BnK7NaYA.js → AgentHtmlConverter-B5qstcmM.js} +129 -128
- package/chunks/{AgentPageRenderer-DLwq6nAa.js → AgentPageRenderer-JMhCw-hi.js} +4 -4
- package/chunks/BlockDiff-C8eiZ-sf.js +45 -0
- package/chunks/{CanvasRenderer-Bqsj1S0p.js → CanvasRenderer-C2vAzLWM.js} +12 -12
- package/chunks/DocumentCompare-DX4RWeSV.js +10 -0
- package/chunks/{DocumentLayoutEngine-7iOYvyVb.js → DocumentLayoutEngine-BhcWXkeu.js} +45 -45
- package/chunks/{DocumentMutator-DIrZBuLr.js → DocumentMutator-FEFU1YM0.js} +6 -6
- package/chunks/DocumentOutline-BOZoTohH.js +4 -0
- package/chunks/{DocumentScrubber-Cz8Q05hF.js → DocumentScrubber-C4N3Qagm.js} +1 -1
- package/chunks/{DocumentSession-lXSXqua5.js → DocumentSession-gZHWP7By.js} +1 -1
- package/chunks/{DocxConverter-BfDw7777.js → DocxConverter-BOyLn5eZ.js} +709 -703
- package/chunks/{DocxGraft-D0uCnGCo.js → DocxGraft-BbE-AaM5.js} +2 -2
- package/chunks/{HtmlConverter-7Xj_g9Jr.js → HtmlConverter-BlzwsPEn.js} +3 -3
- package/chunks/MarkdownConverter-BHVskVXI.js +59 -0
- package/chunks/{OdtConverter-GwRDMnwS.js → OdtConverter-BdmBFOD1.js} +1 -1
- package/chunks/{OfficeImportShared-nlMtIUni.js → OfficeImportShared-B2XJgnDO.js} +4 -4
- package/chunks/{PdfConverter-yOlWiVIj.js → PdfConverter-DZMCHDAo.js} +6 -6
- package/chunks/{RtfConverter--wLd0qrw.js → RtfConverter-RqE-xZcW.js} +66 -66
- package/chunks/{TableBorders-C5pNsuxP.js → TableBorders-ARyTi49V.js} +1 -1
- package/chunks/TextDecoding-IPbuUqcC.js +2 -0
- package/chunks/TextFileDecoder-BZBBejlR.js +10 -0
- package/chunks/{TxtConverter-BoRVCDZw.js → TxtConverter-EPQtb6A6.js} +1 -1
- package/chunks/{Typography-DAGM5kfI.js → Typography-XR6scRNV.js} +9 -9
- package/chunks/XmlConverter-9sFRFaza.js +55 -0
- package/chunks/{capture-Dtinb4bY.js → capture-DhGn0CWA.js} +1 -1
- package/chunks/{carrier-RNy67HN4.js → carrier-D58g-gw4.js} +1 -1
- package/chunks/{chromeImageLayout-bgHYmqTp.js → chromeImageLayout-DeYYS8YP.js} +1 -1
- package/chunks/{engine-TnK8N-gT.js → engine-C5fxuZJo.js} +140 -140
- package/chunks/{footnoteFlatten-BcKaWzVs.js → footnoteFlatten-coCVFd3c.js} +1 -1
- package/chunks/{graftExport-DxAALMHp.js → graftExport-FBGE2qvt.js} +1 -1
- package/chunks/{index-CTti7wRd.js → index-Cezk1s_y.js} +4 -4
- package/chunks/{serverDocumentSession-BmYdjC6e.js → serverDocumentSession-LMu3kocH.js} +559 -560
- package/chunks/{signatures-CU2LMLBp.js → signatures-DsJnnIqV.js} +1 -1
- package/chunks/textExtraction-Bqaqt1Kg.js +2 -0
- package/engine.js +2 -2
- package/package.json +2 -2
- package/chunks/BlockDiff-BdlcKY-t.js +0 -42
- package/chunks/DocumentCompare-BqyiP87r.js +0 -6
- package/chunks/MarkdownConverter-cnW_oePY.js +0 -57
- package/chunks/TextFileDecoder--rsVs3NR.js +0 -9
- package/chunks/XmlConverter-CO8Z28dX.js +0 -55
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{c,h as u,m as g,r as f}from"./capture-
|
|
2
|
-
import{a as i}from"./graftExport-
|
|
1
|
+
import{c,h as u,m as g,r as f}from"./capture-DhGn0CWA.js";import{C as S,a as d,b as m,c as l,i as p,f as h,g as R,h as x,n as C,p as D,l as E,k as y,d as b,s as k,j as _,e as A}from"./signatures-DsJnnIqV.js";
|
|
2
|
+
import{a as i}from"./graftExport-FBGE2qvt.js";import{G,b as I,g as B,r as T}from"./graftExport-FBGE2qvt.js";import{C as F,D as H,c as N,g as P,l as U,s as v}from"./carrier-D58g-gw4.js";function L(a,o){
|
|
3
3
|
const r=a.docxSource;if(!r)return s("no-capture");if(!o)return s("no-carrier");if(!r.sourceHash)return s("unpaired-capture");if(o.hash!==r.sourceHash)return s("carrier-hash-mismatch");const e=i(a),n=Object.
|
|
4
4
|
entries(e.domains).filter(([,t])=>!t).map(([t])=>t);return{fidelity:e.fullyExact?"exact":"grafted",regeneratedBlockIds:e.regeneratedBlockIds,changedDomains:n}}function s(a){return{fidelity:"converted",
|
|
5
5
|
regeneratedBlockIds:[],changedDomains:[],convertedReason:a}}export{F as CARRIER_MAP_KEY,S as CURRENT_GRAFT_SIGNATURE_VERSION,H as DEFAULT_CARRIER_BYTE_CAP,G as GraftProofError,i as assessGraftability,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{a as A,a_ as T,aM as V,b6 as J,b4 as K,W as P,C as U,aV as Z,r as j,Q as B,O as Y,aW as I,N as Q,R as tt,t as et,aS as rt,b7 as nt,aU as it}from"./engine-
|
|
2
|
-
r as st,s as lt}from"./ListNumbering-Qlu6AuRZ.js";import{f as O}from"./footnoteFlatten-
|
|
3
|
-
import{a as ht,l as dt,b as pt,c as z}from"./MathRenderer-Bz9WEVvF.js";import{b as H,a as q,e as mt,g as ut,c as gt,l as ft,h as bt}from"./BidiText-Bkp4Y90s.js";import{c as yt,F as N,g as R,d as xt,L as E}from"./Typography-
|
|
1
|
+
import{a as A,a_ as T,aM as V,b6 as J,b4 as K,W as P,C as U,aV as Z,r as j,Q as B,O as Y,aW as I,N as Q,R as tt,t as et,aS as rt,b7 as nt,aU as it}from"./engine-C5fxuZJo.js";import{i as at,p as D,e as ot,
|
|
2
|
+
r as st,s as lt}from"./ListNumbering-Qlu6AuRZ.js";import{f as O}from"./footnoteFlatten-coCVFd3c.js";import{i as ct}from"./HorizontalRuleOrnaments-gmUZ3R7Q.js";import{b as F}from"./TableGrid-DbroRucl.js";
|
|
3
|
+
import{a as ht,l as dt,b as pt,c as z}from"./MathRenderer-Bz9WEVvF.js";import{b as H,a as q,e as mt,g as ut,c as gt,l as ft,h as bt}from"./BidiText-Bkp4Y90s.js";import{c as yt,F as N,g as R,d as xt,L as E}from"./Typography-XR6scRNV.js";
|
|
4
4
|
const $t=[[/[\p{Script=Hiragana}\p{Script=Katakana}]/u,"ja"],[/\p{Script=Hangul}/u,"ko"],[/\p{Script=Han}/u,"und-Hani"],[/\p{Script=Arabic}/u,"und-Arab"],[/\p{Script=Hebrew}/u,"und-Hebr"],[/\p{Script=Devanagari}/u,
|
|
5
5
|
"und-Deva"],[/\p{Script=Bengali}/u,"und-Beng"],[/\p{Script=Gurmukhi}/u,"pa"],[/\p{Script=Gujarati}/u,"gu"],[/\p{Script=Oriya}/u,"or"],[/\p{Script=Tamil}/u,"ta"],[/\p{Script=Telugu}/u,"te"],[/\p{Script=Kannada}/u,
|
|
6
6
|
"kn"],[/\p{Script=Malayalam}/u,"ml"],[/\p{Script=Sinhala}/u,"si"],[/\p{Script=Thai}/u,"th"],[/\p{Script=Lao}/u,"lo"],[/\p{Script=Khmer}/u,"km"],[/\p{Script=Myanmar}/u,"my"],[/\p{Script=Tibetan}/u,"bo"],
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import{a_ as k,b0 as y,aR as b,aK as $,b1 as w,b2 as M,b3 as T,b4 as I,a as u,b5 as _}from"./engine-C5fxuZJo.js";import{b as v}from"./TableGrid-DbroRucl.js";import{a as j,s as C,e as L,o as N,i as R}from"./ListNumbering-Qlu6AuRZ.js";
|
|
2
|
+
class A{static toMarkdown(t){if(!t||t.type!=="doc"||!t.children)return"";this.exportListNumbering=j(t);const e=[];for(const n of t.children){if(n.type==="header-footer"||n.type==="footnote")continue;if(n.
|
|
3
|
+
type==="toc"){const a=this.tocToMarkdown(n,t);a!==null&&e.push(a);continue}const s=this.blockToMarkdown(n);s!==null&&e.push(s)}const i=[...t.notes??[],...t.children.filter(n=>n.type==="footnote")];if(i.
|
|
4
|
+
length>0){const n=new Map,s=c=>{if(!c||typeof c!="object")return;if(Array.isArray(c)){c.forEach(s);return}const o=c;o.type!=="footnote"&&(o.marks?.footnoteRef&&!n.has(o.marks.footnoteRef)&&n.set(o.marks.
|
|
5
|
+
footnoteRef,o.text??""),s(o.children))};s(t.children.filter(c=>c.type!=="footnote"));let a=n.size;for(const c of i){const o=n.get(c.id)||String(a+=1),r=[];c.children.forEach((d,l)=>{const h=this.blockToMarkdown(
|
|
6
|
+
d)??"";l===0?r.push(`[^${o}]: ${h}`):r.push(h.split(`
|
|
7
|
+
`).map(p=>` ${p}`).join(`
|
|
8
|
+
`))}),e.push(r.join(`
|
|
9
|
+
|
|
10
|
+
`))}}return e.join(`
|
|
11
|
+
|
|
12
|
+
`)}static fromInlineMarkdown(t){return k(this.parseInlineContent(t))}static tocToMarkdown(t,e){const i=y(e,b(t));return i.length===0?null:i.map(n=>`${" ".repeat(n.level-1)}${n.text}`).join(`
|
|
13
|
+
`)}static blockToMarkdown(t){switch(t.type){case"paragraph":return $(t)?"---":this.paragraphToMarkdown(t);case"list":return this.listToMarkdown(t);case"table":return this.tableToMarkdown(t);case"image":
|
|
14
|
+
return this.imageToMarkdown(t);case"code":return this.codeBlockToMarkdown(t);case"math":return this.mathBlockToMarkdown(t);case"placeholder":return null;default:return null}}static paragraphToMarkdown(t){
|
|
15
|
+
const e=this.inlineNodesToMarkdown(t.children);return t.heading?`${"#".repeat(t.heading)} ${e}`:e}static inlineNodesToMarkdown(t){return this.coalesceMarkdownRuns(t).map(e=>this.textNodeToMarkdown(e)).
|
|
16
|
+
join("")}static markdownMarksKey(t){const e=t.marks||{};return JSON.stringify([!!e.code,!!e.latex,!!e.bold,!!e.italic,!!e.strikethrough,e.link||null])}static coalesceMarkdownRuns(t){const e=[];let i=null;
|
|
17
|
+
for(const n of t){const s=n.type==="text"&&!n.marks?.footnoteRef?this.markdownMarksKey(n):null,a=e[e.length-1];s!==null&&s===i&&a?e[e.length-1]={...a,text:a.text+n.text}:e.push(n),i=s}return e}static textNodeToMarkdown(t){
|
|
18
|
+
if(t.marks?.footnoteRef)return`[^${t.text}]`;let e=t.text;return e=e.replace(/\\/g,"\\\\"),t.marks&&(t.marks.code?e=`\`${e.replace(/`/g,"\\`")}\``:t.marks.latex?e=`$${e}$`:(t.marks.bold&&(e=`**${e}**`),
|
|
19
|
+
t.marks.italic&&(e=`*${e}*`),t.marks.strikethrough&&(e=`~~${e}~~`)),t.marks.link&&(e=`[${e}](${t.marks.link})`)),e}static listToMarkdown(t){const e=[],i=this.exportListNumbering?.get(t.id)??C(t),n=[L(
|
|
20
|
+
i)-1,0,0],s=t.variant==="ordered"&&t.children.some(a=>a.heading)?N(t,i):[];for(const[a,c]of t.children.entries()){if(c.type!=="list-item")continue;const o=Math.min(c.indentLevel??0,2),r=this.inlineNodesToMarkdown(
|
|
21
|
+
c.children);if(t.variant==="ordered"){n[o]+=1;for(let h=o+1;h<n.length;h++)n[h]=0}if(c.heading){const h=s[a]?`${s[a]} `:"";e.length&&e.push(""),e.push(`${"#".repeat(c.heading)} ${h}${r}`,"");continue}
|
|
22
|
+
const d=" ".repeat(c.indentLevel??0);let l;t.variant==="ordered"?l=`${n[o]}.`:t.variant==="todo"?l=c.checked?"- [x]":"- [ ]":l="-",e.push(`${d}${l} ${r}`)}for(;e[e.length-1]==="";)e.pop();return e.join(
|
|
23
|
+
`
|
|
24
|
+
`)}static tableToMarkdown(t){if(!t.children||t.children.length===0)return"";const e=v(t),i=[];for(let n=0;n<e.rows;n++){const s=[];for(let a=0;a<e.cols;a++){const c=e.occupancy[n][a];if(!c||c.row!==n||
|
|
25
|
+
c.col!==a){s.push("");continue}const o=c.cell.children.map(r=>r.type==="paragraph"?this.inlineNodesToMarkdown(r.children):r.type==="code"?`\`${r.content||""}\``:"").join(" ");s.push(o)}if(i.push(`| ${s.
|
|
26
|
+
join(" | ")} |`),n===0){const a=s.map(()=>"---").join(" | ");i.push(`| ${a} |`)}}return i.join(`
|
|
27
|
+
`)}static imageToMarkdown(t){return``}static codeBlockToMarkdown(t){const e=t.language||"",i=t.content||"";return`\`\`\`${e}
|
|
28
|
+
${i}
|
|
29
|
+
\`\`\``}static mathBlockToMarkdown(t){return`$$
|
|
30
|
+
${t.content||""}
|
|
31
|
+
$$`}static fromMarkdown(t){const e=t.split(`
|
|
32
|
+
`),i=[];let n=0;for(;n<e.length;){const s=e[n];if(s.trim()===""){n++;continue}if(s.trim().startsWith("```")){const l=this.parseCodeBlock(e,n);i.push(l.block),n=l.nextIndex;continue}if(s.trim().startsWith(
|
|
33
|
+
"$$")){const l=this.parseMathBlock(e,n);i.push(l.block),n=l.nextIndex;continue}if(s.trim().startsWith("|")&&s.trim().endsWith("|")){const l=this.parseTable(e,n);l.block&&i.push(l.block),n=l.nextIndex;
|
|
34
|
+
continue}const a=s.match(/^\[\^([^\]]+)\]:\s?(.*)$/);if(a){const l=a[1],h=[k(this.parseInlineContent(a[2]??""))];for(n++;n<e.length;){const p=e[n];if(p.trim()===""){const f=e[n+1];if(f!==void 0&&/^ {4}/.
|
|
35
|
+
test(f)){n++;continue}break}if(!/^ {4}/.test(p))break;h.push(k(this.parseInlineContent(p.slice(4)))),n++}w(h),i.push({type:"footnote",id:`mdfn-${l}`,children:h,...M(l)==="endnote"?{noteKind:"endnote"}:
|
|
36
|
+
{}});continue}const c=T(s,"markdown");if(c){i.push(I(_[c])),n++;continue}if(this.isListItem(s)){const l=this.parseList(e,n);i.push(l.block),n=l.nextIndex;continue}const o=s.trim().match(/^!\[([^\]]*)\]\(([^)]+)\)$/);
|
|
37
|
+
if(o){i.push({type:"image",id:u(),src:o[2],alt:o[1],width:400,height:300}),n++;continue}const r=s.match(/^(#{1,6})\s+(.*)$/);if(r){const l=r[1].length,h=r[2],p=k(this.parseInlineContent(h));p.heading=
|
|
38
|
+
l,i.push(p),n++;continue}const d=k(this.parseInlineContent(s));i.push(d),n++}return R(u,i),{type:"doc",children:i.length>0?i:[k()]}}static isListItem(t){const e=t.trimStart();return!!(/^[-*+]\s/.test(
|
|
39
|
+
e)||/^\d+\.\s/.test(e)||/^[-*+]\s\[[x ]\]\s/i.test(e))}static parseList(t,e){const i=[];let n=e,s="unordered",a=1,c=!0;for(;n<t.length;){const o=t[n];if(o.trim()===""||!this.isListItem(o))break;const r=o.
|
|
40
|
+
match(/^(\s*)/),d=r?r[1].length:0,l=d===0?0:Math.max(1,Math.floor(d/2)),h=o.trimStart();let p,f;const m=h.match(/^[-*+]\s\[([x ])\]\s(.*)$/i);if(m)c&&(s="todo"),f=m[1].toLowerCase()==="x",p=m[2];else if(/^\d+\.\s/.
|
|
41
|
+
test(h)){const g=h.match(/^(\d+)\.\s(.*)$/);g?(c&&(s="ordered",a=parseInt(g[1],10)),p=g[2]):p=h}else{const g=h.match(/^[-*+]\s(.*)$/);p=g?g[1]:h}const x={type:"list-item",id:u(),children:this.parseInlineContent(
|
|
42
|
+
p),indentLevel:l};f!==void 0&&(x.checked=f),i.push(x),c=!1,n++}return{block:{type:"list",id:u(),variant:s,children:i,startNumber:s==="ordered"?a:void 0},nextIndex:n}}static parseCodeBlock(t,e){const i=t[e].
|
|
43
|
+
trim().slice(3).trim(),n=[];let s=e+1;for(;s<t.length;){const a=t[s];if(a.trim()==="```"){s++;break}n.push(a),s++}return{block:{type:"code",id:u(),content:n.join(`
|
|
44
|
+
`),language:i||void 0},nextIndex:s}}static parseMathBlock(t,e){const i=[];let n=e+1;for(;n<t.length;){const a=t[n];if(a.trim()==="$$"){n++;break}i.push(a),n++}const s=i.join(`
|
|
45
|
+
`).replace(/\\\\/g,"\\");return{block:{type:"math",id:u(),content:s},nextIndex:n}}static parseTable(t,e){const i=[];let n=e;for(;n<t.length;){const d=t[n].trim();if(!d.startsWith("|")||!d.endsWith("|"))
|
|
46
|
+
break;i.push(d),n++}if(i.length<2)return{block:null,nextIndex:n};const s=i[1];if(!/^\|[\s\-:|]+\|$/.test(s))return{block:null,nextIndex:n};const a=[],c=!0;for(let d=0;d<i.length;d++){if(d===1)continue;
|
|
47
|
+
const l=i[d].slice(1,-1).split("|").map(h=>h.trim()).map(h=>({type:"table-cell",id:u(),children:[k(this.parseInlineContent(h))]}));a.push({type:"table-row",id:u(),children:l})}const o=a[0]?.children.length||
|
|
48
|
+
1,r=Array(o).fill(100/o);return{block:{type:"table",id:u(),children:a,columnWidths:r,hasHeader:c},nextIndex:n}}static parseInlineContent(t){const e=[],i=[{regex:/\[\^([^\]]+)\]/g,type:"footnoteref"},{
|
|
49
|
+
regex:/!\[([^\]]*)\]\(([^)]+)\)/g,type:"image"},{regex:/\[([^\]]+)\]\(([^)]+)\)/g,type:"link"},{regex:/\*\*\*([^*]+)\*\*\*/g,type:"bolditalic"},{regex:/\*\*([^*]+)\*\*/g,type:"bold"},{regex:/\*([^*]+)\*/g,
|
|
50
|
+
type:"italic"},{regex:/(^|[^A-Za-z0-9_])___([^_]+)___(?![A-Za-z0-9_])/g,type:"bolditalic",underscore:!0},{regex:/(^|[^A-Za-z0-9_])__([^_]+)__(?![A-Za-z0-9_])/g,type:"bold",underscore:!0},{regex:/(^|[^A-Za-z0-9_])_([^_]+)_(?![A-Za-z0-9_])/g,
|
|
51
|
+
type:"italic",underscore:!0},{regex:/~~([^~]+)~~/g,type:"strikethrough"},{regex:/`([^`]+)`/g,type:"code"},{regex:/\$([^$]+)\$/g,type:"latex"}],n=[];for(const o of i){o.regex.lastIndex=0;let r;for(;(r=
|
|
52
|
+
o.regex.exec(t))!==null;)if(o.type==="link")n.push({index:r.index,length:r[0].length,type:o.type,content:r[1],url:r[2]});else if(o.type==="image")n.push({index:r.index,length:r[0].length,type:o.type,content:r[1]||
|
|
53
|
+
"[image]",url:r[2]});else if(o.type==="bolditalic"||o.type==="bold"||o.type==="italic")if("underscore"in o&&o.underscore){const d=r[1];n.push({index:r.index+d.length,length:r[0].length-d.length,type:o.
|
|
54
|
+
type,content:r[2]})}else n.push({index:r.index,length:r[0].length,type:o.type,content:r[1]});else n.push({index:r.index,length:r[0].length,type:o.type,content:r[1]})}n.sort((o,r)=>o.index-r.index);const s=[];
|
|
55
|
+
let a=0;for(const o of n)o.index>=a&&(s.push(o),a=o.index+o.length);let c=0;for(const o of s){if(o.index>c){const d=t.slice(c,o.index);d&&e.push({type:"text",text:d,marks:{}})}const r={type:"text",text:o.
|
|
56
|
+
content,marks:{}};switch(o.type){case"bold":r.marks={bold:!0};break;case"italic":r.marks={italic:!0};break;case"bolditalic":r.marks={bold:!0,italic:!0};break;case"strikethrough":r.marks={strikethrough:!0};
|
|
57
|
+
break;case"code":r.marks={code:!0};break;case"latex":r.text=o.content.replace(/\\\\/g,"\\"),r.marks={latex:!0};break;case"link":r.marks={link:o.url};break;case"image":r.text=o.content||"[image]",r.marks=
|
|
58
|
+
{link:o.url};break;case"footnoteref":r.text=o.content,r.marks={footnoteRef:`mdfn-${o.content}`,superscript:!0};break}e.push(r),c=o.index+o.length}if(c<t.length){const o=t.slice(c);o&&e.push({type:"tex\
|
|
59
|
+
t",text:o,marks:{}})}return e.length===0&&e.push({type:"text",text:t,marks:{}}),e}}export{A as MarkdownConverter};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a_ as P,a as S}from"./engine-
|
|
1
|
+
import{a_ as P,a as S}from"./engine-C5fxuZJo.js";import{N as _,k as Z,m as E,a as C,l as q,f as U,h as J,g as G,i as O,c as K,j as k,d as Q,p as Y,b as tt,n as W,M as et,s as nt}from"./OfficeImportShared-B2XJgnDO.js";
|
|
2
2
|
class st{static async parseFile(e){const t=(await import("./jszip.min-CPW0h1Kx.js").then(d=>d.j)).default,n=await e.arrayBuffer(),s=await t.loadAsync(new Uint8Array(n)),a=s.file("content.xml");if(!a)throw new Error(
|
|
3
3
|
"Invalid ODT file: missing content.xml");const o=await a.async("text"),l=await s.file("styles.xml")?.async("text"),c=new Set;for(const d of[o,l??""])for(const u of d.matchAll(/xlink:href="([^"]+)"/g))
|
|
4
4
|
c.add(R(ct(u[1])));const h=new Map;return await Promise.all([...c].map(async d=>{const u=s.file(d);u&&!u.dir&&h.set(d,await u.async("uint8array"))})),this.fromContentXml(o,l,{parts:h})}static fromContentXml(e,t,n={}){
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{a_ as l,b1 as M,ae as P,aN as m,
|
|
2
|
-
["http","https","mailto","tel","ftp"]);function
|
|
3
|
-
exec(e)?.[1];if(!(r&&!k.has(r.toLowerCase())))return t}function
|
|
1
|
+
import{a_ as l,b1 as M,ae as P,aN as m,bk as g,a as f,aH as y}from"./engine-C5fxuZJo.js";import{R as v}from"./suggestionAuthorship-B-IuLQlE.js";import{b as S}from"./TableGrid-DbroRucl.js";const k=new Set(
|
|
2
|
+
["http","https","mailto","tel","ftp"]);function $(n){const t=n?.trim();if(!t)return;const e=t.replace(/[\u0000- \u007f]/g,"");if(e.startsWith("//")||e.startsWith("\\\\"))return;const r=/^([a-z][a-z0-9+.-]*):/i.
|
|
3
|
+
exec(e)?.[1];if(!(r&&!k.has(r.toLowerCase())))return t}function j(n){return n/15}function d(n){return Math.round(n*100)/100}function A(n){if(!n)return;const t=/^\s*(-?\d*\.?\d+)\s*(pt|px|cm|mm|in|pc|em)\s*$/i.
|
|
4
4
|
exec(n);if(!t)return;const e=parseFloat(t[1]);if(Number.isFinite(e))switch(t[2].toLowerCase()){case"px":return e;case"pt":return e*96/72;case"pc":return e*16;case"in":return e*96;case"cm":return e*96/
|
|
5
5
|
2.54;case"mm":return e*96/25.4;case"em":return e*16;default:return}}function L(n){if(n>0)return m(n,{indentStepPx:g,storedAsUnits:!1})}function N(n){if(n<0)return-1;if(n>0)return m(n,{indentStepPx:g,storedAsUnits:!1,
|
|
6
6
|
firstLine:!0})}function z(n){const t={};if(n.widthPx&&n.heightPx){const s=y(n.widthPx,n.heightPx);s&&F(s.pageSize,n)&&(t.pageSize=s.pageSize,t.orientation=n.landscape?"landscape":s.orientation)}const e=s=>s!==
|
|
@@ -27,4 +27,4 @@ superscript:s,subscript:o,...u}=r;return{type:"text",text:P(this.counters[t],t),
|
|
|
27
27
|
{},...e?{suggestionAuthorName:e}:{}}}function _(n,t){const e=new Set,r=i=>{if(!i||typeof i!="object")return;if(Array.isArray(i)){i.forEach(r);return}const a=i;a.marks?.comment&&a.marks.comment.split("\
|
|
28
28
|
,").forEach(c=>e.add(c)),r(a.children)};return t.forEach(r),n.filter(i=>e.has(i.id)||i.anchorBlockId!==void 0||i.parentId!==void 0&&e.has(i.parentId))}function q(n){const t=[];for(const e of n){const r=t[t.
|
|
29
29
|
length-1];r&&w(r.marks,e.marks)?r.text+=e.text:t.push({...e,...e.marks?{marks:{...e.marks}}:{}})}return t}function w(n,t){const e=n??{},r=t??{},i=new Set([...Object.keys(e),...Object.keys(r)]);for(const a of i)
|
|
30
|
-
if(e[a]!==r[a])return!1;return!0}export{x as M,U as N,d as a
|
|
30
|
+
if(e[a]!==r[a])return!1;return!0}export{x as M,U as N,d as a,$ as b,T as c,B as d,b as e,N as f,H as g,p as h,K as i,A as j,_ as k,L as l,q as m,I as n,z as p,W as r,w as s,j as t};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
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-
|
|
4
|
-
c as Ae,r as We,o as He,b as Ge,q as ze}from"./TableBorders-
|
|
5
|
-
import{c as qe,p as Et,K as ee,e as Je}from"./DocumentLayoutEngine-
|
|
1
|
+
import{bl as ne,bm as Pt,bn as Ht,bo as Nt,r as Gt,bp as Rt,R as zt,e as Ut,t as re,bq as se,br as le,bs as ce,bt as he,ae as Kt,bu as tt,af as jt,b0 as ge,aR as de,bv as Yt,bw as fe,bx as vt,by as It,
|
|
2
|
+
bz as dt,bA as me,bB as Pe,bC as pe,p as ue,a_ as Ft,h as Te,a8 as xe,ab as ye,a4 as Bt}from"./engine-C5fxuZJo.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-Cezk1s_y.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-ARyTi49V.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-BhcWXkeu.js";import{a as Ze}from"./chromeImageLayout-DeYYS8YP.js";import{l as Dt}from"./UnicodeUtils-CXtusU4g.js";import{createStandardLayout as Qe}from"./DocumentLayout-CsU5MR-3.js";
|
|
6
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-
|
|
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-XR6scRNV.js";import{b as oe}from"./base64-Di1bxoXD.js";const kt=new Map;ra(()=>kt.clear());function fa(it){const t=String.
|
|
8
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
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
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:{
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import{a_ as
|
|
2
|
-
import{f as
|
|
3
|
-
|
|
4
|
-
"windows-1252"}function C(a){const t=String(a);return
|
|
5
|
-
|
|
6
|
-
this.kind=t,this.items=[],this.runs=[],this.runText="",this.runMarks={},this.paraId=w(),this.suppressEmptyPar=!1}}const
|
|
7
|
-
["ldblquote","“"],["rdblquote","”"],["bullet","•"],["emspace"," "],["enspace"," "],["qmspace"," "],["zwj",""],["zwnj",""],["ltrmark",""],["rtlmark",""]]),
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"ftnsep","ftnsepc","ftncn","blipuid","picprop","atnicn","atntime","do","falt","panose","fname","oldcprops","oldpprops","oldtprops","oldsprops","annotation-ignore"]),
|
|
11
|
-
|
|
12
|
-
"fldrslt","header","headerl","headerr","headerf","footer","footerl","footerr","footerf"]),
|
|
13
|
-
|
|
14
|
-
"footerl","even"],["footerf","first"]]);function
|
|
15
|
-
{r:0,g:0,b:0},this.colorHasValue=!1,this.expandedIndex=0,this.expandedParts=[],this.styles=new Map,this.currentStyle=null,this.lists=new Map,this.currentList=null,this.listOverrides=
|
|
16
|
-
null,this.revAuthors=[],this.currentFontEntry=null,this.rowDefs=[],this.pendingCellDef={},this.rowIsHeader=!1,this.body=new L("body"),this.notes=new
|
|
17
|
-
[],this.openCommentRanges=[],this.commentMeta={},this.annotationCounter=0,this.commentRangeIds=new Map,this.commentIds=new Set,this.page={margins:{}},this.sectionSeen
|
|
18
|
-
0,this.cachedMarksVersion=-1,this.cachedMarks={},this.pendingBytes=[],this.pendingBytesEncoding="",this.chainsSeen=new Set,this.ansiEncoding=
|
|
19
|
-
512)),this.state={dest:"body",chars:{},para:{borders:{}},unicodeSkip:1,storyRef:{story:this.body}}}read(){this.tokenize(),this.flushBytes();const t=this.body;this.flushRun(
|
|
20
|
-
length>0)&&this.flushParagraph(t);const e=this.buildBlocks(t.items,"body");
|
|
21
|
-
this.headers).length>0&&(s.headers=this.headers),Object.keys(this.footers).length>0&&(s.footers=this.footers);const r=
|
|
22
|
-
pageLayout();return n&&(s.pageLayout=n),s}tokenize(){const t=this.rtf,e=t.length,s=/\\([a-zA-Z]{1,32})(-?\d{1,10})? ?/y;let r=0;for(;r<e;){const n=t.charCodeAt(r);if(n===
|
|
23
|
-
r++;continue}if(n===125){this.flushBytes(),this.popGroup(),r++;continue}if(n===10||n===13){r++;continue}if(n!==92){let l=r+1;for(;l<e;){const f=t.charCodeAt(l);
|
|
24
|
-
13)break;l++}this.literal(t.slice(r,l)),r=l;continue}const i=t[r+1];if(i===void 0)break;if(i==="\\"||i==="{"||i==="}"){this.flushBytes(),this.text(i),r+=2;continue}
|
|
25
|
-
r+2,r+4),16);r+=4,Number.isNaN(l)||this.byte(l);continue}if(this.flushBytes(),i==="*"){this.state.starred=!0,r+=2;continue}if(i==="~"){this.text(" "),r+=2;continue}
|
|
26
|
-
if(i==="-"){r+=2;continue}if(i===`
|
|
1
|
+
import{a_ as I,a as w,b0 as K,aR as U,aK as G}from"./engine-C5fxuZJo.js";import{d as j}from"./TextDecoding-IPbuUqcC.js";import{N as z,k as _,r as $,s as Y,a as T,t as k,i as X,m as Z,b as J,c as Q,d as tt,
|
|
2
|
+
l as et,f as st,e as rt,g as nt,p as it}from"./OfficeImportShared-B2XJgnDO.js";import{f as at}from"./footnoteFlatten-coCVFd3c.js";import{a as ot,e as lt}from"./ListNumbering-Qlu6AuRZ.js";import{b as ct}from"./TableGrid-DbroRucl.js";
|
|
3
|
+
const ht={65001:"utf-8",932:"shift_jis",936:"gb18030",949:"euc-kr",950:"big5",874:"windows-874",1e4:"macintosh",437:"windows-1252",850:"windows-1252"};function dt(a){const t=/\\ansicpg(\d+)/i.exec(a)?.[1];
|
|
4
|
+
return t?C(t):/\\mac\b/.test(a)?"macintosh":"windows-1252"}function C(a){const t=String(a);return ht[t]??`windows-${t}`}const ut={77:1e4,128:932,129:949,134:936,136:950,161:1253,162:1254,163:1258,177:1255,
|
|
5
|
+
178:1256,186:1257,204:1251,222:874,238:1250},W=new Map;function pt(a,t){let e=W.get(t);if(!e){try{j(new Uint8Array,t),e=t}catch{e="windows-1252"}W.set(t,e)}return j(a instanceof Uint8Array?a:new Uint8Array(
|
|
6
|
+
a),e)}class L{constructor(t){this.kind=t,this.items=[],this.runs=[],this.runText="",this.runMarks={},this.paraId=w(),this.suppressEmptyPar=!1}}const ft=new Map([["emdash","—"],["endash","–"],["lqu\
|
|
7
|
+
ote","‘"],["rquote","’"],["ldblquote","“"],["rdblquote","”"],["bullet","•"],["emspace"," "],["enspace"," "],["qmspace"," "],["zwj",""],["zwnj",""],["ltrmark",""],["rtlmark",""]]),
|
|
8
|
+
gt=new Set(["info","xmlnstbl","themedata","colorschememapping","latentstyles","datastore","generator","filetbl","rsidtbl","nonshppict","objdata","objclass","objname","shpinst","shptxt","userprops","do\
|
|
9
|
+
cvar","pgdsctbl","mmathPr","bkmkstart","bkmkend","xe","tc","txe","template","private","passwordhash","wgrffmtfilter","defchp","defpap","listpicture","pnseclvl","protusertbl","fchars","lchars","aftnsep",
|
|
10
|
+
"aftnsepc","aftncn","ftnsep","ftnsepc","ftncn","blipuid","picprop","atnicn","atntime","do","falt","panose","fname","oldcprops","oldpprops","oldtprops","oldsprops","annotation-ignore"]),mt=new Set(["ex\
|
|
11
|
+
pandedcolortbl","listtable","listoverridetable","shppict","fldinst","annotation","atnauthor","atnid","atnref","atndate","atrfstart","atrfend","pn","revtbl","footnote"]),bt=new Set(["pict","footnote","\
|
|
12
|
+
annotation","fldinst","fldrslt","header","headerl","headerr","headerf","footer","footerl","footerr","footerf"]),kt=new Set(["ul","uld","uldash","uldashd","uldashdd","uldb","ulhwave","ulldash","ulth","\
|
|
13
|
+
ulthd","ulthdash","ulthdashd","ulthdashdd","ulthldash","ululdbwave","ulw","ulwave"]),E=new Map([["header","default"],["headerr","default"],["headerl","even"],["headerf","first"],["footer","default"],[
|
|
14
|
+
"footerr","default"],["footerl","even"],["footerf","first"]]);function F(a,t={}){return new vt(a,t).read()}class vt{constructor(t,e){this.rtf=t,this.options=e,this.defaultFont=0,this.fonts=new Map,this.
|
|
15
|
+
colors=[],this.colorParts={r:0,g:0,b:0},this.colorHasValue=!1,this.expandedIndex=0,this.expandedParts=[],this.styles=new Map,this.currentStyle=null,this.lists=new Map,this.currentList=null,this.listOverrides=
|
|
16
|
+
new Map,this.currentOverride=null,this.revAuthors=[],this.currentFontEntry=null,this.rowDefs=[],this.pendingCellDef={},this.rowIsHeader=!1,this.body=new L("body"),this.notes=new z("rtffn"),this.headers=
|
|
17
|
+
{},this.footers={},this.comments=[],this.openCommentRanges=[],this.commentMeta={},this.annotationCounter=0,this.commentRangeIds=new Map,this.commentIds=new Set,this.page={margins:{}},this.sectionSeen=
|
|
18
|
+
!1,this.stack=[],this.marksVersion=0,this.cachedMarksVersion=-1,this.cachedMarks={},this.pendingBytes=[],this.pendingBytesEncoding="",this.chainsSeen=new Set,this.ansiEncoding=dt(t.slice(0,4096)),this.
|
|
19
|
+
cocoa=/\\cocoartf/.test(t.slice(0,512)),this.state={dest:"body",chars:{},para:{borders:{}},unicodeSkip:1,storyRef:{story:this.body}}}read(){this.tokenize(),this.flushBytes();const t=this.body;this.flushRun(
|
|
20
|
+
t),t.runs.some(i=>i.text.trim().length>0)&&this.flushParagraph(t);const e=this.buildBlocks(t.items,"body");V(e),e.length===0&&e.push(I());const s={type:"doc",children:e};this.notes.notes.length>0&&(s.
|
|
21
|
+
notes=this.notes.notes),Object.keys(this.headers).length>0&&(s.headers=this.headers),Object.keys(this.footers).length>0&&(s.footers=this.footers);const r=_(this.comments,[s.children,s.notes??[]]);r.length>
|
|
22
|
+
0&&(s.comments=r);const n=this.pageLayout();return n&&(s.pageLayout=n),s}tokenize(){const t=this.rtf,e=t.length,s=/\\([a-zA-Z]{1,32})(-?\d{1,10})? ?/y;let r=0;for(;r<e;){const n=t.charCodeAt(r);if(n===
|
|
23
|
+
123){this.flushBytes(),this.pushGroup(),r++;continue}if(n===125){this.flushBytes(),this.popGroup(),r++;continue}if(n===10||n===13){r++;continue}if(n!==92){let l=r+1;for(;l<e;){const f=t.charCodeAt(l);
|
|
24
|
+
if(f===92||f===123||f===125||f===10||f===13)break;l++}this.literal(t.slice(r,l)),r=l;continue}const i=t[r+1];if(i===void 0)break;if(i==="\\"||i==="{"||i==="}"){this.flushBytes(),this.text(i),r+=2;continue}
|
|
25
|
+
if(i==="'"){const l=parseInt(t.slice(r+2,r+4),16);r+=4,Number.isNaN(l)||this.byte(l);continue}if(this.flushBytes(),i==="*"){this.state.starred=!0,r+=2;continue}if(i==="~"){this.text(" "),r+=2;continue}
|
|
26
|
+
if(i==="_"){this.text("‑"),r+=2;continue}if(i==="-"){r+=2;continue}if(i===`
|
|
27
27
|
`||i==="\r"){this.controlWord("par",null),r+=2;continue}s.lastIndex=r;const o=s.exec(t);if(!o){r+=2;continue}r+=o[0].length;const c=o[1],d=o[2]!==void 0?parseInt(o[2],10):null;if(c==="bin"&&d!==null&&
|
|
28
28
|
d>0){this.binary(t.slice(r,r+d)),r+=d;continue}if(c==="u"&&d!==null){this.text(String.fromCharCode(d<0?d+65536:d));let l=this.state.unicodeSkip;for(;l>0&&r<e;){const f=t[r];if(f==="\\")if(t[r+1]==="'")
|
|
29
29
|
r+=4;else{s.lastIndex=r;const m=s.exec(t);r+=m?m[0].length:2}else{if(f==="{"||f==="}")break;if(f===`
|
|
@@ -36,9 +36,9 @@ e.capture&&this.finishStyle(t.capture.text);break;case"listtext":e.dest!=="listt
|
|
|
36
36
|
capture.text.split(";").slice(0,-1))this.revAuthors.push(s.trim());break}t.opensStory&&this.finishStory(t,e)}literal(t){const e=this.state;if(this.flushBytes(),e.dest==="pict"){e.pict?.hex.push(t);return}
|
|
37
37
|
if(this.options.binary){let s=0;for(let r=0;r<t.length;r++)t.charCodeAt(r)>=128&&(r>s&&(this.flushBytes(),this.text(t.slice(s,r))),this.byte(t.charCodeAt(r)&255),s=r+1);s<t.length&&(this.flushBytes(),
|
|
38
38
|
this.text(t.slice(s)));return}this.text(t)}byte(t){const e=this.currentEncoding();this.pendingBytes.length>0&&e!==this.pendingBytesEncoding&&this.flushBytes(),this.pendingBytesEncoding=e,this.pendingBytes.
|
|
39
|
-
push(t)}flushBytes(){if(this.pendingBytes.length===0)return;const t=this.pendingBytes;this.pendingBytes=[],this.text(
|
|
39
|
+
push(t)}flushBytes(){if(this.pendingBytes.length===0)return;const t=this.pendingBytes;this.pendingBytes=[],this.text(pt(t,this.pendingBytesEncoding))}currentEncoding(){const t=this.state.chars;return this.
|
|
40
40
|
fonts.get(t.font??t.lochFont??this.defaultFont)?.encoding??this.ansiEncoding}binary(t){const e=this.state.pict;if(this.state.dest!=="pict"||!e)return;const s=new Uint8Array(t.length);for(let r=0;r<t.length;r++)
|
|
41
|
-
s[r]=t.charCodeAt(r)&255;(e.binary??(e.binary=[])).push(s)}text(t){if(!t)return;const e=this.state;switch(e.dest){case"body":{const s=e.storyRef.story,r=this.effectiveMarks();
|
|
41
|
+
s[r]=t.charCodeAt(r)&255;(e.binary??(e.binary=[])).push(s)}text(t){if(!t)return;const e=this.state;switch(e.dest){case"body":{const s=e.storyRef.story,r=this.effectiveMarks();Y(r,s.runMarks)||(this.flushRun(
|
|
42
42
|
s),s.runMarks=r),s.runText+=t,s.suppressEmptyPar=!1;return}case"fonttbl":case"stylesheet":case"listtext":case"fldinst":case"meta":e.capture&&(e.capture.text+=t),e.dest==="fonttbl"&&t.includes(";")&&this.
|
|
43
43
|
fontTableSemicolons(t);return;case"colortbl":for(const s of t)s===";"&&(this.colors.push(this.colorHasValue?$(this.colorParts.r,this.colorParts.g,this.colorParts.b):void 0),this.colorParts={r:0,g:0,b:0},
|
|
44
44
|
this.colorHasValue=!1);return;case"expandedcolortbl":for(const s of t){if(s!==";")continue;const r=this.expandedParts,n=i=>i/1e5*255;if(r.length>=3)this.colors[this.expandedIndex]=$(n(r[0]),n(r[1]),n(
|
|
@@ -50,37 +50,37 @@ name;r&&(s.fontFamily=r),e.halfPoints&&e.halfPoints>0&&(s.fontSize=T(e.halfPoint
|
|
|
50
50
|
highlight]:void 0)??(e.background?this.colors[e.background]:void 0);return i&&i!=="#ffffff"&&(s.backgroundColor=i),e.expandTwips&&(s.letterSpacing=T(k(e.expandTwips))),t.link&&(s.link=t.link),t.fieldKind&&
|
|
51
51
|
(s.field=t.fieldKind),this.openCommentRanges.length>0&&t.storyRef.story.kind!=="annotation"&&(s.comment=this.openCommentRanges.join(",")),e.deleted?Object.assign(s,this.revisionMarks("deletion",e.revAuthorDel??
|
|
52
52
|
e.revAuthor,e.revTimeDel??e.revTime)):e.revised&&Object.assign(s,this.revisionMarks("insertion",e.revAuthor,e.revTime)),this.cachedMarks=s,this.cachedMarksVersion=this.marksVersion,s}revisionMarks(t,e,s){
|
|
53
|
-
const r=e!==void 0?this.revAuthors[e]:void 0,n=s!==void 0?
|
|
53
|
+
const r=e!==void 0?this.revAuthors[e]:void 0,n=s!==void 0?q(s):void 0;return X(t,`rtfrev-${t==="insertion"?"ins":"del"}-${e??0}-${s??0}`,r&&r!=="Unknown"?r:void 0,n)}flushRun(t){t.runText&&(t.runs.push(
|
|
54
54
|
{type:"text",text:t.runText,marks:{...t.runMarks}}),t.runText="")}flushParagraph(t,e=!1){this.flushRun(t);const s=t.runs.filter(r=>r.text.length>0);if(t.runs=[],s.length===0&&t.suppressEmptyPar&&!e){t.
|
|
55
|
-
suppressEmptyPar=!1,t.listText=void 0,t.paraId=w();return}t.items.push({kind:"para",id:t.paraId,runs:
|
|
55
|
+
suppressEmptyPar=!1,t.listText=void 0,t.paraId=w();return}t.items.push({kind:"para",id:t.paraId,runs:Z(s),para:{...this.state.para,borders:{...this.state.para.borders}},...t.listText!==void 0?{listText:t.
|
|
56
56
|
listText}:{},...e?{forcedInTable:!0}:{}}),t.listText=void 0,t.suppressEmptyPar=!1,t.paraId=w()}controlWord(t,e){const s=this.state,r=s.starred;if(s.starred=!1,s.dest!=="skip"&&!this.startDestination(t)){
|
|
57
|
-
if(r&&!
|
|
57
|
+
if(r&&!mt.has(t)){s.dest="skip";return}if(gt.has(t)){s.dest="skip";return}switch(s.dest){case"fonttbl":this.fontTableWord(t,e);return;case"colortbl":this.colorTableWord(t,e);return;case"expandedcolort\
|
|
58
58
|
bl":t==="c"&&e!==null?this.expandedParts.push(e):(t==="cssrgb"||t==="csgray"||t==="csgenericrgb")&&(this.expandedParts=[]);return;case"stylesheet":this.styleSheetWord(t,e);return;case"listtable":this.
|
|
59
59
|
listTableWord(t,e);return;case"listoverridetable":this.listOverrideWord(t,e);return;case"pict":this.pictWord(t,e);return;case"pn":this.pnWord(t,e);return;case"listtext":case"fldinst":case"meta":t==="t\
|
|
60
60
|
ab"&&this.text(" ");return;case"revtbl":return}if(this.characterWord(t,e)){this.marksVersion++;return}this.paragraphWord(t,e)||this.structureWord(t,e)}}startDestination(t){const e=this.state;if(e.dest!==
|
|
61
|
-
"body"&&
|
|
61
|
+
"body"&&bt.has(t))return e.dest="skip",!0;switch(t){case"fonttbl":return e.dest="fonttbl",e.capture={text:""},!0;case"colortbl":return e.dest="colortbl",this.colors=[],!0;case"expandedcolortbl":return e.
|
|
62
62
|
dest="expandedcolortbl",this.expandedIndex=0,this.expandedParts=[],!0;case"stylesheet":return e.dest="stylesheet",!0;case"listtable":return e.dest="listtable",!0;case"listoverridetable":return e.dest=
|
|
63
63
|
"listoverridetable",!0;case"revtbl":return e.dest="revtbl",!0;case"pict":return e.dest="pict",e.pict={hex:[]},!0;case"shppict":case"shprslt":case"result":case"shp":case"object":case"field":return t===
|
|
64
64
|
"field"&&(e.field={instr:""}),!0;case"fldinst":return e.dest="fldinst",e.capture={text:""},!0;case"fldrslt":{const s=e.field?.instr??"",r=/^\s*HYPERLINK\s+(?:\\[a-z]\s+)*"([^"]+)"/i.exec(s);return r&&
|
|
65
|
-
!/^\s*HYPERLINK\s+\\l\b/i.test(s)&&(e.link=
|
|
65
|
+
!/^\s*HYPERLINK\s+\\l\b/i.test(s)&&(e.link=J(r[1])),/^\s*PAGE\b/i.test(s)&&(e.fieldKind="page"),/^\s*NUMPAGES\b/i.test(s)&&(e.fieldKind="numPages"),this.marksVersion++,!0}case"listtext":case"pntext":return e.
|
|
66
66
|
dest="listtext",e.capture={text:""},!0;case"pn":return e.dest="pn",e.para.pn={kind:"number",level:0},!0;case"footnote":return this.openStory("footnote");case"annotation":return this.openStory("annotat\
|
|
67
|
-
ion");case"atnauthor":case"atnid":case"atnref":case"atndate":case"atrfstart":case"atrfend":return e.dest="meta",e.metaKind=t,e.capture={text:""},!0;default:return
|
|
67
|
+
ion");case"atnauthor":case"atnid":case"atnref":case"atndate":case"atrfstart":case"atrfend":return e.dest="meta",e.metaKind=t,e.capture={text:""},!0;default:return E.has(t)?(e.dest="body",e.opensStory=
|
|
68
68
|
!0,e.storyRef={story:new L("header")},e.para={borders:{}},e.headerWord=t,!0):!1}}openStory(t){const e=this.state;return e.dest="body",e.opensStory=!0,e.storyRef={story:new L(t)},e.para={borders:{}},e.
|
|
69
69
|
link=void 0,t==="annotation"&&(this.annotationRef=void 0,this.annotationDate=void 0),this.marksVersion++,!0}finishStory(t,e){const s=t.storyRef.story;if(this.flushRun(s),s.runs.some(i=>i.text.length>0)){
|
|
70
|
-
const i=this.state;this.state=t,this.flushParagraph(s),this.state=i}const r=this.buildBlocks(s.items,s.kind);
|
|
70
|
+
const i=this.state;this.state=t,this.flushParagraph(s),this.state=i}const r=this.buildBlocks(s.items,s.kind);V(r);const n=e.storyRef.story;if(s.kind==="footnote"||s.kind==="endnote"){if(e.dest!=="body")
|
|
71
71
|
return;this.flushRun(n),this.state=e,this.marksVersion++;const i=this.effectiveMarks(),o=this.notes.add(s.kind,r,i);n.runs.push(o),n.runMarks={},this.marksVersion++;return}if(s.kind==="header"){const i=t.
|
|
72
|
-
headerWord??"header",o=
|
|
72
|
+
headerWord??"header",o=E.get(i)??"default",c=r.filter(d=>d.type==="paragraph");if(c.some(d=>d.children.some(l=>l.text.trim()!==""||l.marks?.field))){const d=i.startsWith("footer")?this.footers:this.headers;
|
|
73
73
|
d[o]=c}return}if(s.kind==="annotation"){const i=r.map(l=>l.type==="paragraph"?l.children.map(f=>f.text).join("").trim():"").filter(l=>l.length>0).join(`
|
|
74
74
|
|
|
75
75
|
`);this.annotationCounter++;const o=this.annotationRef;let c=`rtfcmt-${o??`point-${this.annotationCounter}`}`,d=o!==void 0&&this.commentRangeIds.has(o);if(this.commentIds.has(c)){d=!1;let l=this.annotationCounter;
|
|
76
76
|
for(;this.commentIds.has(`${c}-${l}`);)l++;c=`${c}-${l}`}this.commentIds.add(c),this.comments.push({id:c,author:this.commentMeta.author||this.commentMeta.initials||"Unknown",...this.commentMeta.initials?
|
|
77
|
-
{initials:this.commentMeta.initials}:{},createdAt:new Date(this.annotationDate!==void 0?
|
|
77
|
+
{initials:this.commentMeta.initials}:{},createdAt:new Date(this.annotationDate!==void 0?q(this.annotationDate)??0:0).toISOString(),bodyMd:i,...d?{}:{anchorBlockId:n.paraId}}),this.commentMeta={}}}finishMeta(t,e){
|
|
78
78
|
switch(t){case"atnauthor":this.commentMeta.author=e;break;case"atnid":this.commentMeta.initials=e;break;case"atnref":this.annotationRef=e;break;case"atndate":{const s=parseInt(e,10);Number.isFinite(s)&&
|
|
79
79
|
(this.annotationDate=s);break}case"atrfstart":e&&(this.commentRangeIds.set(e,`rtfcmt-${e}`),this.openCommentRanges=[...this.openCommentRanges,`rtfcmt-${e}`],this.marksVersion++);break;case"atrfend":e&&
|
|
80
80
|
(this.openCommentRanges=this.openCommentRanges.filter(s=>s!==`rtfcmt-${e}`),this.marksVersion++);break}}fontTableWord(t,e){if(t==="f"&&e!==null){const r=this.state.capture;r&&r.text.trim()&&this.currentFontEntry!==
|
|
81
81
|
null&&this.finishFontName(r.text),this.currentFontEntry=e,this.fonts.has(e)||this.fonts.set(e,{name:""}),this.state.capture={text:""};return}const s=this.currentFontEntry!==null?this.fonts.get(this.currentFontEntry):
|
|
82
|
-
void 0;if(s)if(t==="fcharset"&&e!==null){const r=
|
|
83
|
-
null)return;const e=this.fonts.get(this.currentFontEntry),s=t.replace(/;$/,"").trim();e&&s&&!e.name&&(e.name=this.cocoa?
|
|
82
|
+
void 0;if(s)if(t==="fcharset"&&e!==null){const r=ut[e];r&&(s.encoding=C(r)),e===2&&(s.encoding="windows-1252")}else t==="cpg"&&e!==null&&e>0&&(s.encoding=C(e))}finishFontName(t){if(this.currentFontEntry===
|
|
83
|
+
null)return;const e=this.fonts.get(this.currentFontEntry),s=t.replace(/;$/,"").trim();e&&s&&!e.name&&(e.name=this.cocoa?Rt(s):s)}colorTableWord(t,e){if(e!==null){if(t==="red")this.colorParts.r=e;else if(t===
|
|
84
84
|
"green")this.colorParts.g=e;else if(t==="blue")this.colorParts.b=e;else return;this.colorHasValue=!0}}styleSheetWord(t,e){const s=this.state;t==="s"&&e!==null?(this.currentStyle={index:e},s.capture={text:""}):
|
|
85
85
|
t==="outlinelevel"&&e!==null&&this.currentStyle&&(this.currentStyle.outlineLevel=e)}finishStyle(t){if(!this.currentStyle)return;const e=t.replace(/;[\s\S]*$/,"").trim();this.styles.set(this.currentStyle.
|
|
86
86
|
index,{name:e,outlineLevel:this.currentStyle.outlineLevel}),this.currentStyle=null}listTableWord(t,e){switch(t){case"list":this.currentList={def:{levels:[]}};break;case"listlevel":this.currentList?.def.
|
|
@@ -92,10 +92,10 @@ t==="pnlvl"&&e!==null&&(s.level=Math.max(0,e-1));const r=this.stack[this.stack.l
|
|
|
92
92
|
jpegblip":s.format="jpeg";break;case"emfblip":s.format="emf";break;case"wmetafile":s.format="wmf";break;case"macpict":case"dibitmap":case"wbitmap":case"pmmetafile":s.format??(s.format="unsupported");break;case"\
|
|
93
93
|
picw":e!==null&&(s.picw=e);break;case"pich":e!==null&&(s.pich=e);break;case"picwgoal":e!==null&&(s.goalW=e);break;case"pichgoal":e!==null&&(s.goalH=e);break;case"picscalex":e!==null&&(s.scaleX=e);break;case"\
|
|
94
94
|
picscaley":e!==null&&(s.scaleY=e);break}}finishPicture(t,e){let s;if(t.binary&&t.binary.length>0){const b=t.binary.reduce((u,p)=>u+p.length,0);s=new Uint8Array(b);let h=0;for(const u of t.binary)s.set(
|
|
95
|
-
u,h),h+=u.length}else s=
|
|
95
|
+
u,h),h+=u.length}else s=yt(t.hex.join(""));if(s.length===0)return;const r=t.format&&t.format!=="unsupported"?t.format:void 0,n=Q(s)??r;if(!n)return;const i=n==="emf"||n==="wmf",o=(t.scaleX??100)/100,c=(t.
|
|
96
96
|
scaleY??100)/100,d=(b,h)=>b?k(b):h?i?h/2540*96:h:void 0,l=d(t.goalW,t.picw),f=d(t.goalH,t.pich),m=e.storyRef.story,M=e.para;if(this.flushRun(m),m.runs.some(b=>b.text.length>0)){const b=this.state;this.
|
|
97
|
-
state=e,this.flushParagraph(m),this.state=b}else m.runs=[];const
|
|
98
|
-
{align:
|
|
97
|
+
state=e,this.flushParagraph(m),this.state=b}else m.runs=[];const A=M.align==="justify"?void 0:M.align;m.items.push({kind:"image",image:tt(s,n,{width:l!==void 0?l*o:void 0,height:f!==void 0?f*c:void 0},
|
|
98
|
+
{align:A}),inTable:!!M.inTable}),m.suppressEmptyPar=!0}characterWord(t,e){const s=this.state.chars,r=e!==0;if(kt.has(t))return s.underline=r,!0;switch(t){case"plain":{const{revised:n,deleted:i,revAuthor:o,
|
|
99
99
|
revTime:c,revAuthorDel:d,revTimeDel:l}=s;return this.state.chars={revised:n,deleted:i,revAuthor:o,revTime:c,revAuthorDel:d,revTimeDel:l},!0}case"b":return s.bold=r,!0;case"i":return s.italic=r,!0;case"\
|
|
100
100
|
ulnone":return s.underline=!1,!0;case"strike":return s.strike=r,!0;case"striked":return s.dstrike=r,!0;case"super":return s.superscript=r,s.subscript=!1,!0;case"sub":return s.subscript=r,s.superscript=
|
|
101
101
|
!1,!0;case"nosupersub":return s.superscript=!1,s.subscript=!1,!0;case"caps":return s.caps=r,!0;case"scaps":return s.scaps=r,!0;case"v":return s.hidden=r,!0;case"f":return e!==null&&(s.font=e),!0;case"\
|
|
@@ -125,20 +125,20 @@ pendingCellDef.valign="top";return;case"clvertalc":this.pendingCellDef.valign="m
|
|
|
125
125
|
fieldKind=void 0,this.marksVersion++);return;case"ftnalt":s.kind==="footnote"&&(s.kind="endnote");return;case"uc":this.state.unicodeSkip=e??1;return;case"deff":e!==null&&(this.defaultFont=e);return;case"\
|
|
126
126
|
paperw":case"pgwsxn":e!==null&&(!this.sectionSeen||this.page.widthTwips===void 0)&&(this.page.widthTwips=e);return;case"paperh":case"pghsxn":e!==null&&(!this.sectionSeen||this.page.heightTwips===void 0)&&
|
|
127
127
|
(this.page.heightTwips=e);return;case"landscape":case"lndscpsxn":this.page.landscape=!0;return;case"margl":case"margr":case"margt":case"margb":case"marglsxn":case"margrsxn":case"margtsxn":case"margbsx\
|
|
128
|
-
n":{if(e===null)return;const n=t.slice(4,5);if(t.endsWith("sxn")&&this.sectionSeen)return;this.page.margins[n]=e;return}default:{const n=
|
|
128
|
+
n":{if(e===null)return;const n=t.slice(4,5);if(t.endsWith("sxn")&&this.sectionSeen)return;this.page.margins[n]=e;return}default:{const n=ft.get(t);n!==void 0&&this.text(n)}}}buildBlocks(t,e){const s=[],
|
|
129
129
|
r=i=>i.kind==="cell"||i.kind==="row"||i.kind==="para"&&(!!i.para.inTable||!!i.forcedInTable)||(i.kind==="image"||i.kind==="pagebreak")&&i.inTable;let n=0;for(;n<t.length;){const i=t[n];if(e!=="header"&&
|
|
130
130
|
r(i)){const o=n;for(;n<t.length&&r(t[n]);)n++;const c=this.buildTable(t.slice(o,n),e);c&&s.push(...c);continue}if(i.kind==="para"){const o=this.listInfo(i);if(o&&e!=="header"){const c=[{item:i,info:o}];
|
|
131
131
|
for(n++;n<t.length;){const d=t[n];if(d.kind!=="para"||r(d))break;const l=this.listInfo(d);if(!l||l.key!==o.key)break;c.push({item:d,info:l}),n++}s.push(this.buildList(c));continue}i.para.pageBreakBefore&&
|
|
132
132
|
e==="body"&&s.length>0&&s.push({type:"page-break",id:w()}),s.push(this.buildParagraph(i,e)),n++;continue}i.kind==="image"?s.push(i.image):i.kind==="pagebreak"&&s.push({type:"page-break",id:w()}),n++}return s}buildParagraph(t,e){
|
|
133
|
-
const s=t.runs.length>0?t.runs:[{type:"text",text:"",marks:{}}],r=
|
|
134
|
-
(r.heading=i),n.leftTwips!==void 0){const c=
|
|
133
|
+
const s=t.runs.length>0?t.runs:[{type:"text",text:"",marks:{}}],r=I(s);r.id=t.id;const n=t.para;if(n.align&&(r.align=n.align),n.rtl&&(r.direction="rtl"),e!=="header"){const i=this.headingLevel(n);if(i&&
|
|
134
|
+
(r.heading=i),n.leftTwips!==void 0){const c=et(k(n.leftTwips));c&&(r.leftIndent=c)}if(n.firstTwips!==void 0){const c=st(k(n.firstTwips));c&&(r.firstLineIndent=c)}n.spaceBeforeTwips!==void 0&&(r.spaceBefore=
|
|
135
135
|
T(k(Math.max(0,n.spaceBeforeTwips)))),n.spaceAfterTwips!==void 0&&(r.spaceAfter=T(k(Math.max(0,n.spaceAfterTwips)))),n.lineMultiple&&n.lineTwips&&n.lineTwips>0&&(r.lineSpacing=T(n.lineTwips/240)),n.keepNext&&
|
|
136
136
|
(r.keepNext=!0),n.keepLines&&(r.keepLines=!0);const o=n.shading?this.colors[n.shading]:void 0;o&&o!=="#ffffff"&&(r.shading=o),Object.keys(n.borders).length>0&&(r.borders=JSON.stringify(n.borders))}return r}headingLevel(t){
|
|
137
137
|
let e;if(t.outlineLevel!==void 0&&t.outlineLevel<9&&(e=t.outlineLevel+1),e===void 0&&t.style!==void 0){const s=this.styles.get(t.style),r=s?.name&&/^heading\s*(\d)$/i.exec(s.name);r?e=parseInt(r[1],10):
|
|
138
138
|
s?.outlineLevel!==void 0&&s.outlineLevel<9&&(e=s.outlineLevel+1)}if(!(!e||e<1))return Math.min(e,6)}listInfo(t){const e=t.para;if(!this.headingLevel(e)){if(e.ls!==void 0&&e.ls>0){const s=this.listOverrides.
|
|
139
139
|
get(e.ls),r=s!==void 0?this.lists.get(s):void 0,n=Math.max(0,Math.min(8,e.ilvl??0));if(r){const i=r.levels[n]??r.levels[0];if(i&&i.nfc===255&&t.listText===void 0)return;const o=i?i.nfc!==23&&i.nfc!==255:
|
|
140
|
-
!1;return{key:`ls${e.ls}`,ordered:o,level:n,startAt:r.levels[0]?.startAt??1,chain:`rtf-ls-${e.ls}`}}return{key:`ls${e.ls}`,ordered:t.listText!==void 0&&
|
|
141
|
-
ls}`}}if(e.pn)return{key:`pn-${e.pn.kind}`,ordered:e.pn.kind==="number",level:e.pn.level,startAt:1};if(t.listText!==void 0&&t.listText.trim()!==""){const s=
|
|
140
|
+
!1;return{key:`ls${e.ls}`,ordered:o,level:n,startAt:r.levels[0]?.startAt??1,chain:`rtf-ls-${e.ls}`}}return{key:`ls${e.ls}`,ordered:t.listText!==void 0&&O(t.listText),level:n,startAt:1,chain:`rtf-ls-${e.
|
|
141
|
+
ls}`}}if(e.pn)return{key:`pn-${e.pn.kind}`,ordered:e.pn.kind==="number",level:e.pn.level,startAt:1};if(t.listText!==void 0&&t.listText.trim()!==""){const s=O(t.listText);return{key:`lt-${s}`,ordered:s,
|
|
142
142
|
level:0,startAt:1}}}}buildList(t){const e=t[0].info,s=t.map(({item:i,info:o})=>{const c=i.runs.length>0?i.runs:[{type:"text",text:"",marks:{}}];return{type:"list-item",id:i.id,children:c,...o.level>0?
|
|
143
143
|
{indentLevel:o.level}:{},...i.para.rtl?{direction:"rtl"}:{}}}),r={type:"list",id:w(),variant:e.ordered?"ordered":"unordered",children:s};e.ordered&&e.chain?(r.numberingChainId=e.chain,this.chainsSeen.
|
|
144
144
|
has(e.chain)||(this.chainsSeen.add(e.chain),e.startAt!==1&&(r.startNumber=e.startAt))):e.ordered&&e.startAt!==1&&(r.startNumber=e.startAt);const n=t[0].item.para;return n.spaceAfterTwips!==void 0&&(r.
|
|
@@ -146,41 +146,41 @@ spaceAfter=T(k(Math.max(0,n.spaceAfterTwips)))),n.spaceBeforeTwips!==void 0&&(r.
|
|
|
146
146
|
240)),r}buildTable(t,e){const s=[];let r=[],n=[],i=[];for(const h of t)h.kind==="cell"?(r.push({items:n}),n=[]):h.kind==="row"?(n.length>0&&(r.push({items:n}),n=[]),s.push({cells:r,defs:h.defs.length>
|
|
147
147
|
0?h.defs:i,header:h.header}),h.defs.length>0&&(i=h.defs),r=[]):n.push(h);if(n.length>0&&r.push({items:n}),r.length>0&&s.push({cells:r,defs:i,header:!1}),s.length===0)return null;const o=new Set([0]),c=s.
|
|
148
148
|
map(h=>{const u=[];let p=0,g=0;const P=h.defs.length>0?h.defs[h.defs.length-1].right/Math.max(1,h.defs.length):1440;return h.cells.forEach((R,S)=>{const x=h.defs[S],v=x?x.right:g+Math.max(1,Math.round(
|
|
149
|
-
P));if(x?.hmergeCont&&u.length>0){const
|
|
150
|
-
for(const u of h)o.add(Math.max(d,u.left)),o.add(u.right);const l=xt(
|
|
149
|
+
P));if(x?.hmergeCont&&u.length>0){const D=u[u.length-1];D.right=v,D.items.push(...R.items.filter(H=>!Tt(H)))}else u.push({left:p,right:Math.max(v,p+1),def:x,items:R.items});p=v,g=v}),u}),d=0;for(const h of c)
|
|
150
|
+
for(const u of h)o.add(Math.max(d,u.left)),o.add(u.right);const l=wt(xt([...o].sort((h,u)=>h-u),30),rt(c.length)),f=h=>{let u=0,p=l.length-1;for(;u<p;){const g=u+p>>1;l[g]<h?u=g+1:p=g}return u>0&&Math.
|
|
151
151
|
abs(l[u-1]-h)<=Math.abs(l[u]-h)?u-1:u},m=[],M=new Map;c.forEach(h=>{const u=[];for(const p of h){const g=f(p.left),P=Math.max(g+1,f(p.right));if(p.def?.vmergeCont){const v=M.get(g);if(v){v.rowSpan=(v.
|
|
152
|
-
rowSpan??1)+1;continue}}const R=this.buildBlocks(p.items.map(v=>
|
|
152
|
+
rowSpan??1)+1;continue}}const R=this.buildBlocks(p.items.map(v=>Mt(v)),e);St(R);const S={type:"table-cell",id:w(),children:R.length>0?R:[I()]};P-g>1&&(S.colSpan=P-g);const x=p.def?.background?this.colors[p.
|
|
153
153
|
def.background]:void 0;x&&x!=="#ffffff"&&(S.backgroundColor=x),p.def?.valign&&p.def.valign!=="top"&&(S.verticalAlign=p.def.valign),p.def?.vmergeFirst?M.set(g,S):M.delete(g),u.push(S)}m.push({type:"tab\
|
|
154
|
-
le-row",id:w(),children:u})});const
|
|
155
|
-
void 0?k(t.margins[s]):void 0;return
|
|
156
|
-
"b"),marginLeftPx:e("l")})}}function
|
|
157
|
-
e=new Uint8Array(t.length>>1);for(let s=0;s<e.length;s++)e[s]=parseInt(t.slice(s*2,s*2+2),16);return e}function
|
|
158
|
-
function
|
|
159
|
-
function
|
|
160
|
-
a.children.every(t=>t.text.trim()===""&&!t.marks?.footnoteRef)}function
|
|
161
|
-
1]);)a.pop()}function
|
|
154
|
+
le-row",id:w(),children:u})});const A=[];for(let h=1;h<l.length;h++)A.push(l[h]-l[h-1]);const b=nt(m,{columnWidths:A,hasHeader:s[0]?.header});return b?[b]:null}pageLayout(){const t=this.page,e=s=>t.margins[s]!==
|
|
155
|
+
void 0?k(t.margins[s]):void 0;return it({widthPx:t.widthTwips?k(t.widthTwips):void 0,heightPx:t.heightTwips?k(t.heightTwips):void 0,landscape:t.landscape,marginTopPx:e("t"),marginRightPx:e("r"),marginBottomPx:e(
|
|
156
|
+
"b"),marginLeftPx:e("l")})}}function O(a){const t=a.replace(/[\t\s]+/g,"");return/^(\d+|[a-zA-Z]|[ivxlcdm]+|[IVXLCDM]+)[.)]?$/.test(t)&&t.length>0}function yt(a){const t=a.replace(/[^0-9a-fA-F]/g,""),
|
|
157
|
+
e=new Uint8Array(t.length>>1);for(let s=0;s<e.length;s++)e[s]=parseInt(t.slice(s*2,s*2+2),16);return e}function xt(a,t){const e=[];for(const s of a)(e.length===0||s-e[e.length-1]>t)&&e.push(s);return e}
|
|
158
|
+
function wt(a,t){if(a.length-1<=t)return a;const e=a.length-1,s=[];for(let r=0;r<=t;r++)s.push(a[Math.round(r*e/t)]);return s}function Tt(a){return a.kind==="para"&&a.runs.every(t=>t.text.trim()==="")}
|
|
159
|
+
function Mt(a){return a.kind==="para"?{...a,forcedInTable:!1,para:{...a.para,inTable:!1}}:a.kind==="image"||a.kind==="pagebreak"?{...a,inTable:!1}:a}function B(a){return a.type==="paragraph"&&!a.borders&&
|
|
160
|
+
a.children.every(t=>t.text.trim()===""&&!t.marks?.footnoteRef)}function V(a){for(;a.length>0&&B(a[0]);)a.shift();for(;a.length>0&&B(a[a.length-1]);)a.pop()}function St(a){for(;a.length>1&&B(a[a.length-
|
|
161
|
+
1]);)a.pop()}function q(a){const t=a>>>0;if(t===0)return;const e=t&63,s=t>>>6&31,r=t>>>11&31,n=t>>>16&15,i=(t>>>20&511)+1900;if(!(n<1||n>12||r<1))return Date.UTC(i,n-1,r,s,e)}function Rt(a){if(a.startsWith(
|
|
162
162
|
"."))return"";if(/\s/.test(a))return a;let t=a.replace(/-(Regular|Roman|Book|Bold|Italic|Oblique|BoldItalic|BoldOblique|Light|LightItalic|Medium|MediumItalic|Semibold|SemiBold|SemiboldItalic|Heavy|Black|Condensed|Thin|UltraLight)$/,
|
|
163
|
-
"");return t=t.replace(/(PSMT|PS|MT)$/,""),t=t.replace(/([a-z])([A-Z])/g,"$1 $2"),t}const
|
|
164
|
-
e.length;n+=r)s+=String.fromCharCode.apply(null,Array.from(e.subarray(n,n+r)));return
|
|
163
|
+
"");return t=t.replace(/(PSMT|PS|MT)$/,""),t=t.replace(/([a-z])([A-Z])/g,"$1 $2"),t}const N=class{static async parseFile(t){const e=new Uint8Array(await t.arrayBuffer());let s="";const r=32768;for(let n=0;n<
|
|
164
|
+
e.length;n+=r)s+=String.fromCharCode.apply(null,Array.from(e.subarray(n,n+r)));return F(s,{binary:!0})}static fromRtf(t){return F(t)}static toRtf(t){t=at(t),this.exportListNumbering=ot(t);const e=[];for(const s of t.
|
|
165
165
|
children){const r=this.blockToRtf(s,t);r!==null&&e.push(r)}return this.exportListNumbering=null,`{\\rtf1\\ansi\\ansicpg1252\\deff0\\uc1{\\fonttbl{\\f0\\froman Times New Roman;}{\\f1\\fmodern Courier New;}}
|
|
166
166
|
\\f0\\fs24
|
|
167
167
|
`+e.join(`
|
|
168
168
|
`)+`
|
|
169
|
-
}`}static blockToRtf(t,e){switch(t.type){case"paragraph":return
|
|
170
|
-
t);case"code":return"\\pard{\\f1\\fs20 "+y(t.content).replace(/\n/g,"\\line ")+"}\\par";case"math":return"\\pard "+y(t.content)+"\\par";case"toc":{const s=
|
|
169
|
+
}`}static blockToRtf(t,e){switch(t.type){case"paragraph":return G(t)?"\\pard\\brdrb\\brdrs\\brdrw15 \\par":this.paragraphToRtf(t);case"list":return this.listToRtf(t);case"table":return this.tableToRtf(
|
|
170
|
+
t);case"code":return"\\pard{\\f1\\fs20 "+y(t.content).replace(/\n/g,"\\line ")+"}\\par";case"math":return"\\pard "+y(t.content)+"\\par";case"toc":{const s=K(e,U(t));return s.length===0?null:s.map(r=>`\
|
|
171
171
|
\\pard${t.direction==="rtl"?"\\rtlpar":"\\ltrpar"}${t.align==="justify"?"\\qj":t.align==="center"?"\\qc":(t.align??(t.direction==="rtl"?"right":"left"))==="right"?"\\qr":"\\ql"}\\${t.direction==="rtl"?
|
|
172
172
|
"ri":"li"}${(r.level-1)*360} `+y(r.text)+"\\par").join(`
|
|
173
173
|
`)}case"image":return"\\pard{\\i [Image"+(t.alt?`: ${y(t.alt)}`:"")+"]}\\par";case"page-break":return"\\page";case"container":return t.children.map(s=>this.blockToRtf(s,e)).filter(s=>s!==null).join(`
|
|
174
174
|
`);default:return null}}static paragraphToRtf(t){let e="\\pard";t.align==="center"?e+="\\qc":t.align==="right"?e+="\\qr":t.align==="justify"&&(e+="\\qj");let s=this.inlineNodesToRtf(t.children);return t.
|
|
175
|
-
heading&&(s=`{\\b\\fs${this.HEADING_HALF_POINTS[t.heading-1]} ${s}}`),`${e} ${s}\\par`}static listToRtf(t){const e=this.exportListNumbering?.get(t.id);let s=e?
|
|
175
|
+
heading&&(s=`{\\b\\fs${this.HEADING_HALF_POINTS[t.heading-1]} ${s}}`),`${e} ${s}\\par`}static listToRtf(t){const e=this.exportListNumbering?.get(t.id);let s=e?lt(e):t.startNumber??1;const r=[];for(const n of t.
|
|
176
176
|
children){if(n.type!=="list-item")continue;const i=((n.indentLevel??0)+1)*360;let o;t.variant==="ordered"?(o=`${s}. `,s++):t.variant==="todo"?o=n.checked?"[x] ":"[ ] ":o="\\bullet ",r.push(`\\pard\\li${i}\
|
|
177
177
|
${o}`+this.inlineNodesToRtf(n.children)+"\\par")}return r.join(`
|
|
178
|
-
`)}static tableToRtf(t){if(!t.children||t.children.length===0)return"";const e=
|
|
178
|
+
`)}static tableToRtf(t){if(!t.children||t.children.length===0)return"";const e=ct(t),s=9360,r=[];for(let n=0;n<e.rows;n++){const i=["\\trowd\\trgaph108"];for(let o=0;o<e.cols;o++)i.push(`\\cellx${Math.
|
|
179
179
|
round(s*(o+1)/e.cols)}`);for(let o=0;o<e.cols;o++){const c=e.occupancy[n][o];let d="";c&&c.row===n&&c.col===o&&(d=c.cell.children.map(l=>l.type==="paragraph"?this.inlineNodesToRtf(l.children):l.type===
|
|
180
180
|
"code"?y(l.content):"").filter(l=>l.length>0).join("\\line ")),i.push(`\\pard\\intbl ${d}\\cell`)}i.push("\\row"),r.push(i.join(""))}return r.join(`
|
|
181
181
|
`)+`
|
|
182
182
|
\\pard`}static inlineNodesToRtf(t){return t.map(e=>this.textNodeToRtf(e)).join("")}static textNodeToRtf(t){if(t.marks?.footnoteRef)return`{\\super ${y(t.text)}}`;const e=y(t.text).replace(/\n/g,"\\line\
|
|
183
183
|
");if(!t.marks)return e;const s=[];t.marks.bold&&s.push("\\b"),t.marks.italic&&s.push("\\i"),t.marks.underline&&s.push("\\ul"),t.marks.strikethrough&&s.push("\\strike"),t.marks.superscript&&s.push("\\\
|
|
184
184
|
super"),t.marks.subscript&&s.push("\\sub"),t.marks.code&&s.push("\\f1");const r=s.length>0?`{${s.join("")} ${e}}`:e;return t.marks.link?`{\\field{\\*\\fldinst HYPERLINK "${y(t.marks.link)}"}{\\fldrslt ${r}\
|
|
185
|
-
}}`:r}};
|
|
186
|
-
const r=a.charCodeAt(e);if(r<128){t+=s;continue}t+=`\\u${r>32767?r-65536:r}?`}return t}export{
|
|
185
|
+
}}`:r}};N.exportListNumbering=null,N.HEADING_HALF_POINTS=[32,28,26,24,22,22];let At=N;function y(a){let t="";for(let e=0;e<a.length;e++){const s=a[e];if(s==="\\"||s==="{"||s==="}"){t+="\\"+s;continue}
|
|
186
|
+
const r=a.charCodeAt(e);if(r<128){t+=s;continue}t+=`\\u${r>32767?r-65536:r}?`}return t}export{At as RtfConverter,y as escapeRtfText};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{W as $}from"./engine-
|
|
1
|
+
import{W as $}from"./engine-C5fxuZJo.js";const b="#C0C0C0",p=.3,z=.5,P=.7;function y(t){if(typeof t!="string"||t.trim()==="")return null;let o;try{const i=JSON.parse(t);if(typeof i=="string")o={text:i};else if(i&&
|
|
2
2
|
typeof i=="object"&&typeof i.text=="string")o=i;else return null}catch{o={text:t}}const e=o.text.trim();if(!e)return null;const n=typeof o.opacity=="number"&&o.opacity>=0&&o.opacity<=1?o.opacity:p,r=typeof o.
|
|
3
3
|
fontSizePx=="number"&&o.fontSizePx>0?o.fontSizePx:void 0;return{text:e,color:typeof o.color=="string"&&o.color.trim()!==""?o.color:b,opacity:n,diagonal:o.diagonal!==!1,...r!==void 0?{fontSizePx:r}:{}}}
|
|
4
4
|
function x(t){const o={text:t.text};return typeof t.color=="string"&&t.color.trim()!==""&&t.color.toUpperCase()!==b&&(o.color=t.color),typeof t.opacity=="number"&&t.opacity>=0&&t.opacity<=1&&t.opacity!==
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{d as u}from"./TextDecoding-IPbuUqcC.js";const p=["shift_jis","gb18030","big5","euc-kr","windows-1251","windows-1256","windows-1252"];function w(t){return/charset\s*=\s*["']?([^;"'\s]+)/i.exec(t)?.[1]??
|
|
2
|
+
null}function y(t){const n=u(t.subarray(0,2048),"windows-1252");return/<meta[^>]+charset\s*=\s*["']?([^\s"'/>;]+)/i.exec(n)?.[1]??/<meta[^>]+content\s*=\s*["'][^"']*charset\s*=\s*([^\s"';]+)/i.exec(n)?.[1]??
|
|
3
|
+
null}function a(t,n,e=!0){try{return u(t,n,{fatal:e})}catch{return null}}function f(t){let n=0;const e=new Map;for(const c of t){c==="�"?n-=100:/\p{L}|\p{N}/u.test(c)&&(n+=1);for(const[s,r]of[["cjk",
|
|
4
|
+
/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u],["hangul",/\p{Script=Hangul}/u],["cyrillic",/\p{Script=Cyrillic}/u],["arabic",/\p{Script=Arabic}/u]])r.test(c)&&e.set(s,(e.get(s)??0)+1);const o=c.
|
|
5
|
+
codePointAt(0)??0;(o<32&&!`
|
|
6
|
+
\r `.includes(c)||o>=127&&o<160)&&(n-=20)}for(const c of e.values())c>=2&&(n+=c*2);return n-=(t.match(/[ÃÂ]|â[\u0080-\u00bf]/g)??[]).length*8,n}function d(t,n={}){if(t[0]===239&&t[1]===187&&t[2]===
|
|
7
|
+
191)return new TextDecoder("utf-8").decode(t.subarray(3));if(t[0]===255&&t[1]===254)return new TextDecoder("utf-16le").decode(t.subarray(2));if(t[0]===254&&t[1]===255){const r=t.subarray(2).slice();for(let i=0;i+
|
|
8
|
+
1<r.length;i+=2)[r[i],r[i+1]]=[r[i+1],r[i]];return new TextDecoder("utf-16le").decode(r)}const e=w(n.mimeType??"")??(n.kind==="html"?y(t):null);if(e){const r=a(t,e,!1);if(r!==null)return r}const c=a(t,
|
|
9
|
+
"utf-8",!0);if(c!==null)return c;let o=u(t,"windows-1252"),s=f(o);for(const r of p){const i=a(t,r,!0);if(i===null)continue;const l=f(i);l>s&&(o=i,s=l)}return o}async function m(t,n="plain"){const e=new Uint8Array(
|
|
10
|
+
await t.arrayBuffer());return d(e,{kind:n,mimeType:t.type})}export{d as decodeTextBytes,m as decodeTextFile};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as r}from"./footnoteFlatten-
|
|
1
|
+
import{f as r}from"./footnoteFlatten-coCVFd3c.js";import{a_ as p,b0 as c,aR as s,aK as l}from"./engine-C5fxuZJo.js";import{decodeTextFile as m}from"./TextFileDecoder-BZBBejlR.js";class h{static async parseFile(n){
|
|
2
2
|
const o=await m(n);return this.fromText(o)}static fromText(n){const o=n.replace(/\r\n?/g,`
|
|
3
3
|
`).split(/\n\s*\n+/),a=[];for(const t of o){const e=t.trim();e&&a.push(p([{type:"text",text:e}]))}return a.length===0&&a.push(p()),{type:"doc",children:a}}static toText(n,o){n=r(n);const a=t=>t.type===
|
|
4
4
|
"placeholder"?"[Placeholder]":t.type==="image"?"[Image]":t.type==="code"?o?.codeText?.(t)??t.content:t.type==="math"?t.content:t.type==="toc"?c(n,s(t)).map(e=>`${" ".repeat(e.level-1)}${e.text}`).join(
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{bS as h}from"./engine-C5fxuZJo.js";const p={isDark:!1,background:"#f5f5f5",text:"#000000",linkText:"#007bff",selection:"#3390ff",selectionOpacity:.4,inactiveSelection:"#9ac0e8",inactiveSelectionOpacity:.35,
|
|
2
2
|
agentReadHighlight:"#7aaee6",searchHighlight:"#cc8f00",cursor:"#000000",pageBorder:"#dee2e6",pageBackground:"#ffffff",pageShadow:"rgba(0, 0, 0, 0.1)",diffInsert:"#22c55e",diffDelete:"#CF2A2A",diffEqual:"\
|
|
3
3
|
#000000",diffFormatChange:"#f59e0b",diffInsertText:"#0B8237",diffDeleteText:"#CF2A2A",diffFormatChangeText:"#78350f",debugText:"#ff0000",todoCheckboxBorder:"#c8ccd5",todoCheckboxBackground:"#ffffff",todoCheckboxChecked:"\
|
|
4
|
-
#46b35e",todoCheckboxCheckmark:"#46b35e",todoCheckedText:"#6c757d",codeBackground:"#f5f5f5",codeBorder:"#e0e0e0",codeText:"#333333"},
|
|
4
|
+
#46b35e",todoCheckboxCheckmark:"#46b35e",todoCheckedText:"#6c757d",codeBackground:"#f5f5f5",codeBorder:"#e0e0e0",codeText:"#333333"},S={isDark:!0,background:"#080a0e",text:"#c9c9c9",linkText:"#4099ff",
|
|
5
5
|
selection:"#4099ff",selectionOpacity:.4,inactiveSelection:"#5a7a9e",inactiveSelectionOpacity:.35,agentReadHighlight:"#24568f",searchHighlight:"#fbbf24",cursor:"#ffffff",pageBorder:"#1e2430",pageBackground:"\
|
|
6
6
|
#05060a",pageShadow:"rgba(0, 0, 0, 0.5)",diffInsert:"#50B173",diffDelete:"#f87171",diffEqual:"#c9c9c9",diffFormatChange:"#fbbf24",diffInsertText:"#50B173",diffDeleteText:"#f87171",diffFormatChangeText:"\
|
|
7
7
|
#f5a91d",debugText:"#ff6b6b",todoCheckboxBorder:"#2f3747",todoCheckboxBackground:"#05060a",todoCheckboxChecked:"#0e6b30",todoCheckboxCheckmark:"#f3f7ff",todoCheckedText:"#6f7689",codeBackground:"#0c0f\
|
|
8
|
-
15",codeBorder:"#2a2f3a",codeText:"#c9c9c9"};function
|
|
9
|
-
classList.contains("dark")||document.documentElement.classList.contains("dark-theme")}function k(e){const r=
|
|
10
|
-
{...r,pageBackground:n}:r}function
|
|
8
|
+
15",codeBorder:"#2a2f3a",codeText:"#c9c9c9"};function A(e){if(typeof window>"u")return!1;const r=e?.closest?.("[data-theme]")?.getAttribute("data-theme");return r==="dark"?!0:r==="light"?!1:document.documentElement.
|
|
9
|
+
classList.contains("dark")||document.documentElement.classList.contains("dark-theme")}function k(e){const r=A(e)?S:p,n=e?.closest?.("[data-page-background]")?.getAttribute("data-page-background");return n?
|
|
10
|
+
{...r,pageBackground:n}:r}function D(e,r){const n=parseInt(e.slice(1,3),16),t=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16);return`rgba(${n}, ${t}, ${a}, ${r})`}const b=["bold","italic","under\
|
|
11
11
|
line","strikethrough","doubleStrikethrough","smallCaps","allCaps","letterSpacing","code","latex","superscript","subscript","backgroundColor","link"],v=b.reduce((e,r)=>(e[r]=null,e),{}),I=[],d={yellow:"\
|
|
12
12
|
#FDE68A",orange:"#FED7AA",green:"#BBF7D0",blue:"#BFDBFE",purple:"#E9D5FF",pink:"#FBCFE8",gray:"#E5E7EB"},O={yellow:"#7C5E10",orange:"#7C3F16",green:"#1F5F3A",blue:"#1E4E8C",purple:"#5B3A7A",pink:"#7A3\
|
|
13
13
|
F66",gray:"#4B5563"},y=d,m=["yellow","orange","green","blue","purple","pink","gray"],H={yellow:"yellow",gold:"yellow",orange:"orange",darkorange:"orange",darkyellow:"orange",green:"green",darkgreen:"g\
|
|
14
14
|
reen",blue:"blue",cyan:"blue",darkblue:"blue",darkcyan:"blue",purple:"purple",violet:"purple",darkviolet:"purple",darkmagenta:"purple",pink:"pink",magenta:"pink",red:"pink",darkred:"pink",gray:"gray",
|
|
15
15
|
grey:"gray",lightgray:"gray",lightgrey:"gray",darkgray:"gray",darkgrey:"gray",black:"gray",white:"gray"},L={yellow:"yellow",gold:"yellow",orange:"orange",green:"green",blue:"blue",cyan:"blue",purple:"\
|
|
16
16
|
purple",violet:"purple",pink:"pink",magenta:"pink",red:"pink",gray:"gray",grey:"gray",lightgray:"gray",lightgrey:"gray"},M="yellow";function $(e){if(!e)return;const r=e.trim().toLowerCase().replace(/[\s_-]+/g,
|
|
17
|
-
"");return H[r]}function N(e){return f(e)}function
|
|
18
|
-
g,r.b]:null}function
|
|
17
|
+
"");return H[r]}function N(e){return f(e)}function _(e){const r=f(e);return r?y[r]:void 0}function P(e,r=k().isDark){const n=f(e);return n?(r?O:d)[n]:void 0}function C(e){const r=h(e);return r?[r.r,r.
|
|
18
|
+
g,r.b]:null}function R(e){const r=h(e);return r?{rgb:[r.r,r.g,r.b],alpha:r.a}:null}function x(e,r=!1,n=m){let t=null,a=Number.POSITIVE_INFINITY;for(const i of n){const c=[y[i],...r?[d[i]]:[]];for(const g of c){
|
|
19
19
|
const o=C(g);if(!o)continue;const l=(e[0]-o[0])**2+(e[1]-o[1])**2+(e[2]-o[2])**2;l<a&&(a=l,t=i)}}return t?{name:t,distance:a}:null}function B(e){const[r,n,t]=e.map(T=>T/255),a=Math.max(r,n,t),i=Math.min(
|
|
20
20
|
r,n,t),c=a-i,g=(a+i)/2,o=c===0?0:c/(1-Math.abs(2*g-1));let l=null;return c!==0&&(a===r?l=60*((n-t)/c%6):a===n?l=60*((t-r)/c+2):l=60*((r-n)/c+4),l<0&&(l+=360)),{hue:l,lightness:g,saturation:o,maxChannel:Math.
|
|
21
21
|
max(...e)}}function w(e){return e>=20&&e<42?"orange":e>=42&&e<85?"yellow":e>=85&&e<170?"green":e>=170&&e<255?"blue":e>=255&&e<320?"purple":"pink"}function q(e){if(!e)return;const r=e.trim().toLowerCase().
|
|
22
22
|
replace(/[\s_-]+/g,"");return L[r]}function f(e){if(!e)return;const r=$(e);if(r)return r;if(/^[a-z]+$/i.test(e.trim()))return;const n=C(e);if(!n)return;const t=x(n);if(t?.distance===0)return t.name;const{
|
|
23
|
-
hue:a,saturation:i}=B(n),c=Math.max(...n)-Math.min(...n);return a===null||i<=.18||c<10?"gray":w(a)}function z(e){if(!e)return;const r=q(e);if(r)return r;const n=
|
|
23
|
+
hue:a,saturation:i}=B(n),c=Math.max(...n)-Math.min(...n);return a===null||i<=.18||c<10?"gray":w(a)}function z(e){if(!e)return;const r=q(e);if(r)return r;const n=R(e);if(!n||n.alpha<.35)return;const{hue:t,
|
|
24
24
|
lightness:a,saturation:i,maxChannel:c}=B(n.rgb),g=i>.18&&t!==null?[w(t)]:["gray"],o=x(n.rgb,!0,g);if(!o)return;if(o.distance===0)return o.name;if(o.name==="gray")return o.distance>70**2||i>.12||a<.68||
|
|
25
25
|
a>.92?void 0:o.name;const l=i>=.8&&c>=220&&a>=.45;if(!(o.distance>95**2&&!l)&&!(a>.92)&&!(c<150)&&!(i<.22)&&!(a<.55&&c<220))return o.name}const u={paragraph:16,h1:32,h2:24,h3:20,h4:18,h5:16,h6:14,code:14},
|
|
26
26
|
s={paragraph:1.4,heading:1.2,code:1.5};function F(e){if(!e.hasOwnProperty("heading"))return u.paragraph;switch(e.heading){case 1:return u.h1;case 2:return u.h2;case 3:return u.h3;case 4:return u.h4;case 5:
|
|
27
27
|
return u.h5;case 6:return u.h6;default:return u.paragraph}}function E(e){return e.lineSpacing!==void 0?e.lineSpacing:e.heading?s.heading:s.paragraph}function V(e){const r=F(e),n=E(e);return r*n}function j(e){
|
|
28
|
-
return e.lineSpacing!==void 0?e.lineSpacing:s.paragraph}export{I as C,M as D,u as F,m as H,s as L,v as a,b,z as c,
|
|
28
|
+
return e.lineSpacing!==void 0?e.lineSpacing:s.paragraph}export{I as C,M as D,u as F,m as H,s as L,v as a,b,z as c,_ as d,E as e,F as f,k as g,f as h,V as i,j,D as k,p as l,P as m,N as n};
|