documint 0.0.4 → 0.0.6
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/README.md +34 -1
- package/dist/index.d.ts +9 -4
- package/dist/index.js +36 -44
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,36 +1,35 @@
|
|
|
1
|
-
import{useEffect as
|
|
2
|
-
`);return{id:
|
|
3
|
-
`);return{align:$.align??[],id:
|
|
4
|
-
`;case"image":return M.alt??"";case"inlineCode":return M.code;case"link":return
|
|
1
|
+
import{useEffect as z2,useEffectEvent as E2,useLayoutEffect as rG,useMemo as e0,useRef as S1,useState as $9}from"react";function B2($){let M=q0($.children);return{children:$.children,id:K0($.path,"paragraph",M),plainText:M,type:"paragraph"}}function d($){return B2({children:A9(void 0,$.text)})}function x4($){let M=q0($.children);return{children:$.children,depth:$.depth,id:K0($.path,"heading",`${$.depth}:${M}`),plainText:M,type:"heading"}}function $1($){return x4({children:A9(void 0,$.text),depth:$.depth})}function E0($){let M=$.marks??[];return{id:K0($.path,"text",`${$.text}:${M.join(",")}`),marks:M,text:$.text,type:"text"}}function c4($={}){return{id:K0($.path,"break","break"),type:"break"}}function g1($){return{code:$.code,id:K0($.path,"inlineCode",$.code),type:"inlineCode"}}function I1($){return{children:$.children,id:K0($.path,"link",`${$.url}:${q0($.children)}`),title:$.title??null,type:"link",url:$.url}}function H1($){let M=$.alt??null,J=$.width??null;return{alt:M,id:K0($.path,"image",`${$.url}:${J??""}:${M??""}`),title:$.title??null,type:"image",url:$.url,width:J}}function a4($){return{id:K0($.path,"unsupported",$.source),originalType:$.originalType,source:$.source,type:"unsupported"}}function a0($){let M=l1($.children);return{checked:$.checked??null,children:$.children,id:K0($.path,"listItem",M),plainText:M,spread:$.spread??!1,type:"listItem"}}function z1($){let M=$.items.map((J)=>J.plainText).join(`
|
|
2
|
+
`);return{id:K0($.path,"list",`${String($.ordered)}:${M}`),items:$.items,ordered:$.ordered,plainText:M,spread:$.spread??!1,start:$.start??null,type:"list"}}function H0($){let M=l1($.children);return{children:$.children,id:K0($.path,"blockquote",M),plainText:M,type:"blockquote"}}function N8($){return{id:K0($.path,"code",`${$.language??""}:${$.source}`),language:$.language??null,meta:$.meta??null,plainText:$.source,source:$.source,type:"code"}}function M1($){let M=q0($.children);return{children:$.children,id:K0($.path,"tableCell",M),plainText:M}}function p1($){return{cells:$.cells,id:K0($.path,"tableRow",String($.cells.length))}}function E1($){let M=$.rows.map((J)=>J.cells.map((Z)=>Z.plainText).join(" | ")).join(`
|
|
3
|
+
`);return{align:$.align??[],id:K0($.path,"table",M),plainText:M,rows:$.rows,type:"table"}}function s4(){return{id:"",plainText:"",type:"thematicBreak"}}function i4($){return{id:K0($.path,"unsupported",$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"unsupported"}}function q9($){return{attributes:$.attributes,body:$.body,id:K0($.path,"directive",`${$.name}{${$.attributes}}:${$.body}`),name:$.name,plainText:$.body,type:"directive"}}function D0($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&Z.marks.join(",")===J.marks.join(",")){M[M.length-1]=E0({marks:Z.marks,path:Z.id,text:Z.text+J.text});continue}M.push(J)}return M}function T0($,M){return $.type==="heading"?x4({children:M,depth:$.depth}):B2({children:M})}function P0($,M){return a0({checked:$.checked,children:M,spread:$.spread})}function e($,M,J={}){return z1({items:M,ordered:J.ordered??$.ordered,spread:J.spread??$.spread,start:J.start??$.start})}function u0($,M){return E1({align:$.align,rows:M})}function o4($,M){return N8({language:$.language,meta:$.meta,source:M})}function n4($,M){return i4({originalType:$.originalType,source:M})}function A9($,M){return M.length>0?[E0({path:$?`${$}.children.0`:void 0,text:M})]:[]}function K0($,M,J){return $?Z0(M,$,J):""}function d1($,M=[],J){return{blocks:$.map((Z,X)=>F8(Z,X)),comments:M,frontMatter:J}}function W1($,M,J,Z){let X=Z.map((K,q)=>F8(K,M+q)),Y=$.blocks.slice(M+J),Q=Z.length===J?Y:Y.map((K,q)=>F8(K,M+X.length+q));return{blocks:[...$.blocks.slice(0,M),...X,...Q],comments:$.comments,frontMatter:$.frontMatter}}function V9($,M,J,Z){return{blocks:$.blocks,comments:[...$.comments.slice(0,M),...Z,...$.comments.slice(M+J)],frontMatter:$.frontMatter}}function G9($,M,J,Z){if(Z!==void 0)return U9($,Z,M,J);for(let X=0;X<$.blocks.length;X+=1){let Y=U9($,X,M,J);if(Y)return Y}return null}function U9($,M,J,Z){let X=$.blocks[M];if(!X)return null;let Y=N9(X,J,Z);return Y?W1($,M,1,[Y]):null}function N9($,M,J){if($.id===M)return J($);switch($.type){case"blockquote":{let Z=_8($.children,M,J);return Z?H0({children:Z}):null}case"listItem":{let Z=_8($.children,M,J);return Z?P0($,Z):null}case"list":{let Z=_8($.items,M,J);return Z?e($,Z):null}default:return null}}function _8($,M,J){let Z=!1,X=$.map((Y)=>{let Q=N9(Y,M,J);if(!Q)return Y;return Z=!0,Q});return Z?X:null}function q0($){return $.map((M)=>{switch(M.type){case"break":return`
|
|
4
|
+
`;case"image":return M.alt??"";case"inlineCode":return M.code;case"link":return q0(M.children);case"text":return M.text;case"unsupported":return M.source}}).join("")}function l1($){return $.map((M)=>{switch(M.type){case"blockquote":case"listItem":return l1(M.children);case"code":return M.source;case"directive":return M.body;case"heading":case"paragraph":return q0(M.children);case"list":return M.items.map((J)=>J.plainText).join(`
|
|
5
5
|
`);case"table":return M.rows.map((J)=>J.cells.map((Z)=>Z.plainText).join(" | ")).join(`
|
|
6
6
|
`);case"thematicBreak":return"";case"unsupported":return M.source}}).join(`
|
|
7
|
-
`).trim()}function
|
|
8
|
-
`);return{id:
|
|
9
|
-
`);return{align:$.align,id:Y0("table",M,Z),plainText:Z,rows:J,type:"table"}}case"thematicBreak":return{id:Y0("thematicBreak",M,"thematic-break"),plainText:"",type:"thematicBreak"};case"unsupported":return{id:Y0("unsupported",M,$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"unsupported"}}}function EZ($,M){return{cells:$.cells.map((J,Z)=>{let X=J.children.map((Y,Q)=>Z5(Y,`${M}.cells.${Z}.children.${Q}`)),D=N0(X);return{children:X,id:Y0("tableCell",`${M}.cells.${Z}`,D),plainText:D}}),id:Y0("tableRow",M,String($.cells.length))}}function Z5($,M){switch($.type){case"break":return{id:Y0("break",M,"break"),type:"break"};case"image":return{alt:$.alt,id:Y0("image",M,`${$.url}:${$.width??""}:${$.alt??""}`),title:$.title,type:"image",url:$.url,width:$.width};case"inlineCode":return{code:$.code,id:Y0("inlineCode",M,$.code),type:"inlineCode"};case"link":{let J=$.children.map((X,D)=>Z5(X,`${M}.children.${D}`)),Z=N0(J);return{children:J,id:Y0("link",M,`${$.url}:${Z}`),title:$.title,type:"link",url:$.url}}case"text":return{id:Y0("text",M,`${$.text}:${$.marks.join(",")}`),marks:$.marks,text:$.text,type:"text"};case"unsupported":return{id:Y0("unsupported",M,$.source),originalType:$.originalType,source:$.source,type:"unsupported"}}}function z2($){return $.map((M)=>{switch(M.type){case"blockquote":return{...M,children:z2(M.children)};case"heading":case"paragraph":return C0(M,W8(M.children));case"list":return{...M,items:M.items.map((J)=>({...J,children:z2(J.children)}))};case"listItem":return{...M,children:z2(M.children)};case"table":return S0(M,M.rows.map((J)=>({...J,cells:J.cells.map((Z)=>({...Z,children:W8(Z.children)}))})));default:return M}})}function W8($){let M=[...$];for(let J=M.length-1;J>=0;J-=1){let Z=M[J];if(Z.type==="text"){let X=Z.text.replace(/[ \t]+$/u,"");if(X.length===Z.text.length)return M;if(X.length===0){M.splice(J,1);continue}return M[J]={...Z,text:X},M}if(Z.type==="link"){let X=W8(Z.children);if(X.length===Z.children.length&&X.every((D,Y)=>D===Z.children[Y]))return M;if(X.length===0){M.splice(J,1);continue}return M[J]={...Z,children:X},M}return M}return M}function Y0($,M,J){let Z=2166136261;for(let X of`${$}:${M}:${J}`)Z^=X.charCodeAt(0),Z=Math.imul(Z,16777619);return`${$}-${(Z>>>0).toString(36)}`}function W2($,M){E8($.blocks,M,f$(),m$())}function k$($,M){E8($,M,f$(),m$())}function E8($,M,J,Z){for(let[X,D]of $.entries()){if(J.stopped)return;let Y=`${Z.pathPrefix}.${X}`,Q={blockAncestors:Z.blockAncestors,depth:Z.depth,parentBlock:Z.parentBlock,path:Y},K=M.enterBlock?.(D,Q);if(p1(K,J))return;if(K!=="skip")switch(D.type){case"list":R$(D.items,D,M,J,Z,Y);break;case"blockquote":case"listItem":R$(D.children,D,M,J,Z,Y);break;case"heading":case"paragraph":T8(D.children,M,J,{block:D,blockAncestors:[...Z.blockAncestors,D],inlineAncestors:[],parentInline:null,pathPrefix:`${Y}.children`});break;case"table":yZ(D,M,J,{blockAncestors:[...Z.blockAncestors,D],pathPrefix:Y});break;case"code":case"directive":case"thematicBreak":case"unsupported":break}if(J.stopped)return;if(p1(M.leaveBlock?.(D,Q),J))return}}function T8($,M,J,Z){for(let[X,D]of $.entries()){if(J.stopped)return;let Y=`${Z.pathPrefix}.${X}`,Q={block:Z.block,blockAncestors:Z.blockAncestors,inlineAncestors:Z.inlineAncestors,parentInline:Z.parentInline,path:Y},K=M.enterInline?.(D,Q);if(p1(K,J))return;if(K!=="skip"){if(D.type==="link")TZ(D.children,D,M,J,Z,Y)}if(J.stopped)return;if(p1(M.leaveInline?.(D,Q),J))return}}function f$(){return{stopped:!1}}function m$(){return{blockAncestors:[],depth:0,parentBlock:null,pathPrefix:"root"}}function R$($,M,J,Z,X,D){E8($,J,Z,{blockAncestors:[...X.blockAncestors,M],depth:X.depth+1,parentBlock:M,pathPrefix:`${D}.children`})}function TZ($,M,J,Z,X,D){T8($,J,Z,{block:X.block,blockAncestors:X.blockAncestors,inlineAncestors:[...X.inlineAncestors,M],parentInline:M,pathPrefix:`${D}.children`})}function yZ($,M,J,Z){for(let[X,D]of $.rows.entries())for(let[Y,Q]of D.cells.entries()){if(J.stopped)return;let K=`${Z.pathPrefix}.rows.${X}.cells.${Y}`,q={blockAncestors:Z.blockAncestors,cellIndex:Y,path:K,row:D,rowIndex:X,table:$},U=M.enterTableCell?.(Q,q);if(p1(U,J))return;if(U!=="skip")T8(Q.children,M,J,{block:$,blockAncestors:Z.blockAncestors,inlineAncestors:[],parentInline:null,pathPrefix:`${K}.children`});if(J.stopped)return;if(p1(M.leaveTableCell?.(Q,q),J))return}}function p1($,M){if($!=="stop")return!1;return M.stopped=!0,!0}var y8="text";function w8($){return $==="text"||$==="code"||$==="tableCell"}function O8($){return $===y8?void 0:$}function u$($){switch($){case"heading":case"paragraph":return"text";case"code":return"code";default:return null}}function X5($){let M=[];return W2($,{enterBlock(J){switch(J.type){case"heading":case"paragraph":M.push({containerKind:"text",containerOrdinal:M.length,id:J.id,text:N0(J.children)});break;case"code":M.push({containerKind:"code",containerOrdinal:M.length,id:J.id,text:J.source});break}},enterTableCell(J){M.push({containerKind:"tableCell",containerOrdinal:M.length,id:J.id,text:N0(J.children)})}}),M}function C8($,M,J){return{prefix:$.slice(Math.max(0,M-S$),M),suffix:$.slice(J,Math.min($.length,J+S$))}}function E2($,M,J){let Z=j0(M,0,$.text.length),X=j0(J,Z,$.text.length),{prefix:D,suffix:Y}=C8($.text,Z,X);return{kind:O8($.containerKind),prefix:D||void 0,suffix:Y||void 0}}function T2($,M,J){let Z=j0(M,0,$.text.length),X=j0(J,Z,$.text.length);return $.text.slice(Z,X)}function u0($,M){if(M.length===0)return[];let J=[],Z=0;while(Z<=$.length){let X=$.indexOf(M,Z);if(X===-1)break;J.push(X),Z=X+Math.max(1,M.length)}return J}function l1($,M,J){if(M.length===0||J.length===0)return[];let Z=[];for(let X of u0($,M)){let D=X+M.length,Y=$.indexOf(J,D);if(Y!==-1)Z.push({startOffset:D,endOffset:Y})}return Z}function j8($,M,J){if(!M)return!1;return $.slice(Math.max(0,J-M.length),J)===M}function L8($,M,J){if(!M)return!1;return $.slice(J,J+M.length)===M}var S$=24;function j0($,M,J){return Math.min(Math.max($,M),J)}var v$=48,h$=64,wZ=32;function y2($,M){let J=$.anchor.kind??y8,Z=X5(M).filter((Y)=>Y.containerKind===J),X=OZ($,Z);if(X.length>0)return g$($,X,null);let D=CZ($,Z);if(D.length>0)return g$($,D,"repaired");return{match:null,repair:null,status:"stale"}}function OZ($,M){let J=[],Z=$.quote;if(Z.length===0)return J;for(let X of M)for(let D of u0(X.text,Z))J.push({container:X,endOffset:D+Z.length,score:RZ($,X,D),startOffset:D});return J.sort((X,D)=>D.score-X.score),J}function CZ($,M){let J=[];for(let Z of M)J.push(...jZ($,Z));return J.sort((Z,X)=>X.score-Z.score),J}function jZ($,M){let J=[],Z=$.quote.length,X=M.text,D=$.anchor.prefix??"",Y=$.anchor.suffix??"";if(D.length>0&&Y.length>0){for(let Q of l1(X,D,Y))J.push({container:M,endOffset:Q.endOffset,score:R8($,M,Q.startOffset,Q.endOffset,Z),startOffset:Q.startOffset});return J}if(D.length>0){for(let Q of u0(X,D)){let K=Q+D.length,q=j0(K+Z,K,X.length);J.push({container:M,endOffset:q,score:R8($,M,K,q,Z),startOffset:K})}return J}if(Y.length>0)for(let Q of u0(X,Y)){let K=Q,q=j0(K-Z,0,K);J.push({container:M,endOffset:K,score:R8($,M,q,K,Z),startOffset:q})}return J}function g$($,M,J){let[Z,X]=M;if(!Z)return{match:null,repair:null,status:"stale"};if(X&&Z.score===X.score)return{match:null,repair:null,status:"ambiguous"};let D=E2(Z.container,Z.startOffset,Z.endOffset),Y=T2(Z.container,Z.startOffset,Z.endOffset),Q=J??(Y===$.quote&&(D.prefix??"")===($.anchor.prefix??"")&&(D.suffix??"")===($.anchor.suffix??"")?"matched":"repaired");return{match:LZ(Z.container,Z.startOffset,Z.endOffset),repair:{anchor:D,quote:Y},status:Q}}function LZ($,M,J){return{containerId:$.id,containerKind:$.containerKind,containerOrdinal:$.containerOrdinal,endOffset:J,startOffset:M}}function RZ($,M,J){let Z=0;if(j8(M.text,$.anchor.prefix,J))Z+=v$;if(L8(M.text,$.anchor.suffix,J+$.quote.length))Z+=v$;return Z}function R8($,M,J,Z,X){let D=0;if(j8(M.text,$.anchor.prefix,J))D+=h$;if(L8(M.text,$.anchor.suffix,Z))D+=h$;if(D+=Math.max(0,wZ-Math.abs(X-(Z-J))),$.quote.length>0){let Y=M.text.slice(J,Z);if(Y.length>0)D+=kZ($.quote,Y),D+=fZ($.quote,Y)}return D}function kZ($,M){let J=0;while(J<$.length&&J<M.length&&$[J]===M[J])J+=1;return J}function fZ($,M){let J=0;while(J<$.length&&J<M.length&&$[$.length-1-J]===M[M.length-1-J])J+=1;return J}function k8($){if(!$||typeof $!=="object"||Array.isArray($))return null;let M=$,J=SZ(M.anchor),Z=typeof M.quote==="string"?M.quote:null,X=Array.isArray(M.comments)?M.comments.flatMap((D)=>{let Y=mZ(D);return Y?[Y]:[]}):[];if(!J||!Z||X.length===0)return null;return{quote:Z,anchor:J,comments:X,resolvedAt:typeof M.resolvedAt==="string"?M.resolvedAt:void 0}}function mZ($){if(!$||typeof $!=="object"||Array.isArray($))return null;let M=$;if(typeof M.body!=="string"||typeof M.updatedAt!=="string")return null;return{body:M.body,updatedAt:M.updatedAt}}function SZ($){if(!$||typeof $!=="object"||Array.isArray($))return null;let{kind:M,prefix:J,suffix:Z}=$;if("kind"in $&&!w8(M)||"prefix"in $&&typeof J!=="string"||"suffix"in $&&typeof Z!=="string")return null;return{kind:w8(M)?O8(M):void 0,prefix:typeof J==="string"?J:void 0,suffix:typeof Z==="string"?Z:void 0}}function f8($){let M=$.createdAt??new Date().toISOString();return{comments:[I$({body:$.body,updatedAt:M})],quote:$.quote,anchor:$.anchor}}function m8($,M){let J=I$(M);return{...$,comments:[...$.comments,J]}}function S8($,M,J,Z=new Date().toISOString()){let X=J.trim();if(X.length===0)return $;let D=!1,Y=$.comments.map((Q,K)=>{if(K!==M||Q.body===X)return Q;return D=!0,{...Q,body:X,updatedAt:Z}});if(!D)return $;return{...$,comments:Y}}function u8($,M){let J=$.comments.filter((Z,X)=>X!==M);if(J.length===$.comments.length)return $;if(J.length===0)return null;return{...$,comments:J}}function v8($,M,J=new Date().toISOString()){if(Z1($)===M)return $;return{...$,resolvedAt:M?J:void 0}}function Z1($){return $.resolvedAt!=null}function h8($){return $.filter((M)=>Z1(M)).length}function g8($){if($.comments.length===0)return null;return $.comments.reduce((M,J)=>J.updatedAt>M?J.updatedAt:M,$.comments[0].updatedAt)}function I$($){let M=$.updatedAt??new Date().toISOString();return{body:$.body,updatedAt:M}}function p$($){let M=new Set;return W2($,{enterInline(J){if(J.type==="image")M.add(J.url)}}),[...M]}function r1($,M){let J=null;return uZ($,{enterBlock(Z){if(Z.id===M)return J=Z,"stop"}}),J}function uZ($,M){if(Array.isArray($)){k$($,M);return}W2($,M)}function W1(){return{graphemeWidths:new Map,lineBoundaries:new Map,measuredContainerHeights:new Map,measuredLines:new Map,preparedText:new Map,viewportPlans:new WeakMap}}function l$($,M,J){return w2($.preparedText,M,J,256)}function r$($,M,J){return w2($.measuredLines,M,J,512)}function c$($,M,J){return w2($.lineBoundaries,M,J,1024)}function x$($,M,J){return w2($.measuredContainerHeights,M,J,1024)}function d$($,M){let J=$.graphemeWidths.get(M);if(J)return J;let Z=new Map;return w2($.graphemeWidths,M,Z,64),Z}function a$($,M,J){return $.viewportPlans.get(M)?.get(J)??null}function i$($,M,J,Z){let X=$.viewportPlans.get(M)??new Map;return X.set(J,Z),$.viewportPlans.set(M,X),Z}function w2($,M,J,Z){if($.has(M))$.delete(M);if($.set(M,J),$.size>Z){let X=$.keys().next().value;if(X!==void 0)$.delete(X)}return J}var vZ=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","ON","ON","ET","ET","ET","ON","ON","ON","ON","ON","ON","CS","ON","CS","ON","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","ON","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","ON","ET","ET","ET","ET","ON","ON","ON","ON","L","ON","ON","ON","ON","ON","ET","ET","EN","EN","ON","L","ON","ON","ON","EN","L","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L"],hZ=["AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","CS","AL","ON","ON","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AN","AN","AN","AN","AN","AN","AN","AN","AN","AN","ET","AN","AN","AL","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","ON","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL"];function gZ($){if($<=255)return vZ[$];if(1424<=$&&$<=1524)return"R";if(1536<=$&&$<=1791)return hZ[$&255];if(1792<=$&&$<=2220)return"AL";return"L"}function IZ($){let M=$.length;if(M===0)return null;let J=Array(M),Z=0;for(let q=0;q<M;q++){let U=gZ($.charCodeAt(q));if(U==="R"||U==="AL"||U==="AN")Z++;J[q]=U}if(Z===0)return null;let X=M/Z<0.3?0:1,D=new Int8Array(M);for(let q=0;q<M;q++)D[q]=X;let Y=X&1?"R":"L",Q=Y,K=Q;for(let q=0;q<M;q++)if(J[q]==="NSM")J[q]=K;else K=J[q];K=Q;for(let q=0;q<M;q++){let U=J[q];if(U==="EN")J[q]=K==="AL"?"AN":"EN";else if(U==="R"||U==="L"||U==="AL")K=U}for(let q=0;q<M;q++)if(J[q]==="AL")J[q]="R";for(let q=1;q<M-1;q++){if(J[q]==="ES"&&J[q-1]==="EN"&&J[q+1]==="EN")J[q]="EN";if(J[q]==="CS"&&(J[q-1]==="EN"||J[q-1]==="AN")&&J[q+1]===J[q-1])J[q]=J[q-1]}for(let q=0;q<M;q++){if(J[q]!=="EN")continue;let U;for(U=q-1;U>=0&&J[U]==="ET";U--)J[U]="EN";for(U=q+1;U<M&&J[U]==="ET";U++)J[U]="EN"}for(let q=0;q<M;q++){let U=J[q];if(U==="WS"||U==="ES"||U==="ET"||U==="CS")J[q]="ON"}K=Q;for(let q=0;q<M;q++){let U=J[q];if(U==="EN")J[q]=K==="L"?"L":"EN";else if(U==="R"||U==="L")K=U}for(let q=0;q<M;q++){if(J[q]!=="ON")continue;let U=q+1;while(U<M&&J[U]==="ON")U++;let N=q>0?J[q-1]:Q,A=U<M?J[U]:Q,V=N!=="L"?"R":"L";if(V===(A!=="L"?"R":"L"))for(let G=q;G<U;G++)J[G]=V;q=U-1}for(let q=0;q<M;q++)if(J[q]==="ON")J[q]=Y;for(let q=0;q<M;q++){let U=J[q];if((D[q]&1)===0){if(U==="R")D[q]++;else if(U==="AN"||U==="EN")D[q]+=2}else if(U==="L"||U==="AN"||U==="EN")D[q]++}return D}function s$($,M){let J=IZ($);if(J===null)return null;let Z=new Int8Array(M.length);for(let X=0;X<M.length;X++)Z[X]=J[M[X]];return Z}var pZ=/[ \t\n\r\f]+/g,lZ=/[\t\n\r\f]| {2,}|^ | $/;function rZ($){let M=$??"normal";return M==="pre-wrap"?{mode:M,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:M,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function cZ($){if(!lZ.test($))return $;let M=$.replace(pZ," ");if(M.charCodeAt(0)===32)M=M.slice(1);if(M.length>0&&M.charCodeAt(M.length-1)===32)M=M.slice(0,-1);return M}function xZ($){if(!/[\r\f]/.test($))return $.replace(/\r\n/g,`
|
|
7
|
+
`).trim()}function F8($,M){return t4($,`root.${M}`)}function t4($,M){switch($.type){case"blockquote":{let J=$.children.map((X,Y)=>t4(X,`${M}.children.${Y}`)),Z=l1(J);return{children:J,id:Z0("blockquote",M,Z),plainText:Z,type:"blockquote"}}case"code":return{id:Z0("code",M,`${$.language??""}:${$.source}`),language:$.language,meta:$.meta,plainText:$.source,source:$.source,type:"code"};case"directive":return{attributes:$.attributes,body:$.body,id:Z0("directive",M,`${$.name}{${$.attributes}}:${$.body}`),name:$.name,plainText:$.body,type:"directive"};case"heading":{let J=$.children.map((X,Y)=>e4(X,`${M}.children.${Y}`)),Z=q0(J);return{children:J,depth:$.depth,id:Z0("heading",M,`${$.depth}:${Z}`),plainText:Z,type:"heading"}}case"list":{let J=$.items.map((X,Y)=>t4(X,`${M}.children.${Y}`)),Z=J.map((X)=>X.plainText).join(`
|
|
8
|
+
`);return{id:Z0("list",M,`${String($.ordered)}:${Z}`),items:J,ordered:$.ordered,plainText:Z,spread:$.spread,start:$.start,type:"list"}}case"listItem":{let J=$.children.map((X,Y)=>t4(X,`${M}.children.${Y}`)),Z=l1(J);return{checked:$.checked,children:J,id:Z0("listItem",M,Z),plainText:Z,spread:$.spread,type:"listItem"}}case"paragraph":{let J=$.children.map((X,Y)=>e4(X,`${M}.children.${Y}`)),Z=q0(J);return{children:J,id:Z0("paragraph",M,Z),plainText:Z,type:"paragraph"}}case"table":{let J=$.rows.map((X,Y)=>dZ(X,`${M}.rows.${Y}`)),Z=J.map((X)=>X.cells.map((Y)=>Y.plainText).join(" | ")).join(`
|
|
9
|
+
`);return{align:$.align,id:Z0("table",M,Z),plainText:Z,rows:J,type:"table"}}case"thematicBreak":return{id:Z0("thematicBreak",M,"thematic-break"),plainText:"",type:"thematicBreak"};case"unsupported":return{id:Z0("unsupported",M,$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"unsupported"}}}function dZ($,M){return{cells:$.cells.map((J,Z)=>{let X=J.children.map((Q,K)=>e4(Q,`${M}.cells.${Z}.children.${K}`)),Y=q0(X);return{children:X,id:Z0("tableCell",`${M}.cells.${Z}`,Y),plainText:Y}}),id:Z0("tableRow",M,String($.cells.length))}}function e4($,M){switch($.type){case"break":return{id:Z0("break",M,"break"),type:"break"};case"image":return{alt:$.alt,id:Z0("image",M,`${$.url}:${$.width??""}:${$.alt??""}`),title:$.title,type:"image",url:$.url,width:$.width};case"inlineCode":return{code:$.code,id:Z0("inlineCode",M,$.code),type:"inlineCode"};case"link":{let J=$.children.map((X,Y)=>e4(X,`${M}.children.${Y}`)),Z=q0(J);return{children:J,id:Z0("link",M,`${$.url}:${Z}`),title:$.title,type:"link",url:$.url}}case"text":return{id:Z0("text",M,`${$.text}:${$.marks.join(",")}`),marks:$.marks,text:$.text,type:"text"};case"unsupported":return{id:Z0("unsupported",M,$.source),originalType:$.originalType,source:$.source,type:"unsupported"}}}function P2($){return $.map((M)=>{switch(M.type){case"blockquote":return{...M,children:P2(M.children)};case"heading":case"paragraph":return T0(M,H8(M.children));case"list":return{...M,items:M.items.map((J)=>({...J,children:P2(J.children)}))};case"listItem":return{...M,children:P2(M.children)};case"table":return u0(M,M.rows.map((J)=>({...J,cells:J.cells.map((Z)=>({...Z,children:H8(Z.children)}))})));default:return M}})}function H8($){let M=[...$];for(let J=M.length-1;J>=0;J-=1){let Z=M[J];if(Z.type==="text"){let X=Z.text.replace(/[ \t]+$/u,"");if(X.length===Z.text.length)return M;if(X.length===0){M.splice(J,1);continue}return M[J]={...Z,text:X},M}if(Z.type==="link"){let X=H8(Z.children);if(X.length===Z.children.length&&X.every((Y,Q)=>Y===Z.children[Q]))return M;if(X.length===0){M.splice(J,1);continue}return M[J]={...Z,children:X},M}return M}return M}function Z0($,M,J){let Z=2166136261;for(let X of`${$}:${M}:${J}`)Z^=X.charCodeAt(0),Z=Math.imul(Z,16777619);return`${$}-${(Z>>>0).toString(36)}`}function z8($,M){E8($.blocks,M,F9(),H9())}function rZ($,M){E8($,M,F9(),H9())}function x1($,M){let J=null,Z={enterBlock(X){if(X.id===M)return J=X,"stop"}};if(Array.isArray($))rZ($,Z);else z8($,Z);return J}function E8($,M,J,Z){for(let[X,Y]of $.entries()){if(J.stopped)return;let Q=`${Z.pathPrefix}.${X}`,K={blockAncestors:Z.blockAncestors,depth:Z.depth,parentBlock:Z.parentBlock,path:Q},q=M.enterBlock?.(Y,K);if(r1(q,J))return;if(q!=="skip")switch(Y.type){case"list":_9(Y.items,Y,M,J,Z,Q);break;case"blockquote":case"listItem":_9(Y.children,Y,M,J,Z,Q);break;case"heading":case"paragraph":W8(Y.children,M,J,{block:Y,blockAncestors:[...Z.blockAncestors,Y],inlineAncestors:[],parentInline:null,pathPrefix:`${Q}.children`});break;case"table":cZ(Y,M,J,{blockAncestors:[...Z.blockAncestors,Y],pathPrefix:Q});break;case"code":case"directive":case"thematicBreak":case"unsupported":break}if(J.stopped)return;if(r1(M.leaveBlock?.(Y,K),J))return}}function W8($,M,J,Z){for(let[X,Y]of $.entries()){if(J.stopped)return;let Q=`${Z.pathPrefix}.${X}`,K={block:Z.block,blockAncestors:Z.blockAncestors,inlineAncestors:Z.inlineAncestors,parentInline:Z.parentInline,path:Q},q=M.enterInline?.(Y,K);if(r1(q,J))return;if(q!=="skip"){if(Y.type==="link")xZ(Y.children,Y,M,J,Z,Q)}if(J.stopped)return;if(r1(M.leaveInline?.(Y,K),J))return}}function F9(){return{stopped:!1}}function H9(){return{blockAncestors:[],depth:0,parentBlock:null,pathPrefix:"root"}}function _9($,M,J,Z,X,Y){E8($,J,Z,{blockAncestors:[...X.blockAncestors,M],depth:X.depth+1,parentBlock:M,pathPrefix:`${Y}.children`})}function xZ($,M,J,Z,X,Y){W8($,J,Z,{block:X.block,blockAncestors:X.blockAncestors,inlineAncestors:[...X.inlineAncestors,M],parentInline:M,pathPrefix:`${Y}.children`})}function cZ($,M,J,Z){for(let[X,Y]of $.rows.entries())for(let[Q,K]of Y.cells.entries()){if(J.stopped)return;let q=`${Z.pathPrefix}.rows.${X}.cells.${Q}`,D={blockAncestors:Z.blockAncestors,cellIndex:Q,path:q,row:Y,rowIndex:X,table:$},A=M.enterTableCell?.(K,D);if(r1(A,J))return;if(A!=="skip")W8(K.children,M,J,{block:$,blockAncestors:Z.blockAncestors,inlineAncestors:[],parentInline:null,pathPrefix:`${q}.children`});if(J.stopped)return;if(r1(M.leaveTableCell?.(K,D),J))return}}function r1($,M){if($!=="stop")return!1;return M.stopped=!0,!0}var B8="text";function P8($){return $==="text"||$==="code"||$==="tableCell"}function y8($){return $===B8?void 0:$}function E9($){switch($){case"heading":case"paragraph":return"text";case"code":return"code";default:return null}}function $5($){let M=[];return z8($,{enterBlock(J){switch(J.type){case"heading":case"paragraph":M.push({containerKind:"text",containerOrdinal:M.length,id:J.id,text:q0(J.children)});break;case"code":M.push({containerKind:"code",containerOrdinal:M.length,id:J.id,text:J.source});break}},enterTableCell(J){M.push({containerKind:"tableCell",containerOrdinal:M.length,id:J.id,text:q0(J.children)})}}),M}function b8($,M,J){return{prefix:$.slice(Math.max(0,M-z9),M),suffix:$.slice(J,Math.min($.length,J+z9))}}function y2($,M,J){let Z=O0(M,0,$.text.length),X=O0(J,Z,$.text.length),{prefix:Y,suffix:Q}=b8($.text,Z,X);return{kind:y8($.containerKind),prefix:Y||void 0,suffix:Q||void 0}}function b2($,M,J){let Z=O0(M,0,$.text.length),X=O0(J,Z,$.text.length);return $.text.slice(Z,X)}function v0($,M){if(M.length===0)return[];let J=[],Z=0;while(Z<=$.length){let X=$.indexOf(M,Z);if(X===-1)break;J.push(X),Z=X+Math.max(1,M.length)}return J}function c1($,M,J){if(M.length===0||J.length===0)return[];let Z=[];for(let X of v0($,M)){let Y=X+M.length,Q=$.indexOf(J,Y);if(Q!==-1)Z.push({startOffset:Y,endOffset:Q})}return Z}function w8($,M,J){if(!M)return!1;return $.slice(Math.max(0,J-M.length),J)===M}function T8($,M,J){if(!M)return!1;return $.slice(J,J+M.length)===M}var z9=24;function O0($,M,J){return Math.min(Math.max($,M),J)}var W9=48,B9=64,aZ=32;function w2($,M){let J=$.anchor.kind??B8,Z=$5(M).filter((Q)=>Q.containerKind===J),X=sZ($,Z);if(X.length>0)return P9($,X,null);let Y=iZ($,Z);if(Y.length>0)return P9($,Y,"repaired");return{match:null,repair:null,status:"stale"}}function sZ($,M){let J=[],Z=$.quote;if(Z.length===0)return J;for(let X of M)for(let Y of v0(X.text,Z))J.push({container:X,endOffset:Y+Z.length,score:tZ($,X,Y),startOffset:Y});return J.sort((X,Y)=>Y.score-X.score),J}function iZ($,M){let J=[];for(let Z of M)J.push(...oZ($,Z));return J.sort((Z,X)=>X.score-Z.score),J}function oZ($,M){let J=[],Z=$.quote.length,X=M.text,Y=$.anchor.prefix??"",Q=$.anchor.suffix??"";if(Y.length>0&&Q.length>0){for(let K of c1(X,Y,Q))J.push({container:M,endOffset:K.endOffset,score:O8($,M,K.startOffset,K.endOffset,Z),startOffset:K.startOffset});return J}if(Y.length>0){for(let K of v0(X,Y)){let q=K+Y.length,D=O0(q+Z,q,X.length);J.push({container:M,endOffset:D,score:O8($,M,q,D,Z),startOffset:q})}return J}if(Q.length>0)for(let K of v0(X,Q)){let q=K,D=O0(q-Z,0,q);J.push({container:M,endOffset:q,score:O8($,M,D,q,Z),startOffset:D})}return J}function P9($,M,J){let[Z,X]=M;if(!Z)return{match:null,repair:null,status:"stale"};if(X&&Z.score===X.score)return{match:null,repair:null,status:"ambiguous"};let Y=y2(Z.container,Z.startOffset,Z.endOffset),Q=b2(Z.container,Z.startOffset,Z.endOffset),K=J??(Q===$.quote&&(Y.prefix??"")===($.anchor.prefix??"")&&(Y.suffix??"")===($.anchor.suffix??"")?"matched":"repaired");return{match:nZ(Z.container,Z.startOffset,Z.endOffset),repair:{anchor:Y,quote:Q},status:K}}function nZ($,M,J){return{containerId:$.id,containerKind:$.containerKind,containerOrdinal:$.containerOrdinal,endOffset:J,startOffset:M}}function tZ($,M,J){let Z=0;if(w8(M.text,$.anchor.prefix,J))Z+=W9;if(T8(M.text,$.anchor.suffix,J+$.quote.length))Z+=W9;return Z}function O8($,M,J,Z,X){let Y=0;if(w8(M.text,$.anchor.prefix,J))Y+=B9;if(T8(M.text,$.anchor.suffix,Z))Y+=B9;if(Y+=Math.max(0,aZ-Math.abs(X-(Z-J))),$.quote.length>0){let Q=M.text.slice(J,Z);if(Q.length>0)Y+=eZ($.quote,Q),Y+=$X($.quote,Q)}return Y}function eZ($,M){let J=0;while(J<$.length&&J<M.length&&$[J]===M[J])J+=1;return J}function $X($,M){let J=0;while(J<$.length&&J<M.length&&$[$.length-1-J]===M[M.length-1-J])J+=1;return J}function j8($){if(!$||typeof $!=="object"||Array.isArray($))return null;let M=$,J=JX(M.anchor),Z=typeof M.quote==="string"?M.quote:null,X=Array.isArray(M.comments)?M.comments.flatMap((Y)=>{let Q=MX(Y);return Q?[Q]:[]}):[];if(!J||!Z||X.length===0)return null;return{quote:Z,anchor:J,comments:X,resolvedAt:typeof M.resolvedAt==="string"?M.resolvedAt:void 0}}function MX($){if(!$||typeof $!=="object"||Array.isArray($))return null;let M=$;if(typeof M.body!=="string"||typeof M.updatedAt!=="string")return null;return{body:M.body,updatedAt:M.updatedAt}}function JX($){if(!$||typeof $!=="object"||Array.isArray($))return null;let{kind:M,prefix:J,suffix:Z}=$;if("kind"in $&&!P8(M)||"prefix"in $&&typeof J!=="string"||"suffix"in $&&typeof Z!=="string")return null;return{kind:P8(M)?y8(M):void 0,prefix:typeof J==="string"?J:void 0,suffix:typeof Z==="string"?Z:void 0}}function L8($){let M=$.createdAt??new Date().toISOString();return{comments:[y9({body:$.body,updatedAt:M})],quote:$.quote,anchor:$.anchor}}function C8($,M){let J=y9(M);return{...$,comments:[...$.comments,J]}}function R8($,M,J,Z=new Date().toISOString()){let X=J.trim();if(X.length===0)return $;let Y=!1,Q=$.comments.map((K,q)=>{if(q!==M||K.body===X)return K;return Y=!0,{...K,body:X,updatedAt:Z}});if(!Y)return $;return{...$,comments:Q}}function f8($,M){let J=$.comments.filter((Z,X)=>X!==M);if(J.length===$.comments.length)return $;if(J.length===0)return null;return{...$,comments:J}}function m8($,M,J=new Date().toISOString()){if(J1($)===M)return $;return{...$,resolvedAt:M?J:void 0}}function J1($){return $.resolvedAt!=null}function S8($){return $.filter((M)=>J1(M)).length}function k8($){if($.comments.length===0)return null;return $.comments.reduce((M,J)=>J.updatedAt>M?J.updatedAt:M,$.comments[0].updatedAt)}function y9($){let M=$.updatedAt??new Date().toISOString();return{body:$.body,updatedAt:M}}var ZX=240,XX=0.5625,YX=120,b9=48;function M5($,M,J){let Z=$.image?M.images.get($.image.url)??null:null,X=$.image?.width??null,Y=Math.min(J,X??ZX),Q=Math.max(YX,Math.round(Y*XX));if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return{height:Q,width:Y};let K=Math.min(J,X??Z.intrinsicWidth),q=Math.min(1,K/Z.intrinsicWidth);return{height:Math.max(b9,Math.round(Z.intrinsicHeight*q)),width:Math.max(b9,Math.round(Z.intrinsicWidth*q))}}function J5($,M,J,Z){let X=$.documentIndex.regionIndex.get($.selection.anchor.regionId);if(!Z.image||!X)return null;let Y=j0(M.layout,X.id,Z.start);if(!Y)return null;let Q=Y.left+h0($,Y),K=Q+W0(Y,Z.start-Y.start)-Y.left,q=Q+W0(Y,Z.end-Y.start)-Y.left,{height:D}=M5(Z,J,Y.width),A=Y.top+Math.max(0,Math.floor((Y.height-D)/2));return{left:K,top:A,width:q-K,height:D}}function w9($,M){if(!$.image)return`${$.kind}:missing-image`;let J=M.images.get($.image.url);return`${$.kind}:${$.image.url}:${$.image.width??0}:${J?.status??"loading"}:${J?.intrinsicWidth??0}:${J?.intrinsicHeight??0}`}function B1(){return{graphemeWidths:new Map,lineBoundaries:new Map,measuredContainerHeights:new Map,measuredLines:new Map,preparedText:new Map,viewportPlans:new WeakMap}}function T9($,M,J){return T2($.preparedText,M,J,256)}function O9($,M,J){return T2($.measuredLines,M,J,512)}function j9($,M,J){return T2($.lineBoundaries,M,J,1024)}function L9($,M,J){return T2($.measuredContainerHeights,M,J,1024)}function C9($,M){let J=$.graphemeWidths.get(M);if(J)return J;let Z=new Map;return T2($.graphemeWidths,M,Z,64),Z}function R9($,M,J){return $.viewportPlans.get(M)?.get(J)??null}function f9($,M,J,Z){let X=$.viewportPlans.get(M)??new Map;return X.set(J,Z),$.viewportPlans.set(M,X),Z}function T2($,M,J,Z){if($.has(M))$.delete(M);if($.set(M,J),$.size>Z){let X=$.keys().next().value;if(X!==void 0)$.delete(X)}return J}var QX=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","ON","ON","ET","ET","ET","ON","ON","ON","ON","ON","ON","CS","ON","CS","ON","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","ON","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","ON","ET","ET","ET","ET","ON","ON","ON","ON","L","ON","ON","ON","ON","ON","ET","ET","EN","EN","ON","L","ON","ON","ON","EN","L","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L"],KX=["AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","CS","AL","ON","ON","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AN","AN","AN","AN","AN","AN","AN","AN","AN","AN","ET","AN","AN","AL","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","ON","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL"];function DX($){if($<=255)return QX[$];if(1424<=$&&$<=1524)return"R";if(1536<=$&&$<=1791)return KX[$&255];if(1792<=$&&$<=2220)return"AL";return"L"}function qX($){let M=$.length;if(M===0)return null;let J=Array(M),Z=0;for(let D=0;D<M;D++){let A=DX($.charCodeAt(D));if(A==="R"||A==="AL"||A==="AN")Z++;J[D]=A}if(Z===0)return null;let X=M/Z<0.3?0:1,Y=new Int8Array(M);for(let D=0;D<M;D++)Y[D]=X;let Q=X&1?"R":"L",K=Q,q=K;for(let D=0;D<M;D++)if(J[D]==="NSM")J[D]=q;else q=J[D];q=K;for(let D=0;D<M;D++){let A=J[D];if(A==="EN")J[D]=q==="AL"?"AN":"EN";else if(A==="R"||A==="L"||A==="AL")q=A}for(let D=0;D<M;D++)if(J[D]==="AL")J[D]="R";for(let D=1;D<M-1;D++){if(J[D]==="ES"&&J[D-1]==="EN"&&J[D+1]==="EN")J[D]="EN";if(J[D]==="CS"&&(J[D-1]==="EN"||J[D-1]==="AN")&&J[D+1]===J[D-1])J[D]=J[D-1]}for(let D=0;D<M;D++){if(J[D]!=="EN")continue;let A;for(A=D-1;A>=0&&J[A]==="ET";A--)J[A]="EN";for(A=D+1;A<M&&J[A]==="ET";A++)J[A]="EN"}for(let D=0;D<M;D++){let A=J[D];if(A==="WS"||A==="ES"||A==="ET"||A==="CS")J[D]="ON"}q=K;for(let D=0;D<M;D++){let A=J[D];if(A==="EN")J[D]=q==="L"?"L":"EN";else if(A==="R"||A==="L")q=A}for(let D=0;D<M;D++){if(J[D]!=="ON")continue;let A=D+1;while(A<M&&J[A]==="ON")A++;let V=D>0?J[D-1]:K,U=A<M?J[A]:K,G=V!=="L"?"R":"L";if(G===(U!=="L"?"R":"L"))for(let N=D;N<A;N++)J[N]=G;D=A-1}for(let D=0;D<M;D++)if(J[D]==="ON")J[D]=Q;for(let D=0;D<M;D++){let A=J[D];if((Y[D]&1)===0){if(A==="R")Y[D]++;else if(A==="AN"||A==="EN")Y[D]+=2}else if(A==="L"||A==="AN"||A==="EN")Y[D]++}return Y}function m9($,M){let J=qX($);if(J===null)return null;let Z=new Int8Array(M.length);for(let X=0;X<M.length;X++)Z[X]=J[M[X]];return Z}var AX=/[ \t\n\r\f]+/g,UX=/[\t\n\r\f]| {2,}|^ | $/;function VX($){let M=$??"normal";return M==="pre-wrap"?{mode:M,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:M,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function GX($){if(!UX.test($))return $;let M=$.replace(AX," ");if(M.charCodeAt(0)===32)M=M.slice(1);if(M.length>0&&M.charCodeAt(M.length-1)===32)M=M.slice(0,-1);return M}function NX($){if(!/[\r\f]/.test($))return $.replace(/\r\n/g,`
|
|
10
10
|
`);return $.replace(/\r\n/g,`
|
|
11
11
|
`).replace(/[\r\f]/g,`
|
|
12
|
-
`)}var
|
|
13
|
-
`)return"hard-break"}if($===" ")return"space";if($===" "||$===" "||$===""||$==="\uFEFF")return"glue";if($==="")return"zero-width-break";if($==="")return"soft-hyphen";return"text"}function i0($){return $.length===1?$[0]:$.join("")}function QX($,M,J,Z){let X=[],D=null,Y=[],Q=J,K=!1,q=0;for(let U of $){let N=YX(U,Z),A=N==="text"&&M;if(D!==null&&N===D&&A===K){Y.push(U),q+=U.length;continue}if(D!==null)X.push({text:i0(Y),isWordLike:K,kind:D,start:Q});D=N,Y=[U],Q=J+q,K=A,q+=U.length}if(D!==null)X.push({text:i0(Y),isWordLike:K,kind:D,start:Q});return X}function l8($){return $==="space"||$==="preserved-space"||$==="zero-width-break"||$==="hard-break"}var KX=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function qX($,M){let J=$.texts[M];if(J.startsWith("www."))return!0;return KX.test(J)&&M+1<$.len&&$.kinds[M+1]==="text"&&$.texts[M+1]==="//"}function UX($){return $.includes("?")&&($.includes("://")||$.startsWith("www."))}function NX($){let M=$.texts.slice(),J=$.isWordLike.slice(),Z=$.kinds.slice(),X=$.starts.slice();for(let Y=0;Y<$.len;Y++){if(Z[Y]!=="text"||!qX($,Y))continue;let Q=[M[Y]],K=Y+1;while(K<$.len&&!l8(Z[K])){Q.push(M[K]),J[Y]=!0;let q=M[K].includes("?");if(Z[K]="text",M[K]="",K++,q)break}M[Y]=i0(Q)}let D=0;for(let Y=0;Y<M.length;Y++){let Q=M[Y];if(Q.length===0)continue;if(D!==Y)M[D]=Q,J[D]=J[Y],Z[D]=Z[Y],X[D]=X[Y];D++}return M.length=D,J.length=D,Z.length=D,X.length=D,{len:D,texts:M,isWordLike:J,kinds:Z,starts:X}}function AX($){let M=[],J=[],Z=[],X=[];for(let D=0;D<$.len;D++){let Y=$.texts[D];if(M.push(Y),J.push($.isWordLike[D]),Z.push($.kinds[D]),X.push($.starts[D]),!UX(Y))continue;let Q=D+1;if(Q>=$.len||l8($.kinds[Q]))continue;let K=[],q=$.starts[Q],U=Q;while(U<$.len&&!l8($.kinds[U]))K.push($.texts[U]),U++;if(K.length>0)M.push(i0(K)),J.push(!0),Z.push("text"),X.push(q),D=U-1}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}var VX=new Set([":","-","/","×",",",".","+","–","—"]),o$=/^[A-Za-z0-9_]+[,:;]*$/,n$=/[,:;]+$/;function e$($){for(let M of $)if(t$.test(M))return!0;return!1}function r8($){if($.length===0)return!1;for(let M of $){if(t$.test(M)||VX.has(M))continue;return!1}return!0}function GX($){let M=[],J=[],Z=[],X=[];for(let D=0;D<$.len;D++){let Y=$.texts[D],Q=$.kinds[D];if(Q==="text"&&r8(Y)&&e$(Y)){let K=[Y],q=D+1;while(q<$.len&&$.kinds[q]==="text"&&r8($.texts[q]))K.push($.texts[q]),q++;M.push(i0(K)),J.push(!0),Z.push("text"),X.push($.starts[D]),D=q-1;continue}M.push(Y),J.push($.isWordLike[D]),Z.push(Q),X.push($.starts[D])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function BX($){let M=[],J=[],Z=[],X=[];for(let D=0;D<$.len;D++){let Y=$.texts[D],Q=$.kinds[D],K=$.isWordLike[D];if(Q==="text"&&K&&o$.test(Y)){let q=[Y],U=n$.test(Y),N=D+1;while(U&&N<$.len&&$.kinds[N]==="text"&&$.isWordLike[N]&&o$.test($.texts[N])){let A=$.texts[N];q.push(A),U=n$.test(A),N++}M.push(i0(q)),J.push(!0),Z.push("text"),X.push($.starts[D]),D=N-1;continue}M.push(Y),J.push(K),Z.push(Q),X.push($.starts[D])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function FX($){let M=[],J=[],Z=[],X=[];for(let D=0;D<$.len;D++){let Y=$.texts[D];if($.kinds[D]==="text"&&Y.includes("-")){let Q=Y.split("-"),K=Q.length>1;for(let q=0;q<Q.length;q++){let U=Q[q];if(!K)break;if(U.length===0||!e$(U)||!r8(U))K=!1}if(K){let q=0;for(let U=0;U<Q.length;U++){let N=Q[U],A=U<Q.length-1?`${N}-`:N;M.push(A),J.push(!0),Z.push("text"),X.push($.starts[D]+q),q+=A.length}continue}}M.push(Y),J.push($.isWordLike[D]),Z.push($.kinds[D]),X.push($.starts[D])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function _X($){let M=[],J=[],Z=[],X=[],D=0;while(D<$.len){let Y=[$.texts[D]],Q=$.isWordLike[D],K=$.kinds[D],q=$.starts[D];if(K==="glue"){let U=[Y[0]],N=q;D++;while(D<$.len&&$.kinds[D]==="glue")U.push($.texts[D]),D++;let A=i0(U);if(D<$.len&&$.kinds[D]==="text")Y[0]=A,Y.push($.texts[D]),Q=$.isWordLike[D],K="text",q=N,D++;else{M.push(A),J.push(!1),Z.push("glue"),X.push(N);continue}}else D++;if(K==="text")while(D<$.len&&$.kinds[D]==="glue"){let U=[];while(D<$.len&&$.kinds[D]==="glue")U.push($.texts[D]),D++;let N=i0(U);if(D<$.len&&$.kinds[D]==="text"){Y.push(N,$.texts[D]),Q=Q||$.isWordLike[D],D++;continue}Y.push(N)}M.push(i0(Y)),J.push(Q),Z.push(K),X.push(q)}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function bX($){let M=$.texts.slice(),J=$.isWordLike.slice(),Z=$.kinds.slice(),X=$.starts.slice();for(let D=0;D<M.length-1;D++){if(Z[D]!=="text"||Z[D+1]!=="text")continue;if(!a0(M[D])||!a0(M[D+1]))continue;let Y=MX(M[D]);if(Y===null)continue;M[D]=Y.head,M[D+1]=Y.tail+M[D+1],X[D+1]=X[D]+Y.head.length}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function HX($,M,J){let Z=aZ(),X=0,D=[],Y=[],Q=[],K=[];for(let A of Z.segment($))for(let V of QX(A.segment,A.isWordLike??!1,A.index,J)){let B=V.kind==="text";if(M.carryCJKAfterClosingQuote&&B&&X>0&&Q[X-1]==="text"&&a0(V.text)&&a0(D[X-1])&&a8(D[X-1]))D[X-1]+=V.text,Y[X-1]=Y[X-1]||V.isWordLike;else if(B&&X>0&&Q[X-1]==="text"&&eZ(V.text)&&a0(D[X-1]))D[X-1]+=V.text,Y[X-1]=Y[X-1]||V.isWordLike;else if(B&&X>0&&Q[X-1]==="text"&&XX(D[X-1]))D[X-1]+=V.text,Y[X-1]=Y[X-1]||V.isWordLike;else if(B&&X>0&&Q[X-1]==="text"&&V.isWordLike&&p8(V.text)&&ZX(D[X-1]))D[X-1]+=V.text,Y[X-1]=!0;else if(B&&!V.isWordLike&&X>0&&Q[X-1]==="text"&&V.text.length===1&&V.text!=="-"&&V.text!=="—"&&JX(D[X-1],V.text))D[X-1]+=V.text;else if(B&&!V.isWordLike&&X>0&&Q[X-1]==="text"&&(tZ(V.text)||V.text==="-"&&Y[X-1]))D[X-1]+=V.text;else D[X]=V.text,Y[X]=V.isWordLike,Q[X]=V.kind,K[X]=V.start,X++}for(let A=1;A<X;A++)if(Q[A]==="text"&&!Y[A]&&d8(D[A])&&Q[A-1]==="text")D[A-1]+=D[A],Y[A-1]=Y[A-1]||Y[A],D[A]="";for(let A=X-2;A>=0;A--)if(Q[A]==="text"&&!Y[A]&&$X(D[A])){let V=A+1;while(V<X&&D[V]==="")V++;if(V<X&&Q[V]==="text")D[V]=D[A]+D[V],K[V]=K[A],D[A]=""}let q=0;for(let A=0;A<X;A++){let V=D[A];if(V.length===0)continue;if(q!==A)D[q]=V,Y[q]=Y[A],Q[q]=Q[A],K[q]=K[A];q++}D.length=q,Y.length=q,Q.length=q,K.length=q;let U=_X({len:q,texts:D,isWordLike:Y,kinds:Q,starts:K}),N=bX(BX(FX(GX(AX(NX(U))))));for(let A=0;A<N.len-1;A++){let V=DX(N.texts[A]);if(V===null)continue;if(N.kinds[A]!=="space"&&N.kinds[A]!=="preserved-space"||N.kinds[A+1]!=="text"||!p8(N.texts[A+1]))continue;N.texts[A]=V.space,N.isWordLike[A]=!1,N.kinds[A]=N.kinds[A]==="preserved-space"?"preserved-space":"space",N.texts[A+1]=V.marks+N.texts[A+1],N.starts[A+1]=N.starts[A]+V.space.length}return N}function PX($,M){if($.len===0)return[];if(!M.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len}];let J=[],Z=0;for(let X=0;X<$.len;X++){if($.kinds[X]!=="hard-break")continue;J.push({startSegmentIndex:Z,endSegmentIndex:X,consumedEndSegmentIndex:X+1}),Z=X+1}if(Z<$.len)J.push({startSegmentIndex:Z,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len});return J}function $9($,M,J="normal"){let Z=rZ(J),X=Z.mode==="pre-wrap"?xZ($):cZ($);if(X.length===0)return{normalized:X,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let D=HX(X,M,Z);return{normalized:X,chunks:PX(D,Z),...D}}var x1=null,M9=new Map,d1=null,zX=/\p{Emoji_Presentation}/u,WX=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,i8=null,J9=new Map;function s8(){if(x1!==null)return x1;if(typeof OffscreenCanvas<"u")return x1=new OffscreenCanvas(1,1).getContext("2d"),x1;if(typeof document<"u")return x1=document.createElement("canvas").getContext("2d"),x1;throw Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function EX($){let M=M9.get($);if(!M)M=new Map,M9.set($,M);return M}function X1($,M){let J=M.get($);if(J===void 0)J={width:s8().measureText($).width,containsCJK:a0($)},M.set($,J);return J}function a1(){if(d1!==null)return d1;if(typeof navigator>"u")return d1={lineFitEpsilon:0.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},d1;let $=navigator.userAgent,J=navigator.vendor==="Apple Computer, Inc."&&$.includes("Safari/")&&!$.includes("Chrome/")&&!$.includes("Chromium/")&&!$.includes("CriOS/")&&!$.includes("FxiOS/")&&!$.includes("EdgiOS/"),Z=$.includes("Chrome/")||$.includes("Chromium/")||$.includes("CriOS/")||$.includes("Edg/");return d1={lineFitEpsilon:J?0.015625:0.005,carryCJKAfterClosingQuote:Z,preferPrefixWidthsForBreakableRuns:J,preferEarlySoftHyphenBreak:J},d1}function TX($){let M=$.match(/(\d+(?:\.\d+)?)\s*px/);return M?parseFloat(M[1]):16}function o8(){if(i8===null)i8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return i8}function yX($){return zX.test($)||$.includes("️")}function Z9($){return WX.test($)}function wX($,M){let J=J9.get($);if(J!==void 0)return J;let Z=s8();Z.font=$;let X=Z.measureText("\uD83D\uDE00").width;if(J=0,X>M+0.5&&typeof document<"u"&&document.body!==null){let D=document.createElement("span");D.style.font=$,D.style.display="inline-block",D.style.visibility="hidden",D.style.position="absolute",D.textContent="\uD83D\uDE00",document.body.appendChild(D);let Y=D.getBoundingClientRect().width;if(document.body.removeChild(D),X-Y>0.5)J=X-Y}return J9.set($,J),J}function OX($){let M=0,J=o8();for(let Z of J.segment($))if(yX(Z.segment))M++;return M}function CX($,M){if(M.emojiCount===void 0)M.emojiCount=OX($);return M.emojiCount}function D1($,M,J){if(J===0)return M.width;return M.width-CX($,M)*J}function X9($,M,J,Z){if(M.graphemeWidths!==void 0)return M.graphemeWidths;let X=[],D=o8();for(let Y of D.segment($)){let Q=X1(Y.segment,J);X.push(D1(Y.segment,Q,Z))}return M.graphemeWidths=X.length>1?X:null,M.graphemeWidths}function D9($,M,J,Z){if(M.graphemePrefixWidths!==void 0)return M.graphemePrefixWidths;let X=[],D=o8(),Y="";for(let Q of D.segment($)){Y+=Q.segment;let K=X1(Y,J);X.push(D1(Y,K,Z))}return M.graphemePrefixWidths=X.length>1?X:null,M.graphemePrefixWidths}function Y9($,M){let J=s8();J.font=$;let Z=EX($),X=TX($),D=M?wX($,X):0;return{cache:Z,fontSize:X,emojiCorrection:D}}function Y5($){return $==="space"||$==="preserved-space"||$==="tab"||$==="zero-width-break"||$==="soft-hyphen"}function jX($,M){while(M<$.widths.length){let J=$.kinds[M];if(J!=="space"&&J!=="zero-width-break"&&J!=="soft-hyphen")break;M++}return M}function LX($,M){if(M<=0)return 0;let J=$%M;if(Math.abs(J)<=0.000001)return M;return M-J}function Q9($,M,J,Z){if(!Z||M===null)return $[J];return M[J]-(J>0?M[J-1]:0)}function RX($,M,J,Z,X,D){let Y=0,Q=M;while(Y<$.length){let K=D?M+$[Y]:Q+$[Y];if((Y+1<$.length?K+X:K)>J+Z)break;Q=K,Y++}return{fitCount:Y,fittedWidth:Q}}function kX($,M,J){let{widths:Z,kinds:X,breakableWidths:D,breakablePrefixWidths:Y}=$;if(Z.length===0)return 0;let Q=a1(),K=Q.lineFitEpsilon,q=0,U=0,N=!1,A=0,V=0,B=0,G=0,b=-1,P=0;function y(){b=-1,P=0}function z(W=B,F=G,H=U){q++,J?.({startSegmentIndex:A,startGraphemeIndex:V,endSegmentIndex:W,endGraphemeIndex:F,width:H}),U=0,N=!1,y()}function L(W,F){N=!0,A=W,V=0,B=W+1,G=0,U=F}function R(W,F,H){N=!0,A=W,V=F,B=W,G=F+1,U=H}function m(W,F){if(!N){L(W,F);return}U+=F,B=W+1,G=0}function E(W,F){if(!Y5(X[W]))return;b=W+1,P=U-F}function _(W){j(W,0)}function j(W,F){let H=D[W],v=Y[W]??null;for(let h=F;h<H.length;h++){let l=Q9(H,v,h,Q.preferPrefixWidthsForBreakableRuns);if(!N){R(W,h,l);continue}if(U+l>M+K)z(),R(W,h,l);else U+=l,B=W,G=h+1}if(N&&B===W&&G===H.length)B=W+1,G=0}let C=0;while(C<Z.length){if(!N){if(C=jX($,C),C>=Z.length)break}let W=Z[C],F=X[C];if(!N){if(W>M&&D[C]!==null)_(C);else L(C,W);E(C,W),C++;continue}if(U+W>M+K){if(Y5(F)){m(C,W),z(C+1,0,U-W),C++;continue}if(b>=0){if(B>b||B===b&&G>0){z();continue}z(b,0,P);continue}if(W>M&&D[C]!==null){z(),_(C),C++;continue}z();continue}m(C,W),E(C,W),C++}if(N)z();return q}function K9($,M,J){if($.simpleLineWalkFastPath)return kX($,M,J);let{widths:Z,lineEndFitAdvances:X,lineEndPaintAdvances:D,kinds:Y,breakableWidths:Q,breakablePrefixWidths:K,discretionaryHyphenWidth:q,tabStopAdvance:U,chunks:N}=$;if(Z.length===0||N.length===0)return 0;let A=a1(),V=A.lineFitEpsilon,B=0,G=0,b=!1,P=0,y=0,z=0,L=0,R=-1,m=0,E=0,_=null;function j(){R=-1,m=0,E=0,_=null}function C(T=z,k=L,f=G){B++,J?.({startSegmentIndex:P,startGraphemeIndex:y,endSegmentIndex:T,endGraphemeIndex:k,width:f}),G=0,b=!1,j()}function W(T,k){b=!0,P=T,y=0,z=T+1,L=0,G=k}function F(T,k,f){b=!0,P=T,y=k,z=T,L=k+1,G=f}function H(T,k){if(!b){W(T,k);return}G+=k,z=T+1,L=0}function v(T,k){if(!Y5(Y[T]))return;let f=Y[T]==="tab"?0:X[T],d=Y[T]==="tab"?k:D[T];R=T+1,m=G-k+f,E=G-k+d,_=Y[T]}function h(T){l(T,0)}function l(T,k){let f=Q[T],d=K[T]??null;for(let I=k;I<f.length;I++){let U0=Q9(f,d,I,A.preferPrefixWidthsForBreakableRuns);if(!b){F(T,I,U0);continue}if(G+U0>M+V)C(),F(T,I,U0);else G+=U0,z=T,L=I+1}if(b&&z===T&&L===f.length)z=T+1,L=0}function p(T){if(_!=="soft-hyphen")return!1;let k=Q[T];if(k===null)return!1;let f=A.preferPrefixWidthsForBreakableRuns?K[T]??k:k,d=f!==k,{fitCount:I,fittedWidth:U0}=RX(f,G,M,V,q,d);if(I===0)return!1;if(G=U0,z=T,L=I,j(),I===k.length)return z=T+1,L=0,!0;return C(T,I,U0+q),l(T,I),!0}function O(T){B++,J?.({startSegmentIndex:T.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:T.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),j()}for(let T=0;T<N.length;T++){let k=N[T];if(k.startSegmentIndex===k.endSegmentIndex){O(k);continue}b=!1,G=0,P=k.startSegmentIndex,y=0,z=k.startSegmentIndex,L=0,j();let f=k.startSegmentIndex;while(f<k.endSegmentIndex){let d=Y[f],I=d==="tab"?LX(G,U):Z[f];if(d==="soft-hyphen"){if(b)z=f+1,L=0,R=f+1,m=G+q,E=G+q,_=d;f++;continue}if(!b){if(I>M&&Q[f]!==null)h(f);else W(f,I);v(f,I),f++;continue}if(G+I>M+V){let z0=G+(d==="tab"?0:X[f]),_0=G+(d==="tab"?I:D[f]);if(_==="soft-hyphen"&&A.preferEarlySoftHyphenBreak&&m<=M+V){C(R,0,E);continue}if(_==="soft-hyphen"&&p(f)){f++;continue}if(Y5(d)&&z0<=M+V){H(f,I),C(f+1,0,_0),f++;continue}if(R>=0&&m<=M+V){if(z>R||z===R&&L>0){C();continue}let R1=R;C(R1,0,E),f=R1;continue}if(I>M&&Q[f]!==null){C(),h(f),f++;continue}C();continue}H(f,I),v(f,I),f++}if(b){let d=R===k.consumedEndSegmentIndex?E:G;C(k.consumedEndSegmentIndex,0,d)}}return B}var n8=null,q9=new WeakMap;function N9(){if(n8===null)n8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return n8}function fX($){if($)return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]};return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[]}}function mX($,M,J){let Z=N9(),X=a1(),{cache:D,emojiCorrection:Y}=Y9(M,Z9($.normalized)),Q=D1("-",X1("-",D),Y),q=D1(" ",X1(" ",D),Y)*8;if($.len===0)return fX(J);let U=[],N=[],A=[],V=[],B=$.chunks.length<=1,G=J?[]:null,b=[],P=[],y=J?[]:null,z=Array.from({length:$.len}),L=Array.from({length:$.len});function R(_,j,C,W,F,H,v,h){if(F!=="text"&&F!=="space"&&F!=="zero-width-break")B=!1;if(U.push(j),N.push(C),A.push(W),V.push(F),G?.push(H),b.push(v),P.push(h),y!==null)y.push(_)}for(let _=0;_<$.len;_++){z[_]=U.length;let j=$.texts[_],C=$.isWordLike[_],W=$.kinds[_],F=$.starts[_];if(W==="soft-hyphen"){R(j,0,Q,Q,W,F,null,null),L[_]=U.length;continue}if(W==="hard-break"){R(j,0,0,0,W,F,null,null),L[_]=U.length;continue}if(W==="tab"){R(j,0,0,0,W,F,null,null),L[_]=U.length;continue}let H=X1(j,D);if(W==="text"&&H.containsCJK){let p="",O=0;for(let T of Z.segment(j)){let k=T.segment;if(p.length===0){p=k,O=T.index;continue}if(O2.has(p)||c8.has(k)||c1.has(k)||X.carryCJKAfterClosingQuote&&a0(k)&&a8(p)){p+=k;continue}let f=X1(p,D),d=D1(p,f,Y);R(p,d,d,d,"text",F+O,null,null),p=k,O=T.index}if(p.length>0){let T=X1(p,D),k=D1(p,T,Y);R(p,k,k,k,"text",F+O,null,null)}L[_]=U.length;continue}let v=D1(j,H,Y),h=W==="space"||W==="preserved-space"||W==="zero-width-break"?0:v,l=W==="space"||W==="zero-width-break"?0:v;if(C&&j.length>1){let p=X9(j,H,D,Y),O=X.preferPrefixWidthsForBreakableRuns?D9(j,H,D,Y):null;R(j,v,h,l,W,F,p,O)}else R(j,v,h,l,W,F,null,null);L[_]=U.length}let m=SX($.chunks,z,L),E=G===null?null:s$($.normalized,G);if(y!==null)return{widths:U,lineEndFitAdvances:N,lineEndPaintAdvances:A,kinds:V,simpleLineWalkFastPath:B,segLevels:E,breakableWidths:b,breakablePrefixWidths:P,discretionaryHyphenWidth:Q,tabStopAdvance:q,chunks:m,segments:y};return{widths:U,lineEndFitAdvances:N,lineEndPaintAdvances:A,kinds:V,simpleLineWalkFastPath:B,segLevels:E,breakableWidths:b,breakablePrefixWidths:P,discretionaryHyphenWidth:Q,tabStopAdvance:q,chunks:m}}function SX($,M,J){let Z=[];for(let X=0;X<$.length;X++){let D=$[X],Y=D.startSegmentIndex<M.length?M[D.startSegmentIndex]:J[J.length-1]??0,Q=D.endSegmentIndex<M.length?M[D.endSegmentIndex]:J[J.length-1]??0,K=D.consumedEndSegmentIndex<M.length?M[D.consumedEndSegmentIndex]:J[J.length-1]??0;Z.push({startSegmentIndex:Y,endSegmentIndex:Q,consumedEndSegmentIndex:K})}return Z}function uX($,M,J,Z){let X=$9($,a1(),Z?.whiteSpace);return mX(X,M,J)}function A9($,M,J){return uX($,M,!0,J)}function vX($){return $}function U9($,M,J){let Z=J.get($);if(Z!==void 0)return Z;Z=[];let X=N9();for(let D of X.segment(M[$]))Z.push(D.segment);return J.set($,Z),Z}function hX($){let M=q9.get($);if(M!==void 0)return M;return M=new Map,q9.set($,M),M}function gX($,M,J,Z){return Z>0&&$[Z-1]==="soft-hyphen"&&!(M===Z&&J>0)}function IX($,M,J,Z,X,D,Y){let Q="",K=gX(M,Z,X,D);for(let q=Z;q<D;q++){if(M[q]==="soft-hyphen"||M[q]==="hard-break")continue;if(q===Z&&X>0)Q+=U9(q,$,J).slice(X).join("");else Q+=$[q]}if(Y>0){if(K)Q+="-";Q+=U9(D,$,J).slice(Z===D?X:0,Y).join("")}else if(K)Q+="-";return Q}function pX($,M,J,Z,X,D,Y){return{text:IX($.segments,$.kinds,M,Z,X,D,Y),width:J,start:{segmentIndex:Z,graphemeIndex:X},end:{segmentIndex:D,graphemeIndex:Y}}}function lX($,M,J){return pX($,M,J.width,J.startSegmentIndex,J.startGraphemeIndex,J.endSegmentIndex,J.endGraphemeIndex)}function V9($,M,J){let Z=[];if($.widths.length===0)return{lineCount:0,height:0,lines:Z};let X=hX($),D=K9(vX($),M,(Y)=>{Z.push(lX($,X,Y))});return{lineCount:D,height:D*J,lines:Z}}function t8($,M,J){let Z=$.image?M.images.get($.image.url)??null:null,X=$.image?.width??null,D=Math.min(J,X??240),Y=Math.max(120,Math.round(D*0.5625));if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return{height:Y,width:D};let Q=Math.min(J,X??Z.intrinsicWidth),K=Math.min(1,Q/Z.intrinsicWidth);return{height:Math.max(48,Math.round(Z.intrinsicHeight*K)),width:Math.max(48,Math.round(Z.intrinsicWidth*K))}}function G9($,M){if(!$.image)return`${$.kind}:missing-image`;let J=M.images.get($.image.url);return`${$.kind}:${$.image.url}:${$.image.width??0}:${J?.status??"loading"}:${J?.intrinsicWidth??0}:${J?.intrinsicHeight??0}`}var B9=[{fontSize:32,lineHeight:36},{fontSize:26,lineHeight:32},{fontSize:21,lineHeight:28},{fontSize:21,lineHeight:28},{fontSize:19,lineHeight:26},{fontSize:18,lineHeight:26}],Q5;function i1($){if($?.type==="heading"){let{fontSize:M}=b9($.depth);return`700 ${M}px "Iowan Old Style", "Palatino Linotype", serif`}switch($?.type){case"code":return"15px ui-monospace, SFMono-Regular, Menlo, monospace";default:return'16px "Iowan Old Style", "Palatino Linotype", serif'}}function E1($,M){if($?.type==="heading")return b9($.depth).lineHeight;if($?.type==="code")return 22;return M}function b9($){return B9[$-1]??B9.at(-1)}function s1($,M,J,Z,X,D,Y){let Q=`${q5(M,Y)}:${X}:${D}:${J}`,K=$.measuredLines.get(Q);if(K)return K;let q=cX($,M,J,Z,X,D,Y);return r$($,Q,q)}function K5($,M,J,Z,X,D,Y,Q){let K=`${q5(M,Q)}:${J}:${Z}:${D}:${Y}`,q=$.lineBoundaries.get(K);if(q)return q;let U=P9();if(!U)return _9(X);let N=[{left:0,offset:0}],A=0,V=M.inlines.filter((B)=>B.end>J&&B.start<Z);if(V.length===0)return _9(X);for(let B of V){let G=Math.max(J,B.start),b=Math.min(Z,B.end),P=M.text.slice(G,b),y=G-J;if(B.kind==="image"){let z=t8(B,Q,Y).width;A+=z,y+=P.length,N.push({left:A,offset:y});continue}U.font=H9(D,B.marks);for(let z of Array.from(P))A+=z9($,U,z),y+=z.length,N.push({left:A,offset:y})}return c$($,K,N)}function rX($,M,J,Z){let X=`${J}::${Z}::${M}`,D=$.preparedText.get(X);if(D)return D;let Y=A9(M,J,{whiteSpace:Z});return l$($,X,Y)}function cX($,M,J,Z,X,D,Y){let Q=M.text;if(Q.length===0)return[{end:0,height:D,start:0,text:"",width:0}];if(sX(M))return dX($,M,J,X,D,Y);try{let K=rX($,Q,J,$D(Z));return V9(K,X,D).lines.map((U)=>({end:F9(K.segments,U.end),height:D,start:F9(K.segments,U.start),text:U.text,width:U.width}))}catch{return xX(Q,X,D)}}function F9($,M){let J=0;for(let D=0;D<M.segmentIndex;D+=1)J+=$[D]?.length??0;let Z=$[M.segmentIndex]??"",X=Array.from(Z);for(let D=0;D<M.graphemeIndex;D+=1)J+=X[D]?.length??0;return J}function _9($){let M=[{left:0,offset:0}],J=0,Z=0;for(let X of Array.from($))J+=9,Z+=X.length,M.push({left:J,offset:Z});return M}function xX($,M,J){let Z=Math.max(1,Math.floor(M/9)),X=MD($,Z),D=0;return X.map((Y)=>{let Q=D,K=Q+Y.length;return D=K,{end:K,height:J,start:Q,text:Y,width:Y.length*9}})}function dX($,M,J,Z,X,D){let Y=iX($,P9(),M,J,Z,X,D);if(Y.length===0)return[{end:0,height:X,start:0,text:"",width:0}];return aX(Y,M.text,Z,X)}function aX($,M,J,Z){let X=[],D=0;while(D<$.length){let Y=$[D].start;if($[D].text===`
|
|
14
|
-
`){X.push({end:
|
|
15
|
-
`)break;let
|
|
16
|
-
`){let
|
|
17
|
-
`?
|
|
18
|
-
`?0:
|
|
19
|
-
`),Z=[];for(let X of J){if(X.length===0){Z.push("");continue}let D=X;while(D.length>M){let Y=D.slice(0,M),Q=Y.lastIndexOf(" ");if(Q<=0){Z.push(Y),D=D.slice(M);continue}Z.push(Y.slice(0,Q)),D=D.slice(Q+1)}Z.push(D)}return Z}var C2=10,o1=8,e8=120;function W9($,M,J,Z,X,D,Y,Q,K,q){let U=Math.max(1,...D.rows.map((G)=>G.cells.length)),A=Math.max(e8,K.width-Y-K.paddingX)/U,V=JD(Z),B=Q;for(let G=0;G<D.rows.length;G+=1){let b=ZD(V.get(G)??[],X,D,A,C2,K.lineHeight,q),P=Math.max(K.lineHeight+o1*2,...b.map((y)=>y.measuredLines.reduce((z,L)=>z+L.height,0)+o1*2));for(let y of b){let z=Y+y.cellIndex*A,L=B+o1;for(let R of y.measuredLines){let m={blockId:y.container.blockId,boundaries:K5(X,y.container,R.start,R.end,R.text,y.font,A-C2*2,q),regionId:y.container.id,end:R.end,font:y.font,height:R.height,left:z+C2,start:R.start,text:R.text,top:L,width:R.width};$.push(m),$6(M,m),L+=R.height}J.set(y.container.id,{bottom:B+P,left:z,right:z+A,top:B})}DD(M,D.id,B,B+P),B+=P}return B+K.blockGap}function JD($){let M=new Map;for(let J of $){let Z=XD(J.path);if(!Z)continue;let X=M.get(Z.rowIndex)??[];X.push({cellIndex:Z.cellIndex,container:J}),M.set(Z.rowIndex,X)}return M}function ZD($,M,J,Z,X,D,Y){return[...$].sort((Q,K)=>Q.cellIndex-K.cellIndex).map(({cellIndex:Q,container:K})=>{let q=i1(J),U=E1(J,D),N=s1(M,K,q,J,Math.max(40,Z-X*2),U,Y);return{cellIndex:Q,container:K,font:q,lineHeight:U,measuredLines:N}})}function XD($){let M=/\.rows\.(\d+)\.cells\.(\d+)$/.exec($);if(!M)return null;return{cellIndex:Number(M[2]),rowIndex:Number(M[1])}}function DD($,M,J,Z){let X=$.get(M);$.set(M,{bottom:X?Math.max(X.bottom,Z):Z,top:X?Math.min(X.top,J):J})}var YD={blockGap:16,charWidth:9,indentWidth:24,lineHeight:24,paddingX:16,paddingY:12},QD=24,KD=16,qD=6,UD=10,ND=4;function U5($){let M=Math.max(12,Math.floor($.width/9)),J=Math.max(1,Math.ceil($.text.length/M));return{estimatedHeight:J*24,lineCount:J,width:$.width}}function N5($,M,J=W1(),Z=null){let X=Z??{images:new Map},D={...YD,...M},Y=[],Q=new Map,K=new Map($.regions.map((G)=>[G.id,{textLength:G.text.length}])),q=new Map($.blocks.map((G)=>[G.id,G.depth])),U=new Map($.blocks.map((G)=>[G.id,G])),N=L2($.document.blocks),A=new Map,V=D.paddingY;for(let G=0;G<$.regions.length;G+=1){let b=$.regions[G],P=q.get(b.blockId)??0,y=D.paddingX+P*D.indentWidth,z=Math.max(40,D.width-y-D.paddingX),L=N.get(b.blockId)??null;if(L?.type==="table"){let E=U.get(b.blockId)?.regionIds??[],_=$.regions.slice(G,G+E.length);V=W9(Y,A,Q,_,J,L,y,V,D,X),G+=_.length-1;continue}V=AD(Y,A,Q,b,J,L,y,V,z,D,X);let R=V5(U,N,$.regions,G,D.blockGap);V+=R;let m=A.get(b.blockId);if(m)m.bottom=Math.max(m.bottom,V)}return{blocks:$.blocks.map((G)=>{let b=A.get(G.id),P=b?.top??D.paddingY;return{bottom:b?.bottom??P+D.lineHeight/2,depth:G.depth,id:G.id,top:P,type:G.type}}),regionBounds:GD(Y,Q),regionLineIndices:VD(Y),regionMetrics:K,height:Math.max(V,D.paddingY),lines:Y,options:D,width:D.width}}function AD($,M,J,Z,X,D,Y,Q,K,q,U){let N=i1(D),A=E1(D,q.lineHeight),V=s1(X,Z,N,D,K,A,U),B=Q;for(let G of V){let b={blockId:Z.blockId,boundaries:K5(X,Z,G.start,G.end,G.text,N,K,U),regionId:Z.id,end:G.end,font:N,height:G.height,left:Y,start:G.start,text:G.text,top:B,width:G.width};$.push(b),$6(M,b),B+=G.height}return BD($,Z.id,J),B}function VD($){let M=[...$].sort((Z,X)=>Z.top-X.top||Z.left-X.left),J=new Map;$.length=0,$.push(...M);for(let[Z,X]of $.entries()){let D=J.get(X.regionId)??[];D.push(Z),J.set(X.regionId,D)}return J}function GD($,M){let J=new Map(M);for(let Z of $){let X=J.get(Z.regionId),D={bottom:Z.top+Z.height,left:Z.left,right:Z.left+Z.width,top:Z.top};J.set(Z.regionId,X?{bottom:Math.max(X.bottom,D.bottom),left:Math.min(X.left,D.left),right:Math.max(X.right,D.right),top:Math.min(X.top,D.top)}:D)}return J}function BD($,M,J){let Z=$.filter((X)=>X.regionId===M);if(Z.length===0)return;J.set(M,{bottom:Math.max(...Z.map((X)=>X.top+X.height)),left:Math.min(...Z.map((X)=>X.left)),right:Math.max(...Z.map((X)=>X.left+X.width)),top:Math.min(...Z.map((X)=>X.top))})}function $6($,M){let J=$.get(M.blockId),Z=M.top+M.height;$.set(M.blockId,{bottom:J?Math.max(J.bottom,Z):Z,top:J?Math.min(J.top,M.top):M.top})}function O9($,M){let J=0,Z=$.lines.length-1;while(J<=Z){let X=J+Z>>1,D=$.lines[X];if(M<D.top){Z=X-1;continue}if(M>=D.top+D.height){J=X+1;continue}return{index:X,line:D}}return null}function M6($,M){let J=[...$.regionBounds.entries()].find(([,D])=>{return M.x>=D.left&&M.x<=D.right&&M.y>=D.top&&M.y<=D.bottom});if(J)return A5($,J[0],M.y);let Z=O9($,M.y);if(!Z)return null;let X=FD($,M.y,Z.index);if(X.length===1)return X[0]??null;return X.find((D)=>{let Y=$.regionBounds.get(D.line.regionId);return Y?M.x>=Y.left&&M.x<=Y.right:!1})??[...X].sort((D,Y)=>{let Q=$.regionBounds.get(D.line.regionId),K=$.regionBounds.get(Y.line.regionId),q=E9(M.x,Q),U=E9(M.x,K);return q-U})[0]??null}function J6($,M,J){if($.lines.length===0)return{endIndex:0,startIndex:0};let Z=M+J,X=T9($,M),D=T9($,Z);if(X>0){let Y=$.lines[X-1];if(Y.top+Y.height>M)X-=1}if(D<$.lines.length){if($.lines[D].top<Z)D+=1}return{endIndex:D,startIndex:X}}function v0($,M,J){if(!$.regionMetrics.get(J.regionId))return null;let X=s0($,J.regionId,J.offset);if(!X)return null;return{blockId:X.blockId,regionId:X.regionId,height:X.height,left:h0(X,J.offset-X.start),offset:J.offset,top:X.top}}function s0($,M,J){return j2($,M,J)?.line??null}function A5($,M,J){let Z=$.regionLineIndices.get(M);if(!Z||Z.length===0)return null;let X=Z[0],D=Number.POSITIVE_INFINITY;for(let Y of Z){let Q=$.lines[Y],K=J<Q.top?Q.top-J:J>Q.top+Q.height?J-(Q.top+Q.height):0;if(K<D)D=K,X=Y;if(K===0)break}return{index:X,line:$.lines[X]}}function j2($,M,J){let Z=$.regionLineIndices.get(M);if(!Z||Z.length===0)return null;let X=0,D=Z.length-1;while(X<=D){let U=X+D>>1,N=Z[U],A=$.lines[N];if(J<A.start){D=U-1;continue}if(J>A.end){X=U+1;continue}return{index:N,line:A}}let Y=Z[0],Q=Z[Z.length-1],K=$.lines[Y],q=$.lines[Q];if(J<=K.start)return{index:Y,line:K};if(J>=q.end)return{index:Q,line:q};return null}function FD($,M,J){let Z=[];for(let X=J;X>=0;X-=1){let D=$.lines[X];if(M<D.top||M>=D.top+D.height)break;Z.unshift({index:X,line:D})}for(let X=J+1;X<$.lines.length;X+=1){let D=$.lines[X];if(M<D.top||M>=D.top+D.height)break;Z.push({index:X,line:D})}return Z}function E9($,M){if(!M)return Number.POSITIVE_INFINITY;if($<M.left)return M.left-$;if($>M.right)return $-M.right;return 0}function h0($,M){return $.left+_D($.boundaries,M)}function L2($){let M=new Map,J=(Z)=>{for(let X of Z)if(M.set(X.id,X),X.type==="blockquote"||X.type==="listItem")J(X.children);else if(X.type==="list")J(X.items)};return J($),M}function _D($,M){for(let Z of $)if(Z.offset===M)return Z.left;return $.filter((Z)=>Z.offset<=M).at(-1)?.left??0}function T9($,M){let J=0,Z=$.lines.length;while(J<Z){let X=J+Z>>1,D=$.lines[X];if(D.top+D.height<=M)J=X+1;else Z=X}return J}function C9($,M){if($.length===0)return 0;for(let J=1;J<$.length;J+=1){let Z=$[J-1],X=$[J],D=Z.left+(X.left-Z.left)/2;if(M<=D)return Z.offset;if(M<=X.left)return X.offset}return $.at(-1)?.offset??0}function V5($,M,J,Z,X){let D=J[Z],Y=J[Z+1];if(!D||!Y)return X;if(y9($,D.blockId,Y.blockId,"list"))return qD;if(y9($,D.blockId,Y.blockId,"blockquote"))return UD;if(D.blockId===Y.blockId)return ND;return X+bD(M.get(D.blockId))}function bD($){if($?.type!=="heading")return 0;if($.depth===1)return QD;return $.depth===2?KD:0}function y9($,M,J,Z){let X=w9($,M,Z),D=w9($,J,Z);for(let Y of X)if(D.has(Y))return!0;return!1}function w9($,M,J){let Z=new Set,X=$.get(M)??null;while(X){if(X.type===J)Z.add(X.id);X=X.parentBlockId?$.get(X.parentBlockId)??null:null}return Z}function Z6($,M,J,Z=[],X=W1(),D=null){let Y=D??{images:new Map},Q=L2($.document.blocks),K=new Map($.blocks.map((z)=>[z.id,z])),q=new Set(Z),U=Math.max(0,J.top-J.overscan),N=J.top+J.height+J.overscan,A=ED(X,$,Q,K,M,Y),V=j9(A,U),B=j9(A,N);if(V>0){let z=A.entries[V-1];if(z&&z.bottom>U)V-=1}if(B<A.entries.length){let z=A.entries[B];if(z&&z.top<N)B+=1}for(let z of q){let L=A.containerIndices.get(z);if(L===void 0)continue;V=Math.min(V,L),B=Math.max(B,L+1)}if(!Number.isFinite(V)||!Number.isFinite(B))return{estimateRegionBounds:A.estimateRegionBounds,layout:N5({...$,regions:[]},M,X,Y),totalHeight:A.totalHeight,viewport:J};let G=zD($,K,A.containerIndices,V,B),b=A.entries[G.startIndex]?.top??M.paddingY??0,P=N5({...$,regions:$.regions.slice(G.startIndex,G.endIndex)},M,X,Y),y=PD(P,b,A.totalHeight);return HD(X,$,y,M,Y),{estimateRegionBounds:A.estimateRegionBounds,layout:y,totalHeight:A.totalHeight,viewport:J}}function HD($,M,J,Z,X){for(let[D,Y]of J.regionBounds){let Q=Y.bottom-Y.top,K=M.regionIndex.get(D);x$($,L9(K??{path:D,inlines:[],text:""},Z,X),Q)}}function PD($,M,J){return{...$,blocks:$.blocks.map((Z)=>({...Z,bottom:Z.bottom+M,top:Z.top+M})),regionBounds:new Map([...$.regionBounds.entries()].map(([Z,X])=>[Z,{bottom:X.bottom+M,left:X.left,right:X.right,top:X.top+M}])),height:J,lines:$.lines.map((Z)=>({...Z,top:Z.top+M}))}}function zD($,M,J,Z,X){let D=Z,Y=X;for(let Q=Z;Q<X;Q+=1){let K=$.regions[Q],q=M.get(K.blockId);if(!q)continue;if(q.type==="table"){let U=J.get(q.regionIds[0]??""),N=J.get(q.regionIds[q.regionIds.length-1]??"");if(U!==void 0)D=Math.min(D,U);if(N!==void 0)Y=Math.max(Y,N+1)}}return{endIndex:Y,startIndex:D}}function WD($,M,J,Z,X,D){let Y=L9(M,X,D),Q=$.measuredContainerHeights.get(Y);if(Q!==void 0)return Q;let K=X.paddingX??0,q=X.indentWidth??24,U=E1(J,X.lineHeight??24),N=K+Z*q,A=Math.max(40,X.width-N-K);if(M.inlines.some((G)=>G.kind==="image")){let G=i1(J);return s1($,M,G,J,A,U,D).reduce((b,P)=>b+P.height,0)}let V=U5({text:M.text,width:A});return Math.max(U,V.lineCount*U)}function ED($,M,J,Z,X,D){let Y=OD(M,X,D),Q=a$($,M,Y);if(Q)return Q;let K=X.paddingY??0,q=[],U=new Map;for(let N=0;N<M.regions.length;N+=1){let A=M.regions[N],V=J.get(A.blockId)??null;if(V?.type==="table"){let P=TD({block:V,blockMap:J,containerIndices:U,entries:q,index:N,options:X,runtimeBlocks:Z,totalHeight:K,regions:M.regions});if(P){N=P.nextIndex-1,K=P.totalHeight;continue}}let B=WD($,A,V,Z.get(A.blockId)?.depth??0,X,D),G=K,b=G+B;q.push({bottom:b,top:G}),U.set(A.id,N),K=b+V5(Z,J,M.regions,N,X.blockGap??16)}return i$($,M,Y,{containerIndices:U,entries:q,estimateRegionBounds(N){let A=U.get(N);return A===void 0?null:q[A]??null},totalHeight:K})}function TD({block:$,blockMap:M,containerIndices:J,entries:Z,index:X,options:D,runtimeBlocks:Y,totalHeight:Q,regions:K}){let q=Y.get($.id),U=q?.regionIds??[];if(U.length===0)return null;let N=K.slice(X,X+U.length);if(N.length===0||N[0]?.blockId!==$.id)return null;let A=D.paddingX??0,V=D.indentWidth??24,B=q?.depth??0,G=A+B*V,b=Math.max(e8,D.width-G-A),P=Math.max(1,...$.rows.map((E)=>E.cells.length)),y=b/P,z=Math.max(40,y-C2*2),L=E1($,D.lineHeight??24),R=yD(N,X),m=Q;for(let E=0;E<$.rows.length;E+=1){let _=R.get(E)??[],j=Math.max(L+o1*2,..._.map(({region:W})=>wD(W,z,L)+o1*2)),C=m+j;for(let{index:W,region:F}of _)Z[W]={bottom:C,top:m},J.set(F.id,W);m=C}for(let E=X;E<X+N.length;E+=1){let _=K[E];if(!_||Z[E])continue;Z[E]={bottom:m,top:m},J.set(_.id,E)}return{nextIndex:X+N.length,totalHeight:m+V5(Y,M,K,X+N.length-1,D.blockGap??16)}}function yD($,M){let J=new Map;for(let[Z,X]of $.entries()){let D=X.tableCellPosition?.rowIndex;if(D===void 0)continue;let Y=J.get(D)??[];Y.push({index:M+Z,region:X}),J.set(D,Y)}return J}function wD($,M,J){let Z=U5({text:$.text,width:M});return Math.max(J,Z.lineCount*J)}function OD($,M,J){return[M.width,M.paddingX??0,M.paddingY??0,M.indentWidth??24,M.lineHeight??24,M.blockGap??16,CD($,J)].join(":")}function j9($,M){let J=0,Z=$.entries.length;while(J<Z){let X=J+Z>>1;if($.entries[X].bottom<=M)J=X+1;else Z=X}return J}function L9($,M,J){return`${q5($,J)}:${M.width}:${M.paddingX??0}:${M.indentWidth??24}:${M.lineHeight??24}`}function CD($,M){return $.regions.flatMap((J)=>J.inlines.filter((Z)=>Z.kind==="image"&&Z.image).map((Z)=>{let X=Z.image?M.images.get(Z.image.url):null;return`${Z.image?.url??""}:${Z.image?.width??0}:${X?.status??"loading"}:${X?.intrinsicWidth??0}:${X?.intrinsicHeight??0}`})).join("|")}var G5=null;function jD($){let M=/(\d+(?:\.\d+)?)\s*px/.exec($);return M?Number.parseFloat(M[1]):16}function Y1($){G5??=new Map;let M=G5.get($);if(M)return M;let J=f9(),Z=Math.max(12,Math.round(jD($)));if(!J){let A={ascent:Math.round(Z*0.8),descent:Math.max(2,Z-Math.round(Z*0.8)),emHeight:Z};return G5.set($,A),A}J.font=$;let X=J.measureText("Hg"),D=Math.round(X.actualBoundingBoxAscent||0),Y=Math.round(X.actualBoundingBoxDescent||0),Q=D+Y,K=Math.max(Z,Q),q=Q>0?D:Math.round(K*0.8),U=Q>0?Y:Math.max(2,K-q),N={ascent:q,descent:U,emHeight:K};return G5.set($,N),N}function LD($,M){let{emHeight:J}=Y1(M);return Math.max(0,Math.floor(($-J)/2))}function R9($,M){let{ascent:J}=Y1(M);return LD($,M)+J}var B5;function k9($,M){let J=f9();if(!J||$.length===0)return 0;return J.font=M,J.measureText($).width}function f9(){if(B5!==void 0)return B5;return B5=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,B5}var RD=18,kD=14,fD=22;function T0($,M,J){let Z=SD($,J);if(!Z)return null;return m9($,M,Z,J.x)}function X6($,M,J){let Z=$.lines[$.lines.length-1];if(!Z||J.y<=Z.top+Z.height)return null;return m9($,M,Z,J.x)}function m9($,M,J,Z){let X=$.regionMetrics.get(J.regionId);if(!X)return null;let D=Math.max(0,Z-K1(M,J)-J.left),Y=C9(J.boundaries,D),Q=Math.min(X.textLength,J.start+Y);return{regionId:J.regionId,offset:Q,left:h0(J,Y),top:J.top,height:J.height}}function D6($,M,J,Z){let X=U6(M,Z.regionId);if(!X)return null;let D=T0($,M,J);if(D)return{regionId:D.regionId,offset:D.offset};let Y=J.y<vD($);return{regionId:Z.regionId,offset:Y?0:X.text.length}}function Y6($,M,J){let Z=T0($,M,J);if(!Z)return null;let X=U6(M,Z.regionId);if(!X||X.text.length===0)return null;let D=Z.offset<X.text.length&&/\w/.test(X.text[Z.offset]??"")?Z.offset:Z.offset>0&&/\w/.test(X.text[Z.offset-1]??"")?Z.offset-1:Z.offset,Y=hD(X.text,D);if(Y.start===Y.end)return null;return{anchor:{regionId:Z.regionId,offset:Y.start},focus:{regionId:Z.regionId,offset:Y.end}}}function S9($,M,J){let Z=uD($,J);if(!Z||Z.start!==0)return null;let X=n1(M,Z.blockId,"listItem");if(!X)return null;if(k2(M,X.id)?.kind!=="task")return null;let Y=R2(Z),Q=Y.left-4,K=Y.left+Y.size+4,q=Y.top-4,U=Y.top+Y.size+4;return J.x>=Q&&J.x<=K&&J.y>=q&&J.y<=U?{listItemId:X.id}:null}function u9($,M,J){let Z=T0($,M,J);if(!Z)return null;let X=U6(M,Z.regionId);if(!X)return null;let D=X.inlines.find((Q)=>Q.link&&Z.offset>=Q.start&&Z.offset<Q.end);if(!D?.link)return null;let Y=q6($,M,Z.regionId,D.start);if(!Y)return null;return{anchorBottom:Y.anchorBottom,anchorLeft:Y.anchorLeft,endOffset:D.end,regionId:Z.regionId,startOffset:D.start,title:D.link.title,url:D.link.url}}function Q6($,M,J,Z){let X=S9($,M,J);if(X)return{kind:"task-toggle",listItemId:X.listItemId};let D=T0($,M,J);if(!D)return null;let Y=v9(D.regionId,D.offset,Z),Q=Y!==null?h9(Y,$,M,Z):null,K=u9($,M,J);if(K)return{anchorBottom:Q?.anchorBottom??K.anchorBottom,anchorLeft:Q?.anchorLeft??K.anchorLeft,endOffset:K.endOffset,kind:"link",commentThreadIndex:Y,regionId:K.regionId,startOffset:K.startOffset,title:K.title,url:K.url};return{anchorBottom:Q?.anchorBottom??D.top+D.height,anchorLeft:Q?.anchorLeft??D.left,kind:"text",commentThreadIndex:Y}}function K6($,M,J,Z){let X=M.documentIndex.regionIndex.get(J.regionId);if(!X)return null;let D=v9(J.regionId,J.offset,Z),Y=D!==null?h9(D,$,M,Z):null,Q=X.inlines.find((K)=>J.offset>=K.start&&J.offset<=K.end)??null;if(Q?.link){let K=q6($,M,J.regionId,Q.start);if(!K)return null;return{anchorBottom:Y?.anchorBottom??K.anchorBottom,anchorLeft:Y?.anchorLeft??K.anchorLeft,commentThreadIndex:D,endOffset:Q.end,kind:"link",regionId:J.regionId,startOffset:Q.start,title:Q.link.title,url:Q.link.url}}if(Y)return{anchorBottom:Y.anchorBottom,anchorLeft:Y.anchorLeft,commentThreadIndex:D,kind:"text"};return null}function g0($,M,J){let Z=s0(M,J.regionId,J.offset);if(!Z)return J.left;return J.left+K1($,Z)+mD($,Z,J.offset)}function Q1($,M,J){return h0(M,J)+K1($,M)}function K1($,M){let J=n1($,M.blockId,"listItem");if(!J)return 0;return k2($,J.id)?.kind==="task"?fD:RD}function R2($){return{left:$.left,size:kD,top:$.top+3}}function n1($,M,J){let Z=$.documentIndex.blockIndex.get(M)??null;while(Z){if(Z.type===J)return Z;let X=Z.parentBlockId;Z=X?$.documentIndex.blockIndex.get(X)??null:null}return null}function k2($,M){return $.documentIndex.listItemMarkers.get(M)??null}function v9($,M,J){for(let Z of J)if(Z.regionId===$&&M>=Z.startOffset&&M<=Z.endOffset)return Z.threadIndex;return null}function h9($,M,J,Z){let X=Z.find((D)=>D.threadIndex===$);if(!X)return null;return q6(M,J,X.regionId,X.startOffset)}function q6($,M,J,Z){let X=s0($,J,Z);if(!X)return null;return{anchorBottom:X.top+X.height,anchorLeft:h0(X,Z)+K1(M,X)}}function mD($,M,J){if(J<=M.end)return 0;let Z=$.documentIndex.regionIndex.get(M.regionId);if(!Z)return 0;let X=Z.text.slice(M.end,J);if(!/^[ \t]+$/u.test(X))return 0;return k9(X,M.font)}function SD($,M){for(let[Z,X]of $.regionBounds)if(M.x>=X.left&&M.x<=X.right&&M.y>=X.top&&M.y<=X.bottom)return A5($,Z,M.y)?.line??null;let J=M6($,M)?.line??null;if(J)return J;for(let Z of $.blocks)if(M.y>=Z.top&&M.y<=Z.bottom){for(let X=$.lines.length-1;X>=0;X--)if($.lines[X].blockId===Z.id)return $.lines[X]}return null}function uD($,M){return $.lines.find((J)=>M.y>=J.top-4&&M.y<=J.top+J.height+4)??$.lines.filter((J)=>Math.abs(M.y-(J.top+J.height/2))<=10).sort((J,Z)=>Math.abs(M.y-(J.top+J.height/2))-Math.abs(M.y-(Z.top+Z.height/2)))[0]??null}function U6($,M){return $.documentIndex.regionIndex.get(M)??null}function vD($){return $.lines[0]?.top??0}function hD($,M){let J=M,Z=M;while(J>0&&/\w/.test($[J-1]??""))J-=1;while(Z<$.length&&/\w/.test($[Z]??""))Z+=1;return{end:Z,start:J}}function N6($,M,J,Z=null){let X={height:M.height,overscan:Math.max(160,M.height),top:M.top},D=Z6($.documentIndex,M,X,[$.selection.anchor.regionId,$.selection.focus.regionId],J,Z);return{blockMap:L2($.documentIndex.document.blocks),estimateRegionBounds:D.estimateRegionBounds,regionBounds:new Map(D.layout.regionBounds),layout:D.layout,paintHeight:Math.max(240,X.height+X.overscan*2),paintTop:Math.max(0,X.top-X.overscan),totalHeight:D.totalHeight,viewport:{height:X.height,top:X.top}}}function F5($,M,J){return T0(M.layout,$,J)??X6(M.layout,$,J)}function f2($,M,J,Z){return D6(M.layout,$,J,Z)}function A6($,M,J){return Y6(M.layout,$,J)}function V6($,M,J,Z){return Q6(M.layout,$,J,Z)}function G6($,M,J,Z){return K6(M.layout,$,J,Z)}function B6($,M,J){return v0(M.layout,$.documentIndex,J)}function o0($,M,J){let Z=v0(M.layout,$.documentIndex,J);if(!Z)return null;return{...Z,left:g0($,M.layout,Z)}}function g9($,M,J,Z,X){let D=Z-J,Y=X-D;if(Z<=$)return{end:M+Y,start:$+Y};if(J>=M)return{end:M,start:$};let Q=Math.max(0,Math.min(J,M)-$),K=Math.max(0,M-Math.max(Z,$)),q=$<J?$:J;return{end:q+Q+X+K,start:q}}function _6($,M,J){let Z=J.trim();if(Z.length===0||M.startOffset===M.endOffset)return null;let X=$.regionIndex.get(M.regionId)??null,D=X?F6($,X):null;if(!D)return null;return f8({anchor:E2(D,M.startOffset,M.endOffset),body:Z,quote:T2(D,M.startOffset,M.endOffset)})}function L0($){let M="documentIndex"in $?$.documentIndex:$,J=_5(M),Z=M.document.comments,X=[...Z],D=[];for(let[Y,Q]of Z.entries()){let K=y2(Q,M.document);if(!K.match)continue;let U=J.findBySemanticMatch(K.match.containerId,K.match.containerOrdinal)?.runtimeContainer??null;if(!U)continue;if(K.repair)X[Y]={...Q,anchor:K.repair.anchor,quote:K.repair.quote};D.push({endOffset:K.match.endOffset,resolution:K,regionId:U.id,resolved:Q.resolvedAt!=null,startOffset:K.match.startOffset,threadIndex:Y})}return{liveRanges:D,threads:X}}function b6($,M,J,Z,X,D){if($.document.comments.length===0)return M.document.comments;let Y=$.commentContainerIndex.get(J.semanticRegionId)??[],Q=new Set(Y);if(Y.length===0)return M.document.comments;let K=L0($),q=new Map(K.liveRanges.map((V)=>[V.threadIndex,V])),U=F6($,J),N=t1(M,J.path),A=N?F6(M,N):null;if(!U||!A)return M.document.comments;return M.document.comments.map((V,B)=>{if(!Q.has(B))return V;let G=q.get(B),b=G?.resolution.match??null;if(!G||!b||b.containerId!==U.id)return V;let P=g9(b.startOffset,b.endOffset,Z,X,D.length);return{...V,anchor:E2(A,P.start,P.end),quote:T2(A,P.start,P.end)}})}function F6($,M){let J=gD($,M);if(!J)return null;return{containerKind:J,containerOrdinal:-1,id:M.semanticRegionId,text:M.text}}function gD($,M){if($.tableCellIndex.has(M.id))return"tableCell";return u$(M.blockType)}function b5($,M){if(M.length===0)return[];let J=_5($),Z=J.list();return M.map((X)=>({...X,cursorPoint:ID(X,Z,J),viewport:null}))}function ID($,M,J){if(!$.cursor)return null;let Z=pD(M,$.cursor),X=lD(Z,$.cursor);if(X.length!==1)return null;let D=X[0],Y=J.resolveRuntimeContainer(D.container.id);if(!Y)return null;return{offset:Math.max(0,Math.min(D.offset,Y.text.length)),regionId:Y.id}}function pD($,M){return M.kind?$.filter((J)=>J.containerKind===M.kind):$}function lD($,M){if(M.prefix&&M.suffix)return rD($,M.prefix,M.suffix);if(M.prefix)return I9($,M.prefix,"after");if(M.suffix)return I9($,M.suffix,"before");return[]}function I9($,M,J){let Z=[];for(let X of $)for(let D of u0(X.text,M))Z.push({container:X,offset:J==="after"?D+M.length:D});return Z}function rD($,M,J){let Z=[];for(let X of $)for(let D of l1(X.text,M,J))Z.push({container:X,offset:D.startOffset});return Z}var cD=48;function m2($,M,J){let Z="documentIndex"in $?$.documentIndex:$;if(J.length===0)return[];return J.map((X)=>({...X,viewport:xD(Z,M,X)}))}function xD($,M,J){if(!J.cursorPoint)return{status:"unresolved"};let Z=v0(M.layout,$,J.cursorPoint),X=Z?{bottom:Z.top+Z.height,top:Z.top}:M.estimateRegionBounds(J.cursorPoint.regionId);if(!X)return{status:"unresolved"};return{scrollTop:aD(M,X),status:dD(M,X)}}function dD($,M){let J=$.viewport.top,Z=J+$.viewport.height;if(M.bottom<J)return"above";if(M.top>Z)return"below";return"visible"}function aD($,M){let J=Math.max(0,$.totalHeight-$.viewport.height),Z=M.top-Math.min(cD,$.viewport.height/4);return Math.max(0,Math.min(J,Z))}function _5($){let M=X5($.document),J=new Map(M.map((X)=>[X.id,X])),Z=new Map($.regions.map((X)=>[X.semanticRegionId,X]));return{findBySemanticMatch(X,D){let Y=J.get(X)??M[D]??null;if(!Y)return null;return{runtimeContainer:Z.get(Y.id)??null,semanticContainer:Y}},list(X){return X?M.filter((D)=>D.containerKind===X):M},resolveRuntimeContainer(X){return Z.get(X)??null}}}var S2="",p9=1e6;function u2($,M,J){return`${$}:${M}:${J}`}function Q0($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&Z.marks.join(",")===J.marks.join(",")){M[M.length-1]=H0({marks:Z.marks,path:Z.id,text:Z.text+J.text});continue}M.push(J)}return M}function e1($){let M=UY($),J=P6(M.blocks.map((Z,X)=>h2(Z,X)));return z6(M,J)}function h2($,M){let J=[],Z=[],X=[],D=0;function Y(K,q,U,N,A=null){if(Z.length>0)X.push(`
|
|
20
|
-
`),
|
|
21
|
-
${M.text}`:M.text}function
|
|
22
|
-
`)}function
|
|
23
|
-
`});break;case"image":X({id:
|
|
24
|
-
`.slice(M,J);case"image":return S2.slice(M,J);case"inlineCode":return $.code.slice(M,J);case"link":return E6($.children,M,J);case"text":return $.text.slice(M,J);case"unsupported":return $.source.slice(M,J)}}function y6($,M,J,Z){let X=GY($.children,M,J,Z);if(X===null)return null;let D=Q0(d9($.children,M,J,Z,X,`${$.path}.children`));return D.length>0?q1($,D,M,J):null}function w6($,M,J){let Z=0,X=null,D=(Y)=>{for(let Q of Y){let K=b0(Q),q=Z,U=q+K;if(Z=U,J<=q||M>=U)continue;if(Q.type==="text"){let N=Math.max(M,q);if(Math.min(J,U)>N)X=X===null?new Set(Q.marks):new Set(Q.marks.filter((V)=>X?.has(V)));continue}if(Q.type==="link"){let N=Z;Z=q,D(Q.children),Z=N}}};return D($.children),X?[...X]:[]}function GY($,M,J,Z){let X=0,D=!1,Y=!0,Q=(K)=>{for(let q of K){let U=b0(q),N=X,A=N+U;if(X=A,J<=N||M>=A)continue;if(q.type==="text"){let V=Math.max(M,N);if(Math.min(J,A)>V)D=!0,Y&&=q.marks.includes(Z);continue}if(q.type==="link"){let V=X;X=N,Q(q.children),X=V}}};return Q($),D?Y:null}function d9($,M,J,Z,X,D){let Y=[],Q=0;for(let[K,q]of $.entries()){let U=Q,N=b0(q),A=U+N,V=`${D}.${K}`;if(Q=A,J<=U||M>=A){Y.push(q);continue}if(q.type==="text"){Y.push(...BY(q,Math.max(0,M-U),Math.min(N,J-U),Z,X,V));continue}if(q.type==="link"){let B=Q0(d9(q.children,Math.max(0,M-U),Math.min(N,J-U),Z,X,`${V}.children`));if(B.length>0)Y.push({...q,children:B});continue}Y.push(q)}return Y}function BY($,M,J,Z,X,D){let Y=$.text.slice(0,M),Q=$.text.slice(M,J),K=$.text.slice(J),q=X?$.marks.filter((U)=>U!==Z):FY($.marks,Z);return[T1(Y,$.marks,`${D}.before`),T1(Q,q,`${D}.selected`),T1(K,$.marks,`${D}.after`)].filter(Boolean)}function FY($,M){return $.includes(M)?$:[...$,M].sort()}function O6($,M,J){let Z=Q0(_Y($.children,M,J,`${$.path}.children`));return Z.length>0?q1($,Z,M,J):null}function _Y($,M,J,Z){let X=i9($,M,J);if(X)return a9($,M,J,X.code,Z,!1);let D=E6($,M,J);if(D.length===0)return $;return a9($,M,J,D,Z,!0)}function i9($,M,J){let Z=0;for(let X of $){let D=b0(X),Y=Z,Q=Y+D;if(Z=Q,M===Y&&J===Q&&X.type==="inlineCode")return X;if(X.type==="link"){let K=i9(X.children,Math.max(0,M-Y),Math.min(D,J-Y));if(K)return K}}return null}function a9($,M,J,Z,X,D){let Y=[],Q=0,K=!1;for(let[q,U]of $.entries()){let N=`${X}.${q}`,A=b0(U),V=Q,B=V+A;if(Q=B,J<=V||M>=B){Y.push(U);continue}if(!K){Y.push(...z5(U,Math.max(0,M-V),N));let G=D?T6(Z,`${X}.selected`):T1(Z,[],`${X}.selected`);if(G)Y.push(G);K=!0}Y.push(...W5(U,Math.min(A,J-V),N))}return Y}function E5($,M,J,Z,X){return I2($,M,J,Z,(D,Y,Q)=>s9(D,Y,Q,X))}function s9($,M,J,Z){let X=Q0(bY($.children,M,J,Z,`${$.path}.children`)??[]);return X.length>0?q1($,X,M,J):null}function bY($,M,J,Z,X){let D=[],Y=0,Q=!1;for(let[K,q]of $.entries()){let U=`${X}.${K}`,N=b0(q),A=Y,V=A+N;if(Y=V,!Q&&q.type==="link"&&M===A&&J===V){if(Z===null)D.push(...q.children);else D.push(u1({children:q.children,path:U,title:q.title,url:Z}));Q=!0;continue}D.push(q)}return Q?D:null}function C6($,M,J){let Z=Q0(HY($.children,M,J,`${$.path}.children`));return q1($,Z,M+1,M+1)}function HY($,M,J,Z){let X=[],D=0,Y=!1;for(let[Q,K]of $.entries()){let q=`${Z}.${Q}`,U=b0(K),N=D,A=N+U;if(D=A,J<=N||M>=A){X.push(K);continue}if(!Y)X.push(...z5(K,Math.max(0,M-N),q)),X.push(P2({path:`${Z}.selected`})),Y=!0;X.push(...W5(K,Math.min(U,J-N),q))}if(!Y)X.push(P2({path:`${Z}.selected`}));return X}function X0($,M,J=0){return{childIndices:M,kind:"descendant-primary-region",offset:J,rootIndex:$}}function M0($,M=0){return{kind:"root-primary-region",offset:M,rootIndex:$}}function U1($,M,J,Z=0){return{cellIndex:J,kind:"table-cell",offset:Z,rootIndex:$,rowIndex:M}}function n0($,M){return $.regionIndex.get(M)??null}function t1($,M){return $.regionPathIndex.get(M)??null}function M2($,M,J,Z){let X=$.tableCellRegionIndex.get(u2(M,J,Z));return X?$.regionIndex.get(X)??null:null}function PY($){return $.anchor.regionId===$.focus.regionId&&$.anchor.offset===$.focus.offset}function n($,M){let J="documentIndex"in $?$.documentIndex:$,Z="documentIndex"in $?$.selection:M,X=PY(Z),D=o9(J,Z.anchor),Y=o9(J,Z.focus);if(D<=Y)return{collapsed:X,end:Z.focus,start:Z.anchor};return{collapsed:X,end:Z.anchor,start:Z.focus}}function p2($,M){if(!M)return null;if("kind"in M){if(M.kind==="root-primary-region"){let Z=$.document.blocks[M.rootIndex],X=Z?j6($,Z):null;return X?T5(X.id,y5(X.text,M.offset)):null}if(M.kind==="descendant-primary-region"){let Z=$.document.blocks[M.rootIndex],X=Z?zY(Z,M.childIndices):null,D=X?j6($,X):null;return D?T5(D.id,y5(D.text,M.offset)):null}if(M.kind==="table-cell"){let Z=$.document.blocks[M.rootIndex];if(!Z||Z.type!=="table")return null;let X=M2($,Z.id,M.rowIndex,M.cellIndex);return X?T5(X.id,y5(X.text,M.offset)):null}let J=t1($,M.path);if(!J)return null;if(M.kind==="region-path")return T5(J.id,y5(J.text,M.offset));return{anchor:{regionId:J.id,offset:Math.max(0,Math.min(M.startOffset,J.text.length))},focus:{regionId:J.id,offset:Math.max(0,Math.min(M.endOffset,J.text.length))}}}return M}function o9($,M){let J=$.regionOrderIndex.get(M.regionId);if(J===void 0)throw Error(`Unknown canvas region: ${M.regionId}`);return J*p9+M.offset}function T5($,M){let J={offset:M,regionId:$};return{anchor:J,focus:J}}function y5($,M){return M==="end"?$.length:Math.max(0,Math.min(M,$.length))}function zY($,M){let J=$;for(let Z of M){if(!J)return null;let X=n9(J);if(!X)return null;J=X[Z]??null}return J}function j6($,M){let J=$.blockIndex.get(M.id);if(!J)return null;let Z=J.regionIds[0];if(Z)return $.regionIndex.get(Z)??null;let X=n9(M);if(!X)return null;for(let D of X){let Y=j6($,D);if(Y)return Y}return null}function n9($){switch($.type){case"list":return $.items;case"blockquote":case"listItem":return $.children;default:return null}}function l2($){let M=$.documentIndex.regionIndex.get($.selection.anchor.regionId)??null,J=M?$.documentIndex.blockIndex.get(M.blockId)??null:null,Z=$.selection.anchor.offset,X=M?.inlines.find((D)=>Z>D.start&&Z<D.end)??M?.inlines.find((D)=>D.end===Z)??M?.inlines.find((D)=>D.start===Z)??null;return{block:J?{blockId:J.id,depth:J.depth,nodeType:J.type,text:M?.text??""}:null,span:X?.link?{kind:"link",url:X.link.url}:X&&X.marks.length>0?{kind:"marks",marks:X.marks}:{kind:"none"}}}function w5($){let M=n($.documentIndex,$.selection);if(M.start.regionId!==M.end.regionId||M.start.offset===M.end.offset)return[];let J=$.documentIndex.regionIndex.get(M.start.regionId);if(!J)return[];let Z=r1($.documentIndex.document.blocks,J.blockId);if(!Z)return[];let X=P5(Z,J.path,J.semanticRegionId);return X?w6(X,M.start.offset,M.end.offset):[]}function O5($,M,J,Z=null){return J2($,M,1,[J],Z)}function J2($,M,J,Z,X=null){return{document:I1($.document,M,J,Z),selection:X}}function C5($,M,J,Z=null){return r2($,M,()=>J,Z)}function r2($,M,J,Z=null){let X=$.blockIndex.get(M);if(!X)return null;let D=$.document.blocks[X.rootIndex];if(!D)return null;let Y=t9(D,M,J);return Y?J2($,X.rootIndex,1,[Y],Z):null}function t9($,M,J){if($.id===M)return J($);switch($.type){case"blockquote":{let Z=L6($.children,M,J);return Z?P0({children:Z}):null}case"listItem":{let Z=L6($.children,M,J);return Z?E0($,Z):null}case"list":{let Z=L6($.items,M,J);return Z?$0($,Z):null}default:return null}}function L6($,M,J){let Z=!1,X=$.map((D)=>{let Y=t9(D,M,J);if(!Y)return D;return Z=!0,Y});return Z?X:null}function L5($,M,J){let Z=n($,M);if(Z.start.regionId===Z.end.regionId)return WY($,Z,J);return wY($,Z,J)}function WY($,M,J){let Z=n0($,M.start.regionId);if(!Z)throw Error(`Unknown region: ${M.start.regionId}`);let X=r2($,Z.blockId,(q)=>EY(q,Z,M.start.offset,M.end.offset,J));if(!X)throw Error(`Failed to replace block for canvas region: ${Z.id}`);let D=$2($,X.document,Z.rootIndex,1),Y=$.document.comments.length===0?D:D7($,D,Z,M.start.offset,M.end.offset,J),Q=t1(Y,Z.path);if(!Q)throw Error(`Failed to remap region after replacement: ${Z.path}`);let K=M.start.offset+J.length;return{documentIndex:Y,selection:Y7(Q.id,K)}}function EY($,M,J,Z,X){switch($.type){case"heading":case"paragraph":return TY($,M,J,Z,X);case"code":return $5($,e9(M,J,Z,X));case"table":return yY($,M,J,Z,X);case"unsupported":return M5($,e9(M,J,Z,X));default:throw Error(`Canvas text replacement is not supported for block type: ${$.type}`)}}function TY($,M,J,Z,X){let D=x2(M.inlines,J,Z,X),Y=R5(D);return C0($,Y)}function yY($,M,J,Z,X){let D=M.tableCellPosition?.rowIndex,Y=M.tableCellPosition?.cellIndex;if(D===void 0||Y===void 0)throw Error(`Unable to resolve table cell position for region: ${M.id}`);let Q=x2(M.inlines,J,Z,X),K=R5(Q),q=$.rows.map((U,N)=>{if(N!==D)return U;let A=U.cells.map((V,B)=>{if(B!==Y)return V;return J1({children:K})});return{...U,cells:A}});return S0($,q)}function e9($,M,J,Z){return x2($.inlines,M,J,Z).map((X)=>X.text).join("")}function c2($){return $!==null&&($.type==="heading"||$.type==="paragraph")}function wY($,M,J){let Z=n0($,M.start.regionId),X=n0($,M.end.regionId);if(!Z||!X)throw Error("Unknown cross-region selection endpoints.");let D=$.document.blocks[Z.rootIndex],Y=$.document.blocks[X.rootIndex];if(!D||!Y)throw Error("Unknown root blocks for cross-region selection.");let Q=J7(D,Z,M.start.offset),K=Z7(Y,X,M.end.offset),q=OY(Q,K,J),U=q.blocks.length>0?q.blocks:[r({text:""})],N=Z.rootIndex,A=X.rootIndex-Z.rootIndex+1,V=I1($.document,N,A,U),B=$2($,V,N,A),G=$.document.comments.length===0?B:D7($,B,Z,M.start.offset,Z.text.length,c2(Q)?J:""),b=G.roots[N+q.caretLocalIndex]?.regions[0]??null;return{documentIndex:G,selection:Y7(b?.id??Z.id,b?q.caretOffset:0)}}function OY($,M,J){if(c2($)&&c2(M))return{blocks:[CY($,M,J)],caretLocalIndex:0,caretOffset:$.plainText.length+J.length};if(c2($)){let D=[J.length>0?jY($,J):$];if(M)D.push(M);return{blocks:D,caretLocalIndex:0,caretOffset:$.plainText.length+J.length}}if(c2(M)){let X=J.length>0?LY(M,J):M,D=[];if($)D.push($);let Y=D.length;return D.push(X),{blocks:D,caretLocalIndex:Y,caretOffset:J.length}}let Z=[];if($)Z.push($);if(J.length>0){let X=Z.length;if(Z.push(r({text:J})),M)Z.push(M);return{blocks:Z,caretLocalIndex:X,caretOffset:J.length}}if(M){let X=Z.length;return Z.push(M),{blocks:Z,caretLocalIndex:X,caretOffset:0}}return{blocks:Z,caretLocalIndex:0,caretOffset:0}}function CY($,M,J){let Z=J.length>0?[H0({text:J})]:[];return C0($,Q0([...$.children,...Z,...M.children]))}function jY($,M){return C0($,Q0([...$.children,H0({text:M})]))}function LY($,M){return C0($,Q0([H0({text:M}),...$.children]))}function J7($,M,J){if($.type==="table")return null;if($.id===M.blockId)return RY($,M,J);return X7($,(Z)=>fY(Z,M,J))}function Z7($,M,J){if($.type==="table")return null;if($.id===M.blockId)return kY($,M,J);return X7($,(Z)=>mY(Z,M,J))}function RY($,M,J){if(J===0)return null;switch($.type){case"heading":case"paragraph":{let Z=x2(M.inlines,J,M.text.length,"");return C0($,R5(Z))}case"code":return $5($,M.text.slice(0,J));case"unsupported":return M5($,M.text.slice(0,J));default:return null}}function kY($,M,J){if(J===M.text.length)return null;switch($.type){case"heading":case"paragraph":{let Z=x2(M.inlines,0,J,"");return C0($,R5(Z))}case"code":return $5($,M.text.slice(J));case"unsupported":return M5($,M.text.slice(J));default:return null}}function X7($,M){switch($.type){case"blockquote":{let J=M($.children);return J.length===0?null:P0({children:J})}case"list":{let J=M($.items);return J.length===0?null:$0($,J)}case"listItem":{let J=M($.children);return J.length===0?null:E0($,J)}default:return null}}function fY($,M,J){let Z=$.findIndex((Y)=>j5(Y,M));if(Z===-1)return[];let X=$.slice(0,Z),D=J7($[Z],M,J);return D?[...X,D]:X}function mY($,M,J){let Z=$.findIndex((Y)=>j5(Y,M));if(Z===-1)return[];let X=$.slice(Z+1),D=Z7($[Z],M,J);return D?[D,...X]:X}function j5($,M){if($.id===M.blockId)return!0;switch($.type){case"blockquote":case"listItem":return $.children.some((J)=>j5(J,M));case"list":return $.items.some((J)=>j5(J,M));default:return!1}}function D7($,M,J,Z,X,D){let Y=b6($,M,J,Z,X,D);return Y===M.document.comments?M:g2(M,{...M.document,comments:Y})}function Y7($,M){return{anchor:{regionId:$,offset:M},focus:{regionId:$,offset:M}}}function x2($,M,J,Z){let D=SY($,M,J,{didInsert:!1,generatedRunCount:0,replacementText:Z});return IY(pY(D))}function R5($){let M=[];for(let J=0;J<$.length;J+=1){let Z=$[J];if(Z.link){let D=[],Y=Z.link;while(J<$.length&&k6($[J].link,Y)){let Q=M7($[J]);if(Q)D.push(Q);J+=1}if(J-=1,D.length>0)M.push(u1({children:Q0(D),title:Y.title,url:Y.url}));continue}let X=M7(Z);if(X)M.push(X)}return Q0(M)}function SY($,M,J,Z){let X=[];for(let[D,Y]of $.entries()){if(!Z.didInsert&&M===J&&M===Y.start)R6(X,Z,$7($[D-1]??null,Y));if(J<=Y.start||M>=Y.end){X.push(k5(Y));continue}let Q=Math.max(0,M-Y.start),K=Math.min(Y.text.length,J-Y.start),q=!Z.didInsert&&Z.replacementText.length>0?Z.replacementText:"",U=uY(Y,Q,K,q,Z);if(Q!==K||q.length>0)Z.didInsert=!0;X.push(...U)}if(!Z.didInsert)R6(X,Z,$7($.at(-1)??null,null));return X}function uY($,M,J,Z,X){switch($.kind){case"text":case"inlineCode":case"unsupported":return vY($,M,J,Z);case"break":return hY($,M,J,Z,X);case"image":return gY($,M,J,Z)}}function vY($,M,J,Z){let X=$.text.slice(0,M)+Z+$.text.slice(J);return X.length>0?[{...k5($),text:X}]:[]}function hY($,M,J,Z,X){if(M===J)return[k5($)];let D=[];if(Z.length>0)R6(D,X,$.link);return D}function gY($,M,J,Z){if(M===0&&J===$.text.length)return Z.length>0?[Q7(Z,$.link,0)]:[];return[k5($)]}function R6($,M,J){if(M.replacementText.length===0){M.didInsert=!0;return}$.push(Q7(M.replacementText,J,M.generatedRunCount)),M.generatedRunCount+=1,M.didInsert=!0}function Q7($,M,J){return{id:`generated:${J}`,image:null,inlineCode:!1,kind:"text",link:M,marks:[],originalType:null,text:$}}function $7($,M){return $?.link&&M?.link&&k6($.link,M.link)?$.link:null}function k5($){return{id:$.id,image:$.image,inlineCode:$.inlineCode,kind:$.kind,link:$.link,marks:$.marks,originalType:$.originalType,text:$.text}}function IY($){let M=[],J=0;for(let Z of $){let X=J,D=X+Z.text.length;M.push({...Z,end:D,start:X}),J=D}return M}function pY($){let M=[];for(let J of $){let Z=M.at(-1);if(Z&&lY(Z,J)){M[M.length-1]={...Z,text:Z.text+J.text};continue}M.push(J)}return M}function lY($,M){return $.kind===M.kind&&$.inlineCode===M.inlineCode&&k6($.link,M.link)&&cY($.image,M.image)&&$.originalType===M.originalType&&$.marks.join(",")===M.marks.join(",")}function M7($){switch($.kind){case"break":return P2();case"image":return $.image?rY($.image):null;case"inlineCode":return S1({code:$.text});case"text":return $.text.length>0?H0({marks:$.marks,text:$.text}):null;case"unsupported":return n4({originalType:$.originalType??"unsupported",source:$.text})}}function rY($){return o4({alt:$.alt,title:$.title,url:$.url,width:$.width})}function k6($,M){return $?.url===M?.url&&$?.title===M?.title}function cY($,M){return $?.url===M?.url&&$?.title===M?.title&&$?.alt===M?.alt&&$?.width===M?.width}function K7($,M){switch(M.kind){case"replace-block":return C5($,M.blockId,M.block,M.selection??null);case"replace-root":return O5($,M.rootIndex,M.block,M.selection??null);case"replace-root-range":return J2($,M.rootIndex,M.count,M.replacements,M.selection??null);case"replace-selection":{let J=L5($,M.selection,M.text);return{document:J.documentIndex.document,documentIndex:J.documentIndex,selection:J.selection}}}return null}var f6=new Map([["rgba(0, 0, 0, 0)",[0,0,0,0]]]);function d2($){switch($.kind){case"active-block-flash":return 300;case"deleted-text-fade":return 180;case"inserted-text-highlight":return 1000;case"list-marker-pop":return 500;case"punctuation-pulse":return 140}}function S6($,M){let J=M??dY();return $.animations.some((Z)=>J-Z.startedAt<d2(Z))}function U7($,M){return u6($,M,"inserted-text-highlight",(J)=>J.regionPath)}function N7($,M){return z7($,M,"active-block-flash",(J)=>J.blockPath)}function A7($,M){return u6($,M,"deleted-text-fade",(J)=>J.regionPath)}function V7($,M){return u6($,M,"punctuation-pulse",(J)=>J.regionPath)}function G7($,M){return z7($,M,"list-marker-pop",(J)=>J.blockPath)}function B7($,M,J){let Z=new Set([$,M]);for(let X of J){if(X.endOffset<=$||X.startOffset>=M)continue;Z.add(Math.max($,X.startOffset)),Z.add(Math.min(M,X.endOffset))}return[...Z].sort((X,D)=>X-D)}function F7($,M,J){return $.find((Z)=>Z.startOffset<J&&Z.endOffset>M)??null}function _7($,M,J){if(!M)return $;return i2(J.insertHighlightText,$,M.progress)}function b7($,M){return i2($,"rgba(0, 0, 0, 0)",M.progress)}function m5($,M){return i2($,"rgba(0, 0, 0, 0)",M.progress)}function H7($,M){return i2(M.insertHighlightText,"rgba(0, 0, 0, 0)",$.progress)}function P7($){let M=Math.min(1,$.progress*2);return 0.1+0.9*xY(M)}function a2($,M,J){let Z=Math.max(0,M.progress*2-1);return i2(J.insertHighlightText,$,Z)}function u6($,M,J,Z){let X=new Map;for(let D of $.animations){if(D.kind!==J)continue;let Y=d2(D),Q=M-D.startedAt;if(Q>=Y)continue;let K={...D,progress:Math.max(0,Math.min(1,Q/Y))},q=Z(D),U=X.get(q);if(U)U.push(K);else X.set(q,[K])}return X}function z7($,M,J,Z){let X=new Map;for(let D of $.animations){if(D.kind!==J)continue;let Y=d2(D),Q=M-D.startedAt;if(Q>=Y)continue;X.set(Z(D),{...D,progress:Math.max(0,Math.min(1,Q/Y))})}return X}function xY($){return 1-(1-$)*(1-$)*(1-$)}function i2($,M,J){let Z=q7($),X=q7(M);return`rgba(${m6(f5(Z[0],X[0],J))}, ${m6(f5(Z[1],X[1],J))}, ${m6(f5(Z[2],X[2],J))}, ${f5(Z[3],X[3],J)})`}function dY(){return typeof performance<"u"?performance.now():Date.now()}function q7($){let M=f6.get($);if(M)return M;let J=aY($)??iY($)??sY($)??f6.get("rgba(0, 0, 0, 0)");return f6.set($,J),J}function aY($){let M=$.trim();if(!M.startsWith("#"))return null;let J=M.slice(1);if(J.length===3)return[Number.parseInt(`${J[0]}${J[0]}`,16),Number.parseInt(`${J[1]}${J[1]}`,16),Number.parseInt(`${J[2]}${J[2]}`,16),1];if(J.length===6)return[Number.parseInt(J.slice(0,2),16),Number.parseInt(J.slice(2,4),16),Number.parseInt(J.slice(4,6),16),1];return null}function iY($){let M=/^rgb\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec($.trim());if(!M)return null;return[Number(M[1]),Number(M[2]),Number(M[3]),1]}function sY($){let M=/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec($.trim());if(!M)return null;return[Number(M[1]),Number(M[2]),Number(M[3]),Number(M[4])]}function f5($,M,J){return $+(M-$)*J}function m6($){return Math.round($)}function S5($,M,J=N1()){if(M<=0)return $;let Z=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!Z)return $;let X=$.selection.focus.offset,D=Math.max(0,X-M);if(X<=D)return $;return s2($,{endOffset:X,kind:"inserted-text-highlight",regionPath:Z.path,startOffset:D,startedAt:J})}function v6($,M,J=N1()){if(M.text.length===0)return $;return s2($,{kind:"deleted-text-fade",regionPath:M.regionPath,startOffset:M.startOffset,startedAt:J,text:M.text})}function h6($,M,J=N1()){return s2($,{blockPath:M,kind:"active-block-flash",startedAt:J})}function g6($,M=N1()){let J=$.documentIndex.regionIndex.get($.selection.focus.regionId),Z=$.selection.focus.offset-1;if(!J||Z<0||J.text[Z]!==".")return $;return s2($,{kind:"punctuation-pulse",offset:Z,regionPath:J.path,startedAt:M})}function I6($,M,J=N1()){return s2($,{blockPath:M,kind:"list-marker-pop",startedAt:J})}function s2($,M){let J=u5($.animations,M.startedAt);return{...$,animations:[...J,M]}}function u5($,M){return $.filter((J)=>J.startedAt+d2(J)>M)}function N1(){return typeof performance<"u"?performance.now():Date.now()}function W7($){let M=$.documentIndex.regionIndex.get($.selection.focus.regionId);return(M?$.documentIndex.blockIndex.get(M.blockId)??null:null)?.path??""}function v5($,M){let J=Math.max(-1/0,...$.animations.map((Z)=>Z.startedAt));return M.animations.some((Z)=>Z.startedAt>J)}function o2($){let M=e1($),J=T7(M);return{animations:[],documentIndex:M,future:[],history:[],selection:{anchor:J,focus:J}}}function I0($){let M=L0($.documentIndex);return g1(z2($.documentIndex.document.blocks),M.threads,$.documentIndex.document.frontMatter)}function s($,M){if(!M)return null;switch(M.kind){case"keep-state":return $;case"set-selection":return D0($,M.selection);default:{let J=K7($.documentIndex,M);if(!J)return null;let Z=oY($,J.document,J.documentIndex??null),X=p2(Z.documentIndex,J.selection)??$.selection,D=y7($,Z,X);return D0(Z,X,D)}}}function D0($,M,J){let Z="regionId"in M?{anchor:h5($.documentIndex,M),focus:h5($.documentIndex,M)}:{anchor:h5($.documentIndex,M.anchor),focus:h5($.documentIndex,M.focus)},X={...$,selection:Z};return J??y7($,X)?h6(X,W7(X)):X}function y0($,M,J,Z){let X={regionId:M,offset:J};return D0($,Z?{anchor:$.selection.anchor,focus:X}:X)}function oY($,M,J=null){let Z=J??e1(M);return{animations:u5($.animations,N1()),documentIndex:Z,future:[],history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:nY(Z)}}function p6($){let M=$.history.at(-1);if(!M)return $;let J=e1(M.document);return{animations:[],documentIndex:J,future:[{document:$.documentIndex.document,selection:$.selection},...$.future],history:$.history.slice(0,-1),selection:M.selection}}function l6($){let M=$.future[0];if(!M)return $;let J=e1(M.document);return{animations:[],documentIndex:J,future:$.future.slice(1),history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:M.selection}}function g5($,M,J,Z){let X=L$($.documentIndex.document,M,J,Z),D=g2($.documentIndex,X);return{animations:u5($.animations,N1()),documentIndex:D,future:[],history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:$.selection}}function nY($){let M=T7($);return{anchor:M,focus:M}}function T7($){return $.regions[0]?{regionId:$.regions[0].id,offset:0}:{regionId:"empty",offset:0}}function h5($,M){let J=n0($,M.regionId);if(!J)return M;return{regionId:J.id,offset:Math.max(0,Math.min(M.offset,J.text.length))}}function y7($,M,J){let Z=E7($.documentIndex,$.selection),X=E7(M.documentIndex,J??M.selection);return X!==null&&X!==Z}function E7($,M){let J=$.regionIndex.get(M.focus.regionId),Z=J?$.blockIndex.get(J.blockId)??null:null;if(!J||!Z?.path)return null;return Z.type==="table"?`cell:${J.path}`:`block:${Z.path}`}function e2($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return{kind:"unsupported"};if(J.blockType==="code"){let Q=$.blockIndex.get(J.blockId);return Q?{kind:"code",region:J,rootIndex:Q.rootIndex}:{kind:"unsupported"}}let Z=A1($,J.id);if(Z)return{kind:"tableCell",...Z};let X=l0($,M);if(X)return{kind:"listItem",...X};let D=Z2($,M);if(D)return{kind:"blockquoteTextBlock",...D};let Y=p0($,M);if(Y)return{kind:"rootTextBlock",...Y};return{kind:"unsupported"}}function $4($,M){let J=$.blockIndex.get(M);if(!J)throw Error(`Unknown root block: ${M}`);return J.rootIndex}function I5($,M,J){let Z=M?$.blockIndex.get(M)??null:null;while(Z){if(Z.type===J)return Z;let X=Z.parentBlockId;Z=X?$.blockIndex.get(X)??null:null}return null}function n2($){let M=$.split("."),J=[];for(let Z=0;Z<M.length-1;Z+=1)if(M[Z]==="children"){let X=Number(M[Z+1]);if(Number.isInteger(X))J.push(X)}return J}function p0($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId);if(!Z)return null;let X=Z.rootIndex,D=$.document.blocks[X];if(!D||D.type!=="heading"&&D.type!=="paragraph")return null;return{block:D,region:J,rootIndex:X}}function w7($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=I5($,Z?.id??null,"blockquote");if(!X)return null;let D=X.rootIndex,Y=$.document.blocks[D];return Y?.type==="blockquote"?{quote:Y,rootIndex:D}:null}function Z2($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=I5($,Z?.id??null,"blockquote");if(!Z||!X||Z.parentBlockId!==X.id)return null;let D=X.rootIndex,Y=$.document.blocks[D];if(!Y||Y.type!=="blockquote")return null;let Q=Y.children.findIndex((q)=>q.id===Z.id),K=Y.children[Q];if(!K||K.type!=="heading"&&K.type!=="paragraph")return null;return{block:K,blockChildIndices:n2(Z.path),childIndex:Q,region:J,quote:Y,rootIndex:D}}function t2($,M){return r1($.document.blocks,M)}function l0($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=I5($,Z?.id??null,"listItem"),D=I5($,Z?.id??null,"list");if(!Z||!X||!D)return null;let Y=t2($,D.id);if(!Y||Y.type!=="list")return null;let Q=Y.items.findIndex((B)=>B.id===X.id),K=Y.items[Q];if(!K)return null;let q=D.parentBlockId?$.blockIndex.get(D.parentBlockId)??null:null,U=q?.parentBlockId?$.blockIndex.get(q.parentBlockId)??null:null,N=q?.type==="listItem"?t2($,q.id):null,A=U?.type==="list"?t2($,U.id):null,V=A?.type==="list"&&N?A.items.findIndex((B)=>B.id===N.id):-1;return{region:J,item:K,itemChildIndices:n2(X.path),itemIndex:Q,list:Y,listChildIndices:n2(D.path),parentItem:N?.type==="listItem"?N:null,parentItemChildIndices:q?.type==="listItem"?n2(q.path):null,parentItemIndex:V>=0?V:null,parentList:A?.type==="list"?A:null,parentListChildIndices:U?.type==="list"?n2(U.path):null,rootIndex:D.rootIndex}}function A1($,M){let J=$.regionIndex.get(M);if(!J)return null;let Z=$.tableCellIndex.get(J.id),X=$.blockIndex.get(J.blockId),D=X?.type==="table"?$.document.blocks[X.rootIndex]:null;if(!Z||!X||!D||D.type!=="table")return null;return{cellIndex:Z.cellIndex,rootIndex:X.rootIndex,rowIndex:Z.rowIndex,table:D}}function M4($,M,J){return d0({checked:M,children:[r({text:$})],spread:J})}function X2($,M){let J=$.children[0];if(!J||J.type!=="paragraph")return null;return E0($,[r({text:M}),...$.children.slice(1)])}function O7($,M){return M.reduce((J,Z)=>`${J}.children.${Z}`,`root.${$}`)}function C7($,M,J){let Z=$.regionIndex.get(M.anchor.regionId);if(!Z)return null;let X=n($,M),D=X.start.regionId===X.end.regionId&&X.start.regionId===Z.id?Z.text.slice(0,X.start.offset)+J+Z.text.slice(X.end.offset):J;return tY($,M,Z.id,D)??$Q($,M,Z.id,D)??eY($,M,Z.id,D)??MQ($,M,Z.id,D)??XQ($,Z.blockId,Z.rootIndex,D)??{kind:"replace-selection",selection:M,text:J}}function tY($,M,J,Z){let X=l0($,M),D=QQ(Z);if(!X||!D||X.region.id!==J)return null;let Y=X2(X.item,D.text);if(!Y)return null;return{kind:"replace-block",block:$0(X.list,X.list.items.map((Q,K)=>K===X.itemIndex?Y:Q),{ordered:D.ordered,start:D.ordered?1:null}),blockId:X.list.id,selection:X0(X.rootIndex,[...X.listChildIndices,X.itemIndex,0])}}function eY($,M,J,Z){if(!c6($,M,J))return null;if(/^\s*([-+*])\s\[( |x|X)\]\s$/.exec(Z)){let Y=Z.toLowerCase().includes("[x]");return r6($,M,{checked:Y,ordered:!1,start:null})}if(/^\s*[-+*]\s$/.test(Z))return r6($,M,{checked:null,ordered:!1,start:null});let D=/^\s*(\d+)\.\s$/.exec(Z);if(D)return r6($,M,{checked:null,ordered:!0,start:Number(D[1])});return null}function $Q($,M,J,Z){let X=p0($,M),D=KQ(Z);if(!X||X.region.id!==J||X.block.type!=="heading"||!D)return null;return{kind:"replace-root",block:M1({depth:D.depth,text:D.text}),rootIndex:X.rootIndex,selection:M0(X.rootIndex)}}function MQ($,M,J,Z){return JQ($,M,J,Z)??ZQ($,M,J,Z)}function JQ($,M,J,Z){if(!c6($,M,J))return null;let X=/^(#{1,6})\s$/.exec(Z);if(!X)return null;return DQ($,M,X[1].length)}function ZQ($,M,J,Z){if(!c6($,M,J)||!/^>\s$/.test(Z))return null;return YQ($,M)}function XQ($,M,J,Z){if(!/^(?:(?:-\s?){3}|(?:\*\s?){3}|(?:_\s?){3})$/.test(Z))return null;return{kind:"replace-root-range",count:1,replacements:[t4(),r({text:""})],rootIndex:$4($,M),selection:M0(J+1)}}function r6($,M,J){let Z=$4($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:P1({items:[d0({checked:J.checked,children:[r({text:""})],spread:!1})],ordered:J.ordered,spread:!1,start:J.start}),rootIndex:Z,selection:X0(Z,[0,0])}}function DQ($,M,J){let Z=$4($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:M1({depth:J,text:""}),rootIndex:Z,selection:M0(Z)}}function YQ($,M){let J=$4($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:P0({children:[r({text:""})]}),rootIndex:J,selection:X0(J,[0])}}function c6($,M,J){let Z=p0($,M);return Z?.region.id===J&&Z.block.type==="paragraph"}function QQ($){let M=/^[-+*]\s(.+)$/.exec($);if(M)return{ordered:!1,text:M[1]};let J=/^\d+\.\s(.+)$/.exec($);if(J)return{ordered:!0,text:J[1]};return null}function KQ($){let M=/^(#{1,6})\s(.+)$/.exec($);return M?{depth:M[1].length,text:M[2]}:null}function j7($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let Z=l0($,M);if(!Z)return null;let X=Z.region.text,D=Z.item,Y=typeof D.checked==="boolean"?!1:D.checked;if(J.start.offset===0){let N=M4("",Y,D.spread);return{kind:"replace-block",block:$0(Z.list,[...Z.list.items.slice(0,Z.itemIndex),N,D,...Z.list.items.slice(Z.itemIndex+1)]),blockId:Z.list.id,listItemInsertedPath:p5(N,Z.rootIndex,[...Z.listChildIndices,Z.itemIndex]),selection:X0(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex,0])}}if(J.start.offset===X.length){let N=M4("",Y,D.spread);return{kind:"replace-block",block:$0(Z.list,[...Z.list.items.slice(0,Z.itemIndex+1),N,...Z.list.items.slice(Z.itemIndex+1)]),blockId:Z.list.id,listItemInsertedPath:p5(N,Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1]),selection:X0(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1,0])}}let Q=X.slice(0,J.start.offset),K=X.slice(J.start.offset),q=M4(K,Y,D.spread),U=E0(D,[r({text:Q})]);return{kind:"replace-block",block:$0(Z.list,[...Z.list.items.slice(0,Z.itemIndex),U,q,...Z.list.items.slice(Z.itemIndex+1)]),blockId:Z.list.id,listItemInsertedPath:p5(q,Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1]),selection:X0(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1,0])}}function L7($,M){let J=n($,M),Z=l0($,M);if(!Z||J.start.regionId!==J.end.regionId)return null;if(J.start.offset!==0||Z.region.text.length!==0)return j7($,M);if(Z.parentItem&&Z.parentItemIndex!==null&&Z.parentItemChildIndices&&Z.parentList&&Z.parentListChildIndices)return qQ(Z);let X=Z.list.items.slice(0,Z.itemIndex),D=Z.list.items.slice(Z.itemIndex+1),Y=[];if(X.length>0)Y.push($0(Z.list,X));if(Y.push(r({text:""})),D.length>0)Y.push($0(Z.list,D));return{kind:"replace-root-range",count:1,replacements:Y,rootIndex:Z.rootIndex,selection:M0(Z.rootIndex+(X.length>0?1:0))}}function R7($,M){let J=l0($,M);if(!J)return null;if(typeof J.item.checked==="boolean"){let Z=d0({checked:null,children:J.item.children,spread:J.item.spread});return{kind:"replace-block",block:$0(J.list,J.list.items.map((X,D)=>D===J.itemIndex?Z:X)),blockId:J.list.id}}if(J.itemIndex>0){let Z=J.list.items[J.itemIndex-1];if(!Z)return null;if(J.item.plainText.length===0)return{kind:"replace-block",block:$0(J.list,J.list.items.filter((D,Y)=>Y!==J.itemIndex)),blockId:J.list.id,selection:X0(J.rootIndex,[...J.listChildIndices,J.itemIndex-1,0],"end")};let X=X2(Z,`${Z.plainText}${J.item.plainText}`);if(!X)return null;return{kind:"replace-block",block:$0(J.list,J.list.items.flatMap((D,Y)=>{if(Y===J.itemIndex-1)return[X];if(Y===J.itemIndex)return[];return[D]})),blockId:J.list.id,selection:X0(J.rootIndex,[...J.listChildIndices,J.itemIndex-1,0],"end")}}return{kind:"replace-root-range",count:1,replacements:[r({text:J.item.plainText})],rootIndex:J.rootIndex,selection:M0(J.rootIndex)}}function k7($,M){let J=l0($,M);if(!J||J.itemIndex===0)return null;let Z=J.list.items[J.itemIndex-1];if(!Z)return null;let X=UQ(Z,J.item,J);return{kind:"replace-block",block:$0(J.list,J.list.items.flatMap((D,Y)=>{if(Y===J.itemIndex-1)return[X.item];if(Y===J.itemIndex)return[];return[D]})),blockId:J.list.id,selection:X0(J.rootIndex,X.regionChildIndices)}}function f7($,M){let J=l0($,M);if(!J||!J.parentItem||J.parentItemIndex===null||!J.parentItemChildIndices||!J.parentList||!J.parentListChildIndices)return null;let Z=J.list.items.filter((Y,Q)=>Q!==J.itemIndex),X=J.parentItem.children.flatMap((Y)=>{if(Y.type!=="list"||Y.id!==J.list.id)return[Y];if(Z.length===0)return[];return[$0(J.list,Z)]}),D=E0(J.parentItem,X);return{kind:"replace-block",block:$0(J.parentList,[...J.parentList.items.slice(0,J.parentItemIndex),D,J.item,...J.parentList.items.slice(J.parentItemIndex+1)]),blockId:J.parentList.id,selection:X0(J.rootIndex,[...J.parentListChildIndices,J.parentItemIndex+1,0])}}function x6($,M,J){let Z=l0($,M);if(!Z)return null;let X=Z.itemIndex+J;if(X<0||X>=Z.list.items.length)return null;let D=[...Z.list.items],[Y]=D.splice(Z.itemIndex,1);if(!Y)return null;return D.splice(X,0,Y),{kind:"replace-block",block:$0(Z.list,D),blockId:Z.list.id,selection:X0(Z.rootIndex,[...Z.listChildIndices,X,0])}}function qQ($){if(!$.parentItem||$.parentItemIndex===null||!$.parentItemChildIndices||!$.parentList||!$.parentListChildIndices)return null;let M=$.list.items.filter((Y,Q)=>Q!==$.itemIndex),J=$.parentItem.children.flatMap((Y)=>{if(Y.type!=="list"||Y.id!==$.list.id)return[Y];if(M.length===0)return[];return[$0($.list,M)]}),Z=E0($.parentItem,J),X=typeof $.parentItem.checked==="boolean"?!1:$.parentItem.checked,D=M4("",X,$.parentItem.spread);return{kind:"replace-block",block:$0($.parentList,[...$.parentList.items.slice(0,$.parentItemIndex),Z,D,...$.parentList.items.slice($.parentItemIndex+1)]),blockId:$.parentList.id,listItemInsertedPath:p5(D,$.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1]),selection:X0($.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1,0])}}function p5($,M,J){return typeof $.checked==="boolean"?void 0:O7(M,J)}function UQ($,M,J){let Z=$.children.findIndex((D)=>D.type==="list"&&D.ordered===J.list.ordered&&D.start===J.list.start);if(Z>=0){let D=$.children[Z];if(!D||D.type!=="list")return{item:$,regionChildIndices:[...J.listChildIndices,J.itemIndex-1,0]};return{item:E0($,$.children.map((Y,Q)=>Q===Z?$0(D,[...D.items,M]):Y)),regionChildIndices:[...J.listChildIndices,J.itemIndex-1,Z,D.items.length,0]}}let X=P1({items:[M],ordered:J.list.ordered,spread:J.list.spread,start:J.list.start});return{item:E0($,[...$.children,X]),regionChildIndices:[...J.listChildIndices,J.itemIndex-1,$.children.length,0,0]}}function l5($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let Z=p0($,M);if(!Z)return NQ($,M);let X=Z.region.text.slice(0,J.start.offset),D=Z.region.text.slice(J.start.offset),Y=J.start.offset===0&&Z.region.text.length>0?Z.rootIndex:Z.rootIndex+1;if(Z.block.type==="paragraph")return{kind:"replace-root-range",count:1,replacements:J.start.offset===0?[r({text:""}),Z.block]:J.start.offset===Z.region.text.length?[Z.block,r({text:""})]:[r({text:X}),r({text:D})],rootIndex:Z.rootIndex,selection:M0(Y)};return{kind:"replace-root-range",count:1,replacements:J.start.offset===0?[r({text:""}),Z.block]:J.start.offset===Z.region.text.length?[Z.block,r({text:""})]:[M1({depth:Z.block.depth,text:X}),r({text:D})],rootIndex:Z.rootIndex,selection:M0(Y)}}function NQ($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let Z=Z2($,M);if(!Z)return null;let X=Z.region.text,D=X.slice(0,J.start.offset),Y=X.slice(J.start.offset),Q=Z.block.type==="heading"?_Q(Z.block,D,Y,Z.blockChildIndices,J.start.offset,X.length):FQ(Z.block,D,Y,Z.blockChildIndices,J.start.offset,X.length);return{kind:"replace-root",block:P0({children:[...Z.quote.children.slice(0,Z.childIndex),...Q.blocks,...Z.quote.children.slice(Z.childIndex+1)]}),rootIndex:Z.rootIndex,selection:X0(Z.rootIndex,Q.focusChildIndices)}}function m7($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;let Z=Z2($,M);if(!Z||Z.region.text.length!==0||Z.block.type!=="paragraph")return null;let X=Z.quote.children.slice(0,Z.childIndex),D=Z.quote.children.slice(Z.childIndex+1),Y=[];if(X.length>0)Y.push(P0({children:X}));if(Y.push(r({text:""})),D.length>0)Y.push(P0({children:D}));return{kind:"replace-root-range",count:1,replacements:Y,rootIndex:Z.rootIndex,selection:M0(Z.rootIndex+(X.length>0?1:0))}}function S7($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.regionId!==M.anchor.regionId)return null;let Z=$.regionIndex.get(J.start.regionId);if(!Z||Z.blockType!=="code")return null;return{kind:"replace-selection",selection:M,text:`
|
|
25
|
-
`}}function u7($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;let Z=p0($,M),X=Z?GQ(Z):null;if(X)return X;if(Z&&Z.rootIndex>0){let K=$.document.blocks[Z.rootIndex-1],q=$.document.blocks[Z.rootIndex+1];if(K){if(Z.block.plainText.length===0){let U=AQ(Z,K,q);if(U)return U;return{kind:"replace-root-range",count:1,replacements:[],rootIndex:Z.rootIndex,selection:K.type==="paragraph"||K.type==="heading"?M0(Z.rootIndex-1,"end"):K.type==="list"?X0(Z.rootIndex-1,[K.items.length-1,0],"end"):K.type==="blockquote"?X0(Z.rootIndex-1,[K.children.length-1],"end"):M0(Z.rootIndex-1,"end")}}if(K.type==="paragraph")return{kind:"replace-root-range",count:2,replacements:[r({text:`${K.plainText}${Z.block.plainText}`})],rootIndex:Z.rootIndex-1,selection:M0(Z.rootIndex-1,"end")};if(K.type==="heading")return{kind:"replace-root-range",count:2,replacements:[M1({depth:K.depth,text:`${K.plainText}${Z.block.plainText}`})],rootIndex:Z.rootIndex-1,selection:M0(Z.rootIndex-1,"end")};if(K.type==="list"){let U=K.items.length-1,N=K.items[U];if(N){let A=X2(N,`${N.plainText}${Z.block.plainText}`);if(A)return{kind:"replace-root-range",count:2,replacements:[$0(K,K.items.map((V,B)=>B===U?A:V))],rootIndex:Z.rootIndex-1,selection:X0(Z.rootIndex-1,[U,0],"end")}}}}}let D=BQ($,M);if(D)return D;let Y=w7($,M);if(!Y)return null;let Q=Z2($,M);return{kind:"replace-root-range",count:1,replacements:Y.quote.children,rootIndex:Y.rootIndex,selection:M0(Q?Y.rootIndex+Q.childIndex:Y.rootIndex)}}function d6($,M,J){let Z=p0($,M);if(!Z||Z.block.type!=="heading")return null;let X=Math.max(1,Math.min(6,Z.block.depth+J));if(X===Z.block.depth)return{kind:"keep-state"};return{kind:"replace-root",block:M1({depth:X,text:Z.block.plainText}),rootIndex:Z.rootIndex,selection:M0(Z.rootIndex,M.focus.offset)}}function AQ($,M,J){if($.block.type!=="paragraph"||$.block.plainText.length!==0||M.type!=="list"||J?.type!=="list"||!VQ(M,J))return null;let Z=M.items.length-1;return{kind:"replace-root-range",count:3,replacements:[$0(M,[...M.items,...J.items])],rootIndex:$.rootIndex-1,selection:X0($.rootIndex-1,[Z,0],"end")}}function VQ($,M){return $.ordered===M.ordered&&$.start===M.start}function GQ($){if($.block.type!=="heading")return null;return{kind:"replace-root",block:r({text:$.block.plainText}),rootIndex:$.rootIndex,selection:M0($.rootIndex)}}function BQ($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;let Z=Z2($,M);if(!Z||Z.block.type!=="paragraph"||Z.region.text.length!==0)return null;if(Z.quote.children.length===1)return{kind:"replace-root-range",count:1,replacements:[r({text:""})],rootIndex:Z.rootIndex,selection:M0(Z.rootIndex)};let X=Math.max(0,Z.childIndex-1),D=Z.childIndex>0?"end":0;return{kind:"replace-root",block:P0({children:Z.quote.children.filter((Y,Q)=>Q!==Z.childIndex)}),rootIndex:Z.rootIndex,selection:X0(Z.rootIndex,[X],D)}}function FQ($,M,J,Z,X,D){return{blocks:X===0?[r({text:""}),$]:X===D?[$,r({text:""})]:[r({text:M}),r({text:J})],focusChildIndices:X===0?Z:[...Z.slice(0,-1),Z.at(-1)+1]}}function _Q($,M,J,Z,X,D){return{blocks:X===0?[r({text:""}),$]:X===D?[$,r({text:""})]:[M1({depth:$.depth,text:M}),r({text:J})],focusChildIndices:X===0?Z:[...Z.slice(0,-1),Z.at(-1)+1]}}function v7($,M,J){let Z=p0($,M),X=Math.max(2,J);if(!Z||Z.block.type!=="paragraph"||Z.block.plainText.length>0||M.anchor.regionId!==M.focus.regionId||M.anchor.offset!==0||M.focus.offset!==0)return null;return{kind:"replace-root",block:z1({rows:Array.from({length:2},()=>i6(X))}),rootIndex:Z.rootIndex,selection:U1(Z.rootIndex,0,0)}}function a6($,M,J){let Z=A1($,M.focus.regionId);if(!Z)return null;let X=J<0?zQ(Z.table,Z.rowIndex,Z.cellIndex):WQ(Z.table,Z.rowIndex,Z.cellIndex);if(!X)return J>0&&EQ(Z.table,Z.rowIndex,Z.cellIndex)?bQ(Z):{kind:"keep-state"};let D=Z.table.rows[X.rowIndex]?.cells[X.cellIndex];if(!D)return{kind:"keep-state"};return{kind:"set-selection",selection:PQ($,M,Z.table,X.rowIndex,X.cellIndex,Math.min(M.focus.offset,D.plainText.length))}}function h7($,M){let J=H5($,M.focus.regionId);if(!J||J.kind!=="tableCell")return null;let Z=Math.min(M.anchor.offset,M.focus.offset),X=Math.max(M.anchor.offset,M.focus.offset),D=C6(J,Z,X);return{kind:"replace-block",block:D.block,blockId:D.blockId,selection:D.selection}}function g7($,M,J){let Z=A1($,M.focus.regionId);if(!Z)return null;let X=J==="left"?Z.cellIndex:Z.cellIndex+1;return D2(Z,z1({align:x7(Z.table.align,X,0,[null]),rows:Z.table.rows.map((D)=>v1({cells:HQ(D.cells,X,0,[c7()])}))}),U1(Z.rootIndex,Z.rowIndex,X))}function I7($,M){let J=A1($,M.focus.regionId);if(!J)return null;let Z=Math.max(0,...J.table.rows.map((X)=>X.cells.length));if(Z<=1)return null;return D2(J,z1({align:x7(J.table.align,J.cellIndex,1,[]),rows:J.table.rows.map((X)=>v1({cells:X.cells.filter((D,Y)=>Y!==J.cellIndex)}))}),U1(J.rootIndex,J.rowIndex,Math.min(J.cellIndex,Z-2)))}function p7($,M,J){let Z=A1($,M.focus.regionId);if(!Z)return null;let X=J==="above"?Z.rowIndex:Z.rowIndex+1,D=Math.max(1,...Z.table.rows.map((Y)=>Y.cells.length));return D2(Z,S0(Z.table,[...Z.table.rows.slice(0,X),i6(D),...Z.table.rows.slice(X)]),U1(Z.rootIndex,X,Math.min(Z.cellIndex,D-1)))}function l7($,M){let J=A1($,M.focus.regionId);if(!J||J.table.rows.length<=1)return null;let Z=J.table.rows.filter((Y,Q)=>Q!==J.rowIndex),X=Math.min(J.rowIndex,Z.length-1),D=Z[X]?.cells.length??1;return D2(J,S0(J.table,Z),U1(J.rootIndex,X,Math.min(J.cellIndex,D-1)))}function r7($,M){let J=A1($,M.focus.regionId);if(!J)return null;return D2(J,r({text:""}),M0(J.rootIndex))}function i6($){return v1({cells:Array.from({length:$},()=>c7())})}function c7(){return J1({children:[]})}function bQ($){let M=$.table.rows.length,J=Math.max(1,...$.table.rows.map((Z)=>Z.cells.length));return D2($,S0($.table,[...$.table.rows,i6(J)]),U1($.rootIndex,M,0))}function D2($,M,J){return{kind:"replace-block",block:M,blockId:$.table.id,selection:J}}function HQ($,M,J,Z){return[...$.slice(0,M),...Z,...$.slice(M+J)]}function x7($,M,J,Z){return[...$.slice(0,M),...Z,...$.slice(M+J)]}function PQ($,M,J,Z,X,D){let Y=M2($,J.id,Z,X);if(!Y)return M;return{anchor:{regionId:Y.id,offset:D},focus:{regionId:Y.id,offset:D}}}function zQ($,M,J){if(J>0)return{cellIndex:J-1,rowIndex:M};if(M>0){let Z=$.rows[M-1];if(!Z||Z.cells.length===0)return null;return{cellIndex:Z.cells.length-1,rowIndex:M-1}}return null}function WQ($,M,J){let Z=$.rows[M];if(!Z)return null;if(J+1<Z.cells.length)return{cellIndex:J+1,rowIndex:M};let X=$.rows[M+1];if(!X||X.cells.length===0)return null;return{cellIndex:0,rowIndex:M+1}}function EQ($,M,J){let Z=$.rows[M];return Boolean(Z&&M===$.rows.length-1&&J===Z.cells.length-1)}function Y2($,M){let J=C7($.documentIndex,$.selection,M),Z=s($,J);if(!Z)return null;if(J?.kind==="replace-selection"&&M.length>0)Z=S5(Z,M.length);if(M===".")Z=g6(Z);return Z}function J4($){switch(e2($.documentIndex,$.selection).kind){case"code":return s($,S7($.documentIndex,$.selection));case"tableCell":return s($,h7($.documentIndex,$.selection));case"listItem":{let J=L7($.documentIndex,$.selection);return wQ({state:s($,J)??s($,l5($.documentIndex,$.selection)),action:J})}case"blockquoteTextBlock":return s($,m7($.documentIndex,$.selection))??s($,l5($.documentIndex,$.selection));case"rootTextBlock":return s($,l5($.documentIndex,$.selection));case"unsupported":return null}}function r5($){if(a7($))return Z4($);let M=OQ($);if(M)return M;let J=n($.documentIndex,$.selection);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;switch(e2($.documentIndex,$.selection).kind){case"listItem":return s($,R7($.documentIndex,$.selection));case"blockquoteTextBlock":case"rootTextBlock":return s($,u7($.documentIndex,$.selection));default:return null}}function c5($){if(a7($))return Z4($);return CQ($)}function s6($,M){return s($,{kind:"replace-selection",selection:$.selection,text:M})}function x5($,M){let J=s6($,M);return M.length>0?S5(J,M.length):J}function Z4($){return s6($,"")}function o6($){let M=$.documentIndex.regions,J=M[0],Z=M.at(-1);if(!J||!Z)return $;return D0($,{anchor:{regionId:J.id,offset:0},focus:{regionId:Z.id,offset:Z.text.length}})}function n6($){switch(e2($.documentIndex,$.selection).kind){case"tableCell":return s($,a6($.documentIndex,$.selection,1));case"rootTextBlock":return s($,d6($.documentIndex,$.selection,1));case"listItem":return TQ($);default:return null}}function t6($){switch(e2($.documentIndex,$.selection).kind){case"tableCell":return s($,a6($.documentIndex,$.selection,-1));case"rootTextBlock":return s($,d6($.documentIndex,$.selection,-1));case"listItem":return yQ($);default:return null}}function TQ($){return s($,k7($.documentIndex,$.selection))}function yQ($){return s($,f7($.documentIndex,$.selection))}function e6($){return s($,x6($.documentIndex,$.selection,-1))}function $3($){return s($,x6($.documentIndex,$.selection,1))}function M3($,M){return s($,v7($.documentIndex,$.selection,M))}function J3($,M){return s($,g7($.documentIndex,$.selection,M))}function Z3($){return s($,I7($.documentIndex,$.selection))}function X3($,M){return s($,p7($.documentIndex,$.selection,M))}function D3($){return s($,l7($.documentIndex,$.selection))}function Y3($){return s($,r7($.documentIndex,$.selection))}function d5($,M){return d7($,(J,Z,X)=>y6(J,Z,X,M))}function Q3($){return d7($,(M,J,Z)=>O6(M,J,Z))}function X4($){return d5($,"bold")}function D4($){return d5($,"italic")}function Y4($){return d5($,"strikethrough")}function Q4($){return d5($,"underline")}function K3($,M,J,Z,X){return s($,E5($.documentIndex,M,J,Z,X))}function q3($,M,J,Z){return s($,E5($.documentIndex,M,J,Z,null))}function U3($,M){let J=t2($.documentIndex,M);if(!J||J.type!=="listItem"||typeof J.checked!=="boolean")return null;return s($,{kind:"replace-block",block:{...J,checked:!J.checked},blockId:M})}function a5($){return p6($)}function i5($){return l6($)}function N3($,M,J){let Z=_6($.documentIndex,M,J);if(!Z)return null;return g5($,$.documentIndex.document.comments.length,0,[Z])}function A3($,M,J){return K4($,M,(Z)=>m8(Z,{body:J.trim()}))}function V3($,M,J,Z){return K4($,M,(X)=>S8(X,J,Z))}function G3($,M,J){return K4($,M,(Z)=>u8(Z,J))}function B3($,M){return K4($,M,()=>null)}function F3($,M,J){return K4($,M,(Z)=>v8(Z,J))}function K4($,M,J){let X=L0($.documentIndex).threads[M];if(!X)return null;let D=J(X);if(D===X)return null;return g5($,M,1,D?[D]:[])}function wQ($){if(!$.state||!$.action||$.action.kind!=="replace-block"||!$.action.listItemInsertedPath)return $.state;return I6($.state,$.action.listItemInsertedPath)}function d7($,M){let J=n($.documentIndex,$.selection);if(J.start.regionId!==J.end.regionId||J.start.offset===J.end.offset)return null;return s($,I2($.documentIndex,J.start.regionId,J.start.offset,J.end.offset,M))}function a7($){let M=n($.documentIndex,$.selection);return M.start.regionId!==M.end.regionId||M.start.offset!==M.end.offset}function OQ($){return i7($,"backward")}function CQ($){return i7($,"forward")}function i7($,M){if($.selection.anchor.regionId!==$.selection.focus.regionId||$.selection.anchor.offset!==$.selection.focus.offset)return null;let J=n0($.documentIndex,$.selection.focus.regionId);if(!J)return null;if(M==="forward"&&$.selection.focus.offset>=J.text.length)return null;let Z=M==="backward"?RQ(J.text,$.selection.focus.offset):$.selection.focus.offset,X=M==="backward"?$.selection.focus.offset:kQ(J.text,$.selection.focus.offset);if(Z===X)return null;let D=s6(D0($,{anchor:{regionId:J.id,offset:Z},focus:{regionId:J.id,offset:X}}),"");return jQ($,D,Z,X)}function jQ($,M,J,Z){let X=LQ($,J,Z);return X?v6(M,X):M}function LQ($,M,J){let Z=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!Z)return null;let X=Z.text.slice(M,J);if(X.length===0)return null;if(!Z.inlines.find((Y)=>Y.start<=M&&Y.end>=J&&Y.kind==="text"&&Y.link===null&&Y.marks.length===0))return null;return{regionPath:Z.path,startOffset:M,text:X}}function RQ($,M){let J=Array.from($.slice(0,M));if(J.length===0)return 0;return M-J.at(-1).length}function kQ($,M){let J=Array.from($.slice(M))[0];return J?M+J.length:$.length}var s7=1;function o7($,M,J){let Z=$.documentIndex.regionOrderIndex.get($.selection.focus.regionId);if(Z===void 0)return $;let X=$.documentIndex.regions[Z],D=$.selection.focus.offset+M;if(D>=0&&D<=X.text.length)return y0($,X.id,D,J);if(M<0){let Q=$.documentIndex.regions[Z-1];if(!Q)return $;return y0($,Q.id,Q.text.length,J)}let Y=$.documentIndex.regions[Z+1];if(!Y)return $;return y0($,Y.id,0,J)}function n7($,M,J,Z,X){let D=j2(M,J.regionId,J.offset);if(!D)return $;let Y=M.lines[D.index+Z];if(!Y)return $;let Q=T0(M,$,{x:g0($,M,J)+s7,y:Y.top+Y.height/2});if(!Q)return $;return y0($,Q.regionId,Q.offset,X)}function t7($,M,J,Z){let X=$M($,M);if(!X)return $;return y0($,X.regionId,J==="Home"?X.start:X.end,Z)}function e7($,M,J,Z,X){let D=$M($,M);if(!D)return $;let Q=Math.max(1,Math.floor(480/M.options.lineHeight)),K=j2(M,D.regionId,$.selection.focus.offset),q=K?M.lines[K.index+Z*Q]:null;if(!q)return $;let U=T0(M,$,{x:g0($,M,J)+s7,y:q.top+q.height/2});if(!U)return $;return y0($,U.regionId,U.offset,X)}function $M($,M){return s0(M,$.selection.focus.regionId,$.selection.focus.offset)}var fQ=1;function MM($,M,J,Z,X){let D=$.documentIndex.regionIndex.get($.selection.focus.regionId)??null;if(!D)return null;let Y=$.documentIndex.tableCellIndex.get(D.id)??null,Q=$.documentIndex.blockIndex.get(D.blockId)??null;if(!Y||Q?.type!=="table")return null;let K=mQ($,Q.id,Y.rowIndex+Z,Y.cellIndex)??SQ($,Q.id,Z);if(!K)return $;let q=M.regionBounds.get(D.id),U=M.regionBounds.get(K.id);if(!q||!U)return $;let N=U.top+uQ(J.top+J.height/2-q.top,0,Math.max(0,U.bottom-U.top-1)),A=T0(M,$,{x:g0($,M,J)+fQ,y:N});if(!A)return $;return y0($,A.regionId,A.offset,X)}function mQ($,M,J,Z){return M2($.documentIndex,M,J,Z)}function SQ($,M,J){let Z=$.documentIndex.blockIndex.get(M),X=$.documentIndex.regions,D=Z?$.documentIndex.roots[Z.rootIndex]?.regionRange:void 0;if(!D)return null;return J<0?X[D.start-1]??null:X[D.end]??null}function uQ($,M,J){return Math.max(M,Math.min(J,$))}function _3($,M,J=!1){return o7($,M,J)}function b3($,M,J,Z=!1){return vQ($,M,J,Z)}function H3($,M,J,Z=!1){return hQ($,M,J,Z)}function P3($,M,J,Z=!1){return t7($,M,J,Z)}function z3($,M,J=!1){return gQ($,M,J)}function vQ($,M,J,Z){let X=JM($,M);if(!X)return $;return MM($,M,X,J,Z)??n7($,M,X,J,Z)}function hQ($,M,J,Z){let X=JM($,M);if(!X)return $;return e7($,M,X,J,Z)}function gQ($,M,J){let Z=$.documentIndex.regions,X=M==="start"?Z[0]:Z.at(-1);if(!X)return $;return y0($,X.id,M==="start"?0:X.text.length,J)}function JM($,M){return v0(M,$.documentIndex,{regionId:$.selection.focus.regionId,offset:$.selection.focus.offset})}function XM($,M,J,Z,X,D,Y){let Q=J.image?Z.images.get(J.image.url):null,K=lQ(J,Z,Y),q=rQ(M,D,Y,K);if($.fillStyle=X.imageSurfaceBackground,$.fillRect(q.left,q.top,q.width,q.height),Q?.status==="loaded"&&Q.source)$.drawImage(Q.source,q.left,q.top,q.width,q.height);else IQ($,X,{...q,status:Q?.status==="error"?"error":"loading"});$.strokeStyle=X.imageSurfaceBorder,$.strokeRect(q.left,q.top,q.width,q.height)}function IQ($,M,J){let Z=J.status==="loading"?"Loading image":"Image unavailable",X=cQ(J),D=J.top+J.height/2+X.size*0.9;if($.save(),$.beginPath(),$.rect(J.left,J.top,J.width,J.height),$.clip(),J.status==="loading")pQ($,M,J);$.strokeStyle=M.imagePlaceholderIcon,$.lineWidth=1.5,$.strokeRect(X.left,X.top,X.size,X.size),$.beginPath(),$.arc(X.left+X.size*0.28,X.top+X.size*0.3,X.size*0.1,0,Math.PI*2),$.moveTo(X.left+X.size*0.12,X.top+X.size*0.82),$.lineTo(X.left+X.size*0.42,X.top+X.size*0.5),$.lineTo(X.left+X.size*0.58,X.top+X.size*0.66),$.lineTo(X.left+X.size*0.78,X.top+X.size*0.38),$.lineTo(X.left+X.size*0.88,X.top+X.size*0.82),$.stroke(),$.font='500 12px "Iowan Old Style", "Palatino Linotype", serif',$.fillStyle=M.imagePlaceholderText,$.textAlign="center",$.textBaseline="middle",$.fillText(Z,J.left+J.width/2,D),$.restore()}function pQ($,M,J){let Z=Math.max(48,Math.round(J.width*0.22)),X=J.width+Z*2,D=performance.now()%1800/1800,Y=J.left-Z+X*D,Q=$.createLinearGradient(Y,J.top,Y+Z,J.top);Q.addColorStop(0,"rgba(255,255,255,0)"),Q.addColorStop(0.5,M.imageLoadingOverlay),Q.addColorStop(1,"rgba(255,255,255,0)"),$.fillStyle=Q,$.fillRect(J.left,J.top,J.width,J.height)}function lQ($,M,J){if(!$.image)return ZM(J);let Z=M.images.get($.image.url);if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return ZM(J);return Math.max(48,Math.round(J*(Z.intrinsicHeight/Z.intrinsicWidth)))}function rQ($,M,J,Z){return{height:Z,left:M,top:$.top+Math.max(0,Math.floor(($.height-Z)/2)),width:J}}function cQ($){let M=Math.max(18,Math.min(34,Math.round(Math.min($.width,$.height)*0.18)));return{left:$.left+Math.max(12,Math.round(($.width-M)/2)),size:M,top:$.top+Math.max(12,Math.round($.height/2-M*0.95))}}function ZM($){return Math.max(48,Math.round($*0.5625))}var DM=2,YM=8,xQ=3,dQ=1.5,aQ=2,Q2={elbow:{x:6.5,y:10.5},end:{x:11.5,y:3.5},start:{x:3.5,y:7.5}};function QM($,M,J,Z,X,D,Y=null){if(!J||M.start!==0)return;if(Y){let Q=P7(Y),K=tQ(J,M,Z,X,$);$.save(),$.translate(K.x,K.y),$.scale(Q,Q),$.translate(-K.x,-K.y)}if(J.kind==="task")iQ($,M,J.checked,D,Y);else if($.fillStyle=Y?a2(D.listMarkerText,Y,D):D.listMarkerText,J.kind==="ordered")nQ($,J.label,Z,X);else $.fillText(J.label,M.left-DM,X);if(Y)$.restore()}function iQ($,M,J,Z,X=null){let D=R2(M);if(sQ($,D,J,Z,X),!J)return;oQ($,D,Z,X)}function sQ($,M,J,Z,X=null){let D=J?Z.checkboxCheckedFill:Z.checkboxUncheckedFill,Y=J?Z.checkboxCheckedStroke:Z.checkboxUncheckedStroke;$.fillStyle=X?a2(D,X,Z):D,$.strokeStyle=X?a2(Y,X,Z):Y,$.beginPath(),$.lineWidth=dQ,$.roundRect(M.left,M.top,M.size,M.size,xQ),$.fill(),$.stroke()}function oQ($,M,J,Z=null){$.strokeStyle=Z?a2(J.checkboxCheckmark,Z,J):J.checkboxCheckmark,$.lineWidth=aQ,$.beginPath(),$.moveTo(M.left+Q2.start.x,M.top+Q2.start.y),$.lineTo(M.left+Q2.elbow.x,M.top+Q2.elbow.y),$.lineTo(M.left+Q2.end.x,M.top+Q2.end.y),$.stroke()}function nQ($,M,J,Z){let X=$.textAlign;$.textAlign="right",$.fillText(M,J-YM,Z),$.textAlign=X}function tQ($,M,J,Z,X){if($.kind==="task"){let Q=R2(M);return{x:Q.left+Q.size/2,y:Q.top+Q.size/2}}let D=X.measureText($.label),Y=Z-(D.actualBoundingBoxAscent-D.actualBoundingBoxDescent)/2;if($.kind==="ordered")return{x:J-YM-D.width/2,y:Y};return{x:M.left-DM+D.width/2,y:Y}}var eQ=80;function qM({context:$,containerBounds:M,isHeaderRow:J,lineHeight:Z,theme:X}){let D=NM(M,Z);$.fillStyle=J?X.tableHeaderBackground:X.tableBodyBackground,$.fillRect(D.left,D.top,D.width,D.height),AM($,D,X)}function UM({activeBlockFlashes:$,activeBlockId:M,activeRegionId:J,context:Z,editorState:X,endIndex:D,layout:Y,regionBounds:Q,startIndex:K,theme:q,verticalBleed:U}){if(!M||!J)return;let N=X.documentIndex.blockIndex.get(M)??null;if(N?.type!=="table")return;if((X.documentIndex.regionIndex.get(J)??null)?.blockId!==M)return;let V=Q.get(J)??null,B=Y.regionLineIndices.get(J)??null;if(!V||!B||B.length===0)return;let G=Y.lines[B[0]]??null;if(!G)return;let b=NM(V,G.height);if(b.width===0)return;let P=KM({context:Z,endIndex:D,fillStyle:q.activeBlockBackground,layout:Y,left:b.left,lineIndices:B,startIndex:K,verticalBleed:U,width:b.width}),y=N.path?$.get(N.path)??null:null;if(y)KM({context:Z,endIndex:D,fillStyle:m5(q.activeBlockFlash,y),layout:Y,left:b.left,lineIndices:B,startIndex:K,verticalBleed:U,width:b.width});if(!P)return;AM(Z,b,q)}function KM({context:$,endIndex:M,fillStyle:J,layout:Z,left:X,lineIndices:D,startIndex:Y,verticalBleed:Q,width:K}){$.fillStyle=J;let q=!1;for(let U of D){if(U<Y)continue;if(U>=M)break;let N=Z.lines[U];$.fillRect(X,N.top-Q,K,N.height),q=!0}return q}function NM($,M){return{height:Math.max($.bottom-$.top,M),left:$.left,top:$.top,width:Math.max($.right-$.left,eQ)}}function AM($,M,J){$.strokeStyle=J.tableBorder,$.strokeRect(M.left,M.top,M.width,M.height)}var W3=2,$K=3,MK=12,JK=6,ZK=3,XK=1,DK=2,YK=2,QK=8,KK=12,qK=28,UK=4,NK=5,AK=2,VK=3,GK=6,VM=3,BK=12,FK=10,_K=2,bK=2,HK=1,PK=2,E3=2,GM=1.25,zK=5,WK=1,BM=4,EK=4,TK=1.5;function yK({activeBlockId:$,activeRegionId:M,activeThreadIndex:J,containerLineBounds:Z,context:X,devicePixelRatio:D,editorState:Y,height:Q,layout:K,liveCommentRanges:q,normalizedSelection:U,now:N=oK(),resources:A,runtimeBlockMap:V,theme:B,viewportTop:G,width:b}){X.save(),X.scale(D,D),X.clearRect(0,0,b,Q),X.fillStyle=B.background,X.fillRect(0,0,b,Q),X.textBaseline="alphabetic",X.translate(0,-G);let P=wK(Y,U),{endIndex:y,startIndex:z}=J6(K,G,Q),L=N7(Y,N),R=A7(Y,N),m=U7(Y,N),E=G7(Y,N),_=V7(Y,N),j=CK(K,Y,$,z,y),C=OK(K,Y,V,z,y,b);for(let W=z;W<y;W+=1){let F=K.lines[W];kK({containerLineBounds:Z,context:X,editorState:Y,line:F,runtimeBlockMap:V,theme:B,width:b})}UM({activeBlockFlashes:L,activeBlockId:$,activeRegionId:M,context:X,editorState:Y,endIndex:y,layout:K,regionBounds:Z,startIndex:z,theme:B,verticalBleed:W3});for(let W=z;W<y;W+=1){let F=K.lines[W];fK({activeBlockId:$,activeBlockFlashes:L,activeDeletedTextFades:R,activeThreadIndex:J,activeInsertedTextHighlights:m,activeListMarkerPops:E,activePunctuationPulses:_,context:X,editorState:Y,line:F,liveCommentRanges:q,normalizedSelection:U,resources:A,runtimeBlockMap:V,selectionRegionOrderRange:P,theme:B,width:b})}jK(X,C,B),LK(X,j,B),X.restore()}function wK($,M){let J=$.documentIndex.regionOrderIndex,Z=J.get(M.start.regionId),X=J.get(M.end.regionId);return Z===void 0||X===void 0?null:{end:X,start:Z}}function OK($,M,J,Z,X,D){let Y=new Map;for(let Q=Z;Q<X;Q+=1){let K=$.lines[Q],q=J.get(K.blockId);if(q?.type!=="heading"||q.depth!==1&&q.depth!==2)continue;let U=Y.get(q.id),N={bottom:K.top+K.height,left:K.left+K1(M,K),right:D-$.options.paddingX};Y.set(q.id,U?{bottom:Math.max(U.bottom,N.bottom),left:U.left,right:U.right}:N)}return Y}function CK($,M,J,Z,X){let D=new Map;for(let Y=Z;Y<X;Y+=1){let Q=$.lines[Y],K=n1(M,Q.blockId,"blockquote");if(!K)continue;let q=D.get(K.id),U={bottom:Q.top+Q.height,isActive:Q.blockId===J,left:$.options.paddingX+(K.depth+1)*$.options.indentWidth-10,top:Q.top};D.set(K.id,q?{bottom:Math.max(q.bottom,U.bottom),isActive:q.isActive||U.isActive,left:q.left,top:Math.min(q.top,U.top)}:U)}return D}function jK($,M,J){$.fillStyle=J.headingRule;for(let Z of M.values())$.fillRect(Z.left,Z.bottom+zK,Math.max(E3,Z.right-Z.left),WK)}function LK($,M,J){for(let Z of M.values())$.fillStyle=Z.isActive?J.blockquoteRuleActive:J.blockquoteRule,$.fillRect(Z.left,Z.top+$K,ZK,Math.max(MK,Z.bottom-Z.top-JK))}function RK({context:$,devicePixelRatio:M,editorState:J,height:Z,layout:X,normalizedSelection:D,presence:Y,showCaret:Q,theme:K,viewportTop:q,width:U}){$.save(),$.scale(M,M),$.clearRect(0,0,U,Z);let N=D.start.regionId===D.end.regionId&&D.start.offset!==D.end.offset,A=Q&&!N;if($.translate(0,-q),A)FM($,J,X,{color:K.caret,offset:J.selection.focus.offset,regionId:J.selection.focus.regionId});if(Y)for(let V of Y){if(!V.cursorPoint)continue;FM($,J,X,{color:V.color??K.leafAccent,offset:V.cursorPoint.offset,regionId:V.cursorPoint.regionId})}$.restore()}function FM($,M,J,Z){let X=v0(J,M.documentIndex,{regionId:Z.regionId,offset:Z.offset});if(!X)return;let D=g0(M,J,X),Y=pK(J,X);$.fillStyle=Z.color,$.fillRect(D,Y.top,DK,Y.height)}function kK({containerLineBounds:$,context:M,editorState:J,line:Z,runtimeBlockMap:X,theme:D,width:Y}){let Q=X.get(Z.blockId)??null,K=$.get(Z.regionId)??null,q=J.documentIndex.tableCellIndex.get(Z.regionId)??null;mK(M,Z,Q,K,q,D,Y)}function fK({activeBlockId:$,activeBlockFlashes:M,activeDeletedTextFades:J,activeThreadIndex:Z,activeInsertedTextHighlights:X,activeListMarkerPops:D,activePunctuationPulses:Y,context:Q,editorState:K,line:q,liveCommentRanges:U,normalizedSelection:N,resources:A,runtimeBlockMap:V,selectionRegionOrderRange:B,theme:G,width:b}){let P=V.get(q.blockId)??null,y=K.documentIndex.blockIndex.get(q.blockId)?.path??null,z=K.documentIndex.regionIndex.get(q.regionId)??null,L=z?.path??"",R=n1(K,q.blockId,"listItem"),m=R?k2(K,R.id):null,E=R?D.get(R.path)??null:null,_=q.left+K1(K,q),j=cK(q),C=P?.type==="code"?G.codeText:aK(P,G);Q.font=q.font,SK(Q,q,P,y,$,M,G,b),uK(Q,K,q,N,B,G),vK(Q,K,q,U,Z,G),QM(Q,q,m,_,j,G,E),hK(Q,q,z,_,j,X.get(L)??[],C,A,G),gK(Q,q,z,_,j,J.get(L)??[],C),IK(Q,q,z,_,j,Y.get(L)??[],G)}function mK($,M,J,Z,X,D,Y){if(!Z||M.start!==0)return;if(J?.type==="code"){let Q=Math.max(0,M.left-KK);$.fillStyle=D.codeBackground,$.fillRect(Q,Z.top-UK,Math.max(Z.right-M.left+qK,Y-Q),Z.bottom-Z.top+QK);return}if(J?.type!=="table")return;qM({context:$,containerBounds:Z,isHeaderRow:X?.rowIndex===0,lineHeight:M.height,theme:D})}function SK($,M,J,Z,X,D,Y,Q){if(M.blockId!==X||J?.type==="table")return;let K=Z?D.get(Z)??null:null;if($.fillStyle=Y.activeBlockBackground,$.fillRect(0,M.top-W3,Q,M.height),!K)return;$.fillStyle=m5(Y.activeBlockFlash,K),$.fillRect(0,M.top-W3,Q,M.height)}function uK($,M,J,Z,X,D){if(!X)return;let Y=M.documentIndex.regionOrderIndex.get(J.regionId);if(Y===void 0||Y<X.start||Y>X.end)return;let Q=Y===X.start?Math.max(J.start,Z.start.offset):J.start,K=Y===X.end?Math.min(J.end,Z.end.offset):J.end;if(K<=Q)return;$.fillStyle=D.selectionBackground,$.fillRect(Q1(M,J,Q-J.start),J.top+HK,Math.max(bK,Q1(M,J,K-J.start)-Q1(M,J,Q-J.start)),J.height-PK)}function vK($,M,J,Z,X,D){for(let Y of Z){if(Y.regionId!==J.regionId)continue;let Q=Math.max(Y.startOffset,J.start),K=Math.min(Y.endOffset,J.end);if(K<=Q)continue;$.fillStyle=sK(Y,X,D),$.fillRect(Q1(M,J,Q-J.start),J.top+J.height-NK,Math.max(AK,Q1(M,J,K-J.start)-Q1(M,J,Q-J.start)),VK)}}function hK($,M,J,Z,X,D,Y,Q,K){if(!J){$.fillStyle=Y,$.fillText(M.text,Z,X);return}let q=J.inlines.filter((U)=>U.end>M.start&&U.start<M.end);if(q.length===0){$.fillStyle=Y,$.fillText(M.text,Z,X);return}for(let U of q){let N=Math.max(M.start,U.start),A=Math.min(M.end,U.end);if(J.text.slice(N,A).length===0)continue;let{left:B,right:G}=y3(M,Z,N,A),b=iK(M.font,U.marks);if($.font=b,U.kind==="image"){let P=Math.max(24,G-B);XM($,M,U,Q,K,B,P);continue}if(U.kind==="inlineCode"){let P=xK(M,b),y=dK(M,b);$.fillStyle=K.inlineCodeBackground,$.fillRect(B-VM,P,Math.max(FK,G-B+VM*2),y),_M($,M,J.text,Z,X,N,A,K.inlineCodeText,D,K,{strikethrough:!1,underline:!1});continue}_M($,M,J.text,Z,X,N,A,U.link?K.linkText:Y,D,K,{strikethrough:U.marks.includes("strikethrough"),underline:U.marks.includes("underline")||Boolean(U.link)})}}function _M($,M,J,Z,X,D,Y,Q,K,q,U){let N=B7(D,Y,K);for(let A=0;A<N.length-1;A+=1){let V=N[A],B=N[A+1];if(B<=V)continue;let G=J.slice(V,B);if(G.length===0)continue;let{left:b,right:P}=y3(M,Z,V,B),y=F7(K,V,B),z=_7(Q,y,q);if($.fillStyle=z,$.fillText(G,b,X),U.strikethrough)$.fillRect(b,rK(X,M.height,$.font),Math.max(E3,P-b),GM);if(U.underline)$.fillRect(b,lK(X,M.height,$.font),Math.max(E3,P-b),GM)}}function gK($,M,J,Z,X,D,Y){if(!J||D.length===0)return;for(let Q of D){if(Q.startOffset<M.start||Q.startOffset>M.end)continue;let K=Z+(h0(M,Q.startOffset-M.start)-M.left);$.fillStyle=b7(Y,Q),$.fillText(Q.text,K,X)}}function IK($,M,J,Z,X,D,Y){if(!J||D.length===0)return;for(let Q of D){if(Q.offset<M.start||Q.offset>=M.end)continue;let{left:K,right:q}=y3(M,Z,Q.offset,Q.offset+1),U=Math.max(BM,(q-K)/2+BM+EK*Q.progress),{ascent:N,descent:A}=Y1(M.font),V=X-Math.max(1,N*0.42)+Math.max(0.5,A*0.15);$.strokeStyle=H7(Q,Y),$.lineWidth=TK,$.beginPath(),$.arc((K+q)/2,V,U,0,Math.PI*2),$.stroke()}}function pK($,M){let J=s0($,M.regionId,M.offset),Z=J?.font??'16px "Iowan Old Style", "Palatino Linotype", serif',{ascent:X,descent:D}=Y1(Z),Y=Math.max(1,X+D),Q=Math.min(M.height-YK,Y),K=J?Math.max(J.top,J.top+T3(J.height,Z)-XK):M.top+Math.max(0,Math.floor((M.height-Q)/2));return{height:Q,top:K}}function lK($,M,J){let{descent:Z}=Y1(J),X=Math.max(1,Math.round(Math.max(2,Z)*0.35)),D=$+Z-X,Y=$-s5(M,J);return Math.min(Y+M-4,D)}function rK($,M,J){let{ascent:Z}=Y1(J),X=$-s5(M,J);return Math.max(X+2,$-Math.round(Z*0.32))}function cK($){return $.top+s5($.height,$.font)}function s5($,M){return R9($,M)}function xK($,M){let J=T3($.height,M);return $.top+J+_K}function dK($,M){let J=T3($.height,M);return Math.max(BK,$.height-J-GK)}function T3($,M){let{ascent:J}=Y1(M);return s5($,M)-J}function aK($,M){switch($?.type){case"heading":return M.headingText;case"blockquote":return M.blockquoteText;case"table":return M.headingText;default:return M.paragraphText}}function y3($,M,J,Z){return{left:M+(h0($,J-$.start)-$.left),right:M+(h0($,Z-$.start)-$.left)}}function iK($,M){let J=[];if(M.includes("italic"))J.push("italic");if(M.includes("bold"))J.push("700");return J.length>0?`${J.join(" ")} ${$}`:$}function sK($,M,J){if($.resolved)return $.threadIndex===M?J.commentHighlightResolvedActive:J.commentHighlightResolved;return $.threadIndex===M?J.commentHighlightActive:J.commentHighlight}function oK(){return typeof performance<"u"?performance.now():Date.now()}function w3($,M,J,Z){yK({activeBlockId:Z.activeBlockId,activeRegionId:Z.activeRegionId,activeThreadIndex:Z.activeThreadIndex,containerLineBounds:M.regionBounds,context:J,devicePixelRatio:Z.devicePixelRatio,editorState:$,height:Z.height,layout:M.layout,liveCommentRanges:Z.liveCommentRanges,normalizedSelection:Z.normalizedSelection,now:Z.now,resources:Z.resources??{images:new Map},runtimeBlockMap:M.blockMap,theme:Z.theme,viewportTop:M.paintTop,width:Z.width})}function O3($,M,J,Z){RK({context:J,devicePixelRatio:Z.devicePixelRatio,editorState:$,height:Z.height,layout:M.layout,normalizedSelection:Z.normalizedSelection,presence:Z.presence,showCaret:Z.showCaret,theme:Z.theme,viewportTop:M.paintTop,width:Z.width})}import{forwardRef as Mq,createElement as Jq}from"react";var o5=(...$)=>$.filter((M,J,Z)=>{return Boolean(M)&&M.trim()!==""&&Z.indexOf(M)===J}).join(" ").trim();var bM=($)=>$.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var HM=($)=>$.replace(/^([A-Z])|[\s-_]+(\w)/g,(M,J,Z)=>Z?Z.toUpperCase():J.toLowerCase());var C3=($)=>{let M=HM($);return M.charAt(0).toUpperCase()+M.slice(1)};import{forwardRef as $q,createElement as WM}from"react";var n5={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var PM=($)=>{for(let M in $)if(M.startsWith("aria-")||M==="role"||M==="title")return!0;return!1};import{createContext as nK,useContext as tK,useMemo as t_,createElement as e_}from"react";var eK=nK({});var zM=()=>tK(eK);var EM=$q(({color:$,size:M,strokeWidth:J,absoluteStrokeWidth:Z,className:X="",children:D,iconNode:Y,...Q},K)=>{let{size:q=24,strokeWidth:U=2,absoluteStrokeWidth:N=!1,color:A="currentColor",className:V=""}=zM()??{},B=Z??N?Number(J??U)*24/Number(M??q):J??U;return WM("svg",{ref:K,...n5,width:M??q??n5.width,height:M??q??n5.height,stroke:$??A,strokeWidth:B,className:o5("lucide",V,X),...!D&&!PM(Q)&&{"aria-hidden":"true"},...Q},[...Y.map(([G,b])=>WM(G,b)),...Array.isArray(D)?D:[D]])});var u=($,M)=>{let J=Mq(({className:Z,...X},D)=>Jq(EM,{ref:D,iconNode:M,className:o5(`lucide-${bM(C3($))}`,`lucide-${$}`,Z),...X}));return J.displayName=C3($),J};var Zq=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],V1=u("columns-2",Zq);var Xq=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],G1=u("rows-3",Xq);var Dq=[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]],B1=u("send-horizontal",Dq);var Yq=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],q4=u("arrow-down",Yq);var Qq=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],U4=u("arrow-up",Qq);var Kq=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],N4=u("bold",Kq);var qq=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],y1=u("check",qq);var Uq=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],A4=u("chevron-down",Uq);var Nq=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],V4=u("heading-1",Nq);var Aq=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],G4=u("heading-2",Aq);var Vq=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],B4=u("heading-3",Vq);var Gq=[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]],F4=u("heading-4",Gq);var Bq=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]],_4=u("heading-5",Bq);var Fq=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]],b4=u("heading-6",Fq);var _q=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],H4=u("heading",_q);var bq=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],P4=u("italic",bq);var Hq=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],z4=u("list-ordered",Hq);var Pq=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],W4=u("list-todo",Pq);var zq=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],E4=u("list",zq);var Wq=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],T4=u("message-square-plus",Wq);var Eq=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],w1=u("pencil",Eq);var Tq=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],K2=u("plus",Tq);var yq=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],y4=u("strikethrough",yq);var wq=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],F1=u("table-2",wq);var Oq=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],w4=u("text-quote",Oq);var Cq=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],w0=u("trash-2",Cq);var jq=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],O4=u("underline",jq);var Lq=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],C4=u("x",Lq);import{jsx as q2,jsxs as mq}from"react/jsx-runtime";function TM({insetX:$,insetY:M,onSelect:J,presence:Z}){if(!Z)return null;return q2("div",{"aria-label":"Presence",className:"documint-presence-indicators",style:{paddingRight:`${$}px`,top:`${M}px`},children:Z.map((X)=>q2(Rq,{onSelect:()=>J(X),presence:X},X.id))})}function Rq({onSelect:$,presence:M}){let J=M.viewport,Z=kq(M),X=J?.status==="above"?U4:q4,D=J!==null&&J.status!=="unresolved",Y=J?.status==="above"||J?.status==="below";return mq("button",{"aria-label":fq(M),className:"documint-presence-indicator","data-status":J?.status??"unresolved",disabled:!D,onClick:D?$:void 0,style:{"--documint-presence-color":M.color??"var(--documint-leaf-accent)"},type:"button",children:[q2("span",{className:"documint-presence-indicator-avatar",children:M.avatarUrl?q2("img",{alt:"","aria-hidden":"true",className:"documint-presence-indicator-image",draggable:!1,src:M.avatarUrl}):Z}),Y?q2("span",{className:"documint-presence-indicator-direction","aria-hidden":"true",children:q2(X,{className:"documint-presence-indicator-arrow",size:14,strokeWidth:2.3})}):null]})}function kq($){return yM($).charAt(0).toLocaleUpperCase()}function fq($){let M=yM($),J=$.viewport?.status??"unresolved";if(J==="above")return`${M} above viewport`;if(J==="below")return`${M} below viewport`;if(J==="unresolved")return`${M} unresolved`;return`${M} in viewport`}function yM($){return($.fullName??$.username).trim()||"Presence"}var o=`
|
|
26
|
-
`,
|
|
27
|
-
|
|
28
|
-
`,jU="-",LU=".",RU="***",kU=" ",g3=3,fU=5,mU=4,sM=2,SU=2,uU=1,vU=/([\\`*_[\]])/g,hU=/([\\)&])/g,gU=/(["\\])/g;function X8($,M={}){if($.blocks.length===0&&$.comments.length===0&&$.frontMatter===void 0)return"";let J=$.blocks.map((X)=>D8(X,0,M));if($.comments.length>0)J.push(ZN($.comments));if($.frontMatter!==void 0)J.unshift($.frontMatter);let Z=J.join(k4);return Z.endsWith(o)?Z:`${Z}${o}`}function D8($,M,J){let Z=b1(M);switch($.type){case"blockquote":return IU($,M,J);case"code":return pU($,M);case"directive":return XN($,M);case"heading":return nM($,M);case"list":return lU($,M,J);case"listItem":return tM($,M,!1,1,J);case"paragraph":return`${Z}${I3(f4($.children))}`;case"table":return cU($,M,J);case"thematicBreak":return`${Z}${RU}`;case"unsupported":return M===0?$.source:MJ($.source,M)}}function IU($,M,J){let Z=$.children.map((D)=>D8(D,0,J)).join(k4),X=b1(M);return Z.split(o).map((D)=>`${X}${U2}${D.length>0?` ${D}`:""}`).join(o)}function pU($,M){let J=[$.language??"",$.meta??""].filter(Boolean).join(" ").trim(),Z=b1(M),X=`${Z}${L4}${J?J:""}`,D=$.source.length>0?$.source.split(o).map((Y)=>`${Z}${Y}`).join(o):Z;return`${X}${o}${D}${o}${Z}${L4}`}function nM($,M){let J=I3(f4($.children)),Z=`${b1(M)}${"#".repeat($.depth)}`;return J.length>0?`${Z} ${J}`:Z}function lU($,M,J){let Z=$.start??1;return $.items.map((X)=>tM(X,M,$.ordered,Z,J)).join($.spread?k4:o)}function tM($,M,J,Z,X){let D=J?`${Z}${LU}`:jU,Y=$.checked===null?"":`[${$.checked?"x":" "}] `,Q=`${b1(M)}${D} ${Y}`,K=M+D.length+1,q=$.children;if(q.length===0)return Y.length>0?Q:Q.trimEnd();let[U,...N]=q,A=rU(U,Q,Y.length>0,X),V=N.map((B)=>D8(B,K,X)).join($.spread?k4:o);if(!V)return A;return`${A}${$.spread?k4:o}${V}`}function rU($,M,J,Z){switch($.type){case"paragraph":{let X=I3(f4($.children));if(X.length===0)return J?M:M.trimEnd();return`${M}${X}`}case"heading":return`${M}${nM($,0)}`;case"directive":case"unsupported":{let X=$.type==="directive"?p3($):$.source,[D,...Y]=X.split(o);return[M+D,...Y.map((Q)=>`${b1(M.length)}${Q}`)].join(o)}default:{let X=M.length;return`${M.trimEnd()}${o}${D8($,X,Z)}`}}}function cU($,M,J){let Z=$.rows.map((U)=>U.cells.map((N)=>f4(N.children))),X=Math.max(1,...Z.map((U)=>U.length)),D=Z[0]??[],Y=Array.from({length:X},(U,N)=>Math.max(g3,iU($.align[N]),...J.padTableColumns?Z.map((A)=>A[N]?.length??0):[D[N]?.length??0])),Q=xU(Y,$.align,M),K=oM(D,Y,$.align,M,J),q=Z.slice(1).map((U)=>oM(U,Y,$.align,M,J));return[K??dU(Y,M),Q,...q].join(o)}function oM($,M,J,Z,X){let D=M.map((Y,Q)=>{let K=$[Q]??"";if(!X.padTableColumns)return K;return sU(K,Y,J[Q])});return`${" ".repeat(Z)}| ${D.join(" | ")} |`}function xU($,M,J){let Z=$.map((X,D)=>aU(M[D],X));return`${" ".repeat(J)}| ${Z.join(" | ")} |`}function dU($,M){return`${b1(M)}| ${$.map((J)=>"".padEnd(J," ")).join(" | ")} |`}function aU($,M){let J=Math.max(g3,M-($==="center"?SU:$?uU:0));switch($){case"center":return`:${"-".repeat(Math.max(1,J))}:`;case"left":return`:${"-".repeat(Math.max(sM,J))}`;case"right":return`${"-".repeat(Math.max(sM,J))}:`;default:return"-".repeat(J)}}function iU($){return $==="center"?fU:$?mU:g3}function sU($,M,J){if(J==="right")return $.padStart(M," ");return $.padEnd(M," ")}function f4($){return nU($).map((M)=>oU(M)).join("")}function I3($){return $.replace(/^ +/gm,(M)=>kU.repeat(M.length))}function oU($){switch($.type){case"break":return o;case"image":return DN($);case"inlineCode":return $N($.code);case"link":return YN($);case"text":return eU(eM($.text),$.marks);case"unsupported":return $.source}}function nU($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&tU(Z.marks,J.marks)){M[M.length-1]={...Z,text:Z.text+J.text};continue}M.push(J)}return M}function tU($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function eU($,M){return M.reduce((J,Z)=>{switch(Z){case"bold":return`**${J}**`;case"italic":return`*${J}*`;case"strikethrough":return`~~${J}~~`;case"underline":return`${_1}${J}${j4}`}},$)}function $N($){let M=0,J=0;for(let Y of $){if(Y==="`"){if(J+=1,J>M)M=J;continue}J=0}let Z=M>0?M+1:1,X="`".repeat(Z),D=$.startsWith("`")||$.endsWith("`")?` ${$} `:$;return`${X}${D}${X}`}function eM($){return $.replace(vU,"\\$1")}function MN($){return $.replace(hU,"\\$1")}function JN($){return $?` "${$.replace(gU,"\\$1")}"`:""}function ZN($){return p3({attributes:"",body:JSON.stringify($,null,2),name:e5})}function XN($,M){let J=p3($);return M===0?J:MJ(J,M)}function p3($){let M=$.attributes?`{${$.attributes}}`:"";return`:::${$.name}${M}${o}${$.body}${o}${t5}`}function DN($){let M=eM($.alt??""),J=$J($.url,$.title),Z=$.width?`{width=${$.width}}`:"";return`![${M}]${J}${Z}`}function YN($){return`[${f4($.children)}]${$J($.url,$.title)}`}function $J($,M){return`(${MN($)}${JN(M)})`}function b1($){return" ".repeat($)}function MJ($,M){let J=b1(M);return $.split(o).map((Z)=>`${J}${Z}`).join(o)}import{createContext as QN,useContext as KN}from"react";import{createPortal as qN}from"react-dom";import{jsx as XJ}from"react/jsx-runtime";var JJ=QN(void 0);function ZJ({children:$,themeStyles:M}){return XJ(JJ.Provider,{value:M,children:$})}function Y8({children:$}){let M=KN(JJ);if(typeof document>"u")return null;return qN(XJ("div",{className:"documint-overlay",style:{display:"contents",...M},children:$}),document.body)}import{useEffect as Q8,useRef as bJ,useState as O1}from"react";import{forwardRef as NN,useCallback as V2,useEffect as AN,useImperativeHandle as VN,useLayoutEffect as GN,useMemo as BN,useRef as QJ,useState as l3}from"react";var UN=["box-sizing","width","height","overflow-x","overflow-y","border-top-width","border-right-width","border-bottom-width","border-left-width","border-style","padding-top","padding-right","padding-bottom","padding-left","font-style","font-variant","font-weight","font-stretch","font-size","font-size-adjust","line-height","font-family","text-align","text-transform","text-indent","text-decoration","letter-spacing","word-spacing","tab-size"];function DJ($,M,{topGap:J=8}={}){if(!$.isConnected)return null;let Z=getComputedStyle($),X=document.createElement("div");for(let q of UN)X.style.setProperty(q,Z.getPropertyValue(q));Object.assign(X.style,{position:"absolute",top:"0",left:"0",visibility:"hidden",whiteSpace:"pre-wrap",wordWrap:"break-word",width:`${$.clientWidth}px`}),X.textContent=$.value.slice(0,M);let D=document.createElement("span");D.textContent=$.value.slice(M)||".",X.appendChild(D),document.body.appendChild(X);let Y=$.getBoundingClientRect(),Q=parseFloat(Z.lineHeight)||D.offsetHeight,K={left:Y.left+D.offsetLeft+parseFloat(Z.borderLeftWidth)-$.scrollLeft,top:Y.top+D.offsetTop+parseFloat(Z.borderTopWidth)+Q+J-$.scrollTop};return document.body.removeChild(X),K}import{jsx as k0,jsxs as KJ,Fragment as TN}from"react/jsx-runtime";var FN=240,_N="documint-leaf-menu-item documint-completion-item",m4=NN(function({actions:M,completionSources:J,onChange:Z,placeholder:X,readOnly:D=!1,rows:Y=3,value:Q},K){let q=QJ(null);VN(K,()=>q.current,[]);let U=BN(()=>zN(J),[J]),[N,A]=l3(null),[V,B]=l3(0),[G,b]=l3(null),P=V2((E,_)=>{if(!U.length){A(null);return}let j=WN(E,_,U);if(!j){A(null);return}A(j),B(0)},[U]),y=V2((E)=>{let _=E.currentTarget.value,j=E.currentTarget.selectionEnd??_.length;Z(_),P(_,j)},[Z,P]),z=V2((E)=>{let _=E.currentTarget;P(_.value,_.selectionEnd??_.value.length)},[P]),L=V2(()=>{A(null)},[]),R=V2((E)=>{if(!q.current||!N)return;let j=`${N.trigger}${E.label} `,C=Q.slice(0,N.triggerStart),W=Q.slice(N.caret),F=C+j+W,H=N.triggerStart+j.length;Z(F),A(null),requestAnimationFrame(()=>{let v=q.current;if(!v)return;v.focus(),v.setSelectionRange(H,H)})},[N,Z,Q]),m=V2((E)=>{if(N&&N.matches.length>0){if(E.key==="ArrowDown"){E.preventDefault(),E.stopPropagation(),B((_)=>(_+1)%N.matches.length);return}if(E.key==="ArrowUp"){E.preventDefault(),E.stopPropagation(),B((_)=>(_-1+N.matches.length)%N.matches.length);return}if(E.key==="Enter"||E.key==="Tab"){E.preventDefault(),E.stopPropagation();let _=N.matches[V];if(_)R(_);return}if(E.key==="Escape"){E.preventDefault(),E.stopPropagation(),A(null);return}}if(E.key==="Escape"&&M.kind==="edit")E.preventDefault(),M.onCancel()},[M,N,V,R]);return GN(()=>{if(!N){b(null);return}let E=()=>{let _=q.current;if(!_)return;b(DJ(_,N.triggerStart))};return E(),window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}},[N]),KJ("div",{className:"documint-leaf-input-field",children:[k0("textarea",{className:"documint-leaf-input",onBlur:L,onChange:y,onKeyDown:m,onSelect:z,placeholder:X,readOnly:D,ref:q,rows:Y,value:Q}),bN(M),N&&G&&N.matches.length>0?k0(Y8,{children:k0(HN,{activeIndex:V,left:G.left,matches:N.matches,onHover:B,onSelect:R,top:G.top})}):null]})});function bN($){if($.kind==="edit")return KJ(TN,{children:[k0(r3,{className:"documint-leaf-input-cancel",icon:C4,label:"Cancel editing",onClick:$.onCancel}),k0(r3,{className:"documint-leaf-input-save",disabled:$.saveDisabled??!1,icon:y1,label:"Save",onClick:$.onSave})]});return k0(r3,{className:"documint-leaf-input-submit",disabled:$.submitDisabled??!1,icon:B1,iconSize:15,label:$.submitLabel,onClick:$.onSubmit})}function r3({className:$,disabled:M=!1,icon:J,iconSize:Z=14,label:X,onClick:D}){return k0("button",{"aria-label":X,className:`documint-leaf-action ${$}`,disabled:M,onClick:D,title:X,type:"button",children:k0(J,{size:Z,strokeWidth:2.2})})}function HN({activeIndex:$,left:M,matches:J,onHover:Z,onSelect:X,top:D}){let Y=QJ(null);return AN(()=>{let Q=Y.current;if(!Q)return;let K=Q.children[$];if(K instanceof HTMLElement)K.scrollIntoView({block:"nearest"})},[$]),k0("div",{className:"documint-leaf-menu documint-completion-popover",ref:Y,role:"listbox",style:{position:"fixed",left:M,top:D,maxHeight:FN,overflowY:"auto"},children:J.map((Q,K)=>{let q=K===$;return k0("button",{"aria-selected":q,className:`${_N}${q?" is-active":""}`,onPointerDown:PN,onPointerEnter:()=>Z(K),onClick:()=>X(Q),role:"option",type:"button",children:k0("span",{children:Q.label})},Q.label)})})}function PN($){$.preventDefault()}function zN($){if(!$?.length)return[];return $.map((M)=>({trigger:M.trigger,items:[...M.items].sort((J,Z)=>J.label.localeCompare(Z.label,void 0,{sensitivity:"base"}))}))}function WN($,M,J){for(let Z=M-1;Z>=0;Z-=1){let X=$[Z];if(YJ(X))return null;let D=J.find((Q)=>Q.trigger===X);if(!D)continue;if(Z>0&&!YJ($[Z-1]))return null;let Y=$.slice(Z+1,M);return{trigger:D.trigger,query:Y,triggerStart:Z,caret:M,matches:EN(D.items,Y)}}return null}function YJ($){return $===void 0||$===" "||$===`
|
|
29
|
-
`||$==="\t"}function
|
|
30
|
-
`||$==="\t"}import{jsx as qJ,jsxs as CN}from"react/jsx-runtime";function d3({value:$,completionSources:M,onEdit:J}){return qJ("p",{onDoubleClick:J,children:ON($,M)})}function ON($,M){let J=c3($,M);if(J.length===1&&J[0].kind==="text")return $;return J.map((Z,X)=>Z.kind==="token"?CN("span",{className:"documint-mention",children:[Z.trigger,Z.label]},X):qJ(wN,{children:Z.text},X))}import{Children as UJ,isValidElement as NJ,useEffect as jN,useRef as LN,useState as RN}from"react";import{jsx as A0,jsxs as s3}from"react/jsx-runtime";var a3=($)=>{$.preventDefault()},i3=($)=>$.isPrimary&&$.button===0;function kN({children:$}){return A0("div",{className:"documint-leaf-toolbar",children:UJ.map($,fN)})}function fN($){if(!NJ($))return null;if($.type===VJ){let M=$.props;return A0(AJ,{children:A0(mN,{...M})})}if($.type===GJ){let{className:M}=$.props;return A0("div",{className:S4("documint-leaf-toolbar-divider",M)})}if($.type===BJ){let M=$.props;return A0(SN,{...M})}return null}function mN({active:$=!1,className:M,disabled:J=!1,icon:Z,label:X,onClick:D}){return A0("button",{"aria-label":X,className:S4("documint-leaf-toolbar-button",$?"active":null,M),disabled:J,onPointerDown:(Y)=>{if(a3(Y),!J&&i3(Y))D()},title:X,type:"button",children:A0(Z,{size:15,strokeWidth:2.2})})}function SN({children:$,className:M,icon:J,label:Z,onSelect:X}){let D=LN(null),[Y,Q]=RN(!1);return jN(()=>{if(!Y)return;let K=(q)=>{if(D.current&&q.target instanceof Node&&!D.current.contains(q.target))Q(!1)};return window.addEventListener("pointerdown",K),()=>{window.removeEventListener("pointerdown",K)}},[Y]),A0(AJ,{children:s3("div",{className:"documint-leaf-toolbar-menu-shell",ref:D,children:[A0(uN,{className:M,icon:J,isOpen:Y,label:Z,onClick:()=>Q((K)=>!K)}),Y?A0("div",{className:"documint-leaf-menu",role:"menu",children:UJ.map($,(K)=>vN(K,(q)=>{Q(!1),X(q)}))}):null]})})}function uN({className:$,icon:M,isOpen:J,label:Z,onClick:X}){return s3("button",{"aria-expanded":J,"aria-haspopup":"menu","aria-label":Z,className:S4("documint-leaf-toolbar-button",J?"active":null,$),onPointerDown:(D)=>{if(a3(D),i3(D))X()},title:Z,type:"button",children:[A0(M,{size:15,strokeWidth:2.2}),A0(A4,{className:S4("documint-leaf-toolbar-menu-chevron",J?"is-open":null),size:13,strokeWidth:2.2})]})}function vN($,M){if(!NJ($))return null;if($.type===_J){let{className:Y}=$.props;return A0("div",{className:S4("documint-leaf-menu-divider",Y),role:"separator"})}if($.type!==FJ)return null;let{disabled:J=!1,icon:Z,text:X,value:D}=$.props;return s3("button",{className:"documint-leaf-menu-item",disabled:J,onPointerDown:(Y)=>{if(a3(Y),!J&&i3(Y))M(D)},role:"menuitem",type:"button",children:[A0(Z,{size:15,strokeWidth:2.2}),A0("span",{children:X})]})}function S4(...$){return $.filter(Boolean).join(" ")}function AJ({children:$}){return A0("div",{className:"documint-leaf-toolbar-group",children:$})}function VJ($){return null}function GJ($){return null}function BJ($){return null}function FJ($){return null}function _J($){return null}var c=Object.assign(kN,{Button:VJ,Divider:GJ,Menu:BJ,MenuDivider:_J,MenuItem:FJ});import{jsx as t,jsxs as r0,Fragment as pN}from"react/jsx-runtime";var hN=!1,gN=220,C1=()=>{};function o3($){let M=$.mode==="create",J=$.mode==="create"?$:null,Z=$.mode==="thread"?$:null,X=$.canEdit,D=$.link,Y=Z?.thread??null,Q=Y?.comments??[],K=Q[0]??null,q=Y?Z1(Y):!1,U=Z?.animateInitialComment??!1,[N,A]=O1(null),[V,B]=O1(""),[G,b]=O1(""),[P,y]=O1(""),[z,L]=O1(!U),[R,m]=O1(hN),[E,_]=O1(!1),j=bJ(null),C=bJ(null),W=$.mentionSources,F=Y?g8(Y):null,H=F?HJ(F):"",v=X&&!q,h=v&&V.trim().length>0,l=v&&G.trim().length>0,p=X&&P.trim().length>0,O=M||E,T=!M||R,k=!M&&Boolean(Y),f=Boolean(K),d=M?R:!0,I=Z?.onDeleteComment??C1,U0=Z?.onDeleteThread??C1,z0=Z?.onToggleResolved??C1,_0=J?.activeMarks??[],R1=J?.onToggleBold??C1,F8=J?.onToggleItalic??C1,p4=J?.onToggleStrikethrough??C1,_8=J?.onToggleUnderline??C1,l4=X?M?"Add a comment":"Reply to this comment":"Comment editing is disabled",r4=M?P:G;Q8(()=>{if(N!==null&&(N<0||N>=Q.length))A(null),B("")},[Q.length,N]),Q8(()=>{if(!f||!U){L(!0);return}L(!1);let a=requestAnimationFrame(()=>{L(!0)});return()=>{cancelAnimationFrame(a)}},[U,K,f]),Q8(()=>{if(!Z||!U){_(!1);return}_(!0);let a=window.setTimeout(()=>{_(!1)},gN);return()=>{window.clearTimeout(a)}},[U,Z]),Q8(()=>{if(!M||!R||!X)return;let a=requestAnimationFrame(()=>{C.current?.focus()});return()=>{cancelAnimationFrame(a)}},[X,M,R]);let O0=()=>{A(null),B("")},W0=(a,_2)=>{if(!k||!v)return;A(a),B(_2)},k1=(a)=>{if(!Z)return;Z.onEditComment(a,V),O0()},b8=()=>{if(!Z)return;Z.onReply(G),b("")},c4=()=>{if(!J||!p)return;J.onCreateThread(P),y("")},f1=O?`documint-comment-leaf documint-comment-leaf-create${d?" is-expanded":""}`:"documint-comment-leaf",x4=k||f||T?t(IN,{canCreate:p,canEdit:X,canMutateThread:v,canReply:l,canSaveEditedComment:h,comments:Q,composerRef:C,editDraft:V,editingCommentIndex:N,isComposerVisible:T,isInitialCommentVisible:z,isResolved:q,link:D,mentionSources:W,mode:$.mode,onBeginEditingComment:W0,onCancelEditing:O0,onChangeCreateDraft:y,onChangeEditDraft:B,onChangeReplyDraft:b,onDeleteComment:I,onDeleteThread:U0,onSubmitCreate:c4,onSubmitEditedComment:k1,onSubmitReply:b8,onToggleResolved:z0,rootComment:K,showRootComment:f,showThreadChrome:k,threadAge:H,composerPlaceholder:l4,composerValue:r4}):null;return t("div",{className:f1,ref:j,children:r0("div",{className:O?"documint-comment-leaf-create-shell":void 0,children:[O?r0(c,{children:[t(c.Button,{className:"documint-comment-leaf-create-button",icon:T4,label:"Add comment",onClick:()=>m(!0)}),t(c.Divider,{className:"documint-comment-leaf-create-divider"}),t(c.Button,{active:_0.includes("bold"),className:"documint-comment-leaf-create-mark",icon:N4,label:"Bold",onClick:R1}),t(c.Button,{active:_0.includes("italic"),className:"documint-comment-leaf-create-mark",icon:P4,label:"Italic",onClick:F8}),t(c.Button,{active:_0.includes("underline"),className:"documint-comment-leaf-create-mark",icon:O4,label:"Underline",onClick:_8}),t(c.Button,{active:_0.includes("strikethrough"),className:"documint-comment-leaf-create-mark",icon:y4,label:"Strikethrough",onClick:p4})]}):null,t("div",{className:O?"documint-comment-leaf-create-content":void 0,children:x4})]})})}function IN({canCreate:$,canEdit:M,canMutateThread:J,canReply:Z,canSaveEditedComment:X,comments:D,composerRef:Y,editDraft:Q,editingCommentIndex:K,isComposerVisible:q,isInitialCommentVisible:U,isResolved:N,link:A,mentionSources:V,mode:B,onBeginEditingComment:G,onCancelEditing:b,onChangeCreateDraft:P,onChangeEditDraft:y,onChangeReplyDraft:z,onDeleteComment:L,onDeleteThread:R,onSubmitCreate:m,onSubmitEditedComment:E,onSubmitReply:_,onToggleResolved:j,rootComment:C,showRootComment:W,showThreadChrome:F,threadAge:H,composerPlaceholder:v,composerValue:h}){return r0(pN,{children:[F?r0("div",{className:"documint-comment-leaf-header",children:[t("span",{className:"documint-comment-leaf-age",children:H}),r0("div",{className:"documint-comment-leaf-actions",children:[t("button",{className:"documint-leaf-action","aria-label":N?"Reopen comment":"Resolve comment",disabled:!M,onClick:j,title:N?"Reopen comment":"Resolve comment",type:"button",children:t(y1,{size:14,strokeWidth:2.2})}),t("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment thread",disabled:!M,onClick:R,title:"Delete comment thread",type:"button",children:t(w0,{size:14,strokeWidth:2.2})})]})]}):null,F&&A?r0("div",{className:"documint-comment-leaf-link",children:[A.title?t("div",{className:"documint-link-leaf-title",children:A.title}):null,t("div",{className:"documint-link-leaf-url",children:A.url})]}):null,r0("div",{className:`documint-comment-thread${W?"":" is-empty"}`,children:[t("article",{className:W?`documint-comment-message documint-comment-message-root${U?" is-visible":""}`:"documint-comment-message documint-comment-message-root is-hidden",children:C?t(d3,{completionSources:V,onEdit:()=>G(0,C.body),value:C.body}):null}),D.slice(1).map((l,p)=>{let O=p+1,T=K===O;return r0("article",{className:"documint-comment-message",children:[!T?r0("div",{className:"documint-comment-message-meta",children:[t("span",{children:HJ(l.updatedAt)}),J?r0("div",{className:"documint-comment-leaf-actions",children:[t("button",{className:"documint-leaf-action","aria-label":"Edit comment",disabled:!J,onClick:()=>{G(O,l.body)},title:"Edit comment",type:"button",children:t(w1,{size:14,strokeWidth:2.2})}),t("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment",disabled:!J,onClick:()=>L(O),title:"Delete comment",type:"button",children:t(w0,{size:14,strokeWidth:2.2})})]}):null]}):null,T?t(m4,{actions:{kind:"edit",onCancel:b,onSave:()=>E(O),saveDisabled:!X},completionSources:V,onChange:y,readOnly:!M,rows:3,value:Q}):t(d3,{completionSources:V,onEdit:()=>G(O,l.body),value:l.body})]},`${l.updatedAt}:${O}`)})]}),t("div",{className:`documint-comment-reply${F?"":" is-standalone"}${q?" is-visible":""}`,children:t(m4,{actions:B==="create"?{kind:"compose",onSubmit:m,submitDisabled:!$,submitLabel:"Create comment"}:{kind:"compose",onSubmit:_,submitDisabled:!Z,submitLabel:"Reply"},completionSources:V,onChange:B==="create"?P:z,placeholder:v,readOnly:!M,ref:Y,rows:3,value:h})})]})}function HJ($){let M=new Date($);if(Number.isNaN(M.getTime()))return $;let J=M.getTime()-Date.now(),Z=60000,X=60*Z,D=24*X,Y=7*D,Q=30*D,K=365*D,q=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});if(Math.abs(J)<Z)return"just now";if(Math.abs(J)<X)return q.format(Math.round(J/Z),"minute");if(Math.abs(J)<D)return q.format(Math.round(J/X),"hour");if(Math.abs(J)<Y)return q.format(Math.round(J/D),"day");if(Math.abs(J)<K)return q.format(Math.round(J/Q),"month");return q.format(Math.round(J/K),"year")}import{jsx as c0,jsxs as cN}from"react/jsx-runtime";var lN=[{icon:V4,label:"Heading 1",text:"# "},{icon:G4,label:"Heading 2",text:"## "},{icon:B4,label:"Heading 3",text:"### "},{icon:F4,label:"Heading 4",text:"#### "},{icon:_4,label:"Heading 5",text:"##### "},{icon:b4,label:"Heading 6",text:"###### "}],rN=[{columns:2,text:"2 columns"},{columns:3,text:"3 columns"},{columns:4,text:"4 columns"},{columns:5,text:"5 columns"}];function PJ({onInsert:$,onInsertTable:M}){return cN(c,{children:[c0(c.Button,{icon:E4,label:"Insert bulleted list",onClick:()=>$("- ")}),c0(c.Button,{icon:z4,label:"Insert numbered list",onClick:()=>$("1. ")}),c0(c.Button,{icon:W4,label:"Insert task list",onClick:()=>$("- [ ] ")}),c0(c.Divider,{}),c0(c.Menu,{icon:H4,label:"Insert heading",onSelect:$,children:lN.map(({icon:J,label:Z,text:X})=>c0(c.MenuItem,{icon:J,text:Z,value:X},X))}),c0(c.Menu,{icon:F1,label:"Insert table",onSelect:(J)=>M(Number(J)),children:rN.map(({columns:J,text:Z})=>c0(c.MenuItem,{icon:F1,text:Z,value:String(J)},J))}),c0(c.Divider,{}),c0(c.Button,{icon:w4,label:"Insert blockquote",onClick:()=>$("> ")})]})}import{jsx as n3,jsxs as xN}from"react/jsx-runtime";function zJ({anchor:$,children:M,status:J="default"}){let Z=!$.isSelection;return n3(Y8,{children:xN("div",{className:"documint-leaf-anchor","data-selection":$.isSelection?"true":"false",onPointerEnter:$.onPointerEnter,onPointerLeave:$.onPointerLeave,style:{left:`${$.left}px`,top:`${$.top}px`},children:[Z?n3("div",{className:"documint-leaf-bridge"}):null,n3("div",{className:"documint-leaf-shell","data-status":J,children:M})]})})}import{useEffect as WJ,useRef as dN,useState as EJ}from"react";import{jsx as t0,jsxs as t3}from"react/jsx-runtime";function TJ({canEdit:$,onDelete:M,onSave:J,title:Z,url:X}){let[D,Y]=EJ(X),[Q,K]=EJ(!1),q=dN(null),U=aN(),N=D.trim(),A=$&&N.length>0,V=$&&!Q,B=`${U}click to open`,G=`documint-link-leaf-row${Q?" is-editing":""}`;return WJ(()=>{if(Q)return;Y(X)},[Q,X]),WJ(()=>{if(!Q)return;q.current?.focus()},[Q]),t3("div",{className:"documint-link-leaf",children:[Z?t0("div",{className:"documint-link-leaf-title",children:Z}):null,t3("div",{className:G,children:[Q?t0(m4,{actions:{kind:"edit",onCancel:()=>{Y(X),K(!1)},onSave:()=>{J(N),K(!1)},saveDisabled:!A},onChange:Y,readOnly:!$,ref:q,rows:3,value:D}):t0("div",{className:"documint-link-leaf-url",children:X}),V?t3("div",{className:"documint-link-leaf-actions",children:[t0("button",{className:"documint-leaf-action","aria-label":"Edit link",onClick:()=>{if(!$)return;Y(X),K(!0)},title:"Edit link",type:"button",children:t0(w1,{size:14,strokeWidth:2.2})}),t0("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Remove link",onClick:M,title:"Remove link",type:"button",children:t0(w0,{size:14,strokeWidth:2.2})})]}):null]}),t0("div",{className:"documint-link-leaf-divider"}),t0("div",{className:"documint-link-leaf-hint",children:B})]})}function aN(){if(typeof navigator>"u")return"Ctrl+";let $=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/.test($)?"CMD+":"CTRL+"}import{jsx as e0,jsxs as M$}from"react/jsx-runtime";var iN=[{text:"Column left",value:"left"},{text:"Column right",value:"right"}],sN=[{text:"Row above",value:"above"},{text:"Row below",value:"below"}],e3={text:"Delete column",value:"delete"},$$={text:"Delete row",value:"delete"},yJ={text:"Delete table",value:"delete"};function wJ({canDeleteColumn:$,canDeleteRow:M,onDeleteColumn:J,onDeleteRow:Z,onDeleteTable:X,onInsertColumn:D,onInsertRow:Y}){return M$(c,{children:[M$(c.Menu,{icon:V1,label:"Column actions",onSelect:(Q)=>{if(Q===e3.value){J();return}D(Q)},children:[iN.map(({text:Q,value:K})=>e0(c.MenuItem,{icon:K2,text:Q,value:K},K)),e0(c.MenuDivider,{}),e0(c.MenuItem,{disabled:!$,icon:w0,text:e3.text,value:e3.value})]}),M$(c.Menu,{icon:G1,label:"Row actions",onSelect:(Q)=>{if(Q===$$.value){Z();return}Y(Q)},children:[sN.map(({text:Q,value:K})=>e0(c.MenuItem,{icon:K2,text:Q,value:K},K)),e0(c.MenuDivider,{}),e0(c.MenuItem,{disabled:!M,icon:w0,text:$$.text,value:$$.value})]}),e0(c.Divider,{}),e0(c.Menu,{icon:F1,label:"Table actions",onSelect:()=>X(),children:e0(c.MenuItem,{icon:w0,text:yJ.text,value:yJ.value})})]})}import{useEffect as OJ,useEffectEvent as CJ,useLayoutEffect as oN,useMemo as nN,useRef as J$,useState as tN}from"react";function K8($,M){if(!$||$.kind==="task-toggle")return null;if($.commentThreadIndex!==null){let J=M[$.commentThreadIndex]??null;if(!J)return null;return{kind:"comment",left:$.anchorLeft,link:$.kind==="link"?{title:$.title,url:$.url}:null,thread:J,threadIndex:$.commentThreadIndex,top:$.anchorBottom}}if($.kind!=="link")return null;return{endOffset:$.endOffset,kind:"link",left:$.anchorLeft,regionId:$.regionId,startOffset:$.startOffset,title:$.title,top:$.anchorBottom,url:$.url}}var eN=600,$A=530,G2=24;function LJ({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,editorState:Z,editorViewportState:X,getScrollTop:D,layoutWidth:Y,onVisibilityChange:Q,scrollContentHeight:K,scrollTo:q,viewportHeight:U}){let N=nN(()=>n(Z),[Z]),[A,V]=tN(null),B=N.start.regionId===N.end.regionId&&N.start.offset===N.end.offset,G=J$(!0),b=J$(0),P=J$(null),y=CJ(()=>{Q()}),z=CJ(()=>{b.current=typeof performance<"u"?performance.now():Date.now(),G.current=!0,y()});return oN(()=>{let L=MA({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,normalizedSelection:N,state:Z,viewport:X.get()});V((R)=>DA(R,L)?R:L)},[$,M,J,Z,X]),OJ(()=>{let L=Z.selection.focus,R={layoutWidth:Y,offset:L.offset,regionId:L.regionId,scrollContentHeight:K,viewportHeight:U};if(YA(P.current,R))return;let m=B6(Z,X.get(),L);if(!m)return;let E=D(),_=E+G2,j=E+U-G2;if(m.top<_){let C=q(Math.max(0,m.top-G2));if(jJ(m,C,U,G2))P.current=R;return}if(m.top+m.height>j){let C=q(Math.max(0,m.top+m.height-U+G2));if(jJ(m,C,U,G2))P.current=R;return}P.current=R},[Z,Z.selection.focus.offset,Z.selection.focus.regionId,X,Y,K,q,U]),OJ(()=>{if(G.current=!0,y(),!B||typeof window>"u")return;let L=window.setInterval(()=>{if((typeof performance<"u"?performance.now():Date.now())-b.current<eN){if(!G.current)G.current=!0,y();return}G.current=!G.current,y()},$A);return()=>{window.clearInterval(L)}},[B]),{leaf:A,isVisible:()=>G.current,markActivity:z}}function MA({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,normalizedSelection:Z,state:X,viewport:D}){if(!D)return null;let Y=X.selection.focus;if(Z.start.regionId!==Z.end.regionId||Z.start.offset!==Z.end.offset)return null;let Q=$?XA(X,D):null;if(Q)return Q;let K=M?JA(X,D):null;if(K)return K;return K8(G6(X,D,Y,J.liveRanges),J.threads)}function JA($,M){let J=$.selection.focus,Z=$.documentIndex.regionIndex.get(J.regionId),X=Z?$.documentIndex.tableCellIndex.get(Z.id)??null:null;if(!Z||!X)return null;let D=$.documentIndex.blockIndex.get(Z.blockId),Y=D?.type==="table"?$.documentIndex.document.blocks[D.rootIndex]:null;if(!D||!Y||Y.type!=="table")return null;let Q=o0($,M,J),K=ZA(M,Z.id),q=Math.max(1,...Y.rows.map((U)=>U.cells.length));return Q&&K!==null?{cellIndex:X.cellIndex,columnCount:q,kind:"table",left:K,rowCount:Y.rows.length,rowIndex:X.rowIndex,top:Q.top+Q.height}:null}function ZA($,M){let J=$.layout.lines.find((Z)=>Z.regionId===M);return J?J.left:null}function XA($,M){let J=$.selection.focus,Z=$.documentIndex.regionIndex.get(J.regionId);if(!Z||Z.blockType!=="paragraph"||Z.text.length>0)return null;if(J.offset!==0)return null;let X=$.documentIndex.blockIndex.get(Z.blockId);if(!X||X.parentBlockId!==null)return null;let D=o0($,M,J);return D?{kind:"insertion",left:D.left,top:D.top+D.height}:null}function DA($,M){if($===M)return!0;if(!$||!M||$.kind!==M.kind)return!1;switch($.kind){case"comment":return M.kind==="comment"&&$.left===M.left&&$.link?.title===M.link?.title&&$.link?.url===M.link?.url&&$.thread===M.thread&&$.threadIndex===M.threadIndex&&$.top===M.top;case"insertion":return M.kind==="insertion"&&$.left===M.left&&$.top===M.top;case"link":return M.kind==="link"&&$.endOffset===M.endOffset&&$.left===M.left&&$.regionId===M.regionId&&$.startOffset===M.startOffset&&$.title===M.title&&$.top===M.top&&$.url===M.url;case"table":return M.kind==="table"&&$.cellIndex===M.cellIndex&&$.columnCount===M.columnCount&&$.left===M.left&&$.rowCount===M.rowCount&&$.rowIndex===M.rowIndex&&$.top===M.top}}function YA($,M){return $?.layoutWidth===M.layoutWidth&&$.regionId===M.regionId&&$.offset===M.offset&&$.scrollContentHeight===M.scrollContentHeight&&$.viewportHeight===M.viewportHeight}function jJ($,M,J,Z){return $.top>=M+Z&&$.top+$.height<=M+J-Z}import{useEffect as QA,useEffectEvent as KA,useMemo as Z$,useRef as qA,useState as UA}from"react";function RJ($){let M=Z$(()=>NA($),[$]),J=Z$(()=>M.join(`
|
|
31
|
-
`)
|
|
32
|
-
`).split(/(\n)/),l=F;for(let p of h){if(p.length===0)continue;let O=p===`
|
|
33
|
-
`?J4(l):Y2(l,p);if(!O)continue;l=O}return l===F?null:l}),y=V0((F,H,v)=>{let h=F.selection.focus,l={regionId:h.regionId,offset:Math.max(0,h.offset-H)},p=D0(F,{anchor:l,focus:h});return x5(p,v)}),z=V0((F)=>{if(q.current)return;let H=K(),v=OA(F.inputType);if(F.inputType==="insertText"){if(!F.data)return;F.preventDefault();let h=lJ(F.target);if(h>0){N(y(H,h,F.data));return}let l=wA(H,F.data);if(l>0){let p=F.data.slice(l);if(p.length>0)N(P(H,p));return}N(P(H,F.data));return}if(F.inputType==="insertReplacementText"){if(!F.data)return;F.preventDefault();let h=lJ(F.target);N(y(H,h,F.data));return}if(yA(F.inputType)){F.preventDefault(),N(J4(H));return}if(v==="backward"){F.preventDefault(),N(r5(H));return}if(v==="forward"){F.preventDefault(),N(c5(H));return}if(F.inputType==="historyUndo"){F.preventDefault(),N(a5(H)),B();return}if(F.inputType==="historyRedo"){F.preventDefault(),N(i5(H)),B();return}}),L=V0((F)=>{let H=K(),v=F.currentTarget.value,h=q8(H);if(q.current)return;if(rJ(v,h).length===0){v4(F.currentTarget,H);return}N(P(H,v))}),R=V0((F)=>{let H=jA(K(),Z.get(),F.nativeEvent,D);if(!H)return;F.preventDefault(),N(H)}),m=V0((F)=>{let H=D$(K());if(!H)return;F.preventDefault(),F.clipboardData.setData("text/plain",H)}),E=V0((F)=>{let H=K(),v=D$(H);if(!v)return;F.preventDefault(),F.clipboardData.setData("text/plain",v),N(Z4(H))}),_=V0((F)=>{let H=F.clipboardData.getData("text/plain");if(H.length===0)return;F.preventDefault(),N(x5(K(),H))}),j=V0(()=>{Y();let F=X.current;if(F)v4(F,K())}),C=V0((F)=>{if(Y(),F.target.matches(":focus-visible"))b()});Q$(()=>{let F=X.current;if(!F)return;v4(F,M)},[M,X]),zA(()=>{G(M.selection.focus)},[M,G]),Q$(()=>{let F=X.current;if(!F)return;let H=(v)=>z(v);return F.addEventListener("beforeinput",H),()=>F.removeEventListener("beforeinput",H)},[X,z]);let W={onCopy:m,onCut:E,onPaste:_,...Q?{}:{onKeyDown:R}};return{canvasHandlers:{...W,onFocus:C},focus:b,inputHandlers:{...W,onFocus:j,onInput:L}}}var xJ="";function TA(){let[$,M]=WA(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return!1;return window.matchMedia("(pointer: coarse)").matches});return Q$(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return;let J=window.matchMedia("(pointer: coarse)"),Z=(X)=>M(X.matches);return J.addEventListener?.("change",Z),()=>J.removeEventListener?.("change",Z)},[]),$}function yA($){return $==="insertLineBreak"||$==="insertParagraph"}function lJ($){let M=$,J=M?.selectionStart??0,Z=M?.selectionEnd??J;return Math.max(0,Z-J)}function wA($,M){if(M.length<pJ)return 0;let J=q8($,M.length),Z=Math.min(J.length,M.length);for(let X=Z;X>=pJ;X--)if(J.endsWith(M.slice(0,X)))return X;return 0}function OA($){switch($){case"deleteContentBackward":case"deleteComposedCharacterBackward":case"deleteSoftLineBackward":case"deleteHardLineBackward":case"deleteWordBackward":return"backward";case"deleteContentForward":case"deleteSoftLineForward":case"deleteHardLineForward":case"deleteWordForward":return"forward";default:return null}}function CA($){return $.replaceAll(xJ,"")}function q8($,M=EA){let{anchor:J,focus:Z}=$.selection;if(J.regionId!==Z.regionId||J.offset!==Z.offset)return"";let X=$.documentIndex.regionIndex.get(Z.regionId);if(!X)return"";return X.text.slice(Math.max(0,Z.offset-M),Z.offset)}function rJ($,M){let J=CA($);return J.startsWith(M)?J.slice(M.length):J}function v4($,M){let J=q8(M),Z=`${xJ}${J}`;$.value=Z,$.setSelectionRange(Z.length,Z.length)}function jA($,M,J,Z){if(J.key==="Delete")return c5($);let X=mJ(J,Z);if(X){if(X==="moveToLineStart"||X==="moveToLineEnd")return P3($,M.layout,X==="moveToLineStart"?"Home":"End",J.shiftKey);if(X==="moveToDocumentStart"||X==="moveToDocumentEnd")return z3($,X==="moveToDocumentStart"?"start":"end",J.shiftKey);switch(X){case"insertLineBreak":return J4($);case"deleteBackward":return r5($);case"indent":return n6($);case"dedent":return t6($);case"moveListItemUp":return e6($);case"moveListItemDown":return $3($);case"toggleBold":return X4($);case"toggleItalic":return D4($);case"toggleStrikethrough":return Y4($);case"toggleUnderline":return Q4($);case"toggleInlineCode":return Q3($);case"undo":return a5($);case"redo":return i5($);case"selectAll":return o6($)}}if(J.key==="ArrowLeft"||J.key==="ArrowRight")return _3($,J.key==="ArrowLeft"?-1:1,J.shiftKey);if(J.key==="ArrowUp"||J.key==="ArrowDown")return b3($,M.layout,J.key==="ArrowUp"?-1:1,J.shiftKey);if(J.key==="PageUp"||J.key==="PageDown")return H3($,M.layout,J.key==="PageUp"?-1:1,J.shiftKey);if(J.key.length===1&&!J.altKey&&!J.ctrlKey&&!J.metaKey)return Y2($,J.key);return null}import{useEffectEvent as K$,useLayoutEffect as LA,useMemo as RA,useState as kA}from"react";function dJ({editorState:$,editorStateRef:M,editorViewportState:J,onViewportScroll:Z,scrollContainerRef:X,scheduleOverlayRender:D,userPresence:Y}){let Q=RA(()=>{if(!Y||Y.length===0)return;return b5($.documentIndex,Y)},[$.documentIndex,Y]),[K,q]=kA(void 0),U=K$(()=>{if(Q===void 0){if(K!==void 0)q(void 0)}else q(m2(M.current??$,J.get(),Q));D()}),N=K$((V)=>{if(Q===void 0){if(K!==void 0)q(void 0);return}let B=m2(M.current??$,V,Q);if(fA(K,B))return;q(B)});LA(()=>{U()},[Q]);let A=K$((V)=>{if(!V.viewport||V.viewport.status==="unresolved")return;let B=X.current;if(!B)return;B.scrollTop=V.viewport.scrollTop,Z(B)});return{presence:K,scrollToPresence:A,refreshPresence:N}}function fA($,M){if($===M)return!0;if($===void 0||M===void 0||$.length!==M.length)return!1;return $.every((J,Z)=>{let X=M[Z];return J.id===X.id&&mA(J.viewport,X.viewport)})}function mA($,M){if($===M)return!0;if($===null||M===null)return!1;if($.status==="unresolved")return M.status==="unresolved";if(M.status==="unresolved")return!1;return $.status===M.status&&$.scrollTop===M.scrollTop}import{useEffect as SA,useEffectEvent as j1,useRef as h4}from"react";function aJ({editorStateRef:$,renderContent:M,renderOverlay:J,renderViewport:Z}){let X=h4(null),D=h4(!1),Y=h4(!1),Q=h4(!1),K=h4(!1),q=j1(()=>{if(typeof window>"u"){Z();return}D.current=!0,V()}),U=j1(()=>{if(typeof window>"u"){M(),J();return}Y.current=!0,V()}),N=j1(()=>{if(typeof window>"u"){M();return}Q.current=!0,V()}),A=j1(()=>{if(typeof window>"u"){J();return}K.current=!0,V()}),V=j1(()=>{if(typeof window>"u"||X.current!==null)return;X.current=window.requestAnimationFrame(()=>{B()})}),B=j1(()=>{X.current=null;let b=D.current,P=Y.current,y=Q.current,z=K.current;if(D.current=!1,Y.current=!1,Q.current=!1,K.current=!1,b){Z(),G();return}if(P){M(),J(),G();return}if(y)M(),G();if(z)J()}),G=j1(()=>{let b=$.current;if(!b||!S6(b,performance.now()))return;Q.current=!0,V()});return SA(()=>{return()=>{if(typeof window>"u"||X.current===null)return;window.cancelAnimationFrame(X.current),X.current=null}},[]),{scheduleContentPaint:N,scheduleFullPaint:U,scheduleFullRender:q,scheduleOverlayPaint:A}}import{useEffectEvent as q$,useLayoutEffect as iJ,useMemo as U$,useRef as N$,useState as sJ}from"react";function oJ({applyNextState:$,autoScrollDuringDrag:M,canShowSelectionLeaf:J,editorState:Z,editorStateRef:X,editorViewportState:D,focusInput:Y,onActivity:Q,resolvePoint:K,threads:q}){let U=U$(()=>n(Z),[Z]),N=U$(()=>Y$(Z),[Z]),A=U$(()=>w5(Z),[Z]),[V,B]=sJ(null),[G,b]=sJ(null),P=N$(null),y=N$(null),z=N$(null);iJ(()=>{let _=uA(Z,D.get(),U);B((j)=>pA(j,_)?j:_)},[Z,D,U.end.offset,U.end.regionId,U.start.offset,U.start.regionId]),iJ(()=>{let _=hA({canShowSelectionLeaf:J,currentLeaf:G,activeMarks:A,handles:V,selectionRange:N,threads:q});b((j)=>IA(j,_)?j:_)},[A,J,V,G,N,q]);let L=q$((_,j=!0)=>{b((C)=>C?.kind==="create"?{animateInitialComment:j,kind:"thread",left:C.left,threadIndex:_,top:C.top}:C)}),R=q$((_)=>{if(_&&z.current===_.pointerId&&_.currentTarget.hasPointerCapture(_.pointerId))_.currentTarget.releasePointerCapture(_.pointerId);P.current=null,y.current=null,z.current=null}),m=q$((_)=>{let j=X.current,C=y.current,W=K(_);if(!W||!j||!C||z.current!==_.pointerId)return;let F=f2(j,D.get(),W,C);if(!F)return;_.preventDefault(),_.stopPropagation(),Q(),M(_),$(D0(j,{anchor:C,focus:F}))}),E=(_)=>({onPointerCancel:(j)=>{R(j)},onPointerDown:(j)=>{let C=X.current??Z,W=rA(U,_),F=_==="start"?U.start:U.end;if(!V)return;j.preventDefault(),j.stopPropagation(),z.current=j.pointerId,y.current=W,P.current=_,j.currentTarget.setPointerCapture(j.pointerId),Q(),Y(),$(D0(C,{anchor:W,focus:F}))},onPointerMove:(j)=>{if(P.current!==_)return;m(j)},onPointerUp:(j)=>{if(P.current===_)m(j);R(j)}});return{endHandleProps:E("end"),handles:V,leaf:G,promoteLeafToThread:L,startHandleProps:E("start")}}function uA($,M,J){if(J.collapsed)return null;let Z=o0($,M,J.start),X=o0($,M,J.end);if(!Z||!X)return null;return{end:{left:X.left,top:X.top+X.height},start:{left:Z.left,top:Z.top}}}function vA($,M,J){return{activeMarks:J,kind:"create",left:M.start.left,selection:$,top:M.end.top}}function hA({activeMarks:$,canShowSelectionLeaf:M,currentLeaf:J,handles:Z,selectionRange:X,threads:D}){if(!M||!X||!Z)return null;if(J?.kind==="thread")return D[J.threadIndex]?J:null;return vA(X,Z,$)}function gA($,M){return $?.kind==="create"&&$.left===M.left&&$.selection.regionId===M.selection.regionId&&$.selection.startOffset===M.selection.startOffset&&$.selection.endOffset===M.selection.endOffset&&lA($.activeMarks,M.activeMarks)&&$.top===M.top}function IA($,M){if($===M)return!0;if(!$||!M||$.kind!==M.kind)return!1;if($.kind==="create"&&M.kind==="create")return gA($,M);return $.kind==="thread"&&M.kind==="thread"&&$.animateInitialComment===M.animateInitialComment&&$.left===M.left&&$.threadIndex===M.threadIndex&&$.top===M.top}function pA($,M){if($===M)return!0;if(!$||!M)return!1;return $.start.left===M.start.left&&$.start.top===M.start.top&&$.end.left===M.end.left&&$.end.top===M.end.top}function lA($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function rA($,M){return M==="start"?$.end:$.start}import{useEffect as cA,useMemo as eJ,useState as xA}from"react";var g4={activeBlockBackground:"#fff1c7",activeBlockFlash:"rgba(245, 158, 11, 0.28)",background:"#fcfbf7",blockquoteRule:"rgba(14, 116, 144, 0.2)",blockquoteRuleActive:"rgba(124, 45, 18, 0.36)",blockquoteText:"#334155",caret:"#111827",checkboxCheckmark:"#f8fafc",checkboxCheckedFill:"#0f766e",checkboxCheckedStroke:"#0f766e",checkboxUncheckedFill:"#fcfffe",checkboxUncheckedStroke:"#64748b",codeBackground:"#0f172a",codeText:"#e2e8f0",commentHighlight:"#d7e3fc",commentHighlightActive:"#f4d35e",commentHighlightResolved:"#cfe9d8",commentHighlightResolvedActive:"#8dc4a0",headingRule:"rgba(15, 23, 42, 0.18)",headingText:"#0f172a",imageLoadingOverlay:"rgba(255, 255, 255, 0.42)",imagePlaceholderIcon:"rgba(14, 116, 144, 0.42)",imagePlaceholderText:"rgba(15, 23, 42, 0.58)",imageSurfaceBackground:"rgba(240, 249, 255, 0.98)",imageSurfaceBorder:"rgba(14, 116, 144, 0.22)",inlineCodeBackground:"rgba(15, 23, 42, 0.08)",inlineCodeText:"#7c2d12",insertHighlightText:"#2563eb",leafAccent:"#1d4ed8",leafBackground:"#fcfbf7",leafBorder:"rgba(148, 163, 184, 0.55)",leafButtonBackground:"rgba(15, 23, 42, 0.08)",leafButtonBorder:"rgba(148, 163, 184, 0.55)",leafButtonText:"#1f2937",leafResolvedBackground:"#cfe9d8",leafResolvedBorder:"#8dc4a0",leafSecondaryText:"#334155",leafShadow:"0 14px 40px rgba(15, 23, 42, 0.16)",leafText:"#1f2937",linkText:"#1d4ed8",listMarkerText:"#1f2937",paddingX:16,paddingY:12,paragraphText:"#1f2937",selectionBackground:"rgba(125, 211, 252, 0.35)",selectionHandleBackground:"#fcfbf7",selectionHandleBorder:"#1d4ed8",tableBodyBackground:"rgba(248, 250, 252, 0.98)",tableBorder:"rgba(148, 163, 184, 0.55)",tableHeaderBackground:"rgba(226, 232, 240, 0.95)"},I4={activeBlockBackground:"rgba(125, 211, 252, 0.12)",activeBlockFlash:"rgba(226, 232, 240, 0.12)",background:"#0b1220",blockquoteRule:"rgba(103, 232, 249, 0.34)",blockquoteRuleActive:"rgba(125, 211, 252, 0.5)",blockquoteText:"#cbd5e1",caret:"#f8fafc",checkboxCheckmark:"#082f49",checkboxCheckedFill:"#67e8f9",checkboxCheckedStroke:"#67e8f9",checkboxUncheckedFill:"#0f172a",checkboxUncheckedStroke:"#64748b",codeBackground:"#020617",codeText:"#dbeafe",commentHighlight:"rgba(96, 165, 250, 0.34)",commentHighlightActive:"#facc15",commentHighlightResolved:"rgba(74, 222, 128, 0.24)",commentHighlightResolvedActive:"#4ade80",headingRule:"rgba(226, 232, 240, 0.22)",headingText:"#f8fafc",imageLoadingOverlay:"rgba(186, 230, 253, 0.18)",imagePlaceholderIcon:"rgba(125, 211, 252, 0.44)",imagePlaceholderText:"rgba(226, 232, 240, 0.62)",imageSurfaceBackground:"rgba(15, 23, 42, 0.92)",imageSurfaceBorder:"rgba(56, 189, 248, 0.28)",inlineCodeBackground:"rgba(148, 163, 184, 0.16)",inlineCodeText:"#fdba74",insertHighlightText:"#60a5fa",leafAccent:"#93c5fd",leafBackground:"#0b1220",leafBorder:"rgba(100, 116, 139, 0.7)",leafButtonBackground:"rgba(148, 163, 184, 0.16)",leafButtonBorder:"rgba(100, 116, 139, 0.7)",leafButtonText:"#dbe4f0",leafResolvedBackground:"rgba(74, 222, 128, 0.24)",leafResolvedBorder:"#4ade80",leafSecondaryText:"#cbd5e1",leafShadow:"0 18px 44px rgba(2, 6, 23, 0.42), 0 0 0 1px rgba(148, 163, 184, 0.06)",leafText:"#dbe4f0",linkText:"#93c5fd",listMarkerText:"#e2e8f0",paddingX:16,paddingY:12,paragraphText:"#dbe4f0",selectionBackground:"rgba(56, 189, 248, 0.28)",selectionHandleBackground:"#0b1220",selectionHandleBorder:"#93c5fd",tableBodyBackground:"rgba(15, 23, 42, 0.9)",tableBorder:"rgba(100, 116, 139, 0.7)",tableHeaderBackground:"rgba(30, 41, 59, 0.96)"},nJ={...g4,activeBlockBackground:"rgba(16, 185, 129, 0.14)",activeBlockFlash:"rgba(16, 185, 129, 0.26)",background:"#f3fbf6",blockquoteRule:"rgba(5, 150, 105, 0.22)",blockquoteRuleActive:"rgba(6, 95, 70, 0.38)",blockquoteText:"#166534",caret:"#14532d",codeBackground:"#052e16",codeText:"#dcfce7",commentHighlight:"rgba(52, 211, 153, 0.26)",commentHighlightActive:"#10b981",commentHighlightResolved:"rgba(187, 247, 208, 0.96)",commentHighlightResolvedActive:"#059669",headingRule:"rgba(20, 83, 45, 0.18)",headingText:"#14532d",inlineCodeBackground:"rgba(20, 83, 45, 0.08)",inlineCodeText:"#166534",insertHighlightText:"#10b981",leafAccent:"#059669",leafBackground:"#f3fbf6",leafBorder:"rgba(22, 163, 74, 0.24)",leafButtonBackground:"rgba(20, 83, 45, 0.08)",leafButtonBorder:"rgba(22, 163, 74, 0.28)",leafButtonText:"#14532d",leafResolvedBackground:"#d1fae5",leafResolvedBorder:"#10b981",leafSecondaryText:"#166534",leafShadow:"0 14px 40px rgba(20, 83, 45, 0.14)",leafText:"#14532d",linkText:"#047857",paragraphText:"#14532d",selectionBackground:"rgba(52, 211, 153, 0.24)",selectionHandleBackground:"#f3fbf6",selectionHandleBorder:"#059669",tableBodyBackground:"rgba(243, 251, 246, 0.96)",tableBorder:"rgba(22, 163, 74, 0.24)",tableHeaderBackground:"rgba(220, 252, 231, 0.96)"},tJ={...I4,activeBlockBackground:"rgba(168, 85, 247, 0.16)",activeBlockFlash:"rgba(243, 232, 255, 0.13)",blockquoteRule:"rgba(196, 181, 253, 0.34)",blockquoteRuleActive:"rgba(216, 180, 254, 0.44)",caret:"#f5f3ff",codeBackground:"#1e1b4b",codeText:"#ede9fe",commentHighlight:"rgba(167, 139, 250, 0.28)",commentHighlightActive:"#c084fc",commentHighlightResolved:"rgba(45, 212, 191, 0.22)",commentHighlightResolvedActive:"#2dd4bf",headingRule:"rgba(233, 213, 255, 0.24)",headingText:"#f5f3ff",inlineCodeBackground:"rgba(196, 181, 253, 0.16)",inlineCodeText:"#f9a8d4",insertHighlightText:"#c084fc",leafAccent:"#d8b4fe",leafBackground:"#12091f",leafBorder:"rgba(139, 92, 246, 0.34)",leafButtonBackground:"rgba(196, 181, 253, 0.16)",leafButtonBorder:"rgba(139, 92, 246, 0.34)",leafButtonText:"#ede9fe",leafResolvedBackground:"rgba(45, 212, 191, 0.22)",leafResolvedBorder:"#2dd4bf",leafSecondaryText:"#ddd6fe",leafShadow:"0 20px 48px rgba(2, 6, 23, 0.48), 0 0 0 1px rgba(196, 181, 253, 0.08)",leafText:"#f5f3ff",linkText:"#d8b4fe",listMarkerText:"#ede9fe",paragraphText:"#ede9fe",selectionBackground:"rgba(167, 139, 250, 0.26)",selectionHandleBackground:"#12091f",selectionHandleBorder:"#d8b4fe",tableBodyBackground:"rgba(30, 27, 75, 0.88)",tableBorder:"rgba(139, 92, 246, 0.34)",tableHeaderBackground:"rgba(49, 46, 129, 0.94)"};function $Z($){let M=eJ(()=>aA($),[$]),[J,Z]=xA(M.light),X=eJ(()=>iA(J),[J]);return cA(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function"){Z(M.light);return}let D=window.matchMedia("(prefers-color-scheme: dark)"),Y=()=>{Z(D.matches?M.dark:M.light)};if(Y(),typeof D.addEventListener==="function")return D.addEventListener("change",Y),()=>{D.removeEventListener("change",Y)};return D.addListener(Y),()=>{D.removeListener(Y)}},[M]),{theme:J,themeStyles:X}}function dA($){return"light"in $&&"dark"in $}function aA($){if(!$)return{dark:I4,light:g4};if(dA($))return $;return{dark:$,light:$}}function iA($){return{"--documint-background":$.background,"--documint-leaf-button-bg":$.leafButtonBackground,"--documint-leaf-button-border":$.leafButtonBorder,"--documint-leaf-button-text":$.leafButtonText,"--documint-leaf-accent":$.leafAccent,"--documint-leaf-bg":$.leafBackground,"--documint-leaf-border":$.leafBorder,"--documint-leaf-font-family":'"Avenir Next", "Segoe UI", sans-serif',"--documint-leaf-shadow":$.leafShadow??void 0,"--documint-leaf-secondary-text":$.leafSecondaryText,"--documint-leaf-resolved-bg":$.leafResolvedBackground,"--documint-leaf-resolved-border":$.leafResolvedBorder,"--documint-leaf-text":$.leafText,"--documint-mention-bg":$.mentionBackground??void 0,"--documint-mention-text":$.mentionText??void 0,"--documint-selection-handle-bg":$.selectionHandleBackground,"--documint-selection-handle-border":$.selectionHandleBorder}}import{useEffect as nA,useEffectEvent as x0,useRef as A$,useState as U8}from"react";import{useMemo as sA}from"react";function MZ($){return sA(()=>oA({current:null},$),[$])}function oA($,M){return{peek(){return $.current},get(){let J=$.current;if(J!==null)return J;let Z=M();return $.current=Z,Z},invalidate(){$.current=null}}}function JZ($,M){let J=M.getBoundingClientRect();return{x:$.clientX-J.left+M.scrollLeft,y:$.clientY-J.top+M.scrollTop}}function ZZ({editorState:$,editorStateRef:M,renderResources:J,theme:Z}){let X=A$(W1()),D=A$(null),Y=A$({height:240,top:0}),[Q,K]=U8(0),[q,U]=U8(240),[N,A]=U8(0),[V,B]=U8(240),G=tA(Q),b=x0(()=>{let F=M.current??$,H=Y.current;return N6(F,{height:H.height,paddingX:Z.paddingX,paddingY:Z.paddingY,top:H.top,width:G},X.current,J)}),P=MZ(b),y=x0((F)=>{B((H)=>{let v=$V(F,Y.current.height);return H===v?H:v})}),z=x0((F)=>{Y.current={...Y.current,top:F},A((H)=>H===F?H:F),P.invalidate()}),L=x0((F)=>{let H=eA(F),v=H.top!==Y.current.top;if(Y.current=H,A((h)=>h===H.top?h:H.top),v)P.invalidate()}),R=x0((F)=>{let H=D.current;if(!H)return z(F),F;H.scrollTop=F;let v=H.scrollTop;return z(v),v}),m=x0(()=>{return D.current?.scrollTop??Y.current.top}),E=x0((F,H)=>{let v=F!==null&&F.documentIndex!==H.documentIndex,h=P.peek();if(!(!v||!h||h.layout.regionLineIndices.has(H.selection.focus.regionId)))P.invalidate()}),_=x0(()=>{return P.invalidate(),P.get()}),j=x0((F)=>{let H=D.current;return H?JZ(F,H):null}),C=x0((F)=>{gJ(D.current,F)});return nA(()=>{let F=D.current;if(!F||typeof ResizeObserver>"u")return;let H=new ResizeObserver((v)=>{let h=v[0];if(!h)return;let l=Math.max(0,Math.floor(h.contentRect.width)),p=XZ(F);Y.current={...Y.current,height:p},K((O)=>O===l?O:l),U((O)=>O===p?O:p)});return H.observe(F),()=>H.disconnect()},[D]),{actions:{autoScrollDuringDrag:C,getScrollTop:m,observePreparedViewport:y,observeScrollContainer:L,prepareNextPaint:_,reconcileEditorState:E,resolvePoint:j,scrollTo:R},props:{getScrollContainer:(F)=>({onScroll:(H)=>{L(H.currentTarget),F?.onScroll?.(H)},ref:D}),scrollContent:{style:{height:`${V}px`}}},refs:{scrollContainer:D},state:{layoutWidth:G,preparedViewport:P,scrollContentHeight:V,surfaceWidth:Q,viewportHeight:q,viewportTop:N}}}function tA($){return Math.max(240,Math.floor($||480))}function XZ($){return Math.max(240,$.clientHeight)}function eA($){return{height:XZ($),top:$.scrollTop}}function $V($,M){return Math.max(M,Math.ceil($.totalHeight+24))}function MV(){if(typeof window>"u")return 1;return Math.max(1,window.devicePixelRatio||1)}function V$($,{paintHeight:M,paintTop:J,width:Z}){if(!$)return null;let X=Math.max(240,Math.ceil(M)),D=MV();$.width=Math.ceil(Z*D),$.height=Math.ceil(X*D),$.style.width=`${Z}px`,$.style.height=`${X}px`,$.style.transform=`translateY(${J}px)`;let Y=$.getContext("2d");if(!Y)return null;return{context:Y,devicePixelRatio:D,height:X,width:Z}}function G$($,M){return $.activeBlockType===M.activeBlockType&&$.activeCommentThreadIndex===M.activeCommentThreadIndex&&$.activeSpanKind===M.activeSpanKind&&$.canonicalContent===M.canonicalContent&&$.characterCount===M.characterCount&&$.commentThreadCount===M.commentThreadCount&&$.layoutWidth===M.layoutWidth&&$.resolvedCommentCount===M.resolvedCommentCount&&$.selectionFrom===M.selectionFrom&&$.selectionTo===M.selectionTo}function DZ($,M){if(!M?.length||!$?.length)return;let J=new Map($.map((X)=>[X.id,X])),Z=[];for(let X of M){let D=J.get(X.userId);if(!D)continue;Z.push({...D,color:X.color,cursor:X.cursor})}return Z.length===0?void 0:Z}function QZ($,M){if(!$)return{didReconcile:!1,state:M};let J=JV($,M)??NV($,M);return J?{didReconcile:!0,state:J}:{didReconcile:!1,state:M}}function JV($,M){let J=ZV($,M);return J?D0(M,J,!1):null}function ZV($,M){if(_$($.selection.anchor,$.selection.focus)){let D=B$($,M,$.selection.focus,"neutral");return D?{anchor:D,focus:D}:null}let J=qV($),Z=B$($,M,$.selection.anchor,J.anchor),X=B$($,M,$.selection.focus,J.focus);return Z&&X?{anchor:Z,focus:X}:null}function B$($,M,J,Z){let X=$.documentIndex.regionIndex.get(J.regionId);if(!X)return null;let D=F$(X,M);if(!D)return null;return{offset:DV(X.text,D.text,J.offset,Z),regionId:D.id}}function F$($,M){let J=M.documentIndex.regionIndex.get($.id);if(J)return J;if($.text.length===0)return null;let Z=XV($,M);if(Z)return Z;return M.documentIndex.regionPathIndex.get($.path)??null}function XV($,M){let J=null;for(let Z of M.documentIndex.regions){if(Z.blockType!==$.blockType||Z.text!==$.text)continue;if(J)return null;J=Z}return J}function DV($,M,J,Z){let X=j0(J,0,$.length),{prefix:D,suffix:Y}=C8($,X,X),Q=YV(M,D,Y);if(Q!==null)return Q;let K=QV(M,D),q=KV(M,Y);if(Z==="before-suffix")return q??K??j0(J,0,M.length);return K??q??j0(J,0,M.length)}function YV($,M,J){let Z=l1($,M,J).filter((X)=>X.startOffset===X.endOffset);return Z.length===1?Z[0].startOffset:null}function QV($,M){let J=u0($,M);return J.length===1?J[0]+M.length:null}function KV($,M){let J=u0($,M);return J.length===1?J[0]:null}function qV($){let{anchor:M,focus:J}=$.selection;if(_$(M,J))return{anchor:"neutral",focus:"neutral"};return UV($,M,J)<=0?{anchor:"before-suffix",focus:"after-prefix"}:{anchor:"after-prefix",focus:"before-suffix"}}function UV($,M,J){let Z=$.documentIndex.regionOrderIndex.get(M.regionId),X=$.documentIndex.regionOrderIndex.get(J.regionId);if(Z===void 0||X===void 0)return 0;return Z===X?M.offset-J.offset:Z-X}function NV($,M){if(!_$($.selection.anchor,$.selection.focus))return null;let J=AV($);if(!J)return null;let Z=VV($,M,J);if(Z===null)return null;return GV(M,Z)}function AV($){let M=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!M||M.blockType!=="paragraph"||M.text.length>0)return null;return $.documentIndex.blockIndex.get(M.blockId)?.parentBlockId===null?M:null}function VV($,M,J){let Z=YZ($,J.rootIndex,"before"),X=YZ($,J.rootIndex,"after"),D=Z?F$(Z,M):null,Y=X?F$(X,M):null;if(D&&Y)return D.rootIndex<Y.rootIndex?Y.rootIndex:null;if(D)return D.rootIndex+1;if(Y)return Y.rootIndex;return null}function GV($,M){let J=I1($.documentIndex.document,M,0,[r({text:""})]),Z={...$,documentIndex:$2($.documentIndex,J,M,0)},X=p2(Z.documentIndex,M0(M));return X?D0(Z,X,!1):null}function YZ($,M,J){let Z=J==="before"?-1:1;for(let X=M+Z;X>=0&&X<$.documentIndex.roots.length;X+=Z){let D=BV($,X,J);if(D)return D}return null}function BV($,M,J){let Z=$.documentIndex.roots[M]?.regions??[],X=J==="before"?Z.length-1:0,D=J==="before"?-1:1;for(let Y=X;Y>=0&&Y<Z.length;Y+=D){let Q=Z[Y];if(Q&&Q.text.length>0)return Q}return null}function _$($,M){return $.regionId===M.regionId&&$.offset===M.offset}import{jsx as x,jsxs as A8,Fragment as EV}from"react/jsx-runtime";function V8({blocks:$}){return x(EV,{children:$.map((M)=>FV(M))})}function FV($){switch($.type){case"blockquote":return x("blockquote",{className:"preview-block preview-block-blockquote",children:x(V8,{blocks:$.children})},$.id);case"code":return A8("div",{className:"preview-block preview-block-code",children:[x("div",{className:"preview-rich-header",children:HV($.language,$.meta)}),x("pre",{children:x("code",{children:$.source||" "})})]},$.id);case"heading":{let M=`h${$.depth}`;return x(M,{className:"preview-block preview-block-heading",children:N8($.children)},$.id)}case"list":return $.ordered?x("ol",{className:"preview-block preview-block-list",start:$.start??1,children:$.items.map((M)=>b$(M))},$.id):x("ul",{className:"preview-block preview-block-list",children:$.items.map((M)=>b$(M))},$.id);case"listItem":return b$($);case"paragraph":return x("p",{className:"preview-block preview-block-paragraph",children:N8($.children)},$.id);case"table":return A8("div",{className:"preview-block preview-block-table",children:[x("div",{className:"preview-rich-header",children:PV($.rows.length,$.rows[0]?.cells.length??0,$.align.filter((M)=>M!==null).length)}),x("div",{className:"preview-table-scroll",children:x("table",{children:x("tbody",{children:$.rows.map((M)=>x("tr",{children:M.cells.map((J)=>x("td",{children:N8(J.children)},J.id))},M.id))})})})]},$.id);case"thematicBreak":return x("hr",{className:"preview-block preview-block-rule"},$.id);case"directive":return x("pre",{className:`preview-block preview-block-directive preview-block-directive-${$.name}`,children:$.body},$.id);case"unsupported":return x("pre",{className:"preview-block preview-block-unsupported",children:$.source},$.id)}}function b$($){return x("li",{className:"preview-block preview-block-list-item",children:x(V8,{blocks:$.children})},$.id)}function N8($){return $.map((M)=>{switch(M.type){case"break":return x("br",{},M.id);case"image":return A8("span",{className:"preview-inline preview-inline-image",children:[x("img",{alt:M.alt??"",src:M.url,title:M.title??""}),A8("span",{children:[x("strong",{children:zV(M.alt)}),x("small",{children:WV(M.url,M.title)})]})]},M.id);case"inlineCode":return x("code",{className:"preview-inline preview-inline-code",children:M.code},M.id);case"link":return _V(M);case"text":return x("span",{className:"preview-inline",children:bV(M.text,M.marks)},M.id);case"unsupported":return x("span",{className:"preview-inline preview-inline-unsupported",children:M.source},M.id)}})}function _V($){return x("a",{className:"preview-inline preview-inline-link",href:$.url,children:N8($.children)},$.id)}function bV($,M){let J=$;for(let Z of M)switch(Z){case"strikethrough":J=x("del",{children:J});break;case"italic":J=x("em",{children:J});break;case"bold":J=x("strong",{children:J});break;case"underline":J=x("ins",{children:J});break}return J}function HV($,M){return[$??"plain text",M].filter(Boolean).join(" • ")}function PV($,M,J){let Z=J>0?`${J} aligned ${J===1?"column":"columns"}`:"no alignment";return`${$} ${$===1?"row":"rows"} • ${M} ${M===1?"column":"columns"} • ${Z}`}function zV($){return $?.trim()?$:"Untitled image"}function WV($,M){return M?.trim()?`${M} • ${$}`:$}var KZ=`/* Base Documint host and SSR-fallback styles. */
|
|
12
|
+
`)}var u8=null,_X;function FX(){if(u8===null)u8=new Intl.Segmenter(_X,{granularity:"word"});return u8}var HX=/\p{Script=Arabic}/u,Z5=/\p{M}/u,u9=/\p{Nd}/u;function v8($){return HX.test($)}function s0($){for(let M of $){let J=M.codePointAt(0);if(J>=19968&&J<=40959||J>=13312&&J<=19903||J>=131072&&J<=173791||J>=173824&&J<=177983||J>=177984&&J<=178207||J>=178208&&J<=183983||J>=183984&&J<=191471||J>=196608&&J<=201551||J>=63744&&J<=64255||J>=194560&&J<=195103||J>=12288&&J<=12351||J>=12352&&J<=12447||J>=12448&&J<=12543||J>=44032&&J<=55215||J>=65280&&J<=65519)return!0}return!1}var I8=new Set([",",".","!",":",";","?","、","。","・",")","〕","〉","》","」","』","】","〗","〙","〛","ー","々","〻","ゝ","ゞ","ヽ","ヾ"]),O2=new Set(['"',"(","[","{","“","‘","«","‹","(","〔","〈","《","「","『","【","〖","〘","〚"]),p8=new Set(["'","’"]),a1=new Set([".",",","!","?",":",";","،","؛","؟","।","॥","၊","။","၌","၍","၏",")","]","}","%",'"',"”","’","»","›","…"]),zX=new Set([":",".","،","؛"]),EX=new Set(["၏"]),WX=new Set(["”","’","»","›","」","』","】","》","〉","〕",")"]);function BX($){if(l8($))return!0;let M=!1;for(let J of $){if(a1.has(J)){M=!0;continue}if(M&&Z5.test(J))continue;return!1}return M}function PX($){for(let M of $)if(!I8.has(M)&&!a1.has(M))return!1;return $.length>0}function yX($){if(l8($))return!0;for(let M of $)if(!O2.has(M)&&!p8.has(M)&&!Z5.test(M))return!1;return $.length>0}function l8($){let M=!1;for(let J of $){if(J==="\\"||Z5.test(J))continue;if(O2.has(J)||a1.has(J)||p8.has(J)){M=!0;continue}return!1}return M}function bX($){let M=Array.from($),J=M.length;while(J>0){let Z=M[J-1];if(Z5.test(Z)){J--;continue}if(O2.has(Z)||p8.has(Z)){J--;continue}break}if(J<=0||J===M.length)return null;return{head:M.slice(0,J).join(""),tail:M.slice(J).join("")}}function wX($,M){if($.length===0)return!1;for(let J of $)if(J!==M)return!1;return!0}function TX($){if(!v8($)||$.length===0)return!1;return zX.has($[$.length-1])}function OX($){if($.length===0)return!1;return EX.has($[$.length-1])}function jX($){if($.length<2||$[0]!==" ")return null;let M=$.slice(1);if(/^\p{M}+$/u.test(M))return{space:" ",marks:M};return null}function d8($){for(let M=$.length-1;M>=0;M--){let J=$[M];if(WX.has(J))return!0;if(!a1.has(J))return!1}return!1}function LX($,M){if(M.preserveOrdinarySpaces||M.preserveHardBreaks){if($===" ")return"preserved-space";if($==="\t")return"tab";if(M.preserveHardBreaks&&$===`
|
|
13
|
+
`)return"hard-break"}if($===" ")return"space";if($===" "||$===" "||$===""||$==="\uFEFF")return"glue";if($==="")return"zero-width-break";if($==="")return"soft-hyphen";return"text"}function i0($){return $.length===1?$[0]:$.join("")}function CX($,M,J,Z){let X=[],Y=null,Q=[],K=J,q=!1,D=0;for(let A of $){let V=LX(A,Z),U=V==="text"&&M;if(Y!==null&&V===Y&&U===q){Q.push(A),D+=A.length;continue}if(Y!==null)X.push({text:i0(Q),isWordLike:q,kind:Y,start:K});Y=V,Q=[A],K=J+D,q=U,D+=A.length}if(Y!==null)X.push({text:i0(Q),isWordLike:q,kind:Y,start:K});return X}function h8($){return $==="space"||$==="preserved-space"||$==="zero-width-break"||$==="hard-break"}var RX=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function fX($,M){let J=$.texts[M];if(J.startsWith("www."))return!0;return RX.test(J)&&M+1<$.len&&$.kinds[M+1]==="text"&&$.texts[M+1]==="//"}function mX($){return $.includes("?")&&($.includes("://")||$.startsWith("www."))}function SX($){let M=$.texts.slice(),J=$.isWordLike.slice(),Z=$.kinds.slice(),X=$.starts.slice();for(let Q=0;Q<$.len;Q++){if(Z[Q]!=="text"||!fX($,Q))continue;let K=[M[Q]],q=Q+1;while(q<$.len&&!h8(Z[q])){K.push(M[q]),J[Q]=!0;let D=M[q].includes("?");if(Z[q]="text",M[q]="",q++,D)break}M[Q]=i0(K)}let Y=0;for(let Q=0;Q<M.length;Q++){let K=M[Q];if(K.length===0)continue;if(Y!==Q)M[Y]=K,J[Y]=J[Q],Z[Y]=Z[Q],X[Y]=X[Q];Y++}return M.length=Y,J.length=Y,Z.length=Y,X.length=Y,{len:Y,texts:M,isWordLike:J,kinds:Z,starts:X}}function kX($){let M=[],J=[],Z=[],X=[];for(let Y=0;Y<$.len;Y++){let Q=$.texts[Y];if(M.push(Q),J.push($.isWordLike[Y]),Z.push($.kinds[Y]),X.push($.starts[Y]),!mX(Q))continue;let K=Y+1;if(K>=$.len||h8($.kinds[K]))continue;let q=[],D=$.starts[K],A=K;while(A<$.len&&!h8($.kinds[A]))q.push($.texts[A]),A++;if(q.length>0)M.push(i0(q)),J.push(!0),Z.push("text"),X.push(D),Y=A-1}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}var uX=new Set([":","-","/","×",",",".","+","–","—"]),S9=/^[A-Za-z0-9_]+[,:;]*$/,k9=/[,:;]+$/;function v9($){for(let M of $)if(u9.test(M))return!0;return!1}function g8($){if($.length===0)return!1;for(let M of $){if(u9.test(M)||uX.has(M))continue;return!1}return!0}function vX($){let M=[],J=[],Z=[],X=[];for(let Y=0;Y<$.len;Y++){let Q=$.texts[Y],K=$.kinds[Y];if(K==="text"&&g8(Q)&&v9(Q)){let q=[Q],D=Y+1;while(D<$.len&&$.kinds[D]==="text"&&g8($.texts[D]))q.push($.texts[D]),D++;M.push(i0(q)),J.push(!0),Z.push("text"),X.push($.starts[Y]),Y=D-1;continue}M.push(Q),J.push($.isWordLike[Y]),Z.push(K),X.push($.starts[Y])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function hX($){let M=[],J=[],Z=[],X=[];for(let Y=0;Y<$.len;Y++){let Q=$.texts[Y],K=$.kinds[Y],q=$.isWordLike[Y];if(K==="text"&&q&&S9.test(Q)){let D=[Q],A=k9.test(Q),V=Y+1;while(A&&V<$.len&&$.kinds[V]==="text"&&$.isWordLike[V]&&S9.test($.texts[V])){let U=$.texts[V];D.push(U),A=k9.test(U),V++}M.push(i0(D)),J.push(!0),Z.push("text"),X.push($.starts[Y]),Y=V-1;continue}M.push(Q),J.push(q),Z.push(K),X.push($.starts[Y])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function gX($){let M=[],J=[],Z=[],X=[];for(let Y=0;Y<$.len;Y++){let Q=$.texts[Y];if($.kinds[Y]==="text"&&Q.includes("-")){let K=Q.split("-"),q=K.length>1;for(let D=0;D<K.length;D++){let A=K[D];if(!q)break;if(A.length===0||!v9(A)||!g8(A))q=!1}if(q){let D=0;for(let A=0;A<K.length;A++){let V=K[A],U=A<K.length-1?`${V}-`:V;M.push(U),J.push(!0),Z.push("text"),X.push($.starts[Y]+D),D+=U.length}continue}}M.push(Q),J.push($.isWordLike[Y]),Z.push($.kinds[Y]),X.push($.starts[Y])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function IX($){let M=[],J=[],Z=[],X=[],Y=0;while(Y<$.len){let Q=[$.texts[Y]],K=$.isWordLike[Y],q=$.kinds[Y],D=$.starts[Y];if(q==="glue"){let A=[Q[0]],V=D;Y++;while(Y<$.len&&$.kinds[Y]==="glue")A.push($.texts[Y]),Y++;let U=i0(A);if(Y<$.len&&$.kinds[Y]==="text")Q[0]=U,Q.push($.texts[Y]),K=$.isWordLike[Y],q="text",D=V,Y++;else{M.push(U),J.push(!1),Z.push("glue"),X.push(V);continue}}else Y++;if(q==="text")while(Y<$.len&&$.kinds[Y]==="glue"){let A=[];while(Y<$.len&&$.kinds[Y]==="glue")A.push($.texts[Y]),Y++;let V=i0(A);if(Y<$.len&&$.kinds[Y]==="text"){Q.push(V,$.texts[Y]),K=K||$.isWordLike[Y],Y++;continue}Q.push(V)}M.push(i0(Q)),J.push(K),Z.push(q),X.push(D)}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function pX($){let M=$.texts.slice(),J=$.isWordLike.slice(),Z=$.kinds.slice(),X=$.starts.slice();for(let Y=0;Y<M.length-1;Y++){if(Z[Y]!=="text"||Z[Y+1]!=="text")continue;if(!s0(M[Y])||!s0(M[Y+1]))continue;let Q=bX(M[Y]);if(Q===null)continue;M[Y]=Q.head,M[Y+1]=Q.tail+M[Y+1],X[Y+1]=X[Y]+Q.head.length}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function lX($,M,J){let Z=FX(),X=0,Y=[],Q=[],K=[],q=[];for(let U of Z.segment($))for(let G of CX(U.segment,U.isWordLike??!1,U.index,J)){let _=G.kind==="text";if(M.carryCJKAfterClosingQuote&&_&&X>0&&K[X-1]==="text"&&s0(G.text)&&s0(Y[X-1])&&d8(Y[X-1]))Y[X-1]+=G.text,Q[X-1]=Q[X-1]||G.isWordLike;else if(_&&X>0&&K[X-1]==="text"&&PX(G.text)&&s0(Y[X-1]))Y[X-1]+=G.text,Q[X-1]=Q[X-1]||G.isWordLike;else if(_&&X>0&&K[X-1]==="text"&&OX(Y[X-1]))Y[X-1]+=G.text,Q[X-1]=Q[X-1]||G.isWordLike;else if(_&&X>0&&K[X-1]==="text"&&G.isWordLike&&v8(G.text)&&TX(Y[X-1]))Y[X-1]+=G.text,Q[X-1]=!0;else if(_&&!G.isWordLike&&X>0&&K[X-1]==="text"&&G.text.length===1&&G.text!=="-"&&G.text!=="—"&&wX(Y[X-1],G.text))Y[X-1]+=G.text;else if(_&&!G.isWordLike&&X>0&&K[X-1]==="text"&&(BX(G.text)||G.text==="-"&&Q[X-1]))Y[X-1]+=G.text;else Y[X]=G.text,Q[X]=G.isWordLike,K[X]=G.kind,q[X]=G.start,X++}for(let U=1;U<X;U++)if(K[U]==="text"&&!Q[U]&&l8(Y[U])&&K[U-1]==="text")Y[U-1]+=Y[U],Q[U-1]=Q[U-1]||Q[U],Y[U]="";for(let U=X-2;U>=0;U--)if(K[U]==="text"&&!Q[U]&&yX(Y[U])){let G=U+1;while(G<X&&Y[G]==="")G++;if(G<X&&K[G]==="text")Y[G]=Y[U]+Y[G],q[G]=q[U],Y[U]=""}let D=0;for(let U=0;U<X;U++){let G=Y[U];if(G.length===0)continue;if(D!==U)Y[D]=G,Q[D]=Q[U],K[D]=K[U],q[D]=q[U];D++}Y.length=D,Q.length=D,K.length=D,q.length=D;let A=IX({len:D,texts:Y,isWordLike:Q,kinds:K,starts:q}),V=pX(hX(gX(vX(kX(SX(A))))));for(let U=0;U<V.len-1;U++){let G=jX(V.texts[U]);if(G===null)continue;if(V.kinds[U]!=="space"&&V.kinds[U]!=="preserved-space"||V.kinds[U+1]!=="text"||!v8(V.texts[U+1]))continue;V.texts[U]=G.space,V.isWordLike[U]=!1,V.kinds[U]=V.kinds[U]==="preserved-space"?"preserved-space":"space",V.texts[U+1]=G.marks+V.texts[U+1],V.starts[U+1]=V.starts[U]+G.space.length}return V}function dX($,M){if($.len===0)return[];if(!M.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len}];let J=[],Z=0;for(let X=0;X<$.len;X++){if($.kinds[X]!=="hard-break")continue;J.push({startSegmentIndex:Z,endSegmentIndex:X,consumedEndSegmentIndex:X+1}),Z=X+1}if(Z<$.len)J.push({startSegmentIndex:Z,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len});return J}function h9($,M,J="normal"){let Z=VX(J),X=Z.mode==="pre-wrap"?NX($):GX($);if(X.length===0)return{normalized:X,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let Y=lX(X,M,Z);return{normalized:X,chunks:dX(Y,Z),...Y}}var s1=null,g9=new Map,i1=null,rX=/\p{Emoji_Presentation}/u,xX=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,r8=null,I9=new Map;function x8(){if(s1!==null)return s1;if(typeof OffscreenCanvas<"u")return s1=new OffscreenCanvas(1,1).getContext("2d"),s1;if(typeof document<"u")return s1=document.createElement("canvas").getContext("2d"),s1;throw Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function cX($){let M=g9.get($);if(!M)M=new Map,g9.set($,M);return M}function Z1($,M){let J=M.get($);if(J===void 0)J={width:x8().measureText($).width,containsCJK:s0($)},M.set($,J);return J}function o1(){if(i1!==null)return i1;if(typeof navigator>"u")return i1={lineFitEpsilon:0.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},i1;let $=navigator.userAgent,J=navigator.vendor==="Apple Computer, Inc."&&$.includes("Safari/")&&!$.includes("Chrome/")&&!$.includes("Chromium/")&&!$.includes("CriOS/")&&!$.includes("FxiOS/")&&!$.includes("EdgiOS/"),Z=$.includes("Chrome/")||$.includes("Chromium/")||$.includes("CriOS/")||$.includes("Edg/");return i1={lineFitEpsilon:J?0.015625:0.005,carryCJKAfterClosingQuote:Z,preferPrefixWidthsForBreakableRuns:J,preferEarlySoftHyphenBreak:J},i1}function aX($){let M=$.match(/(\d+(?:\.\d+)?)\s*px/);return M?parseFloat(M[1]):16}function c8(){if(r8===null)r8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return r8}function sX($){return rX.test($)||$.includes("️")}function p9($){return xX.test($)}function iX($,M){let J=I9.get($);if(J!==void 0)return J;let Z=x8();Z.font=$;let X=Z.measureText("\uD83D\uDE00").width;if(J=0,X>M+0.5&&typeof document<"u"&&document.body!==null){let Y=document.createElement("span");Y.style.font=$,Y.style.display="inline-block",Y.style.visibility="hidden",Y.style.position="absolute",Y.textContent="\uD83D\uDE00",document.body.appendChild(Y);let Q=Y.getBoundingClientRect().width;if(document.body.removeChild(Y),X-Q>0.5)J=X-Q}return I9.set($,J),J}function oX($){let M=0,J=c8();for(let Z of J.segment($))if(sX(Z.segment))M++;return M}function nX($,M){if(M.emojiCount===void 0)M.emojiCount=oX($);return M.emojiCount}function X1($,M,J){if(J===0)return M.width;return M.width-nX($,M)*J}function l9($,M,J,Z){if(M.graphemeWidths!==void 0)return M.graphemeWidths;let X=[],Y=c8();for(let Q of Y.segment($)){let K=Z1(Q.segment,J);X.push(X1(Q.segment,K,Z))}return M.graphemeWidths=X.length>1?X:null,M.graphemeWidths}function d9($,M,J,Z){if(M.graphemePrefixWidths!==void 0)return M.graphemePrefixWidths;let X=[],Y=c8(),Q="";for(let K of Y.segment($)){Q+=K.segment;let q=Z1(Q,J);X.push(X1(Q,q,Z))}return M.graphemePrefixWidths=X.length>1?X:null,M.graphemePrefixWidths}function r9($,M){let J=x8();J.font=$;let Z=cX($),X=aX($),Y=M?iX($,X):0;return{cache:Z,fontSize:X,emojiCorrection:Y}}function X5($){return $==="space"||$==="preserved-space"||$==="tab"||$==="zero-width-break"||$==="soft-hyphen"}function tX($,M){while(M<$.widths.length){let J=$.kinds[M];if(J!=="space"&&J!=="zero-width-break"&&J!=="soft-hyphen")break;M++}return M}function eX($,M){if(M<=0)return 0;let J=$%M;if(Math.abs(J)<=0.000001)return M;return M-J}function x9($,M,J,Z){if(!Z||M===null)return $[J];return M[J]-(J>0?M[J-1]:0)}function $Y($,M,J,Z,X,Y){let Q=0,K=M;while(Q<$.length){let q=Y?M+$[Q]:K+$[Q];if((Q+1<$.length?q+X:q)>J+Z)break;K=q,Q++}return{fitCount:Q,fittedWidth:K}}function MY($,M,J){let{widths:Z,kinds:X,breakableWidths:Y,breakablePrefixWidths:Q}=$;if(Z.length===0)return 0;let K=o1(),q=K.lineFitEpsilon,D=0,A=0,V=!1,U=0,G=0,_=0,N=0,H=-1,E=0;function L(){H=-1,E=0}function W(P=_,y=N,F=A){D++,J?.({startSegmentIndex:U,startGraphemeIndex:G,endSegmentIndex:P,endGraphemeIndex:y,width:F}),A=0,V=!1,L()}function R(P,y){V=!0,U=P,G=0,_=P+1,N=0,A=y}function f(P,y,F){V=!0,U=P,G=y,_=P,N=y+1,A=F}function I(P,y){if(!V){R(P,y);return}A+=y,_=P+1,N=0}function B(P,y){if(!X5(X[P]))return;H=P+1,E=A-y}function b(P){z(P,0)}function z(P,y){let F=Y[P],C=Q[P]??null;for(let v=y;v<F.length;v++){let h=x9(F,C,v,K.preferPrefixWidthsForBreakableRuns);if(!V){f(P,v,h);continue}if(A+h>M+q)W(),f(P,v,h);else A+=h,_=P,N=v+1}if(V&&_===P&&N===F.length)_=P+1,N=0}let T=0;while(T<Z.length){if(!V){if(T=tX($,T),T>=Z.length)break}let P=Z[T],y=X[T];if(!V){if(P>M&&Y[T]!==null)b(T);else R(T,P);B(T,P),T++;continue}if(A+P>M+q){if(X5(y)){I(T,P),W(T+1,0,A-P),T++;continue}if(H>=0){if(_>H||_===H&&N>0){W();continue}W(H,0,E);continue}if(P>M&&Y[T]!==null){W(),b(T),T++;continue}W();continue}I(T,P),B(T,P),T++}if(V)W();return D}function c9($,M,J){if($.simpleLineWalkFastPath)return MY($,M,J);let{widths:Z,lineEndFitAdvances:X,lineEndPaintAdvances:Y,kinds:Q,breakableWidths:K,breakablePrefixWidths:q,discretionaryHyphenWidth:D,tabStopAdvance:A,chunks:V}=$;if(Z.length===0||V.length===0)return 0;let U=o1(),G=U.lineFitEpsilon,_=0,N=0,H=!1,E=0,L=0,W=0,R=0,f=-1,I=0,B=0,b=null;function z(){f=-1,I=0,B=0,b=null}function T(w=W,m=R,S=N){_++,J?.({startSegmentIndex:E,startGraphemeIndex:L,endSegmentIndex:w,endGraphemeIndex:m,width:S}),N=0,H=!1,z()}function P(w,m){H=!0,E=w,L=0,W=w+1,R=0,N=m}function y(w,m,S){H=!0,E=w,L=m,W=w,R=m+1,N=S}function F(w,m){if(!H){P(w,m);return}N+=m,W=w+1,R=0}function C(w,m){if(!X5(Q[w]))return;let S=Q[w]==="tab"?0:X[w],c=Q[w]==="tab"?m:Y[w];f=w+1,I=N-m+S,B=N-m+c,b=Q[w]}function v(w){h(w,0)}function h(w,m){let S=K[w],c=q[w]??null;for(let l=m;l<S.length;l++){let F0=x9(S,c,l,U.preferPrefixWidthsForBreakableRuns);if(!H){y(w,l,F0);continue}if(N+F0>M+G)T(),y(w,l,F0);else N+=F0,W=w,R=l+1}if(H&&W===w&&R===S.length)W=w+1,R=0}function g(w){if(b!=="soft-hyphen")return!1;let m=K[w];if(m===null)return!1;let S=U.preferPrefixWidthsForBreakableRuns?q[w]??m:m,c=S!==m,{fitCount:l,fittedWidth:F0}=$Y(S,N,M,G,D,c);if(l===0)return!1;if(N=F0,W=w,R=l,z(),l===m.length)return W=w+1,R=0,!0;return T(w,l,F0+D),h(w,l),!0}function O(w){_++,J?.({startSegmentIndex:w.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:w.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),z()}for(let w=0;w<V.length;w++){let m=V[w];if(m.startSegmentIndex===m.endSegmentIndex){O(m);continue}H=!1,N=0,E=m.startSegmentIndex,L=0,W=m.startSegmentIndex,R=0,z();let S=m.startSegmentIndex;while(S<m.endSegmentIndex){let c=Q[S],l=c==="tab"?eX(N,A):Z[S];if(c==="soft-hyphen"){if(H)W=S+1,R=0,f=S+1,I=N+D,B=N+D,b=c;S++;continue}if(!H){if(l>M&&K[S]!==null)v(S);else P(S,l);C(S,l),S++;continue}if(N+l>M+G){let x0=N+(c==="tab"?0:X[S]),f0=N+(c==="tab"?l:Y[S]);if(b==="soft-hyphen"&&U.preferEarlySoftHyphenBreak&&I<=M+G){T(f,0,B);continue}if(b==="soft-hyphen"&&g(S)){S++;continue}if(X5(c)&&x0<=M+G){F(S,l),T(S+1,0,f0),S++;continue}if(f>=0&&I<=M+G){if(W>f||W===f&&R>0){T();continue}let m0=f;T(m0,0,B),S=m0;continue}if(l>M&&K[S]!==null){T(),v(S),S++;continue}T();continue}F(S,l),C(S,l),S++}if(H){let c=f===m.consumedEndSegmentIndex?B:N;T(m.consumedEndSegmentIndex,0,c)}}return _}var a8=null,a9=new WeakMap;function i9(){if(a8===null)a8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return a8}function JY($){if($)return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]};return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[]}}function ZY($,M,J){let Z=i9(),X=o1(),{cache:Y,emojiCorrection:Q}=r9(M,p9($.normalized)),K=X1("-",Z1("-",Y),Q),D=X1(" ",Z1(" ",Y),Q)*8;if($.len===0)return JY(J);let A=[],V=[],U=[],G=[],_=$.chunks.length<=1,N=J?[]:null,H=[],E=[],L=J?[]:null,W=Array.from({length:$.len}),R=Array.from({length:$.len});function f(b,z,T,P,y,F,C,v){if(y!=="text"&&y!=="space"&&y!=="zero-width-break")_=!1;if(A.push(z),V.push(T),U.push(P),G.push(y),N?.push(F),H.push(C),E.push(v),L!==null)L.push(b)}for(let b=0;b<$.len;b++){W[b]=A.length;let z=$.texts[b],T=$.isWordLike[b],P=$.kinds[b],y=$.starts[b];if(P==="soft-hyphen"){f(z,0,K,K,P,y,null,null),R[b]=A.length;continue}if(P==="hard-break"){f(z,0,0,0,P,y,null,null),R[b]=A.length;continue}if(P==="tab"){f(z,0,0,0,P,y,null,null),R[b]=A.length;continue}let F=Z1(z,Y);if(P==="text"&&F.containsCJK){let g="",O=0;for(let w of Z.segment(z)){let m=w.segment;if(g.length===0){g=m,O=w.index;continue}if(O2.has(g)||I8.has(m)||a1.has(m)||X.carryCJKAfterClosingQuote&&s0(m)&&d8(g)){g+=m;continue}let S=Z1(g,Y),c=X1(g,S,Q);f(g,c,c,c,"text",y+O,null,null),g=m,O=w.index}if(g.length>0){let w=Z1(g,Y),m=X1(g,w,Q);f(g,m,m,m,"text",y+O,null,null)}R[b]=A.length;continue}let C=X1(z,F,Q),v=P==="space"||P==="preserved-space"||P==="zero-width-break"?0:C,h=P==="space"||P==="zero-width-break"?0:C;if(T&&z.length>1){let g=l9(z,F,Y,Q),O=X.preferPrefixWidthsForBreakableRuns?d9(z,F,Y,Q):null;f(z,C,v,h,P,y,g,O)}else f(z,C,v,h,P,y,null,null);R[b]=A.length}let I=XY($.chunks,W,R),B=N===null?null:m9($.normalized,N);if(L!==null)return{widths:A,lineEndFitAdvances:V,lineEndPaintAdvances:U,kinds:G,simpleLineWalkFastPath:_,segLevels:B,breakableWidths:H,breakablePrefixWidths:E,discretionaryHyphenWidth:K,tabStopAdvance:D,chunks:I,segments:L};return{widths:A,lineEndFitAdvances:V,lineEndPaintAdvances:U,kinds:G,simpleLineWalkFastPath:_,segLevels:B,breakableWidths:H,breakablePrefixWidths:E,discretionaryHyphenWidth:K,tabStopAdvance:D,chunks:I}}function XY($,M,J){let Z=[];for(let X=0;X<$.length;X++){let Y=$[X],Q=Y.startSegmentIndex<M.length?M[Y.startSegmentIndex]:J[J.length-1]??0,K=Y.endSegmentIndex<M.length?M[Y.endSegmentIndex]:J[J.length-1]??0,q=Y.consumedEndSegmentIndex<M.length?M[Y.consumedEndSegmentIndex]:J[J.length-1]??0;Z.push({startSegmentIndex:Q,endSegmentIndex:K,consumedEndSegmentIndex:q})}return Z}function YY($,M,J,Z){let X=h9($,o1(),Z?.whiteSpace);return ZY(X,M,J)}function o9($,M,J){return YY($,M,!0,J)}function QY($){return $}function s9($,M,J){let Z=J.get($);if(Z!==void 0)return Z;Z=[];let X=i9();for(let Y of X.segment(M[$]))Z.push(Y.segment);return J.set($,Z),Z}function KY($){let M=a9.get($);if(M!==void 0)return M;return M=new Map,a9.set($,M),M}function DY($,M,J,Z){return Z>0&&$[Z-1]==="soft-hyphen"&&!(M===Z&&J>0)}function qY($,M,J,Z,X,Y,Q){let K="",q=DY(M,Z,X,Y);for(let D=Z;D<Y;D++){if(M[D]==="soft-hyphen"||M[D]==="hard-break")continue;if(D===Z&&X>0)K+=s9(D,$,J).slice(X).join("");else K+=$[D]}if(Q>0){if(q)K+="-";K+=s9(Y,$,J).slice(Z===Y?X:0,Q).join("")}else if(q)K+="-";return K}function AY($,M,J,Z,X,Y,Q){return{text:qY($.segments,$.kinds,M,Z,X,Y,Q),width:J,start:{segmentIndex:Z,graphemeIndex:X},end:{segmentIndex:Y,graphemeIndex:Q}}}function UY($,M,J){return AY($,M,J.width,J.startSegmentIndex,J.startGraphemeIndex,J.endSegmentIndex,J.endGraphemeIndex)}function n9($,M,J){let Z=[];if($.widths.length===0)return{lineCount:0,height:0,lines:Z};let X=KY($),Y=c9(QY($),M,(Q)=>{Z.push(UY($,X,Q))});return{lineCount:Y,height:Y*J,lines:Z}}var t9=[{fontSize:32,lineHeight:36},{fontSize:26,lineHeight:32},{fontSize:21,lineHeight:28},{fontSize:21,lineHeight:28},{fontSize:19,lineHeight:26},{fontSize:18,lineHeight:26}],Y5;function n1($){if($?.type==="heading"){let{fontSize:M}=M$($.depth);return`700 ${M}px "Iowan Old Style", "Palatino Linotype", serif`}switch($?.type){case"code":return"15px ui-monospace, SFMono-Regular, Menlo, monospace";default:return'16px "Iowan Old Style", "Palatino Linotype", serif'}}function P1($,M){if($?.type==="heading")return M$($.depth).lineHeight;if($?.type==="code")return 22;return M}function M$($){return t9[$-1]??t9.at(-1)}function t1($,M,J,Z,X,Y,Q){let K=`${K5(M,Q)}:${X}:${Y}:${J}`,q=$.measuredLines.get(K);if(q)return q;let D=GY($,M,J,Z,X,Y,Q);return O9($,K,D)}function Q5($,M,J,Z,X,Y,Q,K){let q=`${K5(M,K)}:${J}:${Z}:${Y}:${Q}`,D=$.lineBoundaries.get(q);if(D)return D;let A=Z$();if(!A)return $$(X);let V=[{left:0,offset:0}],U=0,G=M.inlines.filter((_)=>_.end>J&&_.start<Z);if(G.length===0)return $$(X);for(let _ of G){let N=Math.max(J,_.start),H=Math.min(Z,_.end),E=M.text.slice(N,H),L=N-J;if(_.kind==="image"){let W=M5(_,K,Q).width;U+=W,L+=E.length,V.push({left:U,offset:L});continue}A.font=J$(Y,_.marks);for(let W of Array.from(E))U+=X$($,A,W),L+=W.length,V.push({left:U,offset:L})}return j9($,q,V)}function VY($,M,J,Z){let X=`${J}::${Z}::${M}`,Y=$.preparedText.get(X);if(Y)return Y;let Q=o9(M,J,{whiteSpace:Z});return T9($,X,Q)}function GY($,M,J,Z,X,Y,Q){let K=M.text;if(K.length===0)return[{end:0,height:Y,start:0,text:"",width:0}];if(zY(M))return _Y($,M,J,X,Y,Q);try{let q=VY($,K,J,yY(Z));return n9(q,X,Y).lines.map((A)=>({end:e9(q.segments,A.end),height:Y,start:e9(q.segments,A.start),text:A.text,width:A.width}))}catch{return NY(K,X,Y)}}function e9($,M){let J=0;for(let Y=0;Y<M.segmentIndex;Y+=1)J+=$[Y]?.length??0;let Z=$[M.segmentIndex]??"",X=Array.from(Z);for(let Y=0;Y<M.graphemeIndex;Y+=1)J+=X[Y]?.length??0;return J}function $$($){let M=[{left:0,offset:0}],J=0,Z=0;for(let X of Array.from($))J+=9,Z+=X.length,M.push({left:J,offset:Z});return M}function NY($,M,J){let Z=Math.max(1,Math.floor(M/9)),X=bY($,Z),Y=0;return X.map((Q)=>{let K=Y,q=K+Q.length;return Y=q,{end:q,height:J,start:K,text:Q,width:Q.length*9}})}function _Y($,M,J,Z,X,Y){let Q=HY($,Z$(),M,J,Z,X,Y);if(Q.length===0)return[{end:0,height:X,start:0,text:"",width:0}];return FY(Q,M.text,Z,X)}function FY($,M,J,Z){let X=[],Y=0;while(Y<$.length){let Q=$[Y].start;if($[Y].text===`
|
|
14
|
+
`){X.push({end:Q,height:Z,start:Q,text:"",width:0}),Y+=1;continue}let K=0,q=0,D=Y,A=-1,V=Z;while(D<$.length){let G=$[D];if(G.text===`
|
|
15
|
+
`)break;let _=K+G.width;if(_>J&&D>Y)break;if(K=_,V=Math.max(V,G.height),G.breakable)A=D,q=K;D+=1}if(D===$.length||$[D]?.text===`
|
|
16
|
+
`){let G=$[D-1]?.end??Q;X.push({end:G,height:V,start:Q,text:M.slice(Q,G),width:K}),Y=D<$.length&&$[D]?.text===`
|
|
17
|
+
`?D+1:D;continue}if(A>=Y){let G=$[A].end;X.push({end:G,height:V,start:Q,text:M.slice(Q,G),width:q}),Y=A+1;continue}let U=$[Math.max(Y,D-1)].end;X.push({end:U,height:V,start:Q,text:M.slice(Q,U),width:K}),Y=Math.max(Y+1,D)}return X}function HY($,M,J,Z,X,Y,Q){let K=[];for(let q of J.inlines){if(q.kind==="image"){let A=M5(q,Q,X);K.push({breakable:!0,end:q.end,height:A.height,start:q.start,text:q.text,width:A.width});continue}if(M)M.font=J$(Z,q.marks);let D=q.start;for(let A of Array.from(q.text)){let V=D,U=V+A.length;K.push({breakable:/\s/.test(A),end:U,height:Y,start:V,text:A,width:A===`
|
|
18
|
+
`?0:X$($,M,A)}),D=U}}return K}function zY($){return $.inlines.some((M)=>M.kind==="image"||PY(M))}function K5($,M){return[$.path,BY($.text),EY($,M)].join(":")}function EY($,M){return $.inlines.map((J)=>`${J.start}-${J.end}:${WY(J,M)}`).join("|")}function WY($,M){if($.kind==="image"&&$.image)return w9($,M);return`${$.kind}:${$.inlineCode?1:0}:${$.marks.join(",")}:${$.link?.url??""}`}function BY($){let M=2166136261;for(let J of $)M^=J.charCodeAt(0),M=Math.imul(M,16777619);return(M>>>0).toString(36)}function PY($){return $.marks.includes("italic")||$.marks.includes("bold")}function J$($,M){let J=[];if(M.includes("italic"))J.push("italic");if(M.includes("bold"))J.push("700");return J.length>0?`${J.join(" ")} ${$}`:$}function Z$(){if(Y5!==void 0)return Y5;return Y5=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,Y5}function X$($,M,J){if(!M)return 9;let Z=M.font,X=C9($,Z),Y=X.get(J);if(Y!==void 0)return Y;let Q=M.measureText(J).width;return X.set(J,Q),Q}function yY($){return $?.type==="code"?"pre-wrap":"normal"}function bY($,M){if($.length===0)return[""];let J=$.split(`
|
|
19
|
+
`),Z=[];for(let X of J){if(X.length===0){Z.push("");continue}let Y=X;while(Y.length>M){let Q=Y.slice(0,M),K=Q.lastIndexOf(" ");if(K<=0){Z.push(Q),Y=Y.slice(M);continue}Z.push(Q.slice(0,K)),Y=Y.slice(K+1)}Z.push(Y)}return Z}var j2=10,e1=8,s8=120;function Y$($,M,J,Z,X,Y,Q,K,q,D){let A=Math.max(1,...Y.rows.map((N)=>N.cells.length)),U=Math.max(s8,q.width-Q-q.paddingX)/A,G=wY(Z),_=K;for(let N=0;N<Y.rows.length;N+=1){let H=TY(G.get(N)??[],X,Y,U,j2,q.lineHeight,D),E=Math.max(q.lineHeight+e1*2,...H.map((L)=>L.measuredLines.reduce((W,R)=>W+R.height,0)+e1*2));for(let L of H){let W=Q+L.cellIndex*U,R=_+e1;for(let f of L.measuredLines){let I={blockId:L.container.blockId,boundaries:Q5(X,L.container,f.start,f.end,f.text,L.font,U-j2*2,D),regionId:L.container.id,end:f.end,font:L.font,height:f.height,left:W+j2,start:f.start,text:f.text,top:R,width:f.width};$.push(I),i8(M,I),R+=f.height}J.set(L.container.id,{bottom:_+E,left:W,right:W+U,top:_})}jY(M,Y.id,_,_+E),_+=E}return _+q.blockGap}function wY($){let M=new Map;for(let J of $){let Z=OY(J.path);if(!Z)continue;let X=M.get(Z.rowIndex)??[];X.push({cellIndex:Z.cellIndex,container:J}),M.set(Z.rowIndex,X)}return M}function TY($,M,J,Z,X,Y,Q){return[...$].sort((K,q)=>K.cellIndex-q.cellIndex).map(({cellIndex:K,container:q})=>{let D=n1(J),A=P1(J,Y),V=t1(M,q,D,J,Math.max(40,Z-X*2),A,Q);return{cellIndex:K,container:q,font:D,lineHeight:A,measuredLines:V}})}function OY($){let M=/\.rows\.(\d+)\.cells\.(\d+)$/.exec($);if(!M)return null;return{cellIndex:Number(M[2]),rowIndex:Number(M[1])}}function jY($,M,J,Z){let X=$.get(M);$.set(M,{bottom:X?Math.max(X.bottom,Z):Z,top:X?Math.min(X.top,J):J})}var LY={blockGap:16,charWidth:9,indentWidth:24,lineHeight:24,paddingX:16,paddingY:12},CY=24,RY=16,fY=6,mY=10,SY=4;function D5($){let M=Math.max(12,Math.floor($.width/9)),J=Math.max(1,Math.ceil($.text.length/M));return{estimatedHeight:J*24,lineCount:J,width:$.width}}function q5($,M,J=B1(),Z=null){let X=Z??{images:new Map},Y={...LY,...M},Q=[],K=new Map,q=new Map($.regions.map((N)=>[N.id,{textLength:N.text.length}])),D=new Map($.blocks.map((N)=>[N.id,N.depth])),A=new Map($.blocks.map((N)=>[N.id,N])),V=C2($.document.blocks),U=new Map,G=Y.paddingY;for(let N=0;N<$.regions.length;N+=1){let H=$.regions[N],E=D.get(H.blockId)??0,L=Y.paddingX+E*Y.indentWidth,W=Math.max(40,Y.width-L-Y.paddingX),R=V.get(H.blockId)??null;if(R?.type==="table"){let B=A.get(H.blockId)?.regionIds??[],b=$.regions.slice(N,N+B.length);G=Y$(Q,U,K,b,J,R,L,G,Y,X),N+=b.length-1;continue}G=kY(Q,U,K,H,J,R,L,G,W,Y,X);let f=U5(A,V,$.regions,N,Y.blockGap);G+=f;let I=U.get(H.blockId);if(I)I.bottom=Math.max(I.bottom,G)}return{blocks:$.blocks.map((N)=>{let H=U.get(N.id),E=H?.top??Y.paddingY;return{bottom:H?.bottom??E+Y.lineHeight/2,depth:N.depth,id:N.id,top:E,type:N.type}}),regionBounds:vY(Q,K),regionLineIndices:uY(Q),regionMetrics:q,height:Math.max(G,Y.paddingY),lines:Q,options:Y,width:Y.width}}function kY($,M,J,Z,X,Y,Q,K,q,D,A){let V=n1(Y),U=P1(Y,D.lineHeight),G=t1(X,Z,V,Y,q,U,A),_=K;for(let N of G){let H={blockId:Z.blockId,boundaries:Q5(X,Z,N.start,N.end,N.text,V,q,A),regionId:Z.id,end:N.end,font:V,height:N.height,left:Q,start:N.start,text:N.text,top:_,width:N.width};$.push(H),i8(M,H),_+=N.height}return hY($,Z.id,J),_}function uY($){let M=[...$].sort((Z,X)=>Z.top-X.top||Z.left-X.left),J=new Map;$.length=0,$.push(...M);for(let[Z,X]of $.entries()){let Y=J.get(X.regionId)??[];Y.push(Z),J.set(X.regionId,Y)}return J}function vY($,M){let J=new Map(M);for(let Z of $){let X=J.get(Z.regionId),Y={bottom:Z.top+Z.height,left:Z.left,right:Z.left+Z.width,top:Z.top};J.set(Z.regionId,X?{bottom:Math.max(X.bottom,Y.bottom),left:Math.min(X.left,Y.left),right:Math.max(X.right,Y.right),top:Math.min(X.top,Y.top)}:Y)}return J}function hY($,M,J){let Z=$.filter((X)=>X.regionId===M);if(Z.length===0)return;J.set(M,{bottom:Math.max(...Z.map((X)=>X.top+X.height)),left:Math.min(...Z.map((X)=>X.left)),right:Math.max(...Z.map((X)=>X.left+X.width)),top:Math.min(...Z.map((X)=>X.top))})}function i8($,M){let J=$.get(M.blockId),Z=M.top+M.height;$.set(M.blockId,{bottom:J?Math.max(J.bottom,Z):Z,top:J?Math.min(J.top,M.top):M.top})}function A$($,M){let J=0,Z=$.lines.length-1;while(J<=Z){let X=J+Z>>1,Y=$.lines[X];if(M<Y.top){Z=X-1;continue}if(M>=Y.top+Y.height){J=X+1;continue}return{index:X,line:Y}}return null}function o8($,M){let J=[...$.regionBounds.entries()].find(([,Y])=>{return M.x>=Y.left&&M.x<=Y.right&&M.y>=Y.top&&M.y<=Y.bottom});if(J)return A5($,J[0],M.y);let Z=A$($,M.y);if(!Z)return null;let X=gY($,M.y,Z.index);if(X.length===1)return X[0]??null;return X.find((Y)=>{let Q=$.regionBounds.get(Y.line.regionId);return Q?M.x>=Q.left&&M.x<=Q.right:!1})??[...X].sort((Y,Q)=>{let K=$.regionBounds.get(Y.line.regionId),q=$.regionBounds.get(Q.line.regionId),D=Q$(M.x,K),A=Q$(M.x,q);return D-A})[0]??null}function n8($,M,J){if($.lines.length===0)return{endIndex:0,startIndex:0};let Z=M+J,X=K$($,M),Y=K$($,Z);if(X>0){let Q=$.lines[X-1];if(Q.top+Q.height>M)X-=1}if(Y<$.lines.length){if($.lines[Y].top<Z)Y+=1}return{endIndex:Y,startIndex:X}}function g0($,M,J){if(!$.regionMetrics.get(J.regionId))return null;let X=j0($,J.regionId,J.offset);if(!X)return null;return{blockId:X.blockId,regionId:X.regionId,height:X.height,left:W0(X,J.offset-X.start),offset:J.offset,top:X.top}}function j0($,M,J){return L2($,M,J)?.line??null}function A5($,M,J){let Z=$.regionLineIndices.get(M);if(!Z||Z.length===0)return null;let X=Z[0],Y=Number.POSITIVE_INFINITY;for(let Q of Z){let K=$.lines[Q],q=J<K.top?K.top-J:J>K.top+K.height?J-(K.top+K.height):0;if(q<Y)Y=q,X=Q;if(q===0)break}return{index:X,line:$.lines[X]}}function L2($,M,J){let Z=$.regionLineIndices.get(M);if(!Z||Z.length===0)return null;let X=0,Y=Z.length-1;while(X<=Y){let A=X+Y>>1,V=Z[A],U=$.lines[V];if(J<U.start){Y=A-1;continue}if(J>U.end){X=A+1;continue}return{index:V,line:U}}let Q=Z[0],K=Z[Z.length-1],q=$.lines[Q],D=$.lines[K];if(J<=q.start)return{index:Q,line:q};if(J>=D.end)return{index:K,line:D};return null}function gY($,M,J){let Z=[];for(let X=J;X>=0;X-=1){let Y=$.lines[X];if(M<Y.top||M>=Y.top+Y.height)break;Z.unshift({index:X,line:Y})}for(let X=J+1;X<$.lines.length;X+=1){let Y=$.lines[X];if(M<Y.top||M>=Y.top+Y.height)break;Z.push({index:X,line:Y})}return Z}function Q$($,M){if(!M)return Number.POSITIVE_INFINITY;if($<M.left)return M.left-$;if($>M.right)return $-M.right;return 0}function W0($,M){return $.left+IY($.boundaries,M)}function C2($){let M=new Map,J=(Z)=>{for(let X of Z)if(M.set(X.id,X),X.type==="blockquote"||X.type==="listItem")J(X.children);else if(X.type==="list")J(X.items)};return J($),M}function IY($,M){for(let Z of $)if(Z.offset===M)return Z.left;return $.filter((Z)=>Z.offset<=M).at(-1)?.left??0}function K$($,M){let J=0,Z=$.lines.length;while(J<Z){let X=J+Z>>1,Y=$.lines[X];if(Y.top+Y.height<=M)J=X+1;else Z=X}return J}function U$($,M){if($.length===0)return 0;for(let J=1;J<$.length;J+=1){let Z=$[J-1],X=$[J],Y=Z.left+(X.left-Z.left)/2;if(M<=Y)return Z.offset;if(M<=X.left)return X.offset}return $.at(-1)?.offset??0}function U5($,M,J,Z,X){let Y=J[Z],Q=J[Z+1];if(!Y||!Q)return X;if(D$($,Y.blockId,Q.blockId,"list"))return fY;if(D$($,Y.blockId,Q.blockId,"blockquote"))return mY;if(Y.blockId===Q.blockId)return SY;return X+pY(M.get(Y.blockId))}function pY($){if($?.type!=="heading")return 0;if($.depth===1)return CY;return $.depth===2?RY:0}function D$($,M,J,Z){let X=q$($,M,Z),Y=q$($,J,Z);for(let Q of X)if(Y.has(Q))return!0;return!1}function q$($,M,J){let Z=new Set,X=$.get(M)??null;while(X){if(X.type===J)Z.add(X.id);X=X.parentBlockId?$.get(X.parentBlockId)??null:null}return Z}function t8($,M,J,Z=[],X=B1(),Y=null){let Q=Y??{images:new Map},K=C2($.document.blocks),q=new Map($.blocks.map((W)=>[W.id,W])),D=new Set(Z),A=Math.max(0,J.top-J.overscan),V=J.top+J.height+J.overscan,U=cY(X,$,K,q,M,Q),G=V$(U,A),_=V$(U,V);if(G>0){let W=U.entries[G-1];if(W&&W.bottom>A)G-=1}if(_<U.entries.length){let W=U.entries[_];if(W&&W.top<V)_+=1}for(let W of D){let R=U.containerIndices.get(W);if(R===void 0)continue;G=Math.min(G,R),_=Math.max(_,R+1)}if(!Number.isFinite(G)||!Number.isFinite(_))return{estimateRegionBounds:U.estimateRegionBounds,layout:q5({...$,regions:[]},M,X,Q),totalHeight:U.totalHeight,viewport:J};let N=rY($,q,U.containerIndices,G,_),H=U.entries[N.startIndex]?.top??M.paddingY??0,E=q5({...$,regions:$.regions.slice(N.startIndex,N.endIndex)},M,X,Q),L=dY(E,H,U.totalHeight);return lY(X,$,L,M,Q),{estimateRegionBounds:U.estimateRegionBounds,layout:L,totalHeight:U.totalHeight,viewport:J}}function lY($,M,J,Z,X){for(let[Y,Q]of J.regionBounds){let K=Q.bottom-Q.top,q=M.regionIndex.get(Y);L9($,G$(q??{path:Y,inlines:[],text:""},Z,X),K)}}function dY($,M,J){return{...$,blocks:$.blocks.map((Z)=>({...Z,bottom:Z.bottom+M,top:Z.top+M})),regionBounds:new Map([...$.regionBounds.entries()].map(([Z,X])=>[Z,{bottom:X.bottom+M,left:X.left,right:X.right,top:X.top+M}])),height:J,lines:$.lines.map((Z)=>({...Z,top:Z.top+M}))}}function rY($,M,J,Z,X){let Y=Z,Q=X;for(let K=Z;K<X;K+=1){let q=$.regions[K],D=M.get(q.blockId);if(!D)continue;if(D.type==="table"){let A=J.get(D.regionIds[0]??""),V=J.get(D.regionIds[D.regionIds.length-1]??"");if(A!==void 0)Y=Math.min(Y,A);if(V!==void 0)Q=Math.max(Q,V+1)}}return{endIndex:Q,startIndex:Y}}function xY($,M,J,Z,X,Y){let Q=G$(M,X,Y),K=$.measuredContainerHeights.get(Q);if(K!==void 0)return K;let q=X.paddingX??0,D=X.indentWidth??24,A=P1(J,X.lineHeight??24),V=q+Z*D,U=Math.max(40,X.width-V-q);if(M.inlines.some((N)=>N.kind==="image")){let N=n1(J);return t1($,M,N,J,U,A,Y).reduce((H,E)=>H+E.height,0)}let G=D5({text:M.text,width:U});return Math.max(A,G.lineCount*A)}function cY($,M,J,Z,X,Y){let Q=oY(M,X,Y),K=R9($,M,Q);if(K)return K;let q=X.paddingY??0,D=[],A=new Map;for(let V=0;V<M.regions.length;V+=1){let U=M.regions[V],G=J.get(U.blockId)??null;if(G?.type==="table"){let E=aY({block:G,blockMap:J,containerIndices:A,entries:D,index:V,options:X,runtimeBlocks:Z,totalHeight:q,regions:M.regions});if(E){V=E.nextIndex-1,q=E.totalHeight;continue}}let _=xY($,U,G,Z.get(U.blockId)?.depth??0,X,Y),N=q,H=N+_;D.push({bottom:H,top:N}),A.set(U.id,V),q=H+U5(Z,J,M.regions,V,X.blockGap??16)}return f9($,M,Q,{containerIndices:A,entries:D,estimateRegionBounds(V){let U=A.get(V);return U===void 0?null:D[U]??null},totalHeight:q})}function aY({block:$,blockMap:M,containerIndices:J,entries:Z,index:X,options:Y,runtimeBlocks:Q,totalHeight:K,regions:q}){let D=Q.get($.id),A=D?.regionIds??[];if(A.length===0)return null;let V=q.slice(X,X+A.length);if(V.length===0||V[0]?.blockId!==$.id)return null;let U=Y.paddingX??0,G=Y.indentWidth??24,_=D?.depth??0,N=U+_*G,H=Math.max(s8,Y.width-N-U),E=Math.max(1,...$.rows.map((B)=>B.cells.length)),L=H/E,W=Math.max(40,L-j2*2),R=P1($,Y.lineHeight??24),f=sY(V,X),I=K;for(let B=0;B<$.rows.length;B+=1){let b=f.get(B)??[],z=Math.max(R+e1*2,...b.map(({region:P})=>iY(P,W,R)+e1*2)),T=I+z;for(let{index:P,region:y}of b)Z[P]={bottom:T,top:I},J.set(y.id,P);I=T}for(let B=X;B<X+V.length;B+=1){let b=q[B];if(!b||Z[B])continue;Z[B]={bottom:I,top:I},J.set(b.id,B)}return{nextIndex:X+V.length,totalHeight:I+U5(Q,M,q,X+V.length-1,Y.blockGap??16)}}function sY($,M){let J=new Map;for(let[Z,X]of $.entries()){let Y=X.tableCellPosition?.rowIndex;if(Y===void 0)continue;let Q=J.get(Y)??[];Q.push({index:M+Z,region:X}),J.set(Y,Q)}return J}function iY($,M,J){let Z=D5({text:$.text,width:M});return Math.max(J,Z.lineCount*J)}function oY($,M,J){return[M.width,M.paddingX??0,M.paddingY??0,M.indentWidth??24,M.lineHeight??24,M.blockGap??16,nY($,J)].join(":")}function V$($,M){let J=0,Z=$.entries.length;while(J<Z){let X=J+Z>>1;if($.entries[X].bottom<=M)J=X+1;else Z=X}return J}function G$($,M,J){return`${K5($,J)}:${M.width}:${M.paddingX??0}:${M.indentWidth??24}:${M.lineHeight??24}`}function nY($,M){return $.regions.flatMap((J)=>J.inlines.filter((Z)=>Z.kind==="image"&&Z.image).map((Z)=>{let X=Z.image?M.images.get(Z.image.url):null;return`${Z.image?.url??""}:${Z.image?.width??0}:${X?.status??"loading"}:${X?.intrinsicWidth??0}:${X?.intrinsicHeight??0}`})).join("|")}var V5=null;function tY($){let M=/(\d+(?:\.\d+)?)\s*px/.exec($);return M?Number.parseFloat(M[1]):16}function Y1($){V5??=new Map;let M=V5.get($);if(M)return M;let J=F$(),Z=Math.max(12,Math.round(tY($)));if(!J){let U={ascent:Math.round(Z*0.8),descent:Math.max(2,Z-Math.round(Z*0.8)),emHeight:Z};return V5.set($,U),U}J.font=$;let X=J.measureText("Hg"),Y=Math.round(X.actualBoundingBoxAscent||0),Q=Math.round(X.actualBoundingBoxDescent||0),K=Y+Q,q=Math.max(Z,K),D=K>0?Y:Math.round(q*0.8),A=K>0?Q:Math.max(2,q-D),V={ascent:D,descent:A,emHeight:q};return V5.set($,V),V}function eY($,M){let{emHeight:J}=Y1(M);return Math.max(0,Math.floor(($-J)/2))}function N$($,M){let{ascent:J}=Y1(M);return eY($,M)+J}var G5;function _$($,M){let J=F$();if(!J||$.length===0)return 0;return J.font=M,J.measureText($).width}function F$(){if(G5!==void 0)return G5;return G5=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,G5}var $Q=18,MQ=14,JQ=22;function y0($,M,J){let Z=XQ($,J);if(!Z)return null;return H$($,M,Z,J.x)}function e8($,M,J){let Z=$.lines[$.lines.length-1];if(!Z||J.y<=Z.top+Z.height)return null;return H$($,M,Z,J.x)}function H$($,M,J,Z){let X=$.regionMetrics.get(J.regionId);if(!X)return null;let Y=Math.max(0,Z-h0(M,J)-J.left),Q=U$(J.boundaries,Y),K=Math.min(X.textLength,J.start+Q);return{regionId:J.regionId,offset:K,left:W0(J,Q),top:J.top,height:J.height}}function $6($,M,J,Z){let X=Y6(M,Z.regionId);if(!X)return null;let Y=y0($,M,J);if(Y)return{regionId:Y.regionId,offset:Y.offset};let Q=J.y<QQ($);return{regionId:Z.regionId,offset:Q?0:X.text.length}}function M6($,M,J){let Z=y0($,M,J);if(!Z)return null;let X=Y6(M,Z.regionId);if(!X||X.text.length===0)return null;let Y=Z.offset<X.text.length&&/\w/.test(X.text[Z.offset]??"")?Z.offset:Z.offset>0&&/\w/.test(X.text[Z.offset-1]??"")?Z.offset-1:Z.offset,Q=KQ(X.text,Y);if(Q.start===Q.end)return null;return{anchor:{regionId:Z.regionId,offset:Q.start},focus:{regionId:Z.regionId,offset:Q.end}}}function z$($,M,J){let Z=YQ($,J);if(!Z||Z.start!==0)return null;let X=$2(M,Z.blockId,"listItem");if(!X)return null;if(f2(M,X.id)?.kind!=="task")return null;let Q=R2(Z),K=Q.left-4,q=Q.left+Q.size+4,D=Q.top-4,A=Q.top+Q.size+4;return J.x>=K&&J.x<=q&&J.y>=D&&J.y<=A?{listItemId:X.id}:null}function E$($,M,J){let Z=y0($,M,J);if(!Z)return null;let X=Y6(M,Z.regionId);if(!X)return null;let Y=X.inlines.find((K)=>K.link&&Z.offset>=K.start&&Z.offset<K.end);if(!Y?.link)return null;let Q=X6($,M,Z.regionId,Y.start);if(!Q)return null;return{anchorBottom:Q.anchorBottom,anchorLeft:Q.anchorLeft,endOffset:Y.end,regionId:Z.regionId,startOffset:Y.start,title:Y.link.title,url:Y.link.url}}function J6($,M,J,Z){let X=z$($,M,J);if(X)return{kind:"task-toggle",listItemId:X.listItemId};let Y=y0($,M,J);if(!Y)return null;let Q=W$(Y.regionId,Y.offset,Z),K=Q!==null?B$(Q,$,M,Z):null,q=E$($,M,J);if(q)return{anchorBottom:K?.anchorBottom??q.anchorBottom,anchorLeft:K?.anchorLeft??q.anchorLeft,endOffset:q.endOffset,kind:"link",commentThreadIndex:Q,regionId:q.regionId,startOffset:q.startOffset,title:q.title,url:q.url};return{anchorBottom:K?.anchorBottom??Y.top+Y.height,anchorLeft:K?.anchorLeft??Y.left,kind:"text",commentThreadIndex:Q}}function Z6($,M,J,Z){let X=M.documentIndex.regionIndex.get(J.regionId);if(!X)return null;let Y=W$(J.regionId,J.offset,Z),Q=Y!==null?B$(Y,$,M,Z):null,K=X.inlines.find((q)=>J.offset>=q.start&&J.offset<=q.end)??null;if(K?.link){let q=X6($,M,J.regionId,K.start);if(!q)return null;return{anchorBottom:Q?.anchorBottom??q.anchorBottom,anchorLeft:Q?.anchorLeft??q.anchorLeft,commentThreadIndex:Y,endOffset:K.end,kind:"link",regionId:J.regionId,startOffset:K.start,title:K.link.title,url:K.link.url}}if(Q)return{anchorBottom:Q.anchorBottom,anchorLeft:Q.anchorLeft,commentThreadIndex:Y,kind:"text"};return null}function I0($,M,J){let Z=j0(M,J.regionId,J.offset);if(!Z)return J.left;return J.left+h0($,Z)+ZQ($,Z,J.offset)}function Q1($,M,J){return W0(M,J)+h0($,M)}function h0($,M){let J=$2($,M.blockId,"listItem");if(!J)return 0;return f2($,J.id)?.kind==="task"?JQ:$Q}function R2($){return{left:$.left,size:MQ,top:$.top+3}}function $2($,M,J){let Z=$.documentIndex.blockIndex.get(M)??null;while(Z){if(Z.type===J)return Z;let X=Z.parentBlockId;Z=X?$.documentIndex.blockIndex.get(X)??null:null}return null}function f2($,M){return $.documentIndex.listItemMarkers.get(M)??null}function W$($,M,J){for(let Z of J)if(Z.regionId===$&&M>=Z.startOffset&&M<=Z.endOffset)return Z.threadIndex;return null}function B$($,M,J,Z){let X=Z.find((Y)=>Y.threadIndex===$);if(!X)return null;return X6(M,J,X.regionId,X.startOffset)}function X6($,M,J,Z){let X=j0($,J,Z);if(!X)return null;return{anchorBottom:X.top+X.height,anchorLeft:W0(X,Z)+h0(M,X)}}function ZQ($,M,J){if(J<=M.end)return 0;let Z=$.documentIndex.regionIndex.get(M.regionId);if(!Z)return 0;let X=Z.text.slice(M.end,J);if(!/^[ \t]+$/u.test(X))return 0;return _$(X,M.font)}function XQ($,M){for(let[Z,X]of $.regionBounds)if(M.x>=X.left&&M.x<=X.right&&M.y>=X.top&&M.y<=X.bottom)return A5($,Z,M.y)?.line??null;let J=o8($,M)?.line??null;if(J)return J;for(let Z of $.blocks)if(M.y>=Z.top&&M.y<=Z.bottom){for(let X=$.lines.length-1;X>=0;X--)if($.lines[X].blockId===Z.id)return $.lines[X]}return null}function YQ($,M){return $.lines.find((J)=>M.y>=J.top-4&&M.y<=J.top+J.height+4)??$.lines.filter((J)=>Math.abs(M.y-(J.top+J.height/2))<=10).sort((J,Z)=>Math.abs(M.y-(J.top+J.height/2))-Math.abs(M.y-(Z.top+Z.height/2)))[0]??null}function Y6($,M){return $.documentIndex.regionIndex.get(M)??null}function QQ($){return $.lines[0]?.top??0}function KQ($,M){let J=M,Z=M;while(J>0&&/\w/.test($[J-1]??""))J-=1;while(Z<$.length&&/\w/.test($[Z]??""))Z+=1;return{end:Z,start:J}}function Q6($,M,J,Z=null){let X={height:M.height,overscan:Math.max(160,M.height),top:M.top},Y=t8($.documentIndex,M,X,[$.selection.anchor.regionId,$.selection.focus.regionId],J,Z);return{blockMap:C2($.documentIndex.document.blocks),estimateRegionBounds:Y.estimateRegionBounds,regionBounds:new Map(Y.layout.regionBounds),layout:Y.layout,paintHeight:Math.max(240,X.height+X.overscan*2),paintTop:Math.max(0,X.top-X.overscan),totalHeight:Y.totalHeight,viewport:{height:X.height,top:X.top}}}function N5($,M,J){return y0(M.layout,$,J)??e8(M.layout,$,J)}function m2($,M,J,Z){return $6(M.layout,$,J,Z)}function K6($,M,J){return M6(M.layout,$,J)}function D6($,M,J,Z){return J6(M.layout,$,J,Z)}function q6($,M,J,Z){return Z6(M.layout,$,J,Z)}function A6($,M,J){return g0(M.layout,$.documentIndex,J)}function o0($,M,J){let Z=g0(M.layout,$.documentIndex,J);if(!Z)return null;return{...Z,left:I0($,M.layout,Z)}}function P$($,M,J,Z,X){let Y=Z-J,Q=X-Y;if(Z<=$)return{end:M+Q,start:$+Q};if(J>=M)return{end:M,start:$};let K=Math.max(0,Math.min(J,M)-$),q=Math.max(0,M-Math.max(Z,$)),D=$<J?$:J;return{end:D+K+X+q,start:D}}function V6($,M,J){let Z=J.trim();if(Z.length===0||M.startOffset===M.endOffset)return null;let X=$.regionIndex.get(M.regionId)??null,Y=X?U6($,X):null;if(!Y)return null;return L8({anchor:y2(Y,M.startOffset,M.endOffset),body:Z,quote:b2(Y,M.startOffset,M.endOffset)})}function L0($){let M="documentIndex"in $?$.documentIndex:$,J=_5(M),Z=M.document.comments,X=[...Z],Y=[];for(let[Q,K]of Z.entries()){let q=w2(K,M.document);if(!q.match)continue;let A=J.findBySemanticMatch(q.match.containerId,q.match.containerOrdinal)?.runtimeContainer??null;if(!A)continue;if(q.repair)X[Q]={...K,anchor:q.repair.anchor,quote:q.repair.quote};Y.push({endOffset:q.match.endOffset,resolution:q,regionId:A.id,resolved:K.resolvedAt!=null,startOffset:q.match.startOffset,threadIndex:Q})}return{liveRanges:Y,threads:X}}function G6($,M,J,Z,X,Y){if($.document.comments.length===0)return M.document.comments;let Q=$.commentContainerIndex.get(J.semanticRegionId)??[],K=new Set(Q);if(Q.length===0)return M.document.comments;let q=L0($),D=new Map(q.liveRanges.map((G)=>[G.threadIndex,G])),A=U6($,J),V=M2(M,J.path),U=V?U6(M,V):null;if(!A||!U)return M.document.comments;return M.document.comments.map((G,_)=>{if(!K.has(_))return G;let N=D.get(_),H=N?.resolution.match??null;if(!N||!H||H.containerId!==A.id)return G;let E=P$(H.startOffset,H.endOffset,Z,X,Y.length);return{...G,anchor:y2(U,E.start,E.end),quote:b2(U,E.start,E.end)}})}function U6($,M){let J=DQ($,M);if(!J)return null;return{containerKind:J,containerOrdinal:-1,id:M.semanticRegionId,text:M.text}}function DQ($,M){if($.tableCellIndex.has(M.id))return"tableCell";return E9(M.blockType)}function F5($,M){if(M.length===0)return[];let J=_5($),Z=J.list();return M.map((X)=>({...X,cursorPoint:qQ(X,Z,J),viewport:null}))}function qQ($,M,J){if(!$.cursor)return null;let Z=AQ(M,$.cursor),X=UQ(Z,$.cursor);if(X.length!==1)return null;let Y=X[0],Q=J.resolveRuntimeContainer(Y.container.id);if(!Q)return null;return{offset:Math.max(0,Math.min(Y.offset,Q.text.length)),regionId:Q.id}}function AQ($,M){return M.kind?$.filter((J)=>J.containerKind===M.kind):$}function UQ($,M){if(M.prefix&&M.suffix)return VQ($,M.prefix,M.suffix);if(M.prefix)return y$($,M.prefix,"after");if(M.suffix)return y$($,M.suffix,"before");return[]}function y$($,M,J){let Z=[];for(let X of $)for(let Y of v0(X.text,M))Z.push({container:X,offset:J==="after"?Y+M.length:Y});return Z}function VQ($,M,J){let Z=[];for(let X of $)for(let Y of c1(X.text,M,J))Z.push({container:X,offset:Y.startOffset});return Z}var GQ=48;function S2($,M,J){let Z="documentIndex"in $?$.documentIndex:$;if(J.length===0)return[];return J.map((X)=>({...X,viewport:NQ(Z,M,X)}))}function NQ($,M,J){if(!J.cursorPoint)return{status:"unresolved"};let Z=g0(M.layout,$,J.cursorPoint),X=Z?{bottom:Z.top+Z.height,top:Z.top}:M.estimateRegionBounds(J.cursorPoint.regionId);if(!X)return{status:"unresolved"};return{scrollTop:FQ(M,X),status:_Q(M,X)}}function _Q($,M){let J=$.viewport.top,Z=J+$.viewport.height;if(M.bottom<J)return"above";if(M.top>Z)return"below";return"visible"}function FQ($,M){let J=Math.max(0,$.totalHeight-$.viewport.height),Z=M.top-Math.min(GQ,$.viewport.height/4);return Math.max(0,Math.min(J,Z))}function _5($){let M=$5($.document),J=new Map(M.map((X)=>[X.id,X])),Z=new Map($.regions.map((X)=>[X.semanticRegionId,X]));return{findBySemanticMatch(X,Y){let Q=J.get(X)??M[Y]??null;if(!Q)return null;return{runtimeContainer:Z.get(Q.id)??null,semanticContainer:Q}},list(X){return X?M.filter((Y)=>Y.containerKind===X):M},resolveRuntimeContainer(X){return Z.get(X)??null}}}var k2="",b$=1e6;function u2($,M,J){return`${$}:${M}:${J}`}function J2($){let M=uQ($),J=_6(M.blocks.map((Z,X)=>h2(Z,X)));return F6(M,J)}function h2($,M){let J=[],Z=[],X=[],Y=new Set,Q=0;function K(D,A,V,U,G=null){if(Z.length>0)X.push(`
|
|
20
|
+
`),Q+=1;let _=V.map((E)=>E.text).join(""),N=Q,H=N+_.length;X.push(_),Q=H;for(let E of V)if(E.image)Y.add(E.image.url);Z.push({blockId:D.id,blockType:D.type,end:H,id:`${D.id}:${A}`,path:A,rootIndex:M,inlines:V,semanticRegionId:U,start:N,tableCellPosition:G,text:_})}function q(D,A,V,U){let G={childBlockIds:[],depth:V,end:Q,id:D.id,parentBlockId:U,path:A,regionIds:[],rootIndex:M,start:Q,type:D.type};switch(J.push(G),D.type){case"blockquote":case"listItem":for(let[_,N]of D.children.entries())G.childBlockIds.push(N.id),q(N,`${A}.children.${_}`,V+1,D.id);break;case"code":{K(D,`${A}.source`,[{end:D.source.length,id:`${D.id}:code`,image:null,inlineCode:!1,kind:"text",link:null,marks:[],originalType:null,start:0,text:D.source}],D.id),G.regionIds.push(Z.at(-1).id);break}case"heading":case"paragraph":K(D,`${A}.children`,N6(D.children),D.id),G.regionIds.push(Z.at(-1).id);break;case"list":for(let[_,N]of D.items.entries())G.childBlockIds.push(N.id),q(N,`${A}.children.${_}`,V+1,D.id);break;case"table":for(let[_,N]of D.rows.entries())for(let[H,E]of N.cells.entries())K(D,`${A}.rows.${_}.cells.${H}`,N6(E.children),E.id,{cellIndex:H,rowIndex:_}),G.regionIds.push(Z.at(-1).id);break;case"thematicBreak":break;case"directive":break;case"unsupported":K(D,`${A}.source`,[{end:D.source.length,id:`${D.id}:unsupported`,image:null,inlineCode:!1,kind:"unsupported",link:null,marks:[],originalType:D.originalType,start:0,text:D.source}],D.id),G.regionIds.push(Z.at(-1).id);break}G.end=Q}return q($,`root.${M}`,0,null),{blockRange:{end:J.length,start:0},blocks:J,end:Q,imageUrls:Y,length:Q,regionRange:Z.length>0?{end:Z.length,start:0}:void 0,regions:Z,rootIndex:M,start:0,text:X.join("")}}function _6($,M=null){let J=[],Z=0,X=0,Y=0,Q=!1;for(let[K,q]of $.entries()){if(q.regions.length>0&&Q)Y+=1;let D={...q,blockRange:{end:Z+q.blocks.length,start:Z},end:Y+q.length,regionRange:q.regions.length>0?{end:X+q.regions.length,start:X}:void 0,start:Y},A=M?.[K];if(J.push(zQ(A,q,D)?A:w$(q,D)),Z=D.blockRange.end,X=D.regionRange?.end??X,q.regions.length>0)Y=D.end,Q=!0}return J}function Z2($,M,J,Z){let X=M.blocks.length-($.roots.length-Z);if(X<0)throw Error("Editor model splice received an invalid replacement count.");if(J===$.roots.length&&X===1){let q=M.blocks[J];if(q)return HQ($,M,q)}let Y=X===Z,Q=[...$.roots.slice(0,J),...M.blocks.slice(J,J+X).map((q,D)=>h2(q,J+D)),...Y?$.roots.slice(J+Z):M.blocks.slice(J+X).map((q,D)=>h2(q,J+X+D))],K=_6(Q,$.roots);return F6(M,K,$)}function HQ($,M,J){let Z=$.roots.length,X=h2(J,Z),Y=$.roots.some((A)=>A.regions.length>0),Q=X.regions.length>0&&Y?$.length+1:$.length,K=w$(X,{...X,blockRange:{end:$.blocks.length+X.blocks.length,start:$.blocks.length},end:Q+X.length,regionRange:X.regions.length>0?{end:$.regions.length+X.regions.length,start:$.regions.length}:void 0,start:Q}),q=[...$.blocks,...K.blocks],D=[...$.regions,...K.regions];return{blockIndex:yQ($.blockIndex,K.blocks),blocks:q,commentContainerIndex:M.comments===$.document.comments?$.commentContainerIndex:T$(M),document:M,engine:"canvas",imageUrls:mQ($.imageUrls,K.imageUrls),length:K.end,listItemMarkers:M.blocks===$.document.blocks?$.listItemMarkers:LQ($.listItemMarkers,J),regionIndex:bQ($.regionIndex,K.regions),regionOrderIndex:wQ($.regionOrderIndex,K.regions,$.regions.length),regionPathIndex:TQ($.regionPathIndex,K.regions),regions:D,roots:[...$.roots,K],tableCellIndex:OQ($.tableCellIndex,K.regions),tableCellRegionIndex:jQ($.tableCellRegionIndex,K.regions),text:CQ($.text,K)}}function H5($,M){if(M.blocks!==$.document.blocks)throw Error("Editor model document replacement requires preserving root blocks.");return F6(M,$.roots,$)}function z5($,M,J){let Z=$.blockIndex.get(M);if(!Z)return null;return G9($.document,M,J,Z.rootIndex)}function F6($,M,J=null){let Z=M.flatMap((A)=>A.blocks),X=M.flatMap((A)=>A.regions),{regionIndex:Y,regionOrderIndex:Q,regionPathIndex:K,tableCellIndex:q,tableCellRegionIndex:D}=PQ(X);return{blockIndex:BQ(Z),blocks:Z,commentContainerIndex:$.comments===J?.document.comments?J.commentContainerIndex:T$($),document:$,engine:"canvas",imageUrls:fQ(M,J?.imageUrls),length:M.at(-1)?.end??0,listItemMarkers:$.blocks===J?.document.blocks?J.listItemMarkers:kQ($.blocks),regionIndex:Y,regionOrderIndex:Q,regionPathIndex:K,regions:X,roots:M,tableCellIndex:q,tableCellRegionIndex:D,text:RQ(M)}}function w$($,M){let J=M.start-$.start;return{...M,blocks:J===0?$.blocks:EQ($.blocks,J),regions:J===0?$.regions:WQ($.regions,J)}}function zQ($,M,J){return Boolean($&&M===$&&$.start===J.start&&$.end===J.end&&$.blockRange.start===J.blockRange.start&&$.blockRange.end===J.blockRange.end&&$.regionRange?.start===J.regionRange?.start&&$.regionRange?.end===J.regionRange?.end)}function EQ($,M){return $.map((J)=>({...J,end:J.end+M,start:J.start+M}))}function WQ($,M){return $.map((J)=>({...J,end:J.end+M,start:J.start+M}))}function BQ($){let M=new Map;for(let J of $)M.set(J.id,J);return M}function PQ($){let M=new Map,J=new Map,Z=new Map,X=new Map,Y=new Map;for(let[Q,K]of $.entries()){if(M.set(K.id,K),J.set(K.id,Q),Z.set(K.path,K),!K.tableCellPosition)continue;X.set(K.id,K.tableCellPosition),Y.set(u2(K.blockId,K.tableCellPosition.rowIndex,K.tableCellPosition.cellIndex),K.id)}return{regionIndex:M,regionOrderIndex:J,regionPathIndex:Z,tableCellIndex:X,tableCellRegionIndex:Y}}function yQ($,M){let J=new Map($);for(let Z of M)J.set(Z.id,Z);return J}function bQ($,M){let J=new Map($);for(let Z of M)J.set(Z.id,Z);return J}function wQ($,M,J){let Z=new Map($);for(let[X,Y]of M.entries())Z.set(Y.id,J+X);return Z}function TQ($,M){let J=new Map($);for(let Z of M)J.set(Z.path,Z);return J}function OQ($,M){let J=new Map($);for(let Z of M)if(Z.tableCellPosition)J.set(Z.id,Z.tableCellPosition);return J}function jQ($,M){let J=new Map($);for(let Z of M){if(!Z.tableCellPosition)continue;J.set(u2(Z.blockId,Z.tableCellPosition.rowIndex,Z.tableCellPosition.cellIndex),Z.id)}return J}function LQ($,M){let J=new Map($);return v2(J,[M]),J}function CQ($,M){if(M.regions.length===0)return $;return $.length>0?`${$}
|
|
21
|
+
${M.text}`:M.text}function RQ($){return $.filter((M)=>M.regions.length>0).map((M)=>M.text).join(`
|
|
22
|
+
`)}function fQ($,M){let J=new Set;for(let Z of $)for(let X of Z.imageUrls)J.add(X);return M&&SQ(M,J)?M:J}function mQ($,M){if(M.size===0)return $;let J=null;for(let Z of M){if($.has(Z))continue;J??=new Set($),J.add(Z)}return J??$}function SQ($,M){if($.size!==M.size)return!1;for(let J of $)if(!M.has(J))return!1;return!0}function T$($){let M=new Map;for(let[J,Z]of $.comments.entries()){let X=w2(Z,$).match?.containerId??null;if(!X)continue;let Y=M.get(X)??[];Y.push(J),M.set(X,Y)}return M}function kQ($){let M=new Map;return v2(M,$),M}function v2($,M,J=null){for(let Z of M){if(Z.type==="list"){for(let[X,Y]of Z.items.entries())v2($,[Y],{index:X,ordered:Z.ordered,start:Z.start});continue}if(Z.type==="listItem"){if(typeof Z.checked==="boolean")$.set(Z.id,{checked:Z.checked,kind:"task"});else if(J?.ordered)$.set(Z.id,{kind:"ordered",label:`${(J.start??1)+J.index}.`});else $.set(Z.id,{kind:"bullet",label:"•"});v2($,Z.children,J)}if(Z.type==="blockquote")v2($,Z.children,J)}}function uQ($){if($.blocks.length>0)return $;return d1([d({text:""})],$.comments,$.frontMatter)}function N6($,M=null){let J=[],Z=0,X=(Y)=>{let Q=Z,K=Q+Y.text.length;J.push({...Y,end:K,start:Q}),Z=K};for(let Y of $)switch(Y.type){case"break":X({id:Y.id,image:null,inlineCode:!1,kind:"break",link:M,marks:[],originalType:null,text:`
|
|
23
|
+
`});break;case"image":X({id:Y.id,image:{alt:Y.alt,title:Y.title,url:Y.url,width:Y.width},inlineCode:!1,kind:"image",link:M,marks:[],originalType:null,text:vQ(Y.alt)});break;case"inlineCode":X({id:Y.id,image:null,inlineCode:!0,kind:"inlineCode",link:M,marks:[],originalType:null,text:Y.code});break;case"link":for(let Q of N6(Y.children,{title:Y.title,url:Y.url}))X(Q);break;case"text":X({id:Y.id,image:null,inlineCode:!1,kind:"text",link:M,marks:Y.marks,originalType:null,text:Y.text});break;case"unsupported":X({id:Y.id,image:null,inlineCode:!1,kind:"unsupported",link:M,marks:[],originalType:Y.originalType,text:Y.source});break}return J}function vQ($){return k2}function b0($){switch($.type){case"break":return 1;case"image":return k2.length;case"inlineCode":return $.code.length;case"link":return q0($.children).length;case"text":return $.text.length;case"unsupported":return $.source.length}}function g2($,M,J,Z,X){let Y=[],Q=0,K=!1;for(let[q,D]of $.entries()){let A=`${Z}.${q}`,V=b0(D),U=Q,G=U+V;if(Q=G,J<=U||M>=G){Y.push(D);continue}if(!K){if(Y.push(...hQ(D,Math.max(0,M-U),A)),X)Y.push(X);K=!0}Y.push(...gQ(D,Math.min(V,J-U),A))}if(!K&&X)Y.push(X);return D0(Y)}function hQ($,M,J){if(M<=0)return[];return H6($,0,M,`${J}.before`)}function gQ($,M,J){let Z=b0($);if(M>=Z)return[];return H6($,M,Z,`${J}.after`)}function H6($,M,J,Z){if(M>=J)return[];switch($.type){case"text":return D0([y1($.text.slice(M,J),$.marks,Z)].filter(Boolean));case"inlineCode":return[E6($.code.slice(M,J),Z)];case"link":{let X=D0(IQ($.children,M,J,`${Z}.children`));return X.length>0?[{...$,children:X}]:[]}default:return[]}}function z6($,M,J){let Z=0,X="";for(let Y of $){let Q=b0(Y),K=Z,q=K+Q;if(Z=q,J<=K||M>=q)continue;X+=pQ(Y,Math.max(0,M-K),Math.min(Q,J-K))}return X}function y1($,M,J){if($.length===0)return null;return E0({marks:M,path:J,text:$})}function E6($,M){return g1({code:$,path:M})}function IQ($,M,J,Z){let X=[],Y=0;for(let[Q,K]of $.entries()){let q=b0(K),D=Y,A=D+q;if(Y=A,J<=D||M>=A)continue;X.push(...H6(K,Math.max(0,M-D),Math.min(q,J-D),`${Z}.${Q}`))}return X}function pQ($,M,J){if(M>=J)return"";switch($.type){case"break":return`
|
|
24
|
+
`.slice(M,J);case"image":return k2.slice(M,J);case"inlineCode":return $.code.slice(M,J);case"link":return z6($.children,M,J);case"text":return $.text.slice(M,J);case"unsupported":return $.source.slice(M,J)}}function W6($,M,J,Z){let X=lQ($.children,M,J,Z);if(X===null)return null;let Y=D0(O$($.children,M,J,Z,X,`${$.path}.children`));return Y.length>0?b1($,Y,M,J):null}function B6($,M,J){let Z=0,X=null,Y=(Q)=>{for(let K of Q){let q=b0(K),D=Z,A=D+q;if(Z=A,J<=D||M>=A)continue;if(K.type==="text"){let V=Math.max(M,D);if(Math.min(J,A)>V)X=X===null?new Set(K.marks):new Set(K.marks.filter((G)=>X?.has(G)));continue}if(K.type==="link"){let V=Z;Z=D,Y(K.children),Z=V}}};return Y($.children),X?[...X]:[]}function lQ($,M,J,Z){let X=0,Y=!1,Q=!0,K=(q)=>{for(let D of q){let A=b0(D),V=X,U=V+A;if(X=U,J<=V||M>=U)continue;if(D.type==="text"){let G=Math.max(M,V);if(Math.min(J,U)>G)Y=!0,Q&&=D.marks.includes(Z);continue}if(D.type==="link"){let G=X;X=V,K(D.children),X=G}}};return K($),Y?Q:null}function O$($,M,J,Z,X,Y){let Q=[],K=0;for(let[q,D]of $.entries()){let A=K,V=b0(D),U=A+V,G=`${Y}.${q}`;if(K=U,J<=A||M>=U){Q.push(D);continue}if(D.type==="text"){Q.push(...dQ(D,Math.max(0,M-A),Math.min(V,J-A),Z,X,G));continue}if(D.type==="link"){let _=D0(O$(D.children,Math.max(0,M-A),Math.min(V,J-A),Z,X,`${G}.children`));if(_.length>0)Q.push({...D,children:_});continue}Q.push(D)}return Q}function dQ($,M,J,Z,X,Y){let Q=$.text.slice(0,M),K=$.text.slice(M,J),q=$.text.slice(J),D=X?$.marks.filter((A)=>A!==Z):rQ($.marks,Z);return[y1(Q,$.marks,`${Y}.before`),y1(K,D,`${Y}.selected`),y1(q,$.marks,`${Y}.after`)].filter(Boolean)}function rQ($,M){return $.includes(M)?$:[...$,M].sort()}function P6($,M,J){let Z=xQ($.children,M,J,`${$.path}.children`);return Z.length>0?b1($,Z,M,J):null}function xQ($,M,J,Z){let X=j$($,M,J);if(X)return g2($,M,J,Z,y1(X.code,[],`${Z}.selected`));let Y=z6($,M,J);if(Y.length===0)return $;return g2($,M,J,Z,E6(Y,`${Z}.selected`))}function j$($,M,J){let Z=0;for(let X of $){let Y=b0(X),Q=Z,K=Q+Y;if(Z=K,M===Q&&J===K&&X.type==="inlineCode")return X;if(X.type==="link"){let q=j$(X.children,Math.max(0,M-Q),Math.min(Y,J-Q));if(q)return q}}return null}function y6($,M,J,Z,X){return E5($,M,J,Z,(Y,Q,K)=>L$(Y,Q,K,X))}function L$($,M,J,Z){let X=D0(cQ($.children,M,J,Z,`${$.path}.children`)??[]);return X.length>0?b1($,X,M,J):null}function cQ($,M,J,Z,X){let Y=[],Q=0,K=!1;for(let[q,D]of $.entries()){let A=`${X}.${q}`,V=b0(D),U=Q,G=U+V;if(Q=G,!K&&D.type==="link"&&M===U&&J===G){if(Z===null)Y.push(...D.children);else Y.push(I1({children:D.children,path:A,title:D.title,url:Z}));K=!0;continue}Y.push(D)}return K?Y:null}function X2($,M){let J=$.regionIndex.get(M);if(!J)return null;let Z=x1($.document.blocks,J.blockId);if(!Z)return null;return b6(Z,J.path,J.semanticRegionId)}function aQ($,M,J,Z,X){if(J>=Z)return null;let Y=X2($,M);return Y?X(Y,J,Z):null}function E5($,M,J,Z,X){let Y=aQ($,M,J,Z,X);return Y?{kind:"replace-block",block:Y.block,blockId:Y.blockId,selection:Y.selection}:null}function b6($,M,J){if($.type==="heading"||$.type==="paragraph")return{block:$,children:$.children,kind:"inlineBlock",path:M.replace(/\.children$/,"")};if($.type!=="table")return null;let Z=/^(.*\.rows\.\d+\.cells\.\d+)$/.exec(M);if(!Z)return null;for(let X of $.rows)for(let Y of X.cells)if(Y.id===J)return{block:$,blockPath:Z[1].replace(/\.rows\.\d+\.cells\.\d+$/,""),cell:Y,children:Y.children,kind:"tableCell",path:Z[1]};return null}function R$($,M,J){let Z=X2($,M.focus.regionId);if(!Z)return null;let X=Math.min(M.anchor.offset,M.focus.offset),Y=Math.max(M.anchor.offset,M.focus.offset);return{kind:"replace-block",...I2(Z,X,Y,J)}}function I2($,M,J,Z){let X=`${$.path}.children`,Y=Z(`${X}.selected`),Q=g2($.children,M,J,X,Y);return b1($,Q,M+1,M+1)}function b1($,M,J,Z){switch($.kind){case"inlineBlock":return{block:T0($.block,M),blockId:$.block.id,selection:C$(`${$.path}.children`,J,Z)};case"tableCell":{let X=M1({children:M,path:$.path}),Y=$.block.rows.map((Q)=>({...Q,cells:Q.cells.map((K)=>K.id===$.cell.id?X:K)}));return{block:u0($.block,Y),blockId:$.block.id,selection:C$($.path,J,Z)}}}}function C$($,M,J){return{endOffset:J,kind:"region-range-path",path:$,startOffset:M}}function G0($,M,J=0){return{childIndices:M,kind:"descendant-primary-region",offset:J,rootIndex:$}}function $0($,M=0){return{kind:"root-primary-region",offset:M,rootIndex:$}}function T1($,M,J,Z=0){return{cellIndex:J,kind:"table-cell",offset:Z,rootIndex:$,rowIndex:M}}function K1($,M){return $.regionIndex.get(M)??null}function M2($,M){return $.regionPathIndex.get(M)??null}function Y2($,M,J,Z){let X=$.tableCellRegionIndex.get(u2(M,J,Z));return X?$.regionIndex.get(X)??null:null}function sQ($){return $.anchor.regionId===$.focus.regionId&&$.anchor.offset===$.focus.offset}function Y0($,M){let J="documentIndex"in $?$.documentIndex:$,Z="documentIndex"in $?$.selection:M,X=sQ(Z),Y=f$(J,Z.anchor),Q=f$(J,Z.focus);if(Y<=Q)return{collapsed:X,end:Z.focus,start:Z.anchor};return{collapsed:X,end:Z.anchor,start:Z.focus}}function p2($,M){if(!M)return null;if("kind"in M){if(M.kind==="root-primary-region"){let Z=$.document.blocks[M.rootIndex],X=Z?w6($,Z):null;return X?w1(X.id,W5(X.text,M.offset)):null}if(M.kind==="descendant-primary-region"){let Z=$.document.blocks[M.rootIndex],X=Z?iQ(Z,M.childIndices):null,Y=X?w6($,X):null;return Y?w1(Y.id,W5(Y.text,M.offset)):null}if(M.kind==="table-cell"){let Z=$.document.blocks[M.rootIndex];if(!Z||Z.type!=="table")return null;let X=Y2($,Z.id,M.rowIndex,M.cellIndex);return X?w1(X.id,W5(X.text,M.offset)):null}let J=M2($,M.path);if(!J)return null;if(M.kind==="region-path")return w1(J.id,W5(J.text,M.offset));return{anchor:{regionId:J.id,offset:Math.max(0,Math.min(M.startOffset,J.text.length))},focus:{regionId:J.id,offset:Math.max(0,Math.min(M.endOffset,J.text.length))}}}return M}function f$($,M){let J=$.regionOrderIndex.get(M.regionId);if(J===void 0)throw Error(`Unknown canvas region: ${M.regionId}`);return J*b$+M.offset}function w1($,M){let J={offset:M,regionId:$};return{anchor:J,focus:J}}function W5($,M){return M==="end"?$.length:Math.max(0,Math.min(M,$.length))}function iQ($,M){let J=$;for(let Z of M){if(!J)return null;let X=m$(J);if(!X)return null;J=X[Z]??null}return J}function w6($,M){let J=$.blockIndex.get(M.id);if(!J)return null;let Z=J.regionIds[0];if(Z)return $.regionIndex.get(Z)??null;let X=m$(M);if(!X)return null;for(let Y of X){let Q=w6($,Y);if(Q)return Q}return null}function m$($){switch($.type){case"list":return $.items;case"blockquote":case"listItem":return $.children;default:return null}}function l2($){let M=$.documentIndex.regionIndex.get($.selection.anchor.regionId)??null,J=M?$.documentIndex.blockIndex.get(M.blockId)??null:null,Z=$.selection.anchor.offset,X=M?.inlines.find((Y)=>Z>Y.start&&Z<Y.end)??M?.inlines.find((Y)=>Y.end===Z)??M?.inlines.find((Y)=>Y.start===Z)??null;return{block:J?{blockId:J.id,depth:J.depth,nodeType:J.type,text:M?.text??""}:null,span:X?.link?{kind:"link",url:X.link.url}:X&&X.marks.length>0?{kind:"marks",marks:X.marks}:{kind:"none"}}}function B5($){let M=$.documentIndex.regionIndex.get($.selection.anchor.regionId)??null,J=$.selection.anchor.offset,Z=M?.inlines.find((X)=>J>X.start&&J<X.end)??M?.inlines.find((X)=>X.end===J)??M?.inlines.find((X)=>X.start===J)??null;return Z?.kind==="image"?Z:null}function P5($){let M=Y0($.documentIndex,$.selection);if(M.start.regionId!==M.end.regionId||M.start.offset===M.end.offset)return[];let J=$.documentIndex.regionIndex.get(M.start.regionId);if(!J)return[];let Z=x1($.documentIndex.document.blocks,J.blockId);if(!Z)return[];let X=b6(Z,J.path,J.semanticRegionId);return X?B6(X,M.start.offset,M.end.offset):[]}var T6=new Map([["rgba(0, 0, 0, 0)",[0,0,0,0]]]);function d2($){switch($.kind){case"active-block-flash":return 300;case"deleted-text-fade":return 180;case"inserted-text-highlight":return 1000;case"list-marker-pop":return 500;case"punctuation-pulse":return 140}}function j6($,M){let J=M??nQ();return $.animations.some((Z)=>J-Z.startedAt<d2(Z))}function k$($,M){return L6($,M,"inserted-text-highlight",(J)=>J.regionPath)}function u$($,M){return c$($,M,"active-block-flash",(J)=>J.blockPath)}function v$($,M){return L6($,M,"deleted-text-fade",(J)=>J.regionPath)}function h$($,M){return L6($,M,"punctuation-pulse",(J)=>J.regionPath)}function g$($,M){return c$($,M,"list-marker-pop",(J)=>J.blockPath)}function I$($,M,J){let Z=new Set([$,M]);for(let X of J){if(X.endOffset<=$||X.startOffset>=M)continue;Z.add(Math.max($,X.startOffset)),Z.add(Math.min(M,X.endOffset))}return[...Z].sort((X,Y)=>X-Y)}function p$($,M,J){return $.find((Z)=>Z.startOffset<J&&Z.endOffset>M)??null}function l$($,M,J){if(!M)return $;return x2(J.insertHighlightText,$,M.progress)}function d$($,M){return x2($,"rgba(0, 0, 0, 0)",M.progress)}function b5($,M){return x2($,"rgba(0, 0, 0, 0)",M.progress)}function r$($,M){return x2(M.insertHighlightText,"rgba(0, 0, 0, 0)",$.progress)}function x$($){let M=Math.min(1,$.progress*2);return 0.1+0.9*oQ(M)}function r2($,M,J){let Z=Math.max(0,M.progress*2-1);return x2(J.insertHighlightText,$,Z)}function L6($,M,J,Z){let X=new Map;for(let Y of $.animations){if(Y.kind!==J)continue;let Q=d2(Y),K=M-Y.startedAt;if(K>=Q)continue;let q={...Y,progress:Math.max(0,Math.min(1,K/Q))},D=Z(Y),A=X.get(D);if(A)A.push(q);else X.set(D,[q])}return X}function c$($,M,J,Z){let X=new Map;for(let Y of $.animations){if(Y.kind!==J)continue;let Q=d2(Y),K=M-Y.startedAt;if(K>=Q)continue;X.set(Z(Y),{...Y,progress:Math.max(0,Math.min(1,K/Q))})}return X}function oQ($){return 1-(1-$)*(1-$)*(1-$)}function x2($,M,J){let Z=S$($),X=S$(M);return`rgba(${O6(y5(Z[0],X[0],J))}, ${O6(y5(Z[1],X[1],J))}, ${O6(y5(Z[2],X[2],J))}, ${y5(Z[3],X[3],J)})`}function nQ(){return typeof performance<"u"?performance.now():Date.now()}function S$($){let M=T6.get($);if(M)return M;let J=tQ($)??eQ($)??$K($)??T6.get("rgba(0, 0, 0, 0)");return T6.set($,J),J}function tQ($){let M=$.trim();if(!M.startsWith("#"))return null;let J=M.slice(1);if(J.length===3)return[Number.parseInt(`${J[0]}${J[0]}`,16),Number.parseInt(`${J[1]}${J[1]}`,16),Number.parseInt(`${J[2]}${J[2]}`,16),1];if(J.length===6)return[Number.parseInt(J.slice(0,2),16),Number.parseInt(J.slice(2,4),16),Number.parseInt(J.slice(4,6),16),1];return null}function eQ($){let M=/^rgb\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec($.trim());if(!M)return null;return[Number(M[1]),Number(M[2]),Number(M[3]),1]}function $K($){let M=/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec($.trim());if(!M)return null;return[Number(M[1]),Number(M[2]),Number(M[3]),Number(M[4])]}function y5($,M,J){return $+(M-$)*J}function O6($){return Math.round($)}function C6($,M,J=O1()){if(M<=0)return $;let Z=T5($);if(!Z)return $;let X=$.selection.focus.offset,Y=Math.max(0,X-M);if(X<=Y)return $;return c2($,{endOffset:X,kind:"inserted-text-highlight",regionPath:Z.path,startOffset:Y,startedAt:J})}function a$($,M,J,Z){let X=T5($);if(!X)return M;let Y=X.text.slice(J,Z);if(Y.length===0)return M;if(!X.inlines.some((K)=>K.start<=J&&K.end>=Z&&K.kind==="text"&&K.link===null&&K.marks.length===0))return M;return c2(M,{kind:"deleted-text-fade",regionPath:X.path,startOffset:J,startedAt:O1(),text:Y})}function s$($,M=O1()){let J=T5($),Z=$.selection.focus.offset-1;if(!J||Z<0||J.text[Z]!==".")return $;return c2($,{kind:"punctuation-pulse",offset:Z,regionPath:J.path,startedAt:M})}function i$($,M,J=O1()){return c2($,{blockPath:M,kind:"list-marker-pop",startedAt:J})}function o$($,M,J=O1()){return c2($,{blockPath:M,kind:"active-block-flash",startedAt:J})}function R6($,M){return $.filter((J)=>J.startedAt+d2(J)>M)}function O1(){return typeof performance<"u"?performance.now():Date.now()}function w5($,M){let J=Math.max(-1/0,...$.animations.map((Z)=>Z.startedAt));return M.animations.some((Z)=>Z.startedAt>J)}function n$($){let M=T5($);return(M?$.documentIndex.blockIndex.get(M.blockId)??null:null)?.path??""}function T5($){return $.documentIndex.regionIndex.get($.selection.focus.regionId)??null}function c2($,M){let J=R6($.animations,M.startedAt);return{...$,animations:[...J,M]}}function a2($,M,J,Z){return MK(m6($.inlines,M,J,Z))}function m6($,M,J,Z){let Y=JK($,M,J,{didInsert:!1,generatedRunCount:0,replacementText:Z});return KK(DK(Y))}function MK($){let M=[];for(let J=0;J<$.length;J+=1){let Z=$[J];if(Z.link){let Y=[],Q=Z.link;while(J<$.length&&S6($[J].link,Q)){let K=e$($[J]);if(K)Y.push(K);J+=1}if(J-=1,Y.length>0)M.push(I1({children:D0(Y),title:Q.title,url:Q.url}));continue}let X=e$(Z);if(X)M.push(X)}return D0(M)}function JK($,M,J,Z){let X=[];for(let[Y,Q]of $.entries()){if(!Z.didInsert&&M===J&&M===Q.start)f6(X,Z,t$($[Y-1]??null,Q));if(J<=Q.start||M>=Q.end){X.push(O5(Q));continue}let K=Math.max(0,M-Q.start),q=Math.min(Q.text.length,J-Q.start),D=!Z.didInsert&&Z.replacementText.length>0?Z.replacementText:"",A=ZK(Q,K,q,D,Z);if(K!==q||D.length>0)Z.didInsert=!0;X.push(...A)}if(!Z.didInsert)f6(X,Z,t$($.at(-1)??null,null));return X}function ZK($,M,J,Z,X){switch($.kind){case"text":case"inlineCode":case"unsupported":return XK($,M,J,Z);case"break":return YK($,M,J,Z,X);case"image":return QK($,M,J,Z)}}function XK($,M,J,Z){let X=$.text.slice(0,M)+Z+$.text.slice(J);return X.length>0?[{...O5($),text:X}]:[]}function YK($,M,J,Z,X){if(M===J)return[O5($)];let Y=[];if(Z.length>0)f6(Y,X,$.link);return Y}function QK($,M,J,Z){if(M===0&&J===$.text.length)return Z.length>0?[$7(Z,$.link,0)]:[];return[O5($)]}function f6($,M,J){if(M.replacementText.length===0){M.didInsert=!0;return}$.push($7(M.replacementText,J,M.generatedRunCount)),M.generatedRunCount+=1,M.didInsert=!0}function $7($,M,J){return{id:`generated:${J}`,image:null,inlineCode:!1,kind:"text",link:M,marks:[],originalType:null,text:$}}function t$($,M){return $?.link&&M?.link&&S6($.link,M.link)?$.link:null}function O5($){return{id:$.id,image:$.image,inlineCode:$.inlineCode,kind:$.kind,link:$.link,marks:$.marks,originalType:$.originalType,text:$.text}}function KK($){let M=[],J=0;for(let Z of $){let X=J,Y=X+Z.text.length;M.push({...Z,end:Y,start:X}),J=Y}return M}function DK($){let M=[];for(let J of $){let Z=M.at(-1);if(Z&&qK(Z,J)){M[M.length-1]={...Z,text:Z.text+J.text};continue}M.push(J)}return M}function qK($,M){return $.kind===M.kind&&$.inlineCode===M.inlineCode&&S6($.link,M.link)&&UK($.image,M.image)&&$.originalType===M.originalType&&$.marks.join(",")===M.marks.join(",")}function e$($){switch($.kind){case"break":return c4();case"image":return $.image?AK($.image):null;case"inlineCode":return g1({code:$.text});case"text":return $.text.length>0?E0({marks:$.marks,text:$.text}):null;case"unsupported":return a4({originalType:$.originalType??"unsupported",source:$.text})}}function AK($){return H1({alt:$.alt,title:$.title,url:$.url,width:$.width})}function S6($,M){return $?.url===M?.url&&$?.title===M?.title}function UK($,M){return $?.url===M?.url&&$?.title===M?.title&&$?.alt===M?.alt&&$?.width===M?.width}function J7($,M,J){let Z=Y0($,M);if(Z.start.regionId===Z.end.regionId)return VK($,Z,J);return FK($,Z,J)}function VK($,M,J){let Z=K1($,M.start.regionId);if(!Z)throw Error(`Unknown region: ${M.start.regionId}`);let X=z5($,Z.blockId,(D)=>GK(D,Z,M.start.offset,M.end.offset,J));if(!X)throw Error(`Failed to replace block for canvas region: ${Z.id}`);let Y=Z2($,X,Z.rootIndex,1),Q=Q7($,Y,Z,M.start.offset,M.end.offset,J),K=M2(Q,Z.path);if(!K)throw Error(`Failed to remap region after replacement: ${Z.path}`);let q=M.start.offset+J.length;return{documentIndex:Q,selection:w1(K.id,q)}}function GK($,M,J,Z,X){switch($.type){case"heading":case"paragraph":return NK($,M,J,Z,X);case"code":return o4($,M7(M,J,Z,X));case"table":return _K($,M,J,Z,X);case"unsupported":return n4($,M7(M,J,Z,X));default:throw Error(`Canvas text replacement is not supported for block type: ${$.type}`)}}function NK($,M,J,Z,X){return T0($,a2(M,J,Z,X))}function _K($,M,J,Z,X){let Y=M.tableCellPosition?.rowIndex,Q=M.tableCellPosition?.cellIndex;if(Y===void 0||Q===void 0)throw Error(`Unable to resolve table cell position for region: ${M.id}`);let K=a2(M,J,Z,X),q=$.rows.map((D,A)=>{if(A!==Y)return D;let V=D.cells.map((U,G)=>{if(G!==Q)return U;return M1({children:K})});return{...D,cells:V}});return u0($,q)}function M7($,M,J,Z){return m6($.inlines,M,J,Z).map((X)=>X.text).join("")}function s2($){return $!==null&&($.type==="heading"||$.type==="paragraph")}function FK($,M,J){let Z=K1($,M.start.regionId),X=K1($,M.end.regionId);if(!Z||!X)throw Error("Unknown cross-region selection endpoints.");let Y=$.document.blocks[Z.rootIndex],Q=$.document.blocks[X.rootIndex];if(!Y||!Q)throw Error("Unknown root blocks for cross-region selection.");let K=Z7(Y,Z,M.start.offset),q=X7(Q,X,M.end.offset),D=HK(K,q,J),A=D.blocks.length>0?D.blocks:[d({text:""})],V=Z.rootIndex,U=X.rootIndex-Z.rootIndex+1,G=W1($.document,V,U,A),_=Z2($,G,V,U),N=Q7($,_,Z,M.start.offset,Z.text.length,s2(K)?J:""),H=N.roots[V+D.caretLocalIndex]?.regions[0]??null;return{documentIndex:N,selection:w1(H?.id??Z.id,H?D.caretOffset:0)}}function HK($,M,J){if(s2($)&&s2(M))return{blocks:[zK($,M,J)],caretLocalIndex:0,caretOffset:$.plainText.length+J.length};if(s2($)){let Y=[J.length>0?EK($,J):$];if(M)Y.push(M);return{blocks:Y,caretLocalIndex:0,caretOffset:$.plainText.length+J.length}}if(s2(M)){let X=J.length>0?WK(M,J):M,Y=[];if($)Y.push($);let Q=Y.length;return Y.push(X),{blocks:Y,caretLocalIndex:Q,caretOffset:J.length}}let Z=[];if($)Z.push($);if(J.length>0){let X=Z.length;if(Z.push(d({text:J})),M)Z.push(M);return{blocks:Z,caretLocalIndex:X,caretOffset:J.length}}if(M){let X=Z.length;return Z.push(M),{blocks:Z,caretLocalIndex:X,caretOffset:0}}return{blocks:Z,caretLocalIndex:0,caretOffset:0}}function zK($,M,J){let Z=J.length>0?[E0({text:J})]:[];return T0($,D0([...$.children,...Z,...M.children]))}function EK($,M){return T0($,D0([...$.children,E0({text:M})]))}function WK($,M){return T0($,D0([E0({text:M}),...$.children]))}function Z7($,M,J){if($.type==="table")return null;if($.id===M.blockId)return BK($,M,J);return Y7($,(Z)=>yK(Z,M,J))}function X7($,M,J){if($.type==="table")return null;if($.id===M.blockId)return PK($,M,J);return Y7($,(Z)=>bK(Z,M,J))}function BK($,M,J){if(J===0)return null;switch($.type){case"heading":case"paragraph":return T0($,a2(M,J,M.text.length,""));case"code":return o4($,M.text.slice(0,J));case"unsupported":return n4($,M.text.slice(0,J));default:return null}}function PK($,M,J){if(J===M.text.length)return null;switch($.type){case"heading":case"paragraph":return T0($,a2(M,0,J,""));case"code":return o4($,M.text.slice(J));case"unsupported":return n4($,M.text.slice(J));default:return null}}function Y7($,M){switch($.type){case"blockquote":{let J=M($.children);return J.length===0?null:H0({children:J})}case"list":{let J=M($.items);return J.length===0?null:e($,J)}case"listItem":{let J=M($.children);return J.length===0?null:P0($,J)}default:return null}}function yK($,M,J){let Z=$.findIndex((Q)=>j5(Q,M));if(Z===-1)return[];let X=$.slice(0,Z),Y=Z7($[Z],M,J);return Y?[...X,Y]:X}function bK($,M,J){let Z=$.findIndex((Q)=>j5(Q,M));if(Z===-1)return[];let X=$.slice(Z+1),Y=X7($[Z],M,J);return Y?[Y,...X]:X}function j5($,M){if($.id===M.blockId)return!0;switch($.type){case"blockquote":case"listItem":return $.children.some((J)=>j5(J,M));case"list":return $.items.some((J)=>j5(J,M));default:return!1}}function Q7($,M,J,Z,X,Y){if($.document.comments.length===0)return M;let Q=G6($,M,J,Z,X,Y);return Q===M.document.comments?M:H5(M,{...M.document,comments:Q})}function i2($){let M=J2($),J=A7(M);return{animations:[],documentIndex:M,future:[],history:[],selection:{anchor:J,focus:J}}}function p0($){let M=L0($.documentIndex);return d1(P2($.documentIndex.document.blocks),M.threads,$.documentIndex.document.frontMatter)}function o($,M){if(!M)return null;switch(M.kind){case"keep-state":return $;case"set-selection":return X0($,M.selection);case"replace-block":{let J=z5($.documentIndex,M.blockId,()=>M.block);return J?L5($,J2(J),M.selection??null):null}case"splice-blocks":{let J=W1($.documentIndex.document,M.rootIndex,M.count??1,M.blocks);return L5($,J2(J),M.selection??null)}case"splice-text":{let J=J7($.documentIndex,M.selection,M.text);return L5($,J.documentIndex,J.selection)}case"splice-comments":{let J=V9($.documentIndex.document,M.index,M.count,M.threads);return L5($,H5($.documentIndex,J),null)}}}function L5($,M,J){let Z=wK($,M),X=p2(Z.documentIndex,J)??$.selection,Y=U7($,Z,X);return X0(Z,X,Y)}function X0($,M,J){let Z="regionId"in M?{anchor:C5($.documentIndex,M),focus:C5($.documentIndex,M)}:{anchor:C5($.documentIndex,M.anchor),focus:C5($.documentIndex,M.focus)},X={...$,selection:Z};return J??U7($,X)?o$(X,n$(X)):X}function z0($,M,J,Z){let X={regionId:M,offset:J};return X0($,Z?{anchor:$.selection.anchor,focus:X}:X)}function wK($,M){let J=A7(M);return{animations:R6($.animations,O1()),documentIndex:M,future:[],history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:{anchor:J,focus:J}}}function k6($){let M=$.history.at(-1);if(!M)return $;return q7(M,{future:[D7($),...$.future],history:$.history.slice(0,-1)})}function u6($){let M=$.future[0];if(!M)return $;return q7(M,{future:$.future.slice(1),history:[...$.history,D7($)]})}function D7($){return{document:$.documentIndex.document,selection:$.selection}}function q7($,M){return{animations:[],documentIndex:J2($.document),future:M.future,history:M.history,selection:$.selection}}function A7($){return $.regions[0]?{regionId:$.regions[0].id,offset:0}:{regionId:"empty",offset:0}}function C5($,M){let J=K1($,M.regionId);if(!J)return M;return{regionId:J.id,offset:Math.max(0,Math.min(M.offset,J.text.length))}}function U7($,M,J){let Z=K7($.documentIndex,$.selection),X=K7(M.documentIndex,J??M.selection);return X!==null&&X!==Z}function K7($,M){let J=$.regionIndex.get(M.focus.regionId),Z=J?$.blockIndex.get(J.blockId)??null:null;if(!J||!Z?.path)return null;return Z.type==="table"?`cell:${J.path}`:`block:${Z.path}`}function t2($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return{kind:"unsupported"};if(J.blockType==="code"){let K=$.blockIndex.get(J.blockId);return K?{kind:"code",region:J,rootIndex:K.rootIndex}:{kind:"unsupported"}}let Z=h6($,J.id);if(Z)return{kind:"tableCell",...Z};let X=K2($,M);if(X)return{kind:"listItem",...X};let Y=TK($,M);if(Y)return{kind:"blockquoteTextBlock",...Y};let Q=Q2($,M);if(Q)return{kind:"rootTextBlock",...Q};return{kind:"unsupported"}}function e2($,M){let J=$.blockIndex.get(M);if(!J)throw Error(`Unknown root block: ${M}`);return J.rootIndex}function v6($,M,J){let Z=M?$.blockIndex.get(M)??null:null;while(Z){if(Z.type===J)return Z;let X=Z.parentBlockId;Z=X?$.blockIndex.get(X)??null:null}return null}function o2($){let M=$.split("."),J=[];for(let Z=0;Z<M.length-1;Z+=1)if(M[Z]==="children"){let X=Number(M[Z+1]);if(Number.isInteger(X))J.push(X)}return J}function Q2($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId);if(!Z)return null;let X=Z.rootIndex,Y=$.document.blocks[X];if(!Y||Y.type!=="heading"&&Y.type!=="paragraph")return null;return{block:Y,region:J,rootIndex:X}}function TK($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=v6($,Z?.id??null,"blockquote");if(!Z||!X||Z.parentBlockId!==X.id)return null;let Y=X.rootIndex,Q=$.document.blocks[Y];if(!Q||Q.type!=="blockquote")return null;let K=Q.children.findIndex((D)=>D.id===Z.id),q=Q.children[K];if(!q||q.type!=="heading"&&q.type!=="paragraph")return null;return{block:q,blockChildIndices:o2(Z.path),childIndex:K,region:J,quote:Q,rootIndex:Y}}function n2($,M){return x1($.document.blocks,M)}function K2($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=v6($,Z?.id??null,"listItem"),Y=v6($,Z?.id??null,"list");if(!Z||!X||!Y)return null;let Q=n2($,Y.id);if(!Q||Q.type!=="list")return null;let K=Q.items.findIndex((_)=>_.id===X.id),q=Q.items[K];if(!q)return null;let D=Y.parentBlockId?$.blockIndex.get(Y.parentBlockId)??null:null,A=D?.parentBlockId?$.blockIndex.get(D.parentBlockId)??null:null,V=D?.type==="listItem"?n2($,D.id):null,U=A?.type==="list"?n2($,A.id):null,G=U?.type==="list"&&V?U.items.findIndex((_)=>_.id===V.id):-1;return{region:J,item:q,itemChildIndices:o2(X.path),itemIndex:K,list:Q,listChildIndices:o2(Y.path),parentItem:V?.type==="listItem"?V:null,parentItemChildIndices:D?.type==="listItem"?o2(D.path):null,parentItemIndex:G>=0?G:null,parentList:U?.type==="list"?U:null,parentListChildIndices:A?.type==="list"?o2(A.path):null,rootIndex:Y.rootIndex}}function h6($,M){let J=$.regionIndex.get(M);if(!J)return null;let Z=$.tableCellIndex.get(J.id),X=$.blockIndex.get(J.blockId),Y=X?.type==="table"?$.document.blocks[X.rootIndex]:null;if(!Z||!X||!Y||Y.type!=="table")return null;return{cellIndex:Z.cellIndex,rootIndex:X.rootIndex,rowIndex:Z.rowIndex,table:Y}}function $4($,M,J){return a0({checked:M,children:[d({text:$})],spread:J})}function D2($,M){let J=$.children[0];if(!J||J.type!=="paragraph")return null;return P0($,[d({text:M}),...$.children.slice(1)])}function V7($,M){return M.reduce((J,Z)=>`${J}.children.${Z}`,`root.${$}`)}function G7($,M){if($.selection.anchor.regionId!==$.selection.focus.regionId||$.selection.anchor.offset!==$.selection.focus.offset)return null;let J=K1($.documentIndex,$.selection.focus.regionId);if(!J)return null;if(M==="forward"&&$.selection.focus.offset>=J.text.length)return null;let Z=M==="backward"?OK(J.text,$.selection.focus.offset):$.selection.focus.offset,X=M==="backward"?$.selection.focus.offset:jK(J.text,$.selection.focus.offset);if(Z===X)return null;return{action:{kind:"splice-text",selection:{anchor:{regionId:J.id,offset:Z},focus:{regionId:J.id,offset:X}},text:""},startOffset:Z,endOffset:X}}function OK($,M){let J=Array.from($.slice(0,M));if(J.length===0)return 0;return M-J.at(-1).length}function jK($,M){let J=Array.from($.slice(M))[0];return J?M+J.length:$.length}function N7($,M,J){let Z=$.regionIndex.get(M.anchor.regionId);if(!Z)return null;let X=Y0($,M),Y=X.start.regionId===X.end.regionId&&X.start.regionId===Z.id?Z.text.slice(0,X.start.offset)+J+Z.text.slice(X.end.offset):J;return LK($,M,Z.id,Y)??RK($,M,Z.id,Y)??CK($,M,Z.id,Y)??fK($,M,Z.id,Y)??kK($,Z.blockId,Z.rootIndex,Y)??{kind:"splice-text",selection:M,text:J}}function LK($,M,J,Z){let X=K2($,M),Y=hK(Z);if(!X||!Y||X.region.id!==J)return null;let Q=D2(X.item,Y.text);if(!Q)return null;return{kind:"replace-block",block:e(X.list,X.list.items.map((K,q)=>q===X.itemIndex?Q:K),{ordered:Y.ordered,start:Y.ordered?1:null}),blockId:X.list.id,selection:G0(X.rootIndex,[...X.listChildIndices,X.itemIndex,0])}}function CK($,M,J,Z){if(!I6($,M,J))return null;if(/^\s*([-+*])\s\[( |x|X)\]\s$/.exec(Z)){let Q=Z.toLowerCase().includes("[x]");return g6($,M,{checked:Q,ordered:!1,start:null})}if(/^\s*[-+*]\s$/.test(Z))return g6($,M,{checked:null,ordered:!1,start:null});let Y=/^\s*(\d+)\.\s$/.exec(Z);if(Y)return g6($,M,{checked:null,ordered:!0,start:Number(Y[1])});return null}function RK($,M,J,Z){let X=Q2($,M),Y=gK(Z);if(!X||X.region.id!==J||X.block.type!=="heading"||!Y)return null;return{kind:"splice-blocks",blocks:[$1({depth:Y.depth,text:Y.text})],rootIndex:X.rootIndex,selection:$0(X.rootIndex)}}function fK($,M,J,Z){return mK($,M,J,Z)??SK($,M,J,Z)}function mK($,M,J,Z){if(!I6($,M,J))return null;let X=/^(#{1,6})\s$/.exec(Z);if(!X)return null;return uK($,M,X[1].length)}function SK($,M,J,Z){if(!I6($,M,J)||!/^>\s$/.test(Z))return null;return vK($,M)}function kK($,M,J,Z){if(!/^(?:(?:-\s?){3}|(?:\*\s?){3}|(?:_\s?){3})$/.test(Z))return null;return{kind:"splice-blocks",blocks:[s4(),d({text:""})],rootIndex:e2($,M),selection:$0(J+1)}}function g6($,M,J){let Z=e2($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"splice-blocks",blocks:[z1({items:[a0({checked:J.checked,children:[d({text:""})],spread:!1})],ordered:J.ordered,spread:!1,start:J.start})],rootIndex:Z,selection:G0(Z,[0,0])}}function uK($,M,J){let Z=e2($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"splice-blocks",blocks:[$1({depth:J,text:""})],rootIndex:Z,selection:$0(Z)}}function vK($,M){let J=e2($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"splice-blocks",blocks:[H0({children:[d({text:""})]})],rootIndex:J,selection:G0(J,[0])}}function I6($,M,J){let Z=Q2($,M);return Z?.region.id===J&&Z.block.type==="paragraph"}function hK($){let M=/^[-+*]\s(.+)$/.exec($);if(M)return{ordered:!1,text:M[1]};let J=/^\d+\.\s(.+)$/.exec($);if(J)return{ordered:!0,text:J[1]};return null}function gK($){let M=/^(#{1,6})\s(.+)$/.exec($);return M?{depth:M[1].length,text:M[2]}:null}function D1($,M,J,Z=0){return G0($,[...M,J,0],Z)}function p6($,M){let J=$.region.text,Z=$.item,X=typeof Z.checked==="boolean"?!1:Z.checked;if(M===0){let D=$4("",X,Z.spread);return{kind:"replace-block",block:e($.list,[...$.list.items.slice(0,$.itemIndex),D,Z,...$.list.items.slice($.itemIndex+1)]),blockId:$.list.id,listItemInsertedPath:R5(D,$.rootIndex,[...$.listChildIndices,$.itemIndex]),selection:D1($.rootIndex,$.listChildIndices,$.itemIndex)}}if(M===J.length){let D=$4("",X,Z.spread);return{kind:"replace-block",block:e($.list,[...$.list.items.slice(0,$.itemIndex+1),D,...$.list.items.slice($.itemIndex+1)]),blockId:$.list.id,listItemInsertedPath:R5(D,$.rootIndex,[...$.listChildIndices,$.itemIndex+1]),selection:D1($.rootIndex,$.listChildIndices,$.itemIndex+1)}}let Y=J.slice(0,M),Q=J.slice(M),K=$4(Q,X,Z.spread),q=P0(Z,[d({text:Y})]);return{kind:"replace-block",block:e($.list,[...$.list.items.slice(0,$.itemIndex),q,K,...$.list.items.slice($.itemIndex+1)]),blockId:$.list.id,listItemInsertedPath:R5(K,$.rootIndex,[...$.listChildIndices,$.itemIndex+1]),selection:D1($.rootIndex,$.listChildIndices,$.itemIndex+1)}}function _7($,M){if(M!==0||$.region.text.length!==0)return p6($,M);if($.parentItem&&$.parentItemIndex!==null&&$.parentItemChildIndices&&$.parentList&&$.parentListChildIndices)return IK($);let J=$.list.items.slice(0,$.itemIndex),Z=$.list.items.slice($.itemIndex+1),X=[];if(J.length>0)X.push(e($.list,J));if(X.push(d({text:""})),Z.length>0)X.push(e($.list,Z));return{kind:"splice-blocks",blocks:X,rootIndex:$.rootIndex,selection:$0($.rootIndex+(J.length>0?1:0))}}function F7($){if(typeof $.item.checked==="boolean"){let M=a0({checked:null,children:$.item.children,spread:$.item.spread});return{kind:"replace-block",block:e($.list,$.list.items.map((J,Z)=>Z===$.itemIndex?M:J)),blockId:$.list.id}}if($.itemIndex>0){let M=$.list.items[$.itemIndex-1];if(!M)return null;if($.item.plainText.length===0)return{kind:"replace-block",block:e($.list,$.list.items.filter((Z,X)=>X!==$.itemIndex)),blockId:$.list.id,selection:D1($.rootIndex,$.listChildIndices,$.itemIndex-1,"end")};let J=D2(M,`${M.plainText}${$.item.plainText}`);if(!J)return null;return{kind:"replace-block",block:e($.list,$.list.items.flatMap((Z,X)=>{if(X===$.itemIndex-1)return[J];if(X===$.itemIndex)return[];return[Z]})),blockId:$.list.id,selection:D1($.rootIndex,$.listChildIndices,$.itemIndex-1,M.plainText.length)}}return{kind:"splice-blocks",blocks:[d({text:$.item.plainText})],rootIndex:$.rootIndex,selection:$0($.rootIndex)}}function H7($){if($.itemIndex===0)return null;let M=$.list.items[$.itemIndex-1];if(!M)return null;let J=pK(M,$.item,$);return{kind:"replace-block",block:e($.list,$.list.items.flatMap((Z,X)=>{if(X===$.itemIndex-1)return[J.item];if(X===$.itemIndex)return[];return[Z]})),blockId:$.list.id,selection:G0($.rootIndex,J.regionChildIndices)}}function z7($){if(!$.parentItem||$.parentItemIndex===null||!$.parentItemChildIndices||!$.parentList||!$.parentListChildIndices)return null;let M=$.list.items.filter((X,Y)=>Y!==$.itemIndex),J=$.parentItem.children.flatMap((X)=>{if(X.type!=="list"||X.id!==$.list.id)return[X];if(M.length===0)return[];return[e($.list,M)]}),Z=P0($.parentItem,J);return{kind:"replace-block",block:e($.parentList,[...$.parentList.items.slice(0,$.parentItemIndex),Z,$.item,...$.parentList.items.slice($.parentItemIndex+1)]),blockId:$.parentList.id,selection:D1($.rootIndex,$.parentListChildIndices,$.parentItemIndex+1)}}function l6($,M){let J=$.itemIndex+M;if(J<0||J>=$.list.items.length)return null;let Z=[...$.list.items],[X]=Z.splice($.itemIndex,1);if(!X)return null;return Z.splice(J,0,X),{kind:"replace-block",block:e($.list,Z),blockId:$.list.id,selection:D1($.rootIndex,$.listChildIndices,J)}}function IK($){if(!$.parentItem||$.parentItemIndex===null||!$.parentItemChildIndices||!$.parentList||!$.parentListChildIndices)return null;let M=$.list.items.filter((Q,K)=>K!==$.itemIndex),J=$.parentItem.children.flatMap((Q)=>{if(Q.type!=="list"||Q.id!==$.list.id)return[Q];if(M.length===0)return[];return[e($.list,M)]}),Z=P0($.parentItem,J),X=typeof $.parentItem.checked==="boolean"?!1:$.parentItem.checked,Y=$4("",X,$.parentItem.spread);return{kind:"replace-block",block:e($.parentList,[...$.parentList.items.slice(0,$.parentItemIndex),Z,Y,...$.parentList.items.slice($.parentItemIndex+1)]),blockId:$.parentList.id,listItemInsertedPath:R5(Y,$.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1]),selection:D1($.rootIndex,$.parentListChildIndices,$.parentItemIndex+1)}}function R5($,M,J){return typeof $.checked==="boolean"?void 0:V7(M,J)}function pK($,M,J){let Z=$.children.findIndex((Y)=>Y.type==="list"&&Y.ordered===J.list.ordered&&Y.start===J.list.start);if(Z>=0){let Y=$.children[Z];if(!Y||Y.type!=="list")return{item:$,regionChildIndices:[...J.listChildIndices,J.itemIndex-1,0]};return{item:P0($,$.children.map((Q,K)=>K===Z?e(Y,[...Y.items,M]):Q)),regionChildIndices:[...J.listChildIndices,J.itemIndex-1,Z,Y.items.length,0]}}let X=z1({items:[M],ordered:J.list.ordered,spread:J.list.spread,start:J.list.start});return{item:P0($,[...$.children,X]),regionChildIndices:[...J.listChildIndices,J.itemIndex-1,$.children.length,0,0]}}function E7($,M){let J=$.region.text.length,Z=$.region.text.slice(0,M),X=$.region.text.slice(M),Y=M===0&&J>0?$.rootIndex:$.rootIndex+1;if($.block.type==="paragraph")return{kind:"splice-blocks",blocks:M===0?[d({text:""}),$.block]:M===J?[$.block,d({text:""})]:[d({text:Z}),d({text:X})],rootIndex:$.rootIndex,selection:$0(Y)};return{kind:"splice-blocks",blocks:M===0?[d({text:""}),$.block]:M===J?[$.block,d({text:""})]:[$1({depth:$.block.depth,text:Z}),d({text:X})],rootIndex:$.rootIndex,selection:$0(Y)}}function W7($,M){let J=$.region.text,Z=J.slice(0,M),X=J.slice(M),Y=$.block.type==="heading"?sK($.block,Z,X,$.blockChildIndices,M,J.length):aK($.block,Z,X,$.blockChildIndices,M,J.length);return{kind:"splice-blocks",blocks:[H0({children:[...$.quote.children.slice(0,$.childIndex),...Y.blocks,...$.quote.children.slice($.childIndex+1)]})],rootIndex:$.rootIndex,selection:G0($.rootIndex,Y.focusChildIndices)}}function B7($,M){if(M!==0||$.region.text.length!==0||$.block.type!=="paragraph")return null;let J=$.quote.children.slice(0,$.childIndex),Z=$.quote.children.slice($.childIndex+1),X=[];if(J.length>0)X.push(H0({children:J}));if(X.push(d({text:""})),Z.length>0)X.push(H0({children:Z}));return{kind:"splice-blocks",blocks:X,rootIndex:$.rootIndex,selection:$0($.rootIndex+(J.length>0?1:0))}}function P7($,M){let J=rK($);if(J)return J;if($.rootIndex===0)return null;let Z=M.document.blocks[$.rootIndex-1],X=M.document.blocks[$.rootIndex+1];if(!Z)return null;if($.block.plainText.length===0){let Y=lK($,Z,X);if(Y)return Y;return{kind:"splice-blocks",blocks:[],rootIndex:$.rootIndex,selection:Z.type==="paragraph"||Z.type==="heading"?$0($.rootIndex-1,"end"):Z.type==="list"?G0($.rootIndex-1,[Z.items.length-1,0],"end"):Z.type==="blockquote"?G0($.rootIndex-1,[Z.children.length-1],"end"):$0($.rootIndex-1,"end")}}if(Z.type==="paragraph")return{kind:"splice-blocks",count:2,blocks:[d({text:`${Z.plainText}${$.block.plainText}`})],rootIndex:$.rootIndex-1,selection:$0($.rootIndex-1,Z.plainText.length)};if(Z.type==="heading")return{kind:"splice-blocks",count:2,blocks:[$1({depth:Z.depth,text:`${Z.plainText}${$.block.plainText}`})],rootIndex:$.rootIndex-1,selection:$0($.rootIndex-1,Z.plainText.length)};if(Z.type==="list"){let Y=Z.items.length-1,Q=Z.items[Y];if(Q){let K=D2(Q,`${Q.plainText}${$.block.plainText}`);if(K)return{kind:"splice-blocks",count:2,blocks:[e(Z,Z.items.map((q,D)=>D===Y?K:q))],rootIndex:$.rootIndex-1,selection:G0($.rootIndex-1,[Y,0],Q.plainText.length)}}}return null}function y7($){if($.region.text.length===0)return cK($);if($.childIndex>0)return xK($);return{kind:"splice-blocks",blocks:$.quote.children,rootIndex:$.rootIndex,selection:$0($.rootIndex)}}function d6($,M,J){if($.block.type!=="heading")return null;let Z=Math.max(1,Math.min(6,$.block.depth+M));if(Z===$.block.depth)return{kind:"keep-state"};return{kind:"splice-blocks",blocks:[$1({depth:Z,text:$.block.plainText})],rootIndex:$.rootIndex,selection:$0($.rootIndex,J)}}function lK($,M,J){if($.block.type!=="paragraph"||$.block.plainText.length!==0||M.type!=="list"||J?.type!=="list"||!dK(M,J))return null;let Z=M.items.length-1;return{kind:"splice-blocks",count:3,blocks:[e(M,[...M.items,...J.items])],rootIndex:$.rootIndex-1,selection:G0($.rootIndex-1,[Z,0],"end")}}function dK($,M){return $.ordered===M.ordered&&$.start===M.start}function rK($){if($.block.type!=="heading")return null;return{kind:"splice-blocks",blocks:[d({text:$.block.plainText})],rootIndex:$.rootIndex,selection:$0($.rootIndex)}}function xK($){let J=$.quote.children[$.childIndex-1].plainText,Z=$.block.plainText,X=$.quote.children.filter((Y,Q)=>Q!==$.childIndex).map((Y,Q)=>Q===$.childIndex-1?d({text:`${J}${Z}`}):Y);return{kind:"splice-blocks",blocks:[H0({children:X})],rootIndex:$.rootIndex,selection:G0($.rootIndex,[$.childIndex-1],J.length)}}function cK($){if($.quote.children.length===1)return{kind:"splice-blocks",blocks:[d({text:""})],rootIndex:$.rootIndex,selection:$0($.rootIndex)};let M=Math.max(0,$.childIndex-1),J=$.childIndex>0?"end":0;return{kind:"splice-blocks",blocks:[H0({children:$.quote.children.filter((Z,X)=>X!==$.childIndex)})],rootIndex:$.rootIndex,selection:G0($.rootIndex,[M],J)}}function aK($,M,J,Z,X,Y){return{blocks:X===0?[d({text:""}),$]:X===Y?[$,d({text:""})]:[d({text:M}),d({text:J})],focusChildIndices:X===0?Z:[...Z.slice(0,-1),Z.at(-1)+1]}}function sK($,M,J,Z,X,Y){return{blocks:X===0?[d({text:""}),$]:X===Y?[$,d({text:""})]:[$1({depth:$.depth,text:M}),d({text:J})],focusChildIndices:X===0?Z:[...Z.slice(0,-1),Z.at(-1)+1]}}function b7($,M,J){let Z=Q2($,M),X=Math.max(2,J);if(!Z||Z.block.type!=="paragraph"||Z.block.plainText.length>0||M.anchor.regionId!==M.focus.regionId||M.anchor.offset!==0||M.focus.offset!==0)return null;return{kind:"splice-blocks",blocks:[E1({rows:Array.from({length:2},()=>x6(X))})],rootIndex:Z.rootIndex,selection:T1(Z.rootIndex,0,0)}}function r6($,M,J,Z){let X=Z<0?tK(J.table,J.rowIndex,J.cellIndex):eK(J.table,J.rowIndex,J.cellIndex);if(!X)return Z>0&&$D(J.table,J.rowIndex,J.cellIndex)?iK(J):{kind:"keep-state"};let Y=J.table.rows[X.rowIndex]?.cells[X.cellIndex];if(!Y)return{kind:"keep-state"};return{kind:"set-selection",selection:nK($,M,J.table,X.rowIndex,X.cellIndex,Math.min(M.focus.offset,Y.plainText.length))}}function w7($,M){let J=X2($,M.focus.regionId);if(!J||J.kind!=="tableCell")return null;let Z=Math.min(M.anchor.offset,M.focus.offset),X=Math.max(M.anchor.offset,M.focus.offset),Y=I2(J,Z,X,(Q)=>c4({path:Q}));return{kind:"replace-block",block:Y.block,blockId:Y.blockId,selection:Y.selection}}function T7($,M){let J=M==="left"?$.cellIndex:$.cellIndex+1;return q2($,E1({align:f7($.table.align,J,0,[null]),rows:$.table.rows.map((Z)=>p1({cells:oK(Z.cells,J,0,[R7()])}))}),T1($.rootIndex,$.rowIndex,J))}function O7($){let M=Math.max(0,...$.table.rows.map((J)=>J.cells.length));if(M<=1)return null;return q2($,E1({align:f7($.table.align,$.cellIndex,1,[]),rows:$.table.rows.map((J)=>p1({cells:J.cells.filter((Z,X)=>X!==$.cellIndex)}))}),T1($.rootIndex,$.rowIndex,Math.min($.cellIndex,M-2)))}function j7($,M){let J=M==="above"?$.rowIndex:$.rowIndex+1,Z=Math.max(1,...$.table.rows.map((X)=>X.cells.length));return q2($,u0($.table,[...$.table.rows.slice(0,J),x6(Z),...$.table.rows.slice(J)]),T1($.rootIndex,J,Math.min($.cellIndex,Z-1)))}function L7($){if($.table.rows.length<=1)return null;let M=$.table.rows.filter((X,Y)=>Y!==$.rowIndex),J=Math.min($.rowIndex,M.length-1),Z=M[J]?.cells.length??1;return q2($,u0($.table,M),T1($.rootIndex,J,Math.min($.cellIndex,Z-1)))}function C7($){return q2($,d({text:""}),$0($.rootIndex))}function x6($){return p1({cells:Array.from({length:$},()=>R7())})}function R7(){return M1({children:[]})}function iK($){let M=$.table.rows.length,J=Math.max(1,...$.table.rows.map((Z)=>Z.cells.length));return q2($,u0($.table,[...$.table.rows,x6(J)]),T1($.rootIndex,M,0))}function q2($,M,J){return{kind:"replace-block",block:M,blockId:$.table.id,selection:J}}function oK($,M,J,Z){return[...$.slice(0,M),...Z,...$.slice(M+J)]}function f7($,M,J,Z){return[...$.slice(0,M),...Z,...$.slice(M+J)]}function nK($,M,J,Z,X,Y){let Q=Y2($,J.id,Z,X);if(!Q)return M;return{anchor:{regionId:Q.id,offset:Y},focus:{regionId:Q.id,offset:Y}}}function tK($,M,J){if(J>0)return{cellIndex:J-1,rowIndex:M};if(M>0){let Z=$.rows[M-1];if(!Z||Z.cells.length===0)return null;return{cellIndex:Z.cells.length-1,rowIndex:M-1}}return null}function eK($,M,J){let Z=$.rows[M];if(!Z)return null;if(J+1<Z.cells.length)return{cellIndex:J+1,rowIndex:M};let X=$.rows[M+1];if(!X||X.cells.length===0)return null;return{cellIndex:0,rowIndex:M+1}}function $D($,M,J){let Z=$.rows[M];return Boolean(Z&&M===$.rows.length-1&&J===Z.cells.length-1)}function M4($,M){let J=N7($.documentIndex,$.selection,M),Z=o($,J);if(!Z)return null;if(J?.kind==="splice-text"&&M.length>0)Z=C6(Z,M.length);if(M===".")Z=s$(Z);return Z}function f5($){let M=t2($.documentIndex,$.selection),J=Y0($.documentIndex,$.selection).start.offset;switch(M.kind){case"code":return o($,{kind:"splice-text",selection:$.selection,text:`
|
|
25
|
+
`});case"tableCell":return o($,w7($.documentIndex,$.selection));case"listItem":{let Z=_7(M,J);return MD({state:o($,Z)??o($,p6(M,J)),action:Z})}case"blockquoteTextBlock":return o($,B7(M,J))??o($,W7(M,J));case"rootTextBlock":return o($,E7(M,J));case"unsupported":return null}}function m5($,M){let J=o($,{kind:"splice-text",selection:$.selection,text:M});return M.length>0?C6(J,M.length):J}function S5($){return m5($,"")}function c6($){if(YM($))return S5($);let M=QM($,"backward");if(M)return M;let J=Y0($.documentIndex,$.selection);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;let Z=t2($.documentIndex,$.selection);switch(Z.kind){case"listItem":return o($,F7(Z));case"blockquoteTextBlock":return o($,y7(Z));case"rootTextBlock":return o($,P7(Z,$.documentIndex));default:return null}}function a6($){if(YM($))return S5($);return QM($,"forward")}function m7($,M,J){return z0($,M,J,!0)}function S7($){let M=$.documentIndex.regions,J=M[0],Z=M.at(-1);if(!J||!Z)return $;return X0($,{anchor:{regionId:J.id,offset:0},focus:{regionId:Z.id,offset:Z.text.length}})}function k7($){let M=t2($.documentIndex,$.selection);switch(M.kind){case"tableCell":return o($,r6($.documentIndex,$.selection,M,1));case"rootTextBlock":return o($,d6(M,1,$.selection.focus.offset));case"listItem":return o($,H7(M));default:return null}}function u7($){let M=t2($.documentIndex,$.selection);switch(M.kind){case"tableCell":return o($,r6($.documentIndex,$.selection,M,-1));case"rootTextBlock":return o($,d6(M,-1,$.selection.focus.offset));case"listItem":return o($,z7(M));default:return null}}var v7=j1(K2,($,M)=>l6(M,-1)),h7=j1(K2,($,M)=>l6(M,1));function g7($,M){let J=n2($.documentIndex,M);if(!J||J.type!=="listItem"||typeof J.checked!=="boolean")return null;return o($,{kind:"replace-block",block:{...J,checked:!J.checked},blockId:M})}function I7($,M){return o($,b7($.documentIndex,$.selection,M))}var p7=j1(J4,($,M,J)=>T7(M,J)),l7=j1(J4,($,M)=>O7(M)),d7=j1(J4,($,M,J)=>j7(M,J)),r7=j1(J4,($,M)=>L7(M)),x7=j1(J4,($,M)=>C7(M));function k5($){return g5($,"bold")}function u5($){return g5($,"italic")}function v5($){return g5($,"strikethrough")}function h5($){return g5($,"underline")}function c7($){return ZM($,P6)}function a7($,M,J,Z,X){return XM($,M,J,Z,X)}function s7($,M,J,Z){return XM($,M,J,Z,null)}function i7($,M,J){return o($,R$($.documentIndex,$.selection,(Z)=>H1({alt:J??null,path:Z,url:M})))}function o7($,M,J,Z){let X=X2($.documentIndex,M);if(!X)return null;let{image:Y}=J,Q=I2(X,J.start,J.end,(K)=>H1({alt:Y.alt,path:K,title:Y.title,url:Y.url,width:Z}));return o($,{kind:"replace-block",block:Q.block,blockId:Q.blockId})}function n7($,M,J){let Z=V6($.documentIndex,M,J);if(!Z)return null;return KM($,$.documentIndex.document.comments.length,0,[Z])}function t7($,M,J){return Z4($,M,(Z)=>C8(Z,{body:J.trim()}))}function e7($,M,J,Z){return Z4($,M,(X)=>R8(X,J,Z))}function $M($,M,J){return Z4($,M,(Z)=>f8(Z,J))}function MM($,M){return Z4($,M,()=>null)}function JM($,M,J){return Z4($,M,(Z)=>m8(Z,J))}function s6($){return k6($)}function i6($){return u6($)}function j1($,M){return(J,...Z)=>{let X=$(J.documentIndex,J.selection);return X?o(J,M(J,X,...Z)):null}}function J4($,M){return h6($,M.focus.regionId)}function MD($){if(!$.state||!$.action||$.action.kind!=="replace-block"||!$.action.listItemInsertedPath)return $.state;return i$($.state,$.action.listItemInsertedPath)}function g5($,M){return ZM($,(J,Z,X)=>W6(J,Z,X,M))}function ZM($,M){let J=Y0($.documentIndex,$.selection);if(J.start.regionId!==J.end.regionId||J.start.offset===J.end.offset)return null;return o($,E5($.documentIndex,J.start.regionId,J.start.offset,J.end.offset,M))}function XM($,M,J,Z,X){return o($,y6($.documentIndex,M,J,Z,X))}function YM($){let M=Y0($.documentIndex,$.selection);return M.start.regionId!==M.end.regionId||M.start.offset!==M.end.offset}function QM($,M){let J=G7($,M);if(!J)return null;let Z=o($,J.action);if(!Z)return null;return a$($,Z,J.startOffset,J.endOffset)}function Z4($,M,J){let X=L0($.documentIndex).threads[M];if(!X)return null;let Y=J(X);if(Y===X)return null;return KM($,M,1,Y?[Y]:[])}function KM($,M,J,Z){return o($,{kind:"splice-comments",count:J,index:M,threads:Z})}var DM=1;function qM($,M,J){let Z=$.documentIndex.regionOrderIndex.get($.selection.focus.regionId);if(Z===void 0)return $;let X=$.documentIndex.regions[Z],Y=$.selection.focus.offset+M;if(Y>=0&&Y<=X.text.length)return z0($,X.id,Y,J);if(M<0){let K=$.documentIndex.regions[Z-1];if(!K)return $;return z0($,K.id,K.text.length,J)}let Q=$.documentIndex.regions[Z+1];if(!Q)return $;return z0($,Q.id,0,J)}function AM($,M,J,Z,X){let Y=L2(M,J.regionId,J.offset);if(!Y)return $;let Q=M.lines[Y.index+Z];if(!Q)return $;let K=y0(M,$,{x:I0($,M,J)+DM,y:Q.top+Q.height/2});if(!K)return $;return z0($,K.regionId,K.offset,X)}function UM($,M,J,Z){let X=GM($,M);if(!X)return $;return z0($,X.regionId,J==="Home"?X.start:X.end,Z)}function VM($,M,J,Z,X){let Y=GM($,M);if(!Y)return $;let K=Math.max(1,Math.floor(480/M.options.lineHeight)),q=L2(M,Y.regionId,$.selection.focus.offset),D=q?M.lines[q.index+Z*K]:null;if(!D)return $;let A=y0(M,$,{x:I0($,M,J)+DM,y:D.top+D.height/2});if(!A)return $;return z0($,A.regionId,A.offset,X)}function GM($,M){return j0(M,$.selection.focus.regionId,$.selection.focus.offset)}var JD=1;function NM($,M,J,Z,X){let Y=$.documentIndex.regionIndex.get($.selection.focus.regionId)??null;if(!Y)return null;let Q=$.documentIndex.tableCellIndex.get(Y.id)??null,K=$.documentIndex.blockIndex.get(Y.blockId)??null;if(!Q||K?.type!=="table")return null;let q=ZD($,K.id,Q.rowIndex+Z,Q.cellIndex)??XD($,K.id,Z);if(!q)return $;let D=M.regionBounds.get(Y.id),A=M.regionBounds.get(q.id);if(!D||!A)return $;let V=A.top+YD(J.top+J.height/2-D.top,0,Math.max(0,A.bottom-A.top-1)),U=y0(M,$,{x:I0($,M,J)+JD,y:V});if(!U)return $;return z0($,U.regionId,U.offset,X)}function ZD($,M,J,Z){return Y2($.documentIndex,M,J,Z)}function XD($,M,J){let Z=$.documentIndex.blockIndex.get(M),X=$.documentIndex.regions,Y=Z?$.documentIndex.roots[Z.rootIndex]?.regionRange:void 0;if(!Y)return null;return J<0?X[Y.start-1]??null:X[Y.end]??null}function YD($,M,J){return Math.max(M,Math.min(J,$))}function o6($,M,J=!1){return qM($,M,J)}function n6($,M,J,Z=!1){return QD($,M,J,Z)}function t6($,M,J,Z=!1){return KD($,M,J,Z)}function e6($,M,J,Z=!1){return UM($,M,J,Z)}function $3($,M,J=!1){return DD($,M,J)}function QD($,M,J,Z){let X=_M($,M);if(!X)return $;return NM($,M,X,J,Z)??AM($,M,X,J,Z)}function KD($,M,J,Z){let X=_M($,M);if(!X)return $;return VM($,M,X,J,Z)}function DD($,M,J){let Z=$.documentIndex.regions,X=M==="start"?Z[0]:Z.at(-1);if(!X)return $;return z0($,X.id,M==="start"?0:X.text.length,J)}function _M($,M){return g0(M,$.documentIndex,{regionId:$.selection.focus.regionId,offset:$.selection.focus.offset})}function HM($,M,J,Z,X,Y,Q){let K=J.image?Z.images.get(J.image.url):null,q=UD(J,Z,Q),D=VD(M,Y,Q,q);if($.fillStyle=X.imageSurfaceBackground,$.fillRect(D.left,D.top,D.width,D.height),K?.status==="loaded"&&K.source)$.drawImage(K.source,D.left,D.top,D.width,D.height);else qD($,X,{...D,status:K?.status==="error"?"error":"loading"});$.strokeStyle=X.imageSurfaceBorder,$.strokeRect(D.left,D.top,D.width,D.height)}function qD($,M,J){let Z=J.status==="loading"?"Loading image":"Image unavailable",X=GD(J),Y=J.top+J.height/2+X.size*0.9;if($.save(),$.beginPath(),$.rect(J.left,J.top,J.width,J.height),$.clip(),J.status==="loading")AD($,M,J);$.strokeStyle=M.imagePlaceholderIcon,$.lineWidth=1.5,$.strokeRect(X.left,X.top,X.size,X.size),$.beginPath(),$.arc(X.left+X.size*0.28,X.top+X.size*0.3,X.size*0.1,0,Math.PI*2),$.moveTo(X.left+X.size*0.12,X.top+X.size*0.82),$.lineTo(X.left+X.size*0.42,X.top+X.size*0.5),$.lineTo(X.left+X.size*0.58,X.top+X.size*0.66),$.lineTo(X.left+X.size*0.78,X.top+X.size*0.38),$.lineTo(X.left+X.size*0.88,X.top+X.size*0.82),$.stroke(),$.font='500 12px "Iowan Old Style", "Palatino Linotype", serif',$.fillStyle=M.imagePlaceholderText,$.textAlign="center",$.textBaseline="middle",$.fillText(Z,J.left+J.width/2,Y),$.restore()}function AD($,M,J){let Z=Math.max(48,Math.round(J.width*0.22)),X=J.width+Z*2,Y=performance.now()%1800/1800,Q=J.left-Z+X*Y,K=$.createLinearGradient(Q,J.top,Q+Z,J.top);K.addColorStop(0,"rgba(255,255,255,0)"),K.addColorStop(0.5,M.imageLoadingOverlay),K.addColorStop(1,"rgba(255,255,255,0)"),$.fillStyle=K,$.fillRect(J.left,J.top,J.width,J.height)}function UD($,M,J){if(!$.image)return FM(J);let Z=M.images.get($.image.url);if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return FM(J);return Math.max(48,Math.round(J*(Z.intrinsicHeight/Z.intrinsicWidth)))}function VD($,M,J,Z){return{height:Z,left:M,top:$.top+Math.max(0,Math.floor(($.height-Z)/2)),width:J}}function GD($){let M=Math.max(18,Math.min(34,Math.round(Math.min($.width,$.height)*0.18)));return{left:$.left+Math.max(12,Math.round(($.width-M)/2)),size:M,top:$.top+Math.max(12,Math.round($.height/2-M*0.95))}}function FM($){return Math.max(48,Math.round($*0.5625))}var zM=2,EM=8,ND=3,_D=1.5,FD=2,A2={elbow:{x:6.5,y:10.5},end:{x:11.5,y:3.5},start:{x:3.5,y:7.5}};function WM($,M,J,Z,X,Y,Q=null){if(!J||M.start!==0)return;if(Q){let K=x$(Q),q=BD(J,M,Z,X,$);$.save(),$.translate(q.x,q.y),$.scale(K,K),$.translate(-q.x,-q.y)}if(J.kind==="task")HD($,M,J.checked,Y,Q);else if($.fillStyle=Q?r2(Y.listMarkerText,Q,Y):Y.listMarkerText,J.kind==="ordered")WD($,J.label,Z,X);else $.fillText(J.label,M.left-zM,X);if(Q)$.restore()}function HD($,M,J,Z,X=null){let Y=R2(M);if(zD($,Y,J,Z,X),!J)return;ED($,Y,Z,X)}function zD($,M,J,Z,X=null){let Y=J?Z.checkboxCheckedFill:Z.checkboxUncheckedFill,Q=J?Z.checkboxCheckedStroke:Z.checkboxUncheckedStroke;$.fillStyle=X?r2(Y,X,Z):Y,$.strokeStyle=X?r2(Q,X,Z):Q,$.beginPath(),$.lineWidth=_D,$.roundRect(M.left,M.top,M.size,M.size,ND),$.fill(),$.stroke()}function ED($,M,J,Z=null){$.strokeStyle=Z?r2(J.checkboxCheckmark,Z,J):J.checkboxCheckmark,$.lineWidth=FD,$.beginPath(),$.moveTo(M.left+A2.start.x,M.top+A2.start.y),$.lineTo(M.left+A2.elbow.x,M.top+A2.elbow.y),$.lineTo(M.left+A2.end.x,M.top+A2.end.y),$.stroke()}function WD($,M,J,Z){let X=$.textAlign;$.textAlign="right",$.fillText(M,J-EM,Z),$.textAlign=X}function BD($,M,J,Z,X){if($.kind==="task"){let K=R2(M);return{x:K.left+K.size/2,y:K.top+K.size/2}}let Y=X.measureText($.label),Q=Z-(Y.actualBoundingBoxAscent-Y.actualBoundingBoxDescent)/2;if($.kind==="ordered")return{x:J-EM-Y.width/2,y:Q};return{x:M.left-zM+Y.width/2,y:Q}}var PD=80;function PM({context:$,containerBounds:M,isHeaderRow:J,lineHeight:Z,theme:X}){let Y=bM(M,Z);$.fillStyle=J?X.tableHeaderBackground:X.tableBodyBackground,$.fillRect(Y.left,Y.top,Y.width,Y.height),wM($,Y,X)}function yM({activeBlockFlashes:$,activeBlockId:M,activeRegionId:J,context:Z,editorState:X,endIndex:Y,layout:Q,regionBounds:K,startIndex:q,theme:D,verticalBleed:A}){if(!M||!J)return;let V=X.documentIndex.blockIndex.get(M)??null;if(V?.type!=="table")return;if((X.documentIndex.regionIndex.get(J)??null)?.blockId!==M)return;let G=K.get(J)??null,_=Q.regionLineIndices.get(J)??null;if(!G||!_||_.length===0)return;let N=Q.lines[_[0]]??null;if(!N)return;let H=bM(G,N.height);if(H.width===0)return;let E=BM({context:Z,endIndex:Y,fillStyle:D.activeBlockBackground,layout:Q,left:H.left,lineIndices:_,startIndex:q,verticalBleed:A,width:H.width}),L=V.path?$.get(V.path)??null:null;if(L)BM({context:Z,endIndex:Y,fillStyle:b5(D.activeBlockFlash,L),layout:Q,left:H.left,lineIndices:_,startIndex:q,verticalBleed:A,width:H.width});if(!E)return;wM(Z,H,D)}function BM({context:$,endIndex:M,fillStyle:J,layout:Z,left:X,lineIndices:Y,startIndex:Q,verticalBleed:K,width:q}){$.fillStyle=J;let D=!1;for(let A of Y){if(A<Q)continue;if(A>=M)break;let V=Z.lines[A];$.fillRect(X,V.top-K,q,V.height),D=!0}return D}function bM($,M){return{height:Math.max($.bottom-$.top,M),left:$.left,top:$.top,width:Math.max($.right-$.left,PD)}}function wM($,M,J){$.strokeStyle=J.tableBorder,$.strokeRect(M.left,M.top,M.width,M.height)}var M3=2,yD=3,bD=12,wD=6,TD=3,OD=1,jD=2,LD=2,CD=8,RD=12,fD=28,mD=4,SD=5,kD=2,uD=3,vD=6,TM=3,hD=12,gD=10,ID=2,pD=2,lD=1,dD=2,J3=2,OM=1.25,rD=5,xD=1,jM=4,cD=4,aD=1.5;function sD({activeBlockId:$,activeRegionId:M,activeThreadIndex:J,containerLineBounds:Z,context:X,devicePixelRatio:Y,editorState:Q,height:K,layout:q,liveCommentRanges:D,normalizedSelection:A,now:V=Eq(),resources:U,runtimeBlockMap:G,theme:_,viewportTop:N,width:H}){X.save(),X.scale(Y,Y),X.clearRect(0,0,H,K),X.fillStyle=_.background,X.fillRect(0,0,H,K),X.textBaseline="alphabetic",X.translate(0,-N);let E=iD(Q,A),{endIndex:L,startIndex:W}=n8(q,N,K),R=u$(Q,V),f=v$(Q,V),I=k$(Q,V),B=g$(Q,V),b=h$(Q,V),z=nD(q,Q,$,W,L),T=oD(q,Q,G,W,L,H);for(let P=W;P<L;P+=1){let y=q.lines[P];Mq({containerLineBounds:Z,context:X,editorState:Q,line:y,runtimeBlockMap:G,theme:_,width:H})}yM({activeBlockFlashes:R,activeBlockId:$,activeRegionId:M,context:X,editorState:Q,endIndex:L,layout:q,regionBounds:Z,startIndex:W,theme:_,verticalBleed:M3});for(let P=W;P<L;P+=1){let y=q.lines[P];Jq({activeBlockId:$,activeBlockFlashes:R,activeDeletedTextFades:f,activeThreadIndex:J,activeInsertedTextHighlights:I,activeListMarkerPops:B,activePunctuationPulses:b,context:X,editorState:Q,line:y,liveCommentRanges:D,normalizedSelection:A,resources:U,runtimeBlockMap:G,selectionRegionOrderRange:E,theme:_,width:H})}tD(X,T,_),eD(X,z,_),X.restore()}function iD($,M){let J=$.documentIndex.regionOrderIndex,Z=J.get(M.start.regionId),X=J.get(M.end.regionId);return Z===void 0||X===void 0?null:{end:X,start:Z}}function oD($,M,J,Z,X,Y){let Q=new Map;for(let K=Z;K<X;K+=1){let q=$.lines[K],D=J.get(q.blockId);if(D?.type!=="heading"||D.depth!==1&&D.depth!==2)continue;let A=Q.get(D.id),V={bottom:q.top+q.height,left:q.left+h0(M,q),right:Y-$.options.paddingX};Q.set(D.id,A?{bottom:Math.max(A.bottom,V.bottom),left:A.left,right:A.right}:V)}return Q}function nD($,M,J,Z,X){let Y=new Map;for(let Q=Z;Q<X;Q+=1){let K=$.lines[Q],q=$2(M,K.blockId,"blockquote");if(!q)continue;let D=Y.get(q.id),A={bottom:K.top+K.height,isActive:K.blockId===J,left:$.options.paddingX+(q.depth+1)*$.options.indentWidth-10,top:K.top};Y.set(q.id,D?{bottom:Math.max(D.bottom,A.bottom),isActive:D.isActive||A.isActive,left:D.left,top:Math.min(D.top,A.top)}:A)}return Y}function tD($,M,J){$.fillStyle=J.headingRule;for(let Z of M.values())$.fillRect(Z.left,Z.bottom+rD,Math.max(J3,Z.right-Z.left),xD)}function eD($,M,J){for(let Z of M.values())$.fillStyle=Z.isActive?J.blockquoteRuleActive:J.blockquoteRule,$.fillRect(Z.left,Z.top+yD,TD,Math.max(bD,Z.bottom-Z.top-wD))}function $q({context:$,devicePixelRatio:M,editorState:J,height:Z,layout:X,normalizedSelection:Y,presence:Q,showCaret:K,theme:q,viewportTop:D,width:A}){$.save(),$.scale(M,M),$.clearRect(0,0,A,Z);let V=Y.start.regionId===Y.end.regionId&&Y.start.offset!==Y.end.offset,U=K&&!V;if($.translate(0,-D),U)LM($,J,X,{color:q.caret,offset:J.selection.focus.offset,regionId:J.selection.focus.regionId});if(Q)for(let G of Q){if(!G.cursorPoint)continue;LM($,J,X,{color:G.color??q.leafAccent,offset:G.cursorPoint.offset,regionId:G.cursorPoint.regionId})}$.restore()}function LM($,M,J,Z){let X=g0(J,M.documentIndex,{regionId:Z.regionId,offset:Z.offset});if(!X)return;let Y=I0(M,J,X),Q=Aq(J,X);$.fillStyle=Z.color,$.fillRect(Y,Q.top,jD,Q.height)}function Mq({containerLineBounds:$,context:M,editorState:J,line:Z,runtimeBlockMap:X,theme:Y,width:Q}){let K=X.get(Z.blockId)??null,q=$.get(Z.regionId)??null,D=J.documentIndex.tableCellIndex.get(Z.regionId)??null;Zq(M,Z,K,q,D,Y,Q)}function Jq({activeBlockId:$,activeBlockFlashes:M,activeDeletedTextFades:J,activeThreadIndex:Z,activeInsertedTextHighlights:X,activeListMarkerPops:Y,activePunctuationPulses:Q,context:K,editorState:q,line:D,liveCommentRanges:A,normalizedSelection:V,resources:U,runtimeBlockMap:G,selectionRegionOrderRange:_,theme:N,width:H}){let E=G.get(D.blockId)??null,L=q.documentIndex.blockIndex.get(D.blockId)?.path??null,W=q.documentIndex.regionIndex.get(D.regionId)??null,R=W?.path??"",f=$2(q,D.blockId,"listItem"),I=f?f2(q,f.id):null,B=f?Y.get(f.path)??null:null,b=D.left+h0(q,D),z=Gq(D),T=E?.type==="code"?N.codeText:Fq(E,N);K.font=D.font,Xq(K,D,E,L,$,M,N,H),Yq(K,q,D,V,_,N),Qq(K,q,D,A,Z,N),WM(K,D,I,b,z,N,B),Kq(K,D,W,b,z,X.get(R)??[],T,U,N),Dq(K,D,W,b,z,J.get(R)??[],T),qq(K,D,W,b,z,Q.get(R)??[],N)}function Zq($,M,J,Z,X,Y,Q){if(!Z||M.start!==0)return;if(J?.type==="code"){let K=Math.max(0,M.left-RD);$.fillStyle=Y.codeBackground,$.fillRect(K,Z.top-mD,Math.max(Z.right-M.left+fD,Q-K),Z.bottom-Z.top+CD);return}if(J?.type!=="table")return;PM({context:$,containerBounds:Z,isHeaderRow:X?.rowIndex===0,lineHeight:M.height,theme:Y})}function Xq($,M,J,Z,X,Y,Q,K){if(M.blockId!==X||J?.type==="table")return;let q=Z?Y.get(Z)??null:null;if($.fillStyle=Q.activeBlockBackground,$.fillRect(0,M.top-M3,K,M.height),!q)return;$.fillStyle=b5(Q.activeBlockFlash,q),$.fillRect(0,M.top-M3,K,M.height)}function Yq($,M,J,Z,X,Y){if(!X)return;let Q=M.documentIndex.regionOrderIndex.get(J.regionId);if(Q===void 0||Q<X.start||Q>X.end)return;let K=Q===X.start?Math.max(J.start,Z.start.offset):J.start,q=Q===X.end?Math.min(J.end,Z.end.offset):J.end;if(q<=K)return;$.fillStyle=Y.selectionBackground,$.fillRect(Q1(M,J,K-J.start),J.top+lD,Math.max(pD,Q1(M,J,q-J.start)-Q1(M,J,K-J.start)),J.height-dD)}function Qq($,M,J,Z,X,Y){for(let Q of Z){if(Q.regionId!==J.regionId)continue;let K=Math.max(Q.startOffset,J.start),q=Math.min(Q.endOffset,J.end);if(q<=K)continue;$.fillStyle=zq(Q,X,Y),$.fillRect(Q1(M,J,K-J.start),J.top+J.height-SD,Math.max(kD,Q1(M,J,q-J.start)-Q1(M,J,K-J.start)),uD)}}function Kq($,M,J,Z,X,Y,Q,K,q){if(!J){$.fillStyle=Q,$.fillText(M.text,Z,X);return}let D=J.inlines.filter((A)=>A.end>M.start&&A.start<M.end);if(D.length===0){$.fillStyle=Q,$.fillText(M.text,Z,X);return}for(let A of D){let V=Math.max(M.start,A.start),U=Math.min(M.end,A.end);if(J.text.slice(V,U).length===0)continue;let{left:_,right:N}=X3(M,Z,V,U),H=Hq(M.font,A.marks);if($.font=H,A.kind==="image"){let E=Math.max(24,N-_);HM($,M,A,K,q,_,E);continue}if(A.kind==="inlineCode"){let E=Nq(M,H),L=_q(M,H);$.fillStyle=q.inlineCodeBackground,$.fillRect(_-TM,E,Math.max(gD,N-_+TM*2),L),CM($,M,J.text,Z,X,V,U,q.inlineCodeText,Y,q,{strikethrough:!1,underline:!1});continue}CM($,M,J.text,Z,X,V,U,A.link?q.linkText:Q,Y,q,{strikethrough:A.marks.includes("strikethrough"),underline:A.marks.includes("underline")||Boolean(A.link)})}}function CM($,M,J,Z,X,Y,Q,K,q,D,A){let V=I$(Y,Q,q);for(let U=0;U<V.length-1;U+=1){let G=V[U],_=V[U+1];if(_<=G)continue;let N=J.slice(G,_);if(N.length===0)continue;let{left:H,right:E}=X3(M,Z,G,_),L=p$(q,G,_),W=l$(K,L,D);if($.fillStyle=W,$.fillText(N,H,X),A.strikethrough)$.fillRect(H,Vq(X,M.height,$.font),Math.max(J3,E-H),OM);if(A.underline)$.fillRect(H,Uq(X,M.height,$.font),Math.max(J3,E-H),OM)}}function Dq($,M,J,Z,X,Y,Q){if(!J||Y.length===0)return;for(let K of Y){if(K.startOffset<M.start||K.startOffset>M.end)continue;let q=Z+(W0(M,K.startOffset-M.start)-M.left);$.fillStyle=d$(Q,K),$.fillText(K.text,q,X)}}function qq($,M,J,Z,X,Y,Q){if(!J||Y.length===0)return;for(let K of Y){if(K.offset<M.start||K.offset>=M.end)continue;let{left:q,right:D}=X3(M,Z,K.offset,K.offset+1),A=Math.max(jM,(D-q)/2+jM+cD*K.progress),{ascent:V,descent:U}=Y1(M.font),G=X-Math.max(1,V*0.42)+Math.max(0.5,U*0.15);$.strokeStyle=r$(K,Q),$.lineWidth=aD,$.beginPath(),$.arc((q+D)/2,G,A,0,Math.PI*2),$.stroke()}}function Aq($,M){let J=j0($,M.regionId,M.offset),Z=J?.font??'16px "Iowan Old Style", "Palatino Linotype", serif',{ascent:X,descent:Y}=Y1(Z),Q=Math.max(1,X+Y),K=Math.min(M.height-LD,Q),q=J?Math.max(J.top,J.top+Z3(J.height,Z)-OD):M.top+Math.max(0,Math.floor((M.height-K)/2));return{height:K,top:q}}function Uq($,M,J){let{descent:Z}=Y1(J),X=Math.max(1,Math.round(Math.max(2,Z)*0.35)),Y=$+Z-X,Q=$-I5(M,J);return Math.min(Q+M-4,Y)}function Vq($,M,J){let{ascent:Z}=Y1(J),X=$-I5(M,J);return Math.max(X+2,$-Math.round(Z*0.32))}function Gq($){return $.top+I5($.height,$.font)}function I5($,M){return N$($,M)}function Nq($,M){let J=Z3($.height,M);return $.top+J+ID}function _q($,M){let J=Z3($.height,M);return Math.max(hD,$.height-J-vD)}function Z3($,M){let{ascent:J}=Y1(M);return I5($,M)-J}function Fq($,M){switch($?.type){case"heading":return M.headingText;case"blockquote":return M.blockquoteText;case"table":return M.headingText;default:return M.paragraphText}}function X3($,M,J,Z){return{left:M+(W0($,J-$.start)-$.left),right:M+(W0($,Z-$.start)-$.left)}}function Hq($,M){let J=[];if(M.includes("italic"))J.push("italic");if(M.includes("bold"))J.push("700");return J.length>0?`${J.join(" ")} ${$}`:$}function zq($,M,J){if($.resolved)return $.threadIndex===M?J.commentHighlightResolvedActive:J.commentHighlightResolved;return $.threadIndex===M?J.commentHighlightActive:J.commentHighlight}function Eq(){return typeof performance<"u"?performance.now():Date.now()}function Y3($,M,J,Z){sD({activeBlockId:Z.activeBlockId,activeRegionId:Z.activeRegionId,activeThreadIndex:Z.activeThreadIndex,containerLineBounds:M.regionBounds,context:J,devicePixelRatio:Z.devicePixelRatio,editorState:$,height:Z.height,layout:M.layout,liveCommentRanges:Z.liveCommentRanges,normalizedSelection:Z.normalizedSelection,now:Z.now,resources:Z.resources??{images:new Map},runtimeBlockMap:M.blockMap,theme:Z.theme,viewportTop:M.paintTop,width:Z.width})}function Q3($,M,J,Z){$q({context:J,devicePixelRatio:Z.devicePixelRatio,editorState:$,height:Z.height,layout:M.layout,normalizedSelection:Z.normalizedSelection,presence:Z.presence,showCaret:Z.showCaret,theme:Z.theme,viewportTop:M.paintTop,width:Z.width})}import{forwardRef as bq,createElement as wq}from"react";var p5=(...$)=>$.filter((M,J,Z)=>{return Boolean(M)&&M.trim()!==""&&Z.indexOf(M)===J}).join(" ").trim();var RM=($)=>$.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var fM=($)=>$.replace(/^([A-Z])|[\s-_]+(\w)/g,(M,J,Z)=>Z?Z.toUpperCase():J.toLowerCase());var K3=($)=>{let M=fM($);return M.charAt(0).toUpperCase()+M.slice(1)};import{forwardRef as yq,createElement as kM}from"react";var l5={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var mM=($)=>{for(let M in $)if(M.startsWith("aria-")||M==="role"||M==="title")return!0;return!1};import{createContext as Wq,useContext as Bq,useMemo as eH,createElement as $z}from"react";var Pq=Wq({});var SM=()=>Bq(Pq);var uM=yq(({color:$,size:M,strokeWidth:J,absoluteStrokeWidth:Z,className:X="",children:Y,iconNode:Q,...K},q)=>{let{size:D=24,strokeWidth:A=2,absoluteStrokeWidth:V=!1,color:U="currentColor",className:G=""}=SM()??{},_=Z??V?Number(J??A)*24/Number(M??D):J??A;return kM("svg",{ref:q,...l5,width:M??D??l5.width,height:M??D??l5.height,stroke:$??U,strokeWidth:_,className:p5("lucide",G,X),...!Y&&!mM(K)&&{"aria-hidden":"true"},...K},[...Q.map(([N,H])=>kM(N,H)),...Array.isArray(Y)?Y:[Y]])});var u=($,M)=>{let J=bq(({className:Z,...X},Y)=>wq(uM,{ref:Y,iconNode:M,className:p5(`lucide-${RM(K3($))}`,`lucide-${$}`,Z),...X}));return J.displayName=K3($),J};var Tq=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],q1=u("columns-2",Tq);var Oq=[["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"}]],A1=u("rows-3",Oq);var jq=[["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"}]],U1=u("send-horizontal",jq);var Lq=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],X4=u("arrow-down",Lq);var Cq=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Y4=u("arrow-up",Cq);var Rq=[["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"}]],Q4=u("bold",Rq);var fq=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],L1=u("check",fq);var mq=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],K4=u("chevron-down",mq);var Sq=[["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"}]],D4=u("heading-1",Sq);var kq=[["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"}]],q4=u("heading-2",kq);var uq=[["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"}]],A4=u("heading-3",uq);var vq=[["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"}]],U4=u("heading-4",vq);var hq=[["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"}]],V4=u("heading-5",hq);var gq=[["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"}]],G4=u("heading-6",gq);var Iq=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],N4=u("heading",Iq);var pq=[["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"}]],_4=u("italic",pq);var lq=[["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"}]],F4=u("list-ordered",lq);var dq=[["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"}]],H4=u("list-todo",dq);var rq=[["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"}]],z4=u("list",rq);var xq=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],E4=u("message-square-plus",xq);var cq=[["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"}]],C1=u("pencil",cq);var aq=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],U2=u("plus",aq);var sq=[["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"}]],W4=u("strikethrough",sq);var iq=[["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"}]],V1=u("table-2",iq);var oq=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],B4=u("text-quote",oq);var nq=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],w0=u("trash-2",nq);var tq=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],P4=u("underline",tq);var eq=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],y4=u("x",eq);import{jsx as V2,jsxs as ZA}from"react/jsx-runtime";function vM({insetX:$,insetY:M,onSelect:J,presence:Z}){if(!Z)return null;return V2("div",{"aria-label":"Presence",className:"documint-presence-indicators",style:{paddingRight:`${$}px`,top:`${M}px`},children:Z.map((X)=>V2($A,{onSelect:()=>J(X),presence:X},X.id))})}function $A({onSelect:$,presence:M}){let J=M.viewport,Z=MA(M),X=J?.status==="above"?Y4:X4,Y=J!==null&&J.status!=="unresolved",Q=J?.status==="above"||J?.status==="below";return ZA("button",{"aria-label":JA(M),className:"documint-presence-indicator","data-status":J?.status??"unresolved",disabled:!Y,onClick:Y?$:void 0,style:{"--documint-presence-color":M.color??"var(--documint-leaf-accent)"},type:"button",children:[V2("span",{className:"documint-presence-indicator-avatar",children:M.avatarUrl?V2("img",{alt:"","aria-hidden":"true",className:"documint-presence-indicator-image",draggable:!1,src:M.avatarUrl}):Z}),Q?V2("span",{className:"documint-presence-indicator-direction","aria-hidden":"true",children:V2(X,{className:"documint-presence-indicator-arrow",size:14,strokeWidth:2.3})}):null]})}function MA($){return hM($).charAt(0).toLocaleUpperCase()}function JA($){let M=hM($),J=$.viewport?.status??"unresolved";if(J==="above")return`${M} above viewport`;if(J==="below")return`${M} below viewport`;if(J==="unresolved")return`${M} unresolved`;return`${M} in viewport`}function hM($){return($.fullName??$.username).trim()||"Presence"}var i=`
|
|
26
|
+
`,G1="<ins>",b4="</ins>",G2=">",w4="```",d5=":::",D3=/^:::([A-Za-z][-\w]*)(.*)$/,r5="documint-comments";var x5="`",V3="\\",A3="![",U3="[",lM="(",gM=")",dM=" ",rM=":",XA=/[A-Za-z]/,YA=/[-A-Za-z0-9_]/,QA=/^\{width=([1-9]\d*)\}/,KA=/\\([\\`*_[\]{}()#+\-.!~|])/g,xM=/\\(.)/g,DA=[{delimiter:"**",mark:"bold"},{delimiter:"~~",mark:"strikethrough"},{delimiter:"*",mark:"italic"}];function N2($,M=[]){return G3($,0,$.length,M)}function G3($,M,J,Z){let X=[],Y=M,Q=M;while(Y<J){let K=qA($,Y,J,Z);if(K){IM(X,$.slice(Q,Y),Z),X.push(...K.nodes),Y=K.end,Q=Y;continue}if($[Y]===V3){Y+=Math.min(2,J-Y);continue}Y+=1}return IM(X,$.slice(Q,J),Z),AA(X)}function qA($,M,J,Z){switch($[M]){case rM:return BA($,M,J);case"<":return EA($,M,J,Z);case x5:return _A($,M,J);case"!":return FA($,M,J);case U3:return HA($,M,J,Z);case"*":case"~":return VA($,M,J,Z);default:return null}}function IM($,M,J){if(M.length===0)return;$.push(E0({marks:J,text:oM(M)}))}function N3($,M){return a4({originalType:$,source:M})}function AA($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&GA(Z.marks,J.marks)){M[M.length-1]=E0({marks:Z.marks,text:Z.text+J.text});continue}M.push(J)}return M}function UA($,M,J){for(let Z of DA){if(!$.startsWith(Z.delimiter,M))continue;let X=$.indexOf(Z.delimiter,M+Z.delimiter.length);if(X<0||X>=J)continue;return{contentEnd:X,contentStart:M+Z.delimiter.length,end:X+Z.delimiter.length,mark:Z.mark}}return null}function VA($,M,J,Z){let X=UA($,M,J);if(!X)return null;return{end:X.end,nodes:G3($,X.contentStart,X.contentEnd,[...Z,X.mark])}}function GA($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function NA($,M,J){if($[M]!==x5)return null;let Z=1;while(M+Z<J&&$[M+Z]===x5)Z+=1;let X=x5.repeat(Z),Y=$.indexOf(X,M+Z);if(Y<0||Y>=J)return null;return{end:Y+Z,value:$.slice(M+Z,Y)}}function _A($,M,J){let Z=NA($,M,J);if(!Z)return null;return{end:Z.end,nodes:[g1({code:Z.value})]}}function FA($,M,J){if(!$.startsWith(A3,M))return null;let Z=aM($,M+1,J);if(Z<0||$[Z+1]!==lM)return null;let X=cM($,Z+1,J);if(!X)return null;let Y=zA($,X.end,J);return{end:Y?.end??X.end,nodes:[H1({alt:oM($.slice(M+A3.length,Z)),title:X.title,url:X.url,width:Y?.width??null})]}}function HA($,M,J,Z){if($[M]!==U3||$.startsWith(A3,M-1))return null;let X=aM($,M,J);if(X<0||$[X+1]!==lM)return null;let Y=cM($,X+1,J);if(!Y)return null;return{end:Y.end,nodes:[I1({children:N2($.slice(M+U3.length,X),Z),title:Y.title,url:Y.url})]}}function cM($,M,J){let Z=q3($,M+1,J),X=Z;while(X<J&&$[X]!==gM&&$[X]!==dM){if($[X]===V3){X+=2;continue}X+=1}if(X===Z)return null;let Y=PA($.slice(Z,X));Z=q3($,X,J);let Q=null;if(Z<J&&$[Z]==='"'){let K=iM($,'"',Z+1,J);if(K<0)return null;Q=$.slice(Z+1,K).replace(xM,"$1"),Z=q3($,K+1,J)}if($[Z]!==gM)return null;return{end:Z+1,title:Q,url:Y}}function zA($,M,J){let Z=QA.exec($.slice(M,J));if(!Z)return null;return{end:M+Z[0].length,width:Number(Z[1])}}function EA($,M,J,Z){if(!$.startsWith(G1,M))return WA($,M,J);let X=$.indexOf(b4,M+G1.length);if(X<0||X>=J)return{end:M+G1.length,nodes:[N3("html",G1)]};return{end:X+b4.length,nodes:G3($,M+G1.length,X,[...Z,"underline"])}}function WA($,M,J){if($[M]!=="<")return null;let Z=$.indexOf(">",M+1);if(Z<0||Z>=J)return null;return{end:Z+1,nodes:[N3("html",$.slice(M,Z+1))]}}function BA($,M,J){if($[M]!==rM||!XA.test($[M+1]??""))return null;let Z=M+2;while(Z<J&&YA.test($[Z]??""))Z+=1;let X=pM($,Z,J,"[","]"),Q=pM($,X?.end??Z,J,"{","}")?.end??X?.end??Z;return{end:Q,nodes:[N3("textDirective",$.slice(M,Q))]}}function pM($,M,J,Z,X){if($[M]!==Z)return null;let Y=sM($,X,M+1,J);if(Y<0)return null;return{end:Y+1}}function aM($,M,J){return sM($,"]",M+1,J)}function sM($,M,J,Z){return iM($,M,J,Z)}function iM($,M,J,Z){for(let X=J;X<Z;X+=1){if($[X]===V3){X+=1;continue}if($[X]===M)return X}return-1}function q3($,M,J){while(M<J&&$[M]===dM)M+=1;return M}function oM($){return $.replace(KA,"$1")}function PA($){return $.replace(xM,"$1")}var yA=/^:?-+:?$/;function eM($,M){let J=tM($),Z=$.lines[$.index+1]??"",X=_3(J,M),Y=_3(Z,M);if(!nM(X)||!F3(Y))return null;let Q=[c5(X)],K=bA(Y);$.index+=2;while($.index<$.lines.length){let q=tM($),D=_3(q,M);if(wA(q)||!nM(D))break;Q.push(c5(D)),$.index+=1}return E1({align:K,rows:Q.map((q)=>p1({cells:q.map((D)=>M1({children:N2(D)}))}))})}function nM($){let M=$.trim();return/\|/.test($)&&M.startsWith("|")&&M.endsWith("|")}function F3($){let M=c5($);return M.length>0&&M.every((J)=>yA.test(J.trim()))}function bA($){return c5($).map((M)=>{let J=M.trim();if(J.startsWith(":")&&J.endsWith(":"))return"center";if(J.startsWith(":"))return"left";if(J.endsWith(":"))return"right";return null})}function c5($){return $.trim().slice(1,-1).split("|").map((J)=>J.trim())}function tM($){return $.lines[$.index]??""}function wA($){return $.trim()===""}function _3($,M){return $.slice(M)}var TA=3,OA=/^\d+\.$/,jA=/^\[( |x|X)\](?:\s|$)/,$J=/^```([^\s`]*)?(?:\s+(.*))?$/,MJ=/^::(?!:)[A-Za-z][-\w]*/,JJ=/^(#{1,6})\s+(.*)$/,LA=/\s+#+\s*$/u,CA=/^(\s*)([-+*]|\d+\.)(?:\s+(.*)|\s*)$/,RA=/^(\*\s*){3,}$/,fA=/^(-\s*){3,}$/,mA=/^(_\s*){3,}$/;function s5($,M,J){let Z=[];while($.index<$.lines.length){let X=N0($);if($.index===$.lines.length-1&&X==="")break;if(T4(X)){$.index+=1;continue}if(_2(X)>M+TA)break;let Q=SA($,M,J);if(!Q)break;Z.push(Q)}return Z}function SA($,M,J){return kA($,M,J)??uA($,M)??vA($,M)??gA($,M)??IA($,M)??pA($,M)??eM($,M)??lA($,M,J)??dA($,M)??rA($,M)}function kA($,M,J){let Z=N0($);if(!cA(Z,M))return null;let X=[];while($.index<$.lines.length){let Y=N0($),Q=_2(Y);if(T4(Y)){X.push(""),$.index+=1;continue}if(Q<M)break;let K=C0(Y,M);if(!K.startsWith(G2))break;let q=K.slice(1);if(q.startsWith(" "))q=q.slice(1);X.push(q),$.index+=1}return H0({children:s5({index:0,lines:X},0,J)})}function uA($,M){let J=N0($),Z=C0(J,M),X=$J.exec(Z);if(!X)return null;$.index+=1;let Y=[];while($.index<$.lines.length){let Q=N0($),K=C0(Q,M);if(K.trim()===w4){$.index+=1;break}Y.push(K),$.index+=1}return N8({language:X[1]?X[1]:null,meta:X[2]?X[2]:null,source:Y.join(i)})}function vA($,M){let J=N0($),Z=C0(J,M),X=D3.exec(Z);if(!X)return null;let Y=X[1],Q=[];$.index+=1;while($.index<$.lines.length){let K=N0($),q=C0(K,M);if($.index+=1,q.trim()===d5)break;Q.push(q)}return q9({attributes:hA(X[2]??""),body:Q.join(i),name:Y})}function hA($){let M=$.trim();if(M.startsWith("{")&&M.endsWith("}"))return M.slice(1,-1);return M}function gA($,M){let J=N0($),Z=C0(J,M);if(!MJ.test(Z))return null;return $.index+=1,i4({originalType:"leafDirective",source:Z})}function IA($,M){let J=N0($),Z=JJ.exec(C0(J,M));if(!Z)return null;return $.index+=1,x4({children:N2(Z[2].replace(LA,"")),depth:Z[1].length})}function pA($,M){let J=C0(N0($),M).trim();if(!ZJ(J))return null;return $.index+=1,s4()}function lA($,M,J){let Z=a5(N0($),M);if(!Z)return null;let X=[],Y=!1;while($.index<$.lines.length){let Q=N0($),K=a5(Q,M);if(!K||K.ordered!==Z.ordered)break;$.index+=1;let q=[K.content],D=!1;while($.index<$.lines.length){let A=N0($),V=_2(A);if(T4(A)){let U=iA($.lines,$.index+1);if(U<0||_2($.lines[U]??"")<=M)break;D=!0,q.push(""),$.index+=1;continue}if(V<K.contentIndent)break;if(V===M&&a5(A,M))break;q.push(aA(A,K.contentIndent)),$.index+=1}Y||=D,X.push(a0({checked:K.checked,children:xA(q,J),spread:D}))}return z1({items:X,ordered:Z.ordered,spread:Y,start:Z.ordered&&J.preserveOrderedListStart?Z.start??1:null})}function dA($,M){let J=C0(N0($),M).trim();if(!XJ(J))return null;return $.index+=1,i4({originalType:"html",source:J})}function rA($,M){let J=[];while($.index<$.lines.length){let Z=N0($),X=_2(Z);if(T4(Z))break;if(X<M)break;let Y=C0(Z,M);if(J.length>0&&sA(Z,Y,M))break;J.push(Y),$.index+=1}return B2({children:N2(J.join(i))})}function xA($,M){let J=s5({index:0,lines:$},0,M);if(J.length>0)return J;return[B2({children:[]})]}function a5($,M){let J=CA.exec($);if(!J||J[1].length!==M)return null;let Z=J[2],X=OA.test(Z),Y=X?Number(Z.slice(0,-1)):null,Q=J[3]??"",K=null;if(jA.test(Q)){if(K=Q[1]==="x"||Q[1]==="X",Q=Q.slice(3),Q.startsWith(" "))Q=Q.slice(1)}let q=Q.length>0?J[0].length-J[1].length-J[2].length-Q.length:J[0].length-J[1].length-J[2].length;return{checked:K,content:Q,contentIndent:M+J[2].length+q,ordered:X,start:Y}}function cA($,M){return C0($,M).startsWith(G2)}function C0($,M){return $.slice(M)}function aA($,M){let J=_2($);if(J>=M)return $.slice(M);return $.trim()===""?"":$.slice(Math.min(J,M))}function ZJ($){return RA.test($)||fA.test($)||mA.test($)}function XJ($){return $.startsWith("<")&&$.endsWith(">")}function _2($){let M=0;while(M<$.length&&$[M]===" ")M+=1;return M}function sA($,M,J){return M.startsWith(G2)||$J.test(M)||D3.test(M)||MJ.test(M)||JJ.test(M)||ZJ(M.trim())||F3(M)||a5($,J)!==null||XJ(M.trim())}function N0($){return $.lines[$.index]??""}function T4($){return $.trim()===""}function iA($,M){for(let J=M;J<$.length;J+=1)if(!T4($[J]??""))return J;return-1}function QJ($){let M=$.at(-1),J=M&&YJ(M)?M:null;return{blocks:$.filter((X)=>!YJ(X)),comments:J?oA(J.body):[]}}function oA($){let M;try{M=JSON.parse($)}catch{return[]}if(!Array.isArray(M))return[];return M.flatMap((J)=>{let Z=j8(J);return Z?[Z]:[]})}function YJ($){return $.type==="directive"&&$.name===r5}var KJ="---";function H3($,M={}){let Z={index:0,lines:$.replace(/\r\n/g,i).split(i)},X=nA(Z),Y=s5(Z,0,M),{comments:Q,blocks:K}=QJ(Y);return d1(K,Q,X)}function nA($){if($.lines[0]!==KJ)return;for(let M=1;M<$.lines.length;M+=1)if($.lines[M]===KJ){let J=$.lines.slice(0,M+1).join(i);return $.index=M+1,J}return}var O4=`
|
|
27
|
+
|
|
28
|
+
`,tA="-",eA=".",$U="***",MU=" ",z3=3,JU=5,ZU=4,DJ=2,XU=2,YU=1,QU=/([\\`*_[\]])/g,KU=/([\\)&])/g,DU=/(["\\])/g;function i5($,M={}){if($.blocks.length===0&&$.comments.length===0&&$.frontMatter===void 0)return"";let J=$.blocks.map((X)=>o5(X,0,M));if($.comments.length>0)J.push(TU($.comments));if($.frontMatter!==void 0)J.unshift($.frontMatter);let Z=J.join(O4);return Z.endsWith(i)?Z:`${Z}${i}`}function o5($,M,J){let Z=N1(M);switch($.type){case"blockquote":return qU($,M,J);case"code":return AU($,M);case"directive":return OU($,M);case"heading":return AJ($,M);case"list":return UU($,M,J);case"listItem":return UJ($,M,!1,1,J);case"paragraph":return`${Z}${E3(j4($.children))}`;case"table":return GU($,M,J);case"thematicBreak":return`${Z}${$U}`;case"unsupported":return M===0?$.source:NJ($.source,M)}}function qU($,M,J){let Z=$.children.map((Y)=>o5(Y,0,J)).join(O4),X=N1(M);return Z.split(i).map((Y)=>`${X}${G2}${Y.length>0?` ${Y}`:""}`).join(i)}function AU($,M){let J=[$.language??"",$.meta??""].filter(Boolean).join(" ").trim(),Z=N1(M),X=`${Z}${w4}${J?J:""}`,Y=$.source.length>0?$.source.split(i).map((Q)=>`${Z}${Q}`).join(i):Z;return`${X}${i}${Y}${i}${Z}${w4}`}function AJ($,M){let J=E3(j4($.children)),Z=`${N1(M)}${"#".repeat($.depth)}`;return J.length>0?`${Z} ${J}`:Z}function UU($,M,J){let Z=$.start??1;return $.items.map((X)=>UJ(X,M,$.ordered,Z,J)).join($.spread?O4:i)}function UJ($,M,J,Z,X){let Y=J?`${Z}${eA}`:tA,Q=$.checked===null?"":`[${$.checked?"x":" "}] `,K=`${N1(M)}${Y} ${Q}`,q=M+Y.length+1,D=$.children;if(D.length===0)return Q.length>0?K:K.trimEnd();let[A,...V]=D,U=VU(A,K,Q.length>0,X),G=V.map((_)=>o5(_,q,X)).join($.spread?O4:i);if(!G)return U;return`${U}${$.spread?O4:i}${G}`}function VU($,M,J,Z){switch($.type){case"paragraph":{let X=E3(j4($.children));if(X.length===0)return J?M:M.trimEnd();return`${M}${X}`}case"heading":return`${M}${AJ($,0)}`;case"directive":case"unsupported":{let X=$.type==="directive"?W3($):$.source,[Y,...Q]=X.split(i);return[M+Y,...Q.map((K)=>`${N1(M.length)}${K}`)].join(i)}default:{let X=M.length;return`${M.trimEnd()}${i}${o5($,X,Z)}`}}}function GU($,M,J){let Z=$.rows.map((A)=>A.cells.map((V)=>j4(V.children))),X=Math.max(1,...Z.map((A)=>A.length)),Y=Z[0]??[],Q=Array.from({length:X},(A,V)=>Math.max(z3,HU($.align[V]),...J.padTableColumns?Z.map((U)=>U[V]?.length??0):[Y[V]?.length??0])),K=NU(Q,$.align,M),q=qJ(Y,Q,$.align,M,J),D=Z.slice(1).map((A)=>qJ(A,Q,$.align,M,J));return[q??_U(Q,M),K,...D].join(i)}function qJ($,M,J,Z,X){let Y=M.map((Q,K)=>{let q=$[K]??"";if(!X.padTableColumns)return q;return zU(q,Q,J[K])});return`${" ".repeat(Z)}| ${Y.join(" | ")} |`}function NU($,M,J){let Z=$.map((X,Y)=>FU(M[Y],X));return`${" ".repeat(J)}| ${Z.join(" | ")} |`}function _U($,M){return`${N1(M)}| ${$.map((J)=>"".padEnd(J," ")).join(" | ")} |`}function FU($,M){let J=Math.max(z3,M-($==="center"?XU:$?YU:0));switch($){case"center":return`:${"-".repeat(Math.max(1,J))}:`;case"left":return`:${"-".repeat(Math.max(DJ,J))}`;case"right":return`${"-".repeat(Math.max(DJ,J))}:`;default:return"-".repeat(J)}}function HU($){return $==="center"?JU:$?ZU:z3}function zU($,M,J){if(J==="right")return $.padStart(M," ");return $.padEnd(M," ")}function j4($){return WU($).map((M)=>EU(M)).join("")}function E3($){return $.replace(/^ +/gm,(M)=>MU.repeat(M.length))}function EU($){switch($.type){case"break":return i;case"image":return jU($);case"inlineCode":return yU($.code);case"link":return LU($);case"text":return PU(VJ($.text),$.marks);case"unsupported":return $.source}}function WU($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&BU(Z.marks,J.marks)){M[M.length-1]={...Z,text:Z.text+J.text};continue}M.push(J)}return M}function BU($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function PU($,M){return M.reduce((J,Z)=>{switch(Z){case"bold":return`**${J}**`;case"italic":return`*${J}*`;case"strikethrough":return`~~${J}~~`;case"underline":return`${G1}${J}${b4}`}},$)}function yU($){let M=0,J=0;for(let Q of $){if(Q==="`"){if(J+=1,J>M)M=J;continue}J=0}let Z=M>0?M+1:1,X="`".repeat(Z),Y=$.startsWith("`")||$.endsWith("`")?` ${$} `:$;return`${X}${Y}${X}`}function VJ($){return $.replace(QU,"\\$1")}function bU($){return $.replace(KU,"\\$1")}function wU($){return $?` "${$.replace(DU,"\\$1")}"`:""}function TU($){return W3({attributes:"",body:JSON.stringify($,null,2),name:r5})}function OU($,M){let J=W3($);return M===0?J:NJ(J,M)}function W3($){let M=$.attributes?`{${$.attributes}}`:"";return`:::${$.name}${M}${i}${$.body}${i}${d5}`}function jU($){let M=VJ($.alt??""),J=GJ($.url,$.title),Z=$.width?`{width=${$.width}}`:"";return`![${M}]${J}${Z}`}function LU($){return`[${j4($.children)}]${GJ($.url,$.title)}`}function GJ($,M){return`(${bU($)}${wU(M)})`}function N1($){return" ".repeat($)}function NJ($,M){let J=N1(M);return $.split(i).map((Z)=>`${J}${Z}`).join(i)}import{createContext as CU,useContext as RU}from"react";import{createPortal as fU}from"react-dom";import{jsx as HJ}from"react/jsx-runtime";var _J=CU(void 0);function FJ({children:$,themeStyles:M}){return HJ(_J.Provider,{value:M,children:$})}function n5({children:$}){let M=RU(_J);if(typeof document>"u")return null;return fU(HJ("div",{className:"documint-overlay",style:{display:"contents",...M},children:$}),document.body)}import{useEffect as t5,useRef as RJ,useState as R1}from"react";import{forwardRef as SU,useCallback as F2,useEffect as kU,useImperativeHandle as uU,useLayoutEffect as vU,useMemo as hU,useRef as WJ,useState as B3}from"react";var mU=["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 zJ($,M,{topGap:J=8}={}){if(!$.isConnected)return null;let Z=getComputedStyle($),X=document.createElement("div");for(let D of mU)X.style.setProperty(D,Z.getPropertyValue(D));Object.assign(X.style,{position:"absolute",top:"0",left:"0",visibility:"hidden",whiteSpace:"pre-wrap",wordWrap:"break-word",width:`${$.clientWidth}px`}),X.textContent=$.value.slice(0,M);let Y=document.createElement("span");Y.textContent=$.value.slice(M)||".",X.appendChild(Y),document.body.appendChild(X);let Q=$.getBoundingClientRect(),K=parseFloat(Z.lineHeight)||Y.offsetHeight,q={left:Q.left+Y.offsetLeft+parseFloat(Z.borderLeftWidth)-$.scrollLeft,top:Q.top+Y.offsetTop+parseFloat(Z.borderTopWidth)+K+J-$.scrollTop};return document.body.removeChild(X),q}import{jsx as R0,jsxs as BJ,Fragment as aU}from"react/jsx-runtime";var gU=240,IU="documint-leaf-menu-item documint-completion-item",L4=SU(function({actions:M,completionSources:J,onChange:Z,placeholder:X,readOnly:Y=!1,rows:Q=3,value:K},q){let D=WJ(null);uU(q,()=>D.current,[]);let A=hU(()=>rU(J),[J]),[V,U]=B3(null),[G,_]=B3(0),[N,H]=B3(null),E=F2((B,b)=>{if(!A.length){U(null);return}let z=xU(B,b,A);if(!z){U(null);return}U(z),_(0)},[A]),L=F2((B)=>{let b=B.currentTarget.value,z=B.currentTarget.selectionEnd??b.length;Z(b),E(b,z)},[Z,E]),W=F2((B)=>{let b=B.currentTarget;E(b.value,b.selectionEnd??b.value.length)},[E]),R=F2(()=>{U(null)},[]),f=F2((B)=>{if(!D.current||!V)return;let z=`${V.trigger}${B.label} `,T=K.slice(0,V.triggerStart),P=K.slice(V.caret),y=T+z+P,F=V.triggerStart+z.length;Z(y),U(null),requestAnimationFrame(()=>{let C=D.current;if(!C)return;C.focus(),C.setSelectionRange(F,F)})},[V,Z,K]),I=F2((B)=>{if(V&&V.matches.length>0){if(B.key==="ArrowDown"){B.preventDefault(),B.stopPropagation(),_((b)=>(b+1)%V.matches.length);return}if(B.key==="ArrowUp"){B.preventDefault(),B.stopPropagation(),_((b)=>(b-1+V.matches.length)%V.matches.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),B.stopPropagation();let b=V.matches[G];if(b)f(b);return}if(B.key==="Escape"){B.preventDefault(),B.stopPropagation(),U(null);return}}if(B.key==="Escape"&&M.kind==="edit")B.preventDefault(),M.onCancel()},[M,V,G,f]);return vU(()=>{if(!V){H(null);return}let B=()=>{let b=D.current;if(!b)return;H(zJ(b,V.triggerStart))};return B(),window.addEventListener("scroll",B,!0),window.addEventListener("resize",B),()=>{window.removeEventListener("scroll",B,!0),window.removeEventListener("resize",B)}},[V]),BJ("div",{className:"documint-leaf-input-field",children:[R0("textarea",{className:"documint-leaf-input",onBlur:R,onChange:L,onKeyDown:I,onSelect:W,placeholder:X,readOnly:Y,ref:D,rows:Q,value:K}),pU(M),V&&N&&V.matches.length>0?R0(n5,{children:R0(lU,{activeIndex:G,left:N.left,matches:V.matches,onHover:_,onSelect:f,top:N.top})}):null]})});function pU($){if($.kind==="edit")return BJ(aU,{children:[R0(P3,{className:"documint-leaf-input-cancel",icon:y4,label:"Cancel editing",onClick:$.onCancel}),R0(P3,{className:"documint-leaf-input-save",disabled:$.saveDisabled??!1,icon:L1,label:"Save",onClick:$.onSave})]});return R0(P3,{className:"documint-leaf-input-submit",disabled:$.submitDisabled??!1,icon:U1,iconSize:15,label:$.submitLabel,onClick:$.onSubmit})}function P3({className:$,disabled:M=!1,icon:J,iconSize:Z=14,label:X,onClick:Y}){return R0("button",{"aria-label":X,className:`documint-leaf-action ${$}`,disabled:M,onClick:Y,title:X,type:"button",children:R0(J,{size:Z,strokeWidth:2.2})})}function lU({activeIndex:$,left:M,matches:J,onHover:Z,onSelect:X,top:Y}){let Q=WJ(null);return kU(()=>{let K=Q.current;if(!K)return;let q=K.children[$];if(q instanceof HTMLElement)q.scrollIntoView({block:"nearest"})},[$]),R0("div",{className:"documint-leaf-menu documint-completion-popover",ref:Q,role:"listbox",style:{position:"fixed",left:M,top:Y,maxHeight:gU,overflowY:"auto"},children:J.map((K,q)=>{let D=q===$;return R0("button",{"aria-selected":D,className:`${IU}${D?" is-active":""}`,onPointerDown:dU,onPointerEnter:()=>Z(q),onClick:()=>X(K),role:"option",type:"button",children:R0("span",{children:K.label})},K.label)})})}function dU($){$.preventDefault()}function rU($){if(!$?.length)return[];return $.map((M)=>({trigger:M.trigger,items:[...M.items].sort((J,Z)=>J.label.localeCompare(Z.label,void 0,{sensitivity:"base"}))}))}function xU($,M,J){for(let Z=M-1;Z>=0;Z-=1){let X=$[Z];if(EJ(X))return null;let Y=J.find((K)=>K.trigger===X);if(!Y)continue;if(Z>0&&!EJ($[Z-1]))return null;let Q=$.slice(Z+1,M);return{trigger:Y.trigger,query:Q,triggerStart:Z,caret:M,matches:cU(Y.items,Q)}}return null}function EJ($){return $===void 0||$===" "||$===`
|
|
29
|
+
`||$==="\t"}function cU($,M){if(!M)return $;let J=M.toLowerCase();return $.filter((Z)=>Z.label.toLowerCase().includes(J))}import{Fragment as iU}from"react";function y3($,M){if(!M?.length||!M.some((Q)=>$.includes(Q.trigger)))return[{kind:"text",text:$}];let J=new Map;for(let Q of M){let K=[...Q.items].sort((q,D)=>D.label.length-q.label.length);J.set(Q.trigger,K)}let Z=[],X=0,Y=0;while(X<$.length){let Q=$[X],K=J.get(Q);if(K!==void 0&&(X===0||sU($[X-1]))){let D=K.find((A)=>$.startsWith(A.label,X+1));if(D){if(X>Y)Z.push({kind:"text",text:$.slice(Y,X)});Z.push({kind:"token",trigger:Q,label:D.label,id:D.id}),X+=1+D.label.length,Y=X;continue}}X+=1}if(Y<$.length)Z.push({kind:"text",text:$.slice(Y)});return Z}function b3($,M){let J=[],Z=new Set;for(let X of y3($,M)){if(X.kind!=="token"||X.trigger!=="@"||!X.id)continue;if(Z.has(X.id))continue;Z.add(X.id),J.push(X.id)}return J}function sU($){return $===void 0||$===" "||$===`
|
|
30
|
+
`||$==="\t"}import{jsx as PJ,jsxs as nU}from"react/jsx-runtime";function w3({value:$,completionSources:M,onEdit:J}){return PJ("p",{onDoubleClick:J,children:oU($,M)})}function oU($,M){let J=y3($,M);if(J.length===1&&J[0].kind==="text")return $;return J.map((Z,X)=>Z.kind==="token"?nU("span",{className:"documint-mention",children:[Z.trigger,Z.label]},X):PJ(iU,{children:Z.text},X))}import{Children as yJ,isValidElement as bJ,useEffect as tU,useRef as eU,useState as $V}from"react";import{jsx as A0,jsxs as j3}from"react/jsx-runtime";var T3=($)=>{$.preventDefault()},O3=($)=>$.isPrimary&&$.button===0;function MV({children:$}){return A0("div",{className:"documint-leaf-toolbar",children:yJ.map($,JV)})}function JV($){if(!bJ($))return null;if($.type===TJ){let M=$.props;return A0(wJ,{children:A0(ZV,{...M})})}if($.type===OJ){let{className:M}=$.props;return A0("div",{className:C4("documint-leaf-toolbar-divider",M)})}if($.type===jJ){let M=$.props;return A0(XV,{...M})}return null}function ZV({active:$=!1,className:M,disabled:J=!1,icon:Z,label:X,onClick:Y}){return A0("button",{"aria-label":X,className:C4("documint-leaf-toolbar-button",$?"active":null,M),disabled:J,onPointerDown:(Q)=>{if(T3(Q),!J&&O3(Q))Y()},title:X,type:"button",children:A0(Z,{size:15,strokeWidth:2.2})})}function XV({children:$,className:M,icon:J,label:Z,onSelect:X}){let Y=eU(null),[Q,K]=$V(!1);return tU(()=>{if(!Q)return;let q=(D)=>{if(Y.current&&D.target instanceof Node&&!Y.current.contains(D.target))K(!1)};return window.addEventListener("pointerdown",q),()=>{window.removeEventListener("pointerdown",q)}},[Q]),A0(wJ,{children:j3("div",{className:"documint-leaf-toolbar-menu-shell",ref:Y,children:[A0(YV,{className:M,icon:J,isOpen:Q,label:Z,onClick:()=>K((q)=>!q)}),Q?A0("div",{className:"documint-leaf-menu",role:"menu",children:yJ.map($,(q)=>QV(q,(D)=>{K(!1),X(D)}))}):null]})})}function YV({className:$,icon:M,isOpen:J,label:Z,onClick:X}){return j3("button",{"aria-expanded":J,"aria-haspopup":"menu","aria-label":Z,className:C4("documint-leaf-toolbar-button",J?"active":null,$),onPointerDown:(Y)=>{if(T3(Y),O3(Y))X()},title:Z,type:"button",children:[A0(M,{size:15,strokeWidth:2.2}),A0(K4,{className:C4("documint-leaf-toolbar-menu-chevron",J?"is-open":null),size:13,strokeWidth:2.2})]})}function QV($,M){if(!bJ($))return null;if($.type===CJ){let{className:Q}=$.props;return A0("div",{className:C4("documint-leaf-menu-divider",Q),role:"separator"})}if($.type!==LJ)return null;let{disabled:J=!1,icon:Z,text:X,value:Y}=$.props;return j3("button",{className:"documint-leaf-menu-item",disabled:J,onPointerDown:(Q)=>{if(T3(Q),!J&&O3(Q))M(Y)},role:"menuitem",type:"button",children:[A0(Z,{size:15,strokeWidth:2.2}),A0("span",{children:X})]})}function C4(...$){return $.filter(Boolean).join(" ")}function wJ({children:$}){return A0("div",{className:"documint-leaf-toolbar-group",children:$})}function TJ($){return null}function OJ($){return null}function jJ($){return null}function LJ($){return null}function CJ($){return null}var r=Object.assign(MV,{Button:TJ,Divider:OJ,Menu:jJ,MenuDivider:CJ,MenuItem:LJ});import{jsx as n,jsxs as l0,Fragment as AV}from"react/jsx-runtime";var KV=!1,DV=220,f1=()=>{};function L3($){let M=$.mode==="create",J=$.mode==="create"?$:null,Z=$.mode==="thread"?$:null,X=$.canEdit,Y=$.link,Q=Z?.thread??null,K=Q?.comments??[],q=K[0]??null,D=Q?J1(Q):!1,A=Z?.animateInitialComment??!1,[V,U]=R1(null),[G,_]=R1(""),[N,H]=R1(""),[E,L]=R1(""),[W,R]=R1(!A),[f,I]=R1(KV),[B,b]=R1(!1),z=RJ(null),T=RJ(null),P=$.mentionSources,y=Q?k8(Q):null,F=y?fJ(y):"",C=X&&!D,v=C&&G.trim().length>0,h=C&&N.trim().length>0,g=X&&E.trim().length>0,O=M||B,w=!M||f,m=!M&&Boolean(Q),S=Boolean(q),c=M?f:!0,l=Z?.onDeleteComment??f1,F0=Z?.onDeleteThread??f1,x0=Z?.onToggleResolved??f1,f0=J?.activeMarks??[],m0=J?.onToggleBold??f1,c0=J?.onToggleItalic??f1,K8=J?.onToggleStrikethrough??f1,D8=J?.onToggleUnderline??f1,h4=X?M?"Add a comment":"Reply to this comment":"Comment editing is disabled",q8=M?E:N;t5(()=>{if(V!==null&&(V<0||V>=K.length))U(null),_("")},[K.length,V]),t5(()=>{if(!S||!A){R(!0);return}R(!1);let a=requestAnimationFrame(()=>{R(!0)});return()=>{cancelAnimationFrame(a)}},[A,q,S]),t5(()=>{if(!Z||!A){b(!1);return}b(!0);let a=window.setTimeout(()=>{b(!1)},DV);return()=>{window.clearTimeout(a)}},[A,Z]),t5(()=>{if(!M||!f||!X)return;let a=requestAnimationFrame(()=>{T.current?.focus()});return()=>{cancelAnimationFrame(a)}},[X,M,f]);let W2=()=>{U(null),_("")},g4=(a,I4)=>{if(!m||!C)return;U(a),_(I4)},S0=(a)=>{if(!Z)return;Z.onEditComment(a,G),W2()},B0=()=>{if(!Z)return;Z.onReply(N),H("")},k1=()=>{if(!J||!g)return;J.onCreateThread(E),L("")},A8=O?`documint-comment-leaf documint-comment-leaf-create${c?" is-expanded":""}`:"documint-comment-leaf",u1=m||S||w?n(qV,{canCreate:g,canEdit:X,canMutateThread:C,canReply:h,canSaveEditedComment:v,comments:K,composerRef:T,editDraft:G,editingCommentIndex:V,isComposerVisible:w,isInitialCommentVisible:W,isResolved:D,link:Y,mentionSources:P,mode:$.mode,onBeginEditingComment:g4,onCancelEditing:W2,onChangeCreateDraft:L,onChangeEditDraft:_,onChangeReplyDraft:H,onDeleteComment:l,onDeleteThread:F0,onSubmitCreate:k1,onSubmitEditedComment:S0,onSubmitReply:B0,onToggleResolved:x0,rootComment:q,showRootComment:S,showThreadChrome:m,threadAge:F,composerPlaceholder:h4,composerValue:q8}):null;return n("div",{className:A8,ref:z,children:l0("div",{className:O?"documint-comment-leaf-create-shell":void 0,children:[O?l0(r,{children:[n(r.Button,{className:"documint-comment-leaf-create-button",icon:E4,label:"Add comment",onClick:()=>I(!0)}),n(r.Divider,{className:"documint-comment-leaf-create-divider"}),n(r.Button,{active:f0.includes("bold"),className:"documint-comment-leaf-create-mark",icon:Q4,label:"Bold",onClick:m0}),n(r.Button,{active:f0.includes("italic"),className:"documint-comment-leaf-create-mark",icon:_4,label:"Italic",onClick:c0}),n(r.Button,{active:f0.includes("underline"),className:"documint-comment-leaf-create-mark",icon:P4,label:"Underline",onClick:D8}),n(r.Button,{active:f0.includes("strikethrough"),className:"documint-comment-leaf-create-mark",icon:W4,label:"Strikethrough",onClick:K8})]}):null,n("div",{className:O?"documint-comment-leaf-create-content":void 0,children:u1})]})})}function qV({canCreate:$,canEdit:M,canMutateThread:J,canReply:Z,canSaveEditedComment:X,comments:Y,composerRef:Q,editDraft:K,editingCommentIndex:q,isComposerVisible:D,isInitialCommentVisible:A,isResolved:V,link:U,mentionSources:G,mode:_,onBeginEditingComment:N,onCancelEditing:H,onChangeCreateDraft:E,onChangeEditDraft:L,onChangeReplyDraft:W,onDeleteComment:R,onDeleteThread:f,onSubmitCreate:I,onSubmitEditedComment:B,onSubmitReply:b,onToggleResolved:z,rootComment:T,showRootComment:P,showThreadChrome:y,threadAge:F,composerPlaceholder:C,composerValue:v}){return l0(AV,{children:[y?l0("div",{className:"documint-comment-leaf-header",children:[n("span",{className:"documint-comment-leaf-age",children:F}),l0("div",{className:"documint-comment-leaf-actions",children:[n("button",{className:"documint-leaf-action","aria-label":V?"Reopen comment":"Resolve comment",disabled:!M,onClick:z,title:V?"Reopen comment":"Resolve comment",type:"button",children:n(L1,{size:14,strokeWidth:2.2})}),n("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment thread",disabled:!M,onClick:f,title:"Delete comment thread",type:"button",children:n(w0,{size:14,strokeWidth:2.2})})]})]}):null,y&&U?l0("div",{className:"documint-comment-leaf-link",children:[U.title?n("div",{className:"documint-link-leaf-title",children:U.title}):null,n("div",{className:"documint-link-leaf-url",children:U.url})]}):null,l0("div",{className:`documint-comment-thread${P?"":" is-empty"}`,children:[n("article",{className:P?`documint-comment-message documint-comment-message-root${A?" is-visible":""}`:"documint-comment-message documint-comment-message-root is-hidden",children:T?n(w3,{completionSources:G,onEdit:()=>N(0,T.body),value:T.body}):null}),Y.slice(1).map((h,g)=>{let O=g+1,w=q===O;return l0("article",{className:"documint-comment-message",children:[!w?l0("div",{className:"documint-comment-message-meta",children:[n("span",{children:fJ(h.updatedAt)}),J?l0("div",{className:"documint-comment-leaf-actions",children:[n("button",{className:"documint-leaf-action","aria-label":"Edit comment",disabled:!J,onClick:()=>{N(O,h.body)},title:"Edit comment",type:"button",children:n(C1,{size:14,strokeWidth:2.2})}),n("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment",disabled:!J,onClick:()=>R(O),title:"Delete comment",type:"button",children:n(w0,{size:14,strokeWidth:2.2})})]}):null]}):null,w?n(L4,{actions:{kind:"edit",onCancel:H,onSave:()=>B(O),saveDisabled:!X},completionSources:G,onChange:L,readOnly:!M,rows:3,value:K}):n(w3,{completionSources:G,onEdit:()=>N(O,h.body),value:h.body})]},`${h.updatedAt}:${O}`)})]}),n("div",{className:`documint-comment-reply${y?"":" is-standalone"}${D?" is-visible":""}`,children:n(L4,{actions:_==="create"?{kind:"compose",onSubmit:I,submitDisabled:!$,submitLabel:"Create comment"}:{kind:"compose",onSubmit:b,submitDisabled:!Z,submitLabel:"Reply"},completionSources:G,onChange:_==="create"?E:W,placeholder:C,readOnly:!M,ref:Q,rows:3,value:v})})]})}function fJ($){let M=new Date($);if(Number.isNaN(M.getTime()))return $;let J=M.getTime()-Date.now(),Z=60000,X=60*Z,Y=24*X,Q=7*Y,K=30*Y,q=365*Y,D=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});if(Math.abs(J)<Z)return"just now";if(Math.abs(J)<X)return D.format(Math.round(J/Z),"minute");if(Math.abs(J)<Y)return D.format(Math.round(J/X),"hour");if(Math.abs(J)<Q)return D.format(Math.round(J/Y),"day");if(Math.abs(J)<q)return D.format(Math.round(J/K),"month");return D.format(Math.round(J/q),"year")}import{jsx as d0,jsxs as GV}from"react/jsx-runtime";var UV=[{icon:D4,label:"Heading 1",text:"# "},{icon:q4,label:"Heading 2",text:"## "},{icon:A4,label:"Heading 3",text:"### "},{icon:U4,label:"Heading 4",text:"#### "},{icon:V4,label:"Heading 5",text:"##### "},{icon:G4,label:"Heading 6",text:"###### "}],VV=[{columns:2,text:"2 columns"},{columns:3,text:"3 columns"},{columns:4,text:"4 columns"},{columns:5,text:"5 columns"}];function mJ({onInsert:$,onInsertTable:M}){return GV(r,{children:[d0(r.Button,{icon:z4,label:"Insert bulleted list",onClick:()=>$("- ")}),d0(r.Button,{icon:F4,label:"Insert numbered list",onClick:()=>$("1. ")}),d0(r.Button,{icon:H4,label:"Insert task list",onClick:()=>$("- [ ] ")}),d0(r.Divider,{}),d0(r.Menu,{icon:N4,label:"Insert heading",onSelect:$,children:UV.map(({icon:J,label:Z,text:X})=>d0(r.MenuItem,{icon:J,text:Z,value:X},X))}),d0(r.Menu,{icon:V1,label:"Insert table",onSelect:(J)=>M(Number(J)),children:VV.map(({columns:J,text:Z})=>d0(r.MenuItem,{icon:V1,text:Z,value:String(J)},J))}),d0(r.Divider,{}),d0(r.Button,{icon:B4,label:"Insert blockquote",onClick:()=>$("> ")})]})}import{jsx as C3,jsxs as NV}from"react/jsx-runtime";function SJ({anchor:$,children:M,status:J="default"}){let Z=!$.isSelection;return C3(n5,{children:NV("div",{className:"documint-leaf-anchor","data-selection":$.isSelection?"true":"false",onPointerEnter:$.onPointerEnter,onPointerLeave:$.onPointerLeave,style:{left:`${$.left}px`,top:`${$.top}px`},children:[Z?C3("div",{className:"documint-leaf-bridge"}):null,C3("div",{className:"documint-leaf-shell","data-status":J,children:M})]})})}import{useEffect as kJ,useRef as _V,useState as uJ}from"react";import{jsx as n0,jsxs as R3}from"react/jsx-runtime";function vJ({canEdit:$,onDelete:M,onSave:J,title:Z,url:X}){let[Y,Q]=uJ(X),[K,q]=uJ(!1),D=_V(null),A=FV(),V=Y.trim(),U=$&&V.length>0,G=$&&!K,_=`${A}click to open`,N=`documint-link-leaf-row${K?" is-editing":""}`;return kJ(()=>{if(K)return;Q(X)},[K,X]),kJ(()=>{if(!K)return;D.current?.focus()},[K]),R3("div",{className:"documint-link-leaf",children:[Z?n0("div",{className:"documint-link-leaf-title",children:Z}):null,R3("div",{className:N,children:[K?n0(L4,{actions:{kind:"edit",onCancel:()=>{Q(X),q(!1)},onSave:()=>{J(V),q(!1)},saveDisabled:!U},onChange:Q,readOnly:!$,ref:D,rows:3,value:Y}):n0("div",{className:"documint-link-leaf-url",children:X}),G?R3("div",{className:"documint-link-leaf-actions",children:[n0("button",{className:"documint-leaf-action","aria-label":"Edit link",onClick:()=>{if(!$)return;Q(X),q(!0)},title:"Edit link",type:"button",children:n0(C1,{size:14,strokeWidth:2.2})}),n0("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Remove link",onClick:M,title:"Remove link",type:"button",children:n0(w0,{size:14,strokeWidth:2.2})})]}):null]}),n0("div",{className:"documint-link-leaf-divider"}),n0("div",{className:"documint-link-leaf-hint",children:_})]})}function FV(){if(typeof navigator>"u")return"Ctrl+";let $=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/.test($)?"CMD+":"CTRL+"}import{jsx as t0,jsxs as S3}from"react/jsx-runtime";var HV=[{text:"Column left",value:"left"},{text:"Column right",value:"right"}],zV=[{text:"Row above",value:"above"},{text:"Row below",value:"below"}],f3={text:"Delete column",value:"delete"},m3={text:"Delete row",value:"delete"},hJ={text:"Delete table",value:"delete"};function gJ({canDeleteColumn:$,canDeleteRow:M,onDeleteColumn:J,onDeleteRow:Z,onDeleteTable:X,onInsertColumn:Y,onInsertRow:Q}){return S3(r,{children:[S3(r.Menu,{icon:q1,label:"Column actions",onSelect:(K)=>{if(K===f3.value){J();return}Y(K)},children:[HV.map(({text:K,value:q})=>t0(r.MenuItem,{icon:U2,text:K,value:q},q)),t0(r.MenuDivider,{}),t0(r.MenuItem,{disabled:!$,icon:w0,text:f3.text,value:f3.value})]}),S3(r.Menu,{icon:A1,label:"Row actions",onSelect:(K)=>{if(K===m3.value){Z();return}Q(K)},children:[zV.map(({text:K,value:q})=>t0(r.MenuItem,{icon:U2,text:K,value:q},q)),t0(r.MenuDivider,{}),t0(r.MenuItem,{disabled:!M,icon:w0,text:m3.text,value:m3.value})]}),t0(r.Divider,{}),t0(r.Menu,{icon:V1,label:"Table actions",onSelect:()=>X(),children:t0(r.MenuItem,{icon:w0,text:hJ.text,value:hJ.value})})]})}import{useEffect as IJ,useEffectEvent as pJ,useLayoutEffect as lJ,useMemo as EV,useRef as k3,useState as dJ}from"react";function e5($,M){if(!$||$.kind==="task-toggle")return null;if($.commentThreadIndex!==null){let J=M[$.commentThreadIndex]??null;if(!J)return null;return{kind:"comment",left:$.anchorLeft,link:$.kind==="link"?{title:$.title,url:$.url}:null,thread:J,threadIndex:$.commentThreadIndex,top:$.anchorBottom}}if($.kind!=="link")return null;return{endOffset:$.endOffset,kind:"link",left:$.anchorLeft,regionId:$.regionId,startOffset:$.startOffset,title:$.title,top:$.anchorBottom,url:$.url}}var WV=600,BV=530,H2=24;function xJ({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,editorState:Z,editorViewportState:X,getScrollTop:Y,layoutWidth:Q,onVisibilityChange:K,resources:q,scrollContentHeight:D,scrollTo:A,viewportHeight:V}){let U=EV(()=>Y0(Z),[Z]),[G,_]=dJ(null),[N,H]=dJ(null),E=U.start.regionId===U.end.regionId&&U.start.offset===U.end.offset,L=k3(!0),W=k3(0),R=k3(null),f=pJ(()=>{K()}),I=pJ(()=>{W.current=typeof performance<"u"?performance.now():Date.now(),L.current=!0,f()});return lJ(()=>{let B=PV({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,normalizedSelection:U,state:Z,viewport:X.get()});_((b)=>TV(b,B)?b:B)},[$,M,J,Z,X]),lJ(()=>{let B=q?jV(Z,X.get(),U,q):null;H((b)=>LV(b,B)?b:B)},[Z,X,U,q]),IJ(()=>{let B=Z.selection.focus,b={layoutWidth:Q,offset:B.offset,regionId:B.regionId,scrollContentHeight:D,viewportHeight:V};if(OV(R.current,b))return;let z=A6(Z,X.get(),B);if(!z)return;let T=Y(),P=T+H2,y=T+V-H2;if(z.top<P){let F=A(Math.max(0,z.top-H2));if(rJ(z,F,V,H2))R.current=b;return}if(z.top+z.height>y){let F=A(Math.max(0,z.top+z.height-V+H2));if(rJ(z,F,V,H2))R.current=b;return}R.current=b},[Z,Z.selection.focus.offset,Z.selection.focus.regionId,X,Q,D,A,V]),IJ(()=>{if(L.current=!0,f(),!E||typeof window>"u")return;let B=window.setInterval(()=>{if((typeof performance<"u"?performance.now():Date.now())-W.current<WV){if(!L.current)L.current=!0,f();return}L.current=!L.current,f()},BV);return()=>{window.clearInterval(B)}},[E]),{imageAtCursor:N,leaf:G,isVisible:()=>L.current,markActivity:I}}function PV({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,normalizedSelection:Z,state:X,viewport:Y}){if(!Y)return null;let Q=X.selection.focus;if(Z.start.regionId!==Z.end.regionId||Z.start.offset!==Z.end.offset)return null;let K=$?wV(X,Y):null;if(K)return K;let q=M?yV(X,Y):null;if(q)return q;return e5(q6(X,Y,Q,J.liveRanges),J.threads)}function yV($,M){let J=$.selection.focus,Z=$.documentIndex.regionIndex.get(J.regionId),X=Z?$.documentIndex.tableCellIndex.get(Z.id)??null:null;if(!Z||!X)return null;let Y=$.documentIndex.blockIndex.get(Z.blockId),Q=Y?.type==="table"?$.documentIndex.document.blocks[Y.rootIndex]:null;if(!Y||!Q||Q.type!=="table")return null;let K=o0($,M,J),q=bV(M,Z.id),D=Math.max(1,...Q.rows.map((A)=>A.cells.length));return K&&q!==null?{cellIndex:X.cellIndex,columnCount:D,kind:"table",left:q,rowCount:Q.rows.length,rowIndex:X.rowIndex,top:K.top+K.height}:null}function bV($,M){let J=$.layout.lines.find((Z)=>Z.regionId===M);return J?J.left:null}function wV($,M){let J=$.selection.focus,Z=$.documentIndex.regionIndex.get(J.regionId);if(!Z||Z.blockType!=="paragraph"||Z.text.length>0)return null;if(J.offset!==0)return null;let X=$.documentIndex.blockIndex.get(Z.blockId);if(!X||X.parentBlockId!==null)return null;let Y=o0($,M,J);return Y?{kind:"insertion",left:Y.left,top:Y.top+Y.height}:null}function TV($,M){if($===M)return!0;if(!$||!M||$.kind!==M.kind)return!1;switch($.kind){case"comment":return M.kind==="comment"&&$.left===M.left&&$.link?.title===M.link?.title&&$.link?.url===M.link?.url&&$.thread===M.thread&&$.threadIndex===M.threadIndex&&$.top===M.top;case"insertion":return M.kind==="insertion"&&$.left===M.left&&$.top===M.top;case"link":return M.kind==="link"&&$.endOffset===M.endOffset&&$.left===M.left&&$.regionId===M.regionId&&$.startOffset===M.startOffset&&$.title===M.title&&$.top===M.top&&$.url===M.url;case"table":return M.kind==="table"&&$.cellIndex===M.cellIndex&&$.columnCount===M.columnCount&&$.left===M.left&&$.rowCount===M.rowCount&&$.rowIndex===M.rowIndex&&$.top===M.top}}function OV($,M){return $?.layoutWidth===M.layoutWidth&&$.regionId===M.regionId&&$.offset===M.offset&&$.scrollContentHeight===M.scrollContentHeight&&$.viewportHeight===M.viewportHeight}function rJ($,M,J,Z){return $.top>=M+Z&&$.top+$.height<=M+J-Z}function jV($,M,J,Z){if(!M)return null;if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let X=B5($);if(!X)return null;let Y=J5($,M,Z,X),Q=X.image?Z.images.get(X.image.url)?.intrinsicWidth??null:null,K=$.selection.anchor.regionId;return Y?{bounds:Y,maxWidth:Q,regionId:K,run:X}:null}function LV($,M){if($===M)return!0;if(!$||!M)return!1;return $.regionId===M.regionId&&$.maxWidth===M.maxWidth&&$.bounds.left===M.bounds.left&&$.bounds.top===M.bounds.top&&$.bounds.width===M.bounds.width&&$.bounds.height===M.bounds.height}import{useMemo as u3,useRef as R4,useEffectEvent as v3}from"react";var CV=48;function cJ($,M,J){let Z=R4(null),X=R4(null),Y=R4(null),Q=R4(null),K=R4(1),q=v3((G,_)=>{if(!$)return;G.preventDefault(),G.stopPropagation(),G.currentTarget.setPointerCapture(G.pointerId),Q.current=G.pointerId,Z.current=G.clientX,X.current=G.clientY,Y.current=$.run.image?.width??$.bounds.width,K.current=_}),D=v3((G)=>{if(Q.current!==G.pointerId||Z.current===null||X.current===null||Y.current===null||!$?.run.image)return;let _=G.clientX-Z.current,N=G.clientY-X.current,H=Math.min($.maxWidth??1/0,Math.max(CV,Math.round(Y.current+K.current*(_+N)))),E=o7(M,$.regionId,$.run,H);if(E)J(E)}),A=v3((G)=>{if(G.currentTarget.hasPointerCapture(G.pointerId))G.currentTarget.releasePointerCapture(G.pointerId);Q.current=null,Z.current=null,X.current=null,Y.current=null}),V=u3(()=>({onPointerDown:(G)=>q(G,-1),onPointerMove:D,onPointerUp:A,onPointerCancel:A}),[]),U=u3(()=>({onPointerDown:(G)=>q(G,1),onPointerMove:D,onPointerUp:A,onPointerCancel:A}),[]);return u3(()=>{if(!$)return null;let{bounds:G}=$;return{start:{left:G.left,top:G.top,props:V},end:{left:G.left+G.width,top:G.top+G.height,props:U}}},[$])}import{useEffect as aJ,useEffectEvent as sJ,useMemo as iJ,useRef as RV,useState as fV}from"react";function oJ($,M){let[J,Z]=fV(new Map),X=sJ((q)=>{if(typeof Image>"u")return;let D=[...J.keys()].filter((A)=>!q.has(A));if(D.length>0)Z((A)=>{let V=new Map(A);for(let U of D)V.delete(U);return V});for(let A of q){let V=J.get(A)?.status;if(V==="loaded"||V==="loading")continue;Z((U)=>h3(U,A,f4("loading"))),mV(A,M).then((U)=>{Z((G)=>{if(!G.has(A))return U?.close(),G;return h3(G,A,U?f4("loaded",U):f4("error"))})})}});aJ(()=>{X($)},[$]);let Y=RV(new Map);aJ(()=>{for(let[q,D]of Y.current)if(!J.has(q))D.source?.close();Y.current=J},[J]);let Q=sJ(async(q)=>{if(!M?.writeFile)return null;try{let D=await M.writeFile(q),A=await createImageBitmap(q).catch(()=>null);return Z((V)=>h3(V,D,A?f4("loaded",A):f4("error"))),D}catch{return null}}),K=iJ(()=>J.size===0?null:{images:J},[J]);return iJ(()=>({resources:K,persistImage:Q}),[K,Q])}async function mV($,M){if(/^(https?:|data:|blob:)/i.test($))return SV($);if(!M?.readFile)return null;try{let J=await M.readFile($);return J?await createImageBitmap(J):null}catch{return null}}function SV($){return new Promise((M)=>{let J=new Image;J.decoding="async",J.crossOrigin="anonymous",J.onload=async()=>{try{M(await createImageBitmap(J))}catch{M(null)}},J.onerror=()=>M(null),J.src=$})}function h3($,M,J){let Z=new Map($);return Z.set(M,J),Z}function f4($,M){return{intrinsicHeight:M?.height??0,intrinsicWidth:M?.width??0,source:M??null,status:$}}import{useEffect as nJ,useEffectEvent as _0,useRef as m4,useState as kV}from"react";var uV=48;function tJ({applyNextState:$,autoScrollDuringDrag:M,canvasRef:J,commentState:Z,editorStateRef:X,editorViewportState:Y,focusInput:Q,onActivity:K,readCurrentState:q,resolvePoint:D}){let[A,V]=kV(null),U=m4(null),G=m4(!1),_=m4(null),N=m4(null),H=m4(null),E=e5(A,Z.threads),L=A?.kind==="task-toggle"||E?.kind==="link"?"pointer":"text";nJ(()=>{if(A&&A.kind!=="task-toggle"&&!E)V(null)},[A,E]),nJ(()=>()=>{if(U.current!==null)window.clearTimeout(U.current)},[]);let W=_0(()=>{if(U.current!==null)window.clearTimeout(U.current),U.current=null}),R=_0(()=>{W(),U.current=window.setTimeout(()=>{if(U.current=null,!G.current)V(null)},uV)}),f=_0(()=>{if(!G.current)W(),V(null)}),I=_0((O)=>{if(!O){f();return}if(O.kind==="task-toggle"){W(),V((w)=>w?.kind==="task-toggle"&&w.listItemId===O.listItemId?w:O);return}if(O.commentThreadIndex!==null){if(!(Z.threads[O.commentThreadIndex]??null)){f();return}W();let m=O.commentThreadIndex;V((S)=>S?.kind!=="task-toggle"&&S?.commentThreadIndex===m?S:O);return}if(O.kind!=="link"){f();return}W(),V((w)=>w?.kind==="link"&&w.title===O.title&&w.url===O.url&&w.startOffset===O.startOffset&&w.endOffset===O.endOffset?w:O)}),B=_0((O)=>{let w=X.current;if(!w)return null;let m=D(O);if(!m)return null;return D6(w,Y.get(),m,Z.liveRanges)}),b=_0((O)=>{let w=J.current;if(w&&_.current===O)w.releasePointerCapture(O)}),z=_0(()=>{_.current=null,N.current=null}),T=_0((O)=>{b(O.pointerId),z()}),P=_0((O)=>{if(H.current=O.pointerType,O.pointerType==="touch")return;let w=J.current,m=q(),S=D(O);if(!S)return;if(B(O)?.kind==="task-toggle")return;let l=N5(m,Y.get(),S);if(!w||!l)return;if(_.current=O.pointerId,K(),w.setPointerCapture(O.pointerId),O.shiftKey)N.current=m.selection.anchor,$(m7(m,l.regionId,l.offset));else N.current={offset:l.offset,regionId:l.regionId},$(X0(m,{offset:l.offset,regionId:l.regionId}));Q({offset:l.offset,regionId:l.regionId})}),y=_0((O)=>{let w=N.current,m=q(),S=D(O);if(!S)return;if(_.current!==O.pointerId||!w){I(B(O));return}let c=m2(m,Y.get(),S,w);if(!c)return;K(),M(O),$(X0(m,{anchor:w,focus:c}))}),F=_0(()=>{if(!G.current)R()}),C=_0((O)=>{let w=H.current==="touch";H.current=null;let m=B(O);if(m?.kind==="task-toggle"){let F0=q(),x0=g7(F0,m.listItemId);if(x0)O.preventDefault(),O.stopPropagation(),K(),$(x0);return}if(m?.kind==="link"&&(O.metaKey||O.ctrlKey)){O.preventDefault(),O.stopPropagation(),O.currentTarget.ownerDocument.defaultView?.open(m.url,"_blank","noopener,noreferrer");return}if(!w){Q();return}let S=q(),c=D(O),l=c?N5(S,Y.get(),c):null;if(l)K(),$(X0(S,{offset:l.offset,regionId:l.regionId})),Q({offset:l.offset,regionId:l.regionId});else Q()}),v=_0((O)=>{let w=q(),m=D(O),S=B(O);if(!m||S?.kind==="task-toggle")return;let c=K6(w,Y.get(),m);if(!c)return;O.preventDefault(),O.stopPropagation(),K(),$(X0(w,c)),Q()}),h=_0(()=>{G.current=!0,W()}),g=_0(()=>{G.current=!1,R()});return{canvasHandlers:{onClick:C,onDoubleClick:v,onPointerCancel:T,onPointerDown:P,onPointerLeave:F,onPointerMove:y,onPointerUp:T},cursor:L,leaf:E,leafHandlers:{onPointerEnter:h,onPointerLeave:g}}}import{useEffect as l3,useEffectEvent as U0,useLayoutEffect as hV,useRef as YZ,useState as gV}from"react";import{useEffect as jC1}from"react";var g3=[{key:"Backspace",command:"deleteBackward"},{key:"Enter",command:"insertLineBreak"},{key:"Home",command:"moveToLineStart"},{key:"End",command:"moveToLineEnd"},{key:"Tab",command:"indent"},{key:"Tab",shiftKey:!0,command:"dedent"},{key:"ArrowLeft",modKey:!0,shiftKey:"any",command:"moveToLineStart"},{key:"ArrowRight",modKey:!0,shiftKey:"any",command:"moveToLineEnd"},{key:"ArrowUp",modKey:!0,shiftKey:"any",command:"moveToDocumentStart"},{key:"ArrowDown",modKey:!0,shiftKey:"any",command:"moveToDocumentEnd"},{key:"ArrowUp",altKey:!0,shiftKey:!0,command:"moveListItemUp"},{key:"ArrowDown",altKey:!0,shiftKey:!0,command:"moveListItemDown"},{key:"a",modKey:!0,command:"selectAll"},{key:"b",modKey:!0,command:"toggleBold"},{key:"e",modKey:!0,command:"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 eJ($,M=g3){return M.find((J)=>{let Z=J.shiftKey==="any"?!0:(J.shiftKey??!1)===($.shiftKey??!1);return J.key.toLowerCase()===$.key.toLowerCase()&&(J.altKey??!1)===($.altKey??!1)&&Z&&(J.modKey??!1)===Boolean($.metaKey||$.ctrlKey)})?.command??null}function ZZ($){let M=$.documentIndex.regions.find((Y)=>Y.id===$.selection.anchor.regionId),J=$.documentIndex.regions.find((Y)=>Y.id===$.selection.focus.regionId),Z=(M?.start??0)+$.selection.anchor.offset,X=(J?.start??0)+$.selection.focus.offset;return{end:Math.max(Z,X),start:Math.min(Z,X)}}function I3($){let M=p3($);if(!M)return"";let J=$.documentIndex.regions.find((Z)=>Z.id===M.regionId);if(!J)return"";return J.text.slice(M.startOffset,M.endOffset)}function p3($){let M=vV($);if(M.start.regionId!==M.end.regionId||M.start.offset===M.end.offset)return null;return{endOffset:M.end.offset,regionId:M.start.regionId,startOffset:M.start.offset}}var $Z=28,MZ=18;function XZ($,M){if(!$)return;let J=$.getBoundingClientRect();if(M.clientY<J.top+$Z){$.scrollTop=Math.max(0,$.scrollTop-MZ);return}if(M.clientY>J.bottom-$Z)$.scrollTop+=MZ}function vV($){let M=JZ($.documentIndex.regions,$.selection.anchor.regionId,$.selection.anchor.offset),J=JZ($.documentIndex.regions,$.selection.focus.regionId,$.selection.focus.offset);return M<=J?{end:$.selection.focus,start:$.selection.anchor}:{end:$.selection.anchor,start:$.selection.focus}}function JZ($,M,J){let Z=$.findIndex((X)=>X.id===M);if(Z===-1)return-1;return Z*1e6+J}var IV=1024,QZ=16;function qZ({applyNextState:$,editorState:M,editorStateRef:J,editorViewportState:Z,inputRef:X,keybindings:Y,onActivity:Q,onImagePaste:K}){let q=pV(),D=()=>J.current??M,A=YZ(!1),V=YZ(!1),U=U0((F)=>{if(!F)return;Q(),$(F)}),G=U0(()=>{let F=X.current;if(!F)return;if(typeof document>"u")return;let C=document.execCommand;if(typeof C!=="function")return;try{A.current=!0,C.call(document,"insertText",!1,""),C.call(document,"delete")}catch{}finally{A.current=!1,S4(F,D())}}),_=U0(()=>{if(V.current)return;V.current=!0,G()}),N=U0(()=>{G()}),H=U0((F)=>{if(!q)return;let C=X.current;if(!C)return;let v=Z.get(),h=o0(D(),v,F);if(!h)return;C.style.top=`${h.top}px`,C.style.left=`${h.left}px`,C.style.height=`${h.height}px`}),E=U0((F)=>{let C=X.current;if(!C)return;H(F??D().selection.focus),C.focus({preventScroll:!q}),S4(C,D()),_()}),L=U0((F,C)=>{let h=DZ(C,$8(F)).replace(/\r\n/g,`
|
|
31
|
+
`).split(/(\n)/),g=F;for(let O of h){if(O.length===0)continue;let w=O===`
|
|
32
|
+
`?f5(g):M4(g,O);if(!w)continue;g=w}return g===F?null:g}),W=U0((F,C,v)=>{let h=F.selection.focus,g={regionId:h.regionId,offset:Math.max(0,h.offset-C)},O=X0(F,{anchor:g,focus:h});return m5(O,v)}),R=U0((F)=>{if(A.current)return;let C=D(),v=rV(F.inputType);if(F.inputType==="insertText"){if(!F.data)return;F.preventDefault();let h=KZ(F.target);if(h>0){U(W(C,h,F.data));return}let g=dV(C,F.data);if(g>0){let O=F.data.slice(g);if(O.length>0)U(L(C,O));return}U(L(C,F.data));return}if(F.inputType==="insertReplacementText"){if(!F.data)return;F.preventDefault();let h=KZ(F.target);U(W(C,h,F.data));return}if(lV(F.inputType)){F.preventDefault(),U(f5(C));return}if(v==="backward"){F.preventDefault(),U(c6(C));return}if(v==="forward"){F.preventDefault(),U(a6(C));return}if(F.inputType==="historyUndo"){F.preventDefault(),U(s6(C)),N();return}if(F.inputType==="historyRedo"){F.preventDefault(),U(i6(C)),N();return}}),f=U0((F)=>{let C=D(),v=F.currentTarget.value,h=$8(C);if(A.current)return;if(DZ(v,h).length===0){S4(F.currentTarget,C);return}U(L(C,v))}),I=U0((F)=>{let C=cV(D(),Z.get(),F.nativeEvent,Y);if(!C)return;F.preventDefault(),U(C)}),B=U0((F)=>{let C=I3(D());if(!C)return;F.preventDefault(),F.clipboardData.setData("text/plain",C)}),b=U0((F)=>{let C=D(),v=I3(C);if(!v)return;F.preventDefault(),F.clipboardData.setData("text/plain",v),U(S5(C))}),z=U0(async(F)=>{let v=(K?[...F.clipboardData.items].find((g)=>g.kind==="file"&&g.type.startsWith("image/")):void 0)?.getAsFile()??null;if(v&&K){F.preventDefault();let g=await K(v);if(g)U(i7(D(),g));return}let h=F.clipboardData.getData("text/plain");if(h.length===0)return;F.preventDefault(),U(m5(D(),h))}),T=U0(()=>{Q();let F=X.current;if(F)S4(F,D())}),P=U0((F)=>{if(Q(),F.target.matches(":focus-visible"))E()});l3(()=>{let F=X.current;if(!F)return;S4(F,M)},[M,X]),hV(()=>{H(M.selection.focus)},[M,H]),l3(()=>{let F=X.current;if(!F)return;let C=(v)=>R(v);return F.addEventListener("beforeinput",C),()=>F.removeEventListener("beforeinput",C)},[X,R]);let y={onCopy:B,onCut:b,onPaste:z,...q?{}:{onKeyDown:I}};return{canvasHandlers:{...y,onFocus:P},focus:E,inputHandlers:{...y,onFocus:T,onInput:f}}}var AZ="";function pV(){let[$,M]=gV(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return!1;return window.matchMedia("(pointer: coarse)").matches});return l3(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return;let J=window.matchMedia("(pointer: coarse)"),Z=(X)=>M(X.matches);return J.addEventListener?.("change",Z),()=>J.removeEventListener?.("change",Z)},[]),$}function lV($){return $==="insertLineBreak"||$==="insertParagraph"}function KZ($){let M=$,J=M?.selectionStart??0,Z=M?.selectionEnd??J;return Math.max(0,Z-J)}function dV($,M){if(M.length<QZ)return 0;let J=$8($,M.length),Z=Math.min(J.length,M.length);for(let X=Z;X>=QZ;X--)if(J.endsWith(M.slice(0,X)))return X;return 0}function rV($){switch($){case"deleteContentBackward":case"deleteComposedCharacterBackward":case"deleteSoftLineBackward":case"deleteHardLineBackward":case"deleteWordBackward":return"backward";case"deleteContentForward":case"deleteSoftLineForward":case"deleteHardLineForward":case"deleteWordForward":return"forward";default:return null}}function xV($){return $.replaceAll(AZ,"")}function $8($,M=IV){let{anchor:J,focus:Z}=$.selection;if(J.regionId!==Z.regionId||J.offset!==Z.offset)return"";let X=$.documentIndex.regionIndex.get(Z.regionId);if(!X)return"";return X.text.slice(Math.max(0,Z.offset-M),Z.offset)}function DZ($,M){let J=xV($);return J.startsWith(M)?J.slice(M.length):J}function S4($,M){let J=$8(M),Z=`${AZ}${J}`;$.value=Z,$.setSelectionRange(Z.length,Z.length)}function cV($,M,J,Z){if(J.key==="Delete")return a6($);let X=eJ(J,Z);if(X){if(X==="moveToLineStart"||X==="moveToLineEnd")return e6($,M.layout,X==="moveToLineStart"?"Home":"End",J.shiftKey);if(X==="moveToDocumentStart"||X==="moveToDocumentEnd")return $3($,X==="moveToDocumentStart"?"start":"end",J.shiftKey);switch(X){case"insertLineBreak":return f5($);case"deleteBackward":return c6($);case"indent":return k7($);case"dedent":return u7($);case"moveListItemUp":return v7($);case"moveListItemDown":return h7($);case"toggleBold":return k5($);case"toggleItalic":return u5($);case"toggleStrikethrough":return v5($);case"toggleUnderline":return h5($);case"toggleCode":return c7($);case"undo":return s6($);case"redo":return i6($);case"selectAll":return S7($)}}if(J.key==="ArrowLeft"||J.key==="ArrowRight")return o6($,J.key==="ArrowLeft"?-1:1,J.shiftKey);if(J.key==="ArrowUp"||J.key==="ArrowDown")return n6($,M.layout,J.key==="ArrowUp"?-1:1,J.shiftKey);if(J.key==="PageUp"||J.key==="PageDown")return t6($,M.layout,J.key==="PageUp"?-1:1,J.shiftKey);if(J.key.length===1&&!J.altKey&&!J.ctrlKey&&!J.metaKey)return M4($,J.key);return null}import{useEffectEvent as d3,useLayoutEffect as aV,useMemo as sV,useState as iV}from"react";function UZ({editorState:$,editorStateRef:M,editorViewportState:J,onViewportScroll:Z,scrollContainerRef:X,scheduleOverlayRender:Y,userPresence:Q}){let K=sV(()=>{if(!Q||Q.length===0)return;return F5($.documentIndex,Q)},[$.documentIndex,Q]),[q,D]=iV(void 0),A=d3(()=>{if(K===void 0){if(q!==void 0)D(void 0)}else D(S2(M.current??$,J.get(),K));Y()}),V=d3((G)=>{if(K===void 0){if(q!==void 0)D(void 0);return}let _=S2(M.current??$,G,K);if(oV(q,_))return;D(_)});aV(()=>{A()},[K]);let U=d3((G)=>{if(!G.viewport||G.viewport.status==="unresolved")return;let _=X.current;if(!_)return;_.scrollTop=G.viewport.scrollTop,Z(_)});return{presence:q,scrollToPresence:U,refreshPresence:V}}function oV($,M){if($===M)return!0;if($===void 0||M===void 0||$.length!==M.length)return!1;return $.every((J,Z)=>{let X=M[Z];return J.id===X.id&&nV(J.viewport,X.viewport)})}function nV($,M){if($===M)return!0;if($===null||M===null)return!1;if($.status==="unresolved")return M.status==="unresolved";if(M.status==="unresolved")return!1;return $.status===M.status&&$.scrollTop===M.scrollTop}import{useEffect as tV,useEffectEvent as m1,useRef as k4}from"react";function VZ({editorStateRef:$,renderContent:M,renderOverlay:J,renderViewport:Z}){let X=k4(null),Y=k4(!1),Q=k4(!1),K=k4(!1),q=k4(!1),D=m1(()=>{if(typeof window>"u"){Z();return}Y.current=!0,G()}),A=m1(()=>{if(typeof window>"u"){M(),J();return}Q.current=!0,G()}),V=m1(()=>{if(typeof window>"u"){M();return}K.current=!0,G()}),U=m1(()=>{if(typeof window>"u"){J();return}q.current=!0,G()}),G=m1(()=>{if(typeof window>"u"||X.current!==null)return;X.current=window.requestAnimationFrame(()=>{_()})}),_=m1(()=>{X.current=null;let H=Y.current,E=Q.current,L=K.current,W=q.current;if(Y.current=!1,Q.current=!1,K.current=!1,q.current=!1,H){Z(),N();return}if(E){M(),J(),N();return}if(L)M(),N();if(W)J()}),N=m1(()=>{let H=$.current;if(!H||!j6(H,performance.now()))return;K.current=!0,G()});return tV(()=>{return()=>{if(typeof window>"u"||X.current===null)return;window.cancelAnimationFrame(X.current),X.current=null}},[]),{scheduleContentPaint:V,scheduleFullPaint:A,scheduleFullRender:D,scheduleOverlayPaint:U}}import{useEffectEvent as r3,useLayoutEffect as GZ,useMemo as x3,useRef as c3,useState as NZ}from"react";function _Z({applyNextState:$,autoScrollDuringDrag:M,canShowSelectionLeaf:J,editorState:Z,editorStateRef:X,editorViewportState:Y,focusInput:Q,onActivity:K,resolvePoint:q,threads:D}){let A=x3(()=>Y0(Z),[Z]),V=x3(()=>p3(Z),[Z]),U=x3(()=>P5(Z),[Z]),[G,_]=NZ(null),[N,H]=NZ(null),E=c3(null),L=c3(null),W=c3(null);GZ(()=>{let z=eV(Z,Y.get(),A);_((T)=>XG(T,z)?T:z)},[Z,Y,A.end.offset,A.end.regionId,A.start.offset,A.start.regionId]),GZ(()=>{let z=MG({canShowSelectionLeaf:J,currentLeaf:N,activeMarks:U,handles:G,selectionRange:V,threads:D});H((T)=>ZG(T,z)?T:z)},[U,J,G,N,V,D]);let R=r3((z,T=!0)=>{H((P)=>P?.kind==="create"?{animateInitialComment:T,kind:"thread",left:P.left,threadIndex:z,top:P.top}:P)}),f=r3((z)=>{if(z&&W.current===z.pointerId&&z.currentTarget.hasPointerCapture(z.pointerId))z.currentTarget.releasePointerCapture(z.pointerId);E.current=null,L.current=null,W.current=null}),I=r3((z)=>{let T=X.current,P=L.current,y=q(z);if(!y||!T||!P||W.current!==z.pointerId)return;let F=m2(T,Y.get(),y,P);if(!F)return;z.preventDefault(),z.stopPropagation(),K(),M(z),$(X0(T,{anchor:P,focus:F}))}),B=(z)=>({onPointerCancel:(T)=>{f(T)},onPointerDown:(T)=>{let P=X.current??Z,y=QG(A,z),F=z==="start"?A.start:A.end;if(!G)return;T.preventDefault(),T.stopPropagation(),W.current=T.pointerId,L.current=y,E.current=z,T.currentTarget.setPointerCapture(T.pointerId),K(),Q(),$(X0(P,{anchor:y,focus:F}))},onPointerMove:(T)=>{if(E.current!==z)return;I(T)},onPointerUp:(T)=>{if(E.current===z)I(T);f(T)}});return{handle:G?{start:{...G.start,props:B("start")},end:{...G.end,props:B("end")}}:null,leaf:N,promoteLeafToThread:R}}function eV($,M,J){if(J.collapsed)return null;let Z=o0($,M,J.start),X=o0($,M,J.end);if(!Z||!X)return null;return{end:{left:X.left,top:X.top+X.height},start:{left:Z.left,top:Z.top}}}function $G($,M,J){return{activeMarks:J,kind:"create",left:M.start.left,selection:$,top:M.end.top}}function MG({activeMarks:$,canShowSelectionLeaf:M,currentLeaf:J,handles:Z,selectionRange:X,threads:Y}){if(!M||!X||!Z)return null;if(J?.kind==="thread")return Y[J.threadIndex]?J:null;return $G(X,Z,$)}function JG($,M){return $?.kind==="create"&&$.left===M.left&&$.selection.regionId===M.selection.regionId&&$.selection.startOffset===M.selection.startOffset&&$.selection.endOffset===M.selection.endOffset&&YG($.activeMarks,M.activeMarks)&&$.top===M.top}function ZG($,M){if($===M)return!0;if(!$||!M||$.kind!==M.kind)return!1;if($.kind==="create"&&M.kind==="create")return JG($,M);return $.kind==="thread"&&M.kind==="thread"&&$.animateInitialComment===M.animateInitialComment&&$.left===M.left&&$.threadIndex===M.threadIndex&&$.top===M.top}function XG($,M){if($===M)return!0;if(!$||!M)return!1;return $.start.left===M.start.left&&$.start.top===M.start.top&&$.end.left===M.end.left&&$.end.top===M.end.top}function YG($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function QG($,M){return M==="start"?$.end:$.start}import{useEffect as KG,useMemo as zZ,useState as DG}from"react";var u4={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)"},v4={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)"},FZ={...u4,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)"},HZ={...v4,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 EZ($){let M=zZ(()=>AG($),[$]),[J,Z]=DG(M.light),X=zZ(()=>UG(J),[J]);return KG(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function"){Z(M.light);return}let Y=window.matchMedia("(prefers-color-scheme: dark)"),Q=()=>{Z(Y.matches?M.dark:M.light)};if(Q(),typeof Y.addEventListener==="function")return Y.addEventListener("change",Q),()=>{Y.removeEventListener("change",Q)};return Y.addListener(Q),()=>{Y.removeListener(Q)}},[M]),{theme:J,themeStyles:X}}function qG($){return"light"in $&&"dark"in $}function AG($){if(!$)return{dark:v4,light:u4};if(qG($))return $;return{dark:$,light:$}}function UG($){return{"--documint-background":$.background,"--documint-leaf-button-bg":$.leafButtonBackground,"--documint-leaf-button-border":$.leafButtonBorder,"--documint-leaf-button-text":$.leafButtonText,"--documint-leaf-accent":$.leafAccent,"--documint-leaf-bg":$.leafBackground,"--documint-leaf-border":$.leafBorder,"--documint-leaf-font-family":'"Avenir Next", "Segoe UI", sans-serif',"--documint-leaf-shadow":$.leafShadow??void 0,"--documint-leaf-secondary-text":$.leafSecondaryText,"--documint-leaf-resolved-bg":$.leafResolvedBackground,"--documint-leaf-resolved-border":$.leafResolvedBorder,"--documint-leaf-text":$.leafText,"--documint-mention-bg":$.mentionBackground??void 0,"--documint-mention-text":$.mentionText??void 0,"--documint-selection-handle-bg":$.selectionHandleBackground,"--documint-selection-handle-border":$.selectionHandleBorder}}import{useEffect as NG,useEffectEvent as r0,useRef as a3,useState as M8}from"react";import{useMemo as VG}from"react";function WZ($){return VG(()=>GG({current:null},$),[$])}function GG($,M){return{peek(){return $.current},get(){let J=$.current;if(J!==null)return J;let Z=M();return $.current=Z,Z},invalidate(){$.current=null}}}function BZ($,M){let J=M.getBoundingClientRect();return{x:$.clientX-J.left+M.scrollLeft,y:$.clientY-J.top+M.scrollTop}}function PZ({editorState:$,editorStateRef:M,renderResources:J,theme:Z}){let X=a3(B1()),Y=a3(null),Q=a3({height:240,top:0}),[K,q]=M8(0),[D,A]=M8(240),[V,U]=M8(0),[G,_]=M8(240),N=_G(K),H=r0(()=>{let y=M.current??$,F=Q.current;return Q6(y,{height:F.height,paddingX:Z.paddingX,paddingY:Z.paddingY,top:F.top,width:N},X.current,J)}),E=WZ(H),L=r0((y)=>{_((F)=>{let C=HG(y,Q.current.height);return F===C?F:C})}),W=r0((y)=>{Q.current={...Q.current,top:y},U((F)=>F===y?F:y),E.invalidate()}),R=r0((y)=>{let F=FG(y),C=F.top!==Q.current.top;if(Q.current=F,U((v)=>v===F.top?v:F.top),C)E.invalidate()}),f=r0((y)=>{let F=Y.current;if(!F)return W(y),y;F.scrollTop=y;let C=F.scrollTop;return W(C),C}),I=r0(()=>{return Y.current?.scrollTop??Q.current.top}),B=r0((y,F)=>{let C=y!==null&&y.documentIndex!==F.documentIndex,v=E.peek();if(!(!C||!v||v.layout.regionLineIndices.has(F.selection.focus.regionId)))E.invalidate()}),b=r0(()=>{return E.invalidate(),E.get()}),z=r0((y)=>{let F=Y.current;return F?BZ(y,F):null}),T=r0((y)=>{XZ(Y.current,y)});return NG(()=>{let y=Y.current;if(!y||typeof ResizeObserver>"u")return;let F=new ResizeObserver((C)=>{let v=C[0];if(!v)return;let h=Math.max(0,Math.floor(v.contentRect.width)),g=yZ(y);Q.current={...Q.current,height:g},q((O)=>O===h?O:h),A((O)=>O===g?O:g)});return F.observe(y),()=>F.disconnect()},[Y]),{actions:{autoScrollDuringDrag:T,getScrollTop:I,observePreparedViewport:L,observeScrollContainer:R,prepareNextPaint:b,reconcileEditorState:B,resolvePoint:z,scrollTo:f},props:{getScrollContainer:(y)=>({onScroll:(F)=>{R(F.currentTarget),y?.onScroll?.(F)},ref:Y}),scrollContent:{style:{height:`${G}px`}}},refs:{scrollContainer:Y},state:{layoutWidth:N,preparedViewport:E,scrollContentHeight:G,surfaceWidth:K,viewportHeight:D,viewportTop:V}}}function _G($){return Math.max(240,Math.floor($||480))}function yZ($){return Math.max(240,$.clientHeight)}function FG($){return{height:yZ($),top:$.scrollTop}}function HG($,M){return Math.max(M,Math.ceil($.totalHeight+24))}function zG(){if(typeof window>"u")return 1;return Math.max(1,window.devicePixelRatio||1)}function s3($,{paintHeight:M,paintTop:J,width:Z}){if(!$)return null;let X=Math.max(240,Math.ceil(M)),Y=zG();$.width=Math.ceil(Z*Y),$.height=Math.ceil(X*Y),$.style.width=`${Z}px`,$.style.height=`${X}px`,$.style.transform=`translateY(${J}px)`;let Q=$.getContext("2d");if(!Q)return null;return{context:Q,devicePixelRatio:Y,height:X,width:Z}}function i3($,M){return $.activeBlockType===M.activeBlockType&&$.activeCommentThreadIndex===M.activeCommentThreadIndex&&$.activeSpanKind===M.activeSpanKind&&$.canonicalContent===M.canonicalContent&&$.characterCount===M.characterCount&&$.commentThreadCount===M.commentThreadCount&&$.layoutWidth===M.layoutWidth&&$.resolvedCommentCount===M.resolvedCommentCount&&$.selectionFrom===M.selectionFrom&&$.selectionTo===M.selectionTo}function bZ($,M){if(!M?.length||!$?.length)return;let J=new Map($.map((X)=>[X.id,X])),Z=[];for(let X of M){let Y=J.get(X.userId);if(!Y)continue;Z.push({...Y,color:X.color,cursor:X.cursor})}return Z.length===0?void 0:Z}function TZ($,M){if(!$)return{didReconcile:!1,state:M};let J=EG($,M)??jG($,M);return J?{didReconcile:!0,state:J}:{didReconcile:!1,state:M}}function EG($,M){let J=WG($,M);return J?X0(M,J,!1):null}function WG($,M){if(t3($.selection.anchor,$.selection.focus)){let Y=o3($,M,$.selection.focus,"neutral");return Y?{anchor:Y,focus:Y}:null}let J=TG($),Z=o3($,M,$.selection.anchor,J.anchor),X=o3($,M,$.selection.focus,J.focus);return Z&&X?{anchor:Z,focus:X}:null}function o3($,M,J,Z){let X=$.documentIndex.regionIndex.get(J.regionId);if(!X)return null;let Y=n3(X,M);if(!Y)return null;return{offset:PG(X.text,Y.text,J.offset,Z),regionId:Y.id}}function n3($,M){let J=M.documentIndex.regionIndex.get($.id);if(J)return J;if($.text.length===0)return null;let Z=BG($,M);if(Z)return Z;return M.documentIndex.regionPathIndex.get($.path)??null}function BG($,M){let J=null;for(let Z of M.documentIndex.regions){if(Z.blockType!==$.blockType||Z.text!==$.text)continue;if(J)return null;J=Z}return J}function PG($,M,J,Z){let X=O0(J,0,$.length),{prefix:Y,suffix:Q}=b8($,X,X),K=yG(M,Y,Q);if(K!==null)return K;let q=bG(M,Y),D=wG(M,Q);if(Z==="before-suffix")return D??q??O0(J,0,M.length);return q??D??O0(J,0,M.length)}function yG($,M,J){let Z=c1($,M,J).filter((X)=>X.startOffset===X.endOffset);return Z.length===1?Z[0].startOffset:null}function bG($,M){let J=v0($,M);return J.length===1?J[0]+M.length:null}function wG($,M){let J=v0($,M);return J.length===1?J[0]:null}function TG($){let{anchor:M,focus:J}=$.selection;if(t3(M,J))return{anchor:"neutral",focus:"neutral"};return OG($,M,J)<=0?{anchor:"before-suffix",focus:"after-prefix"}:{anchor:"after-prefix",focus:"before-suffix"}}function OG($,M,J){let Z=$.documentIndex.regionOrderIndex.get(M.regionId),X=$.documentIndex.regionOrderIndex.get(J.regionId);if(Z===void 0||X===void 0)return 0;return Z===X?M.offset-J.offset:Z-X}function jG($,M){if(!t3($.selection.anchor,$.selection.focus))return null;let J=LG($);if(!J)return null;let Z=CG($,M,J);if(Z===null)return null;return RG(M,Z)}function LG($){let M=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!M||M.blockType!=="paragraph"||M.text.length>0)return null;return $.documentIndex.blockIndex.get(M.blockId)?.parentBlockId===null?M:null}function CG($,M,J){let Z=wZ($,J.rootIndex,"before"),X=wZ($,J.rootIndex,"after"),Y=Z?n3(Z,M):null,Q=X?n3(X,M):null;if(Y&&Q)return Y.rootIndex<Q.rootIndex?Q.rootIndex:null;if(Y)return Y.rootIndex+1;if(Q)return Q.rootIndex;return null}function RG($,M){let J=W1($.documentIndex.document,M,0,[d({text:""})]),Z={...$,documentIndex:Z2($.documentIndex,J,M,0)},X=p2(Z.documentIndex,$0(M));return X?X0(Z,X,!1):null}function wZ($,M,J){let Z=J==="before"?-1:1;for(let X=M+Z;X>=0&&X<$.documentIndex.roots.length;X+=Z){let Y=fG($,X,J);if(Y)return Y}return null}function fG($,M,J){let Z=$.documentIndex.roots[M]?.regions??[],X=J==="before"?Z.length-1:0,Y=J==="before"?-1:1;for(let Q=X;Q>=0&&Q<Z.length;Q+=Y){let K=Z[Q];if(K&&K.text.length>0)return K}return null}function t3($,M){return $.regionId===M.regionId&&$.offset===M.offset}import{jsx as x,jsxs as Z8,Fragment as IG}from"react/jsx-runtime";function X8({blocks:$}){return x(IG,{children:$.map((M)=>mG(M))})}function mG($){switch($.type){case"blockquote":return x("blockquote",{className:"preview-block preview-block-blockquote",children:x(X8,{blocks:$.children})},$.id);case"code":return Z8("div",{className:"preview-block preview-block-code",children:[x("div",{className:"preview-rich-header",children:uG($.language,$.meta)}),x("pre",{children:x("code",{children:$.source||" "})})]},$.id);case"heading":{let M=`h${$.depth}`;return x(M,{className:"preview-block preview-block-heading",children:J8($.children)},$.id)}case"list":return $.ordered?x("ol",{className:"preview-block preview-block-list",start:$.start??1,children:$.items.map((M)=>e3(M))},$.id):x("ul",{className:"preview-block preview-block-list",children:$.items.map((M)=>e3(M))},$.id);case"listItem":return e3($);case"paragraph":return x("p",{className:"preview-block preview-block-paragraph",children:J8($.children)},$.id);case"table":return Z8("div",{className:"preview-block preview-block-table",children:[x("div",{className:"preview-rich-header",children:vG($.rows.length,$.rows[0]?.cells.length??0,$.align.filter((M)=>M!==null).length)}),x("div",{className:"preview-table-scroll",children:x("table",{children:x("tbody",{children:$.rows.map((M)=>x("tr",{children:M.cells.map((J)=>x("td",{children:J8(J.children)},J.id))},M.id))})})})]},$.id);case"thematicBreak":return x("hr",{className:"preview-block preview-block-rule"},$.id);case"directive":return x("pre",{className:`preview-block preview-block-directive preview-block-directive-${$.name}`,children:$.body},$.id);case"unsupported":return x("pre",{className:"preview-block preview-block-unsupported",children:$.source},$.id)}}function e3($){return x("li",{className:"preview-block preview-block-list-item",children:x(X8,{blocks:$.children})},$.id)}function J8($){return $.map((M)=>{switch(M.type){case"break":return x("br",{},M.id);case"image":return Z8("span",{className:"preview-inline preview-inline-image",children:[x("img",{alt:M.alt??"",src:M.url,title:M.title??""}),Z8("span",{children:[x("strong",{children:hG(M.alt)}),x("small",{children:gG(M.url,M.title)})]})]},M.id);case"inlineCode":return x("code",{className:"preview-inline preview-inline-code",children:M.code},M.id);case"link":return SG(M);case"text":return x("span",{className:"preview-inline",children:kG(M.text,M.marks)},M.id);case"unsupported":return x("span",{className:"preview-inline preview-inline-unsupported",children:M.source},M.id)}})}function SG($){return x("a",{className:"preview-inline preview-inline-link",href:$.url,children:J8($.children)},$.id)}function kG($,M){let J=$;for(let Z of M)switch(Z){case"strikethrough":J=x("del",{children:J});break;case"italic":J=x("em",{children:J});break;case"bold":J=x("strong",{children:J});break;case"underline":J=x("ins",{children:J});break}return J}function uG($,M){return[$??"plain text",M].filter(Boolean).join(" • ")}function vG($,M,J){let Z=J>0?`${J} aligned ${J===1?"column":"columns"}`:"no alignment";return`${$} ${$===1?"row":"rows"} • ${M} ${M===1?"column":"columns"} • ${Z}`}function hG($){return $?.trim()?$:"Untitled image"}function gG($,M){return M?.trim()?`${M} • ${$}`:$}var OZ=`/* Base Documint host and SSR-fallback styles. */
|
|
34
33
|
|
|
35
34
|
.documint {
|
|
36
35
|
display: grid;
|
|
@@ -180,7 +179,7 @@ ${M.text}`:M.text}function KY($){return $.filter((M)=>M.regions.length>0).map((M
|
|
|
180
179
|
display: block;
|
|
181
180
|
}
|
|
182
181
|
|
|
183
|
-
.documint-
|
|
182
|
+
.documint-resize-handle {
|
|
184
183
|
position: absolute;
|
|
185
184
|
z-index: 4;
|
|
186
185
|
width: 1.2rem;
|
|
@@ -192,21 +191,14 @@ ${M.text}`:M.text}function KY($){return $.filter((M)=>M.regions.length>0).map((M
|
|
|
192
191
|
pointer-events: auto;
|
|
193
192
|
touch-action: none;
|
|
194
193
|
cursor: grab;
|
|
194
|
+
transform: translate(-50%, -50%);
|
|
195
195
|
|
|
196
196
|
&:active {
|
|
197
197
|
cursor: grabbing;
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
.documint-
|
|
202
|
-
transform: translate(-70%, -82%);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
.documint-selection-handle-end {
|
|
206
|
-
transform: translate(-30%, -39%);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
.documint-selection-handle-knob {
|
|
201
|
+
.documint-resize-handle-knob {
|
|
210
202
|
position: absolute;
|
|
211
203
|
inset: 0;
|
|
212
204
|
display: block;
|
|
@@ -373,7 +365,7 @@ ${M.text}`:M.text}function KY($){return $.filter((M)=>M.regions.length>0).map((M
|
|
|
373
365
|
white-space: nowrap;
|
|
374
366
|
}
|
|
375
367
|
}
|
|
376
|
-
`;var
|
|
368
|
+
`;var jZ=`/* Leaf overlay styles, ordered outer → inner:
|
|
377
369
|
1. Anchor — viewport positioning + hover bridge
|
|
378
370
|
2. Shell — bordered container (with state and content variants)
|
|
379
371
|
3. Menu — shared dropdown surface (toolbar menus, completion popover)
|
|
@@ -883,7 +875,7 @@ ${M.text}`:M.text}function KY($){return $.filter((M)=>M.regions.length>0).map((M
|
|
|
883
875
|
font-weight: 500;
|
|
884
876
|
white-space: nowrap;
|
|
885
877
|
}
|
|
886
|
-
`;var
|
|
878
|
+
`;var LZ=`/* Toolbar-specific styles (button, group, divider, and the menu trigger
|
|
887
879
|
shell + chevron). The menu container/item/divider styles themselves
|
|
888
880
|
live one level up in \`overlays/leaves/styles.css\` as \`.documint-leaf-menu*\`
|
|
889
881
|
so they can be shared by the toolbar's nested menu and other surfaces
|
|
@@ -965,6 +957,6 @@ ${M.text}`:M.text}function KY($){return $.filter((M)=>M.regions.length>0).map((M
|
|
|
965
957
|
transform: rotate(180deg);
|
|
966
958
|
}
|
|
967
959
|
}
|
|
968
|
-
`;var
|
|
969
|
-
${
|
|
970
|
-
${
|
|
960
|
+
`;var CZ=`${OZ}
|
|
961
|
+
${jZ}
|
|
962
|
+
${LZ}`;import{jsx as Q0,jsxs as Q8,Fragment as cG}from"react/jsx-runtime";var xG=2,RZ={activeBlockType:null,activeCommentThreadIndex:null,activeSpanKind:null,canonicalContent:"",characterCount:0,commentThreadCount:0,layoutWidth:0,resolvedCommentCount:0,selectionFrom:0,selectionTo:0};function mZ({className:$,content:M,keybindings:J,onCommentChanged:Z,onContentChanged:X,onStateChanged:Y,presence:Q,storage:K,theme:q,users:D}){let A=S1(null),V=S1(null),U=S1(null),G=S1(null),_=S1(M),N=S1(""),H=S1(RZ),[E,L]=$9(!1),{theme:W,themeStyles:R}=EZ(q),[f,I]=$9(RZ),B=e0(()=>H3(M),[M]),b=e0(()=>i5(B),[B]),[z,T]=$9(()=>i2(B)),P=oJ(z.documentIndex.imageUrls,K),y=P.resources,F=e0(()=>[...y?.images.values()??[]].some((j)=>j.status==="loading"),[y]);G.current=z,N.current||=b;let C=PZ({editorState:z,editorStateRef:G,renderResources:y,theme:W}),{actions:v,props:h,refs:g,state:O}=C,{autoScrollDuringDrag:w,getScrollTop:m,observePreparedViewport:S,observeScrollContainer:c,prepareNextPaint:l,reconcileEditorState:F0,resolvePoint:x0,scrollTo:f0}=v,{layoutWidth:m0,preparedViewport:c0,scrollContentHeight:K8,surfaceWidth:D8,viewportHeight:h4,viewportTop:q8}=O,{scrollContainer:W2}=g,g4=e0(()=>l2(z),[z]),S0=e0(()=>L0(z),[z]),B0=e0(()=>Y0(z),[z]),k1=e0(()=>{if(!D?.length)return;return[{trigger:"@",items:D.map((j)=>({label:j.fullName??j.username,id:j.id}))}]},[D]),A8=e0(()=>bZ(D,Q),[D,Q]),U8=e0(()=>fZ(z,S0.liveRanges),[S0.liveRanges,z]),u1=Boolean(X),a=()=>G.current??z,I4=E2((j,k)=>{let p=l2(j),s=L0(j),t=ZZ(j),J0={activeBlockType:p.block?.nodeType??null,activeCommentThreadIndex:fZ(j,s.liveRanges),activeSpanKind:p.span.kind==="none"?null:p.span.kind,canonicalContent:k,characterCount:k.length,commentThreadCount:s.threads.length,layoutWidth:m0,resolvedCommentCount:S8(s.threads),selectionFrom:t.start,selectionTo:t.end};if(I((r4)=>i3(r4,J0)?r4:J0),!i3(H.current,J0))H.current=J0,Y?.(J0)}),M0=E2((j)=>{if(!j)return;let k=G.current??z,p=k.documentIndex!==j.documentIndex,s=w5(k,j);if(G.current=j,T(j),F0(k,j),s)G8();if(!p)return;let t=p0(j),J0=i5(t);N.current=J0,_.current=J0,X?.(J0,t)}),V8=(j)=>{Z?.(j)},M9=(j)=>{let k=p0(a()).comments[j],p=k?.comments.at(-1);if(!k||!p)return;V8({kind:"added",comment:p,mentionedUserIds:b3(p.body,k1),thread:k,threadIndex:j})},SZ=(j,k,p)=>{let s=p0(a()).comments[j],t=s?.comments[k];if(!s||!t)return;V8({kind:"edited",comment:t,previousBody:p,mentionedUserIds:b3(t.body,k1),thread:s,threadIndex:j})},J9=(j,k,p)=>{V8({kind:"deleted",comment:p,thread:k,threadIndex:j})},Z9=E2((j=c0.peek())=>{if(!j)return;let k=s3(A.current,{paintHeight:j.paintHeight,paintTop:j.paintTop,width:m0});if(!k)return;let{context:p,devicePixelRatio:s,height:t,width:J0}=k;Y3(z,j,p,{activeBlockId:g4.block?.blockId??null,activeRegionId:z.selection.focus.regionId,activeThreadIndex:K9??U8,devicePixelRatio:s,height:t,liveCommentRanges:S0.liveRanges,normalizedSelection:B0,now:performance.now(),resources:y,theme:W,width:J0})}),X9=E2((j=c0.peek())=>{if(!j)return;let k=s3(V.current,{paintHeight:j.paintHeight,paintTop:j.paintTop,width:m0});if(!k)return;let{context:p,devicePixelRatio:s,height:t,width:J0}=k;Q3(z,j,p,{devicePixelRatio:s,height:t,normalizedSelection:B0,presence:l4.presence,showCaret:B0.start.regionId!==B0.end.regionId||B0.start.offset!==B0.end.offset||h1.isVisible(),theme:W,width:J0})}),kZ=E2(()=>{let j=l();S(j),l4.refreshPresence(j),Z9(j),X9(j)}),{scheduleContentPaint:G8,scheduleFullPaint:Y9,scheduleFullRender:v1,scheduleOverlayPaint:Q9}=VZ({editorStateRef:G,renderContent:Z9,renderOverlay:X9,renderViewport:kZ}),uZ=h.getScrollContainer({onScroll:()=>v1()}),h1=xJ({canShowInsertionLeaf:Boolean(X),canShowTableLeaf:Boolean(X),commentState:S0,editorState:z,editorViewportState:c0,getScrollTop:m,layoutWidth:m0,onVisibilityChange:Q9,resources:y,scrollContentHeight:K8,scrollTo:f0,viewportHeight:h4}),vZ=cJ(h1.imageAtCursor,z,M0),p4=qZ({applyNextState:M0,editorState:z,editorStateRef:G,editorViewportState:c0,inputRef:U,keybindings:J,onActivity:h1.markActivity,onImagePaste:P.persistImage}),_1=tJ({applyNextState:M0,autoScrollDuringDrag:w,canvasRef:A,commentState:S0,editorStateRef:G,editorViewportState:c0,focusInput:p4.focus,onActivity:h1.markActivity,readCurrentState:a,resolvePoint:x0}),K9=_1.leaf?.kind==="comment"?_1.leaf.threadIndex:null,hZ=E2((j)=>{c(j),v1()}),l4=UZ({editorState:z,editorStateRef:G,editorViewportState:c0,onViewportScroll:hZ,scrollContainerRef:W2,scheduleOverlayRender:Q9,userPresence:A8}),d4=_Z({applyNextState:M0,autoScrollDuringDrag:w,canShowSelectionLeaf:u1,editorState:z,editorStateRef:G,editorViewportState:c0,focusInput:p4.focus,onActivity:h1.markActivity,resolvePoint:x0,threads:S0.threads}),F1=d4.handle??vZ;z2(()=>{v1()},[z.documentIndex,m0,W,y,v1,h4]),z2(()=>{Y9()},[B0.end.offset,B0.end.regionId,B0.start.offset,B0.start.regionId,Y9,g4.block?.blockId]),z2(()=>{G8()},[U8,S0.liveRanges,K9,G8]),z2(()=>{if(!F)return;let j=null,k=window,p=()=>{v1(),j=k.requestAnimationFrame(p)};return j=k.requestAnimationFrame(p),()=>{if(j!==null)k.cancelAnimationFrame(j)}},[F,v1]);let gZ=()=>{let j=_1.leaf,k=j??d4.leaf??h1.leaf,p=!j&&Boolean(d4.leaf),s=W2.current?.getBoundingClientRect()??null,t=k?.kind==="thread"?{...k,thread:S0.threads[k.threadIndex]??null}:null,J0=k?.kind==="comment"?{animateInitialComment:!1,link:k.link,thread:k.thread,threadIndex:k.threadIndex}:t?.thread?{animateInitialComment:t.animateInitialComment??!1,link:null,thread:t.thread,threadIndex:t.threadIndex}:null,r4=J0?.thread&&J1(J0.thread)?"resolved":"default";return{annotationThreadLeaf:J0,visibleLeaf:k,visibleLeafAnchor:k?{isSelection:p,left:(s?.left??0)+k.left,onPointerEnter:j?_1.leafHandlers.onPointerEnter:void 0,onPointerLeave:j?_1.leafHandlers.onPointerLeave:void 0,top:(s?.top??0)+k.top-q8+(p?xG:0)}:void 0,visibleLeafStatus:r4}},{annotationThreadLeaf:k0,visibleLeaf:V0,visibleLeafAnchor:D9,visibleLeafStatus:IZ}=gZ(),pZ=(()=>{if(!V0)return null;switch(V0.kind){case"insertion":return Q0(mJ,{onInsert:(j)=>{M0(M4(a(),j))},onInsertTable:(j)=>{M0(I7(a(),j))}});case"table":return Q0(gJ,{canDeleteColumn:V0.columnCount>1,canDeleteRow:V0.rowCount>1,onDeleteColumn:()=>{M0(l7(a()))},onDeleteRow:()=>{M0(r7(a()))},onDeleteTable:()=>{M0(x7(a()))},onInsertColumn:(j)=>{M0(p7(a(),j))},onInsertRow:(j)=>{M0(d7(a(),j))}});case"link":return Q0(vJ,{canEdit:u1,onDelete:()=>{let j=s7(a(),V0.regionId,V0.startOffset,V0.endOffset);if(j)M0(j)},onSave:(j)=>{let k=a7(a(),V0.regionId,V0.startOffset,V0.endOffset,j);if(k)M0(k)},title:V0.title,url:V0.url});case"create":return Q0(L3,{activeMarks:V0.activeMarks,canEdit:u1,link:null,mode:"create",mentionSources:k1,onCreateThread:(j)=>{let k=a(),p=p0(k).comments.length,s=n7(k,V0.selection,j.trim());if(!s)return;M0(s),d4.promoteLeafToThread(p,!0),M9(p)},onToggleBold:()=>{M0(k5(a()))},onToggleItalic:()=>{M0(u5(a()))},onToggleStrikethrough:()=>{M0(v5(a()))},onToggleUnderline:()=>{M0(h5(a()))}});default:return k0?Q0(L3,{animateInitialComment:k0.animateInitialComment,canEdit:u1,link:k0.link,mode:"thread",mentionSources:k1,onDeleteComment:(j)=>{let{threadIndex:k}=k0,p=a(),s=p0(p).comments[k],t=s?.comments[j],J0=$M(p,k,j);if(!J0)return;if(M0(J0),s&&t)J9(k,s,t)},onDeleteThread:()=>{let{threadIndex:j}=k0,k=a(),p=p0(k).comments[j],s=MM(k,j);if(!s)return;if(M0(s),p)for(let t of p.comments)J9(j,p,t)},onEditComment:(j,k)=>{let{threadIndex:p}=k0,s=a(),t=p0(s).comments[p]?.comments[j]?.body,J0=e7(s,p,j,k);if(!J0)return;if(M0(J0),t!==void 0)SZ(p,j,t)},onReply:(j)=>{let{threadIndex:k}=k0,p=t7(a(),k,j);if(!p)return;M0(p),M9(k)},onToggleResolved:()=>{M0(JM(a(),k0.threadIndex,!J1(k0.thread)))},thread:k0.thread}):null}})();z2(()=>{L(!0)},[]),z2(()=>{I4(z,N.current||b)},[b,z,I4,D8]),rG(()=>{if(M===_.current)return;let j=G.current,k=TZ(j,i2(B)),p=k.state,s=k.didReconcile?m():0;G.current=p,T(p),_.current=M,N.current=b,f0(s)},[b,M,B,m,f0]);let lZ=$?`documint ${$}`:"documint";return Q0(FJ,{themeStyles:R,children:Q8("section",{className:lZ,"data-active-block":f.activeBlockType??"","data-active-comment-thread":f.activeCommentThreadIndex??"","data-active-span":f.activeSpanKind??"",style:{...R,height:"100%",minHeight:0},children:[Q0("style",{children:CZ}),Q8("div",{...uZ,className:"documint-scroll-container",style:{height:"100%",minHeight:0},children:[Q0("textarea",{...p4.inputHandlers,ref:U,autoCapitalize:"sentences",className:"documint-input",spellCheck:!1,tabIndex:-1}),Q0(vM,{insetX:W.paddingX,insetY:W.paddingY,onSelect:l4.scrollToPresence,presence:l4.presence}),Q8("div",{...h.scrollContent,className:"documint-scroll-content",children:[Q0("canvas",{...p4.canvasHandlers,..._1.canvasHandlers,"aria-label":"Documint editor",className:"documint-content-canvas",style:{cursor:_1.cursor},ref:A,tabIndex:0}),Q0("canvas",{"aria-hidden":"true",className:"documint-overlay-canvas",ref:V}),F1&&Q8(cG,{children:[Q0("div",{"aria-hidden":"true",className:"documint-resize-handle",style:{left:`${F1.start.left}px`,top:`${F1.start.top}px`},...F1.start.props,children:Q0("span",{className:"documint-resize-handle-knob"})}),Q0("div",{"aria-hidden":"true",className:"documint-resize-handle",style:{left:`${F1.end.left}px`,top:`${F1.end.top}px`},...F1.end.props,children:Q0("span",{className:"documint-resize-handle-knob"})})]}),V0&&D9?Q0(SJ,{anchor:D9,status:IZ,children:pZ}):null]}),!E?Q0("div",{className:"documint-fallback",children:Q0(X8,{blocks:B.blocks})}):null]})]})})}function fZ($,M){let J=new Map($.documentIndex.regions.map((q,D)=>[q.id,D])),Z=Y8(J,$.selection.anchor.regionId,$.selection.anchor.offset),X=Y8(J,$.selection.focus.regionId,$.selection.focus.offset),[Y,Q]=Z<=X?[Z,X]:[X,Z],K=Z===X;for(let q of M){let D=Y8(J,q.regionId,q.startOffset),A=Y8(J,q.regionId,q.endOffset);if(K){if(Y>=D&&Y<=A)return q.threadIndex;continue}if(Math.max(Y,D)<Math.min(Q,A))return q.threadIndex}return null}function Y8($,M,J){return($.get(M)??-1)*1e6+J}export{FZ as mintTheme,HZ as midnightTheme,u4 as lightTheme,g3 as defaultKeybindings,v4 as darkTheme,mZ as Documint};
|