revise 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/assets/{historyMaterializeWorker-CoAX9ZAi.js → historyMaterializeWorker-C4uxcZEh.js} +1 -1
  3. package/backend.d.ts +22 -0
  4. package/backend.js +1 -1
  5. package/chunks/AgentPageRenderer-BIf_Fza8.js +1 -0
  6. package/chunks/AgentPageRenderer-DT9sNxEn.js +1 -0
  7. package/chunks/{AttachmentDocumentImporter-dNMtkxrv.js → AttachmentDocumentImporter-BUavYRxO.js} +1 -1
  8. package/chunks/{AttachmentDocumentImporter-DSic_6At.js → AttachmentDocumentImporter-DGwfDJSH.js} +1 -1
  9. package/chunks/{BidiText-B4Hzrjg9.js → BidiText-D7LYTAUL.js} +1 -1
  10. package/chunks/DocumentMutator-CjN7Kk-X.js +31 -0
  11. package/chunks/DocumentScrubber-C9ZZEcYW.js +1 -0
  12. package/chunks/DocumentScrubber-DrgzBlx4.js +1 -0
  13. package/chunks/DocumentScrubber-W0EfGmL-.js +1 -0
  14. package/chunks/{DocxConverter-COV6CjUM.js → DocxConverter-Be3uPNcD.js} +3 -3
  15. package/chunks/{DocxConverter-B7P52lw7.js → DocxConverter-CGYMfz-j.js} +6 -6
  16. package/chunks/{DocxConverter-Cq_zCEJC.js → DocxConverter-DabDLfsu.js} +6 -6
  17. package/chunks/{DocxGraft-CJ12C9WP.js → DocxGraft-B6W7fbh4.js} +1 -1
  18. package/chunks/{DocxGraft-DcmFuUkd.js → DocxGraft-Cj7v78BO.js} +1 -1
  19. package/chunks/DocxGraft-Duvo2cpy.js +1 -0
  20. package/chunks/FileImporter-CjUX2S4s.js +1 -0
  21. package/chunks/FileImporter-DtkbI6rF.js +1 -0
  22. package/chunks/{HtmlConverter-JvRlkQM3.js → HtmlConverter-ikXImzTY.js} +1 -1
  23. package/chunks/{MarkdownConverter-B-tPY7X3.js → MarkdownConverter-CFrcLyO_.js} +2 -2
  24. package/chunks/{OdtConverter-DYHnR4E8.js → OdtConverter-BFT_P8SI.js} +1 -1
  25. package/chunks/OdtConverter-Cnda9T0q.js +1 -0
  26. package/chunks/OdtConverter-WdwwXKVM.js +1 -0
  27. package/chunks/PdfConverter-D7UM58vc.js +21 -0
  28. package/chunks/PdfConverter-TB-QPw29.js +21 -0
  29. package/chunks/PdfConverter-wVP63986.js +21 -0
  30. package/chunks/PdfImportService-Dj1-3L2B.js +2 -0
  31. package/chunks/PdfImportService-OE9G383I.js +2 -0
  32. package/chunks/{RtfConverter-oIwzoqCD.js → RtfConverter-D-oqPWNl.js} +5 -5
  33. package/chunks/{RtfConverter-BQGge3K-.js → RtfConverter-D9zhE07-.js} +5 -5
  34. package/chunks/{RtfConverter-CMfZ4olw.js → RtfConverter-DZgwU-_R.js} +1 -1
  35. package/chunks/{TableBorders-BLkZYt1k.js → TableBorders-BorZS8aZ.js} +1 -1
  36. package/chunks/{TxtConverter-C1lp6dBS.js → TxtConverter-BYazsp6P.js} +3 -3
  37. package/chunks/ar-C8zx2RwP.js +8 -0
  38. package/chunks/backend-MFpDFVrD.js +1 -0
  39. package/chunks/base64-BNMNG-lN.js +1 -0
  40. package/chunks/{browser-module-6b2Fq-5C.js → browser-module-BbaxnHNK.js} +1 -1
  41. package/chunks/{browser-module-CkO57IPL.js → browser-module-D2ixluMg.js} +1 -1
  42. package/chunks/capture-qC26xmfy.js +1 -0
  43. package/chunks/{carrier-WgcRSu7a.js → carrier-BWONvrA7.js} +1 -1
  44. package/chunks/de-ByQFqecF.js +8 -0
  45. package/chunks/es-PHpJXv5S.js +8 -0
  46. package/chunks/{footnoteFlatten-CW-DUcgK.js → footnoteFlatten-Bdnn_bz1.js} +1 -1
  47. package/chunks/{graftExport-CVg7PO2A.js → graftExport-CP3h2T88.js} +1 -1
  48. package/chunks/index-CjeGoI2g.js +351 -0
  49. package/chunks/index-D7V8zn4w.js +36 -0
  50. package/chunks/index-DyOcu9mD.js +351 -0
  51. package/chunks/{index.es-DOqegDGr.js → index.es-B97tjxvW.js} +1 -1
  52. package/chunks/{index.es-tXDO0RMv.js → index.es-mTU7Sl3w.js} +1 -1
  53. package/chunks/{jspdf.es.min-CzYti8jo.js → jspdf.es.min-DGiD4mlU.js} +1 -1
  54. package/chunks/{jspdf.es.min-ejWOGhkJ.js → jspdf.es.min-Mykp4BZO.js} +1 -1
  55. package/chunks/{pseudoLocale-CdBtPHRi.js → pseudoLocale-C90lXrPg.js} +1 -1
  56. package/chunks/{pseudoLocale-DEVWLkGC.js → pseudoLocale-UA_TkGrH.js} +1 -1
  57. package/chunks/serverDocumentSession-CRZSb5SO.js +11 -0
  58. package/chunks/signatures-CsL_TjvW.js +1 -0
  59. package/full.js +1 -1
  60. package/index.d.ts +27 -4
  61. package/index.js +1 -1
  62. package/package.json +2 -2
  63. package/root.js +2 -2
  64. package/style.css +1 -1
  65. package/chunks/AgentPageRenderer-C0n4EnuW.js +0 -1
  66. package/chunks/AgentPageRenderer-DURfmiu0.js +0 -1
  67. package/chunks/DocxGraft-CQpvFcYb.js +0 -1
  68. package/chunks/FileImporter-DVnYOJHp.js +0 -1
  69. package/chunks/FileImporter-q9mCch0J.js +0 -1
  70. package/chunks/OdtConverter-Br81BSoJ.js +0 -1
  71. package/chunks/OdtConverter-CQjh0vlo.js +0 -1
  72. package/chunks/PdfConverter-D26rXumc.js +0 -21
  73. package/chunks/PdfConverter-DGZpUSVf.js +0 -21
  74. package/chunks/PdfConverter-DZzVP0-B.js +0 -21
  75. package/chunks/PdfImportService-CBD8TL1k.js +0 -2
  76. package/chunks/PdfImportService-D6uUKGMf.js +0 -2
  77. package/chunks/ar-kgSWdrXF.js +0 -8
  78. package/chunks/backend-Cq-khfdG.js +0 -1
  79. package/chunks/base64-CfDUyGi8.js +0 -36
  80. package/chunks/capture-DU3MC7tb.js +0 -1
  81. package/chunks/de-C2QTHrqo.js +0 -8
  82. package/chunks/es-BKboUn4q.js +0 -8
  83. package/chunks/index-CLw_BlSL.js +0 -353
  84. package/chunks/index-F-kHIwWT.js +0 -353
  85. package/chunks/serverDocumentSession-DZrYbdpk.js +0 -42
