documint 0.0.15 → 0.0.16
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.d.ts +17 -12
- package/dist/index.js +37 -37
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import{useEffect as
|
|
2
|
-
`);return{items:N.items,...U0,ordered:N.ordered,plainText:F,spread:N.spread??!1,start:N.start??null,type:"list"}}function d0(N){let F=
|
|
3
|
-
`);return{align:N.align??[],plainText:F,...U0,rows:N.rows,type:"table"}}function
|
|
4
|
-
`;case"image":return F.alt??"";case"mention":return`@${F.name}`;case"code":return F.code;case"link":return
|
|
1
|
+
import{useEffect as UN,useEffectEvent as r1,useLayoutEffect as mZ,useMemo as lF,useRef as KN,useState as dH}from"react";var U0={id:""};function $1(N){let F=J0(N);return{children:N,...U0,plainText:F,type:"paragraph"}}function F0(N){return $1(FM(N))}function rF(N){let F=J0(N.children);return{children:N.children,depth:N.depth,...U0,plainText:F,type:"heading"}}function T2(N){return rF({children:FM(N.text),depth:N.depth})}function u0(N,F=[]){return{marks:F,...U0,text:N,type:"text"}}function y1(){return{...U0,type:"lineBreak"}}function O1(N){return{code:N,...U0,type:"code"}}function o1(N){return{children:N.children,...U0,title:N.title??null,type:"link",url:N.url}}function w1(N){let F=N.alt??null,A=N.width??null;return{alt:F,...U0,title:N.title??null,type:"image",url:N.url,width:A}}function C2(N){return{name:N.name,...U0,type:"mention",userId:N.userId}}function cF(N){return{originalType:N.originalType,...U0,source:N.source,type:"raw"}}function n1(N){let F=N2(N.children);return{checked:N.checked??null,children:N.children,...U0,plainText:F,spread:N.spread??!1,type:"listItem"}}function t1(N){let F=N.items.map((A)=>A.plainText).join(`
|
|
2
|
+
`);return{items:N.items,...U0,ordered:N.ordered,plainText:F,spread:N.spread??!1,start:N.start??null,type:"list"}}function d0(N){let F=N2(N);return{children:N,...U0,plainText:F,type:"blockquote"}}function Y4(N){return{language:N.language??null,meta:N.meta??null,...U0,plainText:N.source,source:N.source,type:"code"}}function L1(N){let F=J0(N);return{children:N,...U0,plainText:F}}function j2(N){return{cells:N,...U0}}function e1(N){let F=N.rows.map((A)=>A.cells.map((M)=>M.plainText).join(" | ")).join(`
|
|
3
|
+
`);return{align:N.align??[],plainText:F,...U0,rows:N.rows,type:"table"}}function sF(){return{plainText:"",...U0,type:"divider"}}function X4(N){return{originalType:N.originalType,...U0,plainText:N.source,source:N.source,type:"raw"}}function NM(N){return{attributes:N.attributes,body:N.body,...U0,name:N.name,plainText:N.body,type:"directive"}}function W0(N){let F=[];for(let A of N){let M=F.at(-1);if(M?.type==="text"&&A.type==="text"&&M.marks.join(",")===A.marks.join(",")){F[F.length-1]=u0(M.text+A.text,M.marks);continue}F.push(A)}return F}function k0(N,F){return N.type==="heading"?rF({children:F,depth:N.depth}):$1(F)}function Z1(N,F){return n1({checked:N.checked,children:F,spread:N.spread})}function H0(N,F,A={}){return t1({items:F,ordered:A.ordered??N.ordered,spread:A.spread??N.spread,start:A.start??N.start})}function a0(N,F){return e1({align:N.align,rows:F})}function HN(N,F){return Y4({language:N.language,meta:N.meta,source:F})}function _N(N,F){return X4({originalType:N.originalType,source:F})}function FM(N){return N.length>0?[u0(N)]:[]}function R2(N){return b2("root",N)}function b2(N,F){return`${N}.${F}`}function r0(N){return`${N}.children`}function Q4(N){return`${N}.source`}function Y1(N,F){return b2(r0(N),F)}function iF(N,F){return Y1(N,F)}function S4(N,F){return b2(N,F)}function f2(N,F){return`${N}.rows.${F}`}function F2(N,F){return`${N}.cells.${F}`}function AM(N,F){return S4(r0(N),F)}function J4(N,F){V4(N.blocks,F,EM(),XY())}function YY(N,F,A={}){V4(N,F,EM(),$M(A.pathPrefix??"root",A.startIndex??0))}function o0(N,F){let A=null,M={enterBlock(D){if(D.id===F)return A=D,"stop"}};if(Array.isArray(N))YY(N,M);else J4(N,M);return A}function V4(N,F,A,M){for(let[D,E]of N.entries()){if(A.stopped)return;let $=b2(M.pathPrefix,M.startIndex+D),y={blockAncestors:M.blockAncestors,depth:M.depth,parentBlock:M.parentBlock,path:$},Z=F.enterBlock?.(E,y);if(T1(Z,A))return;if(Z!=="skip")switch(E.type){case"list":MM(E.items,E,F,A,M,$);break;case"blockquote":case"listItem":MM(E.children,E,F,A,M,$);break;case"heading":case"paragraph":yM(E.children,F,A,{block:E,blockAncestors:[...M.blockAncestors,E],container:E,kind:"block",path:r0($)});break;case"table":SY(E,F,A,{blockAncestors:[...M.blockAncestors,E],pathPrefix:$});break;case"code":case"directive":case"divider":case"raw":break}if(A.stopped)return;if(T1(F.leaveBlock?.(E,y),A))return}}function DM(N,F,A,M){for(let[D,E]of N.entries()){if(A.stopped)return;let $=S4(M.pathPrefix,D),y={block:M.block,blockAncestors:M.blockAncestors,inlineAncestors:M.inlineAncestors,parentInline:M.parentInline,path:$},Z=F.enterInline?.(E,y);if(T1(Z,A))return;if(Z!=="skip"){if(E.type==="link")QY(E.children,E,F,A,M,$)}if(A.stopped)return;if(T1(F.leaveInline?.(E,y),A))return}}function EM(){return{stopped:!1}}function XY(){return $M("root",0)}function $M(N,F){return{blockAncestors:[],depth:0,parentBlock:null,pathPrefix:N,startIndex:F}}function MM(N,F,A,M,D,E){V4(N,A,M,{blockAncestors:[...D.blockAncestors,F],depth:D.depth+1,parentBlock:F,pathPrefix:r0(E),startIndex:0})}function QY(N,F,A,M,D,E){DM(N,A,M,{block:D.block,blockAncestors:D.blockAncestors,inlineAncestors:[...D.inlineAncestors,F],parentInline:F,pathPrefix:r0(E)})}function SY(N,F,A,M){for(let[D,E]of N.rows.entries())for(let[$,y]of E.cells.entries()){if(A.stopped)return;let Z=F2(f2(M.pathPrefix,D),$),Y={blockAncestors:M.blockAncestors,cellIndex:$,path:Z,row:E,rowIndex:D,table:N},X=F.enterTableCell?.(y,Y);if(T1(X,A))return;if(X!=="skip")yM(y.children,F,A,{block:N,blockAncestors:M.blockAncestors,container:y,kind:"tableCell",path:Z});if(A.stopped)return;if(T1(F.leaveTableCell?.(y,Y),A))return}}function yM(N,F,A,M){let D=F.enterInlineContainer?.(N,M);if(T1(D,A)||D==="skip")return;if(VY(N,F,A,M),A.stopped)return;DM(N,F,A,{block:M.block,blockAncestors:M.blockAncestors,inlineAncestors:[],parentInline:null,pathPrefix:JY(M)})}function JY(N){return N.kind==="tableCell"?r0(N.path):N.path}function VY(N,F,A,M){if(!F.enterPlainText)return;let D=0;for(let E of N){if(A.stopped)return;if(E.type==="text"){let $=D,y=$+E.text.length;if(E.marks.length===0&&T1(F.enterPlainText(E.text,{...M,endOffset:y,startOffset:$}),A))return;D=y;continue}D+=ZM(E)}}function ZM(N){switch(N.type){case"lineBreak":return 1;case"image":case"mention":return 1;case"code":return N.code.length;case"raw":return N.source.length;case"text":return N.text.length;case"link":return N.children.reduce((F,A)=>F+ZM(A),0)}}function T1(N,F){if(N!=="stop")return!1;return F.stopped=!0,!0}function u2(N,F,A="root",M=null){let D=!1,E=[];for(let[$,y]of N.entries()){let Z=b2(A,$),Y=F(y,{parent:M,path:Z,recurse:()=>qY(y,F,r0(Z))});if(Y===null){D=!0;continue}if(Array.isArray(Y)){D=!0,E.push(...Y);continue}if(Y!==y)D=!0;E.push(Y)}return D?E:N}function qY(N,F,A){switch(N.type){case"blockquote":case"listItem":{let M=u2(N.children,F,A,N);return M===N.children?N:{...N,children:M}}case"list":{let M=u2(N.items,F,A,N);return M===N.items?N:{...N,items:M}}default:return N}}function v2(N,F=[],A){return{blocks:N.map((M,D)=>U4(M,D)),comments:QM(F),frontMatter:A}}function A2(N,F,A,M){let D=M.map((y,Z)=>U4(y,F+Z)),E=N.blocks.slice(F+A),$=M.length===A?E:E.map((y,Z)=>U4(y,F+D.length+Z));return{blocks:[...N.blocks.slice(0,F),...D,...$],comments:N.comments,frontMatter:N.frontMatter}}function XM(N,F,A,M){return{blocks:N.blocks,comments:[...N.comments.slice(0,F),...QM(M,F),...N.comments.slice(F+A)],frontMatter:N.frontMatter}}function QM(N,F=0){return N.map((A,M)=>{if(A.id)return A;let D=A.comments[0];return{...A,id:y0("commentThread",`comments.${F+M}`,`${A.anchor.kind??""}:${A.anchor.prefix??""}:${A.anchor.suffix??""}:${A.quote}:${D?.body??""}:${D?.updatedAt??""}`)}})}function SM(N,F,A,M){if(M!==void 0)return YM(N,M,F,A);for(let D=0;D<N.blocks.length;D+=1){let E=YM(N,D,F,A);if(E)return E}return null}function YM(N,F,A,M){let D=N.blocks[F];if(!D)return null;let E=JM(D,A,M);return E?A2(N,F,1,[E]):null}function JM(N,F,A){if(N.id===F)return A(N);switch(N.type){case"blockquote":{let M=q4(N.children,F,A);return M?d0(M):null}case"listItem":{let M=q4(N.children,F,A);return M?Z1(N,M):null}case"list":{let M=q4(N.items,F,A);return M?H0(N,M):null}default:return null}}function q4(N,F,A){let M=!1,D=N.map((E)=>{let $=JM(E,F,A);if(!$)return E;return M=!0,$});return M?D:null}function J0(N){return N.map((F)=>{switch(F.type){case"lineBreak":return`
|
|
4
|
+
`;case"image":return F.alt??"";case"mention":return`@${F.name}`;case"code":return F.code;case"link":return J0(F.children);case"text":return F.text;case"raw":return F.source}}).join("")}function N2(N){return N.map((F)=>{switch(F.type){case"blockquote":case"listItem":return N2(F.children);case"code":return F.source;case"directive":return F.body;case"heading":case"paragraph":return J0(F.children);case"list":return F.items.map((A)=>A.plainText).join(`
|
|
5
5
|
`);case"table":return F.rows.map((A)=>A.cells.map((M)=>M.plainText).join(" | ")).join(`
|
|
6
6
|
`);case"divider":return"";case"raw":return F.source}}).join(`
|
|
7
|
-
`).trim()}function
|
|
8
|
-
`);return{id:
|
|
9
|
-
`);return{align:N.align,id:q0("table",F,M),plainText:M,rows:A,type:"table"}}case"divider":return{id:q0("divider",F,"divider"),plainText:"",type:"divider"};case"raw":return{id:q0("raw",F,N.source),originalType:N.originalType,plainText:N.source,source:N.source,type:"raw"}}}function AX(N,F){return{cells:N.cells.map((A,M)=>{let D=A.children.map(($,Z)=>lF($,dA(t1(F,M),Z))),E=V0(D);return{children:D,id:q0("tableCell",t1(F,M),E),plainText:E}}),id:q0("tableRow",F,String(N.cells.length))}}function lF(N,F){switch(N.type){case"lineBreak":return{id:q0("lineBreak",F,"lineBreak"),type:"lineBreak"};case"image":return{alt:N.alt,id:q0("image",F,`${N.url}:${N.width??""}:${N.alt??""}`),title:N.title,type:"image",url:N.url,width:N.width};case"mention":return{id:q0("mention",F,`${N.userId}:${N.name}`),name:N.name,type:"mention",userId:N.userId};case"code":return{code:N.code,id:q0("code",F,N.code),type:"code"};case"link":{let A=N.children.map((D,E)=>lF(D,pF(F,E))),M=V0(A);return{children:A,id:q0("link",F,`${N.url}:${M}`),title:N.title,type:"link",url:N.url}}case"text":return{id:q0("text",F,`${N.text}:${N.marks.join(",")}`),marks:N.marks,text:N.text,type:"text"};case"raw":return{id:q0("raw",F,N.source),originalType:N.originalType,source:N.source,type:"raw"}}}function FM(N){return L2(N,(F,{recurse:A})=>{switch(F.type){case"blockquote":case"list":case"listItem":return A();case"heading":case"paragraph":return m0(F,Y4(F.children));case"table":return a0(F,F.rows.map((M)=>({...M,cells:M.cells.map((D)=>({...D,children:Y4(D.children)}))})));default:return F}})}function Y4(N){let F=null,A=()=>F??=[...N];for(let M=N.length-1;M>=0;M-=1){let D=N[M];if(D.type==="text"){let E=D.text.replace(/[ \t]+$/u,"");if(E.length===D.text.length)return F??N;let $=A();if(E.length===0){$.splice(M,1);continue}return $[M]={...D,text:E},$}if(D.type==="link"){let E=Y4(D.children);if(E===D.children)return F??N;let $=A();if(E.length===0){$.splice(M,1);continue}return $[M]={...D,children:E},$}return F??N}return F??N}function q0(N,F,A){let M=2166136261;for(let D of`${N}:${F}:${A}`)M^=D.charCodeAt(0),M=Math.imul(M,16777619);return`${N}-${(M>>>0).toString(36)}`}var y4="text";function Q4(N){return N==="text"||N==="code"||N==="tableCell"}function J4(N){return N===y4?void 0:N}function MM(N){switch(N){case"heading":case"paragraph":return"text";case"code":return"code";default:return null}}function rF(N){let F=[];return D4(N,{enterBlock(A){switch(A.type){case"heading":case"paragraph":F.push({containerKind:"text",containerOrdinal:F.length,id:A.id,text:V0(A.children)});break;case"code":F.push({containerKind:"code",containerOrdinal:F.length,id:A.id,text:A.source});break}},enterTableCell(A){F.push({containerKind:"tableCell",containerOrdinal:F.length,id:A.id,text:V0(A.children)})}}),F}function V4(N,F,A){return{prefix:N.slice(Math.max(0,F-AM),F),suffix:N.slice(A,Math.min(N.length,A+AM))}}function KN(N,F,A){let M=i0(F,0,N.text.length),D=i0(A,M,N.text.length),{prefix:E,suffix:$}=V4(N.text,M,D);return{kind:J4(N.containerKind),prefix:E||void 0,suffix:$||void 0}}function SN(N,F,A){let M=i0(F,0,N.text.length),D=i0(A,M,N.text.length);return N.text.slice(M,D)}function X1(N,F){if(F.length===0)return[];let A=[],M=0;while(M<=N.length){let D=N.indexOf(F,M);if(D===-1)break;A.push(D),M=D+Math.max(1,F.length)}return A}function j2(N,F,A){if(F.length===0||A.length===0)return[];let M=[];for(let D of X1(N,F)){let E=D+F.length,$=N.indexOf(A,E);if($!==-1)M.push({startOffset:E,endOffset:$})}return M}function U4(N,F,A){if(!F)return!1;return N.slice(Math.max(0,A-F.length),A)===F}function q4(N,F,A){if(!F)return!1;return N.slice(A,A+F.length)===F}var AM=24;function i0(N,F,A){return Math.min(Math.max(N,F),A)}var DM=48,EM=64,MX=32;function GN(N,F){let A=N.anchor.kind??y4,M=rF(F).filter(($)=>$.containerKind===A),D=DX(N,M);if(D.length>0)return $M(N,D,null);let E=EX(N,M);if(E.length>0)return $M(N,E,"repaired");return{match:null,repair:null,status:"stale"}}function DX(N,F){let A=[],M=N.quote;if(M.length===0)return A;for(let D of F)for(let E of X1(D.text,M))A.push({container:D,endOffset:E+M.length,score:YX(N,D,E),startOffset:E});return A.sort((D,E)=>E.score-D.score),A}function EX(N,F){let A=[];for(let M of F)A.push(...$X(N,M));return A.sort((M,D)=>D.score-M.score),A}function $X(N,F){let A=[],M=N.quote.length,D=F.text,E=N.anchor.prefix??"",$=N.anchor.suffix??"";if(E.length>0&&$.length>0){for(let Z of j2(D,E,$))A.push({container:F,endOffset:Z.endOffset,score:K4(N,F,Z.startOffset,Z.endOffset,M),startOffset:Z.startOffset});return A}if(E.length>0){for(let Z of X1(D,E)){let Y=Z+E.length,X=i0(Y+M,Y,D.length);A.push({container:F,endOffset:X,score:K4(N,F,Y,X,M),startOffset:Y})}return A}if($.length>0)for(let Z of X1(D,$)){let Y=Z,X=i0(Y-M,0,Y);A.push({container:F,endOffset:Y,score:K4(N,F,X,Y,M),startOffset:X})}return A}function $M(N,F,A){let[M,D]=F;if(!M)return{match:null,repair:null,status:"stale"};if(D&&M.score===D.score)return{match:null,repair:null,status:"ambiguous"};let E=KN(M.container,M.startOffset,M.endOffset),$=SN(M.container,M.startOffset,M.endOffset),Z=A??($===N.quote&&(E.prefix??"")===(N.anchor.prefix??"")&&(E.suffix??"")===(N.anchor.suffix??"")?"matched":"repaired");return{match:ZX(M.container,M.startOffset,M.endOffset),repair:{anchor:E,quote:$},status:Z}}function ZX(N,F,A){return{containerId:N.id,containerKind:N.containerKind,containerOrdinal:N.containerOrdinal,endOffset:A,startOffset:F}}function YX(N,F,A){let M=0;if(U4(F.text,N.anchor.prefix,A))M+=DM;if(q4(F.text,N.anchor.suffix,A+N.quote.length))M+=DM;return M}function K4(N,F,A,M,D){let E=0;if(U4(F.text,N.anchor.prefix,A))E+=EM;if(q4(F.text,N.anchor.suffix,M))E+=EM;if(E+=Math.max(0,MX-Math.abs(D-(M-A))),N.quote.length>0){let $=F.text.slice(A,M);if($.length>0)E+=XX(N.quote,$),E+=yX(N.quote,$)}return E}function XX(N,F){let A=0;while(A<N.length&&A<F.length&&N[A]===F[A])A+=1;return A}function yX(N,F){let A=0;while(A<N.length&&A<F.length&&N[N.length-1-A]===F[F.length-1-A])A+=1;return A}function S4(N){if(!N||typeof N!=="object"||Array.isArray(N))return null;let F=N,A=JX(F.anchor),M=typeof F.quote==="string"?F.quote:null,D=Array.isArray(F.comments)?F.comments.flatMap((E)=>{let $=QX(E);return $?[$]:[]}):[];if(!A||!M||D.length===0)return null;return{quote:M,anchor:A,comments:D,resolvedAt:typeof F.resolvedAt==="string"?F.resolvedAt:void 0}}function QX(N){if(!N||typeof N!=="object"||Array.isArray(N))return null;let F=N;if(typeof F.body!=="string"||typeof F.updatedAt!=="string")return null;return{body:F.body,updatedAt:F.updatedAt}}function JX(N){if(!N||typeof N!=="object"||Array.isArray(N))return null;let{kind:F,prefix:A,suffix:M}=N;if("kind"in N&&!Q4(F)||"prefix"in N&&typeof A!=="string"||"suffix"in N&&typeof M!=="string")return null;return{kind:Q4(F)?J4(F):void 0,prefix:typeof A==="string"?A:void 0,suffix:typeof M==="string"?M:void 0}}function G4(N){let F=N.createdAt??new Date().toISOString();return{comments:[ZM({body:N.body,updatedAt:F})],quote:N.quote,anchor:N.anchor}}function z4(N,F){let A=ZM(F);return{...N,comments:[...N.comments,A]}}function H4(N,F,A,M=new Date().toISOString()){let D=A.trim();if(D.length===0)return N;let E=!1,$=N.comments.map((Z,Y)=>{if(Y!==F||Z.body===D)return Z;return E=!0,{...Z,body:D,updatedAt:M}});if(!E)return N;return{...N,comments:$}}function _4(N,F){let A=N.comments.filter((M,D)=>D!==F);if(A.length===N.comments.length)return N;if(A.length===0)return null;return{...N,comments:A}}function B4(N,F,A=new Date().toISOString()){if(j1(N)===F)return N;return{...N,resolvedAt:F?A:void 0}}function j1(N){return N.resolvedAt!=null}function P4(N){if(N.comments.length===0)return null;return N.comments.reduce((F,A)=>A.updatedAt>F?A.updatedAt:F,N.comments[0].updatedAt)}function ZM(N){let F=N.updatedAt??new Date().toISOString();return{body:N.body,updatedAt:F}}function YM(N,F,A,M,D){let E=M-A,$=D-E;if(M<=N)return{end:F+$,start:N+$};if(A>=F)return{end:F,start:N};let Z=Math.max(0,Math.min(A,F)-N),Y=Math.max(0,F-Math.max(M,N)),X=N<A?N:A;return{end:X+Z+D+Y,start:X}}function O4(N,F,A){let M=A.trim();if(M.length===0||F.startOffset===F.endOffset)return null;let D=N.regionIndex.get(F.regionId)??null,E=D?W4(N,D):null;if(!E)return null;return G4({anchor:KN(E,F.startOffset,F.endOffset),body:M,quote:SN(E,F.startOffset,F.endOffset)})}function u0(N){let F="documentIndex"in N?N.documentIndex:N,A=cF(F),M=F.document.comments,D=[...M],E=[];for(let[$,Z]of M.entries()){let Y=GN(Z,F.document);if(!Y.match)continue;let y=A.findBySemanticMatch(Y.match.containerId,Y.match.containerOrdinal)?.runtimeContainer??null;if(!y)continue;if(Y.repair)D[$]={...Z,anchor:Y.repair.anchor,quote:Y.repair.quote};E.push({endOffset:Y.match.endOffset,resolution:Y,regionId:y.id,resolved:Z.resolvedAt!=null,startOffset:Y.match.startOffset,threadIndex:$})}return{liveRanges:E,threads:D}}function T4(N,F,A,M,D,E){if(N.document.comments.length===0)return F.document.comments;let $=N.commentContainerIndex.get(A.semanticRegionId)??[],Z=new Set($);if($.length===0)return F.document.comments;let Y=u0(N),X=new Map(Y.liveRanges.map((V)=>[V.threadIndex,V])),y=W4(N,A),Q=C2(F,A.path),J=Q?W4(F,Q):null;if(!y||!J)return F.document.comments;return F.document.comments.map((V,U)=>{if(!Z.has(U))return V;let S=X.get(U),q=S?.resolution.match??null;if(!S||!q||q.containerId!==y.id)return V;let K=YM(q.startOffset,q.endOffset,M,D,E.length);return{...V,anchor:KN(J,K.start,K.end),quote:SN(J,K.start,K.end)}})}function W4(N,F){let A=VX(N,F);if(!A)return null;return{containerKind:A,containerOrdinal:-1,id:F.semanticRegionId,text:F.text}}function VX(N,F){if(N.tableCellIndex.has(F.id))return"tableCell";return MM(F.blockType)}function sF(N,F){if(F.length===0)return[];let A=cF(N),M=A.list();return F.map((D)=>({...D,cursorPoint:UX(D,M,A),viewport:null}))}function UX(N,F,A){if(!N.cursor)return null;let M=qX(F,N.cursor),D=KX(M,N.cursor);if(D.length!==1)return null;let E=D[0],$=A.resolveRuntimeContainer(E.container.id);if(!$)return null;return{offset:Math.max(0,Math.min(E.offset,$.text.length)),regionId:$.id}}function qX(N,F){return F.kind?N.filter((A)=>A.containerKind===F.kind):N}function KX(N,F){if(F.prefix&&F.suffix)return SX(N,F.prefix,F.suffix);if(F.prefix)return XM(N,F.prefix,"after");if(F.suffix)return XM(N,F.suffix,"before");return[]}function XM(N,F,A){let M=[];for(let D of N)for(let E of X1(D.text,F))M.push({container:D,offset:A==="after"?E+F.length:E});return M}function SX(N,F,A){let M=[];for(let D of N)for(let E of j2(D.text,F,A))M.push({container:D,offset:E.startOffset});return M}var GX=48;function iF(N,F,A){let M="documentIndex"in N?N.documentIndex:N;if(A.length===0)return[];return A.map((D)=>({...D,viewport:zX(M,F,D)}))}function oF(N,F,A){let M="documentIndex"in N?N.documentIndex:N,D=yM(M,F,A);if(!D)return"unresolved";return QM(F,D)}function zX(N,F,A){if(!A.cursorPoint)return{status:"unresolved"};let M=yM(N,F,A.cursorPoint);if(!M)return{status:"unresolved"};return{scrollTop:HX(F,M),status:QM(F,M)}}function yM(N,F,A){let M=o0(F.layout,N,A);if(M)return{bottom:M.top+M.height,top:M.top};return F.estimateRegionBounds(A.regionId)}function QM(N,F){let A=N.viewport.top,M=A+N.viewport.height;if(F.bottom<A)return"above";if(F.top>M)return"below";return"visible"}function HX(N,F){let A=Math.max(0,N.totalHeight-N.viewport.height),M=F.top-Math.min(GX,N.viewport.height/4);return Math.max(0,Math.min(A,M))}function cF(N){let F=rF(N.document),A=new Map(F.map((D)=>[D.id,D])),M=new Map(N.regions.map((D)=>[D.semanticRegionId,D]));return{findBySemanticMatch(D,E){let $=A.get(D)??F[E]??null;if(!$)return null;return{runtimeContainer:M.get($.id)??null,semanticContainer:$}},list(D){return D?F.filter((E)=>E.containerKind===D):F},resolveRuntimeContainer(D){return M.get(D)??null}}}var R2="",JM=1e6;function zN(N,F,A){return`${N}:${F}:${A}`}function b2(N){let F=IX(N),A=w4(F.blocks.map((M,D)=>_N(M,D)));return j4(F,A)}function _N(N,F){let A=[],M=[],D=[],E=new Set,$=0;function Z(X,y,Q,J,V=null){if(M.length>0)D.push(`
|
|
10
|
-
`),$+=1;let U=Q.map((K)=>K.text).join(""),S=$,q=S+U.length;D.push(U),$=q;for(let K of Q)if(K.image)E.add(K.image.url);M.push({blockId:X.id,blockType:X.type,end:q,id:`${X.id}:${y}`,path:y,rootIndex:F,inlines:Q,semanticRegionId:J,start:S,tableCellPosition:V,text:U})}function Y(X,y,Q,J){let V={childBlockIds:[],depth:Q,end:$,id:X.id,parentBlockId:J,path:y,regionIds:[],rootIndex:F,start:$,type:X.type};switch(A.push(V),X.type){case"blockquote":case"listItem":for(let[U,S]of X.children.entries())V.childBlockIds.push(S.id),Y(S,Y1(y,U),Q+1,X.id);break;case"code":{Z(X,A4(y),[{end:X.source.length,id:`${X.id}:code`,image:null,inlineCode:!1,kind:"text",link:null,marks:[],mention:null,originalType:null,start:0,text:X.source}],X.id),V.regionIds.push(M.at(-1).id);break}case"heading":case"paragraph":Z(X,r0(y),L4(X.children),X.id),V.regionIds.push(M.at(-1).id);break;case"list":for(let[U,S]of X.items.entries())V.childBlockIds.push(S.id),Y(S,Y1(y,U),Q+1,X.id);break;case"table":for(let[U,S]of X.rows.entries())for(let[q,K]of S.cells.entries())Z(X,t1(T2(y,U),q),L4(K.children),K.id,{cellIndex:q,rowIndex:U}),V.regionIds.push(M.at(-1).id);break;case"divider":break;case"directive":break;case"raw":Z(X,A4(y),[{end:X.source.length,id:`${X.id}:raw`,image:null,inlineCode:!1,kind:"raw",link:null,marks:[],mention:null,originalType:X.originalType,start:0,text:X.source}],X.id),V.regionIds.push(M.at(-1).id);break}V.end=$}return Y(N,W2(F),0,null),{blockRange:{end:A.length,start:0},blocks:A,end:$,imageUrls:E,length:$,regionRange:M.length>0?{end:M.length,start:0}:void 0,regions:M,rootIndex:F,start:0,text:D.join("")}}function w4(N,F=null){let A=[],M=0,D=0,E=0,$=!1;for(let[Z,Y]of N.entries()){if(Y.regions.length>0&&$)E+=1;let X={...Y,blockRange:{end:M+Y.blocks.length,start:M},end:E+Y.length,regionRange:Y.regions.length>0?{end:D+Y.regions.length,start:D}:void 0,start:E},y=F?.[Z];if(A.push(BX(y,Y,X)?y:VM(Y,X)),M=X.blockRange.end,D=X.regionRange?.end??D,Y.regions.length>0)E=X.end,$=!0}return A}function f2(N,F,A,M){let D=F.blocks.length-(N.roots.length-M);if(D<0)throw Error("Editor model splice received an invalid replacement count.");if(A===N.roots.length&&D===1){let Y=F.blocks[A];if(Y)return _X(N,F,Y)}let E=D===M,$=[...N.roots.slice(0,A),...F.blocks.slice(A,A+D).map((Y,X)=>_N(Y,A+X)),...E?N.roots.slice(A+M):F.blocks.slice(A+D).map((Y,X)=>_N(Y,A+D+X))],Z=w4($,N.roots);return j4(F,Z,N)}function _X(N,F,A){let M=N.roots.length,D=_N(A,M),E=N.roots.some((y)=>y.regions.length>0),$=D.regions.length>0&&E?N.length+1:N.length,Z=VM(D,{...D,blockRange:{end:N.blocks.length+D.blocks.length,start:N.blocks.length},end:$+D.length,regionRange:D.regions.length>0?{end:N.regions.length+D.regions.length,start:N.regions.length}:void 0,start:$}),Y=[...N.blocks,...Z.blocks],X=[...N.regions,...Z.regions];return{blockIndex:LX(N.blockIndex,Z.blocks),blocks:Y,commentContainerIndex:F.comments===N.document.comments?N.commentContainerIndex:UM(F),document:F,engine:"canvas",imageUrls:uX(N.imageUrls,Z.imageUrls),length:Z.end,listItemMarkers:F.blocks===N.document.blocks?N.listItemMarkers:fX(N.listItemMarkers,A),regionIndex:wX(N.regionIndex,Z.regions),regionOrderIndex:jX(N.regionOrderIndex,Z.regions,N.regions.length),regionPathIndex:CX(N.regionPathIndex,Z.regions),regions:X,roots:[...N.roots,Z],tableCellIndex:RX(N.tableCellIndex,Z.regions),tableCellRegionIndex:bX(N.tableCellRegionIndex,Z.regions),text:vX(N.text,Z)}}function nF(N,F){if(F.blocks!==N.document.blocks)throw Error("Editor model document replacement requires preserving root blocks.");return j4(F,N.roots,N)}function tF(N,F,A){let M=N.blockIndex.get(F);if(!M)return null;return eA(N.document,F,A,M.rootIndex)}function j4(N,F,A=null){let M=F.flatMap((y)=>y.blocks),D=F.flatMap((y)=>y.regions),{regionIndex:E,regionOrderIndex:$,regionPathIndex:Z,tableCellIndex:Y,tableCellRegionIndex:X}=TX(D);return{blockIndex:OX(M),blocks:M,commentContainerIndex:N.comments===A?.document.comments?A.commentContainerIndex:UM(N),document:N,engine:"canvas",imageUrls:mX(F,A?.imageUrls),length:F.at(-1)?.end??0,listItemMarkers:N.blocks===A?.document.blocks?A.listItemMarkers:hX(N.blocks),regionIndex:E,regionOrderIndex:$,regionPathIndex:Z,regions:D,roots:F,tableCellIndex:Y,tableCellRegionIndex:X,text:kX(F)}}function VM(N,F){let A=F.start-N.start;return{...F,blocks:A===0?N.blocks:PX(N.blocks,A),regions:A===0?N.regions:WX(N.regions,A)}}function BX(N,F,A){return Boolean(N&&F===N&&N.start===A.start&&N.end===A.end&&N.blockRange.start===A.blockRange.start&&N.blockRange.end===A.blockRange.end&&N.regionRange?.start===A.regionRange?.start&&N.regionRange?.end===A.regionRange?.end)}function PX(N,F){return N.map((A)=>({...A,end:A.end+F,start:A.start+F}))}function WX(N,F){return N.map((A)=>({...A,end:A.end+F,start:A.start+F}))}function OX(N){let F=new Map;for(let A of N)F.set(A.id,A);return F}function TX(N){let F=new Map,A=new Map,M=new Map,D=new Map,E=new Map;for(let[$,Z]of N.entries()){if(F.set(Z.id,Z),A.set(Z.id,$),M.set(Z.path,Z),!Z.tableCellPosition)continue;D.set(Z.id,Z.tableCellPosition),E.set(zN(Z.blockId,Z.tableCellPosition.rowIndex,Z.tableCellPosition.cellIndex),Z.id)}return{regionIndex:F,regionOrderIndex:A,regionPathIndex:M,tableCellIndex:D,tableCellRegionIndex:E}}function LX(N,F){let A=new Map(N);for(let M of F)A.set(M.id,M);return A}function wX(N,F){let A=new Map(N);for(let M of F)A.set(M.id,M);return A}function jX(N,F,A){let M=new Map(N);for(let[D,E]of F.entries())M.set(E.id,A+D);return M}function CX(N,F){let A=new Map(N);for(let M of F)A.set(M.path,M);return A}function RX(N,F){let A=new Map(N);for(let M of F)if(M.tableCellPosition)A.set(M.id,M.tableCellPosition);return A}function bX(N,F){let A=new Map(N);for(let M of F){if(!M.tableCellPosition)continue;A.set(zN(M.blockId,M.tableCellPosition.rowIndex,M.tableCellPosition.cellIndex),M.id)}return A}function fX(N,F){let A=new Map(N);return HN(A,[F]),A}function vX(N,F){if(F.regions.length===0)return N;return N.length>0?`${N}
|
|
11
|
-
${F.text}`:F.text}function kX(N){return N.filter((F)=>F.regions.length>0).map((F)=>F.text).join(`
|
|
12
|
-
`)}function mX(N,F){let A=new Set;for(let M of N)for(let D of M.imageUrls)A.add(D);return F&&gX(F,A)?F:A}function uX(N,F){if(F.size===0)return N;let A=null;for(let M of F){if(N.has(M))continue;A??=new Set(N),A.add(M)}return A??N}function gX(N,F){if(N.size!==F.size)return!1;for(let A of N)if(!F.has(A))return!1;return!0}function UM(N){let F=new Map;for(let[A,M]of N.comments.entries()){let D=GN(M,N).match?.containerId??null;if(!D)continue;let E=F.get(D)??[];E.push(A),F.set(D,E)}return F}function hX(N){let F=new Map;return HN(F,N),F}function HN(N,F,A=null){for(let M of F){if(M.type==="list"){for(let[D,E]of M.items.entries())HN(N,[E],{index:D,ordered:M.ordered,start:M.start});continue}if(M.type==="listItem"){if(typeof M.checked==="boolean")N.set(M.id,{checked:M.checked,kind:"task"});else if(A?.ordered)N.set(M.id,{kind:"ordered",label:`${(A.start??1)+A.index}.`});else N.set(M.id,{kind:"bullet",label:"•"});HN(N,M.children,A)}if(M.type==="blockquote")HN(N,M.children,A)}}function IX(N){if(N.blocks.length>0)return N;return w2([F0("")],N.comments,N.frontMatter)}function L4(N,F=null){let A=[],M=0,D=(E)=>{let $=M,Z=$+E.text.length;A.push({...E,end:Z,start:$}),M=Z};for(let E of N)switch(E.type){case"lineBreak":D({id:E.id,image:null,inlineCode:!1,kind:"lineBreak",link:F,marks:[],mention:null,originalType:null,text:`
|
|
13
|
-
`});break;case"image":D({id:E.id,image:{alt:E.alt,title:E.title,url:E.url,width:E.width},inlineCode:!1,kind:"image",link:F,marks:[],mention:null,originalType:null,text:R2});break;case"mention":D({id:E.id,image:null,inlineCode:!1,kind:"mention",link:F,marks:[],mention:{name:E.name,userId:E.userId},originalType:null,text:R2});break;case"code":D({id:E.id,image:null,inlineCode:!0,kind:"code",link:F,marks:[],mention:null,originalType:null,text:E.code});break;case"link":for(let $ of L4(E.children,{title:E.title,url:E.url}))D($);break;case"text":D({id:E.id,image:null,inlineCode:!1,kind:"text",link:F,marks:E.marks,mention:null,originalType:null,text:E.text});break;case"raw":D({id:E.id,image:null,inlineCode:!1,kind:"raw",link:F,marks:[],mention:null,originalType:E.originalType,text:E.source});break}return A}function g0(N){switch(N.type){case"lineBreak":return 1;case"image":case"mention":return R2.length;case"code":return N.code.length;case"link":return V0(N.children).length;case"text":return N.text.length;case"raw":return N.source.length}}function h0(N,F,A,M){let D=eF(N.children,F,A,M),E=M.reduce((Z,Y)=>Z+g0(Y),0),$=F+E;return BN(N,D,$,$)}function BN(N,F,A,M){switch(N.kind){case"inlineBlock":return{block:m0(N.block,F),blockId:N.block.id,selection:qM(r0(N.path),A,M)};case"tableCell":{let D=T1(F),E=N.block.rows.map(($)=>({...$,cells:$.cells.map((Z)=>Z.id===N.cell.id?D:Z)}));return{block:a0(N.block,E),blockId:N.block.id,selection:qM(N.path,A,M)}}}}function qM(N,F,A){return{endOffset:A,kind:"region-range-path",path:N,startOffset:F}}function eF(N,F,A,M){let D=[],E=0,$=!1;for(let Z of N){let Y=g0(Z),X=E,y=X+Y;if(E=y,A<=X||F>=y){D.push(Z);continue}if(!$)D.push(...pX(Z,Math.max(0,F-X))),D.push(...M),$=!0;D.push(...xX(Z,Math.min(Y,A-X)))}if(!$)D.push(...M);return W0(D)}function pX(N,F){if(F<=0)return[];return C4(N,0,F)}function xX(N,F){let A=g0(N);if(F>=A)return[];return C4(N,F,A)}function C4(N,F,A){if(F>=A)return[];switch(N.type){case"text":{let M=N.text.slice(F,A);return M.length>0?[f0(M,N.marks)]:[]}case"code":return[W1(N.code.slice(F,A))];case"link":{let M=W0(b4(N.children,F,A));return M.length>0?[{...N,children:M}]:[]}default:return[]}}function R4(N,F,A){let M=0,D="";for(let E of N){let $=g0(E),Z=M,Y=Z+$;if(M=Y,A<=Z||F>=Y)continue;D+=lX(E,Math.max(0,F-Z),Math.min($,A-Z))}return D}function b4(N,F,A){let M=[],D=0;for(let E of N){let $=g0(E),Z=D,Y=Z+$;if(D=Y,A<=Z||F>=Y)continue;M.push(...C4(E,Math.max(0,F-Z),Math.min($,A-Z)))}return M}function lX(N,F,A){if(F>=A)return"";switch(N.type){case"lineBreak":return`
|
|
14
|
-
`.slice(F,A);case"image":case"mention":return R2.slice(F,A);case"code":return N.code.slice(F,A);case"link":return R4(N.children,F,A);case"text":return N.text.slice(F,A);case"raw":return N.source.slice(F,A)}}function f4(N,F,A,M){let D=dX(N.children,F,A,M);if(D===null)return null;let E=W0(KM(N.children,F,A,M,D));return E.length>0?BN(N,E,F,A):null}function v4(N,F,A){let M=0,D=null,E=($)=>{for(let Z of $){let Y=g0(Z),X=M,y=X+Y;if(M=y,A<=X||F>=y)continue;if(Z.type==="text"){let Q=Math.max(F,X);if(Math.min(A,y)>Q)D=D===null?new Set(Z.marks):new Set(Z.marks.filter((V)=>D?.has(V)));continue}if(Z.type==="link"){let Q=M;M=X,E(Z.children),M=Q}}};return E(N.children),D?[...D]:[]}function dX(N,F,A,M){let D=0,E=!1,$=!0,Z=(Y)=>{for(let X of Y){let y=g0(X),Q=D,J=Q+y;if(D=J,A<=Q||F>=J)continue;if(X.type==="text"){let V=Math.max(F,Q);if(Math.min(A,J)>V)E=!0,$&&=X.marks.includes(M);continue}if(X.type==="link"){let V=D;D=Q,Z(X.children),D=V}}};return Z(N),E?$:null}function KM(N,F,A,M,D){let E=[],$=0;for(let Z of N){let Y=$,X=g0(Z),y=Y+X;if($=y,A<=Y||F>=y){E.push(Z);continue}if(Z.type==="text"){E.push(...aX(Z,Math.max(0,F-Y),Math.min(X,A-Y),M,D));continue}if(Z.type==="link"){let Q=W0(KM(Z.children,Math.max(0,F-Y),Math.min(X,A-Y),M,D));if(Q.length>0)E.push({...Z,children:Q});continue}E.push(Z)}return E}function aX(N,F,A,M,D){let E=N.text.slice(0,F),$=N.text.slice(F,A),Z=N.text.slice(A),Y=D?N.marks.filter((Q)=>Q!==M):rX(N.marks,M),X=[],y=(Q,J)=>{if(Q.length>0)X.push(f0(Q,J))};return y(E,N.marks),y($,Y),y(Z,N.marks),X}function rX(N,F){return N.includes(F)?N:[...N,F].sort()}function m4(N,F,A){return SM(N,{endOffset:A,regionId:N.selection.focus.regionId,startOffset:F})}function SM(N,F){return OM(N.documentIndex,F.regionId,F.startOffset,F.endOffset,{allowCollapsed:!0})}function N6(N,F){let A=SM(N,F);return A?GM(N,A):null}function GM(N,F){let A=_M(N.documentIndex,F.region.id);return A?{...F,inlineContainer:A}:null}function q1(N){let F=X0(N);if(F.start.regionId!==F.end.regionId)return null;let A=m4(N,F.start.offset,F.end.offset);return A?GM(N,A):null}function F6(N){return zM(N.documentIndex,N.selection)}function zM(N,F){let A=N.regionIndex.get(F.anchor.regionId);if(!A)return{kind:"unsupported"};if(A.blockType==="code"){let Z=N.blockIndex.get(A.blockId);return Z?{kind:"code",region:A,rootIndex:Z.rootIndex,selection:F,...WN(N,A,F)}:{kind:"unsupported"}}let M=BM(N,A.id,F);if(M)return{kind:"tableCell",...M,...WN(N,A,F)};let D=A6(N,F);if(D)return{kind:"listItem",...D};let E=cX(N,F);if(E)return{kind:"blockquoteTextBlock",...E};let $=v2(N,F);if($)return{kind:"rootTextBlock",...$};return{kind:"unsupported"}}function HM(N,F){let{documentIndex:A,selection:M}=N,D=zM(A,M),E=D.kind==="unsupported"?!1:F==="backward"?D.atStart:D.atEnd;switch(D.kind){case"rootTextBlock":return{...D,kind:"rootTextBlock",direction:F,atBoundary:E,previousRoot:A.document.blocks[D.rootIndex-1]??null,nextRoot:A.document.blocks[D.rootIndex+1]??null};case"listItem":return{...D,kind:"listItem",direction:F,atBoundary:E,previousItem:D.list.items[D.itemIndex-1]??null,nextItem:D.list.items[D.itemIndex+1]??null,previousRoot:A.document.blocks[D.rootIndex-1]??null,nextRoot:A.document.blocks[D.rootIndex+1]??null};case"blockquoteTextBlock":return{...D,kind:"blockquoteTextBlock",direction:F,atBoundary:E,previousSibling:D.quote.children[D.childIndex-1]??null,nextSibling:D.quote.children[D.childIndex+1]??null};default:return{kind:"unsupported",direction:F,atBoundary:!1}}}function _M(N,F){let A=N.regionIndex.get(F);if(!A)return null;let M=U1(N.document.blocks,A.blockId);if(!M)return null;return u4(M,A.path,A.semanticRegionId)}function u4(N,F,A){if(N.type==="heading"||N.type==="paragraph")return{block:N,children:N.children,kind:"inlineBlock",path:F.replace(/\.children$/,"")};if(N.type!=="table")return null;let M=/^(.*\.rows\.\d+\.cells\.\d+)$/.exec(F);if(!M)return null;for(let D of N.rows)for(let E of D.cells)if(E.id===A)return{block:N,blockPath:M[1].replace(/\.rows\.\d+\.cells\.\d+$/,""),cell:E,children:E.children,kind:"tableCell",path:M[1]};return null}function k4(N,F,A){let M=F?N.blockIndex.get(F)??null:null;while(M){if(M.type===A)return M;let D=M.parentBlockId;M=D?N.blockIndex.get(D)??null:null}return null}function C1(N){let F=N.split("."),A=[];for(let M=0;M<F.length-1;M+=1)if(F[M]==="children"){let D=Number(F[M+1]);if(Number.isInteger(D))A.push(D)}return A}function v2(N,F){let A=N.regionIndex.get(F.anchor.regionId);if(!A)return null;let M=N.blockIndex.get(A.blockId);if(!M)return null;let D=M.rootIndex,E=N.document.blocks[D];if(!E||E.type!=="heading"&&E.type!=="paragraph")return null;return{...WN(N,A,F),block:E,region:A,rootIndex:D}}function cX(N,F){let A=N.regionIndex.get(F.anchor.regionId);if(!A)return null;let M=N.blockIndex.get(A.blockId),D=k4(N,M?.id??null,"blockquote");if(!M||!D||M.parentBlockId!==D.id)return null;let E=D.rootIndex,$=N.document.blocks[E];if(!$||$.type!=="blockquote")return null;let Z=$.children.findIndex((X)=>X.id===M.id),Y=$.children[Z];if(!Y||Y.type!=="heading"&&Y.type!=="paragraph")return null;return{...WN(N,A,F),block:Y,blockChildIndices:C1(M.path),childIndex:Z,region:A,quote:$,rootIndex:E}}function PN(N,F){return U1(N.document.blocks,F)}function g4(N){return A6(N.documentIndex,N.selection)}function A6(N,F){let A=N.regionIndex.get(F.anchor.regionId);if(!A)return null;let M=N.blockIndex.get(A.blockId),D=k4(N,M?.id??null,"listItem"),E=k4(N,M?.id??null,"list");if(!M||!D||!E)return null;let $=PN(N,E.id);if(!$||$.type!=="list")return null;let Z=$.items.findIndex((U)=>U.id===D.id),Y=$.items[Z];if(!Y)return null;let X=E.parentBlockId?N.blockIndex.get(E.parentBlockId)??null:null,y=X?.parentBlockId?N.blockIndex.get(X.parentBlockId)??null:null,Q=X?.type==="listItem"?PN(N,X.id):null,J=y?.type==="list"?PN(N,y.id):null,V=J?.type==="list"&&Q?J.items.findIndex((U)=>U.id===Q.id):-1;return{...WN(N,A,F),region:A,item:Y,itemChildIndices:C1(D.path),itemIndex:Z,list:$,listChildIndices:C1(E.path),parentItem:Q?.type==="listItem"?Q:null,parentItemChildIndices:X?.type==="listItem"?C1(X.path):null,parentItemIndex:V>=0?V:null,parentList:J?.type==="list"?J:null,parentListChildIndices:y?.type==="list"?C1(y.path):null,rootIndex:E.rootIndex}}function k2(N){return BM(N.documentIndex,N.selection.focus.regionId,N.selection)}function BM(N,F,A){let M=N.regionIndex.get(F);if(!M)return null;let D=N.tableCellIndex.get(M.id),E=N.blockIndex.get(M.blockId),$=E?.type==="table"?N.document.blocks[E.rootIndex]:null,Z=_M(N,M.id);if(!D||!E||!$||$.type!=="table"||!Z||Z.kind!=="tableCell")return null;return{cellIndex:D.cellIndex,documentIndex:N,inlineContainer:Z,region:M,rootIndex:E.rootIndex,rowIndex:D.rowIndex,selection:A,table:$}}function WN(N,F,A){let M=X0(N,A),D=M.start.regionId===F.id?M.start.offset:A.anchor.offset;return{atEnd:D===F.text.length,atStart:D===0,empty:F.text.length===0,offset:D}}function ON(N,F,A){return s1({checked:F,children:[F0(N)],spread:A})}function PM(N,F){let A=N.children[0];if(!A||A.type!=="paragraph")return null;return Z1(N,[F0(F),...N.children.slice(1)])}function WM(N,F){return F.reduce(Y1,W2(N))}function w0(N,F,A=0){return{childIndices:F,kind:"descendant-primary-region",offset:A,rootIndex:N}}function $0(N,F=0){return{kind:"root-primary-region",offset:F,rootIndex:N}}function h4(N,F=0){return{kind:"region",offset:F,regionId:N}}function N2(N,F,A,M=0){return{cellIndex:A,kind:"table-cell",offset:M,rootIndex:N,rowIndex:F}}function H0(N,F){return N.regionIndex.get(F)??null}function OM(N,F,A,M,D={}){let E=H0(N,F);if(!E||A>M)return null;let $=TM(A,E.text.length),Z=TM(M,E.text.length);if($===Z&&D.allowCollapsed!==!0)return null;return{endOffset:Z,region:E,selection:{anchor:{regionId:F,offset:$},focus:{regionId:F,offset:Z}},startOffset:$}}function C2(N,F){return N.regionPathIndex.get(F)??null}function g2(N,F,A,M){let D=N.tableCellRegionIndex.get(zN(F,A,M));return D?N.regionIndex.get(D)??null:null}function TM(N,F){return Math.max(0,Math.min(N,F))}function F2(N,F){let A=N.regionOrderIndex.get(F);if(A===void 0||A===0)return null;return N.regions[A-1]??null}function TN(N,F){let A=N.regionOrderIndex.get(F);if(A===void 0)return null;return N.regions[A+1]??null}function y1(N){return N.regionIds.length===0&&!R1(N)}function R1(N){return N.type==="blockquote"||N.type==="list"||N.type==="listItem"}function I4(N,F){return wM(N.blocks,F,-1)}function LN(N,F){return wM(N.blocks,F,1)}function wM(N,F,A){let M=N.findIndex((D)=>D.id===F);if(M===-1)return null;for(let D=M+A;D>=0&&D<N.length;D+=A){let E=N[D];if(R1(E))continue;return E}return null}function p4(N,F){return N.roots[F]?.regions[0]??null}function D6(N){return N.anchor.regionId===N.focus.regionId&&N.anchor.offset===N.focus.offset}function X0(N,F){let A="documentIndex"in N?N.documentIndex:N,M="documentIndex"in N?N.selection:F,D=D6(M),E=LM(A,M.anchor),$=LM(A,M.focus);if(E<=$)return{collapsed:D,end:M.focus,start:M.anchor};return{collapsed:D,end:M.anchor,start:M.focus}}function wN(N,F){if(!F)return null;if(F.kind==="root-primary-region"){let M=N.document.blocks[F.rootIndex],D=M?M6(N,M):null;return D?m2(D.id,u2(D.text,F.offset)):null}if(F.kind==="descendant-primary-region"){let M=N.document.blocks[F.rootIndex],D=M?sX(M,F.childIndices):null,E=D?M6(N,D):null;return E?m2(E.id,u2(E.text,F.offset)):null}if(F.kind==="region"){let M=H0(N,F.regionId);return M?m2(M.id,u2(M.text,F.offset)):null}if(F.kind==="block-primary-region"){let M=U1(N.document,F.blockId),D=M?M6(N,M):null;return D?m2(D.id,u2(D.text,F.offset)):null}if(F.kind==="table-cell"){let M=N.document.blocks[F.rootIndex];if(!M||M.type!=="table")return null;let D=g2(N,M.id,F.rowIndex,F.cellIndex);return D?m2(D.id,u2(D.text,F.offset)):null}let A=C2(N,F.path);if(!A)return null;if(F.kind==="region-path")return m2(A.id,u2(A.text,F.offset));return{anchor:{regionId:A.id,offset:Math.max(0,Math.min(F.startOffset,A.text.length))},focus:{regionId:A.id,offset:Math.max(0,Math.min(F.endOffset,A.text.length))}}}function m2(N,F){let A={offset:F,regionId:N};return{anchor:A,focus:A}}function LM(N,F){let A=N.regionOrderIndex.get(F.regionId);if(A===void 0)throw Error(`Unknown canvas region: ${F.regionId}`);return A*JM+F.offset}function u2(N,F){return F==="end"?N.length:Math.max(0,Math.min(F,N.length))}function sX(N,F){let A=N;for(let M of F){if(!A)return null;let D=L0(A);if(!D)return null;A=D[M]??null}return A}function M6(N,F){let A=N.blockIndex.get(F.id);if(!A)return null;let M=A.regionIds[0];if(M)return N.regionIndex.get(M)??null;let D=L0(F);if(!D)return null;for(let E of D){let $=M6(N,E);if($)return $}return null}function E6(N){if(!D6(N.selection))return null;let F=N.documentIndex.regionIndex.get(N.selection.focus.regionId);return F?{offset:N.selection.focus.offset,regionId:F.id,text:F.text}:null}function $6(N){let F=N.documentIndex.regionIndex.get(N.selection.anchor.regionId)??null,A=F?N.documentIndex.blockIndex.get(F.blockId)??null:null,M=jM(N);return{block:A?{blockId:A.id,depth:A.depth,nodeType:A.type,text:F?.text??""}:null,span:M?.link?{kind:"link",url:M.link.url}:M&&M.marks.length>0?{kind:"marks",marks:M.marks}:{kind:"none"}}}function Z6(N){let F=jM(N);return F?.kind==="image"?F:null}function jN(N){let F=X0(N.documentIndex,N.selection);if(F.start.regionId!==F.end.regionId||F.start.offset===F.end.offset)return null;return{endOffset:F.end.offset,regionId:F.start.regionId,startOffset:F.start.offset}}function Y6(N){let F=jN(N);if(!F)return[];let A=N.documentIndex.regionIndex.get(F.regionId);if(!A)return[];let M=U1(N.documentIndex.document.blocks,A.blockId);if(!M)return[];let D=u4(M,A.path,A.semanticRegionId);return D?v4(D,F.startOffset,F.endOffset):[]}function jM(N){let F=N.documentIndex.regionIndex.get(N.selection.anchor.regionId)??null;if(!F)return null;let A=N.selection.anchor.offset;return F.inlines.find((M)=>A>M.start&&A<M.end)??F.inlines.find((M)=>M.end===A)??F.inlines.find((M)=>M.start===A)??null}var y6="rgba(0, 0, 0, 0)";function CN(N,F,A){let M=CM(N),D=CM(F);return`rgba(${l4(X6(M[0],D[0],A))}, ${l4(X6(M[1],D[1],A))}, ${l4(X6(M[2],D[2],A))}, ${X6(M[3],D[3],A)})`}var x4=new Map([["rgba(0, 0, 0, 0)",[0,0,0,0]]]);function CM(N){let F=x4.get(N);if(F)return F;let A=iX(N)??oX(N)??nX(N)??x4.get("rgba(0, 0, 0, 0)");return x4.set(N,A),A}function iX(N){let F=N.trim();if(!F.startsWith("#"))return null;let A=F.slice(1);if(A.length===3)return[Number.parseInt(`${A[0]}${A[0]}`,16),Number.parseInt(`${A[1]}${A[1]}`,16),Number.parseInt(`${A[2]}${A[2]}`,16),1];if(A.length===6)return[Number.parseInt(A.slice(0,2),16),Number.parseInt(A.slice(2,4),16),Number.parseInt(A.slice(4,6),16),1];return null}function oX(N){let F=/^rgb\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec(N.trim());if(!F)return null;return[Number(F[1]),Number(F[2]),Number(F[3]),1]}function nX(N){let F=/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec(N.trim());if(!F)return null;return[Number(F[1]),Number(F[2]),Number(F[3]),Number(F[4])]}function X6(N,F,A){return N+(F-N)*A}function l4(N){return Math.round(N)}var tX=300,eX=180,Ny=1000,Fy=500,Ay=140,My=0.1,Dy=0.9,Ey=2,$y=2;function RN(N){switch(N.kind){case"active-block-flash":return tX;case"text-fade":return eX;case"text-highlight":return Ny;case"block-pulse":return Fy;case"text-pulse":return Ay}}function d4(N,F){let A=F??Yy();return N.animations.some((M)=>A-M.startedAt<RN(M))}function RM(N,F){return r4(N,F,"text-highlight",(A)=>A.regionPath)}function bM(N,F){return IM(N,F,"active-block-flash",(A)=>A.blockPath)}function fM(N,F){return r4(N,F,"text-fade",(A)=>A.regionPath)}function vM(N,F){return r4(N,F,"text-pulse",(A)=>A.regionPath)}function kM(N,F){return IM(N,F,"block-pulse",(A)=>A.blockPath)}function mM(N,F,A){let M=new Set([N,F]);for(let D of A){if(D.endOffset<=N||D.startOffset>=F)continue;M.add(Math.max(N,D.startOffset)),M.add(Math.min(F,D.endOffset))}return[...M].sort((D,E)=>D-E)}function a4(N,F,A){return N.find((M)=>M.startOffset<A&&M.endOffset>F)??null}function uM(N,F){return CN(N,y6,F.progress)}function Q6(N,F){return CN(N,y6,F.progress)}function gM(N,F){return CN(F.insertHighlightText,y6,N.progress)}function hM(N){let F=Math.min(1,N.progress*Ey);return My+Dy*Zy(F)}function bN(N,F,A){let M=Math.max(0,F.progress*$y-1);return CN(A.insertHighlightText,N,M)}function r4(N,F,A,M){let D=new Map;for(let E of N.animations){if(E.kind!==A)continue;let $=RN(E),Z=F-E.startedAt;if(Z>=$)continue;let Y={...E,progress:Math.max(0,Math.min(1,Z/$))},X=M(E),y=D.get(X);if(y)y.push(Y);else D.set(X,[Y])}return D}function IM(N,F,A,M){let D=new Map;for(let E of N.animations){if(E.kind!==A)continue;let $=RN(E),Z=F-E.startedAt;if(Z>=$)continue;D.set(M(E),{...E,progress:Math.max(0,Math.min(1,Z/$))})}return D}function Zy(N){return 1-(1-N)*(1-N)*(1-N)}function Yy(){return typeof performance<"u"?performance.now():Date.now()}function pM(N,F,A=V6()){if(!F)return N;switch(F.kind){case"text-highlight":return F.endOffset>F.startOffset?J6(N,{...F,startedAt:A}):N;case"text-fade":return F.text.length>0?J6(N,{...F,startedAt:A}):N;case"text-pulse":case"block-pulse":return J6(N,{...F,startedAt:A})}}function xM(N,F,A=V6()){return J6(N,{blockPath:F,kind:"active-block-flash",startedAt:A})}function c4(N,F){return N.filter((A)=>A.startedAt+RN(A)>F)}function V6(){return typeof performance<"u"?performance.now():Date.now()}function lM(N){let F=Xy(N);return(F?N.documentIndex.blockIndex.get(F.blockId)??null:null)?.path??""}function Xy(N){return N.documentIndex.regionIndex.get(N.selection.focus.regionId)??null}function J6(N,F){let A=c4(N.animations,F.startedAt);return{...N,animations:[...A,F]}}function h2(N,F,A,M){return i4(I2(N.inlines,F,A,M))}function I2(N,F,A,M){let E=yy(N,F,A,{didInsert:!1,generatedInlineCount:0,replacementText:M});return qy(Ky(E))}function i4(N){let F=[];for(let A=0;A<N.length;A+=1){let M=N[A];if(M.link){let E=[],$=M.link;while(A<N.length&&o4(N[A].link,$)){let Z=aM(N[A]);if(Z)E.push(Z);A+=1}if(A-=1,E.length>0)F.push(c1({children:W0(E),title:$.title,url:$.url}));continue}let D=aM(M);if(D)F.push(D)}return W0(F)}function yy(N,F,A,M){let D=[];for(let[E,$]of N.entries()){if(!M.didInsert&&F===A&&F===$.start)s4(D,M,dM(N[E-1]??null,$));if(A<=$.start||F>=$.end){D.push(U6($));continue}let Z=Math.max(0,F-$.start),Y=Math.min($.text.length,A-$.start),X=!M.didInsert&&M.replacementText.length>0?M.replacementText:"",y=Qy($,Z,Y,X,M);if(Z!==Y||X.length>0)M.didInsert=!0;D.push(...y)}if(!M.didInsert)s4(D,M,dM(N.at(-1)??null,null));return D}function Qy(N,F,A,M,D){switch(N.kind){case"text":case"code":case"raw":return Jy(N,F,A,M);case"lineBreak":return Vy(N,F,A,M,D);case"image":case"mention":return Uy(N,F,A,M)}}function Jy(N,F,A,M){let D=N.text.slice(0,F)+M+N.text.slice(A);return D.length>0?[{...U6(N),text:D}]:[]}function Vy(N,F,A,M,D){if(F===A)return[U6(N)];let E=[];if(M.length>0)s4(E,D,N.link);return E}function Uy(N,F,A,M){if(F===0&&A===N.text.length)return M.length>0?[rM(M,N.link,0)]:[];return[U6(N)]}function s4(N,F,A){if(F.replacementText.length===0){F.didInsert=!0;return}N.push(rM(F.replacementText,A,F.generatedInlineCount)),F.generatedInlineCount+=1,F.didInsert=!0}function rM(N,F,A){return{id:`generated:${A}`,image:null,inlineCode:!1,kind:"text",link:F,marks:[],mention:null,originalType:null,text:N}}function dM(N,F){return N?.link&&F?.link&&o4(N.link,F.link)?N.link:null}function U6(N){return{id:N.id,image:N.image,inlineCode:N.inlineCode,kind:N.kind,link:N.link,marks:N.marks,mention:N.mention,originalType:N.originalType,text:N.text}}function qy(N){let F=[],A=0;for(let M of N){let D=A,E=D+M.text.length;F.push({...M,end:E,start:D}),A=E}return F}function Ky(N){let F=[];for(let A of N){let M=F.at(-1);if(M&&Sy(M,A)){F[F.length-1]={...M,text:M.text+A.text};continue}F.push(A)}return F}function Sy(N,F){return N.kind===F.kind&&N.inlineCode===F.inlineCode&&o4(N.link,F.link)&&Hy(N.image,F.image)&&_y(N.mention,F.mention)&&N.originalType===F.originalType&&N.marks.join(",")===F.marks.join(",")}function aM(N){switch(N.kind){case"lineBreak":return $1();case"image":return N.image?Gy(N.image):null;case"mention":return N.mention?zy(N.mention):null;case"code":return W1(N.text);case"text":return N.text.length>0?f0(N.text,N.marks):null;case"raw":return hF({originalType:N.originalType??"raw",source:N.text})}}function Gy(N){return O1({alt:N.alt,title:N.title,url:N.url,width:N.width})}function zy(N){return B2({name:N.name,userId:N.userId})}function o4(N,F){return N?.url===F?.url&&N?.title===F?.title}function Hy(N,F){return N?.url===F?.url&&N?.title===F?.title&&N?.alt===F?.alt&&N?.width===F?.width}function _y(N,F){return N?.userId===F?.userId&&N?.name===F?.name}function fN(N,F,A){if(N.type==="table")return null;if(N.id===F.blockId)return By(N,F,A);return cM(N,(M)=>Wy(M,F,A))}function vN(N,F,A){if(N.type==="table")return null;if(N.id===F.blockId)return Py(N,F,A);return cM(N,(M)=>Oy(M,F,A))}function A2(N,F){if(N.id===F.blockId)return!0;let A=L0(N);return A!==null&&A.some((M)=>A2(M,F))}function By(N,F,A){if(A===0)return null;switch(N.type){case"heading":case"paragraph":return m0(N,h2(F,A,F.text.length,""));case"code":return UN(N,F.text.slice(0,A));case"raw":return qN(N,F.text.slice(0,A));default:return null}}function Py(N,F,A){if(A===F.text.length)return null;switch(N.type){case"heading":case"paragraph":return m0(N,h2(F,0,A,""));case"code":return UN(N,F.text.slice(A));case"raw":return qN(N,F.text.slice(A));default:return null}}function cM(N,F){let A=L0(N);return A?w1(N,F(A)):null}function Wy(N,F,A){let M=N.findIndex(($)=>A2($,F));if(M===-1)return[];let D=N.slice(0,M),E=fN(N[M],F,A);return E?[...D,E]:D}function Oy(N,F,A){let M=N.findIndex(($)=>A2($,F));if(M===-1)return[];let D=N.slice(M+1),E=vN(N[M],F,A);return E?[E,...D]:D}function nM(N,F,A){let M=[],D=0,E={childIndices:[],offset:0},$="",Z=N!==null;if(N)M.push(N),E=sM(N);let Y=0;if(N&&F.length>0){let X=F[0];if(q6(N)&&X.type==="paragraph"){let y=n4(N,N.children,X.children);M[M.length-1]=y,E={childIndices:[],offset:y.plainText.length},Y=1,$=X.plainText}else if(iM(N,X)){let y=oM(N,X);M[M.length-1]=y,E=tM(y),Y=1}}for(let X=Y;X<F.length;X+=1){let y=F[X];M.push(y),D=M.length-1,E=sM(y)}if(A){let X=M.length-1,y=M[X]??null,Q=Y>=F.length&&N!==null,J=null;if(y){if(!Q&&y.type==="paragraph"&&q6(A)){if(J=n4(A,y.children,A.children),N===null&&F.length===1)Z=!0,$=y.plainText}else if(Q&&q6(y)&&q6(A))J=n4(y,y.children,A.children);else if(iM(y,A))J=oM(y,A),E={childIndices:[L0(y).length-1],offset:"end"}}else if(N===null&&F.length===0)Z=!0;if(J)M[X]=J;else M.push(A)}return{blocks:M,caretLocalIndex:D,caretChildIndices:E.childIndices,caretOffset:E.offset,startRegionInsertedText:$,startRegionPreservedAtRoot0:Z}}function sM(N){return L0(N)?tM(N):{childIndices:[],offset:N.plainText.length}}function tM(N){return{childIndices:[L0(N).length-1],offset:"end"}}function n4(N,F,A){return m0(N,W0([...F,...A]))}function q6(N){return N!==null&&(N.type==="heading"||N.type==="paragraph")}function iM(N,F){return N.type===F.type&&L0(N)!==null}function oM(N,F){let A=L0(N),M=L0(F);return w1(N,[...A,...M])}function ND(N,F,A){let M=X0(N,F);if(M.start.regionId===M.end.regionId)return Ty(N,M,A);let D=A.length>0?[F0(A)]:[];return t4(N,F,D)}function t4(N,F,A){let M=X0(N,F),D=H0(N,M.start.regionId),E=H0(N,M.end.regionId);if(!D||!E)throw Error("Unknown selection endpoints.");let $=N.document.blocks[D.rootIndex],Z=N.document.blocks[E.rootIndex];if(!$||!Z)throw Error("Unknown root blocks for selection.");let Y=fN($,D,M.start.offset),X=vN(Z,E,M.end.offset),y=nM(Y,A,X),Q=y.blocks.length>0?y.blocks:[F0("")],J=D.rootIndex,V=E.rootIndex-D.rootIndex+1,U=e1(N.document,J,V,Q),S=f2(N,U,J,V),q=D===E?M.end.offset:D.text.length;return{documentIndex:y.startRegionPreservedAtRoot0?FD(N,S,D,M.start.offset,q,y.startRegionInsertedText):S,selection:w0(J+y.caretLocalIndex,y.caretChildIndices,y.caretOffset)}}function Ty(N,F,A){let M=H0(N,F.start.regionId);if(!M)throw Error(`Unknown region: ${F.start.regionId}`);let D=tF(N,M.blockId,(Y)=>Ly(Y,M,F.start.offset,F.end.offset,A));if(!D)throw Error(`Failed to replace block for region: ${M.id}`);let E=f2(N,D,M.rootIndex,1),$=FD(N,E,M,F.start.offset,F.end.offset,A),Z=C2($,M.path);if(!Z)throw Error(`Failed to remap region after replacement: ${M.path}`);return{documentIndex:$,selection:h4(Z.id,F.start.offset+A.length)}}function Ly(N,F,A,M,D){switch(N.type){case"heading":case"paragraph":return m0(N,h2(F,A,M,D));case"code":return UN(N,eM(F,A,M,D));case"table":return wy(N,F,A,M,D);case"raw":return qN(N,eM(F,A,M,D));default:throw Error(`Region text replacement is not supported for block type: ${N.type}`)}}function wy(N,F,A,M,D){let E=F.tableCellPosition?.rowIndex,$=F.tableCellPosition?.cellIndex;if(E===void 0||$===void 0)throw Error(`Unable to resolve table cell position for region: ${F.id}`);let Z=h2(F,A,M,D),Y=N.rows.map((X,y)=>{if(y!==E)return X;let Q=X.cells.map((J,V)=>V===$?T1(Z):J);return{...X,cells:Q}});return a0(N,Y)}function eM(N,F,A,M){return I2(N.inlines,F,A,M).map((D)=>D.text).join("")}function FD(N,F,A,M,D,E){if(N.document.comments.length===0)return F;let $=T4(N,F,A,M,D,E);return $===F.document.comments?F:nF(F,{...F.document,comments:$})}function p2(N){let F=b2(N),A=ED(F);return{animations:[],documentIndex:F,future:[],history:[],selection:{anchor:A,focus:A}}}function Q1(N){let F=u0(N.documentIndex);return w2(FM(N.documentIndex.document.blocks),F.threads,N.documentIndex.document.frontMatter)}function e4(N,F){if(!F)return null;let A=jy(N,F);return A?pM(A,F.animation):null}function jy(N,F){switch(F.kind){case"keep-state":return N;case"set-selection":return O0(N,F.selection);case"replace-block":{let A=tF(N.documentIndex,F.blockId,()=>F.block);return A?kN(N,b2(A),F.selection??null):null}case"splice-blocks":{let A=e1(N.documentIndex.document,F.rootIndex,F.count??1,F.blocks);return kN(N,b2(A),F.selection??null)}case"splice-text":{let A=ND(N.documentIndex,F.range??N.selection,F.text);return kN(N,A.documentIndex,F.selection??A.selection)}case"splice-fragment":{let A=t4(N.documentIndex,N.selection,F.blocks);return kN(N,A.documentIndex,A.selection)}case"splice-comments":{let A=tA(N.documentIndex.document,F.index,F.count,F.threads);return kN(N,nF(N.documentIndex,A),null)}}}function kN(N,F,A){let M=Cy(N,F),D=wN(M.documentIndex,A)??N.selection,E=$D(N,M,D);return O0(M,D,E)}function O0(N,F,A){let M="regionId"in F?{anchor:K6(N.documentIndex,F),focus:K6(N.documentIndex,F)}:{anchor:K6(N.documentIndex,F.anchor),focus:K6(N.documentIndex,F.focus)},D={...N,selection:M};return A??$D(N,D)?xM(D,lM(D)):D}function I0(N,F,A,M){let D={regionId:F,offset:A};return O0(N,M?{anchor:N.selection.anchor,focus:D}:D)}function Cy(N,F){let A=ED(F);return{animations:c4(N.animations,V6()),documentIndex:F,future:[],history:[...N.history,{document:N.documentIndex.document,selection:N.selection}],selection:{anchor:A,focus:A}}}function N8(N){let F=N.history.at(-1);if(!F)return N;return DD(F,{future:[MD(N),...N.future],history:N.history.slice(0,-1)})}function F8(N){let F=N.future[0];if(!F)return N;return DD(F,{future:N.future.slice(1),history:[...N.history,MD(N)]})}function MD(N){return{document:N.documentIndex.document,selection:N.selection}}function DD(N,F){return{animations:[],documentIndex:b2(N.document),future:F.future,history:F.history,selection:N.selection}}function ED(N){return N.regions[0]?{regionId:N.regions[0].id,offset:0}:{regionId:"empty",offset:0}}function K6(N,F){let A=H0(N,F.regionId);if(!A)return F;return{regionId:A.id,offset:Math.max(0,Math.min(F.offset,A.text.length))}}function $D(N,F,A){let M=AD(N.documentIndex,N.selection),D=AD(F.documentIndex,A??F.selection);return D!==null&&D!==M}function AD(N,F){let A=N.regionIndex.get(F.focus.regionId),M=A?N.blockIndex.get(A.blockId)??null:null;if(!A||!M?.path)return null;return M.type==="table"?`cell:${A.path}`:`block:${M.path}`}function A8(N,F,A){if(F===A)return null;let M=Ry(N.children,F,A);return M!==N.children&&M.length>0?BN(N,M,F,A):null}function Ry(N,F,A){let M=ZD(N,F,A);if(M){let E=M.code.length>0?[f0(M.code,[])]:[];return eF(N,F,A,E)}let D=R4(N,F,A);if(D.length===0)return N;return eF(N,F,A,[W1(D)])}function ZD(N,F,A){let M=0;for(let D of N){let E=g0(D),$=M,Z=$+E;if(M=Z,F===$&&A===Z&&D.type==="code")return D;if(D.type==="link"){let Y=ZD(D.children,Math.max(0,F-$),Math.min(E,A-$));if(Y)return Y}}return null}function M8(N,F,A){let{image:M}=F,D=h0(N,F.start,F.end,[O1({alt:M.alt,title:M.title,url:M.url,width:A})]);return{kind:"replace-block",block:D.block,blockId:D.blockId}}function D8(N,F,A,M){let D=b4(N.children,F,A);if(D.length===0)return null;return h0(N,F,A,[c1({children:D,title:null,url:M})])}function E8(N,F,A,M){let D=YD(N.children,F,A);if(!D)return null;return h0(N,F,A,[c1({children:D.children,title:D.title,url:M})])}function $8(N,F,A){let M=YD(N.children,F,A);if(!M)return null;return h0(N,F,A,M.children)}function YD(N,F,A){let M=0;for(let D of N){let E=g0(D);if(D.type==="link"&&M===F&&M+E===A)return D;M+=E}return null}function Z8(N,F,A,M=""){return{kind:"replace-block",...h0(N.inlineContainer,N.startOffset,N.endOffset,[B2({name:A,userId:F}),...M.length>0?[f0(M)]:[]])}}function x2(N,F){let A=F(N.inlineContainer,N.startOffset,N.endOffset);return A?{kind:"replace-block",block:A.block,blockId:A.blockId,selection:A.selection}:null}function Y8(N,F){return{kind:"replace-block",...h0(N.inlineContainer,N.startOffset,N.endOffset,[F])}}function XD(N,F){return{kind:"replace-block",...h0(N.inlineContainer,N.startOffset,N.endOffset,F)}}function S6(N){return by.test(N)}var by=/[\uFE0F\u{1F1E6}-\u{1F1FF}\p{Extended_Pictographic}]/u;function yD(N,F,A){if(A===".")return fy(N,F);return M2(N,F,A)}function M2(N,F,A){if(A.length===0||S6(A))return;let M=JD(N,F);if(!M)return;return X8(M.region,M.normalized.start.offset,A)}function X8(N,F,A){if(A.length===0||S6(A))return;return{endOffset:F+A.length,kind:"text-highlight",regionPath:N.path,startOffset:F}}function QD(N,F,A){let M=N.text.slice(F,A);if(M.length===0||S6(M))return;return N.inlines.some((E)=>E.start<=F&&E.end>=A&&E.kind==="text"&&E.link===null&&E.marks.length===0)?{kind:"text-fade",regionPath:N.path,startOffset:F,text:M}:void 0}function fy(N,F){let A=JD(N,F);if(!A)return;return{kind:"text-pulse",offset:A.normalized.start.offset,regionPath:A.region.path}}function JD(N,F){let A=X0(N,F);if(A.start.regionId!==A.end.regionId)return null;let M=H0(N,A.start.regionId);return M?{normalized:A,region:M}:null}var vy={"(":")","[":"]","{":"}"};function VD(N,F,A){if(A.length!==1)return null;let M=vy[A];if(!M||!D6(F))return null;let D=N.regionIndex.get(F.focus.regionId);if(!D)return null;let E=`${A}${M}`;return{animation:M2(N,F,E),kind:"splice-text",selection:{kind:"region-path",offset:F.focus.offset+A.length,path:D.path},text:E}}function UD(N,F,A){if(F.anchor.regionId!==F.focus.regionId)return null;let M=N.regionIndex.get(F.anchor.regionId);if(!M)return null;let D=my(N,F,M);if(!D)return null;let{start:E,end:$}=ky(N,F);return uy(M,A,E,$,D)}function ky(N,F){if(F.anchor.offset===F.focus.offset)return{start:F.anchor.offset,end:F.anchor.offset};let A=X0(N,F);return{start:A.start.offset,end:A.end.offset}}function my(N,F,A){switch(A.blockType){case"heading":{let M=v2(N,F);return M?.block.type==="heading"?{kind:"heading",rootIndex:M.rootIndex}:null}case"paragraph":{let M=A6(N,F);if(M)return{kind:"list-item",item:M};let D=v2(N,F);return D?.block.type==="paragraph"?{kind:"root-paragraph",rootIndex:D.rootIndex}:null}default:return null}}function uy(N,F,A,M,D){if(D.kind==="root-paragraph"&&!gy(N,F,M))return null;let E=N.text.slice(0,A)+F+N.text.slice(M);switch(D.kind){case"root-paragraph":return y8(hy,E,D);case"heading":return y8(Iy,E,D);case"list-item":return y8(py,E,D.item)}}function gy(N,F,A){let M=A<N.text.length?N.text:F;return M.length>0&&/\s/.test(M[M.length-1])}function y8(N,F,A){for(let{pattern:M,apply:D}of N){let E=M.exec(F);if(E)return D(E,A)}return null}var hy=[{pattern:l2(/(?:[-+*]\s+)?\[[ xX]?\]/,{allowIndent:!0}),apply:(N,{rootIndex:F})=>Q8(F,{checked:N[1].toLowerCase().includes("x"),ordered:!1,start:null})},{pattern:l2(/[-+*]/,{allowIndent:!0}),apply:(N,{rootIndex:F})=>Q8(F,{checked:null,ordered:!1,start:null})},{pattern:l2(/\d+\./,{allowIndent:!0}),apply:(N,{rootIndex:F})=>Q8(F,{checked:null,ordered:!0,start:Number(N[1].slice(0,-1))})},{pattern:l2(/#{1,6}/,{allowIndent:!1}),apply:(N,{rootIndex:F})=>({kind:"splice-blocks",blocks:[_2({depth:N[1].length,text:""})],rootIndex:F,selection:$0(F)})},{pattern:l2(/>/,{allowIndent:!1}),apply:(N,{rootIndex:F})=>({kind:"splice-blocks",blocks:[d0([F0("")])],rootIndex:F,selection:w0(F,[0])})},{pattern:l2(/---/,{allowIndent:!1}),apply:(N,{rootIndex:F})=>({kind:"splice-blocks",blocks:[IF(),F0("")],rootIndex:F,selection:$0(F+1)})}],Iy=[{pattern:G6(/#{1,6}/),apply:(N,{rootIndex:F})=>({kind:"splice-blocks",blocks:[_2({depth:N[1].length,text:N[2]})],rootIndex:F,selection:$0(F)})}],py=[{pattern:G6(/\d+\./),apply:(N,F)=>J8(N,F,{ordered:!0,start:1,checked:F.item.checked})},{pattern:G6(/\[[ xX]?\]/),apply:(N,F)=>J8(N,F,{ordered:!1,start:null,checked:N[1].toLowerCase().includes("x")})},{pattern:G6(/[-+*]/),apply:(N,F)=>J8(N,F,{ordered:!1,start:null,checked:null})}];function l2(N,F){let A=F.allowIndent?"\\s*":"";return new RegExp(`^${A}(${N.source})\\s$`)}function G6(N){return new RegExp(`^\\s*(${N.source})\\s(.+)$`)}function Q8(N,F){return{kind:"splice-blocks",blocks:[i1({items:[s1({checked:F.checked,children:[F0("")],spread:!1})],ordered:F.ordered,spread:!1,start:F.start})],rootIndex:N,selection:w0(N,[0,0])}}function J8(N,F,A){let M=PM(F.item,N[2]);if(!M)return null;return{kind:"replace-block",block:z0(F.list,F.list.items.map((D,E)=>E===F.itemIndex?{...M,checked:A.checked}:D),{ordered:A.ordered,start:A.start}),blockId:F.list.id,selection:w0(F.rootIndex,[...F.listChildIndices,F.itemIndex,0])}}function qD(N,F,A){return VD(N,F,A)??UD(N,F,A)??{animation:yD(N,F,A),kind:"splice-text",text:A}}function KD(N,F){let A=N.region.text.length,M=N.region.text.slice(0,F),D=N.region.text.slice(F),E=F===0&&A>0?N.rootIndex:N.rootIndex+1;return{kind:"splice-blocks",blocks:HD(N.block,M,D,F,A),rootIndex:N.rootIndex,selection:$0(E)}}function SD(N,F){let A=N.region.text,M=A.slice(0,F),D=A.slice(F),E=HD(N.block,M,D,F,A.length),$=F===0?N.blockChildIndices:[...N.blockChildIndices.slice(0,-1),N.blockChildIndices.at(-1)+1];return{kind:"splice-blocks",blocks:[d0([...N.quote.children.slice(0,N.childIndex),...E,...N.quote.children.slice(N.childIndex+1)])],rootIndex:N.rootIndex,selection:w0(N.rootIndex,$)}}function GD(N,F){if(F!==0||N.region.text.length!==0||N.block.type!=="paragraph")return null;let A=N.quote.children.slice(0,N.childIndex),M=N.quote.children.slice(N.childIndex+1),D=[];if(A.length>0)D.push(d0(A));if(D.push(F0("")),M.length>0)D.push(d0(M));return{kind:"splice-blocks",blocks:D,rootIndex:N.rootIndex,selection:$0(N.rootIndex+(A.length>0?1:0))}}function V8(N,F){if(N.block.type!=="heading")return null;let A=Math.max(1,Math.min(6,N.block.depth+F));if(A===N.block.depth)return{kind:"keep-state"};return{kind:"splice-blocks",blocks:[_2({depth:A,text:N.block.plainText})],rootIndex:N.rootIndex,selection:$0(N.rootIndex,N.offset)}}function zD(N){if(N.block.type!=="paragraph")return null;return{kind:"splice-blocks",blocks:[d0([N.block])],rootIndex:N.rootIndex,selection:w0(N.rootIndex,[0],N.offset)}}function HD(N,F,A,M,D){if(M===0)return[F0(""),N];if(M===D)return[N,F0("")];return[N.type==="heading"?_2({depth:N.depth,text:F}):F0(F),F0(A)]}function mN(N,F,A,M=0){return w0(N,[...F,A,0],M)}function U8(N,F){let A=N.region.text,M=N.item,D=typeof M.checked==="boolean"?!1:M.checked;if(F===0){let X=ON("",D,M.spread);return{kind:"replace-block",block:z0(N.list,[...N.list.items.slice(0,N.itemIndex),X,M,...N.list.items.slice(N.itemIndex+1)]),blockId:N.list.id,animation:H6(z6(X,N.rootIndex,[...N.listChildIndices,N.itemIndex])),selection:mN(N.rootIndex,N.listChildIndices,N.itemIndex)}}if(F===A.length){let X=ON("",D,M.spread);return{kind:"replace-block",block:z0(N.list,[...N.list.items.slice(0,N.itemIndex+1),X,...N.list.items.slice(N.itemIndex+1)]),blockId:N.list.id,animation:H6(z6(X,N.rootIndex,[...N.listChildIndices,N.itemIndex+1])),selection:mN(N.rootIndex,N.listChildIndices,N.itemIndex+1)}}let E=A.slice(0,F),$=A.slice(F),Z=ON($,D,M.spread),Y=Z1(M,[F0(E)]);return{kind:"replace-block",block:z0(N.list,[...N.list.items.slice(0,N.itemIndex),Y,Z,...N.list.items.slice(N.itemIndex+1)]),blockId:N.list.id,animation:H6(z6(Z,N.rootIndex,[...N.listChildIndices,N.itemIndex+1])),selection:mN(N.rootIndex,N.listChildIndices,N.itemIndex+1)}}function _D(N,F){if(F!==0||N.region.text.length!==0)return U8(N,F);if(N.parentItem&&N.parentItemIndex!==null&&N.parentItemChildIndices&&N.parentList&&N.parentListChildIndices)return xy(N);let A=N.list.items.slice(0,N.itemIndex),M=N.list.items.slice(N.itemIndex+1),D=[];if(A.length>0)D.push(z0(N.list,A));if(D.push(F0("")),M.length>0)D.push(z0(N.list,M));return{kind:"splice-blocks",blocks:D,rootIndex:N.rootIndex,selection:$0(N.rootIndex+(A.length>0?1:0))}}function BD(N){if(N.itemIndex===0)return null;let F=N.list.items[N.itemIndex-1];if(!F)return null;let A=ly(F,N.item,N);return{kind:"replace-block",block:z0(N.list,N.list.items.flatMap((M,D)=>{if(D===N.itemIndex-1)return[A.item];if(D===N.itemIndex)return[];return[M]})),blockId:N.list.id,selection:w0(N.rootIndex,A.regionChildIndices)}}function PD(N){return WD(N,()=>({insertedItem:N.item}))}function q8(N,F){let A=N.itemIndex+F;if(A<0||A>=N.list.items.length)return null;let M=[...N.list.items],[D]=M.splice(N.itemIndex,1);if(!D)return null;return M.splice(A,0,D),{kind:"replace-block",block:z0(N.list,M),blockId:N.list.id,selection:mN(N.rootIndex,N.listChildIndices,A)}}function xy(N){return WD(N,(F)=>{let A=typeof F.checked==="boolean"?!1:F.checked;return{insertedItem:ON("",A,F.spread),trackInsertedPath:!0}})}function WD(N,F){if(!N.parentItem||N.parentItemIndex===null||!N.parentItemChildIndices||!N.parentList||!N.parentListChildIndices)return null;let A=N.list.items.filter((Y,X)=>X!==N.itemIndex),M=N.parentItem.children.flatMap((Y)=>{if(Y.type!=="list"||Y.id!==N.list.id)return[Y];if(A.length===0)return[];return[z0(N.list,A)]}),D=Z1(N.parentItem,M),{insertedItem:E,trackInsertedPath:$=!1}=F(N.parentItem),Z=$?z6(E,N.rootIndex,[...N.parentListChildIndices,N.parentItemIndex+1]):void 0;return{kind:"replace-block",block:z0(N.parentList,[...N.parentList.items.slice(0,N.parentItemIndex),D,E,...N.parentList.items.slice(N.parentItemIndex+1)]),blockId:N.parentList.id,animation:H6(Z),selection:mN(N.rootIndex,N.parentListChildIndices,N.parentItemIndex+1)}}function z6(N,F,A){return typeof N.checked==="boolean"?void 0:WM(F,A)}function H6(N){return N?{blockPath:N,kind:"block-pulse"}:void 0}function ly(N,F,A){let M=N.children.findIndex((E)=>E.type==="list"&&E.ordered===A.list.ordered&&E.start===A.list.start);if(M>=0){let E=N.children[M];if(!E||E.type!=="list")return{item:N,regionChildIndices:[...A.listChildIndices,A.itemIndex-1,0]};return{item:Z1(N,N.children.map(($,Z)=>Z===M?z0(E,[...E.items,F]):$)),regionChildIndices:[...A.listChildIndices,A.itemIndex-1,M,E.items.length,0]}}let D=i1({items:[F],ordered:A.list.ordered,spread:A.list.spread,start:A.list.start});return{item:Z1(N,[...N.children,D]),regionChildIndices:[...A.listChildIndices,A.itemIndex-1,N.children.length,0,0]}}function OD(N,F,A){let M=v2(N,F),D=Math.max(2,A);if(!M||M.block.type!=="paragraph"||M.block.plainText.length>0||F.anchor.regionId!==F.focus.regionId||F.anchor.offset!==0||F.focus.offset!==0)return null;return{kind:"splice-blocks",blocks:[o1({rows:Array.from({length:2},()=>S8(D))})],rootIndex:M.rootIndex,selection:N2(M.rootIndex,0,0)}}function K8(N,F){let A=F<0?cy(N.table,N.rowIndex,N.cellIndex):sy(N.table,N.rowIndex,N.cellIndex);if(!A)return F>0&&iy(N.table,N.rowIndex,N.cellIndex)?dy(N):{kind:"keep-state"};let M=N.table.rows[A.rowIndex]?.cells[A.cellIndex];if(!M)return{kind:"keep-state"};return{kind:"set-selection",selection:ry(N.documentIndex,N.selection,N.table,A.rowIndex,A.cellIndex,Math.min(N.selection.focus.offset,M.plainText.length))}}function TD(N){let F=Math.min(N.selection.anchor.offset,N.selection.focus.offset),A=Math.max(N.selection.anchor.offset,N.selection.focus.offset),M=h0(N.inlineContainer,F,A,[$1()]);return{kind:"replace-block",block:M.block,blockId:M.blockId,selection:M.selection}}function LD(N,F){let A=F==="left"?N.cellIndex:N.cellIndex+1;return d2(N,o1({align:fD(N.table.align,A,0,[null]),rows:N.table.rows.map((M)=>P2(ay(M.cells,A,0,[bD()])))}),N2(N.rootIndex,N.rowIndex,A))}function wD(N){let F=Math.max(0,...N.table.rows.map((A)=>A.cells.length));if(F<=1)return null;return d2(N,o1({align:fD(N.table.align,N.cellIndex,1,[]),rows:N.table.rows.map((A)=>P2(A.cells.filter((M,D)=>D!==N.cellIndex)))}),N2(N.rootIndex,N.rowIndex,Math.min(N.cellIndex,F-2)))}function jD(N,F){let A=F==="above"?N.rowIndex:N.rowIndex+1,M=Math.max(1,...N.table.rows.map((D)=>D.cells.length));return d2(N,a0(N.table,[...N.table.rows.slice(0,A),S8(M),...N.table.rows.slice(A)]),N2(N.rootIndex,A,Math.min(N.cellIndex,M-1)))}function CD(N){if(N.table.rows.length<=1)return null;let F=N.table.rows.filter((D,E)=>E!==N.rowIndex),A=Math.min(N.rowIndex,F.length-1),M=F[A]?.cells.length??1;return d2(N,a0(N.table,F),N2(N.rootIndex,A,Math.min(N.cellIndex,M-1)))}function RD(N){return d2(N,F0(""),$0(N.rootIndex))}function S8(N){return P2(Array.from({length:N},()=>bD()))}function bD(){return T1([])}function dy(N){let F=N.table.rows.length,A=Math.max(1,...N.table.rows.map((M)=>M.cells.length));return d2(N,a0(N.table,[...N.table.rows,S8(A)]),N2(N.rootIndex,F,0))}function d2(N,F,A){return{kind:"replace-block",block:F,blockId:N.table.id,selection:A}}function ay(N,F,A,M){return[...N.slice(0,F),...M,...N.slice(F+A)]}function fD(N,F,A,M){return[...N.slice(0,F),...M,...N.slice(F+A)]}function ry(N,F,A,M,D,E){let $=g2(N,A.id,M,D);if(!$)return F;return{anchor:{regionId:$.id,offset:E},focus:{regionId:$.id,offset:E}}}function cy(N,F,A){if(A>0)return{cellIndex:A-1,rowIndex:F};if(F>0){let M=N.rows[F-1];if(!M||M.cells.length===0)return null;return{cellIndex:M.cells.length-1,rowIndex:F-1}}return null}function sy(N,F,A){let M=N.rows[F];if(!M)return null;if(A+1<M.cells.length)return{cellIndex:A+1,rowIndex:F};let D=N.rows[F+1];if(!D||D.cells.length===0)return null;return{cellIndex:0,rowIndex:F+1}}function iy(N,F,A){let M=N.rows[F];return Boolean(M&&F===N.rows.length-1&&A===M.cells.length-1)}function vD(N){switch(N.kind){case"code":return{kind:"splice-text",text:`
|
|
15
|
-
`};case"tableCell":return TD(N);case"listItem":return _D(N,N.offset)??U8(N,N.offset);case"blockquoteTextBlock":return GD(N,N.offset)??SD(N,N.offset);case"rootTextBlock":return KD(N,N.offset);case"unsupported":return null}}function kD(N,F){let A=X0(N,F);if(A.collapsed)return null;let M=H0(N,A.start.regionId),D=H0(N,A.end.regionId);if(!M||!D)return null;let E=N.document.blocks[M.rootIndex],$=N.document.blocks[D.rootIndex];if(!E||!$)return null;if(M===D)return{kind:"single-region",normalized:A,region:M,root:E,wholeRegion:A.start.offset===0&&A.end.offset===M.text.length};return{kind:"multi-region",normalized:A,startRegion:M,endRegion:D,sameRoot:M.rootIndex===D.rootIndex,startRoot:E,endRoot:$}}function G8(N,F){let A=kD(N,F);if(!A)return null;switch(A.kind){case"single-region":if(!A.wholeRegion||A.region.blockType==="table"){let D=ny(A.region,A.normalized.start.offset,A.normalized.end.offset);return oy(D)}let M=uD(A.root,A.region);return M?mD([M]):null;case"multi-region":{let D=A.sameRoot?ty(N,A.startRoot,A.startRegion,A.normalized.start.offset,A.endRegion,A.normalized.end.offset):FQ(N,A.startRegion,A.normalized.start.offset,A.endRegion,A.normalized.end.offset);return D.length>0?mD(D):null}}}function oy(N){if(N.length===0)return null;if(X4(N))return{kind:"text",text:V0(N)};return{kind:"inlines",inlines:N}}function mD(N){if(dF(N))return{kind:"text",text:N[0].plainText};return{kind:"blocks",blocks:N}}function uD(N,F){if(N.id===F.blockId)return N;let A=L0(N);if(!A)return null;let M=A.find((E)=>A2(E,F)),D=M?uD(M,F):null;return D?w1(N,[D]):null}function ny(N,F,A){let M=I2(N.inlines,A,N.text.length,""),D=I2(M,0,F,"");return i4(D)}function ty(N,F,A,M,D,E){if(F.type==="table")return NQ(N,F,A,M,D,E);let $=gD(F,A,M,D,E);return $?[$]:[]}function ey(N,F,A,M,D){let E=N.roots[F.rootIndex],$=E?.regions[0],Z=E?.regions.at(-1);return F===$&&M===Z&&A===0&&D===Z.text.length}function NQ(N,F,A,M,D,E){if(ey(N,A,M,D,E))return[F];let $=A.tableCellPosition?.rowIndex,Z=A.tableCellPosition?.cellIndex,Y=D.tableCellPosition?.rowIndex,X=D.tableCellPosition?.cellIndex;if($===void 0||Z===void 0||Y===void 0||X===void 0)return[];if($!==0||Z!==0||M!==0)return[];let y=F.rows[Y];if(!y)return[];let Q=y.cells.length-1;if(X!==Q||E!==D.text.length)return[];return[a0(F,F.rows.slice(0,Y+1))]}function gD(N,F,A,M,D){let E=L0(N);if(!E)return null;let $=E.findIndex((Y)=>A2(Y,F)),Z=E.findIndex((Y)=>A2(Y,M));if($===-1||Z===-1)return null;if($===Z){let Y=gD(E[$],F,A,M,D);return Y?w1(N,[Y]):null}return w1(N,hD(E,$,F,A,Z,M,D))}function FQ(N,F,A,M,D){return hD(N.document.blocks,F.rootIndex,F,A,M.rootIndex,M,D)}function hD(N,F,A,M,D,E,$){let Z=vN(N[F],A,M),Y=N.slice(F+1,D),X=fN(N[D],E,$);return[Z,...Y,X].filter((y)=>y!==null)}function z8(N,F,A){let M=ZQ(N.documentIndex,N.selection);if(!M)return null;return{destination:M,documentIndex:N.documentIndex,inlineContext:M.sameRegion?q1(N):null,selection:N.selection}}function H8(N,F,A){let M=AQ(N,F)??MQ(N,F,A);return M?$Q(N,M,F):null}function AQ(N,F){switch(F.kind){case"text":return F.text.length>0?{kind:"splice-text",text:F.text}:null;case"inlines":{if(F.inlines.length===0)return null;if(N.destination.sameRegion){let A=N.inlineContext?XD(N.inlineContext,F.inlines):null;if(A)return A}if(N.destination.structuralBlocked)return null;return{kind:"splice-fragment",blocks:[E1(F.inlines)]}}case"blocks":if(F.blocks.length===0||N.destination.structuralBlocked)return null;return{kind:"splice-fragment",blocks:F.blocks}}}function MQ(N,F,A){if(F.kind==="text")return null;let M=N.destination.prefersVerbatimFallback&&A&&A.length>0?A:aF(F);return M.length>0?{kind:"splice-text",text:M}:null}function DQ(N,F){if(N.kind==="splice-text")return N.text;if(N.kind==="replace-block"||N.kind==="splice-fragment")return EQ(F);return""}function EQ(N){switch(N.kind){case"text":return N.text;case"inlines":return V0(N.inlines);case"blocks":return N.blocks.length===1&&N.blocks[0].type==="paragraph"?N.blocks[0].plainText:""}}function $Q(N,F,A){let M=M2(N.documentIndex,N.selection,DQ(F,A));return M?{...F,animation:M}:F}function ZQ(N,F){let A=X0(N,F),M=H0(N,A.start.regionId),D=H0(N,A.end.regionId);if(!M||!D)return null;let E=ID(M)||ID(D);return{prefersVerbatimFallback:M.blockType==="code"||D.blockType==="code",sameRegion:M===D,structuralBlocked:E}}function ID(N){return N.blockType==="table"||N.blockType==="code"}function _6(N,F,A){return{animation:M2(N,F,A),kind:"splice-text",text:A}}function pD(N,F){return{animation:X8(N.region,N.startOffset,F),kind:"splice-text",range:N.selection,text:F}}function xD(N,F,A,M){let D=M==="backward"?I4(N,F.blockId):LN(N,F.blockId);if(D&&y1(D))return YQ(F,D,M);let E=M==="backward"?F2(N,F.id):TN(N,F.id);if(!E)return null;if(A)return yQ(N,F,E,M);let $=M==="backward"?F:E,Z=M==="backward"?E:F;if(!XQ(Z))return null;return QQ(N,$,Z)}function YQ(N,F,A){if(F.parentBlockId!==null)return null;let M=A==="backward"?N.rootIndex-1:N.rootIndex,D=A==="backward"?0:"end";return{kind:"splice-blocks",rootIndex:F.rootIndex,count:1,blocks:[],selection:P6(N,M,D)}}function XQ(N){return N.blockType==="paragraph"||N.blockType==="heading"}function yQ(N,F,A,M){let D=N.document.blocks[F.rootIndex];if(!D)return null;let E=B6(D,F,A.blockId,void 0),$=M==="backward"?A.text.length:0,Y=F.rootIndex===A.rootIndex?VQ(E,A.rootIndex,A.blockId,$):UQ(A,F.rootIndex,E.length,$);if(!Y)return null;return{kind:"splice-blocks",rootIndex:F.rootIndex,count:1,blocks:E,selection:Y}}function QQ(N,F,A){let M=U1(N.document,A.blockId),D=U1(N.document,F.blockId);if(!M||M.type!=="paragraph"&&M.type!=="heading")return null;let E=A.text.length,$=JQ(M,D),Z=P6(A,A.rootIndex,E);if(F.rootIndex===A.rootIndex){let S=N.document.blocks[F.rootIndex];if(!S)return null;let q=B6(S,F,A.blockId,$);return{kind:"splice-blocks",rootIndex:F.rootIndex,count:1,blocks:q,selection:Z}}let Y=N.document.blocks[A.rootIndex],X=N.document.blocks[F.rootIndex];if(!Y||!X)return null;let y=B6(Y,F,A.blockId,$);if(y.length!==1)return null;let Q=y[0],J=B6(X,F,A.blockId,void 0),V=Math.min(A.rootIndex,F.rootIndex),U=A.rootIndex<F.rootIndex?[Q,...J]:[...J,Q];return{kind:"splice-blocks",rootIndex:V,count:2,blocks:U,selection:Z}}function P6(N,F,A=0){let M=C1(N.path);if(M.length===0)return $0(F,A);return w0(F,M,A)}function JQ(N,F){let A=F&&(F.type==="paragraph"||F.type==="heading")?F.children:[];return m0(N,W0([...N.children,...A]))}function VQ(N,F,A,M){for(let D=0;D<N.length;D+=1){let E=N[D],$=_8(E,A);if($){if($.length===0)return $0(F+D,M);return w0(F+D,$,M)}}return null}function UQ(N,F,A,M){let D=C1(N.path),E=A-1,$=N.rootIndex<F?N.rootIndex:N.rootIndex+E;if(D.length===0)return $0($,M);return w0($,D,M)}function _8(N,F){if(N.id===F)return[];switch(N.type){case"list":for(let A=0;A<N.items.length;A+=1){let M=_8(N.items[A],F);if(M)return[A,...M]}return null;case"listItem":case"blockquote":for(let A=0;A<N.children.length;A+=1){let M=_8(N.children[A],F);if(M)return[A,...M]}return null;default:return null}}function B6(N,F,A,M){return L2([N],(D,{parent:E,recurse:$})=>{if(D.type==="listItem"){let Y=D.children[0];if(Y&&Y.id===F.blockId)return qQ(D)}if(D.id===F.blockId&&E?.type!=="listItem")return[];if(D.id===A&&M!==void 0)return M;let Z=$();if(Z.type==="listItem"){let Y=Z.children[0];if(!Y||Y.type!=="paragraph"&&Y.type!=="heading")return[]}return Z})}function qQ(N){if(N.type==="listItem")return N.children.filter((F)=>F.type==="list").flatMap((F)=>F.items);return[]}function lD(N,F){let A=p4(N,F.rootIndex);if(!A||A.id!==F.id)return null;let M=N.document.blocks[F.rootIndex];if(!M)return null;let D=KQ(M);if(!D)return null;return{kind:"splice-blocks",rootIndex:F.rootIndex,count:1,blocks:D,selection:$0(F.rootIndex)}}function KQ(N){switch(N.type){case"heading":return[E1(N.children)];case"blockquote":return[...N.children];case"list":return dD(N.items);default:return null}}function dD(N){return N.flatMap((F)=>{let A=[SQ(F)];for(let M of F.children)if(M.type==="list")A.push(...dD(M.items));return A})}function SQ(N){let F=N.children[0];if(F&&(F.type==="paragraph"||F.type==="heading"))return E1(F.children);return F0("")}var W6;function a2(N){if(N.length===0)return[];let F=HQ();if(!F)return Array.from(N);return Array.from(F.segment(N),(A)=>A.segment)}function GQ(N,F){let A=a2(N.slice(0,F));if(A.length===0)return 0;return F-A.at(-1).length}function zQ(N,F){let A=a2(N.slice(F))[0];return A?F+A.length:N.length}function uN(N,F,A){return A<0?GQ(N,F):zQ(N,F)}function HQ(){if(W6!==void 0)return W6;let N=Intl.Segmenter;return W6=typeof N==="function"?new N(void 0,{granularity:"grapheme"}):null,W6}function aD(N,F){if(N.selection.anchor.regionId!==N.selection.focus.regionId||N.selection.anchor.offset!==N.selection.focus.offset)return null;let A=H0(N.documentIndex,N.selection.focus.regionId);if(!A)return null;if(F==="forward"&&N.selection.focus.offset>=A.text.length)return null;let M=F==="backward"?uN(A.text,N.selection.focus.offset,-1):N.selection.focus.offset,D=F==="backward"?N.selection.focus.offset:uN(A.text,N.selection.focus.offset,1);if(M===D)return null;return{animation:F==="backward"&&(D===A.text.length||_Q(A,D))?QD(A,M,D):void 0,kind:"splice-text",range:{anchor:{regionId:A.id,offset:M},focus:{regionId:A.id,offset:D}},text:""}}function _Q(N,F){return N.inlines.some((A)=>A.kind==="lineBreak"&&A.start===F)}function B8(N,F){return PQ(N)??aD(N,F)??BQ(N.documentIndex,HM(N,F))}function BQ(N,F){if(F.kind==="unsupported"||!F.atBoundary)return null;if(F.direction==="backward"){let A=WQ(F,N);if(A)return A}return xD(N,F.region,F.empty,F.direction)}function PQ(N){let F=X0(N.documentIndex,N.selection);if(F.start.regionId===F.end.regionId&&F.start.offset===F.end.offset)return null;return _6(N.documentIndex,N.selection,"")}function WQ(N,F){let A=lD(F,N.region);if(A)return A;if(N.kind==="rootTextBlock"){let M=OQ(N,F);if(M)return M}return null}function OQ(N,F){if(N.block.type!=="paragraph"||N.block.plainText.length!==0)return null;let A=F.document.blocks[N.rootIndex-1],M=F.document.blocks[N.rootIndex+1];if(!A||A.type!=="list"||!M||M.type!=="list"||!TQ(A,M))return null;let D=F2(F,N.region.id),E=D?P6(D,N.rootIndex-1,"end"):$0(N.rootIndex-1,"end");return{kind:"splice-blocks",count:3,blocks:[z0(A,[...A.items,...M.items])],rootIndex:N.rootIndex-1,selection:E}}function TQ(N,F){return N.ordered===F.ordered&&N.start===F.start}var gN=N0((N,F)=>qD(N.documentIndex,N.selection,F)),O6=N0(vD,F6),rD=N0((N)=>CQ(N)??{kind:"splice-text",text:`
|
|
16
|
-
`}),LQ=N0((N,F)=>_6(N.documentIndex,N.selection,F)),T6=N0((N,F,A,M)=>pD(N,M),(N,F,A)=>m4(N,F,A)),cD=(N)=>LQ(N,""),P8=N0((N)=>B8(N,"backward")),W8=N0((N)=>B8(N,"forward")),hN=(N)=>G8(N.documentIndex,N.selection),wQ=N0(H8,z8);function sD(N,F,A){return wQ(N,F,A)}function iD(N){let F=N.documentIndex.regions,A=F[0],M=F.at(-1);if(!A||!M)return N;return O0(N,{anchor:{regionId:A.id,offset:0},focus:{regionId:M.id,offset:M.text.length}})}var L6=f6("bold"),w6=f6("italic"),j6=f6("strikethrough"),C6=f6("underline"),oD=N0((N)=>x2(N,A8),q1),nD=N0((N,F,A)=>x2(N,(M,D,E)=>E8(M,D,E,A)),N6),tD=N0((N,F)=>x2(N,$8),N6),eD=N0((N,F)=>x2(N,(A,M,D)=>D8(A,M,D,F)),q1),N9=N0((N,F,A)=>Y8(N,O1({alt:A??null,url:F})),q1),F9=N0((N,F,A,M,D="")=>Z8(N,A,M,D),N6),A9=N0((N,F,A)=>M8(N.inlineContainer,F,A),q1),O8=(N)=>N8(N),T8=(N)=>F8(N),R6=N0((N)=>{switch(N.kind){case"tableCell":return K8(N,1);case"rootTextBlock":return V8(N,1)??zD(N);case"listItem":return BD(N);default:return null}},F6),b6=N0((N)=>{switch(N.kind){case"tableCell":return K8(N,-1);case"rootTextBlock":return V8(N,-1);case"listItem":return PD(N);default:return null}},F6),M9=N0((N)=>q8(N,-1),g4),D9=N0((N)=>q8(N,1),g4),E9=N0((N,F)=>{let A=PN(N.documentIndex,F);if(!A||A.type!=="listItem"||typeof A.checked!=="boolean")return null;return{kind:"replace-block",block:{...A,checked:!A.checked},blockId:F}}),$9=N0((N,F)=>OD(N.documentIndex,N.selection,F)),Z9=N0((N,F)=>LD(N,F),k2),Y9=N0(wD,k2),X9=N0((N,F)=>jD(N,F),k2),y9=N0(CD,k2),Q9=N0(RD,k2),J9=N0((N,F,A)=>{let M=O4(N.documentIndex,F,A);if(!M)return null;return{kind:"splice-comments",count:0,index:N.documentIndex.document.comments.length,threads:[M]}}),V9=(N,F,A)=>IN(N,F,(M)=>z4(M,{body:A.trim()})),U9=(N,F,A,M)=>IN(N,F,(D)=>H4(D,A,M)),q9=(N,F,A)=>IN(N,F,(M)=>_4(M,A)),K9=(N,F)=>IN(N,F,()=>null),S9=(N,F,A)=>IN(N,F,(M)=>B4(M,A));function N0(N,F){return(A,...M)=>{let D=F?jQ(N,F,A,M):N(A,...M);if(!D)return null;return e4(A,D)}}function jQ(N,F,A,M){let D=F(A,...M);return D?N(D,...M):null}function CQ(N){let F=q1(N);return F?Y8(F,$1()):null}function f6(N){return N0((F)=>x2(F,(A,M,D)=>f4(A,M,D,N)),q1)}function IN(N,F,A){let D=u0(N.documentIndex).threads[F];if(!D)return null;let E=A(D);if(E===D)return null;return e4(N,{kind:"splice-comments",count:1,index:F,threads:E?[E]:[]})}function D2(){return{graphemeWidths:new Map,lineBoundaries:new Map,measuredContainerHeights:new Map,measuredLines:new Map,preparedText:new Map,viewportPlans:new WeakMap}}function G9(N,F,A){return pN(N.preparedText,F,A,256)}function z9(N,F,A){return pN(N.measuredLines,F,A,512)}function H9(N,F,A){return pN(N.lineBoundaries,F,A,1024)}function _9(N,F,A){return pN(N.measuredContainerHeights,F,A,1024)}function B9(N,F){let A=N.graphemeWidths.get(F);if(A)return A;let M=new Map;return pN(N.graphemeWidths,F,M,64),M}function P9(N,F,A){return N.viewportPlans.get(F)?.get(A)??null}function W9(N,F,A,M){let D=N.viewportPlans.get(F)??new Map;return D.set(A,M),N.viewportPlans.set(F,D),M}function pN(N,F,A,M){if(N.has(F))N.delete(F);if(N.set(F,A),N.size>M){let D=N.keys().next().value;if(D!==void 0)N.delete(D)}return A}var v6={blockGap:16,charWidth:9,indentWidth:12,lineHeight:24,paddingX:16,paddingY:12};function k6(N){return{...v6,...N}}function m6(N,F,A,M,D){if(O9(N,A,M,"list"))return 6;if(O9(N,A,M,"blockquote"))return 10;if(A===M)return 4;return D+RQ(F.get(A))}function RQ(N){if(N?.type!=="heading")return 0;if(N.depth===1)return 24;return N.depth===2?16:0}function O9(N,F,A,M){let D=T9(N,F,M),E=T9(N,A,M);for(let $ of D)if(E.has($))return!0;return!1}function T9(N,F,A){let M=new Set,D=N.get(F)??null;while(D){if(D.type===A)M.add(D.id);D=D.parentBlockId?N.get(D.parentBlockId)??null:null}return M}var L9=18,w9=14;var j9=22;function r2(N,F,A){let M=N.get(A)??null;while(M){if(M.type==="listItem")return F.get(M.id)?.kind==="task"?22:18;M=M.parentBlockId?N.get(M.parentBlockId)??null:null}return 0}var C9=["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","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","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","BN","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"],L8=[[697,698,"ON"],[706,719,"ON"],[722,735,"ON"],[741,749,"ON"],[751,767,"ON"],[768,879,"NSM"],[884,885,"ON"],[894,894,"ON"],[900,901,"ON"],[903,903,"ON"],[1014,1014,"ON"],[1155,1161,"NSM"],[1418,1418,"ON"],[1421,1422,"ON"],[1423,1423,"ET"],[1424,1424,"R"],[1425,1469,"NSM"],[1470,1470,"R"],[1471,1471,"NSM"],[1472,1472,"R"],[1473,1474,"NSM"],[1475,1475,"R"],[1476,1477,"NSM"],[1478,1478,"R"],[1479,1479,"NSM"],[1480,1535,"R"],[1536,1541,"AN"],[1542,1543,"ON"],[1544,1544,"AL"],[1545,1546,"ET"],[1547,1547,"AL"],[1548,1548,"CS"],[1549,1549,"AL"],[1550,1551,"ON"],[1552,1562,"NSM"],[1563,1610,"AL"],[1611,1631,"NSM"],[1632,1641,"AN"],[1642,1642,"ET"],[1643,1644,"AN"],[1645,1647,"AL"],[1648,1648,"NSM"],[1649,1749,"AL"],[1750,1756,"NSM"],[1757,1757,"AN"],[1758,1758,"ON"],[1759,1764,"NSM"],[1765,1766,"AL"],[1767,1768,"NSM"],[1769,1769,"ON"],[1770,1773,"NSM"],[1774,1775,"AL"],[1776,1785,"EN"],[1786,1808,"AL"],[1809,1809,"NSM"],[1810,1839,"AL"],[1840,1866,"NSM"],[1867,1957,"AL"],[1958,1968,"NSM"],[1969,1983,"AL"],[1984,2026,"R"],[2027,2035,"NSM"],[2036,2037,"R"],[2038,2041,"ON"],[2042,2044,"R"],[2045,2045,"NSM"],[2046,2069,"R"],[2070,2073,"NSM"],[2074,2074,"R"],[2075,2083,"NSM"],[2084,2084,"R"],[2085,2087,"NSM"],[2088,2088,"R"],[2089,2093,"NSM"],[2094,2136,"R"],[2137,2139,"NSM"],[2140,2143,"R"],[2144,2191,"AL"],[2192,2193,"AN"],[2194,2198,"AL"],[2199,2207,"NSM"],[2208,2249,"AL"],[2250,2273,"NSM"],[2274,2274,"AN"],[2275,2306,"NSM"],[2362,2362,"NSM"],[2364,2364,"NSM"],[2369,2376,"NSM"],[2381,2381,"NSM"],[2385,2391,"NSM"],[2402,2403,"NSM"],[2433,2433,"NSM"],[2492,2492,"NSM"],[2497,2500,"NSM"],[2509,2509,"NSM"],[2530,2531,"NSM"],[2546,2547,"ET"],[2555,2555,"ET"],[2558,2558,"NSM"],[2561,2562,"NSM"],[2620,2620,"NSM"],[2625,2626,"NSM"],[2631,2632,"NSM"],[2635,2637,"NSM"],[2641,2641,"NSM"],[2672,2673,"NSM"],[2677,2677,"NSM"],[2689,2690,"NSM"],[2748,2748,"NSM"],[2753,2757,"NSM"],[2759,2760,"NSM"],[2765,2765,"NSM"],[2786,2787,"NSM"],[2801,2801,"ET"],[2810,2815,"NSM"],[2817,2817,"NSM"],[2876,2876,"NSM"],[2879,2879,"NSM"],[2881,2884,"NSM"],[2893,2893,"NSM"],[2901,2902,"NSM"],[2914,2915,"NSM"],[2946,2946,"NSM"],[3008,3008,"NSM"],[3021,3021,"NSM"],[3059,3064,"ON"],[3065,3065,"ET"],[3066,3066,"ON"],[3072,3072,"NSM"],[3076,3076,"NSM"],[3132,3132,"NSM"],[3134,3136,"NSM"],[3142,3144,"NSM"],[3146,3149,"NSM"],[3157,3158,"NSM"],[3170,3171,"NSM"],[3192,3198,"ON"],[3201,3201,"NSM"],[3260,3260,"NSM"],[3276,3277,"NSM"],[3298,3299,"NSM"],[3328,3329,"NSM"],[3387,3388,"NSM"],[3393,3396,"NSM"],[3405,3405,"NSM"],[3426,3427,"NSM"],[3457,3457,"NSM"],[3530,3530,"NSM"],[3538,3540,"NSM"],[3542,3542,"NSM"],[3633,3633,"NSM"],[3636,3642,"NSM"],[3647,3647,"ET"],[3655,3662,"NSM"],[3761,3761,"NSM"],[3764,3772,"NSM"],[3784,3790,"NSM"],[3864,3865,"NSM"],[3893,3893,"NSM"],[3895,3895,"NSM"],[3897,3897,"NSM"],[3898,3901,"ON"],[3953,3966,"NSM"],[3968,3972,"NSM"],[3974,3975,"NSM"],[3981,3991,"NSM"],[3993,4028,"NSM"],[4038,4038,"NSM"],[4141,4144,"NSM"],[4146,4151,"NSM"],[4153,4154,"NSM"],[4157,4158,"NSM"],[4184,4185,"NSM"],[4190,4192,"NSM"],[4209,4212,"NSM"],[4226,4226,"NSM"],[4229,4230,"NSM"],[4237,4237,"NSM"],[4253,4253,"NSM"],[4957,4959,"NSM"],[5008,5017,"ON"],[5120,5120,"ON"],[5760,5760,"WS"],[5787,5788,"ON"],[5906,5908,"NSM"],[5938,5939,"NSM"],[5970,5971,"NSM"],[6002,6003,"NSM"],[6068,6069,"NSM"],[6071,6077,"NSM"],[6086,6086,"NSM"],[6089,6099,"NSM"],[6107,6107,"ET"],[6109,6109,"NSM"],[6128,6137,"ON"],[6144,6154,"ON"],[6155,6157,"NSM"],[6158,6158,"BN"],[6159,6159,"NSM"],[6277,6278,"NSM"],[6313,6313,"NSM"],[6432,6434,"NSM"],[6439,6440,"NSM"],[6450,6450,"NSM"],[6457,6459,"NSM"],[6464,6464,"ON"],[6468,6469,"ON"],[6622,6655,"ON"],[6679,6680,"NSM"],[6683,6683,"NSM"],[6742,6742,"NSM"],[6744,6750,"NSM"],[6752,6752,"NSM"],[6754,6754,"NSM"],[6757,6764,"NSM"],[6771,6780,"NSM"],[6783,6783,"NSM"],[6832,6877,"NSM"],[6880,6891,"NSM"],[6912,6915,"NSM"],[6964,6964,"NSM"],[6966,6970,"NSM"],[6972,6972,"NSM"],[6978,6978,"NSM"],[7019,7027,"NSM"],[7040,7041,"NSM"],[7074,7077,"NSM"],[7080,7081,"NSM"],[7083,7085,"NSM"],[7142,7142,"NSM"],[7144,7145,"NSM"],[7149,7149,"NSM"],[7151,7153,"NSM"],[7212,7219,"NSM"],[7222,7223,"NSM"],[7376,7378,"NSM"],[7380,7392,"NSM"],[7394,7400,"NSM"],[7405,7405,"NSM"],[7412,7412,"NSM"],[7416,7417,"NSM"],[7616,7679,"NSM"],[8125,8125,"ON"],[8127,8129,"ON"],[8141,8143,"ON"],[8157,8159,"ON"],[8173,8175,"ON"],[8189,8190,"ON"],[8192,8202,"WS"],[8203,8205,"BN"],[8207,8207,"R"],[8208,8231,"ON"],[8232,8232,"WS"],[8233,8233,"B"],[8234,8238,"BN"],[8239,8239,"CS"],[8240,8244,"ET"],[8245,8259,"ON"],[8260,8260,"CS"],[8261,8286,"ON"],[8287,8287,"WS"],[8288,8303,"BN"],[8304,8304,"EN"],[8308,8313,"EN"],[8314,8315,"ES"],[8316,8318,"ON"],[8320,8329,"EN"],[8330,8331,"ES"],[8332,8334,"ON"],[8352,8399,"ET"],[8400,8432,"NSM"],[8448,8449,"ON"],[8451,8454,"ON"],[8456,8457,"ON"],[8468,8468,"ON"],[8470,8472,"ON"],[8478,8483,"ON"],[8485,8485,"ON"],[8487,8487,"ON"],[8489,8489,"ON"],[8494,8494,"ET"],[8506,8507,"ON"],[8512,8516,"ON"],[8522,8525,"ON"],[8528,8543,"ON"],[8585,8587,"ON"],[8592,8721,"ON"],[8722,8722,"ES"],[8723,8723,"ET"],[8724,9013,"ON"],[9083,9108,"ON"],[9110,9257,"ON"],[9280,9290,"ON"],[9312,9351,"ON"],[9352,9371,"EN"],[9450,9899,"ON"],[9901,10239,"ON"],[10496,11123,"ON"],[11126,11263,"ON"],[11493,11498,"ON"],[11503,11505,"NSM"],[11513,11519,"ON"],[11647,11647,"NSM"],[11744,11775,"NSM"],[11776,11869,"ON"],[11904,11929,"ON"],[11931,12019,"ON"],[12032,12245,"ON"],[12272,12287,"ON"],[12288,12288,"WS"],[12289,12292,"ON"],[12296,12320,"ON"],[12330,12333,"NSM"],[12336,12336,"ON"],[12342,12343,"ON"],[12349,12351,"ON"],[12441,12442,"NSM"],[12443,12444,"ON"],[12448,12448,"ON"],[12539,12539,"ON"],[12736,12773,"ON"],[12783,12783,"ON"],[12829,12830,"ON"],[12880,12895,"ON"],[12924,12926,"ON"],[12977,12991,"ON"],[13004,13007,"ON"],[13175,13178,"ON"],[13278,13279,"ON"],[13311,13311,"ON"],[19904,19967,"ON"],[42128,42182,"ON"],[42509,42511,"ON"],[42607,42610,"NSM"],[42611,42611,"ON"],[42612,42621,"NSM"],[42622,42623,"ON"],[42654,42655,"NSM"],[42736,42737,"NSM"],[42752,42785,"ON"],[42888,42888,"ON"],[43010,43010,"NSM"],[43014,43014,"NSM"],[43019,43019,"NSM"],[43045,43046,"NSM"],[43048,43051,"ON"],[43052,43052,"NSM"],[43064,43065,"ET"],[43124,43127,"ON"],[43204,43205,"NSM"],[43232,43249,"NSM"],[43263,43263,"NSM"],[43302,43309,"NSM"],[43335,43345,"NSM"],[43392,43394,"NSM"],[43443,43443,"NSM"],[43446,43449,"NSM"],[43452,43453,"NSM"],[43493,43493,"NSM"],[43561,43566,"NSM"],[43569,43570,"NSM"],[43573,43574,"NSM"],[43587,43587,"NSM"],[43596,43596,"NSM"],[43644,43644,"NSM"],[43696,43696,"NSM"],[43698,43700,"NSM"],[43703,43704,"NSM"],[43710,43711,"NSM"],[43713,43713,"NSM"],[43756,43757,"NSM"],[43766,43766,"NSM"],[43882,43883,"ON"],[44005,44005,"NSM"],[44008,44008,"NSM"],[44013,44013,"NSM"],[64285,64285,"R"],[64286,64286,"NSM"],[64287,64296,"R"],[64297,64297,"ES"],[64298,64335,"R"],[64336,64450,"AL"],[64451,64466,"ON"],[64467,64829,"AL"],[64830,64847,"ON"],[64848,64911,"AL"],[64912,64913,"ON"],[64914,64967,"AL"],[64968,64975,"ON"],[64976,65007,"BN"],[65008,65020,"AL"],[65021,65023,"ON"],[65024,65039,"NSM"],[65040,65049,"ON"],[65056,65071,"NSM"],[65072,65103,"ON"],[65104,65104,"CS"],[65105,65105,"ON"],[65106,65106,"CS"],[65108,65108,"ON"],[65109,65109,"CS"],[65110,65118,"ON"],[65119,65119,"ET"],[65120,65121,"ON"],[65122,65123,"ES"],[65124,65126,"ON"],[65128,65128,"ON"],[65129,65130,"ET"],[65131,65131,"ON"],[65136,65278,"AL"],[65279,65279,"BN"],[65281,65282,"ON"],[65283,65285,"ET"],[65286,65290,"ON"],[65291,65291,"ES"],[65292,65292,"CS"],[65293,65293,"ES"],[65294,65295,"CS"],[65296,65305,"EN"],[65306,65306,"CS"],[65307,65312,"ON"],[65339,65344,"ON"],[65371,65381,"ON"],[65504,65505,"ET"],[65506,65508,"ON"],[65509,65510,"ET"],[65512,65518,"ON"],[65520,65528,"BN"],[65529,65533,"ON"],[65534,65535,"BN"],[65793,65793,"ON"],[65856,65932,"ON"],[65936,65948,"ON"],[65952,65952,"ON"],[66045,66045,"NSM"],[66272,66272,"NSM"],[66273,66299,"EN"],[66422,66426,"NSM"],[67584,67870,"R"],[67871,67871,"ON"],[67872,68096,"R"],[68097,68099,"NSM"],[68100,68100,"R"],[68101,68102,"NSM"],[68103,68107,"R"],[68108,68111,"NSM"],[68112,68151,"R"],[68152,68154,"NSM"],[68155,68158,"R"],[68159,68159,"NSM"],[68160,68324,"R"],[68325,68326,"NSM"],[68327,68408,"R"],[68409,68415,"ON"],[68416,68863,"R"],[68864,68899,"AL"],[68900,68903,"NSM"],[68904,68911,"AL"],[68912,68921,"AN"],[68922,68927,"AL"],[68928,68937,"AN"],[68938,68968,"R"],[68969,68973,"NSM"],[68974,68974,"ON"],[68975,69215,"R"],[69216,69246,"AN"],[69247,69290,"R"],[69291,69292,"NSM"],[69293,69311,"R"],[69312,69327,"AL"],[69328,69336,"ON"],[69337,69369,"AL"],[69370,69375,"NSM"],[69376,69423,"R"],[69424,69445,"AL"],[69446,69456,"NSM"],[69457,69487,"AL"],[69488,69505,"R"],[69506,69509,"NSM"],[69510,69631,"R"],[69633,69633,"NSM"],[69688,69702,"NSM"],[69714,69733,"ON"],[69744,69744,"NSM"],[69747,69748,"NSM"],[69759,69761,"NSM"],[69811,69814,"NSM"],[69817,69818,"NSM"],[69826,69826,"NSM"],[69888,69890,"NSM"],[69927,69931,"NSM"],[69933,69940,"NSM"],[70003,70003,"NSM"],[70016,70017,"NSM"],[70070,70078,"NSM"],[70089,70092,"NSM"],[70095,70095,"NSM"],[70191,70193,"NSM"],[70196,70196,"NSM"],[70198,70199,"NSM"],[70206,70206,"NSM"],[70209,70209,"NSM"],[70367,70367,"NSM"],[70371,70378,"NSM"],[70400,70401,"NSM"],[70459,70460,"NSM"],[70464,70464,"NSM"],[70502,70508,"NSM"],[70512,70516,"NSM"],[70587,70592,"NSM"],[70606,70606,"NSM"],[70608,70608,"NSM"],[70610,70610,"NSM"],[70625,70626,"NSM"],[70712,70719,"NSM"],[70722,70724,"NSM"],[70726,70726,"NSM"],[70750,70750,"NSM"],[70835,70840,"NSM"],[70842,70842,"NSM"],[70847,70848,"NSM"],[70850,70851,"NSM"],[71090,71093,"NSM"],[71100,71101,"NSM"],[71103,71104,"NSM"],[71132,71133,"NSM"],[71219,71226,"NSM"],[71229,71229,"NSM"],[71231,71232,"NSM"],[71264,71276,"ON"],[71339,71339,"NSM"],[71341,71341,"NSM"],[71344,71349,"NSM"],[71351,71351,"NSM"],[71453,71453,"NSM"],[71455,71455,"NSM"],[71458,71461,"NSM"],[71463,71467,"NSM"],[71727,71735,"NSM"],[71737,71738,"NSM"],[71995,71996,"NSM"],[71998,71998,"NSM"],[72003,72003,"NSM"],[72148,72151,"NSM"],[72154,72155,"NSM"],[72160,72160,"NSM"],[72193,72198,"NSM"],[72201,72202,"NSM"],[72243,72248,"NSM"],[72251,72254,"NSM"],[72263,72263,"NSM"],[72273,72278,"NSM"],[72281,72283,"NSM"],[72330,72342,"NSM"],[72344,72345,"NSM"],[72544,72544,"NSM"],[72546,72548,"NSM"],[72550,72550,"NSM"],[72752,72758,"NSM"],[72760,72765,"NSM"],[72850,72871,"NSM"],[72874,72880,"NSM"],[72882,72883,"NSM"],[72885,72886,"NSM"],[73009,73014,"NSM"],[73018,73018,"NSM"],[73020,73021,"NSM"],[73023,73029,"NSM"],[73031,73031,"NSM"],[73104,73105,"NSM"],[73109,73109,"NSM"],[73111,73111,"NSM"],[73459,73460,"NSM"],[73472,73473,"NSM"],[73526,73530,"NSM"],[73536,73536,"NSM"],[73538,73538,"NSM"],[73562,73562,"NSM"],[73685,73692,"ON"],[73693,73696,"ET"],[73697,73713,"ON"],[78912,78912,"NSM"],[78919,78933,"NSM"],[90398,90409,"NSM"],[90413,90415,"NSM"],[92912,92916,"NSM"],[92976,92982,"NSM"],[94031,94031,"NSM"],[94095,94098,"NSM"],[94178,94178,"ON"],[94180,94180,"NSM"],[113821,113822,"NSM"],[113824,113827,"BN"],[117760,117973,"ON"],[118000,118009,"EN"],[118010,118012,"ON"],[118016,118451,"ON"],[118458,118480,"ON"],[118496,118512,"ON"],[118528,118573,"NSM"],[118576,118598,"NSM"],[119143,119145,"NSM"],[119155,119162,"BN"],[119163,119170,"NSM"],[119173,119179,"NSM"],[119210,119213,"NSM"],[119273,119274,"ON"],[119296,119361,"ON"],[119362,119364,"NSM"],[119365,119365,"ON"],[119552,119638,"ON"],[120513,120513,"ON"],[120539,120539,"ON"],[120571,120571,"ON"],[120597,120597,"ON"],[120629,120629,"ON"],[120655,120655,"ON"],[120687,120687,"ON"],[120713,120713,"ON"],[120745,120745,"ON"],[120771,120771,"ON"],[120782,120831,"EN"],[121344,121398,"NSM"],[121403,121452,"NSM"],[121461,121461,"NSM"],[121476,121476,"NSM"],[121499,121503,"NSM"],[121505,121519,"NSM"],[122880,122886,"NSM"],[122888,122904,"NSM"],[122907,122913,"NSM"],[122915,122916,"NSM"],[122918,122922,"NSM"],[123023,123023,"NSM"],[123184,123190,"NSM"],[123566,123566,"NSM"],[123628,123631,"NSM"],[123647,123647,"ET"],[124140,124143,"NSM"],[124398,124399,"NSM"],[124643,124643,"NSM"],[124646,124646,"NSM"],[124654,124655,"NSM"],[124661,124661,"NSM"],[124928,125135,"R"],[125136,125142,"NSM"],[125143,125251,"R"],[125252,125258,"NSM"],[125259,126063,"R"],[126064,126143,"AL"],[126144,126207,"R"],[126208,126287,"AL"],[126288,126463,"R"],[126464,126703,"AL"],[126704,126705,"ON"],[126706,126719,"AL"],[126720,126975,"R"],[126976,127019,"ON"],[127024,127123,"ON"],[127136,127150,"ON"],[127153,127167,"ON"],[127169,127183,"ON"],[127185,127221,"ON"],[127232,127242,"EN"],[127243,127247,"ON"],[127279,127279,"ON"],[127338,127343,"ON"],[127405,127405,"ON"],[127584,127589,"ON"],[127744,128728,"ON"],[128732,128748,"ON"],[128752,128764,"ON"],[128768,128985,"ON"],[128992,129003,"ON"],[129008,129008,"ON"],[129024,129035,"ON"],[129040,129095,"ON"],[129104,129113,"ON"],[129120,129159,"ON"],[129168,129197,"ON"],[129200,129211,"ON"],[129216,129217,"ON"],[129232,129240,"ON"],[129280,129623,"ON"],[129632,129645,"ON"],[129648,129660,"ON"],[129664,129674,"ON"],[129678,129734,"ON"],[129736,129736,"ON"],[129741,129756,"ON"],[129759,129770,"ON"],[129775,129784,"ON"],[129792,129938,"ON"],[129940,130031,"ON"],[130032,130041,"EN"],[130042,130042,"ON"],[131070,131071,"BN"],[196606,196607,"BN"],[262142,262143,"BN"],[327678,327679,"BN"],[393214,393215,"BN"],[458750,458751,"BN"],[524286,524287,"BN"],[589822,589823,"BN"],[655358,655359,"BN"],[720894,720895,"BN"],[786430,786431,"BN"],[851966,851967,"BN"],[917502,917759,"BN"],[917760,917999,"NSM"],[918000,921599,"BN"],[983038,983039,"BN"],[1048574,1048575,"BN"],[1114110,1114111,"BN"]];function bQ(N){if(N<=255)return C9[N];let F=0,A=L8.length-1;while(F<=A){let M=F+A>>1,D=L8[M];if(N<D[0]){A=M-1;continue}if(N>D[1]){F=M+1;continue}return D[2]}return"L"}function fQ(N){let F=N.length;if(F===0)return null;let A=Array(F),M=!1;for(let X=0;X<F;){let y=N.charCodeAt(X),Q=y,J=1;if(y>=55296&&y<=56319&&X+1<F){let U=N.charCodeAt(X+1);if(U>=56320&&U<=57343)Q=(y-55296<<10)+(U-56320)+65536,J=2}let V=bQ(Q);if(V==="R"||V==="AL"||V==="AN")M=!0;for(let U=0;U<J;U++)A[X+U]=V;X+=J}if(!M)return null;let D=0;for(let X=0;X<F;X++){let y=A[X];if(y==="L"){D=0;break}if(y==="R"||y==="AL"){D=1;break}}let E=new Int8Array(F);for(let X=0;X<F;X++)E[X]=D;let $=D&1?"R":"L",Z=$,Y=Z;for(let X=0;X<F;X++)if(A[X]==="NSM")A[X]=Y;else Y=A[X];Y=Z;for(let X=0;X<F;X++){let y=A[X];if(y==="EN")A[X]=Y==="AL"?"AN":"EN";else if(y==="R"||y==="L"||y==="AL")Y=y}for(let X=0;X<F;X++)if(A[X]==="AL")A[X]="R";for(let X=1;X<F-1;X++){if(A[X]==="ES"&&A[X-1]==="EN"&&A[X+1]==="EN")A[X]="EN";if(A[X]==="CS"&&(A[X-1]==="EN"||A[X-1]==="AN")&&A[X+1]===A[X-1])A[X]=A[X-1]}for(let X=0;X<F;X++){if(A[X]!=="EN")continue;let y;for(y=X-1;y>=0&&A[y]==="ET";y--)A[y]="EN";for(y=X+1;y<F&&A[y]==="ET";y++)A[y]="EN"}for(let X=0;X<F;X++){let y=A[X];if(y==="WS"||y==="ES"||y==="ET"||y==="CS")A[X]="ON"}Y=Z;for(let X=0;X<F;X++){let y=A[X];if(y==="EN")A[X]=Y==="L"?"L":"EN";else if(y==="R"||y==="L")Y=y}for(let X=0;X<F;X++){if(A[X]!=="ON")continue;let y=X+1;while(y<F&&A[y]==="ON")y++;let Q=X>0?A[X-1]:Z,J=y<F?A[y]:Z,V=Q!=="L"?"R":"L";if(V===(J!=="L"?"R":"L"))for(let S=X;S<y;S++)A[S]=V;X=y-1}for(let X=0;X<F;X++)if(A[X]==="ON")A[X]=$;for(let X=0;X<F;X++){let y=A[X];if((E[X]&1)===0){if(y==="R")E[X]++;else if(y==="AN"||y==="EN")E[X]+=2}else if(y==="L"||y==="AN"||y==="EN")E[X]++}return E}function R9(N,F){let A=fQ(N);if(A===null)return null;let M=new Int8Array(F.length);for(let D=0;D<F.length;D++)M[D]=A[F[D]];return M}var vQ=/[ \t\n\r\f]+/g,kQ=/[\t\n\r\f]| {2,}|^ | $/;function mQ(N){let F=N??"normal";return F==="pre-wrap"?{mode:F,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:F,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function uQ(N){if(!kQ.test(N))return N;let F=N.replace(vQ," ");if(F.charCodeAt(0)===32)F=F.slice(1);if(F.length>0&&F.charCodeAt(F.length-1)===32)F=F.slice(0,-1);return F}function gQ(N){if(!/[\r\f]/.test(N))return N;return N.replace(/\r\n/g,`
|
|
7
|
+
`).trim()}function z4(N){return N.every((F)=>F.type==="text"&&F.marks.length===0)}function tF(N){if(N.length!==1)return!1;let F=N[0];return F.type==="paragraph"&&z4(F.children)}function eF(N){switch(N.kind){case"text":return N.text;case"inlines":return J0(N.inlines);case"blocks":return N2(N.blocks)}}function C0(N){switch(N.type){case"blockquote":case"listItem":return N.children;case"list":return N.items;default:return null}}function C1(N,F){if(F.length===0)return null;switch(N.type){case"blockquote":return d0(F);case"list":return H0(N,F);case"listItem":return Z1(N,F);default:return null}}function U4(N,F){return oF(N,R2(F))}function oF(N,F){switch(N.type){case"blockquote":{let A=N.children.map((D,E)=>oF(D,Y1(F,E))),M=N2(A);return{children:A,id:y0("blockquote",F,M),plainText:M,type:"blockquote"}}case"code":return{id:y0("code",F,`${N.language??""}:${N.source}`),language:N.language,meta:N.meta,plainText:N.source,source:N.source,type:"code"};case"directive":return{attributes:N.attributes,body:N.body,id:y0("directive",F,`${N.name}{${N.attributes}}:${N.body}`),name:N.name,plainText:N.body,type:"directive"};case"heading":{let A=N.children.map((D,E)=>nF(D,iF(F,E))),M=J0(A);return{children:A,depth:N.depth,id:y0("heading",F,`${N.depth}:${M}`),plainText:M,type:"heading"}}case"list":{let A=N.items.map((D,E)=>oF(D,Y1(F,E))),M=A.map((D)=>D.plainText).join(`
|
|
8
|
+
`);return{id:y0("list",F,`${String(N.ordered)}:${M}`),items:A,ordered:N.ordered,plainText:M,spread:N.spread,start:N.start,type:"list"}}case"listItem":{let A=N.children.map((D,E)=>oF(D,Y1(F,E))),M=N2(A);return{checked:N.checked,children:A,id:y0("listItem",F,M),plainText:M,spread:N.spread,type:"listItem"}}case"paragraph":{let A=N.children.map((D,E)=>nF(D,iF(F,E))),M=J0(A);return{children:A,id:y0("paragraph",F,M),plainText:M,type:"paragraph"}}case"table":{let A=N.rows.map((D,E)=>UY(D,f2(F,E))),M=A.map((D)=>D.cells.map((E)=>E.plainText).join(" | ")).join(`
|
|
9
|
+
`);return{align:N.align,id:y0("table",F,M),plainText:M,rows:A,type:"table"}}case"divider":return{id:y0("divider",F,"divider"),plainText:"",type:"divider"};case"raw":return{id:y0("raw",F,N.source),originalType:N.originalType,plainText:N.source,source:N.source,type:"raw"}}}function UY(N,F){return{cells:N.cells.map((A,M)=>{let D=A.children.map(($,y)=>nF($,AM(F2(F,M),y))),E=J0(D);return{children:D,id:y0("tableCell",F2(F,M),E),plainText:E}}),id:y0("tableRow",F,String(N.cells.length))}}function nF(N,F){switch(N.type){case"lineBreak":return{id:y0("lineBreak",F,"lineBreak"),type:"lineBreak"};case"image":return{alt:N.alt,id:y0("image",F,`${N.url}:${N.width??""}:${N.alt??""}`),title:N.title,type:"image",url:N.url,width:N.width};case"mention":return{id:y0("mention",F,`${N.userId}:${N.name}`),name:N.name,type:"mention",userId:N.userId};case"code":return{code:N.code,id:y0("code",F,N.code),type:"code"};case"link":{let A=N.children.map((D,E)=>nF(D,iF(F,E))),M=J0(A);return{children:A,id:y0("link",F,`${N.url}:${M}`),title:N.title,type:"link",url:N.url}}case"text":return{id:y0("text",F,`${N.text}:${N.marks.join(",")}`),marks:N.marks,text:N.text,type:"text"};case"raw":return{id:y0("raw",F,N.source),originalType:N.originalType,source:N.source,type:"raw"}}}function VM(N){return u2(N,(F,{recurse:A})=>{switch(F.type){case"blockquote":case"list":case"listItem":return A();case"heading":case"paragraph":return k0(F,K4(F.children));case"table":return a0(F,F.rows.map((M)=>({...M,cells:M.cells.map((D)=>({...D,children:K4(D.children)}))})));default:return F}})}function K4(N){let F=null,A=()=>F??=[...N];for(let M=N.length-1;M>=0;M-=1){let D=N[M];if(D.type==="text"){let E=D.text.replace(/[ \t]+$/u,"");if(E.length===D.text.length)return F??N;let $=A();if(E.length===0){$.splice(M,1);continue}return $[M]={...D,text:E},$}if(D.type==="link"){let E=K4(D.children);if(E===D.children)return F??N;let $=A();if(E.length===0){$.splice(M,1);continue}return $[M]={...D,children:E},$}return F??N}return F??N}function y0(N,F,A){let M=2166136261;for(let D of`${N}:${F}:${A}`)M^=D.charCodeAt(0),M=Math.imul(M,16777619);return`${N}-${(M>>>0).toString(36)}`}var G4="text";function H4(N){return N==="text"||N==="code"||N==="tableCell"}function _4(N){return N===G4?void 0:N}function UM(N){switch(N){case"heading":case"paragraph":return"text";case"code":return"code";default:return null}}function KM(N){return"threadId"in N}function N6(N){let F=[];return J4(N,{enterBlock(A){switch(A.type){case"heading":case"paragraph":F.push({containerKind:"text",containerOrdinal:F.length,id:A.id,text:J0(A.children)});break;case"code":F.push({containerKind:"code",containerOrdinal:F.length,id:A.id,text:A.source});break}},enterTableCell(A){F.push({containerKind:"tableCell",containerOrdinal:F.length,id:A.id,text:J0(A.children)})}}),F}function B4(N,F,A){return{prefix:N.slice(Math.max(0,F-qM),F),suffix:N.slice(A,Math.min(N.length,A+qM))}}function BN(N,F,A){let M=n0(F,0,N.text.length),D=n0(A,M,N.text.length),{prefix:E,suffix:$}=B4(N.text,M,D);return{kind:_4(N.containerKind),prefix:E||void 0,suffix:$||void 0}}function PN(N,F,A){let M=n0(F,0,N.text.length),D=n0(A,M,N.text.length);return N.text.slice(M,D)}function X1(N,F){if(F.length===0)return[];let A=[],M=0;while(M<=N.length){let D=N.indexOf(F,M);if(D===-1)break;A.push(D),M=D+Math.max(1,F.length)}return A}function m2(N,F,A){if(F.length===0||A.length===0)return[];let M=[];for(let D of X1(N,F)){let E=D+F.length,$=N.indexOf(A,E);if($!==-1)M.push({startOffset:E,endOffset:$})}return M}function P4(N,F,A){if(!F)return!1;return N.slice(Math.max(0,A-F.length),A)===F}function W4(N,F,A){if(!F)return!1;return N.slice(A,A+F.length)===F}var qM=24;function n0(N,F,A){return Math.min(Math.max(N,F),A)}var zM=48,GM=64,KY=32;function WN(N,F){let A=N.anchor.kind??G4,M=N6(F).filter(($)=>$.containerKind===A),D=zY(N,M);if(D.length>0)return HM(N,D,null);let E=GY(N,M);if(E.length>0)return HM(N,E,"repaired");return{match:null,repair:null,status:"stale"}}function zY(N,F){let A=[],M=N.quote;if(M.length===0)return A;for(let D of F)for(let E of X1(D.text,M))A.push({container:D,endOffset:E+M.length,score:BY(N,D,E),startOffset:E});return A.sort((D,E)=>E.score-D.score),A}function GY(N,F){let A=[];for(let M of F)A.push(...HY(N,M));return A.sort((M,D)=>D.score-M.score),A}function HY(N,F){let A=[],M=N.quote.length,D=F.text,E=N.anchor.prefix??"",$=N.anchor.suffix??"";if(E.length>0&&$.length>0){for(let y of m2(D,E,$))A.push({container:F,endOffset:y.endOffset,score:O4(N,F,y.startOffset,y.endOffset,M),startOffset:y.startOffset});return A}if(E.length>0){for(let y of X1(D,E)){let Z=y+E.length,Y=n0(Z+M,Z,D.length);A.push({container:F,endOffset:Y,score:O4(N,F,Z,Y,M),startOffset:Z})}return A}if($.length>0)for(let y of X1(D,$)){let Z=y,Y=n0(Z-M,0,Z);A.push({container:F,endOffset:Z,score:O4(N,F,Y,Z,M),startOffset:Y})}return A}function HM(N,F,A){let[M,D]=F;if(!M)return{match:null,repair:null,status:"stale"};if(D&&M.score===D.score)return{match:null,repair:null,status:"ambiguous"};let E=BN(M.container,M.startOffset,M.endOffset),$=PN(M.container,M.startOffset,M.endOffset),y=A??($===N.quote&&(E.prefix??"")===(N.anchor.prefix??"")&&(E.suffix??"")===(N.anchor.suffix??"")?"matched":"repaired");return{match:_Y(M.container,M.startOffset,M.endOffset),repair:{anchor:E,quote:$},status:y}}function _Y(N,F,A){return{containerId:N.id,containerKind:N.containerKind,containerOrdinal:N.containerOrdinal,endOffset:A,startOffset:F}}function BY(N,F,A){let M=0;if(P4(F.text,N.anchor.prefix,A))M+=zM;if(W4(F.text,N.anchor.suffix,A+N.quote.length))M+=zM;return M}function O4(N,F,A,M,D){let E=0;if(P4(F.text,N.anchor.prefix,A))E+=GM;if(W4(F.text,N.anchor.suffix,M))E+=GM;if(E+=Math.max(0,KY-Math.abs(D-(M-A))),N.quote.length>0){let $=F.text.slice(A,M);if($.length>0)E+=PY(N.quote,$),E+=WY(N.quote,$)}return E}function PY(N,F){let A=0;while(A<N.length&&A<F.length&&N[A]===F[A])A+=1;return A}function WY(N,F){let A=0;while(A<N.length&&A<F.length&&N[N.length-1-A]===F[F.length-1-A])A+=1;return A}function w4(N){if(!N||typeof N!=="object"||Array.isArray(N))return null;let F=N,A=wY(F.anchor),M=typeof F.quote==="string"?F.quote:null,D=Array.isArray(F.comments)?F.comments.flatMap((E)=>{let $=OY(E);return $?[$]:[]}):[];if(!A||!M||D.length===0)return null;return{id:"",quote:M,anchor:A,comments:D,resolvedAt:typeof F.resolvedAt==="string"?F.resolvedAt:void 0}}function OY(N){if(!N||typeof N!=="object"||Array.isArray(N))return null;let F=N;if(typeof F.body!=="string"||typeof F.updatedAt!=="string")return null;return{body:F.body,updatedAt:F.updatedAt}}function wY(N){if(!N||typeof N!=="object"||Array.isArray(N))return null;let{kind:F,prefix:A,suffix:M}=N;if("kind"in N&&!H4(F)||"prefix"in N&&typeof A!=="string"||"suffix"in N&&typeof M!=="string")return null;return{kind:H4(F)?_4(F):void 0,prefix:typeof A==="string"?A:void 0,suffix:typeof M==="string"?M:void 0}}function L4(N){let F=N.createdAt??new Date().toISOString(),A=_M({body:N.body,updatedAt:F});return{id:LY(N.anchor,N.quote,N.body,F),comments:[A],quote:N.quote,anchor:N.anchor}}function T4(N,F){let A=_M(F);return{...N,comments:[...N.comments,A]}}function C4(N,F,A,M=new Date().toISOString()){let D=A.trim();if(D.length===0)return N;let E=!1,$=N.comments.map((y,Z)=>{if(Z!==F||y.body===D)return y;return E=!0,{...y,body:D,updatedAt:M}});if(!E)return N;return{...N,comments:$}}function j4(N,F){let A=N.comments.filter((M,D)=>D!==F);if(A.length===N.comments.length)return N;if(A.length===0)return null;return{...N,comments:A}}function R4(N,F,A=new Date().toISOString()){if(j1(N)===F)return N;return{...N,resolvedAt:F?A:void 0}}function j1(N){return N.resolvedAt!=null}function b4(N){if(N.comments.length===0)return null;return N.comments.reduce((F,A)=>A.updatedAt>F?A.updatedAt:F,N.comments[0].updatedAt)}function LY(N,F,A,M,D="comments"){return y0("commentThread",D,`${N.kind??""}:${N.prefix??""}:${N.suffix??""}:${F}:${A}:${M}`)}function _M(N){let F=N.updatedAt??new Date().toISOString();return{body:N.body,updatedAt:F}}function M2(N,F){let A=N.regionOrderIndex.get(F);if(A===void 0||A===0)return null;return N.regions[A-1]??null}function ON(N,F){let A=N.regionOrderIndex.get(F);if(A===void 0)return null;return N.regions[A+1]??null}function Q1(N){return N.regionIds.length===0&&!R1(N)}function R1(N){return N.type==="blockquote"||N.type==="list"||N.type==="listItem"}function f4(N,F){return BM(N.blocks,F,-1)}function wN(N,F){return BM(N.blocks,F,1)}function u4(N,F){return N.roots[F]?.regions[0]??null}function BM(N,F,A){let M=N.findIndex((D)=>D.id===F);if(M===-1)return null;for(let D=M+A;D>=0&&D<N.length;D+=A){let E=N[D];if(!R1(E))return E}return null}function D2(){return{graphemeWidths:new Map,lineBoundaries:new Map,measuredContainerHeights:new Map,measuredLines:new Map,preparedText:new Map,viewportPlans:new WeakMap}}function PM(N,F,A){return LN(N.preparedText,F,A,256)}function WM(N,F,A){return LN(N.measuredLines,F,A,512)}function OM(N,F,A){return LN(N.lineBoundaries,F,A,1024)}function wM(N,F,A){return LN(N.measuredContainerHeights,F,A,1024)}function LM(N,F){let A=N.graphemeWidths.get(F);if(A)return A;let M=new Map;return LN(N.graphemeWidths,F,M,64),M}function TM(N,F,A){return N.viewportPlans.get(F)?.get(A)??null}function CM(N,F,A,M){let D=N.viewportPlans.get(F)??new Map;return D.set(A,M),N.viewportPlans.set(F,D),M}function LN(N,F,A,M){if(N.has(F))N.delete(F);if(N.set(F,A),N.size>M){let D=N.keys().next().value;if(D!==void 0)N.delete(D)}return A}var F6={blockGap:16,charWidth:9,indentWidth:12,lineHeight:24,paddingX:16,paddingY:12};function A6(N){return{...F6,...N}}function M6(N,F,A,M,D){if(jM(N,A,M,"list"))return 6;if(jM(N,A,M,"blockquote"))return 10;if(A===M)return 4;return D+TY(F.get(A))}function TY(N){if(N?.type!=="heading")return 0;if(N.depth===1)return 24;return N.depth===2?16:0}function jM(N,F,A,M){let D=RM(N,F,M),E=RM(N,A,M);for(let $ of D)if(E.has($))return!0;return!1}function RM(N,F,A){let M=new Set,D=N.get(F)??null;while(D){if(D.type===A)M.add(D.id);D=D.parentBlockId?N.get(D.parentBlockId)??null:null}return M}var bM=18,fM=14;var uM=22;function k2(N,F,A){let M=N.get(A)??null;while(M){if(M.type==="listItem")return F.get(M.id)?.kind==="task"?22:18;M=M.parentBlockId?N.get(M.parentBlockId)??null:null}return 0}var vM=["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","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","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","BN","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"],v4=[[697,698,"ON"],[706,719,"ON"],[722,735,"ON"],[741,749,"ON"],[751,767,"ON"],[768,879,"NSM"],[884,885,"ON"],[894,894,"ON"],[900,901,"ON"],[903,903,"ON"],[1014,1014,"ON"],[1155,1161,"NSM"],[1418,1418,"ON"],[1421,1422,"ON"],[1423,1423,"ET"],[1424,1424,"R"],[1425,1469,"NSM"],[1470,1470,"R"],[1471,1471,"NSM"],[1472,1472,"R"],[1473,1474,"NSM"],[1475,1475,"R"],[1476,1477,"NSM"],[1478,1478,"R"],[1479,1479,"NSM"],[1480,1535,"R"],[1536,1541,"AN"],[1542,1543,"ON"],[1544,1544,"AL"],[1545,1546,"ET"],[1547,1547,"AL"],[1548,1548,"CS"],[1549,1549,"AL"],[1550,1551,"ON"],[1552,1562,"NSM"],[1563,1610,"AL"],[1611,1631,"NSM"],[1632,1641,"AN"],[1642,1642,"ET"],[1643,1644,"AN"],[1645,1647,"AL"],[1648,1648,"NSM"],[1649,1749,"AL"],[1750,1756,"NSM"],[1757,1757,"AN"],[1758,1758,"ON"],[1759,1764,"NSM"],[1765,1766,"AL"],[1767,1768,"NSM"],[1769,1769,"ON"],[1770,1773,"NSM"],[1774,1775,"AL"],[1776,1785,"EN"],[1786,1808,"AL"],[1809,1809,"NSM"],[1810,1839,"AL"],[1840,1866,"NSM"],[1867,1957,"AL"],[1958,1968,"NSM"],[1969,1983,"AL"],[1984,2026,"R"],[2027,2035,"NSM"],[2036,2037,"R"],[2038,2041,"ON"],[2042,2044,"R"],[2045,2045,"NSM"],[2046,2069,"R"],[2070,2073,"NSM"],[2074,2074,"R"],[2075,2083,"NSM"],[2084,2084,"R"],[2085,2087,"NSM"],[2088,2088,"R"],[2089,2093,"NSM"],[2094,2136,"R"],[2137,2139,"NSM"],[2140,2143,"R"],[2144,2191,"AL"],[2192,2193,"AN"],[2194,2198,"AL"],[2199,2207,"NSM"],[2208,2249,"AL"],[2250,2273,"NSM"],[2274,2274,"AN"],[2275,2306,"NSM"],[2362,2362,"NSM"],[2364,2364,"NSM"],[2369,2376,"NSM"],[2381,2381,"NSM"],[2385,2391,"NSM"],[2402,2403,"NSM"],[2433,2433,"NSM"],[2492,2492,"NSM"],[2497,2500,"NSM"],[2509,2509,"NSM"],[2530,2531,"NSM"],[2546,2547,"ET"],[2555,2555,"ET"],[2558,2558,"NSM"],[2561,2562,"NSM"],[2620,2620,"NSM"],[2625,2626,"NSM"],[2631,2632,"NSM"],[2635,2637,"NSM"],[2641,2641,"NSM"],[2672,2673,"NSM"],[2677,2677,"NSM"],[2689,2690,"NSM"],[2748,2748,"NSM"],[2753,2757,"NSM"],[2759,2760,"NSM"],[2765,2765,"NSM"],[2786,2787,"NSM"],[2801,2801,"ET"],[2810,2815,"NSM"],[2817,2817,"NSM"],[2876,2876,"NSM"],[2879,2879,"NSM"],[2881,2884,"NSM"],[2893,2893,"NSM"],[2901,2902,"NSM"],[2914,2915,"NSM"],[2946,2946,"NSM"],[3008,3008,"NSM"],[3021,3021,"NSM"],[3059,3064,"ON"],[3065,3065,"ET"],[3066,3066,"ON"],[3072,3072,"NSM"],[3076,3076,"NSM"],[3132,3132,"NSM"],[3134,3136,"NSM"],[3142,3144,"NSM"],[3146,3149,"NSM"],[3157,3158,"NSM"],[3170,3171,"NSM"],[3192,3198,"ON"],[3201,3201,"NSM"],[3260,3260,"NSM"],[3276,3277,"NSM"],[3298,3299,"NSM"],[3328,3329,"NSM"],[3387,3388,"NSM"],[3393,3396,"NSM"],[3405,3405,"NSM"],[3426,3427,"NSM"],[3457,3457,"NSM"],[3530,3530,"NSM"],[3538,3540,"NSM"],[3542,3542,"NSM"],[3633,3633,"NSM"],[3636,3642,"NSM"],[3647,3647,"ET"],[3655,3662,"NSM"],[3761,3761,"NSM"],[3764,3772,"NSM"],[3784,3790,"NSM"],[3864,3865,"NSM"],[3893,3893,"NSM"],[3895,3895,"NSM"],[3897,3897,"NSM"],[3898,3901,"ON"],[3953,3966,"NSM"],[3968,3972,"NSM"],[3974,3975,"NSM"],[3981,3991,"NSM"],[3993,4028,"NSM"],[4038,4038,"NSM"],[4141,4144,"NSM"],[4146,4151,"NSM"],[4153,4154,"NSM"],[4157,4158,"NSM"],[4184,4185,"NSM"],[4190,4192,"NSM"],[4209,4212,"NSM"],[4226,4226,"NSM"],[4229,4230,"NSM"],[4237,4237,"NSM"],[4253,4253,"NSM"],[4957,4959,"NSM"],[5008,5017,"ON"],[5120,5120,"ON"],[5760,5760,"WS"],[5787,5788,"ON"],[5906,5908,"NSM"],[5938,5939,"NSM"],[5970,5971,"NSM"],[6002,6003,"NSM"],[6068,6069,"NSM"],[6071,6077,"NSM"],[6086,6086,"NSM"],[6089,6099,"NSM"],[6107,6107,"ET"],[6109,6109,"NSM"],[6128,6137,"ON"],[6144,6154,"ON"],[6155,6157,"NSM"],[6158,6158,"BN"],[6159,6159,"NSM"],[6277,6278,"NSM"],[6313,6313,"NSM"],[6432,6434,"NSM"],[6439,6440,"NSM"],[6450,6450,"NSM"],[6457,6459,"NSM"],[6464,6464,"ON"],[6468,6469,"ON"],[6622,6655,"ON"],[6679,6680,"NSM"],[6683,6683,"NSM"],[6742,6742,"NSM"],[6744,6750,"NSM"],[6752,6752,"NSM"],[6754,6754,"NSM"],[6757,6764,"NSM"],[6771,6780,"NSM"],[6783,6783,"NSM"],[6832,6877,"NSM"],[6880,6891,"NSM"],[6912,6915,"NSM"],[6964,6964,"NSM"],[6966,6970,"NSM"],[6972,6972,"NSM"],[6978,6978,"NSM"],[7019,7027,"NSM"],[7040,7041,"NSM"],[7074,7077,"NSM"],[7080,7081,"NSM"],[7083,7085,"NSM"],[7142,7142,"NSM"],[7144,7145,"NSM"],[7149,7149,"NSM"],[7151,7153,"NSM"],[7212,7219,"NSM"],[7222,7223,"NSM"],[7376,7378,"NSM"],[7380,7392,"NSM"],[7394,7400,"NSM"],[7405,7405,"NSM"],[7412,7412,"NSM"],[7416,7417,"NSM"],[7616,7679,"NSM"],[8125,8125,"ON"],[8127,8129,"ON"],[8141,8143,"ON"],[8157,8159,"ON"],[8173,8175,"ON"],[8189,8190,"ON"],[8192,8202,"WS"],[8203,8205,"BN"],[8207,8207,"R"],[8208,8231,"ON"],[8232,8232,"WS"],[8233,8233,"B"],[8234,8238,"BN"],[8239,8239,"CS"],[8240,8244,"ET"],[8245,8259,"ON"],[8260,8260,"CS"],[8261,8286,"ON"],[8287,8287,"WS"],[8288,8303,"BN"],[8304,8304,"EN"],[8308,8313,"EN"],[8314,8315,"ES"],[8316,8318,"ON"],[8320,8329,"EN"],[8330,8331,"ES"],[8332,8334,"ON"],[8352,8399,"ET"],[8400,8432,"NSM"],[8448,8449,"ON"],[8451,8454,"ON"],[8456,8457,"ON"],[8468,8468,"ON"],[8470,8472,"ON"],[8478,8483,"ON"],[8485,8485,"ON"],[8487,8487,"ON"],[8489,8489,"ON"],[8494,8494,"ET"],[8506,8507,"ON"],[8512,8516,"ON"],[8522,8525,"ON"],[8528,8543,"ON"],[8585,8587,"ON"],[8592,8721,"ON"],[8722,8722,"ES"],[8723,8723,"ET"],[8724,9013,"ON"],[9083,9108,"ON"],[9110,9257,"ON"],[9280,9290,"ON"],[9312,9351,"ON"],[9352,9371,"EN"],[9450,9899,"ON"],[9901,10239,"ON"],[10496,11123,"ON"],[11126,11263,"ON"],[11493,11498,"ON"],[11503,11505,"NSM"],[11513,11519,"ON"],[11647,11647,"NSM"],[11744,11775,"NSM"],[11776,11869,"ON"],[11904,11929,"ON"],[11931,12019,"ON"],[12032,12245,"ON"],[12272,12287,"ON"],[12288,12288,"WS"],[12289,12292,"ON"],[12296,12320,"ON"],[12330,12333,"NSM"],[12336,12336,"ON"],[12342,12343,"ON"],[12349,12351,"ON"],[12441,12442,"NSM"],[12443,12444,"ON"],[12448,12448,"ON"],[12539,12539,"ON"],[12736,12773,"ON"],[12783,12783,"ON"],[12829,12830,"ON"],[12880,12895,"ON"],[12924,12926,"ON"],[12977,12991,"ON"],[13004,13007,"ON"],[13175,13178,"ON"],[13278,13279,"ON"],[13311,13311,"ON"],[19904,19967,"ON"],[42128,42182,"ON"],[42509,42511,"ON"],[42607,42610,"NSM"],[42611,42611,"ON"],[42612,42621,"NSM"],[42622,42623,"ON"],[42654,42655,"NSM"],[42736,42737,"NSM"],[42752,42785,"ON"],[42888,42888,"ON"],[43010,43010,"NSM"],[43014,43014,"NSM"],[43019,43019,"NSM"],[43045,43046,"NSM"],[43048,43051,"ON"],[43052,43052,"NSM"],[43064,43065,"ET"],[43124,43127,"ON"],[43204,43205,"NSM"],[43232,43249,"NSM"],[43263,43263,"NSM"],[43302,43309,"NSM"],[43335,43345,"NSM"],[43392,43394,"NSM"],[43443,43443,"NSM"],[43446,43449,"NSM"],[43452,43453,"NSM"],[43493,43493,"NSM"],[43561,43566,"NSM"],[43569,43570,"NSM"],[43573,43574,"NSM"],[43587,43587,"NSM"],[43596,43596,"NSM"],[43644,43644,"NSM"],[43696,43696,"NSM"],[43698,43700,"NSM"],[43703,43704,"NSM"],[43710,43711,"NSM"],[43713,43713,"NSM"],[43756,43757,"NSM"],[43766,43766,"NSM"],[43882,43883,"ON"],[44005,44005,"NSM"],[44008,44008,"NSM"],[44013,44013,"NSM"],[64285,64285,"R"],[64286,64286,"NSM"],[64287,64296,"R"],[64297,64297,"ES"],[64298,64335,"R"],[64336,64450,"AL"],[64451,64466,"ON"],[64467,64829,"AL"],[64830,64847,"ON"],[64848,64911,"AL"],[64912,64913,"ON"],[64914,64967,"AL"],[64968,64975,"ON"],[64976,65007,"BN"],[65008,65020,"AL"],[65021,65023,"ON"],[65024,65039,"NSM"],[65040,65049,"ON"],[65056,65071,"NSM"],[65072,65103,"ON"],[65104,65104,"CS"],[65105,65105,"ON"],[65106,65106,"CS"],[65108,65108,"ON"],[65109,65109,"CS"],[65110,65118,"ON"],[65119,65119,"ET"],[65120,65121,"ON"],[65122,65123,"ES"],[65124,65126,"ON"],[65128,65128,"ON"],[65129,65130,"ET"],[65131,65131,"ON"],[65136,65278,"AL"],[65279,65279,"BN"],[65281,65282,"ON"],[65283,65285,"ET"],[65286,65290,"ON"],[65291,65291,"ES"],[65292,65292,"CS"],[65293,65293,"ES"],[65294,65295,"CS"],[65296,65305,"EN"],[65306,65306,"CS"],[65307,65312,"ON"],[65339,65344,"ON"],[65371,65381,"ON"],[65504,65505,"ET"],[65506,65508,"ON"],[65509,65510,"ET"],[65512,65518,"ON"],[65520,65528,"BN"],[65529,65533,"ON"],[65534,65535,"BN"],[65793,65793,"ON"],[65856,65932,"ON"],[65936,65948,"ON"],[65952,65952,"ON"],[66045,66045,"NSM"],[66272,66272,"NSM"],[66273,66299,"EN"],[66422,66426,"NSM"],[67584,67870,"R"],[67871,67871,"ON"],[67872,68096,"R"],[68097,68099,"NSM"],[68100,68100,"R"],[68101,68102,"NSM"],[68103,68107,"R"],[68108,68111,"NSM"],[68112,68151,"R"],[68152,68154,"NSM"],[68155,68158,"R"],[68159,68159,"NSM"],[68160,68324,"R"],[68325,68326,"NSM"],[68327,68408,"R"],[68409,68415,"ON"],[68416,68863,"R"],[68864,68899,"AL"],[68900,68903,"NSM"],[68904,68911,"AL"],[68912,68921,"AN"],[68922,68927,"AL"],[68928,68937,"AN"],[68938,68968,"R"],[68969,68973,"NSM"],[68974,68974,"ON"],[68975,69215,"R"],[69216,69246,"AN"],[69247,69290,"R"],[69291,69292,"NSM"],[69293,69311,"R"],[69312,69327,"AL"],[69328,69336,"ON"],[69337,69369,"AL"],[69370,69375,"NSM"],[69376,69423,"R"],[69424,69445,"AL"],[69446,69456,"NSM"],[69457,69487,"AL"],[69488,69505,"R"],[69506,69509,"NSM"],[69510,69631,"R"],[69633,69633,"NSM"],[69688,69702,"NSM"],[69714,69733,"ON"],[69744,69744,"NSM"],[69747,69748,"NSM"],[69759,69761,"NSM"],[69811,69814,"NSM"],[69817,69818,"NSM"],[69826,69826,"NSM"],[69888,69890,"NSM"],[69927,69931,"NSM"],[69933,69940,"NSM"],[70003,70003,"NSM"],[70016,70017,"NSM"],[70070,70078,"NSM"],[70089,70092,"NSM"],[70095,70095,"NSM"],[70191,70193,"NSM"],[70196,70196,"NSM"],[70198,70199,"NSM"],[70206,70206,"NSM"],[70209,70209,"NSM"],[70367,70367,"NSM"],[70371,70378,"NSM"],[70400,70401,"NSM"],[70459,70460,"NSM"],[70464,70464,"NSM"],[70502,70508,"NSM"],[70512,70516,"NSM"],[70587,70592,"NSM"],[70606,70606,"NSM"],[70608,70608,"NSM"],[70610,70610,"NSM"],[70625,70626,"NSM"],[70712,70719,"NSM"],[70722,70724,"NSM"],[70726,70726,"NSM"],[70750,70750,"NSM"],[70835,70840,"NSM"],[70842,70842,"NSM"],[70847,70848,"NSM"],[70850,70851,"NSM"],[71090,71093,"NSM"],[71100,71101,"NSM"],[71103,71104,"NSM"],[71132,71133,"NSM"],[71219,71226,"NSM"],[71229,71229,"NSM"],[71231,71232,"NSM"],[71264,71276,"ON"],[71339,71339,"NSM"],[71341,71341,"NSM"],[71344,71349,"NSM"],[71351,71351,"NSM"],[71453,71453,"NSM"],[71455,71455,"NSM"],[71458,71461,"NSM"],[71463,71467,"NSM"],[71727,71735,"NSM"],[71737,71738,"NSM"],[71995,71996,"NSM"],[71998,71998,"NSM"],[72003,72003,"NSM"],[72148,72151,"NSM"],[72154,72155,"NSM"],[72160,72160,"NSM"],[72193,72198,"NSM"],[72201,72202,"NSM"],[72243,72248,"NSM"],[72251,72254,"NSM"],[72263,72263,"NSM"],[72273,72278,"NSM"],[72281,72283,"NSM"],[72330,72342,"NSM"],[72344,72345,"NSM"],[72544,72544,"NSM"],[72546,72548,"NSM"],[72550,72550,"NSM"],[72752,72758,"NSM"],[72760,72765,"NSM"],[72850,72871,"NSM"],[72874,72880,"NSM"],[72882,72883,"NSM"],[72885,72886,"NSM"],[73009,73014,"NSM"],[73018,73018,"NSM"],[73020,73021,"NSM"],[73023,73029,"NSM"],[73031,73031,"NSM"],[73104,73105,"NSM"],[73109,73109,"NSM"],[73111,73111,"NSM"],[73459,73460,"NSM"],[73472,73473,"NSM"],[73526,73530,"NSM"],[73536,73536,"NSM"],[73538,73538,"NSM"],[73562,73562,"NSM"],[73685,73692,"ON"],[73693,73696,"ET"],[73697,73713,"ON"],[78912,78912,"NSM"],[78919,78933,"NSM"],[90398,90409,"NSM"],[90413,90415,"NSM"],[92912,92916,"NSM"],[92976,92982,"NSM"],[94031,94031,"NSM"],[94095,94098,"NSM"],[94178,94178,"ON"],[94180,94180,"NSM"],[113821,113822,"NSM"],[113824,113827,"BN"],[117760,117973,"ON"],[118000,118009,"EN"],[118010,118012,"ON"],[118016,118451,"ON"],[118458,118480,"ON"],[118496,118512,"ON"],[118528,118573,"NSM"],[118576,118598,"NSM"],[119143,119145,"NSM"],[119155,119162,"BN"],[119163,119170,"NSM"],[119173,119179,"NSM"],[119210,119213,"NSM"],[119273,119274,"ON"],[119296,119361,"ON"],[119362,119364,"NSM"],[119365,119365,"ON"],[119552,119638,"ON"],[120513,120513,"ON"],[120539,120539,"ON"],[120571,120571,"ON"],[120597,120597,"ON"],[120629,120629,"ON"],[120655,120655,"ON"],[120687,120687,"ON"],[120713,120713,"ON"],[120745,120745,"ON"],[120771,120771,"ON"],[120782,120831,"EN"],[121344,121398,"NSM"],[121403,121452,"NSM"],[121461,121461,"NSM"],[121476,121476,"NSM"],[121499,121503,"NSM"],[121505,121519,"NSM"],[122880,122886,"NSM"],[122888,122904,"NSM"],[122907,122913,"NSM"],[122915,122916,"NSM"],[122918,122922,"NSM"],[123023,123023,"NSM"],[123184,123190,"NSM"],[123566,123566,"NSM"],[123628,123631,"NSM"],[123647,123647,"ET"],[124140,124143,"NSM"],[124398,124399,"NSM"],[124643,124643,"NSM"],[124646,124646,"NSM"],[124654,124655,"NSM"],[124661,124661,"NSM"],[124928,125135,"R"],[125136,125142,"NSM"],[125143,125251,"R"],[125252,125258,"NSM"],[125259,126063,"R"],[126064,126143,"AL"],[126144,126207,"R"],[126208,126287,"AL"],[126288,126463,"R"],[126464,126703,"AL"],[126704,126705,"ON"],[126706,126719,"AL"],[126720,126975,"R"],[126976,127019,"ON"],[127024,127123,"ON"],[127136,127150,"ON"],[127153,127167,"ON"],[127169,127183,"ON"],[127185,127221,"ON"],[127232,127242,"EN"],[127243,127247,"ON"],[127279,127279,"ON"],[127338,127343,"ON"],[127405,127405,"ON"],[127584,127589,"ON"],[127744,128728,"ON"],[128732,128748,"ON"],[128752,128764,"ON"],[128768,128985,"ON"],[128992,129003,"ON"],[129008,129008,"ON"],[129024,129035,"ON"],[129040,129095,"ON"],[129104,129113,"ON"],[129120,129159,"ON"],[129168,129197,"ON"],[129200,129211,"ON"],[129216,129217,"ON"],[129232,129240,"ON"],[129280,129623,"ON"],[129632,129645,"ON"],[129648,129660,"ON"],[129664,129674,"ON"],[129678,129734,"ON"],[129736,129736,"ON"],[129741,129756,"ON"],[129759,129770,"ON"],[129775,129784,"ON"],[129792,129938,"ON"],[129940,130031,"ON"],[130032,130041,"EN"],[130042,130042,"ON"],[131070,131071,"BN"],[196606,196607,"BN"],[262142,262143,"BN"],[327678,327679,"BN"],[393214,393215,"BN"],[458750,458751,"BN"],[524286,524287,"BN"],[589822,589823,"BN"],[655358,655359,"BN"],[720894,720895,"BN"],[786430,786431,"BN"],[851966,851967,"BN"],[917502,917759,"BN"],[917760,917999,"NSM"],[918000,921599,"BN"],[983038,983039,"BN"],[1048574,1048575,"BN"],[1114110,1114111,"BN"]];function CY(N){if(N<=255)return vM[N];let F=0,A=v4.length-1;while(F<=A){let M=F+A>>1,D=v4[M];if(N<D[0]){A=M-1;continue}if(N>D[1]){F=M+1;continue}return D[2]}return"L"}function jY(N){let F=N.length;if(F===0)return null;let A=Array(F),M=!1;for(let Y=0;Y<F;){let X=N.charCodeAt(Y),Q=X,S=1;if(X>=55296&&X<=56319&&Y+1<F){let V=N.charCodeAt(Y+1);if(V>=56320&&V<=57343)Q=(X-55296<<10)+(V-56320)+65536,S=2}let J=CY(Q);if(J==="R"||J==="AL"||J==="AN")M=!0;for(let V=0;V<S;V++)A[Y+V]=J;Y+=S}if(!M)return null;let D=0;for(let Y=0;Y<F;Y++){let X=A[Y];if(X==="L"){D=0;break}if(X==="R"||X==="AL"){D=1;break}}let E=new Int8Array(F);for(let Y=0;Y<F;Y++)E[Y]=D;let $=D&1?"R":"L",y=$,Z=y;for(let Y=0;Y<F;Y++)if(A[Y]==="NSM")A[Y]=Z;else Z=A[Y];Z=y;for(let Y=0;Y<F;Y++){let X=A[Y];if(X==="EN")A[Y]=Z==="AL"?"AN":"EN";else if(X==="R"||X==="L"||X==="AL")Z=X}for(let Y=0;Y<F;Y++)if(A[Y]==="AL")A[Y]="R";for(let Y=1;Y<F-1;Y++){if(A[Y]==="ES"&&A[Y-1]==="EN"&&A[Y+1]==="EN")A[Y]="EN";if(A[Y]==="CS"&&(A[Y-1]==="EN"||A[Y-1]==="AN")&&A[Y+1]===A[Y-1])A[Y]=A[Y-1]}for(let Y=0;Y<F;Y++){if(A[Y]!=="EN")continue;let X;for(X=Y-1;X>=0&&A[X]==="ET";X--)A[X]="EN";for(X=Y+1;X<F&&A[X]==="ET";X++)A[X]="EN"}for(let Y=0;Y<F;Y++){let X=A[Y];if(X==="WS"||X==="ES"||X==="ET"||X==="CS")A[Y]="ON"}Z=y;for(let Y=0;Y<F;Y++){let X=A[Y];if(X==="EN")A[Y]=Z==="L"?"L":"EN";else if(X==="R"||X==="L")Z=X}for(let Y=0;Y<F;Y++){if(A[Y]!=="ON")continue;let X=Y+1;while(X<F&&A[X]==="ON")X++;let Q=Y>0?A[Y-1]:y,S=X<F?A[X]:y,J=Q!=="L"?"R":"L";if(J===(S!=="L"?"R":"L"))for(let K=Y;K<X;K++)A[K]=J;Y=X-1}for(let Y=0;Y<F;Y++)if(A[Y]==="ON")A[Y]=$;for(let Y=0;Y<F;Y++){let X=A[Y];if((E[Y]&1)===0){if(X==="R")E[Y]++;else if(X==="AN"||X==="EN")E[Y]+=2}else if(X==="L"||X==="AN"||X==="EN")E[Y]++}return E}function mM(N,F){let A=jY(N);if(A===null)return null;let M=new Int8Array(F.length);for(let D=0;D<F.length;D++)M[D]=A[F[D]];return M}var RY=/[ \t\n\r\f]+/g,bY=/[\t\n\r\f]| {2,}|^ | $/;function fY(N){let F=N??"normal";return F==="pre-wrap"?{mode:F,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:F,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function uY(N){if(!bY.test(N))return N;let F=N.replace(RY," ");if(F.charCodeAt(0)===32)F=F.slice(1);if(F.length>0&&F.charCodeAt(F.length-1)===32)F=F.slice(0,-1);return F}function vY(N){if(!/[\r\f]/.test(N))return N;return N.replace(/\r\n/g,`
|
|
17
10
|
`).replace(/[\r\f]/g,`
|
|
18
|
-
`)}var
|
|
19
|
-
`)return"hard-break"}if(N===" ")return"space";if(N===" "||N===" "||N===""||N==="\uFEFF")return"glue";if(N==="")return"zero-width-break";if(N==="")return"soft-hyphen";return"text"}var yJ=/[\x20\t\n\xA0\xAD\u200B\u202F\u2060\uFEFF]/;function n0(N){return N.length===1?N[0]:N.join("")}function QJ(N,F){let A=[];for(let M=N.length-1;M>=0;M--)A.push(N[M]);return A.push(F),n0(A)}function JJ(N,F,A,M){if(!yJ.test(N))return[{text:N,isWordLike:F,kind:"text",start:A}];let D=[],E=null,$=[],Z=A,Y=!1,X=0;for(let y of N){let Q=XJ(y,M),J=Q==="text"&&F;if(E!==null&&Q===E&&J===Y){$.push(y),X+=y.length;continue}if(E!==null)D.push({text:n0($),isWordLike:Y,kind:E,start:Z});E=Q,$=[y],Z=A+X,Y=J,X+=y.length}if(E!==null)D.push({text:n0($),isWordLike:Y,kind:E,start:Z});return D}function j8(N){return N==="space"||N==="preserved-space"||N==="zero-width-break"||N==="hard-break"}var VJ=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function UJ(N,F){let A=N.texts[F];if(A.startsWith("www."))return!0;return VJ.test(A)&&F+1<N.len&&N.kinds[F+1]==="text"&&N.texts[F+1]==="//"}function qJ(N){return N.includes("?")&&(N.includes("://")||N.startsWith("www."))}function KJ(N){let F=N.texts.slice(),A=N.isWordLike.slice(),M=N.kinds.slice(),D=N.starts.slice();for(let $=0;$<N.len;$++){if(M[$]!=="text"||!UJ(N,$))continue;let Z=[F[$]],Y=$+1;while(Y<N.len&&!j8(M[Y])){Z.push(F[Y]),A[$]=!0;let X=F[Y].includes("?");if(M[Y]="text",F[Y]="",Y++,X)break}F[$]=n0(Z)}let E=0;for(let $=0;$<F.length;$++){let Z=F[$];if(Z.length===0)continue;if(E!==$)F[E]=Z,A[E]=A[$],M[E]=M[$],D[E]=D[$];E++}return F.length=E,A.length=E,M.length=E,D.length=E,{len:E,texts:F,isWordLike:A,kinds:M,starts:D}}function SJ(N){let F=[],A=[],M=[],D=[];for(let E=0;E<N.len;E++){let $=N.texts[E];if(F.push($),A.push(N.isWordLike[E]),M.push(N.kinds[E]),D.push(N.starts[E]),!qJ($))continue;let Z=E+1;if(Z>=N.len||j8(N.kinds[Z]))continue;let Y=[],X=N.starts[Z],y=Z;while(y<N.len&&!j8(N.kinds[y]))Y.push(N.texts[y]),y++;if(Y.length>0)F.push(n0(Y)),A.push(!0),M.push("text"),D.push(X),E=y-1}return{len:F.length,texts:F,isWordLike:A,kinds:M,starts:D}}var GJ=new Set([":","-","/","×",",",".","+","–","—"]),zJ=new Set([".",",",":",";"]);function m9(N){for(let F=N.length;F>0;){let A=g6(N,F),M=N.slice(A,F);if(E2.test(M)){F=A;continue}return zJ.has(M)||h6(M)}return!1}function HJ(N,F){return F&&!c0(N)}function u9(N){for(let F of N)if(C8.test(F))return!0;return!1}function xN(N){if(N.length===0)return!1;for(let F of N){if(C8.test(F)||GJ.has(F))continue;return!1}return!0}function _J(N){let F=[],A=[],M=[],D=[];for(let E=0;E<N.len;E++){let $=N.texts[E],Z=N.kinds[E];if(Z==="text"&&xN($)&&u9($)){let Y=[$],X=E+1;while(X<N.len&&N.kinds[X]==="text"&&xN(N.texts[X]))Y.push(N.texts[X]),X++;F.push(n0(Y)),A.push(!0),M.push("text"),D.push(N.starts[E]),E=X-1;continue}F.push($),A.push(N.isWordLike[E]),M.push(Z),D.push(N.starts[E])}return{len:F.length,texts:F,isWordLike:A,kinds:M,starts:D}}function BJ(N){let F=[],A=[],M=[],D=[];for(let E=0;E<N.len;E++){let $=N.texts[E],Z=N.kinds[E],Y=N.isWordLike[E];if(Z==="text"&&m9($)&&(Y||MJ($))&&!c0($)){let X=[$],y=!0,Q=E+1;while(y&&Q<N.len&&N.kinds[Q]==="text"&&HJ(N.texts[Q],N.isWordLike[Q])){let J=N.texts[Q];X.push(J),y=m9(J),Q++}F.push(n0(X)),A.push(!0),M.push("text"),D.push(N.starts[E]),E=Q-1;continue}F.push($),A.push(Y),M.push(Z),D.push(N.starts[E])}return{len:F.length,texts:F,isWordLike:A,kinds:M,starts:D}}function PJ(N){let F=[],A=[],M=[],D=[];for(let E=0;E<N.len;E++){let $=N.texts[E];if(N.kinds[E]==="text"&&$.includes("-")){let Z=$.split("-"),Y=Z.length>1;for(let X=0;X<Z.length;X++){let y=Z[X];if(!Y)break;if(y.length===0||!u9(y)||!xN(y))Y=!1}if(Y){let X=0;for(let y=0;y<Z.length;y++){let Q=Z[y],J=y<Z.length-1?`${Q}-`:Q;F.push(J),A.push(!0),M.push("text"),D.push(N.starts[E]+X),X+=J.length}continue}}F.push($),A.push(N.isWordLike[E]),M.push(N.kinds[E]),D.push(N.starts[E])}return{len:F.length,texts:F,isWordLike:A,kinds:M,starts:D}}function WJ(N){let F=[],A=[],M=[],D=[],E=0;while(E<N.len){let $=[N.texts[E]],Z=N.isWordLike[E],Y=N.kinds[E],X=N.starts[E];if(Y==="glue"){let y=[$[0]],Q=X;E++;while(E<N.len&&N.kinds[E]==="glue")y.push(N.texts[E]),E++;let J=n0(y);if(E<N.len&&N.kinds[E]==="text")$[0]=J,$.push(N.texts[E]),Z=N.isWordLike[E],Y="text",X=Q,E++;else{F.push(J),A.push(!1),M.push("glue"),D.push(Q);continue}}else E++;if(Y==="text")while(E<N.len&&N.kinds[E]==="glue"){let y=[];while(E<N.len&&N.kinds[E]==="glue")y.push(N.texts[E]),E++;let Q=n0(y);if(E<N.len&&N.kinds[E]==="text"){$.push(Q,N.texts[E]),Z=Z||N.isWordLike[E],E++;continue}$.push(Q)}F.push(n0($)),A.push(Z),M.push(Y),D.push(X)}return{len:F.length,texts:F,isWordLike:A,kinds:M,starts:D}}function OJ(N){let F=N.texts.slice(),A=N.isWordLike.slice(),M=N.kinds.slice(),D=N.starts.slice();for(let E=0;E<F.length-1;E++){if(M[E]!=="text"||M[E+1]!=="text")continue;if(!c0(F[E])||!c0(F[E+1]))continue;let $=EJ(F[E]);if($===null)continue;F[E]=$.head,F[E+1]=$.tail+F[E+1],D[E+1]=D[E]+$.head.length}return{len:F.length,texts:F,isWordLike:A,kinds:M,starts:D}}function TJ(N,F,A){let M=IQ(),D=0,E=[],$=[],Z=[],Y=[],X=[],y=[],Q=[],J=[],V=[],U=[],S=[],q=[];for(let _ of M.segment(N))for(let j of JJ(_.segment,_.isWordLike??!1,_.index,A)){let b=function(){if(y[P]!==null)$[P]=[v9(E,y,Q,P)],y[P]=null;$[P].push(j.text),Z[P]=Z[P]||j.isWordLike,J[P]=J[P]||O,V[P]=V[P]||W,U[P]=g,S[P]=R,q[P]=k9(V[P],k)},L=j.kind==="text",T=$J(j.text,j.isWordLike,j.kind),O=c0(j.text),W=b9(j.text),k=dN(j.text),g=I6(j.text),R=ZJ(j.text),P=D-1;if(F.carryCJKAfterClosingQuote&&L&&D>0&&Y[P]==="text"&&O&&J[P]&&U[P])b();else if(L&&D>0&&Y[P]==="text"&&nQ(j.text)&&J[P])b();else if(L&&D>0&&Y[P]==="text"&&S[P])b();else if(L&&D>0&&Y[P]==="text"&&j.isWordLike&&W&&q[P])b(),Z[P]=!0;else if(T!==null&&D>0&&Y[P]==="text"&&y[P]===T)Q[P]=(Q[P]??1)+1;else if(L&&!j.isWordLike&&D>0&&Y[P]==="text"&&!J[P]&&(oQ(j.text)||j.text==="-"&&Z[P]))b();else E[D]=j.text,$[D]=[j.text],Z[D]=j.isWordLike,Y[D]=j.kind,X[D]=j.start,y[D]=T,Q[D]=T===null?0:1,J[D]=O,V[D]=W,U[D]=g,S[D]=R,q[D]=k9(W,k),D++}for(let _=0;_<D;_++){if(y[_]!==null){E[_]=v9(E,y,Q,_);continue}E[_]=n0($[_])}for(let _=1;_<D;_++)if(Y[_]==="text"&&!Z[_]&&f8(E[_])&&Y[_-1]==="text"&&!J[_-1])E[_-1]+=E[_],Z[_-1]=Z[_-1]||Z[_],E[_]="";let K=Array.from({length:D},()=>null),G=-1;for(let _=D-1;_>=0;_--){let j=E[_];if(j.length===0)continue;if(Y[_]==="text"&&!Z[_]&&G>=0&&Y[G]==="text"&&(tQ(j)||j==="-"&&DJ(E[G]))){let L=K[G]??[];L.push(j),K[G]=L,X[G]=X[_],E[_]="";continue}G=_}for(let _=0;_<D;_++){let j=K[_];if(j==null)continue;E[_]=QJ(j,E[_])}let z=0;for(let _=0;_<D;_++){let j=E[_];if(j.length===0)continue;if(z!==_)E[z]=j,Z[z]=Z[_],Y[z]=Y[_],X[z]=X[_];z++}E.length=z,Z.length=z,Y.length=z,X.length=z;let H=WJ({len:z,texts:E,isWordLike:Z,kinds:Y,starts:X}),B=OJ(BJ(PJ(_J(SJ(KJ(H))))));for(let _=0;_<B.len-1;_++){let j=YJ(B.texts[_]);if(j===null)continue;if(B.kinds[_]!=="space"&&B.kinds[_]!=="preserved-space"||B.kinds[_+1]!=="text"||!b9(B.texts[_+1]))continue;B.texts[_]=j.space,B.isWordLike[_]=!1,B.kinds[_]=B.kinds[_]==="preserved-space"?"preserved-space":"space",B.texts[_+1]=j.marks+B.texts[_+1],B.starts[_+1]=B.starts[_]+j.space.length}return B}function LJ(N,F){if(N.len===0)return[];if(!F.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:N.len,consumedEndSegmentIndex:N.len}];let A=[],M=0;for(let D=0;D<N.len;D++){if(N.kinds[D]!=="hard-break")continue;A.push({startSegmentIndex:M,endSegmentIndex:D,consumedEndSegmentIndex:D+1}),M=D+1}if(M<N.len)A.push({startSegmentIndex:M,endSegmentIndex:N.len,consumedEndSegmentIndex:N.len});return A}function wJ(N,F,A){if(F.len<=1)return F;let M=[],D=[],E=[],$=[],Z=-1,Y=!1;function X(J){M.push(F.texts[J]),D.push(F.isWordLike[J]),E.push("text"),$.push(F.starts[J])}function y(J,V){let U=!1;for(let K=J;K<V;K++)U=U||F.isWordLike[K];let S=F.starts[J],q=V<F.len?F.starts[V]:N.length;M.push(N.slice(S,q)),D.push(U),E.push("text"),$.push(S)}function Q(J){if(Z<0)return;if(Y)if(Z+1===J)X(Z);else y(Z,J);else for(let V=Z;V<J;V++)X(V);Z=-1,Y=!1}for(let J=0;J<F.len;J++){let V=F.texts[J],U=F.kinds[J];if(U==="text"){if(Z>=0&&!R8(F.texts[J-1],A))Q(J);if(Z<0)Z=J;Y=Y||c0(V);continue}Q(J),M.push(V),D.push(F.isWordLike[J]),E.push(U),$.push(F.starts[J])}return Q(F.len),{len:M.length,texts:M,isWordLike:D,kinds:E,starts:$}}function g9(N,F,A="normal",M="normal"){let D=mQ(A),E=D.mode==="pre-wrap"?gQ(N):uQ(N);if(E.length===0)return{normalized:E,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let $=TJ(E,F,D),Z=M==="keep-all"?wJ(E,$,F.breakKeepAllAfterPunctuation):$;return{normalized:E,chunks:LJ(Z,D),...Z}}var c2=null,h9=new Map,s2=null,jJ=96,CJ=/\p{Emoji_Presentation}/u,RJ=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,v8=null,I9=new Map;function k8(){if(c2!==null)return c2;if(typeof OffscreenCanvas<"u")return c2=new OffscreenCanvas(1,1).getContext("2d"),c2;if(typeof document<"u")return c2=document.createElement("canvas").getContext("2d"),c2;throw Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function bJ(N){let F=h9.get(N);if(!F)F=new Map,h9.set(N,F);return F}function K1(N,F){let A=F.get(N);if(A===void 0)A={width:k8().measureText(N).width,containsCJK:c0(N)},F.set(N,A);return A}function v1(){if(s2!==null)return s2;if(typeof navigator>"u")return s2={lineFitEpsilon:0.005,carryCJKAfterClosingQuote:!1,breakKeepAllAfterPunctuation:!0,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},s2;let N=navigator.userAgent,A=navigator.vendor==="Apple Computer, Inc."&&N.includes("Safari/")&&!N.includes("Chrome/")&&!N.includes("Chromium/")&&!N.includes("CriOS/")&&!N.includes("FxiOS/")&&!N.includes("EdgiOS/"),M=N.includes("Chrome/")||N.includes("Chromium/")||N.includes("CriOS/")||N.includes("Edg/");return s2={lineFitEpsilon:A?0.015625:0.005,carryCJKAfterClosingQuote:M,breakKeepAllAfterPunctuation:!A,preferPrefixWidthsForBreakableRuns:A,preferEarlySoftHyphenBreak:A},s2}function fJ(N){let F=N.match(/(\d+(?:\.\d+)?)\s*px/);return F?parseFloat(F[1]):16}function p9(){if(v8===null)v8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return v8}function vJ(N){return CJ.test(N)||N.includes("️")}function x9(N){return RJ.test(N)}function kJ(N,F){let A=I9.get(N);if(A!==void 0)return A;let M=k8();M.font=N;let D=M.measureText("\uD83D\uDE00").width;if(A=0,D>F+0.5&&typeof document<"u"&&document.body!==null){let E=document.createElement("span");E.style.font=N,E.style.display="inline-block",E.style.visibility="hidden",E.style.position="absolute",E.textContent="\uD83D\uDE00",document.body.appendChild(E);let $=E.getBoundingClientRect().width;if(document.body.removeChild(E),D-$>0.5)A=D-$}return I9.set(N,A),A}function mJ(N){let F=0,A=p9();for(let M of A.segment(N))if(vJ(M.segment))F++;return F}function uJ(N,F){if(F.emojiCount===void 0)F.emojiCount=mJ(N);return F.emojiCount}function f1(N,F,A){if(A===0)return F.width;return F.width-uJ(N,F)*A}function l9(N,F,A,M,D){if(F.breakableFitAdvances!==void 0&&F.breakableFitMode===D)return F.breakableFitAdvances;F.breakableFitMode=D;let E=p9(),$=[];for(let y of E.segment(N))$.push(y.segment);if($.length<=1)return F.breakableFitAdvances=null,F.breakableFitAdvances;if(D==="sum-graphemes"){let y=[];for(let Q of $){let J=K1(Q,A);y.push(f1(Q,J,M))}return F.breakableFitAdvances=y,F.breakableFitAdvances}if(D==="pair-context"||$.length>jJ){let y=[],Q=null,J=0;for(let V of $){let U=K1(V,A),S=f1(V,U,M);if(Q===null)y.push(S);else{let q=Q+V,K=K1(q,A);y.push(f1(q,K,M)-J)}Q=V,J=S}return F.breakableFitAdvances=y,F.breakableFitAdvances}let Z=[],Y="",X=0;for(let y of $){Y+=y;let Q=K1(Y,A),J=f1(Y,Q,M);Z.push(J-X),X=J}return F.breakableFitAdvances=Z,F.breakableFitAdvances}function d9(N,F){let A=k8();A.font=N;let M=bJ(N),D=fJ(N),E=F?kJ(N,D):0;return{cache:M,fontSize:D,emojiCorrection:E}}function gJ(N){return N==="space"||N==="zero-width-break"||N==="soft-hyphen"}function l6(N){return N==="space"||N==="preserved-space"||N==="tab"||N==="zero-width-break"||N==="soft-hyphen"}function m8(N,F,A=N.widths.length){while(F<A){let M=N.kinds[F];if(!gJ(M))break;F++}return F}function a9(N,F){if(F<=0)return 0;let A=N%F;if(Math.abs(A)<=0.000001)return F;return F-A}function r9(N,F,A){return N.letterSpacing!==0&&F&&N.spacingGraphemeCounts[A]>0?N.letterSpacing:0}function u8(N,F){return F===0?0:N+F}function hJ(N,F){return N.letterSpacing!==0&&N.spacingGraphemeCounts[F]>0?N.letterSpacing:0}function c9(N,F,A,M,D){let E=F==="tab"?D+hJ(N,A):N.lineEndFitAdvances[A];return u8(M,E)}function p6(N,F,A,M){let D=F==="tab"?0:N.lineEndFitAdvances[A];return u8(M,D)}function x6(N,F,A,M,D){let E=F==="tab"?D:N.lineEndPaintAdvances[A];return u8(M,E)}function s9(N,F,A){return N.letterSpacing!==0&&F?A+N.letterSpacing:A}function i9(N,F){return N.letterSpacing===0?F:F+N.letterSpacing}function IJ(N,F,A,M,D){if(N.letterSpacing===0)return 0;if(D>0)return N.spacingGraphemeCounts[M]>0?N.letterSpacing:0;for(let E=M-1;E>=F;E--){let $=N.kinds[E];if($==="space"||$==="zero-width-break"||$==="hard-break")continue;if($==="soft-hyphen"){if(E===M-1)return 0;continue}if(E===F&&A>0)return N.letterSpacing;return N.spacingGraphemeCounts[E]>0?N.letterSpacing:0}return 0}function o9(N,F,A,M,D,E){return F+IJ(N,A,M,D,E)}function pJ(N,F){let A=0,M=N.chunks.length;while(A<M){let D=Math.floor((A+M)/2);if(F<N.chunks[D].consumedEndSegmentIndex)M=D;else A=D+1}return A<N.chunks.length?A:-1}function xJ(N,F,A){let M=A.segmentIndex;if(A.graphemeIndex>0)return F;let D=N.chunks[F];if(D.startSegmentIndex===D.endSegmentIndex&&M===D.startSegmentIndex)return A.segmentIndex=M,A.graphemeIndex=0,F;if(M<D.startSegmentIndex)M=D.startSegmentIndex;if(M=m8(N,M,D.endSegmentIndex),M<D.endSegmentIndex)return A.segmentIndex=M,A.graphemeIndex=0,F;if(D.consumedEndSegmentIndex>=N.widths.length)return-1;return A.segmentIndex=D.consumedEndSegmentIndex,A.graphemeIndex=0,F+1}function n9(N,F){if(F.segmentIndex>=N.widths.length)return-1;let A=pJ(N,F.segmentIndex);if(A<0)return-1;return xJ(N,A,F)}function lJ(N,F,A){let{widths:M,kinds:D,breakableFitAdvances:E}=N;if(M.length===0)return 0;let Z=v1().lineFitEpsilon,Y=F+Z,X=0,y=0,Q=!1,J=0,V=0,U=0,S=0,q=-1,K=0;function G(){q=-1,K=0}function z(T=U,O=S,W=y){X++,A?.(W,J,V,T,O),y=0,Q=!1,G()}function H(T,O){Q=!0,J=T,V=0,U=T+1,S=0,y=O}function B(T,O,W){Q=!0,J=T,V=O,U=T,S=O+1,y=W}function _(T,O){if(!Q){H(T,O);return}y+=O,U=T+1,S=0}function j(T,O){let W=E[T];for(let k=O;k<W.length;k++){let g=W[k];if(!Q)B(T,k,g);else if(y+g>Y)z(),B(T,k,g);else y+=g,U=T,S=k+1}if(Q&&U===T&&S===W.length)U=T+1,S=0}let L=0;while(L<M.length){if(!Q){if(L=m8(N,L),L>=M.length)break}let T=M[L],O=D[L],W=l6(O);if(!Q){if(T>Y&&E[L]!==null)j(L,0);else H(L,T);if(W)q=L+1,K=y-T;L++;continue}if(y+T>Y){if(W){_(L,T),z(L+1,0,y-T),L++;continue}if(q>=0){if(U>q||U===q&&S>0){z();continue}z(q,0,K);continue}if(T>Y&&E[L]!==null){z(),j(L,0),L++;continue}z();continue}if(_(L,T),W)q=L+1,K=y-T;L++}if(Q)z();return X}function g8(N,F,A){if(N.simpleLineWalkFastPath)return lJ(N,F,A);let{widths:M,kinds:D,breakableFitAdvances:E,discretionaryHyphenWidth:$,chunks:Z}=N;if(M.length===0||Z.length===0)return 0;let Y=v1(),X=Y.lineFitEpsilon,y=F+X,Q=0,J=0,V=!1,U=0,S=0,q=0,K=0,G=-1,z=0,H=0,B=null;function _(){G=-1,z=0,H=0,B=null}function j(){return B==="soft-hyphen"&&G===q&&K===0?H:J}function L(P=q,b=K,f){if(Q++,A!==void 0)A(o9(N,f??j(),U,S,P,b),U,S,P,b);J=0,V=!1,_()}function T(P,b){V=!0,U=P,S=0,q=P+1,K=0,J=b}function O(P,b,f){V=!0,U=P,S=b,q=P,K=b+1,J=f}function W(P,b){if(!V){T(P,b);return}J+=b,q=P+1,K=0}function k(P,b,f,m,x,r){if(!b)return;let i=p6(N,P,f,x),B0=x6(N,P,f,x,m);G=f+1,z=J-r+i,H=J-r+B0,B=P}function g(P,b){let f=E[P];for(let m=b;m<f.length;m++){let x=f[m];if(!V)O(P,m,x);else{let r=s9(N,!0,x),i=J+r;if(i9(N,i)>y)L(),O(P,m,x);else J=i,q=P,K=m+1}}if(V&&q===P&&K===f.length)q=P+1,K=0}function R(P){Q++,A?.(0,P.startSegmentIndex,0,P.consumedEndSegmentIndex,0),_()}for(let P=0;P<Z.length;P++){let b=Z[P];if(b.startSegmentIndex===b.endSegmentIndex){R(b);continue}V=!1,J=0,U=b.startSegmentIndex,S=0,q=b.startSegmentIndex,K=0,_();let f=b.startSegmentIndex;while(f<b.endSegmentIndex){if(!V){if(f=m8(N,f,b.endSegmentIndex),f>=b.endSegmentIndex)break}let m=D[f],x=l6(m),r=r9(N,V,f),i=m==="tab"?a9(J+r,N.tabStopAdvance):M[f],B0=r+i,Q0=c9(N,m,f,r,i);if(m==="soft-hyphen"){if(V)q=f+1,K=0,G=f+1,z=J+$,H=J+$,B=m;f++;continue}if(!V){if(Q0>y&&E[f]!==null)g(f,0);else T(f,i);k(m,x,f,i,r,B0),f++;continue}if(J+Q0>y){let l=J+p6(N,m,f,r),c=J+x6(N,m,f,r,i);if(B==="soft-hyphen"&&Y.preferEarlySoftHyphenBreak&&z<=y){L(G,0,H);continue}if(x&&l<=y){W(f,B0),L(f+1,0,c),f++;continue}if(G>=0&&z<=y){if(q>G||q===G&&K>0){L();continue}let n=G;L(n,0,H),f=n;continue}if(Q0>y&&E[f]!==null){L(),g(f,0),f++;continue}L();continue}W(f,B0),k(m,x,f,i,r,B0),f++}if(V){let m=G===b.consumedEndSegmentIndex?H:J;L(b.consumedEndSegmentIndex,0,m)}}return Q}function dJ(N,F,A,M){let D=N.chunks[A];if(D.startSegmentIndex===D.endSegmentIndex)return F.segmentIndex=D.consumedEndSegmentIndex,F.graphemeIndex=0,0;let{widths:E,kinds:$,breakableFitAdvances:Z,discretionaryHyphenWidth:Y}=N,X=v1(),y=X.lineFitEpsilon,Q=M+y,J=F.segmentIndex,V=F.graphemeIndex,U=0,S=!1,q=F.segmentIndex,K=F.graphemeIndex,G=-1,z=0,H=0,B=null;function _(){return B==="soft-hyphen"&&G===q&&K===0?H:U}function j(R=q,P=K,b=_()){if(!S)return null;return F.segmentIndex=R,F.graphemeIndex=P,o9(N,b,J,V,R,P)}function L(R,P){S=!0,q=R+1,K=0,U=P}function T(R,P,b){S=!0,q=R,K=P+1,U=b}function O(R,P){if(!S){L(R,P);return}U+=P,q=R+1,K=0}function W(R,P,b,f,m,x){if(!P)return;let r=p6(N,R,b,m),i=x6(N,R,b,m,f);G=b+1,z=U-x+r,H=U-x+i,B=R}function k(R,P){let b=Z[R];for(let f=P;f<b.length;f++){let m=b[f];if(!S)T(R,f,m);else{let x=s9(N,!0,m),r=U+x;if(i9(N,r)>Q)return j();U=r,q=R,K=f+1}}if(S&&q===R&&K===b.length)q=R+1,K=0;return null}function g(){if(B!=="soft-hyphen"||G<0)return null;if(z<=Q)return j(G,0,H);return null}for(let R=F.segmentIndex;R<D.endSegmentIndex;R++){let P=$[R],b=l6(P),f=R===F.segmentIndex?F.graphemeIndex:0,m=r9(N,S,R),x=P==="tab"?a9(U+m,N.tabStopAdvance):E[R],r=m+x,i=c9(N,P,R,m,x);if(P==="soft-hyphen"&&f===0){if(S)q=R+1,K=0,G=R+1,z=U+Y,H=U+Y,B=P;continue}if(!S){if(f>0){let Q0=k(R,f);if(Q0!==null)return Q0}else if(i>Q&&Z[R]!==null){let Q0=k(R,0);if(Q0!==null)return Q0}else L(R,x);W(P,b,R,x,m,r);continue}if(U+i>Q){let Q0=U+p6(N,P,R,m),v=U+x6(N,P,R,m,x);if(B==="soft-hyphen"&&X.preferEarlySoftHyphenBreak&&z<=Q)return j(G,0,H);let l=g();if(l!==null)return l;if(b&&Q0<=Q)return O(R,r),j(R+1,0,v);if(G>=0&&z<=Q){if(q>G||q===G&&K>0)return j();return j(G,0,H)}if(i>Q&&Z[R]!==null){let c=j();if(c!==null)return c;let n=k(R,0);if(n!==null)return n}return j()}O(R,r),W(P,b,R,x,m,r)}if(G===D.consumedEndSegmentIndex&&K===0)return j(D.consumedEndSegmentIndex,0,H);return j(D.consumedEndSegmentIndex,0,U)}function aJ(N,F,A){let{widths:M,kinds:D,breakableFitAdvances:E}=N,Z=v1().lineFitEpsilon,Y=A+Z,X=0,y=!1,Q=F.segmentIndex,J=F.graphemeIndex,V=-1,U=0;for(let S=F.segmentIndex;S<M.length;S++){let q=D[S],K=l6(q),G=S===F.segmentIndex?F.graphemeIndex:0,z=E[S],H=M[S];if(!y){if(G>0||H>Y&&z!==null){let B=z,_=B[G];y=!0,X=_,Q=S,J=G+1;for(let j=G+1;j<B.length;j++){let L=B[j];if(X+L>Y)return F.segmentIndex=Q,F.graphemeIndex=J,X;X+=L,Q=S,J=j+1}if(Q===S&&J===B.length)Q=S+1,J=0}else y=!0,X=H,Q=S+1,J=0;if(K)V=S+1,U=X-H;continue}if(X+H>Y){if(K)return F.segmentIndex=S+1,F.graphemeIndex=0,X;if(V>=0){if(Q>V||Q===V&&J>0)return F.segmentIndex=Q,F.graphemeIndex=J,X;return F.segmentIndex=V,F.graphemeIndex=0,U}return F.segmentIndex=Q,F.graphemeIndex=J,X}if(X+=H,Q=S+1,J=0,K)V=S+1,U=X-H}if(!y)return null;return F.segmentIndex=Q,F.graphemeIndex=J,X}function t9(N,F,A,M){if(N.simpleLineWalkFastPath)return aJ(N,F,M);return dJ(N,F,A,M)}function d6(N,F,A){let M=n9(N,F);if(M<0)return null;return t9(N,F,M,A)}var h8=null;function N7(){if(h8===null)h8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return h8}function rJ(N){if(N)return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],letterSpacing:0,spacingGraphemeCounts:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]};return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],letterSpacing:0,spacingGraphemeCounts:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[]}}function cJ(N,F){let A=[],M=[],D=0,E=!1,$=!1,Z=!1;function Y(){if(M.length===0)return;A.push({text:M.length===1?M[0]:M.join(""),start:D}),M=[],E=!1,$=!1,Z=!1}function X(Q,J,V){M=[Q],D=J,E=V,$=I6(Q),Z=lN.has(Q)}function y(Q,J){M.push(Q),E=E||J;let V=I6(Q);if(Q.length===1&&b1.has(Q))$=$||V;else $=V;Z=!1}for(let Q of N7().segment(N)){let J=Q.segment,V=c0(J);if(M.length===0){X(J,Q.index,V);continue}if(Z||u6.has(J)||b1.has(J)||F.carryCJKAfterClosingQuote&&V&&$){y(J,V);continue}if(!E&&!V){y(J,V);continue}Y(),X(J,Q.index,V)}return Y(),A}function sJ(N,F,A){if(F.length<=1)return F;let M=[],D=-1,E=!1;function $(Y,X){let y=F[Y].start,Q=X<F.length?F[X].start:N.length;M.push({text:N.slice(y,Q),start:y})}function Z(Y){if(D<0)return;if(E)if(D+1===Y)M.push(F[D]);else $(D,Y);else for(let X=D;X<Y;X++)M.push(F[X]);D=-1,E=!1}for(let Y=0;Y<F.length;Y++){let X=F[Y];if(D>=0&&!R8(F[Y-1].text,A))Z(Y);if(D<0)D=Y;E=E||c0(X.text)}return Z(F.length),M}function e9(N,F){if(F==="zero-width-break"||F==="soft-hyphen"||F==="hard-break")return 0;if(F==="tab")return 1;let A=0,M=N7();for(let D of M.segment(N))A++;return A}function iJ(N,F,A){return F>1?N+(F-1)*A:N}function oJ(N,F,A,M,D){let E=v1(),{cache:$,emojiCorrection:Z}=d9(F,x9(N.normalized)),Y=f1("-",K1("-",$),Z)+(D===0?0:D*2),y=f1(" ",K1(" ",$),Z)*8,Q=D!==0;if(N.len===0)return rJ(A);let J=[],V=[],U=[],S=[],q=N.chunks.length<=1&&!Q,K=A?[]:null,G=[],z=[],H=A?[]:null,B=Array.from({length:N.len});function _(O,W,k,g,R,P,b,f){if(R!=="text"&&R!=="space"&&R!=="zero-width-break")q=!1;if(J.push(W),V.push(k),U.push(g),S.push(R),K?.push(P),G.push(b),Q)z.push(f);if(H!==null)H.push(O)}function j(O,W,k,g,R){let P=K1(O,$),b=Q?e9(O,W):0,f=iJ(f1(O,P,Z),b,D),m=W==="space"||W==="preserved-space"||W==="zero-width-break"?0:f,x=m===0?0:m+(b>0?D:0),r=W==="space"||W==="zero-width-break"?0:f;if(R&&g&&O.length>1){let i="sum-graphemes";if(D!==0)i="segment-prefixes";else if(xN(O))i="pair-context";else if(E.preferPrefixWidthsForBreakableRuns)i="segment-prefixes";let B0=l9(O,P,$,Z,i);_(O,f,x,r,W,k,B0,b);return}_(O,f,x,r,W,k,null,b)}for(let O=0;O<N.len;O++){B[O]=J.length;let W=N.texts[O],k=N.isWordLike[O],g=N.kinds[O],R=N.starts[O];if(g==="soft-hyphen"){_(W,0,Y,Y,g,R,null,0);continue}if(g==="hard-break"){_(W,0,0,0,g,R,null,0);continue}if(g==="tab"){_(W,0,0,0,g,R,null,Q?e9(W,g):0);continue}let P=K1(W,$);if(g==="text"&&P.containsCJK){let b=cJ(W,E),f=M==="keep-all"?sJ(W,b,E.breakKeepAllAfterPunctuation):b;for(let m=0;m<f.length;m++){let x=f[m];j(x.text,"text",R+x.start,k,M==="keep-all"||!c0(x.text))}continue}j(W,g,R,k,!0)}let L=nJ(N.chunks,B,J.length),T=K===null?null:R9(N.normalized,K);if(H!==null)return{widths:J,lineEndFitAdvances:V,lineEndPaintAdvances:U,kinds:S,simpleLineWalkFastPath:q,segLevels:T,breakableFitAdvances:G,letterSpacing:D,spacingGraphemeCounts:z,discretionaryHyphenWidth:Y,tabStopAdvance:y,chunks:L,segments:H};return{widths:J,lineEndFitAdvances:V,lineEndPaintAdvances:U,kinds:S,simpleLineWalkFastPath:q,segLevels:T,breakableFitAdvances:G,letterSpacing:D,spacingGraphemeCounts:z,discretionaryHyphenWidth:Y,tabStopAdvance:y,chunks:L}}function nJ(N,F,A){let M=[];for(let D=0;D<N.length;D++){let E=N[D],$=E.startSegmentIndex<F.length?F[E.startSegmentIndex]:A,Z=E.endSegmentIndex<F.length?F[E.endSegmentIndex]:A,Y=E.consumedEndSegmentIndex<F.length?F[E.consumedEndSegmentIndex]:A;M.push({startSegmentIndex:$,endSegmentIndex:Z,consumedEndSegmentIndex:Y})}return M}function tJ(N,F,A,M){let D=M?.wordBreak??"normal",E=M?.letterSpacing??0,$=g9(N,v1(),M?.whiteSpace,D);return oJ($,F,A,D,E)}function i2(N,F,A){return tJ(N,F,!0,A)}function F7(N){return N}function eJ(N,F,A,M,D){return{width:N,start:{segmentIndex:F,graphemeIndex:A},end:{segmentIndex:M,graphemeIndex:D}}}function A7(N,F,A){if(N.widths.length===0)return 0;return g8(F7(N),F,(M,D,E,$,Z)=>{A(eJ(M,D,E,$,Z))})}function I8(N){let F=0;return g8(F7(N),Number.POSITIVE_INFINITY,(A)=>{if(A>F)F=A}),F}var NV=/[ \t\n\f\r]+/,M7=/^[ \t\n\f\r]+/,D7=/[ \t\n\f\r]+$/,E7={segmentIndex:0,graphemeIndex:0},Z7={itemIndex:0,segmentIndex:0,graphemeIndex:0};function FV(N){return N}function p8(N){return{segmentIndex:N.segmentIndex,graphemeIndex:N.graphemeIndex}}function $7(N){return N.segmentIndex===0&&N.graphemeIndex===0}function a6(N,F,A){let M=`${N}\x00${F}`,D=A.get(M);if(D!==void 0)return D;let E=F===0?void 0:{letterSpacing:F},$=I8(i2("A A",N,E)),Z=I8(i2("AA",N,E)),Y=Math.max(0,$-Z);return A.set(M,Y),Y}function AV(N){let F={segmentIndex:0,graphemeIndex:0},A=d6(N,F,Number.POSITIVE_INFINITY);if(A===null)return null;return{endGraphemeIndex:F.graphemeIndex,endSegmentIndex:F.segmentIndex,width:A}}function MV(N,F){return N===0&&F>0}function Y7(N){let F=[],A=Array.from({length:N.length}),M=new Map,D=0;for(let E=0;E<N.length;E++){let $=N[E],Z=$.letterSpacing??0,Y=M7.test($.text),X=D7.test($.text),y=$.text.replace(M7,"").replace(D7,"");if(y.length===0){if(NV.test($.text)&&D===0)D=a6($.font,Z,M);continue}let Q=D>0?D:Y?a6($.font,Z,M):0,J=i2(y,$.font,Z===0?void 0:{letterSpacing:Z}),V=AV(J);if(V===null){D=X?a6($.font,Z,M):0;continue}let U={break:$.break??"normal",endGraphemeIndex:V.endGraphemeIndex,endSegmentIndex:V.endSegmentIndex,extraWidth:$.extraWidth??0,gapBefore:Q,naturalWidth:V.width,prepared:J,sourceItemIndex:E};F.push(U),A[E]=U,D=X?a6($.font,Z,M):0}return{items:F,itemsBySourceItemIndex:A}}function DV(N,F,A,M){if(N.items.length===0||A.itemIndex>=N.items.length)return null;let D=Math.max(1,F),E=0,$=D,Z=A.itemIndex;N:while(Z<N.items.length){let Y=N.items[Z];if(!$7(A)&&A.segmentIndex===Y.endSegmentIndex&&A.graphemeIndex===Y.endGraphemeIndex){Z++,A.segmentIndex=0,A.graphemeIndex=0;continue}let X=E===0?0:Y.gapBefore,y=$7(A);if(Y.break==="never"){if(!y){Z++,A.segmentIndex=0,A.graphemeIndex=0;continue}let K=Y.naturalWidth+Y.extraWidth,G=X+K;if(E>0&&G>$)break N;M?.(Y,X,K,p8(E7),{segmentIndex:Y.endSegmentIndex,graphemeIndex:Y.endGraphemeIndex}),E+=G,$=Math.max(0,D-E),Z++,A.segmentIndex=0,A.graphemeIndex=0;continue}let Q=X+Y.extraWidth;if(E>0&&Q>=$)break N;if(y){let K=Q+Y.naturalWidth;if(K<=$){M?.(Y,X,Y.naturalWidth+Y.extraWidth,p8(E7),{segmentIndex:Y.endSegmentIndex,graphemeIndex:Y.endGraphemeIndex}),E+=K,$=Math.max(0,D-E),Z++,A.segmentIndex=0,A.graphemeIndex=0;continue}}let J=Math.max(1,$-Q),V={segmentIndex:A.segmentIndex,graphemeIndex:A.graphemeIndex},U=d6(Y.prepared,V,J);if(U===null){Z++,A.segmentIndex=0,A.graphemeIndex=0;continue}if(A.segmentIndex===V.segmentIndex&&A.graphemeIndex===V.graphemeIndex){Z++,A.segmentIndex=0,A.graphemeIndex=0;continue}let S=U+Y.extraWidth,q=X+S;if(E>0&&y&&q>$)break N;if(E>0&&y&&X>0&&MV(V.segmentIndex,V.graphemeIndex)){let K={segmentIndex:0,graphemeIndex:0};if(d6(Y.prepared,K,Math.max(1,D-Y.extraWidth))!==null&&(K.segmentIndex>V.segmentIndex||K.segmentIndex===V.segmentIndex&&K.graphemeIndex>V.graphemeIndex))break N}if(M?.(Y,X,S,p8(A),{segmentIndex:V.segmentIndex,graphemeIndex:V.graphemeIndex}),E+=q,$=Math.max(0,D-E),V.segmentIndex===Y.endSegmentIndex&&V.graphemeIndex===Y.endGraphemeIndex){Z++,A.segmentIndex=0,A.graphemeIndex=0;continue}A.segmentIndex=V.segmentIndex,A.graphemeIndex=V.graphemeIndex;break}if(E===0)return null;return A.itemIndex=Z,E}function EV(N,F,A=Z7){let M=FV(N),D={itemIndex:A.itemIndex,segmentIndex:A.segmentIndex,graphemeIndex:A.graphemeIndex},E=[],$=DV(M,F,D,(Z,Y,X,y,Q)=>{E.push({itemIndex:Z.sourceItemIndex,gapBefore:Y,occupiedWidth:X,start:y,end:Q})});if($===null)return null;return{fragments:E,width:$,end:D}}function X7(N,F,A){let M=0,D=Z7;while(!0){let E=EV(N,F,D);if(E===null)return M;A(E),M++,D=E.end}}function aN(N,F,A){let M=N.image?F.images.get(N.image.url)??null:null,D=N.image?.width??null,E=Math.min(A,D??240),$=Math.max(120,Math.round(E*0.5625));if(!M||M.intrinsicWidth<=0||M.intrinsicHeight<=0)return{height:$,width:E};let Z=Math.min(A,D??M.intrinsicWidth),Y=Math.min(1,Z/M.intrinsicWidth);return{height:Math.max(48,Math.round(M.intrinsicHeight*Y)),width:Math.max(48,Math.round(M.intrinsicWidth*Y))}}function y7(N,F){if(!N.image)return`${N.kind}:missing-image`;let A=F.images.get(N.image.url);return`${N.kind}:${N.image.url}:${N.image.width??0}:${A?.status??"loading"}:${A?.intrinsicWidth??0}:${A?.intrinsicHeight??0}`}var r6=4;function x8(N,F){return Math.max(18,N.measureText(`@${F.name}`).width+8)}var Q7=[{fontSize:32,lineHeight:36},{fontSize:26,lineHeight:32},{fontSize:21,lineHeight:28},{fontSize:21,lineHeight:28},{fontSize:19,lineHeight:26},{fontSize:18,lineHeight:26}],J7='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',$V=32,l8;function o2(N){if(N?.type==="heading"){let{fontSize:F}=q7(N.depth);return`700 ${F}px ${J7}`}switch(N?.type){case"code":return"15px ui-monospace, SFMono-Regular, Menlo, monospace";default:return`16px ${J7}`}}function k1(N,F){if(N?.type==="heading")return q7(N.depth).lineHeight;if(N?.type==="code")return 22;return F}function q7(N){return Q7[N-1]??Q7.at(-1)}function a8(N){return ZV(N)?N.split(""):a2(N)}function ZV(N){for(let F=0;F<N.length;F+=1)if(N.charCodeAt(F)>127)return!1;return!0}function n2(N,F,A,M,D,E,$){let Z=`${i6(F,$)}:${D}:${E}:${A}`,Y=N.measuredLines.get(Z);if(Y)return Y;let X=XV(N,F,A,M,D,E,$);return z9(N,Z,X)}function s6(N,F,A,M,D,E,$,Z){let Y=`${i6(F,Z)}:${A}:${M}:${E}:${$}`,X=N.lineBoundaries.get(Y);if(X)return X;let y=S7(),Q=[{left:0,offset:0}],J=0,V=F.inlines.filter((U)=>U.end>A&&U.start<M);for(let U of V){let S=Math.max(A,U.start),q=Math.min(M,U.end),K=F.text.slice(S,q),G=S-A;if(U.kind==="image"){let z=aN(U,Z,$).width;J+=z,G+=K.length,Q.push({left:J,offset:G});continue}if(y.font=c6(E,U.marks),o6(U)){J+=x8(y,U.mention),G+=K.length,Q.push({left:J,offset:G});continue}for(let z of OV(N,y,K))J+=z.width,G+=z.length,Q.push({left:J,offset:G})}return H9(N,Y,Q)}function YV(N,F,A,M){let D=`${A}::${M}::${F}`,E=N.preparedText.get(D);if(E)return E;let $=i2(F,A,{whiteSpace:M});return G9(N,D,$)}function XV(N,F,A,M,D,E,$){let Z=F.text,Y=zV(F);if(Z.length===0)return[{end:0,height:E,start:0,text:"",width:0}];if(HV(Y))return QV(N,F,A,D,E,$);if(Y.hasRichInline)return JV(F,A,D,E);let X=YV(N,Z,A,LV(M,Y)),y=K7(X.segments),Q=[];if(A7(X,D,(J)=>{let V=y(J.start),U=yV(Z,V,y(J.end));Q.push({end:U,height:E,start:V,text:Z.slice(V,U),width:J.width})}),Y.hasHardBreak&&Z.endsWith(`
|
|
20
|
-
`))Q.push({end:
|
|
21
|
-
`?A-1:A}function
|
|
22
|
-
`){D.push({end:
|
|
23
|
-
`)break;let
|
|
24
|
-
`){let
|
|
25
|
-
`?
|
|
26
|
-
`)D.push({end:$.end,height:M,start:$.end,text:"",width:0});return D}function
|
|
27
|
-
`?0:
|
|
28
|
-
`).reduce((E,$)=>E+Math.max(1,Math.ceil($.length/M)),0);return{estimatedHeight:D*A,lineCount:D,width:N.width}}function t6(N,F,A=D2(),M=null){let D=M??{images:new Map},E=k6(F),$=[],Z=new Map,Y=new Map(N.regions.map((q)=>[q.id,{textLength:q.text.length}])),X=N.blockIndex,y=cN(N.document.blocks),Q=new Map,J=new Set(N.regions.map((q)=>q.id)),V=E.paddingY,U=null;for(let q of N.blocks){let K=y.get(q.id)??null;if(!K||R1(K))continue;let G=y1(q),z=q.regionIds.filter((L)=>J.has(L));if(!G&&z.length===0)continue;if(U!==null){if(V+=m6(X,y,U.id,q.id,E.blockGap),!y1(U)){let L=Q.get(U.id);if(L)L.bottom=Math.max(L.bottom,V)}}let H=q.depth,B=E.paddingX+H*E.indentWidth,_=r2(X,N.listItemMarkers,q.id),j=Math.max(40,E.width-B-E.paddingX-_);if(G){let L=V+E.lineHeight;Q.set(q.id,{top:V,bottom:L}),V=L}else if(K.type==="table"){let L=z.map((T)=>N.regionIndex.get(T)).filter((T)=>T!==void 0);V=G7($,Q,Z,L,A,K,B,V,E,D)}else for(let L of z){let T=N.regionIndex.get(L);if(!T)continue;V=RV($,Q,Z,T,A,K,B,V,j,E,D)}U=q}let S=[];for(let q of N.blocks){let K=y.get(q.id);if(!K||R1(K))continue;let G=Q.get(q.id);if(!G)continue;S.push({bottom:G.bottom,depth:q.depth,id:q.id,top:G.top,type:q.type})}return{blocks:S,regionBounds:Z,regionLineIndices:bV($),regionMetrics:Y,height:Math.max(V,E.paddingY),lines:$,options:E,width:E.width}}function RV(N,F,A,M,D,E,$,Z,Y,X,y){let Q=o2(E),J=k1(E,X.lineHeight),V=n2(D,M,Q,E,Y,J,y),U=Z;for(let S of V){let q={blockId:M.blockId,boundaries:s6(D,M,S.start,S.end,S.text,Q,Y,y),regionId:M.id,end:S.end,font:Q,height:S.height,left:$,start:S.start,text:S.text,top:U,width:S.width};N.push(q),c8(F,q),fV(A,q),U+=S.height}return U}function bV(N){N.sort((A,M)=>A.top-M.top||A.left-M.left);let F=new Map;for(let A=0;A<N.length;A+=1){let M=N[A].regionId,D=F.get(M);if(D)D.push(A);else F.set(M,[A])}return F}function fV(N,F){let A=N.get(F.regionId),M=F.left+F.width,D=F.top+F.height;N.set(F.regionId,A?{bottom:Math.max(A.bottom,D),left:Math.min(A.left,F.left),right:Math.max(A.right,M),top:Math.min(A.top,F.top)}:{bottom:D,left:F.left,right:M,top:F.top})}function c8(N,F){let A=N.get(F.blockId),M=F.top+F.height;N.set(F.blockId,{bottom:A?Math.max(A.bottom,M):M,top:A?Math.min(A.top,F.top):F.top})}function cN(N){let F=new Map,A=(M)=>{for(let D of M)if(F.set(D.id,D),D.type==="blockquote"||D.type==="listItem")A(D.children);else if(D.type==="list")A(D.items)};return A(N),F}var s8=null;function vV(N){let F=/(\d+(?:\.\d+)?)\s*px/.exec(N);return F?Number.parseFloat(F[1]):16}function t0(N){s8??=new Map;let F=s8.get(N);if(F)return F;let A=H7(),M=Math.max(12,Math.round(vV(N)));A.font=N;let D=A.measureText("Hg"),E=Math.round(D.actualBoundingBoxAscent||0),$=Math.round(D.actualBoundingBoxDescent||0),Z=E+$,Y=Math.max(M,Z),X=Z>0?E:Math.round(Y*0.8),y=Z>0?$:Math.max(2,Y-X),Q={ascent:X,descent:y,emHeight:Y};return s8.set(N,Q),Q}function sN(N,F){let{emHeight:A}=t0(F);return Math.max(0,Math.floor((N-A)/2))}function $2(N,F){let{ascent:A}=t0(F);return sN(N,F)+A}var e6;function z7(N,F){let A=H7();if(N.length===0)return 0;return A.font=F,A.measureText(N).width}function H7(){if(e6!==void 0)return e6;let F=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d");if(!F)throw Error("Canvas font metrics require OffscreenCanvas or a DOM canvas context.");return e6=F,e6}function W7(N,F){let A=0,M=N.lines.length-1;while(A<=M){let D=A+M>>1,E=N.lines[D];if(F<E.top){M=D-1;continue}if(F>=E.top+E.height){A=D+1;continue}return{index:D,line:E}}return null}function N3(N,F){let A=[...N.regionBounds.entries()].find(([,E])=>{return F.x>=E.left&&F.x<=E.right&&F.y>=E.top&&F.y<=E.bottom});if(A)return iN(N,A[0],F.y);let M=W7(N,F.y);if(!M)return null;let D=kV(N,F.y,M.index);if(D.length===1)return D[0]??null;return D.find((E)=>{let $=N.regionBounds.get(E.line.regionId);return $?F.x>=$.left&&F.x<=$.right:!1})??[...D].sort((E,$)=>{let Z=N.regionBounds.get(E.line.regionId),Y=N.regionBounds.get($.line.regionId),X=B7(F.x,Z),y=B7(F.x,Y);return X-y})[0]??null}function F3(N,F,A){if(N.blocks.length===0)return{endIndex:0,startIndex:0};let M=F+A,D=_7(N,F),E=_7(N,M);if(D>0){if(N.blocks[D-1].bottom>F)D-=1}if(E<N.blocks.length){if(N.blocks[E].top<M)E+=1}return{endIndex:E,startIndex:D}}function _7(N,F){let A=0,M=N.blocks.length;while(A<M){let D=A+M>>1;if(N.blocks[D].bottom<=F)A=D+1;else M=D}return A}function A3(N,F,A){if(N.lines.length===0)return{endIndex:0,startIndex:0};let M=F+A,D=P7(N,F),E=P7(N,M);if(D>0){let $=N.lines[D-1];if($.top+$.height>F)D-=1}if(E<N.lines.length){if(N.lines[E].top<M)E+=1}return{endIndex:E,startIndex:D}}function e0(N,F,A){return e2(N,F,A)?.line??null}function iN(N,F,A){let M=N.regionLineIndices.get(F);if(!M||M.length===0)return null;let D=M[0],E=Number.POSITIVE_INFINITY;for(let $ of M){let Z=N.lines[$],Y=A<Z.top?Z.top-A:A>Z.top+Z.height?A-(Z.top+Z.height):0;if(Y<E)E=Y,D=$;if(Y===0)break}return{index:D,line:N.lines[D]}}function e2(N,F,A){let M=N.regionLineIndices.get(F);if(!M||M.length===0)return null;let D=0,E=M.length-1;while(D<=E){let y=D+E>>1,Q=M[y],J=N.lines[Q];if(A<J.start){E=y-1;continue}if(A>J.end){D=y+1;continue}return{index:Q,line:J}}let $=M[0],Z=M[M.length-1],Y=N.lines[$],X=N.lines[Z];if(A<=Y.start)return{index:$,line:Y};if(A>=X.end)return{index:Z,line:X};return null}function kV(N,F,A){let M=[];for(let D=A;D>=0;D-=1){let E=N.lines[D];if(F<E.top||F>=E.top+E.height)break;M.unshift({index:D,line:E})}for(let D=A+1;D<N.lines.length;D+=1){let E=N.lines[D];if(F<E.top||F>=E.top+E.height)break;M.push({index:D,line:E})}return M}function B7(N,F){if(!F)return Number.POSITIVE_INFINITY;if(N<F.left)return F.left-N;if(N>F.right)return N-F.right;return 0}function R0(N,F){return N.left+mV(N.boundaries,F)}function mV(N,F){for(let M of N)if(M.offset===F)return M.left;return N.filter((M)=>M.offset<=F).at(-1)?.left??0}function P7(N,F){let A=0,M=N.lines.length;while(A<M){let D=A+M>>1,E=N.lines[D];if(E.top+E.height<=F)A=D+1;else M=D}return A}function i8(N,F){if(N.length===0)return 0;for(let A=1;A<N.length;A+=1){let M=N[A-1],D=N[A],E=M.left+(D.left-M.left)/2;if(F<=E)return M.offset;if(F<=D.left)return D.offset}return N.at(-1)?.offset??0}function S1(N,F,A){return R0(F,A)+p0(N,F)}function p0(N,F){let A=G1(N,F.blockId,"listItem");if(!A)return 0;return Y2(N,A.id)?.kind==="task"?j9:L9}function Z2(N){return{left:N.left,size:w9,top:N.top+3}}function G1(N,F,A){let M=N.documentIndex.blockIndex.get(F)??null;while(M){if(M.type===A)return M;let D=M.parentBlockId;M=D?N.documentIndex.blockIndex.get(D)??null:null}return null}function Y2(N,F){return N.documentIndex.listItemMarkers.get(F)??null}function o0(N,F,A){if(!N.regionMetrics.get(A.regionId))return null;let D=e0(N,A.regionId,A.offset);if(!D)return null;return{blockId:D.blockId,regionId:D.regionId,height:D.height,left:R0(D,A.offset-D.start),offset:A.offset,top:D.top}}function N1(N,F,A){let M=e0(F,A.regionId,A.offset);if(!M)return A.left;return A.left+p0(N,M)+uV(N,M,A.offset)}function uV(N,F,A){if(A<=F.end)return 0;let M=N.documentIndex.regionIndex.get(F.regionId);if(!M)return 0;let D=M.text.slice(F.end,A);if(!/^[ \t]+$/u.test(D))return 0;return z7(D,F.font)}var M3;function O7(N,F){if(N.length===0)return null;F=Math.max(0,Math.min(F,N.length));let A=gV(),M=null;for(let D of A.segment(N)){let E=D.index,$=E+D.segment.length;if(!D.isWordLike){if(F<$)return F===E&&M?.end===F?M:null;continue}let Z={end:$,start:E};if(F>=E&&F<$)return Z;if(F===$){M=Z;continue}if(F<E)return M;M=Z}return M&&F===M.end?M:null}function gV(){if(M3!==void 0)return M3;let N=Intl.Segmenter;if(typeof N!=="function")throw Error("Word selection requires Intl.Segmenter.");return M3=new N(void 0,{granularity:"word"}),M3}function v0(N,F,A){let M=hV(N,F,A);if(!M)return null;let D=M.snapToLineStart?M.line.left:A.x;return T7(N,F,M.line,D)}function D3(N,F,A){let M=N.lines[N.lines.length-1];if(!M||A.y<=M.top+M.height)return null;return T7(N,F,M,A.x)}function E3(N,F,A,M){let D=L7(F,M.regionId);if(!D)return null;let E=v0(N,F,A);if(E)return{regionId:E.regionId,offset:E.offset};let $=A.y<IV(N);return{regionId:M.regionId,offset:$?0:D.text.length}}function $3(N,F,A){let M=v0(N,F,A);if(!M)return null;let D=L7(F,M.regionId);if(!D||D.text.length===0)return null;let E=O7(D.text,M.offset);if(!E)return null;return{anchor:{regionId:M.regionId,offset:E.start},focus:{regionId:M.regionId,offset:E.end}}}function T7(N,F,A,M){let D=N.regionMetrics.get(A.regionId);if(!D)return null;let E=Math.max(0,M-p0(F,A)-A.left),$=i8(A.boundaries,E),Z=Math.min(D.textLength,A.start+$);return{regionId:A.regionId,offset:Z,left:R0(A,$),top:A.top,height:A.height}}function hV(N,F,A){for(let[D,E]of N.regionBounds)if(A.x>=E.left&&A.x<=E.right&&A.y>=E.top&&A.y<=E.bottom){let $=iN(N,D,A.y)?.line??null;return $?{line:$}:null}let M=N3(N,A)?.line??null;if(M)return{line:M};for(let D of N.blocks){if(A.y<D.top||A.y>D.bottom)continue;for(let $=N.lines.length-1;$>=0;$--)if(N.lines[$].blockId===D.id)return{line:N.lines[$]};let E=F.documentIndex.blockIndex.get(D.id);if(E&&y1(E)){let $=LN(F.documentIndex,D.id);if($){let Z=N.lines.find((Y)=>Y.blockId===$.id);if(Z)return{line:Z,snapToLineStart:!0}}}}return null}function L7(N,F){return N.documentIndex.regionIndex.get(F)??null}function IV(N){return N.lines[0]?.top??0}function o8(N,F,A){let M=pV(N,A);if(!M||M.start!==0)return null;let D=G1(F,M.blockId,"listItem");if(!D)return null;if(Y2(F,D.id)?.kind!=="task")return null;let $=Z2(M),Z=$.left-4,Y=$.left+$.size+4,X=$.top-4,y=$.top+$.size+4;return A.x>=Z&&A.x<=Y&&A.y>=X&&A.y<=y?{listItemId:D.id}:null}function n8(N,F,A){let M=v0(N,F,A);if(!M)return null;let D=xV(F,M.regionId);if(!D)return null;let E=D.inlines.find(($)=>$.link&&M.offset>=$.start&&M.offset<$.end);if(!E?.link)return null;return{endOffset:E.end,regionId:M.regionId,startOffset:E.start,title:E.link.title,url:E.link.url}}function Z3(N,F,A,M){let D=o8(N,F,A);if(D)return{kind:"task-toggle",listItemId:D.listItemId};let E=v0(N,F,A);if(!E)return null;let $=w7(E.regionId,E.offset,M),Z=n8(N,F,A);if(Z)return{endOffset:Z.endOffset,kind:"link",commentThreadIndex:$,regionId:Z.regionId,startOffset:Z.startOffset,title:Z.title,url:Z.url};return{kind:"text",commentThreadIndex:$}}function Y3(N,F,A,M){let D=F.documentIndex.regionIndex.get(A.regionId);if(!D)return null;let E=w7(A.regionId,A.offset,M),$=D.inlines.find((Z)=>A.offset>=Z.start&&A.offset<=Z.end)??null;if($?.link)return{commentThreadIndex:E,endOffset:$.end,kind:"link",regionId:A.regionId,startOffset:$.start,title:$.link.title,url:$.link.url};if(E!==null)return{commentThreadIndex:E,kind:"text"};return null}function oN(N,F,A,M){let D=N.documentIndex.regionIndex.get(N.selection.anchor.regionId);if(!M.image||!D)return null;let E=e0(F.layout,D.id,M.start);if(!E)return null;let $=E.left+p0(N,E),Z=$+R0(E,M.start-E.start)-E.left,Y=$+R0(E,M.end-E.start)-E.left,{height:X}=aN(M,A,E.width),y=E.top+Math.max(0,Math.floor((E.height-X)/2));return{left:Z,top:y,width:Y-Z,height:X}}function w7(N,F,A){for(let M of A)if(M.regionId===N&&F>=M.startOffset&&F<=M.endOffset)return M.threadIndex;return null}function pV(N,F){return N.lines.find((A)=>F.y>=A.top-4&&F.y<=A.top+A.height+4)??N.lines.filter((A)=>Math.abs(F.y-(A.top+A.height/2))<=10).sort((A,M)=>Math.abs(F.y-(A.top+A.height/2))-Math.abs(F.y-(M.top+M.height/2)))[0]??null}function xV(N,F){return N.documentIndex.regionIndex.get(F)??null}function j7(N,F,A,M,D,E,$){let Z=t8(F,D,E,$),Y=N.measuredContainerHeights.get(Z);if(Y!==void 0)return Y;let X=k1(A,E.lineHeight),y=E.paddingX+M*E.indentWidth,Q=Math.max(40,E.width-y-E.paddingX-D);if(F.inlines.some((U)=>U.kind==="image"||U.kind==="mention")){let U=o2(A);return n2(N,F,U,A,Q,X,$).reduce((S,q)=>S+q.height,0)}let J=n6({charWidth:E.charWidth,lineHeight:X,text:F.text,width:Q});return Math.max(X,J.lineCount*X)}function C7(N,F,A,M){let D=n6({charWidth:M,lineHeight:A,text:N.text,width:F});return Math.max(A,D.lineCount*A)}function t8(N,F,A,M){return`${i6(N,M)}:${A.width}:${A.paddingX}:${A.indentWidth}:${A.lineHeight}:${F}`}function e8(N,F){let A=0,M=N.entries.length;while(A<M){let D=A+M>>1;if(N.entries[D].bottom<=F)A=D+1;else M=D}return A}function R7(N,F,A,M,D){let E=M,$=D;for(let Z=M;Z<D;Z+=1){let Y=N.regions[Z],X=F.get(Y.blockId);if(!X)continue;if(X.type==="table"){let y=A.get(X.regionIds[0]??""),Q=A.get(X.regionIds[X.regionIds.length-1]??"");if(y!==void 0)E=Math.min(E,y);if(Q!==void 0)$=Math.max($,Q+1)}}return{endIndex:$,startIndex:E}}function b7(N,F,A){return{...N,blocks:N.blocks.map((M)=>({...M,bottom:M.bottom+F,top:M.top+F})),regionBounds:new Map([...N.regionBounds.entries()].map(([M,D])=>[M,{bottom:D.bottom+F,left:D.left,right:D.right,top:D.top+F}])),height:A,lines:N.lines.map((M)=>({...M,top:M.top+F}))}}function f7(N,F,A,M,D){for(let[E,$]of A.regionBounds){let Z=$.bottom-$.top,Y=F.regionIndex.get(E),X=Y?r2(F.blockIndex,F.listItemMarkers,Y.blockId):0;_9(N,t8(Y??{path:E,inlines:[],text:""},X,M,D),Z)}}function N5(N,F,A,M=[],D=D2(),E=null){let $=k6(F),Z=E??{images:new Map},Y=cN(N.document.blocks),X=N.blockIndex,y=new Set(M),Q=Math.max(0,A.top-A.overscan),J=A.top+A.height+A.overscan,V=dV(D,N,Y,X,$,Z),U=e8(V,Q),S=e8(V,J);if(U>0){let H=V.entries[U-1];if(H&&H.bottom>Q)U-=1}if(S<V.entries.length){let H=V.entries[S];if(H&&H.top<J)S+=1}for(let H of y){let B=V.containerIndices.get(H);if(B===void 0)continue;U=Math.min(U,B),S=Math.max(S,B+1)}if(!Number.isFinite(U)||!Number.isFinite(S))return{estimateRegionBounds:V.estimateRegionBounds,layout:t6({...N,regions:[]},$,D,Z),totalHeight:V.totalHeight,viewport:A};let q=R7(N,X,V.containerIndices,U,S),K=V.entries[q.startIndex]?.top??$.paddingY,G=t6({...N,regions:N.regions.slice(q.startIndex,q.endIndex)},$,D,Z),z=b7(G,K,V.totalHeight);return f7(D,N,z,$,Z),{estimateRegionBounds:V.estimateRegionBounds,layout:z,totalHeight:V.totalHeight,viewport:A}}function dV(N,F,A,M,D,E){let $=cV(F,D,E),Z=P9(N,F,$);if(Z)return Z;let Y=D.paddingY,X=[],y=new Map,Q=0,J=null;for(let V of F.blocks){let U=A.get(V.id)??null;if(!U||R1(U))continue;let S=y1(V);if(!S&&V.regionIds.length===0)continue;if(J!==null)Y+=m6(M,A,J,V.id,D.blockGap);if(S)Y+=D.lineHeight;else if(U.type==="table"){let q=aV({block:U,containerIndices:y,entries:X,index:Q,options:D,runtimeBlocks:M,totalHeight:Y,regions:F.regions});if(q)Q=q.nextIndex,Y=q.totalHeight}else{let q=r2(F.blockIndex,F.listItemMarkers,V.id);for(let K of V.regionIds){let G=F.regions[Q];if(!G){Q+=1;continue}let z=j7(N,G,U,V.depth,q,D,E),H=Y,B=H+z;X[Q]={bottom:B,top:H},y.set(G.id,Q),Y=B,Q+=1}}J=V.id}return W9(N,F,$,{containerIndices:y,entries:X,estimateRegionBounds(V){let U=y.get(V);return U===void 0?null:X[U]??null},totalHeight:Y})}function aV({block:N,containerIndices:F,entries:A,index:M,options:D,runtimeBlocks:E,totalHeight:$,regions:Z}){let Y=E.get(N.id),X=Y?.regionIds??[];if(X.length===0)return null;let y=Z.slice(M,M+X.length);if(y.length===0||y[0]?.blockId!==N.id)return null;let Q=Y?.depth??0,J=D.paddingX+Q*D.indentWidth,V=Math.max(r8,D.width-J-D.paddingX),U=Math.max(1,...N.rows.map((H)=>H.cells.length)),S=V/U,q=Math.max(40,S-rN*2),K=k1(N,D.lineHeight),G=rV(y,M),z=$;for(let H=0;H<N.rows.length;H+=1){let B=G.get(H)??[],_=Math.max(K+t2*2,...B.map(({region:L})=>C7(L,q,K,D.charWidth)+t2*2)),j=z+_;for(let{index:L,region:T}of B)A[L]={bottom:j,top:z},F.set(T.id,L);z=j}for(let H=M;H<M+y.length;H+=1){let B=Z[H];if(!B||A[H])continue;A[H]={bottom:z,top:z},F.set(B.id,H)}return{nextIndex:M+y.length,totalHeight:z}}function rV(N,F){let A=new Map;for(let[M,D]of N.entries()){let E=D.tableCellPosition?.rowIndex;if(E===void 0)continue;let $=A.get(E)??[];$.push({index:F+M,region:D}),A.set(E,$)}return A}function cV(N,F,A){return[F.width,F.paddingX,F.paddingY,F.indentWidth,F.lineHeight,F.blockGap,sV(N,A)].join(":")}function sV(N,F){if(N.imageUrls.size===0)return"";return N.regions.flatMap((A)=>A.inlines.filter((M)=>M.kind==="image"&&M.image).map((M)=>{let D=M.image?F.images.get(M.image.url):null;return`${M.image?.url??""}:${M.image?.width??0}:${D?.status??"loading"}:${D?.intrinsicWidth??0}:${D?.intrinsicHeight??0}`})).join("|")}function F5(N,F,A,M=null){let D={height:F.height,overscan:Math.max(160,F.height),top:F.top},E=N5(N.documentIndex,F,D,[N.selection.anchor.regionId,N.selection.focus.regionId],A,M);return{blockMap:cN(N.documentIndex.document.blocks),estimateRegionBounds:E.estimateRegionBounds,regionBounds:new Map(E.layout.regionBounds),layout:E.layout,paintHeight:Math.max(240,D.height+D.overscan*2),paintTop:Math.max(0,D.top-D.overscan),totalHeight:E.totalHeight,viewport:{height:D.height,top:D.top}}}function X3(N,F,A){return v0(F.layout,N,A)??D3(F.layout,N,A)}function A5(N,F,A,M){return E3(F.layout,N,A,M)}function M5(N,F,A){return $3(F.layout,N,A)}function v7(N,F,A,M){return Z3(F.layout,N,A,M)}function k7(N,F,A,M){return Y3(F.layout,N,A,M)}function D5(N,F,A){return o0(F.layout,N.documentIndex,A)}function m1(N,F,A){let M=o0(F.layout,N.documentIndex,A);if(!M)return null;return{...M,left:N1(N,F.layout,M)}}var m7=1;function u7(N,F,A){let M=N.documentIndex.regionOrderIndex.get(N.selection.focus.regionId);if(M===void 0)return N;let D=N.documentIndex.regions[M],E=uN(D.text,N.selection.focus.offset,F);if(E!==N.selection.focus.offset)return I0(N,D.id,E,A);if(F<0){let Z=F2(N.documentIndex,D.id);if(!Z)return N;return I0(N,Z.id,Z.text.length,A)}let $=TN(N.documentIndex,D.id);if(!$)return N;return I0(N,$.id,0,A)}function g7(N,F,A,M,D){let E=e2(F,A.regionId,A.offset);if(!E)return N;let $=F.lines[E.index+M];if(!$)return N;let Z=v0(F,N,{x:N1(N,F,A)+m7,y:$.top+$.height/2});if(!Z)return N;return I0(N,Z.regionId,Z.offset,D)}function h7(N,F,A,M){let D=p7(N,F);if(!D)return N;return I0(N,D.regionId,A==="Home"?D.start:D.end,M)}function I7(N,F,A,M,D){let E=p7(N,F);if(!E)return N;let Z=Math.max(1,Math.floor(480/F.options.lineHeight)),Y=e2(F,E.regionId,N.selection.focus.offset),X=Y?F.lines[Y.index+M*Z]:null;if(!X)return N;let y=v0(F,N,{x:N1(N,F,A)+m7,y:X.top+X.height/2});if(!y)return N;return I0(N,y.regionId,y.offset,D)}function p7(N,F){return e0(F,N.selection.focus.regionId,N.selection.focus.offset)}var iV=1;function x7(N,F,A,M,D){let E=N.documentIndex.regionIndex.get(N.selection.focus.regionId)??null;if(!E)return null;let $=N.documentIndex.tableCellIndex.get(E.id)??null,Z=N.documentIndex.blockIndex.get(E.blockId)??null;if(!$||Z?.type!=="table")return null;let Y=oV(N,Z.id,$.rowIndex+M,$.cellIndex)??nV(N,Z.id,M);if(!Y)return N;let X=F.regionBounds.get(E.id),y=F.regionBounds.get(Y.id);if(!X||!y)return N;let Q=y.top+tV(A.top+A.height/2-X.top,0,Math.max(0,y.bottom-y.top-1)),J=v0(F,N,{x:N1(N,F,A)+iV,y:Q});if(!J)return N;return I0(N,J.regionId,J.offset,D)}function oV(N,F,A,M){return g2(N.documentIndex,F,A,M)}function nV(N,F,A){let M=N.documentIndex.blockIndex.get(F),D=N.documentIndex.regions,E=M?N.documentIndex.roots[M.rootIndex]?.regionRange:void 0;if(!E)return null;return A<0?D[E.start-1]??null:D[E.end]??null}function tV(N,F,A){return Math.max(F,Math.min(A,N))}function E5(N,F,A=!1){return u7(N,F,A)}function $5(N,F,A,M=!1){return eV(N,F,A,M)}function Z5(N,F,A,M=!1){return NU(N,F,A,M)}function Y5(N,F,A,M=!1){return h7(N,F,A,M)}function X5(N,F,A=!1){return FU(N,F,A)}function y5(N,F,A){let M=X3(N,F,A);return M?O0(N,{offset:M.offset,regionId:M.regionId}):null}function Q5(N,F,A){let M=X3(N,F,A);return M?I0(N,M.regionId,M.offset,!0):null}function nN(N,F,A,M){let D=A5(N,F,A,M);return D?O0(N,{anchor:M,focus:D}):null}function eV(N,F,A,M){let D=l7(N,F);if(!D)return N;return x7(N,F,D,A,M)??g7(N,F,D,A,M)}function NU(N,F,A,M){let D=l7(N,F);if(!D)return N;return I7(N,F,D,A,M)}function FU(N,F,A){let M=N.documentIndex.regions,D=F==="start"?M[0]:M.at(-1);if(!D)return N;return I0(N,D.id,F==="start"?0:D.text.length,A)}function l7(N,F){return o0(F,N.documentIndex,{regionId:N.selection.focus.regionId,offset:N.selection.focus.offset})}var AU=80;function a7({context:N,containerBounds:F,isHeaderRow:A,lineHeight:M,theme:D}){let E=c7(F,M);N.fillStyle=A?D.tableHeaderBackground:D.tableBodyBackground,N.fillRect(E.left,E.top,E.width,E.height),s7(N,E,D)}function r7({activeBlockFlashes:N,activeBlockId:F,activeRegionId:A,context:M,editorState:D,endIndex:E,layout:$,regionBounds:Z,startIndex:Y,theme:X,verticalBleed:y}){if(!F||!A)return;let Q=D.documentIndex.blockIndex.get(F)??null;if(Q?.type!=="table")return;if((D.documentIndex.regionIndex.get(A)??null)?.blockId!==F)return;let V=Z.get(A)??null,U=$.regionLineIndices.get(A)??null;if(!V||!U||U.length===0)return;let S=$.lines[U[0]]??null;if(!S)return;let q=c7(V,S.height);if(q.width===0)return;let K=d7({context:M,endIndex:E,fillStyle:X.activeBlockBackground,layout:$,left:q.left,lineIndices:U,startIndex:Y,verticalBleed:y,width:q.width}),G=Q.path?N.get(Q.path)??null:null;if(G)d7({context:M,endIndex:E,fillStyle:Q6(X.activeBlockFlash,G),layout:$,left:q.left,lineIndices:U,startIndex:Y,verticalBleed:y,width:q.width});if(!K)return;s7(M,q,X)}function d7({context:N,endIndex:F,fillStyle:A,layout:M,left:D,lineIndices:E,startIndex:$,verticalBleed:Z,width:Y}){N.fillStyle=A;let X=!1;for(let y of E){if(y<$)continue;if(y>=F)break;let Q=M.lines[y];N.fillRect(D,Q.top-Z,Y,Q.height),X=!0}return X}function c7(N,F){return{height:Math.max(N.bottom-N.top,F),left:N.left,top:N.top,width:Math.max(N.right-N.left,AU)}}function s7(N,F,A){N.strokeStyle=A.tableBorder,N.strokeRect(F.left,F.top,F.width,F.height)}var y3=2,MU=3,DU=12,EU=6,$U=3,ZU=8,YU=12,XU=28,yU=4,i7=1,QU=5,JU=2,VU=1;function o7(N,F,A,M,D,E,$){if(!M||F.start!==0)return;if(A?.type==="code"){let Z=Math.max(0,F.left-YU);N.fillStyle=E.codeBackground,N.fillRect(Z,M.top-yU,Math.max(M.right-F.left+XU,$-Z),M.bottom-M.top+ZU);return}if(A?.type!=="table")return;a7({context:N,containerBounds:M,isHeaderRow:D?.rowIndex===0,lineHeight:F.height,theme:E})}function n7(N,F,A,M,D,E,$,Z){if(F.blockId!==D||A?.type==="table")return;let Y=M?E.get(M)??null:null;if(N.fillStyle=$.activeBlockBackground,N.fillRect(0,F.top-y3,Z,F.height),!Y)return;N.fillStyle=Q6($.activeBlockFlash,Y),N.fillRect(0,F.top-y3,Z,F.height)}function t7(N,F,A,M,D,E){let $=new Map;for(let Z=M;Z<D;Z+=1){let Y=N.lines[Z],X=A.get(Y.blockId);if(X?.type!=="heading"||X.depth!==1&&X.depth!==2)continue;let y=$.get(X.id),Q={bottom:Y.top+Y.height,left:Y.left+p0(F,Y),right:E-N.options.paddingX};$.set(X.id,y?{bottom:Math.max(y.bottom,Q.bottom),left:y.left,right:y.right}:Q)}return $}function e7(N,F,A,M,D,E){for(let $=A;$<M;$+=1){let Z=F.blocks[$];if(Z.type==="divider"){let Y=F.options.paddingX+Z.depth*F.options.indentWidth,X=E-F.options.paddingX,y=Math.round(Z.top+(Z.bottom-Z.top-i7)/2);FE(N,{color:D.dividerRule??D.headingRule,left:Y,right:X,thickness:i7,top:y})}}}function NE(N,F,A){for(let M of F.values())FE(N,{color:A.headingRule,left:M.left,minimumWidth:JU,right:M.right,thickness:VU,top:M.bottom+QU})}function FE(N,F){N.fillStyle=F.color,N.fillRect(F.left,F.top,Math.max(F.minimumWidth??0,F.right-F.left),F.thickness)}function AE(N,F,A,M,D){let E=new Map;for(let $=M;$<D;$+=1){let Z=N.lines[$],Y=G1(F,Z.blockId,"blockquote");if(!Y)continue;let X=E.get(Y.id),y={bottom:Z.top+Z.height,isActive:Z.blockId===A,left:N.options.paddingX+(Y.depth+1)*N.options.indentWidth-10,top:Z.top};E.set(Y.id,X?{bottom:Math.max(X.bottom,y.bottom),isActive:X.isActive||y.isActive,left:X.left,top:Math.min(X.top,y.top)}:y)}return E}function ME(N,F,A){for(let M of F.values())N.fillStyle=M.isActive?A.blockquoteRuleActive:A.blockquoteRule,N.fillRect(M.left,M.top+MU,$U,Math.max(DU,M.bottom-M.top-EU))}var UU=1,qU=2,KU=2;function J5({context:N,devicePixelRatio:F,editorState:A,height:M,layout:D,normalizedSelection:E,presence:$,showCaret:Z,theme:Y,viewportTop:X,width:y}){N.save(),N.scale(F,F),N.clearRect(0,0,y,M);let Q=E.start.regionId===E.end.regionId&&E.start.offset!==E.end.offset,J=Z&&!Q;if(N.translate(0,-X),J)DE(N,A,D,{color:Y.caret,offset:A.selection.focus.offset,regionId:A.selection.focus.regionId});if($)for(let V of $){if(!V.cursorPoint)continue;DE(N,A,D,{color:V.color??Y.leafAccent,offset:V.cursorPoint.offset,regionId:V.cursorPoint.regionId})}N.restore()}function DE(N,F,A,M){let D=o0(A,F.documentIndex,{regionId:M.regionId,offset:M.offset});if(!D)return;let E=N1(F,A,D),$=SU(A,D);N.fillStyle=M.color,N.fillRect(E,$.top,qU,$.height)}function SU(N,F){let A=e0(N,F.regionId,F.offset),M=A?.font??'16px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',{ascent:D,descent:E}=t0(M),$=Math.max(1,D+E),Z=Math.min(F.height-KU,$),Y=A?Math.max(A.top,A.top+sN(A.height,M)-UU):F.top+Math.max(0,Math.floor((F.height-Z)/2));return{height:Z,top:Y}}var EE=2,$E=8,GU=3,zU=1.5,HU=2,NN={elbow:{x:6.5,y:10.5},end:{x:11.5,y:3.5},start:{x:3.5,y:7.5}};function ZE(N,F,A,M,D,E,$=null){if(!A||F.start!==0)return;if($){let Z=hM($),Y=OU(A,F,M,D,N);N.save(),N.translate(Y.x,Y.y),N.scale(Z,Z),N.translate(-Y.x,-Y.y)}if(A.kind==="task")_U(N,F,A.checked,E,$);else if(N.fillStyle=$?bN(E.listMarkerText,$,E):E.listMarkerText,A.kind==="ordered")WU(N,A.label,M,D);else N.fillText(A.label,F.left-EE,D);if($)N.restore()}function _U(N,F,A,M,D=null){let E=Z2(F);if(BU(N,E,A,M,D),!A)return;PU(N,E,M,D)}function BU(N,F,A,M,D=null){let E=A?M.checkboxCheckedFill:M.checkboxUncheckedFill,$=A?M.checkboxCheckedStroke:M.checkboxUncheckedStroke;N.fillStyle=D?bN(E,D,M):E,N.strokeStyle=D?bN($,D,M):$,N.beginPath(),N.lineWidth=zU,N.roundRect(F.left,F.top,F.size,F.size,GU),N.fill(),N.stroke()}function PU(N,F,A,M=null){N.strokeStyle=M?bN(A.checkboxCheckmark,M,A):A.checkboxCheckmark,N.lineWidth=HU,N.beginPath(),N.moveTo(F.left+NN.start.x,F.top+NN.start.y),N.lineTo(F.left+NN.elbow.x,F.top+NN.elbow.y),N.lineTo(F.left+NN.end.x,F.top+NN.end.y),N.stroke()}function WU(N,F,A,M){let D=N.textAlign;N.textAlign="right",N.fillText(F,A-$E,M),N.textAlign=D}function OU(N,F,A,M,D){if(N.kind==="task"){let Z=Z2(F);return{x:Z.left+Z.size/2,y:Z.top+Z.size/2}}let E=D.measureText(N.label),$=M-(E.actualBoundingBoxAscent-E.actualBoundingBoxDescent)/2;if(N.kind==="ordered")return{x:A-$E-E.width/2,y:$};return{x:F.left-EE+E.width/2,y:$}}var TU=2,LU=1,wU=2,jU=5,CU=2,RU=3;function YE(N,F){let A=N.documentIndex.regionOrderIndex,M=A.get(F.start.regionId),D=A.get(F.end.regionId);return M===void 0||D===void 0?null:{end:D,start:M}}function XE(N,F,A,M,D,E){if(!D)return;let $=F.documentIndex.regionOrderIndex.get(A.regionId);if($===void 0||$<D.start||$>D.end)return;let Z=$===D.start?Math.max(A.start,M.start.offset):A.start,Y=$===D.end?Math.min(A.end,M.end.offset):A.end;if(Y<=Z)return;N.fillStyle=E.selectionBackground,N.fillRect(S1(F,A,Z-A.start),A.top+LU,Math.max(TU,S1(F,A,Y-A.start)-S1(F,A,Z-A.start)),A.height-wU)}function yE(N,F,A,M,D,E){for(let $ of M){if($.regionId!==A.regionId)continue;let Z=Math.max($.startOffset,A.start),Y=Math.min($.endOffset,A.end);if(Y<=Z)continue;N.fillStyle=bU($,D,E),N.fillRect(S1(F,A,Z-A.start),A.top+A.height-jU,Math.max(CU,S1(F,A,Y-A.start)-S1(F,A,Z-A.start)),RU)}}function bU(N,F,A){if(N.resolved)return N.threadIndex===F?A.commentHighlightResolvedActive:A.commentHighlightResolved;return N.threadIndex===F?A.commentHighlightActive:A.commentHighlight}function Q3(N,F){let A=[];if(F.includes("italic"))A.push("italic");if(F.includes("bold"))A.push("700");return A.length>0?`${A.join(" ")} ${N}`:N}function JE(N,F,A,M,D,E,$){let Z=A.image?M.images.get(A.image.url):null,Y=kU(A,M,$),X=mU(F,E,$,Y);if(N.fillStyle=D.imageSurfaceBackground,N.fillRect(X.left,X.top,X.width,X.height),Z?.status==="loaded"&&Z.source)N.drawImage(Z.source,X.left,X.top,X.width,X.height);else fU(N,D,{...X,status:Z?.status==="error"?"error":"loading"});N.strokeStyle=D.imageSurfaceBorder,N.strokeRect(X.left,X.top,X.width,X.height)}function fU(N,F,A){let M=A.status==="loading"?"Loading image":"Image unavailable",D=uU(A),E=A.top+A.height/2+D.size*0.9;if(N.save(),N.beginPath(),N.rect(A.left,A.top,A.width,A.height),N.clip(),A.status==="loading")vU(N,F,A);N.strokeStyle=F.imagePlaceholderIcon,N.lineWidth=1.5,N.strokeRect(D.left,D.top,D.size,D.size),N.beginPath(),N.arc(D.left+D.size*0.28,D.top+D.size*0.3,D.size*0.1,0,Math.PI*2),N.moveTo(D.left+D.size*0.12,D.top+D.size*0.82),N.lineTo(D.left+D.size*0.42,D.top+D.size*0.5),N.lineTo(D.left+D.size*0.58,D.top+D.size*0.66),N.lineTo(D.left+D.size*0.78,D.top+D.size*0.38),N.lineTo(D.left+D.size*0.88,D.top+D.size*0.82),N.stroke(),N.font='500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',N.fillStyle=F.imagePlaceholderText,N.textAlign="center",N.textBaseline="middle",N.fillText(M,A.left+A.width/2,E),N.restore()}function vU(N,F,A){let M=Math.max(48,Math.round(A.width*0.22)),D=A.width+M*2,E=performance.now()%1800/1800,$=A.left-M+D*E,Z=N.createLinearGradient($,A.top,$+M,A.top);Z.addColorStop(0,"rgba(255,255,255,0)"),Z.addColorStop(0.5,F.imageLoadingOverlay),Z.addColorStop(1,"rgba(255,255,255,0)"),N.fillStyle=Z,N.fillRect(A.left,A.top,A.width,A.height)}function kU(N,F,A){if(!N.image)return QE(A);let M=F.images.get(N.image.url);if(!M||M.intrinsicWidth<=0||M.intrinsicHeight<=0)return QE(A);return Math.max(48,Math.round(A*(M.intrinsicHeight/M.intrinsicWidth)))}function mU(N,F,A,M){return{height:M,left:F,top:N.top+Math.max(0,Math.floor((N.height-M)/2)),width:A}}function uU(N){let F=Math.max(18,Math.min(34,Math.round(Math.min(N.width,N.height)*0.18)));return{left:N.left+Math.max(12,Math.round((N.width-F)/2)),size:F,top:N.top+Math.max(12,Math.round(N.height/2-F*0.95))}}function QE(N){return Math.max(48,Math.round(N*0.5625))}var gU=5,VE=-1,UE=3,hU=1;function qE(N,F,A,M,D,E){if(!A.mention)return;let $=F.top+$2(F.height,N.font),Z=t0(N.font),Y=$-Z.ascent-UE+VE,X=Z.ascent+Z.descent+UE*2,y=Math.max(0,E-D);N.fillStyle=M.mentionBackground??M.inlineCodeBackground,IU(N,D,Y,y,X,gU),N.fillStyle=M.mentionText??M.linkText,N.fillText(`@${A.mention.name}`,D+r6,$+VE+hU)}function IU(N,F,A,M,D,E){let $=Math.min(E,M/2,D/2);N.beginPath(),N.roundRect(F,A,M,D,$),N.fill()}var pU=6,KE=3,xU=12,lU=10,dU=2,SE=4,aU=4,rU=1.5,cU=0,sU=3,GE=1,zE=2,iU=-1,HE=2,_E=1.25,oU=0.02;function PE(N,F,A,M,D,E,$,Z){if(!A){N.fillStyle=E,N.fillText(F.text,M,D);return}let Y=A.inlines.filter((X)=>X.end>F.start&&X.start<F.end);if(Y.length===0){N.fillStyle=E,N.fillText(F.text,M,D);return}for(let X of Y){let y=Math.max(F.start,X.start),Q=Math.min(F.end,X.end);if(A.text.slice(y,Q).length===0)continue;let{left:V,right:U}=X2(F,M,y,Q),S=Q3(F.font,X.marks);if(N.font=S,X.kind==="image"){let q=Math.max(24,U-V);JE(N,F,X,$,Z,V,q);continue}if(X.kind==="mention"){qE(N,F,X,Z,V,U);continue}if(X.kind==="code"){Aq(N,F,S,Z,V,U),BE(N,F,A.text,M,D,y,Q,Z.inlineCodeText,{strikethrough:!1,underline:!1});continue}BE(N,F,A.text,M,D,y,Q,X.link?Z.linkText:E,{strikethrough:X.marks.includes("strikethrough"),underline:X.marks.includes("underline")||Boolean(X.link)})}}function BE(N,F,A,M,D,E,$,Z,Y){let X=A.slice(E,$);if(X.length===0)return;let{left:y,right:Q}=X2(F,M,E,$);if(N.fillStyle=Z,N.fillText(X,y,D),Y.strikethrough)N.fillRect(y,Mq(D,F.height,N.font),Math.max(HE,Q-y),_E);if(Y.underline)N.fillRect(y,Dq(D,F.height,N.font),Math.max(HE,Q-y),_E)}function V5(N,F,A,M,D,E,$){if(!A||E.length===0)return;let Z=E.filter((X)=>X.endOffset>F.start&&X.startOffset<F.end);if(Z.length===0)return;let Y=A.inlines.filter((X)=>X.end>F.start&&X.start<F.end);for(let X of Y){if(X.kind==="image"||X.kind==="mention"||X.kind==="code"||X.link)continue;let y=Math.max(F.start,X.start),Q=Math.min(F.end,X.end),J=A.text.slice(y,Q);if(J.length===0)continue;let V=Z.filter((q)=>q.endOffset>y&&q.startOffset<Q);if(V.length===0)continue;let U=nU(y,Q,V),{left:S}=X2(F,M,y,Q);N.font=Q3(F.font,X.marks);for(let q=0;q<U.length-1;q+=1){let K=U[q],G=U[q+1],z=tU(V,K,G);if(!z||G<=K)continue;let{left:H,right:B}=X2(F,M,K,G);if($==="background"){if(z.backgroundColor){let _=eU(N,H,B,D);N.fillStyle=z.backgroundColor,Nq(N,_.left,_.top,_.width,_.height,sU)}}else if(z.color)LE(N,{color:z.color,eraseExistingGlyphs:!0,height:F.height,left:H,text:J,textBaseline:D,textLeft:S,top:F.top,width:Math.max(0,B-H)})}}}function nU(N,F,A){if(A.length===0)return[N,F];let M=new Set([N,F]);for(let D of A){if(D.endOffset<=N||D.startOffset>=F)continue;M.add(Math.max(N,D.startOffset)),M.add(Math.min(F,D.endOffset))}return[...M].sort((D,E)=>D-E)}function tU(N,F,A){return N.find((M)=>M.startOffset<A&&M.endOffset>F)??null}function eU(N,F,A,M){let D=t0(N.font),E=F-GE,$=A+GE;return{height:D.ascent+D.descent+zE+cU,left:E,top:M-D.ascent-zE+iU,width:Math.max(0,$-E)}}function Nq(N,F,A,M,D,E){if(M<=0||D<=0)return;N.beginPath(),N.roundRect(F,A,M,D,Math.min(E,M/2,D/2)),N.fill()}function WE(N,F,A,M,D,E,$){if(!A||E.length===0)return;let Z=A.inlines.filter((Y)=>Y.end>F.start&&Y.start<F.end);for(let Y of Z){if(Y.kind==="image"||Y.kind==="mention")continue;let X=Math.max(F.start,Y.start),y=Math.min(F.end,Y.end),Q=A.text.slice(X,y);if(Q.length===0)continue;let J=mM(X,y,E).filter((S)=>Fq(A.text,X,y,S));if(J.length<=2){if(!a4(E,X,y))continue}let{left:V}=X2(F,M,X,y),U=Q3(F.font,Y.marks);N.font=U;for(let S=0;S<J.length-1;S+=1){let q=J[S],K=J[S+1],G=a4(E,q,K);if(!G||K<=q)continue;let z=1-G.progress;if(z<=oU)continue;let{left:H,right:B}=X2(F,M,q,K);LE(N,{alpha:z,color:$.insertHighlightText,height:F.height,left:H,text:Q,textBaseline:D,textLeft:V,top:F.top,width:Math.max(0,B-H)})}}}function Fq(N,F,A,M){if(M<=F||M>=A)return!0;let D=F;for(let E of a2(N.slice(F,A))){if(D+=E.length,D===M)return!0;if(D>M)return!1}return!1}function OE(N,F,A,M,D,E,$){if(!A||E.length===0)return;for(let Z of E){if(Z.startOffset<F.start||Z.startOffset>F.end)continue;let Y=M+(R0(F,Z.startOffset-F.start)-F.left);N.fillStyle=uM($,Z),N.fillText(Z.text,Y,D)}}function TE(N,F,A,M,D,E,$){if(!A||E.length===0)return;for(let Z of E){if(Z.offset<F.start||Z.offset>=F.end)continue;let{left:Y,right:X}=X2(F,M,Z.offset,Z.offset+1),y=Math.max(SE,(X-Y)/2+SE+aU*Z.progress),{ascent:Q,descent:J}=t0(F.font),V=D-Math.max(1,Q*0.42)+Math.max(0.5,J*0.15);N.strokeStyle=gM(Z,$),N.lineWidth=rU,N.beginPath(),N.arc((Y+X)/2,V,y,0,Math.PI*2),N.stroke()}}function Aq(N,F,A,M,D,E){let $=sN(F.height,A),Z=F.top+$+dU,Y=Math.max(xU,F.height-$-pU);N.fillStyle=M.inlineCodeBackground,N.fillRect(D-KE,Z,Math.max(lU,E-D+KE*2),Y)}function Mq(N,F,A){let{ascent:M}=t0(A),D=N-$2(F,A);return Math.max(D+2,N-Math.round(M*0.32))}function Dq(N,F,A){let{descent:M}=t0(A),D=Math.max(1,Math.round(Math.max(2,M)*0.35)),E=N+M-D,$=N-$2(F,A);return Math.min($+F-4,E)}function X2(N,F,A,M){return{left:F+(R0(N,A-N.start)-N.left),right:F+(R0(N,M-N.start)-N.left)}}function LE(N,{alpha:F=1,color:A,eraseExistingGlyphs:M=!1,height:D,left:E,text:$,textBaseline:Z,textLeft:Y,top:X,width:y}){if(y<=0||F<=0)return;if(N.save(),N.beginPath(),N.rect(E,X,y,D),N.clip(),M)N.globalCompositeOperation="destination-out",N.fillText($,Y,Z);N.globalCompositeOperation="source-over",N.globalAlpha*=F,N.fillStyle=A,N.fillText($,Y,Z),N.restore()}var wE=new Map;function U5(N,F,A,M){Eq({activeBlockId:M.activeBlockId,activeRegionId:M.activeRegionId,activeThreadIndex:M.activeThreadIndex,containerLineBounds:F.regionBounds,context:A,devicePixelRatio:M.devicePixelRatio,editorState:N,height:M.height,layout:F.layout,liveCommentRanges:M.liveCommentRanges,normalizedSelection:M.normalizedSelection,now:M.now,resources:M.resources??{images:new Map},runtimeBlockMap:F.blockMap,textDecorations:M.textDecorations??wE,theme:M.theme,viewportTop:F.paintTop,width:M.width})}function q5(N,F,A,M){J5({context:A,devicePixelRatio:M.devicePixelRatio,editorState:N,height:M.height,layout:F.layout,normalizedSelection:M.normalizedSelection,presence:M.presence,showCaret:M.showCaret,theme:M.theme,viewportTop:F.paintTop,width:M.width})}function Eq({activeBlockId:N,activeRegionId:F,activeThreadIndex:A,containerLineBounds:M,context:D,devicePixelRatio:E,editorState:$,height:Z,layout:Y,liveCommentRanges:X,normalizedSelection:y,now:Q=Xq(),resources:J,runtimeBlockMap:V,textDecorations:U=wE,theme:S,viewportTop:q,width:K}){D.save(),D.scale(E,E),D.clearRect(0,0,K,Z),D.fillStyle=S.background,D.fillRect(0,0,K,Z),D.textBaseline="alphabetic",D.translate(0,-q);let{endIndex:G,startIndex:z}=A3(Y,q,Z),H=YE($,y),B=bM($,Q),_=fM($,Q),j=RM($,Q),L=kM($,Q),T=vM($,Q),O=AE(Y,$,N,z,G),W=t7(Y,$,V,z,G,K);for(let g=z;g<G;g+=1){let R=Y.lines[g];o7(D,R,V.get(R.blockId)??null,M.get(R.regionId)??null,$.documentIndex.tableCellIndex.get(R.regionId)??null,S,K)}let k=F3(Y,q,Z);e7(D,Y,k.startIndex,k.endIndex,S,K),r7({activeBlockFlashes:B,activeBlockId:N,activeRegionId:F,context:D,editorState:$,endIndex:G,layout:Y,regionBounds:M,startIndex:z,theme:S,verticalBleed:y3});for(let g=z;g<G;g+=1){let R=Y.lines[g];$q({activeBlockId:N,activeBlockFlashes:B,activeTextFades:_,activeTextHighlights:j,activeBlockPulses:L,activeTextPulses:T,activeThreadIndex:A,context:D,editorState:$,line:R,liveCommentRanges:X,normalizedSelection:y,resources:J,runtimeBlockMap:V,selectionRegionOrderRange:H,textDecorations:U,theme:S,width:K})}NE(D,W,S),ME(D,O,S),D.restore()}function $q({activeBlockId:N,activeBlockFlashes:F,activeTextFades:A,activeTextHighlights:M,activeBlockPulses:D,activeTextPulses:E,activeThreadIndex:$,context:Z,editorState:Y,line:X,liveCommentRanges:y,normalizedSelection:Q,resources:J,runtimeBlockMap:V,selectionRegionOrderRange:U,textDecorations:S,theme:q,width:K}){let G=V.get(X.blockId)??null,z=Y.documentIndex.blockIndex.get(X.blockId)?.path??null,H=Y.documentIndex.regionIndex.get(X.regionId)??null,B=H?.path??"",_=G1(Y,X.blockId,"listItem"),j=_?Y2(Y,_.id):null,L=_?D.get(_.path)??null:null,T=X.left+p0(Y,X),O=Zq(X),W=G?.type==="code"?q.codeText:Yq(G,q);Z.font=X.font,n7(Z,X,G,z,N,F,q,K);let k=S.size>0?S.get(B):null;if(k)V5(Z,X,H,T,O,k,"background");if(XE(Z,Y,X,Q,U,q),yE(Z,Y,X,y,$,q),ZE(Z,X,j,T,O,q,L),PE(Z,X,H,T,O,W,J,q),k)V5(Z,X,H,T,O,k,"overlay");WE(Z,X,H,T,O,M.get(B)??[],q),OE(Z,X,H,T,O,A.get(B)??[],W),TE(Z,X,H,T,O,E.get(B)??[],q)}function Zq(N){return N.top+$2(N.height,N.font)}function Yq(N,F){switch(N?.type){case"heading":return F.headingText;case"blockquote":return F.blockquoteText;case"table":return F.headingText;default:return F.paragraphText}}function Xq(){return typeof performance<"u"?performance.now():Date.now()}function K5(N,F,A){if(A.length===0)return F.size===0?null:new Map;let M=N.documentIndex,D=new Set(M.regions.map((Z)=>Z.path)),E=new Map([...F].filter(([Z])=>D.has(Z))),$=E.size!==F.size;for(let Z of A){let Y=new Set(M.roots[Z.rootIndex]?.regions.map((y)=>y.path)??[]);for(let y of Y)E.delete(y);let X=yq(Z.ranges.flatMap((y)=>{let Q=M.regionPathIndex.get(y.path);if(!Q||Q.rootIndex!==Z.rootIndex)return[];return[{...y.backgroundColor&&{backgroundColor:y.backgroundColor},...y.color&&{color:y.color},endOffset:y.endOffset,path:y.path,startOffset:y.startOffset}]}));for(let[y,Q]of X)E.set(y,Q);if(!Qq(F,E,Y))$=!0}return $?E:null}function yq(N){let F=new Map;for(let A of N){let M=F.get(A.path);if(M)M.push(A);else F.set(A.path,[A])}for(let A of F.values())A.sort((M,D)=>M.startOffset-D.startOffset);return F}function Qq(N,F,A){for(let M of A)if(!Jq(N.get(M)??[],F.get(M)??[]))return!1;return!0}function Jq(N,F){if(N.length!==F.length)return!1;return N.every((A,M)=>{let D=F[M];return A.color===D.color&&A.backgroundColor===D.backgroundColor&&A.endOffset===D.endOffset&&A.startOffset===D.startOffset})}function jE(N,F,A){return v7(N,F,A,u0(N).liveRanges)}function S5(N,F,A){return k7(N,F,A,u0(N).liveRanges)}import{forwardRef as Sq,createElement as Gq}from"react";var J3=(...N)=>N.filter((F,A,M)=>{return Boolean(F)&&F.trim()!==""&&M.indexOf(F)===A}).join(" ").trim();var CE=(N)=>N.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var RE=(N)=>N.replace(/^([A-Z])|[\s-_]+(\w)/g,(F,A,M)=>M?M.toUpperCase():A.toLowerCase());var G5=(N)=>{let F=RE(N);return F.charAt(0).toUpperCase()+F.slice(1)};import{forwardRef as Kq,createElement as vE}from"react";var V3={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 bE=(N)=>{for(let F in N)if(F.startsWith("aria-")||F==="role"||F==="title")return!0;return!1};import{createContext as Vq,useContext as Uq,useMemo as GL,createElement as zL}from"react";var qq=Vq({});var fE=()=>Uq(qq);var kE=Kq(({color:N,size:F,strokeWidth:A,absoluteStrokeWidth:M,className:D="",children:E,iconNode:$,...Z},Y)=>{let{size:X=24,strokeWidth:y=2,absoluteStrokeWidth:Q=!1,color:J="currentColor",className:V=""}=fE()??{},U=M??Q?Number(A??y)*24/Number(F??X):A??y;return vE("svg",{ref:Y,...V3,width:F??X??V3.width,height:F??X??V3.height,stroke:N??J,strokeWidth:U,className:J3("lucide",V,D),...!E&&!bE(Z)&&{"aria-hidden":"true"},...Z},[...$.map(([S,q])=>vE(S,q)),...Array.isArray(E)?E:[E]])});var u=(N,F)=>{let A=Sq(({className:M,...D},E)=>Gq(kE,{ref:E,iconNode:F,className:J3(`lucide-${CE(G5(N))}`,`lucide-${N}`,M),...D}));return A.displayName=G5(N),A};var zq=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],u1=u("columns-2",zq);var Hq=[["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",Hq);var _q=[["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"}]],h1=u("send-horizontal",_q);var Bq=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],tN=u("arrow-down",Bq);var Pq=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],eN=u("arrow-up",Pq);var Wq=[["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"}]],NF=u("bold",Wq);var Oq=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],y2=u("check",Oq);var Tq=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],FF=u("chevron-down",Tq);var Lq=[["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"}]],AF=u("heading-1",Lq);var wq=[["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"}]],MF=u("heading-2",wq);var jq=[["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"}]],DF=u("heading-3",jq);var Cq=[["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"}]],EF=u("heading-5",Cq);var Rq=[["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"}]],$F=u("heading-4",Rq);var bq=[["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"}]],ZF=u("heading-6",bq);var fq=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],YF=u("heading",fq);var vq=[["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"}]],XF=u("italic",vq);var kq=[["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"}]],yF=u("list-ordered",kq);var mq=[["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"}]],QF=u("list-todo",mq);var uq=[["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"}]],JF=u("list",uq);var gq=[["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"}]],VF=u("message-square-plus",gq);var hq=[["path",{d:"M5 12h14",key:"1ays0h"}]],UF=u("minus",hq);var Iq=[["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"}]],Q2=u("pencil",Iq);var pq=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],FN=u("plus",pq);var xq=[["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"}]],qF=u("strikethrough",xq);var lq=[["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"}]],I1=u("table-2",lq);var dq=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],KF=u("text-quote",dq);var aq=[["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"}]],s0=u("trash-2",aq);var rq=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],SF=u("underline",rq);var cq=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],GF=u("x",cq);import{jsx as AN,jsxs as nq}from"react/jsx-runtime";function mE({insetX:N,insetY:F,onSelect:A,presence:M}){if(!M)return null;return AN("div",{"aria-label":"Presence",className:"documint-presence-indicators",style:{paddingRight:`${N}px`,top:`${F}px`},children:M.map((D)=>AN(sq,{onSelect:()=>A(D),presence:D},D.id))})}function sq({onSelect:N,presence:F}){let A=F.viewport,M=iq(F),D=A?.status==="above"?eN:tN,E=A!==null&&A.status!=="unresolved",$=A?.status==="above"||A?.status==="below";return nq("button",{"aria-label":oq(F),className:"documint-presence-indicator","data-status":A?.status??"unresolved",disabled:!E,onClick:E?N:void 0,style:{"--documint-presence-color":F.color??"var(--documint-leaf-accent)"},type:"button",children:[AN("span",{className:"documint-presence-indicator-avatar",children:F.avatarUrl?AN("img",{alt:"","aria-hidden":"true",className:"documint-presence-indicator-image",draggable:!1,src:F.avatarUrl}):M}),$?AN("span",{className:"documint-presence-indicator-direction","aria-hidden":"true",children:AN(D,{className:"documint-presence-indicator-arrow",size:14,strokeWidth:2.3})}):null]})}function iq(N){return uE(N).charAt(0).toLocaleUpperCase()}function oq(N){let F=uE(N),A=N.viewport?.status??"unresolved";if(A==="above")return`${F} above viewport`;if(A==="below")return`${F} below viewport`;if(A==="unresolved")return`${F} unresolved`;return`${F} in viewport`}function uE(N){return(N.fullName??N.username).trim()||"Presence"}var s=`
|
|
29
|
-
`,MN="<ins>",zF="</ins>",DN=">",HF="```",U3=":::",q3="documint-comments";var BF="\\",S3="`",lE=":",_F=" ",H5="![",gE="@[",_5="[",B5="(",hE=")",IE=/[\p{L}\p{N}]/u,tq=/[A-Za-z]/,eq=/[-A-Za-z0-9_]/,K3=/\{width=([1-9]\d*)\}/y,NK=/\\([\\`*_[\]{}()#+\-.!~|@])/g,dE=/\\(.)/g,aE=[{delimiter:"**",mark:"bold",requireWordBoundary:!1},{delimiter:"~~",mark:"strikethrough",requireWordBoundary:!1},{delimiter:"*",mark:"italic",requireWordBoundary:!1},{delimiter:"_",mark:"italic",requireWordBoundary:!0}],FK=new Set(aE.map((N)=>N.delimiter[0]));function PF(N){return G3(N,0,N.length,[])}function G3(N,F,A,M){let D=[],E=F,$=F;while(E<A){let Z=AK(N,E,A,M);if(Z){let Y=Math.max($,E-(Z.trimLeading??0));pE(D,N.slice($,Y),M),D.push(...Z.nodes),E=Z.end,$=E;continue}if(N[E]===BF){E+=Math.min(2,A-E);continue}E+=1}return pE(D,N.slice($,A),M),W0(D)}function AK(N,F,A,M){let D=N[F];switch(D){case lE:return MK(N,F,A);case"<":return ZK(N,F,A)??DK(N,F,A,M)??EK(N,F,A);case BF:return YK(N,F,A);case s:return XK(N,F);case S3:return yK(N,F,A);case"!":return QK(N,F,A);case"@":return JK(N,F,A);case _5:return VK(N,F,A,M)}if(D!==void 0&&FK.has(D))return qK(N,F,A,M);return null}function MK(N,F,A){if(N[F]!==lE||!tq.test(N[F+1]??""))return null;let M=F+2;while(M<A&&eq.test(N[M]??""))M+=1;let D=xE(N,M,A,"[","]"),$=xE(N,D?.end??M,A,"{","}")?.end??D?.end??M;return{end:$,nodes:[rE("textDirective",N.slice(F,$))]}}function DK(N,F,A,M){if(!N.startsWith(MN,F))return null;let D=N.indexOf(zF,F+MN.length);if(D<0||D>=A)return null;return{end:D+zF.length,nodes:G3(N,F+MN.length,D,[...M,"underline"])}}function EK(N,F,A){if(N[F]!=="<")return null;let M=N.indexOf(">",F+1);if(M<0||M>=A)return null;return{end:M+1,nodes:[rE("html",N.slice(F,M+1))]}}var $K=/^<br\s*\/?>/i;function ZK(N,F,A){if(N[F]!=="<")return null;let M=$K.exec(N.slice(F,A));if(!M)return null;let D=F+M[0].length;return{end:N[D]===s?D+1:D,nodes:[$1()]}}function YK(N,F,A){if(N[F]!==BF||N[F+1]!==s||F+1>=A)return null;return{end:F+2,nodes:[$1()]}}function XK(N,F){if(N[F]!==s||N[F-1]!==_F||N[F-2]!==_F)return null;let A=0;while(N[F-1-A]===_F)A+=1;return{end:F+1,nodes:[$1()],trimLeading:A}}function yK(N,F,A){if(N[F]!==S3)return null;let M=1;while(F+M<A&&N[F+M]===S3)M+=1;let D=S3.repeat(M),E=N.indexOf(D,F+M);if(E<0||E>=A)return null;return{end:E+M,nodes:[W1(N.slice(F+M,E))]}}function QK(N,F,A){if(!N.startsWith(H5,F))return null;let M=W5(N,F+1,A);if(M<0||N[M+1]!==B5)return null;let D=P5(N,M+1,A);if(!D)return null;let E=UK(N,D.end,A);return{end:E?.end??D.end,nodes:[O1({alt:O5(N.slice(F+H5.length,M)),title:D.title,url:D.url,width:E?.width??null})]}}function JK(N,F,A){if(!N.startsWith(gE,F))return null;let M=W5(N,F+1,A);if(M<0||N[M+1]!==B5)return null;let D=P5(N,M+1,A);if(!D||D.title!==null)return null;return{end:D.end,nodes:[B2({name:O5(N.slice(F+gE.length,M)),userId:D.url})]}}function VK(N,F,A,M){if(N[F]!==_5||N.startsWith(H5,F-1))return null;let D=W5(N,F,A);if(D<0||N[D+1]!==B5)return null;let E=P5(N,D+1,A);if(!E)return null;return{end:E.end,nodes:[c1({children:G3(N,F+_5.length,D,M),title:E.title,url:E.url})]}}function P5(N,F,A){let M=z5(N,F+1,A),D=M;while(D<A&&N[D]!==hE&&N[D]!==_F){if(N[D]===BF){D+=2;continue}D+=1}if(D===M)return null;let E=KK(N.slice(M,D));M=z5(N,D,A);let $=null;if(M<A&&N[M]==='"'){let Z=z3(N,'"',M+1,A);if(Z<0)return null;$=N.slice(M+1,Z).replace(dE,"$1"),M=z5(N,Z+1,A)}if(N[M]!==hE)return null;return{end:M+1,title:$,url:E}}function UK(N,F,A){K3.lastIndex=F;let M=K3.exec(N);if(!M||K3.lastIndex>A)return null;return{end:K3.lastIndex,width:Number(M[1])}}function qK(N,F,A,M){for(let D of aE){if(!N.startsWith(D.delimiter,F))continue;let E=z3(N,D.delimiter,F+D.delimiter.length,A);if(E<0)continue;if(D.requireWordBoundary){let Z=F>0?N[F-1]:"",Y=N[E+D.delimiter.length]??"";if(IE.test(Z)||IE.test(Y))continue}let $=F+D.delimiter.length;return{end:E+D.delimiter.length,nodes:G3(N,$,E,[...M,D.mark])}}return null}function pE(N,F,A){if(F.length===0)return;N.push(f0(O5(F),A))}function xE(N,F,A,M,D){if(N[F]!==M)return null;let E=z3(N,D,F+1,A);if(E<0)return null;return{end:E+1}}function W5(N,F,A){return z3(N,"]",F+1,A)}function z3(N,F,A,M){for(let D=A;D<M;D+=1){if(N[D]===BF){D+=1;continue}if(N.startsWith(F,D))return D}return-1}function z5(N,F,A){while(F<A&&N[F]===_F)F+=1;return F}function O5(N){return N.replace(NK,"$1")}function KK(N){return N.replace(dE,"$1")}function rE(N,F){return hF({originalType:N,source:F})}var SK=/^:?-+:?$/;function sE(N,F){let A=_0(N),M=L5(N,1),D=b0(A,F),E=b0(M,F);if(!cE(D)||!T5(E))return null;let $=[H3(D)],Z=GK(E);N.index+=2;while(N.index<N.lines.length){let Y=_0(N),X=b0(Y,F);if(p1(Y)||!cE(X))break;$.push(H3(X)),N.index+=1}return o1({align:Z,rows:$.map((Y)=>P2(Y.map((X)=>T1(PF(X)))))})}function T5(N){let F=H3(N);return F.length>0&&F.every((A)=>SK.test(A.trim()))}function cE(N){let F=N.trim();return F.startsWith("|")&&F.endsWith("|")}function GK(N){return H3(N).map((F)=>{let A=F.trim();if(A.startsWith(":")&&A.endsWith(":"))return"center";if(A.startsWith(":"))return"left";if(A.endsWith(":"))return"right";return null})}function H3(N){let F=N.trim();if(!F.startsWith("|")||!F.endsWith("|"))return[];return F.slice(1,-1).split("|").map((A)=>A.trim())}var zK=3,iE=/^(#{1,6})\s+(.*)$/,HK=/\s+#+\s*$/u,_K=/^(\s*)([-+*]|\d+\.)(?:\s+(.*)|\s*)$/,BK=/^\d+\.$/,PK=/^\[( |x|X)\](?:\s|$)/,oE=/^```([^\s`]*)?(?:\s+(.*))?$/,nE=/^:::([A-Za-z][-\w]*)(.*)$/,WK=[/^(\*\s*){3,}$/,/^(-\s*){3,}$/,/^(_\s*){3,}$/];function B3(N,F,A){let M=[];while(N.index<N.lines.length){let D=_0(N);if(N.index===N.lines.length-1&&D==="")break;if(p1(D)){N.index+=1;continue}if(EN(D)>F+zK)break;let E=OK(N,F,A);if(!E)break;M.push(E)}return M}function OK(N,F,A){return TK(N,F,A)??LK(N,F)??wK(N,F)??CK(N,F)??RK(N,F)??sE(N,F)??bK(N,F,A)??vK(N,F)??kK(N,F)}function TK(N,F,A){let M=_0(N);if(!b0(M,F).startsWith(DN))return null;let D=[];while(N.index<N.lines.length){let E=_0(N),$=EN(E);if(p1(E)){D.push(""),N.index+=1;continue}if($<F)break;let Z=b0(E,F);if(!Z.startsWith(DN))break;let Y=Z.slice(1);if(Y.startsWith(" "))Y=Y.slice(1);D.push(Y),N.index+=1}return d0(B3({index:0,lines:D},0,A))}function LK(N,F){let A=_0(N),M=b0(A,F),D=oE.exec(M);if(!D)return null;N.index+=1;let E=[];while(N.index<N.lines.length){let $=_0(N),Z=b0($,F);if(Z.trim()===HF){N.index+=1;break}E.push(Z),N.index+=1}return N4({language:D[1]?D[1]:null,meta:D[2]?D[2]:null,source:E.join(s)})}function wK(N,F){let A=_0(N),M=b0(A,F),D=nE.exec(M);if(!D)return null;let E=D[1],$=[];N.index+=1;while(N.index<N.lines.length){let Z=_0(N),Y=b0(Z,F);if(Y.trim()===U3){N.index+=1;break}$.push(Y),N.index+=1}return xA({attributes:jK(D[2]??""),body:$.join(s),name:E})}function jK(N){let F=N.trim();if(F.startsWith("{")&&F.endsWith("}"))return F.slice(1,-1);return F}function CK(N,F){let A=_0(N),M=iE.exec(b0(A,F));if(!M)return null;return N.index+=1,gF({children:PF(M[2].replace(HK,"")),depth:M[1].length})}function RK(N,F){let A=b0(_0(N),F).trim();if(!tE(A))return null;return N.index+=1,IF()}function bK(N,F,A){let M=_3(_0(N),F);if(!M)return null;let D=[],E=!1;while(N.index<N.lines.length){let $=_0(N),Z=_3($,F);if(!Z||Z.ordered!==M.ordered)break;N.index+=1;let Y=[Z.content],X=!1;while(N.index<N.lines.length){let y=_0(N),Q=EN(y);if(p1(y)){let J=gK(N.lines,N.index+1);if(J<0||EN(N.lines[J]??"")<=F)break;X=!0,Y.push(""),N.index+=1;continue}if(Q<Z.contentIndent)break;if(Q===F&&_3(y,F))break;Y.push(uK(y,Z.contentIndent)),N.index+=1}E||=X,D.push(s1({checked:Z.checked,children:fK(Y,A),spread:X}))}return i1({items:D,ordered:M.ordered,spread:E,start:M.ordered&&A.preserveOrderedListStart?M.start??1:null})}function _3(N,F){let A=_K.exec(N);if(!A||A[1].length!==F)return null;let M=A[2],D=BK.test(M),E=D?Number(M.slice(0,-1)):null,$=A[3]??"",Z=null;if(PK.test($)){if(Z=$[1]==="x"||$[1]==="X",$=$.slice(3),$.startsWith(" "))$=$.slice(1)}let Y=A[0].length-A[1].length-A[2].length-$.length;return{checked:Z,content:$,contentIndent:F+A[2].length+Y,ordered:D,start:E}}function fK(N,F){let A=B3({index:0,lines:N},0,F);if(A.length>0)return A;return[E1([])]}function vK(N,F){let A=b0(_0(N),F).trim();if(!eE(A))return null;return N.index+=1,F4({originalType:"html",source:A})}function kK(N,F){let A=[];while(N.index<N.lines.length){let M=_0(N),D=EN(M);if(p1(M))break;if(D<F)break;let E=b0(M,F);if(A.length>0&&mK(M,E,F))break;A.push(E),N.index+=1}return E1(PF(A.join(s)))}function mK(N,F,A){let M=F.trim();return F.startsWith(DN)||oE.test(F)||nE.test(F)||iE.test(F)||tE(M)||T5(F)||_3(N,A)!==null||eE(M)}function EN(N){let F=0;while(F<N.length&&N[F]===" ")F+=1;return F}function uK(N,F){let A=EN(N);if(A>=F)return N.slice(F);return N.trim()===""?"":N.slice(Math.min(A,F))}function gK(N,F){for(let A=F;A<N.length;A+=1)if(!p1(N[A]??""))return A;return-1}function tE(N){return WK.some((F)=>F.test(N))}function eE(N){return N.startsWith("<")&&N.endsWith(">")}function F$(N){let F=N.at(-1),A=F&&N$(F)?F:null;return{blocks:N.filter((D)=>!N$(D)),comments:A?hK(A.body):[]}}function hK(N){let F;try{F=JSON.parse(N)}catch{return[]}if(!Array.isArray(F))return[];return F.flatMap((A)=>{let M=S4(A);return M?[M]:[]})}function N$(N){return N.type==="directive"&&N.name===q3}var A$="---";function WF(N,F={}){let M={index:0,lines:N.replace(/\r\n/g,s).split(s)},D=IK(M),E=B3(M,0,F),{comments:$,blocks:Z}=F$(E);return w2(Z,$,D)}function IK(N){if(N.lines[0]!==A$)return;for(let F=1;F<N.lines.length;F+=1)if(N.lines[F]===A$){let A=N.lines.slice(0,F+1).join(s);return N.index=F+1,A}return}function _0(N){return L5(N,0)}function L5(N,F){return N.lines[N.index+F]??""}function p1(N){return N.trim()===""}function b0(N,F){return N.slice(F)}var pK=/([\\`*_[\]])/g,xK=/([\\)&])/g,lK=/(["\\])/g;function J1(N){let F=W0(N);return F.map((A,M)=>dK(A,F[M+1])).join("")}function dK(N,F){switch(N.type){case"lineBreak":return"<br>";case"image":return cK(N);case"mention":return sK(N);case"code":return rK(N.code);case"link":return iK(N);case"text":return aK(w5(N.text,F),N.marks);case"raw":return N.source}}function aK(N,F){return F.reduce((A,M)=>{switch(M){case"bold":return`**${A}**`;case"italic":return`*${A}*`;case"strikethrough":return`~~${A}~~`;case"underline":return`${MN}${A}${zF}`}},N)}function rK(N){let F=0,A=0;for(let $ of N){if($==="`"){if(A+=1,A>F)F=A;continue}A=0}let M=F>0?F+1:1,D="`".repeat(M),E=N.startsWith("`")||N.endsWith("`")?` ${N} `:N;return`${D}${E}${D}`}function cK(N){let F=w5(N.alt??""),A=M$(N.url,N.title),M=N.width?`{width=${N.width}}`:"";return`![${F}]${A}${M}`}function sK(N){return`@[${w5(N.name)}](${D$(N.userId)})`}function iK(N){return`[${J1(N.children)}]${M$(N.url,N.title)}`}function M$(N,F){return`(${D$(N)}${oK(F)})`}function w5(N,F){let A=N.replace(pK,"\\$1").replace(/@(?=\[)/g,"\\@");return F?.type==="link"&&A.endsWith("@")?`${A.slice(0,-1)}\\@`:A}function D$(N){return N.replace(xK,"\\$1")}function oK(N){return N?` "${N.replace(lK,"\\$1")}"`:""}var $$=3;function Z$(N,F,A){let M=N.rows.map((y)=>y.cells.map((Q)=>J1(Q.children))),D=Math.max(1,...M.map((y)=>y.length)),E=M[0]??[],$=Array.from({length:D},(y,Q)=>Math.max(NS(N.align[Q]),...A.padTableColumns?M.map((J)=>J[Q]?.length??0):[E[Q]?.length??0])),Z=nK($,N.align,F),Y=E$(E,$,N.align,F,A),X=M.slice(1).map((y)=>E$(y,$,N.align,F,A));return[Y??tK($,F),Z,...X].join(s)}function E$(N,F,A,M,D){let E=F.map(($,Z)=>{let Y=N[Z]??"";if(!D.padTableColumns)return Y;return FS(Y,$,A[Z])});return`${" ".repeat(M)}| ${E.join(" | ")} |`}function nK(N,F,A){let M=N.map((D,E)=>eK(F[E],D));return`${" ".repeat(A)}| ${M.join(" | ")} |`}function tK(N,F){return`${" ".repeat(F)}| ${N.map((A)=>"".padEnd(A," ")).join(" | ")} |`}function eK(N,F){let A=Y$(N),M=Math.max($$,F-A),D="-".repeat(M);switch(N){case"center":return`:${D}:`;case"left":return`:${D}`;case"right":return`${D}:`;default:return D}}function NS(N){return $$+Y$(N)}function Y$(N){if(N==="center")return 2;return N?1:0}function FS(N,F,A){if(A==="right")return N.padStart(F," ");return N.padEnd(F," ")}var J2=`
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
`||N==="\t"}function WS(N){return N===void 0||w3(N)||!/[\p{L}\p{N}_]/u.test(N)}var OS=["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 O$(N,F,{scrollX:A=window.scrollX,scrollY:M=window.scrollY}={}){if(!N.isConnected)return null;let D=getComputedStyle(N),E=document.createElement("div");for(let y of OS)E.style.setProperty(y,D.getPropertyValue(y));Object.assign(E.style,{position:"absolute",top:"0",left:"0",visibility:"hidden",whiteSpace:"pre-wrap",wordWrap:"break-word",width:`${N.clientWidth}px`}),E.textContent=N.value.slice(0,F);let $=document.createElement("span");$.textContent=N.value.slice(F)||".",E.appendChild($),document.body.appendChild(E);let Z=N.getBoundingClientRect(),Y=parseFloat(D.lineHeight)||$.offsetHeight,X={anchorHeight:Y,left:A+Z.left+$.offsetLeft+parseFloat(D.borderLeftWidth)-N.scrollLeft,top:M+Z.top+$.offsetTop+parseFloat(D.borderTopWidth)+Y-N.scrollTop};return document.body.removeChild(E),X}function L$({completionSources:N,onChange:F,textareaRef:A,value:M}){let[D,E]=T$(null),[$,Z]=T$(null),Y=D?.triggerStart??null,X=jS(()=>H$(N),[N]),y=TF((K,G)=>{if(!X.length){E(null);return}let z=j3(K,G,X);if(!z){E(null);return}E(z)},[X]),Q=TF((K)=>{let G=K.currentTarget.value,z=K.currentTarget.selectionEnd??G.length;F(G),y(G,z)},[F,y]),J=TF((K)=>{let G=K.currentTarget;y(G.value,G.selectionEnd??G.value.length)},[y]),V=TF(()=>{E(null)},[]),U=TF((K,G)=>{if(!A.current)return;let H=W$(M,G,CS(K));F(H.value),E(null),requestAnimationFrame(()=>{let B=A.current;if(!B)return;B.focus(),B.setSelectionRange(H.caret,H.caret)})},[F,A,M]),S=L3({activeCompletion:D,onAccept:U,onDismiss:V}),q=LS((K)=>{S.handleBeforeInput(K)});return TS(()=>{let K=A.current;if(!K)return;return K.addEventListener("beforeinput",q),()=>K.removeEventListener("beforeinput",q)},[A]),wS(()=>{if(Y===null){Z(null);return}let K=()=>{let G=A.current;if(!G)return;let z=O$(G,Y);Z(z?{anchorHeight:z.anchorHeight,bridge:!1,left:z.left,paddingY:4,top:z.top}:null)};return K(),window.addEventListener("scroll",K,!0),window.addEventListener("resize",K),()=>{window.removeEventListener("scroll",K,!0),window.removeEventListener("resize",K)}},[Y,A]),{activeCompletion:D,anchor:$,handleBlur:V,handleChange:Q,handleKeyDown:S.handleKeyDown,handleSelect:J,leafProps:S.leafProps}}function CS(N){return N.kind==="mention"?{...N,insertText:`@${N.label} `}:N}import{useLayoutEffect as RS,useRef as bS,useState as fS}from"react";import{jsx as v5,jsxs as gS}from"react/jsx-runtime";var w$=12,vS={horizontalOffset:0,verticalPlacement:"below"};function R3({anchor:N,children:F}){let A=bS(null),[M,D]=fS(vS);return RS(()=>{let E=A.current;if(!E||typeof window>"u")return;let $=()=>{let Y=E.getBoundingClientRect(),X=kS(N,Y);D((y)=>uS(y,X)?y:X)};$();let Z=new ResizeObserver($);return Z.observe(E),window.visualViewport?.addEventListener("resize",$),window.addEventListener("resize",$),()=>{Z.disconnect(),window.visualViewport?.removeEventListener("resize",$),window.removeEventListener("resize",$)}},[N.left,N.top]),v5(U$,{children:gS("div",{className:"documint-leaf-anchor","data-bridge":N.bridge,"data-placement":M.verticalPlacement,onPointerEnter:N.onPointerEnter,onPointerLeave:N.onPointerLeave,style:{left:`${N.left+M.horizontalOffset}px`,top:`${N.top}px`,"--documint-leaf-anchor-height":`${N.anchorHeight}px`,"--documint-leaf-bridge-height":`${w$}px`,"--documint-leaf-padding-y":`${N.paddingY}px`},children:[N.bridge?v5("div",{className:"documint-leaf-bridge"}):null,v5("div",{className:"documint-leaf-shell",ref:A,children:F})]})})}function kS(N,F){let A=window.visualViewport,M=A?.width??window.innerWidth,D=A?.height??window.innerHeight,E=A?.offsetLeft??0,$=A?.offsetTop??0,Z=N.left-window.scrollX-E,Y=N.top-window.scrollY-$,X=D-Y;return{horizontalOffset:mS({anchorScreenLeft:Z,shellWidth:F.width,visibleWidth:M}),verticalPlacement:F.height+w$>X?"above":"below"}}function mS({anchorScreenLeft:N,shellWidth:F,visibleWidth:A}){let M=A-N;if(F<=M)return 0;return Math.max(-N,Math.min(-F/2,A-N-F))}function uS(N,F){return N.horizontalOffset===F.horizontalOffset&&N.verticalPlacement===F.verticalPlacement}import{jsx as x1,jsxs as j$,Fragment as xS}from"react/jsx-runtime";function LF({actions:N,autoFocus:F=!1,completionSources:A,onChange:M,placeholder:D,readOnly:E=!1,ref:$,rows:Z=3,saveOnEnter:Y=!1,value:X}){let y=IS(null),Q=$??y,{activeCompletion:J,anchor:V,handleBlur:U,handleChange:S,handleKeyDown:q,handleSelect:K,leafProps:G}=L$({completionSources:A,onChange:M,textareaRef:Q,value:X}),z=hS((H)=>{if(q(H))return;if(H.key==="Escape"&&N.kind==="edit")H.preventDefault(),N.onCancel();if(H.key==="Enter"&&Y){if(H.preventDefault(),N.kind==="edit"&&!N.saveDisabled)N.onSave();else if(N.kind==="compose"&&!N.submitDisabled)N.onSubmit()}},[N,q,Y]);return j$("div",{className:"documint-leaf-input-field",children:[x1("textarea",{autoFocus:F,className:"documint-leaf-input",onBlur:U,onChange:S,onKeyDown:z,onSelect:K,placeholder:D,readOnly:E,ref:Q,rows:Z,value:X}),pS(N),J&&V&&G?x1(R3,{anchor:V,children:x1(T3,{...G})}):null]})}function pS(N){if(N.kind==="edit")return j$(xS,{children:[x1(k5,{className:"documint-leaf-input-cancel",icon:GF,label:"Cancel editing",onClick:N.onCancel}),x1(k5,{className:"documint-leaf-input-save",disabled:N.saveDisabled??!1,icon:y2,label:"Save",onClick:N.onSave})]});return x1(k5,{className:"documint-leaf-input-submit",disabled:N.submitDisabled??!1,icon:h1,iconSize:15,label:N.submitLabel,onClick:N.onSubmit})}function k5({className:N,disabled:F=!1,icon:A,iconSize:M=14,label:D,onClick:E}){return x1("button",{"aria-label":D,className:`documint-leaf-action ${N}`,disabled:F,onClick:E,title:D,children:x1(A,{size:M,strokeWidth:2.2})})}import{Fragment as C$}from"react";import{jsx as b$,jsxs as R$}from"react/jsx-runtime";function m5({value:N,completionSources:F,onEdit:A}){return b$("p",{onDoubleClick:A,children:lS(N,F)})}function lS(N,F){let A=C3(N,F);if(A.length===1&&A[0].kind==="text")return N;return A.map((M,D)=>M.kind==="token"&&M.id?R$("span",{className:"documint-mention",children:[M.trigger,M.label]},D):M.kind==="token"?R$(C$,{children:[M.trigger,M.label]},D):b$(C$,{children:M.text},D))}import{Children as f$,isValidElement as v$,useEffect as dS,useRef as aS,useState as rS}from"react";import{jsx as T0,jsxs as h5}from"react/jsx-runtime";var u5=(N)=>{N.preventDefault()},g5=(N)=>N.isPrimary&&N.button===0;function cS({children:N}){return T0("div",{className:"documint-leaf-toolbar",children:f$.map(N,sS)})}function sS(N){if(!v$(N))return null;if(N.type===m$){let F=N.props;return T0(k$,{children:T0(iS,{...F})})}if(N.type===u$){let{className:F}=N.props;return T0("div",{className:wF("documint-leaf-toolbar-divider",F)})}if(N.type===g$){let F=N.props;return T0(nS,{...F})}return null}function iS({active:N=!1,className:F,disabled:A=!1,icon:M,label:D,onClick:E}){return T0("button",{"aria-label":D,className:wF("documint-leaf-toolbar-button",N?"active":null,F),disabled:A,onPointerDown:($)=>{if(u5($),!A&&g5($))E()},title:D,type:"button",children:T0(oS,{icon:M})})}function oS({icon:N}){return T0(N,{size:15,strokeWidth:2.2})}function nS({children:N,className:F,icon:A,label:M,onSelect:D}){let E=aS(null),[$,Z]=rS(!1);return dS(()=>{if(!$)return;let Y=(X)=>{if(E.current&&X.target instanceof Node&&!E.current.contains(X.target))Z(!1)};return window.addEventListener("pointerdown",Y),()=>{window.removeEventListener("pointerdown",Y)}},[$]),T0(k$,{children:h5("div",{className:"documint-leaf-toolbar-menu-shell",ref:E,children:[T0(tS,{className:F,icon:A,isOpen:$,label:M,onClick:()=>Z((Y)=>!Y)}),$?T0("div",{className:"documint-leaf-menu",role:"menu",children:f$.map(N,(Y)=>eS(Y,(X)=>{Z(!1),D(X)}))}):null]})})}function tS({className:N,icon:F,isOpen:A,label:M,onClick:D}){return h5("button",{"aria-expanded":A,"aria-haspopup":"menu","aria-label":M,className:wF("documint-leaf-toolbar-button",A?"active":null,N),onPointerDown:(E)=>{if(u5(E),g5(E))D()},title:M,type:"button",children:[T0(F,{size:15,strokeWidth:2.2}),T0(FF,{className:wF("documint-leaf-toolbar-menu-chevron",A?"is-open":null),size:13,strokeWidth:2.2})]})}function eS(N,F){if(!v$(N))return null;if(N.type===I$){let{className:$}=N.props;return T0("div",{className:wF("documint-leaf-menu-divider",$),role:"separator"})}if(N.type!==h$)return null;let{disabled:A=!1,icon:M,text:D,value:E}=N.props;return h5("button",{className:"documint-leaf-menu-item",disabled:A,onPointerDown:($)=>{if(u5($),!A&&g5($))F(E)},role:"menuitem",type:"button",children:[T0(M,{size:15,strokeWidth:2.2}),T0("span",{children:D})]})}function wF(...N){return N.filter(Boolean).join(" ")}function k$({children:N}){return T0("div",{className:"documint-leaf-toolbar-group",children:N})}function m$(N){return null}function u$(N){return null}function g$(N){return null}function h$(N){return null}function I$(N){return null}var a=Object.assign(cS,{Button:m$,Divider:u$,Menu:g$,MenuDivider:I$,MenuItem:h$});import{jsx as t,jsxs as V1,Fragment as MG}from"react/jsx-runtime";var NG=!1,FG=220,K2=()=>{};function I5(N){let F=N.mode==="create",A=N.mode==="create"?N:null,M=N.mode==="thread"?N:null,D=N.canEdit,E=N.link,$=M?.thread??null,Z=$?.comments??[],Y=Z[0]??null,X=$?j1($):!1,y=M?.animateInitialComment??!1,[Q,J]=q2(null),[V,U]=q2(""),[S,q]=q2(""),[K,G]=q2(""),[z,H]=q2(!y),[B,_]=q2(NG),[j,L]=q2(!1),T=p$(null),O=p$(null),W=N.completionSources,k=$?P4($):null,g=k?x$(k):"",R=D&&!X,P=R&&V.trim().length>0,b=R&&S.trim().length>0,f=D&&K.trim().length>0,m=F||j,x=!F||B,r=!F&&Boolean($),i=Boolean(Y),B0=F?B:!0,Q0=M?.onDeleteComment??K2,v=M?.onDeleteThread??K2,l=M?.onToggleResolved??K2,c=A?.activeMarks??[],n=A?.onToggleBold??K2,j0=A?.onToggleItalic??K2,P0=A?.onToggleStrikethrough??K2,w=A?.onToggleUnderline??K2,p=A?.actions??[],D0=D?F?"Add a comment":"Reply to this comment":"Comment editing is disabled",G0=F?K:S;b3(()=>{if(Q!==null&&(Q<0||Q>=Z.length))J(null),U("")},[Z.length,Q]),b3(()=>{if(!i||!y){H(!0);return}H(!1);let Y0=requestAnimationFrame(()=>{H(!0)});return()=>{cancelAnimationFrame(Y0)}},[y,Y,i]),b3(()=>{if(!M||!y){L(!1);return}L(!0);let Y0=window.setTimeout(()=>{L(!1)},FG);return()=>{window.clearTimeout(Y0)}},[y,M]),b3(()=>{if(!F||!B||!D)return;let Y0=requestAnimationFrame(()=>{O.current?.focus()});return()=>{cancelAnimationFrame(Y0)}},[D,F,B]);let Z0=()=>{J(null),U("")},E0=(Y0,JN)=>{if(!r||!R)return;J(Y0),U(JN)},C0=(Y0)=>{if(!M)return;M.onEditComment(Y0,V),Z0()},B1=()=>{if(!M)return;M.onReply(S),q("")},z2=()=>{if(!A||!f)return;A.onCreateThread(K),G("")},H2=m?`documint-comment-leaf documint-comment-leaf-create${B0?" is-expanded":""}`:"documint-comment-leaf",mF=r||i||x?t(AG,{canCreate:f,canEdit:D,canMutateThread:R,canReply:b,canSaveEditedComment:P,comments:Z,composerRef:O,editDraft:V,editingCommentIndex:Q,isComposerVisible:x,isInitialCommentVisible:z,isResolved:X,link:E,completionSources:W,mode:N.mode,onBeginEditingComment:E0,onCancelEditing:Z0,onChangeCreateDraft:G,onChangeEditDraft:U,onChangeReplyDraft:q,onDeleteComment:Q0,onDeleteThread:v,onSubmitCreate:z2,onSubmitEditedComment:C0,onSubmitReply:B1,onToggleResolved:l,rootComment:Y,showRootComment:i,showThreadChrome:r,threadAge:g,composerPlaceholder:D0,composerValue:G0}):null;return t("div",{className:H2,"data-resolved":X?"true":void 0,ref:T,children:V1("div",{className:m?"documint-comment-leaf-create-shell":void 0,children:[m?V1(a,{children:[t(a.Button,{className:"documint-comment-leaf-create-button",icon:VF,label:"Add comment",onClick:()=>_(!0)}),t(a.Divider,{}),t(a.Button,{active:c.includes("bold"),className:"documint-comment-leaf-create-mark",icon:NF,label:"Bold",onClick:n}),t(a.Button,{active:c.includes("italic"),className:"documint-comment-leaf-create-mark",icon:XF,label:"Italic",onClick:j0}),t(a.Button,{active:c.includes("underline"),className:"documint-comment-leaf-create-mark",icon:SF,label:"Underline",onClick:w}),t(a.Button,{active:c.includes("strikethrough"),className:"documint-comment-leaf-create-mark",icon:qF,label:"Strikethrough",onClick:P0}),p.length>0?[t(a.Divider,{},"actions-divider"),...p.map((Y0,JN)=>{return t(a.Button,{className:"documint-comment-leaf-create-mark",icon:Y0.icon,label:Y0.label,onClick:()=>Y0.onClick()},`${Y0.label}:${JN}`)})]:null]}):null,t("div",{className:m?"documint-comment-leaf-create-content":void 0,children:mF})]})})}function AG({canCreate:N,canEdit:F,canMutateThread:A,canReply:M,canSaveEditedComment:D,comments:E,composerRef:$,editDraft:Z,editingCommentIndex:Y,isComposerVisible:X,isInitialCommentVisible:y,isResolved:Q,link:J,completionSources:V,mode:U,onBeginEditingComment:S,onCancelEditing:q,onChangeCreateDraft:K,onChangeEditDraft:G,onChangeReplyDraft:z,onDeleteComment:H,onDeleteThread:B,onSubmitCreate:_,onSubmitEditedComment:j,onSubmitReply:L,onToggleResolved:T,rootComment:O,showRootComment:W,showThreadChrome:k,threadAge:g,composerPlaceholder:R,composerValue:P}){return V1(MG,{children:[k?V1("div",{className:"documint-comment-leaf-header",children:[t("span",{className:"documint-comment-leaf-age",children:g}),V1("div",{className:"documint-comment-leaf-actions",children:[t("button",{className:"documint-leaf-action","aria-label":Q?"Reopen comment":"Resolve comment",disabled:!F,onClick:T,title:Q?"Reopen comment":"Resolve comment",type:"button",children:t(y2,{size:14,strokeWidth:2.2})}),t("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment thread",disabled:!F,onClick:B,title:"Delete comment thread",type:"button",children:t(s0,{size:14,strokeWidth:2.2})})]})]}):null,k&&J?V1("div",{className:"documint-comment-leaf-link",children:[J.title?t("div",{className:"documint-link-leaf-title",children:J.title}):null,t("div",{className:"documint-link-leaf-url",children:J.url})]}):null,V1("div",{className:`documint-comment-thread${W?"":" is-empty"}`,children:[t("article",{className:W?`documint-comment-message documint-comment-message-root${y?" is-visible":""}`:"documint-comment-message documint-comment-message-root is-hidden",children:O?t(m5,{completionSources:V,onEdit:()=>S(0,O.body),value:O.body}):null}),E.slice(1).map((b,f)=>{let m=f+1,x=Y===m;return V1("article",{className:"documint-comment-message",children:[!x?V1("div",{className:"documint-comment-message-meta",children:[t("span",{children:x$(b.updatedAt)}),A?V1("div",{className:"documint-comment-leaf-actions",children:[t("button",{className:"documint-leaf-action","aria-label":"Edit comment",disabled:!A,onClick:()=>{S(m,b.body)},title:"Edit comment",type:"button",children:t(Q2,{size:14,strokeWidth:2.2})}),t("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment",disabled:!A,onClick:()=>H(m),title:"Delete comment",type:"button",children:t(s0,{size:14,strokeWidth:2.2})})]}):null]}):null,x?t(LF,{actions:{kind:"edit",onCancel:q,onSave:()=>j(m),saveDisabled:!D},completionSources:V,onChange:G,readOnly:!F,rows:3,value:Z}):t(m5,{completionSources:V,onEdit:()=>S(m,b.body),value:b.body})]},`${b.updatedAt}:${m}`)})]}),t("div",{className:`documint-comment-reply${k?"":" is-standalone"}${X?" is-visible":""}`,children:t(LF,{actions:U==="create"?{kind:"compose",onSubmit:_,submitDisabled:!N,submitLabel:"Create comment"}:{kind:"compose",onSubmit:L,submitDisabled:!M,submitLabel:"Reply"},completionSources:V,onChange:U==="create"?K:z,placeholder:R,readOnly:!F,ref:$,rows:3,value:P})})]})}function x$(N){let F=new Date(N);if(Number.isNaN(F.getTime()))return N;let A=F.getTime()-Date.now(),M=60000,D=60*M,E=24*D,$=7*E,Z=30*E,Y=365*E,X=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});if(Math.abs(A)<M)return"just now";if(Math.abs(A)<D)return X.format(Math.round(A/M),"minute");if(Math.abs(A)<E)return X.format(Math.round(A/D),"hour");if(Math.abs(A)<$)return X.format(Math.round(A/E),"day");if(Math.abs(A)<Y)return X.format(Math.round(A/Z),"month");return X.format(Math.round(A/Y),"year")}import{jsx as F1,jsxs as $G}from"react/jsx-runtime";var DG=[{icon:AF,label:"Heading 1",text:"# "},{icon:MF,label:"Heading 2",text:"## "},{icon:DF,label:"Heading 3",text:"### "},{icon:$F,label:"Heading 4",text:"#### "},{icon:EF,label:"Heading 5",text:"##### "},{icon:ZF,label:"Heading 6",text:"###### "}],EG=[{columns:2,text:"2 columns"},{columns:3,text:"3 columns"},{columns:4,text:"4 columns"},{columns:5,text:"5 columns"}];function l$({onInsert:N,onInsertTable:F}){return $G(a,{children:[F1(a.Button,{icon:JF,label:"Insert bulleted list",onClick:()=>N("- ")}),F1(a.Button,{icon:yF,label:"Insert numbered list",onClick:()=>N("1. ")}),F1(a.Button,{icon:QF,label:"Insert task list",onClick:()=>N("- [ ] ")}),F1(a.Divider,{}),F1(a.Menu,{icon:YF,label:"Insert heading",onSelect:N,children:DG.map(({icon:A,label:M,text:D})=>F1(a.MenuItem,{icon:A,text:M,value:D},D))}),F1(a.Menu,{icon:I1,label:"Insert table",onSelect:(A)=>F(Number(A)),children:EG.map(({columns:A,text:M})=>F1(a.MenuItem,{icon:I1,text:M,value:String(A)},A))}),F1(a.Divider,{}),F1(a.Button,{icon:KF,label:"Insert blockquote",onClick:()=>N("> ")}),F1(a.Button,{icon:UF,label:"Insert divider",onClick:()=>N("--- ")})]})}import{useState as d$}from"react";import{jsx as z1,jsxs as jF}from"react/jsx-runtime";function a$({title:N,url:F,canEdit:A,onSave:M,onDelete:D}){let[E,$]=d$(!1),[Z,Y]=d$(""),X=YG(F),y=XG(F),Q=A&&!E,J=A&&Z.trim().length>0,V=ZG();return jF("div",{className:"documint-link-leaf",children:[N&&z1("div",{className:"documint-link-leaf-title",children:N}),jF("div",{className:"documint-link-leaf-row",children:[E?z1(LF,{actions:{kind:"edit",onCancel:()=>$(!1),onSave:()=>{M(encodeURI(Z.trim())),$(!1)},saveDisabled:!J},autoFocus:!0,onChange:Y,readOnly:!A,rows:3,saveOnEnter:!0,value:Z}):jF("div",{className:"documint-link-leaf-url-row",children:[y&&z1("img",{alt:"","aria-hidden":"true",className:"documint-link-leaf-favicon",onError:(q)=>{q.currentTarget.hidden=!0},src:y},y),z1("div",{className:"documint-link-leaf-url",children:X})]}),Q&&jF("div",{className:"documint-link-leaf-actions",children:[z1("button",{className:"documint-leaf-action","aria-label":"Edit link",onClick:()=>{if(!A)return;Y(X),$(!0)},title:"Edit link",children:z1(Q2,{size:14,strokeWidth:2.2})}),z1("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Remove link",onClick:D,title:"Remove link",children:z1(s0,{size:14,strokeWidth:2.2})})]})]}),z1("div",{className:"documint-link-leaf-divider"}),jF("div",{className:"documint-link-leaf-hint",children:[V,"click to open"]})]})}function ZG(){if(typeof navigator>"u")return"Ctrl+";let N=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/.test(N)?"CMD+":"CTRL+"}function YG(N){try{return decodeURIComponent(N)}catch{return N}}function XG(N){try{let{hostname:F}=new URL(N);return`https://www.google.com/s2/favicons?domain=${F}&sz=32`}catch{return null}}import{jsx as H1,jsxs as l5}from"react/jsx-runtime";var yG=[{text:"Column left",value:"left"},{text:"Column right",value:"right"}],QG=[{text:"Row above",value:"above"},{text:"Row below",value:"below"}],p5={text:"Delete column",value:"delete"},x5={text:"Delete row",value:"delete"},r$={text:"Delete table",value:"delete"};function c$({canDeleteColumn:N,canDeleteRow:F,onDeleteColumn:A,onDeleteRow:M,onDeleteTable:D,onInsertColumn:E,onInsertRow:$}){return l5(a,{children:[l5(a.Menu,{icon:u1,label:"Column actions",onSelect:(Z)=>{if(Z===p5.value){A();return}E(Z)},children:[yG.map(({text:Z,value:Y})=>H1(a.MenuItem,{icon:FN,text:Z,value:Y},Y)),H1(a.MenuDivider,{}),H1(a.MenuItem,{disabled:!N,icon:s0,text:p5.text,value:p5.value})]}),l5(a.Menu,{icon:g1,label:"Row actions",onSelect:(Z)=>{if(Z===x5.value){M();return}$(Z)},children:[QG.map(({text:Z,value:Y})=>H1(a.MenuItem,{icon:FN,text:Z,value:Y},Y)),H1(a.MenuDivider,{}),H1(a.MenuItem,{disabled:!F,icon:s0,text:x5.text,value:x5.value})]}),H1(a.Divider,{}),H1(a.Menu,{icon:I1,label:"Table actions",onSelect:()=>D(),children:H1(a.MenuItem,{icon:s0,text:r$.text,value:r$.value})})]})}import{useEffect as qZ,useEffectEvent as KZ,useRef as QA}from"react";function S2(N,F){return Object.is(N,F)}function d5(N){return(F,A)=>{if(F===A)return!0;if(!F||!A)return!1;return v3(N(F),N(A))}}function f3(N){return(F,A)=>{if(F===A)return!0;if(F.length!==A.length)return!1;return F.every((M,D)=>N(M,A[D]))}}function s$(N,F){return N.regionId===F.regionId&&N.offset===F.offset}function i$(N,F){return N.collapsed===F.collapsed&&s$(N.start,F.start)&&s$(N.end,F.end)}function o$(N,F){return JG(N.block,F.block)&&VG(N.span,F.span)}function n$(N,F){return UG(N.threads,F.threads)&&qG(N.liveRanges,F.liveRanges)}function a5(N,F){return v3(N,F)}function JG(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.blockId===F.blockId&&N.depth===F.depth&&N.nodeType===F.nodeType&&N.text===F.text}function VG(N,F){if(N===F)return!0;if(N.kind!==F.kind)return!1;switch(N.kind){case"link":return F.kind==="link"&&N.url===F.url;case"marks":return F.kind==="marks"&&v3(N.marks,F.marks);case"none":return!0}return!1}function UG(N,F){return v3(N,F)}function qG(N,F){if(N===F)return!0;if(N.length!==F.length)return!1;return N.every((A,M)=>{let D=F[M];return A.endOffset===D.endOffset&&A.regionId===D.regionId&&A.resolved===D.resolved&&A.startOffset===D.startOffset&&A.threadIndex===D.threadIndex})}function v3(N,F){if(N===F)return!0;if(N.length!==F.length)return!1;return N.every((A,M)=>Object.is(A,F[M]))}function t$(N,F,A){return KG(N,F,A)}function KG(N,F,A){let M=N.documentIndex!==F.documentIndex;return{previous:N,next:F,source:A==="external"?"external":"local",reason:A,documentChanged:M,changedRootIndexes:M?SG(N,F):[],animationsChanged:N.animations!==F.animations&&F.animations.length>0}}function SG(N,F){let A=N.documentIndex.document.blocks,M=F.documentIndex.document.blocks;if(A.length!==M.length)return M.map((D,E)=>E);return M.flatMap((D,E)=>D===A[E]?[]:[E])}function e$(N){let F=N,A=0,M=new Set,D=(E,$)=>{if(!E||E===F)return null;let Y=t$(F,E,$);F=E,A+=1;for(let X of M)X(Y);return Y};return{getVersion:()=>A,getState:()=>F,apply(E){return D(E,"command")},command(E,...$){return D(E(F,...$),"command")},replace(E,$="external"){return D(E,$)},subscribe(E){return M.add(E),()=>{M.delete(E)}},subscribeValue(E,$,Z=S2){let Y=E(F),X=(y)=>{let Q=E(y.next);if(Z(Y,Q))return;Y=Q,$()};return M.add(X),()=>{M.delete(X)}}}}function NZ(){let N=null,F=null,A=null,M=new Set,D=(E)=>{if(N=E,F===E)return;F=E;for(let $ of M)$()};return{get(){if(N)return N;if(!A)throw Error("Viewport resolver has not been registered.");return N=A(),N},invalidate(){N=null},peek(){return N},observeViewport(E){D(E)},peekPublishedViewport(){return F},setViewportResolver(E){A=E},subscribe(E){return M.add(E),()=>{M.delete(E)}}}}import{createContext as GG,useCallback as r5,useContext as zG,useSyncExternalStore as HG}from"react";import{jsx as _G}from"react/jsx-runtime";var FZ=GG(null);function c5({children:N,store:F}){return _G(FZ.Provider,{value:F,children:N})}function x0(){let N=zG(FZ);if(!N)throw Error("Documint store is unavailable outside DocumintStoreProvider.");return N}function I(N){let F=x0().editor;return r5((...A)=>F.command(N,...A),[F,N])}function A0(N,...F){let A=x0(),M=r5((E)=>N.subscribe(A,E,...F),[A,N,...F]),D=r5(()=>N.read(A,...F),[A,N,...F]);return HG(M,D,D)}function AZ(N,F){let A=E6(N);if(!A)return null;let M=j3(A.text,A.offset,F??[]);return M?{...M,regionId:A.regionId}:null}function MZ(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.regionId===F.regionId&&N.trigger===F.trigger&&N.query===F.query&&N.triggerStart===F.triggerStart&&N.caret===F.caret&&P$(N.matches,F.matches)}function DZ(N,F){let A={endOffset:F.caret,regionId:F.regionId,startOffset:F.triggerStart};if(BG(N,F))return{kind:"mention",name:N.label,target:A,trailingText:" ",userId:N.id};return{endOffset:F.caret,kind:"text",startOffset:F.triggerStart,text:f5(F,N)}}function BG(N,F){return Boolean(N.id)&&(N.kind==="mention"||F.trigger==="@")}var EZ=[["100","💯"],["airplane","✈️"],["alarm","⏰"],["angry","😠"],["astonished","😲"],["baby","👶"],["balloon","🎈"],["beer","🍺"],["birthday","🎂"],["blush","😊"],["bomb","💣"],["book","📚"],["boom","💥"],["broken_heart","💔"],["calendar","📅"],["camera","📷"],["cat","😺"],["check","✅"],["clap","👏"],["cold_sweat","😰"],["confetti_ball","🎊"],["confused","😕"],["cool","😎"],["cry","😢"],["disappointed","😞"],["dizzy","💫"],["dog","🐶"],["drooling","🤤"],["eggplant","🍆"],["eyes","👀"],["facepalm","🤦"],["fire","🔥"],["flushed","😳"],["ghost","👻"],["gift","🎁"],["grin","😁"],["grinning","😀"],["halo","😇"],["handshake","🤝"],["heart","❤️"],["heart_eyes","😍"],["hug","🤗"],["joy","😂"],["kiss","😘"],["laughing","😆"],["light_bulb","💡"],["loudspeaker","📢"],["love_letter","💌"],["melting","🫠"],["mind_blown","🤯"],["money_mouth","🤑"],["monocle","🧐"],["muscle","💪"],["nauseated","🤢"],["nerd","🤓"],["neutral","😐"],["ok_hand","👌"],["partying","🥳"],["pensive","😔"],["pizza","🍕"],["pleading","🥺"],["poop","💩"],["pray","🙏"],["raised_hands","🙌"],["relieved","😌"],["rocket","🚀"],["rofl","🤣"],["rolling_eyes","🙄"],["rose","🌹"],["scream","😱"],["see_no_evil","🙈"],["shushing","🤫"],["sleeping","😴"],["slightly_smiling","🙂"],["smile","😄"],["smiley","😃"],["smirk","😏"],["sob","😭"],["sparkles","✨"],["star","⭐"],["star_struck","🤩"],["sweat_smile","😅"],["tada","🎉"],["thinking","🤔"],["thumbs_down","👎"],["thumbs_up","👍"],["tired","😫"],["triumph","😤"],["unamused","😒"],["upside_down","🙃"],["warning","⚠️"],["wave","👋"],["weary","😩"],["wink","😉"],["woozy","🥴"],["writing","✍️"],["yawn","🥱"],["yum","😋"],["zany","🤪"],["zipper_mouth","🤐"]];var k3={trigger:":",items:EZ.map(WG)};function WG(N){if(N.length!==2)throw Error("Emoji completion rows must be [label, value] tuples.");let[F,A]=N;return{label:F,icon:A,insertText:A}}function s5(N){if(!N?.length)return null;return{trigger:"@",items:N.map((F)=>({id:F.id,kind:"mention",label:F.fullName??F.username})).sort((F,A)=>F.label.localeCompare(A.label,void 0,{sensitivity:"base"}))}}function CF(N,F){return N.anchor.regionId===F.anchor.regionId&&N.anchor.offset===F.anchor.offset&&N.leftOverride===F.leftOverride&&N.paddingY===F.paddingY}function i5(N,F,A){if(!N||N.kind==="task-toggle")return null;if(N.commentThreadIndex!==null){let M=F[N.commentThreadIndex]??null,D=A.find((E)=>E.threadIndex===N.commentThreadIndex);if(!M||!D)return null;return{anchor:{regionId:D.regionId,offset:D.startOffset},animateInitialComment:!1,kind:"thread",link:N.kind==="link"?{title:N.title,url:N.url}:null,resolved:j1(M),thread:M,threadIndex:N.commentThreadIndex}}if(N.kind!=="link")return null;return{anchor:{regionId:N.regionId,offset:N.startOffset},endOffset:N.endOffset,kind:"link",regionId:N.regionId,startOffset:N.startOffset,title:N.title,url:N.url}}function l0(N,F,A=S2){return A1(N,(M,D,...E)=>F(M,...E),A)}function ZZ(N){let F=Object.entries(N),A=F.map(([,M])=>M);return l0(A,(M,...D)=>{let E={};for(let $=0;$<F.length;$++){let[Z]=F[$];E[Z]=D[$]}return E},OG)}function A1(N,F,A=S2){let M=new WeakMap,D=(E,...$)=>{let Z=N.map((Q)=>Q.read(E)),Y=M.get(E);if(Y&&$Z(Y.depValues,Z)&&$Z(Y.params,$))return Y.value;let X=F(E,$,...Z),y=Y&&A(Y.value,X)?Y.value:X;return M.set(E,{depValues:Z,params:$,value:y}),y};return{read:D,subscribe(E,$,...Z){let Y=D(E,...Z),X=()=>{let Q=D(E,...Z);if(A(Y,Q))return;Y=Q,$()},y=N.map((Q)=>Q.subscribe(E,X));return()=>{for(let Q of y)Q()}}}}function OG(N,F){if(N===F)return!0;let A=Object.keys(N),M=Object.keys(F);if(A.length!==M.length)return!1;return A.every((D)=>Object.is(N[D],F[D]))}function $Z(N,F){return N.length===F.length&&N.every((A,M)=>Object.is(A,F[M]))}function o5({read:N,subscribe:F}){return{read:N,subscribe:F}}function m3(N,F=S2){return o5({read:(A)=>N(A.editor.getState()),subscribe:(A,M)=>A.editor.subscribeValue(N,M,F)})}var M1=o5({read:(N)=>N.viewport.peekPublishedViewport(),subscribe:(N,F)=>N.viewport.subscribe(F)});var TG=(N)=>N,K0=m3(TG),u3=m3((N)=>N.documentIndex),n5=m3((N)=>N.documentIndex.imageUrls);var LG=d5((N)=>[N.regionId,N.startOffset,N.endOffset]),wG=d5((N)=>[N.start.left,N.start.top,N.end.left,N.end.top]),$N=l0([K0],(N,F)=>u0(F),n$),t5=l0([$N],(N,F)=>F.threads,f3(Object.is)),YZ=l0([$N],(N,F)=>F.liveRanges,xG),D1=l0([K0],(N,F)=>X0(F),i$),XZ=l0([K0],(N,F)=>jN(F),LG),yZ=l0([K0],(N,F)=>Y6(F),a5),QZ=l0([K0,D1,M1],(N,F,A,M)=>{if(!M)return null;return bG(F,M,A)},wG),e5=ZZ({handles:QZ,marks:yZ,normalized:D1,range:XZ,viewport:M1}),NA=A1([XZ,yZ,QZ,t5],(N,[F],A,M,D,E)=>{return kG({activeMarks:M,handles:D,promotedThread:F,selectionRange:A,threads:E})},mG),FA=A1([K0,D1,M1,t5,YZ],(N,[F],A,M,D,E,$)=>{if(!D)return null;return uG({isEditable:F,liveRanges:$,normalizedSelection:M,state:A,threads:E,viewport:D})},pG),AA=l0([K0,D1,M1],(N,F,A,M)=>{if(!M)return!0;let D=oF(F,M,A.end);return D!=="above"&&D!=="below"}),MA=l0([K0,D1,M1],(N,F,A,M)=>{if(!M)return null;return D5(F,M,A.end)},lG),DA=A1([K0],(N,[F],A)=>{return AZ(A,F)},MZ),EA=A1([],(N,[F])=>{let A=s5(F);return A?[A,k3]:[k3]},jG);function jG(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.length===F.length&&N.every((A,M)=>_$(A,F[M]))}var $A=A1([K0,M1,t5,YZ],(N,[F],A,M,D,E)=>{let $=F?.kind==="link"&&M?S5(A,M,{regionId:F.regionId,offset:dG(F)}):F,Z=i5($,D,E);return{cursor:F?.kind==="task-toggle"||Z?.kind==="link"?"pointer":"text",leaf:Z}},aG),ZA=l0([K0],(N,F)=>$6(F),o$),YA=A1([K0,D1,M1],(N,[F],A,M,D)=>{if(!F||!D)return null;return CG(A,D,M,F)},RG);function CG(N,F,A,M){if(!A.collapsed)return null;let D=Z6(N);if(!D)return null;let E=oN(N,F,M,D),$=D.image?M.images.get(D.image.url)?.intrinsicWidth??null:null;return E?{bounds:E,inline:D,maxWidth:$}:null}function RG(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.maxWidth===F.maxWidth&&N.bounds.left===F.bounds.left&&N.bounds.top===F.bounds.top&&N.bounds.width===F.bounds.width&&N.bounds.height===F.bounds.height}function bG(N,F,A){if(A.collapsed)return null;let M=m1(N,F,A.start),D=m1(N,F,A.end);if(!M||!D)return null;return{end:{left:D.left,top:D.top+D.height},start:{left:M.left,top:M.top}}}var fG=2;function vG(N,F,A){return{activeMarks:A,anchor:{regionId:N.regionId,offset:N.endOffset},kind:"annotation",leftOverride:F.start.left,paddingY:fG,selection:N}}function kG({activeMarks:N,handles:F,promotedThread:A,selectionRange:M,threads:D}){if(!M||!F)return null;if(A&&JZ(A.selection,M)){let E=D[A.threadIndex];if(!E)return null;return{...A,kind:"thread",link:null,resolved:j1(E),thread:E}}return vG(M,F,N)}function JZ(N,F){return N.endOffset===F.endOffset&&N.regionId===F.regionId&&N.startOffset===F.startOffset}function mG(N,F){if(N===F)return!0;if(!N||!F)return!1;if(N.kind!==F.kind)return!1;switch(N.kind){case"annotation":return F.kind==="annotation"&&CF(N,F)&&a5(N.activeMarks,F.activeMarks)&&JZ(N.selection,F.selection);case"thread":return F.kind==="thread"&&h3(N,F)}}function uG({isEditable:N,liveRanges:F,normalizedSelection:A,state:M,threads:D,viewport:E}){let $=M.selection.focus;if(!A.collapsed)return null;let Z=N?IG(M):null;if(Z)return Z;let Y=N?gG(M,E):null;if(Y)return Y;return i5(S5(M,E,$),D,F)}function gG(N,F){let A=N.selection.focus,M=N.documentIndex.regionIndex.get(A.regionId),D=M?N.documentIndex.tableCellIndex.get(M.id)??null:null;if(!M||!D)return null;let E=N.documentIndex.blockIndex.get(M.blockId),$=E?.type==="table"?N.documentIndex.document.blocks[E.rootIndex]:null;if(!E||!$||$.type!=="table")return null;let Z=hG(F,M.id),Y=Math.max(1,...$.rows.map((X)=>X.cells.length));return Z!==null?{anchor:A,cellIndex:D.cellIndex,columnCount:Y,kind:"table",leftOverride:Z,rowCount:$.rows.length,rowIndex:D.rowIndex}:null}function hG(N,F){let A=N.layout.lines.find((M)=>M.regionId===F);return A?A.left:null}function IG(N){let F=N.selection.focus,A=N.documentIndex.regionIndex.get(F.regionId);if(!A||A.blockType!=="paragraph"||A.text.length>0)return null;if(F.offset!==0)return null;let M=N.documentIndex.blockIndex.get(A.blockId);if(!M||M.parentBlockId!==null)return null;return{anchor:F,kind:"insertion"}}function pG(N,F){if(N===F)return!0;if(!N||!F)return!1;if(N.kind!==F.kind)return!1;switch(N.kind){case"thread":return F.kind==="thread"&&h3(N,F);case"insertion":return F.kind==="insertion"&&CF(N,F);case"link":return F.kind==="link"&&h3(N,F);case"table":return F.kind==="table"&&CF(N,F)&&N.cellIndex===F.cellIndex&&N.columnCount===F.columnCount&&N.rowCount===F.rowCount&&N.rowIndex===F.rowIndex}}function xG(N,F){if(N===F)return!0;if(N.length!==F.length)return!1;return N.every((A,M)=>{let D=F[M];return A.endOffset===D.endOffset&&A.regionId===D.regionId&&A.resolved===D.resolved&&A.startOffset===D.startOffset&&A.threadIndex===D.threadIndex})}function lG(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.blockId===F.blockId&&N.regionId===F.regionId&&N.height===F.height&&N.left===F.left&&N.offset===F.offset&&N.top===F.top}function dG(N){return N.startOffset<N.endOffset?N.startOffset+1:N.startOffset}function aG(N,F){return N.cursor===F.cursor&&rG(N.leaf,F.leaf)}function rG(N,F){if(N===F)return!0;if(!N||!F)return!1;return h3(N,F)}function h3(N,F){if(N.kind!==F.kind)return!1;if(!CF(N,F))return!1;switch(N.kind){case"thread":return F.kind==="thread"&&N.animateInitialComment===F.animateInitialComment&&N.link?.title===F.link?.title&&N.link?.url===F.link?.url&&N.resolved===F.resolved&&N.thread===F.thread&&N.threadIndex===F.threadIndex;case"link":return F.kind==="link"&&N.endOffset===F.endOffset&&N.regionId===F.regionId&&N.startOffset===F.startOffset&&N.title===F.title&&N.url===F.url}}var XA=l0([K0,$N],(N,F,A)=>cG(F,A.liveRanges));function cG(N,F){let A=new Map(N.documentIndex.regions.map((Y,X)=>[Y.id,X])),M=g3(A,N.selection.anchor.regionId,N.selection.anchor.offset),D=g3(A,N.selection.focus.regionId,N.selection.focus.offset),[E,$]=M<=D?[M,D]:[D,M],Z=M===D;for(let Y of F){let X=g3(A,Y.regionId,Y.startOffset),y=g3(A,Y.regionId,Y.endOffset);if(Z){if(E>=X&&E<=y)return Y.threadIndex;continue}if(Math.max(E,X)<Math.min($,y))return Y.threadIndex}return null}function g3(N,F,A){return(N.get(F)??-1)*1e6+A}var sG=A1([u3],(N,[F],A)=>{if(!F?.length)return;return sF(A,F)},VZ),yA=A1([u3,M1],(N,[F],A,M)=>{let D=sG.read(N,F);if(!D)return;return M?iF(A,M,D):D},VZ);function VZ(N,F){if(N===F)return!0;if(!N||!F)return!1;return iG(N,F)}var iG=f3((N,F)=>{return N.id===F.id&&N.username===F.username&&N.fullName===F.fullName&&N.avatarUrl===F.avatarUrl&&N.color===F.color&&oG(N.cursorPoint,F.cursorPoint)&&nG(N.viewport,F.viewport)});function oG(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.offset===F.offset&&N.regionId===F.regionId}function nG(N,F){if(N===F)return!0;if(!N||!F)return!1;if(N.status!==F.status)return!1;if(N.status==="unresolved")return!0;return F.status!=="unresolved"&&N.scrollTop===F.scrollTop}function UZ(N){return{editor:e$(p2(N)),viewport:NZ()}}var tG=600,eG=530,ZN=24;function GZ({getScrollTop:N,isEditable:F,layoutWidth:A,onVisibilityChange:M,scrollContentHeight:D,scrollTo:E,viewportHeight:$}){let Z=A0(D1),Y=A0(FA,F),X=A0(AA),y=A0(MA),Q=Z.start.regionId===Z.end.regionId&&Z.start.offset===Z.end.offset,J=QA(!0),V=QA(0),U=QA(null),S=KZ(()=>{M()}),q=KZ(()=>{V.current=typeof performance<"u"?performance.now():Date.now(),J.current=!0,S()});return qZ(()=>{let K=Z.end,G={layoutWidth:A,offset:K.offset,regionId:K.regionId,scrollContentHeight:D,viewportHeight:$};if(Nz(U.current,G))return;if(!y)return;let z=N(),H=z+ZN,B=z+$-ZN;if(y.top<H){let _=E(Math.max(0,y.top-ZN));if(SZ(y,_,$,ZN))U.current=G;return}if(y.top+y.height>B){let _=E(Math.max(0,y.top+y.height-$+ZN));if(SZ(y,_,$,ZN))U.current=G;return}U.current=G},[y,A,Z.end.offset,Z.end.regionId,D,$]),qZ(()=>{if(J.current=!0,S(),!Q||!X||typeof window>"u")return;let K=window.setInterval(()=>{if((typeof performance<"u"?performance.now():Date.now())-V.current<tG){if(!J.current)J.current=!0,S();return}J.current=!J.current,S()},eG);return()=>{window.clearInterval(K)}},[Q,X]),{caretInViewport:X,leaf:Y,isVisible:()=>J.current,markActivity:q}}function Nz(N,F){return N?.layoutWidth===F.layoutWidth&&N.regionId===F.regionId&&N.offset===F.offset&&N.scrollContentHeight===F.scrollContentHeight&&N.viewportHeight===F.viewportHeight}function SZ(N,F,A,M){return N.top>=F+M&&N.top+N.height<=F+A-M}import{useCallback as Fz}from"react";function zZ({completionSources:N,enabled:F,onMentionAccepted:A}){let M=A0(DA,F?N:void 0),D=I(F9),E=I(T6),$=Fz((X,y)=>{let Q=DZ(X,y);if(Q.kind==="mention"){let J=D(Q.target,Q.userId,Q.name,Q.trailingText);if(J)A?.({target:Q.target,transition:J,userId:Q.userId});return}E(Q.startOffset,Q.endOffset,Q.text)},[D,A,E]),Z=L3({activeCompletion:M,contextKey:M?Az(M):null,onAccept:$}),Y=M&&Z.leafProps?{kind:"completion",anchor:{regionId:M.regionId,offset:M.triggerStart},...Z.leafProps}:null;return{handleBeforeInput:Z.handleBeforeInput,handleKeyDown:Z.handleKeyDown,leaf:Y}}function Az(N){if(!("regionId"in N)||typeof N.regionId!=="string")return null;return[N.regionId,N.trigger,N.triggerStart,N.caret,N.query].join(":")}import{useMemo as JA,useRef as RF,useEffectEvent as VA}from"react";var Mz=48;function HZ(N){let F=A0(YA,N),A=I(A9),M=RF(null),D=RF(null),E=RF(null),$=RF(null),Z=RF(1),Y=VA((V,U)=>{if(!F)return;V.preventDefault(),V.stopPropagation(),V.currentTarget.setPointerCapture(V.pointerId),$.current=V.pointerId,M.current=V.clientX,D.current=V.clientY,E.current=F.inline.image?.width??F.bounds.width,Z.current=U}),X=VA((V)=>{if($.current!==V.pointerId||M.current===null||D.current===null||E.current===null||!F?.inline.image)return;let U=V.clientX-M.current,S=V.clientY-D.current,q=Math.min(F.maxWidth??1/0,Math.max(Mz,Math.round(E.current+Z.current*(U+S)))),K={end:F.inline.end,image:F.inline.image,start:F.inline.start};A(K,q)}),y=VA((V)=>{if(V.currentTarget.hasPointerCapture(V.pointerId))V.currentTarget.releasePointerCapture(V.pointerId);$.current=null,M.current=null,D.current=null,E.current=null}),Q=JA(()=>({onPointerCancel:y,onPointerDown:(V)=>Y(V,-1),onPointerMove:X,onPointerUp:y}),[]),J=JA(()=>({onPointerCancel:y,onPointerDown:(V)=>Y(V,1),onPointerMove:X,onPointerUp:y}),[]);return JA(()=>{if(!F)return null;let{bounds:V}=F;return{start:{left:V.left,top:V.top,props:Q},end:{left:V.left+V.width,props:J,top:V.top+V.height}}},[F])}import{useEffect as _Z,useEffectEvent as BZ,useMemo as PZ,useRef as Dz,useState as Ez}from"react";function WZ(N){let F=A0(n5),[A,M]=Ez(new Map),D=BZ((Y)=>{if(typeof createImageBitmap>"u")return;let X=Zz(A,Y),y=Yz(A,Y);if(X.length)M((Q)=>{let J=new Map(Q);for(let V of X)J.delete(V);return J});for(let Q of y)M((J)=>UA(J,Q,bF("loading"))),$z(Q,N).then((J)=>{M((V)=>{if(!V.has(Q))return J?.close(),V;return UA(V,Q,J?bF("loaded",J):bF("error"))})})});_Z(()=>{D(F)},[F]);let E=Dz(new Map);_Z(()=>{for(let[Y,X]of E.current)if(!A.has(Y))X.source?.close();E.current=A},[A]);let $=BZ(async(Y)=>{try{let X=await N.writeFile(Y),y=await createImageBitmap(Y).catch(()=>null);return M((Q)=>UA(Q,X,y?bF("loaded",y):bF("error"))),X}catch{return null}}),Z=PZ(()=>A.size===0?null:{images:A},[A]);return PZ(()=>({resources:Z,persistImage:$}),[Z,$])}async function $z(N,F){try{let A=await F.readFile(N);return A?await createImageBitmap(A):null}catch{return null}}function Zz(N,F){return[...N.keys()].filter((A)=>!F.has(A))}function Yz(N,F){return[...F].filter((A)=>{let M=N.get(A)?.status;return M!=="loaded"&&M!=="loading"})}function UA(N,F,A){let M=new Map(N);return M.set(F,A),M}function bF(N,F){return{intrinsicHeight:F?.height??0,intrinsicWidth:F?.width??0,source:F??null,status:N}}import{useEffect as OZ,useEffectEvent as S0,useRef as l1,useState as Xz}from"react";var yz=48,TZ=44,LZ=32,wZ=1.6,Qz=600,Jz=24,Vz=500;function Uz(N,F){let A=F.x-N.x,M=F.y-N.y,D=Math.abs(A),E=Math.abs(M),$=F.time-N.time;if(D<TZ||E>LZ||D<E*wZ||$>Qz)return null;return A<0?"left":"right"}function jZ({autoScrollDuringDrag:N,canvasRef:F,focusInput:A,isEditable:M,onActivity:D,resolvePoint:E,storage:$}){let Z=x0(),Y=I(O0),X=I(y5),y=I(Q5),Q=I(R6),J=I(b6),V=I(E9),U=I(nN),[S,q]=Xz(null),{cursor:K,leaf:G}=A0($A,S),z=l1(null),H=l1(!1),B=l1(null),_=l1(null),j=l1(null),L=l1(null),T=l1(new Set),O=l1(null);OZ(()=>{if(S&&S.kind!=="task-toggle"&&!G)q(null)},[S,G]),OZ(()=>()=>{if(z.current!==null)window.clearTimeout(z.current)},[]);let W=S0(()=>{if(z.current!==null)window.clearTimeout(z.current),z.current=null}),k=S0(()=>{W(),z.current=window.setTimeout(()=>{if(z.current=null,!H.current)q(null)},yz)}),g=S0(()=>{if(!H.current)W(),q(null)}),R=S0((w)=>{if(!w){g();return}if(w.kind==="task-toggle"){W(),q((p)=>p?.kind==="task-toggle"&&p.listItemId===w.listItemId?p:w);return}if(w.commentThreadIndex!==null){W();let p=w.commentThreadIndex;q((D0)=>D0?.kind!=="task-toggle"&&D0?.commentThreadIndex===p?D0:w);return}if(w.kind!=="link"){g();return}W(),q((p)=>p?.kind==="link"&&p.title===w.title&&p.url===w.url&&p.startOffset===w.startOffset&&p.endOffset===w.endOffset?p:w)}),P=S0((w)=>{let p=E(w);if(!p)return null;let D0=Z.editor.getState();return jE(D0,Z.viewport.get(),p)}),b=S0((w)=>{let p=F.current;if(p&&B.current===w)p.releasePointerCapture(w)}),f=S0(()=>{B.current=null,_.current=null}),m=S0(()=>{L.current=null}),x=S0((w)=>{O.current={expiresAt:w.timeStamp+Vz,x:w.clientX,y:w.clientY}}),r=S0((w)=>{if(w.pointerType==="touch")T.current.delete(w.pointerId)}),i=S0((w)=>{b(w.pointerId),f(),m(),r(w)}),B0=S0((w)=>{if(j.current=w.pointerType,w.pointerType==="touch"){if(T.current.add(w.pointerId),T.current.size>1)m();else if(M&&w.isPrimary)L.current={pointerId:w.pointerId,startX:w.clientX,startY:w.clientY,startedAt:w.timeStamp,swiping:!1};return}let p=F.current,D0=Z.viewport.get(),G0=E(w);if(!G0)return;if(P(w)?.kind==="task-toggle")return;if(!p)return;let E0=w.shiftKey?y(D0,G0):X(D0,G0);if(!E0)return;let C0=E0.next.selection.focus;B.current=w.pointerId,_.current=w.shiftKey?E0.previous.selection.anchor:C0,D(),p.setPointerCapture(w.pointerId),A(C0)}),Q0=S0((w)=>{let p=L.current;if(w.pointerType==="touch"&&p?.pointerId===w.pointerId){let E0=w.clientX-p.startX,C0=w.clientY-p.startY,B1=Math.abs(E0),z2=Math.abs(C0);if(B1>=TZ&&z2<=LZ&&B1>=z2*wZ)p.swiping=!0,w.preventDefault();return}let D0=_.current,G0=E(w);if(!G0)return;if(B.current!==w.pointerId||!D0){R(P(w));return}if(!U(Z.viewport.get(),G0,D0))return;D(),N(w)}),v=S0(()=>{if(!H.current)k()}),l=S0((w)=>{let p=L.current;if(w.pointerType==="touch"&&p?.pointerId===w.pointerId){let D0=T.current.size===1?Uz({time:p.startedAt,x:p.startX,y:p.startY},{time:w.timeStamp,x:w.clientX,y:w.clientY}):null;if(D0)if(w.preventDefault(),x(w),D0==="right")Q();else J();else if(p.swiping)x(w)}i(w)}),c=S0((w)=>{let p=O.current;if(p){let E0=w.clientX-p.x,C0=w.clientY-p.y,B1=w.timeStamp<=p.expiresAt&&Math.hypot(E0,C0)<=Jz;if(O.current=null,B1){j.current=null,w.preventDefault(),w.stopPropagation();return}}let D0=j.current==="touch";j.current=null;let G0=P(w);if(G0?.kind==="task-toggle"){if(V(G0.listItemId))w.preventDefault(),w.stopPropagation(),D();return}if(G0?.kind==="link"&&(w.metaKey||w.ctrlKey)){w.preventDefault(),w.stopPropagation(),$.openFile(G0.url);return}if(!D0){A();return}let Z0=E(w);if(Z0){let E0=X(Z.viewport.get(),Z0);if(!E0){A();return}D(),A(E0.next.selection.focus)}else A()}),n=S0((w)=>{let p=Z.editor.getState(),D0=E(w),G0=P(w);if(!D0||G0?.kind==="task-toggle")return;let Z0=M5(p,Z.viewport.get(),D0);if(!Z0)return;w.preventDefault(),w.stopPropagation(),D(),Y(Z0),A()}),j0=S0(()=>{H.current=!0,W()}),P0=S0(()=>{H.current=!1,k()});return{canvasHandlers:{onClick:c,onDoubleClick:n,onPointerCancel:i,onPointerDown:B0,onPointerLeave:v,onPointerMove:Q0,onPointerUp:l},cursor:K,leaf:G,leafHandlers:{onPointerEnter:j0,onPointerLeave:P0}}}import{useEffect as KA,useEffectEvent as k0,useLayoutEffect as qz,useRef as RZ,useState as Kz}from"react";import{useEffect as Jx1}from"react";var qA=[{key:"Backspace",command:"deleteBackward"},{key:"Enter",shiftKey:!0,command:"insertSoftLineBreak"},{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:"toggleCode"},{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 CZ(N,F=qA){return F.find((A)=>{let M=A.shiftKey==="any"?!0:(A.shiftKey??!1)===(N.shiftKey??!1);return A.key.toLowerCase()===N.key.toLowerCase()&&(A.altKey??!1)===(N.altKey??!1)&&M&&(A.modKey??!1)===Boolean(N.metaKey||N.ctrlKey)})?.command??null}var Sz=1024,bZ=16;function vZ({inputRef:N,keybindings:F,enableTouchKeyDown:A=!1,onActivity:M,onBeforeInput:D,onKeyDown:E,onImagePaste:$}){let Z=x0(),Y=A0(K0),X=Gz(),y=()=>Z.editor.getState(),Q=RZ(!1),J=RZ(!1),V=I(Pz),U=I(Wz),S=I(O6),q=I(P8),K=I(W8),G=I(O8),z=I(T8),H=I(Oz),B=I(cD),_=I(N9),j=I(eD),L=I(sD),T=k0((v,...l)=>{let c=v(...l);if(c)M();return c}),O=k0(()=>{let v=N.current;if(!v)return;if(typeof document>"u")return;let l=document.execCommand;if(typeof l!=="function")return;try{Q.current=!0,l.call(document,"insertText",!1,""),l.call(document,"delete")}catch{}finally{Q.current=!1,fF(v,y())}}),W=k0(()=>{if(J.current)return;J.current=!0,O()}),k=k0(()=>{O()}),g=k0((v)=>{let l=N.current;if(!l)return;let c=Z.viewport.get(),n=m1(y(),c,v);if(!n)return;l.style.top=`${n.top}px`,l.style.left=`${n.left}px`,l.style.height=`${n.height}px`}),R=k0((v)=>{let l=N.current;if(!l)return;g(v??y().selection.focus),l.focus({preventScroll:!X}),fF(l,y()),W()}),P=k0((v)=>{if(Q.current)return;if(D?.(v))return;let l=y(),c=_z(v.inputType);if(v.inputType==="insertText"){if(!v.data)return;v.preventDefault();let n=fZ(v.target);if(n.charsToReplace>0){T(U,n.charsToReplace,n.trailingOffset,v.data);return}let j0=Hz(l,v.data);if(j0>0){let P0=v.data.slice(j0);if(P0.length>0)T(V,P0);return}T(V,v.data);return}if(v.inputType==="insertReplacementText"){if(!v.data)return;v.preventDefault();let n=fZ(v.target);T(U,n.charsToReplace,n.trailingOffset,v.data);return}if(zz(v.inputType)){v.preventDefault(),T(S);return}if(c==="backward"){v.preventDefault(),T(q);return}if(c==="forward"){v.preventDefault(),T(K);return}if(v.inputType==="historyUndo"){v.preventDefault(),T(G),k();return}if(v.inputType==="historyRedo"){v.preventDefault(),T(z),k();return}}),b=k0((v)=>{let l=y(),c=v.currentTarget.value,n=I3(l);if(Q.current)return;if(mZ(c,n).length===0){fF(v.currentTarget,l);return}T(V,c)}),f=k0((v)=>{if(E?.(v))return;if(!T(H,Z.viewport.get(),v.nativeEvent,F))return;v.preventDefault()}),m=k0((v)=>{let l=hN(y());if(!l)return;v.preventDefault(),v.clipboardData.setData("text/plain",U2(l))}),x=k0((v)=>{let l=y(),c=hN(l);if(!c)return;v.preventDefault(),v.clipboardData.setData("text/plain",U2(c)),T(B)}),r=k0(async(v)=>{let c=($?[...v.clipboardData.items].find((P0)=>P0.kind==="file"&&P0.type.startsWith("image/")):void 0)?.getAsFile()??null;if(c&&$){v.preventDefault();let P0=await $(c);if(P0)T(_,P0);return}let n=v.clipboardData.getData("text/plain");if(n.length===0)return;if(/^https?:\/\//.test(n)){if(T(j,n)){v.preventDefault();return}}v.preventDefault();let j0=C5(n);T(L,j0,n)}),i=k0(()=>{M();let v=N.current;if(v)fF(v,y())}),B0=k0((v)=>{if(M(),v.target.matches(":focus-visible"))R()});KA(()=>{let v=N.current;if(!v)return;fF(v,Y)},[Y,N]),qz(()=>{g(Y.selection.focus)},[Y]),KA(()=>{let v=N.current;if(!v)return;let l=(c)=>P(c);return v.addEventListener("beforeinput",l),()=>v.removeEventListener("beforeinput",l)},[N]);let Q0={onCopy:m,onCut:x,onPaste:r,...!X||A?{onKeyDown:f}:{}};return{canvasHandlers:{...Q0,onFocus:B0},focus:R,inputHandlers:{...Q0,onFocus:i,onInput:b}}}var kZ="";function Gz(){let[N,F]=Kz(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return!1;return window.matchMedia("(pointer: coarse)").matches});return KA(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return;let A=window.matchMedia("(pointer: coarse)"),M=(D)=>F(D.matches);return A.addEventListener?.("change",M),()=>A.removeEventListener?.("change",M)},[]),N}function zz(N){return N==="insertLineBreak"||N==="insertParagraph"}function fZ(N){let F=N,A=F?.selectionStart??0,M=F?.selectionEnd??A,D=F?.value.length??M;return{charsToReplace:Math.max(0,M-A),trailingOffset:Math.max(0,D-M)}}function Hz(N,F){if(F.length<bZ)return 0;let A=I3(N,F.length),M=Math.min(A.length,F.length);for(let D=M;D>=bZ;D--)if(A.endsWith(F.slice(0,D)))return D;return 0}function _z(N){switch(N){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 Bz(N){return N.replaceAll(kZ,"")}function I3(N,F=Sz){let{anchor:A,focus:M}=N.selection;if(A.regionId!==M.regionId||A.offset!==M.offset)return"";let D=N.documentIndex.regionIndex.get(M.regionId);if(!D)return"";return D.text.slice(Math.max(0,M.offset-F),M.offset)}function mZ(N,F){let A=Bz(N);return A.startsWith(F)?A.slice(F.length):A}function fF(N,F){let A=I3(F),M=A.length>0?A:kZ;N.value=M,N.setSelectionRange(M.length,M.length),N.scrollLeft=N.scrollWidth}function Pz(N,F){let M=mZ(F,I3(N)).replace(/\r\n/g,`
|
|
11
|
+
`)}var m4=null,mY;function kY(){if(m4===null)m4=new Intl.Segmenter(mY,{granularity:"word"});return m4}var gY=/\p{Script=Arabic}/u,E2=/\p{M}/u,g4=/\p{Nd}/u;function kM(N){return gY.test(N)}function gM(N){return N>=19968&&N<=40959||N>=13312&&N<=19903||N>=131072&&N<=173791||N>=173824&&N<=177983||N>=177984&&N<=178207||N>=178208&&N<=183983||N>=183984&&N<=191471||N>=191472&&N<=192093||N>=194560&&N<=195103||N>=196608&&N<=201551||N>=201552&&N<=205743||N>=205744&&N<=210041||N>=63744&&N<=64255||N>=12288&&N<=12351||N>=12352&&N<=12447||N>=12448&&N<=12543||N>=12592&&N<=12687||N>=44032&&N<=55215||N>=65280&&N<=65519}function c0(N){for(let F=0;F<N.length;F++){let A=N.charCodeAt(F);if(A<12288)continue;if(A>=55296&&A<=56319&&F+1<N.length){let M=N.charCodeAt(F+1);if(M>=56320&&M<=57343){let D=(A-55296<<10)+(M-56320)+65536;if(gM(D))return!0;F++;continue}}if(gM(A))return!0}return!1}function hY(N){let F=jN(N);return F!==null&&(D6.has(F)||b1.has(F))}var IY=new Set([" "," ","","\uFEFF"]),pY=new Set(["-","‐","–","—"]);function xY(N){let F=jN(N);return F!==null&&IY.has(F)}function lY(N){let F=jN(N);return F!==null&&pY.has(F)}function h4(N,F){if(xY(N))return!1;if(!F)return!0;if(hY(N))return!1;if(lY(N))return!1;return!0}var D6=new Set([",",".","!",":",";","?","、","。","・",")","〕","〉","》","」","』","】","〗","〙","〛","ー","々","〻","ゝ","ゞ","ヽ","ヾ"]),CN=new Set(['"',"(","[","{","¡","¿","“","‘","‚","„","«","‹","⸘","(","〔","〈","《","「","『","【","〖","〘","〚"]),I4=new Set(["'","’"]),b1=new Set([".",",","!","?",":",";","،","؛","؟","।","॥","၊","။","၌","၍","၏",")","]","}","%",'"',"”","’","»","›","…"]),dY=new Set([":",".","،","؛"]),aY=new Set(["၏"]),rY=new Set(["”","’","»","›","」","』","】","》","〉","〕",")"]);function cY(N){if(p4(N))return!0;let F=!1;for(let A of N){if(b1.has(A)||$6(A)){F=!0;continue}if(F&&E2.test(A))continue;return!1}return F}function sY(N){for(let F of N)if(!D6.has(F)&&!b1.has(F))return!1;return N.length>0}function iY(N){if(p4(N))return!0;for(let F of N)if(!CN.has(F)&&!I4.has(F)&&!E2.test(F)&&!$6(F))return!1;return N.length>0}function p4(N){let F=!1;for(let A of N){if(A==="\\"||E2.test(A))continue;if(CN.has(A)||b1.has(A)||I4.has(A)){F=!0;continue}return!1}return F}function E6(N,F){let A=F-1;if(A<=0)return Math.max(A,0);let M=N.charCodeAt(A);if(M<56320||M>57343)return A;let D=A-1;if(D<0)return A;let E=N.charCodeAt(D);return E>=55296&&E<=56319?D:A}function jN(N){if(N.length===0)return null;let F=E6(N,N.length);return N.slice(F)}function oY(N){for(let F of N)if(!E2.test(F))return F;return null}function nY(N){for(let F=N.length;F>0;){let A=E6(N,F),M=N.slice(A,F);if(!E2.test(M))return M;F=A}return null}var tY=[36,37,43,43,92,92,162,165,176,177,1423,1423,1545,1547,1642,1642,2046,2047,2546,2547,2553,2555,2801,2801,3065,3065,3449,3449,3647,3647,6107,6107,8240,8247,8279,8279,8352,8399,8451,8451,8457,8457,8470,8470,8722,8723,43064,43064,65020,65020,65129,65130,65284,65285,65504,65505,65509,65510,73693,73696,123647,123647,126124,126124,126128,126128];function eY(N,F){for(let A=0;A<F.length;A+=2)if(N>=F[A]&&N<=F[A+1])return!0;return!1}function $6(N){let F=N.codePointAt(0);return F!==void 0&&eY(F,tY)}function NX(N){let F=nY(N);return F!==null&&$6(F)}function FX(N){let F=oY(N);return F!==null&&g4.test(F)}function AX(N){let F=Array.from(N),A=F.length;while(A>0){let M=F[A-1];if(E2.test(M)){A--;continue}if(CN.has(M)||I4.has(M)){A--;continue}break}if(A<=0||A===F.length)return null;return{head:F.slice(0,A).join(""),tail:F.slice(A).join("")}}function MX(N,F,A){return A==="text"&&!F&&N.length===1&&N!=="-"&&N!=="—"?N:null}function hM(N,F,A,M){let D=F[M],E=N[M];if(D==null)return E;let $=A[M];if(E.length===$)return E;let y=D.repeat($);return N[M]=y,y}function IM(N,F){return N&&F!==null&&dY.has(F)}function DX(N){let F=jN(N);return F!==null&&aY.has(F)}function EX(N){if(N.length<2||N[0]!==" ")return null;let F=N.slice(1);if(/^\p{M}+$/u.test(F))return{space:" ",marks:F};return null}function y6(N){let F=N.length;while(F>0){let A=E6(N,F),M=N.slice(A,F);if(rY.has(M))return!0;if(!b1.has(M))return!1;F=A}return!1}function $X(N,F){if(F.preserveOrdinarySpaces||F.preserveHardBreaks){if(N===" ")return"preserved-space";if(N==="\t")return"tab";if(F.preserveHardBreaks&&N===`
|
|
12
|
+
`)return"hard-break"}if(N===" ")return"space";if(N===" "||N===" "||N===""||N==="\uFEFF")return"glue";if(N==="")return"zero-width-break";if(N==="")return"soft-hyphen";return"text"}var yX=/[\x20\t\n\xA0\xAD\u200B\u202F\u2060\uFEFF]/;function t0(N){return N.length===1?N[0]:N.join("")}function ZX(N,F){let A=[];for(let M=N.length-1;M>=0;M--)A.push(N[M]);return A.push(F),t0(A)}function YX(N,F,A,M){if(!yX.test(N))return[{text:N,isWordLike:F,kind:"text",start:A}];let D=[],E=null,$=[],y=A,Z=!1,Y=0;for(let X of N){let Q=$X(X,M),S=Q==="text"&&F;if(E!==null&&Q===E&&S===Z){$.push(X),Y+=X.length;continue}if(E!==null)D.push({text:t0($),isWordLike:Z,kind:E,start:y});E=Q,$=[X],y=A+Y,Z=S,Y+=X.length}if(E!==null)D.push({text:t0($),isWordLike:Z,kind:E,start:y});return D}function k4(N){return N==="space"||N==="preserved-space"||N==="zero-width-break"||N==="hard-break"}var XX=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function QX(N,F){let A=N.texts[F];if(A.startsWith("www."))return!0;return XX.test(A)&&F+1<N.len&&N.kinds[F+1]==="text"&&N.texts[F+1]==="//"}function SX(N){return N.includes("?")&&(N.includes("://")||N.startsWith("www."))}function JX(N){let F=N.texts.slice(),A=N.isWordLike.slice(),M=N.kinds.slice(),D=N.starts.slice();for(let $=0;$<N.len;$++){if(M[$]!=="text"||!QX(N,$))continue;let y=[F[$]],Z=$+1;while(Z<N.len&&!k4(M[Z])){y.push(F[Z]),A[$]=!0;let Y=F[Z].includes("?");if(M[Z]="text",F[Z]="",Z++,Y)break}F[$]=t0(y)}let E=0;for(let $=0;$<F.length;$++){let y=F[$];if(y.length===0)continue;if(E!==$)F[E]=y,A[E]=A[$],M[E]=M[$],D[E]=D[$];E++}return F.length=E,A.length=E,M.length=E,D.length=E,{len:E,texts:F,isWordLike:A,kinds:M,starts:D}}function VX(N){let F=[],A=[],M=[],D=[];for(let E=0;E<N.len;E++){let $=N.texts[E];if(F.push($),A.push(N.isWordLike[E]),M.push(N.kinds[E]),D.push(N.starts[E]),!SX($))continue;let y=E+1;if(y>=N.len||k4(N.kinds[y]))continue;let Z=[],Y=N.starts[y],X=y;while(X<N.len&&!k4(N.kinds[X]))Z.push(N.texts[X]),X++;if(Z.length>0)F.push(t0(Z)),A.push(!0),M.push("text"),D.push(Y),E=X-1}return{len:F.length,texts:F,isWordLike:A,kinds:M,starts:D}}var qX=new Set([":","-","/","×",",",".","+","–","—"]),UX=new Set([".",",",":",";"]);function pM(N){for(let F=N.length;F>0;){let A=E6(N,F),M=N.slice(A,F);if(E2.test(M)){F=A;continue}return UX.has(M)||$6(M)}return!1}function KX(N,F){return F&&!c0(N)}function xM(N){for(let F of N)if(g4.test(F))return!0;return!1}function TN(N){if(N.length===0)return!1;for(let F of N){if(g4.test(F)||qX.has(F))continue;return!1}return!0}function zX(N){let F=[],A=[],M=[],D=[];for(let E=0;E<N.len;E++){let $=N.texts[E],y=N.kinds[E];if(y==="text"&&TN($)&&xM($)){let Z=[$],Y=E+1;while(Y<N.len&&N.kinds[Y]==="text"&&TN(N.texts[Y]))Z.push(N.texts[Y]),Y++;F.push(t0(Z)),A.push(!0),M.push("text"),D.push(N.starts[E]),E=Y-1;continue}F.push($),A.push(N.isWordLike[E]),M.push(y),D.push(N.starts[E])}return{len:F.length,texts:F,isWordLike:A,kinds:M,starts:D}}function GX(N){let F=[],A=[],M=[],D=[];for(let E=0;E<N.len;E++){let $=N.texts[E],y=N.kinds[E],Z=N.isWordLike[E];if(y==="text"&&pM($)&&(Z||NX($))&&!c0($)){let Y=[$],X=!0,Q=E+1;while(X&&Q<N.len&&N.kinds[Q]==="text"&&KX(N.texts[Q],N.isWordLike[Q])){let S=N.texts[Q];Y.push(S),X=pM(S),Q++}F.push(t0(Y)),A.push(!0),M.push("text"),D.push(N.starts[E]),E=Q-1;continue}F.push($),A.push(Z),M.push(y),D.push(N.starts[E])}return{len:F.length,texts:F,isWordLike:A,kinds:M,starts:D}}function HX(N){let F=[],A=[],M=[],D=[];for(let E=0;E<N.len;E++){let $=N.texts[E];if(N.kinds[E]==="text"&&$.includes("-")){let y=$.split("-"),Z=y.length>1;for(let Y=0;Y<y.length;Y++){let X=y[Y];if(!Z)break;if(X.length===0||!xM(X)||!TN(X))Z=!1}if(Z){let Y=0;for(let X=0;X<y.length;X++){let Q=y[X],S=X<y.length-1?`${Q}-`:Q;F.push(S),A.push(!0),M.push("text"),D.push(N.starts[E]+Y),Y+=S.length}continue}}F.push($),A.push(N.isWordLike[E]),M.push(N.kinds[E]),D.push(N.starts[E])}return{len:F.length,texts:F,isWordLike:A,kinds:M,starts:D}}function _X(N){let F=[],A=[],M=[],D=[],E=0;while(E<N.len){let $=[N.texts[E]],y=N.isWordLike[E],Z=N.kinds[E],Y=N.starts[E];if(Z==="glue"){let X=[$[0]],Q=Y;E++;while(E<N.len&&N.kinds[E]==="glue")X.push(N.texts[E]),E++;let S=t0(X);if(E<N.len&&N.kinds[E]==="text")$[0]=S,$.push(N.texts[E]),y=N.isWordLike[E],Z="text",Y=Q,E++;else{F.push(S),A.push(!1),M.push("glue"),D.push(Q);continue}}else E++;if(Z==="text")while(E<N.len&&N.kinds[E]==="glue"){let X=[];while(E<N.len&&N.kinds[E]==="glue")X.push(N.texts[E]),E++;let Q=t0(X);if(E<N.len&&N.kinds[E]==="text"){$.push(Q,N.texts[E]),y=y||N.isWordLike[E],E++;continue}$.push(Q)}F.push(t0($)),A.push(y),M.push(Z),D.push(Y)}return{len:F.length,texts:F,isWordLike:A,kinds:M,starts:D}}function BX(N){let F=N.texts.slice(),A=N.isWordLike.slice(),M=N.kinds.slice(),D=N.starts.slice();for(let E=0;E<F.length-1;E++){if(M[E]!=="text"||M[E+1]!=="text")continue;if(!c0(F[E])||!c0(F[E+1]))continue;let $=AX(F[E]);if($===null)continue;F[E]=$.head,F[E+1]=$.tail+F[E+1],D[E+1]=D[E]+$.head.length}return{len:F.length,texts:F,isWordLike:A,kinds:M,starts:D}}function PX(N,F,A){let M=kY(),D=0,E=[],$=[],y=[],Z=[],Y=[],X=[],Q=[],S=[],J=[],V=[],K=[],q=[];for(let _ of M.segment(N))for(let O of YX(_.segment,_.isWordLike??!1,_.index,A)){let R=function(){if(X[P]!==null)$[P]=[hM(E,X,Q,P)],X[P]=null;$[P].push(O.text),y[P]=y[P]||O.isWordLike,S[P]=S[P]||L,J[P]=J[P]||W,V[P]=g,K[P]=j,q[P]=IM(J[P],v)},w=O.kind==="text",b=MX(O.text,O.isWordLike,O.kind),L=c0(O.text),W=kM(O.text),v=jN(O.text),g=y6(O.text),j=DX(O.text),P=D-1;if(F.carryCJKAfterClosingQuote&&w&&D>0&&Z[P]==="text"&&L&&S[P]&&V[P])R();else if(w&&D>0&&Z[P]==="text"&&sY(O.text)&&S[P])R();else if(w&&D>0&&Z[P]==="text"&&K[P])R();else if(w&&D>0&&Z[P]==="text"&&O.isWordLike&&W&&q[P])R(),y[P]=!0;else if(b!==null&&D>0&&Z[P]==="text"&&X[P]===b)Q[P]=(Q[P]??1)+1;else if(w&&!O.isWordLike&&D>0&&Z[P]==="text"&&!S[P]&&(cY(O.text)||O.text==="-"&&y[P]))R();else E[D]=O.text,$[D]=[O.text],y[D]=O.isWordLike,Z[D]=O.kind,Y[D]=O.start,X[D]=b,Q[D]=b===null?0:1,S[D]=L,J[D]=W,V[D]=g,K[D]=j,q[D]=IM(W,v),D++}for(let _=0;_<D;_++){if(X[_]!==null){E[_]=hM(E,X,Q,_);continue}E[_]=t0($[_])}for(let _=1;_<D;_++)if(Z[_]==="text"&&!y[_]&&p4(E[_])&&Z[_-1]==="text"&&!S[_-1])E[_-1]+=E[_],y[_-1]=y[_-1]||y[_],E[_]="";let U=Array.from({length:D},()=>null),z=-1;for(let _=D-1;_>=0;_--){let O=E[_];if(O.length===0)continue;if(Z[_]==="text"&&!y[_]&&z>=0&&Z[z]==="text"&&(iY(O)||O==="-"&&FX(E[z]))){let w=U[z]??[];w.push(O),U[z]=w,Y[z]=Y[_],E[_]="";continue}z=_}for(let _=0;_<D;_++){let O=U[_];if(O==null)continue;E[_]=ZX(O,E[_])}let G=0;for(let _=0;_<D;_++){let O=E[_];if(O.length===0)continue;if(G!==_)E[G]=O,y[G]=y[_],Z[G]=Z[_],Y[G]=Y[_];G++}E.length=G,y.length=G,Z.length=G,Y.length=G;let H=_X({len:G,texts:E,isWordLike:y,kinds:Z,starts:Y}),B=BX(GX(HX(zX(VX(JX(H))))));for(let _=0;_<B.len-1;_++){let O=EX(B.texts[_]);if(O===null)continue;if(B.kinds[_]!=="space"&&B.kinds[_]!=="preserved-space"||B.kinds[_+1]!=="text"||!kM(B.texts[_+1]))continue;B.texts[_]=O.space,B.isWordLike[_]=!1,B.kinds[_]=B.kinds[_]==="preserved-space"?"preserved-space":"space",B.texts[_+1]=O.marks+B.texts[_+1],B.starts[_+1]=B.starts[_]+O.space.length}return B}function WX(N,F){if(N.len===0)return[];if(!F.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:N.len,consumedEndSegmentIndex:N.len}];let A=[],M=0;for(let D=0;D<N.len;D++){if(N.kinds[D]!=="hard-break")continue;A.push({startSegmentIndex:M,endSegmentIndex:D,consumedEndSegmentIndex:D+1}),M=D+1}if(M<N.len)A.push({startSegmentIndex:M,endSegmentIndex:N.len,consumedEndSegmentIndex:N.len});return A}function OX(N,F,A){if(F.len<=1)return F;let M=[],D=[],E=[],$=[],y=-1,Z=!1;function Y(S){M.push(F.texts[S]),D.push(F.isWordLike[S]),E.push("text"),$.push(F.starts[S])}function X(S,J){let V=!1;for(let U=S;U<J;U++)V=V||F.isWordLike[U];let K=F.starts[S],q=J<F.len?F.starts[J]:N.length;M.push(N.slice(K,q)),D.push(V),E.push("text"),$.push(K)}function Q(S){if(y<0)return;if(Z)if(y+1===S)Y(y);else X(y,S);else for(let J=y;J<S;J++)Y(J);y=-1,Z=!1}for(let S=0;S<F.len;S++){let J=F.texts[S],V=F.kinds[S];if(V==="text"){if(y>=0&&!h4(F.texts[S-1],A))Q(S);if(y<0)y=S;Z=Z||c0(J);continue}Q(S),M.push(J),D.push(F.isWordLike[S]),E.push(V),$.push(F.starts[S])}return Q(F.len),{len:M.length,texts:M,isWordLike:D,kinds:E,starts:$}}function lM(N,F,A="normal",M="normal"){let D=fY(A),E=D.mode==="pre-wrap"?vY(N):uY(N);if(E.length===0)return{normalized:E,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let $=PX(E,F,D),y=M==="keep-all"?OX(E,$,F.breakKeepAllAfterPunctuation):$;return{normalized:E,chunks:WX(y,D),...y}}var g2=null,dM=new Map,h2=null,wX=96,LX=/\p{Emoji_Presentation}/u,TX=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,x4=null,aM=new Map;function l4(){if(g2!==null)return g2;if(typeof OffscreenCanvas<"u")return g2=new OffscreenCanvas(1,1).getContext("2d"),g2;if(typeof document<"u")return g2=document.createElement("canvas").getContext("2d"),g2;throw Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function CX(N){let F=dM.get(N);if(!F)F=new Map,dM.set(N,F);return F}function U1(N,F){let A=F.get(N);if(A===void 0)A={width:l4().measureText(N).width,containsCJK:c0(N)},F.set(N,A);return A}function u1(){if(h2!==null)return h2;if(typeof navigator>"u")return h2={lineFitEpsilon:0.005,carryCJKAfterClosingQuote:!1,breakKeepAllAfterPunctuation:!0,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},h2;let N=navigator.userAgent,A=navigator.vendor==="Apple Computer, Inc."&&N.includes("Safari/")&&!N.includes("Chrome/")&&!N.includes("Chromium/")&&!N.includes("CriOS/")&&!N.includes("FxiOS/")&&!N.includes("EdgiOS/"),M=N.includes("Chrome/")||N.includes("Chromium/")||N.includes("CriOS/")||N.includes("Edg/");return h2={lineFitEpsilon:A?0.015625:0.005,carryCJKAfterClosingQuote:M,breakKeepAllAfterPunctuation:!A,preferPrefixWidthsForBreakableRuns:A,preferEarlySoftHyphenBreak:A},h2}function jX(N){let F=N.match(/(\d+(?:\.\d+)?)\s*px/);return F?parseFloat(F[1]):16}function rM(){if(x4===null)x4=new Intl.Segmenter(void 0,{granularity:"grapheme"});return x4}function RX(N){return LX.test(N)||N.includes("️")}function cM(N){return TX.test(N)}function bX(N,F){let A=aM.get(N);if(A!==void 0)return A;let M=l4();M.font=N;let D=M.measureText("\uD83D\uDE00").width;if(A=0,D>F+0.5&&typeof document<"u"&&document.body!==null){let E=document.createElement("span");E.style.font=N,E.style.display="inline-block",E.style.visibility="hidden",E.style.position="absolute",E.textContent="\uD83D\uDE00",document.body.appendChild(E);let $=E.getBoundingClientRect().width;if(document.body.removeChild(E),D-$>0.5)A=D-$}return aM.set(N,A),A}function fX(N){let F=0,A=rM();for(let M of A.segment(N))if(RX(M.segment))F++;return F}function uX(N,F){if(F.emojiCount===void 0)F.emojiCount=fX(N);return F.emojiCount}function f1(N,F,A){if(A===0)return F.width;return F.width-uX(N,F)*A}function sM(N,F,A,M,D){if(F.breakableFitAdvances!==void 0&&F.breakableFitMode===D)return F.breakableFitAdvances;F.breakableFitMode=D;let E=rM(),$=[];for(let X of E.segment(N))$.push(X.segment);if($.length<=1)return F.breakableFitAdvances=null,F.breakableFitAdvances;if(D==="sum-graphemes"){let X=[];for(let Q of $){let S=U1(Q,A);X.push(f1(Q,S,M))}return F.breakableFitAdvances=X,F.breakableFitAdvances}if(D==="pair-context"||$.length>wX){let X=[],Q=null,S=0;for(let J of $){let V=U1(J,A),K=f1(J,V,M);if(Q===null)X.push(K);else{let q=Q+J,U=U1(q,A);X.push(f1(q,U,M)-S)}Q=J,S=K}return F.breakableFitAdvances=X,F.breakableFitAdvances}let y=[],Z="",Y=0;for(let X of $){Z+=X;let Q=U1(Z,A),S=f1(Z,Q,M);y.push(S-Y),Y=S}return F.breakableFitAdvances=y,F.breakableFitAdvances}function iM(N,F){let A=l4();A.font=N;let M=CX(N),D=jX(N),E=F?bX(N,D):0;return{cache:M,fontSize:D,emojiCorrection:E}}function vX(N){return N==="space"||N==="zero-width-break"||N==="soft-hyphen"}function X6(N){return N==="space"||N==="preserved-space"||N==="tab"||N==="zero-width-break"||N==="soft-hyphen"}function d4(N,F,A=N.widths.length){while(F<A){let M=N.kinds[F];if(!vX(M))break;F++}return F}function oM(N,F){if(F<=0)return 0;let A=N%F;if(Math.abs(A)<=0.000001)return F;return F-A}function nM(N,F,A){return N.letterSpacing!==0&&F&&N.spacingGraphemeCounts[A]>0?N.letterSpacing:0}function a4(N,F){return F===0?0:N+F}function mX(N,F){return N.letterSpacing!==0&&N.spacingGraphemeCounts[F]>0?N.letterSpacing:0}function tM(N,F,A,M,D){let E=F==="tab"?D+mX(N,A):N.lineEndFitAdvances[A];return a4(M,E)}function Z6(N,F,A,M){let D=F==="tab"?0:N.lineEndFitAdvances[A];return a4(M,D)}function Y6(N,F,A,M,D){let E=F==="tab"?D:N.lineEndPaintAdvances[A];return a4(M,E)}function eM(N,F,A){return N.letterSpacing!==0&&F?A+N.letterSpacing:A}function ND(N,F){return N.letterSpacing===0?F:F+N.letterSpacing}function kX(N,F,A,M,D){if(N.letterSpacing===0)return 0;if(D>0)return N.spacingGraphemeCounts[M]>0?N.letterSpacing:0;for(let E=M-1;E>=F;E--){let $=N.kinds[E];if($==="space"||$==="zero-width-break"||$==="hard-break")continue;if($==="soft-hyphen"){if(E===M-1)return 0;continue}if(E===F&&A>0)return N.letterSpacing;return N.spacingGraphemeCounts[E]>0?N.letterSpacing:0}return 0}function FD(N,F,A,M,D,E){return F+kX(N,A,M,D,E)}function gX(N,F){let A=0,M=N.chunks.length;while(A<M){let D=Math.floor((A+M)/2);if(F<N.chunks[D].consumedEndSegmentIndex)M=D;else A=D+1}return A<N.chunks.length?A:-1}function hX(N,F,A){let M=A.segmentIndex;if(A.graphemeIndex>0)return F;let D=N.chunks[F];if(D.startSegmentIndex===D.endSegmentIndex&&M===D.startSegmentIndex)return A.segmentIndex=M,A.graphemeIndex=0,F;if(M<D.startSegmentIndex)M=D.startSegmentIndex;if(M=d4(N,M,D.endSegmentIndex),M<D.endSegmentIndex)return A.segmentIndex=M,A.graphemeIndex=0,F;if(D.consumedEndSegmentIndex>=N.widths.length)return-1;return A.segmentIndex=D.consumedEndSegmentIndex,A.graphemeIndex=0,F+1}function AD(N,F){if(F.segmentIndex>=N.widths.length)return-1;let A=gX(N,F.segmentIndex);if(A<0)return-1;return hX(N,A,F)}function IX(N,F,A){let{widths:M,kinds:D,breakableFitAdvances:E}=N;if(M.length===0)return 0;let y=u1().lineFitEpsilon,Z=F+y,Y=0,X=0,Q=!1,S=0,J=0,V=0,K=0,q=-1,U=0;function z(){q=-1,U=0}function G(b=V,L=K,W=X){Y++,A?.(W,S,J,b,L),X=0,Q=!1,z()}function H(b,L){Q=!0,S=b,J=0,V=b+1,K=0,X=L}function B(b,L,W){Q=!0,S=b,J=L,V=b,K=L+1,X=W}function _(b,L){if(!Q){H(b,L);return}X+=L,V=b+1,K=0}function O(b,L){let W=E[b];for(let v=L;v<W.length;v++){let g=W[v];if(!Q)B(b,v,g);else if(X+g>Z)G(),B(b,v,g);else X+=g,V=b,K=v+1}if(Q&&V===b&&K===W.length)V=b+1,K=0}let w=0;while(w<M.length){if(!Q){if(w=d4(N,w),w>=M.length)break}let b=M[w],L=D[w],W=X6(L);if(!Q){if(b>Z&&E[w]!==null)O(w,0);else H(w,b);if(W)q=w+1,U=X-b;w++;continue}if(X+b>Z){if(W){_(w,b),G(w+1,0,X-b),w++;continue}if(q>=0){if(V>q||V===q&&K>0){G();continue}G(q,0,U);continue}if(b>Z&&E[w]!==null){G(),O(w,0),w++;continue}G();continue}if(_(w,b),W)q=w+1,U=X-b;w++}if(Q)G();return Y}function r4(N,F,A){if(N.simpleLineWalkFastPath)return IX(N,F,A);let{widths:M,kinds:D,breakableFitAdvances:E,discretionaryHyphenWidth:$,chunks:y}=N;if(M.length===0||y.length===0)return 0;let Z=u1(),Y=Z.lineFitEpsilon,X=F+Y,Q=0,S=0,J=!1,V=0,K=0,q=0,U=0,z=-1,G=0,H=0,B=null;function _(){z=-1,G=0,H=0,B=null}function O(){return B==="soft-hyphen"&&z===q&&U===0?H:S}function w(P=q,R=U,f){if(Q++,A!==void 0)A(FD(N,f??O(),V,K,P,R),V,K,P,R);S=0,J=!1,_()}function b(P,R){J=!0,V=P,K=0,q=P+1,U=0,S=R}function L(P,R,f){J=!0,V=P,K=R,q=P,U=R+1,S=f}function W(P,R){if(!J){b(P,R);return}S+=R,q=P+1,U=0}function v(P,R,f,m,x,r){if(!R)return;let i=Z6(N,P,f,x),B0=Y6(N,P,f,x,m);z=f+1,G=S-r+i,H=S-r+B0,B=P}function g(P,R){let f=E[P];for(let m=R;m<f.length;m++){let x=f[m];if(!J)L(P,m,x);else{let r=eM(N,!0,x),i=S+r;if(ND(N,i)>X)w(),L(P,m,x);else S=i,q=P,U=m+1}}if(J&&q===P&&U===f.length)q=P+1,U=0}function j(P){Q++,A?.(0,P.startSegmentIndex,0,P.consumedEndSegmentIndex,0),_()}for(let P=0;P<y.length;P++){let R=y[P];if(R.startSegmentIndex===R.endSegmentIndex){j(R);continue}J=!1,S=0,V=R.startSegmentIndex,K=0,q=R.startSegmentIndex,U=0,_();let f=R.startSegmentIndex;while(f<R.endSegmentIndex){if(!J){if(f=d4(N,f,R.endSegmentIndex),f>=R.endSegmentIndex)break}let m=D[f],x=X6(m),r=nM(N,J,f),i=m==="tab"?oM(S+r,N.tabStopAdvance):M[f],B0=r+i,Q0=tM(N,m,f,r,i);if(m==="soft-hyphen"){if(J)q=f+1,U=0,z=f+1,G=S+$,H=S+$,B=m;f++;continue}if(!J){if(Q0>X&&E[f]!==null)g(f,0);else b(f,i);v(m,x,f,i,r,B0),f++;continue}if(S+Q0>X){let l=S+Z6(N,m,f,r),o=S+Y6(N,m,f,r,i);if(B==="soft-hyphen"&&Z.preferEarlySoftHyphenBreak&&G<=X){w(z,0,H);continue}if(x&&l<=X){W(f,B0),w(f+1,0,o),f++;continue}if(z>=0&&G<=X){if(q>z||q===z&&U>0){w();continue}let a=z;w(a,0,H),f=a;continue}if(Q0>X&&E[f]!==null){w(),g(f,0),f++;continue}w();continue}W(f,B0),v(m,x,f,i,r,B0),f++}if(J){let m=z===R.consumedEndSegmentIndex?H:S;w(R.consumedEndSegmentIndex,0,m)}}return Q}function pX(N,F,A,M){let D=N.chunks[A];if(D.startSegmentIndex===D.endSegmentIndex)return F.segmentIndex=D.consumedEndSegmentIndex,F.graphemeIndex=0,0;let{widths:E,kinds:$,breakableFitAdvances:y,discretionaryHyphenWidth:Z}=N,Y=u1(),X=Y.lineFitEpsilon,Q=M+X,S=F.segmentIndex,J=F.graphemeIndex,V=0,K=!1,q=F.segmentIndex,U=F.graphemeIndex,z=-1,G=0,H=0,B=null;function _(){return B==="soft-hyphen"&&z===q&&U===0?H:V}function O(j=q,P=U,R=_()){if(!K)return null;return F.segmentIndex=j,F.graphemeIndex=P,FD(N,R,S,J,j,P)}function w(j,P){K=!0,q=j+1,U=0,V=P}function b(j,P,R){K=!0,q=j,U=P+1,V=R}function L(j,P){if(!K){w(j,P);return}V+=P,q=j+1,U=0}function W(j,P,R,f,m,x){if(!P)return;let r=Z6(N,j,R,m),i=Y6(N,j,R,m,f);z=R+1,G=V-x+r,H=V-x+i,B=j}function v(j,P){let R=y[j];for(let f=P;f<R.length;f++){let m=R[f];if(!K)b(j,f,m);else{let x=eM(N,!0,m),r=V+x;if(ND(N,r)>Q)return O();V=r,q=j,U=f+1}}if(K&&q===j&&U===R.length)q=j+1,U=0;return null}function g(){if(B!=="soft-hyphen"||z<0)return null;if(G<=Q)return O(z,0,H);return null}for(let j=F.segmentIndex;j<D.endSegmentIndex;j++){let P=$[j],R=X6(P),f=j===F.segmentIndex?F.graphemeIndex:0,m=nM(N,K,j),x=P==="tab"?oM(V+m,N.tabStopAdvance):E[j],r=m+x,i=tM(N,P,j,m,x);if(P==="soft-hyphen"&&f===0){if(K)q=j+1,U=0,z=j+1,G=V+Z,H=V+Z,B=P;continue}if(!K){if(f>0){let Q0=v(j,f);if(Q0!==null)return Q0}else if(i>Q&&y[j]!==null){let Q0=v(j,0);if(Q0!==null)return Q0}else w(j,x);W(P,R,j,x,m,r);continue}if(V+i>Q){let Q0=V+Z6(N,P,j,m),u=V+Y6(N,P,j,m,x);if(B==="soft-hyphen"&&Y.preferEarlySoftHyphenBreak&&G<=Q)return O(z,0,H);let l=g();if(l!==null)return l;if(R&&Q0<=Q)return L(j,r),O(j+1,0,u);if(z>=0&&G<=Q){if(q>z||q===z&&U>0)return O();return O(z,0,H)}if(i>Q&&y[j]!==null){let o=O();if(o!==null)return o;let a=v(j,0);if(a!==null)return a}return O()}L(j,r),W(P,R,j,x,m,r)}if(z===D.consumedEndSegmentIndex&&U===0)return O(D.consumedEndSegmentIndex,0,H);return O(D.consumedEndSegmentIndex,0,V)}function xX(N,F,A){let{widths:M,kinds:D,breakableFitAdvances:E}=N,y=u1().lineFitEpsilon,Z=A+y,Y=0,X=!1,Q=F.segmentIndex,S=F.graphemeIndex,J=-1,V=0;for(let K=F.segmentIndex;K<M.length;K++){let q=D[K],U=X6(q),z=K===F.segmentIndex?F.graphemeIndex:0,G=E[K],H=M[K];if(!X){if(z>0||H>Z&&G!==null){let B=G,_=B[z];X=!0,Y=_,Q=K,S=z+1;for(let O=z+1;O<B.length;O++){let w=B[O];if(Y+w>Z)return F.segmentIndex=Q,F.graphemeIndex=S,Y;Y+=w,Q=K,S=O+1}if(Q===K&&S===B.length)Q=K+1,S=0}else X=!0,Y=H,Q=K+1,S=0;if(U)J=K+1,V=Y-H;continue}if(Y+H>Z){if(U)return F.segmentIndex=K+1,F.graphemeIndex=0,Y;if(J>=0){if(Q>J||Q===J&&S>0)return F.segmentIndex=Q,F.graphemeIndex=S,Y;return F.segmentIndex=J,F.graphemeIndex=0,V}return F.segmentIndex=Q,F.graphemeIndex=S,Y}if(Y+=H,Q=K+1,S=0,U)J=K+1,V=Y-H}if(!X)return null;return F.segmentIndex=Q,F.graphemeIndex=S,Y}function MD(N,F,A,M){if(N.simpleLineWalkFastPath)return xX(N,F,M);return pX(N,F,A,M)}function Q6(N,F,A){let M=AD(N,F);if(M<0)return null;return MD(N,F,M,A)}var c4=null;function ED(){if(c4===null)c4=new Intl.Segmenter(void 0,{granularity:"grapheme"});return c4}function lX(N){if(N)return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],letterSpacing:0,spacingGraphemeCounts:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]};return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],letterSpacing:0,spacingGraphemeCounts:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[]}}function dX(N,F){let A=[],M=[],D=0,E=!1,$=!1,y=!1;function Z(){if(M.length===0)return;A.push({text:M.length===1?M[0]:M.join(""),start:D}),M=[],E=!1,$=!1,y=!1}function Y(Q,S,J){M=[Q],D=S,E=J,$=y6(Q),y=CN.has(Q)}function X(Q,S){M.push(Q),E=E||S;let J=y6(Q);if(Q.length===1&&b1.has(Q))$=$||J;else $=J;y=!1}for(let Q of ED().segment(N)){let S=Q.segment,J=c0(S);if(M.length===0){Y(S,Q.index,J);continue}if(y||D6.has(S)||b1.has(S)||F.carryCJKAfterClosingQuote&&J&&$){X(S,J);continue}if(!E&&!J){X(S,J);continue}Z(),Y(S,Q.index,J)}return Z(),A}function aX(N,F,A){if(F.length<=1)return F;let M=[],D=-1,E=!1;function $(Z,Y){let X=F[Z].start,Q=Y<F.length?F[Y].start:N.length;M.push({text:N.slice(X,Q),start:X})}function y(Z){if(D<0)return;if(E)if(D+1===Z)M.push(F[D]);else $(D,Z);else for(let Y=D;Y<Z;Y++)M.push(F[Y]);D=-1,E=!1}for(let Z=0;Z<F.length;Z++){let Y=F[Z];if(D>=0&&!h4(F[Z-1].text,A))y(Z);if(D<0)D=Z;E=E||c0(Y.text)}return y(F.length),M}function DD(N,F){if(F==="zero-width-break"||F==="soft-hyphen"||F==="hard-break")return 0;if(F==="tab")return 1;let A=0,M=ED();for(let D of M.segment(N))A++;return A}function rX(N,F,A){return F>1?N+(F-1)*A:N}function cX(N,F,A,M,D){let E=u1(),{cache:$,emojiCorrection:y}=iM(F,cM(N.normalized)),Z=f1("-",U1("-",$),y)+(D===0?0:D*2),X=f1(" ",U1(" ",$),y)*8,Q=D!==0;if(N.len===0)return lX(A);let S=[],J=[],V=[],K=[],q=N.chunks.length<=1&&!Q,U=A?[]:null,z=[],G=[],H=A?[]:null,B=Array.from({length:N.len});function _(L,W,v,g,j,P,R,f){if(j!=="text"&&j!=="space"&&j!=="zero-width-break")q=!1;if(S.push(W),J.push(v),V.push(g),K.push(j),U?.push(P),z.push(R),Q)G.push(f);if(H!==null)H.push(L)}function O(L,W,v,g,j){let P=U1(L,$),R=Q?DD(L,W):0,f=rX(f1(L,P,y),R,D),m=W==="space"||W==="preserved-space"||W==="zero-width-break"?0:f,x=m===0?0:m+(R>0?D:0),r=W==="space"||W==="zero-width-break"?0:f;if(j&&g&&L.length>1){let i="sum-graphemes";if(D!==0)i="segment-prefixes";else if(TN(L))i="pair-context";else if(E.preferPrefixWidthsForBreakableRuns)i="segment-prefixes";let B0=sM(L,P,$,y,i);_(L,f,x,r,W,v,B0,R);return}_(L,f,x,r,W,v,null,R)}for(let L=0;L<N.len;L++){B[L]=S.length;let W=N.texts[L],v=N.isWordLike[L],g=N.kinds[L],j=N.starts[L];if(g==="soft-hyphen"){_(W,0,Z,Z,g,j,null,0);continue}if(g==="hard-break"){_(W,0,0,0,g,j,null,0);continue}if(g==="tab"){_(W,0,0,0,g,j,null,Q?DD(W,g):0);continue}let P=U1(W,$);if(g==="text"&&P.containsCJK){let R=dX(W,E),f=M==="keep-all"?aX(W,R,E.breakKeepAllAfterPunctuation):R;for(let m=0;m<f.length;m++){let x=f[m];O(x.text,"text",j+x.start,v,M==="keep-all"||!c0(x.text))}continue}O(W,g,j,v,!0)}let w=sX(N.chunks,B,S.length),b=U===null?null:mM(N.normalized,U);if(H!==null)return{widths:S,lineEndFitAdvances:J,lineEndPaintAdvances:V,kinds:K,simpleLineWalkFastPath:q,segLevels:b,breakableFitAdvances:z,letterSpacing:D,spacingGraphemeCounts:G,discretionaryHyphenWidth:Z,tabStopAdvance:X,chunks:w,segments:H};return{widths:S,lineEndFitAdvances:J,lineEndPaintAdvances:V,kinds:K,simpleLineWalkFastPath:q,segLevels:b,breakableFitAdvances:z,letterSpacing:D,spacingGraphemeCounts:G,discretionaryHyphenWidth:Z,tabStopAdvance:X,chunks:w}}function sX(N,F,A){let M=[];for(let D=0;D<N.length;D++){let E=N[D],$=E.startSegmentIndex<F.length?F[E.startSegmentIndex]:A,y=E.endSegmentIndex<F.length?F[E.endSegmentIndex]:A,Z=E.consumedEndSegmentIndex<F.length?F[E.consumedEndSegmentIndex]:A;M.push({startSegmentIndex:$,endSegmentIndex:y,consumedEndSegmentIndex:Z})}return M}function iX(N,F,A,M){let D=M?.wordBreak??"normal",E=M?.letterSpacing??0,$=lM(N,u1(),M?.whiteSpace,D);return cX($,F,A,D,E)}function I2(N,F,A){return iX(N,F,!0,A)}function $D(N){return N}function oX(N,F,A,M,D){return{width:N,start:{segmentIndex:F,graphemeIndex:A},end:{segmentIndex:M,graphemeIndex:D}}}function yD(N,F,A){if(N.widths.length===0)return 0;return r4($D(N),F,(M,D,E,$,y)=>{A(oX(M,D,E,$,y))})}function s4(N){let F=0;return r4($D(N),Number.POSITIVE_INFINITY,(A)=>{if(A>F)F=A}),F}var nX=/[ \t\n\f\r]+/,ZD=/^[ \t\n\f\r]+/,YD=/[ \t\n\f\r]+$/,XD={segmentIndex:0,graphemeIndex:0},SD={itemIndex:0,segmentIndex:0,graphemeIndex:0};function tX(N){return N}function i4(N){return{segmentIndex:N.segmentIndex,graphemeIndex:N.graphemeIndex}}function QD(N){return N.segmentIndex===0&&N.graphemeIndex===0}function S6(N,F,A){let M=`${N}\x00${F}`,D=A.get(M);if(D!==void 0)return D;let E=F===0?void 0:{letterSpacing:F},$=s4(I2("A A",N,E)),y=s4(I2("AA",N,E)),Z=Math.max(0,$-y);return A.set(M,Z),Z}function eX(N){let F={segmentIndex:0,graphemeIndex:0},A=Q6(N,F,Number.POSITIVE_INFINITY);if(A===null)return null;return{endGraphemeIndex:F.graphemeIndex,endSegmentIndex:F.segmentIndex,width:A}}function NQ(N,F){return N===0&&F>0}function JD(N){let F=[],A=Array.from({length:N.length}),M=new Map,D=0;for(let E=0;E<N.length;E++){let $=N[E],y=$.letterSpacing??0,Z=ZD.test($.text),Y=YD.test($.text),X=$.text.replace(ZD,"").replace(YD,"");if(X.length===0){if(nX.test($.text)&&D===0)D=S6($.font,y,M);continue}let Q=D>0?D:Z?S6($.font,y,M):0,S=I2(X,$.font,y===0?void 0:{letterSpacing:y}),J=eX(S);if(J===null){D=Y?S6($.font,y,M):0;continue}let V={break:$.break??"normal",endGraphemeIndex:J.endGraphemeIndex,endSegmentIndex:J.endSegmentIndex,extraWidth:$.extraWidth??0,gapBefore:Q,naturalWidth:J.width,prepared:S,sourceItemIndex:E};F.push(V),A[E]=V,D=Y?S6($.font,y,M):0}return{items:F,itemsBySourceItemIndex:A}}function FQ(N,F,A,M){if(N.items.length===0||A.itemIndex>=N.items.length)return null;let D=Math.max(1,F),E=0,$=D,y=A.itemIndex;N:while(y<N.items.length){let Z=N.items[y];if(!QD(A)&&A.segmentIndex===Z.endSegmentIndex&&A.graphemeIndex===Z.endGraphemeIndex){y++,A.segmentIndex=0,A.graphemeIndex=0;continue}let Y=E===0?0:Z.gapBefore,X=QD(A);if(Z.break==="never"){if(!X){y++,A.segmentIndex=0,A.graphemeIndex=0;continue}let U=Z.naturalWidth+Z.extraWidth,z=Y+U;if(E>0&&z>$)break N;M?.(Z,Y,U,i4(XD),{segmentIndex:Z.endSegmentIndex,graphemeIndex:Z.endGraphemeIndex}),E+=z,$=Math.max(0,D-E),y++,A.segmentIndex=0,A.graphemeIndex=0;continue}let Q=Y+Z.extraWidth;if(E>0&&Q>=$)break N;if(X){let U=Q+Z.naturalWidth;if(U<=$){M?.(Z,Y,Z.naturalWidth+Z.extraWidth,i4(XD),{segmentIndex:Z.endSegmentIndex,graphemeIndex:Z.endGraphemeIndex}),E+=U,$=Math.max(0,D-E),y++,A.segmentIndex=0,A.graphemeIndex=0;continue}}let S=Math.max(1,$-Q),J={segmentIndex:A.segmentIndex,graphemeIndex:A.graphemeIndex},V=Q6(Z.prepared,J,S);if(V===null){y++,A.segmentIndex=0,A.graphemeIndex=0;continue}if(A.segmentIndex===J.segmentIndex&&A.graphemeIndex===J.graphemeIndex){y++,A.segmentIndex=0,A.graphemeIndex=0;continue}let K=V+Z.extraWidth,q=Y+K;if(E>0&&X&&q>$)break N;if(E>0&&X&&Y>0&&NQ(J.segmentIndex,J.graphemeIndex)){let U={segmentIndex:0,graphemeIndex:0};if(Q6(Z.prepared,U,Math.max(1,D-Z.extraWidth))!==null&&(U.segmentIndex>J.segmentIndex||U.segmentIndex===J.segmentIndex&&U.graphemeIndex>J.graphemeIndex))break N}if(M?.(Z,Y,K,i4(A),{segmentIndex:J.segmentIndex,graphemeIndex:J.graphemeIndex}),E+=q,$=Math.max(0,D-E),J.segmentIndex===Z.endSegmentIndex&&J.graphemeIndex===Z.endGraphemeIndex){y++,A.segmentIndex=0,A.graphemeIndex=0;continue}A.segmentIndex=J.segmentIndex,A.graphemeIndex=J.graphemeIndex;break}if(E===0)return null;return A.itemIndex=y,E}function AQ(N,F,A=SD){let M=tX(N),D={itemIndex:A.itemIndex,segmentIndex:A.segmentIndex,graphemeIndex:A.graphemeIndex},E=[],$=FQ(M,F,D,(y,Z,Y,X,Q)=>{E.push({itemIndex:y.sourceItemIndex,gapBefore:Z,occupiedWidth:Y,start:X,end:Q})});if($===null)return null;return{fragments:E,width:$,end:D}}function VD(N,F,A){let M=0,D=SD;while(!0){let E=AQ(N,F,D);if(E===null)return M;A(E),M++,D=E.end}}var J6;function p2(N){if(N.length===0)return[];let F=EQ();if(!F)return Array.from(N);return Array.from(F.segment(N),(A)=>A.segment)}function MQ(N,F){let A=p2(N.slice(0,F));if(A.length===0)return 0;return F-A.at(-1).length}function DQ(N,F){let A=p2(N.slice(F))[0];return A?F+A.length:N.length}function RN(N,F,A){return A<0?MQ(N,F):DQ(N,F)}function EQ(){if(J6!==void 0)return J6;let N=Intl.Segmenter;return J6=typeof N==="function"?new N(void 0,{granularity:"grapheme"}):null,J6}var qD="15px ui-monospace, SFMono-Regular, Menlo, monospace";function UD(N,F){return K1(N,F,!1)}function K1(N,F,A){let M=A?"15px ui-monospace, SFMono-Regular, Menlo, monospace":N,D=[];if(F.includes("italic"))D.push("italic");if(F.includes("bold"))D.push("700");return D.length>0?`${D.join(" ")} ${M}`:M}function bN(N,F,A){let M=N.image?F.images.get(N.image.url)??null:null,D=N.image?.width??null,E=Math.min(A,D??240),$=Math.max(120,Math.round(E*0.5625));if(!M||M.intrinsicWidth<=0||M.intrinsicHeight<=0)return{height:$,width:E};let y=Math.min(A,D??M.intrinsicWidth),Z=Math.min(1,y/M.intrinsicWidth);return{height:Math.max(48,Math.round(M.intrinsicHeight*Z)),width:Math.max(48,Math.round(M.intrinsicWidth*Z))}}function KD(N,F){if(!N.image)return`${N.kind}:missing-image`;let A=F.images.get(N.image.url);return`${N.kind}:${N.image.url}:${N.image.width??0}:${A?.status??"loading"}:${A?.intrinsicWidth??0}:${A?.intrinsicHeight??0}`}var V6=4;function o4(N,F){return Math.max(18,N.measureText(`@${F.name}`).width+8)}var zD=[{fontSize:32,lineHeight:36},{fontSize:26,lineHeight:32},{fontSize:21,lineHeight:28},{fontSize:21,lineHeight:28},{fontSize:19,lineHeight:26},{fontSize:18,lineHeight:26}],GD='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',$Q=32,n4;function x2(N){if(N?.type==="heading"){let{fontSize:F}=BD(N.depth);return`700 ${F}px ${GD}`}switch(N?.type){case"code":return qD;default:return`16px ${GD}`}}function v1(N,F){if(N?.type==="heading")return BD(N.depth).lineHeight;if(N?.type==="code")return 22;return F}function BD(N){return zD[N-1]??zD.at(-1)}function e4(N){return yQ(N)?N.split(""):p2(N)}function yQ(N){for(let F=0;F<N.length;F+=1)if(N.charCodeAt(F)>127)return!1;return!0}function l2(N,F,A,M,D,E,$){let y=`${U6(F,$)}:${D}:${E}:${A}`,Z=N.measuredLines.get(y);if(Z)return Z;let Y=YQ(N,F,A,M,D,E,$);return WM(N,y,Y)}function q6(N,F,A,M,D,E,$,y){let Z=`${U6(F,y)}:${A}:${M}:${E}:${$}`,Y=N.lineBoundaries.get(Z);if(Y)return Y;let X=WD(),Q=[{left:0,offset:0}],S=0,J=F.inlines.filter((V)=>V.end>A&&V.start<M);for(let V of J){let K=Math.max(A,V.start),q=Math.min(M,V.end),U=F.text.slice(K,q),z=K-A;if(V.kind==="image"){let G=bN(V,y,$).width;S+=G,z+=U.length,Q.push({left:S,offset:z});continue}if(X.font=K1(E,V.marks,V.inlineCode),K6(V)){S+=o4(X,V.mention),z+=U.length,Q.push({left:S,offset:z});continue}for(let G of OQ(N,X,U))S+=G.width,z+=G.length,Q.push({left:S,offset:z})}return OM(N,Z,Q)}function ZQ(N,F,A,M){let D=`${A}::${M}::${F}`,E=N.preparedText.get(D);if(E)return E;let $=I2(F,A,{whiteSpace:M});return PM(N,D,$)}function YQ(N,F,A,M,D,E,$){let y=F.text,Z=GQ(F);if(y.length===0)return[{end:0,height:E,start:0,text:"",width:0}];if(HQ(Z))return QQ(N,F,A,D,E,$);if(Z.hasRichInline)return SQ(F,A,D,E);let Y=ZQ(N,y,A,LQ(M,Z)),X=PD(Y.segments),Q=[];if(yD(Y,D,(S)=>{let J=X(S.start),V=XQ(y,J,X(S.end));Q.push({end:V,height:E,start:J,text:y.slice(J,V),width:S.width})}),Z.hasHardBreak&&y.endsWith(`
|
|
13
|
+
`))Q.push({end:y.length,height:E,start:y.length,text:"",width:0});return Q}function XQ(N,F,A){return A>F&&N[A-1]===`
|
|
14
|
+
`?A-1:A}function QQ(N,F,A,M,D,E){let $=zQ(N,WD(),F,A,M,D,E);if($.length===0)return[{end:0,height:D,start:0,text:"",width:0}];return KQ($,F.text,M,D)}function SQ(N,F,A,M){let{items:D,measurementItems:E}=JQ(N,F);if(D.length===0)return[{end:0,height:M,start:0,text:"",width:0}];let $=JD(D),y=$,Z=[];return VD($,A,(Y)=>{let X=VQ(y,E,Y.fragments);if(!X)return;Z.push({end:X.end,height:M,start:X.start,text:N.text.slice(X.start,X.end),width:Y.width})}),Z.length>0?Z:[{end:0,height:M,start:0,text:"",width:0}]}function JQ(N,F){let A=[],M=[];for(let D of N.inlines){if(D.kind==="mention"&&D.mention){A.push({break:"never",extraWidth:V6*2,font:K1(F,D.marks,D.inlineCode),text:`@${D.mention.name}`}),M.push({leadingTrimLength:0,run:D});continue}A.push({font:K1(F,D.marks,D.inlineCode),text:D.text}),M.push({leadingTrimLength:UQ(D.text),run:D})}return{items:A,measurementItems:M}}function VQ(N,F,A){let M=null,D=null;for(let E of A){let $=HD(N,F,E,"start"),y=HD(N,F,E,"end");if($===null||y===null)continue;M=M===null?$:Math.min(M,$),D=D===null?y:Math.max(D,y)}return M===null||D===null?null:{end:D,start:M}}function HD(N,F,A,M){let D=F[A.itemIndex],E=N.itemsBySourceItemIndex[A.itemIndex];if(!D||!E)return null;let{run:$}=D;if($.kind==="mention")return M==="start"?$.start:$.end;let y=M==="start"?A.start:A.end;return $.start+D.leadingTrimLength+PD(E.prepared.segments)(y)}function PD(N){let F=[],A=new Map,M=0;for(let D of N)F.push(M),M+=D.length;return(D)=>{let E=F[D.segmentIndex]??M;if(D.graphemeIndex===0)return E;let $=A.get(D.segmentIndex);if(!$)$=qQ(N[D.segmentIndex]??""),A.set(D.segmentIndex,$);return E+($[D.graphemeIndex]??0)}}function qQ(N){let F=[0],A=0;for(let M of e4(N))A+=M.length,F.push(A);return F}function UQ(N){return N.match(/^[ \t\n\f\r]+/)?.[0].length??0}function KQ(N,F,A,M){let D=[],E=0;while(E<N.length){let y=N[E].start;if(N[E].text===`
|
|
15
|
+
`){D.push({end:y,height:M,start:y,text:"",width:0}),E+=1;continue}let Z=0,Y=0,X=E,Q=-1,S=M;while(X<N.length){let V=N[X];if(V.text===`
|
|
16
|
+
`)break;let K=Z+V.width;if(K>A&&X>E)break;if(Z=K,S=Math.max(S,V.height),V.breakable)Q=X,Y=Z;X+=1}if(X===N.length||N[X]?.text===`
|
|
17
|
+
`){let V=N[X-1]?.end??y;D.push({end:V,height:S,start:y,text:F.slice(y,V),width:Z}),E=X<N.length&&N[X]?.text===`
|
|
18
|
+
`?X+1:X;continue}if(Q>=E){let V=N[Q].end;D.push({end:V,height:S,start:y,text:F.slice(y,V),width:Y}),E=Q+1;continue}let J=N[Math.max(E,X-1)].end;D.push({end:J,height:S,start:y,text:F.slice(y,J),width:Z}),E=Math.max(E+1,X)}let $=N.at(-1);if($?.text===`
|
|
19
|
+
`)D.push({end:$.end,height:M,start:$.end,text:"",width:0});return D}function zQ(N,F,A,M,D,E,$){let y=[];for(let Z of A.inlines){if(Z.kind==="image"){let X=bN(Z,$,D);y.push({breakable:!0,end:Z.end,height:X.height,start:Z.start,text:Z.text,width:X.width});continue}if(F.font=K1(M,Z.marks,Z.inlineCode),K6(Z)){y.push({breakable:!0,end:Z.end,height:E,start:Z.start,text:Z.text,width:o4(F,Z.mention)});continue}let Y=Z.start;for(let X of e4(Z.text)){let Q=Y,S=Q+X.length;y.push({breakable:/\s/.test(X),end:S,height:E,start:Q,text:X,width:X===`
|
|
20
|
+
`?0:t4(N,F,X)}),Y=S}}return y}function GQ(N){let F=!1,A=!1,M=!1;for(let D of N.inlines){if(D.kind==="image")A=!0;else if(D.kind==="lineBreak")F=!0;if(K6(D)||WQ(D))M=!0}return{hasHardBreak:F,hasImage:A,hasRichInline:M}}function HQ(N){return N.hasImage||N.hasHardBreak&&N.hasRichInline}var _D=new WeakMap;function U6(N,F){let A=_D.get(N.inlines);if(A&&A.path===N.path&&A.text===N.text)return A.identity;let M=[N.path,PQ(N.text),_Q(N,F)].join(":");if(!N.inlines.some((D)=>D.kind==="image"))_D.set(N.inlines,{identity:M,path:N.path,text:N.text});return M}function _Q(N,F){return N.inlines.map((A)=>`${A.start}-${A.end}:${BQ(A,F)}`).join("|")}function BQ(N,F){if(N.kind==="image"&&N.image)return KD(N,F);if(K6(N))return`${N.kind}:${N.mention.userId}:${N.mention.name}`;return`${N.kind}:${N.inlineCode?1:0}:${N.marks.join(",")}:${N.link?.url??""}`}function PQ(N){let F=2166136261;for(let A=0;A<N.length;A+=1)F^=N.charCodeAt(A),F=Math.imul(F,16777619);return(F>>>0).toString(36)}function WQ(N){return N.inlineCode||N.marks.includes("italic")||N.marks.includes("bold")}function K6(N){return Boolean(N.mention)}function WD(){if(n4!==void 0)return n4;let F=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d");if(!F)throw Error("Text measurement requires OffscreenCanvas or a DOM canvas context.");return n4=F,F}function t4(N,F,A){let M=F.font,D=LM(N,M),E=D.get(A);if(E!==void 0)return E;let $=F.measureText(A).width;return D.set(A,$),$}function OQ(N,F,A){let M=e4(A);if(M.length<=$Q){let y=[],Z=0,Y=0;for(let X of M){Z+=X.length;let Q=wQ(F,A,Z);y.push({length:X.length,width:Q-Y}),Y=Q}return y}let D=[],E=null,$=0;for(let y of M){let Z=t4(N,F,y);D.push({length:y.length,width:E===null?Z:t4(N,F,E+y)-$}),E=y,$=Z}return D}function wQ(N,F,A){return N.measureText(F.slice(0,A)).width}function LQ(N,F){return N?.type==="code"||F.hasHardBreak?"pre-wrap":"normal"}var fN=10,d2=8,N5=120;function OD(N,F,A,M,D,E,$,y,Z,Y){let X=Math.max(1,...E.rows.map((K)=>K.cells.length)),S=Math.max(N5,Z.width-$-Z.paddingX)/X,J=TQ(M),V=y;for(let K=0;K<E.rows.length;K+=1){let q=CQ(J.get(K)??[],D,E,S,fN,Z.lineHeight,Y),U=Math.max(Z.lineHeight+d2*2,...q.map((z)=>z.measuredLines.reduce((G,H)=>G+H.height,0)+d2*2));for(let z of q){let G=$+z.cellIndex*S,H=V+d2;for(let B of z.measuredLines){let _={blockId:z.container.blockId,boundaries:q6(D,z.container,B.start,B.end,B.text,z.font,S-fN*2,Y),regionId:z.container.id,end:B.end,font:z.font,height:B.height,left:G+fN,start:B.start,text:B.text,top:H,width:B.width};N.push(_),F5(F,_),H+=B.height}A.set(z.container.id,{bottom:V+U,left:G,right:G+S,top:V})}jQ(F,E.id,V,V+U),V+=U}return V}function TQ(N){let F=new Map;for(let A of N){let M=A.tableCellPosition;if(!M)continue;let D=F.get(M.rowIndex)??[];D.push({cellIndex:M.cellIndex,container:A}),F.set(M.rowIndex,D)}return F}function CQ(N,F,A,M,D,E,$){return[...N].sort((y,Z)=>y.cellIndex-Z.cellIndex).map(({cellIndex:y,container:Z})=>{let Y=x2(A),X=v1(A,E),Q=l2(F,Z,Y,A,Math.max(40,M-D*2),X,$);return{cellIndex:y,container:Z,font:Y,lineHeight:X,measuredLines:Q}})}function jQ(N,F,A,M){let D=N.get(F);N.set(F,{bottom:D?Math.max(D.bottom,M):M,top:D?Math.min(D.top,A):A})}function z6(N){let F=N.charWidth??F6.charWidth,A=N.lineHeight??F6.lineHeight,M=Math.max(12,Math.floor(N.width/F)),D=N.text.split(`
|
|
21
|
+
`).reduce((E,$)=>E+Math.max(1,Math.ceil($.length/M)),0);return{estimatedHeight:D*A,lineCount:D,width:N.width}}function G6(N,F,A=D2(),M=null){let D=M??{images:new Map},E=A6(F),$=[],y=new Map,Z=new Map(N.regions.map((q)=>[q.id,{textLength:q.text.length}])),Y=N.blockIndex,X=uN(N.document.blocks),Q=new Map,S=new Set(N.regions.map((q)=>q.id)),J=E.paddingY,V=null;for(let q of N.blocks){let U=X.get(q.id)??null;if(!U||R1(U))continue;let z=Q1(q),G=q.regionIds.filter((w)=>S.has(w));if(!z&&G.length===0)continue;if(V!==null){if(J+=M6(Y,X,V.id,q.id,E.blockGap),!Q1(V)){let w=Q.get(V.id);if(w)w.bottom=Math.max(w.bottom,J)}}let H=q.depth,B=E.paddingX+H*E.indentWidth,_=k2(Y,N.listItemMarkers,q.id),O=Math.max(40,E.width-B-E.paddingX-_);if(z){let w=J+E.lineHeight;Q.set(q.id,{top:J,bottom:w}),J=w}else if(U.type==="table"){let w=G.map((b)=>N.regionIndex.get(b)).filter((b)=>b!==void 0);J=OD($,Q,y,w,A,U,B,J,E,D)}else for(let w of G){let b=N.regionIndex.get(w);if(!b)continue;J=RQ($,Q,y,b,A,U,B,J,O,E,D)}V=q}let K=[];for(let q of N.blocks){let U=X.get(q.id);if(!U||R1(U))continue;let z=Q.get(q.id);if(!z)continue;K.push({bottom:z.bottom,depth:q.depth,id:q.id,top:z.top,type:q.type})}return{blocks:K,regionBounds:y,regionLineIndices:bQ($),regionMetrics:Z,height:Math.max(J,E.paddingY),lines:$,options:E,width:E.width}}function RQ(N,F,A,M,D,E,$,y,Z,Y,X){let Q=x2(E),S=v1(E,Y.lineHeight),J=l2(D,M,Q,E,Z,S,X),V=y;for(let K of J){let q={blockId:M.blockId,boundaries:q6(D,M,K.start,K.end,K.text,Q,Z,X),regionId:M.id,end:K.end,font:Q,height:K.height,left:$,start:K.start,text:K.text,top:V,width:K.width};N.push(q),F5(F,q),fQ(A,q),V+=K.height}return V}function bQ(N){N.sort((A,M)=>A.top-M.top||A.left-M.left);let F=new Map;for(let A=0;A<N.length;A+=1){let M=N[A].regionId,D=F.get(M);if(D)D.push(A);else F.set(M,[A])}return F}function fQ(N,F){let A=N.get(F.regionId),M=F.left+F.width,D=F.top+F.height;N.set(F.regionId,A?{bottom:Math.max(A.bottom,D),left:Math.min(A.left,F.left),right:Math.max(A.right,M),top:Math.min(A.top,F.top)}:{bottom:D,left:F.left,right:M,top:F.top})}function F5(N,F){let A=N.get(F.blockId),M=F.top+F.height;N.set(F.blockId,{bottom:A?Math.max(A.bottom,M):M,top:A?Math.min(A.top,F.top):F.top})}function uN(N){let F=new Map,A=(M)=>{for(let D of M)if(F.set(D.id,D),D.type==="blockquote"||D.type==="listItem")A(D.children);else if(D.type==="list")A(D.items)};return A(N),F}var A5=null;function uQ(N){let F=/(\d+(?:\.\d+)?)\s*px/.exec(N);return F?Number.parseFloat(F[1]):16}function e0(N){A5??=new Map;let F=A5.get(N);if(F)return F;let A=LD(),M=Math.max(12,Math.round(uQ(N)));A.font=N;let D=A.measureText("Hg"),E=Math.round(D.actualBoundingBoxAscent||0),$=Math.round(D.actualBoundingBoxDescent||0),y=E+$,Z=Math.max(M,y),Y=y>0?E:Math.round(Z*0.8),X=y>0?$:Math.max(2,Z-Y),Q={ascent:Y,descent:X,emHeight:Z};return A5.set(N,Q),Q}function M5(N,F){let{emHeight:A}=e0(F);return Math.max(0,Math.floor((N-A)/2))}function $2(N,F){let{ascent:A}=e0(F);return M5(N,F)+A}var H6;function wD(N,F){let A=LD();if(N.length===0)return 0;return A.font=F,A.measureText(N).width}function LD(){if(H6!==void 0)return H6;let F=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d");if(!F)throw Error("Canvas font metrics require OffscreenCanvas or a DOM canvas context.");return H6=F,H6}function RD(N,F){let A=0,M=N.lines.length-1;while(A<=M){let D=A+M>>1,E=N.lines[D];if(F<E.top){M=D-1;continue}if(F>=E.top+E.height){A=D+1;continue}return{index:D,line:E}}return null}function _6(N,F){let A=[...N.regionBounds.entries()].find(([,E])=>{return F.x>=E.left&&F.x<=E.right&&F.y>=E.top&&F.y<=E.bottom});if(A)return vN(N,A[0],F.y);let M=RD(N,F.y);if(!M)return null;let D=vQ(N,F.y,M.index);if(D.length===1)return D[0]??null;return D.find((E)=>{let $=N.regionBounds.get(E.line.regionId);return $?F.x>=$.left&&F.x<=$.right:!1})??[...D].sort((E,$)=>{let y=N.regionBounds.get(E.line.regionId),Z=N.regionBounds.get($.line.regionId),Y=CD(F.x,y),X=CD(F.x,Z);return Y-X})[0]??null}function B6(N,F,A){if(N.blocks.length===0)return{endIndex:0,startIndex:0};let M=F+A,D=TD(N,F),E=TD(N,M);if(D>0){if(N.blocks[D-1].bottom>F)D-=1}if(E<N.blocks.length){if(N.blocks[E].top<M)E+=1}return{endIndex:E,startIndex:D}}function TD(N,F){let A=0,M=N.blocks.length;while(A<M){let D=A+M>>1;if(N.blocks[D].bottom<=F)A=D+1;else M=D}return A}function m1(N,F,A){if(N.lines.length===0)return{endIndex:0,startIndex:0};let M=F+A,D=jD(N,F),E=jD(N,M);if(D>0){let $=N.lines[D-1];if($.top+$.height>F)D-=1}if(E<N.lines.length){if(N.lines[E].top<M)E+=1}return{endIndex:E,startIndex:D}}function N1(N,F,A){return a2(N,F,A)?.line??null}function vN(N,F,A){let M=N.regionLineIndices.get(F);if(!M||M.length===0)return null;let D=M[0],E=Number.POSITIVE_INFINITY;for(let $ of M){let y=N.lines[$],Z=A<y.top?y.top-A:A>y.top+y.height?A-(y.top+y.height):0;if(Z<E)E=Z,D=$;if(Z===0)break}return{index:D,line:N.lines[D]}}function a2(N,F,A){let M=N.regionLineIndices.get(F);if(!M||M.length===0)return null;let D=0,E=M.length-1;while(D<=E){let X=D+E>>1,Q=M[X],S=N.lines[Q];if(A<S.start){E=X-1;continue}if(A>S.end){D=X+1;continue}return{index:Q,line:S}}let $=M[0],y=M[M.length-1],Z=N.lines[$],Y=N.lines[y];if(A<=Z.start)return{index:$,line:Z};if(A>=Y.end)return{index:y,line:Y};return null}function vQ(N,F,A){let M=[];for(let D=A;D>=0;D-=1){let E=N.lines[D];if(F<E.top||F>=E.top+E.height)break;M.unshift({index:D,line:E})}for(let D=A+1;D<N.lines.length;D+=1){let E=N.lines[D];if(F<E.top||F>=E.top+E.height)break;M.push({index:D,line:E})}return M}function CD(N,F){if(!F)return Number.POSITIVE_INFINITY;if(N<F.left)return F.left-N;if(N>F.right)return N-F.right;return 0}function b0(N,F){return N.left+mQ(N.boundaries,F)}function mQ(N,F){for(let M of N)if(M.offset===F)return M.left;return N.filter((M)=>M.offset<=F).at(-1)?.left??0}function jD(N,F){let A=0,M=N.lines.length;while(A<M){let D=A+M>>1,E=N.lines[D];if(E.top+E.height<=F)A=D+1;else M=D}return A}function D5(N,F){if(N.length===0)return 0;for(let A=1;A<N.length;A+=1){let M=N[A-1],D=N[A],E=M.left+(D.left-M.left)/2;if(F<=E)return M.offset;if(F<=D.left)return D.offset}return N.at(-1)?.offset??0}function mN(N,F,A){return b0(F,A)+g0(N,F)}function g0(N,F){let A=z1(N,F.blockId,"listItem");if(!A)return 0;return Z2(N,A.id)?.kind==="task"?uM:bM}function y2(N){return{left:N.left,size:fM,top:N.top+3}}function z1(N,F,A){let M=N.documentIndex.blockIndex.get(F)??null;while(M){if(M.type===A)return M;let D=M.parentBlockId;M=D?N.documentIndex.blockIndex.get(D)??null:null}return null}function Z2(N,F){return N.documentIndex.listItemMarkers.get(F)??null}function F1(N,F,A){if(!N.regionMetrics.get(A.regionId))return null;let D=N1(N,A.regionId,A.offset);if(!D)return null;return{blockId:D.blockId,regionId:D.regionId,height:D.height,left:b0(D,A.offset-D.start),offset:A.offset,top:D.top}}function A1(N,F,A){let M=N1(F,A.regionId,A.offset);if(!M)return A.left;return A.left+g0(N,M)+kQ(N,M,A.offset)}function kQ(N,F,A){if(A<=F.end)return 0;let M=N.documentIndex.regionIndex.get(F.regionId);if(!M)return 0;let D=M.text.slice(F.end,A);if(!/^[ \t]+$/u.test(D))return 0;return wD(D,F.font)}var P6;function bD(N,F){if(N.length===0)return null;F=Math.max(0,Math.min(F,N.length));let A=gQ(),M=null;for(let D of A.segment(N)){let E=D.index,$=E+D.segment.length;if(!D.isWordLike){if(F<$)return F===E&&M?.end===F?M:null;continue}let y={end:$,start:E};if(F>=E&&F<$)return y;if(F===$){M=y;continue}if(F<E)return M;M=y}return M&&F===M.end?M:null}function gQ(){if(P6!==void 0)return P6;let N=Intl.Segmenter;if(typeof N!=="function")throw Error("Word selection requires Intl.Segmenter.");return P6=new N(void 0,{granularity:"word"}),P6}function v0(N,F,A){let M=hQ(N,F,A);if(!M)return null;let D=M.snapToLineStart?M.line.left:A.x;return fD(N,F,M.line,D)}function W6(N,F,A){let M=N.lines[N.lines.length-1];if(!M||A.y<=M.top+M.height)return null;return fD(N,F,M,A.x)}function O6(N,F,A,M){let D=uD(F,M.regionId);if(!D)return null;let E=v0(N,F,A);if(E)return{regionId:E.regionId,offset:E.offset};let $=A.y<IQ(N);return{regionId:M.regionId,offset:$?0:D.text.length}}function w6(N,F,A){let M=v0(N,F,A);if(!M)return null;let D=uD(F,M.regionId);if(!D||D.text.length===0)return null;let E=bD(D.text,M.offset);if(!E)return null;return{anchor:{regionId:M.regionId,offset:E.start},focus:{regionId:M.regionId,offset:E.end}}}function fD(N,F,A,M){let D=N.regionMetrics.get(A.regionId);if(!D)return null;let E=Math.max(0,M-g0(F,A)-A.left),$=D5(A.boundaries,E),y=Math.min(D.textLength,A.start+$);return{regionId:A.regionId,offset:y,left:b0(A,$),top:A.top,height:A.height}}function hQ(N,F,A){for(let[D,E]of N.regionBounds)if(A.x>=E.left&&A.x<=E.right&&A.y>=E.top&&A.y<=E.bottom){let $=vN(N,D,A.y)?.line??null;return $?{line:$}:null}let M=_6(N,A)?.line??null;if(M)return{line:M};for(let D of N.blocks){if(A.y<D.top||A.y>D.bottom)continue;for(let $=N.lines.length-1;$>=0;$--)if(N.lines[$].blockId===D.id)return{line:N.lines[$]};let E=F.documentIndex.blockIndex.get(D.id);if(E&&Q1(E)){let $=wN(F.documentIndex,D.id);if($){let y=N.lines.find((Z)=>Z.blockId===$.id);if(y)return{line:y,snapToLineStart:!0}}}}return null}function uD(N,F){return N.documentIndex.regionIndex.get(F)??null}function IQ(N){return N.lines[0]?.top??0}function G1(N,F){let A=N.viewport.top,M=A+N.viewport.height;if(F.bottom<A)return"above";if(F.top>M)return"below";return"visible"}function E5(N,F,A){let M=pQ(N,A);if(!M||M.start!==0)return null;let D=z1(F,M.blockId,"listItem");if(!D)return null;if(Z2(F,D.id)?.kind!=="task")return null;let $=y2(M),y=$.left-4,Z=$.left+$.size+4,Y=$.top-4,X=$.top+$.size+4;return A.x>=y&&A.x<=Z&&A.y>=Y&&A.y<=X?{listItemId:D.id}:null}function $5(N,F,A){let M=v0(N,F,A);if(!M)return null;let D=xQ(F,M.regionId);if(!D)return null;let E=D.inlines.find(($)=>$.link&&M.offset>=$.start&&M.offset<$.end);if(!E?.link)return null;return{endOffset:E.end,regionId:M.regionId,startOffset:E.start,title:E.link.title,url:E.link.url}}function L6(N,F,A,M){let D=E5(N,F,A);if(D)return{kind:"task-toggle",listItemId:D.listItemId};let E=v0(N,F,A);if(!E)return null;let $=vD(E.regionId,E.offset,M),y=$5(N,F,A);if(y)return{endOffset:y.endOffset,kind:"link",commentThreadIndex:$,regionId:y.regionId,startOffset:y.startOffset,title:y.title,url:y.url};return{kind:"text",commentThreadIndex:$}}function T6(N,F,A,M){let D=F.documentIndex.regionIndex.get(A.regionId);if(!D)return null;let E=vD(A.regionId,A.offset,M),$=D.inlines.find((y)=>A.offset>=y.start&&A.offset<=y.end)??null;if($?.link)return{commentThreadIndex:E,endOffset:$.end,kind:"link",regionId:A.regionId,startOffset:$.start,title:$.link.title,url:$.link.url};if(E!==null)return{commentThreadIndex:E,kind:"text"};return null}function kN(N,F,A,M){let D=N.documentIndex.regionIndex.get(N.selection.anchor.regionId);if(!M.image||!D)return null;let E=N1(F.layout,D.id,M.start);if(!E)return null;let $=E.left+g0(N,E),y=$+b0(E,M.start-E.start)-E.left,Z=$+b0(E,M.end-E.start)-E.left,{height:Y}=bN(M,A,E.width),X=E.top+Math.max(0,Math.floor((E.height-Y)/2));return{left:y,top:X,width:Z-y,height:Y}}function vD(N,F,A){for(let M of A)if(M.regionId===N&&F>=M.startOffset&&F<=M.endOffset)return M.threadIndex;return null}function pQ(N,F){return N.lines.find((A)=>F.y>=A.top-4&&F.y<=A.top+A.height+4)??N.lines.filter((A)=>Math.abs(F.y-(A.top+A.height/2))<=10).sort((A,M)=>Math.abs(F.y-(A.top+A.height/2))-Math.abs(F.y-(M.top+M.height/2)))[0]??null}function xQ(N,F){return N.documentIndex.regionIndex.get(F)??null}function mD(N,F,A,M,D,E,$){let y=y5(F,D,E,$),Z=N.measuredContainerHeights.get(y);if(Z!==void 0)return Z;let Y=v1(A,E.lineHeight),X=E.paddingX+M*E.indentWidth,Q=Math.max(40,E.width-X-E.paddingX-D);if(F.inlines.some((V)=>V.kind==="image"||V.kind==="mention")){let V=x2(A);return l2(N,F,V,A,Q,Y,$).reduce((K,q)=>K+q.height,0)}let S=z6({charWidth:E.charWidth,lineHeight:Y,text:F.text,width:Q});return Math.max(Y,S.lineCount*Y)}function kD(N,F,A,M){let D=z6({charWidth:M,lineHeight:A,text:N.text,width:F});return Math.max(A,D.lineCount*A)}function y5(N,F,A,M){return`${U6(N,M)}:${A.width}:${A.paddingX}:${A.indentWidth}:${A.lineHeight}:${F}`}function Z5(N,F){let A=0,M=N.entries.length;while(A<M){let D=A+M>>1;if(N.entries[D].bottom<=F)A=D+1;else M=D}return A}function gD(N,F,A,M,D){let E=M,$=D;for(let y=M;y<D;y+=1){let Z=N.regions[y],Y=F.get(Z.blockId);if(!Y)continue;if(Y.type==="table"){let X=A.get(Y.regionIds[0]??""),Q=A.get(Y.regionIds[Y.regionIds.length-1]??"");if(X!==void 0)E=Math.min(E,X);if(Q!==void 0)$=Math.max($,Q+1)}}return{endIndex:$,startIndex:E}}function hD(N,F,A){return{...N,blocks:N.blocks.map((M)=>({...M,bottom:M.bottom+F,top:M.top+F})),regionBounds:new Map([...N.regionBounds.entries()].map(([M,D])=>[M,{bottom:D.bottom+F,left:D.left,right:D.right,top:D.top+F}])),height:A,lines:N.lines.map((M)=>({...M,top:M.top+F}))}}function ID(N,F,A,M,D){for(let[E,$]of A.regionBounds){let y=$.bottom-$.top,Z=F.regionIndex.get(E),Y=Z?k2(F.blockIndex,F.listItemMarkers,Z.blockId):0;wM(N,y5(Z??{path:E,inlines:[],text:""},Y,M,D),y)}}function Y5(N,F,A,M=[],D=D2(),E=null){let $=A6(F),y=E??{images:new Map},Z=uN(N.document.blocks),Y=N.blockIndex,X=new Set(M),Q=Math.max(0,A.top-A.overscan),S=A.top+A.height+A.overscan,J=dQ(D,N,Z,Y,$,y),V=Z5(J,Q),K=Z5(J,S);if(V>0){let H=J.entries[V-1];if(H&&H.bottom>Q)V-=1}if(K<J.entries.length){let H=J.entries[K];if(H&&H.top<S)K+=1}for(let H of X){let B=J.containerIndices.get(H);if(B===void 0)continue;V=Math.min(V,B),K=Math.max(K,B+1)}if(!Number.isFinite(V)||!Number.isFinite(K))return{estimateRegionBounds:J.estimateRegionBounds,layout:G6({...N,regions:[]},$,D,y),totalHeight:J.totalHeight,viewport:A};let q=gD(N,Y,J.containerIndices,V,K),U=J.entries[q.startIndex]?.top??$.paddingY,z=G6({...N,regions:N.regions.slice(q.startIndex,q.endIndex)},$,D,y),G=hD(z,U,J.totalHeight);return ID(D,N,G,$,y),{estimateRegionBounds:J.estimateRegionBounds,layout:G,totalHeight:J.totalHeight,viewport:A}}function dQ(N,F,A,M,D,E){let $=cQ(F,D,E),y=TM(N,F,$);if(y)return y;let Z=D.paddingY,Y=[],X=new Map,Q=0,S=null;for(let J of F.blocks){let V=A.get(J.id)??null;if(!V||R1(V))continue;let K=Q1(J);if(!K&&J.regionIds.length===0)continue;if(S!==null)Z+=M6(M,A,S,J.id,D.blockGap);if(K)Z+=D.lineHeight;else if(V.type==="table"){let q=aQ({block:V,containerIndices:X,entries:Y,index:Q,options:D,runtimeBlocks:M,totalHeight:Z,regions:F.regions});if(q)Q=q.nextIndex,Z=q.totalHeight}else{let q=k2(F.blockIndex,F.listItemMarkers,J.id);for(let U of J.regionIds){let z=F.regions[Q];if(!z){Q+=1;continue}let G=mD(N,z,V,J.depth,q,D,E),H=Z,B=H+G;Y[Q]={bottom:B,top:H},X.set(z.id,Q),Z=B,Q+=1}}S=J.id}return CM(N,F,$,{containerIndices:X,entries:Y,estimateRegionBounds(J){let V=X.get(J);return V===void 0?null:Y[V]??null},totalHeight:Z})}function aQ({block:N,containerIndices:F,entries:A,index:M,options:D,runtimeBlocks:E,totalHeight:$,regions:y}){let Z=E.get(N.id),Y=Z?.regionIds??[];if(Y.length===0)return null;let X=y.slice(M,M+Y.length);if(X.length===0||X[0]?.blockId!==N.id)return null;let Q=Z?.depth??0,S=D.paddingX+Q*D.indentWidth,J=Math.max(N5,D.width-S-D.paddingX),V=Math.max(1,...N.rows.map((H)=>H.cells.length)),K=J/V,q=Math.max(40,K-fN*2),U=v1(N,D.lineHeight),z=rQ(X,M),G=$;for(let H=0;H<N.rows.length;H+=1){let B=z.get(H)??[],_=Math.max(U+d2*2,...B.map(({region:w})=>kD(w,q,U,D.charWidth)+d2*2)),O=G+_;for(let{index:w,region:b}of B)A[w]={bottom:O,top:G},F.set(b.id,w);G=O}for(let H=M;H<M+X.length;H+=1){let B=y[H];if(!B||A[H])continue;A[H]={bottom:G,top:G},F.set(B.id,H)}return{nextIndex:M+X.length,totalHeight:G}}function rQ(N,F){let A=new Map;for(let[M,D]of N.entries()){let E=D.tableCellPosition?.rowIndex;if(E===void 0)continue;let $=A.get(E)??[];$.push({index:F+M,region:D}),A.set(E,$)}return A}function cQ(N,F,A){return[F.width,F.paddingX,F.paddingY,F.indentWidth,F.lineHeight,F.blockGap,sQ(N,A)].join(":")}function sQ(N,F){if(N.imageUrls.size===0)return"";return N.regions.flatMap((A)=>A.inlines.filter((M)=>M.kind==="image"&&M.image).map((M)=>{let D=M.image?F.images.get(M.image.url):null;return`${M.image?.url??""}:${M.image?.width??0}:${D?.status??"loading"}:${D?.intrinsicWidth??0}:${D?.intrinsicHeight??0}`})).join("|")}function X5(N,F,A,M=null){let D={height:F.height,overscan:Math.max(160,F.height),top:F.top},E=Y5(N.documentIndex,F,D,[N.selection.anchor.regionId,N.selection.focus.regionId],A,M);return{blockMap:uN(N.documentIndex.document.blocks),estimateRegionBounds:E.estimateRegionBounds,regionBounds:new Map(E.layout.regionBounds),layout:E.layout,paintHeight:Math.max(240,D.height+D.overscan*2),paintTop:Math.max(0,D.top-D.overscan),totalHeight:E.totalHeight,viewport:{height:D.height,top:D.top}}}function C6(N,F,A){return v0(F.layout,N,A)??W6(F.layout,N,A)}function Q5(N,F,A,M){return O6(F.layout,N,A,M)}function S5(N,F,A){return w6(F.layout,N,A)}function pD(N,F,A,M){return L6(F.layout,N,A,M)}function xD(N,F,A,M){return T6(F.layout,N,A,M)}function J5(N,F,A){return F1(F.layout,N.documentIndex,A)}function k1(N,F,A){let M=F1(F.layout,N.documentIndex,A);if(!M)return null;return{...M,left:A1(N,F.layout,M)}}function lD(N,F,A,M,D){let E=M-A,$=D-E;if(M<=N)return{end:F+$,start:N+$};if(A>=F)return{end:F,start:N};let y=Math.max(0,Math.min(A,F)-N),Z=Math.max(0,F-Math.max(M,N)),Y=N<A?N:A;return{end:Y+y+D+Z,start:Y}}function q5(N,F,A){let M=A.trim();if(M.length===0||F.startOffset===F.endOffset)return null;let D=N.regionIndex.get(F.regionId)??null,E=D?V5(N,D):null;if(!E)return null;return L4({anchor:BN(E,F.startOffset,F.endOffset),body:M,quote:PN(E,F.startOffset,F.endOffset)})}function h0(N){let F="documentIndex"in N?N.documentIndex:N,A=R6(F),M=F.document.comments,D=[...M],E=[];for(let[$,y]of M.entries()){let Z=WN(y,F.document);if(!Z.match)continue;let X=A.findBySemanticMatch(Z.match.containerId,Z.match.containerOrdinal)?.runtimeContainer??null;if(!X)continue;if(Z.repair)D[$]={...y,anchor:Z.repair.anchor,quote:Z.repair.quote};E.push({endOffset:Z.match.endOffset,resolution:Z,regionId:X.id,resolved:y.resolvedAt!=null,startOffset:Z.match.startOffset,threadIndex:$})}return{liveRanges:E,threads:D}}function j6(N,F,A){if(F.length===0||A.size===0)return!1;let{endIndex:M,startIndex:D}=m1(N.layout,N.viewport.top,N.viewport.height);for(let E=D;E<M;E+=1){let $=N.layout.lines[E];if(!$)continue;if(G1(N,{bottom:$.top+$.height,top:$.top})!=="visible")continue;if(F.some((y)=>!y.resolved&&A.has(y.threadIndex)&&y.regionId===$.regionId&&y.endOffset>$.start&&y.startOffset<$.end))return!0}return!1}function U5(N,F,A,M,D,E){if(N.document.comments.length===0)return F.document.comments;let $=N.commentContainerIndex.get(A.semanticRegionId)??[],y=new Set($);if($.length===0)return F.document.comments;let Z=h0(N),Y=new Map(Z.liveRanges.map((J)=>[J.threadIndex,J])),X=V5(N,A),Q=r2(F,A.path),S=Q?V5(F,Q):null;if(!X||!S)return F.document.comments;return F.document.comments.map((J,V)=>{if(!y.has(V))return J;let K=Y.get(V),q=K?.resolution.match??null;if(!K||!q||q.containerId!==X.id)return J;let U=lD(q.startOffset,q.endOffset,M,D,E.length);return{...J,anchor:BN(S,U.start,U.end),quote:PN(S,U.start,U.end)}})}function V5(N,F){let A=iQ(N,F);if(!A)return null;return{containerKind:A,containerOrdinal:-1,id:F.semanticRegionId,text:F.text}}function iQ(N,F){if(N.tableCellIndex.has(F.id))return"tableCell";return UM(F.blockType)}function b6(N,F){if(F.length===0)return[];let A=R6(N),M=A.list();return F.map((D)=>({...D,...oQ(D,M,A,N),viewport:null}))}function oQ(N,F,A,M){if(!N.cursor)return{commentThreadIndex:null,cursorPoint:null};if(KM(N.cursor))return nQ(N.cursor,M);return{commentThreadIndex:null,cursorPoint:tQ(N.cursor,F,A)}}function nQ(N,F){let A=F.document.comments.findIndex((M)=>M.id===N.threadId);return{commentThreadIndex:A>=0?A:null,cursorPoint:null}}function tQ(N,F,A){let M=eQ(F,N),D=NS(M,N);if(D.length!==1)return null;let E=D[0],$=A.resolveRuntimeContainer(E.container.id);if(!$)return null;return{offset:Math.max(0,Math.min(E.offset,$.text.length)),regionId:$.id}}function eQ(N,F){return F.kind?N.filter((A)=>A.containerKind===F.kind):N}function NS(N,F){if(F.prefix&&F.suffix)return FS(N,F.prefix,F.suffix);if(F.prefix)return dD(N,F.prefix,"after");if(F.suffix)return dD(N,F.suffix,"before");return[]}function dD(N,F,A){let M=[];for(let D of N)for(let E of X1(D.text,F))M.push({container:D,offset:A==="after"?E+F.length:E});return M}function FS(N,F,A){let M=[];for(let D of N)for(let E of m2(D.text,F,A))M.push({container:D,offset:E.startOffset});return M}var AS=48;function f6(N,F,A){let M="documentIndex"in N?N.documentIndex:N;if(A.length===0)return[];return A.map((D)=>({...D,viewport:MS(M,F,D)}))}function u6(N,F,A){let M="documentIndex"in N?N.documentIndex:N,D=aD(M,F,A);if(!D)return"unresolved";return G1(F,D)}function MS(N,F,A){if(!A.cursorPoint)return{status:"unresolved"};let M=aD(N,F,A.cursorPoint);if(!M)return{status:"unresolved"};return{scrollTop:DS(F,M),status:G1(F,M)}}function aD(N,F,A){let M=F1(F.layout,N,A);if(M)return{bottom:M.top+M.height,top:M.top};return F.estimateRegionBounds(A.regionId)}function DS(N,F){let A=Math.max(0,N.totalHeight-N.viewport.height),M=F.top-Math.min(AS,N.viewport.height/4);return Math.max(0,Math.min(A,M))}function R6(N){let F=N6(N.document),A=new Map(F.map((D)=>[D.id,D])),M=new Map(N.regions.map((D)=>[D.semanticRegionId,D]));return{findBySemanticMatch(D,E){let $=A.get(D)??F[E]??null;if(!$)return null;return{runtimeContainer:M.get($.id)??null,semanticContainer:$}},list(D){return D?F.filter((E)=>E.containerKind===D):F},resolveRuntimeContainer(D){return M.get(D)??null}}}var Y2="",rD=1e6;function gN(N,F,A){return`${N}:${F}:${A}`}function c2(N){let F=WS(N),A=z5(F.blocks.map((M,D)=>IN(M,D)));return G5(F,A)}function IN(N,F){let A=[],M=[],D=[],E=new Set,$=0;function y(Y,X,Q,S,J=null){if(M.length>0)D.push(`
|
|
22
|
+
`),$+=1;let V=Q.map((U)=>U.text).join(""),K=$,q=K+V.length;D.push(V),$=q;for(let U of Q)if(U.image)E.add(U.image.url);M.push({blockId:Y.id,blockType:Y.type,end:q,id:`${Y.id}:${X}`,path:X,rootIndex:F,inlines:Q,semanticRegionId:S,start:K,tableCellPosition:J,text:V})}function Z(Y,X,Q,S){let J={childBlockIds:[],depth:Q,end:$,id:Y.id,parentBlockId:S,path:X,regionIds:[],rootIndex:F,start:$,type:Y.type};switch(A.push(J),Y.type){case"blockquote":case"listItem":for(let[V,K]of Y.children.entries())J.childBlockIds.push(K.id),Z(K,Y1(X,V),Q+1,Y.id);break;case"code":{y(Y,Q4(X),[{end:Y.source.length,id:`${Y.id}:code`,image:null,inlineCode:!1,kind:"text",link:null,marks:[],mention:null,originalType:null,start:0,text:Y.source}],Y.id),J.regionIds.push(M.at(-1).id);break}case"heading":case"paragraph":y(Y,r0(X),K5(Y.children),Y.id),J.regionIds.push(M.at(-1).id);break;case"list":for(let[V,K]of Y.items.entries())J.childBlockIds.push(K.id),Z(K,Y1(X,V),Q+1,Y.id);break;case"table":for(let[V,K]of Y.rows.entries())for(let[q,U]of K.cells.entries())y(Y,F2(f2(X,V),q),K5(U.children),U.id,{cellIndex:q,rowIndex:V}),J.regionIds.push(M.at(-1).id);break;case"divider":break;case"directive":break;case"raw":y(Y,Q4(X),[{end:Y.source.length,id:`${Y.id}:raw`,image:null,inlineCode:!1,kind:"raw",link:null,marks:[],mention:null,originalType:Y.originalType,start:0,text:Y.source}],Y.id),J.regionIds.push(M.at(-1).id);break}J.end=$}return Z(N,R2(F),0,null),{blockRange:{end:A.length,start:0},blocks:A,end:$,imageUrls:E,length:$,regionRange:M.length>0?{end:M.length,start:0}:void 0,regions:M,rootIndex:F,start:0,text:D.join("")}}function z5(N,F=null){let A=[],M=0,D=0,E=0,$=!1;for(let[y,Z]of N.entries()){if(Z.regions.length>0&&$)E+=1;let Y={...Z,blockRange:{end:M+Z.blocks.length,start:M},end:E+Z.length,regionRange:Z.regions.length>0?{end:D+Z.regions.length,start:D}:void 0,start:E},X=F?.[y];if(A.push($S(X,Z,Y)?X:cD(Z,Y)),M=Y.blockRange.end,D=Y.regionRange?.end??D,Z.regions.length>0)E=Y.end,$=!0}return A}function s2(N,F,A,M){let D=F.blocks.length-(N.roots.length-M);if(D<0)throw Error("Editor model splice received an invalid replacement count.");if(A===N.roots.length&&D===1){let Z=F.blocks[A];if(Z)return ES(N,F,Z)}let E=D===M,$=[...N.roots.slice(0,A),...F.blocks.slice(A,A+D).map((Z,Y)=>IN(Z,A+Y)),...E?N.roots.slice(A+M):F.blocks.slice(A+D).map((Z,Y)=>IN(Z,A+D+Y))],y=z5($,N.roots);return G5(F,y,N)}function ES(N,F,A){let M=N.roots.length,D=IN(A,M),E=N.roots.some((X)=>X.regions.length>0),$=D.regions.length>0&&E?N.length+1:N.length,y=cD(D,{...D,blockRange:{end:N.blocks.length+D.blocks.length,start:N.blocks.length},end:$+D.length,regionRange:D.regions.length>0?{end:N.regions.length+D.regions.length,start:N.regions.length}:void 0,start:$}),Z=[...N.blocks,...y.blocks],Y=[...N.regions,...y.regions];return{blockIndex:QS(N.blockIndex,y.blocks),blocks:Z,commentContainerIndex:F.comments===N.document.comments?N.commentContainerIndex:sD(F),document:F,engine:"canvas",imageUrls:_S(N.imageUrls,y.imageUrls),length:y.end,listItemMarkers:F.blocks===N.document.blocks?N.listItemMarkers:KS(N.listItemMarkers,A),regionIndex:SS(N.regionIndex,y.regions),regionOrderIndex:JS(N.regionOrderIndex,y.regions,N.regions.length),regionPathIndex:VS(N.regionPathIndex,y.regions),regions:Y,roots:[...N.roots,y],tableCellIndex:qS(N.tableCellIndex,y.regions),tableCellRegionIndex:US(N.tableCellRegionIndex,y.regions),text:zS(N.text,y)}}function v6(N,F){if(F.blocks!==N.document.blocks)throw Error("Editor model document replacement requires preserving root blocks.");return G5(F,N.roots,N)}function m6(N,F,A){let M=N.blockIndex.get(F);if(!M)return null;return SM(N.document,F,A,M.rootIndex)}function G5(N,F,A=null){let M=F.flatMap((X)=>X.blocks),D=F.flatMap((X)=>X.regions),{regionIndex:E,regionOrderIndex:$,regionPathIndex:y,tableCellIndex:Z,tableCellRegionIndex:Y}=XS(D);return{blockIndex:YS(M),blocks:M,commentContainerIndex:N.comments===A?.document.comments?A.commentContainerIndex:sD(N),document:N,engine:"canvas",imageUrls:HS(F,A?.imageUrls),length:F.at(-1)?.end??0,listItemMarkers:N.blocks===A?.document.blocks?A.listItemMarkers:PS(N.blocks),regionIndex:E,regionOrderIndex:$,regionPathIndex:y,regions:D,roots:F,tableCellIndex:Z,tableCellRegionIndex:Y,text:GS(F)}}function cD(N,F){let A=F.start-N.start;return{...F,blocks:A===0?N.blocks:yS(N.blocks,A),regions:A===0?N.regions:ZS(N.regions,A)}}function $S(N,F,A){return Boolean(N&&F===N&&N.start===A.start&&N.end===A.end&&N.blockRange.start===A.blockRange.start&&N.blockRange.end===A.blockRange.end&&N.regionRange?.start===A.regionRange?.start&&N.regionRange?.end===A.regionRange?.end)}function yS(N,F){return N.map((A)=>({...A,end:A.end+F,start:A.start+F}))}function ZS(N,F){return N.map((A)=>({...A,end:A.end+F,start:A.start+F}))}function YS(N){let F=new Map;for(let A of N)F.set(A.id,A);return F}function XS(N){let F=new Map,A=new Map,M=new Map,D=new Map,E=new Map;for(let[$,y]of N.entries()){if(F.set(y.id,y),A.set(y.id,$),M.set(y.path,y),!y.tableCellPosition)continue;D.set(y.id,y.tableCellPosition),E.set(gN(y.blockId,y.tableCellPosition.rowIndex,y.tableCellPosition.cellIndex),y.id)}return{regionIndex:F,regionOrderIndex:A,regionPathIndex:M,tableCellIndex:D,tableCellRegionIndex:E}}function QS(N,F){let A=new Map(N);for(let M of F)A.set(M.id,M);return A}function SS(N,F){let A=new Map(N);for(let M of F)A.set(M.id,M);return A}function JS(N,F,A){let M=new Map(N);for(let[D,E]of F.entries())M.set(E.id,A+D);return M}function VS(N,F){let A=new Map(N);for(let M of F)A.set(M.path,M);return A}function qS(N,F){let A=new Map(N);for(let M of F)if(M.tableCellPosition)A.set(M.id,M.tableCellPosition);return A}function US(N,F){let A=new Map(N);for(let M of F){if(!M.tableCellPosition)continue;A.set(gN(M.blockId,M.tableCellPosition.rowIndex,M.tableCellPosition.cellIndex),M.id)}return A}function KS(N,F){let A=new Map(N);return hN(A,[F]),A}function zS(N,F){if(F.regions.length===0)return N;return N.length>0?`${N}
|
|
23
|
+
${F.text}`:F.text}function GS(N){return N.filter((F)=>F.regions.length>0).map((F)=>F.text).join(`
|
|
24
|
+
`)}function HS(N,F){let A=new Set;for(let M of N)for(let D of M.imageUrls)A.add(D);return F&&BS(F,A)?F:A}function _S(N,F){if(F.size===0)return N;let A=null;for(let M of F){if(N.has(M))continue;A??=new Set(N),A.add(M)}return A??N}function BS(N,F){if(N.size!==F.size)return!1;for(let A of N)if(!F.has(A))return!1;return!0}function sD(N){let F=new Map;for(let[A,M]of N.comments.entries()){let D=WN(M,N).match?.containerId??null;if(!D)continue;let E=F.get(D)??[];E.push(A),F.set(D,E)}return F}function PS(N){let F=new Map;return hN(F,N),F}function hN(N,F,A=null){for(let M of F){if(M.type==="list"){for(let[D,E]of M.items.entries())hN(N,[E],{index:D,ordered:M.ordered,start:M.start});continue}if(M.type==="listItem"){if(typeof M.checked==="boolean")N.set(M.id,{checked:M.checked,kind:"task"});else if(A?.ordered)N.set(M.id,{kind:"ordered",label:`${(A.start??1)+A.index}.`});else N.set(M.id,{kind:"bullet",label:"•"});hN(N,M.children,A)}if(M.type==="blockquote")hN(N,M.children,A)}}function WS(N){if(N.blocks.length>0)return N;return v2([F0("")],N.comments,N.frontMatter)}function K5(N,F=null){let A=[],M=0,D=(E)=>{let $=M,y=$+E.text.length;A.push({...E,end:y,start:$}),M=y};for(let E of N)switch(E.type){case"lineBreak":D({id:E.id,image:null,inlineCode:!1,kind:"lineBreak",link:F,marks:[],mention:null,originalType:null,text:`
|
|
25
|
+
`});break;case"image":D({id:E.id,image:{alt:E.alt,title:E.title,url:E.url,width:E.width},inlineCode:!1,kind:"image",link:F,marks:[],mention:null,originalType:null,text:Y2});break;case"mention":D({id:E.id,image:null,inlineCode:!1,kind:"mention",link:F,marks:[],mention:{name:E.name,userId:E.userId},originalType:null,text:Y2});break;case"code":D({id:E.id,image:null,inlineCode:!0,kind:"code",link:F,marks:[],mention:null,originalType:null,text:E.code});break;case"link":for(let $ of K5(E.children,{title:E.title,url:E.url}))D($);break;case"text":D({id:E.id,image:null,inlineCode:!1,kind:"text",link:F,marks:E.marks,mention:null,originalType:null,text:E.text});break;case"raw":D({id:E.id,image:null,inlineCode:!1,kind:"raw",link:F,marks:[],mention:null,originalType:E.originalType,text:E.source});break}return A}function j0(N,F,A=0){return{childIndices:F,kind:"descendant-primary-region",offset:A,rootIndex:N}}function $0(N,F=0){return{kind:"root-primary-region",offset:F,rootIndex:N}}function H5(N,F=0){return{kind:"region",offset:F,regionId:N}}function X2(N,F,A,M=0){return{cellIndex:A,kind:"table-cell",offset:M,rootIndex:N,rowIndex:F}}function r2(N,F){return N.regionPathIndex.get(F)??null}function n2(N,F,A,M){let D=N.tableCellRegionIndex.get(gN(F,A,M));return D?N.regionIndex.get(D)??null:null}function pN(N,F){if(!F)return null;if(F.kind==="root-primary-region"){let M=N.document.blocks[F.rootIndex],D=M?k6(N,M):null;return D?i2(D.id,o2(D.text,F.offset)):null}if(F.kind==="descendant-primary-region"){let M=N.document.blocks[F.rootIndex],D=M?OS(M,F.childIndices):null,E=D?k6(N,D):null;return E?i2(E.id,o2(E.text,F.offset)):null}if(F.kind==="region"){let M=N.regionIndex.get(F.regionId)??null;return M?i2(M.id,o2(M.text,F.offset)):null}if(F.kind==="block-primary-region"){let M=o0(N.document,F.blockId),D=M?k6(N,M):null;return D?i2(D.id,o2(D.text,F.offset)):null}if(F.kind==="table-cell"){let M=N.document.blocks[F.rootIndex];if(!M||M.type!=="table")return null;let D=n2(N,M.id,F.rowIndex,F.cellIndex);return D?i2(D.id,o2(D.text,F.offset)):null}let A=r2(N,F.path);if(!A)return null;if(F.kind==="region-path")return i2(A.id,o2(A.text,F.offset));return{anchor:{regionId:A.id,offset:Math.max(0,Math.min(F.startOffset,A.text.length))},focus:{regionId:A.id,offset:Math.max(0,Math.min(F.endOffset,A.text.length))}}}function i2(N,F){let A={offset:F,regionId:N};return{anchor:A,focus:A}}function o2(N,F){return F==="end"?N.length:Math.max(0,Math.min(F,N.length))}function OS(N,F){let A=N;for(let M of F){if(!A)return null;let D=C0(A);if(!D)return null;A=D[M]??null}return A}function k6(N,F){let A=N.blockIndex.get(F.id);if(!A)return null;let M=A.regionIds[0];if(M)return N.regionIndex.get(M)??null;let D=C0(F);if(!D)return null;for(let E of D){let $=k6(N,E);if($)return $}return null}function g6(N){if(!xN(N.selection))return null;let F=N.documentIndex.regionIndex.get(N.selection.focus.regionId);return F?{offset:N.selection.focus.offset,regionId:F.id,text:F.text}:null}function h6(N){let F=N.documentIndex.regionIndex.get(N.selection.anchor.regionId)??null,A=F?N.documentIndex.blockIndex.get(F.blockId)??null:null,M=iD(N);return{block:A?{blockId:A.id,depth:A.depth,nodeType:A.type,text:F?.text??""}:null,span:M?.link?{kind:"link",url:M.link.url}:M&&M.marks.length>0?{kind:"marks",marks:M.marks}:{kind:"none"}}}function I6(N){let F=iD(N);return F?.kind==="image"?F:null}function t2(N){let F=Z0(N.documentIndex,N.selection);if(F.start.regionId!==F.end.regionId||F.start.offset===F.end.offset)return null;return{endOffset:F.end.offset,regionId:F.start.regionId,startOffset:F.start.offset}}function iD(N){let F=N.documentIndex.regionIndex.get(N.selection.anchor.regionId)??null;if(!F)return null;let A=N.selection.anchor.offset;return F.inlines.find((M)=>A>M.start&&A<M.end)??F.inlines.find((M)=>M.end===A)??F.inlines.find((M)=>M.start===A)??null}function _5(N,F){let A=N.regionIndex.get(F);if(!A)return null;let M=o0(N.document.blocks,A.blockId);if(!M)return null;return B5(M,A.path,A.semanticRegionId)}function B5(N,F,A){if(N.type==="heading"||N.type==="paragraph")return{block:N,children:N.children,kind:"inlineBlock",path:F.replace(/\.children$/,"")};if(N.type!=="table")return null;let M=/^(.*\.rows\.\d+\.cells\.\d+)$/.exec(F);if(!M)return null;for(let D of N.rows)for(let E of D.cells)if(E.id===A)return{block:N,blockPath:M[1].replace(/\.rows\.\d+\.cells\.\d+$/,""),cell:E,children:E.children,kind:"tableCell",path:M[1]};return null}function O0(N){switch(N.type){case"lineBreak":return 1;case"image":case"mention":return Y2.length;case"code":return N.code.length;case"link":return J0(N.children).length;case"text":return N.text.length;case"raw":return N.source.length}}function x6(N){let F=t2(N);if(!F)return p6();let A=N.documentIndex.regionIndex.get(F.regionId);if(!A)return p6();let M=o0(N.documentIndex.document.blocks,A.blockId);if(!M)return p6();let D=B5(M,A.path,A.semanticRegionId);if(!D)return p6();return wS(D,F.startOffset,F.endOffset)}function wS(N,F,A){return{code:TS(N,F,A),marks:LS(N,F,A)}}function LS(N,F,A){let M=0,D=null,E=($)=>{for(let y of $){let Z=O0(y),Y=M,X=Y+Z;if(M=X,A<=Y||F>=X)continue;if(y.type==="text"){let Q=Math.max(F,Y);if(Math.min(A,X)>Q)D=D===null?new Set(y.marks):new Set(y.marks.filter((J)=>D?.has(J)));continue}if(y.type==="link"){let Q=M;M=Y,E(y.children),M=Q}}};return E(N.children),D?[...D]:[]}function TS(N,F,A){let M=oD(N.children,F,A);return M.hasCode&&M.allCode}function oD(N,F,A){let M={allCode:!0,hasCode:!1},D=0;for(let E of N){let $=O0(E),y=D,Z=y+$;if(D=Z,A<=y||F>=Z)continue;let Y=Math.max(F,y),X=Math.min(A,Z);if(X<=Y)continue;if(E.type==="code"){M.hasCode=!0;continue}if(E.type==="link"){let Q=oD(E.children,Y-y,X-y);M.hasCode||=Q.hasCode,M.allCode&&=Q.allCode;continue}M.allCode=!1}return M}function p6(){return{code:!1,marks:[]}}function w0(N,F){return N.regionIndex.get(F)??null}function eD(N,F,A,M,D={}){let E=w0(N,F);if(!E||A>M)return null;let $=nD(A,E.text.length),y=nD(M,E.text.length);if($===y&&D.allowCollapsed!==!0)return null;return{endOffset:y,region:E,selection:{anchor:{regionId:F,offset:$},focus:{regionId:F,offset:y}},startOffset:$}}function xN(N){return N.anchor.regionId===N.focus.regionId&&N.anchor.offset===N.focus.offset}function Z0(N,F){let A="documentIndex"in N?N.documentIndex:N,M="documentIndex"in N?N.selection:F,D=xN(M),E=tD(A,M.anchor),$=tD(A,M.focus);if(E<=$)return{collapsed:D,end:M.focus,start:M.anchor};return{collapsed:D,end:M.anchor,start:M.focus}}function nD(N,F){return Math.max(0,Math.min(N,F))}function tD(N,F){let A=N.regionOrderIndex.get(F.regionId);if(A===void 0)throw Error(`Unknown canvas region: ${F.regionId}`);return A*rD+F.offset}var d6="rgba(0, 0, 0, 0)";function Q2(N,F,A){let M=N9(N),D=N9(F);return`rgba(${W5(l6(M[0],D[0],A))}, ${W5(l6(M[1],D[1],A))}, ${W5(l6(M[2],D[2],A))}, ${l6(M[3],D[3],A)})`}var P5=new Map([["rgba(0, 0, 0, 0)",[0,0,0,0]]]);function N9(N){let F=P5.get(N);if(F)return F;let A=CS(N)??jS(N)??RS(N)??P5.get("rgba(0, 0, 0, 0)");return P5.set(N,A),A}function CS(N){let F=N.trim();if(!F.startsWith("#"))return null;let A=F.slice(1);if(A.length===3)return[Number.parseInt(`${A[0]}${A[0]}`,16),Number.parseInt(`${A[1]}${A[1]}`,16),Number.parseInt(`${A[2]}${A[2]}`,16),1];if(A.length===6)return[Number.parseInt(A.slice(0,2),16),Number.parseInt(A.slice(2,4),16),Number.parseInt(A.slice(4,6),16),1];return null}function jS(N){let F=/^rgb\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec(N.trim());if(!F)return null;return[Number(F[1]),Number(F[2]),Number(F[3]),1]}function RS(N){let F=/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec(N.trim());if(!F)return null;return[Number(F[1]),Number(F[2]),Number(F[3]),Number(F[4])]}function l6(N,F,A){return N+(F-N)*A}function W5(N){return Math.round(N)}var bS=300,fS=180,uS=1000,vS=500,mS=140,kS=0.1,gS=0.9,hS=2,IS=2;function lN(N){switch(N.kind){case"active-block-flash":return bS;case"text-fade":return fS;case"text-highlight":return uS;case"block-pulse":return vS;case"text-pulse":return mS}}function O5(N,F){let A=F??xS();return N.animations.some((M)=>A-M.startedAt<lN(M))}function F9(N,F){return L5(N,F,"text-highlight",(A)=>A.regionPath)}function A9(N,F){return X9(N,F,"active-block-flash",(A)=>A.blockPath)}function M9(N,F){return L5(N,F,"text-fade",(A)=>A.regionPath)}function D9(N,F){return L5(N,F,"text-pulse",(A)=>A.regionPath)}function E9(N,F){return X9(N,F,"block-pulse",(A)=>A.blockPath)}function $9(N,F,A){let M=new Set([N,F]);for(let D of A){if(D.endOffset<=N||D.startOffset>=F)continue;M.add(Math.max(N,D.startOffset)),M.add(Math.min(F,D.endOffset))}return[...M].sort((D,E)=>D-E)}function w5(N,F,A){return N.find((M)=>M.startOffset<A&&M.endOffset>F)??null}function y9(N,F){return Q2(N,d6,F.progress)}function a6(N,F){return Q2(N,d6,F.progress)}function Z9(N,F){return Q2(F.insertHighlightText,d6,N.progress)}function Y9(N){let F=Math.min(1,N.progress*hS);return kS+gS*pS(F)}function dN(N,F,A){let M=Math.max(0,F.progress*IS-1);return Q2(A.insertHighlightText,N,M)}function L5(N,F,A,M){let D=new Map;for(let E of N.animations){if(E.kind!==A)continue;let $=lN(E),y=F-E.startedAt;if(y>=$)continue;let Z={...E,progress:Math.max(0,Math.min(1,y/$))},Y=M(E),X=D.get(Y);if(X)X.push(Z);else D.set(Y,[Z])}return D}function X9(N,F,A,M){let D=new Map;for(let E of N.animations){if(E.kind!==A)continue;let $=lN(E),y=F-E.startedAt;if(y>=$)continue;D.set(M(E),{...E,progress:Math.max(0,Math.min(1,y/$))})}return D}function pS(N){return 1-(1-N)*(1-N)*(1-N)}function xS(){return performance.now()}function Q9(N,F,A=c6()){if(!F)return N;switch(F.kind){case"text-highlight":return F.endOffset>F.startOffset?r6(N,{...F,startedAt:A}):N;case"text-fade":return F.text.length>0?r6(N,{...F,startedAt:A}):N;case"text-pulse":case"block-pulse":return r6(N,{...F,startedAt:A})}}function S9(N,F,A=c6()){return r6(N,{blockPath:F,kind:"active-block-flash",startedAt:A})}function T5(N,F){return N.filter((A)=>A.startedAt+lN(A)>F)}function c6(){return performance.now()}function J9(N){let F=lS(N);return(F?N.documentIndex.blockIndex.get(F.blockId)??null:null)?.path??""}function lS(N){return N.documentIndex.regionIndex.get(N.selection.focus.regionId)??null}function r6(N,F){let A=T5(N.animations,F.startedAt);return{...N,animations:[...A,F]}}function e2(N,F,A,M){return j5(NN(N.inlines,F,A,M))}function NN(N,F,A,M){let E=dS(N,F,A,{didInsert:!1,generatedInlineCount:0,replacementText:M});return iS(oS(E))}function j5(N){let F=[];for(let A=0;A<N.length;A+=1){let M=N[A];if(M.link){let E=[],$=M.link;while(A<N.length&&R5(N[A].link,$)){let y=q9(N[A]);if(y)E.push(y);A+=1}if(A-=1,E.length>0)F.push(o1({children:W0(E),title:$.title,url:$.url}));continue}let D=q9(M);if(D)F.push(D)}return W0(F)}function dS(N,F,A,M){let D=[];for(let[E,$]of N.entries()){if(!M.didInsert&&F===A&&F===$.start)C5(D,M,V9(N[E-1]??null,$));if(A<=$.start||F>=$.end){D.push(s6($));continue}let y=Math.max(0,F-$.start),Z=Math.min($.text.length,A-$.start),Y=!M.didInsert&&M.replacementText.length>0?M.replacementText:"",X=aS($,y,Z,Y,M);if(y!==Z||Y.length>0)M.didInsert=!0;D.push(...X)}if(!M.didInsert)C5(D,M,V9(N.at(-1)??null,null));return D}function aS(N,F,A,M,D){switch(N.kind){case"text":case"code":case"raw":return rS(N,F,A,M);case"lineBreak":return cS(N,F,A,M,D);case"image":case"mention":return sS(N,F,A,M)}}function rS(N,F,A,M){let D=N.text.slice(0,F)+M+N.text.slice(A);return D.length>0?[{...s6(N),text:D}]:[]}function cS(N,F,A,M,D){if(F===A)return[s6(N)];let E=[];if(M.length>0)C5(E,D,N.link);return E}function sS(N,F,A,M){if(F===0&&A===N.text.length)return M.length>0?[U9(M,N.link,0)]:[];return[s6(N)]}function C5(N,F,A){if(F.replacementText.length===0){F.didInsert=!0;return}N.push(U9(F.replacementText,A,F.generatedInlineCount)),F.generatedInlineCount+=1,F.didInsert=!0}function U9(N,F,A){return{id:`generated:${A}`,image:null,inlineCode:!1,kind:"text",link:F,marks:[],mention:null,originalType:null,text:N}}function V9(N,F){return N?.link&&F?.link&&R5(N.link,F.link)?N.link:null}function s6(N){return{id:N.id,image:N.image,inlineCode:N.inlineCode,kind:N.kind,link:N.link,marks:N.marks,mention:N.mention,originalType:N.originalType,text:N.text}}function iS(N){let F=[],A=0;for(let M of N){let D=A,E=D+M.text.length;F.push({...M,end:E,start:D}),A=E}return F}function oS(N){let F=[];for(let A of N){let M=F.at(-1);if(M&&nS(M,A)){F[F.length-1]={...M,text:M.text+A.text};continue}F.push(A)}return F}function nS(N,F){return N.kind===F.kind&&N.inlineCode===F.inlineCode&&R5(N.link,F.link)&&NJ(N.image,F.image)&&FJ(N.mention,F.mention)&&N.originalType===F.originalType&&N.marks.join(",")===F.marks.join(",")}function q9(N){switch(N.kind){case"lineBreak":return y1();case"image":return N.image?tS(N.image):null;case"mention":return N.mention?eS(N.mention):null;case"code":return O1(N.text);case"text":return N.text.length>0?u0(N.text,N.marks):null;case"raw":return cF({originalType:N.originalType??"raw",source:N.text})}}function tS(N){return w1({alt:N.alt,title:N.title,url:N.url,width:N.width})}function eS(N){return C2({name:N.name,userId:N.userId})}function R5(N,F){return N?.url===F?.url&&N?.title===F?.title}function NJ(N,F){return N?.url===F?.url&&N?.title===F?.title&&N?.alt===F?.alt&&N?.width===F?.width}function FJ(N,F){return N?.userId===F?.userId&&N?.name===F?.name}function aN(N,F,A){if(N.type==="table")return null;if(N.id===F.blockId)return AJ(N,F,A);return K9(N,(M)=>DJ(M,F,A))}function rN(N,F,A){if(N.type==="table")return null;if(N.id===F.blockId)return MJ(N,F,A);return K9(N,(M)=>EJ(M,F,A))}function S2(N,F){if(N.id===F.blockId)return!0;let A=C0(N);return A!==null&&A.some((M)=>S2(M,F))}function AJ(N,F,A){if(A===0)return null;switch(N.type){case"heading":case"paragraph":return k0(N,e2(F,A,F.text.length,""));case"code":return HN(N,F.text.slice(0,A));case"raw":return _N(N,F.text.slice(0,A));default:return null}}function MJ(N,F,A){if(A===F.text.length)return null;switch(N.type){case"heading":case"paragraph":return k0(N,e2(F,0,A,""));case"code":return HN(N,F.text.slice(A));case"raw":return _N(N,F.text.slice(A));default:return null}}function K9(N,F){let A=C0(N);return A?C1(N,F(A)):null}function DJ(N,F,A){let M=N.findIndex(($)=>S2($,F));if(M===-1)return[];let D=N.slice(0,M),E=aN(N[M],F,A);return E?[...D,E]:D}function EJ(N,F,A){let M=N.findIndex(($)=>S2($,F));if(M===-1)return[];let D=N.slice(M+1),E=rN(N[M],F,A);return E?[E,...D]:D}function _9(N,F,A){let M=[],D=0,E={childIndices:[],offset:0},$="",y=N!==null;if(N)M.push(N),E=z9(N);let Z=0;if(N&&F.length>0){let Y=F[0];if(i6(N)&&Y.type==="paragraph"){let X=b5(N,N.children,Y.children);M[M.length-1]=X,E={childIndices:[],offset:X.plainText.length},Z=1,$=Y.plainText}else if(G9(N,Y)){let X=H9(N,Y);M[M.length-1]=X,E=B9(X),Z=1}}for(let Y=Z;Y<F.length;Y+=1){let X=F[Y];M.push(X),D=M.length-1,E=z9(X)}if(A){let Y=M.length-1,X=M[Y]??null,Q=Z>=F.length&&N!==null,S=null;if(X){if(!Q&&X.type==="paragraph"&&i6(A)){if(S=b5(A,X.children,A.children),N===null&&F.length===1)y=!0,$=X.plainText}else if(Q&&i6(X)&&i6(A))S=b5(X,X.children,A.children);else if(G9(X,A))S=H9(X,A),E={childIndices:[C0(X).length-1],offset:"end"}}else if(N===null&&F.length===0)y=!0;if(S)M[Y]=S;else M.push(A)}return{blocks:M,caretLocalIndex:D,caretChildIndices:E.childIndices,caretOffset:E.offset,startRegionInsertedText:$,startRegionPreservedAtRoot0:y}}function z9(N){return C0(N)?B9(N):{childIndices:[],offset:N.plainText.length}}function B9(N){return{childIndices:[C0(N).length-1],offset:"end"}}function b5(N,F,A){return k0(N,W0([...F,...A]))}function i6(N){return N!==null&&(N.type==="heading"||N.type==="paragraph")}function G9(N,F){return N.type===F.type&&C0(N)!==null}function H9(N,F){let A=C0(N),M=C0(F);return C1(N,[...A,...M])}function W9(N,F,A){let M=Z0(N,F);if(M.start.regionId===M.end.regionId)return $J(N,M,A);let D=A.length>0?[F0(A)]:[];return f5(N,F,D)}function f5(N,F,A){let M=Z0(N,F),D=w0(N,M.start.regionId),E=w0(N,M.end.regionId);if(!D||!E)throw Error("Unknown selection endpoints.");let $=N.document.blocks[D.rootIndex],y=N.document.blocks[E.rootIndex];if(!$||!y)throw Error("Unknown root blocks for selection.");let Z=aN($,D,M.start.offset),Y=rN(y,E,M.end.offset),X=_9(Z,A,Y),Q=X.blocks.length>0?X.blocks:[F0("")],S=D.rootIndex,J=E.rootIndex-D.rootIndex+1,V=A2(N.document,S,J,Q),K=s2(N,V,S,J),q=D===E?M.end.offset:D.text.length;return{documentIndex:X.startRegionPreservedAtRoot0?O9(N,K,D,M.start.offset,q,X.startRegionInsertedText):K,selection:j0(S+X.caretLocalIndex,X.caretChildIndices,X.caretOffset)}}function $J(N,F,A){let M=w0(N,F.start.regionId);if(!M)throw Error(`Unknown region: ${F.start.regionId}`);let D=m6(N,M.blockId,(Z)=>yJ(Z,M,F.start.offset,F.end.offset,A));if(!D)throw Error(`Failed to replace block for region: ${M.id}`);let E=s2(N,D,M.rootIndex,1),$=O9(N,E,M,F.start.offset,F.end.offset,A),y=r2($,M.path);if(!y)throw Error(`Failed to remap region after replacement: ${M.path}`);return{documentIndex:$,selection:H5(y.id,F.start.offset+A.length)}}function yJ(N,F,A,M,D){switch(N.type){case"heading":case"paragraph":return k0(N,e2(F,A,M,D));case"code":return HN(N,P9(F,A,M,D));case"table":return ZJ(N,F,A,M,D);case"raw":return _N(N,P9(F,A,M,D));default:throw Error(`Region text replacement is not supported for block type: ${N.type}`)}}function ZJ(N,F,A,M,D){let E=F.tableCellPosition?.rowIndex,$=F.tableCellPosition?.cellIndex;if(E===void 0||$===void 0)throw Error(`Unable to resolve table cell position for region: ${F.id}`);let y=e2(F,A,M,D),Z=N.rows.map((Y,X)=>{if(X!==E)return Y;let Q=Y.cells.map((S,J)=>J===$?L1(y):S);return{...Y,cells:Q}});return a0(N,Z)}function P9(N,F,A,M){return NN(N.inlines,F,A,M).map((D)=>D.text).join("")}function O9(N,F,A,M,D,E){if(N.document.comments.length===0)return F;let $=U5(N,F,A,M,D,E);return $===F.document.comments?F:v6(F,{...F.document,comments:$})}function FN(N){let F=c2(N),A=C9(F);return{animations:[],documentIndex:F,future:[],history:[],selection:{anchor:A,focus:A}}}function S1(N){let F=h0(N.documentIndex);return v2(VM(N.documentIndex.document.blocks),F.threads,N.documentIndex.document.frontMatter)}function u5(N,F){if(!F)return null;let A=YJ(N,F);return A?Q9(A,F.animation):null}function YJ(N,F){switch(F.kind){case"keep-state":return N;case"set-selection":return L0(N,F.selection);case"replace-block":{let A=m6(N.documentIndex,F.blockId,()=>F.block);return A?cN(N,c2(A),F.selection??null):null}case"splice-blocks":{let A=A2(N.documentIndex.document,F.rootIndex,F.count??1,F.blocks);return cN(N,c2(A),F.selection??null)}case"splice-text":{let A=W9(N.documentIndex,F.range??N.selection,F.text);return cN(N,A.documentIndex,F.selection??A.selection)}case"splice-fragment":{let A=f5(N.documentIndex,N.selection,F.blocks);return cN(N,A.documentIndex,A.selection)}case"splice-comments":{let A=XM(N.documentIndex.document,F.index,F.count,F.threads);return cN(N,v6(N.documentIndex,A),null)}}}function cN(N,F,A){let M=XJ(N,F),D=pN(M.documentIndex,A)??N.selection,E=j9(N,M,D);return L0(M,D,E)}function L0(N,F,A){let M="regionId"in F?{anchor:o6(N.documentIndex,F),focus:o6(N.documentIndex,F)}:{anchor:o6(N.documentIndex,F.anchor),focus:o6(N.documentIndex,F.focus)},D={...N,selection:M};return A??j9(N,D)?S9(D,J9(D)):D}function I0(N,F,A,M){let D={regionId:F,offset:A};return L0(N,M?{anchor:N.selection.anchor,focus:D}:D)}function XJ(N,F){let A=C9(F);return{animations:T5(N.animations,c6()),documentIndex:F,future:[],history:[...N.history,{document:N.documentIndex.document,selection:N.selection}],selection:{anchor:A,focus:A}}}function v5(N){let F=N.history.at(-1);if(!F)return N;return T9(F,{future:[L9(N),...N.future],history:N.history.slice(0,-1)})}function m5(N){let F=N.future[0];if(!F)return N;return T9(F,{future:N.future.slice(1),history:[...N.history,L9(N)]})}function L9(N){return{document:N.documentIndex.document,selection:N.selection}}function T9(N,F){return{animations:[],documentIndex:c2(N.document),future:F.future,history:F.history,selection:N.selection}}function C9(N){return N.regions[0]?{regionId:N.regions[0].id,offset:0}:{regionId:"empty",offset:0}}function o6(N,F){let A=w0(N,F.regionId);if(!A)return F;return{regionId:A.id,offset:Math.max(0,Math.min(F.offset,A.text.length))}}function j9(N,F,A){let M=w9(N.documentIndex,N.selection),D=w9(F.documentIndex,A??F.selection);return D!==null&&D!==M}function w9(N,F){let A=N.regionIndex.get(F.focus.regionId),M=A?N.blockIndex.get(A.blockId)??null:null;if(!A||!M?.path)return null;return M.type==="table"?`cell:${A.path}`:`block:${M.path}`}function g5(N,F,A){return R9(N,{endOffset:A,regionId:N.selection.focus.regionId,startOffset:F})}function R9(N,F){return eD(N.documentIndex,F.regionId,F.startOffset,F.endOffset,{allowCollapsed:!0})}function n6(N,F){let A=R9(N,F);return A?b9(N,A):null}function b9(N,F){let A=_5(N.documentIndex,F.region.id);return A?{...F,inlineContainer:A}:null}function H1(N){let F=Z0(N);if(F.start.regionId!==F.end.regionId)return null;let A=g5(N,F.start.offset,F.end.offset);return A?b9(N,A):null}function t6(N){return f9(N.documentIndex,N.selection)}function f9(N,F){let A=N.regionIndex.get(F.anchor.regionId);if(!A)return{kind:"unsupported"};if(A.blockType==="code"){let y=N.blockIndex.get(A.blockId);return y?{kind:"code",region:A,rootIndex:y.rootIndex,selection:F,...iN(N,A,F)}:{kind:"unsupported"}}let M=v9(N,A.id,F);if(M)return{kind:"tableCell",...M,...iN(N,A,F)};let D=e6(N,F);if(D)return{kind:"listItem",...D};let E=QJ(N,F);if(E)return{kind:"blockquoteTextBlock",...E};let $=AN(N,F);if($)return{kind:"rootTextBlock",...$};return{kind:"unsupported"}}function u9(N,F){let{documentIndex:A,selection:M}=N,D=f9(A,M),E=D.kind==="unsupported"?!1:F==="backward"?D.atStart:D.atEnd;switch(D.kind){case"rootTextBlock":return{...D,kind:"rootTextBlock",direction:F,atBoundary:E,previousRoot:A.document.blocks[D.rootIndex-1]??null,nextRoot:A.document.blocks[D.rootIndex+1]??null};case"listItem":return{...D,kind:"listItem",direction:F,atBoundary:E,previousItem:D.list.items[D.itemIndex-1]??null,nextItem:D.list.items[D.itemIndex+1]??null,previousRoot:A.document.blocks[D.rootIndex-1]??null,nextRoot:A.document.blocks[D.rootIndex+1]??null};case"blockquoteTextBlock":return{...D,kind:"blockquoteTextBlock",direction:F,atBoundary:E,previousSibling:D.quote.children[D.childIndex-1]??null,nextSibling:D.quote.children[D.childIndex+1]??null};default:return{kind:"unsupported",direction:F,atBoundary:!1}}}function k5(N,F,A){let M=F?N.blockIndex.get(F)??null:null;while(M){if(M.type===A)return M;let D=M.parentBlockId;M=D?N.blockIndex.get(D)??null:null}return null}function g1(N){let F=N.split("."),A=[];for(let M=0;M<F.length-1;M+=1)if(F[M]==="children"){let D=Number(F[M+1]);if(Number.isInteger(D))A.push(D)}return A}function AN(N,F){let A=N.regionIndex.get(F.anchor.regionId);if(!A)return null;let M=N.blockIndex.get(A.blockId);if(!M)return null;let D=M.rootIndex,E=N.document.blocks[D];if(!E||E.type!=="heading"&&E.type!=="paragraph")return null;return{...iN(N,A,F),block:E,region:A,rootIndex:D}}function QJ(N,F){let A=N.regionIndex.get(F.anchor.regionId);if(!A)return null;let M=N.blockIndex.get(A.blockId),D=k5(N,M?.id??null,"blockquote");if(!M||!D||M.parentBlockId!==D.id)return null;let E=D.rootIndex,$=N.document.blocks[E];if(!$||$.type!=="blockquote")return null;let y=$.children.findIndex((Y)=>Y.id===M.id),Z=$.children[y];if(!Z||Z.type!=="heading"&&Z.type!=="paragraph")return null;return{...iN(N,A,F),block:Z,blockChildIndices:g1(M.path),childIndex:y,region:A,quote:$,rootIndex:E}}function sN(N,F){return o0(N.document.blocks,F)}function h5(N){return e6(N.documentIndex,N.selection)}function e6(N,F){let A=N.regionIndex.get(F.anchor.regionId);if(!A)return null;let M=N.blockIndex.get(A.blockId),D=k5(N,M?.id??null,"listItem"),E=k5(N,M?.id??null,"list");if(!M||!D||!E)return null;let $=sN(N,E.id);if(!$||$.type!=="list")return null;let y=$.items.findIndex((V)=>V.id===D.id),Z=$.items[y];if(!Z)return null;let Y=E.parentBlockId?N.blockIndex.get(E.parentBlockId)??null:null,X=Y?.parentBlockId?N.blockIndex.get(Y.parentBlockId)??null:null,Q=Y?.type==="listItem"?sN(N,Y.id):null,S=X?.type==="list"?sN(N,X.id):null,J=S?.type==="list"&&Q?S.items.findIndex((V)=>V.id===Q.id):-1;return{...iN(N,A,F),region:A,item:Z,itemChildIndices:g1(D.path),itemIndex:y,list:$,listChildIndices:g1(E.path),parentItem:Q?.type==="listItem"?Q:null,parentItemChildIndices:Y?.type==="listItem"?g1(Y.path):null,parentItemIndex:J>=0?J:null,parentList:S?.type==="list"?S:null,parentListChildIndices:X?.type==="list"?g1(X.path):null,rootIndex:E.rootIndex}}function MN(N){return v9(N.documentIndex,N.selection.focus.regionId,N.selection)}function v9(N,F,A){let M=N.regionIndex.get(F);if(!M)return null;let D=N.tableCellIndex.get(M.id),E=N.blockIndex.get(M.blockId),$=E?.type==="table"?N.document.blocks[E.rootIndex]:null,y=_5(N,M.id);if(!D||!E||!$||$.type!=="table"||!y||y.kind!=="tableCell")return null;return{cellIndex:D.cellIndex,documentIndex:N,inlineContainer:y,region:M,rootIndex:E.rootIndex,rowIndex:D.rowIndex,selection:A,table:$}}function iN(N,F,A){let M=Z0(N,A),D=M.start.regionId===F.id?M.start.offset:A.anchor.offset;return{atEnd:D===F.text.length,atStart:D===0,empty:F.text.length===0,offset:D}}function oN(N,F,A){return n1({checked:F,children:[F0(N)],spread:A})}function m9(N,F){let A=N.children[0];if(!A||A.type!=="paragraph")return null;return Z1(N,[F0(F),...N.children.slice(1)])}function k9(N,F){return F.reduce(Y1,R2(N))}function p0(N,F,A,M){let D=N3(N.children,F,A,M),E=M.reduce((y,Z)=>y+O0(Z),0),$=F+E;return nN(N,D,$,$)}function nN(N,F,A,M){switch(N.kind){case"inlineBlock":return{block:k0(N.block,F),blockId:N.block.id,selection:g9(r0(N.path),A,M)};case"tableCell":{let D=L1(F),E=N.block.rows.map(($)=>({...$,cells:$.cells.map((y)=>y.id===N.cell.id?D:y)}));return{block:a0(N.block,E),blockId:N.block.id,selection:g9(N.path,A,M)}}}}function g9(N,F,A){return{endOffset:A,kind:"region-range-path",path:N,startOffset:F}}function N3(N,F,A,M){let D=[],E=0,$=!1;for(let y of N){let Z=O0(y),Y=E,X=Y+Z;if(E=X,A<=Y||F>=X){D.push(y);continue}if(!$)D.push(...SJ(y,Math.max(0,F-Y))),D.push(...M),$=!0;D.push(...JJ(y,Math.min(Z,A-Y)))}if(!$)D.push(...M);return W0(D)}function SJ(N,F){if(F<=0)return[];return I5(N,0,F)}function JJ(N,F){let A=O0(N);if(F>=A)return[];return I5(N,F,A)}function I5(N,F,A){if(F>=A)return[];switch(N.type){case"text":{let M=N.text.slice(F,A);return M.length>0?[u0(M,N.marks)]:[]}case"code":return[O1(N.code.slice(F,A))];case"link":{let M=W0(x5(N.children,F,A));return M.length>0?[{...N,children:M}]:[]}default:return[]}}function p5(N,F,A){let M=0,D="";for(let E of N){let $=O0(E),y=M,Z=y+$;if(M=Z,A<=y||F>=Z)continue;D+=VJ(E,Math.max(0,F-y),Math.min($,A-y))}return D}function x5(N,F,A){let M=[],D=0;for(let E of N){let $=O0(E),y=D,Z=y+$;if(D=Z,A<=y||F>=Z)continue;M.push(...I5(E,Math.max(0,F-y),Math.min($,A-y)))}return M}function VJ(N,F,A){if(F>=A)return"";switch(N.type){case"lineBreak":return`
|
|
26
|
+
`.slice(F,A);case"image":case"mention":return Y2.slice(F,A);case"code":return N.code.slice(F,A);case"link":return p5(N.children,F,A);case"text":return N.text.slice(F,A);case"raw":return N.source.slice(F,A)}}function l5(N,F,A,M){let D=qJ(N.children,F,A,M);if(D===null)return null;let E=W0(h9(N.children,F,A,M,D));return E.length>0?nN(N,E,F,A):null}function qJ(N,F,A,M){let D=0,E=!1,$=!0,y=(Z)=>{for(let Y of Z){let X=O0(Y),Q=D,S=Q+X;if(D=S,A<=Q||F>=S)continue;if(Y.type==="text"){let J=Math.max(F,Q);if(Math.min(A,S)>J)E=!0,$&&=Y.marks.includes(M);continue}if(Y.type==="link"){let J=D;D=Q,y(Y.children),D=J}}};return y(N),E?$:null}function h9(N,F,A,M,D){let E=[],$=0;for(let y of N){let Z=$,Y=O0(y),X=Z+Y;if($=X,A<=Z||F>=X){E.push(y);continue}if(y.type==="text"){E.push(...UJ(y,Math.max(0,F-Z),Math.min(Y,A-Z),M,D));continue}if(y.type==="link"){let Q=W0(h9(y.children,Math.max(0,F-Z),Math.min(Y,A-Z),M,D));if(Q.length>0)E.push({...y,children:Q});continue}E.push(y)}return E}function UJ(N,F,A,M,D){let E=N.text.slice(0,F),$=N.text.slice(F,A),y=N.text.slice(A),Z=D?N.marks.filter((Q)=>Q!==M):KJ(N.marks,M),Y=[],X=(Q,S)=>{if(Q.length>0)Y.push(u0(Q,S))};return X(E,N.marks),X($,Z),X(y,N.marks),Y}function KJ(N,F){return N.includes(F)?N:[...N,F].sort()}function d5(N,F,A){if(F===A)return null;let M=zJ(N.children,F,A);return M!==N.children&&M.length>0?nN(N,M,F,A):null}function zJ(N,F,A){let M=I9(N,F,A);if(M){let E=M.code.length>0?[u0(M.code,[])]:[];return N3(N,F,A,E)}let D=p5(N,F,A);if(D.length===0)return N;return N3(N,F,A,[O1(D)])}function I9(N,F,A){let M=0;for(let D of N){let E=O0(D),$=M,y=$+E;if(M=y,F===$&&A===y&&D.type==="code")return D;if(D.type==="link"){let Z=I9(D.children,Math.max(0,F-$),Math.min(E,A-$));if(Z)return Z}}return null}function a5(N,F,A){let{image:M}=F,D=p0(N,F.start,F.end,[w1({alt:M.alt,title:M.title,url:M.url,width:A})]);return{kind:"replace-block",block:D.block,blockId:D.blockId}}function r5(N,F,A,M){let D=x5(N.children,F,A);if(D.length===0)return null;return p0(N,F,A,[o1({children:D,title:null,url:M})])}function c5(N,F,A,M){let D=p9(N.children,F,A);if(!D)return null;return p0(N,F,A,[o1({children:D.children,title:D.title,url:M})])}function s5(N,F,A){let M=p9(N.children,F,A);if(!M)return null;return p0(N,F,A,M.children)}function p9(N,F,A){let M=0;for(let D of N){let E=O0(D);if(D.type==="link"&&M===F&&M+E===A)return D;M+=E}return null}function i5(N,F,A,M=""){return{kind:"replace-block",...p0(N.inlineContainer,N.startOffset,N.endOffset,[C2({name:A,userId:F}),...M.length>0?[u0(M)]:[]])}}function DN(N,F){let A=F(N.inlineContainer,N.startOffset,N.endOffset);return A?{kind:"replace-block",block:A.block,blockId:A.blockId,selection:A.selection}:null}function o5(N,F){return{kind:"replace-block",...p0(N.inlineContainer,N.startOffset,N.endOffset,[F])}}function x9(N,F){return{kind:"replace-block",...p0(N.inlineContainer,N.startOffset,N.endOffset,F)}}function F3(N){return GJ.test(N)}var GJ=/[\uFE0F\u{1F1E6}-\u{1F1FF}\p{Extended_Pictographic}]/u;function l9(N,F,A){if(A===".")return HJ(N,F);return J2(N,F,A)}function J2(N,F,A){if(A.length===0||F3(A))return;let M=a9(N,F);if(!M)return;return n5(M.region,M.normalized.start.offset,A)}function n5(N,F,A){if(A.length===0||F3(A))return;return{endOffset:F+A.length,kind:"text-highlight",regionPath:N.path,startOffset:F}}function d9(N,F,A){let M=N.text.slice(F,A);if(M.length===0||F3(M))return;return N.inlines.some((E)=>E.start<=F&&E.end>=A&&E.kind==="text"&&E.link===null&&E.marks.length===0)?{kind:"text-fade",regionPath:N.path,startOffset:F,text:M}:void 0}function HJ(N,F){let A=a9(N,F);if(!A)return;return{kind:"text-pulse",offset:A.normalized.start.offset,regionPath:A.region.path}}function a9(N,F){let A=Z0(N,F);if(A.start.regionId!==A.end.regionId)return null;let M=w0(N,A.start.regionId);return M?{normalized:A,region:M}:null}var _J={"(":")","[":"]","{":"}"};function r9(N,F,A){if(A.length!==1)return null;let M=_J[A];if(!M||!xN(F))return null;let D=N.regionIndex.get(F.focus.regionId);if(!D)return null;let E=`${A}${M}`;return{animation:J2(N,F,E),kind:"splice-text",selection:{kind:"region-path",offset:F.focus.offset+A.length,path:D.path},text:E}}function c9(N,F,A){if(F.anchor.regionId!==F.focus.regionId)return null;let M=N.regionIndex.get(F.anchor.regionId);if(!M)return null;let D=PJ(N,F,M);if(!D)return null;let{start:E,end:$}=BJ(N,F);return WJ(M,A,E,$,D)}function BJ(N,F){if(F.anchor.offset===F.focus.offset)return{start:F.anchor.offset,end:F.anchor.offset};let A=Z0(N,F);return{start:A.start.offset,end:A.end.offset}}function PJ(N,F,A){switch(A.blockType){case"heading":{let M=AN(N,F);return M?.block.type==="heading"?{kind:"heading",rootIndex:M.rootIndex}:null}case"paragraph":{let M=e6(N,F);if(M)return{kind:"list-item",item:M};let D=AN(N,F);return D?.block.type==="paragraph"?{kind:"root-paragraph",rootIndex:D.rootIndex}:null}default:return null}}function WJ(N,F,A,M,D){if(D.kind==="root-paragraph"&&!OJ(N,F,M))return null;let E=N.text.slice(0,A)+F+N.text.slice(M);switch(D.kind){case"root-paragraph":return t5(wJ,E,D);case"heading":return t5(LJ,E,D);case"list-item":return t5(TJ,E,D.item)}}function OJ(N,F,A){let M=A<N.text.length?N.text:F;return M.length>0&&/\s/.test(M[M.length-1])}function t5(N,F,A){for(let{pattern:M,apply:D}of N){let E=M.exec(F);if(E)return D(E,A)}return null}var wJ=[{pattern:EN(/(?:[-+*]\s+)?\[[ xX]?\]/,{allowIndent:!0}),apply:(N,{rootIndex:F})=>e5(F,{checked:N[1].toLowerCase().includes("x"),ordered:!1,start:null})},{pattern:EN(/[-+*]/,{allowIndent:!0}),apply:(N,{rootIndex:F})=>e5(F,{checked:null,ordered:!1,start:null})},{pattern:EN(/\d+\./,{allowIndent:!0}),apply:(N,{rootIndex:F})=>e5(F,{checked:null,ordered:!0,start:Number(N[1].slice(0,-1))})},{pattern:EN(/#{1,6}/,{allowIndent:!1}),apply:(N,{rootIndex:F})=>({kind:"splice-blocks",blocks:[T2({depth:N[1].length,text:""})],rootIndex:F,selection:$0(F)})},{pattern:EN(/>/,{allowIndent:!1}),apply:(N,{rootIndex:F})=>({kind:"splice-blocks",blocks:[d0([F0("")])],rootIndex:F,selection:j0(F,[0])})},{pattern:EN(/---/,{allowIndent:!1}),apply:(N,{rootIndex:F})=>({kind:"splice-blocks",blocks:[sF(),F0("")],rootIndex:F,selection:$0(F+1)})}],LJ=[{pattern:A3(/#{1,6}/),apply:(N,{rootIndex:F})=>({kind:"splice-blocks",blocks:[T2({depth:N[1].length,text:N[2]})],rootIndex:F,selection:$0(F)})}],TJ=[{pattern:A3(/\d+\./),apply:(N,F)=>N8(N,F,{ordered:!0,start:1,checked:F.item.checked})},{pattern:A3(/\[[ xX]?\]/),apply:(N,F)=>N8(N,F,{ordered:!1,start:null,checked:N[1].toLowerCase().includes("x")})},{pattern:A3(/[-+*]/),apply:(N,F)=>N8(N,F,{ordered:!1,start:null,checked:null})}];function EN(N,F){let A=F.allowIndent?"\\s*":"";return new RegExp(`^${A}(${N.source})\\s$`)}function A3(N){return new RegExp(`^\\s*(${N.source})\\s(.+)$`)}function e5(N,F){return{kind:"splice-blocks",blocks:[t1({items:[n1({checked:F.checked,children:[F0("")],spread:!1})],ordered:F.ordered,spread:!1,start:F.start})],rootIndex:N,selection:j0(N,[0,0])}}function N8(N,F,A){let M=m9(F.item,N[2]);if(!M)return null;return{kind:"replace-block",block:H0(F.list,F.list.items.map((D,E)=>E===F.itemIndex?{...M,checked:A.checked}:D),{ordered:A.ordered,start:A.start}),blockId:F.list.id,selection:j0(F.rootIndex,[...F.listChildIndices,F.itemIndex,0])}}function s9(N,F,A){return r9(N,F,A)??c9(N,F,A)??{animation:l9(N,F,A),kind:"splice-text",text:A}}function i9(N,F){let A=N.region.text.length,M=N.region.text.slice(0,F),D=N.region.text.slice(F),E=F===0&&A>0?N.rootIndex:N.rootIndex+1;return{kind:"splice-blocks",blocks:e9(N.block,M,D,F,A),rootIndex:N.rootIndex,selection:$0(E)}}function o9(N,F){let A=N.region.text,M=A.slice(0,F),D=A.slice(F),E=e9(N.block,M,D,F,A.length),$=F===0?N.blockChildIndices:[...N.blockChildIndices.slice(0,-1),N.blockChildIndices.at(-1)+1];return{kind:"splice-blocks",blocks:[d0([...N.quote.children.slice(0,N.childIndex),...E,...N.quote.children.slice(N.childIndex+1)])],rootIndex:N.rootIndex,selection:j0(N.rootIndex,$)}}function n9(N,F){if(F!==0||N.region.text.length!==0||N.block.type!=="paragraph")return null;let A=N.quote.children.slice(0,N.childIndex),M=N.quote.children.slice(N.childIndex+1),D=[];if(A.length>0)D.push(d0(A));if(D.push(F0("")),M.length>0)D.push(d0(M));return{kind:"splice-blocks",blocks:D,rootIndex:N.rootIndex,selection:$0(N.rootIndex+(A.length>0?1:0))}}function F8(N,F){if(N.block.type!=="heading")return null;let A=Math.max(1,Math.min(6,N.block.depth+F));if(A===N.block.depth)return{kind:"keep-state"};return{kind:"splice-blocks",blocks:[T2({depth:A,text:N.block.plainText})],rootIndex:N.rootIndex,selection:$0(N.rootIndex,N.offset)}}function t9(N){if(N.block.type!=="paragraph")return null;return{kind:"splice-blocks",blocks:[d0([N.block])],rootIndex:N.rootIndex,selection:j0(N.rootIndex,[0],N.offset)}}function e9(N,F,A,M,D){if(M===0)return[F0(""),N];if(M===D)return[N,F0("")];return[N.type==="heading"?T2({depth:N.depth,text:F}):F0(F),F0(A)]}function tN(N,F,A,M=0){return j0(N,[...F,A,0],M)}function A8(N,F){let A=N.region.text,M=N.item,D=typeof M.checked==="boolean"?!1:M.checked;if(F===0){let Y=oN("",D,M.spread);return{kind:"replace-block",block:H0(N.list,[...N.list.items.slice(0,N.itemIndex),Y,M,...N.list.items.slice(N.itemIndex+1)]),blockId:N.list.id,animation:D3(M3(Y,N.rootIndex,[...N.listChildIndices,N.itemIndex])),selection:tN(N.rootIndex,N.listChildIndices,N.itemIndex)}}if(F===A.length){let Y=oN("",D,M.spread);return{kind:"replace-block",block:H0(N.list,[...N.list.items.slice(0,N.itemIndex+1),Y,...N.list.items.slice(N.itemIndex+1)]),blockId:N.list.id,animation:D3(M3(Y,N.rootIndex,[...N.listChildIndices,N.itemIndex+1])),selection:tN(N.rootIndex,N.listChildIndices,N.itemIndex+1)}}let E=A.slice(0,F),$=A.slice(F),y=oN($,D,M.spread),Z=Z1(M,[F0(E)]);return{kind:"replace-block",block:H0(N.list,[...N.list.items.slice(0,N.itemIndex),Z,y,...N.list.items.slice(N.itemIndex+1)]),blockId:N.list.id,animation:D3(M3(y,N.rootIndex,[...N.listChildIndices,N.itemIndex+1])),selection:tN(N.rootIndex,N.listChildIndices,N.itemIndex+1)}}function N7(N,F){if(F!==0||N.region.text.length!==0)return A8(N,F);if(N.parentItem&&N.parentItemIndex!==null&&N.parentItemChildIndices&&N.parentList&&N.parentListChildIndices)return CJ(N);let A=N.list.items.slice(0,N.itemIndex),M=N.list.items.slice(N.itemIndex+1),D=[];if(A.length>0)D.push(H0(N.list,A));if(D.push(F0("")),M.length>0)D.push(H0(N.list,M));return{kind:"splice-blocks",blocks:D,rootIndex:N.rootIndex,selection:$0(N.rootIndex+(A.length>0?1:0))}}function F7(N){if(N.itemIndex===0)return null;let F=N.list.items[N.itemIndex-1];if(!F)return null;let A=jJ(F,N.item,N);return{kind:"replace-block",block:H0(N.list,N.list.items.flatMap((M,D)=>{if(D===N.itemIndex-1)return[A.item];if(D===N.itemIndex)return[];return[M]})),blockId:N.list.id,selection:j0(N.rootIndex,A.regionChildIndices)}}function A7(N){return M7(N,()=>({insertedItem:N.item}))}function M8(N,F){let A=N.itemIndex+F;if(A<0||A>=N.list.items.length)return null;let M=[...N.list.items],[D]=M.splice(N.itemIndex,1);if(!D)return null;return M.splice(A,0,D),{kind:"replace-block",block:H0(N.list,M),blockId:N.list.id,selection:tN(N.rootIndex,N.listChildIndices,A)}}function CJ(N){return M7(N,(F)=>{let A=typeof F.checked==="boolean"?!1:F.checked;return{insertedItem:oN("",A,F.spread),trackInsertedPath:!0}})}function M7(N,F){if(!N.parentItem||N.parentItemIndex===null||!N.parentItemChildIndices||!N.parentList||!N.parentListChildIndices)return null;let A=N.list.items.filter((Z,Y)=>Y!==N.itemIndex),M=N.parentItem.children.flatMap((Z)=>{if(Z.type!=="list"||Z.id!==N.list.id)return[Z];if(A.length===0)return[];return[H0(N.list,A)]}),D=Z1(N.parentItem,M),{insertedItem:E,trackInsertedPath:$=!1}=F(N.parentItem),y=$?M3(E,N.rootIndex,[...N.parentListChildIndices,N.parentItemIndex+1]):void 0;return{kind:"replace-block",block:H0(N.parentList,[...N.parentList.items.slice(0,N.parentItemIndex),D,E,...N.parentList.items.slice(N.parentItemIndex+1)]),blockId:N.parentList.id,animation:D3(y),selection:tN(N.rootIndex,N.parentListChildIndices,N.parentItemIndex+1)}}function M3(N,F,A){return typeof N.checked==="boolean"?void 0:k9(F,A)}function D3(N){return N?{blockPath:N,kind:"block-pulse"}:void 0}function jJ(N,F,A){let M=N.children.findIndex((E)=>E.type==="list"&&E.ordered===A.list.ordered&&E.start===A.list.start);if(M>=0){let E=N.children[M];if(!E||E.type!=="list")return{item:N,regionChildIndices:[...A.listChildIndices,A.itemIndex-1,0]};return{item:Z1(N,N.children.map(($,y)=>y===M?H0(E,[...E.items,F]):$)),regionChildIndices:[...A.listChildIndices,A.itemIndex-1,M,E.items.length,0]}}let D=t1({items:[F],ordered:A.list.ordered,spread:A.list.spread,start:A.list.start});return{item:Z1(N,[...N.children,D]),regionChildIndices:[...A.listChildIndices,A.itemIndex-1,N.children.length,0,0]}}function D7(N,F,A){let M=AN(N,F),D=Math.max(2,A);if(!M||M.block.type!=="paragraph"||M.block.plainText.length>0||F.anchor.regionId!==F.focus.regionId||F.anchor.offset!==0||F.focus.offset!==0)return null;return{kind:"splice-blocks",blocks:[e1({rows:Array.from({length:2},()=>E8(D))})],rootIndex:M.rootIndex,selection:X2(M.rootIndex,0,0)}}function D8(N,F){let A=F<0?uJ(N.table,N.rowIndex,N.cellIndex):vJ(N.table,N.rowIndex,N.cellIndex);if(!A)return F>0&&mJ(N.table,N.rowIndex,N.cellIndex)?RJ(N):{kind:"keep-state"};let M=N.table.rows[A.rowIndex]?.cells[A.cellIndex];if(!M)return{kind:"keep-state"};return{kind:"set-selection",selection:fJ(N.documentIndex,N.selection,N.table,A.rowIndex,A.cellIndex,Math.min(N.selection.focus.offset,M.plainText.length))}}function E7(N){let F=Math.min(N.selection.anchor.offset,N.selection.focus.offset),A=Math.max(N.selection.anchor.offset,N.selection.focus.offset),M=p0(N.inlineContainer,F,A,[y1()]);return{kind:"replace-block",block:M.block,blockId:M.blockId,selection:M.selection}}function $7(N,F){let A=F==="left"?N.cellIndex:N.cellIndex+1;return $N(N,e1({align:S7(N.table.align,A,0,[null]),rows:N.table.rows.map((M)=>j2(bJ(M.cells,A,0,[Q7()])))}),X2(N.rootIndex,N.rowIndex,A))}function y7(N){let F=Math.max(0,...N.table.rows.map((A)=>A.cells.length));if(F<=1)return null;return $N(N,e1({align:S7(N.table.align,N.cellIndex,1,[]),rows:N.table.rows.map((A)=>j2(A.cells.filter((M,D)=>D!==N.cellIndex)))}),X2(N.rootIndex,N.rowIndex,Math.min(N.cellIndex,F-2)))}function Z7(N,F){let A=F==="above"?N.rowIndex:N.rowIndex+1,M=Math.max(1,...N.table.rows.map((D)=>D.cells.length));return $N(N,a0(N.table,[...N.table.rows.slice(0,A),E8(M),...N.table.rows.slice(A)]),X2(N.rootIndex,A,Math.min(N.cellIndex,M-1)))}function Y7(N){if(N.table.rows.length<=1)return null;let F=N.table.rows.filter((D,E)=>E!==N.rowIndex),A=Math.min(N.rowIndex,F.length-1),M=F[A]?.cells.length??1;return $N(N,a0(N.table,F),X2(N.rootIndex,A,Math.min(N.cellIndex,M-1)))}function X7(N){return $N(N,F0(""),$0(N.rootIndex))}function E8(N){return j2(Array.from({length:N},()=>Q7()))}function Q7(){return L1([])}function RJ(N){let F=N.table.rows.length,A=Math.max(1,...N.table.rows.map((M)=>M.cells.length));return $N(N,a0(N.table,[...N.table.rows,E8(A)]),X2(N.rootIndex,F,0))}function $N(N,F,A){return{kind:"replace-block",block:F,blockId:N.table.id,selection:A}}function bJ(N,F,A,M){return[...N.slice(0,F),...M,...N.slice(F+A)]}function S7(N,F,A,M){return[...N.slice(0,F),...M,...N.slice(F+A)]}function fJ(N,F,A,M,D,E){let $=n2(N,A.id,M,D);if(!$)return F;return{anchor:{regionId:$.id,offset:E},focus:{regionId:$.id,offset:E}}}function uJ(N,F,A){if(A>0)return{cellIndex:A-1,rowIndex:F};if(F>0){let M=N.rows[F-1];if(!M||M.cells.length===0)return null;return{cellIndex:M.cells.length-1,rowIndex:F-1}}return null}function vJ(N,F,A){let M=N.rows[F];if(!M)return null;if(A+1<M.cells.length)return{cellIndex:A+1,rowIndex:F};let D=N.rows[F+1];if(!D||D.cells.length===0)return null;return{cellIndex:0,rowIndex:F+1}}function mJ(N,F,A){let M=N.rows[F];return Boolean(M&&F===N.rows.length-1&&A===M.cells.length-1)}function J7(N){switch(N.kind){case"code":return{kind:"splice-text",text:`
|
|
27
|
+
`};case"tableCell":return E7(N);case"listItem":return N7(N,N.offset)??A8(N,N.offset);case"blockquoteTextBlock":return n9(N,N.offset)??o9(N,N.offset);case"rootTextBlock":return i9(N,N.offset);case"unsupported":return null}}function V7(N,F){let A=Z0(N,F);if(A.collapsed)return null;let M=w0(N,A.start.regionId),D=w0(N,A.end.regionId);if(!M||!D)return null;let E=N.document.blocks[M.rootIndex],$=N.document.blocks[D.rootIndex];if(!E||!$)return null;if(M===D)return{kind:"single-region",normalized:A,region:M,root:E,wholeRegion:A.start.offset===0&&A.end.offset===M.text.length};return{kind:"multi-region",normalized:A,startRegion:M,endRegion:D,sameRoot:M.rootIndex===D.rootIndex,startRoot:E,endRoot:$}}function $8(N,F){let A=V7(N,F);if(!A)return null;switch(A.kind){case"single-region":if(!A.wholeRegion||A.region.blockType==="table"){let D=gJ(A.region,A.normalized.start.offset,A.normalized.end.offset);return kJ(D)}let M=U7(A.root,A.region);return M?q7([M]):null;case"multi-region":{let D=A.sameRoot?hJ(N,A.startRoot,A.startRegion,A.normalized.start.offset,A.endRegion,A.normalized.end.offset):xJ(N,A.startRegion,A.normalized.start.offset,A.endRegion,A.normalized.end.offset);return D.length>0?q7(D):null}}}function kJ(N){if(N.length===0)return null;if(z4(N))return{kind:"text",text:J0(N)};return{kind:"inlines",inlines:N}}function q7(N){if(tF(N))return{kind:"text",text:N[0].plainText};return{kind:"blocks",blocks:N}}function U7(N,F){if(N.id===F.blockId)return N;let A=C0(N);if(!A)return null;let M=A.find((E)=>S2(E,F)),D=M?U7(M,F):null;return D?C1(N,[D]):null}function gJ(N,F,A){let M=NN(N.inlines,A,N.text.length,""),D=NN(M,0,F,"");return j5(D)}function hJ(N,F,A,M,D,E){if(F.type==="table")return pJ(N,F,A,M,D,E);let $=K7(F,A,M,D,E);return $?[$]:[]}function IJ(N,F,A,M,D){let E=N.roots[F.rootIndex],$=E?.regions[0],y=E?.regions.at(-1);return F===$&&M===y&&A===0&&D===y.text.length}function pJ(N,F,A,M,D,E){if(IJ(N,A,M,D,E))return[F];let $=A.tableCellPosition?.rowIndex,y=A.tableCellPosition?.cellIndex,Z=D.tableCellPosition?.rowIndex,Y=D.tableCellPosition?.cellIndex;if($===void 0||y===void 0||Z===void 0||Y===void 0)return[];if($!==0||y!==0||M!==0)return[];let X=F.rows[Z];if(!X)return[];let Q=X.cells.length-1;if(Y!==Q||E!==D.text.length)return[];return[a0(F,F.rows.slice(0,Z+1))]}function K7(N,F,A,M,D){let E=C0(N);if(!E)return null;let $=E.findIndex((Z)=>S2(Z,F)),y=E.findIndex((Z)=>S2(Z,M));if($===-1||y===-1)return null;if($===y){let Z=K7(E[$],F,A,M,D);return Z?C1(N,[Z]):null}return C1(N,z7(E,$,F,A,y,M,D))}function xJ(N,F,A,M,D){return z7(N.document.blocks,F.rootIndex,F,A,M.rootIndex,M,D)}function z7(N,F,A,M,D,E,$){let y=rN(N[F],A,M),Z=N.slice(F+1,D),Y=aN(N[D],E,$);return[y,...Z,Y].filter((X)=>X!==null)}function y8(N,F,A){let M=sJ(N.documentIndex,N.selection);if(!M)return null;return{destination:M,documentIndex:N.documentIndex,inlineContext:M.sameRegion?H1(N):null,selection:N.selection}}function Z8(N,F,A){let M=lJ(N,F)??dJ(N,F,A);return M?cJ(N,M,F):null}function lJ(N,F){switch(F.kind){case"text":return F.text.length>0?{kind:"splice-text",text:F.text}:null;case"inlines":{if(F.inlines.length===0)return null;if(N.destination.sameRegion){let A=N.inlineContext?x9(N.inlineContext,F.inlines):null;if(A)return A}if(N.destination.structuralBlocked)return null;return{kind:"splice-fragment",blocks:[$1(F.inlines)]}}case"blocks":if(F.blocks.length===0||N.destination.structuralBlocked)return null;return{kind:"splice-fragment",blocks:F.blocks}}}function dJ(N,F,A){if(F.kind==="text")return null;let M=N.destination.prefersVerbatimFallback&&A&&A.length>0?A:eF(F);return M.length>0?{kind:"splice-text",text:M}:null}function aJ(N,F){if(N.kind==="splice-text")return N.text;if(N.kind==="replace-block"||N.kind==="splice-fragment")return rJ(F);return""}function rJ(N){switch(N.kind){case"text":return N.text;case"inlines":return J0(N.inlines);case"blocks":return N.blocks.length===1&&N.blocks[0].type==="paragraph"?N.blocks[0].plainText:""}}function cJ(N,F,A){let M=J2(N.documentIndex,N.selection,aJ(F,A));return M?{...F,animation:M}:F}function sJ(N,F){let A=Z0(N,F),M=w0(N,A.start.regionId),D=w0(N,A.end.regionId);if(!M||!D)return null;let E=G7(M)||G7(D);return{prefersVerbatimFallback:M.blockType==="code"||D.blockType==="code",sameRegion:M===D,structuralBlocked:E}}function G7(N){return N.blockType==="table"||N.blockType==="code"}function E3(N,F,A){return{animation:J2(N,F,A),kind:"splice-text",text:A}}function H7(N,F){return{animation:n5(N.region,N.startOffset,F),kind:"splice-text",range:N.selection,text:F}}function _7(N,F,A,M){let D=M==="backward"?f4(N,F.blockId):wN(N,F.blockId);if(D&&Q1(D))return iJ(F,D,M);let E=M==="backward"?M2(N,F.id):ON(N,F.id);if(!E)return null;if(A)return nJ(N,F,E,M);let $=M==="backward"?F:E,y=M==="backward"?E:F;if(!oJ(y))return null;return tJ(N,$,y)}function iJ(N,F,A){if(F.parentBlockId!==null)return null;let M=A==="backward"?N.rootIndex-1:N.rootIndex,D=A==="backward"?0:"end";return{kind:"splice-blocks",rootIndex:F.rootIndex,count:1,blocks:[],selection:y3(N,M,D)}}function oJ(N){return N.blockType==="paragraph"||N.blockType==="heading"}function nJ(N,F,A,M){let D=N.document.blocks[F.rootIndex];if(!D)return null;let E=$3(D,F,A.blockId,void 0),$=M==="backward"?A.text.length:0,Z=F.rootIndex===A.rootIndex?NV(E,A.rootIndex,A.blockId,$):FV(A,F.rootIndex,E.length,$);if(!Z)return null;return{kind:"splice-blocks",rootIndex:F.rootIndex,count:1,blocks:E,selection:Z}}function tJ(N,F,A){let M=o0(N.document,A.blockId),D=o0(N.document,F.blockId);if(!M||M.type!=="paragraph"&&M.type!=="heading")return null;let E=A.text.length,$=eJ(M,D),y=y3(A,A.rootIndex,E);if(F.rootIndex===A.rootIndex){let K=N.document.blocks[F.rootIndex];if(!K)return null;let q=$3(K,F,A.blockId,$);return{kind:"splice-blocks",rootIndex:F.rootIndex,count:1,blocks:q,selection:y}}let Z=N.document.blocks[A.rootIndex],Y=N.document.blocks[F.rootIndex];if(!Z||!Y)return null;let X=$3(Z,F,A.blockId,$);if(X.length!==1)return null;let Q=X[0],S=$3(Y,F,A.blockId,void 0),J=Math.min(A.rootIndex,F.rootIndex),V=A.rootIndex<F.rootIndex?[Q,...S]:[...S,Q];return{kind:"splice-blocks",rootIndex:J,count:2,blocks:V,selection:y}}function y3(N,F,A=0){let M=g1(N.path);if(M.length===0)return $0(F,A);return j0(F,M,A)}function eJ(N,F){let A=F&&(F.type==="paragraph"||F.type==="heading")?F.children:[];return k0(N,W0([...N.children,...A]))}function NV(N,F,A,M){for(let D=0;D<N.length;D+=1){let E=N[D],$=Y8(E,A);if($){if($.length===0)return $0(F+D,M);return j0(F+D,$,M)}}return null}function FV(N,F,A,M){let D=g1(N.path),E=A-1,$=N.rootIndex<F?N.rootIndex:N.rootIndex+E;if(D.length===0)return $0($,M);return j0($,D,M)}function Y8(N,F){if(N.id===F)return[];switch(N.type){case"list":for(let A=0;A<N.items.length;A+=1){let M=Y8(N.items[A],F);if(M)return[A,...M]}return null;case"listItem":case"blockquote":for(let A=0;A<N.children.length;A+=1){let M=Y8(N.children[A],F);if(M)return[A,...M]}return null;default:return null}}function $3(N,F,A,M){return u2([N],(D,{parent:E,recurse:$})=>{if(D.type==="listItem"){let Z=D.children[0];if(Z&&Z.id===F.blockId)return AV(D)}if(D.id===F.blockId&&E?.type!=="listItem")return[];if(D.id===A&&M!==void 0)return M;let y=$();if(y.type==="listItem"){let Z=y.children[0];if(!Z||Z.type!=="paragraph"&&Z.type!=="heading")return[]}return y})}function AV(N){if(N.type==="listItem")return N.children.filter((F)=>F.type==="list").flatMap((F)=>F.items);return[]}function B7(N,F){let A=u4(N,F.rootIndex);if(!A||A.id!==F.id)return null;let M=N.document.blocks[F.rootIndex];if(!M)return null;let D=MV(M);if(!D)return null;return{kind:"splice-blocks",rootIndex:F.rootIndex,count:1,blocks:D,selection:$0(F.rootIndex)}}function MV(N){switch(N.type){case"heading":return[$1(N.children)];case"blockquote":return[...N.children];case"list":return P7(N.items);default:return null}}function P7(N){return N.flatMap((F)=>{let A=[DV(F)];for(let M of F.children)if(M.type==="list")A.push(...P7(M.items));return A})}function DV(N){let F=N.children[0];if(F&&(F.type==="paragraph"||F.type==="heading"))return $1(F.children);return F0("")}function W7(N,F){if(N.selection.anchor.regionId!==N.selection.focus.regionId||N.selection.anchor.offset!==N.selection.focus.offset)return null;let A=w0(N.documentIndex,N.selection.focus.regionId);if(!A)return null;if(F==="forward"&&N.selection.focus.offset>=A.text.length)return null;let M=F==="backward"?RN(A.text,N.selection.focus.offset,-1):N.selection.focus.offset,D=F==="backward"?N.selection.focus.offset:RN(A.text,N.selection.focus.offset,1);if(M===D)return null;return{animation:F==="backward"&&(D===A.text.length||EV(A,D))?d9(A,M,D):void 0,kind:"splice-text",range:{anchor:{regionId:A.id,offset:M},focus:{regionId:A.id,offset:D}},text:""}}function EV(N,F){return N.inlines.some((A)=>A.kind==="lineBreak"&&A.start===F)}function X8(N,F){return yV(N)??W7(N,F)??$V(N.documentIndex,u9(N,F))}function $V(N,F){if(F.kind==="unsupported"||!F.atBoundary)return null;if(F.direction==="backward"){let A=ZV(F,N);if(A)return A}return _7(N,F.region,F.empty,F.direction)}function yV(N){let F=Z0(N.documentIndex,N.selection);if(F.start.regionId===F.end.regionId&&F.start.offset===F.end.offset)return null;return E3(N.documentIndex,N.selection,"")}function ZV(N,F){let A=B7(F,N.region);if(A)return A;if(N.kind==="rootTextBlock"){let M=YV(N,F);if(M)return M}return null}function YV(N,F){if(N.block.type!=="paragraph"||N.block.plainText.length!==0)return null;let A=F.document.blocks[N.rootIndex-1],M=F.document.blocks[N.rootIndex+1];if(!A||A.type!=="list"||!M||M.type!=="list"||!XV(A,M))return null;let D=M2(F,N.region.id),E=D?y3(D,N.rootIndex-1,"end"):$0(N.rootIndex-1,"end");return{kind:"splice-blocks",count:3,blocks:[H0(A,[...A.items,...M.items])],rootIndex:N.rootIndex-1,selection:E}}function XV(N,F){return N.ordered===F.ordered&&N.start===F.start}var eN=N0((N,F)=>s9(N.documentIndex,N.selection,F)),Z3=N0(J7,t6),O7=N0((N)=>VV(N)??{kind:"splice-text",text:`
|
|
28
|
+
`}),QV=N0((N,F)=>E3(N.documentIndex,N.selection,F)),Y3=N0((N,F,A,M)=>H7(N,M),(N,F,A)=>g5(N,F,A)),w7=(N)=>QV(N,""),Q8=N0((N)=>X8(N,"backward")),S8=N0((N)=>X8(N,"forward")),NF=(N)=>$8(N.documentIndex,N.selection),SV=N0(Z8,y8);function L7(N,F,A){return SV(N,F,A)}function T7(N){let F=N.documentIndex.regions,A=F[0],M=F.at(-1);if(!A||!M)return N;return L0(N,{anchor:{regionId:A.id,offset:0},focus:{regionId:M.id,offset:M.text.length}})}var X3=K3("bold"),Q3=K3("italic"),S3=K3("strikethrough"),J3=K3("underline"),V3=N0((N)=>DN(N,d5),H1),C7=N0((N,F,A)=>DN(N,(M,D,E)=>c5(M,D,E,A)),n6),j7=N0((N,F)=>DN(N,s5),n6),R7=N0((N,F)=>DN(N,(A,M,D)=>r5(A,M,D,F)),H1),b7=N0((N,F,A)=>o5(N,w1({alt:A??null,url:F})),H1),f7=N0((N,F,A,M,D="")=>i5(N,A,M,D),n6),u7=N0((N,F,A)=>a5(N.inlineContainer,F,A),H1),J8=(N)=>v5(N),V8=(N)=>m5(N),q3=N0((N)=>{switch(N.kind){case"tableCell":return D8(N,1);case"rootTextBlock":return F8(N,1)??t9(N);case"listItem":return F7(N);default:return null}},t6),U3=N0((N)=>{switch(N.kind){case"tableCell":return D8(N,-1);case"rootTextBlock":return F8(N,-1);case"listItem":return A7(N);default:return null}},t6),v7=N0((N)=>M8(N,-1),h5),m7=N0((N)=>M8(N,1),h5),k7=N0((N,F)=>{let A=sN(N.documentIndex,F);if(!A||A.type!=="listItem"||typeof A.checked!=="boolean")return null;return{kind:"replace-block",block:{...A,checked:!A.checked},blockId:F}}),g7=N0((N,F)=>D7(N.documentIndex,N.selection,F)),h7=N0((N,F)=>$7(N,F),MN),I7=N0(y7,MN),p7=N0((N,F)=>Z7(N,F),MN),x7=N0(Y7,MN),l7=N0(X7,MN),d7=N0((N,F,A)=>{let M=q5(N.documentIndex,F,A);if(!M)return null;return{kind:"splice-comments",count:0,index:N.documentIndex.document.comments.length,threads:[M]}}),a7=(N,F,A)=>FF(N,F,(M)=>T4(M,{body:A.trim()})),r7=(N,F,A,M)=>FF(N,F,(D)=>C4(D,A,M)),c7=(N,F,A)=>FF(N,F,(M)=>j4(M,A)),s7=(N,F)=>FF(N,F,()=>null),i7=(N,F,A)=>FF(N,F,(M)=>R4(M,A));function N0(N,F){return(A,...M)=>{let D=F?JV(N,F,A,M):N(A,...M);if(!D)return null;return u5(A,D)}}function JV(N,F,A,M){let D=F(A,...M);return D?N(D,...M):null}function VV(N){let F=H1(N);return F?o5(F,y1()):null}function K3(N){return N0((F)=>DN(F,(A,M,D)=>l5(A,M,D,N)),H1)}function FF(N,F,A){let D=h0(N.documentIndex).threads[F];if(!D)return null;let E=A(D);if(E===D)return null;return u5(N,{kind:"splice-comments",count:1,index:F,threads:E?[E]:[]})}var o7=1;function n7(N,F,A){let M=N.documentIndex.regionOrderIndex.get(N.selection.focus.regionId);if(M===void 0)return N;let D=N.documentIndex.regions[M],E=RN(D.text,N.selection.focus.offset,F);if(E!==N.selection.focus.offset)return I0(N,D.id,E,A);if(F<0){let y=M2(N.documentIndex,D.id);if(!y)return N;return I0(N,y.id,y.text.length,A)}let $=ON(N.documentIndex,D.id);if(!$)return N;return I0(N,$.id,0,A)}function t7(N,F,A,M,D){let E=a2(F,A.regionId,A.offset);if(!E)return N;let $=F.lines[E.index+M];if(!$)return N;let y=v0(F,N,{x:A1(N,F,A)+o7,y:$.top+$.height/2});if(!y)return N;return I0(N,y.regionId,y.offset,D)}function e7(N,F,A,M){let D=FE(N,F);if(!D)return N;return I0(N,D.regionId,A==="Home"?D.start:D.end,M)}function NE(N,F,A,M,D){let E=FE(N,F);if(!E)return N;let y=Math.max(1,Math.floor(480/F.options.lineHeight)),Z=a2(F,E.regionId,N.selection.focus.offset),Y=Z?F.lines[Z.index+M*y]:null;if(!Y)return N;let X=v0(F,N,{x:A1(N,F,A)+o7,y:Y.top+Y.height/2});if(!X)return N;return I0(N,X.regionId,X.offset,D)}function FE(N,F){return N1(F,N.selection.focus.regionId,N.selection.focus.offset)}var qV=1;function AE(N,F,A,M,D){let E=N.documentIndex.regionIndex.get(N.selection.focus.regionId)??null;if(!E)return null;let $=N.documentIndex.tableCellIndex.get(E.id)??null,y=N.documentIndex.blockIndex.get(E.blockId)??null;if(!$||y?.type!=="table")return null;let Z=UV(N,y.id,$.rowIndex+M,$.cellIndex)??KV(N,y.id,M);if(!Z)return N;let Y=F.regionBounds.get(E.id),X=F.regionBounds.get(Z.id);if(!Y||!X)return N;let Q=X.top+zV(A.top+A.height/2-Y.top,0,Math.max(0,X.bottom-X.top-1)),S=v0(F,N,{x:A1(N,F,A)+qV,y:Q});if(!S)return N;return I0(N,S.regionId,S.offset,D)}function UV(N,F,A,M){return n2(N.documentIndex,F,A,M)}function KV(N,F,A){let M=N.documentIndex.blockIndex.get(F),D=N.documentIndex.regions,E=M?N.documentIndex.roots[M.rootIndex]?.regionRange:void 0;if(!E)return null;return A<0?D[E.start-1]??null:D[E.end]??null}function zV(N,F,A){return Math.max(F,Math.min(A,N))}function q8(N,F,A=!1){return n7(N,F,A)}function U8(N,F,A,M=!1){return GV(N,F,A,M)}function K8(N,F,A,M=!1){return HV(N,F,A,M)}function z8(N,F,A,M=!1){return e7(N,F,A,M)}function G8(N,F,A=!1){return _V(N,F,A)}function H8(N,F,A){let M=C6(N,F,A);return M?L0(N,{offset:M.offset,regionId:M.regionId}):null}function _8(N,F,A){let M=C6(N,F,A);return M?I0(N,M.regionId,M.offset,!0):null}function AF(N,F,A,M){let D=Q5(N,F,A,M);return D?L0(N,{anchor:M,focus:D}):null}function GV(N,F,A,M){let D=ME(N,F);if(!D)return N;return AE(N,F,D,A,M)??t7(N,F,D,A,M)}function HV(N,F,A,M){let D=ME(N,F);if(!D)return N;return NE(N,F,D,A,M)}function _V(N,F,A){let M=N.documentIndex.regions,D=F==="start"?M[0]:M.at(-1);if(!D)return N;return I0(N,D.id,F==="start"?0:D.text.length,A)}function ME(N,F){return F1(F,N.documentIndex,{regionId:N.selection.focus.regionId,offset:N.selection.focus.offset})}var BV=80;function EE({context:N,containerBounds:F,isHeaderRow:A,lineHeight:M,theme:D}){let E=yE(F,M);N.fillStyle=A?D.tableHeaderBackground:D.tableBodyBackground,N.fillRect(E.left,E.top,E.width,E.height),ZE(N,E,D)}function $E({activeBlockFlashes:N,activeBlockId:F,activeRegionId:A,context:M,editorState:D,endIndex:E,layout:$,regionBounds:y,startIndex:Z,theme:Y,verticalBleed:X}){if(!F||!A)return;let Q=D.documentIndex.blockIndex.get(F)??null;if(Q?.type!=="table")return;if((D.documentIndex.regionIndex.get(A)??null)?.blockId!==F)return;let J=y.get(A)??null,V=$.regionLineIndices.get(A)??null;if(!J||!V||V.length===0)return;let K=$.lines[V[0]]??null;if(!K)return;let q=yE(J,K.height);if(q.width===0)return;let U=DE({context:M,endIndex:E,fillStyle:Y.activeBlockBackground,layout:$,left:q.left,lineIndices:V,startIndex:Z,verticalBleed:X,width:q.width}),z=Q.path?N.get(Q.path)??null:null;if(z)DE({context:M,endIndex:E,fillStyle:a6(Y.activeBlockFlash,z),layout:$,left:q.left,lineIndices:V,startIndex:Z,verticalBleed:X,width:q.width});if(!U)return;ZE(M,q,Y)}function DE({context:N,endIndex:F,fillStyle:A,layout:M,left:D,lineIndices:E,startIndex:$,verticalBleed:y,width:Z}){N.fillStyle=A;let Y=!1;for(let X of E){if(X<$)continue;if(X>=F)break;let Q=M.lines[X];N.fillRect(D,Q.top-y,Z,Q.height),Y=!0}return Y}function yE(N,F){return{height:Math.max(N.bottom-N.top,F),left:N.left,top:N.top,width:Math.max(N.right-N.left,BV)}}function ZE(N,F,A){N.strokeStyle=A.tableBorder,N.strokeRect(F.left,F.top,F.width,F.height)}var z3=2,PV=3,WV=12,OV=6,wV=3,LV=8,TV=12,CV=28,jV=4,YE=1,RV=5,bV=2,fV=1;function XE(N,F,A,M,D,E,$){if(!M||F.start!==0)return;if(A?.type==="code"){let y=Math.max(0,F.left-TV);N.fillStyle=E.codeBackground,N.fillRect(y,M.top-jV,Math.max(M.right-F.left+CV,$-y),M.bottom-M.top+LV);return}if(A?.type!=="table")return;EE({context:N,containerBounds:M,isHeaderRow:D?.rowIndex===0,lineHeight:F.height,theme:E})}function QE(N,F,A,M,D,E,$,y){if(F.blockId!==D||A?.type==="table")return;let Z=M?E.get(M)??null:null;if(N.fillStyle=$.activeBlockBackground,N.fillRect(0,F.top-z3,y,F.height),!Z)return;N.fillStyle=a6($.activeBlockFlash,Z),N.fillRect(0,F.top-z3,y,F.height)}function SE(N,F,A,M,D,E){let $=new Map;for(let y=M;y<D;y+=1){let Z=N.lines[y],Y=A.get(Z.blockId);if(Y?.type!=="heading"||Y.depth!==1&&Y.depth!==2)continue;let X=$.get(Y.id),Q={bottom:Z.top+Z.height,left:Z.left+g0(F,Z),right:E-N.options.paddingX};$.set(Y.id,X?{bottom:Math.max(X.bottom,Q.bottom),left:X.left,right:X.right}:Q)}return $}function JE(N,F,A,M,D,E){for(let $=A;$<M;$+=1){let y=F.blocks[$];if(y.type==="divider"){let Z=F.options.paddingX+y.depth*F.options.indentWidth,Y=E-F.options.paddingX,X=Math.round(y.top+(y.bottom-y.top-YE)/2);qE(N,{color:D.dividerRule??D.headingRule,left:Z,right:Y,thickness:YE,top:X})}}}function VE(N,F,A){for(let M of F.values())qE(N,{color:A.headingRule,left:M.left,minimumWidth:bV,right:M.right,thickness:fV,top:M.bottom+RV})}function qE(N,F){N.fillStyle=F.color,N.fillRect(F.left,F.top,Math.max(F.minimumWidth??0,F.right-F.left),F.thickness)}function UE(N,F,A,M,D){let E=new Map;for(let $=M;$<D;$+=1){let y=N.lines[$],Z=z1(F,y.blockId,"blockquote");if(!Z)continue;let Y=E.get(Z.id),X={bottom:y.top+y.height,isActive:y.blockId===A,left:N.options.paddingX+(Z.depth+1)*N.options.indentWidth-10,top:y.top};E.set(Z.id,Y?{bottom:Math.max(Y.bottom,X.bottom),isActive:Y.isActive||X.isActive,left:Y.left,top:Math.min(Y.top,X.top)}:X)}return E}function KE(N,F,A){for(let M of F.values())N.fillStyle=M.isActive?A.blockquoteRuleActive:A.blockquoteRule,N.fillRect(M.left,M.top+PV,wV,Math.max(WV,M.bottom-M.top-OV))}var uV=1,vV=2,mV=2;function B8({context:N,devicePixelRatio:F,editorState:A,height:M,layout:D,normalizedSelection:E,presence:$,showCaret:y,theme:Z,viewportTop:Y,width:X}){N.save(),N.scale(F,F),N.clearRect(0,0,X,M);let Q=E.start.regionId===E.end.regionId&&E.start.offset!==E.end.offset,S=y&&!Q;if(N.translate(0,-Y),S)zE(N,A,D,{color:Z.caret,offset:A.selection.focus.offset,regionId:A.selection.focus.regionId});if($)for(let J of $){if(!J.cursorPoint)continue;zE(N,A,D,{color:J.color??Z.leafAccent,offset:J.cursorPoint.offset,regionId:J.cursorPoint.regionId})}N.restore()}function zE(N,F,A,M){let D=F1(A,F.documentIndex,{regionId:M.regionId,offset:M.offset});if(!D)return;let E=A1(F,A,D),$=kV(A,D);N.fillStyle=M.color,N.fillRect(E,$.top,vV,$.height)}function kV(N,F){let A=N1(N,F.regionId,F.offset),M=A?.font??'16px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',{ascent:D,descent:E}=e0(M),$=Math.max(1,D+E),y=Math.min(F.height-mV,$),Z=A?Math.max(A.top,A.top+M5(A.height,M)-uV):F.top+Math.max(0,Math.floor((F.height-y)/2));return{height:y,top:Z}}var GE=2,HE=8,gV=3,hV=1.5,IV=2,yN={elbow:{x:6.5,y:10.5},end:{x:11.5,y:3.5},start:{x:3.5,y:7.5}};function _E(N,F,A,M,D,E,$,y=null){if(!A||F.start!==0)return;if(y){let Z=Y9(y),Y=aV(A,F,M,D,N);N.save(),N.translate(Y.x,Y.y),N.scale(Z,Z),N.translate(-Y.x,-Y.y)}if(A.kind==="task")pV(N,F,A.checked,$,y);else{let Z=$.listMarkerText??E;if(N.fillStyle=y?dN(Z,y,$):Z,A.kind==="ordered")dV(N,A.label,M,D);else N.fillText(A.label,F.left-GE,D)}if(y)N.restore()}function pV(N,F,A,M,D=null){let E=y2(F);if(xV(N,E,A,M,D),!A)return;lV(N,E,M,D)}function xV(N,F,A,M,D=null){let E=A?M.checkboxCheckedFill:M.checkboxUncheckedFill,$=A?M.checkboxCheckedStroke:M.checkboxUncheckedStroke;N.fillStyle=D?dN(E,D,M):E,N.strokeStyle=D?dN($,D,M):$,N.beginPath(),N.lineWidth=hV,N.roundRect(F.left,F.top,F.size,F.size,gV),N.fill(),N.stroke()}function lV(N,F,A,M=null){N.strokeStyle=M?dN(A.checkboxCheckmark,M,A):A.checkboxCheckmark,N.lineWidth=IV,N.beginPath(),N.moveTo(F.left+yN.start.x,F.top+yN.start.y),N.lineTo(F.left+yN.elbow.x,F.top+yN.elbow.y),N.lineTo(F.left+yN.end.x,F.top+yN.end.y),N.stroke()}function dV(N,F,A,M){let D=N.textAlign;N.textAlign="right",N.fillText(F,A-HE,M),N.textAlign=D}function aV(N,F,A,M,D){if(N.kind==="task"){let y=y2(F);return{x:y.left+y.size/2,y:y.top+y.size/2}}let E=D.measureText(N.label),$=M-(E.actualBoundingBoxAscent-E.actualBoundingBoxDescent)/2;if(N.kind==="ordered")return{x:A-HE-E.width/2,y:$};return{x:F.left-GE+E.width/2,y:$}}var G3=0.42;function P8(N){let F=Math.max(0,N)%2200/2200;return(1+Math.cos(F*Math.PI*2))/2}function H3(N,F){let A=P8(N);return F+(1-F)*A}var rV=2,cV=1,sV=2,iV=5,oV=2,nV=3;function BE(N,F){let A=N.documentIndex.regionOrderIndex,M=A.get(F.start.regionId),D=A.get(F.end.regionId);return M===void 0||D===void 0?null:{end:D,start:M}}function PE(N,F,A,M,D,E){if(!D)return;let $=F.documentIndex.regionOrderIndex.get(A.regionId);if($===void 0||$<D.start||$>D.end)return;let y=$===D.start?Math.max(A.start,M.start.offset):A.start,Z=$===D.end?Math.min(A.end,M.end.offset):A.end;if(Z<=y)return;let{left:Y,width:X}=OE(F,A,y,Z,rV);N.fillStyle=E.selectionBackground,N.fillRect(Y,A.top+cV,X,A.height-sV)}function WE(N,F,A,M,D,E,$,y){for(let Z of M){if(Z.regionId!==A.regionId)continue;let Y=Math.max(Z.startOffset,A.start),X=Math.min(Z.endOffset,A.end);if(X<=Y)continue;N.fillStyle=tV(Z,D,E,y);let Q=!Z.resolved&&E.has(Z.threadIndex),{left:S,width:J}=OE(F,A,Y,X,oV);if(Q)N.save(),N.globalAlpha*=H3($,G3);if(N.fillRect(S,A.top+A.height-iV,J,nV),Q)N.restore()}}function OE(N,F,A,M,D){let E=mN(N,F,A-F.start),$=mN(N,F,M-F.start);return{left:E,width:Math.max(D,$-E)}}function tV(N,F,A,M){if(N.resolved)return N.threadIndex===F?M.commentHighlightResolvedActive:M.commentHighlightResolved;return N.threadIndex===F?M.commentHighlightActive:A.has(N.threadIndex)?A.get(N.threadIndex)??M.leafAccent:M.commentHighlight}function LE(N,F,A,M,D,E,$){let y=A.image?M.images.get(A.image.url):null,Z=Fq(A,M,$),Y=Aq(F,E,$,Z);if(N.fillStyle=D.imageSurfaceBackground,N.fillRect(Y.left,Y.top,Y.width,Y.height),y?.status==="loaded"&&y.source)N.drawImage(y.source,Y.left,Y.top,Y.width,Y.height);else eV(N,D,{...Y,status:y?.status==="error"?"error":"loading"});N.strokeStyle=D.imageSurfaceBorder,N.strokeRect(Y.left,Y.top,Y.width,Y.height)}function eV(N,F,A){let M=A.status==="loading"?"Loading image":"Image unavailable",D=Mq(A),E=A.top+A.height/2+D.size*0.9;if(N.save(),N.beginPath(),N.rect(A.left,A.top,A.width,A.height),N.clip(),A.status==="loading")Nq(N,F,A);N.strokeStyle=F.imagePlaceholderIcon,N.lineWidth=1.5,N.strokeRect(D.left,D.top,D.size,D.size),N.beginPath(),N.arc(D.left+D.size*0.28,D.top+D.size*0.3,D.size*0.1,0,Math.PI*2),N.moveTo(D.left+D.size*0.12,D.top+D.size*0.82),N.lineTo(D.left+D.size*0.42,D.top+D.size*0.5),N.lineTo(D.left+D.size*0.58,D.top+D.size*0.66),N.lineTo(D.left+D.size*0.78,D.top+D.size*0.38),N.lineTo(D.left+D.size*0.88,D.top+D.size*0.82),N.stroke(),N.font='500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',N.fillStyle=F.imagePlaceholderText,N.textAlign="center",N.textBaseline="middle",N.fillText(M,A.left+A.width/2,E),N.restore()}function Nq(N,F,A){let M=Math.max(48,Math.round(A.width*0.22)),D=A.width+M*2,E=performance.now()%1800/1800,$=A.left-M+D*E,y=N.createLinearGradient($,A.top,$+M,A.top);y.addColorStop(0,"rgba(255,255,255,0)"),y.addColorStop(0.5,F.imageLoadingOverlay),y.addColorStop(1,"rgba(255,255,255,0)"),N.fillStyle=y,N.fillRect(A.left,A.top,A.width,A.height)}function Fq(N,F,A){if(!N.image)return wE(A);let M=F.images.get(N.image.url);if(!M||M.intrinsicWidth<=0||M.intrinsicHeight<=0)return wE(A);return Math.max(48,Math.round(A*(M.intrinsicHeight/M.intrinsicWidth)))}function Aq(N,F,A,M){return{height:M,left:F,top:N.top+Math.max(0,Math.floor((N.height-M)/2)),width:A}}function Mq(N){let F=Math.max(18,Math.min(34,Math.round(Math.min(N.width,N.height)*0.18)));return{left:N.left+Math.max(12,Math.round((N.width-F)/2)),size:F,top:N.top+Math.max(12,Math.round(N.height/2-F*0.95))}}function wE(N){return Math.max(48,Math.round(N*0.5625))}var Dq=5,TE=-1,CE=3,Eq=1;function jE(N,F,A,M,D,E){if(!A.mention)return;let $=F.top+$2(F.height,N.font),y=e0(N.font),Z=$-y.ascent-CE+TE,Y=y.ascent+y.descent+CE*2,X=Math.max(0,E-D);N.fillStyle=M.mentionBackground??M.inlineCodeBackground,$q(N,D,Z,X,Y,Dq),N.fillStyle=M.mentionText??M.linkText,N.fillText(`@${A.mention.name}`,D+V6,$+TE+Eq)}function $q(N,F,A,M,D,E){let $=Math.min(E,M/2,D/2);N.beginPath(),N.roundRect(F,A,M,D,$),N.fill()}var RE=4,yq=4,Zq=1.5,W8={bottomPadding:1,cornerRadius:0,horizontalPadding:1,topPadding:2,verticalNudge:-1},Yq=0.72,bE=2,fE=1.25,Xq=0.02;function mE(N,F,A,M,D,E,$,y){if(!A){N.fillStyle=E,N.fillText(F.text,M,D);return}let Z=A.inlines.filter((Y)=>Y.end>F.start&&Y.start<F.end);if(Z.length===0){N.fillStyle=E,N.fillText(F.text,M,D);return}for(let Y of Z){let X=Math.max(F.start,Y.start),Q=Math.min(F.end,Y.end);if(A.text.slice(X,Q).length===0)continue;let{left:J,right:V}=V2(F,M,X,Q),K=K1(F.font,Y.marks,Y.inlineCode);if(N.font=K,Y.kind==="image"){let q=Math.max(24,V-J);LE(N,F,Y,$,y,J,q);continue}if(Y.kind==="mention"){jE(N,F,Y,y,J,V);continue}if(Y.kind==="code"){O8(N,J,V,D,y.inlineCodeBackground,W8),uE(N,F,A.text,M,D,X,Q,y.inlineCodeText,{strikethrough:!1,underline:!1});continue}uE(N,F,A.text,M,D,X,Q,Y.link?y.linkText:E,{strikethrough:Y.marks.includes("strikethrough"),underline:Y.marks.includes("underline")||Boolean(Y.link)})}}function uE(N,F,A,M,D,E,$,y,Z){let Y=A.slice(E,$);if(Y.length===0)return;let{left:X,right:Q}=V2(F,M,E,$);if(N.fillStyle=y,N.fillText(Y,X,D),Z.strikethrough)N.fillRect(X,Hq(D,F.height,N.font),Math.max(bE,Q-X),fE);if(Z.underline)N.fillRect(X,_q(D,F.height,N.font),Math.max(bE,Q-X),fE)}function w8(N,F,A,M,D,E,$,y,Z){if(!A||E.length===0)return;let Y=vE(E,F.start,F.end);if(Y.length===0)return;let X=A.inlines.filter((Q)=>Q.end>F.start&&Q.start<F.end);for(let Q of X){if(!Qq(Q))continue;let S=Math.max(F.start,Q.start),J=Math.min(F.end,Q.end),V=A.text.slice(S,J);if(V.length===0)continue;let K=vE(Y,S,J);if(K.length===0)continue;let q=Sq(S,J,K),{left:U}=V2(F,M,S,J);N.font=UD(F.font,Q.marks);for(let z=0;z<q.length-1;z+=1){let G=q[z],H=q[z+1],B=Jq(K,G,H);if(!B||H<=G)continue;let{left:_,right:O}=V2(F,M,G,H);Vq(N,{baseTextColor:Z,decoration:B,decorationAnimationTime:y,height:F.height,left:_,phase:$,right:O,text:V,textBaseline:D,textLeft:U,top:F.top})}}}function Qq(N){return N.kind!=="image"&&N.kind!=="mention"&&N.kind!=="code"&&!N.link}function vE(N,F,A){return N.filter((M)=>M.endOffset>F&&M.startOffset<A)}function Sq(N,F,A){if(A.length===0)return[N,F];let M=new Set([N,F]);for(let D of A){if(D.endOffset<=N||D.startOffset>=F)continue;M.add(Math.max(N,D.startOffset)),M.add(Math.min(F,D.endOffset))}return[...M].sort((D,E)=>D-E)}function Jq(N,F,A){return N.find((M)=>M.startOffset<A&&M.endOffset>F)??null}function Vq(N,{baseTextColor:F,decoration:A,decorationAnimationTime:M,height:D,left:E,phase:$,right:y,text:Z,textBaseline:Y,textLeft:X,top:Q}){if($==="background"){if(!A.backgroundColor)return;qq(N,{color:A.backgroundColor,decorationAnimationTime:M,left:E,pulse:A.pulse===!0,right:y,textBaseline:Y});return}if(!A.color)return;IE(N,{color:Uq(A,M,F),eraseExistingGlyphs:!0,height:D,left:E,text:Z,textBaseline:Y,textLeft:X,top:Q,width:Math.max(0,y-E)})}function qq(N,{color:F,decorationAnimationTime:A,left:M,pulse:D,right:E,textBaseline:$}){if(!D){O8(N,M,E,$,F,W8);return}N.save(),N.globalAlpha*=H3(A,G3),O8(N,M,E,$,F,W8),N.restore()}function Uq(N,F,A){if(!N.pulse||!N.backgroundColor)return N.color??A;let D=(1-P8(F))*Yq;return Q2(N.color??A,A,D)}function O8(N,F,A,M,D,E){let $=Kq(N,F,A,M,E);if(N.fillStyle=D,E.cornerRadius<=0){N.fillRect($.left,$.top,$.width,$.height);return}zq(N,$.left,$.top,$.width,$.height,E.cornerRadius)}function Kq(N,F,A,M,D){let E=e0(N.font),$=F-D.horizontalPadding,y=A+D.horizontalPadding;return{height:E.ascent+E.descent+D.topPadding+D.bottomPadding,left:$,top:M-E.ascent-D.topPadding+D.verticalNudge,width:Math.max(0,y-$)}}function zq(N,F,A,M,D,E){if(M<=0||D<=0)return;N.beginPath(),N.roundRect(F,A,M,D,Math.min(E,M/2,D/2)),N.fill()}function kE(N,F,A,M,D,E,$){if(!A||E.length===0)return;let y=A.inlines.filter((Z)=>Z.end>F.start&&Z.start<F.end);for(let Z of y){if(Z.kind==="image"||Z.kind==="mention")continue;let Y=Math.max(F.start,Z.start),X=Math.min(F.end,Z.end),Q=A.text.slice(Y,X);if(Q.length===0)continue;let S=$9(Y,X,E).filter((K)=>Gq(A.text,Y,X,K));if(S.length<=2){if(!w5(E,Y,X))continue}let{left:J}=V2(F,M,Y,X),V=K1(F.font,Z.marks,Z.inlineCode);N.font=V;for(let K=0;K<S.length-1;K+=1){let q=S[K],U=S[K+1],z=w5(E,q,U);if(!z||U<=q)continue;let G=1-z.progress;if(G<=Xq)continue;let{left:H,right:B}=V2(F,M,q,U);IE(N,{alpha:G,color:$.insertHighlightText,height:F.height,left:H,text:Q,textBaseline:D,textLeft:J,top:F.top,width:Math.max(0,B-H)})}}}function Gq(N,F,A,M){if(M<=F||M>=A)return!0;let D=F;for(let E of p2(N.slice(F,A))){if(D+=E.length,D===M)return!0;if(D>M)return!1}return!1}function gE(N,F,A,M,D,E,$){if(!A||E.length===0)return;for(let y of E){if(y.startOffset<F.start||y.startOffset>F.end)continue;let Z=M+(b0(F,y.startOffset-F.start)-F.left);N.fillStyle=y9($,y),N.fillText(y.text,Z,D)}}function hE(N,F,A,M,D,E,$){if(!A||E.length===0)return;for(let y of E){if(y.offset<F.start||y.offset>=F.end)continue;let{left:Z,right:Y}=V2(F,M,y.offset,y.offset+1),X=Math.max(RE,(Y-Z)/2+RE+yq*y.progress),{ascent:Q,descent:S}=e0(F.font),J=D-Math.max(1,Q*0.42)+Math.max(0.5,S*0.15);N.strokeStyle=Z9(y,$),N.lineWidth=Zq,N.beginPath(),N.arc((Z+Y)/2,J,X,0,Math.PI*2),N.stroke()}}function Hq(N,F,A){let{ascent:M}=e0(A),D=N-$2(F,A);return Math.max(D+2,N-Math.round(M*0.32))}function _q(N,F,A){let{descent:M}=e0(A),D=Math.max(1,Math.round(Math.max(2,M)*0.35)),E=N+M-D,$=N-$2(F,A);return Math.min($+F-4,E)}function V2(N,F,A,M){return{left:F+(b0(N,A-N.start)-N.left),right:F+(b0(N,M-N.start)-N.left)}}function IE(N,{alpha:F=1,color:A,eraseExistingGlyphs:M=!1,height:D,left:E,text:$,textBaseline:y,textLeft:Z,top:Y,width:X}){if(X<=0||F<=0)return;if(N.save(),N.beginPath(),N.rect(E,Y,X,D),N.clip(),M)N.globalCompositeOperation="destination-out",N.fillText($,Z,y);N.globalCompositeOperation="source-over",N.globalAlpha*=F,N.fillStyle=A,N.fillText($,Z,y),N.restore()}var pE=new Map,xE=new Map;function L8(N,F,A,M){Bq({activeBlockId:M.activeBlockId,activeRegionId:M.activeRegionId,activeThreadIndex:M.activeThreadIndex,contentPulseTime:M.contentPulseTime,containerLineBounds:F.regionBounds,context:A,devicePixelRatio:M.devicePixelRatio,editorState:N,height:M.height,layout:F.layout,liveCommentRanges:M.liveCommentRanges,normalizedSelection:M.normalizedSelection,presenceActiveThreadColors:M.presenceActiveThreadColors??xE,now:M.now,resources:M.resources??{images:new Map},runtimeBlockMap:F.blockMap,textDecorations:M.textDecorations??pE,theme:M.theme,viewportTop:F.paintTop,width:M.width})}function T8(N,F,A,M){B8({context:A,devicePixelRatio:M.devicePixelRatio,editorState:N,height:M.height,layout:F.layout,normalizedSelection:M.normalizedSelection,presence:M.presence,showCaret:M.showCaret,theme:M.theme,viewportTop:F.paintTop,width:M.width})}function Bq({activeBlockId:N,activeRegionId:F,activeThreadIndex:A,containerLineBounds:M,context:D,devicePixelRatio:E,editorState:$,height:y,layout:Z,liveCommentRanges:Y,normalizedSelection:X,now:Q=wq(),contentPulseTime:S=Q,presenceActiveThreadColors:J=xE,resources:V,runtimeBlockMap:K,textDecorations:q=pE,theme:U,viewportTop:z,width:G}){D.save(),D.scale(E,E),D.clearRect(0,0,G,y),D.fillStyle=U.background,D.fillRect(0,0,G,y),D.textBaseline="alphabetic",D.translate(0,-z);let{endIndex:H,startIndex:B}=m1(Z,z,y),_=BE($,X),O=A9($,Q),w=M9($,Q),b=F9($,Q),L=E9($,Q),W=D9($,Q),v=UE(Z,$,N,B,H),g=SE(Z,$,K,B,H,G);for(let P=B;P<H;P+=1){let R=Z.lines[P];XE(D,R,K.get(R.blockId)??null,M.get(R.regionId)??null,$.documentIndex.tableCellIndex.get(R.regionId)??null,U,G)}let j=B6(Z,z,y);JE(D,Z,j.startIndex,j.endIndex,U,G),$E({activeBlockFlashes:O,activeBlockId:N,activeRegionId:F,context:D,editorState:$,endIndex:H,layout:Z,regionBounds:M,startIndex:B,theme:U,verticalBleed:z3});for(let P=B;P<H;P+=1){let R=Z.lines[P];Pq({activeBlockId:N,activeBlockFlashes:O,contentPulseTime:S,activeTextFades:w,activeTextHighlights:b,activeBlockPulses:L,activeTextPulses:W,activeThreadIndex:A,context:D,editorState:$,line:R,liveCommentRanges:Y,normalizedSelection:X,presenceActiveThreadColors:J,resources:V,runtimeBlockMap:K,selectionRegionOrderRange:_,textDecorations:q,theme:U,width:G})}VE(D,g,U),KE(D,v,U),D.restore()}function Pq({activeBlockId:N,activeBlockFlashes:F,contentPulseTime:A,activeTextFades:M,activeTextHighlights:D,activeBlockPulses:E,activeTextPulses:$,activeThreadIndex:y,context:Z,editorState:Y,line:X,liveCommentRanges:Q,normalizedSelection:S,presenceActiveThreadColors:J,resources:V,runtimeBlockMap:K,selectionRegionOrderRange:q,textDecorations:U,theme:z,width:G}){let H=K.get(X.blockId)??null,B=Y.documentIndex.blockIndex.get(X.blockId)?.path??null,_=Y.documentIndex.regionIndex.get(X.regionId)??null,O=_?.path??"",w=z1(Y,X.blockId,"listItem"),b=w?Z2(Y,w.id):null,L=w?E.get(w.path)??null:null,W=X.left+g0(Y,X),v=Wq(X),g=H?.type==="code"?z.codeText:Oq(H,z);Z.font=X.font,QE(Z,X,H,B,N,F,z,G);let j=U.size>0?U.get(O):null;if(j)w8(Z,X,_,W,v,j,"background",A,g);if(PE(Z,Y,X,S,q,z),WE(Z,Y,X,Q,y,J,A,z),_E(Z,X,b,W,v,g,z,L),mE(Z,X,_,W,v,g,V,z),j)w8(Z,X,_,W,v,j,"overlay",A,g);kE(Z,X,_,W,v,D.get(O)??[],z),gE(Z,X,_,W,v,M.get(O)??[],g),hE(Z,X,_,W,v,$.get(O)??[],z)}function Wq(N){return N.top+$2(N.height,N.font)}function Oq(N,F){switch(N?.type){case"heading":return F.headingText;case"blockquote":return F.blockquoteText;case"table":return F.headingText;default:return F.paragraphText}}function wq(){return performance.now()}function C8(N,F,A){if(A.length===0)return F.size===0?null:new Map;let M=N.documentIndex,D=new Set(M.regions.map((y)=>y.path)),E=new Map([...F].filter(([y])=>D.has(y))),$=E.size!==F.size;for(let y of A){let Z=new Set(M.roots[y.rootIndex]?.regions.map((X)=>X.path)??[]);for(let X of Z)E.delete(X);let Y=Lq(y.ranges.flatMap((X)=>{let Q=M.regionPathIndex.get(X.path);if(!Q||Q.rootIndex!==y.rootIndex)return[];return[{...X.backgroundColor&&{backgroundColor:X.backgroundColor},...X.color&&{color:X.color},...X.backgroundColor&&X.pulse&&{pulse:!0},endOffset:X.endOffset,path:X.path,startOffset:X.startOffset}]}));for(let[X,Q]of Y)E.set(X,Q);if(!Tq(F,E,Z))$=!0}return $?E:null}function Lq(N){let F=new Map;for(let A of N){let M=F.get(A.path);if(M)M.push(A);else F.set(A.path,[A])}for(let A of F.values())A.sort((M,D)=>M.startOffset-D.startOffset);return F}function Tq(N,F,A){for(let M of A)if(!Cq(N.get(M)??[],F.get(M)??[]))return!1;return!0}function Cq(N,F){if(N.length!==F.length)return!1;return N.every((A,M)=>{let D=F[M];return A.color===D.color&&A.backgroundColor===D.backgroundColor&&Boolean(A.backgroundColor&&A.pulse)===Boolean(D.backgroundColor&&D.pulse)&&A.endOffset===D.endOffset&&A.startOffset===D.startOffset})}function j8(N,F,A){if(A.size===0)return!1;let{endIndex:M,startIndex:D}=m1(F.layout,F.viewport.top,F.viewport.height);for(let E=D;E<M;E+=1){let $=F.layout.lines[E];if(!$)continue;if(G1(F,{bottom:$.top+$.height,top:$.top})!=="visible")continue;let y=N.documentIndex.regionIndex.get($.regionId)?.path??null;if((y?A.get(y):null)?.some((Y)=>jq(Y,$)))return!0}return!1}function jq(N,F){return N.pulse===!0&&Boolean(N.backgroundColor)&&N.endOffset>F.start&&N.startOffset<F.end}function lE(N,F,A){return pD(N,F,A,h0(N).liveRanges)}function R8(N,F,A){return xD(N,F,A,h0(N).liveRanges)}import{forwardRef as vq,createElement as mq}from"react";var _3=(...N)=>N.filter((F,A,M)=>{return Boolean(F)&&F.trim()!==""&&M.indexOf(F)===A}).join(" ").trim();var dE=(N)=>N.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var aE=(N)=>N.replace(/^([A-Z])|[\s-_]+(\w)/g,(F,A,M)=>M?M.toUpperCase():A.toLowerCase());var b8=(N)=>{let F=aE(N);return F.charAt(0).toUpperCase()+F.slice(1)};import{forwardRef as uq,createElement as sE}from"react";var B3={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 rE=(N)=>{for(let F in N)if(F.startsWith("aria-")||F==="role"||F==="title")return!0;return!1};import{createContext as Rq,useContext as bq,useMemo as _T,createElement as BT}from"react";var fq=Rq({});var cE=()=>bq(fq);var iE=uq(({color:N,size:F,strokeWidth:A,absoluteStrokeWidth:M,className:D="",children:E,iconNode:$,...y},Z)=>{let{size:Y=24,strokeWidth:X=2,absoluteStrokeWidth:Q=!1,color:S="currentColor",className:J=""}=cE()??{},V=M??Q?Number(A??X)*24/Number(F??Y):A??X;return sE("svg",{ref:Z,...B3,width:F??Y??B3.width,height:F??Y??B3.height,stroke:N??S,strokeWidth:V,className:_3("lucide",J,D),...!E&&!rE(y)&&{"aria-hidden":"true"},...y},[...$.map(([K,q])=>sE(K,q)),...Array.isArray(E)?E:[E]])});var k=(N,F)=>{let A=vq(({className:M,...D},E)=>mq(iE,{ref:E,iconNode:F,className:_3(`lucide-${dE(b8(N))}`,`lucide-${N}`,M),...D}));return A.displayName=b8(N),A};var kq=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],h1=k("columns-2",kq);var gq=[["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"}]],I1=k("rows-3",gq);var hq=[["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"}]],p1=k("send-horizontal",hq);var Iq=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],MF=k("arrow-down",Iq);var pq=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],DF=k("arrow-up",pq);var xq=[["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"}]],EF=k("bold",xq);var lq=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],q2=k("check",lq);var dq=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],$F=k("chevron-down",dq);var aq=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],yF=k("code",aq);var rq=[["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"}]],ZF=k("heading-1",rq);var cq=[["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"}]],YF=k("heading-2",cq);var sq=[["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"}]],XF=k("heading-3",sq);var iq=[["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"}]],QF=k("heading-5",iq);var oq=[["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"}]],SF=k("heading-4",oq);var nq=[["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"}]],JF=k("heading-6",nq);var tq=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],VF=k("heading",tq);var eq=[["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"}]],qF=k("italic",eq);var NU=[["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"}]],UF=k("list-ordered",NU);var FU=[["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"}]],KF=k("list-todo",FU);var AU=[["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"}]],zF=k("list",AU);var MU=[["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"}]],GF=k("message-square-plus",MU);var DU=[["path",{d:"M5 12h14",key:"1ays0h"}]],HF=k("minus",DU);var EU=[["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"}]],U2=k("pencil",EU);var $U=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ZN=k("plus",$U);var yU=[["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"}]],_F=k("strikethrough",yU);var ZU=[["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"}]],x1=k("table-2",ZU);var YU=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],BF=k("text-quote",YU);var XU=[["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"}]],s0=k("trash-2",XU);var QU=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],PF=k("underline",QU);var SU=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],WF=k("x",SU);import{jsx as YN,jsxs as UU}from"react/jsx-runtime";function oE({insetX:N,insetY:F,onSelect:A,presence:M}){if(!M)return null;return YN("div",{"aria-label":"Presence",className:"documint-presence-indicators",style:{paddingRight:`${N}px`,top:`${F}px`},children:M.map((D)=>YN(JU,{onSelect:()=>A(D),presence:D},D.id))})}function JU({onSelect:N,presence:F}){let A=F.viewport,M=VU(F),D=A?.status==="above"?DF:MF,E=A!==null&&A.status!=="unresolved",$=A?.status==="above"||A?.status==="below";return UU("button",{"aria-label":qU(F),className:"documint-presence-indicator","data-status":A?.status??"unresolved",disabled:!E,onClick:E?N:void 0,style:{"--documint-presence-color":F.color??"var(--documint-leaf-accent)"},type:"button",children:[YN("span",{className:"documint-presence-indicator-avatar",children:F.avatarUrl?YN("img",{alt:"","aria-hidden":"true",className:"documint-presence-indicator-image",draggable:!1,src:F.avatarUrl}):M}),$?YN("span",{className:"documint-presence-indicator-direction","aria-hidden":"true",children:YN(D,{className:"documint-presence-indicator-arrow",size:14,strokeWidth:2.3})}):null]})}function VU(N){return nE(N).charAt(0).toLocaleUpperCase()}function qU(N){let F=nE(N),A=N.viewport?.status??"unresolved";if(A==="above")return`${F} above viewport`;if(A==="below")return`${F} below viewport`;if(A==="unresolved")return`${F} unresolved`;return`${F} in viewport`}function nE(N){return(N.fullName??N.username).trim()||"Presence"}var s=`
|
|
29
|
+
`,XN="<ins>",OF="</ins>",QN=">",wF="```",P3=":::",W3="documint-comments";var TF="\\",w3="`",M$=":",LF=" ",u8="![",tE="@[",v8="[",m8="(",eE=")",N$=/[\p{L}\p{N}]/u,KU=/[A-Za-z]/,zU=/[-A-Za-z0-9_]/,O3=/\{width=([1-9]\d*)\}/y,GU=/\\([\\`*_[\]{}()#+\-.!~|@])/g,D$=/\\(.)/g,E$=[{delimiter:"**",mark:"bold",requireWordBoundary:!1},{delimiter:"~~",mark:"strikethrough",requireWordBoundary:!1},{delimiter:"*",mark:"italic",requireWordBoundary:!1},{delimiter:"_",mark:"italic",requireWordBoundary:!0}],HU=new Set(E$.map((N)=>N.delimiter[0]));function CF(N){return L3(N,0,N.length,[])}function L3(N,F,A,M){let D=[],E=F,$=F;while(E<A){let y=_U(N,E,A,M);if(y){let Z=Math.max($,E-(y.trimLeading??0));F$(D,N.slice($,Z),M),D.push(...y.nodes),E=y.end,$=E;continue}if(N[E]===TF){E+=Math.min(2,A-E);continue}E+=1}return F$(D,N.slice($,A),M),W0(D)}function _U(N,F,A,M){let D=N[F];switch(D){case M$:return BU(N,F,A);case"<":return wU(N,F,A)??PU(N,F,A,M)??WU(N,F,A);case TF:return LU(N,F,A);case s:return TU(N,F);case w3:return CU(N,F,A);case"!":return jU(N,F,A);case"@":return RU(N,F,A);case v8:return bU(N,F,A,M)}if(D!==void 0&&HU.has(D))return uU(N,F,A,M);return null}function BU(N,F,A){if(N[F]!==M$||!KU.test(N[F+1]??""))return null;let M=F+2;while(M<A&&zU.test(N[M]??""))M+=1;let D=A$(N,M,A,"[","]"),$=A$(N,D?.end??M,A,"{","}")?.end??D?.end??M;return{end:$,nodes:[$$("textDirective",N.slice(F,$))]}}function PU(N,F,A,M){if(!N.startsWith(XN,F))return null;let D=N.indexOf(OF,F+XN.length);if(D<0||D>=A)return null;return{end:D+OF.length,nodes:L3(N,F+XN.length,D,[...M,"underline"])}}function WU(N,F,A){if(N[F]!=="<")return null;let M=N.indexOf(">",F+1);if(M<0||M>=A)return null;return{end:M+1,nodes:[$$("html",N.slice(F,M+1))]}}var OU=/^<br\s*\/?>/i;function wU(N,F,A){if(N[F]!=="<")return null;let M=OU.exec(N.slice(F,A));if(!M)return null;let D=F+M[0].length;return{end:N[D]===s?D+1:D,nodes:[y1()]}}function LU(N,F,A){if(N[F]!==TF||N[F+1]!==s||F+1>=A)return null;return{end:F+2,nodes:[y1()]}}function TU(N,F){if(N[F]!==s||N[F-1]!==LF||N[F-2]!==LF)return null;let A=0;while(N[F-1-A]===LF)A+=1;return{end:F+1,nodes:[y1()],trimLeading:A}}function CU(N,F,A){if(N[F]!==w3)return null;let M=1;while(F+M<A&&N[F+M]===w3)M+=1;let D=w3.repeat(M),E=N.indexOf(D,F+M);if(E<0||E>=A)return null;return{end:E+M,nodes:[O1(N.slice(F+M,E))]}}function jU(N,F,A){if(!N.startsWith(u8,F))return null;let M=g8(N,F+1,A);if(M<0||N[M+1]!==m8)return null;let D=k8(N,M+1,A);if(!D)return null;let E=fU(N,D.end,A);return{end:E?.end??D.end,nodes:[w1({alt:h8(N.slice(F+u8.length,M)),title:D.title,url:D.url,width:E?.width??null})]}}function RU(N,F,A){if(!N.startsWith(tE,F))return null;let M=g8(N,F+1,A);if(M<0||N[M+1]!==m8)return null;let D=k8(N,M+1,A);if(!D||D.title!==null)return null;return{end:D.end,nodes:[C2({name:h8(N.slice(F+tE.length,M)),userId:D.url})]}}function bU(N,F,A,M){if(N[F]!==v8||N.startsWith(u8,F-1))return null;let D=g8(N,F,A);if(D<0||N[D+1]!==m8)return null;let E=k8(N,D+1,A);if(!E)return null;return{end:E.end,nodes:[o1({children:L3(N,F+v8.length,D,M),title:E.title,url:E.url})]}}function k8(N,F,A){let M=f8(N,F+1,A),D=M;while(D<A&&N[D]!==eE&&N[D]!==LF){if(N[D]===TF){D+=2;continue}D+=1}if(D===M)return null;let E=vU(N.slice(M,D));M=f8(N,D,A);let $=null;if(M<A&&N[M]==='"'){let y=T3(N,'"',M+1,A);if(y<0)return null;$=N.slice(M+1,y).replace(D$,"$1"),M=f8(N,y+1,A)}if(N[M]!==eE)return null;return{end:M+1,title:$,url:E}}function fU(N,F,A){O3.lastIndex=F;let M=O3.exec(N);if(!M||O3.lastIndex>A)return null;return{end:O3.lastIndex,width:Number(M[1])}}function uU(N,F,A,M){for(let D of E$){if(!N.startsWith(D.delimiter,F))continue;let E=T3(N,D.delimiter,F+D.delimiter.length,A);if(E<0)continue;if(D.requireWordBoundary){let y=F>0?N[F-1]:"",Z=N[E+D.delimiter.length]??"";if(N$.test(y)||N$.test(Z))continue}let $=F+D.delimiter.length;return{end:E+D.delimiter.length,nodes:L3(N,$,E,[...M,D.mark])}}return null}function F$(N,F,A){if(F.length===0)return;N.push(u0(h8(F),A))}function A$(N,F,A,M,D){if(N[F]!==M)return null;let E=T3(N,D,F+1,A);if(E<0)return null;return{end:E+1}}function g8(N,F,A){return T3(N,"]",F+1,A)}function T3(N,F,A,M){for(let D=A;D<M;D+=1){if(N[D]===TF){D+=1;continue}if(N.startsWith(F,D))return D}return-1}function f8(N,F,A){while(F<A&&N[F]===LF)F+=1;return F}function h8(N){return N.replace(GU,"$1")}function vU(N){return N.replace(D$,"$1")}function $$(N,F){return cF({originalType:N,source:F})}var mU=/^:?-+:?$/;function Z$(N,F){let A=_0(N),M=p8(N,1),D=f0(A,F),E=f0(M,F);if(!y$(D)||!I8(E))return null;let $=[C3(D)],y=kU(E);N.index+=2;while(N.index<N.lines.length){let Z=_0(N),Y=f0(Z,F);if(l1(Z)||!y$(Y))break;$.push(C3(Y)),N.index+=1}return e1({align:y,rows:$.map((Z)=>j2(Z.map((Y)=>L1(CF(Y)))))})}function I8(N){let F=C3(N);return F.length>0&&F.every((A)=>mU.test(A.trim()))}function y$(N){let F=N.trim();return F.startsWith("|")&&F.endsWith("|")}function kU(N){return C3(N).map((F)=>{let A=F.trim();if(A.startsWith(":")&&A.endsWith(":"))return"center";if(A.startsWith(":"))return"left";if(A.endsWith(":"))return"right";return null})}function C3(N){let F=N.trim();if(!F.startsWith("|")||!F.endsWith("|"))return[];return F.slice(1,-1).split("|").map((A)=>A.trim())}var gU=3,Y$=/^(#{1,6})\s+(.*)$/,hU=/\s+#+\s*$/u,IU=/^(\s*)([-+*]|\d+\.)(?:\s+(.*)|\s*)$/,pU=/^\d+\.$/,xU=/^\[( |x|X)\](?:\s|$)/,X$=/^```([^\s`]*)?(?:\s+(.*))?$/,Q$=/^:::([A-Za-z][-\w]*)(.*)$/,lU=[/^(\*\s*){3,}$/,/^(-\s*){3,}$/,/^(_\s*){3,}$/];function R3(N,F,A){let M=[];while(N.index<N.lines.length){let D=_0(N);if(N.index===N.lines.length-1&&D==="")break;if(l1(D)){N.index+=1;continue}if(SN(D)>F+gU)break;let E=dU(N,F,A);if(!E)break;M.push(E)}return M}function dU(N,F,A){return aU(N,F,A)??rU(N,F)??cU(N,F)??iU(N,F)??oU(N,F)??Z$(N,F)??nU(N,F,A)??eU(N,F)??NK(N,F)}function aU(N,F,A){let M=_0(N);if(!f0(M,F).startsWith(QN))return null;let D=[];while(N.index<N.lines.length){let E=_0(N),$=SN(E);if(l1(E)){D.push(""),N.index+=1;continue}if($<F)break;let y=f0(E,F);if(!y.startsWith(QN))break;let Z=y.slice(1);if(Z.startsWith(" "))Z=Z.slice(1);D.push(Z),N.index+=1}return d0(R3({index:0,lines:D},0,A))}function rU(N,F){let A=_0(N),M=f0(A,F),D=X$.exec(M);if(!D)return null;N.index+=1;let E=[];while(N.index<N.lines.length){let $=_0(N),y=f0($,F);if(y.trim()===wF){N.index+=1;break}E.push(y),N.index+=1}return Y4({language:D[1]?D[1]:null,meta:D[2]?D[2]:null,source:E.join(s)})}function cU(N,F){let A=_0(N),M=f0(A,F),D=Q$.exec(M);if(!D)return null;let E=D[1],$=[];N.index+=1;while(N.index<N.lines.length){let y=_0(N),Z=f0(y,F);if(Z.trim()===P3){N.index+=1;break}$.push(Z),N.index+=1}return NM({attributes:sU(D[2]??""),body:$.join(s),name:E})}function sU(N){let F=N.trim();if(F.startsWith("{")&&F.endsWith("}"))return F.slice(1,-1);return F}function iU(N,F){let A=_0(N),M=Y$.exec(f0(A,F));if(!M)return null;return N.index+=1,rF({children:CF(M[2].replace(hU,"")),depth:M[1].length})}function oU(N,F){let A=f0(_0(N),F).trim();if(!S$(A))return null;return N.index+=1,sF()}function nU(N,F,A){let M=j3(_0(N),F);if(!M)return null;let D=[],E=!1;while(N.index<N.lines.length){let $=_0(N),y=j3($,F);if(!y||y.ordered!==M.ordered)break;N.index+=1;let Z=[y.content],Y=!1;while(N.index<N.lines.length){let X=_0(N),Q=SN(X);if(l1(X)){let S=MK(N.lines,N.index+1);if(S<0||SN(N.lines[S]??"")<=F)break;Y=!0,Z.push(""),N.index+=1;continue}if(Q<y.contentIndent)break;if(Q===F&&j3(X,F))break;Z.push(AK(X,y.contentIndent)),N.index+=1}E||=Y,D.push(n1({checked:y.checked,children:tU(Z,A),spread:Y}))}return t1({items:D,ordered:M.ordered,spread:E,start:M.ordered&&A.preserveOrderedListStart?M.start??1:null})}function j3(N,F){let A=IU.exec(N);if(!A||A[1].length!==F)return null;let M=A[2],D=pU.test(M),E=D?Number(M.slice(0,-1)):null,$=A[3]??"",y=null;if(xU.test($)){if(y=$[1]==="x"||$[1]==="X",$=$.slice(3),$.startsWith(" "))$=$.slice(1)}let Z=A[0].length-A[1].length-A[2].length-$.length;return{checked:y,content:$,contentIndent:F+A[2].length+Z,ordered:D,start:E}}function tU(N,F){let A=R3({index:0,lines:N},0,F);if(A.length>0)return A;return[$1([])]}function eU(N,F){let A=f0(_0(N),F).trim();if(!J$(A))return null;return N.index+=1,X4({originalType:"html",source:A})}function NK(N,F){let A=[];while(N.index<N.lines.length){let M=_0(N),D=SN(M);if(l1(M))break;if(D<F)break;let E=f0(M,F);if(A.length>0&&FK(M,E,F))break;A.push(E),N.index+=1}return $1(CF(A.join(s)))}function FK(N,F,A){let M=F.trim();return F.startsWith(QN)||X$.test(F)||Q$.test(F)||Y$.test(F)||S$(M)||I8(F)||j3(N,A)!==null||J$(M)}function SN(N){let F=0;while(F<N.length&&N[F]===" ")F+=1;return F}function AK(N,F){let A=SN(N);if(A>=F)return N.slice(F);return N.trim()===""?"":N.slice(Math.min(A,F))}function MK(N,F){for(let A=F;A<N.length;A+=1)if(!l1(N[A]??""))return A;return-1}function S$(N){return lU.some((F)=>F.test(N))}function J$(N){return N.startsWith("<")&&N.endsWith(">")}function q$(N){let F=N.at(-1),A=F&&V$(F)?F:null;return{blocks:N.filter((D)=>!V$(D)),comments:A?DK(A.body):[]}}function DK(N){let F;try{F=JSON.parse(N)}catch{return[]}if(!Array.isArray(F))return[];return F.flatMap((A)=>{let M=w4(A);return M?[M]:[]})}function V$(N){return N.type==="directive"&&N.name===W3}var U$="---";function jF(N,F={}){let M={index:0,lines:N.replace(/\r\n/g,s).split(s)},D=EK(M),E=R3(M,0,F),{comments:$,blocks:y}=q$(E);return v2(y,$,D)}function EK(N){if(N.lines[0]!==U$)return;for(let F=1;F<N.lines.length;F+=1)if(N.lines[F]===U$){let A=N.lines.slice(0,F+1).join(s);return N.index=F+1,A}return}function _0(N){return p8(N,0)}function p8(N,F){return N.lines[N.index+F]??""}function l1(N){return N.trim()===""}function f0(N,F){return N.slice(F)}var $K=/([\\`*_[\]])/g,yK=/([\\)&])/g,ZK=/(["\\])/g;function J1(N){let F=W0(N);return F.map((A,M)=>YK(A,F[M+1])).join("")}function YK(N,F){switch(N.type){case"lineBreak":return"<br>";case"image":return SK(N);case"mention":return JK(N);case"code":return QK(N.code);case"link":return VK(N);case"text":return XK(x8(N.text,F),N.marks);case"raw":return N.source}}function XK(N,F){return F.reduce((A,M)=>{switch(M){case"bold":return`**${A}**`;case"italic":return`*${A}*`;case"strikethrough":return`~~${A}~~`;case"underline":return`${XN}${A}${OF}`}},N)}function QK(N){let F=0,A=0;for(let $ of N){if($==="`"){if(A+=1,A>F)F=A;continue}A=0}let M=F>0?F+1:1,D="`".repeat(M),E=N.startsWith("`")||N.endsWith("`")?` ${N} `:N;return`${D}${E}${D}`}function SK(N){let F=x8(N.alt??""),A=K$(N.url,N.title),M=N.width?`{width=${N.width}}`:"";return`![${F}]${A}${M}`}function JK(N){return`@[${x8(N.name)}](${z$(N.userId)})`}function VK(N){return`[${J1(N.children)}]${K$(N.url,N.title)}`}function K$(N,F){return`(${z$(N)}${qK(F)})`}function x8(N,F){let A=N.replace($K,"\\$1").replace(/@(?=\[)/g,"\\@");return F?.type==="link"&&A.endsWith("@")?`${A.slice(0,-1)}\\@`:A}function z$(N){return N.replace(yK,"\\$1")}function qK(N){return N?` "${N.replace(ZK,"\\$1")}"`:""}var H$=3;function _$(N,F,A){let M=N.rows.map((X)=>X.cells.map((Q)=>J1(Q.children))),D=Math.max(1,...M.map((X)=>X.length)),E=M[0]??[],$=Array.from({length:D},(X,Q)=>Math.max(GK(N.align[Q]),...A.padTableColumns?M.map((S)=>S[Q]?.length??0):[E[Q]?.length??0])),y=UK($,N.align,F),Z=G$(E,$,N.align,F,A),Y=M.slice(1).map((X)=>G$(X,$,N.align,F,A));return[Z??KK($,F),y,...Y].join(s)}function G$(N,F,A,M,D){let E=F.map(($,y)=>{let Z=N[y]??"";if(!D.padTableColumns)return Z;return HK(Z,$,A[y])});return`${" ".repeat(M)}| ${E.join(" | ")} |`}function UK(N,F,A){let M=N.map((D,E)=>zK(F[E],D));return`${" ".repeat(A)}| ${M.join(" | ")} |`}function KK(N,F){return`${" ".repeat(F)}| ${N.map((A)=>"".padEnd(A," ")).join(" | ")} |`}function zK(N,F){let A=B$(N),M=Math.max(H$,F-A),D="-".repeat(M);switch(N){case"center":return`:${D}:`;case"left":return`:${D}`;case"right":return`${D}:`;default:return D}}function GK(N){return H$+B$(N)}function B$(N){if(N==="center")return 2;return N?1:0}function HK(N,F,A){if(A==="right")return N.padStart(F," ");return N.padEnd(F," ")}var K2=`
|
|
30
|
+
|
|
31
|
+
`,_K="-",BK=".",PK="---",WK=" ";function RF(N,F={}){return N.map((A)=>b3(A,0,F)).join(K2)}function b3(N,F,A){let M=z2(F);switch(N.type){case"blockquote":return OK(N,F,A);case"code":return wK(N,F);case"directive":return LK(N,F);case"heading":return P$(N,F);case"list":return TK(N,F,A);case"listItem":return W$(N,F,!1,1,A);case"paragraph":return`${M}${l8(J1(N.children))}`;case"table":return _$(N,F,A);case"divider":return`${M}${PK}`;case"raw":return F===0?N.source:O$(N.source,F)}}function OK(N,F,A){let M=N.children.map((E)=>b3(E,0,A)).join(K2),D=z2(F);return M.split(s).map((E)=>`${D}${QN}${E.length>0?` ${E}`:""}`).join(s)}function wK(N,F){let A=[N.language??"",N.meta??""].filter(Boolean).join(" ").trim(),M=z2(F),D=`${M}${wF}${A?A:""}`,E=N.source.length>0?N.source.split(s).map(($)=>`${M}${$}`).join(s):M;return`${D}${s}${E}${s}${M}${wF}`}function LK(N,F){let A=f3(N);return F===0?A:O$(A,F)}function f3(N){let F=N.attributes?`{${N.attributes}}`:"";return`:::${N.name}${F}${s}${N.body}${s}${P3}`}function P$(N,F){let A=l8(J1(N.children)),M=`${z2(F)}${"#".repeat(N.depth)}`;return A.length>0?`${M} ${A}`:M}function TK(N,F,A){let M=N.start??1;return N.items.map((D)=>W$(D,F,N.ordered,M,A)).join(N.spread?K2:s)}function W$(N,F,A,M,D){let E=A?`${M}${BK}`:_K,$=N.checked===null?"":`[${N.checked?"x":" "}] `,y=`${z2(F)}${E} ${$}`,Z=F+E.length+1,Y=N.children;if(Y.length===0)return $.length>0?y:y.trimEnd();let[X,...Q]=Y,S=CK(X,y,$.length>0,D),J=Q.map((V)=>b3(V,Z,D)).join(N.spread?K2:s);if(!J)return S;return`${S}${N.spread?K2:s}${J}`}function CK(N,F,A,M){switch(N.type){case"paragraph":{let D=l8(J1(N.children));if(D.length===0)return A?F:F.trimEnd();return`${F}${D}`}case"heading":return`${F}${P$(N,0)}`;case"directive":case"raw":{let D=N.type==="directive"?f3(N):N.source,[E,...$]=D.split(s);return[F+E,...$.map((y)=>`${z2(F.length)}${y}`)].join(s)}default:{let D=F.length;return`${F.trimEnd()}${s}${b3(N,D,M)}`}}}function l8(N){return N.replace(/^ +/gm,(F)=>WK.repeat(F.length))}function z2(N){return" ".repeat(N)}function O$(N,F){let A=z2(F);return N.split(s).map((M)=>`${A}${M}`).join(s)}function u3(N,F={}){if(N.blocks.length===0&&N.comments.length===0&&N.frontMatter===void 0)return"";let A=[];if(N.frontMatter!==void 0)A.push(N.frontMatter);if(N.blocks.length>0)A.push(RF(N.blocks,F));if(N.comments.length>0)A.push(jK(N.comments));let M=A.join(K2);return M.endsWith(s)?M:`${M}${s}`}function jK(N){return f3({attributes:"",body:JSON.stringify(N.map(RK),null,2),name:W3})}function RK({id:N,...F}){return F}function d8(N){if(N.length===0)return{kind:"text",text:""};let{blocks:F}=jF(N);if(tF(F))return{kind:"text",text:F[0]?.plainText??""};if(F.length===1&&F[0]?.type==="paragraph")return{kind:"inlines",inlines:F[0].children};return{kind:"blocks",blocks:F}}function G2(N){switch(N.kind){case"text":return N.text;case"inlines":return J1(N.inlines);case"blocks":return RF(N.blocks)}}import{createContext as bK,useContext as fK}from"react";import{createPortal as uK}from"react-dom";import{jsx as C$}from"react/jsx-runtime";var w$=bK(void 0);function L$({children:N,themeStyles:F}){return C$(w$.Provider,{value:F,children:N})}function T$({children:N}){let F=fK(w$);if(typeof document>"u")return null;return uK(C$("div",{className:"documint-overlay",style:{display:"contents",...F},children:N}),document.body)}import{useEffect as c3,useRef as Oy,useState as _2}from"react";function H2(N,F){return Object.is(N,F)}function a8(N){return(F,A)=>{if(F===A)return!0;if(!F||!A)return!1;return m3(N(F),N(A))}}function v3(N){return(F,A)=>{if(F===A)return!0;if(F.length!==A.length)return!1;return F.every((M,D)=>N(M,A[D]))}}function j$(N,F){return N.regionId===F.regionId&&N.offset===F.offset}function R$(N,F){return N.collapsed===F.collapsed&&j$(N.start,F.start)&&j$(N.end,F.end)}function b$(N,F){return vK(N.block,F.block)&&mK(N.span,F.span)}function f$(N,F){return kK(N.threads,F.threads)&&gK(N.liveRanges,F.liveRanges)}function u$(N,F){return m3(N,F)}function vK(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.blockId===F.blockId&&N.depth===F.depth&&N.nodeType===F.nodeType&&N.text===F.text}function mK(N,F){if(N===F)return!0;if(N.kind!==F.kind)return!1;switch(N.kind){case"link":return F.kind==="link"&&N.url===F.url;case"marks":return F.kind==="marks"&&m3(N.marks,F.marks);case"none":return!0}return!1}function kK(N,F){return m3(N,F)}function gK(N,F){if(N===F)return!0;if(N.length!==F.length)return!1;return N.every((A,M)=>{let D=F[M];return A.endOffset===D.endOffset&&A.regionId===D.regionId&&A.resolved===D.resolved&&A.startOffset===D.startOffset&&A.threadIndex===D.threadIndex})}function m3(N,F){if(N===F)return!0;if(N.length!==F.length)return!1;return N.every((A,M)=>Object.is(A,F[M]))}function v$(N,F,A){return hK(N,F,A)}function hK(N,F,A){let M=N.documentIndex!==F.documentIndex;return{previous:N,next:F,source:A==="external"?"external":"local",reason:A,documentChanged:M,changedRootIndexes:M?IK(N,F):[],animationsChanged:N.animations!==F.animations&&F.animations.length>0}}function IK(N,F){let A=N.documentIndex.document.blocks,M=F.documentIndex.document.blocks;if(A.length!==M.length)return M.map((D,E)=>E);return M.flatMap((D,E)=>D===A[E]?[]:[E])}function m$(N){let F=N,A=0,M=new Set,D=(E,$)=>{if(!E||E===F)return null;let Z=v$(F,E,$);F=E,A+=1;for(let Y of M)Y(Z);return Z};return{getVersion:()=>A,getState:()=>F,apply(E){return D(E,"command")},command(E,...$){return D(E(F,...$),"command")},replace(E,$="external"){return D(E,$)},subscribe(E){return M.add(E),()=>{M.delete(E)}},subscribeValue(E,$,y=H2){let Z=E(F),Y=(X)=>{let Q=E(X.next);if(y(Z,Q))return;Z=Q,$()};return M.add(Y),()=>{M.delete(Y)}}}}function k$(){let N=null,F=null,A=null,M=new Set,D=(E)=>{if(N=E,F===E)return;F=E;for(let $ of M)$()};return{get(){if(N)return N;if(!A)throw Error("Viewport resolver has not been registered.");return N=A(),N},invalidate(){N=null},peek(){return N},observeViewport(E){D(E)},peekPublishedViewport(){return F},setViewportResolver(E){A=E},subscribe(E){return M.add(E),()=>{M.delete(E)}}}}import{createContext as pK,useCallback as r8,useContext as xK,useSyncExternalStore as lK}from"react";import{jsx as dK}from"react/jsx-runtime";var g$=pK(null);function c8({children:N,store:F}){return dK(g$.Provider,{value:F,children:N})}function x0(){let N=xK(g$);if(!N)throw Error("Documint store is unavailable outside DocumintStoreProvider.");return N}function h(N){let F=x0().editor;return r8((...A)=>F.command(N,...A),[F,N])}function e(N,...F){let A=x0(),M=r8((E)=>N.subscribe(A,E,...F),[A,N,...F]),D=r8(()=>N.read(A,...F),[A,N,...F]);return lK(M,D,D)}function h$(N){if(!N?.length)return[];return N.map((F)=>({trigger:F.trigger,items:[...F.items].sort((A,M)=>A.label.localeCompare(M.label,void 0,{sensitivity:"base"}))}))}function I$(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.trigger===F.trigger&&N.items.length===F.items.length&&N.items.every((A,M)=>p$(A,F.items[M]))}function p$(N,F){return N.id===F.id&&N.icon===F.icon&&N.insertText===F.insertText&&N.kind===F.kind&&N.label===F.label}function x$(N,F){return N.length===F.length&&N.every((A,M)=>p$(A,F[M]))}function g3(N,F,A){for(let M=F-1;M>=0;M-=1){let D=N[M];if(k3(D))return null;let E=A.find((y)=>y.trigger===D);if(!E)continue;if(M>0&&!k3(N[M-1]))return null;let $=N.slice(M+1,F);return{trigger:E.trigger,query:$,triggerStart:M,caret:F,matches:aK(E.items,$)}}return null}function aK(N,F){if(!F)return N.slice(0,50);let A=F.toLowerCase(),M=[];for(let D of N)if(D.label.toLowerCase().includes(A)){if(M.push(D),M.length>=50)break}return M}function l$(N,F,A){let M=s8(F,A),D=N.slice(0,F.triggerStart),E=N.slice(F.caret);return{caret:F.triggerStart+M.length,value:D+M+E}}function s8(N,F){return F.insertText??`${N.trigger}${F.label} `}function h3(N,F){if(!F?.length||!F.some(($)=>N.includes($.trigger)))return[{kind:"text",text:N}];let A=new Map;for(let $ of F){let y=[...$.items].sort((Z,Y)=>Y.label.length-Z.label.length);A.set($.trigger,y)}let M=[],D=0,E=0;while(D<N.length){let $=N[D],y=A.get($);if(y!==void 0&&(D===0||k3(N[D-1]))){let Y=y.find((X)=>{if(!N.startsWith(X.label,D+1))return!1;return rK(N[D+1+X.label.length])});if(Y){if(D>E)M.push({kind:"text",text:N.slice(E,D)});M.push({kind:"token",trigger:$,label:Y.label,id:Y.id}),D+=1+Y.label.length,E=D;continue}}D+=1}if(E<N.length)M.push({kind:"text",text:N.slice(E)});return M}function k3(N){return N===void 0||N===" "||N===`
|
|
32
|
+
`||N==="\t"}function rK(N){return N===void 0||k3(N)||!/[\p{L}\p{N}_]/u.test(N)}function d$(N,F){let A=g6(N);if(!A)return null;let M=g3(A.text,A.offset,F??[]);return M?{...M,regionId:A.regionId}:null}function a$(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.regionId===F.regionId&&N.trigger===F.trigger&&N.query===F.query&&N.triggerStart===F.triggerStart&&N.caret===F.caret&&x$(N.matches,F.matches)}function r$(N,F){let A={endOffset:F.caret,regionId:F.regionId,startOffset:F.triggerStart};if(cK(N,F))return{kind:"mention",name:N.label,target:A,trailingText:" ",userId:N.id};return{endOffset:F.caret,kind:"text",startOffset:F.triggerStart,text:s8(F,N)}}function cK(N,F){return Boolean(N.id)&&(N.kind==="mention"||F.trigger==="@")}var c$=[["100","💯"],["airplane","✈️"],["alarm","⏰"],["angry","😠"],["astonished","😲"],["baby","👶"],["balloon","🎈"],["beer","🍺"],["birthday","🎂"],["blush","😊"],["bomb","💣"],["book","📚"],["boom","💥"],["broken_heart","💔"],["calendar","📅"],["camera","📷"],["cat","😺"],["check","✅"],["clap","👏"],["cold_sweat","😰"],["confetti_ball","🎊"],["confused","😕"],["cool","😎"],["cry","😢"],["disappointed","😞"],["dizzy","💫"],["dog","🐶"],["drooling","🤤"],["eggplant","🍆"],["eyes","👀"],["facepalm","🤦"],["fire","🔥"],["flushed","😳"],["ghost","👻"],["gift","🎁"],["grin","😁"],["grinning","😀"],["halo","😇"],["handshake","🤝"],["heart","❤️"],["heart_eyes","😍"],["hug","🤗"],["joy","😂"],["kiss","😘"],["laughing","😆"],["light_bulb","💡"],["loudspeaker","📢"],["love_letter","💌"],["melting","🫠"],["mind_blown","🤯"],["money_mouth","🤑"],["monocle","🧐"],["muscle","💪"],["nauseated","🤢"],["nerd","🤓"],["neutral","😐"],["ok_hand","👌"],["partying","🥳"],["pensive","😔"],["pizza","🍕"],["pleading","🥺"],["poop","💩"],["pray","🙏"],["raised_hands","🙌"],["relieved","😌"],["rocket","🚀"],["rofl","🤣"],["rolling_eyes","🙄"],["rose","🌹"],["scream","😱"],["see_no_evil","🙈"],["shushing","🤫"],["sleeping","😴"],["slightly_smiling","🙂"],["smile","😄"],["smiley","😃"],["smirk","😏"],["sob","😭"],["sparkles","✨"],["star","⭐"],["star_struck","🤩"],["sweat_smile","😅"],["tada","🎉"],["thinking","🤔"],["thumbs_down","👎"],["thumbs_up","👍"],["tired","😫"],["triumph","😤"],["unamused","😒"],["upside_down","🙃"],["warning","⚠️"],["wave","👋"],["weary","😩"],["wink","😉"],["woozy","🥴"],["writing","✍️"],["yawn","🥱"],["yum","😋"],["zany","🤪"],["zipper_mouth","🤐"]];var I3={trigger:":",items:c$.map(iK)};function iK(N){if(N.length!==2)throw Error("Emoji completion rows must be [label, value] tuples.");let[F,A]=N;return{label:F,icon:A,insertText:A}}function i8(N){if(!N?.length)return null;return{trigger:"@",items:N.map((F)=>({id:F.id,kind:"mention",label:F.fullName??F.username})).sort((F,A)=>F.label.localeCompare(A.label,void 0,{sensitivity:"base"}))}}function bF(N,F){return N.anchor.regionId===F.anchor.regionId&&N.anchor.offset===F.anchor.offset&&N.leftOverride===F.leftOverride&&N.paddingY===F.paddingY}function o8(N,F,A){if(!N||N.kind==="task-toggle")return null;if(N.commentThreadIndex!==null){let M=F[N.commentThreadIndex]??null,D=A.find((E)=>E.threadIndex===N.commentThreadIndex);if(!M||!D)return null;return{anchor:{regionId:D.regionId,offset:D.startOffset},animateInitialComment:!1,kind:"thread",link:N.kind==="link"?{title:N.title,url:N.url}:null,resolved:j1(M),thread:M,threadIndex:N.commentThreadIndex}}if(N.kind!=="link")return null;return{anchor:{regionId:N.regionId,offset:N.startOffset},endOffset:N.endOffset,kind:"link",regionId:N.regionId,startOffset:N.startOffset,title:N.title,url:N.url}}function l0(N,F,A=H2){return i0(N,(M,D,...E)=>F(M,...E),A)}function i$(N){let F=Object.entries(N),A=F.map(([,M])=>M);return l0(A,(M,...D)=>{let E={};for(let $=0;$<F.length;$++){let[y]=F[$];E[y]=D[$]}return E},oK)}function i0(N,F,A=H2){let M=new WeakMap,D=(E,...$)=>{let y=N.map((Q)=>Q.read(E)),Z=M.get(E);if(Z&&s$(Z.depValues,y)&&s$(Z.params,$))return Z.value;let Y=F(E,$,...y),X=Z&&A(Z.value,Y)?Z.value:Y;return M.set(E,{depValues:y,params:$,value:X}),X};return{read:D,subscribe(E,$,...y){let Z=D(E,...y),Y=()=>{let Q=D(E,...y);if(A(Z,Q))return;Z=Q,$()},X=N.map((Q)=>Q.subscribe(E,Y));return()=>{for(let Q of X)Q()}}}}function oK(N,F){if(N===F)return!0;let A=Object.keys(N),M=Object.keys(F);if(A.length!==M.length)return!1;return A.every((D)=>Object.is(N[D],F[D]))}function s$(N,F){return N.length===F.length&&N.every((A,M)=>Object.is(A,F[M]))}function n8({read:N,subscribe:F}){return{read:N,subscribe:F}}function p3(N,F=H2){return n8({read:(A)=>N(A.editor.getState()),subscribe:(A,M)=>A.editor.subscribeValue(N,M,F)})}var M1=n8({read:(N)=>N.viewport.peekPublishedViewport(),subscribe:(N,F)=>N.viewport.subscribe(F)});var nK=(N)=>N,K0=p3(nK),fF=p3((N)=>N.documentIndex),t8=p3((N)=>N.documentIndex.imageUrls);var tK=a8((N)=>[N.regionId,N.startOffset,N.endOffset]),eK=a8((N)=>[N.start.left,N.start.top,N.end.left,N.end.top]);function o$(N,F){return N.code===F.code&&u$(N.marks,F.marks)}var JN=l0([K0],(N,F)=>h0(F),f$),e8=l0([JN],(N,F)=>F.threads,v3(Object.is)),n$=l0([JN],(N,F)=>F.liveRanges,Jz),D1=l0([K0],(N,F)=>Z0(F),R$),t$=l0([K0],(N,F)=>t2(F),tK),e$=l0([K0],(N,F)=>x6(F),o$),Ny=l0([K0,D1,M1],(N,F,A,M)=>{if(!M)return null;return Mz(F,M,A)},eK),NA=i$({formatting:e$,handles:Ny,normalized:D1,range:t$,viewport:M1}),FA=i0([t$,e$,Ny,e8],(N,[F],A,M,D,E)=>{return $z({formatting:M,handles:D,promotedThread:F,selectionRange:A,threads:E})},yz),AA=i0([K0,D1,M1,e8,n$],(N,[F],A,M,D,E,$)=>{if(!D)return null;return Zz({isEditable:F,liveRanges:$,normalizedSelection:M,state:A,threads:E,viewport:D})},Sz),MA=l0([K0,D1,M1],(N,F,A,M)=>{if(!M)return!0;let D=u6(F,M,A.end);return D!=="above"&&D!=="below"}),DA=l0([K0,D1,M1],(N,F,A,M)=>{if(!M)return null;return J5(F,M,A.end)},Vz),EA=i0([K0],(N,[F],A)=>{return d$(A,F)},a$),$A=i0([],(N,[F])=>{let A=i8(F);return A?[A,I3]:[I3]},Nz);function Nz(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.length===F.length&&N.every((A,M)=>I$(A,F[M]))}var yA=i0([K0,M1,e8,n$],(N,[F],A,M,D,E)=>{let $=F?.kind==="link"&&M?R8(A,M,{regionId:F.regionId,offset:qz(F)}):F,y=o8($,D,E);return{cursor:F?.kind==="task-toggle"||y?.kind==="link"?"pointer":"text",leaf:y}},Uz),ZA=l0([K0],(N,F)=>h6(F),b$),YA=i0([K0,D1,M1],(N,[F],A,M,D)=>{if(!F||!D)return null;return Fz(A,D,M,F)},Az);function Fz(N,F,A,M){if(!A.collapsed)return null;let D=I6(N);if(!D)return null;let E=kN(N,F,M,D),$=D.image?M.images.get(D.image.url)?.intrinsicWidth??null:null;return E?{bounds:E,inline:D,maxWidth:$}:null}function Az(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.maxWidth===F.maxWidth&&N.bounds.left===F.bounds.left&&N.bounds.top===F.bounds.top&&N.bounds.width===F.bounds.width&&N.bounds.height===F.bounds.height}function Mz(N,F,A){if(A.collapsed)return null;let M=k1(N,F,A.start),D=k1(N,F,A.end);if(!M||!D)return null;return{end:{left:D.left,top:D.top+D.height},start:{left:M.left,top:M.top}}}var Dz=2;function Ez(N,F,A){return{formatting:A,anchor:{regionId:N.regionId,offset:N.endOffset},kind:"annotation",leftOverride:F.start.left,paddingY:Dz,selection:N}}function $z({formatting:N,handles:F,promotedThread:A,selectionRange:M,threads:D}){if(!M||!F)return null;if(A&&Fy(A.selection,M)){let E=D[A.threadIndex];if(!E)return null;return{...A,kind:"thread",link:null,resolved:j1(E),thread:E}}return Ez(M,F,N)}function Fy(N,F){return N.endOffset===F.endOffset&&N.regionId===F.regionId&&N.startOffset===F.startOffset}function yz(N,F){if(N===F)return!0;if(!N||!F)return!1;if(N.kind!==F.kind)return!1;switch(N.kind){case"annotation":return F.kind==="annotation"&&bF(N,F)&&o$(N.formatting,F.formatting)&&Fy(N.selection,F.selection);case"thread":return F.kind==="thread"&&l3(N,F)}}function Zz({isEditable:N,liveRanges:F,normalizedSelection:A,state:M,threads:D,viewport:E}){let $=M.selection.focus;if(!A.collapsed)return null;let y=N?Qz(M):null;if(y)return y;let Z=N?Yz(M,E):null;if(Z)return Z;return o8(R8(M,E,$),D,F)}function Yz(N,F){let A=N.selection.focus,M=N.documentIndex.regionIndex.get(A.regionId),D=M?N.documentIndex.tableCellIndex.get(M.id)??null:null;if(!M||!D)return null;let E=N.documentIndex.blockIndex.get(M.blockId),$=E?.type==="table"?N.documentIndex.document.blocks[E.rootIndex]:null;if(!E||!$||$.type!=="table")return null;let y=Xz(F,M.id),Z=Math.max(1,...$.rows.map((Y)=>Y.cells.length));return y!==null?{anchor:A,cellIndex:D.cellIndex,columnCount:Z,kind:"table",leftOverride:y,rowCount:$.rows.length,rowIndex:D.rowIndex}:null}function Xz(N,F){let A=N.layout.lines.find((M)=>M.regionId===F);return A?A.left:null}function Qz(N){let F=N.selection.focus,A=N.documentIndex.regionIndex.get(F.regionId);if(!A||A.blockType!=="paragraph"||A.text.length>0)return null;if(F.offset!==0)return null;let M=N.documentIndex.blockIndex.get(A.blockId);if(!M||M.parentBlockId!==null)return null;return{anchor:F,kind:"insertion"}}function Sz(N,F){if(N===F)return!0;if(!N||!F)return!1;if(N.kind!==F.kind)return!1;switch(N.kind){case"thread":return F.kind==="thread"&&l3(N,F);case"insertion":return F.kind==="insertion"&&bF(N,F);case"link":return F.kind==="link"&&l3(N,F);case"table":return F.kind==="table"&&bF(N,F)&&N.cellIndex===F.cellIndex&&N.columnCount===F.columnCount&&N.rowCount===F.rowCount&&N.rowIndex===F.rowIndex}}function Jz(N,F){if(N===F)return!0;if(N.length!==F.length)return!1;return N.every((A,M)=>{let D=F[M];return A.endOffset===D.endOffset&&A.regionId===D.regionId&&A.resolved===D.resolved&&A.startOffset===D.startOffset&&A.threadIndex===D.threadIndex})}function Vz(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.blockId===F.blockId&&N.regionId===F.regionId&&N.height===F.height&&N.left===F.left&&N.offset===F.offset&&N.top===F.top}function qz(N){return N.startOffset<N.endOffset?N.startOffset+1:N.startOffset}function Uz(N,F){return N.cursor===F.cursor&&Kz(N.leaf,F.leaf)}function Kz(N,F){if(N===F)return!0;if(!N||!F)return!1;return l3(N,F)}function l3(N,F){if(N.kind!==F.kind)return!1;if(!bF(N,F))return!1;switch(N.kind){case"thread":return F.kind==="thread"&&N.animateInitialComment===F.animateInitialComment&&N.link?.title===F.link?.title&&N.link?.url===F.link?.url&&N.resolved===F.resolved&&N.thread===F.thread&&N.threadIndex===F.threadIndex;case"link":return F.kind==="link"&&N.endOffset===F.endOffset&&N.regionId===F.regionId&&N.startOffset===F.startOffset&&N.title===F.title&&N.url===F.url}}var XA=l0([K0,JN],(N,F,A)=>zz(F,A.liveRanges));function zz(N,F){let A=new Map(N.documentIndex.regions.map((Z,Y)=>[Z.id,Y])),M=x3(A,N.selection.anchor.regionId,N.selection.anchor.offset),D=x3(A,N.selection.focus.regionId,N.selection.focus.offset),[E,$]=M<=D?[M,D]:[D,M],y=M===D;for(let Z of F){let Y=x3(A,Z.regionId,Z.startOffset),X=x3(A,Z.regionId,Z.endOffset);if(y){if(E>=Y&&E<=X)return Z.threadIndex;continue}if(Math.max(E,Y)<Math.min($,X))return Z.threadIndex}return null}function x3(N,F,A){return(N.get(F)??-1)*1e6+A}var Ay=i0([fF],(N,[F],A)=>{if(!F?.length)return;return b6(A,F)},My),QA=i0([fF,M1],(N,[F],A,M)=>{let D=Ay.read(N,F);if(!D)return;return M?f6(A,M,D):D},My),SA=i0([fF],(N,[F])=>{let A=Ay.read(N,F),M=new Map;for(let D of A??[])if(D.commentThreadIndex!=null&&!M.has(D.commentThreadIndex))M.set(D.commentThreadIndex,D.color??null);return M},Bz);function My(N,F){if(N===F)return!0;if(!N||!F)return!1;return Gz(N,F)}var Gz=v3((N,F)=>{return N.id===F.id&&N.username===F.username&&N.fullName===F.fullName&&N.avatarUrl===F.avatarUrl&&N.color===F.color&&N.commentThreadIndex===F.commentThreadIndex&&Hz(N.cursorPoint,F.cursorPoint)&&_z(N.viewport,F.viewport)});function Hz(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.offset===F.offset&&N.regionId===F.regionId}function _z(N,F){if(N===F)return!0;if(!N||!F)return!1;if(N.status!==F.status)return!1;if(N.status==="unresolved")return!0;return F.status!=="unresolved"&&N.scrollTop===F.scrollTop}function Bz(N,F){if(N===F)return!0;if(N.size!==F.size)return!1;for(let[A,M]of N)if(F.get(A)!==M)return!1;return!0}function Dy(N){return{editor:m$(FN(N)),viewport:k$()}}import{useEffect as Pz,useRef as Wz}from"react";import{jsx as JA,jsxs as Tz}from"react/jsx-runtime";var Oz="documint-leaf-menu-item documint-completion-item";function d3({activeIndex:N,matches:F,onHover:A,onSelect:M}){let D=Wz(null);return Pz(()=>{let E=D.current;if(!E)return;let $=E.children[N];if($ instanceof HTMLElement){let y=$.getBoundingClientRect(),Z=E.getBoundingClientRect();if(y.top<Z.top)E.scrollTop-=Z.top-y.top;else if(y.bottom>Z.bottom)E.scrollTop+=y.bottom-Z.bottom}},[N]),JA("div",{className:"documint-completion-leaf",ref:D,role:"listbox",children:F.map((E,$)=>{let y=$===N;return Tz("button",{"aria-selected":y,className:`${Oz}${y?" is-active":""}`,onPointerDown:wz,onPointerEnter:()=>A($),onClick:()=>M(E),role:"option",type:"button",children:[E.icon?JA("span",{"aria-hidden":"true",className:"documint-completion-item-icon",children:E.icon}):null,JA("span",{children:E.label})]},Lz(E))})})}function wz(N){N.preventDefault()}function Lz(N){return N.id??`${N.kind??""}:${N.label}:${N.insertText??""}:${N.icon??""}`}import{useCallback as az,useRef as rz}from"react";import{useCallback as uF,useEffect as bz,useEffectEvent as fz,useLayoutEffect as uz,useMemo as vz,useState as Xy}from"react";import{useCallback as VA,useEffect as Ey,useRef as $y,useState as yy}from"react";function a3({activeCompletion:N,contextKey:F,onAccept:A,onDismiss:M}){let[D,E]=yy(0),[$,y]=yy(null),Z=$y(!1),Y=$y(null),X=N?F??jz(N):null,Q=X===$||X===Y.current?null:N,S=Q?Math.min(D,Math.max(0,Q.matches.length-1)):D;Ey(()=>{E(0),Y.current=null},[X]),Ey(()=>{if(!X||$&&X!==$)y(null)},[X,$]);let J=VA((U)=>{if(!Q||!X||Y.current===X)return;Y.current=X,y(X),A(U,Q)},[X,A,Q]),V=VA((U)=>{if(!Q||Q.matches.length===0)return!1;if(U.key==="ArrowDown")return U.preventDefault(),U.stopPropagation(),E((z)=>(z+1)%Q.matches.length),!0;if(U.key==="ArrowUp")return U.preventDefault(),U.stopPropagation(),E((z)=>(z-1+Q.matches.length)%Q.matches.length),!0;if(U.key==="Enter"||U.key==="Tab"){U.preventDefault(),U.stopPropagation(),Z.current=!0;let z=Q.matches[S];if(z)J(z);return!0}if(U.key==="Escape")return U.preventDefault(),U.stopPropagation(),y(X),M?.(),!0;return!1},[J,X,S,M,Q]),K=VA((U)=>{if(Z.current&&Zy(U.inputType))return Z.current=!1,U.preventDefault(),U.stopPropagation(),!0;if(!Q||Q.matches.length===0)return Z.current=!1,!1;if(Cz(U.inputType))return U.preventDefault(),U.stopPropagation(),!0;if(!Zy(U.inputType))return Z.current=!1,!1;U.preventDefault(),U.stopPropagation();let z=Q.matches[S];if(z)J(z);return!0},[J,S,Q]),q=Q&&Q.matches.length>0?{activeIndex:S,matches:Q.matches,onHover:E,onSelect:J}:null;return{activeIndex:S,handleBeforeInput:K,handleKeyDown:V,leafProps:q}}function Zy(N){return N==="insertLineBreak"||N==="insertParagraph"}function Cz(N){return N==="insertReplacementText"}function jz(N){return[N.trigger,N.triggerStart,N.caret,N.query].join(":")}var Rz=["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 Yy(N,F,{scrollX:A=window.scrollX,scrollY:M=window.scrollY}={}){if(!N.isConnected)return null;let D=getComputedStyle(N),E=document.createElement("div");for(let X of Rz)E.style.setProperty(X,D.getPropertyValue(X));Object.assign(E.style,{position:"absolute",top:"0",left:"0",visibility:"hidden",whiteSpace:"pre-wrap",wordWrap:"break-word",width:`${N.clientWidth}px`}),E.textContent=N.value.slice(0,F);let $=document.createElement("span");$.textContent=N.value.slice(F)||".",E.appendChild($),document.body.appendChild(E);let y=N.getBoundingClientRect(),Z=parseFloat(D.lineHeight)||$.offsetHeight,Y={anchorHeight:Z,left:A+y.left+$.offsetLeft+parseFloat(D.borderLeftWidth)-N.scrollLeft,top:M+y.top+$.offsetTop+parseFloat(D.borderTopWidth)+Z-N.scrollTop};return document.body.removeChild(E),Y}function Qy({completionSources:N,onChange:F,textareaRef:A,value:M}){let[D,E]=Xy(null),[$,y]=Xy(null),Z=D?.triggerStart??null,Y=vz(()=>h$(N),[N]),X=uF((U,z)=>{if(!Y.length){E(null);return}let G=g3(U,z,Y);if(!G){E(null);return}E(G)},[Y]),Q=uF((U)=>{let z=U.currentTarget.value,G=U.currentTarget.selectionEnd??z.length;F(z),X(z,G)},[F,X]),S=uF((U)=>{let z=U.currentTarget;X(z.value,z.selectionEnd??z.value.length)},[X]),J=uF(()=>{E(null)},[]),V=uF((U,z)=>{if(!A.current)return;let H=l$(M,z,mz(U));F(H.value),E(null),requestAnimationFrame(()=>{let B=A.current;if(!B)return;B.focus(),B.setSelectionRange(H.caret,H.caret)})},[F,A,M]),K=a3({activeCompletion:D,onAccept:V,onDismiss:J}),q=fz((U)=>{K.handleBeforeInput(U)});return bz(()=>{let U=A.current;if(!U)return;return U.addEventListener("beforeinput",q),()=>U.removeEventListener("beforeinput",q)},[A]),uz(()=>{if(Z===null){y(null);return}let U=()=>{let z=A.current;if(!z)return;let G=Yy(z,Z);y(G?{anchorHeight:G.anchorHeight,bridge:!1,left:G.left,paddingY:4,top:G.top}:null)};return U(),window.addEventListener("scroll",U,!0),window.addEventListener("resize",U),()=>{window.removeEventListener("scroll",U,!0),window.removeEventListener("resize",U)}},[Z,A]),{activeCompletion:D,anchor:$,handleBlur:J,handleChange:Q,handleKeyDown:K.handleKeyDown,handleSelect:S,leafProps:K.leafProps}}function mz(N){return N.kind==="mention"?{...N,insertText:`@${N.label} `}:N}import{useLayoutEffect as kz,useRef as gz,useState as hz}from"react";import{jsx as qA,jsxs as dz}from"react/jsx-runtime";var Sy=12,Iz={horizontalOffset:0,verticalPlacement:"below"};function r3({anchor:N,children:F}){let A=gz(null),[M,D]=hz(Iz);return kz(()=>{let E=A.current;if(!E||typeof window>"u")return;let $=()=>{let Z=E.getBoundingClientRect(),Y=pz(N,Z);D((X)=>lz(X,Y)?X:Y)};$();let y=new ResizeObserver($);return y.observe(E),window.visualViewport?.addEventListener("resize",$),window.addEventListener("resize",$),()=>{y.disconnect(),window.visualViewport?.removeEventListener("resize",$),window.removeEventListener("resize",$)}},[N.left,N.top]),qA(T$,{children:dz("div",{className:"documint-leaf-anchor","data-bridge":N.bridge,"data-placement":M.verticalPlacement,onPointerEnter:N.onPointerEnter,onPointerLeave:N.onPointerLeave,style:{left:`${N.left+M.horizontalOffset}px`,top:`${N.top}px`,"--documint-leaf-anchor-height":`${N.anchorHeight}px`,"--documint-leaf-bridge-height":`${Sy}px`,"--documint-leaf-padding-y":`${N.paddingY}px`},children:[N.bridge?qA("div",{className:"documint-leaf-bridge"}):null,qA("div",{className:"documint-leaf-shell",ref:A,children:F})]})})}function pz(N,F){let A=window.visualViewport,M=A?.width??window.innerWidth,D=A?.height??window.innerHeight,E=A?.offsetLeft??0,$=A?.offsetTop??0,y=N.left-window.scrollX-E,Z=N.top-window.scrollY-$,Y=D-Z;return{horizontalOffset:xz({anchorScreenLeft:y,shellWidth:F.width,visibleWidth:M}),verticalPlacement:F.height+Sy>Y?"above":"below"}}function xz({anchorScreenLeft:N,shellWidth:F,visibleWidth:A}){let M=A-N;if(F<=M)return 0;return Math.max(-N,Math.min(-F/2,A-N-F))}function lz(N,F){return N.horizontalOffset===F.horizontalOffset&&N.verticalPlacement===F.verticalPlacement}import{jsx as d1,jsxs as Jy,Fragment as sz}from"react/jsx-runtime";function vF({actions:N,autoFocus:F=!1,completionSources:A,onChange:M,placeholder:D,readOnly:E=!1,ref:$,rows:y=3,saveOnEnter:Z=!1,value:Y}){let X=rz(null),Q=$??X,{activeCompletion:S,anchor:J,handleBlur:V,handleChange:K,handleKeyDown:q,handleSelect:U,leafProps:z}=Qy({completionSources:A,onChange:M,textareaRef:Q,value:Y}),G=az((H)=>{if(q(H))return;if(H.key==="Escape"&&N.kind==="edit")H.preventDefault(),N.onCancel();if(H.key==="Enter"&&Z){if(H.preventDefault(),N.kind==="edit"&&!N.saveDisabled)N.onSave();else if(N.kind==="compose"&&!N.submitDisabled)N.onSubmit()}},[N,q,Z]);return Jy("div",{className:"documint-leaf-input-field",children:[d1("textarea",{autoFocus:F,className:"documint-leaf-input",onBlur:V,onChange:K,onKeyDown:G,onSelect:U,placeholder:D,readOnly:E,ref:Q,rows:y,value:Y}),cz(N),S&&J&&z?d1(r3,{anchor:J,children:d1(d3,{...z})}):null]})}function cz(N){if(N.kind==="edit")return Jy(sz,{children:[d1(UA,{className:"documint-leaf-input-cancel",icon:WF,label:"Cancel editing",onClick:N.onCancel}),d1(UA,{className:"documint-leaf-input-save",disabled:N.saveDisabled??!1,icon:q2,label:"Save",onClick:N.onSave})]});return d1(UA,{className:"documint-leaf-input-submit",disabled:N.submitDisabled??!1,icon:p1,iconSize:15,label:N.submitLabel,onClick:N.onSubmit})}function UA({className:N,disabled:F=!1,icon:A,iconSize:M=14,label:D,onClick:E}){return d1("button",{"aria-label":D,className:`documint-leaf-action ${N}`,disabled:F,onClick:E,title:D,children:d1(A,{size:M,strokeWidth:2.2})})}import{Fragment as Vy}from"react";import{jsx as Uy,jsxs as qy}from"react/jsx-runtime";function KA({value:N,completionSources:F,onEdit:A}){return Uy("p",{onDoubleClick:A,children:iz(N,F)})}function iz(N,F){let A=h3(N,F);if(A.length===1&&A[0].kind==="text")return N;return A.map((M,D)=>M.kind==="token"&&M.id?qy("span",{className:"documint-mention",children:[M.trigger,M.label]},D):M.kind==="token"?qy(Vy,{children:[M.trigger,M.label]},D):Uy(Vy,{children:M.text},D))}import{Children as Ky,isValidElement as zy,useEffect as oz,useRef as nz,useState as tz}from"react";import{jsx as T0,jsxs as HA}from"react/jsx-runtime";var zA=(N)=>{N.preventDefault()},GA=(N)=>N.isPrimary&&N.button===0;function ez({children:N}){return T0("div",{className:"documint-leaf-toolbar",children:Ky.map(N,NG)})}function NG(N){if(!zy(N))return null;if(N.type===Hy){let F=N.props;return T0(Gy,{children:T0(FG,{...F})})}if(N.type===_y){let{className:F}=N.props;return T0("div",{className:mF("documint-leaf-toolbar-divider",F)})}if(N.type===By){let F=N.props;return T0(MG,{...F})}return null}function FG({active:N=!1,className:F,disabled:A=!1,icon:M,label:D,onClick:E}){return T0("button",{"aria-label":D,className:mF("documint-leaf-toolbar-button",N?"active":null,F),disabled:A,onPointerDown:($)=>{if(zA($),!A&&GA($))E()},title:D,type:"button",children:T0(AG,{icon:M})})}function AG({icon:N}){return T0(N,{size:15,strokeWidth:2.2})}function MG({children:N,className:F,icon:A,label:M,onSelect:D}){let E=nz(null),[$,y]=tz(!1);return oz(()=>{if(!$)return;let Z=(Y)=>{if(E.current&&Y.target instanceof Node&&!E.current.contains(Y.target))y(!1)};return window.addEventListener("pointerdown",Z),()=>{window.removeEventListener("pointerdown",Z)}},[$]),T0(Gy,{children:HA("div",{className:"documint-leaf-toolbar-menu-shell",ref:E,children:[T0(DG,{className:F,icon:A,isOpen:$,label:M,onClick:()=>y((Z)=>!Z)}),$?T0("div",{className:"documint-leaf-menu",role:"menu",children:Ky.map(N,(Z)=>EG(Z,(Y)=>{y(!1),D(Y)}))}):null]})})}function DG({className:N,icon:F,isOpen:A,label:M,onClick:D}){return HA("button",{"aria-expanded":A,"aria-haspopup":"menu","aria-label":M,className:mF("documint-leaf-toolbar-button",A?"active":null,N),onPointerDown:(E)=>{if(zA(E),GA(E))D()},title:M,type:"button",children:[T0(F,{size:15,strokeWidth:2.2}),T0($F,{className:mF("documint-leaf-toolbar-menu-chevron",A?"is-open":null),size:13,strokeWidth:2.2})]})}function EG(N,F){if(!zy(N))return null;if(N.type===Wy){let{className:$}=N.props;return T0("div",{className:mF("documint-leaf-menu-divider",$),role:"separator"})}if(N.type!==Py)return null;let{disabled:A=!1,icon:M,text:D,value:E}=N.props;return HA("button",{className:"documint-leaf-menu-item",disabled:A,onPointerDown:($)=>{if(zA($),!A&&GA($))F(E)},role:"menuitem",type:"button",children:[T0(M,{size:15,strokeWidth:2.2}),T0("span",{children:D})]})}function mF(...N){return N.filter(Boolean).join(" ")}function Gy({children:N}){return T0("div",{className:"documint-leaf-toolbar-group",children:N})}function Hy(N){return null}function _y(N){return null}function By(N){return null}function Py(N){return null}function Wy(N){return null}var d=Object.assign(ez,{Button:Hy,Divider:_y,Menu:By,MenuDivider:Wy,MenuItem:Py});import{jsx as t,jsxs as V1,Fragment as XG}from"react/jsx-runtime";var $G=!1,yG=220,ZG={code:!1,marks:[]},_A=()=>{};function BA(N){let F=N.mode==="create",A=N.mode==="create"?N:null,M=N.mode==="thread"?N:null,D=N.canEdit,E=N.link,$=M?.thread??null,y=$?.comments??[],Z=y[0]??null,Y=$?j1($):!1,X=M?.animateInitialComment??!1,[Q,S]=_2(null),[J,V]=_2(""),[K,q]=_2(""),[U,z]=_2(""),[G,H]=_2(!X),[B,_]=_2($G),[O,w]=_2(!1),b=Oy(null),L=Oy(null),W=N.completionSources,v=$?b4($):null,g=v?wy(v):"",j=D&&!Y,P=j&&J.trim().length>0,R=j&&K.trim().length>0,f=D&&U.trim().length>0,m=F||O,x=!F||B,r=!F&&Boolean($),i=Boolean(Z),B0=F?B:!0,Q0=M?.onDeleteComment??_A,u=M?.onDeleteThread??_A,l=M?.onToggleResolved??_A,o=A?.formatting??ZG,a=o.code,V0=o.marks,P0=h(X3),T=h(V3),p=h(Q3),D0=h(S3),q0=h(J3),Y0=A?.actions??[],E0=D?F?"Add a comment":"Reply to this comment":"Comment editing is disabled",R0=F?U:K;c3(()=>{if(Q!==null&&(Q<0||Q>=y.length))S(null),V("")},[y.length,Q]),c3(()=>{if(!i||!X){H(!0);return}H(!1);let G0=requestAnimationFrame(()=>{H(!0)});return()=>{cancelAnimationFrame(G0)}},[X,Z,i]),c3(()=>{if(!M||!X){w(!1);return}w(!0);let G0=window.setTimeout(()=>{w(!1)},yG);return()=>{window.clearTimeout(G0)}},[X,M]),c3(()=>{if(!F||!B||!D)return;let G0=requestAnimationFrame(()=>{L.current?.focus()});return()=>{cancelAnimationFrame(G0)}},[D,F,B]);let q1=()=>{S(null),V("")},P2=(G0,O2)=>{if(!r||!j)return;S(G0),V(O2)},W2=(G0)=>{if(!M)return;M.onEditComment(G0,J),q1()},zN=()=>{if(!M)return;M.onReply(K),q("")},GN=()=>{if(!A||!f)return;A.onCreateThread(U),z("")},dF=m?`documint-comment-leaf documint-comment-leaf-create${B0?" is-expanded":""}`:"documint-comment-leaf",M4=r||i||x?t(YG,{canCreate:f,canEdit:D,canMutateThread:j,canReply:R,canSaveEditedComment:P,comments:y,composerRef:L,editDraft:J,editingCommentIndex:Q,isComposerVisible:x,isInitialCommentVisible:G,isResolved:Y,link:E,completionSources:W,mode:N.mode,onBeginEditingComment:P2,onCancelEditing:q1,onChangeCreateDraft:z,onChangeEditDraft:V,onChangeReplyDraft:q,onDeleteComment:Q0,onDeleteThread:u,onSubmitCreate:GN,onSubmitEditedComment:W2,onSubmitReply:zN,onToggleResolved:l,rootComment:Z,showRootComment:i,showThreadChrome:r,threadAge:g,composerPlaceholder:E0,composerValue:R0}):null;return t("div",{className:dF,"data-resolved":Y?"true":void 0,ref:b,children:V1("div",{className:m?"documint-comment-leaf-create-shell":void 0,children:[m?V1(d,{children:[t(d.Button,{className:"documint-comment-leaf-create-button",icon:GF,label:"Add comment",onClick:()=>_(!0)}),t(d.Divider,{}),t(d.Button,{active:V0.includes("bold"),className:"documint-comment-leaf-create-mark",disabled:a,icon:EF,label:"Bold",onClick:P0}),t(d.Button,{active:V0.includes("italic"),className:"documint-comment-leaf-create-mark",disabled:a,icon:qF,label:"Italic",onClick:p}),t(d.Button,{active:V0.includes("underline"),className:"documint-comment-leaf-create-mark",disabled:a,icon:PF,label:"Underline",onClick:q0}),t(d.Divider,{}),t(d.Button,{active:a,className:"documint-comment-leaf-create-mark",icon:yF,label:"Code",onClick:T}),t(d.Button,{active:V0.includes("strikethrough"),className:"documint-comment-leaf-create-mark",disabled:a,icon:_F,label:"Strikethrough",onClick:D0}),Y0.length>0?[t(d.Divider,{},"actions-divider"),...Y0.map((G0,O2)=>{return t(d.Button,{className:"documint-comment-leaf-create-mark",icon:G0.icon,label:G0.label,onClick:()=>G0.onClick()},`${G0.label}:${O2}`)})]:null]}):null,t("div",{className:m?"documint-comment-leaf-create-content":void 0,children:M4})]})})}function YG({canCreate:N,canEdit:F,canMutateThread:A,canReply:M,canSaveEditedComment:D,comments:E,composerRef:$,editDraft:y,editingCommentIndex:Z,isComposerVisible:Y,isInitialCommentVisible:X,isResolved:Q,link:S,completionSources:J,mode:V,onBeginEditingComment:K,onCancelEditing:q,onChangeCreateDraft:U,onChangeEditDraft:z,onChangeReplyDraft:G,onDeleteComment:H,onDeleteThread:B,onSubmitCreate:_,onSubmitEditedComment:O,onSubmitReply:w,onToggleResolved:b,rootComment:L,showRootComment:W,showThreadChrome:v,threadAge:g,composerPlaceholder:j,composerValue:P}){return V1(XG,{children:[v?V1("div",{className:"documint-comment-leaf-header",children:[t("span",{className:"documint-comment-leaf-age",children:g}),V1("div",{className:"documint-comment-leaf-actions",children:[t("button",{className:"documint-leaf-action","aria-label":Q?"Reopen comment":"Resolve comment",disabled:!F,onClick:b,title:Q?"Reopen comment":"Resolve comment",type:"button",children:t(q2,{size:14,strokeWidth:2.2})}),t("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment thread",disabled:!F,onClick:B,title:"Delete comment thread",type:"button",children:t(s0,{size:14,strokeWidth:2.2})})]})]}):null,v&&S?V1("div",{className:"documint-comment-leaf-link",children:[S.title?t("div",{className:"documint-link-leaf-title",children:S.title}):null,t("div",{className:"documint-link-leaf-url",children:S.url})]}):null,V1("div",{className:`documint-comment-thread${W?"":" is-empty"}`,children:[t("article",{className:W?`documint-comment-message documint-comment-message-root${X?" is-visible":""}`:"documint-comment-message documint-comment-message-root is-hidden",children:L?t(KA,{completionSources:J,onEdit:()=>K(0,L.body),value:L.body}):null}),E.slice(1).map((R,f)=>{let m=f+1,x=Z===m;return V1("article",{className:"documint-comment-message",children:[!x?V1("div",{className:"documint-comment-message-meta",children:[t("span",{children:wy(R.updatedAt)}),A?V1("div",{className:"documint-comment-leaf-actions",children:[t("button",{className:"documint-leaf-action","aria-label":"Edit comment",disabled:!A,onClick:()=>{K(m,R.body)},title:"Edit comment",type:"button",children:t(U2,{size:14,strokeWidth:2.2})}),t("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment",disabled:!A,onClick:()=>H(m),title:"Delete comment",type:"button",children:t(s0,{size:14,strokeWidth:2.2})})]}):null]}):null,x?t(vF,{actions:{kind:"edit",onCancel:q,onSave:()=>O(m),saveDisabled:!D},completionSources:J,onChange:z,readOnly:!F,rows:3,value:y}):t(KA,{completionSources:J,onEdit:()=>K(m,R.body),value:R.body})]},`${R.updatedAt}:${m}`)})]}),t("div",{className:`documint-comment-reply${v?"":" is-standalone"}${Y?" is-visible":""}`,children:t(vF,{actions:V==="create"?{kind:"compose",onSubmit:_,submitDisabled:!N,submitLabel:"Create comment"}:{kind:"compose",onSubmit:w,submitDisabled:!M,submitLabel:"Reply"},completionSources:J,onChange:V==="create"?U:G,placeholder:j,readOnly:!F,ref:$,rows:3,value:P})})]})}function wy(N){let F=new Date(N);if(Number.isNaN(F.getTime()))return N;let A=F.getTime()-Date.now(),M=60000,D=60*M,E=24*D,$=7*E,y=30*E,Z=365*E,Y=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});if(Math.abs(A)<M)return"just now";if(Math.abs(A)<D)return Y.format(Math.round(A/M),"minute");if(Math.abs(A)<E)return Y.format(Math.round(A/D),"hour");if(Math.abs(A)<$)return Y.format(Math.round(A/E),"day");if(Math.abs(A)<Z)return Y.format(Math.round(A/y),"month");return Y.format(Math.round(A/Z),"year")}import{jsx as E1,jsxs as JG}from"react/jsx-runtime";var QG=[{icon:ZF,label:"Heading 1",text:"# "},{icon:YF,label:"Heading 2",text:"## "},{icon:XF,label:"Heading 3",text:"### "},{icon:SF,label:"Heading 4",text:"#### "},{icon:QF,label:"Heading 5",text:"##### "},{icon:JF,label:"Heading 6",text:"###### "}],SG=[{columns:2,text:"2 columns"},{columns:3,text:"3 columns"},{columns:4,text:"4 columns"},{columns:5,text:"5 columns"}];function Ly({onInsert:N,onInsertTable:F}){return JG(d,{children:[E1(d.Button,{icon:zF,label:"Insert bulleted list",onClick:()=>N("- ")}),E1(d.Button,{icon:UF,label:"Insert numbered list",onClick:()=>N("1. ")}),E1(d.Button,{icon:KF,label:"Insert task list",onClick:()=>N("- [ ] ")}),E1(d.Divider,{}),E1(d.Menu,{icon:VF,label:"Insert heading",onSelect:N,children:QG.map(({icon:A,label:M,text:D})=>E1(d.MenuItem,{icon:A,text:M,value:D},D))}),E1(d.Menu,{icon:x1,label:"Insert table",onSelect:(A)=>F(Number(A)),children:SG.map(({columns:A,text:M})=>E1(d.MenuItem,{icon:x1,text:M,value:String(A)},A))}),E1(d.Divider,{}),E1(d.Button,{icon:BF,label:"Insert blockquote",onClick:()=>N("> ")}),E1(d.Button,{icon:HF,label:"Insert divider",onClick:()=>N("--- ")})]})}import{useState as Ty}from"react";import{jsx as _1,jsxs as kF}from"react/jsx-runtime";function Cy({title:N,url:F,canEdit:A,onSave:M,onDelete:D}){let[E,$]=Ty(!1),[y,Z]=Ty(""),Y=qG(F),X=UG(F),Q=A&&!E,S=A&&y.trim().length>0,J=VG();return kF("div",{className:"documint-link-leaf",children:[N&&_1("div",{className:"documint-link-leaf-title",children:N}),kF("div",{className:"documint-link-leaf-row",children:[E?_1(vF,{actions:{kind:"edit",onCancel:()=>$(!1),onSave:()=>{M(encodeURI(y.trim())),$(!1)},saveDisabled:!S},autoFocus:!0,onChange:Z,readOnly:!A,rows:3,saveOnEnter:!0,value:y}):kF("div",{className:"documint-link-leaf-url-row",children:[X&&_1("img",{alt:"","aria-hidden":"true",className:"documint-link-leaf-favicon",onError:(q)=>{q.currentTarget.hidden=!0},src:X},X),_1("div",{className:"documint-link-leaf-url",children:Y})]}),Q&&kF("div",{className:"documint-link-leaf-actions",children:[_1("button",{className:"documint-leaf-action","aria-label":"Edit link",onClick:()=>{if(!A)return;Z(Y),$(!0)},title:"Edit link",children:_1(U2,{size:14,strokeWidth:2.2})}),_1("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Remove link",onClick:D,title:"Remove link",children:_1(s0,{size:14,strokeWidth:2.2})})]})]}),_1("div",{className:"documint-link-leaf-divider"}),kF("div",{className:"documint-link-leaf-hint",children:[J,"click to open"]})]})}function VG(){if(typeof navigator>"u")return"Ctrl+";let N=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/.test(N)?"CMD+":"CTRL+"}function qG(N){try{return decodeURIComponent(N)}catch{return N}}function UG(N){try{let{hostname:F}=new URL(N);return`https://www.google.com/s2/favicons?domain=${F}&sz=32`}catch{return null}}import{jsx as B1,jsxs as OA}from"react/jsx-runtime";var KG=[{text:"Column left",value:"left"},{text:"Column right",value:"right"}],zG=[{text:"Row above",value:"above"},{text:"Row below",value:"below"}],PA={text:"Delete column",value:"delete"},WA={text:"Delete row",value:"delete"},jy={text:"Delete table",value:"delete"};function Ry({canDeleteColumn:N,canDeleteRow:F,onDeleteColumn:A,onDeleteRow:M,onDeleteTable:D,onInsertColumn:E,onInsertRow:$}){return OA(d,{children:[OA(d.Menu,{icon:h1,label:"Column actions",onSelect:(y)=>{if(y===PA.value){A();return}E(y)},children:[KG.map(({text:y,value:Z})=>B1(d.MenuItem,{icon:ZN,text:y,value:Z},Z)),B1(d.MenuDivider,{}),B1(d.MenuItem,{disabled:!N,icon:s0,text:PA.text,value:PA.value})]}),OA(d.Menu,{icon:I1,label:"Row actions",onSelect:(y)=>{if(y===WA.value){M();return}$(y)},children:[zG.map(({text:y,value:Z})=>B1(d.MenuItem,{icon:ZN,text:y,value:Z},Z)),B1(d.MenuDivider,{}),B1(d.MenuItem,{disabled:!F,icon:s0,text:WA.text,value:WA.value})]}),B1(d.Divider,{}),B1(d.Menu,{icon:x1,label:"Table actions",onSelect:()=>D(),children:B1(d.MenuItem,{icon:s0,text:jy.text,value:jy.value})})]})}import{useEffect as GG,useEffectEvent as s3,useRef as wA,useState as HG}from"react";var _G=600;function by({onIdle:N}={}){let[F,A]=HG(null),M=wA(null),D=wA(performance.now()),E=wA(null),$=()=>{if(typeof window>"u"||E.current===null)return;window.clearTimeout(E.current),E.current=null},y=s3(()=>{let Q=M.current;if(Q!==null)D.current=performance.now()-(Q-D.current);E.current=null,M.current=null,A(null),N?.()}),Z=s3(()=>{let Q=performance.now();if(M.current===null)M.current=Q,A(Q);if($(),typeof window<"u")E.current=window.setTimeout(y,_G)}),Y=s3(()=>M.current!==null),X=s3((Q=performance.now())=>(M.current??Q)-D.current);return GG(()=>$,[]),{activeAt:F,resolveAnimationTime:X,isActive:Y,markActive:Z}}import{useEffect as fy,useEffectEvent as BG,useRef as uy}from"react";var PG=530,VN=24;function my({activeAt:N,getScrollTop:F,isEditable:A,layoutWidth:M,onVisibilityChange:D,scrollContentHeight:E,scrollTo:$,viewportHeight:y}){let Z=e(D1),Y=e(AA,A),X=e(MA),Q=e(DA),S=Z.start.regionId===Z.end.regionId&&Z.start.offset===Z.end.offset,J=uy(!0),V=uy(null),K=BG(()=>{D()});return fy(()=>{let q=Z.end,U={layoutWidth:M,offset:q.offset,regionId:q.regionId,scrollContentHeight:E,viewportHeight:y};if(WG(V.current,U))return;if(!Q)return;let z=F(),G=z+VN,H=z+y-VN;if(Q.top<G){let B=$(Math.max(0,Q.top-VN));if(vy(Q,B,y,VN))V.current=U;return}if(Q.top+Q.height>H){let B=$(Math.max(0,Q.top+Q.height-y+VN));if(vy(Q,B,y,VN))V.current=U;return}V.current=U},[Q,M,Z.end.offset,Z.end.regionId,E,y]),fy(()=>{if(J.current=!0,K(),!S||!X||N!==null||typeof window>"u")return;let q=window.setInterval(()=>{J.current=!J.current,K()},PG);return()=>{window.clearInterval(q)}},[S,X,N]),{caretInViewport:X,leaf:Y,isVisible:()=>J.current}}function WG(N,F){return N?.layoutWidth===F.layoutWidth&&N.regionId===F.regionId&&N.offset===F.offset&&N.scrollContentHeight===F.scrollContentHeight&&N.viewportHeight===F.viewportHeight}function vy(N,F,A,M){return N.top>=F+M&&N.top+N.height<=F+A-M}import{useCallback as OG}from"react";function ky({completionSources:N,enabled:F,onMentionAccepted:A}){let M=e(EA,F?N:void 0),D=h(f7),E=h(Y3),$=OG((Y,X)=>{let Q=r$(Y,X);if(Q.kind==="mention"){let S=D(Q.target,Q.userId,Q.name,Q.trailingText);if(S)A?.({target:Q.target,transition:S,userId:Q.userId});return}E(Q.startOffset,Q.endOffset,Q.text)},[D,A,E]),y=a3({activeCompletion:M,contextKey:M?wG(M):null,onAccept:$}),Z=M&&y.leafProps?{kind:"completion",anchor:{regionId:M.regionId,offset:M.triggerStart},...y.leafProps}:null;return{handleBeforeInput:y.handleBeforeInput,handleKeyDown:y.handleKeyDown,leaf:Z}}function wG(N){if(!("regionId"in N)||typeof N.regionId!=="string")return null;return[N.regionId,N.trigger,N.triggerStart,N.caret,N.query].join(":")}import{useMemo as LA,useRef as gF,useEffectEvent as TA}from"react";var LG=48;function gy(N){let F=e(YA,N),A=h(u7),M=gF(null),D=gF(null),E=gF(null),$=gF(null),y=gF(1),Z=TA((J,V)=>{if(!F)return;J.preventDefault(),J.stopPropagation(),J.currentTarget.setPointerCapture(J.pointerId),$.current=J.pointerId,M.current=J.clientX,D.current=J.clientY,E.current=F.inline.image?.width??F.bounds.width,y.current=V}),Y=TA((J)=>{if($.current!==J.pointerId||M.current===null||D.current===null||E.current===null||!F?.inline.image)return;let V=J.clientX-M.current,K=J.clientY-D.current,q=Math.min(F.maxWidth??1/0,Math.max(LG,Math.round(E.current+y.current*(V+K)))),U={end:F.inline.end,image:F.inline.image,start:F.inline.start};A(U,q)}),X=TA((J)=>{if(J.currentTarget.hasPointerCapture(J.pointerId))J.currentTarget.releasePointerCapture(J.pointerId);$.current=null,M.current=null,D.current=null,E.current=null}),Q=LA(()=>({onPointerCancel:X,onPointerDown:(J)=>Z(J,-1),onPointerMove:Y,onPointerUp:X}),[]),S=LA(()=>({onPointerCancel:X,onPointerDown:(J)=>Z(J,1),onPointerMove:Y,onPointerUp:X}),[]);return LA(()=>{if(!F)return null;let{bounds:J}=F;return{start:{left:J.left,top:J.top,props:Q},end:{left:J.left+J.width,props:S,top:J.top+J.height}}},[F])}import{useEffect as hy,useEffectEvent as Iy,useMemo as py,useRef as TG,useState as CG}from"react";function xy(N){let F=e(t8),[A,M]=CG(new Map),D=Iy((Z)=>{if(typeof createImageBitmap>"u")return;let Y=RG(A,Z),X=bG(A,Z);if(Y.length)M((Q)=>{let S=new Map(Q);for(let J of Y)S.delete(J);return S});for(let Q of X)M((S)=>CA(S,Q,hF("loading"))),jG(Q,N).then((S)=>{M((J)=>{if(!J.has(Q))return S?.close(),J;return CA(J,Q,S?hF("loaded",S):hF("error"))})})});hy(()=>{D(F)},[F]);let E=TG(new Map);hy(()=>{for(let[Z,Y]of E.current)if(!A.has(Z))Y.source?.close();E.current=A},[A]);let $=Iy(async(Z)=>{try{let Y=await N.writeFile(Z),X=await createImageBitmap(Z).catch(()=>null);return M((Q)=>CA(Q,Y,X?hF("loaded",X):hF("error"))),Y}catch{return null}}),y=py(()=>A.size===0?null:{images:A},[A]);return py(()=>({resources:y,persistImage:$}),[y,$])}async function jG(N,F){try{let A=await F.readFile(N);return A?await createImageBitmap(A):null}catch{return null}}function RG(N,F){return[...N.keys()].filter((A)=>!F.has(A))}function bG(N,F){return[...F].filter((A)=>{let M=N.get(A)?.status;return M!=="loaded"&&M!=="loading"})}function CA(N,F,A){let M=new Map(N);return M.set(F,A),M}function hF(N,F){return{intrinsicHeight:F?.height??0,intrinsicWidth:F?.width??0,source:F??null,status:N}}import{useEffect as ly,useEffectEvent as z0,useRef as a1,useState as fG}from"react";var uG=48,dy=44,ay=32,ry=1.6,vG=600,mG=24,kG=500;function gG(N,F){let A=F.x-N.x,M=F.y-N.y,D=Math.abs(A),E=Math.abs(M),$=F.time-N.time;if(D<dy||E>ay||D<E*ry||$>vG)return null;return A<0?"left":"right"}function cy({autoScrollDuringDrag:N,canvasRef:F,focusInput:A,isEditable:M,onActivity:D,resolvePoint:E,storage:$}){let y=x0(),Z=h(L0),Y=h(H8),X=h(_8),Q=h(q3),S=h(U3),J=h(k7),V=h(AF),[K,q]=fG(null),{cursor:U,leaf:z}=e(yA,K),G=a1(null),H=a1(!1),B=a1(null),_=a1(null),O=a1(null),w=a1(null),b=a1(new Set),L=a1(null);ly(()=>{if(K&&K.kind!=="task-toggle"&&!z)q(null)},[K,z]),ly(()=>()=>{if(G.current!==null)window.clearTimeout(G.current)},[]);let W=z0(()=>{if(G.current!==null)window.clearTimeout(G.current),G.current=null}),v=z0(()=>{W(),G.current=window.setTimeout(()=>{if(G.current=null,!H.current)q(null)},uG)}),g=z0(()=>{if(!H.current)W(),q(null)}),j=z0((T)=>{if(!T){g();return}if(T.kind==="task-toggle"){W(),q((p)=>p?.kind==="task-toggle"&&p.listItemId===T.listItemId?p:T);return}if(T.commentThreadIndex!==null){W();let p=T.commentThreadIndex;q((D0)=>D0?.kind!=="task-toggle"&&D0?.commentThreadIndex===p?D0:T);return}if(T.kind!=="link"){g();return}W(),q((p)=>p?.kind==="link"&&p.title===T.title&&p.url===T.url&&p.startOffset===T.startOffset&&p.endOffset===T.endOffset?p:T)}),P=z0((T)=>{let p=E(T);if(!p)return null;let D0=y.editor.getState();return lE(D0,y.viewport.get(),p)}),R=z0((T)=>{let p=F.current;if(p&&B.current===T)p.releasePointerCapture(T)}),f=z0(()=>{B.current=null,_.current=null}),m=z0(()=>{w.current=null}),x=z0((T)=>{L.current={expiresAt:T.timeStamp+kG,x:T.clientX,y:T.clientY}}),r=z0((T)=>{if(T.pointerType==="touch")b.current.delete(T.pointerId)}),i=z0((T)=>{R(T.pointerId),f(),m(),r(T)}),B0=z0((T)=>{if(O.current=T.pointerType,T.pointerType==="touch"){if(b.current.add(T.pointerId),b.current.size>1)m();else if(M&&T.isPrimary)w.current={pointerId:T.pointerId,startX:T.clientX,startY:T.clientY,startedAt:T.timeStamp,swiping:!1};return}let p=F.current,D0=y.viewport.get(),q0=E(T);if(!q0)return;if(P(T)?.kind==="task-toggle")return;if(!p)return;let E0=T.shiftKey?X(D0,q0):Y(D0,q0);if(!E0)return;let R0=E0.next.selection.focus;B.current=T.pointerId,_.current=T.shiftKey?E0.previous.selection.anchor:R0,D(),p.setPointerCapture(T.pointerId),A(R0)}),Q0=z0((T)=>{let p=w.current;if(T.pointerType==="touch"&&p?.pointerId===T.pointerId){let E0=T.clientX-p.startX,R0=T.clientY-p.startY,q1=Math.abs(E0),P2=Math.abs(R0);if(q1>=dy&&P2<=ay&&q1>=P2*ry)p.swiping=!0,T.preventDefault();return}let D0=_.current,q0=E(T);if(!q0)return;if(B.current!==T.pointerId||!D0){j(P(T));return}if(!V(y.viewport.get(),q0,D0))return;D(),N(T)}),u=z0(()=>{if(!H.current)v()}),l=z0((T)=>{let p=w.current;if(T.pointerType==="touch"&&p?.pointerId===T.pointerId){let D0=b.current.size===1?gG({time:p.startedAt,x:p.startX,y:p.startY},{time:T.timeStamp,x:T.clientX,y:T.clientY}):null;if(D0)if(T.preventDefault(),x(T),D0==="right")Q();else S();else if(p.swiping)x(T)}i(T)}),o=z0((T)=>{let p=L.current;if(p){let E0=T.clientX-p.x,R0=T.clientY-p.y,q1=T.timeStamp<=p.expiresAt&&Math.hypot(E0,R0)<=mG;if(L.current=null,q1){O.current=null,T.preventDefault(),T.stopPropagation();return}}let D0=O.current==="touch";O.current=null;let q0=P(T);if(q0?.kind==="task-toggle"){if(J(q0.listItemId))T.preventDefault(),T.stopPropagation(),D();return}if(q0?.kind==="link"&&(T.metaKey||T.ctrlKey)){T.preventDefault(),T.stopPropagation(),$.openFile(q0.url);return}if(!D0){A();return}let Y0=E(T);if(Y0){let E0=Y(y.viewport.get(),Y0);if(!E0){A();return}D(),A(E0.next.selection.focus)}else A()}),a=z0((T)=>{let p=y.editor.getState(),D0=E(T),q0=P(T);if(!D0||q0?.kind==="task-toggle")return;let Y0=S5(p,y.viewport.get(),D0);if(!Y0)return;T.preventDefault(),T.stopPropagation(),D(),Z(Y0),A()}),V0=z0(()=>{H.current=!0,W()}),P0=z0(()=>{H.current=!1,v()});return{canvasHandlers:{onClick:o,onDoubleClick:a,onPointerCancel:i,onPointerDown:B0,onPointerLeave:u,onPointerMove:Q0,onPointerUp:l},cursor:U,leaf:z,leafHandlers:{onPointerEnter:V0,onPointerLeave:P0}}}import{useMemo as hG}from"react";function sy({presence:N,users:F}){let A=hG(()=>IG(F,N),[F,N]),M=e(SA,A),D=e(QA,A);return{activeCommentThreadColors:M,resolvedPresence:D}}function IG(N,F){if(!F?.length||!N?.length)return;let A=new Map(N.map((D)=>[D.id,D])),M=[];for(let D of F){let E=A.get(D.userId);if(!E)continue;M.push({...E,color:D.color,cursor:D.cursor})}return M.length===0?void 0:M}import{useEffect as RA,useEffectEvent as m0,useLayoutEffect as pG,useRef as oy,useState as xG}from"react";import{useEffect as _l1}from"react";var jA=[{key:"Backspace",command:"deleteBackward"},{key:"Enter",shiftKey:!0,command:"insertSoftLineBreak"},{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:"toggleCode"},{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 iy(N,F=jA){return F.find((A)=>{let M=A.shiftKey==="any"?!0:(A.shiftKey??!1)===(N.shiftKey??!1);return A.key.toLowerCase()===N.key.toLowerCase()&&(A.altKey??!1)===(N.altKey??!1)&&M&&(A.modKey??!1)===Boolean(N.metaKey||N.ctrlKey)})?.command??null}var lG=1024,ny=16;function ey({inputRef:N,keybindings:F,enableTouchKeyDown:A=!1,onActivity:M,onBeforeInput:D,onKeyDown:E,onImagePaste:$}){let y=x0(),Z=e(K0),Y=dG(),X=()=>y.editor.getState(),Q=oy(!1),S=oy(!1),J=h(iG),V=h(oG),K=h(Z3),q=h(Q8),U=h(S8),z=h(J8),G=h(V8),H=h(nG),B=h(w7),_=h(b7),O=h(R7),w=h(L7),b=m0((u,...l)=>{let o=u(...l);if(o)M();return o}),L=m0(()=>{let u=N.current;if(!u)return;if(typeof document>"u")return;let l=document.execCommand;if(typeof l!=="function")return;try{Q.current=!0,l.call(document,"insertText",!1,""),l.call(document,"delete")}catch{}finally{Q.current=!1,IF(u,X())}}),W=m0(()=>{if(S.current)return;S.current=!0,L()}),v=m0(()=>{L()}),g=m0((u)=>{let l=N.current;if(!l)return;let o=y.viewport.get(),a=k1(X(),o,u);if(!a)return;l.style.top=`${a.top}px`,l.style.left=`${a.left}px`,l.style.height=`${a.height}px`}),j=m0((u)=>{let l=N.current;if(!l)return;g(u??X().selection.focus),l.focus({preventScroll:!Y}),IF(l,X()),W()}),P=m0((u)=>{if(Q.current)return;if(D?.(u))return;let l=X(),o=cG(u.inputType);if(u.inputType==="insertText"){if(!u.data)return;u.preventDefault();let a=ty(u.target);if(a.charsToReplace>0){b(V,a.charsToReplace,a.trailingOffset,u.data);return}let V0=rG(l,u.data);if(V0>0){let P0=u.data.slice(V0);if(P0.length>0)b(J,P0);return}b(J,u.data);return}if(u.inputType==="insertReplacementText"){if(!u.data)return;u.preventDefault();let a=ty(u.target);b(V,a.charsToReplace,a.trailingOffset,u.data);return}if(aG(u.inputType)){u.preventDefault(),b(K);return}if(o==="backward"){u.preventDefault(),b(q);return}if(o==="forward"){u.preventDefault(),b(U);return}if(u.inputType==="historyUndo"){u.preventDefault(),b(z),v();return}if(u.inputType==="historyRedo"){u.preventDefault(),b(G),v();return}}),R=m0((u)=>{let l=X(),o=u.currentTarget.value,a=i3(l);if(Q.current)return;if(FZ(o,a).length===0){IF(u.currentTarget,l);return}b(J,o)}),f=m0((u)=>{if(E?.(u))return;if(!b(H,y.viewport.get(),u.nativeEvent,F))return;u.preventDefault()}),m=m0((u)=>{let l=NF(X());if(!l)return;u.preventDefault(),u.clipboardData.setData("text/plain",G2(l))}),x=m0((u)=>{let l=X(),o=NF(l);if(!o)return;u.preventDefault(),u.clipboardData.setData("text/plain",G2(o)),b(B)}),r=m0(async(u)=>{let o=($?[...u.clipboardData.items].find((P0)=>P0.kind==="file"&&P0.type.startsWith("image/")):void 0)?.getAsFile()??null;if(o&&$){u.preventDefault();let P0=await $(o);if(P0)b(_,P0);return}let a=u.clipboardData.getData("text/plain");if(a.length===0)return;if(/^https?:\/\//.test(a)){if(b(O,a)){u.preventDefault();return}}u.preventDefault();let V0=d8(a);b(w,V0,a)}),i=m0(()=>{M();let u=N.current;if(u)IF(u,X())}),B0=m0((u)=>{if(M(),u.target.matches(":focus-visible"))j()});RA(()=>{let u=N.current;if(!u)return;IF(u,Z)},[Z,N]),pG(()=>{g(Z.selection.focus)},[Z]),RA(()=>{let u=N.current;if(!u)return;let l=(o)=>P(o);return u.addEventListener("beforeinput",l),()=>u.removeEventListener("beforeinput",l)},[N]);let Q0={onCopy:m,onCut:x,onPaste:r,...!Y||A?{onKeyDown:f}:{}};return{canvasHandlers:{...Q0,onFocus:B0},focus:j,inputHandlers:{...Q0,onFocus:i,onInput:R}}}var NZ="";function dG(){let[N,F]=xG(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return!1;return window.matchMedia("(pointer: coarse)").matches});return RA(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return;let A=window.matchMedia("(pointer: coarse)"),M=(D)=>F(D.matches);return A.addEventListener?.("change",M),()=>A.removeEventListener?.("change",M)},[]),N}function aG(N){return N==="insertLineBreak"||N==="insertParagraph"}function ty(N){let F=N,A=F?.selectionStart??0,M=F?.selectionEnd??A,D=F?.value.length??M;return{charsToReplace:Math.max(0,M-A),trailingOffset:Math.max(0,D-M)}}function rG(N,F){if(F.length<ny)return 0;let A=i3(N,F.length),M=Math.min(A.length,F.length);for(let D=M;D>=ny;D--)if(A.endsWith(F.slice(0,D)))return D;return 0}function cG(N){switch(N){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 sG(N){return N.replaceAll(NZ,"")}function i3(N,F=lG){let{anchor:A,focus:M}=N.selection;if(A.regionId!==M.regionId||A.offset!==M.offset)return"";let D=N.documentIndex.regionIndex.get(M.regionId);if(!D)return"";return D.text.slice(Math.max(0,M.offset-F),M.offset)}function FZ(N,F){let A=sG(N);return A.startsWith(F)?A.slice(F.length):A}function IF(N,F){let A=i3(F),M=A.length>0?A:NZ;N.value=M,N.setSelectionRange(M.length,M.length),N.scrollLeft=N.scrollWidth}function iG(N,F){let M=FZ(F,i3(N)).replace(/\r\n/g,`
|
|
33
33
|
`).split(/(\n)/),D=N;for(let E of M){if(E.length===0)continue;let $=E===`
|
|
34
|
-
`?O6(D):gN(D,E);if(!$)continue;D=$}return D===N?null:D}function Wz(N,F,A,M){let D=N.selection.focus,E=Math.max(0,D.offset-A),$=Math.max(0,E-F);return T6(N,$,E,M)}function Oz(N,F,A,M){if(A.key==="Delete")return W8(N);let D=CZ(A,M);if(D){if(D==="moveToLineStart"||D==="moveToLineEnd")return Y5(N,F.layout,D==="moveToLineStart"?"Home":"End",A.shiftKey);if(D==="moveToDocumentStart"||D==="moveToDocumentEnd")return X5(N,D==="moveToDocumentStart"?"start":"end",A.shiftKey);switch(D){case"insertLineBreak":return O6(N);case"insertSoftLineBreak":return rD(N);case"deleteBackward":return P8(N);case"indent":return R6(N);case"dedent":return b6(N);case"moveListItemUp":return M9(N);case"moveListItemDown":return D9(N);case"toggleBold":return L6(N);case"toggleItalic":return w6(N);case"toggleStrikethrough":return j6(N);case"toggleUnderline":return C6(N);case"toggleCode":return oD(N);case"undo":return O8(N);case"redo":return T8(N);case"selectAll":return iD(N)}}if(A.key==="ArrowLeft"||A.key==="ArrowRight")return E5(N,A.key==="ArrowLeft"?-1:1,A.shiftKey);if(A.key==="ArrowUp"||A.key==="ArrowDown")return $5(N,F.layout,A.key==="ArrowUp"?-1:1,A.shiftKey);if(A.key==="PageUp"||A.key==="PageDown")return Z5(N,F.layout,A.key==="PageUp"?-1:1,A.shiftKey);if(A.key.length===1&&!A.altKey&&!A.ctrlKey&&!A.metaKey)return gN(N,A.key);return null}import{useEffect as Tz,useEffectEvent as G2,useRef as uZ}from"react";function gZ(){return{fullRender:!1,fullPaint:!1,contentPaint:!1,overlayPaint:!1}}function hZ({renderContent:N,renderOverlay:F,renderViewport:A}){let M=x0(),D=uZ(null),E=uZ(gZ()),$=G2(()=>{if(typeof window>"u"){A();return}E.current.fullRender=!0,y()}),Z=G2(()=>{if(typeof window>"u"){N(),F();return}E.current.fullPaint=!0,y()}),Y=G2(()=>{if(typeof window>"u"){N();return}E.current.contentPaint=!0,y()}),X=G2(()=>{if(typeof window>"u"){F();return}E.current.overlayPaint=!0,y()}),y=G2(()=>{if(typeof window>"u"||D.current!==null)return;D.current=window.requestAnimationFrame(()=>{Q()})}),Q=G2(()=>{D.current=null;let V=E.current,U=V.fullRender,S=V.fullPaint,q=V.contentPaint,K=V.overlayPaint;if(E.current=gZ(),U){A(),J();return}if(S){N(),F(),J();return}if(q)N(),J();if(K)F()}),J=G2(()=>{if(!d4(M.editor.getState(),performance.now()))return;E.current.contentPaint=!0,y()});return Tz(()=>{return()=>{if(typeof window>"u"||D.current===null)return;window.cancelAnimationFrame(D.current),D.current=null}},[]),{scheduleContentPaint:Y,scheduleFullPaint:Z,scheduleFullRender:$,scheduleOverlayPaint:X}}import{useEffectEvent as SA,useRef as GA,useState as Lz}from"react";function IZ({autoScrollDuringDrag:N,isEditable:F,focusInput:A,onActivity:M,resolvePoint:D}){let[E,$]=Lz(null),Z=A0(e5),Y=A0(NA,E),X=I(O0),y=I(nN),Q=GA(null),J=GA(null),V=GA(null),U=SA((z,H=!0)=>{if(Y?.kind!=="annotation")return;$({anchor:Y.anchor,animateInitialComment:H,leftOverride:Y.leftOverride,paddingY:Y.paddingY,selection:Y.selection,threadIndex:z})}),S=SA((z)=>{if(z&&V.current===z.pointerId&&z.currentTarget.hasPointerCapture(z.pointerId))z.currentTarget.releasePointerCapture(z.pointerId);Q.current=null,J.current=null,V.current=null}),q=SA((z)=>{let H=J.current,B=D(z);if(!B||!H||V.current!==z.pointerId||!Z.viewport)return;if(!y(Z.viewport,B,H))return;z.preventDefault(),z.stopPropagation(),M(),N(z)}),K=(z)=>({onPointerCancel:(H)=>{S(H)},onPointerDown:(H)=>{let B=wz(Z.normalized,z),_=z==="start"?Z.normalized.start:Z.normalized.end;if(!Z.handles)return;H.preventDefault(),H.stopPropagation(),V.current=H.pointerId,J.current=B,Q.current=z,H.currentTarget.setPointerCapture(H.pointerId),M(),A(),X({anchor:B,focus:_})},onPointerMove:(H)=>{if(Q.current!==z)return;q(H)},onPointerUp:(H)=>{if(Q.current===z)q(H);S(H)}});return{handle:Z.handles?{start:{...Z.handles.start,props:K("start")},end:{...Z.handles.end,props:K("end")}}:null,leaf:F?Y:null,promoteLeafToThread:U}}function wz(N,F){return F==="start"?N.end:N.start}import{useEffect as jz,useMemo as lZ,useState as Cz}from"react";var vF={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)"},kF={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)"},pZ={...vF,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)"},xZ={...kF,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 dZ(N){let F=lZ(()=>bz(N),[N]),[A,M]=Cz(F.light),D=lZ(()=>fz(A),[A]);return jz(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function"){M(F.light);return}let E=window.matchMedia("(prefers-color-scheme: dark)"),$=()=>{M(E.matches?F.dark:F.light)};if($(),typeof E.addEventListener==="function")return E.addEventListener("change",$),()=>{E.removeEventListener("change",$)};return E.addListener($),()=>{E.removeListener($)}},[F]),{theme:A,themeStyles:D}}function Rz(N){return"light"in N&&"dark"in N}function bz(N){if(!N)return{dark:kF,light:vF};if(Rz(N))return N;return{dark:N,light:N}}function fz(N){return{"--documint-background":N.background,"--documint-leaf-button-bg":N.leafButtonBackground,"--documint-leaf-button-border":N.leafButtonBorder,"--documint-leaf-button-text":N.leafButtonText,"--documint-leaf-accent":N.leafAccent,"--documint-leaf-bg":N.leafBackground,"--documint-leaf-border":N.leafBorder,"--documint-leaf-font-family":'"Avenir Next", "Segoe UI", sans-serif',"--documint-leaf-shadow":N.leafShadow??void 0,"--documint-leaf-secondary-text":N.leafSecondaryText,"--documint-leaf-resolved-bg":N.leafResolvedBackground,"--documint-leaf-resolved-border":N.leafResolvedBorder,"--documint-leaf-text":N.leafText,"--documint-mention-bg":N.mentionBackground??void 0,"--documint-mention-text":N.mentionText??void 0,"--documint-selection-handle-bg":N.selectionHandleBackground,"--documint-selection-handle-border":N.selectionHandleBorder}}import{useEffect as vz,useEffectEvent as _1,useRef as zA,useState as p3}from"react";function aZ(N,F){let A=F.getBoundingClientRect();return{x:N.clientX-A.left+F.scrollLeft,y:N.clientY-A.top+F.scrollTop}}var rZ=28,cZ=18;function sZ({renderResources:N,theme:F}){let A=x0(),M=zA(D2()),D=zA(null),E=zA({height:240,top:0}),[$,Z]=p3(0),[Y,X]=p3(240),[y,Q]=p3(0),[J,V]=p3(240),U=kz($),S=()=>{let O=A.editor.getState(),W=E.current;return F5(O,{height:W.height,paddingX:F.paddingX,paddingY:F.paddingY,top:W.top,width:U},M.current,N)};A.viewport.setViewportResolver(S);let q=A.viewport,K=_1((O)=>{A.viewport.observeViewport(O),V((W)=>{let k=uz(O,E.current.height);return W===k?W:k})}),G=_1((O)=>{E.current={...E.current,top:O},Q((W)=>W===O?W:O),q.invalidate()}),z=_1((O)=>{let W=mz(O),k=W.top!==E.current.top;if(E.current=W,Q((g)=>g===W.top?g:W.top),k)q.invalidate()}),H=_1((O)=>{let W=D.current;if(!W)return G(O),O;W.scrollTop=O;let k=W.scrollTop;return G(k),k}),B=_1(()=>{return D.current?.scrollTop??E.current.top}),_=_1((O,W)=>{let k=O!==null&&O.documentIndex!==W.documentIndex,g=q.peek();if(!(!k||!g||g.layout.regionLineIndices.has(W.selection.focus.regionId)))q.invalidate()}),j=_1(()=>{q.invalidate()}),L=_1((O)=>{let W=D.current;return W?aZ(O,W):null}),T=_1((O)=>{let W=D.current;if(!W)return;let k=W.getBoundingClientRect();if(O.clientY<k.top+rZ){W.scrollTop=Math.max(0,W.scrollTop-cZ);return}if(O.clientY>k.bottom-rZ)W.scrollTop+=cZ});return vz(()=>{let O=D.current;if(!O||typeof ResizeObserver>"u")return;let W=new ResizeObserver((k)=>{let g=k[0];if(!g)return;let R=Math.max(0,Math.floor(g.contentRect.width)),P=iZ(O);E.current={...E.current,height:P},Z((b)=>b===R?b:R),X((b)=>b===P?b:P)});return W.observe(O),()=>W.disconnect()},[D]),{actions:{autoScrollDuringDrag:T,getScrollTop:B,invalidateViewport:j,observeViewport:K,observeScrollContainer:z,reconcileEditorState:_,resolvePoint:L,scrollTo:H},props:{scrollContent:{style:{height:`${J}px`}}},refs:{scrollContainer:D},state:{layoutWidth:U,scrollContentHeight:J,viewportLayout:q,viewportHeight:Y,viewportTop:y}}}function kz(N){return Math.max(240,Math.floor(N||480))}function iZ(N){return Math.max(240,N.clientHeight)}function mz(N){return{height:iZ(N),top:N.scrollTop}}function uz(N,F){return Math.max(F,Math.ceil(N.totalHeight+24))}function gz(){if(typeof window>"u")return 1;return Math.max(1,window.devicePixelRatio||1)}function HA(N,{paintHeight:F,paintTop:A,width:M}){if(!N)return null;let D=Math.max(240,Math.ceil(F)),E=gz();N.width=Math.ceil(M*E),N.height=Math.ceil(D*E),N.style.width=`${M}px`,N.style.height=`${D}px`,N.style.transform=`translateY(${A}px)`;let $=N.getContext("2d");if(!$)return null;return{context:$,devicePixelRatio:E,height:D,width:M}}function _A(N,F){let A=[],M=new Set;for(let D of C3(N,F)){if(D.kind!=="token"||D.trigger!=="@"||!D.id)continue;if(M.has(D.id))continue;M.add(D.id),A.push(D.id)}return A}function oZ(N,F){if(!F?.length||!N?.length)return;let A=new Map(N.map((D)=>[D.id,D])),M=[];for(let D of F){let E=A.get(D.userId);if(!E)continue;M.push({...E,color:D.color,cursor:D.cursor})}return M.length===0?void 0:M}var nZ=/^(https?:|data:|blob:)/i;class BA{storage;view;constructor(N,F){this.storage=N;this.view=F}async readFile(N){if(nZ.test(N))try{let F=await fetch(N);return F.ok?F.blob():null}catch{return null}return this.storage?.readFile(N)??null}writeFile(N){if(!this.storage?.writeFile)throw Error("No storage configured");return this.storage.writeFile(N)}openFile(N){if(nZ.test(N))this.view?.open(N,"_blank","noopener,noreferrer");else this.storage?.openFile?.(N)}}function eZ(N,F){if(!N)return{didReconcile:!1,state:F};let A=hz(N,F)??sz(N,F);return A?{didReconcile:!0,state:A}:{didReconcile:!1,state:F}}function hz(N,F){let A=Iz(N,F);return A?O0(F,A,!1):null}function Iz(N,F){if(OA(N.selection.anchor,N.selection.focus)){let E=PA(N,F,N.selection.focus,"neutral");return E?{anchor:E,focus:E}:null}let A=rz(N),M=PA(N,F,N.selection.anchor,A.anchor),D=PA(N,F,N.selection.focus,A.focus);return M&&D?{anchor:M,focus:D}:null}function PA(N,F,A,M){let D=N.documentIndex.regionIndex.get(A.regionId);if(!D)return null;let E=WA(D,F);if(!E)return null;return{offset:xz(D.text,E.text,A.offset,M),regionId:E.id}}function WA(N,F){let A=F.documentIndex.regionIndex.get(N.id);if(A)return A;if(N.text.length===0)return null;let M=pz(N,F);if(M)return M;return F.documentIndex.regionPathIndex.get(N.path)??null}function pz(N,F){let A=null;for(let M of F.documentIndex.regions){if(M.blockType!==N.blockType||M.text!==N.text)continue;if(A)return null;A=M}return A}function xz(N,F,A,M){let D=i0(A,0,N.length),{prefix:E,suffix:$}=V4(N,D,D),Z=lz(F,E,$);if(Z!==null)return Z;let Y=dz(F,E),X=az(F,$);if(M==="before-suffix")return X??Y??i0(A,0,F.length);return Y??X??i0(A,0,F.length)}function lz(N,F,A){let M=j2(N,F,A).filter((D)=>D.startOffset===D.endOffset);return M.length===1?M[0].startOffset:null}function dz(N,F){let A=X1(N,F);return A.length===1?A[0]+F.length:null}function az(N,F){let A=X1(N,F);return A.length===1?A[0]:null}function rz(N){let{anchor:F,focus:A}=N.selection;if(OA(F,A))return{anchor:"neutral",focus:"neutral"};return cz(N,F,A)<=0?{anchor:"before-suffix",focus:"after-prefix"}:{anchor:"after-prefix",focus:"before-suffix"}}function cz(N,F,A){let M=N.documentIndex.regionOrderIndex.get(F.regionId),D=N.documentIndex.regionOrderIndex.get(A.regionId);if(M===void 0||D===void 0)return 0;return M===D?F.offset-A.offset:M-D}function sz(N,F){if(!OA(N.selection.anchor,N.selection.focus))return null;let A=iz(N);if(!A)return null;let M=oz(N,F,A);if(M===null)return null;return nz(F,M)}function iz(N){let F=N.documentIndex.regionIndex.get(N.selection.focus.regionId);if(!F||F.blockType!=="paragraph"||F.text.length>0)return null;return N.documentIndex.blockIndex.get(F.blockId)?.parentBlockId===null?F:null}function oz(N,F,A){let M=tZ(N,A.rootIndex,"before"),D=tZ(N,A.rootIndex,"after"),E=M?WA(M,F):null,$=D?WA(D,F):null;if(E&&$)return E.rootIndex<$.rootIndex?$.rootIndex:null;if(E)return E.rootIndex+1;if($)return $.rootIndex;return null}function nz(N,F){let A=e1(N.documentIndex.document,F,0,[F0("")]),M={...N,documentIndex:f2(N.documentIndex,A,F,0)},D=wN(M.documentIndex,$0(F));return D?O0(M,D,!1):null}function tZ(N,F,A){let M=A==="before"?-1:1;for(let D=F+M;D>=0&&D<N.documentIndex.roots.length;D+=M){let E=tz(N,D,A);if(E)return E}return null}function tz(N,F,A){let M=N.documentIndex.roots[F]?.regions??[],D=A==="before"?M.length-1:0,E=A==="before"?-1:1;for(let $=D;$>=0&&$<M.length;$+=E){let Z=M[$];if(Z&&Z.text.length>0)return Z}return null}function OA(N,F){return N.regionId===F.regionId&&N.offset===F.offset}function FY(N,F){let A=N.previous.documentIndex.regionIndex.get(F.regionId);if(!A)return null;let M=N.next.documentIndex.regionPathIndex.get(A.path);if(!M)return null;let D=N.previous.documentIndex.document,E=N.next.documentIndex.document,$=D.blocks[A.rootIndex],Z=E.blocks[M.rootIndex];if(!$||!Z)return null;let Y=ez($,Z);if(!Y)return null;return{lineMarkdown:Y.lineMarkdown,lineNumber:NH(E,M.rootIndex)+Y.lineIndex}}function ez(N,F){let A=NY(N),M=NY(F),D=FH(A,M);if(D===null)return null;let E=M.lastIndexOf(`
|
|
34
|
+
`?Z3(D):eN(D,E);if(!$)continue;D=$}return D===N?null:D}function oG(N,F,A,M){let D=N.selection.focus,E=Math.max(0,D.offset-A),$=Math.max(0,E-F);return Y3(N,$,E,M)}function nG(N,F,A,M){if(A.key==="Delete")return S8(N);let D=iy(A,M);if(D){if(D==="moveToLineStart"||D==="moveToLineEnd")return z8(N,F.layout,D==="moveToLineStart"?"Home":"End",A.shiftKey);if(D==="moveToDocumentStart"||D==="moveToDocumentEnd")return G8(N,D==="moveToDocumentStart"?"start":"end",A.shiftKey);switch(D){case"insertLineBreak":return Z3(N);case"insertSoftLineBreak":return O7(N);case"deleteBackward":return Q8(N);case"indent":return q3(N);case"dedent":return U3(N);case"moveListItemUp":return v7(N);case"moveListItemDown":return m7(N);case"toggleBold":return X3(N);case"toggleItalic":return Q3(N);case"toggleStrikethrough":return S3(N);case"toggleUnderline":return J3(N);case"toggleCode":return V3(N);case"undo":return J8(N);case"redo":return V8(N);case"selectAll":return T7(N)}}if(A.key==="ArrowLeft"||A.key==="ArrowRight")return q8(N,A.key==="ArrowLeft"?-1:1,A.shiftKey);if(A.key==="ArrowUp"||A.key==="ArrowDown")return U8(N,F.layout,A.key==="ArrowUp"?-1:1,A.shiftKey);if(A.key==="PageUp"||A.key==="PageDown")return K8(N,F.layout,A.key==="PageUp"?-1:1,A.shiftKey);if(A.key.length===1&&!A.altKey&&!A.ctrlKey&&!A.metaKey)return eN(N,A.key);return null}import{useEffect as tG,useEffectEvent as B2,useRef as AZ}from"react";function MZ(){return{fullRender:!1,fullPaint:!1,contentPaint:!1,overlayPaint:!1}}function DZ({hasRunningOptionalContentAnimations:N,isActive:F,renderContent:A,renderOverlay:M,renderViewport:D}){let E=x0(),$=AZ(null),y=AZ(MZ()),Z=B2(()=>{if(typeof window>"u"){D();return}y.current.fullRender=!0,S()}),Y=B2(()=>{if(typeof window>"u"){A(),M();return}y.current.fullPaint=!0,S()}),X=B2(()=>{if(typeof window>"u"){A();return}y.current.contentPaint=!0,S()}),Q=B2(()=>{if(typeof window>"u"){M();return}y.current.overlayPaint=!0,S()}),S=B2(()=>{if(typeof window>"u"||$.current!==null)return;$.current=window.requestAnimationFrame(()=>{J()})}),J=B2(()=>{$.current=null;let K=y.current,q=K.fullRender,U=K.fullPaint,z=K.contentPaint,G=K.overlayPaint;if(y.current=MZ(),q){D(),V();return}if(U){A(),M(),V();return}if(z)A(),V();if(G)M()}),V=B2(()=>{if(O5(E.editor.getState(),performance.now())){y.current.contentPaint=!0,S();return}if(F?.()===!0||N?.()!==!0)return;y.current.contentPaint=!0,S()});return tG(()=>{return()=>{if(typeof window>"u"||$.current===null)return;window.cancelAnimationFrame($.current),$.current=null}},[]),{scheduleContentPaint:X,scheduleFullPaint:Y,scheduleFullRender:Z,scheduleOverlayPaint:Q}}import{useEffectEvent as bA,useRef as fA,useState as eG}from"react";function EZ({autoScrollDuringDrag:N,isEditable:F,focusInput:A,onActivity:M,resolvePoint:D}){let[E,$]=eG(null),y=e(NA),Z=e(FA,E),Y=h(L0),X=h(AF),Q=fA(null),S=fA(null),J=fA(null),V=bA((G,H=!0)=>{if(Z?.kind!=="annotation")return;$({anchor:Z.anchor,animateInitialComment:H,leftOverride:Z.leftOverride,paddingY:Z.paddingY,selection:Z.selection,threadIndex:G})}),K=bA((G)=>{if(G&&J.current===G.pointerId&&G.currentTarget.hasPointerCapture(G.pointerId))G.currentTarget.releasePointerCapture(G.pointerId);Q.current=null,S.current=null,J.current=null}),q=bA((G)=>{let H=S.current,B=D(G);if(!B||!H||J.current!==G.pointerId||!y.viewport)return;if(!X(y.viewport,B,H))return;G.preventDefault(),G.stopPropagation(),M(),N(G)}),U=(G)=>({onPointerCancel:(H)=>{K(H)},onPointerDown:(H)=>{let B=NH(y.normalized,G),_=G==="start"?y.normalized.start:y.normalized.end;if(!y.handles)return;H.preventDefault(),H.stopPropagation(),J.current=H.pointerId,S.current=B,Q.current=G,H.currentTarget.setPointerCapture(H.pointerId),M(),A(),Y({anchor:B,focus:_})},onPointerMove:(H)=>{if(Q.current!==G)return;q(H)},onPointerUp:(H)=>{if(Q.current===G)q(H);K(H)}});return{handle:y.handles?{start:{...y.handles.start,props:U("start")},end:{...y.handles.end,props:U("end")}}:null,leaf:F?Z:null,promoteLeafToThread:V}}function NH(N,F){return F==="start"?N.end:N.start}import{useEffect as FH,useMemo as ZZ,useState as AH}from"react";var pF={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",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)"},xF={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(251, 191, 36, 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",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)"},$Z={...pF,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)"},yZ={...xF,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",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 YZ(N){let F=ZZ(()=>DH(N),[N]),[A,M]=AH(F.light),D=ZZ(()=>EH(A),[A]);return FH(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function"){M(F.light);return}let E=window.matchMedia("(prefers-color-scheme: dark)"),$=()=>{M(E.matches?F.dark:F.light)};if($(),typeof E.addEventListener==="function")return E.addEventListener("change",$),()=>{E.removeEventListener("change",$)};return E.addListener($),()=>{E.removeListener($)}},[F]),{theme:A,themeStyles:D}}function MH(N){return"light"in N&&"dark"in N}function DH(N){if(!N)return{dark:xF,light:pF};if(MH(N))return N;return{dark:N,light:N}}function EH(N){return{"--documint-background":N.background,"--documint-leaf-button-bg":N.leafButtonBackground,"--documint-leaf-button-border":N.leafButtonBorder,"--documint-leaf-button-text":N.leafButtonText,"--documint-leaf-accent":N.leafAccent,"--documint-leaf-bg":N.leafBackground,"--documint-leaf-border":N.leafBorder,"--documint-leaf-font-family":'"Avenir Next", "Segoe UI", sans-serif',"--documint-leaf-shadow":N.leafShadow??void 0,"--documint-leaf-secondary-text":N.leafSecondaryText,"--documint-leaf-resolved-bg":N.leafResolvedBackground,"--documint-leaf-resolved-border":N.leafResolvedBorder,"--documint-leaf-text":N.leafText,"--documint-mention-bg":N.mentionBackground??void 0,"--documint-mention-text":N.mentionText??void 0,"--documint-selection-handle-bg":N.selectionHandleBackground,"--documint-selection-handle-border":N.selectionHandleBorder}}import{useEffect as $H,useEffectEvent as P1,useRef as uA,useState as o3}from"react";function XZ(N,F){let A=F.getBoundingClientRect();return{x:N.clientX-A.left+F.scrollLeft,y:N.clientY-A.top+F.scrollTop}}var QZ=28,SZ=18;function JZ({renderResources:N,theme:F}){let A=x0(),M=uA(D2()),D=uA(null),E=uA({height:240,top:0}),[$,y]=o3(0),[Z,Y]=o3(240),[X,Q]=o3(0),[S,J]=o3(240),V=yH($),K=()=>{let L=A.editor.getState(),W=E.current;return X5(L,{height:W.height,paddingX:F.paddingX,paddingY:F.paddingY,top:W.top,width:V},M.current,N)};A.viewport.setViewportResolver(K);let q=A.viewport,U=P1((L)=>{A.viewport.observeViewport(L),J((W)=>{let v=YH(L,E.current.height);return W===v?W:v})}),z=P1((L)=>{E.current={...E.current,top:L},Q((W)=>W===L?W:L),q.invalidate()}),G=P1((L)=>{let W=ZH(L),v=W.top!==E.current.top;if(E.current=W,Q((g)=>g===W.top?g:W.top),v)q.invalidate()}),H=P1((L)=>{let W=D.current;if(!W)return z(L),L;W.scrollTop=L;let v=W.scrollTop;return z(v),v}),B=P1(()=>{return D.current?.scrollTop??E.current.top}),_=P1((L,W)=>{let v=L!==null&&L.documentIndex!==W.documentIndex,g=q.peek();if(!(!v||!g||g.layout.regionLineIndices.has(W.selection.focus.regionId)))q.invalidate()}),O=P1(()=>{q.invalidate()}),w=P1((L)=>{let W=D.current;return W?XZ(L,W):null}),b=P1((L)=>{let W=D.current;if(!W)return;let v=W.getBoundingClientRect();if(L.clientY<v.top+QZ){W.scrollTop=Math.max(0,W.scrollTop-SZ);return}if(L.clientY>v.bottom-QZ)W.scrollTop+=SZ});return $H(()=>{let L=D.current;if(!L||typeof ResizeObserver>"u")return;let W=new ResizeObserver((v)=>{let g=v[0];if(!g)return;let j=Math.max(0,Math.floor(g.contentRect.width)),P=VZ(L);E.current={...E.current,height:P},y((R)=>R===j?R:j),Y((R)=>R===P?R:P)});return W.observe(L),()=>W.disconnect()},[D]),{actions:{autoScrollDuringDrag:b,getScrollTop:B,invalidateViewport:O,observeViewport:U,observeScrollContainer:G,reconcileEditorState:_,resolvePoint:w,scrollTo:H},props:{scrollContent:{style:{height:`${S}px`}}},refs:{scrollContainer:D},state:{layoutWidth:V,scrollContentHeight:S,viewportLayout:q,viewportHeight:Z,viewportTop:X}}}function yH(N){return Math.max(240,Math.floor(N||480))}function VZ(N){return Math.max(240,N.clientHeight)}function ZH(N){return{height:VZ(N),top:N.scrollTop}}function YH(N,F){return Math.max(F,Math.ceil(N.totalHeight+24))}function XH(){if(typeof window>"u")return 1;return Math.max(1,window.devicePixelRatio||1)}function vA(N,{paintHeight:F,paintTop:A,width:M}){if(!N)return null;let D=Math.max(240,Math.ceil(F)),E=XH();N.width=Math.ceil(M*E),N.height=Math.ceil(D*E),N.style.width=`${M}px`,N.style.height=`${D}px`,N.style.transform=`translateY(${A}px)`;let $=N.getContext("2d");if(!$)return null;return{context:$,devicePixelRatio:E,height:D,width:M}}function mA(N,F){let A=[],M=new Set;for(let D of h3(N,F)){if(D.kind!=="token"||D.trigger!=="@"||!D.id)continue;if(M.has(D.id))continue;M.add(D.id),A.push(D.id)}return A}var qZ=/^(https?:|data:|blob:)/i;class kA{storage;view;constructor(N,F){this.storage=N;this.view=F}async readFile(N){if(qZ.test(N))try{let F=await fetch(N);return F.ok?F.blob():null}catch{return null}return this.storage?.readFile(N)??null}writeFile(N){if(!this.storage?.writeFile)throw Error("No storage configured");return this.storage.writeFile(N)}openFile(N){if(qZ.test(N))this.view?.open(N,"_blank","noopener,noreferrer");else this.storage?.openFile?.(N)}}function KZ(N,F){if(!N)return{didReconcile:!1,state:F};let A=QH(N,F)??HH(N,F);return A?{didReconcile:!0,state:A}:{didReconcile:!1,state:F}}function QH(N,F){let A=SH(N,F);return A?L0(F,A,!1):null}function SH(N,F){if(IA(N.selection.anchor,N.selection.focus)){let E=gA(N,F,N.selection.focus,"neutral");return E?{anchor:E,focus:E}:null}let A=zH(N),M=gA(N,F,N.selection.anchor,A.anchor),D=gA(N,F,N.selection.focus,A.focus);return M&&D?{anchor:M,focus:D}:null}function gA(N,F,A,M){let D=N.documentIndex.regionIndex.get(A.regionId);if(!D)return null;let E=hA(D,F);if(!E)return null;return{offset:VH(D.text,E.text,A.offset,M),regionId:E.id}}function hA(N,F){let A=F.documentIndex.regionIndex.get(N.id);if(A)return A;if(N.text.length===0)return null;let M=JH(N,F);if(M)return M;return F.documentIndex.regionPathIndex.get(N.path)??null}function JH(N,F){let A=null;for(let M of F.documentIndex.regions){if(M.blockType!==N.blockType||M.text!==N.text)continue;if(A)return null;A=M}return A}function VH(N,F,A,M){let D=n0(A,0,N.length),{prefix:E,suffix:$}=B4(N,D,D),y=qH(F,E,$);if(y!==null)return y;let Z=UH(F,E),Y=KH(F,$);if(M==="before-suffix")return Y??Z??n0(A,0,F.length);return Z??Y??n0(A,0,F.length)}function qH(N,F,A){let M=m2(N,F,A).filter((D)=>D.startOffset===D.endOffset);return M.length===1?M[0].startOffset:null}function UH(N,F){let A=X1(N,F);return A.length===1?A[0]+F.length:null}function KH(N,F){let A=X1(N,F);return A.length===1?A[0]:null}function zH(N){let{anchor:F,focus:A}=N.selection;if(IA(F,A))return{anchor:"neutral",focus:"neutral"};return GH(N,F,A)<=0?{anchor:"before-suffix",focus:"after-prefix"}:{anchor:"after-prefix",focus:"before-suffix"}}function GH(N,F,A){let M=N.documentIndex.regionOrderIndex.get(F.regionId),D=N.documentIndex.regionOrderIndex.get(A.regionId);if(M===void 0||D===void 0)return 0;return M===D?F.offset-A.offset:M-D}function HH(N,F){if(!IA(N.selection.anchor,N.selection.focus))return null;let A=_H(N);if(!A)return null;let M=BH(N,F,A);if(M===null)return null;return PH(F,M)}function _H(N){let F=N.documentIndex.regionIndex.get(N.selection.focus.regionId);if(!F||F.blockType!=="paragraph"||F.text.length>0)return null;return N.documentIndex.blockIndex.get(F.blockId)?.parentBlockId===null?F:null}function BH(N,F,A){let M=UZ(N,A.rootIndex,"before"),D=UZ(N,A.rootIndex,"after"),E=M?hA(M,F):null,$=D?hA(D,F):null;if(E&&$)return E.rootIndex<$.rootIndex?$.rootIndex:null;if(E)return E.rootIndex+1;if($)return $.rootIndex;return null}function PH(N,F){let A=A2(N.documentIndex.document,F,0,[F0("")]),M={...N,documentIndex:s2(N.documentIndex,A,F,0)},D=pN(M.documentIndex,$0(F));return D?L0(M,D,!1):null}function UZ(N,F,A){let M=A==="before"?-1:1;for(let D=F+M;D>=0&&D<N.documentIndex.roots.length;D+=M){let E=WH(N,D,A);if(E)return E}return null}function WH(N,F,A){let M=N.documentIndex.roots[F]?.regions??[],D=A==="before"?M.length-1:0,E=A==="before"?-1:1;for(let $=D;$>=0&&$<M.length;$+=E){let y=M[$];if(y&&y.text.length>0)return y}return null}function IA(N,F){return N.regionId===F.regionId&&N.offset===F.offset}function GZ(N,F){let A=N.previous.documentIndex.regionIndex.get(F.regionId);if(!A)return null;let M=N.next.documentIndex.regionPathIndex.get(A.path);if(!M)return null;let D=N.previous.documentIndex.document,E=N.next.documentIndex.document,$=D.blocks[A.rootIndex],y=E.blocks[M.rootIndex];if(!$||!y)return null;let Z=OH($,y);if(!Z)return null;return{lineMarkdown:Z.lineMarkdown,lineNumber:wH(E,M.rootIndex)+Z.lineIndex}}function OH(N,F){let A=zZ(N),M=zZ(F),D=LH(A,M);if(D===null)return null;let E=M.lastIndexOf(`
|
|
35
35
|
`,Math.max(0,D-1))+1,$=M.indexOf(`
|
|
36
|
-
`,D);return{lineIndex:
|
|
37
|
-
`)A+=1;return A}import{jsx as o,jsxs as l3,Fragment as XH}from"react/jsx-runtime";function d3({blocks:N}){return o(XH,{children:N.map((F)=>AH(F))})}function AH(N){switch(N.type){case"blockquote":return o("blockquote",{className:"preview-block preview-block-blockquote",children:o(d3,{blocks:N.children})},N.id);case"code":return l3("div",{className:"preview-block preview-block-code",children:[o("div",{className:"preview-rich-header",children:EH(N.language,N.meta)}),o("pre",{children:o("code",{children:N.source||" "})})]},N.id);case"heading":{let F=`h${N.depth}`;return o(F,{className:"preview-block preview-block-heading",children:x3(N.children)},N.id)}case"list":return N.ordered?o("ol",{className:"preview-block preview-block-list",start:N.start??1,children:N.items.map((F)=>LA(F))},N.id):o("ul",{className:"preview-block preview-block-list",children:N.items.map((F)=>LA(F))},N.id);case"listItem":return LA(N);case"paragraph":return o("p",{className:"preview-block preview-block-paragraph",children:x3(N.children)},N.id);case"table":return l3("div",{className:"preview-block preview-block-table",children:[o("div",{className:"preview-rich-header",children:$H(N.rows.length,N.rows[0]?.cells.length??0,N.align.filter((F)=>F!==null).length)}),o("div",{className:"preview-table-scroll",children:o("table",{children:o("tbody",{children:N.rows.map((F)=>o("tr",{children:F.cells.map((A)=>o("td",{children:x3(A.children)},A.id))},F.id))})})})]},N.id);case"divider":return o("hr",{className:"preview-block preview-block-rule"},N.id);case"directive":return o("pre",{className:`preview-block preview-block-directive preview-block-directive-${N.name}`,children:N.body},N.id);case"raw":return o("pre",{className:"preview-block preview-block-unsupported",children:N.source},N.id)}}function LA(N){return o("li",{className:"preview-block preview-block-list-item",children:o(d3,{blocks:N.children})},N.id)}function x3(N){return N.map((F)=>{switch(F.type){case"lineBreak":return o("br",{},F.id);case"image":return l3("span",{className:"preview-inline preview-inline-image",children:[o("img",{alt:F.alt??"",src:F.url,title:F.title??""}),l3("span",{children:[o("strong",{children:ZH(F.alt)}),o("small",{children:YH(F.url,F.title)})]})]},F.id);case"code":return o("code",{className:"preview-inline preview-inline-code",children:F.code},F.id);case"link":return MH(F);case"text":return o("span",{className:"preview-inline",children:DH(F.text,F.marks)},F.id);case"raw":return o("span",{className:"preview-inline preview-inline-unsupported",children:F.source},F.id)}})}function MH(N){return o("a",{className:"preview-inline preview-inline-link",href:N.url,children:x3(N.children)},N.id)}function DH(N,F){let A=N;for(let M of F)switch(M){case"strikethrough":A=o("del",{children:A});break;case"italic":A=o("em",{children:A});break;case"bold":A=o("strong",{children:A});break;case"underline":A=o("ins",{children:A});break}return A}function EH(N,F){return[N??"plain text",F].filter(Boolean).join(" • ")}function $H(N,F,A){let M=A>0?`${A} aligned ${A===1?"column":"columns"}`:"no alignment";return`${N} ${N===1?"row":"rows"} • ${F} ${F===1?"column":"columns"} • ${M}`}function ZH(N){return N?.trim()?N:"Untitled image"}function YH(N,F){return F?.trim()?`${F} • ${N}`:N}import{useEffect as jA,useEffectEvent as r3,useMemo as QY,useRef as CA,useState as VH}from"react";function MY(N,F){return(F??N.blocks.map((M,D)=>D)).flatMap((M)=>{let D=N.blocks[M];return D?[{block:D,rootIndex:M,sourceKey:EY(D)}]:[]})}function DY(N,F,A){return K5(N,F,A.flatMap((M)=>{let D=N.documentIndex.document.blocks[M.rootIndex];if(!D||EY(D)!==M.sourceKey)return[];return[{ranges:M.ranges,rootIndex:M.rootIndex}]}))}var AY=new WeakMap,yH=1;function EY(N){let F=AY.get(N);if(F===void 0)F=String(yH++),AY.set(N,F);return F}function a3(N){return Boolean(N.backgroundColor||N.color)}function $Y(N){return N.filter(a3).map(({backgroundColor:F,color:A,pattern:M})=>({backgroundColor:F,color:A,flags:M.flags.replace(/g|y/g,""),source:M.source}))}function ZY(N){return N.filter(a3).map(({backgroundColor:F,color:A,pattern:M})=>`${M.source}:${M.flags}:${A??""}:${F??""}`).join("|")}var wA='function q(y,u){return`${y}.${u}`}function U(y){return`${y}.children`}function W(y,u){return q(y,u)}function J(y,u){return`${y}.rows.${u}`}function V(y,u){return`${y}.cells.${u}`}function j(y,u,D={}){E(y,u,P(),T(D.pathPrefix??"root",D.startIndex??0))}function E(y,u,D,A){for(let[m,S]of y.entries()){if(D.stopped)return;let R=q(A.pathPrefix,A.startIndex+m),g={blockAncestors:A.blockAncestors,depth:A.depth,parentBlock:A.parentBlock,path:R},$=u.enterBlock?.(S,g);if(K($,D))return;if($!=="skip")switch(S.type){case"list":Q(S.items,S,u,D,A,R);break;case"blockquote":case"listItem":Q(S.children,S,u,D,A,R);break;case"heading":case"paragraph":H(S.children,u,D,{block:S,blockAncestors:[...A.blockAncestors,S],container:S,kind:"block",path:U(R)});break;case"table":O(S,u,D,{blockAncestors:[...A.blockAncestors,S],pathPrefix:R});break;case"code":case"directive":case"divider":case"raw":break}if(D.stopped)return;if(K(u.leaveBlock?.(S,g),D))return}}function M(y,u,D,A){for(let[m,S]of y.entries()){if(D.stopped)return;let R=W(A.pathPrefix,m),g={block:A.block,blockAncestors:A.blockAncestors,inlineAncestors:A.inlineAncestors,parentInline:A.parentInline,path:R},$=u.enterInline?.(S,g);if(K($,D))return;if($!=="skip"){if(S.type==="link")N(S.children,S,u,D,A,R)}if(D.stopped)return;if(K(u.leaveInline?.(S,g),D))return}}function P(){return{stopped:!1}}function T(y,u){return{blockAncestors:[],depth:0,parentBlock:null,pathPrefix:y,startIndex:u}}function Q(y,u,D,A,m,S){E(y,D,A,{blockAncestors:[...m.blockAncestors,u],depth:m.depth+1,parentBlock:u,pathPrefix:U(S),startIndex:0})}function N(y,u,D,A,m,S){M(y,D,A,{block:m.block,blockAncestors:m.blockAncestors,inlineAncestors:[...m.inlineAncestors,u],parentInline:u,pathPrefix:U(S)})}function O(y,u,D,A){for(let[m,S]of y.rows.entries())for(let[R,g]of S.cells.entries()){if(D.stopped)return;let $=V(J(A.pathPrefix,m),R),Y={blockAncestors:A.blockAncestors,cellIndex:R,path:$,row:S,rowIndex:m,table:y},Z=u.enterTableCell?.(g,Y);if(K(Z,D))return;if(Z!=="skip")H(g.children,u,D,{block:y,blockAncestors:A.blockAncestors,container:g,kind:"tableCell",path:$});if(D.stopped)return;if(K(u.leaveTableCell?.(g,Y),D))return}}function H(y,u,D,A){let m=u.enterInlineContainer?.(y,A);if(K(m,D)||m==="skip")return;if(v(y,u,D,A),D.stopped)return;M(y,u,D,{block:A.block,blockAncestors:A.blockAncestors,inlineAncestors:[],parentInline:null,pathPrefix:B(A)})}function B(y){return y.kind==="tableCell"?U(y.path):y.path}function v(y,u,D,A){if(!u.enterPlainText)return;let m=0;for(let S of y){if(D.stopped)return;if(S.type==="text"){let R=m,g=R+S.text.length;if(S.marks.length===0&&K(u.enterPlainText(S.text,{...A,endOffset:g,startOffset:R}),D))return;m=g;continue}m+=X(S)}}function X(y){switch(y.type){case"lineBreak":return 1;case"image":case"mention":return 1;case"code":return y.code.length;case"raw":return y.source.length;case"text":return y.text.length;case"link":return y.children.reduce((u,D)=>u+X(D),0)}}function K(y,u){if(y!=="stop")return!1;return u.stopped=!0,!0}function C(y){return Boolean(y.backgroundColor||y.color)}function _(y){return y.map(({backgroundColor:u,color:D,flags:A,source:m})=>({backgroundColor:u,color:D,pattern:new RegExp(m,A.includes("g")?A:`${A}g`)}))}function w(y,u,D){if(D.length===0)return[];let A=f(D),m=[];return j([y],{enterPlainText(S,R){for(let g of b(S,A))m.push({...G(g),endOffset:R.startOffset+g.end,path:R.path,startOffset:R.startOffset+g.start})}},{startIndex:u}),m.sort((S,R)=>S.startOffset-R.startOffset)}function f(y){return y.filter(C).map(({backgroundColor:u,color:D,pattern:A})=>({regex:new RegExp(A.source,I(A.flags)),style:{backgroundColor:u,color:D}}))}function I(y){return`${y.replace(/[gyd]/g,"")}g`}function b(y,u){let D=Array.from({length:y.length},()=>({}));for(let{regex:A,style:m}of u){A.lastIndex=0;let S;while((S=A.exec(y))!==null){let R=k(S);if(!R||R.end<=R.start){A.lastIndex=S.index+1;continue}for(let g=R.start;g<R.end;g+=1){let $=D[g];if(m.color&&!$.color)$.color=m.color;if(m.backgroundColor&&!$.backgroundColor)$.backgroundColor=m.backgroundColor}}}return x(D)}function k(y){if(y.length<=1)return{end:y.index+y[0].length,start:y.index};for(let u=1;u<y.length;u+=1){let D=y[u];if(!D)continue;let A=y[0].indexOf(D);if(A!==-1){let m=y.index+A;return{end:m+D.length,start:m}}}return null}function G(y){return{...y.backgroundColor&&{backgroundColor:y.backgroundColor},...y.color&&{color:y.color}}}function x(y){let u=[],D=-1,A=null;for(let m=0;m<y.length;m+=1){let S=r(y[m])?y[m]:null;if(S&&D===-1){D=m,A=S;continue}if(!p(S,A)&&D!==-1)u.push({...G(A),end:m,start:D}),D=S?m:-1,A=S}if(D!==-1)u.push({...G(A),end:y.length,start:D});return u}function r(y){return Boolean(y.backgroundColor||y.color)}function p(y,u){return(y?.color??null)===(u?.color??null)&&(y?.backgroundColor??null)===(u?.backgroundColor??null)}var L=[],F="";self.addEventListener("message",(y)=>{let u=y.data;if(u.kind==="configure-decorations"){L=_(u.rules),F=u.rulesKey;return}if(u.kind!=="apply-decorations")return;try{if(u.rulesKey!==F)throw Error("Decoration worker rules are not configured.");let D=h(u.roots,L),A={kind:"decoration-result",requestId:u.requestId,roots:D,rulesKey:u.rulesKey};self.postMessage(A)}catch(D){let A={kind:"decoration-error",message:D instanceof Error?D.message:"Unknown decoration worker error.",requestId:u.requestId,rulesKey:u.rulesKey};self.postMessage(A)}});function h(y,u){return y.map((D)=>({ranges:w(D.block,D.rootIndex,u),rootIndex:D.rootIndex,sourceKey:D.sourceKey}))}\n';var QH=2000;class YY extends Error{constructor(){super("Decoration worker disposed.");this.name="DecorationWorkerDisposedError"}}function XY(N){return N instanceof Error&&N.name==="DecorationWorkerDisposedError"}function yY(N={}){let F=(N.createWorker??JH)();if(!F)return null;let A=F,M=N.timeoutMs??QH,D=!1,E="",$=1,Z=new Map;function Y(X){if(D)return;D=!0,A.terminate();for(let[y,Q]of Z)Z.delete(y),clearTimeout(Q.timeoutId),Q.reject(X)}return A.addEventListener("message",(X)=>{let y=X.data,Q=Z.get(y.requestId);if(!Q)return;if(Z.delete(y.requestId),clearTimeout(Q.timeoutId),y.kind==="decoration-error"){Q.reject(Error(y.message));return}Q.resolve({roots:y.roots,rulesKey:y.rulesKey})}),A.addEventListener("error",(X)=>{Y(Error(X.message||"Decoration worker failed."))}),{dispose(){Y(new YY)},run(X){if(D)return Promise.reject(Error("Decoration worker terminated."));let y=$++;if(E!==X.rulesKey)A.postMessage({kind:"configure-decorations",rules:$Y(X.rules),rulesKey:X.rulesKey}),E=X.rulesKey;let Q={kind:"apply-decorations",requestId:y,roots:X.roots,rulesKey:X.rulesKey};return new Promise((J,V)=>{let U=setTimeout(()=>{Y(Error("Decoration worker job timed out."))},M);Z.set(y,{reject:V,resolve:J,timeoutId:U}),A.postMessage(Q)})}}}function JH(){if(typeof Worker>"u"||typeof Blob>"u"||typeof URL>"u"||wA.trim().length===0)return null;try{let N=new Blob([wA],{type:"application/javascript"}),F=URL.createObjectURL(N),A=new Worker(F,{type:"module"});return URL.revokeObjectURL(F),A}catch(N){return null}}var UH=220,JY=[],YN=new Map;function VY({contentDocument:N,decorations:F,store:A}){let M=CA(null),D=CA(null),E=CA(null),$=QY(()=>{let q=F?.filter(a3)??JY;return q.length===0?JY:q},[F]),Z=$.length>0,Y=QY(()=>ZY($),[$]),[X,y]=VH(()=>YN),Q=()=>{if(E.current!==null)clearTimeout(E.current),E.current=null;D.current=null},J=r3((q)=>{if(q.rulesKey!==Y||q.roots.length===0)return;y((K)=>{return DY(A.editor.getState(),K,q.roots)??K})}),V=r3((q,K=!1)=>{if(K)Q();if(!Z){y((B)=>B.size===0?B:YN);return}let G=A.editor.getState(),z=MY(G.documentIndex.document,q);if(z.length===0){y((B)=>B.size===0?B:YN);return}let H=M.current??yY();if(!H){y((B)=>B.size===0?B:YN);return}M.current=H,H.run({roots:z,rules:$,rulesKey:Y}).then(J).catch((B)=>{if(XY(B))return;if(M.current===H)M.current=null;y((_)=>_.size===0?_:YN)})}),U=r3(()=>{let q=D.current;if(D.current=null,E.current=null,!q||q.size===0)return;V([...q])}),S=r3((q)=>{if(!Z)return;if(!q.documentChanged||q.changedRootIndexes.length===0)return;let K=D.current??new Set;D.current=K;for(let G of q.changedRootIndexes)K.add(G);if(E.current!==null)clearTimeout(E.current);E.current=setTimeout(U,UH)});return jA(()=>{return()=>{Q(),M.current?.dispose(),M.current=null}},[]),jA(()=>{if(Z)return;Q(),M.current?.dispose(),M.current=null,y((q)=>q.size===0?q:YN)},[Z]),jA(()=>{if(!Z)return;V(void 0,!0)},[N,Y,Z]),{scheduleDecorationsForTransition:S,textDecorations:X}}var UY=`/* Base Documint host and SSR-fallback styles. */
|
|
36
|
+
`,D);return{lineIndex:pA(M,E),lineMarkdown:M.slice(E,$===-1?M.length:$)}}function wH(N,F){let A=1;if(N.frontMatter!==void 0)A+=pA(N.frontMatter,N.frontMatter.length)+2;if(F>0){let M=G2({kind:"blocks",blocks:N.blocks.slice(0,F)});if(M.length>0)A+=pA(M,M.length)+2}return A}function zZ(N){return G2({kind:"blocks",blocks:[N]})}function LH(N,F){let A=Math.min(N.length,F.length);for(let M=0;M<A;M+=1)if(N[M]!==F[M])return M;return N.length===F.length?null:A}function pA(N,F){let A=0;for(let M=0;M<F;M+=1)if(N[M]===`
|
|
37
|
+
`)A+=1;return A}import{jsx as n,jsxs as t3,Fragment as vH}from"react/jsx-runtime";function e3({blocks:N}){return n(vH,{children:N.map((F)=>TH(F))})}function TH(N){switch(N.type){case"blockquote":return n("blockquote",{className:"preview-block preview-block-blockquote",children:n(e3,{blocks:N.children})},N.id);case"code":return t3("div",{className:"preview-block preview-block-code",children:[n("div",{className:"preview-rich-header",children:RH(N.language,N.meta)}),n("pre",{children:n("code",{children:N.source||" "})})]},N.id);case"heading":{let F=`h${N.depth}`;return n(F,{className:"preview-block preview-block-heading",children:n3(N.children)},N.id)}case"list":return N.ordered?n("ol",{className:"preview-block preview-block-list",start:N.start??1,children:N.items.map((F)=>xA(F))},N.id):n("ul",{className:"preview-block preview-block-list",children:N.items.map((F)=>xA(F))},N.id);case"listItem":return xA(N);case"paragraph":return n("p",{className:"preview-block preview-block-paragraph",children:n3(N.children)},N.id);case"table":return t3("div",{className:"preview-block preview-block-table",children:[n("div",{className:"preview-rich-header",children:bH(N.rows.length,N.rows[0]?.cells.length??0,N.align.filter((F)=>F!==null).length)}),n("div",{className:"preview-table-scroll",children:n("table",{children:n("tbody",{children:N.rows.map((F)=>n("tr",{children:F.cells.map((A)=>n("td",{children:n3(A.children)},A.id))},F.id))})})})]},N.id);case"divider":return n("hr",{className:"preview-block preview-block-rule"},N.id);case"directive":return n("pre",{className:`preview-block preview-block-directive preview-block-directive-${N.name}`,children:N.body},N.id);case"raw":return n("pre",{className:"preview-block preview-block-unsupported",children:N.source},N.id)}}function xA(N){return n("li",{className:"preview-block preview-block-list-item",children:n(e3,{blocks:N.children})},N.id)}function n3(N){return N.map((F)=>{switch(F.type){case"lineBreak":return n("br",{},F.id);case"image":return t3("span",{className:"preview-inline preview-inline-image",children:[n("img",{alt:F.alt??"",src:F.url,title:F.title??""}),t3("span",{children:[n("strong",{children:fH(F.alt)}),n("small",{children:uH(F.url,F.title)})]})]},F.id);case"code":return n("code",{className:"preview-inline preview-inline-code",children:F.code},F.id);case"link":return CH(F);case"text":return n("span",{className:"preview-inline",children:jH(F.text,F.marks)},F.id);case"raw":return n("span",{className:"preview-inline preview-inline-unsupported",children:F.source},F.id)}})}function CH(N){return n("a",{className:"preview-inline preview-inline-link",href:N.url,children:n3(N.children)},N.id)}function jH(N,F){let A=N;for(let M of F)switch(M){case"strikethrough":A=n("del",{children:A});break;case"italic":A=n("em",{children:A});break;case"bold":A=n("strong",{children:A});break;case"underline":A=n("ins",{children:A});break}return A}function RH(N,F){return[N??"plain text",F].filter(Boolean).join(" • ")}function bH(N,F,A){let M=A>0?`${A} aligned ${A===1?"column":"columns"}`:"no alignment";return`${N} ${N===1?"row":"rows"} • ${F} ${F===1?"column":"columns"} • ${M}`}function fH(N){return N?.trim()?N:"Untitled image"}function uH(N,F){return F?.trim()?`${F} • ${N}`:N}import{useEffect as dA,useEffectEvent as F4,useMemo as CZ,useRef as aA,useState as hH}from"react";function _Z(N,F){return(F??N.blocks.map((M,D)=>D)).flatMap((M)=>{let D=N.blocks[M];return D?[{block:D,rootIndex:M,sourceKey:PZ(D)}]:[]})}function BZ(N,F,A){return C8(N,F,A.flatMap((M)=>{let D=N.documentIndex.document.blocks[M.rootIndex];if(!D||PZ(D)!==M.sourceKey)return[];return[{ranges:M.ranges,rootIndex:M.rootIndex}]}))}var HZ=new WeakMap,mH=1;function PZ(N){let F=HZ.get(N);if(F===void 0)F=String(mH++),HZ.set(N,F);return F}function N4(N){return Boolean(N.backgroundColor||N.color)}function WZ(N){return N.filter(N4).map(({backgroundColor:F,pulse:A,color:M,pattern:D})=>({backgroundColor:F,...F&&A&&{pulse:!0},color:M,flags:D.flags.replace(/g|y/g,""),source:D.source}))}function OZ(N){return N.filter(N4).map(({backgroundColor:F,pulse:A,color:M,pattern:D})=>`${D.source}:${D.flags}:${M??""}:${F??""}:${F&&A?1:0}`).join("|")}var lA='function U(y,u){return`${y}.${u}`}function q(y){return`${y}.children`}function W(y,u){return U(y,u)}function J(y,u){return`${y}.rows.${u}`}function V(y,u){return`${y}.cells.${u}`}function j(y,u,D={}){E(y,u,z(),T(D.pathPrefix??"root",D.startIndex??0))}function E(y,u,D,A){for(let[R,S]of y.entries()){if(D.stopped)return;let $=U(A.pathPrefix,A.startIndex+R),m={blockAncestors:A.blockAncestors,depth:A.depth,parentBlock:A.parentBlock,path:$},g=u.enterBlock?.(S,m);if(K(g,D))return;if(g!=="skip")switch(S.type){case"list":Q(S.items,S,u,D,A,$);break;case"blockquote":case"listItem":Q(S.children,S,u,D,A,$);break;case"heading":case"paragraph":H(S.children,u,D,{block:S,blockAncestors:[...A.blockAncestors,S],container:S,kind:"block",path:q($)});break;case"table":O(S,u,D,{blockAncestors:[...A.blockAncestors,S],pathPrefix:$});break;case"code":case"directive":case"divider":case"raw":break}if(D.stopped)return;if(K(u.leaveBlock?.(S,m),D))return}}function M(y,u,D,A){for(let[R,S]of y.entries()){if(D.stopped)return;let $=W(A.pathPrefix,R),m={block:A.block,blockAncestors:A.blockAncestors,inlineAncestors:A.inlineAncestors,parentInline:A.parentInline,path:$},g=u.enterInline?.(S,m);if(K(g,D))return;if(g!=="skip"){if(S.type==="link")N(S.children,S,u,D,A,$)}if(D.stopped)return;if(K(u.leaveInline?.(S,m),D))return}}function z(){return{stopped:!1}}function T(y,u){return{blockAncestors:[],depth:0,parentBlock:null,pathPrefix:y,startIndex:u}}function Q(y,u,D,A,R,S){E(y,D,A,{blockAncestors:[...R.blockAncestors,u],depth:R.depth+1,parentBlock:u,pathPrefix:q(S),startIndex:0})}function N(y,u,D,A,R,S){M(y,D,A,{block:R.block,blockAncestors:R.blockAncestors,inlineAncestors:[...R.inlineAncestors,u],parentInline:u,pathPrefix:q(S)})}function O(y,u,D,A){for(let[R,S]of y.rows.entries())for(let[$,m]of S.cells.entries()){if(D.stopped)return;let g=V(J(A.pathPrefix,R),$),Y={blockAncestors:A.blockAncestors,cellIndex:$,path:g,row:S,rowIndex:R,table:y},Z=u.enterTableCell?.(m,Y);if(K(Z,D))return;if(Z!=="skip")H(m.children,u,D,{block:y,blockAncestors:A.blockAncestors,container:m,kind:"tableCell",path:g});if(D.stopped)return;if(K(u.leaveTableCell?.(m,Y),D))return}}function H(y,u,D,A){let R=u.enterInlineContainer?.(y,A);if(K(R,D)||R==="skip")return;if(v(y,u,D,A),D.stopped)return;M(y,u,D,{block:A.block,blockAncestors:A.blockAncestors,inlineAncestors:[],parentInline:null,pathPrefix:B(A)})}function B(y){return y.kind==="tableCell"?q(y.path):y.path}function v(y,u,D,A){if(!u.enterPlainText)return;let R=0;for(let S of y){if(D.stopped)return;if(S.type==="text"){let $=R,m=$+S.text.length;if(S.marks.length===0&&K(u.enterPlainText(S.text,{...A,endOffset:m,startOffset:$}),D))return;R=m;continue}R+=X(S)}}function X(y){switch(y.type){case"lineBreak":return 1;case"image":case"mention":return 1;case"code":return y.code.length;case"raw":return y.source.length;case"text":return y.text.length;case"link":return y.children.reduce((u,D)=>u+X(D),0)}}function K(y,u){if(y!=="stop")return!1;return u.stopped=!0,!0}function _(y){return Boolean(y.backgroundColor||y.color)}function w(y){return y.map(({backgroundColor:u,pulse:D,color:A,flags:R,source:S})=>({backgroundColor:u,...u&&D&&{pulse:!0},color:A,pattern:new RegExp(S,R.includes("g")?R:`${R}g`)}))}function C(y,u,D){if(D.length===0)return[];let A=f(D),R=[];return j([y],{enterPlainText(S,$){for(let m of b(S,A))R.push({...G(m),endOffset:$.startOffset+m.end,path:$.path,startOffset:$.startOffset+m.start})}},{startIndex:u}),R.sort((S,$)=>S.startOffset-$.startOffset)}function f(y){return y.filter(_).map(({backgroundColor:u,pulse:D,color:A,pattern:R})=>({regex:new RegExp(R.source,I(R.flags)),style:{backgroundColor:u,...u&&D&&{pulse:!0},color:A}}))}function I(y){return`${y.replace(/[gyd]/g,"")}g`}function b(y,u){let D=Array.from({length:y.length},()=>({}));for(let{regex:A,style:R}of u){A.lastIndex=0;let S;while((S=A.exec(y))!==null){let $=k(S);if(!$||$.end<=$.start){A.lastIndex=S.index+1;continue}for(let m=$.start;m<$.end;m+=1){let g=D[m];if(R.color&&!g.color)g.color=R.color;if(R.backgroundColor&&!g.backgroundColor){if(g.backgroundColor=R.backgroundColor,R.pulse)g.pulse=!0}}}}return x(D)}function k(y){if(y.length<=1)return{end:y.index+y[0].length,start:y.index};for(let u=1;u<y.length;u+=1){let D=y[u];if(!D)continue;let A=y[0].indexOf(D);if(A!==-1){let R=y.index+A;return{end:R+D.length,start:R}}}return null}function G(y){return{...y.backgroundColor&&{backgroundColor:y.backgroundColor},...y.color&&{color:y.color},...y.backgroundColor&&y.pulse&&{pulse:!0}}}function x(y){let u=[],D=-1,A=null;for(let R=0;R<y.length;R+=1){let S=p(y[R])?y[R]:null;if(S&&D===-1){D=R,A=S;continue}if(!r(S,A)&&D!==-1)u.push({...G(A),end:R,start:D}),D=S?R:-1,A=S}if(D!==-1)u.push({...G(A),end:y.length,start:D});return u}function p(y){return Boolean(y.backgroundColor||y.color)}function r(y,u){return(y?.color??null)===(u?.color??null)&&(y?.backgroundColor??null)===(u?.backgroundColor??null)&&Boolean(y?.backgroundColor&&y.pulse)===Boolean(u?.backgroundColor&&u.pulse)}var L=[],F="";self.addEventListener("message",(y)=>{let u=y.data;if(u.kind==="configure-decorations"){L=w(u.rules),F=u.rulesKey;return}if(u.kind!=="apply-decorations")return;try{if(u.rulesKey!==F)throw Error("Decoration worker rules are not configured.");let D=h(u.roots,L),A={kind:"decoration-result",requestId:u.requestId,roots:D,rulesKey:u.rulesKey};self.postMessage(A)}catch(D){let A={kind:"decoration-error",message:D instanceof Error?D.message:"Unknown decoration worker error.",requestId:u.requestId,rulesKey:u.rulesKey};self.postMessage(A)}});function h(y,u){return y.map((D)=>({ranges:C(D.block,D.rootIndex,u),rootIndex:D.rootIndex,sourceKey:D.sourceKey}))}\n';var kH=2000;class wZ extends Error{constructor(){super("Decoration worker disposed.");this.name="DecorationWorkerDisposedError"}}function LZ(N){return N instanceof Error&&N.name==="DecorationWorkerDisposedError"}function TZ(N={}){let F=(N.createWorker??gH)();if(!F)return null;let A=F,M=N.timeoutMs??kH,D=!1,E="",$=1,y=new Map;function Z(Y){if(D)return;D=!0,A.terminate();for(let[X,Q]of y)y.delete(X),clearTimeout(Q.timeoutId),Q.reject(Y)}return A.addEventListener("message",(Y)=>{let X=Y.data,Q=y.get(X.requestId);if(!Q)return;if(y.delete(X.requestId),clearTimeout(Q.timeoutId),X.kind==="decoration-error"){Q.reject(Error(X.message));return}Q.resolve({roots:X.roots,rulesKey:X.rulesKey})}),A.addEventListener("error",(Y)=>{Z(Error(Y.message||"Decoration worker failed."))}),{dispose(){Z(new wZ)},run(Y){if(D)return Promise.reject(Error("Decoration worker terminated."));let X=$++;if(E!==Y.rulesKey)A.postMessage({kind:"configure-decorations",rules:WZ(Y.rules),rulesKey:Y.rulesKey}),E=Y.rulesKey;let Q={kind:"apply-decorations",requestId:X,roots:Y.roots,rulesKey:Y.rulesKey};return new Promise((S,J)=>{let V=setTimeout(()=>{Z(Error("Decoration worker job timed out."))},M);y.set(X,{reject:J,resolve:S,timeoutId:V}),A.postMessage(Q)})}}}function gH(){if(typeof Worker>"u"||typeof Blob>"u"||typeof URL>"u"||lA.trim().length===0)return null;try{let N=new Blob([lA],{type:"application/javascript"}),F=URL.createObjectURL(N),A=new Worker(F,{type:"module"});return URL.revokeObjectURL(F),A}catch(N){return null}}var IH=220,jZ=[],qN=new Map;function RZ({contentDocument:N,decorations:F,store:A}){let M=aA(null),D=aA(null),E=aA(null),$=CZ(()=>{let q=F?.filter(N4)??jZ;return q.length===0?jZ:q},[F]),y=$.length>0,Z=CZ(()=>OZ($),[$]),[Y,X]=hH(()=>qN),Q=()=>{if(E.current!==null)clearTimeout(E.current),E.current=null;D.current=null},S=F4((q)=>{if(q.rulesKey!==Z||q.roots.length===0)return;X((U)=>{return BZ(A.editor.getState(),U,q.roots)??U})}),J=F4((q,U=!1)=>{if(U)Q();if(!y){X((B)=>B.size===0?B:qN);return}let z=A.editor.getState(),G=_Z(z.documentIndex.document,q);if(G.length===0){X((B)=>B.size===0?B:qN);return}let H=M.current??TZ();if(!H){X((B)=>B.size===0?B:qN);return}M.current=H,H.run({roots:G,rules:$,rulesKey:Z}).then(S).catch((B)=>{if(LZ(B))return;if(M.current===H)M.current=null;X((_)=>_.size===0?_:qN)})}),V=F4(()=>{let q=D.current;if(D.current=null,E.current=null,!q||q.size===0)return;J([...q])}),K=F4((q)=>{if(!y)return;if(!q.documentChanged||q.changedRootIndexes.length===0)return;let U=D.current??new Set;D.current=U;for(let z of q.changedRootIndexes)U.add(z);if(E.current!==null)clearTimeout(E.current);E.current=setTimeout(V,IH)});return dA(()=>{return()=>{Q(),M.current?.dispose(),M.current=null}},[]),dA(()=>{if(y)return;Q(),M.current?.dispose(),M.current=null,X((q)=>q.size===0?q:qN)},[y]),dA(()=>{if(!y)return;J(void 0,!0)},[N,Z,y]),{scheduleDecorationsForTransition:K,textDecorations:Y}}var bZ=`/* Base Documint host and SSR-fallback styles. */
|
|
38
38
|
|
|
39
39
|
.documint {
|
|
40
40
|
display: grid;
|
|
@@ -369,7 +369,7 @@ ${F.text}`:F.text}function kX(N){return N.filter((F)=>F.regions.length>0).map((F
|
|
|
369
369
|
white-space: nowrap;
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
|
-
`;var
|
|
372
|
+
`;var fZ=`/* Leaf overlay styles, ordered outer → inner:
|
|
373
373
|
1. Anchor — viewport positioning + hover bridge
|
|
374
374
|
2. Shell — bordered container (with state and content variants)
|
|
375
375
|
3. Menu — shared dropdown surface (toolbar menus, completion popover)
|
|
@@ -967,7 +967,7 @@ ${F.text}`:F.text}function kX(N){return N.filter((F)=>F.regions.length>0).map((F
|
|
|
967
967
|
font-weight: 500;
|
|
968
968
|
white-space: nowrap;
|
|
969
969
|
}
|
|
970
|
-
`;var
|
|
970
|
+
`;var uZ=`/* Toolbar-specific styles (button, group, divider, and the menu trigger
|
|
971
971
|
shell + chevron). The menu container/item/divider styles themselves
|
|
972
972
|
live one level up in \`overlays/leaves/styles.css\` as \`.documint-leaf-menu*\`
|
|
973
973
|
so they can be shared by the toolbar's nested menu and other surfaces
|
|
@@ -1055,6 +1055,6 @@ ${F.text}`:F.text}function kX(N){return N.filter((F)=>F.regions.length>0).map((F
|
|
|
1055
1055
|
transform: rotate(180deg);
|
|
1056
1056
|
}
|
|
1057
1057
|
}
|
|
1058
|
-
`;var
|
|
1059
|
-
${
|
|
1060
|
-
${
|
|
1058
|
+
`;var vZ=`${bZ}
|
|
1059
|
+
${fZ}
|
|
1060
|
+
${uZ}`;import{jsx as X0,jsxs as A4,Fragment as cH}from"react/jsx-runtime";function kZ({content:N,...F}){let A=KN(null),M=lF(()=>jF(N),[N]);if(!A.current)A.current=Dy(M);return X0(c8,{store:A.current,children:X0(aH,{content:N,...F,contentDocument:M})})}function aH({actions:N,className:F,content:A,keybindings:M,decorations:D,onCommentChanged:E,onContentChanged:$,onUserMentioned:y,presence:Z,storage:Y,theme:X,users:Q,contentDocument:S}){let J=KN(null),V=KN(null),K=KN(null),q=KN(A),U=KN(""),z=x0(),G=e(K0),[H,B]=dH(!1),{theme:_,themeStyles:O}=YZ(X),w=lF(()=>u3(S),[S]),b=lF(()=>new kA(Y,typeof window<"u"?window:null),[Y]),L=xy(b),W=L.resources,v=lF(()=>[...W?.images.values()??[]].some((C)=>C.status==="loading"),[W]);U.current||=w;let g=JZ({renderResources:W,theme:_}),{actions:j,props:P,refs:R,state:f}=g,{autoScrollDuringDrag:m,getScrollTop:x,invalidateViewport:r,observeViewport:i,observeScrollContainer:B0,reconcileEditorState:Q0,resolvePoint:u,scrollTo:l}=j,{layoutWidth:o,scrollContentHeight:a,viewportLayout:V0,viewportHeight:P0,viewportTop:T}=f,{scrollContainer:p}=R,D0=e(ZA),q0=e(JN),Y0=e(D1),E0=Boolean($),R0=e($A,Q),q1=lF(()=>{return E0?R0:void 0},[R0,E0]),P2=r1(({target:C,transition:I,userId:c})=>{let A0=GZ(I,C);if(!A0)return;let S0={...A0,userId:c};y?.(S0)}),W2=ky({completionSources:q1,enabled:E0,onMentionAccepted:P2}),{activeCommentThreadColors:zN,resolvedPresence:GN}=sy({presence:Z,users:Q}),dF=e(XA),c1=()=>z.editor.getState(),{scheduleDecorationsForTransition:M4,textDecorations:G0}=RZ({contentDocument:S,decorations:D,store:z}),O2=rH(N?.selection),gZ=()=>{let C=NF(z.editor.getState());return C?eF(C):""},hZ=r1((C)=>{if(!C)return;if(C.source==="external")return;if(Q0(C.previous,C.next),C.animationsChanged)E4();if(!C.documentChanged)return;if(C.reason==="reconciliation")return;M4(C);let I=S1(C.next),c=u3(I);U.current=c,q.current=c,$?.(c,I)});mZ(()=>{return z.editor.subscribe(hZ)},[z]);let IZ=h(eN),pZ=h(g7),xZ=h(I7),lZ=h(x7),dZ=h(l7),aZ=h(h7),rZ=h(p7),cZ=h(j7),sZ=h(C7),iZ=h(d7),oZ=h(c7),nZ=h(s7),tZ=h(r7),eZ=h(a7),NY=h(i7),D4=(C)=>{E?.(C)},rA=(C)=>{let I=S1(c1()).comments[C],c=I?.comments.at(-1);if(!I||!c)return;D4({kind:"added",comment:c,mentionedUserIds:mA(c.body,R0),thread:I,threadId:I.id})},FY=(C,I,c)=>{let A0=S1(c1()).comments[C],S0=A0?.comments[I];if(!A0||!S0)return;D4({kind:"edited",comment:S0,previousBody:c,mentionedUserIds:mA(S0.body,R0),thread:A0,threadId:A0.id})},cA=(C,I)=>{D4({kind:"deleted",comment:I,thread:C,threadId:C.id})},w2=by({onIdle:()=>{E4()}}),sA=r1((C=V0.peek())=>{if(!C)return;let I=vA(J.current,{paintHeight:C.paintHeight,paintTop:C.paintTop,width:o});if(!I)return;let{context:c,devicePixelRatio:A0,height:S0,width:i1}=I,L2=performance.now();L8(G,C,c,{activeBlockId:D0.block?.blockId??null,activeRegionId:G.selection.focus.regionId,activeThreadIndex:eA??dF,contentPulseTime:w2.resolveAnimationTime(L2),devicePixelRatio:A0,height:S0,liveCommentRanges:q0.liveRanges,normalizedSelection:Y0,presenceActiveThreadColors:zN,now:L2,resources:W,textDecorations:G0,theme:_,width:i1})}),iA=r1((C=V0.peek())=>{if(!C)return;let I=vA(V.current,{paintHeight:C.paintHeight,paintTop:C.paintTop,width:o});if(!I)return;let{context:c,devicePixelRatio:A0,height:S0,width:i1}=I;T8(G,C,c,{devicePixelRatio:A0,height:S0,normalizedSelection:Y0,presence:GN,showCaret:Y0.start.regionId!==Y0.end.regionId||Y0.start.offset!==Y0.end.offset||tA.isVisible(),theme:_,width:i1})}),AY=r1(()=>{let C=V0.get();i(C),sA(C),iA(C)}),{scheduleContentPaint:E4,scheduleFullPaint:MY,scheduleFullRender:$4,scheduleOverlayPaint:oA}=DZ({hasRunningOptionalContentAnimations:()=>{let C=V0.peek();return C?j8(G,C,G0)||j6(C,q0.liveRanges,zN):!1},isActive:w2.isActive,renderContent:sA,renderOverlay:iA,renderViewport:AY}),nA=r1((C)=>{B0(C),$4()}),DY=r1((C)=>{nA(C.currentTarget)}),tA=my({activeAt:w2.activeAt,getScrollTop:x,isEditable:E0,layoutWidth:o,onVisibilityChange:oA,scrollContentHeight:a,scrollTo:l,viewportHeight:P0}),EY=gy(W),aF=ey({enableTouchKeyDown:W2.leaf!==null,inputRef:K,keybindings:M,onActivity:w2.markActive,onBeforeInput:W2.handleBeforeInput,onKeyDown:W2.handleKeyDown,onImagePaste:L.persistImage}),W1=cy({autoScrollDuringDrag:m,canvasRef:J,focusInput:aF.focus,isEditable:E0,onActivity:w2.markActive,resolvePoint:u,storage:b}),eA=W1.leaf?.kind==="thread"?W1.leaf.threadIndex:null,$Y=r1((C)=>{if(!C.viewport||C.viewport.status==="unresolved")return;let I=p.current;if(!I)return;I.scrollTop=C.viewport.scrollTop,nA(I)}),y4=EZ({autoScrollDuringDrag:m,focusInput:aF.focus,isEditable:E0,onActivity:w2.markActive,resolvePoint:u}),s1=y4.handle??EY;UN(()=>{r(),$4()},[G.documentIndex,o,_,W,P0]),UN(()=>{MY()},[Y0.end.offset,Y0.end.regionId,Y0.start.offset,Y0.start.regionId,D0.block?.blockId]),UN(()=>{E4()},[dF,q0.liveRanges,eA,zN,G0]),UN(()=>{oA()},[GN]),UN(()=>{if(!v)return;let C=null,I=window,c=()=>{$4(),C=I.requestAnimationFrame(c)};return C=I.requestAnimationFrame(c),()=>{if(C!==null)I.cancelAnimationFrame(C)}},[v]);let M0=y4.leaf??W2.leaf??W1.leaf??tA.leaf,Z4=(()=>{if(!M0)return null;let C=k1(G,V0.get(),M0.anchor);if(!C)return null;let I=C.top+C.height,c=T+P0;if(I<=T||I>=c)return null;let A0=p.current?.getBoundingClientRect(),S0=typeof window<"u"?window.scrollX:0,i1=typeof window<"u"?window.scrollY:0,L2=M0===W1.leaf;return{anchorHeight:C.height,bridge:L2,left:(A0?.left??0)+S0+(M0.leftOverride??C.left),onPointerEnter:L2?W1.leafHandlers.onPointerEnter:void 0,onPointerLeave:L2?W1.leafHandlers.onPointerLeave:void 0,paddingY:M0.paddingY??0,top:(A0?.top??0)+i1+I-T}})(),yY=Z4?(()=>{if(!M0)return null;switch(M0.kind){case"insertion":return X0(Ly,{onInsert:(C)=>{IZ(C)},onInsertTable:(C)=>{pZ(C)}});case"table":return X0(Ry,{canDeleteColumn:M0.columnCount>1,canDeleteRow:M0.rowCount>1,onDeleteColumn:()=>{xZ()},onDeleteRow:()=>{lZ()},onDeleteTable:()=>{dZ()},onInsertColumn:(C)=>{aZ(C)},onInsertRow:(C)=>{rZ(C)}});case"link":return X0(Cy,{canEdit:E0,onDelete:()=>{cZ(M0)},onSave:(C)=>{sZ(M0,C)},title:M0.title,url:M0.url});case"annotation":{let C=O2.length>0?O2.map((I)=>({icon:I.icon,label:I.label,onClick:()=>{I.onClick(gZ())}})):void 0;return X0(BA,{canEdit:E0,formatting:M0.formatting,link:null,mode:"create",completionSources:R0,onCreateThread:(I)=>{let c=c1(),A0=S1(c).comments.length;if(!iZ(M0.selection,I.trim()))return;y4.promoteLeafToThread(A0,!0),rA(A0)},actions:C})}case"thread":return X0(BA,{animateInitialComment:M0.animateInitialComment,canEdit:E0,link:M0.link,mode:"thread",completionSources:R0,onDeleteComment:(C)=>{let{threadIndex:I}=M0,c=c1(),A0=S1(c).comments[I],S0=A0?.comments[C];if(!oZ(I,C))return;if(A0&&S0)cA(A0,S0)},onDeleteThread:()=>{let{threadIndex:C}=M0,I=c1(),c=S1(I).comments[C];if(!nZ(C))return;if(c)for(let S0 of c.comments)cA(c,S0)},onEditComment:(C,I)=>{let{threadIndex:c}=M0,A0=c1(),S0=S1(A0).comments[c]?.comments[C]?.body;if(!tZ(c,C,I))return;if(S0!==void 0)FY(c,C,S0)},onReply:(C)=>{let{threadIndex:I}=M0;if(!eZ(I,C))return;rA(I)},onToggleResolved:()=>{NY(M0.threadIndex,!M0.resolved)},thread:M0.thread});case"completion":return X0(d3,{...M0})}})():null;UN(()=>{B(!0)},[]),mZ(()=>{if(A===q.current)return;let C=z.editor.getState(),I=KZ(C,FN(S)),c=I.state,A0=I.didReconcile?x():0;z.editor.replace(c,"external"),q.current=A,U.current=w,l(A0)},[w,A,S]);let ZY=F?`documint ${F}`:"documint";return X0(L$,{themeStyles:O,children:A4("section",{className:ZY,style:{...O,height:"100%",minHeight:0},children:[X0("style",{children:vZ}),A4("div",{ref:p,onScroll:DY,className:"documint-scroll-container",style:{height:"100%",minHeight:0},children:[X0("textarea",{...aF.inputHandlers,ref:K,autoCapitalize:"sentences",className:"documint-input",spellCheck:!1,tabIndex:-1,wrap:"off"}),X0(oE,{insetX:_.paddingX,insetY:_.paddingY,onSelect:$Y,presence:GN}),A4("div",{...P.scrollContent,className:"documint-scroll-content",children:[X0("canvas",{...aF.canvasHandlers,...W1.canvasHandlers,"aria-label":"Documint editor",className:"documint-content-canvas",style:{cursor:W1.cursor},ref:J,tabIndex:0}),X0("canvas",{"aria-hidden":"true",className:"documint-overlay-canvas",ref:V}),s1&&A4(cH,{children:[X0("div",{"aria-hidden":"true",className:"documint-resize-handle",style:{left:`${s1.start.left}px`,top:`${s1.start.top}px`},...s1.start.props,children:X0("span",{className:"documint-resize-handle-knob"})}),X0("div",{"aria-hidden":"true",className:"documint-resize-handle",style:{left:`${s1.end.left}px`,top:`${s1.end.top}px`},...s1.end.props,children:X0("span",{className:"documint-resize-handle-knob"})})]}),Z4?X0(r3,{anchor:Z4,children:yY}):null]}),!H?X0("div",{className:"documint-fallback",children:X0(e3,{blocks:S.blocks})}):null]})]})})}function rH(N){if(!N)return[];return"onClick"in N?[N]:N}export{$Z as mintTheme,yZ as midnightTheme,pF as lightTheme,jA as defaultKeybindings,xF as darkTheme,kZ as Documint};
|