revise 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/assets/historyMaterializeWorker-B51R08XN.js +612 -0
  3. package/backend.d.ts +8 -2
  4. package/backend.js +1 -1
  5. package/chunks/AgentPageRenderer-CH8kSTJn.js +1 -0
  6. package/chunks/AgentPageRenderer-P23XVguo.js +1 -0
  7. package/chunks/AttachmentDocumentImporter-B1WOaa7d.js +1 -0
  8. package/chunks/AttachmentDocumentImporter-CT_PJp_e.js +1 -0
  9. package/chunks/{BidiText-C8PBPSQY.js → BidiText-Swm5fl9J.js} +74 -74
  10. package/chunks/DocumentMutator-btiDK57e.js +31 -0
  11. package/chunks/{DocumentScrubber-DS4LFDKS.js → DocumentScrubber-CMPfm_HF.js} +1 -1
  12. package/chunks/{DocumentScrubber-COPepQKE.js → DocumentScrubber-Cm2kH8op.js} +1 -1
  13. package/chunks/{DocumentScrubber-Cf_QqHhF.js → DocumentScrubber-bJoKijol.js} +1 -1
  14. package/chunks/DocumentStylesheet-DreoD7sD.js +7 -0
  15. package/chunks/DocxConverter-BcVG-p5K.js +13 -0
  16. package/chunks/DocxConverter-D2bO5RE-.js +1125 -0
  17. package/chunks/DocxConverter-haCfRuWb.js +13 -0
  18. package/chunks/{DocxGraft-Ba63IRP4.js → DocxGraft-BRKh4mHQ.js} +1 -1
  19. package/chunks/{DocxGraft-DjERgl-z.js → DocxGraft-BxSQtl12.js} +2 -2
  20. package/chunks/{DocxGraft-cYlmw4Ab.js → DocxGraft-C9MBQCnf.js} +1 -1
  21. package/chunks/FileImporter-CszqRfVU.js +1 -0
  22. package/chunks/FileImporter-DObFoCCn.js +1 -0
  23. package/chunks/{HtmlConverter-Sd9t49vH.js → HtmlConverter-DwXB4IDh.js} +12 -12
  24. package/chunks/{MarkdownConverter-BdJgh8xt.js → MarkdownConverter-CUC8GgsS.js} +1 -1
  25. package/chunks/MathRenderer-DT6GyJXb.js +68 -0
  26. package/chunks/OdtConverter-7h9HHMpL.js +125 -0
  27. package/chunks/OdtConverter-Ct4qypJk.js +6 -0
  28. package/chunks/OdtConverter-DFl__sJc.js +6 -0
  29. package/chunks/OfficeImportShared-BY6FdZ8d.js +1 -0
  30. package/chunks/OfficeImportShared-BrZoDM0j.js +30 -0
  31. package/chunks/OfficeImportShared-Bvm-mOyj.js +1 -0
  32. package/chunks/PdfConverter-1wyvoT7X.js +21 -0
  33. package/chunks/PdfConverter-BAoEHILo.js +21 -0
  34. package/chunks/PdfConverter-CKEvFj11.js +448 -0
  35. package/chunks/{PdfImportService-CQCgsRX1.js → PdfImportService-BhLPp5uG.js} +2 -2
  36. package/chunks/{PdfImportService-xl7fstr-.js → PdfImportService-xbzrN__L.js} +2 -2
  37. package/chunks/RtfConverter-Bxn-enp8.js +15 -0
  38. package/chunks/RtfConverter-LZPzBDSr.js +15 -0
  39. package/chunks/RtfConverter-_bacXqr1.js +186 -0
  40. package/chunks/{TableBorders-Cdkc62cX.js → TableBorders-CwnF3jvH.js} +1 -1
  41. package/chunks/{TxtConverter-C-oiFUAp.js → TxtConverter-C7FOwHpH.js} +1 -1
  42. package/chunks/XmlConverter-7oo8oeQB.js +2 -0
  43. package/chunks/XmlConverter-DGORHJcZ.js +96 -0
  44. package/chunks/XmlConverter-DeLHReK_.js +2 -0
  45. package/chunks/ar-ComXvtmh.js +13 -0
  46. package/chunks/backend-DecaBz-I.js +490 -0
  47. package/chunks/base64-sSPOzq-u.js +198 -0
  48. package/chunks/{browser-module-CYGCfEyx.js → browser-module-Dj5o3kuL.js} +1 -1
  49. package/chunks/{browser-module-DgvTMhpA.js → browser-module-UuM_O36W.js} +1 -1
  50. package/chunks/{capture-BAJ2in5p.js → capture-1btcWcPF.js} +1 -1
  51. package/chunks/{carrier-C5VZRMxZ.js → carrier-DQeng6yq.js} +1 -1
  52. package/chunks/de-BkbpIKxx.js +13 -0
  53. package/chunks/es-CKkXujOF.js +13 -0
  54. package/chunks/fil-piIHMc8F.js +13 -0
  55. package/chunks/{footnoteFlatten-Bekh8ZfM.js → footnoteFlatten-DUQticYy.js} +1 -1
  56. package/chunks/fr-DuA8qLje.js +13 -0
  57. package/chunks/{graftExport-CRRm1Oe_.js → graftExport-CYnStOdU.js} +1 -1
  58. package/chunks/index-2TBhRkX7.js +387 -0
  59. package/chunks/{index-B1idHquf.js → index-Bf14eTEW.js} +231 -229
  60. package/chunks/index-BwcX_r62.js +387 -0
  61. package/chunks/{index.es-Bwt05m_b.js → index.es-CI7cDExj.js} +1 -1
  62. package/chunks/{index.es-DAQD57G4.js → index.es-DHpGt6Y5.js} +1 -1
  63. package/chunks/ja-DgrSs555.js +13 -0
  64. package/chunks/{jspdf.es.min-DlTF8uTw.js → jspdf.es.min--GshOuIm.js} +1 -1
  65. package/chunks/{jspdf.es.min-CnNRolk9.js → jspdf.es.min-DurJZ1zW.js} +1 -1
  66. package/chunks/pseudoLocale-BoYTjmiK.js +1 -0
  67. package/chunks/pseudoLocale-DG2NnZmz.js +1 -0
  68. package/chunks/serverDocumentSession-CJ1EH3Tp.js +15 -0
  69. package/chunks/{signatures-CBF7NZUy.js → signatures-Bwt_OGik.js} +1 -1
  70. package/chunks/suggestionAuthorship-B-IuLQlE.js +1 -0
  71. package/chunks/zh-9OF3SWWO.js +13 -0
  72. package/full.js +1 -1
  73. package/index.d.ts +13 -5
  74. package/index.js +1 -1
  75. package/package.json +1 -1
  76. package/root.js +2 -2
  77. package/style.css +1 -1
  78. package/assets/historyMaterializeWorker-C4uxcZEh.js +0 -607
  79. package/chunks/AgentPageRenderer-BFB0arQL.js +0 -1
  80. package/chunks/AgentPageRenderer-Dn6SaRjW.js +0 -1
  81. package/chunks/AttachmentDocumentImporter-BHDJAdky.js +0 -1
  82. package/chunks/AttachmentDocumentImporter-CxOZqzt1.js +0 -1
  83. package/chunks/DocumentMutator-4vBJQ74L.js +0 -31
  84. package/chunks/DocumentStylesheet-byN5dtC6.js +0 -7
  85. package/chunks/DocxConverter-BCEB7jWY.js +0 -1083
  86. package/chunks/DocxConverter-C3NflpDr.js +0 -11
  87. package/chunks/DocxConverter-D9ZNn4nX.js +0 -11
  88. package/chunks/FileImporter-CHXj9sNX.js +0 -1
  89. package/chunks/FileImporter-DetvRoJc.js +0 -1
  90. package/chunks/MathRenderer-B0Y1h1JU.js +0 -62
  91. package/chunks/OdtConverter-BKtyx012.js +0 -1
  92. package/chunks/OdtConverter-Ce9j8PRt.js +0 -1
  93. package/chunks/OdtConverter-D709qfYb.js +0 -31
  94. package/chunks/PdfConverter-BA8XLTAM.js +0 -21
  95. package/chunks/PdfConverter-CkDClffR.js +0 -438
  96. package/chunks/PdfConverter-CxLxd-LJ.js +0 -21
  97. package/chunks/RtfConverter-BZOnMUGH.js +0 -14
  98. package/chunks/RtfConverter-Bs81AfXt.js +0 -14
  99. package/chunks/RtfConverter-DfuE5olb.js +0 -45
  100. package/chunks/XmlConverter-C0FnrVYk.js +0 -70
  101. package/chunks/XmlConverter-CQa8baOF.js +0 -2
  102. package/chunks/XmlConverter-DjEYaIyf.js +0 -2
  103. package/chunks/ar-BdmGnaKI.js +0 -14
  104. package/chunks/backend-BIhAX-Gi.js +0 -484
  105. package/chunks/base64-Qx0OzT4p.js +0 -196
  106. package/chunks/de-DldIXRFC.js +0 -14
  107. package/chunks/es-CnyKlSPK.js +0 -14
  108. package/chunks/index-C-4H81OE.js +0 -378
  109. package/chunks/index-iZC8xN0t.js +0 -378
  110. package/chunks/pseudoLocale-BoJwIubw.js +0 -1
  111. package/chunks/pseudoLocale-DWAm7Dpa.js +0 -1
  112. package/chunks/serverDocumentSession-DASrQAbW.js +0 -15
package/backend.d.ts CHANGED
@@ -19,7 +19,13 @@ export interface ReviseDocument {
19
19
  }
20
20
 
21
21
  /** Formats readable on the server. PDF and images are browser-only. */
22
- export type ReviseServerFormat = "docx" | "markdown" | "txt" | "html";
22
+ export type ReviseServerFormat =
23
+ | "docx"
24
+ | "odt"
25
+ | "rtf"
26
+ | "markdown"
27
+ | "txt"
28
+ | "html";
23
29
 
24
30
  /** Top-level keys the editor owns inside a shared document. */
25
31
  export declare const RESERVED_DOCUMENT_KEYS: readonly string[];
@@ -35,7 +41,7 @@ export declare function assertUsableSharedDocument(ydoc: Doc): void;
35
41
  * here; exported for hosts importing converters directly. */
36
42
  export declare function installDomShims(): Promise<void>;
37
43
 
