documint 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,587 +1,67 @@
1
- import{useEffect as k0,useEffectEvent as B1,useLayoutEffect as vG,useMemo as f0,useRef as y1,useState as MM}from"react";function _2($){let M=F1($.children);return{children:$.children,id:G1($.path,"paragraph",M),plainText:M,type:"paragraph"}}function I($){return _2({children:NM(void 0,$.text)})}function h4($){let M=F1($.children);return{children:$.children,depth:$.depth,id:G1($.path,"heading",`${$.depth}:${M}`),plainText:M,type:"heading"}}function Z0($){return h4({children:NM(void 0,$.text),depth:$.depth})}function W1($){let M=$.marks??[];return{id:G1($.path,"text",`${$.text}:${M.join(",")}`),marks:M,text:$.text,type:"text"}}function H2($={}){return{id:G1($.path,"break","break"),type:"break"}}function S0($){return{code:$.code,id:G1($.path,"inlineCode",$.code),type:"inlineCode"}}function m0($){return{children:$.children,id:G1($.path,"link",`${$.url}:${F1($.children)}`),title:$.title??null,type:"link",url:$.url}}function I4($){let M=$.alt??null,J=$.width??null;return{alt:M,id:G1($.path,"image",`${$.url}:${J??""}:${M??""}`),title:$.title??null,type:"image",url:$.url,width:J}}function p4($){return{id:G1($.path,"unsupported",$.source),originalType:$.originalType,source:$.source,type:"unsupported"}}function n1($){let M=g0($.children);return{checked:$.checked??null,children:$.children,id:G1($.path,"listItem",M),plainText:M,spread:$.spread??!1,type:"listItem"}}function y0($){let M=$.items.map((J)=>J.plainText).join(`
2
- `);return{id:G1($.path,"list",`${String($.ordered)}:${M}`),items:$.items,ordered:$.ordered,plainText:M,spread:$.spread??!1,start:$.start??null,type:"list"}}function T1($){let M=g0($.children);return{children:$.children,id:G1($.path,"blockquote",M),plainText:M,type:"blockquote"}}function N6($){return{id:G1($.path,"code",`${$.language??""}:${$.source}`),language:$.language??null,meta:$.meta??null,plainText:$.source,source:$.source,type:"code"}}function X0($){let M=F1($.children);return{children:$.children,id:G1($.path,"tableCell",M),plainText:M}}function v0($){return{cells:$.cells,id:G1($.path,"tableRow",String($.cells.length))}}function V0($){let M=$.rows.map((J)=>J.cells.map((Z)=>Z.plainText).join(" | ")).join(`
3
- `);return{align:$.align??[],id:G1($.path,"table",M),plainText:M,rows:$.rows,type:"table"}}function l4(){return{id:"",plainText:"",type:"thematicBreak"}}function r4($){return{id:G1($.path,"unsupported",$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"unsupported"}}function qM($){return{attributes:$.attributes,body:$.body,id:G1($.path,"directive",`${$.name}{${$.attributes}}:${$.body}`),name:$.name,plainText:$.body,type:"directive"}}function k1($,M){return $.type==="heading"?h4({children:M,depth:$.depth}):_2({children:M})}function b1($,M){return n1({checked:$.checked,children:M,spread:$.spread})}function $1($,M,J={}){return y0({items:M,ordered:J.ordered??$.ordered,spread:J.spread??$.spread,start:J.start??$.start})}function r1($,M){return V0({align:$.align,rows:M})}function c4($,M){return N6({language:$.language,meta:$.meta,source:M})}function x4($,M){return r4({originalType:$.originalType,source:M})}function NM($,M){return M.length>0?[W1({path:$?`${$}.children.0`:void 0,text:M})]:[]}function G1($,M,J){return $?Q1(M,$,J):""}function h0($,M=[]){return{blocks:$.map((J,Z)=>U6(J,Z)),comments:M}}function I0($,M,J,Z){let X=Z.map((Q,K)=>U6(Q,M+K)),A=$.blocks.slice(M+J),Y=Z.length===J?A:A.map((Q,K)=>U6(Q,M+X.length+K));return{blocks:[...$.blocks.slice(0,M),...X,...Y],comments:$.comments}}function UM($,M,J,Z){return{blocks:$.blocks,comments:[...$.comments.slice(0,M),...Z,...$.comments.slice(M+J)]}}function F1($){return $.map((M)=>{switch(M.type){case"break":return`
4
- `;case"image":return M.alt??"";case"inlineCode":return M.code;case"link":return F1(M.children);case"text":return M.text;case"unsupported":return M.source}}).join("")}function g0($){return $.map((M)=>{switch(M.type){case"blockquote":case"listItem":return g0(M.children);case"code":return M.source;case"directive":return M.body;case"heading":case"paragraph":return F1(M.children);case"list":return M.items.map((J)=>J.plainText).join(`
1
+ import{useEffect as B2,useEffectEvent as F2,useLayoutEffect as OV,useMemo as $1,useRef as L1,useState as H$}from"react";function H2($){let M=N0($.children);return{children:$.children,id:q0($.path,"paragraph",M),plainText:M,type:"paragraph"}}function r($){return H2({children:j$(void 0,$.text)})}function s4($){let M=N0($.children);return{children:$.children,depth:$.depth,id:q0($.path,"heading",`${$.depth}:${M}`),plainText:M,type:"heading"}}function M1($){return s4({children:j$(void 0,$.text),depth:$.depth})}function H0($){let M=$.marks??[];return{id:q0($.path,"text",`${$.text}:${M.join(",")}`),marks:M,text:$.text,type:"text"}}function P2($={}){return{id:q0($.path,"break","break"),type:"break"}}function S1($){return{code:$.code,id:q0($.path,"inlineCode",$.code),type:"inlineCode"}}function u1($){return{children:$.children,id:q0($.path,"link",`${$.url}:${N0($.children)}`),title:$.title??null,type:"link",url:$.url}}function o4($){let M=$.alt??null,J=$.width??null;return{alt:M,id:q0($.path,"image",`${$.url}:${J??""}:${M??""}`),title:$.title??null,type:"image",url:$.url,width:J}}function n4($){return{id:q0($.path,"unsupported",$.source),originalType:$.originalType,source:$.source,type:"unsupported"}}function d0($){let M=h1($.children);return{checked:$.checked??null,children:$.children,id:q0($.path,"listItem",M),plainText:M,spread:$.spread??!1,type:"listItem"}}function P1($){let M=$.items.map((J)=>J.plainText).join(`
2
+ `);return{id:q0($.path,"list",`${String($.ordered)}:${M}`),items:$.items,ordered:$.ordered,plainText:M,spread:$.spread??!1,start:$.start??null,type:"list"}}function P0($){let M=h1($.children);return{children:$.children,id:q0($.path,"blockquote",M),plainText:M,type:"blockquote"}}function P8($){return{id:q0($.path,"code",`${$.language??""}:${$.source}`),language:$.language??null,meta:$.meta??null,plainText:$.source,source:$.source,type:"code"}}function J1($){let M=N0($.children);return{children:$.children,id:q0($.path,"tableCell",M),plainText:M}}function v1($){return{cells:$.cells,id:q0($.path,"tableRow",String($.cells.length))}}function z1($){let M=$.rows.map((J)=>J.cells.map((Z)=>Z.plainText).join(" | ")).join(`
3
+ `);return{align:$.align??[],id:q0($.path,"table",M),plainText:M,rows:$.rows,type:"table"}}function t4(){return{id:"",plainText:"",type:"thematicBreak"}}function e4($){return{id:q0($.path,"unsupported",$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"unsupported"}}function C$($){return{attributes:$.attributes,body:$.body,id:q0($.path,"directive",`${$.name}{${$.attributes}}:${$.body}`),name:$.name,plainText:$.body,type:"directive"}}function C0($,M){return $.type==="heading"?s4({children:M,depth:$.depth}):H2({children:M})}function E0($,M){return d0({checked:$.checked,children:M,spread:$.spread})}function $0($,M,J={}){return P1({items:M,ordered:J.ordered??$.ordered,spread:J.spread??$.spread,start:J.start??$.start})}function S0($,M){return z1({align:$.align,rows:M})}function $5($,M){return P8({language:$.language,meta:$.meta,source:M})}function M5($,M){return e4({originalType:$.originalType,source:M})}function j$($,M){return M.length>0?[H0({path:$?`${$}.children.0`:void 0,text:M})]:[]}function q0($,M,J){return $?Y0(M,$,J):""}function g1($,M=[],J){return{blocks:$.map((Z,X)=>z8(Z,X)),comments:M,frontMatter:J}}function I1($,M,J,Z){let X=Z.map((Q,K)=>z8(Q,M+K)),D=$.blocks.slice(M+J),Y=Z.length===J?D:D.map((Q,K)=>z8(Q,M+X.length+K));return{blocks:[...$.blocks.slice(0,M),...X,...Y],comments:$.comments,frontMatter:$.frontMatter}}function L$($,M,J,Z){return{blocks:$.blocks,comments:[...$.comments.slice(0,M),...Z,...$.comments.slice(M+J)],frontMatter:$.frontMatter}}function N0($){return $.map((M)=>{switch(M.type){case"break":return`
4
+ `;case"image":return M.alt??"";case"inlineCode":return M.code;case"link":return N0(M.children);case"text":return M.text;case"unsupported":return M.source}}).join("")}function h1($){return $.map((M)=>{switch(M.type){case"blockquote":case"listItem":return h1(M.children);case"code":return M.source;case"directive":return M.body;case"heading":case"paragraph":return N0(M.children);case"list":return M.items.map((J)=>J.plainText).join(`
5
5
  `);case"table":return M.rows.map((J)=>J.cells.map((Z)=>Z.plainText).join(" | ")).join(`
6
6
  `);case"thematicBreak":return"";case"unsupported":return M.source}}).join(`
7
- `).trim()}function U6($,M){return d4($,`root.${M}`)}function d4($,M){switch($.type){case"blockquote":{let J=$.children.map((X,A)=>d4(X,`${M}.children.${A}`)),Z=g0(J);return{children:J,id:Q1("blockquote",M,Z),plainText:Z,type:"blockquote"}}case"code":return{id:Q1("code",M,`${$.language??""}:${$.source}`),language:$.language,meta:$.meta,plainText:$.source,source:$.source,type:"code"};case"directive":return{attributes:$.attributes,body:$.body,id:Q1("directive",M,`${$.name}{${$.attributes}}:${$.body}`),name:$.name,plainText:$.body,type:"directive"};case"heading":{let J=$.children.map((X,A)=>a4(X,`${M}.children.${A}`)),Z=F1(J);return{children:J,depth:$.depth,id:Q1("heading",M,`${$.depth}:${Z}`),plainText:Z,type:"heading"}}case"list":{let J=$.items.map((X,A)=>d4(X,`${M}.children.${A}`)),Z=J.map((X)=>X.plainText).join(`
8
- `);return{id:Q1("list",M,`${String($.ordered)}:${Z}`),items:J,ordered:$.ordered,plainText:Z,spread:$.spread,start:$.start,type:"list"}}case"listItem":{let J=$.children.map((X,A)=>d4(X,`${M}.children.${A}`)),Z=g0(J);return{checked:$.checked,children:J,id:Q1("listItem",M,Z),plainText:Z,spread:$.spread,type:"listItem"}}case"paragraph":{let J=$.children.map((X,A)=>a4(X,`${M}.children.${A}`)),Z=F1(J);return{children:J,id:Q1("paragraph",M,Z),plainText:Z,type:"paragraph"}}case"table":{let J=$.rows.map((X,A)=>AZ(X,`${M}.rows.${A}`)),Z=J.map((X)=>X.cells.map((A)=>A.plainText).join(" | ")).join(`
9
- `);return{align:$.align,id:Q1("table",M,Z),plainText:Z,rows:J,type:"table"}}case"thematicBreak":return{id:Q1("thematicBreak",M,"thematic-break"),plainText:"",type:"thematicBreak"};case"unsupported":return{id:Q1("unsupported",M,$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"unsupported"}}}function AZ($,M){return{cells:$.cells.map((J,Z)=>{let X=J.children.map((Y,Q)=>a4(Y,`${M}.cells.${Z}.children.${Q}`)),A=F1(X);return{children:X,id:Q1("tableCell",`${M}.cells.${Z}`,A),plainText:A}}),id:Q1("tableRow",M,String($.cells.length))}}function a4($,M){switch($.type){case"break":return{id:Q1("break",M,"break"),type:"break"};case"image":return{alt:$.alt,id:Q1("image",M,`${$.url}:${$.width??""}:${$.alt??""}`),title:$.title,type:"image",url:$.url,width:$.width};case"inlineCode":return{code:$.code,id:Q1("inlineCode",M,$.code),type:"inlineCode"};case"link":{let J=$.children.map((X,A)=>a4(X,`${M}.children.${A}`)),Z=F1(J);return{children:J,id:Q1("link",M,`${$.url}:${Z}`),title:$.title,type:"link",url:$.url}}case"text":return{id:Q1("text",M,`${$.text}:${$.marks.join(",")}`),marks:$.marks,text:$.text,type:"text"};case"unsupported":return{id:Q1("unsupported",M,$.source),originalType:$.originalType,source:$.source,type:"unsupported"}}}function P2($){return $.map((M)=>{switch(M.type){case"blockquote":return{...M,children:P2(M.children)};case"heading":case"paragraph":return k1(M,G6(M.children));case"list":return{...M,items:M.items.map((J)=>({...J,children:P2(J.children)}))};case"listItem":return{...M,children:P2(M.children)};case"table":return r1(M,M.rows.map((J)=>({...J,cells:J.cells.map((Z)=>({...Z,children:G6(Z.children)}))})));default:return M}})}function G6($){let M=[...$];for(let J=M.length-1;J>=0;J-=1){let Z=M[J];if(Z.type==="text"){let X=Z.text.replace(/[ \t]+$/u,"");if(X.length===Z.text.length)return M;if(X.length===0){M.splice(J,1);continue}return M[J]={...Z,text:X},M}if(Z.type==="link"){let X=G6(Z.children);if(X.length===Z.children.length&&X.every((A,Y)=>A===Z.children[Y]))return M;if(X.length===0){M.splice(J,1);continue}return M[J]={...Z,children:X},M}return M}return M}function Q1($,M,J){let Z=2166136261;for(let X of`${$}:${M}:${J}`)Z^=X.charCodeAt(0),Z=Math.imul(Z,16777619);return`${$}-${(Z>>>0).toString(36)}`}function W2($,M){B6($.blocks,M,FM(),DM())}function BM($,M){B6($,M,FM(),DM())}function B6($,M,J,Z){for(let[X,A]of $.entries()){if(J.stopped)return;let Y=`${Z.pathPrefix}.${X}`,Q={blockAncestors:Z.blockAncestors,depth:Z.depth,parentBlock:Z.parentBlock,path:Y},K=M.enterBlock?.(A,Q);if(p0(K,J))return;if(K!=="skip")switch(A.type){case"list":GM(A.items,A,M,J,Z,Y);break;case"blockquote":case"listItem":GM(A.children,A,M,J,Z,Y);break;case"heading":case"paragraph":F6(A.children,M,J,{block:A,blockAncestors:[...Z.blockAncestors,A],inlineAncestors:[],parentInline:null,pathPrefix:`${Y}.children`});break;case"table":QZ(A,M,J,{blockAncestors:[...Z.blockAncestors,A],pathPrefix:Y});break;case"code":case"directive":case"thematicBreak":case"unsupported":break}if(J.stopped)return;if(p0(M.leaveBlock?.(A,Q),J))return}}function F6($,M,J,Z){for(let[X,A]of $.entries()){if(J.stopped)return;let Y=`${Z.pathPrefix}.${X}`,Q={block:Z.block,blockAncestors:Z.blockAncestors,inlineAncestors:Z.inlineAncestors,parentInline:Z.parentInline,path:Y},K=M.enterInline?.(A,Q);if(p0(K,J))return;if(K!=="skip"){if(A.type==="link")YZ(A.children,A,M,J,Z,Y)}if(J.stopped)return;if(p0(M.leaveInline?.(A,Q),J))return}}function FM(){return{stopped:!1}}function DM(){return{blockAncestors:[],depth:0,parentBlock:null,pathPrefix:"root"}}function GM($,M,J,Z,X,A){B6($,J,Z,{blockAncestors:[...X.blockAncestors,M],depth:X.depth+1,parentBlock:M,pathPrefix:`${A}.children`})}function YZ($,M,J,Z,X,A){F6($,J,Z,{block:X.block,blockAncestors:X.blockAncestors,inlineAncestors:[...X.inlineAncestors,M],parentInline:M,pathPrefix:`${A}.children`})}function QZ($,M,J,Z){for(let[X,A]of $.rows.entries())for(let[Y,Q]of A.cells.entries()){if(J.stopped)return;let K=`${Z.pathPrefix}.rows.${X}.cells.${Y}`,q={blockAncestors:Z.blockAncestors,cellIndex:Y,path:K,row:A,rowIndex:X,table:$},N=M.enterTableCell?.(Q,q);if(p0(N,J))return;if(N!=="skip")F6(Q.children,M,J,{block:$,blockAncestors:Z.blockAncestors,inlineAncestors:[],parentInline:null,pathPrefix:`${K}.children`});if(J.stopped)return;if(p0(M.leaveTableCell?.(Q,q),J))return}}function p0($,M){if($!=="stop")return!1;return M.stopped=!0,!0}var D6="text";function _6($){return $==="text"||$==="code"||$==="tableCell"}function s4($){return $===D6?void 0:$}function i4($){let M=[];return W2($,{enterBlock(J){switch(J.type){case"heading":case"paragraph":M.push({containerKind:"text",containerOrdinal:M.length,id:J.id,text:F1(J.children)});break;case"code":M.push({containerKind:"code",containerOrdinal:M.length,id:J.id,text:J.source});break}},enterTableCell(J){M.push({containerKind:"tableCell",containerOrdinal:M.length,id:J.id,text:F1(J.children)})}}),M}function _M($){let M=new Set;return W2($,{enterInline(J){if(J.type==="image")M.add(J.url)}}),[...M]}function l0($,M){let J=null;return KZ($,{enterBlock(Z){if(Z.id===M)return J=Z,"stop"}}),J}function KZ($,M){if(Array.isArray($)){BM($,M);return}W2($,M)}var HM=24;function T2($,M,J){let Z=r0(M,0,$.text.length),X=r0(J,Z,$.text.length);return{kind:s4($.containerKind),prefix:$.text.slice(Math.max(0,Z-HM),Z)||void 0,suffix:$.text.slice(X,X+HM)||void 0}}function y2($,M,J){let Z=r0(M,0,$.text.length),X=r0(J,Z,$.text.length);return $.text.slice(Z,X)}var PM=48,WM=64,qZ=32;function V2($,M){let J=$.anchor.kind??D6,Z=i4(M).filter((Y)=>Y.containerKind===J),X=NZ($,Z);if(X.length>0)return TM($,X,null);let A=UZ($,Z);if(A.length>0)return TM($,A,"repaired");return{match:null,repair:null,status:"stale"}}function NZ($,M){let J=[],Z=$.quote;if(Z.length===0)return J;for(let X of M){let A=0;while(A<=X.text.length){let Y=X.text.indexOf(Z,A);if(Y===-1)break;J.push({container:X,endOffset:Y+Z.length,score:FZ($,X,Y),startOffset:Y}),A=Y+Math.max(1,Z.length)}}return J.sort((X,A)=>A.score-X.score),J}function UZ($,M){let J=[];for(let Z of M)J.push(...GZ($,Z));return J.sort((Z,X)=>X.score-Z.score),J}function GZ($,M){let J=[],Z=$.quote.length,X=M.text,A=$.anchor.prefix??"",Y=$.anchor.suffix??"";if(A.length>0&&Y.length>0){let Q=0;while(Q<=X.length){let K=X.indexOf(A,Q);if(K===-1)break;let q=K+A.length,N=X.indexOf(Y,q);if(N!==-1&&N>=q)J.push({container:M,endOffset:N,score:H6($,M,q,N,Z),startOffset:q});Q=K+Math.max(1,A.length)}return J}if(A.length>0){let Q=0;while(Q<=X.length){let K=X.indexOf(A,Q);if(K===-1)break;let q=K+A.length,N=r0(q+Z,q,X.length);J.push({container:M,endOffset:N,score:H6($,M,q,N,Z),startOffset:q}),Q=K+Math.max(1,A.length)}return J}if(Y.length>0){let Q=0;while(Q<=X.length){let K=X.indexOf(Y,Q);if(K===-1)break;let q=K,N=r0(q-Z,0,q);J.push({container:M,endOffset:q,score:H6($,M,N,q,Z),startOffset:N}),Q=K+Math.max(1,Y.length)}}return J}function TM($,M,J){let[Z,X]=M;if(!Z)return{match:null,repair:null,status:"stale"};if(X&&Z.score===X.score)return{match:null,repair:null,status:"ambiguous"};let A=T2(Z.container,Z.startOffset,Z.endOffset),Y=y2(Z.container,Z.startOffset,Z.endOffset),Q=J??(Y===$.quote&&(A.prefix??"")===($.anchor.prefix??"")&&(A.suffix??"")===($.anchor.suffix??"")?"matched":"repaired");return{match:BZ(Z.container,Z.startOffset,Z.endOffset),repair:{anchor:A,quote:Y},status:Q}}function BZ($,M,J){return{containerId:$.id,containerKind:$.containerKind,containerOrdinal:$.containerOrdinal,endOffset:J,startOffset:M}}function FZ($,M,J){let Z=0;if(yM(M.text,$.anchor.prefix,J))Z+=PM;if(VM(M.text,$.anchor.suffix,J+$.quote.length))Z+=PM;return Z}function H6($,M,J,Z,X){let A=0;if(yM(M.text,$.anchor.prefix,J))A+=WM;if(VM(M.text,$.anchor.suffix,Z))A+=WM;if(A+=Math.max(0,qZ-Math.abs(X-(Z-J))),$.quote.length>0){let Y=M.text.slice(J,Z);if(Y.length>0)A+=DZ($.quote,Y),A+=_Z($.quote,Y)}return A}function yM($,M,J){if(!M)return!1;return $.slice(Math.max(0,J-M.length),J)===M}function VM($,M,J){if(!M)return!1;return $.slice(J,J+M.length)===M}function DZ($,M){let J=0;while(J<$.length&&J<M.length&&$[J]===M[J])J+=1;return J}function _Z($,M){let J=0;while(J<$.length&&J<M.length&&$[$.length-1-J]===M[M.length-1-J])J+=1;return J}function r0($,M,J){return Math.min(Math.max($,M),J)}function P6($){if(!$||typeof $!=="object"||Array.isArray($))return null;let M=$,J=PZ(M.anchor),Z=typeof M.quote==="string"?M.quote:null,X=Array.isArray(M.comments)?M.comments.flatMap((A)=>{let Y=HZ(A);return Y?[Y]:[]}):[];if(!J||!Z||X.length===0)return null;return{quote:Z,anchor:J,comments:X,resolvedAt:typeof M.resolvedAt==="string"?M.resolvedAt:void 0}}function HZ($){if(!$||typeof $!=="object"||Array.isArray($))return null;let M=$;if(typeof M.body!=="string"||typeof M.updatedAt!=="string")return null;return{body:M.body,updatedAt:M.updatedAt}}function PZ($){if(!$||typeof $!=="object"||Array.isArray($))return null;let{kind:M,prefix:J,suffix:Z}=$;if("kind"in $&&!_6(M)||"prefix"in $&&typeof J!=="string"||"suffix"in $&&typeof Z!=="string")return null;return{kind:_6(M)?s4(M):void 0,prefix:typeof J==="string"?J:void 0,suffix:typeof Z==="string"?Z:void 0}}function W6($){let M=$.createdAt??new Date().toISOString();return{comments:[zM({body:$.body,updatedAt:M})],quote:$.quote,anchor:$.anchor}}function T6($,M){let J=zM(M);return{...$,comments:[...$.comments,J]}}function y6($,M,J,Z=new Date().toISOString()){let X=J.trim();if(X.length===0)return $;let A=!1,Y=$.comments.map((Q,K)=>{if(K!==M||Q.body===X)return Q;return A=!0,{...Q,body:X,updatedAt:Z}});if(!A)return $;return{...$,comments:Y}}function V6($,M){let J=$.comments.filter((Z,X)=>X!==M);if(J.length===$.comments.length)return $;if(J.length===0)return null;return{...$,comments:J}}function z6($,M,J=new Date().toISOString()){if(A0($)===M)return $;return{...$,resolvedAt:M?J:void 0}}function A0($){return $.resolvedAt!=null}function O6($){return $.filter((M)=>A0(M)).length}function b6($){if($.comments.length===0)return null;return $.comments.reduce((M,J)=>J.updatedAt>M?J.updatedAt:M,$.comments[0].updatedAt)}function zM($){let M=$.updatedAt??new Date().toISOString();return{body:$.body,updatedAt:M}}function z0(){return{graphemeWidths:new Map,lineBoundaries:new Map,measuredContainerHeights:new Map,measuredLines:new Map,preparedText:new Map,viewportPlans:new WeakMap}}function OM($,M,J){return z2($.preparedText,M,J,256)}function bM($,M,J){return z2($.measuredLines,M,J,512)}function CM($,M,J){return z2($.lineBoundaries,M,J,1024)}function EM($,M,J){return z2($.measuredContainerHeights,M,J,1024)}function wM($,M){let J=$.graphemeWidths.get(M);if(J)return J;let Z=new Map;return z2($.graphemeWidths,M,Z,64),Z}function jM($,M,J){return $.viewportPlans.get(M)?.get(J)??null}function RM($,M,J,Z){let X=$.viewportPlans.get(M)??new Map;return X.set(J,Z),$.viewportPlans.set(M,X),Z}function z2($,M,J,Z){if($.has(M))$.delete(M);if($.set(M,J),$.size>Z){let X=$.keys().next().value;if(X!==void 0)$.delete(X)}return J}var WZ=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","ON","ON","ET","ET","ET","ON","ON","ON","ON","ON","ON","CS","ON","CS","ON","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","ON","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","ON","ET","ET","ET","ET","ON","ON","ON","ON","L","ON","ON","ON","ON","ON","ET","ET","EN","EN","ON","L","ON","ON","ON","EN","L","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L"],TZ=["AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","CS","AL","ON","ON","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AN","AN","AN","AN","AN","AN","AN","AN","AN","AN","ET","AN","AN","AL","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","ON","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL"];function yZ($){if($<=255)return WZ[$];if(1424<=$&&$<=1524)return"R";if(1536<=$&&$<=1791)return TZ[$&255];if(1792<=$&&$<=2220)return"AL";return"L"}function VZ($){let M=$.length;if(M===0)return null;let J=Array(M),Z=0;for(let q=0;q<M;q++){let N=yZ($.charCodeAt(q));if(N==="R"||N==="AL"||N==="AN")Z++;J[q]=N}if(Z===0)return null;let X=M/Z<0.3?0:1,A=new Int8Array(M);for(let q=0;q<M;q++)A[q]=X;let Y=X&1?"R":"L",Q=Y,K=Q;for(let q=0;q<M;q++)if(J[q]==="NSM")J[q]=K;else K=J[q];K=Q;for(let q=0;q<M;q++){let N=J[q];if(N==="EN")J[q]=K==="AL"?"AN":"EN";else if(N==="R"||N==="L"||N==="AL")K=N}for(let q=0;q<M;q++)if(J[q]==="AL")J[q]="R";for(let q=1;q<M-1;q++){if(J[q]==="ES"&&J[q-1]==="EN"&&J[q+1]==="EN")J[q]="EN";if(J[q]==="CS"&&(J[q-1]==="EN"||J[q-1]==="AN")&&J[q+1]===J[q-1])J[q]=J[q-1]}for(let q=0;q<M;q++){if(J[q]!=="EN")continue;let N;for(N=q-1;N>=0&&J[N]==="ET";N--)J[N]="EN";for(N=q+1;N<M&&J[N]==="ET";N++)J[N]="EN"}for(let q=0;q<M;q++){let N=J[q];if(N==="WS"||N==="ES"||N==="ET"||N==="CS")J[q]="ON"}K=Q;for(let q=0;q<M;q++){let N=J[q];if(N==="EN")J[q]=K==="L"?"L":"EN";else if(N==="R"||N==="L")K=N}for(let q=0;q<M;q++){if(J[q]!=="ON")continue;let N=q+1;while(N<M&&J[N]==="ON")N++;let U=q>0?J[q-1]:Q,G=N<M?J[N]:Q,B=U!=="L"?"R":"L";if(B===(G!=="L"?"R":"L"))for(let F=q;F<N;F++)J[F]=B;q=N-1}for(let q=0;q<M;q++)if(J[q]==="ON")J[q]=Y;for(let q=0;q<M;q++){let N=J[q];if((A[q]&1)===0){if(N==="R")A[q]++;else if(N==="AN"||N==="EN")A[q]+=2}else if(N==="L"||N==="AN"||N==="EN")A[q]++}return A}function LM($,M){let J=VZ($);if(J===null)return null;let Z=new Int8Array(M.length);for(let X=0;X<M.length;X++)Z[X]=J[M[X]];return Z}var zZ=/[ \t\n\r\f]+/g,OZ=/[\t\n\r\f]| {2,}|^ | $/;function bZ($){let M=$??"normal";return M==="pre-wrap"?{mode:M,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:M,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function CZ($){if(!OZ.test($))return $;let M=$.replace(zZ," ");if(M.charCodeAt(0)===32)M=M.slice(1);if(M.length>0&&M.charCodeAt(M.length-1)===32)M=M.slice(0,-1);return M}function EZ($){if(!/[\r\f]/.test($))return $.replace(/\r\n/g,`
7
+ `).trim()}function z8($,M){return J5($,`root.${M}`)}function J5($,M){switch($.type){case"blockquote":{let J=$.children.map((X,D)=>J5(X,`${M}.children.${D}`)),Z=h1(J);return{children:J,id:Y0("blockquote",M,Z),plainText:Z,type:"blockquote"}}case"code":return{id:Y0("code",M,`${$.language??""}:${$.source}`),language:$.language,meta:$.meta,plainText:$.source,source:$.source,type:"code"};case"directive":return{attributes:$.attributes,body:$.body,id:Y0("directive",M,`${$.name}{${$.attributes}}:${$.body}`),name:$.name,plainText:$.body,type:"directive"};case"heading":{let J=$.children.map((X,D)=>Z5(X,`${M}.children.${D}`)),Z=N0(J);return{children:J,depth:$.depth,id:Y0("heading",M,`${$.depth}:${Z}`),plainText:Z,type:"heading"}}case"list":{let J=$.items.map((X,D)=>J5(X,`${M}.children.${D}`)),Z=J.map((X)=>X.plainText).join(`
8
+ `);return{id:Y0("list",M,`${String($.ordered)}:${Z}`),items:J,ordered:$.ordered,plainText:Z,spread:$.spread,start:$.start,type:"list"}}case"listItem":{let J=$.children.map((X,D)=>J5(X,`${M}.children.${D}`)),Z=h1(J);return{checked:$.checked,children:J,id:Y0("listItem",M,Z),plainText:Z,spread:$.spread,type:"listItem"}}case"paragraph":{let J=$.children.map((X,D)=>Z5(X,`${M}.children.${D}`)),Z=N0(J);return{children:J,id:Y0("paragraph",M,Z),plainText:Z,type:"paragraph"}}case"table":{let J=$.rows.map((X,D)=>EZ(X,`${M}.rows.${D}`)),Z=J.map((X)=>X.cells.map((D)=>D.plainText).join(" | ")).join(`
9
+ `);return{align:$.align,id:Y0("table",M,Z),plainText:Z,rows:J,type:"table"}}case"thematicBreak":return{id:Y0("thematicBreak",M,"thematic-break"),plainText:"",type:"thematicBreak"};case"unsupported":return{id:Y0("unsupported",M,$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"unsupported"}}}function EZ($,M){return{cells:$.cells.map((J,Z)=>{let X=J.children.map((Y,Q)=>Z5(Y,`${M}.cells.${Z}.children.${Q}`)),D=N0(X);return{children:X,id:Y0("tableCell",`${M}.cells.${Z}`,D),plainText:D}}),id:Y0("tableRow",M,String($.cells.length))}}function Z5($,M){switch($.type){case"break":return{id:Y0("break",M,"break"),type:"break"};case"image":return{alt:$.alt,id:Y0("image",M,`${$.url}:${$.width??""}:${$.alt??""}`),title:$.title,type:"image",url:$.url,width:$.width};case"inlineCode":return{code:$.code,id:Y0("inlineCode",M,$.code),type:"inlineCode"};case"link":{let J=$.children.map((X,D)=>Z5(X,`${M}.children.${D}`)),Z=N0(J);return{children:J,id:Y0("link",M,`${$.url}:${Z}`),title:$.title,type:"link",url:$.url}}case"text":return{id:Y0("text",M,`${$.text}:${$.marks.join(",")}`),marks:$.marks,text:$.text,type:"text"};case"unsupported":return{id:Y0("unsupported",M,$.source),originalType:$.originalType,source:$.source,type:"unsupported"}}}function z2($){return $.map((M)=>{switch(M.type){case"blockquote":return{...M,children:z2(M.children)};case"heading":case"paragraph":return C0(M,W8(M.children));case"list":return{...M,items:M.items.map((J)=>({...J,children:z2(J.children)}))};case"listItem":return{...M,children:z2(M.children)};case"table":return S0(M,M.rows.map((J)=>({...J,cells:J.cells.map((Z)=>({...Z,children:W8(Z.children)}))})));default:return M}})}function W8($){let M=[...$];for(let J=M.length-1;J>=0;J-=1){let Z=M[J];if(Z.type==="text"){let X=Z.text.replace(/[ \t]+$/u,"");if(X.length===Z.text.length)return M;if(X.length===0){M.splice(J,1);continue}return M[J]={...Z,text:X},M}if(Z.type==="link"){let X=W8(Z.children);if(X.length===Z.children.length&&X.every((D,Y)=>D===Z.children[Y]))return M;if(X.length===0){M.splice(J,1);continue}return M[J]={...Z,children:X},M}return M}return M}function Y0($,M,J){let Z=2166136261;for(let X of`${$}:${M}:${J}`)Z^=X.charCodeAt(0),Z=Math.imul(Z,16777619);return`${$}-${(Z>>>0).toString(36)}`}function W2($,M){E8($.blocks,M,f$(),m$())}function k$($,M){E8($,M,f$(),m$())}function E8($,M,J,Z){for(let[X,D]of $.entries()){if(J.stopped)return;let Y=`${Z.pathPrefix}.${X}`,Q={blockAncestors:Z.blockAncestors,depth:Z.depth,parentBlock:Z.parentBlock,path:Y},K=M.enterBlock?.(D,Q);if(p1(K,J))return;if(K!=="skip")switch(D.type){case"list":R$(D.items,D,M,J,Z,Y);break;case"blockquote":case"listItem":R$(D.children,D,M,J,Z,Y);break;case"heading":case"paragraph":T8(D.children,M,J,{block:D,blockAncestors:[...Z.blockAncestors,D],inlineAncestors:[],parentInline:null,pathPrefix:`${Y}.children`});break;case"table":yZ(D,M,J,{blockAncestors:[...Z.blockAncestors,D],pathPrefix:Y});break;case"code":case"directive":case"thematicBreak":case"unsupported":break}if(J.stopped)return;if(p1(M.leaveBlock?.(D,Q),J))return}}function T8($,M,J,Z){for(let[X,D]of $.entries()){if(J.stopped)return;let Y=`${Z.pathPrefix}.${X}`,Q={block:Z.block,blockAncestors:Z.blockAncestors,inlineAncestors:Z.inlineAncestors,parentInline:Z.parentInline,path:Y},K=M.enterInline?.(D,Q);if(p1(K,J))return;if(K!=="skip"){if(D.type==="link")TZ(D.children,D,M,J,Z,Y)}if(J.stopped)return;if(p1(M.leaveInline?.(D,Q),J))return}}function f$(){return{stopped:!1}}function m$(){return{blockAncestors:[],depth:0,parentBlock:null,pathPrefix:"root"}}function R$($,M,J,Z,X,D){E8($,J,Z,{blockAncestors:[...X.blockAncestors,M],depth:X.depth+1,parentBlock:M,pathPrefix:`${D}.children`})}function TZ($,M,J,Z,X,D){T8($,J,Z,{block:X.block,blockAncestors:X.blockAncestors,inlineAncestors:[...X.inlineAncestors,M],parentInline:M,pathPrefix:`${D}.children`})}function yZ($,M,J,Z){for(let[X,D]of $.rows.entries())for(let[Y,Q]of D.cells.entries()){if(J.stopped)return;let K=`${Z.pathPrefix}.rows.${X}.cells.${Y}`,q={blockAncestors:Z.blockAncestors,cellIndex:Y,path:K,row:D,rowIndex:X,table:$},U=M.enterTableCell?.(Q,q);if(p1(U,J))return;if(U!=="skip")T8(Q.children,M,J,{block:$,blockAncestors:Z.blockAncestors,inlineAncestors:[],parentInline:null,pathPrefix:`${K}.children`});if(J.stopped)return;if(p1(M.leaveTableCell?.(Q,q),J))return}}function p1($,M){if($!=="stop")return!1;return M.stopped=!0,!0}var y8="text";function w8($){return $==="text"||$==="code"||$==="tableCell"}function O8($){return $===y8?void 0:$}function u$($){switch($){case"heading":case"paragraph":return"text";case"code":return"code";default:return null}}function X5($){let M=[];return W2($,{enterBlock(J){switch(J.type){case"heading":case"paragraph":M.push({containerKind:"text",containerOrdinal:M.length,id:J.id,text:N0(J.children)});break;case"code":M.push({containerKind:"code",containerOrdinal:M.length,id:J.id,text:J.source});break}},enterTableCell(J){M.push({containerKind:"tableCell",containerOrdinal:M.length,id:J.id,text:N0(J.children)})}}),M}function C8($,M,J){return{prefix:$.slice(Math.max(0,M-S$),M),suffix:$.slice(J,Math.min($.length,J+S$))}}function E2($,M,J){let Z=j0(M,0,$.text.length),X=j0(J,Z,$.text.length),{prefix:D,suffix:Y}=C8($.text,Z,X);return{kind:O8($.containerKind),prefix:D||void 0,suffix:Y||void 0}}function T2($,M,J){let Z=j0(M,0,$.text.length),X=j0(J,Z,$.text.length);return $.text.slice(Z,X)}function u0($,M){if(M.length===0)return[];let J=[],Z=0;while(Z<=$.length){let X=$.indexOf(M,Z);if(X===-1)break;J.push(X),Z=X+Math.max(1,M.length)}return J}function l1($,M,J){if(M.length===0||J.length===0)return[];let Z=[];for(let X of u0($,M)){let D=X+M.length,Y=$.indexOf(J,D);if(Y!==-1)Z.push({startOffset:D,endOffset:Y})}return Z}function j8($,M,J){if(!M)return!1;return $.slice(Math.max(0,J-M.length),J)===M}function L8($,M,J){if(!M)return!1;return $.slice(J,J+M.length)===M}var S$=24;function j0($,M,J){return Math.min(Math.max($,M),J)}var v$=48,h$=64,wZ=32;function y2($,M){let J=$.anchor.kind??y8,Z=X5(M).filter((Y)=>Y.containerKind===J),X=OZ($,Z);if(X.length>0)return g$($,X,null);let D=CZ($,Z);if(D.length>0)return g$($,D,"repaired");return{match:null,repair:null,status:"stale"}}function OZ($,M){let J=[],Z=$.quote;if(Z.length===0)return J;for(let X of M)for(let D of u0(X.text,Z))J.push({container:X,endOffset:D+Z.length,score:RZ($,X,D),startOffset:D});return J.sort((X,D)=>D.score-X.score),J}function CZ($,M){let J=[];for(let Z of M)J.push(...jZ($,Z));return J.sort((Z,X)=>X.score-Z.score),J}function jZ($,M){let J=[],Z=$.quote.length,X=M.text,D=$.anchor.prefix??"",Y=$.anchor.suffix??"";if(D.length>0&&Y.length>0){for(let Q of l1(X,D,Y))J.push({container:M,endOffset:Q.endOffset,score:R8($,M,Q.startOffset,Q.endOffset,Z),startOffset:Q.startOffset});return J}if(D.length>0){for(let Q of u0(X,D)){let K=Q+D.length,q=j0(K+Z,K,X.length);J.push({container:M,endOffset:q,score:R8($,M,K,q,Z),startOffset:K})}return J}if(Y.length>0)for(let Q of u0(X,Y)){let K=Q,q=j0(K-Z,0,K);J.push({container:M,endOffset:K,score:R8($,M,q,K,Z),startOffset:q})}return J}function g$($,M,J){let[Z,X]=M;if(!Z)return{match:null,repair:null,status:"stale"};if(X&&Z.score===X.score)return{match:null,repair:null,status:"ambiguous"};let D=E2(Z.container,Z.startOffset,Z.endOffset),Y=T2(Z.container,Z.startOffset,Z.endOffset),Q=J??(Y===$.quote&&(D.prefix??"")===($.anchor.prefix??"")&&(D.suffix??"")===($.anchor.suffix??"")?"matched":"repaired");return{match:LZ(Z.container,Z.startOffset,Z.endOffset),repair:{anchor:D,quote:Y},status:Q}}function LZ($,M,J){return{containerId:$.id,containerKind:$.containerKind,containerOrdinal:$.containerOrdinal,endOffset:J,startOffset:M}}function RZ($,M,J){let Z=0;if(j8(M.text,$.anchor.prefix,J))Z+=v$;if(L8(M.text,$.anchor.suffix,J+$.quote.length))Z+=v$;return Z}function R8($,M,J,Z,X){let D=0;if(j8(M.text,$.anchor.prefix,J))D+=h$;if(L8(M.text,$.anchor.suffix,Z))D+=h$;if(D+=Math.max(0,wZ-Math.abs(X-(Z-J))),$.quote.length>0){let Y=M.text.slice(J,Z);if(Y.length>0)D+=kZ($.quote,Y),D+=fZ($.quote,Y)}return D}function kZ($,M){let J=0;while(J<$.length&&J<M.length&&$[J]===M[J])J+=1;return J}function fZ($,M){let J=0;while(J<$.length&&J<M.length&&$[$.length-1-J]===M[M.length-1-J])J+=1;return J}function k8($){if(!$||typeof $!=="object"||Array.isArray($))return null;let M=$,J=SZ(M.anchor),Z=typeof M.quote==="string"?M.quote:null,X=Array.isArray(M.comments)?M.comments.flatMap((D)=>{let Y=mZ(D);return Y?[Y]:[]}):[];if(!J||!Z||X.length===0)return null;return{quote:Z,anchor:J,comments:X,resolvedAt:typeof M.resolvedAt==="string"?M.resolvedAt:void 0}}function mZ($){if(!$||typeof $!=="object"||Array.isArray($))return null;let M=$;if(typeof M.body!=="string"||typeof M.updatedAt!=="string")return null;return{body:M.body,updatedAt:M.updatedAt}}function SZ($){if(!$||typeof $!=="object"||Array.isArray($))return null;let{kind:M,prefix:J,suffix:Z}=$;if("kind"in $&&!w8(M)||"prefix"in $&&typeof J!=="string"||"suffix"in $&&typeof Z!=="string")return null;return{kind:w8(M)?O8(M):void 0,prefix:typeof J==="string"?J:void 0,suffix:typeof Z==="string"?Z:void 0}}function f8($){let M=$.createdAt??new Date().toISOString();return{comments:[I$({body:$.body,updatedAt:M})],quote:$.quote,anchor:$.anchor}}function m8($,M){let J=I$(M);return{...$,comments:[...$.comments,J]}}function S8($,M,J,Z=new Date().toISOString()){let X=J.trim();if(X.length===0)return $;let D=!1,Y=$.comments.map((Q,K)=>{if(K!==M||Q.body===X)return Q;return D=!0,{...Q,body:X,updatedAt:Z}});if(!D)return $;return{...$,comments:Y}}function u8($,M){let J=$.comments.filter((Z,X)=>X!==M);if(J.length===$.comments.length)return $;if(J.length===0)return null;return{...$,comments:J}}function v8($,M,J=new Date().toISOString()){if(Z1($)===M)return $;return{...$,resolvedAt:M?J:void 0}}function Z1($){return $.resolvedAt!=null}function h8($){return $.filter((M)=>Z1(M)).length}function g8($){if($.comments.length===0)return null;return $.comments.reduce((M,J)=>J.updatedAt>M?J.updatedAt:M,$.comments[0].updatedAt)}function I$($){let M=$.updatedAt??new Date().toISOString();return{body:$.body,updatedAt:M}}function p$($){let M=new Set;return W2($,{enterInline(J){if(J.type==="image")M.add(J.url)}}),[...M]}function r1($,M){let J=null;return uZ($,{enterBlock(Z){if(Z.id===M)return J=Z,"stop"}}),J}function uZ($,M){if(Array.isArray($)){k$($,M);return}W2($,M)}function W1(){return{graphemeWidths:new Map,lineBoundaries:new Map,measuredContainerHeights:new Map,measuredLines:new Map,preparedText:new Map,viewportPlans:new WeakMap}}function l$($,M,J){return w2($.preparedText,M,J,256)}function r$($,M,J){return w2($.measuredLines,M,J,512)}function c$($,M,J){return w2($.lineBoundaries,M,J,1024)}function x$($,M,J){return w2($.measuredContainerHeights,M,J,1024)}function d$($,M){let J=$.graphemeWidths.get(M);if(J)return J;let Z=new Map;return w2($.graphemeWidths,M,Z,64),Z}function a$($,M,J){return $.viewportPlans.get(M)?.get(J)??null}function i$($,M,J,Z){let X=$.viewportPlans.get(M)??new Map;return X.set(J,Z),$.viewportPlans.set(M,X),Z}function w2($,M,J,Z){if($.has(M))$.delete(M);if($.set(M,J),$.size>Z){let X=$.keys().next().value;if(X!==void 0)$.delete(X)}return J}var vZ=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","ON","ON","ET","ET","ET","ON","ON","ON","ON","ON","ON","CS","ON","CS","ON","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","ON","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","ON","ET","ET","ET","ET","ON","ON","ON","ON","L","ON","ON","ON","ON","ON","ET","ET","EN","EN","ON","L","ON","ON","ON","EN","L","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L"],hZ=["AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","CS","AL","ON","ON","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AN","AN","AN","AN","AN","AN","AN","AN","AN","AN","ET","AN","AN","AL","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","ON","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL"];function gZ($){if($<=255)return vZ[$];if(1424<=$&&$<=1524)return"R";if(1536<=$&&$<=1791)return hZ[$&255];if(1792<=$&&$<=2220)return"AL";return"L"}function IZ($){let M=$.length;if(M===0)return null;let J=Array(M),Z=0;for(let q=0;q<M;q++){let U=gZ($.charCodeAt(q));if(U==="R"||U==="AL"||U==="AN")Z++;J[q]=U}if(Z===0)return null;let X=M/Z<0.3?0:1,D=new Int8Array(M);for(let q=0;q<M;q++)D[q]=X;let Y=X&1?"R":"L",Q=Y,K=Q;for(let q=0;q<M;q++)if(J[q]==="NSM")J[q]=K;else K=J[q];K=Q;for(let q=0;q<M;q++){let U=J[q];if(U==="EN")J[q]=K==="AL"?"AN":"EN";else if(U==="R"||U==="L"||U==="AL")K=U}for(let q=0;q<M;q++)if(J[q]==="AL")J[q]="R";for(let q=1;q<M-1;q++){if(J[q]==="ES"&&J[q-1]==="EN"&&J[q+1]==="EN")J[q]="EN";if(J[q]==="CS"&&(J[q-1]==="EN"||J[q-1]==="AN")&&J[q+1]===J[q-1])J[q]=J[q-1]}for(let q=0;q<M;q++){if(J[q]!=="EN")continue;let U;for(U=q-1;U>=0&&J[U]==="ET";U--)J[U]="EN";for(U=q+1;U<M&&J[U]==="ET";U++)J[U]="EN"}for(let q=0;q<M;q++){let U=J[q];if(U==="WS"||U==="ES"||U==="ET"||U==="CS")J[q]="ON"}K=Q;for(let q=0;q<M;q++){let U=J[q];if(U==="EN")J[q]=K==="L"?"L":"EN";else if(U==="R"||U==="L")K=U}for(let q=0;q<M;q++){if(J[q]!=="ON")continue;let U=q+1;while(U<M&&J[U]==="ON")U++;let N=q>0?J[q-1]:Q,A=U<M?J[U]:Q,V=N!=="L"?"R":"L";if(V===(A!=="L"?"R":"L"))for(let G=q;G<U;G++)J[G]=V;q=U-1}for(let q=0;q<M;q++)if(J[q]==="ON")J[q]=Y;for(let q=0;q<M;q++){let U=J[q];if((D[q]&1)===0){if(U==="R")D[q]++;else if(U==="AN"||U==="EN")D[q]+=2}else if(U==="L"||U==="AN"||U==="EN")D[q]++}return D}function s$($,M){let J=IZ($);if(J===null)return null;let Z=new Int8Array(M.length);for(let X=0;X<M.length;X++)Z[X]=J[M[X]];return Z}var pZ=/[ \t\n\r\f]+/g,lZ=/[\t\n\r\f]| {2,}|^ | $/;function rZ($){let M=$??"normal";return M==="pre-wrap"?{mode:M,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:M,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function cZ($){if(!lZ.test($))return $;let M=$.replace(pZ," ");if(M.charCodeAt(0)===32)M=M.slice(1);if(M.length>0&&M.charCodeAt(M.length-1)===32)M=M.slice(0,-1);return M}function xZ($){if(!/[\r\f]/.test($))return $.replace(/\r\n/g,`
10
10
  `);return $.replace(/\r\n/g,`
11
11
  `).replace(/[\r\f]/g,`
12
- `)}var C6=null,wZ;function jZ(){if(C6===null)C6=new Intl.Segmenter(wZ,{granularity:"word"});return C6}var RZ=/\p{Script=Arabic}/u,o4=/\p{M}/u,uM=/\p{Nd}/u;function E6($){return RZ.test($)}function t1($){for(let M of $){let J=M.codePointAt(0);if(J>=19968&&J<=40959||J>=13312&&J<=19903||J>=131072&&J<=173791||J>=173824&&J<=177983||J>=177984&&J<=178207||J>=178208&&J<=183983||J>=183984&&J<=191471||J>=196608&&J<=201551||J>=63744&&J<=64255||J>=194560&&J<=195103||J>=12288&&J<=12351||J>=12352&&J<=12447||J>=12448&&J<=12543||J>=44032&&J<=55215||J>=65280&&J<=65519)return!0}return!1}var R6=new Set([",",".","!",":",";","?","、","。","・",")","〕","〉","》","」","』","】","〗","〙","〛","ー","々","〻","ゝ","ゞ","ヽ","ヾ"]),O2=new Set(['"',"(","[","{","“","‘","«","‹","(","〔","〈","《","「","『","【","〖","〘","〚"]),L6=new Set(["'","’"]),c0=new Set([".",",","!","?",":",";","،","؛","؟","।","॥","၊","။","၌","၍","၏",")","]","}","%",'"',"”","’","»","›","…"]),LZ=new Set([":",".","،","؛"]),kZ=new Set(["၏"]),fZ=new Set(["”","’","»","›","」","』","】","》","〉","〕",")"]);function uZ($){if(k6($))return!0;let M=!1;for(let J of $){if(c0.has(J)){M=!0;continue}if(M&&o4.test(J))continue;return!1}return M}function SZ($){for(let M of $)if(!R6.has(M)&&!c0.has(M))return!1;return $.length>0}function mZ($){if(k6($))return!0;for(let M of $)if(!O2.has(M)&&!L6.has(M)&&!o4.test(M))return!1;return $.length>0}function k6($){let M=!1;for(let J of $){if(J==="\\"||o4.test(J))continue;if(O2.has(J)||c0.has(J)||L6.has(J)){M=!0;continue}return!1}return M}function vZ($){let M=Array.from($),J=M.length;while(J>0){let Z=M[J-1];if(o4.test(Z)){J--;continue}if(O2.has(Z)||L6.has(Z)){J--;continue}break}if(J<=0||J===M.length)return null;return{head:M.slice(0,J).join(""),tail:M.slice(J).join("")}}function gZ($,M){if($.length===0)return!1;for(let J of $)if(J!==M)return!1;return!0}function hZ($){if(!E6($)||$.length===0)return!1;return LZ.has($[$.length-1])}function IZ($){if($.length===0)return!1;return kZ.has($[$.length-1])}function pZ($){if($.length<2||$[0]!==" ")return null;let M=$.slice(1);if(/^\p{M}+$/u.test(M))return{space:" ",marks:M};return null}function f6($){for(let M=$.length-1;M>=0;M--){let J=$[M];if(fZ.has(J))return!0;if(!c0.has(J))return!1}return!1}function lZ($,M){if(M.preserveOrdinarySpaces||M.preserveHardBreaks){if($===" ")return"preserved-space";if($==="\t")return"tab";if(M.preserveHardBreaks&&$===`
13
- `)return"hard-break"}if($===" ")return"space";if($===" "||$===" "||$==="⁠"||$==="\uFEFF")return"glue";if($==="​")return"zero-width-break";if($==="­")return"soft-hyphen";return"text"}function e1($){return $.length===1?$[0]:$.join("")}function rZ($,M,J,Z){let X=[],A=null,Y=[],Q=J,K=!1,q=0;for(let N of $){let U=lZ(N,Z),G=U==="text"&&M;if(A!==null&&U===A&&G===K){Y.push(N),q+=N.length;continue}if(A!==null)X.push({text:e1(Y),isWordLike:K,kind:A,start:Q});A=U,Y=[N],Q=J+q,K=G,q+=N.length}if(A!==null)X.push({text:e1(Y),isWordLike:K,kind:A,start:Q});return X}function w6($){return $==="space"||$==="preserved-space"||$==="zero-width-break"||$==="hard-break"}var cZ=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function xZ($,M){let J=$.texts[M];if(J.startsWith("www."))return!0;return cZ.test(J)&&M+1<$.len&&$.kinds[M+1]==="text"&&$.texts[M+1]==="//"}function dZ($){return $.includes("?")&&($.includes("://")||$.startsWith("www."))}function aZ($){let M=$.texts.slice(),J=$.isWordLike.slice(),Z=$.kinds.slice(),X=$.starts.slice();for(let Y=0;Y<$.len;Y++){if(Z[Y]!=="text"||!xZ($,Y))continue;let Q=[M[Y]],K=Y+1;while(K<$.len&&!w6(Z[K])){Q.push(M[K]),J[Y]=!0;let q=M[K].includes("?");if(Z[K]="text",M[K]="",K++,q)break}M[Y]=e1(Q)}let A=0;for(let Y=0;Y<M.length;Y++){let Q=M[Y];if(Q.length===0)continue;if(A!==Y)M[A]=Q,J[A]=J[Y],Z[A]=Z[Y],X[A]=X[Y];A++}return M.length=A,J.length=A,Z.length=A,X.length=A,{len:A,texts:M,isWordLike:J,kinds:Z,starts:X}}function sZ($){let M=[],J=[],Z=[],X=[];for(let A=0;A<$.len;A++){let Y=$.texts[A];if(M.push(Y),J.push($.isWordLike[A]),Z.push($.kinds[A]),X.push($.starts[A]),!dZ(Y))continue;let Q=A+1;if(Q>=$.len||w6($.kinds[Q]))continue;let K=[],q=$.starts[Q],N=Q;while(N<$.len&&!w6($.kinds[N]))K.push($.texts[N]),N++;if(K.length>0)M.push(e1(K)),J.push(!0),Z.push("text"),X.push(q),A=N-1}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}var iZ=new Set([":","-","/","×",",",".","+","–","—"]),kM=/^[A-Za-z0-9_]+[,:;]*$/,fM=/[,:;]+$/;function SM($){for(let M of $)if(uM.test(M))return!0;return!1}function j6($){if($.length===0)return!1;for(let M of $){if(uM.test(M)||iZ.has(M))continue;return!1}return!0}function oZ($){let M=[],J=[],Z=[],X=[];for(let A=0;A<$.len;A++){let Y=$.texts[A],Q=$.kinds[A];if(Q==="text"&&j6(Y)&&SM(Y)){let K=[Y],q=A+1;while(q<$.len&&$.kinds[q]==="text"&&j6($.texts[q]))K.push($.texts[q]),q++;M.push(e1(K)),J.push(!0),Z.push("text"),X.push($.starts[A]),A=q-1;continue}M.push(Y),J.push($.isWordLike[A]),Z.push(Q),X.push($.starts[A])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function nZ($){let M=[],J=[],Z=[],X=[];for(let A=0;A<$.len;A++){let Y=$.texts[A],Q=$.kinds[A],K=$.isWordLike[A];if(Q==="text"&&K&&kM.test(Y)){let q=[Y],N=fM.test(Y),U=A+1;while(N&&U<$.len&&$.kinds[U]==="text"&&$.isWordLike[U]&&kM.test($.texts[U])){let G=$.texts[U];q.push(G),N=fM.test(G),U++}M.push(e1(q)),J.push(!0),Z.push("text"),X.push($.starts[A]),A=U-1;continue}M.push(Y),J.push(K),Z.push(Q),X.push($.starts[A])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function tZ($){let M=[],J=[],Z=[],X=[];for(let A=0;A<$.len;A++){let Y=$.texts[A];if($.kinds[A]==="text"&&Y.includes("-")){let Q=Y.split("-"),K=Q.length>1;for(let q=0;q<Q.length;q++){let N=Q[q];if(!K)break;if(N.length===0||!SM(N)||!j6(N))K=!1}if(K){let q=0;for(let N=0;N<Q.length;N++){let U=Q[N],G=N<Q.length-1?`${U}-`:U;M.push(G),J.push(!0),Z.push("text"),X.push($.starts[A]+q),q+=G.length}continue}}M.push(Y),J.push($.isWordLike[A]),Z.push($.kinds[A]),X.push($.starts[A])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function eZ($){let M=[],J=[],Z=[],X=[],A=0;while(A<$.len){let Y=[$.texts[A]],Q=$.isWordLike[A],K=$.kinds[A],q=$.starts[A];if(K==="glue"){let N=[Y[0]],U=q;A++;while(A<$.len&&$.kinds[A]==="glue")N.push($.texts[A]),A++;let G=e1(N);if(A<$.len&&$.kinds[A]==="text")Y[0]=G,Y.push($.texts[A]),Q=$.isWordLike[A],K="text",q=U,A++;else{M.push(G),J.push(!1),Z.push("glue"),X.push(U);continue}}else A++;if(K==="text")while(A<$.len&&$.kinds[A]==="glue"){let N=[];while(A<$.len&&$.kinds[A]==="glue")N.push($.texts[A]),A++;let U=e1(N);if(A<$.len&&$.kinds[A]==="text"){Y.push(U,$.texts[A]),Q=Q||$.isWordLike[A],A++;continue}Y.push(U)}M.push(e1(Y)),J.push(Q),Z.push(K),X.push(q)}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function $X($){let M=$.texts.slice(),J=$.isWordLike.slice(),Z=$.kinds.slice(),X=$.starts.slice();for(let A=0;A<M.length-1;A++){if(Z[A]!=="text"||Z[A+1]!=="text")continue;if(!t1(M[A])||!t1(M[A+1]))continue;let Y=vZ(M[A]);if(Y===null)continue;M[A]=Y.head,M[A+1]=Y.tail+M[A+1],X[A+1]=X[A]+Y.head.length}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function MX($,M,J){let Z=jZ(),X=0,A=[],Y=[],Q=[],K=[];for(let G of Z.segment($))for(let B of rZ(G.segment,G.isWordLike??!1,G.index,J)){let D=B.kind==="text";if(M.carryCJKAfterClosingQuote&&D&&X>0&&Q[X-1]==="text"&&t1(B.text)&&t1(A[X-1])&&f6(A[X-1]))A[X-1]+=B.text,Y[X-1]=Y[X-1]||B.isWordLike;else if(D&&X>0&&Q[X-1]==="text"&&SZ(B.text)&&t1(A[X-1]))A[X-1]+=B.text,Y[X-1]=Y[X-1]||B.isWordLike;else if(D&&X>0&&Q[X-1]==="text"&&IZ(A[X-1]))A[X-1]+=B.text,Y[X-1]=Y[X-1]||B.isWordLike;else if(D&&X>0&&Q[X-1]==="text"&&B.isWordLike&&E6(B.text)&&hZ(A[X-1]))A[X-1]+=B.text,Y[X-1]=!0;else if(D&&!B.isWordLike&&X>0&&Q[X-1]==="text"&&B.text.length===1&&B.text!=="-"&&B.text!=="—"&&gZ(A[X-1],B.text))A[X-1]+=B.text;else if(D&&!B.isWordLike&&X>0&&Q[X-1]==="text"&&(uZ(B.text)||B.text==="-"&&Y[X-1]))A[X-1]+=B.text;else A[X]=B.text,Y[X]=B.isWordLike,Q[X]=B.kind,K[X]=B.start,X++}for(let G=1;G<X;G++)if(Q[G]==="text"&&!Y[G]&&k6(A[G])&&Q[G-1]==="text")A[G-1]+=A[G],Y[G-1]=Y[G-1]||Y[G],A[G]="";for(let G=X-2;G>=0;G--)if(Q[G]==="text"&&!Y[G]&&mZ(A[G])){let B=G+1;while(B<X&&A[B]==="")B++;if(B<X&&Q[B]==="text")A[B]=A[G]+A[B],K[B]=K[G],A[G]=""}let q=0;for(let G=0;G<X;G++){let B=A[G];if(B.length===0)continue;if(q!==G)A[q]=B,Y[q]=Y[G],Q[q]=Q[G],K[q]=K[G];q++}A.length=q,Y.length=q,Q.length=q,K.length=q;let N=eZ({len:q,texts:A,isWordLike:Y,kinds:Q,starts:K}),U=$X(nZ(tZ(oZ(sZ(aZ(N))))));for(let G=0;G<U.len-1;G++){let B=pZ(U.texts[G]);if(B===null)continue;if(U.kinds[G]!=="space"&&U.kinds[G]!=="preserved-space"||U.kinds[G+1]!=="text"||!E6(U.texts[G+1]))continue;U.texts[G]=B.space,U.isWordLike[G]=!1,U.kinds[G]=U.kinds[G]==="preserved-space"?"preserved-space":"space",U.texts[G+1]=B.marks+U.texts[G+1],U.starts[G+1]=U.starts[G]+B.space.length}return U}function JX($,M){if($.len===0)return[];if(!M.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len}];let J=[],Z=0;for(let X=0;X<$.len;X++){if($.kinds[X]!=="hard-break")continue;J.push({startSegmentIndex:Z,endSegmentIndex:X,consumedEndSegmentIndex:X+1}),Z=X+1}if(Z<$.len)J.push({startSegmentIndex:Z,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len});return J}function mM($,M,J="normal"){let Z=bZ(J),X=Z.mode==="pre-wrap"?EZ($):CZ($);if(X.length===0)return{normalized:X,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let A=MX(X,M,Z);return{normalized:X,chunks:JX(A,Z),...A}}var x0=null,vM=new Map,d0=null,ZX=/\p{Emoji_Presentation}/u,XX=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,u6=null,gM=new Map;function S6(){if(x0!==null)return x0;if(typeof OffscreenCanvas<"u")return x0=new OffscreenCanvas(1,1).getContext("2d"),x0;if(typeof document<"u")return x0=document.createElement("canvas").getContext("2d"),x0;throw Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function AX($){let M=vM.get($);if(!M)M=new Map,vM.set($,M);return M}function Y0($,M){let J=M.get($);if(J===void 0)J={width:S6().measureText($).width,containsCJK:t1($)},M.set($,J);return J}function a0(){if(d0!==null)return d0;if(typeof navigator>"u")return d0={lineFitEpsilon:0.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},d0;let $=navigator.userAgent,J=navigator.vendor==="Apple Computer, Inc."&&$.includes("Safari/")&&!$.includes("Chrome/")&&!$.includes("Chromium/")&&!$.includes("CriOS/")&&!$.includes("FxiOS/")&&!$.includes("EdgiOS/"),Z=$.includes("Chrome/")||$.includes("Chromium/")||$.includes("CriOS/")||$.includes("Edg/");return d0={lineFitEpsilon:J?0.015625:0.005,carryCJKAfterClosingQuote:Z,preferPrefixWidthsForBreakableRuns:J,preferEarlySoftHyphenBreak:J},d0}function YX($){let M=$.match(/(\d+(?:\.\d+)?)\s*px/);return M?parseFloat(M[1]):16}function m6(){if(u6===null)u6=new Intl.Segmenter(void 0,{granularity:"grapheme"});return u6}function QX($){return ZX.test($)||$.includes("️")}function hM($){return XX.test($)}function KX($,M){let J=gM.get($);if(J!==void 0)return J;let Z=S6();Z.font=$;let X=Z.measureText("\uD83D\uDE00").width;if(J=0,X>M+0.5&&typeof document<"u"&&document.body!==null){let A=document.createElement("span");A.style.font=$,A.style.display="inline-block",A.style.visibility="hidden",A.style.position="absolute",A.textContent="\uD83D\uDE00",document.body.appendChild(A);let Y=A.getBoundingClientRect().width;if(document.body.removeChild(A),X-Y>0.5)J=X-Y}return gM.set($,J),J}function qX($){let M=0,J=m6();for(let Z of J.segment($))if(QX(Z.segment))M++;return M}function NX($,M){if(M.emojiCount===void 0)M.emojiCount=qX($);return M.emojiCount}function Q0($,M,J){if(J===0)return M.width;return M.width-NX($,M)*J}function IM($,M,J,Z){if(M.graphemeWidths!==void 0)return M.graphemeWidths;let X=[],A=m6();for(let Y of A.segment($)){let Q=Y0(Y.segment,J);X.push(Q0(Y.segment,Q,Z))}return M.graphemeWidths=X.length>1?X:null,M.graphemeWidths}function pM($,M,J,Z){if(M.graphemePrefixWidths!==void 0)return M.graphemePrefixWidths;let X=[],A=m6(),Y="";for(let Q of A.segment($)){Y+=Q.segment;let K=Y0(Y,J);X.push(Q0(Y,K,Z))}return M.graphemePrefixWidths=X.length>1?X:null,M.graphemePrefixWidths}function lM($,M){let J=S6();J.font=$;let Z=AX($),X=YX($),A=M?KX($,X):0;return{cache:Z,fontSize:X,emojiCorrection:A}}function n4($){return $==="space"||$==="preserved-space"||$==="tab"||$==="zero-width-break"||$==="soft-hyphen"}function UX($,M){while(M<$.widths.length){let J=$.kinds[M];if(J!=="space"&&J!=="zero-width-break"&&J!=="soft-hyphen")break;M++}return M}function GX($,M){if(M<=0)return 0;let J=$%M;if(Math.abs(J)<=0.000001)return M;return M-J}function rM($,M,J,Z){if(!Z||M===null)return $[J];return M[J]-(J>0?M[J-1]:0)}function BX($,M,J,Z,X,A){let Y=0,Q=M;while(Y<$.length){let K=A?M+$[Y]:Q+$[Y];if((Y+1<$.length?K+X:K)>J+Z)break;Q=K,Y++}return{fitCount:Y,fittedWidth:Q}}function FX($,M,J){let{widths:Z,kinds:X,breakableWidths:A,breakablePrefixWidths:Y}=$;if(Z.length===0)return 0;let Q=a0(),K=Q.lineFitEpsilon,q=0,N=0,U=!1,G=0,B=0,D=0,F=0,H=-1,b=0;function E(){H=-1,b=0}function V(W=D,_=F,C=N){q++,J?.({startSegmentIndex:G,startGraphemeIndex:B,endSegmentIndex:W,endGraphemeIndex:_,width:C}),N=0,U=!1,E()}function R(W,_){U=!0,G=W,B=0,D=W+1,F=0,N=_}function O(W,_,C){U=!0,G=W,B=_,D=W,F=_+1,N=C}function j(W,_){if(!U){R(W,_);return}N+=_,D=W+1,F=0}function f(W,_){if(!n4(X[W]))return;H=W+1,b=N-_}function z(W){y(W,0)}function y(W,_){let C=A[W],g=Y[W]??null;for(let u=_;u<C.length;u++){let d=rM(C,g,u,Q.preferPrefixWidthsForBreakableRuns);if(!U){O(W,u,d);continue}if(N+d>M+K)V(),O(W,u,d);else N+=d,D=W,F=u+1}if(U&&D===W&&F===C.length)D=W+1,F=0}let T=0;while(T<Z.length){if(!U){if(T=UX($,T),T>=Z.length)break}let W=Z[T],_=X[T];if(!U){if(W>M&&A[T]!==null)z(T);else R(T,W);f(T,W),T++;continue}if(N+W>M+K){if(n4(_)){j(T,W),V(T+1,0,N-W),T++;continue}if(H>=0){if(D>H||D===H&&F>0){V();continue}V(H,0,b);continue}if(W>M&&A[T]!==null){V(),z(T),T++;continue}V();continue}j(T,W),f(T,W),T++}if(U)V();return q}function cM($,M,J){if($.simpleLineWalkFastPath)return FX($,M,J);let{widths:Z,lineEndFitAdvances:X,lineEndPaintAdvances:A,kinds:Y,breakableWidths:Q,breakablePrefixWidths:K,discretionaryHyphenWidth:q,tabStopAdvance:N,chunks:U}=$;if(Z.length===0||U.length===0)return 0;let G=a0(),B=G.lineFitEpsilon,D=0,F=0,H=!1,b=0,E=0,V=0,R=0,O=-1,j=0,f=0,z=null;function y(){O=-1,j=0,f=0,z=null}function T(k=V,S=R,m=F){D++,J?.({startSegmentIndex:b,startGraphemeIndex:E,endSegmentIndex:k,endGraphemeIndex:S,width:m}),F=0,H=!1,y()}function W(k,S){H=!0,b=k,E=0,V=k+1,R=0,F=S}function _(k,S,m){H=!0,b=k,E=S,V=k,R=S+1,F=m}function C(k,S){if(!H){W(k,S);return}F+=S,V=k+1,R=0}function g(k,S){if(!n4(Y[k]))return;let m=Y[k]==="tab"?0:X[k],Z1=Y[k]==="tab"?S:A[k];O=k+1,j=F-S+m,f=F-S+Z1,z=Y[k]}function u(k){d(k,0)}function d(k,S){let m=Q[k],Z1=K[k]??null;for(let t=S;t<m.length;t++){let N1=rM(m,Z1,t,G.preferPrefixWidthsForBreakableRuns);if(!H){_(k,t,N1);continue}if(F+N1>M+B)T(),_(k,t,N1);else F+=N1,V=k,R=t+1}if(H&&V===k&&R===m.length)V=k+1,R=0}function p(k){if(z!=="soft-hyphen")return!1;let S=Q[k];if(S===null)return!1;let m=G.preferPrefixWidthsForBreakableRuns?K[k]??S:S,Z1=m!==S,{fitCount:t,fittedWidth:N1}=BX(m,F,M,B,q,Z1);if(t===0)return!1;if(F=N1,V=k,R=t,y(),t===S.length)return V=k+1,R=0,!0;return T(k,t,N1+q),d(k,t),!0}function J1(k){D++,J?.({startSegmentIndex:k.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:k.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),y()}for(let k=0;k<U.length;k++){let S=U[k];if(S.startSegmentIndex===S.endSegmentIndex){J1(S);continue}H=!1,F=0,b=S.startSegmentIndex,E=0,V=S.startSegmentIndex,R=0,y();let m=S.startSegmentIndex;while(m<S.endSegmentIndex){let Z1=Y[m],t=Z1==="tab"?GX(F,N):Z[m];if(Z1==="soft-hyphen"){if(H)V=m+1,R=0,O=m+1,j=F+q,f=F+q,z=Z1;m++;continue}if(!H){if(t>M&&Q[m]!==null)u(m);else W(m,t);g(m,t),m++;continue}if(F+t>M+B){let v1=F+(Z1==="tab"?0:X[m]),g1=F+(Z1==="tab"?t:A[m]);if(z==="soft-hyphen"&&G.preferEarlySoftHyphenBreak&&j<=M+B){T(O,0,f);continue}if(z==="soft-hyphen"&&p(m)){m++;continue}if(n4(Z1)&&v1<=M+B){C(m,t),T(m+1,0,g1),m++;continue}if(O>=0&&j<=M+B){if(V>O||V===O&&R>0){T();continue}let A1=O;T(A1,0,f),m=A1;continue}if(t>M&&Q[m]!==null){T(),u(m),m++;continue}T();continue}C(m,t),g(m,t),m++}if(H){let Z1=O===S.consumedEndSegmentIndex?f:F;T(S.consumedEndSegmentIndex,0,Z1)}}return D}var v6=null,xM=new WeakMap;function aM(){if(v6===null)v6=new Intl.Segmenter(void 0,{granularity:"grapheme"});return v6}function DX($){if($)return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]};return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[]}}function _X($,M,J){let Z=aM(),X=a0(),{cache:A,emojiCorrection:Y}=lM(M,hM($.normalized)),Q=Q0("-",Y0("-",A),Y),q=Q0(" ",Y0(" ",A),Y)*8;if($.len===0)return DX(J);let N=[],U=[],G=[],B=[],D=$.chunks.length<=1,F=J?[]:null,H=[],b=[],E=J?[]:null,V=Array.from({length:$.len}),R=Array.from({length:$.len});function O(z,y,T,W,_,C,g,u){if(_!=="text"&&_!=="space"&&_!=="zero-width-break")D=!1;if(N.push(y),U.push(T),G.push(W),B.push(_),F?.push(C),H.push(g),b.push(u),E!==null)E.push(z)}for(let z=0;z<$.len;z++){V[z]=N.length;let y=$.texts[z],T=$.isWordLike[z],W=$.kinds[z],_=$.starts[z];if(W==="soft-hyphen"){O(y,0,Q,Q,W,_,null,null),R[z]=N.length;continue}if(W==="hard-break"){O(y,0,0,0,W,_,null,null),R[z]=N.length;continue}if(W==="tab"){O(y,0,0,0,W,_,null,null),R[z]=N.length;continue}let C=Y0(y,A);if(W==="text"&&C.containsCJK){let p="",J1=0;for(let k of Z.segment(y)){let S=k.segment;if(p.length===0){p=S,J1=k.index;continue}if(O2.has(p)||R6.has(S)||c0.has(S)||X.carryCJKAfterClosingQuote&&t1(S)&&f6(p)){p+=S;continue}let m=Y0(p,A),Z1=Q0(p,m,Y);O(p,Z1,Z1,Z1,"text",_+J1,null,null),p=S,J1=k.index}if(p.length>0){let k=Y0(p,A),S=Q0(p,k,Y);O(p,S,S,S,"text",_+J1,null,null)}R[z]=N.length;continue}let g=Q0(y,C,Y),u=W==="space"||W==="preserved-space"||W==="zero-width-break"?0:g,d=W==="space"||W==="zero-width-break"?0:g;if(T&&y.length>1){let p=IM(y,C,A,Y),J1=X.preferPrefixWidthsForBreakableRuns?pM(y,C,A,Y):null;O(y,g,u,d,W,_,p,J1)}else O(y,g,u,d,W,_,null,null);R[z]=N.length}let j=HX($.chunks,V,R),f=F===null?null:LM($.normalized,F);if(E!==null)return{widths:N,lineEndFitAdvances:U,lineEndPaintAdvances:G,kinds:B,simpleLineWalkFastPath:D,segLevels:f,breakableWidths:H,breakablePrefixWidths:b,discretionaryHyphenWidth:Q,tabStopAdvance:q,chunks:j,segments:E};return{widths:N,lineEndFitAdvances:U,lineEndPaintAdvances:G,kinds:B,simpleLineWalkFastPath:D,segLevels:f,breakableWidths:H,breakablePrefixWidths:b,discretionaryHyphenWidth:Q,tabStopAdvance:q,chunks:j}}function HX($,M,J){let Z=[];for(let X=0;X<$.length;X++){let A=$[X],Y=A.startSegmentIndex<M.length?M[A.startSegmentIndex]:J[J.length-1]??0,Q=A.endSegmentIndex<M.length?M[A.endSegmentIndex]:J[J.length-1]??0,K=A.consumedEndSegmentIndex<M.length?M[A.consumedEndSegmentIndex]:J[J.length-1]??0;Z.push({startSegmentIndex:Y,endSegmentIndex:Q,consumedEndSegmentIndex:K})}return Z}function PX($,M,J,Z){let X=mM($,a0(),Z?.whiteSpace);return _X(X,M,J)}function sM($,M,J){return PX($,M,!0,J)}function WX($){return $}function dM($,M,J){let Z=J.get($);if(Z!==void 0)return Z;Z=[];let X=aM();for(let A of X.segment(M[$]))Z.push(A.segment);return J.set($,Z),Z}function TX($){let M=xM.get($);if(M!==void 0)return M;return M=new Map,xM.set($,M),M}function yX($,M,J,Z){return Z>0&&$[Z-1]==="soft-hyphen"&&!(M===Z&&J>0)}function VX($,M,J,Z,X,A,Y){let Q="",K=yX(M,Z,X,A);for(let q=Z;q<A;q++){if(M[q]==="soft-hyphen"||M[q]==="hard-break")continue;if(q===Z&&X>0)Q+=dM(q,$,J).slice(X).join("");else Q+=$[q]}if(Y>0){if(K)Q+="-";Q+=dM(A,$,J).slice(Z===A?X:0,Y).join("")}else if(K)Q+="-";return Q}function zX($,M,J,Z,X,A,Y){return{text:VX($.segments,$.kinds,M,Z,X,A,Y),width:J,start:{segmentIndex:Z,graphemeIndex:X},end:{segmentIndex:A,graphemeIndex:Y}}}function OX($,M,J){return zX($,M,J.width,J.startSegmentIndex,J.startGraphemeIndex,J.endSegmentIndex,J.endGraphemeIndex)}function iM($,M,J){let Z=[];if($.widths.length===0)return{lineCount:0,height:0,lines:Z};let X=TX($),A=cM(WX($),M,(Y)=>{Z.push(OX($,X,Y))});return{lineCount:A,height:A*J,lines:Z}}function g6($,M,J){let Z=$.image?M.images.get($.image.url)??null:null,X=$.image?.width??null,A=Math.min(J,X??240),Y=Math.max(120,Math.round(A*0.5625));if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return{height:Y,width:A};let Q=Math.min(J,X??Z.intrinsicWidth),K=Math.min(1,Q/Z.intrinsicWidth);return{height:Math.max(48,Math.round(Z.intrinsicHeight*K)),width:Math.max(48,Math.round(Z.intrinsicWidth*K))}}function oM($,M){if(!$.image)return`${$.kind}:missing-image`;let J=M.images.get($.image.url);return`${$.kind}:${$.image.url}:${$.image.width??0}:${J?.status??"loading"}:${J?.intrinsicWidth??0}:${J?.intrinsicHeight??0}`}var nM=[{fontSize:32,lineHeight:36},{fontSize:26,lineHeight:32},{fontSize:21,lineHeight:28},{fontSize:21,lineHeight:28},{fontSize:19,lineHeight:26},{fontSize:18,lineHeight:26}],t4;function s0($){if($?.type==="heading"){let{fontSize:M}=$3($.depth);return`700 ${M}px "Iowan Old Style", "Palatino Linotype", serif`}switch($?.type){case"code":return"15px ui-monospace, SFMono-Regular, Menlo, monospace";default:return'16px "Iowan Old Style", "Palatino Linotype", serif'}}function O0($,M){if($?.type==="heading")return $3($.depth).lineHeight;if($?.type==="code")return 22;return M}function $3($){return nM[$-1]??nM.at(-1)}function i0($,M,J,Z,X,A,Y){let Q=`${$5(M,Y)}:${X}:${A}:${J}`,K=$.measuredLines.get(Q);if(K)return K;let q=CX($,M,J,Z,X,A,Y);return bM($,Q,q)}function e4($,M,J,Z,X,A,Y,Q){let K=`${$5(M,Q)}:${J}:${Z}:${A}:${Y}`,q=$.lineBoundaries.get(K);if(q)return q;let N=J3();if(!N)return eM(X);let U=[{left:0,offset:0}],G=0,B=M.inlines.filter((D)=>D.end>J&&D.start<Z);if(B.length===0)return eM(X);for(let D of B){let F=Math.max(J,D.start),H=Math.min(Z,D.end),b=M.text.slice(F,H),E=F-J;if(D.kind==="image"){let V=g6(D,Q,Y).width;G+=V,E+=b.length,U.push({left:G,offset:E});continue}N.font=M3(A,D.marks);for(let V of Array.from(b))G+=Z3($,N,V),E+=V.length,U.push({left:G,offset:E})}return CM($,K,U)}function bX($,M,J,Z){let X=`${J}::${Z}::${M}`,A=$.preparedText.get(X);if(A)return A;let Y=sM(M,J,{whiteSpace:Z});return OM($,X,Y)}function CX($,M,J,Z,X,A,Y){let Q=M.text;if(Q.length===0)return[{end:0,height:A,start:0,text:"",width:0}];if(LX(M))return wX($,M,J,X,A,Y);try{let K=bX($,Q,J,mX(Z));return iM(K,X,A).lines.map((N)=>({end:tM(K.segments,N.end),height:A,start:tM(K.segments,N.start),text:N.text,width:N.width}))}catch{return EX(Q,X,A)}}function tM($,M){let J=0;for(let A=0;A<M.segmentIndex;A+=1)J+=$[A]?.length??0;let Z=$[M.segmentIndex]??"",X=Array.from(Z);for(let A=0;A<M.graphemeIndex;A+=1)J+=X[A]?.length??0;return J}function eM($){let M=[{left:0,offset:0}],J=0,Z=0;for(let X of Array.from($))J+=9,Z+=X.length,M.push({left:J,offset:Z});return M}function EX($,M,J){let Z=Math.max(1,Math.floor(M/9)),X=vX($,Z),A=0;return X.map((Y)=>{let Q=A,K=Q+Y.length;return A=K,{end:K,height:J,start:Q,text:Y,width:Y.length*9}})}function wX($,M,J,Z,X,A){let Y=RX($,J3(),M,J,Z,X,A);if(Y.length===0)return[{end:0,height:X,start:0,text:"",width:0}];return jX(Y,M.text,Z,X)}function jX($,M,J,Z){let X=[],A=0;while(A<$.length){let Y=$[A].start;if($[A].text===`
14
- `){X.push({end:Y,height:Z,start:Y,text:"",width:0}),A+=1;continue}let Q=0,K=0,q=A,N=-1,U=Z;while(q<$.length){let B=$[q];if(B.text===`
15
- `)break;let D=Q+B.width;if(D>J&&q>A)break;if(Q=D,U=Math.max(U,B.height),B.breakable)N=q,K=Q;q+=1}if(q===$.length||$[q]?.text===`
16
- `){let B=$[q-1]?.end??Y;X.push({end:B,height:U,start:Y,text:M.slice(Y,B),width:Q}),A=q<$.length&&$[q]?.text===`
17
- `?q+1:q;continue}if(N>=A){let B=$[N].end;X.push({end:B,height:U,start:Y,text:M.slice(Y,B),width:K}),A=N+1;continue}let G=$[Math.max(A,q-1)].end;X.push({end:G,height:U,start:Y,text:M.slice(Y,G),width:Q}),A=Math.max(A+1,q)}return X}function RX($,M,J,Z,X,A,Y){let Q=[];for(let K of J.inlines){if(K.kind==="image"){let N=g6(K,Y,X);Q.push({breakable:!0,end:K.end,height:N.height,start:K.start,text:K.text,width:N.width});continue}if(M)M.font=M3(Z,K.marks);let q=K.start;for(let N of Array.from(K.text)){let U=q,G=U+N.length;Q.push({breakable:/\s/.test(N),end:G,height:A,start:U,text:N,width:N===`
18
- `?0:Z3($,M,N)}),q=G}}return Q}function LX($){return $.inlines.some((M)=>M.kind==="image"||SX(M))}function $5($,M){return[$.path,uX($.text),kX($,M)].join(":")}function kX($,M){return $.inlines.map((J)=>`${J.start}-${J.end}:${fX(J,M)}`).join("|")}function fX($,M){if($.kind==="image"&&$.image)return oM($,M);return`${$.kind}:${$.inlineCode?1:0}:${$.marks.join(",")}:${$.link?.url??""}`}function uX($){let M=2166136261;for(let J of $)M^=J.charCodeAt(0),M=Math.imul(M,16777619);return(M>>>0).toString(36)}function SX($){return $.marks.includes("italic")||$.marks.includes("bold")}function M3($,M){let J=[];if(M.includes("italic"))J.push("italic");if(M.includes("bold"))J.push("700");return J.length>0?`${J.join(" ")} ${$}`:$}function J3(){if(t4!==void 0)return t4;return t4=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,t4}function Z3($,M,J){if(!M)return 9;let Z=M.font,X=wM($,Z),A=X.get(J);if(A!==void 0)return A;let Y=M.measureText(J).width;return X.set(J,Y),Y}function mX($){return $?.type==="code"?"pre-wrap":"normal"}function vX($,M){if($.length===0)return[""];let J=$.split(`
19
- `),Z=[];for(let X of J){if(X.length===0){Z.push("");continue}let A=X;while(A.length>M){let Y=A.slice(0,M),Q=Y.lastIndexOf(" ");if(Q<=0){Z.push(Y),A=A.slice(M);continue}Z.push(Y.slice(0,Q)),A=A.slice(Q+1)}Z.push(A)}return Z}var b2=10,o0=8,h6=120;function X3($,M,J,Z,X,A,Y,Q,K,q){let N=Math.max(1,...A.rows.map((F)=>F.cells.length)),G=Math.max(h6,K.width-Y-K.paddingX)/N,B=gX(Z),D=Q;for(let F=0;F<A.rows.length;F+=1){let H=hX(B.get(F)??[],X,A,G,b2,K.lineHeight,q),b=Math.max(K.lineHeight+o0*2,...H.map((E)=>E.measuredLines.reduce((V,R)=>V+R.height,0)+o0*2));for(let E of H){let V=Y+E.cellIndex*G,R=D+o0;for(let O of E.measuredLines){let j={blockId:E.container.blockId,boundaries:e4(X,E.container,O.start,O.end,O.text,E.font,G-b2*2,q),regionId:E.container.id,end:O.end,font:E.font,height:O.height,left:V+b2,start:O.start,text:O.text,top:R,width:O.width};$.push(j),I6(M,j),R+=O.height}J.set(E.container.id,{bottom:D+b,left:V,right:V+G,top:D})}pX(M,A.id,D,D+b),D+=b}return D+K.blockGap}function gX($){let M=new Map;for(let J of $){let Z=IX(J.path);if(!Z)continue;let X=M.get(Z.rowIndex)??[];X.push({cellIndex:Z.cellIndex,container:J}),M.set(Z.rowIndex,X)}return M}function hX($,M,J,Z,X,A,Y){return[...$].sort((Q,K)=>Q.cellIndex-K.cellIndex).map(({cellIndex:Q,container:K})=>{let q=s0(J),N=O0(J,A),U=i0(M,K,q,J,Math.max(40,Z-X*2),N,Y);return{cellIndex:Q,container:K,font:q,lineHeight:N,measuredLines:U}})}function IX($){let M=/\.rows\.(\d+)\.cells\.(\d+)$/.exec($);if(!M)return null;return{cellIndex:Number(M[2]),rowIndex:Number(M[1])}}function pX($,M,J,Z){let X=$.get(M);$.set(M,{bottom:X?Math.max(X.bottom,Z):Z,top:X?Math.min(X.top,J):J})}var lX={blockGap:16,charWidth:9,indentWidth:24,lineHeight:24,paddingX:16,paddingY:12},rX=24,cX=16,xX=6,dX=10,aX=4;function M5($){let M=Math.max(12,Math.floor($.width/9)),J=Math.max(1,Math.ceil($.text.length/M));return{estimatedHeight:J*24,lineCount:J,width:$.width}}function J5($,M,J=z0(),Z=null){let X=Z??{images:new Map},A={...lX,...M},Y=[],Q=new Map,K=new Map($.regions.map((F)=>[F.id,{textLength:F.text.length}])),q=new Map($.blocks.map((F)=>[F.id,F.depth])),N=new Map($.blocks.map((F)=>[F.id,F])),U=E2($.document.blocks),G=new Map,B=A.paddingY;for(let F=0;F<$.regions.length;F+=1){let H=$.regions[F],b=q.get(H.blockId)??0,E=A.paddingX+b*A.indentWidth,V=Math.max(40,A.width-E-A.paddingX),R=U.get(H.blockId)??null;if(R?.type==="table"){let f=N.get(H.blockId)?.regionIds??[],z=$.regions.slice(F,F+f.length);B=X3(Y,G,Q,z,J,R,E,B,A,X),F+=z.length-1;continue}B=sX(Y,G,Q,H,J,R,E,B,V,A,X);let O=X5(N,U,$.regions,F,A.blockGap);B+=O;let j=G.get(H.blockId);if(j)j.bottom=Math.max(j.bottom,B)}return{blocks:$.blocks.map((F)=>{let H=G.get(F.id),b=H?.top??A.paddingY;return{bottom:H?.bottom??b+A.lineHeight/2,depth:F.depth,id:F.id,top:b,type:F.type}}),regionBounds:oX(Y,Q),regionLineIndices:iX(Y),regionMetrics:K,height:Math.max(B,A.paddingY),lines:Y,options:A,width:A.width}}function sX($,M,J,Z,X,A,Y,Q,K,q,N){let U=s0(A),G=O0(A,q.lineHeight),B=i0(X,Z,U,A,K,G,N),D=Q;for(let F of B){let H={blockId:Z.blockId,boundaries:e4(X,Z,F.start,F.end,F.text,U,K,N),regionId:Z.id,end:F.end,font:U,height:F.height,left:Y,start:F.start,text:F.text,top:D,width:F.width};$.push(H),I6(M,H),D+=F.height}return nX($,Z.id,J),D}function iX($){let M=[...$].sort((Z,X)=>Z.top-X.top||Z.left-X.left),J=new Map;$.length=0,$.push(...M);for(let[Z,X]of $.entries()){let A=J.get(X.regionId)??[];A.push(Z),J.set(X.regionId,A)}return J}function oX($,M){let J=new Map(M);for(let Z of $){let X=J.get(Z.regionId),A={bottom:Z.top+Z.height,left:Z.left,right:Z.left+Z.width,top:Z.top};J.set(Z.regionId,X?{bottom:Math.max(X.bottom,A.bottom),left:Math.min(X.left,A.left),right:Math.max(X.right,A.right),top:Math.min(X.top,A.top)}:A)}return J}function nX($,M,J){let Z=$.filter((X)=>X.regionId===M);if(Z.length===0)return;J.set(M,{bottom:Math.max(...Z.map((X)=>X.top+X.height)),left:Math.min(...Z.map((X)=>X.left)),right:Math.max(...Z.map((X)=>X.left+X.width)),top:Math.min(...Z.map((X)=>X.top))})}function I6($,M){let J=$.get(M.blockId),Z=M.top+M.height;$.set(M.blockId,{bottom:J?Math.max(J.bottom,Z):Z,top:J?Math.min(J.top,M.top):M.top})}function q3($,M){let J=0,Z=$.lines.length-1;while(J<=Z){let X=J+Z>>1,A=$.lines[X];if(M<A.top){Z=X-1;continue}if(M>=A.top+A.height){J=X+1;continue}return{index:X,line:A}}return null}function p6($,M){let J=[...$.regionBounds.entries()].find(([,A])=>{return M.x>=A.left&&M.x<=A.right&&M.y>=A.top&&M.y<=A.bottom});if(J)return Z5($,J[0],M.y);let Z=q3($,M.y);if(!Z)return null;let X=tX($,M.y,Z.index);if(X.length===1)return X[0]??null;return X.find((A)=>{let Y=$.regionBounds.get(A.line.regionId);return Y?M.x>=Y.left&&M.x<=Y.right:!1})??[...X].sort((A,Y)=>{let Q=$.regionBounds.get(A.line.regionId),K=$.regionBounds.get(Y.line.regionId),q=A3(M.x,Q),N=A3(M.x,K);return q-N})[0]??null}function l6($,M,J){if($.lines.length===0)return{endIndex:0,startIndex:0};let Z=M+J,X=Y3($,M),A=Y3($,Z);if(X>0){let Y=$.lines[X-1];if(Y.top+Y.height>M)X-=1}if(A<$.lines.length){if($.lines[A].top<Z)A+=1}return{endIndex:A,startIndex:X}}function c1($,M,J){if(!$.regionMetrics.get(J.regionId))return null;let X=$0($,J.regionId,J.offset);if(!X)return null;return{blockId:X.blockId,regionId:X.regionId,height:X.height,left:x1(X,J.offset-X.start),offset:J.offset,top:X.top}}function $0($,M,J){return C2($,M,J)?.line??null}function Z5($,M,J){let Z=$.regionLineIndices.get(M);if(!Z||Z.length===0)return null;let X=Z[0],A=Number.POSITIVE_INFINITY;for(let Y of Z){let Q=$.lines[Y],K=J<Q.top?Q.top-J:J>Q.top+Q.height?J-(Q.top+Q.height):0;if(K<A)A=K,X=Y;if(K===0)break}return{index:X,line:$.lines[X]}}function C2($,M,J){let Z=$.regionLineIndices.get(M);if(!Z||Z.length===0)return null;let X=0,A=Z.length-1;while(X<=A){let N=X+A>>1,U=Z[N],G=$.lines[U];if(J<G.start){A=N-1;continue}if(J>G.end){X=N+1;continue}return{index:U,line:G}}let Y=Z[0],Q=Z[Z.length-1],K=$.lines[Y],q=$.lines[Q];if(J<=K.start)return{index:Y,line:K};if(J>=q.end)return{index:Q,line:q};return null}function tX($,M,J){let Z=[];for(let X=J;X>=0;X-=1){let A=$.lines[X];if(M<A.top||M>=A.top+A.height)break;Z.unshift({index:X,line:A})}for(let X=J+1;X<$.lines.length;X+=1){let A=$.lines[X];if(M<A.top||M>=A.top+A.height)break;Z.push({index:X,line:A})}return Z}function A3($,M){if(!M)return Number.POSITIVE_INFINITY;if($<M.left)return M.left-$;if($>M.right)return $-M.right;return 0}function x1($,M){return $.left+eX($.boundaries,M)}function E2($){let M=new Map,J=(Z)=>{for(let X of Z)if(M.set(X.id,X),X.type==="blockquote"||X.type==="listItem")J(X.children);else if(X.type==="list")J(X.items)};return J($),M}function eX($,M){for(let Z of $)if(Z.offset===M)return Z.left;return $.filter((Z)=>Z.offset<=M).at(-1)?.left??0}function Y3($,M){let J=0,Z=$.lines.length;while(J<Z){let X=J+Z>>1,A=$.lines[X];if(A.top+A.height<=M)J=X+1;else Z=X}return J}function N3($,M){if($.length===0)return 0;for(let J=1;J<$.length;J+=1){let Z=$[J-1],X=$[J],A=Z.left+(X.left-Z.left)/2;if(M<=A)return Z.offset;if(M<=X.left)return X.offset}return $.at(-1)?.offset??0}function X5($,M,J,Z,X){let A=J[Z],Y=J[Z+1];if(!A||!Y)return X;if(Q3($,A.blockId,Y.blockId,"list"))return xX;if(Q3($,A.blockId,Y.blockId,"blockquote"))return dX;if(A.blockId===Y.blockId)return aX;return X+$A(M.get(A.blockId))}function $A($){if($?.type!=="heading")return 0;if($.depth===1)return rX;return $.depth===2?cX:0}function Q3($,M,J,Z){let X=K3($,M,Z),A=K3($,J,Z);for(let Y of X)if(A.has(Y))return!0;return!1}function K3($,M,J){let Z=new Set,X=$.get(M)??null;while(X){if(X.type===J)Z.add(X.id);X=X.parentBlockId?$.get(X.parentBlockId)??null:null}return Z}function r6($,M,J,Z=[],X=z0(),A=null){let Y=A??{images:new Map},Q=E2($.document.blocks),K=new Map($.blocks.map((V)=>[V.id,V])),q=new Set(Z),N=Math.max(0,J.top-J.overscan),U=J.top+J.height+J.overscan,G=AA(X,$,Q,K,M,Y),B=U3(G,N),D=U3(G,U);if(B>0){let V=G.entries[B-1];if(V&&V.bottom>N)B-=1}if(D<G.entries.length){let V=G.entries[D];if(V&&V.top<U)D+=1}for(let V of q){let R=G.containerIndices.get(V);if(R===void 0)continue;B=Math.min(B,R),D=Math.max(D,R+1)}if(!Number.isFinite(B)||!Number.isFinite(D))return{estimateRegionBounds:G.estimateRegionBounds,layout:J5({...$,regions:[]},M,X,Y),totalHeight:G.totalHeight,viewport:J};let F=ZA($,K,G.containerIndices,B,D),H=G.entries[F.startIndex]?.top??M.paddingY??0,b=J5({...$,regions:$.regions.slice(F.startIndex,F.endIndex)},M,X,Y),E=JA(b,H,G.totalHeight);return MA(X,$,E,M,Y),{estimateRegionBounds:G.estimateRegionBounds,layout:E,totalHeight:G.totalHeight,viewport:J}}function MA($,M,J,Z,X){for(let[A,Y]of J.regionBounds){let Q=Y.bottom-Y.top,K=M.regionIndex.get(A);EM($,G3(K??{path:A,inlines:[],text:""},Z,X),Q)}}function JA($,M,J){return{...$,blocks:$.blocks.map((Z)=>({...Z,bottom:Z.bottom+M,top:Z.top+M})),regionBounds:new Map([...$.regionBounds.entries()].map(([Z,X])=>[Z,{bottom:X.bottom+M,left:X.left,right:X.right,top:X.top+M}])),height:J,lines:$.lines.map((Z)=>({...Z,top:Z.top+M}))}}function ZA($,M,J,Z,X){let A=Z,Y=X;for(let Q=Z;Q<X;Q+=1){let K=$.regions[Q],q=M.get(K.blockId);if(!q)continue;if(q.type==="table"){let N=J.get(q.regionIds[0]??""),U=J.get(q.regionIds[q.regionIds.length-1]??"");if(N!==void 0)A=Math.min(A,N);if(U!==void 0)Y=Math.max(Y,U+1)}}return{endIndex:Y,startIndex:A}}function XA($,M,J,Z,X,A){let Y=G3(M,X,A),Q=$.measuredContainerHeights.get(Y);if(Q!==void 0)return Q;let K=X.paddingX??0,q=X.indentWidth??24,N=O0(J,X.lineHeight??24),U=K+Z*q,G=Math.max(40,X.width-U-K);if(M.inlines.some((F)=>F.kind==="image")){let F=s0(J);return i0($,M,F,J,G,N,A).reduce((H,b)=>H+b.height,0)}let B=M5({text:M.text,width:G});return Math.max(N,B.lineCount*N)}function AA($,M,J,Z,X,A){let Y=qA(M,X,A),Q=jM($,M,Y);if(Q)return Q;let K=X.paddingY??0,q=[],N=new Map;for(let U=0;U<M.regions.length;U+=1){let G=M.regions[U],B=J.get(G.blockId)??null;if(B?.type==="table"){let b=YA({block:B,blockMap:J,containerIndices:N,entries:q,index:U,options:X,runtimeBlocks:Z,totalHeight:K,regions:M.regions});if(b){U=b.nextIndex-1,K=b.totalHeight;continue}}let D=XA($,G,B,Z.get(G.blockId)?.depth??0,X,A),F=K,H=F+D;q.push({bottom:H,top:F}),N.set(G.id,U),K=H+X5(Z,J,M.regions,U,X.blockGap??16)}return RM($,M,Y,{containerIndices:N,entries:q,estimateRegionBounds(U){let G=N.get(U);return G===void 0?null:q[G]??null},totalHeight:K})}function YA({block:$,blockMap:M,containerIndices:J,entries:Z,index:X,options:A,runtimeBlocks:Y,totalHeight:Q,regions:K}){let q=Y.get($.id),N=q?.regionIds??[];if(N.length===0)return null;let U=K.slice(X,X+N.length);if(U.length===0||U[0]?.blockId!==$.id)return null;let G=A.paddingX??0,B=A.indentWidth??24,D=q?.depth??0,F=G+D*B,H=Math.max(h6,A.width-F-G),b=Math.max(1,...$.rows.map((f)=>f.cells.length)),E=H/b,V=Math.max(40,E-b2*2),R=O0($,A.lineHeight??24),O=QA(U,X),j=Q;for(let f=0;f<$.rows.length;f+=1){let z=O.get(f)??[],y=Math.max(R+o0*2,...z.map(({region:W})=>KA(W,V,R)+o0*2)),T=j+y;for(let{index:W,region:_}of z)Z[W]={bottom:T,top:j},J.set(_.id,W);j=T}for(let f=X;f<X+U.length;f+=1){let z=K[f];if(!z||Z[f])continue;Z[f]={bottom:j,top:j},J.set(z.id,f)}return{nextIndex:X+U.length,totalHeight:j+X5(Y,M,K,X+U.length-1,A.blockGap??16)}}function QA($,M){let J=new Map;for(let[Z,X]of $.entries()){let A=X.tableCellPosition?.rowIndex;if(A===void 0)continue;let Y=J.get(A)??[];Y.push({index:M+Z,region:X}),J.set(A,Y)}return J}function KA($,M,J){let Z=M5({text:$.text,width:M});return Math.max(J,Z.lineCount*J)}function qA($,M,J){return[M.width,M.paddingX??0,M.paddingY??0,M.indentWidth??24,M.lineHeight??24,M.blockGap??16,NA($,J)].join(":")}function U3($,M){let J=0,Z=$.entries.length;while(J<Z){let X=J+Z>>1;if($.entries[X].bottom<=M)J=X+1;else Z=X}return J}function G3($,M,J){return`${$5($,J)}:${M.width}:${M.paddingX??0}:${M.indentWidth??24}:${M.lineHeight??24}`}function NA($,M){return $.regions.flatMap((J)=>J.inlines.filter((Z)=>Z.kind==="image"&&Z.image).map((Z)=>{let X=Z.image?M.images.get(Z.image.url):null;return`${Z.image?.url??""}:${Z.image?.width??0}:${X?.status??"loading"}:${X?.intrinsicWidth??0}:${X?.intrinsicHeight??0}`})).join("|")}var A5=null;function UA($){let M=/(\d+(?:\.\d+)?)\s*px/.exec($);return M?Number.parseFloat(M[1]):16}function K0($){A5??=new Map;let M=A5.get($);if(M)return M;let J=D3(),Z=Math.max(12,Math.round(UA($)));if(!J){let G={ascent:Math.round(Z*0.8),descent:Math.max(2,Z-Math.round(Z*0.8)),emHeight:Z};return A5.set($,G),G}J.font=$;let X=J.measureText("Hg"),A=Math.round(X.actualBoundingBoxAscent||0),Y=Math.round(X.actualBoundingBoxDescent||0),Q=A+Y,K=Math.max(Z,Q),q=Q>0?A:Math.round(K*0.8),N=Q>0?Y:Math.max(2,K-q),U={ascent:q,descent:N,emHeight:K};return A5.set($,U),U}function GA($,M){let{emHeight:J}=K0(M);return Math.max(0,Math.floor(($-J)/2))}function B3($,M){let{ascent:J}=K0(M);return GA($,M)+J}var Y5;function F3($,M){let J=D3();if(!J||$.length===0)return 0;return J.font=M,J.measureText($).width}function D3(){if(Y5!==void 0)return Y5;return Y5=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,Y5}var BA=18,FA=14,DA=22;function C1($,M,J){let Z=HA($,J);if(!Z)return null;return _3($,M,Z,J.x)}function c6($,M,J){let Z=$.lines[$.lines.length-1];if(!Z||J.y<=Z.top+Z.height)return null;return _3($,M,Z,J.x)}function _3($,M,J,Z){let X=$.regionMetrics.get(J.regionId);if(!X)return null;let A=Math.max(0,Z-N0(M,J)-J.left),Y=N3(J.boundaries,A),Q=Math.min(X.textLength,J.start+Y);return{regionId:J.regionId,offset:Q,left:x1(J,Y),top:J.top,height:J.height}}function x6($,M,J,Z){let X=o6(M,Z.regionId);if(!X)return null;let A=C1($,M,J);if(A)return{regionId:A.regionId,offset:A.offset};let Y=J.y<WA($);return{regionId:Z.regionId,offset:Y?0:X.text.length}}function d6($,M,J){let Z=C1($,M,J);if(!Z)return null;let X=o6(M,Z.regionId);if(!X||X.text.length===0)return null;let A=Z.offset<X.text.length&&/\w/.test(X.text[Z.offset]??"")?Z.offset:Z.offset>0&&/\w/.test(X.text[Z.offset-1]??"")?Z.offset-1:Z.offset,Y=TA(X.text,A);if(Y.start===Y.end)return null;return{anchor:{regionId:Z.regionId,offset:Y.start},focus:{regionId:Z.regionId,offset:Y.end}}}function H3($,M,J){let Z=PA($,J);if(!Z||Z.start!==0)return null;let X=n0(M,Z.blockId,"listItem");if(!X)return null;if(j2(M,X.id)?.kind!=="task")return null;let Y=w2(Z),Q=Y.left-4,K=Y.left+Y.size+4,q=Y.top-4,N=Y.top+Y.size+4;return J.x>=Q&&J.x<=K&&J.y>=q&&J.y<=N?{listItemId:X.id}:null}function P3($,M,J){let Z=C1($,M,J);if(!Z)return null;let X=o6(M,Z.regionId);if(!X)return null;let A=X.inlines.find((Q)=>Q.link&&Z.offset>=Q.start&&Z.offset<Q.end);if(!A?.link)return null;let Y=i6($,M,Z.regionId,A.start);if(!Y)return null;return{anchorBottom:Y.anchorBottom,anchorLeft:Y.anchorLeft,endOffset:A.end,regionId:Z.regionId,startOffset:A.start,title:A.link.title,url:A.link.url}}function a6($,M,J,Z){let X=H3($,M,J);if(X)return{kind:"task-toggle",listItemId:X.listItemId};let A=C1($,M,J);if(!A)return null;let Y=W3(A.regionId,A.offset,Z),Q=Y!==null?T3(Y,$,M,Z):null,K=P3($,M,J);if(K)return{anchorBottom:Q?.anchorBottom??K.anchorBottom,anchorLeft:Q?.anchorLeft??K.anchorLeft,endOffset:K.endOffset,kind:"link",commentThreadIndex:Y,regionId:K.regionId,startOffset:K.startOffset,title:K.title,url:K.url};return{anchorBottom:Q?.anchorBottom??A.top+A.height,anchorLeft:Q?.anchorLeft??A.left,kind:"text",commentThreadIndex:Y}}function s6($,M,J,Z){let X=M.documentIndex.regionIndex.get(J.regionId);if(!X)return null;let A=W3(J.regionId,J.offset,Z),Y=A!==null?T3(A,$,M,Z):null,Q=X.inlines.find((K)=>J.offset>=K.start&&J.offset<=K.end)??null;if(Q?.link){let K=i6($,M,J.regionId,Q.start);if(!K)return null;return{anchorBottom:Y?.anchorBottom??K.anchorBottom,anchorLeft:Y?.anchorLeft??K.anchorLeft,commentThreadIndex:A,endOffset:Q.end,kind:"link",regionId:J.regionId,startOffset:Q.start,title:Q.link.title,url:Q.link.url}}if(Y)return{anchorBottom:Y.anchorBottom,anchorLeft:Y.anchorLeft,commentThreadIndex:A,kind:"text"};return null}function d1($,M,J){let Z=$0(M,J.regionId,J.offset);if(!Z)return J.left;return J.left+N0($,Z)+_A($,Z,J.offset)}function q0($,M,J){return x1(M,J)+N0($,M)}function N0($,M){let J=n0($,M.blockId,"listItem");if(!J)return 0;return j2($,J.id)?.kind==="task"?DA:BA}function w2($){return{left:$.left,size:FA,top:$.top+3}}function n0($,M,J){let Z=$.documentIndex.blockIndex.get(M)??null;while(Z){if(Z.type===J)return Z;let X=Z.parentBlockId;Z=X?$.documentIndex.blockIndex.get(X)??null:null}return null}function j2($,M){return $.documentIndex.listItemMarkers.get(M)??null}function W3($,M,J){for(let Z of J)if(Z.regionId===$&&M>=Z.startOffset&&M<=Z.endOffset)return Z.threadIndex;return null}function T3($,M,J,Z){let X=Z.find((A)=>A.threadIndex===$);if(!X)return null;return i6(M,J,X.regionId,X.startOffset)}function i6($,M,J,Z){let X=$0($,J,Z);if(!X)return null;return{anchorBottom:X.top+X.height,anchorLeft:x1(X,Z)+N0(M,X)}}function _A($,M,J){if(J<=M.end)return 0;let Z=$.documentIndex.regionIndex.get(M.regionId);if(!Z)return 0;let X=Z.text.slice(M.end,J);if(!/^[ \t]+$/u.test(X))return 0;return F3(X,M.font)}function HA($,M){for(let[Z,X]of $.regionBounds)if(M.x>=X.left&&M.x<=X.right&&M.y>=X.top&&M.y<=X.bottom)return Z5($,Z,M.y)?.line??null;let J=p6($,M)?.line??null;if(J)return J;for(let Z of $.blocks)if(M.y>=Z.top&&M.y<=Z.bottom){for(let X=$.lines.length-1;X>=0;X--)if($.lines[X].blockId===Z.id)return $.lines[X]}return null}function PA($,M){return $.lines.find((J)=>M.y>=J.top-4&&M.y<=J.top+J.height+4)??$.lines.filter((J)=>Math.abs(M.y-(J.top+J.height/2))<=10).sort((J,Z)=>Math.abs(M.y-(J.top+J.height/2))-Math.abs(M.y-(Z.top+Z.height/2)))[0]??null}function o6($,M){return $.documentIndex.regionIndex.get(M)??null}function WA($){return $.lines[0]?.top??0}function TA($,M){let J=M,Z=M;while(J>0&&/\w/.test($[J-1]??""))J-=1;while(Z<$.length&&/\w/.test($[Z]??""))Z+=1;return{end:Z,start:J}}function n6($,M,J,Z=null){let X={height:M.height,overscan:Math.max(160,M.height),top:M.top},A=r6($.documentIndex,M,X,[$.selection.anchor.regionId,$.selection.focus.regionId],J,Z);return{blockMap:E2($.documentIndex.document.blocks),estimateRegionBounds:A.estimateRegionBounds,regionBounds:new Map(A.layout.regionBounds),layout:A.layout,paintHeight:Math.max(240,X.height+X.overscan*2),paintTop:Math.max(0,X.top-X.overscan),totalHeight:A.totalHeight,viewport:{height:X.height,top:X.top}}}function t6($,M,J){return C1(M.layout,$,J)??c6(M.layout,$,J)}function R2($,M,J,Z){return x6(M.layout,$,J,Z)}function e6($,M,J){return d6(M.layout,$,J)}function $8($,M,J,Z){return a6(M.layout,$,J,Z)}function M8($,M,J,Z){return s6(M.layout,$,J,Z)}function J8($,M,J){return c1(M.layout,$.documentIndex,J)}function M0($,M,J){let Z=c1(M.layout,$.documentIndex,J);if(!Z)return null;return{...Z,left:d1($,M.layout,Z)}}function X8($,M,J){let Z=J.trim();if(Z.length===0||M.startOffset===M.endOffset)return null;let X=$.regionIndex.get(M.regionId)??null,A=X?Z8($,X):null;if(!A)return null;return W6({anchor:T2(A,M.startOffset,M.endOffset),body:Z,quote:y2(A,M.startOffset,M.endOffset)})}function f1($){let M="documentIndex"in $?$.documentIndex:$,J=Q5(M),Z=M.document.comments,X=[...Z],A=[];for(let[Y,Q]of Z.entries()){let K=V2(Q,M.document);if(!K.match)continue;let N=J.findBySemanticMatch(K.match.containerId,K.match.containerOrdinal)?.runtimeContainer??null;if(!N)continue;if(K.repair)X[Y]={...Q,anchor:K.repair.anchor,quote:K.repair.quote};A.push({endOffset:K.match.endOffset,resolution:K,regionId:N.id,resolved:Q.resolvedAt!=null,startOffset:K.match.startOffset,threadIndex:Y})}return{liveRanges:A,threads:X}}function A8($,M,J,Z,X,A){if($.document.comments.length===0)return M.document.comments;let Y=$.commentContainerIndex.get(J.semanticRegionId)??[],Q=new Set(Y);if(Y.length===0)return M.document.comments;let K=f1($),q=new Map(K.liveRanges.map((B)=>[B.threadIndex,B])),N=Z8($,J),U=t0(M,J.path),G=U?Z8(M,U):null;if(!N||!G)return M.document.comments;return M.document.comments.map((B,D)=>{if(!Q.has(D))return B;let F=q.get(D),H=F?.resolution.match??null;if(!F||!H||H.containerId!==N.id)return B;let b=VA(H.startOffset,H.endOffset,Z,X,A.length);if(!b)return B;return{...B,anchor:T2(G,b.start,b.end),quote:y2(G,b.start,b.end)}})}function Z8($,M){let J=yA($,M);if(!J)return null;return{containerKind:J,containerOrdinal:-1,id:M.semanticRegionId,text:M.text}}function yA($,M){if($.tableCellIndex.has(M.id))return"tableCell";switch(M.blockType){case"code":return"code";case"heading":case"paragraph":return"text";default:return null}}function VA($,M,J,Z,X){let A=Z-J,Y=X-A;if(Z<=$)return{end:M+Y,start:$+Y};if(J>=M)return{end:M,start:$};let Q=Math.max(0,Math.min(J,M)-$),K=Math.max(0,M-Math.max(Z,$)),q=$<J?$:J;return{end:q+Q+X+K,start:q}}function K5($,M){if(M.length===0)return[];let J=Q5($),Z=J.list();return M.map((X)=>({...X,cursorPoint:zA(X,Z,J),viewport:null}))}function zA($,M,J){if(!$.cursor)return null;let Z=OA(M,$.cursor),X=bA(Z,$.cursor);if(X.length!==1)return null;let A=X[0],Y=J.resolveRuntimeContainer(A.container.id);if(!Y)return null;return{offset:Math.max(0,Math.min(A.offset,Y.text.length)),regionId:Y.id}}function OA($,M){return M.kind?$.filter((J)=>J.containerKind===M.kind):$}function bA($,M){if(M.prefix&&M.suffix)return CA($,M.prefix,M.suffix);if(M.prefix)return y3($,M.prefix,"after");if(M.suffix)return y3($,M.suffix,"before");return[]}function y3($,M,J){if(M.length===0)return[];let Z=[];for(let X of $)for(let A of V3(X.text,M))Z.push({container:X,offset:J==="after"?A+M.length:A});return Z}function CA($,M,J){if(M.length===0||J.length===0)return[];let Z=[];for(let X of $)for(let A of V3(X.text,M)){let Y=A+M.length;if(X.text.indexOf(J,Y)!==-1)Z.push({container:X,offset:Y})}return Z}function V3($,M){let J=[],Z=0;while(Z<=$.length){let X=$.indexOf(M,Z);if(X===-1)break;J.push(X),Z=X+Math.max(1,M.length)}return J}var EA=48;function q5($,M,J){let Z="documentIndex"in $?$.documentIndex:$;if(J.length===0)return[];return J.map((X)=>({...X,viewport:wA(Z,M,X)}))}function wA($,M,J){if(!J.cursorPoint)return z3();let Z=c1(M.layout,$,J.cursorPoint),X=Z?{bottom:Z.top+Z.height,top:Z.top}:M.estimateRegionBounds(J.cursorPoint.regionId);if(!X)return z3();return{scrollTop:RA(M,X),status:jA(M,X)}}function jA($,M){let J=$.viewport.top,Z=J+$.viewport.height;if(M.bottom<J)return"above";if(M.top>Z)return"below";return"visible"}function RA($,M){let J=Math.max(0,$.totalHeight-$.viewport.height),Z=M.top-Math.min(EA,$.viewport.height/4);return Math.max(0,Math.min(J,Z))}function z3(){return{scrollTop:null,status:"unresolved"}}function Q5($){let M=i4($.document),J=new Map(M.map((X)=>[X.id,X])),Z=new Map($.regions.map((X)=>[X.semanticRegionId,X]));return{findBySemanticMatch(X,A){let Y=J.get(X)??M[A]??null;if(!Y)return null;return{runtimeContainer:Z.get(Y.id)??null,semanticContainer:Y}},list(X){return X?M.filter((A)=>A.containerKind===X):M},resolveRuntimeContainer(X){return Z.get(X)??null}}}var L2="",O3=1e6;function k2($,M,J){return`${$}:${M}:${J}`}function U1($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&Z.marks.join(",")===J.marks.join(",")){M[M.length-1]=W1({marks:Z.marks,path:Z.id,text:Z.text+J.text});continue}M.push(J)}return M}function e0($){let M=aA($),J=Q8(M.blocks.map((Z,X)=>u2(Z,X)));return K8(M,J)}function u2($,M){let J=[],Z=[],X=[],A=0;function Y(K,q,N,U,G=null){if(Z.length>0)X.push(`
20
- `),A+=1;let B=N.map((H)=>H.text).join(""),D=A,F=D+B.length;X.push(B),A=F,Z.push({blockId:K.id,blockType:K.type,end:F,id:`${K.id}:${q}`,path:q,rootIndex:M,inlines:N,semanticRegionId:U,start:D,tableCellPosition:G,text:B})}function Q(K,q,N,U){let G={childBlockIds:[],depth:N,end:A,id:K.id,parentBlockId:U,path:q,regionIds:[],rootIndex:M,start:A,type:K.type};switch(J.push(G),K.type){case"blockquote":case"listItem":for(let[B,D]of K.children.entries())G.childBlockIds.push(D.id),Q(D,`${q}.children.${B}`,N+1,K.id);break;case"code":{Y(K,`${q}.source`,[{end:K.source.length,id:`${K.id}:code`,image:null,inlineCode:!1,kind:"text",link:null,marks:[],originalType:null,start:0,text:K.source}],K.id),G.regionIds.push(Z.at(-1).id);break}case"heading":case"paragraph":Y(K,`${q}.children`,Y8(K.children),K.id),G.regionIds.push(Z.at(-1).id);break;case"list":for(let[B,D]of K.items.entries())G.childBlockIds.push(D.id),Q(D,`${q}.children.${B}`,N+1,K.id);break;case"table":for(let[B,D]of K.rows.entries())for(let[F,H]of D.cells.entries())Y(K,`${q}.rows.${B}.cells.${F}`,Y8(H.children),H.id,{cellIndex:F,rowIndex:B}),G.regionIds.push(Z.at(-1).id);break;case"thematicBreak":break;case"directive":break;case"unsupported":Y(K,`${q}.source`,[{end:K.source.length,id:`${K.id}:unsupported`,image:null,inlineCode:!1,kind:"unsupported",link:null,marks:[],originalType:K.originalType,start:0,text:K.source}],K.id),G.regionIds.push(Z.at(-1).id);break}G.end=A}return Q($,`root.${M}`,0,null),{blockRange:{end:J.length,start:0},blocks:J,end:A,length:A,regionRange:Z.length>0?{end:Z.length,start:0}:void 0,regions:Z,rootIndex:M,start:0,text:X.join("")}}function Q8($,M=null){let J=[],Z=0,X=0,A=0,Y=!1;for(let[Q,K]of $.entries()){if(K.regions.length>0&&Y)A+=1;let q={...K,blockRange:{end:Z+K.blocks.length,start:Z},end:A+K.length,regionRange:K.regions.length>0?{end:X+K.regions.length,start:X}:void 0,start:A},N=M?.[Q];if(J.push(kA(N,K,q)?N:b3(K,q)),Z=q.blockRange.end,X=q.regionRange?.end??X,K.regions.length>0)A=q.end,Y=!0}return J}function $2($,M,J,Z){let X=M.blocks.length-($.roots.length-Z);if(X<0)throw Error("Editor model splice received an invalid replacement count.");if(J===$.roots.length&&X===1){let K=M.blocks[J];if(K)return LA($,M,K)}let A=X===Z,Y=[...$.roots.slice(0,J),...M.blocks.slice(J,J+X).map((K,q)=>u2(K,J+q)),...A?$.roots.slice(J+Z):M.blocks.slice(J+X).map((K,q)=>u2(K,J+X+q))],Q=Q8(Y,$.roots);return K8(M,Q,$)}function LA($,M,J){let Z=$.roots.length,X=u2(J,Z),A=$.roots.some((N)=>N.regions.length>0),Y=X.regions.length>0&&A?$.length+1:$.length,Q=b3(X,{...X,blockRange:{end:$.blocks.length+X.blocks.length,start:$.blocks.length},end:Y+X.length,regionRange:X.regions.length>0?{end:$.regions.length+X.regions.length,start:$.regions.length}:void 0,start:Y}),K=[...$.blocks,...Q.blocks],q=[...$.regions,...Q.regions];return{blockIndex:vA($.blockIndex,Q.blocks),blocks:K,commentContainerIndex:M.comments===$.document.comments?$.commentContainerIndex:C3(M),document:M,engine:"canvas",length:Q.end,listItemMarkers:M.blocks===$.document.blocks?$.listItemMarkers:rA($.listItemMarkers,J),regionIndex:gA($.regionIndex,Q.regions),regionOrderIndex:hA($.regionOrderIndex,Q.regions,$.regions.length),regionPathIndex:IA($.regionPathIndex,Q.regions),regions:q,roots:[...$.roots,Q],tableCellIndex:pA($.tableCellIndex,Q.regions),tableCellRegionIndex:lA($.tableCellRegionIndex,Q.regions),text:cA($.text,Q)}}function S2($,M){if(M.blocks!==$.document.blocks)throw Error("Editor model document replacement requires preserving root blocks.");return K8(M,$.roots,$)}function K8($,M,J=null){let Z=M.flatMap((N)=>N.blocks),X=M.flatMap((N)=>N.regions),{regionIndex:A,regionOrderIndex:Y,regionPathIndex:Q,tableCellIndex:K,tableCellRegionIndex:q}=mA(X);return{blockIndex:SA(Z),blocks:Z,commentContainerIndex:$.comments===J?.document.comments?J.commentContainerIndex:C3($),document:$,engine:"canvas",length:M.at(-1)?.end??0,listItemMarkers:$.blocks===J?.document.blocks?J.listItemMarkers:dA($.blocks),regionIndex:A,regionOrderIndex:Y,regionPathIndex:Q,regions:X,roots:M,tableCellIndex:K,tableCellRegionIndex:q,text:xA(M)}}function b3($,M){let J=M.start-$.start;return{...M,blocks:J===0?$.blocks:fA($.blocks,J),regions:J===0?$.regions:uA($.regions,J)}}function kA($,M,J){return Boolean($&&M===$&&$.start===J.start&&$.end===J.end&&$.blockRange.start===J.blockRange.start&&$.blockRange.end===J.blockRange.end&&$.regionRange?.start===J.regionRange?.start&&$.regionRange?.end===J.regionRange?.end)}function fA($,M){return $.map((J)=>({...J,end:J.end+M,start:J.start+M}))}function uA($,M){return $.map((J)=>({...J,end:J.end+M,start:J.start+M}))}function SA($){let M=new Map;for(let J of $)M.set(J.id,J);return M}function mA($){let M=new Map,J=new Map,Z=new Map,X=new Map,A=new Map;for(let[Y,Q]of $.entries()){if(M.set(Q.id,Q),J.set(Q.id,Y),Z.set(Q.path,Q),!Q.tableCellPosition)continue;X.set(Q.id,Q.tableCellPosition),A.set(k2(Q.blockId,Q.tableCellPosition.rowIndex,Q.tableCellPosition.cellIndex),Q.id)}return{regionIndex:M,regionOrderIndex:J,regionPathIndex:Z,tableCellIndex:X,tableCellRegionIndex:A}}function vA($,M){let J=new Map($);for(let Z of M)J.set(Z.id,Z);return J}function gA($,M){let J=new Map($);for(let Z of M)J.set(Z.id,Z);return J}function hA($,M,J){let Z=new Map($);for(let[X,A]of M.entries())Z.set(A.id,J+X);return Z}function IA($,M){let J=new Map($);for(let Z of M)J.set(Z.path,Z);return J}function pA($,M){let J=new Map($);for(let Z of M)if(Z.tableCellPosition)J.set(Z.id,Z.tableCellPosition);return J}function lA($,M){let J=new Map($);for(let Z of M){if(!Z.tableCellPosition)continue;J.set(k2(Z.blockId,Z.tableCellPosition.rowIndex,Z.tableCellPosition.cellIndex),Z.id)}return J}function rA($,M){let J=new Map($);return f2(J,[M]),J}function cA($,M){if(M.regions.length===0)return $;return $.length>0?`${$}
21
- ${M.text}`:M.text}function xA($){return $.filter((M)=>M.regions.length>0).map((M)=>M.text).join(`
22
- `)}function C3($){let M=new Map;for(let[J,Z]of $.comments.entries()){let X=V2(Z,$).match?.containerId??null;if(!X)continue;let A=M.get(X)??[];A.push(J),M.set(X,A)}return M}function dA($){let M=new Map;return f2(M,$),M}function f2($,M,J=null){for(let Z of M){if(Z.type==="list"){for(let[X,A]of Z.items.entries())f2($,[A],{index:X,ordered:Z.ordered,start:Z.start});continue}if(Z.type==="listItem"){if(typeof Z.checked==="boolean")$.set(Z.id,{checked:Z.checked,kind:"task"});else if(J?.ordered)$.set(Z.id,{kind:"ordered",label:`${(J.start??1)+J.index}.`});else $.set(Z.id,{kind:"bullet",label:"•"});f2($,Z.children,J)}if(Z.type==="blockquote")f2($,Z.children,J)}}function aA($){if($.blocks.length>0)return $;return h0([I({text:""})],$.comments)}function Y8($,M=null){let J=[],Z=0,X=(A)=>{let Y=Z,Q=Y+A.text.length;J.push({...A,end:Q,start:Y}),Z=Q};for(let A of $)switch(A.type){case"break":X({id:A.id,image:null,inlineCode:!1,kind:"break",link:M,marks:[],originalType:null,text:`
23
- `});break;case"image":X({id:A.id,image:{alt:A.alt,title:A.title,url:A.url,width:A.width},inlineCode:!1,kind:"image",link:M,marks:[],originalType:null,text:sA(A.alt)});break;case"inlineCode":X({id:A.id,image:null,inlineCode:!0,kind:"inlineCode",link:M,marks:[],originalType:null,text:A.code});break;case"link":for(let Y of Y8(A.children,{title:A.title,url:A.url}))X(Y);break;case"text":X({id:A.id,image:null,inlineCode:!1,kind:"text",link:M,marks:A.marks,originalType:null,text:A.text});break;case"unsupported":X({id:A.id,image:null,inlineCode:!1,kind:"unsupported",link:M,marks:[],originalType:A.originalType,text:A.source});break}return J}function sA($){return L2}function N5($,M){let J=$.regionIndex.get(M);if(!J)return null;let Z=l0($.document.blocks,J.blockId);if(!Z)return null;return U5(Z,J.path,J.semanticRegionId)}function w3($,M,J,Z,X){if(J>=Z)return null;let A=N5($,M);return A?X(A,J,Z):null}function m2($,M,J,Z,X){let A=w3($,M,J,Z,X);return A?{kind:"replace-block",block:A.block,blockId:A.blockId,selection:A.selection}:null}function U5($,M,J){if($.type==="heading"||$.type==="paragraph")return{block:$,children:$.children,kind:"inlineBlock",path:M.replace(/\.children$/,"")};if($.type!=="table")return null;let Z=/^(.*\.rows\.\d+\.cells\.\d+)$/.exec(M);if(!Z)return null;for(let X of $.rows)for(let A of X.cells)if(A.id===J)return{block:$,blockPath:Z[1].replace(/\.rows\.\d+\.cells\.\d+$/,""),cell:A,children:A.children,kind:"tableCell",path:Z[1]};return null}function U0($,M,J,Z){switch($.kind){case"inlineBlock":return{block:k1($.block,M),blockId:$.block.id,selection:E3(`${$.path}.children`,J,Z)};case"tableCell":{let X=X0({children:M,path:$.path}),A=$.block.rows.map((Y)=>({...Y,cells:Y.cells.map((Q)=>Q.id===$.cell.id?X:Q)}));return{block:r1($.block,A),blockId:$.block.id,selection:E3($.path,J,Z)}}}}function E3($,M,J){return{endOffset:J,kind:"region-range-path",path:$,startOffset:M}}function P1($){switch($.type){case"break":return 1;case"image":return L2.length;case"inlineCode":return $.code.length;case"link":return F1($.children).length;case"text":return $.text.length;case"unsupported":return $.source.length}}function G5($,M,J){if(M<=0)return[];return q8($,0,M,`${J}.before`)}function B5($,M,J){let Z=P1($);if(M>=Z)return[];return q8($,M,Z,`${J}.after`)}function q8($,M,J,Z){if(M>=J)return[];switch($.type){case"text":return U1([b0($.text.slice(M,J),$.marks,Z)].filter(Boolean));case"inlineCode":return[U8($.code.slice(M,J),Z)];case"link":{let X=U1(iA($.children,M,J,`${Z}.children`));return X.length>0?[{...$,children:X}]:[]}default:return[]}}function N8($,M,J){let Z=0,X="";for(let A of $){let Y=P1(A),Q=Z,K=Q+Y;if(Z=K,J<=Q||M>=K)continue;X+=oA(A,Math.max(0,M-Q),Math.min(Y,J-Q))}return X}function b0($,M,J){if($.length===0)return null;return W1({marks:M,path:J,text:$})}function U8($,M){return S0({code:$,path:M})}function iA($,M,J,Z){let X=[],A=0;for(let[Y,Q]of $.entries()){let K=P1(Q),q=A,N=q+K;if(A=N,J<=q||M>=N)continue;X.push(...q8(Q,Math.max(0,M-q),Math.min(K,J-q),`${Z}.${Y}`))}return X}function oA($,M,J){if(M>=J)return"";switch($.type){case"break":return`
24
- `.slice(M,J);case"image":return L2.slice(M,J);case"inlineCode":return $.code.slice(M,J);case"link":return N8($.children,M,J);case"text":return $.text.slice(M,J);case"unsupported":return $.source.slice(M,J)}}function G8($,M,J,Z){let X=nA($.children,M,J,Z);if(X===null)return null;let A=U1(j3($.children,M,J,Z,X,`${$.path}.children`));return A.length>0?U0($,A,M,J):null}function B8($,M,J){let Z=0,X=null,A=(Y)=>{for(let Q of Y){let K=P1(Q),q=Z,N=q+K;if(Z=N,J<=q||M>=N)continue;if(Q.type==="text"){let U=Math.max(M,q);if(Math.min(J,N)>U)X=X===null?new Set(Q.marks):new Set(Q.marks.filter((B)=>X?.has(B)));continue}if(Q.type==="link"){let U=Z;Z=q,A(Q.children),Z=U}}};return A($.children),X?[...X]:[]}function nA($,M,J,Z){let X=0,A=!1,Y=!0,Q=(K)=>{for(let q of K){let N=P1(q),U=X,G=U+N;if(X=G,J<=U||M>=G)continue;if(q.type==="text"){let B=Math.max(M,U);if(Math.min(J,G)>B)A=!0,Y&&=q.marks.includes(Z);continue}if(q.type==="link"){let B=X;X=U,Q(q.children),X=B}}};return Q($),A?Y:null}function j3($,M,J,Z,X,A){let Y=[],Q=0;for(let[K,q]of $.entries()){let N=Q,U=P1(q),G=N+U,B=`${A}.${K}`;if(Q=G,J<=N||M>=G){Y.push(q);continue}if(q.type==="text"){Y.push(...tA(q,Math.max(0,M-N),Math.min(U,J-N),Z,X,B));continue}if(q.type==="link"){let D=U1(j3(q.children,Math.max(0,M-N),Math.min(U,J-N),Z,X,`${B}.children`));if(D.length>0)Y.push({...q,children:D});continue}Y.push(q)}return Y}function tA($,M,J,Z,X,A){let Y=$.text.slice(0,M),Q=$.text.slice(M,J),K=$.text.slice(J),q=X?$.marks.filter((N)=>N!==Z):eA($.marks,Z);return[b0(Y,$.marks,`${A}.before`),b0(Q,q,`${A}.selected`),b0(K,$.marks,`${A}.after`)].filter(Boolean)}function eA($,M){return $.includes(M)?$:[...$,M].sort()}function F8($,M,J){let Z=U1($Y($.children,M,J,`${$.path}.children`));return Z.length>0?U0($,Z,M,J):null}function $Y($,M,J,Z){let X=L3($,M,J);if(X)return R3($,M,J,X.code,Z,!1);let A=N8($,M,J);if(A.length===0)return $;return R3($,M,J,A,Z,!0)}function L3($,M,J){let Z=0;for(let X of $){let A=P1(X),Y=Z,Q=Y+A;if(Z=Q,M===Y&&J===Q&&X.type==="inlineCode")return X;if(X.type==="link"){let K=L3(X.children,Math.max(0,M-Y),Math.min(A,J-Y));if(K)return K}}return null}function R3($,M,J,Z,X,A){let Y=[],Q=0,K=!1;for(let[q,N]of $.entries()){let U=`${X}.${q}`,G=P1(N),B=Q,D=B+G;if(Q=D,J<=B||M>=D){Y.push(N);continue}if(!K){Y.push(...G5(N,Math.max(0,M-B),U));let F=A?U8(Z,`${X}.selected`):b0(Z,[],`${X}.selected`);if(F)Y.push(F);K=!0}Y.push(...B5(N,Math.min(G,J-B),U))}return Y}function F5($,M,J,Z,X){return m2($,M,J,Z,(A,Y,Q)=>k3(A,Y,Q,X))}function k3($,M,J,Z){let X=U1(MY($.children,M,J,Z,`${$.path}.children`)??[]);return X.length>0?U0($,X,M,J):null}function MY($,M,J,Z,X){let A=[],Y=0,Q=!1;for(let[K,q]of $.entries()){let N=`${X}.${K}`,U=P1(q),G=Y,B=G+U;if(Y=B,!Q&&q.type==="link"&&M===G&&J===B){if(Z===null)A.push(...q.children);else A.push(m0({children:q.children,path:N,title:q.title,url:Z}));Q=!0;continue}A.push(q)}return Q?A:null}function D8($,M,J){let Z=U1(JY($.children,M,J,`${$.path}.children`));return U0($,Z,M+1,M+1)}function JY($,M,J,Z){let X=[],A=0,Y=!1;for(let[Q,K]of $.entries()){let q=`${Z}.${Q}`,N=P1(K),U=A,G=U+N;if(A=G,J<=U||M>=G){X.push(K);continue}if(!Y)X.push(...G5(K,Math.max(0,M-U),q)),X.push(H2({path:`${Z}.selected`})),Y=!0;X.push(...B5(K,Math.min(N,J-U),q))}if(!Y)X.push(H2({path:`${Z}.selected`}));return X}function X1($,M,J=0){return{childIndices:M,kind:"descendant-primary-region",offset:J,rootIndex:$}}function M1($,M=0){return{kind:"root-primary-region",offset:M,rootIndex:$}}function G0($,M,J,Z=0){return{cellIndex:J,kind:"table-cell",offset:Z,rootIndex:$,rowIndex:M}}function J0($,M){return $.regionIndex.get(M)??null}function t0($,M){return $.regionPathIndex.get(M)??null}function M2($,M,J,Z){let X=$.tableCellRegionIndex.get(k2(M,J,Z));return X?$.regionIndex.get(X)??null:null}function H8($){return $.anchor.regionId===$.focus.regionId&&$.anchor.offset===$.focus.offset}function n($,M){let J="documentIndex"in $?$.documentIndex:$,Z="documentIndex"in $?$.selection:M,X=f3(J,Z.anchor),A=f3(J,Z.focus);if(X<=A)return{end:Z.focus,start:Z.anchor};return{end:Z.anchor,start:Z.focus}}function v2($,M){if(!M)return null;if("kind"in M){if(M.kind==="root-primary-region"){let Z=$.document.blocks[M.rootIndex],X=Z?_8($,Z):null;return X?D5(X.id,_5(X.text,M.offset)):null}if(M.kind==="descendant-primary-region"){let Z=$.document.blocks[M.rootIndex],X=Z?ZY(Z,M.childIndices):null,A=X?_8($,X):null;return A?D5(A.id,_5(A.text,M.offset)):null}if(M.kind==="table-cell"){let Z=$.document.blocks[M.rootIndex];if(!Z||Z.type!=="table")return null;let X=M2($,Z.id,M.rowIndex,M.cellIndex);return X?D5(X.id,_5(X.text,M.offset)):null}let J=t0($,M.path);if(!J)return null;if(M.kind==="region-path")return D5(J.id,_5(J.text,M.offset));return{anchor:{regionId:J.id,offset:Math.max(0,Math.min(M.startOffset,J.text.length))},focus:{regionId:J.id,offset:Math.max(0,Math.min(M.endOffset,J.text.length))}}}return M}function f3($,M){let J=$.regionOrderIndex.get(M.regionId);if(J===void 0)throw Error(`Unknown canvas region: ${M.regionId}`);return J*O3+M.offset}function D5($,M){let J={offset:M,regionId:$};return{anchor:J,focus:J}}function _5($,M){return M==="end"?$.length:Math.max(0,Math.min(M,$.length))}function ZY($,M){let J=$;for(let Z of M){if(!J)return null;let X=u3(J);if(!X)return null;J=X[Z]??null}return J}function _8($,M){let J=$.blockIndex.get(M.id);if(!J)return null;let Z=J.regionIds[0];if(Z)return $.regionIndex.get(Z)??null;let X=u3(M);if(!X)return null;for(let A of X){let Y=_8($,A);if(Y)return Y}return null}function u3($){switch($.type){case"list":return $.items;case"blockquote":case"listItem":return $.children;default:return null}}function g2($){let M=$.documentIndex.regionIndex.get($.selection.anchor.regionId)??null,J=M?$.documentIndex.blockIndex.get(M.blockId)??null:null,Z=$.selection.anchor.offset,X=M?.inlines.find((A)=>Z>A.start&&Z<A.end)??M?.inlines.find((A)=>A.end===Z)??M?.inlines.find((A)=>A.start===Z)??null;return{block:J?{blockId:J.id,depth:J.depth,nodeType:J.type,text:M?.text??""}:null,span:X?.link?{kind:"link",url:X.link.url}:X&&X.marks.length>0?{kind:"marks",marks:X.marks}:{kind:"none"}}}function H5($){let M=n($.documentIndex,$.selection);if(M.start.regionId!==M.end.regionId||M.start.offset===M.end.offset)return[];let J=$.documentIndex.regionIndex.get(M.start.regionId);if(!J)return[];let Z=l0($.documentIndex.document.blocks,J.blockId);if(!Z)return[];let X=U5(Z,J.path,J.semanticRegionId);return X?B8(X,M.start.offset,M.end.offset):[]}function P5($,M,J,Z=null){return J2($,M,1,[J],Z)}function J2($,M,J,Z,X=null){return{document:I0($.document,M,J,Z),selection:X}}function W5($,M,J,Z=null){return h2($,M,()=>J,Z)}function h2($,M,J,Z=null){let X=$.blockIndex.get(M);if(!X)return null;let A=$.document.blocks[X.rootIndex];if(!A)return null;let Y=S3(A,M,J);return Y?J2($,X.rootIndex,1,[Y],Z):null}function S3($,M,J){if($.id===M)return J($);switch($.type){case"blockquote":{let Z=P8($.children,M,J);return Z?T1({children:Z}):null}case"listItem":{let Z=P8($.children,M,J);return Z?b1($,Z):null}case"list":{let Z=P8($.items,M,J);return Z?$1($,Z):null}default:return null}}function P8($,M,J){let Z=!1,X=$.map((A)=>{let Y=S3(A,M,J);if(!Y)return A;return Z=!0,Y});return Z?X:null}function y5($,M,J){let Z=n($,M);if(Z.start.regionId===Z.end.regionId)return XY($,Z,J);return KY($,Z,J)}function XY($,M,J){let Z=J0($,M.start.regionId);if(!Z)throw Error(`Unknown region: ${M.start.regionId}`);let X=h2($,Z.blockId,(q)=>AY(q,Z,M.start.offset,M.end.offset,J));if(!X)throw Error(`Failed to replace block for canvas region: ${Z.id}`);let A=$2($,X.document,Z.rootIndex,1),Y=$.document.comments.length===0?A:l3($,A,Z,M.start.offset,M.end.offset,J),Q=t0(Y,Z.path);if(!Q)throw Error(`Failed to remap region after replacement: ${Z.path}`);let K=M.start.offset+J.length;return{documentIndex:Y,selection:r3(Q.id,K)}}function AY($,M,J,Z,X){switch($.type){case"heading":case"paragraph":return YY($,M,J,Z,X);case"code":return c4($,m3(M,J,Z,X));case"table":return QY($,M,J,Z,X);case"unsupported":return x4($,m3(M,J,Z,X));default:throw Error(`Canvas text replacement is not supported for block type: ${$.type}`)}}function YY($,M,J,Z,X){let A=p2(M.inlines,J,Z,X),Y=V5(A);return k1($,Y)}function QY($,M,J,Z,X){let A=M.tableCellPosition?.rowIndex,Y=M.tableCellPosition?.cellIndex;if(A===void 0||Y===void 0)throw Error(`Unable to resolve table cell position for region: ${M.id}`);let Q=p2(M.inlines,J,Z,X),K=V5(Q),q=$.rows.map((N,U)=>{if(U!==A)return N;let G=N.cells.map((B,D)=>{if(D!==Y)return B;return X0({children:K})});return{...N,cells:G}});return r1($,q)}function m3($,M,J,Z){return p2($.inlines,M,J,Z).map((X)=>X.text).join("")}function I2($){return $!==null&&($.type==="heading"||$.type==="paragraph")}function KY($,M,J){let Z=J0($,M.start.regionId),X=J0($,M.end.regionId);if(!Z||!X)throw Error("Unknown cross-region selection endpoints.");let A=$.document.blocks[Z.rootIndex],Y=$.document.blocks[X.rootIndex];if(!A||!Y)throw Error("Unknown root blocks for cross-region selection.");let Q=h3(A,Z,M.start.offset),K=I3(Y,X,M.end.offset),q=qY(Q,K,J),N=q.blocks.length>0?q.blocks:[I({text:""})],U=Z.rootIndex,G=X.rootIndex-Z.rootIndex+1,B=I0($.document,U,G,N),D=$2($,B,U,G),F=$.document.comments.length===0?D:l3($,D,Z,M.start.offset,Z.text.length,I2(Q)?J:""),H=F.roots[U+q.caretLocalIndex]?.regions[0]??null;return{documentIndex:F,selection:r3(H?.id??Z.id,H?q.caretOffset:0)}}function qY($,M,J){if(I2($)&&I2(M))return{blocks:[NY($,M,J)],caretLocalIndex:0,caretOffset:$.plainText.length+J.length};if(I2($)){let A=[J.length>0?UY($,J):$];if(M)A.push(M);return{blocks:A,caretLocalIndex:0,caretOffset:$.plainText.length+J.length}}if(I2(M)){let X=J.length>0?GY(M,J):M,A=[];if($)A.push($);let Y=A.length;return A.push(X),{blocks:A,caretLocalIndex:Y,caretOffset:J.length}}let Z=[];if($)Z.push($);if(J.length>0){let X=Z.length;if(Z.push(I({text:J})),M)Z.push(M);return{blocks:Z,caretLocalIndex:X,caretOffset:J.length}}if(M){let X=Z.length;return Z.push(M),{blocks:Z,caretLocalIndex:X,caretOffset:0}}return{blocks:Z,caretLocalIndex:0,caretOffset:0}}function NY($,M,J){let Z=J.length>0?[W1({text:J})]:[];return k1($,U1([...$.children,...Z,...M.children]))}function UY($,M){return k1($,U1([...$.children,W1({text:M})]))}function GY($,M){return k1($,U1([W1({text:M}),...$.children]))}function h3($,M,J){if($.type==="table")return null;if($.id===M.blockId)return BY($,M,J);return p3($,(Z)=>DY(Z,M,J))}function I3($,M,J){if($.type==="table")return null;if($.id===M.blockId)return FY($,M,J);return p3($,(Z)=>_Y(Z,M,J))}function BY($,M,J){if(J===0)return null;switch($.type){case"heading":case"paragraph":{let Z=p2(M.inlines,J,M.text.length,"");return k1($,V5(Z))}case"code":return c4($,M.text.slice(0,J));case"unsupported":return x4($,M.text.slice(0,J));default:return null}}function FY($,M,J){if(J===M.text.length)return null;switch($.type){case"heading":case"paragraph":{let Z=p2(M.inlines,0,J,"");return k1($,V5(Z))}case"code":return c4($,M.text.slice(J));case"unsupported":return x4($,M.text.slice(J));default:return null}}function p3($,M){switch($.type){case"blockquote":{let J=M($.children);return J.length===0?null:T1({children:J})}case"list":{let J=M($.items);return J.length===0?null:$1($,J)}case"listItem":{let J=M($.children);return J.length===0?null:b1($,J)}default:return null}}function DY($,M,J){let Z=$.findIndex((Y)=>T5(Y,M));if(Z===-1)return[];let X=$.slice(0,Z),A=h3($[Z],M,J);return A?[...X,A]:X}function _Y($,M,J){let Z=$.findIndex((Y)=>T5(Y,M));if(Z===-1)return[];let X=$.slice(Z+1),A=I3($[Z],M,J);return A?[A,...X]:X}function T5($,M){if($.id===M.blockId)return!0;switch($.type){case"blockquote":case"listItem":return $.children.some((J)=>T5(J,M));case"list":return $.items.some((J)=>T5(J,M));default:return!1}}function l3($,M,J,Z,X,A){let Y=A8($,M,J,Z,X,A);return Y===M.document.comments?M:S2(M,{...M.document,comments:Y})}function r3($,M){return{anchor:{regionId:$,offset:M},focus:{regionId:$,offset:M}}}function p2($,M,J,Z){let A=HY($,M,J,{didInsert:!1,generatedRunCount:0,replacementText:Z});return VY(zY(A))}function V5($){let M=[];for(let J=0;J<$.length;J+=1){let Z=$[J];if(Z.link){let A=[],Y=Z.link;while(J<$.length&&T8($[J].link,Y)){let Q=g3($[J]);if(Q)A.push(Q);J+=1}if(J-=1,A.length>0)M.push(m0({children:U1(A),title:Y.title,url:Y.url}));continue}let X=g3(Z);if(X)M.push(X)}return U1(M)}function HY($,M,J,Z){let X=[];for(let[A,Y]of $.entries()){if(!Z.didInsert&&M===J&&M===Y.start)W8(X,Z,v3($[A-1]??null,Y));if(J<=Y.start||M>=Y.end){X.push(z5(Y));continue}let Q=Math.max(0,M-Y.start),K=Math.min(Y.text.length,J-Y.start),q=!Z.didInsert&&Z.replacementText.length>0?Z.replacementText:"",N=PY(Y,Q,K,q,Z);if(Q!==K||q.length>0)Z.didInsert=!0;X.push(...N)}if(!Z.didInsert)W8(X,Z,v3($.at(-1)??null,null));return X}function PY($,M,J,Z,X){switch($.kind){case"text":case"inlineCode":case"unsupported":return WY($,M,J,Z);case"break":return TY($,M,J,Z,X);case"image":return yY($,M,J,Z)}}function WY($,M,J,Z){let X=$.text.slice(0,M)+Z+$.text.slice(J);return X.length>0?[{...z5($),text:X}]:[]}function TY($,M,J,Z,X){if(M===J)return[z5($)];let A=[];if(Z.length>0)W8(A,X,$.link);return A}function yY($,M,J,Z){if(M===0&&J===$.text.length)return Z.length>0?[c3(Z,$.link,0)]:[];return[z5($)]}function W8($,M,J){if(M.replacementText.length===0){M.didInsert=!0;return}$.push(c3(M.replacementText,J,M.generatedRunCount)),M.generatedRunCount+=1,M.didInsert=!0}function c3($,M,J){return{id:`generated:${J}`,image:null,inlineCode:!1,kind:"text",link:M,marks:[],originalType:null,text:$}}function v3($,M){return $?.link&&M?.link&&T8($.link,M.link)?$.link:null}function z5($){return{id:$.id,image:$.image,inlineCode:$.inlineCode,kind:$.kind,link:$.link,marks:$.marks,originalType:$.originalType,text:$.text}}function VY($){let M=[],J=0;for(let Z of $){let X=J,A=X+Z.text.length;M.push({...Z,end:A,start:X}),J=A}return M}function zY($){let M=[];for(let J of $){let Z=M.at(-1);if(Z&&OY(Z,J)){M[M.length-1]={...Z,text:Z.text+J.text};continue}M.push(J)}return M}function OY($,M){return $.kind===M.kind&&$.inlineCode===M.inlineCode&&T8($.link,M.link)&&CY($.image,M.image)&&$.originalType===M.originalType&&$.marks.join(",")===M.marks.join(",")}function g3($){switch($.kind){case"break":return H2();case"image":return $.image?bY($.image):null;case"inlineCode":return S0({code:$.text});case"text":return $.text.length>0?W1({marks:$.marks,text:$.text}):null;case"unsupported":return p4({originalType:$.originalType??"unsupported",source:$.text})}}function bY($){return I4({alt:$.alt,title:$.title,url:$.url,width:$.width})}function T8($,M){return $?.url===M?.url&&$?.title===M?.title}function CY($,M){return $?.url===M?.url&&$?.title===M?.title&&$?.alt===M?.alt&&$?.width===M?.width}function x3($,M){switch(M.kind){case"replace-block":return W5($,M.blockId,M.block,M.selection??null);case"replace-root":return P5($,M.rootIndex,M.block,M.selection??null);case"replace-root-range":return J2($,M.rootIndex,M.count,M.replacements,M.selection??null);case"replace-selection":{let J=y5($,M.selection,M.text);return{document:J.documentIndex.document,documentIndex:J.documentIndex,selection:J.selection}}}return null}var y8=new Map([["rgba(0, 0, 0, 0)",[0,0,0,0]]]);function l2($){switch($.kind){case"active-block-flash":return 300;case"deleted-text-fade":return 180;case"inserted-text-highlight":return 1000;case"list-marker-pop":return 500;case"punctuation-pulse":return 140}}function z8($,M){let J=M??wY();return $.animations.some((Z)=>J-Z.startedAt<l2(Z))}function a3($,M){return O8($,M,"inserted-text-highlight",(J)=>J.regionPath)}function s3($,M){return X9($,M,"active-block-flash",(J)=>J.blockPath)}function i3($,M){return O8($,M,"deleted-text-fade",(J)=>J.regionPath)}function o3($,M){return O8($,M,"punctuation-pulse",(J)=>J.regionPath)}function n3($,M){return X9($,M,"list-marker-pop",(J)=>J.blockPath)}function t3($,M,J){let Z=new Set([$,M]);for(let X of J){if(X.endOffset<=$||X.startOffset>=M)continue;Z.add(Math.max($,X.startOffset)),Z.add(Math.min(M,X.endOffset))}return[...Z].sort((X,A)=>X-A)}function e3($,M,J){return $.find((Z)=>Z.startOffset<J&&Z.endOffset>M)??null}function $9($,M,J){if(!M)return $;return c2(J.insertHighlightText,$,M.progress)}function M9($,M){return c2($,"rgba(0, 0, 0, 0)",M.progress)}function b5($,M){return c2($,"rgba(0, 0, 0, 0)",M.progress)}function J9($,M){return c2(M.insertHighlightText,"rgba(0, 0, 0, 0)",$.progress)}function Z9($){let M=Math.min(1,$.progress*2);return 0.1+0.9*EY(M)}function r2($,M,J){let Z=Math.max(0,M.progress*2-1);return c2(J.insertHighlightText,$,Z)}function O8($,M,J,Z){let X=new Map;for(let A of $.animations){if(A.kind!==J)continue;let Y=l2(A),Q=M-A.startedAt;if(Q>=Y)continue;let K={...A,progress:Math.max(0,Math.min(1,Q/Y))},q=Z(A),N=X.get(q);if(N)N.push(K);else X.set(q,[K])}return X}function X9($,M,J,Z){let X=new Map;for(let A of $.animations){if(A.kind!==J)continue;let Y=l2(A),Q=M-A.startedAt;if(Q>=Y)continue;X.set(Z(A),{...A,progress:Math.max(0,Math.min(1,Q/Y))})}return X}function EY($){return 1-(1-$)*(1-$)*(1-$)}function c2($,M,J){let Z=d3($),X=d3(M);return`rgba(${V8(O5(Z[0],X[0],J))}, ${V8(O5(Z[1],X[1],J))}, ${V8(O5(Z[2],X[2],J))}, ${O5(Z[3],X[3],J)})`}function wY(){return typeof performance<"u"?performance.now():Date.now()}function d3($){let M=y8.get($);if(M)return M;let J=jY($)??RY($)??LY($)??y8.get("rgba(0, 0, 0, 0)");return y8.set($,J),J}function jY($){let M=$.trim();if(!M.startsWith("#"))return null;let J=M.slice(1);if(J.length===3)return[Number.parseInt(`${J[0]}${J[0]}`,16),Number.parseInt(`${J[1]}${J[1]}`,16),Number.parseInt(`${J[2]}${J[2]}`,16),1];if(J.length===6)return[Number.parseInt(J.slice(0,2),16),Number.parseInt(J.slice(2,4),16),Number.parseInt(J.slice(4,6),16),1];return null}function RY($){let M=/^rgb\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec($.trim());if(!M)return null;return[Number(M[1]),Number(M[2]),Number(M[3]),1]}function LY($){let M=/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec($.trim());if(!M)return null;return[Number(M[1]),Number(M[2]),Number(M[3]),Number(M[4])]}function O5($,M,J){return $+(M-$)*J}function V8($){return Math.round($)}function C5($,M,J=B0()){if(M<=0)return $;let Z=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!Z)return $;let X=$.selection.focus.offset,A=Math.max(0,X-M);if(X<=A)return $;return x2($,{endOffset:X,kind:"inserted-text-highlight",regionPath:Z.path,startOffset:A,startedAt:J})}function b8($,M,J=B0()){if(M.text.length===0)return $;return x2($,{kind:"deleted-text-fade",regionPath:M.regionPath,startOffset:M.startOffset,startedAt:J,text:M.text})}function C8($,M,J=B0()){return x2($,{blockPath:M,kind:"active-block-flash",startedAt:J})}function E8($,M=B0()){let J=$.documentIndex.regionIndex.get($.selection.focus.regionId),Z=$.selection.focus.offset-1;if(!J||Z<0||J.text[Z]!==".")return $;return x2($,{kind:"punctuation-pulse",offset:Z,regionPath:J.path,startedAt:M})}function w8($,M,J=B0()){return x2($,{blockPath:M,kind:"list-marker-pop",startedAt:J})}function x2($,M){let J=E5($.animations,M.startedAt);return{...$,animations:[...J,M]}}function E5($,M){return $.filter((J)=>J.startedAt+l2(J)>M)}function B0(){return typeof performance<"u"?performance.now():Date.now()}function A9($){let M=$.documentIndex.regionIndex.get($.selection.focus.regionId);return(M?$.documentIndex.blockIndex.get(M.blockId)??null:null)?.path??""}function w5($,M){let J=Math.max(-1/0,...$.animations.map((Z)=>Z.startedAt));return M.animations.some((Z)=>Z.startedAt>J)}function d2($){let M=e0($),J=Q9(M);return{animations:[],documentIndex:M,future:[],history:[],selection:{anchor:J,focus:J}}}function a2($){let M=f1($.documentIndex);return h0(P2($.documentIndex.document.blocks),M.threads)}function a($,M){if(!M)return null;switch(M.kind){case"keep-state":return $;case"set-selection":return K1($,M.selection);default:{let J=x3($.documentIndex,M);if(!J)return null;let Z=kY($,J.document,J.documentIndex??null),X=v2(Z.documentIndex,J.selection)??$.selection,A=K9($,Z,X);return K1(Z,X,A)}}}function K1($,M,J){let Z="regionId"in M?{anchor:j5($.documentIndex,M),focus:j5($.documentIndex,M)}:{anchor:j5($.documentIndex,M.anchor),focus:j5($.documentIndex,M.focus)},X={...$,selection:Z};return J??K9($,X)?C8(X,A9(X)):X}function E1($,M,J,Z){let X={regionId:M,offset:J};return K1($,Z?{anchor:$.selection.anchor,focus:X}:X)}function kY($,M,J=null){let Z=J??e0(M);return{animations:E5($.animations,B0()),documentIndex:Z,future:[],history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:fY(Z)}}function j8($){let M=$.history.at(-1);if(!M)return $;let J=e0(M.document);return{animations:[],documentIndex:J,future:[{document:$.documentIndex.document,selection:$.selection},...$.future],history:$.history.slice(0,-1),selection:M.selection}}function R8($){let M=$.future[0];if(!M)return $;let J=e0(M.document);return{animations:[],documentIndex:J,future:$.future.slice(1),history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:M.selection}}function R5($,M,J,Z){let X=UM($.documentIndex.document,M,J,Z),A=S2($.documentIndex,X);return{animations:E5($.animations,B0()),documentIndex:A,future:[],history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:$.selection}}function fY($){let M=Q9($);return{anchor:M,focus:M}}function Q9($){return $.regions[0]?{regionId:$.regions[0].id,offset:0}:{regionId:"empty",offset:0}}function j5($,M){let J=J0($,M.regionId);if(!J)return M;return{regionId:J.id,offset:Math.max(0,Math.min(M.offset,J.text.length))}}function K9($,M,J){let Z=Y9($.documentIndex,$.selection),X=Y9(M.documentIndex,J??M.selection);return X!==null&&X!==Z}function Y9($,M){let J=$.regionIndex.get(M.focus.regionId),Z=J?$.blockIndex.get(J.blockId)??null:null;if(!J||!Z?.path)return null;return Z.type==="table"?`cell:${J.path}`:`block:${Z.path}`}function o2($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return{kind:"unsupported"};if(J.blockType==="code"){let Q=$.blockIndex.get(J.blockId);return Q?{kind:"code",region:J,rootIndex:Q.rootIndex}:{kind:"unsupported"}}let Z=F0($,J.id);if(Z)return{kind:"tableCell",...Z};let X=s1($,M);if(X)return{kind:"listItem",...X};let A=Z2($,M);if(A)return{kind:"blockquoteTextBlock",...A};let Y=a1($,M);if(Y)return{kind:"rootTextBlock",...Y};return{kind:"unsupported"}}function n2($,M){let J=$.blockIndex.get(M);if(!J)throw Error(`Unknown root block: ${M}`);return J.rootIndex}function L5($,M,J){let Z=M?$.blockIndex.get(M)??null:null;while(Z){if(Z.type===J)return Z;let X=Z.parentBlockId;Z=X?$.blockIndex.get(X)??null:null}return null}function s2($){let M=$.split("."),J=[];for(let Z=0;Z<M.length-1;Z+=1)if(M[Z]==="children"){let X=Number(M[Z+1]);if(Number.isInteger(X))J.push(X)}return J}function a1($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId);if(!Z)return null;let X=Z.rootIndex,A=$.document.blocks[X];if(!A||A.type!=="heading"&&A.type!=="paragraph")return null;return{block:A,region:J,rootIndex:X}}function q9($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=L5($,Z?.id??null,"blockquote");if(!X)return null;let A=X.rootIndex,Y=$.document.blocks[A];return Y?.type==="blockquote"?{quote:Y,rootIndex:A}:null}function Z2($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=L5($,Z?.id??null,"blockquote");if(!Z||!X||Z.parentBlockId!==X.id)return null;let A=X.rootIndex,Y=$.document.blocks[A];if(!Y||Y.type!=="blockquote")return null;let Q=Y.children.findIndex((q)=>q.id===Z.id),K=Y.children[Q];if(!K||K.type!=="heading"&&K.type!=="paragraph")return null;return{block:K,blockChildIndices:s2(Z.path),childIndex:Q,region:J,quote:Y,rootIndex:A}}function i2($,M){return l0($.document.blocks,M)}function s1($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=L5($,Z?.id??null,"listItem"),A=L5($,Z?.id??null,"list");if(!Z||!X||!A)return null;let Y=i2($,A.id);if(!Y||Y.type!=="list")return null;let Q=Y.items.findIndex((D)=>D.id===X.id),K=Y.items[Q];if(!K)return null;let q=A.parentBlockId?$.blockIndex.get(A.parentBlockId)??null:null,N=q?.parentBlockId?$.blockIndex.get(q.parentBlockId)??null:null,U=q?.type==="listItem"?i2($,q.id):null,G=N?.type==="list"?i2($,N.id):null,B=G?.type==="list"&&U?G.items.findIndex((D)=>D.id===U.id):-1;return{region:J,item:K,itemChildIndices:s2(X.path),itemIndex:Q,list:Y,listChildIndices:s2(A.path),parentItem:U?.type==="listItem"?U:null,parentItemChildIndices:q?.type==="listItem"?s2(q.path):null,parentItemIndex:B>=0?B:null,parentList:G?.type==="list"?G:null,parentListChildIndices:N?.type==="list"?s2(N.path):null,rootIndex:A.rootIndex}}function F0($,M){let J=$.regionIndex.get(M);if(!J)return null;let Z=$.tableCellIndex.get(J.id),X=$.blockIndex.get(J.blockId),A=X?.type==="table"?$.document.blocks[X.rootIndex]:null;if(!Z||!X||!A||A.type!=="table")return null;return{cellIndex:Z.cellIndex,rootIndex:X.rootIndex,rowIndex:Z.rowIndex,table:A}}function t2($,M,J){return n1({checked:M,children:[I({text:$})],spread:J})}function X2($,M){let J=$.children[0];if(!J||J.type!=="paragraph")return null;return b1($,[I({text:M}),...$.children.slice(1)])}function N9($,M){return M.reduce((J,Z)=>`${J}.children.${Z}`,`root.${$}`)}function U9($,M,J){let Z=$.regionIndex.get(M.anchor.regionId);if(!Z)return null;let X=n($,M),A=X.start.regionId===X.end.regionId&&X.start.regionId===Z.id?Z.text.slice(0,X.start.offset)+J+Z.text.slice(X.end.offset):J;return uY($,M,Z.id,A)??mY($,M,Z.id,A)??SY($,M,Z.id,A)??vY($,M,Z.id,A)??IY($,Z.blockId,Z.rootIndex,A)??{kind:"replace-selection",selection:M,text:J}}function uY($,M,J,Z){let X=s1($,M),A=rY(Z);if(!X||!A||X.region.id!==J)return null;let Y=X2(X.item,A.text);if(!Y)return null;return{kind:"replace-block",block:$1(X.list,X.list.items.map((Q,K)=>K===X.itemIndex?Y:Q),{ordered:A.ordered,start:A.ordered?1:null}),blockId:X.list.id,selection:X1(X.rootIndex,[...X.listChildIndices,X.itemIndex,0])}}function SY($,M,J,Z){if(!k8($,M,J))return null;if(/^\s*([-+*])\s\[( |x|X)\]\s$/.exec(Z)){let Y=Z.toLowerCase().includes("[x]");return L8($,M,{checked:Y,ordered:!1,start:null})}if(/^\s*[-+*]\s$/.test(Z))return L8($,M,{checked:null,ordered:!1,start:null});let A=/^\s*(\d+)\.\s$/.exec(Z);if(A)return L8($,M,{checked:null,ordered:!0,start:Number(A[1])});return null}function mY($,M,J,Z){let X=a1($,M),A=cY(Z);if(!X||X.region.id!==J||X.block.type!=="heading"||!A)return null;return{kind:"replace-root",block:Z0({depth:A.depth,text:A.text}),rootIndex:X.rootIndex,selection:M1(X.rootIndex)}}function vY($,M,J,Z){return gY($,M,J,Z)??hY($,M,J,Z)}function gY($,M,J,Z){if(!k8($,M,J))return null;let X=/^(#{1,6})\s$/.exec(Z);if(!X)return null;return pY($,M,X[1].length)}function hY($,M,J,Z){if(!k8($,M,J)||!/^>\s$/.test(Z))return null;return lY($,M)}function IY($,M,J,Z){if(!/^(?:(?:-\s?){3}|(?:\*\s?){3}|(?:_\s?){3})$/.test(Z))return null;return{kind:"replace-root-range",count:1,replacements:[l4(),I({text:""})],rootIndex:n2($,M),selection:M1(J+1)}}function L8($,M,J){let Z=n2($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:y0({items:[n1({checked:J.checked,children:[I({text:""})],spread:!1})],ordered:J.ordered,spread:!1,start:J.start}),rootIndex:Z,selection:X1(Z,[0,0])}}function pY($,M,J){let Z=n2($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:Z0({depth:J,text:""}),rootIndex:Z,selection:M1(Z)}}function lY($,M){let J=n2($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:T1({children:[I({text:""})]}),rootIndex:J,selection:X1(J,[0])}}function k8($,M,J){let Z=a1($,M);return Z?.region.id===J&&Z.block.type==="paragraph"}function rY($){let M=/^[-+*]\s(.+)$/.exec($);if(M)return{ordered:!1,text:M[1]};let J=/^\d+\.\s(.+)$/.exec($);if(J)return{ordered:!0,text:J[1]};return null}function cY($){let M=/^(#{1,6})\s(.+)$/.exec($);return M?{depth:M[1].length,text:M[2]}:null}function G9($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let Z=s1($,M);if(!Z)return null;let X=Z.region.text,A=Z.item,Y=typeof A.checked==="boolean"?!1:A.checked;if(J.start.offset===0){let U=t2("",Y,A.spread);return{kind:"replace-block",block:$1(Z.list,[...Z.list.items.slice(0,Z.itemIndex),U,A,...Z.list.items.slice(Z.itemIndex+1)]),blockId:Z.list.id,listItemInsertedPath:k5(U,Z.rootIndex,[...Z.listChildIndices,Z.itemIndex]),selection:X1(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex,0])}}if(J.start.offset===X.length){let U=t2("",Y,A.spread);return{kind:"replace-block",block:$1(Z.list,[...Z.list.items.slice(0,Z.itemIndex+1),U,...Z.list.items.slice(Z.itemIndex+1)]),blockId:Z.list.id,listItemInsertedPath:k5(U,Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1]),selection:X1(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1,0])}}let Q=X.slice(0,J.start.offset),K=X.slice(J.start.offset),q=t2(K,Y,A.spread),N=b1(A,[I({text:Q})]);return{kind:"replace-block",block:$1(Z.list,[...Z.list.items.slice(0,Z.itemIndex),N,q,...Z.list.items.slice(Z.itemIndex+1)]),blockId:Z.list.id,listItemInsertedPath:k5(q,Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1]),selection:X1(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1,0])}}function B9($,M){let J=n($,M),Z=s1($,M);if(!Z||J.start.regionId!==J.end.regionId)return null;if(J.start.offset!==0||Z.region.text.length!==0)return G9($,M);if(Z.parentItem&&Z.parentItemIndex!==null&&Z.parentItemChildIndices&&Z.parentList&&Z.parentListChildIndices)return xY(Z);let X=Z.list.items.slice(0,Z.itemIndex),A=Z.list.items.slice(Z.itemIndex+1),Y=[];if(X.length>0)Y.push($1(Z.list,X));if(Y.push(I({text:""})),A.length>0)Y.push($1(Z.list,A));return{kind:"replace-root-range",count:1,replacements:Y,rootIndex:Z.rootIndex,selection:M1(Z.rootIndex+(X.length>0?1:0))}}function F9($,M){let J=s1($,M);if(!J)return null;if(typeof J.item.checked==="boolean"){let Z=n1({checked:null,children:J.item.children,spread:J.item.spread});return{kind:"replace-block",block:$1(J.list,J.list.items.map((X,A)=>A===J.itemIndex?Z:X)),blockId:J.list.id}}if(J.itemIndex>0){let Z=J.list.items[J.itemIndex-1];if(!Z)return null;if(J.item.plainText.length===0)return{kind:"replace-block",block:$1(J.list,J.list.items.filter((A,Y)=>Y!==J.itemIndex)),blockId:J.list.id,selection:X1(J.rootIndex,[...J.listChildIndices,J.itemIndex-1,0],"end")};let X=X2(Z,`${Z.plainText}${J.item.plainText}`);if(!X)return null;return{kind:"replace-block",block:$1(J.list,J.list.items.flatMap((A,Y)=>{if(Y===J.itemIndex-1)return[X];if(Y===J.itemIndex)return[];return[A]})),blockId:J.list.id,selection:X1(J.rootIndex,[...J.listChildIndices,J.itemIndex-1,0],"end")}}return{kind:"replace-root-range",count:1,replacements:[I({text:J.item.plainText})],rootIndex:J.rootIndex,selection:M1(J.rootIndex)}}function D9($,M){let J=s1($,M);if(!J||J.itemIndex===0)return null;let Z=J.list.items[J.itemIndex-1];if(!Z)return null;let X=dY(Z,J.item,J);return{kind:"replace-block",block:$1(J.list,J.list.items.flatMap((A,Y)=>{if(Y===J.itemIndex-1)return[X.item];if(Y===J.itemIndex)return[];return[A]})),blockId:J.list.id,selection:X1(J.rootIndex,X.regionChildIndices)}}function _9($,M){let J=s1($,M);if(!J||!J.parentItem||J.parentItemIndex===null||!J.parentItemChildIndices||!J.parentList||!J.parentListChildIndices)return null;let Z=J.list.items.filter((Y,Q)=>Q!==J.itemIndex),X=J.parentItem.children.flatMap((Y)=>{if(Y.type!=="list"||Y.id!==J.list.id)return[Y];if(Z.length===0)return[];return[$1(J.list,Z)]}),A=b1(J.parentItem,X);return{kind:"replace-block",block:$1(J.parentList,[...J.parentList.items.slice(0,J.parentItemIndex),A,J.item,...J.parentList.items.slice(J.parentItemIndex+1)]),blockId:J.parentList.id,selection:X1(J.rootIndex,[...J.parentListChildIndices,J.parentItemIndex+1,0])}}function f8($,M,J){let Z=s1($,M);if(!Z)return null;let X=Z.itemIndex+J;if(X<0||X>=Z.list.items.length)return null;let A=[...Z.list.items],[Y]=A.splice(Z.itemIndex,1);if(!Y)return null;return A.splice(X,0,Y),{kind:"replace-block",block:$1(Z.list,A),blockId:Z.list.id,selection:X1(Z.rootIndex,[...Z.listChildIndices,X,0])}}function xY($){if(!$.parentItem||$.parentItemIndex===null||!$.parentItemChildIndices||!$.parentList||!$.parentListChildIndices)return null;let M=$.list.items.filter((Y,Q)=>Q!==$.itemIndex),J=$.parentItem.children.flatMap((Y)=>{if(Y.type!=="list"||Y.id!==$.list.id)return[Y];if(M.length===0)return[];return[$1($.list,M)]}),Z=b1($.parentItem,J),X=typeof $.parentItem.checked==="boolean"?!1:$.parentItem.checked,A=t2("",X,$.parentItem.spread);return{kind:"replace-block",block:$1($.parentList,[...$.parentList.items.slice(0,$.parentItemIndex),Z,A,...$.parentList.items.slice($.parentItemIndex+1)]),blockId:$.parentList.id,listItemInsertedPath:k5(A,$.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1]),selection:X1($.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1,0])}}function k5($,M,J){return typeof $.checked==="boolean"?void 0:N9(M,J)}function dY($,M,J){let Z=$.children.findIndex((A)=>A.type==="list"&&A.ordered===J.list.ordered&&A.start===J.list.start);if(Z>=0){let A=$.children[Z];if(!A||A.type!=="list")return{item:$,regionChildIndices:[...J.listChildIndices,J.itemIndex-1,0]};return{item:b1($,$.children.map((Y,Q)=>Q===Z?$1(A,[...A.items,M]):Y)),regionChildIndices:[...J.listChildIndices,J.itemIndex-1,Z,A.items.length,0]}}let X=y0({items:[M],ordered:J.list.ordered,spread:J.list.spread,start:J.list.start});return{item:b1($,[...$.children,X]),regionChildIndices:[...J.listChildIndices,J.itemIndex-1,$.children.length,0,0]}}function f5($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let Z=a1($,M);if(!Z)return aY($,M);let X=Z.region.text.slice(0,J.start.offset),A=Z.region.text.slice(J.start.offset),Y=J.start.offset===0&&Z.region.text.length>0?Z.rootIndex:Z.rootIndex+1;if(Z.block.type==="paragraph")return{kind:"replace-root-range",count:1,replacements:J.start.offset===0?[I({text:""}),Z.block]:J.start.offset===Z.region.text.length?[Z.block,I({text:""})]:[I({text:X}),I({text:A})],rootIndex:Z.rootIndex,selection:M1(Y)};return{kind:"replace-root-range",count:1,replacements:J.start.offset===0?[I({text:""}),Z.block]:J.start.offset===Z.region.text.length?[Z.block,I({text:""})]:[Z0({depth:Z.block.depth,text:X}),I({text:A})],rootIndex:Z.rootIndex,selection:M1(Y)}}function aY($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let Z=Z2($,M);if(!Z)return null;let X=Z.region.text,A=X.slice(0,J.start.offset),Y=X.slice(J.start.offset),Q=Z.block.type==="heading"?eY(Z.block,A,Y,Z.blockChildIndices,J.start.offset,X.length):tY(Z.block,A,Y,Z.blockChildIndices,J.start.offset,X.length);return{kind:"replace-root",block:T1({children:[...Z.quote.children.slice(0,Z.childIndex),...Q.blocks,...Z.quote.children.slice(Z.childIndex+1)]}),rootIndex:Z.rootIndex,selection:X1(Z.rootIndex,Q.focusChildIndices)}}function H9($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;let Z=Z2($,M);if(!Z||Z.region.text.length!==0||Z.block.type!=="paragraph")return null;let X=Z.quote.children.slice(0,Z.childIndex),A=Z.quote.children.slice(Z.childIndex+1),Y=[];if(X.length>0)Y.push(T1({children:X}));if(Y.push(I({text:""})),A.length>0)Y.push(T1({children:A}));return{kind:"replace-root-range",count:1,replacements:Y,rootIndex:Z.rootIndex,selection:M1(Z.rootIndex+(X.length>0?1:0))}}function P9($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.regionId!==M.anchor.regionId)return null;let Z=$.regionIndex.get(J.start.regionId);if(!Z||Z.blockType!=="code")return null;return{kind:"replace-selection",selection:M,text:`
25
- `}}function W9($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;let Z=a1($,M),X=Z?oY(Z):null;if(X)return X;if(Z&&Z.rootIndex>0){let K=$.document.blocks[Z.rootIndex-1],q=$.document.blocks[Z.rootIndex+1];if(K){if(Z.block.plainText.length===0){let N=sY(Z,K,q);if(N)return N;return{kind:"replace-root-range",count:1,replacements:[],rootIndex:Z.rootIndex,selection:K.type==="paragraph"||K.type==="heading"?M1(Z.rootIndex-1,"end"):K.type==="list"?X1(Z.rootIndex-1,[K.items.length-1,0],"end"):K.type==="blockquote"?X1(Z.rootIndex-1,[K.children.length-1],"end"):M1(Z.rootIndex-1,"end")}}if(K.type==="paragraph")return{kind:"replace-root-range",count:2,replacements:[I({text:`${K.plainText}${Z.block.plainText}`})],rootIndex:Z.rootIndex-1,selection:M1(Z.rootIndex-1,"end")};if(K.type==="heading")return{kind:"replace-root-range",count:2,replacements:[Z0({depth:K.depth,text:`${K.plainText}${Z.block.plainText}`})],rootIndex:Z.rootIndex-1,selection:M1(Z.rootIndex-1,"end")};if(K.type==="list"){let N=K.items.length-1,U=K.items[N];if(U){let G=X2(U,`${U.plainText}${Z.block.plainText}`);if(G)return{kind:"replace-root-range",count:2,replacements:[$1(K,K.items.map((B,D)=>D===N?G:B))],rootIndex:Z.rootIndex-1,selection:X1(Z.rootIndex-1,[N,0],"end")}}}}}let A=nY($,M);if(A)return A;let Y=q9($,M);if(!Y)return null;let Q=Z2($,M);return{kind:"replace-root-range",count:1,replacements:Y.quote.children,rootIndex:Y.rootIndex,selection:M1(Q?Y.rootIndex+Q.childIndex:Y.rootIndex)}}function u8($,M,J){let Z=a1($,M);if(!Z||Z.block.type!=="heading")return null;let X=Math.max(1,Math.min(6,Z.block.depth+J));if(X===Z.block.depth)return{kind:"keep-state"};return{kind:"replace-root",block:Z0({depth:X,text:Z.block.plainText}),rootIndex:Z.rootIndex,selection:M1(Z.rootIndex,M.focus.offset)}}function sY($,M,J){if($.block.type!=="paragraph"||$.block.plainText.length!==0||M.type!=="list"||J?.type!=="list"||!iY(M,J))return null;let Z=M.items.length-1;return{kind:"replace-root-range",count:3,replacements:[$1(M,[...M.items,...J.items])],rootIndex:$.rootIndex-1,selection:X1($.rootIndex-1,[Z,0],"end")}}function iY($,M){return $.ordered===M.ordered&&$.start===M.start}function oY($){if($.block.type!=="heading")return null;return{kind:"replace-root",block:I({text:$.block.plainText}),rootIndex:$.rootIndex,selection:M1($.rootIndex)}}function nY($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;let Z=Z2($,M);if(!Z||Z.block.type!=="paragraph"||Z.region.text.length!==0)return null;if(Z.quote.children.length===1)return{kind:"replace-root-range",count:1,replacements:[I({text:""})],rootIndex:Z.rootIndex,selection:M1(Z.rootIndex)};let X=Math.max(0,Z.childIndex-1),A=Z.childIndex>0?"end":0;return{kind:"replace-root",block:T1({children:Z.quote.children.filter((Y,Q)=>Q!==Z.childIndex)}),rootIndex:Z.rootIndex,selection:X1(Z.rootIndex,[X],A)}}function tY($,M,J,Z,X,A){return{blocks:X===0?[I({text:""}),$]:X===A?[$,I({text:""})]:[I({text:M}),I({text:J})],focusChildIndices:X===0?Z:[...Z.slice(0,-1),Z.at(-1)+1]}}function eY($,M,J,Z,X,A){return{blocks:X===0?[I({text:""}),$]:X===A?[$,I({text:""})]:[Z0({depth:$.depth,text:M}),I({text:J})],focusChildIndices:X===0?Z:[...Z.slice(0,-1),Z.at(-1)+1]}}function T9($,M,J){let Z=a1($,M),X=Math.max(2,J);if(!Z||Z.block.type!=="paragraph"||Z.block.plainText.length>0||M.anchor.regionId!==M.focus.regionId||M.anchor.offset!==0||M.focus.offset!==0)return null;return{kind:"replace-root",block:V0({rows:Array.from({length:2},()=>m8(X))}),rootIndex:Z.rootIndex,selection:G0(Z.rootIndex,0,0)}}function S8($,M,J){let Z=F0($,M.focus.regionId);if(!Z)return null;let X=J<0?ZQ(Z.table,Z.rowIndex,Z.cellIndex):XQ(Z.table,Z.rowIndex,Z.cellIndex);if(!X)return J>0&&AQ(Z.table,Z.rowIndex,Z.cellIndex)?$Q(Z):{kind:"keep-state"};let A=Z.table.rows[X.rowIndex]?.cells[X.cellIndex];if(!A)return{kind:"keep-state"};return{kind:"set-selection",selection:JQ($,M,Z.table,X.rowIndex,X.cellIndex,Math.min(M.focus.offset,A.plainText.length))}}function y9($,M){let J=N5($,M.focus.regionId);if(!J||J.kind!=="tableCell")return null;let Z=Math.min(M.anchor.offset,M.focus.offset),X=Math.max(M.anchor.offset,M.focus.offset),A=D8(J,Z,X);return{kind:"replace-block",block:A.block,blockId:A.blockId,selection:A.selection}}function V9($,M,J){let Z=F0($,M.focus.regionId);if(!Z)return null;let X=J==="left"?Z.cellIndex:Z.cellIndex+1;return A2(Z,V0({align:w9(Z.table.align,X,0,[null]),rows:Z.table.rows.map((A)=>v0({cells:MQ(A.cells,X,0,[E9()])}))}),G0(Z.rootIndex,Z.rowIndex,X))}function z9($,M){let J=F0($,M.focus.regionId);if(!J)return null;let Z=Math.max(0,...J.table.rows.map((X)=>X.cells.length));if(Z<=1)return null;return A2(J,V0({align:w9(J.table.align,J.cellIndex,1,[]),rows:J.table.rows.map((X)=>v0({cells:X.cells.filter((A,Y)=>Y!==J.cellIndex)}))}),G0(J.rootIndex,J.rowIndex,Math.min(J.cellIndex,Z-2)))}function O9($,M,J){let Z=F0($,M.focus.regionId);if(!Z)return null;let X=J==="above"?Z.rowIndex:Z.rowIndex+1,A=Math.max(1,...Z.table.rows.map((Y)=>Y.cells.length));return A2(Z,r1(Z.table,[...Z.table.rows.slice(0,X),m8(A),...Z.table.rows.slice(X)]),G0(Z.rootIndex,X,Math.min(Z.cellIndex,A-1)))}function b9($,M){let J=F0($,M.focus.regionId);if(!J||J.table.rows.length<=1)return null;let Z=J.table.rows.filter((Y,Q)=>Q!==J.rowIndex),X=Math.min(J.rowIndex,Z.length-1),A=Z[X]?.cells.length??1;return A2(J,r1(J.table,Z),G0(J.rootIndex,X,Math.min(J.cellIndex,A-1)))}function C9($,M){let J=F0($,M.focus.regionId);if(!J)return null;return A2(J,I({text:""}),M1(J.rootIndex))}function m8($){return v0({cells:Array.from({length:$},()=>E9())})}function E9(){return X0({children:[]})}function $Q($){let M=$.table.rows.length,J=Math.max(1,...$.table.rows.map((Z)=>Z.cells.length));return A2($,r1($.table,[...$.table.rows,m8(J)]),G0($.rootIndex,M,0))}function A2($,M,J){return{kind:"replace-block",block:M,blockId:$.table.id,selection:J}}function MQ($,M,J,Z){return[...$.slice(0,M),...Z,...$.slice(M+J)]}function w9($,M,J,Z){return[...$.slice(0,M),...Z,...$.slice(M+J)]}function JQ($,M,J,Z,X,A){let Y=M2($,J.id,Z,X);if(!Y)return M;return{anchor:{regionId:Y.id,offset:A},focus:{regionId:Y.id,offset:A}}}function ZQ($,M,J){if(J>0)return{cellIndex:J-1,rowIndex:M};if(M>0){let Z=$.rows[M-1];if(!Z||Z.cells.length===0)return null;return{cellIndex:Z.cells.length-1,rowIndex:M-1}}return null}function XQ($,M,J){let Z=$.rows[M];if(!Z)return null;if(J+1<Z.cells.length)return{cellIndex:J+1,rowIndex:M};let X=$.rows[M+1];if(!X||X.cells.length===0)return null;return{cellIndex:0,rowIndex:M+1}}function AQ($,M,J){let Z=$.rows[M];return Boolean(Z&&M===$.rows.length-1&&J===Z.cells.length-1)}function Y2($,M){let J=U9($.documentIndex,$.selection,M),Z=a($,J);if(!Z)return null;if(J?.kind==="replace-selection"&&M.length>0)Z=C5(Z,M.length);if(M===".")Z=E8(Z);return Z}function e2($){switch(o2($.documentIndex,$.selection).kind){case"code":return a($,P9($.documentIndex,$.selection));case"tableCell":return a($,y9($.documentIndex,$.selection));case"listItem":{let J=B9($.documentIndex,$.selection);return KQ({state:a($,J)??a($,f5($.documentIndex,$.selection)),action:J})}case"blockquoteTextBlock":return a($,H9($.documentIndex,$.selection))??a($,f5($.documentIndex,$.selection));case"rootTextBlock":return a($,f5($.documentIndex,$.selection));case"unsupported":return null}}function u5($){if(R9($))return $4($);let M=qQ($);if(M)return M;let J=n($.documentIndex,$.selection);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;switch(o2($.documentIndex,$.selection).kind){case"listItem":return a($,F9($.documentIndex,$.selection));case"blockquoteTextBlock":case"rootTextBlock":return a($,W9($.documentIndex,$.selection));default:return null}}function S5($){if(R9($))return $4($);return NQ($)}function v8($,M){return a($,{kind:"replace-selection",selection:$.selection,text:M})}function m5($,M){let J=v8($,M);return M.length>0?C5(J,M.length):J}function $4($){return v8($,"")}function g8($){let M=$.documentIndex.regions,J=M[0],Z=M.at(-1);if(!J||!Z)return $;return K1($,{anchor:{regionId:J.id,offset:0},focus:{regionId:Z.id,offset:Z.text.length}})}function h8($){switch(o2($.documentIndex,$.selection).kind){case"tableCell":return a($,S8($.documentIndex,$.selection,1));case"rootTextBlock":return a($,u8($.documentIndex,$.selection,1));case"listItem":return YQ($);default:return null}}function I8($){switch(o2($.documentIndex,$.selection).kind){case"tableCell":return a($,S8($.documentIndex,$.selection,-1));case"rootTextBlock":return a($,u8($.documentIndex,$.selection,-1));case"listItem":return QQ($);default:return null}}function YQ($){return a($,D9($.documentIndex,$.selection))}function QQ($){return a($,_9($.documentIndex,$.selection))}function p8($){return a($,f8($.documentIndex,$.selection,-1))}function l8($){return a($,f8($.documentIndex,$.selection,1))}function r8($,M){return a($,T9($.documentIndex,$.selection,M))}function c8($,M){return a($,V9($.documentIndex,$.selection,M))}function x8($){return a($,z9($.documentIndex,$.selection))}function d8($,M){return a($,O9($.documentIndex,$.selection,M))}function a8($){return a($,b9($.documentIndex,$.selection))}function s8($){return a($,C9($.documentIndex,$.selection))}function v5($,M){return j9($,(J,Z,X)=>G8(J,Z,X,M))}function i8($){return j9($,(M,J,Z)=>F8(M,J,Z))}function M4($){return v5($,"bold")}function J4($){return v5($,"italic")}function Z4($){return v5($,"strikethrough")}function X4($){return v5($,"underline")}function o8($,M,J,Z,X){return a($,F5($.documentIndex,M,J,Z,X))}function n8($,M,J,Z){return a($,F5($.documentIndex,M,J,Z,null))}function t8($,M){let J=i2($.documentIndex,M);if(!J||J.type!=="listItem"||typeof J.checked!=="boolean")return null;return a($,{kind:"replace-block",block:{...J,checked:!J.checked},blockId:M})}function g5($){return j8($)}function h5($){return R8($)}function e8($,M,J){let Z=X8($.documentIndex,M,J);if(!Z)return null;return R5($,$.documentIndex.document.comments.length,0,[Z])}function $$($,M,J){return A4($,M,(Z)=>T6(Z,{body:J.trim()}))}function M$($,M,J,Z){return A4($,M,(X)=>y6(X,J,Z))}function J$($,M,J){return A4($,M,(Z)=>V6(Z,J))}function Z$($,M){return A4($,M,()=>null)}function X$($,M,J){return A4($,M,(Z)=>z6(Z,J))}function A4($,M,J){let X=f1($.documentIndex).threads[M];if(!X)return null;let A=J(X);if(A===X)return null;return R5($,M,1,A?[A]:[])}function KQ($){if(!$.state||!$.action||$.action.kind!=="replace-block"||!$.action.listItemInsertedPath)return $.state;return w8($.state,$.action.listItemInsertedPath)}function j9($,M){let J=n($.documentIndex,$.selection);if(J.start.regionId!==J.end.regionId||J.start.offset===J.end.offset)return null;return a($,m2($.documentIndex,J.start.regionId,J.start.offset,J.end.offset,M))}function R9($){let M=n($.documentIndex,$.selection);return M.start.regionId!==M.end.regionId||M.start.offset!==M.end.offset}function qQ($){return L9($,"backward")}function NQ($){return L9($,"forward")}function L9($,M){if($.selection.anchor.regionId!==$.selection.focus.regionId||$.selection.anchor.offset!==$.selection.focus.offset)return null;let J=J0($.documentIndex,$.selection.focus.regionId);if(!J)return null;if(M==="forward"&&$.selection.focus.offset>=J.text.length)return null;let Z=M==="backward"?BQ(J.text,$.selection.focus.offset):$.selection.focus.offset,X=M==="backward"?$.selection.focus.offset:FQ(J.text,$.selection.focus.offset);if(Z===X)return null;let A=v8(K1($,{anchor:{regionId:J.id,offset:Z},focus:{regionId:J.id,offset:X}}),"");return UQ($,A,Z,X)}function UQ($,M,J,Z){let X=GQ($,J,Z);return X?b8(M,X):M}function GQ($,M,J){let Z=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!Z)return null;let X=Z.text.slice(M,J);if(X.length===0)return null;if(!Z.inlines.find((Y)=>Y.start<=M&&Y.end>=J&&Y.kind==="text"&&Y.link===null&&Y.marks.length===0))return null;return{regionPath:Z.path,startOffset:M,text:X}}function BQ($,M){let J=Array.from($.slice(0,M));if(J.length===0)return 0;return M-J.at(-1).length}function FQ($,M){let J=Array.from($.slice(M))[0];return J?M+J.length:$.length}var k9=1;function f9($,M,J){let Z=$.documentIndex.regionOrderIndex.get($.selection.focus.regionId);if(Z===void 0)return $;let X=$.documentIndex.regions[Z],A=$.selection.focus.offset+M;if(A>=0&&A<=X.text.length)return E1($,X.id,A,J);if(M<0){let Q=$.documentIndex.regions[Z-1];if(!Q)return $;return E1($,Q.id,Q.text.length,J)}let Y=$.documentIndex.regions[Z+1];if(!Y)return $;return E1($,Y.id,0,J)}function u9($,M,J,Z,X){let A=C2(M,J.regionId,J.offset);if(!A)return $;let Y=M.lines[A.index+Z];if(!Y)return $;let Q=C1(M,$,{x:d1($,M,J)+k9,y:Y.top+Y.height/2});if(!Q)return $;return E1($,Q.regionId,Q.offset,X)}function S9($,M,J,Z){let X=v9($,M);if(!X)return $;return E1($,X.regionId,J==="Home"?X.start:X.end,Z)}function m9($,M,J,Z,X){let A=v9($,M);if(!A)return $;let Q=Math.max(1,Math.floor(480/M.options.lineHeight)),K=C2(M,A.regionId,$.selection.focus.offset),q=K?M.lines[K.index+Z*Q]:null;if(!q)return $;let N=C1(M,$,{x:d1($,M,J)+k9,y:q.top+q.height/2});if(!N)return $;return E1($,N.regionId,N.offset,X)}function v9($,M){return $0(M,$.selection.focus.regionId,$.selection.focus.offset)}var DQ=1;function g9($,M,J,Z,X){let A=$.documentIndex.regionIndex.get($.selection.focus.regionId)??null;if(!A)return null;let Y=$.documentIndex.tableCellIndex.get(A.id)??null,Q=$.documentIndex.blockIndex.get(A.blockId)??null;if(!Y||Q?.type!=="table")return null;let K=_Q($,Q.id,Y.rowIndex+Z,Y.cellIndex)??HQ($,Q.id,Z);if(!K)return $;let q=M.regionBounds.get(A.id),N=M.regionBounds.get(K.id);if(!q||!N)return $;let U=N.top+PQ(J.top+J.height/2-q.top,0,Math.max(0,N.bottom-N.top-1)),G=C1(M,$,{x:d1($,M,J)+DQ,y:U});if(!G)return $;return E1($,G.regionId,G.offset,X)}function _Q($,M,J,Z){return M2($.documentIndex,M,J,Z)}function HQ($,M,J){let Z=$.documentIndex.blockIndex.get(M),X=$.documentIndex.regions,A=Z?$.documentIndex.roots[Z.rootIndex]?.regionRange:void 0;if(!A)return null;return J<0?X[A.start-1]??null:X[A.end]??null}function PQ($,M,J){return Math.max(M,Math.min(J,$))}function A$($,M,J=!1){return f9($,M,J)}function Y$($,M,J,Z=!1){return WQ($,M,J,Z)}function Q$($,M,J,Z=!1){return TQ($,M,J,Z)}function K$($,M,J,Z=!1){return S9($,M,J,Z)}function q$($,M,J=!1){return yQ($,M,J)}function WQ($,M,J,Z){let X=h9($,M);if(!X)return $;return g9($,M,X,J,Z)??u9($,M,X,J,Z)}function TQ($,M,J,Z){let X=h9($,M);if(!X)return $;return m9($,M,X,J,Z)}function yQ($,M,J){let Z=$.documentIndex.regions,X=M==="start"?Z[0]:Z.at(-1);if(!X)return $;return E1($,X.id,M==="start"?0:X.text.length,J)}function h9($,M){return c1(M,$.documentIndex,{regionId:$.selection.focus.regionId,offset:$.selection.focus.offset})}function p9($,M,J,Z,X,A,Y){let Q=J.image?Z.images.get(J.image.url):null,K=OQ(J,Z,Y),q=bQ(M,A,Y,K);if($.fillStyle=X.imageSurfaceBackground,$.fillRect(q.left,q.top,q.width,q.height),Q?.status==="loaded"&&Q.source)$.drawImage(Q.source,q.left,q.top,q.width,q.height);else VQ($,X,{...q,status:Q?.status==="error"?"error":"loading"});$.strokeStyle=X.imageSurfaceBorder,$.strokeRect(q.left,q.top,q.width,q.height)}function VQ($,M,J){let Z=J.status==="loading"?"Loading image":"Image unavailable",X=CQ(J),A=J.top+J.height/2+X.size*0.9;if($.save(),$.beginPath(),$.rect(J.left,J.top,J.width,J.height),$.clip(),J.status==="loading")zQ($,M,J);$.strokeStyle=M.imagePlaceholderIcon,$.lineWidth=1.5,$.strokeRect(X.left,X.top,X.size,X.size),$.beginPath(),$.arc(X.left+X.size*0.28,X.top+X.size*0.3,X.size*0.1,0,Math.PI*2),$.moveTo(X.left+X.size*0.12,X.top+X.size*0.82),$.lineTo(X.left+X.size*0.42,X.top+X.size*0.5),$.lineTo(X.left+X.size*0.58,X.top+X.size*0.66),$.lineTo(X.left+X.size*0.78,X.top+X.size*0.38),$.lineTo(X.left+X.size*0.88,X.top+X.size*0.82),$.stroke(),$.font='500 12px "Iowan Old Style", "Palatino Linotype", serif',$.fillStyle=M.imagePlaceholderText,$.textAlign="center",$.textBaseline="middle",$.fillText(Z,J.left+J.width/2,A),$.restore()}function zQ($,M,J){let Z=Math.max(48,Math.round(J.width*0.22)),X=J.width+Z*2,A=performance.now()%1800/1800,Y=J.left-Z+X*A,Q=$.createLinearGradient(Y,J.top,Y+Z,J.top);Q.addColorStop(0,"rgba(255,255,255,0)"),Q.addColorStop(0.5,M.imageLoadingOverlay),Q.addColorStop(1,"rgba(255,255,255,0)"),$.fillStyle=Q,$.fillRect(J.left,J.top,J.width,J.height)}function OQ($,M,J){if(!$.image)return I9(J);let Z=M.images.get($.image.url);if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return I9(J);return Math.max(48,Math.round(J*(Z.intrinsicHeight/Z.intrinsicWidth)))}function bQ($,M,J,Z){return{height:Z,left:M,top:$.top+Math.max(0,Math.floor(($.height-Z)/2)),width:J}}function CQ($){let M=Math.max(18,Math.min(34,Math.round(Math.min($.width,$.height)*0.18)));return{left:$.left+Math.max(12,Math.round(($.width-M)/2)),size:M,top:$.top+Math.max(12,Math.round($.height/2-M*0.95))}}function I9($){return Math.max(48,Math.round($*0.5625))}var l9=2,r9=8,EQ=3,wQ=1.5,jQ=2,Q2={elbow:{x:6.5,y:10.5},end:{x:11.5,y:3.5},start:{x:3.5,y:7.5}};function c9($,M,J,Z,X,A,Y=null){if(!J||M.start!==0)return;if(Y){let Q=Z9(Y),K=uQ(J,M,Z,X,$);$.save(),$.translate(K.x,K.y),$.scale(Q,Q),$.translate(-K.x,-K.y)}if(J.kind==="task")RQ($,M,J.checked,A,Y);else if($.fillStyle=Y?r2(A.listMarkerText,Y,A):A.listMarkerText,J.kind==="ordered")fQ($,J.label,Z,X);else $.fillText(J.label,M.left-l9,X);if(Y)$.restore()}function RQ($,M,J,Z,X=null){let A=w2(M);if(LQ($,A,J,Z,X),!J)return;kQ($,A,Z,X)}function LQ($,M,J,Z,X=null){let A=J?Z.checkboxCheckedFill:Z.checkboxUncheckedFill,Y=J?Z.checkboxCheckedStroke:Z.checkboxUncheckedStroke;$.fillStyle=X?r2(A,X,Z):A,$.strokeStyle=X?r2(Y,X,Z):Y,$.beginPath(),$.lineWidth=wQ,$.roundRect(M.left,M.top,M.size,M.size,EQ),$.fill(),$.stroke()}function kQ($,M,J,Z=null){$.strokeStyle=Z?r2(J.checkboxCheckmark,Z,J):J.checkboxCheckmark,$.lineWidth=jQ,$.beginPath(),$.moveTo(M.left+Q2.start.x,M.top+Q2.start.y),$.lineTo(M.left+Q2.elbow.x,M.top+Q2.elbow.y),$.lineTo(M.left+Q2.end.x,M.top+Q2.end.y),$.stroke()}function fQ($,M,J,Z){let X=$.textAlign;$.textAlign="right",$.fillText(M,J-r9,Z),$.textAlign=X}function uQ($,M,J,Z,X){if($.kind==="task"){let Q=w2(M);return{x:Q.left+Q.size/2,y:Q.top+Q.size/2}}let A=X.measureText($.label),Y=Z-(A.actualBoundingBoxAscent-A.actualBoundingBoxDescent)/2;if($.kind==="ordered")return{x:J-r9-A.width/2,y:Y};return{x:M.left-l9+A.width/2,y:Y}}var SQ=80;function d9({context:$,containerBounds:M,isHeaderRow:J,lineHeight:Z,theme:X}){let A=s9(M,Z);$.fillStyle=J?X.tableHeaderBackground:X.tableBodyBackground,$.fillRect(A.left,A.top,A.width,A.height),i9($,A,X)}function a9({activeBlockFlashes:$,activeBlockId:M,activeRegionId:J,context:Z,editorState:X,endIndex:A,layout:Y,regionBounds:Q,startIndex:K,theme:q,verticalBleed:N}){if(!M||!J)return;let U=X.documentIndex.blockIndex.get(M)??null;if(U?.type!=="table")return;if((X.documentIndex.regionIndex.get(J)??null)?.blockId!==M)return;let B=Q.get(J)??null,D=Y.regionLineIndices.get(J)??null;if(!B||!D||D.length===0)return;let F=Y.lines[D[0]]??null;if(!F)return;let H=s9(B,F.height);if(H.width===0)return;let b=x9({context:Z,endIndex:A,fillStyle:q.activeBlockBackground,layout:Y,left:H.left,lineIndices:D,startIndex:K,verticalBleed:N,width:H.width}),E=U.path?$.get(U.path)??null:null;if(E)x9({context:Z,endIndex:A,fillStyle:b5(q.activeBlockFlash,E),layout:Y,left:H.left,lineIndices:D,startIndex:K,verticalBleed:N,width:H.width});if(!b)return;i9(Z,H,q)}function x9({context:$,endIndex:M,fillStyle:J,layout:Z,left:X,lineIndices:A,startIndex:Y,verticalBleed:Q,width:K}){$.fillStyle=J;let q=!1;for(let N of A){if(N<Y)continue;if(N>=M)break;let U=Z.lines[N];$.fillRect(X,U.top-Q,K,U.height),q=!0}return q}function s9($,M){return{height:Math.max($.bottom-$.top,M),left:$.left,top:$.top,width:Math.max($.right-$.left,SQ)}}function i9($,M,J){$.strokeStyle=J.tableBorder,$.strokeRect(M.left,M.top,M.width,M.height)}var N$=2,mQ=3,vQ=12,gQ=6,hQ=3,IQ=1,pQ=2,lQ=2,rQ=8,cQ=12,xQ=28,dQ=4,aQ=5,sQ=2,iQ=3,oQ=6,o9=3,nQ=12,tQ=10,eQ=2,$K=2,MK=1,JK=2,U$=2,n9=1.25,ZK=5,XK=1,t9=4,AK=4,YK=1.5;function QK({activeBlockId:$,activeRegionId:M,activeThreadIndex:J,containerLineBounds:Z,context:X,devicePixelRatio:A,editorState:Y,height:Q,layout:K,liveCommentRanges:q,normalizedSelection:N,now:U=kK(),resources:G,runtimeBlockMap:B,theme:D,viewportTop:F,width:H}){X.save(),X.scale(A,A),X.clearRect(0,0,H,Q),X.fillStyle=D.background,X.fillRect(0,0,H,Q),X.textBaseline="alphabetic",X.translate(0,-F);let b=KK(Y,N),{endIndex:E,startIndex:V}=l6(K,F,Q),R=s3(Y,U),O=i3(Y,U),j=a3(Y,U),f=n3(Y,U),z=o3(Y,U),y=NK(K,Y,$,V,E),T=qK(K,Y,B,V,E,H);for(let W=V;W<E;W+=1){let _=K.lines[W];FK({containerLineBounds:Z,context:X,editorState:Y,line:_,runtimeBlockMap:B,theme:D,width:H})}a9({activeBlockFlashes:R,activeBlockId:$,activeRegionId:M,context:X,editorState:Y,endIndex:E,layout:K,regionBounds:Z,startIndex:V,theme:D,verticalBleed:N$});for(let W=V;W<E;W+=1){let _=K.lines[W];DK({activeBlockId:$,activeBlockFlashes:R,activeDeletedTextFades:O,activeThreadIndex:J,activeInsertedTextHighlights:j,activeListMarkerPops:f,activePunctuationPulses:z,context:X,editorState:Y,line:_,liveCommentRanges:q,normalizedSelection:N,resources:G,runtimeBlockMap:B,selectionRegionOrderRange:b,theme:D,width:H})}UK(X,T,D),GK(X,y,D),X.restore()}function KK($,M){let J=$.documentIndex.regionOrderIndex,Z=J.get(M.start.regionId),X=J.get(M.end.regionId);return Z===void 0||X===void 0?null:{end:X,start:Z}}function qK($,M,J,Z,X,A){let Y=new Map;for(let Q=Z;Q<X;Q+=1){let K=$.lines[Q],q=J.get(K.blockId);if(q?.type!=="heading"||q.depth!==1&&q.depth!==2)continue;let N=Y.get(q.id),U={bottom:K.top+K.height,left:K.left+N0(M,K),right:A-$.options.paddingX};Y.set(q.id,N?{bottom:Math.max(N.bottom,U.bottom),left:N.left,right:N.right}:U)}return Y}function NK($,M,J,Z,X){let A=new Map;for(let Y=Z;Y<X;Y+=1){let Q=$.lines[Y],K=n0(M,Q.blockId,"blockquote");if(!K)continue;let q=A.get(K.id),N={bottom:Q.top+Q.height,isActive:Q.blockId===J,left:$.options.paddingX+(K.depth+1)*$.options.indentWidth-10,top:Q.top};A.set(K.id,q?{bottom:Math.max(q.bottom,N.bottom),isActive:q.isActive||N.isActive,left:q.left,top:Math.min(q.top,N.top)}:N)}return A}function UK($,M,J){$.fillStyle=J.headingRule;for(let Z of M.values())$.fillRect(Z.left,Z.bottom+ZK,Math.max(U$,Z.right-Z.left),XK)}function GK($,M,J){for(let Z of M.values())$.fillStyle=Z.isActive?J.blockquoteRuleActive:J.blockquoteRule,$.fillRect(Z.left,Z.top+mQ,hQ,Math.max(vQ,Z.bottom-Z.top-gQ))}function BK({context:$,devicePixelRatio:M,editorState:J,height:Z,layout:X,normalizedSelection:A,presence:Y,showCaret:Q,theme:K,viewportTop:q,width:N}){$.save(),$.scale(M,M),$.clearRect(0,0,N,Z);let U=A.start.regionId===A.end.regionId&&A.start.offset!==A.end.offset,G=Q&&!U;if($.translate(0,-q),G)e9($,J,X,{color:K.caret,offset:J.selection.focus.offset,regionId:J.selection.focus.regionId});if(Y)for(let B of Y){if(!B.cursorPoint)continue;e9($,J,X,{color:B.color??K.leafAccent,offset:B.cursorPoint.offset,regionId:B.cursorPoint.regionId})}$.restore()}function e9($,M,J,Z){let X=c1(J,M.documentIndex,{regionId:Z.regionId,offset:Z.offset});if(!X)return;let A=d1(M,J,X),Y=zK(J,X);$.fillStyle=Z.color,$.fillRect(A,Y.top,pQ,Y.height)}function FK({containerLineBounds:$,context:M,editorState:J,line:Z,runtimeBlockMap:X,theme:A,width:Y}){let Q=X.get(Z.blockId)??null,K=$.get(Z.regionId)??null,q=J.documentIndex.tableCellIndex.get(Z.regionId)??null;_K(M,Z,Q,K,q,A,Y)}function DK({activeBlockId:$,activeBlockFlashes:M,activeDeletedTextFades:J,activeThreadIndex:Z,activeInsertedTextHighlights:X,activeListMarkerPops:A,activePunctuationPulses:Y,context:Q,editorState:K,line:q,liveCommentRanges:N,normalizedSelection:U,resources:G,runtimeBlockMap:B,selectionRegionOrderRange:D,theme:F,width:H}){let b=B.get(q.blockId)??null,E=K.documentIndex.blockIndex.get(q.blockId)?.path??null,V=K.documentIndex.regionIndex.get(q.regionId)??null,R=V?.path??"",O=n0(K,q.blockId,"listItem"),j=O?j2(K,O.id):null,f=O?A.get(O.path)??null:null,z=q.left+N0(K,q),y=CK(q),T=b?.type==="code"?F.codeText:jK(b,F);Q.font=q.font,HK(Q,q,b,E,$,M,F,H),PK(Q,K,q,U,D,F),WK(Q,K,q,N,Z,F),c9(Q,q,j,z,y,F,f),TK(Q,q,V,z,y,X.get(R)??[],T,G,F),yK(Q,q,V,z,y,J.get(R)??[],T),VK(Q,q,V,z,y,Y.get(R)??[],F)}function _K($,M,J,Z,X,A,Y){if(!Z||M.start!==0)return;if(J?.type==="code"){let Q=Math.max(0,M.left-cQ);$.fillStyle=A.codeBackground,$.fillRect(Q,Z.top-dQ,Math.max(Z.right-M.left+xQ,Y-Q),Z.bottom-Z.top+rQ);return}if(J?.type!=="table")return;d9({context:$,containerBounds:Z,isHeaderRow:X?.rowIndex===0,lineHeight:M.height,theme:A})}function HK($,M,J,Z,X,A,Y,Q){if(M.blockId!==X||J?.type==="table")return;let K=Z?A.get(Z)??null:null;if($.fillStyle=Y.activeBlockBackground,$.fillRect(0,M.top-N$,Q,M.height),!K)return;$.fillStyle=b5(Y.activeBlockFlash,K),$.fillRect(0,M.top-N$,Q,M.height)}function PK($,M,J,Z,X,A){if(!X)return;let Y=M.documentIndex.regionOrderIndex.get(J.regionId);if(Y===void 0||Y<X.start||Y>X.end)return;let Q=Y===X.start?Math.max(J.start,Z.start.offset):J.start,K=Y===X.end?Math.min(J.end,Z.end.offset):J.end;if(K<=Q)return;$.fillStyle=A.selectionBackground,$.fillRect(q0(M,J,Q-J.start),J.top+MK,Math.max($K,q0(M,J,K-J.start)-q0(M,J,Q-J.start)),J.height-JK)}function WK($,M,J,Z,X,A){for(let Y of Z){if(Y.regionId!==J.regionId)continue;let Q=Math.max(Y.startOffset,J.start),K=Math.min(Y.endOffset,J.end);if(K<=Q)continue;$.fillStyle=LK(Y,X,A),$.fillRect(q0(M,J,Q-J.start),J.top+J.height-aQ,Math.max(sQ,q0(M,J,K-J.start)-q0(M,J,Q-J.start)),iQ)}}function TK($,M,J,Z,X,A,Y,Q,K){if(!J){$.fillStyle=Y,$.fillText(M.text,Z,X);return}let q=J.inlines.filter((N)=>N.end>M.start&&N.start<M.end);if(q.length===0){$.fillStyle=Y,$.fillText(M.text,Z,X);return}for(let N of q){let U=Math.max(M.start,N.start),G=Math.min(M.end,N.end);if(J.text.slice(U,G).length===0)continue;let{left:D,right:F}=B$(M,Z,U,G),H=RK(M.font,N.marks);if($.font=H,N.kind==="image"){let b=Math.max(24,F-D);p9($,M,N,Q,K,D,b);continue}if(N.kind==="inlineCode"){let b=EK(M,H),E=wK(M,H);$.fillStyle=K.inlineCodeBackground,$.fillRect(D-o9,b,Math.max(tQ,F-D+o9*2),E),$7($,M,J.text,Z,X,U,G,K.inlineCodeText,A,K,{strikethrough:!1,underline:!1});continue}$7($,M,J.text,Z,X,U,G,N.link?K.linkText:Y,A,K,{strikethrough:N.marks.includes("strikethrough"),underline:N.marks.includes("underline")||Boolean(N.link)})}}function $7($,M,J,Z,X,A,Y,Q,K,q,N){let U=t3(A,Y,K);for(let G=0;G<U.length-1;G+=1){let B=U[G],D=U[G+1];if(D<=B)continue;let F=J.slice(B,D);if(F.length===0)continue;let{left:H,right:b}=B$(M,Z,B,D),E=e3(K,B,D),V=$9(Q,E,q);if($.fillStyle=V,$.fillText(F,H,X),N.strikethrough)$.fillRect(H,bK(X,M.height,$.font),Math.max(U$,b-H),n9);if(N.underline)$.fillRect(H,OK(X,M.height,$.font),Math.max(U$,b-H),n9)}}function yK($,M,J,Z,X,A,Y){if(!J||A.length===0)return;for(let Q of A){if(Q.startOffset<M.start||Q.startOffset>M.end)continue;let K=Z+(x1(M,Q.startOffset-M.start)-M.left);$.fillStyle=M9(Y,Q),$.fillText(Q.text,K,X)}}function VK($,M,J,Z,X,A,Y){if(!J||A.length===0)return;for(let Q of A){if(Q.offset<M.start||Q.offset>=M.end)continue;let{left:K,right:q}=B$(M,Z,Q.offset,Q.offset+1),N=Math.max(t9,(q-K)/2+t9+AK*Q.progress),{ascent:U,descent:G}=K0(M.font),B=X-Math.max(1,U*0.42)+Math.max(0.5,G*0.15);$.strokeStyle=J9(Q,Y),$.lineWidth=YK,$.beginPath(),$.arc((K+q)/2,B,N,0,Math.PI*2),$.stroke()}}function zK($,M){let J=$0($,M.regionId,M.offset),Z=J?.font??'16px "Iowan Old Style", "Palatino Linotype", serif',{ascent:X,descent:A}=K0(Z),Y=Math.max(1,X+A),Q=Math.min(M.height-lQ,Y),K=J?Math.max(J.top,J.top+G$(J.height,Z)-IQ):M.top+Math.max(0,Math.floor((M.height-Q)/2));return{height:Q,top:K}}function OK($,M,J){let{descent:Z}=K0(J),X=Math.max(1,Math.round(Math.max(2,Z)*0.35)),A=$+Z-X,Y=$-I5(M,J);return Math.min(Y+M-4,A)}function bK($,M,J){let{ascent:Z}=K0(J),X=$-I5(M,J);return Math.max(X+2,$-Math.round(Z*0.32))}function CK($){return $.top+I5($.height,$.font)}function I5($,M){return B3($,M)}function EK($,M){let J=G$($.height,M);return $.top+J+eQ}function wK($,M){let J=G$($.height,M);return Math.max(nQ,$.height-J-oQ)}function G$($,M){let{ascent:J}=K0(M);return I5($,M)-J}function jK($,M){switch($?.type){case"heading":return M.headingText;case"blockquote":return M.blockquoteText;case"table":return M.headingText;default:return M.paragraphText}}function B$($,M,J,Z){return{left:M+(x1($,J-$.start)-$.left),right:M+(x1($,Z-$.start)-$.left)}}function RK($,M){let J=[];if(M.includes("italic"))J.push("italic");if(M.includes("bold"))J.push("700");return J.length>0?`${J.join(" ")} ${$}`:$}function LK($,M,J){if($.resolved)return $.threadIndex===M?J.commentHighlightResolvedActive:J.commentHighlightResolved;return $.threadIndex===M?J.commentHighlightActive:J.commentHighlight}function kK(){return typeof performance<"u"?performance.now():Date.now()}function F$($,M,J,Z){QK({activeBlockId:Z.activeBlockId,activeRegionId:Z.activeRegionId,activeThreadIndex:Z.activeThreadIndex,containerLineBounds:M.regionBounds,context:J,devicePixelRatio:Z.devicePixelRatio,editorState:$,height:Z.height,layout:M.layout,liveCommentRanges:Z.liveCommentRanges,normalizedSelection:Z.normalizedSelection,now:Z.now,resources:Z.resources??{images:new Map},runtimeBlockMap:M.blockMap,theme:Z.theme,viewportTop:M.paintTop,width:Z.width})}function D$($,M,J,Z){BK({context:J,devicePixelRatio:Z.devicePixelRatio,editorState:$,height:Z.height,layout:M.layout,normalizedSelection:Z.normalizedSelection,presence:Z.presence,showCaret:Z.showCaret,theme:Z.theme,viewportTop:M.paintTop,width:Z.width})}import{forwardRef as vK,createElement as gK}from"react";var p5=(...$)=>$.filter((M,J,Z)=>{return Boolean(M)&&M.trim()!==""&&Z.indexOf(M)===J}).join(" ").trim();var M7=($)=>$.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var J7=($)=>$.replace(/^([A-Z])|[\s-_]+(\w)/g,(M,J,Z)=>Z?Z.toUpperCase():J.toLowerCase());var _$=($)=>{let M=J7($);return M.charAt(0).toUpperCase()+M.slice(1)};import{forwardRef as mK,createElement as A7}from"react";var l5={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var Z7=($)=>{for(let M in $)if(M.startsWith("aria-")||M==="role"||M==="title")return!0;return!1};import{createContext as fK,useContext as uK,useMemo as YH,createElement as QH}from"react";var SK=fK({});var X7=()=>uK(SK);var Y7=mK(({color:$,size:M,strokeWidth:J,absoluteStrokeWidth:Z,className:X="",children:A,iconNode:Y,...Q},K)=>{let{size:q=24,strokeWidth:N=2,absoluteStrokeWidth:U=!1,color:G="currentColor",className:B=""}=X7()??{},D=Z??U?Number(J??N)*24/Number(M??q):J??N;return A7("svg",{ref:K,...l5,width:M??q??l5.width,height:M??q??l5.height,stroke:$??G,strokeWidth:D,className:p5("lucide",B,X),...!A&&!Z7(Q)&&{"aria-hidden":"true"},...Q},[...Y.map(([F,H])=>A7(F,H)),...Array.isArray(A)?A:[A]])});var L=($,M)=>{let J=vK(({className:Z,...X},A)=>gK(Y7,{ref:A,iconNode:M,className:p5(`lucide-${M7(_$($))}`,`lucide-${$}`,Z),...X}));return J.displayName=_$($),J};var hK=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],D0=L("columns-2",hK);var IK=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],_0=L("rows-3",IK);var pK=[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]],H0=L("send-horizontal",pK);var lK=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Y4=L("arrow-down",lK);var rK=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Q4=L("arrow-up",rK);var cK=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],K4=L("bold",cK);var xK=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],C0=L("check",xK);var dK=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],q4=L("chevron-down",dK);var aK=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],N4=L("heading-1",aK);var sK=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],U4=L("heading-2",sK);var iK=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],G4=L("heading-3",iK);var oK=[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]],B4=L("heading-4",oK);var nK=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]],F4=L("heading-5",nK);var tK=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]],D4=L("heading-6",tK);var eK=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],_4=L("heading",eK);var $q=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],H4=L("italic",$q);var Mq=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],P4=L("list-ordered",Mq);var Jq=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],W4=L("list-todo",Jq);var Zq=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],T4=L("list",Zq);var Xq=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],y4=L("message-square-plus",Xq);var Aq=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],E0=L("pencil",Aq);var Yq=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],K2=L("plus",Yq);var Qq=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],V4=L("strikethrough",Qq);var Kq=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],P0=L("table-2",Kq);var qq=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],z4=L("text-quote",qq);var Nq=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],w1=L("trash-2",Nq);var Uq=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],O4=L("underline",Uq);var Gq=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],b4=L("x",Gq);import{jsxDEV as w0}from"react/jsx-dev-runtime";function Q7({insetX:$,insetY:M,onSelect:J,presence:Z}){if(Z.length===0)return null;return w0("div",{"aria-label":"Presence",className:"documint-presence-indicators",style:{paddingRight:`${$}px`,top:`${M}px`},children:Z.map((X,A)=>w0(Bq,{onSelect:()=>J(X),presence:X},_q(X,A),!1,void 0,this))},void 0,!1,void 0,this)}function Bq({onSelect:$,presence:M}){let J=M.viewport,Z=Fq(M),X=J?.status==="above"?Q4:Y4,A=J!==null&&J.scrollTop!==null,Y=J?.status==="above"||J?.status==="below";return w0("button",{"aria-label":Dq(M),className:"documint-presence-indicator","data-status":J?.status??"unresolved",disabled:!A,onClick:A?$:void 0,style:{"--documint-presence-color":M.color??"var(--documint-leaf-accent)"},type:"button",children:[w0("span",{className:"documint-presence-indicator-avatar",children:M.imageUrl?w0("img",{alt:"","aria-hidden":"true",className:"documint-presence-indicator-image",draggable:!1,src:M.imageUrl},void 0,!1,void 0,this):Z},void 0,!1,void 0,this),Y?w0("span",{className:"documint-presence-indicator-direction","aria-hidden":"true",children:w0(X,{className:"documint-presence-indicator-arrow",size:14,strokeWidth:2.3},void 0,!1,void 0,this)},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)}function Fq($){return K7($).charAt(0).toLocaleUpperCase()}function Dq($){let M=K7($),J=$.viewport?.status??"unresolved";if(J==="above")return`${M} above viewport`;if(J==="below")return`${M} below viewport`;if(J==="unresolved")return`${M} unresolved`;return`${M} in viewport`}function K7($){return $.name.trim()||"Presence"}function _q($,M){return[M,$.name,$.imageUrl??"",$.color??"",$.cursor?.kind??"",$.cursor?.prefix??"",$.cursor?.suffix??""].join(":")}var s=`
26
- `,W0="<ins>",C4="</ins>",q2=">",E4="```",r5=":::",H$=/^:::([A-Za-z][-\w]*)(.*)$/,c5="documint-comments";var x5="`",y$="\\",W$="![",T$="[",G7="(",q7=")",B7=" ",F7=":",Hq=/[A-Za-z]/,Pq=/[-A-Za-z0-9_]/,Wq=/^\{width=([1-9]\d*)\}/,Tq=/\\([\\`*_[\]{}()#+\-.!~|])/g,D7=/\\(.)/g,yq=[{delimiter:"**",mark:"bold"},{delimiter:"~~",mark:"strikethrough"},{delimiter:"*",mark:"italic"}];function N2($,M=[]){return V$($,0,$.length,M)}function V$($,M,J,Z){let X=[],A=M,Y=M;while(A<J){let Q=Vq($,A,J,Z);if(Q){N7(X,$.slice(Y,A),Z),X.push(...Q.nodes),A=Q.end,Y=A;continue}if($[A]===y$){A+=Math.min(2,J-A);continue}A+=1}return N7(X,$.slice(Y,J),Z),zq(X)}function Vq($,M,J,Z){switch($[M]){case F7:return uq($,M,J);case"<":return kq($,M,J,Z);case x5:return wq($,M,J);case"!":return jq($,M,J);case T$:return Rq($,M,J,Z);case"*":case"~":return bq($,M,J,Z);default:return null}}function N7($,M,J){if(M.length===0)return;$.push(W1({marks:J,text:T7(M)}))}function z$($,M){return p4({originalType:$,source:M})}function zq($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&Cq(Z.marks,J.marks)){M[M.length-1]=W1({marks:Z.marks,text:Z.text+J.text});continue}M.push(J)}return M}function Oq($,M,J){for(let Z of yq){if(!$.startsWith(Z.delimiter,M))continue;let X=$.indexOf(Z.delimiter,M+Z.delimiter.length);if(X<0||X>=J)continue;return{contentEnd:X,contentStart:M+Z.delimiter.length,end:X+Z.delimiter.length,mark:Z.mark}}return null}function bq($,M,J,Z){let X=Oq($,M,J);if(!X)return null;return{end:X.end,nodes:V$($,X.contentStart,X.contentEnd,[...Z,X.mark])}}function Cq($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function Eq($,M,J){if($[M]!==x5)return null;let Z=1;while(M+Z<J&&$[M+Z]===x5)Z+=1;let X=x5.repeat(Z),A=$.indexOf(X,M+Z);if(A<0||A>=J)return null;return{end:A+Z,value:$.slice(M+Z,A)}}function wq($,M,J){let Z=Eq($,M,J);if(!Z)return null;return{end:Z.end,nodes:[S0({code:Z.value})]}}function jq($,M,J){if(!$.startsWith(W$,M))return null;let Z=H7($,M+1,J);if(Z<0||$[Z+1]!==G7)return null;let X=_7($,Z+1,J);if(!X)return null;let A=Lq($,X.end,J);return{end:A?.end??X.end,nodes:[I4({alt:T7($.slice(M+W$.length,Z)),title:X.title,url:X.url,width:A?.width??null})]}}function Rq($,M,J,Z){if($[M]!==T$||$.startsWith(W$,M-1))return null;let X=H7($,M,J);if(X<0||$[X+1]!==G7)return null;let A=_7($,X+1,J);if(!A)return null;return{end:A.end,nodes:[m0({children:N2($.slice(M+T$.length,X),Z),title:A.title,url:A.url})]}}function _7($,M,J){let Z=P$($,M+1,J),X=Z;while(X<J&&$[X]!==q7&&$[X]!==B7){if($[X]===y$){X+=2;continue}X+=1}if(X===Z)return null;let A=Sq($.slice(Z,X));Z=P$($,X,J);let Y=null;if(Z<J&&$[Z]==='"'){let Q=W7($,'"',Z+1,J);if(Q<0)return null;Y=$.slice(Z+1,Q).replace(D7,"$1"),Z=P$($,Q+1,J)}if($[Z]!==q7)return null;return{end:Z+1,title:Y,url:A}}function Lq($,M,J){let Z=Wq.exec($.slice(M,J));if(!Z)return null;return{end:M+Z[0].length,width:Number(Z[1])}}function kq($,M,J,Z){if(!$.startsWith(W0,M))return fq($,M,J);let X=$.indexOf(C4,M+W0.length);if(X<0||X>=J)return{end:M+W0.length,nodes:[z$("html",W0)]};return{end:X+C4.length,nodes:V$($,M+W0.length,X,[...Z,"underline"])}}function fq($,M,J){if($[M]!=="<")return null;let Z=$.indexOf(">",M+1);if(Z<0||Z>=J)return null;return{end:Z+1,nodes:[z$("html",$.slice(M,Z+1))]}}function uq($,M,J){if($[M]!==F7||!Hq.test($[M+1]??""))return null;let Z=M+2;while(Z<J&&Pq.test($[Z]??""))Z+=1;let X=U7($,Z,J,"[","]"),Y=U7($,X?.end??Z,J,"{","}")?.end??X?.end??Z;return{end:Y,nodes:[z$("textDirective",$.slice(M,Y))]}}function U7($,M,J,Z,X){if($[M]!==Z)return null;let A=P7($,X,M+1,J);if(A<0)return null;return{end:A+1}}function H7($,M,J){return P7($,"]",M+1,J)}function P7($,M,J,Z){return W7($,M,J,Z)}function W7($,M,J,Z){for(let X=J;X<Z;X+=1){if($[X]===y$){X+=1;continue}if($[X]===M)return X}return-1}function P$($,M,J){while(M<J&&$[M]===B7)M+=1;return M}function T7($){return $.replace(Tq,"$1")}function Sq($){return $.replace(D7,"$1")}var mq=/^:?-+:?$/;function z7($,M){let J=V7($),Z=$.lines[$.index+1]??"",X=O$(J,M),A=O$(Z,M);if(!y7(X)||!b$(A))return null;let Y=[d5(X)],Q=vq(A);$.index+=2;while($.index<$.lines.length){let K=V7($),q=O$(K,M);if(gq(K)||!y7(q))break;Y.push(d5(q)),$.index+=1}return V0({align:Q,rows:Y.map((K)=>v0({cells:K.map((q)=>X0({children:N2(q)}))}))})}function y7($){let M=$.trim();return/\|/.test($)&&M.startsWith("|")&&M.endsWith("|")}function b$($){let M=d5($);return M.length>0&&M.every((J)=>mq.test(J.trim()))}function vq($){return d5($).map((M)=>{let J=M.trim();if(J.startsWith(":")&&J.endsWith(":"))return"center";if(J.startsWith(":"))return"left";if(J.endsWith(":"))return"right";return null})}function d5($){return $.trim().slice(1,-1).split("|").map((J)=>J.trim())}function V7($){return $.lines[$.index]??""}function gq($){return $.trim()===""}function O$($,M){return $.slice(M)}var hq=3,Iq=/^\d+\.$/,pq=/^\[( |x|X)\](?:\s|$)/,O7=/^```([^\s`]*)?(?:\s+(.*))?$/,b7=/^::(?!:)[A-Za-z][-\w]*/,C7=/^(#{1,6})\s+(.*)$/,lq=/\s+#+\s*$/u,rq=/^(\s*)([-+*]|\d+\.)(?:\s+(.*)|\s*)$/,cq=/^(\*\s*){3,}$/,xq=/^(-\s*){3,}$/,dq=/^(_\s*){3,}$/;function s5($,M,J){let Z=[];while($.index<$.lines.length){let X=H1($);if($.index===$.lines.length-1&&X==="")break;if(w4(X)){$.index+=1;continue}if(U2(X)>M+hq)break;let Y=aq($,M,J);if(!Y)break;Z.push(Y)}return Z}function aq($,M,J){return sq($,M,J)??iq($,M)??oq($,M)??tq($,M)??eq($,M)??$N($,M)??z7($,M)??MN($,M,J)??JN($,M)??ZN($,M)}function sq($,M,J){let Z=H1($);if(!AN(Z,M))return null;let X=[];while($.index<$.lines.length){let A=H1($),Y=U2(A);if(w4(A)){X.push(""),$.index+=1;continue}if(Y<M)break;let Q=u1(A,M);if(!Q.startsWith(q2))break;let K=Q.slice(1);if(K.startsWith(" "))K=K.slice(1);X.push(K),$.index+=1}return T1({children:s5({index:0,lines:X},0,J)})}function iq($,M){let J=H1($),Z=u1(J,M),X=O7.exec(Z);if(!X)return null;$.index+=1;let A=[];while($.index<$.lines.length){let Y=H1($),Q=u1(Y,M);if(Q.trim()===E4){$.index+=1;break}A.push(Q),$.index+=1}return N6({language:X[1]?X[1]:null,meta:X[2]?X[2]:null,source:A.join(s)})}function oq($,M){let J=H1($),Z=u1(J,M),X=H$.exec(Z);if(!X)return null;let A=X[1],Y=[];$.index+=1;while($.index<$.lines.length){let Q=H1($),K=u1(Q,M);if($.index+=1,K.trim()===r5)break;Y.push(K)}return qM({attributes:nq(X[2]??""),body:Y.join(s),name:A})}function nq($){let M=$.trim();if(M.startsWith("{")&&M.endsWith("}"))return M.slice(1,-1);return M}function tq($,M){let J=H1($),Z=u1(J,M);if(!b7.test(Z))return null;return $.index+=1,r4({originalType:"leafDirective",source:Z})}function eq($,M){let J=H1($),Z=C7.exec(u1(J,M));if(!Z)return null;return $.index+=1,h4({children:N2(Z[2].replace(lq,"")),depth:Z[1].length})}function $N($,M){let J=u1(H1($),M).trim();if(!E7(J))return null;return $.index+=1,l4()}function MN($,M,J){let Z=a5(H1($),M);if(!Z)return null;let X=[],A=!1;while($.index<$.lines.length){let Y=H1($),Q=a5(Y,M);if(!Q||Q.ordered!==Z.ordered)break;$.index+=1;let K=[Q.content],q=!1;while($.index<$.lines.length){let N=H1($),U=U2(N);if(w4(N)){let G=KN($.lines,$.index+1);if(G<0||U2($.lines[G]??"")<=M)break;q=!0,K.push(""),$.index+=1;continue}if(U<Q.contentIndent)break;if(U===M&&a5(N,M))break;K.push(YN(N,Q.contentIndent)),$.index+=1}A||=q,X.push(n1({checked:Q.checked,children:XN(K,J),spread:q}))}return y0({items:X,ordered:Z.ordered,spread:A,start:Z.ordered&&J.preserveOrderedListStart?Z.start??1:null})}function JN($,M){let J=u1(H1($),M).trim();if(!w7(J))return null;return $.index+=1,r4({originalType:"html",source:J})}function ZN($,M){let J=[];while($.index<$.lines.length){let Z=H1($),X=U2(Z);if(w4(Z))break;if(X<M)break;let A=u1(Z,M);if(J.length>0&&QN(Z,A,M))break;J.push(A),$.index+=1}return _2({children:N2(J.join(s))})}function XN($,M){let J=s5({index:0,lines:$},0,M);if(J.length>0)return J;return[_2({children:[]})]}function a5($,M){let J=rq.exec($);if(!J||J[1].length!==M)return null;let Z=J[2],X=Iq.test(Z),A=X?Number(Z.slice(0,-1)):null,Y=J[3]??"",Q=null;if(pq.test(Y)){if(Q=Y[1]==="x"||Y[1]==="X",Y=Y.slice(3),Y.startsWith(" "))Y=Y.slice(1)}let K=Y.length>0?J[0].length-J[1].length-J[2].length-Y.length:J[0].length-J[1].length-J[2].length;return{checked:Q,content:Y,contentIndent:M+J[2].length+K,ordered:X,start:A}}function AN($,M){return u1($,M).startsWith(q2)}function u1($,M){return $.slice(M)}function YN($,M){let J=U2($);if(J>=M)return $.slice(M);return $.trim()===""?"":$.slice(Math.min(J,M))}function E7($){return cq.test($)||xq.test($)||dq.test($)}function w7($){return $.startsWith("<")&&$.endsWith(">")}function U2($){let M=0;while(M<$.length&&$[M]===" ")M+=1;return M}function QN($,M,J){return M.startsWith(q2)||O7.test(M)||H$.test(M)||b7.test(M)||C7.test(M)||E7(M.trim())||b$(M)||a5($,J)!==null||w7(M.trim())}function H1($){return $.lines[$.index]??""}function w4($){return $.trim()===""}function KN($,M){for(let J=M;J<$.length;J+=1)if(!w4($[J]??""))return J;return-1}function R7($){let M=$.at(-1),J=M&&j7(M)?M:null;return{blocks:$.filter((X)=>!j7(X)),comments:J?qN(J.body):[]}}function qN($){let M;try{M=JSON.parse($)}catch{return[]}if(!Array.isArray(M))return[];return M.flatMap((J)=>{let Z=P6(J);return Z?[Z]:[]})}function j7($){return $.type==="directive"&&$.name===c5}function C$($,M={}){let Z={index:0,lines:$.replace(/\r\n/g,s).split(s)},X=s5(Z,0,M),{comments:A,blocks:Y}=R7(X);return h0(Y,A)}var j4=`
27
-
28
- `,NN="-",UN=".",GN="***",BN="&#x20;",E$=3,FN=5,DN=4,L7=2,_N=2,HN=1,PN=/([\\`*_[\]])/g,WN=/([\\)&])/g,TN=/(["\\])/g;function i5($,M={}){if($.blocks.length===0&&$.comments.length===0)return"";let J=$.blocks.map((X)=>o5(X,0,M));if($.comments.length>0)J.push(gN($.comments));let Z=J.join(j4);return Z.endsWith(s)?Z:`${Z}${s}`}function o5($,M,J){let Z=T0(M);switch($.type){case"blockquote":return yN($,M,J);case"code":return VN($,M);case"directive":return hN($,M);case"heading":return f7($,M);case"list":return zN($,M,J);case"listItem":return u7($,M,!1,1,J);case"paragraph":return`${Z}${w$(R4($.children))}`;case"table":return bN($,M,J);case"thematicBreak":return`${Z}${GN}`;case"unsupported":return M===0?$.source:v7($.source,M)}}function yN($,M,J){let Z=$.children.map((A)=>o5(A,0,J)).join(j4),X=T0(M);return Z.split(s).map((A)=>`${X}${q2}${A.length>0?` ${A}`:""}`).join(s)}function VN($,M){let J=[$.language??"",$.meta??""].filter(Boolean).join(" ").trim(),Z=T0(M),X=`${Z}${E4}${J?J:""}`,A=$.source.length>0?$.source.split(s).map((Y)=>`${Z}${Y}`).join(s):Z;return`${X}${s}${A}${s}${Z}${E4}`}function f7($,M){let J=w$(R4($.children)),Z=`${T0(M)}${"#".repeat($.depth)}`;return J.length>0?`${Z} ${J}`:Z}function zN($,M,J){let Z=$.start??1;return $.items.map((X)=>u7(X,M,$.ordered,Z,J)).join($.spread?j4:s)}function u7($,M,J,Z,X){let A=J?`${Z}${UN}`:NN,Y=$.checked===null?"":`[${$.checked?"x":" "}] `,Q=`${T0(M)}${A} ${Y}`,K=M+A.length+1,q=$.children;if(q.length===0)return Y.length>0?Q:Q.trimEnd();let[N,...U]=q,G=ON(N,Q,Y.length>0,X),B=U.map((D)=>o5(D,K,X)).join($.spread?j4:s);if(!B)return G;return`${G}${$.spread?j4:s}${B}`}function ON($,M,J,Z){switch($.type){case"paragraph":{let X=w$(R4($.children));if(X.length===0)return J?M:M.trimEnd();return`${M}${X}`}case"heading":return`${M}${f7($,0)}`;case"directive":case"unsupported":{let X=$.type==="directive"?j$($):$.source,[A,...Y]=X.split(s);return[M+A,...Y.map((Q)=>`${T0(M.length)}${Q}`)].join(s)}default:{let X=M.length;return`${M.trimEnd()}${s}${o5($,X,Z)}`}}}function bN($,M,J){let Z=$.rows.map((N)=>N.cells.map((U)=>R4(U.children))),X=Math.max(1,...Z.map((N)=>N.length)),A=Z[0]??[],Y=Array.from({length:X},(N,U)=>Math.max(E$,jN($.align[U]),...J.padTableColumns?Z.map((G)=>G[U]?.length??0):[A[U]?.length??0])),Q=CN(Y,$.align,M),K=k7(A,Y,$.align,M,J),q=Z.slice(1).map((N)=>k7(N,Y,$.align,M,J));return[K??EN(Y,M),Q,...q].join(s)}function k7($,M,J,Z,X){let A=M.map((Y,Q)=>{let K=$[Q]??"";if(!X.padTableColumns)return K;return RN(K,Y,J[Q])});return`${" ".repeat(Z)}| ${A.join(" | ")} |`}function CN($,M,J){let Z=$.map((X,A)=>wN(M[A],X));return`${" ".repeat(J)}| ${Z.join(" | ")} |`}function EN($,M){return`${T0(M)}| ${$.map((J)=>"".padEnd(J," ")).join(" | ")} |`}function wN($,M){let J=Math.max(E$,M-($==="center"?_N:$?HN:0));switch($){case"center":return`:${"-".repeat(Math.max(1,J))}:`;case"left":return`:${"-".repeat(Math.max(L7,J))}`;case"right":return`${"-".repeat(Math.max(L7,J))}:`;default:return"-".repeat(J)}}function jN($){return $==="center"?FN:$?DN:E$}function RN($,M,J){if(J==="right")return $.padStart(M," ");return $.padEnd(M," ")}function R4($){return kN($).map((M)=>LN(M)).join("")}function w$($){return $.replace(/^ +/gm,(M)=>BN.repeat(M.length))}function LN($){switch($.type){case"break":return s;case"image":return IN($);case"inlineCode":return SN($.code);case"link":return pN($);case"text":return uN(S7($.text),$.marks);case"unsupported":return $.source}}function kN($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&fN(Z.marks,J.marks)){M[M.length-1]={...Z,text:Z.text+J.text};continue}M.push(J)}return M}function fN($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function uN($,M){return M.reduce((J,Z)=>{switch(Z){case"bold":return`**${J}**`;case"italic":return`*${J}*`;case"strikethrough":return`~~${J}~~`;case"underline":return`${W0}${J}${C4}`}},$)}function SN($){let M=0,J=0;for(let Y of $){if(Y==="`"){if(J+=1,J>M)M=J;continue}J=0}let Z=M>0?M+1:1,X="`".repeat(Z),A=$.startsWith("`")||$.endsWith("`")?` ${$} `:$;return`${X}${A}${X}`}function S7($){return $.replace(PN,"\\$1")}function mN($){return $.replace(WN,"\\$1")}function vN($){return $?` "${$.replace(TN,"\\$1")}"`:""}function gN($){return j$({attributes:"",body:JSON.stringify($,null,2),name:c5})}function hN($,M){let J=j$($);return M===0?J:v7(J,M)}function j$($){let M=$.attributes?`{${$.attributes}}`:"";return`:::${$.name}${M}${s}${$.body}${s}${r5}`}function IN($){let M=S7($.alt??""),J=m7($.url,$.title),Z=$.width?`{width=${$.width}}`:"";return`![${M}]${J}${Z}`}function pN($){return`[${R4($.children)}]${m7($.url,$.title)}`}function m7($,M){return`(${mN($)}${vN(M)})`}function T0($){return" ".repeat($)}function v7($,M){let J=T0(M);return $.split(s).map((Z)=>`${J}${Z}`).join(s)}import{useEffect as t5,useRef as tN,useState as j0}from"react";import{forwardRef as lN}from"react";import{jsxDEV as G2}from"react/jsx-dev-runtime";var n5=lN(function({className:M,onCancel:J,onChange:Z,onSave:X,placeholder:A,readOnly:Y=!1,rows:Q=3,saveDisabled:K=!1,value:q},N){return G2("div",{className:"documint-edit-input-field",children:[G2("textarea",{className:M??"documint-comment-input",onChange:(U)=>Z(U.currentTarget.value),onKeyDown:(U)=>{if(U.key!=="Escape")return;U.preventDefault(),J()},placeholder:A,readOnly:Y,ref:N,rows:Q,value:q},void 0,!1,void 0,this),G2("button",{className:"documint-leaf-action documint-edit-input-cancel","aria-label":"Cancel editing",onClick:J,title:"Cancel editing",type:"button",children:G2(b4,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this),G2("button",{className:"documint-leaf-action documint-edit-input-save","aria-label":"Save",disabled:K,onClick:X,title:"Save",type:"button",children:G2(C0,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)});import{Children as g7,isValidElement as h7,useEffect as rN,useRef as cN,useState as xN}from"react";import{jsxDEV as q1}from"react/jsx-dev-runtime";var R$=($)=>{$.preventDefault()},L$=($)=>$.isPrimary&&$.button===0;function dN({children:$}){return q1("div",{className:"documint-leaf-toolbar",children:g7.map($,aN)},void 0,!1,void 0,this)}function aN($){if(!h7($))return null;if($.type===p7){let M=$.props;return q1(I7,{children:q1(sN,{...M},void 0,!1,void 0,this)},void 0,!1,void 0,this)}if($.type===l7){let{className:M}=$.props;return q1("div",{className:L4("documint-leaf-toolbar-divider",M)},void 0,!1,void 0,this)}if($.type===r7){let M=$.props;return q1(iN,{...M},void 0,!1,void 0,this)}return null}function sN({active:$=!1,className:M,disabled:J=!1,icon:Z,label:X,onClick:A}){return q1("button",{"aria-label":X,className:L4("documint-leaf-toolbar-button",$?"active":null,M),disabled:J,onPointerDown:(Y)=>{if(R$(Y),!J&&L$(Y))A()},title:X,type:"button",children:q1(Z,{size:15,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function iN({children:$,className:M,icon:J,label:Z,onSelect:X}){let A=cN(null),[Y,Q]=xN(!1);return rN(()=>{if(!Y)return;let K=(q)=>{if(A.current&&q.target instanceof Node&&!A.current.contains(q.target))Q(!1)};return window.addEventListener("pointerdown",K),()=>{window.removeEventListener("pointerdown",K)}},[Y]),q1(I7,{children:q1("div",{className:"documint-leaf-toolbar-menu-shell",ref:A,children:[q1(oN,{className:M,icon:J,isOpen:Y,label:Z,onClick:()=>Q((K)=>!K)},void 0,!1,void 0,this),Y?q1("div",{className:"documint-leaf-toolbar-menu",role:"menu",children:g7.map($,(K)=>nN(K,(q)=>{Q(!1),X(q)}))},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function oN({className:$,icon:M,isOpen:J,label:Z,onClick:X}){return q1("button",{"aria-expanded":J,"aria-haspopup":"menu","aria-label":Z,className:L4("documint-leaf-toolbar-button",J?"active":null,$),onPointerDown:(A)=>{if(R$(A),L$(A))X()},title:Z,type:"button",children:[q1(M,{size:15,strokeWidth:2.2},void 0,!1,void 0,this),q1(q4,{className:L4("documint-leaf-toolbar-menu-chevron",J?"is-open":null),size:13,strokeWidth:2.2},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function nN($,M){if(!h7($))return null;if($.type===x7){let{className:Y}=$.props;return q1("div",{className:L4("documint-leaf-toolbar-menu-divider",Y),role:"separator"},void 0,!1,void 0,this)}if($.type!==c7)return null;let{disabled:J=!1,icon:Z,text:X,value:A}=$.props;return q1("button",{className:"documint-leaf-toolbar-menu-item",disabled:J,onPointerDown:(Y)=>{if(R$(Y),!J&&L$(Y))M(A)},role:"menuitem",type:"button",children:[q1(Z,{size:15,strokeWidth:2.2},void 0,!1,void 0,this),q1("span",{children:X},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function L4(...$){return $.filter(Boolean).join(" ")}function I7({children:$}){return q1("div",{className:"documint-leaf-toolbar-group",children:$},void 0,!1,void 0,this)}function p7($){return null}function l7($){return null}function r7($){return null}function c7($){return null}function x7($){return null}var x=Object.assign(dN,{Button:p7,Divider:l7,Menu:r7,MenuDivider:x7,MenuItem:c7});import{jsxDEV as h,Fragment as JU}from"react/jsx-dev-runtime";var eN=!1,$U=220,R0=()=>{};function k$($){let M=$.mode==="create",J=$.mode==="create"?$:null,Z=$.mode==="thread"?$:null,X=$.canEdit,A=$.link,Y=Z?.thread??null,Q=Y?.comments??[],K=Q[0]??null,q=Y?A0(Y):!1,N=Z?.animateInitialComment??!1,[U,G]=j0(null),[B,D]=j0(""),[F,H]=j0(""),[b,E]=j0(""),[V,R]=j0(!N),[O,j]=j0(eN),[f,z]=j0(!1),y=tN(null),T=Y?b6(Y):null,W=T?d7(T):"",_=X&&!q,C=_&&B.trim().length>0,g=_&&F.trim().length>0,u=X&&b.trim().length>0,d=M||f,p=!M||O,J1=!M&&Boolean(Y),k=Boolean(K),S=M?O:!0,m=Z?.onDeleteComment??R0,Z1=Z?.onDeleteThread??R0,t=Z?.onToggleResolved??R0,N1=J?.activeMarks??[],v1=J?.onToggleBold??R0,g1=J?.onToggleItalic??R0,A1=J?.onToggleStrikethrough??R0,S4=J?.onToggleUnderline??R0,Q6=X?M?"Add a comment":"Reply to this comment":"Comment editing is disabled",u0=M?b:F;t5(()=>{if(U!==null&&(U<0||U>=Q.length))G(null),D("")},[Q.length,U]),t5(()=>{if(!k||!N){R(!0);return}R(!1);let z1=requestAnimationFrame(()=>{R(!0)});return()=>{cancelAnimationFrame(z1)}},[N,K,k]),t5(()=>{if(!Z||!N){z(!1);return}z(!0);let z1=window.setTimeout(()=>{z(!1)},$U);return()=>{window.clearTimeout(z1)}},[N,Z]),t5(()=>{if(!M||!O||!X)return;let z1=requestAnimationFrame(()=>{y.current?.querySelector(".documint-comment-reply-field textarea")?.focus()});return()=>{cancelAnimationFrame(z1)}},[X,M,O]);let m4=()=>{G(null),D("")},i1=(z1,i)=>{if(!J1||!_)return;G(z1),D(i)},v4=(z1)=>{if(!Z)return;Z.onEditComment(z1,B),m4()},h1=()=>{if(!Z)return;Z.onReply(F),H("")},V1=()=>{if(!J||!u)return;J.onCreateThread(b),E("")},g4=d?`documint-comment-leaf documint-comment-leaf-create${S?" is-expanded":""}`:"documint-comment-leaf",e=J1||k||p?h(MU,{canCreate:u,canEdit:X,canMutateThread:_,canReply:g,canSaveEditedComment:C,commentAgeFormatter:d7,comments:Q,editDraft:B,editingCommentIndex:U,isComposerVisible:p,isInitialCommentVisible:V,isResolved:q,link:A,mode:$.mode,onBeginEditingComment:i1,onCancelEditing:m4,onChangeCreateDraft:E,onChangeEditDraft:D,onChangeReplyDraft:H,onDeleteComment:m,onDeleteThread:Z1,onSubmitCreate:V1,onSubmitEditedComment:v4,onSubmitReply:h1,onToggleResolved:t,rootComment:K,showRootComment:k,showThreadChrome:J1,threadAge:W,composerPlaceholder:Q6,composerValue:u0},void 0,!1,void 0,this):null;return h("div",{className:g4,ref:y,children:h("div",{className:d?"documint-comment-leaf-create-shell":void 0,children:[d?h(x,{children:[h(x.Button,{className:"documint-comment-leaf-create-button",icon:y4,label:"Add comment",onClick:()=>j(!0)},void 0,!1,void 0,this),h(x.Divider,{className:"documint-comment-leaf-create-divider"},void 0,!1,void 0,this),h(x.Button,{active:N1.includes("bold"),className:"documint-comment-leaf-create-mark",icon:K4,label:"Bold",onClick:v1},void 0,!1,void 0,this),h(x.Button,{active:N1.includes("italic"),className:"documint-comment-leaf-create-mark",icon:H4,label:"Italic",onClick:g1},void 0,!1,void 0,this),h(x.Button,{active:N1.includes("underline"),className:"documint-comment-leaf-create-mark",icon:O4,label:"Underline",onClick:S4},void 0,!1,void 0,this),h(x.Button,{active:N1.includes("strikethrough"),className:"documint-comment-leaf-create-mark",icon:V4,label:"Strikethrough",onClick:A1},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,h("div",{className:d?"documint-comment-leaf-create-content":void 0,children:e},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function MU({canCreate:$,canEdit:M,canMutateThread:J,canReply:Z,canSaveEditedComment:X,commentAgeFormatter:A,comments:Y,editDraft:Q,editingCommentIndex:K,isComposerVisible:q,isInitialCommentVisible:N,isResolved:U,link:G,mode:B,onBeginEditingComment:D,onCancelEditing:F,onChangeCreateDraft:H,onChangeEditDraft:b,onChangeReplyDraft:E,onDeleteComment:V,onDeleteThread:R,onSubmitCreate:O,onSubmitEditedComment:j,onSubmitReply:f,onToggleResolved:z,rootComment:y,showRootComment:T,showThreadChrome:W,threadAge:_,composerPlaceholder:C,composerValue:g}){return h(JU,{children:[W?h("div",{className:"documint-comment-leaf-header",children:[h("span",{className:"documint-comment-leaf-age",children:_},void 0,!1,void 0,this),h("div",{className:"documint-comment-leaf-actions",children:[h("button",{className:"documint-leaf-action","aria-label":U?"Reopen comment":"Resolve comment",disabled:!M,onClick:z,title:U?"Reopen comment":"Resolve comment",type:"button",children:h(C0,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this),h("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment thread",disabled:!M,onClick:R,title:"Delete comment thread",type:"button",children:h(w1,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):null,W&&G?h("div",{className:"documint-comment-leaf-link",children:[G.title?h("div",{className:"documint-link-leaf-title",children:G.title},void 0,!1,void 0,this):null,h("div",{className:"documint-link-leaf-url",children:G.url},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,h("div",{className:`documint-comment-thread${T?"":" is-empty"}`,children:[h("article",{className:T?`documint-comment-message documint-comment-message-root${N?" is-visible":""}`:"documint-comment-message documint-comment-message-root is-hidden",children:y?h("p",{onDoubleClick:()=>{D(0,y.body)},children:y.body},void 0,!1,void 0,this):null},void 0,!1,void 0,this),Y.slice(1).map((u,d)=>{let p=d+1,J1=K===p;return h("article",{className:"documint-comment-message",children:[!J1?h("div",{className:"documint-comment-message-meta",children:[h("span",{children:A(u.updatedAt)},void 0,!1,void 0,this),J?h("div",{className:"documint-comment-leaf-actions",children:[h("button",{className:"documint-leaf-action","aria-label":"Edit comment",disabled:!J,onClick:()=>{D(p,u.body)},title:"Edit comment",type:"button",children:h(E0,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this),h("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment",disabled:!J,onClick:()=>V(p),title:"Delete comment",type:"button",children:h(w1,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this):null,J1?h(n5,{className:"documint-comment-input",onCancel:F,onChange:b,onSave:()=>j(p),readOnly:!M,rows:3,saveDisabled:!X,value:Q},void 0,!1,void 0,this):h("p",{onDoubleClick:()=>{D(p,u.body)},children:u.body},void 0,!1,void 0,this)]},`${u.updatedAt}:${p}`,!0,void 0,this)})]},void 0,!0,void 0,this),h("div",{className:`documint-comment-reply${W?"":" is-standalone"}${q?" is-visible":""}`,children:h("div",{className:"documint-comment-reply-field",children:[h("textarea",{className:"documint-comment-input",onChange:(u)=>B==="create"?H(u.currentTarget.value):E(u.currentTarget.value),placeholder:C,readOnly:!M,rows:3,value:g},void 0,!1,void 0,this),h("button",{className:"documint-leaf-action documint-comment-reply-submit","aria-label":B==="create"?"Create comment":"Reply",disabled:B==="create"?!$:!Z,onClick:B==="create"?O:f,title:B==="create"?"Create comment":"Reply",type:"button",children:h(H0,{size:15,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function d7($){let M=new Date($);if(Number.isNaN(M.getTime()))return $;let J=M.getTime()-Date.now(),Z=60000,X=60*Z,A=24*X,Y=7*A,Q=30*A,K=365*A,q=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});if(Math.abs(J)<Z)return"just now";if(Math.abs(J)<X)return q.format(Math.round(J/Z),"minute");if(Math.abs(J)<A)return q.format(Math.round(J/X),"hour");if(Math.abs(J)<Y)return q.format(Math.round(J/A),"day");if(Math.abs(J)<K)return q.format(Math.round(J/Q),"month");return q.format(Math.round(J/K),"year")}import{jsxDEV as S1}from"react/jsx-dev-runtime";var ZU=[{icon:N4,label:"Heading 1",text:"# "},{icon:U4,label:"Heading 2",text:"## "},{icon:G4,label:"Heading 3",text:"### "},{icon:B4,label:"Heading 4",text:"#### "},{icon:F4,label:"Heading 5",text:"##### "},{icon:D4,label:"Heading 6",text:"###### "}],XU=[{columns:2,text:"2 columns"},{columns:3,text:"3 columns"},{columns:4,text:"4 columns"},{columns:5,text:"5 columns"}];function a7({onInsert:$,onInsertTable:M}){return S1(x,{children:[S1(x.Button,{icon:T4,label:"Insert bulleted list",onClick:()=>$("- ")},void 0,!1,void 0,this),S1(x.Button,{icon:P4,label:"Insert numbered list",onClick:()=>$("1. ")},void 0,!1,void 0,this),S1(x.Button,{icon:W4,label:"Insert task list",onClick:()=>$("- [ ] ")},void 0,!1,void 0,this),S1(x.Divider,{},void 0,!1,void 0,this),S1(x.Menu,{icon:_4,label:"Insert heading",onSelect:$,children:ZU.map(({icon:J,label:Z,text:X})=>S1(x.MenuItem,{icon:J,text:Z,value:X},X,!1,void 0,this))},void 0,!1,void 0,this),S1(x.Menu,{icon:P0,label:"Insert table",onSelect:(J)=>M(Number(J)),children:XU.map(({columns:J,text:Z})=>S1(x.MenuItem,{icon:P0,text:Z,value:String(J)},J,!1,void 0,this))},void 0,!1,void 0,this),S1(x.Divider,{},void 0,!1,void 0,this),S1(x.Button,{icon:z4,label:"Insert blockquote",onClick:()=>$("> ")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{createPortal as AU}from"react-dom";import{jsxDEV as f$}from"react/jsx-dev-runtime";function s7({anchor:$,children:M,className:J,status:Z="default"}){if(typeof document>"u")return null;let X=$.container??document.body,A=!$.isSelection,Y=J?`documint-leaf-shell ${J}`:"documint-leaf-shell";return AU(f$("div",{className:"documint-leaf-anchor","data-selection":$.isSelection?"true":"false",onPointerEnter:$.onPointerEnter,onPointerLeave:$.onPointerLeave,style:{left:`${$.left}px`,top:`${$.top}px`},children:[A?f$("div",{className:"documint-leaf-bridge"},void 0,!1,void 0,this):null,f$("div",{className:Y,"data-status":Z,children:M},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X)}import{useEffect as i7,useRef as YU,useState as o7}from"react";import{jsxDEV as j1}from"react/jsx-dev-runtime";function n7({canEdit:$,onDelete:M,onSave:J,title:Z,url:X}){let[A,Y]=o7(X),[Q,K]=o7(!1),q=YU(null),N=QU(),U=A.trim(),G=$&&U.length>0,B=$&&!Q,D=`${N}click to open`,F=`documint-link-leaf-row${Q?" is-editing":""}`;return i7(()=>{if(Q)return;Y(X)},[Q,X]),i7(()=>{if(!Q)return;q.current?.focus()},[Q]),j1("div",{className:"documint-link-leaf",children:[Z?j1("div",{className:"documint-link-leaf-title",children:Z},void 0,!1,void 0,this):null,j1("div",{className:F,children:[Q?j1(n5,{className:"documint-comment-input documint-link-leaf-input",onCancel:()=>{Y(X),K(!1)},onChange:Y,onSave:()=>{J(U),K(!1)},readOnly:!$,ref:q,rows:3,saveDisabled:!G,value:A},void 0,!1,void 0,this):j1("div",{className:"documint-link-leaf-url",children:X},void 0,!1,void 0,this),B?j1("div",{className:"documint-link-leaf-actions",children:[j1("button",{className:"documint-leaf-action","aria-label":"Edit link",onClick:()=>{if(!$)return;Y(X),K(!0)},title:"Edit link",type:"button",children:j1(E0,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this),j1("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Remove link",onClick:M,title:"Remove link",type:"button",children:j1(w1,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this),j1("div",{className:"documint-link-leaf-divider"},void 0,!1,void 0,this),j1("div",{className:"documint-link-leaf-hint",children:D},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function QU(){if(typeof navigator>"u")return"Ctrl+";let $=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/.test($)?"CMD+":"CTRL+"}import{jsxDEV as R1}from"react/jsx-dev-runtime";var KU=[{text:"Column left",value:"left"},{text:"Column right",value:"right"}],qU=[{text:"Row above",value:"above"},{text:"Row below",value:"below"}],u$={text:"Delete column",value:"delete"},S$={text:"Delete row",value:"delete"},t7={text:"Delete table",value:"delete"};function e7({canDeleteColumn:$,canDeleteRow:M,onDeleteColumn:J,onDeleteRow:Z,onDeleteTable:X,onInsertColumn:A,onInsertRow:Y}){return R1(x,{children:[R1(x.Menu,{icon:D0,label:"Column actions",onSelect:(Q)=>{if(Q===u$.value){J();return}A(Q)},children:[KU.map(({text:Q,value:K})=>R1(x.MenuItem,{icon:K2,text:Q,value:K},K,!1,void 0,this)),R1(x.MenuDivider,{},void 0,!1,void 0,this),R1(x.MenuItem,{disabled:!$,icon:w1,text:u$.text,value:u$.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this),R1(x.Menu,{icon:_0,label:"Row actions",onSelect:(Q)=>{if(Q===S$.value){Z();return}Y(Q)},children:[qU.map(({text:Q,value:K})=>R1(x.MenuItem,{icon:K2,text:Q,value:K},K,!1,void 0,this)),R1(x.MenuDivider,{},void 0,!1,void 0,this),R1(x.MenuItem,{disabled:!M,icon:w1,text:S$.text,value:S$.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this),R1(x.Divider,{},void 0,!1,void 0,this),R1(x.Menu,{icon:P0,label:"Table actions",onSelect:()=>X(),children:R1(x.MenuItem,{icon:w1,text:t7.text,value:t7.value},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as NU,useEffectEvent as $J,useLayoutEffect as UU,useMemo as GU,useRef as MJ,useState as BU}from"react";function e5($,M){if(!$||$.kind==="task-toggle")return null;if($.commentThreadIndex!==null){let J=M[$.commentThreadIndex]??null;if(!J)return null;return{kind:"comment",left:$.anchorLeft,link:$.kind==="link"?{title:$.title,url:$.url}:null,thread:J,threadIndex:$.commentThreadIndex,top:$.anchorBottom}}if($.kind!=="link")return null;return{endOffset:$.endOffset,kind:"link",left:$.anchorLeft,regionId:$.regionId,startOffset:$.startOffset,title:$.title,top:$.anchorBottom,url:$.url}}var FU=600,DU=530;function JJ({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,editorState:Z,editorViewportState:X,onVisibilityChange:A}){let Y=GU(()=>n(Z),[Z]),[Q,K]=BU(null),q=Y.start.regionId===Y.end.regionId&&Y.start.offset===Y.end.offset,N=MJ(!0),U=MJ(0),G=$J(()=>{A()}),B=$J(()=>{U.current=typeof performance<"u"?performance.now():Date.now(),N.current=!0,G()});return UU(()=>{let D=_U({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,normalizedSelection:Y,state:Z,viewport:X.get()});K((F)=>TU(F,D)?F:D)},[$,M,J,Z,X,Y.end.offset,Y.end.regionId,Y.start.offset,Y.start.regionId]),NU(()=>{if(N.current=!0,G(),!q||typeof window>"u")return;let D=window.setInterval(()=>{if((typeof performance<"u"?performance.now():Date.now())-U.current<FU){if(!N.current)N.current=!0,G();return}N.current=!N.current,G()},DU);return()=>{window.clearInterval(D)}},[q]),{leaf:Q,isVisible:()=>N.current,markActivity:B}}function _U({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,normalizedSelection:Z,state:X,viewport:A}){if(!A)return null;let Y=X.selection.focus;if(Z.start.regionId!==Z.end.regionId||Z.start.offset!==Z.end.offset)return null;let Q=$?WU(X,A):null;if(Q)return Q;let K=M?HU(X,A):null;if(K)return K;return e5(M8(X,A,Y,J.liveRanges),J.threads)}function HU($,M){let J=$.selection.focus,Z=$.documentIndex.regionIndex.get(J.regionId),X=Z?$.documentIndex.tableCellIndex.get(Z.id)??null:null;if(!Z||!X)return null;let A=$.documentIndex.blockIndex.get(Z.blockId),Y=A?.type==="table"?$.documentIndex.document.blocks[A.rootIndex]:null;if(!A||!Y||Y.type!=="table")return null;let Q=M0($,M,J),K=PU(M,Z.id),q=Math.max(1,...Y.rows.map((N)=>N.cells.length));return Q&&K!==null?{cellIndex:X.cellIndex,columnCount:q,kind:"table",left:K,rowCount:Y.rows.length,rowIndex:X.rowIndex,top:Q.top+Q.height}:null}function PU($,M){let J=$.layout.lines.find((Z)=>Z.regionId===M);return J?J.left:null}function WU($,M){let J=$.selection.focus,Z=$.documentIndex.regionIndex.get(J.regionId);if(!Z||Z.blockType!=="paragraph"||Z.text.length>0)return null;if(J.offset!==0)return null;let X=$.documentIndex.blockIndex.get(Z.blockId);if(!X||X.parentBlockId!==null)return null;let A=M0($,M,J);return A?{kind:"insertion",left:A.left,top:A.top+A.height}:null}function TU($,M){if($===M)return!0;if(!$||!M||$.kind!==M.kind)return!1;switch($.kind){case"comment":return M.kind==="comment"&&$.left===M.left&&$.link?.title===M.link?.title&&$.link?.url===M.link?.url&&$.thread===M.thread&&$.threadIndex===M.threadIndex&&$.top===M.top;case"insertion":return M.kind==="insertion"&&$.left===M.left&&$.top===M.top;case"link":return M.kind==="link"&&$.endOffset===M.endOffset&&$.left===M.left&&$.regionId===M.regionId&&$.startOffset===M.startOffset&&$.title===M.title&&$.top===M.top&&$.url===M.url;case"table":return M.kind==="table"&&$.cellIndex===M.cellIndex&&$.columnCount===M.columnCount&&$.left===M.left&&$.rowCount===M.rowCount&&$.rowIndex===M.rowIndex&&$.top===M.top}}import{useEffect as yU,useMemo as m$,useRef as ZJ,useState as VU}from"react";function XJ($){let M=m$(()=>zU($),[$]),J=m$(()=>M.join(`
29
- `),[M]),[Z,X]=VU(new Map),A=ZJ(Z),Y=ZJ(new Map);return A.current=Z,yU(()=>{if(typeof Image>"u")return;let Q=!0,K=new Set(M),q=Y.current;X((N)=>bU(N,K,q));for(let N of M){if(OU(A.current,q,N))continue;CU(N,q,X,()=>Q)}return()=>{Q=!1}},[J]),m$(()=>Z.size===0?null:{images:Z},[Z])}function zU($){return[..._M($)].sort()}function OU($,M,J){return $.get(J)?.status==="loaded"||M.has(J)}function bU($,M,J){let Z=!1,X=new Map($);for(let A of X.keys())if(!M.has(A))X.delete(A),J.delete(A),Z=!0;return Z?X:$}function CU($,M,J,Z){let X=new Image;X.decoding="async",X.crossOrigin="anonymous",M.set($,X),J((A)=>{let Y=new Map(A);return Y.set($,EU()),Y}),X.onload=()=>{if(M.delete($),!Z())return;J((A)=>{let Y=new Map(A);return Y.set($,wU(X)),Y})},X.onerror=()=>{if(M.delete($),!Z())return;J((A)=>{let Y=new Map(A);return Y.set($,jU()),Y})},X.src=$}function EU(){return{intrinsicHeight:0,intrinsicWidth:0,source:null,status:"loading"}}function wU($){return{intrinsicHeight:$.naturalHeight,intrinsicWidth:$.naturalWidth,source:$,status:"loaded"}}function jU(){return{intrinsicHeight:0,intrinsicWidth:0,source:null,status:"error"}}import{useEffect as AJ,useEffectEvent as m1,useRef as YJ,useState as RU}from"react";var LU=48;function QJ({commentState:$,editorStateRef:M,editorViewportState:J,resolveDocumentPoint:Z}){let[X,A]=RU(null),Y=YJ(null),Q=YJ(!1),K=e5(X,$.threads),q=X?.kind==="task-toggle"||K?.kind==="link"?"pointer":"text";AJ(()=>{if(X&&X.kind!=="task-toggle"&&!K)A(null)},[X,K]);let N=m1(()=>{if(Y.current!==null)window.clearTimeout(Y.current),Y.current=null}),U=m1(()=>{N(),Y.current=window.setTimeout(()=>{if(Y.current=null,!Q.current)A(null)},LU)}),G=m1(()=>{N(),A(null)}),B=m1(()=>{if(!Q.current)G()});AJ(()=>()=>{if(Y.current!==null)window.clearTimeout(Y.current)},[]);let D=m1((O)=>{let j=M.current;if(!j)return null;let f=Z(O);if(!f)return null;return $8(j,J.get(),f,$.liveRanges)}),F=m1((O)=>{if(!O){B();return}if(O.kind==="task-toggle"){N(),A((j)=>j?.kind==="task-toggle"&&j.listItemId===O.listItemId?j:O);return}if(O.commentThreadIndex!==null){if(!($.threads[O.commentThreadIndex]??null)){B();return}N();let f=O.commentThreadIndex;A((z)=>z?.kind!=="task-toggle"&&z?.commentThreadIndex===f?z:O);return}if(O.kind!=="link"){B();return}N(),A((j)=>j?.kind==="link"&&j.title===O.title&&j.url===O.url&&j.startOffset===O.startOffset&&j.endOffset===O.endOffset?j:O)}),H=m1((O)=>{F(D(O))}),b=m1(()=>{if(!Q.current)U()}),E=m1(()=>{Q.current=!0,N()}),V=m1(()=>{Q.current=!1,U()});return{canvasHandlers:{onClick:m1((O)=>{let j=D(O);if(!j||j.kind!=="link"||!O.metaKey&&!O.ctrlKey)return!1;return O.preventDefault(),O.stopPropagation(),O.currentTarget.ownerDocument.defaultView?.open(j.url,"_blank","noopener,noreferrer"),!0}),onPointerLeave:b,onPointerMove:H},cursor:q,leaf:K,leafHandlers:{onPointerEnter:E,onPointerLeave:V},resolveTarget:D}}import{useEffect as p$,useEffectEvent as D1,useLayoutEffect as fU,useRef as BJ,useState as uU}from"react";var v$=[{key:"Backspace",command:"deleteBackward"},{key:"Enter",command:"insertLineBreak"},{key:"Home",command:"moveToLineStart"},{key:"End",command:"moveToLineEnd"},{key:"Tab",command:"indent"},{key:"Tab",shiftKey:!0,command:"dedent"},{key:"ArrowLeft",modKey:!0,shiftKey:"any",command:"moveToLineStart"},{key:"ArrowRight",modKey:!0,shiftKey:"any",command:"moveToLineEnd"},{key:"ArrowUp",modKey:!0,shiftKey:"any",command:"moveToDocumentStart"},{key:"ArrowDown",modKey:!0,shiftKey:"any",command:"moveToDocumentEnd"},{key:"ArrowUp",altKey:!0,shiftKey:!0,command:"moveListItemUp"},{key:"ArrowDown",altKey:!0,shiftKey:!0,command:"moveListItemDown"},{key:"a",modKey:!0,command:"selectAll"},{key:"b",modKey:!0,command:"toggleBold"},{key:"e",modKey:!0,command:"toggleInlineCode"},{key:"i",modKey:!0,command:"toggleItalic"},{key:"u",modKey:!0,command:"toggleUnderline"},{key:"y",modKey:!0,command:"redo"},{key:"z",modKey:!0,command:"undo"},{key:"z",modKey:!0,shiftKey:!0,command:"redo"}];function KJ($,M=v$){return M.find((J)=>{let Z=J.shiftKey==="any"?!0:(J.shiftKey??!1)===($.shiftKey??!1);return J.key.toLowerCase()===$.key.toLowerCase()&&(J.altKey??!1)===($.altKey??!1)&&Z&&(J.modKey??!1)===Boolean($.metaKey||$.ctrlKey)})?.command??null}function GJ($){let M=$.documentIndex.regions.find((A)=>A.id===$.selection.anchor.regionId),J=$.documentIndex.regions.find((A)=>A.id===$.selection.focus.regionId),Z=(M?.start??0)+$.selection.anchor.offset,X=(J?.start??0)+$.selection.focus.offset;return{end:Math.max(Z,X),start:Math.min(Z,X)}}function g$($){let M=h$($);if(!M)return"";let J=$.documentIndex.regions.find((Z)=>Z.id===M.regionId);if(!J)return"";return J.text.slice(M.startOffset,M.endOffset)}function h$($){let M=kU($);if(M.start.regionId!==M.end.regionId||M.start.offset===M.end.offset)return null;return{endOffset:M.end.offset,regionId:M.start.regionId,startOffset:M.start.offset}}var qJ=28,NJ=18;function I$($,M){if(!$)return;let J=$.getBoundingClientRect();if(M.clientY<J.top+qJ){$.scrollTop=Math.max(0,$.scrollTop-NJ);return}if(M.clientY>J.bottom-qJ)$.scrollTop+=NJ}function kU($){let M=UJ($.documentIndex.regions,$.selection.anchor.regionId,$.selection.anchor.offset),J=UJ($.documentIndex.regions,$.selection.focus.regionId,$.selection.focus.offset);return M<=J?{end:$.selection.focus,start:$.selection.anchor}:{end:$.selection.anchor,start:$.selection.focus}}function UJ($,M,J){let Z=$.findIndex((X)=>X.id===M);if(Z===-1)return-1;return Z*1e6+J}var SU=64;function DJ({editorState:$,editorStateRef:M,editorViewportState:J,inputRef:Z,keybindings:X,onActivity:A,onEditorStateChange:Y}){let Q=mU(),K=()=>M.current??$,q=BJ(!1),N=BJ(!1),U=D1((_)=>{if(!_)return;A(),Y(_)}),G=D1(()=>{let _=Z.current;if(!_)return;if(typeof document>"u")return;let C=document.execCommand;if(typeof C!=="function")return;try{q.current=!0,C.call(document,"insertText",!1,"‌"),C.call(document,"delete")}catch{}finally{q.current=!1,k4(_,K())}}),B=D1(()=>{if(N.current)return;N.current=!0,G()}),D=D1(()=>{G()}),F=D1((_)=>{if(!Q)return;let C=Z.current;if(!C)return;let g=J.get(),u=M0(K(),g,_);if(!u)return;C.style.top=`${u.top}px`,C.style.left=`${u.left}px`,C.style.height=`${u.height}px`}),H=D1((_)=>{let C=Z.current;if(!C)return;F(_??K().selection.focus),C.focus({preventScroll:!Q}),k4(C,K()),B()}),b=D1((_,C)=>{let u=FJ(C,l$(_)).replace(/\r\n/g,`
30
- `).split(/(\n)/),d=_;for(let p of u){if(p.length===0)continue;let J1=p===`
31
- `?e2(d):Y2(d,p);if(!J1)continue;d=J1}return d===_?null:d}),E=D1((_,C,g)=>{let u=_.selection.focus,d={regionId:u.regionId,offset:Math.max(0,u.offset-C)},p=K1(_,{anchor:d,focus:u});return m5(p,g)}),V=D1((_)=>{if(q.current)return;let C=K(),g=gU(_.inputType);if(_.inputType==="insertText"){if(!_.data)return;_.preventDefault(),U(b(C,_.data));return}if(_.inputType==="insertReplacementText"){if(!_.data)return;_.preventDefault();let u=_.target,d=u?.selectionStart??0,p=u?.selectionEnd??d,J1=Math.max(0,p-d);U(E(C,J1,_.data));return}if(vU(_.inputType)){_.preventDefault(),U(e2(C));return}if(g==="backward"){_.preventDefault(),U(u5(C));return}if(g==="forward"){_.preventDefault(),U(S5(C));return}if(_.inputType==="historyUndo"){_.preventDefault(),U(g5(C)),D();return}if(_.inputType==="historyRedo"){_.preventDefault(),U(h5(C)),D();return}}),R=D1((_)=>{if(q.current)return;let C=K(),g=_.currentTarget.value;if(FJ(g,l$(C)).length===0){k4(_.currentTarget,C);return}U(b(C,g))}),O=D1((_)=>{let C=IU(K(),J.get(),_.nativeEvent,X);if(!C)return;_.preventDefault(),U(C)}),j=D1((_)=>{let C=g$(K());if(!C)return;_.preventDefault(),_.clipboardData.setData("text/plain",C)}),f=D1((_)=>{let C=K(),g=g$(C);if(!g)return;_.preventDefault(),_.clipboardData.setData("text/plain",g),U($4(C))}),z=D1((_)=>{let C=_.clipboardData.getData("text/plain");if(C.length===0)return;_.preventDefault(),U(m5(K(),C))}),y=D1(()=>{A();let _=Z.current;if(_)k4(_,K())}),T=D1(()=>{A(),H()});p$(()=>{let _=Z.current;if(!_)return;k4(_,$)},[$,Z]),fU(()=>{F($.selection.focus)},[$,F]),p$(()=>{let _=Z.current;if(!_)return;let C=(g)=>V(g);return _.addEventListener("beforeinput",C),()=>_.removeEventListener("beforeinput",C)},[Z,V]);let W={onCopy:j,onCut:f,onPaste:z,...Q?{}:{onKeyDown:O}};return{canvasHandlers:{...W,onFocus:T},focus:H,inputHandlers:{...W,onFocus:y,onInput:R}}}var _J="​";function mU(){let[$,M]=uU(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return!1;return window.matchMedia("(pointer: coarse)").matches});return p$(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return;let J=window.matchMedia("(pointer: coarse)"),Z=(X)=>M(X.matches);return J.addEventListener?.("change",Z),()=>J.removeEventListener?.("change",Z)},[]),$}function vU($){return $==="insertLineBreak"||$==="insertParagraph"}function gU($){switch($){case"deleteContentBackward":case"deleteComposedCharacterBackward":case"deleteSoftLineBackward":case"deleteHardLineBackward":case"deleteWordBackward":return"backward";case"deleteContentForward":case"deleteSoftLineForward":case"deleteHardLineForward":case"deleteWordForward":return"forward";default:return null}}function hU($){return $.replaceAll(_J,"")}function l$($,M=SU){let{anchor:J,focus:Z}=$.selection;if(J.regionId!==Z.regionId||J.offset!==Z.offset)return"";let X=$.documentIndex.regionIndex.get(Z.regionId);if(!X)return"";return X.text.slice(Math.max(0,Z.offset-M),Z.offset)}function FJ($,M){let J=hU($);return J.startsWith(M)?J.slice(M.length):J}function k4($,M){let J=l$(M),Z=`${_J}${J}`;$.value=Z,$.setSelectionRange(Z.length,Z.length)}function IU($,M,J,Z){if(J.key==="Delete")return S5($);let X=KJ(J,Z);if(X){if(X==="moveToLineStart"||X==="moveToLineEnd")return K$($,M.layout,X==="moveToLineStart"?"Home":"End",J.shiftKey);if(X==="moveToDocumentStart"||X==="moveToDocumentEnd")return q$($,X==="moveToDocumentStart"?"start":"end",J.shiftKey);switch(X){case"insertLineBreak":return e2($);case"deleteBackward":return u5($);case"indent":return h8($);case"dedent":return I8($);case"moveListItemUp":return p8($);case"moveListItemDown":return l8($);case"toggleBold":return M4($);case"toggleItalic":return J4($);case"toggleStrikethrough":return Z4($);case"toggleUnderline":return X4($);case"toggleInlineCode":return i8($);case"undo":return g5($);case"redo":return h5($);case"selectAll":return g8($)}}if(J.key==="ArrowLeft"||J.key==="ArrowRight")return A$($,J.key==="ArrowLeft"?-1:1,J.shiftKey);if(J.key==="ArrowUp"||J.key==="ArrowDown")return Y$($,M.layout,J.key==="ArrowUp"?-1:1,J.shiftKey);if(J.key==="PageUp"||J.key==="PageDown")return Q$($,M.layout,J.key==="PageUp"?-1:1,J.shiftKey);if(J.key.length===1&&!J.altKey&&!J.ctrlKey&&!J.metaKey)return Y2($,J.key);return null}import{useEffect as pU,useEffectEvent as r$,useLayoutEffect as lU,useMemo as rU,useRef as HJ,useState as cU}from"react";var xU=[];function PJ({editorState:$,editorStateRef:M,editorViewportState:J,onViewportScroll:Z,presence:X,scrollContainerRef:A,scheduleOverlayRender:Y}){let Q=rU(()=>{if(!X||X.length===0)return xU;return K5($.documentIndex,X)},[$.documentIndex,X]),[K,q]=cU([]),N=HJ(Q),U=HJ(K);N.current=Q,U.current=K;let G=r$((F)=>{if(dU(U.current,F))return;U.current=F,q(F)}),B=r$((F)=>{let H=N.current;if(H.length===0){G([]);return}G(q5(M.current??$,F,H))});pU(()=>{Y()},[Q,Y]),lU(()=>{if(Q.length===0){G([]);return}B(J.get())},[J,B,Q,G]);let D=r$((F)=>{if(!F.viewport||F.viewport.scrollTop===null)return;let H=A.current;if(!H)return;H.scrollTop=F.viewport.scrollTop,Z(H)});return{canvasPresence:Q.length===0?void 0:Q,presenceOverlayProps:{onSelect:D,presence:K},refreshViewportPresence:B}}function dU($,M){if($.length!==M.length)return!1;return $.every((J,Z)=>{let X=M[Z];return X!==void 0&&J.color===X.color&&J.imageUrl===X.imageUrl&&J.name===X.name&&J.viewport?.scrollTop===X.viewport?.scrollTop&&J.viewport?.status===X.viewport?.status})}import{useEffect as aU,useEffectEvent as $6,useRef as M6}from"react";function WJ({hasRunningAnimations:$,renderContent:M,renderOverlay:J,renderViewport:Z}){let X=M6(null),A=M6(!1),Y=M6(!1),Q=M6(!1),K=$6(()=>{if(typeof window>"u"||X.current!==null)return;X.current=window.requestAnimationFrame(()=>{N()})}),q=$6(()=>{if(!$?.())return;Y.current=!0,K()}),N=$6(()=>{X.current=null;let G=A.current,B=Y.current,D=Q.current;if(A.current=!1,Y.current=!1,Q.current=!1,G){Z(),q();return}if(B){if(M(),D)J();q();return}if(D)J()}),U=$6((G)=>{if(typeof window>"u")switch(G){case"viewport":Z();return;case"content":M();return;case"overlay":J();return}switch(G){case"viewport":A.current=!0;break;case"content":Y.current=!0;break;case"overlay":Q.current=!0;break}K()});return aU(()=>{return()=>{if(typeof window>"u"||X.current===null)return;window.cancelAnimationFrame(X.current),X.current=null}},[]),{scheduleRender:U}}import{useEffectEvent as c$,useLayoutEffect as TJ,useMemo as x$,useRef as d$,useState as yJ}from"react";function J6($,M){let J=M.getBoundingClientRect();return{x:$.clientX-J.left+M.scrollLeft,y:$.clientY-J.top+M.scrollTop}}function VJ({autoScrollContainer:$,canShowSelectionLeaf:M,canvasRef:J,threads:Z,editorState:X,editorStateRef:A,scrollContainerRef:Y,editorViewportState:Q,onActivity:K,onEditorStateChange:q}){let N=x$(()=>n(X),[X]),U=x$(()=>h$(X),[X]),G=x$(()=>H5(X),[X]),[B,D]=yJ(null),[F,H]=yJ(null),b=d$(null),E=d$(null),V=d$(null);TJ(()=>{let z=sU(X,Q.get(),N);D((y)=>eU(y,z)?y:z)},[X,Q,N.end.offset,N.end.regionId,N.start.offset,N.start.regionId]),TJ(()=>{let z=oU({canShowSelectionLeaf:M,currentLeaf:F,activeMarks:G,handles:B,selectionRange:U,threads:Z});H((y)=>tU(y,z)?y:z)},[G,M,B,F,U,Z]);let R=c$((z,y=!0)=>{H((T)=>T?.kind==="create"?{animateInitialComment:y,kind:"thread",left:T.left,threadIndex:z,top:T.top}:T)}),O=c$((z)=>{if(z&&V.current===z.pointerId&&z.currentTarget.hasPointerCapture(z.pointerId))z.currentTarget.releasePointerCapture(z.pointerId);b.current=null,E.current=null,V.current=null}),j=c$((z)=>{let y=Y.current,T=A.current,W=E.current;if(!y||!T||!W||V.current!==z.pointerId)return;let _=J6(z,y),C=R2(T,Q.get(),_,W);if(!C)return;z.preventDefault(),z.stopPropagation(),K(),$(z),q(K1(T,{anchor:W,focus:C}))}),f=(z)=>({onPointerCancel:(y)=>{O(y)},onPointerDown:(y)=>{let T=A.current??X,W=MG(N,z),_=z==="start"?N.start:N.end;if(!B)return;y.preventDefault(),y.stopPropagation(),V.current=y.pointerId,E.current=W,b.current=z,y.currentTarget.setPointerCapture(y.pointerId),K(),J.current?.focus({preventScroll:!0}),q(K1(T,{anchor:W,focus:_}))},onPointerMove:(y)=>{if(b.current!==z)return;j(y)},onPointerUp:(y)=>{if(b.current===z)j(y);O(y)}});return{endHandleProps:f("end"),handles:B,leaf:F,promoteLeafToThread:R,startHandleProps:f("start")}}function sU($,M,J){if(H8($.selection))return null;let Z=M0($,M,J.start),X=M0($,M,J.end);if(!Z||!X)return null;return{end:{left:X.left,top:X.top+X.height},start:{left:Z.left,top:Z.top}}}function iU($,M,J){return{activeMarks:J,kind:"create",left:M.start.left,selection:$,top:M.end.top}}function oU({activeMarks:$,canShowSelectionLeaf:M,currentLeaf:J,handles:Z,selectionRange:X,threads:A}){if(!M||!X||!Z)return null;if(J?.kind==="thread")return A[J.threadIndex]?J:null;return iU(X,Z,$)}function nU($,M){return $?.kind==="create"&&$.left===M.left&&$.selection.regionId===M.selection.regionId&&$.selection.startOffset===M.selection.startOffset&&$.selection.endOffset===M.selection.endOffset&&$G($.activeMarks,M.activeMarks)&&$.top===M.top}function tU($,M){if($===M)return!0;if(!$||!M||$.kind!==M.kind)return!1;if($.kind==="create"&&M.kind==="create")return nU($,M);return $.kind==="thread"&&M.kind==="thread"&&$.animateInitialComment===M.animateInitialComment&&$.left===M.left&&$.threadIndex===M.threadIndex&&$.top===M.top}function eU($,M){if($===M)return!0;if(!$||!M)return!1;return $.start.left===M.start.left&&$.start.top===M.start.top&&$.end.left===M.end.left&&$.end.top===M.end.top}function $G($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function MG($,M){return M==="start"?$.end:$.start}import{useEffect as JG,useMemo as bJ,useState as ZG}from"react";var f4={activeBlockBackground:"#fff1c7",activeBlockFlash:"rgba(245, 158, 11, 0.28)",background:"#fcfbf7",blockquoteRule:"rgba(14, 116, 144, 0.2)",blockquoteRuleActive:"rgba(124, 45, 18, 0.36)",blockquoteText:"#334155",caret:"#111827",checkboxCheckmark:"#f8fafc",checkboxCheckedFill:"#0f766e",checkboxCheckedStroke:"#0f766e",checkboxUncheckedFill:"#fcfffe",checkboxUncheckedStroke:"#64748b",codeBackground:"#0f172a",codeText:"#e2e8f0",commentHighlight:"#d7e3fc",commentHighlightActive:"#f4d35e",commentHighlightResolved:"#cfe9d8",commentHighlightResolvedActive:"#8dc4a0",headingRule:"rgba(15, 23, 42, 0.18)",headingText:"#0f172a",imageLoadingOverlay:"rgba(255, 255, 255, 0.42)",imagePlaceholderIcon:"rgba(14, 116, 144, 0.42)",imagePlaceholderText:"rgba(15, 23, 42, 0.58)",imageSurfaceBackground:"rgba(240, 249, 255, 0.98)",imageSurfaceBorder:"rgba(14, 116, 144, 0.22)",inlineCodeBackground:"rgba(15, 23, 42, 0.08)",inlineCodeText:"#7c2d12",insertHighlightText:"#2563eb",leafAccent:"#1d4ed8",leafBackground:"#fcfbf7",leafBorder:"rgba(148, 163, 184, 0.55)",leafButtonBackground:"rgba(15, 23, 42, 0.08)",leafButtonBorder:"rgba(148, 163, 184, 0.55)",leafButtonText:"#1f2937",leafResolvedBackground:"#cfe9d8",leafResolvedBorder:"#8dc4a0",leafSecondaryText:"#334155",leafShadow:"0 14px 40px rgba(15, 23, 42, 0.16)",leafText:"#1f2937",linkText:"#1d4ed8",listMarkerText:"#1f2937",paddingX:16,paddingY:12,paragraphText:"#1f2937",selectionBackground:"rgba(125, 211, 252, 0.35)",selectionHandleBackground:"#fcfbf7",selectionHandleBorder:"#1d4ed8",tableBodyBackground:"rgba(248, 250, 252, 0.98)",tableBorder:"rgba(148, 163, 184, 0.55)",tableHeaderBackground:"rgba(226, 232, 240, 0.95)"},u4={activeBlockBackground:"rgba(125, 211, 252, 0.12)",activeBlockFlash:"rgba(226, 232, 240, 0.12)",background:"#0b1220",blockquoteRule:"rgba(103, 232, 249, 0.34)",blockquoteRuleActive:"rgba(125, 211, 252, 0.5)",blockquoteText:"#cbd5e1",caret:"#f8fafc",checkboxCheckmark:"#082f49",checkboxCheckedFill:"#67e8f9",checkboxCheckedStroke:"#67e8f9",checkboxUncheckedFill:"#0f172a",checkboxUncheckedStroke:"#64748b",codeBackground:"#020617",codeText:"#dbeafe",commentHighlight:"rgba(96, 165, 250, 0.34)",commentHighlightActive:"#facc15",commentHighlightResolved:"rgba(74, 222, 128, 0.24)",commentHighlightResolvedActive:"#4ade80",headingRule:"rgba(226, 232, 240, 0.22)",headingText:"#f8fafc",imageLoadingOverlay:"rgba(186, 230, 253, 0.18)",imagePlaceholderIcon:"rgba(125, 211, 252, 0.44)",imagePlaceholderText:"rgba(226, 232, 240, 0.62)",imageSurfaceBackground:"rgba(15, 23, 42, 0.92)",imageSurfaceBorder:"rgba(56, 189, 248, 0.28)",inlineCodeBackground:"rgba(148, 163, 184, 0.16)",inlineCodeText:"#fdba74",insertHighlightText:"#60a5fa",leafAccent:"#93c5fd",leafBackground:"#0b1220",leafBorder:"rgba(100, 116, 139, 0.7)",leafButtonBackground:"rgba(148, 163, 184, 0.16)",leafButtonBorder:"rgba(100, 116, 139, 0.7)",leafButtonText:"#dbe4f0",leafResolvedBackground:"rgba(74, 222, 128, 0.24)",leafResolvedBorder:"#4ade80",leafSecondaryText:"#cbd5e1",leafShadow:"0 18px 44px rgba(2, 6, 23, 0.42), 0 0 0 1px rgba(148, 163, 184, 0.06)",leafText:"#dbe4f0",linkText:"#93c5fd",listMarkerText:"#e2e8f0",paddingX:16,paddingY:12,paragraphText:"#dbe4f0",selectionBackground:"rgba(56, 189, 248, 0.28)",selectionHandleBackground:"#0b1220",selectionHandleBorder:"#93c5fd",tableBodyBackground:"rgba(15, 23, 42, 0.9)",tableBorder:"rgba(100, 116, 139, 0.7)",tableHeaderBackground:"rgba(30, 41, 59, 0.96)"},zJ={...f4,activeBlockBackground:"rgba(16, 185, 129, 0.14)",activeBlockFlash:"rgba(16, 185, 129, 0.26)",background:"#f3fbf6",blockquoteRule:"rgba(5, 150, 105, 0.22)",blockquoteRuleActive:"rgba(6, 95, 70, 0.38)",blockquoteText:"#166534",caret:"#14532d",codeBackground:"#052e16",codeText:"#dcfce7",commentHighlight:"rgba(52, 211, 153, 0.26)",commentHighlightActive:"#10b981",commentHighlightResolved:"rgba(187, 247, 208, 0.96)",commentHighlightResolvedActive:"#059669",headingRule:"rgba(20, 83, 45, 0.18)",headingText:"#14532d",inlineCodeBackground:"rgba(20, 83, 45, 0.08)",inlineCodeText:"#166534",insertHighlightText:"#10b981",leafAccent:"#059669",leafBackground:"#f3fbf6",leafBorder:"rgba(22, 163, 74, 0.24)",leafButtonBackground:"rgba(20, 83, 45, 0.08)",leafButtonBorder:"rgba(22, 163, 74, 0.28)",leafButtonText:"#14532d",leafResolvedBackground:"#d1fae5",leafResolvedBorder:"#10b981",leafSecondaryText:"#166534",leafShadow:"0 14px 40px rgba(20, 83, 45, 0.14)",leafText:"#14532d",linkText:"#047857",paragraphText:"#14532d",selectionBackground:"rgba(52, 211, 153, 0.24)",selectionHandleBackground:"#f3fbf6",selectionHandleBorder:"#059669",tableBodyBackground:"rgba(243, 251, 246, 0.96)",tableBorder:"rgba(22, 163, 74, 0.24)",tableHeaderBackground:"rgba(220, 252, 231, 0.96)"},OJ={...u4,activeBlockBackground:"rgba(168, 85, 247, 0.16)",activeBlockFlash:"rgba(243, 232, 255, 0.13)",blockquoteRule:"rgba(196, 181, 253, 0.34)",blockquoteRuleActive:"rgba(216, 180, 254, 0.44)",caret:"#f5f3ff",codeBackground:"#1e1b4b",codeText:"#ede9fe",commentHighlight:"rgba(167, 139, 250, 0.28)",commentHighlightActive:"#c084fc",commentHighlightResolved:"rgba(45, 212, 191, 0.22)",commentHighlightResolvedActive:"#2dd4bf",headingRule:"rgba(233, 213, 255, 0.24)",headingText:"#f5f3ff",inlineCodeBackground:"rgba(196, 181, 253, 0.16)",inlineCodeText:"#f9a8d4",insertHighlightText:"#c084fc",leafAccent:"#d8b4fe",leafBackground:"#12091f",leafBorder:"rgba(139, 92, 246, 0.34)",leafButtonBackground:"rgba(196, 181, 253, 0.16)",leafButtonBorder:"rgba(139, 92, 246, 0.34)",leafButtonText:"#ede9fe",leafResolvedBackground:"rgba(45, 212, 191, 0.22)",leafResolvedBorder:"#2dd4bf",leafSecondaryText:"#ddd6fe",leafShadow:"0 20px 48px rgba(2, 6, 23, 0.48), 0 0 0 1px rgba(196, 181, 253, 0.08)",leafText:"#f5f3ff",linkText:"#d8b4fe",listMarkerText:"#ede9fe",paragraphText:"#ede9fe",selectionBackground:"rgba(167, 139, 250, 0.26)",selectionHandleBackground:"#12091f",selectionHandleBorder:"#d8b4fe",tableBodyBackground:"rgba(30, 27, 75, 0.88)",tableBorder:"rgba(139, 92, 246, 0.34)",tableHeaderBackground:"rgba(49, 46, 129, 0.94)"};function CJ($){let M=bJ(()=>AG($),[$]),[J,Z]=ZG(M.light),X=bJ(()=>YG(J),[J]);return JG(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function"){Z(M.light);return}let A=window.matchMedia("(prefers-color-scheme: dark)"),Y=()=>{Z(A.matches?M.dark:M.light)};if(Y(),typeof A.addEventListener==="function")return A.addEventListener("change",Y),()=>{A.removeEventListener("change",Y)};return A.addListener(Y),()=>{A.removeListener(Y)}},[M]),{theme:J,themeStyles:X}}function XG($){return"light"in $&&"dark"in $}function AG($){if(!$)return{dark:u4,light:f4};if(XG($))return $;return{dark:$,light:$}}function YG($){return{"--documint-leaf-button-bg":$.leafButtonBackground,"--documint-leaf-button-border":$.leafButtonBorder,"--documint-leaf-button-text":$.leafButtonText,"--documint-leaf-accent":$.leafAccent,"--documint-leaf-bg":$.leafBackground,"--documint-leaf-border":$.leafBorder,"--documint-leaf-font-family":'"Avenir Next", "Segoe UI", sans-serif',"--documint-leaf-shadow":$.leafShadow??void 0,"--documint-leaf-secondary-text":$.leafSecondaryText,"--documint-leaf-resolved-bg":$.leafResolvedBackground,"--documint-leaf-resolved-border":$.leafResolvedBorder,"--documint-leaf-text":$.leafText,"--documint-selection-handle-bg":$.selectionHandleBackground,"--documint-selection-handle-border":$.selectionHandleBorder}}import{useEffect as qG,useEffectEvent as L0,useRef as a$,useState as Z6}from"react";import{useMemo as QG}from"react";function EJ($){return QG(()=>KG({current:null},$),[$])}function KG($,M){return{get current(){return $.current},get(){let J=$.current;if(J!==null)return J;let Z=M();return $.current=Z,Z},invalidate(){$.current=null}}}function wJ({editorState:$,editorStateRef:M,renderResources:J,theme:Z}){let X=a$(z0()),A=a$(null),Y=a$({height:240,top:0}),[Q,K]=Z6(0),[q,N]=Z6(240),[U,G]=Z6(0),[B,D]=Z6(240),F=NG(Q),H=L0(()=>{let y=M.current??$,T=Y.current;return n6(y,{height:T.height,paddingX:Z.paddingX,paddingY:Z.paddingY,top:T.top,width:F},X.current,J)}),b=EJ(H),E=L0((y)=>{D((T)=>{let W=GG(y,Y.current.height);return T===W?T:W})}),V=L0((y)=>{let T=UG(y);Y.current=T,G((W)=>W===T.top?W:T.top)}),R=L0((y)=>{Y.current={...Y.current,top:y},G((T)=>T===y?T:y),b.invalidate()}),O=L0((y)=>{let T=A.current;if(!T)return R(y),y;T.scrollTop=y;let W=T.scrollTop;return R(W),W}),j=L0(()=>{return A.current?.scrollTop??Y.current.top}),f=L0((y)=>{let T=A.current;return T?J6(y,T):null}),z=(y)=>({onScroll:(T)=>{V(T.currentTarget),y?.onScroll?.(T)},ref:A});return qG(()=>{let y=A.current;if(!y||typeof ResizeObserver>"u")return;let T=new ResizeObserver((W)=>{let _=W[0];if(!_)return;let C=Math.max(0,Math.floor(_.contentRect.width)),g=jJ(y);Y.current={...Y.current,height:g},K((u)=>u===C?u:C),N((u)=>u===g?u:g)});return T.observe(y),()=>{T.disconnect()}},[A]),{actions:{getScrollTop:j,observePreparedViewport:E,observeScrollContainer:V,resolvePointerPoint:f,scrollTo:O},props:{getScrollContainer:z,scrollContent:{style:{height:`${B}px`}}},refs:{scrollContainer:A},state:{layoutWidth:F,preparedViewport:b,scrollContentHeight:B,surfaceWidth:Q,viewportHeight:q,viewportTop:U}}}function NG($){return Math.max(240,Math.floor($||480))}function jJ($){return Math.max(240,$.clientHeight)}function UG($){return{height:jJ($),top:$.scrollTop}}function GG($,M){return Math.max(M,Math.ceil($.totalHeight+24))}function BG(){if(typeof window>"u")return 1;return Math.max(1,window.devicePixelRatio||1)}function s$($,{paintHeight:M,paintTop:J,width:Z}){if(!$)return null;let X=Math.max(240,Math.ceil(M)),A=BG();$.width=Math.ceil(Z*A),$.height=Math.ceil(X*A),$.style.width=`${Z}px`,$.style.height=`${X}px`,$.style.transform=`translateY(${J}px)`;let Y=$.getContext("2d");if(!Y)return null;return{context:Y,devicePixelRatio:A,height:X,width:Z}}function i$($,M){return $.activeBlockType===M.activeBlockType&&$.activeCommentThreadIndex===M.activeCommentThreadIndex&&$.activeSpanKind===M.activeSpanKind&&$.canonicalContent===M.canonicalContent&&$.characterCount===M.characterCount&&$.commentThreadCount===M.commentThreadCount&&$.layoutWidth===M.layoutWidth&&$.resolvedCommentCount===M.resolvedCommentCount&&$.selectionFrom===M.selectionFrom&&$.selectionTo===M.selectionTo}var RJ=24;function fJ($,M){if(!$)return LJ(M);let J=DG($,M)??HG($,M);return J?FG(J):LJ(M)}function FG($){return{didReconcile:!0,state:$}}function LJ($){return{didReconcile:!1,state:$}}function DG($,M){let J=_G($,M);return J?K1(M,J,!1):null}function _G($,M){if(e$($.selection.anchor,$.selection.focus)){let A=o$($,M,$.selection.focus,"neutral");return A?{anchor:A,focus:A}:null}let J=EG($),Z=o$($,M,$.selection.anchor,J.anchor),X=o$($,M,$.selection.focus,J.focus);return Z&&X?{anchor:Z,focus:X}:null}function o$($,M,J,Z){let X=$.documentIndex.regionIndex.get(J.regionId);if(!X)return null;let A=t$(X,M);if(!A)return null;return{offset:zG(X.text,A.text,J.offset,Z),regionId:A.id}}function t$($,M){let J=M.documentIndex.regionIndex.get($.id);if(J)return J;if($.text.length===0)return null;let Z=VG($,M);if(Z)return Z;let X=M.documentIndex.regionPathIndex.get($.path);if(X)return X;return null}function HG($,M){if(!e$($.selection.anchor,$.selection.focus))return null;let J=PG($);if(!J)return null;let Z=TG($,M,J);if(Z===null)return null;return WG(M,Z)}function PG($){let M=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!M||M.blockType!=="paragraph"||M.text.length>0)return null;return $.documentIndex.blockIndex.get(M.blockId)?.parentBlockId===null?M:null}function WG($,M){let J=I0($.documentIndex.document,M,0,[I({text:""})]),Z={...$,documentIndex:$2($.documentIndex,J,M,0)},X=v2(Z.documentIndex,M1(M));return X?K1(Z,X,!1):null}function TG($,M,J){let Z=kJ($,J.rootIndex,"before"),X=kJ($,J.rootIndex,"after"),A=Z?t$(Z,M):null,Y=X?t$(X,M):null;if(A&&Y)return A.rootIndex<Y.rootIndex?Y.rootIndex:null;if(A)return A.rootIndex+1;if(Y)return Y.rootIndex;return null}function kJ($,M,J){let Z=J==="before"?-1:1;for(let X=M+Z;X>=0&&X<$.documentIndex.roots.length;X+=Z){let A=yG($,X,J);if(!A)continue;return A}return null}function yG($,M,J){let Z=$.documentIndex.roots[M]?.regions??[],X=J==="before"?Z.length-1:0,A=J==="before"?-1:1;for(let Y=X;Y>=0&&Y<Z.length;Y+=A){let Q=Z[Y];if(Q&&Q.text.length>0)return Q}return null}function VG($,M){let J=null;for(let Z of M.documentIndex.regions){if(Z.blockType!==$.blockType||Z.text!==$.text)continue;if(J)return null;J=Z}return J}function zG($,M,J,Z){let X=n$(J,0,$.length),A=$.slice(Math.max(0,X-RJ),X),Y=$.slice(X,Math.min($.length,X+RJ)),Q=OG(M,A,Y);if(Q!==null)return Q;let K=bG(M,A),q=CG(M,Y);if(Z==="before-suffix")return q??K??n$(J,0,M.length);return K??q??n$(J,0,M.length)}function OG($,M,J){if(M.length===0||J.length===0)return null;let Z=null,X=0;while(X<=$.length){let A=$.indexOf(M,X);if(A===-1)break;let Y=A+M.length;if($.startsWith(J,Y)){if(Z!==null)return null;Z=Y}X=A+Math.max(1,M.length)}return Z}function bG($,M){if(M.length===0)return null;let J=uJ($,M);return J===null?null:J+M.length}function CG($,M){return M.length===0?null:uJ($,M)}function uJ($,M){let J=null,Z=0;while(Z<=$.length){let X=$.indexOf(M,Z);if(X===-1)break;if(J!==null)return null;J=X,Z=X+Math.max(1,M.length)}return J}function EG($){let{anchor:M,focus:J}=$.selection;if(e$(M,J))return{anchor:"neutral",focus:"neutral"};return wG($,M,J)<=0?{anchor:"before-suffix",focus:"after-prefix"}:{anchor:"after-prefix",focus:"before-suffix"}}function wG($,M,J){let Z=$.documentIndex.regionOrderIndex.get(M.regionId),X=$.documentIndex.regionOrderIndex.get(J.regionId);if(Z===void 0||X===void 0)return 0;return Z===X?M.offset-J.offset:Z-X}function e$($,M){return $.regionId===M.regionId&&$.offset===M.offset}function n$($,M,J){return Math.max(M,Math.min($,J))}import{jsxDEV as l,Fragment as mG}from"react/jsx-dev-runtime";function A6({blocks:$}){return l(mG,{children:$.map((M)=>jG(M))},void 0,!1,void 0,this)}function jG($){switch($.type){case"blockquote":return l("blockquote",{className:"preview-block preview-block-blockquote",children:l(A6,{blocks:$.children},void 0,!1,void 0,this)},$.id,!1,void 0,this);case"code":return l("div",{className:"preview-block preview-block-code",children:[l("div",{className:"preview-rich-header",children:kG($.language,$.meta)},void 0,!1,void 0,this),l("pre",{children:l("code",{children:$.source||" "},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},$.id,!0,void 0,this);case"heading":{let M=`h${$.depth}`;return l(M,{className:"preview-block preview-block-heading",children:X6($.children)},$.id,!1,void 0,this)}case"list":return $.ordered?l("ol",{className:"preview-block preview-block-list",start:$.start??1,children:$.items.map((M)=>$M(M))},$.id,!1,void 0,this):l("ul",{className:"preview-block preview-block-list",children:$.items.map((M)=>$M(M))},$.id,!1,void 0,this);case"listItem":return $M($);case"paragraph":return l("p",{className:"preview-block preview-block-paragraph",children:X6($.children)},$.id,!1,void 0,this);case"table":return l("div",{className:"preview-block preview-block-table",children:[l("div",{className:"preview-rich-header",children:fG($.rows.length,$.rows[0]?.cells.length??0,$.align.filter((M)=>M!==null).length)},void 0,!1,void 0,this),l("div",{className:"preview-table-scroll",children:l("table",{children:l("tbody",{children:$.rows.map((M)=>l("tr",{children:M.cells.map((J)=>l("td",{children:X6(J.children)},J.id,!1,void 0,this))},M.id,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},$.id,!0,void 0,this);case"thematicBreak":return l("hr",{className:"preview-block preview-block-rule"},$.id,!1,void 0,this);case"directive":return l("pre",{className:`preview-block preview-block-directive preview-block-directive-${$.name}`,children:$.body},$.id,!1,void 0,this);case"unsupported":return l("pre",{className:"preview-block preview-block-unsupported",children:$.source},$.id,!1,void 0,this)}}function $M($){return l("li",{className:"preview-block preview-block-list-item",children:l(A6,{blocks:$.children},void 0,!1,void 0,this)},$.id,!1,void 0,this)}function X6($){return $.map((M)=>{switch(M.type){case"break":return l("br",{},M.id,!1,void 0,this);case"image":return l("span",{className:"preview-inline preview-inline-image",children:[l("img",{alt:M.alt??"",src:M.url,title:M.title??""},void 0,!1,void 0,this),l("span",{children:[l("strong",{children:uG(M.alt)},void 0,!1,void 0,this),l("small",{children:SG(M.url,M.title)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},M.id,!0,void 0,this);case"inlineCode":return l("code",{className:"preview-inline preview-inline-code",children:M.code},M.id,!1,void 0,this);case"link":return RG(M);case"text":return l("span",{className:"preview-inline",children:LG(M.text,M.marks)},M.id,!1,void 0,this);case"unsupported":return l("span",{className:"preview-inline preview-inline-unsupported",children:M.source},M.id,!1,void 0,this)}})}function RG($){return l("a",{className:"preview-inline preview-inline-link",href:$.url,children:X6($.children)},$.id,!1,void 0,this)}function LG($,M){let J=$;for(let Z of M)switch(Z){case"strikethrough":J=l("del",{children:J},void 0,!1,void 0,this);break;case"italic":J=l("em",{children:J},void 0,!1,void 0,this);break;case"bold":J=l("strong",{children:J},void 0,!1,void 0,this);break;case"underline":J=l("ins",{children:J},void 0,!1,void 0,this);break}return J}function kG($,M){return[$??"plain text",M].filter(Boolean).join(" • ")}function fG($,M,J){let Z=J>0?`${J} aligned ${J===1?"column":"columns"}`:"no alignment";return`${$} ${$===1?"row":"rows"} • ${M} ${M===1?"column":"columns"} • ${Z}`}function uG($){return $?.trim()?$:"Untitled image"}function SG($,M){return M?.trim()?`${M} • ${$}`:$}var SJ=`
32
- :where(.documint-leaf-toolbar) {
33
- --documint-leaf-toolbar-button-active-bg:
34
- color-mix(in srgb, var(--documint-leaf-accent) 16%, var(--documint-leaf-bg));
35
- --documint-leaf-toolbar-divider-color:
36
- color-mix(in srgb, var(--documint-leaf-border) 72%, transparent);
37
- --documint-leaf-toolbar-menu-border-color:
38
- color-mix(in srgb, var(--documint-leaf-border) 88%, transparent);
39
- --documint-leaf-toolbar-menu-hover-bg:
40
- color-mix(in srgb, var(--documint-leaf-accent) 12%, var(--documint-leaf-bg));
41
- --documint-leaf-toolbar-shadow-fallback:
42
- 0 14px 40px color-mix(in srgb, var(--documint-leaf-text) 16%, transparent);
43
- display: inline-flex;
44
- align-items: center;
45
- gap: 0.52rem;
46
- }
47
-
48
- :where(.documint-leaf-toolbar-group) {
49
- display: inline-flex;
50
- align-items: center;
51
- gap: 0.38rem;
52
- }
53
-
54
- :where(.documint-leaf-toolbar-divider) {
55
- width: 1px;
56
- height: 1.15rem;
57
- background: var(--documint-leaf-toolbar-divider-color);
58
- }
59
-
60
- :where(.documint-leaf-toolbar-button),
61
- :where(.documint-leaf-toolbar-menu-item) {
62
- appearance: none;
63
- display: inline-flex;
64
- align-items: center;
65
- gap: 0.36rem;
66
- border: 0;
67
- background: transparent;
68
- color: var(--documint-leaf-button-text);
69
- cursor: pointer;
70
- font: inherit;
71
- }
72
-
73
- :where(.documint-leaf-toolbar-button) {
74
- justify-content: center;
75
- min-width: 1.45rem;
76
- height: 1.45rem;
77
- padding: 0 0.12rem;
78
- border-radius: 0.38rem;
79
- line-height: 0;
80
- transition:
81
- background-color 120ms ease,
82
- color 120ms ease;
83
- }
84
-
85
- :where(.documint-leaf-toolbar-menu-shell .documint-leaf-toolbar-button) {
86
- gap: 0.18rem;
87
- }
88
-
89
- :where(.documint-leaf-toolbar-button:hover) {
90
- background: var(--documint-leaf-toolbar-button-active-bg);
91
- }
92
-
93
- :where(.documint-leaf-toolbar-button:disabled) {
94
- opacity: 0.42;
95
- cursor: default;
96
- }
97
-
98
- :where(.documint-leaf-toolbar-button:disabled:hover) {
99
- background: transparent;
100
- }
101
-
102
- :where(.documint-leaf-toolbar-button.active) {
103
- background: var(--documint-leaf-toolbar-button-active-bg);
104
- color: var(--documint-leaf-text);
105
- }
106
-
107
- :where(.documint-leaf-toolbar-menu-shell) {
108
- position: relative;
109
- }
110
-
111
- :where(.documint-leaf-toolbar-menu-chevron) {
112
- transition: transform 140ms ease;
113
- }
114
-
115
- :where(.documint-leaf-toolbar-menu-chevron.is-open) {
116
- transform: rotate(180deg);
117
- }
118
-
119
- :where(.documint-leaf-toolbar-menu) {
120
- position: absolute;
121
- top: calc(100% + 0.55rem);
122
- left: 0;
123
- display: grid;
124
- gap: 0.2rem;
125
- min-width: 10.5rem;
126
- padding: 0.35rem;
127
- border: 1px solid var(--documint-leaf-toolbar-menu-border-color);
128
- border-radius: 0.8rem;
129
- background: var(--documint-leaf-bg);
130
- box-shadow: var(--documint-leaf-shadow, var(--documint-leaf-toolbar-shadow-fallback));
131
- }
132
-
133
- :where(.documint-leaf-toolbar-menu-item) {
134
- width: 100%;
135
- padding: 0.45rem 0.55rem;
136
- border-radius: 0.55rem;
137
- line-height: 1.2;
138
- text-align: left;
139
- }
140
-
141
- :where(.documint-leaf-toolbar-menu-item:hover) {
142
- background: var(--documint-leaf-toolbar-menu-hover-bg);
143
- }
144
-
145
- :where(.documint-leaf-toolbar-menu-item:disabled) {
146
- opacity: 0.42;
147
- cursor: default;
148
- }
149
-
150
- :where(.documint-leaf-toolbar-menu-item:disabled:hover) {
151
- background: transparent;
152
- }
153
-
154
- :where(.documint-leaf-toolbar-menu-divider) {
155
- height: 1px;
156
- margin: 0.15rem 0.2rem;
157
- background: var(--documint-leaf-toolbar-divider-color);
158
- }
159
- `;var mJ=`
160
- :where(.documint-leaf-shell) {
161
- --documint-leaf-divider-color:
162
- color-mix(in srgb, var(--documint-leaf-border) 60%, transparent);
163
- --documint-leaf-shadow-fallback:
164
- 0 14px 40px color-mix(in srgb, var(--documint-leaf-text) 16%, transparent);
165
- padding: 0.8rem;
166
- border: 1px solid var(--documint-leaf-border);
167
- border-radius: 0.95rem;
168
- background: var(--documint-leaf-bg);
169
- box-shadow: var(--documint-leaf-shadow, var(--documint-leaf-shadow-fallback));
170
- color: var(--documint-leaf-text);
171
- font-family: var(--documint-leaf-font-family, "Avenir Next", "Segoe UI", sans-serif);
172
- font-size: 0.84rem;
173
- line-height: 1.45;
174
- pointer-events: auto;
175
- }
176
-
177
- :where(.documint-leaf-shell:has(> .documint-leaf-toolbar)),
178
- :where(.documint-leaf-shell:has(> .documint-comment-leaf-create)) {
179
- width: auto;
180
- padding: 0.38rem 0.58rem;
181
- }
182
-
183
- :where(.documint-leaf-shell:has(> .documint-comment-leaf-create.is-expanded)) {
184
- padding: 0.8rem;
185
- }
186
-
187
- :where(.documint-leaf-shell[data-status="resolved"]) {
188
- border-color: var(--documint-leaf-resolved-border);
189
- background: var(--documint-leaf-resolved-bg);
190
- }
191
-
192
- :where(.documint-leaf-shell p) {
193
- margin: 0;
194
- }
195
-
196
- :where(.documint-comment-leaf:not(.documint-comment-leaf-create)),
197
- :where(.documint-comment-leaf-create.is-expanded) {
198
- width: var(--documint-leaf-width, min(18rem, calc(100vw - 4rem)));
199
- }
200
-
201
- :where(.documint-link-leaf) {
202
- width: min(16rem, calc(100vw - 4rem));
203
- }
204
-
205
- ${SJ}
206
-
207
- :where(.documint-leaf-anchor) {
208
- --documint-leaf-anchor-bridge-height: 12px;
209
- position: fixed;
210
- z-index: 1000;
211
- padding-top: var(--documint-leaf-anchor-bridge-height);
212
- margin-top: calc(var(--documint-leaf-anchor-bridge-height) * -1);
213
- pointer-events: auto;
214
- }
215
-
216
- :where(.documint-leaf-anchor[data-selection="true"]) {
217
- --documint-leaf-anchor-bridge-height: 0px;
218
- padding-top: 0;
219
- margin-top: 14px;
220
- pointer-events: none;
221
- }
222
-
223
- :where(.documint-leaf-bridge) {
224
- width: 100%;
225
- height: var(--documint-leaf-anchor-bridge-height);
226
- }
227
-
228
- :where(.documint-link-leaf) {
229
- display: grid;
230
- gap: 0.3rem;
231
- min-width: 0;
232
- }
233
-
234
- :where(.documint-link-leaf-row) {
235
- display: grid;
236
- grid-template-columns: minmax(0, 1fr) auto;
237
- align-items: flex-start;
238
- gap: 0.6rem;
239
- }
240
-
241
- :where(.documint-link-leaf-row.is-editing) {
242
- grid-template-columns: minmax(0, 1fr);
243
- }
244
-
245
- :where(.documint-link-leaf-actions) {
246
- display: inline-flex;
247
- align-items: center;
248
- gap: 0.5rem;
249
- }
250
-
251
- :where(.documint-link-leaf-divider) {
252
- margin: 0.2rem 0;
253
- border-top: 1px solid var(--documint-leaf-divider-color);
254
- }
255
-
256
- :where(.documint-link-leaf-hint) {
257
- color: var(--documint-leaf-secondary-text);
258
- font-size: 0.74rem;
259
- font-style: italic;
260
- }
261
-
262
- :where(.documint-link-leaf-title) {
263
- color: var(--documint-leaf-text);
264
- font-size: 0.78rem;
265
- font-weight: 600;
266
- }
267
-
268
- :where(.documint-link-leaf-url) {
269
- min-width: 0;
270
- color: var(--documint-leaf-secondary-text);
271
- font-size: 0.76rem;
272
- line-height: 1.4;
273
- overflow-wrap: anywhere;
274
- }
275
-
276
- :where(.documint-link-leaf-input) {
277
- min-height: auto;
278
- padding-right: 0.75rem;
279
- padding-bottom: 2.1rem;
280
- overflow-wrap: anywhere;
281
- }
282
-
283
- :where(.documint-comment-leaf-header),
284
- :where(.documint-comment-leaf-actions),
285
- :where(.documint-comment-message-meta) {
286
- display: flex;
287
- align-items: center;
288
- justify-content: space-between;
289
- gap: 0.5rem;
290
- }
291
-
292
- :where(.documint-comment-leaf-header) {
293
- margin-bottom: 0.7rem;
294
- }
295
-
296
- :where(.documint-comment-leaf-link) {
297
- display: grid;
298
- gap: 0.3rem;
299
- margin-bottom: 0.8rem;
300
- padding-bottom: 0.8rem;
301
- border-bottom: 1px solid var(--documint-leaf-divider-color);
302
- }
303
-
304
- :where(.documint-comment-leaf-create) {
305
- --documint-comment-create-scale-duration: 180ms;
306
- --documint-comment-create-fade-duration: 120ms;
307
- height: auto;
308
- padding: 0;
309
- overflow: visible;
310
- }
311
-
312
- :where(.documint-comment-leaf-create-shell) {
313
- position: relative;
314
- display: grid;
315
- width: max-content;
316
- height: 100%;
317
- }
318
-
319
- :where(.documint-comment-leaf-create-shell > .documint-leaf-toolbar) {
320
- position: relative;
321
- z-index: 0;
322
- }
323
-
324
- :where(.documint-comment-leaf-create.is-expanded .documint-comment-leaf-create-shell) {
325
- width: 100%;
326
- min-height: 5.5rem;
327
- }
328
-
329
- :where(.documint-comment-leaf-create.is-expanded .documint-comment-leaf-create-shell > .documint-leaf-toolbar) {
330
- position: absolute;
331
- inset: 0;
332
- pointer-events: none;
333
- z-index: 1;
334
- }
335
-
336
- :where(.documint-comment-leaf-create-button) {
337
- width: 1.7rem;
338
- height: 1.7rem;
339
- padding: 0;
340
- line-height: 0;
341
- position: relative;
342
- z-index: 0;
343
- display: inline-flex;
344
- opacity: 1;
345
- transform: scale(1);
346
- transition:
347
- opacity var(--documint-comment-create-fade-duration) ease,
348
- transform var(--documint-comment-create-scale-duration) ease;
349
- }
350
-
351
- :where(.documint-comment-leaf-create-divider) {
352
- opacity: 1;
353
- transition: opacity var(--documint-comment-create-fade-duration) ease;
354
- }
355
-
356
- :where(.documint-comment-leaf-create-mark) {
357
- opacity: 1;
358
- transition:
359
- opacity var(--documint-comment-create-fade-duration) ease,
360
- transform var(--documint-comment-create-scale-duration) ease;
361
- }
362
-
363
- :where(.documint-comment-leaf-create.is-expanded .documint-comment-leaf-create-button),
364
- :where(.documint-comment-leaf-create.is-expanded .documint-comment-leaf-create-mark) {
365
- opacity: 0;
366
- transform: scale(0.72);
367
- pointer-events: none;
368
- }
369
-
370
- :where(.documint-comment-leaf-create.is-expanded .documint-comment-leaf-create-divider) {
371
- opacity: 0;
372
- }
373
-
374
- :where(.documint-comment-leaf-create-content) {
375
- position: absolute;
376
- top: 0;
377
- left: 0;
378
- right: 0;
379
- opacity: 0;
380
- transform: scale(0);
381
- transform-origin: top left;
382
- transition:
383
- opacity var(--documint-comment-create-fade-duration) ease,
384
- transform var(--documint-comment-create-scale-duration) ease;
385
- pointer-events: none;
386
- z-index: 1;
387
- }
388
-
389
- :where(.documint-comment-leaf-create.is-expanded .documint-comment-leaf-create-content) {
390
- position: relative;
391
- opacity: 1;
392
- transform: scale(1);
393
- pointer-events: auto;
394
- z-index: 0;
395
- }
396
-
397
- :where(.documint-comment-leaf-age) {
398
- color: var(--documint-leaf-secondary-text);
399
- font-size: 0.76rem;
400
- }
401
-
402
- :where(.documint-comment-thread) {
403
- display: grid;
404
- gap: 0.75rem;
405
- max-height: 16rem;
406
- margin-bottom: 0.8rem;
407
- overflow: auto;
408
- }
409
-
410
- :where(.documint-comment-thread.is-empty) {
411
- max-height: 0;
412
- margin-bottom: 0;
413
- overflow: hidden;
414
- }
415
-
416
- :where(.documint-comment-message) {
417
- display: grid;
418
- gap: 0.55rem;
419
- padding-bottom: 0.75rem;
420
- border-bottom: 1px solid var(--documint-leaf-divider-color);
421
- }
422
-
423
- :where(.documint-comment-message-root) {
424
- transform: translateY(-8px) scaleY(0);
425
- transform-origin: top left;
426
- opacity: 0;
427
- transition:
428
- opacity 140ms ease,
429
- transform 180ms ease;
430
- }
431
-
432
- :where(.documint-comment-message-root.is-visible) {
433
- transform: translateY(0) scaleY(1);
434
- opacity: 1;
435
- }
436
-
437
- :where(.documint-comment-message-root.is-hidden) {
438
- max-height: 0;
439
- padding-bottom: 0;
440
- border-bottom: 0;
441
- overflow: hidden;
442
- }
443
-
444
- :where(.documint-comment-message:last-child) {
445
- padding-bottom: 0;
446
- border-bottom: 0;
447
- }
448
-
449
- :where(.documint-comment-reply) {
450
- position: relative;
451
- display: block;
452
- padding-top: 0.85rem;
453
- border-top: 1px solid var(--documint-leaf-divider-color);
454
- }
455
-
456
- :where(.documint-comment-reply.is-standalone) {
457
- padding-top: 0;
458
- border-top: 0;
459
- }
460
-
461
- :where(.documint-comment-reply.is-standalone:not(.is-visible)) {
462
- max-height: 0;
463
- overflow: hidden;
464
- }
465
-
466
- :where(.documint-leaf-shell[data-status="resolved"] .documint-comment-reply) {
467
- border-top-color: color-mix(in srgb, var(--documint-leaf-resolved-border) 72%, transparent);
468
- }
469
-
470
- :where(.documint-comment-message-meta span) {
471
- color: var(--documint-leaf-secondary-text);
472
- font-size: 0.74rem;
473
- }
474
-
475
- :where(.documint-comment-actions) {
476
- display: flex;
477
- gap: 0.4rem;
478
- }
479
-
480
- :where(.documint-leaf-action) {
481
- appearance: none;
482
- display: inline-flex;
483
- align-items: center;
484
- justify-content: center;
485
- width: auto;
486
- height: auto;
487
- padding: 0;
488
- border: 0;
489
- border-radius: 0;
490
- background: transparent;
491
- color: var(--documint-leaf-button-text);
492
- cursor: pointer;
493
- font: inherit;
494
- }
495
-
496
- :where(.documint-leaf-action-text) {
497
- padding: 0.35rem 0.62rem;
498
- border: 1px solid var(--documint-leaf-button-border);
499
- border-radius: 999px;
500
- background: var(--documint-leaf-button-bg);
501
- }
502
-
503
- :where(.documint-leaf-action:not(.documint-leaf-action-text)) {
504
- line-height: 0;
505
- }
506
-
507
- :where(.documint-leaf-action:disabled) {
508
- opacity: 0.45;
509
- cursor: default;
510
- }
511
-
512
- :where(.documint-leaf-action-danger) {
513
- color: var(--documint-leaf-accent);
514
- }
515
-
516
- :where(.documint-comment-input) {
517
- box-sizing: border-box;
518
- width: 100%;
519
- min-height: 4.6rem;
520
- padding: 0.65rem 3.2rem 0.75rem 0.75rem;
521
- border: 1px solid var(--documint-leaf-border);
522
- border-radius: 0.75rem;
523
- background: var(--documint-leaf-button-bg);
524
- color: var(--documint-leaf-text);
525
- font: inherit;
526
- resize: none;
527
- }
528
-
529
- :where(.documint-leaf-shell[data-status="resolved"] .documint-comment-input) {
530
- border-color: var(--documint-leaf-resolved-border);
531
- }
532
-
533
- :where(.documint-comment-input::placeholder) {
534
- color: var(--documint-leaf-secondary-text);
535
- }
536
-
537
- :where(.documint-edit-input-field) {
538
- position: relative;
539
- width: 100%;
540
- min-width: 0;
541
- }
542
-
543
- :where(.documint-link-leaf-row > .documint-edit-input-field) {
544
- width: 100%;
545
- }
546
-
547
- :where(.documint-edit-input-cancel) {
548
- position: absolute;
549
- right: 0.7rem;
550
- top: 0.7rem;
551
- }
552
-
553
- :where(.documint-edit-input-save) {
554
- position: absolute;
555
- right: 0.7rem;
556
- bottom: calc(0.7rem + 3px);
557
- }
558
-
559
- :where(.documint-comment-reply-field) {
560
- position: relative;
561
- }
562
-
563
- :where(.documint-comment-reply-submit) {
564
- position: absolute;
565
- right: 0.7rem;
566
- bottom: calc(0.7rem + 3px);
567
- }
568
- `;var vJ=`
569
- :where(.documint) {
12
+ `)}var I8=null,dZ;function aZ(){if(I8===null)I8=new Intl.Segmenter(dZ,{granularity:"word"});return I8}var iZ=/\p{Script=Arabic}/u,D5=/\p{M}/u,t$=/\p{Nd}/u;function p8($){return iZ.test($)}function a0($){for(let M of $){let J=M.codePointAt(0);if(J>=19968&&J<=40959||J>=13312&&J<=19903||J>=131072&&J<=173791||J>=173824&&J<=177983||J>=177984&&J<=178207||J>=178208&&J<=183983||J>=183984&&J<=191471||J>=196608&&J<=201551||J>=63744&&J<=64255||J>=194560&&J<=195103||J>=12288&&J<=12351||J>=12352&&J<=12447||J>=12448&&J<=12543||J>=44032&&J<=55215||J>=65280&&J<=65519)return!0}return!1}var c8=new Set([",",".","!",":",";","?","、","。","・",")","〕","〉","》","」","』","】","〗","〙","〛","ー","々","〻","ゝ","ゞ","ヽ","ヾ"]),O2=new Set(['"',"(","[","{","“","‘","«","‹","(","〔","〈","《","「","『","【","〖","〘","〚"]),x8=new Set(["'","’"]),c1=new Set([".",",","!","?",":",";","،","؛","؟","।","॥","၊","။","၌","၍","၏",")","]","}","%",'"',"”","’","»","›","…"]),sZ=new Set([":",".","،","؛"]),oZ=new Set(["၏"]),nZ=new Set(["”","’","»","›","」","』","】","》","〉","〕",")"]);function tZ($){if(d8($))return!0;let M=!1;for(let J of $){if(c1.has(J)){M=!0;continue}if(M&&D5.test(J))continue;return!1}return M}function eZ($){for(let M of $)if(!c8.has(M)&&!c1.has(M))return!1;return $.length>0}function $X($){if(d8($))return!0;for(let M of $)if(!O2.has(M)&&!x8.has(M)&&!D5.test(M))return!1;return $.length>0}function d8($){let M=!1;for(let J of $){if(J==="\\"||D5.test(J))continue;if(O2.has(J)||c1.has(J)||x8.has(J)){M=!0;continue}return!1}return M}function MX($){let M=Array.from($),J=M.length;while(J>0){let Z=M[J-1];if(D5.test(Z)){J--;continue}if(O2.has(Z)||x8.has(Z)){J--;continue}break}if(J<=0||J===M.length)return null;return{head:M.slice(0,J).join(""),tail:M.slice(J).join("")}}function JX($,M){if($.length===0)return!1;for(let J of $)if(J!==M)return!1;return!0}function ZX($){if(!p8($)||$.length===0)return!1;return sZ.has($[$.length-1])}function XX($){if($.length===0)return!1;return oZ.has($[$.length-1])}function DX($){if($.length<2||$[0]!==" ")return null;let M=$.slice(1);if(/^\p{M}+$/u.test(M))return{space:" ",marks:M};return null}function a8($){for(let M=$.length-1;M>=0;M--){let J=$[M];if(nZ.has(J))return!0;if(!c1.has(J))return!1}return!1}function YX($,M){if(M.preserveOrdinarySpaces||M.preserveHardBreaks){if($===" ")return"preserved-space";if($==="\t")return"tab";if(M.preserveHardBreaks&&$===`
13
+ `)return"hard-break"}if($===" ")return"space";if($===" "||$===" "||$==="⁠"||$==="\uFEFF")return"glue";if($==="​")return"zero-width-break";if($==="­")return"soft-hyphen";return"text"}function i0($){return $.length===1?$[0]:$.join("")}function QX($,M,J,Z){let X=[],D=null,Y=[],Q=J,K=!1,q=0;for(let U of $){let N=YX(U,Z),A=N==="text"&&M;if(D!==null&&N===D&&A===K){Y.push(U),q+=U.length;continue}if(D!==null)X.push({text:i0(Y),isWordLike:K,kind:D,start:Q});D=N,Y=[U],Q=J+q,K=A,q+=U.length}if(D!==null)X.push({text:i0(Y),isWordLike:K,kind:D,start:Q});return X}function l8($){return $==="space"||$==="preserved-space"||$==="zero-width-break"||$==="hard-break"}var KX=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function qX($,M){let J=$.texts[M];if(J.startsWith("www."))return!0;return KX.test(J)&&M+1<$.len&&$.kinds[M+1]==="text"&&$.texts[M+1]==="//"}function UX($){return $.includes("?")&&($.includes("://")||$.startsWith("www."))}function NX($){let M=$.texts.slice(),J=$.isWordLike.slice(),Z=$.kinds.slice(),X=$.starts.slice();for(let Y=0;Y<$.len;Y++){if(Z[Y]!=="text"||!qX($,Y))continue;let Q=[M[Y]],K=Y+1;while(K<$.len&&!l8(Z[K])){Q.push(M[K]),J[Y]=!0;let q=M[K].includes("?");if(Z[K]="text",M[K]="",K++,q)break}M[Y]=i0(Q)}let D=0;for(let Y=0;Y<M.length;Y++){let Q=M[Y];if(Q.length===0)continue;if(D!==Y)M[D]=Q,J[D]=J[Y],Z[D]=Z[Y],X[D]=X[Y];D++}return M.length=D,J.length=D,Z.length=D,X.length=D,{len:D,texts:M,isWordLike:J,kinds:Z,starts:X}}function AX($){let M=[],J=[],Z=[],X=[];for(let D=0;D<$.len;D++){let Y=$.texts[D];if(M.push(Y),J.push($.isWordLike[D]),Z.push($.kinds[D]),X.push($.starts[D]),!UX(Y))continue;let Q=D+1;if(Q>=$.len||l8($.kinds[Q]))continue;let K=[],q=$.starts[Q],U=Q;while(U<$.len&&!l8($.kinds[U]))K.push($.texts[U]),U++;if(K.length>0)M.push(i0(K)),J.push(!0),Z.push("text"),X.push(q),D=U-1}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}var VX=new Set([":","-","/","×",",",".","+","–","—"]),o$=/^[A-Za-z0-9_]+[,:;]*$/,n$=/[,:;]+$/;function e$($){for(let M of $)if(t$.test(M))return!0;return!1}function r8($){if($.length===0)return!1;for(let M of $){if(t$.test(M)||VX.has(M))continue;return!1}return!0}function GX($){let M=[],J=[],Z=[],X=[];for(let D=0;D<$.len;D++){let Y=$.texts[D],Q=$.kinds[D];if(Q==="text"&&r8(Y)&&e$(Y)){let K=[Y],q=D+1;while(q<$.len&&$.kinds[q]==="text"&&r8($.texts[q]))K.push($.texts[q]),q++;M.push(i0(K)),J.push(!0),Z.push("text"),X.push($.starts[D]),D=q-1;continue}M.push(Y),J.push($.isWordLike[D]),Z.push(Q),X.push($.starts[D])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function BX($){let M=[],J=[],Z=[],X=[];for(let D=0;D<$.len;D++){let Y=$.texts[D],Q=$.kinds[D],K=$.isWordLike[D];if(Q==="text"&&K&&o$.test(Y)){let q=[Y],U=n$.test(Y),N=D+1;while(U&&N<$.len&&$.kinds[N]==="text"&&$.isWordLike[N]&&o$.test($.texts[N])){let A=$.texts[N];q.push(A),U=n$.test(A),N++}M.push(i0(q)),J.push(!0),Z.push("text"),X.push($.starts[D]),D=N-1;continue}M.push(Y),J.push(K),Z.push(Q),X.push($.starts[D])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function FX($){let M=[],J=[],Z=[],X=[];for(let D=0;D<$.len;D++){let Y=$.texts[D];if($.kinds[D]==="text"&&Y.includes("-")){let Q=Y.split("-"),K=Q.length>1;for(let q=0;q<Q.length;q++){let U=Q[q];if(!K)break;if(U.length===0||!e$(U)||!r8(U))K=!1}if(K){let q=0;for(let U=0;U<Q.length;U++){let N=Q[U],A=U<Q.length-1?`${N}-`:N;M.push(A),J.push(!0),Z.push("text"),X.push($.starts[D]+q),q+=A.length}continue}}M.push(Y),J.push($.isWordLike[D]),Z.push($.kinds[D]),X.push($.starts[D])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function _X($){let M=[],J=[],Z=[],X=[],D=0;while(D<$.len){let Y=[$.texts[D]],Q=$.isWordLike[D],K=$.kinds[D],q=$.starts[D];if(K==="glue"){let U=[Y[0]],N=q;D++;while(D<$.len&&$.kinds[D]==="glue")U.push($.texts[D]),D++;let A=i0(U);if(D<$.len&&$.kinds[D]==="text")Y[0]=A,Y.push($.texts[D]),Q=$.isWordLike[D],K="text",q=N,D++;else{M.push(A),J.push(!1),Z.push("glue"),X.push(N);continue}}else D++;if(K==="text")while(D<$.len&&$.kinds[D]==="glue"){let U=[];while(D<$.len&&$.kinds[D]==="glue")U.push($.texts[D]),D++;let N=i0(U);if(D<$.len&&$.kinds[D]==="text"){Y.push(N,$.texts[D]),Q=Q||$.isWordLike[D],D++;continue}Y.push(N)}M.push(i0(Y)),J.push(Q),Z.push(K),X.push(q)}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function bX($){let M=$.texts.slice(),J=$.isWordLike.slice(),Z=$.kinds.slice(),X=$.starts.slice();for(let D=0;D<M.length-1;D++){if(Z[D]!=="text"||Z[D+1]!=="text")continue;if(!a0(M[D])||!a0(M[D+1]))continue;let Y=MX(M[D]);if(Y===null)continue;M[D]=Y.head,M[D+1]=Y.tail+M[D+1],X[D+1]=X[D]+Y.head.length}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function HX($,M,J){let Z=aZ(),X=0,D=[],Y=[],Q=[],K=[];for(let A of Z.segment($))for(let V of QX(A.segment,A.isWordLike??!1,A.index,J)){let B=V.kind==="text";if(M.carryCJKAfterClosingQuote&&B&&X>0&&Q[X-1]==="text"&&a0(V.text)&&a0(D[X-1])&&a8(D[X-1]))D[X-1]+=V.text,Y[X-1]=Y[X-1]||V.isWordLike;else if(B&&X>0&&Q[X-1]==="text"&&eZ(V.text)&&a0(D[X-1]))D[X-1]+=V.text,Y[X-1]=Y[X-1]||V.isWordLike;else if(B&&X>0&&Q[X-1]==="text"&&XX(D[X-1]))D[X-1]+=V.text,Y[X-1]=Y[X-1]||V.isWordLike;else if(B&&X>0&&Q[X-1]==="text"&&V.isWordLike&&p8(V.text)&&ZX(D[X-1]))D[X-1]+=V.text,Y[X-1]=!0;else if(B&&!V.isWordLike&&X>0&&Q[X-1]==="text"&&V.text.length===1&&V.text!=="-"&&V.text!=="—"&&JX(D[X-1],V.text))D[X-1]+=V.text;else if(B&&!V.isWordLike&&X>0&&Q[X-1]==="text"&&(tZ(V.text)||V.text==="-"&&Y[X-1]))D[X-1]+=V.text;else D[X]=V.text,Y[X]=V.isWordLike,Q[X]=V.kind,K[X]=V.start,X++}for(let A=1;A<X;A++)if(Q[A]==="text"&&!Y[A]&&d8(D[A])&&Q[A-1]==="text")D[A-1]+=D[A],Y[A-1]=Y[A-1]||Y[A],D[A]="";for(let A=X-2;A>=0;A--)if(Q[A]==="text"&&!Y[A]&&$X(D[A])){let V=A+1;while(V<X&&D[V]==="")V++;if(V<X&&Q[V]==="text")D[V]=D[A]+D[V],K[V]=K[A],D[A]=""}let q=0;for(let A=0;A<X;A++){let V=D[A];if(V.length===0)continue;if(q!==A)D[q]=V,Y[q]=Y[A],Q[q]=Q[A],K[q]=K[A];q++}D.length=q,Y.length=q,Q.length=q,K.length=q;let U=_X({len:q,texts:D,isWordLike:Y,kinds:Q,starts:K}),N=bX(BX(FX(GX(AX(NX(U))))));for(let A=0;A<N.len-1;A++){let V=DX(N.texts[A]);if(V===null)continue;if(N.kinds[A]!=="space"&&N.kinds[A]!=="preserved-space"||N.kinds[A+1]!=="text"||!p8(N.texts[A+1]))continue;N.texts[A]=V.space,N.isWordLike[A]=!1,N.kinds[A]=N.kinds[A]==="preserved-space"?"preserved-space":"space",N.texts[A+1]=V.marks+N.texts[A+1],N.starts[A+1]=N.starts[A]+V.space.length}return N}function PX($,M){if($.len===0)return[];if(!M.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len}];let J=[],Z=0;for(let X=0;X<$.len;X++){if($.kinds[X]!=="hard-break")continue;J.push({startSegmentIndex:Z,endSegmentIndex:X,consumedEndSegmentIndex:X+1}),Z=X+1}if(Z<$.len)J.push({startSegmentIndex:Z,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len});return J}function $9($,M,J="normal"){let Z=rZ(J),X=Z.mode==="pre-wrap"?xZ($):cZ($);if(X.length===0)return{normalized:X,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let D=HX(X,M,Z);return{normalized:X,chunks:PX(D,Z),...D}}var x1=null,M9=new Map,d1=null,zX=/\p{Emoji_Presentation}/u,WX=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,i8=null,J9=new Map;function s8(){if(x1!==null)return x1;if(typeof OffscreenCanvas<"u")return x1=new OffscreenCanvas(1,1).getContext("2d"),x1;if(typeof document<"u")return x1=document.createElement("canvas").getContext("2d"),x1;throw Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function EX($){let M=M9.get($);if(!M)M=new Map,M9.set($,M);return M}function X1($,M){let J=M.get($);if(J===void 0)J={width:s8().measureText($).width,containsCJK:a0($)},M.set($,J);return J}function a1(){if(d1!==null)return d1;if(typeof navigator>"u")return d1={lineFitEpsilon:0.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},d1;let $=navigator.userAgent,J=navigator.vendor==="Apple Computer, Inc."&&$.includes("Safari/")&&!$.includes("Chrome/")&&!$.includes("Chromium/")&&!$.includes("CriOS/")&&!$.includes("FxiOS/")&&!$.includes("EdgiOS/"),Z=$.includes("Chrome/")||$.includes("Chromium/")||$.includes("CriOS/")||$.includes("Edg/");return d1={lineFitEpsilon:J?0.015625:0.005,carryCJKAfterClosingQuote:Z,preferPrefixWidthsForBreakableRuns:J,preferEarlySoftHyphenBreak:J},d1}function TX($){let M=$.match(/(\d+(?:\.\d+)?)\s*px/);return M?parseFloat(M[1]):16}function o8(){if(i8===null)i8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return i8}function yX($){return zX.test($)||$.includes("️")}function Z9($){return WX.test($)}function wX($,M){let J=J9.get($);if(J!==void 0)return J;let Z=s8();Z.font=$;let X=Z.measureText("\uD83D\uDE00").width;if(J=0,X>M+0.5&&typeof document<"u"&&document.body!==null){let D=document.createElement("span");D.style.font=$,D.style.display="inline-block",D.style.visibility="hidden",D.style.position="absolute",D.textContent="\uD83D\uDE00",document.body.appendChild(D);let Y=D.getBoundingClientRect().width;if(document.body.removeChild(D),X-Y>0.5)J=X-Y}return J9.set($,J),J}function OX($){let M=0,J=o8();for(let Z of J.segment($))if(yX(Z.segment))M++;return M}function CX($,M){if(M.emojiCount===void 0)M.emojiCount=OX($);return M.emojiCount}function D1($,M,J){if(J===0)return M.width;return M.width-CX($,M)*J}function X9($,M,J,Z){if(M.graphemeWidths!==void 0)return M.graphemeWidths;let X=[],D=o8();for(let Y of D.segment($)){let Q=X1(Y.segment,J);X.push(D1(Y.segment,Q,Z))}return M.graphemeWidths=X.length>1?X:null,M.graphemeWidths}function D9($,M,J,Z){if(M.graphemePrefixWidths!==void 0)return M.graphemePrefixWidths;let X=[],D=o8(),Y="";for(let Q of D.segment($)){Y+=Q.segment;let K=X1(Y,J);X.push(D1(Y,K,Z))}return M.graphemePrefixWidths=X.length>1?X:null,M.graphemePrefixWidths}function Y9($,M){let J=s8();J.font=$;let Z=EX($),X=TX($),D=M?wX($,X):0;return{cache:Z,fontSize:X,emojiCorrection:D}}function Y5($){return $==="space"||$==="preserved-space"||$==="tab"||$==="zero-width-break"||$==="soft-hyphen"}function jX($,M){while(M<$.widths.length){let J=$.kinds[M];if(J!=="space"&&J!=="zero-width-break"&&J!=="soft-hyphen")break;M++}return M}function LX($,M){if(M<=0)return 0;let J=$%M;if(Math.abs(J)<=0.000001)return M;return M-J}function Q9($,M,J,Z){if(!Z||M===null)return $[J];return M[J]-(J>0?M[J-1]:0)}function RX($,M,J,Z,X,D){let Y=0,Q=M;while(Y<$.length){let K=D?M+$[Y]:Q+$[Y];if((Y+1<$.length?K+X:K)>J+Z)break;Q=K,Y++}return{fitCount:Y,fittedWidth:Q}}function kX($,M,J){let{widths:Z,kinds:X,breakableWidths:D,breakablePrefixWidths:Y}=$;if(Z.length===0)return 0;let Q=a1(),K=Q.lineFitEpsilon,q=0,U=0,N=!1,A=0,V=0,B=0,G=0,b=-1,P=0;function y(){b=-1,P=0}function z(W=B,F=G,H=U){q++,J?.({startSegmentIndex:A,startGraphemeIndex:V,endSegmentIndex:W,endGraphemeIndex:F,width:H}),U=0,N=!1,y()}function L(W,F){N=!0,A=W,V=0,B=W+1,G=0,U=F}function R(W,F,H){N=!0,A=W,V=F,B=W,G=F+1,U=H}function m(W,F){if(!N){L(W,F);return}U+=F,B=W+1,G=0}function E(W,F){if(!Y5(X[W]))return;b=W+1,P=U-F}function _(W){j(W,0)}function j(W,F){let H=D[W],v=Y[W]??null;for(let h=F;h<H.length;h++){let l=Q9(H,v,h,Q.preferPrefixWidthsForBreakableRuns);if(!N){R(W,h,l);continue}if(U+l>M+K)z(),R(W,h,l);else U+=l,B=W,G=h+1}if(N&&B===W&&G===H.length)B=W+1,G=0}let C=0;while(C<Z.length){if(!N){if(C=jX($,C),C>=Z.length)break}let W=Z[C],F=X[C];if(!N){if(W>M&&D[C]!==null)_(C);else L(C,W);E(C,W),C++;continue}if(U+W>M+K){if(Y5(F)){m(C,W),z(C+1,0,U-W),C++;continue}if(b>=0){if(B>b||B===b&&G>0){z();continue}z(b,0,P);continue}if(W>M&&D[C]!==null){z(),_(C),C++;continue}z();continue}m(C,W),E(C,W),C++}if(N)z();return q}function K9($,M,J){if($.simpleLineWalkFastPath)return kX($,M,J);let{widths:Z,lineEndFitAdvances:X,lineEndPaintAdvances:D,kinds:Y,breakableWidths:Q,breakablePrefixWidths:K,discretionaryHyphenWidth:q,tabStopAdvance:U,chunks:N}=$;if(Z.length===0||N.length===0)return 0;let A=a1(),V=A.lineFitEpsilon,B=0,G=0,b=!1,P=0,y=0,z=0,L=0,R=-1,m=0,E=0,_=null;function j(){R=-1,m=0,E=0,_=null}function C(T=z,k=L,f=G){B++,J?.({startSegmentIndex:P,startGraphemeIndex:y,endSegmentIndex:T,endGraphemeIndex:k,width:f}),G=0,b=!1,j()}function W(T,k){b=!0,P=T,y=0,z=T+1,L=0,G=k}function F(T,k,f){b=!0,P=T,y=k,z=T,L=k+1,G=f}function H(T,k){if(!b){W(T,k);return}G+=k,z=T+1,L=0}function v(T,k){if(!Y5(Y[T]))return;let f=Y[T]==="tab"?0:X[T],d=Y[T]==="tab"?k:D[T];R=T+1,m=G-k+f,E=G-k+d,_=Y[T]}function h(T){l(T,0)}function l(T,k){let f=Q[T],d=K[T]??null;for(let I=k;I<f.length;I++){let U0=Q9(f,d,I,A.preferPrefixWidthsForBreakableRuns);if(!b){F(T,I,U0);continue}if(G+U0>M+V)C(),F(T,I,U0);else G+=U0,z=T,L=I+1}if(b&&z===T&&L===f.length)z=T+1,L=0}function p(T){if(_!=="soft-hyphen")return!1;let k=Q[T];if(k===null)return!1;let f=A.preferPrefixWidthsForBreakableRuns?K[T]??k:k,d=f!==k,{fitCount:I,fittedWidth:U0}=RX(f,G,M,V,q,d);if(I===0)return!1;if(G=U0,z=T,L=I,j(),I===k.length)return z=T+1,L=0,!0;return C(T,I,U0+q),l(T,I),!0}function O(T){B++,J?.({startSegmentIndex:T.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:T.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),j()}for(let T=0;T<N.length;T++){let k=N[T];if(k.startSegmentIndex===k.endSegmentIndex){O(k);continue}b=!1,G=0,P=k.startSegmentIndex,y=0,z=k.startSegmentIndex,L=0,j();let f=k.startSegmentIndex;while(f<k.endSegmentIndex){let d=Y[f],I=d==="tab"?LX(G,U):Z[f];if(d==="soft-hyphen"){if(b)z=f+1,L=0,R=f+1,m=G+q,E=G+q,_=d;f++;continue}if(!b){if(I>M&&Q[f]!==null)h(f);else W(f,I);v(f,I),f++;continue}if(G+I>M+V){let z0=G+(d==="tab"?0:X[f]),_0=G+(d==="tab"?I:D[f]);if(_==="soft-hyphen"&&A.preferEarlySoftHyphenBreak&&m<=M+V){C(R,0,E);continue}if(_==="soft-hyphen"&&p(f)){f++;continue}if(Y5(d)&&z0<=M+V){H(f,I),C(f+1,0,_0),f++;continue}if(R>=0&&m<=M+V){if(z>R||z===R&&L>0){C();continue}let R1=R;C(R1,0,E),f=R1;continue}if(I>M&&Q[f]!==null){C(),h(f),f++;continue}C();continue}H(f,I),v(f,I),f++}if(b){let d=R===k.consumedEndSegmentIndex?E:G;C(k.consumedEndSegmentIndex,0,d)}}return B}var n8=null,q9=new WeakMap;function N9(){if(n8===null)n8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return n8}function fX($){if($)return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]};return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[]}}function mX($,M,J){let Z=N9(),X=a1(),{cache:D,emojiCorrection:Y}=Y9(M,Z9($.normalized)),Q=D1("-",X1("-",D),Y),q=D1(" ",X1(" ",D),Y)*8;if($.len===0)return fX(J);let U=[],N=[],A=[],V=[],B=$.chunks.length<=1,G=J?[]:null,b=[],P=[],y=J?[]:null,z=Array.from({length:$.len}),L=Array.from({length:$.len});function R(_,j,C,W,F,H,v,h){if(F!=="text"&&F!=="space"&&F!=="zero-width-break")B=!1;if(U.push(j),N.push(C),A.push(W),V.push(F),G?.push(H),b.push(v),P.push(h),y!==null)y.push(_)}for(let _=0;_<$.len;_++){z[_]=U.length;let j=$.texts[_],C=$.isWordLike[_],W=$.kinds[_],F=$.starts[_];if(W==="soft-hyphen"){R(j,0,Q,Q,W,F,null,null),L[_]=U.length;continue}if(W==="hard-break"){R(j,0,0,0,W,F,null,null),L[_]=U.length;continue}if(W==="tab"){R(j,0,0,0,W,F,null,null),L[_]=U.length;continue}let H=X1(j,D);if(W==="text"&&H.containsCJK){let p="",O=0;for(let T of Z.segment(j)){let k=T.segment;if(p.length===0){p=k,O=T.index;continue}if(O2.has(p)||c8.has(k)||c1.has(k)||X.carryCJKAfterClosingQuote&&a0(k)&&a8(p)){p+=k;continue}let f=X1(p,D),d=D1(p,f,Y);R(p,d,d,d,"text",F+O,null,null),p=k,O=T.index}if(p.length>0){let T=X1(p,D),k=D1(p,T,Y);R(p,k,k,k,"text",F+O,null,null)}L[_]=U.length;continue}let v=D1(j,H,Y),h=W==="space"||W==="preserved-space"||W==="zero-width-break"?0:v,l=W==="space"||W==="zero-width-break"?0:v;if(C&&j.length>1){let p=X9(j,H,D,Y),O=X.preferPrefixWidthsForBreakableRuns?D9(j,H,D,Y):null;R(j,v,h,l,W,F,p,O)}else R(j,v,h,l,W,F,null,null);L[_]=U.length}let m=SX($.chunks,z,L),E=G===null?null:s$($.normalized,G);if(y!==null)return{widths:U,lineEndFitAdvances:N,lineEndPaintAdvances:A,kinds:V,simpleLineWalkFastPath:B,segLevels:E,breakableWidths:b,breakablePrefixWidths:P,discretionaryHyphenWidth:Q,tabStopAdvance:q,chunks:m,segments:y};return{widths:U,lineEndFitAdvances:N,lineEndPaintAdvances:A,kinds:V,simpleLineWalkFastPath:B,segLevels:E,breakableWidths:b,breakablePrefixWidths:P,discretionaryHyphenWidth:Q,tabStopAdvance:q,chunks:m}}function SX($,M,J){let Z=[];for(let X=0;X<$.length;X++){let D=$[X],Y=D.startSegmentIndex<M.length?M[D.startSegmentIndex]:J[J.length-1]??0,Q=D.endSegmentIndex<M.length?M[D.endSegmentIndex]:J[J.length-1]??0,K=D.consumedEndSegmentIndex<M.length?M[D.consumedEndSegmentIndex]:J[J.length-1]??0;Z.push({startSegmentIndex:Y,endSegmentIndex:Q,consumedEndSegmentIndex:K})}return Z}function uX($,M,J,Z){let X=$9($,a1(),Z?.whiteSpace);return mX(X,M,J)}function A9($,M,J){return uX($,M,!0,J)}function vX($){return $}function U9($,M,J){let Z=J.get($);if(Z!==void 0)return Z;Z=[];let X=N9();for(let D of X.segment(M[$]))Z.push(D.segment);return J.set($,Z),Z}function hX($){let M=q9.get($);if(M!==void 0)return M;return M=new Map,q9.set($,M),M}function gX($,M,J,Z){return Z>0&&$[Z-1]==="soft-hyphen"&&!(M===Z&&J>0)}function IX($,M,J,Z,X,D,Y){let Q="",K=gX(M,Z,X,D);for(let q=Z;q<D;q++){if(M[q]==="soft-hyphen"||M[q]==="hard-break")continue;if(q===Z&&X>0)Q+=U9(q,$,J).slice(X).join("");else Q+=$[q]}if(Y>0){if(K)Q+="-";Q+=U9(D,$,J).slice(Z===D?X:0,Y).join("")}else if(K)Q+="-";return Q}function pX($,M,J,Z,X,D,Y){return{text:IX($.segments,$.kinds,M,Z,X,D,Y),width:J,start:{segmentIndex:Z,graphemeIndex:X},end:{segmentIndex:D,graphemeIndex:Y}}}function lX($,M,J){return pX($,M,J.width,J.startSegmentIndex,J.startGraphemeIndex,J.endSegmentIndex,J.endGraphemeIndex)}function V9($,M,J){let Z=[];if($.widths.length===0)return{lineCount:0,height:0,lines:Z};let X=hX($),D=K9(vX($),M,(Y)=>{Z.push(lX($,X,Y))});return{lineCount:D,height:D*J,lines:Z}}function t8($,M,J){let Z=$.image?M.images.get($.image.url)??null:null,X=$.image?.width??null,D=Math.min(J,X??240),Y=Math.max(120,Math.round(D*0.5625));if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return{height:Y,width:D};let Q=Math.min(J,X??Z.intrinsicWidth),K=Math.min(1,Q/Z.intrinsicWidth);return{height:Math.max(48,Math.round(Z.intrinsicHeight*K)),width:Math.max(48,Math.round(Z.intrinsicWidth*K))}}function G9($,M){if(!$.image)return`${$.kind}:missing-image`;let J=M.images.get($.image.url);return`${$.kind}:${$.image.url}:${$.image.width??0}:${J?.status??"loading"}:${J?.intrinsicWidth??0}:${J?.intrinsicHeight??0}`}var B9=[{fontSize:32,lineHeight:36},{fontSize:26,lineHeight:32},{fontSize:21,lineHeight:28},{fontSize:21,lineHeight:28},{fontSize:19,lineHeight:26},{fontSize:18,lineHeight:26}],Q5;function i1($){if($?.type==="heading"){let{fontSize:M}=b9($.depth);return`700 ${M}px "Iowan Old Style", "Palatino Linotype", serif`}switch($?.type){case"code":return"15px ui-monospace, SFMono-Regular, Menlo, monospace";default:return'16px "Iowan Old Style", "Palatino Linotype", serif'}}function E1($,M){if($?.type==="heading")return b9($.depth).lineHeight;if($?.type==="code")return 22;return M}function b9($){return B9[$-1]??B9.at(-1)}function s1($,M,J,Z,X,D,Y){let Q=`${q5(M,Y)}:${X}:${D}:${J}`,K=$.measuredLines.get(Q);if(K)return K;let q=cX($,M,J,Z,X,D,Y);return r$($,Q,q)}function K5($,M,J,Z,X,D,Y,Q){let K=`${q5(M,Q)}:${J}:${Z}:${D}:${Y}`,q=$.lineBoundaries.get(K);if(q)return q;let U=P9();if(!U)return _9(X);let N=[{left:0,offset:0}],A=0,V=M.inlines.filter((B)=>B.end>J&&B.start<Z);if(V.length===0)return _9(X);for(let B of V){let G=Math.max(J,B.start),b=Math.min(Z,B.end),P=M.text.slice(G,b),y=G-J;if(B.kind==="image"){let z=t8(B,Q,Y).width;A+=z,y+=P.length,N.push({left:A,offset:y});continue}U.font=H9(D,B.marks);for(let z of Array.from(P))A+=z9($,U,z),y+=z.length,N.push({left:A,offset:y})}return c$($,K,N)}function rX($,M,J,Z){let X=`${J}::${Z}::${M}`,D=$.preparedText.get(X);if(D)return D;let Y=A9(M,J,{whiteSpace:Z});return l$($,X,Y)}function cX($,M,J,Z,X,D,Y){let Q=M.text;if(Q.length===0)return[{end:0,height:D,start:0,text:"",width:0}];if(sX(M))return dX($,M,J,X,D,Y);try{let K=rX($,Q,J,$D(Z));return V9(K,X,D).lines.map((U)=>({end:F9(K.segments,U.end),height:D,start:F9(K.segments,U.start),text:U.text,width:U.width}))}catch{return xX(Q,X,D)}}function F9($,M){let J=0;for(let D=0;D<M.segmentIndex;D+=1)J+=$[D]?.length??0;let Z=$[M.segmentIndex]??"",X=Array.from(Z);for(let D=0;D<M.graphemeIndex;D+=1)J+=X[D]?.length??0;return J}function _9($){let M=[{left:0,offset:0}],J=0,Z=0;for(let X of Array.from($))J+=9,Z+=X.length,M.push({left:J,offset:Z});return M}function xX($,M,J){let Z=Math.max(1,Math.floor(M/9)),X=MD($,Z),D=0;return X.map((Y)=>{let Q=D,K=Q+Y.length;return D=K,{end:K,height:J,start:Q,text:Y,width:Y.length*9}})}function dX($,M,J,Z,X,D){let Y=iX($,P9(),M,J,Z,X,D);if(Y.length===0)return[{end:0,height:X,start:0,text:"",width:0}];return aX(Y,M.text,Z,X)}function aX($,M,J,Z){let X=[],D=0;while(D<$.length){let Y=$[D].start;if($[D].text===`
14
+ `){X.push({end:Y,height:Z,start:Y,text:"",width:0}),D+=1;continue}let Q=0,K=0,q=D,U=-1,N=Z;while(q<$.length){let V=$[q];if(V.text===`
15
+ `)break;let B=Q+V.width;if(B>J&&q>D)break;if(Q=B,N=Math.max(N,V.height),V.breakable)U=q,K=Q;q+=1}if(q===$.length||$[q]?.text===`
16
+ `){let V=$[q-1]?.end??Y;X.push({end:V,height:N,start:Y,text:M.slice(Y,V),width:Q}),D=q<$.length&&$[q]?.text===`
17
+ `?q+1:q;continue}if(U>=D){let V=$[U].end;X.push({end:V,height:N,start:Y,text:M.slice(Y,V),width:K}),D=U+1;continue}let A=$[Math.max(D,q-1)].end;X.push({end:A,height:N,start:Y,text:M.slice(Y,A),width:Q}),D=Math.max(D+1,q)}return X}function iX($,M,J,Z,X,D,Y){let Q=[];for(let K of J.inlines){if(K.kind==="image"){let U=t8(K,Y,X);Q.push({breakable:!0,end:K.end,height:U.height,start:K.start,text:K.text,width:U.width});continue}if(M)M.font=H9(Z,K.marks);let q=K.start;for(let U of Array.from(K.text)){let N=q,A=N+U.length;Q.push({breakable:/\s/.test(U),end:A,height:D,start:N,text:U,width:U===`
18
+ `?0:z9($,M,U)}),q=A}}return Q}function sX($){return $.inlines.some((M)=>M.kind==="image"||eX(M))}function q5($,M){return[$.path,tX($.text),oX($,M)].join(":")}function oX($,M){return $.inlines.map((J)=>`${J.start}-${J.end}:${nX(J,M)}`).join("|")}function nX($,M){if($.kind==="image"&&$.image)return G9($,M);return`${$.kind}:${$.inlineCode?1:0}:${$.marks.join(",")}:${$.link?.url??""}`}function tX($){let M=2166136261;for(let J of $)M^=J.charCodeAt(0),M=Math.imul(M,16777619);return(M>>>0).toString(36)}function eX($){return $.marks.includes("italic")||$.marks.includes("bold")}function H9($,M){let J=[];if(M.includes("italic"))J.push("italic");if(M.includes("bold"))J.push("700");return J.length>0?`${J.join(" ")} ${$}`:$}function P9(){if(Q5!==void 0)return Q5;return Q5=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,Q5}function z9($,M,J){if(!M)return 9;let Z=M.font,X=d$($,Z),D=X.get(J);if(D!==void 0)return D;let Y=M.measureText(J).width;return X.set(J,Y),Y}function $D($){return $?.type==="code"?"pre-wrap":"normal"}function MD($,M){if($.length===0)return[""];let J=$.split(`
19
+ `),Z=[];for(let X of J){if(X.length===0){Z.push("");continue}let D=X;while(D.length>M){let Y=D.slice(0,M),Q=Y.lastIndexOf(" ");if(Q<=0){Z.push(Y),D=D.slice(M);continue}Z.push(Y.slice(0,Q)),D=D.slice(Q+1)}Z.push(D)}return Z}var C2=10,o1=8,e8=120;function W9($,M,J,Z,X,D,Y,Q,K,q){let U=Math.max(1,...D.rows.map((G)=>G.cells.length)),A=Math.max(e8,K.width-Y-K.paddingX)/U,V=JD(Z),B=Q;for(let G=0;G<D.rows.length;G+=1){let b=ZD(V.get(G)??[],X,D,A,C2,K.lineHeight,q),P=Math.max(K.lineHeight+o1*2,...b.map((y)=>y.measuredLines.reduce((z,L)=>z+L.height,0)+o1*2));for(let y of b){let z=Y+y.cellIndex*A,L=B+o1;for(let R of y.measuredLines){let m={blockId:y.container.blockId,boundaries:K5(X,y.container,R.start,R.end,R.text,y.font,A-C2*2,q),regionId:y.container.id,end:R.end,font:y.font,height:R.height,left:z+C2,start:R.start,text:R.text,top:L,width:R.width};$.push(m),$6(M,m),L+=R.height}J.set(y.container.id,{bottom:B+P,left:z,right:z+A,top:B})}DD(M,D.id,B,B+P),B+=P}return B+K.blockGap}function JD($){let M=new Map;for(let J of $){let Z=XD(J.path);if(!Z)continue;let X=M.get(Z.rowIndex)??[];X.push({cellIndex:Z.cellIndex,container:J}),M.set(Z.rowIndex,X)}return M}function ZD($,M,J,Z,X,D,Y){return[...$].sort((Q,K)=>Q.cellIndex-K.cellIndex).map(({cellIndex:Q,container:K})=>{let q=i1(J),U=E1(J,D),N=s1(M,K,q,J,Math.max(40,Z-X*2),U,Y);return{cellIndex:Q,container:K,font:q,lineHeight:U,measuredLines:N}})}function XD($){let M=/\.rows\.(\d+)\.cells\.(\d+)$/.exec($);if(!M)return null;return{cellIndex:Number(M[2]),rowIndex:Number(M[1])}}function DD($,M,J,Z){let X=$.get(M);$.set(M,{bottom:X?Math.max(X.bottom,Z):Z,top:X?Math.min(X.top,J):J})}var YD={blockGap:16,charWidth:9,indentWidth:24,lineHeight:24,paddingX:16,paddingY:12},QD=24,KD=16,qD=6,UD=10,ND=4;function U5($){let M=Math.max(12,Math.floor($.width/9)),J=Math.max(1,Math.ceil($.text.length/M));return{estimatedHeight:J*24,lineCount:J,width:$.width}}function N5($,M,J=W1(),Z=null){let X=Z??{images:new Map},D={...YD,...M},Y=[],Q=new Map,K=new Map($.regions.map((G)=>[G.id,{textLength:G.text.length}])),q=new Map($.blocks.map((G)=>[G.id,G.depth])),U=new Map($.blocks.map((G)=>[G.id,G])),N=L2($.document.blocks),A=new Map,V=D.paddingY;for(let G=0;G<$.regions.length;G+=1){let b=$.regions[G],P=q.get(b.blockId)??0,y=D.paddingX+P*D.indentWidth,z=Math.max(40,D.width-y-D.paddingX),L=N.get(b.blockId)??null;if(L?.type==="table"){let E=U.get(b.blockId)?.regionIds??[],_=$.regions.slice(G,G+E.length);V=W9(Y,A,Q,_,J,L,y,V,D,X),G+=_.length-1;continue}V=AD(Y,A,Q,b,J,L,y,V,z,D,X);let R=V5(U,N,$.regions,G,D.blockGap);V+=R;let m=A.get(b.blockId);if(m)m.bottom=Math.max(m.bottom,V)}return{blocks:$.blocks.map((G)=>{let b=A.get(G.id),P=b?.top??D.paddingY;return{bottom:b?.bottom??P+D.lineHeight/2,depth:G.depth,id:G.id,top:P,type:G.type}}),regionBounds:GD(Y,Q),regionLineIndices:VD(Y),regionMetrics:K,height:Math.max(V,D.paddingY),lines:Y,options:D,width:D.width}}function AD($,M,J,Z,X,D,Y,Q,K,q,U){let N=i1(D),A=E1(D,q.lineHeight),V=s1(X,Z,N,D,K,A,U),B=Q;for(let G of V){let b={blockId:Z.blockId,boundaries:K5(X,Z,G.start,G.end,G.text,N,K,U),regionId:Z.id,end:G.end,font:N,height:G.height,left:Y,start:G.start,text:G.text,top:B,width:G.width};$.push(b),$6(M,b),B+=G.height}return BD($,Z.id,J),B}function VD($){let M=[...$].sort((Z,X)=>Z.top-X.top||Z.left-X.left),J=new Map;$.length=0,$.push(...M);for(let[Z,X]of $.entries()){let D=J.get(X.regionId)??[];D.push(Z),J.set(X.regionId,D)}return J}function GD($,M){let J=new Map(M);for(let Z of $){let X=J.get(Z.regionId),D={bottom:Z.top+Z.height,left:Z.left,right:Z.left+Z.width,top:Z.top};J.set(Z.regionId,X?{bottom:Math.max(X.bottom,D.bottom),left:Math.min(X.left,D.left),right:Math.max(X.right,D.right),top:Math.min(X.top,D.top)}:D)}return J}function BD($,M,J){let Z=$.filter((X)=>X.regionId===M);if(Z.length===0)return;J.set(M,{bottom:Math.max(...Z.map((X)=>X.top+X.height)),left:Math.min(...Z.map((X)=>X.left)),right:Math.max(...Z.map((X)=>X.left+X.width)),top:Math.min(...Z.map((X)=>X.top))})}function $6($,M){let J=$.get(M.blockId),Z=M.top+M.height;$.set(M.blockId,{bottom:J?Math.max(J.bottom,Z):Z,top:J?Math.min(J.top,M.top):M.top})}function O9($,M){let J=0,Z=$.lines.length-1;while(J<=Z){let X=J+Z>>1,D=$.lines[X];if(M<D.top){Z=X-1;continue}if(M>=D.top+D.height){J=X+1;continue}return{index:X,line:D}}return null}function M6($,M){let J=[...$.regionBounds.entries()].find(([,D])=>{return M.x>=D.left&&M.x<=D.right&&M.y>=D.top&&M.y<=D.bottom});if(J)return A5($,J[0],M.y);let Z=O9($,M.y);if(!Z)return null;let X=FD($,M.y,Z.index);if(X.length===1)return X[0]??null;return X.find((D)=>{let Y=$.regionBounds.get(D.line.regionId);return Y?M.x>=Y.left&&M.x<=Y.right:!1})??[...X].sort((D,Y)=>{let Q=$.regionBounds.get(D.line.regionId),K=$.regionBounds.get(Y.line.regionId),q=E9(M.x,Q),U=E9(M.x,K);return q-U})[0]??null}function J6($,M,J){if($.lines.length===0)return{endIndex:0,startIndex:0};let Z=M+J,X=T9($,M),D=T9($,Z);if(X>0){let Y=$.lines[X-1];if(Y.top+Y.height>M)X-=1}if(D<$.lines.length){if($.lines[D].top<Z)D+=1}return{endIndex:D,startIndex:X}}function v0($,M,J){if(!$.regionMetrics.get(J.regionId))return null;let X=s0($,J.regionId,J.offset);if(!X)return null;return{blockId:X.blockId,regionId:X.regionId,height:X.height,left:h0(X,J.offset-X.start),offset:J.offset,top:X.top}}function s0($,M,J){return j2($,M,J)?.line??null}function A5($,M,J){let Z=$.regionLineIndices.get(M);if(!Z||Z.length===0)return null;let X=Z[0],D=Number.POSITIVE_INFINITY;for(let Y of Z){let Q=$.lines[Y],K=J<Q.top?Q.top-J:J>Q.top+Q.height?J-(Q.top+Q.height):0;if(K<D)D=K,X=Y;if(K===0)break}return{index:X,line:$.lines[X]}}function j2($,M,J){let Z=$.regionLineIndices.get(M);if(!Z||Z.length===0)return null;let X=0,D=Z.length-1;while(X<=D){let U=X+D>>1,N=Z[U],A=$.lines[N];if(J<A.start){D=U-1;continue}if(J>A.end){X=U+1;continue}return{index:N,line:A}}let Y=Z[0],Q=Z[Z.length-1],K=$.lines[Y],q=$.lines[Q];if(J<=K.start)return{index:Y,line:K};if(J>=q.end)return{index:Q,line:q};return null}function FD($,M,J){let Z=[];for(let X=J;X>=0;X-=1){let D=$.lines[X];if(M<D.top||M>=D.top+D.height)break;Z.unshift({index:X,line:D})}for(let X=J+1;X<$.lines.length;X+=1){let D=$.lines[X];if(M<D.top||M>=D.top+D.height)break;Z.push({index:X,line:D})}return Z}function E9($,M){if(!M)return Number.POSITIVE_INFINITY;if($<M.left)return M.left-$;if($>M.right)return $-M.right;return 0}function h0($,M){return $.left+_D($.boundaries,M)}function L2($){let M=new Map,J=(Z)=>{for(let X of Z)if(M.set(X.id,X),X.type==="blockquote"||X.type==="listItem")J(X.children);else if(X.type==="list")J(X.items)};return J($),M}function _D($,M){for(let Z of $)if(Z.offset===M)return Z.left;return $.filter((Z)=>Z.offset<=M).at(-1)?.left??0}function T9($,M){let J=0,Z=$.lines.length;while(J<Z){let X=J+Z>>1,D=$.lines[X];if(D.top+D.height<=M)J=X+1;else Z=X}return J}function C9($,M){if($.length===0)return 0;for(let J=1;J<$.length;J+=1){let Z=$[J-1],X=$[J],D=Z.left+(X.left-Z.left)/2;if(M<=D)return Z.offset;if(M<=X.left)return X.offset}return $.at(-1)?.offset??0}function V5($,M,J,Z,X){let D=J[Z],Y=J[Z+1];if(!D||!Y)return X;if(y9($,D.blockId,Y.blockId,"list"))return qD;if(y9($,D.blockId,Y.blockId,"blockquote"))return UD;if(D.blockId===Y.blockId)return ND;return X+bD(M.get(D.blockId))}function bD($){if($?.type!=="heading")return 0;if($.depth===1)return QD;return $.depth===2?KD:0}function y9($,M,J,Z){let X=w9($,M,Z),D=w9($,J,Z);for(let Y of X)if(D.has(Y))return!0;return!1}function w9($,M,J){let Z=new Set,X=$.get(M)??null;while(X){if(X.type===J)Z.add(X.id);X=X.parentBlockId?$.get(X.parentBlockId)??null:null}return Z}function Z6($,M,J,Z=[],X=W1(),D=null){let Y=D??{images:new Map},Q=L2($.document.blocks),K=new Map($.blocks.map((z)=>[z.id,z])),q=new Set(Z),U=Math.max(0,J.top-J.overscan),N=J.top+J.height+J.overscan,A=ED(X,$,Q,K,M,Y),V=j9(A,U),B=j9(A,N);if(V>0){let z=A.entries[V-1];if(z&&z.bottom>U)V-=1}if(B<A.entries.length){let z=A.entries[B];if(z&&z.top<N)B+=1}for(let z of q){let L=A.containerIndices.get(z);if(L===void 0)continue;V=Math.min(V,L),B=Math.max(B,L+1)}if(!Number.isFinite(V)||!Number.isFinite(B))return{estimateRegionBounds:A.estimateRegionBounds,layout:N5({...$,regions:[]},M,X,Y),totalHeight:A.totalHeight,viewport:J};let G=zD($,K,A.containerIndices,V,B),b=A.entries[G.startIndex]?.top??M.paddingY??0,P=N5({...$,regions:$.regions.slice(G.startIndex,G.endIndex)},M,X,Y),y=PD(P,b,A.totalHeight);return HD(X,$,y,M,Y),{estimateRegionBounds:A.estimateRegionBounds,layout:y,totalHeight:A.totalHeight,viewport:J}}function HD($,M,J,Z,X){for(let[D,Y]of J.regionBounds){let Q=Y.bottom-Y.top,K=M.regionIndex.get(D);x$($,L9(K??{path:D,inlines:[],text:""},Z,X),Q)}}function PD($,M,J){return{...$,blocks:$.blocks.map((Z)=>({...Z,bottom:Z.bottom+M,top:Z.top+M})),regionBounds:new Map([...$.regionBounds.entries()].map(([Z,X])=>[Z,{bottom:X.bottom+M,left:X.left,right:X.right,top:X.top+M}])),height:J,lines:$.lines.map((Z)=>({...Z,top:Z.top+M}))}}function zD($,M,J,Z,X){let D=Z,Y=X;for(let Q=Z;Q<X;Q+=1){let K=$.regions[Q],q=M.get(K.blockId);if(!q)continue;if(q.type==="table"){let U=J.get(q.regionIds[0]??""),N=J.get(q.regionIds[q.regionIds.length-1]??"");if(U!==void 0)D=Math.min(D,U);if(N!==void 0)Y=Math.max(Y,N+1)}}return{endIndex:Y,startIndex:D}}function WD($,M,J,Z,X,D){let Y=L9(M,X,D),Q=$.measuredContainerHeights.get(Y);if(Q!==void 0)return Q;let K=X.paddingX??0,q=X.indentWidth??24,U=E1(J,X.lineHeight??24),N=K+Z*q,A=Math.max(40,X.width-N-K);if(M.inlines.some((G)=>G.kind==="image")){let G=i1(J);return s1($,M,G,J,A,U,D).reduce((b,P)=>b+P.height,0)}let V=U5({text:M.text,width:A});return Math.max(U,V.lineCount*U)}function ED($,M,J,Z,X,D){let Y=OD(M,X,D),Q=a$($,M,Y);if(Q)return Q;let K=X.paddingY??0,q=[],U=new Map;for(let N=0;N<M.regions.length;N+=1){let A=M.regions[N],V=J.get(A.blockId)??null;if(V?.type==="table"){let P=TD({block:V,blockMap:J,containerIndices:U,entries:q,index:N,options:X,runtimeBlocks:Z,totalHeight:K,regions:M.regions});if(P){N=P.nextIndex-1,K=P.totalHeight;continue}}let B=WD($,A,V,Z.get(A.blockId)?.depth??0,X,D),G=K,b=G+B;q.push({bottom:b,top:G}),U.set(A.id,N),K=b+V5(Z,J,M.regions,N,X.blockGap??16)}return i$($,M,Y,{containerIndices:U,entries:q,estimateRegionBounds(N){let A=U.get(N);return A===void 0?null:q[A]??null},totalHeight:K})}function TD({block:$,blockMap:M,containerIndices:J,entries:Z,index:X,options:D,runtimeBlocks:Y,totalHeight:Q,regions:K}){let q=Y.get($.id),U=q?.regionIds??[];if(U.length===0)return null;let N=K.slice(X,X+U.length);if(N.length===0||N[0]?.blockId!==$.id)return null;let A=D.paddingX??0,V=D.indentWidth??24,B=q?.depth??0,G=A+B*V,b=Math.max(e8,D.width-G-A),P=Math.max(1,...$.rows.map((E)=>E.cells.length)),y=b/P,z=Math.max(40,y-C2*2),L=E1($,D.lineHeight??24),R=yD(N,X),m=Q;for(let E=0;E<$.rows.length;E+=1){let _=R.get(E)??[],j=Math.max(L+o1*2,..._.map(({region:W})=>wD(W,z,L)+o1*2)),C=m+j;for(let{index:W,region:F}of _)Z[W]={bottom:C,top:m},J.set(F.id,W);m=C}for(let E=X;E<X+N.length;E+=1){let _=K[E];if(!_||Z[E])continue;Z[E]={bottom:m,top:m},J.set(_.id,E)}return{nextIndex:X+N.length,totalHeight:m+V5(Y,M,K,X+N.length-1,D.blockGap??16)}}function yD($,M){let J=new Map;for(let[Z,X]of $.entries()){let D=X.tableCellPosition?.rowIndex;if(D===void 0)continue;let Y=J.get(D)??[];Y.push({index:M+Z,region:X}),J.set(D,Y)}return J}function wD($,M,J){let Z=U5({text:$.text,width:M});return Math.max(J,Z.lineCount*J)}function OD($,M,J){return[M.width,M.paddingX??0,M.paddingY??0,M.indentWidth??24,M.lineHeight??24,M.blockGap??16,CD($,J)].join(":")}function j9($,M){let J=0,Z=$.entries.length;while(J<Z){let X=J+Z>>1;if($.entries[X].bottom<=M)J=X+1;else Z=X}return J}function L9($,M,J){return`${q5($,J)}:${M.width}:${M.paddingX??0}:${M.indentWidth??24}:${M.lineHeight??24}`}function CD($,M){return $.regions.flatMap((J)=>J.inlines.filter((Z)=>Z.kind==="image"&&Z.image).map((Z)=>{let X=Z.image?M.images.get(Z.image.url):null;return`${Z.image?.url??""}:${Z.image?.width??0}:${X?.status??"loading"}:${X?.intrinsicWidth??0}:${X?.intrinsicHeight??0}`})).join("|")}var G5=null;function jD($){let M=/(\d+(?:\.\d+)?)\s*px/.exec($);return M?Number.parseFloat(M[1]):16}function Y1($){G5??=new Map;let M=G5.get($);if(M)return M;let J=f9(),Z=Math.max(12,Math.round(jD($)));if(!J){let A={ascent:Math.round(Z*0.8),descent:Math.max(2,Z-Math.round(Z*0.8)),emHeight:Z};return G5.set($,A),A}J.font=$;let X=J.measureText("Hg"),D=Math.round(X.actualBoundingBoxAscent||0),Y=Math.round(X.actualBoundingBoxDescent||0),Q=D+Y,K=Math.max(Z,Q),q=Q>0?D:Math.round(K*0.8),U=Q>0?Y:Math.max(2,K-q),N={ascent:q,descent:U,emHeight:K};return G5.set($,N),N}function LD($,M){let{emHeight:J}=Y1(M);return Math.max(0,Math.floor(($-J)/2))}function R9($,M){let{ascent:J}=Y1(M);return LD($,M)+J}var B5;function k9($,M){let J=f9();if(!J||$.length===0)return 0;return J.font=M,J.measureText($).width}function f9(){if(B5!==void 0)return B5;return B5=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,B5}var RD=18,kD=14,fD=22;function T0($,M,J){let Z=SD($,J);if(!Z)return null;return m9($,M,Z,J.x)}function X6($,M,J){let Z=$.lines[$.lines.length-1];if(!Z||J.y<=Z.top+Z.height)return null;return m9($,M,Z,J.x)}function m9($,M,J,Z){let X=$.regionMetrics.get(J.regionId);if(!X)return null;let D=Math.max(0,Z-K1(M,J)-J.left),Y=C9(J.boundaries,D),Q=Math.min(X.textLength,J.start+Y);return{regionId:J.regionId,offset:Q,left:h0(J,Y),top:J.top,height:J.height}}function D6($,M,J,Z){let X=U6(M,Z.regionId);if(!X)return null;let D=T0($,M,J);if(D)return{regionId:D.regionId,offset:D.offset};let Y=J.y<vD($);return{regionId:Z.regionId,offset:Y?0:X.text.length}}function Y6($,M,J){let Z=T0($,M,J);if(!Z)return null;let X=U6(M,Z.regionId);if(!X||X.text.length===0)return null;let D=Z.offset<X.text.length&&/\w/.test(X.text[Z.offset]??"")?Z.offset:Z.offset>0&&/\w/.test(X.text[Z.offset-1]??"")?Z.offset-1:Z.offset,Y=hD(X.text,D);if(Y.start===Y.end)return null;return{anchor:{regionId:Z.regionId,offset:Y.start},focus:{regionId:Z.regionId,offset:Y.end}}}function S9($,M,J){let Z=uD($,J);if(!Z||Z.start!==0)return null;let X=n1(M,Z.blockId,"listItem");if(!X)return null;if(k2(M,X.id)?.kind!=="task")return null;let Y=R2(Z),Q=Y.left-4,K=Y.left+Y.size+4,q=Y.top-4,U=Y.top+Y.size+4;return J.x>=Q&&J.x<=K&&J.y>=q&&J.y<=U?{listItemId:X.id}:null}function u9($,M,J){let Z=T0($,M,J);if(!Z)return null;let X=U6(M,Z.regionId);if(!X)return null;let D=X.inlines.find((Q)=>Q.link&&Z.offset>=Q.start&&Z.offset<Q.end);if(!D?.link)return null;let Y=q6($,M,Z.regionId,D.start);if(!Y)return null;return{anchorBottom:Y.anchorBottom,anchorLeft:Y.anchorLeft,endOffset:D.end,regionId:Z.regionId,startOffset:D.start,title:D.link.title,url:D.link.url}}function Q6($,M,J,Z){let X=S9($,M,J);if(X)return{kind:"task-toggle",listItemId:X.listItemId};let D=T0($,M,J);if(!D)return null;let Y=v9(D.regionId,D.offset,Z),Q=Y!==null?h9(Y,$,M,Z):null,K=u9($,M,J);if(K)return{anchorBottom:Q?.anchorBottom??K.anchorBottom,anchorLeft:Q?.anchorLeft??K.anchorLeft,endOffset:K.endOffset,kind:"link",commentThreadIndex:Y,regionId:K.regionId,startOffset:K.startOffset,title:K.title,url:K.url};return{anchorBottom:Q?.anchorBottom??D.top+D.height,anchorLeft:Q?.anchorLeft??D.left,kind:"text",commentThreadIndex:Y}}function K6($,M,J,Z){let X=M.documentIndex.regionIndex.get(J.regionId);if(!X)return null;let D=v9(J.regionId,J.offset,Z),Y=D!==null?h9(D,$,M,Z):null,Q=X.inlines.find((K)=>J.offset>=K.start&&J.offset<=K.end)??null;if(Q?.link){let K=q6($,M,J.regionId,Q.start);if(!K)return null;return{anchorBottom:Y?.anchorBottom??K.anchorBottom,anchorLeft:Y?.anchorLeft??K.anchorLeft,commentThreadIndex:D,endOffset:Q.end,kind:"link",regionId:J.regionId,startOffset:Q.start,title:Q.link.title,url:Q.link.url}}if(Y)return{anchorBottom:Y.anchorBottom,anchorLeft:Y.anchorLeft,commentThreadIndex:D,kind:"text"};return null}function g0($,M,J){let Z=s0(M,J.regionId,J.offset);if(!Z)return J.left;return J.left+K1($,Z)+mD($,Z,J.offset)}function Q1($,M,J){return h0(M,J)+K1($,M)}function K1($,M){let J=n1($,M.blockId,"listItem");if(!J)return 0;return k2($,J.id)?.kind==="task"?fD:RD}function R2($){return{left:$.left,size:kD,top:$.top+3}}function n1($,M,J){let Z=$.documentIndex.blockIndex.get(M)??null;while(Z){if(Z.type===J)return Z;let X=Z.parentBlockId;Z=X?$.documentIndex.blockIndex.get(X)??null:null}return null}function k2($,M){return $.documentIndex.listItemMarkers.get(M)??null}function v9($,M,J){for(let Z of J)if(Z.regionId===$&&M>=Z.startOffset&&M<=Z.endOffset)return Z.threadIndex;return null}function h9($,M,J,Z){let X=Z.find((D)=>D.threadIndex===$);if(!X)return null;return q6(M,J,X.regionId,X.startOffset)}function q6($,M,J,Z){let X=s0($,J,Z);if(!X)return null;return{anchorBottom:X.top+X.height,anchorLeft:h0(X,Z)+K1(M,X)}}function mD($,M,J){if(J<=M.end)return 0;let Z=$.documentIndex.regionIndex.get(M.regionId);if(!Z)return 0;let X=Z.text.slice(M.end,J);if(!/^[ \t]+$/u.test(X))return 0;return k9(X,M.font)}function SD($,M){for(let[Z,X]of $.regionBounds)if(M.x>=X.left&&M.x<=X.right&&M.y>=X.top&&M.y<=X.bottom)return A5($,Z,M.y)?.line??null;let J=M6($,M)?.line??null;if(J)return J;for(let Z of $.blocks)if(M.y>=Z.top&&M.y<=Z.bottom){for(let X=$.lines.length-1;X>=0;X--)if($.lines[X].blockId===Z.id)return $.lines[X]}return null}function uD($,M){return $.lines.find((J)=>M.y>=J.top-4&&M.y<=J.top+J.height+4)??$.lines.filter((J)=>Math.abs(M.y-(J.top+J.height/2))<=10).sort((J,Z)=>Math.abs(M.y-(J.top+J.height/2))-Math.abs(M.y-(Z.top+Z.height/2)))[0]??null}function U6($,M){return $.documentIndex.regionIndex.get(M)??null}function vD($){return $.lines[0]?.top??0}function hD($,M){let J=M,Z=M;while(J>0&&/\w/.test($[J-1]??""))J-=1;while(Z<$.length&&/\w/.test($[Z]??""))Z+=1;return{end:Z,start:J}}function N6($,M,J,Z=null){let X={height:M.height,overscan:Math.max(160,M.height),top:M.top},D=Z6($.documentIndex,M,X,[$.selection.anchor.regionId,$.selection.focus.regionId],J,Z);return{blockMap:L2($.documentIndex.document.blocks),estimateRegionBounds:D.estimateRegionBounds,regionBounds:new Map(D.layout.regionBounds),layout:D.layout,paintHeight:Math.max(240,X.height+X.overscan*2),paintTop:Math.max(0,X.top-X.overscan),totalHeight:D.totalHeight,viewport:{height:X.height,top:X.top}}}function F5($,M,J){return T0(M.layout,$,J)??X6(M.layout,$,J)}function f2($,M,J,Z){return D6(M.layout,$,J,Z)}function A6($,M,J){return Y6(M.layout,$,J)}function V6($,M,J,Z){return Q6(M.layout,$,J,Z)}function G6($,M,J,Z){return K6(M.layout,$,J,Z)}function B6($,M,J){return v0(M.layout,$.documentIndex,J)}function o0($,M,J){let Z=v0(M.layout,$.documentIndex,J);if(!Z)return null;return{...Z,left:g0($,M.layout,Z)}}function g9($,M,J,Z,X){let D=Z-J,Y=X-D;if(Z<=$)return{end:M+Y,start:$+Y};if(J>=M)return{end:M,start:$};let Q=Math.max(0,Math.min(J,M)-$),K=Math.max(0,M-Math.max(Z,$)),q=$<J?$:J;return{end:q+Q+X+K,start:q}}function _6($,M,J){let Z=J.trim();if(Z.length===0||M.startOffset===M.endOffset)return null;let X=$.regionIndex.get(M.regionId)??null,D=X?F6($,X):null;if(!D)return null;return f8({anchor:E2(D,M.startOffset,M.endOffset),body:Z,quote:T2(D,M.startOffset,M.endOffset)})}function L0($){let M="documentIndex"in $?$.documentIndex:$,J=_5(M),Z=M.document.comments,X=[...Z],D=[];for(let[Y,Q]of Z.entries()){let K=y2(Q,M.document);if(!K.match)continue;let U=J.findBySemanticMatch(K.match.containerId,K.match.containerOrdinal)?.runtimeContainer??null;if(!U)continue;if(K.repair)X[Y]={...Q,anchor:K.repair.anchor,quote:K.repair.quote};D.push({endOffset:K.match.endOffset,resolution:K,regionId:U.id,resolved:Q.resolvedAt!=null,startOffset:K.match.startOffset,threadIndex:Y})}return{liveRanges:D,threads:X}}function b6($,M,J,Z,X,D){if($.document.comments.length===0)return M.document.comments;let Y=$.commentContainerIndex.get(J.semanticRegionId)??[],Q=new Set(Y);if(Y.length===0)return M.document.comments;let K=L0($),q=new Map(K.liveRanges.map((V)=>[V.threadIndex,V])),U=F6($,J),N=t1(M,J.path),A=N?F6(M,N):null;if(!U||!A)return M.document.comments;return M.document.comments.map((V,B)=>{if(!Q.has(B))return V;let G=q.get(B),b=G?.resolution.match??null;if(!G||!b||b.containerId!==U.id)return V;let P=g9(b.startOffset,b.endOffset,Z,X,D.length);return{...V,anchor:E2(A,P.start,P.end),quote:T2(A,P.start,P.end)}})}function F6($,M){let J=gD($,M);if(!J)return null;return{containerKind:J,containerOrdinal:-1,id:M.semanticRegionId,text:M.text}}function gD($,M){if($.tableCellIndex.has(M.id))return"tableCell";return u$(M.blockType)}function b5($,M){if(M.length===0)return[];let J=_5($),Z=J.list();return M.map((X)=>({...X,cursorPoint:ID(X,Z,J),viewport:null}))}function ID($,M,J){if(!$.cursor)return null;let Z=pD(M,$.cursor),X=lD(Z,$.cursor);if(X.length!==1)return null;let D=X[0],Y=J.resolveRuntimeContainer(D.container.id);if(!Y)return null;return{offset:Math.max(0,Math.min(D.offset,Y.text.length)),regionId:Y.id}}function pD($,M){return M.kind?$.filter((J)=>J.containerKind===M.kind):$}function lD($,M){if(M.prefix&&M.suffix)return rD($,M.prefix,M.suffix);if(M.prefix)return I9($,M.prefix,"after");if(M.suffix)return I9($,M.suffix,"before");return[]}function I9($,M,J){let Z=[];for(let X of $)for(let D of u0(X.text,M))Z.push({container:X,offset:J==="after"?D+M.length:D});return Z}function rD($,M,J){let Z=[];for(let X of $)for(let D of l1(X.text,M,J))Z.push({container:X,offset:D.startOffset});return Z}var cD=48;function m2($,M,J){let Z="documentIndex"in $?$.documentIndex:$;if(J.length===0)return[];return J.map((X)=>({...X,viewport:xD(Z,M,X)}))}function xD($,M,J){if(!J.cursorPoint)return{status:"unresolved"};let Z=v0(M.layout,$,J.cursorPoint),X=Z?{bottom:Z.top+Z.height,top:Z.top}:M.estimateRegionBounds(J.cursorPoint.regionId);if(!X)return{status:"unresolved"};return{scrollTop:aD(M,X),status:dD(M,X)}}function dD($,M){let J=$.viewport.top,Z=J+$.viewport.height;if(M.bottom<J)return"above";if(M.top>Z)return"below";return"visible"}function aD($,M){let J=Math.max(0,$.totalHeight-$.viewport.height),Z=M.top-Math.min(cD,$.viewport.height/4);return Math.max(0,Math.min(J,Z))}function _5($){let M=X5($.document),J=new Map(M.map((X)=>[X.id,X])),Z=new Map($.regions.map((X)=>[X.semanticRegionId,X]));return{findBySemanticMatch(X,D){let Y=J.get(X)??M[D]??null;if(!Y)return null;return{runtimeContainer:Z.get(Y.id)??null,semanticContainer:Y}},list(X){return X?M.filter((D)=>D.containerKind===X):M},resolveRuntimeContainer(X){return Z.get(X)??null}}}var S2="",p9=1e6;function u2($,M,J){return`${$}:${M}:${J}`}function Q0($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&Z.marks.join(",")===J.marks.join(",")){M[M.length-1]=H0({marks:Z.marks,path:Z.id,text:Z.text+J.text});continue}M.push(J)}return M}function e1($){let M=UY($),J=P6(M.blocks.map((Z,X)=>h2(Z,X)));return z6(M,J)}function h2($,M){let J=[],Z=[],X=[],D=0;function Y(K,q,U,N,A=null){if(Z.length>0)X.push(`
20
+ `),D+=1;let V=U.map((b)=>b.text).join(""),B=D,G=B+V.length;X.push(V),D=G,Z.push({blockId:K.id,blockType:K.type,end:G,id:`${K.id}:${q}`,path:q,rootIndex:M,inlines:U,semanticRegionId:N,start:B,tableCellPosition:A,text:V})}function Q(K,q,U,N){let A={childBlockIds:[],depth:U,end:D,id:K.id,parentBlockId:N,path:q,regionIds:[],rootIndex:M,start:D,type:K.type};switch(J.push(A),K.type){case"blockquote":case"listItem":for(let[V,B]of K.children.entries())A.childBlockIds.push(B.id),Q(B,`${q}.children.${V}`,U+1,K.id);break;case"code":{Y(K,`${q}.source`,[{end:K.source.length,id:`${K.id}:code`,image:null,inlineCode:!1,kind:"text",link:null,marks:[],originalType:null,start:0,text:K.source}],K.id),A.regionIds.push(Z.at(-1).id);break}case"heading":case"paragraph":Y(K,`${q}.children`,H6(K.children),K.id),A.regionIds.push(Z.at(-1).id);break;case"list":for(let[V,B]of K.items.entries())A.childBlockIds.push(B.id),Q(B,`${q}.children.${V}`,U+1,K.id);break;case"table":for(let[V,B]of K.rows.entries())for(let[G,b]of B.cells.entries())Y(K,`${q}.rows.${V}.cells.${G}`,H6(b.children),b.id,{cellIndex:G,rowIndex:V}),A.regionIds.push(Z.at(-1).id);break;case"thematicBreak":break;case"directive":break;case"unsupported":Y(K,`${q}.source`,[{end:K.source.length,id:`${K.id}:unsupported`,image:null,inlineCode:!1,kind:"unsupported",link:null,marks:[],originalType:K.originalType,start:0,text:K.source}],K.id),A.regionIds.push(Z.at(-1).id);break}A.end=D}return Q($,`root.${M}`,0,null),{blockRange:{end:J.length,start:0},blocks:J,end:D,length:D,regionRange:Z.length>0?{end:Z.length,start:0}:void 0,regions:Z,rootIndex:M,start:0,text:X.join("")}}function P6($,M=null){let J=[],Z=0,X=0,D=0,Y=!1;for(let[Q,K]of $.entries()){if(K.regions.length>0&&Y)D+=1;let q={...K,blockRange:{end:Z+K.blocks.length,start:Z},end:D+K.length,regionRange:K.regions.length>0?{end:X+K.regions.length,start:X}:void 0,start:D},U=M?.[Q];if(J.push(sD(U,K,q)?U:l9(K,q)),Z=q.blockRange.end,X=q.regionRange?.end??X,K.regions.length>0)D=q.end,Y=!0}return J}function $2($,M,J,Z){let X=M.blocks.length-($.roots.length-Z);if(X<0)throw Error("Editor model splice received an invalid replacement count.");if(J===$.roots.length&&X===1){let K=M.blocks[J];if(K)return iD($,M,K)}let D=X===Z,Y=[...$.roots.slice(0,J),...M.blocks.slice(J,J+X).map((K,q)=>h2(K,J+q)),...D?$.roots.slice(J+Z):M.blocks.slice(J+X).map((K,q)=>h2(K,J+X+q))],Q=P6(Y,$.roots);return z6(M,Q,$)}function iD($,M,J){let Z=$.roots.length,X=h2(J,Z),D=$.roots.some((U)=>U.regions.length>0),Y=X.regions.length>0&&D?$.length+1:$.length,Q=l9(X,{...X,blockRange:{end:$.blocks.length+X.blocks.length,start:$.blocks.length},end:Y+X.length,regionRange:X.regions.length>0?{end:$.regions.length+X.regions.length,start:$.regions.length}:void 0,start:Y}),K=[...$.blocks,...Q.blocks],q=[...$.regions,...Q.regions];return{blockIndex:$Y($.blockIndex,Q.blocks),blocks:K,commentContainerIndex:M.comments===$.document.comments?$.commentContainerIndex:r9(M),document:M,engine:"canvas",length:Q.end,listItemMarkers:M.blocks===$.document.blocks?$.listItemMarkers:YY($.listItemMarkers,J),regionIndex:MY($.regionIndex,Q.regions),regionOrderIndex:JY($.regionOrderIndex,Q.regions,$.regions.length),regionPathIndex:ZY($.regionPathIndex,Q.regions),regions:q,roots:[...$.roots,Q],tableCellIndex:XY($.tableCellIndex,Q.regions),tableCellRegionIndex:DY($.tableCellRegionIndex,Q.regions),text:QY($.text,Q)}}function g2($,M){if(M.blocks!==$.document.blocks)throw Error("Editor model document replacement requires preserving root blocks.");return z6(M,$.roots,$)}function z6($,M,J=null){let Z=M.flatMap((U)=>U.blocks),X=M.flatMap((U)=>U.regions),{regionIndex:D,regionOrderIndex:Y,regionPathIndex:Q,tableCellIndex:K,tableCellRegionIndex:q}=eD(X);return{blockIndex:tD(Z),blocks:Z,commentContainerIndex:$.comments===J?.document.comments?J.commentContainerIndex:r9($),document:$,engine:"canvas",length:M.at(-1)?.end??0,listItemMarkers:$.blocks===J?.document.blocks?J.listItemMarkers:qY($.blocks),regionIndex:D,regionOrderIndex:Y,regionPathIndex:Q,regions:X,roots:M,tableCellIndex:K,tableCellRegionIndex:q,text:KY(M)}}function l9($,M){let J=M.start-$.start;return{...M,blocks:J===0?$.blocks:oD($.blocks,J),regions:J===0?$.regions:nD($.regions,J)}}function sD($,M,J){return Boolean($&&M===$&&$.start===J.start&&$.end===J.end&&$.blockRange.start===J.blockRange.start&&$.blockRange.end===J.blockRange.end&&$.regionRange?.start===J.regionRange?.start&&$.regionRange?.end===J.regionRange?.end)}function oD($,M){return $.map((J)=>({...J,end:J.end+M,start:J.start+M}))}function nD($,M){return $.map((J)=>({...J,end:J.end+M,start:J.start+M}))}function tD($){let M=new Map;for(let J of $)M.set(J.id,J);return M}function eD($){let M=new Map,J=new Map,Z=new Map,X=new Map,D=new Map;for(let[Y,Q]of $.entries()){if(M.set(Q.id,Q),J.set(Q.id,Y),Z.set(Q.path,Q),!Q.tableCellPosition)continue;X.set(Q.id,Q.tableCellPosition),D.set(u2(Q.blockId,Q.tableCellPosition.rowIndex,Q.tableCellPosition.cellIndex),Q.id)}return{regionIndex:M,regionOrderIndex:J,regionPathIndex:Z,tableCellIndex:X,tableCellRegionIndex:D}}function $Y($,M){let J=new Map($);for(let Z of M)J.set(Z.id,Z);return J}function MY($,M){let J=new Map($);for(let Z of M)J.set(Z.id,Z);return J}function JY($,M,J){let Z=new Map($);for(let[X,D]of M.entries())Z.set(D.id,J+X);return Z}function ZY($,M){let J=new Map($);for(let Z of M)J.set(Z.path,Z);return J}function XY($,M){let J=new Map($);for(let Z of M)if(Z.tableCellPosition)J.set(Z.id,Z.tableCellPosition);return J}function DY($,M){let J=new Map($);for(let Z of M){if(!Z.tableCellPosition)continue;J.set(u2(Z.blockId,Z.tableCellPosition.rowIndex,Z.tableCellPosition.cellIndex),Z.id)}return J}function YY($,M){let J=new Map($);return v2(J,[M]),J}function QY($,M){if(M.regions.length===0)return $;return $.length>0?`${$}
21
+ ${M.text}`:M.text}function KY($){return $.filter((M)=>M.regions.length>0).map((M)=>M.text).join(`
22
+ `)}function r9($){let M=new Map;for(let[J,Z]of $.comments.entries()){let X=y2(Z,$).match?.containerId??null;if(!X)continue;let D=M.get(X)??[];D.push(J),M.set(X,D)}return M}function qY($){let M=new Map;return v2(M,$),M}function v2($,M,J=null){for(let Z of M){if(Z.type==="list"){for(let[X,D]of Z.items.entries())v2($,[D],{index:X,ordered:Z.ordered,start:Z.start});continue}if(Z.type==="listItem"){if(typeof Z.checked==="boolean")$.set(Z.id,{checked:Z.checked,kind:"task"});else if(J?.ordered)$.set(Z.id,{kind:"ordered",label:`${(J.start??1)+J.index}.`});else $.set(Z.id,{kind:"bullet",label:"•"});v2($,Z.children,J)}if(Z.type==="blockquote")v2($,Z.children,J)}}function UY($){if($.blocks.length>0)return $;return g1([r({text:""})],$.comments,$.frontMatter)}function H6($,M=null){let J=[],Z=0,X=(D)=>{let Y=Z,Q=Y+D.text.length;J.push({...D,end:Q,start:Y}),Z=Q};for(let D of $)switch(D.type){case"break":X({id:D.id,image:null,inlineCode:!1,kind:"break",link:M,marks:[],originalType:null,text:`
23
+ `});break;case"image":X({id:D.id,image:{alt:D.alt,title:D.title,url:D.url,width:D.width},inlineCode:!1,kind:"image",link:M,marks:[],originalType:null,text:NY(D.alt)});break;case"inlineCode":X({id:D.id,image:null,inlineCode:!0,kind:"inlineCode",link:M,marks:[],originalType:null,text:D.code});break;case"link":for(let Y of H6(D.children,{title:D.title,url:D.url}))X(Y);break;case"text":X({id:D.id,image:null,inlineCode:!1,kind:"text",link:M,marks:D.marks,originalType:null,text:D.text});break;case"unsupported":X({id:D.id,image:null,inlineCode:!1,kind:"unsupported",link:M,marks:[],originalType:D.originalType,text:D.source});break}return J}function NY($){return S2}function H5($,M){let J=$.regionIndex.get(M);if(!J)return null;let Z=r1($.document.blocks,J.blockId);if(!Z)return null;return P5(Z,J.path,J.semanticRegionId)}function x9($,M,J,Z,X){if(J>=Z)return null;let D=H5($,M);return D?X(D,J,Z):null}function I2($,M,J,Z,X){let D=x9($,M,J,Z,X);return D?{kind:"replace-block",block:D.block,blockId:D.blockId,selection:D.selection}:null}function P5($,M,J){if($.type==="heading"||$.type==="paragraph")return{block:$,children:$.children,kind:"inlineBlock",path:M.replace(/\.children$/,"")};if($.type!=="table")return null;let Z=/^(.*\.rows\.\d+\.cells\.\d+)$/.exec(M);if(!Z)return null;for(let X of $.rows)for(let D of X.cells)if(D.id===J)return{block:$,blockPath:Z[1].replace(/\.rows\.\d+\.cells\.\d+$/,""),cell:D,children:D.children,kind:"tableCell",path:Z[1]};return null}function q1($,M,J,Z){switch($.kind){case"inlineBlock":return{block:C0($.block,M),blockId:$.block.id,selection:c9(`${$.path}.children`,J,Z)};case"tableCell":{let X=J1({children:M,path:$.path}),D=$.block.rows.map((Y)=>({...Y,cells:Y.cells.map((Q)=>Q.id===$.cell.id?X:Q)}));return{block:S0($.block,D),blockId:$.block.id,selection:c9($.path,J,Z)}}}}function c9($,M,J){return{endOffset:J,kind:"region-range-path",path:$,startOffset:M}}function b0($){switch($.type){case"break":return 1;case"image":return S2.length;case"inlineCode":return $.code.length;case"link":return N0($.children).length;case"text":return $.text.length;case"unsupported":return $.source.length}}function z5($,M,J){if(M<=0)return[];return W6($,0,M,`${J}.before`)}function W5($,M,J){let Z=b0($);if(M>=Z)return[];return W6($,M,Z,`${J}.after`)}function W6($,M,J,Z){if(M>=J)return[];switch($.type){case"text":return Q0([T1($.text.slice(M,J),$.marks,Z)].filter(Boolean));case"inlineCode":return[T6($.code.slice(M,J),Z)];case"link":{let X=Q0(AY($.children,M,J,`${Z}.children`));return X.length>0?[{...$,children:X}]:[]}default:return[]}}function E6($,M,J){let Z=0,X="";for(let D of $){let Y=b0(D),Q=Z,K=Q+Y;if(Z=K,J<=Q||M>=K)continue;X+=VY(D,Math.max(0,M-Q),Math.min(Y,J-Q))}return X}function T1($,M,J){if($.length===0)return null;return H0({marks:M,path:J,text:$})}function T6($,M){return S1({code:$,path:M})}function AY($,M,J,Z){let X=[],D=0;for(let[Y,Q]of $.entries()){let K=b0(Q),q=D,U=q+K;if(D=U,J<=q||M>=U)continue;X.push(...W6(Q,Math.max(0,M-q),Math.min(K,J-q),`${Z}.${Y}`))}return X}function VY($,M,J){if(M>=J)return"";switch($.type){case"break":return`
24
+ `.slice(M,J);case"image":return S2.slice(M,J);case"inlineCode":return $.code.slice(M,J);case"link":return E6($.children,M,J);case"text":return $.text.slice(M,J);case"unsupported":return $.source.slice(M,J)}}function y6($,M,J,Z){let X=GY($.children,M,J,Z);if(X===null)return null;let D=Q0(d9($.children,M,J,Z,X,`${$.path}.children`));return D.length>0?q1($,D,M,J):null}function w6($,M,J){let Z=0,X=null,D=(Y)=>{for(let Q of Y){let K=b0(Q),q=Z,U=q+K;if(Z=U,J<=q||M>=U)continue;if(Q.type==="text"){let N=Math.max(M,q);if(Math.min(J,U)>N)X=X===null?new Set(Q.marks):new Set(Q.marks.filter((V)=>X?.has(V)));continue}if(Q.type==="link"){let N=Z;Z=q,D(Q.children),Z=N}}};return D($.children),X?[...X]:[]}function GY($,M,J,Z){let X=0,D=!1,Y=!0,Q=(K)=>{for(let q of K){let U=b0(q),N=X,A=N+U;if(X=A,J<=N||M>=A)continue;if(q.type==="text"){let V=Math.max(M,N);if(Math.min(J,A)>V)D=!0,Y&&=q.marks.includes(Z);continue}if(q.type==="link"){let V=X;X=N,Q(q.children),X=V}}};return Q($),D?Y:null}function d9($,M,J,Z,X,D){let Y=[],Q=0;for(let[K,q]of $.entries()){let U=Q,N=b0(q),A=U+N,V=`${D}.${K}`;if(Q=A,J<=U||M>=A){Y.push(q);continue}if(q.type==="text"){Y.push(...BY(q,Math.max(0,M-U),Math.min(N,J-U),Z,X,V));continue}if(q.type==="link"){let B=Q0(d9(q.children,Math.max(0,M-U),Math.min(N,J-U),Z,X,`${V}.children`));if(B.length>0)Y.push({...q,children:B});continue}Y.push(q)}return Y}function BY($,M,J,Z,X,D){let Y=$.text.slice(0,M),Q=$.text.slice(M,J),K=$.text.slice(J),q=X?$.marks.filter((U)=>U!==Z):FY($.marks,Z);return[T1(Y,$.marks,`${D}.before`),T1(Q,q,`${D}.selected`),T1(K,$.marks,`${D}.after`)].filter(Boolean)}function FY($,M){return $.includes(M)?$:[...$,M].sort()}function O6($,M,J){let Z=Q0(_Y($.children,M,J,`${$.path}.children`));return Z.length>0?q1($,Z,M,J):null}function _Y($,M,J,Z){let X=i9($,M,J);if(X)return a9($,M,J,X.code,Z,!1);let D=E6($,M,J);if(D.length===0)return $;return a9($,M,J,D,Z,!0)}function i9($,M,J){let Z=0;for(let X of $){let D=b0(X),Y=Z,Q=Y+D;if(Z=Q,M===Y&&J===Q&&X.type==="inlineCode")return X;if(X.type==="link"){let K=i9(X.children,Math.max(0,M-Y),Math.min(D,J-Y));if(K)return K}}return null}function a9($,M,J,Z,X,D){let Y=[],Q=0,K=!1;for(let[q,U]of $.entries()){let N=`${X}.${q}`,A=b0(U),V=Q,B=V+A;if(Q=B,J<=V||M>=B){Y.push(U);continue}if(!K){Y.push(...z5(U,Math.max(0,M-V),N));let G=D?T6(Z,`${X}.selected`):T1(Z,[],`${X}.selected`);if(G)Y.push(G);K=!0}Y.push(...W5(U,Math.min(A,J-V),N))}return Y}function E5($,M,J,Z,X){return I2($,M,J,Z,(D,Y,Q)=>s9(D,Y,Q,X))}function s9($,M,J,Z){let X=Q0(bY($.children,M,J,Z,`${$.path}.children`)??[]);return X.length>0?q1($,X,M,J):null}function bY($,M,J,Z,X){let D=[],Y=0,Q=!1;for(let[K,q]of $.entries()){let U=`${X}.${K}`,N=b0(q),A=Y,V=A+N;if(Y=V,!Q&&q.type==="link"&&M===A&&J===V){if(Z===null)D.push(...q.children);else D.push(u1({children:q.children,path:U,title:q.title,url:Z}));Q=!0;continue}D.push(q)}return Q?D:null}function C6($,M,J){let Z=Q0(HY($.children,M,J,`${$.path}.children`));return q1($,Z,M+1,M+1)}function HY($,M,J,Z){let X=[],D=0,Y=!1;for(let[Q,K]of $.entries()){let q=`${Z}.${Q}`,U=b0(K),N=D,A=N+U;if(D=A,J<=N||M>=A){X.push(K);continue}if(!Y)X.push(...z5(K,Math.max(0,M-N),q)),X.push(P2({path:`${Z}.selected`})),Y=!0;X.push(...W5(K,Math.min(U,J-N),q))}if(!Y)X.push(P2({path:`${Z}.selected`}));return X}function X0($,M,J=0){return{childIndices:M,kind:"descendant-primary-region",offset:J,rootIndex:$}}function M0($,M=0){return{kind:"root-primary-region",offset:M,rootIndex:$}}function U1($,M,J,Z=0){return{cellIndex:J,kind:"table-cell",offset:Z,rootIndex:$,rowIndex:M}}function n0($,M){return $.regionIndex.get(M)??null}function t1($,M){return $.regionPathIndex.get(M)??null}function M2($,M,J,Z){let X=$.tableCellRegionIndex.get(u2(M,J,Z));return X?$.regionIndex.get(X)??null:null}function PY($){return $.anchor.regionId===$.focus.regionId&&$.anchor.offset===$.focus.offset}function n($,M){let J="documentIndex"in $?$.documentIndex:$,Z="documentIndex"in $?$.selection:M,X=PY(Z),D=o9(J,Z.anchor),Y=o9(J,Z.focus);if(D<=Y)return{collapsed:X,end:Z.focus,start:Z.anchor};return{collapsed:X,end:Z.anchor,start:Z.focus}}function p2($,M){if(!M)return null;if("kind"in M){if(M.kind==="root-primary-region"){let Z=$.document.blocks[M.rootIndex],X=Z?j6($,Z):null;return X?T5(X.id,y5(X.text,M.offset)):null}if(M.kind==="descendant-primary-region"){let Z=$.document.blocks[M.rootIndex],X=Z?zY(Z,M.childIndices):null,D=X?j6($,X):null;return D?T5(D.id,y5(D.text,M.offset)):null}if(M.kind==="table-cell"){let Z=$.document.blocks[M.rootIndex];if(!Z||Z.type!=="table")return null;let X=M2($,Z.id,M.rowIndex,M.cellIndex);return X?T5(X.id,y5(X.text,M.offset)):null}let J=t1($,M.path);if(!J)return null;if(M.kind==="region-path")return T5(J.id,y5(J.text,M.offset));return{anchor:{regionId:J.id,offset:Math.max(0,Math.min(M.startOffset,J.text.length))},focus:{regionId:J.id,offset:Math.max(0,Math.min(M.endOffset,J.text.length))}}}return M}function o9($,M){let J=$.regionOrderIndex.get(M.regionId);if(J===void 0)throw Error(`Unknown canvas region: ${M.regionId}`);return J*p9+M.offset}function T5($,M){let J={offset:M,regionId:$};return{anchor:J,focus:J}}function y5($,M){return M==="end"?$.length:Math.max(0,Math.min(M,$.length))}function zY($,M){let J=$;for(let Z of M){if(!J)return null;let X=n9(J);if(!X)return null;J=X[Z]??null}return J}function j6($,M){let J=$.blockIndex.get(M.id);if(!J)return null;let Z=J.regionIds[0];if(Z)return $.regionIndex.get(Z)??null;let X=n9(M);if(!X)return null;for(let D of X){let Y=j6($,D);if(Y)return Y}return null}function n9($){switch($.type){case"list":return $.items;case"blockquote":case"listItem":return $.children;default:return null}}function l2($){let M=$.documentIndex.regionIndex.get($.selection.anchor.regionId)??null,J=M?$.documentIndex.blockIndex.get(M.blockId)??null:null,Z=$.selection.anchor.offset,X=M?.inlines.find((D)=>Z>D.start&&Z<D.end)??M?.inlines.find((D)=>D.end===Z)??M?.inlines.find((D)=>D.start===Z)??null;return{block:J?{blockId:J.id,depth:J.depth,nodeType:J.type,text:M?.text??""}:null,span:X?.link?{kind:"link",url:X.link.url}:X&&X.marks.length>0?{kind:"marks",marks:X.marks}:{kind:"none"}}}function w5($){let M=n($.documentIndex,$.selection);if(M.start.regionId!==M.end.regionId||M.start.offset===M.end.offset)return[];let J=$.documentIndex.regionIndex.get(M.start.regionId);if(!J)return[];let Z=r1($.documentIndex.document.blocks,J.blockId);if(!Z)return[];let X=P5(Z,J.path,J.semanticRegionId);return X?w6(X,M.start.offset,M.end.offset):[]}function O5($,M,J,Z=null){return J2($,M,1,[J],Z)}function J2($,M,J,Z,X=null){return{document:I1($.document,M,J,Z),selection:X}}function C5($,M,J,Z=null){return r2($,M,()=>J,Z)}function r2($,M,J,Z=null){let X=$.blockIndex.get(M);if(!X)return null;let D=$.document.blocks[X.rootIndex];if(!D)return null;let Y=t9(D,M,J);return Y?J2($,X.rootIndex,1,[Y],Z):null}function t9($,M,J){if($.id===M)return J($);switch($.type){case"blockquote":{let Z=L6($.children,M,J);return Z?P0({children:Z}):null}case"listItem":{let Z=L6($.children,M,J);return Z?E0($,Z):null}case"list":{let Z=L6($.items,M,J);return Z?$0($,Z):null}default:return null}}function L6($,M,J){let Z=!1,X=$.map((D)=>{let Y=t9(D,M,J);if(!Y)return D;return Z=!0,Y});return Z?X:null}function L5($,M,J){let Z=n($,M);if(Z.start.regionId===Z.end.regionId)return WY($,Z,J);return wY($,Z,J)}function WY($,M,J){let Z=n0($,M.start.regionId);if(!Z)throw Error(`Unknown region: ${M.start.regionId}`);let X=r2($,Z.blockId,(q)=>EY(q,Z,M.start.offset,M.end.offset,J));if(!X)throw Error(`Failed to replace block for canvas region: ${Z.id}`);let D=$2($,X.document,Z.rootIndex,1),Y=$.document.comments.length===0?D:D7($,D,Z,M.start.offset,M.end.offset,J),Q=t1(Y,Z.path);if(!Q)throw Error(`Failed to remap region after replacement: ${Z.path}`);let K=M.start.offset+J.length;return{documentIndex:Y,selection:Y7(Q.id,K)}}function EY($,M,J,Z,X){switch($.type){case"heading":case"paragraph":return TY($,M,J,Z,X);case"code":return $5($,e9(M,J,Z,X));case"table":return yY($,M,J,Z,X);case"unsupported":return M5($,e9(M,J,Z,X));default:throw Error(`Canvas text replacement is not supported for block type: ${$.type}`)}}function TY($,M,J,Z,X){let D=x2(M.inlines,J,Z,X),Y=R5(D);return C0($,Y)}function yY($,M,J,Z,X){let D=M.tableCellPosition?.rowIndex,Y=M.tableCellPosition?.cellIndex;if(D===void 0||Y===void 0)throw Error(`Unable to resolve table cell position for region: ${M.id}`);let Q=x2(M.inlines,J,Z,X),K=R5(Q),q=$.rows.map((U,N)=>{if(N!==D)return U;let A=U.cells.map((V,B)=>{if(B!==Y)return V;return J1({children:K})});return{...U,cells:A}});return S0($,q)}function e9($,M,J,Z){return x2($.inlines,M,J,Z).map((X)=>X.text).join("")}function c2($){return $!==null&&($.type==="heading"||$.type==="paragraph")}function wY($,M,J){let Z=n0($,M.start.regionId),X=n0($,M.end.regionId);if(!Z||!X)throw Error("Unknown cross-region selection endpoints.");let D=$.document.blocks[Z.rootIndex],Y=$.document.blocks[X.rootIndex];if(!D||!Y)throw Error("Unknown root blocks for cross-region selection.");let Q=J7(D,Z,M.start.offset),K=Z7(Y,X,M.end.offset),q=OY(Q,K,J),U=q.blocks.length>0?q.blocks:[r({text:""})],N=Z.rootIndex,A=X.rootIndex-Z.rootIndex+1,V=I1($.document,N,A,U),B=$2($,V,N,A),G=$.document.comments.length===0?B:D7($,B,Z,M.start.offset,Z.text.length,c2(Q)?J:""),b=G.roots[N+q.caretLocalIndex]?.regions[0]??null;return{documentIndex:G,selection:Y7(b?.id??Z.id,b?q.caretOffset:0)}}function OY($,M,J){if(c2($)&&c2(M))return{blocks:[CY($,M,J)],caretLocalIndex:0,caretOffset:$.plainText.length+J.length};if(c2($)){let D=[J.length>0?jY($,J):$];if(M)D.push(M);return{blocks:D,caretLocalIndex:0,caretOffset:$.plainText.length+J.length}}if(c2(M)){let X=J.length>0?LY(M,J):M,D=[];if($)D.push($);let Y=D.length;return D.push(X),{blocks:D,caretLocalIndex:Y,caretOffset:J.length}}let Z=[];if($)Z.push($);if(J.length>0){let X=Z.length;if(Z.push(r({text:J})),M)Z.push(M);return{blocks:Z,caretLocalIndex:X,caretOffset:J.length}}if(M){let X=Z.length;return Z.push(M),{blocks:Z,caretLocalIndex:X,caretOffset:0}}return{blocks:Z,caretLocalIndex:0,caretOffset:0}}function CY($,M,J){let Z=J.length>0?[H0({text:J})]:[];return C0($,Q0([...$.children,...Z,...M.children]))}function jY($,M){return C0($,Q0([...$.children,H0({text:M})]))}function LY($,M){return C0($,Q0([H0({text:M}),...$.children]))}function J7($,M,J){if($.type==="table")return null;if($.id===M.blockId)return RY($,M,J);return X7($,(Z)=>fY(Z,M,J))}function Z7($,M,J){if($.type==="table")return null;if($.id===M.blockId)return kY($,M,J);return X7($,(Z)=>mY(Z,M,J))}function RY($,M,J){if(J===0)return null;switch($.type){case"heading":case"paragraph":{let Z=x2(M.inlines,J,M.text.length,"");return C0($,R5(Z))}case"code":return $5($,M.text.slice(0,J));case"unsupported":return M5($,M.text.slice(0,J));default:return null}}function kY($,M,J){if(J===M.text.length)return null;switch($.type){case"heading":case"paragraph":{let Z=x2(M.inlines,0,J,"");return C0($,R5(Z))}case"code":return $5($,M.text.slice(J));case"unsupported":return M5($,M.text.slice(J));default:return null}}function X7($,M){switch($.type){case"blockquote":{let J=M($.children);return J.length===0?null:P0({children:J})}case"list":{let J=M($.items);return J.length===0?null:$0($,J)}case"listItem":{let J=M($.children);return J.length===0?null:E0($,J)}default:return null}}function fY($,M,J){let Z=$.findIndex((Y)=>j5(Y,M));if(Z===-1)return[];let X=$.slice(0,Z),D=J7($[Z],M,J);return D?[...X,D]:X}function mY($,M,J){let Z=$.findIndex((Y)=>j5(Y,M));if(Z===-1)return[];let X=$.slice(Z+1),D=Z7($[Z],M,J);return D?[D,...X]:X}function j5($,M){if($.id===M.blockId)return!0;switch($.type){case"blockquote":case"listItem":return $.children.some((J)=>j5(J,M));case"list":return $.items.some((J)=>j5(J,M));default:return!1}}function D7($,M,J,Z,X,D){let Y=b6($,M,J,Z,X,D);return Y===M.document.comments?M:g2(M,{...M.document,comments:Y})}function Y7($,M){return{anchor:{regionId:$,offset:M},focus:{regionId:$,offset:M}}}function x2($,M,J,Z){let D=SY($,M,J,{didInsert:!1,generatedRunCount:0,replacementText:Z});return IY(pY(D))}function R5($){let M=[];for(let J=0;J<$.length;J+=1){let Z=$[J];if(Z.link){let D=[],Y=Z.link;while(J<$.length&&k6($[J].link,Y)){let Q=M7($[J]);if(Q)D.push(Q);J+=1}if(J-=1,D.length>0)M.push(u1({children:Q0(D),title:Y.title,url:Y.url}));continue}let X=M7(Z);if(X)M.push(X)}return Q0(M)}function SY($,M,J,Z){let X=[];for(let[D,Y]of $.entries()){if(!Z.didInsert&&M===J&&M===Y.start)R6(X,Z,$7($[D-1]??null,Y));if(J<=Y.start||M>=Y.end){X.push(k5(Y));continue}let Q=Math.max(0,M-Y.start),K=Math.min(Y.text.length,J-Y.start),q=!Z.didInsert&&Z.replacementText.length>0?Z.replacementText:"",U=uY(Y,Q,K,q,Z);if(Q!==K||q.length>0)Z.didInsert=!0;X.push(...U)}if(!Z.didInsert)R6(X,Z,$7($.at(-1)??null,null));return X}function uY($,M,J,Z,X){switch($.kind){case"text":case"inlineCode":case"unsupported":return vY($,M,J,Z);case"break":return hY($,M,J,Z,X);case"image":return gY($,M,J,Z)}}function vY($,M,J,Z){let X=$.text.slice(0,M)+Z+$.text.slice(J);return X.length>0?[{...k5($),text:X}]:[]}function hY($,M,J,Z,X){if(M===J)return[k5($)];let D=[];if(Z.length>0)R6(D,X,$.link);return D}function gY($,M,J,Z){if(M===0&&J===$.text.length)return Z.length>0?[Q7(Z,$.link,0)]:[];return[k5($)]}function R6($,M,J){if(M.replacementText.length===0){M.didInsert=!0;return}$.push(Q7(M.replacementText,J,M.generatedRunCount)),M.generatedRunCount+=1,M.didInsert=!0}function Q7($,M,J){return{id:`generated:${J}`,image:null,inlineCode:!1,kind:"text",link:M,marks:[],originalType:null,text:$}}function $7($,M){return $?.link&&M?.link&&k6($.link,M.link)?$.link:null}function k5($){return{id:$.id,image:$.image,inlineCode:$.inlineCode,kind:$.kind,link:$.link,marks:$.marks,originalType:$.originalType,text:$.text}}function IY($){let M=[],J=0;for(let Z of $){let X=J,D=X+Z.text.length;M.push({...Z,end:D,start:X}),J=D}return M}function pY($){let M=[];for(let J of $){let Z=M.at(-1);if(Z&&lY(Z,J)){M[M.length-1]={...Z,text:Z.text+J.text};continue}M.push(J)}return M}function lY($,M){return $.kind===M.kind&&$.inlineCode===M.inlineCode&&k6($.link,M.link)&&cY($.image,M.image)&&$.originalType===M.originalType&&$.marks.join(",")===M.marks.join(",")}function M7($){switch($.kind){case"break":return P2();case"image":return $.image?rY($.image):null;case"inlineCode":return S1({code:$.text});case"text":return $.text.length>0?H0({marks:$.marks,text:$.text}):null;case"unsupported":return n4({originalType:$.originalType??"unsupported",source:$.text})}}function rY($){return o4({alt:$.alt,title:$.title,url:$.url,width:$.width})}function k6($,M){return $?.url===M?.url&&$?.title===M?.title}function cY($,M){return $?.url===M?.url&&$?.title===M?.title&&$?.alt===M?.alt&&$?.width===M?.width}function K7($,M){switch(M.kind){case"replace-block":return C5($,M.blockId,M.block,M.selection??null);case"replace-root":return O5($,M.rootIndex,M.block,M.selection??null);case"replace-root-range":return J2($,M.rootIndex,M.count,M.replacements,M.selection??null);case"replace-selection":{let J=L5($,M.selection,M.text);return{document:J.documentIndex.document,documentIndex:J.documentIndex,selection:J.selection}}}return null}var f6=new Map([["rgba(0, 0, 0, 0)",[0,0,0,0]]]);function d2($){switch($.kind){case"active-block-flash":return 300;case"deleted-text-fade":return 180;case"inserted-text-highlight":return 1000;case"list-marker-pop":return 500;case"punctuation-pulse":return 140}}function S6($,M){let J=M??dY();return $.animations.some((Z)=>J-Z.startedAt<d2(Z))}function U7($,M){return u6($,M,"inserted-text-highlight",(J)=>J.regionPath)}function N7($,M){return z7($,M,"active-block-flash",(J)=>J.blockPath)}function A7($,M){return u6($,M,"deleted-text-fade",(J)=>J.regionPath)}function V7($,M){return u6($,M,"punctuation-pulse",(J)=>J.regionPath)}function G7($,M){return z7($,M,"list-marker-pop",(J)=>J.blockPath)}function B7($,M,J){let Z=new Set([$,M]);for(let X of J){if(X.endOffset<=$||X.startOffset>=M)continue;Z.add(Math.max($,X.startOffset)),Z.add(Math.min(M,X.endOffset))}return[...Z].sort((X,D)=>X-D)}function F7($,M,J){return $.find((Z)=>Z.startOffset<J&&Z.endOffset>M)??null}function _7($,M,J){if(!M)return $;return i2(J.insertHighlightText,$,M.progress)}function b7($,M){return i2($,"rgba(0, 0, 0, 0)",M.progress)}function m5($,M){return i2($,"rgba(0, 0, 0, 0)",M.progress)}function H7($,M){return i2(M.insertHighlightText,"rgba(0, 0, 0, 0)",$.progress)}function P7($){let M=Math.min(1,$.progress*2);return 0.1+0.9*xY(M)}function a2($,M,J){let Z=Math.max(0,M.progress*2-1);return i2(J.insertHighlightText,$,Z)}function u6($,M,J,Z){let X=new Map;for(let D of $.animations){if(D.kind!==J)continue;let Y=d2(D),Q=M-D.startedAt;if(Q>=Y)continue;let K={...D,progress:Math.max(0,Math.min(1,Q/Y))},q=Z(D),U=X.get(q);if(U)U.push(K);else X.set(q,[K])}return X}function z7($,M,J,Z){let X=new Map;for(let D of $.animations){if(D.kind!==J)continue;let Y=d2(D),Q=M-D.startedAt;if(Q>=Y)continue;X.set(Z(D),{...D,progress:Math.max(0,Math.min(1,Q/Y))})}return X}function xY($){return 1-(1-$)*(1-$)*(1-$)}function i2($,M,J){let Z=q7($),X=q7(M);return`rgba(${m6(f5(Z[0],X[0],J))}, ${m6(f5(Z[1],X[1],J))}, ${m6(f5(Z[2],X[2],J))}, ${f5(Z[3],X[3],J)})`}function dY(){return typeof performance<"u"?performance.now():Date.now()}function q7($){let M=f6.get($);if(M)return M;let J=aY($)??iY($)??sY($)??f6.get("rgba(0, 0, 0, 0)");return f6.set($,J),J}function aY($){let M=$.trim();if(!M.startsWith("#"))return null;let J=M.slice(1);if(J.length===3)return[Number.parseInt(`${J[0]}${J[0]}`,16),Number.parseInt(`${J[1]}${J[1]}`,16),Number.parseInt(`${J[2]}${J[2]}`,16),1];if(J.length===6)return[Number.parseInt(J.slice(0,2),16),Number.parseInt(J.slice(2,4),16),Number.parseInt(J.slice(4,6),16),1];return null}function iY($){let M=/^rgb\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec($.trim());if(!M)return null;return[Number(M[1]),Number(M[2]),Number(M[3]),1]}function sY($){let M=/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec($.trim());if(!M)return null;return[Number(M[1]),Number(M[2]),Number(M[3]),Number(M[4])]}function f5($,M,J){return $+(M-$)*J}function m6($){return Math.round($)}function S5($,M,J=N1()){if(M<=0)return $;let Z=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!Z)return $;let X=$.selection.focus.offset,D=Math.max(0,X-M);if(X<=D)return $;return s2($,{endOffset:X,kind:"inserted-text-highlight",regionPath:Z.path,startOffset:D,startedAt:J})}function v6($,M,J=N1()){if(M.text.length===0)return $;return s2($,{kind:"deleted-text-fade",regionPath:M.regionPath,startOffset:M.startOffset,startedAt:J,text:M.text})}function h6($,M,J=N1()){return s2($,{blockPath:M,kind:"active-block-flash",startedAt:J})}function g6($,M=N1()){let J=$.documentIndex.regionIndex.get($.selection.focus.regionId),Z=$.selection.focus.offset-1;if(!J||Z<0||J.text[Z]!==".")return $;return s2($,{kind:"punctuation-pulse",offset:Z,regionPath:J.path,startedAt:M})}function I6($,M,J=N1()){return s2($,{blockPath:M,kind:"list-marker-pop",startedAt:J})}function s2($,M){let J=u5($.animations,M.startedAt);return{...$,animations:[...J,M]}}function u5($,M){return $.filter((J)=>J.startedAt+d2(J)>M)}function N1(){return typeof performance<"u"?performance.now():Date.now()}function W7($){let M=$.documentIndex.regionIndex.get($.selection.focus.regionId);return(M?$.documentIndex.blockIndex.get(M.blockId)??null:null)?.path??""}function v5($,M){let J=Math.max(-1/0,...$.animations.map((Z)=>Z.startedAt));return M.animations.some((Z)=>Z.startedAt>J)}function o2($){let M=e1($),J=T7(M);return{animations:[],documentIndex:M,future:[],history:[],selection:{anchor:J,focus:J}}}function I0($){let M=L0($.documentIndex);return g1(z2($.documentIndex.document.blocks),M.threads,$.documentIndex.document.frontMatter)}function s($,M){if(!M)return null;switch(M.kind){case"keep-state":return $;case"set-selection":return D0($,M.selection);default:{let J=K7($.documentIndex,M);if(!J)return null;let Z=oY($,J.document,J.documentIndex??null),X=p2(Z.documentIndex,J.selection)??$.selection,D=y7($,Z,X);return D0(Z,X,D)}}}function D0($,M,J){let Z="regionId"in M?{anchor:h5($.documentIndex,M),focus:h5($.documentIndex,M)}:{anchor:h5($.documentIndex,M.anchor),focus:h5($.documentIndex,M.focus)},X={...$,selection:Z};return J??y7($,X)?h6(X,W7(X)):X}function y0($,M,J,Z){let X={regionId:M,offset:J};return D0($,Z?{anchor:$.selection.anchor,focus:X}:X)}function oY($,M,J=null){let Z=J??e1(M);return{animations:u5($.animations,N1()),documentIndex:Z,future:[],history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:nY(Z)}}function p6($){let M=$.history.at(-1);if(!M)return $;let J=e1(M.document);return{animations:[],documentIndex:J,future:[{document:$.documentIndex.document,selection:$.selection},...$.future],history:$.history.slice(0,-1),selection:M.selection}}function l6($){let M=$.future[0];if(!M)return $;let J=e1(M.document);return{animations:[],documentIndex:J,future:$.future.slice(1),history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:M.selection}}function g5($,M,J,Z){let X=L$($.documentIndex.document,M,J,Z),D=g2($.documentIndex,X);return{animations:u5($.animations,N1()),documentIndex:D,future:[],history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:$.selection}}function nY($){let M=T7($);return{anchor:M,focus:M}}function T7($){return $.regions[0]?{regionId:$.regions[0].id,offset:0}:{regionId:"empty",offset:0}}function h5($,M){let J=n0($,M.regionId);if(!J)return M;return{regionId:J.id,offset:Math.max(0,Math.min(M.offset,J.text.length))}}function y7($,M,J){let Z=E7($.documentIndex,$.selection),X=E7(M.documentIndex,J??M.selection);return X!==null&&X!==Z}function E7($,M){let J=$.regionIndex.get(M.focus.regionId),Z=J?$.blockIndex.get(J.blockId)??null:null;if(!J||!Z?.path)return null;return Z.type==="table"?`cell:${J.path}`:`block:${Z.path}`}function e2($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return{kind:"unsupported"};if(J.blockType==="code"){let Q=$.blockIndex.get(J.blockId);return Q?{kind:"code",region:J,rootIndex:Q.rootIndex}:{kind:"unsupported"}}let Z=A1($,J.id);if(Z)return{kind:"tableCell",...Z};let X=l0($,M);if(X)return{kind:"listItem",...X};let D=Z2($,M);if(D)return{kind:"blockquoteTextBlock",...D};let Y=p0($,M);if(Y)return{kind:"rootTextBlock",...Y};return{kind:"unsupported"}}function $4($,M){let J=$.blockIndex.get(M);if(!J)throw Error(`Unknown root block: ${M}`);return J.rootIndex}function I5($,M,J){let Z=M?$.blockIndex.get(M)??null:null;while(Z){if(Z.type===J)return Z;let X=Z.parentBlockId;Z=X?$.blockIndex.get(X)??null:null}return null}function n2($){let M=$.split("."),J=[];for(let Z=0;Z<M.length-1;Z+=1)if(M[Z]==="children"){let X=Number(M[Z+1]);if(Number.isInteger(X))J.push(X)}return J}function p0($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId);if(!Z)return null;let X=Z.rootIndex,D=$.document.blocks[X];if(!D||D.type!=="heading"&&D.type!=="paragraph")return null;return{block:D,region:J,rootIndex:X}}function w7($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=I5($,Z?.id??null,"blockquote");if(!X)return null;let D=X.rootIndex,Y=$.document.blocks[D];return Y?.type==="blockquote"?{quote:Y,rootIndex:D}:null}function Z2($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=I5($,Z?.id??null,"blockquote");if(!Z||!X||Z.parentBlockId!==X.id)return null;let D=X.rootIndex,Y=$.document.blocks[D];if(!Y||Y.type!=="blockquote")return null;let Q=Y.children.findIndex((q)=>q.id===Z.id),K=Y.children[Q];if(!K||K.type!=="heading"&&K.type!=="paragraph")return null;return{block:K,blockChildIndices:n2(Z.path),childIndex:Q,region:J,quote:Y,rootIndex:D}}function t2($,M){return r1($.document.blocks,M)}function l0($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=I5($,Z?.id??null,"listItem"),D=I5($,Z?.id??null,"list");if(!Z||!X||!D)return null;let Y=t2($,D.id);if(!Y||Y.type!=="list")return null;let Q=Y.items.findIndex((B)=>B.id===X.id),K=Y.items[Q];if(!K)return null;let q=D.parentBlockId?$.blockIndex.get(D.parentBlockId)??null:null,U=q?.parentBlockId?$.blockIndex.get(q.parentBlockId)??null:null,N=q?.type==="listItem"?t2($,q.id):null,A=U?.type==="list"?t2($,U.id):null,V=A?.type==="list"&&N?A.items.findIndex((B)=>B.id===N.id):-1;return{region:J,item:K,itemChildIndices:n2(X.path),itemIndex:Q,list:Y,listChildIndices:n2(D.path),parentItem:N?.type==="listItem"?N:null,parentItemChildIndices:q?.type==="listItem"?n2(q.path):null,parentItemIndex:V>=0?V:null,parentList:A?.type==="list"?A:null,parentListChildIndices:U?.type==="list"?n2(U.path):null,rootIndex:D.rootIndex}}function A1($,M){let J=$.regionIndex.get(M);if(!J)return null;let Z=$.tableCellIndex.get(J.id),X=$.blockIndex.get(J.blockId),D=X?.type==="table"?$.document.blocks[X.rootIndex]:null;if(!Z||!X||!D||D.type!=="table")return null;return{cellIndex:Z.cellIndex,rootIndex:X.rootIndex,rowIndex:Z.rowIndex,table:D}}function M4($,M,J){return d0({checked:M,children:[r({text:$})],spread:J})}function X2($,M){let J=$.children[0];if(!J||J.type!=="paragraph")return null;return E0($,[r({text:M}),...$.children.slice(1)])}function O7($,M){return M.reduce((J,Z)=>`${J}.children.${Z}`,`root.${$}`)}function C7($,M,J){let Z=$.regionIndex.get(M.anchor.regionId);if(!Z)return null;let X=n($,M),D=X.start.regionId===X.end.regionId&&X.start.regionId===Z.id?Z.text.slice(0,X.start.offset)+J+Z.text.slice(X.end.offset):J;return tY($,M,Z.id,D)??$Q($,M,Z.id,D)??eY($,M,Z.id,D)??MQ($,M,Z.id,D)??XQ($,Z.blockId,Z.rootIndex,D)??{kind:"replace-selection",selection:M,text:J}}function tY($,M,J,Z){let X=l0($,M),D=QQ(Z);if(!X||!D||X.region.id!==J)return null;let Y=X2(X.item,D.text);if(!Y)return null;return{kind:"replace-block",block:$0(X.list,X.list.items.map((Q,K)=>K===X.itemIndex?Y:Q),{ordered:D.ordered,start:D.ordered?1:null}),blockId:X.list.id,selection:X0(X.rootIndex,[...X.listChildIndices,X.itemIndex,0])}}function eY($,M,J,Z){if(!c6($,M,J))return null;if(/^\s*([-+*])\s\[( |x|X)\]\s$/.exec(Z)){let Y=Z.toLowerCase().includes("[x]");return r6($,M,{checked:Y,ordered:!1,start:null})}if(/^\s*[-+*]\s$/.test(Z))return r6($,M,{checked:null,ordered:!1,start:null});let D=/^\s*(\d+)\.\s$/.exec(Z);if(D)return r6($,M,{checked:null,ordered:!0,start:Number(D[1])});return null}function $Q($,M,J,Z){let X=p0($,M),D=KQ(Z);if(!X||X.region.id!==J||X.block.type!=="heading"||!D)return null;return{kind:"replace-root",block:M1({depth:D.depth,text:D.text}),rootIndex:X.rootIndex,selection:M0(X.rootIndex)}}function MQ($,M,J,Z){return JQ($,M,J,Z)??ZQ($,M,J,Z)}function JQ($,M,J,Z){if(!c6($,M,J))return null;let X=/^(#{1,6})\s$/.exec(Z);if(!X)return null;return DQ($,M,X[1].length)}function ZQ($,M,J,Z){if(!c6($,M,J)||!/^>\s$/.test(Z))return null;return YQ($,M)}function XQ($,M,J,Z){if(!/^(?:(?:-\s?){3}|(?:\*\s?){3}|(?:_\s?){3})$/.test(Z))return null;return{kind:"replace-root-range",count:1,replacements:[t4(),r({text:""})],rootIndex:$4($,M),selection:M0(J+1)}}function r6($,M,J){let Z=$4($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:P1({items:[d0({checked:J.checked,children:[r({text:""})],spread:!1})],ordered:J.ordered,spread:!1,start:J.start}),rootIndex:Z,selection:X0(Z,[0,0])}}function DQ($,M,J){let Z=$4($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:M1({depth:J,text:""}),rootIndex:Z,selection:M0(Z)}}function YQ($,M){let J=$4($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:P0({children:[r({text:""})]}),rootIndex:J,selection:X0(J,[0])}}function c6($,M,J){let Z=p0($,M);return Z?.region.id===J&&Z.block.type==="paragraph"}function QQ($){let M=/^[-+*]\s(.+)$/.exec($);if(M)return{ordered:!1,text:M[1]};let J=/^\d+\.\s(.+)$/.exec($);if(J)return{ordered:!0,text:J[1]};return null}function KQ($){let M=/^(#{1,6})\s(.+)$/.exec($);return M?{depth:M[1].length,text:M[2]}:null}function j7($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let Z=l0($,M);if(!Z)return null;let X=Z.region.text,D=Z.item,Y=typeof D.checked==="boolean"?!1:D.checked;if(J.start.offset===0){let N=M4("",Y,D.spread);return{kind:"replace-block",block:$0(Z.list,[...Z.list.items.slice(0,Z.itemIndex),N,D,...Z.list.items.slice(Z.itemIndex+1)]),blockId:Z.list.id,listItemInsertedPath:p5(N,Z.rootIndex,[...Z.listChildIndices,Z.itemIndex]),selection:X0(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex,0])}}if(J.start.offset===X.length){let N=M4("",Y,D.spread);return{kind:"replace-block",block:$0(Z.list,[...Z.list.items.slice(0,Z.itemIndex+1),N,...Z.list.items.slice(Z.itemIndex+1)]),blockId:Z.list.id,listItemInsertedPath:p5(N,Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1]),selection:X0(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1,0])}}let Q=X.slice(0,J.start.offset),K=X.slice(J.start.offset),q=M4(K,Y,D.spread),U=E0(D,[r({text:Q})]);return{kind:"replace-block",block:$0(Z.list,[...Z.list.items.slice(0,Z.itemIndex),U,q,...Z.list.items.slice(Z.itemIndex+1)]),blockId:Z.list.id,listItemInsertedPath:p5(q,Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1]),selection:X0(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1,0])}}function L7($,M){let J=n($,M),Z=l0($,M);if(!Z||J.start.regionId!==J.end.regionId)return null;if(J.start.offset!==0||Z.region.text.length!==0)return j7($,M);if(Z.parentItem&&Z.parentItemIndex!==null&&Z.parentItemChildIndices&&Z.parentList&&Z.parentListChildIndices)return qQ(Z);let X=Z.list.items.slice(0,Z.itemIndex),D=Z.list.items.slice(Z.itemIndex+1),Y=[];if(X.length>0)Y.push($0(Z.list,X));if(Y.push(r({text:""})),D.length>0)Y.push($0(Z.list,D));return{kind:"replace-root-range",count:1,replacements:Y,rootIndex:Z.rootIndex,selection:M0(Z.rootIndex+(X.length>0?1:0))}}function R7($,M){let J=l0($,M);if(!J)return null;if(typeof J.item.checked==="boolean"){let Z=d0({checked:null,children:J.item.children,spread:J.item.spread});return{kind:"replace-block",block:$0(J.list,J.list.items.map((X,D)=>D===J.itemIndex?Z:X)),blockId:J.list.id}}if(J.itemIndex>0){let Z=J.list.items[J.itemIndex-1];if(!Z)return null;if(J.item.plainText.length===0)return{kind:"replace-block",block:$0(J.list,J.list.items.filter((D,Y)=>Y!==J.itemIndex)),blockId:J.list.id,selection:X0(J.rootIndex,[...J.listChildIndices,J.itemIndex-1,0],"end")};let X=X2(Z,`${Z.plainText}${J.item.plainText}`);if(!X)return null;return{kind:"replace-block",block:$0(J.list,J.list.items.flatMap((D,Y)=>{if(Y===J.itemIndex-1)return[X];if(Y===J.itemIndex)return[];return[D]})),blockId:J.list.id,selection:X0(J.rootIndex,[...J.listChildIndices,J.itemIndex-1,0],"end")}}return{kind:"replace-root-range",count:1,replacements:[r({text:J.item.plainText})],rootIndex:J.rootIndex,selection:M0(J.rootIndex)}}function k7($,M){let J=l0($,M);if(!J||J.itemIndex===0)return null;let Z=J.list.items[J.itemIndex-1];if(!Z)return null;let X=UQ(Z,J.item,J);return{kind:"replace-block",block:$0(J.list,J.list.items.flatMap((D,Y)=>{if(Y===J.itemIndex-1)return[X.item];if(Y===J.itemIndex)return[];return[D]})),blockId:J.list.id,selection:X0(J.rootIndex,X.regionChildIndices)}}function f7($,M){let J=l0($,M);if(!J||!J.parentItem||J.parentItemIndex===null||!J.parentItemChildIndices||!J.parentList||!J.parentListChildIndices)return null;let Z=J.list.items.filter((Y,Q)=>Q!==J.itemIndex),X=J.parentItem.children.flatMap((Y)=>{if(Y.type!=="list"||Y.id!==J.list.id)return[Y];if(Z.length===0)return[];return[$0(J.list,Z)]}),D=E0(J.parentItem,X);return{kind:"replace-block",block:$0(J.parentList,[...J.parentList.items.slice(0,J.parentItemIndex),D,J.item,...J.parentList.items.slice(J.parentItemIndex+1)]),blockId:J.parentList.id,selection:X0(J.rootIndex,[...J.parentListChildIndices,J.parentItemIndex+1,0])}}function x6($,M,J){let Z=l0($,M);if(!Z)return null;let X=Z.itemIndex+J;if(X<0||X>=Z.list.items.length)return null;let D=[...Z.list.items],[Y]=D.splice(Z.itemIndex,1);if(!Y)return null;return D.splice(X,0,Y),{kind:"replace-block",block:$0(Z.list,D),blockId:Z.list.id,selection:X0(Z.rootIndex,[...Z.listChildIndices,X,0])}}function qQ($){if(!$.parentItem||$.parentItemIndex===null||!$.parentItemChildIndices||!$.parentList||!$.parentListChildIndices)return null;let M=$.list.items.filter((Y,Q)=>Q!==$.itemIndex),J=$.parentItem.children.flatMap((Y)=>{if(Y.type!=="list"||Y.id!==$.list.id)return[Y];if(M.length===0)return[];return[$0($.list,M)]}),Z=E0($.parentItem,J),X=typeof $.parentItem.checked==="boolean"?!1:$.parentItem.checked,D=M4("",X,$.parentItem.spread);return{kind:"replace-block",block:$0($.parentList,[...$.parentList.items.slice(0,$.parentItemIndex),Z,D,...$.parentList.items.slice($.parentItemIndex+1)]),blockId:$.parentList.id,listItemInsertedPath:p5(D,$.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1]),selection:X0($.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1,0])}}function p5($,M,J){return typeof $.checked==="boolean"?void 0:O7(M,J)}function UQ($,M,J){let Z=$.children.findIndex((D)=>D.type==="list"&&D.ordered===J.list.ordered&&D.start===J.list.start);if(Z>=0){let D=$.children[Z];if(!D||D.type!=="list")return{item:$,regionChildIndices:[...J.listChildIndices,J.itemIndex-1,0]};return{item:E0($,$.children.map((Y,Q)=>Q===Z?$0(D,[...D.items,M]):Y)),regionChildIndices:[...J.listChildIndices,J.itemIndex-1,Z,D.items.length,0]}}let X=P1({items:[M],ordered:J.list.ordered,spread:J.list.spread,start:J.list.start});return{item:E0($,[...$.children,X]),regionChildIndices:[...J.listChildIndices,J.itemIndex-1,$.children.length,0,0]}}function l5($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let Z=p0($,M);if(!Z)return NQ($,M);let X=Z.region.text.slice(0,J.start.offset),D=Z.region.text.slice(J.start.offset),Y=J.start.offset===0&&Z.region.text.length>0?Z.rootIndex:Z.rootIndex+1;if(Z.block.type==="paragraph")return{kind:"replace-root-range",count:1,replacements:J.start.offset===0?[r({text:""}),Z.block]:J.start.offset===Z.region.text.length?[Z.block,r({text:""})]:[r({text:X}),r({text:D})],rootIndex:Z.rootIndex,selection:M0(Y)};return{kind:"replace-root-range",count:1,replacements:J.start.offset===0?[r({text:""}),Z.block]:J.start.offset===Z.region.text.length?[Z.block,r({text:""})]:[M1({depth:Z.block.depth,text:X}),r({text:D})],rootIndex:Z.rootIndex,selection:M0(Y)}}function NQ($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let Z=Z2($,M);if(!Z)return null;let X=Z.region.text,D=X.slice(0,J.start.offset),Y=X.slice(J.start.offset),Q=Z.block.type==="heading"?_Q(Z.block,D,Y,Z.blockChildIndices,J.start.offset,X.length):FQ(Z.block,D,Y,Z.blockChildIndices,J.start.offset,X.length);return{kind:"replace-root",block:P0({children:[...Z.quote.children.slice(0,Z.childIndex),...Q.blocks,...Z.quote.children.slice(Z.childIndex+1)]}),rootIndex:Z.rootIndex,selection:X0(Z.rootIndex,Q.focusChildIndices)}}function m7($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;let Z=Z2($,M);if(!Z||Z.region.text.length!==0||Z.block.type!=="paragraph")return null;let X=Z.quote.children.slice(0,Z.childIndex),D=Z.quote.children.slice(Z.childIndex+1),Y=[];if(X.length>0)Y.push(P0({children:X}));if(Y.push(r({text:""})),D.length>0)Y.push(P0({children:D}));return{kind:"replace-root-range",count:1,replacements:Y,rootIndex:Z.rootIndex,selection:M0(Z.rootIndex+(X.length>0?1:0))}}function S7($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.regionId!==M.anchor.regionId)return null;let Z=$.regionIndex.get(J.start.regionId);if(!Z||Z.blockType!=="code")return null;return{kind:"replace-selection",selection:M,text:`
25
+ `}}function u7($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;let Z=p0($,M),X=Z?GQ(Z):null;if(X)return X;if(Z&&Z.rootIndex>0){let K=$.document.blocks[Z.rootIndex-1],q=$.document.blocks[Z.rootIndex+1];if(K){if(Z.block.plainText.length===0){let U=AQ(Z,K,q);if(U)return U;return{kind:"replace-root-range",count:1,replacements:[],rootIndex:Z.rootIndex,selection:K.type==="paragraph"||K.type==="heading"?M0(Z.rootIndex-1,"end"):K.type==="list"?X0(Z.rootIndex-1,[K.items.length-1,0],"end"):K.type==="blockquote"?X0(Z.rootIndex-1,[K.children.length-1],"end"):M0(Z.rootIndex-1,"end")}}if(K.type==="paragraph")return{kind:"replace-root-range",count:2,replacements:[r({text:`${K.plainText}${Z.block.plainText}`})],rootIndex:Z.rootIndex-1,selection:M0(Z.rootIndex-1,"end")};if(K.type==="heading")return{kind:"replace-root-range",count:2,replacements:[M1({depth:K.depth,text:`${K.plainText}${Z.block.plainText}`})],rootIndex:Z.rootIndex-1,selection:M0(Z.rootIndex-1,"end")};if(K.type==="list"){let U=K.items.length-1,N=K.items[U];if(N){let A=X2(N,`${N.plainText}${Z.block.plainText}`);if(A)return{kind:"replace-root-range",count:2,replacements:[$0(K,K.items.map((V,B)=>B===U?A:V))],rootIndex:Z.rootIndex-1,selection:X0(Z.rootIndex-1,[U,0],"end")}}}}}let D=BQ($,M);if(D)return D;let Y=w7($,M);if(!Y)return null;let Q=Z2($,M);return{kind:"replace-root-range",count:1,replacements:Y.quote.children,rootIndex:Y.rootIndex,selection:M0(Q?Y.rootIndex+Q.childIndex:Y.rootIndex)}}function d6($,M,J){let Z=p0($,M);if(!Z||Z.block.type!=="heading")return null;let X=Math.max(1,Math.min(6,Z.block.depth+J));if(X===Z.block.depth)return{kind:"keep-state"};return{kind:"replace-root",block:M1({depth:X,text:Z.block.plainText}),rootIndex:Z.rootIndex,selection:M0(Z.rootIndex,M.focus.offset)}}function AQ($,M,J){if($.block.type!=="paragraph"||$.block.plainText.length!==0||M.type!=="list"||J?.type!=="list"||!VQ(M,J))return null;let Z=M.items.length-1;return{kind:"replace-root-range",count:3,replacements:[$0(M,[...M.items,...J.items])],rootIndex:$.rootIndex-1,selection:X0($.rootIndex-1,[Z,0],"end")}}function VQ($,M){return $.ordered===M.ordered&&$.start===M.start}function GQ($){if($.block.type!=="heading")return null;return{kind:"replace-root",block:r({text:$.block.plainText}),rootIndex:$.rootIndex,selection:M0($.rootIndex)}}function BQ($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;let Z=Z2($,M);if(!Z||Z.block.type!=="paragraph"||Z.region.text.length!==0)return null;if(Z.quote.children.length===1)return{kind:"replace-root-range",count:1,replacements:[r({text:""})],rootIndex:Z.rootIndex,selection:M0(Z.rootIndex)};let X=Math.max(0,Z.childIndex-1),D=Z.childIndex>0?"end":0;return{kind:"replace-root",block:P0({children:Z.quote.children.filter((Y,Q)=>Q!==Z.childIndex)}),rootIndex:Z.rootIndex,selection:X0(Z.rootIndex,[X],D)}}function FQ($,M,J,Z,X,D){return{blocks:X===0?[r({text:""}),$]:X===D?[$,r({text:""})]:[r({text:M}),r({text:J})],focusChildIndices:X===0?Z:[...Z.slice(0,-1),Z.at(-1)+1]}}function _Q($,M,J,Z,X,D){return{blocks:X===0?[r({text:""}),$]:X===D?[$,r({text:""})]:[M1({depth:$.depth,text:M}),r({text:J})],focusChildIndices:X===0?Z:[...Z.slice(0,-1),Z.at(-1)+1]}}function v7($,M,J){let Z=p0($,M),X=Math.max(2,J);if(!Z||Z.block.type!=="paragraph"||Z.block.plainText.length>0||M.anchor.regionId!==M.focus.regionId||M.anchor.offset!==0||M.focus.offset!==0)return null;return{kind:"replace-root",block:z1({rows:Array.from({length:2},()=>i6(X))}),rootIndex:Z.rootIndex,selection:U1(Z.rootIndex,0,0)}}function a6($,M,J){let Z=A1($,M.focus.regionId);if(!Z)return null;let X=J<0?zQ(Z.table,Z.rowIndex,Z.cellIndex):WQ(Z.table,Z.rowIndex,Z.cellIndex);if(!X)return J>0&&EQ(Z.table,Z.rowIndex,Z.cellIndex)?bQ(Z):{kind:"keep-state"};let D=Z.table.rows[X.rowIndex]?.cells[X.cellIndex];if(!D)return{kind:"keep-state"};return{kind:"set-selection",selection:PQ($,M,Z.table,X.rowIndex,X.cellIndex,Math.min(M.focus.offset,D.plainText.length))}}function h7($,M){let J=H5($,M.focus.regionId);if(!J||J.kind!=="tableCell")return null;let Z=Math.min(M.anchor.offset,M.focus.offset),X=Math.max(M.anchor.offset,M.focus.offset),D=C6(J,Z,X);return{kind:"replace-block",block:D.block,blockId:D.blockId,selection:D.selection}}function g7($,M,J){let Z=A1($,M.focus.regionId);if(!Z)return null;let X=J==="left"?Z.cellIndex:Z.cellIndex+1;return D2(Z,z1({align:x7(Z.table.align,X,0,[null]),rows:Z.table.rows.map((D)=>v1({cells:HQ(D.cells,X,0,[c7()])}))}),U1(Z.rootIndex,Z.rowIndex,X))}function I7($,M){let J=A1($,M.focus.regionId);if(!J)return null;let Z=Math.max(0,...J.table.rows.map((X)=>X.cells.length));if(Z<=1)return null;return D2(J,z1({align:x7(J.table.align,J.cellIndex,1,[]),rows:J.table.rows.map((X)=>v1({cells:X.cells.filter((D,Y)=>Y!==J.cellIndex)}))}),U1(J.rootIndex,J.rowIndex,Math.min(J.cellIndex,Z-2)))}function p7($,M,J){let Z=A1($,M.focus.regionId);if(!Z)return null;let X=J==="above"?Z.rowIndex:Z.rowIndex+1,D=Math.max(1,...Z.table.rows.map((Y)=>Y.cells.length));return D2(Z,S0(Z.table,[...Z.table.rows.slice(0,X),i6(D),...Z.table.rows.slice(X)]),U1(Z.rootIndex,X,Math.min(Z.cellIndex,D-1)))}function l7($,M){let J=A1($,M.focus.regionId);if(!J||J.table.rows.length<=1)return null;let Z=J.table.rows.filter((Y,Q)=>Q!==J.rowIndex),X=Math.min(J.rowIndex,Z.length-1),D=Z[X]?.cells.length??1;return D2(J,S0(J.table,Z),U1(J.rootIndex,X,Math.min(J.cellIndex,D-1)))}function r7($,M){let J=A1($,M.focus.regionId);if(!J)return null;return D2(J,r({text:""}),M0(J.rootIndex))}function i6($){return v1({cells:Array.from({length:$},()=>c7())})}function c7(){return J1({children:[]})}function bQ($){let M=$.table.rows.length,J=Math.max(1,...$.table.rows.map((Z)=>Z.cells.length));return D2($,S0($.table,[...$.table.rows,i6(J)]),U1($.rootIndex,M,0))}function D2($,M,J){return{kind:"replace-block",block:M,blockId:$.table.id,selection:J}}function HQ($,M,J,Z){return[...$.slice(0,M),...Z,...$.slice(M+J)]}function x7($,M,J,Z){return[...$.slice(0,M),...Z,...$.slice(M+J)]}function PQ($,M,J,Z,X,D){let Y=M2($,J.id,Z,X);if(!Y)return M;return{anchor:{regionId:Y.id,offset:D},focus:{regionId:Y.id,offset:D}}}function zQ($,M,J){if(J>0)return{cellIndex:J-1,rowIndex:M};if(M>0){let Z=$.rows[M-1];if(!Z||Z.cells.length===0)return null;return{cellIndex:Z.cells.length-1,rowIndex:M-1}}return null}function WQ($,M,J){let Z=$.rows[M];if(!Z)return null;if(J+1<Z.cells.length)return{cellIndex:J+1,rowIndex:M};let X=$.rows[M+1];if(!X||X.cells.length===0)return null;return{cellIndex:0,rowIndex:M+1}}function EQ($,M,J){let Z=$.rows[M];return Boolean(Z&&M===$.rows.length-1&&J===Z.cells.length-1)}function Y2($,M){let J=C7($.documentIndex,$.selection,M),Z=s($,J);if(!Z)return null;if(J?.kind==="replace-selection"&&M.length>0)Z=S5(Z,M.length);if(M===".")Z=g6(Z);return Z}function J4($){switch(e2($.documentIndex,$.selection).kind){case"code":return s($,S7($.documentIndex,$.selection));case"tableCell":return s($,h7($.documentIndex,$.selection));case"listItem":{let J=L7($.documentIndex,$.selection);return wQ({state:s($,J)??s($,l5($.documentIndex,$.selection)),action:J})}case"blockquoteTextBlock":return s($,m7($.documentIndex,$.selection))??s($,l5($.documentIndex,$.selection));case"rootTextBlock":return s($,l5($.documentIndex,$.selection));case"unsupported":return null}}function r5($){if(a7($))return Z4($);let M=OQ($);if(M)return M;let J=n($.documentIndex,$.selection);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;switch(e2($.documentIndex,$.selection).kind){case"listItem":return s($,R7($.documentIndex,$.selection));case"blockquoteTextBlock":case"rootTextBlock":return s($,u7($.documentIndex,$.selection));default:return null}}function c5($){if(a7($))return Z4($);return CQ($)}function s6($,M){return s($,{kind:"replace-selection",selection:$.selection,text:M})}function x5($,M){let J=s6($,M);return M.length>0?S5(J,M.length):J}function Z4($){return s6($,"")}function o6($){let M=$.documentIndex.regions,J=M[0],Z=M.at(-1);if(!J||!Z)return $;return D0($,{anchor:{regionId:J.id,offset:0},focus:{regionId:Z.id,offset:Z.text.length}})}function n6($){switch(e2($.documentIndex,$.selection).kind){case"tableCell":return s($,a6($.documentIndex,$.selection,1));case"rootTextBlock":return s($,d6($.documentIndex,$.selection,1));case"listItem":return TQ($);default:return null}}function t6($){switch(e2($.documentIndex,$.selection).kind){case"tableCell":return s($,a6($.documentIndex,$.selection,-1));case"rootTextBlock":return s($,d6($.documentIndex,$.selection,-1));case"listItem":return yQ($);default:return null}}function TQ($){return s($,k7($.documentIndex,$.selection))}function yQ($){return s($,f7($.documentIndex,$.selection))}function e6($){return s($,x6($.documentIndex,$.selection,-1))}function $3($){return s($,x6($.documentIndex,$.selection,1))}function M3($,M){return s($,v7($.documentIndex,$.selection,M))}function J3($,M){return s($,g7($.documentIndex,$.selection,M))}function Z3($){return s($,I7($.documentIndex,$.selection))}function X3($,M){return s($,p7($.documentIndex,$.selection,M))}function D3($){return s($,l7($.documentIndex,$.selection))}function Y3($){return s($,r7($.documentIndex,$.selection))}function d5($,M){return d7($,(J,Z,X)=>y6(J,Z,X,M))}function Q3($){return d7($,(M,J,Z)=>O6(M,J,Z))}function X4($){return d5($,"bold")}function D4($){return d5($,"italic")}function Y4($){return d5($,"strikethrough")}function Q4($){return d5($,"underline")}function K3($,M,J,Z,X){return s($,E5($.documentIndex,M,J,Z,X))}function q3($,M,J,Z){return s($,E5($.documentIndex,M,J,Z,null))}function U3($,M){let J=t2($.documentIndex,M);if(!J||J.type!=="listItem"||typeof J.checked!=="boolean")return null;return s($,{kind:"replace-block",block:{...J,checked:!J.checked},blockId:M})}function a5($){return p6($)}function i5($){return l6($)}function N3($,M,J){let Z=_6($.documentIndex,M,J);if(!Z)return null;return g5($,$.documentIndex.document.comments.length,0,[Z])}function A3($,M,J){return K4($,M,(Z)=>m8(Z,{body:J.trim()}))}function V3($,M,J,Z){return K4($,M,(X)=>S8(X,J,Z))}function G3($,M,J){return K4($,M,(Z)=>u8(Z,J))}function B3($,M){return K4($,M,()=>null)}function F3($,M,J){return K4($,M,(Z)=>v8(Z,J))}function K4($,M,J){let X=L0($.documentIndex).threads[M];if(!X)return null;let D=J(X);if(D===X)return null;return g5($,M,1,D?[D]:[])}function wQ($){if(!$.state||!$.action||$.action.kind!=="replace-block"||!$.action.listItemInsertedPath)return $.state;return I6($.state,$.action.listItemInsertedPath)}function d7($,M){let J=n($.documentIndex,$.selection);if(J.start.regionId!==J.end.regionId||J.start.offset===J.end.offset)return null;return s($,I2($.documentIndex,J.start.regionId,J.start.offset,J.end.offset,M))}function a7($){let M=n($.documentIndex,$.selection);return M.start.regionId!==M.end.regionId||M.start.offset!==M.end.offset}function OQ($){return i7($,"backward")}function CQ($){return i7($,"forward")}function i7($,M){if($.selection.anchor.regionId!==$.selection.focus.regionId||$.selection.anchor.offset!==$.selection.focus.offset)return null;let J=n0($.documentIndex,$.selection.focus.regionId);if(!J)return null;if(M==="forward"&&$.selection.focus.offset>=J.text.length)return null;let Z=M==="backward"?RQ(J.text,$.selection.focus.offset):$.selection.focus.offset,X=M==="backward"?$.selection.focus.offset:kQ(J.text,$.selection.focus.offset);if(Z===X)return null;let D=s6(D0($,{anchor:{regionId:J.id,offset:Z},focus:{regionId:J.id,offset:X}}),"");return jQ($,D,Z,X)}function jQ($,M,J,Z){let X=LQ($,J,Z);return X?v6(M,X):M}function LQ($,M,J){let Z=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!Z)return null;let X=Z.text.slice(M,J);if(X.length===0)return null;if(!Z.inlines.find((Y)=>Y.start<=M&&Y.end>=J&&Y.kind==="text"&&Y.link===null&&Y.marks.length===0))return null;return{regionPath:Z.path,startOffset:M,text:X}}function RQ($,M){let J=Array.from($.slice(0,M));if(J.length===0)return 0;return M-J.at(-1).length}function kQ($,M){let J=Array.from($.slice(M))[0];return J?M+J.length:$.length}var s7=1;function o7($,M,J){let Z=$.documentIndex.regionOrderIndex.get($.selection.focus.regionId);if(Z===void 0)return $;let X=$.documentIndex.regions[Z],D=$.selection.focus.offset+M;if(D>=0&&D<=X.text.length)return y0($,X.id,D,J);if(M<0){let Q=$.documentIndex.regions[Z-1];if(!Q)return $;return y0($,Q.id,Q.text.length,J)}let Y=$.documentIndex.regions[Z+1];if(!Y)return $;return y0($,Y.id,0,J)}function n7($,M,J,Z,X){let D=j2(M,J.regionId,J.offset);if(!D)return $;let Y=M.lines[D.index+Z];if(!Y)return $;let Q=T0(M,$,{x:g0($,M,J)+s7,y:Y.top+Y.height/2});if(!Q)return $;return y0($,Q.regionId,Q.offset,X)}function t7($,M,J,Z){let X=$M($,M);if(!X)return $;return y0($,X.regionId,J==="Home"?X.start:X.end,Z)}function e7($,M,J,Z,X){let D=$M($,M);if(!D)return $;let Q=Math.max(1,Math.floor(480/M.options.lineHeight)),K=j2(M,D.regionId,$.selection.focus.offset),q=K?M.lines[K.index+Z*Q]:null;if(!q)return $;let U=T0(M,$,{x:g0($,M,J)+s7,y:q.top+q.height/2});if(!U)return $;return y0($,U.regionId,U.offset,X)}function $M($,M){return s0(M,$.selection.focus.regionId,$.selection.focus.offset)}var fQ=1;function MM($,M,J,Z,X){let D=$.documentIndex.regionIndex.get($.selection.focus.regionId)??null;if(!D)return null;let Y=$.documentIndex.tableCellIndex.get(D.id)??null,Q=$.documentIndex.blockIndex.get(D.blockId)??null;if(!Y||Q?.type!=="table")return null;let K=mQ($,Q.id,Y.rowIndex+Z,Y.cellIndex)??SQ($,Q.id,Z);if(!K)return $;let q=M.regionBounds.get(D.id),U=M.regionBounds.get(K.id);if(!q||!U)return $;let N=U.top+uQ(J.top+J.height/2-q.top,0,Math.max(0,U.bottom-U.top-1)),A=T0(M,$,{x:g0($,M,J)+fQ,y:N});if(!A)return $;return y0($,A.regionId,A.offset,X)}function mQ($,M,J,Z){return M2($.documentIndex,M,J,Z)}function SQ($,M,J){let Z=$.documentIndex.blockIndex.get(M),X=$.documentIndex.regions,D=Z?$.documentIndex.roots[Z.rootIndex]?.regionRange:void 0;if(!D)return null;return J<0?X[D.start-1]??null:X[D.end]??null}function uQ($,M,J){return Math.max(M,Math.min(J,$))}function _3($,M,J=!1){return o7($,M,J)}function b3($,M,J,Z=!1){return vQ($,M,J,Z)}function H3($,M,J,Z=!1){return hQ($,M,J,Z)}function P3($,M,J,Z=!1){return t7($,M,J,Z)}function z3($,M,J=!1){return gQ($,M,J)}function vQ($,M,J,Z){let X=JM($,M);if(!X)return $;return MM($,M,X,J,Z)??n7($,M,X,J,Z)}function hQ($,M,J,Z){let X=JM($,M);if(!X)return $;return e7($,M,X,J,Z)}function gQ($,M,J){let Z=$.documentIndex.regions,X=M==="start"?Z[0]:Z.at(-1);if(!X)return $;return y0($,X.id,M==="start"?0:X.text.length,J)}function JM($,M){return v0(M,$.documentIndex,{regionId:$.selection.focus.regionId,offset:$.selection.focus.offset})}function XM($,M,J,Z,X,D,Y){let Q=J.image?Z.images.get(J.image.url):null,K=lQ(J,Z,Y),q=rQ(M,D,Y,K);if($.fillStyle=X.imageSurfaceBackground,$.fillRect(q.left,q.top,q.width,q.height),Q?.status==="loaded"&&Q.source)$.drawImage(Q.source,q.left,q.top,q.width,q.height);else IQ($,X,{...q,status:Q?.status==="error"?"error":"loading"});$.strokeStyle=X.imageSurfaceBorder,$.strokeRect(q.left,q.top,q.width,q.height)}function IQ($,M,J){let Z=J.status==="loading"?"Loading image":"Image unavailable",X=cQ(J),D=J.top+J.height/2+X.size*0.9;if($.save(),$.beginPath(),$.rect(J.left,J.top,J.width,J.height),$.clip(),J.status==="loading")pQ($,M,J);$.strokeStyle=M.imagePlaceholderIcon,$.lineWidth=1.5,$.strokeRect(X.left,X.top,X.size,X.size),$.beginPath(),$.arc(X.left+X.size*0.28,X.top+X.size*0.3,X.size*0.1,0,Math.PI*2),$.moveTo(X.left+X.size*0.12,X.top+X.size*0.82),$.lineTo(X.left+X.size*0.42,X.top+X.size*0.5),$.lineTo(X.left+X.size*0.58,X.top+X.size*0.66),$.lineTo(X.left+X.size*0.78,X.top+X.size*0.38),$.lineTo(X.left+X.size*0.88,X.top+X.size*0.82),$.stroke(),$.font='500 12px "Iowan Old Style", "Palatino Linotype", serif',$.fillStyle=M.imagePlaceholderText,$.textAlign="center",$.textBaseline="middle",$.fillText(Z,J.left+J.width/2,D),$.restore()}function pQ($,M,J){let Z=Math.max(48,Math.round(J.width*0.22)),X=J.width+Z*2,D=performance.now()%1800/1800,Y=J.left-Z+X*D,Q=$.createLinearGradient(Y,J.top,Y+Z,J.top);Q.addColorStop(0,"rgba(255,255,255,0)"),Q.addColorStop(0.5,M.imageLoadingOverlay),Q.addColorStop(1,"rgba(255,255,255,0)"),$.fillStyle=Q,$.fillRect(J.left,J.top,J.width,J.height)}function lQ($,M,J){if(!$.image)return ZM(J);let Z=M.images.get($.image.url);if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return ZM(J);return Math.max(48,Math.round(J*(Z.intrinsicHeight/Z.intrinsicWidth)))}function rQ($,M,J,Z){return{height:Z,left:M,top:$.top+Math.max(0,Math.floor(($.height-Z)/2)),width:J}}function cQ($){let M=Math.max(18,Math.min(34,Math.round(Math.min($.width,$.height)*0.18)));return{left:$.left+Math.max(12,Math.round(($.width-M)/2)),size:M,top:$.top+Math.max(12,Math.round($.height/2-M*0.95))}}function ZM($){return Math.max(48,Math.round($*0.5625))}var DM=2,YM=8,xQ=3,dQ=1.5,aQ=2,Q2={elbow:{x:6.5,y:10.5},end:{x:11.5,y:3.5},start:{x:3.5,y:7.5}};function QM($,M,J,Z,X,D,Y=null){if(!J||M.start!==0)return;if(Y){let Q=P7(Y),K=tQ(J,M,Z,X,$);$.save(),$.translate(K.x,K.y),$.scale(Q,Q),$.translate(-K.x,-K.y)}if(J.kind==="task")iQ($,M,J.checked,D,Y);else if($.fillStyle=Y?a2(D.listMarkerText,Y,D):D.listMarkerText,J.kind==="ordered")nQ($,J.label,Z,X);else $.fillText(J.label,M.left-DM,X);if(Y)$.restore()}function iQ($,M,J,Z,X=null){let D=R2(M);if(sQ($,D,J,Z,X),!J)return;oQ($,D,Z,X)}function sQ($,M,J,Z,X=null){let D=J?Z.checkboxCheckedFill:Z.checkboxUncheckedFill,Y=J?Z.checkboxCheckedStroke:Z.checkboxUncheckedStroke;$.fillStyle=X?a2(D,X,Z):D,$.strokeStyle=X?a2(Y,X,Z):Y,$.beginPath(),$.lineWidth=dQ,$.roundRect(M.left,M.top,M.size,M.size,xQ),$.fill(),$.stroke()}function oQ($,M,J,Z=null){$.strokeStyle=Z?a2(J.checkboxCheckmark,Z,J):J.checkboxCheckmark,$.lineWidth=aQ,$.beginPath(),$.moveTo(M.left+Q2.start.x,M.top+Q2.start.y),$.lineTo(M.left+Q2.elbow.x,M.top+Q2.elbow.y),$.lineTo(M.left+Q2.end.x,M.top+Q2.end.y),$.stroke()}function nQ($,M,J,Z){let X=$.textAlign;$.textAlign="right",$.fillText(M,J-YM,Z),$.textAlign=X}function tQ($,M,J,Z,X){if($.kind==="task"){let Q=R2(M);return{x:Q.left+Q.size/2,y:Q.top+Q.size/2}}let D=X.measureText($.label),Y=Z-(D.actualBoundingBoxAscent-D.actualBoundingBoxDescent)/2;if($.kind==="ordered")return{x:J-YM-D.width/2,y:Y};return{x:M.left-DM+D.width/2,y:Y}}var eQ=80;function qM({context:$,containerBounds:M,isHeaderRow:J,lineHeight:Z,theme:X}){let D=NM(M,Z);$.fillStyle=J?X.tableHeaderBackground:X.tableBodyBackground,$.fillRect(D.left,D.top,D.width,D.height),AM($,D,X)}function UM({activeBlockFlashes:$,activeBlockId:M,activeRegionId:J,context:Z,editorState:X,endIndex:D,layout:Y,regionBounds:Q,startIndex:K,theme:q,verticalBleed:U}){if(!M||!J)return;let N=X.documentIndex.blockIndex.get(M)??null;if(N?.type!=="table")return;if((X.documentIndex.regionIndex.get(J)??null)?.blockId!==M)return;let V=Q.get(J)??null,B=Y.regionLineIndices.get(J)??null;if(!V||!B||B.length===0)return;let G=Y.lines[B[0]]??null;if(!G)return;let b=NM(V,G.height);if(b.width===0)return;let P=KM({context:Z,endIndex:D,fillStyle:q.activeBlockBackground,layout:Y,left:b.left,lineIndices:B,startIndex:K,verticalBleed:U,width:b.width}),y=N.path?$.get(N.path)??null:null;if(y)KM({context:Z,endIndex:D,fillStyle:m5(q.activeBlockFlash,y),layout:Y,left:b.left,lineIndices:B,startIndex:K,verticalBleed:U,width:b.width});if(!P)return;AM(Z,b,q)}function KM({context:$,endIndex:M,fillStyle:J,layout:Z,left:X,lineIndices:D,startIndex:Y,verticalBleed:Q,width:K}){$.fillStyle=J;let q=!1;for(let U of D){if(U<Y)continue;if(U>=M)break;let N=Z.lines[U];$.fillRect(X,N.top-Q,K,N.height),q=!0}return q}function NM($,M){return{height:Math.max($.bottom-$.top,M),left:$.left,top:$.top,width:Math.max($.right-$.left,eQ)}}function AM($,M,J){$.strokeStyle=J.tableBorder,$.strokeRect(M.left,M.top,M.width,M.height)}var W3=2,$K=3,MK=12,JK=6,ZK=3,XK=1,DK=2,YK=2,QK=8,KK=12,qK=28,UK=4,NK=5,AK=2,VK=3,GK=6,VM=3,BK=12,FK=10,_K=2,bK=2,HK=1,PK=2,E3=2,GM=1.25,zK=5,WK=1,BM=4,EK=4,TK=1.5;function yK({activeBlockId:$,activeRegionId:M,activeThreadIndex:J,containerLineBounds:Z,context:X,devicePixelRatio:D,editorState:Y,height:Q,layout:K,liveCommentRanges:q,normalizedSelection:U,now:N=oK(),resources:A,runtimeBlockMap:V,theme:B,viewportTop:G,width:b}){X.save(),X.scale(D,D),X.clearRect(0,0,b,Q),X.fillStyle=B.background,X.fillRect(0,0,b,Q),X.textBaseline="alphabetic",X.translate(0,-G);let P=wK(Y,U),{endIndex:y,startIndex:z}=J6(K,G,Q),L=N7(Y,N),R=A7(Y,N),m=U7(Y,N),E=G7(Y,N),_=V7(Y,N),j=CK(K,Y,$,z,y),C=OK(K,Y,V,z,y,b);for(let W=z;W<y;W+=1){let F=K.lines[W];kK({containerLineBounds:Z,context:X,editorState:Y,line:F,runtimeBlockMap:V,theme:B,width:b})}UM({activeBlockFlashes:L,activeBlockId:$,activeRegionId:M,context:X,editorState:Y,endIndex:y,layout:K,regionBounds:Z,startIndex:z,theme:B,verticalBleed:W3});for(let W=z;W<y;W+=1){let F=K.lines[W];fK({activeBlockId:$,activeBlockFlashes:L,activeDeletedTextFades:R,activeThreadIndex:J,activeInsertedTextHighlights:m,activeListMarkerPops:E,activePunctuationPulses:_,context:X,editorState:Y,line:F,liveCommentRanges:q,normalizedSelection:U,resources:A,runtimeBlockMap:V,selectionRegionOrderRange:P,theme:B,width:b})}jK(X,C,B),LK(X,j,B),X.restore()}function wK($,M){let J=$.documentIndex.regionOrderIndex,Z=J.get(M.start.regionId),X=J.get(M.end.regionId);return Z===void 0||X===void 0?null:{end:X,start:Z}}function OK($,M,J,Z,X,D){let Y=new Map;for(let Q=Z;Q<X;Q+=1){let K=$.lines[Q],q=J.get(K.blockId);if(q?.type!=="heading"||q.depth!==1&&q.depth!==2)continue;let U=Y.get(q.id),N={bottom:K.top+K.height,left:K.left+K1(M,K),right:D-$.options.paddingX};Y.set(q.id,U?{bottom:Math.max(U.bottom,N.bottom),left:U.left,right:U.right}:N)}return Y}function CK($,M,J,Z,X){let D=new Map;for(let Y=Z;Y<X;Y+=1){let Q=$.lines[Y],K=n1(M,Q.blockId,"blockquote");if(!K)continue;let q=D.get(K.id),U={bottom:Q.top+Q.height,isActive:Q.blockId===J,left:$.options.paddingX+(K.depth+1)*$.options.indentWidth-10,top:Q.top};D.set(K.id,q?{bottom:Math.max(q.bottom,U.bottom),isActive:q.isActive||U.isActive,left:q.left,top:Math.min(q.top,U.top)}:U)}return D}function jK($,M,J){$.fillStyle=J.headingRule;for(let Z of M.values())$.fillRect(Z.left,Z.bottom+zK,Math.max(E3,Z.right-Z.left),WK)}function LK($,M,J){for(let Z of M.values())$.fillStyle=Z.isActive?J.blockquoteRuleActive:J.blockquoteRule,$.fillRect(Z.left,Z.top+$K,ZK,Math.max(MK,Z.bottom-Z.top-JK))}function RK({context:$,devicePixelRatio:M,editorState:J,height:Z,layout:X,normalizedSelection:D,presence:Y,showCaret:Q,theme:K,viewportTop:q,width:U}){$.save(),$.scale(M,M),$.clearRect(0,0,U,Z);let N=D.start.regionId===D.end.regionId&&D.start.offset!==D.end.offset,A=Q&&!N;if($.translate(0,-q),A)FM($,J,X,{color:K.caret,offset:J.selection.focus.offset,regionId:J.selection.focus.regionId});if(Y)for(let V of Y){if(!V.cursorPoint)continue;FM($,J,X,{color:V.color??K.leafAccent,offset:V.cursorPoint.offset,regionId:V.cursorPoint.regionId})}$.restore()}function FM($,M,J,Z){let X=v0(J,M.documentIndex,{regionId:Z.regionId,offset:Z.offset});if(!X)return;let D=g0(M,J,X),Y=pK(J,X);$.fillStyle=Z.color,$.fillRect(D,Y.top,DK,Y.height)}function kK({containerLineBounds:$,context:M,editorState:J,line:Z,runtimeBlockMap:X,theme:D,width:Y}){let Q=X.get(Z.blockId)??null,K=$.get(Z.regionId)??null,q=J.documentIndex.tableCellIndex.get(Z.regionId)??null;mK(M,Z,Q,K,q,D,Y)}function fK({activeBlockId:$,activeBlockFlashes:M,activeDeletedTextFades:J,activeThreadIndex:Z,activeInsertedTextHighlights:X,activeListMarkerPops:D,activePunctuationPulses:Y,context:Q,editorState:K,line:q,liveCommentRanges:U,normalizedSelection:N,resources:A,runtimeBlockMap:V,selectionRegionOrderRange:B,theme:G,width:b}){let P=V.get(q.blockId)??null,y=K.documentIndex.blockIndex.get(q.blockId)?.path??null,z=K.documentIndex.regionIndex.get(q.regionId)??null,L=z?.path??"",R=n1(K,q.blockId,"listItem"),m=R?k2(K,R.id):null,E=R?D.get(R.path)??null:null,_=q.left+K1(K,q),j=cK(q),C=P?.type==="code"?G.codeText:aK(P,G);Q.font=q.font,SK(Q,q,P,y,$,M,G,b),uK(Q,K,q,N,B,G),vK(Q,K,q,U,Z,G),QM(Q,q,m,_,j,G,E),hK(Q,q,z,_,j,X.get(L)??[],C,A,G),gK(Q,q,z,_,j,J.get(L)??[],C),IK(Q,q,z,_,j,Y.get(L)??[],G)}function mK($,M,J,Z,X,D,Y){if(!Z||M.start!==0)return;if(J?.type==="code"){let Q=Math.max(0,M.left-KK);$.fillStyle=D.codeBackground,$.fillRect(Q,Z.top-UK,Math.max(Z.right-M.left+qK,Y-Q),Z.bottom-Z.top+QK);return}if(J?.type!=="table")return;qM({context:$,containerBounds:Z,isHeaderRow:X?.rowIndex===0,lineHeight:M.height,theme:D})}function SK($,M,J,Z,X,D,Y,Q){if(M.blockId!==X||J?.type==="table")return;let K=Z?D.get(Z)??null:null;if($.fillStyle=Y.activeBlockBackground,$.fillRect(0,M.top-W3,Q,M.height),!K)return;$.fillStyle=m5(Y.activeBlockFlash,K),$.fillRect(0,M.top-W3,Q,M.height)}function uK($,M,J,Z,X,D){if(!X)return;let Y=M.documentIndex.regionOrderIndex.get(J.regionId);if(Y===void 0||Y<X.start||Y>X.end)return;let Q=Y===X.start?Math.max(J.start,Z.start.offset):J.start,K=Y===X.end?Math.min(J.end,Z.end.offset):J.end;if(K<=Q)return;$.fillStyle=D.selectionBackground,$.fillRect(Q1(M,J,Q-J.start),J.top+HK,Math.max(bK,Q1(M,J,K-J.start)-Q1(M,J,Q-J.start)),J.height-PK)}function vK($,M,J,Z,X,D){for(let Y of Z){if(Y.regionId!==J.regionId)continue;let Q=Math.max(Y.startOffset,J.start),K=Math.min(Y.endOffset,J.end);if(K<=Q)continue;$.fillStyle=sK(Y,X,D),$.fillRect(Q1(M,J,Q-J.start),J.top+J.height-NK,Math.max(AK,Q1(M,J,K-J.start)-Q1(M,J,Q-J.start)),VK)}}function hK($,M,J,Z,X,D,Y,Q,K){if(!J){$.fillStyle=Y,$.fillText(M.text,Z,X);return}let q=J.inlines.filter((U)=>U.end>M.start&&U.start<M.end);if(q.length===0){$.fillStyle=Y,$.fillText(M.text,Z,X);return}for(let U of q){let N=Math.max(M.start,U.start),A=Math.min(M.end,U.end);if(J.text.slice(N,A).length===0)continue;let{left:B,right:G}=y3(M,Z,N,A),b=iK(M.font,U.marks);if($.font=b,U.kind==="image"){let P=Math.max(24,G-B);XM($,M,U,Q,K,B,P);continue}if(U.kind==="inlineCode"){let P=xK(M,b),y=dK(M,b);$.fillStyle=K.inlineCodeBackground,$.fillRect(B-VM,P,Math.max(FK,G-B+VM*2),y),_M($,M,J.text,Z,X,N,A,K.inlineCodeText,D,K,{strikethrough:!1,underline:!1});continue}_M($,M,J.text,Z,X,N,A,U.link?K.linkText:Y,D,K,{strikethrough:U.marks.includes("strikethrough"),underline:U.marks.includes("underline")||Boolean(U.link)})}}function _M($,M,J,Z,X,D,Y,Q,K,q,U){let N=B7(D,Y,K);for(let A=0;A<N.length-1;A+=1){let V=N[A],B=N[A+1];if(B<=V)continue;let G=J.slice(V,B);if(G.length===0)continue;let{left:b,right:P}=y3(M,Z,V,B),y=F7(K,V,B),z=_7(Q,y,q);if($.fillStyle=z,$.fillText(G,b,X),U.strikethrough)$.fillRect(b,rK(X,M.height,$.font),Math.max(E3,P-b),GM);if(U.underline)$.fillRect(b,lK(X,M.height,$.font),Math.max(E3,P-b),GM)}}function gK($,M,J,Z,X,D,Y){if(!J||D.length===0)return;for(let Q of D){if(Q.startOffset<M.start||Q.startOffset>M.end)continue;let K=Z+(h0(M,Q.startOffset-M.start)-M.left);$.fillStyle=b7(Y,Q),$.fillText(Q.text,K,X)}}function IK($,M,J,Z,X,D,Y){if(!J||D.length===0)return;for(let Q of D){if(Q.offset<M.start||Q.offset>=M.end)continue;let{left:K,right:q}=y3(M,Z,Q.offset,Q.offset+1),U=Math.max(BM,(q-K)/2+BM+EK*Q.progress),{ascent:N,descent:A}=Y1(M.font),V=X-Math.max(1,N*0.42)+Math.max(0.5,A*0.15);$.strokeStyle=H7(Q,Y),$.lineWidth=TK,$.beginPath(),$.arc((K+q)/2,V,U,0,Math.PI*2),$.stroke()}}function pK($,M){let J=s0($,M.regionId,M.offset),Z=J?.font??'16px "Iowan Old Style", "Palatino Linotype", serif',{ascent:X,descent:D}=Y1(Z),Y=Math.max(1,X+D),Q=Math.min(M.height-YK,Y),K=J?Math.max(J.top,J.top+T3(J.height,Z)-XK):M.top+Math.max(0,Math.floor((M.height-Q)/2));return{height:Q,top:K}}function lK($,M,J){let{descent:Z}=Y1(J),X=Math.max(1,Math.round(Math.max(2,Z)*0.35)),D=$+Z-X,Y=$-s5(M,J);return Math.min(Y+M-4,D)}function rK($,M,J){let{ascent:Z}=Y1(J),X=$-s5(M,J);return Math.max(X+2,$-Math.round(Z*0.32))}function cK($){return $.top+s5($.height,$.font)}function s5($,M){return R9($,M)}function xK($,M){let J=T3($.height,M);return $.top+J+_K}function dK($,M){let J=T3($.height,M);return Math.max(BK,$.height-J-GK)}function T3($,M){let{ascent:J}=Y1(M);return s5($,M)-J}function aK($,M){switch($?.type){case"heading":return M.headingText;case"blockquote":return M.blockquoteText;case"table":return M.headingText;default:return M.paragraphText}}function y3($,M,J,Z){return{left:M+(h0($,J-$.start)-$.left),right:M+(h0($,Z-$.start)-$.left)}}function iK($,M){let J=[];if(M.includes("italic"))J.push("italic");if(M.includes("bold"))J.push("700");return J.length>0?`${J.join(" ")} ${$}`:$}function sK($,M,J){if($.resolved)return $.threadIndex===M?J.commentHighlightResolvedActive:J.commentHighlightResolved;return $.threadIndex===M?J.commentHighlightActive:J.commentHighlight}function oK(){return typeof performance<"u"?performance.now():Date.now()}function w3($,M,J,Z){yK({activeBlockId:Z.activeBlockId,activeRegionId:Z.activeRegionId,activeThreadIndex:Z.activeThreadIndex,containerLineBounds:M.regionBounds,context:J,devicePixelRatio:Z.devicePixelRatio,editorState:$,height:Z.height,layout:M.layout,liveCommentRanges:Z.liveCommentRanges,normalizedSelection:Z.normalizedSelection,now:Z.now,resources:Z.resources??{images:new Map},runtimeBlockMap:M.blockMap,theme:Z.theme,viewportTop:M.paintTop,width:Z.width})}function O3($,M,J,Z){RK({context:J,devicePixelRatio:Z.devicePixelRatio,editorState:$,height:Z.height,layout:M.layout,normalizedSelection:Z.normalizedSelection,presence:Z.presence,showCaret:Z.showCaret,theme:Z.theme,viewportTop:M.paintTop,width:Z.width})}import{forwardRef as Mq,createElement as Jq}from"react";var o5=(...$)=>$.filter((M,J,Z)=>{return Boolean(M)&&M.trim()!==""&&Z.indexOf(M)===J}).join(" ").trim();var bM=($)=>$.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var HM=($)=>$.replace(/^([A-Z])|[\s-_]+(\w)/g,(M,J,Z)=>Z?Z.toUpperCase():J.toLowerCase());var C3=($)=>{let M=HM($);return M.charAt(0).toUpperCase()+M.slice(1)};import{forwardRef as $q,createElement as WM}from"react";var n5={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var PM=($)=>{for(let M in $)if(M.startsWith("aria-")||M==="role"||M==="title")return!0;return!1};import{createContext as nK,useContext as tK,useMemo as t_,createElement as e_}from"react";var eK=nK({});var zM=()=>tK(eK);var EM=$q(({color:$,size:M,strokeWidth:J,absoluteStrokeWidth:Z,className:X="",children:D,iconNode:Y,...Q},K)=>{let{size:q=24,strokeWidth:U=2,absoluteStrokeWidth:N=!1,color:A="currentColor",className:V=""}=zM()??{},B=Z??N?Number(J??U)*24/Number(M??q):J??U;return WM("svg",{ref:K,...n5,width:M??q??n5.width,height:M??q??n5.height,stroke:$??A,strokeWidth:B,className:o5("lucide",V,X),...!D&&!PM(Q)&&{"aria-hidden":"true"},...Q},[...Y.map(([G,b])=>WM(G,b)),...Array.isArray(D)?D:[D]])});var u=($,M)=>{let J=Mq(({className:Z,...X},D)=>Jq(EM,{ref:D,iconNode:M,className:o5(`lucide-${bM(C3($))}`,`lucide-${$}`,Z),...X}));return J.displayName=C3($),J};var Zq=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],V1=u("columns-2",Zq);var Xq=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],G1=u("rows-3",Xq);var Dq=[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]],B1=u("send-horizontal",Dq);var Yq=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],q4=u("arrow-down",Yq);var Qq=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],U4=u("arrow-up",Qq);var Kq=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],N4=u("bold",Kq);var qq=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],y1=u("check",qq);var Uq=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],A4=u("chevron-down",Uq);var Nq=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],V4=u("heading-1",Nq);var Aq=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],G4=u("heading-2",Aq);var Vq=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],B4=u("heading-3",Vq);var Gq=[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]],F4=u("heading-4",Gq);var Bq=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]],_4=u("heading-5",Bq);var Fq=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]],b4=u("heading-6",Fq);var _q=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],H4=u("heading",_q);var bq=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],P4=u("italic",bq);var Hq=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],z4=u("list-ordered",Hq);var Pq=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],W4=u("list-todo",Pq);var zq=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],E4=u("list",zq);var Wq=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],T4=u("message-square-plus",Wq);var Eq=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],w1=u("pencil",Eq);var Tq=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],K2=u("plus",Tq);var yq=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],y4=u("strikethrough",yq);var wq=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],F1=u("table-2",wq);var Oq=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],w4=u("text-quote",Oq);var Cq=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],w0=u("trash-2",Cq);var jq=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],O4=u("underline",jq);var Lq=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],C4=u("x",Lq);import{jsx as q2,jsxs as mq}from"react/jsx-runtime";function TM({insetX:$,insetY:M,onSelect:J,presence:Z}){if(!Z)return null;return q2("div",{"aria-label":"Presence",className:"documint-presence-indicators",style:{paddingRight:`${$}px`,top:`${M}px`},children:Z.map((X)=>q2(Rq,{onSelect:()=>J(X),presence:X},X.id))})}function Rq({onSelect:$,presence:M}){let J=M.viewport,Z=kq(M),X=J?.status==="above"?U4:q4,D=J!==null&&J.status!=="unresolved",Y=J?.status==="above"||J?.status==="below";return mq("button",{"aria-label":fq(M),className:"documint-presence-indicator","data-status":J?.status??"unresolved",disabled:!D,onClick:D?$:void 0,style:{"--documint-presence-color":M.color??"var(--documint-leaf-accent)"},type:"button",children:[q2("span",{className:"documint-presence-indicator-avatar",children:M.avatarUrl?q2("img",{alt:"","aria-hidden":"true",className:"documint-presence-indicator-image",draggable:!1,src:M.avatarUrl}):Z}),Y?q2("span",{className:"documint-presence-indicator-direction","aria-hidden":"true",children:q2(X,{className:"documint-presence-indicator-arrow",size:14,strokeWidth:2.3})}):null]})}function kq($){return yM($).charAt(0).toLocaleUpperCase()}function fq($){let M=yM($),J=$.viewport?.status??"unresolved";if(J==="above")return`${M} above viewport`;if(J==="below")return`${M} below viewport`;if(J==="unresolved")return`${M} unresolved`;return`${M} in viewport`}function yM($){return($.fullName??$.username).trim()||"Presence"}var o=`
26
+ `,_1="<ins>",j4="</ins>",U2=">",L4="```",t5=":::",j3=/^:::([A-Za-z][-\w]*)(.*)$/,e5="documint-comments";var $8="`",f3="\\",R3="![",k3="[",jM="(",wM=")",LM=" ",RM=":",Sq=/[A-Za-z]/,uq=/[-A-Za-z0-9_]/,vq=/^\{width=([1-9]\d*)\}/,hq=/\\([\\`*_[\]{}()#+\-.!~|])/g,kM=/\\(.)/g,gq=[{delimiter:"**",mark:"bold"},{delimiter:"~~",mark:"strikethrough"},{delimiter:"*",mark:"italic"}];function N2($,M=[]){return m3($,0,$.length,M)}function m3($,M,J,Z){let X=[],D=M,Y=M;while(D<J){let Q=Iq($,D,J,Z);if(Q){OM(X,$.slice(Y,D),Z),X.push(...Q.nodes),D=Q.end,Y=D;continue}if($[D]===f3){D+=Math.min(2,J-D);continue}D+=1}return OM(X,$.slice(Y,J),Z),pq(X)}function Iq($,M,J,Z){switch($[M]){case RM:return tq($,M,J);case"<":return oq($,M,J,Z);case $8:return dq($,M,J);case"!":return aq($,M,J);case k3:return iq($,M,J,Z);case"*":case"~":return rq($,M,J,Z);default:return null}}function OM($,M,J){if(M.length===0)return;$.push(H0({marks:J,text:vM(M)}))}function S3($,M){return n4({originalType:$,source:M})}function pq($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&cq(Z.marks,J.marks)){M[M.length-1]=H0({marks:Z.marks,text:Z.text+J.text});continue}M.push(J)}return M}function lq($,M,J){for(let Z of gq){if(!$.startsWith(Z.delimiter,M))continue;let X=$.indexOf(Z.delimiter,M+Z.delimiter.length);if(X<0||X>=J)continue;return{contentEnd:X,contentStart:M+Z.delimiter.length,end:X+Z.delimiter.length,mark:Z.mark}}return null}function rq($,M,J,Z){let X=lq($,M,J);if(!X)return null;return{end:X.end,nodes:m3($,X.contentStart,X.contentEnd,[...Z,X.mark])}}function cq($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function xq($,M,J){if($[M]!==$8)return null;let Z=1;while(M+Z<J&&$[M+Z]===$8)Z+=1;let X=$8.repeat(Z),D=$.indexOf(X,M+Z);if(D<0||D>=J)return null;return{end:D+Z,value:$.slice(M+Z,D)}}function dq($,M,J){let Z=xq($,M,J);if(!Z)return null;return{end:Z.end,nodes:[S1({code:Z.value})]}}function aq($,M,J){if(!$.startsWith(R3,M))return null;let Z=mM($,M+1,J);if(Z<0||$[Z+1]!==jM)return null;let X=fM($,Z+1,J);if(!X)return null;let D=sq($,X.end,J);return{end:D?.end??X.end,nodes:[o4({alt:vM($.slice(M+R3.length,Z)),title:X.title,url:X.url,width:D?.width??null})]}}function iq($,M,J,Z){if($[M]!==k3||$.startsWith(R3,M-1))return null;let X=mM($,M,J);if(X<0||$[X+1]!==jM)return null;let D=fM($,X+1,J);if(!D)return null;return{end:D.end,nodes:[u1({children:N2($.slice(M+k3.length,X),Z),title:D.title,url:D.url})]}}function fM($,M,J){let Z=L3($,M+1,J),X=Z;while(X<J&&$[X]!==wM&&$[X]!==LM){if($[X]===f3){X+=2;continue}X+=1}if(X===Z)return null;let D=eq($.slice(Z,X));Z=L3($,X,J);let Y=null;if(Z<J&&$[Z]==='"'){let Q=uM($,'"',Z+1,J);if(Q<0)return null;Y=$.slice(Z+1,Q).replace(kM,"$1"),Z=L3($,Q+1,J)}if($[Z]!==wM)return null;return{end:Z+1,title:Y,url:D}}function sq($,M,J){let Z=vq.exec($.slice(M,J));if(!Z)return null;return{end:M+Z[0].length,width:Number(Z[1])}}function oq($,M,J,Z){if(!$.startsWith(_1,M))return nq($,M,J);let X=$.indexOf(j4,M+_1.length);if(X<0||X>=J)return{end:M+_1.length,nodes:[S3("html",_1)]};return{end:X+j4.length,nodes:m3($,M+_1.length,X,[...Z,"underline"])}}function nq($,M,J){if($[M]!=="<")return null;let Z=$.indexOf(">",M+1);if(Z<0||Z>=J)return null;return{end:Z+1,nodes:[S3("html",$.slice(M,Z+1))]}}function tq($,M,J){if($[M]!==RM||!Sq.test($[M+1]??""))return null;let Z=M+2;while(Z<J&&uq.test($[Z]??""))Z+=1;let X=CM($,Z,J,"[","]"),Y=CM($,X?.end??Z,J,"{","}")?.end??X?.end??Z;return{end:Y,nodes:[S3("textDirective",$.slice(M,Y))]}}function CM($,M,J,Z,X){if($[M]!==Z)return null;let D=SM($,X,M+1,J);if(D<0)return null;return{end:D+1}}function mM($,M,J){return SM($,"]",M+1,J)}function SM($,M,J,Z){return uM($,M,J,Z)}function uM($,M,J,Z){for(let X=J;X<Z;X+=1){if($[X]===f3){X+=1;continue}if($[X]===M)return X}return-1}function L3($,M,J){while(M<J&&$[M]===LM)M+=1;return M}function vM($){return $.replace(hq,"$1")}function eq($){return $.replace(kM,"$1")}var $U=/^:?-+:?$/;function IM($,M){let J=gM($),Z=$.lines[$.index+1]??"",X=u3(J,M),D=u3(Z,M);if(!hM(X)||!v3(D))return null;let Y=[M8(X)],Q=MU(D);$.index+=2;while($.index<$.lines.length){let K=gM($),q=u3(K,M);if(JU(K)||!hM(q))break;Y.push(M8(q)),$.index+=1}return z1({align:Q,rows:Y.map((K)=>v1({cells:K.map((q)=>J1({children:N2(q)}))}))})}function hM($){let M=$.trim();return/\|/.test($)&&M.startsWith("|")&&M.endsWith("|")}function v3($){let M=M8($);return M.length>0&&M.every((J)=>$U.test(J.trim()))}function MU($){return M8($).map((M)=>{let J=M.trim();if(J.startsWith(":")&&J.endsWith(":"))return"center";if(J.startsWith(":"))return"left";if(J.endsWith(":"))return"right";return null})}function M8($){return $.trim().slice(1,-1).split("|").map((J)=>J.trim())}function gM($){return $.lines[$.index]??""}function JU($){return $.trim()===""}function u3($,M){return $.slice(M)}var ZU=3,XU=/^\d+\.$/,DU=/^\[( |x|X)\](?:\s|$)/,pM=/^```([^\s`]*)?(?:\s+(.*))?$/,lM=/^::(?!:)[A-Za-z][-\w]*/,rM=/^(#{1,6})\s+(.*)$/,YU=/\s+#+\s*$/u,QU=/^(\s*)([-+*]|\d+\.)(?:\s+(.*)|\s*)$/,KU=/^(\*\s*){3,}$/,qU=/^(-\s*){3,}$/,UU=/^(_\s*){3,}$/;function Z8($,M,J){let Z=[];while($.index<$.lines.length){let X=B0($);if($.index===$.lines.length-1&&X==="")break;if(R4(X)){$.index+=1;continue}if(A2(X)>M+ZU)break;let Y=NU($,M,J);if(!Y)break;Z.push(Y)}return Z}function NU($,M,J){return AU($,M,J)??VU($,M)??GU($,M)??FU($,M)??_U($,M)??bU($,M)??IM($,M)??HU($,M,J)??PU($,M)??zU($,M)}function AU($,M,J){let Z=B0($);if(!EU(Z,M))return null;let X=[];while($.index<$.lines.length){let D=B0($),Y=A2(D);if(R4(D)){X.push(""),$.index+=1;continue}if(Y<M)break;let Q=R0(D,M);if(!Q.startsWith(U2))break;let K=Q.slice(1);if(K.startsWith(" "))K=K.slice(1);X.push(K),$.index+=1}return P0({children:Z8({index:0,lines:X},0,J)})}function VU($,M){let J=B0($),Z=R0(J,M),X=pM.exec(Z);if(!X)return null;$.index+=1;let D=[];while($.index<$.lines.length){let Y=B0($),Q=R0(Y,M);if(Q.trim()===L4){$.index+=1;break}D.push(Q),$.index+=1}return P8({language:X[1]?X[1]:null,meta:X[2]?X[2]:null,source:D.join(o)})}function GU($,M){let J=B0($),Z=R0(J,M),X=j3.exec(Z);if(!X)return null;let D=X[1],Y=[];$.index+=1;while($.index<$.lines.length){let Q=B0($),K=R0(Q,M);if($.index+=1,K.trim()===t5)break;Y.push(K)}return C$({attributes:BU(X[2]??""),body:Y.join(o),name:D})}function BU($){let M=$.trim();if(M.startsWith("{")&&M.endsWith("}"))return M.slice(1,-1);return M}function FU($,M){let J=B0($),Z=R0(J,M);if(!lM.test(Z))return null;return $.index+=1,e4({originalType:"leafDirective",source:Z})}function _U($,M){let J=B0($),Z=rM.exec(R0(J,M));if(!Z)return null;return $.index+=1,s4({children:N2(Z[2].replace(YU,"")),depth:Z[1].length})}function bU($,M){let J=R0(B0($),M).trim();if(!cM(J))return null;return $.index+=1,t4()}function HU($,M,J){let Z=J8(B0($),M);if(!Z)return null;let X=[],D=!1;while($.index<$.lines.length){let Y=B0($),Q=J8(Y,M);if(!Q||Q.ordered!==Z.ordered)break;$.index+=1;let K=[Q.content],q=!1;while($.index<$.lines.length){let U=B0($),N=A2(U);if(R4(U)){let A=wU($.lines,$.index+1);if(A<0||A2($.lines[A]??"")<=M)break;q=!0,K.push(""),$.index+=1;continue}if(N<Q.contentIndent)break;if(N===M&&J8(U,M))break;K.push(TU(U,Q.contentIndent)),$.index+=1}D||=q,X.push(d0({checked:Q.checked,children:WU(K,J),spread:q}))}return P1({items:X,ordered:Z.ordered,spread:D,start:Z.ordered&&J.preserveOrderedListStart?Z.start??1:null})}function PU($,M){let J=R0(B0($),M).trim();if(!xM(J))return null;return $.index+=1,e4({originalType:"html",source:J})}function zU($,M){let J=[];while($.index<$.lines.length){let Z=B0($),X=A2(Z);if(R4(Z))break;if(X<M)break;let D=R0(Z,M);if(J.length>0&&yU(Z,D,M))break;J.push(D),$.index+=1}return H2({children:N2(J.join(o))})}function WU($,M){let J=Z8({index:0,lines:$},0,M);if(J.length>0)return J;return[H2({children:[]})]}function J8($,M){let J=QU.exec($);if(!J||J[1].length!==M)return null;let Z=J[2],X=XU.test(Z),D=X?Number(Z.slice(0,-1)):null,Y=J[3]??"",Q=null;if(DU.test(Y)){if(Q=Y[1]==="x"||Y[1]==="X",Y=Y.slice(3),Y.startsWith(" "))Y=Y.slice(1)}let K=Y.length>0?J[0].length-J[1].length-J[2].length-Y.length:J[0].length-J[1].length-J[2].length;return{checked:Q,content:Y,contentIndent:M+J[2].length+K,ordered:X,start:D}}function EU($,M){return R0($,M).startsWith(U2)}function R0($,M){return $.slice(M)}function TU($,M){let J=A2($);if(J>=M)return $.slice(M);return $.trim()===""?"":$.slice(Math.min(J,M))}function cM($){return KU.test($)||qU.test($)||UU.test($)}function xM($){return $.startsWith("<")&&$.endsWith(">")}function A2($){let M=0;while(M<$.length&&$[M]===" ")M+=1;return M}function yU($,M,J){return M.startsWith(U2)||pM.test(M)||j3.test(M)||lM.test(M)||rM.test(M)||cM(M.trim())||v3(M)||J8($,J)!==null||xM(M.trim())}function B0($){return $.lines[$.index]??""}function R4($){return $.trim()===""}function wU($,M){for(let J=M;J<$.length;J+=1)if(!R4($[J]??""))return J;return-1}function aM($){let M=$.at(-1),J=M&&dM(M)?M:null;return{blocks:$.filter((X)=>!dM(X)),comments:J?OU(J.body):[]}}function OU($){let M;try{M=JSON.parse($)}catch{return[]}if(!Array.isArray(M))return[];return M.flatMap((J)=>{let Z=k8(J);return Z?[Z]:[]})}function dM($){return $.type==="directive"&&$.name===e5}var iM="---";function h3($,M={}){let Z={index:0,lines:$.replace(/\r\n/g,o).split(o)},X=CU(Z),D=Z8(Z,0,M),{comments:Y,blocks:Q}=aM(D);return g1(Q,Y,X)}function CU($){if($.lines[0]!==iM)return;for(let M=1;M<$.lines.length;M+=1)if($.lines[M]===iM){let J=$.lines.slice(0,M+1).join(o);return $.index=M+1,J}return}var k4=`
27
+
28
+ `,jU="-",LU=".",RU="***",kU="&#x20;",g3=3,fU=5,mU=4,sM=2,SU=2,uU=1,vU=/([\\`*_[\]])/g,hU=/([\\)&])/g,gU=/(["\\])/g;function X8($,M={}){if($.blocks.length===0&&$.comments.length===0&&$.frontMatter===void 0)return"";let J=$.blocks.map((X)=>D8(X,0,M));if($.comments.length>0)J.push(ZN($.comments));if($.frontMatter!==void 0)J.unshift($.frontMatter);let Z=J.join(k4);return Z.endsWith(o)?Z:`${Z}${o}`}function D8($,M,J){let Z=b1(M);switch($.type){case"blockquote":return IU($,M,J);case"code":return pU($,M);case"directive":return XN($,M);case"heading":return nM($,M);case"list":return lU($,M,J);case"listItem":return tM($,M,!1,1,J);case"paragraph":return`${Z}${I3(f4($.children))}`;case"table":return cU($,M,J);case"thematicBreak":return`${Z}${RU}`;case"unsupported":return M===0?$.source:MJ($.source,M)}}function IU($,M,J){let Z=$.children.map((D)=>D8(D,0,J)).join(k4),X=b1(M);return Z.split(o).map((D)=>`${X}${U2}${D.length>0?` ${D}`:""}`).join(o)}function pU($,M){let J=[$.language??"",$.meta??""].filter(Boolean).join(" ").trim(),Z=b1(M),X=`${Z}${L4}${J?J:""}`,D=$.source.length>0?$.source.split(o).map((Y)=>`${Z}${Y}`).join(o):Z;return`${X}${o}${D}${o}${Z}${L4}`}function nM($,M){let J=I3(f4($.children)),Z=`${b1(M)}${"#".repeat($.depth)}`;return J.length>0?`${Z} ${J}`:Z}function lU($,M,J){let Z=$.start??1;return $.items.map((X)=>tM(X,M,$.ordered,Z,J)).join($.spread?k4:o)}function tM($,M,J,Z,X){let D=J?`${Z}${LU}`:jU,Y=$.checked===null?"":`[${$.checked?"x":" "}] `,Q=`${b1(M)}${D} ${Y}`,K=M+D.length+1,q=$.children;if(q.length===0)return Y.length>0?Q:Q.trimEnd();let[U,...N]=q,A=rU(U,Q,Y.length>0,X),V=N.map((B)=>D8(B,K,X)).join($.spread?k4:o);if(!V)return A;return`${A}${$.spread?k4:o}${V}`}function rU($,M,J,Z){switch($.type){case"paragraph":{let X=I3(f4($.children));if(X.length===0)return J?M:M.trimEnd();return`${M}${X}`}case"heading":return`${M}${nM($,0)}`;case"directive":case"unsupported":{let X=$.type==="directive"?p3($):$.source,[D,...Y]=X.split(o);return[M+D,...Y.map((Q)=>`${b1(M.length)}${Q}`)].join(o)}default:{let X=M.length;return`${M.trimEnd()}${o}${D8($,X,Z)}`}}}function cU($,M,J){let Z=$.rows.map((U)=>U.cells.map((N)=>f4(N.children))),X=Math.max(1,...Z.map((U)=>U.length)),D=Z[0]??[],Y=Array.from({length:X},(U,N)=>Math.max(g3,iU($.align[N]),...J.padTableColumns?Z.map((A)=>A[N]?.length??0):[D[N]?.length??0])),Q=xU(Y,$.align,M),K=oM(D,Y,$.align,M,J),q=Z.slice(1).map((U)=>oM(U,Y,$.align,M,J));return[K??dU(Y,M),Q,...q].join(o)}function oM($,M,J,Z,X){let D=M.map((Y,Q)=>{let K=$[Q]??"";if(!X.padTableColumns)return K;return sU(K,Y,J[Q])});return`${" ".repeat(Z)}| ${D.join(" | ")} |`}function xU($,M,J){let Z=$.map((X,D)=>aU(M[D],X));return`${" ".repeat(J)}| ${Z.join(" | ")} |`}function dU($,M){return`${b1(M)}| ${$.map((J)=>"".padEnd(J," ")).join(" | ")} |`}function aU($,M){let J=Math.max(g3,M-($==="center"?SU:$?uU:0));switch($){case"center":return`:${"-".repeat(Math.max(1,J))}:`;case"left":return`:${"-".repeat(Math.max(sM,J))}`;case"right":return`${"-".repeat(Math.max(sM,J))}:`;default:return"-".repeat(J)}}function iU($){return $==="center"?fU:$?mU:g3}function sU($,M,J){if(J==="right")return $.padStart(M," ");return $.padEnd(M," ")}function f4($){return nU($).map((M)=>oU(M)).join("")}function I3($){return $.replace(/^ +/gm,(M)=>kU.repeat(M.length))}function oU($){switch($.type){case"break":return o;case"image":return DN($);case"inlineCode":return $N($.code);case"link":return YN($);case"text":return eU(eM($.text),$.marks);case"unsupported":return $.source}}function nU($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&tU(Z.marks,J.marks)){M[M.length-1]={...Z,text:Z.text+J.text};continue}M.push(J)}return M}function tU($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function eU($,M){return M.reduce((J,Z)=>{switch(Z){case"bold":return`**${J}**`;case"italic":return`*${J}*`;case"strikethrough":return`~~${J}~~`;case"underline":return`${_1}${J}${j4}`}},$)}function $N($){let M=0,J=0;for(let Y of $){if(Y==="`"){if(J+=1,J>M)M=J;continue}J=0}let Z=M>0?M+1:1,X="`".repeat(Z),D=$.startsWith("`")||$.endsWith("`")?` ${$} `:$;return`${X}${D}${X}`}function eM($){return $.replace(vU,"\\$1")}function MN($){return $.replace(hU,"\\$1")}function JN($){return $?` "${$.replace(gU,"\\$1")}"`:""}function ZN($){return p3({attributes:"",body:JSON.stringify($,null,2),name:e5})}function XN($,M){let J=p3($);return M===0?J:MJ(J,M)}function p3($){let M=$.attributes?`{${$.attributes}}`:"";return`:::${$.name}${M}${o}${$.body}${o}${t5}`}function DN($){let M=eM($.alt??""),J=$J($.url,$.title),Z=$.width?`{width=${$.width}}`:"";return`![${M}]${J}${Z}`}function YN($){return`[${f4($.children)}]${$J($.url,$.title)}`}function $J($,M){return`(${MN($)}${JN(M)})`}function b1($){return" ".repeat($)}function MJ($,M){let J=b1(M);return $.split(o).map((Z)=>`${J}${Z}`).join(o)}import{createContext as QN,useContext as KN}from"react";import{createPortal as qN}from"react-dom";import{jsx as XJ}from"react/jsx-runtime";var JJ=QN(void 0);function ZJ({children:$,themeStyles:M}){return XJ(JJ.Provider,{value:M,children:$})}function Y8({children:$}){let M=KN(JJ);if(typeof document>"u")return null;return qN(XJ("div",{className:"documint-overlay",style:{display:"contents",...M},children:$}),document.body)}import{useEffect as Q8,useRef as bJ,useState as O1}from"react";import{forwardRef as NN,useCallback as V2,useEffect as AN,useImperativeHandle as VN,useLayoutEffect as GN,useMemo as BN,useRef as QJ,useState as l3}from"react";var UN=["box-sizing","width","height","overflow-x","overflow-y","border-top-width","border-right-width","border-bottom-width","border-left-width","border-style","padding-top","padding-right","padding-bottom","padding-left","font-style","font-variant","font-weight","font-stretch","font-size","font-size-adjust","line-height","font-family","text-align","text-transform","text-indent","text-decoration","letter-spacing","word-spacing","tab-size"];function DJ($,M,{topGap:J=8}={}){if(!$.isConnected)return null;let Z=getComputedStyle($),X=document.createElement("div");for(let q of UN)X.style.setProperty(q,Z.getPropertyValue(q));Object.assign(X.style,{position:"absolute",top:"0",left:"0",visibility:"hidden",whiteSpace:"pre-wrap",wordWrap:"break-word",width:`${$.clientWidth}px`}),X.textContent=$.value.slice(0,M);let D=document.createElement("span");D.textContent=$.value.slice(M)||".",X.appendChild(D),document.body.appendChild(X);let Y=$.getBoundingClientRect(),Q=parseFloat(Z.lineHeight)||D.offsetHeight,K={left:Y.left+D.offsetLeft+parseFloat(Z.borderLeftWidth)-$.scrollLeft,top:Y.top+D.offsetTop+parseFloat(Z.borderTopWidth)+Q+J-$.scrollTop};return document.body.removeChild(X),K}import{jsx as k0,jsxs as KJ,Fragment as TN}from"react/jsx-runtime";var FN=240,_N="documint-leaf-menu-item documint-completion-item",m4=NN(function({actions:M,completionSources:J,onChange:Z,placeholder:X,readOnly:D=!1,rows:Y=3,value:Q},K){let q=QJ(null);VN(K,()=>q.current,[]);let U=BN(()=>zN(J),[J]),[N,A]=l3(null),[V,B]=l3(0),[G,b]=l3(null),P=V2((E,_)=>{if(!U.length){A(null);return}let j=WN(E,_,U);if(!j){A(null);return}A(j),B(0)},[U]),y=V2((E)=>{let _=E.currentTarget.value,j=E.currentTarget.selectionEnd??_.length;Z(_),P(_,j)},[Z,P]),z=V2((E)=>{let _=E.currentTarget;P(_.value,_.selectionEnd??_.value.length)},[P]),L=V2(()=>{A(null)},[]),R=V2((E)=>{if(!q.current||!N)return;let j=`${N.trigger}${E.label} `,C=Q.slice(0,N.triggerStart),W=Q.slice(N.caret),F=C+j+W,H=N.triggerStart+j.length;Z(F),A(null),requestAnimationFrame(()=>{let v=q.current;if(!v)return;v.focus(),v.setSelectionRange(H,H)})},[N,Z,Q]),m=V2((E)=>{if(N&&N.matches.length>0){if(E.key==="ArrowDown"){E.preventDefault(),E.stopPropagation(),B((_)=>(_+1)%N.matches.length);return}if(E.key==="ArrowUp"){E.preventDefault(),E.stopPropagation(),B((_)=>(_-1+N.matches.length)%N.matches.length);return}if(E.key==="Enter"||E.key==="Tab"){E.preventDefault(),E.stopPropagation();let _=N.matches[V];if(_)R(_);return}if(E.key==="Escape"){E.preventDefault(),E.stopPropagation(),A(null);return}}if(E.key==="Escape"&&M.kind==="edit")E.preventDefault(),M.onCancel()},[M,N,V,R]);return GN(()=>{if(!N){b(null);return}let E=()=>{let _=q.current;if(!_)return;b(DJ(_,N.triggerStart))};return E(),window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}},[N]),KJ("div",{className:"documint-leaf-input-field",children:[k0("textarea",{className:"documint-leaf-input",onBlur:L,onChange:y,onKeyDown:m,onSelect:z,placeholder:X,readOnly:D,ref:q,rows:Y,value:Q}),bN(M),N&&G&&N.matches.length>0?k0(Y8,{children:k0(HN,{activeIndex:V,left:G.left,matches:N.matches,onHover:B,onSelect:R,top:G.top})}):null]})});function bN($){if($.kind==="edit")return KJ(TN,{children:[k0(r3,{className:"documint-leaf-input-cancel",icon:C4,label:"Cancel editing",onClick:$.onCancel}),k0(r3,{className:"documint-leaf-input-save",disabled:$.saveDisabled??!1,icon:y1,label:"Save",onClick:$.onSave})]});return k0(r3,{className:"documint-leaf-input-submit",disabled:$.submitDisabled??!1,icon:B1,iconSize:15,label:$.submitLabel,onClick:$.onSubmit})}function r3({className:$,disabled:M=!1,icon:J,iconSize:Z=14,label:X,onClick:D}){return k0("button",{"aria-label":X,className:`documint-leaf-action ${$}`,disabled:M,onClick:D,title:X,type:"button",children:k0(J,{size:Z,strokeWidth:2.2})})}function HN({activeIndex:$,left:M,matches:J,onHover:Z,onSelect:X,top:D}){let Y=QJ(null);return AN(()=>{let Q=Y.current;if(!Q)return;let K=Q.children[$];if(K instanceof HTMLElement)K.scrollIntoView({block:"nearest"})},[$]),k0("div",{className:"documint-leaf-menu documint-completion-popover",ref:Y,role:"listbox",style:{position:"fixed",left:M,top:D,maxHeight:FN,overflowY:"auto"},children:J.map((Q,K)=>{let q=K===$;return k0("button",{"aria-selected":q,className:`${_N}${q?" is-active":""}`,onPointerDown:PN,onPointerEnter:()=>Z(K),onClick:()=>X(Q),role:"option",type:"button",children:k0("span",{children:Q.label})},Q.label)})})}function PN($){$.preventDefault()}function zN($){if(!$?.length)return[];return $.map((M)=>({trigger:M.trigger,items:[...M.items].sort((J,Z)=>J.label.localeCompare(Z.label,void 0,{sensitivity:"base"}))}))}function WN($,M,J){for(let Z=M-1;Z>=0;Z-=1){let X=$[Z];if(YJ(X))return null;let D=J.find((Q)=>Q.trigger===X);if(!D)continue;if(Z>0&&!YJ($[Z-1]))return null;let Y=$.slice(Z+1,M);return{trigger:D.trigger,query:Y,triggerStart:Z,caret:M,matches:EN(D.items,Y)}}return null}function YJ($){return $===void 0||$===" "||$===`
29
+ `||$==="\t"}function EN($,M){if(!M)return $;let J=M.toLowerCase();return $.filter((Z)=>Z.label.toLowerCase().includes(J))}import{Fragment as wN}from"react";function c3($,M){if(!M?.length||!M.some((Y)=>$.includes(Y.trigger)))return[{kind:"text",text:$}];let J=new Map;for(let Y of M){let Q=[...Y.items].sort((K,q)=>q.label.length-K.label.length);J.set(Y.trigger,Q)}let Z=[],X=0,D=0;while(X<$.length){let Y=$[X],Q=J.get(Y);if(Q!==void 0&&(X===0||yN($[X-1]))){let q=Q.find((U)=>$.startsWith(U.label,X+1));if(q){if(X>D)Z.push({kind:"text",text:$.slice(D,X)});Z.push({kind:"token",trigger:Y,label:q.label,id:q.id}),X+=1+q.label.length,D=X;continue}}X+=1}if(D<$.length)Z.push({kind:"text",text:$.slice(D)});return Z}function x3($,M){let J=[],Z=new Set;for(let X of c3($,M)){if(X.kind!=="token"||X.trigger!=="@"||!X.id)continue;if(Z.has(X.id))continue;Z.add(X.id),J.push(X.id)}return J}function yN($){return $===void 0||$===" "||$===`
30
+ `||$==="\t"}import{jsx as qJ,jsxs as CN}from"react/jsx-runtime";function d3({value:$,completionSources:M,onEdit:J}){return qJ("p",{onDoubleClick:J,children:ON($,M)})}function ON($,M){let J=c3($,M);if(J.length===1&&J[0].kind==="text")return $;return J.map((Z,X)=>Z.kind==="token"?CN("span",{className:"documint-mention",children:[Z.trigger,Z.label]},X):qJ(wN,{children:Z.text},X))}import{Children as UJ,isValidElement as NJ,useEffect as jN,useRef as LN,useState as RN}from"react";import{jsx as A0,jsxs as s3}from"react/jsx-runtime";var a3=($)=>{$.preventDefault()},i3=($)=>$.isPrimary&&$.button===0;function kN({children:$}){return A0("div",{className:"documint-leaf-toolbar",children:UJ.map($,fN)})}function fN($){if(!NJ($))return null;if($.type===VJ){let M=$.props;return A0(AJ,{children:A0(mN,{...M})})}if($.type===GJ){let{className:M}=$.props;return A0("div",{className:S4("documint-leaf-toolbar-divider",M)})}if($.type===BJ){let M=$.props;return A0(SN,{...M})}return null}function mN({active:$=!1,className:M,disabled:J=!1,icon:Z,label:X,onClick:D}){return A0("button",{"aria-label":X,className:S4("documint-leaf-toolbar-button",$?"active":null,M),disabled:J,onPointerDown:(Y)=>{if(a3(Y),!J&&i3(Y))D()},title:X,type:"button",children:A0(Z,{size:15,strokeWidth:2.2})})}function SN({children:$,className:M,icon:J,label:Z,onSelect:X}){let D=LN(null),[Y,Q]=RN(!1);return jN(()=>{if(!Y)return;let K=(q)=>{if(D.current&&q.target instanceof Node&&!D.current.contains(q.target))Q(!1)};return window.addEventListener("pointerdown",K),()=>{window.removeEventListener("pointerdown",K)}},[Y]),A0(AJ,{children:s3("div",{className:"documint-leaf-toolbar-menu-shell",ref:D,children:[A0(uN,{className:M,icon:J,isOpen:Y,label:Z,onClick:()=>Q((K)=>!K)}),Y?A0("div",{className:"documint-leaf-menu",role:"menu",children:UJ.map($,(K)=>vN(K,(q)=>{Q(!1),X(q)}))}):null]})})}function uN({className:$,icon:M,isOpen:J,label:Z,onClick:X}){return s3("button",{"aria-expanded":J,"aria-haspopup":"menu","aria-label":Z,className:S4("documint-leaf-toolbar-button",J?"active":null,$),onPointerDown:(D)=>{if(a3(D),i3(D))X()},title:Z,type:"button",children:[A0(M,{size:15,strokeWidth:2.2}),A0(A4,{className:S4("documint-leaf-toolbar-menu-chevron",J?"is-open":null),size:13,strokeWidth:2.2})]})}function vN($,M){if(!NJ($))return null;if($.type===_J){let{className:Y}=$.props;return A0("div",{className:S4("documint-leaf-menu-divider",Y),role:"separator"})}if($.type!==FJ)return null;let{disabled:J=!1,icon:Z,text:X,value:D}=$.props;return s3("button",{className:"documint-leaf-menu-item",disabled:J,onPointerDown:(Y)=>{if(a3(Y),!J&&i3(Y))M(D)},role:"menuitem",type:"button",children:[A0(Z,{size:15,strokeWidth:2.2}),A0("span",{children:X})]})}function S4(...$){return $.filter(Boolean).join(" ")}function AJ({children:$}){return A0("div",{className:"documint-leaf-toolbar-group",children:$})}function VJ($){return null}function GJ($){return null}function BJ($){return null}function FJ($){return null}function _J($){return null}var c=Object.assign(kN,{Button:VJ,Divider:GJ,Menu:BJ,MenuDivider:_J,MenuItem:FJ});import{jsx as t,jsxs as r0,Fragment as pN}from"react/jsx-runtime";var hN=!1,gN=220,C1=()=>{};function o3($){let M=$.mode==="create",J=$.mode==="create"?$:null,Z=$.mode==="thread"?$:null,X=$.canEdit,D=$.link,Y=Z?.thread??null,Q=Y?.comments??[],K=Q[0]??null,q=Y?Z1(Y):!1,U=Z?.animateInitialComment??!1,[N,A]=O1(null),[V,B]=O1(""),[G,b]=O1(""),[P,y]=O1(""),[z,L]=O1(!U),[R,m]=O1(hN),[E,_]=O1(!1),j=bJ(null),C=bJ(null),W=$.mentionSources,F=Y?g8(Y):null,H=F?HJ(F):"",v=X&&!q,h=v&&V.trim().length>0,l=v&&G.trim().length>0,p=X&&P.trim().length>0,O=M||E,T=!M||R,k=!M&&Boolean(Y),f=Boolean(K),d=M?R:!0,I=Z?.onDeleteComment??C1,U0=Z?.onDeleteThread??C1,z0=Z?.onToggleResolved??C1,_0=J?.activeMarks??[],R1=J?.onToggleBold??C1,F8=J?.onToggleItalic??C1,p4=J?.onToggleStrikethrough??C1,_8=J?.onToggleUnderline??C1,l4=X?M?"Add a comment":"Reply to this comment":"Comment editing is disabled",r4=M?P:G;Q8(()=>{if(N!==null&&(N<0||N>=Q.length))A(null),B("")},[Q.length,N]),Q8(()=>{if(!f||!U){L(!0);return}L(!1);let a=requestAnimationFrame(()=>{L(!0)});return()=>{cancelAnimationFrame(a)}},[U,K,f]),Q8(()=>{if(!Z||!U){_(!1);return}_(!0);let a=window.setTimeout(()=>{_(!1)},gN);return()=>{window.clearTimeout(a)}},[U,Z]),Q8(()=>{if(!M||!R||!X)return;let a=requestAnimationFrame(()=>{C.current?.focus()});return()=>{cancelAnimationFrame(a)}},[X,M,R]);let O0=()=>{A(null),B("")},W0=(a,_2)=>{if(!k||!v)return;A(a),B(_2)},k1=(a)=>{if(!Z)return;Z.onEditComment(a,V),O0()},b8=()=>{if(!Z)return;Z.onReply(G),b("")},c4=()=>{if(!J||!p)return;J.onCreateThread(P),y("")},f1=O?`documint-comment-leaf documint-comment-leaf-create${d?" is-expanded":""}`:"documint-comment-leaf",x4=k||f||T?t(IN,{canCreate:p,canEdit:X,canMutateThread:v,canReply:l,canSaveEditedComment:h,comments:Q,composerRef:C,editDraft:V,editingCommentIndex:N,isComposerVisible:T,isInitialCommentVisible:z,isResolved:q,link:D,mentionSources:W,mode:$.mode,onBeginEditingComment:W0,onCancelEditing:O0,onChangeCreateDraft:y,onChangeEditDraft:B,onChangeReplyDraft:b,onDeleteComment:I,onDeleteThread:U0,onSubmitCreate:c4,onSubmitEditedComment:k1,onSubmitReply:b8,onToggleResolved:z0,rootComment:K,showRootComment:f,showThreadChrome:k,threadAge:H,composerPlaceholder:l4,composerValue:r4}):null;return t("div",{className:f1,ref:j,children:r0("div",{className:O?"documint-comment-leaf-create-shell":void 0,children:[O?r0(c,{children:[t(c.Button,{className:"documint-comment-leaf-create-button",icon:T4,label:"Add comment",onClick:()=>m(!0)}),t(c.Divider,{className:"documint-comment-leaf-create-divider"}),t(c.Button,{active:_0.includes("bold"),className:"documint-comment-leaf-create-mark",icon:N4,label:"Bold",onClick:R1}),t(c.Button,{active:_0.includes("italic"),className:"documint-comment-leaf-create-mark",icon:P4,label:"Italic",onClick:F8}),t(c.Button,{active:_0.includes("underline"),className:"documint-comment-leaf-create-mark",icon:O4,label:"Underline",onClick:_8}),t(c.Button,{active:_0.includes("strikethrough"),className:"documint-comment-leaf-create-mark",icon:y4,label:"Strikethrough",onClick:p4})]}):null,t("div",{className:O?"documint-comment-leaf-create-content":void 0,children:x4})]})})}function IN({canCreate:$,canEdit:M,canMutateThread:J,canReply:Z,canSaveEditedComment:X,comments:D,composerRef:Y,editDraft:Q,editingCommentIndex:K,isComposerVisible:q,isInitialCommentVisible:U,isResolved:N,link:A,mentionSources:V,mode:B,onBeginEditingComment:G,onCancelEditing:b,onChangeCreateDraft:P,onChangeEditDraft:y,onChangeReplyDraft:z,onDeleteComment:L,onDeleteThread:R,onSubmitCreate:m,onSubmitEditedComment:E,onSubmitReply:_,onToggleResolved:j,rootComment:C,showRootComment:W,showThreadChrome:F,threadAge:H,composerPlaceholder:v,composerValue:h}){return r0(pN,{children:[F?r0("div",{className:"documint-comment-leaf-header",children:[t("span",{className:"documint-comment-leaf-age",children:H}),r0("div",{className:"documint-comment-leaf-actions",children:[t("button",{className:"documint-leaf-action","aria-label":N?"Reopen comment":"Resolve comment",disabled:!M,onClick:j,title:N?"Reopen comment":"Resolve comment",type:"button",children:t(y1,{size:14,strokeWidth:2.2})}),t("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment thread",disabled:!M,onClick:R,title:"Delete comment thread",type:"button",children:t(w0,{size:14,strokeWidth:2.2})})]})]}):null,F&&A?r0("div",{className:"documint-comment-leaf-link",children:[A.title?t("div",{className:"documint-link-leaf-title",children:A.title}):null,t("div",{className:"documint-link-leaf-url",children:A.url})]}):null,r0("div",{className:`documint-comment-thread${W?"":" is-empty"}`,children:[t("article",{className:W?`documint-comment-message documint-comment-message-root${U?" is-visible":""}`:"documint-comment-message documint-comment-message-root is-hidden",children:C?t(d3,{completionSources:V,onEdit:()=>G(0,C.body),value:C.body}):null}),D.slice(1).map((l,p)=>{let O=p+1,T=K===O;return r0("article",{className:"documint-comment-message",children:[!T?r0("div",{className:"documint-comment-message-meta",children:[t("span",{children:HJ(l.updatedAt)}),J?r0("div",{className:"documint-comment-leaf-actions",children:[t("button",{className:"documint-leaf-action","aria-label":"Edit comment",disabled:!J,onClick:()=>{G(O,l.body)},title:"Edit comment",type:"button",children:t(w1,{size:14,strokeWidth:2.2})}),t("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment",disabled:!J,onClick:()=>L(O),title:"Delete comment",type:"button",children:t(w0,{size:14,strokeWidth:2.2})})]}):null]}):null,T?t(m4,{actions:{kind:"edit",onCancel:b,onSave:()=>E(O),saveDisabled:!X},completionSources:V,onChange:y,readOnly:!M,rows:3,value:Q}):t(d3,{completionSources:V,onEdit:()=>G(O,l.body),value:l.body})]},`${l.updatedAt}:${O}`)})]}),t("div",{className:`documint-comment-reply${F?"":" is-standalone"}${q?" is-visible":""}`,children:t(m4,{actions:B==="create"?{kind:"compose",onSubmit:m,submitDisabled:!$,submitLabel:"Create comment"}:{kind:"compose",onSubmit:_,submitDisabled:!Z,submitLabel:"Reply"},completionSources:V,onChange:B==="create"?P:z,placeholder:v,readOnly:!M,ref:Y,rows:3,value:h})})]})}function HJ($){let M=new Date($);if(Number.isNaN(M.getTime()))return $;let J=M.getTime()-Date.now(),Z=60000,X=60*Z,D=24*X,Y=7*D,Q=30*D,K=365*D,q=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});if(Math.abs(J)<Z)return"just now";if(Math.abs(J)<X)return q.format(Math.round(J/Z),"minute");if(Math.abs(J)<D)return q.format(Math.round(J/X),"hour");if(Math.abs(J)<Y)return q.format(Math.round(J/D),"day");if(Math.abs(J)<K)return q.format(Math.round(J/Q),"month");return q.format(Math.round(J/K),"year")}import{jsx as c0,jsxs as cN}from"react/jsx-runtime";var lN=[{icon:V4,label:"Heading 1",text:"# "},{icon:G4,label:"Heading 2",text:"## "},{icon:B4,label:"Heading 3",text:"### "},{icon:F4,label:"Heading 4",text:"#### "},{icon:_4,label:"Heading 5",text:"##### "},{icon:b4,label:"Heading 6",text:"###### "}],rN=[{columns:2,text:"2 columns"},{columns:3,text:"3 columns"},{columns:4,text:"4 columns"},{columns:5,text:"5 columns"}];function PJ({onInsert:$,onInsertTable:M}){return cN(c,{children:[c0(c.Button,{icon:E4,label:"Insert bulleted list",onClick:()=>$("- ")}),c0(c.Button,{icon:z4,label:"Insert numbered list",onClick:()=>$("1. ")}),c0(c.Button,{icon:W4,label:"Insert task list",onClick:()=>$("- [ ] ")}),c0(c.Divider,{}),c0(c.Menu,{icon:H4,label:"Insert heading",onSelect:$,children:lN.map(({icon:J,label:Z,text:X})=>c0(c.MenuItem,{icon:J,text:Z,value:X},X))}),c0(c.Menu,{icon:F1,label:"Insert table",onSelect:(J)=>M(Number(J)),children:rN.map(({columns:J,text:Z})=>c0(c.MenuItem,{icon:F1,text:Z,value:String(J)},J))}),c0(c.Divider,{}),c0(c.Button,{icon:w4,label:"Insert blockquote",onClick:()=>$("> ")})]})}import{jsx as n3,jsxs as xN}from"react/jsx-runtime";function zJ({anchor:$,children:M,status:J="default"}){let Z=!$.isSelection;return n3(Y8,{children:xN("div",{className:"documint-leaf-anchor","data-selection":$.isSelection?"true":"false",onPointerEnter:$.onPointerEnter,onPointerLeave:$.onPointerLeave,style:{left:`${$.left}px`,top:`${$.top}px`},children:[Z?n3("div",{className:"documint-leaf-bridge"}):null,n3("div",{className:"documint-leaf-shell","data-status":J,children:M})]})})}import{useEffect as WJ,useRef as dN,useState as EJ}from"react";import{jsx as t0,jsxs as t3}from"react/jsx-runtime";function TJ({canEdit:$,onDelete:M,onSave:J,title:Z,url:X}){let[D,Y]=EJ(X),[Q,K]=EJ(!1),q=dN(null),U=aN(),N=D.trim(),A=$&&N.length>0,V=$&&!Q,B=`${U}click to open`,G=`documint-link-leaf-row${Q?" is-editing":""}`;return WJ(()=>{if(Q)return;Y(X)},[Q,X]),WJ(()=>{if(!Q)return;q.current?.focus()},[Q]),t3("div",{className:"documint-link-leaf",children:[Z?t0("div",{className:"documint-link-leaf-title",children:Z}):null,t3("div",{className:G,children:[Q?t0(m4,{actions:{kind:"edit",onCancel:()=>{Y(X),K(!1)},onSave:()=>{J(N),K(!1)},saveDisabled:!A},onChange:Y,readOnly:!$,ref:q,rows:3,value:D}):t0("div",{className:"documint-link-leaf-url",children:X}),V?t3("div",{className:"documint-link-leaf-actions",children:[t0("button",{className:"documint-leaf-action","aria-label":"Edit link",onClick:()=>{if(!$)return;Y(X),K(!0)},title:"Edit link",type:"button",children:t0(w1,{size:14,strokeWidth:2.2})}),t0("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Remove link",onClick:M,title:"Remove link",type:"button",children:t0(w0,{size:14,strokeWidth:2.2})})]}):null]}),t0("div",{className:"documint-link-leaf-divider"}),t0("div",{className:"documint-link-leaf-hint",children:B})]})}function aN(){if(typeof navigator>"u")return"Ctrl+";let $=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/.test($)?"CMD+":"CTRL+"}import{jsx as e0,jsxs as M$}from"react/jsx-runtime";var iN=[{text:"Column left",value:"left"},{text:"Column right",value:"right"}],sN=[{text:"Row above",value:"above"},{text:"Row below",value:"below"}],e3={text:"Delete column",value:"delete"},$$={text:"Delete row",value:"delete"},yJ={text:"Delete table",value:"delete"};function wJ({canDeleteColumn:$,canDeleteRow:M,onDeleteColumn:J,onDeleteRow:Z,onDeleteTable:X,onInsertColumn:D,onInsertRow:Y}){return M$(c,{children:[M$(c.Menu,{icon:V1,label:"Column actions",onSelect:(Q)=>{if(Q===e3.value){J();return}D(Q)},children:[iN.map(({text:Q,value:K})=>e0(c.MenuItem,{icon:K2,text:Q,value:K},K)),e0(c.MenuDivider,{}),e0(c.MenuItem,{disabled:!$,icon:w0,text:e3.text,value:e3.value})]}),M$(c.Menu,{icon:G1,label:"Row actions",onSelect:(Q)=>{if(Q===$$.value){Z();return}Y(Q)},children:[sN.map(({text:Q,value:K})=>e0(c.MenuItem,{icon:K2,text:Q,value:K},K)),e0(c.MenuDivider,{}),e0(c.MenuItem,{disabled:!M,icon:w0,text:$$.text,value:$$.value})]}),e0(c.Divider,{}),e0(c.Menu,{icon:F1,label:"Table actions",onSelect:()=>X(),children:e0(c.MenuItem,{icon:w0,text:yJ.text,value:yJ.value})})]})}import{useEffect as OJ,useEffectEvent as CJ,useLayoutEffect as oN,useMemo as nN,useRef as J$,useState as tN}from"react";function K8($,M){if(!$||$.kind==="task-toggle")return null;if($.commentThreadIndex!==null){let J=M[$.commentThreadIndex]??null;if(!J)return null;return{kind:"comment",left:$.anchorLeft,link:$.kind==="link"?{title:$.title,url:$.url}:null,thread:J,threadIndex:$.commentThreadIndex,top:$.anchorBottom}}if($.kind!=="link")return null;return{endOffset:$.endOffset,kind:"link",left:$.anchorLeft,regionId:$.regionId,startOffset:$.startOffset,title:$.title,top:$.anchorBottom,url:$.url}}var eN=600,$A=530,G2=24;function LJ({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,editorState:Z,editorViewportState:X,getScrollTop:D,layoutWidth:Y,onVisibilityChange:Q,scrollContentHeight:K,scrollTo:q,viewportHeight:U}){let N=nN(()=>n(Z),[Z]),[A,V]=tN(null),B=N.start.regionId===N.end.regionId&&N.start.offset===N.end.offset,G=J$(!0),b=J$(0),P=J$(null),y=CJ(()=>{Q()}),z=CJ(()=>{b.current=typeof performance<"u"?performance.now():Date.now(),G.current=!0,y()});return oN(()=>{let L=MA({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,normalizedSelection:N,state:Z,viewport:X.get()});V((R)=>DA(R,L)?R:L)},[$,M,J,Z,X]),OJ(()=>{let L=Z.selection.focus,R={layoutWidth:Y,offset:L.offset,regionId:L.regionId,scrollContentHeight:K,viewportHeight:U};if(YA(P.current,R))return;let m=B6(Z,X.get(),L);if(!m)return;let E=D(),_=E+G2,j=E+U-G2;if(m.top<_){let C=q(Math.max(0,m.top-G2));if(jJ(m,C,U,G2))P.current=R;return}if(m.top+m.height>j){let C=q(Math.max(0,m.top+m.height-U+G2));if(jJ(m,C,U,G2))P.current=R;return}P.current=R},[Z,Z.selection.focus.offset,Z.selection.focus.regionId,X,Y,K,q,U]),OJ(()=>{if(G.current=!0,y(),!B||typeof window>"u")return;let L=window.setInterval(()=>{if((typeof performance<"u"?performance.now():Date.now())-b.current<eN){if(!G.current)G.current=!0,y();return}G.current=!G.current,y()},$A);return()=>{window.clearInterval(L)}},[B]),{leaf:A,isVisible:()=>G.current,markActivity:z}}function MA({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,normalizedSelection:Z,state:X,viewport:D}){if(!D)return null;let Y=X.selection.focus;if(Z.start.regionId!==Z.end.regionId||Z.start.offset!==Z.end.offset)return null;let Q=$?XA(X,D):null;if(Q)return Q;let K=M?JA(X,D):null;if(K)return K;return K8(G6(X,D,Y,J.liveRanges),J.threads)}function JA($,M){let J=$.selection.focus,Z=$.documentIndex.regionIndex.get(J.regionId),X=Z?$.documentIndex.tableCellIndex.get(Z.id)??null:null;if(!Z||!X)return null;let D=$.documentIndex.blockIndex.get(Z.blockId),Y=D?.type==="table"?$.documentIndex.document.blocks[D.rootIndex]:null;if(!D||!Y||Y.type!=="table")return null;let Q=o0($,M,J),K=ZA(M,Z.id),q=Math.max(1,...Y.rows.map((U)=>U.cells.length));return Q&&K!==null?{cellIndex:X.cellIndex,columnCount:q,kind:"table",left:K,rowCount:Y.rows.length,rowIndex:X.rowIndex,top:Q.top+Q.height}:null}function ZA($,M){let J=$.layout.lines.find((Z)=>Z.regionId===M);return J?J.left:null}function XA($,M){let J=$.selection.focus,Z=$.documentIndex.regionIndex.get(J.regionId);if(!Z||Z.blockType!=="paragraph"||Z.text.length>0)return null;if(J.offset!==0)return null;let X=$.documentIndex.blockIndex.get(Z.blockId);if(!X||X.parentBlockId!==null)return null;let D=o0($,M,J);return D?{kind:"insertion",left:D.left,top:D.top+D.height}:null}function DA($,M){if($===M)return!0;if(!$||!M||$.kind!==M.kind)return!1;switch($.kind){case"comment":return M.kind==="comment"&&$.left===M.left&&$.link?.title===M.link?.title&&$.link?.url===M.link?.url&&$.thread===M.thread&&$.threadIndex===M.threadIndex&&$.top===M.top;case"insertion":return M.kind==="insertion"&&$.left===M.left&&$.top===M.top;case"link":return M.kind==="link"&&$.endOffset===M.endOffset&&$.left===M.left&&$.regionId===M.regionId&&$.startOffset===M.startOffset&&$.title===M.title&&$.top===M.top&&$.url===M.url;case"table":return M.kind==="table"&&$.cellIndex===M.cellIndex&&$.columnCount===M.columnCount&&$.left===M.left&&$.rowCount===M.rowCount&&$.rowIndex===M.rowIndex&&$.top===M.top}}function YA($,M){return $?.layoutWidth===M.layoutWidth&&$.regionId===M.regionId&&$.offset===M.offset&&$.scrollContentHeight===M.scrollContentHeight&&$.viewportHeight===M.viewportHeight}function jJ($,M,J,Z){return $.top>=M+Z&&$.top+$.height<=M+J-Z}import{useEffect as QA,useEffectEvent as KA,useMemo as Z$,useRef as qA,useState as UA}from"react";function RJ($){let M=Z$(()=>NA($),[$]),J=Z$(()=>M.join(`
31
+ `),[M]),[Z,X]=UA(new Map),D=qA(new Map),Y=KA((Q,K)=>{if(typeof Image>"u")return;let q=new Set(Q),U=D.current;X((N)=>VA(N,q,U));for(let N of Q){if(AA(Z,U,N))continue;GA(N,U,X,K)}});return QA(()=>{let Q=!0;return Y(M,()=>Q),()=>{Q=!1}},[J]),Z$(()=>Z.size===0?null:{images:Z},[Z])}function NA($){return[...p$($)].sort()}function AA($,M,J){return $.get(J)?.status==="loaded"||M.has(J)}function VA($,M,J){let Z=!1,X=new Map($);for(let D of X.keys())if(!M.has(D))X.delete(D),J.delete(D),Z=!0;return Z?X:$}function GA($,M,J,Z){let X=new Image;X.decoding="async",X.crossOrigin="anonymous",M.set($,X),J((D)=>{let Y=new Map(D);return Y.set($,BA()),Y}),X.onload=()=>{if(M.delete($),!Z())return;J((D)=>{let Y=new Map(D);return Y.set($,FA(X)),Y})},X.onerror=()=>{if(M.delete($),!Z())return;J((D)=>{let Y=new Map(D);return Y.set($,_A()),Y})},X.src=$}function BA(){return{intrinsicHeight:0,intrinsicWidth:0,source:null,status:"loading"}}function FA($){return{intrinsicHeight:$.naturalHeight,intrinsicWidth:$.naturalWidth,source:$,status:"loaded"}}function _A(){return{intrinsicHeight:0,intrinsicWidth:0,source:null,status:"error"}}import{useEffect as kJ,useEffectEvent as F0,useRef as u4,useState as bA}from"react";var HA=48;function fJ({applyNextState:$,autoScrollDuringDrag:M,canvasRef:J,commentState:Z,editorStateRef:X,editorViewportState:D,focusInput:Y,onActivity:Q,readCurrentState:K,resolvePoint:q}){let[U,N]=bA(null),A=u4(null),V=u4(!1),B=u4(null),G=u4(null),b=u4(null),P=K8(U,Z.threads),y=U?.kind==="task-toggle"||P?.kind==="link"?"pointer":"text";kJ(()=>{if(U&&U.kind!=="task-toggle"&&!P)N(null)},[U,P]),kJ(()=>()=>{if(A.current!==null)window.clearTimeout(A.current)},[]);let z=F0(()=>{if(A.current!==null)window.clearTimeout(A.current),A.current=null}),L=F0(()=>{z(),A.current=window.setTimeout(()=>{if(A.current=null,!V.current)N(null)},HA)}),R=F0(()=>{if(!V.current)z(),N(null)}),m=F0((O)=>{if(!O){R();return}if(O.kind==="task-toggle"){z(),N((T)=>T?.kind==="task-toggle"&&T.listItemId===O.listItemId?T:O);return}if(O.commentThreadIndex!==null){if(!(Z.threads[O.commentThreadIndex]??null)){R();return}z();let k=O.commentThreadIndex;N((f)=>f?.kind!=="task-toggle"&&f?.commentThreadIndex===k?f:O);return}if(O.kind!=="link"){R();return}z(),N((T)=>T?.kind==="link"&&T.title===O.title&&T.url===O.url&&T.startOffset===O.startOffset&&T.endOffset===O.endOffset?T:O)}),E=F0((O)=>{let T=X.current;if(!T)return null;let k=q(O);if(!k)return null;return V6(T,D.get(),k,Z.liveRanges)}),_=F0((O)=>{let T=J.current;if(T&&B.current===O)T.releasePointerCapture(O)}),j=F0(()=>{B.current=null,G.current=null}),C=F0((O)=>{_(O.pointerId),j()}),W=F0((O)=>{if(b.current=O.pointerType,O.pointerType==="touch")return;let T=J.current,k=K(),f=q(O);if(!f)return;if(E(O)?.kind==="task-toggle")return;let I=F5(k,D.get(),f);if(!T||!I)return;B.current=O.pointerId,G.current={offset:I.offset,regionId:I.regionId},Q(),T.setPointerCapture(O.pointerId),$(D0(k,{offset:I.offset,regionId:I.regionId})),Y({offset:I.offset,regionId:I.regionId})}),F=F0((O)=>{let T=G.current,k=K(),f=q(O);if(!f)return;if(B.current!==O.pointerId||!T){m(E(O));return}let d=f2(k,D.get(),f,T);if(!d)return;Q(),M(O),$(D0(k,{anchor:T,focus:d}))}),H=F0(()=>{if(!V.current)L()}),v=F0((O)=>{let T=b.current==="touch";b.current=null;let k=E(O);if(k?.kind==="task-toggle"){let U0=K(),z0=U3(U0,k.listItemId);if(z0)O.preventDefault(),O.stopPropagation(),Q(),$(z0);return}if(k?.kind==="link"&&(O.metaKey||O.ctrlKey)){O.preventDefault(),O.stopPropagation(),O.currentTarget.ownerDocument.defaultView?.open(k.url,"_blank","noopener,noreferrer");return}if(!T){Y();return}let f=K(),d=q(O),I=d?F5(f,D.get(),d):null;if(I)Q(),$(D0(f,{offset:I.offset,regionId:I.regionId})),Y({offset:I.offset,regionId:I.regionId});else Y()}),h=F0((O)=>{let T=K(),k=q(O),f=E(O);if(!k||f?.kind==="task-toggle")return;let d=A6(T,D.get(),k);if(!d)return;O.preventDefault(),O.stopPropagation(),Q(),$(D0(T,d)),Y()}),l=F0(()=>{V.current=!0,z()}),p=F0(()=>{V.current=!1,L()});return{canvasHandlers:{onClick:v,onDoubleClick:h,onPointerCancel:C,onPointerDown:W,onPointerLeave:H,onPointerMove:F,onPointerUp:C},cursor:y,leaf:P,leafHandlers:{onPointerEnter:l,onPointerLeave:p}}}import{useEffect as Q$,useEffectEvent as V0,useLayoutEffect as zA,useRef as IJ,useState as WA}from"react";import{useEffect as yL1}from"react";var X$=[{key:"Backspace",command:"deleteBackward"},{key:"Enter",command:"insertLineBreak"},{key:"Home",command:"moveToLineStart"},{key:"End",command:"moveToLineEnd"},{key:"Tab",command:"indent"},{key:"Tab",shiftKey:!0,command:"dedent"},{key:"ArrowLeft",modKey:!0,shiftKey:"any",command:"moveToLineStart"},{key:"ArrowRight",modKey:!0,shiftKey:"any",command:"moveToLineEnd"},{key:"ArrowUp",modKey:!0,shiftKey:"any",command:"moveToDocumentStart"},{key:"ArrowDown",modKey:!0,shiftKey:"any",command:"moveToDocumentEnd"},{key:"ArrowUp",altKey:!0,shiftKey:!0,command:"moveListItemUp"},{key:"ArrowDown",altKey:!0,shiftKey:!0,command:"moveListItemDown"},{key:"a",modKey:!0,command:"selectAll"},{key:"b",modKey:!0,command:"toggleBold"},{key:"e",modKey:!0,command:"toggleInlineCode"},{key:"i",modKey:!0,command:"toggleItalic"},{key:"u",modKey:!0,command:"toggleUnderline"},{key:"y",modKey:!0,command:"redo"},{key:"z",modKey:!0,command:"undo"},{key:"z",modKey:!0,shiftKey:!0,command:"redo"}];function mJ($,M=X$){return M.find((J)=>{let Z=J.shiftKey==="any"?!0:(J.shiftKey??!1)===($.shiftKey??!1);return J.key.toLowerCase()===$.key.toLowerCase()&&(J.altKey??!1)===($.altKey??!1)&&Z&&(J.modKey??!1)===Boolean($.metaKey||$.ctrlKey)})?.command??null}function hJ($){let M=$.documentIndex.regions.find((D)=>D.id===$.selection.anchor.regionId),J=$.documentIndex.regions.find((D)=>D.id===$.selection.focus.regionId),Z=(M?.start??0)+$.selection.anchor.offset,X=(J?.start??0)+$.selection.focus.offset;return{end:Math.max(Z,X),start:Math.min(Z,X)}}function D$($){let M=Y$($);if(!M)return"";let J=$.documentIndex.regions.find((Z)=>Z.id===M.regionId);if(!J)return"";return J.text.slice(M.startOffset,M.endOffset)}function Y$($){let M=PA($);if(M.start.regionId!==M.end.regionId||M.start.offset===M.end.offset)return null;return{endOffset:M.end.offset,regionId:M.start.regionId,startOffset:M.start.offset}}var SJ=28,uJ=18;function gJ($,M){if(!$)return;let J=$.getBoundingClientRect();if(M.clientY<J.top+SJ){$.scrollTop=Math.max(0,$.scrollTop-uJ);return}if(M.clientY>J.bottom-SJ)$.scrollTop+=uJ}function PA($){let M=vJ($.documentIndex.regions,$.selection.anchor.regionId,$.selection.anchor.offset),J=vJ($.documentIndex.regions,$.selection.focus.regionId,$.selection.focus.offset);return M<=J?{end:$.selection.focus,start:$.selection.anchor}:{end:$.selection.anchor,start:$.selection.focus}}function vJ($,M,J){let Z=$.findIndex((X)=>X.id===M);if(Z===-1)return-1;return Z*1e6+J}var EA=1024,pJ=16;function cJ({applyNextState:$,editorState:M,editorStateRef:J,editorViewportState:Z,inputRef:X,keybindings:D,onActivity:Y}){let Q=TA(),K=()=>J.current??M,q=IJ(!1),U=IJ(!1),N=V0((F)=>{if(!F)return;Y(),$(F)}),A=V0(()=>{let F=X.current;if(!F)return;if(typeof document>"u")return;let H=document.execCommand;if(typeof H!=="function")return;try{q.current=!0,H.call(document,"insertText",!1,"‌"),H.call(document,"delete")}catch{}finally{q.current=!1,v4(F,K())}}),V=V0(()=>{if(U.current)return;U.current=!0,A()}),B=V0(()=>{A()}),G=V0((F)=>{if(!Q)return;let H=X.current;if(!H)return;let v=Z.get(),h=o0(K(),v,F);if(!h)return;H.style.top=`${h.top}px`,H.style.left=`${h.left}px`,H.style.height=`${h.height}px`}),b=V0((F)=>{let H=X.current;if(!H)return;G(F??K().selection.focus),H.focus({preventScroll:!Q}),v4(H,K()),V()}),P=V0((F,H)=>{let h=rJ(H,q8(F)).replace(/\r\n/g,`
32
+ `).split(/(\n)/),l=F;for(let p of h){if(p.length===0)continue;let O=p===`
33
+ `?J4(l):Y2(l,p);if(!O)continue;l=O}return l===F?null:l}),y=V0((F,H,v)=>{let h=F.selection.focus,l={regionId:h.regionId,offset:Math.max(0,h.offset-H)},p=D0(F,{anchor:l,focus:h});return x5(p,v)}),z=V0((F)=>{if(q.current)return;let H=K(),v=OA(F.inputType);if(F.inputType==="insertText"){if(!F.data)return;F.preventDefault();let h=lJ(F.target);if(h>0){N(y(H,h,F.data));return}let l=wA(H,F.data);if(l>0){let p=F.data.slice(l);if(p.length>0)N(P(H,p));return}N(P(H,F.data));return}if(F.inputType==="insertReplacementText"){if(!F.data)return;F.preventDefault();let h=lJ(F.target);N(y(H,h,F.data));return}if(yA(F.inputType)){F.preventDefault(),N(J4(H));return}if(v==="backward"){F.preventDefault(),N(r5(H));return}if(v==="forward"){F.preventDefault(),N(c5(H));return}if(F.inputType==="historyUndo"){F.preventDefault(),N(a5(H)),B();return}if(F.inputType==="historyRedo"){F.preventDefault(),N(i5(H)),B();return}}),L=V0((F)=>{let H=K(),v=F.currentTarget.value,h=q8(H);if(q.current)return;if(rJ(v,h).length===0){v4(F.currentTarget,H);return}N(P(H,v))}),R=V0((F)=>{let H=jA(K(),Z.get(),F.nativeEvent,D);if(!H)return;F.preventDefault(),N(H)}),m=V0((F)=>{let H=D$(K());if(!H)return;F.preventDefault(),F.clipboardData.setData("text/plain",H)}),E=V0((F)=>{let H=K(),v=D$(H);if(!v)return;F.preventDefault(),F.clipboardData.setData("text/plain",v),N(Z4(H))}),_=V0((F)=>{let H=F.clipboardData.getData("text/plain");if(H.length===0)return;F.preventDefault(),N(x5(K(),H))}),j=V0(()=>{Y();let F=X.current;if(F)v4(F,K())}),C=V0((F)=>{if(Y(),F.target.matches(":focus-visible"))b()});Q$(()=>{let F=X.current;if(!F)return;v4(F,M)},[M,X]),zA(()=>{G(M.selection.focus)},[M,G]),Q$(()=>{let F=X.current;if(!F)return;let H=(v)=>z(v);return F.addEventListener("beforeinput",H),()=>F.removeEventListener("beforeinput",H)},[X,z]);let W={onCopy:m,onCut:E,onPaste:_,...Q?{}:{onKeyDown:R}};return{canvasHandlers:{...W,onFocus:C},focus:b,inputHandlers:{...W,onFocus:j,onInput:L}}}var xJ="​";function TA(){let[$,M]=WA(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return!1;return window.matchMedia("(pointer: coarse)").matches});return Q$(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return;let J=window.matchMedia("(pointer: coarse)"),Z=(X)=>M(X.matches);return J.addEventListener?.("change",Z),()=>J.removeEventListener?.("change",Z)},[]),$}function yA($){return $==="insertLineBreak"||$==="insertParagraph"}function lJ($){let M=$,J=M?.selectionStart??0,Z=M?.selectionEnd??J;return Math.max(0,Z-J)}function wA($,M){if(M.length<pJ)return 0;let J=q8($,M.length),Z=Math.min(J.length,M.length);for(let X=Z;X>=pJ;X--)if(J.endsWith(M.slice(0,X)))return X;return 0}function OA($){switch($){case"deleteContentBackward":case"deleteComposedCharacterBackward":case"deleteSoftLineBackward":case"deleteHardLineBackward":case"deleteWordBackward":return"backward";case"deleteContentForward":case"deleteSoftLineForward":case"deleteHardLineForward":case"deleteWordForward":return"forward";default:return null}}function CA($){return $.replaceAll(xJ,"")}function q8($,M=EA){let{anchor:J,focus:Z}=$.selection;if(J.regionId!==Z.regionId||J.offset!==Z.offset)return"";let X=$.documentIndex.regionIndex.get(Z.regionId);if(!X)return"";return X.text.slice(Math.max(0,Z.offset-M),Z.offset)}function rJ($,M){let J=CA($);return J.startsWith(M)?J.slice(M.length):J}function v4($,M){let J=q8(M),Z=`${xJ}${J}`;$.value=Z,$.setSelectionRange(Z.length,Z.length)}function jA($,M,J,Z){if(J.key==="Delete")return c5($);let X=mJ(J,Z);if(X){if(X==="moveToLineStart"||X==="moveToLineEnd")return P3($,M.layout,X==="moveToLineStart"?"Home":"End",J.shiftKey);if(X==="moveToDocumentStart"||X==="moveToDocumentEnd")return z3($,X==="moveToDocumentStart"?"start":"end",J.shiftKey);switch(X){case"insertLineBreak":return J4($);case"deleteBackward":return r5($);case"indent":return n6($);case"dedent":return t6($);case"moveListItemUp":return e6($);case"moveListItemDown":return $3($);case"toggleBold":return X4($);case"toggleItalic":return D4($);case"toggleStrikethrough":return Y4($);case"toggleUnderline":return Q4($);case"toggleInlineCode":return Q3($);case"undo":return a5($);case"redo":return i5($);case"selectAll":return o6($)}}if(J.key==="ArrowLeft"||J.key==="ArrowRight")return _3($,J.key==="ArrowLeft"?-1:1,J.shiftKey);if(J.key==="ArrowUp"||J.key==="ArrowDown")return b3($,M.layout,J.key==="ArrowUp"?-1:1,J.shiftKey);if(J.key==="PageUp"||J.key==="PageDown")return H3($,M.layout,J.key==="PageUp"?-1:1,J.shiftKey);if(J.key.length===1&&!J.altKey&&!J.ctrlKey&&!J.metaKey)return Y2($,J.key);return null}import{useEffectEvent as K$,useLayoutEffect as LA,useMemo as RA,useState as kA}from"react";function dJ({editorState:$,editorStateRef:M,editorViewportState:J,onViewportScroll:Z,scrollContainerRef:X,scheduleOverlayRender:D,userPresence:Y}){let Q=RA(()=>{if(!Y||Y.length===0)return;return b5($.documentIndex,Y)},[$.documentIndex,Y]),[K,q]=kA(void 0),U=K$(()=>{if(Q===void 0){if(K!==void 0)q(void 0)}else q(m2(M.current??$,J.get(),Q));D()}),N=K$((V)=>{if(Q===void 0){if(K!==void 0)q(void 0);return}let B=m2(M.current??$,V,Q);if(fA(K,B))return;q(B)});LA(()=>{U()},[Q]);let A=K$((V)=>{if(!V.viewport||V.viewport.status==="unresolved")return;let B=X.current;if(!B)return;B.scrollTop=V.viewport.scrollTop,Z(B)});return{presence:K,scrollToPresence:A,refreshPresence:N}}function fA($,M){if($===M)return!0;if($===void 0||M===void 0||$.length!==M.length)return!1;return $.every((J,Z)=>{let X=M[Z];return J.id===X.id&&mA(J.viewport,X.viewport)})}function mA($,M){if($===M)return!0;if($===null||M===null)return!1;if($.status==="unresolved")return M.status==="unresolved";if(M.status==="unresolved")return!1;return $.status===M.status&&$.scrollTop===M.scrollTop}import{useEffect as SA,useEffectEvent as j1,useRef as h4}from"react";function aJ({editorStateRef:$,renderContent:M,renderOverlay:J,renderViewport:Z}){let X=h4(null),D=h4(!1),Y=h4(!1),Q=h4(!1),K=h4(!1),q=j1(()=>{if(typeof window>"u"){Z();return}D.current=!0,V()}),U=j1(()=>{if(typeof window>"u"){M(),J();return}Y.current=!0,V()}),N=j1(()=>{if(typeof window>"u"){M();return}Q.current=!0,V()}),A=j1(()=>{if(typeof window>"u"){J();return}K.current=!0,V()}),V=j1(()=>{if(typeof window>"u"||X.current!==null)return;X.current=window.requestAnimationFrame(()=>{B()})}),B=j1(()=>{X.current=null;let b=D.current,P=Y.current,y=Q.current,z=K.current;if(D.current=!1,Y.current=!1,Q.current=!1,K.current=!1,b){Z(),G();return}if(P){M(),J(),G();return}if(y)M(),G();if(z)J()}),G=j1(()=>{let b=$.current;if(!b||!S6(b,performance.now()))return;Q.current=!0,V()});return SA(()=>{return()=>{if(typeof window>"u"||X.current===null)return;window.cancelAnimationFrame(X.current),X.current=null}},[]),{scheduleContentPaint:N,scheduleFullPaint:U,scheduleFullRender:q,scheduleOverlayPaint:A}}import{useEffectEvent as q$,useLayoutEffect as iJ,useMemo as U$,useRef as N$,useState as sJ}from"react";function oJ({applyNextState:$,autoScrollDuringDrag:M,canShowSelectionLeaf:J,editorState:Z,editorStateRef:X,editorViewportState:D,focusInput:Y,onActivity:Q,resolvePoint:K,threads:q}){let U=U$(()=>n(Z),[Z]),N=U$(()=>Y$(Z),[Z]),A=U$(()=>w5(Z),[Z]),[V,B]=sJ(null),[G,b]=sJ(null),P=N$(null),y=N$(null),z=N$(null);iJ(()=>{let _=uA(Z,D.get(),U);B((j)=>pA(j,_)?j:_)},[Z,D,U.end.offset,U.end.regionId,U.start.offset,U.start.regionId]),iJ(()=>{let _=hA({canShowSelectionLeaf:J,currentLeaf:G,activeMarks:A,handles:V,selectionRange:N,threads:q});b((j)=>IA(j,_)?j:_)},[A,J,V,G,N,q]);let L=q$((_,j=!0)=>{b((C)=>C?.kind==="create"?{animateInitialComment:j,kind:"thread",left:C.left,threadIndex:_,top:C.top}:C)}),R=q$((_)=>{if(_&&z.current===_.pointerId&&_.currentTarget.hasPointerCapture(_.pointerId))_.currentTarget.releasePointerCapture(_.pointerId);P.current=null,y.current=null,z.current=null}),m=q$((_)=>{let j=X.current,C=y.current,W=K(_);if(!W||!j||!C||z.current!==_.pointerId)return;let F=f2(j,D.get(),W,C);if(!F)return;_.preventDefault(),_.stopPropagation(),Q(),M(_),$(D0(j,{anchor:C,focus:F}))}),E=(_)=>({onPointerCancel:(j)=>{R(j)},onPointerDown:(j)=>{let C=X.current??Z,W=rA(U,_),F=_==="start"?U.start:U.end;if(!V)return;j.preventDefault(),j.stopPropagation(),z.current=j.pointerId,y.current=W,P.current=_,j.currentTarget.setPointerCapture(j.pointerId),Q(),Y(),$(D0(C,{anchor:W,focus:F}))},onPointerMove:(j)=>{if(P.current!==_)return;m(j)},onPointerUp:(j)=>{if(P.current===_)m(j);R(j)}});return{endHandleProps:E("end"),handles:V,leaf:G,promoteLeafToThread:L,startHandleProps:E("start")}}function uA($,M,J){if(J.collapsed)return null;let Z=o0($,M,J.start),X=o0($,M,J.end);if(!Z||!X)return null;return{end:{left:X.left,top:X.top+X.height},start:{left:Z.left,top:Z.top}}}function vA($,M,J){return{activeMarks:J,kind:"create",left:M.start.left,selection:$,top:M.end.top}}function hA({activeMarks:$,canShowSelectionLeaf:M,currentLeaf:J,handles:Z,selectionRange:X,threads:D}){if(!M||!X||!Z)return null;if(J?.kind==="thread")return D[J.threadIndex]?J:null;return vA(X,Z,$)}function gA($,M){return $?.kind==="create"&&$.left===M.left&&$.selection.regionId===M.selection.regionId&&$.selection.startOffset===M.selection.startOffset&&$.selection.endOffset===M.selection.endOffset&&lA($.activeMarks,M.activeMarks)&&$.top===M.top}function IA($,M){if($===M)return!0;if(!$||!M||$.kind!==M.kind)return!1;if($.kind==="create"&&M.kind==="create")return gA($,M);return $.kind==="thread"&&M.kind==="thread"&&$.animateInitialComment===M.animateInitialComment&&$.left===M.left&&$.threadIndex===M.threadIndex&&$.top===M.top}function pA($,M){if($===M)return!0;if(!$||!M)return!1;return $.start.left===M.start.left&&$.start.top===M.start.top&&$.end.left===M.end.left&&$.end.top===M.end.top}function lA($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function rA($,M){return M==="start"?$.end:$.start}import{useEffect as cA,useMemo as eJ,useState as xA}from"react";var g4={activeBlockBackground:"#fff1c7",activeBlockFlash:"rgba(245, 158, 11, 0.28)",background:"#fcfbf7",blockquoteRule:"rgba(14, 116, 144, 0.2)",blockquoteRuleActive:"rgba(124, 45, 18, 0.36)",blockquoteText:"#334155",caret:"#111827",checkboxCheckmark:"#f8fafc",checkboxCheckedFill:"#0f766e",checkboxCheckedStroke:"#0f766e",checkboxUncheckedFill:"#fcfffe",checkboxUncheckedStroke:"#64748b",codeBackground:"#0f172a",codeText:"#e2e8f0",commentHighlight:"#d7e3fc",commentHighlightActive:"#f4d35e",commentHighlightResolved:"#cfe9d8",commentHighlightResolvedActive:"#8dc4a0",headingRule:"rgba(15, 23, 42, 0.18)",headingText:"#0f172a",imageLoadingOverlay:"rgba(255, 255, 255, 0.42)",imagePlaceholderIcon:"rgba(14, 116, 144, 0.42)",imagePlaceholderText:"rgba(15, 23, 42, 0.58)",imageSurfaceBackground:"rgba(240, 249, 255, 0.98)",imageSurfaceBorder:"rgba(14, 116, 144, 0.22)",inlineCodeBackground:"rgba(15, 23, 42, 0.08)",inlineCodeText:"#7c2d12",insertHighlightText:"#2563eb",leafAccent:"#1d4ed8",leafBackground:"#fcfbf7",leafBorder:"rgba(148, 163, 184, 0.55)",leafButtonBackground:"rgba(15, 23, 42, 0.08)",leafButtonBorder:"rgba(148, 163, 184, 0.55)",leafButtonText:"#1f2937",leafResolvedBackground:"#cfe9d8",leafResolvedBorder:"#8dc4a0",leafSecondaryText:"#334155",leafShadow:"0 14px 40px rgba(15, 23, 42, 0.16)",leafText:"#1f2937",linkText:"#1d4ed8",listMarkerText:"#1f2937",paddingX:16,paddingY:12,paragraphText:"#1f2937",selectionBackground:"rgba(125, 211, 252, 0.35)",selectionHandleBackground:"#fcfbf7",selectionHandleBorder:"#1d4ed8",tableBodyBackground:"rgba(248, 250, 252, 0.98)",tableBorder:"rgba(148, 163, 184, 0.55)",tableHeaderBackground:"rgba(226, 232, 240, 0.95)"},I4={activeBlockBackground:"rgba(125, 211, 252, 0.12)",activeBlockFlash:"rgba(226, 232, 240, 0.12)",background:"#0b1220",blockquoteRule:"rgba(103, 232, 249, 0.34)",blockquoteRuleActive:"rgba(125, 211, 252, 0.5)",blockquoteText:"#cbd5e1",caret:"#f8fafc",checkboxCheckmark:"#082f49",checkboxCheckedFill:"#67e8f9",checkboxCheckedStroke:"#67e8f9",checkboxUncheckedFill:"#0f172a",checkboxUncheckedStroke:"#64748b",codeBackground:"#020617",codeText:"#dbeafe",commentHighlight:"rgba(96, 165, 250, 0.34)",commentHighlightActive:"#facc15",commentHighlightResolved:"rgba(74, 222, 128, 0.24)",commentHighlightResolvedActive:"#4ade80",headingRule:"rgba(226, 232, 240, 0.22)",headingText:"#f8fafc",imageLoadingOverlay:"rgba(186, 230, 253, 0.18)",imagePlaceholderIcon:"rgba(125, 211, 252, 0.44)",imagePlaceholderText:"rgba(226, 232, 240, 0.62)",imageSurfaceBackground:"rgba(15, 23, 42, 0.92)",imageSurfaceBorder:"rgba(56, 189, 248, 0.28)",inlineCodeBackground:"rgba(148, 163, 184, 0.16)",inlineCodeText:"#fdba74",insertHighlightText:"#60a5fa",leafAccent:"#93c5fd",leafBackground:"#0b1220",leafBorder:"rgba(100, 116, 139, 0.7)",leafButtonBackground:"rgba(148, 163, 184, 0.16)",leafButtonBorder:"rgba(100, 116, 139, 0.7)",leafButtonText:"#dbe4f0",leafResolvedBackground:"rgba(74, 222, 128, 0.24)",leafResolvedBorder:"#4ade80",leafSecondaryText:"#cbd5e1",leafShadow:"0 18px 44px rgba(2, 6, 23, 0.42), 0 0 0 1px rgba(148, 163, 184, 0.06)",leafText:"#dbe4f0",linkText:"#93c5fd",listMarkerText:"#e2e8f0",paddingX:16,paddingY:12,paragraphText:"#dbe4f0",selectionBackground:"rgba(56, 189, 248, 0.28)",selectionHandleBackground:"#0b1220",selectionHandleBorder:"#93c5fd",tableBodyBackground:"rgba(15, 23, 42, 0.9)",tableBorder:"rgba(100, 116, 139, 0.7)",tableHeaderBackground:"rgba(30, 41, 59, 0.96)"},nJ={...g4,activeBlockBackground:"rgba(16, 185, 129, 0.14)",activeBlockFlash:"rgba(16, 185, 129, 0.26)",background:"#f3fbf6",blockquoteRule:"rgba(5, 150, 105, 0.22)",blockquoteRuleActive:"rgba(6, 95, 70, 0.38)",blockquoteText:"#166534",caret:"#14532d",codeBackground:"#052e16",codeText:"#dcfce7",commentHighlight:"rgba(52, 211, 153, 0.26)",commentHighlightActive:"#10b981",commentHighlightResolved:"rgba(187, 247, 208, 0.96)",commentHighlightResolvedActive:"#059669",headingRule:"rgba(20, 83, 45, 0.18)",headingText:"#14532d",inlineCodeBackground:"rgba(20, 83, 45, 0.08)",inlineCodeText:"#166534",insertHighlightText:"#10b981",leafAccent:"#059669",leafBackground:"#f3fbf6",leafBorder:"rgba(22, 163, 74, 0.24)",leafButtonBackground:"rgba(20, 83, 45, 0.08)",leafButtonBorder:"rgba(22, 163, 74, 0.28)",leafButtonText:"#14532d",leafResolvedBackground:"#d1fae5",leafResolvedBorder:"#10b981",leafSecondaryText:"#166534",leafShadow:"0 14px 40px rgba(20, 83, 45, 0.14)",leafText:"#14532d",linkText:"#047857",paragraphText:"#14532d",selectionBackground:"rgba(52, 211, 153, 0.24)",selectionHandleBackground:"#f3fbf6",selectionHandleBorder:"#059669",tableBodyBackground:"rgba(243, 251, 246, 0.96)",tableBorder:"rgba(22, 163, 74, 0.24)",tableHeaderBackground:"rgba(220, 252, 231, 0.96)"},tJ={...I4,activeBlockBackground:"rgba(168, 85, 247, 0.16)",activeBlockFlash:"rgba(243, 232, 255, 0.13)",blockquoteRule:"rgba(196, 181, 253, 0.34)",blockquoteRuleActive:"rgba(216, 180, 254, 0.44)",caret:"#f5f3ff",codeBackground:"#1e1b4b",codeText:"#ede9fe",commentHighlight:"rgba(167, 139, 250, 0.28)",commentHighlightActive:"#c084fc",commentHighlightResolved:"rgba(45, 212, 191, 0.22)",commentHighlightResolvedActive:"#2dd4bf",headingRule:"rgba(233, 213, 255, 0.24)",headingText:"#f5f3ff",inlineCodeBackground:"rgba(196, 181, 253, 0.16)",inlineCodeText:"#f9a8d4",insertHighlightText:"#c084fc",leafAccent:"#d8b4fe",leafBackground:"#12091f",leafBorder:"rgba(139, 92, 246, 0.34)",leafButtonBackground:"rgba(196, 181, 253, 0.16)",leafButtonBorder:"rgba(139, 92, 246, 0.34)",leafButtonText:"#ede9fe",leafResolvedBackground:"rgba(45, 212, 191, 0.22)",leafResolvedBorder:"#2dd4bf",leafSecondaryText:"#ddd6fe",leafShadow:"0 20px 48px rgba(2, 6, 23, 0.48), 0 0 0 1px rgba(196, 181, 253, 0.08)",leafText:"#f5f3ff",linkText:"#d8b4fe",listMarkerText:"#ede9fe",paragraphText:"#ede9fe",selectionBackground:"rgba(167, 139, 250, 0.26)",selectionHandleBackground:"#12091f",selectionHandleBorder:"#d8b4fe",tableBodyBackground:"rgba(30, 27, 75, 0.88)",tableBorder:"rgba(139, 92, 246, 0.34)",tableHeaderBackground:"rgba(49, 46, 129, 0.94)"};function $Z($){let M=eJ(()=>aA($),[$]),[J,Z]=xA(M.light),X=eJ(()=>iA(J),[J]);return cA(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function"){Z(M.light);return}let D=window.matchMedia("(prefers-color-scheme: dark)"),Y=()=>{Z(D.matches?M.dark:M.light)};if(Y(),typeof D.addEventListener==="function")return D.addEventListener("change",Y),()=>{D.removeEventListener("change",Y)};return D.addListener(Y),()=>{D.removeListener(Y)}},[M]),{theme:J,themeStyles:X}}function dA($){return"light"in $&&"dark"in $}function aA($){if(!$)return{dark:I4,light:g4};if(dA($))return $;return{dark:$,light:$}}function iA($){return{"--documint-background":$.background,"--documint-leaf-button-bg":$.leafButtonBackground,"--documint-leaf-button-border":$.leafButtonBorder,"--documint-leaf-button-text":$.leafButtonText,"--documint-leaf-accent":$.leafAccent,"--documint-leaf-bg":$.leafBackground,"--documint-leaf-border":$.leafBorder,"--documint-leaf-font-family":'"Avenir Next", "Segoe UI", sans-serif',"--documint-leaf-shadow":$.leafShadow??void 0,"--documint-leaf-secondary-text":$.leafSecondaryText,"--documint-leaf-resolved-bg":$.leafResolvedBackground,"--documint-leaf-resolved-border":$.leafResolvedBorder,"--documint-leaf-text":$.leafText,"--documint-mention-bg":$.mentionBackground??void 0,"--documint-mention-text":$.mentionText??void 0,"--documint-selection-handle-bg":$.selectionHandleBackground,"--documint-selection-handle-border":$.selectionHandleBorder}}import{useEffect as nA,useEffectEvent as x0,useRef as A$,useState as U8}from"react";import{useMemo as sA}from"react";function MZ($){return sA(()=>oA({current:null},$),[$])}function oA($,M){return{peek(){return $.current},get(){let J=$.current;if(J!==null)return J;let Z=M();return $.current=Z,Z},invalidate(){$.current=null}}}function JZ($,M){let J=M.getBoundingClientRect();return{x:$.clientX-J.left+M.scrollLeft,y:$.clientY-J.top+M.scrollTop}}function ZZ({editorState:$,editorStateRef:M,renderResources:J,theme:Z}){let X=A$(W1()),D=A$(null),Y=A$({height:240,top:0}),[Q,K]=U8(0),[q,U]=U8(240),[N,A]=U8(0),[V,B]=U8(240),G=tA(Q),b=x0(()=>{let F=M.current??$,H=Y.current;return N6(F,{height:H.height,paddingX:Z.paddingX,paddingY:Z.paddingY,top:H.top,width:G},X.current,J)}),P=MZ(b),y=x0((F)=>{B((H)=>{let v=$V(F,Y.current.height);return H===v?H:v})}),z=x0((F)=>{Y.current={...Y.current,top:F},A((H)=>H===F?H:F),P.invalidate()}),L=x0((F)=>{let H=eA(F),v=H.top!==Y.current.top;if(Y.current=H,A((h)=>h===H.top?h:H.top),v)P.invalidate()}),R=x0((F)=>{let H=D.current;if(!H)return z(F),F;H.scrollTop=F;let v=H.scrollTop;return z(v),v}),m=x0(()=>{return D.current?.scrollTop??Y.current.top}),E=x0((F,H)=>{let v=F!==null&&F.documentIndex!==H.documentIndex,h=P.peek();if(!(!v||!h||h.layout.regionLineIndices.has(H.selection.focus.regionId)))P.invalidate()}),_=x0(()=>{return P.invalidate(),P.get()}),j=x0((F)=>{let H=D.current;return H?JZ(F,H):null}),C=x0((F)=>{gJ(D.current,F)});return nA(()=>{let F=D.current;if(!F||typeof ResizeObserver>"u")return;let H=new ResizeObserver((v)=>{let h=v[0];if(!h)return;let l=Math.max(0,Math.floor(h.contentRect.width)),p=XZ(F);Y.current={...Y.current,height:p},K((O)=>O===l?O:l),U((O)=>O===p?O:p)});return H.observe(F),()=>H.disconnect()},[D]),{actions:{autoScrollDuringDrag:C,getScrollTop:m,observePreparedViewport:y,observeScrollContainer:L,prepareNextPaint:_,reconcileEditorState:E,resolvePoint:j,scrollTo:R},props:{getScrollContainer:(F)=>({onScroll:(H)=>{L(H.currentTarget),F?.onScroll?.(H)},ref:D}),scrollContent:{style:{height:`${V}px`}}},refs:{scrollContainer:D},state:{layoutWidth:G,preparedViewport:P,scrollContentHeight:V,surfaceWidth:Q,viewportHeight:q,viewportTop:N}}}function tA($){return Math.max(240,Math.floor($||480))}function XZ($){return Math.max(240,$.clientHeight)}function eA($){return{height:XZ($),top:$.scrollTop}}function $V($,M){return Math.max(M,Math.ceil($.totalHeight+24))}function MV(){if(typeof window>"u")return 1;return Math.max(1,window.devicePixelRatio||1)}function V$($,{paintHeight:M,paintTop:J,width:Z}){if(!$)return null;let X=Math.max(240,Math.ceil(M)),D=MV();$.width=Math.ceil(Z*D),$.height=Math.ceil(X*D),$.style.width=`${Z}px`,$.style.height=`${X}px`,$.style.transform=`translateY(${J}px)`;let Y=$.getContext("2d");if(!Y)return null;return{context:Y,devicePixelRatio:D,height:X,width:Z}}function G$($,M){return $.activeBlockType===M.activeBlockType&&$.activeCommentThreadIndex===M.activeCommentThreadIndex&&$.activeSpanKind===M.activeSpanKind&&$.canonicalContent===M.canonicalContent&&$.characterCount===M.characterCount&&$.commentThreadCount===M.commentThreadCount&&$.layoutWidth===M.layoutWidth&&$.resolvedCommentCount===M.resolvedCommentCount&&$.selectionFrom===M.selectionFrom&&$.selectionTo===M.selectionTo}function DZ($,M){if(!M?.length||!$?.length)return;let J=new Map($.map((X)=>[X.id,X])),Z=[];for(let X of M){let D=J.get(X.userId);if(!D)continue;Z.push({...D,color:X.color,cursor:X.cursor})}return Z.length===0?void 0:Z}function QZ($,M){if(!$)return{didReconcile:!1,state:M};let J=JV($,M)??NV($,M);return J?{didReconcile:!0,state:J}:{didReconcile:!1,state:M}}function JV($,M){let J=ZV($,M);return J?D0(M,J,!1):null}function ZV($,M){if(_$($.selection.anchor,$.selection.focus)){let D=B$($,M,$.selection.focus,"neutral");return D?{anchor:D,focus:D}:null}let J=qV($),Z=B$($,M,$.selection.anchor,J.anchor),X=B$($,M,$.selection.focus,J.focus);return Z&&X?{anchor:Z,focus:X}:null}function B$($,M,J,Z){let X=$.documentIndex.regionIndex.get(J.regionId);if(!X)return null;let D=F$(X,M);if(!D)return null;return{offset:DV(X.text,D.text,J.offset,Z),regionId:D.id}}function F$($,M){let J=M.documentIndex.regionIndex.get($.id);if(J)return J;if($.text.length===0)return null;let Z=XV($,M);if(Z)return Z;return M.documentIndex.regionPathIndex.get($.path)??null}function XV($,M){let J=null;for(let Z of M.documentIndex.regions){if(Z.blockType!==$.blockType||Z.text!==$.text)continue;if(J)return null;J=Z}return J}function DV($,M,J,Z){let X=j0(J,0,$.length),{prefix:D,suffix:Y}=C8($,X,X),Q=YV(M,D,Y);if(Q!==null)return Q;let K=QV(M,D),q=KV(M,Y);if(Z==="before-suffix")return q??K??j0(J,0,M.length);return K??q??j0(J,0,M.length)}function YV($,M,J){let Z=l1($,M,J).filter((X)=>X.startOffset===X.endOffset);return Z.length===1?Z[0].startOffset:null}function QV($,M){let J=u0($,M);return J.length===1?J[0]+M.length:null}function KV($,M){let J=u0($,M);return J.length===1?J[0]:null}function qV($){let{anchor:M,focus:J}=$.selection;if(_$(M,J))return{anchor:"neutral",focus:"neutral"};return UV($,M,J)<=0?{anchor:"before-suffix",focus:"after-prefix"}:{anchor:"after-prefix",focus:"before-suffix"}}function UV($,M,J){let Z=$.documentIndex.regionOrderIndex.get(M.regionId),X=$.documentIndex.regionOrderIndex.get(J.regionId);if(Z===void 0||X===void 0)return 0;return Z===X?M.offset-J.offset:Z-X}function NV($,M){if(!_$($.selection.anchor,$.selection.focus))return null;let J=AV($);if(!J)return null;let Z=VV($,M,J);if(Z===null)return null;return GV(M,Z)}function AV($){let M=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!M||M.blockType!=="paragraph"||M.text.length>0)return null;return $.documentIndex.blockIndex.get(M.blockId)?.parentBlockId===null?M:null}function VV($,M,J){let Z=YZ($,J.rootIndex,"before"),X=YZ($,J.rootIndex,"after"),D=Z?F$(Z,M):null,Y=X?F$(X,M):null;if(D&&Y)return D.rootIndex<Y.rootIndex?Y.rootIndex:null;if(D)return D.rootIndex+1;if(Y)return Y.rootIndex;return null}function GV($,M){let J=I1($.documentIndex.document,M,0,[r({text:""})]),Z={...$,documentIndex:$2($.documentIndex,J,M,0)},X=p2(Z.documentIndex,M0(M));return X?D0(Z,X,!1):null}function YZ($,M,J){let Z=J==="before"?-1:1;for(let X=M+Z;X>=0&&X<$.documentIndex.roots.length;X+=Z){let D=BV($,X,J);if(D)return D}return null}function BV($,M,J){let Z=$.documentIndex.roots[M]?.regions??[],X=J==="before"?Z.length-1:0,D=J==="before"?-1:1;for(let Y=X;Y>=0&&Y<Z.length;Y+=D){let Q=Z[Y];if(Q&&Q.text.length>0)return Q}return null}function _$($,M){return $.regionId===M.regionId&&$.offset===M.offset}import{jsx as x,jsxs as A8,Fragment as EV}from"react/jsx-runtime";function V8({blocks:$}){return x(EV,{children:$.map((M)=>FV(M))})}function FV($){switch($.type){case"blockquote":return x("blockquote",{className:"preview-block preview-block-blockquote",children:x(V8,{blocks:$.children})},$.id);case"code":return A8("div",{className:"preview-block preview-block-code",children:[x("div",{className:"preview-rich-header",children:HV($.language,$.meta)}),x("pre",{children:x("code",{children:$.source||" "})})]},$.id);case"heading":{let M=`h${$.depth}`;return x(M,{className:"preview-block preview-block-heading",children:N8($.children)},$.id)}case"list":return $.ordered?x("ol",{className:"preview-block preview-block-list",start:$.start??1,children:$.items.map((M)=>b$(M))},$.id):x("ul",{className:"preview-block preview-block-list",children:$.items.map((M)=>b$(M))},$.id);case"listItem":return b$($);case"paragraph":return x("p",{className:"preview-block preview-block-paragraph",children:N8($.children)},$.id);case"table":return A8("div",{className:"preview-block preview-block-table",children:[x("div",{className:"preview-rich-header",children:PV($.rows.length,$.rows[0]?.cells.length??0,$.align.filter((M)=>M!==null).length)}),x("div",{className:"preview-table-scroll",children:x("table",{children:x("tbody",{children:$.rows.map((M)=>x("tr",{children:M.cells.map((J)=>x("td",{children:N8(J.children)},J.id))},M.id))})})})]},$.id);case"thematicBreak":return x("hr",{className:"preview-block preview-block-rule"},$.id);case"directive":return x("pre",{className:`preview-block preview-block-directive preview-block-directive-${$.name}`,children:$.body},$.id);case"unsupported":return x("pre",{className:"preview-block preview-block-unsupported",children:$.source},$.id)}}function b$($){return x("li",{className:"preview-block preview-block-list-item",children:x(V8,{blocks:$.children})},$.id)}function N8($){return $.map((M)=>{switch(M.type){case"break":return x("br",{},M.id);case"image":return A8("span",{className:"preview-inline preview-inline-image",children:[x("img",{alt:M.alt??"",src:M.url,title:M.title??""}),A8("span",{children:[x("strong",{children:zV(M.alt)}),x("small",{children:WV(M.url,M.title)})]})]},M.id);case"inlineCode":return x("code",{className:"preview-inline preview-inline-code",children:M.code},M.id);case"link":return _V(M);case"text":return x("span",{className:"preview-inline",children:bV(M.text,M.marks)},M.id);case"unsupported":return x("span",{className:"preview-inline preview-inline-unsupported",children:M.source},M.id)}})}function _V($){return x("a",{className:"preview-inline preview-inline-link",href:$.url,children:N8($.children)},$.id)}function bV($,M){let J=$;for(let Z of M)switch(Z){case"strikethrough":J=x("del",{children:J});break;case"italic":J=x("em",{children:J});break;case"bold":J=x("strong",{children:J});break;case"underline":J=x("ins",{children:J});break}return J}function HV($,M){return[$??"plain text",M].filter(Boolean).join(" • ")}function PV($,M,J){let Z=J>0?`${J} aligned ${J===1?"column":"columns"}`:"no alignment";return`${$} ${$===1?"row":"rows"} • ${M} ${M===1?"column":"columns"} • ${Z}`}function zV($){return $?.trim()?$:"Untitled image"}function WV($,M){return M?.trim()?`${M} • ${$}`:$}var KZ=`/* Base Documint host and SSR-fallback styles. */
34
+
35
+ .documint {
570
36
  display: grid;
571
37
  min-width: 0;
572
38
  min-height: 0;
573
39
  }
574
40
 
575
- :where(.documint-scroll-container) {
41
+ /* Default elevated-surface shadow shared by leaf overlays, menus, and
42
+ presence indicators. Both the host section and the overlay portal
43
+ wrapper carry it so descendants inherit the same value whether they're
44
+ rendered in-tree or portaled to document.body. */
45
+ .documint,
46
+ .documint-overlay {
47
+ --documint-leaf-shadow-fallback:
48
+ 0 14px 40px color-mix(in srgb, var(--documint-leaf-text) 16%, transparent);
49
+ }
50
+
51
+ .documint-scroll-container {
576
52
  position: relative;
577
53
  display: block;
578
54
  width: 100%;
579
55
  min-width: 0;
580
56
  min-height: 0;
581
57
  overflow: auto;
58
+ /* Match the canvas's paint color so the iOS overscroll bounce (and any
59
+ other reveal of the scroll container beyond the canvas's painted area)
60
+ shows the themed background instead of browser white. */
61
+ background: var(--documint-background);
582
62
  }
583
63
 
584
- :where(.documint-input) {
64
+ .documint-input {
585
65
  /* The bridge must look like a real focused input to iOS so Safari
586
66
  shifts the page above the virtual keyboard. Empirically:
587
67
  - opacity must be greater than 0
@@ -606,21 +86,25 @@ ${SJ}
606
86
  resize: none;
607
87
  }
608
88
 
609
- :where(.documint-scroll-content) {
89
+ .documint-scroll-content {
610
90
  position: relative;
611
91
  min-height: 100%;
612
92
  overflow: hidden;
613
93
  }
614
94
 
615
- :where(.documint-content-canvas) {
95
+ .documint-content-canvas {
616
96
  position: absolute;
617
97
  inset: 0 auto auto 0;
618
98
  display: block;
619
99
  width: 100%;
620
100
  outline: none;
101
+ /* Let the browser handle native pan (scrolling) on touch and eliminate the
102
+ historical 300ms tap delay. Double-tap zoom is suppressed on the canvas
103
+ (we want \`dblclick\` for word-select), but pinch-zoom and pan are kept. */
104
+ touch-action: manipulation;
621
105
  }
622
106
 
623
- :where(.documint-overlay-canvas) {
107
+ .documint-overlay-canvas {
624
108
  position: absolute;
625
109
  inset: 0 auto auto 0;
626
110
  display: block;
@@ -628,7 +112,7 @@ ${SJ}
628
112
  pointer-events: none;
629
113
  }
630
114
 
631
- :where(.documint-presence-indicators) {
115
+ .documint-presence-indicators {
632
116
  position: sticky;
633
117
  z-index: 5;
634
118
  display: flex;
@@ -650,10 +134,7 @@ ${SJ}
650
134
  border: 1px solid var(--documint-leaf-border);
651
135
  border-radius: 999px;
652
136
  background: var(--documint-leaf-bg);
653
- box-shadow: var(
654
- --documint-leaf-shadow,
655
- 0 14px 40px color-mix(in srgb, var(--documint-leaf-text) 16%, transparent)
656
- );
137
+ box-shadow: var(--documint-leaf-shadow, var(--documint-leaf-shadow-fallback));
657
138
  color: var(--documint-leaf-text);
658
139
  cursor: pointer;
659
140
  font-family: var(--documint-leaf-font-family, "Avenir Next", "Segoe UI", sans-serif);
@@ -661,237 +142,829 @@ ${SJ}
661
142
  font-weight: 700;
662
143
  line-height: 1;
663
144
  pointer-events: auto;
145
+
146
+ &:disabled {
147
+ cursor: default;
148
+ opacity: 0.72;
149
+ }
150
+ }
151
+
152
+ .documint-presence-indicator-avatar {
153
+ display: inline-grid;
154
+ place-items: center;
155
+ width: var(--documint-presence-indicator-size);
156
+ height: var(--documint-presence-indicator-size);
157
+ overflow: hidden;
158
+ border-radius: 999px;
159
+ background: var(--documint-presence-color);
160
+ color: white;
161
+ }
162
+
163
+ .documint-presence-indicator-image {
164
+ display: block;
165
+ width: calc(100% - 2px);
166
+ height: calc(100% - 2px);
167
+ border-radius: inherit;
168
+ object-fit: cover;
169
+ }
170
+
171
+ .documint-presence-indicator-direction {
172
+ display: inline-flex;
173
+ align-items: center;
174
+ height: 100%;
175
+ padding: 0 0.42rem 0 0.36rem;
176
+ color: var(--documint-leaf-text);
177
+ }
178
+
179
+ .documint-presence-indicator-arrow {
180
+ display: block;
181
+ }
182
+
183
+ .documint-selection-handle {
184
+ position: absolute;
185
+ z-index: 4;
186
+ width: 1.2rem;
187
+ height: 1.2rem;
188
+ margin: 0;
189
+ padding: 0;
190
+ border: 0;
191
+ background: transparent;
192
+ pointer-events: auto;
193
+ touch-action: none;
194
+ cursor: grab;
195
+
196
+ &:active {
197
+ cursor: grabbing;
198
+ }
199
+ }
200
+
201
+ .documint-selection-handle-start {
202
+ transform: translate(-70%, -82%);
203
+ }
204
+
205
+ .documint-selection-handle-end {
206
+ transform: translate(-30%, -39%);
207
+ }
208
+
209
+ .documint-selection-handle-knob {
210
+ position: absolute;
211
+ inset: 0;
212
+ display: block;
213
+ border: 2px solid var(--documint-selection-handle-border);
214
+ border-radius: 999px;
215
+ background: var(--documint-selection-handle-bg);
216
+ box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
217
+ }
218
+
219
+ .documint-fallback {
220
+ max-width: 100%;
221
+ color: #0f172a;
222
+ line-height: 1.65;
223
+ white-space: normal;
224
+
225
+ & p {
226
+ margin: 0 0 0.9rem;
227
+ }
228
+
229
+ & h1,
230
+ & h2,
231
+ & h3,
232
+ & h4,
233
+ & h5,
234
+ & h6 {
235
+ margin: 0 0 0.85rem;
236
+ line-height: 1.15;
237
+ }
238
+
239
+ & h1 {
240
+ font-size: 2rem;
241
+ }
242
+
243
+ & h2 {
244
+ font-size: 1.55rem;
245
+ }
246
+
247
+ & h3 {
248
+ font-size: 1.25rem;
249
+ }
250
+
251
+ & ul,
252
+ & ol {
253
+ margin: 0 0 1rem;
254
+ padding-left: 1.4rem;
255
+ }
256
+
257
+ & li > p {
258
+ margin: 0;
259
+ }
260
+
261
+ & blockquote {
262
+ margin: 0 0 1rem;
263
+ padding-left: 1rem;
264
+ border-left: 3px solid rgba(14, 116, 144, 0.3);
265
+ color: #334155;
266
+ }
267
+
268
+ & pre {
269
+ margin: 0 0 1rem;
270
+ padding: 0.9rem 1rem;
271
+ overflow: auto;
272
+ border-radius: 0.85rem;
273
+ background: #0f172a;
274
+ color: #e2e8f0;
275
+ }
276
+
277
+ & table {
278
+ width: 100%;
279
+ margin: 0 0 1rem;
280
+ border-collapse: collapse;
281
+ }
282
+
283
+ & td {
284
+ padding: 0.45rem 0.55rem;
285
+ border: 1px solid rgba(148, 163, 184, 0.35);
286
+ }
287
+
288
+ & a {
289
+ color: #0369a1;
290
+ }
291
+ }
292
+
293
+ .preview-rich-header {
294
+ margin: 0 0 0.35rem;
295
+ color: #9fb3c8;
296
+ font-family: "Avenir Next", "Segoe UI", sans-serif;
297
+ font-size: 0.74rem;
298
+ font-weight: 700;
299
+ letter-spacing: 0.08em;
300
+ text-transform: uppercase;
301
+ }
302
+
303
+ .preview-block-code {
304
+ margin: 0 0 1rem;
305
+ padding: 0.75rem;
306
+ border-radius: 0.9rem;
307
+ background: linear-gradient(180deg, #132033, #0f172a);
308
+ color: #e2e8f0;
309
+
310
+ & pre {
311
+ margin: 0;
312
+ padding: 0.9rem 1rem;
313
+ overflow: auto;
314
+ border-radius: 0.75rem;
315
+ background: rgba(15, 23, 42, 0.72);
316
+ }
317
+ }
318
+
319
+ .preview-block-table {
320
+ margin: 0 0 1rem;
321
+ padding: 0.75rem;
322
+ border: 1px solid rgba(14, 116, 144, 0.18);
323
+ border-radius: 0.9rem;
324
+ background: rgba(248, 250, 252, 0.96);
325
+ }
326
+
327
+ .preview-table-scroll {
328
+ overflow-x: auto;
329
+
330
+ & table {
331
+ min-width: max-content;
332
+ }
333
+ }
334
+
335
+ .preview-inline-image {
336
+ display: inline-flex;
337
+ align-items: center;
338
+ gap: 0.65rem;
339
+ max-width: min(100%, 34rem);
340
+ margin: 0 0.15rem;
341
+ padding: 0.35rem 0.55rem;
342
+ border: 1px solid rgba(14, 116, 144, 0.16);
343
+ border-radius: 999px;
344
+ background: rgba(240, 249, 255, 0.95);
345
+ vertical-align: middle;
346
+
347
+ & img {
348
+ flex: none;
349
+ width: 2.4rem;
350
+ height: 2.4rem;
351
+ object-fit: cover;
352
+ border-radius: 0.65rem;
353
+ background: rgba(148, 163, 184, 0.18);
354
+ }
355
+
356
+ & > span {
357
+ display: grid;
358
+ min-width: 0;
359
+ }
360
+
361
+ & strong {
362
+ color: #0f172a;
363
+ font-family: "Avenir Next", "Segoe UI", sans-serif;
364
+ font-size: 0.88rem;
365
+ }
366
+
367
+ & small {
368
+ overflow: hidden;
369
+ color: #475569;
370
+ font-family: "Avenir Next", "Segoe UI", sans-serif;
371
+ font-size: 0.75rem;
372
+ text-overflow: ellipsis;
373
+ white-space: nowrap;
374
+ }
375
+ }
376
+ `;var qZ=`/* Leaf overlay styles, ordered outer → inner:
377
+ 1. Anchor — viewport positioning + hover bridge
378
+ 2. Shell — bordered container (with state and content variants)
379
+ 3. Menu — shared dropdown surface (toolbar menus, completion popover)
380
+ 4. Action — small icon buttons used throughout leaf chrome
381
+ 5. Input — textarea wrapper (cancel/save/submit positioning)
382
+ 6. Comment — comment leaf root, header, thread, replies, create chrome
383
+ 7. Link — link leaf layout
384
+ 8. Mention — inline pill rendered inside read-only leaf text
385
+
386
+ The toolbar's own styles live in \`toolbar/styles.css\`; both files are
387
+ concatenated by the editor's stylesheet assembly. */
388
+
389
+ /* -- Anchor: positioned wrapper rendered by LeafAnchor (via OverlayPortal) -- */
390
+
391
+ .documint-leaf-anchor {
392
+ --documint-leaf-anchor-bridge-height: 12px;
393
+ position: fixed;
394
+ z-index: 1000;
395
+ padding-top: var(--documint-leaf-anchor-bridge-height);
396
+ margin-top: calc(var(--documint-leaf-anchor-bridge-height) * -1);
397
+ pointer-events: auto;
398
+
399
+ &[data-selection="true"] {
400
+ --documint-leaf-anchor-bridge-height: 0px;
401
+ padding-top: 0;
402
+ margin-top: 14px;
403
+ pointer-events: none;
404
+ }
405
+ }
406
+
407
+ .documint-leaf-bridge {
408
+ width: 100%;
409
+ height: var(--documint-leaf-anchor-bridge-height);
410
+ }
411
+
412
+ /* -- Shell: bordered, themed container that holds leaf content -- */
413
+
414
+ .documint-leaf-shell {
415
+ --documint-leaf-divider-color:
416
+ color-mix(in srgb, var(--documint-leaf-border) 60%, transparent);
417
+ padding: 0.8rem;
418
+ border: 1px solid var(--documint-leaf-border);
419
+ border-radius: 0.95rem;
420
+ background: var(--documint-leaf-bg);
421
+ box-shadow: var(--documint-leaf-shadow, var(--documint-leaf-shadow-fallback));
422
+ color: var(--documint-leaf-text);
423
+ font-family: var(--documint-leaf-font-family, "Avenir Next", "Segoe UI", sans-serif);
424
+ font-size: 0.84rem;
425
+ line-height: 1.45;
426
+ pointer-events: auto;
427
+
428
+ &:has(> .documint-leaf-toolbar),
429
+ &:has(> .documint-comment-leaf-create) {
430
+ width: auto;
431
+ padding: 0.38rem 0.58rem;
432
+ }
433
+
434
+ &:has(> .documint-comment-leaf-create.is-expanded) {
435
+ padding: 0.8rem;
436
+ }
437
+
438
+ &[data-status="resolved"] {
439
+ border-color: var(--documint-leaf-resolved-border);
440
+ background: var(--documint-leaf-resolved-bg);
441
+ }
442
+
443
+ & p {
444
+ margin: 0;
445
+ }
446
+ }
447
+
448
+ /* -- Menu: shared dropdown surface (toolbar menus, completion popover) -- */
449
+
450
+ .documint-leaf-menu {
451
+ --documint-leaf-menu-border-color:
452
+ color-mix(in srgb, var(--documint-leaf-border) 88%, transparent);
453
+ --documint-leaf-menu-hover-bg:
454
+ color-mix(in srgb, var(--documint-leaf-accent) 12%, var(--documint-leaf-bg));
455
+ position: absolute;
456
+ top: calc(100% + 0.55rem);
457
+ left: 0;
458
+ display: grid;
459
+ gap: 0.2rem;
460
+ min-width: 10.5rem;
461
+ padding: 0.35rem;
462
+ border: 1px solid var(--documint-leaf-menu-border-color);
463
+ border-radius: 0.8rem;
464
+ background: var(--documint-leaf-bg);
465
+ box-shadow: var(--documint-leaf-shadow, var(--documint-leaf-shadow-fallback));
466
+ color: var(--documint-leaf-text);
467
+ font-family: var(--documint-leaf-font-family, "Avenir Next", "Segoe UI", sans-serif);
468
+ font-size: 0.84rem;
469
+ line-height: 1.45;
470
+ }
471
+
472
+ .documint-leaf-menu-item {
473
+ appearance: none;
474
+ display: inline-flex;
475
+ align-items: center;
476
+ gap: 0.36rem;
477
+ width: 100%;
478
+ padding: 0.45rem 0.55rem;
479
+ border: 0;
480
+ border-radius: 0.55rem;
481
+ background: transparent;
482
+ color: var(--documint-leaf-button-text);
483
+ cursor: pointer;
484
+ font: inherit;
485
+ line-height: 1.2;
486
+ text-align: left;
487
+
488
+ &:hover {
489
+ background: var(--documint-leaf-menu-hover-bg);
490
+ }
491
+
492
+ &:disabled {
493
+ opacity: 0.42;
494
+ cursor: default;
495
+
496
+ &:hover {
497
+ background: transparent;
498
+ }
499
+ }
500
+ }
501
+
502
+ .documint-leaf-menu-divider {
503
+ height: 1px;
504
+ margin: 0.15rem 0.2rem;
505
+ background: color-mix(in srgb, var(--documint-leaf-border) 72%, transparent);
506
+ }
507
+
508
+ /* -- Action: icon button used throughout leaf chrome -- */
509
+
510
+ .documint-leaf-action {
511
+ appearance: none;
512
+ display: inline-flex;
513
+ justify-content: center;
514
+ align-items: center;
515
+ width: auto;
516
+ height: auto;
517
+ padding: 0;
518
+ border: 0;
519
+ border-radius: 0;
520
+ background: transparent;
521
+ color: var(--documint-leaf-button-text);
522
+ cursor: pointer;
523
+ font: inherit;
524
+
525
+ &:not(.documint-leaf-action-text) {
526
+ line-height: 0;
527
+ }
528
+
529
+ &:disabled {
530
+ opacity: 0.45;
531
+ cursor: default;
532
+ }
533
+ }
534
+
535
+ .documint-leaf-action-text {
536
+ padding: 0.35rem 0.62rem;
537
+ border: 1px solid var(--documint-leaf-button-border);
538
+ border-radius: 999px;
539
+ background: var(--documint-leaf-button-bg);
540
+ }
541
+
542
+ .documint-leaf-action-danger {
543
+ color: var(--documint-leaf-accent);
544
+ }
545
+
546
+ /* -- Input: textarea (leaf-input) inside a positioning field that hosts
547
+ the absolutely-placed action buttons (cancel, save, submit). -- */
548
+
549
+ .documint-leaf-input-field {
550
+ position: relative;
551
+ width: 100%;
552
+ min-width: 0;
553
+ }
554
+
555
+ .documint-leaf-input-cancel {
556
+ position: absolute;
557
+ top: 0.7rem;
558
+ right: 0.7rem;
559
+ }
560
+
561
+ .documint-leaf-input-save,
562
+ .documint-leaf-input-submit {
563
+ position: absolute;
564
+ right: 0.7rem;
565
+ bottom: calc(0.7rem + 3px);
664
566
  }
665
567
 
666
- :where(.documint-presence-indicator:disabled) {
667
- cursor: default;
668
- opacity: 0.72;
568
+ .documint-leaf-input {
569
+ box-sizing: border-box;
570
+ width: 100%;
571
+ min-height: 4.6rem;
572
+ padding: 0.65rem 3.2rem 0.75rem 0.75rem;
573
+ border: 1px solid var(--documint-leaf-border);
574
+ border-radius: 0.75rem;
575
+ background: var(--documint-leaf-button-bg);
576
+ color: var(--documint-leaf-text);
577
+ font: inherit;
578
+ resize: none;
579
+
580
+ &::placeholder {
581
+ color: var(--documint-leaf-secondary-text);
582
+ }
669
583
  }
670
584
 
671
- :where(.documint-presence-indicator-avatar) {
672
- display: inline-grid;
673
- place-items: center;
674
- width: var(--documint-presence-indicator-size);
675
- height: var(--documint-presence-indicator-size);
676
- overflow: hidden;
677
- border-radius: 999px;
678
- background: var(--documint-presence-color);
679
- color: white;
585
+ .documint-leaf-shell[data-status="resolved"] .documint-leaf-input {
586
+ border-color: var(--documint-leaf-resolved-border);
680
587
  }
681
588
 
682
- :where(.documint-presence-indicator-image) {
683
- display: block;
684
- width: calc(100% - 2px);
685
- height: calc(100% - 2px);
686
- border-radius: inherit;
687
- object-fit: cover;
589
+ /* -- Comment leaf -- */
590
+
591
+ .documint-comment-leaf:not(.documint-comment-leaf-create),
592
+ .documint-comment-leaf-create.is-expanded {
593
+ width: var(--documint-leaf-width, min(18rem, calc(100vw - 4rem)));
688
594
  }
689
595
 
690
- :where(.documint-presence-indicator-direction) {
691
- display: inline-flex;
596
+ .documint-comment-leaf-header,
597
+ .documint-comment-leaf-actions,
598
+ .documint-comment-message-meta {
599
+ display: flex;
600
+ justify-content: space-between;
692
601
  align-items: center;
693
- height: 100%;
694
- padding: 0 0.42rem 0 0.36rem;
695
- color: var(--documint-leaf-text);
602
+ gap: 0.5rem;
696
603
  }
697
604
 
698
- :where(.documint-presence-indicator-arrow) {
699
- display: block;
605
+ .documint-comment-leaf-header {
606
+ margin-bottom: 0.7rem;
700
607
  }
701
608
 
702
- :where(.documint-selection-handle) {
703
- position: absolute;
704
- z-index: 4;
705
- width: 1.2rem;
706
- height: 1.2rem;
707
- margin: 0;
708
- padding: 0;
709
- border: 0;
710
- background: transparent;
711
- pointer-events: auto;
712
- touch-action: none;
713
- cursor: grab;
609
+ .documint-comment-leaf-link {
610
+ display: grid;
611
+ gap: 0.3rem;
612
+ margin-bottom: 0.8rem;
613
+ padding-bottom: 0.8rem;
614
+ border-bottom: 1px solid var(--documint-leaf-divider-color);
714
615
  }
715
616
 
716
- :where(.documint-selection-handle:active) {
717
- cursor: grabbing;
617
+ .documint-comment-leaf-age {
618
+ color: var(--documint-leaf-secondary-text);
619
+ font-size: 0.76rem;
718
620
  }
719
621
 
720
- :where(.documint-selection-handle-start) {
721
- transform: translate(-70%, -82%);
622
+ .documint-comment-actions {
623
+ display: flex;
624
+ gap: 0.4rem;
722
625
  }
723
626
 
724
- :where(.documint-selection-handle-end) {
725
- transform: translate(-30%, -39%);
627
+ .documint-comment-message-meta span {
628
+ color: var(--documint-leaf-secondary-text);
629
+ font-size: 0.74rem;
726
630
  }
727
631
 
728
- :where(.documint-selection-handle-knob) {
729
- position: absolute;
730
- inset: 0;
731
- display: block;
732
- border: 2px solid var(--documint-selection-handle-border);
733
- border-radius: 999px;
734
- background: var(--documint-selection-handle-bg);
735
- box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
632
+ /* Thread (scrollable list of comment messages) */
633
+
634
+ .documint-comment-thread {
635
+ display: grid;
636
+ gap: 0.75rem;
637
+ max-height: 16rem;
638
+ margin-bottom: 0.8rem;
639
+ overflow: auto;
640
+
641
+ &.is-empty {
642
+ max-height: 0;
643
+ margin-bottom: 0;
644
+ overflow: hidden;
645
+ }
736
646
  }
737
647
 
738
- :where(.documint-fallback) {
739
- max-width: 100%;
740
- color: #0f172a;
741
- line-height: 1.65;
742
- white-space: normal;
648
+ .documint-comment-message {
649
+ display: grid;
650
+ gap: 0.55rem;
651
+ padding-bottom: 0.75rem;
652
+ border-bottom: 1px solid var(--documint-leaf-divider-color);
653
+
654
+ &:last-child {
655
+ padding-bottom: 0;
656
+ border-bottom: 0;
657
+ }
743
658
  }
744
659
 
745
- :where(.documint-fallback p) {
746
- margin: 0 0 0.9rem;
660
+ .documint-comment-message-root {
661
+ transform: translateY(-8px) scaleY(0);
662
+ transform-origin: top left;
663
+ opacity: 0;
664
+ transition:
665
+ opacity 140ms ease,
666
+ transform 180ms ease;
667
+
668
+ &.is-visible {
669
+ transform: translateY(0) scaleY(1);
670
+ opacity: 1;
671
+ }
672
+
673
+ &.is-hidden {
674
+ max-height: 0;
675
+ padding-bottom: 0;
676
+ border-bottom: 0;
677
+ overflow: hidden;
678
+ }
747
679
  }
748
680
 
749
- :where(.documint-fallback h1),
750
- :where(.documint-fallback h2),
751
- :where(.documint-fallback h3),
752
- :where(.documint-fallback h4),
753
- :where(.documint-fallback h5),
754
- :where(.documint-fallback h6) {
755
- margin: 0 0 0.85rem;
756
- line-height: 1.15;
681
+ /* Reply (compose surface at the bottom of the thread) */
682
+
683
+ .documint-comment-reply {
684
+ position: relative;
685
+ display: block;
686
+ padding-top: 0.85rem;
687
+ border-top: 1px solid var(--documint-leaf-divider-color);
688
+
689
+ &.is-standalone {
690
+ padding-top: 0;
691
+ border-top: 0;
692
+
693
+ &:not(.is-visible) {
694
+ max-height: 0;
695
+ overflow: hidden;
696
+ }
697
+ }
757
698
  }
758
699
 
759
- :where(.documint-fallback h1) {
760
- font-size: 2rem;
700
+ .documint-leaf-shell[data-status="resolved"] .documint-comment-reply {
701
+ border-top-color: color-mix(in srgb, var(--documint-leaf-resolved-border) 72%, transparent);
761
702
  }
762
703
 
763
- :where(.documint-fallback h2) {
764
- font-size: 1.55rem;
704
+ /* Create chrome (the animated "add comment" toolbar that expands into a composer) */
705
+
706
+ .documint-comment-leaf-create {
707
+ --documint-comment-create-scale-duration: 180ms;
708
+ --documint-comment-create-fade-duration: 120ms;
709
+ height: auto;
710
+ padding: 0;
711
+ overflow: visible;
712
+
713
+ &.is-expanded {
714
+ & .documint-comment-leaf-create-shell {
715
+ width: 100%;
716
+ min-height: 5.5rem;
717
+
718
+ & > .documint-leaf-toolbar {
719
+ position: absolute;
720
+ inset: 0;
721
+ z-index: 1;
722
+ pointer-events: none;
723
+ }
724
+ }
725
+
726
+ & .documint-comment-leaf-create-button,
727
+ & .documint-comment-leaf-create-mark {
728
+ opacity: 0;
729
+ transform: scale(0.72);
730
+ pointer-events: none;
731
+ }
732
+
733
+ & .documint-comment-leaf-create-divider {
734
+ opacity: 0;
735
+ }
736
+
737
+ & .documint-comment-leaf-create-content {
738
+ position: relative;
739
+ z-index: 0;
740
+ opacity: 1;
741
+ transform: scale(1);
742
+ pointer-events: auto;
743
+ }
744
+ }
745
+ }
746
+
747
+ .documint-comment-leaf-create-shell {
748
+ position: relative;
749
+ display: grid;
750
+ width: max-content;
751
+ height: 100%;
752
+
753
+ & > .documint-leaf-toolbar {
754
+ position: relative;
755
+ z-index: 0;
756
+ }
765
757
  }
766
758
 
767
- :where(.documint-fallback h3) {
768
- font-size: 1.25rem;
759
+ .documint-comment-leaf-create-button {
760
+ position: relative;
761
+ z-index: 0;
762
+ display: inline-flex;
763
+ width: 1.7rem;
764
+ height: 1.7rem;
765
+ padding: 0;
766
+ line-height: 0;
767
+ opacity: 1;
768
+ transform: scale(1);
769
+ transition:
770
+ opacity var(--documint-comment-create-fade-duration) ease,
771
+ transform var(--documint-comment-create-scale-duration) ease;
769
772
  }
770
773
 
771
- :where(.documint-fallback ul),
772
- :where(.documint-fallback ol) {
773
- margin: 0 0 1rem;
774
- padding-left: 1.4rem;
774
+ .documint-comment-leaf-create-divider {
775
+ opacity: 1;
776
+ transition: opacity var(--documint-comment-create-fade-duration) ease;
775
777
  }
776
778
 
777
- :where(.documint-fallback li > p) {
778
- margin: 0;
779
+ .documint-comment-leaf-create-mark {
780
+ opacity: 1;
781
+ transition:
782
+ opacity var(--documint-comment-create-fade-duration) ease,
783
+ transform var(--documint-comment-create-scale-duration) ease;
779
784
  }
780
785
 
781
- :where(.documint-fallback blockquote) {
782
- margin: 0 0 1rem;
783
- padding-left: 1rem;
784
- border-left: 3px solid rgba(14, 116, 144, 0.3);
785
- color: #334155;
786
+ .documint-comment-leaf-create-content {
787
+ position: absolute;
788
+ top: 0;
789
+ left: 0;
790
+ right: 0;
791
+ z-index: 1;
792
+ opacity: 0;
793
+ transform: scale(0);
794
+ transform-origin: top left;
795
+ pointer-events: none;
796
+ transition:
797
+ opacity var(--documint-comment-create-fade-duration) ease,
798
+ transform var(--documint-comment-create-scale-duration) ease;
786
799
  }
787
800
 
788
- :where(.documint-fallback pre) {
789
- margin: 0 0 1rem;
790
- padding: 0.9rem 1rem;
791
- overflow: auto;
792
- border-radius: 0.85rem;
793
- background: #0f172a;
794
- color: #e2e8f0;
801
+ /* -- Link leaf -- */
802
+
803
+ .documint-link-leaf {
804
+ display: grid;
805
+ gap: 0.3rem;
806
+ min-width: 0;
807
+ width: min(16rem, calc(100vw - 4rem));
795
808
  }
796
809
 
797
- :where(.documint-fallback table) {
798
- width: 100%;
799
- margin: 0 0 1rem;
800
- border-collapse: collapse;
810
+ .documint-link-leaf-row {
811
+ display: grid;
812
+ grid-template-columns: minmax(0, 1fr) auto;
813
+ align-items: flex-start;
814
+ gap: 0.6rem;
815
+
816
+ &.is-editing {
817
+ grid-template-columns: minmax(0, 1fr);
818
+ }
819
+
820
+ & > .documint-leaf-input-field {
821
+ width: 100%;
822
+ }
801
823
  }
802
824
 
803
- :where(.documint-fallback td) {
804
- padding: 0.45rem 0.55rem;
805
- border: 1px solid rgba(148, 163, 184, 0.35);
825
+ .documint-link-leaf-actions {
826
+ display: inline-flex;
827
+ align-items: center;
828
+ gap: 0.5rem;
806
829
  }
807
830
 
808
- :where(.documint-fallback a) {
809
- color: #0369a1;
831
+ .documint-link-leaf-divider {
832
+ margin: 0.2rem 0;
833
+ border-top: 1px solid var(--documint-leaf-divider-color);
810
834
  }
811
835
 
812
- :where(.preview-rich-header) {
813
- margin: 0 0 0.35rem;
814
- color: #9fb3c8;
815
- font-family: "Avenir Next", "Segoe UI", sans-serif;
816
- font-size: 0.74rem;
817
- font-weight: 700;
818
- letter-spacing: 0.08em;
819
- text-transform: uppercase;
836
+ .documint-link-leaf-title {
837
+ color: var(--documint-leaf-text);
838
+ font-size: 0.78rem;
839
+ font-weight: 600;
820
840
  }
821
841
 
822
- :where(.preview-block-code) {
823
- margin: 0 0 1rem;
824
- padding: 0.75rem;
825
- border-radius: 0.9rem;
826
- background: linear-gradient(180deg, #132033, #0f172a);
827
- color: #e2e8f0;
842
+ .documint-link-leaf-url {
843
+ min-width: 0;
844
+ color: var(--documint-leaf-secondary-text);
845
+ font-size: 0.76rem;
846
+ line-height: 1.4;
847
+ overflow-wrap: anywhere;
828
848
  }
829
849
 
830
- :where(.preview-block-code pre) {
831
- margin: 0;
832
- padding: 0.9rem 1rem;
833
- overflow: auto;
834
- border-radius: 0.75rem;
835
- background: rgba(15, 23, 42, 0.72);
850
+ .documint-link-leaf-hint {
851
+ color: var(--documint-leaf-secondary-text);
852
+ font-size: 0.74rem;
853
+ font-style: italic;
836
854
  }
837
855
 
838
- :where(.preview-block-table) {
839
- margin: 0 0 1rem;
840
- padding: 0.75rem;
841
- border: 1px solid rgba(14, 116, 144, 0.18);
842
- border-radius: 0.9rem;
843
- background: rgba(248, 250, 252, 0.96);
856
+ /* -- Completion popover (uses .documint-leaf-menu for visual base) -- */
857
+
858
+ .documint-completion-popover {
859
+ z-index: 1100;
860
+ min-width: 12rem;
844
861
  }
845
862
 
846
- :where(.preview-table-scroll) {
847
- overflow-x: auto;
863
+ .documint-completion-item {
864
+ white-space: nowrap;
865
+ overflow: hidden;
866
+ text-overflow: ellipsis;
867
+
868
+ &.is-active {
869
+ background: var(--documint-leaf-menu-hover-bg);
870
+ }
848
871
  }
849
872
 
850
- :where(.preview-table-scroll table) {
851
- min-width: max-content;
873
+ /* -- Mention: inline pill rendered inside read-only leaf text -- */
874
+
875
+ .documint-mention {
876
+ padding: 0.05em 0.3em;
877
+ border-radius: 0.4em;
878
+ background: var(
879
+ --documint-mention-bg,
880
+ color-mix(in srgb, var(--documint-leaf-accent) 14%, transparent)
881
+ );
882
+ color: var(--documint-mention-text, var(--documint-leaf-accent));
883
+ font-weight: 500;
884
+ white-space: nowrap;
852
885
  }
886
+ `;var UZ=`/* Toolbar-specific styles (button, group, divider, and the menu trigger
887
+ shell + chevron). The menu container/item/divider styles themselves
888
+ live one level up in \`overlays/leaves/styles.css\` as \`.documint-leaf-menu*\`
889
+ so they can be shared by the toolbar's nested menu and other surfaces
890
+ (e.g. the completion popover in LeafInput). */
853
891
 
854
- :where(.preview-inline-image) {
892
+ .documint-leaf-toolbar {
893
+ --documint-leaf-toolbar-button-active-bg:
894
+ color-mix(in srgb, var(--documint-leaf-accent) 16%, var(--documint-leaf-bg));
895
+ --documint-leaf-toolbar-divider-color:
896
+ color-mix(in srgb, var(--documint-leaf-border) 72%, transparent);
855
897
  display: inline-flex;
856
898
  align-items: center;
857
- gap: 0.65rem;
858
- max-width: min(100%, 34rem);
859
- margin: 0 0.15rem;
860
- padding: 0.35rem 0.55rem;
861
- border: 1px solid rgba(14, 116, 144, 0.16);
862
- border-radius: 999px;
863
- background: rgba(240, 249, 255, 0.95);
864
- vertical-align: middle;
899
+ gap: 0.52rem;
865
900
  }
866
901
 
867
- :where(.preview-inline-image img) {
868
- flex: none;
869
- width: 2.4rem;
870
- height: 2.4rem;
871
- object-fit: cover;
872
- border-radius: 0.65rem;
873
- background: rgba(148, 163, 184, 0.18);
902
+ .documint-leaf-toolbar-group {
903
+ display: inline-flex;
904
+ align-items: center;
905
+ gap: 0.38rem;
874
906
  }
875
907
 
876
- :where(.preview-inline-image > span) {
877
- display: grid;
878
- min-width: 0;
908
+ .documint-leaf-toolbar-divider {
909
+ width: 1px;
910
+ height: 1.15rem;
911
+ background: var(--documint-leaf-toolbar-divider-color);
879
912
  }
880
913
 
881
- :where(.preview-inline-image strong) {
882
- color: #0f172a;
883
- font-family: "Avenir Next", "Segoe UI", sans-serif;
884
- font-size: 0.88rem;
914
+ .documint-leaf-toolbar-button {
915
+ appearance: none;
916
+ display: inline-flex;
917
+ justify-content: center;
918
+ align-items: center;
919
+ gap: 0.36rem;
920
+ min-width: 1.45rem;
921
+ height: 1.45rem;
922
+ padding: 0 0.12rem;
923
+ border: 0;
924
+ border-radius: 0.38rem;
925
+ background: transparent;
926
+ color: var(--documint-leaf-button-text);
927
+ cursor: pointer;
928
+ font: inherit;
929
+ line-height: 0;
930
+ transition:
931
+ background-color 120ms ease,
932
+ color 120ms ease;
933
+
934
+ &:hover {
935
+ background: var(--documint-leaf-toolbar-button-active-bg);
936
+ }
937
+
938
+ &.active {
939
+ background: var(--documint-leaf-toolbar-button-active-bg);
940
+ color: var(--documint-leaf-text);
941
+ }
942
+
943
+ &:disabled {
944
+ opacity: 0.42;
945
+ cursor: default;
946
+
947
+ &:hover {
948
+ background: transparent;
949
+ }
950
+ }
885
951
  }
886
952
 
887
- :where(.preview-inline-image small) {
888
- overflow: hidden;
889
- color: #475569;
890
- font-family: "Avenir Next", "Segoe UI", sans-serif;
891
- font-size: 0.75rem;
892
- text-overflow: ellipsis;
893
- white-space: nowrap;
953
+ .documint-leaf-toolbar-menu-shell {
954
+ position: relative;
955
+
956
+ & .documint-leaf-toolbar-button {
957
+ gap: 0.18rem;
958
+ }
894
959
  }
895
960
 
896
- ${mJ}
897
- `;import{jsxDEV as Y1,Fragment as IG}from"react/jsx-dev-runtime";var gG=2,gJ={activeBlockType:null,activeCommentThreadIndex:null,activeSpanKind:null,canonicalContent:"",characterCount:0,commentThreadCount:0,layoutWidth:0,resolvedCommentCount:0,selectionFrom:0,selectionTo:0};function pJ({className:$,content:M,keybindings:J,onContentChange:Z,onStateChange:X,presence:A,theme:Y}){let Q=y1(null),K=y1(null),q=y1(null),N=y1(null),U=y1(null),G=y1(null),B=y1(null),D=y1(null),F=y1(!1),H=y1(M),b=y1(""),E=y1(gJ),V=y1(null),[R,O]=MM(!1),{theme:j,themeStyles:f}=CJ(Y),[z,y]=MM(gJ),T=f0(()=>C$(M),[M]),W=f0(()=>i5(T),[T]),[_,C]=MM(()=>d2(T)),g=XJ(_.documentIndex.document),u=f0(()=>[...g?.images.values()??[]].some((P)=>P.status==="loading"),[g]);U.current=_,b.current||=W;let d=wJ({editorState:_,editorStateRef:U,renderResources:g,theme:j}),{actions:p,props:J1,refs:k,state:S}=d,{getScrollTop:m,observePreparedViewport:Z1,observeScrollContainer:t,resolvePointerPoint:N1,scrollTo:v1}=p,{layoutWidth:g1,preparedViewport:A1,scrollContentHeight:S4,surfaceWidth:Q6,viewportHeight:u0,viewportTop:m4}=S,{scrollContainer:i1}=k,v4=f0(()=>g2(_),[_]),h1=f0(()=>f1(_),[_]),V1=f0(()=>n(_),[_]),g4=f0(()=>IJ(_,h1.liveRanges),[h1.liveRanges,_]),B2=Boolean(Z),e=()=>U.current??_,z1=B1((P,w)=>{let v=g2(P),c=f1(P),r=GJ(P),o={activeBlockType:v.block?.nodeType??null,activeCommentThreadIndex:IJ(P,c.liveRanges),activeSpanKind:v.span.kind==="none"?null:v.span.kind,canonicalContent:w,characterCount:w.length,commentThreadCount:c.threads.length,layoutWidth:g1,resolvedCommentCount:O6(c.threads),selectionFrom:r.start,selectionTo:r.end};if(y((l1)=>i$(l1,o)?l1:o),!i$(E.current,o))E.current=o,X?.(o)}),i=B1((P)=>{if(!P)return;let w=U.current??_,v=w.documentIndex!==P.documentIndex,c=w5(w,P);U.current=P,C(P);let r=A1.current;if(!(!v||!r||r.layout.regionLineIndices.has(P.selection.focus.regionId)))A1.invalidate();if(c)O1("viewport");if(!v)return;let l1=a2(P),D2=i5(l1);b.current=D2,H.current=D2,Z?.(D2,l1)}),JM=B1((P=A1.current)=>{if(!P)return;let w=s$(K.current,{paintHeight:P.paintHeight,paintTop:P.paintTop,width:g1});if(!w)return;let{context:v,devicePixelRatio:c,height:r,width:o}=w;F$(_,P,v,{activeBlockId:v4.block?.blockId??null,activeRegionId:_.selection.focus.regionId,activeThreadIndex:XM??g4,devicePixelRatio:c,height:r,liveCommentRanges:h1.liveRanges,normalizedSelection:V1,now:performance.now(),resources:g,theme:j,width:o})}),ZM=B1((P=A1.current)=>{if(!P)return;let w=s$(q.current,{paintHeight:P.paintHeight,paintTop:P.paintTop,width:g1});if(!w)return;let{context:v,devicePixelRatio:c,height:r,width:o}=w;D$(_,P,v,{devicePixelRatio:c,height:r,normalizedSelection:V1,presence:K6.canvasPresence,showCaret:V1.start.regionId!==V1.end.regionId||V1.start.offset!==V1.end.offset||o1.isVisible(),theme:j,width:o})}),lJ=B1(()=>{A1.invalidate();let P=A1.get();Z1(P),K6.refreshViewportPresence(P),JM(P),ZM(P)}),{scheduleRender:O1}=WJ({hasRunningAnimations:()=>z8(U.current??_,performance.now()),renderContent:JM,renderOverlay:ZM,renderViewport:lJ}),rJ=J1.getScrollContainer({onScroll:()=>O1("viewport")}),o1=JJ({canShowInsertionLeaf:Boolean(Z),canShowTableLeaf:Boolean(Z),commentState:h1,editorState:_,editorViewportState:A1,onVisibilityChange:()=>O1("overlay")}),L1=QJ({commentState:h1,editorStateRef:U,editorViewportState:A1,resolveDocumentPoint:N1}),XM=L1.leaf?.kind==="comment"?L1.leaf.threadIndex:null,cJ=B1((P)=>{t(P),O1("viewport")}),K6=PJ({editorState:_,editorStateRef:U,editorViewportState:A1,onViewportScroll:cJ,presence:A,scrollContainerRef:i1,scheduleOverlayRender:()=>O1("overlay")}),AM=B1((P,w)=>{if(P.scrollHeight<=P.clientHeight||w.deltaY===0)return;let v=24,c=w.deltaMode===1?v:w.deltaMode===2?P.clientHeight:1,r=Math.max(0,Math.min(P.scrollHeight-P.clientHeight,P.scrollTop+w.deltaY*c));if(r===P.scrollTop)return;w.preventDefault(),v1(r),O1("viewport")}),F2=DJ({editorState:_,editorStateRef:U,editorViewportState:A1,inputRef:N,keybindings:J,onActivity:o1.markActivity,onEditorStateChange:i}),I1=VJ({autoScrollContainer:(P)=>{I$(i1.current,P)},canShowSelectionLeaf:B2,canvasRef:K,threads:h1.threads,editorState:_,editorStateRef:U,scrollContainerRef:i1,editorViewportState:A1,onActivity:o1.markActivity,onEditorStateChange:i}),xJ=B1(()=>{K.current?.focus({preventScroll:!0})}),YM=B1((P)=>{let w=K.current;if(w&&G.current===P)w.releasePointerCapture(P)}),QM=B1(()=>{G.current=null,B.current=null}),dJ=B1((P)=>{YM(P.pointerId),QM(),D.current=null,F.current=!1}),aJ=B1((P)=>{let w=K.current,v=e(),c=N1(P);if(!c)return;let r=L1.resolveTarget(P);if(r?.kind==="task-toggle"){P.preventDefault(),P.stopPropagation(),D.current=r.listItemId,o1.markActivity(),xJ();return}let o=t6(v,A1.get(),c);if(!w||!o)return;G.current=P.pointerId,B.current={offset:o.offset,regionId:o.regionId},o1.markActivity(),w.setPointerCapture(P.pointerId),i(K1(v,{offset:o.offset,regionId:o.regionId})),F2.focus({offset:o.offset,regionId:o.regionId})}),sJ=B1(()=>{L1.canvasHandlers.onPointerLeave(),F.current=!1}),iJ=B1((P)=>{let w=B.current,v=e(),c=N1(P);if(!c)return;if(L1.canvasHandlers.onPointerMove(P),G.current!==P.pointerId||!w)return;let r=R2(v,A1.get(),c,w);if(!r)return;o1.markActivity(),I$(i1.current,P),i(K1(v,{anchor:w,focus:r}))}),oJ=B1((P)=>{let w=e();if(YM(P.pointerId),D.current){let v=t8(w,D.current);if(D.current=null,v)F.current=!0,P.preventDefault(),P.stopPropagation(),o1.markActivity(),i(v)}QM()}),nJ=B1((P)=>{if(F.current){F.current=!1,D.current=null,P.preventDefault(),P.stopPropagation();return}if(L1.canvasHandlers.onClick(P))return;D.current=null,F2.focus()}),tJ=B1((P)=>{let w=e(),v=N1(P),c=L1.resolveTarget(P);if(!v||c?.kind==="task-toggle")return;let r=e6(w,A1.get(),v);if(!r)return;P.preventDefault(),P.stopPropagation(),o1.markActivity(),i(K1(w,r)),F2.focus()});k0(()=>{O(!0)},[]),vG(()=>{if(M===H.current)return;let P=U.current,w=fJ(P,d2(T)),v=w.state,c=w.didReconcile?m():0;U.current=v,C(v),H.current=M,b.current=W,v1(c)},[W,M,T,m,v1]),k0(()=>{z1(_,b.current||W)},[W,_,z1,Q6]),k0(()=>{let P=i1.current,w=_.selection.focus;if(!P)return;let v={layoutWidth:g1,offset:w.offset,regionId:w.regionId,scrollContentHeight:S4,viewportHeight:u0};if(hG(V.current,v))return;let c=24,r=J8(_,A1.get(),w);if(!r)return;let o=u0,l1=P.scrollTop,D2=l1+c,XZ=l1+o-c;if(r.top<D2){let q6=v1(Math.max(0,r.top-c));if(hJ(r,q6,o,c))V.current=v;return}if(r.top+r.height>XZ){let q6=v1(Math.max(0,r.top+r.height-o+c));if(hJ(r,q6,o,c))V.current=v;return}V.current=v},[_,_.selection.focus.offset,_.selection.focus.regionId,A1,g1,S4,v1,u0]),k0(()=>{O1("viewport")},[h1.liveRanges,_,g1,V1.end.regionId,V1.end.offset,V1.start.regionId,V1.start.offset,v4.block?.blockId,j,g,g4,O1,u0]),k0(()=>{if(!u)return;let P=null,w=window,v=()=>{O1("viewport"),P=w.requestAnimationFrame(v)};return P=w.requestAnimationFrame(v),()=>{if(P!==null)w.cancelAnimationFrame(P)}},[u,O1]),k0(()=>{O1("content")},[XM,O1]),k0(()=>{let P=i1.current;if(!P)return;let w=(v)=>{AM(P,v)};return P.addEventListener("wheel",w,{passive:!1}),()=>{P.removeEventListener("wheel",w)}},[AM]);let eJ=$?`documint ${$}`:"documint",$Z=()=>{let P=L1.leaf,w=P??I1.leaf??o1.leaf,v=!P&&Boolean(I1.leaf),c=i1.current?.getBoundingClientRect()??null,r=w?.kind==="thread"?{...w,thread:h1.threads[w.threadIndex]??null}:null,o=w?.kind==="comment"?{animateInitialComment:!1,link:w.link,thread:w.thread,threadIndex:w.threadIndex}:r?.thread?{animateInitialComment:r.animateInitialComment??!1,link:null,thread:r.thread,threadIndex:r.threadIndex}:null,l1=o?.thread&&A0(o.thread)?"resolved":"default";return{annotationThreadLeaf:o,visibleLeaf:w,visibleLeafAnchor:w?{container:Q.current,isSelection:v,left:(c?.left??0)+w.left,onPointerEnter:P?L1.leafHandlers.onPointerEnter:void 0,onPointerLeave:P?L1.leafHandlers.onPointerLeave:void 0,top:(c?.top??0)+w.top-m4+(v?gG:0)}:void 0,visibleLeafClassName:w?.kind==="link"?"documint-link-leaf":void 0,visibleLeafStatus:l1}},{annotationThreadLeaf:p1,visibleLeaf:_1,visibleLeafAnchor:KM,visibleLeafClassName:MZ,visibleLeafStatus:JZ}=$Z(),ZZ=(()=>{if(!_1)return null;switch(_1.kind){case"insertion":return Y1(a7,{onInsert:(P)=>{i(Y2(e(),P))},onInsertTable:(P)=>{i(r8(e(),P))}},void 0,!1,void 0,this);case"table":return Y1(e7,{canDeleteColumn:_1.columnCount>1,canDeleteRow:_1.rowCount>1,onDeleteColumn:()=>{i(x8(e()))},onDeleteRow:()=>{i(a8(e()))},onDeleteTable:()=>{i(s8(e()))},onInsertColumn:(P)=>{i(c8(e(),P))},onInsertRow:(P)=>{i(d8(e(),P))}},void 0,!1,void 0,this);case"link":return Y1(n7,{canEdit:B2,onDelete:()=>{let P=n8(e(),_1.regionId,_1.startOffset,_1.endOffset);if(P)i(P)},onSave:(P)=>{let w=o8(e(),_1.regionId,_1.startOffset,_1.endOffset,P);if(w)i(w)},title:_1.title,url:_1.url},void 0,!1,void 0,this);case"create":return Y1(k$,{activeMarks:_1.activeMarks,canEdit:B2,link:null,mode:"create",onCreateThread:(P)=>{let w=e(),v=a2(w).comments.length,c=e8(w,_1.selection,P.trim());if(!c)return;i(c),I1.promoteLeafToThread(v,!0)},onToggleBold:()=>{i(M4(e()))},onToggleItalic:()=>{i(J4(e()))},onToggleStrikethrough:()=>{i(Z4(e()))},onToggleUnderline:()=>{i(X4(e()))}},void 0,!1,void 0,this);default:return p1?Y1(k$,{animateInitialComment:p1.animateInitialComment,canEdit:B2,link:p1.link,mode:"thread",onDeleteComment:(P)=>{i(J$(e(),p1.threadIndex,P))},onDeleteThread:()=>{i(Z$(e(),p1.threadIndex))},onEditComment:(P,w)=>{i(M$(e(),p1.threadIndex,P,w))},onReply:(P)=>{i($$(e(),p1.threadIndex,P))},onToggleResolved:()=>{i(X$(e(),p1.threadIndex,!A0(p1.thread)))},thread:p1.thread},void 0,!1,void 0,this):null}})();return Y1("section",{className:eJ,"data-active-block":z.activeBlockType??"","data-active-comment-thread":z.activeCommentThreadIndex??"","data-active-span":z.activeSpanKind??"",ref:Q,style:{...f,height:"100%",minHeight:0},children:[Y1("style",{children:vJ},void 0,!1,void 0,this),Y1("div",{...rJ,className:"documint-scroll-container",style:{height:"100%",minHeight:0},children:[Y1("textarea",{...F2.inputHandlers,ref:N,autoCapitalize:"sentences",className:"documint-input",spellCheck:!1,tabIndex:-1},void 0,!1,void 0,this),Y1(Q7,{insetX:j.paddingX,insetY:j.paddingY,...K6.presenceOverlayProps},void 0,!1,void 0,this),Y1("div",{...J1.scrollContent,className:"documint-scroll-content",children:[Y1("canvas",{...F2.canvasHandlers,"aria-label":"Documint editor",className:"documint-content-canvas",style:{cursor:L1.cursor},onPointerCancel:dJ,onPointerDown:aJ,onPointerLeave:sJ,onPointerMove:iJ,onPointerUp:oJ,onClick:nJ,onDoubleClick:tJ,ref:K,tabIndex:0},void 0,!1,void 0,this),Y1("canvas",{"aria-hidden":"true",className:"documint-overlay-canvas",ref:q},void 0,!1,void 0,this),I1.handles?Y1(IG,{children:[Y1("div",{"aria-hidden":"true",className:"documint-selection-handle documint-selection-handle-start",style:{left:`${I1.handles.start.left}px`,top:`${I1.handles.start.top}px`},...I1.startHandleProps,children:Y1("span",{className:"documint-selection-handle-knob"},void 0,!1,void 0,this)},void 0,!1,void 0,this),Y1("div",{"aria-hidden":"true",className:"documint-selection-handle documint-selection-handle-end",style:{left:`${I1.handles.end.left}px`,top:`${I1.handles.end.top}px`},...I1.endHandleProps,children:Y1("span",{className:"documint-selection-handle-knob"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,_1&&KM?Y1(s7,{anchor:KM,className:MZ,status:JZ,children:ZZ},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),!R?Y1("div",{className:"documint-fallback",children:Y1(A6,{blocks:T.blocks},void 0,!1,void 0,this)},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function hG($,M){return $?.layoutWidth===M.layoutWidth&&$.regionId===M.regionId&&$.offset===M.offset&&$.scrollContentHeight===M.scrollContentHeight&&$.viewportHeight===M.viewportHeight}function hJ($,M,J,Z){return $.top>=M+Z&&$.top+$.height<=M+J-Z}function IJ($,M){let J=new Map($.documentIndex.regions.map((K,q)=>[K.id,q])),Z=Y6(J,$.selection.anchor.regionId,$.selection.anchor.offset),X=Y6(J,$.selection.focus.regionId,$.selection.focus.offset),[A,Y]=Z<=X?[Z,X]:[X,Z],Q=Z===X;for(let K of M){let q=Y6(J,K.regionId,K.startOffset),N=Y6(J,K.regionId,K.endOffset);if(Q){if(A>=q&&A<=N)return K.threadIndex;continue}if(Math.max(A,q)<Math.min(Y,N))return K.threadIndex}return null}function Y6($,M,J){return($.get(M)??-1)*1e6+J}export{zJ as mintTheme,OJ as midnightTheme,f4 as lightTheme,v$ as defaultKeybindings,u4 as darkTheme,pJ as Documint};
961
+ .documint-leaf-toolbar-menu-chevron {
962
+ transition: transform 140ms ease;
963
+
964
+ &.is-open {
965
+ transform: rotate(180deg);
966
+ }
967
+ }
968
+ `;var NZ=`${KZ}
969
+ ${qZ}
970
+ ${UZ}`;import{jsx as K0,jsxs as B8,Fragment as jV}from"react/jsx-runtime";var CV=2,AZ={activeBlockType:null,activeCommentThreadIndex:null,activeSpanKind:null,canonicalContent:"",characterCount:0,commentThreadCount:0,layoutWidth:0,resolvedCommentCount:0,selectionFrom:0,selectionTo:0};function GZ({className:$,content:M,keybindings:J,onCommentChanged:Z,onContentChanged:X,onStateChanged:D,presence:Y,theme:Q,users:K}){let q=L1(null),U=L1(null),N=L1(null),A=L1(null),V=L1(M),B=L1(""),G=L1(AZ),[b,P]=H$(!1),{theme:y,themeStyles:z}=$Z(Q),[L,R]=H$(AZ),m=$1(()=>h3(M),[M]),E=$1(()=>X8(m),[m]),[_,j]=H$(()=>o2(m)),C=RJ(_.documentIndex.document),W=$1(()=>[...C?.images.values()??[]].some((w)=>w.status==="loading"),[C]);A.current=_,B.current||=E;let F=ZZ({editorState:_,editorStateRef:A,renderResources:C,theme:y}),{actions:H,props:v,refs:h,state:l}=F,{autoScrollDuringDrag:p,getScrollTop:O,observePreparedViewport:T,observeScrollContainer:k,prepareNextPaint:f,reconcileEditorState:d,resolvePoint:I,scrollTo:U0}=H,{layoutWidth:z0,preparedViewport:_0,scrollContentHeight:R1,surfaceWidth:F8,viewportHeight:p4,viewportTop:_8}=l,{scrollContainer:l4}=h,r4=$1(()=>l2(_),[_]),O0=$1(()=>L0(_),[_]),W0=$1(()=>n(_),[_]),k1=$1(()=>{if(!K?.length)return;return[{trigger:"@",items:K.map((w)=>({label:w.fullName??w.username,id:w.id}))}]},[K]),b8=$1(()=>DZ(K,Y),[K,Y]),c4=$1(()=>VZ(_,O0.liveRanges),[O0.liveRanges,_]),f1=Boolean(X),J0=()=>A.current??_,x4=F2((w,S)=>{let g=l2(w),i=L0(w),e=hJ(w),Z0={activeBlockType:g.block?.nodeType??null,activeCommentThreadIndex:VZ(w,i.liveRanges),activeSpanKind:g.span.kind==="none"?null:g.span.kind,canonicalContent:S,characterCount:S.length,commentThreadCount:i.threads.length,layoutWidth:z0,resolvedCommentCount:h8(i.threads),selectionFrom:e.start,selectionTo:e.end};if(R((i4)=>G$(i4,Z0)?i4:Z0),!G$(G.current,Z0))G.current=Z0,D?.(Z0)}),a=F2((w)=>{if(!w)return;let S=A.current??_,g=S.documentIndex!==w.documentIndex,i=v5(S,w);if(A.current=w,j(w),d(S,w),i)H8();if(!g)return;let e=I0(w),Z0=X8(e);B.current=Z0,V.current=Z0,X?.(Z0,e)}),_2=(w)=>{Z?.(w)},P$=(w)=>{let S=I0(J0()).comments[w],g=S?.comments.at(-1);if(!S||!g)return;_2({kind:"added",comment:g,mentionedUserIds:x3(g.body,k1),thread:S,threadIndex:w})},BZ=(w,S,g)=>{let i=I0(J0()).comments[w],e=i?.comments[S];if(!i||!e)return;_2({kind:"edited",comment:e,previousBody:g,mentionedUserIds:x3(e.body,k1),thread:i,threadIndex:w})},z$=(w,S,g)=>{_2({kind:"deleted",comment:g,thread:S,threadIndex:w})},W$=F2((w=_0.peek())=>{if(!w)return;let S=V$(q.current,{paintHeight:w.paintHeight,paintTop:w.paintTop,width:z0});if(!S)return;let{context:g,devicePixelRatio:i,height:e,width:Z0}=S;w3(_,w,g,{activeBlockId:r4.block?.blockId??null,activeRegionId:_.selection.focus.regionId,activeThreadIndex:w$??c4,devicePixelRatio:i,height:e,liveCommentRanges:O0.liveRanges,normalizedSelection:W0,now:performance.now(),resources:C,theme:y,width:Z0})}),E$=F2((w=_0.peek())=>{if(!w)return;let S=V$(U.current,{paintHeight:w.paintHeight,paintTop:w.paintTop,width:z0});if(!S)return;let{context:g,devicePixelRatio:i,height:e,width:Z0}=S;O3(_,w,g,{devicePixelRatio:i,height:e,normalizedSelection:W0,presence:a4.presence,showCaret:W0.start.regionId!==W0.end.regionId||W0.start.offset!==W0.end.offset||b2.isVisible(),theme:y,width:Z0})}),FZ=F2(()=>{let w=f();T(w),a4.refreshPresence(w),W$(w),E$(w)}),{scheduleContentPaint:H8,scheduleFullPaint:T$,scheduleFullRender:m1,scheduleOverlayPaint:y$}=aJ({editorStateRef:A,renderContent:W$,renderOverlay:E$,renderViewport:FZ}),_Z=v.getScrollContainer({onScroll:()=>m1()}),b2=LJ({canShowInsertionLeaf:Boolean(X),canShowTableLeaf:Boolean(X),commentState:O0,editorState:_,editorViewportState:_0,getScrollTop:O,layoutWidth:z0,onVisibilityChange:y$,scrollContentHeight:R1,scrollTo:U0,viewportHeight:p4}),d4=cJ({applyNextState:a,editorState:_,editorStateRef:A,editorViewportState:_0,inputRef:N,keybindings:J,onActivity:b2.markActivity}),H1=fJ({applyNextState:a,autoScrollDuringDrag:p,canvasRef:q,commentState:O0,editorStateRef:A,editorViewportState:_0,focusInput:d4.focus,onActivity:b2.markActivity,readCurrentState:J0,resolvePoint:I}),w$=H1.leaf?.kind==="comment"?H1.leaf.threadIndex:null,bZ=F2((w)=>{k(w),m1()}),a4=dJ({editorState:_,editorStateRef:A,editorViewportState:_0,onViewportScroll:bZ,scrollContainerRef:l4,scheduleOverlayRender:y$,userPresence:b8}),f0=oJ({applyNextState:a,autoScrollDuringDrag:p,canShowSelectionLeaf:f1,editorState:_,editorStateRef:A,editorViewportState:_0,focusInput:d4.focus,onActivity:b2.markActivity,resolvePoint:I,threads:O0.threads});B2(()=>{m1()},[_.documentIndex,z0,y,C,m1,p4]),B2(()=>{T$()},[W0.end.offset,W0.end.regionId,W0.start.offset,W0.start.regionId,T$,r4.block?.blockId]),B2(()=>{H8()},[c4,O0.liveRanges,w$,H8]),B2(()=>{if(!W)return;let w=null,S=window,g=()=>{m1(),w=S.requestAnimationFrame(g)};return w=S.requestAnimationFrame(g),()=>{if(w!==null)S.cancelAnimationFrame(w)}},[W,m1]);let HZ=()=>{let w=H1.leaf,S=w??f0.leaf??b2.leaf,g=!w&&Boolean(f0.leaf),i=l4.current?.getBoundingClientRect()??null,e=S?.kind==="thread"?{...S,thread:O0.threads[S.threadIndex]??null}:null,Z0=S?.kind==="comment"?{animateInitialComment:!1,link:S.link,thread:S.thread,threadIndex:S.threadIndex}:e?.thread?{animateInitialComment:e.animateInitialComment??!1,link:null,thread:e.thread,threadIndex:e.threadIndex}:null,i4=Z0?.thread&&Z1(Z0.thread)?"resolved":"default";return{annotationThreadLeaf:Z0,visibleLeaf:S,visibleLeafAnchor:S?{isSelection:g,left:(i?.left??0)+S.left,onPointerEnter:w?H1.leafHandlers.onPointerEnter:void 0,onPointerLeave:w?H1.leafHandlers.onPointerLeave:void 0,top:(i?.top??0)+S.top-_8+(g?CV:0)}:void 0,visibleLeafStatus:i4}},{annotationThreadLeaf:m0,visibleLeaf:G0,visibleLeafAnchor:O$,visibleLeafStatus:PZ}=HZ(),zZ=(()=>{if(!G0)return null;switch(G0.kind){case"insertion":return K0(PJ,{onInsert:(w)=>{a(Y2(J0(),w))},onInsertTable:(w)=>{a(M3(J0(),w))}});case"table":return K0(wJ,{canDeleteColumn:G0.columnCount>1,canDeleteRow:G0.rowCount>1,onDeleteColumn:()=>{a(Z3(J0()))},onDeleteRow:()=>{a(D3(J0()))},onDeleteTable:()=>{a(Y3(J0()))},onInsertColumn:(w)=>{a(J3(J0(),w))},onInsertRow:(w)=>{a(X3(J0(),w))}});case"link":return K0(TJ,{canEdit:f1,onDelete:()=>{let w=q3(J0(),G0.regionId,G0.startOffset,G0.endOffset);if(w)a(w)},onSave:(w)=>{let S=K3(J0(),G0.regionId,G0.startOffset,G0.endOffset,w);if(S)a(S)},title:G0.title,url:G0.url});case"create":return K0(o3,{activeMarks:G0.activeMarks,canEdit:f1,link:null,mode:"create",mentionSources:k1,onCreateThread:(w)=>{let S=J0(),g=I0(S).comments.length,i=N3(S,G0.selection,w.trim());if(!i)return;a(i),f0.promoteLeafToThread(g,!0),P$(g)},onToggleBold:()=>{a(X4(J0()))},onToggleItalic:()=>{a(D4(J0()))},onToggleStrikethrough:()=>{a(Y4(J0()))},onToggleUnderline:()=>{a(Q4(J0()))}});default:return m0?K0(o3,{animateInitialComment:m0.animateInitialComment,canEdit:f1,link:m0.link,mode:"thread",mentionSources:k1,onDeleteComment:(w)=>{let{threadIndex:S}=m0,g=J0(),i=I0(g).comments[S],e=i?.comments[w],Z0=G3(g,S,w);if(!Z0)return;if(a(Z0),i&&e)z$(S,i,e)},onDeleteThread:()=>{let{threadIndex:w}=m0,S=J0(),g=I0(S).comments[w],i=B3(S,w);if(!i)return;if(a(i),g)for(let e of g.comments)z$(w,g,e)},onEditComment:(w,S)=>{let{threadIndex:g}=m0,i=J0(),e=I0(i).comments[g]?.comments[w]?.body,Z0=V3(i,g,w,S);if(!Z0)return;if(a(Z0),e!==void 0)BZ(g,w,e)},onReply:(w)=>{let{threadIndex:S}=m0,g=A3(J0(),S,w);if(!g)return;a(g),P$(S)},onToggleResolved:()=>{a(F3(J0(),m0.threadIndex,!Z1(m0.thread)))},thread:m0.thread}):null}})();B2(()=>{P(!0)},[]),B2(()=>{x4(_,B.current||E)},[E,_,x4,F8]),OV(()=>{if(M===V.current)return;let w=A.current,S=QZ(w,o2(m)),g=S.state,i=S.didReconcile?O():0;A.current=g,j(g),V.current=M,B.current=E,U0(i)},[E,M,m,O,U0]);let WZ=$?`documint ${$}`:"documint";return K0(ZJ,{themeStyles:z,children:B8("section",{className:WZ,"data-active-block":L.activeBlockType??"","data-active-comment-thread":L.activeCommentThreadIndex??"","data-active-span":L.activeSpanKind??"",style:{...z,height:"100%",minHeight:0},children:[K0("style",{children:NZ}),B8("div",{..._Z,className:"documint-scroll-container",style:{height:"100%",minHeight:0},children:[K0("textarea",{...d4.inputHandlers,ref:N,autoCapitalize:"sentences",className:"documint-input",spellCheck:!1,tabIndex:-1}),K0(TM,{insetX:y.paddingX,insetY:y.paddingY,onSelect:a4.scrollToPresence,presence:a4.presence}),B8("div",{...v.scrollContent,className:"documint-scroll-content",children:[K0("canvas",{...d4.canvasHandlers,...H1.canvasHandlers,"aria-label":"Documint editor",className:"documint-content-canvas",style:{cursor:H1.cursor},ref:q,tabIndex:0}),K0("canvas",{"aria-hidden":"true",className:"documint-overlay-canvas",ref:U}),f0.handles?B8(jV,{children:[K0("div",{"aria-hidden":"true",className:"documint-selection-handle documint-selection-handle-start",style:{left:`${f0.handles.start.left}px`,top:`${f0.handles.start.top}px`},...f0.startHandleProps,children:K0("span",{className:"documint-selection-handle-knob"})}),K0("div",{"aria-hidden":"true",className:"documint-selection-handle documint-selection-handle-end",style:{left:`${f0.handles.end.left}px`,top:`${f0.handles.end.top}px`},...f0.endHandleProps,children:K0("span",{className:"documint-selection-handle-knob"})})]}):null,G0&&O$?K0(zJ,{anchor:O$,status:PZ,children:zZ}):null]}),!b?K0("div",{className:"documint-fallback",children:K0(V8,{blocks:m.blocks})}):null]})]})})}function VZ($,M){let J=new Map($.documentIndex.regions.map((K,q)=>[K.id,q])),Z=G8(J,$.selection.anchor.regionId,$.selection.anchor.offset),X=G8(J,$.selection.focus.regionId,$.selection.focus.offset),[D,Y]=Z<=X?[Z,X]:[X,Z],Q=Z===X;for(let K of M){let q=G8(J,K.regionId,K.startOffset),U=G8(J,K.regionId,K.endOffset);if(Q){if(D>=q&&D<=U)return K.threadIndex;continue}if(Math.max(D,q)<Math.min(Y,U))return K.threadIndex}return null}function G8($,M,J){return($.get(M)??-1)*1e6+J}export{nJ as mintTheme,tJ as midnightTheme,g4 as lightTheme,X$ as defaultKeybindings,I4 as darkTheme,GZ as Documint};