@@ -0,0 +1 @@
1
+ import{A as P,B as I,E,F as L,S as R,H as q,I as D,J as $,K as H,L as N,M as F,N as B,O as j,P as W}from"./index-CjeGoI2g.js";function w(t,r,o,n){if(Array.isArray(t)){for(const s of t)w(s,r,o,n);return}if(!t||typeof t!="object")return;const a=t,e=typeof a.id=="string"?a.id:r;a.type==="math"&&typeof a.content=="string"&&o.push({content:a.content,displayMode:a.displayMode!=="inline",blockId:e}),a.type==="text"&&typeof a.text=="string"&&a.marks?.latex&&o.push({content:a.text,displayMode:!1,blockId:e}),a.type==="image"&&typeof a.src=="string"&&n.push({src:a.src,blockId:e,permanentlyPlaceholder:a.originalFormat==="emf"||a.originalFormat==="wmf"});for(const s of Object.values(a))if(Array.isArray(s))for(const l of s)w(l,e,o,n);else s&&typeof s=="object"&&w(s,e,o,n)}function S(){return new Promise(t=>{let r=!1;const o=()=>{r||(r=!0,clearTimeout(n),t())},n=setTimeout(o,50);typeof requestAnimationFrame=="function"&&requestAnimationFrame(o)})}async function G(t,r){if(t.length===0)return;const o=Promise.allSettled(t.map(n=>D(n.content,n.displayMode,r)));await Promise.race([o,new Promise(n=>setTimeout(n,2500))]),await S(),await S()}function v(t,r){if(typeof t.pageNumber=="number")return t.pageNumber-1;const o=t.bounds.y;return r.pageGeometries?.find(n=>o>=n.pageTop&&o<n.pageTop+n.pageHeight)?.pageIndex??0}function O(t,r){return new Set(t.fragments.filter(o=>r.has(v(o,t))).map(o=>o.blockId))}function Y(t){return t==="table"?"#7c3aed":t==="table-cell"||t==="table-row"?"#db2777":t==="image"?"#ea580c":t==="container"?"#2563eb":t==="math"?"#ca8a04":"#0891b2"}function A(t,r,o){t.save(),t.lineWidth=.75,t.setLineDash([4,3]),t.strokeStyle="rgba(22, 163, 74, 0.9)",t.strokeRect(o.marginLeft,o.marginTop,o.pageWidth-o.marginLeft-o.marginRight,o.pageHeight-o.marginTop-o.marginBottom),t.setLineDash([]);const n=new Set;for(const a of r.fragments){if(v(a,r)!==o.pageIndex)continue;const{bounds:e}=a,s=e.relativeToPage?e.y:e.y-o.pageTop,l=`${a.blockId}:${Math.round(e.x)}:${Math.round(s)}:${Math.round(e.width)}:${Math.round(e.height)}`;if(n.has(l)||e.width<=0||e.height<=0)continue;n.add(l);const m=Y(a.block.type);if(t.strokeStyle=m,t.globalAlpha=.82,t.strokeRect(e.x,s,e.width,e.height),(a.block.type==="table"||a.block.type==="table-cell"||a.block.type==="image"||a.block.type==="container"||a.block.type==="math")&&e.width>=42&&e.height>=12){const p=`${a.block.type} #${a.blockId}`;t.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",t.textAlign="left",t.textBaseline="top";const f=Math.min(e.width,t.measureText(p).width+5);t.globalAlpha=.88,t.fillStyle=m,t.fillRect(e.x,Math.max(0,s),f,13),t.globalAlpha=1,t.fillStyle="#ffffff",t.fillText(p,e.x+2,Math.max(0,s)+1,Math.max(1,f-4))}}t.restore()}function _(t,r){return{pageIndex:0,sectionIndex:0,pageTop:0,pageWidth:t.pageWidth,pageHeight:Math.min(4096,Math.max(t.pageHeight,r.totalHeight)),marginTop:t.pageMarginTop??t.pageMargin,marginRight:t.pageMarginRight??t.pageMargin,marginBottom:t.pageMarginBottom??t.pageMargin,marginLeft:t.pageMarginLeft??t.pageMargin,showPageNumbers:!1,pageNumberPosition:"bottom-right",renderedPageNumber:1}}function U(t){const r=document.createElement("canvas");r.width=Math.ceil(t.geometry.pageWidth),r.height=Math.ceil(t.geometry.pageHeight);const o=r.getContext("2d");if(!o)throw new Error("The browser could not create a page canvas.");const n=P(t.themeElement);o.fillStyle=n.pageBackground,o.fillRect(0,0,r.width,r.height);const a=I(o);t.editor.setTextMeasurementContext(a,t.layout);const e=$(o,r,t.layout,a);e.theme=n,e.currentPage=t.geometry.pageIndex,e.pageGeometry=t.geometry,e.yOffset=t.geometry.pageTop,e.startY=t.geometry.pageTop,e.endY=t.geometry.pageTop+t.geometry.pageHeight,e.pageLayoutSettings=t.pageLayoutSettings,e.headersContent=t.editor.getDocument().headers,e.footersContent=t.editor.getDocument().footers,e.watermark=H(t.editor.getDocument().watermark),e.totalPages=t.computed.pageCount,e.lineNumberMarks=t.computed.lineNumberMarks,e.headingPageNumbers=N(t.computed),e.syntaxTheme=F(t.codeTheme||"solarized",n.isDark),B(e,1);const s={showCursor:!1,isFocused:!1,readOnly:!0,printPreview:!0,forceImagePlaceholders:t.forceImagePlaceholders};if(t.pageless){const l={startY:0,endY:t.geometry.pageHeight};j(e,t.editor,l,s)}else W(e,t.editor,t.geometry.pageIndex,s);return t.mode==="layout"&&A(o,t.computed,t.geometry),r}function K(t,r,o){const n=o==="compact"?360:720,a=o==="compact"?Math.min(2,t.length):t.length,e=Math.ceil(t.length/a),s=16,l=16,m=26,p=t.map(c=>({width:n,height:Math.round(c.height/c.width*n)})),f=Array.from({length:e},(c,u)=>Math.max(...p.slice(u*a,(u+1)*a).map(h=>h.height+m))),d=document.createElement("canvas");d.width=l*2+a*n+Math.max(0,a-1)*s,d.height=l*2+f.reduce((c,u)=>c+u,0)+Math.max(0,e-1)*s;const g=d.getContext("2d");if(!g)throw new Error("The browser could not create a page contact sheet.");g.fillStyle="#e5e7eb",g.fillRect(0,0,d.width,d.height),g.fillStyle="#111827",g.font="600 14px ui-sans-serif, system-ui, sans-serif",g.textBaseline="top";let y=l;for(let c=0;c<e;c+=1){for(let u=0;u<a;u+=1){const h=c*a+u;if(h>=t.length)break;const b=l+u*(n+s);g.fillText(`Page ${r[h]}`,b,y+4),g.drawImage(t[h],b,y+m,p[h].width,p[h].height),g.strokeStyle="#9ca3af",g.strokeRect(b,y+m,p[h].width,p[h].height)}y+=f[c]+s}return d}async function z(t){const r=t.editor.getDocument(),o=P(t.themeElement),n=[],a=[];w(r,null,n,a),await G(n,o.text);const e=document.createElement("canvas");e.width=8,e.height=8;const s=e.getContext("2d");if(!s)throw new Error("The browser could not measure document pages.");const l=I(s);t.editor.setTextMeasurementContext(l,t.layout);const m=E(r,l,t.layout),p=m.pageGeometries?.length?m.pageGeometries:[_(t.layout,m)],f=p.length,d=t.request.startPage-1;if(d<0||d>=f)throw new Error(`start_page ${t.request.startPage} is outside this ${f}-page document.`);const g=p.slice(d,Math.min(f,d+t.request.pageCount)),y=new Set(g.map(i=>i.pageIndex)),c=O(m,y),u=a.filter(i=>i.blockId===null||c.has(i.blockId)),h=await Promise.all(u.map(i=>i.permanentlyPlaceholder?Promise.resolve("placeholder"):L(i.src))),b=g.map(i=>U({editor:t.editor,layout:t.layout,computed:m,geometry:i,pageLayoutSettings:t.pageLayoutSettings,mode:t.request.mode,codeTheme:t.codeTheme,themeElement:t.themeElement,pageless:!!r.pageless})),M=g.map(i=>i.pageIndex+1),x=K(b,M,t.request.quality);let k;try{k=x.toDataURL("image/jpeg",t.request.quality==="compact"?.78:.9)}catch(i){throw typeof i=="object"&&i!==null&&"name"in i&&i.name==="SecurityError"?new R("visual_resource_unavailable","A document resource prevented safe page export. Re-upload external images and retry visual inspection.","verification",!1):i}const C=n.filter(i=>i.blockId===null||c.has(i.blockId)).filter(i=>{const T=q(i.content,i.displayMode,o.text);return T.loading||!T.image}).length;return{dataUrl:k,width:x.width,height:x.height,pages:M,totalPages:f,placeholderImageCount:h.filter(i=>i==="placeholder").length,failedImageCount:h.filter(i=>i==="failed").length,mathPlaceholderCount:C}}export{A as paintPageLayoutDiagnostics,z as renderDocumentPagesForAgent};
@@ -1 +1 @@
1
- import{O as d,P as g,Q as y}from"./index-CLw_BlSL.js";const f="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 D(e){if(e.type==="pdf"&&(e.urls?.length??0)>1)throw new Error(f);const o=e.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 n=await r.blob();if(n.type.startsWith("image/"))throw new Error(f);const t=e.type==="pdf"?"attachment.pdf":"attachment.docx";return new File([n],e.fileName||t,{type:e.mimeType||n.type})}async function k(e){const{attachment:o,documentId:r,documentSession:n}=e,t=e.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 h=n.getWorkingDocument(),u=h.children.length;if(!d(h)&&!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&&!h.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 D(o);let p;if(o.type==="docx"){const{FileImporter:a}=await import("./FileImporter-DVnYOJHp.js"),s=await a.parseFile(m),i=n.getYDoc();if(t)p=g(i,s,t);else{if(!d(n.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 l=s.pendingDocxCarrier;if(delete s.pendingDocxCarrier,i.transact(()=>{const c=i.getXmlFragment("content");c.length>0&&c.delete(0,c.length),y(i,s)}),l){const{storeDocxCarrier:c}=await import("./DocxGraft-CJ12C9WP.js");await c(i,l.bytes,{hash:l.hash})}}}else{const{importPdfIntoExistingDocument:a}=await import("./PdfImportService-D6uUKGMf.js");await a(m,r,n.getYDoc(),void 0,t)}const w=n.getWorkingDocument();return{blockCount:p??(t?Math.max(0,w.children.length-u):w.children.length),fileName:o.fileName||m.name}}export{k as importAttachmentIntoDocument,d as isEmptyDocumentForAttachmentImport};
1
+ import{Q as d,R as g,T as y}from"./index-CjeGoI2g.js";const f="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 D(e){if(e.type==="pdf"&&(e.urls?.length??0)>1)throw new Error(f);const o=e.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 n=await r.blob();if(n.type.startsWith("image/"))throw new Error(f);const t=e.type==="pdf"?"attachment.pdf":"attachment.docx";return new File([n],e.fileName||t,{type:e.mimeType||n.type})}async function k(e){const{attachment:o,documentId:r,documentSession:n}=e,t=e.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 h=n.getWorkingDocument(),u=h.children.length;if(!d(h)&&!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&&!h.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 D(o);let p;if(o.type==="docx"){const{FileImporter:a}=await import("./FileImporter-CjUX2S4s.js"),s=await a.parseFile(m),i=n.getYDoc();if(t)p=g(i,s,t);else{if(!d(n.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 l=s.pendingDocxCarrier;if(delete s.pendingDocxCarrier,i.transact(()=>{const c=i.getXmlFragment("content");c.length>0&&c.delete(0,c.length),y(i,s)}),l){const{storeDocxCarrier:c}=await import("./DocxGraft-B6W7fbh4.js");await c(i,l.bytes,{hash:l.hash})}}}else{const{importPdfIntoExistingDocument:a}=await import("./PdfImportService-OE9G383I.js");await a(m,r,n.getYDoc(),void 0,t)}const w=n.getWorkingDocument();return{blockCount:p??(t?Math.max(0,w.children.length-u):w.children.length),fileName:o.fileName||m.name}}export{k as importAttachmentIntoDocument,d as isEmptyDocumentForAttachmentImport};
@@ -1 +1 @@
1
- import{O as d,P as g,Q as y}from"./index-F-kHIwWT.js";const f="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 D(e){if(e.type==="pdf"&&(e.urls?.length??0)>1)throw new Error(f);const o=e.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 n=await r.blob();if(n.type.startsWith("image/"))throw new Error(f);const t=e.type==="pdf"?"attachment.pdf":"attachment.docx";return new File([n],e.fileName||t,{type:e.mimeType||n.type})}async function k(e){const{attachment:o,documentId:r,documentSession:n}=e,t=e.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 h=n.getWorkingDocument(),u=h.children.length;if(!d(h)&&!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&&!h.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 D(o);let p;if(o.type==="docx"){const{FileImporter:a}=await import("./FileImporter-q9mCch0J.js"),s=await a.parseFile(m),i=n.getYDoc();if(t)p=g(i,s,t);else{if(!d(n.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 l=s.pendingDocxCarrier;if(delete s.pendingDocxCarrier,i.transact(()=>{const c=i.getXmlFragment("content");c.length>0&&c.delete(0,c.length),y(i,s)}),l){const{storeDocxCarrier:c}=await import("./DocxGraft-DcmFuUkd.js");await c(i,l.bytes,{hash:l.hash})}}}else{const{importPdfIntoExistingDocument:a}=await import("./PdfImportService-CBD8TL1k.js");await a(m,r,n.getYDoc(),void 0,t)}const w=n.getWorkingDocument();return{blockCount:p??(t?Math.max(0,w.children.length-u):w.children.length),fileName:o.fileName||m.name}}export{k as importAttachmentIntoDocument,d as isEmptyDocumentForAttachmentImport};
1
+ import{Q as d,R as g,T as y}from"./index-DyOcu9mD.js";const f="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 D(e){if(e.type==="pdf"&&(e.urls?.length??0)>1)throw new Error(f);const o=e.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 n=await r.blob();if(n.type.startsWith("image/"))throw new Error(f);const t=e.type==="pdf"?"attachment.pdf":"attachment.docx";return new File([n],e.fileName||t,{type:e.mimeType||n.type})}async function k(e){const{attachment:o,documentId:r,documentSession:n}=e,t=e.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 h=n.getWorkingDocument(),u=h.children.length;if(!d(h)&&!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&&!h.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 D(o);let p;if(o.type==="docx"){const{FileImporter:a}=await import("./FileImporter-DtkbI6rF.js"),s=await a.parseFile(m),i=n.getYDoc();if(t)p=g(i,s,t);else{if(!d(n.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 l=s.pendingDocxCarrier;if(delete s.pendingDocxCarrier,i.transact(()=>{const c=i.getXmlFragment("content");c.length>0&&c.delete(0,c.length),y(i,s)}),l){const{storeDocxCarrier:c}=await import("./DocxGraft-Cj7v78BO.js");await c(i,l.bytes,{hash:l.hash})}}}else{const{importPdfIntoExistingDocument:a}=await import("./PdfImportService-Dj1-3L2B.js");await a(m,r,n.getYDoc(),void 0,t)}const w=n.getWorkingDocument();return{blockCount:p??(t?Math.max(0,w.children.length-u):w.children.length),fileName:o.fileName||m.name}}export{k as importAttachmentIntoDocument,d as isEmptyDocumentForAttachmentImport};
@@ -1 +1 @@
1
- import{r as jr,e as wn,c as xn}from"./MathRenderer-B0Y1h1JU.js";import{bF as Lr}from"./backend-Cq-khfdG.js";const Fr={js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",ts:"typescript",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",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(["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","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",comment:"#008000",function:"#795E26",variable:"#001080",operator:"#000000",punctuation:"#000000",type:"#267F99",property:"#001080",constant:"#0070C1",default:"#000000",background:"#ffffff",text:"#000000"};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("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","for","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","import","export","from","as","default","this","super"].includes(t)?"keyword":["string","template_string","string_fragment","template_literal"].includes(t)?"string":["number","integer","float"].includes(t)?"number":["comment","line_comment","block_comment"].includes(t)?"comment":t==="identifier"&&(e==="function_declaration"||e==="call_expression"||e==="method_definition")?"function":["type_identifier","predefined_type","type_annotation"].includes(t)?"type":t==="property_identifier"||e==="member_expression"?"property":["true","false","null","undefined"].includes(t)?"constant":["+","-","*","/","%","=","==","===","!=","!==","<",">","<=",">=","&&","||","!","&","|","^","~","<<",">>",">>>","++","--","+=","-=","*=","/=","?",":","=>"].includes(t)?"operator":["(",")","{","}","[","]",";",",",".","..."].includes(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")).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(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,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 grammar 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<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;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;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;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}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;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.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,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,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){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){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=="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.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"Diagram render failed"}function qn(t,e,n){if(e<=0||n<=0||!Number.isFinite(e)||!Number.isFinite(n))return;const r=Kt(t);Tr.set(r,{width:Math.max(1,Math.round(e)),height:Math.max(1,Math.round(n))})}function Nn(t,e){if(!e.image||e.width<=0||e.height<=0)return;const n=Kt(t);$r.set(n,{image:e.image,svg:e.svg,width:Math.max(1,Math.round(e.width)),height:Math.max(1,Math.round(e.height))})}function Dn(){typeof window<"u"&&window.dispatchEvent(new CustomEvent("diagram-render-ready"));for(const t of Fn)try{t()}catch(e){console.error("diagram render callback failed:",e)}}function Tn(t){if(typeof DOMParser<"u")try{const n=new DOMParser().parseFromString(t,"image/svg+xml").documentElement,r=n.getAttribute("viewBox");if(r){const l=r.split(/\s+/).map(s=>Number.parseFloat(s)).filter(s=>Number.isFinite(s));if(l.length===4&&l[2]>0&&l[3]>0)return{width:l[2],height:l[3]}}const a=n.getAttribute("width"),o=n.getAttribute("height");if(a&&o){const l=Number.parseFloat(a),s=Number.parseFloat(o);if(Number.isFinite(l)&&Number.isFinite(s))return{width:l,height:s}}}catch{}const e=t.match(/viewBox="([^"]+)"/i);if(e){const n=e[1].split(/\s+/).map(r=>Number.parseFloat(r)).filter(r=>Number.isFinite(r));if(n.length===4&&n[2]>0&&n[3]>0)return{width:n[2],height:n[3]}}return{width:800,height:xt}}function $n(t,e,n){if(t<=0||e<=0)return{width:n,height:xt};if(t<=n)return{width:t,height:e};const r=n/t;return{width:n,height:Math.max(40,Math.round(e*r))}}async function Pn(t,e,n){const r="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(t),a=new Image;return new Promise((o,l)=>{a.onload=()=>{o(a)},a.onerror=()=>{l(new Error("Failed to load rendered diagram SVG"))},a.src=r,a.width=Math.max(1,Math.round(e)),a.height=Math.max(1,Math.round(n))})}function Rn(t){const e=Math.max(1,t.naturalWidth||t.width||1),n=Math.max(1,t.naturalHeight||t.height||1),r=document.createElement("canvas");r.width=e,r.height=n;const a=r.getContext("2d");if(!a)throw new Error("Unable to create PNG export canvas");return a.drawImage(t,0,0,e,n),r.toDataURL("image/png")}async function zn(){if(typeof window>"u")throw new Error("Mermaid runtime requires a browser environment");return window.mermaid?window.mermaid:(Ae||(Ae=new Promise((t,e)=>{const n=document.querySelector('script[data-revise-mermaid="true"]');if(n){n.addEventListener("load",()=>t(window.mermaid)),n.addEventListener("error",()=>e(new Error("Failed to load Mermaid script")));return}const r=document.createElement("script");r.src="https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js",r.async=!0,r.defer=!0,r.setAttribute("data-revise-mermaid","true"),r.onload=()=>t(window.mermaid),r.onerror=()=>e(new Error("Failed to load Mermaid script")),document.head.appendChild(r)})),Ae)}function An(t){return{background:t.pageBackground,primaryColor:t.codeBackground,primaryBorderColor:t.codeBorder,primaryTextColor:t.codeText,secondaryColor:t.background,secondaryBorderColor:t.pageBorder,tertiaryColor:t.background,tertiaryBorderColor:t.pageBorder,lineColor:t.text,arrowheadColor:t.text,defaultLinkColor:t.text,textColor:t.text,edgeLabelBackground:t.pageBackground,clusterBkg:t.codeBackground,clusterBorder:t.pageBorder,nodeBorder:t.codeBorder,fontFamily:"Arial, sans-serif",cScale0:t.codeBackground,cScale1:t.background,cScale2:t.pageBackground,cScaleLabel0:t.text,cScaleLabel1:t.text,cScaleLabel2:t.text}}function Ar(t){if(typeof document>"u")return;const e=document.getElementById(t);e?.parentElement&&e.parentElement.removeChild(e)}const On={protocol:"mermaid",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(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 SVG 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(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("latex")||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,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(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)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"};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.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({...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:{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{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.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||[])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:"#3390ff",selectionOpacity:.4,inactiveSelection:"#9ac0e8",inactiveSelectionOpacity:.35,agentReadHighlight:"#7aaee6",searchHighlight:"#cc8f00",cursor:"#000000",pageBorder:"#dee2e6",pageBackground:"#ffffff",pageShadow:"rgba(0, 0, 0, 0.1)",diffInsert:"#22c55e",diffDelete:"#CF2A2A",diffEqual:"#000000",diffFormatChange:"#f59e0b",diffInsertText:"#0B8237",diffDeleteText:"#CF2A2A",diffFormatChangeText:"#78350f",debugText:"#ff0000",todoCheckboxBorder:"#c8ccd5",todoCheckboxBackground:"#ffffff",todoCheckboxChecked:"#46b35e",todoCheckboxCheckmark:"#46b35e",todoCheckedText:"#6c757d",codeBackground:"#f5f5f5",codeBorder:"#e0e0e0",codeText:"#333333"},Hn={isDark:!0,background:"#080a0e",text:"#c9c9c9",linkText:"#4099ff",selection:"#4099ff",selectionOpacity:.4,inactiveSelection:"#5a7a9e",inactiveSelectionOpacity:.35,agentReadHighlight:"#24568f",searchHighlight:"#fbbf24",cursor:"#ffffff",pageBorder:"#1e2430",pageBackground:"#05060a",pageShadow:"rgba(0, 0, 0, 0.5)",diffInsert:"#50B173",diffDelete:"#f87171",diffEqual:"#c9c9c9",diffFormatChange:"#fbbf24",diffInsertText:"#50B173",diffDeleteText:"#f87171",diffFormatChangeText:"#f5a91d",debugText:"#ff6b6b",todoCheckboxBorder:"#2f3747",todoCheckboxBackground:"#05060a",todoCheckboxChecked:"#0e6b30",todoCheckboxCheckmark:"#f3f7ff",todoCheckedText:"#6f7689",codeBackground:"#0c0f15",codeBorder:"#2a2f3a",codeText:"#c9c9c9"};function Un(t){if(typeof window>"u")return!1;const e=t?.closest?.("[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){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(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","latex","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",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"],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:"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:"gray",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",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?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.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])**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;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&&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)return;const e=ra(t);if(e)return e;if(/^[a-z]+$/i.test(t.trim()))return;const n=Kr(t);if(n)return Yr(n)?.name}function fa(t){if(!t)return;const e=ca(t);if(e)return e;const n=ia(t);if(!n||n.alpha<.35)return;const{hue:r,lightness:a,saturation:o,maxChannel:l}=la(n.rgb),s=o>.18&&r!==null?[sa(r)]:["gray"],f=Yr(n.rgb,!0,s);if(!f)return;if(f.distance===0)return f.name;if(f.name==="gray")return f.distance>70**2||o>.12||a<.68||a>.92?void 0:f.name;const m=o>=.8&&l>=220&&a>=.45;if(!(f.distance>95**2&&!m)&&!(a>.92)&&!(l<150)&&!(o<.22)&&!(a<.55&&l<220))return f.name}const O={paragraph:16,h1:32,h2:24,h3:20,h4:18,h5:16,h6:14,code:14},te={paragraph:1.4,heading:1.2,code:1.5};function tn(t){if(!t.hasOwnProperty("heading"))return O.paragraph;switch(t.heading){case 1:return O.h1;case 2:return O.h2;case 3:return O.h3;case 4:return O.h4;case 5:return O.h5;case 6:return O.h6;default:return O.paragraph}}function en(t){return t.lineSpacing!==void 0?t.lineSpacing:t.heading?te.heading:te.paragraph}function ua(t){const e=tn(t),n=en(t);return e*n}function da(t){return t.lineSpacing!==void 0?t.lineSpacing:te.paragraph}function ha(){var t=function(e){var n={R:"13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73",EN:"1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9",ES:"17,2,6dp+1,f+1,av,16vr,mx+1,4o,2",ET:"z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj",AN:"16o+5,2j+9,2+1,35,ed,1ff2+9,87+u",CS:"18,2+1,b,2u,12k,55v,l,17v0,2,3,53,2+1,b",B:"a,3,f+2,2v,690",S:"9,2,k",WS:"c,k,4f4,1vk+a,u,1j,335",ON:"x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2+2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2+3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i",BN:"0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1",NSM:"lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1af+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+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,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:"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|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(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){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,+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>-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(",").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(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}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.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]=$,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.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];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)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.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.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),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 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):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=[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],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<=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._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)}}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++){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<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],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&&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(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(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]})}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-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]]=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]]&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<=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}}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){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>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>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>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(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++)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.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>=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){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.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=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","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;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(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||(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(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<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+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{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,rn as t,tn as u,Jn as v,ba as w,oa as x,ua as y,da as z};
1
+ import{r as Ir,e as wn,c as xn}from"./MathRenderer-B0Y1h1JU.js";import{bG as Lr}from"./backend-MFpDFVrD.js";const Fr={js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",ts:"typescript",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",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(["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","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",comment:"#008000",function:"#795E26",variable:"#001080",operator:"#000000",punctuation:"#000000",type:"#267F99",property:"#001080",constant:"#0070C1",default:"#000000",background:"#ffffff",text:"#000000"};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("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","for","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","import","export","from","as","default","this","super"].includes(t)?"keyword":["string","template_string","string_fragment","template_literal"].includes(t)?"string":["number","integer","float"].includes(t)?"number":["comment","line_comment","block_comment"].includes(t)?"comment":t==="identifier"&&(e==="function_declaration"||e==="call_expression"||e==="method_definition")?"function":["type_identifier","predefined_type","type_annotation"].includes(t)?"type":t==="property_identifier"||e==="member_expression"?"property":["true","false","null","undefined"].includes(t)?"constant":["+","-","*","/","%","=","==","===","!=","!==","<",">","<=",">=","&&","||","!","&","|","^","~","<<",">>",">>>","++","--","+=","-=","*=","/=","?",":","=>"].includes(t)?"operator":["(",")","{","}","[","]",";",",",".","..."].includes(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")).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(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,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 grammar 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<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;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;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;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}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;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.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,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,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){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){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=="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.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"Diagram render failed"}function qn(t,e,n){if(e<=0||n<=0||!Number.isFinite(e)||!Number.isFinite(n))return;const r=Kt(t);Tr.set(r,{width:Math.max(1,Math.round(e)),height:Math.max(1,Math.round(n))})}function Nn(t,e){if(!e.image||e.width<=0||e.height<=0)return;const n=Kt(t);$r.set(n,{image:e.image,svg:e.svg,width:Math.max(1,Math.round(e.width)),height:Math.max(1,Math.round(e.height))})}function Dn(){typeof window<"u"&&window.dispatchEvent(new CustomEvent("diagram-render-ready"));for(const t of Fn)try{t()}catch(e){console.error("diagram render callback failed:",e)}}function Tn(t){if(typeof DOMParser<"u")try{const n=new DOMParser().parseFromString(t,"image/svg+xml").documentElement,r=n.getAttribute("viewBox");if(r){const l=r.split(/\s+/).map(s=>Number.parseFloat(s)).filter(s=>Number.isFinite(s));if(l.length===4&&l[2]>0&&l[3]>0)return{width:l[2],height:l[3]}}const a=n.getAttribute("width"),o=n.getAttribute("height");if(a&&o){const l=Number.parseFloat(a),s=Number.parseFloat(o);if(Number.isFinite(l)&&Number.isFinite(s))return{width:l,height:s}}}catch{}const e=t.match(/viewBox="([^"]+)"/i);if(e){const n=e[1].split(/\s+/).map(r=>Number.parseFloat(r)).filter(r=>Number.isFinite(r));if(n.length===4&&n[2]>0&&n[3]>0)return{width:n[2],height:n[3]}}return{width:800,height:xt}}function $n(t,e,n){if(t<=0||e<=0)return{width:n,height:xt};if(t<=n)return{width:t,height:e};const r=n/t;return{width:n,height:Math.max(40,Math.round(e*r))}}async function Pn(t,e,n){const r="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(t),a=new Image;return new Promise((o,l)=>{a.onload=()=>{o(a)},a.onerror=()=>{l(new Error("Failed to load rendered diagram SVG"))},a.src=r,a.width=Math.max(1,Math.round(e)),a.height=Math.max(1,Math.round(n))})}function Rn(t){const e=Math.max(1,t.naturalWidth||t.width||1),n=Math.max(1,t.naturalHeight||t.height||1),r=document.createElement("canvas");r.width=e,r.height=n;const a=r.getContext("2d");if(!a)throw new Error("Unable to create PNG export canvas");return a.drawImage(t,0,0,e,n),r.toDataURL("image/png")}async function zn(){if(typeof window>"u")throw new Error("Mermaid runtime requires a browser environment");return window.mermaid?window.mermaid:(Ae||(Ae=new Promise((t,e)=>{const n=document.querySelector('script[data-revise-mermaid="true"]');if(n){n.addEventListener("load",()=>t(window.mermaid)),n.addEventListener("error",()=>e(new Error("Failed to load Mermaid script")));return}const r=document.createElement("script");r.src="https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js",r.async=!0,r.defer=!0,r.setAttribute("data-revise-mermaid","true"),r.onload=()=>t(window.mermaid),r.onerror=()=>e(new Error("Failed to load Mermaid script")),document.head.appendChild(r)})),Ae)}function An(t){return{background:t.pageBackground,primaryColor:t.codeBackground,primaryBorderColor:t.codeBorder,primaryTextColor:t.codeText,secondaryColor:t.background,secondaryBorderColor:t.pageBorder,tertiaryColor:t.background,tertiaryBorderColor:t.pageBorder,lineColor:t.text,arrowheadColor:t.text,defaultLinkColor:t.text,textColor:t.text,edgeLabelBackground:t.pageBackground,clusterBkg:t.codeBackground,clusterBorder:t.pageBorder,nodeBorder:t.codeBorder,fontFamily:"Arial, sans-serif",cScale0:t.codeBackground,cScale1:t.background,cScale2:t.pageBackground,cScaleLabel0:t.text,cScaleLabel1:t.text,cScaleLabel2:t.text}}function Ar(t){if(typeof document>"u")return;const e=document.getElementById(t);e?.parentElement&&e.parentElement.removeChild(e)}const On={protocol:"mermaid",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(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 SVG 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(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("latex")||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,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(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)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"};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.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({...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:{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{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.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||[])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:"#3390ff",selectionOpacity:.4,inactiveSelection:"#9ac0e8",inactiveSelectionOpacity:.35,agentReadHighlight:"#7aaee6",searchHighlight:"#cc8f00",cursor:"#000000",pageBorder:"#dee2e6",pageBackground:"#ffffff",pageShadow:"rgba(0, 0, 0, 0.1)",diffInsert:"#22c55e",diffDelete:"#CF2A2A",diffEqual:"#000000",diffFormatChange:"#f59e0b",diffInsertText:"#0B8237",diffDeleteText:"#CF2A2A",diffFormatChangeText:"#78350f",debugText:"#ff0000",todoCheckboxBorder:"#c8ccd5",todoCheckboxBackground:"#ffffff",todoCheckboxChecked:"#46b35e",todoCheckboxCheckmark:"#46b35e",todoCheckedText:"#6c757d",codeBackground:"#f5f5f5",codeBorder:"#e0e0e0",codeText:"#333333"},Un={isDark:!0,background:"#080a0e",text:"#c9c9c9",linkText:"#4099ff",selection:"#4099ff",selectionOpacity:.4,inactiveSelection:"#5a7a9e",inactiveSelectionOpacity:.35,agentReadHighlight:"#24568f",searchHighlight:"#fbbf24",cursor:"#ffffff",pageBorder:"#1e2430",pageBackground:"#05060a",pageShadow:"rgba(0, 0, 0, 0.5)",diffInsert:"#50B173",diffDelete:"#f87171",diffEqual:"#c9c9c9",diffFormatChange:"#fbbf24",diffInsertText:"#50B173",diffDeleteText:"#f87171",diffFormatChangeText:"#f5a91d",debugText:"#ff6b6b",todoCheckboxBorder:"#2f3747",todoCheckboxBackground:"#05060a",todoCheckboxChecked:"#0e6b30",todoCheckboxCheckmark:"#f3f7ff",todoCheckedText:"#6f7689",codeBackground:"#0c0f15",codeBorder:"#2a2f3a",codeText:"#c9c9c9"};function Jn(t){if(typeof window>"u")return!1;const e=t?.closest?.("[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){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(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","latex","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",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"],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:"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:"gray",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",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?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.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])**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;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&&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)return;const e=ra(t);if(e)return e;if(/^[a-z]+$/i.test(t.trim()))return;const n=Kr(t);if(n)return Yr(n)?.name}function fa(t){if(!t)return;const e=ca(t);if(e)return e;const n=ia(t);if(!n||n.alpha<.35)return;const{hue:r,lightness:a,saturation:o,maxChannel:l}=la(n.rgb),s=o>.18&&r!==null?[sa(r)]:["gray"],f=Yr(n.rgb,!0,s);if(!f)return;if(f.distance===0)return f.name;if(f.name==="gray")return f.distance>70**2||o>.12||a<.68||a>.92?void 0:f.name;const m=o>=.8&&l>=220&&a>=.45;if(!(f.distance>95**2&&!m)&&!(a>.92)&&!(l<150)&&!(o<.22)&&!(a<.55&&l<220))return f.name}const O={paragraph:16,h1:32,h2:24,h3:20,h4:18,h5:16,h6:14,code:14},te={paragraph:1.4,heading:1.2,code:1.5};function tn(t){if(!t.hasOwnProperty("heading"))return O.paragraph;switch(t.heading){case 1:return O.h1;case 2:return O.h2;case 3:return O.h3;case 4:return O.h4;case 5:return O.h5;case 6:return O.h6;default:return O.paragraph}}function en(t){return t.lineSpacing!==void 0?t.lineSpacing:t.heading?te.heading:te.paragraph}function ua(t){const e=tn(t),n=en(t);return e*n}function da(t){return t.lineSpacing!==void 0?t.lineSpacing:te.paragraph}function ha(){var t=function(e){var n={R:"13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73",EN:"1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9",ES:"17,2,6dp+1,f+1,av,16vr,mx+1,4o,2",ET:"z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj",AN:"16o+5,2j+9,2+1,35,ed,1ff2+9,87+u",CS:"18,2+1,b,2u,12k,55v,l,17v0,2,3,53,2+1,b",B:"a,3,f+2,2v,690",S:"9,2,k",WS:"c,k,4f4,1vk+a,u,1j,335",ON:"x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2+2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2+3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i",BN:"0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1",NSM:"lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1af+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+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,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:"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|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(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){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,+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>-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(",").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(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}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.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]=$,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.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];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)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.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.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),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 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):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=[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],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<=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._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)}}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++){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<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],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&&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(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(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]})}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-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]]=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]]&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<=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}}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){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>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>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>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(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++)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.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>=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){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.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=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","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;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(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||(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(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<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+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{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,rn as t,tn as u,ua as v,da as w,Vn as x,ba as y,oa as z};