38
- /** Parse .docx, .md, .txt, or .html into the document model. */
44
+ /** Parse .docx, .odt, .rtf, .md, .txt, or .html into the document model. */
39
45
  export declare function parseDocument(
40
46
  bytes: Uint8Array,
41
47
  filename: string,
package/backend.js CHANGED
@@ -1,3 +1,3 @@
1
- import{bW as s,R as a,bV as e,bU as o,bS as c,bR as r,bI as b,bQ as t,bN as D,bJ as m,bP as i,b as d,bH as n,bT as S,bK as u,bO as l,bL as R,bM as T}from"./chunks/backend-BIhAX-Gi.js";import"yjs";export{
1
+ import{bZ as s,R as a,bY as e,bX as o,bV as c,bU as r,bL as b,bT as t,bQ as D,bM as m,bS as i,b as d,bK as n,bW as S,bN as u,bR as l,bO as R,bP as T}from"./chunks/backend-DecaBz-I.js";import"yjs";export{
2
2
  s as RESERVED_DOCUMENT_KEYS,a as ReviseToolError,e as assertUsableSharedDocument,o as createReviseYDoc,c as createServerDocumentSession,r as decodeYDoc,b as documentToDocx,t as encodeYDoc,D as exportDocument,
3
3
  m as fileToYDoc,i as hasDocument,d as installDomShims,n as parseDocument,S as repairSeedRace,u as seedYDocFromFile,l as ydocSourceFidelity,R as ydocToDocument,T as ydocToDocx};
@@ -0,0 +1 @@
1
+ import*as x from"yjs";import{K as P,L as O,S as k,M as C,N as D,O as Y,Q as B,T as G,U as A,z,V as K,W as Q,X as V,Y as X,Z,_ as J,$ as ee,a0 as te,a1 as oe}from"./index-BwcX_r62.js";function $(e,t,n,i){if(Array.isArray(e)){for(const r of e)$(r,t,n,i);return}if(!e||typeof e!="object")return;const a=e,o=typeof a.id=="string"?a.id:t;a.type==="math"&&typeof a.content=="string"&&n.push({content:a.content,displayMode:a.displayMode!=="inline",blockId:o}),a.type==="text"&&typeof a.text=="string"&&a.marks?.latex&&n.push({content:a.text,displayMode:!1,blockId:o}),a.type==="image"&&typeof a.src=="string"&&i.push({src:a.src,blockId:o,permanentlyPlaceholder:a.originalFormat==="emf"||a.originalFormat==="wmf"});for(const r of Object.values(a))if(Array.isArray(r))for(const s of r)$(s,o,n,i);else r&&typeof r=="object"&&$(r,o,n,i)}function j(){return new Promise(e=>{let t=!1;const n=()=>{t||(t=!0,clearTimeout(i),e())},i=setTimeout(n,50);typeof requestAnimationFrame=="function"&&requestAnimationFrame(n)})}async function ne(e,t){if(e.length===0)return;const n=Promise.allSettled(e.map(i=>K(i.content,i.displayMode,t)));await Promise.race([n,new Promise(i=>setTimeout(i,2500))]),await j(),await j()}function R(e,t){if(typeof e.pageNumber=="number")return e.pageNumber-1;const n=e.bounds.y;return t.pageGeometries?.find(i=>n>=i.pageTop&&n<i.pageTop+i.pageHeight)?.pageIndex??0}function ae(e,t){return new Set(e.fragments.filter(n=>t.has(R(n,e))).map(n=>n.blockId))}function ie(e){return e==="table"?"#7c3aed":e==="table-cell"||e==="table-row"?"#db2777":e==="image"?"#ea580c":e==="container"?"#2563eb":e==="math"?"#ca8a04":"#0891b2"}function E(e,t,n){e.save(),e.lineWidth=.75,e.setLineDash([4,3]),e.strokeStyle="rgba(22, 163, 74, 0.9)",e.strokeRect(n.marginLeft,n.marginTop,n.pageWidth-n.marginLeft-n.marginRight,n.pageHeight-n.marginTop-n.marginBottom),e.setLineDash([]);const i=new Set;for(const a of t.fragments){if(R(a,t)!==n.pageIndex)continue;const{bounds:o}=a,r=o.relativeToPage?o.y:o.y-n.pageTop,s=`${a.blockId}:${Math.round(o.x)}:${Math.round(r)}:${Math.round(o.width)}:${Math.round(o.height)}`;if(i.has(s)||o.width<=0||o.height<=0)continue;i.add(s);const g=ie(a.block.type);if(e.strokeStyle=g,e.globalAlpha=.82,e.strokeRect(o.x,r,o.width,o.height),(a.block.type==="table"||a.block.type==="table-cell"||a.block.type==="image"||a.block.type==="container"||a.block.type==="math")&&o.width>=42&&o.height>=12){const l=`${a.block.type} #${a.blockId}`;e.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",e.textAlign="left",e.textBaseline="top";const d=Math.min(o.width,e.measureText(l).width+5);e.globalAlpha=.88,e.fillStyle=g,e.fillRect(o.x,Math.max(0,r),d,13),e.globalAlpha=1,e.fillStyle="#ffffff",e.fillText(l,o.x+2,Math.max(0,r)+1,Math.max(1,d-4))}}e.restore()}function re(e,t){return{pageIndex:0,sectionIndex:0,pageTop:0,pageWidth:e.pageWidth,pageHeight:Math.min(4096,Math.max(e.pageHeight,t.totalHeight)),marginTop:e.pageMarginTop??e.pageMargin,marginRight:e.pageMarginRight??e.pageMargin,marginBottom:e.pageMarginBottom??e.pageMargin,marginLeft:e.pageMarginLeft??e.pageMargin,showPageNumbers:!1,pageNumberPosition:"bottom-right",renderedPageNumber:1}}const L=new WeakMap;let q=0;function se(e){let t=L.get(e);return t||(q+=1,t=`session-${q}`,L.set(e,t)),t}const F=new WeakMap;let H=0;function ce(e){let t=F.get(e);return t===void 0&&(H+=1,t=H,F.set(e,t)),t}function W(e){let t=2166136261;for(const n of e.join("\0"))t^=n.codePointAt(0),t=Math.imul(t,16777619)>>>0;return t.toString(36)}function ge(e){const t=e.getDocumentSession?.();if(!t)throw new k("document_unavailable","Rendered page inspection needs a loaded document. Wait for the document to open, then retry.","verification",!1);return t}function de(e){const t=e.getDetachedSuggestionStore?.();return{liveIds:[...e.getDocumentMutator().getLiveSuggestionIds()].sort(),legacyIds:t?[...t.getPendingSuggestions().keys()].sort():[]}}function le(e,t){return t!==P?"live-pending-suggestion-projection":e.isHistoryOpen()?"displayed-history-revision":"displayed-document"}function v(e,t){return`${e} ${t}${e===1?"":"s"}`}function he(e,t,n,i){const a=i.liveIds.length,o=i.legacyIds.length,r=v(o,"legacy detached suggestion");if(e==="displayed-history-revision")return"The past revision the editor displays while the history view is open, not the live document. The live document's pending suggestions are not part of this image.";if(e==="displayed-document"){const d=`The document as the editor displays it, with ${v(a,"pending suggestion")} drawn as tracked changes.`;return o>0?`${d} ${r} ${o===1?"is":"are"} pending outside the document and not drawn; show-with-tracked-changes-accepted previews them.`:d}const s=n?"The live document, not the past revision the history view displays,":"The live document",g=n?"":"; this view equals show-tracked-changes",l="in a private preview; nothing was resolved in the document.";if(t==="show-with-tracked-changes-accepted")return a>0?`${s} with all ${v(a,"pending suggestion")} accepted ${l}`:o>0?`${s} with all ${r} applied ${l}`:`${s} has no pending suggestions to accept${g}.`;if(a>0){const d=o>0?` ${r} stored outside the document ${o===1?"is":"are"} absent here as well.`:"";return`${s} with all ${v(a,"pending suggestion")} rejected ${l}${d}`}return o>0?`${s} as it stands: its ${r} ${o===1?"is":"are"} stored outside the document, so there is nothing to reject${g}.`:`${s} has no pending suggestions to reject${g}.`}function ue(e,t,n){const i=e.getDocumentId(),a=se(e),o=e.getDocumentMutator().derivedDocumentRevision,r=e.isHistoryOpen(),s=le(e,t),g=n.liveIds.length,l=n.legacyIds.length,d=t==="show-with-tracked-changes-accepted"?g>0?g:l:t==="show-before-tracked-changes"?g:0,w=s==="displayed-history-revision"?[`h${ce(e.getCurrentDocument())}`]:[`r${o}`,`s${g}.${W(n.liveIds)}`,...l>0?[`l${l}.${W(n.legacyIds)}`]:[]],u=s==="displayed-history-revision"?{...e.getSelection(),diffEnabled:e.isDiffEnabled()}:void 0;return{documentId:i,sessionId:a,basis:s,historyOpen:r,revision:o,pendingSuggestionCount:g+l,legacyDetachedSuggestionCount:l,projectedSuggestionCount:d,...u?{historySelection:u}:{},description:he(s,t,r,n),key:[i,a,s,...w,t].join(":")}}function N(e,t){const n=ge(e),i=de(n),a=i.liveIds.length,o=i.legacyIds.length;if(t==="show-with-tracked-changes-accepted"&&a>0&&o>0)throw new k("render_view_unsupported",`This document has ${v(a,"pending suggestion")} plus ${v(o,"legacy detached suggestion")} stored outside it, which cannot be previewed accepted together. Use show-tracked-changes or show-before-tracked-changes, or read the accepted text with a read tool.`,"verification",!1);const r=ue(n,t,i);if(r.basis==="displayed-history-revision")return{doc:{...e.getDocument()},snapshot:r};if(t==="show-with-tracked-changes-accepted"&&a===0&&o>0){const g=n.getDetachedSuggestionStore().materializeWithSuggestions(i.legacyIds);try{return{doc:A(g),snapshot:r}}finally{g.destroy()}}const s=new x.Doc;try{if(x.applyUpdate(s,x.encodeStateAsUpdate(n.getYDoc())),r.projectedSuggestionCount===0)return{doc:A(s),snapshot:r};const g=z.createSuggestionProjectionFromYDoc(s,t==="show-with-tracked-changes-accepted"?"accept":"reject",i.liveIds);try{return{doc:g.doc,snapshot:r}}finally{g.ydoc.destroy()}}finally{s.destroy()}}function pe(e){const t=e.createCanvas?.()??document.createElement("canvas");t.width=Math.ceil(e.geometry.pageWidth),t.height=Math.ceil(e.geometry.pageHeight);const n=t.getContext("2d");if(!n)throw new Error("The browser could not create a page canvas.");const i=C(e.themeElement);n.fillStyle=i.pageBackground,n.fillRect(0,0,t.width,t.height);const a=D(n),o=Q(n,t,e.layout,a);o.theme=i,o.currentPage=e.geometry.pageIndex,o.pageGeometry=e.geometry,o.yOffset=e.geometry.pageTop,o.startY=e.geometry.pageTop,o.endY=e.geometry.pageTop+e.geometry.pageHeight,o.pageLayoutSettings=e.pageLayoutSettings,o.headersContent=e.doc.headers,o.footersContent=e.doc.footers,o.watermark=V(e.doc.watermark),o.totalPages=e.computed.pageCount,o.lineNumberMarks=e.computed.lineNumberMarks,o.pageFontFamilies=X(e.computed,o.layout.fontFamily),o.headingPageNumbers=Z(e.computed),o.syntaxTheme=J(e.codeTheme||"solarized",i.isDark),ee(o,1);const r={diffDocument:e.doc,showCursor:!1,isFocused:!1,readOnly:!0,printPreview:!0,forceImagePlaceholders:e.forceImagePlaceholders};if(e.pageless){const s={startY:0,endY:e.geometry.pageHeight};te(o,e.editor,s,r)}else oe(o,e.editor,e.geometry.pageIndex,r);return e.mode==="layout"&&E(n,e.computed,e.geometry),t}function me(e,t,n,i){const a=n==="compact"?360:720,o=n==="compact"?Math.min(2,e.length):e.length,r=Math.ceil(e.length/o),s=16,g=16,l=26,d=e.map(p=>({width:a,height:Math.round(p.height/p.width*a)})),w=Array.from({length:r},(p,m)=>Math.max(...d.slice(m*o,(m+1)*o).map(f=>f.height+l))),u=i?.()??document.createElement("canvas");u.width=g*2+o*a+Math.max(0,o-1)*s,u.height=g*2+w.reduce((p,m)=>p+m,0)+Math.max(0,r-1)*s;const h=u.getContext("2d");if(!h)throw new Error("The browser could not create a page contact sheet.");h.fillStyle="#e5e7eb",h.fillRect(0,0,u.width,u.height),h.fillStyle="#111827",h.font="600 14px ui-sans-serif, system-ui, sans-serif",h.textBaseline="top";let y=g;for(let p=0;p<r;p+=1){for(let m=0;m<o;m+=1){const f=p*o+m;if(f>=e.length)break;const b=g+m*(a+s);h.fillText(`Page ${t[f]}`,b,y+4),h.drawImage(e[f],b,y+l,d[f].width,d[f].height),h.strokeStyle="#9ca3af",h.strokeRect(b,y+l,d[f].width,d[f].height)}y+=w[p]+s}return u}async function fe(e){const t=e.request.view??P;if(!O(t))throw new k("invalid_view",`Unknown render view "${String(t)}". Use show-tracked-changes, show-with-tracked-changes-accepted, or show-before-tracked-changes.`);const{doc:n,snapshot:i}=N(e.editor,t),a=C(e.themeElement),o=[],r=[];$(n,null,o,r),await ne(o,a.text);const s=e.createCanvas?.()??document.createElement("canvas");s.width=8,s.height=8;const g=s.getContext("2d");if(!g)throw new Error("The browser could not measure document pages.");const l=D(g),d=Y(n,l,e.layout),w=d.pageGeometries?.length?d.pageGeometries:[re(e.layout,d)],u=w.length,h=e.request.startPage-1;if(h<0||h>=u)throw new Error(`start_page ${e.request.startPage} is outside this ${u}-page document in the ${t} view.`);const y=w.slice(h,Math.min(u,h+e.request.pageCount)),p=new Set(y.map(c=>c.pageIndex)),m=ae(d,p),f=r.filter(c=>c.blockId===null||m.has(c.blockId)),b=await Promise.all(f.map(c=>c.permanentlyPlaceholder?Promise.resolve("placeholder"):B(c.src))),U=y.map(c=>pe({editor:e.editor,doc:n,layout:e.layout,computed:d,geometry:c,pageLayoutSettings:e.pageLayoutSettings,mode:e.request.mode,codeTheme:e.codeTheme,themeElement:e.themeElement,pageless:!!n.pageless,createCanvas:e.createCanvas})),I=y.map(c=>c.pageIndex+1),M=me(U,I,e.request.quality,e.createCanvas);let S;try{S=M.toDataURL("image/jpeg",e.request.quality==="compact"?.78:.9)}catch(c){throw typeof c=="object"&&c!==null&&"name"in c&&c.name==="SecurityError"?new k("visual_resource_unavailable","A document resource prevented safe page export. Re-upload external images and retry visual inspection.","verification",!1):c}const _=o.filter(c=>c.blockId===null||m.has(c.blockId)).filter(c=>{const T=G(c.content,c.displayMode,a.text);return T.loading||!T.image}).length;return{dataUrl:S,width:M.width,height:M.height,pages:I,totalPages:u,placeholderImageCount:b.filter(c=>c==="placeholder").length,failedImageCount:b.filter(c=>c==="failed").length,mathPlaceholderCount:_,view:t,snapshot:i}}export{N as captureAgentPageRenderSource,E as paintPageLayoutDiagnostics,fe as renderDocumentPagesForAgent};
@@ -0,0 +1 @@
1
+ import*as x from"yjs";import{K as P,L as O,S as k,M as C,N as D,O as Y,Q as B,T as G,U as A,z,V as K,W as Q,X as V,Y as X,Z,_ as J,$ as ee,a0 as te,a1 as oe}from"./index-2TBhRkX7.js";function $(e,t,n,i){if(Array.isArray(e)){for(const r of e)$(r,t,n,i);return}if(!e||typeof e!="object")return;const a=e,o=typeof a.id=="string"?a.id:t;a.type==="math"&&typeof a.content=="string"&&n.push({content:a.content,displayMode:a.displayMode!=="inline",blockId:o}),a.type==="text"&&typeof a.text=="string"&&a.marks?.latex&&n.push({content:a.text,displayMode:!1,blockId:o}),a.type==="image"&&typeof a.src=="string"&&i.push({src:a.src,blockId:o,permanentlyPlaceholder:a.originalFormat==="emf"||a.originalFormat==="wmf"});for(const r of Object.values(a))if(Array.isArray(r))for(const s of r)$(s,o,n,i);else r&&typeof r=="object"&&$(r,o,n,i)}function j(){return new Promise(e=>{let t=!1;const n=()=>{t||(t=!0,clearTimeout(i),e())},i=setTimeout(n,50);typeof requestAnimationFrame=="function"&&requestAnimationFrame(n)})}async function ne(e,t){if(e.length===0)return;const n=Promise.allSettled(e.map(i=>K(i.content,i.displayMode,t)));await Promise.race([n,new Promise(i=>setTimeout(i,2500))]),await j(),await j()}function R(e,t){if(typeof e.pageNumber=="number")return e.pageNumber-1;const n=e.bounds.y;return t.pageGeometries?.find(i=>n>=i.pageTop&&n<i.pageTop+i.pageHeight)?.pageIndex??0}function ae(e,t){return new Set(e.fragments.filter(n=>t.has(R(n,e))).map(n=>n.blockId))}function ie(e){return e==="table"?"#7c3aed":e==="table-cell"||e==="table-row"?"#db2777":e==="image"?"#ea580c":e==="container"?"#2563eb":e==="math"?"#ca8a04":"#0891b2"}function E(e,t,n){e.save(),e.lineWidth=.75,e.setLineDash([4,3]),e.strokeStyle="rgba(22, 163, 74, 0.9)",e.strokeRect(n.marginLeft,n.marginTop,n.pageWidth-n.marginLeft-n.marginRight,n.pageHeight-n.marginTop-n.marginBottom),e.setLineDash([]);const i=new Set;for(const a of t.fragments){if(R(a,t)!==n.pageIndex)continue;const{bounds:o}=a,r=o.relativeToPage?o.y:o.y-n.pageTop,s=`${a.blockId}:${Math.round(o.x)}:${Math.round(r)}:${Math.round(o.width)}:${Math.round(o.height)}`;if(i.has(s)||o.width<=0||o.height<=0)continue;i.add(s);const g=ie(a.block.type);if(e.strokeStyle=g,e.globalAlpha=.82,e.strokeRect(o.x,r,o.width,o.height),(a.block.type==="table"||a.block.type==="table-cell"||a.block.type==="image"||a.block.type==="container"||a.block.type==="math")&&o.width>=42&&o.height>=12){const l=`${a.block.type} #${a.blockId}`;e.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",e.textAlign="left",e.textBaseline="top";const d=Math.min(o.width,e.measureText(l).width+5);e.globalAlpha=.88,e.fillStyle=g,e.fillRect(o.x,Math.max(0,r),d,13),e.globalAlpha=1,e.fillStyle="#ffffff",e.fillText(l,o.x+2,Math.max(0,r)+1,Math.max(1,d-4))}}e.restore()}function re(e,t){return{pageIndex:0,sectionIndex:0,pageTop:0,pageWidth:e.pageWidth,pageHeight:Math.min(4096,Math.max(e.pageHeight,t.totalHeight)),marginTop:e.pageMarginTop??e.pageMargin,marginRight:e.pageMarginRight??e.pageMargin,marginBottom:e.pageMarginBottom??e.pageMargin,marginLeft:e.pageMarginLeft??e.pageMargin,showPageNumbers:!1,pageNumberPosition:"bottom-right",renderedPageNumber:1}}const L=new WeakMap;let q=0;function se(e){let t=L.get(e);return t||(q+=1,t=`session-${q}`,L.set(e,t)),t}const F=new WeakMap;let H=0;function ce(e){let t=F.get(e);return t===void 0&&(H+=1,t=H,F.set(e,t)),t}function W(e){let t=2166136261;for(const n of e.join("\0"))t^=n.codePointAt(0),t=Math.imul(t,16777619)>>>0;return t.toString(36)}function ge(e){const t=e.getDocumentSession?.();if(!t)throw new k("document_unavailable","Rendered page inspection needs a loaded document. Wait for the document to open, then retry.","verification",!1);return t}function de(e){const t=e.getDetachedSuggestionStore?.();return{liveIds:[...e.getDocumentMutator().getLiveSuggestionIds()].sort(),legacyIds:t?[...t.getPendingSuggestions().keys()].sort():[]}}function le(e,t){return t!==P?"live-pending-suggestion-projection":e.isHistoryOpen()?"displayed-history-revision":"displayed-document"}function v(e,t){return`${e} ${t}${e===1?"":"s"}`}function he(e,t,n,i){const a=i.liveIds.length,o=i.legacyIds.length,r=v(o,"legacy detached suggestion");if(e==="displayed-history-revision")return"The past revision the editor displays while the history view is open, not the live document. The live document's pending suggestions are not part of this image.";if(e==="displayed-document"){const d=`The document as the editor displays it, with ${v(a,"pending suggestion")} drawn as tracked changes.`;return o>0?`${d} ${r} ${o===1?"is":"are"} pending outside the document and not drawn; show-with-tracked-changes-accepted previews them.`:d}const s=n?"The live document, not the past revision the history view displays,":"The live document",g=n?"":"; this view equals show-tracked-changes",l="in a private preview; nothing was resolved in the document.";if(t==="show-with-tracked-changes-accepted")return a>0?`${s} with all ${v(a,"pending suggestion")} accepted ${l}`:o>0?`${s} with all ${r} applied ${l}`:`${s} has no pending suggestions to accept${g}.`;if(a>0){const d=o>0?` ${r} stored outside the document ${o===1?"is":"are"} absent here as well.`:"";return`${s} with all ${v(a,"pending suggestion")} rejected ${l}${d}`}return o>0?`${s} as it stands: its ${r} ${o===1?"is":"are"} stored outside the document, so there is nothing to reject${g}.`:`${s} has no pending suggestions to reject${g}.`}function ue(e,t,n){const i=e.getDocumentId(),a=se(e),o=e.getDocumentMutator().derivedDocumentRevision,r=e.isHistoryOpen(),s=le(e,t),g=n.liveIds.length,l=n.legacyIds.length,d=t==="show-with-tracked-changes-accepted"?g>0?g:l:t==="show-before-tracked-changes"?g:0,w=s==="displayed-history-revision"?[`h${ce(e.getCurrentDocument())}`]:[`r${o}`,`s${g}.${W(n.liveIds)}`,...l>0?[`l${l}.${W(n.legacyIds)}`]:[]],u=s==="displayed-history-revision"?{...e.getSelection(),diffEnabled:e.isDiffEnabled()}:void 0;return{documentId:i,sessionId:a,basis:s,historyOpen:r,revision:o,pendingSuggestionCount:g+l,legacyDetachedSuggestionCount:l,projectedSuggestionCount:d,...u?{historySelection:u}:{},description:he(s,t,r,n),key:[i,a,s,...w,t].join(":")}}function N(e,t){const n=ge(e),i=de(n),a=i.liveIds.length,o=i.legacyIds.length;if(t==="show-with-tracked-changes-accepted"&&a>0&&o>0)throw new k("render_view_unsupported",`This document has ${v(a,"pending suggestion")} plus ${v(o,"legacy detached suggestion")} stored outside it, which cannot be previewed accepted together. Use show-tracked-changes or show-before-tracked-changes, or read the accepted text with a read tool.`,"verification",!1);const r=ue(n,t,i);if(r.basis==="displayed-history-revision")return{doc:{...e.getDocument()},snapshot:r};if(t==="show-with-tracked-changes-accepted"&&a===0&&o>0){const g=n.getDetachedSuggestionStore().materializeWithSuggestions(i.legacyIds);try{return{doc:A(g),snapshot:r}}finally{g.destroy()}}const s=new x.Doc;try{if(x.applyUpdate(s,x.encodeStateAsUpdate(n.getYDoc())),r.projectedSuggestionCount===0)return{doc:A(s),snapshot:r};const g=z.createSuggestionProjectionFromYDoc(s,t==="show-with-tracked-changes-accepted"?"accept":"reject",i.liveIds);try{return{doc:g.doc,snapshot:r}}finally{g.ydoc.destroy()}}finally{s.destroy()}}function pe(e){const t=e.createCanvas?.()??document.createElement("canvas");t.width=Math.ceil(e.geometry.pageWidth),t.height=Math.ceil(e.geometry.pageHeight);const n=t.getContext("2d");if(!n)throw new Error("The browser could not create a page canvas.");const i=C(e.themeElement);n.fillStyle=i.pageBackground,n.fillRect(0,0,t.width,t.height);const a=D(n),o=Q(n,t,e.layout,a);o.theme=i,o.currentPage=e.geometry.pageIndex,o.pageGeometry=e.geometry,o.yOffset=e.geometry.pageTop,o.startY=e.geometry.pageTop,o.endY=e.geometry.pageTop+e.geometry.pageHeight,o.pageLayoutSettings=e.pageLayoutSettings,o.headersContent=e.doc.headers,o.footersContent=e.doc.footers,o.watermark=V(e.doc.watermark),o.totalPages=e.computed.pageCount,o.lineNumberMarks=e.computed.lineNumberMarks,o.pageFontFamilies=X(e.computed,o.layout.fontFamily),o.headingPageNumbers=Z(e.computed),o.syntaxTheme=J(e.codeTheme||"solarized",i.isDark),ee(o,1);const r={diffDocument:e.doc,showCursor:!1,isFocused:!1,readOnly:!0,printPreview:!0,forceImagePlaceholders:e.forceImagePlaceholders};if(e.pageless){const s={startY:0,endY:e.geometry.pageHeight};te(o,e.editor,s,r)}else oe(o,e.editor,e.geometry.pageIndex,r);return e.mode==="layout"&&E(n,e.computed,e.geometry),t}function me(e,t,n,i){const a=n==="compact"?360:720,o=n==="compact"?Math.min(2,e.length):e.length,r=Math.ceil(e.length/o),s=16,g=16,l=26,d=e.map(p=>({width:a,height:Math.round(p.height/p.width*a)})),w=Array.from({length:r},(p,m)=>Math.max(...d.slice(m*o,(m+1)*o).map(f=>f.height+l))),u=i?.()??document.createElement("canvas");u.width=g*2+o*a+Math.max(0,o-1)*s,u.height=g*2+w.reduce((p,m)=>p+m,0)+Math.max(0,r-1)*s;const h=u.getContext("2d");if(!h)throw new Error("The browser could not create a page contact sheet.");h.fillStyle="#e5e7eb",h.fillRect(0,0,u.width,u.height),h.fillStyle="#111827",h.font="600 14px ui-sans-serif, system-ui, sans-serif",h.textBaseline="top";let y=g;for(let p=0;p<r;p+=1){for(let m=0;m<o;m+=1){const f=p*o+m;if(f>=e.length)break;const b=g+m*(a+s);h.fillText(`Page ${t[f]}`,b,y+4),h.drawImage(e[f],b,y+l,d[f].width,d[f].height),h.strokeStyle="#9ca3af",h.strokeRect(b,y+l,d[f].width,d[f].height)}y+=w[p]+s}return u}async function fe(e){const t=e.request.view??P;if(!O(t))throw new k("invalid_view",`Unknown render view "${String(t)}". Use show-tracked-changes, show-with-tracked-changes-accepted, or show-before-tracked-changes.`);const{doc:n,snapshot:i}=N(e.editor,t),a=C(e.themeElement),o=[],r=[];$(n,null,o,r),await ne(o,a.text);const s=e.createCanvas?.()??document.createElement("canvas");s.width=8,s.height=8;const g=s.getContext("2d");if(!g)throw new Error("The browser could not measure document pages.");const l=D(g),d=Y(n,l,e.layout),w=d.pageGeometries?.length?d.pageGeometries:[re(e.layout,d)],u=w.length,h=e.request.startPage-1;if(h<0||h>=u)throw new Error(`start_page ${e.request.startPage} is outside this ${u}-page document in the ${t} view.`);const y=w.slice(h,Math.min(u,h+e.request.pageCount)),p=new Set(y.map(c=>c.pageIndex)),m=ae(d,p),f=r.filter(c=>c.blockId===null||m.has(c.blockId)),b=await Promise.all(f.map(c=>c.permanentlyPlaceholder?Promise.resolve("placeholder"):B(c.src))),U=y.map(c=>pe({editor:e.editor,doc:n,layout:e.layout,computed:d,geometry:c,pageLayoutSettings:e.pageLayoutSettings,mode:e.request.mode,codeTheme:e.codeTheme,themeElement:e.themeElement,pageless:!!n.pageless,createCanvas:e.createCanvas})),I=y.map(c=>c.pageIndex+1),M=me(U,I,e.request.quality,e.createCanvas);let S;try{S=M.toDataURL("image/jpeg",e.request.quality==="compact"?.78:.9)}catch(c){throw typeof c=="object"&&c!==null&&"name"in c&&c.name==="SecurityError"?new k("visual_resource_unavailable","A document resource prevented safe page export. Re-upload external images and retry visual inspection.","verification",!1):c}const _=o.filter(c=>c.blockId===null||m.has(c.blockId)).filter(c=>{const T=G(c.content,c.displayMode,a.text);return T.loading||!T.image}).length;return{dataUrl:S,width:M.width,height:M.height,pages:I,totalPages:u,placeholderImageCount:b.filter(c=>c==="placeholder").length,failedImageCount:b.filter(c=>c==="failed").length,mathPlaceholderCount:_,view:t,snapshot:i}}export{N as captureAgentPageRenderSource,E as paintPageLayoutDiagnostics,fe as renderDocumentPagesForAgent};
@@ -0,0 +1 @@
1
+ import{a2 as l,a3 as y,a4 as D}from"./index-2TBhRkX7.js";const w="This attachment was stored in an older per-page image format that cannot be imported. Ask the user to re-attach the original file.";async function k(n){if(n.type==="pdf"&&(n.urls?.length??0)>1)throw new Error(w);const o=n.urls?.[0];if(!o)throw new Error("The attachment no longer has an importable file URL.");const r=await fetch(o);if(!r.ok)throw new Error(`Could not download the attachment (${r.status}).`);const e=await r.blob();if(e.type.startsWith("image/"))throw new Error(w);const t=n.type==="pdf"?"attachment.pdf":"attachment.docx";return new File([e],n.fileName||t,{type:n.mimeType||e.type})}async function b(n){const{attachment:o,documentId:r,documentSession:e}=n;let t=n.afterBlockId?.trim()||void 0;if(o.type!=="docx"&&o.type!=="pdf")throw new Error("Only DOCX and PDF attachments can be imported into the document.");const s=e.getWorkingDocument(),f=s.children.length,p=l(s);if(!p&&!t&&l(e.getDocumentWithPendingSuggestionsApplied())&&(t=s.children.at(-1)?.id),!p&&!t)throw new Error("The current document has content. Provide after_block_id to insert the attachment after a current top-level block without replacing existing content.");if(t&&!s.children.some(a=>a.id===t))throw new Error(`Block "${t}" was not found as a top-level insertion anchor. Read the document and use a current top-level block ID.`);const m=await k(o);let g;if(o.type==="docx"){const{FileImporter:a}=await import("./FileImporter-DObFoCCn.js"),h=await a.parseFile(m),i=e.getYDoc();if(t)g=y(i,h,t);else{if(!l(e.getWorkingDocument()))throw new Error("The current document is no longer empty; import was cancelled. Read the document and provide after_block_id to insert the attachment without replacing existing content.");const d=h.pendingDocxCarrier;if(delete h.pendingDocxCarrier,i.transact(()=>{const c=i.getXmlFragment("content");c.length>0&&c.delete(0,c.length),D(i,h)}),d){const{storeDocxCarrier:c}=await import("./DocxGraft-BRKh4mHQ.js");await c(i,d.bytes,{hash:d.hash})}}}else{const{importPdfIntoExistingDocument:a}=await import("./PdfImportService-BhLPp5uG.js");await a(m,r,e.getYDoc(),void 0,t)}const u=e.getWorkingDocument();return{blockCount:g??(t?Math.max(0,u.children.length-f):u.children.length),fileName:o.fileName||m.name}}export{b as importAttachmentIntoDocument,l as isEmptyDocumentForAttachmentImport};
@@ -0,0 +1 @@
1
+ import{a2 as l,a3 as y,a4 as D}from"./index-BwcX_r62.js";const w="This attachment was stored in an older per-page image format that cannot be imported. Ask the user to re-attach the original file.";async function k(n){if(n.type==="pdf"&&(n.urls?.length??0)>1)throw new Error(w);const o=n.urls?.[0];if(!o)throw new Error("The attachment no longer has an importable file URL.");const r=await fetch(o);if(!r.ok)throw new Error(`Could not download the attachment (${r.status}).`);const e=await r.blob();if(e.type.startsWith("image/"))throw new Error(w);const t=n.type==="pdf"?"attachment.pdf":"attachment.docx";return new File([e],n.fileName||t,{type:n.mimeType||e.type})}async function b(n){const{attachment:o,documentId:r,documentSession:e}=n;let t=n.afterBlockId?.trim()||void 0;if(o.type!=="docx"&&o.type!=="pdf")throw new Error("Only DOCX and PDF attachments can be imported into the document.");const s=e.getWorkingDocument(),f=s.children.length,p=l(s);if(!p&&!t&&l(e.getDocumentWithPendingSuggestionsApplied())&&(t=s.children.at(-1)?.id),!p&&!t)throw new Error("The current document has content. Provide after_block_id to insert the attachment after a current top-level block without replacing existing content.");if(t&&!s.children.some(a=>a.id===t))throw new Error(`Block "${t}" was not found as a top-level insertion anchor. Read the document and use a current top-level block ID.`);const m=await k(o);let g;if(o.type==="docx"){const{FileImporter:a}=await import("./FileImporter-CszqRfVU.js"),h=await a.parseFile(m),i=e.getYDoc();if(t)g=y(i,h,t);else{if(!l(e.getWorkingDocument()))throw new Error("The current document is no longer empty; import was cancelled. Read the document and provide after_block_id to insert the attachment without replacing existing content.");const d=h.pendingDocxCarrier;if(delete h.pendingDocxCarrier,i.transact(()=>{const c=i.getXmlFragment("content");c.length>0&&c.delete(0,c.length),D(i,h)}),d){const{storeDocxCarrier:c}=await import("./DocxGraft-C9MBQCnf.js");await c(i,d.bytes,{hash:d.hash})}}}else{const{importPdfIntoExistingDocument:a}=await import("./PdfImportService-xbzrN__L.js");await a(m,r,e.getYDoc(),void 0,t)}const u=e.getWorkingDocument();return{blockCount:g??(t?Math.max(0,u.children.length-f):u.children.length),fileName:o.fileName||m.name}}export{b as importAttachmentIntoDocument,l as isEmptyDocumentForAttachmentImport};
@@ -1,31 +1,31 @@
1
- import{r as Ir,e as wn,c as xn}from"./MathRenderer-B0Y1h1JU.js";import{bG as Lr}from"./backend-BIhAX-Gi.js";const Fr={js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",ts:"typescript",
1
+ import{r as jr,e as wn,c as xn}from"./MathRenderer-DT6GyJXb.js";import{bJ as Lr}from"./backend-DecaBz-I.js";const Fr={js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",ts:"typescript",
2
2
  tsx:"tsx",mts:"typescript",cts:"typescript",py:"python",python3:"python",py3:"python","c++":"cpp",cxx:"cpp",cc:"cpp",hpp:"cpp",h:"c",cs:"c_sharp",csharp:"c_sharp","c#":"c_sharp",golang:"go",rs:"rust",
3
3
  rb:"ruby",sh:"bash",shell:"bash",zsh:"bash",htm:"html",yml:"yaml",kt:"kotlin",kts:"kotlin",ex:"elixir",exs:"elixir",sol:"solidity",ml:"ocaml",mli:"ocaml",plaintext:"text",plain:"text",txt:"text"},_n=new Set(
4
4
  ["javascript","typescript","tsx","python","java","c","cpp","c_sharp","go","rust","ruby","php","swift","kotlin","scala","bash","css","html","json","yaml","toml","lua","elixir","dart","vue","zig","elm",
5
- "solidity","ocaml"]);function Jt(t){const e=t.toLowerCase().trim();if(Fr[e]){const n=Fr[e];return n==="text"?null:n}return _n.has(e)?e:null}const $e={keyword:"#0000FF",string:"#A31515",number:"#098658",
5
+ "solidity","ocaml"]);function Ut(t){const e=t.toLowerCase().trim();if(Fr[e]){const n=Fr[e];return n==="text"?null:n}return _n.has(e)?e:null}const $e={keyword:"#0000FF",string:"#A31515",number:"#098658",
6
6
  comment:"#008000",function:"#795E26",variable:"#001080",operator:"#000000",punctuation:"#000000",type:"#267F99",property:"#001080",constant:"#0070C1",default:"#000000",background:"#ffffff",text:"#0000\
7
- 00"};let kt=null,Vt=new Map,Qt=new Map,wt=new Set,Er=!1;function Bn(t){return typeof t=="object"&&t!==null&&"status"in t&&t.status===404?!0:(t instanceof Error?t.message:typeof t=="string"?t:"").includes(
8
- "status 404")}function jn(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e^t.charCodeAt(n);return(e>>>0).toString(36)}function Cn(t,e){return["const","let","var","function","return","if","else","fo\
7
+ 00"};let kt=null,Jt=new Map,Vt=new Map,wt=new Set,Er=!1;function Bn(t){return typeof t=="object"&&t!==null&&"status"in t&&t.status===404?!0:(t instanceof Error?t.message:typeof t=="string"?t:"").includes(
8
+ "status 404")}function Cn(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e^t.charCodeAt(n);return(e>>>0).toString(36)}function Mn(t,e){return["const","let","var","function","return","if","else","fo\
9
9
  r","while","do","switch","case","break","continue","try","catch","finally","throw","new","delete","typeof","instanceof","void","in","of","class","extends","static","get","set","async","await","yield",
10
10
  "import","export","from","as","default","this","super"].includes(t)?"keyword":["string","template_string","string_fragment","template_literal"].includes(t)?"string":["number","integer","float"].includes(
11
11
  t)?"number":["comment","line_comment","block_comment"].includes(t)?"comment":t==="identifier"&&(e==="function_declaration"||e==="call_expression"||e==="method_definition")?"function":["type_identifier",
12
12
  "predefined_type","type_annotation"].includes(t)?"type":t==="property_identifier"||e==="member_expression"?"property":["true","false","null","undefined"].includes(t)?"constant":["+","-","*","/","%","=",
13
13
  "==","===","!=","!==","<",">","<=",">=","&&","||","!","&","|","^","~","<<",">>",">>>","++","--","+=","-=","*=","/=","?",":","=>"].includes(t)?"operator":["(",")","{","}","[","]",";",",",".","..."].includes(
14
14
  t)?"punctuation":t==="identifier"?"variable":"default"}function Pe(){return typeof window>"u"||globalThis.__reviseServerRuntime===!0}async function qr(){if(kt)return kt;const t=(async()=>{const e=(await import("./web-tree-sitter-BXGZGnNj.js")).
15
- Parser;await e.init({locateFile:r=>Ir(`tree-sitter/${r}`)});const n=new e;return Er=!0,n})();return t.catch(()=>{kt===t&&(kt=null)}),kt=t,t}async function Nr(t){if(Vt.has(t))return Vt.get(t);if(wt.has(
16
- t))return null;if(Qt.has(t))return Qt.get(t);const e=(async()=>{try{const n=await(await import("./web-tree-sitter-BXGZGnNj.js")).Language.load(Ir(`tree-sitter/tree-sitter-${t}.wasm`));return Vt.set(t,
15
+ Parser;await e.init({locateFile:r=>jr(`tree-sitter/${r}`)});const n=new e;return Er=!0,n})();return t.catch(()=>{kt===t&&(kt=null)}),kt=t,t}async function Nr(t){if(Jt.has(t))return Jt.get(t);if(wt.has(
16
+ t))return null;if(Vt.has(t))return Vt.get(t);const e=(async()=>{try{const n=await(await import("./web-tree-sitter-BXGZGnNj.js")).Language.load(jr(`tree-sitter/tree-sitter-${t}.wasm`));return Jt.set(t,
17
17
  n),n}catch(n){return Bn(n)?(wt.add(t),console.warn(`Tree-sitter grammar not found for ${t} (404). Disabling syntax highlighting for this language.`),null):(console.warn(`Failed to load tree-sitter gra\
18
- mmar for ${t}:`,n),null)}finally{Qt.delete(t)}})();return Qt.set(t,e),e}function Dr(t,e){if(t.childCount===0)e.push({start:t.startIndex,end:t.endIndex,type:t.type,parentType:t.parent?.type});else for(let n=0;n<
19
- t.childCount;n++)Dr(t.child(n),e)}function Mn(t="javascript"){const e=Jt(t);return e?Er&&Vt.has(e):!0}async function Sn(t="javascript"){if(Pe())return!1;const e=Jt(t);if(!e)return!0;if(wt.has(e))return!1;
18
+ mmar for ${t}:`,n),null)}finally{Vt.delete(t)}})();return Vt.set(t,e),e}function Dr(t,e){if(t.childCount===0)e.push({start:t.startIndex,end:t.endIndex,type:t.type,parentType:t.parent?.type});else for(let n=0;n<
19
+ t.childCount;n++)Dr(t.child(n),e)}function Sn(t="javascript"){const e=Ut(t);return e?Er&&Jt.has(e):!0}async function In(t="javascript"){if(Pe())return!1;const e=Ut(t);if(!e)return!0;if(wt.has(e))return!1;
20
20
  try{const n=await qr(),r=await Nr(e);return r?(n.setLanguage(r),!0):!1}catch(n){return console.warn("Failed to preload syntax highlighter:",n),!1}}async function Re(t,e="javascript",n=$e){if(Pe())return null;
21
- const r=Jt(e);if(!r||wt.has(r))return null;try{const a=await qr(),o=await Nr(r);if(!o)return null;a.setLanguage(o);const l=a.parse(t),s=[];Dr(l.rootNode,s),s.sort((h,N)=>h.start-N.start);const f=[];let m=0;
22
- for(const h of s){if(h.start>m){const w=t.slice(m,h.start);w&&f.push({text:w,color:n.default})}const N=t.slice(h.start,h.end);if(N){const w=Cn(h.type,h.parentType);f.push({text:N,color:n[w]})}m=h.end}
23
- return m<t.length&&f.push({text:t.slice(m),color:n.default}),f}catch(a){return console.warn("Syntax highlighting failed:",a),null}}let lt=new Map;const In=100;function Ln(t,e="javascript",n){if(Pe())return null;
24
- const r=Jt(e);if(!r||wt.has(r))return null;const a=n||$e,o=a.keyword+a.string,l=`${r}:${o}:${jn(t)}`;if(lt.has(l))return lt.get(l);const s=(f,m)=>{if(lt.size>=In){const h=lt.keys().next().value;h&&lt.
25
- delete(h)}lt.set(f,m)};return Mn(r)?(Re(t,r,a).then(f=>{f&&s(l,f)}),null):(Re(t,r,a).then(f=>{f&&(s(l,f),typeof window<"u"&&window.dispatchEvent(new CustomEvent("syntax-highlight-ready")))}),null)}const xt=180,
26
- ze=new Map,Gt=new Map,Tr=new Map,$r=new Map,Fn=new Set,J=new Map;let Ae=null,Pr=0;function G(t){return t.trim().toLowerCase()}function Rr(t){return[t.background,t.text,t.selection,t.pageBorder,t.pageBackground,
27
- t.codeBackground,t.codeBorder,t.codeText,t.diffInsert,t.diffDelete].join("|")}function Oe(t){const e=G(t.protocol),n=Math.max(120,Math.round(t.maxWidth));return`${e}:${n}:${Rr(t.theme)}:${t.source}`}function Kt(t){
28
- const e=G(t.protocol),n=Math.max(120,Math.round(t.maxWidth));return`${e}:${n}:${Rr(t.theme)}`}function zr(t){const e=Kt(t);return Tr.get(e)||{width:Math.max(120,Math.round(t.maxWidth)),height:xt}}function We(t){
21
+ const r=Ut(e);if(!r||wt.has(r))return null;try{const a=await qr(),o=await Nr(r);if(!o)return null;a.setLanguage(o);const l=a.parse(t),s=[];Dr(l.rootNode,s),s.sort((h,N)=>h.start-N.start);const f=[];let m=0;
22
+ for(const h of s){if(h.start>m){const w=t.slice(m,h.start);w&&f.push({text:w,color:n.default})}const N=t.slice(h.start,h.end);if(N){const w=Mn(h.type,h.parentType);f.push({text:N,color:n[w]})}m=h.end}
23
+ return m<t.length&&f.push({text:t.slice(m),color:n.default}),f}catch(a){return console.warn("Syntax highlighting failed:",a),null}}let lt=new Map;const jn=100;function Ln(t,e="javascript",n){if(Pe())return null;
24
+ const r=Ut(e);if(!r||wt.has(r))return null;const a=n||$e,o=a.keyword+a.string,l=`${r}:${o}:${Cn(t)}`;if(lt.has(l))return lt.get(l);const s=(f,m)=>{if(lt.size>=jn){const h=lt.keys().next().value;h&&lt.
25
+ delete(h)}lt.set(f,m)};return Sn(r)?(Re(t,r,a).then(f=>{f&&s(l,f)}),null):(Re(t,r,a).then(f=>{f&&(s(l,f),typeof window<"u"&&window.dispatchEvent(new CustomEvent("syntax-highlight-ready")))}),null)}const xt=180,
26
+ ze=new Map,Qt=new Map,Tr=new Map,$r=new Map,Fn=new Set,U=new Map;let Ae=null,Pr=0;function Q(t){return t.trim().toLowerCase()}function Rr(t){return[t.background,t.text,t.selection,t.pageBorder,t.pageBackground,
27
+ t.codeBackground,t.codeBorder,t.codeText,t.diffInsert,t.diffDelete].join("|")}function Oe(t){const e=Q(t.protocol),n=Math.max(120,Math.round(t.maxWidth));return`${e}:${n}:${Rr(t.theme)}:${t.source}`}function Kt(t){
28
+ const e=Q(t.protocol),n=Math.max(120,Math.round(t.maxWidth));return`${e}:${n}:${Rr(t.theme)}`}function zr(t){const e=Kt(t);return Tr.get(e)||{width:Math.max(120,Math.round(t.maxWidth)),height:xt}}function We(t){
29
29
  return t.replace(/\s+/g," ").trim()}function En(t){if(t instanceof Error&&t.message)return We(t.message);if(typeof t=="string"&&t.trim())return We(t);if(t&&typeof t=="object"){const e=t,n=typeof e.message==
30
30
  "string"&&e.message||typeof e.str=="string"&&e.str||"",r=typeof e.hash=="object"&&e.hash?e.hash:null,a=r&&typeof r.line=="number"&&Number.isFinite(r.line)?r.line+1:null,o=r&&typeof r.loc=="object"&&r.
31
31
  loc?r.loc:null,l=o&&typeof o.first_column=="number"&&Number.isFinite(o.first_column)?o.first_column+1:null,s=a!==null?`Line ${a}${l!==null?`, col ${l}`:""}: `:"";if(n.trim())return`${s}${We(n)}`}return"\
@@ -49,36 +49,36 @@ text,cScaleLabel1:t.text,cScaleLabel2:t.text}}function Ar(t){if(typeof document>
49
49
  id",renderToSvg:async(t,e)=>{const n=await zn();if(!n)throw new Error("Mermaid runtime unavailable");n.initialize({startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0,theme:"base",themeVariables:An(
50
50
  e)}),Pr+=1;const r=`revise-mermaid-${Pr}`;Ar(r);let a;try{a=await n.render(r,t)}finally{Ar(r)}const o=typeof a=="string"?a:a?.svg;if(!o||typeof o!="string")throw new Error("Mermaid returned invalid SV\
51
51
  G output");const l=Tn(o);return{svg:o,width:l.width,height:l.height}}};function Or(t,e){return{protocol:t,renderToSvg:async(n,r)=>{const a=n.trim();if(!a)throw new Error("LaTeX source is empty");await wn(
52
- a,e,r.text);const o=xn(a,e,r.text);if(!o?.svg)throw new Error("LaTeX render unavailable");return{svg:o.svg,width:o.width,height:o.height}}}}function Wr(){J.has("mermaid")||J.set("mermaid",On),J.has("l\
53
- atex")||J.set("latex",Or("latex",!0)),J.has("latex-inline")||J.set("latex-inline",Or("latex-inline",!1))}async function Wn(t){Wr();const e=G(t.protocol),n=J.get(e);if(!n)return{image:null,width:t.maxWidth,
52
+ a,e,r.text);const o=xn(a,e,r.text);if(!o?.svg)throw new Error("LaTeX render unavailable");return{svg:o.svg,width:o.width,height:o.height}}}}function Wr(){U.has("mermaid")||U.set("mermaid",On),U.has("l\
53
+ atex")||U.set("latex",Or("latex",!0)),U.has("latex-inline")||U.set("latex-inline",Or("latex-inline",!1))}async function Wn(t){Wr();const e=Q(t.protocol),n=U.get(e);if(!n)return{image:null,width:t.maxWidth,
54
54
  height:xt,loading:!1,error:`Unsupported diagram protocol: ${t.protocol}`};try{const{svg:r,width:a,height:o}=await n.renderToSvg(t.source,t.theme),l=$n(a,o,t.maxWidth);qn(t,l.width,l.height);const s={image:await Pn(
55
55
  r,l.width,l.height),svg:r,width:l.width,height:l.height,loading:!1};return Nn(t,s),s}catch(r){const a=zr(t);return{image:null,width:a.width,height:a.height,loading:!1,error:En(r)}}}function Xr(t){if(!t)
56
- return null;Wr();const e=G(t);return J.has(e)?e:null}function Xe(t){const e=G(t.protocol);if(!e||!t.source.trim())return{image:null,width:t.maxWidth,height:xt,loading:!1,error:"Diagram source is empty"};
57
- const n={...t,protocol:e,source:t.source},r=Oe(n),a=ze.get(r);if(a)return a;if(!Gt.has(r)){const f=Wn(n).then(m=>(ze.set(r,m),Gt.delete(r),Dn(),m));Gt.set(r,f)}const o=Kt(n),l=$r.get(o);if(l)return{image:l.
58
- image,svg:l.svg,width:l.width,height:l.height,loading:!0};const s=zr(n);return{image:null,width:s.width,height:s.height,loading:!0}}async function Zr(t){const e=Xe(t);if(!e.loading)return e;const n=Oe(
59
- {...t,protocol:G(t.protocol)});return Gt.get(n)||Xe(t)}function Hr(t){const e=Oe({...t,protocol:G(t.protocol)}),n=ze.get(e);return!n||n.loading?null:n}function Xn(t){const e=Hr(t);return!e||!e.svg?null:
60
- {svg:e.svg,width:e.width,height:e.height}}function Zn(t){if(typeof document>"u")return null;const e=Hr(t);if(!e||!e.image)return null;try{return{dataUrl:Rn(e.image),width:e.width,height:e.height}}catch{
61
- return null}}async function Hn(t,e,n){const r=[],a=o=>{if(!(!o||typeof o!="object")){if(o.type==="code"){const l=Xr(o.language);l&&o.renderDiagram!==!1&&o.content?.trim()&&r.push({protocol:l,source:o.
56
+ return null;Wr();const e=Q(t);return U.has(e)?e:null}function Xe(t){const e=Q(t.protocol);if(!e||!t.source.trim())return{image:null,width:t.maxWidth,height:xt,loading:!1,error:"Diagram source is empty"};
57
+ const n={...t,protocol:e,source:t.source},r=Oe(n),a=ze.get(r);if(a)return a;if(!Qt.has(r)){const f=Wn(n).then(m=>(ze.set(r,m),Qt.delete(r),Dn(),m));Qt.set(r,f)}const o=Kt(n),l=$r.get(o);if(l)return{image:l.
58
+ image,svg:l.svg,width:l.width,height:l.height,loading:!0};const s=zr(n);return{image:null,width:s.width,height:s.height,loading:!0}}async function Gr(t){const e=Xe(t);if(!e.loading)return e;const n=Oe(
59
+ {...t,protocol:Q(t.protocol)});return Qt.get(n)||Xe(t)}function Zr(t){const e=Oe({...t,protocol:Q(t.protocol)}),n=ze.get(e);return!n||n.loading?null:n}function Xn(t){const e=Zr(t);return!e||!e.svg?null:
60
+ {svg:e.svg,width:e.width,height:e.height}}function Gn(t){if(typeof document>"u")return null;const e=Zr(t);if(!e||!e.image)return null;try{return{dataUrl:Rn(e.image),width:e.width,height:e.height}}catch{
61
+ return null}}async function Zn(t,e,n){const r=[],a=o=>{if(!(!o||typeof o!="object")){if(o.type==="code"){const l=Xr(o.language);l&&o.renderDiagram!==!1&&o.content?.trim()&&r.push({protocol:l,source:o.
62
62
  content,theme:e,maxWidth:n});return}if(o.type==="container"||o.type==="table-cell"){for(const l of o.children||[])a(l);return}if(o.type==="table")for(const l of o.children||[])for(const s of l.children||
63
- [])for(const f of s.children||[])a(f)}};for(const o of t.children)a(o);r.length!==0&&await Promise.all(r.map(o=>Zr(o)))}const Ur={isDark:!1,background:"#f5f5f5",text:"#000000",linkText:"#007bff",selection:"\
63
+ [])for(const f of s.children||[])a(f)}};for(const o of t.children)a(o);r.length!==0&&await Promise.all(r.map(o=>Gr(o)))}const Hr={isDark:!1,background:"#f5f5f5",text:"#000000",linkText:"#007bff",selection:"\
64
64
  #3390ff",selectionOpacity:.4,inactiveSelection:"#9ac0e8",inactiveSelectionOpacity:.35,agentReadHighlight:"#7aaee6",searchHighlight:"#cc8f00",cursor:"#000000",pageBorder:"#dee2e6",pageBackground:"#ffff\
65
65
  ff",pageShadow:"rgba(0, 0, 0, 0.1)",diffInsert:"#22c55e",diffDelete:"#CF2A2A",diffEqual:"#000000",diffFormatChange:"#f59e0b",diffInsertText:"#0B8237",diffDeleteText:"#CF2A2A",diffFormatChangeText:"#78\
66
66
  350f",debugText:"#ff0000",todoCheckboxBorder:"#c8ccd5",todoCheckboxBackground:"#ffffff",todoCheckboxChecked:"#46b35e",todoCheckboxCheckmark:"#46b35e",todoCheckedText:"#6c757d",codeBackground:"#f5f5f5",
67
- codeBorder:"#e0e0e0",codeText:"#333333"},Un={isDark:!0,background:"#080a0e",text:"#c9c9c9",linkText:"#4099ff",selection:"#4099ff",selectionOpacity:.4,inactiveSelection:"#5a7a9e",inactiveSelectionOpacity:.35,
67
+ codeBorder:"#e0e0e0",codeText:"#333333"},Hn={isDark:!0,background:"#080a0e",text:"#c9c9c9",linkText:"#4099ff",selection:"#4099ff",selectionOpacity:.4,inactiveSelection:"#5a7a9e",inactiveSelectionOpacity:.35,
68
68
  agentReadHighlight:"#24568f",searchHighlight:"#fbbf24",cursor:"#ffffff",pageBorder:"#1e2430",pageBackground:"#05060a",pageShadow:"rgba(0, 0, 0, 0.5)",diffInsert:"#50B173",diffDelete:"#f87171",diffEqual:"\
69
69
  #c9c9c9",diffFormatChange:"#fbbf24",diffInsertText:"#50B173",diffDeleteText:"#f87171",diffFormatChangeText:"#f5a91d",debugText:"#ff6b6b",todoCheckboxBorder:"#2f3747",todoCheckboxBackground:"#05060a",todoCheckboxChecked:"\
70
- #0e6b30",todoCheckboxCheckmark:"#f3f7ff",todoCheckedText:"#6f7689",codeBackground:"#0c0f15",codeBorder:"#2a2f3a",codeText:"#c9c9c9"};function Jn(t){if(typeof window>"u")return!1;const e=t?.closest?.("\
71
- [data-theme]")?.getAttribute("data-theme");return e==="dark"?!0:e==="light"?!1:document.documentElement.classList.contains("dark")||document.documentElement.classList.contains("dark-theme")}function Jr(t){
72
- const e=Jn(t)?Un:Ur,n=t?.closest?.("[data-page-background]")?.getAttribute("data-page-background");return n?{...e,pageBackground:n}:e}function Vn(t,e){const n=parseInt(t.slice(1,3),16),r=parseInt(t.slice(
73
- 3,5),16),a=parseInt(t.slice(5,7),16);return`rgba(${n}, ${r}, ${a}, ${e})`}const Vr=["bold","italic","underline","strikethrough","doubleStrikethrough","smallCaps","allCaps","letterSpacing","code","late\
74
- x","superscript","subscript","backgroundColor","link"],Qn=Vr.reduce((t,e)=>(t[e]=null,t),{}),Gn=[],Ze={yellow:"#FDE68A",orange:"#FED7AA",green:"#BBF7D0",blue:"#BFDBFE",purple:"#E9D5FF",pink:"#FBCFE8",
75
- gray:"#E5E7EB"},Kn={yellow:"#7C5E10",orange:"#7C3F16",green:"#1F5F3A",blue:"#1E4E8C",purple:"#5B3A7A",pink:"#7A3F66",gray:"#4B5563"},Qr=Ze,Gr=["yellow","orange","green","blue","purple","pink","gray"],
70
+ #0e6b30",todoCheckboxCheckmark:"#f3f7ff",todoCheckedText:"#6f7689",codeBackground:"#0c0f15",codeBorder:"#2a2f3a",codeText:"#c9c9c9"};function Un(t){if(typeof window>"u")return!1;const e=t?.closest?.("\
71
+ [data-theme]")?.getAttribute("data-theme");return e==="dark"?!0:e==="light"?!1:document.documentElement.classList.contains("dark")||document.documentElement.classList.contains("dark-theme")}function Ur(t){
72
+ const e=Un(t)?Hn:Hr,n=t?.closest?.("[data-page-background]")?.getAttribute("data-page-background");return n?{...e,pageBackground:n}:e}function Jn(t,e){const n=parseInt(t.slice(1,3),16),r=parseInt(t.slice(
73
+ 3,5),16),a=parseInt(t.slice(5,7),16);return`rgba(${n}, ${r}, ${a}, ${e})`}const Jr=["bold","italic","underline","strikethrough","doubleStrikethrough","smallCaps","allCaps","letterSpacing","code","late\
74
+ x","superscript","subscript","backgroundColor","link"],Vn=Jr.reduce((t,e)=>(t[e]=null,t),{}),Qn=[],Ge={yellow:"#FDE68A",orange:"#FED7AA",green:"#BBF7D0",blue:"#BFDBFE",purple:"#E9D5FF",pink:"#FBCFE8",
75
+ gray:"#E5E7EB"},Kn={yellow:"#7C5E10",orange:"#7C3F16",green:"#1F5F3A",blue:"#1E4E8C",purple:"#5B3A7A",pink:"#7A3F66",gray:"#4B5563"},Vr=Ge,Qr=["yellow","orange","green","blue","purple","pink","gray"],
76
76
  Yn={yellow:"yellow",gold:"yellow",orange:"orange",darkorange:"orange",darkyellow:"orange",green:"green",darkgreen:"green",blue:"blue",cyan:"blue",darkblue:"blue",darkcyan:"blue",purple:"purple",violet:"\
77
77
  purple",darkviolet:"purple",darkmagenta:"purple",pink:"pink",magenta:"pink",red:"pink",darkred:"pink",gray:"gray",grey:"gray",lightgray:"gray",lightgrey:"gray",darkgray:"gray",darkgrey:"gray",black:"g\
78
78
  ray",white:"gray"},ta={yellow:"yellow",gold:"yellow",orange:"orange",green:"green",blue:"blue",cyan:"blue",purple:"purple",violet:"purple",pink:"pink",magenta:"pink",red:"pink",gray:"gray",grey:"gray",
79
79
  lightgray:"gray",lightgrey:"gray"},ea="yellow";function ra(t){if(!t)return;const e=t.trim().toLowerCase().replace(/[\s_-]+/g,"");return Yn[e]}function na(t){return Yt(t)}function aa(t){const e=Yt(t);return e?
80
- Qr[e]:void 0}function oa(t,e=Jr().isDark){const n=Yt(t);return n?(e?Kn:Ze)[n]:void 0}function Kr(t){const e=Lr(t);return e?[e.r,e.g,e.b]:null}function ia(t){const e=Lr(t);return e?{rgb:[e.r,e.g,e.b],alpha:e.
81
- a}:null}function Yr(t,e=!1,n=Gr){let r=null,a=Number.POSITIVE_INFINITY;for(const o of n){const l=[Qr[o],...e?[Ze[o]]:[]];for(const s of l){const f=Kr(s);if(!f)continue;const m=(t[0]-f[0])**2+(t[1]-f[1])**
80
+ Vr[e]:void 0}function oa(t,e=Ur().isDark){const n=Yt(t);return n?(e?Kn:Ge)[n]:void 0}function Kr(t){const e=Lr(t);return e?[e.r,e.g,e.b]:null}function ia(t){const e=Lr(t);return e?{rgb:[e.r,e.g,e.b],alpha:e.
81
+ a}:null}function Yr(t,e=!1,n=Qr){let r=null,a=Number.POSITIVE_INFINITY;for(const o of n){const l=[Vr[o],...e?[Ge[o]]:[]];for(const s of l){const f=Kr(s);if(!f)continue;const m=(t[0]-f[0])**2+(t[1]-f[1])**
82
82
  2+(t[2]-f[2])**2;m<a&&(a=m,r=o)}}return r?{name:r,distance:a}:null}function la(t){const[e,n,r]=t.map(h=>h/255),a=Math.max(e,n,r),o=Math.min(e,n,r),l=a-o,s=(a+o)/2,f=l===0?0:l/(1-Math.abs(2*s-1));let m=null;
83
83
  return l!==0&&(a===e?m=60*((n-r)/l%6):a===n?m=60*((r-e)/l+2):m=60*((e-n)/l+4),m<0&&(m+=360)),{hue:m,lightness:s,saturation:f,maxChannel:Math.max(...t)}}function sa(t){return t>=20&&t<42?"orange":t>=42&&
84
84
  t<85?"yellow":t>=85&&t<170?"green":t>=170&&t<255?"blue":t>=255&&t<320?"purple":"pink"}function ca(t){if(!t)return;const e=t.trim().toLowerCase().replace(/[\s_-]+/g,"");return ta[e]}function Yt(t){if(!t)
@@ -104,57 +104,57 @@ f+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+
104
104
  f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,gzhy+6n",AL:"16w,3,2,e+1b,z+2,2+2s,g+1,8+1,b+m,2+t,s+2i,c+e,4h+f,1d+1e,1bwe+dp,3+3z,x+c,2+1,35+3y,2rm+z,5+7,b+5,dt+l,c+u,17nl+27,1t+27,4x+6n,3+d",LRO:"\
105
105
  6ct",RLO:"6cu",LRE:"6cq",RLE:"6cr",PDF:"6cs",LRI:"6ee",RLI:"6ef",FSI:"6eg",PDI:"6eh"},r={},a={};r.L=1,a[1]="L",Object.keys(n).forEach(function(u,k){r[u]=1<<k+1,a[r[u]]=u}),Object.freeze(r);var o=r.LRI|
106
106
  r.RLI|r.FSI,l=r.L|r.R|r.AL,s=r.B|r.S|r.WS|r.ON|r.FSI|r.LRI|r.RLI|r.PDI,f=r.BN|r.RLE|r.LRE|r.RLO|r.LRO|r.PDF,m=r.S|r.WS|r.B|o|r.PDI|f,h=null;function N(){if(!h){h=new Map;var u=function(y){if(n.hasOwnProperty(
107
- y)){var i=0;n[y].split(",").forEach(function(_){var d=_.split("+"),p=d[0],g=d[1];p=parseInt(p,36),g=g?parseInt(g,36):0,h.set(i+=p,r[y]);for(var j=0;j<g;j++)h.set(++i,r[y])})}};for(var k in n)u(k)}}function w(u){
108
- return N(),h.get(u.codePointAt(0))||r.L}function K(u){return a[w(u)]}var jt={pairs:"14>1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,\
107
+ y)){var i=0;n[y].split(",").forEach(function(_){var d=_.split("+"),p=d[0],g=d[1];p=parseInt(p,36),g=g?parseInt(g,36):0,h.set(i+=p,r[y]);for(var C=0;C<g;C++)h.set(++i,r[y])})}};for(var k in n)u(k)}}function w(u){
108
+ return N(),h.get(u.codePointAt(0))||r.L}function K(u){return a[w(u)]}var Ct={pairs:"14>1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,\
109
109
  +2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",canonical:"6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>\
110
110
  -14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye"};function re(u,k){var y=36,i=0,_=new Map,d=k&&new Map,p;return u.split("\
111
- ,").forEach(function g(j){if(j.indexOf("+")!==-1)for(var C=+j;C--;)g(p);else{p=j;var v=j.split(">"),B=v[0],P=v[1];B=String.fromCodePoint(i+=parseInt(B,y)),P=String.fromCodePoint(i+=parseInt(P,y)),_.set(
112
- B,P),k&&d.set(P,B)}}),{map:_,reverseMap:d}}var ne,Ue,Je;function ae(){if(!ne){var u=re(jt.pairs,!0),k=u.map,y=u.reverseMap;ne=k,Ue=y,Je=re(jt.canonical,!1).map}}function oe(u){return ae(),ne.get(u)||null}
113
- function ie(u){return ae(),Ue.get(u)||null}function le(u){return ae(),Je.get(u)||null}var E=r.L,D=r.R,I=r.EN,st=r.ES,Ct=r.ET,ct=r.AN,Mt=r.CS,Y=r.B,an=r.S,St=r.ON,on=r.BN,It=r.NSM,Lt=r.AL,Ve=r.LRO,Ft=r.
114
- RLO,Qe=r.LRE,se=r.RLE,Ge=r.PDF,ln=r.LRI,Ke=r.RLI,sn=r.FSI,tt=r.PDI;function cn(u,k){for(var y=125,i=new Uint32Array(u.length),_=0;_<u.length;_++)i[_]=w(u[_]);var d=new Map;function p(L,$){var F=i[L];i[L]=
115
- $,d.set(F,d.get(F)-1),F&s&&d.set(s,d.get(s)-1),d.set($,(d.get($)||0)+1),$&s&&d.set(s,(d.get(s)||0)+1)}for(var g=new Uint8Array(u.length),j=new Map,C=[],v=null,B=0;B<u.length;B++)v||C.push(v={start:B,end:u.
116
- length-1,level:k==="rtl"?1:k==="ltr"?0:Mr(B,!1)}),i[B]&Y&&(v.end=B,v=null);for(var P=se|Qe|Ft|Ve|o|tt|Ge|Y,V=function(L){return L+(L&1?1:2)},W=function(L){return L+(L&1?2:1)},X=0;X<C.length;X++){v=C[X];
117
- var b=[{_level:v.level,_override:0,_isolate:0}],x=void 0,A=0,Z=0,ue=0;d.clear();for(var M=v.start;M<=v.end;M++){var S=i[M];if(x=b[b.length-1],d.set(S,(d.get(S)||0)+1),S&s&&d.set(s,(d.get(s)||0)+1),S&P)
118
- if(S&(se|Qe)){g[M]=x._level;var er=(S===se?W:V)(x._level);er<=y&&!A&&!Z?b.push({_level:er,_override:0,_isolate:0}):A||Z++}else if(S&(Ft|Ve)){g[M]=x._level;var rr=(S===Ft?W:V)(x._level);rr<=y&&!A&&!Z?b.
119
- push({_level:rr,_override:S&Ft?D:E,_isolate:0}):A||Z++}else if(S&o){S&sn&&(S=Mr(M+1,!0)===1?Ke:ln),g[M]=x._level,x._override&&p(M,x._override);var nr=(S===Ke?W:V)(x._level);nr<=y&&A===0&&Z===0?(ue++,b.
120
- push({_level:nr,_override:0,_isolate:1,_isolInitIndex:M})):A++}else if(S&tt){if(A>0)A--;else if(ue>0){for(Z=0;!b[b.length-1]._isolate;)b.pop();var de=b[b.length-1]._isolInitIndex;de!=null&&(j.set(de,M),
121
- j.set(M,de)),b.pop(),ue--}x=b[b.length-1],g[M]=x._level,x._override&&p(M,x._override)}else S&Ge?(A===0&&(Z>0?Z--:!x._isolate&&b.length>1&&(b.pop(),x=b[b.length-1])),g[M]=x._level):S&Y&&(g[M]=v.level);else
122
- g[M]=x._level,x._override&&S!==on&&p(M,x._override)}for(var et=[],R=null,Q=v.start;Q<=v.end;Q++){var he=i[Q];if(!(he&f)){var ar=g[Q],or=he&o,gn=he===tt;R&&ar===R._level?(R._end=Q,R._endsWithIsolInit=or):
123
- et.push(R={_start:Q,_end:Q,_level:ar,_startsWithPDI:gn,_endsWithIsolInit:or})}}for(var ge=[],Et=0;Et<et.length;Et++){var qt=et[Et];if(!qt._startsWithPDI||qt._startsWithPDI&&!j.has(qt._start)){for(var pe=[
124
- R=qt],ir=void 0;R&&R._endsWithIsolInit&&(ir=j.get(R._end))!=null;)for(var Nt=Et+1;Nt<et.length;Nt++)if(et[Nt]._start===ir){pe.push(R=et[Nt]);break}for(var rt=[],me=0;me<pe.length;me++)for(var lr=pe[me],
111
+ ,").forEach(function g(C){if(C.indexOf("+")!==-1)for(var M=+C;M--;)g(p);else{p=C;var v=C.split(">"),B=v[0],P=v[1];B=String.fromCodePoint(i+=parseInt(B,y)),P=String.fromCodePoint(i+=parseInt(P,y)),_.set(
112
+ B,P),k&&d.set(P,B)}}),{map:_,reverseMap:d}}var ne,He,Ue;function ae(){if(!ne){var u=re(Ct.pairs,!0),k=u.map,y=u.reverseMap;ne=k,He=y,Ue=re(Ct.canonical,!1).map}}function oe(u){return ae(),ne.get(u)||null}
113
+ function ie(u){return ae(),He.get(u)||null}function le(u){return ae(),Ue.get(u)||null}var E=r.L,D=r.R,j=r.EN,st=r.ES,Mt=r.ET,ct=r.AN,St=r.CS,Y=r.B,an=r.S,It=r.ON,on=r.BN,jt=r.NSM,Lt=r.AL,Je=r.LRO,Ft=r.
114
+ RLO,Ve=r.LRE,se=r.RLE,Qe=r.PDF,ln=r.LRI,Ke=r.RLI,sn=r.FSI,tt=r.PDI;function cn(u,k){for(var y=125,i=new Uint32Array(u.length),_=0;_<u.length;_++)i[_]=w(u[_]);var d=new Map;function p(L,$){var F=i[L];i[L]=
115
+ $,d.set(F,d.get(F)-1),F&s&&d.set(s,d.get(s)-1),d.set($,(d.get($)||0)+1),$&s&&d.set(s,(d.get(s)||0)+1)}for(var g=new Uint8Array(u.length),C=new Map,M=[],v=null,B=0;B<u.length;B++)v||M.push(v={start:B,end:u.
116
+ length-1,level:k==="rtl"?1:k==="ltr"?0:Sr(B,!1)}),i[B]&Y&&(v.end=B,v=null);for(var P=se|Ve|Ft|Je|o|tt|Qe|Y,J=function(L){return L+(L&1?1:2)},W=function(L){return L+(L&1?2:1)},X=0;X<M.length;X++){v=M[X];
117
+ var b=[{_level:v.level,_override:0,_isolate:0}],x=void 0,A=0,G=0,ue=0;d.clear();for(var S=v.start;S<=v.end;S++){var I=i[S];if(x=b[b.length-1],d.set(I,(d.get(I)||0)+1),I&s&&d.set(s,(d.get(s)||0)+1),I&P)
118
+ if(I&(se|Ve)){g[S]=x._level;var er=(I===se?W:J)(x._level);er<=y&&!A&&!G?b.push({_level:er,_override:0,_isolate:0}):A||G++}else if(I&(Ft|Je)){g[S]=x._level;var rr=(I===Ft?W:J)(x._level);rr<=y&&!A&&!G?b.
119
+ push({_level:rr,_override:I&Ft?D:E,_isolate:0}):A||G++}else if(I&o){I&sn&&(I=Sr(S+1,!0)===1?Ke:ln),g[S]=x._level,x._override&&p(S,x._override);var nr=(I===Ke?W:J)(x._level);nr<=y&&A===0&&G===0?(ue++,b.
120
+ push({_level:nr,_override:0,_isolate:1,_isolInitIndex:S})):A++}else if(I&tt){if(A>0)A--;else if(ue>0){for(G=0;!b[b.length-1]._isolate;)b.pop();var de=b[b.length-1]._isolInitIndex;de!=null&&(C.set(de,S),
121
+ C.set(S,de)),b.pop(),ue--}x=b[b.length-1],g[S]=x._level,x._override&&p(S,x._override)}else I&Qe?(A===0&&(G>0?G--:!x._isolate&&b.length>1&&(b.pop(),x=b[b.length-1])),g[S]=x._level):I&Y&&(g[S]=v.level);else
122
+ g[S]=x._level,x._override&&I!==on&&p(S,x._override)}for(var et=[],R=null,V=v.start;V<=v.end;V++){var he=i[V];if(!(he&f)){var ar=g[V],or=he&o,gn=he===tt;R&&ar===R._level?(R._end=V,R._endsWithIsolInit=or):
123
+ et.push(R={_start:V,_end:V,_level:ar,_startsWithPDI:gn,_endsWithIsolInit:or})}}for(var ge=[],Et=0;Et<et.length;Et++){var qt=et[Et];if(!qt._startsWithPDI||qt._startsWithPDI&&!C.has(qt._start)){for(var pe=[
124
+ R=qt],ir=void 0;R&&R._endsWithIsolInit&&(ir=C.get(R._end))!=null;)for(var Nt=Et+1;Nt<et.length;Nt++)if(et[Nt]._start===ir){pe.push(R=et[Nt]);break}for(var rt=[],me=0;me<pe.length;me++)for(var lr=pe[me],
125
125
  ve=lr._start;ve<=lr._end;ve++)rt.push(ve);for(var pn=g[rt[0]],sr=v.level,Dt=rt[0]-1;Dt>=0;Dt--)if(!(i[Dt]&f)){sr=g[Dt];break}var ye=rt[rt.length-1],mn=g[ye],cr=v.level;if(!(i[ye]&o)){for(var Tt=ye+1;Tt<=
126
126
  v.end;Tt++)if(!(i[Tt]&f)){cr=g[Tt];break}}ge.push({_seqIndices:rt,_sosType:Math.max(sr,pn)%2?D:E,_eosType:Math.max(cr,mn)%2?D:E})}}for(var be=0;be<ge.length;be++){var ke=ge[be],c=ke._seqIndices,ft=ke.
127
- _sosType,vn=ke._eosType,nt=g[c[0]]&1?D:E;if(d.get(It))for(var $t=0;$t<c.length;$t++){var fr=c[$t];if(i[fr]&It){for(var we=ft,Pt=$t-1;Pt>=0;Pt--)if(!(i[c[Pt]]&f)){we=i[c[Pt]];break}p(fr,we&(o|tt)?St:we)}}
128
- if(d.get(I))for(var Rt=0;Rt<c.length;Rt++){var ur=c[Rt];if(i[ur]&I)for(var zt=Rt-1;zt>=-1;zt--){var dr=zt===-1?ft:i[c[zt]];if(dr&l){dr===Lt&&p(ur,ct);break}}}if(d.get(Lt))for(var xe=0;xe<c.length;xe++){
129
- var hr=c[xe];i[hr]&Lt&&p(hr,D)}if(d.get(st)||d.get(Mt))for(var ut=1;ut<c.length-1;ut++){var _e=c[ut];if(i[_e]&(st|Mt)){for(var at=0,Be=0,je=ut-1;je>=0&&(at=i[c[je]],!!(at&f));je--);for(var Ce=ut+1;Ce<
130
- c.length&&(Be=i[c[Ce]],!!(Be&f));Ce++);at===Be&&(i[_e]===st?at===I:at&(I|ct))&&p(_e,at)}}if(d.get(I))for(var z=0;z<c.length;z++){var yn=c[z];if(i[yn]&I){for(var At=z-1;At>=0&&i[c[At]]&(Ct|f);At--)p(c[At],
131
- I);for(z++;z<c.length&&i[c[z]]&(Ct|f|I);z++)i[c[z]]!==I&&p(c[z],I)}}if(d.get(Ct)||d.get(st)||d.get(Mt))for(var dt=0;dt<c.length;dt++){var gr=c[dt];if(i[gr]&(Ct|st|Mt)){p(gr,St);for(var Ot=dt-1;Ot>=0&&
132
- i[c[Ot]]&f;Ot--)p(c[Ot],St);for(var Wt=dt+1;Wt<c.length&&i[c[Wt]]&f;Wt++)p(c[Wt],St)}}if(d.get(I))for(var Me=0,pr=ft;Me<c.length;Me++){var mr=c[Me],Se=i[mr];Se&I?pr===E&&p(mr,E):Se&l&&(pr=Se)}if(d.get(
133
- s)){var ht=D|I|ct,vr=ht|E,Xt=[];{for(var ot=[],it=0;it<c.length;it++)if(i[c[it]]&s){var gt=u[c[it]],yr=void 0;if(oe(gt)!==null)if(ot.length<63)ot.push({char:gt,seqIndex:it});else break;else if((yr=ie(
134
- gt))!==null)for(var pt=ot.length-1;pt>=0;pt--){var Ie=ot[pt].char;if(Ie===yr||Ie===ie(le(gt))||oe(le(Ie))===gt){Xt.push([ot[pt].seqIndex,it]),ot.length=pt;break}}}Xt.sort(function(L,$){return L[0]-$[0]})}
135
- for(var Le=0;Le<Xt.length;Le++){for(var br=Xt[Le],Zt=br[0],Fe=br[1],kr=!1,T=0,Ee=Zt+1;Ee<Fe;Ee++){var wr=c[Ee];if(i[wr]&vr){kr=!0;var xr=i[wr]&ht?D:E;if(xr===nt){T=xr;break}}}if(kr&&!T){T=ft;for(var qe=Zt-
136
- 1;qe>=0;qe--){var _r=c[qe];if(i[_r]&vr){var Br=i[_r]&ht?D:E;Br!==nt?T=Br:T=nt;break}}}if(T){if(i[c[Zt]]=i[c[Fe]]=T,T!==nt){for(var mt=Zt+1;mt<c.length;mt++)if(!(i[c[mt]]&f)){w(u[c[mt]])&It&&(i[c[mt]]=
137
- T);break}}if(T!==nt){for(var vt=Fe+1;vt<c.length;vt++)if(!(i[c[vt]]&f)){w(u[c[vt]])&It&&(i[c[vt]]=T);break}}}}for(var H=0;H<c.length;H++)if(i[c[H]]&s){for(var jr=H,Ne=H,De=ft,yt=H-1;yt>=0;yt--)if(i[c[yt]]&
138
- f)jr=yt;else{De=i[c[yt]]&ht?D:E;break}for(var Cr=vn,bt=H+1;bt<c.length;bt++)if(i[c[bt]]&(s|f))Ne=bt;else{Cr=i[c[bt]]&ht?D:E;break}for(var Te=jr;Te<=Ne;Te++)i[c[Te]]=De===Cr?De:nt;H=Ne}}}for(var q=v.start;q<=
139
- v.end;q++){var bn=g[q],Ht=i[q];if(bn&1?Ht&(E|I|ct)&&g[q]++:Ht&D?g[q]++:Ht&(ct|I)&&(g[q]+=2),Ht&f&&(g[q]=q===0?v.level:g[q-1]),q===v.end||w(u[q])&(an|Y))for(var Ut=q;Ut>=0&&w(u[Ut])&m;Ut--)g[Ut]=v.level}}
140
- return{levels:g,paragraphs:C};function Mr(L,$){for(var F=L;F<u.length;F++){var U=i[F];if(U&(D|Lt))return 1;if(U&(Y|E)||$&&U===tt)return 0;if(U&o){var Sr=kn(F);F=Sr===-1?u.length:Sr}}return 0}function kn(L){
141
- for(var $=1,F=L+1;F<u.length;F++){var U=i[F];if(U&Y)break;if(U&tt){if(--$===0)return F}else U&o&&$++}return-1}}var fn="14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>\
127
+ _sosType,vn=ke._eosType,nt=g[c[0]]&1?D:E;if(d.get(jt))for(var $t=0;$t<c.length;$t++){var fr=c[$t];if(i[fr]&jt){for(var we=ft,Pt=$t-1;Pt>=0;Pt--)if(!(i[c[Pt]]&f)){we=i[c[Pt]];break}p(fr,we&(o|tt)?It:we)}}
128
+ if(d.get(j))for(var Rt=0;Rt<c.length;Rt++){var ur=c[Rt];if(i[ur]&j)for(var zt=Rt-1;zt>=-1;zt--){var dr=zt===-1?ft:i[c[zt]];if(dr&l){dr===Lt&&p(ur,ct);break}}}if(d.get(Lt))for(var xe=0;xe<c.length;xe++){
129
+ var hr=c[xe];i[hr]&Lt&&p(hr,D)}if(d.get(st)||d.get(St))for(var ut=1;ut<c.length-1;ut++){var _e=c[ut];if(i[_e]&(st|St)){for(var at=0,Be=0,Ce=ut-1;Ce>=0&&(at=i[c[Ce]],!!(at&f));Ce--);for(var Me=ut+1;Me<
130
+ c.length&&(Be=i[c[Me]],!!(Be&f));Me++);at===Be&&(i[_e]===st?at===j:at&(j|ct))&&p(_e,at)}}if(d.get(j))for(var z=0;z<c.length;z++){var yn=c[z];if(i[yn]&j){for(var At=z-1;At>=0&&i[c[At]]&(Mt|f);At--)p(c[At],
131
+ j);for(z++;z<c.length&&i[c[z]]&(Mt|f|j);z++)i[c[z]]!==j&&p(c[z],j)}}if(d.get(Mt)||d.get(st)||d.get(St))for(var dt=0;dt<c.length;dt++){var gr=c[dt];if(i[gr]&(Mt|st|St)){p(gr,It);for(var Ot=dt-1;Ot>=0&&
132
+ i[c[Ot]]&f;Ot--)p(c[Ot],It);for(var Wt=dt+1;Wt<c.length&&i[c[Wt]]&f;Wt++)p(c[Wt],It)}}if(d.get(j))for(var Se=0,pr=ft;Se<c.length;Se++){var mr=c[Se],Ie=i[mr];Ie&j?pr===E&&p(mr,E):Ie&l&&(pr=Ie)}if(d.get(
133
+ s)){var ht=D|j|ct,vr=ht|E,Xt=[];{for(var ot=[],it=0;it<c.length;it++)if(i[c[it]]&s){var gt=u[c[it]],yr=void 0;if(oe(gt)!==null)if(ot.length<63)ot.push({char:gt,seqIndex:it});else break;else if((yr=ie(
134
+ gt))!==null)for(var pt=ot.length-1;pt>=0;pt--){var je=ot[pt].char;if(je===yr||je===ie(le(gt))||oe(le(je))===gt){Xt.push([ot[pt].seqIndex,it]),ot.length=pt;break}}}Xt.sort(function(L,$){return L[0]-$[0]})}
135
+ for(var Le=0;Le<Xt.length;Le++){for(var br=Xt[Le],Gt=br[0],Fe=br[1],kr=!1,T=0,Ee=Gt+1;Ee<Fe;Ee++){var wr=c[Ee];if(i[wr]&vr){kr=!0;var xr=i[wr]&ht?D:E;if(xr===nt){T=xr;break}}}if(kr&&!T){T=ft;for(var qe=Gt-
136
+ 1;qe>=0;qe--){var _r=c[qe];if(i[_r]&vr){var Br=i[_r]&ht?D:E;Br!==nt?T=Br:T=nt;break}}}if(T){if(i[c[Gt]]=i[c[Fe]]=T,T!==nt){for(var mt=Gt+1;mt<c.length;mt++)if(!(i[c[mt]]&f)){w(u[c[mt]])&jt&&(i[c[mt]]=
137
+ T);break}}if(T!==nt){for(var vt=Fe+1;vt<c.length;vt++)if(!(i[c[vt]]&f)){w(u[c[vt]])&jt&&(i[c[vt]]=T);break}}}}for(var Z=0;Z<c.length;Z++)if(i[c[Z]]&s){for(var Cr=Z,Ne=Z,De=ft,yt=Z-1;yt>=0;yt--)if(i[c[yt]]&
138
+ f)Cr=yt;else{De=i[c[yt]]&ht?D:E;break}for(var Mr=vn,bt=Z+1;bt<c.length;bt++)if(i[c[bt]]&(s|f))Ne=bt;else{Mr=i[c[bt]]&ht?D:E;break}for(var Te=Cr;Te<=Ne;Te++)i[c[Te]]=De===Mr?De:nt;Z=Ne}}}for(var q=v.start;q<=
139
+ v.end;q++){var bn=g[q],Zt=i[q];if(bn&1?Zt&(E|j|ct)&&g[q]++:Zt&D?g[q]++:Zt&(ct|j)&&(g[q]+=2),Zt&f&&(g[q]=q===0?v.level:g[q-1]),q===v.end||w(u[q])&(an|Y))for(var Ht=q;Ht>=0&&w(u[Ht])&m;Ht--)g[Ht]=v.level}}
140
+ return{levels:g,paragraphs:M};function Sr(L,$){for(var F=L;F<u.length;F++){var H=i[F];if(H&(D|Lt))return 1;if(H&(Y|E)||$&&H===tt)return 0;if(H&o){var Ir=kn(F);F=Ir===-1?u.length:Ir}}return 0}function kn(L){
141
+ for(var $=1,F=L+1;F<u.length;F++){var H=i[F];if(H&Y)break;if(H&tt){if(--$===0)return F}else H&o&&$++}return-1}}var fn="14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>\
142
142
  1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7\
143
143
  >8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1\
144
144
  >1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1",ce;function un(){if(!ce){var u=re(fn,!0),k=u.map,y=u.reverseMap;y.forEach(
145
145
  function(i,_){k.set(_,i)}),ce=k}}function fe(u){return un(),ce.get(u)||null}function dn(u,k,y,i){var _=u.length;y=Math.max(0,y==null?0:+y),i=Math.min(_-1,i==null?_-1:+i);for(var d=new Map,p=y;p<=i;p++)
146
146
  if(k[p]&1){var g=fe(u[p]);g!==null&&d.set(p,g)}return d}function Ye(u,k,y,i){var _=u.length;y=Math.max(0,y==null?0:+y),i=Math.min(_-1,i==null?_-1:+i);var d=[];return k.paragraphs.forEach(function(p){var g=Math.
147
- max(y,p.start),j=Math.min(i,p.end);if(g<j){for(var C=k.levels.slice(g,j+1),v=j;v>=g&&w(u[v])&m;v--)C[v]=p.level;for(var B=p.level,P=1/0,V=0;V<C.length;V++){var W=C[V];W>B&&(B=W),W<P&&(P=W|1)}for(var X=B;X>=
148
- P;X--)for(var b=0;b<C.length;b++)if(C[b]>=X){for(var x=b;b+1<C.length&&C[b+1]>=X;)b++;b>x&&d.push([x+g,b+g])}}}),d}function hn(u,k,y,i){var _=tr(u,k,y,i),d=[].concat(u);return _.forEach(function(p,g){
149
- d[g]=(k.levels[p]&1?fe(u[p]):null)||u[p]}),d.join("")}function tr(u,k,y,i){for(var _=Ye(u,k,y,i),d=[],p=0;p<u.length;p++)d[p]=p;return _.forEach(function(g){for(var j=g[0],C=g[1],v=d.slice(j,C+1),B=v.
150
- length;B--;)d[C-B]=v[B]}),d}return e.closingToOpeningBracket=ie,e.getBidiCharType=w,e.getBidiCharTypeName=K,e.getCanonicalBracket=le,e.getEmbeddingLevels=cn,e.getMirroredCharacter=fe,e.getMirroredCharactersMap=
147
+ max(y,p.start),C=Math.min(i,p.end);if(g<C){for(var M=k.levels.slice(g,C+1),v=C;v>=g&&w(u[v])&m;v--)M[v]=p.level;for(var B=p.level,P=1/0,J=0;J<M.length;J++){var W=M[J];W>B&&(B=W),W<P&&(P=W|1)}for(var X=B;X>=
148
+ P;X--)for(var b=0;b<M.length;b++)if(M[b]>=X){for(var x=b;b+1<M.length&&M[b+1]>=X;)b++;b>x&&d.push([x+g,b+g])}}}),d}function hn(u,k,y,i){var _=tr(u,k,y,i),d=[].concat(u);return _.forEach(function(p,g){
149
+ d[g]=(k.levels[p]&1?fe(u[p]):null)||u[p]}),d.join("")}function tr(u,k,y,i){for(var _=Ye(u,k,y,i),d=[],p=0;p<u.length;p++)d[p]=p;return _.forEach(function(g){for(var C=g[0],M=g[1],v=d.slice(C,M+1),B=v.
150
+ length;B--;)d[M-B]=v[B]}),d}return e.closingToOpeningBracket=ie,e.getBidiCharType=w,e.getBidiCharTypeName=K,e.getCanonicalBracket=le,e.getEmbeddingLevels=cn,e.getMirroredCharacter=fe,e.getMirroredCharactersMap=
151
151
  dn,e.getReorderSegments=Ye,e.getReorderedIndices=tr,e.getReorderedString=hn,e.openingToClosingBracket=oe,Object.defineProperty(e,"__esModule",{value:!0}),e}({});return t}const ga=new Set(["R","AL","AN",
152
152
  "RLE","RLO","RLI","LRE","LRO","LRI","FSI","PDI","PDF"]),_t=new Map,pa=500;function rn(t){const e=_t.get(t);if(e!==void 0)return e;let n=!1;for(const r of t)if(ga.has(ee().getBidiCharTypeName(r))){n=!0;
153
153
  break}if(_t.size>=pa){const r=_t.keys().next().value;r!==void 0&&_t.delete(r)}return _t.set(t,n),n}function nn(t){for(let e=0;e<t.length;){const n=t.codePointAt(e);if(n===void 0)break;const r=String.fromCodePoint(
154
- n),a=ee().getBidiCharTypeName(r);if(a==="R"||a==="AL")return"rtl";if(a==="L")return"ltr";e+=r.length}return null}function ma(t,e){return t==="rtl"||t==="ltr"?t:nn(e)??"ltr"}let He=null;function ee(){return He||
155
- (He=ha()),He}const Bt=new Map,va=300;function ya(t,e){const n=e+"\0"+t,r=Bt.get(n);if(r)return r;const a=ee().getEmbeddingLevels(t,e);if(Bt.size>=va){const o=Bt.keys().next().value;o!==void 0&&Bt.delete(
154
+ n),a=ee().getBidiCharTypeName(r);if(a==="R"||a==="AL")return"rtl";if(a==="L")return"ltr";e+=r.length}return null}function ma(t,e){return t==="rtl"||t==="ltr"?t:nn(e)??"ltr"}let Ze=null;function ee(){return Ze||
155
+ (Ze=ha()),Ze}const Bt=new Map,va=300;function ya(t,e){const n=e+"\0"+t,r=Bt.get(n);if(r)return r;const a=ee().getEmbeddingLevels(t,e);if(Bt.size>=va){const o=Bt.keys().next().value;o!==void 0&&Bt.delete(
156
156
  o)}return Bt.set(n,a),a}function ba(t,e,n,r){if(r<=n)return[];if(e==="ltr"&&!rn(t.slice(n,r)))return[{start:n,end:r,rtl:!1}];const a=ya(t,e),o=ee().getReorderSegments(t,a,n,r-1),l=r-n,s=new Array(l);for(let h=0;h<
157
- l;h++)s[h]=n+h;for(const[h,N]of o){let w=h-n,K=N-n;for(;w<K;){const jt=s[w];s[w]=s[K],s[K]=jt,w++,K--}}const f=[];let m=0;for(let h=1;h<=l;h++){if(!(h===l||Math.abs(s[h]-s[h-1])!==1||s[h]-s[h-1]!==s[m+
157
+ l;h++)s[h]=n+h;for(const[h,N]of o){let w=h-n,K=N-n;for(;w<K;){const Ct=s[w];s[w]=s[K],s[K]=Ct,w++,K--}}const f=[];let m=0;for(let h=1;h<=l;h++){if(!(h===l||Math.abs(s[h]-s[h-1])!==1||s[h]-s[h-1]!==s[m+
158
158
  1]-s[m]))continue;const N=s[m],w=s[h-1];N<=w?f.push({start:N,end:w+1,rtl:!1}):f.push({start:w,end:N+1,rtl:!0}),m=h}for(const h of f)h.end-h.start===1&&(h.rtl=(a.levels[h.start]&1)===1);return f}export{
159
- Xe as A,Sn as B,Gn as C,ea as D,O as F,Gr as H,te as L,Qn as a,Vr as b,nn as c,fa as d,Jr as e,Hn as f,Xr as g,Yt as h,aa as i,Xn as j,Ln as k,$e as l,Zn as m,na as n,Ur as o,en as p,Re as q,ma as r,Zr as s,
160
- rn as t,tn as u,ua as v,da as w,Vn as x,ba as y,oa as z};
159
+ Xe as A,In as B,Qn as C,ea as D,O as F,Qr as H,te as L,Vn as a,Jr as b,nn as c,fa as d,Ur as e,Zn as f,Xr as g,Yt as h,aa as i,Xn as j,Ln as k,$e as l,Gn as m,na as n,Hr as o,en as p,Re as q,ma as r,Gr as s,
160
+ rn as t,tn as u,ua as v,da as w,Jn as x,ba as y,oa as z};