@reviseio/engine 0.0.0-stage → 3.0.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/FONT-LICENSE-HAN-EXT-B.txt +91 -0
  3. package/FONT-LICENSE-KATEX.txt +95 -0
  4. package/FONT-LICENSE-LIBERATION.txt +102 -0
  5. package/FONT-LICENSE-NOTO-MULTILINGUAL.txt +93 -0
  6. package/FONT-LICENSE-NOTO-SANS-SC.txt +93 -0
  7. package/FONT-LICENSE-NOTO.txt +94 -0
  8. package/FONT-LICENSE-SOURCE-CODE-PRO.txt +94 -0
  9. package/FONT-LICENSE-SOURCE-SERIF-4.txt +93 -0
  10. package/LICENSE +141 -0
  11. package/README.md +11 -2
  12. package/THIRD-PARTY-NOTICES.md +3376 -0
  13. package/assets/historyMaterializeWorker-Kl0syEbc.js +618 -0
  14. package/chunks/AgentHtmlConverter-BnK7NaYA.js +379 -0
  15. package/chunks/AgentPageRenderViews-BTLjPZJQ.js +2 -0
  16. package/chunks/AgentPageRenderer-DLwq6nAa.js +180 -0
  17. package/chunks/BidiText-Bkp4Y90s.js +160 -0
  18. package/chunks/BlockDiff-BdlcKY-t.js +42 -0
  19. package/chunks/CanvasRenderer-Bqsj1S0p.js +110 -0
  20. package/chunks/ColorParserFull-BKH72fK8.js +446 -0
  21. package/chunks/DocumentCompare-BqyiP87r.js +6 -0
  22. package/chunks/DocumentLayout-CsU5MR-3.js +12 -0
  23. package/chunks/DocumentLayoutEngine-7iOYvyVb.js +218 -0
  24. package/chunks/DocumentMutator-DIrZBuLr.js +13 -0
  25. package/chunks/DocumentScrubber-Cz8Q05hF.js +21 -0
  26. package/chunks/DocumentSession-lXSXqua5.js +1 -0
  27. package/chunks/DocumentStylesheet-CEEt18sr.js +7 -0
  28. package/chunks/DocxConverter-BfDw7777.js +1236 -0
  29. package/chunks/DocxGraft-D0uCnGCo.js +8 -0
  30. package/chunks/HorizontalRuleOrnaments-gmUZ3R7Q.js +3 -0
  31. package/chunks/HtmlConverter-7Xj_g9Jr.js +267 -0
  32. package/chunks/ListNumbering-Qlu6AuRZ.js +23 -0
  33. package/chunks/MarkdownConverter-cnW_oePY.js +57 -0
  34. package/chunks/MathRenderer-Bz9WEVvF.js +68 -0
  35. package/chunks/OdtConverter-GwRDMnwS.js +125 -0
  36. package/chunks/OfficeImportShared-nlMtIUni.js +30 -0
  37. package/chunks/PageNumeralFonts-BWzI061X.js +5 -0
  38. package/chunks/ParagraphDiffAnalysis-DrmStvmz.js +36 -0
  39. package/chunks/PdfConverter-yOlWiVIj.js +457 -0
  40. package/chunks/RtfConverter--wLd0qrw.js +186 -0
  41. package/chunks/TableBorders-C5pNsuxP.js +32 -0
  42. package/chunks/TableGrid-DbroRucl.js +12 -0
  43. package/chunks/TextFileDecoder--rsVs3NR.js +9 -0
  44. package/chunks/TxtConverter-BoRVCDZw.js +14 -0
  45. package/chunks/Typography-DAGM5kfI.js +28 -0
  46. package/chunks/UnicodeUtils-CXtusU4g.js +10 -0
  47. package/chunks/XmlConverter-CO8Z28dX.js +55 -0
  48. package/chunks/_commonjsHelpers-DaMA6jEr.js +2 -0
  49. package/chunks/_revise-sdk-lazy-harfbuzz-CDWdjF9f.js +1 -0
  50. package/chunks/base64-Di1bxoXD.js +1 -0
  51. package/chunks/browser-module-CFmqfGkE.js +1791 -0
  52. package/chunks/bundle.min-DRpfgV69.js +782 -0
  53. package/chunks/capture-Dtinb4bY.js +11 -0
  54. package/chunks/carrier-RNy67HN4.js +6 -0
  55. package/chunks/chromeImageLayout-bgHYmqTp.js +18 -0
  56. package/chunks/engine-TnK8N-gT.js +520 -0
  57. package/chunks/footnoteFlatten-BcKaWzVs.js +6 -0
  58. package/chunks/graftExport-DxAALMHp.js +104 -0
  59. package/chunks/html2canvas.esm-CntiHiYW.js +997 -0
  60. package/chunks/index-BWdRWxoH.js +1807 -0
  61. package/chunks/index-CTti7wRd.js +1002 -0
  62. package/chunks/index.es-CI0QPo8w.js +780 -0
  63. package/chunks/jspdf.es.min-DU74zN8b.js +1792 -0
  64. package/chunks/jszip.min-CPW0h1Kx.js +476 -0
  65. package/chunks/katex-DWj8TvwO.js +1462 -0
  66. package/chunks/pdf-BLWDCiFF.js +1828 -0
  67. package/chunks/purify.es-BwLardii.js +107 -0
  68. package/chunks/serverDocumentSession-BmYdjC6e.js +1011 -0
  69. package/chunks/signatures-CU2LMLBp.js +21 -0
  70. package/chunks/suggestionAuthorship-B-IuLQlE.js +1 -0
  71. package/chunks/web-tree-sitter-BXGZGnNj.js +2 -0
  72. package/chunks/xmlScan-DXjt2cTS.js +8 -0
  73. package/engine.d.ts +179 -0
  74. package/engine.js +3 -0
  75. package/package.json +64 -4
  76. package/serverToolContract.d.ts +420 -0
  77. package/serverToolInputs.generated.d.ts +264 -0
@@ -0,0 +1,110 @@
1
+ import{bK as y,l as A,bN as C,x as We,C as Re,a as Ee,bO as Ye,bP as Ue,bp as ze,br as De,bQ as He,bq as _e,bG as je,bM as Ge}from"./engine-TnK8N-gT.js";import{getLayoutBlockSpacingPx as qe,getLayoutMarginTop as Y,
2
+ getLayoutMarginRight as oe,getLayoutMarginBottom as K,getLayoutMarginLeft as U,getLayoutPageStep as Ke,getLayoutFootnoteInset as ae,getLayoutPageContentTop as Xe}from"./DocumentLayout-CsU5MR-3.js";import{
3
+ g as se,f as Ve}from"./Typography-DAGM5kfI.js";import{v as Qe}from"./TableBorders-C5pNsuxP.js";function le(r){if(!r||typeof r!="object")return!1;const e=r;return e.diffState==="insert"&&!!e.suggestionId}
4
+ function Je(r,e){return{centerX:r.x-y.blockInsertMarkerMarginXPx,centerY:e+y.blockInsertMarkerOffsetYPx,armLength:y.blockInsertMarkerArmPx}}function ce(r,e,t,n){const{centerX:i,centerY:o,armLength:a}=Je(
5
+ e,t);r.save(),r.strokeStyle=n.diffInsert,r.lineWidth=y.blockInsertMarkerLineWidthPx,r.lineCap="round",r.beginPath(),r.moveTo(i-a,o),r.lineTo(i+a,o),r.moveTo(i,o-a),r.lineTo(i,o+a),r.stroke(),r.restore()}
6
+ function Ze(r,e,t,n,i,o,a){const l=a==="insert"?i.diffInsert:i.diffDelete,s=t+Math.max(n/2,8),c=e.left+y.pendingBreakRuleStartPx,f=e.right;r.save(),r.font=`${y.pendingBreakLabelFontSizePx}px Arial, sa\
7
+ ns-serif`;const u=a==="delete"?`${o} (removed)`:o,h=r.measureText(u).width,g=c+(f-c)/2,d=h/2+y.pendingBreakLabelGapPx;r.strokeStyle=l,r.globalAlpha=y.pendingBreakRuleOpacity,r.lineWidth=1,r.setLineDash(
8
+ [y.pendingBreakDashPx,y.pendingBreakDashPx]),r.beginPath(),r.moveTo(c,s),r.lineTo(g-d,s),r.moveTo(g+d,s),r.lineTo(f,s),r.stroke(),r.setLineDash([]),r.fillStyle=l,r.globalAlpha=y.pendingBreakLabelOpacity,
9
+ r.textAlign="center",r.textBaseline="middle",r.fillText(u,g,s),r.restore()}const et={arial:"Liberation Sans",helvetica:"Liberation Sans",inter:"Liberation Sans","sans-serif":"Liberation Sans","system-\
10
+ ui":"Liberation Sans","ui-sans-serif":"Liberation Sans",calibri:"Liberation Sans",monospace:"Liberation Sans","ui-monospace":"Liberation Sans",courier:"Liberation Sans","courier new":"Liberation Sans",
11
+ consolas:"Liberation Sans",menlo:"Liberation Sans","fira code":"Liberation Sans","liberation sans":"Liberation Sans",times:"Noto Serif","times new roman":"Noto Serif",serif:"Noto Serif","ui-serif":"No\
12
+ to Serif",georgia:"Noto Serif",cambria:"Noto Serif","noto serif":"Noto Serif"};function tt(r){const e=r.split(",")[0].trim().replace(/^["']|["']$/g,"");return et[e.toLowerCase()]??e}function rt(){return typeof window>
13
+ "u"}function z(r){return rt()?tt(r):r}function fe(r,e){const t=new Map,n=new Map;for(const i of r.children)for(const o of i.children){n.set(o.id,o.children.map(a=>a.id));for(const a of o.children)t.set(
14
+ a.id,o.id)}for(const i of e.children)for(const o of i.children){const a=o.children.filter(s=>t.has(s.id)).map(s=>s.id);if(a.some(s=>t.get(s)!==o.id))return!0;const l=new Set(a);if((n.get(o.id)??[]).filter(
15
+ s=>l.has(s)).some((s,c)=>s!==a[c]))return!0}return!1}function he(r){const e=new Map;if(!r)return e;function t(n,i,o){for(let a=0;a<n.length;a++){const l=n[a];if(l.id){if(e.set(l.id,{block:l,containerPath:i,
16
+ parentContainer:o,indexInParent:a}),l.type==="container"||l.type==="footnote"||l.type==="header-footer"){const s=l;t(s.children,[...i,s.id],s)}if(l.type==="table"){const s=l;for(const c of s.children)
17
+ for(let f=0;f<c.children.length;f++){const u=c.children[f];u.id&&e.set(u.id,{block:u,containerPath:[...i,s.id],parentContainer:void 0,indexInParent:f}),t(u.children,[...i,s.id,u.id],void 0)}}if(l.type===
18
+ "table-cell"){const s=l;t(s.children,[...i,s.id],void 0)}}}}return t(r.children,[]),r.notes&&t(r.notes,[]),r.chrome&&t(r.chrome,[]),e}function X(r){return r?.marks?Object.keys(r.marks).length>0:!1}function nt(r,e){
19
+ const t=Math.min(e,r.length-1);for(let n=t;n>=0;n--){const i=r[n];if(!(!i||i.type!=="text")&&(i.text.length>0||X(i)))return i}}function D(r,e,t){if(r.length===0||e<0)return;let n=e;n>=r.length&&(n=r.length-
20
+ 1,t=Number.POSITIVE_INFINITY);const i=r[n];if(i&&i.type==="text"){const a=i.text.length,l=Math.max(0,Math.min(t,a));if(a>0&&l>0||a===0&&X(i)||a>0&&t>a)return i}const o=nt(r,n-1);if(o)return o;if(i&&i.
21
+ type==="text"&&X(i))return i}function ue(r,e,t){const n=t?.anchor,i=t?.focus;if(n&&i&&!(n.block===i.block&&n.offset===i.offset)){const o=ee(r,n,i)<=0?n:i,a=H(r,{block:o.block,offset:o.offset+1});if(a)
22
+ return a}return H(r,e)}function H(r,e){const t=k(r,e.block);if(t){if(t.type==="paragraph"){const n=t;let i=e.offset,o=0;for(let a=0;a<n.children.length;a++){const l=n.children[a];if(l.type==="text"){if(i<=
23
+ l.text.length){o=a;break}i-=l.text.length,o=a}}return D(n.children,o,i)}if(t.type==="list"){const n=t;let i=e.offset;for(let o=0;o<n.children.length;o++){const a=n.children[o],l=a.children.filter(s=>s.
24
+ type==="text").reduce((s,c)=>s+c.text.length,0);if(i<=l){let s=i;for(let c=0;c<a.children.length;c++){const f=a.children[c];if(f.type==="text"){if(s<=f.text.length)return D(a.children,c,s);s-=f.text.length}}
25
+ return D(a.children,a.children.length-1,Number.POSITIVE_INFINITY)}i-=l,o<n.children.length-1&&(i-=1)}if(n.children.length>0){const o=n.children[n.children.length-1];return D(o.children,o.children.length-
26
+ 1,Number.POSITIVE_INFINITY)}}}}function de(r,e){const t=k(r,e.block);if(!t)return!1;const n=(l=>{if(l.type==="paragraph")return{children:l.children,offset:e.offset};if(l.type==="list"){const s=l;let c=e.
27
+ offset;for(let f=0;f<s.children.length;f++){const u=s.children[f],h=u.children.filter(g=>g.type==="text").reduce((g,d)=>g+d.text.length,0);if(c<=h)return{children:u.children,offset:c};c-=h,f<s.children.
28
+ length-1&&(c-=1)}}return null})(t);if(!n)return!1;const{children:i,offset:o}=n;let a=0;for(let l=0;l<i.length;l++){const s=i[l];if(s.type!=="text")continue;const c=a+s.text.length;if(o===c&&s.marks?.link)
29
+ return!0;a=c}return!1}function ge(r,e){const t=k(r,e.block);if(!t)return!1;const n=(s=>{if(s.type==="paragraph")return{children:s.children,offset:e.offset};if(s.type==="list"){const c=s;let f=e.offset;
30
+ for(let u=0;u<c.children.length;u++){const h=c.children[u],g=h.children.filter(d=>d.type==="text").reduce((d,p)=>d+p.text.length,0);if(f<=g)return{children:h.children,offset:f};f-=g,u<c.children.length-
31
+ 1&&(f-=1)}}return null})(t);if(!n)return!1;const{children:i,offset:o}=n,a=i.filter(s=>s.type==="text");let l=0;for(let s=0;s<a.length;s++){const c=a[s],f=l+c.text.length;if(o===f&&c.marks?.comment)return a[s+
32
+ 1]?.marks?.comment!==c.marks.comment;l=f}return!1}function k(r,e){if(!A(r)&&r.id===e)return r;if(A(r)&&r.chrome)for(const t of r.chrome){if(t.id===e)return t;const n=k(t,e);if(n)return n}if(A(r)&&r.notes)
33
+ for(const t of r.notes){if(t.id===e)return t;const n=k(t,e);if(n)return n}for(let t=0;t<r.children.length;t++){const n=r.children[t];if(n.id===e)return n;if(C(n)){const i=k(n,e);if(i)return i}if(n.type===
34
+ "list"){const i=n;for(const o of i.children)if(o.id===e)return i}if(n.type==="table"){const i=n;for(const o of i.children){if(o.id===e)return i;for(const a of o.children){if(a.id===e)return a;const l=k(
35
+ a,e);if(l)return l}}}}return null}function S(r,e){if(A(r)&&r.chrome)for(const t of r.chrome){if(t.id===e)return r;const n=S(t,e);if(n)return n}if(A(r)&&r.notes)for(const t of r.notes){if(t.id===e)return r;
36
+ const n=S(t,e);if(n)return n}for(let t=0;t<r.children.length;t++){const n=r.children[t];if(n.id===e)return r;if(C(n)){const i=S(n,e);if(i)return i}if(n.type==="list"){const i=n;for(const o of i.children)
37
+ if(o.id===e)return r}if(n.type==="table"){const i=n;for(const o of i.children)for(const a of o.children){if(a.id===e)return i;const l=S(a,e);if(l)return l}}}return null}function pe(r,e){const t=S(r,e);
38
+ return t?t.children.findIndex(n=>n.id===e):-1}function _(r,e){function t(n,i){for(let o=0;o<n.children.length;o++){const a=n.children[o];if(a.id===e)return[...i,o];if(C(a)){const l=t(a,[...i,o]);if(l)
39
+ return l}if(a.type==="list"){const l=a;for(let s=0;s<l.children.length;s++)if(l.children[s].id===e)return[...i,o,s]}if(a.type==="table"){const l=a;for(let s=0;s<l.children.length;s++){const c=l.children[s];
40
+ if(c.id===e)return[...i,o,s];for(let f=0;f<c.children.length;f++){const u=c.children[f];if(u.id===e)return[...i,o,s,f];const h=t(u,[...i,o,s,f]);if(h)return h}}}}return null}return t(r,[])}function V(r,e){
41
+ const t=Math.min(r.length,e.length);for(let n=0;n<t;n++)if(r[n]!==e[n])return r[n]-e[n];return r.length-e.length}function*me(r){function*e(t,n){if(t.type==="paragraph"||t.type==="list")yield{block:t,path:n};else if(t.
42
+ type==="table"){const i=t;for(let o=0;o<i.children.length;o++){const a=i.children[o];for(let l=0;l<a.children.length;l++){const s=a.children[l];for(let c=0;c<s.children.length;c++)yield*e(s.children[c],
43
+ [...n,o,l,c])}}}else if(C(t)){const i=t;for(let o=0;o<i.children.length;o++)yield*e(i.children[o],[...n,o])}}for(let t=0;t<r.children.length;t++)yield*e(r.children[t],[t])}function*xe(r){function*e(t,n){
44
+ if(yield{block:t,path:n},C(t)){const i=t;for(let o=0;o<i.children.length;o++)yield*e(i.children[o],[...n,o])}}for(let t=0;t<r.children.length;t++)yield*e(r.children[t],[t])}function be(r,e){for(let t=0;t<
45
+ r.children.length;t++){const n=r.children[t];if(n.id===e||C(n)&&k(n,e))return t;if(n.type==="list"){const i=n;for(const o of i.children)if(o.id===e)return t}if(n.type==="table"){const i=n;for(const o of i.
46
+ children){if(o.id===e)return t;for(const a of o.children)if(a.id===e||k(a,e))return t}}}return-1}function ye(r,e){const t=S(r,e);if(!t)return null;const n=t.children.findIndex(o=>o.id===e);if(n===-1)return null;
47
+ const i=t.children[n]?.type==="header-footer";for(let o=n+1;o<t.children.length;o++){const a=t.children[o];if(!(!i&&a.type==="header-footer"))return a}return null}function Q(r,e){const t=ye(r,e);if(t)
48
+ return t;const n=S(r,e);return!n||A(n)?null:Q(r,n.id)}function J(r,e){const t=Z(r,e);if(t)return t;const n=S(r,e);return!n||A(n)?null:J(r,n.id)}function Z(r,e){const t=S(r,e);if(!t)return null;const n=t.
49
+ children.findIndex(o=>o.id===e);if(n<=0)return null;const i=t.children[n]?.type==="header-footer";for(let o=n-1;o>=0;o--){const a=t.children[o];if(!(!i&&a.type==="header-footer"))return a}return null}
50
+ function ee(r,e,t){if(e.block===t.block)return Math.sign(e.offset-t.offset);const n=_(r,e.block),i=_(r,t.block);if(!n||!i)return 0;const o=V(n,i);return o!==0?o:Math.sign(e.offset-t.offset)}const it=Object.
51
+ freeze(Object.defineProperty({__proto__:null,collectAllBlocks:he,comparePaths:V,comparePositions:ee,findBlockById:k,findBlockIndex:pe,findBlockParent:S,findNextBlock:Q,findNextSibling:ye,findPrevBlock:J,
52
+ findPrevSibling:Z,findTextNodeBeforeCursor:H,findTextNodeForInsertion:ue,findTopLevelBlockIndex:be,getBlockPathFromRoot:_,isAtEndOfCommentedText:ge,isAtEndOfLinkedText:de,iterateAllBlocksInOrder:xe,iterateBlocksInOrder:me,
53
+ tableBlocksMoved:fe},Symbol.toStringTag,{value:"Module"}));function te(r,e){return`${"id"in r&&r.id||r.type}:${e}`}const O=new Map,re=new Map,ke=1e3,Se=10;async function ot(r,e=1500){const t=ne(r);return t?
54
+ L(t)?"ready":t instanceof EventTarget?new Promise(n=>{let i=!1;const o=c=>{i||(i=!0,clearTimeout(s),t.removeEventListener?.("load",a),t.removeEventListener?.("error",l),n(c))},a=()=>o(L(t)?"ready":"pl\
55
+ aceholder"),l=()=>o("failed"),s=setTimeout(()=>o("placeholder"),e);t.addEventListener?.("load",a,{once:!0}),t.addEventListener?.("error",l,{once:!0})}):"placeholder":"placeholder"}function at(r,e){const t=ne(
56
+ e.src);if(!t)return;const n=i=>r.drawImage(i,e.x,e.y,e.width,e.height);if(L(t)){n(t);return}t instanceof EventTarget&&t.addEventListener("load",()=>{L(t)&&n(t)},{once:!0})}function L(r){return typeof r.
57
+ complete=="boolean"?!!(r.complete&&r.naturalWidth>0&&r.naturalHeight>0):!0}function ne(r){const e=O.get(r);if(e&&L(e))return re.delete(r),e;if(e&&!L(e)){const i=re.get(r);if(i){const o=O.get(i);if(o&&
58
+ L(o))return o}return e}if(typeof Image>"u")return null;const t=re.get(r);if(t){const i=O.get(t);if(i&&L(i)){const o=new Image;return o.crossOrigin="anonymous",ve(o,r),O.set(r,o),i}}const n=new Image;return n.
59
+ crossOrigin="anonymous",ve(n,r),O.set(r,n),n}function st(r){if(typeof fetch!="function"||!r)return!1;const e=r.trim().toLowerCase();return!(e.startsWith("data:")||e.startsWith("blob:"))}function ve(r,e){
60
+ if(!st(e)){r.src=e;return}let t=0;const n=()=>{t+=1,fetch(e,{method:"HEAD"}).then(i=>{if(i.status===200){r.src=e;return}t<Se&&setTimeout(n,ke)}).catch(()=>{t<Se&&setTimeout(n,ke)})};n()}const Me="imag\
61
+ e-resize-handle",Pe="image-body",we=12,W=32;class lt{constructor(){this.type="image",this.isTextBased=!1}render(e,t,n,i,o){e.save();const a=o?.renderCtx,l=n.relativeToPage?0:a?.yOffset??0,s=n.y-l,c=n.
62
+ width,f=n.height,u=se(e.canvas),h=t.originalFormat||o?.forceImagePlaceholders?null:ne(t.src),g=()=>{e.fillStyle=u.pageBorder,e.globalAlpha=.2,e.fillRect(n.x,s,c,f),e.globalAlpha=1,e.strokeStyle=u.pageBorder,
63
+ e.strokeRect(n.x,s,c,f),e.fillStyle="#6b7280",e.font="14px sans-serif",e.textAlign="center",e.textBaseline="middle";const p=t.originalFormat?`${t.originalFormat.toUpperCase()} image`:o?.forceImagePlaceholders?
64
+ "Image unavailable":"Image";e.fillText(p,n.x+c/2,s+f/2)},d=h&&typeof h.complete=="boolean"?!!(h.complete&&h.naturalWidth>0&&h.naturalHeight>0):!0;if(h&&d?e.drawImage(h,n.x,s,c,f):(g(),h&&"onload"in h&&
65
+ typeof h.onload=="function"&&(h.onload=()=>{typeof requestAnimationFrame=="function"&&requestAnimationFrame(()=>{const p=o?.renderCtx?.ctx??e,b=n.relativeToPage?0:o?.renderCtx?.yOffset??0;p.drawImage(
66
+ h,n.x,n.y-b,c,f)})})),e.restore(),t.uploading&&(e.save(),e.globalAlpha=.35,e.fillStyle=u.pageBackground,e.fillRect(n.x,s,c,f),e.globalAlpha=1,e.fillStyle=u.selection,e.font="12px sans-serif",e.textAlign=
67
+ "center",e.textBaseline="middle",e.fillText("Uploading…",n.x+c/2,s+f/2),e.restore()),o&&!o.isReadOnly){const p=te(t,Me),b=te(t,Pe),v=(t.align??"left")==="right",m=o.activeUIComponentKey===p,M=o.isSelected,
68
+ N=o.hoveredUIComponentKey===p||o.hoveredUIComponentKey===b,P=m||N;if((P||M)&&(e.save(),e.strokeStyle=u.selection,e.lineWidth=2,e.strokeRect(n.x,s,c,f),e.restore()),P){const I=Math.max(8,Math.min(we,Math.
69
+ min(c,f)*.25)),w=Math.max(6,Math.min(I,Math.min(c,f))),R=v?n.x:n.x+c-w,E=s+f-w;e.save(),e.globalAlpha=m?.95:.85,e.fillStyle=m?u.selection:u.pageBackground,e.fillRect(R,E,w,w),e.globalAlpha=1,e.lineWidth=
70
+ 2,e.strokeStyle=u.selection,e.strokeRect(R,E,w,w),e.restore()}}le(t)&&ce(e,n,s,u)}getBounds(e,t,n,i,o,a){const l=o.availableWidth,s=e.width||l,c=e.height||l,f=Math.min(s,l),u=s>0?f/s:1,h=Math.max(Math.
71
+ round(c*u),1),g=e.align??"left";let d=t;return g==="center"?d=t+Math.max(0,(o.availableWidth-f)/2):g==="right"&&(d=t+Math.max(0,o.availableWidth-f)),{x:d,width:f,units:[{height:h,width:f,x:d}],margins:{
72
+ top:o.suppressTopSpacingForFirstChild?0:qe(o,12),bottom:0}}}hitTest(e,t,n,i,o,a,l){return t>=i.x&&t<=i.x+i.width&&n>=i.y&&n<=i.y+i.height?{type:"block",bounds:i}:null}getUIComponents(e,t,n,i,o,a,l){if(l?.
73
+ isReadOnly)return[];const s=()=>{const h=Math.max(8,Math.min(we,Math.min(t.width,t.height)*.25));return Math.max(6,Math.min(h,Math.min(t.width,t.height)))},c=e.align??"left",f=c==="right",u=f?"nesw-re\
74
+ size":"nwse-resize";return[{id:Me,cursor:u,getBounds:()=>{const h=s();return{x:f?t.x:t.x+Math.max(t.width-h,0),y:t.y+Math.max(t.height-h,0),width:h,height:h}},onMouseDown:h=>{const g=h.block,d=g.width||
75
+ W,p=g.height||W,b=d>0?p/d:1;let v=d,m=p;const M=h.position.x,N=h.position.y,P=h.blockBounds,I=P.x,w=P.y,R=I+d,E=w+p,Ae=P.x+P.width,Ce=I+d/2,j=f?M-I:M-R,Ne=N-E,G=(x,F)=>Math.max(W,Math.min(Math.round(x),
76
+ F)),ie=x=>Math.max(W,Math.round(x));return{cursor:u,onMouseMove:x=>{const F=x.layout.availableWidth,q=x.position.x,Fe=x.position.y;let B;if(c==="right"){const T=q-j;B=G(Ae-T,F)}else if(c==="center"){const T=q-
77
+ j,Oe=Math.max(W/2,T-Ce);B=G(Oe*2,F)}else{const T=q-j;B=G(T-I,F)}let $;if(x.modifiers.shiftKey){const T=Fe-Ne;$=ie(T-w)}else $=ie(B*b);if(Math.abs(B-v)<1&&Math.abs($-m)<1)return;const $e={...x.block,width:B,
78
+ height:$};x.api.replaceBlock($e)&&(v=B,m=$)},onMouseUp:x=>{x.api.requestRedraw()},onCancel:()=>{}}}},{id:Pe,cursor:void 0,getBounds:()=>({x:t.x,y:t.y,width:t.width,height:t.height})}]}getFirstCursorPosition(e){
79
+ return null}getLastCursorPosition(e){return e.id?{block:e.id,offset:0}:{block:"",offset:0}}getNextCursorPosition(e,t){return null}getPreviousCursorPosition(e,t){return null}getCursorScreenPosition(e,t,n,i,o,a,l,s){
80
+ const c=(t.offset??0)<=0,f=n.y+n.height;return{x:c?n.x:n.x+n.width,y:f,fontSize:o.fontSize}}getSelectionRects(e,t,n,i,o,a,l,s){return[]}getCharacterAtPoint(e,t,n,i,o,a,l){return null}getCharacterOffset(e,t){
81
+ return 0}getPositionFromOffset(e,t){}getPlainText(e){return""}getWordCount(e){return 0}getCharCount(e){return 0}isEmpty(e){return!1}canEdit(){return!1}canMergeWith(e){return!1}mergeWith(e,t,n){return e}split(e,t){
82
+ return{before:e,after:e}}toHTML(e){const t=[`src="${e.src}"`,`width="${e.width}"`,`height="${e.height}"`];return e.sourceUrl&&t.push(`data-source-url="${e.sourceUrl}"`),e.alt&&t.push(`alt="${e.alt}"`),
83
+ e.align&&e.align!=="left"&&t.push(`data-align="${e.align}"`),`<img ${t.join(" ")}/>`}toMarkdown(e){return`![${e.alt??""}](${e.src})`}toPlainText(e){return""}toYjs(e,t){return We(e)}fromYjs(e){const t=e.
84
+ getAttribute("width"),n=e.getAttribute("height");return{type:"image",id:e.getAttribute("id")||Ee(),src:e.getAttribute("src")||"",sourceUrl:e.getAttribute("sourceUrl")||void 0,width:t?parseInt(t,10):200,
85
+ height:n?parseInt(n,10):200,diffState:e.getAttribute("diffState")==="insert"||e.getAttribute("diffState")==="delete"||e.getAttribute("diffState")==="equal"?e.getAttribute("diffState"):void 0,suggestionId:e.
86
+ getAttribute("suggestionId")||void 0,alt:e.getAttribute("alt")||void 0,align:Re(e,"align"),originalFormat:e.getAttribute("originalFormat")==="emf"||e.getAttribute("originalFormat")==="wmf"?e.getAttribute(
87
+ "originalFormat"):void 0,originalDataUrl:e.getAttribute("originalDataUrl")||void 0,anchorXml:e.getAttribute("anchorXml")||void 0}}findMatches(e,t){return[]}validate(e){const t=[];return e.src||t.push(
88
+ "Image block must have a source URL"),(!(e.width>0)||!(e.height>0))&&t.push("Image block must have positive dimensions"),e.align&&!["left","center","right"].includes(e.align)&&t.push("Image block has \
89
+ invalid alignment"),{valid:t.length===0,errors:t}}isAtomic(){return!0}allowsInternalCursor(){return!1}shouldDeleteBlock(e,t,n){return!0}handleEnterKey(e,t){return{action:"insert-after"}}getNavigationTarget(e,t){
90
+ return null}}function ct(r,e,t,n){return{ctx:r,canvas:e,layout:t,textContext:n,currentPage:0,theme:se(e)}}function Ie(r,e,t,n="Arial, sans-serif"){let i;r?.fontFamily?i=r.fontFamily:i=n,i=Ye(i);const o=Ue(
91
+ r?.lang);return o&&!i.startsWith(o)&&(i=`${o}, ${i}`),z(i)}function Le(r,e,t,n){let i=r?.fontSize??e;if((r?.superscript||r?.subscript)&&(i=Math.round(i*.7)),r?.code)return`normal ${i}px ${Ge}`;const o=Ie(
92
+ r,n?.para,n?.doc,t);let a="";r?.italic&&(a+="italic ");let l="normal";return r?.bold&&(l="bold"),`${a}${l} ${i}px ${o}`}function ft(r,e,t=16,n="Arial, sans-serif",i,o){const a=i?Ve(i):t;r.font=Le(e,a,
93
+ n,{para:i,doc:o})}function ht(r,e,t){if(t.pageless)return{newY:r,pageChanged:!1};const n=Ke(t),i=t.sectionStartY??0,o=t.sectionFirstPageIndex??0,a=r-i-t.textStartY,l=Math.max(0,Math.floor(a/n)),s=i+l*
94
+ n,c=K(t),f=s+t.pageHeight-c-ae(t,o+l);if(r+e>f){const u=Y(t);for(let h=1;h<=Be;h++){const g=l+h,d=i+g*n,p=o+g,b=Xe(t,p),v=ae(t,p),m=d+b,M=d+t.pageHeight-c-v;if(b<=u&&v<=0||m+e<=M||h===Be)return{newY:m,
95
+ pageChanged:!0}}}return{newY:r,pageChanged:!1}}const Be=200;function ut(r,e){const{ctx:t,canvas:n,layout:i}=r,o=typeof window<"u"&&window.devicePixelRatio?window.devicePixelRatio:1,a=n.width/o/e;t.save();
96
+ const l=r.pageGeometry,s=l?.marginTop??Y(i),c=l?.marginRight??oe(i),f=l?.marginBottom??K(i),u=l?.marginLeft??U(i),h=l?.pageHeight??i.pageHeight;if(Te(r,"back"),r.watermark&&!i.pageless&&Qe(t,r.watermark,
97
+ a,h),!i.pageless)for(const p of l?.chromeImages??[])at(t,p);const g=!!r.headersContent,d=!!r.footersContent;if((l?l.showPageNumbers:r.pageLayoutSettings?.showPageNumbers)&&!i.pageless){const p=l?.pageNumberPosition??
98
+ r.pageLayoutSettings?.pageNumberPosition??"top-right",b=p.startsWith("top");if(!(b?g:d)){const v=p.endsWith("right"),m=12,M=m/2+4,N=v?a-c:u,P=b?Math.max(M,s/2):h-Math.max(M,f/2),I=l?ze(l.renderedPageNumber,
99
+ l.pageNumberFormat):r.pageLayoutSettings?De(r.pageLayoutSettings,r.currentPage):String(r.currentPage+1);t.fillStyle=r.theme.text,t.font=`normal ${m}px ${z(i.fontFamily)}`,t.textAlign=v?"right":"left",
100
+ t.textBaseline="middle",t.fillText(I,N,P)}}gt(r),dt(r),t.restore()}function dt(r){const{ctx:e,layout:t}=r;if(t.pageless)return;const n=r.pageGeometry,i=n?n.pleadingGrid:r.pageLayoutSettings?.pleadingGrid;
101
+ if(!i)return;const o=n?.marginTop??Y(t),a=n?.marginLeft??U(t),l=i.fontSizePx??t.fontSize,s=i.firstBaselinePx??o+l;e.save(),e.fillStyle=r.theme.text,e.font=`normal ${l}px ${z(r.pageFontFamilies?.get(r.
102
+ currentPage+1)??i.fontFamily??t.fontFamily)}`,e.textAlign="right",e.textBaseline="alphabetic";const c=a-(i.distancePx??14);for(let f=0;f<i.rows;f++)e.fillText(String(f+1),c,s+f*i.pitchPx);e.restore()}
103
+ function Te(r,e){const{layout:t,pageGeometry:n}=r,i=n?n.pageBorders:r.pageLayoutSettings?.pageBorders;if(!i||t.pageless||i.zOrder!==e)return;const o=72/96;He(r.ctx,_e(i,(n?.pageWidth??t.pageWidth)*o,(n?.
104
+ pageHeight??t.pageHeight)*o,{top:(n?.marginTop??Y(t))*o,right:(n?.marginRight??oe(t))*o,bottom:(n?.marginBottom??K(t))*o,left:(n?.marginLeft??U(t))*o},n?.sectionFirstPage??r.currentPage===0).map(a=>({
105
+ ...a,color:je(a.color,r.theme.isDark)??r.theme.text})))}function gt(r){const{ctx:e,layout:t}=r;if(t.pageless)return;const n=r.pageGeometry,i=n?n.lineNumbering:r.pageLayoutSettings?.lineNumbering;if(!i)
106
+ return;const o=r.lineNumberMarks;if(!o||o.length===0)return;const a=r.yOffset??r.startY??0,l=n?.marginLeft??U(t),s=r.currentPage+1;let c=i.start;if(i.restart==="continuous")for(const u of o)(u.pageNumber??
107
+ 0)<s&&c++;e.save(),e.fillStyle=r.theme.text,e.globalAlpha*=.55,e.font=`normal 10px ${z(r.pageFontFamilies?.get(s)??t.fontFamily)}`,e.textAlign="right",e.textBaseline="alphabetic";const f=l-(i.distancePx??
108
+ 12);for(const u of o){if(u.pageNumber!==s)continue;const h=c++;if(h%i.countBy!==0)continue;const g=u.baselineOffset??Math.min(u.height,t.fontSize);e.fillText(String(h),f,u.y-a+g)}e.restore()}export{ft as A,
109
+ Ze as B,te as C,Z as D,it as E,lt as I,ee as a,ct as b,V as c,Te as d,ut as e,k as f,_ as g,be as h,S as i,pe as j,he as k,H as l,de as m,ge as n,me as o,ue as p,J as q,Q as r,xe as s,fe as t,Ie as u,
110
+ ht as v,ot as w,le as x,ce as y,Le as z};